2
0
Mark Sibly 9 жил өмнө
parent
commit
8b2986d897

+ 0 - 3
modules/chipmunk/c2mx2.json

@@ -3,9 +3,6 @@
 	
 	"outputFile":"chipmunk_extern.monkey2",
 	
-	"excludeFiles":[
-	],
-
 	"clangArgs":[
 		"-Xclang",
 		"-IChipmunk7/include"

+ 49 - 49
modules/chipmunk/chipmunk_extern.monkey2

@@ -56,7 +56,7 @@ End
 
 '***** File: Chipmunk7/include/chipmunk/cpVect.h *****
 
-Global cpvzero:cpVect
+Const cpvzero:cpVect
 Function cpv:cpVect( x:cpFloat, y:cpFloat )
 Function cpveql:cpBool( v1:cpVect, v2:cpVect )
 Function cpvadd:cpVect( v1:cpVect, v2:cpVect )
@@ -113,7 +113,7 @@ Function cpBBOffset:cpBB( bb:cpBB, v:cpVect )
 
 '***** File: Chipmunk7/include/chipmunk/cpTransform.h *****
 
-Global cpTransformIdentity:cpTransform
+Const cpTransformIdentity:cpTransform
 Function cpTransformNew:cpTransform( a:cpFloat, b:cpFloat, c:cpFloat, d:cpFloat, tx:cpFloat, ty:cpFloat )
 Function cpTransformNewTranspose:cpTransform( a:cpFloat, c:cpFloat, tx:cpFloat, b:cpFloat, d:cpFloat, ty:cpFloat )
 Function cpTransformInverse:cpTransform( t:cpTransform )
@@ -134,10 +134,10 @@ Function cpTransformAxialScale:cpTransform( axis:cpVect, pivot:cpVect, scale:cpF
 
 '***** File: Chipmunk7/include/chipmunk/cpSpatialIndex.h *****
 
-Alias cpSpatialIndexBBFunc:cpBB( Void Ptr ) 
-Alias cpSpatialIndexIteratorFunc:Void( Void Ptr, Void Ptr ) 
-Alias cpSpatialIndexQueryFunc:Int( Void Ptr, Void Ptr, cpCollisionID, Void Ptr ) 
-Alias cpSpatialIndexSegmentQueryFunc:Double( Void Ptr, Void Ptr, Void Ptr ) 
+Alias cpSpatialIndexBBFunc:cpBB( Void Ptr )
+Alias cpSpatialIndexIteratorFunc:Void( Void Ptr, Void Ptr )
+Alias cpSpatialIndexQueryFunc:cpCollisionID( Void Ptr, Void Ptr, cpCollisionID, Void Ptr )
+Alias cpSpatialIndexSegmentQueryFunc:cpFloat( Void Ptr, Void Ptr, Void Ptr )
 Struct cpSpatialIndex
 	Field klass:cpSpatialIndexClass Ptr
 	Field bbfunc:cpSpatialIndexBBFunc
@@ -152,22 +152,22 @@ Function cpBBTreeAlloc:cpBBTree Ptr(  )
 Function cpBBTreeInit:cpSpatialIndex Ptr( tree:cpBBTree Ptr, bbfunc:cpSpatialIndexBBFunc, staticIndex:cpSpatialIndex Ptr )
 Function cpBBTreeNew:cpSpatialIndex Ptr( bbfunc:cpSpatialIndexBBFunc, staticIndex:cpSpatialIndex Ptr )
 Function cpBBTreeOptimize:Void( index:cpSpatialIndex Ptr )
-Alias cpBBTreeVelocityFunc:cpVect( Void Ptr ) 
+Alias cpBBTreeVelocityFunc:cpVect( Void Ptr )
 Function cpBBTreeSetVelocityFunc:Void( index:cpSpatialIndex Ptr, func:cpBBTreeVelocityFunc )
 Function cpSweep1DAlloc:cpSweep1D Ptr(  )
 Function cpSweep1DInit:cpSpatialIndex Ptr( sweep:cpSweep1D Ptr, bbfunc:cpSpatialIndexBBFunc, staticIndex:cpSpatialIndex Ptr )
 Function cpSweep1DNew:cpSpatialIndex Ptr( bbfunc:cpSpatialIndexBBFunc, staticIndex:cpSpatialIndex Ptr )
-Alias cpSpatialIndexDestroyImpl:Void( cpSpatialIndex Ptr ) 
-Alias cpSpatialIndexCountImpl:Int( cpSpatialIndex Ptr ) 
-Alias cpSpatialIndexEachImpl:Void( cpSpatialIndex Ptr, cpSpatialIndexIteratorFunc, Void Ptr ) 
-Alias cpSpatialIndexContainsImpl:UByte( cpSpatialIndex Ptr, Void Ptr, cpHashValue ) 
-Alias cpSpatialIndexInsertImpl:Void( cpSpatialIndex Ptr, Void Ptr, cpHashValue ) 
-Alias cpSpatialIndexRemoveImpl:Void( cpSpatialIndex Ptr, Void Ptr, cpHashValue ) 
-Alias cpSpatialIndexReindexImpl:Void( cpSpatialIndex Ptr ) 
-Alias cpSpatialIndexReindexObjectImpl:Void( cpSpatialIndex Ptr, Void Ptr, cpHashValue ) 
-Alias cpSpatialIndexReindexQueryImpl:Void( cpSpatialIndex Ptr, cpSpatialIndexQueryFunc, Void Ptr ) 
-Alias cpSpatialIndexQueryImpl:Void( cpSpatialIndex Ptr, Void Ptr, cpBB, cpSpatialIndexQueryFunc, Void Ptr ) 
-Alias cpSpatialIndexSegmentQueryImpl:Void( cpSpatialIndex Ptr, Void Ptr, cpVect, cpVect, cpFloat, cpSpatialIndexSegmentQueryFunc, Void Ptr ) 
+Alias cpSpatialIndexDestroyImpl:Void( cpSpatialIndex Ptr )
+Alias cpSpatialIndexCountImpl:Int( cpSpatialIndex Ptr )
+Alias cpSpatialIndexEachImpl:Void( cpSpatialIndex Ptr, cpSpatialIndexIteratorFunc, Void Ptr )
+Alias cpSpatialIndexContainsImpl:cpBool( cpSpatialIndex Ptr, Void Ptr, cpHashValue )
+Alias cpSpatialIndexInsertImpl:Void( cpSpatialIndex Ptr, Void Ptr, cpHashValue )
+Alias cpSpatialIndexRemoveImpl:Void( cpSpatialIndex Ptr, Void Ptr, cpHashValue )
+Alias cpSpatialIndexReindexImpl:Void( cpSpatialIndex Ptr )
+Alias cpSpatialIndexReindexObjectImpl:Void( cpSpatialIndex Ptr, Void Ptr, cpHashValue )
+Alias cpSpatialIndexReindexQueryImpl:Void( cpSpatialIndex Ptr, cpSpatialIndexQueryFunc, Void Ptr )
+Alias cpSpatialIndexQueryImpl:Void( cpSpatialIndex Ptr, Void Ptr, cpBB, cpSpatialIndexQueryFunc, Void Ptr )
+Alias cpSpatialIndexSegmentQueryImpl:Void( cpSpatialIndex Ptr, Void Ptr, cpVect, cpVect, cpFloat, cpSpatialIndexSegmentQueryFunc, Void Ptr )
 Struct cpSpatialIndexClass
 	Field destroy:cpSpatialIndexDestroyImpl
 	Field count:cpSpatialIndexCountImpl
@@ -239,8 +239,8 @@ End
 Const CP_BODY_TYPE_DYNAMIC:cpBodyType
 Const CP_BODY_TYPE_KINEMATIC:cpBodyType
 Const CP_BODY_TYPE_STATIC:cpBodyType
-Alias cpBodyVelocityFunc:Void( cpBody Ptr, cpVect, cpFloat, cpFloat ) 
-Alias cpBodyPositionFunc:Void( cpBody Ptr, cpFloat ) 
+Alias cpBodyVelocityFunc:Void( cpBody Ptr, cpVect, cpFloat, cpFloat )
+Alias cpBodyPositionFunc:Void( cpBody Ptr, cpFloat )
 Function cpBodyAlloc:cpBody Ptr(  )
 Function cpBodyInit:cpBody Ptr( body:cpBody Ptr, mass:cpFloat, moment:cpFloat )
 Function cpBodyNew:cpBody Ptr( mass:cpFloat, moment:cpFloat )
@@ -290,11 +290,11 @@ Function cpBodyApplyImpulseAtLocalPoint:Void( body:cpBody Ptr, impulse:cpVect, p
 Function cpBodyGetVelocityAtWorldPoint:cpVect( body:cpBody Ptr, point:cpVect )
 Function cpBodyGetVelocityAtLocalPoint:cpVect( body:cpBody Ptr, point:cpVect )
 Function cpBodyKineticEnergy:cpFloat( body:cpBody Ptr )
-Alias cpBodyShapeIteratorFunc:Void( cpBody Ptr, cpShape Ptr, Void Ptr ) 
+Alias cpBodyShapeIteratorFunc:Void( cpBody Ptr, cpShape Ptr, Void Ptr )
 Function cpBodyEachShape:Void( body:cpBody Ptr, func:cpBodyShapeIteratorFunc, data:Void Ptr )
-Alias cpBodyConstraintIteratorFunc:Void( cpBody Ptr, cpConstraint Ptr, Void Ptr ) 
+Alias cpBodyConstraintIteratorFunc:Void( cpBody Ptr, cpConstraint Ptr, Void Ptr )
 Function cpBodyEachConstraint:Void( body:cpBody Ptr, func:cpBodyConstraintIteratorFunc, data:Void Ptr )
-Alias cpBodyArbiterIteratorFunc:Void( cpBody Ptr, cpArbiter Ptr, Void Ptr ) 
+Alias cpBodyArbiterIteratorFunc:Void( cpBody Ptr, cpArbiter Ptr, Void Ptr )
 Function cpBodyEachArbiter:Void( body:cpBody Ptr, func:cpBodyArbiterIteratorFunc, data:Void Ptr )
 
 '***** File: Chipmunk7/include/chipmunk/cpShape.h *****
@@ -316,8 +316,8 @@ Struct cpShapeFilter
 	Field categories:cpBitmask
 	Field mask:cpBitmask
 End
-Global CP_SHAPE_FILTER_ALL:cpShapeFilter
-Global CP_SHAPE_FILTER_NONE:cpShapeFilter
+Const CP_SHAPE_FILTER_ALL:cpShapeFilter
+Const CP_SHAPE_FILTER_NONE:cpShapeFilter
 Function cpShapeFilterNew:cpShapeFilter( group:cpGroup, categories:cpBitmask, mask:cpBitmask )
 Function cpShapeDestroy:Void( shape:cpShape Ptr )
 Function cpShapeFree:Void( shape:cpShape Ptr )
@@ -382,8 +382,8 @@ Function cpPolyShapeGetRadius:cpFloat( shape:cpShape Ptr )
 
 '***** File: Chipmunk7/include/chipmunk/cpConstraint.h *****
 
-Alias cpConstraintPreSolveFunc:Void( cpConstraint Ptr, cpSpace Ptr ) 
-Alias cpConstraintPostSolveFunc:Void( cpConstraint Ptr, cpSpace Ptr ) 
+Alias cpConstraintPreSolveFunc:Void( cpConstraint Ptr, cpSpace Ptr )
+Alias cpConstraintPostSolveFunc:Void( cpConstraint Ptr, cpSpace Ptr )
 Function cpConstraintDestroy:Void( constraint:cpConstraint Ptr )
 Function cpConstraintFree:Void( constraint:cpConstraint Ptr )
 Function cpConstraintGetSpace:cpSpace Ptr( constraint:cpConstraint Ptr )
@@ -461,7 +461,7 @@ Function cpGrooveJointSetAnchorB:Void( constraint:cpConstraint Ptr, anchorB:cpVe
 '***** File: Chipmunk7/include/chipmunk/cpDampedSpring.h *****
 
 Function cpConstraintIsDampedSpring:cpBool( constraint:cpConstraint Ptr )
-Alias cpDampedSpringForceFunc:Double( cpConstraint Ptr, cpFloat ) 
+Alias cpDampedSpringForceFunc:cpFloat( cpConstraint Ptr, cpFloat )
 Function cpDampedSpringAlloc:cpDampedSpring Ptr(  )
 Function cpDampedSpringInit:cpDampedSpring Ptr( joint:cpDampedSpring Ptr, a:cpBody Ptr, b:cpBody Ptr, anchorA:cpVect, anchorB:cpVect, restLength:cpFloat, stiffness:cpFloat, damping:cpFloat )
 Function cpDampedSpringNew:cpConstraint Ptr( a:cpBody Ptr, b:cpBody Ptr, anchorA:cpVect, anchorB:cpVect, restLength:cpFloat, stiffness:cpFloat, damping:cpFloat )
@@ -481,7 +481,7 @@ Function cpDampedSpringSetSpringForceFunc:Void( constraint:cpConstraint Ptr, spr
 '***** File: Chipmunk7/include/chipmunk/cpDampedRotarySpring.h *****
 
 Function cpConstraintIsDampedRotarySpring:cpBool( constraint:cpConstraint Ptr )
-Alias cpDampedRotarySpringTorqueFunc:Double( cpConstraint Ptr, cpFloat ) 
+Alias cpDampedRotarySpringTorqueFunc:cpFloat( cpConstraint Ptr, cpFloat )
 Function cpDampedRotarySpringAlloc:cpDampedRotarySpring Ptr(  )
 Function cpDampedRotarySpringInit:cpDampedRotarySpring Ptr( joint:cpDampedRotarySpring Ptr, a:cpBody Ptr, b:cpBody Ptr, restAngle:cpFloat, stiffness:cpFloat, damping:cpFloat )
 Function cpDampedRotarySpringNew:cpConstraint Ptr( a:cpBody Ptr, b:cpBody Ptr, restAngle:cpFloat, stiffness:cpFloat, damping:cpFloat )
@@ -540,10 +540,10 @@ Function cpSimpleMotorSetRate:Void( constraint:cpConstraint Ptr, rate:cpFloat )
 
 '***** File: Chipmunk7/include/chipmunk/cpSpace.h *****
 
-Alias cpCollisionBeginFunc:UByte( cpArbiter Ptr, cpSpace Ptr, cpDataPointer ) 
-Alias cpCollisionPreSolveFunc:UByte( cpArbiter Ptr, cpSpace Ptr, cpDataPointer ) 
-Alias cpCollisionPostSolveFunc:Void( cpArbiter Ptr, cpSpace Ptr, cpDataPointer ) 
-Alias cpCollisionSeparateFunc:Void( cpArbiter Ptr, cpSpace Ptr, cpDataPointer ) 
+Alias cpCollisionBeginFunc:cpBool( cpArbiter Ptr, cpSpace Ptr, cpDataPointer )
+Alias cpCollisionPreSolveFunc:cpBool( cpArbiter Ptr, cpSpace Ptr, cpDataPointer )
+Alias cpCollisionPostSolveFunc:Void( cpArbiter Ptr, cpSpace Ptr, cpDataPointer )
+Alias cpCollisionSeparateFunc:Void( cpArbiter Ptr, cpSpace Ptr, cpDataPointer )
 Struct cpCollisionHandler
 	Field typeA:cpCollisionType
 	Field typeB:cpCollisionType
@@ -591,23 +591,23 @@ Function cpSpaceRemoveConstraint:Void( space:cpSpace Ptr, constraint:cpConstrain
 Function cpSpaceContainsShape:cpBool( space:cpSpace Ptr, shape:cpShape Ptr )
 Function cpSpaceContainsBody:cpBool( space:cpSpace Ptr, body:cpBody Ptr )
 Function cpSpaceContainsConstraint:cpBool( space:cpSpace Ptr, constraint:cpConstraint Ptr )
-Alias cpPostStepFunc:Void( cpSpace Ptr, Void Ptr, Void Ptr ) 
+Alias cpPostStepFunc:Void( cpSpace Ptr, Void Ptr, Void Ptr )
 Function cpSpaceAddPostStepCallback:cpBool( space:cpSpace Ptr, func:cpPostStepFunc, key:Void Ptr, data:Void Ptr )
-Alias cpSpacePointQueryFunc:Void( cpShape Ptr, cpVect, cpFloat, cpVect, Void Ptr ) 
+Alias cpSpacePointQueryFunc:Void( cpShape Ptr, cpVect, cpFloat, cpVect, Void Ptr )
 Function cpSpacePointQuery:Void( space:cpSpace Ptr, point:cpVect, maxDistance:cpFloat, filter:cpShapeFilter, func:cpSpacePointQueryFunc, data:Void Ptr )
 Function cpSpacePointQueryNearest:cpShape Ptr( space:cpSpace Ptr, point:cpVect, maxDistance:cpFloat, filter:cpShapeFilter, out:cpPointQueryInfo Ptr )
-Alias cpSpaceSegmentQueryFunc:Void( cpShape Ptr, cpVect, cpVect, cpFloat, Void Ptr ) 
+Alias cpSpaceSegmentQueryFunc:Void( cpShape Ptr, cpVect, cpVect, cpFloat, Void Ptr )
 Function cpSpaceSegmentQuery:Void( space:cpSpace Ptr, start:cpVect, end_:cpVect, radius:cpFloat, filter:cpShapeFilter, func:cpSpaceSegmentQueryFunc, data:Void Ptr )
 Function cpSpaceSegmentQueryFirst:cpShape Ptr( space:cpSpace Ptr, start:cpVect, end_:cpVect, radius:cpFloat, filter:cpShapeFilter, out:cpSegmentQueryInfo Ptr )
-Alias cpSpaceBBQueryFunc:Void( cpShape Ptr, Void Ptr ) 
+Alias cpSpaceBBQueryFunc:Void( cpShape Ptr, Void Ptr )
 Function cpSpaceBBQuery:Void( space:cpSpace Ptr, bb:cpBB, filter:cpShapeFilter, func:cpSpaceBBQueryFunc, data:Void Ptr )
-Alias cpSpaceShapeQueryFunc:Void( cpShape Ptr, cpContactPointSet Ptr, Void Ptr ) 
+Alias cpSpaceShapeQueryFunc:Void( cpShape Ptr, cpContactPointSet Ptr, Void Ptr )
 Function cpSpaceShapeQuery:cpBool( space:cpSpace Ptr, shape:cpShape Ptr, func:cpSpaceShapeQueryFunc, data:Void Ptr )
-Alias cpSpaceBodyIteratorFunc:Void( cpBody Ptr, Void Ptr ) 
+Alias cpSpaceBodyIteratorFunc:Void( cpBody Ptr, Void Ptr )
 Function cpSpaceEachBody:Void( space:cpSpace Ptr, func:cpSpaceBodyIteratorFunc, data:Void Ptr )
-Alias cpSpaceShapeIteratorFunc:Void( cpShape Ptr, Void Ptr ) 
+Alias cpSpaceShapeIteratorFunc:Void( cpShape Ptr, Void Ptr )
 Function cpSpaceEachShape:Void( space:cpSpace Ptr, func:cpSpaceShapeIteratorFunc, data:Void Ptr )
-Alias cpSpaceConstraintIteratorFunc:Void( cpConstraint Ptr, Void Ptr ) 
+Alias cpSpaceConstraintIteratorFunc:Void( cpConstraint Ptr, Void Ptr )
 Function cpSpaceEachConstraint:Void( space:cpSpace Ptr, func:cpSpaceConstraintIteratorFunc, data:Void Ptr )
 Function cpSpaceReindexStatic:Void( space:cpSpace Ptr )
 Function cpSpaceReindexShape:Void( space:cpSpace Ptr, shape:cpShape Ptr )
@@ -620,12 +620,12 @@ Struct cpSpaceDebugColor
 	Field b:Float
 	Field a:Float
 End
-Alias cpSpaceDebugDrawCircleImpl:Void( cpVect, cpFloat, cpFloat, cpSpaceDebugColor, cpSpaceDebugColor, cpDataPointer ) 
-Alias cpSpaceDebugDrawSegmentImpl:Void( cpVect, cpVect, cpSpaceDebugColor, cpDataPointer ) 
-Alias cpSpaceDebugDrawFatSegmentImpl:Void( cpVect, cpVect, cpFloat, cpSpaceDebugColor, cpSpaceDebugColor, cpDataPointer ) 
-Alias cpSpaceDebugDrawPolygonImpl:Void( Int, cpVect Ptr, cpFloat, cpSpaceDebugColor, cpSpaceDebugColor, cpDataPointer ) 
-Alias cpSpaceDebugDrawDotImpl:Void( cpFloat, cpVect, cpSpaceDebugColor, cpDataPointer ) 
-Alias cpSpaceDebugDrawColorForShapeImpl:cpSpaceDebugColor( cpShape Ptr, cpDataPointer ) 
+Alias cpSpaceDebugDrawCircleImpl:Void( cpVect, cpFloat, cpFloat, cpSpaceDebugColor, cpSpaceDebugColor, cpDataPointer )
+Alias cpSpaceDebugDrawSegmentImpl:Void( cpVect, cpVect, cpSpaceDebugColor, cpDataPointer )
+Alias cpSpaceDebugDrawFatSegmentImpl:Void( cpVect, cpVect, cpFloat, cpSpaceDebugColor, cpSpaceDebugColor, cpDataPointer )
+Alias cpSpaceDebugDrawPolygonImpl:Void( Int, cpVect Ptr, cpFloat, cpSpaceDebugColor, cpSpaceDebugColor, cpDataPointer )
+Alias cpSpaceDebugDrawDotImpl:Void( cpFloat, cpVect, cpSpaceDebugColor, cpDataPointer )
+Alias cpSpaceDebugDrawColorForShapeImpl:cpSpaceDebugColor( cpShape Ptr, cpDataPointer )
 Enum cpSpaceDebugDrawFlags
 End
 Const CP_SPACE_DEBUG_DRAW_SHAPES:cpSpaceDebugDrawFlags
@@ -648,7 +648,7 @@ Function cpSpaceDebugDraw:Void( space:cpSpace Ptr, options:cpSpaceDebugDrawOptio
 
 '***** File: Chipmunk7/include/chipmunk/chipmunk.h *****
 
-Global cpVersionString:libc.const_char_t Ptr
+Global cpVersionString:CString
 Function cpMomentForCircle:cpFloat( m:cpFloat, r1:cpFloat, r2:cpFloat, offset:cpVect )
 Function cpAreaForCircle:cpFloat( r1:cpFloat, r2:cpFloat )
 Function cpMomentForSegment:cpFloat( m:cpFloat, a:cpVect, b:cpVect, radius:cpFloat )
@@ -710,4 +710,4 @@ End
 Struct cpSpaceHash
 End
 Struct cpSweep1D
-End
+End

+ 0 - 63
modules/mojox/tests/theme_test.monkey2

@@ -1,63 +0,0 @@
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojox>"
-
-#Import "assets/simple_theme.json"
-
-Using std..
-Using mojo..
-Using mojox..
-
-Class MyWindow Extends Window
-
-	Method New()
-		Super.New( "Theme Demo",640,480,WindowFlags.Resizable )
-		
-		Local theme1:=App.Theme
-		Local theme2:=Theme.Load( "asset::simple_theme.json" )
-		
-		App.Theme=theme2
-
-		ClearColor=App.Theme.GetColor( "windowClearColor" )
-		
-		New Fiber( Lambda()
-		
-			Repeat
-			
-				Alert( "Click me to change theme!" )
-				
-				App.Theme=App.Theme=theme1 ? theme2 Else theme1
-
-				ClearColor=App.Theme.GetColor( "windowClearColor" )
-			
-			Forever
-
-		End )
-		
-		App.Idle+=OnIdle
-	End
-	
-	Method OnIdle()
-	
-		App.RequestRender()
-		
-		App.Idle+=OnIdle
-	End
-
-End
-
-
-Function Main()
-
-	Local config:=New StringMap<String>
-	
-'	config["initialTheme"]="asset::simple_theme.json"
-
-	New AppInstance( config )
-	
-	New MyWindow
-	
-	App.Run()
-End
-

+ 52 - 0
src/c2mx2/README.TXT

@@ -0,0 +1,52 @@
+
+***** SETUP *****
+
+You will need to install LLVM binaries into c2mx2/LLVM directory:
+
+http://llvm.org/releases/download.html
+
+For windows, use 32 bit binaries.
+
+You will also need mingw-64 in your system PATH.
+
+To launch, just run src/c2mx2/c2mx2.monkey2 from inside Ted2.
+
+There are some sample cmx2.json config files in the chipmunk and sqlite module dirs.
+
+
+***** USAGE *****
+
+C2mx2 is a simple C header to Monkey2 'Extern' convertor that uses the libclang library.
+
+When you run C2mx2, you will be prompted for a json config file. Once selected, conversion will start. The config file should contain:
+
+"inputFile" (string) The 'root' file to convert.
+
+"outputFile" (string) The output monkey2 file.
+
+"clangArgs" (string array) array of clang cmd line arguments.
+
+"includeFiles" (string array) array of files to process. If missing, all files are processed. Mutually exclusive with "excludeFiles".
+
+"excludeFiles" (string array) array of files to ignore. If missing, no files are ignored. Mutually exclusive with "includeFiles".
+
+"cstringTypes" (string array) Array of C types to treat as Monkey2 CString types. Each element must be one of: "const char *", "const signed char *", "const unsigned char *", "char *", "signed char *", "unsigned char *". If missing, defaults to ["const char *"].
+
+"anonEnumType" (string) Monkey2 type to use for anonymous enums, defaults to "Int".
+
+"externStructs" (string array) Array of 'undeclared' structs that are referenced but not defined in C code. C2mx2 will create 'empty' structs for each of these unless it finds a definition for them somewhere in the C code.
+
+"header" (string array) Array of lines to emit at the top of the output code.
+
+"footer" (string array) Array of lines to emit at the bottom of the output code.
+
+
+***** LIMITATIONS *****
+
+* Can't do C++.
+
+* Can't do #define's.
+
+* Can't do structs in structs.
+
+* C2mx2 tries its best, but monkey2 is NOT C and there may be some things that need tweaking in the output file.

+ 189 - 124
src/c2mx2/c2mx2.monkey2

@@ -1,17 +1,7 @@
 
 #rem
 
-A very much WIP C->MX2 'Extern' generator based on 'libclang'. However, it did libclang itself and chipmunk nicely.
-
-This wont work 'as is' - you'll need to copy LLVM binaries to this dir (inside a LLVM dir). LLVM binaries are here:
-
-http://llvm.org/releases/download.html
-
-You'll probably also need mingw-64 in your system PATH.
-
-Use 32 bit binaries for Windows.
-
-Only tested on Windows.
+See README.TXT
 
 #end
 
@@ -44,6 +34,7 @@ Global ExcludeFiles:StringMap<Bool>
 
 Global ext_structs:=New StringMap<Bool>
 Global def_structs:=New StringMap<Bool>
+Global cstring_types:=New StringMap<Bool>
 
 Global Keywords:StringMap<String>
 
@@ -75,6 +66,13 @@ Function InitKeywords()
 	Next
 End
 
+Function SetFile( file:String )
+	If file=CurrentFile Return
+	CurrentFile=file
+	buf.Push( "~n'***** File: "+CurrentFile+" *****~n" )
+	Print "Processing:"+file
+End
+
 Struct CXString Extension
 	Method To:String()
 		Return ToString( Self )
@@ -82,10 +80,9 @@ Struct CXString Extension
 End
 
 Function ToString:String( str:CXString )
-	Local p:=clang_getCString( str )
-	Local t:=String.FromCString( p )
+	Local cstr:=clang_getCString( str )
 	clang_disposeString( str )
-	Return t
+	Return cstr
 End
 
 Function ToCString:const_char_t Ptr( str:String )
@@ -107,42 +104,77 @@ Function Err( err:String,cursor:CXCursor )
 	Print ErrInfo( cursor )+" : "+err
 End
 
-Function TypeName:String( type:CXType )
+Function CursorSpelling:String( cursor:CXCursor )
 
-	Local ctype:=String( clang_getTypeSpelling( type ) )
-	If ctype.Contains( "(anonymous" ) Return ""
+	Local id:=String( clang_getCursorSpelling( cursor ) )
 	
-	If ctype.StartsWith( "const " ) 
+	If Keywords.Contains( id ) id+="_"
 	
-		ctype=ctype.Slice( 6 )
-		If ctype.EndsWith( " &" ) ctype=ctype.Slice( 0,-2 )
-		
-	Else If ctype.EndsWith( " &" )
+	Return id
+End
+
+Function TypeSpelling:String( type:CXType )
+
+	Local id:=String( clang_getTypeSpelling( type ) )
 	
-		Print "Error: non-const reference type"
-		Return ""
-	Endif
+	If id.Contains( "(anonymous" ) Return ""
+	
+	If id.StartsWith( "const " ) id=id.Slice( 6 )
 	
-	If ctype.StartsWith( "struct " )
-		ctype=ctype.Slice( 7 )
-	Else If ctype.StartsWith( "union " )
-		ctype=ctype.Slice( 6 )
-	Else If ctype.StartsWith( "enum " )
-		ctype=ctype.Slice( 5 )
+	If id.StartsWith( "struct " )
+		id=id.Slice( 7 )
+	Else If id.StartsWith( "union " )
+		id=id.Slice( 6 )
+	Else If id.StartsWith( "enum " )
+		id=id.Slice( 5 )
 	Endif
 
-	If Keywords.Contains( ctype ) ctype+="_"
+	If Keywords.Contains( id ) id+="_"
 	
-	Return ctype
+	Return id
 End
 
-Function TransType:String( type:CXType )
+Function IsCStringType:Bool( type:CXType )
 
+	Local ptype:CXType
+	
 	Select type.kind
+	Case CXType_Pointer
+		ptype=clang_getPointeeType( type )
+	Case CXType_ConstantArray,CXType_IncompleteArray 
+		ptype=clang_getElementType( type )
+	Default
+		Return False
+	End
 	
-	Case CXType_Void Return "Void"
+	If clang_isConstQualifiedType( ptype )
+		Select ptype.kind
+		Case CXType_Char_S,CXType_Char_U 
+			Return cstring_types["const char *"]
+		Case CXType_SChar
+			Return cstring_types["const signed char *"]
+		Case CXType_UChar
+			Return cstring_types["const unsigned char *"]
+		End
+	Else
+		Select ptype.kind
+		Case CXType_Char_S,CXType_Char_U 
+			Return cstring_types["char *"]
+		Case CXType_SChar
+			Return cstring_types["signed char *"]
+		Case CXType_UChar
+			Return cstring_types["unsigned char *"]
+		End
+	Endif
 	
-	Case CXType_Char_S,CXType_Char_U Return clang_isConstQualifiedType( type ) ? "libc.const_char_t" Else "libc.char_t"
+	Return False
+End
+
+Function TransType:String( type:CXType,scope:String="" )
+
+	Select type.kind
+	
+	Case CXType_Void Return "Void"
 	
 	Case CXType_SChar Return "Byte"
 	
@@ -170,78 +202,86 @@ Function TransType:String( type:CXType )
 	
 	Case CXType_ULongLong Return ULongLongType
 	
-	Case CXType_Typedef return TypeName( type )
-	
-	Case CXType_Enum Return TypeName( type )
+	Case CXType_Typedef Return TypeSpelling( type )
+
+	Case CXType_Enum Return TypeSpelling( type )
 	
-	Case CXType_Record Return TypeName( type )
+	Case CXType_Record Return TypeSpelling( type )
 	
 	Case CXType_Elaborated Return TransType( clang_Type_getNamedType( type ) )
 	
-	Case CXType_Pointer 
+	Case CXType_Char_S,CXType_Char_U 
+	
+		Return clang_isConstQualifiedType( type ) ? "libc.const_char_t" Else "libc.char_t"
+	
+	Case CXType_Pointer
+	
+		If scope And IsCStringType( type ) Return "CString"
+		
+		'can't return const pointers...
+		If scope="return" And clang_isConstQualifiedType( type ) Return ""
 	
 		Local ptype:=TransType( clang_getPointeeType( type ) )
 		If ptype
-			If ptype.EndsWith( ")" ) ptype+=" " Else ptype+=" Ptr"
-			Return ptype
+			If ptype.EndsWith( ")" ) Return ptype
+			Return ptype+" Ptr"
 		Endif
 	
 	Case CXType_ConstantArray	'naughty!
 	
+		If scope And IsCStringType( type ) Return "CString"
+	
 		Local ptype:=TransType( clang_getElementType( type ) )
 		If ptype Return ptype+" Ptr"
 	
 	Case CXType_IncompleteArray 
+
+		If scope And IsCStringType( type ) Return "CString"
 	
 		Local ptype:=TransType( clang_getElementType( type ) )
 		If ptype Return ptype+" Ptr"
 	
-'	Case CXType_LValueReference		'C++ time!
-	
-'		If clang_isConstQualifiedType( type ) Return TypeName( type )
-
 	Case CXType_Unexposed
 	
 		Local ctype:=clang_getCanonicalType( type )
 		
 		If ctype.kind=CXType_FunctionProto
 		
-			Local retType:=TransType( clang_getResultType( ctype ) )
-			
-			Local n:=clang_getNumArgTypes( type ),args:=""
-
-			For Local i:=0 Until n
-				If i args+=", "
-				args+=TransType( clang_getArgType( type,i ) )
-			Next
-			
-			Return retType+"( "+args+" )"
+			'Note: we use 'type' here because 'ctype' loses typedefs or something...
+			'
+			Local retType:=TransType( clang_getResultType( type ),"return" )
+				
+			If retType
+					
+				Local n:=clang_getNumArgTypes( type ),args:=""
+		
+				For Local i:=0 Until n
+					Local arg:=TransType( clang_getArgType( type,i ),"param" )
+					If Not arg Return ""
+					If i args+=", "
+					args+=arg
+				Next
+					
+				Return retType+"( "+args+" )"
+					
+			Endif
+		
 		Endif
 		
-	End
-	
-'	Print "Unknown CXType:"+clang_getTypeSpelling( type )+", CXTypeKind="+Int( type.kind )
-	
-	Return ""
-End
-
-Function TransType:String( cursor:CXCursor )
-
-	Return TransType( clang_getCursorType( cursor ) )
-End
-
-Function DeclName:String( cursor:CXCursor )
+		'Return TransType( ctype )
 
-	Local id:=String( clang_getCursorSpelling( cursor ) )
+'	Case CXType_LValueReference		'C++ time!
 	
-	If Keywords.Contains( id ) id+="_"
+'		If clang_isConstQualifiedType( type ) Return TypeName( type )
+
+	End
 	
-	Return id
+	Return ""
 End
 
-Function TypeName:String( cursor:CXCursor )
+Function TransType:String( cursor:CXCursor,scope:String="" )
 
-	Return TypeName( clang_getCursorType( cursor ) )
+	Return TransType( clang_getCursorType( cursor ),scope )
 End
 
 Function VisitFunc:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client_data:CXClientData )
@@ -250,45 +290,56 @@ Function VisitFunc:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client_da
 
 	Case CXCursor_ParmDecl
 
-		Local id:=DeclName( cursor )
+		Local id:=CursorSpelling( cursor )
 
-		Local type:=TransType( cursor )
+		Local type:=TransType( cursor,"param" )
 
 		If Not type
 			params="?"
 			Return CXChildVisit_Break
 		Endif
 
-		If type="libc.char_t Ptr" Or type="libc.const_char_t Ptr" type="CString"
-
 		If params params+=", "
+		
 		If id params+=id+":"+type Else params+=type
 	End
 	
 	Return CXChildVisit_Continue
 End
 
+Function VisitStruct:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client_data:CXClientData )
+
+	Select cursor.kind
+
+	Case CXCursor_FieldDecl
+
+		Local id:=CursorSpelling( cursor )
+		
+		Local type:=TransType( cursor,"var" )
+		
+		If type
+			buf.Push( tab+"Field "+id+":"+type )
+		Else
+			Err( "Failed to convert type of field: "+id,cursor )
+		Endif
+	End
+
+	Return CXChildVisit_Continue
+End
+
 Function VisitEnum:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client_data:CXClientData )
 
-	Select clang_getCursorKind( cursor )
+	Select cursor.kind
 
 	Case CXCursor_EnumConstantDecl
 	
-		buf.Push( tab+"Const "+DeclName( cursor )+":"+enumid )
-	
+		buf.Push( tab+"Const "+CursorSpelling( cursor )+":"+enumid )
 	End
 	
 	Return CXChildVisit_Continue
 End
 
-Function SetFile( file:String )
-	If file=CurrentFile Return
-	CurrentFile=file
-	buf.Push( "~n'***** File: "+CurrentFile+" *****~n" )
-	Print "Processing:"+file
-End
-
-Function VisitMembers:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client_data:CXClientData )
+Function VisitUnit:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client_data:CXClientData )
 
 	Local srcloc:=clang_getCursorLocation( cursor )
 	Local cfile:CXFile,line:UInt
@@ -306,6 +357,7 @@ Function VisitMembers:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client
 	Case CXCursor_EnumDecl
 
 		Local id:=TransType( cursor )
+		
 		If id
 			SetFile( file )
 			buf.Push( tab+"Enum "+id+"~nEnd" )
@@ -328,7 +380,7 @@ Function VisitMembers:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client
 				buf.Push( tab+"Struct "+id )
 			
 				tab+="~t"
-				clang_visitChildren( cursor,VisitMembers,Null )
+				clang_visitChildren( cursor,VisitStruct,Null )
 				tab=tab.Slice( 0,-1 )
 					
 				buf.Push( tab+"End" )
@@ -364,7 +416,7 @@ Function VisitMembers:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client
 	
 	Case CXCursor_TypedefDecl
 	
-		Local id:=DeclName( cursor )
+		Local id:=CursorSpelling( cursor )
 
 		Local type:=TransType( clang_getTypedefDeclUnderlyingType( cursor ) )
 		
@@ -379,11 +431,11 @@ Function VisitMembers:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client
 	
 	Case CXCursor_FunctionDecl
 
-		Local id:=DeclName( cursor )
+		Local id:=CursorSpelling( cursor )
 	
 		Local ftype:=clang_getCursorType( cursor )
 		
-		Local retType:=TransType( clang_getResultType( ftype ) )
+		Local retType:=TransType( clang_getResultType( ftype ),"return" )
 		
 		If retType
 
@@ -402,41 +454,38 @@ Function VisitMembers:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client
 		
 	Case CXCursor_VarDecl
 	
-		Local id:=DeclName( cursor )
+		Local id:=CursorSpelling( cursor )
 		
-		Local type:=TransType( cursor )
+		Local type:=clang_getCursorType( cursor )
+		
+		Local ptype:=TransType( type,"global" )
+		
+		If ptype
 		
-		If type
 			SetFile( file )
-			buf.Push( "Global "+id+":"+type )
+			
+			If clang_isConstQualifiedType( type )
+				buf.Push( "Const "+id+":"+ptype )
+			Else
+				buf.Push( "Global "+id+":"+ptype )
+			Endif
 		Else
 			Err( "Failed to convert type for var: "+id,cursor )
 		Endif
 		
-	Case CXCursor_FieldDecl
-
-		Local id:=DeclName( cursor )
-		Local type:=TransType( cursor )
-		
-		If type
-			buf.Push( tab+"Field "+id+":"+type )
-		Else
-			Err( "Failed to convert type of field: "+id,cursor )
-		Endif
-	
 	End
 	
 	Return CXChildVisit_Continue
 End
 
-Function VisitAll:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client_data:CXClientData )
+Function VisitDebug:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client_data:CXClientData )
 
 	Local ctype:=clang_getCursorType( cursor )
 
 	Print tab+clang_getCursorSpelling( cursor )+":"+clang_getTypeSpelling( ctype )+", cursor kind="+Int( cursor.kind )+", type kind="+Int( ctype.kind )
 	
 	tab+="~t"
