summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-04-02 11:00:45 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-04-02 11:00:45 +0200
commit428596f42a038b60488c1daefc994c887d574a27 (patch)
tree214eee2a26c4c83e456dd225c6f3fea1e79f0dba
parent9abe6dc2ec3e722465d8014b08e1ccec3865caf0 (diff)
working so far
-rw-r--r--java/java-generator.c440
1 files changed, 410 insertions, 30 deletions
diff --git a/java/java-generator.c b/java/java-generator.c
index 8e7df70..bc2a723 100644
--- a/java/java-generator.c
+++ b/java/java-generator.c
@@ -7,6 +7,8 @@
7#include <stdio.h> 7#include <stdio.h>
8#include <ctype.h> 8#include <ctype.h>
9 9
10static const Eolian_Class *efl_object;
11
10static Eina_Bool 12static Eina_Bool
11_blacklists(const char *name) 13_blacklists(const char *name)
12{ 14{
@@ -142,6 +144,7 @@ _flush_out_strbuf(Eina_Strbuf *strbuf, const char *class_name)
142 } 144 }
143 eina_strbuf_append_printf(path, "%s.java", split[i]); 145 eina_strbuf_append_printf(path, "%s.java", split[i]);
144 eina_strbuf_append(package, ";\n\n"); 146 eina_strbuf_append(package, ";\n\n");
147 eina_strbuf_append(package, "import efl.bindings.NativeCaller;\n");
145 148
146 //write the file 149 //write the file
147 int fd = open(eina_strbuf_string_get(path), O_CREAT | O_TRUNC | O_RDWR, 0700); 150 int fd = open(eina_strbuf_string_get(path), O_CREAT | O_TRUNC | O_RDWR, 0700);
@@ -327,7 +330,7 @@ _add_java_class_type(const Eolian_Type *type, Eina_Strbuf *buf)
327 eina_strbuf_append(buf, "Integer "); 330 eina_strbuf_append(buf, "Integer ");
328} 331}
329static void 332static void
330_create_property_container(Eina_Strbuf *buf, Eina_Hash *property_map, const Eolian_Function *func) 333_create_property_container(Eina_Strbuf *buf, const Eolian_Function *func)
331{ 334{
332 Eina_Strbuf *inner, *privat_fields, *constructor, *methods, *constructor_impl; 335 Eina_Strbuf *inner, *privat_fields, *constructor, *methods, *constructor_impl;
333 int number_of_values = 0; 336 int number_of_values = 0;
@@ -342,7 +345,7 @@ _create_property_container(Eina_Strbuf *buf, Eina_Hash *property_map, const Eoli
342 constructor_impl = eina_strbuf_new(); 345 constructor_impl = eina_strbuf_new();
343 methods = eina_strbuf_new(); 346 methods = eina_strbuf_new();
344 347
345 eina_strbuf_append_printf(inner, "class %sProperty {\n", func_name); 348 eina_strbuf_append_printf(inner, "public static class %sProperty {\n", func_name);
346 349
347 eina_strbuf_append_printf(constructor, "\n public %sProperty(", func_name); 350 eina_strbuf_append_printf(constructor, "\n public %sProperty(", func_name);
348 eina_strbuf_append_printf(constructor_impl, "{\n"); 351 eina_strbuf_append_printf(constructor_impl, "{\n");
@@ -393,7 +396,6 @@ _create_property_container(Eina_Strbuf *buf, Eina_Hash *property_map, const Eoli
393 eina_strbuf_replace_all(inner, "\n", "\n "); 396 eina_strbuf_replace_all(inner, "\n", "\n ");
394 eina_strbuf_append(inner, "\n"); 397 eina_strbuf_append(inner, "\n");
395 eina_strbuf_append_buffer(buf, inner); 398 eina_strbuf_append_buffer(buf, inner);
396 eina_hash_add(property_map, eolian_function_name_get(func), (void*)0x1337);
397 } 399 }
398 400
399 eina_strbuf_free(inner); 401 eina_strbuf_free(inner);
@@ -404,7 +406,7 @@ _create_property_container(Eina_Strbuf *buf, Eina_Hash *property_map, const Eoli
404} 406}
405 407
406static void 408static void
407_create_property_containers(Eina_Strbuf *buf, Eina_Hash *property_map, Eolian_Class *class) 409_create_property_containers(Eina_Strbuf *buf, Eolian_Class *class)
408{ 410{
409 Eolian_Implement *impl; 411 Eolian_Implement *impl;
410 Eina_Iterator *iter = eolian_class_implements_get(class); 412 Eina_Iterator *iter = eolian_class_implements_get(class);
@@ -421,7 +423,7 @@ _create_property_containers(Eina_Strbuf *buf, Eina_Hash *property_map, Eolian_Cl
421 if (ftype != EOLIAN_PROP_GET && ftype != EOLIAN_PROPERTY) 423 if (ftype != EOLIAN_PROP_GET && ftype != EOLIAN_PROPERTY)
422 continue; 424 continue;
423 425
424 _create_property_container(buf, property_map, func); 426 _create_property_container(buf, func);
425 } 427 }
426 eina_iterator_free(iter); 428 eina_iterator_free(iter);
427} 429}
@@ -444,16 +446,37 @@ _output_parameters(Eina_Iterator *parameters, Eina_Strbuf *buf, Eina_Bool *first
444} 446}
445 447
446static void 448static void
447_output_function(Eina_Strbuf *buf, const Eolian_Function_Type ftype, const Eolian_Implement *impl, const Eolian_Function *func, const char *prefix, Eina_Bool class) 449_output_parameter_names(Eina_Iterator *parameters, Eina_Strbuf *buf, Eina_Bool *first)
450{
451 Eolian_Function_Parameter *parameter;
452
453 EINA_ITERATOR_FOREACH(parameters, parameter)
454 {
455 if (*first)
456 *first = EINA_FALSE;
457 else
458 eina_strbuf_append(buf, ", ");
459
460 eina_strbuf_append(buf, _sanitize_name(eolian_parameter_name_get(parameter)));
461 }
462}
463
464static void
465_output_function(Eina_Strbuf *buf, const Eolian_Function_Type ftype,
466 const Eolian_Implement *impl,
467 const Eolian_Function *func,
468 const char *prefix, const char *annotations,
469 Eina_Bool make_native)
448{ 470{
449 Eina_Bool values_expressed = EINA_FALSE; 471 Eina_Bool values_expressed = EINA_FALSE;
450 if (ftype == EOLIAN_PROP_GET || ftype == EOLIAN_PROP_SET) 472 if (ftype == EOLIAN_PROP_GET || ftype == EOLIAN_PROP_SET)
451 _output_documentation(buf, eolian_implement_documentation_get(impl, EOLIAN_PROPERTY), "\n "); 473 _output_documentation(buf, eolian_implement_documentation_get(impl, EOLIAN_PROPERTY), "\n ");
452 else 474 else
453 _output_documentation(buf, eolian_implement_documentation_get(impl, ftype), "\n "); 475 _output_documentation(buf, eolian_implement_documentation_get(impl, ftype), "\n ");
454 476 if (annotations)
477 eina_strbuf_append_printf(buf, " %s\n", annotations);
455 eina_strbuf_append(buf, " public "); 478 eina_strbuf_append(buf, " public ");
456 if (class) 479 if (make_native)
457 { 480 {
458 eina_strbuf_append(buf, "native "); 481 eina_strbuf_append(buf, "native ");
459 } 482 }
@@ -516,7 +539,8 @@ _output_function(Eina_Strbuf *buf, const Eolian_Function_Type ftype, const Eolia
516 eina_strbuf_append_printf(buf, "void "); 539 eina_strbuf_append_printf(buf, "void ");
517 } 540 }
518 541
519 eina_strbuf_append(buf, prefix); 542 if (prefix)
543 eina_strbuf_append(buf, prefix);
520 eina_strbuf_append(buf, _sanitize_function(eolian_function_name_get(func), !!prefix)); 544 eina_strbuf_append(buf, _sanitize_function(eolian_function_name_get(func), !!prefix));
521 eina_strbuf_append(buf, "("); 545 eina_strbuf_append(buf, "(");
522 Eina_Bool first = EINA_TRUE; 546 Eina_Bool first = EINA_TRUE;
@@ -530,51 +554,388 @@ _output_function(Eina_Strbuf *buf, const Eolian_Function_Type ftype, const Eolia
530 if (!values_expressed) 554 if (!values_expressed)
531 _output_parameters(eolian_property_values_get(func, ftype), buf, &first); 555 _output_parameters(eolian_property_values_get(func, ftype), buf, &first);
532 } 556 }
533 eina_strbuf_append(buf, ");\n"); 557 eina_strbuf_append(buf, ")");
534} 558}
535 559
536static void 560static void
537_compile_eoclass(Eolian_Class *class, const char *keyword, const char *implement_keyword, Eina_Bool is_class) 561_output_function_call(Eina_Strbuf *buf,
562 const Eolian_Class *class,
563 const Eolian_Function_Type ftype,
564 const Eolian_Function *func,
565 const char *prefix,
566 int index)
567{
568 const Eolian_Type *type = eolian_function_return_type_get(func, ftype);
569 const char *function_name = _sanitize_function(eolian_function_name_get(func), !!prefix);
570
571 eina_strbuf_append(buf, " {\n ");
572 if (type || ftype == EOLIAN_PROP_GET)
573 eina_strbuf_append_printf(buf, "return ");
574 eina_strbuf_append_printf(buf, "native%d%s.", index, _sanitize_type(eolian_class_short_name_get(class)));
575
576 if (prefix)
577 eina_strbuf_append(buf, prefix);
578 eina_strbuf_append(buf, function_name);
579 eina_strbuf_append(buf, "(");
580 Eina_Bool first = EINA_TRUE;
581 if (ftype == EOLIAN_METHOD)
582 {
583 _output_parameter_names(eolian_function_parameters_get(func), buf, &first);
584 }
585 else
586 {
587 _output_parameter_names(eolian_property_keys_get(func, ftype), buf, &first);
588 if (ftype == EOLIAN_PROP_SET)
589 _output_parameter_names(eolian_property_values_get(func, ftype), buf, &first);
590 }
591 eina_strbuf_append(buf, ");\n }\n");
592}
593
594static void
595_create_native_adapter(Eina_Strbuf *real, Eolian_Class *class)
538{ 596{
539 Eina_Strbuf *buf = eina_strbuf_new();
540 Eina_Hash *property_map;
541 Eolian_Implement *impl; 597 Eolian_Implement *impl;
542 Eina_Iterator *iter; 598 Eina_Strbuf *buf = eina_strbuf_new();
599 Eina_Iterator *iter = eolian_class_implements_get(class);
600 const char *typename = _sanitize_type(eolian_class_short_name_get(class));
543 601
544 property_map = eina_hash_string_small_new(NULL); 602 eina_strbuf_append_printf(buf, "class %sNative extends NativeCaller {\n", typename);
545 _output_documentation(buf, eolian_class_documentation_get(class), "\n");
546 _output_head(class, keyword, implement_keyword, buf);
547 eina_strbuf_append(buf, " {\n");
548 603
549 _create_property_containers(buf, property_map, class); 604 if (eolian_class_type_get(class) == EOLIAN_CLASS_REGULAR)
605 {
606 eina_strbuf_append_printf(buf, " /**\n");
607 eina_strbuf_append_printf(buf, " * Create a new instance of %s \n", eolian_class_c_name_get(class));
608 eina_strbuf_append_printf(buf, " */\n");
609 eina_strbuf_append_printf(buf, " public native long init();\n");
610 eina_strbuf_append_printf(buf, " public %sNative() {\n", typename);
611 eina_strbuf_append_printf(buf, " super();\n");
612 eina_strbuf_append_printf(buf, " setNativeAddress(init());\n");
613 eina_strbuf_append_printf(buf, " }\n\n");
614 }
615 eina_strbuf_append_printf(buf, " public %sNative(NativeCaller native_handle) {\n", typename);
616 eina_strbuf_append_printf(buf, " super(native_handle);\n");
617 eina_strbuf_append_printf(buf, " }\n\n");
618 EINA_ITERATOR_FOREACH(iter, impl)
619 {
620 Eolian_Function_Type ftype = EOLIAN_UNRESOLVED;
621 const Eolian_Function *func;
622 if (eolian_implement_class_get(impl) != class)
623 continue;
624 func = eolian_implement_function_get(impl, &ftype);
625 if (ftype == EOLIAN_PROP_GET || ftype == EOLIAN_PROPERTY)
626 {
627 _output_function(buf, EOLIAN_PROP_GET, impl, func, "get", NULL, EINA_TRUE);
628 eina_strbuf_append(buf, ";\n");
629 }
630 if (ftype == EOLIAN_PROP_SET || ftype == EOLIAN_PROPERTY)
631 {
632 _output_function(buf, EOLIAN_PROP_SET, impl, func, "set", NULL, EINA_TRUE);
633 eina_strbuf_append(buf, ";\n");
634 }
635 if (ftype == EOLIAN_METHOD)
636 {
637 _output_function(buf, ftype, impl, func, NULL, NULL, EINA_TRUE);
638 eina_strbuf_append(buf, ";\n");
639 }
640 }
641 eina_strbuf_append(buf, "}\n");
642 if (eolian_class_type_get(class) == EOLIAN_CLASS_REGULAR || eolian_class_type_get(class) == EOLIAN_CLASS_ABSTRACT)
643 eina_strbuf_append_printf(buf, "private %sNative native0%s;\n", typename, typename);
644
645 eina_strbuf_replace_all(buf, "\n", "\n ");
646 eina_strbuf_prepend(buf, " ");
647 eina_strbuf_append(buf, "\n");
648 eina_strbuf_append_buffer(real, buf);
649 eina_strbuf_free(buf);
650
651 eina_iterator_free(iter);
652}
653
654static void
655_create_defined_methods(Eina_Strbuf *buf, const Eolian_Class *class, const char *annotations, int index, Eina_Bool is_class)
656{
657 Eolian_Implement *impl;
658 Eina_Iterator *iter;
550 659
551 iter = eolian_class_implements_get(class); 660 iter = eolian_class_implements_get(class);
552 EINA_ITERATOR_FOREACH(iter, impl) 661 EINA_ITERATOR_FOREACH(iter, impl)
553 { 662 {
554 Eolian_Function_Type ftype = EOLIAN_UNRESOLVED; 663 Eolian_Function_Type ftype = EOLIAN_UNRESOLVED;
555 const Eolian_Function *func; 664 const Eolian_Function *func;
665
556 if (eolian_implement_class_get(impl) != class) 666 if (eolian_implement_class_get(impl) != class)
557 continue; 667 continue;
558 func = eolian_implement_function_get(impl, &ftype); 668 func = eolian_implement_function_get(impl, &ftype);
559 if (ftype == EOLIAN_PROP_GET) 669
670 if (ftype == EOLIAN_PROP_GET || ftype == EOLIAN_PROPERTY)
560 { 671 {
561 _output_function(buf, ftype, impl, func, "get", is_class); 672 _output_function(buf, EOLIAN_PROP_GET, impl, func, "get", annotations, EINA_FALSE);
673 if (is_class)
674 _output_function_call(buf, class, EOLIAN_PROP_GET, func, "get", index);
675 else
676 eina_strbuf_append(buf, ";\n");
562 } 677 }
563 else if (ftype == EOLIAN_PROP_SET) 678 if (ftype == EOLIAN_PROP_SET || ftype == EOLIAN_PROPERTY)
564 { 679 {
565 _output_function(buf, ftype, impl, func, "set", is_class); 680 _output_function(buf, EOLIAN_PROP_SET, impl, func, "set", annotations, EINA_FALSE);
681 if (is_class)
682 _output_function_call(buf, class, EOLIAN_PROP_SET, func, "set", index);
683 else
684 eina_strbuf_append(buf, ";\n");
566 } 685 }
567 else if (ftype == EOLIAN_PROPERTY) 686 if (ftype == EOLIAN_METHOD)
568 { 687 {
569 _output_function(buf, EOLIAN_PROP_GET, impl, func, "get", is_class); 688 _output_function(buf, ftype, impl, func, NULL, annotations, EINA_FALSE);
570 _output_function(buf, EOLIAN_PROP_SET, impl, func, "set", is_class); 689 if (is_class)
690 _output_function_call(buf, class, ftype, func, NULL, index);
691 else
692 eina_strbuf_append(buf, ";\n");
571 } 693 }
572 else 694
695 }
696 eina_iterator_free(iter);
697}
698
699static void
700_fetch_all_constructors(const Eolian_Class *class, Eina_Array **constructors_must, Eina_Array **constructors_optional)
701{
702 const Eolian_Constructor *constructor;
703 Eina_Iterator *constructors;
704
705 if (eolian_class_parent_get(class))
706 _fetch_all_constructors(eolian_class_parent_get(class), constructors_must, constructors_optional);
707
708 constructors = eolian_class_constructors_get(class);
709 EINA_ITERATOR_FOREACH(constructors, constructor)
710 {
711 if (eolian_constructor_is_optional(constructor))
712 eina_array_push(*constructors_optional, eolian_constructor_function_get(constructor));
713 else
714 eina_array_push(*constructors_must, eolian_constructor_function_get(constructor));
715 }
716 eina_iterator_free(constructors);
717}
718
719static void
720_create_constructors(Eina_Strbuf *buf, Eolian_Class *class)
721{
722 Eina_Bool first = EINA_TRUE;
723 Eina_Strbuf *function_calls;
724 Eina_Array *here, *parent, *here_optional, *parent_optional;
725 const char *typename = _sanitize_type(eolian_class_short_name_get(class));
726
727 function_calls = eina_strbuf_new();
728 here = eina_array_new(10);
729 parent = eina_array_new(10);
730 here_optional = eina_array_new(10);
731 parent_optional = eina_array_new(10);
732
733 //parent constructors
734 if (eolian_class_parent_get(class))
735 {
736 _fetch_all_constructors(eolian_class_parent_get(class), &parent, &parent_optional);
737 }
738
739 //here constructors
740 _fetch_all_constructors(class, &here, &here_optional);
741
742 eina_strbuf_append_printf(buf, " public %s(", typename);
743 for (unsigned int i = 0; i < eina_array_count(here); ++i)
744 {
745 Eolian_Function *function = eina_array_data_get(here, i);
746 Eolian_Function_Type type = eolian_function_type_get(function);
747
748 if (type == EOLIAN_METHOD)
749 {
750 _output_parameters(eolian_function_parameters_get(function), buf, &first);
751 }
752 else if (type == EOLIAN_PROPERTY || type == EOLIAN_PROP_SET)
573 { 753 {
574 _output_function(buf, ftype, impl, func, "", is_class); 754 _output_parameters(eolian_property_keys_get(function, EOLIAN_PROP_SET), buf, &first);
755 _output_parameters(eolian_property_values_get(function, EOLIAN_PROP_SET), buf, &first);
575 } 756 }
576 } 757 }
577 eina_iterator_free(iter); 758 eina_strbuf_append(buf, ") {\n");
759 if (eolian_class_parent_get(class))
760 {
761 eina_strbuf_append(buf, " super(");
762
763 first = EINA_TRUE;
764 for (unsigned int i = 0; i < eina_array_count(here); ++i)
765 {
766 Eolian_Function *function = eina_array_data_get(here, i);
767 Eolian_Function_Type type = eolian_function_type_get(function);
768 unsigned int i;
769
770 if (!eina_array_find(parent, function, &i))
771 {
772 Eina_Bool local_first = EINA_TRUE;
773 eina_strbuf_append(function_calls, " ");
774 if (type == EOLIAN_METHOD)
775 {
776 eina_strbuf_append_printf(function_calls, "%s(", _sanitize_function(eolian_function_name_get(function), EINA_FALSE));
777 _output_parameter_names(eolian_function_parameters_get(function), function_calls, &local_first);
778 }
779 else if (type == EOLIAN_PROPERTY || type == EOLIAN_PROP_SET)
780 {
781 eina_strbuf_append_printf(function_calls, "set%s(", _sanitize_function(eolian_function_name_get(function), EINA_TRUE));
782 _output_parameter_names(eolian_property_keys_get(function, EOLIAN_PROP_SET), function_calls, &local_first);
783 _output_parameter_names(eolian_property_values_get(function, EOLIAN_PROP_SET), function_calls, &local_first);
784 }
785 eina_strbuf_append(function_calls, ");\n");
786 }
787 else
788 {
789 if (type == EOLIAN_METHOD)
790 {
791 _output_parameter_names(eolian_function_parameters_get(function), buf, &first);
792 }
793 else if (type == EOLIAN_PROPERTY || type == EOLIAN_PROP_SET)
794 {
795 _output_parameter_names(eolian_property_keys_get(function, EOLIAN_PROP_SET), buf, &first);
796 _output_parameter_names(eolian_property_values_get(function, EOLIAN_PROP_SET), buf, &first);
797 }
798 }
799 }
800 eina_strbuf_append(buf, ");\n");
801 }
802 else
803 {
804 eina_strbuf_append(buf, " InitializeNativeHandler(null);\n");
805
806 }
807 eina_strbuf_append_buffer(buf, function_calls);
808
809 eina_strbuf_append(buf," }\n\n");
810}
811
812static void
813_fetch_inherited_interfaces(Eina_Array *tmp, const Eolian_Class *class)
814{
815 Eina_Iterator *iter = eolian_class_extensions_get(class);
816 const Eolian_Class *extension;
817 unsigned int out_idx;
818
819 if (!eina_array_find(tmp, class, &out_idx))
820 eina_array_push(tmp, class);
821
822 EINA_ITERATOR_FOREACH(iter, extension)
823 {
824 _fetch_inherited_interfaces(tmp, extension);
825 }
826
827 if (eolian_class_parent_get(class))
828 _fetch_inherited_interfaces(tmp, eolian_class_parent_get(class));
829}
830
831static void
832_fetch_real_interfaces_deduped(Eina_Array *tmp, const Eolian_Class *class)
833{
834 Eina_Array *parent_all_interfaces = eina_array_new(10);
835 Eina_Array *all_interfaces = eina_array_new(10);
836
837 _fetch_inherited_interfaces(parent_all_interfaces, eolian_class_parent_get(class));
838 _fetch_inherited_interfaces(all_interfaces, class);
839
840 for (int i = 0; i < eina_array_count(all_interfaces); ++i)
841 {
842 const Eolian_Class *parent_interface = eina_array_data_get(all_interfaces, i);
843 unsigned int out_idx;
844 if (!eina_array_find(parent_all_interfaces, parent_interface, &out_idx))
845 {
846 eina_array_push(tmp, parent_interface);
847 }
848 }
849}
850
851static void
852_create_creation_logic(Eina_Strbuf *buf, Eolian_Class *class)
853{
854 const char *typename = _sanitize_type(eolian_class_short_name_get(class));
855
856 if (eolian_class_type_get(class) == EOLIAN_CLASS_REGULAR ||
857 eolian_class_type_get(class) == EOLIAN_CLASS_ABSTRACT)
858 {
859 Eina_Array *extensions = eina_array_new(10);
860 _fetch_real_interfaces_deduped(extensions, class);
861 for (int i = 1; i < eina_array_count(extensions); ++i)
862 {
863 const Eolian_Class *extension = eina_array_data_get(extensions, i);
864
865 eina_strbuf_append_printf(buf, " private %s.%sNative native%d%s;\n",
866 _sanitize_type(eolian_class_name_get(extension)),
867 _sanitize_type(eolian_class_short_name_get(extension)), i,
868 _sanitize_type(eolian_class_short_name_get(extension)));
869 }
870 if (eolian_class_parent_get(class) && class != efl_object)
871 eina_strbuf_append(buf, " @Override\n");
872 eina_strbuf_append_printf(buf, " protected void InitializeNativeHandler(NativeCaller nativeCaller) {\n");
873 eina_strbuf_append_printf(buf, " NativeCaller local = nativeCaller;\n");
874 if (eolian_class_type_get(class) == EOLIAN_CLASS_REGULAR)
875 {
876 eina_strbuf_append_printf(buf, " if (local == null)\n");
877 eina_strbuf_append_printf(buf, " local = new %sNative();\n", typename);
878 }
879 for (int i = 1; i < eina_array_count(extensions); ++i)
880 {
881 const Eolian_Class *extension = eina_array_data_get(extensions, i);
882
883 eina_strbuf_append_printf(buf, " native%d%s = new %s.%sNative(local);\n", i,
884 _sanitize_type(eolian_class_short_name_get(extension)),
885 _sanitize_type(eolian_class_name_get(extension)),
886 _sanitize_type(eolian_class_short_name_get(extension)));
887 }
888 if (eolian_class_type_get(class) == EOLIAN_CLASS_REGULAR || eolian_class_type_get(class) == EOLIAN_CLASS_ABSTRACT)
889 eina_strbuf_append_printf(buf, " native0%s = new %sNative(local);\n", typename, typename);
890 if (eolian_class_parent_get(class))
891 eina_strbuf_append_printf(buf, " super.InitializeNativeHandler(local);\n");
892 eina_strbuf_append_printf(buf, " }\n");
893 eina_array_free(extensions);
894 }
895}
896
897static void
898_fill_in_all_implements(Eina_Strbuf *buf, const Eolian_Class *class)
899{
900 Eina_Array *extensions = eina_array_new(10);
901 _fetch_real_interfaces_deduped(extensions, class);
902 for (int i = 1; i < eina_array_count(extensions); ++i)
903 {
904 const Eolian_Class *extension = eina_array_data_get(extensions, i);
905
906 _create_defined_methods(buf, extension, "@Override", i, EINA_TRUE);
907 }
908}
909
910static void
911_compile_eoclass(Eolian_Class *class, const char *keyword, const char *implement_keyword, Eina_Bool is_class)
912{
913 Eina_Strbuf *buf = eina_strbuf_new();
914
915 _output_documentation(buf, eolian_class_documentation_get(class), "\n");
916 _output_head(class, keyword, implement_keyword, buf);
917 eina_strbuf_append(buf, " {\n");
918
919 //create all the property contains
920 _create_property_containers(buf, class);
921
922 //create the native class that contains all the JNI calls
923 _create_native_adapter(buf, class);
924
925 //creation logic for creating native objects
926 _create_creation_logic(buf, class);
927
928 //create the constructors
929 if (eolian_class_type_get(class) == EOLIAN_CLASS_REGULAR || eolian_class_type_get(class) == EOLIAN_CLASS_ABSTRACT)
930 _create_constructors(buf, class);
931
932 //define all the methdos that is initially defined in here
933 _create_defined_methods(buf, class, "", 0, is_class);
934
935 //FIXME create event wrappers
936
937 if (eolian_class_type_get(class) == EOLIAN_CLASS_REGULAR || eolian_class_type_get(class) == EOLIAN_CLASS_ABSTRACT)
938 _fill_in_all_implements(buf, class);
578 939
579 eina_strbuf_append(buf, "}\n"); 940 eina_strbuf_append(buf, "}\n");
580 941
@@ -596,7 +957,7 @@ _compile_all_classes(Eolian_State *state)
596 Eina_Bool is_class = EINA_FALSE; 957 Eina_Bool is_class = EINA_FALSE;
597 if (eolian_class_type_get(class) == EOLIAN_CLASS_REGULAR) 958 if (eolian_class_type_get(class) == EOLIAN_CLASS_REGULAR)
598 { 959 {
599 keyword = "abstract class"; //FIXME 960 keyword = "class";
600 implements = "implements"; 961 implements = "implements";
601 is_class = EINA_TRUE; 962 is_class = EINA_TRUE;
602 } 963 }
@@ -757,6 +1118,8 @@ int main(int argc, char const *argv[])
757 1118
758 eolian_state_check(state); 1119 eolian_state_check(state);
759 1120
1121 efl_object = eolian_state_class_by_name_get(state, "Efl.Object");
1122
760 _compile_all_structs(state); 1123 _compile_all_structs(state);
761 _compile_all_enums(state); 1124 _compile_all_enums(state);
762 _compile_all_classes(state); 1125 _compile_all_classes(state);
@@ -781,6 +1144,23 @@ int main(int argc, char const *argv[])
781 eina_strbuf_append(util, " }\n"); 1144 eina_strbuf_append(util, " }\n");
782 eina_strbuf_append(util, "}\n"); 1145 eina_strbuf_append(util, "}\n");
783 _flush_out_strbuf(util, "Efl.Bindings.Util"); 1146 _flush_out_strbuf(util, "Efl.Bindings.Util");
1147
1148 util = eina_strbuf_new();
1149 eina_strbuf_append(util, "public abstract class NativeCaller {\n");
1150 eina_strbuf_append(util, " private long nativeAddress;\n");
1151 eina_strbuf_append(util, " public NativeCaller(NativeCaller nativeCaller) {\n");
1152 eina_strbuf_append(util, " this.nativeAddress = nativeCaller.getNativeAddress();\n");
1153 eina_strbuf_append(util, " }\n");
1154 eina_strbuf_append(util, " public NativeCaller() {\n");
1155 eina_strbuf_append(util, " }\n");
1156 eina_strbuf_append(util, " protected void setNativeAddress(long nativeAddress) {\n");
1157 eina_strbuf_append(util, " this.nativeAddress = nativeAddress;\n");
1158 eina_strbuf_append(util, " }\n");
1159 eina_strbuf_append(util, " protected long getNativeAddress() {\n");
1160 eina_strbuf_append(util, " return this.nativeAddress;\n");
1161 eina_strbuf_append(util, " }\n");
1162 eina_strbuf_append(util, "}\n");
1163 _flush_out_strbuf(util, "Efl.Bindings.NativeCaller");
784 } 1164 }
785 1165
786 eolian_shutdown(); 1166 eolian_shutdown();