forked from enlightenment/efl
cxx: Place beta API declarations behind ifdef
NOTE: protected APIs are placed behind ifdef as well in the implementation file. This makes sense since the define is required for the C code to compile, but this isn't what @protected means.
This commit is contained in:
parent
2dd1e59a4c
commit
3f64dcc521
|
@ -33,7 +33,7 @@ struct base_class_definition_generator
|
|||
"struct " << string << " {\n"
|
||||
).generate(sink, cls.cxx_name, context)) return false;
|
||||
|
||||
if(!as_generator(*(scope_tab << function_declaration))
|
||||
if(!as_generator(*(scope_tab << function_declaration(get_klass_name(cls))))
|
||||
.generate(sink, cls.functions, context)) return false;
|
||||
|
||||
// static Efl_Class const* _eo_class();
|
||||
|
|
|
@ -87,7 +87,7 @@ struct class_definition_generator
|
|||
// << scope_tab << scope_tab << ": ::efl::eo::concrete( ::efl::eo::do_eo_add( ::efl::eo::concrete{nullptr}, f)) {}\n"
|
||||
).generate(sink, attributes::make_infinite_tuple(cls.cxx_name), context)) return false;
|
||||
|
||||
if(!as_generator(*(scope_tab << function_declaration))
|
||||
if(!as_generator(*(scope_tab << function_declaration(get_klass_name(cls))))
|
||||
.generate(sink, cls.functions, context)) return false;
|
||||
|
||||
// static Efl_Class const* _eo_class();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "grammar/generator.hpp"
|
||||
#include "grammar/klass_def.hpp"
|
||||
|
||||
#include "grammar/string.hpp"
|
||||
#include "grammar/indentation.hpp"
|
||||
#include "grammar/list.hpp"
|
||||
#include "grammar/alternative.hpp"
|
||||
|
@ -15,13 +16,43 @@ namespace efl { namespace eolian { namespace grammar {
|
|||
|
||||
struct function_declaration_generator
|
||||
{
|
||||
template <typename OutputIterator, typename Context>
|
||||
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
|
||||
{
|
||||
return as_generator
|
||||
("::efl::eolian::return_traits<" << grammar::type(true) << ">::type " << string << "(" << (parameter % ", ") << ") const;\n")
|
||||
.generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), context);
|
||||
}
|
||||
function_declaration_generator(attributes::klass_name const& name)
|
||||
: _klass_name(name)
|
||||
{}
|
||||
|
||||
template <typename OutputIterator, typename Context>
|
||||
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& ctx) const
|
||||
{
|
||||
std::string suffix;
|
||||
switch(_klass_name.type)
|
||||
{
|
||||
case attributes::class_type::regular:
|
||||
case attributes::class_type::abstract_:
|
||||
suffix = "CLASS";
|
||||
break;
|
||||
case attributes::class_type::mixin:
|
||||
suffix = "MIXIN";
|
||||
break;
|
||||
case attributes::class_type::interface_:
|
||||
suffix = "INTERFACE";
|
||||
break;
|
||||
}
|
||||
|
||||
if(f.is_beta &&
|
||||
!as_generator("#ifdef " << *(string << "_") << string << "_" << string << "_BETA\n")
|
||||
.generate(sink, std::make_tuple(_klass_name.namespaces, _klass_name.eolian_name, suffix), add_upper_case_context(ctx)))
|
||||
return false;
|
||||
if(!as_generator
|
||||
("::efl::eolian::return_traits<" << grammar::type(true) << ">::type " << string << "(" << (parameter % ", ") << ") const;\n")
|
||||
.generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), ctx))
|
||||
return false;
|
||||
if(f.is_beta &&
|
||||
!as_generator("#endif\n").generate(sink, attributes::unused, ctx))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
attributes::klass_name _klass_name;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
@ -31,8 +62,14 @@ namespace type_traits {
|
|||
template <>
|
||||
struct attributes_needed<function_declaration_generator> : std::integral_constant<int, 1> {};
|
||||
}
|
||||
|
||||
function_declaration_generator const function_declaration = {};
|
||||
|
||||
struct function_declaration_terminal
|
||||
{
|
||||
function_declaration_generator operator()(attributes::klass_name name) const
|
||||
{
|
||||
return function_declaration_generator{name};
|
||||
}
|
||||
} const function_declaration = {};
|
||||
|
||||
} } }
|
||||
|
||||
|
|
Loading…
Reference in New Issue