-	clang_visitChildren( cursor,VisitAll,Null )
+	clang_visitChildren( cursor,VisitDebug,Null )
 	tab=tab.Slice( 0,-1 )
 
 	Return CXChildVisit_Continue
@@ -445,29 +494,26 @@ End
 Function Main()
 
 	Local path:=RequestFile( "Select c2mx2.json file...","Json files:json" )
-	If Not path 
-		Print "No path selected"
-		Return
-	Endif
+	If Not path Return
 	
 	Local config:=JsonObject.Load( path )
 	If Not config
-		Notify( "c2mx2","Failed to load JSON object from "+path,True )
+		Print "C2mx2: Failed to load JSON object from "+path
 		Return
 	Endif
 
 	If Not config.Contains( "inputFile" )
-		Notify( "c2mx2","No inputFile specified",True )
+		Print "C2mx2: No inputFile specified"
 		Return
 	Endif
 	
 	If Not config.Contains( "outputFile" )
-		Notify( "c2mx2","No outputFile specified",True )
+		Print "C2mx2: No outputFile specified"
 		Return
 	Endif
 
 	If Not config.Contains( "clangArgs" )
-		Notify( "c2mx2","No clangArgs specified",True )
+		Print "C2mx2: No clangArgs specified"
 		Return
 	Endif
 	
