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
This commit is contained in:
Lauro Moura 2018-11-29 21:04:37 -02:00 committed by Vitor Sousa
parent eec7bc458e
commit 3623753c1d
92 changed files with 3193 additions and 2794 deletions

View File

@ -49,9 +49,11 @@ lib_efl_mono_libefl_mono_dll_sources = \
$(efl_ecore_evas_mono_files) $(efl_ecore_evas_mono_files)
efl_mono_test_files = \ efl_mono_test_files = \
tests/efl_mono/test_testing.eo \ tests/efl_mono/dummy_test_object.eo \
tests/efl_mono/test_child.eo \ tests/efl_mono/dummy_test_iface.eo \
tests/efl_mono/test_numberwrapper.eo \ tests/efl_mono/dummy_another_iface.eo \
tests/efl_mono/dummy_child.eo \
tests/efl_mono/dummy_numberwrapper.eo \
tests/efl_mono/mono_test_driver.sh tests/efl_mono/mono_test_driver.sh
EXTRA_DIST2 += \ EXTRA_DIST2 += \
@ -384,12 +386,24 @@ tests_efl_mono_libefl_mono_native_test_la_LDFLAGS = -rpath $(abs_top_builddir)/t
tests_efl_mono_libefl_mono_native_test_la_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_ECORE_INTERNAL_LIBS@ @USE_ELDBUS_INTERNAL_LIBS@ tests_efl_mono_libefl_mono_native_test_la_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_ECORE_INTERNAL_LIBS@ @USE_ELDBUS_INTERNAL_LIBS@
tests_efl_mono_libefl_mono_native_test_la_LIBTOOLFLAGS = --tag=disable-static tests_efl_mono_libefl_mono_native_test_la_LIBTOOLFLAGS = --tag=disable-static
tests/efl_mono/libefl_mono_native_test.c: tests/efl_mono/test_testing.eo.h tests/efl_mono/test_testing.eo.c tests/efl_mono/test_child.eo.h tests/efl_mono/test_child.eo.c tests/efl_mono/test_numberwrapper.eo.h tests/efl_mono/test_numberwrapper.eo.c tests/efl_mono/libefl_mono_native_test.c: \
tests/efl_mono/dummy_test_object.eo.h \
tests/efl_mono/dummy_test_object.eo.c \
tests/efl_mono/dummy_test_iface.eo.h \
tests/efl_mono/dummy_test_iface.eo.c \
tests/efl_mono/dummy_another_iface.eo.h \
tests/efl_mono/dummy_another_iface.eo.c \
tests/efl_mono/dummy_child.eo.h \
tests/efl_mono/dummy_child.eo.c \
tests/efl_mono/dummy_numberwrapper.eo.h \
tests/efl_mono/dummy_numberwrapper.eo.c
# Intermediate C Sharp test DLL # Intermediate C Sharp test DLL
efl_mono_test_eolian_mono_files = tests/efl_mono/test_testing.eo.cs \ efl_mono_test_eolian_mono_files = tests/efl_mono/dummy_test_object.eo.cs \
tests/efl_mono/test_child.eo.cs \ tests/efl_mono/dummy_test_iface.eo.cs \
tests/efl_mono/test_numberwrapper.eo.cs tests/efl_mono/dummy_another_iface.eo.cs \
tests/efl_mono/dummy_child.eo.cs \
tests/efl_mono/dummy_numberwrapper.eo.cs
tests/efl_mono/libefl_mono_test.dll: $(efl_mono_test_eolian_mono_files) tests/efl_mono/$(am__dirstamp) lib/efl_mono/libefl_mono.dll tests/efl_mono/libefl_mono_native_test.la tests/efl_mono/libefl_mono_test.dll.config tests/efl_mono/libefl_mono_test.dll: $(efl_mono_test_eolian_mono_files) tests/efl_mono/$(am__dirstamp) lib/efl_mono/libefl_mono.dll tests/efl_mono/libefl_mono_native_test.la tests/efl_mono/libefl_mono_test.dll.config
@rm -f tests/efl_mono/libefl_mono_test.dll @rm -f tests/efl_mono/libefl_mono_test.dll
@ -461,7 +475,7 @@ tests/efl_mono/%.eo.cs: tests/efl_mono/%.eo $(_EOLIAN_MONO_DEP)
$(MKDIR_P) $(dir $@); \ $(MKDIR_P) $(dir $@); \
$(EOLIAN_MONO) $(EOLIAN_FLAGS) $(EOLIAN_MONO_FLAGS) --dllimport "@DLIB_PREFIX_MONO@efl_mono_native_test@DLIB_SUFFIX_MONO@" -o $@ $(ALL_EO_REFS) $< $(EOLIAN_MONO) $(EOLIAN_FLAGS) $(EOLIAN_MONO_FLAGS) --dllimport "@DLIB_PREFIX_MONO@efl_mono_native_test@DLIB_SUFFIX_MONO@" -o $@ $(ALL_EO_REFS) $<
CLEANFILES += tests/efl_mono/libefl_mono_test.dll tests/efl_mono/test_testing.eo.cs tests/efl_mono/test_child.eo.cs tests/efl_mono/test_numberwrapper.eo.cs tests/efl_mono/test_testing.eo.c tests/efl_mono/test_child.eo.c tests/efl_mono/test_numberwrapper.eo.c tests/efl_mono/test_testing.eo.h tests/efl_mono/test_child.eo.h tests/efl_mono/test_numberwrapper.eo.h tests/efl_mono/efl_mono.config CLEANFILES += tests/efl_mono/libefl_mono_test.dll tests/efl_mono/dummy_test_object.eo.cs tests/efl_mono/dummy_child.eo.cs tests/efl_mono/dummy_numberwrapper.eo.cs tests/efl_mono/dummy_test_object.eo.c tests/efl_mono/dummy_child.eo.c tests/efl_mono/dummy_numberwrapper.eo.c tests/efl_mono/dummy_test_object.eo.h tests/efl_mono/dummy_child.eo.h tests/efl_mono/dummy_numberwrapper.eo.h tests/efl_mono/efl_mono.config
endif endif

View File

@ -54,7 +54,7 @@ struct async_function_declaration_generator
return true; return true;
if (!as_generator( if (!as_generator(
scope_tab << "System.Threading.Tasks.Task<eina.Value> " << name_helpers::managed_async_method_name(f) << "(" << *(parameter << ",") << scope_tab << "System.Threading.Tasks.Task<Eina.Value> " << name_helpers::managed_async_method_name(f) << "(" << *(parameter << ",") <<
" System.Threading.CancellationToken token=default(System.Threading.CancellationToken));\n" " System.Threading.CancellationToken token=default(System.Threading.CancellationToken));\n"
).generate(sink, f.parameters, context)) ).generate(sink, f.parameters, context))
return false; return false;
@ -89,10 +89,10 @@ struct async_function_definition_generator
std::transform(f.parameters.begin(), f.parameters.end(), std::back_inserter(param_forwarding), parameter_forwarding); std::transform(f.parameters.begin(), f.parameters.end(), std::back_inserter(param_forwarding), parameter_forwarding);
if(!as_generator( if(!as_generator(
scope_tab << "public System.Threading.Tasks.Task<eina.Value> " << name_helpers::managed_async_method_name(f) << "(" << *(parameter << ",") << " System.Threading.CancellationToken token)\n" scope_tab << "public System.Threading.Tasks.Task<Eina.Value> " << name_helpers::managed_async_method_name(f) << "(" << *(parameter << ",") << " System.Threading.CancellationToken token=default(System.Threading.CancellationToken))\n"
<< scope_tab << "{\n" << scope_tab << "{\n"
<< scope_tab << scope_tab << "eina.Future future = " << name_helpers::managed_method_name(f) << "(" << (string % ",") << ");\n" << scope_tab << scope_tab << "Eina.Future future = " << name_helpers::managed_method_name(f) << "(" << (string % ",") << ");\n"
<< scope_tab << scope_tab << "return efl.eo.Globals.WrapAsync(future, token);\n" << scope_tab << scope_tab << "return Efl.Eo.Globals.WrapAsync(future, token);\n"
<< scope_tab << "}\n" << scope_tab << "}\n"
).generate(sink, std::make_tuple(f.parameters, param_forwarding), context)) ).generate(sink, std::make_tuple(f.parameters, param_forwarding), context))
return false; return false;

View File

@ -62,6 +62,8 @@ inline bool is_struct_blacklisted(std::string const& full_name)
|| full_name == "Eina.Slice" || full_name == "Eina.Slice"
|| full_name == "Eina.Rw_Slice" || full_name == "Eina.Rw_Slice"
|| full_name == "Eina.Promise" || full_name == "Eina.Promise"
|| full_name == "Eina.Value"
|| full_name == "Eina.Value_Type"
|| full_name == "Eina.Future"; || full_name == "Eina.Future";
} }

View File

@ -27,16 +27,15 @@ struct enum_definition_generator
( (
"public enum " << string << "\n{\n" "public enum " << string << "\n{\n"
) )
.generate(sink, name_helpers::enum_managed_name(enum_), context)) .generate(sink, name_helpers::typedecl_managed_name(enum_), context))
return false; return false;
// iterate enum fiels // iterate enum fiels
for(auto first = std::begin(enum_.fields) for(auto first = std::begin(enum_.fields)
, last = std::end(enum_.fields); first != last; ++first) , last = std::end(enum_.fields); first != last; ++first)
{ {
auto name = (*first).name; auto name = name_helpers::enum_field_managed_name((*first).name);
auto literal = (*first).value.literal; auto literal = (*first).value.literal;
name[0] = std::toupper(name[0]); // Hack to allow 'static' as a field name
if (!as_generator if (!as_generator
( (
documentation << string << " = " << string << ",\n" documentation << string << " = " << string << ",\n"

View File

@ -41,8 +41,8 @@ struct unpack_event_args_visitor
{"bool", [&arg] { return arg + " != IntPtr.Zero"; }} {"bool", [&arg] { return arg + " != IntPtr.Zero"; }}
, {"int", [&arg] { return arg + ".ToInt32()"; }} , {"int", [&arg] { return arg + ".ToInt32()"; }}
, {"uint", [&arg] { return "(uint)" + arg + ".ToInt32()";}} , {"uint", [&arg] { return "(uint)" + arg + ".ToInt32()";}}
, {"string", [&arg] { return "eina.StringConversion.NativeUtf8ToManagedString(" + arg + ")"; }} , {"string", [&arg] { return "Eina.StringConversion.NativeUtf8ToManagedString(" + arg + ")"; }}
, {"Eina.Error", [&arg] { return "(eina.Error)Marshal.PtrToStructure(" + arg + ", typeof(eina.Error))"; }} , {"Eina.Error", [&arg] { return "(Eina.Error)Marshal.PtrToStructure(" + arg + ", typeof(Eina.Error))"; }}
}; };
std::string full_type_name = name_helpers::type_full_eolian_name(regular); std::string full_type_name = name_helpers::type_full_eolian_name(regular);
@ -71,6 +71,9 @@ struct unpack_event_args_visitor
} }
}; };
/*
* Generates a struct wrapping the argument of a given event.
*/
struct event_argument_wrapper_generator struct event_argument_wrapper_generator
{ {
template<typename OutputIterator, typename Context> template<typename OutputIterator, typename Context>
@ -97,6 +100,11 @@ struct event_argument_wrapper_generator
} }
} const event_argument_wrapper {}; } const event_argument_wrapper {};
/*
* Generates an event declaration as a C# Interface member.
* In regular/abstract classes they are declared directly in their
* implementation in event_definition_generator.
*/
struct event_declaration_generator struct event_declaration_generator
{ {
template<typename OutputIterator, typename Context> template<typename OutputIterator, typename Context>
@ -104,11 +112,9 @@ struct event_declaration_generator
{ {
std::string wrapper_args_type; std::string wrapper_args_type;
std::string evt_name = name_helpers::managed_event_name(evt.name); std::string evt_name = name_helpers::managed_event_name(evt.name);
std::string evt_args_name = name_helpers::managed_event_args_name(evt);
efl::eina::optional<grammar::attributes::type_def> etype = evt.type; if (evt.type.is_engaged())
if (etype.is_engaged()) wrapper_args_type = "<" + name_helpers::managed_event_args_name(evt) + ">";
wrapper_args_type = "<" + evt_args_name + ">";
if (!as_generator( if (!as_generator(
documentation(1) documentation(1)
@ -122,34 +128,39 @@ struct event_declaration_generator
struct event_registration_generator struct event_registration_generator
{ {
attributes::klass_def const* klass; attributes::klass_def const& klass;
attributes::klass_def const& leaf_klass;
bool is_inherited_event;
template<typename OutputIterator, typename Context> template<typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::event_def const& evt, Context const& context) const bool generate(OutputIterator sink, attributes::event_def const& evt, Context const& context) const
{ {
std::string wrapper_event_name; std::string wrapper_event_name;
if (klass) if (is_inherited_event && !helpers::is_unique_event(evt, leaf_klass))
wrapper_event_name = name_helpers::translate_inherited_event_name(evt, *klass); wrapper_event_name = name_helpers::translate_inherited_event_name(evt, klass);
else else
wrapper_event_name = name_helpers::managed_event_name(evt.name); wrapper_event_name = name_helpers::managed_event_name(evt.name);
return as_generator(scope_tab << scope_tab << "evt_" << wrapper_event_name << "_delegate = " return as_generator(scope_tab << scope_tab << "evt_" << wrapper_event_name << "_delegate = "
<< "new efl.Event_Cb(on_" << wrapper_event_name << "_NativeCallback);\n" << "new Efl.EventCb(on_" << wrapper_event_name << "_NativeCallback);\n"
).generate(sink, attributes::unused, context); ).generate(sink, attributes::unused, context);
} }
}; };
struct event_registration_parameterized struct event_registration_parameterized
{ {
event_registration_generator operator()(attributes::klass_def const* klass=NULL) const event_registration_generator operator()(attributes::klass_def const& klass, attributes::klass_def const& leaf_klass) const
{ {
return {klass}; bool is_inherited_event = klass != leaf_klass;
return {klass, leaf_klass, is_inherited_event};
} }
} const event_registration; } const event_registration;
struct event_definition_generator struct event_definition_generator
{ {
attributes::klass_def const& klass; attributes::klass_def const& klass;
attributes::klass_def const& leaf_klass;
bool is_inherited_event; bool is_inherited_event;
template<typename OutputIterator, typename Context> template<typename OutputIterator, typename Context>
@ -157,8 +168,12 @@ struct event_definition_generator
{ {
std::string managed_evt_name = name_helpers::managed_event_name(evt.name); std::string managed_evt_name = name_helpers::managed_event_name(evt.name);
bool is_unique = helpers::is_unique_event(evt, leaf_klass);
bool use_explicit_impl = is_inherited_event && !is_unique;
// The name of the public event that goes in the public API.
std::string wrapper_evt_name; std::string wrapper_evt_name;
if (is_inherited_event) if (use_explicit_impl)
wrapper_evt_name = name_helpers::translate_inherited_event_name(evt, klass); wrapper_evt_name = name_helpers::translate_inherited_event_name(evt, klass);
else else
wrapper_evt_name = managed_evt_name; wrapper_evt_name = managed_evt_name;
@ -167,14 +182,11 @@ struct event_definition_generator
if (is_inherited_event) if (is_inherited_event)
klass_name = name_helpers::klass_full_interface_name(klass); klass_name = name_helpers::klass_full_interface_name(klass);
else else
klass_name = name_helpers::klass_interface_name(klass); klass_name = name_helpers::klass_concrete_name(klass);
std::string upper_c_name = utils::to_uppercase(evt.c_name);
std::string wrapper_args_type = "EventArgs"; std::string wrapper_args_type = "EventArgs";
std::string wrapper_args_template = ""; std::string wrapper_args_template = "";
std::string event_args = "EventArgs args = EventArgs.Empty;\n"; std::string event_args = "EventArgs args = EventArgs.Empty;\n";
std::string visibility = is_inherit_context(context) ? "protected" : "private";
efl::eina::optional<grammar::attributes::type_def> etype = evt.type; efl::eina::optional<grammar::attributes::type_def> etype = evt.type;
@ -196,68 +208,125 @@ struct event_definition_generator
event_args = arg_initializer; event_args = arg_initializer;
} }
// Wrapper event declaration if(!as_generator("private static object " << wrapper_evt_name << "Key = new object();\n")
.generate(sink, attributes::unused, context))
return false;
if(!as_generator(documentation(1)).generate(sink, evt, context)) if(!as_generator(documentation(1)).generate(sink, evt, context))
return false; return false;
// Visible event declaration. Either a regular class member or an explicit interface implementation.
if (klass.type == attributes::class_type::interface_ || klass.type == attributes::class_type::mixin)
{
// Public event implementation.
if (!as_generator( if (!as_generator(
scope_tab << visibility << " event EventHandler" << wrapper_args_template << " " << wrapper_evt_name << ";\n" scope_tab << (!use_explicit_impl ? "public " : " ") << "event EventHandler" << wrapper_args_template << " " << (use_explicit_impl ? (klass_name + ".") : "") << managed_evt_name << "\n"
<< scope_tab << "///<summary>Method to raise event "<< wrapper_evt_name << ".</summary>\n" ).generate(sink, attributes::unused, context))
<< scope_tab << visibility << " void On_" << wrapper_evt_name << "(" << wrapper_args_type << " e)\n" return false;
<< scope_tab << "{\n" }
<< scope_tab << scope_tab << "EventHandler" << wrapper_args_template << " evt;\n" else // For inheritable classes event handling.
<< scope_tab << scope_tab << "lock (eventLock) {\n" {
<< scope_tab << scope_tab << scope_tab << "evt = " << wrapper_evt_name << ";\n" // We may have inherited an event with the same name as this concrete event, thus
<< scope_tab << scope_tab << "}\n" // the concrete event would "hide" the interface one, requiring the new keyword.
<< scope_tab << scope_tab << "if (evt != null) { evt(this, e); }\n" std::string visibility = "public ";
<< scope_tab << "}\n" if (!is_unique)
<< scope_tab << "private void on_" << wrapper_evt_name << "_NativeCallback(System.IntPtr data, ref efl.Event_StructInternal evt)\n" visibility += "new ";
if (!as_generator(
scope_tab << visibility << "event EventHandler" << wrapper_args_template << " " << wrapper_evt_name << "\n"
).generate(sink, attributes::unused, context))
return false;
}
if (!generate_event_add_remove(sink, evt, wrapper_evt_name, context))
return false;
if (!generate_event_trigger(sink, wrapper_evt_name, wrapper_args_type, wrapper_args_template, context))
return false;
// Store the delegate for this event in this instance. This is initialized in register_event_proxies()
// We can't initialize them directly here as they depend on the member methods being valid (i.e.
// the constructor being called).
if (!as_generator(scope_tab << "Efl.EventCb evt_" << wrapper_evt_name << "_delegate;\n").generate(sink, attributes::unused, context))
return false;
// Callback to be given to C's callback_priority_add
if (!as_generator(
scope_tab << "private void on_" << wrapper_evt_name << "_NativeCallback(System.IntPtr data, ref Efl.Event_StructInternal evt)\n"
<< scope_tab << "{\n" << scope_tab << "{\n"
<< scope_tab << scope_tab << event_args << scope_tab << scope_tab << event_args
<< scope_tab << scope_tab << "try {\n" << scope_tab << scope_tab << "try {\n"
<< scope_tab << scope_tab << scope_tab << "On_" << wrapper_evt_name << "(args);\n" << scope_tab << scope_tab << scope_tab << "On_" << wrapper_evt_name << "(args);\n"
<< scope_tab << scope_tab << "} catch (Exception e) {\n" << scope_tab << scope_tab << "} catch (Exception e) {\n"
<< scope_tab << scope_tab << scope_tab << "eina.Log.Error(e.ToString());\n" << scope_tab << scope_tab << scope_tab << "Eina.Log.Error(e.ToString());\n"
<< scope_tab << scope_tab << scope_tab << "eina.Error.Set(eina.Error.EFL_ERROR);\n" << scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.EFL_ERROR);\n"
<< scope_tab << scope_tab << "}\n" << scope_tab << scope_tab << "}\n"
<< scope_tab << "}\n" << scope_tab << "}\n\n"
<< scope_tab << "efl.Event_Cb evt_" << wrapper_evt_name << "_delegate;\n" ).generate(sink, attributes::unused, context))
<< scope_tab << "event EventHandler" << wrapper_args_template << " " << klass_name << "." << managed_evt_name << "{\n")
.generate(sink, NULL, context))
return false; return false;
return true;
}
template<typename OutputIterator, typename Context>
bool generate_event_trigger(OutputIterator sink
, std::string const& event_name
, std::string const& event_args_type
, std::string const& event_template_args
, Context context) const
{
auto delegate_type = "EventHandler" + event_template_args;
if (!as_generator( if (!as_generator(
scope_tab << scope_tab << "add {\n" scope_tab << "///<summary>Method to raise event "<< event_name << ".</summary>\n"
<< scope_tab << "public void On_" << event_name << "(" << event_args_type << " e)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << delegate_type << " evt;\n"
<< scope_tab << scope_tab << "lock (eventLock) {\n"
<< scope_tab << scope_tab << "evt = (" << delegate_type << ")eventHandlers[" << event_name << "Key];\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << "evt?.Invoke(this, e);\n"
<< scope_tab << "}\n"
).generate(sink, nullptr, context))
return false;
return true;
}
template<typename OutputIterator, typename Context>
bool generate_event_add_remove(OutputIterator sink, attributes::event_def const &evt, const std::string& event_name, Context context) const
{
std::string upper_c_name = utils::to_uppercase(evt.c_name);
return as_generator(
scope_tab << "{\n"
<< scope_tab << scope_tab << "add {\n"
<< scope_tab << scope_tab << scope_tab << "lock (eventLock) {\n" << scope_tab << scope_tab << scope_tab << "lock (eventLock) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "string key = \"_" << upper_c_name << "\";\n" << scope_tab << scope_tab << scope_tab << scope_tab << "string key = \"_" << upper_c_name << "\";\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "if (add_cpp_event_handler(key, this.evt_" << wrapper_evt_name << "_delegate))\n" << scope_tab << scope_tab << scope_tab << scope_tab << "if (add_cpp_event_handler(key, this.evt_" << event_name << "_delegate)) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << wrapper_evt_name << " += value;\n" << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eventHandlers.AddHandler(" << event_name << "Key , value);\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "else\n" << scope_tab << scope_tab << scope_tab << scope_tab << "} else\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Error adding proxy for event {key}\");\n" << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Error adding proxy for event {key}\");\n"
<< scope_tab << scope_tab << scope_tab << "}\n" // End of lock block << scope_tab << scope_tab << scope_tab << "}\n" // End of lock block
<< scope_tab << scope_tab << "}\n" << scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << "remove {\n" << scope_tab << scope_tab << "remove {\n"
<< scope_tab << scope_tab << scope_tab << "lock (eventLock) {\n" << scope_tab << scope_tab << scope_tab << "lock (eventLock) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "string key = \"_" << upper_c_name << "\";\n" << scope_tab << scope_tab << scope_tab << scope_tab << "string key = \"_" << upper_c_name << "\";\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "if (remove_cpp_event_handler(key, this.evt_" << wrapper_evt_name << "_delegate))\n" << scope_tab << scope_tab << scope_tab << scope_tab << "if (remove_cpp_event_handler(key, this.evt_" << event_name << "_delegate)) { \n"
<< scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << wrapper_evt_name << " -= value;\n" << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eventHandlers.RemoveHandler(" << event_name << "Key , value);\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "else\n" << scope_tab << scope_tab << scope_tab << scope_tab << "} else\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Error removing proxy for event {key}\");\n" << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Error removing proxy for event {key}\");\n"
<< scope_tab << scope_tab << scope_tab << "}\n" // End of lock block << scope_tab << scope_tab << scope_tab << "}\n" // End of lock block
<< scope_tab << scope_tab << "}\n" << scope_tab << scope_tab << "}\n"
<< scope_tab << "}\n") << scope_tab << "}\n"
.generate(sink, NULL, context)) ).generate(sink, attributes::unused, context);
return false;
return true;
} }
}; };
struct event_definition_parameterized struct event_definition_parameterized
{ {
event_definition_generator operator()(attributes::klass_def const& klass, bool is_inherited_event=false) const event_definition_generator operator()(attributes::klass_def const& klass, attributes::klass_def const& leaf_klass) const
{ {
return {klass, is_inherited_event}; bool is_inherited_event = klass != leaf_klass;
return {klass, leaf_klass, is_inherited_event};
} }
} const event_definition; } const event_definition;

View File

@ -83,22 +83,22 @@ struct native_function_definition_generator
<< ")\n" << ")\n"
<< scope_tab << "{\n" << scope_tab << "{\n"
/****/ /****/
<< scope_tab << scope_tab << "eina.Log.Debug(\"function " << string << " was called\");\n" << scope_tab << scope_tab << "Eina.Log.Debug(\"function " << string << " was called\");\n"
/****/ /****/
<< scope_tab << scope_tab << "efl.eo.IWrapper wrapper = efl.eo.Globals.data_get(pd);\n" << scope_tab << scope_tab << "Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);\n"
<< scope_tab << scope_tab << "if(wrapper != null) {\n" << scope_tab << scope_tab << "if(wrapper != null) {\n"
<< scope_tab << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble() << scope_tab << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble()
<< scope_tab << scope_tab << scope_tab << "try {\n" << scope_tab << scope_tab << scope_tab << "try {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "") << "((" << klass_inherit_name << ")wrapper)." << string << scope_tab << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "") << "((" << klass_inherit_name << ")wrapper)." << string
<< "(" << (native_argument_invocation % ", ") << ");\n" << "(" << (native_argument_invocation % ", ") << ");\n"
<< scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n" << scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Warning($\"Callback error: {e.ToString()}\");\n" << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "eina.Error.Set(eina.Error.EFL_ERROR);\n" << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.EFL_ERROR);\n"
<< scope_tab << scope_tab << scope_tab << "}\n" << scope_tab << scope_tab << scope_tab << "}\n"
<< eolian_mono::native_function_definition_epilogue(*klass) << eolian_mono::native_function_definition_epilogue(*klass)
<< scope_tab << scope_tab << "} else {\n" << scope_tab << scope_tab << "} else {\n"
<< scope_tab << scope_tab << scope_tab << (return_type != " void" ? "return " : "") << string << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "return " : "") << string
<< "(efl.eo.Globals.efl_super(obj, " << klass_inherit_name << ".klass)" << *(", " << argument) << ");\n" << "(Efl.Eo.Globals.efl_super(obj, " << klass_inherit_name << ".klass)" << *(", " << argument) << ");\n"
<< scope_tab << scope_tab << "}\n" << scope_tab << scope_tab << "}\n"
<< scope_tab << "}\n" << scope_tab << "}\n"
) )
@ -137,7 +137,7 @@ struct function_definition_generator
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
{ {
EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "function_definition_generator: " << f.c_name << std::endl; EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "function_definition_generator: " << f.c_name << std::endl;
if(do_super && f.is_static) // Static methods goes only on Concrete classes. if(!do_super && f.is_static) // Static methods goes only on Concrete classes.
return true; return true;
if(blacklist::is_function_blacklisted(f.c_name)) if(blacklist::is_function_blacklisted(f.c_name))
return true; return true;
@ -145,7 +145,7 @@ struct function_definition_generator
if(!as_generator if(!as_generator
("\n\n" << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(context).actual_library_name(f.filename) << ")]\n" ("\n\n" << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(context).actual_library_name(f.filename) << ")]\n"
<< scope_tab << eolian_mono::marshall_annotation(true) << scope_tab << eolian_mono::marshall_annotation(true)
<< " private static extern " << (do_super ? " protected " : " private ") << "static extern "
<< eolian_mono::marshall_type(true) << eolian_mono::marshall_type(true)
<< " " << string << " " << string
<< "(System.IntPtr obj" << "(System.IntPtr obj"
@ -165,13 +165,19 @@ struct function_definition_generator
(documentation(1)).generate(sink, f, context)) (documentation(1)).generate(sink, f, context))
return false; return false;
std::string self = "this.NativeHandle";
// inherited is set in the constructor, true if this instance is from a pure C# class (not generated).
if (do_super && !f.is_static)
self = "(inherited ? Efl.Eo.Globals.efl_super(" + self + ", this.NativeClass) : " + self + ")";
else
self = name_helpers::klass_get_full_name(f.klass) + "()";
if(!as_generator if(!as_generator
(scope_tab << (do_super ? "virtual " : "") << "public " << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ") (scope_tab << ((do_super && !f.is_static) ? "virtual " : "") << "public " << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ")
<< ") {\n " << ") {\n "
<< eolian_mono::function_definition_preamble() << string << "(" << eolian_mono::function_definition_preamble() << string << "("
<< (do_super ? "efl.eo.Globals.efl_super(" : "") << self
<< (f.is_static ? name_helpers::klass_get_full_name(f.klass) + "()": "this.raw_handle")
<< (do_super ? ", this.raw_klass)" : "")
<< *(", " << argument_invocation ) << ");\n" << *(", " << argument_invocation ) << ");\n"
<< eolian_mono::function_definition_epilogue() << eolian_mono::function_definition_epilogue()
<< " }\n") << " }\n")

View File

@ -34,14 +34,10 @@ struct native_function_definition_preamble_generator
return false; return false;
if (!as_generator( if (!as_generator(
scope_tab << scope_tab << "//Placeholder in variables\n" *(scope_tab << scope_tab << native_convert_in_variable)
<< *(scope_tab << scope_tab << native_convert_in_variable << "\n") << *(scope_tab << scope_tab << native_convert_out_variable)
<< scope_tab << scope_tab << "//Placeholder out variables\n" << *(scope_tab << scope_tab << native_convert_function_pointer)
<< *(scope_tab << scope_tab << native_convert_out_variable << "\n") << scope_tab << scope_tab << scope_tab << native_convert_return_variable
<< scope_tab << scope_tab << "//Function pointer wrappers\n"
<< *(scope_tab << scope_tab << native_convert_function_pointer << "\n")
<< scope_tab << scope_tab << "//Return variable and function call\n"
<< scope_tab << scope_tab << scope_tab << native_convert_return_variable << "\n"
).generate(sink, std::make_tuple(f.parameters, f.parameters, f.parameters, f.return_type), context)) ).generate(sink, std::make_tuple(f.parameters, f.parameters, f.parameters, f.return_type), context))
return false; return false;
@ -61,13 +57,9 @@ struct function_definition_preamble_generator
return false; return false;
if (!as_generator( if (!as_generator(
scope_tab << scope_tab << "//Placeholder in variables\n" *(scope_tab << scope_tab << convert_in_variable)
<< *(scope_tab << scope_tab << convert_in_variable << "\n") << *(scope_tab << scope_tab << convert_out_variable)
<< scope_tab << scope_tab << "//Placeholder out variables\n" << *(scope_tab << scope_tab << convert_function_pointer)
<< *(scope_tab << scope_tab << convert_out_variable << "\n")
<< scope_tab << scope_tab << "//Function pointers handling\n"
<< *(scope_tab << scope_tab << convert_function_pointer << "\n")
<< scope_tab << scope_tab << "//Return variable and function call\n"
<< scope_tab << scope_tab << convert_return_variable << scope_tab << scope_tab << convert_return_variable
).generate(sink, std::make_tuple(f.parameters, f.parameters, f.parameters, f.return_type), context)) ).generate(sink, std::make_tuple(f.parameters, f.parameters, f.parameters, f.return_type), context))
return false; return false;
@ -90,11 +82,8 @@ struct native_function_definition_epilogue_generator
return false; return false;
if (!as_generator( if (!as_generator(
scope_tab << scope_tab << "//Assigning out variables\n" *(scope_tab << scope_tab << native_convert_out_assign(*klass))
<< *(scope_tab << scope_tab << native_convert_out_assign(*klass) << "\n") << *(scope_tab << scope_tab << native_convert_in_ptr_assign)
<< scope_tab << scope_tab << "//Placeholder in ptr variables that need to be updated\n"
<< *(scope_tab << scope_tab << native_convert_in_ptr_assign << "\n")
<< scope_tab << scope_tab << "//Converting return variable\n"
<< scope_tab << scope_tab << native_convert_return(*klass) << scope_tab << scope_tab << native_convert_return(*klass)
).generate(sink, std::make_tuple(f.parameters, f.parameters, f.return_type), context)) ).generate(sink, std::make_tuple(f.parameters, f.parameters, f.return_type), context))
return false; return false;
@ -110,12 +99,9 @@ struct function_definition_epilogue_generator
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
{ {
if (!as_generator( if (!as_generator(
scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n" scope_tab << scope_tab << "Eina.Error.RaiseIfOccurred();\n"
<< scope_tab << scope_tab << "//Assigning out variables\n" << *(scope_tab << scope_tab << convert_out_assign)
<< *(scope_tab << scope_tab << convert_out_assign << "\n") << *(scope_tab << scope_tab << convert_in_ptr_assign)
<< scope_tab << scope_tab << "//Placeholder in ptr variables that need to be updated\n"
<< *(scope_tab << scope_tab << convert_in_ptr_assign << "\n")
<< scope_tab << scope_tab << "//Converting return variable\n"
<< scope_tab << scope_tab << convert_return << scope_tab << scope_tab << convert_return
).generate(sink, std::make_tuple(f.parameters, f.parameters, f.return_type), context)) ).generate(sink, std::make_tuple(f.parameters, f.parameters, f.return_type), context))
return false; return false;

View File

@ -38,28 +38,29 @@ struct function_pointer {
if (!name_helpers::open_namespaces(sink, f.namespaces, funcptr_ctx)) if (!name_helpers::open_namespaces(sink, f.namespaces, funcptr_ctx))
return false; return false;
std::string f_name = name_helpers::typedecl_managed_name(f);
// C# visible delegate // C# visible delegate
if (!as_generator(documentation if (!as_generator(documentation
<< "public delegate " << type << " " << string << "public delegate " << type << " " << string
<< "(" << (parameter % ", ") << ");\n") << "(" << (parameter % ", ") << ");\n")
.generate(sink, std::make_tuple(f, f.return_type, name_helpers::escape_keyword(f.name), f.parameters), funcptr_ctx)) .generate(sink, std::make_tuple(f, f.return_type, f_name, f.parameters), funcptr_ctx))
return false; return false;
// "Internal" delegate, 1-to-1 with the Unamaged function type // "Internal" delegate, 1-to-1 with the Unamaged function type
if (!as_generator(marshall_native_annotation(true) if (!as_generator(marshall_native_annotation(true)
<< "internal delegate " << marshall_type(true) << " " << string // public? << "public delegate " << marshall_type(true) << " " << string // public?
<< "Internal(IntPtr data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_native_annotation << " " << marshall_parameter)) << ");\n") << "Internal(IntPtr data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_native_annotation << " " << marshall_parameter)) << ");\n")
.generate(sink, std::make_tuple(f.return_type, f.return_type, name_helpers::escape_keyword(f.name), f.parameters), funcptr_ctx)) .generate(sink, std::make_tuple(f.return_type, f.return_type, f_name, f.parameters), funcptr_ctx))
return false; return false;
std::string f_name = name_helpers::escape_keyword(f.name);
// Wrapper type, with callback matching the Unamanaged one // Wrapper type, with callback matching the Unamanaged one
if (!as_generator("internal class " << f_name << "Wrapper\n" if (!as_generator("internal class " << f_name << "Wrapper\n"
<< "{\n\n" << "{\n\n"
<< scope_tab << "private " << f_name << "Internal _cb;\n" << scope_tab << "private " << f_name << "Internal _cb;\n"
<< scope_tab << "private IntPtr _cb_data;\n" << scope_tab << "private IntPtr _cb_data;\n"
<< scope_tab << "private Eina_Free_Cb _cb_free_cb;\n\n" << scope_tab << "private EinaFreeCb _cb_free_cb;\n\n"
<< scope_tab << "internal " << f_name << "Wrapper (" << f_name << "Internal _cb, IntPtr _cb_data, Eina_Free_Cb _cb_free_cb)\n" << scope_tab << "internal " << f_name << "Wrapper (" << f_name << "Internal _cb, IntPtr _cb_data, EinaFreeCb _cb_free_cb)\n"
<< scope_tab << "{\n" << scope_tab << "{\n"
<< scope_tab << scope_tab << "this._cb = _cb;\n" << scope_tab << scope_tab << "this._cb = _cb;\n"
<< scope_tab << scope_tab << "this._cb_data = _cb_data;\n" << scope_tab << scope_tab << "this._cb_data = _cb_data;\n"
@ -88,8 +89,8 @@ struct function_pointer {
<< scope_tab << scope_tab << "try {\n" << scope_tab << scope_tab << "try {\n"
<< scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "") << "cb(" << (native_argument_invocation % ", ") << ");\n" << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "") << "cb(" << (native_argument_invocation % ", ") << ");\n"
<< scope_tab << scope_tab << "} catch (Exception e) {\n" << scope_tab << scope_tab << "} catch (Exception e) {\n"
<< scope_tab << scope_tab << scope_tab << "eina.Log.Warning($\"Callback error: {e.ToString()}\");\n" << scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n"
<< scope_tab << scope_tab << scope_tab << "eina.Error.Set(eina.Error.EFL_ERROR);\n" << scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.EFL_ERROR);\n"
<< scope_tab << scope_tab << "}\n" << scope_tab << scope_tab << "}\n"
<< native_function_definition_epilogue(nullptr) << native_function_definition_epilogue(nullptr)
<< scope_tab << "}\n" << scope_tab << "}\n"

View File

@ -40,7 +40,7 @@ struct function_registration_generator
#ifdef _WIN32 #ifdef _WIN32
(scope_tab << scope_tab << "descs[" << index << "].api_func = Marshal.StringToHGlobalAnsi(\"" << string << "\");\n" (scope_tab << scope_tab << "descs[" << index << "].api_func = Marshal.StringToHGlobalAnsi(\"" << string << "\");\n"
#else #else
(scope_tab << scope_tab << "descs[" << index << "].api_func = efl.eo.Globals.dlsym(efl.eo.Globals.RTLD_DEFAULT, \"" << string << "\");\n" (scope_tab << scope_tab << "descs[" << index << "].api_func = Efl.Eo.Globals.dlsym(Efl.Eo.Globals.RTLD_DEFAULT, \"" << string << "\");\n"
#endif #endif
<< scope_tab << scope_tab << "descs[" << index << "].func = Marshal.GetFunctionPointerForDelegate(" << name_helpers::klass_native_inherit_name(*klass) << "." << string << "_static_delegate);\n" << scope_tab << scope_tab << "descs[" << index << "].func = Marshal.GetFunctionPointerForDelegate(" << name_helpers::klass_native_inherit_name(*klass) << "." << string << "_static_delegate);\n"
) )

View File

@ -65,6 +65,163 @@ inline bool need_pointer_conversion(attributes::regular_type_def const* regular)
return false; return false;
} }
// While klass_def has immediate_inherits, we need a way to get all interfaces inherited by an interface
// either directly or through another interface.
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> interface_inherits(attributes::klass_def const& cls)
{
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> inherits;
std::function<void(attributes::klass_name const&)> inherit_algo =
[&] (attributes::klass_name const& klass)
{
// TODO we could somehow cache klass_def instantiations
attributes::klass_def c(get_klass(klass, cls.unit), cls.unit);
for(auto&& inherit : c.immediate_inherits)
{
switch(inherit.type)
{
case attributes::class_type::mixin:
case attributes::class_type::interface_:
inherits.insert(inherit);
inherit_algo(inherit);
break;
case attributes::class_type::regular:
case attributes::class_type::abstract_:
inherit_algo(inherit);
default:
break;
}
}
};
inherit_algo(get_klass_name(cls));
return inherits;
}
// Returns the set of interfaces implemented by this type that haven't been implemented
// by a regular parent class.
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> non_implemented_interfaces(attributes::klass_def const& cls)
{
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> implemented_interfaces;
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> interfaces;
std::function<void(attributes::klass_name const&, bool)> inherit_algo =
[&] (attributes::klass_name const& klass, bool is_implemented)
{
// TODO we could somehow cache klass_def instantiations
attributes::klass_def c(get_klass(klass, cls.unit), cls.unit);
for(auto&& inherit : c.immediate_inherits)
{
switch(inherit.type)
{
case attributes::class_type::mixin:
case attributes::class_type::interface_:
interfaces.insert(inherit);
if (is_implemented)
implemented_interfaces.insert(inherit);
inherit_algo(inherit, is_implemented);
break;
case attributes::class_type::abstract_:
case attributes::class_type::regular:
inherit_algo(inherit, true);
default:
break;
}
}
};
inherit_algo(get_klass_name(cls), false);
for (auto&& inherit : implemented_interfaces)
interfaces.erase(inherit);
return interfaces;
}
/*
* Determines whether this class has any regular ancestor or not
*/
bool has_regular_ancestor(attributes::klass_def const& cls)
{
auto inherits = cls.inherits;
std::function<bool(attributes::klass_name const&)> is_regular =
[&] (attributes::klass_name const& klass)
{
return klass.type == attributes::class_type::regular || klass.type == attributes::class_type::abstract_;
};
return std::any_of(inherits.begin(), inherits.end(), is_regular);
}
/*
* Gets all methods that this class should implement (i.e. that come from an unimplemented interface/mixin and the class itself)
*/
std::vector<attributes::function_def> get_all_implementable_methods(attributes::klass_def const& cls)
{
std::vector<attributes::function_def> ret;
std::copy(cls.functions.begin(), cls.functions.end(), std::back_inserter(ret));
// Non implemented interfaces
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> implemented_interfaces;
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> interfaces;
std::function<void(attributes::klass_name const&, bool)> inherit_algo =
[&] (attributes::klass_name const &klass, bool is_implemented)
{
attributes::klass_def c(get_klass(klass, cls.unit), cls.unit);
for (auto&& inherit: c.immediate_inherits)
{
switch(inherit.type)
{
case attributes::class_type::mixin:
case attributes::class_type::interface_:
interfaces.insert(inherit);
if (is_implemented)
implemented_interfaces.insert(inherit);
inherit_algo(inherit, is_implemented);
break;
case attributes::class_type::abstract_:
case attributes::class_type::regular:
inherit_algo(inherit, true);
default:
break;
}
}
};
inherit_algo(attributes::get_klass_name(cls), false);
for (auto&& inherit : implemented_interfaces)
interfaces.erase(inherit);
for (auto&& inherit : interfaces)
{
attributes::klass_def klass(get_klass(inherit, cls.unit), cls.unit);
std::copy(klass.functions.cbegin(), klass.functions.cend(), std::back_inserter(ret));
}
return ret;
}
/*
* Checks whether the given is unique going up the inheritance tree from leaf_klass
*/
inline bool is_unique_event(attributes::event_def const& evt
, attributes::klass_def const& leaf_klass)
{
auto events = leaf_klass.get_all_events();
int i = 1;
return !std::any_of(events.cbegin(), events.cend(),
[&evt, &i](const attributes::event_def &other) {
return evt.name == other.name && i++ == 2;
});
}
} // namespace helpers } // namespace helpers
} // namespace eolian_mono } // namespace eolian_mono

View File

@ -4,6 +4,7 @@
#include "grammar/integral.hpp" #include "grammar/integral.hpp"
#include "grammar/generator.hpp" #include "grammar/generator.hpp"
#include "grammar/klass_def.hpp" #include "grammar/klass_def.hpp"
#include "grammar/attribute_conditional.hpp"
#include "blacklist.hh" #include "blacklist.hh"
#include "grammar/indentation.hpp" #include "grammar/indentation.hpp"
@ -35,11 +36,11 @@ static bool generate_static_cast_method(OutputIterator sink, grammar::attributes
{ {
return as_generator( return as_generator(
scope_tab << "///<summary>Casts obj into an instance of this type.</summary>\n" scope_tab << "///<summary>Casts obj into an instance of this type.</summary>\n"
<< scope_tab << "public static " << name_helpers::klass_interface_name(cls) << " static_cast(efl.IObject obj)\n" << scope_tab << "public " << (helpers::has_regular_ancestor(cls) ? "new " : "") <<"static " << name_helpers::klass_concrete_name(cls) << " static_cast(Efl.Object obj)\n"
<< scope_tab << "{\n" << scope_tab << "{\n"
<< scope_tab << scope_tab << "if (obj == null)\n" << scope_tab << scope_tab << "if (obj == null)\n"
<< scope_tab << scope_tab << scope_tab << "throw new System.ArgumentNullException(\"obj\");\n" << scope_tab << scope_tab << scope_tab << "throw new System.ArgumentNullException(\"obj\");\n"
<< scope_tab << scope_tab << "return new " << name_helpers::klass_concrete_name(cls) << "(obj.raw_handle);\n" << scope_tab << scope_tab << "return new " << name_helpers::klass_concrete_name(cls) << "(obj.NativeHandle);\n"
<< scope_tab << "}\n" << scope_tab << "}\n"
).generate(sink, nullptr, context); ).generate(sink, nullptr, context);
} }
@ -51,29 +52,29 @@ static bool generate_equals_method(OutputIterator sink, Context const &context)
scope_tab << "///<summary>Verifies if the given object is equal to this one.</summary>\n" scope_tab << "///<summary>Verifies if the given object is equal to this one.</summary>\n"
<< scope_tab << "public override bool Equals(object obj)\n" << scope_tab << "public override bool Equals(object obj)\n"
<< scope_tab << "{\n" << scope_tab << "{\n"
<< scope_tab << scope_tab << "var other = obj as efl.IObject;\n" << scope_tab << scope_tab << "var other = obj as Efl.Object;\n"
<< scope_tab << scope_tab << "if (other == null)\n" << scope_tab << scope_tab << "if (other == null)\n"
<< scope_tab << scope_tab << scope_tab << "return false;\n" << scope_tab << scope_tab << scope_tab << "return false;\n"
<< scope_tab << scope_tab << "return this.raw_handle == other.raw_handle;\n" << scope_tab << scope_tab << "return this.NativeHandle == other.NativeHandle;\n"
<< scope_tab << "}\n" << scope_tab << "}\n"
<< scope_tab << "///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>\n" << scope_tab << "///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>\n"
<< scope_tab << "public override int GetHashCode()\n" << scope_tab << "public override int GetHashCode()\n"
<< scope_tab << "{\n" << scope_tab << "{\n"
<< scope_tab << scope_tab << "return this.raw_handle.ToInt32();\n" << scope_tab << scope_tab << "return this.NativeHandle.ToInt32();\n"
<< scope_tab << "}\n" << scope_tab << "}\n"
<< scope_tab << "///<summary>Turns the native pointer into a string representation.</summary>\n" << scope_tab << "///<summary>Turns the native pointer into a string representation.</summary>\n"
<< scope_tab << "public override String ToString()\n" << scope_tab << "public override String ToString()\n"
<< scope_tab << "{\n" << scope_tab << "{\n"
<< scope_tab << scope_tab << "return $\"{this.GetType().Name}@[{this.raw_handle.ToInt32():x}]\";\n" << scope_tab << scope_tab << "return $\"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]\";\n"
<< scope_tab << "}\n" << scope_tab << "}\n"
).generate(sink, nullptr, context); ).generate(sink, nullptr, context);
} }
/* Get the actual number of functions of a class, checking for blacklisted ones */ /* Get the actual number of functions of a class, checking for blacklisted ones */
static std::size_t static std::size_t
get_inheritable_function_count(grammar::attributes::klass_def const& cls) get_implementable_function_count(grammar::attributes::klass_def const& cls)
{ {
auto methods = cls.get_all_methods(); auto methods = helpers::get_all_implementable_methods(cls);
return std::count_if(methods.cbegin(), methods.cend(), [](grammar::attributes::function_def const& func) return std::count_if(methods.cbegin(), methods.cend(), [](grammar::attributes::function_def const& func)
{ {
return !blacklist::is_function_blacklisted(func.c_name) && !func.is_static; return !blacklist::is_function_blacklisted(func.c_name) && !func.is_static;
@ -97,6 +98,9 @@ struct klass
switch(cls.type) switch(cls.type)
{ {
case attributes::class_type::regular: case attributes::class_type::regular:
class_type = "class";
suffix = "CLASS";
break;
case attributes::class_type::abstract_: case attributes::class_type::abstract_:
class_type = "class"; class_type = "class";
suffix = "CLASS"; suffix = "CLASS";
@ -117,6 +121,7 @@ struct klass
auto methods = cls.get_all_methods(); auto methods = cls.get_all_methods();
// Interface class // Interface class
if(class_type == "interface")
{ {
auto iface_cxt = context_add_tag(class_context{class_context::interface}, context); auto iface_cxt = context_add_tag(class_context{class_context::interface}, context);
@ -132,11 +137,12 @@ struct klass
for(auto first = std::begin(cls.immediate_inherits) for(auto first = std::begin(cls.immediate_inherits)
, last = std::end(cls.immediate_inherits); first != last; ++first) , last = std::end(cls.immediate_inherits); first != last; ++first)
{ {
if(first->type != attributes::class_type::regular && first->type != attributes::class_type::abstract_)
if(!as_generator("\n" << scope_tab << string << " ,").generate(sink, name_helpers::klass_full_interface_name(*first), iface_cxt)) if(!as_generator("\n" << scope_tab << string << " ,").generate(sink, name_helpers::klass_full_interface_name(*first), iface_cxt))
return false; return false;
} }
if(!as_generator("\n" << scope_tab << "efl.eo.IWrapper, IDisposable").generate(sink, attributes::unused, iface_cxt)) if(!as_generator("\n" << scope_tab << "Efl.Eo.IWrapper, IDisposable").generate(sink, attributes::unused, iface_cxt))
return false; return false;
if(!as_generator("\n{\n").generate(sink, attributes::unused, iface_cxt)) if(!as_generator("\n{\n").generate(sink, attributes::unused, iface_cxt))
@ -154,85 +160,74 @@ struct klass
for (auto &&p : cls.parts) for (auto &&p : cls.parts)
if (!as_generator( if (!as_generator(
documentation(1) documentation(1)
<< name_helpers::klass_full_interface_name(p.klass) << " " << utils::capitalize(p.name) << "{ get;}\n" << name_helpers::klass_full_concrete_or_interface_name(p.klass) << " " << utils::capitalize(p.name) << "{ get;}\n"
).generate(sink, p, iface_cxt)) ).generate(sink, p, iface_cxt))
return false; return false;
// End of interface declaration // End of interface declaration
if(!as_generator("}\n").generate(sink, attributes::unused, iface_cxt)) return false; if(!as_generator("}\n").generate(sink, attributes::unused, iface_cxt)) return false;
} }
// Concrete class // Events arguments go in the top namespace to avoid the Concrete suffix clutter in interface events.
// if(class_type == "class") // Regular/abstract class events go here too for consistency.
if(!as_generator(*(event_argument_wrapper)).generate(sink, cls.events, context))
return false;
bool root = !helpers::has_regular_ancestor(cls);
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> inherit_interfaces = helpers::non_implemented_interfaces(cls);
std::vector<attributes::klass_name> inherit_classes;
std::copy_if(cls.immediate_inherits.begin(), cls.immediate_inherits.end()
, std::back_inserter(inherit_classes)
, [] (attributes::klass_name const& klass)
{
switch (klass.type)
{
case attributes::class_type::regular:
case attributes::class_type::abstract_:
return true;
default:
return false;
};
});
// Concrete class for interfaces, mixins, etc.
if(class_type != "class")
{ {
auto concrete_cxt = context_add_tag(class_context{class_context::concrete}, context); auto concrete_cxt = context_add_tag(class_context{class_context::concrete}, context);
auto concrete_name = name_helpers::klass_concrete_name(cls); auto concrete_name = name_helpers::klass_concrete_name(cls);
auto interface_name = name_helpers::klass_interface_name(cls); auto interface_name = name_helpers::klass_interface_name(cls);
if(!as_generator if(!as_generator
( (
documentation documentation
<< "sealed public class " << concrete_name << " : " << interface_name << "\n{\n" << "sealed public class " << concrete_name << " : " << "\n"
<< scope_tab << "System.IntPtr handle;\n" << (klass_full_concrete_or_interface_name % ",") << "\n"
<< scope_tab << "///<summary>Pointer to the native instance.</summary>\n" << (inherit_classes.size() > 0 ? ", " : "" ) << interface_name << "\n"
<< scope_tab << "public System.IntPtr raw_handle {\n" << scope_tab << *(", " << name_helpers::klass_full_concrete_or_interface_name) << "\n"
<< scope_tab << scope_tab << "get { return handle; }\n" << "{\n"
<< scope_tab << "}\n" ).generate(sink, std::make_tuple(cls, inherit_classes, inherit_interfaces), concrete_cxt))
<< scope_tab << "///<summary>Pointer to the native class description.</summary>\n" return false;
<< scope_tab << "public System.IntPtr raw_klass {\n"
<< scope_tab << scope_tab << "get { return efl.eo.Globals.efl_class_get(handle); }\n" if (!generate_fields(sink, cls, concrete_cxt))
<< scope_tab << "}\n" return false;
<< scope_tab << "///<summary>Delegate for function to be called from inside the native constructor.</summary>\n"
<< scope_tab << "public delegate void ConstructingMethod(" << interface_name << " obj);\n" if (!as_generator
<< scope_tab << "///<summary>Returns the pointer the underlying Eo class object. Used internally on class methods.</summary>\n" (
<< scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(concrete_cxt).actual_library_name(cls.filename) scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(concrete_cxt).actual_library_name(cls.filename)
<< ")] public static extern System.IntPtr\n" << ")] internal static extern System.IntPtr\n"
<< scope_tab << scope_tab << name_helpers::klass_get_name(cls) << "();\n" << scope_tab << scope_tab << name_helpers::klass_get_name(cls) << "();\n"
<< (class_type == "class" ? "" : "/*")
<< scope_tab << "///<summary>Creates a new instance.</summary>\n"
<< scope_tab << "///<param>Parent instance.</param>\n"
<< scope_tab << "///<param>Delegate to call constructing methods that should be run inside the constructor.</param>\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"
<< scope_tab << scope_tab << "if(parent != null)\n"
<< scope_tab << scope_tab << scope_tab << "parent_ptr = parent.raw_handle;\n"
<< scope_tab << scope_tab << "handle = efl.eo.Globals._efl_add_internal_start(\"file\", 0, klass, parent_ptr, 1, 0);\n"
<< scope_tab << scope_tab << "register_event_proxies();\n"
<< scope_tab << scope_tab << "if (init_cb != null) {\n"
<< scope_tab << scope_tab << scope_tab << "init_cb(this);\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << "handle = efl.eo.Globals._efl_add_end(handle, 1, 0);\n" // replace handle with the actual final handle
<< scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n"
<< scope_tab << "}\n"
<< (class_type == "class" ? "" : "*/")
<< scope_tab << "///<summary>Constructs an instance from a native pointer.</summary>\n" << scope_tab << "///<summary>Constructs an instance from a native pointer.</summary>\n"
<< scope_tab << "public " << concrete_name << "(System.IntPtr raw)\n" << scope_tab << "public " << concrete_name << "(System.IntPtr raw)\n"
<< scope_tab << "{\n" << scope_tab << "{\n"
<< scope_tab << scope_tab << "handle = raw;\n" << scope_tab << scope_tab << "handle = raw;\n"
<< scope_tab << scope_tab << "register_event_proxies();\n" << scope_tab << scope_tab << "register_event_proxies();\n"
<< scope_tab << "}\n" << scope_tab << "}\n"
<< scope_tab << "///<summary>Destructor.</summary>\n"
<< scope_tab << "~" << concrete_name << "()\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "Dispose(false);\n"
<< scope_tab << "}\n"
<< scope_tab << "///<summary>Releases the underlying native instance.</summary>\n"
<< scope_tab << "internal void Dispose(bool disposing)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "if (handle != System.IntPtr.Zero) {\n"
<< scope_tab << scope_tab << scope_tab << "efl.eo.Globals.efl_unref(handle);\n"
<< scope_tab << scope_tab << scope_tab << "handle = System.IntPtr.Zero;\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << "}\n"
<< scope_tab << "///<summary>Releases the underlying native instance.</summary>\n"
<< scope_tab << "public void Dispose()\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "Dispose(true);\n"
<< scope_tab << scope_tab << "GC.SuppressFinalize(this);\n"
<< scope_tab << "}\n"
) )
.generate(sink, cls, concrete_cxt)) .generate(sink, attributes::unused, concrete_cxt))
return false;
if (!generate_dispose_methods(sink, cls, concrete_cxt))
return false; return false;
if (!generate_static_cast_method(sink, cls, concrete_cxt)) if (!generate_static_cast_method(sink, cls, concrete_cxt))
@ -249,100 +244,53 @@ struct klass
// Parts // Parts
if(!as_generator(*(part_definition)) if(!as_generator(*(part_definition))
.generate(sink, cls.get_all_parts(), concrete_cxt)) return false; .generate(sink, cls.parts, concrete_cxt)) return false;
// Concrete function definitions // Concrete function definitions
auto implemented_methods = helpers::get_all_implementable_methods(cls);
if(!as_generator(*(function_definition)) if(!as_generator(*(function_definition))
.generate(sink, methods, concrete_cxt)) return false; .generate(sink, implemented_methods, concrete_cxt)) return false;
// Async wrappers // Async wrappers
if(!as_generator(*(async_function_definition)).generate(sink, methods, concrete_cxt)) if(!as_generator(*(async_function_definition)).generate(sink, implemented_methods, concrete_cxt))
return false;
if(!as_generator(*(event_argument_wrapper)).generate(sink, cls.events, context))
return false; return false;
if(!as_generator("}\n").generate(sink, attributes::unused, concrete_cxt)) return false; if(!as_generator("}\n").generate(sink, attributes::unused, concrete_cxt)) return false;
} }
// Inherit class // Inheritable class
if(class_type == "class") if(class_type == "class")
{ {
auto inherit_cxt = context_add_tag(class_context{class_context::inherit}, context); auto inherit_cxt = context_add_tag(class_context{class_context::inherit}, context);
bool cls_has_string_return = has_string_return(cls);
bool cls_has_stringshare_return = has_stringshare_return(cls);
auto interface_name = name_helpers::klass_interface_name(cls);
auto inherit_name = name_helpers::klass_inherit_name(cls);
auto native_inherit_name = name_helpers::klass_native_inherit_name(cls);
// Class header
if(!as_generator if(!as_generator
( (
documentation documentation
<< "public " << class_type << " " << inherit_name << " : " << interface_name << "\n{\n" << "public " << class_type << " " << name_helpers::klass_concrete_name(cls) << " : "
<< scope_tab << "System.IntPtr handle;\n" << (klass_full_concrete_or_interface_name % ",") // classes
<< scope_tab << "internal static System.IntPtr klass = System.IntPtr.Zero;\n" << (inherit_classes.empty() ? "" : ",")
<< scope_tab << "private static readonly object klassAllocLock = new object();\n" << " Efl.Eo.IWrapper" << (root ? ", IDisposable" : "")
<< scope_tab << (cls_has_string_return ? ("internal Dictionary<String, IntPtr> cached_strings = new Dictionary<String, IntPtr>();") : "") << "\n" << (inherit_interfaces.empty() ? "" : ",")
<< scope_tab << (cls_has_stringshare_return ? ("internal Dictionary<String, IntPtr> cached_stringshares = new Dictionary<String, IntPtr>();") : "") << "\n" << (klass_full_concrete_or_interface_name % ",") // interfaces
<< scope_tab << "///<summary>Pointer to the native instance.</summary>\n" << "\n{\n"
<< scope_tab << "public System.IntPtr raw_handle {\n"
<< scope_tab << scope_tab << "get { return handle; }\n"
<< scope_tab << "}\n"
<< scope_tab << "///<summary>Pointer to the native class description.</summary>\n"
<< scope_tab << "public System.IntPtr raw_klass {\n"
<< scope_tab << scope_tab << "get { return klass; }\n"
<< scope_tab << "}\n"
<< scope_tab << "///<summary>Delegate for function to be called from inside the native constructor.</summary>\n"
<< scope_tab << "public delegate void ConstructingMethod(" << interface_name << " obj);\n"
<< scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(inherit_cxt).actual_library_name(cls.filename)
<< ")] private static extern System.IntPtr\n"
<< scope_tab << scope_tab << name_helpers::klass_get_name(cls) << "();\n"
<< scope_tab << "///<summary>Creates a new instance.</summary>\n"
<< scope_tab << "///<param>Parent instance.</param>\n"
<< scope_tab << "///<param>Delegate to call constructing methods that should be run inside the constructor.</param>\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"
<< scope_tab << scope_tab << scope_tab << scope_tab << "if (klass == System.IntPtr.Zero) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "klass = efl.eo.Globals.register_class(new efl.eo.Globals.class_initializer(" << native_inherit_name << ".class_initializer), \"" << cls.eolian_name << "\", " << name_helpers::klass_get_name(cls) << "());\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << "handle = efl.eo.Globals.instantiate_start(klass, parent);\n"
<< scope_tab << scope_tab << "register_event_proxies();\n"
<< scope_tab << scope_tab << "if (init_cb != null) {\n"
<< scope_tab << scope_tab << scope_tab << "init_cb(this);\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << "efl.eo.Globals.data_set(this);\n"
<< scope_tab << scope_tab << "handle = efl.eo.Globals.instantiate_end(handle);\n"
<< scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n"
<< scope_tab << "}\n"
<< scope_tab << "///<summary>Destructor.</summary>\n"
<< scope_tab << "~" << inherit_name << "()\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "Dispose(false);\n"
<< scope_tab << "}\n"
<< scope_tab << "///<summary>Releases the underlying native instance.</summary>\n"
<< scope_tab << "protected virtual void Dispose(bool disposing)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "if (handle != System.IntPtr.Zero) {\n"
<< scope_tab << scope_tab << scope_tab << "efl.eo.Globals.efl_unref(handle);\n"
<< scope_tab << scope_tab << scope_tab << "handle = System.IntPtr.Zero;\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << "}\n"
<< scope_tab << "///<summary>Releases the underlying native instance.</summary>\n"
<< scope_tab << "public void Dispose()\n"
<< scope_tab << "{\n"
<< scope_tab << (cls_has_string_return ? "efl.eo.Globals.free_dict_values(cached_strings);" : "") << "\n"
<< scope_tab << (cls_has_stringshare_return ? "efl.eo.Globals.free_stringshare_values(cached_stringshares);" : "") << "\n"
<< scope_tab << scope_tab << "Dispose(true);\n"
<< scope_tab << scope_tab << "GC.SuppressFinalize(this);\n"
<< scope_tab << "}\n"
) )
.generate(sink, cls, inherit_cxt)) .generate(sink, std::make_tuple(cls, inherit_classes, inherit_interfaces), inherit_cxt))
return false;
// Class body
if(!generate_fields(sink, cls, inherit_cxt))
return false;
if (!generate_constructors(sink, cls, inherit_cxt))
return false;
if (!generate_dispose_methods(sink, cls, inherit_cxt))
return false;
if (!generate_static_cast_method(sink, cls, inherit_cxt))
return false; return false;
if (!generate_equals_method(sink, inherit_cxt)) if (!generate_equals_method(sink, inherit_cxt))
@ -356,20 +304,21 @@ struct klass
// Parts // Parts
if(!as_generator(*(part_definition)) if(!as_generator(*(part_definition))
.generate(sink, cls.get_all_parts(), inherit_cxt)) return false; .generate(sink, cls.parts, inherit_cxt)) return false;
// Inherit function definitions // Inherit function definitions
auto implemented_methods = helpers::get_all_implementable_methods(cls);
if(!as_generator(*(function_definition(true))) if(!as_generator(*(function_definition(true)))
.generate(sink, methods, inherit_cxt)) return false; .generate(sink, implemented_methods, inherit_cxt)) return false;
// Async wrappers // Async wrappers
if(!as_generator(*(async_function_definition(true))).generate(sink, methods, inherit_cxt)) if(!as_generator(*(async_function_definition(true))).generate(sink, implemented_methods, inherit_cxt))
return false; return false;
if(!as_generator("}\n").generate(sink, attributes::unused, inherit_cxt)) return false; if(!as_generator("}\n").generate(sink, attributes::unused, inherit_cxt)) return false;
} }
std::size_t function_count = get_inheritable_function_count(cls); std::size_t function_count = get_implementable_function_count(cls);
int function_registration_index = 0; int function_registration_index = 0;
auto index_generator = [&function_registration_index] auto index_generator = [&function_registration_index]
@ -394,7 +343,7 @@ struct klass
// Native wrapper registration // Native wrapper registration
if(!as_generator(*(function_registration(index_generator, cls))) if(!as_generator(*(function_registration(index_generator, cls)))
.generate(sink, methods, inative_cxt)) return false; .generate(sink, helpers::get_all_implementable_methods(cls), inative_cxt)) return false;
if(!as_generator if(!as_generator
( scope_tab << scope_tab << "IntPtr descs_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(descs[0])*" << function_count << ");\n" ( scope_tab << scope_tab << "IntPtr descs_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(descs[0])*" << function_count << ");\n"
@ -409,7 +358,7 @@ struct klass
<< scope_tab << scope_tab << "ops.count = (UIntPtr)" << function_count << ";\n" << scope_tab << scope_tab << "ops.count = (UIntPtr)" << function_count << ";\n"
<< scope_tab << scope_tab << "IntPtr ops_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(ops));\n" << scope_tab << scope_tab << "IntPtr ops_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(ops));\n"
<< scope_tab << scope_tab << "Marshal.StructureToPtr(ops, ops_ptr, false);\n" << scope_tab << scope_tab << "Marshal.StructureToPtr(ops, ops_ptr, false);\n"
<< scope_tab << scope_tab << "efl.eo.Globals.efl_class_functions_set(klass, ops_ptr, IntPtr.Zero);\n" << scope_tab << scope_tab << "Efl.Eo.Globals.efl_class_functions_set(klass, ops_ptr, IntPtr.Zero);\n"
).generate(sink, attributes::unused, inative_cxt)) return false; ).generate(sink, attributes::unused, inative_cxt)) return false;
@ -419,7 +368,7 @@ struct klass
// //
// Native method definitions // Native method definitions
if(!as_generator(*(native_function_definition(cls))) if(!as_generator(*(native_function_definition(cls)))
.generate(sink, methods, inative_cxt)) return false; .generate(sink, helpers::get_all_implementable_methods(cls), inative_cxt)) return false;
if(!as_generator("}\n").generate(sink, attributes::unused, inative_cxt)) return false; if(!as_generator("}\n").generate(sink, attributes::unused, inative_cxt)) return false;
} }
@ -430,12 +379,223 @@ struct klass
return true; return true;
} }
template <typename OutputIterator, typename Context>
bool generate_fields(OutputIterator sink, attributes::klass_def const& cls, Context const& context) const
{
std::string visibility = is_inherit_context(context) ? "protected " : "private ";
bool root = !helpers::has_regular_ancestor(cls);
bool is_inherit = is_inherit_context(context);
std::string class_getter = "return Efl.Eo.Globals.efl_class_get(handle);";
// The klass field is static but there is no problem if multiple C# classes inherit from this generated one
// as it is just a simple wrapper, forwarding the Eo calls either to the user API (where C#'s virtual method
// resolution kicks in) or to the base implementation (efl_super).
if (is_inherit)
{
if(!as_generator(
scope_tab << "public " << (root ? "" : "new ") << "static System.IntPtr klass = System.IntPtr.Zero;\n"
).generate(sink, attributes::unused, context))
return false;
class_getter = "return klass;";
}
std::string raw_klass_modifier;
if (!root)
raw_klass_modifier = "override ";
else if (is_inherit)
raw_klass_modifier = "virtual ";
if(!as_generator(
scope_tab << "///<summary>Pointer to the native class description.</summary>\n"
<< scope_tab << "public " << raw_klass_modifier << "System.IntPtr NativeClass {\n"
<< scope_tab << scope_tab << "get {\n"
<< scope_tab << scope_tab << scope_tab << class_getter << "\n" //return klass; }\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << "}\n"
).generate(sink, attributes::unused, context))
return false;
// The remaining fields aren't needed in children classes.
if (!root)
return true;
if (cls.get_all_events().size() > 0)
if (!as_generator(scope_tab << (is_inherit ? "protected " : "private ") << "EventHandlerList eventHandlers = new EventHandlerList();\n").generate(sink, attributes::unused, context))
return false;
if (is_inherit)
{
if (!as_generator(
scope_tab << "private static readonly object klassAllocLock = new object();\n"
<< scope_tab << "protected bool inherited;\n"
).generate(sink, attributes::unused, context))
return false;
}
return as_generator(
scope_tab << visibility << " System.IntPtr handle;\n"
<< scope_tab << "public Dictionary<String, IntPtr> cached_strings = new Dictionary<String, IntPtr>();" << "\n"
<< scope_tab << "public Dictionary<String, IntPtr> cached_stringshares = new Dictionary<String, IntPtr>();" << "\n"
<< scope_tab << "///<summary>Pointer to the native instance.</summary>\n"
<< scope_tab << "public System.IntPtr NativeHandle {\n"
<< scope_tab << scope_tab << "get { return handle; }\n"
<< scope_tab << "}\n"
).generate(sink, attributes::unused, context);
}
template <typename OutputIterator, typename Context>
bool generate_constructors(OutputIterator sink, attributes::klass_def const& cls, Context const& context) const
{
bool root = !helpers::has_regular_ancestor(cls);
auto inherit_name = name_helpers::klass_concrete_name(cls);
auto native_inherit_name = name_helpers::klass_native_inherit_name(cls);
if(!as_generator(
scope_tab << "///<summary>Delegate for function to be called from inside the native constructor.</summary>\n"
<< scope_tab << "public" << (root ? "" : " new") << " delegate void ConstructingMethod(" << inherit_name << " obj);\n"
<< scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(context).actual_library_name(cls.filename)
<< ")] internal static extern System.IntPtr\n"
<< scope_tab << scope_tab << name_helpers::klass_get_name(cls) << "();\n"
).generate(sink, attributes::unused, context))
return false;
if (!root)
{
return as_generator(
scope_tab << "///<summary>Creates a new instance.</summary>\n"
<< scope_tab << "///<param name=\"parent\">Parent instance.</param>\n"
<< scope_tab << "///<param name=\"init_cb\">Delegate to call constructing methods that should be run inside the constructor.</param>\n"
<< scope_tab << "public " << inherit_name << "(Efl.Object parent = null, ConstructingMethod init_cb=null) : base(" << native_inherit_name << ".class_initializer, \"" << inherit_name << "\", " << name_helpers::klass_get_name(cls) << "(), typeof(" << inherit_name << "), parent, ref klass)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "if (init_cb != null) {\n"
<< scope_tab << scope_tab << scope_tab << "init_cb(this);\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << "FinishInstantiation();\n"
<< scope_tab << "}\n"
<< scope_tab << "///<summary>Internal constructor to forward the wrapper initialization to the root class.</summary>\n"
<< scope_tab << "protected " << inherit_name << "(Efl.Eo.Globals.class_initializer class_initializer, String klass_name, IntPtr base_klass, Type managed_type, Efl.Object parent, ref IntPtr target_klass) : base(class_initializer, klass_name, base_klass, managed_type, parent, ref target_klass) {}\n"
<< scope_tab << "///<summary>Constructs an instance from a native pointer.</summary>\n"
<< scope_tab << "public " << inherit_name << "(System.IntPtr raw)" << (root ? "" : " : base(raw)") << "\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << (root ? "handle = raw;\n" : "")
<< scope_tab << scope_tab << "register_event_proxies();\n"
<< scope_tab << "}\n"
).generate(sink, attributes::unused, context);
}
// Detailed constructors go only in root classes.
return as_generator(
scope_tab << "///<summary>Creates a new instance.</summary>\n"
<< scope_tab << "///<param name=\"parent\">Parent instance.</param>\n"
<< scope_tab << "///<param name=\"init_cb\">Delegate to call constructing methods that should be run inside the constructor.</param>\n"
<< scope_tab << "public " << inherit_name << "(Efl.Object parent = null, ConstructingMethod init_cb=null) : this(" << native_inherit_name << ".class_initializer, \"" << inherit_name << "\", " << name_helpers::klass_get_name(cls) << "(), typeof(" << inherit_name << "), parent, ref klass)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "if (init_cb != null) {\n"
<< scope_tab << scope_tab << scope_tab << "init_cb(this);\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << "FinishInstantiation();\n"
<< scope_tab << "}\n"
<< scope_tab << "protected " << inherit_name << "(Efl.Eo.Globals.class_initializer class_initializer, String klass_name, IntPtr base_klass, Type managed_type, Efl.Object parent, ref IntPtr target_klass)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "inherited = this.GetType() != managed_type;\n"
<< scope_tab << scope_tab << "IntPtr actual_klass = base_klass;\n"
<< scope_tab << scope_tab << "if (inherited) {\n"
<< scope_tab << scope_tab << scope_tab << "if (target_klass == System.IntPtr.Zero) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "lock (klassAllocLock) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "if (target_klass == System.IntPtr.Zero) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "target_klass = Efl.Eo.Globals.register_class(class_initializer, klass_name, base_klass);\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "if (target_klass == System.IntPtr.Zero) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "throw new System.InvalidOperationException(\"Failed to initialize class '" << inherit_name << "'\");\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << scope_tab << "actual_klass = target_klass;\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << "handle = Efl.Eo.Globals.instantiate_start(actual_klass, parent);\n"
<< scope_tab << scope_tab << "register_event_proxies();\n"
<< scope_tab << "}\n"
<< scope_tab << "protected void FinishInstantiation()\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "if (inherited) {\n"
<< scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.data_set(this);\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << "handle = Efl.Eo.Globals.instantiate_end(handle);\n"
<< scope_tab << scope_tab << "Eina.Error.RaiseIfOccurred();\n"
<< scope_tab << "}\n"
<< scope_tab << "///<summary>Constructs an instance from a native pointer.</summary>\n"
<< scope_tab << "public " << inherit_name << "(System.IntPtr raw)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "handle = raw;\n"
<< scope_tab << scope_tab << "register_event_proxies();\n"
<< scope_tab << "}\n"
).generate(sink, attributes::unused, context);
}
template <typename OutputIterator, typename Context>
bool generate_dispose_methods(OutputIterator sink, attributes::klass_def const& cls, Context const& context) const
{
std::string name = join_namespaces(cls.namespaces, '.') + cls.eolian_name;
if (helpers::has_regular_ancestor(cls))
return true;
std::string visibility = is_inherit_context(context) ? "protected virtual " : "";
auto inherit_name = name_helpers::klass_concrete_name(cls);
return as_generator(
scope_tab << "///<summary>Destructor.</summary>\n"
<< scope_tab << "~" << inherit_name << "()\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "Dispose(false);\n"
<< scope_tab << "}\n"
<< scope_tab << "///<summary>Releases the underlying native instance.</summary>\n"
<< scope_tab << visibility << "void Dispose(bool disposing)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "if (handle != System.IntPtr.Zero) {\n"
<< scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.efl_unref(handle);\n"
<< scope_tab << scope_tab << scope_tab << "handle = System.IntPtr.Zero;\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << "}\n"
<< scope_tab << "///<summary>Releases the underlying native instance.</summary>\n"
<< scope_tab << "public void Dispose()\n"
<< scope_tab << "{\n"
<< scope_tab << "Efl.Eo.Globals.free_dict_values(cached_strings);" << "\n"
<< scope_tab << "Efl.Eo.Globals.free_stringshare_values(cached_stringshares);" << "\n"
<< scope_tab << scope_tab << "Dispose(true);\n"
<< scope_tab << scope_tab << "GC.SuppressFinalize(this);\n"
<< scope_tab << "}\n"
).generate(sink, attributes::unused, context);
}
template <typename OutputIterator, typename Context> template <typename OutputIterator, typename Context>
bool generate_events_registration(OutputIterator sink, attributes::klass_def const& cls, Context const& context) const bool generate_events_registration(OutputIterator sink, attributes::klass_def const& cls, Context const& context) const
{ {
bool root = !helpers::has_regular_ancestor(cls);
std::string virtual_modifier = " ";
if (!root)
virtual_modifier = "override ";
else
{
if (is_inherit_context(context))
virtual_modifier = "virtual ";
}
// Event proxy registration // Event proxy registration
if (!as_generator( if (!as_generator(
scope_tab << "private void register_event_proxies()\n" scope_tab << (is_inherit_context(context) || !root ? "protected " : "") << virtual_modifier << "void register_event_proxies()\n"
<< scope_tab << "{\n" << scope_tab << "{\n"
) )
.generate(sink, NULL, context)) .generate(sink, NULL, context))
@ -443,15 +603,23 @@ struct klass
// Generate event registrations here // Generate event registrations here
// Assigning the delegates if (!root)
if (!as_generator(*(event_registration())).generate(sink, cls.events, context)) if (!as_generator(scope_tab << scope_tab << "base.register_event_proxies();\n").generate(sink, NULL, context))
return false; return false;
for (auto&& c : cls.inherits) // Assigning the delegates
if (!as_generator(*(event_registration(cls, cls))).generate(sink, cls.events, context))
return false;
for (auto&& c : helpers::non_implemented_interfaces(cls))
{ {
// Only non-regular types (which declare events through interfaces) need to register them.
if (c.type == attributes::class_type::regular)
continue;
attributes::klass_def klass(get_klass(c, cls.unit), cls.unit); attributes::klass_def klass(get_klass(c, cls.unit), cls.unit);
if (!as_generator(*(event_registration(&klass))).generate(sink, klass.events, context)) if (!as_generator(*(event_registration(klass, cls))).generate(sink, klass.events, context))
return false; return false;
} }
@ -472,51 +640,57 @@ struct klass
std::string visibility = is_inherit_context(context) ? "protected " : "private "; std::string visibility = is_inherit_context(context) ? "protected " : "private ";
if (!as_generator(scope_tab << "private readonly object eventLock = new object();\n" if (!helpers::has_regular_ancestor(cls))
<< scope_tab << "private Dictionary<string, int> event_cb_count = new Dictionary<string, int>();\n") {
if (!as_generator(scope_tab << visibility << "readonly object eventLock = new object();\n"
<< scope_tab << visibility << "Dictionary<string, int> event_cb_count = new Dictionary<string, int>();\n")
.generate(sink, NULL, context)) .generate(sink, NULL, context))
return false; return false;
// Callback registration functions // Callback registration functions
if (!as_generator( if (!as_generator(
scope_tab << "private bool add_cpp_event_handler(string key, efl.Event_Cb evt_delegate) {\n" scope_tab << visibility << "bool add_cpp_event_handler(string key, Efl.EventCb evt_delegate) {\n"
<< scope_tab << scope_tab << "int event_count = 0;\n" << scope_tab << scope_tab << "int event_count = 0;\n"
<< scope_tab << scope_tab << "if (!event_cb_count.TryGetValue(key, out event_count))\n" << scope_tab << scope_tab << "if (!event_cb_count.TryGetValue(key, out event_count))\n"
<< scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n" << scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n"
<< scope_tab << scope_tab << "if (event_count == 0) {\n" << scope_tab << scope_tab << "if (event_count == 0) {\n"
<< scope_tab << scope_tab << scope_tab << "IntPtr desc = efl.Event_Description.GetNative(key);\n"
<< scope_tab << scope_tab << scope_tab << "IntPtr desc = Efl.EventDescription.GetNative(key);\n"
<< scope_tab << scope_tab << scope_tab << "if (desc == IntPtr.Zero) {\n" << scope_tab << scope_tab << scope_tab << "if (desc == IntPtr.Zero) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Failed to get native event {key}\");\n" << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to get native event {key}\");\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n" << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n"
<< scope_tab << scope_tab << scope_tab << "}\n" << scope_tab << scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << scope_tab << "bool result = efl.eo.Globals.efl_event_callback_priority_add(handle, desc, 0, evt_delegate, System.IntPtr.Zero);\n"
<< scope_tab << scope_tab << scope_tab << " bool result = Efl.Eo.Globals.efl_event_callback_priority_add(handle, desc, 0, evt_delegate, System.IntPtr.Zero);\n"
<< scope_tab << scope_tab << scope_tab << "if (!result) {\n" << scope_tab << scope_tab << scope_tab << "if (!result) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Failed to add event proxy for event {key}\");\n" << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to add event proxy for event {key}\");\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n" << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n"
<< scope_tab << scope_tab << scope_tab << "}\n" << scope_tab << scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n" << scope_tab << scope_tab << scope_tab << "Eina.Error.RaiseIfOccurred();\n"
<< scope_tab << scope_tab << "} \n" << scope_tab << scope_tab << "} \n"
<< scope_tab << scope_tab << "event_cb_count[key]++;\n" << scope_tab << scope_tab << "event_cb_count[key]++;\n"
<< scope_tab << scope_tab << "return true;\n" << scope_tab << scope_tab << "return true;\n"
<< scope_tab << "}\n" << scope_tab << "}\n"
<< scope_tab << "private bool remove_cpp_event_handler(string key, efl.Event_Cb evt_delegate) {\n" << scope_tab << visibility << "bool remove_cpp_event_handler(string key, Efl.EventCb evt_delegate) {\n"
<< scope_tab << scope_tab << "int event_count = 0;\n" << scope_tab << scope_tab << "int event_count = 0;\n"
<< scope_tab << scope_tab << "if (!event_cb_count.TryGetValue(key, out event_count))\n" << scope_tab << scope_tab << "if (!event_cb_count.TryGetValue(key, out event_count))\n"
<< scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n" << scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n"
<< scope_tab << scope_tab << "if (event_count == 1) {\n" << scope_tab << scope_tab << "if (event_count == 1) {\n"
<< scope_tab << scope_tab << scope_tab << "IntPtr desc = efl.Event_Description.GetNative(key);\n"
<< scope_tab << scope_tab << scope_tab << "IntPtr desc = Efl.EventDescription.GetNative(key);\n"
<< scope_tab << scope_tab << scope_tab << "if (desc == IntPtr.Zero) {\n" << scope_tab << scope_tab << scope_tab << "if (desc == IntPtr.Zero) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Failed to get native event {key}\");\n" << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to get native event {key}\");\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n" << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n"
<< scope_tab << scope_tab << scope_tab << "}\n" << scope_tab << scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << scope_tab << "bool result = efl.eo.Globals.efl_event_callback_del(handle, desc, evt_delegate, System.IntPtr.Zero);\n"
<< scope_tab << scope_tab << scope_tab << "bool result = Efl.Eo.Globals.efl_event_callback_del(handle, desc, evt_delegate, System.IntPtr.Zero);\n"
<< scope_tab << scope_tab << scope_tab << "if (!result) {\n" << scope_tab << scope_tab << scope_tab << "if (!result) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Failed to remove event proxy for event {key}\");\n" << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to remove event proxy for event {key}\");\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n" << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n"
<< scope_tab << scope_tab << scope_tab << "}\n" << scope_tab << scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n" << scope_tab << scope_tab << scope_tab << "Eina.Error.RaiseIfOccurred();\n"
<< scope_tab << scope_tab << "} else if (event_count == 0) {\n" << scope_tab << scope_tab << "} else if (event_count == 0) {\n"
<< scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Trying to remove proxy for event {key} when there is nothing registered.\");\n" << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Trying to remove proxy for event {key} when there is nothing registered.\");\n"
<< scope_tab << scope_tab << scope_tab << "return false;\n" << scope_tab << scope_tab << scope_tab << "return false;\n"
<< scope_tab << scope_tab << "} \n" << scope_tab << scope_tab << "} \n"
<< scope_tab << scope_tab << "event_cb_count[key]--;\n" << scope_tab << scope_tab << "event_cb_count[key]--;\n"
@ -525,16 +699,20 @@ struct klass
) )
.generate(sink, NULL, context)) .generate(sink, NULL, context))
return false; return false;
}
// Self events // Self events
if (!as_generator(*(event_definition(cls))).generate(sink, cls.events, context)) if (!as_generator(*(event_definition(cls, cls))).generate(sink, cls.events, context))
return false; return false;
// Inherited events // Inherited events
for (auto&& c : cls.inherits)
// For now, as mixins can inherit from regular classes, we can't filter out inherited events.
auto inherits = helpers::non_implemented_interfaces(cls);
for (auto&& c : inherits)
{ {
attributes::klass_def klass(get_klass(c, cls.unit), cls.unit); attributes::klass_def klass(get_klass(c, cls.unit), cls.unit);
if (!as_generator(*(event_definition(klass, true))).generate(sink, klass.events, context)) if (!as_generator(*(event_definition(klass, cls))).generate(sink, klass.events, context))
return false; return false;
} }
return true; return true;

View File

@ -53,34 +53,34 @@ struct marshall_annotation_visitor_generate
// signed primitives // signed primitives
{"bool", nullptr, [&] { return " [MarshalAs(UnmanagedType.U1)]"; }}, {"bool", nullptr, [&] { return " [MarshalAs(UnmanagedType.U1)]"; }},
{"string", true, [&] { {"string", true, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringPassOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]";
}}, }},
{"string", false, [&] { {"string", false, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringKeepOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]";
}}, }},
{"mstring", true, [&] { {"mstring", true, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringPassOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]";
}}, }},
{"mstring", false, [&] { {"mstring", false, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringKeepOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]";
}}, }},
{"stringshare", true, [&] { {"stringshare", true, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringsharePassOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringsharePassOwnershipMarshaler))]";
}}, }},
{"stringshare", false, [&] { {"stringshare", false, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringshareKeepOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringshareKeepOwnershipMarshaler))]";
}}, }},
{"any_value_ptr", true, [&] { {"any_value_ptr", true, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(eina.ValueMarshalerOwn))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshalerOwn))]";
}}, }},
{"any_value_ptr", false, [&] { {"any_value_ptr", false, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(eina.ValueMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshaler))]";
}}, }},
{"strbuf", true, [&] { {"strbuf", true, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StrbufPassOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]";
}}, }},
{"strbuf", false, [&] { {"strbuf", false, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StrbufKeepOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]";
}}, }},
}; };
match const return_match_table[] = match const return_match_table[] =
@ -88,34 +88,34 @@ struct marshall_annotation_visitor_generate
// signed primitives // signed primitives
{"bool", nullptr, [&] { return " [return: MarshalAs(UnmanagedType.U1)]"; }}, {"bool", nullptr, [&] { return " [return: MarshalAs(UnmanagedType.U1)]"; }},
{"string", true, [&] { {"string", true, [&] {
return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringPassOwnershipMarshaler))]"; return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]";
}}, }},
{"string", false, [&] { {"string", false, [&] {
return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringKeepOwnershipMarshaler))]"; return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]";
}}, }},
{"mstring", true, [&] { {"mstring", true, [&] {
return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringPassOwnershipMarshaler))]"; return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]";
}}, }},
{"mstring", false, [&] { {"mstring", false, [&] {
return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringKeepOwnershipMarshaler))]"; return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]";
}}, }},
{"stringshare", true, [&] { {"stringshare", true, [&] {
return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringsharePassOwnershipMarshaler))]"; return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringsharePassOwnershipMarshaler))]";
}}, }},
{"stringshare", false, [&] { {"stringshare", false, [&] {
return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringshareKeepOwnershipMarshaler))]"; return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringshareKeepOwnershipMarshaler))]";
}}, }},
{"any_value_ptr", true, [&] { {"any_value_ptr", true, [&] {
return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(eina.ValueMarshalerOwn))]"; return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshalerOwn))]";
}}, }},
{"any_value_ptr", false, [&] { {"any_value_ptr", false, [&] {
return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(eina.ValueMarshaler))]"; return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshaler))]";
}}, }},
{"strbuf", true, [&] { {"strbuf", true, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StrbufPassOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]";
}}, }},
{"strbuf", false, [&] { {"strbuf", false, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StrbufKeepOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]";
}}, }},
}; };
@ -142,11 +142,11 @@ struct marshall_annotation_visitor_generate
} }
bool operator()(attributes::klass_name const& klass_name) const bool operator()(attributes::klass_name const& klass_name) const
{ {
const char no_return_prefix[] = "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(efl.eo.MarshalTest<"; const char no_return_prefix[] = "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Efl.Eo.MarshalTest<";
const char return_prefix[] = "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(efl.eo.MarshalTest<"; const char return_prefix[] = "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Efl.Eo.MarshalTest<";
return as_generator return as_generator
((is_return ? return_prefix : no_return_prefix) ((is_return ? return_prefix : no_return_prefix)
<< string << ", efl.eo." << (klass_name.base_qualifier & qualifier_info::is_own ? "OwnTag" : "NonOwnTag") << ">))]" << string << ", Efl.Eo." << (klass_name.base_qualifier & qualifier_info::is_own ? "OwnTag" : "NonOwnTag") << ">))]"
).generate(sink, name_helpers::klass_full_concrete_name(klass_name), *context); ).generate(sink, name_helpers::klass_full_concrete_name(klass_name), *context);
} }
bool operator()(attributes::complex_type_def const& c) const bool operator()(attributes::complex_type_def const& c) const
@ -154,7 +154,7 @@ struct marshall_annotation_visitor_generate
if (c.outer.base_type == "future") if (c.outer.base_type == "future")
{ {
std::string prefix = is_return ? "return: " : ""; std::string prefix = is_return ? "return: " : "";
return as_generator("[" << prefix << "MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(eina.FutureMarshaler))]").generate(sink, nullptr, *context); return as_generator("[" << prefix << "MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))]").generate(sink, nullptr, *context);
} }
return true; return true;
} }
@ -187,26 +187,26 @@ struct marshall_native_annotation_visitor_generate
// signed primitives // signed primitives
{"bool", nullptr, [&] { return " [MarshalAs(UnmanagedType.U1)]"; }}, {"bool", nullptr, [&] { return " [MarshalAs(UnmanagedType.U1)]"; }},
{"string", true, [&] { {"string", true, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringPassOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]";
}}, }},
{"string", false, [&] { {"string", false, [&] {
if (is_out) if (is_out)
return ""; return "";
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringKeepOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]";
}}, }},
{"stringshare", true, [&] { {"stringshare", true, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringsharePassOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringsharePassOwnershipMarshaler))]";
}}, }},
{"stringshare", false, [&] { {"stringshare", false, [&] {
if (is_out) if (is_out)
return ""; return "";
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringshareKeepOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringshareKeepOwnershipMarshaler))]";
}}, }},
{"strbuf", true, [&] { {"strbuf", true, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StrbufPassOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]";
}}, }},
{"strbuf", false, [&] { {"strbuf", false, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StrbufKeepOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]";
}}, }},
}; };
match const return_match_table[] = match const return_match_table[] =
@ -214,18 +214,18 @@ struct marshall_native_annotation_visitor_generate
// signed primitives // signed primitives
{"bool", nullptr, [&] { return " [return: MarshalAs(UnmanagedType.U1)]"; }}, {"bool", nullptr, [&] { return " [return: MarshalAs(UnmanagedType.U1)]"; }},
{"string", true, [&] { {"string", true, [&] {
return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringPassOwnershipMarshaler))]"; return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]";
}}, }},
{"string", false, [&] { return ""; }}, {"string", false, [&] { return ""; }},
{"stringshare", true, [&] { {"stringshare", true, [&] {
return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StringsharePassOwnershipMarshaler))]"; return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringsharePassOwnershipMarshaler))]";
}}, }},
{"stringshare", false, [&] { return ""; }}, {"stringshare", false, [&] { return ""; }},
{"strbuf", true, [&] { {"strbuf", true, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StrbufPassOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]";
}}, }},
{"strbuf", false, [&] { {"strbuf", false, [&] {
return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(efl.eo.StrbufKeepOwnershipMarshaler))]"; return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]";
}}, }},
}; };
@ -252,11 +252,11 @@ struct marshall_native_annotation_visitor_generate
} }
bool operator()(attributes::klass_name const& klass_name) const bool operator()(attributes::klass_name const& klass_name) const
{ {
const char no_return_prefix[] = "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(efl.eo.MarshalTest<"; const char no_return_prefix[] = "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Efl.Eo.MarshalTest<";
const char return_prefix[] = "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(efl.eo.MarshalTest<"; const char return_prefix[] = "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Efl.Eo.MarshalTest<";
return as_generator return as_generator
((is_return ? return_prefix : no_return_prefix) ((is_return ? return_prefix : no_return_prefix)
<< string << ", efl.eo." << (klass_name.base_qualifier & qualifier_info::is_own ? "OwnTag" : "NonOwnTag") << ">))]" << string << ", Efl.Eo." << (klass_name.base_qualifier & qualifier_info::is_own ? "OwnTag" : "NonOwnTag") << ">))]"
).generate(sink, name_helpers::klass_full_concrete_name(klass_name), *context); ).generate(sink, name_helpers::klass_full_concrete_name(klass_name), *context);
} }
bool operator()(attributes::complex_type_def const& c) const bool operator()(attributes::complex_type_def const& c) const
@ -264,7 +264,7 @@ struct marshall_native_annotation_visitor_generate
if (c.outer.base_type == "future") if (c.outer.base_type == "future")
{ {
std::string prefix = is_return ? "return: " : ""; std::string prefix = is_return ? "return: " : "";
return as_generator("[" << prefix << "MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(eina.FutureMarshaler))]").generate(sink, nullptr, *context); return as_generator("[" << prefix << "MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))]").generate(sink, nullptr, *context);
} }
return true; return true;
} }

View File

@ -22,7 +22,7 @@ struct marshall_native_annotation_visitor_generate;
* *
* For example, Eina.Value can be marshaled either as an eina.Value instance through * For example, Eina.Value can be marshaled either as an eina.Value instance through
* CustomMarshallers if we have a ptr(Eina.Value) or through the intermediate * CustomMarshallers if we have a ptr(Eina.Value) or through the intermediate
* eina.Value_Native blittable struct if it is passed by value. * eina.ValueNative blittable struct if it is passed by value.
* *
* For details, check marshall_type_impl.h with the actual conversion rules. * For details, check marshall_type_impl.h with the actual conversion rules.
*/ */

View File

@ -94,7 +94,7 @@ struct marshall_type_visitor_generate
{ {
regular_type_def r = regular; regular_type_def r = regular;
r.base_qualifier.qualifier ^= qualifier_info::is_ref; r.base_qualifier.qualifier ^= qualifier_info::is_ref;
return replace_base_type(r, " eina.Strbuf"); return replace_base_type(r, " Eina.Strbuf");
}} }}
, {"Binbuf", true, [&] , {"Binbuf", true, [&]
{ {
@ -115,9 +115,9 @@ struct marshall_type_visitor_generate
regular_type_def r = regular; regular_type_def r = regular;
r.namespaces.clear(); r.namespaces.clear();
if (is_ptr) if (is_ptr)
r.base_type = " eina.Value"; r.base_type = " Eina.Value";
else else
r.base_type = " eina.Value_Native"; r.base_type = " Eina.ValueNative";
return r; return r;
}} }}
, {"any_value", false, [&] , {"any_value", false, [&]
@ -125,23 +125,23 @@ struct marshall_type_visitor_generate
regular_type_def r = regular; regular_type_def r = regular;
r.namespaces.clear(); r.namespaces.clear();
if (is_ptr) if (is_ptr)
r.base_type = " eina.Value"; r.base_type = " Eina.Value";
else else
r.base_type = " eina.Value_Native"; r.base_type = " Eina.ValueNative";
return r; return r;
}} }}
, {"any_value_ptr", true, [&] , {"any_value_ptr", true, [&]
{ {
regular_type_def r = regular; regular_type_def r = regular;
r.namespaces.clear(); r.namespaces.clear();
r.base_type = " eina.Value"; r.base_type = " Eina.Value";
return r; return r;
}} }}
, {"any_value_ptr", false, [&] , {"any_value_ptr", false, [&]
{ {
regular_type_def r = regular; regular_type_def r = regular;
r.namespaces.clear(); r.namespaces.clear();
r.base_type = " eina.Value"; r.base_type = " Eina.Value";
return r; return r;
}} }}
, {"void", nullptr, [&] , {"void", nullptr, [&]

View File

@ -36,6 +36,10 @@ inline bool is_iequal(std::string const& lhs, std::string const& rhs)
{ {
return strcasecmp(lhs.c_str(), rhs.c_str()) == 0; return strcasecmp(lhs.c_str(), rhs.c_str()) == 0;
} }
inline bool is_equal(std::string const& lhs, std::string const& rhs)
{
return lhs == rhs;
}
} }
inline std::string identity(std::string const& str) inline std::string identity(std::string const& str)
@ -45,21 +49,21 @@ inline std::string identity(std::string const& str)
inline std::string escape_keyword(std::string const& name) inline std::string escape_keyword(std::string const& name)
{ {
using detail::is_iequal; using detail::is_equal;
if(is_iequal(name, "delete") if(is_equal(name, "delete")
|| is_iequal(name, "do") || is_equal(name, "do")
|| is_iequal(name, "lock") || is_equal(name, "lock")
|| is_iequal(name, "event") || is_equal(name, "event")
|| is_iequal(name, "in") || is_equal(name, "in")
|| is_iequal(name, "object") || is_equal(name, "object")
|| is_iequal(name, "interface") || is_equal(name, "interface")
|| is_iequal(name, "string") || is_equal(name, "string")
|| is_iequal(name, "internal") || is_equal(name, "internal")
|| is_iequal(name, "fixed") || is_equal(name, "fixed")
|| is_iequal(name, "base")) || is_equal(name, "base"))
return "kw_" + name; return "kw_" + name;
if (is_iequal(name, "Finalize")) if (is_equal(name, "Finalize"))
return name + "Add"; // Eo's Finalize is actually the end of efl_add. return name + "Add"; // Eo's Finalize is actually the end of efl_add.
return name; return name;
} }
@ -169,7 +173,7 @@ void reorder_verb(std::vector<std::string> &names)
inline std::string managed_namespace(std::string const& ns) inline std::string managed_namespace(std::string const& ns)
{ {
return utils::to_lowercase(escape_keyword(ns)); return escape_keyword(utils::remove_all(ns, '_'));
} }
inline std::string managed_method_name(attributes::function_def const& f) inline std::string managed_method_name(attributes::function_def const& f)
@ -208,7 +212,7 @@ inline std::string type_full_eolian_name(attributes::regular_type_def const& typ
inline std::string type_full_managed_name(attributes::regular_type_def const& type) inline std::string type_full_managed_name(attributes::regular_type_def const& type)
{ {
return join_namespaces(type.namespaces, '.', managed_namespace) + type.base_type; return join_namespaces(type.namespaces, '.', managed_namespace) + utils::remove_all(type.base_type, '_');
} }
inline std::string struct_full_eolian_name(attributes::struct_def const& struct_) inline std::string struct_full_eolian_name(attributes::struct_def const& struct_)
@ -216,9 +220,22 @@ inline std::string struct_full_eolian_name(attributes::struct_def const& struct_
return join_namespaces(struct_.namespaces, '.') + struct_.cxx_name; return join_namespaces(struct_.namespaces, '.') + struct_.cxx_name;
} }
inline std::string enum_managed_name(attributes::enum_def const& enum_) template<typename T>
inline std::string typedecl_managed_name(T const& item)
{ {
return enum_.cxx_name; return utils::remove_all(item.cxx_name, '_');
}
inline std::string typedecl_managed_name(attributes::function_def const& func)
{
return utils::remove_all(func.name, '_');
}
inline std::string enum_field_managed_name(std::string name)
{
std::vector<std::string> names = utils::split(name, '_');
return utils::to_pascal_case(names);
} }
inline std::string to_field_name(std::string const& in) inline std::string to_field_name(std::string const& in)
@ -226,41 +243,106 @@ inline std::string to_field_name(std::string const& in)
return utils::capitalize(in); return utils::capitalize(in);
} }
// Class name translation (interface/concrete/inherit/etc) inline std::string managed_part_name(attributes::part_def const& part)
template<typename T>
inline std::string klass_interface_name(T const& klass)
{ {
return "I" + klass.eolian_name; std::vector<std::string> names = utils::split(part.name, '_');
return utils::to_pascal_case(names);
} }
// Class name translation (interface/concrete/inherit/etc)
struct klass_interface_name_generator
{
template <typename T> template <typename T>
inline std::string klass_full_interface_name(T const& klass) std::string operator()(T const& klass) const
{
return utils::remove_all(klass.eolian_name, '_');
}
template <typename OutputIterator, typename Attr, typename Context>
bool generate(OutputIterator sink, Attr const& attribute, Context const& context) const
{
return as_generator((*this).operator()<Attr>(attribute)).generate(sink, attributes::unused, context);
}
} klass_interface_name;
struct klass_full_interface_name_generator
{
template <typename T>
std::string operator()(T const& klass) const
{ {
return join_namespaces(klass.namespaces, '.', managed_namespace) + klass_interface_name(klass); return join_namespaces(klass.namespaces, '.', managed_namespace) + klass_interface_name(klass);
} }
template <typename OutputIterator, typename Attr, typename Context>
bool generate(OutputIterator sink, Attr const& attribute, Context const& context) const
{
return as_generator((*this).operator()<Attr>(attribute)).generate(sink, attributes::unused, context);
}
} klass_full_interface_name;
template<typename T> template<typename T>
inline std::string klass_concrete_name(T const& klass) inline std::string klass_concrete_name(T const& klass)
{ {
return klass.eolian_name; std::string name = utils::remove_all(klass.eolian_name, '_');
if (klass.type == attributes::class_type::regular || klass.type == attributes::class_type::abstract_)
return name;
return name + "Concrete";
} }
struct klass_full_concrete_name_generator
{
template <typename T> template <typename T>
inline std::string klass_full_concrete_name(T const& klass) std::string operator()(T const& klass) const
{ {
return join_namespaces(klass.namespaces, '.', managed_namespace) + klass_concrete_name(klass); return join_namespaces(klass.namespaces, '.', managed_namespace) + klass_concrete_name(klass);
} }
template <typename OutputIterator, typename Attr, typename Context>
bool generate(OutputIterator sink, Attr const& attribute, Context const& context) const
{
return as_generator((*this).operator()<Attr>(attribute)).generate(sink, attributes::unused, context);
}
} klass_full_concrete_name;
struct klass_full_concrete_or_interface_name_generator
{
template <typename T>
std::string operator()(T const& klass) const
{
switch(klass.type)
{
case attributes::class_type::abstract_:
case attributes::class_type::regular:
return klass_full_concrete_name(klass);
}
return klass_full_interface_name(klass);
}
template <typename OutputIterator, typename Context>
bool generate(OutputIterator, attributes::unused_type, Context const&) const
{
return true;
}
template <typename OutputIterator, typename Attr, typename Context>
bool generate(OutputIterator sink, Attr const& attribute, Context const& context) const
{
return as_generator((*this).operator()<Attr>(attribute)).generate(sink, attributes::unused, context);
}
} klass_full_concrete_or_interface_name;
template<typename T> template<typename T>
inline std::string klass_inherit_name(T const& klass) inline std::string klass_inherit_name(T const& klass)
{ {
return klass.eolian_name + "Inherit"; return klass_concrete_name(klass);
} }
template<typename T> template<typename T>
inline std::string klass_native_inherit_name(T const& klass) inline std::string klass_native_inherit_name(T const& klass)
{ {
return klass.eolian_name + "NativeInherit"; return klass_concrete_name(klass) + "NativeInherit";
} }
template<typename T> template<typename T>
@ -282,17 +364,20 @@ inline std::string managed_event_name(std::string const& name)
inline std::string managed_event_args_short_name(attributes::event_def const& evt) inline std::string managed_event_args_short_name(attributes::event_def const& evt)
{ {
return name_helpers::managed_event_name(evt.name) + "_Args"; std::string ret;
ret = klass_interface_name(evt.klass);
return ret + name_helpers::managed_event_name(evt.name) + "_Args";
} }
inline std::string managed_event_args_name(attributes::event_def evt) inline std::string managed_event_args_name(attributes::event_def evt)
{ {
return klass_full_concrete_name(evt.klass) + "." + managed_event_args_short_name(evt); return join_namespaces(evt.klass.namespaces, '.', managed_namespace) +
managed_event_args_short_name(evt);
} }
inline std::string translate_inherited_event_name(const attributes::event_def &evt, const attributes::klass_def &klass) inline std::string translate_inherited_event_name(const attributes::event_def &evt, const attributes::klass_def &klass)
{ {
return join_namespaces(klass.namespaces, '_') + klass.cxx_name + "_" + managed_event_name(evt.name); return join_namespaces(klass.namespaces, '_') + klass_interface_name(klass) + "_" + managed_event_name(evt.name);
} }
// Open/close namespaces // Open/close namespaces
@ -318,4 +403,34 @@ bool close_namespaces(OutputIterator sink, std::vector<std::string> const& names
} // namespace eolian_mono } // namespace eolian_mono
namespace efl { namespace eolian { namespace grammar {
template <>
struct is_eager_generator<eolian_mono::name_helpers::klass_interface_name_generator> : std::true_type {};
template <>
struct is_generator<eolian_mono::name_helpers::klass_interface_name_generator> : std::true_type {};
template <>
struct is_eager_generator<eolian_mono::name_helpers::klass_full_interface_name_generator> : std::true_type {};
template <>
struct is_generator<eolian_mono::name_helpers::klass_full_interface_name_generator> : std::true_type {};
template <>
struct is_eager_generator<eolian_mono::name_helpers::klass_full_concrete_or_interface_name_generator> : std::true_type {};
template <>
struct is_generator<eolian_mono::name_helpers::klass_full_concrete_or_interface_name_generator> : std::true_type {};
template <>
struct is_eager_generator<eolian_mono::name_helpers::klass_full_concrete_name_generator> : std::true_type {};
template <>
struct is_generator<eolian_mono::name_helpers::klass_full_concrete_name_generator> : std::true_type {};
namespace type_traits {
template <>
struct attributes_needed<struct ::eolian_mono::name_helpers::klass_full_concrete_or_interface_name_generator> : std::integral_constant<int, 1> {};
}
} } }
#endif #endif

View File

@ -458,7 +458,7 @@ struct marshall_parameter_generator
).generate(sink, std::make_tuple(param, param_name), context); ).generate(sink, std::make_tuple(param, param_name), context);
return as_generator( return as_generator(
"IntPtr " << param_name << "_data, " << type << "Internal " << param_name << ", Eina_Free_Cb " "IntPtr " << param_name << "_data, " << type << "Internal " << param_name << ", EinaFreeCb "
<< param_name << "_free_cb" << param_name << "_free_cb"
).generate(sink, param, context); ).generate(sink, param, context);
} }
@ -527,7 +527,7 @@ struct argument_invocation_generator
else if (param.type.original_type.visit(is_fp_visitor{})) else if (param.type.original_type.visit(is_fp_visitor{}))
{ {
std::string param_name = escape_keyword(param.param_name); std::string param_name = escape_keyword(param.param_name);
return as_generator("GCHandle.ToIntPtr(" << param_name << "_handle), " << type << "Wrapper.Cb, efl.eo.Globals.free_gchandle") return as_generator("GCHandle.ToIntPtr(" << param_name << "_handle), " << type << "Wrapper.Cb, Efl.Eo.Globals.free_gchandle")
.generate(sink, param.type, context); .generate(sink, param.type, context);
} }
else else
@ -553,7 +553,7 @@ struct native_convert_in_variable_generator
if (param.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(param, regular)) if (param.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(param, regular))
{ {
return as_generator( return as_generator(
"var " << string << " = eina.PrimitiveConversion.PointerToManaged<" << type << ">(" << escape_keyword(param.param_name) << ");\n" "var " << string << " = Eina.PrimitiveConversion.PointerToManaged<" << type << ">(" << escape_keyword(param.param_name) << ");\n"
).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context); ).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context);
} }
else if (helpers::need_struct_conversion(regular)) else if (helpers::need_struct_conversion(regular))
@ -565,7 +565,7 @@ struct native_convert_in_variable_generator
else if (param.type.c_type == "Eina_Binbuf *" || param.type.c_type == "const Eina_Binbuf *") else if (param.type.c_type == "Eina_Binbuf *" || param.type.c_type == "const Eina_Binbuf *")
{ {
return as_generator( return as_generator(
"var " << string << " = new eina.Binbuf(" << escape_keyword(param.param_name) << ", " << (param.type.has_own ? "true" : "false") << ");\n" "var " << string << " = new Eina.Binbuf(" << escape_keyword(param.param_name) << ", " << (param.type.has_own ? "true" : "false") << ");\n"
).generate(sink, in_variable_name(param.param_name), context); ).generate(sink, in_variable_name(param.param_name), context);
} }
else if (param.type.c_type == "Eina_Hash *" || param.type.c_type == "const Eina_Hash *") else if (param.type.c_type == "Eina_Hash *" || param.type.c_type == "const Eina_Hash *")
@ -622,7 +622,7 @@ struct convert_in_variable_generator
if (param.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(param, regular)) if (param.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(param, regular))
{ {
return as_generator( return as_generator(
"var " << string << " = eina.PrimitiveConversion.ManagedToPointerAlloc(" << escape_keyword(param.param_name) << ");\n" "var " << string << " = Eina.PrimitiveConversion.ManagedToPointerAlloc(" << escape_keyword(param.param_name) << ");\n"
).generate(sink, in_variable_name(param.param_name), context); ).generate(sink, in_variable_name(param.param_name), context);
} }
else if (helpers::need_struct_conversion(regular)) else if (helpers::need_struct_conversion(regular))
@ -813,7 +813,7 @@ struct native_convert_out_variable_generator
) )
{ {
return as_generator( return as_generator(
"eina.Binbuf " << string << " = default(eina.Binbuf);\n" "Eina.Binbuf " << string << " = default(Eina.Binbuf);\n"
).generate(sink, out_variable_name(param.param_name), context); ).generate(sink, out_variable_name(param.param_name), context);
} }
else if (param_is_acceptable(param, "Eina_Array *", WANT_OWN, WANT_OUT) else if (param_is_acceptable(param, "Eina_Array *", WANT_OWN, WANT_OUT)
@ -886,7 +886,7 @@ struct convert_out_assign_generator
if (param.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion_in_return(param.type, param.direction)) if (param.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion_in_return(param.type, param.direction))
{ {
bool ret = as_generator( bool ret = as_generator(
string << " = eina.PrimitiveConversion.PointerToManaged<" << type << ">(" << out_variable_name(param.param_name) << ");\n" string << " = Eina.PrimitiveConversion.PointerToManaged<" << type << ">(" << out_variable_name(param.param_name) << ");\n"
).generate(sink, std::make_tuple(escape_keyword(param.param_name), param.type), context); ).generate(sink, std::make_tuple(escape_keyword(param.param_name), param.type), context);
if (param.type.has_own) if (param.type.has_own)
@ -908,7 +908,7 @@ struct convert_out_assign_generator
) )
{ {
return as_generator( return as_generator(
string << " = new eina.Binbuf(" << string << ", " << (param.type.has_own ? "true" : "false") << ");\n" string << " = new Eina.Binbuf(" << string << ", " << (param.type.has_own ? "true" : "false") << ");\n"
).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context); ).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context);
} }
else if (param_is_acceptable(param, "Eina_Hash *", WANT_OWN, WANT_OUT) else if (param_is_acceptable(param, "Eina_Hash *", WANT_OWN, WANT_OUT)
@ -1032,7 +1032,7 @@ struct convert_return_generator
if (ret_type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion_in_return(ret_type, attributes::parameter_direction::unknown)) if (ret_type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion_in_return(ret_type, attributes::parameter_direction::unknown))
{ {
return as_generator( return as_generator(
"var __ret_tmp = eina.PrimitiveConversion.PointerToManaged<" << type << ">(_ret_var);\n" "var __ret_tmp = Eina.PrimitiveConversion.PointerToManaged<" << type << ">(_ret_var);\n"
<< scope_tab << scope_tab << (ret_type.has_own ? ("Marshal.FreeHGlobal(_ret_var);\n"): "\n") << scope_tab << scope_tab << (ret_type.has_own ? ("Marshal.FreeHGlobal(_ret_var);\n"): "\n")
<< scope_tab << scope_tab << "return __ret_tmp;\n" << scope_tab << scope_tab << "return __ret_tmp;\n"
).generate(sink, ret_type, context); ).generate(sink, ret_type, context);
@ -1045,7 +1045,7 @@ struct convert_return_generator
} }
else if (ret_type.c_type == "Eina_Binbuf *" || ret_type.c_type == "const Eina_Binbuf *") else if (ret_type.c_type == "Eina_Binbuf *" || ret_type.c_type == "const Eina_Binbuf *")
{ {
if (!as_generator("var _binbuf_ret = new eina.Binbuf(_ret_var, " << std::string{ret_type.has_own ? "true" : "false"} << ");\n" if (!as_generator("var _binbuf_ret = new Eina.Binbuf(_ret_var, " << std::string{ret_type.has_own ? "true" : "false"} << ");\n"
<< scope_tab << scope_tab << "return _binbuf_ret;\n") << scope_tab << scope_tab << "return _binbuf_ret;\n")
.generate(sink, attributes::unused, context)) .generate(sink, attributes::unused, context))
return false; return false;
@ -1104,7 +1104,7 @@ struct native_convert_out_assign_generator
if (param.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion_in_return(param.type, param.direction)) if (param.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion_in_return(param.type, param.direction))
{ {
return as_generator( return as_generator(
string << " = eina.PrimitiveConversion.ManagedToPointerAlloc(" << string << ");\n" string << " = Eina.PrimitiveConversion.ManagedToPointerAlloc(" << string << ");\n"
).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context); ).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context);
} }
else if (helpers::need_struct_conversion(regular)) else if (helpers::need_struct_conversion(regular))
@ -1121,7 +1121,7 @@ struct native_convert_out_assign_generator
return false; return false;
} }
return as_generator( return as_generator(
string << "= efl.eo.Globals.cached_stringshare_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_stringshares, " << string << ");\n" string << "= Efl.Eo.Globals.cached_stringshare_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_stringshares, " << string << ");\n"
).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context); ).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context);
} }
else if (param_is_acceptable(param, "const char *", !WANT_OWN, WANT_OUT)) else if (param_is_acceptable(param, "const char *", !WANT_OWN, WANT_OUT))
@ -1132,7 +1132,7 @@ struct native_convert_out_assign_generator
return false; return false;
} }
return as_generator( return as_generator(
string << "= efl.eo.Globals.cached_string_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_strings, " << string << ");\n" string << "= Efl.Eo.Globals.cached_string_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_strings, " << string << ");\n"
).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context); ).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context);
} }
else if (param_is_acceptable(param, "Eina_Binbuf *", WANT_OWN, WANT_OUT) else if (param_is_acceptable(param, "Eina_Binbuf *", WANT_OWN, WANT_OUT)
@ -1251,7 +1251,7 @@ struct native_convert_return_generator
if (ret_type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion_in_return(ret_type, attributes::parameter_direction::unknown) ) if (ret_type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion_in_return(ret_type, attributes::parameter_direction::unknown) )
{ {
return as_generator( return as_generator(
"return eina.PrimitiveConversion.ManagedToPointerAlloc(_ret_var);\n" "return Eina.PrimitiveConversion.ManagedToPointerAlloc(_ret_var);\n"
).generate(sink, attributes::unused, context); ).generate(sink, attributes::unused, context);
} }
else if (helpers::need_struct_conversion(regular)) else if (helpers::need_struct_conversion(regular))
@ -1270,7 +1270,7 @@ struct native_convert_return_generator
return false; return false;
} }
return as_generator( return as_generator(
"return efl.eo.Globals.cached_string_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_strings, _ret_var);\n" "return Efl.Eo.Globals.cached_string_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_strings, _ret_var);\n"
).generate(sink, attributes::unused, context); ).generate(sink, attributes::unused, context);
} }
else else
@ -1288,7 +1288,7 @@ struct native_convert_return_generator
return false; return false;
} }
return as_generator( return as_generator(
"return efl.eo.Globals.cached_stringshare_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_stringshares, _ret_var);\n" "return Efl.Eo.Globals.cached_stringshare_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_stringshares, _ret_var);\n"
).generate(sink, attributes::unused, context); ).generate(sink, attributes::unused, context);
} }
else else

View File

@ -18,14 +18,13 @@ struct part_definition_generator
template <typename OutputIterator, typename Context> template <typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::part_def const& part, Context const& context) const bool generate(OutputIterator sink, attributes::part_def const& part, Context const& context) const
{ {
auto part_interface_name = name_helpers::klass_full_interface_name(part.klass); auto part_klass_name = name_helpers::klass_full_concrete_or_interface_name(part.klass);
auto part_klass_name = name_helpers::klass_full_concrete_name(part.klass);
return as_generator(scope_tab << documentation return as_generator(scope_tab << documentation
<< scope_tab << "public " << part_interface_name << " " << utils::capitalize(part.name) << "\n" << scope_tab << "public " << part_klass_name << " " << name_helpers::managed_part_name(part) << "\n"
<< scope_tab << "{\n" << scope_tab << "{\n"
<< scope_tab << scope_tab << "get\n" << scope_tab << scope_tab << "get\n"
<< scope_tab << scope_tab << "{\n" << scope_tab << scope_tab << "{\n"
<< scope_tab << scope_tab << scope_tab << "efl.IObject obj = efl_part_get(raw_handle, \"" << part.name << "\");\n" << scope_tab << scope_tab << scope_tab << "Efl.Object obj = efl_part_get(NativeHandle, \"" << part.name << "\");\n"
<< scope_tab << scope_tab << scope_tab << "return " << part_klass_name << ".static_cast(obj);\n" << scope_tab << scope_tab << scope_tab << "return " << part_klass_name << ".static_cast(obj);\n"
<< scope_tab << scope_tab << "}\n" << scope_tab << scope_tab << "}\n"
<< scope_tab << "}\n" << scope_tab << "}\n"

View File

@ -18,12 +18,12 @@ namespace eolian_mono {
inline std::string binding_struct_name(attributes::struct_def const& struct_) inline std::string binding_struct_name(attributes::struct_def const& struct_)
{ {
return struct_.cxx_name; return name_helpers::typedecl_managed_name(struct_);
} }
inline std::string binding_struct_internal_name(attributes::struct_def const& struct_) inline std::string binding_struct_internal_name(attributes::struct_def const& struct_)
{ {
return struct_.cxx_name + "_StructInternal"; return binding_struct_name(struct_) + "_StructInternal";
} }
struct struct_definition_generator struct struct_definition_generator
@ -175,7 +175,7 @@ struct to_internal_field_convert_generator
if (klass) if (klass)
{ {
if (!as_generator( if (!as_generator(
scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ".raw_handle;\n") scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ".NativeHandle;\n")
.generate(sink, std::make_tuple(field_name, field_name), context)) .generate(sink, std::make_tuple(field_name, field_name), context))
return false; return false;
} }
@ -196,7 +196,7 @@ struct to_internal_field_convert_generator
else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular)) else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular))
{ {
if (!as_generator( if (!as_generator(
scope_tab << scope_tab << "_internal_struct." << string << " = eina.PrimitiveConversion.ManagedToPointerAlloc(_external_struct." << string << ");\n") scope_tab << scope_tab << "_internal_struct." << string << " = Eina.PrimitiveConversion.ManagedToPointerAlloc(_external_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field_name), context)) .generate(sink, std::make_tuple(field_name, field_name), context))
return false; return false;
} }
@ -210,14 +210,14 @@ struct to_internal_field_convert_generator
else if (regular && (regular->base_type == "string" || regular->base_type == "mstring")) else if (regular && (regular->base_type == "string" || regular->base_type == "mstring"))
{ {
if (!as_generator( if (!as_generator(
scope_tab << scope_tab << "_internal_struct." << string << " = eina.MemoryNative.StrDup(_external_struct." << string << ");\n") scope_tab << scope_tab << "_internal_struct." << string << " = Eina.MemoryNative.StrDup(_external_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field_name), context)) .generate(sink, std::make_tuple(field_name, field_name), context))
return false; return false;
} }
else if (regular && regular->base_type == "stringshare") else if (regular && regular->base_type == "stringshare")
{ {
if (!as_generator( if (!as_generator(
scope_tab << scope_tab << "_internal_struct." << string << " = eina.Stringshare.eina_stringshare_add(_external_struct." << string << ");\n") scope_tab << scope_tab << "_internal_struct." << string << " = Eina.Stringshare.eina_stringshare_add(_external_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field_name), context)) .generate(sink, std::make_tuple(field_name, field_name), context))
return false; return false;
} }
@ -273,9 +273,9 @@ struct to_external_field_convert_generator
if (!as_generator( if (!as_generator(
"\n" "\n"
<< scope_tab << scope_tab << "_external_struct." << string << scope_tab << scope_tab << "_external_struct." << string
<< " = (" << interface_name << ") System.Activator.CreateInstance(typeof(" << " = (" << concrete_name << ") System.Activator.CreateInstance(typeof("
<< concrete_name << "), new System.Object[] {_internal_struct." << string << "});\n" << concrete_name << "), new System.Object[] {_internal_struct." << string << "});\n"
<< scope_tab << scope_tab << "efl.eo.Globals.efl_ref(_internal_struct." << string << ");\n\n") << scope_tab << scope_tab << "Efl.Eo.Globals.efl_ref(_internal_struct." << string << ");\n\n")
.generate(sink, std::make_tuple(field_name, field_name, field_name), context)) .generate(sink, std::make_tuple(field_name, field_name, field_name), context))
return false; return false;
} }
@ -308,7 +308,7 @@ struct to_external_field_convert_generator
else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular)) else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular))
{ {
if (!as_generator( if (!as_generator(
scope_tab << scope_tab << "_external_struct." << string << " = eina.PrimitiveConversion.PointerToManaged<" << type << ">(_internal_struct." << string << ");\n") scope_tab << scope_tab << "_external_struct." << string << " = Eina.PrimitiveConversion.PointerToManaged<" << type << ">(_internal_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field.type, field_name), context)) .generate(sink, std::make_tuple(field_name, field.type, field_name), context))
return false; return false;
} }
@ -322,7 +322,7 @@ struct to_external_field_convert_generator
else if (regular && (regular->base_type == "string" || regular->base_type == "mstring" || regular->base_type == "stringshare")) else if (regular && (regular->base_type == "string" || regular->base_type == "mstring" || regular->base_type == "stringshare"))
{ {
if (!as_generator( if (!as_generator(
scope_tab << scope_tab << "_external_struct." << string << " = eina.StringConversion.NativeUtf8ToManagedString(_internal_struct." << string << ");\n") scope_tab << scope_tab << "_external_struct." << string << " = Eina.StringConversion.NativeUtf8ToManagedString(_internal_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field_name), context)) .generate(sink, std::make_tuple(field_name, field_name), context))
return false; return false;
} }
@ -339,14 +339,14 @@ struct to_external_field_convert_generator
else if (field.type.c_type == "Eina_Value" || field.type.c_type == "const Eina_Value") else if (field.type.c_type == "Eina_Value" || field.type.c_type == "const Eina_Value")
{ {
if (!as_generator( if (!as_generator(
scope_tab << scope_tab << "_external_struct." << string << " = new eina.Value(_internal_struct." << string << ");\n" scope_tab << scope_tab << "_external_struct." << string << " = new Eina.Value(_internal_struct." << string << ");\n"
).generate(sink, std::make_tuple(field_name, field_name), context)) ).generate(sink, std::make_tuple(field_name, field_name), context))
return false; return false;
} }
else if (field.type.c_type == "Eina_Value *" || field.type.c_type == "const Eina_Value *") else if (field.type.c_type == "Eina_Value *" || field.type.c_type == "const Eina_Value *")
{ {
if (!as_generator( if (!as_generator(
scope_tab << scope_tab << "_external_struct." << string << " = new eina.Value(_internal_struct." << string << ", eina.Ownership.Unmanaged);\n" scope_tab << scope_tab << "_external_struct." << string << " = new Eina.Value(_internal_struct." << string << ", Eina.Ownership.Unmanaged);\n"
).generate(sink, std::make_tuple(field_name, field_name), context)) ).generate(sink, std::make_tuple(field_name, field_name), context))
return false; return false;
} }
@ -369,8 +369,8 @@ struct struct_binding_conversion_functions_generator
// Open conversion class // Open conversion class
if (!as_generator if (!as_generator
( (
"/// <summary>Conversion class for struct " << struct_.cxx_name << "</summary>\n" "/// <summary>Conversion class for struct " << name_helpers::typedecl_managed_name(struct_) << "</summary>\n"
"public static class " << struct_.cxx_name << "_StructConversion\n{\n" "public static class " << name_helpers::typedecl_managed_name(struct_) << "_StructConversion\n{\n"
) )
.generate(sink, nullptr, context)) .generate(sink, nullptr, context))
return false; return false;

View File

@ -117,7 +117,7 @@ struct visitor_generate
}} }}
, {"Eina.Error", nullptr, [&] // Eina.Error , {"Eina.Error", nullptr, [&] // Eina.Error
{ {
return regular_type_def{" eina.Error", regular.base_qualifier, {}}; return regular_type_def{" Eina.Error", regular.base_qualifier, {}};
}} // TODO }} // TODO
, {"string", nullptr, [&] , {"string", nullptr, [&]
{ {
@ -139,16 +139,16 @@ struct visitor_generate
}} }}
, {"strbuf", nullptr, [&] , {"strbuf", nullptr, [&]
{ {
return regular_type_def{" eina.Strbuf", regular.base_qualifier, {}}; return regular_type_def{" Eina.Strbuf", regular.base_qualifier, {}};
}} }}
, {"any_value", true, [&] , {"any_value", true, [&]
{ return regular_type_def{" eina.Value", regular.base_qualifier, {}}; { return regular_type_def{" Eina.Value", regular.base_qualifier, {}};
}} }}
, {"any_value", false, [&] , {"any_value", false, [&]
{ return regular_type_def{" eina.Value", regular.base_qualifier, {}}; { return regular_type_def{" Eina.Value", regular.base_qualifier, {}};
}} }}
, {"any_value_ptr", nullptr, [&] , {"any_value_ptr", nullptr, [&]
{ return regular_type_def{" eina.Value", regular.base_qualifier, {}}; { return regular_type_def{" Eina.Value", regular.base_qualifier, {}};
}} // FIXME add proper support for any_value_ptr }} // FIXME add proper support for any_value_ptr
}; };
std::string full_type_name = name_helpers::type_full_eolian_name(regular); std::string full_type_name = name_helpers::type_full_eolian_name(regular);
@ -237,6 +237,9 @@ struct visitor_generate
} }
bool operator()(attributes::klass_name klass) const bool operator()(attributes::klass_name klass) const
{ {
if(klass.type == attributes::class_type::regular || klass.type == attributes::class_type::abstract_)
return as_generator(string).generate(sink, name_helpers::klass_full_concrete_name(klass), *context);
else
return as_generator(string).generate(sink, name_helpers::klass_full_interface_name(klass), *context); return as_generator(string).generate(sink, name_helpers::klass_full_interface_name(klass), *context);
} }
bool operator()(attributes::complex_type_def const& complex) const bool operator()(attributes::complex_type_def const& complex) const
@ -255,51 +258,51 @@ struct visitor_generate
{"list", nullptr, nullptr, [&] {"list", nullptr, nullptr, [&]
{ {
complex_type_def c = complex; complex_type_def c = complex;
c.outer.base_type = "eina.List"; c.outer.base_type = "Eina.List";
return c; return c;
}} }}
, {"inlist", nullptr, nullptr, [&] , {"inlist", nullptr, nullptr, [&]
{ {
complex_type_def c = complex; complex_type_def c = complex;
c.outer.base_type = "eina.Inlist"; c.outer.base_type = "Eina.Inlist";
return c; return c;
}} }}
, {"array", nullptr, nullptr, [&] , {"array", nullptr, nullptr, [&]
{ {
complex_type_def c = complex; complex_type_def c = complex;
c.outer.base_type = "eina.Array"; c.outer.base_type = "Eina.Array";
return c; return c;
}} }}
, {"inarray", nullptr, nullptr, [&] , {"inarray", nullptr, nullptr, [&]
{ {
complex_type_def c = complex; complex_type_def c = complex;
c.outer.base_type = "eina.Inarray"; c.outer.base_type = "Eina.Inarray";
return c; return c;
}} }}
, {"hash", nullptr, nullptr , {"hash", nullptr, nullptr
, [&] , [&]
{ {
complex_type_def c = complex; complex_type_def c = complex;
c.outer.base_type = "eina.Hash"; c.outer.base_type = "Eina.Hash";
return c; return c;
}} }}
, {"future", nullptr, nullptr, [&] , {"future", nullptr, nullptr, [&]
{ {
(*this)(regular_type_def{" eina.Future", complex.outer.base_qualifier, {}}); (*this)(regular_type_def{" Eina.Future", complex.outer.base_qualifier, {}});
return attributes::type_def::variant_type(); return attributes::type_def::variant_type();
} }
} }
, {"iterator", nullptr, nullptr, [&] , {"iterator", nullptr, nullptr, [&]
{ {
complex_type_def c = complex; complex_type_def c = complex;
c.outer.base_type = "eina.Iterator"; c.outer.base_type = "Eina.Iterator";
return c; return c;
} }
} }
, {"accessor", nullptr, nullptr, [&] , {"accessor", nullptr, nullptr, [&]
{ {
complex_type_def c = complex; complex_type_def c = complex;
c.outer.base_type = "eina.Accessor"; c.outer.base_type = "Eina.Accessor";
return c; return c;
} }
} }

View File

@ -11,18 +11,19 @@
namespace eolian_mono { namespace eolian_mono {
namespace grammar = efl::eolian::grammar; namespace grammar = efl::eolian::grammar;
using efl::eolian::grammar::as_generator; using grammar::as_generator;
using efl::eolian::grammar::string; using grammar::string;
using efl::eolian::grammar::html_escaped_string; using grammar::html_escaped_string;
using efl::eolian::grammar::operator<<; using grammar::operator<<;
using efl::eolian::grammar::operator%; using grammar::operator%;
using efl::eolian::grammar::operator*; using grammar::operator*;
using efl::eolian::grammar::scope_tab; using grammar::scope_tab;
using efl::eolian::grammar::lower_case; using grammar::lower_case;
using efl::eolian::grammar::upper_case; using grammar::upper_case;
using efl::eolian::grammar::lit; using grammar::lit;
using efl::eolian::grammar::qualifier_info; using grammar::qualifier_info;
using efl::eolian::grammar::context_find_tag; using grammar::context_find_tag;
using grammar::attribute_conditional;
} }

View File

@ -2,6 +2,7 @@
#define EOLIAN_MONO_UTILS_HPP #define EOLIAN_MONO_UTILS_HPP
#include <string> #include <string>
#include <vector>
#include <sstream> #include <sstream>
#include <iterator> #include <iterator>
#include <algorithm> #include <algorithm>
@ -63,6 +64,12 @@ namespace eolian_mono { namespace utils {
return ret; return ret;
} }
inline std::string remove_all(std::string name, char target)
{
name.erase(std::remove(name.begin(), name.end(), target), name.end());
return name;
}
} } } }
#endif #endif

View File

@ -128,7 +128,10 @@ run(options_type const& opts)
if (!as_generator("#pragma warning disable CS1591\n").generate(iterator, efl::eolian::grammar::attributes::unused, efl::eolian::grammar::context_null())) if (!as_generator("#pragma warning disable CS1591\n").generate(iterator, efl::eolian::grammar::attributes::unused, efl::eolian::grammar::context_null()))
throw std::runtime_error("Failed to generate pragma to disable missing docs"); throw std::runtime_error("Failed to generate pragma to disable missing docs");
if (!as_generator("using System;\nusing System.Runtime.InteropServices;\nusing System.Collections.Generic;\n") if (!as_generator("using System;\n"
"using System.Runtime.InteropServices;\n"
"using System.Collections.Generic;\n"
"using System.ComponentModel;\n")
.generate(iterator, efl::eolian::grammar::attributes::unused, efl::eolian::grammar::context_null())) .generate(iterator, efl::eolian::grammar::attributes::unused, efl::eolian::grammar::context_null()))
{ {
throw std::runtime_error("Failed to generate file preamble"); throw std::runtime_error("Failed to generate file preamble");

View File

@ -29,9 +29,9 @@ public class EcoreEvas
ecore_evas_show(handle); ecore_evas_show(handle);
} }
public efl.canvas.IObject canvas public Efl.Canvas.Object canvas
{ {
get { return new efl.canvas.Object(ecore_evas_get(handle)); } get { return new Efl.Canvas.Object(ecore_evas_get(handle)); }
} }
} }

View File

@ -4,9 +4,9 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using static efl.UnsafeNativeMethods; using static Efl.UnsafeNativeMethods;
namespace efl { namespace Efl {
static class UnsafeNativeMethods { static class UnsafeNativeMethods {
[DllImport(efl.Libs.Ecore)] public static extern void ecore_init(); [DllImport(efl.Libs.Ecore)] public static extern void ecore_init();
@ -28,15 +28,15 @@ public enum Components {
public static class All { public static class All {
private static bool InitializedUi = false; private static bool InitializedUi = false;
public static void Init(efl.Components components=Components.Basic) { public static void Init(Efl.Components components=Components.Basic) {
eina.Config.Init(); Eina.Config.Init();
efl.eo.Config.Init(); Efl.Eo.Config.Init();
ecore_init(); ecore_init();
evas_init(); evas_init();
eldbus.Config.Init(); eldbus.Config.Init();
if (components == Components.Ui) { if (components == Components.Ui) {
efl.ui.Config.Init(); Efl.Ui.Config.Init();
InitializedUi = true; InitializedUi = true;
} }
} }
@ -48,17 +48,17 @@ public static class All {
System.GC.WaitForPendingFinalizers(); System.GC.WaitForPendingFinalizers();
if (InitializedUi) if (InitializedUi)
efl.ui.Config.Shutdown(); Efl.Ui.Config.Shutdown();
eldbus.Config.Shutdown(); eldbus.Config.Shutdown();
evas_shutdown(); evas_shutdown();
ecore_shutdown(); ecore_shutdown();
efl.eo.Config.Shutdown(); Efl.Eo.Config.Shutdown();
eina.Config.Shutdown(); Eina.Config.Shutdown();
} }
} }
// Placeholder. Will move to elm_config.cs later // Placeholder. Will move to elm_config.cs later
namespace ui { namespace Ui {
public static class Config { public static class Config {
public static void Init() { public static void Init() {
@ -70,7 +70,7 @@ public static class Config {
#endif #endif
elm_init(0, IntPtr.Zero); elm_init(0, IntPtr.Zero);
elm_policy_set((int)elm.Policy.Quit, (int)elm.Policy_Quit.Last_window_hidden); elm_policy_set((int)Elm.Policy.Quit, (int)Elm.PolicyQuit.LastWindowHidden);
} }
public static void Shutdown() { public static void Shutdown() {
elm_shutdown(); elm_shutdown();

View File

@ -3,11 +3,11 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using static eina.TraitFunctions; using static Eina.TraitFunctions;
using static eina.AccessorNativeFunctions; using static Eina.AccessorNativeFunctions;
namespace eina { namespace Eina {
internal class AccessorNativeFunctions internal class AccessorNativeFunctions
{ {

View File

@ -4,10 +4,10 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Collections.Generic; using System.Collections.Generic;
using static eina.TraitFunctions; using static Eina.TraitFunctions;
using static eina.ArrayNativeFunctions; using static Eina.ArrayNativeFunctions;
namespace eina { namespace Eina {
public static class ArrayNativeFunctions public static class ArrayNativeFunctions
{ {
@ -272,9 +272,9 @@ public class Array<T> : IEnumerable<T>, IDisposable
} }
public eina.Iterator<T> GetIterator() public Eina.Iterator<T> GetIterator()
{ {
return new eina.Iterator<T>(eina_array_iterator_new(Handle), true, false); return new Eina.Iterator<T>(eina_array_iterator_new(Handle), true, false);
} }
public IEnumerator<T> GetEnumerator() public IEnumerator<T> GetEnumerator()
@ -292,9 +292,9 @@ public class Array<T> : IEnumerable<T>, IDisposable
} }
/// <summary> Gets an Accessor for this Array.</summary> /// <summary> Gets an Accessor for this Array.</summary>
public eina.Accessor<T> GetAccessor() public Eina.Accessor<T> GetAccessor()
{ {
return new eina.Accessor<T>(eina_array_accessor_new(Handle), Ownership.Managed); return new Eina.Accessor<T>(eina_array_accessor_new(Handle), Ownership.Managed);
} }
} }

View File

@ -3,7 +3,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace eina { namespace Eina {
public class Binbuf : IDisposable public class Binbuf : IDisposable
{ {
@ -16,7 +16,7 @@ public class Binbuf : IDisposable
[DllImport(efl.Libs.Eina)] public static extern byte [DllImport(efl.Libs.Eina)] public static extern byte
eina_binbuf_append_length(IntPtr buf, byte[] str, UIntPtr length); eina_binbuf_append_length(IntPtr buf, byte[] str, UIntPtr length);
[DllImport(efl.Libs.Eina)] public static extern byte [DllImport(efl.Libs.Eina)] public static extern byte
eina_binbuf_append_slice(IntPtr buf, eina.Slice slice); eina_binbuf_append_slice(IntPtr buf, Eina.Slice slice);
[DllImport(efl.Libs.Eina)] public static extern byte [DllImport(efl.Libs.Eina)] public static extern byte
eina_binbuf_append_buffer(IntPtr buf, IntPtr data); eina_binbuf_append_buffer(IntPtr buf, IntPtr data);
[DllImport(efl.Libs.Eina)] public static extern byte [DllImport(efl.Libs.Eina)] public static extern byte
@ -24,7 +24,7 @@ public class Binbuf : IDisposable
[DllImport(efl.Libs.Eina)] public static extern byte [DllImport(efl.Libs.Eina)] public static extern byte
eina_binbuf_insert_length(IntPtr buf, byte[] str, UIntPtr length, UIntPtr pos); eina_binbuf_insert_length(IntPtr buf, byte[] str, UIntPtr length, UIntPtr pos);
[DllImport(efl.Libs.Eina)] public static extern byte [DllImport(efl.Libs.Eina)] public static extern byte
eina_binbuf_insert_slice(IntPtr buf, eina.Slice slice, UIntPtr pos); eina_binbuf_insert_slice(IntPtr buf, Eina.Slice slice, UIntPtr pos);
[DllImport(efl.Libs.Eina)] public static extern byte [DllImport(efl.Libs.Eina)] public static extern byte
eina_binbuf_insert_char(IntPtr buf, byte c, UIntPtr pos); eina_binbuf_insert_char(IntPtr buf, byte c, UIntPtr pos);
[DllImport(efl.Libs.Eina)] public static extern byte [DllImport(efl.Libs.Eina)] public static extern byte
@ -35,7 +35,7 @@ public class Binbuf : IDisposable
eina_binbuf_string_free(IntPtr buf); eina_binbuf_string_free(IntPtr buf);
[DllImport(efl.Libs.Eina)] public static extern UIntPtr [DllImport(efl.Libs.Eina)] public static extern UIntPtr
eina_binbuf_length_get(IntPtr buf); eina_binbuf_length_get(IntPtr buf);
[DllImport(efl.Libs.Eina)] public static extern eina.Slice [DllImport(efl.Libs.Eina)] public static extern Eina.Slice
eina_binbuf_slice_get(IntPtr buf); eina_binbuf_slice_get(IntPtr buf);
public IntPtr Handle {get;set;} = IntPtr.Zero; public IntPtr Handle {get;set;} = IntPtr.Zero;
@ -146,7 +146,7 @@ public class Binbuf : IDisposable
return 0 != eina_binbuf_append_char(Handle, c); return 0 != eina_binbuf_append_char(Handle, c);
} }
public bool Append(eina.Slice slice) public bool Append(Eina.Slice slice)
{ {
return 0 != eina_binbuf_append_slice(Handle, slice); return 0 != eina_binbuf_append_slice(Handle, slice);
} }
@ -166,7 +166,7 @@ public class Binbuf : IDisposable
return 0 != eina_binbuf_insert_char(Handle, c, (UIntPtr)pos); return 0 != eina_binbuf_insert_char(Handle, c, (UIntPtr)pos);
} }
public bool Insert(eina.Slice slice, uint pos) public bool Insert(Eina.Slice slice, uint pos)
{ {
return 0 != eina_binbuf_insert_slice(Handle, slice, (UIntPtr)pos); return 0 != eina_binbuf_insert_slice(Handle, slice, (UIntPtr)pos);
} }
@ -203,7 +203,7 @@ public class Binbuf : IDisposable
return eina_binbuf_length_get(Handle); return eina_binbuf_length_get(Handle);
} }
eina.Slice GetSlice() Eina.Slice GetSlice()
{ {
return eina_binbuf_slice_get(Handle); return eina_binbuf_slice_get(Handle);
} }

View File

@ -4,13 +4,13 @@ using System;
using System.Text; using System.Text;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace eina namespace Eina
{ {
namespace Callbacks namespace Callbacks
{ {
public delegate int Eina_Compare_Cb(IntPtr data1, IntPtr data2); public delegate int EinaCompareCb(IntPtr data1, IntPtr data2);
public delegate void Eina_Free_Cb(IntPtr data); public delegate void EinaFreeCb(IntPtr data);
} }
@ -107,11 +107,11 @@ public static class PrimitiveConversion
{ {
if (nat == IntPtr.Zero) if (nat == IntPtr.Zero)
{ {
eina.Log.Error("Null pointer for primitive type."); Eina.Log.Error("Null pointer for primitive type.");
return default(T); return default(T);
} }
var w = Marshal.PtrToStructure<eina.ConvertWrapper<T> >(nat); var w = Marshal.PtrToStructure<Eina.ConvertWrapper<T> >(nat);
return w.val; return w.val;
} }

View File

@ -3,7 +3,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace eina { namespace Eina {
public class Config { public class Config {
[DllImport(efl.Libs.Eina)] private static extern int eina_init(); [DllImport(efl.Libs.Eina)] private static extern int eina_init();
@ -11,11 +11,11 @@ public class Config {
public static void Init() { public static void Init() {
if (eina_init() == 0) if (eina_init() == 0)
throw (new efl.EflException("Failed to initialize Eina")); throw (new Efl.EflException("Failed to initialize Eina"));
// Initialize the submodules here // Initialize the submodules here
eina.Log.Init(); Eina.Log.Init();
eina.Error.Init(); Eina.Error.Init();
} }
public static int Shutdown() { public static int Shutdown() {

View File

@ -5,14 +5,14 @@ using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Collections.Generic; using System.Collections.Generic;
using eina.Callbacks; using Eina.Callbacks;
using static eina.HashNativeFunctions; using static Eina.HashNativeFunctions;
using static eina.InarrayNativeFunctions; using static Eina.InarrayNativeFunctions;
using static eina.InlistNativeFunctions; using static Eina.InlistNativeFunctions;
using static eina.NativeCustomExportFunctions; using static Eina.NativeCustomExportFunctions;
using static eina.ContainerCommonData; using static Eina.ContainerCommonData;
namespace eina { namespace Eina {
public enum ElementType { NumericType, StringType, ObjectType }; public enum ElementType { NumericType, StringType, ObjectType };
@ -150,7 +150,7 @@ public class StringElementTraits<T> : IBaseElementTraits<T>
{ {
if (nat == IntPtr.Zero) if (nat == IntPtr.Zero)
{ {
eina.Log.Error("Null pointer for Inlist node."); Eina.Log.Error("Null pointer for Inlist node.");
return default(T); return default(T);
} }
var w = Marshal.PtrToStructure< InlistNode<IntPtr> >(nat); var w = Marshal.PtrToStructure< InlistNode<IntPtr> >(nat);
@ -204,15 +204,15 @@ public class EflObjectElementTraits<T> : IBaseElementTraits<T>
public IntPtr ManagedToNativeAlloc(T man) public IntPtr ManagedToNativeAlloc(T man)
{ {
IntPtr h = ((efl.eo.IWrapper)man).raw_handle; IntPtr h = ((Efl.Eo.IWrapper)man).NativeHandle;
if (h == IntPtr.Zero) if (h == IntPtr.Zero)
return h; return h;
return efl.eo.Globals.efl_ref(h); return Efl.Eo.Globals.efl_ref(h);
} }
public IntPtr ManagedToNativeAllocRef(T man, bool refs) public IntPtr ManagedToNativeAllocRef(T man, bool refs)
{ {
IntPtr h = refs ? ManagedToNativeAlloc(man) : ((efl.eo.IWrapper)man).raw_handle; IntPtr h = refs ? ManagedToNativeAlloc(man) : ((Efl.Eo.IWrapper)man).NativeHandle;
return intPtrTraits.ManagedToNativeAlloc(h); return intPtrTraits.ManagedToNativeAlloc(h);
} }
@ -235,7 +235,7 @@ public class EflObjectElementTraits<T> : IBaseElementTraits<T>
public void NativeFree(IntPtr nat) public void NativeFree(IntPtr nat)
{ {
if (nat != IntPtr.Zero) if (nat != IntPtr.Zero)
efl.eo.Globals.efl_unref(nat); Efl.Eo.Globals.efl_unref(nat);
} }
public void NativeFreeRef(IntPtr nat, bool unrefs) public void NativeFreeRef(IntPtr nat, bool unrefs)
@ -276,7 +276,7 @@ public class EflObjectElementTraits<T> : IBaseElementTraits<T>
{ {
if (nat == IntPtr.Zero) if (nat == IntPtr.Zero)
return default(T); return default(T);
return (T) Activator.CreateInstance(concreteType, efl.eo.Globals.efl_ref(nat)); return (T) Activator.CreateInstance(concreteType, Efl.Eo.Globals.efl_ref(nat));
} }
public T NativeToManagedRef(IntPtr nat) public T NativeToManagedRef(IntPtr nat)
@ -290,7 +290,7 @@ public class EflObjectElementTraits<T> : IBaseElementTraits<T>
{ {
if (nat == IntPtr.Zero) if (nat == IntPtr.Zero)
{ {
eina.Log.Error("Null pointer for Inlist node."); Eina.Log.Error("Null pointer for Inlist node.");
return default(T); return default(T);
} }
var w = Marshal.PtrToStructure< InlistNode<IntPtr> >(nat); var w = Marshal.PtrToStructure< InlistNode<IntPtr> >(nat);
@ -384,7 +384,7 @@ public abstract class PrimitiveElementTraits<T>
{ {
if (nat == IntPtr.Zero) if (nat == IntPtr.Zero)
{ {
eina.Log.Error("Null pointer on primitive/struct container."); Eina.Log.Error("Null pointer on primitive/struct container.");
return default(T); return default(T);
} }
return PrimitiveConversion.PointerToManaged<T>(nat); return PrimitiveConversion.PointerToManaged<T>(nat);
@ -399,7 +399,7 @@ public abstract class PrimitiveElementTraits<T>
{ {
if (nat == IntPtr.Zero) if (nat == IntPtr.Zero)
{ {
eina.Log.Error("Null pointer for Inlist node."); Eina.Log.Error("Null pointer for Inlist node.");
return default(T); return default(T);
} }
var w = Marshal.PtrToStructure< InlistNode<T> >(nat); var w = Marshal.PtrToStructure< InlistNode<T> >(nat);
@ -503,7 +503,7 @@ public static class TraitFunctions
{ {
public static bool IsEflObject(System.Type type) public static bool IsEflObject(System.Type type)
{ {
return typeof(efl.eo.IWrapper).IsAssignableFrom(type); return typeof(Efl.Eo.IWrapper).IsAssignableFrom(type);
} }
public static bool IsString(System.Type type) public static bool IsString(System.Type type)
@ -511,7 +511,7 @@ public static class TraitFunctions
return type == typeof(string); return type == typeof(string);
} }
public static eina.ElementType GetElementTypeCode(System.Type type) public static Eina.ElementType GetElementTypeCode(System.Type type)
{ {
if (IsEflObject(type)) if (IsEflObject(type))
return ElementType.ObjectType; return ElementType.ObjectType;

View File

@ -3,7 +3,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace eina { namespace Eina {
public struct Error : IComparable<Error> public struct Error : IComparable<Error>
{ {
@ -36,7 +36,7 @@ public struct Error : IComparable<Error>
} }
public override string ToString() public override string ToString()
{ {
return "eina.Error(" + code + ")"; return "Eina.Error(" + code + ")";
} }
internal static void Init() internal static void Init()
@ -62,7 +62,7 @@ public struct Error : IComparable<Error>
public static String MsgGet(Error error) public static String MsgGet(Error error)
{ {
IntPtr cstr = eina_error_msg_get(error); IntPtr cstr = eina_error_msg_get(error);
return eina.StringConversion.NativeUtf8ToManagedString(cstr); return Eina.StringConversion.NativeUtf8ToManagedString(cstr);
} }
public static void RaiseIfOccurred() public static void RaiseIfOccurred()
@ -75,7 +75,7 @@ public struct Error : IComparable<Error>
public static void Raise(Error e) public static void Raise(Error e)
{ {
if (e != 0) if (e != 0)
throw (new efl.EflException(MsgGet(e))); throw (new Efl.EflException(MsgGet(e)));
} }
public static void Clear() public static void Clear()

View File

@ -4,12 +4,12 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Collections.Generic; using System.Collections.Generic;
using static eina.TraitFunctions; using static Eina.TraitFunctions;
using static eina.IteratorNativeFunctions; using static Eina.IteratorNativeFunctions;
using static eina.HashNativeFunctions; using static Eina.HashNativeFunctions;
using eina.Callbacks; using Eina.Callbacks;
namespace eina namespace Eina
{ {
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
@ -365,14 +365,14 @@ public class Hash<TKey, TValue> : IEnumerable<KeyValuePair<TKey,TValue>>, IDi
return eina_hash_population(Handle); return eina_hash_population(Handle);
} }
public eina.Iterator<TKey> Keys() public Eina.Iterator<TKey> Keys()
{ {
return new eina.Iterator<TKey>(EinaHashIteratorKeyNew<TKey>(Handle), true, false); return new Eina.Iterator<TKey>(EinaHashIteratorKeyNew<TKey>(Handle), true, false);
} }
public eina.Iterator<TValue> Values() public Eina.Iterator<TValue> Values()
{ {
return new eina.Iterator<TValue>(eina_hash_iterator_data_new(Handle), true, false); return new Eina.Iterator<TValue>(eina_hash_iterator_data_new(Handle), true, false);
} }
public IEnumerator<KeyValuePair<TKey,TValue>> GetEnumerator() public IEnumerator<KeyValuePair<TKey,TValue>> GetEnumerator()
@ -382,7 +382,7 @@ public class Hash<TKey, TValue> : IEnumerable<KeyValuePair<TKey,TValue>>, IDi
{ {
for (IntPtr tuplePtr; eina_iterator_next(itr, out tuplePtr);) for (IntPtr tuplePtr; eina_iterator_next(itr, out tuplePtr);)
{ {
var tuple = Marshal.PtrToStructure<eina.HashTupleNative>(tuplePtr); var tuple = Marshal.PtrToStructure<Eina.HashTupleNative>(tuplePtr);
var key = NativeToManagedRef<TKey>(tuple.key); var key = NativeToManagedRef<TKey>(tuple.key);
var val = NativeToManaged<TValue>(tuple.data); var val = NativeToManaged<TValue>(tuple.data);
yield return new KeyValuePair<TKey, TValue>(key, val); yield return new KeyValuePair<TKey, TValue>(key, val);

View File

@ -4,10 +4,10 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Collections.Generic; using System.Collections.Generic;
using static eina.TraitFunctions; using static Eina.TraitFunctions;
using static eina.InarrayNativeFunctions; using static Eina.InarrayNativeFunctions;
namespace eina { namespace Eina {
public static class InarrayNativeFunctions public static class InarrayNativeFunctions
{ {
@ -298,14 +298,14 @@ public class Inarray<T> : IEnumerable<T>, IDisposable
return true; return true;
} }
public eina.Iterator<T> GetIterator() public Eina.Iterator<T> GetIterator()
{ {
return new eina.Iterator<T>(eina_inarray_iterator_new(Handle), true, false); return new Eina.Iterator<T>(eina_inarray_iterator_new(Handle), true, false);
} }
public eina.Iterator<T> GetReversedIterator() public Eina.Iterator<T> GetReversedIterator()
{ {
return new eina.Iterator<T>(eina_inarray_iterator_reversed_new(Handle), true, false); return new Eina.Iterator<T>(eina_inarray_iterator_reversed_new(Handle), true, false);
} }
public IEnumerator<T> GetEnumerator() public IEnumerator<T> GetEnumerator()
@ -323,9 +323,9 @@ public class Inarray<T> : IEnumerable<T>, IDisposable
} }
/// <summary> Gets an Accessor for this Array.</summary> /// <summary> Gets an Accessor for this Array.</summary>
public eina.Accessor<T> GetAccessor() public Eina.Accessor<T> GetAccessor()
{ {
return new eina.AccessorInArray<T>(eina_inarray_accessor_new(Handle), Ownership.Managed); return new Eina.AccessorInArray<T>(eina_inarray_accessor_new(Handle), Ownership.Managed);
} }
} }

View File

@ -4,11 +4,11 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Collections.Generic; using System.Collections.Generic;
using static eina.TraitFunctions; using static Eina.TraitFunctions;
using static eina.InlistNativeFunctions; using static Eina.InlistNativeFunctions;
using eina.Callbacks; using Eina.Callbacks;
namespace eina { namespace Eina {
public static class InlistNativeFunctions public static class InlistNativeFunctions
{ {
@ -296,9 +296,9 @@ public class Inlist<T> : IEnumerable<T>, IDisposable
} }
public eina.Iterator<T> GetIterator() public Eina.Iterator<T> GetIterator()
{ {
return new eina.Iterator<T>(eina_inlist_iterator_wrapper_new_custom_export_mono(Handle), true, false); return new Eina.Iterator<T>(eina_inlist_iterator_wrapper_new_custom_export_mono(Handle), true, false);
} }
public IEnumerator<T> GetEnumerator() public IEnumerator<T> GetEnumerator()
@ -315,9 +315,9 @@ public class Inlist<T> : IEnumerable<T>, IDisposable
} }
/// <summary> Gets an Accessor for this List.</summary> /// <summary> Gets an Accessor for this List.</summary>
public eina.Accessor<T> GetAccessor() public Eina.Accessor<T> GetAccessor()
{ {
return new eina.AccessorInList<T>(eina_inlist_accessor_new(Handle), Ownership.Managed); return new Eina.AccessorInList<T>(eina_inlist_accessor_new(Handle), Ownership.Managed);
} }
} }

View File

@ -4,10 +4,10 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Collections.Generic; using System.Collections.Generic;
using static eina.TraitFunctions; using static Eina.TraitFunctions;
using static eina.IteratorNativeFunctions; using static Eina.IteratorNativeFunctions;
namespace eina { namespace Eina {
public static class IteratorNativeFunctions public static class IteratorNativeFunctions
{ {

View File

@ -4,11 +4,11 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Collections.Generic; using System.Collections.Generic;
using static eina.TraitFunctions; using static Eina.TraitFunctions;
using static eina.ListNativeFunctions; using static Eina.ListNativeFunctions;
using eina.Callbacks; using Eina.Callbacks;
namespace eina { namespace Eina {
public static class ListNativeFunctions public static class ListNativeFunctions
{ {
@ -328,14 +328,14 @@ public class List<T> : IEnumerable<T>, IDisposable
} }
public eina.Iterator<T> GetIterator() public Eina.Iterator<T> GetIterator()
{ {
return new eina.Iterator<T>(eina_list_iterator_new(Handle), true, false); return new Eina.Iterator<T>(eina_list_iterator_new(Handle), true, false);
} }
public eina.Iterator<T> GetReversedIterator() public Eina.Iterator<T> GetReversedIterator()
{ {
return new eina.Iterator<T>(eina_list_iterator_reversed_new(Handle), true, false); return new Eina.Iterator<T>(eina_list_iterator_reversed_new(Handle), true, false);
} }
public IEnumerator<T> GetEnumerator() public IEnumerator<T> GetEnumerator()
@ -352,9 +352,9 @@ public class List<T> : IEnumerable<T>, IDisposable
} }
/// <summary> Gets an Accessor for this List.</summary> /// <summary> Gets an Accessor for this List.</summary>
public eina.Accessor<T> GetAccessor() public Eina.Accessor<T> GetAccessor()
{ {
return new eina.Accessor<T>(eina_list_accessor_new(Handle), Ownership.Managed); return new Eina.Accessor<T>(eina_list_accessor_new(Handle), Ownership.Managed);
} }
} }

View File

@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
namespace eina { // Manual wrappers around eina functions namespace Eina { // Manual wrappers around eina functions
public class Log public class Log
{ {

View File

@ -4,9 +4,9 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using static eina.EinaNative.PromiseNativeMethods; using static Eina.EinaNative.PromiseNativeMethods;
namespace eina { namespace Eina {
namespace EinaNative { namespace EinaNative {
@ -21,10 +21,10 @@ static internal class PromiseNativeMethods
internal static extern IntPtr eina_promise_new(IntPtr scheduler, Promise_Cancel_Cb cancel_cb, IntPtr data); internal static extern IntPtr eina_promise_new(IntPtr scheduler, Promise_Cancel_Cb cancel_cb, IntPtr data);
[DllImport(efl.Libs.Eina)] [DllImport(efl.Libs.Eina)]
internal static extern void eina_promise_resolve(IntPtr scheduler, eina.Value_Native value); internal static extern void eina_promise_resolve(IntPtr scheduler, Eina.ValueNative value);
[DllImport(efl.Libs.Eina)] [DllImport(efl.Libs.Eina)]
internal static extern void eina_promise_reject(IntPtr scheduler, eina.Error reason); internal static extern void eina_promise_reject(IntPtr scheduler, Eina.Error reason);
[DllImport(efl.Libs.Eina)] [DllImport(efl.Libs.Eina)]
internal static extern IntPtr eina_future_new(IntPtr promise); internal static extern IntPtr eina_future_new(IntPtr promise);
@ -41,7 +41,7 @@ static internal class PromiseNativeMethods
[DllImport(efl.Libs.Eina)] [DllImport(efl.Libs.Eina)]
internal static extern IntPtr eina_future_chain_array(IntPtr prev, FutureDesc[] desc); internal static extern IntPtr eina_future_chain_array(IntPtr prev, FutureDesc[] desc);
internal delegate eina.Value_Native FutureCb(IntPtr data, eina.Value_Native value, IntPtr dead_future); internal delegate Eina.ValueNative FutureCb(IntPtr data, Eina.ValueNative value, IntPtr dead_future);
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct FutureDesc internal struct FutureDesc
@ -82,10 +82,10 @@ public class Promise : IDisposable
/// </summary> /// </summary>
public Promise(CancelCb cancelCb=null) public Promise(CancelCb cancelCb=null)
{ {
efl.ILoop loop = efl.App.GetLoopMain(); Efl.Loop loop = Efl.App.GetLoopMain();
// Should we be able to pass different schedulers? // Should we be able to pass different schedulers?
IntPtr scheduler = efl_loop_future_scheduler_get(loop.raw_handle); IntPtr scheduler = efl_loop_future_scheduler_get(loop.NativeHandle);
IntPtr cb_data = IntPtr.Zero; IntPtr cb_data = IntPtr.Zero;
@ -112,7 +112,7 @@ public class Promise : IDisposable
if (cb != null) if (cb != null)
cb(); cb();
else else
eina.Log.Info("Null promise CancelCb found"); Eina.Log.Info("Null promise CancelCb found");
handle.Free(); handle.Free();
} }
@ -133,7 +133,7 @@ public class Promise : IDisposable
{ {
if (Handle != IntPtr.Zero) if (Handle != IntPtr.Zero)
{ {
eina_promise_reject(Handle, eina.Error.ECANCELED); eina_promise_reject(Handle, Eina.Error.ECANCELED);
Handle = IntPtr.Zero; Handle = IntPtr.Zero;
} }
} }
@ -149,7 +149,7 @@ public class Promise : IDisposable
/// ///
/// This will make all futures attached to it to be called with the given value as payload. /// This will make all futures attached to it to be called with the given value as payload.
/// </summary> /// </summary>
public void Resolve(eina.Value value) public void Resolve(Eina.Value value)
{ {
SanityChecks(); SanityChecks();
eina_promise_resolve(this.Handle, value); eina_promise_resolve(this.Handle, value);
@ -162,10 +162,10 @@ public class Promise : IDisposable
/// <summary> /// <summary>
/// Rejects a promise. /// Rejects a promise.
/// ///
/// The future chain attached to this promise will be called with an eina.Value of type /// The future chain attached to this promise will be called with an Eina.Value of type
/// eina.ValueType.Error and payload eina.Error.ECANCELED. /// Eina.ValueType.Error and payload Eina.Error.ECANCELED.
/// </summary> /// </summary>
public void Reject(eina.Error reason) public void Reject(Eina.Error reason)
{ {
SanityChecks(); SanityChecks();
eina_promise_reject(this.Handle, reason); eina_promise_reject(this.Handle, reason);
@ -182,13 +182,13 @@ public class Future
/// <summary> /// <summary>
/// Callback attached to a future and to be called when resolving/rejecting a promise. /// Callback attached to a future and to be called when resolving/rejecting a promise.
/// ///
/// The eina.Value as argument can come with an eina.Error.ECANCELED as payload if the /// The Eina.Value as argument can come with an Eina.Error.ECANCELED as payload if the
/// promise/future was rejected/cancelled. /// promise/future was rejected/cancelled.
/// ///
/// The return value usually is same as the argument, forwarded, but can be changed in /// The return value usually is same as the argument, forwarded, but can be changed in
/// case were the chain act as a transforming pipeline. /// case were the chain act as a transforming pipeline.
/// </summary> /// </summary>
public delegate eina.Value ResolvedCb(eina.Value value); public delegate Eina.Value ResolvedCb(Eina.Value value);
public IntPtr Handle { get; internal set; } public IntPtr Handle { get; internal set; }
@ -197,7 +197,7 @@ public class Future
/// </summary> /// </summary>
public Future(IntPtr handle) public Future(IntPtr handle)
{ {
Handle = ThenRaw(handle, (eina.Value value) => { Handle = ThenRaw(handle, (Eina.Value value) => {
Handle = IntPtr.Zero; Handle = IntPtr.Zero;
return value; return value;
}); });
@ -212,7 +212,7 @@ public class Future
public Future(Promise promise, ResolvedCb cb=null) public Future(Promise promise, ResolvedCb cb=null)
{ {
IntPtr intermediate = eina_future_new(promise.Handle); IntPtr intermediate = eina_future_new(promise.Handle);
Handle = ThenRaw(intermediate, (eina.Value value) => { Handle = ThenRaw(intermediate, (Eina.Value value) => {
if (cb != null) if (cb != null)
value = cb(value); value = cb(value);
Handle = IntPtr.Zero; Handle = IntPtr.Zero;
@ -229,7 +229,7 @@ public class Future
/// <summary> /// <summary>
/// Cancels this future and the chain it belongs to, along with the promise linked against it. /// Cancels this future and the chain it belongs to, along with the promise linked against it.
/// ///
/// The callbacks will still be called with eina.Error.ECANCELED as payload. The promise cancellation /// The callbacks will still be called with Eina.Error.ECANCELED as payload. The promise cancellation
/// callback will also be called if present. /// callback will also be called if present.
/// </summary> /// </summary>
public void Cancel() public void Cancel()
@ -263,14 +263,14 @@ public class Future
desc.data = GCHandle.ToIntPtr(handle); desc.data = GCHandle.ToIntPtr(handle);
return eina_future_then_from_desc(previous, desc); return eina_future_then_from_desc(previous, desc);
} }
private static eina.Value_Native NativeResolvedCb(IntPtr data, eina.Value_Native value, IntPtr dead_future) private static Eina.ValueNative NativeResolvedCb(IntPtr data, Eina.ValueNative value, IntPtr dead_future)
{ {
GCHandle handle = GCHandle.FromIntPtr(data); GCHandle handle = GCHandle.FromIntPtr(data);
ResolvedCb cb = handle.Target as ResolvedCb; ResolvedCb cb = handle.Target as ResolvedCb;
if (cb != null) if (cb != null)
value = cb(value); value = cb(value);
else else
eina.Log.Warning("Failed to get future callback."); Eina.Log.Warning("Failed to get future callback.");
handle.Free(); handle.Free();
return value; return value;
} }
@ -310,7 +310,7 @@ public class Future
GCHandle handle = GCHandle.FromIntPtr(descs[i].data); GCHandle handle = GCHandle.FromIntPtr(descs[i].data);
handle.Free(); handle.Free();
} }
eina.Log.Error($"Failed to create native future description for callbacks. Error: {e.ToString()}"); Eina.Log.Error($"Failed to create native future description for callbacks. Error: {e.ToString()}");
return null; return null;
} }
return new Future(eina_future_chain_array(Handle, descs)); return new Future(eina_future_chain_array(Handle, descs));

View File

@ -3,7 +3,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace eina { namespace Eina {
public interface ISliceBase public interface ISliceBase
{ {
@ -40,7 +40,7 @@ public struct Slice : ISliceBase
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct Rw_Slice : ISliceBase public struct RwSlice : ISliceBase
{ {
public UIntPtr Len {get;set;} public UIntPtr Len {get;set;}
public IntPtr Mem {get;set;} public IntPtr Mem {get;set;}
@ -51,13 +51,13 @@ public struct Rw_Slice : ISliceBase
set { Len = (UIntPtr) value; } set { Len = (UIntPtr) value; }
} }
public Rw_Slice(IntPtr mem, UIntPtr len) public RwSlice(IntPtr mem, UIntPtr len)
{ {
Mem = mem; Mem = mem;
Len = len; Len = len;
} }
public Rw_Slice PinnedDataSet(IntPtr mem, UIntPtr len) public RwSlice PinnedDataSet(IntPtr mem, UIntPtr len)
{ {
Mem = mem; Mem = mem;
Len = len; Len = len;
@ -77,7 +77,7 @@ public struct Rw_Slice : ISliceBase
public static class Eina_SliceUtils public static class Eina_SliceUtils
{ {
public static byte[] GetBytes(this eina.ISliceBase slc) public static byte[] GetBytes(this Eina.ISliceBase slc)
{ {
var size = (int)(slc.Len); var size = (int)(slc.Len);
byte[] mArray = new byte[size]; byte[] mArray = new byte[size];

View File

@ -1,9 +1,9 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using static eina.EinaNative.StrbufNativeMethods; using static Eina.EinaNative.StrbufNativeMethods;
namespace eina namespace Eina
{ {
namespace EinaNative namespace EinaNative
{ {

View File

@ -4,7 +4,7 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace eina { namespace Eina {
public class Stringshare { public class Stringshare {
[DllImport(efl.Libs.Eina)] public static extern System.IntPtr [DllImport(efl.Libs.Eina)] public static extern System.IntPtr

View File

@ -10,11 +10,11 @@ using System.Security;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using static eina.EinaNative.UnsafeNativeMethods; using static Eina.EinaNative.UnsafeNativeMethods;
using static eina.TraitFunctions; using static Eina.TraitFunctions;
namespace eina { namespace Eina {
namespace EinaNative { namespace EinaNative {
@ -270,11 +270,11 @@ static internal class UnsafeNativeMethods {
[DllImport(efl.Libs.Eina)] [DllImport(efl.Libs.Eina)]
[return: MarshalAsAttribute(UnmanagedType.U1)] [return: MarshalAsAttribute(UnmanagedType.U1)]
internal static extern bool eina_value_optional_pget(IntPtr handle, out eina.EinaNative.Value_Array output); internal static extern bool eina_value_optional_pget(IntPtr handle, out Eina.EinaNative.Value_Array output);
[DllImport(efl.Libs.Eina)] [DllImport(efl.Libs.Eina)]
[return: MarshalAsAttribute(UnmanagedType.U1)] [return: MarshalAsAttribute(UnmanagedType.U1)]
internal static extern bool eina_value_optional_pget(IntPtr handle, out eina.EinaNative.Value_List output); internal static extern bool eina_value_optional_pget(IntPtr handle, out Eina.EinaNative.Value_List output);
[DllImport(efl.Libs.Eina)] [DllImport(efl.Libs.Eina)]
[return: MarshalAsAttribute(UnmanagedType.U1)] [return: MarshalAsAttribute(UnmanagedType.U1)]
@ -325,11 +325,11 @@ static internal class UnsafeNativeMethods {
[DllImport(efl.Libs.CustomExports)] [DllImport(efl.Libs.CustomExports)]
[return: MarshalAsAttribute(UnmanagedType.U1)] [return: MarshalAsAttribute(UnmanagedType.U1)]
internal static extern bool eina_value_pset_wrapper(IntPtr handle, ref eina.EinaNative.Value_Array ptr); internal static extern bool eina_value_pset_wrapper(IntPtr handle, ref Eina.EinaNative.Value_Array ptr);
[DllImport(efl.Libs.CustomExports)] [DllImport(efl.Libs.CustomExports)]
[return: MarshalAsAttribute(UnmanagedType.U1)] [return: MarshalAsAttribute(UnmanagedType.U1)]
internal static extern bool eina_value_pset_wrapper(IntPtr handle, ref eina.EinaNative.Value_List ptr); internal static extern bool eina_value_pset_wrapper(IntPtr handle, ref Eina.EinaNative.Value_List ptr);
[DllImport(efl.Libs.Eina)] [DllImport(efl.Libs.Eina)]
[return: MarshalAsAttribute(UnmanagedType.U1)] [return: MarshalAsAttribute(UnmanagedType.U1)]
@ -394,14 +394,14 @@ static internal class UnsafeNativeMethods {
/// <summary>Struct for passing Values by value to Unmanaged functions.</summary> /// <summary>Struct for passing Values by value to Unmanaged functions.</summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct Value_Native public struct ValueNative
{ {
public IntPtr Type; public IntPtr Type;
public IntPtr Value; // Atually an Eina_Value_Union, but it is padded to 8 bytes. public IntPtr Value; // Atually an Eina_Value_Union, but it is padded to 8 bytes.
public override string ToString() public override string ToString()
{ {
return $"Value_Native<Type:0x{Type.ToInt64():x}, Value:0x{Value.ToInt64():x}>"; return $"ValueNative<Type:0x{Type.ToInt64():x}, Value:0x{Value.ToInt64():x}>";
} }
} }
@ -582,7 +582,7 @@ static class ValueTypeBridge
private static void LoadTypes() private static void LoadTypes()
{ {
eina.Config.Init(); // Make sure eina is initialized. Eina.Config.Init(); // Make sure eina is initialized.
ManagedToNative.Add(ValueType.SByte, type_sbyte()); ManagedToNative.Add(ValueType.SByte, type_sbyte());
NativeToManaged.Add(type_sbyte(), ValueType.SByte); NativeToManaged.Add(type_sbyte(), ValueType.SByte);
@ -669,9 +669,9 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
// Ok EINA_VALUE_TYPE_DOUBLE: double -- double // Ok EINA_VALUE_TYPE_DOUBLE: double -- double
// EINA_VALUE_TYPE_STRINGSHARE: const char * -- string // EINA_VALUE_TYPE_STRINGSHARE: const char * -- string
// Ok EINA_VALUE_TYPE_STRING: const char * -- string // Ok EINA_VALUE_TYPE_STRING: const char * -- string
// Ok EINA_VALUE_TYPE_ARRAY: Eina_Value_Array -- eina.Array? // Ok EINA_VALUE_TYPE_ARRAY: Eina_Value_Array -- Eina.Array?
// Ok EINA_VALUE_TYPE_LIST: Eina_Value_List -- eina.List? // Ok EINA_VALUE_TYPE_LIST: Eina_Value_List -- Eina.List?
// EINA_VALUE_TYPE_HASH: Eina_Value_Hash -- eina.Hash? // EINA_VALUE_TYPE_HASH: Eina_Value_Hash -- Eina.Hash?
// EINA_VALUE_TYPE_TIMEVAL: struct timeval -- FIXME // EINA_VALUE_TYPE_TIMEVAL: struct timeval -- FIXME
// EINA_VALUE_TYPE_BLOB: Eina_Value_Blob -- FIXME // EINA_VALUE_TYPE_BLOB: Eina_Value_Blob -- FIXME
// EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct -- FIXME // EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct -- FIXME
@ -686,7 +686,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
/// <summary> Whether this is an Optional value (meaning it can have a value or not). </summary> /// <summary> Whether this is an Optional value (meaning it can have a value or not). </summary>
public bool Optional { public bool Optional {
get { get {
return GetValueType() == eina.ValueType.Optional; return GetValueType() == Eina.ValueType.Optional;
} }
/* protected set { /* protected set {
// Should we expose this? // Should we expose this?
@ -700,7 +700,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
public bool Empty { public bool Empty {
get { get {
SanityChecks(); SanityChecks();
return GetValueType() == eina.ValueType.Empty; return GetValueType() == Eina.ValueType.Empty;
} }
} }
@ -745,7 +745,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
this.Handle = Alloc(); this.Handle = Alloc();
if (this.Handle == IntPtr.Zero) if (this.Handle == IntPtr.Zero)
throw new OutOfMemoryException("Failed to allocate memory for eina.Value"); throw new OutOfMemoryException("Failed to allocate memory for Eina.Value");
// Initialize to EINA_VALUE_EMPTY before performing any other operation on this value. // Initialize to EINA_VALUE_EMPTY before performing any other operation on this value.
MemoryNative.Memset(this.Handle, 0, eina_value_sizeof()); MemoryNative.Memset(this.Handle, 0, eina_value_sizeof());
@ -779,19 +779,19 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
} }
/// <summary>Constructor to build value from Values_Natives passed by value from C.</summary> /// <summary>Constructor to build value from Values_Natives passed by value from C.</summary>
public Value(Value_Native value) public Value(ValueNative value)
{ {
IntPtr tmp = IntPtr.Zero; IntPtr tmp = IntPtr.Zero;
try { try {
this.Handle = Alloc(); this.Handle = Alloc();
if (value.Type == IntPtr.Zero) // Got an EINA_VALUE_EMPTY by value. if (value.Type == IntPtr.Zero) // Got an EINA_VALUE_EMPTY by value.
MemoryNative.Memset(this.Handle, 0, Marshal.SizeOf(typeof(Value_Native))); MemoryNative.Memset(this.Handle, 0, Marshal.SizeOf(typeof(ValueNative)));
else else
{ {
// We allocate this intermediate Value_Native using malloc to allow freeing with // We allocate this intermediate ValueNative using malloc to allow freeing with
// free(), avoiding a call to eina_value_flush that would wipe the underlying value contents // free(), avoiding a call to eina_value_flush that would wipe the underlying value contents
// for pointer types like string. // for pointer types like string.
tmp = MemoryNative.Alloc(Marshal.SizeOf(typeof(Value_Native))); tmp = MemoryNative.Alloc(Marshal.SizeOf(typeof(ValueNative)));
Marshal.StructureToPtr(value, tmp, false); // Can't get the address of a struct directly. Marshal.StructureToPtr(value, tmp, false); // Can't get the address of a struct directly.
this.Handle = Alloc(); this.Handle = Alloc();
@ -811,19 +811,19 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
} }
/// <summary>Implicit conversion from managed value to native struct representation.</summary> /// <summary>Implicit conversion from managed value to native struct representation.</summary>
public static implicit operator Value_Native(Value v) public static implicit operator ValueNative(Value v)
{ {
return v.GetNative(); return v.GetNative();
} }
/// <summary>Implicit conversion from native struct representation to managed wrapper.</summary> /// <summary>Implicit conversion from native struct representation to managed wrapper.</summary>
public static implicit operator Value(Value_Native v) public static implicit operator Value(ValueNative v)
{ {
return new Value(v); return new Value(v);
} }
/// <summary>Creates an Value instance from a given array description.</summary> /// <summary>Creates an Value instance from a given array description.</summary>
private static Value FromArrayDesc(eina.EinaNative.Value_Array arrayDesc) private static Value FromArrayDesc(Eina.EinaNative.Value_Array arrayDesc)
{ {
Value value = new Value(); Value value = new Value();
value.Setup(ValueType.Array, ValueType.String); // Placeholder values to be overwritten by the following pset call. value.Setup(ValueType.Array, ValueType.String); // Placeholder values to be overwritten by the following pset call.
@ -833,7 +833,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
} }
/// <summary>Creates an Value instance from a given array description.</summary> /// <summary>Creates an Value instance from a given array description.</summary>
private static Value FromListDesc(eina.EinaNative.Value_List listDesc) private static Value FromListDesc(Eina.EinaNative.Value_List listDesc)
{ {
Value value = new Value(); Value value = new Value();
value.Setup(ValueType.List, ValueType.String); // Placeholder values to be overwritten by the following pset call. value.Setup(ValueType.List, ValueType.String); // Placeholder values to be overwritten by the following pset call.
@ -898,7 +898,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
throw new ObjectDisposedException(base.GetType().Name); throw new ObjectDisposedException(base.GetType().Name);
// Can't call setup with Empty value type (would give an eina error) // Can't call setup with Empty value type (would give an eina error)
if (type == eina.ValueType.Empty) if (type == Eina.ValueType.Empty)
{ {
// Need to cleanup as it may point to payload outside the underlying Eina_Value (like arrays and strings). // Need to cleanup as it may point to payload outside the underlying Eina_Value (like arrays and strings).
if (!Empty) if (!Empty)
@ -989,10 +989,10 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
Flushed = true; Flushed = true;
} }
/// <summary>Get a Value_Native struct with the *value* pointed by this eina.Value.</summary> /// <summary>Get a ValueNative struct with the *value* pointed by this Eina.Value.</summary>
public Value_Native GetNative() public ValueNative GetNative()
{ {
Value_Native value = (Value_Native)Marshal.PtrToStructure(this.Handle, typeof(Value_Native)); ValueNative value = (ValueNative)Marshal.PtrToStructure(this.Handle, typeof(ValueNative));
return value; return value;
} }
@ -1007,7 +1007,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
if (!GetValueType().IsNumeric()) if (!GetValueType().IsNumeric())
throw (new ArgumentException( throw (new ArgumentException(
"Trying to set numeric value on a non-numeric eina.Value")); "Trying to set numeric value on a non-numeric Eina.Value"));
return eina_value_set_wrapper_uchar(this.Handle, value); return eina_value_set_wrapper_uchar(this.Handle, value);
} }
@ -1022,7 +1022,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
if (!GetValueType().IsNumeric()) if (!GetValueType().IsNumeric())
throw (new ArgumentException( throw (new ArgumentException(
"Trying to set numeric value on a non-numeric eina.Value")); "Trying to set numeric value on a non-numeric Eina.Value"));
return eina_value_set_wrapper_char(this.Handle, value); return eina_value_set_wrapper_char(this.Handle, value);
} }
@ -1037,7 +1037,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
if (!GetValueType().IsNumeric()) if (!GetValueType().IsNumeric())
throw (new ArgumentException( throw (new ArgumentException(
"Trying to set numeric value on a non-numeric eina.Value")); "Trying to set numeric value on a non-numeric Eina.Value"));
return eina_value_set_wrapper_short(this.Handle, value); return eina_value_set_wrapper_short(this.Handle, value);
} }
@ -1052,7 +1052,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
if (!GetValueType().IsNumeric()) if (!GetValueType().IsNumeric())
throw (new ArgumentException( throw (new ArgumentException(
"Trying to set numeric value on a non-numeric eina.Value")); "Trying to set numeric value on a non-numeric Eina.Value"));
return eina_value_set_wrapper_ushort(this.Handle, value); return eina_value_set_wrapper_ushort(this.Handle, value);
} }
@ -1068,7 +1068,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
if (!GetValueType().IsNumeric()) if (!GetValueType().IsNumeric())
throw (new ArgumentException( throw (new ArgumentException(
"Trying to set numeric value on a non-numeric eina.Value")); "Trying to set numeric value on a non-numeric Eina.Value"));
return eina_value_set_wrapper_uint(this.Handle, value); return eina_value_set_wrapper_uint(this.Handle, value);
} }
@ -1084,7 +1084,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
if (!GetValueType().IsNumeric()) if (!GetValueType().IsNumeric())
throw (new ArgumentException( throw (new ArgumentException(
"Trying to set numeric value on a non-numeric eina.Value")); "Trying to set numeric value on a non-numeric Eina.Value"));
return eina_value_set_wrapper_int(this.Handle, value); return eina_value_set_wrapper_int(this.Handle, value);
} }
@ -1100,7 +1100,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
if (!GetValueType().IsNumeric()) if (!GetValueType().IsNumeric())
throw (new ArgumentException( throw (new ArgumentException(
"Trying to set numeric value on a non-numeric eina.Value")); "Trying to set numeric value on a non-numeric Eina.Value"));
return eina_value_set_wrapper_ulong(this.Handle, value); return eina_value_set_wrapper_ulong(this.Handle, value);
} }
@ -1116,7 +1116,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
if (!GetValueType().IsNumeric()) if (!GetValueType().IsNumeric())
throw (new ArgumentException( throw (new ArgumentException(
"Trying to set numeric value on a non-numeric eina.Value")); "Trying to set numeric value on a non-numeric Eina.Value"));
return eina_value_set_wrapper_long(this.Handle, value); return eina_value_set_wrapper_long(this.Handle, value);
} }
@ -1132,7 +1132,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
if (!GetValueType().IsNumeric()) if (!GetValueType().IsNumeric())
throw (new ArgumentException( throw (new ArgumentException(
"Trying to set numeric value on a non-numeric eina.Value")); "Trying to set numeric value on a non-numeric Eina.Value"));
return eina_value_set_wrapper_float(this.Handle, value); return eina_value_set_wrapper_float(this.Handle, value);
} }
@ -1149,7 +1149,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
if (!GetValueType().IsNumeric()) if (!GetValueType().IsNumeric())
throw (new ArgumentException( throw (new ArgumentException(
"Trying to set numeric value on a non-numeric eina.Value")); "Trying to set numeric value on a non-numeric Eina.Value"));
return eina_value_set_wrapper_double(this.Handle, value); return eina_value_set_wrapper_double(this.Handle, value);
} }
@ -1165,13 +1165,13 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
if (!GetValueType().IsString()) if (!GetValueType().IsString())
throw (new ArgumentException( throw (new ArgumentException(
"Trying to set non-string value on a string eina.Value")); "Trying to set non-string value on a string Eina.Value"));
// No need to worry about ownership as eina_value_set will copy the passed string. // No need to worry about ownership as eina_value_set will copy the passed string.
return eina_value_set_wrapper_string(this.Handle, value); return eina_value_set_wrapper_string(this.Handle, value);
} }
/// <summary>Stores the given error value.</summary> /// <summary>Stores the given error value.</summary>
public bool Set(eina.Error value) public bool Set(Eina.Error value)
{ {
SanityChecks(); SanityChecks();
@ -1211,7 +1211,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
Marshal.StructureToPtr(value_list, ptr_val, false); Marshal.StructureToPtr(value_list, ptr_val, false);
break; break;
default: default:
throw new InvalidValueTypeException("Only containers can be passed as raw eina.Values"); throw new InvalidValueTypeException("Only containers can be passed as raw Eina.Values");
} }
return eina_value_optional_pset(this.Handle, native_type, ptr_val); return eina_value_optional_pset(this.Handle, native_type, ptr_val);
@ -1338,8 +1338,8 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
return true; return true;
} }
/// <summary>Gets the currently stored value as an eina.Error.</summary> /// <summary>Gets the currently stored value as an Eina.Error.</summary>
public bool Get(out eina.Error value) public bool Get(out Eina.Error value)
{ {
SanityChecks(); SanityChecks();
bool ret; bool ret;
@ -1354,7 +1354,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
return ret; return ret;
} }
/// <summary>Gets the currently stored value as an complex (e.g. container) eina.Value.</summary> /// <summary>Gets the currently stored value as an complex (e.g. container) Eina.Value.</summary>
public bool Get(out Value value) public bool Get(out Value value)
{ {
SanityChecks(); SanityChecks();
@ -1368,14 +1368,14 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
switch (managedType) { switch (managedType) {
case ValueType.Array: case ValueType.Array:
eina.EinaNative.Value_Array array_desc; Eina.EinaNative.Value_Array array_desc;
if (!eina_value_optional_pget(this.Handle, out array_desc)) if (!eina_value_optional_pget(this.Handle, out array_desc))
return false; return false;
value = Value.FromArrayDesc(array_desc); value = Value.FromArrayDesc(array_desc);
break; break;
case ValueType.List: case ValueType.List:
eina.EinaNative.Value_List list_desc; Eina.EinaNative.Value_List list_desc;
if (!eina_value_optional_pget(this.Handle, out list_desc)) if (!eina_value_optional_pget(this.Handle, out list_desc))
return false; return false;
@ -1490,7 +1490,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
return str; return str;
} }
/// <summary>Empties an optional eina.Value, freeing what was previously contained.</summary> /// <summary>Empties an optional Eina.Value, freeing what was previously contained.</summary>
public bool Reset() public bool Reset()
{ {
OptionalSanityChecks(); OptionalSanityChecks();

View File

@ -136,7 +136,7 @@ public abstract class BasicMessageArgument
{ {
if (!InternalAppendTo(msg)) if (!InternalAppendTo(msg))
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not append basic type to eldbus.Message"); throw new SEHException("Eldbus: could not append basic type to eldbus.Message");
} }
} }
@ -145,7 +145,7 @@ public abstract class BasicMessageArgument
{ {
if (!InternalAppendTo(iter)) if (!InternalAppendTo(iter))
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not append basic type to eldbus.MessageIterator"); throw new SEHException("Eldbus: could not append basic type to eldbus.MessageIterator");
} }
} }
@ -503,8 +503,8 @@ public static class Common
public static void RaiseNullHandle() public static void RaiseNullHandle()
{ {
if (NullHandleError == 0) if (NullHandleError == 0)
NullHandleError = eina.Error.Register("Eldbus: null handle"); NullHandleError = Eina.Error.Register("Eldbus: null handle");
eina.Error.Raise(NullHandleError); Eina.Error.Raise(NullHandleError);
} }
public delegate void Eldbus_Message_Cb(IntPtr data, IntPtr msg, IntPtr pending); public delegate void Eldbus_Message_Cb(IntPtr data, IntPtr msg, IntPtr pending);
@ -526,7 +526,7 @@ public static class Common
MessageDelegate dlgt = Marshal.GetDelegateForFunctionPointer(data, typeof(MessageDelegate)) as MessageDelegate; MessageDelegate dlgt = Marshal.GetDelegateForFunctionPointer(data, typeof(MessageDelegate)) as MessageDelegate;
if (dlgt == null) if (dlgt == null)
{ {
eina.Log.Error("Eldbus: invalid delegate pointer from Eldbus_Message_Cb"); Eina.Log.Error("Eldbus: invalid delegate pointer from Eldbus_Message_Cb");
return; return;
} }
@ -540,7 +540,7 @@ public static class Common
} }
catch(Exception e) catch(Exception e)
{ {
eina.Log.Error("Eldbus: could not convert Eldbus_Message_Cb parameters. Exception: " + e.ToString()); Eina.Log.Error("Eldbus: could not convert Eldbus_Message_Cb parameters. Exception: " + e.ToString());
return; return;
} }
@ -550,12 +550,12 @@ public static class Common
} }
catch(Exception e) catch(Exception e)
{ {
eina.Log.Error("Eldbus: Eldbus_Message_Cb delegate error. Exception: " + e.ToString()); Eina.Log.Error("Eldbus: Eldbus_Message_Cb delegate error. Exception: " + e.ToString());
} }
} }
private static Eldbus_Message_Cb message_cb_wrapper = null; private static Eldbus_Message_Cb message_cb_wrapper = null;
private static eina.Error NullHandleError = 0; private static Eina.Error NullHandleError = 0;
} }
} }

View File

@ -13,7 +13,7 @@ public static class Config
public static void Init() public static void Init()
{ {
if (eldbus_init() == 0) if (eldbus_init() == 0)
throw new efl.EflException("Failed to initialize Eldbus"); throw new Efl.EflException("Failed to initialize Eldbus");
} }
public static void Shutdown() public static void Shutdown()

View File

@ -193,7 +193,7 @@ public class Connection : IDisposable
if(pending_hdl == IntPtr.Zero) if(pending_hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_connection_send"); throw new SEHException("Eldbus: could not get `Pending' object from eldbus_connection_send");
} }
@ -225,7 +225,7 @@ public class Connection : IDisposable
if(pending_hdl == IntPtr.Zero) if(pending_hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_request"); throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_request");
} }
@ -246,7 +246,7 @@ public class Connection : IDisposable
if(pending_hdl == IntPtr.Zero) if(pending_hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_release"); throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_release");
} }
@ -267,7 +267,7 @@ public class Connection : IDisposable
if(pending_hdl == IntPtr.Zero) if(pending_hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_owner_get"); throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_owner_get");
} }
@ -288,7 +288,7 @@ public class Connection : IDisposable
if(pending_hdl == IntPtr.Zero) if(pending_hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_owner_has"); throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_owner_has");
} }
@ -306,7 +306,7 @@ public class Connection : IDisposable
if(pending_hdl == IntPtr.Zero) if(pending_hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_names_list"); throw new SEHException("Eldbus: could not get `Pending' object from eldbus_names_list");
} }
@ -324,7 +324,7 @@ public class Connection : IDisposable
if(pending_hdl == IntPtr.Zero) if(pending_hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_names_activatable_list"); throw new SEHException("Eldbus: could not get `Pending' object from eldbus_names_activatable_list");
} }
@ -342,7 +342,7 @@ public class Connection : IDisposable
if(pending_hdl == IntPtr.Zero) if(pending_hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_hello"); throw new SEHException("Eldbus: could not get `Pending' object from eldbus_hello");
} }
@ -363,7 +363,7 @@ public class Connection : IDisposable
if(pending_hdl == IntPtr.Zero) if(pending_hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_start"); throw new SEHException("Eldbus: could not get `Pending' object from eldbus_name_start");
} }

View File

@ -252,7 +252,7 @@ public class Message : IDisposable
var ptr = eldbus_message_method_call_new(dest, path, iface, method); var ptr = eldbus_message_method_call_new(dest, path, iface, method);
if (ptr == IntPtr.Zero) if (ptr == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_method_call_new"); throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_method_call_new");
} }
return new eldbus.Message(ptr, true); return new eldbus.Message(ptr, true);
@ -263,7 +263,7 @@ public class Message : IDisposable
var ptr = eldbus_message_signal_new(path, _interface, name); var ptr = eldbus_message_signal_new(path, _interface, name);
if (ptr == IntPtr.Zero) if (ptr == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_signal_new"); throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_signal_new");
} }
return new eldbus.Message(ptr, true); return new eldbus.Message(ptr, true);
@ -329,7 +329,7 @@ public class Message : IDisposable
var ptr = eldbus_message_error_new(Handle, error_name, error_msg); var ptr = eldbus_message_error_new(Handle, error_name, error_msg);
if (ptr == IntPtr.Zero) if (ptr == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_error_new"); throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_error_new");
} }
return new eldbus.Message(ptr, false); return new eldbus.Message(ptr, false);
@ -341,7 +341,7 @@ public class Message : IDisposable
var ptr = eldbus_message_method_return_new(Handle); var ptr = eldbus_message_method_return_new(Handle);
if (ptr == IntPtr.Zero) if (ptr == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_method_return_new"); throw new SEHException("Eldbus: could not get `Message' object from eldbus_message_method_return_new");
} }
return new eldbus.Message(ptr, false); return new eldbus.Message(ptr, false);
@ -472,7 +472,7 @@ public class Message : IDisposable
var ptr = eldbus_message_iter_get(Handle); var ptr = eldbus_message_iter_get(Handle);
if (ptr == IntPtr.Zero) if (ptr == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `MessageIterator' object from eldbus_message_iter_get"); throw new SEHException("Eldbus: could not get `MessageIterator' object from eldbus_message_iter_get");
} }
return new eldbus.MessageIterator(ptr, IntPtr.Zero); return new eldbus.MessageIterator(ptr, IntPtr.Zero);
@ -534,13 +534,13 @@ public class MessageIterator
} }
else if (!eldbus_message_iter_arguments_append(Handle, signature, out new_iter)) else if (!eldbus_message_iter_arguments_append(Handle, signature, out new_iter))
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not append container type"); throw new SEHException("Eldbus: could not append container type");
} }
if (new_iter == IntPtr.Zero) if (new_iter == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `MessageIterator' object from eldbus_message_iter_arguments_append"); throw new SEHException("Eldbus: could not get `MessageIterator' object from eldbus_message_iter_arguments_append");
} }
@ -555,7 +555,7 @@ public class MessageIterator
if (new_iter == IntPtr.Zero) if (new_iter == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `MessageIterator' object from eldbus_message_iter_container_new"); throw new SEHException("Eldbus: could not get `MessageIterator' object from eldbus_message_iter_container_new");
} }
@ -573,7 +573,7 @@ public class MessageIterator
if (!eldbus_message_iter_container_close(Parent, Handle)) if (!eldbus_message_iter_container_close(Parent, Handle))
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not close MessageIterator"); throw new SEHException("Eldbus: could not close MessageIterator");
} }
@ -686,7 +686,7 @@ public class MessageIterator
bool r = eldbus_message_iter_get_and_next(Handle, typecode, out hdl); bool r = eldbus_message_iter_get_and_next(Handle, typecode, out hdl);
if (hdl == IntPtr.Zero) if (hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get argument"); throw new SEHException("Eldbus: could not get argument");
} }
iter = new eldbus.MessageIterator(hdl, Handle); iter = new eldbus.MessageIterator(hdl, Handle);
@ -700,7 +700,7 @@ public class MessageIterator
IntPtr hdl = IntPtr.Zero; IntPtr hdl = IntPtr.Zero;
if (!eldbus_message_iter_arguments_get(Handle, signatue, out hdl) || hdl == IntPtr.Zero) if (!eldbus_message_iter_arguments_get(Handle, signatue, out hdl) || hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get argument"); throw new SEHException("Eldbus: could not get argument");
} }
iter = new eldbus.MessageIterator(hdl, Handle); iter = new eldbus.MessageIterator(hdl, Handle);
@ -802,7 +802,7 @@ public class MessageIterator
IntPtr hdl = IntPtr.Zero; IntPtr hdl = IntPtr.Zero;
if (!eldbus_message_iter_arguments_get(Handle, signatue, out hdl) || hdl == IntPtr.Zero) if (!eldbus_message_iter_arguments_get(Handle, signatue, out hdl) || hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get argument"); throw new SEHException("Eldbus: could not get argument");
} }
iter = new eldbus.MessageIterator(hdl, Handle); iter = new eldbus.MessageIterator(hdl, Handle);
@ -830,7 +830,7 @@ public class MessageIterator
if (!eldbus_message_iter_fixed_array_get(Handle, type_code, out value, out n_elements)) if (!eldbus_message_iter_fixed_array_get(Handle, type_code, out value, out n_elements))
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get fixed array"); throw new SEHException("Eldbus: could not get fixed array");
} }
} }

View File

@ -122,7 +122,7 @@ public class Object : System.IDisposable
if (handle == IntPtr.Zero) if (handle == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Object' object from eldbus_object_get"); throw new SEHException("Eldbus: could not get `Object' object from eldbus_object_get");
} }
@ -170,7 +170,7 @@ public class Object : System.IDisposable
if (conn == IntPtr.Zero) if (conn == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Connection' object from eldbus_object_connection_get"); throw new SEHException("Eldbus: could not get `Connection' object from eldbus_object_connection_get");
} }
@ -217,7 +217,7 @@ public class Object : System.IDisposable
if (pending_hdl == IntPtr.Zero) if (pending_hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_send"); throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_send");
} }
@ -232,7 +232,7 @@ public class Object : System.IDisposable
if (hdl == IntPtr.Zero) if (hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Message' object from eldbus_object_method_call_new"); throw new SEHException("Eldbus: could not get `Message' object from eldbus_object_method_call_new");
} }
@ -250,7 +250,7 @@ public class Object : System.IDisposable
if (pending_hdl == IntPtr.Zero) if (pending_hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_peer_ping"); throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_peer_ping");
} }
@ -268,7 +268,7 @@ public class Object : System.IDisposable
if (pending_hdl == IntPtr.Zero) if (pending_hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_peer_machine_id_get"); throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_peer_machine_id_get");
} }
@ -286,7 +286,7 @@ public class Object : System.IDisposable
if (pending_hdl == IntPtr.Zero) if (pending_hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_introspect"); throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_introspect");
} }
@ -304,7 +304,7 @@ public class Object : System.IDisposable
if (pending_hdl == IntPtr.Zero) if (pending_hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_managed_objects_get"); throw new SEHException("Eldbus: could not get `Pending' object from eldbus_object_managed_objects_get");
} }

View File

@ -134,7 +134,7 @@ public class Proxy : IDisposable
var ptr = eldbus_proxy_object_get(Handle); var ptr = eldbus_proxy_object_get(Handle);
if (ptr == IntPtr.Zero) if (ptr == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Object' object from eldbus_proxy_object_get"); throw new SEHException("Eldbus: could not get `Object' object from eldbus_proxy_object_get");
} }
return new eldbus.Object(ptr, false); return new eldbus.Object(ptr, false);
@ -157,7 +157,7 @@ public class Proxy : IDisposable
var ptr = eldbus_proxy_method_call_new(Handle, member); var ptr = eldbus_proxy_method_call_new(Handle, member);
if (ptr == IntPtr.Zero) if (ptr == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Message' object from eldbus_proxy_method_call_new"); throw new SEHException("Eldbus: could not get `Message' object from eldbus_proxy_method_call_new");
} }
return new eldbus.Message(ptr, false); return new eldbus.Message(ptr, false);
@ -177,7 +177,7 @@ public class Proxy : IDisposable
if (pending_hdl == IntPtr.Zero) if (pending_hdl == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Pending' object from eldbus_proxy_send"); throw new SEHException("Eldbus: could not get `Pending' object from eldbus_proxy_send");
} }
@ -190,7 +190,7 @@ public class Proxy : IDisposable
var ptr = eldbus_proxy_send_and_block(Handle, msg.Handle, timeout); var ptr = eldbus_proxy_send_and_block(Handle, msg.Handle, timeout);
if (ptr == IntPtr.Zero) if (ptr == IntPtr.Zero)
{ {
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
throw new SEHException("Eldbus: could not get `Message' object from eldbus_proxy_send_and_block"); throw new SEHException("Eldbus: could not get `Message' object from eldbus_proxy_send_and_block");
} }
return new eldbus.Message(ptr, true); return new eldbus.Message(ptr, true);

View File

@ -6,9 +6,9 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Threading; using System.Threading;
using static eina.NativeCustomExportFunctions; using static Eina.NativeCustomExportFunctions;
namespace efl { namespace eo { namespace Efl { namespace Eo {
public class Globals { public class Globals {
[DllImport(efl.Libs.Eo)] public static extern void efl_object_init(); [DllImport(efl.Libs.Eo)] public static extern void efl_object_init();
@ -20,8 +20,10 @@ public class Globals {
_efl_add_end(IntPtr eo, byte is_ref, byte is_fallback); _efl_add_end(IntPtr eo, byte is_ref, byte is_fallback);
[DllImport(efl.Libs.Eo)] public static extern IntPtr [DllImport(efl.Libs.Eo)] public static extern IntPtr
efl_ref(IntPtr eo); efl_ref(IntPtr eo);
[DllImport(efl.Libs.Eo)] public static extern void [DllImport(efl.Libs.CustomExports)] public static extern void
efl_unref(IntPtr eo); efl_unref(IntPtr eo);
[DllImport(efl.Libs.Eo)] public static extern int
efl_ref_count(IntPtr eo);
[DllImport(efl.Libs.Eo)] public static extern IntPtr [DllImport(efl.Libs.Eo)] public static extern IntPtr
efl_class_new(IntPtr class_description, IntPtr base0); efl_class_new(IntPtr class_description, IntPtr base0);
[DllImport(efl.Libs.Eo)] public static extern IntPtr [DllImport(efl.Libs.Eo)] public static extern IntPtr
@ -55,12 +57,12 @@ public class Globals {
System.IntPtr obj, System.IntPtr obj,
IntPtr desc, IntPtr desc,
short priority, short priority,
efl.Event_Cb cb, Efl.EventCb cb,
System.IntPtr data); System.IntPtr data);
[DllImport(efl.Libs.Eo)] public static extern bool efl_event_callback_del( [DllImport(efl.Libs.Eo)] public static extern bool efl_event_callback_del(
System.IntPtr obj, System.IntPtr obj,
IntPtr desc, IntPtr desc,
efl.Event_Cb cb, Efl.EventCb cb,
System.IntPtr data); System.IntPtr data);
[DllImport(efl.Libs.Eo)] public static extern IntPtr [DllImport(efl.Libs.Eo)] public static extern IntPtr
efl_object_legacy_only_event_description_get([MarshalAs(UnmanagedType.LPStr)] String name); efl_object_legacy_only_event_description_get([MarshalAs(UnmanagedType.LPStr)] String name);
@ -83,36 +85,40 @@ public class Globals {
if(initializer != null) if(initializer != null)
description.class_initializer = Marshal.GetFunctionPointerForDelegate(initializer); description.class_initializer = Marshal.GetFunctionPointerForDelegate(initializer);
IntPtr description_ptr = eina.MemoryNative.Alloc(Marshal.SizeOf(description)); IntPtr description_ptr = Eina.MemoryNative.Alloc(Marshal.SizeOf(description));
Marshal.StructureToPtr(description, description_ptr, false); Marshal.StructureToPtr(description, description_ptr, false);
eina.Log.Debug("Going to register!"); Eina.Log.Debug("Going to register!");
IntPtr klass = efl.eo.Globals.efl_class_new(description_ptr, base_klass, IntPtr.Zero); IntPtr klass = Efl.Eo.Globals.efl_class_new(description_ptr, base_klass, IntPtr.Zero);
if(klass == IntPtr.Zero) if(klass == IntPtr.Zero)
eina.Log.Error("klass was not registered"); Eina.Log.Error("klass was not registered");
eina.Log.Debug("Registered?"); else
Eina.Log.Debug("Registered class successfully");
return klass; return klass;
} }
public static IntPtr instantiate_start(IntPtr klass, efl.IObject parent) public static IntPtr instantiate_start(IntPtr klass, Efl.Object parent)
{ {
eina.Log.Debug("Instantiating"); Eina.Log.Debug($"Instantiating from klass 0x{klass.ToInt64():x}");
System.IntPtr parent_ptr = System.IntPtr.Zero; System.IntPtr parent_ptr = System.IntPtr.Zero;
if(parent != null) if(parent != null)
parent_ptr = parent.raw_handle; parent_ptr = parent.NativeHandle;
System.IntPtr eo = efl.eo.Globals._efl_add_internal_start("file", 0, klass, parent_ptr, 1, 0); System.IntPtr eo = Efl.Eo.Globals._efl_add_internal_start("file", 0, klass, parent_ptr, 1, 0);
Console.WriteLine($"Eo instance right after internal_start 0x{eo.ToInt64():x} with refcount {Efl.Eo.Globals.efl_ref_count(eo)}");
Console.WriteLine($"Parent was 0x{parent_ptr.ToInt64()}");
return eo; return eo;
} }
public static IntPtr instantiate_end(IntPtr eo) { public static IntPtr instantiate_end(IntPtr eo) {
eina.Log.Debug("efl_add_internal_start returned"); Eina.Log.Debug("calling efl_add_internal_end");
eo = efl.eo.Globals._efl_add_end(eo, 1, 0); eo = Efl.Eo.Globals._efl_add_end(eo, 1, 0);
eina.Log.Debug("efl_add_end returned"); Eina.Log.Debug($"efl_add_end returned eo 0x{eo.ToInt64():x}");
return eo; return eo;
} }
public static void data_set(efl.eo.IWrapper obj) public static void data_set(Efl.Eo.IWrapper obj)
{ {
IntPtr pd = efl.eo.Globals.efl_data_scope_get(obj.raw_handle, obj.raw_klass); Eina.Log.Debug($"Calling data_scope_get with obj {obj.NativeHandle.ToInt64():x} and klass {obj.NativeClass.ToInt64():x}");
IntPtr pd = Efl.Eo.Globals.efl_data_scope_get(obj.NativeHandle, obj.NativeClass);
{ {
GCHandle gch = GCHandle.Alloc(obj); GCHandle gch = GCHandle.Alloc(obj);
EolianPD epd; EolianPD epd;
@ -120,13 +126,13 @@ public class Globals {
Marshal.StructureToPtr(epd, pd, false); Marshal.StructureToPtr(epd, pd, false);
} }
} }
public static efl.eo.IWrapper data_get(IntPtr pd) public static Efl.Eo.IWrapper data_get(IntPtr pd)
{ {
EolianPD epd = (EolianPD)Marshal.PtrToStructure(pd, typeof(EolianPD)); EolianPD epd = (EolianPD)Marshal.PtrToStructure(pd, typeof(EolianPD));
if(epd.pointer != IntPtr.Zero) if(epd.pointer != IntPtr.Zero)
{ {
GCHandle gch = GCHandle.FromIntPtr(epd.pointer); GCHandle gch = GCHandle.FromIntPtr(epd.pointer);
return (efl.eo.IWrapper)gch.Target; return (Efl.Eo.IWrapper)gch.Target;
} }
else else
return null; return null;
@ -137,7 +143,7 @@ public class Globals {
IntPtr ptr = IntPtr.Zero; IntPtr ptr = IntPtr.Zero;
if (!dict.TryGetValue(str, out ptr)) if (!dict.TryGetValue(str, out ptr))
{ {
ptr = eina.StringConversion.ManagedStringToNativeUtf8Alloc(str); ptr = Eina.StringConversion.ManagedStringToNativeUtf8Alloc(str);
dict[str] = ptr; dict[str] = ptr;
} }
@ -149,7 +155,7 @@ public class Globals {
IntPtr ptr = IntPtr.Zero; IntPtr ptr = IntPtr.Zero;
if (!dict.TryGetValue(str, out ptr)) if (!dict.TryGetValue(str, out ptr))
{ {
ptr = eina.Stringshare.eina_stringshare_add(str); ptr = Eina.Stringshare.eina_stringshare_add(str);
dict[str] = ptr; dict[str] = ptr;
} }
@ -160,7 +166,7 @@ public class Globals {
{ {
foreach(IntPtr ptr in dict.Values) foreach(IntPtr ptr in dict.Values)
{ {
eina.MemoryNative.Free(ptr); Eina.MemoryNative.Free(ptr);
} }
} }
@ -168,7 +174,7 @@ public class Globals {
{ {
foreach(IntPtr ptr in dict.Values) foreach(IntPtr ptr in dict.Values)
{ {
eina.Stringshare.eina_stringshare_del(ptr); Eina.Stringshare.eina_stringshare_del(ptr);
} }
} }
@ -178,27 +184,27 @@ public class Globals {
handle.Free(); handle.Free();
} }
public static System.Threading.Tasks.Task<eina.Value> WrapAsync(eina.Future future, CancellationToken token) public static System.Threading.Tasks.Task<Eina.Value> WrapAsync(Eina.Future future, CancellationToken token)
{ {
// Creates a task that will wait for SetResult for completion. // Creates a task that will wait for SetResult for completion.
// TaskCompletionSource is used to create tasks for 'external' Task sources. // TaskCompletionSource is used to create tasks for 'external' Task sources.
var tcs = new System.Threading.Tasks.TaskCompletionSource<eina.Value>(); var tcs = new System.Threading.Tasks.TaskCompletionSource<Eina.Value>();
// Flag to be passed to the cancell callback // Flag to be passed to the cancell callback
bool fulfilled = false; bool fulfilled = false;
future.Then((eina.Value received) => { future.Then((Eina.Value received) => {
lock (future) lock (future)
{ {
// Convert an failed Future to a failed Task. // Convert an failed Future to a failed Task.
if (received.GetValueType() == eina.ValueType.Error) if (received.GetValueType() == Eina.ValueType.Error)
{ {
eina.Error err; Eina.Error err;
received.Get(out err); received.Get(out err);
if (err == eina.Error.ECANCELED) if (err == Eina.Error.ECANCELED)
tcs.SetCanceled(); tcs.SetCanceled();
else else
tcs.TrySetException(new efl.FutureException(received)); tcs.TrySetException(new Efl.FutureException(received));
} }
else else
{ {
@ -213,7 +219,7 @@ public class Globals {
token.Register(() => { token.Register(() => {
lock (future) lock (future)
{ {
// Will trigger the Then callback above with an eina.Error // Will trigger the Then callback above with an Eina.Error
if (!fulfilled) if (!fulfilled)
future.Cancel(); future.Cancel();
} }
@ -238,11 +244,13 @@ public static class Config
public interface IWrapper public interface IWrapper
{ {
IntPtr raw_handle /// <summary>Pointer to internal Eo instance.</summary>
IntPtr NativeHandle
{ {
get; get;
} }
IntPtr raw_klass /// <summary>Pointer to internal Eo class.</summary>
IntPtr NativeClass
{ {
get; get;
} }
@ -265,42 +273,42 @@ public class MarshalTest<T, U> : ICustomMarshaler
{ {
public static ICustomMarshaler GetInstance(string cookie) public static ICustomMarshaler GetInstance(string cookie)
{ {
eina.Log.Debug("MarshalTest.GetInstace cookie " + cookie); Eina.Log.Debug("MarshalTest.GetInstace cookie " + cookie);
return new MarshalTest<T, U>(); return new MarshalTest<T, U>();
} }
public void CleanUpManagedData(object ManagedObj) public void CleanUpManagedData(object ManagedObj)
{ {
//eina.Log.Warning("MarshalTest.CleanUpManagedData not implemented"); //Eina.Log.Warning("MarshalTest.CleanUpManagedData not implemented");
//throw new NotImplementedException(); //throw new NotImplementedException();
} }
public void CleanUpNativeData(IntPtr pNativeData) public void CleanUpNativeData(IntPtr pNativeData)
{ {
//eina.Log.Warning("MarshalTest.CleanUpNativeData not implemented"); //Eina.Log.Warning("MarshalTest.CleanUpNativeData not implemented");
//throw new NotImplementedException(); //throw new NotImplementedException();
} }
public int GetNativeDataSize() public int GetNativeDataSize()
{ {
eina.Log.Debug("MarshalTest.GetNativeDataSize"); Eina.Log.Debug("MarshalTest.GetNativeDataSize");
return 0; return 0;
//return 8; //return 8;
} }
public IntPtr MarshalManagedToNative(object ManagedObj) public IntPtr MarshalManagedToNative(object ManagedObj)
{ {
eina.Log.Debug("MarshalTest.MarshallManagedToNative"); Eina.Log.Debug("MarshalTest.MarshallManagedToNative");
var r = ((IWrapper)ManagedObj).raw_handle; var r = ((IWrapper)ManagedObj).NativeHandle;
if (typeof(U) == typeof(OwnTag)) if (typeof(U) == typeof(OwnTag))
efl.eo.Globals.efl_ref(r); Efl.Eo.Globals.efl_ref(r);
return r; return r;
} }
public object MarshalNativeToManaged(IntPtr pNativeData) public object MarshalNativeToManaged(IntPtr pNativeData)
{ {
eina.Log.Debug("MarshalTest.MarshalNativeToManaged"); Eina.Log.Debug("MarshalTest.MarshalNativeToManaged");
if (typeof(U) != typeof(OwnTag)) if (typeof(U) != typeof(OwnTag))
efl.eo.Globals.efl_ref(pNativeData); Efl.Eo.Globals.efl_ref(pNativeData);
return Activator.CreateInstance(typeof(T), new System.Object[] {pNativeData}); return Activator.CreateInstance(typeof(T), new System.Object[] {pNativeData});
// return null; // return null;
} }
@ -308,13 +316,13 @@ public class MarshalTest<T, U> : ICustomMarshaler
public class StringPassOwnershipMarshaler : ICustomMarshaler { public class StringPassOwnershipMarshaler : ICustomMarshaler {
public object MarshalNativeToManaged(IntPtr pNativeData) { public object MarshalNativeToManaged(IntPtr pNativeData) {
var ret = eina.StringConversion.NativeUtf8ToManagedString(pNativeData); var ret = Eina.StringConversion.NativeUtf8ToManagedString(pNativeData);
eina.MemoryNative.Free(pNativeData); Eina.MemoryNative.Free(pNativeData);
return ret; return ret;
} }
public IntPtr MarshalManagedToNative(object managedObj) { public IntPtr MarshalManagedToNative(object managedObj) {
return eina.MemoryNative.StrDup((string)managedObj); return Eina.MemoryNative.StrDup((string)managedObj);
} }
public void CleanUpNativeData(IntPtr pNativeData) { public void CleanUpNativeData(IntPtr pNativeData) {
@ -339,11 +347,11 @@ public class StringPassOwnershipMarshaler : ICustomMarshaler {
public class StringKeepOwnershipMarshaler: ICustomMarshaler { public class StringKeepOwnershipMarshaler: ICustomMarshaler {
public object MarshalNativeToManaged(IntPtr pNativeData) { public object MarshalNativeToManaged(IntPtr pNativeData) {
return eina.StringConversion.NativeUtf8ToManagedString(pNativeData); return Eina.StringConversion.NativeUtf8ToManagedString(pNativeData);
} }
public IntPtr MarshalManagedToNative(object managedObj) { public IntPtr MarshalManagedToNative(object managedObj) {
return eina.StringConversion.ManagedStringToNativeUtf8Alloc((string)managedObj); return Eina.StringConversion.ManagedStringToNativeUtf8Alloc((string)managedObj);
} }
public void CleanUpNativeData(IntPtr pNativeData) { public void CleanUpNativeData(IntPtr pNativeData) {
@ -368,13 +376,13 @@ public class StringKeepOwnershipMarshaler: ICustomMarshaler {
public class StringsharePassOwnershipMarshaler : ICustomMarshaler { public class StringsharePassOwnershipMarshaler : ICustomMarshaler {
public object MarshalNativeToManaged(IntPtr pNativeData) { public object MarshalNativeToManaged(IntPtr pNativeData) {
var ret = eina.StringConversion.NativeUtf8ToManagedString(pNativeData); var ret = Eina.StringConversion.NativeUtf8ToManagedString(pNativeData);
eina.Stringshare.eina_stringshare_del(pNativeData); Eina.Stringshare.eina_stringshare_del(pNativeData);
return ret; return ret;
} }
public IntPtr MarshalManagedToNative(object managedObj) { public IntPtr MarshalManagedToNative(object managedObj) {
return eina.Stringshare.eina_stringshare_add((string)managedObj); return Eina.Stringshare.eina_stringshare_add((string)managedObj);
} }
public void CleanUpNativeData(IntPtr pNativeData) { public void CleanUpNativeData(IntPtr pNativeData) {
@ -399,11 +407,11 @@ public class StringsharePassOwnershipMarshaler : ICustomMarshaler {
public class StringshareKeepOwnershipMarshaler : ICustomMarshaler { public class StringshareKeepOwnershipMarshaler : ICustomMarshaler {
public object MarshalNativeToManaged(IntPtr pNativeData) { public object MarshalNativeToManaged(IntPtr pNativeData) {
return eina.StringConversion.NativeUtf8ToManagedString(pNativeData); return Eina.StringConversion.NativeUtf8ToManagedString(pNativeData);
} }
public IntPtr MarshalManagedToNative(object managedObj) { public IntPtr MarshalManagedToNative(object managedObj) {
return eina.Stringshare.eina_stringshare_add((string)managedObj); return Eina.Stringshare.eina_stringshare_add((string)managedObj);
} }
public void CleanUpNativeData(IntPtr pNativeData) { public void CleanUpNativeData(IntPtr pNativeData) {
@ -428,11 +436,11 @@ public class StringshareKeepOwnershipMarshaler : ICustomMarshaler {
public class StrbufPassOwnershipMarshaler : ICustomMarshaler { public class StrbufPassOwnershipMarshaler : ICustomMarshaler {
public object MarshalNativeToManaged(IntPtr pNativeData) { public object MarshalNativeToManaged(IntPtr pNativeData) {
return new eina.Strbuf(pNativeData, eina.Ownership.Managed); return new Eina.Strbuf(pNativeData, Eina.Ownership.Managed);
} }
public IntPtr MarshalManagedToNative(object managedObj) { public IntPtr MarshalManagedToNative(object managedObj) {
eina.Strbuf buf = managedObj as eina.Strbuf; Eina.Strbuf buf = managedObj as Eina.Strbuf;
buf.ReleaseOwnership(); buf.ReleaseOwnership();
return buf.Handle; return buf.Handle;
} }
@ -459,11 +467,11 @@ public class StrbufPassOwnershipMarshaler : ICustomMarshaler {
public class StrbufKeepOwnershipMarshaler: ICustomMarshaler { public class StrbufKeepOwnershipMarshaler: ICustomMarshaler {
public object MarshalNativeToManaged(IntPtr pNativeData) { public object MarshalNativeToManaged(IntPtr pNativeData) {
return new eina.Strbuf(pNativeData, eina.Ownership.Unmanaged); return new Eina.Strbuf(pNativeData, Eina.Ownership.Unmanaged);
} }
public IntPtr MarshalManagedToNative(object managedObj) { public IntPtr MarshalManagedToNative(object managedObj) {
eina.Strbuf buf = managedObj as eina.Strbuf; Eina.Strbuf buf = managedObj as Eina.Strbuf;
return buf.Handle; return buf.Handle;
} }
@ -500,18 +508,18 @@ public class EflException : Exception
} }
} }
/// <summary>Exception to be raised when a Task fails due to a failed eina.Future.</summary> /// <summary>Exception to be raised when a Task fails due to a failed Eina.Future.</summary>
public class FutureException : EflException public class FutureException : EflException
{ {
/// <summary>The error code returned by the failed eina.Future.</summary> /// <summary>The error code returned by the failed Eina.Future.</summary>
public eina.Error Error { get; private set; } public Eina.Error Error { get; private set; }
/// <summary>Construct a new exception from the eina.Error stored in the given eina.Value.</summary> /// <summary>Construct a new exception from the Eina.Error stored in the given Eina.Value.</summary>
public FutureException(eina.Value value) : base("Future failed.") public FutureException(Eina.Value value) : base("Future failed.")
{ {
if (value.GetValueType() != eina.ValueType.Error) if (value.GetValueType() != Eina.ValueType.Error)
throw new ArgumentException("FutureException must receive an eina.Value with eina.Error."); throw new ArgumentException("FutureException must receive an Eina.Value with Eina.Error.");
eina.Error err; Eina.Error err;
value.Get(out err); value.Get(out err);
Error = err; Error = err;
} }

View File

@ -51,29 +51,28 @@ public struct EolianPD
} }
#pragma warning disable 0169 #pragma warning disable 0169
public struct Evas_Object_Box_Layout public struct EvasObjectBoxLayout
{ {
IntPtr o; IntPtr o;
IntPtr priv; IntPtr priv;
IntPtr user_data; IntPtr user_data;
}; };
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)] [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
public struct Evas_Object_Box_Data public struct EvasObjectBoxData
{ {
} }
public delegate void Eina_Free_Cb(IntPtr data); public struct EvasObjectBoxOption {
public struct Evas_Object_Box_Option {
IntPtr obj; IntPtr obj;
[MarshalAsAttribute(UnmanagedType.U1)] bool max_reached; [MarshalAsAttribute(UnmanagedType.U1)] bool max_reached;
[MarshalAsAttribute(UnmanagedType.U1)] bool min_reached; [MarshalAsAttribute(UnmanagedType.U1)] bool min_reached;
evas.Coord alloc_size; Evas.Coord alloc_size;
}; };
#pragma warning restore 0169 #pragma warning restore 0169
namespace efl { namespace Efl {
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct Event_Description { public struct EventDescription {
public IntPtr Name; public IntPtr Name;
[MarshalAs(UnmanagedType.U1)] public bool Unfreezable; [MarshalAs(UnmanagedType.U1)] public bool Unfreezable;
[MarshalAs(UnmanagedType.U1)] public bool Legacy_is; [MarshalAs(UnmanagedType.U1)] public bool Legacy_is;
@ -81,7 +80,7 @@ public struct Event_Description {
private static Dictionary<string, IntPtr> descriptions = new Dictionary<string, IntPtr>(); private static Dictionary<string, IntPtr> descriptions = new Dictionary<string, IntPtr>();
public Event_Description(string name) public EventDescription(string name)
{ {
this.Name = GetNative(name); this.Name = GetNative(name);
this.Unfreezable = false; this.Unfreezable = false;
@ -93,10 +92,10 @@ public struct Event_Description {
{ {
if (!descriptions.ContainsKey(name)) if (!descriptions.ContainsKey(name))
{ {
IntPtr data = efl.eo.Globals.dlsym(efl.eo.Globals.RTLD_DEFAULT, name); IntPtr data = Efl.Eo.Globals.dlsym(Efl.Eo.Globals.RTLD_DEFAULT, name);
if (data == IntPtr.Zero) { if (data == IntPtr.Zero) {
string error = eina.StringConversion.NativeUtf8ToManagedString(efl.eo.Globals.dlerror()); string error = Eina.StringConversion.NativeUtf8ToManagedString(Efl.Eo.Globals.dlerror());
throw new Exception(error); throw new Exception(error);
} }
descriptions.Add(name, data); descriptions.Add(name, data);
@ -105,17 +104,10 @@ public struct Event_Description {
} }
}; };
public delegate void EventCb(System.IntPtr data, ref Event_StructInternal evt);
public delegate void Event_Cb(System.IntPtr data, ref Event_StructInternal evt);
#pragma warning disable 0169
public struct Dbg_Info {
IntPtr name;
IntPtr value;
};
#pragma warning restore 0169
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct Text_Cursor_Cursor { public struct TextCursorCursor {
IntPtr obj; IntPtr obj;
UIntPtr pos; // UIntPtr to automatically change size_t between 32/64 UIntPtr pos; // UIntPtr to automatically change size_t between 32/64
IntPtr node; IntPtr node;
@ -123,7 +115,7 @@ public struct Text_Cursor_Cursor {
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct Text_Annotate_Annotation { public struct TextAnnotateAnnotation {
IntPtr list; IntPtr list;
IntPtr obj; IntPtr obj;
IntPtr start_node; IntPtr start_node;
@ -131,40 +123,36 @@ public struct Text_Annotate_Annotation {
[MarshalAsAttribute(UnmanagedType.U1)]bool is_item; [MarshalAsAttribute(UnmanagedType.U1)]bool is_item;
} }
public delegate void Signal_Cb(IntPtr data, IntPtr obj, IntPtr emission, IntPtr source); public delegate void SignalCb(IntPtr data, IntPtr obj, IntPtr emission, IntPtr source);
namespace access { namespace Access {
public struct Action_Data { public struct ActionData {
public IntPtr name; public IntPtr name;
public IntPtr action; public IntPtr action;
public IntPtr param; public IntPtr param;
public IntPtr func; public IntPtr func;
} }
} // namespace access public struct StateSet {
private ulong val;
} // namespace efl public static implicit operator StateSet(ulong x)
namespace evas { namespace font {
}
// C# does not allow typedefs, so we use these implicit conversions.
public struct Modifier_Mask {
private ulong mask;
public static implicit operator Modifier_Mask(ulong x)
{ {
return new Modifier_Mask{mask=x}; return new StateSet{val=x};
} }
public static implicit operator ulong(Modifier_Mask x) public static implicit operator ulong(StateSet x)
{ {
return x.mask; return x.val;
} }
} }
} // namespace Access
} // namespace Efl
namespace Evas {
public struct Coord { public struct Coord {
int val; int val;
@ -177,37 +165,8 @@ public struct Coord {
} }
} }
}
public struct Efl_Font_Size {
int val;
public Efl_Font_Size(int value) { val = value; }
static public implicit operator Efl_Font_Size(int val) {
return new Efl_Font_Size(val);
}
static public implicit operator int(Efl_Font_Size coord) {
return coord.val;
}
}
namespace eina {
[StructLayout(LayoutKind.Sequential)]
public struct Rectangle {
public int x;
public int y;
public int w;
public int h;
}
}
namespace evas {
/* Copied from Evas_Legacy.h */ /* Copied from Evas_Legacy.h */
public enum Text_Style_Type public enum TextStyleType
{ {
///<summary> plain, standard text.</summary> ///<summary> plain, standard text.</summary>
Plain = 0, Plain = 0,
@ -249,246 +208,19 @@ public enum Text_Style_Type
ShadowDirectionRight = 112 /* 7 >> 4 */ ShadowDirectionRight = 112 /* 7 >> 4 */
}; };
// Copied from Evas_Common.h } // namespace Evas
//
//
//
public enum Callback_Type
{
///<summary> Mouse In Event.</summary>
EVAS_CALLBACK_MOUSE_IN = 0,
///<summary> Mouse Out Event.</summary>
EVAS_CALLBACK_MOUSE_OUT,
///<summary> Mouse Button Down Event.</summary>
EVAS_CALLBACK_MOUSE_DOWN,
///<summary> Mouse Button Up Event.</summary>
EVAS_CALLBACK_MOUSE_UP,
///<summary> Mouse Move Event.</summary>
EVAS_CALLBACK_MOUSE_MOVE,
///<summary> Mouse Wheel Event.</summary>
EVAS_CALLBACK_MOUSE_WHEEL,
///<summary> Multi-touch Down Event.</summary>
EVAS_CALLBACK_MULTI_DOWN,
///<summary> Multi-touch Up Event.</summary>
EVAS_CALLBACK_MULTI_UP,
///<summary> Multi-touch Move Event.</summary>
EVAS_CALLBACK_MULTI_MOVE,
///<summary> Object Being Freed (Called after Del).</summary>
EVAS_CALLBACK_FREE,
///<summary> Key Press Event.</summary>
EVAS_CALLBACK_KEY_DOWN,
///<summary> Key Release Event.</summary>
EVAS_CALLBACK_KEY_UP,
///<summary> Focus In Event.</summary>
EVAS_CALLBACK_FOCUS_IN,
///<summary> Focus Out Event.</summary>
EVAS_CALLBACK_FOCUS_OUT,
///<summary> Show Event.</summary>
EVAS_CALLBACK_SHOW,
///<summary> Hide Event.</summary>
EVAS_CALLBACK_HIDE,
///<summary> Move Event.</summary>
EVAS_CALLBACK_MOVE,
///<summary> Resize Event.</summary>
EVAS_CALLBACK_RESIZE,
///<summary> Restack Event.</summary>
EVAS_CALLBACK_RESTACK,
///<summary> Object Being Deleted (called before Free).</summary>
EVAS_CALLBACK_DEL,
///<summary> Events go on/off hold.</summary>
EVAS_CALLBACK_HOLD,
///<summary> Size hints changed event.</summary>
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
///<summary> Image has been preloaded.</summary>
EVAS_CALLBACK_IMAGE_PRELOADED,
///<summary> Canvas got focus as a whole.</summary>
EVAS_CALLBACK_CANVAS_FOCUS_IN,
///<summary> Canvas lost focus as a whole.</summary>
EVAS_CALLBACK_CANVAS_FOCUS_OUT,
///<summary>Called after render update regions have been calculated,
/// but only if update regions exist.</summary>
EVAS_CALLBACK_RENDER_FLUSH_PRE,
///<summary>Called after render update regions have
/// been sent to the display server, but only
/// if update regions existed for the most recent frame.</summary>
EVAS_CALLBACK_RENDER_FLUSH_POST,
///<summary> Canvas object got focus.</summary>
EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
///<summary> Canvas object lost focus.</summary>
EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
///<summary> Image data has been unloaded (by some mechanism in Evas that throw out original image data).</summary>
EVAS_CALLBACK_IMAGE_UNLOADED,
///<summary> Called just before rendering starts on the canvas target. @since 1.2.</summary>
EVAS_CALLBACK_RENDER_PRE,
///<summary> Called just after rendering stops on the canvas target. @since 1.2.</summary>
EVAS_CALLBACK_RENDER_POST,
///<summary> Image size is changed. @since 1.8.</summary>
EVAS_CALLBACK_IMAGE_RESIZE,
///<summary> Devices added, removed or changed on canvas. @since 1.8.</summary>
EVAS_CALLBACK_DEVICE_CHANGED,
///<summary> Input device changed value on some axis. @since 1.13.</summary>
EVAS_CALLBACK_AXIS_UPDATE,
///<summary> Canvas viewport resized. @since 1.15.</summary>
EVAS_CALLBACK_CANVAS_VIEWPORT_RESIZE,
///<summary>Sentinel value to indicate last enum field during iteration.</summary>
EVAS_CALLBACK_LAST
};
}
namespace elm {
namespace atspi {
public struct State_Set {
private ulong val;
public static implicit operator State_Set(ulong x)
{
return new State_Set{val=x};
}
public static implicit operator ulong(State_Set x)
{
return x.val;
}
}
[StructLayout(LayoutKind.Sequential)]
public struct Relation_Set
{
public IntPtr pointer; // list<ptr(elm.atspi.Relation)>
}
} // namespace atspi
namespace gengrid { namespace item {
[StructLayout(LayoutKind.Sequential)]
public struct Class
{
int version;
uint refcount;
[MarshalAsAttribute(UnmanagedType.U1)]bool delete_me;
IntPtr item_style;
IntPtr decorate_item_style;
IntPtr decorate_all_item_style;
// Delegates inside Elm_Gen_Item_Class_Functions
IntPtr text_get;
IntPtr content_get;
IntPtr state_get;
IntPtr del;
IntPtr filter_get;
IntPtr reusable_content_get;
}
} // namespace item
} // namespace gengrid
namespace genlist { namespace item {
[StructLayout(LayoutKind.Sequential)]
public struct Class
{
int version;
uint refcount;
[MarshalAsAttribute(UnmanagedType.U1)]bool delete_me;
IntPtr item_style;
IntPtr decorate_item_style;
IntPtr decorate_all_item_style;
// Delegates inside Elm_Gen_Item_Class_Functions
IntPtr text_get;
IntPtr content_get;
IntPtr state_get;
IntPtr del;
IntPtr filter_get;
IntPtr reusable_content_get;
}
} // namespace item
} // namespace genlist
} // namespace elm
// Global delegates // Global delegates
public delegate IntPtr list_data_get_func_type(IntPtr l);
public delegate void region_hook_func_type(IntPtr data, IntPtr obj);
public delegate void slider_freefunc_type(IntPtr data);
public delegate void slider_func_type(double val);
public delegate int Eina_Compare_Cb(IntPtr a, IntPtr b); public delegate int Eina_Compare_Cb(IntPtr a, IntPtr b);
public delegate void Elm_Interface_Scrollable_Cb(IntPtr obj, IntPtr data); public delegate void ElmInterfaceScrollableCb(IntPtr obj, IntPtr data);
public delegate void Elm_Interface_Scrollable_Min_Limit_Cb(IntPtr obj, public delegate void ElmInterfaceScrollableMinLimitCb(IntPtr obj,
[MarshalAsAttribute(UnmanagedType.U1)]bool w, [MarshalAsAttribute(UnmanagedType.U1)]bool w,
[MarshalAsAttribute(UnmanagedType.U1)]bool h); [MarshalAsAttribute(UnmanagedType.U1)]bool h);
public delegate void Elm_Interface_Scrollable_Resize_Cb(IntPtr obj, evas.Coord w, evas.Coord h); public delegate void ElmInterfaceScrollableResizeCb(IntPtr obj, Evas.Coord w, Evas.Coord h);
public delegate void Elm_Entry_Item_Provider_Cb(IntPtr data, IntPtr obj, IntPtr item);
public delegate void Elm_Entry_Filter_Cb(IntPtr data, IntPtr obj, IntPtr text);
[return: MarshalAsAttribute(UnmanagedType.U1)] [return: MarshalAsAttribute(UnmanagedType.U1)]
public delegate bool Elm_Multibuttonentry_Item_Filter_Cb(IntPtr obj, IntPtr item_label, IntPtr item_data, IntPtr data); public delegate bool ElmMultibuttonentryItemFilterCb(IntPtr obj, IntPtr item_label, IntPtr item_data, IntPtr data);
public delegate IntPtr Elm_Multibuttonentry_Format_Cb(int count, IntPtr data); public delegate IntPtr ElmMultibuttonentryFormatCb(int count, IntPtr data);
[return: MarshalAsAttribute(UnmanagedType.U1)] public delegate void EinaFreeCb(IntPtr data);
public delegate bool Elm_Fileselector_Filter_Func(IntPtr path, [MarshalAsAttribute(UnmanagedType.U1)]bool dir, IntPtr data); public delegate void EvasSmartCb(IntPtr data, IntPtr obj, IntPtr event_info);
public delegate void Evas_Smart_Cb(IntPtr data, IntPtr obj, IntPtr event_info); public delegate void ElmObjectItemSignalCb(IntPtr data, IntPtr item, IntPtr emission, IntPtr source);
public delegate void Elm_Gesture_Event_Cb(IntPtr data, IntPtr event_info); public delegate void ElmTooltipItemContentCb(IntPtr data, IntPtr obj, IntPtr tooltip, IntPtr item);
public delegate void Elm_Object_Item_Signal_Cb(IntPtr data, IntPtr item, IntPtr emission, IntPtr source);
public delegate void Elm_Tooltip_Item_Content_Cb(IntPtr data, IntPtr obj, IntPtr tooltip, IntPtr item);
public delegate void Elm_Sys_Notify_Send_Cb(IntPtr data, uint id);
public delegate IntPtr Elm_Calendar_Format_Cb(IntPtr format);
namespace edje {
public delegate void Signal_Cb(IntPtr data, IntPtr obj, IntPtr emission, IntPtr source);
public delegate void Markup_Filter_Cb(IntPtr data, IntPtr obj, IntPtr part, IntPtr text );
public delegate void Item_Provider_Cb(IntPtr data, IntPtr obj, IntPtr part, IntPtr item);
// Message_Handler_Cb is now legacy
namespace text {
public delegate void Filter_Cb(IntPtr data, IntPtr obj, IntPtr part, int _type, IntPtr text);
public delegate void Change_Cb(IntPtr data, IntPtr obj, IntPtr part);
}
} // namespace edje
public enum Elm_Code_Status_Type {
ELM_CODE_STATUS_TYPE_DEFAULT = 0,
ELM_CODE_STATUS_TYPE_CURRENT,
ELM_CODE_STATUS_TYPE_IGNORED,
ELM_CODE_STATUS_TYPE_NOTE,
ELM_CODE_STATUS_TYPE_WARNING,
ELM_CODE_STATUS_TYPE_ERROR,
ELM_CODE_STATUS_TYPE_FATAL,
ELM_CODE_STATUS_TYPE_ADDED,
ELM_CODE_STATUS_TYPE_REMOVED,
ELM_CODE_STATUS_TYPE_CHANGED,
ELM_CODE_STATUS_TYPE_PASSED,
ELM_CODE_STATUS_TYPE_FAILED,
ELM_CODE_STATUS_TYPE_TODO,
ELM_CODE_STATUS_TYPE_COUNT
};
[StructLayout(LayoutKind.Sequential)]
public struct Elm_Atspi_Action
{
IntPtr name;
IntPtr action;
IntPtr param;
IntPtr func;
}
[StructLayout(LayoutKind.Sequential)]
public struct Tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
}
public delegate IntPtr Efl_Ui_Calendar_Format_Cb(Tm stime); // struct tm as argument

View File

@ -391,6 +391,25 @@ ecore_ecore_ipc_server_example_CPPFLAGS = $(ECORE_COMMON_CPPFLAGS) $(AM_CPPFLAGS
ecore_ecore_ipc_client_example_SOURCES = ecore/ecore_ipc_client_example.c ecore_ecore_ipc_client_example_SOURCES = ecore/ecore_ipc_client_example.c
ecore_ecore_ipc_client_example_CPPFLAGS = $(ECORE_COMMON_CPPFLAGS) $(AM_CPPFLAGS) ecore_ecore_ipc_client_example_CPPFLAGS = $(ECORE_COMMON_CPPFLAGS) $(AM_CPPFLAGS)
if HAVE_CSHARP
if HAVE_WIN32
MCSFLAGS ?=
MCSFLAGS += -define:WIN32
endif
EXTRA_PROGRAMS += \
ecore/efl_mono_loop_timer_example
ecore_efl_mono_loop_timer_example_SOURCES = \
ecore/efl_mono_loop_timer_example.cs
ecore/efl_mono_loop_timer_example$(EXEEXT): $(ecore_efl_mono_loop_timer_example_SOURCES) $(am_dirstamp) $(top_builddir)/src/lib/efl_mono/libefl_mono.dll
@rm -f ecore/efl_mono_loop_timer_example$(EXEEXT)
$(AM_V_MCS) $(MCS) $(MCSFLAGS) -r:$(abs_top_builddir)/src/lib/efl_mono/libefl_mono.dll -out:$@ $(filter %.cs, $(^))
endif
ECORE_SRCS = \ ECORE_SRCS = \
ecore/ecore_animator_example.c \ ecore/ecore_animator_example.c \

View File

@ -1,43 +0,0 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
class TestMain
{
/* private efl.Loop loop; */
public TestMain(efl.Loop loop)
{
/* this.loop = loop; */
}
static void Main(string[] args)
{
efl.All.Init();
efl.Loop loop = new efl.LoopConcrete();
TestMain listener = new TestMain(loop);
loop.CALLBACK_ADD += listener.callback_added_cb;
loop.CALLBACK_ADD += listener.on_idle_enter;
loop.CALLBACK_ADD -= listener.on_idle_enter;
loop.IDLE += listener.on_idle_enter; // Will trigger CALLBACK_ADD
efl.All.Shutdown();
}
public void on_idle_enter(object sender, EventArgs e)
{
Console.WriteLine("I should not be called while the loop is not running...");
}
public void callback_added_cb(object sender, EventArgs e)
{
Console.WriteLine("Looks like we added a new callback.");
}
}

View File

@ -4,10 +4,10 @@ using System.Runtime.CompilerServices;
class TestMain class TestMain
{ {
private efl.Loop loop; private Efl.Loop loop;
private int count; private int count;
public TestMain(efl.Loop loop) public TestMain(Efl.Loop loop)
{ {
this.loop = loop; this.loop = loop;
this.count = 0; this.count = 0;
@ -15,32 +15,35 @@ class TestMain
static void Main(string[] args) static void Main(string[] args)
{ {
efl.All.Init(); Efl.All.Init();
efl.Loop loop = new efl.LoopConcrete(); var loop = new Efl.Loop();
efl.loop.Timer timer = new efl.loop.TimerConcrete(loop); var timer = new Efl.LoopTimer(loop, (Efl.LoopTimer t) => {
t.SetInterval(1.0);
});
TestMain listener = new TestMain(loop); TestMain listener = new TestMain(loop);
Console.WriteLine("Starting MainLoop"); Console.WriteLine("Starting MainLoop");
timer.interval_set(1.0); timer.TickEvt += listener.on_tick;
timer.TickEvt += listener.another_callback;
timer.TickEvt -= listener.another_callback;
timer.TICK += listener.on_tick; loop.Begin();
timer.TICK += listener.another_callback;
timer.TICK -= listener.another_callback;
loop.begin(); Efl.All.Shutdown();
efl.All.Shutdown();
} }
public void on_tick(object sender, EventArgs e) public void on_tick(object sender, EventArgs e)
{ {
Console.WriteLine("on_tick called on listener"); Console.WriteLine("on_tick called on listener");
if (count++ == 5) if (count++ == 5) {
loop.quit(0); Eina.Value v = new Eina.Value(Eina.ValueType.Int32);
v.Set(0);
loop.Quit(v);
}
} }
public void another_callback(object sender, EventArgs e) public void another_callback(object sender, EventArgs e)

View File

@ -1,8 +1,8 @@
using static System.Console; using static System.Console;
class PlusTenNumberWrapper : example.NumberwrapperInherit class PlusTenNumberWrapper : Example.Numberwrapper
{ {
public PlusTenNumberWrapper(efl.IObject parent = null) public PlusTenNumberWrapper(Efl.Object parent = null)
: base(parent) : base(parent)
{} {}
@ -20,8 +20,8 @@ public class ExampleEoInherit01
{ {
public static void Main() public static void Main()
{ {
eina.Config.Init(); Eina.Config.Init();
efl.eo.Config.Init(); Efl.Eo.Config.Init();
var inheritObj = new PlusTenNumberWrapper(); var inheritObj = new PlusTenNumberWrapper();
@ -52,7 +52,7 @@ public class ExampleEoInherit01
WriteLine("## Using original object ##\n"); WriteLine("## Using original object ##\n");
// Check original EFL object // Check original EFL object
var origObj = new example.Numberwrapper(); var origObj = new Example.Numberwrapper();
given = 111; given = 111;
origObj.SetNumber(given); origObj.SetNumber(given);
stored = origObj.GetNumber(); stored = origObj.GetNumber();

View File

@ -12,10 +12,10 @@ public class ExampleFunctionPointer01
public static void Main() public static void Main()
{ {
eina.Config.Init(); Eina.Config.Init();
efl.eo.Config.Init(); Efl.Eo.Config.Init();
var obj = new example.Numberwrapper(); var obj = new Example.Numberwrapper();
// Set internal value // Set internal value
obj.SetNumber(12); obj.SetNumber(12);

View File

@ -4,7 +4,7 @@ public class ExampleEinaArray01
{ {
public static void Main() public static void Main()
{ {
eina.Config.Init(); Eina.Config.Init();
var strings = new string[]{ var strings = new string[]{
"helo", "hera", "starbuck", "kat", "boomer", "helo", "hera", "starbuck", "kat", "boomer",
@ -13,7 +13,7 @@ public class ExampleEinaArray01
"skulls", "bulldog", "flat top", "hammerhead", "gonzo" "skulls", "bulldog", "flat top", "hammerhead", "gonzo"
}; };
var array = new eina.Array<string>(20U); var array = new Eina.Array<string>(20U);
// Push new elements // Push new elements
foreach (string s in strings) foreach (string s in strings)

View File

@ -4,11 +4,11 @@ public class ExampleEinaBinbuf01
{ {
public static void Main() public static void Main()
{ {
eina.Config.Init(); Eina.Config.Init();
var bytes = new byte[]{0, 1, 2, 3, 4, 5, 6}; var bytes = new byte[]{0, 1, 2, 3, 4, 5, 6};
var bb = new eina.Binbuf(); var bb = new Eina.Binbuf();
// Append initial bytes // Append initial bytes
bb.Append(bytes); bb.Append(bytes);

View File

@ -3,73 +3,73 @@ using static System.Console;
public class ExampleEinaError01 public class ExampleEinaError01
{ {
private static bool RegisteredErrors = false; private static bool RegisteredErrors = false;
private static eina.Error MyErrorNegative; private static Eina.Error MyErrorNegative;
private static eina.Error MyErrorNull; private static Eina.Error MyErrorNull;
private static void testFunc(int n, string s) private static void testFunc(int n, string s)
{ {
if (!RegisteredErrors) if (!RegisteredErrors)
{ {
MyErrorNegative = eina.Error.Register("Negative number"); MyErrorNegative = Eina.Error.Register("Negative number");
MyErrorNull = eina.Error.Register("NULL pointer"); MyErrorNull = Eina.Error.Register("NULL pointer");
RegisteredErrors = true; RegisteredErrors = true;
} }
if (n < 0) if (n < 0)
{ {
eina.Error.Set(MyErrorNegative); Eina.Error.Set(MyErrorNegative);
return; return;
} }
if (s == null) if (s == null)
{ {
eina.Error.Set(MyErrorNull); Eina.Error.Set(MyErrorNull);
return; return;
} }
} }
public static void Main() public static void Main()
{ {
eina.Config.Init(); Eina.Config.Init();
efl.eo.Config.Init(); Efl.Eo.Config.Init();
// Handling Eina_Error with exception // Handling Eina_Error with exception
try try
{ {
testFunc(-1, "abc"); testFunc(-1, "abc");
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
} }
catch(efl.EflException e) catch(Efl.EflException e)
{ {
WriteLine($"Caught error: {e.Message}"); WriteLine($"Caught error: {e.Message}");
} }
// Handling Eina_Error directly // Handling Eina_Error directly
testFunc(42, null); testFunc(42, null);
eina.Error err = eina.Error.Get(); Eina.Error err = Eina.Error.Get();
if (err != 0) if (err != 0)
{ {
WriteLine($"Error set: {err.Message}"); WriteLine($"Error set: {err.Message}");
} }
eina.Error.Clear(); Eina.Error.Clear();
// No error set // No error set
try try
{ {
testFunc(42, "abc"); testFunc(42, "abc");
eina.Error.RaiseIfOccurred(); Eina.Error.RaiseIfOccurred();
err = eina.Error.Get(); err = Eina.Error.Get();
WriteLine($"Really no error? {err == eina.Error.NO_ERROR}."); WriteLine($"Really no error? {err == Eina.Error.NO_ERROR}.");
} }
catch catch
{ {
WriteLine("Unspected error!!!"); WriteLine("Unspected error!!!");
} }
WriteLine("No error message is empty string: \"{0}\"", eina.Error.NO_ERROR.Message); WriteLine("No error message is empty string: \"{0}\"", Eina.Error.NO_ERROR.Message);
WriteLine("No error message is empty string: \"{0}\"", eina.Error.MsgGet(0)); WriteLine("No error message is empty string: \"{0}\"", Eina.Error.MsgGet(0));
} }
} }

View File

@ -4,9 +4,9 @@ public class ExampleEinaHash01
{ {
public static void Main() public static void Main()
{ {
eina.Config.Init(); Eina.Config.Init();
var phone_book = new eina.Hash<string, string>(); var phone_book = new Eina.Hash<string, string>();
// Add initial entries to our hash // Add initial entries to our hash
phone_book.Add("Wolfgang Amadeus Mozart", "+01 23 456-78910"); phone_book.Add("Wolfgang Amadeus Mozart", "+01 23 456-78910");

View File

@ -2,20 +2,20 @@ using System;
public class Example public class Example
{ {
public static efl.ui.IButton CreateButton(efl.IObject parent, public static Efl.Ui.Button CreateButton(Efl.Object parent,
string text, string text,
int w, int h, int w, int h,
EventHandler callback) { EventHandler callback) {
efl.ui.IButton button = new efl.ui.Button(parent); Efl.Ui.Button button = new Efl.Ui.Button(parent);
button.SetText(text); button.SetText(text);
button.SetSize(new eina.Size2D(w, h)); button.SetSize(new Eina.Size2D(w, h));
button.ClickedEvt += callback; ((Efl.Ui.Clickable)button).ClickedEvt += callback;
return button; return button;
} }
public static void Formatter(eina.Strbuf buf, eina.Value val){ public static void Formatter(Eina.Strbuf buf, Eina.Value val){
double ratio; double ratio;
if (val.Get(out ratio)) { if (val.Get(out ratio)) {
buf.Append($"{(int)(ratio*100)}%"); buf.Append($"{(int)(ratio*100)}%");
@ -34,27 +34,27 @@ public class Example
int W = 120; int W = 120;
int H = 30; int H = 30;
efl.All.Init(efl.Components.Ui); Efl.All.Init(Efl.Components.Ui);
efl.ui.Win win = new efl.ui.Win(null); Efl.Ui.Win win = new Efl.Ui.Win(null);
win.SetText("Hello, C#!!"); win.SetText("Hello, C#!!");
win.SetAutohide(true); win.SetAutohide(true);
efl.ui.Box_Flow box = new efl.ui.Box_Flow(win); Efl.Ui.BoxFlow box = new Efl.Ui.BoxFlow(win);
efl.ui.IButton button = CreateButton(box, "Click to exit", 120, 30, Efl.Ui.Button button = CreateButton(box, "Click to exit", 120, 30,
(object sender, EventArgs e) => { (object sender, EventArgs e) => {
efl.ui.Config.Exit(); Efl.Ui.Config.Exit();
}); });
box.DoPack(button); box.DoPack(button);
efl.ui.Progressbar bar = new efl.ui.Progressbar(box); Efl.Ui.Progressbar bar = new Efl.Ui.Progressbar(box);
bar.SetSize(new eina.Size2D(W, H)); bar.SetSize(new Eina.Size2D(W, H));
bar.SetFormatCb(Formatter); bar.SetFormatCb(Formatter);
efl.ui.ISlider slider = new efl.ui.Slider(box); Efl.Ui.Slider slider = new Efl.Ui.Slider(box);
slider.SetSize(new eina.Size2D(W, H)); slider.SetSize(new Eina.Size2D(W, H));
slider.ChangedEvt += (object sender, EventArgs e) => { slider.ChangedEvt += (object sender, EventArgs e) => {
bar.SetRangeValue(slider.GetRangeValue()); bar.SetRangeValue(slider.GetRangeValue());
@ -66,12 +66,12 @@ public class Example
button.SetVisible(true); button.SetVisible(true);
box.SetVisible(true); box.SetVisible(true);
win.SetSize(new eina.Size2D(W, 3 * H)); win.SetSize(new Eina.Size2D(W, 3 * H));
win.SetVisible(true); win.SetVisible(true);
efl.ui.Config.Run(); Efl.Ui.Config.Run();
efl.All.Shutdown(); Efl.All.Shutdown();
} }
} }

View File

@ -14,16 +14,16 @@ public class Example
return miles * KMS_PER_MILE; return miles * KMS_PER_MILE;
} }
private static void ShowErrorPopup(efl.ui.Win win, string message) private static void ShowErrorPopup(Efl.Ui.Win win, string message)
{ {
efl.ui.IAlert_Popup popup = new efl.ui.Alert_Popup(win); Efl.Ui.AlertPopup popup = new Efl.Ui.AlertPopup(win);
efl.ui.Text popup_text = new efl.ui.Text(popup); Efl.Ui.Text popup_text = new Efl.Ui.Text(popup);
popup_text.SetText($"Error: {message}"); popup_text.SetText($"Error: {message}");
popup.SetContent(popup_text); popup.SetContent(popup_text);
popup.SetVisible(true); popup.SetVisible(true);
popup.SetButton(efl.ui.Alert_Popup_Button.Positive, "Ok", null); popup.SetButton(Efl.Ui.AlertPopupButton.Positive, "Ok", null);
popup.SetSize(new eina.Size2D(150, 30)); popup.SetSize(new Eina.Size2D(150, 30));
popup.ButtonClickedEvt += (object sender, efl.ui.Alert_Popup.ButtonClickedEvt_Args e) => { popup.ButtonClickedEvt += (object sender, Efl.Ui.AlertPopupButtonClickedEvt_Args e) => {
popup.SetParent(null); popup.SetParent(null);
popup.Invalidate(); popup.Invalidate();
}; };
@ -37,34 +37,34 @@ public class Example
public static void Main() { public static void Main() {
int W = 120; int W = 120;
int H = 30; int H = 30;
eina.Size2D size = new eina.Size2D(W, H); Eina.Size2D size = new Eina.Size2D(W, H);
efl.All.Init(efl.Components.Ui); Efl.All.Init(Efl.Components.Ui);
efl.ui.Win win = new efl.ui.Win(null); Efl.Ui.Win win = new Efl.Ui.Win(null);
win.SetText("C# Unit Converter"); win.SetText("C# Unit Converter");
win.SetAutohide(true); win.SetAutohide(true);
efl.ui.Box_Flow box = new efl.ui.Box_Flow(win); Efl.Ui.BoxFlow box = new Efl.Ui.BoxFlow(win);
box.SetDirection(efl.ui.Dir.Horizontal); box.SetDirection(Efl.Ui.Dir.Horizontal);
efl.ui.Box_Flow miles_box = new efl.ui.Box_Flow(box); Efl.Ui.BoxFlow miles_box = new Efl.Ui.BoxFlow(box);
miles_box.SetDirection(efl.ui.Dir.Down); miles_box.SetDirection(Efl.Ui.Dir.Down);
box.DoPack(miles_box); box.DoPack(miles_box);
efl.ui.Text miles_label = new efl.ui.Text(miles_box); Efl.Ui.Text miles_label = new Efl.Ui.Text(miles_box);
miles_label.SetText("Miles:"); miles_label.SetText("Miles:");
miles_label.SetSize(size); miles_label.SetSize(size);
miles_label.SetVisible(true); miles_label.SetVisible(true);
efl.ui.Text_Editable miles_input = new efl.ui.Text_Editable(miles_box); Efl.Ui.TextEditable miles_input = new Efl.Ui.TextEditable(miles_box);
miles_input.SetText(""); miles_input.SetText("");
miles_input.SetScrollable(true); miles_input.SetScrollable(true);
miles_input.SetSize(size); miles_input.SetSize(size);
miles_input.SetVisible(true); miles_input.SetVisible(true);
efl.ui.IButton miles_button = new efl.ui.Button(miles_box); Efl.Ui.Button miles_button = new Efl.Ui.Button(miles_box);
miles_button.SetText("To Km"); miles_button.SetText("To Km");
miles_button.SetSize(size); miles_button.SetSize(size);
miles_button.SetVisible(true); miles_button.SetVisible(true);
@ -74,23 +74,23 @@ public class Example
miles_box.DoPack(miles_button); miles_box.DoPack(miles_button);
efl.ui.Box_Flow kms_box = new efl.ui.Box_Flow(box); Efl.Ui.BoxFlow kms_box = new Efl.Ui.BoxFlow(box);
kms_box.SetDirection(efl.ui.Dir.Down); kms_box.SetDirection(Efl.Ui.Dir.Down);
box.DoPack(kms_box); box.DoPack(kms_box);
efl.ui.Text kms_label = new efl.ui.Text(kms_box); Efl.Ui.Text kms_label = new Efl.Ui.Text(kms_box);
kms_label.SetText("Kilometers:"); kms_label.SetText("Kilometers:");
kms_label.SetSize(size); kms_label.SetSize(size);
kms_label.SetVisible(true); kms_label.SetVisible(true);
efl.ui.Text_Editable kms_input = new efl.ui.Text_Editable(kms_box); Efl.Ui.TextEditable kms_input = new Efl.Ui.TextEditable(kms_box);
kms_input.SetText(""); kms_input.SetText("");
kms_input.SetScrollable(true); kms_input.SetScrollable(true);
kms_input.SetSize(size); kms_input.SetSize(size);
kms_input.SetVisible(true); kms_input.SetVisible(true);
efl.ui.IButton kms_button = new efl.ui.Button(kms_box); Efl.Ui.Button kms_button = new Efl.Ui.Button(kms_box);
kms_button.SetText("To Miles"); kms_button.SetText("To Miles");
kms_button.SetSize(size); kms_button.SetSize(size);
kms_button.SetVisible(true); kms_button.SetVisible(true);
@ -99,7 +99,7 @@ public class Example
kms_box.DoPack(kms_input); kms_box.DoPack(kms_input);
kms_box.DoPack(kms_button); kms_box.DoPack(kms_button);
kms_button.ClickedEvt += (object sender, EventArgs e) => { ((Efl.Ui.Clickable)kms_button).ClickedEvt += (object sender, EventArgs e) => {
try try
{ {
string text = kms_input.GetText(); string text = kms_input.GetText();
@ -115,7 +115,7 @@ public class Example
} }
}; };
miles_button.ClickedEvt += (object sender, EventArgs e) => { ((Efl.Ui.Clickable)miles_button).ClickedEvt += (object sender, EventArgs e) => {
try try
{ {
string text = miles_input.GetText(); string text = miles_input.GetText();
@ -134,17 +134,17 @@ public class Example
kms_box.SetVisible(true); kms_box.SetVisible(true);
miles_box.SetVisible(true); miles_box.SetVisible(true);
box.SetPosition(new eina.Position2D(20, 30)); box.SetPosition(new Eina.Position2D(20, 30));
box.SetVisible(true); box.SetVisible(true);
win.SetPosition(new eina.Position2D(200, 200)); win.SetPosition(new Eina.Position2D(200, 200));
win.SetSize(new eina.Size2D(400, 120)); win.SetSize(new Eina.Size2D(400, 120));
win.SetVisible(true); win.SetVisible(true);
efl.ui.Config.Run(); Efl.Ui.Config.Run();
efl.All.Shutdown(); Efl.All.Shutdown();
} }
} }

View File

@ -2,9 +2,9 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
public class MyBox : evas.BoxInherit public class MyBox : Evas.Box
{ {
public MyBox(efl.IObject parent) : base(parent) {} public MyBox(Efl.Object parent) : base(parent) {}
[DllImport("evas")] static extern void evas_obj_box_layout_vertical(IntPtr obj, IntPtr data, IntPtr privdata); [DllImport("evas")] static extern void evas_obj_box_layout_vertical(IntPtr obj, IntPtr data, IntPtr privdata);
[DllImport("evas")] static extern void evas_obj_box_layout_horizontal(IntPtr obj, IntPtr data, IntPtr privdata); [DllImport("evas")] static extern void evas_obj_box_layout_horizontal(IntPtr obj, IntPtr data, IntPtr privdata);
@ -15,11 +15,11 @@ public class MyBox : evas.BoxInherit
override public void CalculateGroup() override public void CalculateGroup()
{ {
IntPtr evas = evas_object_evas_get(raw_handle); IntPtr evas = evas_object_evas_get(NativeHandle);
evas_event_freeze(evas); evas_event_freeze(evas);
Console.WriteLine("called group_calculate"); Console.WriteLine("called group_calculate");
/* layouting_set(true); */ /* layouting_set(true); */
evas_obj_box_layout_vertical(raw_handle, IntPtr.Zero, IntPtr.Zero); evas_obj_box_layout_vertical(NativeHandle, IntPtr.Zero, IntPtr.Zero);
/* layouting_set(false); */ /* layouting_set(false); */
/* children_changed_set(false); */ /* children_changed_set(false); */
evas_event_thaw(evas); evas_event_thaw(evas);
@ -30,21 +30,21 @@ class TestMain
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
efl.All.Init(); Efl.All.Init();
efl.Loop loop = new efl.Loop(); Efl.Loop loop = new Efl.Loop();
EcoreEvas ecore_evas = new EcoreEvas(); EcoreEvas ecore_evas = new EcoreEvas();
efl.canvas.IObject canvas = ecore_evas.canvas; Efl.Canvas.Object canvas = ecore_evas.canvas;
canvas.SetVisible(true); canvas.SetVisible(true);
efl.IObject parent = canvas.GetParent(); Efl.Object parent = canvas.GetParent();
System.Diagnostics.Debug.Assert(parent.raw_handle != IntPtr.Zero); System.Diagnostics.Debug.Assert(parent.NativeHandle != IntPtr.Zero);
evas.IBox box = new MyBox(canvas); Evas.Box box = new MyBox(canvas);
eina.Size2D size = new eina.Size2D(); Eina.Size2D size = new Eina.Size2D();
size.W = 320; size.W = 320;
size.H = 240; size.H = 240;
@ -52,7 +52,7 @@ class TestMain
box.SetSize(size); box.SetSize(size);
box.SetVisible(true); box.SetVisible(true);
efl.canvas.Rectangle rect = new efl.canvas.Rectangle(canvas); Efl.Canvas.Rectangle rect = new Efl.Canvas.Rectangle(canvas);
rect.SetColor(0, 0, 255, 255); rect.SetColor(0, 0, 255, 255);
size.W = 320; size.W = 320;
size.H = 120; size.H = 120;
@ -60,7 +60,7 @@ class TestMain
rect.SetVisible(true); rect.SetVisible(true);
box.Append(rect); box.Append(rect);
efl.canvas.Rectangle rect2 = new efl.canvas.Rectangle(canvas); Efl.Canvas.Rectangle rect2 = new Efl.Canvas.Rectangle(canvas);
rect2.SetColor(0, 255, 0, 255); rect2.SetColor(0, 255, 0, 255);
rect2.SetSize(size); rect2.SetSize(size);
rect2.SetVisible(true); rect2.SetVisible(true);
@ -68,6 +68,6 @@ class TestMain
loop.Begin(); loop.Begin();
efl.All.Shutdown(); Efl.All.Shutdown();
} }
} }

View File

@ -6,7 +6,7 @@ class TestMain
static int WIDTH = 320; static int WIDTH = 320;
static int HEIGHT = 240; static int HEIGHT = 240;
evas.IImage image; Evas.Image image;
static string ImagePath([CallerFilePath] string folder="") static string ImagePath([CallerFilePath] string folder="")
@ -14,27 +14,27 @@ class TestMain
return System.IO.Path.GetDirectoryName(folder); return System.IO.Path.GetDirectoryName(folder);
} }
public TestMain(evas.IImage image) public TestMain(Evas.Image image)
{ {
this.image = image; this.image = image;
} }
static void Main(string[] args) static void Main(string[] args)
{ {
efl.All.Init(); Efl.All.Init();
efl.Loop loop = new efl.Loop(); Efl.Loop loop = new Efl.Loop();
EcoreEvas ecore_evas = new EcoreEvas(); EcoreEvas ecore_evas = new EcoreEvas();
eina.Size2D size = new eina.Size2D(); Eina.Size2D size = new Eina.Size2D();
efl.canvas.IObject canvas = ecore_evas.canvas; Efl.Canvas.Object canvas = ecore_evas.canvas;
canvas.SetVisible(true); canvas.SetVisible(true);
efl.IObject parent = canvas.GetParent(); Efl.Object parent = canvas.GetParent();
System.Diagnostics.Debug.Assert(parent.raw_handle != IntPtr.Zero); System.Diagnostics.Debug.Assert(parent.NativeHandle != IntPtr.Zero);
efl.canvas.Rectangle bg = new efl.canvas.Rectangle(canvas); Efl.Canvas.Rectangle bg = new Efl.Canvas.Rectangle(canvas);
bg.SetColor(255, 255, 255, 255); bg.SetColor(255, 255, 255, 255);
size.W = WIDTH; size.W = WIDTH;
size.H = HEIGHT; size.H = HEIGHT;
@ -42,15 +42,15 @@ class TestMain
bg.SetVisible(true); bg.SetVisible(true);
string valid_path = args[0]; string valid_path = args[0];
evas.Image image = new evas.Image(canvas); Evas.Image image = new Evas.Image(canvas);
image.SetFile(valid_path, null); image.SetFile(valid_path, null);
/* FIXME evas-image uses error handling code from /* FIXME evas-image uses error handling code from
* evas_object_image_load_error_get, which seems to be not available * evas_object_image_load_error_get, which seems to be not available
* efl.image.load.State state = image.load_error_get(); */ * Efl.image.load.State state = image.load_error_get(); */
// FIXME missing move // FIXME missing move
eina.Rect rect = new eina.Rect(); Eina.Rect rect = new Eina.Rect();
rect.X = 0; rect.X = 0;
rect.Y = 0; rect.Y = 0;
@ -75,13 +75,13 @@ class TestMain
/* EventListener callback = new EventListener(); */ /* EventListener callback = new EventListener(); */
/* bg.key_focus_set(true); */ /* bg.key_focus_set(true); */
/* bg.event_callback_priority_add(evas.Callback_Type.Key_down, */ /* bg.event_callback_priority_add(Evas.Callback_Type.Key_down, */
/* efl.Callback_Priority.Default, */ /* Efl.Callback_Priority.Default, */
/* callback, null); */ /* callback, null); */
loop.Begin(); loop.Begin();
efl.All.Shutdown(); Efl.All.Shutdown();
} }
public void on_key_down(object sender, EventArgs e) public void on_key_down(object sender, EventArgs e)

View File

@ -10,19 +10,19 @@ class TestMain
static void Main(string[] args) static void Main(string[] args)
{ {
efl.All.Init(); Efl.All.Init();
efl.Loop loop = new efl.Loop(); Efl.Loop loop = new Efl.Loop();
EcoreEvas ecore_evas = new EcoreEvas(); EcoreEvas ecore_evas = new EcoreEvas();
eina.Size2D size = new eina.Size2D(); Eina.Size2D size = new Eina.Size2D();
eina.Position2D pos = new eina.Position2D(); Eina.Position2D pos = new Eina.Position2D();
efl.canvas.IObject canvas = ecore_evas.canvas; Efl.Canvas.Object canvas = ecore_evas.canvas;
canvas.SetVisible(true); canvas.SetVisible(true);
efl.canvas.Rectangle bg = new efl.canvas.Rectangle(canvas); Efl.Canvas.Rectangle bg = new Efl.Canvas.Rectangle(canvas);
bg.SetColor(255, 255, 255, 255); bg.SetColor(255, 255, 255, 255);
pos.X = 0; pos.X = 0;
pos.Y = 0; pos.Y = 0;
@ -33,7 +33,7 @@ class TestMain
bg.SetVisible(true); bg.SetVisible(true);
string path = args[0]; string path = args[0];
evas.Image logo = new evas.Image(canvas); Evas.Image logo = new Evas.Image(canvas);
logo.SetFillAuto(true); logo.SetFillAuto(true);
// TODO add preloaded support (depends on events) // TODO add preloaded support (depends on events)
@ -53,7 +53,7 @@ class TestMain
pixels[i] = generator.Next(); pixels[i] = generator.Next();
} }
evas.Image noise_img = new evas.Image(canvas); Evas.Image noise_img = new Evas.Image(canvas);
size.W = WIDTH / 4; size.W = WIDTH / 4;
size.H = HEIGHT / 4; size.H = HEIGHT / 4;
noise_img.SetSize(size); noise_img.SetSize(size);
@ -66,7 +66,7 @@ class TestMain
noise_img.SetVisible(true); noise_img.SetVisible(true);
Console.WriteLine("Creating noise image with sizez %d, %d", WIDTH/4, HEIGHT/4); Console.WriteLine("Creating noise image with sizez %d, %d", WIDTH/4, HEIGHT/4);
efl.canvas.Proxy proxy_img = new efl.canvas.Proxy(canvas); Efl.Canvas.Proxy proxy_img = new Efl.Canvas.Proxy(canvas);
proxy_img.SetSource(noise_img); proxy_img.SetSource(noise_img);
pos.X = WIDTH / 2; pos.X = WIDTH / 2;
pos.Y = HEIGHT / 2; pos.Y = HEIGHT / 2;

View File

@ -12,28 +12,28 @@ class TestMain
{ {
int color_index = 0; int color_index = 0;
efl.All.Init(); Efl.All.Init();
efl.Loop loop = new efl.Loop(); Efl.Loop loop = new Efl.Loop();
EcoreEvas ecore_evas = new EcoreEvas(); EcoreEvas ecore_evas = new EcoreEvas();
efl.canvas.IObject canvas = ecore_evas.canvas; Efl.Canvas.Object canvas = ecore_evas.canvas;
canvas.SetVisible(true); canvas.SetVisible(true);
efl.IObject parent = canvas.GetParent(); Efl.Object parent = canvas.GetParent();
System.Diagnostics.Debug.Assert(parent.raw_handle != IntPtr.Zero); System.Diagnostics.Debug.Assert(parent.NativeHandle != IntPtr.Zero);
efl.canvas.Rectangle rect = new efl.canvas.Rectangle(canvas); Efl.Canvas.Rectangle rect = new Efl.Canvas.Rectangle(canvas);
rect.SetColor(colors[0, 0], colors[0, 1], colors[0, 2], 255); rect.SetColor(colors[0, 0], colors[0, 1], colors[0, 2], 255);
eina.Size2D size = new eina.Size2D(); Eina.Size2D size = new Eina.Size2D();
size.W = 640; size.W = 640;
size.H = 480; size.H = 480;
rect.SetSize(size); rect.SetSize(size);
rect.SetVisible(true); rect.SetVisible(true);
canvas.KeyDownEvt += (object sender, efl.input.Interface.KeyDownEvt_Args e) => { canvas.KeyDownEvt += (object sender, Efl.Input.InterfaceKeyDownEvt_Args e) => {
color_index = (color_index + 1) % 3; color_index = (color_index + 1) % 3;
Console.WriteLine("Key Down"); Console.WriteLine("Key Down");
Console.WriteLine("Got key obj at {0}", e.arg.raw_handle.ToString("X")); Console.WriteLine("Got key obj at {0}", e.arg.NativeHandle.ToString("X"));
Console.WriteLine("Got key_get() == [{0}]", e.arg.GetKey()); Console.WriteLine("Got key_get() == [{0}]", e.arg.GetKey());
rect.SetColor(colors[color_index, 0], rect.SetColor(colors[color_index, 0],
colors[color_index, 1], colors[color_index, 1],
@ -42,6 +42,6 @@ class TestMain
loop.Begin(); loop.Begin();
efl.All.Shutdown(); Efl.All.Shutdown();
} }
} }

View File

@ -9,37 +9,37 @@ class TestMain
static void Main(string[] args) static void Main(string[] args)
{ {
efl.All.Init(); Efl.All.Init();
efl.Loop loop = new efl.Loop(); Efl.Loop loop = new Efl.Loop();
EcoreEvas ecore_evas = new EcoreEvas(); EcoreEvas ecore_evas = new EcoreEvas();
eina.Size2D size = new eina.Size2D(); Eina.Size2D size = new Eina.Size2D();
size.W = WIDTH; size.W = WIDTH;
size.H = HEIGHT; size.H = HEIGHT;
eina.Size2D hint = new eina.Size2D(); Eina.Size2D hint = new Eina.Size2D();
efl.canvas.IObject canvas = ecore_evas.canvas; Efl.Canvas.Object canvas = ecore_evas.canvas;
canvas.SetVisible(true); canvas.SetVisible(true);
efl.IObject parent = canvas.GetParent(); Efl.Object parent = canvas.GetParent();
System.Diagnostics.Debug.Assert(parent.raw_handle != IntPtr.Zero); System.Diagnostics.Debug.Assert(parent.NativeHandle != IntPtr.Zero);
efl.canvas.Rectangle bg = new efl.canvas.Rectangle(canvas); Efl.Canvas.Rectangle bg = new Efl.Canvas.Rectangle(canvas);
bg.SetColor(255, 255, 255, 255); bg.SetColor(255, 255, 255, 255);
bg.SetSize(size); bg.SetSize(size);
bg.SetVisible(true); bg.SetVisible(true);
evas.Table table = new evas.Table(canvas); Evas.Table table = new Evas.Table(canvas);
table.SetHomogeneous(evas.object_table.Homogeneous_Mode.None); table.SetHomogeneous(Evas.ObjectTable.HomogeneousMode.None);
table.SetPadding(0, 0); table.SetPadding(0, 0);
table.SetSize(size); table.SetSize(size);
table.SetVisible(true); table.SetVisible(true);
efl.canvas.Rectangle rect = new efl.canvas.Rectangle(canvas); Efl.Canvas.Rectangle rect = new Efl.Canvas.Rectangle(canvas);
rect.SetColor(255, 0, 0, 255); rect.SetColor(255, 0, 0, 255);
hint.W = 100; hint.W = 100;
hint.H = 50; hint.H = 50;
@ -47,7 +47,7 @@ class TestMain
rect.SetVisible(true); rect.SetVisible(true);
table.Pack(rect, 1, 1, 2, 1); table.Pack(rect, 1, 1, 2, 1);
rect = new efl.canvas.Rectangle(canvas); rect = new Efl.Canvas.Rectangle(canvas);
rect.SetColor(0, 255, 0, 255); rect.SetColor(0, 255, 0, 255);
hint.W = 50; hint.W = 50;
hint.H = 100; hint.H = 100;
@ -55,7 +55,7 @@ class TestMain
rect.SetVisible(true); rect.SetVisible(true);
table.Pack(rect, 1, 2, 1, 2); table.Pack(rect, 1, 2, 1, 2);
rect = new efl.canvas.Rectangle(canvas); rect = new Efl.Canvas.Rectangle(canvas);
rect.SetColor(0, 0, 255, 255); rect.SetColor(0, 0, 255, 255);
hint.W = 50; hint.W = 50;
hint.H = 50; hint.H = 50;
@ -63,7 +63,7 @@ class TestMain
rect.SetVisible(true); rect.SetVisible(true);
table.Pack(rect, 2, 2, 1, 1); table.Pack(rect, 2, 2, 1, 1);
rect = new efl.canvas.Rectangle(canvas); rect = new Efl.Canvas.Rectangle(canvas);
rect.SetColor(255, 255, 0, 255); rect.SetColor(255, 255, 0, 255);
rect.SetHintMin(hint); rect.SetHintMin(hint);
rect.SetVisible(true); rect.SetVisible(true);
@ -71,7 +71,7 @@ class TestMain
loop.Begin(); loop.Begin();
efl.All.Shutdown(); Efl.All.Shutdown();
} }
} }

View File

@ -22,19 +22,19 @@ class TestMain
static int HEIGHT = 240; static int HEIGHT = 240;
private EcoreEvas ecore_evas; private EcoreEvas ecore_evas;
private efl.canvas.IObject canvas; private Efl.Canvas.Object canvas;
private efl.canvas.IRectangle bg; private Efl.Canvas.Rectangle bg;
private evas.Text text; private Evas.Text text;
private evas.Image border; private Evas.Image border;
public TestMain(String border_file) { public TestMain(String border_file) {
ecore_evas = new EcoreEvas(); ecore_evas = new EcoreEvas();
eina.Size2D size = new eina.Size2D(); Eina.Size2D size = new Eina.Size2D();
eina.Position2D position = new eina.Position2D(); Eina.Position2D position = new Eina.Position2D();
canvas = ecore_evas.canvas; canvas = ecore_evas.canvas;
canvas.SetVisible(true); canvas.SetVisible(true);
bg = new efl.canvas.Rectangle(canvas); bg = new Efl.Canvas.Rectangle(canvas);
bg.SetColor(255, 255, 255, 255); bg.SetColor(255, 255, 255, 255);
position.X = 0; position.X = 0;
position.Y = 0; position.Y = 0;
@ -45,10 +45,11 @@ class TestMain
bg.SetVisible(true); bg.SetVisible(true);
bg.SetKeyFocus(true); bg.SetKeyFocus(true);
/* ((Efl.Input.Interface)bg).KeyDownEvt += On_KeyDown; */
bg.KeyDownEvt += On_KeyDown; bg.KeyDownEvt += On_KeyDown;
text = new evas.Text(canvas); text = new Evas.Text(canvas);
text.SetStyle(evas.Text_Style_Type.OutlineSoftShadow); text.SetStyle(Evas.TextStyleType.OutlineSoftShadow);
text.SetColor(0, 0, 0, 255); text.SetColor(0, 0, 0, 255);
text.SetGlowColor(255, 0, 0, 255); text.SetGlowColor(255, 0, 0, 255);
@ -65,13 +66,13 @@ class TestMain
text.SetPosition(position); text.SetPosition(position);
text.SetVisible(true); text.SetVisible(true);
efl.font.Size font_size = 0; Efl.Font.Size font_size = 0;
String font = String.Empty; String font = String.Empty;
text.GetFont(out font, out font_size); text.GetFont(out font, out font_size);
Console.WriteLine("Adding text object with font {0} and size {1}", font, size); Console.WriteLine("Adding text object with font {0} and size {1}", font, size);
// setup border // setup border
border = new evas.Image(canvas); border = new Evas.Image(canvas);
border.SetFile(border_file, null); border.SetFile(border_file, null);
border.SetBorder(3, 3, 3, 3); border.SetBorder(3, 3, 3, 3);
border.SetBorderCenterFill(0); border.SetBorderCenterFill(0);
@ -87,15 +88,15 @@ class TestMain
} }
private void On_KeyDown(object sender, efl.input.Interface.KeyDownEvt_Args e) private void On_KeyDown(object sender, Efl.Input.InterfaceKeyDownEvt_Args e)
{ {
var key = e.arg.GetKey(); var key = e.arg.GetKey();
if (key == "h") { if (key == "h") {
Console.WriteLine(commands); Console.WriteLine(commands);
} else if (key == "t") { } else if (key == "t") {
evas.Text_Style_Type type = text.GetStyle(); Evas.TextStyleType type = text.GetStyle();
type = (evas.Text_Style_Type)(((int)type + 1) % 10); // 10 hardcoded from C example type = (Evas.TextStyleType)(((int)type + 1) % 10); // 10 hardcoded from C example
text.SetStyle(type); text.SetStyle(type);
} }
} }
@ -107,19 +108,19 @@ class TestMain
static void Main(string[] args) static void Main(string[] args)
{ {
efl.All.Init(); Efl.All.Init();
String border_path = "./src/examples/evas/resources/images/red.png"; String border_path = "./src/examples/evas/resources/images/red.png";
if (args.Length >= 1) if (args.Length >= 1)
border_path = args[0]; border_path = args[0];
efl.Loop loop = new efl.Loop(); Efl.Loop loop = new Efl.Loop();
TestMain t = new TestMain(border_path); TestMain t = new TestMain(border_path);
loop.Begin(); loop.Begin();
efl.All.Shutdown(); Efl.All.Shutdown();
} }
} }

View File

@ -1129,6 +1129,22 @@ struct klass_def
return ret; return ret;
} }
std::vector<event_def> get_all_events() const
{
std::vector<event_def> ret;
std::copy(events.cbegin(), events.cend(), std::back_inserter(ret));
for (auto inherit : inherits)
{
klass_def klass(get_klass(inherit, unit), unit);
std::copy(klass.events.cbegin(), klass.events.cend(),
std::back_inserter(ret));
}
return ret;
}
}; };
struct value_def struct value_def

View File

@ -11,7 +11,7 @@ class TestIntDirections
{ {
int original = 1984; int original = 1984;
int received; int received;
test.ITesting t = new test.Testing(); var t = new Dummy.TestObject();
t.IntOut(original, out received); t.IntOut(original, out received);
@ -22,7 +22,7 @@ class TestIntDirections
{ {
int original = 1984; int original = 1984;
int received; int received;
test.ITesting t = new test.Testing(); var t = new Dummy.TestObject();
t.IntPtrOut(original, out received); t.IntPtrOut(original, out received);

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ namespace TestSuite
class TestEo class TestEo
{ {
private class Derived : test.TestingInherit private class Derived : Dummy.TestObject
{ {
} }
@ -15,21 +15,20 @@ class TestEo
// //
public static void return_same_object() public static void return_same_object()
{ {
test.ITesting testing = new test.Testing(); var testing = new Dummy.TestObject();
test.ITesting o1 = testing.ReturnObject(); var o1 = testing.ReturnObject();
Test.Assert(o1.raw_handle != IntPtr.Zero); Test.Assert(o1.NativeHandle != IntPtr.Zero);
Test.Assert(o1.raw_handle == testing.raw_handle); Test.Assert(o1.NativeHandle == testing.NativeHandle);
test.ITesting o2 = o1.ReturnObject(); var o2 = o1.ReturnObject();
Test.Assert(o2.raw_handle != IntPtr.Zero); Test.Assert(o2.NativeHandle != IntPtr.Zero);
Test.Assert(o2.raw_handle == o1.raw_handle); Test.Assert(o2.NativeHandle == o1.NativeHandle);
} }
/* Commented out as adding the event listener seems to prevent it from being GC'd. /* Commented out as adding the event listener seems to prevent it from being GC'd.
public static void destructor_really_frees() public static void destructor_really_frees()
{ {
bool delEventCalled = false; bool delEventCalled = false;
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
obj.DEL += (object sender, EventArgs e) => { delEventCalled = true; }; obj.DEL += (object sender, EventArgs e) => { delEventCalled = true; };
} }
@ -46,8 +45,10 @@ class TestEo
{ {
bool delEventCalled = false; bool delEventCalled = false;
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
Eina.Log.Error($"Created object 0x{obj.NativeHandle.ToInt64():x}");
obj.DelEvt += (object sender, EventArgs e) => { delEventCalled = true; }; obj.DelEvt += (object sender, EventArgs e) => { delEventCalled = true; };
Eina.Log.Error($"Will dispose object 0x{obj.NativeHandle.ToInt64():x}");
((IDisposable)obj).Dispose(); ((IDisposable)obj).Dispose();
} }
@ -59,7 +60,7 @@ class TestEo
{ {
bool delEventCalled = false; bool delEventCalled = false;
{ {
test.ITesting obj = new Derived(); var obj = new Derived();
obj.DEL += (object sender, EventArgs e) => { delEventCalled = true; }; obj.DEL += (object sender, EventArgs e) => { delEventCalled = true; };
} }
@ -76,7 +77,7 @@ class TestEo
{ {
bool delEventCalled = false; bool delEventCalled = false;
{ {
test.ITesting obj = new Derived(); var obj = new Derived();
obj.DEL += (object sender, EventArgs e) => { delEventCalled = true; }; obj.DEL += (object sender, EventArgs e) => { delEventCalled = true; };
((IDisposable)obj).Dispose(); ((IDisposable)obj).Dispose();
} }
@ -86,7 +87,8 @@ class TestEo
*/ */
} }
class MyLoop : efl.LoopInherit
class MyLoop : Efl.Loop
{ {
public MyLoop() : base(null) { } public MyLoop() : base(null) { }
} }
@ -95,8 +97,8 @@ class TestEoInherit
{ {
public static void instantiate_inherited() public static void instantiate_inherited()
{ {
efl.ILoop loop = new MyLoop(); Efl.Loop loop = new MyLoop();
Test.Assert(loop.raw_handle != System.IntPtr.Zero); Test.Assert(loop.NativeHandle != System.IntPtr.Zero);
} }
} }
@ -104,7 +106,7 @@ class TestEoNames
{ {
public static void name_getset() public static void name_getset()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
string name = "Dummy"; string name = "Dummy";
obj.SetName(name); obj.SetName(name);
@ -118,9 +120,9 @@ class TestEoConstructingMethods
{ {
bool called = false; bool called = false;
string name = "Test object"; string name = "Test object";
test.ITesting obj = new test.Testing(null, (test.ITesting a) => { var obj = new Dummy.TestObject(null, (Dummy.TestObject a) => {
called = true; called = true;
Console.WriteLine("callback: obj raw_handle: {0:x}", a.raw_handle); Console.WriteLine("callback: obj NativeHandle: {0:x}", a.NativeHandle);
a.SetName(name); a.SetName(name);
}); });
@ -128,10 +130,10 @@ class TestEoConstructingMethods
Test.AssertEquals(name, obj.GetName()); Test.AssertEquals(name, obj.GetName());
} }
private class Derived : test.TestingInherit private class Derived : Dummy.TestObject
{ {
public Derived(test.ITesting parent = null, public Derived(Dummy.TestObject parent = null,
test.TestingInherit.ConstructingMethod cb = null) : base(parent, cb) { Dummy.TestObject.ConstructingMethod cb = null) : base(parent, cb) {
} }
} }
@ -139,7 +141,7 @@ class TestEoConstructingMethods
{ {
bool called = false; bool called = false;
string name = "Another test object"; string name = "Another test object";
Derived obj = new Derived(null, (test.ITesting a) => { Derived obj = new Derived(null, (Dummy.TestObject a) => {
called = true; called = true;
a.SetComment(name); a.SetComment(name);
}); });
@ -153,41 +155,41 @@ class TestEoParent
{ {
public static void basic_parent() public static void basic_parent()
{ {
test.ITesting parent = new test.Testing(null); var parent = new Dummy.TestObject(null);
test.ITesting child = new test.Testing(parent); var child = new Dummy.TestObject(parent);
Test.AssertEquals(parent, child.GetParent()); Test.AssertEquals(parent, child.GetParent());
test.ITesting parent_retrieved = test.Testing.static_cast(child.GetParent()); var parent_retrieved = Dummy.TestObject.static_cast(child.GetParent());
Test.AssertEquals(parent, parent_retrieved); Test.AssertEquals(parent, parent_retrieved);
} }
public static void parent_inherited_class() public static void parent_inherited_class()
{ {
test.INumberwrapper parent = new test.Numberwrapper(null); Dummy.Numberwrapper parent = new Dummy.Numberwrapper(null);
test.ITesting child = new test.Testing(parent); var child = new Dummy.TestObject(parent);
Test.AssertEquals(parent, child.GetParent()); Test.AssertEquals(parent, child.GetParent());
test.INumberwrapper parent_retrieved = test.Numberwrapper.static_cast(child.GetParent()); Dummy.Numberwrapper parent_retrieved = Dummy.Numberwrapper.static_cast(child.GetParent());
Test.AssertEquals(parent, parent_retrieved); Test.AssertEquals(parent, parent_retrieved);
} }
private class Derived : test.TestingInherit private class Derived : Dummy.TestObject
{ {
public Derived(test.ITesting parent = null) : base (parent) public Derived(Dummy.TestObject parent = null) : base (parent)
{ {
} }
} }
public static void basic_parent_managed_inherit() public static void basic_parent_managed_inherit()
{ {
test.ITesting parent = new Derived(null); var parent = new Derived(null);
test.ITesting child = new Derived(parent); var child = new Derived(parent);
Test.AssertEquals(parent, child.GetParent()); Test.AssertEquals(parent, child.GetParent());
test.ITesting parent_from_cast = test.Testing.static_cast(child.GetParent()); var parent_from_cast = Dummy.TestObject.static_cast(child.GetParent());
Test.AssertEquals(parent, parent_from_cast); Test.AssertEquals(parent, parent_from_cast);
} }
} }
@ -197,15 +199,15 @@ class TestKlassMethods
public static void basic_class_method() public static void basic_class_method()
{ {
int reference = 0xbeef; int reference = 0xbeef;
test.Testing.SetKlassProp(reference); Dummy.TestObject.SetKlassProp(reference);
Test.AssertEquals(reference, test.Testing.GetKlassProp()); Test.AssertEquals(reference, Dummy.TestObject.GetKlassProp());
} }
public static void inherited_class_method() public static void inherited_class_method()
{ {
int reference = 0xdead; int reference = 0xdead;
test.Child.SetKlassProp(reference); Dummy.Child.SetKlassProp(reference);
Test.AssertEquals(reference, test.Child.GetKlassProp()); Test.AssertEquals(reference, Dummy.Child.GetKlassProp());
} }
} }
@ -213,13 +215,13 @@ class TestTypedefs
{ {
public static void basic_typedef_test() public static void basic_typedef_test()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
test.MyInt input = 1900; Dummy.MyInt input = 1900;
test.MyInt receiver; Dummy.MyInt receiver;
int ret = obj.BypassTypedef(input, out receiver); int ret = obj.BypassTypedef(input, out receiver);
Test.AssertEquals((test.MyInt)ret, input); Test.AssertEquals((Dummy.MyInt)ret, input);
Test.AssertEquals(receiver, input); Test.AssertEquals(receiver, input);
} }
@ -229,13 +231,13 @@ class TestEoAccessors
{ {
public static void basic_eo_accessors() public static void basic_eo_accessors()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
eina.List<int> lst = new eina.List<int>(); Eina.List<int> lst = new Eina.List<int>();
lst.Append(4); lst.Append(4);
lst.Append(3); lst.Append(3);
lst.Append(2); lst.Append(2);
lst.Append(5); lst.Append(5);
eina.Accessor<int> acc = obj.CloneAccessor(lst.GetAccessor()); Eina.Accessor<int> acc = obj.CloneAccessor(lst.GetAccessor());
var zipped = acc.Zip(lst, (first, second) => new Tuple<int, int>(first, second)); var zipped = acc.Zip(lst, (first, second) => new Tuple<int, int>(first, second));
@ -248,10 +250,10 @@ class TestEoAccessors
class TestEoFinalize class TestEoFinalize
{ {
public sealed class Inherit : efl.ObjectInherit public sealed class Inherit : Efl.Object
{ {
public bool finalizeCalled = false; public bool finalizeCalled = false;
public override efl.IObject FinalizeAdd() public override Efl.Object FinalizeAdd()
{ {
finalizeCalled = true; finalizeCalled = true;
return this; return this;
@ -266,4 +268,39 @@ class TestEoFinalize
} }
} }
class TestEoMultipleChildClasses
{
public sealed class FirstChild : Efl.Object
{
public int receivedValue = 0;
public override Efl.Object FinalizeAdd()
{
receivedValue = 1;
return this;
}
}
public sealed class SecondChild : Efl.Object
{
public int receivedValue = 0;
public override Efl.Object FinalizeAdd()
{
receivedValue = 2;
return this;
}
}
public static void test_multiple_child_classes()
{
FirstChild obj = new FirstChild();
Test.AssertEquals(1, obj.receivedValue);
SecondChild obj2 = new SecondChild();
Test.AssertEquals(2, obj2.receivedValue);
obj = new FirstChild();
Test.AssertEquals(1, obj.receivedValue);
}
}
} }

View File

@ -9,24 +9,24 @@ class TestEoPromises
{ {
public static void test_simple_task_run() public static void test_simple_task_run()
{ {
efl.ILoop loop = efl.App.GetLoopMain(); Efl.Loop loop = Efl.App.GetLoopMain();
eina.Future future = loop.Idle(); Eina.Future future = loop.Idle();
bool callbackCalled = false; bool callbackCalled = false;
int ret_code = 1992; int ret_code = 1992;
future.Then((eina.Value value) => { future.Then((Eina.Value value) => {
callbackCalled = true; callbackCalled = true;
eina.Value v = new eina.Value(eina.ValueType.Int32); Eina.Value v = new Eina.Value(Eina.ValueType.Int32);
v.Set(ret_code); v.Set(ret_code);
loop.Quit(v); loop.Quit(v);
return value; return value;
}); });
eina.Value ret_value = loop.Begin(); Eina.Value ret_value = loop.Begin();
Test.Assert(callbackCalled, "Future loop callback must have been called."); Test.Assert(callbackCalled, "Future loop callback must have been called.");
Test.AssertEquals(ret_value.GetValueType(), eina.ValueType.Int32); Test.AssertEquals(ret_value.GetValueType(), Eina.ValueType.Int32);
int ret_from_value; int ret_from_value;
Test.Assert(ret_value.Get(out ret_from_value)); Test.Assert(ret_value.Get(out ret_from_value));
@ -36,17 +36,17 @@ class TestEoPromises
public static void test_object_promise() public static void test_object_promise()
{ {
efl.ILoop loop = efl.App.GetLoopMain(); Efl.Loop loop = Efl.App.GetLoopMain();
test.Testing obj = new test.Testing(); var obj = new Dummy.TestObject();
eina.Future future = obj.GetFuture(); Eina.Future future = obj.GetFuture();
bool callbackCalled = false; bool callbackCalled = false;
int receivedValue = -1; int receivedValue = -1;
int sentValue = 1984; int sentValue = 1984;
future.Then((eina.Value value) => { future.Then((Eina.Value value) => {
callbackCalled = true; callbackCalled = true;
Test.AssertEquals(value.GetValueType(), eina.ValueType.Int32); Test.AssertEquals(value.GetValueType(), Eina.ValueType.Int32);
value.Get(out receivedValue); value.Get(out receivedValue);
return value; return value;
@ -61,17 +61,17 @@ class TestEoPromises
public static void test_object_promise_cancel() public static void test_object_promise_cancel()
{ {
efl.ILoop loop = efl.App.GetLoopMain(); Efl.Loop loop = Efl.App.GetLoopMain();
test.Testing obj = new test.Testing(); var obj = new Dummy.TestObject();
eina.Future future = obj.GetFuture(); Eina.Future future = obj.GetFuture();
bool callbackCalled = false; bool callbackCalled = false;
eina.Error receivedError = -1; Eina.Error receivedError = -1;
eina.Error sentError = 120; Eina.Error sentError = 120;
future.Then((eina.Value value) => { future.Then((Eina.Value value) => {
callbackCalled = true; callbackCalled = true;
Test.AssertEquals(value.GetValueType(), eina.ValueType.Error); Test.AssertEquals(value.GetValueType(), Eina.ValueType.Error);
value.Get(out receivedError); value.Get(out receivedError);
return value; return value;
@ -88,10 +88,10 @@ class TestEoPromises
class LoopConsumer class LoopConsumer
{ {
public static async Task Consume(efl.ILoop loop) public static async Task Consume(Efl.Loop loop)
{ {
Task<eina.Value> task = loop.IdleAsync(); Task<Eina.Value> task = loop.IdleAsync();
eina.Value v = await task; Eina.Value v = await task;
loop.Quit(v); loop.Quit(v);
} }
} }
@ -100,7 +100,7 @@ class TestLoopEoAsyncMethods
{ {
public static void test_simple_async() public static void test_simple_async()
{ {
efl.ILoop loop = efl.App.GetLoopMain(); Efl.Loop loop = Efl.App.GetLoopMain();
Task t = LoopConsumer.Consume(loop); Task t = LoopConsumer.Consume(loop);
loop.Begin(); loop.Begin();
@ -113,18 +113,18 @@ class TestEoAsyncMethods
public static void test_async_fulfill() public static void test_async_fulfill()
{ {
efl.ILoop loop = efl.App.GetLoopMain(); Efl.Loop loop = Efl.App.GetLoopMain();
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
Task<eina.Value> task = obj.GetFutureAsync(); Task<Eina.Value> task = obj.GetFutureAsync();
int sentValue = 1337; int sentValue = 1337;
obj.FulfillPromise(sentValue); obj.FulfillPromise(sentValue);
loop.Iterate(); loop.Iterate();
eina.Value v = task.Result; Eina.Value v = task.Result;
Test.AssertEquals(v.GetValueType(), eina.ValueType.Int32); Test.AssertEquals(v.GetValueType(), Eina.ValueType.Int32);
int receivedValue; int receivedValue;
v.Get(out receivedValue); v.Get(out receivedValue);
@ -133,11 +133,11 @@ class TestEoAsyncMethods
public static void test_async_cancel() public static void test_async_cancel()
{ {
efl.ILoop loop = efl.App.GetLoopMain(); Efl.Loop loop = Efl.App.GetLoopMain();
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
CancellationTokenSource cancelSrc = new CancellationTokenSource(); CancellationTokenSource cancelSrc = new CancellationTokenSource();
Task<eina.Value> task = obj.GetFutureAsync(cancelSrc.Token); Task<Eina.Value> task = obj.GetFutureAsync(cancelSrc.Token);
cancelSrc.Cancel(); cancelSrc.Cancel();
loop.Iterate(); loop.Iterate();
@ -145,7 +145,7 @@ class TestEoAsyncMethods
bool raised = false; bool raised = false;
try try
{ {
eina.Value v = task.Result; Eina.Value v = task.Result;
} }
catch (AggregateException ae) catch (AggregateException ae)
{ {
@ -162,12 +162,12 @@ class TestEoAsyncMethods
public static void test_async_reject() public static void test_async_reject()
{ {
efl.ILoop loop = efl.App.GetLoopMain(); Efl.Loop loop = Efl.App.GetLoopMain();
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
Task<eina.Value> task = obj.GetFutureAsync(); Task<Eina.Value> task = obj.GetFutureAsync();
eina.Error sentError = 1337; Eina.Error sentError = 1337;
obj.RejectPromise(sentError); obj.RejectPromise(sentError);
loop.Iterate(); loop.Iterate();
@ -175,15 +175,15 @@ class TestEoAsyncMethods
bool raised = false; bool raised = false;
try try
{ {
eina.Value v = task.Result; Eina.Value v = task.Result;
} }
catch (AggregateException ae) catch (AggregateException ae)
{ {
raised = true; raised = true;
ae.Handle((x) => ae.Handle((x) =>
{ {
Test.Assert(x is efl.FutureException, "AggregateException must have been TaskCanceledException"); Test.Assert(x is Efl.FutureException, "AggregateException must have been TaskCanceledException");
efl.FutureException ex = x as efl.FutureException; Efl.FutureException ex = x as Efl.FutureException;
Test.AssertEquals(ex.Error, sentError); Test.AssertEquals(ex.Error, sentError);
return true; return true;
}); });

View File

@ -7,10 +7,10 @@ class TestEinaError
{ {
public static void basic_test() public static void basic_test()
{ {
eina.Error.Clear(); Eina.Error.Clear();
Test.AssertNotRaises<efl.EflException>(eina.Error.RaiseIfOccurred); Test.AssertNotRaises<Efl.EflException>(Eina.Error.RaiseIfOccurred);
eina.Error.Set(eina.Error.ENOENT); Eina.Error.Set(Eina.Error.ENOENT);
Test.AssertRaises<efl.EflException>(eina.Error.RaiseIfOccurred); Test.AssertRaises<Efl.EflException>(Eina.Error.RaiseIfOccurred);
} }
} }
@ -19,24 +19,24 @@ class TestEolianError
public static void global_eina_error() public static void global_eina_error()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
Test.AssertRaises<efl.EflException>(() => obj.RaisesEinaError()); Test.AssertRaises<Efl.EflException>(() => obj.RaisesEinaError());
} }
class Child : test.TestingInherit { class Child : Dummy.TestObject {
} }
public static void global_eina_error_inherited() public static void global_eina_error_inherited()
{ {
test.ITesting obj = new Child(); var obj = new Child();
Test.AssertRaises<efl.EflException>(() => obj.RaisesEinaError()); Test.AssertRaises<Efl.EflException>(() => obj.RaisesEinaError());
} }
class CustomException : Exception { class CustomException : Exception {
public CustomException(string msg): base(msg) {} public CustomException(string msg): base(msg) {}
} }
class Overrider : test.TestingInherit { class Overrider : Dummy.TestObject {
public override void ChildrenRaiseError() { public override void ChildrenRaiseError() {
throw (new CustomException("Children error")); throw (new CustomException("Children error"));
} }
@ -44,18 +44,18 @@ class TestEolianError
public static void exception_raised_from_inherited_virtual() public static void exception_raised_from_inherited_virtual()
{ {
test.ITesting obj = new Overrider(); var obj = new Overrider();
Test.AssertRaises<efl.EflException>(obj.CallChildrenRaiseError); Test.AssertRaises<Efl.EflException>(obj.CallChildrenRaiseError);
} }
// return eina_error // return eina_error
public static void eina_error_return() public static void eina_error_return()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
eina.Error expected = 42; Eina.Error expected = 42;
obj.SetErrorRet(expected); obj.SetErrorRet(expected);
eina.Error error = obj.ReturnsError(); Eina.Error error = obj.ReturnsError();
Test.AssertEquals(expected, error); Test.AssertEquals(expected, error);
@ -66,12 +66,12 @@ class TestEolianError
Test.AssertEquals(expected, error); Test.AssertEquals(expected, error);
} }
class ReturnOverride : test.TestingInherit { class ReturnOverride : Dummy.TestObject {
eina.Error code; Eina.Error code;
public override void SetErrorRet(eina.Error err) { public override void SetErrorRet(Eina.Error err) {
code = 2 * err; code = 2 * err;
} }
public override eina.Error ReturnsError() public override Eina.Error ReturnsError()
{ {
return code; return code;
} }
@ -79,18 +79,18 @@ class TestEolianError
public static void eina_error_return_from_inherited_virtual() public static void eina_error_return_from_inherited_virtual()
{ {
test.ITesting obj = new ReturnOverride(); var obj = new ReturnOverride();
eina.Error expected = 42; Eina.Error expected = 42;
obj.SetErrorRet(expected); obj.SetErrorRet(expected);
eina.Error error = obj.ReturnsError(); Eina.Error error = obj.ReturnsError();
Test.AssertEquals(new eina.Error(expected * 2), error); Test.AssertEquals(new Eina.Error(expected * 2), error);
expected = 0; expected = 0;
obj.SetErrorRet(expected); obj.SetErrorRet(expected);
error = obj.ReturnsError(); error = obj.ReturnsError();
Test.AssertEquals(new eina.Error(expected * 2), error); Test.AssertEquals(new Eina.Error(expected * 2), error);
} }
// events // events
@ -108,11 +108,11 @@ class TestEolianError
// An event whose managed delegate generates an exception // An event whose managed delegate generates an exception
// must set an eina_error so it can be reported back to // must set an eina_error so it can be reported back to
// the managed code // the managed code
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
Listener listener = new Listener(); Listener listener = new Listener();
obj.EvtWithIntEvt += listener.callback; obj.EvtWithIntEvt += listener.callback;
Test.AssertRaises<efl.EflException>(() => { obj.EmitEventWithInt(2); }); Test.AssertRaises<Efl.EflException>(() => { obj.EmitEventWithInt(2); });
} }
} }
} }

View File

@ -2,9 +2,9 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
public class MyBox : evas.BoxInherit public class MyBox : Evas.Box
{ {
public MyBox(efl.Object parent) : base(parent) {} public MyBox(Efl.Object parent) : base(parent) {}
[DllImport("evas")] static extern void evas_obj_box_layout_vertical(IntPtr obj, IntPtr data, IntPtr privdata); [DllImport("evas")] static extern void evas_obj_box_layout_vertical(IntPtr obj, IntPtr data, IntPtr privdata);
[DllImport("evas")] static extern void evas_obj_box_layout_horizontal(IntPtr obj, IntPtr data, IntPtr privdata); [DllImport("evas")] static extern void evas_obj_box_layout_horizontal(IntPtr obj, IntPtr data, IntPtr privdata);
@ -15,11 +15,11 @@ public class MyBox : evas.BoxInherit
override public void CalculateGroup() override public void CalculateGroup()
{ {
IntPtr evas = evas_object_evas_get(raw_handle); IntPtr evas = evas_object_evas_get(NativeHandle);
evas_event_freeze(evas); evas_event_freeze(evas);
eina.Log.Debug("called group_calculate"); Eina.Log.Debug("called group_calculate");
// slayouting_set(true); // slayouting_set(true);
evas_obj_box_layout_vertical(raw_handle, IntPtr.Zero, IntPtr.Zero); evas_obj_box_layout_vertical(NativeHandle, IntPtr.Zero, IntPtr.Zero);
// layouting_set(false); // layouting_set(false);
// children_changed_set(false); // children_changed_set(false);
evas_event_thaw(evas); evas_event_thaw(evas);
@ -46,7 +46,7 @@ class TestEvas
/* canvas.visible_set(true); */ /* canvas.visible_set(true); */
/* efl.Object parent = canvas.parent_get(); */ /* efl.Object parent = canvas.parent_get(); */
/* Test.Assert(parent.raw_handle != IntPtr.Zero); */ /* Test.Assert(parent.NativeHandle != IntPtr.Zero); */
/* efl.canvas.Rectangle rect = new efl.canvas.RectangleConcrete(canvas); */ /* efl.canvas.Rectangle rect = new efl.canvas.RectangleConcrete(canvas); */
/* rect.color_set(255, 255, 255, 255); */ /* rect.color_set(255, 255, 255, 255); */

View File

@ -1,7 +1,5 @@
using System; using System;
using static test.Testing; // For the event args
namespace TestSuite namespace TestSuite
{ {
@ -9,17 +7,17 @@ class TestEoEvents
{ {
public bool called = false; public bool called = false;
public bool correct_sender = false; public bool correct_sender = false;
public efl.ILoop loop { get; set; } public Efl.Loop loop { get; set; }
protected void callback(object sender, EventArgs e) { protected void callback(object sender, EventArgs e) {
called = true; called = true;
efl.IObject obj = sender as efl.IObject; Efl.Object obj = sender as Efl.Object;
if (obj != null) if (obj != null)
{ {
obj.SetName("loop_called"); obj.SetName("loop_called");
correct_sender = true; correct_sender = true;
} }
eina.Value v = new eina.Value(eina.ValueType.Int32); Eina.Value v = new Eina.Value(Eina.ValueType.Int32);
v.Set(0); v.Set(0);
loop.Quit(v); loop.Quit(v);
} }
@ -27,7 +25,7 @@ class TestEoEvents
public static void idle_event() public static void idle_event()
{ {
efl.ILoop loop = new efl.Loop(); Efl.Loop loop = new Efl.Loop();
loop.SetName("loop"); loop.SetName("loop");
TestEoEvents listener = new TestEoEvents(); TestEoEvents listener = new TestEoEvents();
listener.loop = loop; listener.loop = loop;
@ -44,10 +42,10 @@ class TestEoEvents
public static void event_with_string_payload() public static void event_with_string_payload()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
string received_string = null; string received_string = null;
obj.EvtWithStringEvt += (object sender, EvtWithStringEvt_Args e) => { obj.EvtWithStringEvt += (object sender, Dummy.TestObjectEvtWithStringEvt_Args e) => {
received_string = e.arg; received_string = e.arg;
}; };
@ -58,10 +56,10 @@ class TestEoEvents
public static void event_with_int_payload() public static void event_with_int_payload()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
int received_int= 0; int received_int= 0;
obj.EvtWithIntEvt += (object sender, EvtWithIntEvt_Args e) => { obj.EvtWithIntEvt += (object sender, Dummy.TestObjectEvtWithIntEvt_Args e) => {
received_int = e.arg; received_int = e.arg;
}; };
@ -72,10 +70,10 @@ class TestEoEvents
public static void event_with_bool_payload() public static void event_with_bool_payload()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
bool received_bool = false; bool received_bool = false;
obj.EvtWithBoolEvt += (object sender, EvtWithBoolEvt_Args e) => { obj.EvtWithBoolEvt += (object sender, Dummy.TestObjectEvtWithBoolEvt_Args e) => {
received_bool = e.arg; received_bool = e.arg;
}; };
@ -90,9 +88,9 @@ class TestEoEvents
public static void event_with_uint_payload() public static void event_with_uint_payload()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
uint received_uint = 0; uint received_uint = 0;
obj.EvtWithUintEvt += (object sender, EvtWithUintEvt_Args e) => { obj.EvtWithUintEvt += (object sender, Dummy.TestObjectEvtWithUintEvt_Args e) => {
received_uint = e.arg; received_uint = e.arg;
}; };
@ -103,14 +101,14 @@ class TestEoEvents
public static void event_with_object_payload() public static void event_with_object_payload()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
test.ITesting received_obj = null; Dummy.TestObject received_obj = null;
obj.EvtWithObjEvt += (object sender, EvtWithObjEvt_Args e) => { obj.EvtWithObjEvt += (object sender, Dummy.TestObjectEvtWithObjEvt_Args e) => {
received_obj = e.arg; received_obj = e.arg;
}; };
test.ITesting sent_obj = new test.Testing(); var sent_obj = new Dummy.TestObject();
obj.EmitEventWithObj(sent_obj); obj.EmitEventWithObj(sent_obj);
@ -119,14 +117,14 @@ class TestEoEvents
public static void event_with_error_payload() public static void event_with_error_payload()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
eina.Error received_error = 0; Eina.Error received_error = 0;
obj.EvtWithErrorEvt += (object sender, EvtWithErrorEvt_Args e) => { obj.EvtWithErrorEvt += (object sender, Dummy.TestObjectEvtWithErrorEvt_Args e) => {
received_error = e.arg; received_error = e.arg;
}; };
eina.Error sent_error = -2001; Eina.Error sent_error = -2001;
obj.EmitEventWithError(sent_error); obj.EmitEventWithError(sent_error);
@ -135,14 +133,14 @@ class TestEoEvents
public static void event_with_struct_payload() public static void event_with_struct_payload()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
test.StructSimple received_struct = default(test.StructSimple); Dummy.StructSimple received_struct = default(Dummy.StructSimple);
obj.EvtWithStructEvt += (object sender, EvtWithStructEvt_Args e) => { obj.EvtWithStructEvt += (object sender, Dummy.TestObjectEvtWithStructEvt_Args e) => {
received_struct = e.arg; received_struct = e.arg;
}; };
test.StructSimple sent_struct = default(test.StructSimple); Dummy.StructSimple sent_struct = default(Dummy.StructSimple);
sent_struct.Fstring = "Struct Event"; sent_struct.Fstring = "Struct Event";
obj.EmitEventWithStruct(sent_struct); obj.EmitEventWithStruct(sent_struct);
@ -154,8 +152,8 @@ class TestEoEvents
{ {
int received = 0; int received = 0;
int sent = 42; int sent = 42;
test.ITesting obj = new test.Testing(null, (test.ITesting t) => { var obj = new Dummy.TestObject(null, (Dummy.TestObject t) => {
t.EvtWithIntEvt += (object sender, EvtWithIntEvt_Args e) => { t.EvtWithIntEvt += (object sender, Dummy.TestObjectEvtWithIntEvt_Args e) => {
received = e.arg; received = e.arg;
}; };
}); });
@ -170,10 +168,10 @@ class TestEventAddRemove
{ {
public static void test_add_remove_event() public static void test_add_remove_event()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
bool called = true; bool called = true;
EventHandler<test.Testing.EvtWithIntEvt_Args> evtCb = (object sender, EvtWithIntEvt_Args e) => { EventHandler<Dummy.TestObjectEvtWithIntEvt_Args> evtCb = (object sender, Dummy.TestObjectEvtWithIntEvt_Args e) => {
called = true; called = true;
}; };
@ -185,9 +183,50 @@ class TestEventAddRemove
obj.EvtWithIntEvt -= evtCb; obj.EvtWithIntEvt -= evtCb;
obj.EmitEventWithInt(42); obj.EmitEventWithInt(42);
Test.Assert(!called); Test.Assert(!called);
}
}
class TestInterfaceEvents
{
public static void test_nonconflicting_events()
{
var obj = new Dummy.TestObject();
var called = false;
EventHandler cb = (object sender, EventArgs e) => {
called = true;
};
obj.NonconflictedEvt += cb;
obj.EmitNonconflicted();
Test.Assert(called);
}
public static void test_conflicting_events()
{
var obj = new Dummy.TestObject();
var test_called = false;
var another_called = false;
EventHandler cb = (object sender, EventArgs e) => {
test_called = true;
};
EventHandler another_cb = (object sender, EventArgs e) => {
another_called = true;
};
((Dummy.TestIface)obj).ConflictedEvt += cb;
((Dummy.AnotherIface)obj).ConflictedEvt += another_cb;
obj.EmitTestConflicted();
Test.Assert(test_called);
Test.Assert(!another_called);
test_called = false;
obj.EmitAnotherConflicted();
Test.Assert(!test_called);
Test.Assert(another_called);
} }
} }
} }

View File

@ -9,15 +9,15 @@ class TestFunctionPointerMarshalling
{ {
public static void func_pointer_marshalling() public static void func_pointer_marshalling()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
bool called = false; bool called = false;
eina.Strbuf buf = new eina.Strbuf(); Eina.Strbuf buf = new Eina.Strbuf();
string argument = "Some String"; string argument = "Some String";
eina.Value v = new eina.Value(eina.ValueType.String); Eina.Value v = new Eina.Value(Eina.ValueType.String);
v.Set(argument); v.Set(argument);
string reference = new string(argument.ToCharArray().Reverse().ToArray()); string reference = new string(argument.ToCharArray().Reverse().ToArray());
obj.CallFormatCb(buf, v, (eina.Strbuf ibuf, eina.Value val) => { obj.CallFormatCb(buf, v, (Eina.Strbuf ibuf, Eina.Value val) => {
called = true; called = true;
string str = null; string str = null;
val.Get(out str); val.Get(out str);

View File

@ -29,7 +29,7 @@ class TestFunctionPointers
public static void set_callback_basic() public static void set_callback_basic()
{ {
setup(); setup();
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
obj.SetCallback(twice); obj.SetCallback(twice);
Test.Assert(called == false, "set_callback should not call the callback"); Test.Assert(called == false, "set_callback should not call the callback");
@ -44,7 +44,7 @@ class TestFunctionPointers
{ {
setup(); setup();
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
obj.SetCallback(y => { obj.SetCallback(y => {
called = true; called = true;
return y + 4; return y + 4;
@ -62,7 +62,7 @@ class TestFunctionPointers
{ {
setup(); setup();
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
obj.SetCallback(twice); obj.SetCallback(twice);
Test.Assert(called == false, "set_callback should not call the callback"); Test.Assert(called == false, "set_callback should not call the callback");
@ -83,7 +83,7 @@ class TestFunctionPointers
Test.AssertEquals(42 * 42, x); Test.AssertEquals(42 * 42, x);
} }
class NoOverride : test.TestingInherit { class NoOverride : Dummy.TestObject {
} }
public static void set_callback_inherited_no_override() public static void set_callback_inherited_no_override()
{ {
@ -99,15 +99,15 @@ class TestFunctionPointers
Test.AssertEquals(42 * 3, x); Test.AssertEquals(42 * 3, x);
} }
class WithOverride : test.TestingInherit { class WithOverride : Dummy.TestObject {
public bool set_called = false; public bool set_called = false;
public bool invoke_called = false; public bool invoke_called = false;
public test.SimpleCb cb = null; public Dummy.SimpleCb cb = null;
public WithOverride() : base() { public WithOverride() : base() {
} }
public override void SetCallback(test.SimpleCb cb) { public override void SetCallback(Dummy.SimpleCb cb) {
set_called = true; set_called = true;
this.cb = cb; this.cb = cb;
} }
@ -115,7 +115,7 @@ class TestFunctionPointers
invoke_called = true; invoke_called = true;
if (cb != null) if (cb != null)
return cb(a); return cb(a);
eina.Log.Error("No callback set upon call_callback invocation"); Eina.Log.Error("No callback set upon call_callback invocation");
return -1; return -1;
} }
} }

View File

@ -15,7 +15,7 @@ class TestMain
static int Main(string[] args) static int Main(string[] args)
{ {
efl.All.Init(); Efl.All.Init();
bool pass = true; bool pass = true;

View File

@ -13,11 +13,11 @@ public static class TestParts
{ {
public static void basic_part_test() public static void basic_part_test()
{ {
test.ITesting t = new test.Testing(); var t = new Dummy.TestObject();
do_part_test(t); do_part_test(t);
} }
private class Child : test.TestingInherit private class Child : Dummy.TestObject
{ {
public Child() : base(null) {} public Child() : base(null) {}
} }
@ -27,14 +27,14 @@ public static class TestParts
do_part_test(t); do_part_test(t);
} }
private static void do_part_test(test.ITesting t) private static void do_part_test(Dummy.TestObject t)
{ {
var p1 = t.Part1; var p1 = t.PartOne;
var p2 = t.Part2; var p2 = t.PartTwo;
Test.Assert(p1 is test.Testing); Test.Assert(p1 is Dummy.TestObject);
Test.AssertEquals("part1", p1.GetName()); Test.AssertEquals("part_one", p1.GetName());
Test.Assert(p2 is test.Testing); Test.Assert(p2 is Dummy.TestObject);
Test.AssertEquals("part2", p2.GetName()); Test.AssertEquals("part_two", p2.GetName());
} }
} }

View File

@ -9,8 +9,8 @@ class TestPromises
public static void test_simple_cancel() public static void test_simple_cancel()
{ {
bool cleanCalled = false; bool cleanCalled = false;
eina.Promise promise = new eina.Promise(() => { cleanCalled = true; }); Eina.Promise promise = new Eina.Promise(() => { cleanCalled = true; });
eina.Future future = new eina.Future(promise); Eina.Future future = new Eina.Future(promise);
future.Cancel(); future.Cancel();
Test.Assert(cleanCalled, "Promise clean callback should have been called."); Test.Assert(cleanCalled, "Promise clean callback should have been called.");
Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); }); Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); });
@ -20,19 +20,19 @@ class TestPromises
public static void test_simple_resolve() public static void test_simple_resolve()
{ {
bool callbackCalled = false; bool callbackCalled = false;
eina.Value received_value = null; Eina.Value received_value = null;
efl.ILoop loop = efl.App.GetLoopMain(); Efl.Loop loop = Efl.App.GetLoopMain();
eina.Promise promise = new eina.Promise(); Eina.Promise promise = new Eina.Promise();
eina.Future future = new eina.Future(promise); Eina.Future future = new Eina.Future(promise);
future = future.Then((eina.Value value) => { future = future.Then((Eina.Value value) => {
callbackCalled = true; callbackCalled = true;
received_value = value; received_value = value;
return value; return value;
} ); } );
eina.Value reference_value = new eina.Value(eina.ValueType.Int32); Eina.Value reference_value = new Eina.Value(Eina.ValueType.Int32);
reference_value.Set(1984); reference_value.Set(1984);
promise.Resolve(reference_value); promise.Resolve(reference_value);
@ -45,24 +45,24 @@ class TestPromises
public static void test_simple_reject() public static void test_simple_reject()
{ {
bool callbackCalled = false; bool callbackCalled = false;
eina.Error received_error = eina.Error.NO_ERROR; Eina.Error received_error = Eina.Error.NO_ERROR;
efl.ILoop loop = efl.App.GetLoopMain(); Efl.Loop loop = Efl.App.GetLoopMain();
eina.Promise promise = new eina.Promise(); Eina.Promise promise = new Eina.Promise();
eina.Future future = new eina.Future(promise); Eina.Future future = new Eina.Future(promise);
future = future.Then((eina.Value value) => { future = future.Then((Eina.Value value) => {
callbackCalled = true; callbackCalled = true;
value.Get(out received_error); value.Get(out received_error);
return value; return value;
}); });
promise.Reject(eina.Error.EPERM); promise.Reject(Eina.Error.EPERM);
loop.Iterate(); loop.Iterate();
Test.Assert(callbackCalled, "Future callback should have been called."); Test.Assert(callbackCalled, "Future callback should have been called.");
Test.AssertEquals(received_error, eina.Error.EPERM); Test.AssertEquals(received_error, Eina.Error.EPERM);
Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); }); Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); });
Test.AssertRaises<ObjectDisposedException>(future.Cancel); Test.AssertRaises<ObjectDisposedException>(future.Cancel);
@ -72,12 +72,12 @@ class TestPromises
{ {
bool callbackCalled = false; bool callbackCalled = false;
bool promiseCallbackCalled = false; bool promiseCallbackCalled = false;
eina.Error received_error = eina.Error.NO_ERROR; Eina.Error received_error = Eina.Error.NO_ERROR;
eina.Promise promise = new eina.Promise(() => { promiseCallbackCalled = true; }); Eina.Promise promise = new Eina.Promise(() => { promiseCallbackCalled = true; });
eina.Future future = new eina.Future(promise); Eina.Future future = new Eina.Future(promise);
future = future.Then((eina.Value value) => { future = future.Then((Eina.Value value) => {
callbackCalled = true; callbackCalled = true;
value.Get(out received_error); value.Get(out received_error);
return value; return value;
@ -87,18 +87,18 @@ class TestPromises
Test.Assert(promiseCallbackCalled, "Promise cancel callback should have been called."); Test.Assert(promiseCallbackCalled, "Promise cancel callback should have been called.");
Test.Assert(callbackCalled, "Future callback should have been called."); Test.Assert(callbackCalled, "Future callback should have been called.");
Test.AssertEquals(received_error, eina.Error.ECANCELED); Test.AssertEquals(received_error, Eina.Error.ECANCELED);
} }
private delegate eina.Future.ResolvedCb FutureCbGenerator(int x); private delegate Eina.Future.ResolvedCb FutureCbGenerator(int x);
public static void test_then_chaining() public static void test_then_chaining()
{ {
bool[] callbacksCalled = {false, false, false, false}; bool[] callbacksCalled = {false, false, false, false};
eina.Value[] received_value = {null, null, null, null}; Eina.Value[] received_value = {null, null, null, null};
FutureCbGenerator genResolvedCb = (int i) => { FutureCbGenerator genResolvedCb = (int i) => {
return (eina.Value value) => { return (Eina.Value value) => {
callbacksCalled[i] = true; callbacksCalled[i] = true;
int x; int x;
value.Get(out x); value.Get(out x);
@ -108,13 +108,13 @@ class TestPromises
}; };
}; };
efl.ILoop loop = efl.App.GetLoopMain(); Efl.Loop loop = Efl.App.GetLoopMain();
eina.Promise promise = new eina.Promise(); Eina.Promise promise = new Eina.Promise();
eina.Future future = new eina.Future(promise); Eina.Future future = new Eina.Future(promise);
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
future = future.Then(genResolvedCb(i)); future = future.Then(genResolvedCb(i));
eina.Value reference_value = new eina.Value(eina.ValueType.Int32); Eina.Value reference_value = new Eina.Value(Eina.ValueType.Int32);
reference_value.Set(0); reference_value.Set(0);
promise.Resolve(reference_value); promise.Resolve(reference_value);
@ -137,10 +137,10 @@ class TestPromises
public static void test_then_chain_array() public static void test_then_chain_array()
{ {
bool[] callbacksCalled = {false, false, false, false}; bool[] callbacksCalled = {false, false, false, false};
eina.Value[] received_value = {null, null, null, null}; Eina.Value[] received_value = {null, null, null, null};
FutureCbGenerator genResolvedCb = (int i) => { FutureCbGenerator genResolvedCb = (int i) => {
return (eina.Value value) => { return (Eina.Value value) => {
callbacksCalled[i] = true; callbacksCalled[i] = true;
int x; int x;
value.Get(out x); value.Get(out x);
@ -150,16 +150,16 @@ class TestPromises
}; };
}; };
var cbs = new List<eina.Future.ResolvedCb>(); var cbs = new List<Eina.Future.ResolvedCb>();
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
cbs.Add(genResolvedCb(i)); cbs.Add(genResolvedCb(i));
efl.ILoop loop = efl.App.GetLoopMain(); Efl.Loop loop = Efl.App.GetLoopMain();
eina.Promise promise = new eina.Promise(); Eina.Promise promise = new Eina.Promise();
eina.Future future = new eina.Future(promise); Eina.Future future = new Eina.Future(promise);
future = future.Chain(cbs); future = future.Chain(cbs);
eina.Value reference_value = new eina.Value(eina.ValueType.Int32); Eina.Value reference_value = new Eina.Value(Eina.ValueType.Int32);
reference_value.Set(0); reference_value.Set(0);
promise.Resolve(reference_value); promise.Resolve(reference_value);
@ -182,25 +182,25 @@ class TestPromises
public static void test_cancel_after_resolve() public static void test_cancel_after_resolve()
{ {
bool callbackCalled = false; bool callbackCalled = false;
eina.Error received_error = eina.Error.NO_ERROR; Eina.Error received_error = Eina.Error.NO_ERROR;
efl.ILoop loop = efl.App.GetLoopMain(); Efl.Loop loop = Efl.App.GetLoopMain();
eina.Promise promise = new eina.Promise(); Eina.Promise promise = new Eina.Promise();
eina.Future future = new eina.Future(promise); Eina.Future future = new Eina.Future(promise);
future = future.Then((eina.Value value) => { future = future.Then((Eina.Value value) => {
callbackCalled = true; callbackCalled = true;
value.Get(out received_error); value.Get(out received_error);
return value; return value;
}); });
promise.Reject(eina.Error.EPERM); promise.Reject(Eina.Error.EPERM);
future.Cancel(); future.Cancel();
loop.Iterate(); loop.Iterate();
Test.Assert(callbackCalled, "Future callback should have been called."); Test.Assert(callbackCalled, "Future callback should have been called.");
Test.AssertEquals(received_error, eina.Error.ECANCELED); Test.AssertEquals(received_error, Eina.Error.ECANCELED);
Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); }); Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); });
Test.AssertRaises<ObjectDisposedException>(future.Cancel); Test.AssertRaises<ObjectDisposedException>(future.Cancel);
@ -209,19 +209,19 @@ class TestPromises
public static void test_constructor_with_callback() public static void test_constructor_with_callback()
{ {
bool callbackCalled = false; bool callbackCalled = false;
eina.Value received_value = null; Eina.Value received_value = null;
efl.ILoop loop = efl.App.GetLoopMain(); Efl.Loop loop = Efl.App.GetLoopMain();
eina.Promise promise = new eina.Promise(); Eina.Promise promise = new Eina.Promise();
#pragma warning disable 0219 #pragma warning disable 0219
eina.Future future = new eina.Future(promise,(eina.Value value) => { Eina.Future future = new Eina.Future(promise,(Eina.Value value) => {
callbackCalled = true; callbackCalled = true;
received_value = value; received_value = value;
return value; return value;
} ); } );
#pragma warning restore 0219 #pragma warning restore 0219
eina.Value reference_value = new eina.Value(eina.ValueType.Int32); Eina.Value reference_value = new Eina.Value(Eina.ValueType.Int32);
reference_value.Set(1984); reference_value.Set(1984);
promise.Resolve(reference_value); promise.Resolve(reference_value);
@ -234,13 +234,13 @@ class TestPromises
public static void test_reject_on_disposal() public static void test_reject_on_disposal()
{ {
bool callbackCalled = false; bool callbackCalled = false;
eina.Error received_error = eina.Error.NO_ERROR; Eina.Error received_error = Eina.Error.NO_ERROR;
efl.ILoop loop = efl.App.GetLoopMain(); Efl.Loop loop = Efl.App.GetLoopMain();
eina.Promise promise = new eina.Promise(); Eina.Promise promise = new Eina.Promise();
eina.Future future = new eina.Future(promise); Eina.Future future = new Eina.Future(promise);
future = future.Then((eina.Value value) => { future = future.Then((Eina.Value value) => {
callbackCalled = true; callbackCalled = true;
value.Get(out received_error); value.Get(out received_error);
return value; return value;
@ -251,7 +251,7 @@ class TestPromises
loop.Iterate(); loop.Iterate();
Test.Assert(callbackCalled, "Future callback should have been called."); Test.Assert(callbackCalled, "Future callback should have been called.");
Test.AssertEquals(received_error, eina.Error.ECANCELED); Test.AssertEquals(received_error, Eina.Error.ECANCELED);
Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); }); Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); });
Test.AssertRaises<ObjectDisposedException>(future.Cancel); Test.AssertRaises<ObjectDisposedException>(future.Cancel);

View File

@ -6,7 +6,7 @@ class TestStrBuf
{ {
public static void test_steal() public static void test_steal()
{ {
eina.Strbuf buf = new eina.Strbuf(); Eina.Strbuf buf = new Eina.Strbuf();
buf.Append("Here's"); buf.Append("Here's");
buf.Append(' '); buf.Append(' ');
@ -18,8 +18,8 @@ class TestStrBuf
public static void test_eolian() public static void test_eolian()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
eina.Strbuf buf = new eina.Strbuf(); Eina.Strbuf buf = new Eina.Strbuf();
obj.AppendToStrbuf(buf, "Appended"); obj.AppendToStrbuf(buf, "Appended");
obj.AppendToStrbuf(buf, " to buf"); obj.AppendToStrbuf(buf, " to buf");
@ -27,7 +27,7 @@ class TestStrBuf
Test.AssertEquals("Appended to buf", buf.Steal()); Test.AssertEquals("Appended to buf", buf.Steal());
} }
private class Appender : test.TestingInherit private class Appender : Dummy.TestObject
{ {
public bool called; public bool called;
public Appender() : base(null) public Appender() : base(null)
@ -35,9 +35,9 @@ class TestStrBuf
called = false; called = false;
} }
public override void AppendToStrbuf(eina.Strbuf buf, string str) public override void AppendToStrbuf(Eina.Strbuf buf, string str)
{ {
eina.Log.Error("Virtual wrapper called"); Eina.Log.Error("Virtual wrapper called");
called = true; called = true;
buf.Append(str); buf.Append(str);
} }
@ -46,7 +46,7 @@ class TestStrBuf
public static void test_virtual_eolian() public static void test_virtual_eolian()
{ {
Appender obj = new Appender(); Appender obj = new Appender();
eina.Strbuf buf = new eina.Strbuf(); Eina.Strbuf buf = new Eina.Strbuf();
obj.CallAppendToStrbuf(buf, "Is"); obj.CallAppendToStrbuf(buf, "Is");
obj.CallAppendToStrbuf(buf, " this"); obj.CallAppendToStrbuf(buf, " this");

View File

@ -8,7 +8,7 @@ class TestStrings
public static void in_string() public static void in_string()
{ {
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
String sent = "in_string"; String sent = "in_string";
String returned = obj.InString(sent); String returned = obj.InString(sent);
Test.AssertEquals(sent, returned); Test.AssertEquals(sent, returned);
@ -21,7 +21,7 @@ class TestStrings
public static void in_own_string() public static void in_own_string()
{ {
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
String sent = "in_own_string"; String sent = "in_own_string";
String returned = obj.InOwnString(sent); String returned = obj.InOwnString(sent);
Test.AssertEquals(sent, returned); Test.AssertEquals(sent, returned);
@ -33,7 +33,7 @@ class TestStrings
public static void return_string() public static void return_string()
{ {
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
Test.AssertEquals("string", obj.ReturnString()); Test.AssertEquals("string", obj.ReturnString());
} }
System.GC.Collect(); System.GC.Collect();
@ -43,7 +43,7 @@ class TestStrings
public static void return_own_string() public static void return_own_string()
{ {
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
Test.AssertEquals("own_string", obj.ReturnOwnString()); Test.AssertEquals("own_string", obj.ReturnOwnString());
} }
System.GC.Collect(); System.GC.Collect();
@ -54,7 +54,7 @@ class TestStrings
{ {
{ {
String str = String.Empty; String str = String.Empty;
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
obj.OutString(out str); obj.OutString(out str);
Test.AssertEquals("out_string", str); Test.AssertEquals("out_string", str);
} }
@ -66,14 +66,14 @@ class TestStrings
{ {
{ {
String str = String.Empty; String str = String.Empty;
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
obj.OutOwnString(out str); obj.OutOwnString(out str);
Test.AssertEquals(str.ToString(), "out_own_string"); Test.AssertEquals(str.ToString(), "out_own_string");
} }
System.GC.Collect(); System.GC.Collect();
} }
private class StringReturner : test.TestingInherit private class StringReturner : Dummy.TestObject
{ {
public String received_in; public String received_in;
public String received_in_own; public String received_in_own;
@ -144,7 +144,7 @@ class TestStrings
* some time in the future */ * some time in the future */
public static void return_string_from_virtual() public static void return_string_from_virtual()
{ {
test.ITesting obj = new StringReturner(); var obj = new StringReturner();
/* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */ /* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */
Test.AssertEquals("inherited", obj.CallReturnString()); Test.AssertEquals("inherited", obj.CallReturnString());
System.GC.Collect(); System.GC.Collect();
@ -153,7 +153,7 @@ class TestStrings
/* The managed wrapper must surrender the ownership to the C after the virtual call. */ /* The managed wrapper must surrender the ownership to the C after the virtual call. */
public static void return_own_string_from_virtual() public static void return_own_string_from_virtual()
{ {
test.ITesting obj = new StringReturner(); var obj = new StringReturner();
/* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */ /* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */
Test.AssertEquals("own_inherited", obj.CallReturnOwnString()); Test.AssertEquals("own_inherited", obj.CallReturnOwnString());
System.GC.Collect(); System.GC.Collect();
@ -163,7 +163,7 @@ class TestStrings
* need to cache it until some time in the future. */ * need to cache it until some time in the future. */
public static void out_string_from_virtual() public static void out_string_from_virtual()
{ {
test.ITesting obj = new StringReturner(); var obj = new StringReturner();
/* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */ /* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */
Test.AssertEquals("out_inherited", obj.CallOutString()); Test.AssertEquals("out_inherited", obj.CallOutString());
System.GC.Collect(); System.GC.Collect();
@ -172,7 +172,7 @@ class TestStrings
/* The managed wrapper gives C the ownership of the filled out parameter */ /* The managed wrapper gives C the ownership of the filled out parameter */
public static void out_own_string_from_virtual() public static void out_own_string_from_virtual()
{ {
test.ITesting obj = new StringReturner(); var obj = new StringReturner();
/* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */ /* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */
Test.AssertEquals("out_own_inherited", obj.CallOutOwnString()); Test.AssertEquals("out_own_inherited", obj.CallOutOwnString());
System.GC.Collect(); System.GC.Collect();
@ -185,7 +185,7 @@ class TestStringshare
public static void in_stringshare() public static void in_stringshare()
{ {
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
String sent = "in_stringshare"; String sent = "in_stringshare";
String returned = obj.InStringshare(sent); String returned = obj.InStringshare(sent);
Test.AssertEquals(sent, returned); Test.AssertEquals(sent, returned);
@ -196,7 +196,7 @@ class TestStringshare
public static void in_own_stringshare() public static void in_own_stringshare()
{ {
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
String sent = "in_own_stringshare"; String sent = "in_own_stringshare";
String returned = obj.InOwnStringshare(sent); String returned = obj.InOwnStringshare(sent);
Test.AssertEquals(sent, returned); Test.AssertEquals(sent, returned);
@ -207,7 +207,7 @@ class TestStringshare
public static void return_stringshare() public static void return_stringshare()
{ {
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
Test.AssertEquals("stringshare", obj.ReturnStringshare()); Test.AssertEquals("stringshare", obj.ReturnStringshare());
} }
System.GC.Collect(); System.GC.Collect();
@ -216,7 +216,7 @@ class TestStringshare
public static void return_own_stringshare() public static void return_own_stringshare()
{ {
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
Test.AssertEquals("own_stringshare", obj.ReturnOwnStringshare()); Test.AssertEquals("own_stringshare", obj.ReturnOwnStringshare());
} }
System.GC.Collect(); System.GC.Collect();
@ -226,7 +226,7 @@ class TestStringshare
{ {
{ {
String str = String.Empty; String str = String.Empty;
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
obj.OutStringshare(out str); obj.OutStringshare(out str);
Test.AssertEquals("out_stringshare", str); Test.AssertEquals("out_stringshare", str);
} }
@ -237,14 +237,14 @@ class TestStringshare
{ {
{ {
String str = String.Empty; String str = String.Empty;
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
obj.OutOwnStringshare(out str); obj.OutOwnStringshare(out str);
Test.AssertEquals(str.ToString(), "out_own_stringshare"); Test.AssertEquals(str.ToString(), "out_own_stringshare");
} }
System.GC.Collect(); System.GC.Collect();
} }
private class StringshareReturner : test.TestingInherit private class StringshareReturner : Dummy.TestObject
{ {
public String received_in; public String received_in;
public String received_in_own; public String received_in_own;
@ -304,28 +304,28 @@ class TestStringshare
public static void return_stringshare_from_virtual() public static void return_stringshare_from_virtual()
{ {
test.ITesting obj = new StringshareReturner(); var obj = new StringshareReturner();
// for (int i = 0; i < 1000000; i ++) // Uncomment this to check for memory leaks. // for (int i = 0; i < 1000000; i ++) // Uncomment this to check for memory leaks.
Test.AssertEquals("inherited", obj.CallReturnStringshare()); Test.AssertEquals("inherited", obj.CallReturnStringshare());
} }
public static void return_own_stringshare_from_virtual() public static void return_own_stringshare_from_virtual()
{ {
test.ITesting obj = new StringshareReturner(); var obj = new StringshareReturner();
// for (int i = 0; i < 1000000; i ++) // Uncomment this to check for memory leaks. // for (int i = 0; i < 1000000; i ++) // Uncomment this to check for memory leaks.
Test.AssertEquals("own_inherited", obj.CallReturnOwnStringshare()); Test.AssertEquals("own_inherited", obj.CallReturnOwnStringshare());
} }
public static void out_stringshare_from_virtual() public static void out_stringshare_from_virtual()
{ {
test.ITesting obj = new StringshareReturner(); var obj = new StringshareReturner();
// for (int i = 0; i < 1000000; i ++) // Uncomment this to check for memory leaks. // for (int i = 0; i < 1000000; i ++) // Uncomment this to check for memory leaks.
Test.AssertEquals("out_inherited", obj.CallOutStringshare()); Test.AssertEquals("out_inherited", obj.CallOutStringshare());
} }
public static void out_own_stringshare_from_virtual() public static void out_own_stringshare_from_virtual()
{ {
test.ITesting obj = new StringshareReturner(); var obj = new StringshareReturner();
// for (int i = 0; i < 1000000; i ++) // Uncomment this to check for memory leaks. // for (int i = 0; i < 1000000; i ++) // Uncomment this to check for memory leaks.
Test.AssertEquals("out_own_inherited", obj.CallOutOwnStringshare()); Test.AssertEquals("out_own_inherited", obj.CallOutOwnStringshare());
} }

View File

@ -11,9 +11,9 @@ class TestStructs
{ {
// Auxiliary function // // Auxiliary function //
private static test.StructSimple structSimpleWithValues() private static Dummy.StructSimple structSimpleWithValues()
{ {
var simple = new test.StructSimple(); var simple = new Dummy.StructSimple();
simple.Fbyte = (sbyte)-126; simple.Fbyte = (sbyte)-126;
simple.Fubyte = (byte) 254u; simple.Fubyte = (byte) 254u;
@ -42,7 +42,7 @@ class TestStructs
simple.Fdouble = -9007199254740992.0; simple.Fdouble = -9007199254740992.0;
simple.Fbool = true; simple.Fbool = true;
simple.Fvoid_ptr = (IntPtr) 0xFE; simple.Fvoid_ptr = (IntPtr) 0xFE;
simple.Fenum = test.SampleEnum.V2; simple.Fenum = Dummy.SampleEnum.V2;
simple.Fstring = "test/string"; simple.Fstring = "test/string";
simple.Fmstring = "test/mstring"; simple.Fmstring = "test/mstring";
simple.Fstringshare = "test/stringshare"; simple.Fstringshare = "test/stringshare";
@ -50,7 +50,7 @@ class TestStructs
return simple; return simple;
} }
private static void checkStructSimple(test.StructSimple simple) private static void checkStructSimple(Dummy.StructSimple simple)
{ {
Test.Assert(simple.Fbyte == (sbyte) -126); Test.Assert(simple.Fbyte == (sbyte) -126);
Test.Assert(simple.Fubyte == (byte) 254u); Test.Assert(simple.Fubyte == (byte) 254u);
@ -79,13 +79,13 @@ class TestStructs
Test.Assert(simple.Fdouble == -9007199254740992.0); Test.Assert(simple.Fdouble == -9007199254740992.0);
Test.Assert(simple.Fbool == true); Test.Assert(simple.Fbool == true);
Test.Assert(simple.Fvoid_ptr == (IntPtr) 0xFE); Test.Assert(simple.Fvoid_ptr == (IntPtr) 0xFE);
Test.Assert(simple.Fenum == test.SampleEnum.V2); Test.Assert(simple.Fenum == Dummy.SampleEnum.V2);
Test.Assert(simple.Fstring == "test/string"); Test.Assert(simple.Fstring == "test/string");
Test.Assert(simple.Fmstring == "test/mstring"); Test.Assert(simple.Fmstring == "test/mstring");
Test.Assert(simple.Fstringshare == "test/stringshare"); Test.Assert(simple.Fstringshare == "test/stringshare");
} }
private static void checkZeroedStructSimple(test.StructSimple simple) private static void checkZeroedStructSimple(Dummy.StructSimple simple)
{ {
Test.Assert(simple.Fbyte == 0); Test.Assert(simple.Fbyte == 0);
Test.Assert(simple.Fubyte == 0); Test.Assert(simple.Fubyte == 0);
@ -114,64 +114,64 @@ class TestStructs
Test.Assert(simple.Fdouble == 0); Test.Assert(simple.Fdouble == 0);
Test.Assert(simple.Fbool == false); Test.Assert(simple.Fbool == false);
Test.Assert(simple.Fvoid_ptr == IntPtr.Zero); Test.Assert(simple.Fvoid_ptr == IntPtr.Zero);
Test.Assert(simple.Fenum == test.SampleEnum.V0); Test.Assert(simple.Fenum == Dummy.SampleEnum.V0);
Test.Assert(simple.Fstring == null); Test.Assert(simple.Fstring == null);
Test.Assert(simple.Fmstring == null); Test.Assert(simple.Fmstring == null);
Test.Assert(simple.Fstringshare == null); Test.Assert(simple.Fstringshare == null);
} }
private static test.StructComplex structComplexWithValues() private static Dummy.StructComplex structComplexWithValues()
{ {
var complex = new test.StructComplex(); var complex = new Dummy.StructComplex();
complex.Farray = new eina.Array<int>(); complex.Farray = new Eina.Array<int>();
complex.Farray.Push(0x0); complex.Farray.Push(0x0);
complex.Farray.Push(0x2A); complex.Farray.Push(0x2A);
complex.Farray.Push(0x42); complex.Farray.Push(0x42);
complex.Finarray = new eina.Inarray<int>(); complex.Finarray = new Eina.Inarray<int>();
complex.Finarray.Push(0x0); complex.Finarray.Push(0x0);
complex.Finarray.Push(0x2A); complex.Finarray.Push(0x2A);
complex.Finarray.Push(0x42); complex.Finarray.Push(0x42);
complex.Flist = new eina.List<string>(); complex.Flist = new Eina.List<string>();
complex.Flist.Append("0x0"); complex.Flist.Append("0x0");
complex.Flist.Append("0x2A"); complex.Flist.Append("0x2A");
complex.Flist.Append("0x42"); complex.Flist.Append("0x42");
complex.Finlist = new eina.Inlist<int>(); complex.Finlist = new Eina.Inlist<int>();
complex.Finlist.Append(0x0); complex.Finlist.Append(0x0);
complex.Finlist.Append(0x2A); complex.Finlist.Append(0x2A);
complex.Finlist.Append(0x42); complex.Finlist.Append(0x42);
complex.Fhash = new eina.Hash<string, string>(); complex.Fhash = new Eina.Hash<string, string>();
complex.Fhash["aa"] = "aaa"; complex.Fhash["aa"] = "aaa";
complex.Fhash["bb"] = "bbb"; complex.Fhash["bb"] = "bbb";
complex.Fhash["cc"] = "ccc"; complex.Fhash["cc"] = "ccc";
complex.Fiterator = complex.Farray.GetIterator(); complex.Fiterator = complex.Farray.GetIterator();
complex.Fany_value = new eina.Value(eina.ValueType.Double); complex.Fany_value = new Eina.Value(Eina.ValueType.Double);
complex.Fany_value.Set(-9007199254740992.0); complex.Fany_value.Set(-9007199254740992.0);
complex.Fany_value_ptr = new eina.Value(eina.ValueType.String); complex.Fany_value_ptr = new Eina.Value(Eina.ValueType.String);
complex.Fany_value_ptr.Set("abc"); complex.Fany_value_ptr.Set("abc");
complex.Fbinbuf = new eina.Binbuf(); complex.Fbinbuf = new Eina.Binbuf();
complex.Fbinbuf.Append(126); complex.Fbinbuf.Append(126);
complex.Fslice.Length = 1; complex.Fslice.Length = 1;
complex.Fslice.Mem = eina.MemoryNative.Alloc(1); complex.Fslice.Mem = Eina.MemoryNative.Alloc(1);
Marshal.WriteByte(complex.Fslice.Mem, 125); Marshal.WriteByte(complex.Fslice.Mem, 125);
complex.Fobj = new test.Numberwrapper(); complex.Fobj = new Dummy.Numberwrapper();
complex.Fobj.SetNumber(42); complex.Fobj.SetNumber(42);
return complex; return complex;
} }
private static void checkStructComplex(test.StructComplex complex) private static void checkStructComplex(Dummy.StructComplex complex)
{ {
Test.Assert(complex.Farray.ToArray().SequenceEqual(base_seq_int)); Test.Assert(complex.Farray.ToArray().SequenceEqual(base_seq_int));
@ -211,7 +211,7 @@ class TestStructs
} }
private static void checkZeroedStructComplex(test.StructComplex complex) private static void checkZeroedStructComplex(Dummy.StructComplex complex)
{ {
Test.Assert(complex.Farray == null); Test.Assert(complex.Farray == null);
Test.Assert(complex.Finarray == null); Test.Assert(complex.Finarray == null);
@ -235,19 +235,19 @@ class TestStructs
private static void simple_default_instantiation() private static void simple_default_instantiation()
{ {
var simple = new test.StructSimple(); var simple = new Dummy.StructSimple();
checkZeroedStructSimple(simple); checkZeroedStructSimple(simple);
} }
private static void complex_default_instantiation() private static void complex_default_instantiation()
{ {
var complex = new test.StructComplex(); var complex = new Dummy.StructComplex();
checkZeroedStructComplex(complex); checkZeroedStructComplex(complex);
} }
public static void parameter_initialization() public static void parameter_initialization()
{ {
var simple = new test.StructSimple(0x1, 0x2, (char)0x3, 0x4, 0x5); var simple = new Dummy.StructSimple(0x1, 0x2, (char)0x3, 0x4, 0x5);
Test.AssertEquals(0x1, simple.Fbyte); Test.AssertEquals(0x1, simple.Fbyte);
Test.AssertEquals(0x2, simple.Fubyte); Test.AssertEquals(0x2, simple.Fubyte);
Test.AssertEquals(0x3, simple.Fchar); Test.AssertEquals(0x3, simple.Fchar);
@ -261,7 +261,7 @@ class TestStructs
public static void simple_in() public static void simple_in()
{ {
var simple = structSimpleWithValues(); var simple = structSimpleWithValues();
test.ITesting t = new test.Testing(); var t = new Dummy.TestObject();
bool r = t.StructSimpleIn(simple); bool r = t.StructSimpleIn(simple);
Test.Assert(r, "Function returned false"); Test.Assert(r, "Function returned false");
} }
@ -271,7 +271,7 @@ class TestStructs
var simple = structSimpleWithValues(); var simple = structSimpleWithValues();
int original = simple.Fint; int original = simple.Fint;
simple.Fmstring = "Struct Ptr In"; simple.Fmstring = "Struct Ptr In";
test.ITesting t = new test.Testing(); var t = new Dummy.TestObject();
Test.Assert(t.StructSimplePtrIn(ref simple)); Test.Assert(t.StructSimplePtrIn(ref simple));
Test.AssertEquals(-original, simple.Fint); Test.AssertEquals(-original, simple.Fint);
Test.AssertEquals("nI rtP tcurtS", simple.Fmstring); Test.AssertEquals("nI rtP tcurtS", simple.Fmstring);
@ -282,16 +282,16 @@ class TestStructs
var simple = structSimpleWithValues(); var simple = structSimpleWithValues();
int original = simple.Fint; int original = simple.Fint;
simple.Fmstring = "Struct Ptr In Own"; simple.Fmstring = "Struct Ptr In Own";
test.ITesting t = new test.Testing(); var t = new Dummy.TestObject();
test.StructSimple result = t.StructSimplePtrInOwn(ref simple); Dummy.StructSimple result = t.StructSimplePtrInOwn(ref simple);
Test.AssertEquals(-original, result.Fint); Test.AssertEquals(-original, result.Fint);
Test.AssertEquals("nwO nI rtP tcurtS", result.Fmstring); Test.AssertEquals("nwO nI rtP tcurtS", result.Fmstring);
} }
public static void simple_out() public static void simple_out()
{ {
var simple = new test.StructSimple(); var simple = new Dummy.StructSimple();
test.ITesting t = new test.Testing(); var t = new Dummy.TestObject();
bool r = t.StructSimpleOut(out simple); bool r = t.StructSimpleOut(out simple);
Test.Assert(r, "Function returned false"); Test.Assert(r, "Function returned false");
checkStructSimple(simple); checkStructSimple(simple);
@ -299,55 +299,55 @@ class TestStructs
public static void simple_ptr_out() public static void simple_ptr_out()
{ {
test.StructSimple simple; Dummy.StructSimple simple;
test.ITesting t = new test.Testing(); var t = new Dummy.TestObject();
test.StructSimple result = t.StructSimplePtrOut(out simple); Dummy.StructSimple result = t.StructSimplePtrOut(out simple);
Test.AssertEquals(result.Fint, simple.Fint); Test.AssertEquals(result.Fint, simple.Fint);
Test.AssertEquals(result.Fstring, simple.Fstring); Test.AssertEquals(result.Fstring, simple.Fstring);
} }
public static void simple_ptr_out_own() public static void simple_ptr_out_own()
{ {
test.StructSimple simple; Dummy.StructSimple simple;
test.ITesting t = new test.Testing(); var t = new Dummy.TestObject();
test.StructSimple result = t.StructSimplePtrOutOwn(out simple); Dummy.StructSimple result = t.StructSimplePtrOutOwn(out simple);
Test.AssertEquals(result.Fint, simple.Fint); Test.AssertEquals(result.Fint, simple.Fint);
Test.AssertEquals(simple.Fstring, "Ptr Out Own"); Test.AssertEquals(simple.Fstring, "Ptr Out Own");
} }
public static void simple_return() public static void simple_return()
{ {
test.ITesting t = new test.Testing(); var t = new Dummy.TestObject();
var simple = t.StructSimpleReturn(); var simple = t.StructSimpleReturn();
checkStructSimple(simple); checkStructSimple(simple);
} }
public static void simple_ptr_return() public static void simple_ptr_return()
{ {
test.ITesting t = new test.Testing(); var t = new Dummy.TestObject();
var simple = t.StructSimplePtrReturn(); var simple = t.StructSimplePtrReturn();
Test.AssertEquals(simple.Fstring, "Ret Ptr"); Test.AssertEquals(simple.Fstring, "Ret Ptr");
} }
public static void simple_ptr_return_own() public static void simple_ptr_return_own()
{ {
test.ITesting t = new test.Testing(); var t = new Dummy.TestObject();
var simple = t.StructSimplePtrReturnOwn(); var simple = t.StructSimplePtrReturnOwn();
Test.AssertEquals(simple.Fstring, "Ret Ptr Own"); Test.AssertEquals(simple.Fstring, "Ret Ptr Own");
} }
public class StructReturner : test.TestingInherit public class StructReturner : Dummy.TestObject
{ {
public test.StructSimple received; public Dummy.StructSimple received;
public bool called; public bool called;
public StructReturner() : base(null) public StructReturner() : base(null)
{ {
called = false; called = false;
received = default(test.StructSimple); received = default(Dummy.StructSimple);
} }
public override bool StructSimpleIn(test.StructSimple simple) public override bool StructSimpleIn(Dummy.StructSimple simple)
{ {
called = true; called = true;
received = simple; received = simple;
@ -355,63 +355,63 @@ class TestStructs
return true; return true;
} }
public override bool StructSimplePtrIn(ref test.StructSimple simple) public override bool StructSimplePtrIn(ref Dummy.StructSimple simple)
{ {
called = true; called = true;
simple.Fstring = "Virtual Struct Ptr In"; simple.Fstring = "Virtual Struct Ptr In";
return true; return true;
} }
public override test.StructSimple StructSimplePtrInOwn(ref test.StructSimple simple) public override Dummy.StructSimple StructSimplePtrInOwn(ref Dummy.StructSimple simple)
{ {
called = true; called = true;
received = simple; received = simple;
return received; return received;
} }
public override bool StructSimpleOut(out test.StructSimple simple) { public override bool StructSimpleOut(out Dummy.StructSimple simple) {
called = true; called = true;
simple = new test.StructSimple(); simple = new Dummy.StructSimple();
simple.Fstring = "Virtual Struct Out"; simple.Fstring = "Virtual Struct Out";
return true; return true;
} }
public override test.StructSimple StructSimplePtrOut(out test.StructSimple simple) { public override Dummy.StructSimple StructSimplePtrOut(out Dummy.StructSimple simple) {
called = true; called = true;
// No way to explicitly define the ownership of the parameter. // No way to explicitly define the ownership of the parameter.
simple = new test.StructSimple(); simple = new Dummy.StructSimple();
simple.Fstring = "Virtual Struct Ptr Out"; simple.Fstring = "Virtual Struct Ptr Out";
return simple; return simple;
} }
public override test.StructSimple StructSimplePtrOutOwn(out test.StructSimple simple) { public override Dummy.StructSimple StructSimplePtrOutOwn(out Dummy.StructSimple simple) {
called = true; called = true;
// No way to explicitly define the ownership of the parameter. // No way to explicitly define the ownership of the parameter.
simple = new test.StructSimple(); simple = new Dummy.StructSimple();
simple.Fstring = "Virtual Struct Ptr Out Own"; simple.Fstring = "Virtual Struct Ptr Out Own";
return simple; return simple;
} }
public override test.StructSimple StructSimpleReturn() public override Dummy.StructSimple StructSimpleReturn()
{ {
called = true; called = true;
var simple = new test.StructSimple(); var simple = new Dummy.StructSimple();
simple.Fstring = "Virtual Struct Return"; simple.Fstring = "Virtual Struct Return";
return simple; return simple;
} }
public override test.StructSimple StructSimplePtrReturn() public override Dummy.StructSimple StructSimplePtrReturn()
{ {
called = true; called = true;
var simple = new test.StructSimple(); var simple = new Dummy.StructSimple();
simple.Fstring = "Virtual Struct Ptr Return"; simple.Fstring = "Virtual Struct Ptr Return";
return simple; return simple;
} }
public override test.StructSimple StructSimplePtrReturnOwn() public override Dummy.StructSimple StructSimplePtrReturnOwn()
{ {
called = true; called = true;
var simple = new test.StructSimple(); var simple = new Dummy.StructSimple();
simple.Fstring = "Virtual Struct Ptr Return Own"; simple.Fstring = "Virtual Struct Ptr Return Own";
return simple; return simple;
} }
@ -453,7 +453,7 @@ class TestStructs
public static void simple_out_virtual() public static void simple_out_virtual()
{ {
StructReturner t = new StructReturner(); StructReturner t = new StructReturner();
test.StructSimple simple; Dummy.StructSimple simple;
t.CallStructSimpleOut(out simple); t.CallStructSimpleOut(out simple);
Test.Assert(t.called, "override was not called"); Test.Assert(t.called, "override was not called");
Test.AssertEquals("Virtual Struct Out", simple.Fstring); Test.AssertEquals("Virtual Struct Out", simple.Fstring);
@ -462,7 +462,7 @@ class TestStructs
public static void simple_ptr_out_virtual() public static void simple_ptr_out_virtual()
{ {
StructReturner t = new StructReturner(); StructReturner t = new StructReturner();
test.StructSimple simple; Dummy.StructSimple simple;
t.CallStructSimplePtrOut(out simple); t.CallStructSimplePtrOut(out simple);
Test.Assert(t.called, "override was not called"); Test.Assert(t.called, "override was not called");
Test.AssertEquals("Virtual Struct Ptr Out", simple.Fstring); Test.AssertEquals("Virtual Struct Ptr Out", simple.Fstring);
@ -471,7 +471,7 @@ class TestStructs
public static void simple_ptr_out_own_virtual() public static void simple_ptr_out_own_virtual()
{ {
StructReturner t = new StructReturner(); StructReturner t = new StructReturner();
test.StructSimple simple; Dummy.StructSimple simple;
t.CallStructSimplePtrOutOwn(out simple); t.CallStructSimplePtrOutOwn(out simple);
Test.Assert(t.called, "override was not called"); Test.Assert(t.called, "override was not called");
Test.AssertEquals("Virtual Struct Ptr Out Own", simple.Fstring); Test.AssertEquals("Virtual Struct Ptr Out Own", simple.Fstring);
@ -480,7 +480,7 @@ class TestStructs
public static void simple_return_virtual() public static void simple_return_virtual()
{ {
StructReturner t = new StructReturner(); StructReturner t = new StructReturner();
test.StructSimple simple = t.CallStructSimpleReturn(); Dummy.StructSimple simple = t.CallStructSimpleReturn();
Test.Assert(t.called, "override was not called"); Test.Assert(t.called, "override was not called");
Test.AssertEquals("Virtual Struct Return", simple.Fstring); Test.AssertEquals("Virtual Struct Return", simple.Fstring);
} }
@ -488,7 +488,7 @@ class TestStructs
public static void simple_ptr_return_virtual() public static void simple_ptr_return_virtual()
{ {
StructReturner t = new StructReturner(); StructReturner t = new StructReturner();
test.StructSimple simple = t.CallStructSimplePtrReturn(); Dummy.StructSimple simple = t.CallStructSimplePtrReturn();
Test.Assert(t.called, "override was not called"); Test.Assert(t.called, "override was not called");
Test.AssertEquals("Virtual Struct Ptr Return", simple.Fstring); Test.AssertEquals("Virtual Struct Ptr Return", simple.Fstring);
} }
@ -496,7 +496,7 @@ class TestStructs
public static void simple_ptr_return_own_virtual() public static void simple_ptr_return_own_virtual()
{ {
StructReturner t = new StructReturner(); StructReturner t = new StructReturner();
test.StructSimple simple = t.CallStructSimplePtrReturnOwn(); Dummy.StructSimple simple = t.CallStructSimplePtrReturnOwn();
Test.Assert(t.called, "override was not called"); Test.Assert(t.called, "override was not called");
Test.AssertEquals("Virtual Struct Ptr Return Own", simple.Fstring); Test.AssertEquals("Virtual Struct Ptr Return Own", simple.Fstring);
} }
@ -505,7 +505,7 @@ class TestStructs
public static void complex_in() public static void complex_in()
{ {
var complex = structComplexWithValues(); var complex = structComplexWithValues();
test.ITesting t = new test.Testing(); var t = new Dummy.TestObject();
bool r = t.StructComplexIn(complex); bool r = t.StructComplexIn(complex);
Test.Assert(r, "Function returned false"); Test.Assert(r, "Function returned false");
} }
@ -520,8 +520,8 @@ class TestStructs
public static void complex_out() public static void complex_out()
{ {
var complex = new test.StructComplex(); var complex = new Dummy.StructComplex();
test.ITesting t = new test.Testing(); var t = new Dummy.TestObject();
bool r = t.StructComplexOut(out complex); bool r = t.StructComplexOut(out complex);
Test.Assert(r, "Function returned false"); Test.Assert(r, "Function returned false");
checkStructComplex(complex); checkStructComplex(complex);
@ -537,7 +537,7 @@ class TestStructs
public static void complex_return() public static void complex_return()
{ {
test.ITesting t = new test.Testing(); var t = new Dummy.TestObject();
var complex = t.StructComplexReturn(); var complex = t.StructComplexReturn();
checkStructComplex(complex); checkStructComplex(complex);
} }

View File

@ -13,7 +13,7 @@ public static class TestEinaValue {
public static void TestByteSimple() public static void TestByteSimple()
{ {
using (eina.Value v = new eina.Value(eina.ValueType.Byte)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.Byte)) {
byte val = 0xff; byte val = 0xff;
Test.Assert(v.Set(val)); Test.Assert(v.Set(val));
byte x; byte x;
@ -24,7 +24,7 @@ public static class TestEinaValue {
public static void TestSByteSimple() public static void TestSByteSimple()
{ {
using (eina.Value v = new eina.Value(eina.ValueType.SByte)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.SByte)) {
sbyte val = -45; sbyte val = -45;
Test.Assert(v.Set(val)); Test.Assert(v.Set(val));
sbyte x; sbyte x;
@ -35,7 +35,7 @@ public static class TestEinaValue {
public static void TestShortSimple() public static void TestShortSimple()
{ {
using (eina.Value v = new eina.Value(eina.ValueType.Short)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.Short)) {
short val = -128; short val = -128;
Test.Assert(v.Set(val)); Test.Assert(v.Set(val));
short x; short x;
@ -46,7 +46,7 @@ public static class TestEinaValue {
public static void TestUShortSimple() public static void TestUShortSimple()
{ {
using (eina.Value v = new eina.Value(eina.ValueType.UShort)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.UShort)) {
ushort val = 0xff55; ushort val = 0xff55;
Test.Assert(v.Set(val)); Test.Assert(v.Set(val));
ushort x; ushort x;
@ -57,7 +57,7 @@ public static class TestEinaValue {
public static void TestLongSimple() public static void TestLongSimple()
{ {
using (eina.Value v = new eina.Value(eina.ValueType.Long)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.Long)) {
long val = 0xdeadbeef; long val = 0xdeadbeef;
Test.Assert(v.Set(val)); Test.Assert(v.Set(val));
long x; long x;
@ -68,7 +68,7 @@ public static class TestEinaValue {
public static void TestULongSimple() public static void TestULongSimple()
{ {
using (eina.Value v = new eina.Value(eina.ValueType.ULong)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.ULong)) {
ulong val = 0xdeadbeef; ulong val = 0xdeadbeef;
Test.Assert(v.Set(val)); Test.Assert(v.Set(val));
ulong x; ulong x;
@ -79,7 +79,7 @@ public static class TestEinaValue {
public static void TestFloatSimple() public static void TestFloatSimple()
{ {
using (eina.Value v = new eina.Value(eina.ValueType.Float)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.Float)) {
float val = 1.609344f; float val = 1.609344f;
Test.Assert(v.Set(val)); Test.Assert(v.Set(val));
float x; float x;
@ -90,7 +90,7 @@ public static class TestEinaValue {
public static void TestDoubleSimple() public static void TestDoubleSimple()
{ {
using (eina.Value v = new eina.Value(eina.ValueType.Double)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.Double)) {
double val = 1.609344; double val = 1.609344;
Test.Assert(v.Set(val)); Test.Assert(v.Set(val));
double x; double x;
@ -102,7 +102,7 @@ public static class TestEinaValue {
public static void TestIntSimple() public static void TestIntSimple()
{ {
using (eina.Value v = new eina.Value(eina.ValueType.Int32)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.Int32)) {
Test.Assert(v.Set(32)); Test.Assert(v.Set(32));
int x; int x;
Test.Assert(v.Get(out x)); Test.Assert(v.Get(out x));
@ -116,7 +116,7 @@ public static class TestEinaValue {
public static void TestUIntSimple() public static void TestUIntSimple()
{ {
using (eina.Value v = new eina.Value(eina.ValueType.Int32)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.Int32)) {
Test.Assert(v.Set(0xdeadbeef)); Test.Assert(v.Set(0xdeadbeef));
uint x = 0; uint x = 0;
Test.Assert(v.Get(out x)); Test.Assert(v.Get(out x));
@ -126,7 +126,7 @@ public static class TestEinaValue {
public static void TestStringSimple() public static void TestStringSimple()
{ {
using (eina.Value v = new eina.Value(eina.ValueType.String)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.String)) {
string expected_str = "Hello"; string expected_str = "Hello";
Test.Assert(v.Set(expected_str)); Test.Assert(v.Set(expected_str));
string str = null; string str = null;
@ -137,10 +137,10 @@ public static class TestEinaValue {
public static void TestErrorSimple() public static void TestErrorSimple()
{ {
using (eina.Value v = new eina.Value(eina.ValueType.Error)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.Error)) {
eina.Error error = new eina.Error(eina.Error.NO_ERROR); Eina.Error error = new Eina.Error(Eina.Error.NO_ERROR);
Test.Assert(v.Set(error)); Test.Assert(v.Set(error));
eina.Error x; Eina.Error x;
Test.Assert(v.Get(out x)); Test.Assert(v.Get(out x));
Test.AssertEquals(error, x); Test.AssertEquals(error, x);
} }
@ -148,10 +148,10 @@ public static class TestEinaValue {
public static void TestSetWrongType() public static void TestSetWrongType()
{ {
using (eina.Value v = new eina.Value(eina.ValueType.String)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.String)) {
Test.AssertRaises<ArgumentException>(() => v.Set(42)); Test.AssertRaises<ArgumentException>(() => v.Set(42));
Test.AssertNotRaises<ArgumentException>(() => v.Set("Wumpus")); Test.AssertNotRaises<ArgumentException>(() => v.Set("Wumpus"));
Test.Assert(v.Setup(eina.ValueType.Int32)); Test.Assert(v.Setup(Eina.ValueType.Int32));
Test.AssertRaises<ArgumentException>(() => v.Set("Wat?")); Test.AssertRaises<ArgumentException>(() => v.Set("Wat?"));
Test.AssertNotRaises<ArgumentException>(() => v.Set(1984)); Test.AssertNotRaises<ArgumentException>(() => v.Set(1984));
} }
@ -159,12 +159,12 @@ public static class TestEinaValue {
public static void TestValueSetup() public static void TestValueSetup()
{ {
using (eina.Value v = new eina.Value(eina.ValueType.Int32)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.Int32)) {
Test.Assert(v.Set(44)); Test.Assert(v.Set(44));
int x = 0; int x = 0;
Test.Assert(v.Get(out x)); Test.Assert(v.Get(out x));
Test.AssertEquals(44, x); Test.AssertEquals(44, x);
v.Setup(eina.ValueType.String); v.Setup(Eina.ValueType.String);
string str = "Hello"; string str = "Hello";
Test.Assert(v.Get(out str)); Test.Assert(v.Get(out str));
@ -174,7 +174,7 @@ public static class TestEinaValue {
public static void TestValueDispose() public static void TestValueDispose()
{ {
eina.Value v = new eina.Value(eina.ValueType.Int32); Eina.Value v = new Eina.Value(Eina.ValueType.Int32);
v.Dispose(); v.Dispose();
Test.AssertRaises<ObjectDisposedException>(v.Flush); Test.AssertRaises<ObjectDisposedException>(v.Flush);
Test.AssertRaises<ObjectDisposedException>(() => v.ToString()); Test.AssertRaises<ObjectDisposedException>(() => v.ToString());
@ -183,34 +183,34 @@ public static class TestEinaValue {
public static void TestValueFlush() public static void TestValueFlush()
{ {
using (eina.Value v = new eina.Value(eina.ValueType.Int32)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.Int32)) {
Test.Assert(v.Set(44)); Test.Assert(v.Set(44));
Test.Assert(!v.Flushed); Test.Assert(!v.Flushed);
v.Flush(); v.Flush();
Test.Assert(v.Flushed); Test.Assert(v.Flushed);
int x; int x;
Test.AssertRaises<eina.ValueFlushedException>(() => v.Get(out x)); Test.AssertRaises<Eina.ValueFlushedException>(() => v.Get(out x));
x = 42; x = 42;
Test.AssertRaises<eina.ValueFlushedException>(() => v.Set(x)); Test.AssertRaises<Eina.ValueFlushedException>(() => v.Set(x));
v.Setup(eina.ValueType.String); v.Setup(Eina.ValueType.String);
Test.AssertNotRaises<eina.ValueFlushedException>(() => v.Set("Hello, EFL")); Test.AssertNotRaises<Eina.ValueFlushedException>(() => v.Set("Hello, EFL"));
string y = String.Empty; string y = String.Empty;
Test.AssertNotRaises<eina.ValueFlushedException>(() => v.Get(out y)); Test.AssertNotRaises<Eina.ValueFlushedException>(() => v.Get(out y));
v.Flush(); v.Flush();
Test.AssertRaises<eina.ValueFlushedException>(() => v.Get(out y)); Test.AssertRaises<Eina.ValueFlushedException>(() => v.Get(out y));
v.Setup(eina.ValueType.Array, eina.ValueType.UInt32); v.Setup(Eina.ValueType.Array, Eina.ValueType.UInt32);
Test.AssertNotRaises<eina.ValueFlushedException>(() => Test.AssertNotRaises<Eina.ValueFlushedException>(() =>
v.Append(42)); v.Append(42));
v.Flush(); v.Flush();
Test.AssertRaises<eina.ValueFlushedException>(() => Test.AssertRaises<Eina.ValueFlushedException>(() =>
v.Append(42)); v.Append(42));
Test.AssertRaises<eina.ValueFlushedException>(() => v.GetValueSubType()); Test.AssertRaises<Eina.ValueFlushedException>(() => v.GetValueSubType());
} }
} }
@ -218,7 +218,7 @@ public static class TestEinaValue {
private delegate bool BoolRet(); private delegate bool BoolRet();
public static void TestValueOptionalInt() public static void TestValueOptionalInt()
{ {
using (eina.Value a = new eina.Value(eina.ValueType.Optional)) { using (Eina.Value a = new Eina.Value(Eina.ValueType.Optional)) {
Test.Assert(a.Optional); Test.Assert(a.Optional);
Test.Assert(a.OptionalEmpty); // By default, optional values are empty Test.Assert(a.OptionalEmpty); // By default, optional values are empty
@ -242,7 +242,7 @@ public static class TestEinaValue {
} }
public static void TestValueOptionalUint() public static void TestValueOptionalUint()
{ {
using (eina.Value a = new eina.Value(eina.ValueType.Optional)) { using (Eina.Value a = new Eina.Value(Eina.ValueType.Optional)) {
Test.Assert(a.Optional); Test.Assert(a.Optional);
Test.Assert(a.OptionalEmpty); // By default, optional values are empty Test.Assert(a.OptionalEmpty); // By default, optional values are empty
@ -266,13 +266,13 @@ public static class TestEinaValue {
} }
public static void TestValueOptionalString() public static void TestValueOptionalString()
{ {
using (eina.Value a = new eina.Value(eina.ValueType.Int32)) { using (Eina.Value a = new Eina.Value(Eina.ValueType.Int32)) {
Test.Assert(!a.Optional); Test.Assert(!a.Optional);
BoolRet dummy = () => a.OptionalEmpty; BoolRet dummy = () => a.OptionalEmpty;
Test.AssertRaises<eina.InvalidValueTypeException>(() => dummy()); Test.AssertRaises<Eina.InvalidValueTypeException>(() => dummy());
} }
using (eina.Value a = new eina.Value(eina.ValueType.Optional)) { using (Eina.Value a = new Eina.Value(Eina.ValueType.Optional)) {
Test.Assert(a.Optional); Test.Assert(a.Optional);
Test.Assert(a.OptionalEmpty); // By default, optional values are empty Test.Assert(a.OptionalEmpty); // By default, optional values are empty
@ -296,9 +296,9 @@ public static class TestEinaValue {
} }
public static void TestValueOptionalArrays() public static void TestValueOptionalArrays()
{ {
using (eina.Value a = new eina.Value(eina.ValueType.Optional)) using (Eina.Value a = new Eina.Value(Eina.ValueType.Optional))
using (eina.Value expected = new eina.Value(eina.ValueType.Array, using (Eina.Value expected = new Eina.Value(Eina.ValueType.Array,
eina.ValueType.Int32)) Eina.ValueType.Int32))
{ {
Test.Assert(a.Optional); Test.Assert(a.Optional);
@ -320,7 +320,7 @@ public static class TestEinaValue {
Test.Assert(a.Set(expected)); Test.Assert(a.Set(expected));
Test.Assert(!a.OptionalEmpty); Test.Assert(!a.OptionalEmpty);
eina.Value actual = null; Eina.Value actual = null;
Test.Assert(a.Get(out actual)); Test.Assert(a.Get(out actual));
Test.AssertEquals(expected, actual); Test.AssertEquals(expected, actual);
@ -330,9 +330,9 @@ public static class TestEinaValue {
} }
public static void TestValueOptionalLists() public static void TestValueOptionalLists()
{ {
using (eina.Value a = new eina.Value(eina.ValueType.Optional)) using (Eina.Value a = new Eina.Value(Eina.ValueType.Optional))
using (eina.Value expected = new eina.Value(eina.ValueType.List, using (Eina.Value expected = new Eina.Value(Eina.ValueType.List,
eina.ValueType.Int32)) Eina.ValueType.Int32))
{ {
Test.Assert(a.Optional); Test.Assert(a.Optional);
@ -354,7 +354,7 @@ public static class TestEinaValue {
Test.Assert(a.Set(expected)); Test.Assert(a.Set(expected));
Test.Assert(!a.OptionalEmpty); Test.Assert(!a.OptionalEmpty);
eina.Value actual = null; Eina.Value actual = null;
Test.Assert(a.Get(out actual)); Test.Assert(a.Get(out actual));
Test.AssertEquals(expected, actual); Test.AssertEquals(expected, actual);
} }
@ -362,8 +362,8 @@ public static class TestEinaValue {
public static void TestValueCompareInts() public static void TestValueCompareInts()
{ {
using (eina.Value a = new eina.Value(eina.ValueType.Int32)) using (Eina.Value a = new Eina.Value(Eina.ValueType.Int32))
using (eina.Value b = new eina.Value(eina.ValueType.Int32)) { using (Eina.Value b = new Eina.Value(Eina.ValueType.Int32)) {
Test.Assert(a.Set(123)); Test.Assert(a.Set(123));
Test.Assert(b.Set(123)); Test.Assert(b.Set(123));
Test.AssertEquals(0, a.CompareTo(b)); Test.AssertEquals(0, a.CompareTo(b));
@ -379,9 +379,9 @@ public static class TestEinaValue {
public static void TestValueComparisonEquals() public static void TestValueComparisonEquals()
{ {
using (eina.Value a = new eina.Value(eina.ValueType.Int32)) using (Eina.Value a = new Eina.Value(Eina.ValueType.Int32))
using (eina.Value b = new eina.Value(eina.ValueType.Int32)) using (Eina.Value b = new Eina.Value(Eina.ValueType.Int32))
using (eina.Value c = new eina.Value(eina.ValueType.Int32)) { using (Eina.Value c = new Eina.Value(Eina.ValueType.Int32)) {
Test.Assert(a.Set(1)); Test.Assert(a.Set(1));
Test.Assert(b.Set(1)); Test.Assert(b.Set(1));
Test.Assert(c.Set(1)); Test.Assert(c.Set(1));
@ -399,8 +399,8 @@ public static class TestEinaValue {
public static void TestValueComparisonOverloadEquals() public static void TestValueComparisonOverloadEquals()
{ {
using (eina.Value a = new eina.Value(eina.ValueType.Int32)) using (Eina.Value a = new Eina.Value(Eina.ValueType.Int32))
using (eina.Value b = new eina.Value(eina.ValueType.Int32)) { using (Eina.Value b = new Eina.Value(Eina.ValueType.Int32)) {
Test.Assert(a.Set(1)); Test.Assert(a.Set(1));
Test.Assert(b.Set(1)); Test.Assert(b.Set(1));
@ -423,8 +423,8 @@ public static class TestEinaValue {
public static void TestValueComparisonOverloadLessMore() public static void TestValueComparisonOverloadLessMore()
{ {
using (eina.Value a = new eina.Value(eina.ValueType.Int32)) using (Eina.Value a = new Eina.Value(Eina.ValueType.Int32))
using (eina.Value b = new eina.Value(eina.ValueType.Int32)) { using (Eina.Value b = new Eina.Value(Eina.ValueType.Int32)) {
Test.Assert(a.Set(1)); Test.Assert(a.Set(1));
Test.Assert(b.Set(0)); Test.Assert(b.Set(0));
@ -437,8 +437,8 @@ public static class TestEinaValue {
public static void TestValueCompareStrings() public static void TestValueCompareStrings()
{ {
using (eina.Value a = new eina.Value(eina.ValueType.String)) using (Eina.Value a = new Eina.Value(Eina.ValueType.String))
using (eina.Value b = new eina.Value(eina.ValueType.String)) { using (Eina.Value b = new Eina.Value(Eina.ValueType.String)) {
Test.Assert(a.Set("aaa")); Test.Assert(a.Set("aaa"));
Test.Assert(b.Set("aaa")); Test.Assert(b.Set("aaa"));
Test.AssertEquals(0, a.CompareTo(b)); Test.AssertEquals(0, a.CompareTo(b));
@ -455,8 +455,8 @@ public static class TestEinaValue {
public static void TestValueCompareArray() public static void TestValueCompareArray()
{ {
using(eina.Value a = new eina.Value(eina.ValueType.Array, eina.ValueType.Int32)) using(Eina.Value a = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.Int32))
using(eina.Value b = new eina.Value(eina.ValueType.Array, eina.ValueType.Int32)) { using(Eina.Value b = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.Int32)) {
Test.AssertEquals(a, b); Test.AssertEquals(a, b);
@ -498,8 +498,8 @@ public static class TestEinaValue {
public static void TestValueCompareList() public static void TestValueCompareList()
{ {
using(eina.Value a = new eina.Value(eina.ValueType.List, eina.ValueType.Int32)) using(Eina.Value a = new Eina.Value(Eina.ValueType.List, Eina.ValueType.Int32))
using(eina.Value b = new eina.Value(eina.ValueType.List, eina.ValueType.Int32)) { using(Eina.Value b = new Eina.Value(Eina.ValueType.List, Eina.ValueType.Int32)) {
Test.AssertEquals(a, b); Test.AssertEquals(a, b);
@ -546,7 +546,7 @@ public static class TestEinaValue {
public static void TestValueToString() public static void TestValueToString()
{ {
using(eina.Value a = new eina.Value(eina.ValueType.Int32)) { using(Eina.Value a = new Eina.Value(Eina.ValueType.Int32)) {
int i = -12345; int i = -12345;
string x = $"{i}"; string x = $"{i}";
Test.Assert(a.Set(i)); Test.Assert(a.Set(i));
@ -554,13 +554,13 @@ public static class TestEinaValue {
uint u = 0xdeadbeef; uint u = 0xdeadbeef;
x = $"{u}"; x = $"{u}";
Test.Assert(a.Setup(eina.ValueType.UInt32)); Test.Assert(a.Setup(Eina.ValueType.UInt32));
Test.Assert(a.Set(u)); Test.Assert(a.Set(u));
Test.AssertEquals(x, a.ToString()); Test.AssertEquals(x, a.ToString());
string s = "Hello, Johnny!"; string s = "Hello, Johnny!";
x = s; x = s;
Test.Assert(a.Setup(eina.ValueType.String)); Test.Assert(a.Setup(Eina.ValueType.String));
Test.Assert(a.Set(s)); Test.Assert(a.Set(s));
Test.AssertEquals(x, a.ToString()); Test.AssertEquals(x, a.ToString());
} }
@ -568,8 +568,8 @@ public static class TestEinaValue {
public static void TestValueConvertInt() public static void TestValueConvertInt()
{ {
using(eina.Value from = new eina.Value(eina.ValueType.Int32)) using(Eina.Value from = new Eina.Value(Eina.ValueType.Int32))
using(eina.Value to = new eina.Value(eina.ValueType.UInt32)) { using(Eina.Value to = new Eina.Value(Eina.ValueType.UInt32)) {
int source = 0x7FFFFFFF; int source = 0x7FFFFFFF;
uint target_uint; uint target_uint;
int target_int; int target_int;
@ -581,12 +581,12 @@ public static class TestEinaValue {
Test.Assert(to.Get(out target_uint)); Test.Assert(to.Get(out target_uint));
Test.AssertEquals(target_uint, (uint)source); Test.AssertEquals(target_uint, (uint)source);
Test.Assert(to.Setup(eina.ValueType.Int32)); Test.Assert(to.Setup(Eina.ValueType.Int32));
Test.Assert(from.ConvertTo(to)); Test.Assert(from.ConvertTo(to));
Test.Assert(to.Get(out target_int)); Test.Assert(to.Get(out target_int));
Test.AssertEquals(target_int, source); Test.AssertEquals(target_int, source);
Test.Assert(to.Setup(eina.ValueType.String)); Test.Assert(to.Setup(Eina.ValueType.String));
Test.Assert(from.ConvertTo(to)); Test.Assert(from.ConvertTo(to));
Test.Assert(to.Get(out target_str)); Test.Assert(to.Get(out target_str));
Test.AssertEquals(target_str, source_str); Test.AssertEquals(target_str, source_str);
@ -598,8 +598,8 @@ public static class TestEinaValue {
public static void TestValueConvertUInt() public static void TestValueConvertUInt()
{ {
using(eina.Value from = new eina.Value(eina.ValueType.UInt32)) using(Eina.Value from = new Eina.Value(Eina.ValueType.UInt32))
using(eina.Value to = new eina.Value(eina.ValueType.UInt32)) { using(Eina.Value to = new Eina.Value(Eina.ValueType.UInt32)) {
uint source = 0xFFFFFFFF; uint source = 0xFFFFFFFF;
uint target_uint; uint target_uint;
string target_str; string target_str;
@ -610,10 +610,10 @@ public static class TestEinaValue {
Test.Assert(to.Get(out target_uint)); Test.Assert(to.Get(out target_uint));
Test.AssertEquals(target_uint, source); Test.AssertEquals(target_uint, source);
Test.Assert(to.Setup(eina.ValueType.Int32)); Test.Assert(to.Setup(Eina.ValueType.Int32));
Test.Assert(!from.ConvertTo(to)); Test.Assert(!from.ConvertTo(to));
Test.Assert(to.Setup(eina.ValueType.String)); Test.Assert(to.Setup(Eina.ValueType.String));
Test.Assert(from.ConvertTo(to)); Test.Assert(from.ConvertTo(to));
Test.Assert(to.Get(out target_str)); Test.Assert(to.Get(out target_str));
Test.AssertEquals(target_str, source_str); Test.AssertEquals(target_str, source_str);
@ -626,21 +626,21 @@ public static class TestEinaValue {
public static void TestValueContainerConstructorWrongArgs() public static void TestValueContainerConstructorWrongArgs()
{ {
Test.AssertRaises<ArgumentException>(() => { Test.AssertRaises<ArgumentException>(() => {
using(eina.Value array = new eina.Value(eina.ValueType.String, eina.ValueType.String)) { } using(Eina.Value array = new Eina.Value(Eina.ValueType.String, Eina.ValueType.String)) { }
}); });
} }
public static void TestValueContainerWithNonContainerAccess() public static void TestValueContainerWithNonContainerAccess()
{ {
using(eina.Value array = new eina.Value(eina.ValueType.Int32)) { using(Eina.Value array = new Eina.Value(Eina.ValueType.Int32)) {
Test.AssertRaises<eina.InvalidValueTypeException>(() => array[0] = 1); Test.AssertRaises<Eina.InvalidValueTypeException>(() => array[0] = 1);
object val = null; object val = null;
Test.AssertRaises<eina.InvalidValueTypeException>(() => val = array[0]); Test.AssertRaises<Eina.InvalidValueTypeException>(() => val = array[0]);
} }
} }
public static void TestValueArray() { public static void TestValueArray() {
using(eina.Value array = new eina.Value(eina.ValueType.Array, eina.ValueType.Int32)) { using(Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.Int32)) {
Test.AssertEquals(0, array.Count()); Test.AssertEquals(0, array.Count());
Test.Assert(array.Append(0)); Test.Assert(array.Append(0));
Test.AssertEquals(1, array.Count()); Test.AssertEquals(1, array.Count());
@ -669,13 +669,13 @@ public static class TestEinaValue {
Test.AssertEquals("[1984, -42, 5, 42]", array.ToString()); Test.AssertEquals("[1984, -42, 5, 42]", array.ToString());
} }
using(eina.Value array = new eina.Value(eina.ValueType.Array, eina.ValueType.UInt32)) { using(Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.UInt32)) {
Test.Assert(array.Append(2)); Test.Assert(array.Append(2));
Test.AssertEquals((uint)array[0], (uint)2); Test.AssertEquals((uint)array[0], (uint)2);
Test.AssertRaises<OverflowException>(() => array[0] = -1); Test.AssertRaises<OverflowException>(() => array[0] = -1);
} }
using(eina.Value array = new eina.Value(eina.ValueType.Array, eina.ValueType.String)) { using(Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.String)) {
Test.Assert(array.Append("hello")); Test.Assert(array.Append("hello"));
Test.Assert(array.Append("world")); Test.Assert(array.Append("world"));
@ -692,7 +692,7 @@ public static class TestEinaValue {
} }
public static void TestArrayOutOfBounds() { public static void TestArrayOutOfBounds() {
using(eina.Value array = new eina.Value(eina.ValueType.Array, eina.ValueType.Int32)) { using(Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.Int32)) {
object placeholder = null; object placeholder = null;
Test.AssertRaises<System.ArgumentOutOfRangeException>(() => array[0] = 1); Test.AssertRaises<System.ArgumentOutOfRangeException>(() => array[0] = 1);
Test.AssertRaises<System.ArgumentOutOfRangeException>(() => placeholder = array[0]); Test.AssertRaises<System.ArgumentOutOfRangeException>(() => placeholder = array[0]);
@ -708,16 +708,16 @@ public static class TestEinaValue {
} }
public static void TestValueArraySubType() { public static void TestValueArraySubType() {
using(eina.Value array = new eina.Value(eina.ValueType.Array, eina.ValueType.Int32)) using(Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.Int32))
Test.AssertEquals(eina.ValueType.Int32, array.GetValueSubType()); Test.AssertEquals(Eina.ValueType.Int32, array.GetValueSubType());
using(eina.Value array = new eina.Value(eina.ValueType.Array, eina.ValueType.UInt32)) using(Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.UInt32))
Test.AssertEquals(eina.ValueType.UInt32, array.GetValueSubType()); Test.AssertEquals(Eina.ValueType.UInt32, array.GetValueSubType());
} }
public static void TestValueArrayConvert() { public static void TestValueArrayConvert() {
using(eina.Value array = new eina.Value(eina.ValueType.Array, eina.ValueType.Int32)) using(Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.Int32))
using(eina.Value other = new eina.Value(eina.ValueType.Int32)) { using(Eina.Value other = new Eina.Value(Eina.ValueType.Int32)) {
other.Set(100); other.Set(100);
other.ConvertTo(array); other.ConvertTo(array);
Test.AssertEquals(100, (int)array[0]); Test.AssertEquals(100, (int)array[0]);
@ -726,7 +726,7 @@ public static class TestEinaValue {
} }
public static void TestValueList() { public static void TestValueList() {
using(eina.Value list = new eina.Value(eina.ValueType.List, eina.ValueType.Int32)) { using(Eina.Value list = new Eina.Value(Eina.ValueType.List, Eina.ValueType.Int32)) {
Test.AssertEquals(0, list.Count()); Test.AssertEquals(0, list.Count());
Test.Assert(list.Append(0)); Test.Assert(list.Append(0));
Test.AssertEquals(1, list.Count()); Test.AssertEquals(1, list.Count());
@ -755,13 +755,13 @@ public static class TestEinaValue {
Test.AssertEquals("[1984, -42, 5, 42]", list.ToString()); Test.AssertEquals("[1984, -42, 5, 42]", list.ToString());
} }
using(eina.Value list = new eina.Value(eina.ValueType.List, eina.ValueType.UInt32)) { using(Eina.Value list = new Eina.Value(Eina.ValueType.List, Eina.ValueType.UInt32)) {
Test.Assert(list.Append(2)); Test.Assert(list.Append(2));
Test.AssertEquals((uint)list[0], (uint)2); Test.AssertEquals((uint)list[0], (uint)2);
Test.AssertRaises<OverflowException>(() => list[0] = -1); Test.AssertRaises<OverflowException>(() => list[0] = -1);
} }
using(eina.Value list = new eina.Value(eina.ValueType.List, eina.ValueType.String)) { using(Eina.Value list = new Eina.Value(Eina.ValueType.List, Eina.ValueType.String)) {
Test.Assert(list.Append("hello")); Test.Assert(list.Append("hello"));
Test.Assert(list.Append("world")); Test.Assert(list.Append("world"));
@ -778,7 +778,7 @@ public static class TestEinaValue {
} }
public static void TestListOutOfBounds() { public static void TestListOutOfBounds() {
using(eina.Value list = new eina.Value(eina.ValueType.List, eina.ValueType.Int32)) { using(Eina.Value list = new Eina.Value(Eina.ValueType.List, Eina.ValueType.Int32)) {
object placeholder = null; object placeholder = null;
Test.AssertRaises<System.ArgumentOutOfRangeException>(() => list[0] = 1); Test.AssertRaises<System.ArgumentOutOfRangeException>(() => list[0] = 1);
Test.AssertRaises<System.ArgumentOutOfRangeException>(() => placeholder = list[0]); Test.AssertRaises<System.ArgumentOutOfRangeException>(() => placeholder = list[0]);
@ -794,16 +794,16 @@ public static class TestEinaValue {
} }
public static void TestValueListSubType() { public static void TestValueListSubType() {
using(eina.Value list = new eina.Value(eina.ValueType.List, eina.ValueType.Int32)) using(Eina.Value list = new Eina.Value(Eina.ValueType.List, Eina.ValueType.Int32))
Test.AssertEquals(eina.ValueType.Int32, list.GetValueSubType()); Test.AssertEquals(Eina.ValueType.Int32, list.GetValueSubType());
using(eina.Value list = new eina.Value(eina.ValueType.List, eina.ValueType.UInt32)) using(Eina.Value list = new Eina.Value(Eina.ValueType.List, Eina.ValueType.UInt32))
Test.AssertEquals(eina.ValueType.UInt32, list.GetValueSubType()); Test.AssertEquals(Eina.ValueType.UInt32, list.GetValueSubType());
} }
public static void TestValueListConvert() { public static void TestValueListConvert() {
using(eina.Value list = new eina.Value(eina.ValueType.List, eina.ValueType.Int32)) using(Eina.Value list = new Eina.Value(Eina.ValueType.List, Eina.ValueType.Int32))
using(eina.Value other = new eina.Value(eina.ValueType.Int32)) { using(Eina.Value other = new Eina.Value(Eina.ValueType.Int32)) {
other.Set(100); other.Set(100);
other.ConvertTo(list); other.ConvertTo(list);
Test.AssertEquals(100, (int)list[0]); Test.AssertEquals(100, (int)list[0]);
@ -813,20 +813,20 @@ public static class TestEinaValue {
public static void TestStringThroughValue() { public static void TestStringThroughValue() {
// Check if Value_Native->Value doesn't try to free the pointed string. // Check if Value_Native->Value doesn't try to free the pointed string.
using(eina.Value value_ptr = new eina.Value(eina.ValueType.String)) { using(Eina.Value value_ptr = new Eina.Value(Eina.ValueType.String)) {
string payload = "Something"; string payload = "Something";
value_ptr.Set(payload); value_ptr.Set(payload);
eina.Value_Native byvalue = value_ptr; Eina.ValueNative byvalue = value_ptr;
eina.Value another_value_ptr = byvalue; Eina.Value another_value_ptr = byvalue;
Test.AssertEquals(value_ptr, another_value_ptr); Test.AssertEquals(value_ptr, another_value_ptr);
} }
} }
public static void TestValueEmpty() { public static void TestValueEmpty() {
using (eina.Value empty = new eina.Value(eina.ValueType.Empty)) { using (Eina.Value empty = new Eina.Value(Eina.ValueType.Empty)) {
Test.Assert(empty.Empty, "Value must be empty"); Test.Assert(empty.Empty, "Value must be empty");
empty.Setup(eina.ValueType.Int32); empty.Setup(Eina.ValueType.Int32);
// Values already set-up are not empty. For this kind of empty, use Optional // Values already set-up are not empty. For this kind of empty, use Optional
Test.Assert(!empty.Empty, "Values already set-up must not be empty."); Test.Assert(!empty.Empty, "Values already set-up must not be empty.");
@ -837,13 +837,13 @@ public static class TestEinaValue {
} }
public static void TestValueCopy() { public static void TestValueCopy() {
eina.Value v2 = null; Eina.Value v2 = null;
int raw_val = 42; int raw_val = 42;
using (eina.Value v = new eina.Value(eina.ValueType.Int32)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.Int32)) {
Test.Assert(v.Set(raw_val)); Test.Assert(v.Set(raw_val));
v2 = new eina.Value(v); v2 = new Eina.Value(v);
} }
int rec_val; int rec_val;

View File

@ -11,15 +11,15 @@ namespace TestSuite {
public static class TestEinaValueEolian { public static class TestEinaValueEolian {
public static void TestEolianEinaValueInReturn() public static void TestEolianEinaValueInReturn()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
using (eina.Value v = new eina.Value(eina.ValueType.Int32)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.Int32)) {
v.Set(42); v.Set(42);
obj.SetValuePtr(v); obj.SetValuePtr(v);
Test.AssertEquals(eina.Ownership.Managed, v.Ownership); Test.AssertEquals(Eina.Ownership.Managed, v.Ownership);
eina.Value v_received = obj.GetValuePtrOwn(); Eina.Value v_received = obj.GetValuePtrOwn();
Test.AssertEquals(eina.Ownership.Managed, v_received.Ownership); Test.AssertEquals(Eina.Ownership.Managed, v_received.Ownership);
Test.AssertEquals(v, v_received); Test.AssertEquals(v, v_received);
v_received.Dispose(); v_received.Dispose();
} }
@ -27,17 +27,17 @@ public static class TestEinaValueEolian {
public static void TestEolianEinaValueInOwn() public static void TestEolianEinaValueInOwn()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
using (eina.Value v = new eina.Value(eina.ValueType.Int32)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.Int32)) {
v.Set(2001); v.Set(2001);
Test.AssertEquals(eina.Ownership.Managed, v.Ownership); Test.AssertEquals(Eina.Ownership.Managed, v.Ownership);
obj.SetValuePtrOwn(v); obj.SetValuePtrOwn(v);
Test.AssertEquals(eina.Ownership.Unmanaged, v.Ownership); Test.AssertEquals(Eina.Ownership.Unmanaged, v.Ownership);
eina.Value v_received = obj.GetValuePtr(); Eina.Value v_received = obj.GetValuePtr();
Test.AssertEquals(eina.Ownership.Unmanaged, v_received.Ownership); Test.AssertEquals(Eina.Ownership.Unmanaged, v_received.Ownership);
Test.AssertEquals(v, v_received); Test.AssertEquals(v, v_received);
@ -47,62 +47,62 @@ public static class TestEinaValueEolian {
public static void TestEolianEinaValueOut() public static void TestEolianEinaValueOut()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
using (eina.Value v = new eina.Value(eina.ValueType.String)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.String)) {
eina.Value v_out = null; Eina.Value v_out = null;
v.Set("hello!"); v.Set("hello!");
obj.SetValuePtr(v); obj.SetValuePtr(v);
obj.OutValuePtr(out v_out); obj.OutValuePtr(out v_out);
Test.AssertEquals(v, v_out); Test.AssertEquals(v, v_out);
Test.AssertEquals(eina.Ownership.Unmanaged, v_out.Ownership); Test.AssertEquals(Eina.Ownership.Unmanaged, v_out.Ownership);
} }
} }
public static void TestEolianEinaValueOutOwn() public static void TestEolianEinaValueOutOwn()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
using (eina.Value v = new eina.Value(eina.ValueType.String)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.String)) {
eina.Value v_out = null; Eina.Value v_out = null;
v.Set("hello!"); v.Set("hello!");
obj.SetValuePtr(v); obj.SetValuePtr(v);
obj.OutValuePtrOwn(out v_out); obj.OutValuePtrOwn(out v_out);
Test.AssertEquals(v, v_out); Test.AssertEquals(v, v_out);
Test.AssertEquals(eina.Ownership.Managed, v_out.Ownership); Test.AssertEquals(Eina.Ownership.Managed, v_out.Ownership);
} }
} }
public static void TestEolianEinaValueOutByValue() public static void TestEolianEinaValueOutByValue()
{ {
test.ITesting obj = new test.Testing(); var obj = new Dummy.TestObject();
using (eina.Value v = new eina.Value(eina.ValueType.String)) { using (Eina.Value v = new Eina.Value(Eina.ValueType.String)) {
eina.Value v_out = null; Eina.Value v_out = null;
v.Set("hello!"); v.Set("hello!");
obj.SetValue(v); obj.SetValue(v);
obj.OutValue(out v_out); obj.OutValue(out v_out);
Test.AssertEquals(v, v_out); Test.AssertEquals(v, v_out);
Test.AssertEquals(eina.Ownership.Managed, v_out.Ownership); Test.AssertEquals(Eina.Ownership.Managed, v_out.Ownership);
} }
} }
private class ValueHandler : test.TestingInherit private class ValueHandler : Dummy.TestObject
{ {
public eina.Value value; public Eina.Value value;
public ValueHandler() : base(null) public ValueHandler() : base(null)
{ {
value = null; value = null;
} }
public override void SetValue(eina.Value value) public override void SetValue(Eina.Value value)
{ {
this.value = value; this.value = value;
} }
@ -111,7 +111,7 @@ public static class TestEinaValueEolian {
public static void TestEolianEinaValueByValueConst() public static void TestEolianEinaValueByValueConst()
{ {
ValueHandler obj = new ValueHandler(); ValueHandler obj = new ValueHandler();
using (eina.Value val = new eina.Value(eina.ValueType.String)) { using (Eina.Value val = new Eina.Value(Eina.ValueType.String)) {
obj.CallSetValue(val); obj.CallSetValue(val);
Test.AssertEquals(val, obj.value); Test.AssertEquals(val, obj.value);
} }

View File

@ -0,0 +1,10 @@
interface Dummy.Another_Iface ()
{
methods {
emit_another_conflicted {
}
}
events {
conflicted: void;
}
}

View File

@ -1,6 +1,6 @@
import eina_types; import eina_types;
class Test.Child extends Test.Testing { class Dummy.Child extends Dummy.Test_Object {
implements { implements {
class.constructor; class.constructor;

View File

@ -1,4 +1,4 @@
class Test.Numberwrapper extends Efl.Object { class Dummy.Numberwrapper extends Efl.Object {
methods { methods {
@property number { @property number {
get { get {

View File

@ -0,0 +1,13 @@
interface Dummy.Test_Iface ()
{
methods {
emit_test_conflicted {
}
emit_nonconflicted {
}
}
events {
conflicted: void;
nonconflicted: void;
}
}

View File

@ -1,8 +1,8 @@
import eina_types; import eina_types;
type Test.MyInt: int; type Dummy.MyInt: int;
enum Test.SampleEnum { enum Dummy.SampleEnum {
v0, v0,
v1, v1,
v2, v2,
@ -10,7 +10,7 @@ enum Test.SampleEnum {
v4, v4,
} }
struct Test.StructSimple struct Dummy.StructSimple
{ {
fbyte: byte; fbyte: byte;
fubyte: ubyte; fubyte: ubyte;
@ -40,7 +40,7 @@ struct Test.StructSimple
fdouble: double; fdouble: double;
fbool: bool; fbool: bool;
fvoid_ptr: void_ptr; fvoid_ptr: void_ptr;
fenum: Test.SampleEnum; fenum: Dummy.SampleEnum;
// fboolptr: ptr(bool); // TODO // fboolptr: ptr(bool); // TODO
// fbyteptr: ptr(byte); // fbyteptr: ptr(byte);
// fubyteptr: ptr(ubyte); // fubyteptr: ptr(ubyte);
@ -55,14 +55,14 @@ struct Test.StructSimple
// ffloatptr: ptr(float); // ffloatptr: ptr(float);
// fdoubleptr: ptr(double); // fdoubleptr: ptr(double);
// fvoid_ptrptr: ptr(void_ptr); // fvoid_ptrptr: ptr(void_ptr);
// fenumptr: ptr(Test.SampleEnum); // fenumptr: ptr(Dummy.SampleEnum);
fstring: string; fstring: string;
fmstring: mstring; fmstring: mstring;
fstringshare: stringshare; fstringshare: stringshare;
fmyint: Test.MyInt; fmyint: Dummy.MyInt;
} }
struct Test.StructComplex { struct Dummy.StructComplex {
farray: array<ptr(int)>; farray: array<ptr(int)>;
finarray: inarray<int>; finarray: inarray<int>;
flist: list<string>; flist: list<string>;
@ -74,32 +74,32 @@ struct Test.StructComplex {
fbinbuf: ptr(Eina.Binbuf); fbinbuf: ptr(Eina.Binbuf);
fslice: Eina.Slice; fslice: Eina.Slice;
// fslice: ptr(Eina.Slice); // TODO // fslice: ptr(Eina.Slice); // TODO
fobj: Test.Numberwrapper; fobj: Dummy.Numberwrapper;
} }
function Test.SimpleCb { function Dummy.SimpleCb {
params { params {
a: int; a: int;
} }
return: int; return: int;
}; };
function Test.FormatCb { function Dummy.FormatCb {
params { params {
@in str: strbuf; @in str: strbuf;
@in value: const(any_value); @in value: const(any_value);
} }
}; };
class Test.Testing extends Efl.Object implements Efl.Part { class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface, Dummy.Another_Iface {
parts { parts {
part1: Test.Testing; [[ Part number one. ]] part_one: Dummy.Test_Object; [[ Part number one. ]]
part2: Test.Testing; [[ Part number two. ]] part_two: Dummy.Test_Object; [[ Part number two. ]]
} }
methods { methods {
return_object { return_object {
return: Test.Testing; return: Dummy.Test_Object;
} }
int_out { int_out {
@ -451,14 +451,14 @@ class Test.Testing extends Efl.Object implements Efl.Part {
/* Object */ /* Object */
eina_array_obj_in { eina_array_obj_in {
params { params {
@in arr: array<Test.Numberwrapper>; @in arr: array<Dummy.Numberwrapper>;
} }
return: bool; return: bool;
} }
eina_array_obj_in_own { eina_array_obj_in_own {
params { params {
@in arr: array<Test.Numberwrapper @owned> @owned; @in arr: array<Dummy.Numberwrapper @owned> @owned;
} }
return: bool; return: bool;
} }
@ -468,7 +468,7 @@ class Test.Testing extends Efl.Object implements Efl.Part {
eina_array_obj_out { eina_array_obj_out {
params { params {
@out arr: array<Test.Numberwrapper>; @out arr: array<Dummy.Numberwrapper>;
} }
return: bool; return: bool;
} }
@ -478,27 +478,27 @@ class Test.Testing extends Efl.Object implements Efl.Part {
eina_array_obj_out_own { eina_array_obj_out_own {
params { params {
@out arr: array<Test.Numberwrapper @owned> @owned; @out arr: array<Dummy.Numberwrapper @owned> @owned;
} }
return: bool; return: bool;
} }
eina_array_obj_return { eina_array_obj_return {
return: array<Test.Numberwrapper>; return: array<Dummy.Numberwrapper>;
} }
check_eina_array_obj_return { check_eina_array_obj_return {
return: bool; return: bool;
} }
eina_array_obj_return_own { eina_array_obj_return_own {
return: array<Test.Numberwrapper @owned> @owned; return: array<Dummy.Numberwrapper @owned> @owned;
} }
eina_array_obj_return_in { eina_array_obj_return_in {
params { params {
@in arr: array<Test.Numberwrapper>; @in arr: array<Dummy.Numberwrapper>;
} }
return: array<Test.Numberwrapper>; return: array<Dummy.Numberwrapper>;
} }
/* Eina Inarray */ /* Eina Inarray */
@ -598,14 +598,14 @@ class Test.Testing extends Efl.Object implements Efl.Part {
/* Object */ /* Object */
eina_inarray_obj_in { eina_inarray_obj_in {
params { params {
@in arr: inarray<Test.Numberwrapper>; @in arr: inarray<Dummy.Numberwrapper>;
} }
return: bool; return: bool;
} }
eina_inarray_obj_in_own { eina_inarray_obj_in_own {
params { params {
@in arr: inarray<Test.Numberwrapper @owned> @owned; @in arr: inarray<Dummy.Numberwrapper @owned> @owned;
} }
return: bool; return: bool;
} }
@ -615,7 +615,7 @@ class Test.Testing extends Efl.Object implements Efl.Part {
eina_inarray_obj_out { eina_inarray_obj_out {
params { params {
@out arr: inarray<Test.Numberwrapper>; @out arr: inarray<Dummy.Numberwrapper>;
} }
return: bool; return: bool;
} }
@ -625,27 +625,27 @@ class Test.Testing extends Efl.Object implements Efl.Part {
eina_inarray_obj_out_own { eina_inarray_obj_out_own {
params { params {
@out arr: inarray<Test.Numberwrapper @owned> @owned; @out arr: inarray<Dummy.Numberwrapper @owned> @owned;
} }
return: bool; return: bool;
} }
eina_inarray_obj_return { eina_inarray_obj_return {
return: inarray<Test.Numberwrapper>; return: inarray<Dummy.Numberwrapper>;
} }
check_eina_inarray_obj_return { check_eina_inarray_obj_return {
return: bool; return: bool;
} }
eina_inarray_obj_return_own { eina_inarray_obj_return_own {
return: inarray<Test.Numberwrapper @owned> @owned; return: inarray<Dummy.Numberwrapper @owned> @owned;
} }
eina_inarray_obj_return_in { eina_inarray_obj_return_in {
params { params {
@in arr: inarray<Test.Numberwrapper>; @in arr: inarray<Dummy.Numberwrapper>;
} }
return: inarray<Test.Numberwrapper>; return: inarray<Dummy.Numberwrapper>;
} }
/* Eina List */ /* Eina List */
@ -745,14 +745,14 @@ class Test.Testing extends Efl.Object implements Efl.Part {
/* Object */ /* Object */
eina_list_obj_in { eina_list_obj_in {
params { params {
@in lst: list<Test.Numberwrapper>; @in lst: list<Dummy.Numberwrapper>;
} }
return: bool; return: bool;
} }
eina_list_obj_in_own { eina_list_obj_in_own {
params { params {
@in lst: list<Test.Numberwrapper @owned> @owned; @in lst: list<Dummy.Numberwrapper @owned> @owned;
} }
return: bool; return: bool;
} }
@ -762,7 +762,7 @@ class Test.Testing extends Efl.Object implements Efl.Part {
eina_list_obj_out { eina_list_obj_out {
params { params {
@out lst: list<Test.Numberwrapper>; @out lst: list<Dummy.Numberwrapper>;
} }
return: bool; return: bool;
} }
@ -772,27 +772,27 @@ class Test.Testing extends Efl.Object implements Efl.Part {
eina_list_obj_out_own { eina_list_obj_out_own {
params { params {
@out lst: list<Test.Numberwrapper @owned> @owned; @out lst: list<Dummy.Numberwrapper @owned> @owned;
} }
return: bool; return: bool;
} }
eina_list_obj_return { eina_list_obj_return {
return: list<Test.Numberwrapper>; return: list<Dummy.Numberwrapper>;
} }
check_eina_list_obj_return { check_eina_list_obj_return {
return: bool; return: bool;
} }
eina_list_obj_return_own { eina_list_obj_return_own {
return: list<Test.Numberwrapper @owned> @owned; return: list<Dummy.Numberwrapper @owned> @owned;
} }
eina_list_obj_return_in { eina_list_obj_return_in {
params { params {
@in lst: list<Test.Numberwrapper>; @in lst: list<Dummy.Numberwrapper>;
} }
return: list<Test.Numberwrapper>; return: list<Dummy.Numberwrapper>;
} }
/* Eina Inlist */ /* Eina Inlist */
@ -892,14 +892,14 @@ class Test.Testing extends Efl.Object implements Efl.Part {
/* Object */ /* Object */
eina_inlist_obj_in { eina_inlist_obj_in {
params { params {
@in lst: inlist<Test.Numberwrapper>; @in lst: inlist<Dummy.Numberwrapper>;
} }
return: bool; return: bool;
} }
eina_inlist_obj_in_own { eina_inlist_obj_in_own {
params { params {
@in lst: inlist<Test.Numberwrapper @owned> @owned; @in lst: inlist<Dummy.Numberwrapper @owned> @owned;
} }
return: bool; return: bool;
} }
@ -909,7 +909,7 @@ class Test.Testing extends Efl.Object implements Efl.Part {
eina_inlist_obj_out { eina_inlist_obj_out {
params { params {
@out lst: inlist<Test.Numberwrapper>; @out lst: inlist<Dummy.Numberwrapper>;
} }
return: bool; return: bool;
} }
@ -919,27 +919,27 @@ class Test.Testing extends Efl.Object implements Efl.Part {
eina_inlist_obj_out_own { eina_inlist_obj_out_own {
params { params {
@out lst: inlist<Test.Numberwrapper @owned> @owned; @out lst: inlist<Dummy.Numberwrapper @owned> @owned;
} }
return: bool; return: bool;
} }
eina_inlist_obj_return { eina_inlist_obj_return {
return: inlist<Test.Numberwrapper>; return: inlist<Dummy.Numberwrapper>;
} }
check_eina_inlist_obj_return { check_eina_inlist_obj_return {
return: bool; return: bool;
} }
eina_inlist_obj_return_own { eina_inlist_obj_return_own {
return: inlist<Test.Numberwrapper @owned> @owned; return: inlist<Dummy.Numberwrapper @owned> @owned;
} }
eina_inlist_obj_return_in { eina_inlist_obj_return_in {
params { params {
@in lst: inlist<Test.Numberwrapper>; @in lst: inlist<Dummy.Numberwrapper>;
} }
return: inlist<Test.Numberwrapper>; return: inlist<Dummy.Numberwrapper>;
} }
@ -1052,58 +1052,58 @@ class Test.Testing extends Efl.Object implements Efl.Part {
// Object // // Object //
eina_hash_obj_in { eina_hash_obj_in {
params { params {
@in hsh: hash<Test.Numberwrapper, Test.Numberwrapper>; @in hsh: hash<Dummy.Numberwrapper, Dummy.Numberwrapper>;
@in nwk1: Test.Numberwrapper; @in nwk1: Dummy.Numberwrapper;
@in nwv1: Test.Numberwrapper; @in nwv1: Dummy.Numberwrapper;
@out nwk2: Test.Numberwrapper; @out nwk2: Dummy.Numberwrapper;
@out nwv2: Test.Numberwrapper; @out nwv2: Dummy.Numberwrapper;
} }
return: bool; return: bool;
} }
eina_hash_obj_in_own { eina_hash_obj_in_own {
params { params {
@in hsh: hash<Test.Numberwrapper, Test.Numberwrapper @owned> @owned; @in hsh: hash<Dummy.Numberwrapper, Dummy.Numberwrapper @owned> @owned;
@in nwk1: Test.Numberwrapper; @in nwk1: Dummy.Numberwrapper;
@in nwv1: Test.Numberwrapper; @in nwv1: Dummy.Numberwrapper;
@out nwk2: Test.Numberwrapper; @out nwk2: Dummy.Numberwrapper;
@out nwv2: Test.Numberwrapper; @out nwv2: Dummy.Numberwrapper;
} }
return: bool; return: bool;
} }
check_eina_hash_obj_in_own { check_eina_hash_obj_in_own {
params { params {
@in nwk1: Test.Numberwrapper; @in nwk1: Dummy.Numberwrapper;
@in nwv1: Test.Numberwrapper; @in nwv1: Dummy.Numberwrapper;
@in nwk2: Test.Numberwrapper; @in nwk2: Dummy.Numberwrapper;
@in nwv2: Test.Numberwrapper; @in nwv2: Dummy.Numberwrapper;
} }
return: bool; return: bool;
} }
eina_hash_obj_out { eina_hash_obj_out {
params { params {
@out hsh: hash<Test.Numberwrapper, Test.Numberwrapper>; @out hsh: hash<Dummy.Numberwrapper, Dummy.Numberwrapper>;
@out nwk: Test.Numberwrapper; @out nwk: Dummy.Numberwrapper;
@out nwv: Test.Numberwrapper; @out nwv: Dummy.Numberwrapper;
} }
return: bool; return: bool;
} }
check_eina_hash_obj_out { check_eina_hash_obj_out {
params { params {
@in nwk1: Test.Numberwrapper; @in nwk1: Dummy.Numberwrapper;
@in nwv1: Test.Numberwrapper; @in nwv1: Dummy.Numberwrapper;
@in nwk2: Test.Numberwrapper; @in nwk2: Dummy.Numberwrapper;
@in nwv2: Test.Numberwrapper; @in nwv2: Dummy.Numberwrapper;
} }
return: bool; return: bool;
} }
eina_hash_obj_out_own { eina_hash_obj_out_own {
params { params {
@out hsh: hash<Test.Numberwrapper, Test.Numberwrapper @owned> @owned; @out hsh: hash<Dummy.Numberwrapper, Dummy.Numberwrapper @owned> @owned;
@out nwk: Test.Numberwrapper; @out nwk: Dummy.Numberwrapper;
@out nwv: Test.Numberwrapper; @out nwv: Dummy.Numberwrapper;
} }
return: bool; return: bool;
} }
@ -1113,27 +1113,27 @@ class Test.Testing extends Efl.Object implements Efl.Part {
eina_hash_obj_return { eina_hash_obj_return {
params { params {
@out nwk: Test.Numberwrapper; @out nwk: Dummy.Numberwrapper;
@out nwv: Test.Numberwrapper; @out nwv: Dummy.Numberwrapper;
} }
return: hash<Test.Numberwrapper, Test.Numberwrapper>; return: hash<Dummy.Numberwrapper, Dummy.Numberwrapper>;
} }
check_eina_hash_obj_return { check_eina_hash_obj_return {
params { params {
@in nwk1: Test.Numberwrapper; @in nwk1: Dummy.Numberwrapper;
@in nwv1: Test.Numberwrapper; @in nwv1: Dummy.Numberwrapper;
@in nwk2: Test.Numberwrapper; @in nwk2: Dummy.Numberwrapper;
@in nwv2: Test.Numberwrapper; @in nwv2: Dummy.Numberwrapper;
} }
return: bool; return: bool;
} }
eina_hash_obj_return_own { eina_hash_obj_return_own {
params { params {
@out nwk: Test.Numberwrapper; @out nwk: Dummy.Numberwrapper;
@out nwv: Test.Numberwrapper; @out nwv: Dummy.Numberwrapper;
} }
return: hash<Test.Numberwrapper, Test.Numberwrapper @owned> @owned; return: hash<Dummy.Numberwrapper, Dummy.Numberwrapper @owned> @owned;
} }
check_eina_hash_obj_return_own { check_eina_hash_obj_return_own {
return: bool; return: bool;
@ -1236,14 +1236,14 @@ class Test.Testing extends Efl.Object implements Efl.Part {
/* Object */ /* Object */
eina_iterator_obj_in { eina_iterator_obj_in {
params { params {
@in itr: iterator<Test.Numberwrapper>; @in itr: iterator<Dummy.Numberwrapper>;
} }
return: bool; return: bool;
} }
eina_iterator_obj_in_own { eina_iterator_obj_in_own {
params { params {
@in itr: iterator<Test.Numberwrapper @owned> @owned; @in itr: iterator<Dummy.Numberwrapper @owned> @owned;
} }
return: bool; return: bool;
} }
@ -1253,7 +1253,7 @@ class Test.Testing extends Efl.Object implements Efl.Part {
eina_iterator_obj_out { eina_iterator_obj_out {
params { params {
@out itr: iterator<Test.Numberwrapper>; @out itr: iterator<Dummy.Numberwrapper>;
} }
return: bool; return: bool;
} }
@ -1263,27 +1263,27 @@ class Test.Testing extends Efl.Object implements Efl.Part {
eina_iterator_obj_out_own { eina_iterator_obj_out_own {
params { params {
@out itr: iterator<Test.Numberwrapper @owned> @owned; @out itr: iterator<Dummy.Numberwrapper @owned> @owned;
} }
return: bool; return: bool;
} }
eina_iterator_obj_return { eina_iterator_obj_return {
return: iterator<Test.Numberwrapper>; return: iterator<Dummy.Numberwrapper>;
} }
check_eina_iterator_obj_return { check_eina_iterator_obj_return {
return: bool; return: bool;
} }
eina_iterator_obj_return_own { eina_iterator_obj_return_own {
return: iterator<Test.Numberwrapper @owned> @owned; return: iterator<Dummy.Numberwrapper @owned> @owned;
} }
/* Function Pointer */ /* Function Pointer */
set_callback { set_callback {
params { params {
cb: Test.SimpleCb; cb: Dummy.SimpleCb;
} }
} }
@ -1385,158 +1385,158 @@ class Test.Testing extends Efl.Object implements Efl.Part {
struct_simple_in { struct_simple_in {
params { params {
@in simple: Test.StructSimple; @in simple: Dummy.StructSimple;
} }
return: bool; return: bool;
} }
struct_simple_ptr_in { struct_simple_ptr_in {
params { params {
@in simple: ptr(Test.StructSimple); @in simple: ptr(Dummy.StructSimple);
} }
return: bool; return: bool;
} }
struct_simple_ptr_in_own { struct_simple_ptr_in_own {
params { params {
@in simple: ptr(Test.StructSimple) @owned; @in simple: ptr(Dummy.StructSimple) @owned;
} }
return: Test.StructSimple; return: Dummy.StructSimple;
} }
struct_simple_out { struct_simple_out {
params { params {
@out simple: Test.StructSimple; @out simple: Dummy.StructSimple;
} }
return: bool; return: bool;
} }
struct_simple_ptr_out { struct_simple_ptr_out {
params { params {
@out simple: ptr(Test.StructSimple); @out simple: ptr(Dummy.StructSimple);
} }
return: Test.StructSimple; return: Dummy.StructSimple;
} }
struct_simple_ptr_out_own { struct_simple_ptr_out_own {
params { params {
@out simple: ptr(Test.StructSimple) @owned; @out simple: ptr(Dummy.StructSimple) @owned;
} }
return: Test.StructSimple; return: Dummy.StructSimple;
} }
struct_simple_return { struct_simple_return {
return: Test.StructSimple; return: Dummy.StructSimple;
} }
struct_simple_ptr_return { struct_simple_ptr_return {
return: ptr(Test.StructSimple); return: ptr(Dummy.StructSimple);
} }
struct_simple_ptr_return_own { struct_simple_ptr_return_own {
return: ptr(Test.StructSimple) @owned; return: ptr(Dummy.StructSimple) @owned;
} }
call_struct_simple_in { call_struct_simple_in {
params { params {
@in simple: Test.StructSimple; @in simple: Dummy.StructSimple;
} }
} }
call_struct_simple_ptr_in { call_struct_simple_ptr_in {
params { params {
@in simple: ptr(Test.StructSimple); @in simple: ptr(Dummy.StructSimple);
} }
} }
call_struct_simple_ptr_in_own { call_struct_simple_ptr_in_own {
params { params {
@in simple: ptr(Test.StructSimple) @owned; @in simple: ptr(Dummy.StructSimple) @owned;
} }
} }
call_struct_simple_out { call_struct_simple_out {
params { params {
@out simple: Test.StructSimple; @out simple: Dummy.StructSimple;
} }
} }
call_struct_simple_ptr_out { call_struct_simple_ptr_out {
params { params {
@out simple: ptr(Test.StructSimple); @out simple: ptr(Dummy.StructSimple);
} }
} }
call_struct_simple_ptr_out_own { call_struct_simple_ptr_out_own {
params { params {
@out simple: ptr(Test.StructSimple) @owned; @out simple: ptr(Dummy.StructSimple) @owned;
} }
} }
call_struct_simple_return { call_struct_simple_return {
return: Test.StructSimple; return: Dummy.StructSimple;
} }
call_struct_simple_ptr_return { call_struct_simple_ptr_return {
return: ptr(Test.StructSimple); return: ptr(Dummy.StructSimple);
} }
call_struct_simple_ptr_return_own { call_struct_simple_ptr_return_own {
return: ptr(Test.StructSimple) @owned; return: ptr(Dummy.StructSimple) @owned;
} }
struct_complex_in { struct_complex_in {
params { params {
@in complex: Test.StructComplex; @in complex: Dummy.StructComplex;
} }
return: bool; return: bool;
} }
struct_complex_ptr_in { struct_complex_ptr_in {
params { params {
@in complex: ptr(Test.StructComplex); @in complex: ptr(Dummy.StructComplex);
} }
return: bool; return: bool;
} }
struct_complex_ptr_in_own { struct_complex_ptr_in_own {
params { params {
@in complex: ptr(Test.StructComplex) @owned; @in complex: ptr(Dummy.StructComplex) @owned;
} }
return: bool; return: bool;
} }
struct_complex_out { struct_complex_out {
params { params {
@out complex: Test.StructComplex; @out complex: Dummy.StructComplex;
} }
return: bool; return: bool;
} }
// struct_complex_ptr_out { // struct_complex_ptr_out {
// params { // params {
// @out complex: ptr(Test.StructComplex); // @out complex: ptr(Dummy.StructComplex);
// } // }
// return: bool; // return: bool;
// } // }
// //
// struct_complex_ptr_out_own { // struct_complex_ptr_out_own {
// params { // params {
// @out complex: ptr(Test.StructComplex) @owned; // @out complex: ptr(Dummy.StructComplex) @owned;
// } // }
// return: bool; // return: bool;
// } // }
struct_complex_return { struct_complex_return {
return: Test.StructComplex; return: Dummy.StructComplex;
} }
// struct_complex_ptr_return { // struct_complex_ptr_return {
// return: ptr(Test.StructComplex); // return: ptr(Dummy.StructComplex);
// } // }
// //
// struct_complex_ptr_return_own { // struct_complex_ptr_return_own {
// return: ptr(Test.StructComplex) @owned; // return: ptr(Dummy.StructComplex) @owned;
// } // }
emit_event_with_string { emit_event_with_string {
@ -1561,7 +1561,7 @@ class Test.Testing extends Efl.Object implements Efl.Part {
} }
emit_event_with_obj { emit_event_with_obj {
params { params {
@in data: Test.Testing; @in data: Dummy.Test_Object;
} }
} }
@ -1573,7 +1573,7 @@ class Test.Testing extends Efl.Object implements Efl.Part {
emit_event_with_struct { emit_event_with_struct {
params { params {
@in data: Test.StructSimple; @in data: Dummy.StructSimple;
} }
} }
@ -1595,17 +1595,17 @@ class Test.Testing extends Efl.Object implements Efl.Part {
params { params {
@in str: strbuf; @in str: strbuf;
@in value: const(any_value); @in value: const(any_value);
@in func: Test.FormatCb; @in func: Dummy.FormatCb;
} }
} }
bypass_typedef { bypass_typedef {
params { params {
@in data: Test.MyInt; @in data: Dummy.MyInt;
@out receiver: Test.MyInt; @out receiver: Dummy.MyInt;
} }
return: Test.MyInt; return: Dummy.MyInt;
} }
@property klass_prop @class { @property klass_prop @class {
@ -1647,14 +1647,17 @@ class Test.Testing extends Efl.Object implements Efl.Part {
class.destructor; class.destructor;
Efl.Object.constructor; Efl.Object.constructor;
Efl.Part.part_get; Efl.Part.part_get;
Dummy.Test_Iface.emit_test_conflicted;
Dummy.Test_Iface.emit_nonconflicted;
Dummy.Another_Iface.emit_another_conflicted;
} }
events { events {
evt,with,string @hot: string; evt,with,string @hot: string;
evt,with,bool: bool; evt,with,bool: bool;
evt,with,int @hot: int; evt,with,int @hot: int;
evt,with,uint @hot: uint; evt,with,uint @hot: uint;
evt,with,obj @hot: Test.Testing; evt,with,obj @hot: Dummy.Test_Object;
evt,with,error @hot: Eina.Error; evt,with,error @hot: Eina.Error;
evt,with,struct @hot: Test.StructSimple; evt,with,struct @hot: Dummy.StructSimple;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
eo_files = ['test_child.eo', 'test_numberwrapper.eo', 'test_testing.eo'] eo_files = ['dummy_child.eo', 'dummy_numberwrapper.eo', 'dummy_test_object.eo', 'dummy_test_iface.eo', 'dummy_another_iface.eo']
eo_file_targets = [] eo_file_targets = []