summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2015-06-24 15:23:01 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-06-24 15:23:01 +0100
commitdae35333fd905507ddae01a69add184ea1e3d10f (patch)
tree3c06a501248acbbb01234a77a376275c7f84a2ba /src/bin
parenteff0e37947d939dc26a2a9997ca79d3d8b5effae (diff)
eolian_cxx: Use C++ wrappers instead of native types as parameters
Summary: Using C++ wrapper types in the signature of methods of the generated classes. Now, when the type is an Eo type defined in Eolian, eolian_cxx will detect it and use the equivalent C++ wrapper. Types defined in Eolian no longer need to be specified in the lookup table, so removed them from there. Disable wrapping of non-const char*. The current wrapper (unique_ptr) is not suited for some required operations like ownership acquisition from C code. Fix constructing properties that only have the "set" method. Fix translation of non-const parameters. Modified Makefiles to allow proper inclusion of evas_cxx headers required by some tests and examples. Move one auxiliary function to another reader to make it more accessible. @feature Reviewers: felipealmeida, q66, cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2752
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian_cxx/convert.cc2
-rw-r--r--src/bin/eolian_cxx/eolian_wrappers.hh13
-rw-r--r--src/bin/eolian_cxx/type_lookup.hh36
-rw-r--r--src/bin/eolian_cxx/type_lookup_table.cc4
4 files changed, 38 insertions, 17 deletions
diff --git a/src/bin/eolian_cxx/convert.cc b/src/bin/eolian_cxx/convert.cc
index 051c6e3e80..1b42e66799 100644
--- a/src/bin/eolian_cxx/convert.cc
+++ b/src/bin/eolian_cxx/convert.cc
@@ -302,7 +302,7 @@ convert_eolian_functions(efl::eolian::eo_class& cls, Eolian_Class const& klass)
302 Eolian_Function const& func = *(::eolian_constructor_function_get(&ctor)); 302 Eolian_Function const& func = *(::eolian_constructor_function_get(&ctor));
303 303
304 efl::eolian::eo_function f; 304 efl::eolian::eo_function f;
305 if (::eolian_function_type_get(&func) != EOLIAN_PROPERTY) 305 if (function_op_type(func) == EOLIAN_METHOD)
306 f = _convert_function(klass, func); 306 f = _convert_function(klass, func);
307 else 307 else
308 f = _convert_property_set_to_function(klass, func); 308 f = _convert_property_set_to_function(klass, func);
diff --git a/src/bin/eolian_cxx/eolian_wrappers.hh b/src/bin/eolian_cxx/eolian_wrappers.hh
index 65f218d6e4..9ea4f4cf15 100644
--- a/src/bin/eolian_cxx/eolian_wrappers.hh
+++ b/src/bin/eolian_cxx/eolian_wrappers.hh
@@ -97,19 +97,6 @@ class_eo_name(Eolian_Class const& klass)
97 (find_replace(class_full_name(klass) + "_" + suffix, ".", "_")); 97 (find_replace(class_full_name(klass) + "_" + suffix, ".", "_"));
98} 98}
99 99
100inline std::string
101class_format_cxx(std::string const& fullname)
102{
103 std::string s = fullname;
104 auto found = s.find(".");
105 while (found != std::string::npos)
106 {
107 s.replace(found, 1, "::");
108 found = s.find(".");
109 }
110 return s;
111}
112
113inline efl::eolian::eo_class::eo_class_type 100inline efl::eolian::eo_class::eo_class_type
114class_type(Eolian_Class const& klass) 101class_type(Eolian_Class const& klass)
115{ 102{
diff --git a/src/bin/eolian_cxx/type_lookup.hh b/src/bin/eolian_cxx/type_lookup.hh
index f7be16e857..38b683d468 100644
--- a/src/bin/eolian_cxx/type_lookup.hh
+++ b/src/bin/eolian_cxx/type_lookup.hh
@@ -7,6 +7,7 @@
7#include <vector> 7#include <vector>
8#include <cctype> 8#include <cctype>
9#include <iterator> 9#include <iterator>
10#include <stdexcept>
10#include <cassert> 11#include <cassert>
11#include <cstddef> 12#include <cstddef>
12 13
@@ -23,6 +24,19 @@ namespace eolian_cxx {
23typedef std::vector<efl::eolian::eolian_type> lookup_table_type; 24typedef std::vector<efl::eolian::eolian_type> lookup_table_type;
24extern const lookup_table_type type_lookup_table; 25extern const lookup_table_type type_lookup_table;
25 26
27inline std::string
28class_format_cxx(std::string const& fullname)
29{
30 std::string s = fullname;
31 auto found = s.find(".");
32 while (found != std::string::npos)
33 {
34 s.replace(found, 1, "::");
35 found = s.find(".");
36 }
37 return s;
38}
39
26inline bool 40inline bool
27type_is_complex(Eolian_Type const& type) 41type_is_complex(Eolian_Type const& type)
28{ 42{
@@ -33,6 +47,28 @@ inline efl::eolian::eolian_type
33type_from_eolian(Eolian_Type const& type) 47type_from_eolian(Eolian_Type const& type)
34{ 48{
35 efl::eolian::eolian_type x; 49 efl::eolian::eolian_type x;
50
51 Eolian_Type_Type tpt = ::eolian_type_type_get(&type);
52 if (tpt == EOLIAN_TYPE_POINTER || tpt == EOLIAN_TYPE_ALIAS || tpt == EOLIAN_TYPE_REGULAR)
53 {
54 Eolian_Type const* base_type = ::eolian_type_base_type_get(&type);
55 if (base_type && ::eolian_type_type_get(base_type) == EOLIAN_TYPE_CLASS)
56 {
57 Eolian_Class const* klass = ::eolian_type_class_get(base_type);
58 if (klass)
59 {
60 x.category = efl::eolian::eolian_type::simple_;
61 x.is_class = true;
62 x.binding_requires_optional = false;
63 x.binding = "::" + class_format_cxx(safe_lower(safe_str(::eolian_class_full_name_get(klass))));
64
65 Eina_Stringshare* klass_file = ::eolian_class_file_get(klass);
66 if (klass_file)
67 x.includes = {safe_str(klass_file) + ".hh"};
68 }
69 }
70 }
71
36 x.native = normalize_spaces(safe_str(::eolian_type_c_type_get(&type))); 72 x.native = normalize_spaces(safe_str(::eolian_type_c_type_get(&type)));
37 x.is_own = ::eolian_type_is_own(&type); 73 x.is_own = ::eolian_type_is_own(&type);
38 x.is_const = ::eolian_type_is_const(&type); 74 x.is_const = ::eolian_type_is_const(&type);
diff --git a/src/bin/eolian_cxx/type_lookup_table.cc b/src/bin/eolian_cxx/type_lookup_table.cc
index dd005518fb..de6529969e 100644
--- a/src/bin/eolian_cxx/type_lookup_table.cc
+++ b/src/bin/eolian_cxx/type_lookup_table.cc
@@ -23,12 +23,10 @@ type_lookup_table
23 {"Eina_List *", eolian_type::complex_, false, true, true, true, "::efl::eina::list", {"eina-cxx/eina_list.hh"}}, 23 {"Eina_List *", eolian_type::complex_, false, true, true, true, "::efl::eina::list", {"eina-cxx/eina_list.hh"}},
24 {"const Eina_List *", eolian_type::complex_, true, false, true, true, "::efl::eina::crange_list", {"eina-cxx/eina_list.hh"}}, 24 {"const Eina_List *", eolian_type::complex_, true, false, true, true, "::efl::eina::crange_list", {"eina-cxx/eina_list.hh"}},
25 {"Eio_Filter_Direct_Cb", eolian_type::callback_, {"Eio.h"}}, 25 {"Eio_Filter_Direct_Cb", eolian_type::callback_, {"Eio.h"}},
26 {"Emodel *", eolian_type::simple_, false, false, true, false, "::emodel", {"Emodel.hh"}},
27 {"Eo *", eolian_type::simple_, false, true, true, false, "::efl::eo::concrete", {"eo_concrete.hh"}}, 26 {"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"}}, 27 {"Eo *", eolian_type::simple_, false, false, true, false, "::efl::eo::concrete", {"eo_concrete.hh"}},
29 //{"Evas_Object_Box_Layout", eolian_type::callback_, {"Evas.h"}}, 28 //{"Evas_Object_Box_Layout", eolian_type::callback_, {"Evas.h"}},
30 {"Evas_Object *", eolian_type::simple_, false, false, true, false, "::evas::object", {"canvas/evas_object.eo.hh"}}, 29 //{"char *", eolian_type::simple_, false, true, true, false, "std::unique_ptr<char*>", {"memory"}},
31 {"char *", eolian_type::simple_, false, true, true, false, "std::unique_ptr<char*>", {"memory"}},
32 {"const Eina_Inlist *", eolian_type::complex_, false, false, true, true, "::efl::eina::range_inlist", {"eina-cxx/eina_inlist.hh"}}, 30 {"const Eina_Inlist *", eolian_type::complex_, false, false, true, true, "::efl::eina::range_inlist", {"eina-cxx/eina_inlist.hh"}},
33 {"const Eina_List *", eolian_type::complex_, false, false, true, true, "::efl::eina::range_list", {"eina-cxx/eina_ptrlist.hh"}}, 31 {"const Eina_List *", eolian_type::complex_, false, false, true, true, "::efl::eina::range_list", {"eina-cxx/eina_ptrlist.hh"}},
34 {"const char *", eolian_type::simple_, false, false, true, true, "::efl::eina::string_view", {"string"}}, 32 {"const char *", eolian_type::simple_, false, false, true, true, "::efl::eina::string_view", {"string"}},