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


C++ JLocalEnv::CallStaticObjectMethod方法代码示例

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


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

示例1: objectToValue

extern "C" VALUE
rb_struct_define(const char* name_cstr, ...)
{
    JLocalEnv env;
    va_list varargs;
    std::vector<char *> args;

    va_start(varargs, name_cstr);
    char* cp;
    while ((cp = va_arg(varargs, char *)) != NULL) {
        args.push_back(cp);
    }
    va_end(varargs);

    jobjectArray argArray = env->NewObjectArray(args.size() + 1, IRubyObject_class, NULL);
    checkExceptions(env);

    env->SetObjectArrayElement(argArray, 0, 
        name_cstr == NULL ? getNil() : valueToObject(env, rb_str_new_cstr(name_cstr)));
    checkExceptions(env);

    for (unsigned int i = 0; i < args.size(); i++) {
        env->SetObjectArrayElement(argArray, i + 1, valueToObject(env, rb_str_new_cstr(args[i])));
        checkExceptions(env);
    }

    jmethodID mid = getCachedMethodID(env, Ruby_class, "getStructClass", "()Lorg/jruby/RubyClass;");
    jobject structClass = env->CallObjectMethod(getRuntime(), mid);

    jobject newStructSubclass = env->CallStaticObjectMethod(RubyStruct_class, RubyStruct_newInstance,
            structClass, argArray, getNullBlock());
    checkExceptions(env);

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

示例2: objectToValue

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

示例3: objectToValue

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

示例4: objectToValue

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

示例5: addSymbol

Symbol*
jruby::resolveSymbolById(ID id)
{
    JLocalEnv env;

    jobject obj = env->CallStaticObjectMethod(Symbol_class, RubySymbol_getSymbolLong,
            jruby::getRuntime(), (jlong) id);

    if (env->IsSameObject(obj, NULL)) {
        rb_raise(rb_eRuntimeError, "could not resolve symbol ID %lld", (long long) id);
    }

    return addSymbol(env, id, obj);
}
开发者ID:Epictetus,项目名称:jruby,代码行数:14,代码来源:symbol.cpp

示例6: VALUE

extern "C" void
rb_define_method(VALUE klass, const char* meth, VALUE(*fn)(ANYARGS), int arity)
{
    JLocalEnv env;

    jmethodID JRuby_newMethod = getStaticMethodID(env, JRuby_class, "newMethod", "(Lorg/jruby/RubyModule;JI)Lorg/jruby/internal/runtime/methods/DynamicMethod;");
    jmethodID RubyModule_addMethod_method = getMethodID(env, RubyModule_class, "addMethod",
            "(Ljava/lang/String;Lorg/jruby/internal/runtime/methods/DynamicMethod;)V");

    jobject module = valueToObject(env, klass);
    env->CallVoidMethod(module, RubyModule_addMethod_method, env->NewStringUTF(meth),
            env->CallStaticObjectMethod(JRuby_class, JRuby_newMethod, module, (jlong)(intptr_t) fn, arity));
    checkExceptions(env);
}
开发者ID:ajeygore,项目名称:jruby,代码行数:14,代码来源:module.cpp

示例7: size

static VALUE
newArray(long len)
{
    if (len < 0) {
        rb_raise(rb_eArgError, "negative array size (or size too big)");
    }

    JLocalEnv env;
    jobject ary = env->CallStaticObjectMethod(RubyArray_class, RubyArray_newArray, getRuntime(), (jlong)len);
    checkExceptions(env);

    VALUE ary_value = objectToValue(env, ary);
    return ary_value;
}
开发者ID:Epictetus,项目名称:jruby,代码行数:14,代码来源:array.cpp

示例8: getRuntime

extern "C" VALUE
rb_data_object_alloc(VALUE klass, void* data, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
{
    Handle* h = new Handle;
    JLocalEnv env;
    
    h->data = data;
    h->dmark = dmark;
    h->dfree = dfree;
    h->finalize = rubydata_finalize;
    h->type = T_DATA;

    jobject obj = env->CallStaticObjectMethod(RubyData_class, RubyData_newRubyData_method, getRuntime(), 
            valueToObject(env, klass), (jlong) h);
    checkExceptions(env);
    h->obj = env->NewWeakGlobalRef(obj);
    checkExceptions(env);
    

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

示例9: return

extern "C" VALUE
rb_class_of(VALUE obj)
{
    JLocalEnv env;
    return (VALUE) env->CallStaticObjectMethod(JRuby_class, JRuby_getMetaClass, valueToObject(env, obj));
}
开发者ID:jamiejackson,项目名称:jruby,代码行数:6,代码来源:class.cpp


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