summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-11-28 22:03:17 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-11-28 22:20:21 +0900
commit1f36ec4d0855bdfcb8e81ed3dc9408934ed3dda4 (patch)
tree3f4406d0d21dfb1be64c51e4c4cbac5d8ddb12a2
parent0d35b848ca470f9d9fd8f83f3d0c2c9ea32d1055 (diff)
downloadefl-devs/jpeg/cxx.tar.gz
cxx: Add ability to manually define new methodsdevs/jpeg/cxx
This adds a set of macros that, if defined, will be part of the class definition and implementation: Example: ifdef EOLIAN_CXX_EFL_UI_WIN_EXTRA_DECLARATIONS EOLIAN_CXX_EFL_UI_WIN_EXTRA_DECLARATIONS endif ifdef EOLIAN_CXX_EFL_UI_WIN_EXTRA_IMPLEMENTATIONS EOLIAN_CXX_EFL_UI_WIN_EXTRA_IMPLEMENTATIONS endif This feature is disable by default. Not sure we'll need it.
-rw-r--r--src/lib/eolian_cxx/grammar/base_class_definition.hpp10
-rw-r--r--src/lib/eolian_cxx/grammar/class_declaration.hpp2
-rw-r--r--src/lib/eolian_cxx/grammar/class_definition.hpp21
-rw-r--r--src/lib/eolian_cxx/grammar/class_implementation.hpp32
-rw-r--r--src/lib/eolian_cxx/grammar/generator.hpp1
5 files changed, 52 insertions, 14 deletions
diff --git a/src/lib/eolian_cxx/grammar/base_class_definition.hpp b/src/lib/eolian_cxx/grammar/base_class_definition.hpp
index 22c2847e5f..69ed79ac74 100644
--- a/src/lib/eolian_cxx/grammar/base_class_definition.hpp
+++ b/src/lib/eolian_cxx/grammar/base_class_definition.hpp
@@ -40,6 +40,16 @@ struct base_class_definition_generator
if(!as_generator(*(part_declaration << ";\n"))
.generate(sink, cls.parts, context)) return false;
+#ifdef USE_EXTRA_IMPLEMENTATIONS
+ if(!as_generator
+ ("#ifdef EOLIAN_CXX_" << *(string << "_") << string << "_EXTRA_DECLARATIONS\n"
+ << scope_tab << "EOLIAN_CXX_" << *(string << "_") << string << "_EXTRA_DECLARATIONS\n"
+ << "#endif\n")
+ .generate(sink, std::make_tuple(cls.namespaces, cls.eolian_name,
+ cls.namespaces, cls.eolian_name), add_upper_case_context(context)))
+ return false;
+#endif
+
// static Efl_Class const* _eo_class();
std::string suffix;
switch(cls.type)
diff --git a/src/lib/eolian_cxx/grammar/class_declaration.hpp b/src/lib/eolian_cxx/grammar/class_declaration.hpp
index d448c31074..7a3908b9e5 100644
--- a/src/lib/eolian_cxx/grammar/class_declaration.hpp
+++ b/src/lib/eolian_cxx/grammar/class_declaration.hpp
@@ -66,7 +66,7 @@ struct class_declaration_generator
.generate(sink, std::make_tuple(), context))
return false;
-
+
return true;
}
};
diff --git a/src/lib/eolian_cxx/grammar/class_definition.hpp b/src/lib/eolian_cxx/grammar/class_definition.hpp
index 0ed997a848..af4dd5ca92 100644
--- a/src/lib/eolian_cxx/grammar/class_definition.hpp
+++ b/src/lib/eolian_cxx/grammar/class_definition.hpp
@@ -208,15 +208,28 @@ struct class_definition_generator
if(!as_generator(scope_tab << "/// @endcond\n").generate(sink, attributes::unused, context)) return false;
// EXPERIMENTAL: Parts
- if(!as_generator("#ifdef EFL_CXXPERIMENTAL\n").generate(sink, attributes::unused, context)) return false;
- if(!as_generator(*(scope_tab << part_declaration << ";\n"))
- .generate(sink, cls.parts, context)) return false;
- if(!as_generator("#endif \n").generate(sink, attributes::unused, context)) return false;
+ if (!cls.parts.empty())
+ {
+ if(!as_generator("#ifdef EFL_CXXPERIMENTAL\n").generate(sink, attributes::unused, context)) return false;
+ if(!as_generator(*(scope_tab << part_declaration << ";\n"))
+ .generate(sink, cls.parts, context)) return false;
+ if(!as_generator("#endif \n").generate(sink, attributes::unused, context)) return false;
+ }
if(!as_generator( scope_tab << "::efl::eo::wref<" << string << "> _get_wref() const { "
"return ::efl::eo::wref<" << string << ">(*this); }\n"
).generate(sink, std::make_tuple(cls.cxx_name, cls.cxx_name), context)) return false;
+#ifdef USE_EXTRA_IMPLEMENTATIONS
+ if(!as_generator
+ ("#ifdef EOLIAN_CXX_" << *(string << "_") << string << "_EXTRA_DECLARATIONS\n"
+ << scope_tab << "EOLIAN_CXX_" << *(string << "_") << string << "_EXTRA_DECLARATIONS\n"
+ << "#endif\n")
+ .generate(sink, std::make_tuple(cls.namespaces, cls.eolian_name,
+ cls.namespaces, cls.eolian_name), add_upper_case_context(context)))
+ return false;
+#endif
+
// EXPERIMENTAL: wref and implicit conversion to Eo*
if(!as_generator("#ifdef EFL_CXXPERIMENTAL\n").generate(sink, attributes::unused, context)) return false;
// For easy wref, operator-> in wref needs to also return a pointer type
diff --git a/src/lib/eolian_cxx/grammar/class_implementation.hpp b/src/lib/eolian_cxx/grammar/class_implementation.hpp
index e960c009df..bc6e650f4f 100644
--- a/src/lib/eolian_cxx/grammar/class_implementation.hpp
+++ b/src/lib/eolian_cxx/grammar/class_implementation.hpp
@@ -26,15 +26,15 @@ struct class_implementation_generator
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;
- std::string guard_symbol;
+ std::string class_uppercase;
- if(!as_generator(*(string << "_") << string << "_IMPL_HH")
- .generate(std::back_inserter(guard_symbol)
+ if(!as_generator(*(string << "_") << string)
+ .generate(std::back_inserter(class_uppercase)
, std::make_tuple(cpp_namespaces, cls.cxx_name), add_upper_case_context(ctx)))
return false;
- if(!as_generator( "#ifndef " << guard_symbol << "\n"
- << "#define " << guard_symbol << "\n")
+ if(!as_generator( "#ifndef " << class_uppercase << "_IMPL_HH\n"
+ << "#define " << class_uppercase << "_IMPL_HH\n")
.generate(sink, std::make_tuple(), ctx))
return false;
@@ -46,14 +46,21 @@ struct class_implementation_generator
if(!as_generator(
(namespaces
[*function_definition(get_klass_name(cls))
- << *part_implementation(cls.cxx_name)]
+ << *part_implementation(cls.cxx_name)
+#ifdef USE_EXTRA_IMPLEMENTATIONS
+ << "#ifdef EOLIAN_CXX_" << string << "_EXTRA_IMPLEMENTATIONS\n"
+ << scope_tab << "EOLIAN_CXX_" << string << "_EXTRA_IMPLEMENTATIONS\n"
+ << "#endif\n"
+#endif
+ ]
<< "\n"
- )).generate(sink, std::make_tuple(cls.namespaces, cls.functions, cls.parts), ctx))
+ )).generate(sink, std::make_tuple(cls.namespaces, cls.functions, cls.parts,
+ class_uppercase, class_uppercase), ctx))
return false;
#endif
if(!as_generator(
- attribute_reorder<0, 1, 4, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3>
+ attribute_reorder<0, 1, 4, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 5, 5>
(
"namespace eo_cxx {\n"
<< namespaces
@@ -66,9 +73,16 @@ struct class_implementation_generator
<< class_name << "*>(static_cast<void*>(this)); }\n"
<< "inline " << base_class_name << "::operator " << class_name << " const&() const { return *static_cast< "
<< class_name << " const*>(static_cast<void const*>(this)); }\n"
+#ifdef USE_EXTRA_IMPLEMENTATIONS
+ << "#ifdef EOLIAN_CXX_" << string << "_EXTRA_IMPLEMENTATIONS\n"
+ << scope_tab << "EOLIAN_CXX_" << string << "_EXTRA_IMPLEMENTATIONS\n"
+ << "#endif\n"
+#endif
]
<< "}\n"
- )).generate(sink, std::make_tuple(cls.namespaces, cls.functions, cpp_namespaces, cls.cxx_name, cls.parts), ctx))
+ )).generate(sink, std::make_tuple(cls.namespaces, cls.functions, cpp_namespaces,
+ cls.cxx_name, cls.parts,
+ class_uppercase), ctx))
return false;
if(!as_generator("#endif\n").generate(sink, std::make_tuple(), ctx))
diff --git a/src/lib/eolian_cxx/grammar/generator.hpp b/src/lib/eolian_cxx/grammar/generator.hpp
index c2942605d0..741dfd6c13 100644
--- a/src/lib/eolian_cxx/grammar/generator.hpp
+++ b/src/lib/eolian_cxx/grammar/generator.hpp
@@ -5,6 +5,7 @@
// EXPERIMENTAL
//#define USE_EOCXX_INHERIT_ONLY
+//#define USE_EXTRA_IMPLEMENTATIONS
namespace efl { namespace eolian { namespace grammar {