summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2019-05-16 15:31:37 +0200
committerDaniel Kolesa <d.kolesa@samsung.com>2019-05-16 15:43:52 +0200
commit4ab1f2388eb303f8e5d9eae31cdcf39df683c736 (patch)
tree9dc1d113f199f97b1025e38a6c1479303b833a70
parent7f45f94af0201d48f7fcae14c6320ce3b9bcab71 (diff)
eolian: add API to retrieve the C name of an object
This is to prepare for type/class renaming support. This adds the necessary API to retrieve C-specific names. Other refactoring is necessary elsewhere for now. This also renames the old API eolian_class_c_name_get to eolian_class_c_macro_get to avoid conflict as well as clarify the intention.
-rw-r--r--src/bin/eolian/headers.c2
-rw-r--r--src/bin/eolian/sources.c6
-rw-r--r--src/bindings/luajit/eolian.lua15
-rw-r--r--src/lib/eolian/Eolian.h88
-rw-r--r--src/lib/eolian/database_class.c1
-rw-r--r--src/lib/eolian/database_class_api.c2
-rw-r--r--src/lib/eolian/database_type.c2
-rw-r--r--src/lib/eolian/database_var.c1
-rw-r--r--src/lib/eolian/eo_parser.c20
-rw-r--r--src/lib/eolian/eolian_database.c7
-rw-r--r--src/lib/eolian/eolian_database.h1
-rw-r--r--src/scripts/pyolian/eolian.py4
-rw-r--r--src/scripts/pyolian/eolian_lib.py6
-rwxr-xr-xsrc/scripts/pyolian/test_eolian.py2
-rw-r--r--src/tests/eolian/eolian_parsing.c3
15 files changed, 141 insertions, 19 deletions
diff --git a/src/bin/eolian/headers.c b/src/bin/eolian/headers.c
index d35c604577..645d6945d1 100644
--- a/src/bin/eolian/headers.c
+++ b/src/bin/eolian/headers.c
@@ -205,7 +205,7 @@ eo_gen_header_gen(const Eolian_State *state, const Eolian_Class *cl,
205 } 205 }
206 } 206 }
207 207
208 Eina_Stringshare *mname = eolian_class_c_name_get(cl); 208 Eina_Stringshare *mname = eolian_class_c_macro_get(cl);
209 Eina_Stringshare *gname = eolian_class_c_get_function_name_get(cl); 209 Eina_Stringshare *gname = eolian_class_c_get_function_name_get(cl);
210 eina_strbuf_append_printf(buf, "#define %s %s()\n\n", mname, gname); 210 eina_strbuf_append_printf(buf, "#define %s %s()\n\n", mname, gname);
211 eina_stringshare_del(mname); 211 eina_stringshare_del(mname);
diff --git a/src/bin/eolian/sources.c b/src/bin/eolian/sources.c
index 265dc75d92..37acd7e641 100644
--- a/src/bin/eolian/sources.c
+++ b/src/bin/eolian/sources.c
@@ -1163,14 +1163,14 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
1163 eina_strbuf_append(buf, ", NULL"); 1163 eina_strbuf_append(buf, ", NULL");
1164 else 1164 else
1165 { 1165 {
1166 Eina_Stringshare *mname = eolian_class_c_name_get(icl); 1166 Eina_Stringshare *mname = eolian_class_c_macro_get(icl);
1167 eina_strbuf_append_printf(buf, ", %s", mname); 1167 eina_strbuf_append_printf(buf, ", %s", mname);
1168 eina_stringshare_del(mname); 1168 eina_stringshare_del(mname);
1169 } 1169 }
1170 Eina_Iterator *itr = eolian_class_extensions_get(cl); 1170 Eina_Iterator *itr = eolian_class_extensions_get(cl);
1171 EINA_ITERATOR_FOREACH(itr, icl) 1171 EINA_ITERATOR_FOREACH(itr, icl)
1172 { 1172 {
1173 Eina_Stringshare *mname = eolian_class_c_name_get(icl); 1173 Eina_Stringshare *mname = eolian_class_c_macro_get(icl);
1174 eina_strbuf_append_printf(buf, ", %s", mname); 1174 eina_strbuf_append_printf(buf, ", %s", mname);
1175 eina_stringshare_del(mname); 1175 eina_stringshare_del(mname);
1176 } 1176 }
@@ -1342,7 +1342,7 @@ _gen_proto(const Eolian_Class *cl, const Eolian_Function *fid,
1342 if (!strcmp(efname + strlen(efname) - sizeof("destructor") + 1, "destructor")) 1342 if (!strcmp(efname + strlen(efname) - sizeof("destructor") + 1, "destructor"))
1343 { 1343 {
1344 Eina_Stringshare *fcn = eolian_function_full_c_name_get(fid, ftype); 1344 Eina_Stringshare *fcn = eolian_function_full_c_name_get(fid, ftype);
1345 Eina_Stringshare *mname = eolian_class_c_name_get(cl); 1345 Eina_Stringshare *mname = eolian_class_c_macro_get(cl);
1346 eina_strbuf_append(buf, " "); 1346 eina_strbuf_append(buf, " ");
1347 eina_strbuf_append(buf, fcn); 1347 eina_strbuf_append(buf, fcn);
1348 eina_stringshare_del(fcn); 1348 eina_stringshare_del(fcn);
diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua
index a89946c1eb..d3edf8492b 100644
--- a/src/bindings/luajit/eolian.lua
+++ b/src/bindings/luajit/eolian.lua
@@ -301,6 +301,7 @@ ffi.cdef [[
301 int eolian_object_line_get(const Eolian_Object *obj); 301 int eolian_object_line_get(const Eolian_Object *obj);
302 int eolian_object_column_get(const Eolian_Object *obj); 302 int eolian_object_column_get(const Eolian_Object *obj);
303 const char *eolian_object_name_get(const Eolian_Object *obj); 303 const char *eolian_object_name_get(const Eolian_Object *obj);
304 const char *eolian_object_c_name_get(const Eolian_Object *obj);
304 const char *eolian_object_short_name_get(const Eolian_Object *obj); 305 const char *eolian_object_short_name_get(const Eolian_Object *obj);
305 Eina_Iterator *eolian_object_namespaces_get(const Eolian_Object *obj); 306 Eina_Iterator *eolian_object_namespaces_get(const Eolian_Object *obj);
306 Eina_Bool eolian_object_is_beta(const Eolian_Object *obj); 307 Eina_Bool eolian_object_is_beta(const Eolian_Object *obj);
@@ -409,7 +410,7 @@ ffi.cdef [[
409 const char *eolian_class_c_get_function_name_get(const Eolian_Class *klass); 410 const char *eolian_class_c_get_function_name_get(const Eolian_Class *klass);
410 Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp); 411 Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp);
411 Eolian_Type_Builtin_Type eolian_type_builtin_type_get(const Eolian_Type *tp); 412 Eolian_Type_Builtin_Type eolian_type_builtin_type_get(const Eolian_Type *tp);
412 const char *eolian_class_c_name_get(const Eolian_Class *klass); 413 const char *eolian_class_c_macro_get(const Eolian_Class *klass);
413 const char *eolian_class_c_data_type_get(const Eolian_Class *klass); 414 const char *eolian_class_c_data_type_get(const Eolian_Class *klass);
414 Eolian_Typedecl_Type eolian_typedecl_type_get(const Eolian_Typedecl *tp); 415 Eolian_Typedecl_Type eolian_typedecl_type_get(const Eolian_Typedecl *tp);
415 Eina_Iterator *eolian_typedecl_struct_fields_get(const Eolian_Typedecl *tp); 416 Eina_Iterator *eolian_typedecl_struct_fields_get(const Eolian_Typedecl *tp);
@@ -587,6 +588,14 @@ local object_idx, wrap_object = gen_wrap {
587 return ffi.string(v) 588 return ffi.string(v)
588 end, 589 end,
589 590
591 c_name_get = function(self)
592 local v = eolian.eolian_object_c_name_get(cast_obj(self))
593 if v == nil then
594 return nil
595 end
596 return ffi.string(v)
597 end,
598
590 short_name_get = function(self) 599 short_name_get = function(self)
591 local v = eolian.eolian_object_short_name_get(cast_obj(self)) 600 local v = eolian.eolian_object_short_name_get(cast_obj(self))
592 if v == nil then 601 if v == nil then
@@ -1510,8 +1519,8 @@ M.Class = ffi.metatype("Eolian_Class", {
1510 return ffi_stringshare(v) 1519 return ffi_stringshare(v)
1511 end, 1520 end,
1512 1521
1513 c_name_get = function(self) 1522 c_macro_get = function(self)
1514 local v = eolian.eolian_class_c_name_get(self) 1523 local v = eolian.eolian_class_c_macro_get(self)
1515 if v == nil then return nil end 1524 if v == nil then return nil end
1516 return ffi_stringshare(v) 1525 return ffi_stringshare(v)
1517 end, 1526 end,
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index 748edb9be6..662cf39f7a 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -586,6 +586,7 @@ EAPI void *eolian_state_error_data_set(Eolian_State *state, void *data);
586 * @see eolian_object_line_get 586 * @see eolian_object_line_get
587 * @see eolian_object_column_get 587 * @see eolian_object_column_get
588 * @see eolian_object_name_get 588 * @see eolian_object_name_get
589 * @see eolian_object_c_name_get
589 * 590 *
590 * @ingroup Eolian 591 * @ingroup Eolian
591 */ 592 */
@@ -601,6 +602,7 @@ EAPI Eolian_Object_Type eolian_object_type_get(const Eolian_Object *obj);
601 * @see eolian_object_line_get 602 * @see eolian_object_line_get
602 * @see eolian_object_column_get 603 * @see eolian_object_column_get
603 * @see eolian_object_name_get 604 * @see eolian_object_name_get
605 * @see eolian_object_c_name_get
604 * 606 *
605 * @ingroup Eolian 607 * @ingroup Eolian
606 */ 608 */
@@ -617,6 +619,7 @@ EAPI const Eolian_Unit *eolian_object_unit_get(const Eolian_Object *obj);
617 * @see eolian_object_line_get 619 * @see eolian_object_line_get
618 * @see eolian_object_column_get 620 * @see eolian_object_column_get
619 * @see eolian_object_name_get 621 * @see eolian_object_name_get
622 * @see eolian_object_c_name_get
620 * 623 *
621 * @ingroup Eolian 624 * @ingroup Eolian
622 */ 625 */
@@ -632,6 +635,7 @@ EAPI const char *eolian_object_file_get(const Eolian_Object *obj);
632 * @see eolian_object_file_get 635 * @see eolian_object_file_get
633 * @see eolian_object_column_get 636 * @see eolian_object_column_get
634 * @see eolian_object_name_get 637 * @see eolian_object_name_get
638 * @see eolian_object_c_name_get
635 * 639 *
636 * @ingroup Eolian 640 * @ingroup Eolian
637 */ 641 */
@@ -650,6 +654,7 @@ EAPI int eolian_object_line_get(const Eolian_Object *obj);
650 * @see eolian_object_file_get 654 * @see eolian_object_file_get
651 * @see eolian_object_line_get 655 * @see eolian_object_line_get
652 * @see eolian_object_name_get 656 * @see eolian_object_name_get
657 * @see eolian_object_c_name_get
653 * 658 *
654 * @ingroup Eolian 659 * @ingroup Eolian
655 */ 660 */
@@ -669,12 +674,35 @@ EAPI int eolian_object_column_get(const Eolian_Object *obj);
669 * @see eolian_object_column_get 674 * @see eolian_object_column_get
670 * @see eolian_object_short_name_get 675 * @see eolian_object_short_name_get
671 * @see eolian_object_namespaces_get 676 * @see eolian_object_namespaces_get
677 * @see eolian_object_c_name_get
672 * 678 *
673 * @ingroup Eolian 679 * @ingroup Eolian
674 */ 680 */
675EAPI const char *eolian_object_name_get(const Eolian_Object *obj); 681EAPI const char *eolian_object_name_get(const Eolian_Object *obj);
676 682
677/* 683/*
684 * @brief Get the C name of an object.
685 *
686 * This is the full name, but for C. It is typically derived from the
687 * regular full name, with namespaces flattened to underscores, but
688 * some things may be explicitly renamed. Only classes, types (both
689 * declarations and instances) and variables have C names, as others
690 * are never referred to by name directly in C.
691 *
692 * @see eolian_object_unit_get
693 * @see eolian_object_type_get
694 * @see eolian_object_file_get
695 * @see eolian_object_line_get
696 * @see eolian_object_column_get
697 * @see eolian_object_short_name_get
698 * @see eolian_object_namespaces_get
699 * @see eolian_object_name_get
700 *
701 * @ingroup Eolian
702 */
703EAPI const char *eolian_object_c_name_get(const Eolian_Object *obj);
704
705/*
678 * @brief Get the short name of an object. 706 * @brief Get the short name of an object.
679 * 707 *
680 * This means a name without namespaces. If the object's name is not 708 * This means a name without namespaces. If the object's name is not
@@ -1392,6 +1420,19 @@ eolian_class_name_get(const Eolian_Class *klass)
1392} 1420}
1393 1421
1394/* 1422/*
1423 * @brief A helper function to get the C name of a class.
1424 *
1425 * @see eolian_object_c_name_get
1426 *
1427 * @ingroup Eolian
1428 */
1429static inline const char *
1430eolian_class_c_name_get(const Eolian_Class *klass)
1431{
1432 return eolian_object_c_name_get(EOLIAN_OBJECT(klass));
1433}
1434
1435/*
1395 * @brief A helper function to get the short name of a class. 1436 * @brief A helper function to get the short name of a class.
1396 * 1437 *
1397 * @see eolian_object_short_name_get 1438 * @see eolian_object_short_name_get
@@ -2278,12 +2319,12 @@ EAPI Eina_Bool eolian_class_dtor_enable_get(const Eolian_Class *klass);
2278EAPI Eina_Stringshare *eolian_class_c_get_function_name_get(const Eolian_Class *klass); 2319EAPI Eina_Stringshare *eolian_class_c_get_function_name_get(const Eolian_Class *klass);
2279 2320
2280/* 2321/*
2281 * @brief Get the C name of the class. 2322 * @brief Get the C macro of the class.
2282 * 2323 *
2283 * @param[in] klass the class 2324 * @param[in] klass the class
2284 * @return the C name 2325 * @return the C symbol
2285 * 2326 *
2286 * The C name is the name of the macro the class is accessed through, in format 2327 * This is the name by which the class is accessed in C environment, in format
2287 * CLASS_NAME_SUFFIX where SUFFIX is CLASS, MIXIN or INTERFACE. You're responsible 2328 * CLASS_NAME_SUFFIX where SUFFIX is CLASS, MIXIN or INTERFACE. You're responsible
2288 * for the stringshare afterwards. 2329 * for the stringshare afterwards.
2289 * 2330 *
@@ -2291,7 +2332,7 @@ EAPI Eina_Stringshare *eolian_class_c_get_function_name_get(const Eolian_Class *
2291 * 2332 *
2292 * @ingroup Eolian 2333 * @ingroup Eolian
2293 */ 2334 */
2294EAPI Eina_Stringshare *eolian_class_c_name_get(const Eolian_Class *klass); 2335EAPI Eina_Stringshare *eolian_class_c_macro_get(const Eolian_Class *klass);
2295 2336
2296/* 2337/*
2297 * @brief Get the C data type of the class. 2338 * @brief Get the C data type of the class.
@@ -2560,6 +2601,19 @@ eolian_typedecl_name_get(const Eolian_Typedecl *tp)
2560} 2601}
2561 2602
2562/* 2603/*
2604 * @brief A helper function to get the C name of a typedecl.
2605 *
2606 * @see eolian_object_c_name_get
2607 *
2608 * @ingroup Eolian
2609 */
2610static inline const char *
2611eolian_typedecl_c_name_get(const Eolian_Typedecl *tp)
2612{
2613 return eolian_object_c_name_get(EOLIAN_OBJECT(tp));
2614}
2615
2616/*
2563 * @brief A helper function to get the short name of a typedecl. 2617 * @brief A helper function to get the short name of a typedecl.
2564 * 2618 *
2565 * @see eolian_object_short_name_get 2619 * @see eolian_object_short_name_get
@@ -2755,6 +2809,19 @@ eolian_type_name_get(const Eolian_Type *tp)
2755} 2809}
2756 2810
2757/* 2811/*
2812 * @brief A helper function to get the C name of a type.
2813 *
2814 * @see eolian_object_c_name_get
2815 *
2816 * @ingroup Eolian
2817 */
2818static inline const char *
2819eolian_type_c_name_get(const Eolian_Type *tp)
2820{
2821 return eolian_object_c_name_get(EOLIAN_OBJECT(tp));
2822}
2823
2824/*
2758 * @brief A helper function to get the short name of a type. 2825 * @brief A helper function to get the short name of a type.
2759 * 2826 *
2760 * @see eolian_object_short_name_get 2827 * @see eolian_object_short_name_get
@@ -2998,6 +3065,19 @@ eolian_variable_name_get(const Eolian_Variable *tp)
2998} 3065}
2999 3066
3000/* 3067/*
3068 * @brief A helper function to get the C name of a variable.
3069 *
3070 * @see eolian_object_c_name_get
3071 *
3072 * @ingroup Eolian
3073 */
3074static inline const char *
3075eolian_variable_c_name_get(const Eolian_Variable *tp)
3076{
3077 return eolian_object_c_name_get(EOLIAN_OBJECT(tp));
3078}
3079
3080/*
3001 * @brief A helper function to get the short name of a variable. 3081 * @brief A helper function to get the short name of a variable.
3002 * 3082 *
3003 * @see eolian_object_short_name_get 3083 * @see eolian_object_short_name_get
diff --git a/src/lib/eolian/database_class.c b/src/lib/eolian/database_class.c
index 4c8c45d400..110817cdb5 100644
--- a/src/lib/eolian/database_class.c
+++ b/src/lib/eolian/database_class.c
@@ -18,6 +18,7 @@ database_class_del(Eolian_Class *cl)
18 18
19 eina_stringshare_del(cl->base.file); 19 eina_stringshare_del(cl->base.file);
20 eina_stringshare_del(cl->base.name); 20 eina_stringshare_del(cl->base.name);
21 eina_stringshare_del(cl->base.c_name);
21 22
22 EINA_LIST_FREE(cl->implements, impl) 23 EINA_LIST_FREE(cl->implements, impl)
23 database_implement_del(impl); 24 database_implement_del(impl);
diff --git a/src/lib/eolian/database_class_api.c b/src/lib/eolian/database_class_api.c
index 3e3b0d78d5..5733d6c6ff 100644
--- a/src/lib/eolian/database_class_api.c
+++ b/src/lib/eolian/database_class_api.c
@@ -178,7 +178,7 @@ eolian_class_c_get_function_name_get(const Eolian_Class *cl)
178} 178}
179 179
180EAPI Eina_Stringshare * 180EAPI Eina_Stringshare *
181eolian_class_c_name_get(const Eolian_Class *cl) 181eolian_class_c_macro_get(const Eolian_Class *cl)
182{ 182{
183 EINA_SAFETY_ON_NULL_RETURN_VAL(cl, NULL); 183 EINA_SAFETY_ON_NULL_RETURN_VAL(cl, NULL);
184 Eina_Stringshare *ret; 184 Eina_Stringshare *ret;
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index 529617e348..2523527a2d 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -11,6 +11,7 @@ database_type_del(Eolian_Type *tp)
11 if (!tp || eolian_object_unref(&tp->base)) return; 11 if (!tp || eolian_object_unref(&tp->base)) return;
12 eina_stringshare_del(tp->base.file); 12 eina_stringshare_del(tp->base.file);
13 eina_stringshare_del(tp->base.name); 13 eina_stringshare_del(tp->base.name);
14 eina_stringshare_del(tp->base.c_name);
14 database_type_del(tp->base_type); 15 database_type_del(tp->base_type);
15 database_type_del(tp->next_type); 16 database_type_del(tp->next_type);
16 if (tp->freefunc) eina_stringshare_del(tp->freefunc); 17 if (tp->freefunc) eina_stringshare_del(tp->freefunc);
@@ -23,6 +24,7 @@ database_typedecl_del(Eolian_Typedecl *tp)
23 if (!tp || eolian_object_unref(&tp->base)) return; 24 if (!tp || eolian_object_unref(&tp->base)) return;
24 eina_stringshare_del(tp->base.file); 25 eina_stringshare_del(tp->base.file);
25 eina_stringshare_del(tp->base.name); 26 eina_stringshare_del(tp->base.name);
27 eina_stringshare_del(tp->base.c_name);
26 database_type_del(tp->base_type); 28 database_type_del(tp->base_type);
27 if (tp->fields) eina_hash_free(tp->fields); 29 if (tp->fields) eina_hash_free(tp->fields);
28 if (tp->field_list) eina_list_free(tp->field_list); 30 if (tp->field_list) eina_list_free(tp->field_list);
diff --git a/src/lib/eolian/database_var.c b/src/lib/eolian/database_var.c
index a6eea20cdf..4007091848 100644
--- a/src/lib/eolian/database_var.c
+++ b/src/lib/eolian/database_var.c
@@ -11,6 +11,7 @@ database_var_del(Eolian_Variable *var)
11 if (!var || eolian_object_unref(&var->base)) return; 11 if (!var || eolian_object_unref(&var->base)) return;
12 eina_stringshare_del(var->base.file); 12 eina_stringshare_del(var->base.file);
13 eina_stringshare_del(var->base.name); 13 eina_stringshare_del(var->base.name);
14 eina_stringshare_del(var->base.c_name);
14 if (var->base_type) 15 if (var->base_type)
15 database_type_del(var->base_type); 16 database_type_del(var->base_type);
16 if (var->value) database_expr_del(var->value); 17 if (var->value) database_expr_del(var->value);
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 65a28dfd58..80d89e558b 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -98,6 +98,17 @@ check_match(Eo_Lexer *ls, int what, int who, int where, int col)
98 } 98 }
99} 99}
100 100
101static Eina_Stringshare *
102make_c_name(const char *fulln)
103{
104 char *mbuf = strdup(fulln);
105 for (char *p = mbuf; (p = strchr(p, '.')); ++p)
106 *p = '_';
107 Eina_Stringshare *ret = eina_stringshare_add(mbuf);
108 free(mbuf);
109 return ret;
110}
111
101static Eina_Bool 112static Eina_Bool
102compare_class_file(const char *fn1, const char *fn2) 113compare_class_file(const char *fn1, const char *fn2)
103{ 114{
@@ -440,6 +451,7 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
440 def->is_extern = is_extern; 451 def->is_extern = is_extern;
441 def->base.is_beta = is_beta; 452 def->base.is_beta = is_beta;
442 def->base.name = name; 453 def->base.name = name;
454 def->base.c_name = make_c_name(name);
443 def->type = EOLIAN_TYPEDECL_STRUCT; 455 def->type = EOLIAN_TYPEDECL_STRUCT;
444 def->fields = eina_hash_string_small_new(EINA_FREE_CB(_struct_field_free)); 456 def->fields = eina_hash_string_small_new(EINA_FREE_CB(_struct_field_free));
445 if (freefunc) 457 if (freefunc)
@@ -499,6 +511,7 @@ parse_enum(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
499 def->is_extern = is_extern; 511 def->is_extern = is_extern;
500 def->base.is_beta = is_beta; 512 def->base.is_beta = is_beta;
501 def->base.name = name; 513 def->base.name = name;
514 def->base.c_name = make_c_name(name);
502 def->type = EOLIAN_TYPEDECL_ENUM; 515 def->type = EOLIAN_TYPEDECL_ENUM;
503 def->fields = eina_hash_string_small_new(EINA_FREE_CB(_enum_field_free)); 516 def->fields = eina_hash_string_small_new(EINA_FREE_CB(_enum_field_free));
504 check_next(ls, '{'); 517 check_next(ls, '{');
@@ -672,6 +685,7 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ptr)
672 { 685 {
673 def->btype = ls->t.kw - KW_byte + 1; 686 def->btype = ls->t.kw - KW_byte + 1;
674 def->base.name = eina_stringshare_ref(ls->t.value.s); 687 def->base.name = eina_stringshare_ref(ls->t.value.s);
688 def->base.c_name = eina_stringshare_ref(def->base.name);
675 eo_lexer_get(ls); 689 eo_lexer_get(ls);
676 if ((tpid >= KW_accessor && tpid <= KW_list) || 690 if ((tpid >= KW_accessor && tpid <= KW_list) ||
677 (tpid >= KW_slice && tpid <= KW_rw_slice)) 691 (tpid >= KW_slice && tpid <= KW_rw_slice))
@@ -723,6 +737,7 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ptr)
723 def->type = EOLIAN_TYPE_CLASS; 737 def->type = EOLIAN_TYPE_CLASS;
724 } 738 }
725 def->base.name = eina_stringshare_add(nm); 739 def->base.name = eina_stringshare_add(nm);
740 def->base.c_name = make_c_name(nm);
726 eo_lexer_context_pop(ls); 741 eo_lexer_context_pop(ls);
727 eo_lexer_dtor_pop(ls); 742 eo_lexer_dtor_pop(ls);
728 } 743 }
@@ -760,6 +775,7 @@ tags_done:
760 FILL_BASE(def->base, ls, ls->line_number, ls->column, TYPEDECL); 775 FILL_BASE(def->base, ls, ls->line_number, ls->column, TYPEDECL);
761 parse_name(ls, buf); 776 parse_name(ls, buf);
762 def->base.name = eina_stringshare_add(eina_strbuf_string_get(buf)); 777 def->base.name = eina_stringshare_add(eina_strbuf_string_get(buf));
778 def->base.c_name = make_c_name(def->base.name);
763 Eolian_Object *decl = _eolian_decl_get(ls, def->base.name); 779 Eolian_Object *decl = _eolian_decl_get(ls, def->base.name);
764 if (decl) 780 if (decl)
765 { 781 {
@@ -805,6 +821,7 @@ tags_done:
805 FILL_BASE(def->base, ls, ls->line_number, ls->column, VARIABLE); 821 FILL_BASE(def->base, ls, ls->line_number, ls->column, VARIABLE);
806 parse_name(ls, buf); 822 parse_name(ls, buf);
807 def->base.name = eina_stringshare_add(eina_strbuf_string_get(buf)); 823 def->base.name = eina_stringshare_add(eina_strbuf_string_get(buf));
824 def->base.c_name = make_c_name(def->base.name);
808 Eolian_Object *decl = _eolian_decl_get(ls, def->base.name); 825 Eolian_Object *decl = _eolian_decl_get(ls, def->base.name);
809 if (decl) 826 if (decl)
810 { 827 {
@@ -1257,6 +1274,7 @@ parse_function_pointer(Eo_Lexer *ls)
1257tags_done: 1274tags_done:
1258 parse_name(ls, buf); 1275 parse_name(ls, buf);
1259 def->base.name = eina_stringshare_add(eina_strbuf_string_get(buf)); 1276 def->base.name = eina_stringshare_add(eina_strbuf_string_get(buf));
1277 def->base.c_name = make_c_name(def->base.name);
1260 eo_lexer_dtor_pop(ls); 1278 eo_lexer_dtor_pop(ls);
1261 1279
1262 meth = calloc(1, sizeof(Eolian_Function)); 1280 meth = calloc(1, sizeof(Eolian_Function));
@@ -2047,6 +2065,7 @@ parse_class(Eo_Lexer *ls, Eolian_Class_Type type)
2047 eo_lexer_syntax_error(ls, "class and file names differ"); 2065 eo_lexer_syntax_error(ls, "class and file names differ");
2048 } 2066 }
2049 ls->klass->base.name = eina_stringshare_add(eina_strbuf_string_get(buf)); 2067 ls->klass->base.name = eina_stringshare_add(eina_strbuf_string_get(buf));
2068 ls->klass->base.c_name = make_c_name(ls->klass->base.name);
2050 Eolian_Object *decl = _eolian_decl_get(ls, ls->klass->base.name); 2069 Eolian_Object *decl = _eolian_decl_get(ls, ls->klass->base.name);
2051 if (decl) 2070 if (decl)
2052 { 2071 {
@@ -2246,6 +2265,7 @@ postparams:
2246 eo_lexer_dtor_pop(ls); 2265 eo_lexer_dtor_pop(ls);
2247 } 2266 }
2248 def->base.name = name; 2267 def->base.name = name;
2268 def->base.c_name = make_c_name(name);
2249 eo_lexer_get(ls); 2269 eo_lexer_get(ls);
2250 FILL_DOC(ls, def, doc); 2270 FILL_DOC(ls, def, doc);
2251 FILL_BASE(def->base, ls, line, col, TYPEDECL); 2271 FILL_BASE(def->base, ls, line, col, TYPEDECL);
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index 194ac064a2..93e833e9a5 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -60,6 +60,13 @@ eolian_object_name_get(const Eolian_Object *obj)
60 return obj->name; 60 return obj->name;
61} 61}
62 62
63EAPI const char *
64eolian_object_c_name_get(const Eolian_Object *obj)
65{
66 if (!obj) return NULL;
67 return obj->c_name;
68}
69
63typedef struct _Eolian_Namespace_List 70typedef struct _Eolian_Namespace_List
64{ 71{
65 Eina_Iterator itr; 72 Eina_Iterator itr;
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index baf2fde640..f2dceba007 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -85,6 +85,7 @@ struct _Eolian_Object
85 Eolian_Unit *unit; 85 Eolian_Unit *unit;
86 Eina_Stringshare *file; 86 Eina_Stringshare *file;
87 Eina_Stringshare *name; 87 Eina_Stringshare *name;
88 Eina_Stringshare *c_name;
88 int line; 89 int line;
89 int column; 90 int column;
90 int refcount; 91 int refcount;
diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py
index 84e3f480ed..502c658971 100644
--- a/src/scripts/pyolian/eolian.py
+++ b/src/scripts/pyolian/eolian.py
@@ -636,8 +636,8 @@ class Class(Object):
636 return "<eolian.Class '{0.name}', {0.type!s}>".format(self) 636 return "<eolian.Class '{0.name}', {0.type!s}>".format(self)
637 637
638 @cached_property 638 @cached_property
639 def c_name(self): 639 def c_macro(self):
640 s = lib.eolian_class_c_name_get(self) 640 s = lib.eolian_class_c_macro_get(self)
641 ret = _str_to_py(s) 641 ret = _str_to_py(s)
642 lib.eina_stringshare_del(c_void_p(s)) 642 lib.eina_stringshare_del(c_void_p(s))
643 return ret 643 return ret
diff --git a/src/scripts/pyolian/eolian_lib.py b/src/scripts/pyolian/eolian_lib.py
index 6e9f9cb1a6..655684b66b 100644
--- a/src/scripts/pyolian/eolian_lib.py
+++ b/src/scripts/pyolian/eolian_lib.py
@@ -306,9 +306,9 @@ lib.eolian_class_dtor_enable_get.restype = c_bool
306lib.eolian_class_c_get_function_name_get.argtypes = (c_void_p,) 306lib.eolian_class_c_get_function_name_get.argtypes = (c_void_p,)
307lib.eolian_class_c_get_function_name_get.restype = c_void_p # Stringshare TO BE FREED 307lib.eolian_class_c_get_function_name_get.restype = c_void_p # Stringshare TO BE FREED
308 308
309# EAPI Eina_Stringshare *eolian_class_c_name_get(const Eolian_Class *klass); 309# EAPI Eina_Stringshare *eolian_class_c_macro_get(const Eolian_Class *klass);
310lib.eolian_class_c_name_get.argtypes = (c_void_p,) 310lib.eolian_class_c_macro_get.argtypes = (c_void_p,)
311lib.eolian_class_c_name_get.restype = c_void_p # Stringshare TO BE FREED 311lib.eolian_class_c_macro_get.restype = c_void_p # Stringshare TO BE FREED
312 312
313# EAPI Eina_Stringshare *eolian_class_c_data_type_get(const Eolian_Class *klass); 313# EAPI Eina_Stringshare *eolian_class_c_data_type_get(const Eolian_Class *klass);
314lib.eolian_class_c_data_type_get.argtypes = (c_void_p,) 314lib.eolian_class_c_data_type_get.argtypes = (c_void_p,)
diff --git a/src/scripts/pyolian/test_eolian.py b/src/scripts/pyolian/test_eolian.py
index 990fcfc6c9..b394c502cf 100755
--- a/src/scripts/pyolian/test_eolian.py
+++ b/src/scripts/pyolian/test_eolian.py
@@ -333,7 +333,7 @@ class TestEolianClass(unittest.TestCase):
333 self.assertFalse(cls.ctor_enable) 333 self.assertFalse(cls.ctor_enable)
334 self.assertFalse(cls.dtor_enable) 334 self.assertFalse(cls.dtor_enable)
335 self.assertEqual(cls.c_get_function_name, 'efl_loop_timer_class_get') 335 self.assertEqual(cls.c_get_function_name, 'efl_loop_timer_class_get')
336 self.assertEqual(cls.c_name, 'EFL_LOOP_TIMER_CLASS') 336 self.assertEqual(cls.c_macro, 'EFL_LOOP_TIMER_CLASS')
337 self.assertEqual(cls.c_data_type, 'Efl_Loop_Timer_Data') 337 self.assertEqual(cls.c_data_type, 'Efl_Loop_Timer_Data')
338 self.assertEqual([f.name for f in cls.methods], ['reset','loop_reset','delay']) 338 self.assertEqual([f.name for f in cls.methods], ['reset','loop_reset','delay'])
339 self.assertEqual([f.name for f in cls.properties], ['interval','pending']) 339 self.assertEqual([f.name for f in cls.properties], ['interval','pending'])
diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c
index 60dc8f965d..5ac08b8cd2 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -575,9 +575,10 @@ EFL_START_TEST(eolian_simple_parsing)
575 eina_stringshare_del(string); 575 eina_stringshare_del(string);
576 576
577 /* c name */ 577 /* c name */
578 fail_if(!(string = eolian_class_c_name_get(class))); 578 fail_if(!(string = eolian_class_c_macro_get(class)));
579 fail_if(strcmp(string, "CLASS_SIMPLE_CLASS")); 579 fail_if(strcmp(string, "CLASS_SIMPLE_CLASS"));
580 eina_stringshare_del(string); 580 eina_stringshare_del(string);
581 fail_if(strcmp(eolian_class_c_name_get(class), "Class_Simple"));
581 582
582 /* Property */ 583 /* Property */
583 fail_if(!(fid = eolian_class_function_by_name_get(class, "a", EOLIAN_PROPERTY))); 584 fail_if(!(fid = eolian_class_function_by_name_get(class, "a", EOLIAN_PROPERTY)));