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
(
"public enum " << string << "\n{\n"
)
- .generate(sink, enum_.cxx_name, context))
+ .generate(sink, name_helpers::enum_managed_name(enum_), context))
return false;
// 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
return as_generator
(eolian_mono::type(true) << " " << string << "(" << (parameter % ", ") << ");\n")
- .generate(sink, std::make_tuple(f.return_type, name_helpers::managed_method_name(f.name), f.parameters), context);
+ .generate(sink, std::make_tuple(f.return_type, name_helpers::managed_method_name(f), f.parameters), context);
}
};
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
.generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters
, /***/f.c_name/***/
, f
- , managed_method_name(f.name)
+ , name_helpers::managed_method_name(f)
, f.parameters
, f
, f.c_name
@@ -175,7 +175,7 @@ struct function_definition_generator
<< *(", " << argument_invocation ) << ");\n"
<< eolian_mono::function_definition_epilogue()
<< " }\n")
- .generate(sink, std::make_tuple(managed_method_name(f.name), f.parameters, f, f.c_name, f.parameters, f), context))
+ .generate(sink, std::make_tuple(name_helpers::managed_method_name(f), f.parameters, f, f.c_name, f.parameters, f), context))
return false;
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
{
return as_generator(
scope_tab << "///Casts obj into an instance of this type.\n"
- << scope_tab << "public static " << name_helpers::klass_interface_name(cls) << " static_cast(efl.Object obj)\n"
+ << scope_tab << "public static " << name_helpers::klass_interface_name(cls) << " static_cast(efl.IObject obj)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "if (obj == null)\n"
<< 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)
scope_tab << "///Verifies if the given object is equals to this.\n"
<< scope_tab << "public override bool Equals(object obj)\n"
<< scope_tab << "{\n"
- << scope_tab << scope_tab << "var other = obj as efl.Object;\n"
+ << scope_tab << scope_tab << "var other = obj as efl.IObject;\n"
<< scope_tab << scope_tab << "if (other == null)\n"
<< scope_tab << scope_tab << scope_tab << "return false;\n"
<< scope_tab << scope_tab << "return this.raw_handle == other.raw_handle;\n"
@@ -126,7 +126,7 @@ struct klass
(
"public " /*<< class_type*/ "interface" /*<<*/ " " << string << " : "
)
- .generate(sink, cls.cxx_name, iface_cxt))
+ .generate(sink, name_helpers::klass_interface_name(cls), iface_cxt))
return false;
for(auto first = std::begin(cls.immediate_inherits)
, last = std::end(cls.immediate_inherits); first != last; ++first)
@@ -186,7 +186,7 @@ struct klass
<< scope_tab << "///Creates a new instance.\n"
<< scope_tab << "///Parent instance.\n"
<< scope_tab << "///Delegate to call constructing methods that should be run inside the constructor.\n"
- << scope_tab << "public " << concrete_name << "(efl.Object parent = null, ConstructingMethod init_cb=null)\n"
+ << scope_tab << "public " << concrete_name << "(efl.IObject parent = null, ConstructingMethod init_cb=null)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "System.IntPtr klass = " << name_helpers::klass_get_name(cls) << "();\n"
<< scope_tab << scope_tab << "System.IntPtr parent_ptr = System.IntPtr.Zero;\n"
@@ -293,7 +293,7 @@ struct klass
<< scope_tab << "///Creates a new instance.\n"
<< scope_tab << "///Parent instance.\n"
<< scope_tab << "///Delegate to call constructing methods that should be run inside the constructor.\n"
- << scope_tab << "public " << inherit_name << "(efl.Object parent = null, ConstructingMethod init_cb=null)\n"
+ << scope_tab << "public " << inherit_name << "(efl.IObject parent = null, ConstructingMethod init_cb=null)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "if (klass == System.IntPtr.Zero) {\n"
<< 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)
return utils::to_lowercase(escape_keyword(ns));
}
-inline std::string managed_method_name(std::string const& underscore_name)
+inline std::string managed_method_name(attributes::function_def const& f)
{
- std::vector names = utils::split(underscore_name, '_');
+ std::vector names = utils::split(f.name, '_');
name_helpers::reorder_verb(names);
- return escape_keyword(utils::to_pascal_case(names));
+ std::string candidate = escape_keyword(utils::to_pascal_case(names));
+
+ // Some eolian methods have the same name as their parent class
+ if (candidate == f.klass.eolian_name)
+ candidate = "Do" + candidate;
+
+ return candidate;
}
inline 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_
return join_namespaces(struct_.namespaces, '.') + struct_.cxx_name;
}
+inline std::string enum_managed_name(attributes::enum_def const& enum_)
+{
+ return enum_.cxx_name;
+}
+
inline std::string to_field_name(std::string const& in)
{
return utils::capitalize(in);
@@ -210,7 +221,7 @@ inline std::string to_field_name(std::string const& in)
template
inline std::string klass_interface_name(T const& klass)
{
- return klass.eolian_name;
+ return "I" + klass.eolian_name;
}
template
@@ -222,7 +233,7 @@ inline std::string klass_full_interface_name(T const& klass)
template
inline std::string klass_concrete_name(T const& klass)
{
- return klass.eolian_name + "Concrete";
+ return klass.eolian_name;
}
template
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
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "get\n"
<< scope_tab << scope_tab << "{\n"
- << scope_tab << scope_tab << scope_tab << "efl.Object obj = efl_part(raw_handle, \"" << part.name << "\");\n"
+ << scope_tab << scope_tab << scope_tab << "efl.IObject obj = efl_part(raw_handle, \"" << part.name << "\");\n"
<< scope_tab << scope_tab << scope_tab << "return " << part_klass_name << ".static_cast(obj);\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << "}\n"
diff --git a/src/bindings/mono/ecore_evas_mono/ecore_evas.cs b/src/bindings/mono/ecore_evas_mono/ecore_evas.cs
index 81609f4736..c7a27dde29 100644
--- a/src/bindings/mono/ecore_evas_mono/ecore_evas.cs
+++ b/src/bindings/mono/ecore_evas_mono/ecore_evas.cs
@@ -29,9 +29,9 @@ public class EcoreEvas
ecore_evas_show(handle);
}
- public efl.canvas.Object canvas
+ public efl.canvas.IObject canvas
{
- get { return new efl.canvas.ObjectConcrete(ecore_evas_get(handle)); }
+ get { return new efl.canvas.Object(ecore_evas_get(handle)); }
}
}
diff --git a/src/bindings/mono/eina_mono/eina_container_common.cs b/src/bindings/mono/eina_mono/eina_container_common.cs
index 173f54d905..d40ddd8a23 100644
--- a/src/bindings/mono/eina_mono/eina_container_common.cs
+++ b/src/bindings/mono/eina_mono/eina_container_common.cs
@@ -1,6 +1,7 @@
#pragma warning disable 1591
using System;
+using System.Linq;
using System.Runtime.InteropServices;
using System.Collections.Generic;
@@ -522,19 +523,41 @@ public static class TraitFunctions
private static IDictionary register = new Dictionary();
+ private static System.Type AsEflInstantiableType(System.Type type)
+ {
+ if (!IsEflObject(type))
+ return null;
+
+ if (type.IsInterface)
+ {
+ string[] names = type.FullName.Split('.');
+ names[names.Count() - 1] = names.Last().Substring(1); // Remove the leading 'I' (What about user-defined interfaces?)
+
+ string fullName = string.Join(".", names);
+ return type.Assembly.GetType(fullName); // That was our best guess...
+ }
+
+
+ System.Type current = type;
+ while (current != null)
+ {
+ if (current.Name.EndsWith("Inherit"))
+ throw new Exception("Inherit-based classes are not currently supported.");
+ current = current.BaseType;
+ }
+
+ return type; // Not inherited neither interface, so it should be a concrete.
+ }
+
public static object RegisterTypeTraits()
{
object traits;
var type = typeof(T);
if (IsEflObject(type))
{
- System.Type concrete = type;
- if (!type.Name.EndsWith("Concrete"))
- {
- var c = type.Assembly.GetType(type.FullName + "Concrete");
- if (c != null && type.IsAssignableFrom(c))
- concrete = c;
- }
+ System.Type concrete = AsEflInstantiableType(type);
+ if (concrete == null || !type.IsAssignableFrom(concrete))
+ throw new Exception("Failed to get a suitable concrete class for this type.");
traits = new EflObjectElementTraits(concrete);
}
else if (IsString(type))
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs
index 5ca1c2d90a..569ee58d08 100644
--- a/src/bindings/mono/eo_mono/iwrapper.cs
+++ b/src/bindings/mono/eo_mono/iwrapper.cs
@@ -95,7 +95,7 @@ public class Globals {
eina.Log.Debug("Registered?");
return klass;
}
- public static IntPtr instantiate_start(IntPtr klass, efl.Object parent)
+ public static IntPtr instantiate_start(IntPtr klass, efl.IObject parent)
{
eina.Log.Debug("Instantiating");
System.IntPtr parent_ptr = System.IntPtr.Zero;