cxx: Add support for protected and beta events

The code is horrible, pardon my C++.

Note: I guess @protected should also change the scope from
public: to protected: but that's another problem. Here I'm only
trying to fix the build while still introducing @beta and
@protected flags.
This commit is contained in:
Jean-Philippe Andre 2016-06-14 16:20:51 +09:00
parent 8a0e74afa8
commit c6dfdeb0c8
2 changed files with 44 additions and 18 deletions

View File

@ -110,21 +110,44 @@ struct class_definition_generator
scope_tab << "Eo* _eo_ptr() const { return *(Eo**)this; }\n"
).generate(sink, attributes::unused, context)) return false;
if(!as_generator
(
*attribute_reorder<1, 2, 0, 1>
((scope_tab << "static struct " << string_replace(',', '_') << "_event\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "static Eo_Event_Description const* description()\n"
<< scope_tab << scope_tab << "{ return " << string << "; }\n"
<< scope_tab << scope_tab << "typedef "
<< (attribute_conditional([] (eina::optional<attributes::type_def> t) { return !!t; })
[attribute_replace([] (eina::optional<attributes::type_def> t) { return *t; }) [type]]
| "void")
<< " parameter_type;\n"
<< scope_tab << "} const " << string_replace(',', '_') << "_event;\n"
))).generate(sink, cls.events, context))
return false;
for (auto&& e : cls.events)
{
if (e.beta)
{
suffix = "BETA";
if(!as_generator
("#ifdef " << *(string << "_") << string << "_" << string << "\n")
.generate(sink, std::make_tuple(cls.namespaces, cls.eolian_name, suffix), add_upper_case_context(context)))
return false;
}
if (e.protect)
{
suffix = "PROTECTED";
if(!as_generator
("#ifdef " << *(string << "_") << string << "_" << string << "\n")
.generate(sink, std::make_tuple(cls.namespaces, cls.eolian_name, suffix), add_upper_case_context(context)))
return false;
}
if(!as_generator
(
*attribute_reorder<1, 2, 0, 1>
((scope_tab << "static struct " << string_replace(',', '_') << "_event\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "static Eo_Event_Description const* description()\n"
<< scope_tab << scope_tab << "{ return " << string << "; }\n"
<< scope_tab << scope_tab << "typedef "
<< (attribute_conditional([] (eina::optional<attributes::type_def> t) { return !!t; })
[attribute_replace([] (eina::optional<attributes::type_def> t) { return *t; }) [type]]
| "void")
<< " parameter_type;\n"
<< scope_tab << "} const " << string_replace(',', '_') << "_event;\n"
))).generate(sink, std::vector<attributes::event_def>{e}, context))
return false;
if (e.beta && !as_generator("#endif\n").generate(sink, attributes::unused, context))
return false;
if (e.protect && !as_generator("#endif\n").generate(sink, attributes::unused, context))
return false;
}
// /// @cond LOCAL
if(!as_generator(scope_tab << "/// @cond LOCAL\n").generate(sink, attributes::unused, context)) return false;

View File

@ -532,13 +532,16 @@ struct event_def
{
eina::optional<type_def> type;
std::string name, c_name;
bool beta, protect;
event_def(type_def type, std::string name, std::string c_name)
: type(type), name(name), c_name(c_name) {}
event_def(type_def type, std::string name, std::string c_name, bool beta, bool protect)
: type(type), name(name), c_name(c_name), beta(beta), protect(protect) {}
event_def(Eolian_Event const* event)
: type( ::eolian_event_type_get(event) ? ::eolian_event_type_get(event) : eina::optional<type_def>{})
, name( ::eolian_event_name_get(event))
, c_name( ::eolian_event_c_name_get(event)) {}
, c_name( ::eolian_event_c_name_get(event))
, beta( ::eolian_event_is_beta(event))
, protect( ::eolian_event_scope_get(event) == EOLIAN_SCOPE_PROTECTED){}
};
template <>