summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2018-05-02 19:49:37 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2018-05-03 18:04:41 -0300
commit4636d6e0eb1f4a66b202b6cf6df793ec40c135a6 (patch)
treea0fc192dc8e2e52775c8a39209d1bdc740f3a807 /src/bin
parentc9dd86579f1e4b585e5dadbc9f69df0abd263917 (diff)
efl_mono: Change generated classes naming scheme
Summary: Now the generated classes use an approach more familiar to C# developers: Interfaces: efl.Object -> efl.IObject Concrete (implementation) classes: efl.ObjectConcrete -> efl.Object. During this change, some methods that could clash with the implementation class name (CS0542) had the prefix "Do" added (like in efl.Duplicate.Duplicate() and efl.Pack.Pack()). Depends on D6049 Reviewers: felipealmeida, vitor.sousa Reviewed By: vitor.sousa Subscribers: cedric Tags: #efl Differential Revision: https://phab.enlightenment.org/D6050
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian_mono/eolian/mono/enum_definition.hh2
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_declaration.hh2
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh4
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh10
-rw-r--r--src/bin/eolian_mono/eolian/mono/name_helpers.hh21
-rw-r--r--src/bin/eolian_mono/eolian/mono/part_definition.hh2
6 files changed, 26 insertions, 15 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/enum_definition.hh b/src/bin/eolian_mono/eolian/mono/enum_definition.hh
index f7c40d7201..9261f5b2e6 100644
--- a/src/bin/eolian_mono/eolian/mono/enum_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/enum_definition.hh
@@ -27,7 +27,7 @@ struct enum_definition_generator
27 ( 27 (
28 "public enum " << string << "\n{\n" 28 "public enum " << string << "\n{\n"
29 ) 29 )
30 .generate(sink, enum_.cxx_name, context)) 30 .generate(sink, name_helpers::enum_managed_name(enum_), context))
31 return false; 31 return false;
32 32
33 // iterate enum fiels 33 // iterate enum fiels
diff --git a/src/bin/eolian_mono/eolian/mono/function_declaration.hh b/src/bin/eolian_mono/eolian/mono/function_declaration.hh
index 80a2782bf4..8fdb8269e8 100644
--- a/src/bin/eolian_mono/eolian/mono/function_declaration.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_declaration.hh
@@ -28,7 +28,7 @@ struct function_declaration_generator
28 28
29 return as_generator 29 return as_generator
30 (eolian_mono::type(true) << " " << string << "(" << (parameter % ", ") << ");\n") 30 (eolian_mono::type(true) << " " << string << "(" << (parameter % ", ") << ");\n")
31 .generate(sink, std::make_tuple(f.return_type, name_helpers::managed_method_name(f.name), f.parameters), context); 31 .generate(sink, std::make_tuple(f.return_type, name_helpers::managed_method_name(f), f.parameters), context);
32 } 32 }
33}; 33};
34 34
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index b5553489c8..7e44b2938b 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -105,7 +105,7 @@ struct native_function_definition_generator
105 .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
106 , /***/f.c_name/***/ 106 , /***/f.c_name/***/
107 , f 107 , f
108 , managed_method_name(f.name) 108 , name_helpers::managed_method_name(f)
109 , f.parameters 109 , f.parameters
110 , f 110 , f
111 , f.c_name 111 , f.c_name
@@ -175,7 +175,7 @@ struct function_definition_generator
175 << *(", " << argument_invocation ) << ");\n" 175 << *(", " << argument_invocation ) << ");\n"
176 << eolian_mono::function_definition_epilogue() 176 << eolian_mono::function_definition_epilogue()
177 << " }\n") 177 << " }\n")
178 .generate(sink, std::make_tuple(managed_method_name(f.name), f.parameters, f, f.c_name, f.parameters, f), context)) 178 .generate(sink, std::make_tuple(name_helpers::managed_method_name(f), f.parameters, f, f.c_name, f.parameters, f), context))
179 return false; 179 return false;
180 180
181 return true; 181 return true;
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index 7f67dddc08..dcbead34d0 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -34,7 +34,7 @@ static bool generate_static_cast_method(OutputIterator sink, grammar::attributes
34{ 34{
35 return as_generator( 35 return as_generator(
36 scope_tab << "///<summary>Casts obj into an instance of this type.</summary>\n" 36 scope_tab << "///<summary>Casts obj into an instance of this type.</summary>\n"
37 << scope_tab << "public static " << name_helpers::klass_interface_name(cls) << " static_cast(efl.Object obj)\n" 37 << scope_tab << "public static " << name_helpers::klass_interface_name(cls) << " static_cast(efl.IObject obj)\n"
38 << scope_tab << "{\n" 38 << scope_tab << "{\n"
39 << scope_tab << scope_tab << "if (obj == null)\n" 39 << scope_tab << scope_tab << "if (obj == null)\n"
40 << scope_tab << scope_tab << scope_tab << "throw new System.ArgumentNullException(\"obj\");\n" 40 << scope_tab << scope_tab << scope_tab << "throw new System.ArgumentNullException(\"obj\");\n"
@@ -50,7 +50,7 @@ static bool generate_equals_method(OutputIterator sink, Context const &context)
50 scope_tab << "///<summary>Verifies if the given object is equals to this.</summary>\n" 50 scope_tab << "///<summary>Verifies if the given object is equals to this.</summary>\n"
51 << scope_tab << "public override bool Equals(object obj)\n" 51 << scope_tab << "public override bool Equals(object obj)\n"
52 << scope_tab << "{\n" 52 << scope_tab << "{\n"
53 << scope_tab << scope_tab << "var other = obj as efl.Object;\n" 53 << scope_tab << scope_tab << "var other = obj as efl.IObject;\n"
54 << scope_tab << scope_tab << "if (other == null)\n" 54 << scope_tab << scope_tab << "if (other == null)\n"
55 << scope_tab << scope_tab << scope_tab << "return false;\n" 55 << scope_tab << scope_tab << scope_tab << "return false;\n"
56 << scope_tab << scope_tab << "return this.raw_handle == other.raw_handle;\n" 56 << scope_tab << scope_tab << "return this.raw_handle == other.raw_handle;\n"
@@ -126,7 +126,7 @@ struct klass
126 ( 126 (
127 "public " /*<< class_type*/ "interface" /*<<*/ " " << string << " : " 127 "public " /*<< class_type*/ "interface" /*<<*/ " " << string << " : "
128 ) 128 )
129 .generate(sink, cls.cxx_name, iface_cxt)) 129 .generate(sink, name_helpers::klass_interface_name(cls), iface_cxt))
130 return false; 130 return false;
131 for(auto first = std::begin(cls.immediate_inherits) 131 for(auto first = std::begin(cls.immediate_inherits)
132 , last = std::end(cls.immediate_inherits); first != last; ++first) 132 , last = std::end(cls.immediate_inherits); first != last; ++first)
@@ -186,7 +186,7 @@ struct klass
186 << scope_tab << "///<summary>Creates a new instance.</summary>\n" 186 << scope_tab << "///<summary>Creates a new instance.</summary>\n"
187 << scope_tab << "///<param>Parent instance.</param>\n" 187 << scope_tab << "///<param>Parent instance.</param>\n"
188 << scope_tab << "///<param>Delegate to call constructing methods that should be run inside the constructor.</param>\n" 188 << scope_tab << "///<param>Delegate to call constructing methods that should be run inside the constructor.</param>\n"
189 << scope_tab << "public " << concrete_name << "(efl.Object parent = null, ConstructingMethod init_cb=null)\n" 189 << scope_tab << "public " << concrete_name << "(efl.IObject parent = null, ConstructingMethod init_cb=null)\n"
190 << scope_tab << "{\n" 190 << scope_tab << "{\n"
191 << scope_tab << scope_tab << "System.IntPtr klass = " << name_helpers::klass_get_name(cls) << "();\n" 191 << scope_tab << scope_tab << "System.IntPtr klass = " << name_helpers::klass_get_name(cls) << "();\n"
192 << scope_tab << scope_tab << "System.IntPtr parent_ptr = System.IntPtr.Zero;\n" 192 << scope_tab << scope_tab << "System.IntPtr parent_ptr = System.IntPtr.Zero;\n"
@@ -293,7 +293,7 @@ struct klass
293 << scope_tab << "///<summary>Creates a new instance.</summary>\n" 293 << scope_tab << "///<summary>Creates a new instance.</summary>\n"
294 << scope_tab << "///<param>Parent instance.</param>\n" 294 << scope_tab << "///<param>Parent instance.</param>\n"
295 << scope_tab << "///<param>Delegate to call constructing methods that should be run inside the constructor.</param>\n" 295 << scope_tab << "///<param>Delegate to call constructing methods that should be run inside the constructor.</param>\n"
296 << scope_tab << "public " << inherit_name << "(efl.Object parent = null, ConstructingMethod init_cb=null)\n" 296 << scope_tab << "public " << inherit_name << "(efl.IObject parent = null, ConstructingMethod init_cb=null)\n"
297 << scope_tab << "{\n" 297 << scope_tab << "{\n"
298 << scope_tab << scope_tab << "if (klass == System.IntPtr.Zero) {\n" 298 << scope_tab << scope_tab << "if (klass == System.IntPtr.Zero) {\n"
299 << scope_tab << scope_tab << scope_tab << "lock (klassAllocLock) {\n" 299 << scope_tab << scope_tab << scope_tab << "lock (klassAllocLock) {\n"
diff --git a/src/bin/eolian_mono/eolian/mono/name_helpers.hh b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
index 59d6b59b18..bba06e9221 100644
--- a/src/bin/eolian_mono/eolian/mono/name_helpers.hh
+++ b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
@@ -172,13 +172,19 @@ inline std::string managed_namespace(std::string const& ns)
172 return utils::to_lowercase(escape_keyword(ns)); 172 return utils::to_lowercase(escape_keyword(ns));
173} 173}
174 174
175inline std::string managed_method_name(std::string const& underscore_name) 175inline std::string managed_method_name(attributes::function_def const& f)
176{ 176{
177 std::vector<std::string> names = utils::split(underscore_name, '_'); 177 std::vector<std::string> names = utils::split(f.name, '_');
178 178
179 name_helpers::reorder_verb(names); 179 name_helpers::reorder_verb(names);
180 180
181 return escape_keyword(utils::to_pascal_case(names)); 181 std::string candidate = escape_keyword(utils::to_pascal_case(names));
182
183 // Some eolian methods have the same name as their parent class
184 if (candidate == f.klass.eolian_name)
185 candidate = "Do" + candidate;
186
187 return candidate;
182} 188}
183 189
184inline std::string function_ptr_full_eolian_name(attributes::function_def const& func) 190inline std::string function_ptr_full_eolian_name(attributes::function_def const& func)
@@ -201,6 +207,11 @@ inline std::string struct_full_eolian_name(attributes::struct_def const& struct_
201 return join_namespaces(struct_.namespaces, '.') + struct_.cxx_name; 207 return join_namespaces(struct_.namespaces, '.') + struct_.cxx_name;
202} 208}
203 209
210inline std::string enum_managed_name(attributes::enum_def const& enum_)
211{
212 return enum_.cxx_name;
213}
214
204inline std::string to_field_name(std::string const& in) 215inline std::string to_field_name(std::string const& in)
205{ 216{
206 return utils::capitalize(in); 217 return utils::capitalize(in);
@@ -210,7 +221,7 @@ inline std::string to_field_name(std::string const& in)
210template<typename T> 221template<typename T>
211inline std::string klass_interface_name(T const& klass) 222inline std::string klass_interface_name(T const& klass)
212{ 223{
213 return klass.eolian_name; 224 return "I" + klass.eolian_name;
214} 225}
215 226
216template<typename T> 227template<typename T>
@@ -222,7 +233,7 @@ inline std::string klass_full_interface_name(T const& klass)
222template<typename T> 233template<typename T>
223inline std::string klass_concrete_name(T const& klass) 234inline std::string klass_concrete_name(T const& klass)
224{ 235{
225 return klass.eolian_name + "Concrete"; 236 return klass.eolian_name;
226} 237}
227 238
228template<typename T> 239template<typename T>
diff --git a/src/bin/eolian_mono/eolian/mono/part_definition.hh b/src/bin/eolian_mono/eolian/mono/part_definition.hh
index 2a54ceb961..bba29dc8c3 100644
--- a/src/bin/eolian_mono/eolian/mono/part_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/part_definition.hh
@@ -25,7 +25,7 @@ struct part_definition_generator
25 << scope_tab << "{\n" 25 << scope_tab << "{\n"
26 << scope_tab << scope_tab << "get\n" 26 << scope_tab << scope_tab << "get\n"
27 << scope_tab << scope_tab << "{\n" 27 << scope_tab << scope_tab << "{\n"
28 << scope_tab << scope_tab << scope_tab << "efl.Object obj = efl_part(raw_handle, \"" << part.name << "\");\n" 28 << scope_tab << scope_tab << scope_tab << "efl.IObject obj = efl_part(raw_handle, \"" << part.name << "\");\n"
29 << scope_tab << scope_tab << scope_tab << "return " << part_klass_name << ".static_cast(obj);\n" 29 << scope_tab << scope_tab << scope_tab << "return " << part_klass_name << ".static_cast(obj);\n"
30 << scope_tab << scope_tab << "}\n" 30 << scope_tab << scope_tab << "}\n"
31 << scope_tab << "}\n" 31 << scope_tab << "}\n"