summaryrefslogtreecommitdiff
path: root/src/bin/eolian_cxx/comments.cc
diff options
context:
space:
mode:
authorSavio Sena <savio@expertisesolutions.com.br>2014-05-03 00:55:51 +0200
committerCedric Bail <cedric.bail@free.fr>2014-05-03 00:56:32 +0200
commit46b6e8a563bd429690e7bffba4e98d06aa40798d (patch)
treeb7a2aebfc32bcc6d7a2600072a00d69a9f68d9a1 /src/bin/eolian_cxx/comments.cc
parent64c6c63725d96f03baf34b660ca71e13b29078c1 (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/bin/eolian_cxx/comments.cc')
-rw-r--r--src/bin/eolian_cxx/comments.cc110
1 files changed, 110 insertions, 0 deletions
diff --git a/src/bin/eolian_cxx/comments.cc b/src/bin/eolian_cxx/comments.cc
new file mode 100644
index 0000000000..afe725f300
--- /dev/null
+++ b/src/bin/eolian_cxx/comments.cc
@@ -0,0 +1,110 @@
1
2#include "comments.hh"
3#include "safe_strings.hh"
4
5static std::string
6_comment_parameter(Eolian_Function_Parameter param)
7{
8 Eolian_Parameter_Dir direction;
9 Eina_Stringshare *description;
10
11 eolian_parameter_information_get
12 (param, &direction, NULL, NULL, &description);
13
14 std::string doc = "@param";
15 if (direction == EOLIAN_IN_PARAM) doc += " ";
16 else if (direction == EOLIAN_OUT_PARAM) doc += "[out] ";
17 else if (direction == EOLIAN_INOUT_PARAM) doc += "[inout] ";
18 else assert(false);
19
20 doc += safe_strshare(eolian_parameter_name_get(param));
21 doc += " ";
22 doc += safe_str(description);
23
24 return doc;
25}
26
27static std::string
28_comment_parameters_list(const Eina_List *params)
29{
30 std::string doc = "";
31 const Eina_List *it;
32 void *curr;
33 EINA_LIST_FOREACH (params, it, curr)
34 {
35 doc += _comment_parameter
36 (static_cast<Eolian_Function_Parameter>(curr)) + "\n";
37 }
38 return doc;
39}
40
41static std::string
42_comment_brief_and_params(Eolian_Function function,
43 const char *key = EOLIAN_COMMENT)
44{
45 std::string doc = "";
46 std::string func = safe_str(eolian_function_description_get(function, key));
47 if (func != "")
48 {
49 doc += "@brief " + func + "\n\n";
50 }
51 std::string params = _comment_parameters_list(eolian_parameters_list_get(function));
52 if (params != "")
53 {
54 doc += params + "\n";
55 }
56 return doc;
57}
58
59static std::string
60_comment_return(Eolian_Function function,
61 Eolian_Function_Type rettype)
62{
63 std::string doc = "";
64 std::string ret = safe_str(eolian_function_return_type_get(function, rettype));
65 std::string comment = safe_str(eolian_function_return_comment_get(function, rettype));
66 if (ret != "void" && ret != "" && comment != "")
67 {
68 doc = "@return " + comment;
69 }
70 return doc;
71}
72
73namespace detail {
74
75std::string
76eolian_class_comment(const char *classname)
77{
78 return safe_str(eolian_class_description_get(classname));
79}
80
81std::string
82eolian_constructor_comment(Eolian_Function constructor)
83{
84 return _comment_brief_and_params(constructor);
85}
86
87std::string eolian_function_comment(Eolian_Function function)
88{
89 std::string doc = _comment_brief_and_params(function);
90 doc += _comment_return(function, EOLIAN_METHOD);
91 return doc;
92}
93
94std::string eolian_property_getter_comment(Eolian_Function property)
95{
96 std::string doc = _comment_brief_and_params
97 (property, EOLIAN_COMMENT_GET);
98 doc += _comment_return(property, EOLIAN_PROP_GET);
99 return doc;
100}
101
102std::string eolian_property_setter_comment(Eolian_Function property)
103{
104 std::string doc = _comment_brief_and_params
105 (property, EOLIAN_COMMENT_SET);
106 doc += _comment_return(property, EOLIAN_PROP_SET);
107 return doc;
108}
109
110} // namespace detail