当前位置: 首页>>代码示例>>C++>>正文


C++ JLocalEnv类代码示例

本文整理汇总了C++中JLocalEnv的典型用法代码示例。如果您正苦于以下问题:C++ JLocalEnv类的具体用法?C++ JLocalEnv怎么用?C++ JLocalEnv使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了JLocalEnv类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rb_num2ll

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;
}
开发者ID:nahi,项目名称:jruby,代码行数:25,代码来源:numeric.cpp

示例2: rb_data_object_alloc

extern "C" VALUE
rb_data_object_alloc(VALUE klass, void* data, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
{
    JLocalEnv env;

    RubyData* h = new RubyData;

    TAILQ_INSERT_TAIL(&dataHandles, h, dataList);
    h->toRData()->data = data;
    h->toRData()->dmark = dmark;
    h->toRData()->dfree = dfree;
    h->setType(T_DATA);

    jvalue params[3];
    params[0].l = getRuntime();
    params[1].l = valueToObject(env, klass);
    params[2].j = p2j(h);

    jobject obj = env->CallStaticObjectMethodA(RubyData_class, RubyData_newRubyData_method, params);
    checkExceptions(env);

    h->obj = env->NewGlobalRef(obj);
    checkExceptions(env);


    return (VALUE) (uintptr_t) h;
}
开发者ID:Epictetus,项目名称:jruby,代码行数:27,代码来源:data-object.cpp

示例3: rb_rescue

extern "C" VALUE
rb_rescue(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*r_proc)(ANYARGS), VALUE data2)
{
    try {
        return (*b_proc)(data1);

    } catch (jruby::JavaException& ex) {
        JLocalEnv env;

        jthrowable t = ex.getCause(env);
        if (!env->IsInstanceOf(t, RaiseException_class)) {
            // Not a ruby exception, just propagate
            throw;
        }

        jobject rubyException = env->GetObjectField(t, RaiseException_exception_field);
        checkExceptions(env);

        VALUE exc = objectToValue(env, rubyException);
        if (rb_obj_is_kind_of(exc, rb_eStandardError)) {

            VALUE result = (*r_proc)(data2);
            env->CallStaticVoidMethod(JRuby_class, JRuby_clearErrorInfo, jruby::getRuntime());

            return result;
        }

        rb_raise(rb_eTypeError, "wrong exception type raised (expected StandardError subclass)");

        return Qnil;
    }
}
开发者ID:DatekWireless,项目名称:jruby,代码行数:32,代码来源:exception.cpp

示例4: rb_respond_to

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;
}
开发者ID:BrandonMathis,项目名称:jruby,代码行数:8,代码来源:object.cpp

示例5: rb_num2chr

extern "C" char
rb_num2chr(VALUE v)
{
    JLocalEnv env;
    jbyte result = env->CallStaticByteMethod(RubyNumeric_class, RubyNumeric_num2chr_method, valueToObject(env, v));
    checkExceptions(env);
    return (char) result;
}
开发者ID:nahi,项目名称:jruby,代码行数:8,代码来源:numeric.cpp

示例6: rb_ary_size

extern "C" int
rb_ary_size(VALUE ary)
{
    JLocalEnv env;
    int length = (int)(env->GetIntField(valueToObject(env, ary), RubyArray_length_field));
    checkExceptions(env);
    return length;
}
开发者ID:Epictetus,项目名称:jruby,代码行数:8,代码来源:array.cpp

示例7: rb_define_module

extern "C" VALUE
rb_define_module(const char* name)
{
    JLocalEnv env;
    jobject mod = env->CallObjectMethod(getRuntime(), Ruby_defineModule_method, env->NewStringUTF(name));
    checkExceptions(env);
    return objectToValue(env, mod);
}
开发者ID:ajeygore,项目名称:jruby,代码行数:8,代码来源:module.cpp

示例8: rb_define_const

extern "C" void
rb_define_const(VALUE module, const char* name, VALUE obj)
{
    JLocalEnv env;
    jmethodID mid = getMethodID(env, RubyModule_class, "defineConstant",
            "(Ljava/lang/String;Lorg/jruby/runtime/builtin/IRubyObject;)V");
    env->CallVoidMethod(valueToObject(env, module), mid, env->NewStringUTF(name), valueToObject(env, obj));
    checkExceptions(env);
}
开发者ID:ajeygore,项目名称:jruby,代码行数:9,代码来源:module.cpp

示例9: rb_block_proc

extern "C" VALUE
rb_block_proc()
{
    JLocalEnv env;
    jobject proc = env->CallStaticObjectMethod(JRuby_class, JRuby_getBlockProc, getRuntime());
    checkExceptions(env);

    return objectToValue(env, proc);
}
开发者ID:BrandonMathis,项目名称:jruby,代码行数:9,代码来源:kernel.cpp

示例10: rb_thread_create

extern "C" VALUE
rb_thread_create(VALUE (*fn)(ANYARGS), void* arg)
{
    JLocalEnv env;
    jobject ret = env->CallStaticObjectMethod(JRuby_class, JRuby_newThread, getRuntime(),
                p2j((void*)fn), valueToObject(env, (arg == NULL ? rb_ary_new() : (VALUE)arg)));
    checkExceptions(env);
    return objectToValue(env, ret);
}
开发者ID:Epictetus,项目名称:jruby,代码行数:9,代码来源:thread.cpp

示例11: rb_class_new

extern "C" VALUE
rb_class_new(VALUE klass)
{
    JLocalEnv env;
    jobject jklass = env->CallStaticObjectMethod(RubyClass_class, RubyClass_newClass_method,
            getRuntime(), valueToObject(env, klass));
    checkExceptions(env);
    return objectToValue(env, jklass);
}
开发者ID:Vouters,项目名称:jruby,代码行数:9,代码来源:class.cpp

示例12: rb_path2class

extern "C" VALUE
rb_path2class(const char* path)
{
    JLocalEnv env;
    jobject klass = env->CallObjectMethod(getRuntime(), Ruby_getClassFromPath_method, env->NewStringUTF(path));
    checkExceptions(env);

    return objectToValue(env, klass);
}
开发者ID:Vouters,项目名称:jruby,代码行数:9,代码来源:class.cpp

示例13: rb_path_to_class

extern "C" VALUE 
rb_path_to_class(VALUE pathname)
{
    JLocalEnv env;
    jobject klass = env->CallObjectMethod(getRuntime(), Ruby_getClassFromPath_method, env->NewStringUTF(rb_str_ptr_readonly(pathname)));
    checkExceptions(env);

    return objectToValue(env, klass);
}
开发者ID:Vouters,项目名称:jruby,代码行数:9,代码来源:class.cpp

示例14: rb_yield_splat

extern "C" VALUE
rb_yield_splat(VALUE array)
{
    JLocalEnv env;
    jobject retval = env->CallStaticObjectMethod(JRuby_class, JRuby_yield, getRuntime(), valueToObject(env, array));
    checkExceptions(env);

    return objectToValue(env, retval);
}
开发者ID:BrandonMathis,项目名称:jruby,代码行数:9,代码来源:kernel.cpp

示例15: rb_str_modify

extern "C" void
rb_str_modify(VALUE str)
{
    JLocalEnv env;
    jmethodID mid = getCachedMethodID(env, RubyString_class, "modify", "()V");

    env->CallVoidMethod(valueToObject(env, str), mid);
    checkExceptions(env);
}
开发者ID:RB-DPR,项目名称:RB-DPR,代码行数:9,代码来源:string.cpp


注:本文中的JLocalEnv类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。