#include "grammar/namespace.hpp"
#include "grammar/case.hpp"
#include "grammar/address_of.hpp"
+#include "grammar/attribute_reorder.hpp"
namespace efl { namespace eolian { namespace grammar {
// operator ::ns::Class_Name() const;
// operator ::ns::Class_Name&();
// operator ::ns::Class_Name const&() const;
+ auto class_name = *(lit("::") << lower_case[string]) << "::" << string;
if(!as_generator
(
- scope_tab << "operator " << *("::" << lower_case[string]) << "::" << string << "() const;\n"
- << scope_tab << "operator " << *("::" << lower_case[string]) << "::" << string << "&();\n"
- << scope_tab << "operator " << *("::" << lower_case[string]) << "::" << string << " const&() const;\n"
- ).generate(sink, std::make_tuple
- (cpp_namespaces, cls.cxx_name, cpp_namespaces, cls.cxx_name, cpp_namespaces, cls.cxx_name)
- , context))
+ attribute_reorder<0, 1, 0, 1, 0, 1, 0, 1>
+ (
+ scope_tab << "operator " << class_name << "() const;\n"
+ << scope_tab << "operator " << class_name << "&();\n"
+ << scope_tab << "operator " << class_name << " const&() const;\n"
+ )).generate(sink, std::make_tuple(cpp_namespaces, cls.cxx_name), context))
return false;
// /// @cond LOCAL
template <typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::klass_def const& cls, Context const& ctx) const
{
+ std::vector<std::string> cpp_namespaces = attributes::cpp_namespaces(cls.namespaces);
+ auto base_class_name = *(lower_case[string] << "::") << string;
+ auto class_name = *(lit("::") << lower_case[string]) << "::" << string;
return as_generator
(
(namespaces
[*function_definition(get_klass_name(cls))]
- // << "namespace eo_cxx {\n"
- // << namespaces
- // [*function_definition(get_klass_name(cls))]
- // << "}\n\n"
+ << "\n"
)).generate(sink, std::make_tuple(cls.namespaces, cls.functions), ctx)
&& as_generator
(
- "namespace eo_cxx {\n"
- << namespaces
- [*function_definition(get_klass_name(cls))]
- << "}\n\n"
- ).generate(sink, std::make_tuple(cls.namespaces, cls.functions), ctx);
+ attribute_reorder<0, 1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3>
+ (
+ "namespace eo_cxx {\n"
+ << namespaces
+ [
+ *function_definition(get_klass_name(cls))
+ << base_class_name << "::operator " << class_name << "() const { return *static_cast< "
+ << class_name << " const*>(static_cast<void const*>(this)); }\n"
+ << base_class_name << "::operator " << class_name << "&() { return *static_cast< "
+ << class_name << "*>(static_cast<void*>(this)); }\n"
+ << base_class_name << "::operator " << class_name << " const&() const { return *static_cast< "
+ << class_name << " const*>(static_cast<void const*>(this)); }\n"
+ ]
+ << "}\n\n"
+ )).generate(sink, std::make_tuple(cls.namespaces, cls.functions, cpp_namespaces, cls.cxx_name), ctx);
}
};