FFI: FFI-Tools-mt.22.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

FFI: FFI-Tools-mt.22.mcz

commits-2
Marcel Taeumel uploaded a new version of FFI-Tools to project FFI:
http://source.squeak.org/FFI/FFI-Tools-mt.22.mcz

==================== Summary ====================

Name: FFI-Tools-mt.22
Author: mt
Time: 1 May 2021, 6:32:23.937408 pm
UUID: 6c3060d1-8b56-c74a-99be-d36a04e838cb
Ancestors: FFI-Tools-mt.21

Adds interface to enumerate fields (name and type) in structure types. Use that interface to show more structure in ObjectExplorer on such types.

I could not really decide on whether to prepend or append those new fields in the object explorer. For a larger structure type, you might have to scroll down to discover the basic "compiledSpec" etc. ...

=============== Diff against FFI-Tools-mt.21 ===============

Item was added:
+ ----- Method: ExternalStructureType>>allTypesDo:seen: (in category '*FFI-Tools-enumerating') -----
+ allTypesDo: aBlock seen: seenObjects
+ "Overridden to support cyclic typedefs."
+
+ (seenObjects ifAbsentAdd: self) ifFalse: [^ self].
+ super allTypesDo: aBlock seen: seenObjects.!

Item was changed:
  ----- Method: ExternalStructureType>>explorerContents (in category '*FFI-Tools') -----
  explorerContents
 
+ | basicExplorerFields originalTypeField fieldTypeFields |
- | basicExplorerFields originalTypeField |
  basicExplorerFields := super explorerContents.
+
+ self isTypeAlias ifTrue: [
+ originalTypeField := ObjectExplorerWrapper
+ with: self originalType
+ name: '_originalType'
+ model: self.
+ ^ {originalTypeField}, basicExplorerFields].
+
+ fieldTypeFields := Array streamContents: [:s |
+ self typesDo: [:type :fieldName |
+ s nextPut: (ObjectExplorerWrapper
+ with: type
+ name: (fieldName ifNil: ['__'] ifNotNil: ['_', fieldName])
+ model: self)]].
+
+ ^ fieldTypeFields, basicExplorerFields!
- self isTypeAlias ifFalse: [^ basicExplorerFields].
- originalTypeField := ObjectExplorerWrapper
- with: self originalType
- name: '_originalType'
- model: self.
- ^ {originalTypeField}, basicExplorerFields!

Item was added:
+ ----- Method: ExternalStructureType>>typesDo: (in category '*FFI-Tools-enumerating') -----
+ typesDo: block
+
+ self assert: [self isPointerType not].
+ self assert: [self referentClass notNil].
+
+ (self isTypeAlias
+ ifTrue: [
+ "Add a custom role to emphasize it in #allTypes."
+ {{#'_aliasFor' . self referentClass fields second}}]
+ ifFalse: [self referentClass fields])
+ do: [:spec |
+ | fieldName typeName type |
+ fieldName := spec first.
+ typeName := spec second.
+ type := ExternalType typeNamed: typeName.
+ block cull: type cull: fieldName].!

Item was added:
+ ----- Method: ExternalType>>allTypes (in category '*FFI-Tools-enumerating') -----
+ allTypes
+
+ ^ Array streamContents: [:s |
+ self allTypesDo: [:type :fieldName |
+ s nextPut: fieldName -> type]]!

Item was added:
+ ----- Method: ExternalType>>allTypesDo: (in category '*FFI-Tools-enumerating') -----
+ allTypesDo: block
+
+ self allTypesDo: block seen: IdentitySet new.!

Item was added:
+ ----- Method: ExternalType>>allTypesDo:seen: (in category '*FFI-Tools-enumerating') -----
+ allTypesDo: aBlock seen: seenObjects
+
+ self typesDo: [:type :fieldName |
+ aBlock cull: type cull: fieldName.
+ type allTypesDo: aBlock seen: seenObjects].!

Item was added:
+ ----- Method: ExternalType>>types (in category '*FFI-Tools-enumerating') -----
+ types
+
+ ^ Array streamContents: [:s |
+ self typesDo: [:type :fieldName | s nextPut: fieldName -> type]]!

Item was added:
+ ----- Method: ExternalType>>typesDo: (in category '*FFI-Tools-enumerating') -----
+ typesDo: block
+
+ self isPointerType
+ ifTrue: [ self asNonPointerType typesDo: block ]
+ ifFalse: [ "Atomic. There are no more types here." ].!