}
template<typename Context>
-inline bool is_function_blacklisted(attributes::function_def const& func, Context context)
+inline bool is_function_blacklisted(attributes::function_def const& func, Context const& context)
{
auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
auto c_name = func.c_name;
}
template <typename Context>
-inline bool is_struct_blacklisted(attributes::struct_def const& struct_, Context context)
+inline bool is_struct_blacklisted(attributes::struct_def const& struct_, Context const& context)
{
auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
if (struct_.is_beta && !options.want_beta)
// Struct as type_def is for places where the struct is used as a struct field or parameter/return.
template <typename Context>
-inline bool is_struct_blacklisted(attributes::type_def const& struct_, Context context)
+inline bool is_struct_blacklisted(attributes::type_def const& struct_, Context const& context)
{
auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
if (struct_.is_beta && !options.want_beta)
}
template<typename Context>
-inline bool is_property_blacklisted(attributes::property_def const& property, Context context)
+inline bool is_property_blacklisted(attributes::property_def const& property, Context const& context)
{
auto name = name_helpers::klass_full_concrete_or_interface_name(property.klass) + "." + name_helpers::property_managed_name(property);
template<typename Context>
inline bool is_property_blacklisted(attributes::property_def const& property,
attributes::klass_def const& implementing_class,
- Context context)
+ Context const& context)
{
std::string property_name = name_helpers::property_managed_name(property);
std::string klass_name = name_helpers::klass_concrete_or_interface_name(implementing_class);
}
template<typename Context>
-inline bool is_class_blacklisted(attributes::klass_def const& cls, Context context)
+inline bool is_class_blacklisted(attributes::klass_def const& cls, Context const& context)
{
auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
}
template<typename Context>
-inline bool is_class_blacklisted(attributes::klass_name const& cls, Context context)
+inline bool is_class_blacklisted(attributes::klass_name const& cls, Context const& context)
{
auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
template<typename Context>
-inline bool is_event_blacklisted(attributes::event_def const& evt, Context context)
+inline bool is_event_blacklisted(attributes::event_def const& evt, Context const& context)
{
auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
bool is_inherited_event;
template<typename OutputIterator, typename Context>
- bool generate(OutputIterator sink, attributes::event_def const& evt, Context context) const
+ bool generate(OutputIterator sink, attributes::event_def const& evt, Context const& context) const
{
if (blacklist::is_event_blacklisted(evt, context))
return true;
, std::string const& event_name
, std::string const& event_args_type
, std::string const& event_template_args
- , Context context) const
+ , Context const& context) const
{
auto delegate_type = "EventHandler" + event_template_args;
if (!as_generator(
}
template<typename OutputIterator, typename Context>
- bool generate_event_add_remove(OutputIterator sink, attributes::event_def const &evt, const std::string& event_name, Context context) const
+ bool generate_event_add_remove(OutputIterator sink, attributes::event_def const &evt, const std::string& event_name, Context const& context) const
{
std::string upper_c_name = utils::to_uppercase(evt.c_name);
auto unit = (const Eolian_Unit*) context_find_tag<eolian_state_context>(context).state;
struct property_wrapper_definition_generator
{
template<typename OutputIterator, typename Context>
- bool generate(OutputIterator sink, attributes::property_def const& property, Context context) const
+ bool generate(OutputIterator sink, attributes::property_def const& property, Context const& context) const
{
if (blacklist::is_property_blacklisted(property, *implementing_klass, context))
return true;
// Blacklist structs that require some kind of manual binding.
template <typename Context>
-static bool is_function_ptr_blacklisted(attributes::function_def const& func, Context context)
+static bool is_function_ptr_blacklisted(attributes::function_def const& func, Context const& context)
{
std::string name = name_helpers::function_ptr_full_eolian_name(func);
#ifndef EOLIAN_MONO_GENERATION_CONTEXTS_HH
#define EOLIAN_MONO_GENERATION_CONTEXTS_HH
+#include "grammar/context.hpp"
+#include "grammar/indentation.hpp"
+
namespace eolian_mono {
struct class_context
wrapper_kind current_wrapper_kind;
};
+struct indentation_context
+{
+ constexpr indentation_context(indentation_context const& other) = default;
+ constexpr indentation_context(efl::eolian::grammar::scope_tab_generator indent)
+ : indent(indent)
+ {}
+ constexpr indentation_context(int n)
+ : indent(n)
+ {}
+ constexpr indentation_context(int n, int m)
+ : indent(n, m)
+ {}
+ efl::eolian::grammar::scope_tab_generator indent;
+};
+
+template <typename Context>
+inline constexpr efl::eolian::grammar::scope_tab_generator const& current_indentation(Context const& context)
+{
+ return efl::eolian::grammar::context_find_tag<indentation_context>(context).indent;
+}
+
+template <typename Context>
+inline constexpr Context change_indentation(efl::eolian::grammar::scope_tab_generator const& indent, Context const& context)
+{
+ return efl::eolian::grammar::context_replace_tag(indentation_context(indent), context);
+}
+
struct library_context
{
std::string library_name;
// Returns the set of interfaces implemented by this type that haven't been implemented
// by a regular parent class.
template<typename Context>
-std::set<attributes::klass_name, attributes::compare_klass_name_by_name> non_implemented_interfaces(attributes::klass_def const& cls, Context context)
+std::set<attributes::klass_name, attributes::compare_klass_name_by_name> non_implemented_interfaces(attributes::klass_def const& cls, Context const& context)
{
auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> implemented_interfaces;
// Open/close namespaces
template<typename OutputIterator, typename Context>
-bool open_namespaces(OutputIterator sink, std::vector<std::string> namespaces, Context context)
+bool open_namespaces(OutputIterator sink, std::vector<std::string> namespaces, Context const& context)
{
std::transform(namespaces.begin(), namespaces.end(), namespaces.begin(), managed_namespace);
}
template<typename OutputIterator, typename Context>
-bool close_namespaces(OutputIterator sink, std::vector<std::string> const& namespaces, Context context)
+bool close_namespaces(OutputIterator sink, std::vector<std::string> const& namespaces, Context const& context)
{
auto close_namespace = *(lit("} ")) << "\n";
return as_generator(close_namespace).generate(sink, namespaces, context);
struct constructor_param_generator
{
template<typename OutputIterator, typename Context>
- bool generate(OutputIterator sink, attributes::constructor_def const& ctor, Context context) const
+ bool generate(OutputIterator sink, attributes::constructor_def const& ctor, Context const& context) const
{
auto params = ctor.function.parameters;
struct constructor_invocation_generator
{
template<typename OutputIterator, typename Context>
- bool generate(OutputIterator sink, attributes::constructor_def const& ctor, Context context) const
+ bool generate(OutputIterator sink, attributes::constructor_def const& ctor, Context const& context) const
{
auto params = ctor.function.parameters;
if (!as_generator(
struct constant_definition_generator
{
template<typename OutputIterator, typename Context>
- bool generate(OutputIterator sink, attributes::variable_def constant, Context context) const
+ bool generate(OutputIterator sink, attributes::variable_def constant, Context const& context) const
{
// Open partial class
if (!name_helpers::open_namespaces(sink, constant.namespaces, context))
throw std::runtime_error("Failed to generate file preamble");
}
- auto lib_context = efl::eolian::grammar::context_add_tag(eolian_mono::library_context{opts.dllimport,
- opts.v_major,
- opts.v_minor,
- opts.references_map},
- efl::eolian::grammar::context_null());
-
- auto options_context = efl::eolian::grammar::context_add_tag(eolian_mono::options_context{opts.want_beta}, lib_context);
-
- auto context = efl::eolian::grammar::context_add_tag(eolian_mono::eolian_state_context{opts.state}, options_context);
+ using efl::eolian::grammar::context_add_tag;
+
+ auto context = context_add_tag(eolian_mono::indentation_context{0},
+ context_add_tag(eolian_mono::eolian_state_context{opts.state},
+ context_add_tag(eolian_mono::options_context{opts.want_beta},
+ context_add_tag(eolian_mono::library_context{opts.dllimport,
+ opts.v_major,
+ opts.v_minor,
+ opts.references_map},
+ efl::eolian::grammar::context_null()))));
EINA_ITERATOR_FOREACH(aliases, tp)
{