@@ -490,7 +536,7 @@ Function Main()
 	For Local i:=0 Until args.Length
 		args[i]=ToCString( cargs[i].ToString() )
 	Next
-
+	
 	'include/exclude files
 	If config.Contains( "includeFiles" )
 		IncludeFiles=New StringMap<Bool>
@@ -503,6 +549,22 @@ Function Main()
 			ExcludeFiles[file.ToString()]=True
 		Next
 	Endif
+
+	'extern structs
+	If config.Contains( "externStructs" )
+		For Local it:=Eachin config.GetArray( "externStructs" )
+			ext_structs[it.ToString()]=True
+		Next
+	Endif
+	
+	'CString compatible types
+	If config.Contains( "cstringTypes" )
+		For Local it:=Eachin config.GetArray( "cstringTypes" )
+			cstring_types[it.ToString()]=True
+		Next
+	Else
+		cstring_types["const char *"]=True
+	Endif
 	
 	'anonymous enum type
 	If config.Contains( "anonEnumType" )
@@ -528,7 +590,7 @@ Function Main()
 	
 	Local cursor:=clang_getTranslationUnitCursor( tu )
 	
-	clang_visitChildren( cursor,VisitMembers,Null )
+	clang_visitChildren( cursor,VisitUnit,Null )
 
 	'emit extern structs	
 	buf.Push( "~n'***** Extern Structs *****~n" )
