summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/function_definition.hh
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2018-04-10 22:30:40 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2018-04-12 21:23:42 -0300
commit65f868786a59533a1cbf9d58b886cdc4f49ceb94 (patch)
treea0d2478b2f8504cb14d2e06ea78cb3c5b655764a /src/bin/eolian_mono/eolian/mono/function_definition.hh
parenta252c3445d2cf45aba332b6fcd634e54ee7239dc (diff)
efl_mono: Proper support for @class methods.
Previously, class methods were implemented as regular instance methods. This commits generates C# static methods for @class methods on the *Concrete classes (and their childs).
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/function_definition.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index 04e8921..e030434 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -11,6 +11,7 @@
11#include "grammar/alternative.hpp" 11#include "grammar/alternative.hpp"
12#include "grammar/attribute_reorder.hpp" 12#include "grammar/attribute_reorder.hpp"
13#include "type.hh" 13#include "type.hh"
14#include "helpers.hh"
14#include "function_helpers.hh" 15#include "function_helpers.hh"
15#include "marshall_type.hh" 16#include "marshall_type.hh"
16#include "parameter.hh" 17#include "parameter.hh"
@@ -28,7 +29,7 @@ struct native_function_definition_generator
28 template <typename OutputIterator, typename Context> 29 template <typename OutputIterator, typename Context>
29 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 30 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
30 { 31 {
31 if(is_function_blacklisted(f.c_name)) 32 if(is_function_blacklisted(f.c_name) || f.is_static) // Only Concrete classes implement static methods.
32 return true; 33 return true;
33 else 34 else
34 { 35 {
@@ -131,10 +132,11 @@ struct function_definition_generator
131 template <typename OutputIterator, typename Context> 132 template <typename OutputIterator, typename Context>
132 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 133 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
133 { 134 {
135 if(do_super && f.is_static) // Static methods goes only on Concrete classes.
136 return true;
134 if(is_function_blacklisted(f.c_name)) 137 if(is_function_blacklisted(f.c_name))
135 return true; 138 return true;
136 else 139
137 {
138 if(!as_generator 140 if(!as_generator
139 ("\n\n" << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(context).actual_library_name(f.filename) << ")]\n" 141 ("\n\n" << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(context).actual_library_name(f.filename) << ")]\n"
140 << scope_tab << eolian_mono::marshall_annotation(true) 142 << scope_tab << eolian_mono::marshall_annotation(true)
@@ -159,11 +161,11 @@ struct function_definition_generator
159 return false; 161 return false;
160 162
161 if(!as_generator 163 if(!as_generator
162 (scope_tab << (do_super ? "virtual " : "") << "public " << return_type << " " << string << "(" << (parameter % ", ") 164 (scope_tab << (do_super ? "virtual " : "") << "public " << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ")
163 << ") {\n " 165 << ") {\n "
164 << eolian_mono::function_definition_preamble() << string << "(" 166 << eolian_mono::function_definition_preamble() << string << "("
165 << (do_super ? "efl.eo.Globals.efl_super(" : "") 167 << (do_super ? "efl.eo.Globals.efl_super(" : "")
166 << "this.raw_handle" 168 << (f.is_static ? klass_get_name(f.klass) + "()": "this.raw_handle")
167 << (do_super ? ", this.raw_klass)" : "") 169 << (do_super ? ", this.raw_klass)" : "")
168 << *(", " << argument_invocation ) << ");\n" 170 << *(", " << argument_invocation ) << ");\n"
169 << eolian_mono::function_definition_epilogue() 171 << eolian_mono::function_definition_epilogue()
@@ -172,7 +174,6 @@ struct function_definition_generator
172 return false; 174 return false;
173 175
174 return true; 176 return true;
175 }
176 } 177 }
177 178
178 bool do_super; 179 bool do_super;