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-27 18:08:25 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2018-05-03 18:04:41 -0300
commitc9dd86579f1e4b585e5dadbc9f69df0abd263917 (patch)
treeba8b38e3600b15dec828e170dbe070dfd2bcb654 /src/bin/eolian_mono/eolian/mono/function_definition.hh
parentf39baf1e82d7571225ac6429f7486e60abcf604f (diff)
efl_mono: More uniformization of the handling of names
Summary: Uses a common helper to open and close namespaces, to get the managed and unmanaged name of things, the interface, concrete and inherit class names, etc. eolian_cxx: Add namespace information to func_def, as it'll avoid eolian-cxx clients dealing with the eolian C api directly when trying to access a function pointer namespace. Depends on D6048 Reviewers: felipealmeida, vitor.sousa Reviewed By: vitor.sousa Subscribers: cedric Tags: #efl Differential Revision: https://phab.enlightenment.org/D6049
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/function_definition.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh20
1 files changed, 12 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 bf7d15e..b555348 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -10,6 +10,7 @@
10#include "grammar/list.hpp" 10#include "grammar/list.hpp"
11#include "grammar/alternative.hpp" 11#include "grammar/alternative.hpp"
12#include "grammar/attribute_reorder.hpp" 12#include "grammar/attribute_reorder.hpp"
13#include "logging.hh"
13#include "type.hh" 14#include "type.hh"
14#include "name_helpers.hh" 15#include "name_helpers.hh"
15#include "helpers.hh" 16#include "helpers.hh"
@@ -30,6 +31,7 @@ struct native_function_definition_generator
30 template <typename OutputIterator, typename Context> 31 template <typename OutputIterator, typename Context>
31 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 32 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
32 { 33 {
34 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "native_function_definition_generator: " << f.c_name << std::endl;
33 if(blacklist::is_function_blacklisted(f.c_name) || f.is_static) // Only Concrete classes implement static methods. 35 if(blacklist::is_function_blacklisted(f.c_name) || f.is_static) // Only Concrete classes implement static methods.
34 return true; 36 return true;
35 else 37 else
@@ -69,6 +71,8 @@ struct native_function_definition_generator
69 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context)) 71 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context))
70 return false; 72 return false;
71 73
74 std::string klass_inherit_name = name_helpers::klass_inherit_name(*klass);
75
72 if(!as_generator 76 if(!as_generator
73 (scope_tab 77 (scope_tab
74 << " private static " 78 << " private static "
@@ -85,7 +89,7 @@ struct native_function_definition_generator
85 << scope_tab << scope_tab << "if(wrapper != null) {\n" 89 << scope_tab << scope_tab << "if(wrapper != null) {\n"
86 << scope_tab << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble() 90 << scope_tab << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble()
87 << scope_tab << scope_tab << scope_tab << "try {\n" 91 << scope_tab << scope_tab << scope_tab << "try {\n"
88 << scope_tab << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "") << "((" << string << "Inherit)wrapper)." << string 92 << scope_tab << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "") << "((" << klass_inherit_name << ")wrapper)." << string
89 << "(" << (native_argument_invocation % ", ") << ");\n" 93 << "(" << (native_argument_invocation % ", ") << ");\n"
90 << scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n" 94 << scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n"
91 << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Warning($\"Callback error: {e.ToString()}\");\n" 95 << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Warning($\"Callback error: {e.ToString()}\");\n"
@@ -94,18 +98,18 @@ struct native_function_definition_generator
94 << eolian_mono::native_function_definition_epilogue(*klass) 98 << eolian_mono::native_function_definition_epilogue(*klass)
95 << scope_tab << scope_tab << "} else {\n" 99 << scope_tab << scope_tab << "} else {\n"
96 << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "return " : "") << string 100 << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "return " : "") << string
97 << "(efl.eo.Globals.efl_super(obj, " << string << "Inherit.klass)" << *(", " << argument) << ");\n" 101 << "(efl.eo.Globals.efl_super(obj, " << klass_inherit_name << ".klass)" << *(", " << argument) << ");\n"
98 << scope_tab << scope_tab << "}\n" 102 << scope_tab << scope_tab << "}\n"
99 << scope_tab << "}\n" 103 << scope_tab << "}\n"
100 ) 104 )
101 .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters 105 .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters
102 , /***/f.c_name/***/ 106 , /***/f.c_name/***/
103 , f 107 , f
104 , klass->cxx_name, managed_method_name(f.name) 108 , managed_method_name(f.name)
105 , f.parameters 109 , f.parameters
106 , f 110 , f
107 , f.c_name 111 , f.c_name
108 , klass->cxx_name, f.parameters 112 , f.parameters
109 ) 113 )
110 , context)) 114 , context))
111 return false; 115 return false;
@@ -114,10 +118,9 @@ struct native_function_definition_generator
114 (scope_tab << "private static " 118 (scope_tab << "private static "
115 << string 119 << string
116 << "_delegate " 120 << "_delegate "
117 << string << "_static_delegate = new " << string << "_delegate(" << string << "NativeInherit." << string << ");\n" 121 << string << "_static_delegate = new " << string << "_delegate(" << name_helpers::klass_native_inherit_name(*klass) << "." << string << ");\n"
118 ) 122 )
119 .generate(sink, std::make_tuple(f.c_name, f.c_name, f.c_name, klass->cxx_name 123 .generate(sink, std::make_tuple(f.c_name, f.c_name, f.c_name, escape_keyword(f.name)), context))
120 , escape_keyword(f.name)), context))
121 return false; 124 return false;
122 return true; 125 return true;
123 } 126 }
@@ -133,6 +136,7 @@ struct function_definition_generator
133 template <typename OutputIterator, typename Context> 136 template <typename OutputIterator, typename Context>
134 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 137 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
135 { 138 {
139 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "function_definition_generator: " << f.c_name << std::endl;
136 if(do_super && f.is_static) // Static methods goes only on Concrete classes. 140 if(do_super && f.is_static) // Static methods goes only on Concrete classes.
137 return true; 141 return true;
138 if(blacklist::is_function_blacklisted(f.c_name)) 142 if(blacklist::is_function_blacklisted(f.c_name))
@@ -166,7 +170,7 @@ struct function_definition_generator
166 << ") {\n " 170 << ") {\n "
167 << eolian_mono::function_definition_preamble() << string << "(" 171 << eolian_mono::function_definition_preamble() << string << "("
168 << (do_super ? "efl.eo.Globals.efl_super(" : "") 172 << (do_super ? "efl.eo.Globals.efl_super(" : "")
169 << (f.is_static ? name_helpers::klass_get_name(f.klass) + "()": "this.raw_handle") 173 << (f.is_static ? name_helpers::klass_get_full_name(f.klass) + "()": "this.raw_handle")
170 << (do_super ? ", this.raw_klass)" : "") 174 << (do_super ? ", this.raw_klass)" : "")
171 << *(", " << argument_invocation ) << ");\n" 175 << *(", " << argument_invocation ) << ");\n"
172 << eolian_mono::function_definition_epilogue() 176 << eolian_mono::function_definition_epilogue()