class: ExternalStructure
added:
#fields
#generateCTypeFromFieldDescription:
changed: #sizeof
--- a/ExternalStructure.st Mon Feb 09 11:07:35 2015 +0100
+++ b/ExternalStructure.st Mon Feb 09 12:52:18 2015 +0100
@@ -11,6 +11,8 @@
"
"{ Package: 'stx:libbasic' }"
+"{ NameSpace: Smalltalk }"
+
ExternalBytes subclass:#ExternalStructure
instanceVariableNames:''
classVariableNames:''
@@ -113,15 +115,38 @@
^ cType
!
+fields
+ "for Squeak compatibility support: may return a literal array structure definition,
+ from which the size and layout of the fields can be constructed.
+ Returns nil for ST/X subclasses, which redefine the sizeof method"
+
+ ^ nil
+!
+
sizeof
"the sizeof my instances in bytes"
+ cType isNil ifTrue:[
+ "/ second chance for Squeak external structures
+ self fields notNil ifTrue:[
+ self generateCTypeFromFieldDescription:self fields.
+ ].
+ ].
cType notNil ifTrue:[
^ cType sizeof
].
self subclassResponsibility
! !
+!ExternalStructure class methodsFor:'utilities'!
+
+generateCTypeFromFieldDescription:fieldsSpec
+ "to support Squeak external structures, which define a fields method,
+ which returns a literal array spec of fields"
+
+ self halt.
+! !
+
!ExternalStructure methodsFor:'private'!
fromExternalAddress:anExternalAddress
@@ -131,10 +156,10 @@
!ExternalStructure class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalStructure.st,v 1.5 2013-01-28 18:04:13 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalStructure.st,v 1.6 2015-02-09 11:52:18 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalStructure.st,v 1.5 2013-01-28 18:04:13 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalStructure.st,v 1.6 2015-02-09 11:52:18 cg Exp $'
! !