summaryrefslogtreecommitdiff
path: root/src/bin/eolian
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-08-22 16:56:41 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2014-08-22 16:56:41 +0100
commitb75014a02487221041563c8689a88820d7db9789 (patch)
treed6181f5a1cab4e011401d53f54ea87fafd61424d /src/bin/eolian
parent894c9a42dbcc2e3c6777092c55413295b486d814 (diff)
eolian: refactor the struct/enum field APIs
Diffstat (limited to 'src/bin/eolian')
-rw-r--r--src/bin/eolian/types_generator.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/bin/eolian/types_generator.c b/src/bin/eolian/types_generator.c
index 96481f6b02..acd8d5e06c 100644
--- a/src/bin/eolian/types_generator.c
+++ b/src/bin/eolian/types_generator.c
@@ -69,7 +69,7 @@ _type_generate(const Eolian_Type *tp, Eina_Bool in_typedef)
69 case EOLIAN_TYPE_STRUCT: 69 case EOLIAN_TYPE_STRUCT:
70 case EOLIAN_TYPE_STRUCT_OPAQUE: 70 case EOLIAN_TYPE_STRUCT_OPAQUE:
71 { 71 {
72 const char *member_name; 72 const Eolian_Struct_Type_Field *member;
73 char *name = _concat_name(tp); 73 char *name = _concat_name(tp);
74 if ((in_typedef && name) || tp_type == EOLIAN_TYPE_STRUCT_OPAQUE) 74 if ((in_typedef && name) || tp_type == EOLIAN_TYPE_STRUCT_OPAQUE)
75 { 75 {
@@ -79,15 +79,15 @@ _type_generate(const Eolian_Type *tp, Eina_Bool in_typedef)
79 } 79 }
80 eina_strbuf_append_printf(buf, "struct%s%s {\n", name?" ":"", name?name:""); 80 eina_strbuf_append_printf(buf, "struct%s%s {\n", name?" ":"", name?name:"");
81 free(name); 81 free(name);
82 Eina_Iterator *members = eolian_type_struct_field_names_get(tp); 82 Eina_Iterator *members = eolian_type_struct_fields_get(tp);
83 EINA_ITERATOR_FOREACH(members, member_name) 83 EINA_ITERATOR_FOREACH(members, member)
84 { 84 {
85 const char *desc = eolian_type_struct_field_description_get(tp, member_name); 85 const char *desc = eolian_type_struct_field_description_get(member);
86 const Eolian_Type *member = eolian_type_struct_field_get(tp, member_name); 86 const Eolian_Type *type = eolian_type_struct_field_type_get(member);
87 Eina_Stringshare *c_type = eolian_type_c_type_get(member); 87 Eina_Stringshare *c_type = eolian_type_c_type_get(type);
88 eina_strbuf_append_printf(buf, " %s%s%s;", 88 eina_strbuf_append_printf(buf, " %s%s%s;",
89 c_type, strchr(c_type, '*')?"":" ", 89 c_type, strchr(c_type, '*')?"":" ",
90 member_name); 90 eolian_type_struct_field_name_get(member));
91 if (desc) eina_strbuf_append_printf(buf, " /** %s */", desc); 91 if (desc) eina_strbuf_append_printf(buf, " /** %s */", desc);
92 eina_strbuf_append(buf, "\n"); 92 eina_strbuf_append(buf, "\n");
93 } 93 }
@@ -97,7 +97,7 @@ _type_generate(const Eolian_Type *tp, Eina_Bool in_typedef)
97 } 97 }
98 case EOLIAN_TYPE_ENUM: 98 case EOLIAN_TYPE_ENUM:
99 { 99 {
100 const char *member_name; 100 const Eolian_Enum_Type_Field *member;
101 char *name = _concat_name(tp); 101 char *name = _concat_name(tp);
102 if (in_typedef) 102 if (in_typedef)
103 { 103 {
@@ -115,28 +115,28 @@ _type_generate(const Eolian_Type *tp, Eina_Bool in_typedef)
115 else 115 else
116 pre = name; 116 pre = name;
117 eina_str_toupper(&pre); 117 eina_str_toupper(&pre);
118 Eina_Iterator *members = eolian_type_enum_field_names_get(tp); 118 Eina_Iterator *members = eolian_type_enum_fields_get(tp);
119 Eina_Bool next = eina_iterator_next(members, (void**)&member_name); 119 Eina_Bool next = eina_iterator_next(members, (void**)&member);
120 Eina_Strbuf *membuf = eina_strbuf_new(); 120 Eina_Strbuf *membuf = eina_strbuf_new();
121 while (next) 121 while (next)
122 { 122 {
123 const char *desc = eolian_type_enum_field_description_get(tp, member_name); 123 const char *desc = eolian_type_enum_field_description_get(member);
124 const Eolian_Expression *member = eolian_type_enum_field_get(tp, member_name); 124 const Eolian_Expression *value = eolian_type_enum_field_value_get(member);
125 char *memb_u = strdup(member_name); 125 char *memb_u = strdup(eolian_type_enum_field_name_get(member));
126 eina_str_toupper(&memb_u); 126 eina_str_toupper(&memb_u);
127 eina_strbuf_reset(membuf); 127 eina_strbuf_reset(membuf);
128 eina_strbuf_append(membuf, pre); 128 eina_strbuf_append(membuf, pre);
129 eina_strbuf_append_char(membuf, '_'); 129 eina_strbuf_append_char(membuf, '_');
130 eina_strbuf_append(membuf, memb_u); 130 eina_strbuf_append(membuf, memb_u);
131 free(memb_u); 131 free(memb_u);
132 if (!member) 132 if (!value)
133 eina_strbuf_append_printf(buf, " %s", eina_strbuf_string_get(membuf)); 133 eina_strbuf_append_printf(buf, " %s", eina_strbuf_string_get(membuf));
134 else 134 else
135 { 135 {
136 Eolian_Value val = eolian_expression_eval(member, EOLIAN_MASK_INT); 136 Eolian_Value val = eolian_expression_eval(value, EOLIAN_MASK_INT);
137 const char *lit = eolian_expression_value_to_literal(&val); 137 const char *lit = eolian_expression_value_to_literal(&val);
138 eina_strbuf_append_printf(buf, " %s = %s", eina_strbuf_string_get(membuf), lit); 138 eina_strbuf_append_printf(buf, " %s = %s", eina_strbuf_string_get(membuf), lit);
139 const char *exp = eolian_expression_serialize(member); 139 const char *exp = eolian_expression_serialize(value);
140 if (exp && strcmp(lit, exp)) 140 if (exp && strcmp(lit, exp))
141 { 141 {
142 eina_strbuf_append_printf(buf, " /* %s */", exp); 142 eina_strbuf_append_printf(buf, " /* %s */", exp);
@@ -144,7 +144,7 @@ _type_generate(const Eolian_Type *tp, Eina_Bool in_typedef)
144 } 144 }
145 eina_stringshare_del(lit); 145 eina_stringshare_del(lit);
146 } 146 }
147 next = eina_iterator_next(members, (void**)&member_name); 147 next = eina_iterator_next(members, (void**)&member);
148 if (next) 148 if (next)
149 eina_strbuf_append(buf, ","); 149 eina_strbuf_append(buf, ",");
150 if (desc) eina_strbuf_append_printf(buf, " /** %s */", desc); 150 if (desc) eina_strbuf_append_printf(buf, " /** %s */", desc);