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)
380380 WriteLine ( "static {0}^ {1}(::System::IntPtr native);" ,
381381 @class . Name , Helpers . CreateInstanceIdentifier ) ;
382382
383+ WriteLine ( $ "static { @class . Name } ^ { Helpers . CreateInstanceIdentifier } (::System::IntPtr native, bool { Helpers . OwnsNativeInstanceIdentifier } );") ;
384+
383385 foreach ( var ctor in @class . Constructors )
384386 {
385387 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
670670
671671 UnindentAndWriteCloseBrace ( ) ;
672672
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()";
677675
678- WriteOpenBraceAndIndent ( ) ;
676+ NewLine ( ) ;
677+ WriteLine ( $ "{ qualifiedIdentifier } ^ { qualifiedIdentifier } ::{ Helpers . CreateInstanceIdentifier } ({ createInstanceParams } )") ;
679678
680- WriteLine ( "return gcnew ::{0}(({1}) native.ToPointer());" , qualifiedIdentifier , nativeType ) ;
679+ WriteOpenBraceAndIndent ( ) ;
681680
682- UnindentAndWriteCloseBrace ( ) ;
683- NewLine ( ) ;
681+ WriteLine ( $ "return gcnew ::{ qualifiedIdentifier } ({ createInstanceParamsValues } );") ;
682+
683+ UnindentAndWriteCloseBrace ( ) ;
684+ NewLine ( ) ;
684685
686+ if ( ! withOwnNativeInstanceParam )
687+ {
685688 GenerateClassConstructor ( @class , true ) ;
686689 }
687690 }
You can’t perform that action at this time.
0 commit comments