summaryrefslogtreecommitdiff
path: root/src/bin/eolian_cxx
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2015-01-12 12:00:59 -0200
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2015-04-14 01:06:57 -0300
commitd53038989886a85b75c81a395269f6f349d7d78f (patch)
treed21410341bfd403ccc503a928687b304a734e9d5 /src/bin/eolian_cxx
parentbe58d02cb655c244a659abbcdb9ab44e8a5459ce (diff)
eolian_cxx: Add protected methods and events to C++ wrappers and fixes
Using eina::string_view in eolian generated interfaces (instead of std::string) to allow lightweight passing of both C strings and C++ std::string. Also, No longer using eina::optional in generated headers for types that already implements the concept of null state (like Eo wrappers and eina_accessor). Also fix allocating callback objects require by class methods (i.e. static) in static vectors so the memory will be freed when the programs exit. Added a new test case for testing callbacks on class methods. Moved method definitions and supplementary code from generated C++ wrappers to auxiliary header file (.eo.impl.hh) generated together with the main ".eo.hh" file. Updated Makefiles to list such files in the compilation and cleanup processes. Updated .gitignore to include these new generated files. Made general adjustments on the documentation of generated C++ wrappers Added "PREDEFINED" preprocessor macro definition in the Doxyfile.in in order to make some adjustments for better documentation in the C++ generated headers. Excluding generation of documentation for classes in the "eo_cxx" namespace (the namespace for "abstract" eolian C++ wrappers). Now generating the documentation for the events too. Hiding some auxiliary code from being documented. Some aesthetic adjustments for generated white space. Generate documentation for the main constructor of C++ wrappers and added auxiliary grammars to list parameters names.
Diffstat (limited to 'src/bin/eolian_cxx')
-rw-r--r--src/bin/eolian_cxx/convert.cc3
-rw-r--r--src/bin/eolian_cxx/eolian_cxx.cc48
-rw-r--r--src/bin/eolian_cxx/eolian_wrappers.hh21
-rw-r--r--src/bin/eolian_cxx/type_lookup_table.cc34
4 files changed, 77 insertions, 29 deletions
diff --git a/src/bin/eolian_cxx/convert.cc b/src/bin/eolian_cxx/convert.cc
index d029999411..22ee22f0e5 100644
--- a/src/bin/eolian_cxx/convert.cc
+++ b/src/bin/eolian_cxx/convert.cc
@@ -141,6 +141,7 @@ _convert_property_set_to_function(Eolian_Class const& klass,
141 efl::eolian::eo_function set_ = 141 efl::eolian::eo_function set_ =
142 { 142 {
143 efl::eolian::eo_function::regular_, 143 efl::eolian::eo_function::regular_,
144 function_scope(prop_),
144 function_name(prop_) + "_set", 145 function_name(prop_) + "_set",
145 function_impl(prop_) + "_set", 146 function_impl(prop_) + "_set",
146 function_return_type(prop_, eolian_cxx::setter), 147 function_return_type(prop_, eolian_cxx::setter),
@@ -168,6 +169,7 @@ _convert_property_get_to_function(Eolian_Class const& klass,
168 efl::eolian::eo_function get_ = 169 efl::eolian::eo_function get_ =
169 { 170 {
170 efl::eolian::eo_function::regular_, 171 efl::eolian::eo_function::regular_,
172 function_scope(prop_),
171 function_name(prop_) + "_get", 173 function_name(prop_) + "_get",
172 function_impl(prop_) + "_get", 174 function_impl(prop_) + "_get",
173 function_return_type(prop_, eolian_cxx::getter), 175 function_return_type(prop_, eolian_cxx::getter),
@@ -291,6 +293,7 @@ convert_eolian_functions(efl::eolian::eo_class& cls, Eolian_Class const& klass)
291 { 293 {
292 cls.functions.push_back({ 294 cls.functions.push_back({
293 function_type(func), 295 function_type(func),
296 function_scope(func),
294 function_name(func), 297 function_name(func),
295 function_impl(func), 298 function_impl(func),
296 function_return_type(func), 299 function_return_type(func),
diff --git a/src/bin/eolian_cxx/eolian_cxx.cc b/src/bin/eolian_cxx/eolian_cxx.cc
index 93e9e442ab..7afa10da10 100644
--- a/src/bin/eolian_cxx/eolian_cxx.cc
+++ b/src/bin/eolian_cxx/eolian_cxx.cc
@@ -119,30 +119,58 @@ generate(const Eolian_Class& klass, eolian_cxx::options_type const& opts)
119{ 119{
120 efl::eolian::eo_class cls = eolian_cxx::convert_eolian_class(klass); 120 efl::eolian::eo_class cls = eolian_cxx::convert_eolian_class(klass);
121 efl::eolian::eo_generator_options gen_opts = generator_options(klass); 121 efl::eolian::eo_generator_options gen_opts = generator_options(klass);
122 std::string outname = opts.out_file.empty() ? (class_base_file(klass) + ".hh") : opts.out_file; 122 std::string header_decl_file_name = opts.out_file.empty() ? (class_base_file(klass) + ".hh") : opts.out_file;
123
124 std::string header_impl_file_name = header_decl_file_name;
125 std::size_t dot_pos = header_impl_file_name.rfind(".hh");
126 if (dot_pos != std::string::npos)
127 header_impl_file_name.insert(dot_pos, ".impl");
128 else
129 header_impl_file_name.insert(header_impl_file_name.size(), ".impl");
130
131 std::size_t slash_pos = header_decl_file_name.rfind('/');
132 gen_opts.header_decl_file_name = (slash_pos == std::string::npos) ?
133 header_decl_file_name :
134 header_decl_file_name.substr(slash_pos+1);
135
136 slash_pos = header_impl_file_name.rfind('/');
137 gen_opts.header_impl_file_name = (slash_pos == std::string::npos) ?
138 header_impl_file_name :
139 header_impl_file_name.substr(slash_pos+1);
140
123 if (!opts.out_dir.empty()) 141 if (!opts.out_dir.empty())
124 { 142 {
125 outname = opts.out_dir + "/" + outname; 143 header_decl_file_name = opts.out_dir + "/" + header_decl_file_name;
144 header_impl_file_name = opts.out_dir + "/" + header_impl_file_name;
126 } 145 }
127 if(opts.out_file == "-") 146 if(opts.out_file == "-")
128 { 147 {
129 efl::eolian::generate(std::cout, cls, gen_opts); 148 efl::eolian::generate(std::cout, std::cout, cls, gen_opts);
130 } 149 }
131 else 150 else
132 { 151 {
133 std::ofstream outfile; 152 std::ofstream header_decl;
134 outfile.open(outname); 153 header_decl.open(header_decl_file_name);
135 if (outfile.good()) 154 if (!header_decl.good())
136 { 155 {
137 efl::eolian::generate(outfile, cls, gen_opts); 156 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
138 outfile.close(); 157 << "Can't open output file: " << header_decl_file_name << std::endl;
158 return false;
139 } 159 }
140 else 160
161 std::ofstream header_impl;
162 header_impl.open(header_impl_file_name);
163 if (!header_impl.good())
141 { 164 {
142 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain) 165 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
143 << "Can't open output file: " << outname << std::endl; 166 << "Can't open output file: " << header_impl_file_name << std::endl;
144 return false; 167 return false;
145 } 168 }
169
170 efl::eolian::generate(header_decl, header_impl, cls, gen_opts);
171
172 header_decl.close();
173 header_impl.close();
146 } 174 }
147 return true; 175 return true;
148} 176}
diff --git a/src/bin/eolian_cxx/eolian_wrappers.hh b/src/bin/eolian_cxx/eolian_wrappers.hh
index d1b28a6f5f..5cad7976c0 100644
--- a/src/bin/eolian_cxx/eolian_wrappers.hh
+++ b/src/bin/eolian_cxx/eolian_wrappers.hh
@@ -25,6 +25,15 @@ getter_t const getter = {};
25struct method_t { static constexpr ::Eolian_Function_Type value = ::EOLIAN_METHOD; }; 25struct method_t { static constexpr ::Eolian_Function_Type value = ::EOLIAN_METHOD; };
26method_t const method = {}; 26method_t const method = {};
27 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
28inline const Eolian_Class* 37inline const Eolian_Class*
29class_from_file(std::string const& file) 38class_from_file(std::string const& file)
30{ 39{
@@ -195,11 +204,18 @@ function_is_constructor(Eolian_Class const& cls, Eolian_Function const& func)
195 return ::eolian_function_is_constructor(&func, &cls); 204 return ::eolian_function_is_constructor(&func, &cls);
196} 205}
197 206
207inline efl::eolian::eolian_scope
208function_scope(Eolian_Function const& func)
209{
210 return eolian_scope_cxx(::eolian_function_scope_get(&func));
211}
212
198inline bool 213inline bool
199function_is_visible(Eolian_Function const& func, Eolian_Function_Type func_type) 214function_is_visible(Eolian_Function const& func, Eolian_Function_Type func_type)
200{ 215{
201 return (::eolian_function_scope_get(&func) == EOLIAN_SCOPE_PUBLIC && 216 Eolian_Object_Scope s = ::eolian_function_scope_get(&func);
202 ! ::eolian_function_is_legacy_only(&func, func_type)); 217 return ((s == EOLIAN_SCOPE_PUBLIC || s == EOLIAN_SCOPE_PROTECTED) &&
218 !::eolian_function_is_legacy_only(&func, func_type));
203} 219}
204 220
205inline bool 221inline bool
@@ -388,6 +404,7 @@ event_create(Eolian_Class const& klass, const Eolian_Event *event_)
388 std::string name_ = safe_str(name); 404 std::string name_ = safe_str(name);
389 std::transform(name_.begin(), name_.end(), name_.begin(), 405 std::transform(name_.begin(), name_.end(), name_.begin(),
390 [](int c) { return c != ',' ? c : '_'; }); 406 [](int c) { return c != ',' ? c : '_'; });
407 event.scope = eolian_scope_cxx(::eolian_event_scope_get(event_));
391 event.name = normalize_spaces(name_); 408 event.name = normalize_spaces(name_);
392 event.eo_name = safe_upper 409 event.eo_name = safe_upper
393 (find_replace(class_full_name(klass), ".", "_") + "_EVENT_" + event.name); 410 (find_replace(class_full_name(klass), ".", "_") + "_EVENT_" + event.name);
diff --git a/src/bin/eolian_cxx/type_lookup_table.cc b/src/bin/eolian_cxx/type_lookup_table.cc
index 7fa085e9ba..dd005518fb 100644
--- a/src/bin/eolian_cxx/type_lookup_table.cc
+++ b/src/bin/eolian_cxx/type_lookup_table.cc
@@ -13,25 +13,25 @@ type_lookup_table
13 {"Ecore_Task_Cb", eolian_type::callback_, {"Ecore.h"}}, 13 {"Ecore_Task_Cb", eolian_type::callback_, {"Ecore.h"}},
14 {"Ecore_Timeline_Cb", eolian_type::callback_, {"Ecore.h"}}, 14 {"Ecore_Timeline_Cb", eolian_type::callback_, {"Ecore.h"}},
15 {"Edje_Signal_Cb", eolian_type::callback_, {"Edje.h"}}, 15 {"Edje_Signal_Cb", eolian_type::callback_, {"Edje.h"}},
16 {"Eina_Accessor *", eolian_type::complex_, false, false, true, "::efl::eina::accessor", {"eina-cxx/eina_accessor.hh"}}, 16 {"Eina_Accessor *", eolian_type::complex_, false, false, true, false, "::efl::eina::accessor", {"eina-cxx/eina_accessor.hh"}},
17 {"Eina_Bool", eolian_type::simple_, false, false, false, "bool", {}}, 17 {"Eina_Bool", eolian_type::simple_, false, false, false, false, "bool", {}},
18 {"Eina_Bool *", eolian_type::simple_, false, false, false, "bool*", {}}, 18 {"Eina_Bool *", eolian_type::simple_, false, false, false, false, "bool*", {}},
19 {"Eina_Inlist *", eolian_type::complex_, false, false, true, "::efl::eina::range_inlist", {"eina-cxx/eina_inlist.hh"}}, 19 {"Eina_Inlist *", eolian_type::complex_, false, false, true, true, "::efl::eina::range_inlist", {"eina-cxx/eina_inlist.hh"}},
20 {"Eina_Inlist *", eolian_type::complex_, false, true, true, "::efl::eina::inlist", {"eina-cxx/eina_inlist.hh"}}, 20 {"Eina_Inlist *", eolian_type::complex_, false, true, true, true, "::efl::eina::inlist", {"eina-cxx/eina_inlist.hh"}},
21 {"Eina_Iterator *", eolian_type::complex_, false, false, true, "::efl::eina::iterator", {"eina-cxx/eina_iterator.hh"}}, 21 {"Eina_Iterator *", eolian_type::complex_, false, false, true, true, "::efl::eina::iterator", {"eina-cxx/eina_iterator.hh"}},
22 {"Eina_List *", eolian_type::complex_, false, false, true, "::efl::eina::range_list", {"eina-cxx/eina_list.hh"}}, 22 {"Eina_List *", eolian_type::complex_, false, false, true, true, "::efl::eina::range_list", {"eina-cxx/eina_list.hh"}},
23 {"Eina_List *", eolian_type::complex_, false, 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, "::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, "::emodel", {"Emodel.hh"}}, 26 {"Emodel *", eolian_type::simple_, false, false, true, false, "::emodel", {"Emodel.hh"}},
27 {"Eo *", eolian_type::simple_, false, true, true, "::efl::eo::concrete", {"eo_concrete.hh"}}, 27 {"Eo *", eolian_type::simple_, false, true, true, false, "::efl::eo::concrete", {"eo_concrete.hh"}},
28 {"Eo *", eolian_type::simple_, false, false, true, "::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"}}, 29 //{"Evas_Object_Box_Layout", eolian_type::callback_, {"Evas.h"}},
30 {"Evas_Object *", eolian_type::simple_, false, false, true, "::evas::object", {"canvas/evas_object.eo.hh"}}, 30 {"Evas_Object *", eolian_type::simple_, false, false, true, false, "::evas::object", {"canvas/evas_object.eo.hh"}},
31 {"char *", eolian_type::simple_, false, true, true, "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, "::efl::eina::range_inlist", {"eina-cxx/eina_inlist.hh"}}, 32 {"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, "::efl::eina::range_list", {"eina-cxx/eina_ptrlist.hh"}}, 33 {"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, "std::string", {"string"}}, 34 {"const char *", eolian_type::simple_, false, false, true, true, "::efl::eina::string_view", {"string"}},
35}; 35};
36 36
37} 37}