summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/function_pointer.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/function_pointer.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_pointer.hh48
1 files changed, 21 insertions, 27 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/function_pointer.hh b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
index 721368f..3b50403 100644
--- a/src/bin/eolian_mono/eolian/mono/function_pointer.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_pointer.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_POINTER_HPP 16#ifndef EOLIAN_MONO_FUNCTION_POINTER_HPP
2#define EOLIAN_MONO_FUNCTION_POINTER_HPP 17#define EOLIAN_MONO_FUNCTION_POINTER_HPP
3 18
@@ -51,19 +66,19 @@ struct function_pointer {
51 return false; 66 return false;
52 // "Internal" delegate, 1-to-1 with the Unamaged function type 67 // "Internal" delegate, 1-to-1 with the Unamaged function type
53 if (!as_generator(marshall_annotation(true) 68 if (!as_generator(marshall_annotation(true)
54 << "public delegate " << marshall_type(true) << " " << string // public? 69 << "internal delegate " << marshall_type(true) << " " << string // public?
55 << "Internal(IntPtr data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_annotation << " " << marshall_parameter)) << ");\n") 70 << "Internal(IntPtr data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_annotation << " " << marshall_parameter)) << ");\n")
56 .generate(sink, std::make_tuple(f.return_type, f.return_type, f_name, f.parameters), funcptr_ctx)) 71 .generate(sink, std::make_tuple(f.return_type, f.return_type, f_name, f.parameters), funcptr_ctx))
57 return false; 72 return false;
58 73
59 // Wrapper type, with callback matching the Unamanaged one 74 // Wrapper type, with callback matching the Unamanaged one
60 if (!as_generator("internal class " << f_name << "Wrapper : IDisposable\n" 75 if (!as_generator("internal class " << f_name << "Wrapper\n"
61 << "{\n\n" 76 << "{\n\n"
62 << scope_tab << "private " << f_name << "Internal _cb;\n" 77 << scope_tab << "private " << f_name << "Internal _cb;\n"
63 << scope_tab << "private IntPtr _cb_data;\n" 78 << scope_tab << "private IntPtr _cb_data;\n"
64 << scope_tab << "private EinaFreeCb _cb_free_cb;\n\n" 79 << scope_tab << "private Eina.Callbacks.EinaFreeCb _cb_free_cb;\n\n"
65 80
66 << scope_tab << "internal " << f_name << "Wrapper (" << f_name << "Internal _cb, IntPtr _cb_data, EinaFreeCb _cb_free_cb)\n" 81 << scope_tab << "internal " << f_name << "Wrapper (" << f_name << "Internal _cb, IntPtr _cb_data, Eina.Callbacks.EinaFreeCb _cb_free_cb)\n"
67 << scope_tab << "{\n" 82 << scope_tab << "{\n"
68 << scope_tab << scope_tab << "this._cb = _cb;\n" 83 << scope_tab << scope_tab << "this._cb = _cb;\n"
69 << scope_tab << scope_tab << "this._cb_data = _cb_data;\n" 84 << scope_tab << scope_tab << "this._cb_data = _cb_data;\n"
@@ -72,34 +87,13 @@ struct function_pointer {
72 87
73 << scope_tab << "~" << f_name << "Wrapper()\n" 88 << scope_tab << "~" << f_name << "Wrapper()\n"
74 << scope_tab << "{\n" 89 << scope_tab << "{\n"
75 << scope_tab << scope_tab << "Dispose(false);\n"
76 << scope_tab << "}\n\n"
77
78 << scope_tab << "protected virtual void Dispose(bool disposing)\n"
79 << scope_tab << "{\n"
80 << scope_tab << scope_tab << "if (this._cb_free_cb != null)\n" 90 << scope_tab << scope_tab << "if (this._cb_free_cb != null)\n"
81 << scope_tab << scope_tab << "{\n" 91 << scope_tab << scope_tab << "{\n"
82 << scope_tab << scope_tab << scope_tab << "if (disposing)\n" 92 << scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.ThreadSafeFreeCbExec(this._cb_free_cb, this._cb_data);\n"
83 << scope_tab << scope_tab << scope_tab << "{\n"
84 << scope_tab << scope_tab << scope_tab << scope_tab << "this._cb_free_cb(this._cb_data);\n"
85 << scope_tab << scope_tab << scope_tab << "}\n"
86 << scope_tab << scope_tab << scope_tab << "else\n"
87 << scope_tab << scope_tab << scope_tab << "{\n"
88 << scope_tab << scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.ThreadSafeFreeCbExec(this._cb_free_cb, this._cb_data);\n"
89 << scope_tab << scope_tab << scope_tab << "}\n"
90 << scope_tab << scope_tab << scope_tab << "this._cb_free_cb = null;\n"
91 << scope_tab << scope_tab << scope_tab << "this._cb_data = IntPtr.Zero;\n"
92 << scope_tab << scope_tab << scope_tab << "this._cb = null;\n"
93 << scope_tab << scope_tab << "}\n" 93 << scope_tab << scope_tab << "}\n"
94 << scope_tab << "}\n\n" 94 << scope_tab << "}\n\n"
95 95
96 << scope_tab << "public void Dispose()\n" 96 << scope_tab << "internal " << type << " ManagedCb(" << (parameter % ", ") << ")\n"
97 << scope_tab << "{\n"
98 << scope_tab << scope_tab << "Dispose(true);\n"
99 << scope_tab << scope_tab << "GC.SuppressFinalize(this);\n"
100 << scope_tab << "}\n\n"
101
102 << scope_tab << "internal " << type << " ManagedCb(" << (parameter % ",") << ")\n"
103 << scope_tab << "{\n" 97 << scope_tab << "{\n"
104 << function_definition_preamble << "_cb(_cb_data, " << (argument_invocation % ", ") << ");\n" 98 << function_definition_preamble << "_cb(_cb_data, " << (argument_invocation % ", ") << ");\n"
105 << function_definition_epilogue 99 << function_definition_epilogue