forked from enlightenment/efl
eolian_cxx: Fix @beta on generated bindings for C++
This commit is contained in:
parent
6e7ab244f7
commit
2c48b3212a
|
@ -142,6 +142,7 @@ _convert_property_set_to_function(Eolian_Class const& klass,
|
||||||
{
|
{
|
||||||
efl::eolian::eo_function::regular_,
|
efl::eolian::eo_function::regular_,
|
||||||
function_scope(prop_),
|
function_scope(prop_),
|
||||||
|
function_is_beta(prop_),
|
||||||
function_name(prop_) + "_set",
|
function_name(prop_) + "_set",
|
||||||
function_impl(prop_) + "_set",
|
function_impl(prop_) + "_set",
|
||||||
function_return_type(prop_, eolian_cxx::setter),
|
function_return_type(prop_, eolian_cxx::setter),
|
||||||
|
@ -170,6 +171,7 @@ _convert_property_get_to_function(Eolian_Class const& klass,
|
||||||
{
|
{
|
||||||
efl::eolian::eo_function::regular_,
|
efl::eolian::eo_function::regular_,
|
||||||
function_scope(prop_),
|
function_scope(prop_),
|
||||||
|
function_is_beta(prop_),
|
||||||
function_name(prop_) + "_get",
|
function_name(prop_) + "_get",
|
||||||
function_impl(prop_) + "_get",
|
function_impl(prop_) + "_get",
|
||||||
function_return_type(prop_, eolian_cxx::getter),
|
function_return_type(prop_, eolian_cxx::getter),
|
||||||
|
@ -218,6 +220,7 @@ _convert_function(Eolian_Class const& klass, Eolian_Function const& func)
|
||||||
return {
|
return {
|
||||||
function_type(func),
|
function_type(func),
|
||||||
function_scope(func),
|
function_scope(func),
|
||||||
|
function_is_beta(func),
|
||||||
function_name(func),
|
function_name(func),
|
||||||
function_impl(func),
|
function_impl(func),
|
||||||
function_return_type(func),
|
function_return_type(func),
|
||||||
|
|
|
@ -204,6 +204,12 @@ function_is_constructor(Eolian_Class const& cls, Eolian_Function const& func)
|
||||||
return ::eolian_function_is_constructor(&func, &cls);
|
return ::eolian_function_is_constructor(&func, &cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
function_is_beta(Eolian_Function const& func)
|
||||||
|
{
|
||||||
|
return ::eolian_function_is_beta(&func);
|
||||||
|
}
|
||||||
|
|
||||||
inline efl::eolian::eolian_scope
|
inline efl::eolian::eolian_scope
|
||||||
function_scope(Eolian_Function const& func)
|
function_scope(Eolian_Function const& func)
|
||||||
{
|
{
|
||||||
|
@ -403,6 +409,7 @@ event_create(Eolian_Class const& klass, const Eolian_Event *event_)
|
||||||
std::transform(name_.begin(), name_.end(), name_.begin(),
|
std::transform(name_.begin(), name_.end(), name_.begin(),
|
||||||
[](int c) { return c != ',' ? c : '_'; });
|
[](int c) { return c != ',' ? c : '_'; });
|
||||||
event.scope = eolian_scope_cxx(::eolian_event_scope_get(event_));
|
event.scope = eolian_scope_cxx(::eolian_event_scope_get(event_));
|
||||||
|
event.is_beta = (::eolian_event_is_beta(event_) != EINA_FALSE);
|
||||||
event.name = normalize_spaces(name_);
|
event.name = normalize_spaces(name_);
|
||||||
event.eo_name = safe_upper
|
event.eo_name = safe_upper
|
||||||
(find_replace(class_full_name(klass), ".", "_") + "_EVENT_" + event.name);
|
(find_replace(class_full_name(klass), ".", "_") + "_EVENT_" + event.name);
|
||||||
|
|
|
@ -285,6 +285,7 @@ struct eo_function
|
||||||
};
|
};
|
||||||
eo_function_type type;
|
eo_function_type type;
|
||||||
eolian_scope scope;
|
eolian_scope scope;
|
||||||
|
bool is_beta;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string impl;
|
std::string impl;
|
||||||
eolian_type_instance ret;
|
eolian_type_instance ret;
|
||||||
|
@ -297,6 +298,7 @@ struct eo_event
|
||||||
eo_event() : scope(eolian_scope::public_) {}
|
eo_event() : scope(eolian_scope::public_) {}
|
||||||
|
|
||||||
eolian_scope scope;
|
eolian_scope scope;
|
||||||
|
bool is_beta;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string eo_name;
|
std::string eo_name;
|
||||||
//parameters_container_type params; // XXX desirable.
|
//parameters_container_type params; // XXX desirable.
|
||||||
|
|
|
@ -29,6 +29,8 @@ operator<<(std::ostream& out, _scope_guard_head<T> const& x)
|
||||||
assert(x._e.scope != eolian_scope::private_);
|
assert(x._e.scope != eolian_scope::private_);
|
||||||
if (x._e.scope == eolian_scope::protected_)
|
if (x._e.scope == eolian_scope::protected_)
|
||||||
out << "#ifdef " << name_upper(x._cls) << "_PROTECTED" << endl;
|
out << "#ifdef " << name_upper(x._cls) << "_PROTECTED" << endl;
|
||||||
|
if (x._e.is_beta)
|
||||||
|
out << "#ifdef " << name_upper(x._cls) << "_BETA" << endl;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +55,8 @@ operator<<(std::ostream& out, _scope_guard_tail<T> const& x)
|
||||||
{
|
{
|
||||||
if (x._e.scope == eolian_scope::protected_)
|
if (x._e.scope == eolian_scope::protected_)
|
||||||
out << "#endif" << endl;
|
out << "#endif" << endl;
|
||||||
|
if (x._e.is_beta)
|
||||||
|
out << "#endif" << endl;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,26 +31,27 @@ struct inheritance_operation
|
||||||
{
|
{
|
||||||
eo_class const& _cls;
|
eo_class const& _cls;
|
||||||
eo_function const& _func;
|
eo_function const& _func;
|
||||||
functions_container_type::size_type _idx;
|
inheritance_operation(eo_class const& cls, eo_function const& func)
|
||||||
inheritance_operation(eo_class const& cls, eo_function const& func, functions_container_type::size_type idx)
|
: _cls(cls), _func(func)
|
||||||
: _cls(cls), _func(func), _idx(idx)
|
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::ostream&
|
inline std::ostream&
|
||||||
operator<<(std::ostream& out, inheritance_operation const& x)
|
operator<<(std::ostream& out, inheritance_operation const& x)
|
||||||
{
|
{
|
||||||
assert(x._idx < x._cls.functions.size());
|
|
||||||
eo_function const& func = x._func;
|
eo_function const& func = x._func;
|
||||||
out << tab(1)
|
out << scope_guard_head(x._cls, func)
|
||||||
<< "ops[" << x._idx << "].func = reinterpret_cast<void*>(& ::"
|
<< tab(1)
|
||||||
|
<< "ops[i].func = reinterpret_cast<void*>(& ::"
|
||||||
<< _ns_as_prefix(x._cls) << "_"
|
<< _ns_as_prefix(x._cls) << "_"
|
||||||
<< x._cls.name << "_" << func.name << "_wrapper<T>);" << endl
|
<< x._cls.name << "_" << func.name << "_wrapper<T>);" << endl
|
||||||
<< tab(1) << "ops[" << x._idx << "].api_func = reinterpret_cast<void*>(& ::"
|
<< tab(1) << "ops[i].api_func = reinterpret_cast<void*>(& ::"
|
||||||
<< func.impl << ");" << endl
|
<< func.impl << ");" << endl
|
||||||
<< tab(1) << "ops[" << x._idx << "].op = EO_OP_OVERRIDE;" << endl
|
<< tab(1) << "ops[i].op = EO_OP_OVERRIDE;" << endl
|
||||||
<< tab(1) << "ops[" << x._idx << "].op_type = EO_OP_TYPE_REGULAR;" << endl // XXX class ops
|
<< tab(1) << "ops[i].op_type = EO_OP_TYPE_REGULAR;" << endl // XXX class ops
|
||||||
<< tab(1) << "ops[" << x._idx << "].doc = NULL;" << endl
|
<< tab(1) << "ops[i].doc = NULL;" << endl
|
||||||
|
<< tab(1) << "++i;" << endl
|
||||||
|
<< scope_guard_tail(x._cls, func)
|
||||||
<< endl;
|
<< endl;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -74,23 +75,13 @@ operator<<(std::ostream& out, inheritance_operations_description const& x)
|
||||||
<< tab(11)
|
<< tab(11)
|
||||||
<< ", Eo_Op_Description* ops)" << endl
|
<< ", Eo_Op_Description* ops)" << endl
|
||||||
<< "{" << endl
|
<< "{" << endl
|
||||||
|
<< tab(1) << "int i = 0;" << endl
|
||||||
|
<< tab(1) << "(void)i;" << endl
|
||||||
<< tab(1) << "(void)ops;" << endl;
|
<< tab(1) << "(void)ops;" << endl;
|
||||||
|
|
||||||
auto funcs = x._cls.functions;
|
for (auto const& f : x._cls.functions)
|
||||||
auto part = std::stable_partition(funcs.begin(), funcs.end(), [](eo_function const& f){ return f.scope == eolian_scope::public_; });
|
|
||||||
|
|
||||||
functions_container_type::size_type op_idx = 0;
|
|
||||||
for (auto it = funcs.begin(); it != part; ++it, ++op_idx)
|
|
||||||
{
|
{
|
||||||
out << inheritance_operation(x._cls, *it, op_idx);
|
out << inheritance_operation(x._cls, f);
|
||||||
}
|
|
||||||
|
|
||||||
if (part != funcs.end())
|
|
||||||
{
|
|
||||||
out << scope_guard_head(x._cls, *part);
|
|
||||||
for (auto it = part; it != funcs.end(); ++it, ++op_idx)
|
|
||||||
out << inheritance_operation(x._cls, *it, op_idx);
|
|
||||||
out << scope_guard_tail(x._cls, *part);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::string const& parent : x._cls.parents)
|
for (std::string const& parent : x._cls.parents)
|
||||||
|
@ -167,25 +158,50 @@ operator<<(std::ostream& out, inheritance_wrappers const& x)
|
||||||
struct inheritance_base_operations_size
|
struct inheritance_base_operations_size
|
||||||
{
|
{
|
||||||
eo_class const& _cls;
|
eo_class const& _cls;
|
||||||
functions_container_type const& _funcs;
|
inheritance_base_operations_size(eo_class const& cls)
|
||||||
inheritance_base_operations_size(eo_class const& cls, functions_container_type const& funcs)
|
: _cls(cls)
|
||||||
: _cls(cls), _funcs(funcs)
|
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::ostream&
|
inline std::ostream&
|
||||||
operator<<(std::ostream& out, inheritance_base_operations_size const& x)
|
operator<<(std::ostream& out, inheritance_base_operations_size const& x)
|
||||||
{
|
{
|
||||||
|
int pcted = 0;
|
||||||
|
int beta = 0;
|
||||||
|
int pcted_beta = 0;
|
||||||
|
|
||||||
|
auto funcs = x._cls.functions;
|
||||||
|
|
||||||
|
for (auto const& f : funcs)
|
||||||
|
{
|
||||||
|
if (f.is_beta && f.scope != eolian_scope::public_)
|
||||||
|
++pcted_beta;
|
||||||
|
if (f.scope != eolian_scope::public_)
|
||||||
|
++pcted;
|
||||||
|
if (f.is_beta)
|
||||||
|
++beta;
|
||||||
|
}
|
||||||
|
auto all = funcs.size();
|
||||||
|
|
||||||
out << "template<>"
|
out << "template<>"
|
||||||
<< endl << "struct operation_description_class_size< "
|
<< endl << "struct operation_description_class_size< "
|
||||||
<< full_name(x._cls) << " >" << endl
|
<< full_name(x._cls) << " >" << endl
|
||||||
<< "{" << endl
|
<< "{" << endl
|
||||||
<< tab(1) << "static constexpr int value = "
|
<< tab(1) << "static constexpr int value = " << endl
|
||||||
<< x._funcs.size();
|
<< "#if defined(" << name_upper(x._cls) << "_PROTECTED)"
|
||||||
|
<< " && defined(" << name_upper(x._cls) << "_BETA)" << endl
|
||||||
|
<< tab(2) << all << endl
|
||||||
|
<< "#elif defined(" << name_upper(x._cls) << "_PROTECTED)" << endl
|
||||||
|
<< tab(2) << (all - beta) << endl
|
||||||
|
<< "#elif defined(" << name_upper(x._cls) << "_BETA)" << endl
|
||||||
|
<< tab(2) << (all - pcted) << endl
|
||||||
|
<< "#else" << endl
|
||||||
|
<< tab(2) << (all + pcted_beta - beta - pcted) << endl
|
||||||
|
<< "#endif" << endl;
|
||||||
|
|
||||||
for (std::string const& parent : x._cls.parents)
|
for (std::string const& parent : x._cls.parents)
|
||||||
{
|
{
|
||||||
out << " + operation_description_class_size<::" << parent << " >::value";
|
out << tab(2) << "+ operation_description_class_size<::" << parent << " >::value";
|
||||||
}
|
}
|
||||||
|
|
||||||
out << ";" << endl
|
out << ";" << endl
|
||||||
|
@ -195,28 +211,6 @@ operator<<(std::ostream& out, inheritance_base_operations_size const& x)
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct inheritance_base_operations_size_scopes
|
|
||||||
{
|
|
||||||
eo_class const& _cls;
|
|
||||||
inheritance_base_operations_size_scopes(eo_class const& cls)
|
|
||||||
: _cls(cls)
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
|
|
||||||
inline std::ostream&
|
|
||||||
operator<<(std::ostream& out, inheritance_base_operations_size_scopes const& x)
|
|
||||||
{
|
|
||||||
auto funcs = x._cls.functions;
|
|
||||||
auto part = std::stable_partition(funcs.begin(), funcs.end(), [](eo_function const& f){ return f.scope == eolian_scope::public_; });
|
|
||||||
|
|
||||||
out << "#ifdef " << name_upper(x._cls) << "_PROTECTED" << endl
|
|
||||||
<< inheritance_base_operations_size(x._cls, funcs)
|
|
||||||
<< "#else" << endl
|
|
||||||
<< inheritance_base_operations_size(x._cls, {funcs.begin(), part})
|
|
||||||
<< "#endif" << endl << endl;
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct inheritance_base_operations_extensions
|
struct inheritance_base_operations_extensions
|
||||||
{
|
{
|
||||||
eo_class const& _cls;
|
eo_class const& _cls;
|
||||||
|
@ -341,7 +335,7 @@ eo_inheritance_detail_generator(std::ostream& out, eo_class const& cls)
|
||||||
out << inheritance_wrappers(cls)
|
out << inheritance_wrappers(cls)
|
||||||
<< "namespace efl { namespace eo { namespace detail {" << endl << endl
|
<< "namespace efl { namespace eo { namespace detail {" << endl << endl
|
||||||
<< inheritance_base_operations(cls) << endl
|
<< inheritance_base_operations(cls) << endl
|
||||||
<< inheritance_base_operations_size_scopes(cls)
|
<< inheritance_base_operations_size(cls)
|
||||||
<< inheritance_operations_description(cls)
|
<< inheritance_operations_description(cls)
|
||||||
<< inheritance_eo_class_getter(cls)
|
<< inheritance_eo_class_getter(cls)
|
||||||
<< "} } }" << endl;
|
<< "} } }" << endl;
|
||||||
|
|
Loading…
Reference in New Issue