Marcel Taeumel uploaded a new version of FFI-Tools to project FFI:
http://source.squeak.org/FFI/FFI-Tools-mt.15.mcz
==================== Summary ====================
Name: FFI-Tools-mt.15
Author: mt
Time: 11 June 2020, 11:13:29.847059 am
UUID: ae1bb806-a075-a541-8e78-a93421394155
Ancestors: FFI-Tools-mt.14
Simplify support for C-string interpretation.
=============== Diff against FFI-Tools-mt.14 ===============
Item was changed:
----- Method: ExternalData>>explorerContentsStructFields (in category '*FFI-Tools') -----
explorerContentsStructFields
+ "In case some data interpretation omitted to convert char*, which is a (null-terminated) C string, to Smalltalk string."
+
+ ^ (self isNull not and: [type = ExternalType string]) ifFalse: [#()] ifTrue: [
-
- ^ (self isNull not and: [self mightBeCString]) ifFalse: [#()] ifTrue: [
{ObjectExplorerWrapper
+ with: self fromCString
- with: self fromCStringLimited
name: 'as C string'
model: self}]!
Item was removed:
- ----- Method: ExternalData>>fromCStringLimited (in category '*FFI-Tools') -----
- fromCStringLimited
-
- ^ self fromCStringLimitedTo: 50!
Item was removed:
- ----- Method: ExternalData>>fromCStringLimitedTo: (in category '*FFI-Tools') -----
- fromCStringLimitedTo: limit
- "Limit the number of characters to fetch in case this is no C string."
-
- | stream index char |
- type isPointerType ifFalse: [self error: 'External object is not a pointer type.'].
- stream := WriteStream on: String new.
- index := 1.
- [index > limit or: [(char := handle unsignedCharAt: index) = 0 asCharacter]] whileFalse: [
- stream nextPut: char.
- index := index + 1].
- ^stream contents!
Item was changed:
----- Method: ExternalData>>hasContentsInExplorer (in category '*FFI-Tools') -----
hasContentsInExplorer
^ super hasContentsInExplorer
+ or: [self isNull not and: [type = ExternalType string]]!
- or: [self isNull not and: [self mightBeCString]]!
Item was removed:
- ----- Method: ExternalData>>mightBeCString (in category '*FFI-Tools') -----
- mightBeCString
-
- ^ type isPointerType
- and: [(type instVarNamed: #referencedType) = ExternalType char]!
Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:
http://source.squeak.org/FFI/FFI-Kernel-mt.104.mcz
==================== Summary ====================
Name: FFI-Kernel-mt.104
Author: mt
Time: 11 June 2020, 10:55:09.189855 am
UUID: 4867f4c0-e2a0-3f45-8392-9445111c80c5
Ancestors: FFI-Kernel-mt.103
Adds lightweight aliases for 'long' and 'unsigned long' in C. Do not confuse it with Squeak FFI 'long', which is 'int' or rather 'int32_t'.
(We might want to add a warning for programmers that want to compile methods or struct fields using 'long' instead of 'c_long' or 'int32_t'. To help them think about the issue.)
=============== Diff against FFI-Kernel-mt.103 ===============
Item was added:
+ ----- Method: ExternalType class>>c_long (in category 'type constants - extra') -----
+ c_long
+ "Try to approximate a fitting type for 'long' in a C interface. First, note that this is not the same as 'long' in Squeak FFI, which is always 4 byte and hence corresponds to 'int' or rather 'int32_t' in C. Second, note that we do not want to expose the platforms underlying data model in Squeak because the OpenSmalltalk VM has no support for all kinds of architectures out there but only a popular subset such as x86-based ones. Still, this method is written to explicate the issue of different data models for 32-bit and 64-bit platforms."
+
+ | platform dataModel |
+ platform := FFIPlatformDescription current.
+ dataModel := platform wordSize = 4
+ ifTrue: ['ILP32']
+ ifFalse: [platform isWindows
+ ifTrue: ['LLP64']
+ ifFalse: ['LP64']].
+ ^ dataModel caseOf: {
+ ['ILP32'] -> [self int32_t].
+ ['LP64'] -> [self int64_t].
+ ['LLP64'] -> [self int32_t] }!
Item was added:
+ ----- Method: ExternalType class>>c_ulong (in category 'type constants - extra') -----
+ c_ulong
+ "Try to approximate a fitting type for 'usigned long' in a C interface. See comment in #c_long."
+
+ ^ self atomicTypeNamed: 'u', self c_long atomicTypeName!
David T. Lewis uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-dtl.1164.mcz
==================== Summary ====================
Name: System-dtl.1164
Author: dtl
Time: 8 June 2020, 9:16:15.619687 pm
UUID: f4d402cd-389a-4600-abcb-6ba4486c07c4
Ancestors: System-mt.1163
Fix handling of the '--' command line token, and let command parameters be handled consistently by SmalltalkImage>>argumentAt:
Discussion at http://lists.squeakfoundation.org/pipermail/squeak-dev/2020-June/209945.html
=============== Diff against System-mt.1163 ===============
Item was changed:
----- Method: SmalltalkImage>>argumentAt: (in category 'command line') -----
argumentAt: argumentIndex
"Answer the i-th argument of the command line, or nil if not so many argument."
+ ^ self arguments at: argumentIndex ifAbsent: [].
+ !
- ^ self getSystemAttribute:
- argumentIndex +
- (Preferences readDocumentAtStartup
- ifTrue: [ 2 ]
- ifFalse: [ 1 ])!
Item was changed:
----- Method: SmalltalkImage>>arguments (in category 'command line') -----
arguments
"Answer an array with all the command line arguments.
This does not include imagePath, documentPath nor any option."
"Smalltalk commandLine arguments"
+ | args strm |
+ args := self rawArguments.
+ (args includes: '--')
+ ifTrue: [ ^args copyAfter: self imageArgumentsMarker ].
+ strm := args readStream.
+ strm atEnd ifFalse: [ strm next. "skip image name"
+ strm atEnd ifFalse: [ strm next "skip startup document name" ] ].
+ ^ strm upToEnd.
+ !
- ^Array streamContents: [:str |
- | arg i |
- i := 1.
- [i > 998 or: [(arg := self argumentAt: i) == nil]]
- whileFalse:
- [str nextPut: arg.
- i := i + 1]].!
Item was changed:
----- Method: SmalltalkImage>>documentPath (in category 'command line') -----
documentPath
+ "Answer the absolute path of the document passed to the VM or nil if none."
- "Answer the absolute path of the document passed to the vm or nil if none."
"Smalltalk commandLine documentPath"
+ ^ (self getSystemAttribute: 2)
+ ifNotNil: [ :arg | arg = self imageArgumentsMarker
+ ifTrue: [nil] ifFalse: [arg]].
+
+ !
- ^ Preferences readDocumentAtStartup ifTrue: [ self getSystemAttribute: 2 ]!
Item was added:
+ ----- Method: SmalltalkImage>>imageArgumentsMarker (in category 'command line') -----
+ imageArgumentsMarker
+ "The '--' token on the command line indicates that remaining arguments should
+ be passed to the image without interpretation, and should not be treated as e.g.
+ specification of a start script."
+
+ ^ '--'!
Item was added:
+ ----- Method: SmalltalkImage>>rawArguments (in category 'command line') -----
+ rawArguments
+ "Answer an array with all the command line arguments as delivered
+ from the VM. Any arguments for the VM itself will have been removed
+ (these are accessed with optionAt:)."
+
+ "Smalltalk commandLine rawArguments"
+
+ ^Array streamContents: [:str |
+ | arg i |
+ i := 1.
+ [i > 998 or: [(arg := self getSystemAttribute: i) == nil]]
+ whileFalse:
+ [str nextPut: arg.
+ i := i + 1]].!
Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:
http://source.squeak.org/FFI/FFI-Kernel-mt.102.mcz
==================== Summary ====================
Name: FFI-Kernel-mt.102
Author: mt
Time: 10 June 2020, 6:16:11.229765 pm
UUID: 66dfe493-cd3f-d94f-98d8-6aed8a471f05
Ancestors: FFI-Kernel-mt.101
Fixes postload script.
=============== Diff against FFI-Kernel-mt.101 ===============
Item was changed:
(PackageInfo named: 'FFI-Kernel') postscript: 'Smalltalk removeFromStartUpList: ExternalAddress.
Smalltalk removeFromStartUpList: ExternalObject.
"Since #pointerSize in ExternalType is never nil anymore, make the code generated for fields more specific, i.e., #shortPointerAt:(put:) or #longPointerAt:(put:)."
+ ExternalType platformChangedFrom: FFIPlatformDescription empty to: FFIPlatformDescription current.
+ ExternalStructure platformChangedFrom: FFIPlatformDescription empty to: FFIPlatformDescription current.'!
- ExternalType platformChangedFrom: nil to: nil.
- ExternalStructure platformChangedFrom: nil to: nil.'!
Marcel Taeumel uploaded a new version of FFI-Tools to project FFI:
http://source.squeak.org/FFI/FFI-Tools-mt.14.mcz
==================== Summary ====================
Name: FFI-Tools-mt.14
Author: mt
Time: 10 June 2020, 6:11:23.992765 pm
UUID: 5cd9c909-5179-9b41-9d43-633764dc7e49
Ancestors: FFI-Tools-mt.13
Complements FFI-Kernel-mt.101
=============== Diff against FFI-Tools-mt.13 ===============
Item was changed:
----- Method: ExternalStructure>>explorerContentsMetaFields (in category '*FFI-Tools') -----
explorerContentsMetaFields
"Answer extra fields for the object explorer to show meta information about this structure."
^ {ObjectExplorerWrapper
+ with: self externalType
- with: (self class externalType ifNotNil: [:type |
- handle class == ExternalAddress ifTrue: [type asPointerType] ifFalse: [type]])
name: '_type'
model: self}!
Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:
http://source.squeak.org/FFI/FFI-Kernel-mt.101.mcz
==================== Summary ====================
Name: FFI-Kernel-mt.101
Author: mt
Time: 10 June 2020, 6:10:37.422765 pm
UUID: a5283cbb-1343-6f45-85c9-d434c38a88ac
Ancestors: FFI-Kernel-mt.100
Adds a mechanism for lightweight type aliases for atomic types by looking at the messages of ExternalType class for a referenced selector. This has entails no overhead for FFI calls, only a tiny one when compiling struct fields and methods that do FFI calls. Because that's when type names are looked up to find actual instances of ExternalType.
Adds such lightweight aliases for standard typedefs from stddef.h and stdint.h. This includes size_t (and similar), which makes a dynamic dispatch on the platform's #wordSize. Consequently, we have to re-compile all FFI calls when a platform change is detected, which now happens.
Adds more lightweight aliases to address the #ffiLongVsInt problem in Squeak FFI. You can now use 'int' and 'uint' etc. and it will correctly map to 'long' and 'ulong'. But you may be better off using 'int32_t' and 'uint32_t'; see above.
(Note that there is still no convenient alias for the platform-specific C long type yet.)
=============== Diff against FFI-Kernel-mt.100 ===============
Item was changed:
----- Method: ExternalStructure class>>platformChangedFrom:to: (in category 'system startup') -----
platformChangedFrom: lastPlatform to: currentPlatform
+ "The system is coming up on a new platform. Compile all field specs and install them in the respective struct types."
+
- "The system is coming up on a new platform. Clear out the existing handles."
self compileAllFields.!
Item was changed:
+ ----- Method: ExternalStructure>>externalType (in category 'accessing') -----
- ----- Method: ExternalStructure>>externalType (in category 'converting') -----
externalType
+ | type |
+ self flag: #ffiDesignSmell. "mt: Note that type aliases to pointer types store pointers via handle as ByteArray, not ExternalAddress."
+ type := self class externalType.
+ ^ handle class == ExternalAddress
+ ifTrue: [type asPointerType]
+ ifFalse: [type]!
- ^ self class externalType!
Item was added:
+ ----- Method: ExternalType class>>int (in category 'type constants') -----
+ int
+
+ self flag: #ffiLongVsInt.
+ ^ self long!
Item was added:
+ ----- Method: ExternalType class>>int16_t (in category 'type constants - stdint.h') -----
+ int16_t
+
+ ^ self signedShort!
Item was added:
+ ----- Method: ExternalType class>>int32_t (in category 'type constants - stdint.h') -----
+ int32_t
+
+ ^ self signedInt!
Item was added:
+ ----- Method: ExternalType class>>int64_t (in category 'type constants - stdint.h') -----
+ int64_t
+
+ ^ self signedLongLong!
Item was added:
+ ----- Method: ExternalType class>>int8_t (in category 'type constants - stdint.h') -----
+ int8_t
+
+ ^ self signedByte!
Item was added:
+ ----- Method: ExternalType class>>intptr_t (in category 'type constants - stddef.h') -----
+ intptr_t
+ "Answer a signed integer type that can hold a data pointer on the current platform, that is, 4-byte pointers on 32-bit und 8-byte pointers on 64-bit. Unlike actual C pointers (e.g., void*), you can do (pointer) arithmetic (e.g., #+) and bitwise manipulation (e.g., #bitOr:) on the resulting Smalltalk Integer objects.
+
+ Note that the equivalent type for a void* yields an instance if ExternalData, whose handle is an ExternalAddress, which actually impelements #+ as of June 2020. So, you can also do pointer arithmetic using that type.
+
+ Note that all FFI calls and struct types will be updated automatically on startup if a platform change is detected."
+
+ ^ FFIPlatformDescription current wordSize = 4
+ ifTrue: [self signedInt]
+ ifFalse: [self signedLongLong]!
Item was changed:
----- Method: ExternalType class>>long (in category 'type constants') -----
long
+
+ self flag: #ffiLongVsInt.
+ ^ self signedLong!
- ^self signedLong!
Item was added:
+ ----- Method: ExternalType class>>longlong (in category 'type constants') -----
+ longlong
+ ^ self signedLongLong!
Item was changed:
----- Method: ExternalType class>>platformChangedFrom:to: (in category 'system startup') -----
platformChangedFrom: lastPlatform to: currentPlatform
"Byte size or byte alignment for atomic types might be different on the new platform."
+ "1) Update all atomic types for platform-specifc byte size and alignment."
self initializeAtomicTypes.
+
+ "2) Discard all compiled specs for all structure types."
+ self initializeStructureTypes.
+
+ "3) Update all type-name mappings for all FFI calls."
+ lastPlatform wordSize ~= currentPlatform wordSize
+ ifTrue: [self recompileAllLibraryFunctions].!
- self initializeStructureTypes.!
Item was added:
+ ----- Method: ExternalType class>>ptrdiff_t (in category 'type constants - stddef.h') -----
+ ptrdiff_t
+
+ ^ self intptr_t!
Item was added:
+ ----- Method: ExternalType class>>recompileAllLibraryFunctions (in category 'housekeeping') -----
+ recompileAllLibraryFunctions
+ "Recompile all methods that do FFI calls (e.g. <apicall ... > or <cdecl ... >) to update all mappings from type name to atomic type and struct type. Note that unknown struct types will be created on-the-fly and can later be completed by defining fields in the particular structure class via #defineFields or #compileFields. Note that such a recompilation is especially useful if 'type constants' for atomic types to additional dispatch such as according to the current platform's #wordSize."
+
+ SystemNavigation default allSelectorsAndMethodsDo: [:behavior :selector :method |
+ method externalLibraryFunction ifNotNil: [behavior recompile: selector]].!
Item was changed:
----- Method: ExternalType class>>resetAllStructureTypes (in category 'housekeeping') -----
resetAllStructureTypes
"Warning: This call is only required if you change the container for StructTypes!! Note that (2) and (3) can be swapped but that puts unnecessary pressure on the GC."
StructTypes := nil.
"1) Initialize the container for structure types."
self initializeStructureTypes.
"2) Recompile all FFI calls to create and persist structure types."
+ self recompileAllLibraryFunctions.
- SystemNavigation default allSelectorsAndMethodsDo: [:behavior :selector :method |
- method externalLibraryFunction ifNotNil: [behavior recompile: selector]].
"3) Update all structure types' spec and alignment."
ExternalStructure compileAllFields.
!
Item was added:
+ ----- Method: ExternalType class>>signedInt (in category 'type constants') -----
+ signedInt
+
+ self flag: #ffiLongVsInt.
+ ^ self signedLong!
Item was changed:
----- Method: ExternalType class>>signedLong (in category 'type constants') -----
signedLong
+
+ self flag: #ffiLongVsInt.
^AtomicTypes at: 'long'!
Item was added:
+ ----- Method: ExternalType class>>size_t (in category 'type constants - stddef.h') -----
+ size_t
+
+ ^ self uintptr_t!
Item was changed:
----- Method: ExternalType class>>string (in category 'type constants') -----
string
+ ^ self char asPointerType!
- ^(AtomicTypes at: 'char') asPointerType!
Item was added:
+ ----- Method: ExternalType class>>uint (in category 'type constants') -----
+ uint
+
+ self flag: #ffiLongVsInt.
+ ^ self ulong!
Item was added:
+ ----- Method: ExternalType class>>uint16_t (in category 'type constants - stdint.h') -----
+ uint16_t
+
+ ^ self unsignedShort!
Item was added:
+ ----- Method: ExternalType class>>uint32_t (in category 'type constants - stdint.h') -----
+ uint32_t
+
+ ^ self unsignedInt!
Item was added:
+ ----- Method: ExternalType class>>uint64_t (in category 'type constants - stdint.h') -----
+ uint64_t
+
+ ^ self unsignedLongLong!
Item was added:
+ ----- Method: ExternalType class>>uint8_t (in category 'type constants - stdint.h') -----
+ uint8_t
+
+ ^ self unsignedByte!
Item was added:
+ ----- Method: ExternalType class>>uintptr_t (in category 'type constants - stddef.h') -----
+ uintptr_t
+ "Answer an unsigned integer type that can hold a data pointer on the current platform, that is, 4-byte pointers on 32-bit und 8-byte pointers on 64-bit. Unlike actual C pointers (e.g., void*), you can do (pointer) arithmetic (e.g., #+) and bitwise manipulation (e.g., #bitOr:) on the resulting Smalltalk Integer objects.
+
+ Note that the equivalent type for a void* yields an instance if ExternalData, whose handle is an ExternalAddress, which actually impelements #+ as of June 2020. So, you can also do pointer arithmetic using that type.
+
+ Note that all FFI calls and struct types will be updated automatically on startup if a platform change is detected."
+
+ ^ FFIPlatformDescription current wordSize = 4
+ ifTrue: [self unsignedInt]
+ ifFalse: [self unsignedLongLong]!
Item was changed:
----- Method: ExternalType class>>ulong (in category 'type constants') -----
ulong
+
+ self flag: #ffiLongVsInt.
+ ^ self unsignedLong!
- ^self unsignedLong!
Item was added:
+ ----- Method: ExternalType class>>ulonglong (in category 'type constants') -----
+ ulonglong
+ ^ self unsignedLongLong!
Item was added:
+ ----- Method: ExternalType class>>unsignedInt (in category 'type constants') -----
+ unsignedInt
+
+ self flag: #ffiLongVsInt.
+ ^ self unsignedLong!
Item was changed:
----- Method: ExternalType class>>unsignedLong (in category 'type constants') -----
unsignedLong
+
+ self flag: #ffiLongVsInt.
+ ^ AtomicTypes at: 'ulong'!
- ^AtomicTypes at: 'ulong'!
Marcel Taeumel uploaded a new version of Monticello to project The Trunk:
http://source.squeak.org/trunk/Monticello-mt.723.mcz
==================== Summary ====================
Name: Monticello-mt.723
Author: mt
Time: 9 June 2020, 4:25:51.863525 pm
UUID: c851a345-4eb8-1142-bf75-29e9a04ff2d9
Ancestors: Monticello-jr.722
Try to make CI on squeak-app pass again.
=============== Diff against Monticello-jr.722 ===============
Item was changed:
----- Method: MCHttpRepository>>clearCredentials (in category 'accessing') -----
clearCredentials
+ user beWritableObject.
user ifNotNil: [user atAllPut: $x].
+ password beWritableObject.
password ifNotNil: [password atAllPut: $x].
user := password := String empty!