summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/struct_definition.hh
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2018-11-29 21:04:37 -0200
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2018-11-29 21:29:48 -0200
commit3623753c1d6b893955a1c31e8559a2312f674192 (patch)
treee862682ff92d34ce4ebf44c95efa24ba3a57fe7a /src/bin/eolian_mono/eolian/mono/struct_definition.hh
parenteec7bc458eee333fd7237a3bd43e8c2c884f21ca (diff)
csharp: Change to new class API.
Summary: As discussed in T7204: - Eo Interfaces/mixins -> C# Interfaces with concrete class implementations - Eo Regular/Abstracts -> Proper C# classes - Added some new generators and helper methods. - Refactored the class generator, splitting into helper methods Eo handles now are stored only in the "root" class in any given inheritance tree (generally, Efl.Object), and accessible to each child. Methods also are defined in a single place instead of repeatedly generated in everyfile, reducing the size of the generated .dll from 30MB to around 4.5MB. Mixins are generated as C# interfaces but any regular class it inherits from is lost, as we can't have interfaces inheriting from regular classes. This will be dealt with in a later commit. Summary of API Changes: - Merged Inherit/Concrete classes. (These suffixes disappear from regular classes). - Interface still have implementations with 'Concrete' suffix for when they are returned from methods. - Removed 'I' from interface names. - Removed interfaces for regular/abstract Eo classes. - Concrete classes for interfaces/mixins hold the event argument struct. - Removed '_' from classes, enums, structs, etc, as indicated in C# naming conventions. - Namespaces are now Camel.Cased. - Renamed IWrapper's raw_handle/raw_klass to NativeHandle/NativeClass Also renamed the test classes as after the namespace change, the test namespace Test can conflict with the helper Test namespace. (And use more meaningful names than Test.Testing...) Also Fixes T7336 by removing a deprecated example and adding efl_loop_timer_example to build system. Fixes T7451 by hiding the class_get DllImports and renaming the IWrapper fields. The native handlers are used in the manual binding. Still need to work: - As there are still some events names clashing (e.g. Efl.Ui.Bg with "resize" from Efl.Gfx.Entity and Efl.Gfx.Image), Events are currently declared on the interface and implemented "namespaced" in the classes, requiring the cast to the interface to access the event. - The Mixin Conundrum. Mixin inheritance will be dealt in a future commit. Depends on D7260 Reviewers: segfaultxavi, vitor.sousa, felipealmeida, Jaehyun_Cho Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T7451, T7336 Differential Revision: https://phab.enlightenment.org/D7262
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/struct_definition.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/struct_definition.hh28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
index 58007a2cdd..99347ed1dc 100644
--- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
@@ -18,12 +18,12 @@ namespace eolian_mono {
18 18
19inline std::string binding_struct_name(attributes::struct_def const& struct_) 19inline std::string binding_struct_name(attributes::struct_def const& struct_)
20{ 20{
21 return struct_.cxx_name; 21 return name_helpers::typedecl_managed_name(struct_);
22} 22}
23 23
24inline std::string binding_struct_internal_name(attributes::struct_def const& struct_) 24inline std::string binding_struct_internal_name(attributes::struct_def const& struct_)
25{ 25{
26 return struct_.cxx_name + "_StructInternal"; 26 return binding_struct_name(struct_) + "_StructInternal";
27} 27}
28 28
29struct struct_definition_generator 29struct struct_definition_generator
@@ -175,7 +175,7 @@ struct to_internal_field_convert_generator
175 if (klass) 175 if (klass)
176 { 176 {
177 if (!as_generator( 177 if (!as_generator(
178 scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ".raw_handle;\n") 178 scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ".NativeHandle;\n")
179 .generate(sink, std::make_tuple(field_name, field_name), context)) 179 .generate(sink, std::make_tuple(field_name, field_name), context))
180 return false; 180 return false;
181 } 181 }
@@ -196,7 +196,7 @@ struct to_internal_field_convert_generator
196 else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular)) 196 else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular))
197 { 197 {
198 if (!as_generator( 198 if (!as_generator(
199 scope_tab << scope_tab << "_internal_struct." << string << " = eina.PrimitiveConversion.ManagedToPointerAlloc(_external_struct." << string << ");\n") 199 scope_tab << scope_tab << "_internal_struct." << string << " = Eina.PrimitiveConversion.ManagedToPointerAlloc(_external_struct." << string << ");\n")
200 .generate(sink, std::make_tuple(field_name, field_name), context)) 200 .generate(sink, std::make_tuple(field_name, field_name), context))
201 return false; 201 return false;
202 } 202 }
@@ -210,14 +210,14 @@ struct to_internal_field_convert_generator
210 else if (regular && (regular->base_type == "string" || regular->base_type == "mstring")) 210 else if (regular && (regular->base_type == "string" || regular->base_type == "mstring"))
211 { 211 {
212 if (!as_generator( 212 if (!as_generator(
213 scope_tab << scope_tab << "_internal_struct." << string << " = eina.MemoryNative.StrDup(_external_struct." << string << ");\n") 213 scope_tab << scope_tab << "_internal_struct." << string << " = Eina.MemoryNative.StrDup(_external_struct." << string << ");\n")
214 .generate(sink, std::make_tuple(field_name, field_name), context)) 214 .generate(sink, std::make_tuple(field_name, field_name), context))
215 return false; 215 return false;
216 } 216 }
217 else if (regular && regular->base_type == "stringshare") 217 else if (regular && regular->base_type == "stringshare")
218 { 218 {
219 if (!as_generator( 219 if (!as_generator(
220 scope_tab << scope_tab << "_internal_struct." << string << " = eina.Stringshare.eina_stringshare_add(_external_struct." << string << ");\n") 220 scope_tab << scope_tab << "_internal_struct." << string << " = Eina.Stringshare.eina_stringshare_add(_external_struct." << string << ");\n")
221 .generate(sink, std::make_tuple(field_name, field_name), context)) 221 .generate(sink, std::make_tuple(field_name, field_name), context))
222 return false; 222 return false;
223 } 223 }
@@ -273,9 +273,9 @@ struct to_external_field_convert_generator
273 if (!as_generator( 273 if (!as_generator(
274 "\n" 274 "\n"
275 << scope_tab << scope_tab << "_external_struct." << string 275 << scope_tab << scope_tab << "_external_struct." << string
276 << " = (" << interface_name << ") System.Activator.CreateInstance(typeof(" 276 << " = (" << concrete_name << ") System.Activator.CreateInstance(typeof("
277 << concrete_name << "), new System.Object[] {_internal_struct." << string << "});\n" 277 << concrete_name << "), new System.Object[] {_internal_struct." << string << "});\n"
278 << scope_tab << scope_tab << "efl.eo.Globals.efl_ref(_internal_struct." << string << ");\n\n") 278 << scope_tab << scope_tab << "Efl.Eo.Globals.efl_ref(_internal_struct." << string << ");\n\n")
279 .generate(sink, std::make_tuple(field_name, field_name, field_name), context)) 279 .generate(sink, std::make_tuple(field_name, field_name, field_name), context))
280 return false; 280 return false;
281 } 281 }
@@ -308,7 +308,7 @@ struct to_external_field_convert_generator
308 else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular)) 308 else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular))
309 { 309 {
310 if (!as_generator( 310 if (!as_generator(
311 scope_tab << scope_tab << "_external_struct." << string << " = eina.PrimitiveConversion.PointerToManaged<" << type << ">(_internal_struct." << string << ");\n") 311 scope_tab << scope_tab << "_external_struct." << string << " = Eina.PrimitiveConversion.PointerToManaged<" << type << ">(_internal_struct." << string << ");\n")
312 .generate(sink, std::make_tuple(field_name, field.type, field_name), context)) 312 .generate(sink, std::make_tuple(field_name, field.type, field_name), context))
313 return false; 313 return false;
314 } 314 }
@@ -322,7 +322,7 @@ struct to_external_field_convert_generator
322 else if (regular && (regular->base_type == "string" || regular->base_type == "mstring" || regular->base_type == "stringshare")) 322 else if (regular && (regular->base_type == "string" || regular->base_type == "mstring" || regular->base_type == "stringshare"))
323 { 323 {
324 if (!as_generator( 324 if (!as_generator(
325 scope_tab << scope_tab << "_external_struct." << string << " = eina.StringConversion.NativeUtf8ToManagedString(_internal_struct." << string << ");\n") 325 scope_tab << scope_tab << "_external_struct." << string << " = Eina.StringConversion.NativeUtf8ToManagedString(_internal_struct." << string << ");\n")
326 .generate(sink, std::make_tuple(field_name, field_name), context)) 326 .generate(sink, std::make_tuple(field_name, field_name), context))
327 return false; 327 return false;
328 } 328 }
@@ -339,14 +339,14 @@ struct to_external_field_convert_generator
339 else if (field.type.c_type == "Eina_Value" || field.type.c_type == "const Eina_Value") 339 else if (field.type.c_type == "Eina_Value" || field.type.c_type == "const Eina_Value")
340 { 340 {
341 if (!as_generator( 341 if (!as_generator(
342 scope_tab << scope_tab << "_external_struct." << string << " = new eina.Value(_internal_struct." << string << ");\n" 342 scope_tab << scope_tab << "_external_struct." << string << " = new Eina.Value(_internal_struct." << string << ");\n"
343 ).generate(sink, std::make_tuple(field_name, field_name), context)) 343 ).generate(sink, std::make_tuple(field_name, field_name), context))
344 return false; 344 return false;
345 } 345 }
346 else if (field.type.c_type == "Eina_Value *" || field.type.c_type == "const Eina_Value *") 346 else if (field.type.c_type == "Eina_Value *" || field.type.c_type == "const Eina_Value *")
347 { 347 {
348 if (!as_generator( 348 if (!as_generator(
349 scope_tab << scope_tab << "_external_struct." << string << " = new eina.Value(_internal_struct." << string << ", eina.Ownership.Unmanaged);\n" 349 scope_tab << scope_tab << "_external_struct." << string << " = new Eina.Value(_internal_struct." << string << ", Eina.Ownership.Unmanaged);\n"
350 ).generate(sink, std::make_tuple(field_name, field_name), context)) 350 ).generate(sink, std::make_tuple(field_name, field_name), context))
351 return false; 351 return false;
352 } 352 }
@@ -369,8 +369,8 @@ struct struct_binding_conversion_functions_generator
369 // Open conversion class 369 // Open conversion class
370 if (!as_generator 370 if (!as_generator
371 ( 371 (
372 "/// <summary>Conversion class for struct " << struct_.cxx_name << "</summary>\n" 372 "/// <summary>Conversion class for struct " << name_helpers::typedecl_managed_name(struct_) << "</summary>\n"
373 "public static class " << struct_.cxx_name << "_StructConversion\n{\n" 373 "public static class " << name_helpers::typedecl_managed_name(struct_) << "_StructConversion\n{\n"
374 ) 374 )
375 .generate(sink, nullptr, context)) 375 .generate(sink, nullptr, context))
376 return false; 376 return false;