本文整理匯總了C++中GET_VM函數的典型用法代碼示例。如果您正苦於以下問題:C++ GET_VM函數的具體用法?C++ GET_VM怎麽用?C++ GET_VM使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GET_VM函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: ruby_dispatch
static force_inline VALUE
ruby_dispatch(VALUE top, VALUE self, SEL sel, rb_vm_method_node_t *node,
unsigned char opt, int argc, const VALUE *argv)
{
const rb_vm_arity_t &arity = node->arity;
if ((argc < arity.min) || ((arity.max != -1) && (argc > arity.max))) {
short limit = (argc < arity.min) ? arity.min : arity.max;
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
argc, limit);
}
if ((node->flags & VM_METHOD_PRIVATE) && opt == 0) {
// Calling a private method with no explicit receiver OR an attribute
// assignment to non-self, triggering #method_missing.
rb_vm_block_t *b = GET_VM()->current_block();
return method_missing(self, sel, b, argc, argv,
METHOD_MISSING_PRIVATE);
}
if ((node->flags & VM_METHOD_PROTECTED)
&& top != 0 && node->klass != NULL
&& !rb_obj_is_kind_of(top, (VALUE)node->klass)) {
// Calling a protected method inside a method where 'self' is not
// an instance of the class where the method was originally defined,
// triggering #method_missing.
rb_vm_block_t *b = GET_VM()->current_block();
return method_missing(self, sel, b, argc, argv,
METHOD_MISSING_PROTECTED);
}
if ((node->flags & VM_METHOD_EMPTY) && arity.max == arity.min) {
// Calling an empty method, let's just return nil!
return Qnil;
}
if ((node->flags & VM_METHOD_FBODY) && arity.max != arity.min) {
// Calling a function defined with rb_objc_define_method with
// a negative arity, which means a different calling convention.
if (arity.real == 2) {
return ((VALUE (*)(VALUE, SEL, int, const VALUE *))node->ruby_imp)
(self, sel, argc, argv);
}
else if (arity.real == 1) {
return ((VALUE (*)(VALUE, SEL, ...))node->ruby_imp)
(self, sel, rb_ary_new4(argc, argv));
}
else if (arity.real == 3) {
return ((VALUE (*)(VALUE, SEL, VALUE, int,
const VALUE *))node->ruby_imp)
(self, sel, top, argc, argv);
}
else {
printf("invalid negative arity for C function %d\n",
arity.real);
abort();
}
}
return __rb_vm_rcall(self, sel, node->ruby_imp, arity, argc, argv);
}
示例2: trap
static VALUE
trap(int sig, sighandler_t func, VALUE command)
{
sighandler_t oldfunc;
VALUE oldcmd;
rb_vm_t *vm = GET_VM();
/*
* Be careful. ruby_signal() and trap_list[sig].cmd must be changed
* atomically. In current implementation, we only need to don't call
* RUBY_VM_CHECK_INTS().
*/
oldfunc = ruby_signal(sig, func);
oldcmd = vm->trap_list[sig].cmd;
switch (oldcmd) {
case 0:
case Qtrue:
if (oldfunc == SIG_IGN) oldcmd = rb_str_new2("IGNORE");
else if (oldfunc == sighandler) oldcmd = rb_str_new2("DEFAULT");
else oldcmd = Qnil;
break;
case Qnil:
break;
case Qundef:
oldcmd = rb_str_new2("EXIT");
break;
}
vm->trap_list[sig].cmd = command;
vm->trap_list[sig].safe = rb_safe_level();
return oldcmd;
}
示例3: ruby_init
void
ruby_init(void)
{
int state;
if (ruby_initialized)
return;
ruby_initialized = 1;
#ifdef __MACOS__
rb_origenviron = 0;
#else
rb_origenviron = environ;
#endif
#if WITH_OBJC
char *s;
s = getenv("MACRUBY_DEBUG");
ruby_dlog_enabled = !(s == NULL || *s == '0');
s = getenv("MACRUBY_DEBUG_FILE");
if (s == NULL) {
ruby_dlog_file = stderr;
}
else {
ruby_dlog_file = fopen(s, "w");
if (ruby_dlog_file == NULL) {
fprintf(stderr, "cannot open macruby debug file `%s'",
strerror(errno));
ruby_dlog_file = stderr;
}
}
#endif
Init_stack((void *)&state);
Init_PreGC();
Init_BareVM();
Init_heap();
PUSH_TAG();
if ((state = EXEC_TAG()) == 0) {
rb_call_inits();
#ifdef __MACOS__
_macruby_init();
#elif defined(__VMS)
_vmsruby_init();
#endif
ruby_prog_init();
ALLOW_INTS;
}
POP_TAG();
if (state) {
error_print();
exit(EXIT_FAILURE);
}
GET_VM()->running = 1;
}
示例4: Init_postponed_job
static void
Init_postponed_job(void)
{
rb_vm_t *vm = GET_VM();
vm->postponed_job_buffer = ALLOC_N(rb_postponed_job_t, MAX_POSTPONED_JOB);
vm->postponed_job_index = 0;
}
示例5: trap
static VALUE
trap(struct trap_arg *arg)
{
sighandler_t oldfunc, func = arg->func;
VALUE oldcmd, command = arg->cmd;
int sig = arg->sig;
rb_vm_t *vm = GET_VM();
oldfunc = ruby_signal(sig, func);
oldcmd = vm->trap_list[sig].cmd;
switch (oldcmd) {
case 0:
if (oldfunc == SIG_IGN) oldcmd = rb_str_new2("IGNORE");
else if (oldfunc == sighandler) oldcmd = rb_str_new2("DEFAULT");
else oldcmd = Qnil;
break;
case Qundef:
oldcmd = rb_str_new2("EXIT");
break;
}
vm->trap_list[sig].cmd = command;
vm->trap_list[sig].safe = rb_safe_level();
/* enable at least specified signal. */
#if USE_TRAP_MASK
#ifdef HAVE_SIGPROCMASK
sigdelset(&arg->mask, sig);
#else
arg->mask &= ~sigmask(sig);
#endif
#endif
return oldcmd;
}
示例6: ruby_setup
/* Initializes the Ruby VM and builtin libraries.
* @retval 0 if succeeded.
* @retval non-zero an error occurred.
*/
int
ruby_setup(void)
{
static int initialized = 0;
int state;
if (initialized)
return 0;
initialized = 1;
ruby_init_stack((void *)&state);
Init_BareVM();
Init_heap();
Init_vm_objects();
PUSH_TAG();
if ((state = EXEC_TAG()) == 0) {
rb_call_inits();
ruby_prog_init();
GET_VM()->running = 1;
}
POP_TAG();
return state;
}
示例7: Init_load
void
Init_load(void)
{
#undef rb_intern
#define rb_intern(str) rb_intern2((str), strlen(str))
rb_vm_t *vm = GET_VM();
static const char var_load_path[] = "$:";
ID id_load_path = rb_intern2(var_load_path, sizeof(var_load_path)-1);
rb_define_hooked_variable(var_load_path, (VALUE*)vm, load_path_getter, rb_gvar_readonly_setter);
rb_alias_variable(rb_intern("$-I"), id_load_path);
rb_alias_variable(rb_intern("$LOAD_PATH"), id_load_path);
vm->load_path = rb_ary_new();
vm->expanded_load_path = rb_ary_tmp_new(0);
vm->load_path_snapshot = rb_ary_tmp_new(0);
vm->load_path_check_cache = 0;
rb_define_virtual_variable("$\"", get_loaded_features, 0);
rb_define_virtual_variable("$LOADED_FEATURES", get_loaded_features, 0);
vm->loaded_features = rb_ary_new();
vm->loaded_features_snapshot = rb_ary_tmp_new(0);
vm->loaded_features_index = st_init_strtable();
rb_define_global_function("load", rb_f_load, -1);
rb_define_global_function("require", rb_f_require, 1);
rb_define_global_function("require_relative", rb_f_require_relative, 1);
rb_define_method(rb_cModule, "autoload", rb_mod_autoload, 2);
rb_define_method(rb_cModule, "autoload?", rb_mod_autoload_p, 1);
rb_define_global_function("autoload", rb_f_autoload, 2);
rb_define_global_function("autoload?", rb_f_autoload_p, 1);
ruby_dln_librefs = rb_ary_tmp_new(0);
rb_gc_register_mark_object(ruby_dln_librefs);
}
示例8: init_sigchld
static void
init_sigchld(int sig)
{
sighandler_t oldfunc;
#if USE_TRAP_MASK
# ifdef HAVE_SIGPROCMASK
sigset_t mask;
sigset_t fullmask;
# else
int mask;
int fullmask;
# endif
#endif
#if USE_TRAP_MASK
/* disable interrupt */
sigfillset(&fullmask);
pthread_sigmask(SIG_BLOCK, &fullmask, &mask);
#endif
oldfunc = ruby_signal(sig, SIG_DFL);
if (oldfunc != SIG_DFL && oldfunc != SIG_IGN) {
ruby_signal(sig, oldfunc);
} else {
GET_VM()->trap_list[sig].cmd = 0;
}
#if USE_TRAP_MASK
sigdelset(&mask, sig);
pthread_sigmask(SIG_SETMASK, &mask, NULL);
trap_last_mask = mask;
#endif
}
示例9: rb_vm_block_eval2
VALUE
rb_vm_block_eval2(rb_vm_block_t *b, VALUE self, SEL sel, int argc,
const VALUE *argv)
{
// TODO check given arity and raise exception
return vm_block_eval(GET_VM(), b, sel, self, argc, argv);
}
示例10: rb_vm_set_current_mri_method_context
void
rb_vm_set_current_mri_method_context(VALUE self, SEL sel)
{
RoxorVM *vm = GET_VM();
vm->set_current_mri_method_self(self);
vm->set_current_mri_method_sel(sel);
}
示例11: require_compiled
VALUE require_compiled(VALUE fname, VALUE* result)
{
VALUE path;
char* szName = 0;
// FilePathValue(fname);
szName = RSTRING_PTR(fname);
RAWTRACE1("require_compiled: %s", szName);
rb_funcall(fname, rb_intern("sub!"), 2, rb_str_new2(".rb"), rb_str_new2("") );
if ( strcmp("strscan",szName)==0 || strcmp("enumerator",szName)==0 )
return Qtrue;
path = find_file(fname);
if ( path != 0 )
{
VALUE seq;
if ( isAlreadyLoaded(path) == Qtrue )
return Qtrue;
rb_ary_push(GET_VM()->loaded_features, path);
seq = loadISeqFromFile(path);
//*result = rb_funcall(seq, rb_intern("eval"), 0 );
*result = rb_iseq_eval(seq);
return Qtrue;
}
return Qnil;
}
示例12: get_loaded_features_index
static st_table *
get_loaded_features_index(void)
{
VALUE features;
int i;
rb_vm_t *vm = GET_VM();
if (!rb_ary_shared_with_p(vm->loaded_features_snapshot, vm->loaded_features)) {
/* The sharing was broken; something (other than us in rb_provide_feature())
modified loaded_features. Rebuild the index. */
st_foreach(vm->loaded_features_index, loaded_features_index_clear_i, 0);
features = vm->loaded_features;
for (i = 0; i < RARRAY_LEN(features); i++) {
VALUE entry, as_str;
as_str = entry = rb_ary_entry(features, i);
StringValue(as_str);
as_str = rb_fstring(rb_str_freeze(as_str));
if (as_str != entry)
rb_ary_store(features, i, as_str);
features_index_add(as_str, INT2FIX(i));
}
reset_loaded_features_snapshot();
}
return vm->loaded_features_index;
}
示例13: ruby_running
int
ruby_running()
{
if(GET_VM() != NULL)
return 1;
else
return 0;
}
示例14: rb_call_super
VALUE
rb_call_super(int argc, const VALUE *argv)
{
RoxorVM *vm = GET_VM();
VALUE self = vm->get_current_mri_method_self();
SEL sel = vm->get_current_mri_method_sel();
assert(self != 0 && sel != 0);
return rb_vm_call_super(self, sel, argc, argv);
}
示例15: Free_Mem
Free_Mem (Size, Block_A, Zone)
{
signed long
Status;
Status = LIB$GET_VM(Size, &Block_A, Zone) ;
XLOG$FAO(LOG$MEM,"!%T FREE_MEM: Status: !SL, Size: !SL, Addr: !SL, Zone: !SL!/",
0, Status, Size, Block_A, Zone) ;
Mem_Stat() ;
return (Status);
}