USING: accessors alien.c-types alien.syntax classes
classes.struct compiler.units eval io.encodings.ascii kernel
math.constants tools.test ;
-FROM: alien.c-types => short ;
IN: alien.c-types.tests
CONSTANT: xyz 123
{ t } [ void* lookup-c-type pointer: opaque lookup-c-type = ] unit-test
[ opaque lookup-c-type ] [ no-c-type? ] must-fail-with
+! c-type-string
+{
+ "c-string[ascii]"
+ "foo*"
+ "int[5]"
+ "int**"
+ "MyFunkyString*"
+ "opaque*"
+} [
+ { c-string ascii } c-type-string
+ pointer: foo c-type-string
+ { int 5 } c-type-string
+ pointer: pointer: int c-type-string
+ pointer: MyFunkyString c-type-string
+ pointer: opaque c-type-string
+] unit-test
+
[ "
USING: alien.syntax ;
IN: alien.c-types.tests
]
[ error>> error>> redefine-error? ]
must-fail-with
+
+[
+ "IN: alien.c-types.tests
+ USE: alien.syntax
+ USE: alien.c-types
+ CALLBACK: void cb987 ( )
+ CALLBACK: void cb987 ( )" eval( -- )
+]
+[ error>> error>> redefine-error? ]
+must-fail-with
+
+[
+ "IN: alien.c-types.tests
+ USE: alien.syntax
+ USE: alien.c-types
+ FUNCTION: void func987 ( )
+ FUNCTION: void func987 ( )" eval( -- )
+]
+[ error>> error>> redefine-error? ]
+must-fail-with
+
+! generic -> callback
+"IN: alien.c-types.tests
+USE: alien.syntax
+USE: alien.c-types
+GENERIC: foo-func ( x -- )
+" eval( -- )
+
+"IN: alien.c-types.tests
+USE: alien.syntax
+USE: alien.c-types
+CALLBACK: void foo-func ( )
+" eval( -- )
+
+! generic -> typedef
+"IN: alien.c-types.tests
+USE: alien.syntax
+USE: alien.c-types
+GENERIC: foo-func ( x -- )
+" eval( -- )
+
+"IN: alien.c-types.tests
+USE: alien.syntax
+USE: alien.c-types
+TYPEDEF: void* foo-func
+" eval( -- )