class BDB1::Delegate

Public Class Methods

_load(p1) click to toggle source
static VALUE
bdb1_deleg_load(VALUE obj, VALUE str)
{
    bdb1_DB *dbst;

    if (NIL_P(obj = rb_thread_local_aref(rb_thread_current(), bdb1_id_current_db))) {
        rb_raise(bdb1_eFatal, "BUG : current_db not set");
    }
    Data_Get_Struct(obj, bdb1_DB, dbst);
    return rb_funcall(dbst->marshal, rb_intern("load"), 1, str);
}

Public Instance Methods

_dump(p1) click to toggle source
static VALUE
bdb1_deleg_dump(VALUE obj, VALUE limit)
{
    struct deleg_class *delegst;
    bdb1_DB *dbst;
    Data_Get_Struct(obj, struct deleg_class, delegst);
    Data_Get_Struct(delegst->db, bdb1_DB, dbst);
    return rb_funcall(dbst->marshal, rb_intern("dump"), 1, delegst->obj);
}
inspect() click to toggle source
static VALUE bdb1_deleg_inspect(VALUE obj) 
method_missing(*args) click to toggle source
static VALUE
bdb1_deleg_missing(int argc, VALUE *argv, VALUE obj)
{
    struct deleg_class *delegst, *newst;
    bdb1_DB *dbst;
    VALUE res, new;

    Data_Get_Struct(obj, struct deleg_class, delegst);
    if (rb_block_given_p()) {
        res = rb_block_call(delegst->obj, id_send, argc, argv, rb_yield, 0);
    }
    else {
        res = rb_funcall2(delegst->obj, id_send, argc, argv);
    }
    Data_Get_Struct(delegst->db, bdb1_DB, dbst);
    if (dbst->dbp) {
        VALUE nargv[2];

        if (!SPECIAL_CONST_P(res) &&
            (TYPE(res) != T_DATA || 
             RDATA(res)->dmark != (RUBY_DATA_FUNC)bdb1_deleg_mark)) {
            new = Data_Make_Struct(bdb1_cDelegate, struct deleg_class, 
                                   bdb1_deleg_mark, bdb1_deleg_free, newst);
            newst->db = delegst->db;
            newst->obj = res;
            newst->key = (!delegst->type)?obj:delegst->key;
            newst->type = 1;
            res = new;
        }
        if (!delegst->type) {
            nargv[0] = delegst->key;
            nargv[1] = delegst->obj;
        }
        else {
            Data_Get_Struct(delegst->key, struct deleg_class, newst);
            nargv[0] = newst->key;
            nargv[1] = newst->obj;
        }
        bdb1_put(2, nargv, delegst->db);
    }
    return res;
}
to_a() click to toggle source
static VALUE bdb1_deleg_to_a(VALUE obj) 
to_ary() click to toggle source
static VALUE bdb1_deleg_to_ary(VALUE obj) 
to_f() click to toggle source
static VALUE bdb1_deleg_to_f(VALUE obj) 
to_hash() click to toggle source
static VALUE bdb1_deleg_to_hash(VALUE obj) 
to_i() click to toggle source
static VALUE bdb1_deleg_to_i(VALUE obj) 
to_int() click to toggle source
static VALUE bdb1_deleg_to_int(VALUE obj) 
to_io() click to toggle source
static VALUE bdb1_deleg_to_io(VALUE obj) 
to_orig() click to toggle source
VALUE
bdb1_deleg_to_orig(VALUE obj)
{
    struct deleg_class *delegst;
    Data_Get_Struct(obj, struct deleg_class, delegst);
    return delegst->obj;
}
to_proc() click to toggle source
static VALUE bdb1_deleg_to_proc(VALUE obj) 
to_s() click to toggle source
static VALUE bdb1_deleg_to_s(VALUE obj) 
to_str() click to toggle source
static VALUE bdb1_deleg_to_str(VALUE obj)