Marcel Taeumel uploaded a new version of FFI-Tools to project FFI:
http://source.squeak.org/FFI/FFI-Tools-mt.5.mcz ==================== Summary ==================== Name: FFI-Tools-mt.5 Author: mt Time: 20 May 2020, 6:32:54.913513 pm UUID: aea11f3a-7296-fe41-99a3-a9415b34bd44 Ancestors: FFI-Tools-mt.4 Better support for NULL pointers in both Inspector and ObjectExplorer. =============== Diff against FFI-Tools-mt.4 =============== Item was changed: ----- Method: ExternalData>>explorerContents (in category '*FFI-Tools') ----- explorerContents + ^ super explorerContents, ((self isNull not and: [self mightBeCString]) ifFalse: [#()] ifTrue: [ + {ObjectExplorerWrapper + with: self fromCStringLimited + name: 'as C string' + model: self}])! - ^ super explorerContents, ((type isPointerType and: [(type instVarNamed: #referencedType) = ExternalType char]) - ifTrue: [ - {ObjectExplorerWrapper - with: self fromCStringLimited - name: 'as C string' - model: self}] - ifFalse: [])! Item was changed: ----- Method: ExternalData>>hasContentsInExplorer (in category '*FFI-Tools') ----- hasContentsInExplorer + ^ super hasContentsInExplorer + or: [self isNull not and: [self mightBeCString]]! - ^ (type isPointerType and: [(type instVarNamed: #referencedType) = ExternalType char]) - or: [super hasContentsInExplorer]! Item was added: + ----- Method: ExternalData>>mightBeCString (in category '*FFI-Tools') ----- + mightBeCString + + ^ type isPointerType + and: [(type instVarNamed: #referencedType) = ExternalType char]! Item was added: + ----- Method: ExternalStructure class>>newNull (in category '*FFI-Tools') ----- + newNull + "Answer a NULL pointer to this structure. Note that #new virtually allocates a byte array in image, which then results in NULL values for the structure's fields. Note that #externalNew actually reserves memory for the structure through FFI, which then results in undefined behavior when exploring the results." + + ^ self fromHandle: ExternalAddress new! Item was changed: ----- Method: ExternalStructure>>explorerContents (in category '*FFI-Tools') ----- explorerContents | basicExplorerFields | basicExplorerFields := super explorerContents. basicExplorerFields do: [:explorerField | explorerField itemName: '_', explorerField itemName]. ^ basicExplorerFields, (self class allFieldSelectors replace: [:simpleGetter | ObjectExplorerWrapper + with: (self isNull ifFalse: [self perform: simpleGetter]) - with: (self perform: simpleGetter) name: simpleGetter model: self])! Item was changed: ----- Method: ExternalStructure>>hasContentsInExplorer (in category '*FFI-Tools') ----- hasContentsInExplorer + ^ super hasContentsInExplorer + or: [self class allFieldSelectors notEmpty]! - ^ self class allFieldSelectors notEmpty! Item was changed: ----- Method: ExternalStructureInspector>>streamRecordFieldsOn: (in category 'fields - streaming') ----- streamRecordFieldsOn: aStream self object class allFieldSelectors do: [:field | aStream nextPut: ((self newFieldForType: #record key: field) + valueGetter: [:object | object isNull ifFalse: [object perform: field]]; + valueSetter: [:object :value | object isNull ifFalse: [(field, ':') asSymbol with: value]]; - valueGetter: [:object | object perform: field]; - valueSetter: [:object :value | (field, ':') asSymbol with: value]; yourself)].! |
Free forum by Nabble | Edit this page |