本文整理汇总了C++中NativeMethodEnvironment::get_object方法的典型用法代码示例。如果您正苦于以下问题:C++ NativeMethodEnvironment::get_object方法的具体用法?C++ NativeMethodEnvironment::get_object怎么用?C++ NativeMethodEnvironment::get_object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NativeMethodEnvironment
的用法示例。
在下文中一共展示了NativeMethodEnvironment::get_object方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rb_string_value
VALUE rb_string_value(volatile VALUE* object_variable) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
if(!kind_of<String>(env->get_object(*object_variable))) {
*object_variable = rb_str_to_str(*object_variable);
}
return *object_variable;
}
示例2: rb_io_check_closed
void rb_io_check_closed(rb_io_t* iot) {
VALUE io_handle = iot->handle;
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
IO* io = c_as<IO>(env->get_object(io_handle));
if(io->descriptor()->to_native() == -1) {
rb_raise(rb_eIOError, "closed stream");
}
}
示例3: rb_ary_unshift
VALUE rb_ary_unshift(VALUE self, VALUE object) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Array* array = capi_get_array(env, self);
array->unshift(env->state(), env->get_object(object));
capi_update_array(env, self);
return self;
}
示例4: rb_ary_unshift
VALUE rb_ary_unshift(VALUE self_handle, VALUE object_handle) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Array* self = capi_get_array(env, self_handle);
self->unshift(env->state(), env->get_object(object_handle));
capi_update_array(env, self_handle);
return self_handle;
}
示例5: rb_io_check_writable
void rb_io_check_writable(rb_io_t* iot) {
VALUE io_handle = iot->handle;
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
IO* io = c_as<IO>(env->get_object(io_handle));
int io_mode = io->mode()->to_native() & O_ACCMODE;
if(!(O_WRONLY == io_mode || O_RDWR == io_mode)) {
rb_raise(rb_eIOError, "not opened for writing");
}
}
示例6: rb_ivar_defined
VALUE rb_ivar_defined(VALUE obj_handle, ID ivar_name) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Symbol* ivar = reinterpret_cast<Symbol*>(ivar_name);
Object* obj = env->get_object(obj_handle);
Object* ret = obj->ivar_defined(env->state(), ivar);
return env->get_handle(ret);
}
示例7: rb_string_value_ptr
char* rb_string_value_ptr(volatile VALUE* object_variable) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
VALUE str = rb_string_value(object_variable);
// Type check.
(void)c_as<String>(env->get_object(str));
return RSTRING_PTR(str);
}
示例8: rb_io_check_readable
void rb_io_check_readable(rb_io_t* iot) {
VALUE io_handle = iot->handle;
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
IO* io = c_as<IO>(env->get_object(io_handle));
if ((io->mode()->to_native() & O_ACCMODE) != O_RDONLY) {
rb_raise(rb_eIOError, "not opened for reading");
}
}
示例9: capi_define_method
void capi_define_method(const char* file, VALUE target,
const char* name, CApiGenericFunction fptr, int arity, CApiMethodKind kind) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
VM* state = env->state();
Symbol* method_name = state->symbol(name);
Module* module = NULL;
if (kind == cCApiSingletonMethod) {
module = c_as<Module>(env->get_object(target)->metaclass(env->state()));
}
else {
module = c_as<Module>(env->get_object(target));
}
NativeMethod* method = NULL;
method = NativeMethod::create(state,
String::create(state, file),
module,
method_name,
fptr,
Fixnum::from(arity));
MethodVisibility* visibility = MethodVisibility::create(state);
visibility->method(state, method);
switch(kind) {
case cCApiPrivateMethod:
visibility->visibility(state, state->symbol("private"));
break;
case cCApiProtectedMethod:
visibility->visibility(state, state->symbol("protected"));
break;
default: /* Also catches singletons for now. @todo Verify OK. --rue */
visibility->visibility(state, state->symbol("public"));
break;
}
module->method_table()->store(state, method_name, visibility);
state->global_cache->clear(module, method_name);
}
示例10: rb_file_path_value
VALUE rb_file_path_value(volatile VALUE* obj) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
STATE = env->state();
if(!kind_of<String>(env->get_object(*obj))) {
*obj = rb_funcall(env->get_handle(G(type)), rb_intern("coerce_to_path"), 1, *obj);
}
return *obj;
}
示例11: rb_call_super
VALUE rb_call_super(int argc, const VALUE *argv) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Object** args = reinterpret_cast<Object**>(alloca(sizeof(Object*) * argc));
for(int i = 0; i < argc; i++) {
args[i] = env->get_object(argv[i]);
}
return capi_call_super_native(env, argc, args);
}
示例12: rb_big_sign
int rb_big_sign(VALUE obj) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Bignum* big = c_as<Bignum>(env->get_object(obj));
if (big->mp_val()->sign == MP_NEG) {
return -1;
}
return 1;
}
示例13: rb_enc_get_index
int rb_enc_get_index(VALUE obj) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Object* val = env->get_object(obj);
Encoding* enc = Encoding::get_object_encoding(env->state(), val);
if(enc->nil_p()) return 0;
return Encoding::find_index(env->state(), enc->get_encoding()->name);
}
示例14: rb_enc_get
rb_encoding* rb_enc_get(VALUE obj) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Object* val = env->get_object(obj);
if(!val->reference_p() && !val->symbol_p()) return 0;
Encoding* enc = Encoding::get_object_encoding(env->state(), val);
if(enc->nil_p()) return 0;
return enc->get_encoding();
}
示例15: rb_call_super
VALUE rb_call_super(int argc, const VALUE *argv) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Object* args[argc];
for(int i = 0; i < argc; i++) {
args[i] = env->get_object(argv[i]);
}
return capi_call_super_native(env, argc, args);
}