本文整理汇总了C++中NativeMethodEnvironment::get_handle_global方法的典型用法代码示例。如果您正苦于以下问题:C++ NativeMethodEnvironment::get_handle_global方法的具体用法?C++ NativeMethodEnvironment::get_handle_global怎么用?C++ NativeMethodEnvironment::get_handle_global使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NativeMethodEnvironment
的用法示例。
在下文中一共展示了NativeMethodEnvironment::get_handle_global方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rb_define_class_under
/** @note Shares code with rb_define_module_under, change there too. --rue */
VALUE rb_define_class_under(VALUE parent_handle, const char* name, VALUE superclass_handle) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Module* parent = c_as<Module>(env->get_object(parent_handle));
Class* superclass = c_as<Class>(env->get_object(superclass_handle));
Symbol* constant = env->state()->symbol(name);
bool created = false;
Class* cls = rubinius::Helpers::open_class(env->state(),
env->current_call_frame(), parent, superclass, constant, &created);
return env->get_handle_global(cls);
}
示例2: capi_get_constant
VALUE capi_get_constant(CApiConstant type) {
static CApiConstantHandleMap map;
CApiConstantHandleMap::iterator entry = map.find(type);
if(entry == map.end()) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Object* obj = env->state()->globals.object.get()->get_const(env->state(),
capi_get_constant_name(type).c_str());
Handle handle = env->get_handle_global(obj);
map[type] = handle;
return handle;
} else {
return entry->second;
}
}
示例3:
/**
* This looks like a complicated scheme but there is a reason for
* doing it this way. In MRI, rb_cObject, etc. are all global data.
* We need to avoid global data to better support embedding and
* other features like MVM. @see capi_get_constant().
*/
std::string& capi_get_constant_name(int type) {
static CApiConstantNameMap map;
if(map.empty()) {
map.resize(cCApiMaxConstant + 1);
map[cCApiArray] = "Array";
map[cCApiBignum] = "Bignum";
map[cCApiClass] = "Class";
map[cCApiComparable] = "Comparable";
map[cCApiData] = "Data";
map[cCApiEnumerable] = "Enumerable";
map[cCApiFalse] = "FalseClass";
map[cCApiFixnum] = "Fixnum";
map[cCApiFloat] = "Float";
map[cCApiHash] = "Hash";
map[cCApiInteger] = "Integer";
map[cCApiIO] = "IO";
map[cCApiKernel] = "Kernel";
map[cCApiModule] = "Module";
map[cCApiNil] = "NilClass";
map[cCApiObject] = "Object";
map[cCApiRegexp] = "Regexp";
map[cCApiString] = "String";
map[cCApiSymbol] = "Symbol";
map[cCApiThread] = "Thread";
map[cCApiTime] = "Time";
map[cCApiTrue] = "TrueClass";
map[cCApiArgumentError] = "ArgumentError";
map[cCApiEOFError] = "EOFError";
map[cCApiErrno] = "Errno";
map[cCApiException] = "Exception";
map[cCApiFatal] = "Fatal";
map[cCApiFloatDomainError] = "FloatDomainError";
map[cCApiIndexError] = "IndexError";
map[cCApiInterrupt] = "Interrupt";
map[cCApiIOError] = "IOError";
map[cCApiLoadError] = "LoadError";
map[cCApiLocalJumpError] = "LocalJumpError";
map[cCApiNameError] = "NameError";
map[cCApiNoMemoryError] = "NoMemoryError";
map[cCApiNoMethodError] = "NoMethodError";
map[cCApiNotImplementedError] = "NotImplementedError";
map[cCApiRangeError] = "RangeError";
map[cCApiRegexpError] = "RegexpError";
map[cCApiRuntimeError] = "RuntimeError";
map[cCApiScriptError] = "ScriptError";
map[cCApiSecurityError] = "SecurityError";
map[cCApiSignalException] = "SignalException";
map[cCApiStandardError] = "StandardError";
map[cCApiSyntaxError] = "SyntaxError";
map[cCApiSystemCallError] = "SystemCallError";
map[cCApiSystemExit] = "SystemExit";
map[cCApiSystemStackError] = "SystemStackError";
map[cCApiTypeError] = "TypeError";
map[cCApiThreadError] = "ThreadError";
map[cCApiZeroDivisionError] = "ZeroDivisionError";
}
if(type < 0 || type >= cCApiMaxConstant) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
rb_raise(env->get_handle_global(env->state()->globals.exception.get()),
"C-API: invalid constant index");
}
return map[type];
}
示例4: rb_class_of
VALUE rb_class_of(VALUE object_handle) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Class* class_object = env->get_object(object_handle)->class_object(env->state());
return env->get_handle_global(class_object);
}