本文整理汇总了C++中JLocalEnv::CallStaticVoidMethod方法的典型用法代码示例。如果您正苦于以下问题:C++ JLocalEnv::CallStaticVoidMethod方法的具体用法?C++ JLocalEnv::CallStaticVoidMethod怎么用?C++ JLocalEnv::CallStaticVoidMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JLocalEnv
的用法示例。
在下文中一共展示了JLocalEnv::CallStaticVoidMethod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VALUE
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;
}
}
示例2: getRuntime
extern "C" int
rb_thread_select(int max, fd_set * read, fd_set * write, fd_set * except, struct timeval *timeout)
{
JLocalEnv env;
if (!read && !write && !except) {
// Just sleep for the specified amount of time
long interval = timeout ? (timeout->tv_sec * 1000 + timeout->tv_usec / 1000) : 0;
env->CallStaticVoidMethod(JRuby_class, JRuby_threadSleep, getRuntime(), (jint)interval);
checkExceptions(env);
return 0;
} else {
void** data = (void**)xmalloc(sizeof(void*) * 5);
data[0] = (void*)max;
data[1] = (void*)read;
data[2] = (void*)write;
data[3] = (void*)except;
data[4] = (void*)timeout;
VALUE ret = rb_thread_blocking_region(jruby_select, (void*)data, NULL, NULL);
return (int)ret;
}
}