File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
src/Generator/Generators/CSharp Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -776,10 +776,18 @@ private void MarshalRefClass(Class @class)
776
776
Context . Parameter . Name } "", ""Cannot be null because it is passed by value."");" ) ;
777
777
778
778
var nativeClass = typePrinter . PrintNative ( @class ) ;
779
+
779
780
var cctorName = CSharpSources . GetFunctionNativeIdentifier ( Context . Context , cctor ) ;
781
+
782
+ var defaultValue = "" ;
783
+ var TypePrinter = new CSharpTypePrinter ( Context . Context ) ;
784
+ var ExpressionPrinter = new CSharpExpressionPrinter ( TypePrinter ) ;
785
+ if ( cctor . Parameters . Count > 1 )
786
+ defaultValue = $ ", { ExpressionPrinter . VisitParameter ( cctor . Parameters . Last ( ) ) } ";
787
+
780
788
Context . Before . WriteLine ( $ "byte* __{ Context . Parameter . Name } Memory = stackalloc byte[sizeof({ nativeClass } )];") ;
781
789
Context . Before . WriteLine ( $ "__IntPtr __{ Context . Parameter . Name } Ptr = (__IntPtr)__{ Context . Parameter . Name } Memory;") ;
782
- Context . Before . WriteLine ( $ "{ nativeClass } .{ cctorName } (__{ Context . Parameter . Name } Ptr, { Context . Parameter . Name } .__Instance);") ;
790
+ Context . Before . WriteLine ( $ "{ nativeClass } .{ cctorName } (__{ Context . Parameter . Name } Ptr, { Context . Parameter . Name } .__Instance{ defaultValue } );") ;
783
791
Context . Return . Write ( $ "__{ Context . Parameter . Name } Ptr") ;
784
792
785
793
if ( Context . Context . ParserOptions . IsItaniumLikeAbi && @class . HasNonTrivialDestructor )
You can’t perform that action at this time.
0 commit comments