本文整理汇总了C++中JLocalEnv::NewStringUTF方法的典型用法代码示例。如果您正苦于以下问题:C++ JLocalEnv::NewStringUTF方法的具体用法?C++ JLocalEnv::NewStringUTF怎么用?C++ JLocalEnv::NewStringUTF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JLocalEnv
的用法示例。
在下文中一共展示了JLocalEnv::NewStringUTF方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getCachedMethodID
extern "C" void
rb_define_alias(VALUE klass, const char* new_name, const char* old_name)
{
JLocalEnv env;
jmethodID mid = getCachedMethodID(env, RubyModule_class, "defineAlias",
"(Ljava/lang/String;Ljava/lang/String;)V");
env->CallVoidMethod(valueToObject(env, klass), mid, env->NewStringUTF(new_name),
env->NewStringUTF(old_name));
checkExceptions(env);
}
示例2: 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);
}
示例3: 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);
}
示例4: getMethodID
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);
}
示例5: 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);
}
示例6: objectToValue
extern "C" VALUE
rb_define_class(const char* name, VALUE parent)
{
JLocalEnv env;
VALUE super = parent ? parent : rb_cObject;
jobject result = env->CallObjectMethod(getRuntime(), Ruby_defineClass_method,
env->NewStringUTF(name), valueToObject(env, super), getDefaultAllocator(env, super));
checkExceptions(env);
return objectToValue(env, result);
}
示例7: objectToValue
extern "C" VALUE
rb_iv_set(VALUE obj, const char* name, VALUE value)
{
JLocalEnv env;
char var_name[strlen(name) + 2];
(name[0] != '@') ? strcpy(var_name, "@")[0] : var_name[0] = '\0';
strcat(var_name, name);
jobject retval = env->CallObjectMethod(valueToObject(env, obj), RubyBasicObject_setInstanceVariable_method,
env->NewStringUTF(var_name), valueToObject(env, value));
checkExceptions(env);
return objectToValue(env, retval);
}
示例8: 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);
}
示例9: strcpy
extern "C" VALUE
rb_ivar_defined(VALUE obj, ID ivar)
{
JLocalEnv env;
const char* name = rb_id2name(ivar);
char var_name[strlen(name) + 2];
(name[0] != '@') ? strcpy(var_name, "@")[0] : var_name[0] = '\0';
strcat(var_name, name);
jboolean retval = env->CallBooleanMethod(valueToObject(env, obj), RubyBasicObject_hasInstanceVariable_method,
env->NewStringUTF(var_name));
checkExceptions(env);
return (retval == JNI_TRUE) ? Qtrue : Qfalse;
}
示例10: 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;
}
示例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);
}