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


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

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


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

示例1: checkExceptions

extern "C" void
rb_undef_method(VALUE klass, const char* method)
{
    JLocalEnv env;

    jobject ctxt = env->CallObjectMethod(getRuntime(), Ruby_getCurrentContext_method);
    checkExceptions(env);
    env->CallObjectMethod(valueToObject(env, klass), RubyModule_undef_method, ctxt, env->NewStringUTF(method));
    checkExceptions(env);
}
开发者ID:GregMefford,项目名称:jruby,代码行数:10,代码来源:module.cpp

示例2: getMethodID

extern "C" void
rb_undef_method(VALUE klass, const char* method)
{
    JLocalEnv env;

    jmethodID undef = getMethodID(env, RubyModule_class, "undef",
            "(Lorg/jruby/runtime/ThreadContext;Ljava/lang/String;)V");
    jobject ctxt = env->CallObjectMethod(getRuntime(), Ruby_getCurrentContext_method);
    checkExceptions(env);
    env->CallObjectMethod(valueToObject(env, klass), undef, ctxt, env->NewStringUTF(method));
    checkExceptions(env);
}
开发者ID:ajeygore,项目名称:jruby,代码行数:12,代码来源:module.cpp

示例3: 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

示例4: objectToValue

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

示例5: objectToValue

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

示例6: objectToValue

VALUE
jruby::getSymbol(const char* name)
{
    JLocalEnv env;
    jobject result = env->CallObjectMethod(getRuntime(), Ruby_newSymbol_method, env->NewStringUTF(name));
    checkExceptions(env);

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

示例7: getCachedMethodID

extern "C" void
jruby_infect(VALUE object1, VALUE object2)
{
    if (OBJ_TAINTED(object1)) {
        JLocalEnv env;
        jmethodID mid = getCachedMethodID(env, IRubyObject_class, "infectBy",
            "(Lorg/jruby/runtime/builtin/IRubyObject;)Lorg/jruby/runtime/builtin/IRubyObject;");
        env->CallObjectMethod(valueToObject(env, object2), mid, object1);
        checkExceptions(env);
    }
}
开发者ID:BrandonMathis,项目名称:jruby,代码行数:11,代码来源:object.cpp

示例8: objectToValue

extern "C" VALUE
rb_singleton_class(VALUE obj)
{
    JLocalEnv env;

    jmethodID IRubyObject_getSingletonClass_method = getCachedMethodID(env, IRubyObject_class, "getSingletonClass",
            "()Lorg/jruby/RubyClass;");
    jobject singleton = env->CallObjectMethod(valueToObject(env, obj), IRubyObject_getSingletonClass_method);
    checkExceptions(env);

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

示例9: checkExceptions

extern "C" ID
rb_intern2(const char* name, long len)
{
    std::map<StringKey, ID>::iterator it = nonConstSymbolMap.find(StringKey(name, len));
    if (it != nonConstSymbolMap.end()) {
        return it->second;
    }

    JLocalEnv env;
    jobject result = env->CallObjectMethod(getRuntime(), Ruby_newSymbol_method, env->NewStringUTF(name));
    checkExceptions(env);

    Symbol* sym = addSymbol(env, env->GetIntField(result, RubySymbol_id_field), result);
    nonConstSymbolMap.insert(std::map<StringKey, ID>::value_type(StringKey(sym->cstr, (long) len), sym->id));

    return sym->id;
}
开发者ID:Epictetus,项目名称:jruby,代码行数:17,代码来源:symbol.cpp

示例10: VALUE

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

    jmethodID IRubyObject_getSingletonClass_method = getMethodID(env, IRubyObject_class, "getSingletonClass",
            "()Lorg/jruby/RubyClass;");
    jobject singleton = env->CallObjectMethod(valueToObject(env, object), IRubyObject_getSingletonClass_method);

    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");

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

示例11: callMethodA

extern "C" VALUE
rb_struct_new(VALUE klass, ...)
{
    JLocalEnv env;
    jmethodID mid = getCachedMethodID(env, RubyBasicObject_class, "getInternalVariable", 
        "(Ljava/lang/String;)Ljava/lang/Object;");

    int size = NUM2INT(objectToValue(env, env->CallObjectMethod(valueToObject(env, klass), mid, env->NewStringUTF("__size__"))));

    VALUE* values = (VALUE *) alloca(sizeof(VALUE) * size);

    va_list args;
    va_start(args, klass);
    for (int i = 0; i < size; ++i) {
        values[i] = va_arg(args, VALUE);
    }

    va_end(args);

    return callMethodA(klass, "new", size, values);
}
开发者ID:BrandonMathis,项目名称:jruby,代码行数:21,代码来源:struct.cpp


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