@@ -547,11 +609,14 @@ Function Main()
 		Next
 	Endif
 
-	'emit output	
+	'Done!
+	buf.Push( "" )	
+	
+	'emit output
 	If SaveString( buf.Join( "~n" ),output )
-		Notify( "c2mx2","Finished generating '"+output+"'!" )
+		Print "~nc2mx2: **** Success ***** - output saved to "+output
 	Else
-		Notify( "c2mx2","Failed to generat output file",true )
+		Print "~nc2mx2: Error saving output to "+output
 	Endif
 
 End

+ 0 - 4
src/c2mx2/libclang_c2mx2.json

@@ -24,10 +24,6 @@
 		"#Import \"<clang-c/Index.h>\"",
 		"",
 		"Extern"
-	],
-	
-	"footer":[
-		"Public"
 	]
 	
 }

+ 21 - 22
src/c2mx2/libclang_extern.monkey2

@@ -32,7 +32,7 @@ Struct CXStringSet
 	Field Strings:CXString Ptr
 	Field Count:UInt
 End
-Function clang_getCString:libc.const_char_t Ptr( string_:CXString )
+Function clang_getCString:CString( string_:CXString )
 Function clang_disposeString:Void( string_:CXString )
 Function clang_disposeStringSet:Void( set:CXStringSet Ptr )
 
