summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2018-01-13 19:24:17 -0200
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2018-01-13 19:24:17 -0200
commitf8e36dce771c6ff0b44e4714437dc143b9354c9a (patch)
tree815281cd0f8f361503b6efc1380a6fff486c80a1
parentedbf07cd1f0eb1129598b23d7e156c6600e348c6 (diff)
eolian-js: Add lazy grouping feature
-rw-r--r--src/Makefile_Efl_Js.am40
-rw-r--r--src/bin/eolian_js/main.cc382
-rw-r--r--src/bindings/cxx/eina_cxx/eina_aligned_union.hh10
-rw-r--r--src/bindings/cxx/eina_cxx/eina_tpl_char_switch.hh1005
-rw-r--r--src/bindings/cxx/eina_cxx/eina_tuple.hh166
-rw-r--r--src/bindings/js/efl_js/efl_js.cc156
-rw-r--r--src/bindings/js/eo_js/eo_js_list.hh160
-rw-r--r--src/bindings/js/eo_js/eo_js_namespace_tree.hh291
8 files changed, 2084 insertions, 126 deletions
diff --git a/src/Makefile_Efl_Js.am b/src/Makefile_Efl_Js.am
index addf072949..e253fa70e4 100644
--- a/src/Makefile_Efl_Js.am
+++ b/src/Makefile_Efl_Js.am
@@ -56,33 +56,16 @@ bin_efl_js_eflv8js_LDADD = \
56 56
57endif 57endif
58 58
59# @echo @ECHO_E@ "#ifdef HAVE_CONFIG_H" > $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc 59ordered_generated_js_bindings = $(sort $(GENERATED_JS_BINDINGS))
60# @echo @ECHO_E@ "#include \"config.h\"" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc 60
61# @echo @ECHO_E@ "#include \"elementary_config.h\"" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc 61AM_V_EOLJS_LINK = $(am__v_EOLJS_LINK_@AM_V@)
62# @echo @ECHO_E@ "#endif\n" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc 62am__v_EOLJS_LINK_ = $(am__v_EOLJS_LINK_@AM_DEFAULT_V@)
63# @echo @ECHO_E@ "#include <Efl.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc 63am__v_EOLJS__LINK_0 = @echo " EOLJS_LINK " $@;
64# @echo @ECHO_E@ "#include <Efl_Config.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc 64
65# @echo @ECHO_E@ "#include <Ecore.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc 65bindings/js/efl_js/eolian_js_bindings.js.hh: $(GENERATED_JS_BINDINGS:%.eo.js.cc=%.eo) $(_EOLIAN_JS_DEP)
66# @echo @ECHO_E@ "#include <Eo.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc 66 $(AM_V_EOLJS_LINK)$(EOLIAN_JS) -l $(EOLIAN_FLAGS) -o $@ $(filter %.eo, $(^))
67# @echo @ECHO_E@ "#include <Ecore_Con.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc 67
68# @echo @ECHO_E@ "#include <Ecore_Audio.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc 68CLEANFILES += bindings/js/efl_js/eolian_js_bindings.js.hh
69# @echo @ECHO_E@ "#include <Evas.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc
70# @echo @ECHO_E@ "#include <Edje.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc
71# @echo @ECHO_E@ "#include <Ecore_Con_Eet.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc
72# @echo @ECHO_E@ "#include <Emotion.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc
73# @echo @ECHO_E@ "#define ELM_INTERNAL_API_ARGESFSDFEFC" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc
74# @echo @ECHO_E@ "#include <Elementary.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc
75# @echo @ECHO_E@ "extern \"C\" {" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc
76# @echo @ECHO_E@ "#include <elm_widget.h>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc
77# @echo @ECHO_E@ "}\n" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc
78# @echo @ECHO_E@ "#include <Eina_Js.hh>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc
79# @echo @ECHO_E@ "#include <Eo_Js.hh>" >> $(top_builddir)/src/bindings/js/efl_js/eolian_js_bindings.cc
80
81bindings/js/efl_js/eolian_js_bindings.hh: $(GENERATED_JS_BINDINGS)
82 @echo @ECHO_E@ "" > $@
83 @for i in $(GENERATED_JS_BINDINGS); do echo "#include <$$i>" >> $@; done
84
85CLEANFILES += bindings/js/efl_js/eolian_js_bindings.hh
86 69
87## Install Ecore-JS headers 70## Install Ecore-JS headers
88installed_ecorejsheadersdir = $(includedir)/ecore-js-@VMAJ@ 71installed_ecorejsheadersdir = $(includedir)/ecore-js-@VMAJ@
@@ -164,12 +147,13 @@ bindings/js/eio_js/eio_js.cc \
164bindings/js/efl_js/efl_js.cc \ 147bindings/js/efl_js/efl_js.cc \
165bindings/js/ethumb_js/ethumb_js_client.cc 148bindings/js/ethumb_js/ethumb_js_client.cc
166 149
167bindings/js/efl_js/bindings_js_efl_js_libefl_js_la-efl_js.l$(OBJEXT): bindings/js/efl_js/eolian_js_bindings.hh 150bindings/js/efl_js/bindings_js_efl_js_libefl_js_la-efl_js.l$(OBJEXT): bindings/js/efl_js/eolian_js_bindings.js.hh
168 151
169bindings/js/efl_js/efl_js.cc $(bindings_js_efl_js_libefl_js_la_SOURCES): $(ecore_eolian_cxx_public_hh) $(ecore_eolian_cxx_public_impl_hh) $(eo_eolian_cxx_public_hh) $(eo_eolian_cxx_public_impl_hh) $(efl_eolian_cxx_public_hh) $(efl_eolian_cxx_public_impl_hh) lib/ecore/Ecore.eo.hh 152bindings/js/efl_js/efl_js.cc $(bindings_js_efl_js_libefl_js_la_SOURCES): $(ecore_eolian_cxx_public_hh) $(ecore_eolian_cxx_public_impl_hh) $(eo_eolian_cxx_public_hh) $(eo_eolian_cxx_public_impl_hh) $(efl_eolian_cxx_public_hh) $(efl_eolian_cxx_public_impl_hh) lib/ecore/Ecore.eo.hh
170 153
171bindings_js_efl_js_libefl_js_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ 154bindings_js_efl_js_libefl_js_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
172-I$(top_srcdir)/src/lib/efl \ 155-I$(top_srcdir)/src/lib/efl \
156-I$(top_builddir)/src/bindings/js/efl_js \
173-I$(top_builddir)/src/lib/efl/interfaces/ \ 157-I$(top_builddir)/src/lib/efl/interfaces/ \
174-I$(top_builddir)/src/lib/evas/canvas/ \ 158-I$(top_builddir)/src/lib/evas/canvas/ \
175-I$(top_builddir)/src/lib/evas/gesture/ \ 159-I$(top_builddir)/src/lib/evas/gesture/ \
diff --git a/src/bin/eolian_js/main.cc b/src/bin/eolian_js/main.cc
index 4921a58525..a68e7cbb16 100644
--- a/src/bin/eolian_js/main.cc
+++ b/src/bin/eolian_js/main.cc
@@ -24,6 +24,7 @@
24#include <cstdlib> 24#include <cstdlib>
25#include <vector> 25#include <vector>
26#include <set> 26#include <set>
27#include <map>
27 28
28namespace eolian { namespace js { 29namespace eolian { namespace js {
29 30
@@ -438,6 +439,8 @@ int main(int argc, char** argv)
438 439
439 std::vector<std::string> include_paths; 440 std::vector<std::string> include_paths;
440 std::string out_file, in_file; 441 std::string out_file, in_file;
442 std::vector<std::string> in_files;
443 bool linking = false;
441 444
442 efl::eina::eina_init eina_init; 445 efl::eina::eina_init eina_init;
443 struct eolian_init 446 struct eolian_init
@@ -452,9 +455,10 @@ int main(int argc, char** argv)
452 { "out-file", required_argument, 0, 'o' }, 455 { "out-file", required_argument, 0, 'o' },
453 { "version", no_argument, 0, 'v' }, 456 { "version", no_argument, 0, 'v' },
454 { "help", no_argument, 0, 'h' }, 457 { "help", no_argument, 0, 'h' },
458 { "link", no_argument, 0, 'l' },
455 { 0, 0, 0, 0 } 459 { 0, 0, 0, 0 }
456 }; 460 };
457 const char* options = "I:D:o:c:arvh"; 461 const char* options = "I:D:o:c:arvhl";
458 462
459 // get command line options 463 // get command line options
460 int c, idx; 464 int c, idx;
@@ -463,6 +467,7 @@ int main(int argc, char** argv)
463 if (c == 'I') 467 if (c == 'I')
464 { 468 {
465 include_paths.push_back(optarg); 469 include_paths.push_back(optarg);
470 std::cout << "-I" << optarg << std::endl;
466 } 471 }
467 else if (c == 'o') 472 else if (c == 'o')
468 { 473 {
@@ -483,114 +488,327 @@ int main(int argc, char** argv)
483 // _print_version(); 488 // _print_version();
484 // if (argc == 2) exit(EXIT_SUCCESS); 489 // if (argc == 2) exit(EXIT_SUCCESS);
485 } 490 }
491 else if(c == 'l')
492 {
493 linking = true;
494 }
486 } 495 }
487 496
488 if (optind == argc-1) 497 std::cout << "optind " << optind << " argc " << argc << std::endl;
498
499 std::ofstream os (out_file.c_str());
500 if(!os.is_open())
489 { 501 {
490 in_file = argv[optind]; 502 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "Couldn't open output file " << out_file;
503 return -1;
491 } 504 }
492 505
493 Eolian* eolian = eolian_new(); 506 EINA_CXX_DOM_LOG_DBG(eolian::js::domain) << "output was opened";
494 Eolian_Unit* eolian_unit = static_cast<Eolian_Unit*>(static_cast<void*>(eolian)); 507
495 508 if(!linking)
496 // Add include paths to eolian library 509 {
497 for(auto src : include_paths) 510 Eolian* eolian = eolian_new();
498 if (!::eolian_directory_scan(eolian, src.c_str())) 511 Eolian_Unit* eolian_unit = static_cast<Eolian_Unit*>(static_cast<void*>(eolian));
512
513 if (optind == argc-1)
514 {
515 in_file = argv[optind];
516 }
517
518 // Add include paths to eolian library
519 for(auto src : include_paths)
520 if (!::eolian_directory_scan(eolian, src.c_str()))
521 {
522 EINA_CXX_DOM_LOG_WARN(eolian::js::domain)
523 << "Couldn't load eolian from '" << src << "'.";
524 }
525 if (!::eolian_all_eot_files_parse(eolian))
499 { 526 {
500 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) 527 EINA_CXX_DOM_LOG_WARN(eolian::js::domain)
501 << "Couldn't load eolian from '" << src << "'."; 528 << "Eolian failed parsing eot files";
529 assert(false && "Error parsing eot files");
530 }
531 if (!::eolian_file_parse(eolian, in_file.c_str()))
532 {
533 EINA_CXX_DOM_LOG_WARN(eolian::js::domain)
534 << "Failed parsing: " << in_file << ".";
535 assert(false && "Error parsing input file");
502 } 536 }
503 if (!::eolian_all_eot_files_parse(eolian))
504 {
505 EINA_CXX_DOM_LOG_WARN(eolian::js::domain)
506 << "Eolian failed parsing eot files";
507 assert(false && "Error parsing eot files");
508 }
509 if (!::eolian_file_parse(eolian, in_file.c_str()))
510 {
511 EINA_CXX_DOM_LOG_WARN(eolian::js::domain)
512 << "Failed parsing: " << in_file << ".";
513 assert(false && "Error parsing input file");
514 }
515 537
516 // Create filename path for output 538 // Create filename path for output
517 std::string file_basename; 539 std::string file_basename;
518 const Eolian_Class *klass = NULL; 540 const Eolian_Class *klass = NULL;
519 {
520 char* dup = strdup(in_file.c_str());
521 char *bn = basename(dup);
522 klass = ::eolian_class_get_by_file(eolian_unit, bn);
523 file_basename = bn;
524 free(dup);
525 }
526 if(!klass)
527 { 541 {
528 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "could not find any class defined in this eo file"; 542 char* dup = strdup(in_file.c_str());
529 return -1; 543 char *bn = basename(dup);
544 klass = ::eolian_class_get_by_file(eolian_unit, bn);
545 file_basename = bn;
546 free(dup);
530 } 547 }
548 if(!klass)
549 {
550 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "could not find any class defined in this eo file";
551 return -1;
552 }
531 553
532 std::ofstream os (out_file.c_str()); 554
533 if(!os.is_open()) 555 std::ostream_iterator<char> iterator = std::ostream_iterator<char>(os);
534 { 556
535 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "Couldn't open output file " << out_file; 557 // probably not eot file
536 return -1; 558 if(klass)
559 {
560 os << "#if !defined(EFL_JAVASCRIPT_EOLIAN_GENERATE_REGISTER_STRUCT)\n";
561 // function to iterate through all inheritance class
562 std::function<void(Eolian_Class const*, std::function<void(Eolian_Class const*)>)>
563 recurse_inherits
564 = [&] (Eolian_Class const* klass, std::function<void(Eolian_Class const*)> function)
565 {
566 for(efl::eina::iterator<const char> first ( ::eolian_class_inherits_get(klass))
567 , last; first != last; ++first)
568 {
569 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << &*first << std::endl;
570 Eolian_Class const* base = ::eolian_class_get_by_name(eolian_unit, &*first);
571 if(base)
572 {
573 function(base);
574 recurse_inherits(base, function);
575 }
576 }
577 };
578
579 os << "extern \"C\" {\n\n";
580
581 auto includes_fun = [&os] (Eolian_Class const* klass)
582 {
583 os << "#include <" << eolian_class_file_get(klass) << ".h>\n\n";
584 };
585 // generate include for all inheritance
586 recurse_inherits(klass, includes_fun);
587 os << "#include <" << eolian_class_file_get(klass) << ".h>\n\n";
588
589 os << "}\n\n";
590
591 using efl::eolian::grammar::attributes::unused;
592 using efl::eolian::grammar::context_null;
593 efl::eolian::grammar::attributes::klass_def klass_def(klass, eolian_unit);
594 if (!eolian::js::grammar::class_registration.generate(iterator, klass_def, context_null{}))
595 {
596 throw std::runtime_error("Failed to generate class");
597 }
598
599 os << "#else\n";
600 // if (!eolian::js::grammar::call_registration.generate(iterator, klass_def, context_null{}))
601 // {
602 // throw std::runtime_error("Failed to generate class");
603 // }
604 os << "#endif\n";
605 }
537 } 606 }
607 else
608 {
609 Eolian* eolian = eolian_new();
610 Eolian_Unit* eolian_unit = static_cast<Eolian_Unit*>(static_cast<void*>(eolian));
611
612 for(auto src : include_paths)
613 if (!::eolian_directory_scan(eolian, src.c_str()))
614 {
615 EINA_CXX_DOM_LOG_WARN(eolian::js::domain)
616 << "Couldn't load eolian from '" << src << "'.";
617 }
618
619 int optional_index = optind;
620 while (optional_index != argc)
621 {
622 std::cout << "opening " << argv[optional_index] << std::endl;
623 if (!::eolian_file_parse(eolian, argv[optional_index]))
624 {
625 std::cout
626 << "Failed parsing: " << argv[optional_index] << "." << std::endl;
627 EINA_CXX_DOM_LOG_WARN(eolian::js::domain)
628 << "Failed parsing: " << argv[optional_index] << ".";
629 assert(false && "Error parsing input file");
630 }
631 // in_files.push_back(argv[optind]);
632 optional_index++;
633 }
538 634
539 EINA_CXX_DOM_LOG_DBG(eolian::js::domain) << "output was opened"; 635 // if(!::eolian_all_eo_files_parse(eolian))
636 // {
637 // EINA_CXX_DOM_LOG_WARN(eolian::js::domain)
638 // << "Eolian failed parsing eo files";
639 // assert(false && "Error parsing eot files");
640 // }
641 if (!::eolian_all_eot_files_parse(eolian))
642 {
643 EINA_CXX_DOM_LOG_WARN(eolian::js::domain)
644 << "Eolian failed parsing eot files";
645 assert(false && "Error parsing eot files");
646 }
540 647
541 648 // ns -> items
542 std::ostream_iterator<char> iterator = std::ostream_iterator<char>(os); 649 std::map<std::string, std::set<std::string>> all_names;
543 650
544 // probably not eot file 651 efl::eina::iterator<Eolian_Class const> klasses (eolian_all_classes_get(eolian_unit));
545 if(klass) 652 for(;klasses != efl::eina::iterator<Eolian_Class const>{}
546 { 653 ;++klasses)
547 os << "#ifndef EFL_JAVASCRIPT_EOLIAN_GENERATE_REGISTER_CALL\n";
548 // function to iterate through all inheritance class
549 std::function<void(Eolian_Class const*, std::function<void(Eolian_Class const*)>)>
550 recurse_inherits
551 = [&] (Eolian_Class const* klass, std::function<void(Eolian_Class const*)> function)
552 { 654 {
553 for(efl::eina::iterator<const char> first ( ::eolian_class_inherits_get(klass)) 655 std::string outer_namespace; // starts with global
554 , last; first != last; ++first) 656 std::string name = ::eolian_class_full_name_get(&*klasses);
657
658 auto iterator_old = name.begin();
659 auto iterator = std::find(iterator_old, name.end(), '.');
660 while(iterator != name.end())
555 { 661 {
556 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << &*first << std::endl; 662 std::string namespace_name(iterator_old, iterator);
557 Eolian_Class const* base = ::eolian_class_get_by_name(eolian_unit, &*first); 663
558 if(base) 664 // std::cout << "outer namespace " << outer_namespace << " name " << namespace_name << std::endl;
665
666 all_names[outer_namespace].insert(namespace_name);
667 iterator_old = std::next(iterator);
668 if(outer_namespace.empty())
669 outer_namespace = namespace_name;
670 else
559 { 671 {
560 function(base); 672 outer_namespace += '.';
561 recurse_inherits(base, function); 673 outer_namespace += namespace_name;
562 } 674 }
675 // std::cout << "before loop outer namespace " << outer_namespace << " name " << namespace_name << std::endl;
676 iterator = std::find(iterator_old, name.end(), '.');
563 } 677 }
564 }; 678 all_names[outer_namespace].insert({iterator_old, iterator});
679 }
565 680
566 os << "extern \"C\" {\n\n"; 681 // os << "typedef efl::eo::js::namespace_object"
567 682 for(auto&& item : all_names)
568 auto includes_fun = [&os] (Eolian_Class const* klass)
569 { 683 {
570 os << "#include <" << eolian_class_file_get(klass) << ".h>\n\n"; 684 std::vector<std::string> classes;
571 }; 685
572 // generate include for all inheritance 686 std::cout << "namespace " << item.first << std::endl;
573 recurse_inherits(klass, includes_fun); 687
574 os << "#include <" << eolian_class_file_get(klass) << ".h>\n\n"; 688 for(auto&& object : item.second)
689 {
690 std::string ns = item.first;
691 if(!ns.empty())
692 ns += '.';
693 if(all_names.find(ns + object) == all_names.end()) // class name
694 classes.push_back(object);
695 }
696
697 std::cout << "generating classes structs" << std::endl;
698 //if(!classes.empty())
699 {
700 std::string classes_struct_name = item.first;
701 std::transform(classes_struct_name.begin()
702 , classes_struct_name.end()
703 , classes_struct_name.begin()
704 , [] (char c)
705 {
706 c = ::tolower(c);
707 if(c == '.')
708 c = '_';
709 return c;
710 });
711 os << "struct " << classes_struct_name << "_classes\n"
712 << "{\n"
713 << " typedef efl::eo::js::list\n"
714 " <\n";
715
716 auto cls_iterator = classes.begin();
717 while(cls_iterator != classes.end())
718 {
719 auto&& cls = *cls_iterator;
720 os << "::efl::eo::js::class_object<efl::eo::js::name<";
721 auto char_iterator = cls.begin();
722 while(char_iterator != cls.end())
723 {
724 os << "'" << *char_iterator << "'";
725 if(std::next(char_iterator) != cls.end())
726 os << ", ";
727 ++char_iterator;
728 }
729 os << ">, std::false_type>";
730 cls_iterator++;
731 if(cls_iterator != classes.end())
732 os << ", ";
733 }
734 os << "> type;\n};\n";
735
736 ///
737 }
738 }
575 739
576 os << "}\n\n"; 740 for(auto item_iterator = all_names.rbegin()
741 , last_item_iterator = all_names.rend()
742 ;item_iterator != last_item_iterator
743 ;++item_iterator)
744 {
745 auto&& item = *item_iterator;
746
747 std::vector<std::string> namespaces;
748 //bool is_there_classes = false;
577 749
578 using efl::eolian::grammar::attributes::unused; 750 std::cout << "namespace " << item.first << std::endl;
579 using efl::eolian::grammar::context_null;
580 efl::eolian::grammar::attributes::klass_def klass_def(klass, eolian_unit);
581 if (!eolian::js::grammar::class_registration.generate(iterator, klass_def, context_null{}))
582 {
583 throw std::runtime_error("Failed to generate class");
584 }
585 751
586 os << "#else\n"; 752 for(auto&& object : item.second)
587 // if (!eolian::js::grammar::call_registration.generate(iterator, klass_def, context_null{})) 753 {
588 // { 754 std::cout << "searching if " << object << " is a namespace" << std::endl;
589 // throw std::runtime_error("Failed to generate class"); 755 std::string ns = item.first;
590 // } 756 if(!ns.empty())
591 os << "#endif\n"; 757 ns += '.';
758 if(all_names.find(ns + object) != all_names.end()) // namespace name
759 namespaces.push_back(object);
760 }
761
762 //if(!namespaces.empty())
763 {
764 std::string classes_struct_name = item.first;
765 auto fix_name = [] (std::string& name)
766 {
767 std::transform(name.begin()
768 , name.end()
769 , name.begin()
770 , [] (char c)
771 {
772 c = ::tolower(c);
773 if(c == '.')
774 c = '_';
775 return c;
776 });
777 };
778 fix_name(classes_struct_name);
779
780 os << "struct " << classes_struct_name << "_namespaces\n"
781 << "{\n"
782 << " typedef efl::eo::js::list\n"
783 " <\n";
784
785 std::cout << "namespace " << classes_struct_name << " has " << namespaces.size()
786 << " namespaces" << std::endl;
787
788 auto namespace_iterator = namespaces.begin();
789 while(namespace_iterator != namespaces.end())
790 {
791 auto&& namesp = *namespace_iterator;
792 os << "::efl::eo::js::namespace_object<efl::eo::js::name<";
793 auto char_iterator = namesp.begin();
794 while(char_iterator != namesp.end())
795 {
796 os << "'" << *char_iterator << "'";
797 if(std::next(char_iterator) != namesp.end())
798 os << ", ";
799 ++char_iterator;
800 }
801 std::string full_name = (item.first == "" ? "" : item.first + '.') + namesp;
802 fix_name(full_name);
803 os << ">, " << full_name << "_classes, " << full_name << "_namespaces>";
804 namespace_iterator++;
805 if(namespace_iterator != namespaces.end())
806 os << ", ";
807 }
808 os << "> type;\n};\n";
809 }
810 }
592 } 811 }
593
594 // std::vector<Eolian_Function const*> constructor_functions; 812 // std::vector<Eolian_Function const*> constructor_functions;
595 // std::vector<Eolian_Function const*> normal_functions; 813 // std::vector<Eolian_Function const*> normal_functions;
596 814
diff --git a/src/bindings/cxx/eina_cxx/eina_aligned_union.hh b/src/bindings/cxx/eina_cxx/eina_aligned_union.hh
index eabe878408..b61a70ad3c 100644
--- a/src/bindings/cxx/eina_cxx/eina_aligned_union.hh
+++ b/src/bindings/cxx/eina_cxx/eina_aligned_union.hh
@@ -4,13 +4,13 @@
4namespace efl { namespace eina { namespace _mpl { 4namespace efl { namespace eina { namespace _mpl {
5 5
6template <std::size_t...Numbers> 6template <std::size_t...Numbers>
7struct max; 7struct max_c;
8 8
9template <std::size_t A0> 9template <std::size_t A0>
10struct max<A0> : std::integral_constant<std::size_t, A0> {}; 10struct max_c<A0> : std::integral_constant<std::size_t, A0> {};
11 11
12template <std::size_t A0, std::size_t A1, std::size_t...Args> 12template <std::size_t A0, std::size_t A1, std::size_t...Args>
13struct max<A0, A1, Args...> : max<(A0 > A1 ? A0 : A1), Args...> {}; 13struct max_c<A0, A1, Args...> : max_c<(A0 > A1 ? A0 : A1), Args...> {};
14 14
15} 15}
16 16
@@ -18,10 +18,10 @@ struct max<A0, A1, Args...> : max<(A0 > A1 ? A0 : A1), Args...> {};
18template <std::size_t Min, typename...Args> 18template <std::size_t Min, typename...Args>
19struct aligned_union 19struct aligned_union
20{ 20{
21 static constexpr std::size_t alignment_value = _mpl::max<alignof(Args)...>::value; 21 static constexpr std::size_t alignment_value = _mpl::max_c<alignof(Args)...>::value;
22 22
23 typedef typename std::aligned_storage 23 typedef typename std::aligned_storage
24 < _mpl::max<Min, sizeof(Args)...>::value 24 < _mpl::max_c<Min, sizeof(Args)...>::value
25 , alignment_value >::type type; 25 , alignment_value >::type type;
26}; 26};
27 27
diff --git a/src/bindings/cxx/eina_cxx/eina_tpl_char_switch.hh b/src/bindings/cxx/eina_cxx/eina_tpl_char_switch.hh
new file mode 100644
index 0000000000..cc76bc5f04
--- /dev/null
+++ b/src/bindings/cxx/eina_cxx/eina_tpl_char_switch.hh
@@ -0,0 +1,1005 @@
1#ifndef EINA_TPL_SWITCH_HH_
2#define EINA_TPL_SWITCH_HH_
3
4namespace efl { namespace eina { namespace _mpl {
5
6template <char...Chars>
7struct tpl_char_switch;
8
9template <>
10struct tpl_char_switch<>
11{
12 template <typename F, typename Fail>
13 constexpr void operator()(char c, Fail const fail) const
14 {
15 fail(c);
16 }
17};
18
19template <char C0>
20struct tpl_char_switch<C0>
21{
22 template <typename F, typename Fail, typename...Args>
23 constexpr void operator()(char c, Fail const fail, Args&&...args) const
24 {
25 if(c == C0)
26 typename F::template apply<C0>::type{}(args...);
27 else
28 fail(c);
29 }
30};
31
32template <char C0, char C1>
33struct tpl_char_switch<C0, C1>
34{
35 template <typename F, typename Fail, typename...Args>
36 constexpr void operator()(char c, Fail const fail, Args&&...args) const
37 {
38 switch(c)
39 {
40 case C0:
41 typename F::template apply<C0>::type{}(args...);
42 break;
43 case C1:
44 typename F::template apply<C1>::type{}(args...);
45 break;
46 default:
47 fail(c);
48 };
49 }
50};
51
52template <char C0, char C1, char C2>
53struct tpl_char_switch<C0, C1, C2>
54{
55 template <typename F, typename Fail, typename...Args>
56 constexpr void operator()(char c, Fail const fail, Args&&...args) const
57 {
58 switch(c)
59 {
60 case C0:
61 typename F::template apply<C0>::type{}(args...);
62 break;
63 case C1:
64 typename F::template apply<C1>::type{}(args...);
65 break;
66 case C2:
67 typename F::template apply<C2>::type{}(args...);
68 break;
69 default:
70 fail(c);
71 };
72 }
73};
74
75template <char C0, char C1, char C2, char C3>
76struct tpl_char_switch<C0, C1, C2, C3>
77{
78 template <typename F, typename Fail, typename...Args>
79 constexpr void operator()(char c, Fail const fail, Args&&...args) const
80 {
81 switch(c)
82 {
83 case C0:
84 typename F::template apply<C0>::type{}(args...);
85 break;
86 case C1:
87 typename F::template apply<C1>::type{}(args...);
88 break;
89 case C2:
90 typename F::template apply<C2>::type{}(args...);
91 break;
92 case C3:
93 typename F::template apply<C3>::type{}(args...);
94 break;
95 default:
96 fail(c);
97 };
98 }
99};
100
101template <char C0, char C1, char C2, char C3, char C4>
102struct tpl_char_switch<C0, C1, C2, C3, C4>
103{
104 template <typename F, typename Fail, typename...Args>
105 constexpr void operator()(char c, Fail const fail, Args&&...args) const
106 {
107 switch(c)
108 {
109 case C0:
110 typename F::template apply<C0>::type{}(args...);
111 break;
112 case C1:
113 typename F::template apply<C1>::type{}(args...);
114 break;
115 case C2:
116 typename F::template apply<C2>::type{}(args...);
117 break;
118 case C3:
119 typename F::template apply<C3>::type{}(args...);
120 break;
121 case C4:
122 typename F::template apply<C4>::type{}(args...);
123 break;
124 default:
125 fail(c);
126 };
127 }
128};
129
130template <char C0, char C1, char C2, char C3, char C4, char C5>
131struct tpl_char_switch<C0, C1, C2, C3, C4, C5>
132{
133 template <typename F, typename Fail, typename...Args>
134 constexpr void operator()(char c, Fail const fail, Args&&...args) const
135 {
136 switch(c)
137 {
138 case C0:
139 typename F::template apply<C0>::type{}(args...);
140 break;
141 case C1:
142 typename F::template apply<C1>::type{}(args...);
143 break;
144 case C2:
145 typename F::template apply<C2>::type{}(args...);
146 break;
147 case C3:
148 typename F::template apply<C3>::type{}(args...);
149 break;
150 case C4:
151 typename F::template apply<C4>::type{}(args...);
152 break;
153 case C5:
154 typename F::template apply<C5>::type{}(args...);
155 break;
156 default:
157 fail(c);
158 };
159 }
160};
161
162template <char C0, char C1, char C2, char C3, char C4, char C5, char C6>
163struct tpl_char_switch<C0, C1, C2, C3, C4, C5, C6>
164{
165 template <typename F, typename Fail, typename...Args>
166 constexpr void operator()(char c, Fail const fail, Args&&...args) const
167 {
168 switch(c)
169 {
170 case C0:
171 typename F::template apply<C0>::type{}(args...);
172 break;
173 case C1:
174 typename F::template apply<C1>::type{}(args...);
175 break;
176 case C2:
177 typename F::template apply<C2>::type{}(args...);
178 break;
179 case C3:
180 typename F::template apply<C3>::type{}(args...);
181 break;
182 case C4:
183 typename F::template apply<C4>::type{}(args...);
184 break;
185 case C5:
186 typename F::template apply<C5>::type{}(args...);
187 break;
188 case C6:
189 typename F::template apply<C6>::type{}(args...);
190 break;
191 default:
192 fail(c);
193 };
194 }
195};
196
197template <char C0, char C1, char C2, char C3, char C4, char C5, char C6, char C7>
198struct tpl_char_switch<C0, C1, C2, C3, C4, C5, C6, C7>
199{
200 template <typename F, typename Fail, typename...Args>
201 constexpr void operator()(char c, Fail const fail, Args&&...args) const
202 {
203 switch(c)
204 {
205 case C0:
206 typename F::template apply<C0>::type{}(args...);
207 break;
208 case C1:
209 typename F::template apply<C1>::type{}(args...);
210 break;
211 case C2:
212 typename F::template apply<C2>::type{}(args...);
213 break;
214 case C3:
215 typename F::template apply<C3>::type{}(args...);
216 break;
217 case C4:
218 typename F::template apply<C4>::type{}(args...);
219 break;
220 case C5:
221 typename F::template apply<C5>::type{}(args...);
222 break;
223 case C6:
224 typename F::template apply<C6>::type{}(args...);
225 break;
226 case C7:
227 typename F::template apply<C7>::type{}(args...);
228 break;
229 default:
230 fail(c);
231 };
232 }
233};
234
235template <char C0, char C1, char C2, char C3, char C4, char C5, char C6, char C7, char C8>
236struct tpl_char_switch<C0, C1, C2, C3, C4, C5, C6, C7, C8>
237{
238 template <typename F, typename Fail, typename...Args>
239 constexpr void operator()(char c, Fail const fail, Args&&...args) const
240 {
241 switch(c)
242 {
243 case C0:
244 typename F::template apply<C0>::type{}(args...);
245 break;
246 case C1:
247 typename F::template apply<C1>::type{}(args...);
248 break;
249 case C2:
250 typename F::template apply<C2>::type{}(args...);
251 break;
252 case C3:
253 typename F::template apply<C3>::type{}(args...);
254 break;
255 case C4:
256 typename F::template apply<C4>::type{}(args...);
257 break;
258 case C5:
259 typename F::template apply<C5>::type{}(args...);
260 break;
261 case C6:
262 typename F::template apply<C6>::type{}(args...);
263 break;
264 case C7:
265 typename F::template apply<C7>::type{}(args...);
266 break;
267 case C8:
268 typename F::template apply<C8>::type{}(args...);
269 break;
270 default:
271 fail(c);
272 };
273 }
274};
275
276template <char C0, char C1, char C2, char C3, char C4, char C5, char C6, char C7, char C8, char C9>
277struct tpl_char_switch<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>
278{
279 template <typename F, typename Fail, typename...Args>
280 constexpr void operator()(char c, Fail const fail, Args&&...args) const
281 {
282 switch(c)
283 {
284 case C0:
285 typename F::template apply<C0>::type{}(args...);
286 break;
287 case C1:
288 typename F::template apply<C1>::type{}(args...);
289 break;
290 case C2:
291 typename F::template apply<C2>::type{}(args...);
292 break;
293 case C3:
294 typename F::template apply<C3>::type{}(args...);
295 break;
296 case C4:
297 typename F::template apply<C4>::type{}(args...);
298 break;
299 case C5:
300 typename F::template apply<C5>::type{}(args...);
301 break;
302 case C6:
303 typename F::template apply<C6>::type{}(args...);
304 break;
305 case C7:
306 typename F::template apply<C7>::type{}(args...);
307 break;
308 case C8:
309 typename F::template apply<C8>::type{}(args...);
310 break;
311 case C9:
312 typename F::template apply<C9>::type{}(args...);
313 break;
314 default:
315 fail(c);
316 };
317 }
318};
319
320template <char C0, char C1, char C2, char C3, char C4, char C5, char C6, char C7, char C8, char C9, char C10>
321struct tpl_char_switch<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10>
322{
323 template <typename F, typename Fail, typename...Args>
324 constexpr void operator()(char c, Fail const fail, Args&&...args) const
325 {
326 switch(c)
327 {
328 case C0:
329 typename F::template apply<C0>::type{}(args...);
330 break;
331 case C1:
332 typename F::template apply<C1>::type{}(args...);
333 break;
334 case C2:
335 typename F::template apply<C2>::type{}(args...);
336 break;
337 case C3:
338 typename F::template apply<C3>::type{}(args...);
339 break;
340 case C4:
341 typename F::template apply<C4>::type{}(args...);
342 break;
343 case C5:
344 typename F::template apply<C5>::type{}(args...);
345 break;
346 case C6:
347 typename F::template apply<C6>::type{}(args...);
348 break;
349 case C7:
350 typename F::template apply<C7>::type{}(args...);
351 break;
352 case C8:
353 typename F::template apply<C8>::type{}(args...);
354 break;
355 case C9:
356 typename F::template apply<C9>::type{}(args...);
357 break;
358 case C10:
359 typename F::template apply<C10>::type{}(args...);
360 break;
361 default:
362 fail(c);
363 };
364 }
365};
366
367template <char C0, char C1, char C2, char C3, char C4, char C5, char C6, char C7, char C8, char C9, char C10, char C11>
368struct tpl_char_switch<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11>
369{
370 template <typename F, typename Fail, typename...Args>
371 constexpr void operator()(char c, Fail const fail, Args&&...args) const
372 {
373 switch(c)
374 {
375 case C0:
376 typename F::template apply<C0>::type{}(args...);
377 break;
378 case C1:
379 typename F::template apply<C1>::type{}(args...);
380 break;
381 case C2:
382 typename F::template apply<C2>::type{}(args...);
383 break;
384 case C3:
385 typename F::template apply<C3>::type{}(args...);
386 break;
387 case C4:
388 typename F::template apply<C4>::type{}(args...);
389 break;
390 case C5:
391 typename F::template apply<C5>::type{}(args...);
392 break;
393 case C6:
394 typename F::template apply<C6>::type{}(args...);
395 break;
396 case C7:
397 typename F::template apply<C7>::type{}(args...);
398 break;
399 case C8:
400 typename F::template apply<C8>::type{}(args...);
401 break;
402 case C9:
403 typename F::template apply<C9>::type{}(args...);
404 break;
405 case C10:
406 typename F::template apply<C10>::type{}(args...);
407 break;
408 case C11:
409 typename F::template apply<C11>::type{}(args...);
410 break;
411 default:
412 fail(c);
413 };
414 }
415};
416
417template <char C0, char C1, char C2, char C3, char C4, char C5, char C6, char C7, char C8, char C9, char C10, char C11, char C12>
418struct tpl_char_switch<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12>
419{
420 template <typename F, typename Fail, typename...Args>
421 constexpr void operator()(char c, Fail const fail, Args&&...args) const
422 {
423 switch(c)
424 {
425 case C0:
426 typename F::template apply<C0>::type{}(args...);
427 break;
428 case C1:
429 typename F::template apply<C1>::type{}(args...);
430 break;
431 case C2:
432 typename F::template apply<C2>::type{}(args...);
433 break;
434 case C3:
435 typename F::template apply<C3>::type{}(args...);
436 break;
437 case C4:
438 typename F::template apply<C4>::type{}(args...);
439 break;
440 case C5:
441 typename F::template apply<C5>::type{}(args...);
442 break;
443 case C6:
444 typename F::template apply<C6>::type{}(args...);
445 break;
446 case C7:
447 typename F::template apply<C7>::type{}(args...);
448 break;
449 case C8:
450 typename F::template apply<C8>::type{}(args...);
451 break;
452 case C9:
453 typename F::template apply<C9>::type{}(args...);
454 break;
455 case C10:
456 typename F::template apply<C10>::type{}(args...);
457 break;
458 case C11:
459 typename F::template apply<C11>::type{}(args...);
460 break;
461 case C12:
462 typename F::template apply<C12>::type{}(args...);
463 break;
464 default:
465 fail(c);
466 };
467 }
468};
469
470template <char C0, char C1, char C2, char C3, char C4, char C5, char C6, char C7, char C8, char C9, char C10, char C11, char C12, char C13>
471struct tpl_char_switch<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13>
472{
473 template <typename F, typename Fail, typename...Args>
474 constexpr void operator()(char c, Fail const fail, Args&&...args) const
475 {
476 switch(c)
477 {
478 case C0:
479 typename F::template apply<C0>::type{}(args...);
480 break;
481 case C1:
482 typename F::template apply<C1>::type{}(args...);
483 break;
484 case C2:
485 typename F::template apply<C2>::type{}(args...);
486 break;
487 case C3:
488 typename F::template apply<C3>::type{}(args...);
489 break;
490 case C4:
491 typename F::template apply<C4>::type{}(args...);
492 break;
493 case C5:
494 typename F::template apply<C5>::type{}(args...);
495 break;
496 case C6:
497 typename F::template apply<C6>::type{}(args...);
498 break;
499 case C7:
500 typename F::template apply<C7>::type{}(args...);
501 break;
502 case C8:
503 typename F::template apply<C8>::type{}(args...);
504 break;
505 case C9:
506 typename F::template apply<C9>::type{}(args...);
507 break;
508 case C10:
509 typename F::template apply<C10>::type{}(args...);
510 break;
511 case C11:
512 typename F::template apply<C11>::type{}(args...);
513 break;
514 case C12:
515 typename F::template apply<C12>::type{}(args...);
516 break;
517 case C13:
518 typename F::template apply<C13>::type{}(args...);
519 break;
520 default:
521 fail(c);
522 };
523 }
524};
525
526template <char C0, char C1, char C2, char C3, char C4, char C5, char C6, char C7, char C8, char C9, char C10, char C11, char C12, char C13, char C14>
527struct tpl_char_switch<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14>
528{
529 template <typename F, typename Fail, typename...Args>
530 constexpr void operator()(char c, Fail const fail, Args&&...args) const
531 {
532 switch(c)
533 {
534 case C0:
535 typename F::template apply<C0>::type{}(args...);
536 break;
537 case C1:
538 typename F::template apply<C1>::type{}(args...);
539 break;
540 case C2:
541 typename F::template apply<C2>::type{}(args...);
542 break;
543 case C3:
544 typename F::template apply<C3>::type{}(args...);
545 break;
546 case C4:
547 typename F::template apply<C4>::type{}(args...);
548 break;
549 case C5:
550 typename F::template apply<C5>::type{}(args...);
551 break;
552 case C6:
553 typename F::template apply<C6>::type{}(args...);
554 break;
555 case C7:
556 typename F::template apply<C7>::type{}(args...);
557 break;
558 case C8:
559 typename F::template apply<C8>::type{}(args...);
560 break;
561 case C9:
562 typename F::template apply<C9>::type{}(args...);
563 break;
564 case C10:
565 typename F::template apply<C10>::type{}(args...);
566 break;
567 case C11:
568 typename F::template apply<C11>::type{}(args...);
569 break;
570 case C12:
571 typename F::template apply<C12>::type{}(args...);
572 break;
573 case C13:
574 typename F::template apply<C13>::type{}(args...);
575 break;
576 case C14:
577 typename F::template apply<C14>::type{}(args...);
578 break;
579 default:
580 fail(c);
581 };
582 }
583};
584
585template <char C0, char C1, char C2, char C3, char C4, char C5, char C6, char C7, char C8, char C9, char C10, char C11, char C12, char C13, char C14, char C15>
586struct tpl_char_switch<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15>
587{
588 template <typename F, typename Fail, typename...Args>
589 constexpr void operator()(char c, Fail const fail, Args&&...args) const
590 {
591 switch(c)
592 {
593 case C0:
594 typename F::template apply<C0>::type{}(args...);
595 break;
596 case C1:
597 typename F::template apply<C1>::type{}(args...);
598 break;
599 case C2:
600 typename F::template apply<C2>::type{}(args...);
601 break;
602 case C3:
603 typename F::template apply<C3>::type{}(args...);
604 break;
605 case C4:
606 typename F::template apply<C4>::type{}(args...);
607 break;
608 case C5:
609 typename F::template apply<C5>::type{}(args...);
610 break;
611 case C6:
612 typename F::template apply<C6>::type{}(args...);
613 break;
614 case C7:
615 typename F::template apply<C7>::type{}(args...);
616 break;
617 case C8:
618 typename F::template apply<C8>::type{}(args...);
619 break;
620 case C9:
621 typename F::template apply<C9>::type{}(args...);
622 break;
623 case C10:
624 typename F::template apply<C10>::type{}(args...);
625 break;
626 case C11:
627 typename F::template apply<C11>::type{}(args...);
628 break;
629 case C12:
630 typename F::template apply<C12>::type{}(args...);
631 break;
632 case C13:
633 typename F::template apply<C13>::type{}(args...);
634 break;
635 case C14:
636 typename F::template apply<C14>::type{}(args...);
637 break;
638 case C15:
639 typename F::template apply<C15>::type{}(args...);
640 break;
641 default:
642 fail(c);
643 };
644 }
645};
646
647template <char C0, char C1, char C2, char C3, char C4, char C5, char C6, char C7, char C8, char C9, char C10, char C11, char C12, char C13, char C14, char C15, char C16>
648struct tpl_char_switch<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16>
649{
650 template <typename F, typename Fail, typename...Args>
651 constexpr void operator()(char c, Fail const fail, Args&&...args) const
652 {
653 switch(c)
654 {
655 case C0:
656 typename F::template apply<C0>::type{}(args...);
657 break;
658 case C1:
659 typename F::template apply<C1>::type{}(args...);
660 break;
661 case C2:
662 typename F::template apply<C2>::type{}(args...);
663 break;
664 case C3:
665 typename F::template apply<C3>::type{}(args...);
666 break;
667 case C4:
668 typename F::template apply<C4>::type{}(args...);
669 break;
670 case C5:
671 typename F::template apply<C5>::type{}(args...);
672 break;
673 case C6:
674 typename F::template apply<C6>::type{}(args...);
675 break;
676 case C7:
677 typename F::template apply<C7>::type{}(args...);
678 break;
679 case C8:
680 typename F::template apply<C8>::type{}(args...);
681 break;
682 case C9:
683 typename F::template apply<C9>::type{}(args...);
684 break;
685 case C10:
686 typename F::template apply<C10>::type{}(args...);
687 break;
688 case C11:
689 typename F::template apply<C11>::type{}(args...);
690 break;
691 case C12:
692 typename F::template apply<C12>::type{}(args...);
693 break;
694 case C13:
695 typename F::template apply<C13>::type{}(args...);
696 break;
697 case C14:
698 typename F::template apply<C14>::type{}(args...);
699 break;
700 case C15:
701 typename F::template apply<C15>::type{}(args...);
702 break;
703 case C16:
704 typename F::template apply<C16>::type{}(args...);
705 break;
706 default:
707 fail(c);
708 };
709 }
710};
711
712template <char C0, char C1, char C2, char C3, char C4, char C5, char C6, char C7, char C8, char C9, char C10, char C11, char C12, char C13, char C14, char C15, char C16, char C17>
713struct tpl_char_switch<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17>
714{
715 template <typename F, typename Fail, typename...Args>
716 constexpr void operator()(char c, Fail const fail, Args&&...args) const
717 {
718 switch(c)
719 {
720 case C0:
721 typename F::template apply<C0>::type{}(args...);
722 break;
723 case C1:
724 typename F::template apply<C1>::type{}(args...);
725 break;
726 case C2:
727 typename F::template apply<C2>::type{}(args...);
728 break;
729 case C3:
730 typename F::template apply<C3>::type{}(args...);
731 break;
732 case C4:
733 typename F::template apply<C4>::type{}(args...);
734 break;
735 case C5:
736 typename F::template apply<C5>::type{}(args...);
737 break;
738 case C6:
739 typename F::template apply<C6>::type{}(args...);
740 break;
741 case C7:
742 typename F::template apply<C7>::type{}(args...);
743 break;
744 case C8:
745 typename F::template apply<C8>::type{}(args...);
746 break;
747 case C9:
748 typename F::template apply<C9>::type{}(args...);
749 break;
750 case C10:
751 typename F::template apply<C10>::type{}(args...);
752 break;
753 case C11:
754 typename F::template apply<C11>::type{}(args...);
755 break;
756 case C12:
757 typename F::template apply<C12>::type{}(args...);
758 break;
759 case C13:
760 typename F::template apply<C13>::type{}(args...);
761 break;
762 case C14:
763 typename F::template apply<C14>::type{}(args...);
764 break;
765 case C15:
766 typename F::template apply<C15>::type{}(args...);
767 break;
768 case C16:
769 typename F::template apply<C16>::type{}(args...);
770 break;
771 case C17:
772 typename F::template apply<C17>::type{}(args...);
773 break;
774 default:
775 fail(c);
776 };
777 }
778};
779
780template <char C0, char C1, char C2, char C3, char C4, char C5, char C6, char C7, char C8, char C9, char C10, char C11, char C12, char C13, char C14, char C15, char C16, char C17, char C18>
781struct tpl_char_switch<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18>
782{
783 template <typename F, typename Fail, typename...Args>
784 constexpr void operator()(char c, Fail const fail, Args&&...args) const
785 {
786 switch(c)
787 {
788 case C0:
789 typename F::template apply<C0>::type{}(args...);
790 break;
791 case C1:
792 typename F::template apply<C1>::type{}(args...);
793 break;
794 case C2:
795 typename F::template apply<C2>::type{}(args...);
796 break;
797 case C3:
798 typename F::template apply<C3>::type{}(args...);
799 break;
800 case C4:
801 typename F::template apply<C4>::type{}(args...);
802 break;
803 case C5:
804 typename F::template apply<C5>::type{}(args...);
805 break;
806 case C6:
807 typename F::template apply<C6>::type{}(args...);
808 break;
809 case C7:
810 typename F::template apply<C7>::type{}(args...);
811 break;
812 case C8:
813 typename F::template apply<C8>::type{}(args...);
814 break;
815 case C9:
816 typename F::template apply<C9>::type{}(args...);
817 break;
818 case C10:
819 typename F::template apply<C10>::type{}(args...);
820 break;
821 case C11:
822 typename F::template apply<C11>::type{}(args...);
823 break;
824 case C12:
825 typename F::template apply<C12>::type{}(args...);
826 break;
827 case C13:
828 typename F::template apply<C13>::type{}(args...);
829 break;
830 case C14:
831 typename F::template apply<C14>::type{}(args...);
832 break;
833 case C15:
834 typename F::template apply<C15>::type{}(args...);
835 break;
836 case C16:
837 typename F::template apply<C16>::type{}(args...);
838 break;
839 case C17:
840 typename F::template apply<C17>::type{}(args...);
841 break;
842 case C18:
843 typename F::template apply<C18>::type{}(args...);
844 break;
845 default:
846 fail(c);
847 };
848 }
849};
850
851template <char C0, char C1, char C2, char C3, char C4, char C5, char C6, char C7, char C8, char C9, char C10, char C11, char C12, char C13, char C14, char C15, char C16, char C17, char C18, char C19>
852struct tpl_char_switch<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19>
853{
854 template <typename F, typename Fail, typename...Args>
855 constexpr void operator()(char c, Fail const fail, Args&&...args) const
856 {
857 switch(c)
858 {
859 case C0:
860 typename F::template apply<C0>::type{}(args...);
861 break;
862 case C1:
863 typename F::template apply<C1>::type{}(args...);
864 break;
865 case C2:
866 typename F::template apply<C2>::type{}(args...);
867 break;
868 case C3:
869 typename F::template apply<C3>::type{}(args...);
870 break;
871 case C4:
872 typename F::template apply<C4>::type{}(args...);
873 break;
874 case C5:
875 typename F::template apply<C5>::type{}(args...);
876 break;
877 case C6:
878 typename F::template apply<C6>::type{}(args...);
879 break;
880 case C7:
881 typename F::template apply<C7>::type{}(args...);
882 break;
883 case C8:
884 typename F::template apply<C8>::type{}(args...);
885 break;
886 case C9:
887 typename F::template apply<C9>::type{}(args...);
888 break;
889 case C10:
890 typename F::template apply<C10>::type{}(args...);
891 break;
892 case C11:
893 typename F::template apply<C11>::type{}(args...);
894 break;
895 case C12:
896 typename F::template apply<C12>::type{}(args...);
897 break;
898 case C13:
899 typename F::template apply<C13>::type{}(args...);
900 break;
901 case C14:
902 typename F::template apply<C14>::type{}(args...);
903 break;
904 case C15:
905 typename F::template apply<C15>::type{}(args...);
906 break;
907 case C16:
908 typename F::template apply<C16>::type{}(args...);
909 break;
910 case C17:
911 typename F::template apply<C17>::type{}(args...);
912 break;
913 case C18:
914 typename F::template apply<C18>::type{}(args...);
915 break;
916 case C19:
917 typename F::template apply<C19>::type{}(args...);
918 break;
919 default:
920 fail(c);
921 };
922 }
923};
924
925template <char C0, char C1, char C2, char C3, char C4, char C5, char C6, char C7, char C8, char C9, char C10, char C11, char C12, char C13, char C14, char C15, char C16, char C17, char C18, char C19, char C20>
926struct tpl_char_switch<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20>
927{
928 template <typename F, typename Fail, typename...Args>
929 constexpr void operator()(char c, Fail const fail, Args&&...args) const
930 {
931 switch(c)
932 {
933 case C0:
934 typename F::template apply<C0>::type{}(args...);
935 break;
936 case C1:
937 typename F::template apply<C1>::type{}(args...);
938 break;
939 case C2:
940 typename F::template apply<C2>::type{}(args...);
941 break;
942 case C3:
943 typename F::template apply<C3>::type{}(args...);
944 break;
945 case C4:
946 typename F::template apply<C4>::type{}(args...);
947 break;
948 case C5:
949 typename F::template apply<C5>::type{}(args...);
950 break;
951 case C6:
952 typename F::template apply<C6>::type{}(args...);
953 break;
954 case C7:
955 typename F::template apply<C7>::type{}(args...);
956 break;
957 case C8:
958 typename F::template apply<C8>::type{}(args...);
959 break;
960 case C9:
961 typename F::template apply<C9>::type{}(args...);
962 break;
963 case C10:
964 typename F::template apply<C10>::type{}(args...);
965 break;
966 case C11:
967 typename F::template apply<C11>::type{}(args...);
968 break;
969 case C12:
970 typename F::template apply<C12>::type{}(args...);
971 break;
972 case C13:
973 typename F::template apply<C13>::type{}(args...);
974 break;
975 case C14:
976 typename F::template apply<C14>::type{}(args...);
977 break;
978 case C15:
979 typename F::template apply<C15>::type{}(args...);
980 break;
981 case C16:
982 typename F::template apply<C16>::type{}(args...);
983 break;
984 case C17:
985 typename F::template apply<C17>::type{}(args...);
986 break;
987 case C18:
988 typename F::template apply<C18>::type{}(args...);
989 break;
990 case C19:
991 typename F::template apply<C19>::type{}(args...);
992 break;
993 case C20:
994 typename F::template apply<C20>::type{}(args...);
995 break;
996 default:
997 fail(c);
998 };
999 }
1000};
1001
1002
1003} } }
1004
1005#endif
diff --git a/src/bindings/cxx/eina_cxx/eina_tuple.hh b/src/bindings/cxx/eina_cxx/eina_tuple.hh
index 45545c3702..155742f234 100644
--- a/src/bindings/cxx/eina_cxx/eina_tuple.hh
+++ b/src/bindings/cxx/eina_cxx/eina_tuple.hh
@@ -83,6 +83,172 @@ struct tuple_find<T, std::tuple<T, Ts...> > : std::integral_constant<std::size_t
83template <typename T, typename T1, typename... Ts> 83template <typename T, typename T1, typename... Ts>
84struct tuple_find<T, std::tuple<T1, Ts...> > : std::integral_constant 84struct tuple_find<T, std::tuple<T1, Ts...> > : std::integral_constant
85 <std::size_t, 1 + tuple_find<T, std::tuple<Ts...> >::value> {}; 85 <std::size_t, 1 + tuple_find<T, std::tuple<Ts...> >::value> {};
86
87
88template <typename T, typename I, typename Fold>
89struct tuple_fold;
90
91template <typename I, typename Fold, typename...T>
92struct tuple_fold_aux;
93
94
95template <typename I, typename Fold, typename T>
96struct tuple_fold_aux<I, Fold, T> : Fold::template apply<I, T>
97{
98};
99
100template <typename I, typename Fold, typename T, typename...Ts>
101struct tuple_fold_aux<I, Fold, T, Ts...> : tuple_fold_aux
102 <typename Fold::template apply<I, T>::type
103 , Fold, Ts...>
104{
105
106};
107
108template <typename...T, typename I, typename Fold>
109struct tuple_fold<std::tuple<T...>, I, Fold> : tuple_fold_aux<I, Fold, T...>
110{};
111
112template <typename Pred, typename...Args>
113struct min;
114
115template <typename Pred, typename A0>
116struct min<Pred, A0>
117{
118 typedef A0 type;
119};
120
121template <typename Pred, typename A0, typename A1, typename...Args>
122struct min<Pred, A0, A1, Args...>
123{
124 typedef typename min<Pred, A1, Args...>::type rest_result;
125 typedef typename std::conditional
126 <Pred::template apply<A0, rest_result>::value
127 , A0, rest_result>::type type;
128};
129
130template <typename Pred, typename...Args>
131struct max;
132
133template <typename Pred, typename A0>
134struct max<Pred, A0>
135{
136 typedef A0 type;
137};
138
139template <typename Pred, typename A0, typename A1, typename...Args>
140struct max<Pred, A0, A1, Args...>
141{
142 typedef typename max<Pred, A1, Args...>::type rest_result;
143 typedef typename std::conditional
144 <Pred::template apply<rest_result, A0>::value
145 , A0, rest_result>::type type;
146};
147
148template <typename T, typename Removed>
149struct tuple_remove;
150
151template <typename Removed, typename Partial, typename...T>
152struct tuple_remove_aux;
153
154template <typename Removed, typename Partial>
155struct tuple_remove_aux<Removed, Partial>
156{
157 typedef Partial type;
158};
159
160template <typename Removed, typename...Partials, typename...T>
161struct tuple_remove_aux<Removed, std::tuple<Partials...>, Removed, T...>
162{
163 typedef std::tuple<Partials..., T...> type;
164};
165
166template <typename Removed, typename...Partials, typename A0, typename...T>
167struct tuple_remove_aux<Removed, std::tuple<Partials...>, A0, T...>
168 : tuple_remove_aux<Removed, std::tuple<Partials..., A0>, T...>
169{
170};
171
172template <typename...T, typename Removed>
173struct tuple_remove<std::tuple<T...>, Removed>
174 : tuple_remove_aux<Removed, std::tuple<>, T...>
175{
176};
177 ///
178
179template <typename T, typename Removed>
180struct tuple_remove_all;
181
182template <typename Removed, typename Partial, typename...T>
183struct tuple_remove_all_aux;
184
185template <typename Removed, typename Partial>
186struct tuple_remove_all_aux<Removed, Partial>
187{
188 typedef Partial type;
189};
190
191template <typename Removed, typename...Partials, typename...T>
192struct tuple_remove_all_aux<Removed, std::tuple<Partials...>, Removed, T...>
193 : tuple_remove_all_aux<Removed, std::tuple<Partials...>, T...>
194{
195};
196
197template <typename Removed, typename...Partials, typename A0, typename...T>
198struct tuple_remove_all_aux<Removed, std::tuple<Partials...>, A0, T...>
199 : tuple_remove_all_aux<Removed, std::tuple<Partials..., A0>, T...>
200{
201};
202
203template <typename...T, typename Removed>
204struct tuple_remove_all<std::tuple<T...>, Removed>
205 : tuple_remove_all_aux<Removed, std::tuple<>, T...>
206{
207};
208
209template <typename Tuple, typename Pred, typename Partial>
210struct tuple_sort_unique_aux;
211
212template <typename T0, typename...T, typename Pred, typename...Partials>
213struct tuple_sort_unique_aux<std::tuple<T0, T...>, Pred, std::tuple<Partials...>>
214{
215 typedef typename min<Pred, T0, T...>::type min_type;
216 typedef typename tuple_remove_all<std::tuple<T0, T...>, min_type>::type new_tuple_type;
217 typedef typename tuple_sort_unique_aux<new_tuple_type, Pred, std::tuple<Partials..., min_type>>::type type;
218};
219
220template <typename Pred, typename Partial>
221struct tuple_sort_unique_aux<std::tuple<>, Pred, Partial>
222{
223 typedef Partial type;
224};
225
226template <typename T, typename Pred>
227struct tuple_sort_unique
228 : tuple_sort_unique_aux<T, Pred, std::tuple<>>
229{};
230
231template <typename Tuple, typename Pred, typename Partial>
232struct tuple_sort_aux;
233
234template <typename T0, typename...T, typename Pred, typename...Partials>
235struct tuple_sort_aux<std::tuple<T0, T...>, Pred, std::tuple<Partials...>>
236{
237 typedef typename min<Pred, T0, T...>::type min_type;
238 typedef typename tuple_remove<std::tuple<T0, T...>, min_type>::type new_tuple_type;
239 typedef typename tuple_sort_aux<new_tuple_type, Pred, std::tuple<Partials..., min_type>>::type type;
240};
241
242template <typename Pred, typename Partial>
243struct tuple_sort_aux<std::tuple<>, Pred, Partial>
244{
245 typedef Partial type;
246};
247
248template <typename T, typename Pred>
249struct tuple_sort
250 : tuple_sort_aux<T, Pred, std::tuple<>>
251{};
86 252
87} } } 253} } }
88 254
diff --git a/src/bindings/js/efl_js/efl_js.cc b/src/bindings/js/efl_js/efl_js.cc
index b85574ae6c..a6cd5313f5 100644
--- a/src/bindings/js/efl_js/efl_js.cc
+++ b/src/bindings/js/efl_js/efl_js.cc
@@ -7,14 +7,26 @@
7#include <Efl.h> 7#include <Efl.h>
8#include <Efl_Config.h> 8#include <Efl_Config.h>
9#include <Ecore.h> 9#include <Ecore.h>
10#include <Ecore_Evas.h> 10#include <Eo.h>
11#include <Eina.hh> 11#include <Ecore_Con.h>
12#include <Ecore_Audio.h>
13#include <Evas.h>
14#include <Edje.h>
15#include <Ecore_Con_Eet.h>
16#include <Emotion.h>
17#define ELM_INTERNAL_API_ARGESFSDFEFC
18#include <Elementary.h>
19extern "C" {
20#include <elm_widget.h>
21}
22
12#include <Eina_Js.hh> 23#include <Eina_Js.hh>
13#include <Ecore_Js.hh> 24#include <Ecore_Js.hh>
14#include <Eio_Js.hh> 25#include <Eio_Js.hh>
15#include <Eldbus_Js.hh> 26#include <Eldbus_Js.hh>
16#include <Ethumb_Js.hh> 27#include <Ethumb_Js.hh>
17#include <Elementary.h> 28
29#include <eo_js_list.hh>
18 30
19#include <iostream> 31#include <iostream>
20 32
@@ -36,22 +48,142 @@
36# endif 48# endif
37#endif /* ! _WIN32 */ 49#endif /* ! _WIN32 */
38 50
51// include registrations
52#include <eo_js_namespace_tree.hh>
53
54struct object_registration_win
55{
56 void operator()(v8::Handle<v8::Object>, v8::Isolate*) const
57 {
58 std::cout << "called " << __func__ << std::endl;
59 }
60};
61
62
63struct object_registration_abc
64{
65 void operator()(v8::Handle<v8::Object>, v8::Isolate*) const
66 {
67 std::cout << "called " << __func__ << std::endl;
68 }
69};
70
39namespace { 71namespace {
40 72
73namespace _mpl {
74
75#include <eolian_js_bindings.js.hh>
76
77// struct efl_elementary_classes
78// {
79// typedef efl::eo::js::list
80// <efl::eo::js::class_object<efl::eo::js::name<'W', 'i', 'n'>, std::false_type>> type;
81// };
82
83// struct afl_elementary_classes
84// {
85// typedef efl::eo::js::list
86// <efl::eo::js::class_object<efl::eo::js::name<'W', 'i', 'n'>, std::false_type>> type;
87// };
88
89// struct efl_namespaces
90// {
91// typedef efl::eo::js::list
92// <efl::eo::js::namespace_object<efl::eo::js::name<'E', 'l', 'e', 'm', 'e', 'n', 't', 'a', 'r', 'y'>, std::false_type, efl_elementary_classes, efl::eo::js::empty>> type;
93// };
94
95// struct afl_namespaces
96// {
97// typedef efl::eo::js::list
98// <efl::eo::js::namespace_object<efl::eo::js::name<'E', 'l', 'e', 'm', 'e', 'n', 't', 'a', 'r', 'y'>, std::false_type, afl_elementary_classes, efl::eo::js::empty>> type;
99// };
100
101// struct global_namespaces
102// {
103// typedef efl::eo::js::list
104// <efl::eo::js::namespace_object<efl::eo::js::name<'E', 'f', 'l'>, std::false_type
105// , efl::eo::js::empty, efl_namespaces>
106// , efl::eo::js::namespace_object<efl::eo::js::name<'A', 'f', 'l'>, std::false_type
107// , efl::eo::js::empty, afl_namespaces>
108// > type;
109// };
110
111typedef efl::eo::js::namespace_object<efl::eo::js::name<>
112 , _classes, _namespaces
113 > global_namespace;
114
115}
116
117template <typename T>
118struct is_registered
119{
120 static bool yes;
121
122};
123
124template <typename T> bool is_registered<T>::yes = false;
125
126template <typename T>
127void namespace_accessor_get(v8::Local<v8::Name> name, v8::PropertyCallbackInfo<v8::Value> const& info);
128
129struct found_item
130{
131 efl::eina::string_view name;
132 v8::PropertyCallbackInfo<v8::Value> const& info;
133
134 template <typename Name, typename Classes, typename InnerNamespaces>
135 void operator()(efl::eo::js::namespace_object<Name, Classes, InnerNamespaces> const) const
136 {
137 typedef efl::eo::js::namespace_object<Name, Classes, InnerNamespaces> type;
138 std::cout << "returned namespace item" << std::endl;
139 if(is_registered<type>::yes)
140 {
141 std::cout << "Already registered" << std::endl;
142 }
143 else
144 {
145 std::cout << "Not registered yet" << std::endl;
146 is_registered<type>::yes = true;
147
148 v8::Isolate* isolate = info.GetIsolate();
149 v8::Local<v8::ObjectTemplate> ns_object = ::efl::eina::js::compatibility_new<v8::ObjectTemplate>(isolate);
150 ns_object->SetHandler({&namespace_accessor_get<type>});
151 auto obj = ns_object->NewInstance();
152 info.This()->Set(::efl::eina::js::compatibility_new<v8::String>(isolate, name.data())
153 , obj);
154
155 info.GetReturnValue().Set(obj);
156 }
157 }
158
159 template <typename Name, typename Registration>
160 void operator()(efl::eo::js::class_object<Name, Registration> const) const
161 {
162 //std::cout << "returned class item" << std::endl;
163 // must register
164 }
165};
166
167template <typename T>
41void namespace_accessor_get(v8::Local<v8::Name> name, v8::PropertyCallbackInfo<v8::Value> const& info) 168void namespace_accessor_get(v8::Local<v8::Name> name, v8::PropertyCallbackInfo<v8::Value> const& info)
42{ 169{
43 std::cout << "was it here?" << std::endl; 170 std::cout << "was it here?" << std::endl;
44 v8::Local<v8::String> name_str = name->ToString(); 171 v8::Local<v8::String> name_str = name->ToString();
45 assert(!!*name_str); 172 assert(!!*name_str);
46 v8::String::Utf8Value value(info.GetIsolate(), name_str); 173 v8::String::Utf8Value value(info.GetIsolate(), name_str);
47 std::cout << *value << std::endl; 174 std::cout << "searching for " << *value << std::endl;
48 175
49 if(info.Data()->IsNullOrUndefined()) 176 // if(info.Data()->IsNullOrUndefined())
50 { 177 // {
51 std::cout << "no value already assigned" << std::endl; 178 // std::cout << "no value already assigned" << std::endl;
52 } 179 // }
53 else 180 // else
54 std::cout << "value already assigned" << std::endl; 181 // std::cout << "value already assigned" << std::endl;
182
183 efl::eina::string_view string = *value;
184
185 efl::eo::js::search_separate(string, T{}
186 , found_item{string, info});
55} 187}
56 188
57} 189}
@@ -87,11 +219,13 @@ EAPI void init(v8::Local<v8::Object> exports, v8::Local<v8::Object> module)
87 { 219 {
88 auto evas = ::efl::eina::js::compatibility_new<v8::Object>(isolate); 220 auto evas = ::efl::eina::js::compatibility_new<v8::Object>(isolate);
89 ns_obj = ::efl::eina::js::compatibility_new<v8::ObjectTemplate>(isolate); 221 ns_obj = ::efl::eina::js::compatibility_new<v8::ObjectTemplate>(isolate);
90 ns_obj->SetHandler({&namespace_accessor_get}); 222 ns_obj->SetHandler({&namespace_accessor_get<_mpl::global_namespace>});
91 auto obj = ns_obj->NewInstance(); 223 auto obj = ns_obj->NewInstance();
92 obj->Set(::efl::eina::js::compatibility_new<v8::String>(isolate, "evas"), evas); 224 obj->Set(::efl::eina::js::compatibility_new<v8::String>(isolate, "evas"), evas);
93 module->Set(::efl::eina::js::compatibility_new<v8::String>(isolate, "exports"), obj); 225 module->Set(::efl::eina::js::compatibility_new<v8::String>(isolate, "exports"), obj);
94 } 226 }
227
228 // _mpl::foo();
95 } 229 }
96 catch(...) 230 catch(...)
97 { 231 {
diff --git a/src/bindings/js/eo_js/eo_js_list.hh b/src/bindings/js/eo_js/eo_js_list.hh
new file mode 100644
index 0000000000..0f8c4d6a45
--- /dev/null
+++ b/src/bindings/js/eo_js/eo_js_list.hh
@@ -0,0 +1,160 @@
1#ifndef EFL_EO_JS_LIST_HH
2#define EFL_EO_JS_LIST_HH
3
4namespace efl { namespace eo { namespace js {
5
6template <typename...Items>
7struct list
8{
9};
10
11template <typename List1, typename...Lists>
12struct list_concat;
13
14template <typename...List1>
15struct list_concat<list<List1...>>
16{
17 typedef list<List1...> type;
18};
19
20template <typename...List1, typename...List2>
21struct list_concat<list<List1...>, list<List2...>>
22{
23 typedef list<List1..., List2...> type;
24};
25
26template <typename...List1, typename...List2, typename...List3, typename...Lists>
27struct list_concat<list<List1...>, list<List2...>, list<List3...>, Lists...>
28 : list_concat<list<List1..., List2..., List3...>, Lists...>
29{};
30
31template <typename T, typename PartialList, typename...Items>
32struct list_remove_first_impl;
33
34template <typename T, typename...Partials, typename...Items>
35struct list_remove_first_impl<T, list<Partials...>, T, Items...>
36{
37 typedef list<Partials..., Items...> type;
38};
39
40template <typename T, typename PartialList>
41struct list_remove_first_impl<T, PartialList>
42{
43 typedef PartialList type;
44};
45
46template <typename T, typename...Partials, typename T0, typename...Items>
47struct list_remove_first_impl<T, list<Partials...>, T0, Items...>
48 : list_remove_first_impl<T, list<Partials..., T0>, Items...>
49{
50};
51
52template <typename T, typename List>
53struct list_remove_first;
54
55template <typename T, typename...Items>
56struct list_remove_first<T, list<Items...>>
57 : list_remove_first_impl<T, list<>, Items...>
58{
59};
60
61template <typename Pred, typename Partial, typename List>
62struct list_sort_impl;
63
64template <typename T>
65struct message_fail
66{
67 struct type {};
68 static_assert(std::is_same<T, type>::value);
69};
70
71template <typename Pred, typename...Partials, typename T0, typename...T>
72struct list_sort_impl<Pred, list<Partials...>, list<T0, T...>>
73{
74 typedef typename eina::_mpl::min<Pred, T0, T...>::type min_type;
75 typedef typename list_remove_first<min_type, list<T0, T...>>::type new_list_type;
76 typedef typename list_sort_impl<Pred, list<Partials..., min_type>, new_list_type>::type type;
77 //typedef typename message_fail<min_type>::type fail;
78};
79
80template <typename Pred, typename Partial>
81struct list_sort_impl<Pred, Partial, list<>>
82{
83 typedef Partial type;
84};
85
86template <typename Pred, typename List1, typename...Lists>
87struct list_sort
88 : list_sort_impl<Pred, list<>, typename list_concat<List1, Lists...>::type>
89{};
90
91template <typename T, typename I, typename Fold>
92struct list_fold;
93
94template <typename I, typename Fold, typename...T>
95struct list_fold_aux;
96
97
98template <typename I, typename Fold, typename T>
99struct list_fold_aux<I, Fold, T> : Fold::template apply<I, T>
100{
101};
102
103template <typename I, typename Fold, typename T, typename...Ts>
104struct list_fold_aux<I, Fold, T, Ts...> : list_fold_aux
105 <typename Fold::template apply<I, T>::type
106 , Fold, Ts...>
107{
108
109};
110
111template <typename...T, typename I, typename Fold>
112struct list_fold<list<T...>, I, Fold> : list_fold_aux<I, Fold, T...>
113{};
114
115/// find_if
116
117template <typename List, typename Pred, typename Enable = void>
118struct list_find_if_impl;
119
120template <typename I, typename...List, typename Pred>
121struct list_find_if_impl<list<I, List...>, Pred
122 , typename std::enable_if<(Pred::template apply<I>::type::value)>::type>
123{
124 typedef I type;
125};
126
127template <typename I, typename...List, typename Pred>
128struct list_find_if_impl<list<I, List...>, Pred
129 , typename std::enable_if<!(Pred::template apply<I>::type::value)>::type>
130 : list_find_if_impl<list<List...>, Pred>
131{
132};
133
134template <typename Pred>
135struct list_find_if_impl<list<>, Pred>
136{
137};
138
139template <typename List, typename Pred>
140struct list_find_if : list_find_if_impl<List, Pred>
141{
142};
143
144template <typename Pred, typename T>
145struct list_min;
146
147template <typename Pred, typename T>
148struct list_max;
149
150template <typename...T, typename Pred>
151struct list_min<Pred, list<T...>>
152 : eina::_mpl::min<Pred, T...> {};
153
154template <typename...T, typename Pred>
155struct list_max<Pred, list<T...>>
156 : eina::_mpl::max<Pred, T...> {};
157
158} } }
159
160#endif
diff --git a/src/bindings/js/eo_js/eo_js_namespace_tree.hh b/src/bindings/js/eo_js/eo_js_namespace_tree.hh
new file mode 100644
index 0000000000..ca0aec1988
--- /dev/null
+++ b/src/bindings/js/eo_js/eo_js_namespace_tree.hh
@@ -0,0 +1,291 @@
1#ifndef EFL_EO_JS_NAMESPACE_TREE_HH
2#define EFL_EO_JS_NAMESPACE_TREE_HH
3
4#include <eina_string_view.hh>
5
6#include <eina_tpl_char_switch.hh>
7
8#include <eo_js_list.hh>
9
10namespace efl { namespace eo { namespace js {
11
12struct empty
13{
14 typedef list<> type;
15};
16
17template <char...Chars>
18struct name
19{
20 static constexpr const int size = sizeof...(Chars);
21};
22
23template <typename T>
24struct name_size;
25
26template <char...Chars>
27struct name_size<name<Chars...>>
28 : std::integral_constant<std::size_t, sizeof...(Chars)>
29{};
30
31template <std::size_t, typename Name>
32struct name_at_c;
33
34template <char Char, char...Chars>
35struct name_at_c<0ul, name<Char, Chars...>>
36 : std::integral_constant<char, Char>
37{
38};
39
40template <std::size_t Index, char Char, char...Chars>
41struct name_at_c<Index, name<Char, Chars...>>
42 : name_at_c<Index-1, name<Chars...>>
43{
44};
45
46// template <std::size_t Index, char...Chars>
47// struct name_at_c<Index, name<Chars...>
48// {
49
50// };
51
52// template <std::size_t Index, char...CharsBefore, char Char, char...CharsAfter>
53// struct name_at_c_impl<Index, name<Chars...>>
54// {
55
56// };
57
58typedef void(*object_registration_type)(v8::Handle<v8::Object>, v8::Isolate*);
59
60template <typename Name
61 , typename Classes
62 , typename InnerNamespaces>
63struct namespace_object
64{
65 typedef Name name;
66 typedef Classes classes;
67 typedef InnerNamespaces inner_namespaces;
68};
69
70template <typename Name, typename Registration>
71struct class_object
72{
73 typedef Name name;
74 typedef Registration registration;
75};
76
77template <typename NameLhs, typename NameRhs>
78struct name_less;
79
80template <>
81struct name_less<name<>, name<>>
82{
83 static constexpr const bool value = false;
84};
85
86template <char...Chars>
87struct name_less<name<Chars...>, name<>>
88{
89 static constexpr const bool value = false;
90};
91
92template <char...Chars>
93struct name_less<name<>, name<Chars...>>
94{
95 static constexpr const bool value = true;
96};
97
98template <char CharacterLhs, char...NameLhs, char CharacterRhs, char...NameRhs>
99struct name_less<name<CharacterLhs, NameLhs...>, name<CharacterRhs, NameRhs...>>
100{
101 static constexpr const bool value =
102 CharacterLhs < CharacterRhs
103 || (CharacterLhs == CharacterRhs && name_less<name<NameLhs...>, name<NameRhs...>>::value);
104};
105
106template <typename T>
107struct identity { typedef T type; };
108
109struct name_less_predicate
110{
111 template <typename A0, typename A1>
112 struct apply;
113
114 template <typename Name1, typename Name2, typename...Others1, typename...Others2>
115 struct apply<namespace_object<Name1, Others1...>, namespace_object<Name2, Others2...>>
116 : name_less<Name1, Name2>
117 {};
118 template <typename Name1, typename Name2, typename...Others1, typename...Others2>
119 struct apply<class_object<Name1, Others1...>, class_object<Name2, Others2...>>
120 : name_less<Name1, Name2>
121 {};
122 template <typename Name1, typename Name2, typename...Others1, typename...Others2>
123 struct apply<namespace_object<Name1, Others1...>, class_object<Name2, Others2...>>
124 : name_less<Name1, Name2>
125 {};
126 template <typename Name1, typename Name2, typename...Others1, typename...Others2>
127 struct apply<class_object<Name1, Others1...>, namespace_object<Name2, Others2...>>
128 : name_less<Name1, Name2>
129 {};
130};
131
132template <typename A0, typename A1>
133struct pair
134{
135 typedef A0 first;
136 typedef A1 second;
137};
138
139template <std::size_t Index>
140struct map_op
141{
142 template <typename I, typename A0, typename Enable = void>
143 struct apply;
144
145 template <typename A0>
146 struct apply<list<>, A0>
147 {
148 typedef list<pair<name_at_c<Index, typename A0::name>
149 , list<A0>>> type;
150 };
151
152 template <typename C, typename...Items, typename...Pairs, typename A0>
153 struct apply<list<pair<C, list<Items...>>, Pairs...>, A0
154 , typename std::enable_if<(name_at_c<Index, typename A0::name>::value == C::value)>::type>
155 {
156 typedef list<pair<C, list<A0, Items...>>, Pairs...> type;
157 };
158
159 template <typename C, typename List, typename...Pairs, typename A0>
160 struct apply<list<pair<C, List>, Pairs...>, A0
161 , typename std::enable_if<!(name_at_c<Index, typename A0::name>::value == C::value)>::type>
162 {
163 typedef list<pair<name_at_c<Index, typename A0::name>, list<A0>>, pair<C, List>, Pairs...> type;
164 };
165};
166
167template <std::size_t Index, typename List>
168struct map_chars
169{
170 typedef typename list_fold<List, list<>, map_op<Index>>::type type;
171};
172
173struct create_switch_fold
174{
175 template <typename I, typename A0>
176 struct apply;
177
178 template <char...Chars, typename A0, typename A1>
179 struct apply<eina::_mpl::tpl_char_switch<Chars...>, pair<A0, A1>>
180 {
181 typedef eina::_mpl::tpl_char_switch<Chars..., A0::value> type;
182 };
183};
184
185template <typename Map>
186struct create_switch
187{
188 typedef typename list_fold<Map, eina::_mpl::tpl_char_switch<>, create_switch_fold>::type type;
189};
190
191template <std::size_t Index, typename...Objects>
192void search_separate_switch_case(eina::string_view string, list<Objects...>
193 , std::false_type);
194template <std::size_t Index, typename...Objects>
195void search_separate_switch_case(eina::string_view string, list<Objects...>
196 , std::true_type);
197
198template <int Index, typename Map>
199struct switch_case_call
200{
201 template <char C>
202 struct apply
203 {
204 struct find_char_pair
205 {
206 template <typename T>
207 struct apply;
208 template <typename P1, typename P2>
209 struct apply<pair<P1, P2>>
210 : std::integral_constant<bool, (P1::value == C)>
211 {
212 };
213 };
214
215 struct type
216 {
217 template <typename F>
218 constexpr void operator()(eina::string_view string, F const f) const
219 {
220 std::cout << "Found character " << C << std::endl;
221 typedef typename list_find_if<Map, find_char_pair>::type type;
222 typedef typename type::second objects;
223 typedef typename list_max<name_less_predicate, objects>::type max_type;
224
225 search_separate_switch_case<Index+1>(string, objects{}
226 , f
227 , std::integral_constant<bool, (name_size<typename max_type::name>::value == Index+1)>{});
228 }
229 };
230 };
231};
232
233template <std::size_t Index, typename F, typename Object>
234void search_separate_switch_case(eina::string_view string, list<Object>
235 , F const f
236 , std::true_type)
237{
238 if(string.size() == Index)
239 {
240 std::cout << "Found " << typeid(Object).name() << std::endl;
241 f(Object{});
242 }
243 else
244 {
245 std::cout << "Not found" << std::endl;
246 }
247}
248
249template <std::size_t Index, typename F, typename...Objects>
250void search_separate_switch_case(eina::string_view string, list<Objects...>
251 , F const f
252 , std::false_type)
253{
254 typedef typename map_chars<Index, list<Objects...>>::type map;
255 typedef typename create_switch<map>::type switch_type;
256
257 switch_type{}
258 .template operator()<switch_case_call<Index, map>>
259 (string[Index]
260 , [] (char c)
261 {
262 std::cout << "Not found character " << c << " in Index " << Index << " possible characters should be " << typeid(switch_type).name() << std::endl;
263 }, string, f);
264}
265
266template <typename F, /*typename Registration, */typename Name, typename NamespaceList, typename ClassList>
267void search_separate(eina::string_view string, namespace_object<Name
268 , ClassList, NamespaceList>
269 , F const f)
270{
271 // typedef typename eina::_mpl::tuple_sort<std::tuple<Items...>, item_less_pred>::type ordered_by_tuple_sizes;
272 typedef typename list_sort<name_less_predicate, typename ClassList::type, typename NamespaceList::type
273 >::type objects;
274 typedef typename list_max<name_less_predicate, objects>::type max_type;
275
276 search_separate_switch_case<0ul>(string, objects{}
277 , f
278 , std::integral_constant<bool, (name_size<typename max_type::name>::value == 0)>{});
279 // search_separate_by_length_case(string, identity<ordered_by_tuple_sizes>{});
280}
281
282
283// template <typename...Items>
284// void search(identity<std::tuple<Items...>> x)
285// {
286
287// }
288
289} } }
290
291#endif