From cb7f2d0dd5da40be7ae0bcaf89ceebe3c0d32b6d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Tue, 28 Nov 2017 15:32:02 +0900 Subject: [PATCH] cxx: Add header guards for manual definitions This will be used for things like efl_del efl_part was a lucky case where the entire class was to be implemented manually, thus the global header guard was sufficient. --- src/lib/eolian_cxx/grammar/function_declaration.hpp | 13 +++++++++++++ src/lib/eolian_cxx/grammar/function_definition.hpp | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/lib/eolian_cxx/grammar/function_declaration.hpp b/src/lib/eolian_cxx/grammar/function_declaration.hpp index fe3ad73..634642e 100644 --- a/src/lib/eolian_cxx/grammar/function_declaration.hpp +++ b/src/lib/eolian_cxx/grammar/function_declaration.hpp @@ -44,6 +44,11 @@ struct function_declaration_generator .generate(sink, std::make_tuple(_klass_name.namespaces, _klass_name.eolian_name, suffix), add_upper_case_context(ctx))) return false; + if(!as_generator + ("#ifndef EOLIAN_CXX_" << string << "_DECLARATION\n") + .generate(sink, f.c_name, add_upper_case_context(ctx))) + return false; + std::string template_statement(f.template_statement()); if (!template_statement.empty() && !as_generator(template_statement << " ") @@ -58,9 +63,17 @@ struct function_declaration_generator << string << "(" << (parameter % ", ") << ")" << const_flag << ";\n") .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), ctx)) return false; + + if(!as_generator + ("#else\n" << scope_tab << "EOLIAN_CXX_" << string << "_DECLARATION\n" + "#endif\n") + .generate(sink, f.c_name, add_upper_case_context(ctx))) + return false; + if(f.is_beta && !as_generator("#endif\n").generate(sink, attributes::unused, ctx)) return false; + return true; } diff --git a/src/lib/eolian_cxx/grammar/function_definition.hpp b/src/lib/eolian_cxx/grammar/function_definition.hpp index 1ffbed4..46df876 100644 --- a/src/lib/eolian_cxx/grammar/function_definition.hpp +++ b/src/lib/eolian_cxx/grammar/function_definition.hpp @@ -54,6 +54,11 @@ struct function_definition_generator .generate(sink, std::make_tuple(_klass_name.namespaces, _klass_name.eolian_name), add_upper_case_context(ctx))) return false; + if(!as_generator + ("#ifndef EOLIAN_CXX_" << string << "_IMPLEMENTATION\n") + .generate(sink, f.c_name, add_upper_case_context(ctx))) + return false; + std::string template_statement(f.template_statement()); if (!template_statement.empty() && !as_generator(template_statement << "\n") @@ -161,6 +166,12 @@ struct function_definition_generator if(!as_generator("}\n").generate(sink, attributes::unused, ctx)) return false; + if(!as_generator + ("#else\n" << scope_tab << "EOLIAN_CXX_" << string << "_IMPLEMENTATION\n" + "#endif\n") + .generate(sink, f.c_name, add_upper_case_context(ctx))) + return false; + if(f.is_beta && !as_generator("#endif\n").generate(sink, attributes::unused, ctx)) return false; -- 2.7.4