@@ -69,25 +69,16 @@ private static void GenerateFieldAccessors(CppGenerationContext context, TypeToG
6969 private static void GenerateSingleFieldAccessors ( CppGenerationContext context , TypeToGenerate item , IFieldSymbol field , GeneratedResult result )
7070 {
7171 CppType fieldType = CppType . FromCSharp ( context , field . Type ) ;
72- CppType setType = fieldType . AsParameterType ( ) ;
73- CppType getType = fieldType . AsReturnType ( ) ;
7472
75- CppInteropFunction getRecipe = new CppInteropFunction ( context , result . CppDefinition . Type , field . Name )
76- . ReturnType ( getType )
77- . Static ( field . IsStatic ) ;
78- CppInteropFunction setRecipe = new CppInteropFunction ( context , result . CppDefinition . Type , field . Name )
79- . Parameters ( new [ ] { new CppInteropParameter ( "value" , setType ) } )
80- . ReturnType ( CppType . Void )
81- . Static ( field . IsStatic ) ;
73+ CppInteropFunction baseRecipe = new CppInteropFunction ( context , result . CppDefinition . Type , field . Name ) . Static ( field . IsStatic ) ;
74+ CppInteropFunction getRecipe = baseRecipe . Clone ( ) . ReturnType ( fieldType . AsReturnType ( ) ) ;
75+ CppInteropFunction setRecipe = baseRecipe . Clone ( ) . Parameters ( [ new CppInteropParameter ( "value" , fieldType . AsParameterType ( ) ) ] ) ;
8276
8377 var ( getCsName , getCsContent ) = Interop . CreateCSharpDelegateInit ( context , item . Type , field , isGet : true ) ;
8478 var ( setCsName , setCsContent ) = Interop . CreateCSharpDelegateInit ( context , item . Type , field , isGet : false ) ;
8579
8680 getRecipe . AddToGeneration ( result , getCsName , getCsContent , getRecipe . Body ( ) ) ;
87-
88- IReadOnlyList < CppStatement > setterBody = CppInterop . CallManagedFunction (
89- new CppIdentifier ( setRecipe . FunctionPointerName ) , setRecipe . CallArguments ( ) ) ;
90- setRecipe . AddToGeneration ( result , setCsName , setCsContent , setterBody ) ;
81+ setRecipe . AddToGeneration ( result , setCsName , setCsContent , setRecipe . Body ( ) ) ;
9182 }
9283 }
9384}
0 commit comments