Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:
http://source.squeak.org/FFI/FFI-Kernel-mt.150.mcz ==================== Summary ==================== Name: FFI-Kernel-mt.150 Author: mt Time: 16 May 2021, 7:29:44.888024 am UUID: d372abc2-2996-6949-be7e-2bfad84cfa4a Ancestors: FFI-Kernel-mt.149 Fixes support of void and void* in ExternalData. =============== Diff against FFI-Kernel-mt.149 =============== Item was added: + ----- Method: ExternalData>>arrayType (in category 'accessing - types') ----- + arrayType + "Answer this container's array type or 'nil' if unknown." + + | arrayType | + type ifNil: [^ nil]. + arrayType := self containerType asNonPointerType. + ^ arrayType isVoid + ifTrue: [nil] + ifFalse: [arrayType]! Item was changed: ----- Method: ExternalData>>contentType (in category 'accessing - types') ----- contentType "^ <ExternalType>" "Answer the content type for the current container type." + ^ self arrayType + ifNil: [ExternalType void] + ifNotNil: [:arrayType | arrayType contentType]! - ^ self containerType asNonPointerType contentType! Item was added: + ----- Method: ExternalData>>contentTypeCheck (in category 'private') ----- + contentTypeCheck + + self contentType isVoid ifTrue: [ + self error: 'You cannot do that for void content.'].! Item was changed: ----- Method: ExternalData>>setContentType: (in category 'initialize-release') ----- setContentType: externalType externalType = ExternalType string ifTrue: [ ^ self setContentType: externalType asNonPointerType]. + self setType: (externalType isVoid + ifTrue: [externalType "Size gets lost for void."] + ifFalse: [externalType asArrayType: self size]).! - self setType: (externalType asArrayType: self size).! Item was changed: ----- Method: ExternalData>>setSize: (in category 'initialize-release') ----- setSize: numElements "Set the size for the receiver, which will be used when enumerating its elements." + + self contentTypeCheck. - self setType: (self contentType asArrayType: numElements).! Item was changed: ----- Method: ExternalData>>setType: (in category 'private') ----- setType: externalType "Private. Set the type used to derive content and container types. If you want to change the content type later, use #setContentType:." - externalType isVoid ifTrue: [ - ^ self setType: externalType asPointerType]. externalType = ExternalType string ifTrue: [ ^ self setType: externalType asNonPointerType]. + (externalType asNonPointerType isArrayType or: [externalType isVoid]) - externalType asNonPointerType isArrayType ifTrue: [type := externalType] ifFalse: [type := (externalType asArrayType: nil)]. handle isExternalAddress ifTrue: [type := type asPointerType] ifFalse: [type := type asNonPointerType].! Item was changed: ----- Method: ExternalData>>size (in category 'accessing') ----- size + "Answer how many elements the receiver contains. Support void type." + + ^ self arrayType ifNotNil: [:arrayType | arrayType size]! - "Answer how many elements the receiver contains." - - ^ self containerType asNonPointerType size - ! Item was changed: ----- Method: ExternalData>>sizeCheck (in category 'private') ----- sizeCheck + self size ifNil: [self error: 'Size is unknown for this data'].! - self size ifNil: [self error: 'Size is unknown for this data pointer'].! Item was changed: ----- Method: ExternalData>>typeCheck (in category 'private') ----- typeCheck "Check type. If you happen to have a regular pointer type here, convert it into array type of unknown size. This can happen for result values of FFI calls if the signature did not specify, e.g., 'int[]' but 'int*'." + type asNonPointerType isVoid + ifTrue: [^ self]. + type asNonPointerType isArrayType ifFalse: [self setType: type "int*" asNonPointerType "int ... to become int[], not int*[]"].! |
Free forum by Nabble | Edit this page |