@@ -59,8 +59,8 @@ Alias CXIndex:Void Ptr
 Alias CXTranslationUnit:CXTranslationUnitImpl Ptr
 Alias CXClientData:Void Ptr
 Struct CXUnsavedFile
-	Field Filename:libc.const_char_t Ptr
-	Field Contents:libc.const_char_t Ptr
+	Field Filename:CString
+	Field Contents:CString
 	Field Length:ULong
 End
 Enum CXAvailabilityKind
@@ -229,7 +229,7 @@ Const CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN:CXTUResourceUsageKind
 Const CXTUResourceUsage_MEMORY_IN_BYTES_END:CXTUResourceUsageKind
 Const CXTUResourceUsage_First:CXTUResourceUsageKind
 Const CXTUResourceUsage_Last:CXTUResourceUsageKind
-Function clang_getTUResourceUsageName:libc.const_char_t Ptr( kind:CXTUResourceUsageKind )
+Function clang_getTUResourceUsageName:CString( kind:CXTUResourceUsageKind )
 Struct CXTUResourceUsageEntry
 	Field kind:CXTUResourceUsageKind
 	Field amount:ULong
@@ -709,7 +709,7 @@ End
 Const CXChildVisit_Break:CXChildVisitResult
 Const CXChildVisit_Continue:CXChildVisitResult
 Const CXChildVisit_Recurse:CXChildVisitResult
