summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile_Cxx.am13
-rw-r--r--src/Makefile_Eolian_Cxx.am87
-rw-r--r--src/bin/eolian_cxx/convert.cc373
-rw-r--r--src/bin/eolian_cxx/convert.hh19
-rw-r--r--src/bin/eolian_cxx/convert_comments.cc95
-rw-r--r--src/bin/eolian_cxx/convert_comments.hh46
-rw-r--r--src/bin/eolian_cxx/eolian_cxx.cc258
-rw-r--r--src/bin/eolian_cxx/eolian_wrappers.hh430
-rw-r--r--src/bin/eolian_cxx/safe_strings.hh160
-rw-r--r--src/bin/eolian_cxx/type_lookup.hh160
-rw-r--r--src/bin/eolian_cxx/type_lookup_table.cc36
-rw-r--r--src/bindings/cxx/eo_cxx/Eo.hh5
-rw-r--r--src/bindings/cxx/eo_cxx/eo_concrete.hh110
-rw-r--r--src/bindings/cxx/eo_cxx/eo_cxx_interop.hh751
-rw-r--r--src/bindings/cxx/eo_cxx/eo_event.hh71
-rw-r--r--src/bindings/cxx/eo_cxx/eo_inherit.hh308
-rw-r--r--src/examples/elementary/bg_cxx_example_01.cc13
-rw-r--r--src/examples/elementary/button_cxx_example_00.cc25
-rw-r--r--src/examples/eolian_cxx/Makefile.am14
-rw-r--r--src/examples/eolian_cxx/colourable.c1
-rw-r--r--src/examples/eolian_cxx/colourable_cxx.cc1
-rw-r--r--src/examples/eolian_cxx/colourablesquare.c1
-rw-r--r--src/examples/eolian_cxx/colourablesquare_cxx.cc1
-rw-r--r--src/examples/eolian_cxx/eolian_cxx_simple_01.cc12
-rw-r--r--src/examples/eolian_cxx/ns_colourable.eo1
-rw-r--r--src/examples/eolian_cxx/ns_colourablesquare.eo1
-rw-r--r--src/lib/eolian_cxx/Eolian_Cxx.hh8
-rw-r--r--src/lib/eolian_cxx/eo_generate.hh23
-rw-r--r--src/lib/eolian_cxx/eo_types.hh350
-rw-r--r--src/lib/eolian_cxx/eo_validate.hh116
-rw-r--r--src/lib/eolian_cxx/grammar/address_of.hpp74
-rw-r--r--src/lib/eolian_cxx/grammar/alternative.hpp52
-rw-r--r--src/lib/eolian_cxx/grammar/attribute_conditional.hpp66
-rw-r--r--src/lib/eolian_cxx/grammar/attribute_reorder.hpp87
-rw-r--r--src/lib/eolian_cxx/grammar/attribute_replace.hpp63
-rw-r--r--src/lib/eolian_cxx/grammar/attributes.hpp185
-rw-r--r--src/lib/eolian_cxx/grammar/base_class_definition.hpp112
-rw-r--r--src/lib/eolian_cxx/grammar/c_type.hpp74
-rw-r--r--src/lib/eolian_cxx/grammar/case.hpp86
-rw-r--r--src/lib/eolian_cxx/grammar/class_declaration.hpp56
-rw-r--r--src/lib/eolian_cxx/grammar/class_definition.hpp176
-rw-r--r--src/lib/eolian_cxx/grammar/class_implementation.hpp56
-rw-r--r--src/lib/eolian_cxx/grammar/comment.hh45
-rw-r--r--src/lib/eolian_cxx/grammar/container.hpp46
-rw-r--r--src/lib/eolian_cxx/grammar/context.hpp46
-rw-r--r--src/lib/eolian_cxx/grammar/converting_argument.hpp47
-rw-r--r--src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh603
-rw-r--r--src/lib/eolian_cxx/grammar/eo_class_events_generator.hh117
-rw-r--r--src/lib/eolian_cxx/grammar/eo_class_functions_generator.hh173
-rw-r--r--src/lib/eolian_cxx/grammar/eo_class_generator.hh265
-rw-r--r--src/lib/eolian_cxx/grammar/eo_class_scope_guard_generator.hh65
-rw-r--r--src/lib/eolian_cxx/grammar/eo_header_generator.hh150
-rw-r--r--src/lib/eolian_cxx/grammar/eps.hpp24
-rw-r--r--src/lib/eolian_cxx/grammar/function_declaration.hpp39
-rw-r--r--src/lib/eolian_cxx/grammar/function_definition.hpp155
-rw-r--r--src/lib/eolian_cxx/grammar/generator.hpp50
-rw-r--r--src/lib/eolian_cxx/grammar/header.hpp38
-rw-r--r--src/lib/eolian_cxx/grammar/header_guards.hpp79
-rw-r--r--src/lib/eolian_cxx/grammar/header_include_directive.hpp34
-rw-r--r--src/lib/eolian_cxx/grammar/impl_header.hpp21
-rw-r--r--src/lib/eolian_cxx/grammar/implementation_include_directive.hpp39
-rw-r--r--src/lib/eolian_cxx/grammar/indentation.hpp50
-rw-r--r--src/lib/eolian_cxx/grammar/inheritance_base_generator.hh339
-rw-r--r--src/lib/eolian_cxx/grammar/keyword.hpp15
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp704
-rw-r--r--src/lib/eolian_cxx/grammar/kleene.hpp47
-rw-r--r--src/lib/eolian_cxx/grammar/list.hpp52
-rw-r--r--src/lib/eolian_cxx/grammar/meta.hpp42
-rw-r--r--src/lib/eolian_cxx/grammar/namespace.hpp67
-rw-r--r--src/lib/eolian_cxx/grammar/namespace_generator.hh68
-rw-r--r--src/lib/eolian_cxx/grammar/parameter.hpp78
-rw-r--r--src/lib/eolian_cxx/grammar/parameters_generator.hh453
-rw-r--r--src/lib/eolian_cxx/grammar/qualifier_def.hpp178
-rw-r--r--src/lib/eolian_cxx/grammar/sequence.hpp136
-rw-r--r--src/lib/eolian_cxx/grammar/string.hpp185
-rw-r--r--src/lib/eolian_cxx/grammar/tab.hh30
-rw-r--r--src/lib/eolian_cxx/grammar/type.hpp40
-rw-r--r--src/lib/eolian_cxx/grammar/type_generator.hh266
-rw-r--r--src/lib/eolian_cxx/grammar/type_impl.hpp333
-rw-r--r--src/lib/eolian_cxx/grammar/type_traits.hpp63
-rw-r--r--src/lib/eolian_cxx/grammar/variant.hpp276
-rw-r--r--src/tests/eolian_cxx/callback.c56
-rw-r--r--src/tests/eolian_cxx/callback.eo36
-rw-r--r--src/tests/eolian_cxx/complex.c5
-rw-r--r--src/tests/eolian_cxx/complex.eo80
-rw-r--r--src/tests/eolian_cxx/complex_cxx.cc22
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_suite.cc1
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_suite.h1
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_test_binding.cc172
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_test_callback.cc184
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_test_generate.cc60
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_test_inheritance.cc56
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_test_wrapper.cc4
-rw-r--r--src/tests/eolian_cxx/generic.c89
-rw-r--r--src/tests/eolian_cxx/generic.eo64
-rw-r--r--src/tests/eolian_cxx/name1_name2_type_generation.c240
-rw-r--r--src/tests/eolian_cxx/name1_name2_type_generation.eo220
-rw-r--r--src/tests/eolian_cxx/name_name_cxx.cc4
98 files changed, 5737 insertions, 5591 deletions
diff --git a/src/Makefile_Cxx.am b/src/Makefile_Cxx.am
index 9a199bd5f9..4343b5d875 100644
--- a/src/Makefile_Cxx.am
+++ b/src/Makefile_Cxx.am
@@ -7,15 +7,15 @@ installed_eocxxheadersdir = $(includedir)/eo-cxx-@VMAJ@/
7nodist_installed_eocxxheaders_DATA = $(eo_eolian_cxx_hh) $(eo_eolian_cxx_impl) 7nodist_installed_eocxxheaders_DATA = $(eo_eolian_cxx_hh) $(eo_eolian_cxx_impl)
8dist_installed_eocxxheaders_DATA = \ 8dist_installed_eocxxheaders_DATA = \
9bindings/cxx/eo_cxx/eo_concrete.hh \ 9bindings/cxx/eo_cxx/eo_concrete.hh \
10bindings/cxx/eo_cxx/eo_cxx_interop.hh \
10bindings/cxx/eo_cxx/eo_event.hh \ 11bindings/cxx/eo_cxx/eo_event.hh \
11bindings/cxx/eo_cxx/eo_init.hh \ 12bindings/cxx/eo_cxx/Eo.hh \
12bindings/cxx/eo_cxx/eo_wref.hh \
13bindings/cxx/eo_cxx/eo_inherit.hh \ 13bindings/cxx/eo_cxx/eo_inherit.hh \
14bindings/cxx/eo_cxx/eo_ops.hh \
15bindings/cxx/eo_cxx/eo_private.hh \
16bindings/cxx/eo_cxx/eo_inherit_bindings.hh \ 14bindings/cxx/eo_cxx/eo_inherit_bindings.hh \
17bindings/cxx/eo_cxx/eo_cxx_interop.hh \ 15bindings/cxx/eo_cxx/eo_init.hh \
18bindings/cxx/eo_cxx/Eo.hh 16bindings/cxx/eo_cxx/eo_ops.hh \
17bindings/cxx/eo_cxx/eo_wref.hh \
18bindings/cxx/eo_cxx/eo_private.hh
19 19
20### Elementary C++ 20### Elementary C++
21installed_elementarycxxmainheadersdir = $(includedir)/elementary-cxx-@VMAJ@/ 21installed_elementarycxxmainheadersdir = $(includedir)/elementary-cxx-@VMAJ@/
@@ -138,6 +138,7 @@ bindings/cxx/eina_cxx/eina_accessor.hh \
138bindings/cxx/eina_cxx/eina_array.hh \ 138bindings/cxx/eina_cxx/eina_array.hh \
139bindings/cxx/eina_cxx/eina_clone_allocators.hh \ 139bindings/cxx/eina_cxx/eina_clone_allocators.hh \
140bindings/cxx/eina_cxx/eina_error.hh \ 140bindings/cxx/eina_cxx/eina_error.hh \
141bindings/cxx/eina_cxx/eina_future.hh \
141bindings/cxx/eina_cxx/eina_eo_concrete_fwd.hh \ 142bindings/cxx/eina_cxx/eina_eo_concrete_fwd.hh \
142bindings/cxx/eina_cxx/eina_fold.hh \ 143bindings/cxx/eina_cxx/eina_fold.hh \
143bindings/cxx/eina_cxx/eina_function.hh \ 144bindings/cxx/eina_cxx/eina_function.hh \
diff --git a/src/Makefile_Eolian_Cxx.am b/src/Makefile_Eolian_Cxx.am
index 57dc265b97..981cca5bb2 100644
--- a/src/Makefile_Eolian_Cxx.am
+++ b/src/Makefile_Eolian_Cxx.am
@@ -6,40 +6,53 @@ installed_eoliancxxmainheadersdir = $(includedir)/eolian-cxx-@VMAJ@/
6dist_installed_eoliancxxmainheaders_DATA = \ 6dist_installed_eoliancxxmainheaders_DATA = \
7lib/eolian_cxx/Eolian_Cxx.hh 7lib/eolian_cxx/Eolian_Cxx.hh
8 8
9installed_eoliancxxheadersdir = $(includedir)/eolian-cxx-@VMAJ@/
10dist_installed_eoliancxxheaders_DATA = \
11lib/eolian_cxx/eo_generate.hh \
12lib/eolian_cxx/eo_types.hh \
13lib/eolian_cxx/eo_validate.hh
14
15installed_eoliancxxgrammarheadersdir = $(includedir)/eolian-cxx-@VMAJ@/grammar/ 9installed_eoliancxxgrammarheadersdir = $(includedir)/eolian-cxx-@VMAJ@/grammar/
16dist_installed_eoliancxxgrammarheaders_DATA = \ 10dist_installed_eoliancxxgrammarheaders_DATA = \
17lib/eolian_cxx/grammar/comment.hh \ 11lib/eolian_cxx/grammar/address_of.hpp \
18lib/eolian_cxx/grammar/eo_class_scope_guard_generator.hh \ 12lib/eolian_cxx/grammar/alternative.hpp \
19lib/eolian_cxx/grammar/eo_class_constructors_generator.hh \ 13lib/eolian_cxx/grammar/attribute_conditional.hpp \
20lib/eolian_cxx/grammar/eo_class_events_generator.hh \ 14lib/eolian_cxx/grammar/attribute_reorder.hpp \
21lib/eolian_cxx/grammar/eo_class_functions_generator.hh \ 15lib/eolian_cxx/grammar/attribute_replace.hpp \
22lib/eolian_cxx/grammar/namespace_generator.hh \ 16lib/eolian_cxx/grammar/attributes.hpp \
23lib/eolian_cxx/grammar/eo_class_generator.hh \ 17lib/eolian_cxx/grammar/base_class_definition.hpp \
24lib/eolian_cxx/grammar/eo_header_generator.hh \ 18lib/eolian_cxx/grammar/case.hpp \
25lib/eolian_cxx/grammar/inheritance_base_generator.hh \ 19lib/eolian_cxx/grammar/class_declaration.hpp \
26lib/eolian_cxx/grammar/parameters_generator.hh \ 20lib/eolian_cxx/grammar/class_definition.hpp \
27lib/eolian_cxx/grammar/type_generator.hh \ 21lib/eolian_cxx/grammar/class_implementation.hpp \
28lib/eolian_cxx/grammar/tab.hh 22lib/eolian_cxx/grammar/container.hpp \
23lib/eolian_cxx/grammar/context.hpp \
24lib/eolian_cxx/grammar/converting_argument.hpp \
25lib/eolian_cxx/grammar/c_type.hpp \
26lib/eolian_cxx/grammar/eps.hpp \
27lib/eolian_cxx/grammar/function_declaration.hpp \
28lib/eolian_cxx/grammar/function_definition.hpp \
29lib/eolian_cxx/grammar/generator.hpp \
30lib/eolian_cxx/grammar/header_guards.hpp \
31lib/eolian_cxx/grammar/header.hpp \
32lib/eolian_cxx/grammar/header_include_directive.hpp \
33lib/eolian_cxx/grammar/implementation_include_directive.hpp \
34lib/eolian_cxx/grammar/impl_header.hpp \
35lib/eolian_cxx/grammar/indentation.hpp \
36lib/eolian_cxx/grammar/keyword.hpp \
37lib/eolian_cxx/grammar/klass_def.hpp \
38lib/eolian_cxx/grammar/kleene.hpp \
39lib/eolian_cxx/grammar/list.hpp \
40lib/eolian_cxx/grammar/meta.hpp \
41lib/eolian_cxx/grammar/namespace.hpp \
42lib/eolian_cxx/grammar/parameter.hpp \
43lib/eolian_cxx/grammar/qualifier_def.hpp \
44lib/eolian_cxx/grammar/sequence.hpp \
45lib/eolian_cxx/grammar/string.hpp \
46lib/eolian_cxx/grammar/type.hpp \
47lib/eolian_cxx/grammar/type_impl.hpp \
48lib/eolian_cxx/grammar/type_traits.hpp \
49lib/eolian_cxx/grammar/variant.hpp
29 50
30### Binary 51### Binary
31 52
32bin_PROGRAMS += bin/eolian_cxx/eolian_cxx 53bin_PROGRAMS += bin/eolian_cxx/eolian_cxx
33 54
34bin_eolian_cxx_eolian_cxx_SOURCES = \ 55bin_eolian_cxx_eolian_cxx_SOURCES = \
35 bin/eolian_cxx/convert_comments.cc \
36 bin/eolian_cxx/convert_comments.hh \
37 bin/eolian_cxx/convert.cc \
38 bin/eolian_cxx/convert.hh \
39 bin/eolian_cxx/eolian_wrappers.hh \
40 bin/eolian_cxx/safe_strings.hh \
41 bin/eolian_cxx/type_lookup.hh \
42 bin/eolian_cxx/type_lookup_table.cc \
43 bin/eolian_cxx/eolian_cxx.cc 56 bin/eolian_cxx/eolian_cxx.cc
44 57
45bin_eolian_cxx_eolian_cxx_CXXFLAGS = -I$(top_builddir)/src/lib/efl \ 58bin_eolian_cxx_eolian_cxx_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
@@ -63,32 +76,29 @@ TESTS += tests/eolian_cxx/eolian_cxx_suite
63tests_eolian_cxx_eolian_cxx_suite_SOURCES = \ 76tests_eolian_cxx_eolian_cxx_suite_SOURCES = \
64tests/eolian_cxx/eolian_cxx_suite.cc \ 77tests/eolian_cxx/eolian_cxx_suite.cc \
65tests/eolian_cxx/eolian_cxx_test_parse.cc \ 78tests/eolian_cxx/eolian_cxx_test_parse.cc \
66tests/eolian_cxx/callback.c \
67tests/eolian_cxx/a.c \ 79tests/eolian_cxx/a.c \
68tests/eolian_cxx/b.c \ 80tests/eolian_cxx/b.c \
69tests/eolian_cxx/c.c \ 81tests/eolian_cxx/c.c \
70tests/eolian_cxx/d.c \ 82tests/eolian_cxx/d.c \
71tests/eolian_cxx/eolian_cxx_test_binding.cc \ 83tests/eolian_cxx/eolian_cxx_test_binding.cc \
72tests/eolian_cxx/eolian_cxx_test_callback.cc \
73tests/eolian_cxx/eolian_cxx_test_address_of.cc \ 84tests/eolian_cxx/eolian_cxx_test_address_of.cc \
74tests/eolian_cxx/eolian_cxx_test_wrapper.cc \ 85tests/eolian_cxx/eolian_cxx_test_wrapper.cc \
75tests/eolian_cxx/simple.c \ 86tests/eolian_cxx/simple.c \
76tests/eolian_cxx/name_name.c \ 87tests/eolian_cxx/name_name.c \
77tests/eolian_cxx/name_name_cxx.cc \ 88tests/eolian_cxx/name_name_cxx.cc \
78tests/eolian_cxx/generic.c \ 89tests/eolian_cxx/generic.c \
90tests/eolian_cxx/name1_name2_type_generation.c \
79tests/eolian_cxx/eolian_cxx_test_inheritance.cc \ 91tests/eolian_cxx/eolian_cxx_test_inheritance.cc \
80tests/eolian_cxx/eolian_cxx_test_generate.cc \ 92tests/eolian_cxx/eolian_cxx_test_generate.cc \
81tests/eolian_cxx/complex.c \ 93tests/eolian_cxx/complex.c \
82tests/eolian_cxx/complex_cxx.cc \ 94tests/eolian_cxx/complex_cxx.cc \
83tests/eolian_cxx/eolian_cxx_suite.h 95tests/eolian_cxx/eolian_cxx_suite.h
84 96
85tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-eolian_cxx_test_wrapper.$(OBJEXT): tests/eolian_cxx/callback.eo.hh tests/eolian_cxx/callback.eo.h 97tests/eolian_cxx/name1_name2_type_generation.$(OBJEXT): tests/eolian_cxx/name1_name2_type_generation.eo.h tests/eolian_cxx/name1_name2_type_generation.eo.c
86tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-eolian_cxx_test_callback.$(OBJEXT): tests/eolian_cxx/callback.eo.hh tests/eolian_cxx/callback.eo.h
87tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-eolian_cxx_test_inheritance.$(OBJEXT): tests/eolian_cxx/simple.eo.hh tests/eolian_cxx/simple.eo.h 98tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-eolian_cxx_test_inheritance.$(OBJEXT): tests/eolian_cxx/simple.eo.hh tests/eolian_cxx/simple.eo.h
88tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-eolian_cxx_test_binding.$(OBJEXT): tests/eolian_cxx/generic.eo.hh tests/eolian_cxx/generic.eo.h 99tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-eolian_cxx_test_binding.$(OBJEXT): tests/eolian_cxx/generic.eo.hh tests/eolian_cxx/generic.eo.h tests/eolian_cxx/name1_name2_type_generation.eo.hh tests/eolian_cxx/name1_name2_type_generation.eo.h tests/eolian_cxx/name1_name2_type_generation.eo.c
89tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-eolian_cxx_test_address_of.$(OBJEXT): tests/eolian_cxx/a.eo.hh tests/eolian_cxx/b.eo.hh tests/eolian_cxx/c.eo.hh tests/eolian_cxx/d.eo.hh tests/eolian_cxx/a.eo.h tests/eolian_cxx/b.eo.h tests/eolian_cxx/c.eo.h tests/eolian_cxx/d.eo.h 100tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-eolian_cxx_test_address_of.$(OBJEXT): tests/eolian_cxx/a.eo.hh tests/eolian_cxx/b.eo.hh tests/eolian_cxx/c.eo.hh tests/eolian_cxx/d.eo.hh tests/eolian_cxx/a.eo.h tests/eolian_cxx/b.eo.h tests/eolian_cxx/c.eo.h tests/eolian_cxx/d.eo.h
90 101
91tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-callback.$(OBJEXT): tests/eolian_cxx/callback.eo.c tests/eolian_cxx/callback.eo.h
92tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-simple.$(OBJEXT): tests/eolian_cxx/simple.eo.c tests/eolian_cxx/simple.eo.h 102tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-simple.$(OBJEXT): tests/eolian_cxx/simple.eo.c tests/eolian_cxx/simple.eo.h
93tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-generic.$(OBJEXT): tests/eolian_cxx/generic.eo.c tests/eolian_cxx/generic.eo.h 103tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-generic.$(OBJEXT): tests/eolian_cxx/generic.eo.c tests/eolian_cxx/generic.eo.h
94tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-a.$(OBJEXT): tests/eolian_cxx/a.eo.c tests/eolian_cxx/a.eo.h 104tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-a.$(OBJEXT): tests/eolian_cxx/a.eo.c tests/eolian_cxx/a.eo.h
@@ -103,10 +113,6 @@ tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-complex.$(OBJEXT): tests/eoli
103tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-complex_cxx.$(OBJEXT): tests/eolian_cxx/complex.eo.h tests/eolian_cxx/complex.eo.hh 113tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-complex_cxx.$(OBJEXT): tests/eolian_cxx/complex.eo.h tests/eolian_cxx/complex.eo.hh
104 114
105CLEANFILES += \ 115CLEANFILES += \
106tests/eolian_cxx/callback.eo.hh \
107tests/eolian_cxx/callback.eo.c \
108tests/eolian_cxx/callback.eo.h \
109tests/eolian_cxx/callback.eo.impl.hh \
110tests/eolian_cxx/simple.eo.c \ 116tests/eolian_cxx/simple.eo.c \
111tests/eolian_cxx/simple.eo.h \ 117tests/eolian_cxx/simple.eo.h \
112tests/eolian_cxx/simple.eo.hh \ 118tests/eolian_cxx/simple.eo.hh \
@@ -134,7 +140,11 @@ tests/eolian_cxx/ns_name_other.eo.impl.hh \
134tests/eolian_cxx/complex.eo.hh \ 140tests/eolian_cxx/complex.eo.hh \
135tests/eolian_cxx/complex.eo.c \ 141tests/eolian_cxx/complex.eo.c \
136tests/eolian_cxx/complex.eo.h \ 142tests/eolian_cxx/complex.eo.h \
137tests/eolian_cxx/complex.eo.impl.hh 143tests/eolian_cxx/complex.eo.impl.hh \
144tests/eolian_cxx/name1_name2_type_generation.eo.hh \
145tests/eolian_cxx/name1_name2_type_generation.eo.impl.hh \
146tests/eolian_cxx/name1_name2_type_generation.eo.h \
147tests/eolian_cxx/name1_name2_type_generation.eo.c
138 148
139 149
140tests_eolian_cxx_eolian_cxx_suite_CXXFLAGS = \ 150tests_eolian_cxx_eolian_cxx_suite_CXXFLAGS = \
@@ -159,7 +169,7 @@ tests_eolian_cxx_eolian_cxx_suite_DEPENDENCIES = @USE_EOLIAN_INTERNAL_LIBS@
159 169
160endif 170endif
161 171
162EXTRA_DIST += tests/eolian_cxx/callback.eo \ 172EXTRA_DIST += \
163tests/eolian_cxx/simple.eo \ 173tests/eolian_cxx/simple.eo \
164tests/eolian_cxx/generic.eo \ 174tests/eolian_cxx/generic.eo \
165tests/eolian_cxx/a.eo \ 175tests/eolian_cxx/a.eo \
@@ -169,6 +179,7 @@ tests/eolian_cxx/d.eo \
169tests/eolian_cxx/name_name.eo \ 179tests/eolian_cxx/name_name.eo \
170tests/eolian_cxx/ns_name.eo \ 180tests/eolian_cxx/ns_name.eo \
171tests/eolian_cxx/ns_name_other.eo \ 181tests/eolian_cxx/ns_name_other.eo \
182tests/eolian_cxx/name1_name2_type_generation.eo \
172tests/eolian_cxx/complex.eo 183tests/eolian_cxx/complex.eo
173 184
174include Makefile_Eolian_Cxx_Helper.am 185include Makefile_Eolian_Cxx_Helper.am
diff --git a/src/bin/eolian_cxx/convert.cc b/src/bin/eolian_cxx/convert.cc
deleted file mode 100644
index 97e88c9171..0000000000
--- a/src/bin/eolian_cxx/convert.cc
+++ /dev/null
@@ -1,373 +0,0 @@
1
2#include <vector>
3#include <set>
4#include <map>
5#include <algorithm>
6#include <cassert>
7#include <cstddef>
8
9#ifdef HAVE_CONFIG_H
10# include <config.h>
11#endif
12
13#include <Eina.hh>
14#include <Eolian.h>
15
16#include "eo_types.hh"
17#include "eo_validate.hh"
18
19#include "safe_strings.hh"
20#include "convert_comments.hh"
21#include "eolian_wrappers.hh"
22
23namespace eolian_cxx {
24
25extern efl::eina::log_domain domain;
26typedef std::map<efl::eolian::eo_event, bool> event_map;
27
28void
29add_ancestor_recursive(const char* klass_name, std::set<std::string>& ancestor)
30{
31 if (!klass_name)
32 return;
33
34 Eolian_Class const* klass = ::eolian_class_get_by_name(klass_name);
35 if (!klass)
36 {
37 std::cerr << "Error: could not get eolian class name `" << klass_name << "'" << std::endl;
38 return;
39 }
40
41 ancestor.insert(class_format_cxx(safe_str(klass_name)));
42
43 Eina_Iterator* inheritances = ::eolian_class_inherits_get(klass);
44 void* curr = 0;
45
46 EINA_ITERATOR_FOREACH(inheritances, curr)
47 {
48 add_ancestor_recursive(static_cast<const char*>(curr), ancestor);
49 }
50 eina_iterator_free(inheritances);
51}
52
53void
54add_events_recursive(event_map& events, Eolian_Class const& klass, std::set<std::string>& ancestors)
55{
56 for (efl::eolian::eo_event const& e : event_list(klass))
57 {
58 auto it = events.find(e);
59 if (it == events.end())
60 events[e] = true;
61 else
62 it->second = false;
63 }
64
65 Eina_Iterator* inheritances = ::eolian_class_inherits_get(&klass);
66 void* curr = 0;
67
68 EINA_ITERATOR_FOREACH(inheritances, curr)
69 {
70 const char* ancestor_name = static_cast<const char*>(curr);
71 if (!ancestor_name || ancestors.find(ancestor_name) != ancestors.end())
72 continue;
73
74 Eolian_Class const* ancestor_klass = ::eolian_class_get_by_name(ancestor_name);
75 if (!ancestor_klass)
76 {
77 std::cerr << "Error: could not get eolian class name `" << ancestor_name << "'" << std::endl;
78 continue;
79 }
80 ancestors.insert(ancestor_name);
81 add_events_recursive(events, *ancestor_klass, ancestors);
82 }
83
84 eina_iterator_free(inheritances);
85}
86
87static efl::eolian::parameters_container_type
88_convert_eolian_parameters(Eina_Iterator *parameters,
89 Eolian_Function_Type func_type)
90{
91 if (parameters == NULL) return {};
92 assert(func_type != EOLIAN_PROPERTY);
93
94 void *curr;
95 efl::eolian::parameters_container_type list;
96 EINA_ITERATOR_FOREACH(parameters, curr)
97 {
98 const Eolian_Function_Parameter *id =
99 (static_cast<const Eolian_Function_Parameter*>(curr));
100 list.push_back
101 ({
102 parameter_type(*id),
103 parameter_name(*id)
104 });
105 }
106 eina_iterator_free(parameters);
107 return list;
108}
109
110static efl::eolian::parameters_container_type
111_convert_eolian_parameters(Eina_Iterator *parameters, getter_t func_type)
112{
113 return _convert_eolian_parameters(parameters, func_type.value);
114}
115
116static efl::eolian::parameters_container_type
117_convert_eolian_parameters(Eina_Iterator *parameters, setter_t func_type)
118{
119 return _convert_eolian_parameters(parameters, func_type.value);
120}
121
122static efl::eolian::parameters_container_type
123_convert_eolian_parameters(Eolian_Function const& func)
124{
125 assert(function_op_type(func) != EOLIAN_PROPERTY);
126 return _convert_eolian_parameters
127 (::eolian_function_parameters_get(&func), function_op_type(func));
128}
129
130static efl::eolian::eo_function
131_convert_property_set_to_function(Eolian_Class const& klass,
132 Eolian_Function const& prop_)
133{
134 efl::eolian::eo_function set_ =
135 {
136 efl::eolian::eo_function::regular_,
137 function_scope(prop_),
138 function_is_beta(prop_),
139 function_name(prop_) + "_set",
140 function_impl(prop_) + "_set",
141 function_return_type(prop_, eolian_cxx::setter),
142 _convert_eolian_parameters(::eolian_property_values_get(&prop_, EOLIAN_PROP_SET),
143 eolian_cxx::setter),
144 convert_comments_function(klass, prop_, eolian_cxx::setter)
145 };
146 efl::eolian::parameters_container_type keys =
147 _convert_eolian_parameters(::eolian_property_keys_get(&prop_, EOLIAN_PROP_SET),
148 eolian_cxx::setter);
149 if (!keys.empty())
150 {
151 keys.reserve(keys.size() + set_.params.size());
152 keys.insert(keys.end(), set_.params.begin(),
153 set_.params.end());
154 set_.params = keys;
155 }
156 return set_;
157}
158
159static efl::eolian::eo_function
160_convert_property_get_to_function(Eolian_Class const& klass,
161 Eolian_Function const& prop_)
162{
163 efl::eolian::eo_function get_ =
164 {
165 efl::eolian::eo_function::regular_,
166 function_scope(prop_),
167 function_is_beta(prop_),
168 function_name(prop_) + "_get",
169 function_impl(prop_) + "_get",
170 function_return_type(prop_, eolian_cxx::getter),
171 _convert_eolian_parameters(::eolian_property_values_get(&prop_, EOLIAN_PROP_GET),
172 eolian_cxx::getter),
173 convert_comments_function(klass, prop_, eolian_cxx::getter)
174 };
175
176 // if the getter has a single parameter and a void return
177 // it is transformed into a getter with no parameters
178 // that actually returns what would be the first argument.
179 if (get_.params.size() == 1 && efl::eolian::type_is_void(get_.ret) &&
180 !function_return_is_explicit_void(prop_, eolian_cxx::getter))
181 {
182 get_.ret = get_.params[0].type;
183 get_.params.clear();
184 }
185 else // otherwise just create the described getter
186 {
187 std::transform
188 (get_.params.begin(), get_.params.end(), get_.params.begin(),
189 [](efl::eolian::eo_parameter const& param)
190 {
191 efl::eolian::eolian_type getter_param_type =
192 type_to_native(param.type);
193 getter_param_type.native += "*";
194 return efl::eolian::eo_parameter
195 { { getter_param_type }, param.name };
196 });
197 }
198 efl::eolian::parameters_container_type keys =
199 _convert_eolian_parameters(::eolian_property_keys_get(&prop_, EOLIAN_PROP_GET),
200 eolian_cxx::getter);
201 if (!keys.empty())
202 {
203 keys.reserve(keys.size() + get_.params.size());
204 keys.insert(keys.end(), get_.params.begin(),
205 get_.params.end());
206 get_.params = keys;
207 }
208 return get_;
209}
210
211static efl::eolian::eo_function
212_convert_function(Eolian_Class const& klass, Eolian_Function const& func)
213{
214 return {
215 function_type(func),
216 function_scope(func),
217 function_is_beta(func),
218 function_name(func),
219 function_impl(func),
220 function_return_type(func),
221 _convert_eolian_parameters(func),
222 convert_comments_function(klass, func, eolian_cxx::method)
223 };
224}
225
226
227void
228convert_eolian_inheritances(efl::eolian::eo_class& cls, Eolian_Class const& klass)
229{
230 Eina_Iterator *inheritances =
231 ::eolian_class_inherits_get(&klass);
232 void *curr;
233
234 std::set<std::string> ancestors;
235
236 EINA_ITERATOR_FOREACH(inheritances, curr)
237 {
238 const char* klass_name = static_cast<const char*>(curr);
239 cls.parents.push_back(class_format_cxx(safe_str(klass_name)));
240 add_ancestor_recursive(klass_name, ancestors);
241 }
242 eina_iterator_free(inheritances);
243
244 cls.ancestors.assign(ancestors.begin(), ancestors.end());
245}
246
247void
248convert_eolian_events(efl::eolian::eo_class& cls, Eolian_Class const& klass)
249{
250 efl::eolian::events_container_type events = event_list(klass);
251 cls.own_events.reserve(cls.own_events.size() + events.size());
252 cls.own_events.insert(cls.own_events.end(), events.begin(), events.end());
253
254 event_map concrete_events;
255 std::set<std::string> ancestors;
256
257 add_events_recursive(concrete_events, klass, ancestors);
258
259 for (auto const& e : events)
260 {
261 concrete_events[e] = true;
262 }
263
264 for (auto const& pair : concrete_events)
265 {
266 if (pair.second)
267 cls.concrete_events.push_back(pair.first);
268 }
269}
270
271efl::eolian::eo_class
272convert_eolian_class_new(Eolian_Class const& klass)
273{
274 efl::eolian::eo_class cls;
275 cls.type = class_type(klass);
276 cls.name = class_name(klass);
277 cls.name_space = class_namespace_full(klass);
278 if(cls.name_space.empty())
279 cls.name_space = "nonamespace";
280 cls.eo_name = class_eo_name(klass);
281 cls.comment = convert_comments_class(klass);
282 return cls;
283}
284
285void
286convert_eolian_functions(efl::eolian::eo_class& cls, Eolian_Class const& klass)
287{
288 for(efl::eina::iterator<const Eolian_Function> first ( ::eolian_class_functions_get(&klass, EOLIAN_METHOD))
289 , last; first != last; ++first)
290 {
291 Eolian_Function const& func = *first;
292
293 if (function_is_visible(func, function_op_type(func)) &&
294 !function_is_constructor(klass, func))
295 {
296 cls.functions.push_back(_convert_function(klass, func));
297 }
298 }
299 if (class_eo_name(klass) != "EO_BASE_CLASS")
300 for(efl::eina::iterator<const Eolian_Constructor> first ( ::eolian_class_constructors_get(&klass))
301 , last; first != last; ++first)
302 {
303 Eolian_Constructor const& ctor = *first;
304 Eolian_Function const& func = *(::eolian_constructor_function_get(&ctor));
305
306 efl::eolian::eo_function f;
307 if (function_op_type(func) == EOLIAN_METHOD)
308 f = _convert_function(klass, func);
309 else
310 f = _convert_property_set_to_function(klass, func);
311
312
313 (::eolian_constructor_is_optional(&ctor) ?
314 cls.optional_constructors :
315 cls.constructors
316 ).push_back({
317 function_name(func),
318 f.impl,
319 f.params,
320 f.comment
321 });
322 }
323
324 cls.all_constructors = cls.constructors;
325 cls.all_constructors.insert(cls.all_constructors.end(),
326 cls.optional_constructors.begin(), cls.optional_constructors.end());
327
328 for(efl::eina::iterator<const Eolian_Function> first ( ::eolian_class_functions_get(&klass, EOLIAN_PROPERTY))
329 , last; first != last; ++first)
330 {
331 Eolian_Function const& func = *first;
332 Eolian_Function_Type t = ::eolian_function_type_get(&func);
333
334 if (!function_is_visible(func, t))
335 continue;
336
337 if(t == EOLIAN_PROP_GET)
338 {
339 cls.functions.push_back
340 (_convert_property_get_to_function(klass, func));
341 }
342 else if(t == EOLIAN_PROP_SET)
343 {
344 cls.functions.push_back
345 (_convert_property_set_to_function(klass, func));
346 }
347 else if(t == EOLIAN_PROPERTY)
348 {
349 cls.functions.push_back
350 (_convert_property_get_to_function(klass, func));
351 cls.functions.push_back
352 (_convert_property_set_to_function(klass, func));
353 }
354 else
355 {
356 std::cerr << "Error: Inconsistent type for Eolian function \'" << ::eolian_function_name_get(&func) << "\'." << std::endl;
357 throw std::runtime_error("Invalid Eolian function type");
358 }
359 }
360}
361
362efl::eolian::eo_class
363convert_eolian_class(const Eolian_Class& klass)
364{
365 efl::eolian::eo_class cls(eolian_cxx::convert_eolian_class_new(klass));
366 eolian_cxx::convert_eolian_inheritances(cls, klass);
367 eolian_cxx::convert_eolian_functions(cls, klass);
368 eolian_cxx::convert_eolian_events(cls, klass);
369 efl::eolian::eo_class_validate(cls);
370 return cls;
371}
372
373} // namespace eolian_cxx {
diff --git a/src/bin/eolian_cxx/convert.hh b/src/bin/eolian_cxx/convert.hh
deleted file mode 100644
index df829f4afe..0000000000
--- a/src/bin/eolian_cxx/convert.hh
+++ /dev/null
@@ -1,19 +0,0 @@
1
2#ifndef EOLIAN_CXX_EOLIAN_CONVERT_CLASSES_HH
3#define EOLIAN_CXX_EOLIAN_CONVERT_CLASSES_HH
4
5#include "eo_types.hh"
6
7namespace eolian_cxx
8{
9
10///
11/// @brief Retrieve a efl::eolian::eo_class from an Eolian_Class* name.
12/// @param cls The Eolian class.
13/// @return The @p eo_class describing @p classname.
14///
15efl::eolian::eo_class convert_eolian_class(const Eolian_Class& klass);
16
17}
18
19#endif // EOLIAN_CXX_EOLIAN_CONVERT_CLASSES_HH
diff --git a/src/bin/eolian_cxx/convert_comments.cc b/src/bin/eolian_cxx/convert_comments.cc
deleted file mode 100644
index 94fed90c72..0000000000
--- a/src/bin/eolian_cxx/convert_comments.cc
+++ /dev/null
@@ -1,95 +0,0 @@
1
2#include "convert_comments.hh"
3#include "safe_strings.hh"
4
5namespace eolian_cxx {
6
7static std::string
8_comment_parameter(Eolian_Function_Parameter *param)
9{
10 Eolian_Parameter_Dir direction = eolian_parameter_direction_get(param);
11
12 std::string doc = "@param";
13 if (direction == EOLIAN_IN_PARAM) doc += " ";
14 else if (direction == EOLIAN_OUT_PARAM) doc += "[out] ";
15 else if (direction == EOLIAN_INOUT_PARAM) doc += "[inout] ";
16 else assert(false);
17
18 doc += safe_str(::eolian_parameter_name_get(param));
19 doc += " ";
20 /* FIXME */
21 doc += safe_str(NULL);
22
23 return doc;
24}
25
26static std::string
27_comment_parameters_list(Eina_Iterator *params)
28{
29 std::string doc = "";
30 void *curr;
31 EINA_ITERATOR_FOREACH(params, curr)
32 {
33 doc += _comment_parameter
34 (static_cast<Eolian_Function_Parameter*>(curr)) + "\n";
35 }
36 eina_iterator_free(params);
37 return doc;
38}
39
40static std::string
41_comment_brief_and_params(Eolian_Function const& function, Eolian_Function_Type)
42{
43 std::string doc = "";
44 /* FIXME */
45 std::string func = safe_str(NULL);
46 if (func != "")
47 {
48 doc += "@brief " + func + "\n\n";
49 }
50 std::string params = _comment_parameters_list(::eolian_function_parameters_get(&function));
51 if (params != "")
52 {
53 doc += params + "\n";
54 }
55 return doc;
56}
57
58static std::string
59_comment_return(Eolian_Function const& function,
60 Eolian_Function_Type rettype)
61{
62 const Eolian_Type *rettypet = ::eolian_function_return_type_get(&function, rettype);
63 const char *rettypes = NULL;
64 if (rettypet) rettypes = ::eolian_type_c_type_get(rettypet);
65 std::string doc = "";
66 std::string ret = safe_str(rettypes);
67 if (rettypes) eina_stringshare_del(rettypes);
68 /* FIXME */
69 std::string comment = safe_str(NULL);
70 if (ret != "void" && ret != "" && comment != "")
71 {
72 doc = "@return " + comment;
73 }
74 return doc;
75}
76
77std::string
78convert_comments_class(Eolian_Class const&)
79{
80 /* FIXME */
81 return safe_str(NULL);
82}
83
84std::string
85convert_comments_function(Eolian_Class const& klass,
86 Eolian_Function const& function,
87 Eolian_Function_Type func_type)
88{
89 std::string doc = _comment_brief_and_params(function, func_type);
90 if (!function_is_constructor(klass, function))
91 doc += _comment_return(function, func_type);
92 return doc;
93}
94
95} // namespace eolian_cxx
diff --git a/src/bin/eolian_cxx/convert_comments.hh b/src/bin/eolian_cxx/convert_comments.hh
deleted file mode 100644
index 788362e4be..0000000000
--- a/src/bin/eolian_cxx/convert_comments.hh
+++ /dev/null
@@ -1,46 +0,0 @@
1
2#ifndef EOLIAN_CXX_CONVERT_COMMENTS_HH
3#define EOLIAN_CXX_CONVERT_COMMENTS_HH
4
5#include <string>
6
7#include <Eolian.h>
8#include <Eolian_Cxx.hh>
9
10#include "eolian_wrappers.hh"
11
12namespace eolian_cxx {
13
14std::string convert_comments_class(Eolian_Class const& klass);
15
16std::string convert_comments_function(Eolian_Class const& klass,
17 Eolian_Function const& function,
18 Eolian_Function_Type func_type);
19
20inline std::string
21convert_comments_function(Eolian_Class const& klass, Eolian_Function const& function_, method_t func_type_)
22{
23 return convert_comments_function(klass, function_, func_type_.value);
24}
25
26inline std::string
27convert_comments_function(Eolian_Class const& klass, Eolian_Function const& property_, getter_t func_type_)
28{
29 return convert_comments_function(klass, property_, func_type_.value);
30}
31
32inline std::string
33convert_comments_function(Eolian_Class const& klass, Eolian_Function const& property_, setter_t func_type_)
34{
35 return convert_comments_function(klass, property_, func_type_.value);
36}
37
38inline std::string
39convert_comments_function(Eolian_Class const& klass, Eolian_Function const& function_)
40{
41 return convert_comments_function(klass, function_, eolian_cxx::method);
42}
43
44}
45
46#endif // EOLIAN_CXX_CONVERT_COMMENTS_HH
diff --git a/src/bin/eolian_cxx/eolian_cxx.cc b/src/bin/eolian_cxx/eolian_cxx.cc
index d7f3d935b5..12cd5f4ee6 100644
--- a/src/bin/eolian_cxx/eolian_cxx.cc
+++ b/src/bin/eolian_cxx/eolian_cxx.cc
@@ -21,12 +21,9 @@
21#include <Eina.hh> 21#include <Eina.hh>
22#include <Eolian_Cxx.hh> 22#include <Eolian_Cxx.hh>
23 23
24#include "convert.hh" 24#include "grammar/klass_def.hpp"
25#include "type_lookup.hh" 25#include "grammar/header.hpp"
26 26#include "grammar/impl_header.hpp"
27#include "convert.hh"
28#include "eolian_wrappers.hh"
29#include "safe_strings.hh"
30 27
31namespace eolian_cxx { 28namespace eolian_cxx {
32 29
@@ -36,20 +33,6 @@ struct options_type
36 std::vector<std::string> include_dirs; 33 std::vector<std::string> include_dirs;
37 std::string in_file; 34 std::string in_file;
38 std::string out_file; 35 std::string out_file;
39 std::string out_dir;
40 std::string classname;
41 bool recurse;
42 bool generate_all;
43
44 options_type()
45 : include_dirs()
46 , in_file()
47 , out_file()
48 , out_dir()
49 , classname()
50 , recurse(false)
51 , generate_all(false)
52 {}
53}; 36};
54 37
55efl::eina::log_domain domain("eolian_cxx"); 38efl::eina::log_domain domain("eolian_cxx");
@@ -57,29 +40,11 @@ efl::eina::log_domain domain("eolian_cxx");
57static bool 40static bool
58opts_check(eolian_cxx::options_type const& opts) 41opts_check(eolian_cxx::options_type const& opts)
59{ 42{
60 if (!opts.generate_all && opts.in_file.empty()) 43 if (opts.in_file.empty())
61 { 44 {
62 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain) 45 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
63 << "Nothing to generate?" << std::endl; 46 << "Nothing to generate?" << std::endl;
64 } 47 }
65 else if (opts.generate_all && !opts.in_file.empty())
66 {
67 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
68 << "Didn't expect to receive input files (" << opts.in_file
69 << ") with parameter -a."
70 << std::endl;
71 }
72 else if (opts.generate_all && !opts.out_file.empty())
73 {
74 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
75 << "Can't use -a and -o together." << std::endl;
76 }
77 else if (opts.generate_all && opts.include_dirs.empty())
78 {
79 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
80 << "Option -a requires at least one include directory (-I)."
81 << std::endl;
82 }
83 else 48 else
84 { 49 {
85 return true; // valid. 50 return true; // valid.
@@ -87,39 +52,11 @@ opts_check(eolian_cxx::options_type const& opts)
87 return false; 52 return false;
88} 53}
89 54
90efl::eolian::eo_generator_options
91generator_options(const Eolian_Class& klass)
92{
93 efl::eolian::eo_generator_options gen_opts;
94 gen_opts.c_headers.push_back(class_base_file(klass) + ".h");
95
96 void *cur = NULL;
97 Eina_Iterator *inheritances = ::eolian_class_inherits_get(&klass);
98 EINA_ITERATOR_FOREACH(inheritances, cur)
99 {
100 const Eolian_Class *ext = ::eolian_class_get_by_name(static_cast<const char*>(cur));
101 std::string eo_parent_file = class_base_file(*ext);
102 if (!eo_parent_file.empty())
103 {
104 gen_opts.cxx_headers.push_back(eo_parent_file + ".hh");
105 }
106 else
107 {
108 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
109 << "Couldn't find source file for class '" << ext << "'"
110 << std::endl;
111 }
112 }
113 eina_iterator_free(inheritances);
114 return gen_opts;
115}
116
117static bool 55static bool
118generate(const Eolian_Class& klass, eolian_cxx::options_type const& opts) 56generate(const Eolian_Class* klass, eolian_cxx::options_type const& opts)
119{ 57{
120 efl::eolian::eo_class cls = eolian_cxx::convert_eolian_class(klass); 58 std::string header_decl_file_name = opts.out_file.empty()
121 efl::eolian::eo_generator_options gen_opts = generator_options(klass); 59 ? (::eolian_class_file_get(klass) + std::string(".hh")) : opts.out_file;
122 std::string header_decl_file_name = opts.out_file.empty() ? (class_base_file(klass) + ".hh") : opts.out_file;
123 60
124 std::string header_impl_file_name = header_decl_file_name; 61 std::string header_impl_file_name = header_decl_file_name;
125 std::size_t dot_pos = header_impl_file_name.rfind(".hh"); 62 std::size_t dot_pos = header_impl_file_name.rfind(".hh");
@@ -128,24 +65,101 @@ generate(const Eolian_Class& klass, eolian_cxx::options_type const& opts)
128 else 65 else
129 header_impl_file_name.insert(header_impl_file_name.size(), ".impl"); 66 header_impl_file_name.insert(header_impl_file_name.size(), ".impl");
130 67
131 std::size_t slash_pos = header_decl_file_name.rfind('/'); 68 efl::eolian::grammar::attributes::klass_def klass_def(klass);
132 gen_opts.header_decl_file_name = (slash_pos == std::string::npos) ? 69 std::vector<efl::eolian::grammar::attributes::klass_def> klasses{klass_def};
133 header_decl_file_name : 70
134 header_decl_file_name.substr(slash_pos+1); 71 std::set<std::string> c_headers;
135 72 std::set<std::string> cpp_headers;
136 slash_pos = header_impl_file_name.rfind('/'); 73 c_headers.insert(eolian_class_file_get(klass) + std::string(".h"));
137 gen_opts.header_impl_file_name = (slash_pos == std::string::npos) ? 74
138 header_impl_file_name : 75 std::function<void(efl::eolian::grammar::attributes::type_def const&)>
139 header_impl_file_name.substr(slash_pos+1); 76 variant_function;
77 auto klass_name_function
78 = [&] (efl::eolian::grammar::attributes::klass_name const& name)
79 {
80 Eolian_Class const* klass = get_klass(name);
81 assert(klass);
82 c_headers.insert(eolian_class_file_get(klass) + std::string(".h"));
83 cpp_headers.insert(eolian_class_file_get(klass) + std::string(".hh"));
84 };
85 auto complex_function
86 = [&] (efl::eolian::grammar::attributes::complex_type_def const& complex)
87 {
88 for(auto&& t : complex.subtypes)
89 {
90 variant_function(t);
91 }
92 };
93 variant_function = [&] (efl::eolian::grammar::attributes::type_def const& type)
94 {
95 if(efl::eolian::grammar::attributes::klass_name const*
96 name = efl::eolian::grammar::attributes::get<efl::eolian::grammar::attributes::klass_name>
97 (&type.original_type))
98 klass_name_function(*name);
99 else if(efl::eolian::grammar::attributes::complex_type_def const*
100 complex = efl::eolian::grammar::attributes::get<efl::eolian::grammar::attributes::complex_type_def>
101 (&type.original_type))
102 complex_function(*complex);
103 };
140 104
141 if (!opts.out_dir.empty()) 105 std::function<void(Eolian_Class const*)> klass_function
106 = [&] (Eolian_Class const* klass)
142 { 107 {
143 header_decl_file_name = opts.out_dir + "/" + header_decl_file_name; 108 for(efl::eina::iterator<const char> inherit_iterator ( ::eolian_class_inherits_get(klass))
144 header_impl_file_name = opts.out_dir + "/" + header_impl_file_name; 109 , inherit_last; inherit_iterator != inherit_last; ++inherit_iterator)
145 } 110 {
111 Eolian_Class const* inherit = ::eolian_class_get_by_name(&*inherit_iterator);
112 c_headers.insert(eolian_class_file_get(inherit) + std::string(".h"));
113 cpp_headers.insert(eolian_class_file_get(inherit) + std::string(".hh"));
114
115 klass_function(inherit);
116 }
117
118 efl::eolian::grammar::attributes::klass_def klass_def(klass);
119 for(auto&& f : klass_def.functions)
120 {
121 variant_function(f.return_type);
122 for(auto&& p : f.parameters)
123 {
124 variant_function(p.type);
125 }
126 }
127 for(auto&& e : klass_def.events)
128 {
129 if(e.type)
130 variant_function(*e.type);
131 }
132 };
133 klass_function(klass);
134
135 cpp_headers.erase(eolian_class_file_get(klass) + std::string(".hh"));
136
137 std::string guard_name;
138 as_generator(*(efl::eolian::grammar::string << "_") << efl::eolian::grammar::string << "_EO_HH")
139 .generate(std::back_insert_iterator<std::string>(guard_name)
140 , std::make_tuple(klass_def.namespaces, klass_def.eolian_name)
141 , efl::eolian::grammar::context_null{});
142
143 std::tuple<std::string, std::set<std::string>&, std::set<std::string>&
144 , std::vector<efl::eolian::grammar::attributes::klass_def>&
145 , std::vector<efl::eolian::grammar::attributes::klass_def>&
146 , std::vector<efl::eolian::grammar::attributes::klass_def>&
147 , std::vector<efl::eolian::grammar::attributes::klass_def>&
148 > attributes
149 {guard_name, c_headers, cpp_headers, klasses, klasses, klasses, klasses};
150
146 if(opts.out_file == "-") 151 if(opts.out_file == "-")
147 { 152 {
148 efl::eolian::generate(std::cout, std::cout, cls, gen_opts); 153 std::ostream_iterator<char> iterator(std::cout);
154
155 efl::eolian::grammar::class_header.generate(iterator, attributes, efl::eolian::grammar::context_null());
156 std::endl(std::cout);
157
158 efl::eolian::grammar::impl_header.generate(iterator, klasses, efl::eolian::grammar::context_null());
159
160 std::endl(std::cout);
161 std::flush(std::cout);
162 std::flush(std::cerr);
149 } 163 }
150 else 164 else
151 { 165 {
@@ -167,10 +181,18 @@ generate(const Eolian_Class& klass, eolian_cxx::options_type const& opts)
167 return false; 181 return false;
168 } 182 }
169 183
184#if 1
185 efl::eolian::grammar::class_header.generate
186 (std::ostream_iterator<char>(header_decl), attributes, efl::eolian::grammar::context_null());
187
188 efl::eolian::grammar::impl_header.generate
189 (std::ostream_iterator<char>(header_impl), klasses, efl::eolian::grammar::context_null());
190#else
170 efl::eolian::generate(header_decl, header_impl, cls, gen_opts); 191 efl::eolian::generate(header_decl, header_impl, cls, gen_opts);
192#endif
171 193
172 header_decl.close();
173 header_impl.close(); 194 header_impl.close();
195 header_decl.close();
174 } 196 }
175 return true; 197 return true;
176} 198}
@@ -179,34 +201,23 @@ static void
179run(options_type const& opts) 201run(options_type const& opts)
180{ 202{
181 const Eolian_Class *klass = NULL; 203 const Eolian_Class *klass = NULL;
182 if (!opts.classname.empty()) 204 char* dup = strdup(opts.in_file.c_str());
183 klass = class_from_name(opts.classname); 205 char* base = basename(dup);
184 else if (!opts.in_file.empty()) 206 klass = ::eolian_class_get_by_file(base);
185 klass = class_from_file(opts.in_file); 207 free(dup);
186 if (klass) 208 if (klass)
187 { 209 {
188 if (!generate(*klass, opts)) 210 if (!generate(klass, opts))
189 goto err; 211 goto err;
190 } 212 }
191 else 213 else
192 { 214 {
193 efl::eina::iterator<const Eolian_Class> it(class_list_all()); 215 std::abort();
194 efl::eina::iterator<const Eolian_Class> end;
195 while (it != end)
196 {
197 Eolian_Class c = (*it);
198 if (!generate(c, opts))
199 {
200 klass = &c;
201 goto err;
202 }
203 ++it;
204 }
205 } 216 }
206 return; 217 return;
207 err: 218 err:
208 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain) 219 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
209 << "Error generating: " << class_name(*klass) 220 << "Error generating: " << ::eolian_class_name_get(klass)
210 << std::endl; 221 << std::endl;
211 assert(false && "error generating class"); 222 assert(false && "error generating class");
212} 223}
@@ -228,20 +239,17 @@ database_load(options_type const& opts)
228 << "Eolian failed parsing eot files"; 239 << "Eolian failed parsing eot files";
229 assert(false && "Error parsing eot files"); 240 assert(false && "Error parsing eot files");
230 } 241 }
231 if (!opts.in_file.empty()) 242 if (opts.in_file.empty())
232 { 243 {
233 if (!::eolian_file_parse(opts.in_file.c_str())) 244 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
234 { 245 << "No input file.";
235 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain) 246 assert(false && "Error parsing input file");
236 << "Failed parsing: " << opts.in_file << ".";
237 assert(false && "Error parsing input file");
238 }
239 } 247 }
240 else if (!::eolian_all_eo_files_parse()) 248 if (!::eolian_file_parse(opts.in_file.c_str()))
241 { 249 {
242 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain) 250 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
243 << "Eolian failed parsing input files"; 251 << "Failed parsing: " << opts.in_file << ".";
244 assert(false && "Error parsing input files"); 252 assert(false && "Error parsing input file");
245 } 253 }
246 if (!::eolian_database_validate(EINA_FALSE)) 254 if (!::eolian_database_validate(EINA_FALSE))
247 { 255 {
@@ -299,11 +307,7 @@ opts_get(int argc, char **argv)
299 const struct option long_options[] = 307 const struct option long_options[] =
300 { 308 {
301 { "in", required_argument, 0, 'I' }, 309 { "in", required_argument, 0, 'I' },
302 { "out-dir", required_argument, 0, 'D' },
303 { "out-file", required_argument, 0, 'o' }, 310 { "out-file", required_argument, 0, 'o' },
304 { "class", required_argument, 0, 'c' },
305 { "all", no_argument, 0, 'a' },
306 { "recurse", no_argument, 0, 'r' },
307 { "version", no_argument, 0, 'v' }, 311 { "version", no_argument, 0, 'v' },
308 { "help", no_argument, 0, 'h' }, 312 { "help", no_argument, 0, 'h' },
309 { 0, 0, 0, 0 } 313 { 0, 0, 0, 0 }
@@ -317,29 +321,11 @@ opts_get(int argc, char **argv)
317 { 321 {
318 opts.include_dirs.push_back(optarg); 322 opts.include_dirs.push_back(optarg);
319 } 323 }
320 else if (c == 'D')
321 {
322 _assert_not_dup("D", opts.out_dir);
323 opts.out_dir = optarg;
324 }
325 else if (c == 'o') 324 else if (c == 'o')
326 { 325 {
327 _assert_not_dup("o", opts.out_file); 326 _assert_not_dup("o", opts.out_file);
328 opts.out_file = optarg; 327 opts.out_file = optarg;
329 } 328 }
330 else if (c == 'c')
331 {
332 _assert_not_dup("c", opts.classname);
333 opts.classname = optarg;
334 }
335 else if (c == 'a')
336 {
337 opts.generate_all = true;
338 }
339 else if (c == 'r')
340 {
341 opts.recurse = true;
342 }
343 else if (c == 'h') 329 else if (c == 'h')
344 { 330 {
345 _usage(argv[0]); 331 _usage(argv[0]);
diff --git a/src/bin/eolian_cxx/eolian_wrappers.hh b/src/bin/eolian_cxx/eolian_wrappers.hh
deleted file mode 100644
index c2b8f66a14..0000000000
--- a/src/bin/eolian_cxx/eolian_wrappers.hh
+++ /dev/null
@@ -1,430 +0,0 @@
1#ifndef EOLIAN_CXX_EOLIAN_WRAPPERS_HH
2#define EOLIAN_CXX_EOLIAN_WRAPPERS_HH
3
4#include <cassert>
5#include <libgen.h>
6
7#include <Eolian.h>
8
9#include "eo_types.hh"
10#include "safe_strings.hh"
11#include "type_lookup.hh"
12
13namespace eolian_cxx
14{
15
16struct property_t { static constexpr ::Eolian_Function_Type value = ::EOLIAN_PROPERTY; };
17property_t const property = {};
18
19struct setter_t { static constexpr ::Eolian_Function_Type value = ::EOLIAN_PROP_SET; };
20setter_t const setter = {};
21
22struct getter_t { static constexpr ::Eolian_Function_Type value = ::EOLIAN_PROP_GET; };
23getter_t const getter = {};
24
25struct method_t { static constexpr ::Eolian_Function_Type value = ::EOLIAN_METHOD; };
26method_t const method = {};
27
28inline efl::eolian::eolian_scope
29eolian_scope_cxx(Eolian_Object_Scope s)
30{
31 using efl::eolian::eolian_scope;
32 return s == EOLIAN_SCOPE_PRIVATE ? eolian_scope::private_ :
33 s == EOLIAN_SCOPE_PROTECTED ? eolian_scope::protected_ :
34 eolian_scope::public_;
35}
36
37inline const Eolian_Class*
38class_from_file(std::string const& file)
39{
40 char *dup = strdup(file.c_str());
41 char *bn = basename(dup);
42 const Eolian_Class *cl = ::eolian_class_get_by_file(bn);
43 free(dup);
44 return cl;
45}
46
47inline std::string
48class_file(Eolian_Class const& klass)
49{
50 return safe_str(::eolian_class_file_get(&klass));
51}
52
53inline std::string
54class_base_file(Eolian_Class const& klass)
55{
56 return path_base(safe_str(::eolian_class_file_get(&klass)));
57}
58
59inline std::string
60class_name(Eolian_Class const& klass)
61{
62 return ::eolian_class_name_get(&klass);
63}
64
65inline std::string
66class_full_name(Eolian_Class const& klass)
67{
68 return safe_str(::eolian_class_full_name_get(&klass));
69}
70
71inline const Eolian_Class *
72class_from_name(std::string const& classname)
73{
74 return ::eolian_class_get_by_name(classname.c_str());
75}
76
77inline std::string
78class_eo_name(Eolian_Class const& klass)
79{
80 std::string suffix;
81 switch (::eolian_class_type_get(&klass))
82 {
83 case EOLIAN_CLASS_REGULAR:
84 case EOLIAN_CLASS_ABSTRACT:
85 suffix = "CLASS";
86 break;
87 case EOLIAN_CLASS_MIXIN:
88 suffix = "MIXIN";
89 break;
90 case EOLIAN_CLASS_INTERFACE:
91 suffix = "INTERFACE";
92 break;
93 default:
94 break;
95 }
96 return safe_upper
97 (find_replace(class_full_name(klass) + "_" + suffix, ".", "_"));
98}
99
100inline efl::eolian::eo_class::eo_class_type
101class_type(Eolian_Class const& klass)
102{
103 efl::eolian::eo_class::eo_class_type type = {};
104 Eolian_Class_Type cls_type = ::eolian_class_type_get(&klass);
105
106 if (cls_type == EOLIAN_CLASS_REGULAR)
107 type = efl::eolian::eo_class::regular_;
108 else if (cls_type == EOLIAN_CLASS_ABSTRACT)
109 type = efl::eolian::eo_class::regular_noninst_;
110 else if (cls_type == EOLIAN_CLASS_MIXIN)
111 type = efl::eolian::eo_class::mixin_;
112 else if (cls_type == EOLIAN_CLASS_INTERFACE)
113 type = efl::eolian::eo_class::interface_;
114 else { assert(false); }
115
116 return type;
117}
118
119inline std::string
120class_namespace_full(Eolian_Class const& klass)
121{
122 std::string s;
123 Eina_Iterator* itr = ::eolian_class_namespaces_get(&klass);
124 void* name;
125 EINA_ITERATOR_FOREACH(itr, name)
126 {
127 s += static_cast<const char*>(name);
128 s += "::";
129 }
130 eina_iterator_free(itr);
131 if (s.size() >= 2)
132 s = s.substr(0, s.size()-2);
133 return safe_lower(s);
134}
135
136inline efl::eina::iterator<const Eolian_Class>
137class_list_all()
138{
139 return efl::eina::iterator<const Eolian_Class>(::eolian_all_classes_get());
140}
141
142inline Eolian_Function const&
143constructor_function(Eolian_Constructor const& ctor)
144{
145 assert(!!::eolian_constructor_function_get(&ctor));
146 return * ::eolian_constructor_function_get(&ctor);
147}
148
149inline efl::eina::iterator<const Eolian_Function>
150functions_get(Eolian_Class const& cls)
151{
152 Eina_Iterator *itr = ::eolian_class_functions_get(&cls, EOLIAN_METHOD); // XXX
153 return itr
154 ? efl::eina::iterator<const Eolian_Function>(itr)
155 : efl::eina::iterator<const Eolian_Function>();
156}
157
158inline std::string
159function_name(Eolian_Function const& func)
160{
161 return keyword_avoid(::eolian_function_name_get(&func));
162}
163
164inline std::string
165function_impl(Eolian_Function const& func)
166{
167 const char *s = ::eolian_function_full_c_name_get(&func, EOLIAN_METHOD, EINA_FALSE);
168 std::string ret(s);
169 ::eina_stringshare_del(s);
170 return ret;
171}
172
173inline Eolian_Function_Type
174function_op_type(Eolian_Function const& func)
175{
176 return ::eolian_function_type_get(&func);
177}
178
179inline efl::eolian::eo_function::eo_function_type
180function_type(Eolian_Function const& func)
181{
182 return ::eolian_function_is_class(&func)
183 ? efl::eolian::eo_function::class_
184 : efl::eolian::eo_function::regular_
185 ;
186}
187
188inline bool
189function_is_constructor(Eolian_Class const& cls, Eolian_Function const& func)
190{
191 return ::eolian_function_is_constructor(&func, &cls);
192}
193
194inline bool
195function_is_beta(Eolian_Function const& func)
196{
197 return ::eolian_function_is_beta(&func);
198}
199
200inline efl::eolian::eolian_scope
201function_scope(Eolian_Function const& func)
202{
203 return eolian_scope_cxx(::eolian_function_scope_get(&func));
204}
205
206inline bool
207function_is_visible(Eolian_Function const& func, Eolian_Function_Type func_type)
208{
209 Eolian_Object_Scope s = ::eolian_function_scope_get(&func);
210 return ((s == EOLIAN_SCOPE_PUBLIC || s == EOLIAN_SCOPE_PROTECTED) &&
211 !::eolian_function_is_legacy_only(&func, func_type));
212}
213
214inline bool
215function_is_visible(Eolian_Function const& func, method_t)
216{
217 return function_is_visible(func, method_t::value);
218}
219
220inline bool
221function_is_visible(Eolian_Function const& func)
222{
223 return function_is_visible(func, function_op_type(func));
224}
225
226inline bool
227function_is_visible(Eolian_Constructor const& ctor_)
228{
229 Eolian_Function const* func = ::eolian_constructor_function_get(&ctor_);
230 Eolian_Class const* cls = ::eolian_constructor_class_get(&ctor_);
231 assert(!!func);
232 assert(!!cls);
233 return (::eolian_class_ctor_enable_get(cls) &&
234 function_is_visible(*func, method_t::value));
235}
236
237inline efl::eolian::eolian_type_instance
238function_return_type(Eolian_Function const& func, Eolian_Function_Type func_type = method_t::value)
239{
240 return type_lookup(::eolian_function_return_type_get(&func, func_type));
241}
242
243inline efl::eolian::eolian_type_instance
244function_return_type(Eolian_Function const& func, setter_t func_type)
245{
246 return function_return_type(func, func_type.value);
247}
248
249inline efl::eolian::eolian_type_instance
250function_return_type(Eolian_Function const& func, getter_t func_type)
251{
252 return function_return_type(func, func_type.value);
253}
254
255inline efl::eolian::eolian_type_instance
256function_return_type(Eolian_Function const& func, method_t func_type)
257{
258 return function_return_type(func, func_type.value);
259}
260
261inline bool
262function_return_is_explicit_void(Eolian_Function const& func, getter_t func_type)
263{
264 // XXX This function shouldn't exist. Eolian should
265 // forge functions a priori. Bindings generators
266 // shouldn't be required to convert such thing.
267 Eolian_Type const* type =
268 ::eolian_function_return_type_get(&func, func_type.value);
269 return !!type && type->type == EOLIAN_TYPE_VOID;
270}
271
272inline efl::eina::iterator<const Eolian_Function>
273properties_get(Eolian_Class const& cls)
274{
275 Eina_Iterator *itr = ::eolian_class_functions_get(&cls, EOLIAN_PROPERTY); // XXX
276 return itr
277 ? efl::eina::iterator<const Eolian_Function>(itr)
278 : efl::eina::iterator<const Eolian_Function>();
279}
280
281inline bool
282property_is_getter(Eolian_Function_Type func_type)
283{
284 return func_type == property_t::value || func_type == getter_t::value;
285}
286
287inline bool
288property_is_getter(Eolian_Function const& func)
289{
290 return property_is_getter(function_op_type(func));
291}
292
293inline bool
294property_is_setter(Eolian_Function_Type func_type)
295{
296 return func_type == property_t::value || func_type == setter_t::value;
297}
298
299inline bool
300property_is_setter(Eolian_Function const& func)
301{
302 return property_is_setter(function_op_type(func));
303}
304
305inline std::string
306parameter_name(Eolian_Function_Parameter const& parameter)
307{
308 return safe_str(::eolian_parameter_name_get(&parameter)) + "_";
309}
310
311inline bool
312parameter_is_out(Eolian_Function_Parameter const& parameter)
313{
314 Eolian_Parameter_Dir direction = eolian_parameter_direction_get(&parameter);
315 return direction == EOLIAN_OUT_PARAM || direction == EOLIAN_INOUT_PARAM;
316}
317
318inline efl::eolian::eolian_type_instance
319parameter_type(Eolian_Function_Parameter const& parameter)
320{
321 efl::eolian::eolian_type_instance type
322 (type_lookup(::eolian_parameter_type_get(&parameter)));
323 assert(!type.empty());
324 if (parameter_is_out(parameter))
325 {
326 if (type.front().native.find("char") != std::string::npos)
327 type = { efl::eolian::type_to_native(type) };
328 type.is_out = true;
329 type.front().native += "*";
330 }
331 type.is_optional = ::eolian_parameter_is_optional(&parameter) ||
332 ::eolian_parameter_is_nullable(&parameter);
333 return type;
334}
335
336inline efl::eolian::eo_event
337event_create(const Eolian_Event *event_)
338{
339 efl::eolian::eo_event event;
340 const char *name = ::eolian_event_name_get(event_);
341 if (name)
342 {
343 std::string name_ = safe_str(name);
344 std::transform(name_.begin(), name_.end(), name_.begin(),
345 [](int c) { return c != ',' ? c : '_'; });
346 event.scope = eolian_scope_cxx(::eolian_event_scope_get(event_));
347 event.is_beta = (::eolian_event_is_beta(event_) != EINA_FALSE);
348 event.name = normalize_spaces(name_);
349 event.eo_name = safe_str(::eolian_event_c_name_get(event_));
350 /* FIXME: use doc api */
351 event.comment = safe_str("");
352 }
353 return event;
354}
355
356inline efl::eolian::events_container_type
357event_list(Eolian_Class const& klass)
358{
359 efl::eolian::events_container_type events;
360 Eina_Iterator *itr = ::eolian_class_events_get(&klass);
361 Eolian_Event *e;
362 EINA_ITERATOR_FOREACH(itr, e)
363 {
364 events.push_back(event_create(e));
365 }
366 eina_iterator_free(itr);
367 return events;
368}
369
370inline efl::eina::iterator<const Eolian_Implement>
371implements_get(Eolian_Class const& cls)
372{
373 Eina_Iterator *itr = ::eolian_class_implements_get(&cls);
374 return itr
375 ? efl::eina::iterator<const Eolian_Implement>(itr)
376 : efl::eina::iterator<const Eolian_Implement>();
377}
378
379inline bool
380implement_is_property_get(Eolian_Implement const& impl)
381{
382 return ::eolian_implement_is_prop_get(&impl);
383}
384
385inline bool
386implement_is_property_set(Eolian_Implement const& impl)
387{
388 return ::eolian_implement_is_prop_set(&impl);
389}
390
391inline bool
392implement_is_property(Eolian_Implement const& impl)
393{
394 return implement_is_property_get(impl) ||
395 implement_is_property_set(impl);
396}
397
398inline Eolian_Function const*
399implement_function(Eolian_Implement const& impl)
400{
401 return ::eolian_implement_function_get(&impl, nullptr);
402}
403
404inline Eolian_Class const*
405implement_class(Eolian_Implement const& impl)
406{
407 return ::eolian_implement_class_get(&impl);
408}
409
410// XXX This function shouldn't exist. Eolian should provide some way
411// to determine if a method is a destructor.
412inline bool
413implement_is_destructor(Eolian_Implement const& impl)
414{
415 return !safe_str
416 (::eolian_implement_full_name_get(&impl)).compare("Eo.Base.destructor");
417}
418
419inline bool
420implement_is_visible(Eolian_Implement const& impl)
421{
422 return function_is_visible(*implement_function(impl)) &&
423 !::eolian_implement_is_virtual(&impl) &&
424 !::eolian_implement_is_empty(&impl) &&
425 !implement_is_destructor(impl);
426}
427
428}
429
430#endif // EOLIAN_CXX_EOLIAN_WRAPPERS_HH
diff --git a/src/bin/eolian_cxx/safe_strings.hh b/src/bin/eolian_cxx/safe_strings.hh
deleted file mode 100644
index 4601af6b85..0000000000
--- a/src/bin/eolian_cxx/safe_strings.hh
+++ /dev/null
@@ -1,160 +0,0 @@
1
2#ifndef EOLIAN_CXX_BIN_SAFE_STRINGS_HH
3#define EOLIAN_CXX_BIN_SAFE_STRINGS_HH
4
5#include <string>
6#include <algorithm>
7#include <cstddef>
8#include <cctype>
9#include <iterator>
10
11extern "C"
12{
13#include <Eina.h>
14}
15
16/// @brief Safely convert const char* to std::string.
17///
18inline std::string
19safe_str(const char* str)
20{
21 return (str != NULL) ? str : "";
22}
23
24/// @brief Safely convert Eina_Stringshare to std::string.
25///
26inline std::string
27safe_strshare(Eina_Stringshare* strsh)
28{
29 std::string ret = strsh != NULL ? strsh : "";
30 eina_stringshare_del(strsh);
31 return ret;
32}
33
34/// @brief Get a lower-case copy of string.
35///
36inline std::string
37safe_lower(std::string const& s)
38{
39 std::string res;
40 res.resize(s.size());
41 std::transform(s.begin(), s.end(), res.begin(), ::tolower);
42 return res;
43}
44
45/// @brief Get a lower-case copy of string.
46///
47inline std::string
48safe_lower(const char *s)
49{
50 return safe_lower(safe_str(s));
51}
52
53/// @brief Get a upper-case copy of string.
54///
55inline std::string
56safe_upper(std::string const& s)
57{
58 std::string res;
59 res.resize(s.size());
60 std::transform(s.begin(), s.end(), res.begin(), ::toupper);
61 return res;
62}
63
64/// @brief Get a upper-case copy of string.
65///
66inline std::string
67safe_upper(const char* s)
68{
69 return safe_upper(safe_str(s));
70}
71
72/// @brief Trim both ends of the string and replaces any
73/// subsequence of contiguous spaces with a single space.
74///
75inline std::string
76normalize_spaces(std::string const& s)
77{
78 std::ostringstream os;
79 bool prev_is_space = true;
80 std::remove_copy_if
81 (s.begin(), s.end(),
82 std::ostream_iterator<char>(os),
83 [&prev_is_space] (char c)
84 {
85 bool r = ::isspace(c);
86 if (r && prev_is_space)
87 return true;
88 prev_is_space = r;
89 return false;
90 });
91 std::string r = os.str();
92 if (!r.empty() && ::isspace(r.back()))
93 r.erase(r.end()-1, r.end());
94 return r;
95}
96
97/// @brief Return the basename of a path.
98///
99inline std::string
100path_base(std::string path)
101{
102 std::string::reverse_iterator
103 slash = std::find(path.rbegin(), path.rend(), '/');
104 return std::string(slash.base(), path.end());
105}
106
107/// @brief Find-and-replace patterns in a string.
108///
109inline std::string
110find_replace(std::string const& s_,
111 std::string const& old,
112 std::string const& new_)
113{
114 std::string s = s_;
115 std::string::size_type found = s.find(old);
116 std::string::size_type len = new_.length();
117 while (found != std::string::npos)
118 {
119 s.replace(found, len, new_);
120 found = s.find(old);
121 }
122 return s;
123}
124
125/// @brief Append '_' if @p key is a C++ keyword.
126///
127inline std::string
128keyword_avoid(std::string const& name)
129{
130 if (name == "delete" ||
131 name == "throw" ||
132 name == "break" ||
133 name == "friend" ||
134 name == "goto" ||
135 name == "default" ||
136 name == "new" ||
137 name == "auto" ||
138 name == "do" ||
139 name == "sizeof" ||
140 name == "try" ||
141 name == "this" ||
142 name == "virtual" ||
143 name == "register" ||
144 name == "typename" ||
145 name == "template")
146 {
147 return name + "_"; // XXX Warn?
148 }
149 return name;
150}
151
152/// @brief Append '_' if @p key is a C++ keyword.
153///
154inline std::string
155keyword_avoid(const char* name)
156{
157 return keyword_avoid(safe_str(name));
158}
159
160#endif // EOLIAN_CXX_BIN_SAFE_STRINGS_HH
diff --git a/src/bin/eolian_cxx/type_lookup.hh b/src/bin/eolian_cxx/type_lookup.hh
deleted file mode 100644
index 9410bdf358..0000000000
--- a/src/bin/eolian_cxx/type_lookup.hh
+++ /dev/null
@@ -1,160 +0,0 @@
1
2#ifndef EOLIAN_CXX_TYPE_LOOKUP_HH
3#define EOLIAN_CXX_TYPE_LOOKUP_HH
4
5#include <algorithm>
6#include <string>
7#include <vector>
8#include <cctype>
9#include <iterator>
10#include <stdexcept>
11#include <cassert>
12#include <cstddef>
13
14#include <Eolian.h>
15#include <eolian_database.h>
16
17#include <Eina.hh>
18
19#include "eo_types.hh"
20#include "safe_strings.hh"
21
22namespace eolian_cxx {
23
24typedef std::vector<efl::eolian::eolian_type> lookup_table_type;
25extern const lookup_table_type type_lookup_table;
26
27inline std::string
28class_format_cxx(std::string const& fullname)
29{
30 auto current = fullname.begin(), last = fullname.end();
31 auto found = std::find(current, last, '.');
32 std::string new_string;
33 if(found == last)
34 new_string = "nonamespace::" + fullname;
35 else
36 while (current != last)
37 {
38 if(found == last)
39 {
40 new_string.insert(new_string.end(), current, found);
41 current = found;
42 }
43 else
44 {
45 new_string += std::tolower(*current);
46 new_string.insert(new_string.end(), std::next(current), found);
47 new_string = safe_lower(new_string);
48 new_string += "::";
49 current = std::next(found);
50 found = std::find(current, last, '.');
51 }
52 }
53 return new_string;
54}
55
56inline bool
57type_is_complex(Eolian_Type const& type)
58{
59 return ::eolian_type_type_get(&type) == EOLIAN_TYPE_COMPLEX;
60}
61
62inline efl::eolian::eolian_type
63type_from_eolian(Eolian_Type const& type)
64{
65 efl::eolian::eolian_type x;
66
67 Eolian_Type_Type tpt = ::eolian_type_type_get(&type);
68 if (tpt == EOLIAN_TYPE_CLASS)
69 {
70 Eolian_Class const* klass = ::eolian_type_class_get(&type);
71 if (klass)
72 {
73 x.category = efl::eolian::eolian_type::simple_;
74 x.is_class = true;
75 x.binding_requires_optional = false;
76 x.binding = "::" + class_format_cxx(safe_str(::eolian_class_full_name_get(klass)));
77 x.native = "::";
78 x.native += safe_str( ::eolian_class_full_name_get(klass));
79 std::replace(x.native.begin(), x.native.end(), '.', '_');
80
81 if( ::eolian_type_is_const(&type))
82 x.native += " const";
83
84 x.native += '*';
85
86 Eina_Stringshare* klass_file = ::eolian_class_file_get(klass);
87 if (klass_file)
88 x.includes = {safe_str(klass_file) + ".hh"};
89 }
90 }
91
92 if(x.native.empty())
93 x.native = normalize_spaces(safe_str(::eolian_type_c_type_get(&type)));
94 x.is_own = ::eolian_type_is_own(&type);
95 x.is_const = ::eolian_type_is_const(&type);
96 return x;
97}
98
99template <typename Iterator>
100inline const efl::eolian::eolian_type&
101type_find(Iterator first, Iterator last, efl::eolian::eolian_type const& type)
102{
103 auto res = std::find_if
104 (first, last,
105 [&type] (efl::eolian::eolian_type const& x)
106 {
107 return (x.native == type.native && x.is_own == type.is_own);
108 });
109 return (res != last) ? *res : type;
110}
111
112inline efl::eolian::eolian_type_instance
113type_lookup(const Eolian_Type* type,
114 lookup_table_type const& lut = type_lookup_table)
115{
116 if (type == NULL) return { efl::eolian::void_type }; // XXX shouldn't
117 // assert(type != NULL);
118
119 std::vector<Eolian_Type const*> types;
120 types.push_back(type);
121
122 if (type_is_complex(*type))
123 {
124 efl::eina::iterator<Eolian_Type const> end;
125 efl::eina::iterator<Eolian_Type const> it
126 (::eolian_type_subtypes_get(type));
127 while(it != end)
128 {
129 if(Eolian_Type const* t = &*it)
130 {
131 types.push_back
132 /* remove this base type get when pointers are removed */
133 ( ::eolian_type_type_get(t) == EOLIAN_TYPE_POINTER ? ::eolian_type_base_type_get(t)
134 : t
135 );
136 ++it;
137 }
138 }
139 }
140
141 efl::eolian::eolian_type_instance v(types.size());
142 for (std::size_t i = 0; i != types.size(); ++i)
143 {
144 v.parts[i] = type_find(lut.begin(), lut.end(), type_from_eolian(*types[i]));
145 }
146
147 // Let's degrade to opaque classes when not enough information
148 // is available for complex types
149 if(v.parts.size() == 1 && type_is_complex(v.front()))
150 {
151 efl::eolian::eolian_type tmp = v.front();
152 return {efl::eolian::type_to_native(tmp)};
153 }
154
155 return v;
156}
157
158} // namespace eolian_cxx {
159
160#endif // EOLIAN_CXX_TYPE_LOOKUP_HH
diff --git a/src/bin/eolian_cxx/type_lookup_table.cc b/src/bin/eolian_cxx/type_lookup_table.cc
deleted file mode 100644
index 046b8b8744..0000000000
--- a/src/bin/eolian_cxx/type_lookup_table.cc
+++ /dev/null
@@ -1,36 +0,0 @@
1#include "type_lookup.hh"
2
3namespace eolian_cxx {
4
5using efl::eolian::eolian_type;
6
7const lookup_table_type
8type_lookup_table
9{
10 {"Ecore_Cb", eolian_type::callback_, {"Ecore.h"}},
11 {"Ecore_Task_Cb", eolian_type::callback_, {"Ecore.h"}},
12 {"Ecore_Timeline_Cb", eolian_type::callback_, {"Ecore.h"}},
13 {"Edje_Signal_Cb", eolian_type::callback_, {"Edje.h"}},
14 {"Eina_Accessor *", eolian_type::complex_, false, false, true, false, "::efl::eina::accessor", {"eina_accessor.hh"}},
15 {"Eina_Bool", eolian_type::simple_, false, false, false, false, "bool", {}},
16 {"Eina_Bool *", eolian_type::simple_, false, false, false, false, "bool*", {}},
17 {"Eina_Inlist *", eolian_type::complex_, false, false, true, true, "::efl::eina::range_inlist", {"eina_inlist.hh"}},
18 {"Eina_Inlist *", eolian_type::complex_, false, true, true, true, "::efl::eina::inlist", {"eina_inlist.hh"}},
19 {"Eina_Iterator *", eolian_type::complex_, false, false, true, true, "::efl::eina::iterator", {"eina_iterator.hh"}},
20 {"Eina_List *", eolian_type::complex_, false, false, true, true, "::efl::eina::range_list", {"eina_list.hh"}},
21 {"Eina_List *", eolian_type::complex_, false, true, true, true, "::efl::eina::list", {"eina_list.hh"}},
22 {"const Eina_List *", eolian_type::complex_, true, false, true, true, "::efl::eina::crange_list", {"eina_list.hh"}},
23 {"Eina_Array *", eolian_type::complex_, false, false, true, true, "::efl::eina::range_array", {"eina_array.hh"}},
24 {"Eina_Array *", eolian_type::complex_, false, true, true, true, "::efl::eina::array", {"eina_array.hh"}},
25 {"const Eina_Array *", eolian_type::complex_, true, false, true, true, "::efl::eina::crange_array", {"eina_array.hh"}},
26 {"Eio_Filter_Direct_Cb", eolian_type::callback_, {"Eio.h"}},
27 {"Eo *", eolian_type::simple_, false, true, true, false, "::efl::eo::concrete", {"eo_concrete.hh"}},
28 {"Eo *", eolian_type::simple_, false, false, true, false, "::efl::eo::concrete", {"eo_concrete.hh"}},
29 //{"Evas_Object_Box_Layout", eolian_type::callback_, {"Evas.h"}},
30 //{"char *", eolian_type::simple_, false, true, true, false, "std::unique_ptr<char*>", {"memory"}},
31 {"const Eina_Inlist *", eolian_type::complex_, false, false, true, true, "::efl::eina::range_inlist", {"eina_inlist.hh"}},
32 {"const Eina_List *", eolian_type::complex_, false, false, true, true, "::efl::eina::range_list", {"eina_ptrlist.hh"}},
33 {"const char *", eolian_type::simple_, false, false, true, true, "::efl::eina::string_view", {"string"}},
34};
35
36}
diff --git a/src/bindings/cxx/eo_cxx/Eo.hh b/src/bindings/cxx/eo_cxx/Eo.hh
index a6f0423724..b7d1e856a3 100644
--- a/src/bindings/cxx/eo_cxx/Eo.hh
+++ b/src/bindings/cxx/eo_cxx/Eo.hh
@@ -4,6 +4,9 @@
4#include <eo_concrete.hh> 4#include <eo_concrete.hh>
5#include <eo_init.hh> 5#include <eo_init.hh>
6#include <eo_wref.hh> 6#include <eo_wref.hh>
7#include <eo_inherit.hh> 7// #include <eo_inherit.hh>
8//#include <eo_own_ptr.hh>
9#include <eo_cxx_interop.hh>
10#include <eo_event.hh>
8 11
9#endif // EFL_CXX_EO_HH 12#endif // EFL_CXX_EO_HH
diff --git a/src/bindings/cxx/eo_cxx/eo_concrete.hh b/src/bindings/cxx/eo_cxx/eo_concrete.hh
index c975bbc5e3..11d2c5b5da 100644
--- a/src/bindings/cxx/eo_cxx/eo_concrete.hh
+++ b/src/bindings/cxx/eo_cxx/eo_concrete.hh
@@ -11,7 +11,6 @@
11#include <eina_optional.hh> 11#include <eina_optional.hh>
12 12
13#include "eo_ops.hh" 13#include "eo_ops.hh"
14#include "eo_event.hh"
15 14
16#ifndef EFL_CXX_THROW 15#ifndef EFL_CXX_THROW
17#if defined ( EFL_CXX_NO_EXCEPTIONS ) 16#if defined ( EFL_CXX_NO_EXCEPTIONS )
@@ -22,9 +21,9 @@
22#endif 21#endif
23 22
24#if !defined(EFL_DOXYGEN) && !defined(EO_CXX_INHERIT) 23#if !defined(EFL_DOXYGEN) && !defined(EO_CXX_INHERIT)
25# define EO_CXX_INHERIT(name) ::eo_cxx::name 24# define EO_CXX_INHERIT(name) ::eo_cxx name
26#elif !defined(EO_CXX_INHERIT) 25#elif !defined(EO_CXX_INHERIT)
27# define EO_CXX_INHERIT(name) ::name 26# define EO_CXX_INHERIT(name) name
28#endif 27#endif
29 28
30namespace efl { namespace eo { 29namespace efl { namespace eo {
@@ -137,53 +136,11 @@ struct concrete
137 _eo_raw = _ptr; 136 _eo_raw = _ptr;
138 } 137 }
139 138
140 /// @brief Get the reference count of this object.
141 ///
142 /// @return The referencer count of this object.
143 ///
144 int ref_get() const { return detail::ref_get(_eo_raw); }
145
146 /// @brief Set the parent of this object.
147 ///
148 /// @param parent The new parent.
149 ///
150 void parent_set(concrete parent)
151 {
152 detail::parent_set(_eo_raw, parent._eo_ptr());
153 }
154
155 /// @brief Get the parent of this object.
156 ///
157 /// @return An @ref efl::eo::concrete instance that binds the parent
158 /// object. Returns NULL if there is no parent.
159 ///
160 eina::optional<concrete> parent_get()
161 {
162 Eo *r = detail::parent_get(_eo_raw);
163 if(!r) return nullptr;
164 else
165 {
166 detail::ref(r); // XXX eo_parent_get does not call eo_ref so we may.
167 return concrete(r);
168 }
169 }
170
171 /// @brief Get debug information of this object.
172 ///
173 /// @return The root node of the debug information tree.
174 ///
175 Eo_Dbg_Info dbg_info_get()
176 {
177 Eo_Dbg_Info info;
178 detail::dbg_info_get(_eo_raw, &info);
179 return info;
180 }
181
182 explicit operator bool() const 139 explicit operator bool() const
183 { 140 {
184 return _eo_raw; 141 return _eo_raw;
185 } 142 }
186 protected: 143protected:
187 Eo* _eo_raw; ///< The opaque <em>EO Object</em>. 144 Eo* _eo_raw; ///< The opaque <em>EO Object</em>.
188}; 145};
189 146
@@ -223,20 +180,6 @@ struct extension_inheritance<concrete>
223 }; 180 };
224}; 181};
225 182
226struct concrete_address_of
227{
228 explicit concrete_address_of(void* p) : p(p) {}
229 operator void*() { return p; }
230 void* p;
231};
232
233struct concrete_address_const_of
234{
235 explicit concrete_address_const_of(void const* p) : p(p) {}
236 operator void const*() { return p; }
237 void const* p;
238};
239
240} 183}
241 184
242/// @brief Downcast @p U to @p T. 185/// @brief Downcast @p U to @p T.
@@ -264,42 +207,17 @@ T downcast(U object)
264 } 207 }
265} 208}
266 209
267/// 210template <typename T>
268/// @brief Type used to hold the parent passed to concrete Eo C++ 211struct is_eolian_object : std::false_type {};
269/// constructors. 212template <typename T>
270/// 213struct is_eolian_object<T const> : is_eolian_object<T> {};
271struct parent_type 214template <typename T>
272{ 215struct is_eolian_object<T const&> : is_eolian_object<T> {};
273 Eo* _eo_raw; 216template <typename T>
274}; 217struct is_eolian_object<T&> : is_eolian_object<T> {};
275 218template <>
276/// 219struct is_eolian_object<eo::concrete> : std::true_type {};
277/// @brief The expression type declaring the assignment operator used 220
278/// in the parent argument of the concrete Eo C++ class.
279///
280struct parent_expr
281{
282 parent_type operator=(efl::eo::concrete const& parent) const
283 {
284 return { parent._eo_ptr() };
285 }
286
287 template <typename T>
288 parent_type operator=(T const& parent) const
289 {
290 return { parent._eo_ptr() };
291 }
292 parent_type operator=(std::nullptr_t) const
293 {
294 return { nullptr };
295 }
296};
297
298///
299/// @brief Placeholder for the parent argument.
300///
301parent_expr const parent = {};
302
303/// @} 221/// @}
304 222
305} } // namespace efl { namespace eo { 223} } // namespace efl { namespace eo {
diff --git a/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh b/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh
index a588b5b8e1..a19bb24226 100644
--- a/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh
+++ b/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh
@@ -7,6 +7,7 @@
7#include <utility> 7#include <utility>
8#include <type_traits> 8#include <type_traits>
9#include <initializer_list> 9#include <initializer_list>
10#include <future>
10 11
11#include <Eina.hh> 12#include <Eina.hh>
12#include <Eo.hh> 13#include <Eo.hh>
@@ -15,519 +16,537 @@
15 16
16namespace efl { namespace eolian { 17namespace efl { namespace eolian {
17 18
18//// From C++ to C 19template <typename T, typename Enable = void>
20struct in_traits { typedef T const& type; };
21template <typename T>
22struct in_traits<T, typename std::enable_if<eo::is_eolian_object<T>::value>::type> { typedef T type; };
23template <typename T>
24struct in_traits<T, typename std::enable_if<std::is_fundamental<T>::value>::type> { typedef T type; };
25template <>
26struct in_traits<eina::string_view> { typedef eina::string_view type; };
27template <>
28struct in_traits<eina::string_view const> { typedef eina::string_view const type; };
29template <typename T>
30struct in_traits<T&> { typedef T& type; };
31template <typename T>
32struct in_traits<T*> { typedef T* type; };
33template <typename T, typename D>
34struct in_traits<std::unique_ptr<T, D>> { typedef std::unique_ptr<T, D> type; };
19 35
20inline const char* 36template <typename T>
21to_c(std::string const& x) 37struct in_traits<eina::range_list<T>> { typedef eina::range_list<T> type; };
38template <typename T>
39struct in_traits<eina::range_array<T>> { typedef eina::range_array<T> type; };
40
41template <typename T>
42struct out_traits { typedef T type; };
43template <typename T>
44struct out_traits<efl::eina::future<T>> { typedef efl::eina::future<T>& type; };
45
46template <typename T>
47struct inout_traits { typedef T type; };
48template <typename T>
49struct inout_traits<efl::eina::future<T>> { typedef efl::eina::future<T>& type; };
50
51namespace impl {
52
53template <typename From, typename To>
54struct tag
22{ 55{
23 return x.c_str(); 56 typedef To to;
57 typedef From from;
58};
59
60template <typename To, typename From, typename Lhs, typename Rhs>
61void assign_out(Lhs& lhs, Rhs& rhs);
62
63template <typename T>
64void assign_out_impl(T*& lhs, T& rhs, tag<T*, T>)
65{
66 *lhs = rhs;
24} 67}
25 68template <typename U, typename T>
26inline const char* 69void assign_out_impl(std::unique_ptr<T, void(*)(const void*)>& lhs, U* rhs, tag<std::unique_ptr<T, void(*)(const void*)>&, U*>)
27to_c(eina::optional<std::string> const& x)
28{ 70{
29 if (!x) 71 lhs.reset(rhs);
30 return nullptr;
31 return x->c_str();
32} 72}
33 73template <typename Tag>
34inline const char* 74void assign_out_impl(bool& lhs, Eina_Bool rhs, Tag)
35to_c(eina::string_view const& x)
36{ 75{
37 return x.data(); 76 lhs = rhs;
38} 77}
39 78template <typename T>
40inline const char* 79void assign_out_impl(T& lhs, T& rhs, tag<T&, T>)
41to_c(eina::optional<eina::string_view> const& x)
42{ 80{
43 if (!x) 81 lhs = rhs;
44 return nullptr;
45 return x->data();
46} 82}
47 83template <typename T>
48inline const char* 84void assign_out_impl(T& lhs, Eo* rhs, tag<T&, Eo*>
49to_c(efl::eina::stringshare const& x) 85 , typename std::enable_if<eo::is_eolian_object<T>::value>::type* = 0)
50{ 86{
51 return x.c_str(); 87 lhs._reset(rhs);
52} 88}
53 89template <typename T>
54inline const char* 90void assign_out_impl(T& lhs, Eo const* rhs, tag<T&, Eo const*>
55to_c(eina::optional<efl::eina::stringshare> const& x) 91 , typename std::enable_if<eo::is_eolian_object<T>::value>::type* = 0)
56{ 92{
57 if (!x) 93 lhs._reset(const_cast<Eo*>(rhs));
58 return nullptr;
59 return x->c_str();
60} 94}
61 95template <typename T>
62inline Eina_Bool 96void assign_out_impl(efl::eina::future<T>& /*v*/, Eina_Promise*, tag<efl::eina::future<T>&, Eina_Promise*>)
63to_c(bool x)
64{ 97{
65 return x ? EINA_TRUE : EINA_FALSE;
66} 98}
67 99template <typename Tag>
68inline Eina_Bool* 100void assign_out_impl(efl::eina::string_view& view, const char* string, Tag)
69to_c(bool* x)
70{ 101{
71 static_assert(sizeof(bool) == sizeof(Eina_Bool), ""); 102 view = {string};
72 return reinterpret_cast<Eina_Bool*>(x);
73} 103}
74 104template <typename T, typename Rhs, typename U, typename O>
75template <typename T> 105void assign_out_impl(efl::eina::optional<T>& lhs, Rhs*& rhs, tag<efl::eina::optional<U>&, O>)
76T to_c(T const& v, typename std::enable_if<!std::is_convertible<T*, ::efl::eo::concrete*>::value>::type* = 0)
77{ 106{
78 return v; 107 if(rhs)
108 assign_out<U, O>(*lhs, rhs);
109 else
110 lhs.disengage();
79} 111}
80 112template <typename T, typename Rhs, typename U, typename O>
81template <typename T> 113void assign_out_impl(efl::eina::optional<T>& lhs, Rhs& rhs, tag<efl::eina::optional<U>&, O>)
82Eo* to_c(T const& v, typename std::enable_if<std::is_convertible<T*, ::efl::eo::concrete*>::value>::type* = 0)
83{ 114{
84 return v._eo_ptr(); 115 assign_out<U, O>(*lhs, rhs);
85} 116}
86 117template <typename T, typename Rhs, typename U, typename O>
87template <typename T> 118void assign_out_impl(efl::eina::optional<T>& lhs, Rhs*& rhs, tag<efl::eina::optional<U>, O>)
88Eo* to_c(eina::optional<T> const& v, typename std::enable_if<std::is_convertible<T*, ::efl::eo::concrete*>::value>::type* = 0)
89{ 119{
90 if (!v) 120 if(rhs)
91 return nullptr; 121 assign_out<U, O>(*lhs, rhs);
92 return v->_eo_ptr(); 122 else
123 lhs.disengage();
93} 124}
94 125template <typename T, typename Rhs, typename U, typename O>
95template <typename T> 126void assign_out_impl(efl::eina::optional<T>& lhs, Rhs& rhs, tag<efl::eina::optional<U>, O>)
96Eo** to_c(T* v, typename std::enable_if<std::is_convertible<T*, ::efl::eo::concrete*>::value>::type* = 0)
97{ 127{
98 static_assert(sizeof(T) == sizeof(Eo*), ""); 128 assign_out<U, O>(*lhs, rhs);
99 return static_cast<Eo**>(static_cast<void*>(v));
100} 129}
101 130template <typename Tag>
102template <typename R, typename T> 131void assign_out_impl(eina::value& lhs, Eina_Value const& rhs, Tag)
103R to_native(T& v)
104{ 132{
105 static_assert(sizeof(T) == sizeof(R), ""); 133 Eina_Value* v = eina_value_new(EINA_VALUE_TYPE_CHAR);
106 return v.native_handle(); 134 eina_value_flush(v);
135 eina_value_copy(&rhs, v);
136 lhs = {v};
107} 137}
108 138template <typename T, typename Tag>
109template <typename R, typename T> 139void assign_out_impl(efl::eina::list<T>& lhs, Eina_List* rhs, Tag)
110R to_native(eina::optional<T>& v)
111{ 140{
112 static_assert(sizeof(T) == sizeof(R), ""); 141 lhs = efl::eina::list<T>{rhs};
113 if (!v)
114 return nullptr;
115 return v->native_handle();
116} 142}
117 143}
118template <typename R, typename T> 144
119R to_native(T* v) 145template <typename To, typename From, typename Lhs, typename Rhs>
146void assign_out(Lhs& lhs, Rhs& rhs)
120{ 147{
121 static_assert(sizeof(T) == sizeof(typename std::remove_pointer<R>::type), ""); 148 return impl::assign_out_impl(lhs, rhs, impl::tag<To, From>{});
122 return static_cast<R>(static_cast<void*>(v));
123} 149}
124
125 150
126//// From C to C++ 151namespace impl {
127 152
128template <typename T> 153template <typename T>
129struct tag {}; 154T* convert_inout_impl(T& v, tag<T, T*>)
130
131template <typename T, typename U, typename O>
132T to_cxx(U object, O o);
133
134// XXX
135inline void*
136to_cxx(void *x, std::tuple<std::false_type>, tag<void*>)
137{ 155{
138 return x; 156 return v;
139} 157}
140 158template <typename T>
141// XXX 159T& convert_inout_impl(T& v, tag<T, T>)
142inline const void*
143to_cxx(const void *x, std::tuple<std::false_type>, tag<const void*>)
144{ 160{
145 return x; 161 return v;
146} 162}
147
148template <typename T> 163template <typename T>
149inline T 164Eo* convert_inout_impl(T& v, tag<T, Eo*>
150to_cxx(Eo* x, std::tuple<std::true_type>, tag<T>) 165 , typename std::enable_if<eo::is_eolian_object<T>::value>::type* = 0)
151{ 166{
152 return T(x); 167 return v._eo_ptr();
153} 168}
154
155template <typename T> 169template <typename T>
156inline T 170Eo const* convert_inout_impl(T v, tag<T, Eo const*>
157to_cxx(Eo* x, std::tuple<std::false_type>, tag<T>) 171 , typename std::enable_if<eo::is_eolian_object<T>::value>::type* = 0)
158{ 172{
159 return T(::eo_ref(x)); 173 return v._eo_ptr();
160} 174}
161
162template <typename T> 175template <typename T>
163inline eina::optional<T> 176Eina_Promise* convert_inout_impl(efl::eina::future<T>& /*v*/, tag<efl::eina::future<T>, Eina_Promise*>)
164to_cxx(Eo* x, std::tuple<std::true_type>, tag<eina::optional<T> >) 177{
178 return nullptr;
179}
180}
181
182template <typename To, typename From, typename V>
183auto convert_inout(V& object) -> decltype(impl::convert_inout_impl(object, impl::tag<From, To>{}))
165{ 184{
166 if (!x) 185 return impl::convert_inout_impl(object, impl::tag<From, To>{});
167 return nullptr;
168 return T(x);
169} 186}
187
188template <typename T, typename U, typename V>
189T convert_to_c(V&& object);
190
191namespace impl {
170 192
171template <typename T> 193template <typename U, typename T>
172inline eina::optional<T> 194auto convert_to_c_impl
173to_cxx(Eo* x, std::tuple<std::false_type>, tag<eina::optional<T> >) 195(T&& v, tag<U, U>, typename std::enable_if<std::is_same<typename std::remove_reference<T>::type, U>::value>::type* =0) -> decltype(std::forward<T>(v))
174{ 196{
175 if (!x) 197 return std::forward<T>(v);
176 return nullptr;
177 return T(::eo_ref(x));
178} 198}
179 199
180template <typename T> 200template <typename T>
181inline T 201T const& convert_to_c_impl(T const& v, tag<T, T const&>)
182to_cxx(Eo** x, std::tuple<std::false_type>, tag<T>)
183{ 202{
184 static_assert(sizeof(Eo*) == sizeof(typename std::remove_pointer<T>::type), ""); 203 return v;
185 return static_cast<T>((static_cast<void*>(x)));
186} 204}
187
188#ifdef _EVAS_H
189template <typename T> 205template <typename T>
190Evas_Object_Textblock_Node_Format * 206Eo* convert_to_c_impl(T v, tag<Eo*, T>
191to_cxx(Evas_Object_Textblock_Node_Format* x, std::tuple<std::false_type>, tag<T>) 207 , typename std::enable_if<eo::is_eolian_object<T>::value>::type* = 0)
192{ 208{
193 return x; // XXX 209 return v._eo_ptr();
194} 210}
195#endif 211template <typename T>
196 212Eo const* convert_to_c_impl(T v, tag<Eo const*, T>
197inline bool 213 , typename std::enable_if<eo::is_eolian_object<T>::value>::type* = 0)
198to_cxx(Eina_Bool x, std::tuple<std::false_type>, tag<bool>)
199{ 214{
200 return !!x; 215 return v._eo_ptr();
201} 216}
202 217inline const char* convert_to_c_impl( ::efl::eina::string_view v, tag<const char*, ::efl::eina::string_view>)
203inline std::string
204to_cxx(const char* x, std::tuple<std::false_type>, tag<std::string>)
205{ 218{
206 return std::string(x); 219 return v.c_str();
207} 220}
208 221inline const char** convert_to_c_impl(efl::eina::string_view* /*view*/, tag<const char **, efl::eina::string_view*>)
209inline eina::optional<std::string>
210to_cxx(const char* x, std::tuple<std::false_type>, tag<eina::optional<std::string> >)
211{ 222{
212 if (!x) 223 std::abort();
213 return nullptr;
214 return std::string(x);
215} 224}
216 225inline const char* convert_to_c_impl( std::string const& v, tag<const char*, std::string const&>)
217inline eina::string_view
218to_cxx(const char* x, std::tuple<std::false_type>, tag<eina::string_view>)
219{ 226{
220 return eina::string_view(x); 227 std::size_t len = v.size()+1;
228 char* buffer = static_cast<char*>(malloc(len));
229 std::memcpy(buffer, v.data(), len);
230 return buffer;
221} 231}
222 232inline const char** convert_to_c_impl(std::string* /*view*/, tag<const char **, std::string*>)
223inline eina::optional<eina::string_view>
224to_cxx(const char* x, std::tuple<std::false_type>, tag<eina::optional<eina::string_view> >)
225{ 233{
226 if (!x) 234 std::abort();
227 return nullptr;
228 return eina::string_view(x);
229} 235}
230 236inline Eina_Value* convert_to_c_impl( ::efl::eina::value v, tag<Eina_Value*, in_traits<eina::value>::type>)
231template <typename T, typename Enable = void>
232struct traits
233{ 237{
234 typedef T type; 238 Eina_Value* nv = eina_value_new(v.type_info());
235}; 239 eina_value_copy(v.native_handle(), nv);
236 240 return nv;
241}
242inline Eina_Value const* convert_to_c_impl( ::efl::eina::value v, tag<Eina_Value const*, in_traits<eina::value>::type>)
243{
244 Eina_Value* nv = eina_value_new(v.type_info());
245 eina_value_copy(v.native_handle(), nv);
246 return nv;
247}
248inline Eina_Bool convert_to_c_impl( bool b, tag<Eina_Bool, bool>)
249{
250 return b;
251}
237template <typename T> 252template <typename T>
238struct traits 253T convert_to_c_impl(efl::eina::optional<T> const& optional, tag<T, efl::eina::optional<T>const&>)
239 <T, typename std::enable_if<std::is_base_of<::efl::eo::concrete, T>::value>::type>
240{ 254{
241 typedef Eo* type; 255 return optional ? *optional : T{};
242}; 256}
243 257template <typename U, typename T>
258U convert_to_c_impl(efl::eina::optional<T> const& optional, tag<U, efl::eina::optional<T>const&>)
259{
260 return impl::convert_to_c_impl(optional ? *optional : T{}, tag<U, typename in_traits<T>::type>{});
261}
244template <typename T> 262template <typename T>
245struct traits 263Eina_List* convert_to_c_impl(efl::eina::range_list<T> range, tag<Eina_List *, efl::eina::range_list<T>>)
246 <T, typename std::enable_if<std::is_base_of<std::basic_string<char>, T>::value>::type>
247{ 264{
248 typedef const char* type; 265 return range.native_handle();
249}; 266}
250
251template <typename T> 267template <typename T>
252struct traits 268Eina_List const* convert_to_c_impl(efl::eina::range_list<T> range, tag<Eina_List const *, efl::eina::range_list<T>>)
253 <T, typename std::enable_if<std::is_base_of<::efl::eina::basic_string_view<char>, T>::value>::type>
254{ 269{
255 typedef const char* type; 270 return range.native_handle();
256}; 271}
257 272template <typename T>
258template <typename T, typename ...Args> 273Eina_List* convert_to_c_impl(efl::eina::list<T>const& c, tag<Eina_List *, efl::eina::list<T>const&>)
259inline efl::eina::range_list<T const>
260to_cxx(const Eina_List* x, std::tuple<std::false_type, Args...>, tag< efl::eina::range_list<T> >)
261{ 274{
262 return efl::eina::range_list<T const> {x}; 275 return const_cast<Eina_List*>(c.native_handle());
263} 276}
264 277template <typename T>
265template <typename T, typename ...Args> 278Eina_List const* convert_to_c_impl(efl::eina::list<T>const& c, tag<Eina_List const *, efl::eina::list<T>const&>)
266inline eina::optional<efl::eina::range_list<T const> >
267to_cxx(const Eina_List* x, std::tuple<std::false_type, Args...>, tag< eina::optional<efl::eina::range_list<T> > >)
268{ 279{
269 if (!x) 280 return c.native_handle();
270 return nullptr;
271 return efl::eina::range_list<T const> {x};
272} 281}
273 282template <typename T>
274template <typename T, typename ...Args> 283Eina_Array* convert_to_c_impl(efl::eina::range_array<T> range, tag<Eina_Array *, efl::eina::range_array<T>>)
275inline efl::eina::range_list<T>
276to_cxx(Eina_List* x, std::tuple<std::false_type, Args...>, tag< efl::eina::range_list<T> >)
277{ 284{
278 return efl::eina::range_list<T>{x}; 285 return range.native_handle();
279} 286}
280 287template <typename T>
281template <typename T, typename ...Args> 288Eina_Array const* convert_to_c_impl(efl::eina::range_array<T> range, tag<Eina_Array const *, efl::eina::range_array<T>>)
282inline eina::optional<efl::eina::range_list<T> >
283to_cxx(Eina_List* x, std::tuple<std::false_type, Args...>, tag< eina::optional<efl::eina::range_list<T> > >)
284{ 289{
285 if (!x) 290 return range.native_handle();
286 return nullptr;
287 return efl::eina::range_list<T>{x};
288} 291}
289 292template <typename T>
290template <typename T, typename ...Args> 293Eina_Array* convert_to_c_impl(efl::eina::array<T>const& c, tag<Eina_Array *, efl::eina::array<T>const&>)
291inline efl::eina::list<T>
292to_cxx(Eina_List* x, std::tuple<std::true_type, Args...>, tag< efl::eina::list<T> >)
293{ 294{
294 return efl::eina::list<T> {x}; 295 return c.native_handle();
295} 296}
296 297template <typename T>
297template <typename T, typename ...Args> 298Eina_Array const* convert_to_c_impl(efl::eina::array<T>const& c, tag<Eina_Array const *, efl::eina::array<T>const&>)
298inline eina::optional<efl::eina::list<T> >
299to_cxx(Eina_List* x, std::tuple<std::true_type, Args...>, tag< eina::optional<efl::eina::list<T> > >)
300{ 299{
301 if (!x) 300 return c.native_handle();
302 return nullptr;
303 return efl::eina::list<T> {x};
304} 301}
305 302inline const char** convert_to_c_impl(efl::eina::string_view /*view*/, tag<char const **, efl::eina::string_view>)
306template <typename T, typename ...Args>
307inline efl::eina::range_array<T const>
308to_cxx(const Eina_Array* x, std::tuple<std::false_type, Args...>, tag< efl::eina::range_array<T> >)
309{ 303{
310 return efl::eina::range_array<T const> {x}; 304 std::abort();
311} 305}
312 306// inline const char* convert_to_c_impl(std::string const& x, tag<const char*, std::string>)
313template <typename T, typename ...Args> 307// {
314inline eina::optional<efl::eina::range_array<T const> > 308// return x.c_str();
315to_cxx(const Eina_Array* x, std::tuple<std::false_type, Args...>, tag< eina::optional<efl::eina::range_array<T> > >) 309// }
310inline const char* convert_to_c_impl(efl::eina::stringshare x, tag<const char*, efl::eina::stringshare>)
316{ 311{
317 if (!x) 312 return x.c_str();
318 return nullptr;
319 return efl::eina::range_array<T const> {x};
320} 313}
321 314template <typename T>
322template <typename T, typename ...Args> 315Eina_Promise* convert_to_c_impl(efl::eina::future<T> const&, tag<Eina_Promise*, efl::eina::future<T>const&>)
323inline efl::eina::range_array<T>
324to_cxx(Eina_Array* x, std::tuple<std::false_type, Args...>, tag< efl::eina::range_array<T> >)
325{ 316{
326 return efl::eina::range_array<T>{x}; 317 std::abort();
327} 318}
328 319template <typename T, typename U, typename Deleter>
329template <typename T, typename ...Args> 320T* convert_to_c_impl(std::unique_ptr<U, Deleter>& v, tag<T*, std::unique_ptr<U, Deleter>>)
330inline eina::optional<efl::eina::range_array<T> >
331to_cxx(Eina_Array* x, std::tuple<std::false_type, Args...>, tag< eina::optional<efl::eina::range_array<T> > >)
332{ 321{
333 if (!x) 322 return convert_to_c<T*, U*>(v.release());
334 return nullptr;
335 return efl::eina::range_array<T>{x};
336} 323}
337 324
338template <typename T, typename ...Args> 325template <typename T>
339inline efl::eina::array<T> 326Eina_Array** convert_to_c_impl(efl::eina::array<T>& c, tag<Eina_Array **, efl::eina::array<T>&>)
340to_cxx(Eina_Array* x, std::tuple<std::true_type, Args...>, tag< efl::eina::array<T> >)
341{ 327{
342 return efl::eina::array<T> {x}; 328 std::abort();
343} 329}
344 330template <typename T>
345template <typename T, typename ...Args> 331Eina_Array** convert_to_c_impl(efl::eina::range_array<T>& c, tag<Eina_Array **, efl::eina::range_array<T>&>)
346inline eina::optional<efl::eina::array<T> >
347to_cxx(Eina_Array* x, std::tuple<std::true_type, Args...>, tag< eina::optional<efl::eina::array<T> > >)
348{ 332{
349 if (!x) 333 std::abort();
350 return nullptr; 334}
351 return efl::eina::array<T> {x};
352} 335}
353
354 336
355inline eina::stringshare 337template <typename T, typename U, typename V>
356to_cxx(Eina_Stringshare const* x, const std::false_type, tag<eina::stringshare>) 338T convert_to_c(V&& object)
357{ 339{
358 return ::eina_stringshare_ref(x); 340 return impl::convert_to_c_impl(std::forward<V>(object), impl::tag<T, U>{});
359} 341}
342namespace impl {
343template <typename T>
344struct is_range : std::false_type {};
345template <typename T>
346struct is_range<efl::eina::range_list<T>> : std::true_type {};
347template <typename T>
348struct is_range<efl::eina::range_array<T>> : std::true_type {};
360 349
361inline eina::optional<eina::stringshare> 350template <typename T>
362to_cxx(Eina_Stringshare const* x, const std::false_type, tag<eina::optional<eina::stringshare> >) 351struct is_container : std::false_type {};
352template <typename T>
353struct is_container<efl::eina::list<T>> : std::true_type {};
354template <typename T>
355struct is_container<efl::eina::array<T>> : std::true_type {};
356
357// event
358template <typename T>
359T convert_to_event(void* value, typename std::enable_if< eo::is_eolian_object<T>::value>::type* = 0)
363{ 360{
364 if (!x) 361 return T{::eo_ref(static_cast<Eo*>(value))};
365 return nullptr;
366 return eina::stringshare(::eina_stringshare_ref(x));
367} 362}
368 363template <typename T>
369template <typename T, typename ...Args> 364T convert_to_event(void* value, typename std::enable_if< is_container<T>::value
370inline efl::eina::accessor<T> 365 || is_range<T>::value>::type* = 0)
371to_cxx(Eina_Accessor* x, std::tuple<std::false_type, Args...>, tag< efl::eina::accessor<T> >)
372{ 366{
373 return efl::eina::accessor<T>(x); 367 return T{static_cast<typename T::native_handle_type>(value)};
374} 368}
375 369template <typename T>
376template <typename T, typename ...Args> 370T convert_to_event(void* value, typename std::enable_if< !std::is_pointer<T>::value
377inline eina::optional<efl::eina::accessor<T> > 371 && !is_container<T>::value && !is_range<T>::value
378to_cxx(Eina_Accessor* x, std::tuple<std::false_type, Args...>, tag< eina::optional<efl::eina::accessor<T> > >) 372 && !eo::is_eolian_object<T>::value>::type* = 0)
379{ 373{
380 if (!x) 374 return *static_cast<T*>(value);
381 return nullptr;
382 return efl::eina::accessor<T>(x);
383} 375}
384 376template <typename T>
385template <typename T, typename ...Args> 377T convert_to_event(void* value, typename std::enable_if<std::is_same<T, bool>::value>::type* = 0)
386inline efl::eina::iterator<T>
387to_cxx(Eina_Iterator* x, std::tuple<std::false_type, Args...>, tag< efl::eina::iterator<T> >)
388{ 378{
389 return efl::eina::iterator<T>(x); 379 return *static_cast<Eina_Bool*>(value);
390} 380}
391 381}
392template <typename T, typename ...Args> 382template <typename T>
393inline eina::optional<efl::eina::iterator<T> > 383T convert_to_event(void* value) { return impl::convert_to_event<T>(value); }
394to_cxx(Eina_Iterator* x, std::tuple<std::false_type, Args...>, tag< eina::optional<efl::eina::iterator<T> > >) 384namespace impl {
385
386template <typename T>
387T convert_to_return(T value, tag<T, T>)
395{ 388{
396 if (!x) 389 return value;
397 return nullptr;
398 return efl::eina::iterator<T>(x);
399} 390}
400 391template <typename T>
401template <typename T, typename ...Args> 392T convert_to_return(Eo* value, tag<Eo*, T>, typename std::enable_if< eo::is_eolian_object<T>::value>::type* = 0)
402T
403to_cxx(Eo const* x, std::tuple<std::false_type, Args...>, tag< T >
404 , typename std::enable_if<std::is_base_of<::efl::eo::concrete, T>::value>* = 0)
405{ 393{
406 // Workaround for erroneous constness 394 return T{value};
407 return T{ ::eo_ref(const_cast<Eo*>(x))};
408} 395}
409 396template <typename T>
410template <typename T, typename ...Args> 397T convert_to_return(Eo const* value, tag<Eo const*, T>, typename std::enable_if<eo::is_eolian_object<T>::value>::type* = 0)
411eina::optional<T>
412to_cxx(Eo const* x, std::tuple<std::false_type, Args...>, tag< eina::optional<T> >
413 , typename std::enable_if<std::is_base_of<::efl::eo::concrete, T>::value>* = 0)
414{ 398{
415 // Workaround for erroneous constness 399 return T{const_cast<Eo*>(value)};
416 if (!x)
417 return nullptr;
418 return T{ ::eo_ref(const_cast<Eo*>(x))};
419} 400}
420 401template <typename T>
421template <typename T, typename ...Args> 402eina::list<T> convert_to_return(Eina_List* value, tag<Eina_List*, eina::list<T>>)
422T
423to_cxx(Eo const* x, std::tuple<std::true_type, Args...>, tag< T >
424 , typename std::enable_if<std::is_base_of<::efl::eo::concrete, T>::value>* = 0)
425{ 403{
426 // Workaround for erroneous constness 404 return eina::list<T>{value};
427 return T{const_cast<Eo*>(x)};
428} 405}
429 406template <typename T>
430template <typename T, typename ...Args> 407eina::list<T> convert_to_return(Eina_List const* value, tag<Eina_List const*, eina::list<T>>)
431eina::optional<T>
432to_cxx(Eo const* x, std::tuple<std::true_type, Args...>, tag< eina::optional<T> >
433 , typename std::enable_if<std::is_base_of<::efl::eo::concrete, T>::value>* = 0)
434{ 408{
435 // Workaround for erroneous constness 409 return eina::list<T>{const_cast<Eina_List*>(value)};
436 if (!x)
437 return nullptr;
438 return T{const_cast<Eo*>(x)};
439} 410}
440 411template <typename T>
441template <typename T, typename U, typename O> 412eina::range_list<T> convert_to_return(Eina_List* value, tag<Eina_List*, eina::range_list<T>>)
442T to_cxx(U object, O o)
443{ 413{
444 return to_cxx(object, o, tag<T>()); 414 return eina::range_list<T>{value};
445} 415}
446 416template <typename T>
447//// Callbacks 417eina::range_list<T> convert_to_return(Eina_List const* value, tag<Eina_List const*, eina::range_list<T>>)
448
449template <typename F, typename R, typename V, typename... Args>
450R funcall(V* data, Args... args)
451{ 418{
452 F const* f = static_cast<F const*>(data); 419 return eina::range_list<T>{const_cast<Eina_List*>(value)};
453 return (*f)(args...);
454} 420}
455
456template <typename T> 421template <typename T>
457struct callback_result_type; 422eina::array<T> convert_to_return(Eina_Array* value, tag<Eina_Array*, eina::array<T>>)
458
459template <typename R, typename... Args>
460struct callback_result_type<R(*)(Args...)>
461{ 423{
462 typedef R type; 424 return eina::array<T>{value};
463}; 425}
464 426template <typename T>
465template <typename R> 427eina::array<T> convert_to_return(Eina_Array const* value, tag<Eina_Array const*, eina::array<T>>)
466struct callback_args_type;
467
468template <typename R, typename... Args>
469struct callback_args_type<R(*)(Args...)>
470{ 428{
471 typedef std::tuple<Args...> type; 429 return eina::array<T>{const_cast<Eina_Array*>(value)};
472}; 430}
473 431template <typename T>
474template <typename C, typename F, typename R, typename V, typename... Args> 432eina::range_array<T> convert_to_return(Eina_Array* value, tag<Eina_Array*, eina::range_array<T>>)
475C get_callback_impl(tag<std::tuple<V*, Args...> >)
476{ 433{
477 static_assert(std::is_same<void, typename std::remove_cv<V>::type>::value, 434 return eina::range_array<T>{value};
478 "First argument of callback should be void* or const void*");
479 return static_cast<C>(&eolian::funcall<F, R, V, Args...>);
480} 435}
481 436template <typename T>
482template <typename C, typename F> 437eina::range_array<T> convert_to_return(Eina_Array const* value, tag<Eina_Array const*, eina::range_array<T>>)
483C get_callback()
484{ 438{
485 return get_callback_impl<C, F, typename callback_result_type<C>::type> 439 return eina::range_array<T>{const_cast<Eina_Array*>(value)};
486 (tag<typename callback_args_type<C>::type>());
487} 440}
488 441
489template <typename F> 442template <typename T>
490Eina_Bool free_callback_callback(void* data, ::Eo_Event const*) 443eina::iterator<T> convert_to_return(Eina_Iterator* value, tag<Eina_Iterator*, eina::iterator<T>>)
491{ 444{
492 delete static_cast<F*>(data); 445 return eina::iterator<T>{value};
493 return EO_CALLBACK_CONTINUE;
494} 446}
495 447template <typename T>
496template <typename... Fs> 448struct is_future : std::false_type {};
497inline 449template <typename T>
498void register_ev_del_free_callback(Eo* eoptr, Fs&&... fs) 450struct is_future<efl::eina::future<T>> : std::true_type {};
451template <typename T>
452T convert_to_return(Eina_Promise* /*value*/, tag<Eina_Promise*, T>, typename std::enable_if<is_future<T>::value>::type* = 0)
499{ 453{
500 std::initializer_list<int const> const v {(fs.register_ev_del_free_callback(eoptr), 0)...}; 454 std::abort();
501 (void) v; (void) eoptr; 455 return {};
502} 456}
503 457// Eina_Value*
504template <typename F> 458inline efl::eina::value convert_to_return(Eina_Value* value, tag<Eina_Value*, efl::eina::value>)
505inline 459{
506std::vector<F>& get_static_callback_vector() 460 return efl::eina::value{value};
461}
462template <typename T, typename U>
463T convert_to_return(U* value, tag<T, U*>, typename std::enable_if<is_range<T>::value || is_container<T>::value>::type* = 0)
464{
465 // const should be to the type if value is const
466 return T{const_cast<typename std::remove_const<U>::type*>(value)};
467}
468template <typename T>
469T convert_to_return(const char** /*value*/, tag<const char**, T>, typename std::enable_if<std::is_same<T, efl::eina::string_view*>::value>::type* = 0)
470{
471 std::abort();
472}
473inline eina::string_view convert_to_return(const char* value, tag<const char*, efl::eina::string_view>)
507{ 474{
508 static std::vector<F> vec; 475 return {value};
509 return vec; 476}
477inline std::string convert_to_return(const char* value, tag<const char*, std::string>)
478{
479 return {value};
480}
481inline bool convert_to_return(Eina_Bool value, tag<Eina_Bool, bool>)
482{
483 return !!value;
484}
485template <typename T>
486std::unique_ptr<T, void(*)(const void*)> convert_to_return(T* value, tag<T*, std::unique_ptr<T, void(*)(const void*)>>)
487{
488 return std::unique_ptr<T, void(*)(const void*)>{value, (void(*)(const void*))&free};
489}
490template <typename T, typename U>
491std::unique_ptr<T, void(*)(const void*)> convert_to_return(U* value, tag<U*, std::unique_ptr<T, void(*)(const void*)>>)
492{
493 return std::unique_ptr<T, void(*)(const void*)>{convert_to_return(value, tag<U*, T*>{}), (void(*)(const void*))&free};
494}
510} 495}
511 496
512template <typename F> 497template <typename T, typename U>
513inline 498T convert_to_return(U& object)
514F* alloc_static_callback(F&& f)
515{ 499{
516 get_static_callback_vector<F>().push_back(std::forward<F>(f)); 500 return impl::convert_to_return(object, impl::tag<U, T>{});
517 return &(get_static_callback_vector<F>().back());
518} 501}
519 502
520/// Miscellaneous 503/// Miscellaneous
504template <typename T, typename Enable = void>
505struct is_callable : std::false_type {};
506template <typename T>
507struct is_callable<T, decltype(std::declval<T>() ())> : std::true_type {};
521 508
522template <typename... Fs> 509inline void do_eo_add(Eo*& object, efl::eo::concrete const& parent
523inline 510 , Eo_Class const* klass)
524void call_ctors(Eo* _obj_eo_self, Fs&&... fs) 511{
512 object = ::_eo_add_internal_start(__FILE__, __LINE__, klass, parent._eo_ptr(), EINA_TRUE, EINA_FALSE);
513 object = ::_eo_add_end(object, EINA_FALSE);
514}
515template <typename F>
516void do_eo_add(Eo*& object, efl::eo::concrete const& parent, Eo_Class const* klass, F f)
525{ 517{
526 std::initializer_list<int const> const v {(fs(_obj_eo_self), 0)...}; 518 object = ::_eo_add_internal_start(__FILE__, __LINE__, klass, parent._eo_ptr(), EINA_TRUE, EINA_FALSE);
527 (void) v; 519 f();
528 (void) _obj_eo_self; 520 object = ::_eo_add_end(object, EINA_FALSE);
529} 521}
530 522
523template <typename D, typename T>
524struct light_address_of_operator
525{
526 operator T* () const { return static_cast<T*>(static_cast<void*>(static_cast<D const*>(this)->p)); }
527};
528template <typename D, typename T>
529struct light_address_of_operator<D, T const>
530{
531 operator T const* () const { return static_cast<T const*>(static_cast<void const*>(static_cast<D const*>(this)->p)); }
532};
533
534template <typename T, typename...Args>
535struct address_of_operator : light_address_of_operator<address_of_operator<T, Args...>, Args>...
536{
537 operator T* () { return p; };
538 address_of_operator(T* p) : p(p) {}
539 T* p;
540};
541
542template <typename T, typename...Args>
543struct address_of_operator<T const, Args...> : light_address_of_operator<address_of_operator<T const, Args...>, Args>...
544{
545 operator T const* () { return p; };
546 address_of_operator(T const* p) : p(p) {}
547 T const* p;
548};
549
531} } // namespace efl { namespace eolian { 550} } // namespace efl { namespace eolian {
532 551
533#endif // EFL_EOLIAN_INTEROP_HH 552#endif // EFL_EOLIAN_INTEROP_HH
diff --git a/src/bindings/cxx/eo_cxx/eo_event.hh b/src/bindings/cxx/eo_cxx/eo_event.hh
index 320bfc9cba..2120121cd8 100644
--- a/src/bindings/cxx/eo_cxx/eo_event.hh
+++ b/src/bindings/cxx/eo_cxx/eo_event.hh
@@ -8,11 +8,13 @@
8 8
9#include <Eo.h> 9#include <Eo.h>
10#include <Ecore.h> 10#include <Ecore.h>
11#include "eo_concrete.hh"
12#include "eo_cxx_interop.hh"
11 13
12#include <functional> 14#include <functional>
13#include <memory> 15#include <memory>
14 16
15namespace efl { namespace eo { 17namespace efl { namespace eolian {
16 18
17typedef ::Eo_Callback_Priority callback_priority; 19typedef ::Eo_Callback_Priority callback_priority;
18namespace callback_priorities 20namespace callback_priorities
@@ -121,30 +123,77 @@ signal_connection make_signal_connection(std::unique_ptr<F>& data, Eo* eo, ::Eo_
121 123
122namespace _detail { 124namespace _detail {
123 125
124template <typename T, typename F> 126template <typename T, typename P, typename F>
125Eina_Bool really_call_event(T& wrapper, F& f, Eo_Event_Description const& desc, void *info 127Eina_Bool really_call_event(T& wrapper, F& f, void *, std::true_type, std::true_type)
126 , std::true_type)
127{ 128{
128 f(wrapper, desc, info); 129 f(wrapper);
129 return true; 130 return true;
130} 131}
131template <typename T, typename F> 132template <typename T, typename P, typename F>
132Eina_Bool really_call_event(T& wrapper, F& f, Eo_Event_Description const& desc, void *info 133Eina_Bool really_call_event(T& wrapper, F& f, void *info, std::true_type, std::false_type)
133 , std::false_type) 134{
135 f(wrapper, convert_to_event<P>(info));
136 return true;
137}
138template <typename T, typename P, typename F>
139Eina_Bool really_call_event(T& wrapper, F& f, void *, std::false_type, std::true_type)
134{ 140{
135 return f(wrapper, desc, info); 141 return f(wrapper);
142}
143template <typename T, typename P, typename F>
144Eina_Bool really_call_event(T& wrapper, F& f, void *info, std::false_type, std::false_type)
145{
146 return f(wrapper, convert_to_event<P>(info));
136} 147}
137 148
149template <typename T, typename P, typename F, typename Enable = void>
150struct is_void;
151template <typename T, typename P, typename F>
152struct is_void<T, P, F, typename std::enable_if
153 <std::is_void<decltype(std::declval<F>()(std::declval<T>(), std::declval<P>()))>::value>::type>
154 : std::true_type {};
155template <typename T, typename P, typename F>
156struct is_void<T, P, F, typename std::enable_if
157 <!std::is_void<decltype(std::declval<F>()(std::declval<T>(), std::declval<P>()))>::value>::type>
158 : std::false_type {};
159template <typename T, typename F>
160struct is_void<T, void, F, typename std::enable_if
161 <std::is_void<decltype(std::declval<F>()(std::declval<T>()))>::value>::type>
162 : std::true_type {};
138template <typename T, typename F> 163template <typename T, typename F>
164struct is_void<T, void, F, typename std::enable_if
165 <!std::is_void<decltype(std::declval<F>()(std::declval<T>()))>::value>::type>
166 : std::false_type {};
167
168template <typename T, typename P, typename F>
139Eina_Bool 169Eina_Bool
140event_callback(void *data, ::Eo_Event const* event) 170event_callback(void *data, ::Eo_Event const* event)
141{ 171{
142 T wrapper(::eo_ref(event->object)); 172 T wrapper(::eo_ref(event->object));
143 F *f = static_cast<F*>(data); 173 F *f = static_cast<F*>(data);
144 return _detail::really_call_event(wrapper, *f, *event->desc, event->info 174 return _detail::really_call_event<T, P>
145 , std::is_void<decltype((*f)(wrapper, *event->desc, event->info))>()); 175 (wrapper, *f, event->info, is_void<T, P, F>(), std::is_void<P>{});
176}
146} 177}
147 178
179template <typename Event, typename Object, typename F>
180signal_connection event_add(Event event, Object object, F&& function)
181{
182 static_assert((eo::is_eolian_object<Object>::value), "Type is not an object");
183
184 typedef typename std::remove_reference<F>::type function_type;
185 std::unique_ptr<function_type> f(new function_type(std::forward<F>(function)));
186
187 ::eo_event_callback_priority_add
188 (object._eo_ptr(), event.description(), 0
189 , static_cast<Eo_Event_Cb>
190 (&_detail::event_callback<Object, typename Event::parameter_type, function_type>)
191 , f.get());
192 return make_signal_connection
193 (f, object._eo_ptr()
194 , static_cast<Eo_Event_Cb>
195 (&_detail::event_callback<Object, typename Event::parameter_type, function_type>)
196 , event.description());
148} 197}
149 198
150} } 199} }
diff --git a/src/bindings/cxx/eo_cxx/eo_inherit.hh b/src/bindings/cxx/eo_cxx/eo_inherit.hh
index a05d11fe94..96ee1dc3bf 100644
--- a/src/bindings/cxx/eo_cxx/eo_inherit.hh
+++ b/src/bindings/cxx/eo_cxx/eo_inherit.hh
@@ -1,155 +1,155 @@
1 1
2/// 2// ///
3/// @file eo_inherit.hh 3// /// @file eo_inherit.hh
4/// 4// ///
5 5
6#ifndef EFL_CXX_EO_INHERIT_HH 6// #ifndef EFL_CXX_EO_INHERIT_HH
7#define EFL_CXX_EO_INHERIT_HH 7// #define EFL_CXX_EO_INHERIT_HH
8 8
9#include <tuple> 9// #include <tuple>
10#include <cassert> 10// #include <cassert>
11 11
12#include <eina_integer_sequence.hh> 12// #include <eina_integer_sequence.hh>
13 13
14#include "eo_ops.hh" 14// #include "eo_ops.hh"
15#include "eo_private.hh" 15// #include "eo_private.hh"
16#include "eo_cxx_interop.hh" 16// #include "eo_cxx_interop.hh"
17 17
18namespace efl { namespace eo { 18// namespace efl { namespace eo {
19 19
20namespace detail { 20// namespace detail {
21 21
22template <typename D, typename... E, std::size_t... S> 22// template <typename D, typename... E, std::size_t... S>
23Eo_Class const* create_class(eina::index_sequence<S...>); 23// Eo_Class const* create_class(eina::index_sequence<S...>);
24 24
25/// @internal 25// /// @internal
26/// 26// ///
27/// @brief Find the correct function for the <em>"constructor"</em> 27// /// @brief Find the correct function for the <em>"constructor"</em>
28/// operation and invoke it. 28// /// operation and invoke it.
29/// 29// ///
30/// @param this_ The <em>user data</em> to be passed to the resolved function. 30// /// @param this_ The <em>user data</em> to be passed to the resolved function.
31/// @param args An heterogeneous sequence of arguments. 31// /// @param args An heterogeneous sequence of arguments.
32/// 32// ///
33inline EO_VOID_FUNC_BODYV(inherit_constructor, EO_FUNC_CALL(this_), void* this_); 33// inline EO_VOID_FUNC_BODYV(inherit_constructor, EO_FUNC_CALL(this_), void* this_);
34 34
35} 35// }
36 36
37/// @addtogroup Efl_Cxx_API 37// /// @addtogroup Efl_Cxx_API
38/// @{ 38// /// @{
39 39
40/// @brief Template-class that allows client code to inherit from 40// /// @brief Template-class that allows client code to inherit from
41/// <em>EO C++ Classes</em> without the need to make explicit calls to 41// /// <em>EO C++ Classes</em> without the need to make explicit calls to
42/// <em>EO</em> methods --- that would naturally be necessary to 42// /// <em>EO</em> methods --- that would naturally be necessary to
43/// register itself in the <em>EO Subsystem</em>. 43// /// register itself in the <em>EO Subsystem</em>.
44/// 44// ///
45/// @param D The derived class 45// /// @param D The derived class
46/// @param O The parent class 46// /// @param O The parent class
47/// @param E Class extensions (either mixins or interfaces) 47// /// @param E Class extensions (either mixins or interfaces)
48/// 48// ///
49/// The derived class @p D will inherit all EO operations and event 49// /// The derived class @p D will inherit all EO operations and event
50/// callbacks from the parent class @p P, as well as from the <c>Base 50// /// callbacks from the parent class @p P, as well as from the <c>Base
51/// Class</c> (@ref efl::eo::concrete) since every EO C++ Class must 51// /// Class</c> (@ref efl::eo::concrete) since every EO C++ Class must
52/// inherit from it. 52// /// inherit from it.
53/// 53// ///
54/// efl::eo::inherit makes use of meta-template elements to build (in 54// /// efl::eo::inherit makes use of meta-template elements to build (in
55/// compile-time) code capable of registering @p D as an <em>EO 55// /// compile-time) code capable of registering @p D as an <em>EO
56/// Class</em> within <em>EO Subsystem</em>. Each class is registered 56// /// Class</em> within <em>EO Subsystem</em>. Each class is registered
57/// only once upon instantiation of an object of its type. 57// /// only once upon instantiation of an object of its type.
58/// 58// ///
59/// @note Function overriding is currently not supported. 59// /// @note Function overriding is currently not supported.
60/// 60// ///
61template <typename D, typename... E> 61// template <typename D, typename... E>
62struct inherit; 62// struct inherit;
63 63
64/// @} 64// /// @}
65 65
66/// @addtogroup Efl_Cxx_API 66// /// @addtogroup Efl_Cxx_API
67/// @{ 67// /// @{
68 68
69template <typename D, typename... E> 69// template <typename D, typename... E>
70struct inherit 70// struct inherit
71 : detail::operations<E>::template type<inherit<D, E...> > ... 71// : detail::operations<E>::template type<inherit<D, E...> > ...
72 , detail::conversion_operator<inherit<D, E...>, E>... 72// , detail::conversion_operator<inherit<D, E...>, E>...
73{ 73// {
74 /// @typedef inherit_base 74// /// @typedef inherit_base
75 /// 75// ///
76 typedef inherit<D, E...> inherit_base; 76// typedef inherit<D, E...> inherit_base;
77 77
78 //@{ 78// //@{
79 /// @brief Class constructor. 79// /// @brief Class constructor.
80 /// 80// ///
81 /// @ref inherit has a "variadic" constructor implementation that 81// /// @ref inherit has a "variadic" constructor implementation that
82 /// allows from zero to EFL_MAX_ARGS heterogeneous parameters. 82// /// allows from zero to EFL_MAX_ARGS heterogeneous parameters.
83 /// 83// ///
84 template<typename... Args> 84// template<typename... Args>
85 inherit(efl::eo::parent_type _p, Args&& ... args) 85// inherit(efl::eo::parent_type _p, Args&& ... args)
86 { 86// {
87 _eo_cls = detail::create_class<D, E...> (eina::make_index_sequence<sizeof...(E)>()); 87// _eo_cls = detail::create_class<D, E...> (eina::make_index_sequence<sizeof...(E)>());
88 _eo_raw = eo_add_ref(_eo_cls, _p._eo_raw, detail::inherit_constructor(eo_self, this), ::efl::eolian::call_ctors(eo_self, args...)); 88// _eo_raw = eo_add_ref(_eo_cls, _p._eo_raw, detail::inherit_constructor(eo_self, this), ::efl::eolian::call_ctors(eo_self, args...));
89 ::efl::eolian::register_ev_del_free_callback(_eo_raw, args...); 89// ::efl::eolian::register_ev_del_free_callback(_eo_raw, args...);
90 } 90// }
91 91
92 template<typename... Args> 92// template<typename... Args>
93 inherit(Args&& ... args) 93// inherit(Args&& ... args)
94 : inherit(::efl::eo::parent = nullptr, std::forward<Args>(args)...) 94// : inherit(::efl::eo::parent = nullptr, std::forward<Args>(args)...)
95 {} 95// {}
96 //@} 96// //@}
97 97
98 /// @brief Class destructor. 98// /// @brief Class destructor.
99 /// 99// ///
100 ~inherit() 100// ~inherit()
101 { 101// {
102 detail::unref(_eo_raw); 102// detail::unref(_eo_raw);
103 } 103// }
104 104
105 /// @brief Gets the <em>EO Object</em> corresponding to this <em>EO 105// /// @brief Gets the <em>EO Object</em> corresponding to this <em>EO
106 /// C++ Object</em>. 106// /// C++ Object</em>.
107 /// 107// ///
108 /// @return A pointer to the <em>EO Object</em>. 108// /// @return A pointer to the <em>EO Object</em>.
109 /// 109// ///
110 Eo* _eo_ptr() const { return _eo_raw; } 110// Eo* _eo_ptr() const { return _eo_raw; }
111 111
112 /// @brief Gets the <em>EO Class</em> corresponding to this <em>EO 112// /// @brief Gets the <em>EO Class</em> corresponding to this <em>EO
113 /// C++ Class</em>. 113// /// C++ Class</em>.
114 /// 114// ///
115 /// @return A pointer to the <em>EO Class</em>. 115// /// @return A pointer to the <em>EO Class</em>.
116 /// 116// ///
117 Eo_Class const* _eo_class() const { return _eo_cls; } 117// Eo_Class const* _eo_class() const { return _eo_cls; }
118 118
119 Eo* _release() 119// Eo* _release()
120 { 120// {
121 Eo* tmp = _eo_raw; 121// Eo* tmp = _eo_raw;
122 _eo_raw = nullptr; 122// _eo_raw = nullptr;
123 return tmp; 123// return tmp;
124 } 124// }
125 125
126protected: 126// protected:
127 /// @brief Copy constructor. 127// /// @brief Copy constructor.
128 /// 128// ///
129 inherit(inherit const& other) 129// inherit(inherit const& other)
130 : _eo_cls(other._eo_cls) 130// : _eo_cls(other._eo_cls)
131 , _eo_raw(other._eo_raw) 131// , _eo_raw(other._eo_raw)
132 { detail::ref(_eo_raw); } 132// { detail::ref(_eo_raw); }
133 133
134 /// @brief Assignment Operator 134// /// @brief Assignment Operator
135 /// 135// ///
136 inherit& operator=(inherit const& other) 136// inherit& operator=(inherit const& other)
137 { 137// {
138 _eo_cls = other._eo_cls; 138// _eo_cls = other._eo_cls;
139 _eo_raw = other._eo_raw; 139// _eo_raw = other._eo_raw;
140 detail::ref(_eo_raw); 140// detail::ref(_eo_raw);
141 return *this; 141// return *this;
142 } 142// }
143 143
144private: 144// private:
145 Eo_Class const* _eo_cls; ///< The <em>EO Class</em>. 145// Eo_Class const* _eo_cls; ///< The <em>EO Class</em>.
146 Eo* _eo_raw; ///< The <em>EO Object</em>. 146// Eo* _eo_raw; ///< The <em>EO Object</em>.
147}; 147// };
148 148
149/// @} 149// /// @}
150 150
151} } // namespace efl { namespace eo { 151// } } // namespace efl { namespace eo {
152 152
153#include "eo_inherit_bindings.hh" 153// #include "eo_inherit_bindings.hh"
154 154
155#endif // EFL_CXX_INHERIT_HH 155// #endif // EFL_CXX_INHERIT_HH
diff --git a/src/examples/elementary/bg_cxx_example_01.cc b/src/examples/elementary/bg_cxx_example_01.cc
index 9fe20f445c..a1db40aa91 100644
--- a/src/examples/elementary/bg_cxx_example_01.cc
+++ b/src/examples/elementary/bg_cxx_example_01.cc
@@ -1,3 +1,5 @@
1#define EFL_EO_API_SUPPORT
2
1#include <Elementary.hh> 3#include <Elementary.hh>
2 4
3EAPI_MAIN int 5EAPI_MAIN int
@@ -5,16 +7,11 @@ elm_main (int argc, char *argv[])
5{ 7{
6 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN); 8 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
7 9
8 ::elm::win_standard win; 10 ::elm::win::Standard win;
9 win.title_set("Bg Plain"); 11 // win.title_set("Bg Plain");
10 win.autohide_set(true); 12 win.autohide_set(true);
11 13
12 ::elm::bg bg(efl::eo::parent = win); 14 win.eo_cxx::efl::Gfx::size_set(320,320);
13 bg.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
14 win.resize_object_add(bg);
15 bg.visible_set(true);
16
17 win.size_set(320,320);
18 win.visible_set(true); 15 win.visible_set(true);
19 16
20 elm_run(); 17 elm_run();
diff --git a/src/examples/elementary/button_cxx_example_00.cc b/src/examples/elementary/button_cxx_example_00.cc
index a18d652146..c12f504c70 100644
--- a/src/examples/elementary/button_cxx_example_00.cc
+++ b/src/examples/elementary/button_cxx_example_00.cc
@@ -1,3 +1,5 @@
1#define EFL_EO_API_SUPPORT
2
1#include <Elementary.hh> 3#include <Elementary.hh>
2 4
3EAPI_MAIN int 5EAPI_MAIN int
@@ -5,28 +7,23 @@ elm_main (int argc, char *argv[])
5{ 7{
6 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN); 8 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
7 9
8 ::elm::win_standard win; 10 ::elm::win::Standard win;
9 win.title_set("Hello, World!"); 11 //win.title_set("Hello, World!");
10 win.autohide_set(true); 12 win.autohide_set(true);
11 13
12 ::elm::bg bg(efl::eo::parent = win); 14 ::elm::Button btn(win);
13 bg.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
14 win.resize_object_add(bg);
15 bg.visible_set(true);
16
17 ::elm::button btn(efl::eo::parent = win);
18 btn.text_set("elm.text","Good-Bye, World!"); 15 btn.text_set("elm.text","Good-Bye, World!");
19 btn.size_set(120, 30); 16 btn.eo_cxx::efl::Gfx::size_set(120, 30);
20 btn.position_set(60, 15); 17 btn.eo_cxx::efl::Gfx::position_set(60, 15);
21 btn.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 18 // btn.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
22 btn.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL); 19 // btn.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
23 btn.visible_set(true); 20 btn.visible_set(true);
24 21
25 auto on_click = std::bind([] () { elm_exit(); }); 22 auto on_click = std::bind([] () { elm_exit(); });
26 23
27 btn.callback_clicked_add( on_click ); 24 efl::eolian::event_add(evas::Clickable_Interface::clicked_event, btn, on_click);
28 25
29 win.size_set(240, 60); 26 win.eo_cxx::efl::Gfx::size_set(240, 60);
30 win.visible_set(true); 27 win.visible_set(true);
31 28
32 elm_run(); 29 elm_run();
diff --git a/src/examples/eolian_cxx/Makefile.am b/src/examples/eolian_cxx/Makefile.am
index 8b6b68f6dd..f0b82d1da9 100644
--- a/src/examples/eolian_cxx/Makefile.am
+++ b/src/examples/eolian_cxx/Makefile.am
@@ -93,15 +93,15 @@ IMPL = \
93 93
94SRCS = \ 94SRCS = \
95 eolian_cxx_simple_01.cc \ 95