diff options
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 | ||