summaryrefslogtreecommitdiff
path: root/src/bindings
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/bindings
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/bindings')
-rw-r--r--src/bindings/eo_cxx/eo_concrete.hh6
-rw-r--r--src/bindings/eo_cxx/eo_cxx_interop.hh52
2 files changed, 58 insertions, 0 deletions
diff --git a/src/bindings/eo_cxx/eo_concrete.hh b/src/bindings/eo_cxx/eo_concrete.hh
index 63029a14e7..9e328b1d92 100644
--- a/src/bindings/eo_cxx/eo_concrete.hh
+++ b/src/bindings/eo_cxx/eo_concrete.hh
@@ -21,6 +21,12 @@
21#endif 21#endif
22#endif 22#endif
23 23
24#if !defined(EFL_DOXYGEN) && !defined(EO_CXX_INHERIT)
25# define EO_CXX_INHERIT(name) ::eo_cxx::name
26#elif !defined(EO_CXX_INHERIT)
27# define EO_CXX_INHERIT(name) ::name
28#endif
29
24namespace efl { namespace eo { 30namespace efl { namespace eo {
25 31
26/// @addtogroup Efl_Cxx_API 32/// @addtogroup Efl_Cxx_API
diff --git a/src/bindings/eo_cxx/eo_cxx_interop.hh b/src/bindings/eo_cxx/eo_cxx_interop.hh
index ba6a473fc6..08ca3005ba 100644
--- a/src/bindings/eo_cxx/eo_cxx_interop.hh
+++ b/src/bindings/eo_cxx/eo_cxx_interop.hh
@@ -4,6 +4,7 @@
4 4
5#include <string> 5#include <string>
6#include <tuple> 6#include <tuple>
7#include <utility>
7#include <type_traits> 8#include <type_traits>
8 9
9#include <Eina.hh> 10#include <Eina.hh>
@@ -28,6 +29,20 @@ to_c(eina::optional<std::string> const& x)
28} 29}
29 30
30inline const char* 31inline const char*
32to_c(eina::string_view const& x)
33{
34 return x.data();
35}
36
37inline const char*
38to_c(eina::optional<eina::string_view> const& x)
39{
40 if (!x)
41 return nullptr;
42 return x->data();
43}
44
45inline const char*
31to_c(efl::eina::stringshare const& x) 46to_c(efl::eina::stringshare const& x)
32{ 47{
33 return x.c_str(); 48 return x.c_str();
@@ -196,6 +211,20 @@ to_cxx(const char* x, std::tuple<std::false_type>, tag<eina::optional<std::strin
196 return std::string(x); 211 return std::string(x);
197} 212}
198 213
214inline eina::string_view
215to_cxx(const char* x, std::tuple<std::false_type>, tag<eina::string_view>)
216{
217 return eina::string_view(x);
218}
219
220inline eina::optional<eina::string_view>
221to_cxx(const char* x, std::tuple<std::false_type>, tag<eina::optional<eina::string_view> >)
222{
223 if (!x)
224 return nullptr;
225 return eina::string_view(x);
226}
227
199template <typename T, typename Enable = void> 228template <typename T, typename Enable = void>
200struct traits 229struct traits
201{ 230{
@@ -216,6 +245,13 @@ struct traits
216 typedef const char* type; 245 typedef const char* type;
217}; 246};
218 247
248template <typename T>
249struct traits
250 <T, typename std::enable_if<std::is_base_of<::efl::eina::basic_string_view<char>, T>::value>::type>
251{
252 typedef const char* type;
253};
254
219template <typename T, typename ...Args> 255template <typename T, typename ...Args>
220inline efl::eina::range_list<T const> 256inline efl::eina::range_list<T const>
221to_cxx(const Eina_List* x, std::tuple<std::false_type, Args...>, tag< efl::eina::range_list<T> >) 257to_cxx(const Eina_List* x, std::tuple<std::false_type, Args...>, tag< efl::eina::range_list<T> >)
@@ -407,6 +443,22 @@ Eina_Bool free_callback_calback(void* data, Eo* obj EINA_UNUSED
407 return EO_CALLBACK_CONTINUE; 443 return EO_CALLBACK_CONTINUE;
408} 444}
409 445
446template <typename F>
447inline
448std::vector<F>& get_static_callback_vector()
449{
450 static std::vector<F> vec;
451 return vec;
452}
453
454template <typename F>
455inline
456F* alloc_static_callback(F&& f)
457{
458 get_static_callback_vector<F>().push_back(std::forward<F>(f));
459 return &(get_static_callback_vector<F>().back());
460}
461
410} } // namespace efl { namespace eolian { 462} } // namespace efl { namespace eolian {
411 463
412#endif // EFL_EOLIAN_INTEROP_HH 464#endif // EFL_EOLIAN_INTEROP_HH