Example #1
0
File: alloc.c Project: FizzyP/julia
int jl_field_isdefined(jl_value_t *v, jl_sym_t *fld, int err)
{
    jl_datatype_t *st = (jl_datatype_t*)jl_typeof(v);
    int i = jl_field_index(st, fld, err);
    if (i == -1) return 0;
    size_t offs = jl_field_offset(st,i) + sizeof(void*);
    if (st->fields[i].isptr) {
        return *(jl_value_t**)((char*)v + offs) != NULL;
    }
    return 1;
}
Example #2
0
DLLEXPORT jl_value_t *jl_get_field(jl_value_t *o, char *fld)
{
    jl_value_t *v;
    JL_TRY {
        jl_value_t *s = (jl_value_t*)jl_symbol(fld);
        int i = jl_field_index((jl_datatype_t*)jl_typeof(o), (jl_sym_t*)s, 1);
        v = jl_get_nth_field(o, i);
    }
    JL_CATCH {
        v = NULL;
    }
    return v;
}