Răsfoiți Sursa

Weird fix for weird 'variant cast failed' issue with reflection.

Mark Sibly 7 ani în urmă
părinte
comite
e12d5a668e
2 a modificat fișierele cu 16 adăugiri și 4 ștergeri
  1. 8 0
      src/mx2cc/translator.monkey2
  2. 8 4
      src/mx2cc/translator_cpp.monkey2

+ 8 - 0
src/mx2cc/translator.monkey2

@@ -667,6 +667,14 @@ Method AddRef:Bool( node:SNode )
 		UsesType( type )
 	End
 	
+	Method UsesFunc( type:FuncType )
+		
+		UsesType( type.retType)
+		For Local argty:=Eachin type.argTypes
+			UsesType( argty )
+		Next
+	End
+	
 	Method UsesType( type:Type )
 		
 		Local xtype:=Cast<AliasType>( type )

+ 8 - 4
src/mx2cc/translator_cpp.monkey2

@@ -968,7 +968,8 @@ Class Translator_CPP Extends Translator
 				args+=","+TransType( arg )
 			Next
 			
-			DeclsFunc( func.ftype )
+			UsesFunc( func.ftype )
+'			DeclsFunc( func.ftype )
 			RefsFunc( func )
 						
 			decls.Push( "bbFunctionDecl<"+args+">(~q"+id+"~q,&"+fname+meta+")" )
@@ -1091,7 +1092,8 @@ Class Translator_CPP Extends Translator
 							args+=TransType( arg )
 						Next
 						
-						DeclsFunc( ctor.ftype )
+						UsesFunc( ctor.ftype )
+'						DeclsFunc( ctor.ftype )
 						
 						decls.Push( "bbCtorDecl<"+args+">("+meta+")" )
 					Next
@@ -1131,7 +1133,8 @@ Class Translator_CPP Extends Translator
 					args+=","+TransType( arg )
 				Next
 				
-				DeclsFunc( func.ftype )
+				UsesFunc( func.ftype )
+				'DeclsFunc( func.ftype )
 				
 				decls.Push( "bbMethodDecl<"+args+">(~q"+id+"~q,&"+cname+"::"+fname+meta+")" )
 			Next
@@ -1190,7 +1193,8 @@ Class Translator_CPP Extends Translator
 				Local fname:=FuncName( func )
 				Local meta:=func.fdecl.meta ? ","+EnquoteCppString( func.fdecl.meta ) Else ""
 					
-				DeclsFunc( func.ftype )
+				UsesFunc( func.ftype )
+				'DeclsFunc( func.ftype )
 					
 				If func.IsExtension