summaryrefslogtreecommitdiff
path: root/src/bin/eolian_cxx/comments.cc
diff options
context:
space:
mode:
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