LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 16 Sep 2015 06:25:43 +0100
changeset 48 a5c898296427
parent 47 35c51ba4e4a7
child 49 307d55f736ec
LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions Make LLVMIsAXXX() functions to return bool instead of LLVMValueRef(). Make LLVMPrintXXXToString() functions to return generic pointer instead of char*
Cface__LLVM_C.st
--- a/Cface__LLVM_C.st	Mon Aug 17 10:04:39 2015 +0100
+++ b/Cface__LLVM_C.st	Wed Sep 16 06:25:43 2015 +0100
@@ -51,17 +51,36 @@
 definitions:definitionFile
     super definitions:definitionFile.
 
-    "/ A hack to map LLVMBool to #bool FFIT type
-
+    "/ A hack to map LLVMBool to #bool FFI type
     definitionFile definitions do:[:each | 
         (each isKindOf: CTypedefNode) ifTrue:[
             each cName = 'LLVMBool' ifTrue:[ 
                 each type: CBoolNode new 
             ].                                           
         ]
-    ]
+    ].
+    "/ A hack to change return type of all LLVMIsAXXX() functions
+    "/ to bool (this avoids an extra allocation & nil test)
+    definitionFile definitions do:[:each | 
+        (each isKindOf: CFunctionNode) ifTrue:[
+            (each cName startsWith: 'LLVMIsA') ifTrue:[
+                each return: CBoolNode new
+            ]
+        ]
+    ].
+    "/ A hack to make all LLVMPrintXXXToString() to return
+    "/ generic pointer. This is necessary as we need the pointer
+    "/ in Smalltalk code to later invoke LLVMDisposeMessage()
+    definitionFile definitions do:[:each | 
+        (each isKindOf: CFunctionNode) ifTrue:[
+            ((each cName startsWith: 'LLVMPrint') and:[each cName endsWith: 'ToString']) ifTrue:[
+                each return: (CPointerNode new type: (CPointerNode new type: CVoidNode new))
+            ]
+        ]
+    ].
 
     "Created: / 14-08-2015 / 11:13:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 16-09-2015 / 06:11:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 smalltalkPackage