64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
i.e., for `int` generate #int FFI type, for `unsigned long long` generate #ulonglong FFI type,
--- a/Cface__CIntNode.st Mon Jul 06 23:08:04 2015 +0100
+++ b/Cface__CIntNode.st Wed Aug 12 07:49:03 2015 +0100
@@ -29,9 +29,9 @@
ffiTypeSymbol
"superclass Cface::CTypeNode says that I am responsible to implement this method"
- ^ #int32
+ ^ #int
- "Modified: / 12-07-2011 / 16:29:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 12-08-2015 / 07:40:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
smalltalkName
--- a/Cface__CLongNode.st Mon Jul 06 23:08:04 2015 +0100
+++ b/Cface__CLongNode.st Wed Aug 12 07:49:03 2015 +0100
@@ -39,11 +39,17 @@
!
ffiTypeSymbol
- "superclass Cface::CModifierNode says that I am responsible to implement this method"
+ type isCIntNode ifTrue:[
+ ^ #long.
+ ].
+ type isCLongNode ifTrue:[
+ type type isCIntNode ifTrue:[
+ ^ #longlong
+ ].
+ ].
+ self error: 'type invalid or not (yet) supported'
- ^ #long
-
- "Modified: / 12-07-2011 / 16:33:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 12-08-2015 / 07:45:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
stxStructFieldGetterSelector
@@ -59,6 +65,23 @@
"Created: / 30-05-2012 / 21:39:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!CLongNode methodsFor:'printing'!
+
+printOn: stream indent: indent
+ stream nextPutAll:'long '.
+ type printOn: stream indent: indent.
+
+ "Created: / 12-08-2015 / 07:42:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!CLongNode methodsFor:'testing'!
+
+isCLongNode
+ ^ true
+
+ "Created: / 12-08-2015 / 07:45:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!CLongNode methodsFor:'visiting'!
acceptVisitor:aVisitor
--- a/Cface__CTypedefNode.st Mon Jul 06 23:08:04 2015 +0100
+++ b/Cface__CTypedefNode.st Wed Aug 12 07:49:03 2015 +0100
@@ -4,7 +4,7 @@
CDerivedTypeNode subclass:#CTypedefNode
instanceVariableNames:'type'
- classVariableNames:''
+ classVariableNames:'C99IntTypes2FFITypes'
poolDictionaries:''
category:'Cface-C AST'
!
@@ -36,6 +36,28 @@
"Deleted: #name:id: / 19-11-2007 / 09:41:43 / haja"
! !
+!CTypedefNode class methodsFor:'initialization'!
+
+initialize
+ "Invoked at system start or when the class is dynamically loaded."
+
+ "/ please change as required (and remove this comment)
+
+ C99IntTypes2FFITypes := Dictionary withKeysAndValues:#(
+ int8_t sint8
+ int16_t sint16
+ int32_t sint32
+ int64_t sint64
+
+ uint8_t uint8
+ uint16_t uint16
+ uint32_t uint32
+ uint64_t uint64
+ )
+
+ "Modified: / 12-08-2015 / 07:38:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!CTypedefNode methodsFor:'accessing'!
cByteSize
@@ -46,13 +68,14 @@
!
ffiTypeSymbol
+ C99IntTypes2FFITypes at: cName ifPresent:[ :ffiType | ^ ffiType ].
type isCPointerToCStructure ifTrue:[
^ self smalltalkClassName ? #pointer
].
^ type ffiTypeSymbol
"Created: / 03-07-2008 / 22:40:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
- "Modified: / 06-07-2015 / 23:05:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 12-08-2015 / 07:39:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
type
@@ -116,3 +139,5 @@
^ '$Id$'
! !
+
+CTypedefNode initialize!
--- a/Cface__CUnsignedNode.st Mon Jul 06 23:08:04 2015 +0100
+++ b/Cface__CUnsignedNode.st Wed Aug 12 07:49:03 2015 +0100
@@ -38,15 +38,11 @@
!CUnsignedNode methodsFor:'printing'!
printOn: stream indent: indent
-
- stream
- nextPutAll:'unsigned ';
- cr;
- next: indent + 1 put: Character tab.
-
- type printOn: stream indent: indent + 1.
+ stream nextPutAll:'unsigned '.
+ type printOn: stream indent: indent.
"Created: / 04-03-2008 / 10:57:12 / janfrog"
+ "Modified: / 12-08-2015 / 07:42:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CUnsignedNode methodsFor:'testing'!