Пример #1
0
extern "C" long long
rb_num2ll(VALUE v)
{
    if (FIXNUM_P(v)) {
        return FIX2LONG(v);
    }

    Handle* h = Handle::valueOf(v);
    if (h->getType() == T_FIXNUM) {
        return ((RubyFixnum *) h)->longValue();
    }

    JLocalEnv env;

    jsync(env);

    jvalue params[1];

    params[0].l = valueToObject(env, v);

    jlong result = env->CallStaticLongMethodA(RubyNumeric_class, RubyNumeric_num2long_method, params);
    checkExceptions(env);

    return (long long) result;
}
Пример #2
0
extern "C" long long
rb_big2ll(VALUE obj)
{
    JLocalEnv env;
    jvalue params[1];

    params[0].l = valueToObject(env, obj);
    jlong result = env->CallStaticLongMethodA(RubyNumeric_class, RubyNumeric_num2long_method, params);
    checkExceptions(env);

    return (long long) result;
}
Пример #3
0
static inline RubyFixnum*
newNumber(jmethodID method, long long v)
{
    JLocalEnv env;
    jvalue params[2];

    params[0].l = getRuntime();
    params[1].j = (jlong) v;

    jlong result = env->CallStaticLongMethodA(JRuby_class, method, params);
    checkExceptions(env);

    return (RubyFixnum *) j2p(result);
}