summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/function_definition.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/function_definition.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index df72f2c..cded973 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -1,3 +1,18 @@
1/*
2 * Copyright 2019 by its authors. See AUTHORS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
1#ifndef EOLIAN_MONO_FUNCTION_DEFINITION_HH 16#ifndef EOLIAN_MONO_FUNCTION_DEFINITION_HH
2#define EOLIAN_MONO_FUNCTION_DEFINITION_HH 17#define EOLIAN_MONO_FUNCTION_DEFINITION_HH
3 18
@@ -61,7 +76,7 @@ struct native_function_definition_generator
61 if(!as_generator 76 if(!as_generator
62 ( 77 (
63 indent << eolian_mono::marshall_annotation(true) << "\n" 78 indent << eolian_mono::marshall_annotation(true) << "\n"
64 << indent << "public delegate " 79 << indent << "internal delegate "
65 << eolian_mono::marshall_type(true) 80 << eolian_mono::marshall_type(true)
66 << " " 81 << " "
67 << string << "_api_delegate(" << (f.is_static ? "" : "System.IntPtr obj") 82 << string << "_api_delegate(" << (f.is_static ? "" : "System.IntPtr obj")
@@ -76,7 +91,7 @@ struct native_function_definition_generator
76 91
77 // Delegate holder (so it can't be collected). 92 // Delegate holder (so it can't be collected).
78 if(!as_generator 93 if(!as_generator
79 (indent << "public static Efl.Eo.FunctionWrapper<" << string << "_api_delegate> " << string << "_ptr = new Efl.Eo.FunctionWrapper<" 94 (indent << "internal static readonly Efl.Eo.FunctionWrapper<" << string << "_api_delegate> " << string << "_ptr = new Efl.Eo.FunctionWrapper<"
80 << string << "_api_delegate>(Module, \"" << string << "\");\n\n") 95 << string << "_api_delegate>(Module, \"" << string << "\");\n\n")
81 .generate(sink, std::make_tuple(f.c_name, f.c_name, f.c_name, f.c_name), context)) 96 .generate(sink, std::make_tuple(f.c_name, f.c_name, f.c_name, f.c_name), context))
82 return false; 97 return false;
@@ -102,13 +117,14 @@ struct native_function_definition_generator
102 else 117 else
103 klass_cast_name = name_helpers::klass_inherit_name(*klass); 118 klass_cast_name = name_helpers::klass_inherit_name(*klass);
104 119
105 std::string self = "Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj))"; 120 std::string self = "Efl.Eo.Globals.Super(obj, Efl.Eo.Globals.GetClass(obj))";
106 121
107 if (f.is_static) 122 if (f.is_static)
108 self = ""; 123 self = "";
109 124
110 if(!as_generator 125 if(!as_generator
111 (indent << "private static " 126 (indent << "[SuppressMessage(\"Microsoft.Reliability\", \"CA2000:DisposeObjectsBeforeLosingScope\", Justification = \"The instantiated objects can be stored in the called Managed API method.\")]\n"
127 << indent << "private static "
112 << eolian_mono::marshall_type(true) << " " 128 << eolian_mono::marshall_type(true) << " "
113 << string 129 << string
114 << "(System.IntPtr obj, System.IntPtr pd" 130 << "(System.IntPtr obj, System.IntPtr pd"
@@ -198,7 +214,7 @@ struct function_definition_generator
198 // IsGeneratedBindingClass is set in the constructor, true if this 214 // IsGeneratedBindingClass is set in the constructor, true if this
199 // instance is from a pure C# class (not generated). 215 // instance is from a pure C# class (not generated).
200 if (do_super && !f.is_static) 216 if (do_super && !f.is_static)
201 self = "(IsGeneratedBindingClass ? " + self + " : Efl.Eo.Globals.efl_super(" + self + ", this.NativeClass))"; 217 self = "(IsGeneratedBindingClass ? " + self + " : Efl.Eo.Globals.Super(" + self + ", this.NativeClass))";
202 else if (f.is_static) 218 else if (f.is_static)
203 self = ""; 219 self = "";
204 220
@@ -208,7 +224,7 @@ struct function_definition_generator
208 << scope_tab(2) << eolian_mono::function_definition_preamble() 224 << scope_tab(2) << eolian_mono::function_definition_preamble()
209 << klass_full_native_inherit_name(f.klass) << "." << string << "_ptr.Value.Delegate(" 225 << klass_full_native_inherit_name(f.klass) << "." << string << "_ptr.Value.Delegate("
210 << self 226 << self
211 << ((!f.is_static && (f.parameters.size() > 0)) ? "," : "") 227 << ((!f.is_static && (f.parameters.size() > 0)) ? ", " : "")
212 << (argument_invocation % ", ") << ");\n" 228 << (argument_invocation % ", ") << ");\n"
213 << scope_tab(2) << eolian_mono::function_definition_epilogue() 229 << scope_tab(2) << eolian_mono::function_definition_epilogue()
214 << scope_tab(1) << "}\n\n") 230 << scope_tab(1) << "}\n\n")
@@ -482,8 +498,8 @@ struct property_wrapper_definition_generator
482 << argument(false) << " = default(" << type(true) << ");\n" 498 << argument(false) << " = default(" << type(true) << ");\n"
483 ) 499 )
484 << scope_tab(3) << name_helpers::managed_method_name(*property.getter) 500 << scope_tab(3) << name_helpers::managed_method_name(*property.getter)
485 << "(" << (("out _out_" << argument(false)) % ",") << ");\n" 501 << "(" << (("out _out_" << argument(false)) % ", ") << ");\n"
486 << scope_tab(3) << "return (" << (("_out_"<< argument(false)) % ",") << ");\n" 502 << scope_tab(3) << "return (" << (("_out_"<< argument(false)) % ", ") << ");\n"
487 << scope_tab(2) << "}" << "\n" 503 << scope_tab(2) << "}" << "\n"
488 ).generate(sink, std::make_tuple(parameters, parameters, parameters), context)) 504 ).generate(sink, std::make_tuple(parameters, parameters, parameters), context))
489 return false; 505 return false;