}
EAPI const Eolian_Class *
-eolian_class_get_by_name(const Eolian_Unit *unit EINA_UNUSED,
- const char *class_name)
+eolian_class_get_by_name(const Eolian_Unit *unit, const char *class_name)
{
- if (!_state) return NULL;
+ if (!unit) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(class_name);
- Eolian_Class *cl = eina_hash_find(_state->unit.classes, shr);
+ Eolian_Class *cl = eina_hash_find(unit->state->unit.classes, shr);
eina_stringshare_del(shr);
return cl;
}
EAPI const Eolian_Class *
-eolian_class_get_by_file(const Eolian_Unit *unit EINA_UNUSED,
- const char *file_name)
+eolian_class_get_by_file(const Eolian_Unit *unit, const char *file_name)
{
- if (!_state) return NULL;
+ if (!unit) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(file_name);
- Eolian_Class *cl = eina_hash_find(_state->classes_f, shr);
+ Eolian_Class *cl = eina_hash_find(unit->state->classes_f, shr);
eina_stringshare_del(shr);
return cl;
}
}
EAPI Eina_Iterator *
-eolian_all_classes_get(const Eolian_Unit *unit EINA_UNUSED)
+eolian_all_classes_get(const Eolian_Unit *unit)
{
- return (_state ? eina_hash_iterator_data_new(_state->unit.classes) : NULL);
+ return (unit ? eina_hash_iterator_data_new(unit->state->unit.classes) : NULL);
}
EAPI const Eolian_Documentation *
}
void
-database_type_add(Eolian_Typedecl *def)
+database_type_add(Eolian *state, Eolian_Typedecl *def)
{
- eina_hash_set(_state->unit.aliases, def->full_name, def);
- eina_hash_set(_state->aliases_f, def->base.file, eina_list_append
- ((Eina_List*)eina_hash_find(_state->aliases_f, def->base.file),
+ eina_hash_set(state->unit.aliases, def->full_name, def);
+ eina_hash_set(state->aliases_f, def->base.file, eina_list_append
+ ((Eina_List*)eina_hash_find(state->aliases_f, def->base.file),
def));
database_decl_add(def->full_name, EOLIAN_DECL_ALIAS, def->base.file, def);
}
void
-database_struct_add(Eolian_Typedecl *tp)
+database_struct_add(Eolian *state, Eolian_Typedecl *tp)
{
- eina_hash_set(_state->unit.structs, tp->full_name, tp);
- eina_hash_set(_state->structs_f, tp->base.file, eina_list_append
- ((Eina_List*)eina_hash_find(_state->structs_f, tp->base.file), tp));
+ eina_hash_set(state->unit.structs, tp->full_name, tp);
+ eina_hash_set(state->structs_f, tp->base.file, eina_list_append
+ ((Eina_List*)eina_hash_find(state->structs_f, tp->base.file), tp));
database_decl_add(tp->full_name, EOLIAN_DECL_STRUCT, tp->base.file, tp);
}
void
-database_enum_add(Eolian_Typedecl *tp)
+database_enum_add(Eolian *state, Eolian_Typedecl *tp)
{
- eina_hash_set(_state->unit.enums, tp->full_name, tp);
- eina_hash_set(_state->enums_f, tp->base.file, eina_list_append
- ((Eina_List*)eina_hash_find(_state->enums_f, tp->base.file), tp));
+ eina_hash_set(state->unit.enums, tp->full_name, tp);
+ eina_hash_set(state->enums_f, tp->base.file, eina_list_append
+ ((Eina_List*)eina_hash_find(state->enums_f, tp->base.file), tp));
database_decl_add(tp->full_name, EOLIAN_DECL_ENUM, tp->base.file, tp);
}
#include "eo_lexer.h"
EAPI const Eolian_Typedecl *
-eolian_typedecl_alias_get_by_name(const Eolian_Unit *unit EINA_UNUSED,
- const char *name)
+eolian_typedecl_alias_get_by_name(const Eolian_Unit *unit, const char *name)
{
- if (!_state) return NULL;
+ if (!unit) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(name);
- Eolian_Typedecl *tp = eina_hash_find(_state->unit.aliases, shr);
+ Eolian_Typedecl *tp = eina_hash_find(unit->state->unit.aliases, shr);
eina_stringshare_del(shr);
if (!tp) return NULL;
return tp;
}
EAPI const Eolian_Typedecl *
-eolian_typedecl_struct_get_by_name(const Eolian_Unit *unit EINA_UNUSED,
- const char *name)
+eolian_typedecl_struct_get_by_name(const Eolian_Unit *unit, const char *name)
{
- if (!_state) return NULL;
+ if (!unit) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(name);
- Eolian_Typedecl *tp = eina_hash_find(_state->unit.structs, shr);
+ Eolian_Typedecl *tp = eina_hash_find(unit->state->unit.structs, shr);
eina_stringshare_del(shr);
if (!tp) return NULL;
return tp;
}
EAPI const Eolian_Typedecl *
-eolian_typedecl_enum_get_by_name(const Eolian_Unit *unit EINA_UNUSED,
- const char *name)
+eolian_typedecl_enum_get_by_name(const Eolian_Unit *unit, const char *name)
{
- if (!_state) return NULL;
+ if (!unit) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(name);
- Eolian_Typedecl *tp = eina_hash_find(_state->unit.enums, shr);
+ Eolian_Typedecl *tp = eina_hash_find(unit->state->unit.enums, shr);
eina_stringshare_del(shr);
if (!tp) return NULL;
return tp;
}
EAPI Eina_Iterator *
-eolian_typedecl_aliases_get_by_file(const Eolian_Unit *unit EINA_UNUSED,
- const char *fname)
+eolian_typedecl_aliases_get_by_file(const Eolian_Unit *unit, const char *fname)
{
- if (!_state) return NULL;
+ if (!unit) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(fname);
- Eina_List *l = eina_hash_find(_state->aliases_f, shr);
+ Eina_List *l = eina_hash_find(unit->state->aliases_f, shr);
eina_stringshare_del(shr);
if (!l) return NULL;
return eina_list_iterator_new(l);
}
EAPI Eina_Iterator *
-eolian_typedecl_structs_get_by_file(const Eolian_Unit *unit EINA_UNUSED,
- const char *fname)
+eolian_typedecl_structs_get_by_file(const Eolian_Unit *unit, const char *fname)
{
- if (!_state) return NULL;
+ if (!unit) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(fname);
- Eina_List *l = eina_hash_find(_state->structs_f, shr);
+ Eina_List *l = eina_hash_find(unit->state->structs_f, shr);
eina_stringshare_del(shr);
if (!l) return NULL;
return eina_list_iterator_new(l);
}
EAPI Eina_Iterator *
-eolian_typedecl_enums_get_by_file(const Eolian_Unit *unit EINA_UNUSED,
- const char *fname)
+eolian_typedecl_enums_get_by_file(const Eolian_Unit *unit, const char *fname)
{
- if (!_state) return NULL;
+ if (!unit) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(fname);
- Eina_List *l = eina_hash_find(_state->enums_f, shr);
+ Eina_List *l = eina_hash_find(unit->state->enums_f, shr);
eina_stringshare_del(shr);
if (!l) return NULL;
return eina_list_iterator_new(l);
}
EAPI Eina_Iterator *
-eolian_typedecl_all_aliases_get(const Eolian_Unit *unit EINA_UNUSED)
+eolian_typedecl_all_aliases_get(const Eolian_Unit *unit)
{
- return (_state ? eina_hash_iterator_data_new(_state->unit.aliases) : NULL);
+ return (unit ? eina_hash_iterator_data_new(unit->state->unit.aliases) : NULL);
}
EAPI Eina_Iterator *
-eolian_typedecl_all_structs_get(const Eolian_Unit *unit EINA_UNUSED)
+eolian_typedecl_all_structs_get(const Eolian_Unit *unit)
{
- return (_state ? eina_hash_iterator_data_new(_state->unit.structs) : NULL);
+ return (unit ? eina_hash_iterator_data_new(unit->state->unit.structs) : NULL);
}
EAPI Eina_Iterator *
-eolian_typedecl_all_enums_get(const Eolian_Unit *unit EINA_UNUSED)
+eolian_typedecl_all_enums_get(const Eolian_Unit *unit)
{
- return (_state ? eina_hash_iterator_data_new(_state->unit.enums) : NULL);
+ return (unit ? eina_hash_iterator_data_new(unit->state->unit.enums) : NULL);
}
EAPI Eolian_Type_Type
}
Eina_Bool
-database_validate(const Eolian_Unit *src)
+database_validate(Eolian *state, const Eolian_Unit *src)
{
Eolian_Class *cl;
Cb_Ret rt = { src, EINA_TRUE };
- eina_hash_foreach(_state->unit.aliases, (Eina_Hash_Foreach)_typedecl_map_cb, &rt);
+ eina_hash_foreach(state->unit.aliases, (Eina_Hash_Foreach)_typedecl_map_cb, &rt);
if (!rt.succ)
return EINA_FALSE;
- eina_hash_foreach(_state->unit.structs, (Eina_Hash_Foreach)_typedecl_map_cb, &rt);
+ eina_hash_foreach(state->unit.structs, (Eina_Hash_Foreach)_typedecl_map_cb, &rt);
if (!rt.succ)
return EINA_FALSE;
- eina_hash_foreach(_state->unit.enums, (Eina_Hash_Foreach)_typedecl_map_cb, &rt);
+ eina_hash_foreach(state->unit.enums, (Eina_Hash_Foreach)_typedecl_map_cb, &rt);
if (!rt.succ)
return EINA_FALSE;
- eina_hash_foreach(_state->unit.globals, (Eina_Hash_Foreach)_var_map_cb, &rt);
+ eina_hash_foreach(state->unit.globals, (Eina_Hash_Foreach)_var_map_cb, &rt);
if (!rt.succ)
return EINA_FALSE;
- eina_hash_foreach(_state->unit.constants, (Eina_Hash_Foreach)_var_map_cb, &rt);
+ eina_hash_foreach(state->unit.constants, (Eina_Hash_Foreach)_var_map_cb, &rt);
if (!rt.succ)
return EINA_FALSE;
}
static void
-database_var_global_add(Eolian_Variable *var)
+database_var_global_add(Eolian *state, Eolian_Variable *var)
{
- eina_hash_set(_state->unit.globals, var->full_name, var);
- eina_hash_set(_state->globals_f, var->base.file, eina_list_append
- ((Eina_List*)eina_hash_find(_state->globals_f, var->base.file), var));
+ eina_hash_set(state->unit.globals, var->full_name, var);
+ eina_hash_set(state->globals_f, var->base.file, eina_list_append
+ ((Eina_List*)eina_hash_find(state->globals_f, var->base.file), var));
database_decl_add(var->full_name, EOLIAN_DECL_VAR, var->base.file, var);
}
static void
-database_var_constant_add(Eolian_Variable *var)
+database_var_constant_add(Eolian *state, Eolian_Variable *var)
{
- eina_hash_set(_state->unit.constants, var->full_name, var);
- eina_hash_set(_state->constants_f, var->base.file, eina_list_append
- ((Eina_List*)eina_hash_find(_state->constants_f, var->base.file), var));
+ eina_hash_set(state->unit.constants, var->full_name, var);
+ eina_hash_set(state->constants_f, var->base.file, eina_list_append
+ ((Eina_List*)eina_hash_find(state->constants_f, var->base.file), var));
database_decl_add(var->full_name, EOLIAN_DECL_VAR, var->base.file, var);
}
void
-database_var_add(Eolian_Variable *var)
+database_var_add(Eolian *state, Eolian_Variable *var)
{
if (var->type == EOLIAN_VAR_GLOBAL)
- database_var_global_add(var);
+ database_var_global_add(state, var);
else
- database_var_constant_add(var);
+ database_var_constant_add(state, var);
}
#include "eolian_database.h"
EAPI const Eolian_Variable *
-eolian_variable_global_get_by_name(const Eolian_Unit *unit EINA_UNUSED,
- const char *name)
+eolian_variable_global_get_by_name(const Eolian_Unit *unit, const char *name)
{
- if (!_state) return NULL;
+ if (!unit) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(name);
- Eolian_Variable *v = eina_hash_find(_state->unit.globals, shr);
+ Eolian_Variable *v = eina_hash_find(unit->state->unit.globals, shr);
eina_stringshare_del(shr);
return v;
}
EAPI const Eolian_Variable *
-eolian_variable_constant_get_by_name(const Eolian_Unit *unit EINA_UNUSED,
- const char *name)
+eolian_variable_constant_get_by_name(const Eolian_Unit *unit, const char *name)
{
- if (!_state) return NULL;
+ if (!unit) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(name);
- Eolian_Variable *v = eina_hash_find(_state->unit.constants, shr);
+ Eolian_Variable *v = eina_hash_find(unit->state->unit.constants, shr);
eina_stringshare_del(shr);
return v;
}
EAPI Eina_Iterator *
-eolian_variable_globals_get_by_file(const Eolian_Unit *unit EINA_UNUSED,
- const char *fname)
+eolian_variable_globals_get_by_file(const Eolian_Unit *unit, const char *fname)
{
- if (!_state) return NULL;
+ if (!unit) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(fname);
- Eina_List *l = eina_hash_find(_state->globals_f, shr);
+ Eina_List *l = eina_hash_find(unit->state->globals_f, shr);
eina_stringshare_del(shr);
if (!l) return NULL;
return eina_list_iterator_new(l);
}
EAPI Eina_Iterator *
-eolian_variable_constants_get_by_file(const Eolian_Unit *unit EINA_UNUSED,
+eolian_variable_constants_get_by_file(const Eolian_Unit *unit,
const char *fname)
{
- if (!_state) return NULL;
+ if (!unit) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(fname);
- Eina_List *l = eina_hash_find(_state->constants_f, shr);
+ Eina_List *l = eina_hash_find(unit->state->constants_f, shr);
eina_stringshare_del(shr);
if (!l) return NULL;
return eina_list_iterator_new(l);
}
EAPI Eina_Iterator *
-eolian_variable_all_constants_get(const Eolian_Unit *unit EINA_UNUSED)
+eolian_variable_all_constants_get(const Eolian_Unit *unit)
{
- return (_state ? eina_hash_iterator_data_new(_state->unit.constants) : NULL);
+ return (unit ? eina_hash_iterator_data_new(unit->state->unit.constants) : NULL);
}
EAPI Eina_Iterator *
-eolian_variable_all_globals_get(const Eolian_Unit *unit EINA_UNUSED)
+eolian_variable_all_globals_get(const Eolian_Unit *unit)
{
- return (_state ? eina_hash_iterator_data_new(_state->unit.globals) : NULL);
+ return (unit ? eina_hash_iterator_data_new(unit->state->unit.globals) : NULL);
}
EAPI Eolian_Variable_Type
};
static void
-doc_ref_class(const char *cname)
+doc_ref_class(Eo_Lexer *ls, const char *cname)
{
size_t clen = strlen(cname);
char *buf = alloca(clen + 4);
*p = tolower(*p);
}
memcpy(buf + clen, ".eo", sizeof(".eo"));
- const char *eop = eina_hash_find(_state->filenames_eo, buf);
+ const char *eop = eina_hash_find(ls->state->filenames_eo, buf);
if (!eop)
return;
eina_hash_set(_defereos, buf, eop);
buf[rlen] = '\0';
/* actual full class name */
- doc_ref_class(buf);
+ doc_ref_class(ls, buf);
/* method name at the end */
char *end = strrchr(buf, '.');
if (!end)
return;
*end = '\0';
- doc_ref_class(buf);
+ doc_ref_class(ls, buf);
/* .get or .set at the end, handle possible property */
if (strcmp(end + 1, "get") && strcmp(end + 1, "set"))
if (!end)
return;
*end = '\0';
- doc_ref_class(buf);
+ doc_ref_class(ls, buf);
}
static int
}
static void
-eo_lexer_set_input(Eo_Lexer *ls, const char *source)
+eo_lexer_set_input(Eo_Lexer *ls, Eolian *state, const char *source)
{
Eina_File *f = eina_file_open(source, EINA_FALSE);
if (!f)
longjmp(ls->err_jmp, EINA_TRUE);
}
ls->lookahead.token = -1;
+ ls->state = state;
ls->buff = eina_strbuf_new();
ls->handle = f;
ls->stream = eina_file_map_all(f, EINA_FILE_RANDOM);
next_char(ls);
Eolian_Unit *ncunit = calloc(1, sizeof(Eolian_Unit));
- database_unit_init(ncunit, ls->filename);
+ database_unit_init(state, ncunit, ls->filename);
eina_hash_add(_units, ls->filename, ncunit);
}
}
Eo_Lexer *
-eo_lexer_new(const char *source)
+eo_lexer_new(Eolian *state, const char *source)
{
volatile Eo_Lexer *ls = calloc(1, sizeof(Eo_Lexer));
if (!setjmp(((Eo_Lexer *)(ls))->err_jmp))
{
- eo_lexer_set_input((Eo_Lexer *) ls, source);
+ eo_lexer_set_input((Eo_Lexer *) ls, state, source);
return (Eo_Lexer *) ls;
}
eo_lexer_free((Eo_Lexer *) ls);
/* points to the current line being lexed, used by error messages to
* display the current line with a caret at the respective column */
const char *stream_line;
+ /* a pointer to the state this lexer belongs to */
+ Eolian *state;
/* this is jumped to when an error happens */
jmp_buf err_jmp;
int eo_lexer_init (void);
int eo_lexer_shutdown (void);
-Eo_Lexer *eo_lexer_new (const char *source);
+Eo_Lexer *eo_lexer_new (Eolian *state, const char *source);
void eo_lexer_free (Eo_Lexer *ls);
/* gets a regular token, singlechar or one of TOK_something */
int eo_lexer_get (Eo_Lexer *ls);
}
check_match(ls, '}', '{', bline, bcolumn);
FILL_BASE(def->base, ls, line, column);
- if (name) database_struct_add(def);
+ if (name) database_struct_add(ls->state, def);
return def;
}
}
check_match(ls, '}', '{', bline, bcolumn);
FILL_BASE(def->base, ls, line, column);
- if (name) database_enum_add(def);
+ if (name) database_enum_add(ls->state, def);
return def;
}
if (eina_hash_find(_parsingeos, fname))
return NULL;
Eolian_Class *cl = NULL;
- if (!eo_parser_database_fill(fname, EINA_FALSE, &cl) || !cl)
+ if (!eo_parser_database_fill(ls->state, fname, EINA_FALSE, &cl) || !cl)
{
char buf[PATH_MAX];
eo_lexer_context_restore(ls);
fnm = database_class_to_filename(nm);
if (!compare_class_file(bnm, fnm))
{
- const char *fname = eina_hash_find(_state->filenames_eo, fnm);
+ const char *fname = eina_hash_find(ls->state->filenames_eo, fnm);
eina_stringshare_del(bnm);
free(fnm);
if (fname)
if (!compare_class_file(bnm, fnm))
{
Eolian_Class *dep = NULL;
- const char *fname = eina_hash_find(_state->filenames_eo, fnm);
+ const char *fname = eina_hash_find(ls->state->filenames_eo, fnm);
eina_stringshare_del(bnm);
free(fnm);
if (fname)
eo_lexer_syntax_error(ls, ebuf);
return; /* unreachable (longjmp above), make static analysis shut up */
}
- fname = eina_hash_find(_state->filenames_eo, fnm);
+ fname = eina_hash_find(ls->state->filenames_eo, fnm);
free(fnm);
if (!fname)
{
check(ls, TOK_VALUE);
eina_strbuf_append(buf, ls->t.value.s);
eina_strbuf_append(buf, ".eot");
- if (!(found = eina_hash_find(_state->filenames_eot, eina_strbuf_string_get(buf))))
+ if (!(found = eina_hash_find(ls->state->filenames_eot, eina_strbuf_string_get(buf))))
{
size_t buflen = eina_strbuf_length_get(buf);
eina_strbuf_remove(buf, buflen - 1, buflen);
- if (!(found = eina_hash_find(_state->filenames_eo, eina_strbuf_string_get(buf))))
+ if (!(found = eina_hash_find(ls->state->filenames_eo, eina_strbuf_string_get(buf))))
{
pop_strbuf(ls);
snprintf(errbuf, sizeof(errbuf),
}
case KW_type:
{
- database_type_add(parse_typedef(ls));
+ database_type_add(ls->state, parse_typedef(ls));
pop_typedecl(ls);
break;
}
case KW_function:
{
- database_type_add(parse_function_pointer(ls));
+ database_type_add(ls->state, parse_function_pointer(ls));
pop_typedecl(ls);
break;
}
case KW_const:
case KW_var:
{
- database_var_add(parse_variable(ls, ls->t.kw == KW_var));
+ database_var_add(ls->state, parse_variable(ls, ls->t.kw == KW_var));
eolian_object_ref(&ls->tmp.var->base);
ls->tmp.var = NULL;
break;
eo_lexer_get(ls);
FILL_DOC(ls, def, doc);
FILL_BASE(def->base, ls, line, col);
- database_struct_add(def);
+ database_struct_add(ls->state, def);
pop_typedecl(ls);
break;
}
}
Eina_Bool
-eo_parser_database_fill(const char *filename, Eina_Bool eot, Eolian_Class **fcl)
+eo_parser_database_fill(Eolian *state, const char *filename, Eina_Bool eot, Eolian_Class **fcl)
{
Eolian_Class *cl = eina_hash_find(_parsedeos, filename);
if (cl)
eina_hash_set(_parsingeos, filename, (void *)EINA_TRUE);
- Eo_Lexer *ls = eo_lexer_new(filename);
+ Eo_Lexer *ls = eo_lexer_new(state, filename);
if (!ls)
{
_eolian_log("unable to create lexer for file '%s'", filename);
if (!_db_fill_ctors(cl))
goto error;
- eina_hash_set(_state->unit.classes, cl->full_name, cl);
- eina_hash_set(_state->classes_f, cl->base.file, cl);
+ eina_hash_set(ls->state->unit.classes, cl->full_name, cl);
+ eina_hash_set(ls->state->classes_f, cl->base.file, cl);
eolian_object_ref(&cl->base);
if (fcl) *fcl = cl;
#include "eo_lexer.h"
-Eina_Bool eo_parser_database_fill(const char *filename, Eina_Bool eot, Eolian_Class **cl);
+Eina_Bool eo_parser_database_fill(Eolian *state, const char *filename, Eina_Bool eot, Eolian_Class **cl);
#endif /* __EO_PARSER_H__ */
\ No newline at end of file
static Eolian_Unit *_cunit = NULL;
-Eolian *_state = NULL;
-
static int _database_init_count = 0;
static void
_parsingeos = eina_hash_string_small_new(NULL);
_defereos = eina_hash_string_small_new(NULL);
_units = eina_hash_stringshared_new(EINA_FREE_CB(database_unit_del));
- _state = eolian_new();
return ++_database_init_count;
}
if (_database_init_count == 0)
{
- eolian_free(_state); _state = NULL;
eina_hash_free(_decls ); _decls = NULL;
eina_hash_free(_declsf ); _declsf = NULL;
eina_hash_free(_parsedeos ); _parsedeos = NULL;
}
void
-database_unit_init(Eolian_Unit *unit, Eina_Stringshare *fname)
+database_unit_init(Eolian *state, Eolian_Unit *unit, Eina_Stringshare *fname)
{
+ unit->state = state;
+
if (fname)
{
Eolian_Unit *ocunit = _cunit;
if (!state)
return NULL;
- database_unit_init(&state->unit, NULL);
+ database_unit_init(state, &state->unit, NULL);
state->filenames_eo = eina_hash_string_small_new(free);
state->filenames_eot = eina_hash_string_small_new(free);
static void
_scan_cb(const char *name, const char *path, void *data EINA_UNUSED)
{
+ Eolian *state = data;
Eina_Bool is_eo = eina_str_has_suffix(name, EO_SUFFIX);
if (!is_eo && !eina_str_has_suffix(name, EOT_SUFFIX)) return;
- eina_hash_add(is_eo ? _state->filenames_eo : _state->filenames_eot,
+ eina_hash_add(is_eo ? state->filenames_eo : state->filenames_eot,
eina_stringshare_add(name), join_path(path, name));
}
EAPI Eina_Bool
-eolian_directory_scan(Eolian *state EINA_UNUSED, const char *dir)
+eolian_directory_scan(Eolian *state, const char *dir)
{
- if (!dir) return EINA_FALSE;
- eina_file_dir_list(dir, EINA_TRUE, _scan_cb, NULL);
+ if (!dir || !state) return EINA_FALSE;
+ eina_file_dir_list(dir, EINA_TRUE, _scan_cb, state);
return EINA_TRUE;
}
}
static Eina_Bool
-_eolian_file_parse_nodep(const char *filepath)
+_eolian_file_parse_nodep(Eolian *state, const char *filepath)
{
Eina_Bool is_eo;
const char *eopath;
_eolian_log("file '%s' doesn't have a correct extension", filepath);
return EINA_FALSE;
}
- if (!(eopath = eina_hash_find(is_eo ? _state->filenames_eo : _state->filenames_eot, filepath)))
+ if (!(eopath = eina_hash_find(is_eo ? state->filenames_eo : state->filenames_eot, filepath)))
{
char *vpath = eina_file_path_sanitize(filepath);
- Eina_Bool ret = eo_parser_database_fill(vpath, !is_eo, NULL);
+ Eina_Bool ret = eo_parser_database_fill(state, vpath, !is_eo, NULL);
free(vpath);
return ret;
}
- return eo_parser_database_fill(eopath, !is_eo, NULL);
+ return eo_parser_database_fill(state, eopath, !is_eo, NULL);
}
static Eina_Bool
-_parse_deferred()
+_parse_deferred(Eolian *state)
{
Eina_Hash *defer = _defereos;
if (!defer || !eina_hash_population(defer))
const char *dep;
EINA_ITERATOR_FOREACH(itr, dep)
{
- if (!_eolian_file_parse_nodep(dep))
+ if (!_eolian_file_parse_nodep(state, dep))
{
eina_iterator_free(itr);
eina_hash_free_buckets(_defereos);
eina_iterator_free(itr);
eina_hash_free(defer);
/* in case more deps were queued in, parse them */
- return _parse_deferred();
+ return _parse_deferred(state);
}
-static Eolian_Unit unit_tmp;
-
EAPI const Eolian_Unit *
-eolian_file_parse(Eolian *state EINA_UNUSED, const char *filepath)
+eolian_file_parse(Eolian *state, const char *filepath)
{
- if (!_eolian_file_parse_nodep(filepath))
+ if (!_eolian_file_parse_nodep(state, filepath))
return NULL;
- if (!_parse_deferred())
+ if (!_parse_deferred(state))
return NULL;
/* FIXME: pass unit properly */
- if (!database_validate(NULL))
+ if (!database_validate(state, &state->unit))
return NULL;
- return &unit_tmp;
+ return &state->unit;
}
+typedef struct _Parse_Data
+{
+ Eolian *state;
+ Eina_Bool ret;
+} Parse_Data;
+
static Eina_Bool _tfile_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata)
{
- Eina_Bool *ret = fdata;
- if (*ret) *ret = eo_parser_database_fill(data, EINA_TRUE, NULL);
- if (*ret) *ret = _parse_deferred();
- return *ret;
+ Parse_Data *pd = fdata;
+ if (pd->ret) pd->ret = eo_parser_database_fill(pd->state, data, EINA_TRUE, NULL);
+ if (pd->ret) pd->ret = _parse_deferred(pd->state);
+ return pd->ret;
}
EAPI Eina_Bool
-eolian_all_eot_files_parse(Eolian *state EINA_UNUSED)
+eolian_all_eot_files_parse(Eolian *state)
{
- Eina_Bool ret = EINA_TRUE;
+ Parse_Data pd = { state, EINA_TRUE };
if (_database_init_count <= 0)
return EINA_FALSE;
- eina_hash_foreach(_state->filenames_eot, _tfile_parse, &ret);
+ eina_hash_foreach(state->filenames_eot, _tfile_parse, &pd);
/* FIXME: pass unit properly */
- if (ret && !database_validate(NULL))
+ if (pd.ret && !database_validate(state, &state->unit))
return EINA_FALSE;
- return ret;
+ return pd.ret;
}
static Eina_Bool _file_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata)
{
- Eina_Bool *ret = fdata;
- if (*ret) *ret = eo_parser_database_fill(data, EINA_FALSE, NULL);
- if (*ret) *ret = _parse_deferred();
- return *ret;
+ Parse_Data *pd = fdata;
+ if (pd->ret) pd->ret = eo_parser_database_fill(pd->state, data, EINA_FALSE, NULL);
+ if (pd->ret) pd->ret = _parse_deferred(pd->state);
+ return pd->ret;
}
EAPI Eina_Bool
-eolian_all_eo_files_parse(Eolian *state EINA_UNUSED)
+eolian_all_eo_files_parse(Eolian *state)
{
- Eina_Bool ret = EINA_TRUE;
+ Parse_Data pd = { state, EINA_TRUE };
if (_database_init_count <= 0)
return EINA_FALSE;
- eina_hash_foreach(_state->filenames_eo, _file_parse, &ret);
+ eina_hash_foreach(state->filenames_eo, _file_parse, &pd);
/* FIXME: pass unit properly */
- if (ret && !database_validate(NULL))
+ if (pd.ret && !database_validate(state, &state->unit))
return EINA_FALSE;
- return ret;
+ return pd.ret;
}
EAPI Eina_Iterator *
-eolian_all_eot_files_get(Eolian *state EINA_UNUSED)
+eolian_all_eot_files_get(Eolian *state)
{
- if (!_state) return NULL;
- return eina_hash_iterator_key_new(_state->filenames_eot);
+ if (!state) return NULL;
+ return eina_hash_iterator_key_new(state->filenames_eot);
}
EAPI Eina_Iterator *
-eolian_all_eo_files_get(Eolian *state EINA_UNUSED)
+eolian_all_eo_files_get(Eolian *state)
{
- if (!_state) return NULL;
- return eina_hash_iterator_key_new(_state->filenames_eo);
+ if (!state) return NULL;
+ return eina_hash_iterator_key_new(state->filenames_eo);
}
EAPI Eina_Iterator *
-eolian_all_eot_file_paths_get(Eolian *state EINA_UNUSED)
+eolian_all_eot_file_paths_get(Eolian *state)
{
- if (!_state) return NULL;
- return eina_hash_iterator_data_new(_state->filenames_eot);
+ if (!state) return NULL;
+ return eina_hash_iterator_data_new(state->filenames_eot);
}
EAPI Eina_Iterator *
-eolian_all_eo_file_paths_get(Eolian *state EINA_UNUSED)
+eolian_all_eo_file_paths_get(Eolian *state)
{
- if (!_state) return NULL;
- return eina_hash_iterator_data_new(_state->filenames_eo);
+ if (!state) return NULL;
+ return eina_hash_iterator_data_new(state->filenames_eo);
}
/* for deferred dependency parsing */
extern Eina_Hash *_defereos;
-/* TODO: remove */
-extern Eolian *_state;
-
struct _Eolian_Unit
{
+ Eolian *state;
Eolian_Unit *parent;
Eina_Hash *children;
Eina_Hash *classes;
int database_shutdown(void);
char *database_class_to_filename(const char *cname);
-Eina_Bool database_validate(const Eolian_Unit *src);
+Eina_Bool database_validate(Eolian *state, const Eolian_Unit *src);
void database_decl_add(Eina_Stringshare *name, Eolian_Declaration_Type type,
Eina_Stringshare *file, void *ptr);
void database_doc_del(Eolian_Documentation *doc);
-void database_unit_init(Eolian_Unit *unit, Eina_Stringshare *fname);
+void database_unit_init(Eolian *state, Eolian_Unit *unit, Eina_Stringshare *fname);
void database_unit_del(Eolian_Unit *unit);
/* types */
-void database_type_add(Eolian_Typedecl *def);
-void database_struct_add(Eolian_Typedecl *tp);
-void database_enum_add(Eolian_Typedecl *tp);
+void database_type_add(Eolian *state, Eolian_Typedecl *def);
+void database_struct_add(Eolian *state, Eolian_Typedecl *tp);
+void database_enum_add(Eolian *state, Eolian_Typedecl *tp);
void database_type_del(Eolian_Type *tp);
void database_typedecl_del(Eolian_Typedecl *tp);
/* variables */
void database_var_del(Eolian_Variable *var);
-void database_var_add(Eolian_Variable *var);
+void database_var_add(Eolian *state, Eolian_Variable *var);
/* classes */
void database_class_del(Eolian_Class *cl);