Mark Sibly 7 лет назад
Родитель
Сommit
d964ab0ba4
2 измененных файлов с 40 добавлено и 13 удалено
  1. 36 12
      src/mx2cc/test.monkey2
  2. 4 1
      src/mx2cc/translator_cpp.monkey2

+ 36 - 12
src/mx2cc/test.monkey2

@@ -4,15 +4,7 @@ Namespace test
 '#Import "<std>"
 '#Import "<std>"
 
 
 '#Reflect std.graphics
 '#Reflect std.graphics
-'#Reflect test
-
-Class C
-	
-End
-
-Enum E
-	A=1,B=2,C=3
-End
+#Reflect test
 
 
 Function InvokeMethod:Variant( name:String,instance:Object,args:Variant[]=Null )
 Function InvokeMethod:Variant( name:String,instance:Object,args:Variant[]=Null )
 	
 	
@@ -47,7 +39,7 @@ Function InvokeMethod:Variant( name:String,instance:Object,args:Variant[]=Null )
 	Return Null
 	Return Null
 End
 End
 
 
-Function EnumTypes()
+Function PrintAllTypes()
 	
 	
 	For Local type:=Eachin TypeInfo.GetTypes()
 	For Local type:=Eachin TypeInfo.GetTypes()
 		
 		
@@ -62,8 +54,40 @@ Function EnumTypes()
 	
 	
 End
 End
 
 
-Function Main()
+Class C
+End
 
 
-	EnumTypes()
+Class C Extension
+	
+	Method Update()
+		
+		Print "It worked!"
+	End
 	
 	
 End
 End
+
+Function Main()
+	
+	Print "All types:"
+	
+	PrintAllTypes()
+	
+	Local c:=New C
+	
+	For Local type:=Eachin TypeInfo.GetTypes()
+		
+		'look for extension
+		If type.Kind="Class Extension" And type.Name="test.C Extension"
+			
+			Print "Found extension!"
+			
+			Local decl:=type.GetDecl( "Update" )
+			
+			decl.Invoke( c,Null )
+		Endif
+	
+	Next
+	
+	Print "Bye!"
+End
+		

+ 4 - 1
src/mx2cc/translator_cpp.monkey2

@@ -1100,7 +1100,10 @@ Class Translator_CPP Extends Translator
 		'Ctor		
 		'Ctor		
 		Local name:=ctype.Name
 		Local name:=ctype.Name
 		Local kind:=cdecl.kind.Capitalize()
 		Local kind:=cdecl.kind.Capitalize()
-		If cdecl.IsExtension kind+=" Extension"
+		If cdecl.IsExtension 
+			name+=" Extension"
+			kind+=" Extension"
+		Endif
 		Emit( rcname+"():bbClassTypeInfo(~q"+name+"~q,~q"+kind+"~q){" )
 		Emit( rcname+"():bbClassTypeInfo(~q"+name+"~q,~q"+kind+"~q){" )
 		Emit( "}" )
 		Emit( "}" )