In order to find setters and getters, the actual code depends on dlopen() and
dlsym() to open the process as a shared library and to look for symbols.
However, this implies compiling with extra flags which not suitable for all
projects.
I've made a simple wrapper around these calls so that a someone could replace
this mecanism with a lookup table:
void *evcpe_symboldb_open(void);
void *evcpe_symboldb_find(void *handle, char *symbol);
int evcpe_symboldb_close(void *handle);
/* -------------- EVCPE IMPLEMENTATION ------------*/
void *evcpe_symboldb_open(void)
{
return dlopen(NULL, RTLD_LAZY|RTLD_GLOBAL);
}
void *evcpe_symboldb_find(void *handle, const char *symbol)
{
return dlsym(handle, symbol);
}
int evcpe_symboldb_close(void *handle)
{
return dlclose(handle);
}
/* -------------- SIMPLE LOOKUP TABLE ------------*/
struct entry_s
{
void *fn; /**< function's ptr */
const char *name; /**< function's name */
};
static struct entry_s methods[] =
{
/* ............... */
};
void *evcpe_symboldb_open(void)
{
return 0;
}
void *evcpe_symboldb_find(void *handle, const char *symbol)
{
int i;
for (i = 0; i < sizeof(methods)/sizeof(struct entry_s); ++i)
{
if (!strcmp(methods[i].name, symbol))
{
return 0;
}
}
return -1;
}
int evcpe_symboldb_close(void *handle)
{
return 0;
}
Original issue reported on code.google.com by atef.hal...@gmail.com on 10 Oct 2011 at 7:58
Original issue reported on code.google.com by
atef.hal...@gmail.com
on 10 Oct 2011 at 7:58