@@ -83,9 +83,9 @@ public override bool VisitFunctionType(FunctionType function, TypeQualifiers qua
83
83
var delegateType = function . ToString ( ) ;
84
84
85
85
Context . Return . Write ( "safe_cast<{0}>(" , delegateType + "^" ) ;
86
- Context . Return . Write ( "System::Runtime::InteropServices::Marshal::" ) ;
86
+ Context . Return . Write ( ":: System::Runtime::InteropServices::Marshal::" ) ;
87
87
Context . Return . Write ( "GetDelegateForFunctionPointer(" ) ;
88
- Context . Return . Write ( "System::IntPtr({0}), {1}::typeid))" , Context . ReturnVarName ,
88
+ Context . Return . Write ( ":: System::IntPtr({0}), {1}::typeid))" , Context . ReturnVarName ,
89
89
delegateType . TrimEnd ( '^' ) ) ;
90
90
91
91
return true ;
@@ -223,9 +223,9 @@ public override bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals)
223
223
if ( decl . Type . IsPointerTo ( out function ) )
224
224
{
225
225
Context . Return . Write ( $ "{ Context . ReturnVarName } == nullptr ? nullptr : safe_cast<{ typedef } >(") ;
226
- Context . Return . Write ( "System::Runtime::InteropServices::Marshal::" ) ;
226
+ Context . Return . Write ( ":: System::Runtime::InteropServices::Marshal::" ) ;
227
227
Context . Return . Write ( "GetDelegateForFunctionPointer(" ) ;
228
- Context . Return . Write ( "IntPtr({0}), {1}::typeid))" , Context . ReturnVarName ,
228
+ Context . Return . Write ( "::System:: IntPtr({0}), {1}::typeid))" , Context . ReturnVarName ,
229
229
typedef . ToString ( ) . TrimEnd ( '^' ) ) ;
230
230
return true ;
231
231
}
@@ -280,8 +280,7 @@ public override bool VisitClassDecl(Class @class)
280
280
if ( @class . IsRefType && needsCopy )
281
281
{
282
282
var name = Generator . GeneratedIdentifier ( Context . ReturnVarName ) ;
283
- Context . Before . WriteLine ( "auto {0} = new ::{1}({2});" , name ,
284
- @class . QualifiedOriginalName , Context . ReturnVarName ) ;
283
+ Context . Before . WriteLine ( $ "auto { name } = new { ( @class . IsUnion ? "union" : "struct" ) } ::{ @class . QualifiedOriginalName } ({ Context . ReturnVarName } );") ;
285
284
instance = name ;
286
285
287
286
ownNativeInstance = true ;
@@ -306,7 +305,7 @@ public void WriteClassInstance(Class @class, string instance, bool ownNativeInst
306
305
instance ) ;
307
306
308
307
Context . Return . Write ( "::{0}(" , QualifiedIdentifier ( @class ) ) ;
309
- Context . Return . Write ( "(::{0}*)" , @class . QualifiedOriginalName ) ;
308
+ Context . Return . Write ( $ "( { ( @class . IsUnion ? "union" : "struct" ) } :: { @class . QualifiedOriginalName } *)" ) ;
310
309
Context . Return . Write ( "{0}{1})" , instance , ownNativeInstance ? ", true" : "" ) ;
311
310
}
312
311
@@ -449,7 +448,7 @@ public override bool VisitArrayType(ArrayType array, TypeQualifiers quals)
449
448
450
449
supportBefore . WriteLine ( $ "if ({ Context . Parameter . Name } ->Length != { array . Size } )") ;
451
450
supportBefore . WriteOpenBraceAndIndent ( ) ;
452
- supportBefore . WriteLine ( $ "throw gcnew System::InvalidOperationException(\" Source array size must equal destination array size.\" );") ;
451
+ supportBefore . WriteLine ( $ "throw gcnew :: System::InvalidOperationException(\" Source array size must equal destination array size.\" );") ;
453
452
supportBefore . UnindentAndWriteCloseBrace ( ) ;
454
453
455
454
string nativeVal = string . Empty ;
@@ -494,7 +493,7 @@ public bool VisitDelegateType(string type)
494
493
495
494
var sb = new StringBuilder ( ) ;
496
495
sb . AppendFormat ( "static_cast<{0}>(" , type ) ;
497
- sb . Append ( "System::Runtime::InteropServices::Marshal::" ) ;
496
+ sb . Append ( ":: System::Runtime::InteropServices::Marshal::" ) ;
498
497
sb . Append ( "GetFunctionPointerForDelegate(" ) ;
499
498
sb . AppendFormat ( "{0}).ToPointer())" , Context . Parameter . Name ) ;
500
499
Context . Return . Write ( sb . ToString ( ) ) ;
@@ -529,7 +528,7 @@ public override bool VisitPointerType(PointerType pointer, TypeQualifiers quals)
529
528
ArgumentPrefix . Write ( "&" ) ;
530
529
}
531
530
532
- Context . Return . Write ( "(::{0}){1}{2}" , @enum . QualifiedOriginalName ,
531
+ Context . Return . Write ( "(enum ::{0}){1}{2}" , @enum . QualifiedOriginalName ,
533
532
isRef ? string . Empty : "*" , Context . Parameter . Name ) ;
534
533
return true ;
535
534
}
@@ -728,12 +727,12 @@ private void MarshalRefClass(Class @class)
728
727
&& method . Conversion == MethodConversionKind . FunctionToInstanceMethod
729
728
&& Context . ParameterIndex == 0 )
730
729
{
731
- Context . Return . Write ( "(::{0}*)" , @class . QualifiedOriginalName ) ;
730
+ Context . Return . Write ( $ "( { ( @class . IsUnion ? "union" : "struct" ) } :: { @class . QualifiedOriginalName } *)" ) ;
732
731
Context . Return . Write ( "NativePtr" ) ;
733
732
return ;
734
733
}
735
734
736
- Context . Return . Write ( "(::{0}*)" , @class . QualifiedOriginalName ) ;
735
+ Context . Return . Write ( $ "( { ( @class . IsUnion ? "union" : "struct" ) } :: { @class . QualifiedOriginalName } *)" ) ;
737
736
Context . Return . Write ( "{0}->NativePtr" , Context . Parameter . Name ) ;
738
737
}
739
738
@@ -858,7 +857,7 @@ public override bool VisitTypedefDecl(TypedefDecl typedef)
858
857
859
858
public override bool VisitEnumDecl ( Enumeration @enum )
860
859
{
861
- Context . Return . Write ( "(::{0}){1}" , @enum . QualifiedOriginalName ,
860
+ Context . Return . Write ( "(enum ::{0}){1}" , @enum . QualifiedOriginalName ,
862
861
Context . Parameter . Name ) ;
863
862
return true ;
864
863
}
0 commit comments