-Alias CXCursorVisitor:CXChildVisitResult( CXCursor, CXCursor, CXClientData ) 
+Alias CXCursorVisitor:CXChildVisitResult( CXCursor, CXCursor, CXClientData )
 Function clang_visitChildren:UInt( parent:CXCursor, visitor:CXCursorVisitor, client_data:CXClientData )
 Function clang_getCursorUSR:CXString( CXCursor )
 Function clang_constructUSR_ObjCClass:CXString( class_name:CString )
@@ -811,7 +811,7 @@ Function clang_disposeTokens:Void( TU:CXTranslationUnit, Tokens:CXToken Ptr, Num
 Function clang_getCursorKindSpelling:CXString( Kind:CXCursorKind )
 Function clang_getDefinitionSpellingAndExtent:Void( CXCursor, startBuf:libc.const_char_t Ptr Ptr, endBuf:libc.const_char_t Ptr Ptr, startLine:UInt Ptr, startColumn:UInt Ptr, endLine:UInt Ptr, endColumn:UInt Ptr )
 Function clang_enableStackTraces:Void(  )
-Function clang_executeOnThread:Void( fn:Void( Void Ptr ) , user_data:Void Ptr, stack_size:UInt )
+Function clang_executeOnThread:Void( fn:Void( Void Ptr ), user_data:Void Ptr, stack_size:UInt )
 Alias CXCompletionString:Void Ptr
 Struct CXCompletionResult
 	Field CursorKind:CXCursorKind
@@ -898,7 +898,7 @@ Function clang_codeCompleteGetContainerUSR:CXString( Results:CXCodeCompleteResul
 Function clang_codeCompleteGetObjCSelector:CXString( Results:CXCodeCompleteResults Ptr )
 Function clang_getClangVersion:CXString(  )
 Function clang_toggleCrashRecovery:Void( isEnabled:UInt )
-Alias CXInclusionVisitor:Void( CXFile, CXSourceLocation Ptr, UInt, CXClientData ) 
+Alias CXInclusionVisitor:Void( CXFile, CXSourceLocation Ptr, UInt, CXClientData )
 Function clang_getInclusions:Void( tu:CXTranslationUnit, visitor:CXInclusionVisitor, client_data:CXClientData )
 Enum CXEvalResultKind
 End
@@ -914,7 +914,7 @@ Function clang_Cursor_Evaluate:CXEvalResult( C:CXCursor )
 Function clang_EvalResult_getKind:CXEvalResultKind( E:CXEvalResult )
 Function clang_EvalResult_getAsInt:Int( E:CXEvalResult )
 Function clang_EvalResult_getAsDouble:Double( E:CXEvalResult )
-Function clang_EvalResult_getAsStr:libc.const_char_t Ptr( E:CXEvalResult )
+Function clang_EvalResult_getAsStr:CString( E:CXEvalResult )
 Function clang_EvalResult_dispose:Void( E:CXEvalResult )
 Alias CXRemapping:Void Ptr
 Function clang_getRemappings:CXRemapping( path:CString )
@@ -928,7 +928,7 @@ Const CXVisit_Break:CXVisitorResult
 Const CXVisit_Continue:CXVisitorResult
 Struct CXCursorAndRangeVisitor
 	Field context:Void Ptr
-	Field visit:CXVisitorResult( Void Ptr, CXCursor, CXSourceRange ) 
+	Field visit:CXVisitorResult( Void Ptr, CXCursor, CXSourceRange )
 End
 Enum CXResult
 End
@@ -947,7 +947,7 @@ Struct CXIdxLoc
 End
 Struct CXIdxIncludedFileInfo
 	Field hashLoc:CXIdxLoc
-	Field filename:libc.const_char_t Ptr
+	Field filename:CString
 	Field file:CXFile
 	Field isImport:Int
 	Field isAngled:Int
@@ -1015,8 +1015,8 @@ Struct CXIdxEntityInfo
 	Field kind:CXIdxEntityKind
 	Field templateKind:CXIdxEntityCXXTemplateKind
 	Field lang:CXIdxEntityLanguage
-	Field name:libc.const_char_t Ptr
-	Field USR:libc.const_char_t Ptr
+	Field name:CString
+	Field USR:CString
 	Field cursor:CXCursor
 	Field attributes:CXIdxAttrInfo Ptr Ptr
 	Field numAttributes:UInt
@@ -1106,14 +1106,14 @@ Struct CXIdxEntityRefInfo
 	Field container:CXIdxContainerInfo Ptr
 End
 Struct IndexerCallbacks
-	Field abortQuery:Int( CXClientData, Void Ptr ) 
-	Field diagnostic:Void( CXClientData, CXDiagnosticSet, Void Ptr ) 
-	Field enteredMainFile:Void Ptr( CXClientData, CXFile, Void Ptr ) 
-	Field ppIncludedFile:Void Ptr( CXClientData, CXIdxIncludedFileInfo Ptr ) 
-	Field importedASTFile:Void Ptr( CXClientData, CXIdxImportedASTFileInfo Ptr ) 
-	Field startedTranslationUnit:Void Ptr( CXClientData, Void Ptr ) 
-	Field indexDeclaration:Void( CXClientData, CXIdxDeclInfo Ptr ) 
-	Field indexEntityReference:Void( CXClientData, CXIdxEntityRefInfo Ptr ) 
+	Field abortQuery:Int( CXClientData, Void Ptr )
+	Field diagnostic:Void( CXClientData, CXDiagnosticSet, Void Ptr )
+	Field enteredMainFile:CXIdxClientFile( CXClientData, CXFile, Void Ptr )
+	Field ppIncludedFile:CXIdxClientFile( CXClientData, CXIdxIncludedFileInfo Ptr )
+	Field importedASTFile:CXIdxClientASTFile( CXClientData, CXIdxImportedASTFileInfo Ptr )
+	Field startedTranslationUnit:CXIdxClientContainer( CXClientData, Void Ptr )
+	Field indexDeclaration:Void( CXClientData, CXIdxDeclInfo Ptr )
+	Field indexEntityReference:Void( CXClientData, CXIdxEntityRefInfo Ptr )
 End
 Function clang_index_isEntityObjCContainerKind:Int( CXIdxEntityKind )
 Function clang_index_getObjCContainerDeclInfo:CXIdxObjCContainerDeclInfo Ptr( CXIdxDeclInfo Ptr )
@@ -1143,7 +1143,7 @@ Function clang_indexSourceFileFullArgv:Int( CXIndexAction, client_data:CXClientD
 Function clang_indexTranslationUnit:Int( CXIndexAction, client_data:CXClientData, index_callbacks:IndexerCallbacks Ptr, index_callbacks_size:UInt, index_options:UInt, CXTranslationUnit )
 Function clang_indexLoc_getFileLocation:Void( loc:CXIdxLoc, indexFile:CXIdxClientFile Ptr, file:CXFile Ptr, line:UInt Ptr, column:UInt Ptr, offset:UInt Ptr )
 Function clang_indexLoc_getCXSourceLocation:CXSourceLocation( loc:CXIdxLoc )
-Alias CXFieldVisitor:CXVisitorResult( CXCursor, CXClientData ) 
+Alias CXFieldVisitor:CXVisitorResult( CXCursor, CXClientData )
 Function clang_Type_visitFields:UInt( T:CXType, visitor:CXFieldVisitor, client_data:CXClientData )
 
 '***** Extern Structs *****
@@ -1156,4 +1156,3 @@ Struct CXTranslationUnitImpl
 End
 Struct CXVirtualFileOverlayImpl
 End
-Public

+ 21 - 22
src/c2mx2/libclang_extern_new.monkey2

@@ -32,7 +32,7 @@ Struct CXStringSet
 	Field Strings:CXString Ptr
 	Field Count:UInt
 End
-Function clang_getCString:libc.const_char_t Ptr( string_:CXString )
+Function clang_getCString:CString( string_:CXString )
 Function clang_disposeString:Void( string_:CXString )
 Function clang_disposeStringSet:Void( set:CXStringSet Ptr )
 
@@ -59,8 +59,8 @@ Alias CXIndex:Void Ptr
 Alias CXTranslationUnit:CXTranslationUnitImpl Ptr
 Alias CXClientData:Void Ptr
 Struct CXUnsavedFile
-	Field Filename:libc.const_char_t Ptr
-	Field Contents:libc.const_char_t Ptr
+	Field Filename:CString
+	Field Contents:CString
 	Field Length:ULong
 End
 Enum CXAvailabilityKind
@@ -229,7 +229,7 @@ Const CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN:CXTUResourceUsageKind
 Const CXTUResourceUsage_MEMORY_IN_BYTES_END:CXTUResourceUsageKind
 Const CXTUResourceUsage_First:CXTUResourceUsageKind
 Const CXTUResourceUsage_Last:CXTUResourceUsageKind
-Function clang_getTUResourceUsageName:libc.const_char_t Ptr( kind:CXTUResourceUsageKind )
+Function clang_getTUResourceUsageName:CString( kind:CXTUResourceUsageKind )
 Struct CXTUResourceUsageEntry
 	Field kind:CXTUResourceUsageKind
 	Field amount:ULong
@@ -709,7 +709,7 @@ End
 Const CXChildVisit_Break:CXChildVisitResult
 Const CXChildVisit_Continue:CXChildVisitResult
 Const CXChildVisit_Recurse:CXChildVisitResult
-Alias CXCursorVisitor:CXChildVisitResult( CXCursor, CXCursor, CXClientData ) 
+Alias CXCursorVisitor:CXChildVisitResult( CXCursor, CXCursor, CXClientData )
 Function clang_visitChildren:UInt( parent:CXCursor, visitor:CXCursorVisitor, client_data:CXClientData )
 Function clang_getCursorUSR:CXString( CXCursor )
 Function clang_constructUSR_ObjCClass:CXString( class_name:CString )
@@ -811,7 +811,7 @@ Function clang_disposeTokens:Void( TU:CXTranslationUnit, Tokens:CXToken Ptr, Num
 Function clang_getCursorKindSpelling:CXString( Kind:CXCursorKind )
 Function clang_getDefinitionSpellingAndExtent:Void( CXCursor, startBuf:libc.const_char_t Ptr Ptr, endBuf:libc.const_char_t Ptr Ptr, startLine:UInt Ptr, startColumn:UInt Ptr, endLine:UInt Ptr, endColumn:UInt Ptr )
 Function clang_enableStackTraces:Void(  )
-Function clang_executeOnThread:Void( fn:Void( Void Ptr ) , user_data:Void Ptr, stack_size:UInt )
+Function clang_executeOnThread:Void( fn:Void( Void Ptr ), user_data:Void Ptr, stack_size:UInt )
 Alias CXCompletionString:Void Ptr
 Struct CXCompletionResult
 	Field CursorKind:CXCursorKind
@@ -898,7 +898,7 @@ Function clang_codeCompleteGetContainerUSR:CXString( Results:CXCodeCompleteResul
 Function clang_codeCompleteGetObjCSelector:CXString( Results:CXCodeCompleteResults Ptr )
 Function clang_getClangVersion:CXString(  )
 Function clang_toggleCrashRecovery:Void( isEnabled:UInt )
-Alias CXInclusionVisitor:Void( CXFile, CXSourceLocation Ptr, UInt, CXClientData ) 
+Alias CXInclusionVisitor:Void( CXFile, CXSourceLocation Ptr, UInt, CXClientData )
 Function clang_getInclusions:Void( tu:CXTranslationUnit, visitor:CXInclusionVisitor, client_data:CXClientData )
 Enum CXEvalResultKind
 End
@@ -914,7 +914,7 @@ Function clang_Cursor_Evaluate:CXEvalResult( C:CXCursor )
 Function clang_EvalResult_getKind:CXEvalResultKind( E:CXEvalResult )
 Function clang_EvalResult_getAsInt:Int( E:CXEvalResult )
 Function clang_EvalResult_getAsDouble:Double( E:CXEvalResult )
-Function clang_EvalResult_getAsStr:libc.const_char_t Ptr( E:CXEvalResult )
+Function clang_EvalResult_getAsStr:CString( E:CXEvalResult )
 Function clang_EvalResult_dispose:Void( E:CXEvalResult )
 Alias CXRemapping:Void Ptr
 Function clang_getRemappings:CXRemapping( path:CString )
@@ -928,7 +928,7 @@ Const CXVisit_Break:CXVisitorResult
 Const CXVisit_Continue:CXVisitorResult
 Struct CXCursorAndRangeVisitor
 	Field context:Void Ptr
-	Field visit:CXVisitorResult( Void Ptr, CXCursor, CXSourceRange ) 
+	Field visit:CXVisitorResult( Void Ptr, CXCursor, CXSourceRange )
 End
 Enum CXResult
 End
@@ -947,7 +947,7 @@ Struct CXIdxLoc
 End
 Struct CXIdxIncludedFileInfo
 	Field hashLoc:CXIdxLoc
-	Field filename:libc.const_char_t Ptr
+	Field filename:CString
 	Field file:CXFile
 	Field isImport:Int
 	Field isAngled:Int
@@ -1015,8 +1015,8 @@ Struct CXIdxEntityInfo
 	Field kind:CXIdxEntityKind
 	Field templateKind:CXIdxEntityCXXTemplateKind
 	Field lang:CXIdxEntityLanguage
-	Field name:libc.const_char_t Ptr
-	Field USR:libc.const_char_t Ptr
+	Field name:CString
+	Field USR:CString
 	Field cursor:CXCursor
 	Field attributes:CXIdxAttrInfo Ptr Ptr
 	Field numAttributes:UInt
@@ -1106,14 +1106,14 @@ Struct CXIdxEntityRefInfo
 	Field container:CXIdxContainerInfo Ptr
 End
 Struct IndexerCallbacks
-	Field abortQuery:Int( CXClientData, Void Ptr ) 
-	Field diagnostic:Void( CXClientData, CXDiagnosticSet, Void Ptr ) 
-	Field enteredMainFile:Void Ptr( CXClientData, CXFile, Void Ptr ) 
-	Field ppIncludedFile:Void Ptr( CXClientData, CXIdxIncludedFileInfo Ptr ) 
-	Field importedASTFile:Void Ptr( CXClientData, CXIdxImportedASTFileInfo Ptr ) 
-	Field startedTranslationUnit:Void Ptr( CXClientData, Void Ptr ) 
-	Field indexDeclaration:Void( CXClientData, CXIdxDeclInfo Ptr ) 
-	Field indexEntityReference:Void( CXClientData, CXIdxEntityRefInfo Ptr ) 
+	Field abortQuery:Int( CXClientData, Void Ptr )
+	Field diagnostic:Void( CXClientData, CXDiagnosticSet, Void Ptr )
+	Field enteredMainFile:CXIdxClientFile( CXClientData, CXFile, Void Ptr )
+	Field ppIncludedFile:CXIdxClientFile( CXClientData, CXIdxIncludedFileInfo Ptr )
+	Field importedASTFile:CXIdxClientASTFile( CXClientData, CXIdxImportedASTFileInfo Ptr )
+	Field startedTranslationUnit:CXIdxClientContainer( CXClientData, Void Ptr )
+	Field indexDeclaration:Void( CXClientData, CXIdxDeclInfo Ptr )
+	Field indexEntityReference:Void( CXClientData, CXIdxEntityRefInfo Ptr )
 End
 Function clang_index_isEntityObjCContainerKind:Int( CXIdxEntityKind )
 Function clang_index_getObjCContainerDeclInfo:CXIdxObjCContainerDeclInfo Ptr( CXIdxDeclInfo Ptr )
@@ -1143,7 +1143,7 @@ Function clang_indexSourceFileFullArgv:Int( CXIndexAction, client_data:CXClientD
 Function clang_indexTranslationUnit:Int( CXIndexAction, client_data:CXClientData, index_callbacks:IndexerCallbacks Ptr, index_callbacks_size:UInt, index_options:UInt, CXTranslationUnit )
 Function clang_indexLoc_getFileLocation:Void( loc:CXIdxLoc, indexFile:CXIdxClientFile Ptr, file:CXFile Ptr, line:UInt Ptr, column:UInt Ptr, offset:UInt Ptr )
 Function clang_indexLoc_getCXSourceLocation:CXSourceLocation( loc:CXIdxLoc )
-Alias CXFieldVisitor:CXVisitorResult( CXCursor, CXClientData ) 
+Alias CXFieldVisitor:CXVisitorResult( CXCursor, CXClientData )
 Function clang_Type_visitFields:UInt( T:CXType, visitor:CXFieldVisitor, client_data:CXClientData )
 
 '***** Extern Structs *****
@@ -1156,4 +1156,3 @@ Struct CXTranslationUnitImpl
 End
 Struct CXVirtualFileOverlayImpl
 End
-Public