forked from enlightenment/efl
eolian-mono: Make Get/Set internal for generated properties
Make Get and Set methods internal for properties that get the property syntax generated. Reviewed-by: João Paulo Taylor Ienczak Zanette <joao.tiz@expertisesolutions.com.br> Differential Revision: https://phab.enlightenment.org/D11252
This commit is contained in:
parent
d00dadb79a
commit
595cb754b3
|
@ -36,6 +36,7 @@
|
|||
#include "using_decl.hh"
|
||||
#include "generation_contexts.hh"
|
||||
#include "blacklist.hh"
|
||||
#include "documentation.hh"
|
||||
|
||||
namespace eolian_mono {
|
||||
|
||||
|
@ -71,8 +72,10 @@ struct async_function_declaration_generator
|
|||
if(f.scope != attributes::member_scope::scope_public)
|
||||
return true;
|
||||
|
||||
auto ref = documentation_generator::function_conversion (f, context);
|
||||
|
||||
if (!as_generator(
|
||||
scope_tab(2) << "/// <summary>Async wrapper for <see cref=\"" << name_helpers::managed_method_name(f) << "\" />.\n"
|
||||
scope_tab(2) << "/// <summary>Async wrapper for <see cref=\"" << ref << "\" />.\n"
|
||||
).generate(sink, attributes::unused, context))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "name_helpers.hh"
|
||||
#include "generation_contexts.hh"
|
||||
#include "blacklist.hh"
|
||||
#include "property_definition.hh"
|
||||
|
||||
#include <Eina.h>
|
||||
|
||||
|
@ -76,7 +77,8 @@ struct documentation_generator
|
|||
// The name_tail parameter is the last 4 chars of the original string, which
|
||||
// could be ".set" or ".get" and in this case they are ignored by Eolian.
|
||||
// We want them to know what the documentation intended to reference.
|
||||
static std::string function_conversion(const ::Eolian_Object *klass, const ::Eolian_Function *function, std::string name_tail)
|
||||
template <typename Context>
|
||||
static std::string function_conversion(const ::Eolian_Object *klass, const ::Eolian_Function *function, std::string name_tail, Context const& context)
|
||||
{
|
||||
::Eolian_Function_Type ftype = ::eolian_function_type_get(function);
|
||||
const char* eo_name = ::eolian_function_name_get(function);
|
||||
|
@ -113,26 +115,65 @@ struct documentation_generator
|
|||
name += name_helpers::managed_method_name({function, ftype, NULL, eolian_object_unit_get(EOLIAN_OBJECT(function))});
|
||||
break;
|
||||
case ::EOLIAN_PROP_SET:
|
||||
name += ".Set";
|
||||
name += name_helpers::property_managed_name(klass_d, eo_name);
|
||||
break;
|
||||
case ::EOLIAN_PROP_GET:
|
||||
name += ".Get";
|
||||
name += name_helpers::property_managed_name(klass_d, eo_name);
|
||||
break;
|
||||
case ::EOLIAN_PROPERTY:
|
||||
{
|
||||
efl::eina::optional<attributes::function_def> getter_func;
|
||||
efl::eina::optional<attributes::function_def> setter_func;
|
||||
auto unit = (const Eolian_Unit*) context_find_tag<eolian_state_context>(context).state;
|
||||
if (ftype == ::EOLIAN_PROPERTY || ftype == ::EOLIAN_PROP_GET)
|
||||
getter_func = attributes::function_def{function, ::EOLIAN_PROP_GET, nullptr, unit};
|
||||
if (ftype == ::EOLIAN_PROPERTY || ftype == ::EOLIAN_PROP_SET)
|
||||
setter_func = attributes::function_def{function, ::EOLIAN_PROP_SET, nullptr, unit};
|
||||
attributes::property_def property{function, getter_func, setter_func, unit};
|
||||
|
||||
std::string short_name = name_helpers::property_managed_name(klass_d, eo_name);
|
||||
class_context::wrapper_kind klass_kind;
|
||||
if (helpers::is_managed_interface(klass_d))
|
||||
klass_kind = class_context::interface;
|
||||
else
|
||||
klass_kind = class_context::inherit;
|
||||
auto my_context = grammar::context_replace_tag(class_context{klass_kind}, context);
|
||||
|
||||
if (name_tail == ".get")
|
||||
{
|
||||
int getter_nkeys = property_num_keys(function, ::EOLIAN_PROP_GET);
|
||||
int setter_nkeys = property_num_keys(function, ::EOLIAN_PROP_SET);
|
||||
std::string short_name = name_helpers::property_managed_name(klass_d, eo_name);
|
||||
bool blacklisted = blacklist::is_property_blacklisted(name + "." + short_name);
|
||||
// EO properties with keys or blacklisted are not converted into C# properties.
|
||||
// In these cases we refer to the getter method instead of the property.
|
||||
if ((getter_nkeys > 0) || (setter_nkeys > 0) || (blacklisted)) name += ".Get" + short_name;
|
||||
else if (name_tail == ".get") name += ".Get" + short_name;
|
||||
else if (name_tail == ".set") name += ".Set" + short_name;
|
||||
else name += "." + short_name;
|
||||
if (property_generate_wrapper_getter (property, my_context))
|
||||
{
|
||||
name += "." + short_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
name += ".Get" + short_name;
|
||||
}
|
||||
}
|
||||
else if (name_tail == ".set")
|
||||
{
|
||||
if (property_generate_wrapper_setter (property, my_context))
|
||||
{
|
||||
name += "." + short_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
name += ".Set" + short_name;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (ftype)
|
||||
{
|
||||
case ::EOLIAN_PROPERTY:
|
||||
case ::EOLIAN_PROP_GET:
|
||||
if (property_generate_wrapper_getter (property, my_context))
|
||||
name += "." + short_name;
|
||||
else
|
||||
name += ".Get" + short_name;
|
||||
break;
|
||||
default:
|
||||
name += ".Set" + short_name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -140,33 +181,89 @@ struct documentation_generator
|
|||
return name;
|
||||
}
|
||||
|
||||
static std::string function_conversion(attributes::function_def const& func)
|
||||
template <typename Context>
|
||||
static std::string function_conversion(attributes::function_def const& func, Context const& context)
|
||||
{
|
||||
// This function is called only from the constructor reference conversion, so it does not
|
||||
// need to check whether this function non-public in a interface returning an empty reference (yet).
|
||||
std::string name = name_helpers::klass_full_concrete_or_interface_name(func.klass);
|
||||
switch (func.type)
|
||||
{
|
||||
// managed_method_name takes care of reordering the function name so the get/set goes first
|
||||
// for properties
|
||||
case attributes::function_type::method:
|
||||
case attributes::function_type::prop_set:
|
||||
case attributes::function_type::prop_get:
|
||||
if (blacklist::is_function_blacklisted(func.c_name))return "";
|
||||
if (!name.empty()) name += ".";
|
||||
name += name_helpers::managed_method_name(func);
|
||||
break;
|
||||
default:
|
||||
// No need to deal with property as function_defs are converted to get/set when building a given klass_def.
|
||||
break;
|
||||
// managed_method_name takes care of reordering the function name so the get/set goes first
|
||||
// for properties
|
||||
case attributes::function_type::method:
|
||||
if (blacklist::is_function_blacklisted(func.c_name))return "";
|
||||
if (!name.empty()) name += ".";
|
||||
name += name_helpers::managed_method_name(func);
|
||||
break;
|
||||
case attributes::function_type::prop_set:
|
||||
case attributes::function_type::prop_get:
|
||||
case attributes::function_type::property:
|
||||
{
|
||||
auto unit = (const Eolian_Unit*) context_find_tag<eolian_state_context>(context).state;
|
||||
auto klass = get_klass(func.klass, unit);
|
||||
attributes::klass_def klass_d(klass, unit);
|
||||
|
||||
auto eo_name = func.name;
|
||||
auto prop_name = eo_name;
|
||||
if (prop_name.size () > 4
|
||||
&&
|
||||
( prop_name.substr(prop_name.size() - 4) == "_set"
|
||||
|| prop_name.substr(prop_name.size() - 4) == "_get"))
|
||||
{
|
||||
prop_name = prop_name.substr(0, prop_name.size() - 4);
|
||||
}
|
||||
std::string short_name = name_helpers::property_managed_name(klass_d, prop_name);
|
||||
assert (prop_name.size() <= 4 ||
|
||||
(prop_name.substr(prop_name.size() - 4) != "_set"
|
||||
&& prop_name.substr(prop_name.size() - 4) != "_get"));
|
||||
assert (short_name.size() <= 3 ||
|
||||
(short_name.substr(short_name.size() - 3) != "Set"
|
||||
&& short_name.substr(short_name.size() - 3) != "Get"));
|
||||
|
||||
// We need to replace the current class context with the context
|
||||
// from the class that originated this property.
|
||||
class_context::wrapper_kind klass_kind;
|
||||
if (helpers::is_managed_interface(klass_d))
|
||||
klass_kind = class_context::interface;
|
||||
else
|
||||
klass_kind = class_context::inherit;
|
||||
|
||||
auto my_context = grammar::context_replace_tag(class_context{klass_kind}, context);
|
||||
|
||||
auto function = eolian_class_function_by_name_get (klass, prop_name.c_str(), EOLIAN_PROPERTY);
|
||||
attributes::function_def getter_func{function, ::EOLIAN_PROP_GET, nullptr, unit};
|
||||
attributes::function_def setter_func{function, ::EOLIAN_PROP_SET, nullptr, unit};
|
||||
attributes::property_def prop{function, getter_func, setter_func, unit};
|
||||
|
||||
if (func.type == attributes::function_type::prop_get || func.type == attributes::function_type::property)
|
||||
{
|
||||
if (property_generate_wrapper_getter (prop, my_context))
|
||||
name += "." + short_name;
|
||||
else
|
||||
name += ".Get" + short_name;
|
||||
}
|
||||
else if (func.type == attributes::function_type::prop_set)
|
||||
{
|
||||
if (property_generate_wrapper_setter (prop, my_context))
|
||||
name += "." + short_name;
|
||||
else
|
||||
name += ".Set" + short_name;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// No need to deal with property as function_defs are converted to get/set when building a given klass_def.
|
||||
break;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
// Turns an Eolian reference like @Efl.Input.Pointer.tool into a <see> tag
|
||||
template <typename Context>
|
||||
static std::string ref_conversion(const ::Eolian_Doc_Token *token, const Eolian_State *state, std::string name_tail,
|
||||
bool want_beta)
|
||||
bool want_beta, Context const& context)
|
||||
{
|
||||
const Eolian_Object *data, *data2;
|
||||
::Eolian_Object_Type type =
|
||||
|
@ -195,7 +292,7 @@ struct documentation_generator
|
|||
is_beta = eolian_object_is_beta(data) || eolian_object_is_beta(data2);
|
||||
break;
|
||||
case ::EOLIAN_OBJECT_FUNCTION:
|
||||
ref += function_conversion(data, (const ::Eolian_Function *)data2, name_tail);
|
||||
ref += function_conversion(data, (const ::Eolian_Function *)data2, name_tail, context);
|
||||
is_beta = eolian_object_is_beta(data) || eolian_object_is_beta(data2);
|
||||
break;
|
||||
case ::EOLIAN_OBJECT_CONSTANT:
|
||||
|
@ -226,8 +323,9 @@ struct documentation_generator
|
|||
return ref;
|
||||
}
|
||||
|
||||
// Turns EO documentation syntax into C# triple-slash XML comment syntax
|
||||
static std::string syntax_conversion(std::string text, const Eolian_State *state, bool want_beta)
|
||||
// Turns EO documentation syntax into C# triple-slash XML comment syntax
|
||||
template <typename Context>
|
||||
static std::string syntax_conversion(std::string text, const Eolian_State *state, bool want_beta, Context const& context)
|
||||
{
|
||||
std::string new_text, ref;
|
||||
::Eolian_Doc_Token_Type previous_token_type = ::EOLIAN_DOC_TOKEN_UNKNOWN;
|
||||
|
@ -266,7 +364,7 @@ struct documentation_generator
|
|||
new_text += token_text;
|
||||
break;
|
||||
case ::EOLIAN_DOC_TOKEN_REF:
|
||||
ref = ref_conversion(&token, state, name_tail, want_beta);
|
||||
ref = ref_conversion(&token, state, name_tail, want_beta, context);
|
||||
if (ref != "")
|
||||
{
|
||||
if (utils::ends_with(ref, BETA_REF_SUFFIX))
|
||||
|
@ -333,7 +431,7 @@ struct documentation_generator
|
|||
if (!as_generator(html_escaped_string).generate(std::back_inserter(new_text), text, context))
|
||||
return false;
|
||||
auto options = context_find_tag<options_context>(context);
|
||||
new_text = syntax_conversion( new_text, context_find_tag<eolian_state_context>(context).state, options.want_beta);
|
||||
new_text = syntax_conversion( new_text, context_find_tag<eolian_state_context>(context).state, options.want_beta, context);
|
||||
|
||||
std::string tabs;
|
||||
as_generator(scope_tab(scope_size) << "/// ").generate (std::back_inserter(tabs), attributes::unused, context);
|
||||
|
@ -698,7 +796,7 @@ struct documentation_generator
|
|||
|
||||
for (auto &¶m : ctor.function.parameters)
|
||||
{
|
||||
auto ref = function_conversion(func);
|
||||
auto ref = function_conversion(func, context);
|
||||
|
||||
if (!context_find_tag<options_context>(context).want_beta && func.is_beta)
|
||||
{
|
||||
|
@ -741,7 +839,7 @@ struct documentation_string_generator
|
|||
|
||||
auto options = context_find_tag<options_context>(context);
|
||||
auto state = context_find_tag<eolian_state_context>(context).state;
|
||||
if (!as_generator(string).generate(sink, documentation_generator::syntax_conversion(escaped, state, options.want_beta), context))
|
||||
if (!as_generator(string).generate(sink, documentation_generator::syntax_conversion(escaped, state, options.want_beta, context), context))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "grammar/alternative.hpp"
|
||||
#include "grammar/attribute_reorder.hpp"
|
||||
#include "grammar/counter.hpp"
|
||||
#include "property_definition.hh"
|
||||
#include "logging.hh"
|
||||
#include "type.hh"
|
||||
#include "name_helpers.hh"
|
||||
|
@ -44,6 +45,7 @@ namespace eolian_mono {
|
|||
struct native_function_definition_generator
|
||||
{
|
||||
attributes::klass_def const* klass;
|
||||
std::vector<attributes::property_def> properties;
|
||||
|
||||
template <typename OutputIterator, typename Context>
|
||||
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
|
||||
|
@ -52,6 +54,24 @@ struct native_function_definition_generator
|
|||
if(blacklist::is_function_blacklisted(f, context))
|
||||
return true;
|
||||
|
||||
auto it = std::find_if (properties.begin(), properties.end()
|
||||
, [&] (attributes::property_def const& prop)
|
||||
{
|
||||
return (prop.getter && *prop.getter == f)
|
||||
|| (prop.setter && *prop.setter == f);
|
||||
});
|
||||
if (it != properties.end())
|
||||
{
|
||||
if (it->getter && *it->getter == f)
|
||||
{
|
||||
if (property_generate_wrapper_getter (*it, context))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (property_generate_wrapper_setter (*it, context))
|
||||
return true;
|
||||
}
|
||||
|
||||
auto const& indent = current_indentation(context);
|
||||
|
||||
// Delegate for the C# method we will export to EO as a method implementation.
|
||||
|
@ -184,10 +204,6 @@ struct native_function_definition_generator
|
|||
|
||||
struct function_definition_generator
|
||||
{
|
||||
function_definition_generator(bool do_super = false)
|
||||
: do_super(do_super)
|
||||
{}
|
||||
|
||||
template <typename OutputIterator, typename Context>
|
||||
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
|
||||
{
|
||||
|
@ -197,6 +213,25 @@ struct function_definition_generator
|
|||
if(blacklist::is_function_blacklisted(f, context))
|
||||
return true;
|
||||
|
||||
auto function_scope = eolian_mono::function_scope_get(f);
|
||||
auto it = std::find_if (properties.begin(), properties.end()
|
||||
, [&] (attributes::property_def const& prop)
|
||||
{
|
||||
return (prop.getter && *prop.getter == f)
|
||||
|| (prop.setter && *prop.setter == f);
|
||||
});
|
||||
if (it != properties.end())
|
||||
{
|
||||
if (it->getter && *it->getter == f)
|
||||
{
|
||||
if (property_generate_wrapper_getter (*it, context))
|
||||
function_scope = "internal ";
|
||||
}
|
||||
else
|
||||
if (property_generate_wrapper_setter (*it, context))
|
||||
function_scope = "internal ";
|
||||
}
|
||||
|
||||
// Do not generate static function for concrete class
|
||||
if (is_concrete && f.is_static)
|
||||
return true;
|
||||
|
@ -219,7 +254,7 @@ struct function_definition_generator
|
|||
self = "";
|
||||
|
||||
if(!as_generator
|
||||
(scope_tab(2) << eolian_mono::function_scope_get(f) << ((do_super && !f.is_static) ? "virtual " : "") << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ")
|
||||
(scope_tab(2) << function_scope << ((do_super && !f.is_static) ? "virtual " : "") << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ")
|
||||
<< ") {\n"
|
||||
<< scope_tab(3) << eolian_mono::function_definition_preamble()
|
||||
<< klass_full_native_inherit_name(f.klass) << "." << string << "_ptr.Value.Delegate("
|
||||
|
@ -235,24 +270,29 @@ struct function_definition_generator
|
|||
}
|
||||
|
||||
bool do_super;
|
||||
std::vector<attributes::property_def> properties;
|
||||
};
|
||||
|
||||
struct function_definition_parameterized
|
||||
{
|
||||
function_definition_generator operator()(bool do_super) const
|
||||
function_definition_generator operator()(bool do_super, std::vector<attributes::property_def> properties) const
|
||||
{
|
||||
return {do_super};
|
||||
return {do_super, properties};
|
||||
}
|
||||
function_definition_generator operator()(std::vector<attributes::property_def> properties) const
|
||||
{
|
||||
return {false, properties};
|
||||
}
|
||||
} const function_definition;
|
||||
function_definition_generator as_generator(function_definition_parameterized)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
// function_definition_generator as_generator(function_definition_parameterized)
|
||||
// {
|
||||
// return {};
|
||||
// }
|
||||
struct native_function_definition_parameterized
|
||||
{
|
||||
native_function_definition_generator operator()(attributes::klass_def const& klass) const
|
||||
native_function_definition_generator operator()(attributes::klass_def const& klass, std::vector<attributes::property_def> properties) const
|
||||
{
|
||||
return {&klass};
|
||||
return {&klass, properties};
|
||||
}
|
||||
} const native_function_definition;
|
||||
|
||||
|
@ -356,27 +396,19 @@ struct property_wrapper_definition_generator
|
|||
// if (get_params > 0 || set_params > 1)
|
||||
// return true;
|
||||
|
||||
if (property.getter
|
||||
&& std::find_if (property.getter->parameters.begin()
|
||||
, property.getter->parameters.end()
|
||||
, [] (parameter_def const& p)
|
||||
{
|
||||
return p.direction != parameter_direction::out;
|
||||
}) != property.getter->parameters.end())
|
||||
if (property.getter && !property.getter->keys.empty())
|
||||
return true;
|
||||
if (property.setter
|
||||
&& std::find_if (property.setter->parameters.begin()
|
||||
, property.setter->parameters.end()
|
||||
, [] (parameter_def const& p)
|
||||
{
|
||||
return p.direction != parameter_direction::in;
|
||||
}) != property.setter->parameters.end())
|
||||
if (property.setter && !property.setter->keys.empty())
|
||||
return true;
|
||||
|
||||
|
||||
if (property.getter && property.setter)
|
||||
{
|
||||
if (get_params != 0 && property.setter->parameters.size() != property.getter->parameters.size())
|
||||
return true;
|
||||
if (property.setter->values.size() != property.getter->values.size())
|
||||
{
|
||||
if (!std::equal(property.setter->values.begin(), property.setter->values.end()
|
||||
, property.getter->values.begin()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<attributes::parameter_def> parameters;
|
||||
|
@ -481,9 +513,11 @@ struct property_wrapper_definition_generator
|
|||
if (property.getter.is_engaged() && is_interface)
|
||||
{
|
||||
if (is_get_public)
|
||||
{
|
||||
if (!as_generator(scope_tab(2) << scope_tab << set_scope << "get;\n"
|
||||
).generate(sink, attributes::unused, context))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (property.getter.is_engaged() && get_params == 0/*parameters.size() == 1 && property.getter.is_engaged()*/)
|
||||
{
|
||||
|
@ -526,9 +560,11 @@ struct property_wrapper_definition_generator
|
|||
if (property.setter.is_engaged() && is_interface)
|
||||
{
|
||||
if (is_set_public)
|
||||
{
|
||||
if (!as_generator(scope_tab(2) << scope_tab << set_scope << "set;\n"
|
||||
).generate(sink, attributes::unused, context))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (parameters.size() == 1 && property.setter.is_engaged())
|
||||
{
|
||||
|
|
|
@ -248,6 +248,67 @@ std::vector<attributes::function_def> get_all_implementable_methods(attributes::
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets all properties that this class should implement (i.e. that come from an unimplemented interface/mixin and the class itself)
|
||||
*/
|
||||
template<typename Context>
|
||||
std::vector<attributes::property_def> get_all_implementable_properties(attributes::klass_def const& cls, Context const& context)
|
||||
{
|
||||
bool want_beta = efl::eolian::grammar::context_find_tag<options_context>(context).want_beta;
|
||||
std::vector<attributes::property_def> ret;
|
||||
auto filter_beta = [&want_beta](attributes::property_def const& prop) {
|
||||
if (!want_beta)
|
||||
return prop.getter && !prop.setter ? !prop.getter->is_beta
|
||||
: prop.getter && prop.setter ? !prop.getter->is_beta || !prop.setter->is_beta
|
||||
: true
|
||||
;
|
||||
else
|
||||
return true;
|
||||
};
|
||||
|
||||
std::copy_if(cls.properties.begin(), cls.properties.end(), std::back_inserter(ret), filter_beta);
|
||||
|
||||
// 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_if(klass.properties.cbegin(), klass.properties.cend(), std::back_inserter(ret), filter_beta);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename Klass>
|
||||
inline bool is_managed_interface(Klass const& klass)
|
||||
{
|
||||
|
@ -284,6 +345,51 @@ std::vector<attributes::function_def> get_all_registerable_methods(attributes::k
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool is_function_registerable (attributes::function_def func, attributes::klass_def const& cls)
|
||||
{
|
||||
if (cls == func.klass)
|
||||
return true;
|
||||
|
||||
if (is_managed_interface(func.klass) && func.is_static)
|
||||
return true;
|
||||
|
||||
if (!is_managed_interface(func.klass) || func.scope != attributes::member_scope::scope_public)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// /*
|
||||
// * Gets all methods that this class should register (i.e. that comes from it and non-public interface methods
|
||||
// * that this class is the first one implementing)
|
||||
// */
|
||||
// template<typename Context>
|
||||
// std::vector<attributes::property_def> get_all_registerable_properties(attributes::klass_def const& cls, Context const& context)
|
||||
// {
|
||||
// std::vector<attributes::property_def> ret;
|
||||
|
||||
// auto implementable_properties = get_all_implementable_properties(cls, context);
|
||||
|
||||
// std::copy_if(implementable_properties.cbegin(), implementable_properties.cend(), std::back_inserter(ret)
|
||||
// , [&cls](attributes::property_def const & property) {
|
||||
// auto klass = property.getter ? property.getter->klass
|
||||
// : property.setter->klass;
|
||||
|
||||
// if (cls == klass)
|
||||
// return true;
|
||||
|
||||
// if (is_managed_interface(klass) && ((property.getter && property.getter->is_static)
|
||||
// || (property.setter && property.setter->is_static)))
|
||||
// return true;
|
||||
|
||||
// if (!is_managed_interface(klass) || ((property.getter && property.getter->scope != attributes::member_scope::scope_public)
|
||||
// || (property.setter && property.setter->scope != attributes::member_scope::scope_public)))
|
||||
// return true;
|
||||
// return false;
|
||||
// });
|
||||
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
/*
|
||||
* Checks whether the given is unique going up the inheritance tree from leaf_klass
|
||||
*/
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "name_helpers.hh"
|
||||
#include "async_function_definition.hh"
|
||||
#include "function_definition.hh"
|
||||
#include "property_definition.hh"
|
||||
#include "function_registration.hh"
|
||||
#include "function_declaration.hh"
|
||||
#include "documentation.hh"
|
||||
|
@ -142,7 +143,27 @@ struct klass
|
|||
if(!as_generator("\n" << scope_tab << "{\n").generate(sink, attributes::unused, iface_cxt))
|
||||
return false;
|
||||
|
||||
if(!as_generator(*(function_declaration)).generate(sink, cls.functions, iface_cxt))
|
||||
auto properties = cls.properties;
|
||||
auto functions = cls.functions;
|
||||
functions.erase (std::remove_if (functions.begin(), functions.end()
|
||||
, [&] (attributes::function_def const& f)
|
||||
{
|
||||
auto it = std::find_if (properties.begin(), properties.end()
|
||||
, [&f] (attributes::property_def const& prop)
|
||||
{
|
||||
return (prop.getter && *prop.getter == f)
|
||||
|| (prop.setter && *prop.setter == f);
|
||||
});
|
||||
if (it != properties.end())
|
||||
{
|
||||
if (it->getter && *it->getter == f)
|
||||
return property_generate_wrapper_getter (*it, iface_cxt);
|
||||
else if (it->setter && *it->setter == f)
|
||||
return property_generate_wrapper_setter (*it, iface_cxt);
|
||||
}
|
||||
return false;
|
||||
}), functions.end());
|
||||
if(!as_generator(*(function_declaration)).generate(sink, functions, iface_cxt))
|
||||
return false;
|
||||
|
||||
if(!as_generator(*(async_function_declaration)).generate(sink, cls.functions, iface_cxt))
|
||||
|
@ -158,7 +179,10 @@ struct klass
|
|||
).generate(sink, p, iface_cxt))
|
||||
return false;
|
||||
|
||||
if (!as_generator(*(property_wrapper_definition(cls))).generate(sink, cls.properties, iface_cxt))
|
||||
properties.erase(std::remove_if (properties.begin(), properties.end()
|
||||
, [&] (attributes::property_def const& prop)
|
||||
{ return !property_generate_wrapper_getter (prop, iface_cxt); }), properties.end());
|
||||
if (!as_generator(*(property_wrapper_definition(cls))).generate(sink, properties, iface_cxt))
|
||||
return false;
|
||||
|
||||
// End of interface declaration
|
||||
|
@ -246,7 +270,7 @@ struct klass
|
|||
|
||||
// Inherit function definitions
|
||||
auto implemented_methods = helpers::get_all_implementable_methods(cls, inherit_cxt);
|
||||
if(!as_generator(*(function_definition(true)))
|
||||
if(!as_generator(*(function_definition(true, helpers::get_all_implementable_properties(cls, inherit_cxt))))
|
||||
.generate(sink, implemented_methods, inherit_cxt)) return false;
|
||||
|
||||
// Async wrappers
|
||||
|
@ -337,6 +361,7 @@ struct klass
|
|||
auto native_inherit_name = name_helpers::klass_native_inherit_name(cls);
|
||||
auto inherit_name = name_helpers::klass_inherit_name(cls);
|
||||
auto implementable_methods = helpers::get_all_registerable_methods(cls, context);
|
||||
auto implementable_properties = helpers::get_all_implementable_properties(cls, context);
|
||||
bool root = !helpers::has_regular_ancestor(cls);
|
||||
bool is_concrete = context_find_tag<class_context>(context).current_wrapper_kind == class_context::concrete;
|
||||
auto const& indent = current_indentation(inative_cxt).inc();
|
||||
|
@ -376,11 +401,12 @@ struct klass
|
|||
return false;
|
||||
}
|
||||
|
||||
if(implementable_methods.size() >= 1)
|
||||
if(!implementable_methods.empty())
|
||||
{
|
||||
if(!as_generator(
|
||||
indent << scope_tab << "private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule("
|
||||
<< context_find_tag<library_context>(context).actual_library_name(cls.filename) << ");\n\n"
|
||||
<< context_find_tag<library_context>(context).actual_library_name(cls.filename) << "); // " << implementable_methods.size()
|
||||
<< " " << implementable_properties.size() << "\n\n"
|
||||
).generate(sink, attributes::unused, inative_cxt))
|
||||
return false;
|
||||
}
|
||||
|
@ -455,10 +481,17 @@ struct klass
|
|||
// Native method definitions
|
||||
if(!as_generator(
|
||||
indent << scope_tab << "#pragma warning disable CA1707, CS1591, SA1300, SA1600\n\n"
|
||||
<< *(native_function_definition(cls))
|
||||
<< *(native_function_definition(cls, implementable_properties))
|
||||
<< indent << scope_tab << "#pragma warning restore CA1707, CS1591, SA1300, SA1600\n\n")
|
||||
.generate(sink, implementable_methods, change_indentation(indent.inc(), inative_cxt))) return false;
|
||||
|
||||
if(!as_generator(
|
||||
indent << scope_tab << "#pragma warning disable CA1707, CS1591, SA1300, SA1600\n\n"
|
||||
<< *(native_property_function_definition(cls, cls))
|
||||
<< indent << scope_tab << "#pragma warning restore CA1707, CS1591, SA1300, SA1600\n\n")
|
||||
.generate(sink, implementable_properties
|
||||
, change_indentation(indent.inc(), inative_cxt))) return false;
|
||||
|
||||
if(!as_generator(indent << "}\n").generate(sink, attributes::unused, inative_cxt)) return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace eolian_mono {
|
|||
struct argument_generator;
|
||||
struct argument_invocation_generator;
|
||||
struct native_argument_invocation_generator;
|
||||
struct native_tuple_argument_invocation_generator;
|
||||
struct native_convert_in_variable_generator;
|
||||
struct convert_in_variable_generator;
|
||||
struct native_convert_out_variable_generator;
|
||||
|
@ -108,6 +109,16 @@ template <>
|
|||
struct attributes_needed< ::eolian_mono::native_argument_invocation_generator> : std::integral_constant<int, 1> {};
|
||||
}
|
||||
|
||||
template <>
|
||||
struct is_eager_generator< ::eolian_mono::native_tuple_argument_invocation_generator> : std::true_type {};
|
||||
template <>
|
||||
struct is_generator< ::eolian_mono::native_tuple_argument_invocation_generator> : std::true_type {};
|
||||
|
||||
namespace type_traits {
|
||||
template <>
|
||||
struct attributes_needed< ::eolian_mono::native_tuple_argument_invocation_generator> : std::integral_constant<int, 1> {};
|
||||
}
|
||||
|
||||
template <>
|
||||
struct is_eager_generator< ::eolian_mono::native_convert_in_variable_generator> : std::true_type {};
|
||||
template <>
|
||||
|
@ -552,6 +563,28 @@ struct native_argument_invocation_generator
|
|||
}
|
||||
} const native_argument_invocation {};
|
||||
|
||||
struct native_tuple_argument_invocation_generator
|
||||
{
|
||||
template <typename OutputIterator, typename Context>
|
||||
bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
|
||||
{
|
||||
std::string arg;// = direction_modifier(param);
|
||||
|
||||
if (param_should_use_out_var(param, true))
|
||||
arg += out_variable_name(param.param_name);
|
||||
else if (param_should_use_in_var(param, true))
|
||||
arg += in_variable_name(param.param_name);
|
||||
else if (param.type.original_type.visit(is_fp_visitor{}))
|
||||
{
|
||||
arg += escape_keyword(param.param_name) + "_wrapper.ManagedCb";
|
||||
}
|
||||
else // FIXME Wrap data and C function pointers into some kind of structure.
|
||||
arg += escape_keyword(param.param_name);
|
||||
|
||||
return as_generator(arg).generate(sink, attributes::unused, context);
|
||||
}
|
||||
} const native_tuple_argument_invocation {};
|
||||
|
||||
// Generates the correct parameter name when invoking a function
|
||||
struct argument_invocation_generator
|
||||
{
|
||||
|
|
|
@ -0,0 +1,383 @@
|
|||
/*
|
||||
* Copyright 2019 by its authors. See AUTHORS.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef EOLIAN_MONO_PROPERTY_DEFINITION_HH
|
||||
#define EOLIAN_MONO_PROPERTY_DEFINITION_HH
|
||||
|
||||
#include "grammar/generator.hpp"
|
||||
#include "grammar/klass_def.hpp"
|
||||
|
||||
#include "grammar/indentation.hpp"
|
||||
#include "grammar/list.hpp"
|
||||
#include "grammar/alternative.hpp"
|
||||
#include "type.hh"
|
||||
#include "parameter.hh"
|
||||
#include "name_helpers.hh"
|
||||
#include "using_decl.hh"
|
||||
#include "blacklist.hh"
|
||||
|
||||
#include <eina_variant.hh>
|
||||
|
||||
namespace eolian_mono {
|
||||
|
||||
struct compare_get_and_set_value_type
|
||||
{
|
||||
inline bool operator () (attributes::parameter_def const& get, attributes::parameter_def const& set) const;
|
||||
inline bool operator () (attributes::type_def const& get, attributes::type_def const& set) const;
|
||||
};
|
||||
|
||||
struct compare_get_and_set_value_type_overload
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(T const& /*left*/, U const& /*right*/) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool operator()(attributes::regular_type_def const& left, attributes::regular_type_def const& right) const
|
||||
{
|
||||
return left.base_type == right.base_type
|
||||
&& left.namespaces == right.namespaces;
|
||||
}
|
||||
bool operator()(attributes::complex_type_def const& left, attributes::complex_type_def const& right) const
|
||||
{
|
||||
return (*this)(left.outer, right.outer)
|
||||
&& std::equal (left.subtypes.begin(), left.subtypes.end(), right.subtypes.begin()
|
||||
, compare_get_and_set_value_type{});
|
||||
}
|
||||
bool operator()(attributes::klass_name const& left, attributes::klass_name const& right) const
|
||||
{
|
||||
return left.namespaces == right.namespaces
|
||||
&& left.eolian_name == right.eolian_name;
|
||||
}
|
||||
|
||||
typedef bool result_type;
|
||||
};
|
||||
|
||||
inline bool compare_get_and_set_value_type::operator () (attributes::parameter_def const& get, attributes::parameter_def const& set) const
|
||||
{
|
||||
return efl::eina::visit(compare_get_and_set_value_type_overload{}, get.type.original_type, set.type.original_type);
|
||||
}
|
||||
inline bool compare_get_and_set_value_type::operator () (attributes::type_def const& get, attributes::type_def const& set) const
|
||||
{
|
||||
return efl::eina::visit(compare_get_and_set_value_type_overload{}, get.original_type, set.original_type);
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
bool property_generate_wrapper_both_check(attributes::property_def const& property, Context const& context)
|
||||
{
|
||||
if (blacklist::is_property_blacklisted(property, context))
|
||||
return false;
|
||||
|
||||
bool is_interface = context_find_tag<class_context>(context).current_wrapper_kind == class_context::interface;
|
||||
bool is_static = (property.getter.is_engaged() && property.getter->is_static)
|
||||
|| (property.setter.is_engaged() && property.setter->is_static);
|
||||
bool is_concrete = context_find_tag<class_context>(context).current_wrapper_kind == class_context::concrete;
|
||||
|
||||
if ((is_concrete || is_interface) && is_static)
|
||||
return false;
|
||||
|
||||
if (!property.getter)
|
||||
return false;
|
||||
|
||||
if (property.setter)
|
||||
{
|
||||
if (property.getter->values.size() == property.setter->values.size())
|
||||
{
|
||||
if (!std::equal (property.getter->values.begin(), property.getter->values.end(), property.setter->values.begin()
|
||||
, compare_get_and_set_value_type{}))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
bool property_generate_wrapper_getter(attributes::property_def const& property, Context const& context)
|
||||
{
|
||||
if (!property_generate_wrapper_both_check (property, context))
|
||||
return false;
|
||||
|
||||
if (!property.getter->keys.empty())
|
||||
return false;
|
||||
|
||||
if (property.getter->explicit_return_type != attributes::void_)
|
||||
return false;
|
||||
|
||||
assert (!!property.getter.is_engaged());
|
||||
|
||||
bool is_interface = context_find_tag<class_context>(context).current_wrapper_kind == class_context::interface;
|
||||
if (is_interface)
|
||||
{
|
||||
std::string get_scope = property.getter.is_engaged() ? eolian_mono::function_scope_get(*property.getter) : "";
|
||||
bool is_get_public = get_scope == "public ";
|
||||
if (!is_get_public)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
bool property_generate_wrapper_setter (attributes::property_def const& property, Context const& context)
|
||||
{
|
||||
if (!property_generate_wrapper_both_check (property, context))
|
||||
return false;
|
||||
if (!property.setter)
|
||||
return false;
|
||||
|
||||
if (property.setter->explicit_return_type != attributes::void_)
|
||||
return false;
|
||||
|
||||
if (!property.setter->keys.empty())
|
||||
return false;
|
||||
|
||||
bool is_interface = context_find_tag<class_context>(context).current_wrapper_kind == class_context::interface;
|
||||
if (property.setter.is_engaged() && is_interface)
|
||||
{
|
||||
std::string set_scope = property.setter.is_engaged() ? eolian_mono::function_scope_get(*property.setter) : "";
|
||||
bool is_set_public = set_scope == "public ";
|
||||
if (!is_set_public)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
struct native_property_function_definition_generator
|
||||
{
|
||||
template <typename OutputIterator, typename Context>
|
||||
bool generate(OutputIterator sink, attributes::property_def const& property, Context const& context) const
|
||||
{
|
||||
EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "native_property_function_definition_generator: " << property.name << std::endl;
|
||||
|
||||
if(blacklist::is_property_blacklisted(property, context))
|
||||
return true;
|
||||
|
||||
auto const& indent = current_indentation(context);
|
||||
|
||||
bool has_wrapper_getter = property_generate_wrapper_getter (property, context);
|
||||
bool has_wrapper_setter = property_generate_wrapper_setter (property, context);
|
||||
|
||||
auto gen = [&] (attributes::function_def const& f, bool is_set)
|
||||
{
|
||||
// Delegate for the C# method we will export to EO as a method implementation.
|
||||
if(!as_generator
|
||||
(
|
||||
indent << eolian_mono::marshall_annotation(true) << "\n"
|
||||
<< indent << "private delegate "
|
||||
<< eolian_mono::marshall_type(true)
|
||||
<< " "
|
||||
<< string
|
||||
<< "_delegate(" << (f.is_static ? "" : "System.IntPtr obj, System.IntPtr pd")
|
||||
<< ((!f.is_static && f.parameters.size() > 0) ? ", " : "")
|
||||
<< (grammar::attribute_reorder<-1, -1>
|
||||
(
|
||||
(marshall_annotation << " " << marshall_parameter)
|
||||
) % ", ")
|
||||
<< ");\n\n")
|
||||
.generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context))
|
||||
return false;
|
||||
|
||||
// API delegate is the wrapper for the Eo methods exported from C that we will use from C#.
|
||||
if(!as_generator
|
||||
(
|
||||
indent << eolian_mono::marshall_annotation(true) << "\n"
|
||||
<< indent << "internal delegate "
|
||||
<< eolian_mono::marshall_type(true)
|
||||
<< " "
|
||||
<< string << "_api_delegate(" << (f.is_static ? "" : "System.IntPtr obj")
|
||||
<< ((!f.is_static && f.parameters.size() > 0) ? ", " : "")
|
||||
<< (grammar::attribute_reorder<-1, -1>
|
||||
(
|
||||
(marshall_annotation << " " << marshall_parameter)
|
||||
) % ", ")
|
||||
<< ");\n\n")
|
||||
.generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context))
|
||||
return false;
|
||||
|
||||
// Delegate holder (so it can't be collected).
|
||||
if(!as_generator
|
||||
(indent << "internal static readonly Efl.Eo.FunctionWrapper<" << string << "_api_delegate> " << string << "_ptr = new Efl.Eo.FunctionWrapper<"
|
||||
<< string << "_api_delegate>(Module, \"" << string << "\");\n\n")
|
||||
.generate(sink, std::make_tuple(f.c_name, f.c_name, f.c_name, f.c_name), context))
|
||||
return false;
|
||||
|
||||
// We do not generate the wrapper to be called from C for non public interface member directly.
|
||||
if (blacklist::is_non_public_interface_member(f, *implementing_klass))
|
||||
return true;
|
||||
|
||||
// Do not generate static method in interface
|
||||
if (((implementing_klass->type == attributes::class_type::interface_) ||
|
||||
(implementing_klass->type == attributes::class_type::mixin)) && f.is_static)
|
||||
return true;
|
||||
|
||||
// Actual method implementation to be called from C.
|
||||
std::string return_type;
|
||||
if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context))
|
||||
return false;
|
||||
|
||||
std::string klass_cast_name;
|
||||
if ((implementing_klass->type == attributes::class_type::interface_) ||
|
||||
((implementing_klass->type == attributes::class_type::mixin) && !f.is_static))
|
||||
klass_cast_name = name_helpers::klass_interface_name(*implementing_klass);
|
||||
else
|
||||
klass_cast_name = name_helpers::klass_inherit_name(*implementing_klass);
|
||||
|
||||
std::string self = "Efl.Eo.Globals.Super(obj, Efl.Eo.Globals.GetClass(obj))";
|
||||
|
||||
if (f.is_static)
|
||||
self = "";
|
||||
|
||||
if(!as_generator
|
||||
(indent << "[SuppressMessage(\"Microsoft.Reliability\", \"CA2000:DisposeObjectsBeforeLosingScope\", Justification = \"The instantiated objects can be stored in the called Managed API method.\")]\n"
|
||||
<< indent << "private static "
|
||||
<< eolian_mono::marshall_type(true) << " "
|
||||
<< string
|
||||
<< "(System.IntPtr obj, System.IntPtr pd"
|
||||
<< *(", " << marshall_parameter)
|
||||
<< ")\n"
|
||||
<< indent << "{\n"
|
||||
<< indent << scope_tab << "Eina.Log.Debug(\"function " << string << " was called\");\n"
|
||||
<< indent << scope_tab << "var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);\n"
|
||||
<< indent << scope_tab << "if (ws != null)\n"
|
||||
<< indent << scope_tab << "{\n"
|
||||
<< indent << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble() << "\n"
|
||||
<< indent << scope_tab << scope_tab << "try\n"
|
||||
<< indent << scope_tab << scope_tab << "{\n"
|
||||
)
|
||||
.generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters
|
||||
, /***/f.c_name/***/
|
||||
, f
|
||||
), context))
|
||||
return false;
|
||||
if (is_set/* && has_wrapper_setter*/)
|
||||
{
|
||||
if(!as_generator
|
||||
(
|
||||
indent << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "")
|
||||
<< (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")ws.Target).") << string
|
||||
)
|
||||
.generate(sink, std::make_tuple(name_helpers::property_managed_name(property), f.parameters), context))
|
||||
return false;
|
||||
|
||||
if(!f.keys.empty() && !as_generator(lit("[(") << (native_argument_invocation % ", ") << ")]").generate (sink, f.keys, context))
|
||||
return false;
|
||||
|
||||
if(!as_generator
|
||||
(" = ("
|
||||
<< (native_tuple_argument_invocation % ", ") << ");\n"
|
||||
)
|
||||
.generate(sink, f.values, context))
|
||||
return false;
|
||||
}
|
||||
else if (!is_set/* && has_wrapper_getter*/)
|
||||
{
|
||||
if(!as_generator
|
||||
(
|
||||
indent << scope_tab << scope_tab << scope_tab << "var ret = "
|
||||
<< (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")ws.Target).")
|
||||
<< string
|
||||
|
||||
)
|
||||
.generate(sink, std::make_tuple(name_helpers::property_managed_name(property)), context))
|
||||
return false;
|
||||
|
||||
if(!f.keys.empty() && !as_generator(lit("[(") << (native_argument_invocation % ", ") << ")]").generate (sink, f.keys, context))
|
||||
return false;
|
||||
|
||||
if (!as_generator(";\n").generate (sink, attributes::unused, context))
|
||||
return false;
|
||||
|
||||
}
|
||||
// else if (!as_generator
|
||||
// (indent << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "")
|
||||
// << (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")ws.Target).") << string
|
||||
// << "(" << (native_argument_invocation % ", ") << ");\n"
|
||||
// ).generate(sink, std::make_tuple(name_helpers::managed_method_name(f), f.parameters), context))
|
||||
// return false;
|
||||
|
||||
if(!as_generator
|
||||
(
|
||||
indent << scope_tab << scope_tab << "}\n"
|
||||
<< indent << scope_tab << scope_tab << "catch (Exception e)\n"
|
||||
<< indent << scope_tab << scope_tab << "{\n"
|
||||
<< indent << scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n"
|
||||
<< indent << scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);\n"
|
||||
<< indent << scope_tab << scope_tab << "}\n\n"
|
||||
<< indent << eolian_mono::native_function_definition_epilogue(*implementing_klass) << "\n"
|
||||
<< indent << scope_tab << "}\n"
|
||||
<< indent << scope_tab << "else\n"
|
||||
<< indent << scope_tab << "{\n"
|
||||
<< indent << scope_tab << scope_tab << (return_type != "void" ? "return " : "") << string
|
||||
<< "_ptr.Value.Delegate(" << self << ((!f.is_static && f.parameters.size() > 0) ? ", " : "") << (argument % ", ") << ");\n"
|
||||
<< indent << scope_tab << "}\n"
|
||||
<< indent << "}\n\n"
|
||||
)
|
||||
.generate(sink, std::make_tuple(f, f.c_name, f.parameters), context))
|
||||
return false;
|
||||
|
||||
// Static functions do not need to be called from C
|
||||
if (f.is_static)
|
||||
return true;
|
||||
|
||||
// This is the delegate that will be passed to Eo to be called from C.
|
||||
if(!as_generator(
|
||||
indent << "private static " << f.c_name << "_delegate " << f.c_name << "_static_delegate;\n\n"
|
||||
).generate(sink, attributes::unused, context))
|
||||
return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
bool r = true;
|
||||
if(r && property.getter && has_wrapper_getter
|
||||
&& helpers::is_function_registerable (*property.getter, *implementing_klass))
|
||||
r &= gen (*property.getter, false);
|
||||
if(r && property.setter && has_wrapper_setter
|
||||
&& helpers::is_function_registerable (*property.setter, *implementing_klass))
|
||||
r &= gen (*property.setter, true);
|
||||
return r;
|
||||
}
|
||||
|
||||
attributes::klass_def const* implementing_klass, *klass_from_property;
|
||||
};
|
||||
|
||||
struct native_property_function_definition_parameterized
|
||||
{
|
||||
native_property_function_definition_generator operator()(attributes::klass_def const& klass
|
||||
, attributes::klass_def const& prop_from_klass) const
|
||||
{
|
||||
return {&klass, &prop_from_klass};
|
||||
}
|
||||
} const native_property_function_definition;
|
||||
|
||||
}
|
||||
|
||||
namespace efl { namespace eolian { namespace grammar {
|
||||
|
||||
template <>
|
||||
struct is_eager_generator< ::eolian_mono::native_property_function_definition_generator> : std::true_type {};
|
||||
template <>
|
||||
struct is_generator< ::eolian_mono::native_property_function_definition_generator> : std::true_type {};
|
||||
|
||||
namespace type_traits {
|
||||
|
||||
template <>
|
||||
struct attributes_needed< ::eolian_mono::native_property_function_definition_generator> : std::integral_constant<int, 1> {};
|
||||
|
||||
} } } }
|
||||
|
||||
#endif
|
|
@ -24,9 +24,21 @@
|
|||
#include <iosfwd>
|
||||
|
||||
#include <eina_aligned_union.hh>
|
||||
#include <eina_tuple.hh>
|
||||
|
||||
namespace efl { namespace eina {
|
||||
|
||||
template <typename... Args>
|
||||
struct variant;
|
||||
|
||||
template <typename...Args>
|
||||
struct variant_size : std::tuple_size<std::tuple<Args...>>::type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename V>
|
||||
struct variant_as_tuple;
|
||||
|
||||
namespace _impl {
|
||||
|
||||
template <typename T, typename U, typename...Others>
|
||||
|
@ -51,7 +63,57 @@ template <typename T, typename U, typename...Args>
|
|||
struct find : find_impl<0u, T, U, Args...>
|
||||
{};
|
||||
|
||||
template <std::size_t NT, std::size_t NV, typename TupleVariant, typename TypesFound>
|
||||
struct visit_impl_meta_args
|
||||
{
|
||||
typedef std::integral_constant<std::size_t, NT> current_type_index;
|
||||
typedef std::integral_constant<std::size_t, NV> current_variant_index;
|
||||
typedef TupleVariant variants;
|
||||
// typedef typename std::tuple_element<NV, variants>::type current_variant;
|
||||
// typedef typename variant_as_tuple<current_variant>::type current_variant_types;
|
||||
// typedef typename std::tuple_element<NT, current_variant_types>::type current_type;
|
||||
typedef TypesFound types_found;
|
||||
};
|
||||
|
||||
template <typename T> struct current_variant_types
|
||||
{
|
||||
typedef typename std::tuple_element<T::current_variant_index::value, typename T::variants>::type current_variant;
|
||||
typedef typename variant_as_tuple<current_variant>::type type;
|
||||
};
|
||||
}
|
||||
|
||||
// template <typename FoundTypes, std::size_t N, typename...Tuples>
|
||||
// struct call_n_visitor;
|
||||
|
||||
// template <typename FoundTypes, std::size_t N, typename Tuple, typename...Tuples>
|
||||
// struct call_n_visitor<FoundTypes, N, Tuple, Tuples...>
|
||||
// {
|
||||
|
||||
/*
|
||||
template <typename F>
|
||||
static typename F::result_type call(int type, void* buffer, F f)
|
||||
{
|
||||
if(type == N)
|
||||
{
|
||||
using std::tuple_element;
|
||||
typedef typename tuple_element<N, Tuple>::type type;
|
||||
type* o = static_cast<type*>(buffer);
|
||||
return f(*o);
|
||||
}
|
||||
else
|
||||
return call_visitor<N+1, L, Tuple>::call(type, buffer, f);
|
||||
}
|
||||
*/
|
||||
|
||||
// template <typename FoundTypes, std::size_t L, typename Tuple>
|
||||
// struct call_n_visitor<FoundTypes, L, L, Tuple>
|
||||
// {
|
||||
// template <typename F, typename...Variants>
|
||||
// static typename F::result_type call(int, void const*, F, Variants&&... variants)
|
||||
// {
|
||||
// std::abort();
|
||||
// }
|
||||
// };
|
||||
|
||||
template <std::size_t N, std::size_t L, typename Tuple>
|
||||
struct call_visitor
|
||||
|
@ -306,6 +368,11 @@ struct variant
|
|||
{
|
||||
return call_visitor<0u, sizeof...(Args), std::tuple<Args...>>::call(type, static_cast<void*>(&buffer), f);
|
||||
}
|
||||
|
||||
constexpr std::size_t index() const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
|
@ -332,6 +399,103 @@ private:
|
|||
* Member variable for holding the contained value.
|
||||
*/
|
||||
buffer_type buffer;
|
||||
|
||||
template <typename V>
|
||||
friend struct variant_as_tuple;
|
||||
|
||||
// template <std::size_t NT, std::size_t NV, typename F, typename Tuple, typename Types, typename TupleVariant, std::size_t...I>
|
||||
// friend typename F::result_type visit_impl2
|
||||
// (std::false_type, std::false_type
|
||||
// , _impl::visit_impl_meta_args<NT, NV, Tuple, Types>, F&& f, TupleVariant&& variants, index_sequence<I...>);
|
||||
|
||||
// template <std::size_t NT, std::size_t NV, typename F, typename Tuple, typename Types, typename TupleVariant, std::size_t...I>
|
||||
// friend typename F::result_type visit_impl2
|
||||
// (std::true_type, std::false_type
|
||||
// , _impl::visit_impl_meta_args<NT, NV, Tuple, Types>, F&& f, TupleVariant&& variants, index_sequence<I...>);
|
||||
// template <std::size_t NT, std::size_t NV, typename F, typename Tuple, typename Types, typename TupleVariant, std::size_t...I>
|
||||
// friend typename F::result_type visit_impl2
|
||||
// (std::false_type, std::true_type
|
||||
// , _impl::visit_impl_meta_args<NT, NV, Tuple, Types>, F&& f, TupleVariant&& variants, index_sequence<I...>);
|
||||
|
||||
// // template <std::size_t NT, std::size_t NV, typename F, typename Tuple, typename Types, typename TupleVariant>
|
||||
// // friend typename F::result_type visit_impl2
|
||||
// // (std::true_type, std::false_type
|
||||
// // , _impl::visit_impl_meta_args<NT, NV, Tuple, Types>, F&& f, TupleVariant&& variants)
|
||||
// // {
|
||||
// // }
|
||||
|
||||
// // template <typename F, typename...AllVariants, typename...Variants>
|
||||
// // friend typename F::result_type call
|
||||
// // (std::true_type, int, F &&, Variants&&... variants)
|
||||
// // {
|
||||
// // std::abort();
|
||||
// // }
|
||||
|
||||
// // template <typename F, typename Variant, typename...Variants>
|
||||
// // friend typename F::result_type call (F&&f, Variant&& variant, Variants&&... variants)
|
||||
// // {
|
||||
// // return call (std::integral_constant<bool, (N == variant_size<Variant>::value)>{}
|
||||
// // , variant.type, std::forward<F>(f), std::forward<Variant>(variant), std::forward<Variants>(variants)...);
|
||||
// // }
|
||||
|
||||
// // template <typename F, typename Variant, typename...Variants>
|
||||
// // friend typename F::result_type call (F&&f, Variant&& variant, Variants&&... variants)
|
||||
// // {
|
||||
// // return call (std::integral_constant<bool, (N == variant_size<Variant>::value)>{}
|
||||
// // , variant.type, std::forward<F>(f), std::forward<Variant>(variant), std::forward<Variants>(variants)...);
|
||||
// // }
|
||||
|
||||
// template <typename F, typename...Variants>
|
||||
// friend typename F::result_type visit_impl (F&& f, Variants&&... variants);
|
||||
};
|
||||
|
||||
|
||||
template <typename...VArgs>
|
||||
struct variant_as_tuple<variant<VArgs...>>
|
||||
{
|
||||
typedef std::tuple<VArgs...> type;
|
||||
};
|
||||
|
||||
template <typename...VArgs>
|
||||
struct variant_as_tuple<const variant<VArgs...>>
|
||||
{
|
||||
typedef std::tuple<VArgs...> type;
|
||||
};
|
||||
|
||||
template <typename...VArgs>
|
||||
struct variant_as_tuple<volatile variant<VArgs...>>
|
||||
{
|
||||
typedef std::tuple<VArgs...> type;
|
||||
};
|
||||
|
||||
template <typename...VArgs>
|
||||
struct variant_as_tuple<const volatile variant<VArgs...>>
|
||||
{
|
||||
typedef std::tuple<VArgs...> type;
|
||||
};
|
||||
|
||||
template <typename...VArgs>
|
||||
struct variant_as_tuple<variant<VArgs...>&>
|
||||
{
|
||||
typedef std::tuple<VArgs...> type;
|
||||
};
|
||||
|
||||
template <typename...VArgs>
|
||||
struct variant_as_tuple<const variant<VArgs...>&>
|
||||
{
|
||||
typedef std::tuple<VArgs...> type;
|
||||
};
|
||||
|
||||
template <typename...VArgs>
|
||||
struct variant_as_tuple<volatile variant<VArgs...>&>
|
||||
{
|
||||
typedef std::tuple<VArgs...> type;
|
||||
};
|
||||
|
||||
template <typename...VArgs>
|
||||
struct variant_as_tuple<const volatile variant<VArgs...>&>
|
||||
{
|
||||
typedef std::tuple<VArgs...> type;
|
||||
};
|
||||
|
||||
template <typename...Args>
|
||||
|
@ -372,7 +536,80 @@ T const& get(variant<Args...>const& variant, typename std::enable_if<_impl::is_o
|
|||
else
|
||||
throw std::logic_error("");
|
||||
}
|
||||
|
||||
|
||||
template <std::size_t NT, std::size_t NV, typename F, typename Tuple, typename Types, typename TupleVariant, std::size_t...I>
|
||||
typename F::result_type visit_impl2
|
||||
(std::false_type, std::true_type
|
||||
, _impl::visit_impl_meta_args<NT, NV, Tuple, Types>, F&& f, TupleVariant&& variants
|
||||
, eina::index_sequence<I...>)
|
||||
{
|
||||
return f (eina::get<typename std::tuple_element<I, Types>::type>(std::get<I>(variants))...);
|
||||
}
|
||||
|
||||
template <std::size_t NT, std::size_t NV, typename F, typename Tuple, typename Types, typename TupleVariant, std::size_t...I>
|
||||
typename F::result_type visit_impl2
|
||||
(std::true_type, std::false_type
|
||||
, _impl::visit_impl_meta_args<NT, NV, Tuple, Types>, F&&, TupleVariant&&, eina::index_sequence<I...>)
|
||||
{
|
||||
std::abort();
|
||||
}
|
||||
|
||||
|
||||
template <std::size_t NT, std::size_t NV, typename F, typename Tuple, typename Types, typename TupleVariant
|
||||
, std::size_t...I>
|
||||
typename F::result_type visit_impl2 (std::false_type, std::false_type
|
||||
, _impl::visit_impl_meta_args<NT, NV, Tuple, Types>, F&& f, TupleVariant&& variants
|
||||
, index_sequence<I...>)
|
||||
{
|
||||
using std::tuple_element;
|
||||
typedef _impl::visit_impl_meta_args<NT, NV, Tuple, Types> meta_args;
|
||||
if(std::get<NV>(variants).index() == NT)
|
||||
{
|
||||
typedef typename _impl::current_variant_types<meta_args>::type variant_types;
|
||||
typedef typename tuple_element<NT, variant_types>::type type;
|
||||
std::integral_constant<bool, (std::tuple_size<Tuple>::value == NV+1)> is_true {};
|
||||
return visit_impl2( std::false_type{}
|
||||
, is_true
|
||||
, _impl::visit_impl_meta_args<0u, NV+1, Tuple, typename _mpl::push_back<Types, type>::type>{}
|
||||
, std::forward<F>(f), std::forward<TupleVariant>(variants)
|
||||
, make_index_sequence<std::tuple_size<TupleVariant>::value>{});
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef typename _impl::current_variant_types<meta_args>::type variant_types;
|
||||
return visit_impl2 (std::integral_constant<bool, (std::tuple_size<variant_types>::value == NT+1)>{}
|
||||
, std::false_type{}
|
||||
, _impl::visit_impl_meta_args<NT+1, NV, Tuple, Types>{}, std::forward<F>(f), std::forward<TupleVariant>(variants)
|
||||
, make_index_sequence<std::tuple_size<TupleVariant>::value>{});
|
||||
}
|
||||
}
|
||||
|
||||
template <std::size_t NT, std::size_t NV, typename F, typename Tuple, typename Types, typename TupleVariant>
|
||||
typename F::result_type visit_impl_aux (std::false_type fals, std::false_type
|
||||
, _impl::visit_impl_meta_args<NT, NV, Tuple, Types> args, F&& f, TupleVariant&& variants)
|
||||
{
|
||||
return visit_impl2 (fals, fals, args, std::forward<F>(f), std::forward<TupleVariant>(variants)
|
||||
, make_index_sequence<std::tuple_size<TupleVariant>::value>{});
|
||||
}
|
||||
|
||||
template <typename F, typename...Variants>
|
||||
typename F::result_type visit_impl (F&& f, Variants&&... variants)
|
||||
{
|
||||
return visit_impl_aux
|
||||
(std::false_type{}
|
||||
, std::false_type{}
|
||||
, _impl::visit_impl_meta_args
|
||||
<0u, 0u
|
||||
, std::tuple<typename std::remove_cv<Variants>::type...>, std::tuple<>>{}, std::forward<F>(f), std::forward_as_tuple(std::forward<Variants>(variants)...));
|
||||
}
|
||||
|
||||
template <typename F, typename...Variants>
|
||||
auto visit (F&& function, Variants&& ... variants) -> typename F::result_type
|
||||
{
|
||||
return visit_impl (std::forward<F>(function), std::forward<Variants>(variants)...);
|
||||
}
|
||||
|
||||
} }
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -33,20 +33,13 @@ public class GenericModel<T> : Efl.Object, Efl.IModel
|
|||
/// <summary>The list of properties available in the wrapped model.</summary>
|
||||
public IEnumerable<System.String> Properties
|
||||
{
|
||||
get { return GetProperties(); }
|
||||
get { return model.Properties; }
|
||||
}
|
||||
|
||||
/// <summary>The number of children in the wrapped model.</summary>
|
||||
public uint ChildrenCount
|
||||
{
|
||||
get { return GetChildrenCount(); }
|
||||
}
|
||||
|
||||
/// <summary>The list of properties available in the wrapped model.</summary>
|
||||
/// <returns>The list of properties in the model.</returns>
|
||||
public IEnumerable<System.String> GetProperties()
|
||||
{
|
||||
return model.GetProperties();
|
||||
get { return model.ChildrenCount; }
|
||||
}
|
||||
|
||||
/// <summary>Gets the value of the given property in the wrapped model.</summary>
|
||||
|
@ -67,13 +60,6 @@ public class GenericModel<T> : Efl.Object, Efl.IModel
|
|||
return model.SetProperty(property, value);
|
||||
}
|
||||
|
||||
/// <summary>Returns the number of children in the wrapped model.</summary>
|
||||
/// <returns>The number of children.</returns>
|
||||
public uint GetChildrenCount()
|
||||
{
|
||||
return model.GetChildrenCount();
|
||||
}
|
||||
|
||||
/// <summary>Returns an <see cref="Eina.Future" /> that will resolve when the property is ready to be read.</summary>
|
||||
/// <param name="property">The property of the model.</param>
|
||||
/// <returns>An <see cref="Eina.Future" /> that resolves when the property is ready.</returns>
|
||||
|
@ -169,10 +155,10 @@ public class GenericModel<T> : Efl.Object, Efl.IModel
|
|||
|
||||
/// <summary>Get children as specified by iterator.
|
||||
///
|
||||
/// Provided index have to be between 0 and <see cref="Efl.IModel.GetChildrenCount"/>.
|
||||
/// Provided index have to be between 0 and <see cref="Efl.IModel.ChildrenCount"/>.
|
||||
///
|
||||
/// This function might rely on <see cref="Efl.IModel.GetChildrenSlice"/> as a fallback.</summary>
|
||||
/// <param name="indices">Indices of the requested children.</param>
|
||||
/// This function might rely on <see cref="Efl.IModel.GetChildrenSlice"/> as a fallback.<br/>Since EFL 1.23.</summary>
|
||||
/// <param name="indices">Indices of the requested children.</param>
|
||||
/// <returns>Array of children</returns>
|
||||
public Eina.Future GetChildrenIndex(IEnumerable<uint> indices)
|
||||
{
|
||||
|
|
|
@ -227,7 +227,7 @@ public abstract class EoWrapper : IWrapper, IDisposable
|
|||
public void Del()
|
||||
{
|
||||
// FIXME Implement this
|
||||
((Efl.Object)this).SetParent(null);
|
||||
((Efl.Object)this).Parent = null;
|
||||
Dispose();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,28 +40,25 @@ context_add_tag(NewTag const& tag, context_null context)
|
|||
return context_cons<NewTag, context_null>{tag, context};
|
||||
}
|
||||
|
||||
template <typename Tag, typename SameTag, typename Tail>
|
||||
constexpr context_cons<SameTag, Tail>
|
||||
context_replace_tag(Tag const& tag, context_cons<SameTag, Tail> const& context
|
||||
, typename std::enable_if<std::is_same<Tag, SameTag>::value>::type* = nullptr)
|
||||
template <typename Tag, typename Tail>
|
||||
constexpr context_cons<Tag, Tail>
|
||||
context_replace_tag(Tag const& tag, context_cons<Tag, Tail> const& context)
|
||||
{
|
||||
return {tag, context.tail};
|
||||
}
|
||||
|
||||
template <typename Tag, typename OtherTag, typename Tail>
|
||||
constexpr context_cons<OtherTag, Tail>
|
||||
context_replace_tag(Tag const& tag, context_cons<OtherTag, Tail> const& context
|
||||
, typename std::enable_if<!std::is_same<Tag, OtherTag>::value>::type* = nullptr)
|
||||
{
|
||||
return {context.tag, context_replace_tag(tag, context.tail)};
|
||||
}
|
||||
|
||||
template <typename Tag>
|
||||
constexpr context_null
|
||||
constexpr context_cons<Tag, context_null>
|
||||
context_replace_tag(Tag const& tag, context_null const&)
|
||||
{
|
||||
static_assert(std::is_same<Tag, context_null>::value, "Tag type not available in this generation context");
|
||||
return tag;
|
||||
return context_cons<Tag, context_null>{tag, context_null{}};
|
||||
}
|
||||
|
||||
template <typename Tag, typename OtherTag, typename Tail>
|
||||
constexpr context_cons<OtherTag, decltype(context_replace_tag(std::declval<Tag>(), std::declval<Tail>()))>
|
||||
context_replace_tag(Tag const& tag, context_cons<OtherTag, Tail> const& context)
|
||||
{
|
||||
return {context.tag, context_replace_tag(tag, context.tail)};
|
||||
}
|
||||
|
||||
template <typename Tag, typename Context>
|
||||
|
|
|
@ -576,10 +576,10 @@ class TestEinaArray
|
|||
var a = new Eina.Array<Dummy.Numberwrapper>();
|
||||
Test.Assert(a.Handle != IntPtr.Zero);
|
||||
var o = new Dummy.Numberwrapper();
|
||||
o.SetNumber(88);
|
||||
o.Number = 88;
|
||||
Test.Assert(a.Push(o));
|
||||
Test.Assert(a[0].NativeHandle == o.NativeHandle);
|
||||
Test.Assert(a[0].GetNumber() == 88);
|
||||
Test.Assert(a[0].Number == 88);
|
||||
o.Dispose();
|
||||
a.Dispose();
|
||||
}
|
||||
|
@ -619,11 +619,11 @@ class TestEinaArray
|
|||
var a = new Eina.Array<Dummy.Numberwrapper>();
|
||||
Test.Assert(a.Handle != IntPtr.Zero);
|
||||
var o = new Dummy.Numberwrapper();
|
||||
o.SetNumber(88);
|
||||
o.Number = 88;
|
||||
Test.Assert(a.Push(o));
|
||||
var p = a.Pop();
|
||||
Test.Assert(p.NativeHandle == o.NativeHandle);
|
||||
Test.Assert(p.GetNumber() == 88);
|
||||
Test.Assert(p.Number == 88);
|
||||
Test.Assert(a.Count() == 0);
|
||||
o.Dispose();
|
||||
a.Dispose();
|
||||
|
@ -674,25 +674,25 @@ class TestEinaArray
|
|||
Test.Assert(a.Handle != IntPtr.Zero);
|
||||
|
||||
var o1 = new Dummy.Numberwrapper();
|
||||
o1.SetNumber(88);
|
||||
o1.Number = 88;
|
||||
|
||||
Test.Assert(a.Push(o1));
|
||||
Test.Assert(a[0].NativeHandle == o1.NativeHandle);
|
||||
Test.Assert(a[0].GetNumber() == 88);
|
||||
Test.Assert(a[0].Number == 88);
|
||||
|
||||
var o2 = new Dummy.Numberwrapper();
|
||||
o2.SetNumber(44);
|
||||
o2.Number = 44;
|
||||
|
||||
a.DataSet(0, o2);
|
||||
Test.Assert(a[0].NativeHandle == o2.NativeHandle);
|
||||
Test.Assert(a[0].GetNumber() == 44);
|
||||
Test.Assert(a[0].Number == 44);
|
||||
|
||||
var o3 = new Dummy.Numberwrapper();
|
||||
o3.SetNumber(22);
|
||||
o3.Number = 22;
|
||||
|
||||
a[0] = o3;
|
||||
Test.Assert(a[0].NativeHandle == o3.NativeHandle);
|
||||
Test.Assert(a[0].GetNumber() == 22);
|
||||
Test.Assert(a[0].Number == 22);
|
||||
o3.Dispose();
|
||||
o2.Dispose();
|
||||
o1.Dispose();
|
||||
|
@ -758,24 +758,24 @@ class TestEinaArray
|
|||
Test.Assert(a.Count() == 0);
|
||||
|
||||
var o1 = new Dummy.Numberwrapper();
|
||||
o1.SetNumber(88);
|
||||
o1.Number = 88;
|
||||
Test.Assert(a.Push(o1));
|
||||
Test.Assert(a[0].NativeHandle == o1.NativeHandle);
|
||||
Test.Assert(a[0].GetNumber() == 88);
|
||||
Test.Assert(a[0].Number == 88);
|
||||
Test.Assert(a.Count() == 1);
|
||||
|
||||
var o2 = new Dummy.Numberwrapper();
|
||||
o2.SetNumber(44);
|
||||
o2.Number = 44;
|
||||
Test.Assert(a.Push(o2));
|
||||
Test.Assert(a[1].NativeHandle == o2.NativeHandle);
|
||||
Test.Assert(a[1].GetNumber() == 44);
|
||||
Test.Assert(a[1].Number == 44);
|
||||
Test.Assert(a.Count() == 2);
|
||||
|
||||
var o3 = new Dummy.Numberwrapper();
|
||||
o3.SetNumber(22);
|
||||
o3.Number = 22;
|
||||
Test.Assert(a.Push(o3));
|
||||
Test.Assert(a[2].NativeHandle == o3.NativeHandle);
|
||||
Test.Assert(a[2].GetNumber() == 22);
|
||||
Test.Assert(a[2].Number == 22);
|
||||
Test.Assert(a.Count() == 3);
|
||||
|
||||
o3.Dispose();
|
||||
|
@ -891,9 +891,9 @@ class TestEinaArray
|
|||
var a = new Dummy.Numberwrapper();
|
||||
var b = new Dummy.Numberwrapper();
|
||||
var c = new Dummy.Numberwrapper();
|
||||
a.SetNumber(88);
|
||||
b.SetNumber(44);
|
||||
c.SetNumber(22);
|
||||
a.Number = 88;
|
||||
b.Number = 44;
|
||||
c.Number = 22;
|
||||
var cmp = new Dummy.Numberwrapper[]{a, b, c};
|
||||
|
||||
var arr = new Eina.Array<Dummy.Numberwrapper>();
|
||||
|
@ -905,7 +905,7 @@ class TestEinaArray
|
|||
int i = 0;
|
||||
foreach (Dummy.Numberwrapper e in arr)
|
||||
{
|
||||
Test.AssertEquals(cmp[i].GetNumber(), e.GetNumber());
|
||||
Test.AssertEquals(cmp[i].Number, e.Number);
|
||||
Test.Assert(cmp[i].NativeHandle == e.NativeHandle);
|
||||
++i;
|
||||
}
|
||||
|
@ -1247,10 +1247,10 @@ class TestEinaInarray
|
|||
var a = new Eina.Inarray<Dummy.Numberwrapper>();
|
||||
Test.Assert(a.Handle != IntPtr.Zero);
|
||||
var o = new Dummy.Numberwrapper();
|
||||
o.SetNumber(88);
|
||||
o.Number = 88;
|
||||
Test.Assert(a.Push(o) == 0);
|
||||
Test.Assert(a[0].NativeHandle == o.NativeHandle);
|
||||
Test.Assert(a[0].GetNumber() == 88);
|
||||
Test.Assert(a[0].Number == 88);
|
||||
o.Dispose();
|
||||
a.Dispose();
|
||||
}
|
||||
|
@ -1280,11 +1280,11 @@ class TestEinaInarray
|
|||
var a = new Eina.Inarray<Dummy.Numberwrapper>();
|
||||
Test.Assert(a.Handle != IntPtr.Zero);
|
||||
var o = new Dummy.Numberwrapper();
|
||||
o.SetNumber(88);
|
||||
o.Number = 88;
|
||||
Test.Assert(a.Push(o) >= 0);
|
||||
var p = a.Pop();
|
||||
Test.Assert(p.NativeHandle == o.NativeHandle);
|
||||
Test.Assert(p.GetNumber() == 88);
|
||||
Test.Assert(p.Number == 88);
|
||||
Test.Assert(a.Count() == 0);
|
||||
o.Dispose();
|
||||
a.Dispose();
|
||||
|
@ -1326,26 +1326,26 @@ class TestEinaInarray
|
|||
Test.Assert(a.Handle != IntPtr.Zero);
|
||||
|
||||
var o1 = new Dummy.Numberwrapper();
|
||||
o1.SetNumber(88);
|
||||
o1.Number = 88;
|
||||
|
||||
Test.Assert(a.Push(o1) >= 0);
|
||||
Test.Assert(a[0].NativeHandle == o1.NativeHandle);
|
||||
Test.Assert(a[0].GetNumber() == 88);
|
||||
Test.Assert(a[0].Number == 88);
|
||||
|
||||
var o2 = new Dummy.Numberwrapper();
|
||||
o2.SetNumber(44);
|
||||
o2.Number = 44;
|
||||
|
||||
a.ReplaceAt(0, o2);
|
||||
Test.Assert(a[0].NativeHandle == o2.NativeHandle);
|
||||
Test.Assert(a[0].GetNumber() == 44);
|
||||
Test.Assert(a[0].Number == 44);
|
||||
Test.Assert(a.Count() == 1);
|
||||
|
||||
var o3 = new Dummy.Numberwrapper();
|
||||
o3.SetNumber(22);
|
||||
o3.Number = 22;
|
||||
|
||||
a[0] = o3;
|
||||
Test.Assert(a[0].NativeHandle == o3.NativeHandle);
|
||||
Test.Assert(a[0].GetNumber() == 22);
|
||||
Test.Assert(a[0].Number == 22);
|
||||
Test.Assert(a.Count() == 1);
|
||||
|
||||
o3.Dispose();
|
||||
|
@ -1396,24 +1396,24 @@ class TestEinaInarray
|
|||
Test.Assert(a.Count() == 0);
|
||||
|
||||
var o1 = new Dummy.Numberwrapper();
|
||||
o1.SetNumber(88);
|
||||
o1.Number = 88;
|
||||
Test.Assert(a.Push(o1) == 0);
|
||||
Test.Assert(a[0].NativeHandle == o1.NativeHandle);
|
||||
Test.Assert(a[0].GetNumber() == 88);
|
||||
Test.Assert(a[0].Number == 88);
|
||||
Test.Assert(a.Count() == 1);
|
||||
|
||||
var o2 = new Dummy.Numberwrapper();
|
||||
o2.SetNumber(44);
|
||||
o2.Number = 44;
|
||||
Test.Assert(a.Push(o2) == 1);
|
||||
Test.Assert(a[1].NativeHandle == o2.NativeHandle);
|
||||
Test.Assert(a[1].GetNumber() == 44);
|
||||
Test.Assert(a[1].Number == 44);
|
||||
Test.Assert(a.Count() == 2);
|
||||
|
||||
var o3 = new Dummy.Numberwrapper();
|
||||
o3.SetNumber(22);
|
||||
o3.Number = 22;
|
||||
Test.Assert(a.Push(o3) == 2);
|
||||
Test.Assert(a[2].NativeHandle == o3.NativeHandle);
|
||||
Test.Assert(a[2].GetNumber() == 22);
|
||||
Test.Assert(a[2].Number == 22);
|
||||
Test.Assert(a.Count() == 3);
|
||||
|
||||
o3.Dispose();
|
||||
|
@ -1495,9 +1495,9 @@ class TestEinaInarray
|
|||
var a = new Dummy.Numberwrapper();
|
||||
var b = new Dummy.Numberwrapper();
|
||||
var c = new Dummy.Numberwrapper();
|
||||
a.SetNumber(88);
|
||||
b.SetNumber(44);
|
||||
c.SetNumber(22);
|
||||
a.Number = 88;
|
||||
b.Number = 44;
|
||||
c.Number = 22;
|
||||
var cmp = new Dummy.Numberwrapper[]{a, b, c};
|
||||
|
||||
var arr = new Eina.Inarray<Dummy.Numberwrapper>();
|
||||
|
@ -1509,7 +1509,7 @@ class TestEinaInarray
|
|||
int i = 0;
|
||||
foreach (Dummy.Numberwrapper e in arr)
|
||||
{
|
||||
Test.AssertEquals(cmp[i].GetNumber(), e.GetNumber());
|
||||
Test.AssertEquals(cmp[i].Number, e.Number);
|
||||
Test.Assert(cmp[i].NativeHandle == e.NativeHandle);
|
||||
++i;
|
||||
}
|
||||
|
@ -1571,25 +1571,25 @@ class TestEinaList
|
|||
var lst = new Eina.List<Dummy.Numberwrapper>();
|
||||
|
||||
var o1 = new Dummy.Numberwrapper();
|
||||
o1.SetNumber(88);
|
||||
o1.Number = 88;
|
||||
|
||||
lst.Append(o1);
|
||||
Test.Assert(lst[0].NativeHandle == o1.NativeHandle);
|
||||
Test.Assert(lst[0].GetNumber() == 88);
|
||||
Test.Assert(lst[0].Number == 88);
|
||||
|
||||
var o2 = new Dummy.Numberwrapper();
|
||||
o2.SetNumber(44);
|
||||
o2.Number = 44;
|
||||
|
||||
lst.DataSet(0, o2);
|
||||
Test.Assert(lst[0].NativeHandle == o2.NativeHandle);
|
||||
Test.Assert(lst[0].GetNumber() == 44);
|
||||
Test.Assert(lst[0].Number == 44);
|
||||
|
||||
var o3 = new Dummy.Numberwrapper();
|
||||
o3.SetNumber(22);
|
||||
o3.Number = 22;
|
||||
|
||||
lst[0] = o3;
|
||||
Test.Assert(lst[0].NativeHandle == o3.NativeHandle);
|
||||
Test.Assert(lst[0].GetNumber() == 22);
|
||||
Test.Assert(lst[0].Number == 22);
|
||||
o3.Dispose();
|
||||
o2.Dispose();
|
||||
o1.Dispose();
|
||||
|
@ -1651,24 +1651,24 @@ class TestEinaList
|
|||
Test.Assert(lst.Count() == 0);
|
||||
|
||||
var o1 = new Dummy.Numberwrapper();
|
||||
o1.SetNumber(88);
|
||||
o1.Number = 88;
|
||||
lst.Append(o1);
|
||||
Test.Assert(lst[0].NativeHandle == o1.NativeHandle);
|
||||
Test.Assert(lst[0].GetNumber() == 88);
|
||||
Test.Assert(lst[0].Number == 88);
|
||||
Test.Assert(lst.Count() == 1);
|
||||
|
||||
var o2 = new Dummy.Numberwrapper();
|
||||
o2.SetNumber(44);
|
||||
o2.Number = 44;
|
||||
lst.Append(o2);
|
||||
Test.Assert(lst[1].NativeHandle == o2.NativeHandle);
|
||||
Test.Assert(lst[1].GetNumber() == 44);
|
||||
Test.Assert(lst[1].Number == 44);
|
||||
Test.Assert(lst.Count() == 2);
|
||||
|
||||
var o3 = new Dummy.Numberwrapper();
|
||||
o3.SetNumber(22);
|
||||
o3.Number = 22;
|
||||
lst.Append(o3);
|
||||
Test.Assert(lst[2].NativeHandle == o3.NativeHandle);
|
||||
Test.Assert(lst[2].GetNumber() == 22);
|
||||
Test.Assert(lst[2].Number == 22);
|
||||
Test.Assert(lst.Count() == 3);
|
||||
o3.Dispose();
|
||||
o2.Dispose();
|
||||
|
@ -1779,24 +1779,24 @@ class TestEinaList
|
|||
Test.Assert(lst.Count() == 0);
|
||||
|
||||
var o1 = new Dummy.Numberwrapper();
|
||||
o1.SetNumber(88);
|
||||
o1.Number = 88;
|
||||
lst.Prepend(o1);
|
||||
Test.Assert(lst[0].NativeHandle == o1.NativeHandle);
|
||||
Test.Assert(lst[0].GetNumber() == 88);
|
||||
Test.Assert(lst[0].Number == 88);
|
||||
Test.Assert(lst.Count() == 1);
|
||||
|
||||
var o2 = new Dummy.Numberwrapper();
|
||||
o2.SetNumber(44);
|
||||
o2.Number = 44;
|
||||
lst.Prepend(o2);
|
||||
Test.Assert(lst[0].NativeHandle == o2.NativeHandle);
|
||||
Test.Assert(lst[0].GetNumber() == 44);
|
||||
Test.Assert(lst[0].Number == 44);
|
||||
Test.Assert(lst.Count() == 2);
|
||||
|
||||
var o3 = new Dummy.Numberwrapper();
|
||||
o3.SetNumber(22);
|
||||
o3.Number = 22;
|
||||
lst.Prepend(o3);
|
||||
Test.Assert(lst[0].NativeHandle == o3.NativeHandle);
|
||||
Test.Assert(lst[0].GetNumber() == 22);
|
||||
Test.Assert(lst[0].Number == 22);
|
||||
Test.Assert(lst.Count() == 3);
|
||||
|
||||
o3.Dispose();
|
||||
|
@ -2025,9 +2025,9 @@ class TestEinaList
|
|||
var a = new Dummy.Numberwrapper();
|
||||
var b = new Dummy.Numberwrapper();
|
||||
var c = new Dummy.Numberwrapper();
|
||||
a.SetNumber(88);
|
||||
b.SetNumber(44);
|
||||
c.SetNumber(22);
|
||||
a.Number = 88;
|
||||
b.Number = 44;
|
||||
c.Number = 22;
|
||||
var cmp = new Dummy.Numberwrapper[]{a, b, c};
|
||||
|
||||
var lst = new Eina.List<Dummy.Numberwrapper>();
|
||||
|
@ -2038,7 +2038,7 @@ class TestEinaList
|
|||
int i = 0;
|
||||
foreach (Dummy.Numberwrapper e in lst)
|
||||
{
|
||||
Test.AssertEquals(cmp[i].GetNumber(), e.GetNumber());
|
||||
Test.AssertEquals(cmp[i].Number, e.Number);
|
||||
Test.Assert(cmp[i].NativeHandle == e.NativeHandle);
|
||||
++i;
|
||||
}
|
||||
|
@ -2366,25 +2366,25 @@ class TestEinaInlist
|
|||
var lst = new Eina.Inlist<Dummy.Numberwrapper>();
|
||||
|
||||
var o1 = new Dummy.Numberwrapper();
|
||||
o1.SetNumber(88);
|
||||
o1.Number = 88;
|
||||
|
||||
lst.Append(o1);
|
||||
Test.Assert(lst[0].NativeHandle == o1.NativeHandle);
|
||||
Test.Assert(lst[0].GetNumber() == 88);
|
||||
Test.Assert(lst[0].Number == 88);
|
||||
|
||||
var o2 = new Dummy.Numberwrapper();
|
||||
o2.SetNumber(44);
|
||||
o2.Number = 44;
|
||||
|
||||
lst.DataSet(0, o2);
|
||||
Test.Assert(lst[0].NativeHandle == o2.NativeHandle);
|
||||
Test.Assert(lst[0].GetNumber() == 44);
|
||||
Test.Assert(lst[0].Number == 44);
|
||||
|
||||
var o3 = new Dummy.Numberwrapper();
|
||||
o3.SetNumber(22);
|
||||
o3.Number = 22;
|
||||
|
||||
lst[0] = o3;
|
||||
Test.Assert(lst[0].NativeHandle == o3.NativeHandle);
|
||||
Test.Assert(lst[0].GetNumber() == 22);
|
||||
Test.Assert(lst[0].Number == 22);
|
||||
|
||||
Test.Assert(lst.Count() == 1);
|
||||
o3.Dispose();
|
||||
|
@ -2432,24 +2432,24 @@ class TestEinaInlist
|
|||
Test.Assert(lst.Count() == 0);
|
||||
|
||||
var o1 = new Dummy.Numberwrapper();
|
||||
o1.SetNumber(88);
|
||||
o1.Number = 88;
|
||||
lst.Append(o1);
|
||||
Test.Assert(lst[0].NativeHandle == o1.NativeHandle);
|
||||
Test.Assert(lst[0].GetNumber() == 88);
|
||||
Test.Assert(lst[0].Number == 88);
|
||||
Test.Assert(lst.Count() == 1);
|
||||
|
||||
var o2 = new Dummy.Numberwrapper();
|
||||
o2.SetNumber(44);
|
||||
o2.Number = 44;
|
||||
lst.Append(o2);
|
||||
Test.Assert(lst[1].NativeHandle == o2.NativeHandle);
|
||||
Test.Assert(lst[1].GetNumber() == 44);
|
||||
Test.Assert(lst[1].Number == 44);
|
||||
Test.Assert(lst.Count() == 2);
|
||||
|
||||
var o3 = new Dummy.Numberwrapper();
|
||||
o3.SetNumber(22);
|
||||
o3.Number = 22;
|
||||
lst.Append(o3);
|
||||
Test.Assert(lst[2].NativeHandle == o3.NativeHandle);
|
||||
Test.Assert(lst[2].GetNumber() == 22);
|
||||
Test.Assert(lst[2].Number == 22);
|
||||
Test.Assert(lst.Count() == 3);
|
||||
o3.Dispose();
|
||||
o2.Dispose();
|
||||
|
@ -2528,24 +2528,24 @@ class TestEinaInlist
|
|||
Test.Assert(lst.Count() == 0);
|
||||
|
||||
var o1 = new Dummy.Numberwrapper();
|
||||
o1.SetNumber(88);
|
||||
o1.Number = 88;
|
||||
lst.Prepend(o1);
|
||||
Test.Assert(lst[0].NativeHandle == o1.NativeHandle);
|
||||
Test.Assert(lst[0].GetNumber() == 88);
|
||||
Test.Assert(lst[0].Number == 88);
|
||||
Test.Assert(lst.Count() == 1);
|
||||
|
||||
var o2 = new Dummy.Numberwrapper();
|
||||
o2.SetNumber(44);
|
||||
o2.Number = 44;
|
||||
lst.Prepend(o2);
|
||||
Test.Assert(lst[0].NativeHandle == o2.NativeHandle);
|
||||
Test.Assert(lst[0].GetNumber() == 44);
|
||||
Test.Assert(lst[0].Number == 44);
|
||||
Test.Assert(lst.Count() == 2);
|
||||
|
||||
var o3 = new Dummy.Numberwrapper();
|
||||
o3.SetNumber(22);
|
||||
o3.Number = 22;
|
||||
lst.Prepend(o3);
|
||||
Test.Assert(lst[0].NativeHandle == o3.NativeHandle);
|
||||
Test.Assert(lst[0].GetNumber() == 22);
|
||||
Test.Assert(lst[0].Number == 22);
|
||||
Test.Assert(lst.Count() == 3);
|
||||
o3.Dispose();
|
||||
o2.Dispose();
|
||||
|
@ -2590,9 +2590,9 @@ class TestEinaInlist
|
|||
var a = new Dummy.Numberwrapper();
|
||||
var b = new Dummy.Numberwrapper();
|
||||
var c = new Dummy.Numberwrapper();
|
||||
a.SetNumber(88);
|
||||
b.SetNumber(44);
|
||||
c.SetNumber(22);
|
||||
a.Number = 88;
|
||||
b.Number = 44;
|
||||
c.Number = 22;
|
||||
var cmp = new Dummy.Numberwrapper[]{a, b, c};
|
||||
|
||||
var lst = new Eina.Inlist<Dummy.Numberwrapper>();
|
||||
|
@ -2603,7 +2603,7 @@ class TestEinaInlist
|
|||
int i = 0;
|
||||
foreach (Dummy.Numberwrapper e in lst)
|
||||
{
|
||||
Test.AssertEquals(cmp[i].GetNumber(), e.GetNumber());
|
||||
Test.AssertEquals(cmp[i].Number, e.Number);
|
||||
Test.Assert(cmp[i].NativeHandle == e.NativeHandle);
|
||||
++i;
|
||||
}
|
||||
|
@ -2690,17 +2690,17 @@ class TestEinaHash
|
|||
|
||||
hsh[a] = aa;
|
||||
Test.Assert(hsh[a].NativeHandle == aa.NativeHandle);
|
||||
Test.Assert(hsh[a].GetNumber() == aa.GetNumber());
|
||||
Test.Assert(hsh[a].Number == aa.Number);
|
||||
Test.Assert(hsh.Count == 1);
|
||||
|
||||
hsh[b] = bb;
|
||||
Test.Assert(hsh[b].NativeHandle == bb.NativeHandle);
|
||||
Test.Assert(hsh[b].GetNumber() == bb.GetNumber());
|
||||
Test.Assert(hsh[b].Number == bb.Number);
|
||||
Test.Assert(hsh.Count == 2);
|
||||
|
||||
hsh[c] = cc;
|
||||
Test.Assert(hsh[c].NativeHandle == cc.NativeHandle);
|
||||
Test.Assert(hsh[c].GetNumber() == cc.GetNumber());
|
||||
Test.Assert(hsh[c].Number == cc.Number);
|
||||
|
||||
Test.Assert(hsh.Count == 3);
|
||||
|
||||
|
@ -2810,17 +2810,17 @@ class TestEinaHash
|
|||
hsh[b] = bb;
|
||||
hsh[c] = cc;
|
||||
|
||||
dct[a.GetNumber()] = aa;
|
||||
dct[b.GetNumber()] = bb;
|
||||
dct[c.GetNumber()] = cc;
|
||||
dct[a.Number] = aa;
|
||||
dct[b.Number] = bb;
|
||||
dct[c.Number] = cc;
|
||||
|
||||
int count = 0;
|
||||
|
||||
foreach (KeyValuePair<Dummy.Numberwrapper, Dummy.Numberwrapper> kvp in hsh)
|
||||
{
|
||||
Test.Assert(dct[kvp.Key.GetNumber()].NativeHandle == kvp.Value.NativeHandle);
|
||||
Test.Assert(dct[kvp.Key.GetNumber()].GetNumber() == kvp.Value.GetNumber());
|
||||
dct.Remove(kvp.Key.GetNumber());
|
||||
Test.Assert(dct[kvp.Key.Number].NativeHandle == kvp.Value.NativeHandle);
|
||||
Test.Assert(dct[kvp.Key.Number].Number == kvp.Value.Number);
|
||||
dct.Remove(kvp.Key.Number);
|
||||
++count;
|
||||
}
|
||||
|
||||
|
@ -3121,11 +3121,11 @@ class TestEinaHash
|
|||
Test.Assert(t.EinaHashObjIn(hsh, nwk1, nwv1, out nwk2, out nwv2));
|
||||
Test.Assert(hsh.Own);
|
||||
Test.Assert(hsh[nwk1].NativeHandle == nwv1.NativeHandle);
|
||||
Test.Assert(hsh[nwk1].GetNumber() == nwv1.GetNumber());
|
||||
Test.Assert(hsh[nwk1].GetNumber() == 222);
|
||||
Test.Assert(hsh[nwk1].Number == nwv1.Number);
|
||||
Test.Assert(hsh[nwk1].Number == 222);
|
||||
Test.Assert(hsh[nwk2].NativeHandle == nwv2.NativeHandle);
|
||||
Test.Assert(hsh[nwk2].GetNumber() == nwv2.GetNumber());
|
||||
Test.Assert(hsh[nwk2].GetNumber() == 444);
|
||||
Test.Assert(hsh[nwk2].Number == nwv2.Number);
|
||||
Test.Assert(hsh[nwk2].Number == 444);
|
||||
nwk1.Dispose();
|
||||
nwk2.Dispose();
|
||||
nwv1.Dispose();
|
||||
|
@ -3147,11 +3147,11 @@ class TestEinaHash
|
|||
Test.Assert(t.EinaHashObjInOwn(hsh, nwk1, nwv1, out nwk2, out nwv2));
|
||||
Test.Assert(!hsh.Own);
|
||||
Test.Assert(hsh[nwk1].NativeHandle == nwv1.NativeHandle);
|
||||
Test.Assert(hsh[nwk1].GetNumber() == nwv1.GetNumber());
|
||||
Test.Assert(hsh[nwk1].GetNumber() == 222);
|
||||
Test.Assert(hsh[nwk1].Number == nwv1.Number);
|
||||
Test.Assert(hsh[nwk1].Number == 222);
|
||||
Test.Assert(hsh[nwk2].NativeHandle == nwv2.NativeHandle);
|
||||
Test.Assert(hsh[nwk2].GetNumber() == nwv2.GetNumber());
|
||||
Test.Assert(hsh[nwk2].GetNumber() == 444);
|
||||
Test.Assert(hsh[nwk2].Number == nwv2.Number);
|
||||
Test.Assert(hsh[nwk2].Number == 444);
|
||||
hsh.Dispose();
|
||||
Test.Assert(hsh.Handle == IntPtr.Zero);
|
||||
Test.Assert(t.CheckEinaHashObjInOwn(nwk1, nwv1, nwk2, nwv2));
|
||||
|
@ -3171,8 +3171,8 @@ class TestEinaHash
|
|||
Test.Assert(t.EinaHashObjOut(out hsh, out nwk1, out nwv1));
|
||||
Test.Assert(!hsh.Own);
|
||||
Test.Assert(hsh[nwk1].NativeHandle == nwv1.NativeHandle);
|
||||
Test.Assert(hsh[nwk1].GetNumber() == nwv1.GetNumber());
|
||||
Test.Assert(hsh[nwk1].GetNumber() == 222);
|
||||
Test.Assert(hsh[nwk1].Number == nwv1.Number);
|
||||
Test.Assert(hsh[nwk1].Number == 222);
|
||||
Dummy.Numberwrapper nwk2 = NW(44);
|
||||
Dummy.Numberwrapper nwv2 = NW(444);
|
||||
hsh[nwk2] = nwv2;
|
||||
|
@ -3195,8 +3195,8 @@ class TestEinaHash
|
|||
Test.Assert(t.EinaHashObjOutOwn(out hsh, out nwk1, out nwv1));
|
||||
Test.Assert(hsh.Own);
|
||||
Test.Assert(hsh[nwk1].NativeHandle == nwv1.NativeHandle);
|
||||
Test.Assert(hsh[nwk1].GetNumber() == nwv1.GetNumber());
|
||||
Test.Assert(hsh[nwk1].GetNumber() == 222);
|
||||
Test.Assert(hsh[nwk1].Number == nwv1.Number);
|
||||
Test.Assert(hsh[nwk1].Number == 222);
|
||||
Dummy.Numberwrapper nwk2 = NW(44);
|
||||
Dummy.Numberwrapper nwv2 = NW(444);
|
||||
hsh[nwk2] = nwv2;
|
||||
|
@ -3218,8 +3218,8 @@ class TestEinaHash
|
|||
var hsh = t.EinaHashObjReturn(out nwk1, out nwv1);
|
||||
Test.Assert(!hsh.Own);
|
||||
Test.Assert(hsh[nwk1].NativeHandle == nwv1.NativeHandle);
|
||||
Test.Assert(hsh[nwk1].GetNumber() == nwv1.GetNumber());
|
||||
Test.Assert(hsh[nwk1].GetNumber() == 222);
|
||||
Test.Assert(hsh[nwk1].Number == nwv1.Number);
|
||||
Test.Assert(hsh[nwk1].Number == 222);
|
||||
Dummy.Numberwrapper nwk2 = NW(44);
|
||||
Dummy.Numberwrapper nwv2 = NW(444);
|
||||
hsh[nwk2] = nwv2;
|
||||
|
@ -3241,8 +3241,8 @@ class TestEinaHash
|
|||
var hsh = t.EinaHashObjReturnOwn(out nwk1, out nwv1);
|
||||
Test.Assert(hsh.Own);
|
||||
Test.Assert(hsh[nwk1].NativeHandle == nwv1.NativeHandle);
|
||||
Test.Assert(hsh[nwk1].GetNumber() == nwv1.GetNumber());
|
||||
Test.Assert(hsh[nwk1].GetNumber() == 222);
|
||||
Test.Assert(hsh[nwk1].Number == nwv1.Number);
|
||||
Test.Assert(hsh[nwk1].Number == 222);
|
||||
Dummy.Numberwrapper nwk2 = NW(44);
|
||||
Dummy.Numberwrapper nwv2 = NW(444);
|
||||
hsh[nwk2] = nwv2;
|
||||
|
@ -3395,7 +3395,7 @@ class TestEinaIterator
|
|||
foreach (Dummy.Numberwrapper e in itr)
|
||||
{
|
||||
Test.Assert(e.NativeHandle == base_objs[idx].NativeHandle);
|
||||
Test.Assert(e.GetNumber() == base_objs[idx].GetNumber());
|
||||
Test.Assert(e.Number == base_objs[idx].Number);
|
||||
++idx;
|
||||
}
|
||||
Test.AssertEquals(idx, base_objs.Length);
|
||||
|
@ -3561,7 +3561,7 @@ class TestEinaIterator
|
|||
foreach (Dummy.Numberwrapper e in itr)
|
||||
{
|
||||
Test.Assert(e.NativeHandle == base_objs[idx].NativeHandle);
|
||||
Test.Assert(e.GetNumber() == base_objs[idx].GetNumber());
|
||||
Test.Assert(e.Number == base_objs[idx].Number);
|
||||
++idx;
|
||||
}
|
||||
Test.AssertEquals(idx, base_objs.Length);
|
||||
|
@ -3903,19 +3903,19 @@ class TestEinaIterator
|
|||
hsh[a] = aa;
|
||||
hsh[b] = bb;
|
||||
hsh[c] = cc;
|
||||
dct[a.GetNumber()] = a;
|
||||
dct[b.GetNumber()] = b;
|
||||
dct[c.GetNumber()] = c;
|
||||
dct[a.Number] = a;
|
||||
dct[b.Number] = b;
|
||||
dct[c.Number] = c;
|
||||
|
||||
var itr = hsh.Keys();
|
||||
|
||||
int idx = 0;
|
||||
foreach (Dummy.Numberwrapper e in itr)
|
||||
{
|
||||
Test.Assert(dct[e.GetNumber()] != null);
|
||||
Test.Assert(dct[e.GetNumber()].NativeHandle == e.NativeHandle);
|
||||
Test.Assert(dct[e.GetNumber()].GetNumber() == e.GetNumber());
|
||||
dct.Remove(e.GetNumber());
|
||||
Test.Assert(dct[e.Number] != null);
|
||||
Test.Assert(dct[e.Number].NativeHandle == e.NativeHandle);
|
||||
Test.Assert(dct[e.Number].Number == e.Number);
|
||||
dct.Remove(e.Number);
|
||||
++idx;
|
||||
}
|
||||
Test.AssertEquals(dct.Count, 0);
|
||||
|
@ -3939,19 +3939,19 @@ class TestEinaIterator
|
|||
hsh[a] = aa;
|
||||
hsh[b] = bb;
|
||||
hsh[c] = cc;
|
||||
dct[aa.GetNumber()] = aa;
|
||||
dct[bb.GetNumber()] = bb;
|
||||
dct[cc.GetNumber()] = cc;
|
||||
dct[aa.Number] = aa;
|
||||
dct[bb.Number] = bb;
|
||||
dct[cc.Number] = cc;
|
||||
|
||||
var itr = hsh.Values();
|
||||
|
||||
int idx = 0;
|
||||
foreach (Dummy.Numberwrapper e in itr)
|
||||
{
|
||||
Test.Assert(dct[e.GetNumber()] != null);
|
||||
Test.Assert(dct[e.GetNumber()].NativeHandle == e.NativeHandle);
|
||||
Test.Assert(dct[e.GetNumber()].GetNumber() == e.GetNumber());
|
||||
dct.Remove(e.GetNumber());
|
||||
Test.Assert(dct[e.Number] != null);
|
||||
Test.Assert(dct[e.Number].NativeHandle == e.NativeHandle);
|
||||
Test.Assert(dct[e.Number].Number == e.Number);
|
||||
dct.Remove(e.Number);
|
||||
++idx;
|
||||
}
|
||||
Test.AssertEquals(dct.Count, 0);
|
||||
|
@ -4392,7 +4392,7 @@ class TestEinaIterator
|
|||
int idx = 0;
|
||||
foreach (Dummy.Numberwrapper e in itr)
|
||||
{
|
||||
Test.AssertEquals(e.GetNumber(), base_seq_obj[idx].GetNumber());
|
||||
Test.AssertEquals(e.Number, base_seq_obj[idx].Number);
|
||||
++idx;
|
||||
}
|
||||
Test.AssertEquals(idx, base_seq_obj.Length);
|
||||
|
@ -4413,7 +4413,7 @@ class TestEinaIterator
|
|||
int idx = 0;
|
||||
foreach (Dummy.Numberwrapper e in itr)
|
||||
{
|
||||
Test.AssertEquals(e.GetNumber(), base_seq_obj[idx].GetNumber());
|
||||
Test.AssertEquals(e.Number, base_seq_obj[idx].Number);
|
||||
++idx;
|
||||
}
|
||||
Test.AssertEquals(idx, base_seq_obj.Length);
|
||||
|
@ -4432,7 +4432,7 @@ class TestEinaIterator
|
|||
int idx = 0;
|
||||
foreach (Dummy.Numberwrapper e in itr)
|
||||
{
|
||||
Test.AssertEquals(e.GetNumber(), base_seq_obj[idx].GetNumber());
|
||||
Test.AssertEquals(e.Number, base_seq_obj[idx].Number);
|
||||
++idx;
|
||||
}
|
||||
Test.AssertEquals(idx, base_seq_obj.Length);
|
||||
|
@ -4452,7 +4452,7 @@ class TestEinaIterator
|
|||
int idx = 0;
|
||||
foreach (Dummy.Numberwrapper e in itr)
|
||||
{
|
||||
Test.AssertEquals(e.GetNumber(), base_seq_obj[idx].GetNumber());
|
||||
Test.AssertEquals(e.Number, base_seq_obj[idx].Number);
|
||||
++idx;
|
||||
}
|
||||
Test.AssertEquals(idx, base_seq_obj.Length);
|
||||
|
|
|
@ -49,7 +49,7 @@ public static class BaseData
|
|||
public static Dummy.Numberwrapper NW(int n)
|
||||
{
|
||||
var nw = new Dummy.Numberwrapper();
|
||||
nw.SetNumber(n);
|
||||
nw.Number = n;
|
||||
return nw;
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,9 @@ public static class BaseData
|
|||
var a = new Dummy.Numberwrapper();
|
||||
var b = new Dummy.Numberwrapper();
|
||||
var c = new Dummy.Numberwrapper();
|
||||
a.SetNumber(0x0);
|
||||
b.SetNumber(0x2A);
|
||||
c.SetNumber(0x42);
|
||||
a.Number = 0x0;
|
||||
b.Number = 0x2A;
|
||||
c.Number = 0x42;
|
||||
return new Dummy.Numberwrapper[]{a, b, c};
|
||||
}
|
||||
|
||||
|
@ -69,9 +69,9 @@ public static class BaseData
|
|||
var a = new Dummy.Numberwrapper();
|
||||
var b = new Dummy.Numberwrapper();
|
||||
var c = new Dummy.Numberwrapper();
|
||||
a.SetNumber(42);
|
||||
b.SetNumber(43);
|
||||
c.SetNumber(33);
|
||||
a.Number = 42;
|
||||
b.Number = 43;
|
||||
c.Number = 33;
|
||||
return new Dummy.Numberwrapper[]{a, b, c};
|
||||
}
|
||||
|
||||
|
@ -83,12 +83,12 @@ public static class BaseData
|
|||
var d = new Dummy.Numberwrapper();
|
||||
var e = new Dummy.Numberwrapper();
|
||||
var f = new Dummy.Numberwrapper();
|
||||
a.SetNumber(0x0);
|
||||
b.SetNumber(0x2A);
|
||||
c.SetNumber(0x42);
|
||||
d.SetNumber(42);
|
||||
e.SetNumber(43);
|
||||
f.SetNumber(33);
|
||||
a.Number = 0x0;
|
||||
b.Number = 0x2A;
|
||||
c.Number = 0x42;
|
||||
d.Number = 42;
|
||||
e.Number = 43;
|
||||
f.Number = 33;
|
||||
return new Dummy.Numberwrapper[]{a, b, c, d, e, f};
|
||||
}
|
||||
|
||||
|
@ -102,8 +102,8 @@ public static class BaseData
|
|||
Test.Assert(a.Length == b.Length, "Different lenght", line, file, member);
|
||||
for (int i = 0; i < a.Length; ++i)
|
||||
{
|
||||
int av = a[i].GetNumber();
|
||||
int bv = b[i].GetNumber();
|
||||
int av = a[i].Number;
|
||||
int bv = b[i].Number;
|
||||
Test.Assert(av == bv, $"Different values for element [{i}]: {av} == {bv}", line, file, member);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,8 +149,8 @@ class TestEoNames
|
|||
var obj = new Dummy.TestObject();
|
||||
|
||||
string name = "Dummy";
|
||||
obj.SetName(name);
|
||||
Test.AssertEquals(name, obj.GetName());
|
||||
obj.Name = name;
|
||||
Test.AssertEquals(name, obj.Name);
|
||||
obj.Dispose();
|
||||
}
|
||||
}
|
||||
|
@ -162,9 +162,9 @@ class TestEoParent
|
|||
var parent = new Dummy.TestObject(null);
|
||||
var child = new Dummy.TestObject(parent);
|
||||
|
||||
Test.AssertEquals(parent, child.GetParent());
|
||||
Test.AssertEquals(parent, child.Parent);
|
||||
|
||||
var parent_retrieved = child.GetParent() as Dummy.TestObject;
|
||||
var parent_retrieved = child.Parent as Dummy.TestObject;
|
||||
Test.AssertEquals(parent, parent_retrieved);
|
||||
child.Dispose();
|
||||
parent.Dispose();
|
||||
|
@ -175,9 +175,9 @@ class TestEoParent
|
|||
Dummy.Numberwrapper parent = new Dummy.Numberwrapper(null);
|
||||
var child = new Dummy.TestObject(parent);
|
||||
|
||||
Test.AssertEquals(parent, child.GetParent());
|
||||
Test.AssertEquals(parent, child.Parent);
|
||||
|
||||
Dummy.Numberwrapper parent_retrieved = child.GetParent() as Dummy.Numberwrapper;
|
||||
Dummy.Numberwrapper parent_retrieved = child.Parent as Dummy.Numberwrapper;
|
||||
Test.AssertEquals(parent, parent_retrieved);
|
||||
child.Dispose();
|
||||
parent.Dispose();
|
||||
|
@ -195,9 +195,9 @@ class TestEoParent
|
|||
var parent = new Derived(null);
|
||||
var child = new Derived(parent);
|
||||
|
||||
Test.AssertEquals(parent, child.GetParent());
|
||||
Test.AssertEquals(parent, child.Parent);
|
||||
|
||||
var parent_from_cast = child.GetParent() as Derived;
|
||||
var parent_from_cast = child.Parent as Derived;
|
||||
Test.AssertEquals(parent, parent_from_cast);
|
||||
child.Dispose();
|
||||
parent.Dispose();
|
||||
|
@ -209,15 +209,15 @@ class TestKlassMethods
|
|||
public static void basic_class_method()
|
||||
{
|
||||
int reference = 0xbeef;
|
||||
Dummy.TestObject.SetKlassProp(reference);
|
||||
Test.AssertEquals(reference, Dummy.TestObject.GetKlassProp());
|
||||
Dummy.TestObject.KlassProp = reference;
|
||||
Test.AssertEquals(reference, Dummy.TestObject.KlassProp);
|
||||
}
|
||||
|
||||
public static void inherited_class_method()
|
||||
{
|
||||
int reference = 0xdead;
|
||||
Dummy.Child.SetKlassProp(reference);
|
||||
Test.AssertEquals(reference, Dummy.Child.GetKlassProp());
|
||||
Dummy.Child.KlassProp = reference;
|
||||
Test.AssertEquals(reference, Dummy.Child.KlassProp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -559,7 +559,7 @@ class TestConstructors
|
|||
#else
|
||||
var obj = new Dummy.Child(null, a, b);
|
||||
#endif
|
||||
Test.Assert(!obj.GetIfaceWasSet());
|
||||
Test.Assert(!obj.IfaceWasSet);
|
||||
obj.Dispose();
|
||||
}
|
||||
}
|
||||
|
@ -586,7 +586,7 @@ class TestProvider
|
|||
var obj = new Dummy.TestObject();
|
||||
Dummy.Numberwrapper provider = obj.FindProvider(typeof(Dummy.Numberwrapper)) as Dummy.Numberwrapper;
|
||||
Test.AssertEquals(provider.GetType(), typeof(Dummy.Numberwrapper));
|
||||
Test.AssertEquals(provider.GetNumber(), 1999);
|
||||
Test.AssertEquals(provider.Number, 1999);
|
||||
obj.Dispose();
|
||||
}
|
||||
|
||||
|
@ -685,16 +685,16 @@ class TestProtectedInterfaceMembers
|
|||
{
|
||||
var type = typeof(Dummy.ITestIface);
|
||||
var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance);
|
||||
var properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
||||
|
||||
// Fully protected property
|
||||
Test.AssertNull(methods.SingleOrDefault(m => m.Name == "GetProtectedProp"));
|
||||
Test.AssertNull(methods.SingleOrDefault(m => m.Name == "SetProtectedProp"));
|
||||
|
||||
// Partially protected property
|
||||
Test.AssertNotNull(methods.SingleOrDefault(m => m.Name == "GetPublicGetterPrivateSetter"));
|
||||
Test.AssertNotNull(properties.SingleOrDefault(m => m.Name == "PublicGetterPrivateSetter"));
|
||||
Test.AssertNull(methods.SingleOrDefault(m => m.Name == "SetPublicGetterPrivateSetter"));
|
||||
|
||||
var properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
||||
Test.AssertNull(properties.SingleOrDefault(m => m.Name == "ProtectedProp"));
|
||||
Test.AssertNotNull(properties.SingleOrDefault(m => m.Name == "PublicGetterPrivateSetter"));
|
||||
}
|
||||
|
@ -703,15 +703,16 @@ class TestProtectedInterfaceMembers
|
|||
{
|
||||
var type = typeof(Dummy.TestObject);
|
||||
|
||||
// Fully protected property
|
||||
var protected_methods = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).Where(m => m.IsFamily);
|
||||
Test.AssertNotNull(protected_methods.SingleOrDefault(m => m.Name == "GetProtectedProp"));
|
||||
Test.AssertNotNull(protected_methods.SingleOrDefault(m => m.Name == "SetProtectedProp"));
|
||||
// Fully internal property
|
||||
var internal_methods = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).Where(m => m.IsAssembly);
|
||||
Test.AssertNotNull(internal_methods.SingleOrDefault(m => m.Name == "GetProtectedProp"));
|
||||
Test.AssertNotNull(internal_methods.SingleOrDefault(m => m.Name == "SetProtectedProp"));
|
||||
|
||||
// Partially protected property
|
||||
var public_methods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance);
|
||||
Test.AssertNotNull(public_methods.SingleOrDefault(m => m.Name == "GetPublicGetterPrivateSetter"));
|
||||
Test.AssertNotNull(protected_methods.SingleOrDefault(m => m.Name == "SetPublicGetterPrivateSetter"));
|
||||
Test.AssertNull(public_methods.SingleOrDefault(m => m.Name == "GetPublicGetterPrivateSetter"));
|
||||
Test.AssertNotNull(internal_methods.SingleOrDefault(m => m.Name == "GetPublicGetterPrivateSetter"));
|
||||
Test.AssertNotNull(internal_methods.SingleOrDefault(m => m.Name == "SetPublicGetterPrivateSetter"));
|
||||
|
||||
var protected_properties = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
var prop = protected_properties.SingleOrDefault(m => m.Name == "ProtectedProp");
|
||||
|
|
|
@ -30,7 +30,7 @@ class TestEoEvents
|
|||
Efl.Object obj = sender as Efl.Object;
|
||||
if (obj != null)
|
||||
{
|
||||
obj.SetName("loop_called");
|
||||
obj.Name = "loop_called";
|
||||
correct_sender = true;
|
||||
}
|
||||
|
||||
|
@ -44,18 +44,18 @@ class TestEoEvents
|
|||
public static void idle_event()
|
||||
{
|
||||
Efl.Loop loop = Efl.App.AppMain;
|
||||
loop.SetName("loop");
|
||||
loop.Name = "loop";
|
||||
TestEoEvents listener = new TestEoEvents();
|
||||
listener.loop = loop;
|
||||
loop.IdleEvent += listener.callback;
|
||||
|
||||
Test.Assert(!listener.called);
|
||||
Test.Assert(!listener.correct_sender);
|
||||
Test.AssertEquals("loop", loop.GetName());
|
||||
Test.AssertEquals("loop", loop.Name);
|
||||
loop.Begin();
|
||||
Test.Assert(listener.called);
|
||||
Test.Assert(listener.correct_sender);
|
||||
Test.AssertEquals("loop_called", loop.GetName());
|
||||
Test.AssertEquals("loop_called", loop.Name);
|
||||
|
||||
loop.IdleEvent -= listener.callback;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public static class TestModel {
|
|||
var veggies = CreateModel(loop);
|
||||
|
||||
var model = new Efl.GenericModel<VeggieViewModel>(veggies, loop);
|
||||
Test.AssertEquals(3, (int)model.GetChildrenCount());
|
||||
Test.AssertEquals(3, (int)model.ChildrenCount);
|
||||
|
||||
VeggieViewModel r2 = await model.GetAtAsync(1).ConfigureAwait(false);
|
||||
Test.AssertEquals(r2.Name, "Romaine Lettuce");
|
||||
|
|
|
@ -51,9 +51,9 @@ public static class TestParts
|
|||
var p1 = t.OnePart;
|
||||
var p2 = t.TwoPart;
|
||||
Test.Assert(p1 is Dummy.TestObject);
|
||||
Test.AssertEquals("part_one", p1.GetName());
|
||||
Test.AssertEquals("part_one", p1.Name);
|
||||
Test.Assert(p2 is Dummy.TestObject);
|
||||
Test.AssertEquals("part_two", p2.GetName());
|
||||
Test.AssertEquals("part_two", p2.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,9 +97,9 @@ public static class TestNamedParts
|
|||
var p1 = obj.GetPart("one");
|
||||
var p2 = obj.GetPart("two");
|
||||
Test.Assert(p1 is Dummy.TestObject);
|
||||
Test.AssertEquals("part_one", p1.GetName());
|
||||
Test.AssertEquals("part_one", p1.Name);
|
||||
Test.Assert(p2 is Dummy.TestObject);
|
||||
Test.AssertEquals("part_two", p2.GetName());
|
||||
Test.AssertEquals("part_two", p2.Name);
|
||||
obj.Dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ internal class StructHelpers
|
|||
Marshal.WriteByte(Fslice.Mem, 125);
|
||||
|
||||
var Fobj = new Dummy.Numberwrapper();
|
||||
Fobj.SetNumber(42);
|
||||
Fobj.Number = 42;
|
||||
|
||||
return new Dummy.StructComplex(farray: Farray, flist: Flist, fhash: Fhash,
|
||||
fiterator: Fiterator, fanyValue:Fany_value, fanyValueRef: Fany_value_ref,
|
||||
|
@ -205,7 +205,7 @@ internal class StructHelpers
|
|||
Test.Assert(complex.Fslice.GetBytes()[0] == 125);
|
||||
|
||||
Test.Assert(complex.Fobj != null);
|
||||
Test.Assert(complex.Fobj.GetNumber() == 42);
|
||||
Test.Assert(complex.Fobj.Number == 42);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue