diff options
author | Savio Sena <savio@expertisesolutions.com.br> | 2014-05-03 00:55:51 +0200 |
---|---|---|
committer | Cedric Bail <cedric.bail@free.fr> | 2014-05-03 00:56:32 +0200 |
commit | 46b6e8a563bd429690e7bffba4e98d06aa40798d (patch) | |
tree | b7a2aebfc32bcc6d7a2600072a00d69a9f68d9a1 /src/lib/eolian_cxx/eo_validate.hh | |
parent | 64c6c63725d96f03baf34b660ca71e13b29078c1 (diff) |
eolian_cxx: initial version of the EFL C++ Bindings Generator.
Summary:
This patch adds 'eolian_cxx' -- a C++ bindings generator --
to the EFL tree. Eolian Cxx uses Eolian API to read .eo files and generate
.eo.hh. It relies/depends on Eo Cxx and Eina Cxx (both non-generated
bindings).
src/bin/eolian_cxx: The eolian_cxx program.
src/lib/eolian_cxx: A header-only library that implements the C++ code
generation that binds the .eo classes.
=Examples=
src/examples/eolian_cxx/eolian_cxx_simple_01.cc: The simplest example,
it just uses some "dummy" generated C++ classes.
src/examples/eolian_cxx/eolian_cxx_inherit_01.cc: Illustrates how
pure C++ classes inherit from .eo generated classes.
src/examples/evas/evas_cxx_rectangle.cc: More realistic example using
the generated bindings Evas Cxx. Still a bit shallow because we don't
have full fledged .eo descriptions yet, but will be improved.
=Important=
The generated code is not supported and not a stable API/ABI. It is
here to gather people interest and get review before we set things in
stone for release 1.11.
@feature
Reviewers: cedric, smohanty, raster, stefan_schmidt
CC: felipealmeida, JackDanielZ, cedric, stefan
Differential Revision: https://phab.enlightenment.org/D805
Signed-off-by: Cedric Bail <cedric.bail@free.fr>
Diffstat (limited to 'src/lib/eolian_cxx/eo_validate.hh')
-rw-r--r-- | src/lib/eolian_cxx/eo_validate.hh | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/lib/eolian_cxx/eo_validate.hh b/src/lib/eolian_cxx/eo_validate.hh new file mode 100644 index 0000000000..9e5342d55d --- /dev/null +++ b/src/lib/eolian_cxx/eo_validate.hh | |||
@@ -0,0 +1,91 @@ | |||
1 | |||
2 | #ifndef EOLIAN_CXX_EO_CLASS_VALIDATE_HH | ||
3 | #define EOLIAN_CXX_EO_CLASS_VALIDATE_HH | ||
4 | |||
5 | #include <string> | ||
6 | #include <cassert> | ||
7 | |||
8 | #ifdef DEBUG | ||
9 | #include <iostream> | ||
10 | #endif | ||
11 | |||
12 | #include "eo_types.hh" | ||
13 | |||
14 | namespace efl { namespace eolian { | ||
15 | |||
16 | inline bool | ||
17 | _isvalid(const std::string& name) | ||
18 | { | ||
19 | return name.size() > 0 and isalpha(name[0]); | ||
20 | } | ||
21 | |||
22 | inline void | ||
23 | _dbg(const std::string& msg) | ||
24 | { | ||
25 | #ifdef DEBUG | ||
26 | std::cerr << "eo_validate() - " << msg << std::endl; | ||
27 | #endif | ||
28 | } | ||
29 | |||
30 | inline void | ||
31 | eo_class_validate(const eo_class& cls) | ||
32 | { | ||
33 | _dbg("class name... " + cls.name); | ||
34 | assert(_isvalid(cls.name)); | ||
35 | |||
36 | _dbg("class type... " + cls.type); | ||
37 | assert(cls.type != eo_class::regular_ || | ||
38 | cls.type != eo_class::regular_noninst_ || | ||
39 | cls.type != eo_class::interface_ || | ||
40 | cls.type != eo_class::mixin_); | ||
41 | |||
42 | { | ||
43 | constructors_container_type::const_iterator it, | ||
44 | first = cls.constructors.begin(), | ||
45 | last = cls.constructors.end(); | ||
46 | for (it = first; it != last; ++it) | ||
47 | { | ||
48 | parameters_container_type::const_iterator | ||
49 | param = (*it).params.begin(), | ||
50 | last_param = (*it).params.end(); | ||
51 | _dbg("constructor... " + (*it).name); | ||
52 | assert(_isvalid((*it).name)); | ||
53 | for (; param != last_param; ++param) | ||
54 | { | ||
55 | _dbg("constructor parameter... " + (*param).name); | ||
56 | assert(_isvalid((*param).name)); | ||
57 | _dbg("constructor parameter type... " + (*param).type); | ||
58 | assert(_isvalid((*param).type)); | ||
59 | } | ||
60 | } | ||
61 | } | ||
62 | |||
63 | { | ||
64 | functions_container_type::const_iterator it, | ||
65 | first = cls.functions.begin(), | ||
66 | last = cls.functions.end(); | ||
67 | for (it = first; it != last; ++it) | ||
68 | { | ||
69 | _dbg("function... " + (*it).name); | ||
70 | assert(_isvalid((*it).name)); | ||
71 | _dbg("function api... " + (*it).impl); | ||
72 | assert(_isvalid((*it).impl)); | ||
73 | _dbg("function return... " + (*it).ret); | ||
74 | assert(_isvalid((*it).ret)); | ||
75 | parameters_container_type::const_iterator | ||
76 | param = (*it).params.begin(), | ||
77 | last_param = (*it).params.end(); | ||
78 | for (; param != last_param; ++param) | ||
79 | { | ||
80 | _dbg("function parameter... " + (*param).name); | ||
81 | assert(_isvalid((*param).name)); | ||
82 | _dbg("function parameter type... " + (*param).type); | ||
83 | assert(_isvalid((*param).type)); | ||
84 | } | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
89 | } } // namespace efl { namespace eolian { | ||
90 | |||
91 | #endif // EOLIAN_CXX_EO_CLASS_VALIDATE_HH | ||