static Eina_Bool _get_impl_func(Eolian_Class *cl, Eolian_Implement *impl, Eolian_Function_Type ftype, Eolian_Function **foo_id) { size_t cllen = strlen(cl->full_name); size_t imlen = strlen(impl->full_name); const char *imstr = impl->full_name; *foo_id = NULL; if (imstr[0] == '.') ++imstr; else if ((imlen > (cllen + 1)) && (*(imstr + cllen) == '.') && !strncmp(imstr, cl->full_name, cllen)) imstr += cllen + 1; else return EINA_TRUE; if (strchr(imstr, '.')) return EINA_FALSE; impl->klass = cl; *foo_id = (Eolian_Function*)eolian_class_function_get_by_name(cl, imstr, ftype); impl->foo_id = *foo_id; return !!*foo_id; }
static Eina_Bool _validate_ref(const char *ref, const Eolian_Object *info) { if (eolian_declaration_get_by_name(ref)) return EINA_TRUE; const char *suffix = strrchr(ref, '.'); if (!suffix) goto failed; Eina_Stringshare *base = eina_stringshare_add_length(ref, suffix - ref); const Eolian_Type *tp = eolian_type_struct_get_by_name(base); if (tp) { eina_stringshare_del(base); if (!eolian_type_struct_field_get(tp, suffix + 1)) goto failed; return EINA_TRUE; } tp = eolian_type_enum_get_by_name(base); if (tp) { eina_stringshare_del(base); if (!eolian_type_enum_field_get(tp, suffix + 1)) goto failed; return EINA_TRUE; } const Eolian_Class *cl = eolian_class_get_by_name(base); if (cl) { eina_stringshare_del(base); if (!eolian_class_function_get_by_name(cl, suffix + 1, EOLIAN_UNRESOLVED)) goto failed; return EINA_TRUE; } Eolian_Function_Type ftype = EOLIAN_UNRESOLVED; if (!strcmp(suffix, ".get")) ftype = EOLIAN_PROP_GET; else if (!strcmp(suffix, ".set")) ftype = EOLIAN_PROP_SET; const char *meth; if (ftype != EOLIAN_UNRESOLVED) { eina_stringshare_del(base); meth = suffix - 1; while ((meth != ref) && (*meth != '.')) --meth; if (meth == ref) goto failed; base = eina_stringshare_add_length(ref, meth - ref); cl = eolian_class_get_by_name(base); eina_stringshare_del(base); } if (!cl) goto failed; char *ameth = strndup(meth + 1, suffix - meth - 1); const Eolian_Function *fn = eolian_class_function_get_by_name(cl, ameth, ftype); free(ameth); if (!fn) goto failed; return EINA_TRUE; failed: fprintf(stderr, "eolian:%s:%d:%d: failed validating reference '%s'\n", info->file, info->line, info->column, ref); return EINA_FALSE; }
static Eina_Bool _db_fill_implement(Eolian_Class *cl, Eolian_Implement *impl) { const char *impl_name = impl->full_name; Eolian_Function *foo_id; Eolian_Function_Type ftype = EOLIAN_UNRESOLVED; if (impl->is_prop_get) ftype = EOLIAN_PROP_GET; else if (impl->is_prop_set) ftype = EOLIAN_PROP_SET; if (impl->is_virtual) { foo_id = (Eolian_Function*)eolian_class_function_get_by_name(cl, impl_name, ftype); if (!foo_id) return _func_error(cl, impl); if (impl->is_prop_set) foo_id->set_virtual_pure = EINA_TRUE; else foo_id->get_virtual_pure = EINA_TRUE; impl->full_name = eina_stringshare_printf("%s.%s", cl->full_name, impl_name); eina_stringshare_del(impl_name); impl_name = impl->full_name; _write_impl(foo_id, impl); } else if (impl->is_auto) { if (!_get_impl_func(cl, impl, ftype, &foo_id)) return _func_error(cl, impl); if (!foo_id) goto pasttags; if (impl->is_prop_set) foo_id->set_auto = EINA_TRUE; else foo_id->get_auto = EINA_TRUE; _write_impl(foo_id, impl); } else if (impl->is_empty) { if (!_get_impl_func(cl, impl, ftype, &foo_id)) return _func_error(cl, impl); if (!foo_id) goto pasttags; if (impl->is_prop_set) foo_id->set_empty = EINA_TRUE; else foo_id->get_empty = EINA_TRUE; _write_impl(foo_id, impl); } else if (!_get_impl_func(cl, impl, ftype, &foo_id)) return _func_error(cl, impl); pasttags: if (impl_name[0] == '.') { impl->full_name = eina_stringshare_printf("%s%s", cl->full_name, impl_name); eina_stringshare_del(impl_name); } return EINA_TRUE; }
static void _generate_ref(const char *refn, Eina_Strbuf *wbuf, Eina_Bool use_legacy) { const Eolian_Declaration *decl = eolian_declaration_get_by_name(refn); if (decl) { char *n = strdup(eolian_declaration_name_get(decl)); char *p = n; while ((p = strchr(p, '.'))) *p = '_'; eina_strbuf_append(wbuf, n); free(n); return; } /* not a plain declaration, so it must be struct/enum field or func */ const char *sfx = strrchr(refn, '.'); if (!sfx) goto noref; Eina_Stringshare *bname = eina_stringshare_add_length(refn, sfx - refn); const Eolian_Type *tp = eolian_type_struct_get_by_name(bname); if (tp) { if (!eolian_type_struct_field_get(tp, sfx + 1)) { eina_stringshare_del(bname); goto noref; } _generate_ref(bname, wbuf, use_legacy); eina_strbuf_append(wbuf, sfx); eina_stringshare_del(bname); return; } tp = eolian_type_enum_get_by_name(bname); if (tp) { const Eolian_Enum_Type_Field *efl = eolian_type_enum_field_get(tp, sfx + 1); if (!efl) { eina_stringshare_del(bname); goto noref; } _generate_ref(bname, wbuf, use_legacy); Eina_Stringshare *str = eolian_type_enum_field_c_name_get(efl); eina_strbuf_append_char(wbuf, '.'); eina_strbuf_append(wbuf, str); eina_stringshare_del(str); eina_stringshare_del(bname); return; } const Eolian_Class *cl = eolian_class_get_by_name(bname); const Eolian_Function *fn = NULL; Eolian_Function_Type ftype = EOLIAN_UNRESOLVED; if (!cl) { const char *mname; if (!strcmp(sfx, ".get")) ftype = EOLIAN_PROP_GET; else if (!strcmp(sfx, ".set")) ftype = EOLIAN_PROP_SET; if (ftype != EOLIAN_UNRESOLVED) { eina_stringshare_del(bname); mname = sfx - 1; while ((mname != refn) && (*mname != '.')) --mname; if (mname == refn) goto noref; bname = eina_stringshare_add_length(refn, mname - refn); cl = eolian_class_get_by_name(bname); eina_stringshare_del(bname); } if (cl) { char *meth = strndup(mname + 1, sfx - mname - 1); fn = eolian_class_function_get_by_name(cl, meth, ftype); if (ftype == EOLIAN_UNRESOLVED) ftype = eolian_function_type_get(fn); free(meth); } } else { fn = eolian_class_function_get_by_name(cl, sfx + 1, ftype); ftype = eolian_function_type_get(fn); } if (!fn) goto noref; Eina_Stringshare *fcn = eolian_function_full_c_name_get(fn, ftype, use_legacy); if (!fcn) goto noref; eina_strbuf_append(wbuf, fcn); eina_stringshare_del(fcn); return; noref: eina_strbuf_append(wbuf, refn); }