Example #1
0
extern "C" int
rb_respond_to(VALUE obj, ID id)
{
    JLocalEnv env;
    jboolean ret = env->CallBooleanMethod(valueToObject(env, obj), IRubyObject_respondsTo_method, idToString(env, id));
    checkExceptions(env);
    return ret != JNI_FALSE;
}
Example #2
0
extern "C" VALUE
rb_ivar_defined(VALUE obj, ID ivar)
{
    JLocalEnv env;
    const char* name = rb_id2name(ivar);

    char var_name[strlen(name) + 2];
    (name[0] != '@') ? strcpy(var_name, "@")[0] : var_name[0] = '\0';
    strcat(var_name, name);

    jboolean retval = env->CallBooleanMethod(valueToObject(env, obj), RubyBasicObject_hasInstanceVariable_method,
            env->NewStringUTF(var_name));
    checkExceptions(env);

    return (retval == JNI_TRUE) ? Qtrue : Qfalse;
}