summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2014-02-23 11:19:14 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-03-03 14:09:57 +0200
commit87f661e08ed7a88e831dce456ed163cd7e4749f3 (patch)
tree2be27f67ac10c5de4cae820545e580b5b11a6574 /src/bin
parent8cc58ed7cb62d74851e84b2cf0d1707ea293b823 (diff)
Eolian: support non null parameters.
The generation is only needed in legacy headers.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian/legacy_generator.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/bin/eolian/legacy_generator.c b/src/bin/eolian/legacy_generator.c
index 783c2d3963..d16e198610 100644
--- a/src/bin/eolian/legacy_generator.c
+++ b/src/bin/eolian/legacy_generator.c
@@ -95,6 +95,8 @@ _eapi_decl_func_generate(const char *classname, Eolian_Function funcid, Eolian_F
95 95
96 const Eina_List *l; 96 const Eina_List *l;
97 void *data; 97 void *data;
98 Eina_Strbuf *flags = NULL;
99 int leg_param_idx = 1; /* Index of the parameter inside the legacy function. It begins from 1 since obj is the first. */
98 100
99 EINA_LIST_FOREACH(eolian_property_keys_list_get(funcid), l, data) 101 EINA_LIST_FOREACH(eolian_property_keys_list_get(funcid), l, data)
100 { 102 {
@@ -102,10 +104,21 @@ _eapi_decl_func_generate(const char *classname, Eolian_Function funcid, Eolian_F
102 const char *pdesc; 104 const char *pdesc;
103 const char *ptype; 105 const char *ptype;
104 eolian_parameter_information_get((Eolian_Function_Parameter)data, NULL, &ptype, &pname, &pdesc); 106 eolian_parameter_information_get((Eolian_Function_Parameter)data, NULL, &ptype, &pname, &pdesc);
107 leg_param_idx++;
105 eina_strbuf_append_printf(fparam, ", %s%s %s", 108 eina_strbuf_append_printf(fparam, ", %s%s %s",
106 eolian_parameter_get_const_attribute_get(data)?"const":"", 109 eolian_parameter_get_const_attribute_get(data)?"const":"",
107 ptype, pname); 110 ptype, pname);
108 eina_strbuf_append_printf(descparam, " * @param %s\n", pname); 111 eina_strbuf_append_printf(descparam, " * @param %s\n", pname);
112 if (eolian_parameter_is_nonull((Eolian_Function_Parameter)data))
113 {
114 if (!flags)
115 {
116 flags = eina_strbuf_new();
117 eina_strbuf_append_printf(flags, " EINA_ARG_NONNULL(%d", leg_param_idx);
118 }
119 else
120 eina_strbuf_append_printf(flags, ", %d", leg_param_idx);
121 }
109 } 122 }
110 if (!var_as_ret) 123 if (!var_as_ret)
111 { 124 {
@@ -116,20 +129,42 @@ _eapi_decl_func_generate(const char *classname, Eolian_Function funcid, Eolian_F
116 const char *ptype; 129 const char *ptype;
117 Eolian_Parameter_Dir pdir; 130 Eolian_Parameter_Dir pdir;
118 eolian_parameter_information_get((Eolian_Function_Parameter)data, &pdir, &ptype, &pname, &pdesc); 131 eolian_parameter_information_get((Eolian_Function_Parameter)data, &pdir, &ptype, &pname, &pdesc);
132 leg_param_idx++;
119 const char *ptrstr = (umpr) ? umpr : ( (pdir == EOLIAN_IN_PARAM) ? "" : "*" ); 133 const char *ptrstr = (umpr) ? umpr : ( (pdir == EOLIAN_IN_PARAM) ? "" : "*" );
120 eina_strbuf_append_printf(fparam, ", %s%s%s %s", 134 eina_strbuf_append_printf(fparam, ", %s%s%s %s",
121 eolian_parameter_get_const_attribute_get(data)?"const":"", 135 eolian_parameter_get_const_attribute_get(data)?"const":"",
122 ptype, ptrstr, pname); 136 ptype, ptrstr, pname);
123 eina_strbuf_append_printf(descparam, " * @param %s\n", pname); 137 eina_strbuf_append_printf(descparam, " * @param %s\n", pname);
138 if (eolian_parameter_is_nonull((Eolian_Function_Parameter)data))
139 {
140 if (!flags)
141 {
142 flags = eina_strbuf_new();
143 eina_strbuf_append_printf(flags, " EINA_ARG_NONNULL(%d", leg_param_idx);
144 }
145 else
146 eina_strbuf_append_printf(flags, ", %d", leg_param_idx);
147 }
124 } 148 }
125 } 149 }
150 if (flags) eina_strbuf_append_printf(flags, ")");
151
126 eina_strbuf_replace_all(fbody, "@#params", eina_strbuf_string_get(fparam)); 152 eina_strbuf_replace_all(fbody, "@#params", eina_strbuf_string_get(fparam));
127 eina_strbuf_replace_all(fbody, "@#list_desc_param", eina_strbuf_string_get(descparam)); 153 eina_strbuf_replace_all(fbody, "@#list_desc_param", eina_strbuf_string_get(descparam));
128 eina_strbuf_replace_all(fbody, "@#type_return", (rettype) ? rettype : "void"); 154 eina_strbuf_replace_all(fbody, "@#type_return", (rettype) ? rettype : "void");
129 eina_strbuf_replace_all(fbody, "@#is_const", (ftype == GET || eolian_function_object_is_const(funcid)) ? "const " : ""); 155 eina_strbuf_replace_all(fbody, "@#is_const", (ftype == GET || eolian_function_object_is_const(funcid)) ? "const " : "");
156 if (eolian_function_return_is_warn_unused(funcid, ftype))
157 {
158 Eina_Bool no_nonull = !flags;
159 if (no_nonull) flags = eina_strbuf_new();
160 eina_strbuf_prepend_printf(flags, " EINA_WARN_UNUSED_RESULT%s", !no_nonull?", ":"");
161 }
162 if (flags)
163 eina_strbuf_replace_all(fbody, "@#flags", eina_strbuf_string_get(flags));
130 eina_strbuf_replace_all(fbody, "@#flags", (eolian_function_return_is_warn_unused(funcid, ftype)) ? " EINA_WARN_UNUSED_RESULT" : ""); 164 eina_strbuf_replace_all(fbody, "@#flags", (eolian_function_return_is_warn_unused(funcid, ftype)) ? " EINA_WARN_UNUSED_RESULT" : "");
131 eina_strbuf_append(buf, eina_strbuf_string_get(fbody)); 165 eina_strbuf_append(buf, eina_strbuf_string_get(fbody));
132 166
167 eina_strbuf_free(flags);
133 eina_strbuf_free(fbody); 168 eina_strbuf_free(fbody);
134 eina_strbuf_free(fparam); 169 eina_strbuf_free(fparam);
135 eina_strbuf_free(descparam); 170 eina_strbuf_free(descparam);