summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/eolian_cxx/eolian_cxx.cc26
-rw-r--r--src/lib/eolian_cxx/grammar/implementation_include_directive.hpp2
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp48
3 files changed, 41 insertions, 35 deletions
diff --git a/src/bin/eolian_cxx/eolian_cxx.cc b/src/bin/eolian_cxx/eolian_cxx.cc
index 18978a3fe9..ee1b39909c 100644
--- a/src/bin/eolian_cxx/eolian_cxx.cc
+++ b/src/bin/eolian_cxx/eolian_cxx.cc
@@ -33,6 +33,7 @@ struct options_type
33{ 33{
34 std::vector<std::string> include_dirs; 34 std::vector<std::string> include_dirs;
35 std::vector<std::string> in_files; 35 std::vector<std::string> in_files;
36 mutable Eolian_Unit const* unit;
36 std::string out_file; 37 std::string out_file;
37 bool main_header; 38 bool main_header;
38 39
@@ -69,7 +70,7 @@ generate(const Eolian_Class* klass, eolian_cxx::options_type const& opts)
69 else 70 else
70 header_impl_file_name.insert(header_impl_file_name.size(), ".impl"); 71 header_impl_file_name.insert(header_impl_file_name.size(), ".impl");
71 72
72 efl::eolian::grammar::attributes::klass_def klass_def(klass); 73 efl::eolian::grammar::attributes::klass_def klass_def(klass, opts.unit);
73 std::vector<efl::eolian::grammar::attributes::klass_def> klasses{klass_def}; 74 std::vector<efl::eolian::grammar::attributes::klass_def> klasses{klass_def};
74 std::vector<efl::eolian::grammar::attributes::klass_def> forward_klasses{klass_def}; 75 std::vector<efl::eolian::grammar::attributes::klass_def> forward_klasses{klass_def};
75 76
@@ -82,11 +83,11 @@ generate(const Eolian_Class* klass, eolian_cxx::options_type const& opts)
82 auto klass_name_function 83 auto klass_name_function
83 = [&] (efl::eolian::grammar::attributes::klass_name const& name) 84 = [&] (efl::eolian::grammar::attributes::klass_name const& name)
84 { 85 {
85 Eolian_Class const* klass = get_klass(name); 86 Eolian_Class const* klass = get_klass(name, opts.unit);
86 assert(klass); 87 assert(klass);
87 c_headers.insert(eolian_class_file_get(klass) + std::string(".h")); 88 c_headers.insert(eolian_class_file_get(klass) + std::string(".h"));
88 cpp_headers.insert(eolian_class_file_get(klass) + std::string(".hh")); 89 cpp_headers.insert(eolian_class_file_get(klass) + std::string(".hh"));
89 efl::eolian::grammar::attributes::klass_def cls{klass}; 90 efl::eolian::grammar::attributes::klass_def cls{klass, opts.unit};
90 if(std::find(forward_klasses.begin(), forward_klasses.end(), cls) == forward_klasses.end()) 91 if(std::find(forward_klasses.begin(), forward_klasses.end(), cls) == forward_klasses.end())
91 forward_klasses.push_back(cls); 92 forward_klasses.push_back(cls);
92 }; 93 };
@@ -116,17 +117,17 @@ generate(const Eolian_Class* klass, eolian_cxx::options_type const& opts)
116 for(efl::eina::iterator<const char> inherit_iterator ( ::eolian_class_inherits_get(klass)) 117 for(efl::eina::iterator<const char> inherit_iterator ( ::eolian_class_inherits_get(klass))
117 , inherit_last; inherit_iterator != inherit_last; ++inherit_iterator) 118 , inherit_last; inherit_iterator != inherit_last; ++inherit_iterator)
118 { 119 {
119 Eolian_Class const* inherit = ::eolian_class_get_by_name(&*inherit_iterator); 120 Eolian_Class const* inherit = ::eolian_class_get_by_name(opts.unit, &*inherit_iterator);
120 c_headers.insert(eolian_class_file_get(inherit) + std::string(".h")); 121 c_headers.insert(eolian_class_file_get(inherit) + std::string(".h"));
121 cpp_headers.insert(eolian_class_file_get(inherit) + std::string(".hh")); 122 cpp_headers.insert(eolian_class_file_get(inherit) + std::string(".hh"));
122 efl::eolian::grammar::attributes::klass_def klass{inherit}; 123 efl::eolian::grammar::attributes::klass_def klass{inherit, opts.unit};
123 if(std::find(forward_klasses.begin(), forward_klasses.end(), klass) == forward_klasses.end()) 124 if(std::find(forward_klasses.begin(), forward_klasses.end(), klass) == forward_klasses.end())
124 forward_klasses.push_back(klass); 125 forward_klasses.push_back(klass);
125 126
126 klass_function(inherit); 127 klass_function(inherit);
127 } 128 }
128 129
129 efl::eolian::grammar::attributes::klass_def klass_def(klass); 130 efl::eolian::grammar::attributes::klass_def klass_def(klass, opts.unit);
130 for(auto&& f : klass_def.functions) 131 for(auto&& f : klass_def.functions)
131 { 132 {
132 variant_function(f.return_type); 133 variant_function(f.return_type);
@@ -212,7 +213,7 @@ run(options_type const& opts)
212 const Eolian_Class *klass = NULL; 213 const Eolian_Class *klass = NULL;
213 char* dup = strdup(opts.in_files[0].c_str()); 214 char* dup = strdup(opts.in_files[0].c_str());
214 char* base = basename(dup); 215 char* base = basename(dup);
215 klass = ::eolian_class_get_by_file(base); 216 klass = ::eolian_class_get_by_file(NULL, base);
216 free(dup); 217 free(dup);
217 if (klass) 218 if (klass)
218 { 219 {
@@ -236,15 +237,20 @@ run(options_type const& opts)
236 237
237 for(auto&& name : opts.in_files) 238 for(auto&& name : opts.in_files)
238 { 239 {
239 bool b = ::eolian_file_parse(name.c_str()); 240 Eolian_Unit const* unit = ::eolian_file_parse(name.c_str());
240 if(!b) 241 if(!unit)
241 { 242 {
242 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain) 243 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
243 << "Failed parsing: " << name << "."; 244 << "Failed parsing: " << name << ".";
244 } 245 }
246 else
247 {
248 if(!opts.unit)
249 opts.unit = unit;
250 }
245 char* dup = strdup(name.c_str()); 251 char* dup = strdup(name.c_str());
246 char* base = basename(dup); 252 char* base = basename(dup);
247 Eolian_Class const* klass = ::eolian_class_get_by_file(base); 253 Eolian_Class const* klass = ::eolian_class_get_by_file(unit, base);
248 free(dup); 254 free(dup);
249 if (klass) 255 if (klass)
250 { 256 {
diff --git a/src/lib/eolian_cxx/grammar/implementation_include_directive.hpp b/src/lib/eolian_cxx/grammar/implementation_include_directive.hpp
index 6c2631ab80..f82d84b9ea 100644
--- a/src/lib/eolian_cxx/grammar/implementation_include_directive.hpp
+++ b/src/lib/eolian_cxx/grammar/implementation_include_directive.hpp
@@ -20,7 +20,7 @@ struct implementation_include_directive_generator
20 bool generate(OutputIterator sink, attributes::klass_def const& cls, Context const& ctx) const 20 bool generate(OutputIterator sink, attributes::klass_def const& cls, Context const& ctx) const
21 { 21 {
22 return as_generator("#include \"" << string << ".impl.hh\"\n") 22 return as_generator("#include \"" << string << ".impl.hh\"\n")
23 .generate(sink, std::string(eolian_class_file_get(get_klass(get_klass_name(cls)))), add_lower_case_context(ctx)); 23 .generate(sink, std::string(eolian_class_file_get(get_klass(get_klass_name(cls, unit_from_context(ctx))))), add_lower_case_context(ctx));
24 } 24 }
25 template <typename OutputIterator, typename Context> 25 template <typename OutputIterator, typename Context>
26 bool generate(OutputIterator sink, std::string const& cls, Context const& ctx) const 26 bool generate(OutputIterator sink, std::string const& cls, Context const& ctx) const
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index 17254e64ca..9629c70715 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -210,11 +210,11 @@ struct type_def
210 type_def(variant_type original_type, std::string c_type) 210 type_def(variant_type original_type, std::string c_type)
211 : original_type(original_type), c_type(c_type) {} 211 : original_type(original_type), c_type(c_type) {}
212 212
213 type_def(Eolian_Type const* eolian_type) 213 type_def(Eolian_Type const* eolian_type, Eolian_Unit const* unit)
214 { 214 {
215 set(eolian_type); 215 set(eolian_type, unit);
216 } 216 }
217 void set(Eolian_Type const* eolian_type); 217 void set(Eolian_Type const* eolian_type, Eolian_Unit const* unit);
218}; 218};
219 219
220struct get_qualifier_visitor 220struct get_qualifier_visitor
@@ -242,7 +242,7 @@ inline bool operator!=(type_def const& lhs, type_def const& rhs)
242 242
243type_def const void_ {attributes::regular_type_def{"void", {qualifier_info::is_none, {}}, {}}, "void"}; 243type_def const void_ {attributes::regular_type_def{"void", {qualifier_info::is_none, {}}, {}}, "void"};
244 244
245inline void type_def::set(Eolian_Type const* eolian_type) 245inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* unit)
246{ 246{
247 c_type = ::eolian_type_c_type_get(eolian_type); 247 c_type = ::eolian_type_c_type_get(eolian_type);
248 // ::eina_stringshare_del(stringshare); // this crashes 248 // ::eina_stringshare_del(stringshare); // this crashes
@@ -264,7 +264,7 @@ inline void type_def::set(Eolian_Type const* eolian_type)
264 break; 264 break;
265 case EOLIAN_TYPE_CLASS: 265 case EOLIAN_TYPE_CLASS:
266 { 266 {
267 Eolian_Class const* klass = eolian_type_class_get(eolian_type); 267 Eolian_Class const* klass = eolian_type_class_get(unit, eolian_type);
268 original_type = klass_name(klass, {qualifiers(eolian_type), {}}); 268 original_type = klass_name(klass, {qualifiers(eolian_type), {}});
269 } 269 }
270 break; 270 break;
@@ -275,7 +275,7 @@ inline void type_def::set(Eolian_Type const* eolian_type)
275 Eolian_Type const* stp = eolian_type_base_type_get(eolian_type); 275 Eolian_Type const* stp = eolian_type_base_type_get(eolian_type);
276 while (stp) 276 while (stp)
277 { 277 {
278 complex.subtypes.push_back({stp}); 278 complex.subtypes.push_back({stp, unit});
279 stp = eolian_type_next_type_get(stp); 279 stp = eolian_type_next_type_get(stp);
280 } 280 }
281 original_type = complex; 281 original_type = complex;
@@ -329,8 +329,8 @@ struct parameter_def
329 329
330 parameter_def(parameter_direction direction, type_def type, std::string param_name, std::string c_type) 330 parameter_def(parameter_direction direction, type_def type, std::string param_name, std::string c_type)
331 : direction(std::move(direction)), type(std::move(type)), param_name(std::move(param_name)), c_type(std::move(c_type)) {} 331 : direction(std::move(direction)), type(std::move(type)), param_name(std::move(param_name)), c_type(std::move(c_type)) {}
332 parameter_def(Eolian_Function_Parameter const* param) 332 parameter_def(Eolian_Function_Parameter const* param, Eolian_Unit const* unit)
333 : type( ::eolian_parameter_type_get(param)) 333 : type( ::eolian_parameter_type_get(param), unit)
334 , param_name( ::eolian_parameter_name_get(param)) 334 , param_name( ::eolian_parameter_name_get(param))
335 , c_type( ::eolian_type_c_type_get(::eolian_parameter_type_get(param))) 335 , c_type( ::eolian_type_c_type_get(::eolian_parameter_type_get(param)))
336 { 336 {
@@ -415,19 +415,19 @@ struct function_def
415 , std::string c_name, bool is_beta) 415 , std::string c_name, bool is_beta)
416 : return_type(return_type), name(name), parameters(parameters), c_name(c_name), is_beta(is_beta) {} 416 : return_type(return_type), name(name), parameters(parameters), c_name(c_name), is_beta(is_beta) {}
417 function_def() = default; 417 function_def() = default;
418 function_def( ::Eolian_Function const* function, Eolian_Function_Type type) 418 function_def( ::Eolian_Function const* function, Eolian_Function_Type type, Eolian_Unit const* unit)
419 : return_type(void_) 419 : return_type(void_)
420 { 420 {
421 Eolian_Type const* r_type = ::eolian_function_return_type_get(function, type); 421 Eolian_Type const* r_type = ::eolian_function_return_type_get(function, type);
422 name = ::eolian_function_name_get(function); 422 name = ::eolian_function_name_get(function);
423 if(r_type) 423 if(r_type)
424 return_type.set(r_type); 424 return_type.set(r_type, unit);
425 if(type == EOLIAN_METHOD) 425 if(type == EOLIAN_METHOD)
426 { 426 {
427 for(efl::eina::iterator<Eolian_Function_Parameter> param_iterator ( ::eolian_function_parameters_get(function)) 427 for(efl::eina::iterator<Eolian_Function_Parameter> param_iterator ( ::eolian_function_parameters_get(function))
428 , param_last; param_iterator != param_last; ++param_iterator) 428 , param_last; param_iterator != param_last; ++param_iterator)
429 { 429 {
430 parameters.push_back(&*param_iterator); 430 parameters.push_back({&*param_iterator, unit});
431 } 431 }
432 } 432 }
433 else if(type == EOLIAN_PROP_GET || type == EOLIAN_PROP_SET) 433 else if(type == EOLIAN_PROP_GET || type == EOLIAN_PROP_SET)
@@ -440,14 +440,14 @@ struct function_def
440 ( ::eolian_property_keys_get(function, type)) 440 ( ::eolian_property_keys_get(function, type))
441 , param_last; param_iterator != param_last; ++param_iterator) 441 , param_last; param_iterator != param_last; ++param_iterator)
442 { 442 {
443 parameters.push_back(&*param_iterator); 443 parameters.push_back({&*param_iterator, unit});
444 } 444 }
445 std::vector<parameter_def> values; 445 std::vector<parameter_def> values;
446 for(efl::eina::iterator<Eolian_Function_Parameter> param_iterator 446 for(efl::eina::iterator<Eolian_Function_Parameter> param_iterator
447 ( ::eolian_property_values_get(function, type)) 447 ( ::eolian_property_values_get(function, type))
448 , param_last; param_iterator != param_last; ++param_iterator) 448 , param_last; param_iterator != param_last; ++param_iterator)
449 { 449 {
450 values.push_back(&*param_iterator); 450 values.push_back({&*param_iterator, unit});
451 } 451 }
452 452
453 if(!r_type && type == EOLIAN_PROP_GET && values.size() == 1) 453 if(!r_type && type == EOLIAN_PROP_GET && values.size() == 1)
@@ -546,8 +546,8 @@ struct event_def
546 546
547 event_def(type_def type, std::string name, std::string c_name, bool beta, bool protect) 547 event_def(type_def type, std::string name, std::string c_name, bool beta, bool protect)
548 : type(type), name(name), c_name(c_name), beta(beta), protect(protect) {} 548 : type(type), name(name), c_name(c_name), beta(beta), protect(protect) {}
549 event_def(Eolian_Event const* event) 549 event_def(Eolian_Event const* event, Eolian_Unit const* unit)
550 : type( ::eolian_event_type_get(event) ? ::eolian_event_type_get(event) : eina::optional<type_def>{}) 550 : type( ::eolian_event_type_get(event) ? eina::optional<type_def>{{::eolian_event_type_get(event), unit}} : eina::optional<type_def>{})
551 , name( ::eolian_event_name_get(event)) 551 , name( ::eolian_event_name_get(event))
552 , c_name( ::eolian_event_c_name_get(event)) 552 , c_name( ::eolian_event_c_name_get(event))
553 , beta( ::eolian_event_is_beta(event)) 553 , beta( ::eolian_event_is_beta(event))
@@ -622,7 +622,7 @@ struct klass_def
622 , namespaces(namespaces) 622 , namespaces(namespaces)
623 , functions(functions), inherits(inherits), type(type) 623 , functions(functions), inherits(inherits), type(type)
624 {} 624 {}
625 klass_def(Eolian_Class const* klass) 625 klass_def(Eolian_Class const* klass, Eolian_Unit const* unit)
626 { 626 {
627 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_class_namespaces_get(klass)) 627 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_class_namespaces_get(klass))
628 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator) 628 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator)
@@ -640,19 +640,19 @@ struct klass_def
640 try { 640 try {
641 if(! ::eolian_function_is_legacy_only(function, EOLIAN_PROP_GET) 641 if(! ::eolian_function_is_legacy_only(function, EOLIAN_PROP_GET)
642 && ::eolian_function_scope_get(function, EOLIAN_PROP_GET) != EOLIAN_SCOPE_PRIVATE) 642 && ::eolian_function_scope_get(function, EOLIAN_PROP_GET) != EOLIAN_SCOPE_PRIVATE)
643 functions.push_back({function, EOLIAN_PROP_GET}); 643 functions.push_back({function, EOLIAN_PROP_GET, unit});
644 } catch(std::exception const&) {} 644 } catch(std::exception const&) {}
645 try { 645 try {
646 if(! ::eolian_function_is_legacy_only(function, EOLIAN_PROP_SET) 646 if(! ::eolian_function_is_legacy_only(function, EOLIAN_PROP_SET)
647 && ::eolian_function_scope_get(function, EOLIAN_PROP_SET) != EOLIAN_SCOPE_PRIVATE) 647 && ::eolian_function_scope_get(function, EOLIAN_PROP_SET) != EOLIAN_SCOPE_PRIVATE)
648 functions.push_back({function, EOLIAN_PROP_SET}); 648 functions.push_back({function, EOLIAN_PROP_SET, unit});
649 } catch(std::exception const&) {} 649 } catch(std::exception const&) {}
650 } 650 }
651 else 651 else
652 try { 652 try {
653 if(! ::eolian_function_is_legacy_only(function, type) 653 if(! ::eolian_function_is_legacy_only(function, type)
654 && ::eolian_function_scope_get(function, type) != EOLIAN_SCOPE_PRIVATE) 654 && ::eolian_function_scope_get(function, type) != EOLIAN_SCOPE_PRIVATE)
655 functions.push_back({function, type}); 655 functions.push_back({function, type, unit});
656 } catch(std::exception const&) {} 656 } catch(std::exception const&) {}
657 } 657 }
658 for(efl::eina::iterator<Eolian_Function const> eolian_functions ( ::eolian_class_functions_get(klass, EOLIAN_METHOD)) 658 for(efl::eina::iterator<Eolian_Function const> eolian_functions ( ::eolian_class_functions_get(klass, EOLIAN_METHOD))
@@ -663,7 +663,7 @@ struct klass_def
663 Eolian_Function_Type type = eolian_function_type_get(function); 663 Eolian_Function_Type type = eolian_function_type_get(function);
664 if(! ::eolian_function_is_legacy_only(function, EOLIAN_METHOD) 664 if(! ::eolian_function_is_legacy_only(function, EOLIAN_METHOD)
665 && ::eolian_function_scope_get(function, type) != EOLIAN_SCOPE_PRIVATE) 665 && ::eolian_function_scope_get(function, type) != EOLIAN_SCOPE_PRIVATE)
666 functions.push_back({function, EOLIAN_METHOD}); 666 functions.push_back({function, EOLIAN_METHOD, unit});
667 } catch(std::exception const&) {} 667 } catch(std::exception const&) {}
668 } 668 }
669 std::function<void(Eolian_Class const*)> inherit_algo = 669 std::function<void(Eolian_Class const*)> inherit_algo =
@@ -672,7 +672,7 @@ struct klass_def
672 for(efl::eina::iterator<const char> inherit_iterator ( ::eolian_class_inherits_get(klass)) 672 for(efl::eina::iterator<const char> inherit_iterator ( ::eolian_class_inherits_get(klass))
673 , inherit_last; inherit_iterator != inherit_last; ++inherit_iterator) 673 , inherit_last; inherit_iterator != inherit_last; ++inherit_iterator)
674 { 674 {
675 Eolian_Class const* inherit = ::eolian_class_get_by_name(&*inherit_iterator); 675 Eolian_Class const* inherit = ::eolian_class_get_by_name(unit, &*inherit_iterator);
676 inherits.insert({inherit, {}}); 676 inherits.insert({inherit, {}});
677 inherit_algo(inherit); 677 inherit_algo(inherit);
678 } 678 }
@@ -699,7 +699,7 @@ struct klass_def
699 , event_last; event_iterator != event_last; ++event_iterator) 699 , event_last; event_iterator != event_last; ++event_iterator)
700 { 700 {
701 try { 701 try {
702 events.push_back(&*event_iterator); 702 events.push_back({&*event_iterator, unit});
703 } catch(std::exception const&) {} 703 } catch(std::exception const&) {}
704 } 704 }
705 } 705 }
@@ -711,7 +711,7 @@ inline klass_name get_klass_name(klass_def const& klass)
711 return {klass.namespaces, klass.eolian_name, {qualifier_info::is_none, {}}, klass.type}; 711 return {klass.namespaces, klass.eolian_name, {qualifier_info::is_none, {}}, klass.type};
712} 712}
713 713
714inline Eolian_Class const* get_klass(klass_name const& klass_name_) 714inline Eolian_Class const* get_klass(klass_name const& klass_name_, Eolian_Unit const* unit)
715{ 715{
716 std::string klass_name; 716 std::string klass_name;
717 if(!as_generator(*(string << ".") << string) 717 if(!as_generator(*(string << ".") << string)
@@ -720,7 +720,7 @@ inline Eolian_Class const* get_klass(klass_name const& klass_name_)
720 , context_null{})) 720 , context_null{}))
721 return nullptr; 721 return nullptr;
722 else 722 else
723 return ::eolian_class_get_by_name(klass_name.c_str()); 723 return ::eolian_class_get_by_name(unit, klass_name.c_str());
724} 724}
725 725
726inline std::vector<std::string> cpp_namespaces(std::vector<std::string> namespaces) 726inline std::vector<std::string> cpp_namespaces(std::vector<std::string> namespaces)