forked from enlightenment/efl
cxx: Implement support for @class static functions
This commit is contained in:
parent
0f812f1584
commit
6653b9e2b1
|
@ -24,7 +24,7 @@ struct function_declaration_generator
|
|||
template <typename OutputIterator, typename Context>
|
||||
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& ctx) const
|
||||
{
|
||||
std::string suffix;
|
||||
std::string suffix, static_flag, const_flag;
|
||||
switch(_klass_name.type)
|
||||
{
|
||||
case attributes::class_type::regular:
|
||||
|
@ -50,8 +50,12 @@ struct function_declaration_generator
|
|||
.generate(sink, attributes::unused, ctx))
|
||||
return false;
|
||||
|
||||
if (f.is_static) static_flag = "static ";
|
||||
else const_flag = " const";
|
||||
|
||||
if(!as_generator
|
||||
(scope_tab << "::efl::eolian::return_traits<" << grammar::type(true) << ">::type " << string << "(" << (parameter % ", ") << ") const;\n")
|
||||
(scope_tab << static_flag << "::efl::eolian::return_traits<" << grammar::type(true) << ">::type "
|
||||
<< string << "(" << (parameter % ", ") << ")" << const_flag << ";\n")
|
||||
.generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), ctx))
|
||||
return false;
|
||||
if(f.is_beta &&
|
||||
|
|
|
@ -60,9 +60,14 @@ struct function_definition_generator
|
|||
.generate(sink, attributes::unused, ctx))
|
||||
return false;
|
||||
|
||||
std::string const_flag;
|
||||
if (!f.is_static) const_flag = " const";
|
||||
|
||||
if(!as_generator
|
||||
("inline ::efl::eolian::return_traits<" << grammar::type(true) << ">::type " << string << "::" << string << "(" << (parameter % ", ") << ") const\n{\n")
|
||||
.generate(sink, std::make_tuple(f.return_type, _klass_name.eolian_name, escape_keyword(f.name), f.parameters), ctx))
|
||||
("inline ::efl::eolian::return_traits<" << grammar::type(true) << ">::type " << string << "::"
|
||||
<< string << "(" << (parameter % ", ") << ")" << string << "\n{\n")
|
||||
.generate(sink, std::make_tuple(f.return_type, _klass_name.eolian_name,
|
||||
escape_keyword(f.name), f.parameters, const_flag), ctx))
|
||||
return false;
|
||||
|
||||
std::vector<std::string> opening_statements(f.opening_statements());
|
||||
|
@ -104,10 +109,13 @@ struct function_definition_generator
|
|||
&& !as_generator(attributes::c_type({attributes::parameter_direction::in, f.return_type, ""})
|
||||
<< " __return_value = "
|
||||
).generate(sink, attributes::unused, ctx)) return false;
|
||||
|
||||
|
||||
std::string object_flag;
|
||||
if (f.is_static) object_flag = "_eo_class()";
|
||||
else object_flag = "_eo_ptr()";
|
||||
|
||||
if(!as_generator
|
||||
(" ::" << string << "(this->_eo_ptr()"
|
||||
<<
|
||||
(" ::" << string << "(" << string <<
|
||||
*(
|
||||
"\n" << scope_tab << scope_tab << ", "
|
||||
<<
|
||||
|
@ -119,7 +127,7 @@ struct function_definition_generator
|
|||
)
|
||||
)
|
||||
<< ");\n"
|
||||
).generate(sink, std::make_tuple(f.c_name, f.parameters), ctx))
|
||||
).generate(sink, std::make_tuple(f.c_name, object_flag, f.parameters), ctx))
|
||||
return false;
|
||||
|
||||
auto out_assignments =
|
||||
|
|
|
@ -439,6 +439,7 @@ struct function_def
|
|||
bool is_beta;
|
||||
bool is_protected;
|
||||
bool is_function_pointer;
|
||||
bool is_static;
|
||||
|
||||
friend inline bool operator==(function_def const& lhs, function_def const& rhs)
|
||||
{
|
||||
|
@ -449,7 +450,8 @@ struct function_def
|
|||
&& lhs.filename == rhs.filename
|
||||
&& lhs.is_beta == rhs.is_beta
|
||||
&& lhs.is_protected == rhs.is_protected
|
||||
&& lhs.is_function_pointer == rhs.is_function_pointer;
|
||||
&& lhs.is_function_pointer == rhs.is_function_pointer
|
||||
&& lhs.is_static == rhs.is_static;
|
||||
}
|
||||
friend inline bool operator!=(function_def const& lhs, function_def const& rhs)
|
||||
{
|
||||
|
@ -531,7 +533,7 @@ struct function_def
|
|||
}
|
||||
is_beta = eolian_function_is_beta(function);
|
||||
is_protected = eolian_function_scope_get(function, type) == EOLIAN_SCOPE_PROTECTED;
|
||||
is_protected = eolian_function_scope_get(function, type) == EOLIAN_SCOPE_PROTECTED;
|
||||
is_static = eolian_function_is_class(function);
|
||||
}
|
||||
|
||||
std::string template_statement() const
|
||||
|
|
Loading…
Reference in New Issue