本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例9: return
extern "C" VALUE
rb_class_of(VALUE obj)
{
JLocalEnv env;
return (VALUE) env->CallStaticObjectMethod(JRuby_class, JRuby_getMetaClass, valueToObject(env, obj));
}