File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed
src/Generator/Generators/CLI Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -380,6 +380,8 @@ public void GenerateClassConstructors(Class @class, string nativeType)
380
380
WriteLine ( "static {0}^ {1}(::System::IntPtr native);" ,
381
381
@class . Name , Helpers . CreateInstanceIdentifier ) ;
382
382
383
+ WriteLine ( $ "static { @class . Name } ^ { Helpers . CreateInstanceIdentifier } (::System::IntPtr native, bool { Helpers . OwnsNativeInstanceIdentifier } );") ;
384
+
383
385
foreach ( var ctor in @class . Constructors )
384
386
{
385
387
if ( ASTUtils . CheckIgnoreMethod ( ctor ) || FunctionIgnored ( ctor ) )
Original file line number Diff line number Diff line change @@ -670,18 +670,21 @@ private void GenerateClassConstructor(Class @class, bool withOwnNativeInstancePa
670
670
671
671
UnindentAndWriteCloseBrace ( ) ;
672
672
673
- if ( ! withOwnNativeInstanceParam )
674
- {
675
- NewLine ( ) ;
676
- WriteLine ( "{0}^ {0}::{1}(::System::IntPtr native)" , qualifiedIdentifier , Helpers . CreateInstanceIdentifier ) ;
673
+ string createInstanceParams = withOwnNativeInstanceParam ? $ "::System::IntPtr native, bool { Helpers . OwnsNativeInstanceIdentifier } " : "::System::IntPtr native" ;
674
+ string createInstanceParamsValues = withOwnNativeInstanceParam ? $ "({ nativeType } ) native.ToPointer(), { Helpers . OwnsNativeInstanceIdentifier } " : $ "({ nativeType } ) native.ToPointer()";
677
675
678
- WriteOpenBraceAndIndent ( ) ;
676
+ NewLine ( ) ;
677
+ WriteLine ( $ "{ qualifiedIdentifier } ^ { qualifiedIdentifier } ::{ Helpers . CreateInstanceIdentifier } ({ createInstanceParams } )") ;
679
678
680
- WriteLine ( "return gcnew ::{0}(({1}) native.ToPointer());" , qualifiedIdentifier , nativeType ) ;
679
+ WriteOpenBraceAndIndent ( ) ;
681
680
682
- UnindentAndWriteCloseBrace ( ) ;
683
- NewLine ( ) ;
681
+ WriteLine ( $ "return gcnew ::{ qualifiedIdentifier } ({ createInstanceParamsValues } );") ;
682
+
683
+ UnindentAndWriteCloseBrace ( ) ;
684
+ NewLine ( ) ;
684
685
686
+ if ( ! withOwnNativeInstanceParam )
687
+ {
685
688
GenerateClassConstructor ( @class , true ) ;
686
689
}
687
690
}
You can’t perform that action at this time.
0 commit comments