本文整理汇总了C++中GetProcPtr函数的典型用法代码示例。如果您正苦于以下问题:C++ GetProcPtr函数的具体用法?C++ GetProcPtr怎么用?C++ GetProcPtr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetProcPtr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: proc_call
static VALUE
proc_call(VALUE procval, SEL sel, int argc, const VALUE *argv)
{
#if 0
rb_proc_t *proc;
rb_block_t *blockptr = 0;
GetProcPtr(procval, proc);
if (BUILTIN_TYPE(proc->block.iseq) != T_NODE &&
proc->block.iseq->arg_block != -1) {
if (rb_block_given_p()) {
rb_proc_t *proc;
VALUE procval;
procval = rb_block_proc();
GetProcPtr(procval, proc);
blockptr = &proc->block;
}
}
return vm_invoke_proc(GET_THREAD(), proc, proc->block.self,
argc, argv, blockptr);
#endif
rb_vm_block_t *proc;
GetProcPtr(procval, proc);
return rb_vm_block_eval(proc, argc, argv);
}
示例2: proc_eq
static VALUE
proc_eq(VALUE self, SEL sel, VALUE other)
{
if (self == other) {
return Qtrue;
}
else if (rb_obj_is_kind_of(other, rb_cProc)) {
rb_vm_block_t *self_b, *other_b;
GetProcPtr(self, self_b);
GetProcPtr(other, other_b);
return self_b == other_b ? Qtrue : Qfalse;
}
return Qfalse;
}
示例3: proc_dup
static VALUE
proc_dup(VALUE self)
{
VALUE procval = proc_alloc(rb_cProc);
rb_proc_t *src, *dst;
GetProcPtr(self, src);
GetProcPtr(procval, dst);
dst->block = src->block;
dst->envval = src->envval;
dst->safe_level = dst->safe_level;
dst->special_cref_stack = src->special_cref_stack;
return procval;
}
示例4: rb_vm_make_proc
VALUE
rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass)
{
VALUE procval, envval, blockprocval = 0;
rb_proc_t *proc;
rb_control_frame_t *cfp = RUBY_VM_GET_CFP_FROM_BLOCK_PTR(block);
if (block->proc) {
rb_bug("rb_vm_make_proc: Proc value is already created.");
}
if (GC_GUARDED_PTR_REF(cfp->lfp[0])) {
rb_proc_t *p;
blockprocval = vm_make_proc_from_block(
th, (rb_block_t *)GC_GUARDED_PTR_REF(*cfp->lfp));
GetProcPtr(blockprocval, p);
*cfp->lfp = GC_GUARDED_PTR(&p->block);
}
envval = rb_vm_make_env_object(th, cfp);
if (PROCDEBUG) {
check_env_value(envval);
}
procval = rb_proc_alloc(klass);
GetProcPtr(procval, proc);
proc->blockprocval = blockprocval;
proc->block.self = block->self;
proc->block.lfp = block->lfp;
proc->block.dfp = block->dfp;
proc->block.iseq = block->iseq;
proc->block.proc = procval;
proc->envval = envval;
proc->safe_level = th->safe_level;
if (VMDEBUG) {
if (th->stack < block->dfp && block->dfp < th->stack + th->stack_size) {
rb_bug("invalid ptr: block->dfp");
}
if (th->stack < block->lfp && block->lfp < th->stack + th->stack_size) {
rb_bug("invalid ptr: block->lfp");
}
}
return procval;
}
示例5: proc_hash
static VALUE
proc_hash(VALUE self, SEL sel)
{
rb_vm_block_t *b;
GetProcPtr(self, b);
return LONG2FIX(b);
}
示例6: rb_proc_arity
int
rb_proc_arity(VALUE proc)
{
rb_vm_block_t *b;
GetProcPtr(proc, b);
return rb_vm_arity_n(b->arity);
}
示例7: proc_dup
static VALUE
proc_dup(VALUE self, SEL sel)
{
rb_vm_block_t *src;
GetProcPtr(self, src);
return Data_Wrap_Struct(CLASS_OF(self), NULL, NULL, src);
}
示例8: rb_proc_call_with_block
VALUE
rb_proc_call_with_block(VALUE self, int argc, VALUE *argv, VALUE pass_procval)
{
rb_proc_t *proc;
rb_block_t *block = 0;
GetProcPtr(self, proc);
if (!NIL_P(pass_procval)) {
rb_proc_t *pass_proc;
GetProcPtr(pass_procval, pass_proc);
block = &pass_proc->block;
}
return rb_vm_invoke_proc(GET_THREAD(), proc, proc->block.self,
argc, argv, block);
}
示例9: proc_yield
static VALUE
proc_yield(int argc, VALUE *argv, VALUE procval)
{
rb_proc_t *proc;
GetProcPtr(procval, proc);
return th_invoke_proc(GET_THREAD(), proc, proc->block.self, argc, argv);
}
示例10: proc_dump
/*
* call-seq:
* proc.dump(limit) => String
*
* Dump a Proc to a String.
*/
static VALUE proc_dump(VALUE self, VALUE limit)
{
if(rb_safe_level() >= 4)
{
/* no access to potentially sensitive data from the sandbox */
rb_raise(rb_eSecurityError, "Insecure: can't dump proc");
}
{
#ifdef RUBY_VM
rb_proc_t * p;
VALUE iseq, str;
rb_iseq_t * iseqdat;
GetProcPtr(self, p);
iseq = p->block.iseq->self;
iseqdat = iseq_check(iseq);
iseqdat->type = ISEQ_TYPE_TOP; /* TODO: is this right? */
str = marshal_dump(iseq, limit);
return str;
#else
struct BLOCK * b;
VALUE body, var, arr;
Data_Get_Struct(self, struct BLOCK, b);
body = wrap_node(b->body);
var = wrap_node(b->var);
arr = rb_assoc_new(body, var);
return marshal_dump(arr, limit);
#endif
}
}
示例11: proc_to_s
static VALUE
proc_to_s(VALUE self)
{
VALUE str = 0;
rb_proc_t *proc;
const char *cname = rb_obj_classname(self);
rb_iseq_t *iseq;
const char *is_lambda;
GetProcPtr(self, proc);
iseq = proc->block.iseq;
is_lambda = proc->is_lambda ? " (lambda)" : "";
if (RUBY_VM_NORMAL_ISEQ_P(iseq)) {
int line_no = 0;
if (iseq->insn_info_table) {
line_no = rb_iseq_first_lineno(iseq);
}
str = rb_sprintf("#<%s:%[email protected]%s:%d%s>", cname, (void *)self,
RSTRING_PTR(iseq->filename),
line_no, is_lambda);
}
else {
str = rb_sprintf("#<%s:%p%s>", cname, (void *)proc->block.iseq,
is_lambda);
}
if (OBJ_TAINTED(self)) {
OBJ_TAINT(str);
}
return str;
}
示例12: proc_arity
static VALUE
proc_arity(VALUE self)
{
rb_proc_t *proc;
rb_iseq_t *iseq;
GetProcPtr(self, proc);
iseq = proc->block.iseq;
if (iseq) {
if (BUILTIN_TYPE(iseq) != T_NODE) {
if (iseq->arg_rest < 0) {
return INT2FIX(iseq->argc);
}
else {
return INT2FIX(-(iseq->argc + 1 + iseq->arg_post_len));
}
}
else {
NODE *node = (NODE *)iseq;
if (nd_type(node) == NODE_IFUNC && node->nd_cfnc == bmcall) {
/* method(:foo).to_proc.arity */
return INT2FIX(method_arity(node->nd_tval));
}
}
}
return INT2FIX(-1);
}
示例13: proc_to_s
static VALUE
proc_to_s(VALUE self)
{
VALUE str = 0;
rb_proc_t *proc;
char *cname = rb_obj_classname(self);
rb_iseq_t *iseq;
GetProcPtr(self, proc);
iseq = proc->block.iseq;
if (RUBY_VM_NORMAL_ISEQ_P(iseq)) {
int line_no = 0;
if (iseq->insn_info_tbl) {
line_no = iseq->insn_info_tbl[0].line_no;
}
str = rb_sprintf("#<%s:%[email protected]%s:%d>", cname, self,
RSTRING_PTR(iseq->filename),
line_no);
}
else {
str = rb_sprintf("#<%s:%p>", cname, proc->block.iseq);
}
if (OBJ_TAINTED(self)) {
OBJ_TAINT(str);
}
return str;
}
示例14: proc_dup
static VALUE
proc_dup(VALUE self)
{
VALUE procval = rb_proc_alloc(rb_cProc);
rb_proc_t *src, *dst;
GetProcPtr(self, src);
GetProcPtr(procval, dst);
dst->block = src->block;
dst->block.proc = procval;
dst->envval = src->envval;
dst->safe_level = src->safe_level;
dst->is_lambda = src->is_lambda;
return procval;
}
示例15: trap_handler
static sighandler_t
trap_handler(VALUE *cmd, int sig)
{
sighandler_t func = sighandler;
VALUE command;
if (NIL_P(*cmd)) {
func = SIG_IGN;
}
else {
command = rb_check_string_type(*cmd);
if (!NIL_P(command)) {
SafeStringValue(command); /* taint check */
*cmd = command;
switch (RSTRING_LEN(command)) {
case 0:
goto sig_ign;
break;
case 14:
if (strncmp(RSTRING_PTR(command), "SYSTEM_DEFAULT", 14) == 0) {
func = SIG_DFL;
*cmd = 0;
}
break;
case 7:
if (strncmp(RSTRING_PTR(command), "SIG_IGN", 7) == 0) {
sig_ign:
func = SIG_IGN;
*cmd = 0;
}
else if (strncmp(RSTRING_PTR(command), "SIG_DFL", 7) == 0) {
sig_dfl:
func = default_handler(sig);
*cmd = 0;
}
else if (strncmp(RSTRING_PTR(command), "DEFAULT", 7) == 0) {
goto sig_dfl;
}
break;
case 6:
if (strncmp(RSTRING_PTR(command), "IGNORE", 6) == 0) {
goto sig_ign;
}
break;
case 4:
if (strncmp(RSTRING_PTR(command), "EXIT", 4) == 0) {
*cmd = Qundef;
}
break;
}
}
else {
rb_proc_t *proc;
GetProcPtr(*cmd, proc);
}
}
return func;
}