本文整理汇总了C++中rb_funcall2函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_funcall2函数的具体用法?C++ rb_funcall2怎么用?C++ rb_funcall2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_funcall2函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ts_each
//
// From Guy Decoux [ruby-talk:144098]
//
static VALUE ts_each(VALUE *tmp) {
return rb_funcall2(tmp[0], (ID)tmp[1], (int)tmp[2], (VALUE *)tmp[3]);
}
开发者ID:Shoes3,项目名称:shoes3,代码行数:6,代码来源:ruby.c
示例2: evalHelper
static VALUE evalHelper(evalArg *arg)
{
VALUE argv[] = { arg->string, Qnil, arg->filename };
return rb_funcall2(Qnil, rb_intern("eval"), ARRAY_SIZE(argv), argv);
}
开发者ID:Ancurio,项目名称:mkxp-abs,代码行数:5,代码来源:binding-mri.cpp
示例3: nucomp_f_complex
/*
* call-seq:
* Complex(x[, y]) -> numeric
*
* Returns x+i*y;
*/
static VALUE
nucomp_f_complex(int argc, VALUE *argv, VALUE klass)
{
return rb_funcall2(rb_cComplex, id_convert, argc, argv);
}
开发者ID:nikuuchi,项目名称:oreore_ruby,代码行数:11,代码来源:complex.c
示例4: callback_invoke
static void
callback_invoke(ffi_cif* cif, void* retval, void** parameters, void* user_data)
{
Closure* closure = (Closure *) user_data;
Function* fn = (Function *) closure->info;
FunctionType *cbInfo = fn->info;
VALUE* rbParams;
VALUE rbReturnValue;
int i;
rbParams = ALLOCA_N(VALUE, cbInfo->parameterCount);
for (i = 0; i < cbInfo->parameterCount; ++i) {
VALUE param;
switch (cbInfo->parameterTypes[i]->nativeType) {
case NATIVE_INT8:
param = INT2NUM(*(int8_t *) parameters[i]);
break;
case NATIVE_UINT8:
param = UINT2NUM(*(uint8_t *) parameters[i]);
break;
case NATIVE_INT16:
param = INT2NUM(*(int16_t *) parameters[i]);
break;
case NATIVE_UINT16:
param = UINT2NUM(*(uint16_t *) parameters[i]);
break;
case NATIVE_INT32:
param = INT2NUM(*(int32_t *) parameters[i]);
break;
case NATIVE_UINT32:
param = UINT2NUM(*(uint32_t *) parameters[i]);
break;
case NATIVE_INT64:
param = LL2NUM(*(int64_t *) parameters[i]);
break;
case NATIVE_UINT64:
param = ULL2NUM(*(uint64_t *) parameters[i]);
break;
case NATIVE_LONG:
param = LONG2NUM(*(long *) parameters[i]);
break;
case NATIVE_ULONG:
param = ULONG2NUM(*(unsigned long *) parameters[i]);
break;
case NATIVE_FLOAT32:
param = rb_float_new(*(float *) parameters[i]);
break;
case NATIVE_FLOAT64:
param = rb_float_new(*(double *) parameters[i]);
break;
case NATIVE_STRING:
param = (*(void **) parameters[i] != NULL) ? rb_tainted_str_new2(*(char **) parameters[i]) : Qnil;
break;
case NATIVE_POINTER:
param = rbffi_Pointer_NewInstance(*(void **) parameters[i]);
break;
case NATIVE_BOOL:
param = (*(uint8_t *) parameters[i]) ? Qtrue : Qfalse;
break;
case NATIVE_FUNCTION:
case NATIVE_CALLBACK:
param = rbffi_NativeValue_ToRuby(cbInfo->parameterTypes[i],
rb_ary_entry(cbInfo->rbParameterTypes, i), parameters[i], Qnil);
break;
default:
param = Qnil;
break;
}
rbParams[i] = param;
}
rbReturnValue = rb_funcall2(fn->rbProc, id_call, cbInfo->parameterCount, rbParams);
if (rbReturnValue == Qnil || TYPE(rbReturnValue) == T_NIL) {
memset(retval, 0, cbInfo->ffiReturnType->size);
} else switch (cbInfo->returnType->nativeType) {
case NATIVE_INT8:
case NATIVE_INT16:
case NATIVE_INT32:
*((ffi_sarg *) retval) = NUM2INT(rbReturnValue);
break;
case NATIVE_UINT8:
case NATIVE_UINT16:
case NATIVE_UINT32:
*((ffi_arg *) retval) = NUM2UINT(rbReturnValue);
break;
case NATIVE_INT64:
*((int64_t *) retval) = NUM2LL(rbReturnValue);
break;
case NATIVE_UINT64:
*((uint64_t *) retval) = NUM2ULL(rbReturnValue);
break;
case NATIVE_LONG:
*((ffi_sarg *) retval) = NUM2LONG(rbReturnValue);
break;
case NATIVE_ULONG:
*((ffi_arg *) retval) = NUM2ULONG(rbReturnValue);
break;
case NATIVE_FLOAT32:
*((float *) retval) = (float) NUM2DBL(rbReturnValue);
break;
//.........这里部分代码省略.........
开发者ID:Jefers,项目名称:saffron_app,代码行数:101,代码来源:Function.c
示例5: variadic_initialize
static VALUE
variadic_initialize(VALUE self, VALUE rbFunction, VALUE rbParameterTypes, VALUE rbReturnType, VALUE options)
{
VariadicInvoker* invoker = NULL;
VALUE retval = Qnil;
VALUE convention = Qnil;
VALUE fixed = Qnil;
#if defined(X86_WIN32)
VALUE rbConventionStr;
#endif
int i;
Check_Type(options, T_HASH);
convention = rb_hash_aref(options, ID2SYM(rb_intern("convention")));
Data_Get_Struct(self, VariadicInvoker, invoker);
invoker->rbEnums = rb_hash_aref(options, ID2SYM(rb_intern("enums")));
invoker->rbAddress = rbFunction;
invoker->function = rbffi_AbstractMemory_Cast(rbFunction, rbffi_PointerClass)->address;
#if defined(X86_WIN32)
rbConventionStr = rb_funcall2(convention, rb_intern("to_s"), 0, NULL);
invoker->abi = (RTEST(convention) && strcmp(StringValueCStr(rbConventionStr), "stdcall") == 0)
? FFI_STDCALL : FFI_DEFAULT_ABI;
#else
invoker->abi = FFI_DEFAULT_ABI;
#endif
invoker->rbReturnType = rbffi_Type_Lookup(rbReturnType);
if (!RTEST(invoker->rbReturnType)) {
VALUE typeName = rb_funcall2(rbReturnType, rb_intern("inspect"), 0, NULL);
rb_raise(rb_eTypeError, "Invalid return type (%s)", RSTRING_PTR(typeName));
}
Data_Get_Struct(rbReturnType, Type, invoker->returnType);
invoker->paramCount = -1;
fixed = rb_ary_new2(RARRAY_LEN(rbParameterTypes) - 1);
for (i = 0; i < RARRAY_LEN(rbParameterTypes); ++i) {
VALUE entry = rb_ary_entry(rbParameterTypes, i);
VALUE rbType = rbffi_Type_Lookup(entry);
Type* type;
if (!RTEST(rbType)) {
VALUE typeName = rb_funcall2(entry, rb_intern("inspect"), 0, NULL);
rb_raise(rb_eTypeError, "Invalid parameter type (%s)", RSTRING_PTR(typeName));
}
Data_Get_Struct(rbType, Type, type);
if (type->nativeType != NATIVE_VARARGS) {
rb_ary_push(fixed, entry);
}
}
/*
* @fixed and @type_map are used by the parameter mangling ruby code
*/
rb_iv_set(self, "@fixed", fixed);
rb_iv_set(self, "@type_map", rb_hash_aref(options, ID2SYM(rb_intern("type_map"))));
return retval;
}
开发者ID:robenkleene,项目名称:webconsole,代码行数:61,代码来源:Variadic.c
示例6: eval_expression
static VALUE
eval_expression(VALUE args)
{
return rb_funcall2(rb_mKernel, idEval, 2, RARRAY_PTR(args));
}
开发者ID:Achieve-development,项目名称:achieve,代码行数:5,代码来源:breakpoint.c
示例7: rb_digest_class_s_bubblebabble
/*
* call-seq:
* Digest::Class.bubblebabble(string, ...) -> hash_string
*
* Returns the BubbleBabble encoded hash value of a given _string_.
*/
static VALUE
rb_digest_class_s_bubblebabble(int argc, VALUE *argv, VALUE klass)
{
return bubblebabble_str_new(rb_funcall2(klass, id_digest, argc, argv));
}
开发者ID:No-Inoue,项目名称:ruby-1.8.7-p374-centos_openssl,代码行数:11,代码来源:bubblebabble.c
示例8: rbffi_NativeValue_ToRuby
VALUE
rbffi_NativeValue_ToRuby(Type* type, VALUE rbType, const void* ptr)
{
switch (type->nativeType) {
case NATIVE_VOID:
return Qnil;
case NATIVE_INT8:
return INT2NUM((signed char) *(ffi_sarg *) ptr);
case NATIVE_INT16:
return INT2NUM((signed short) *(ffi_sarg *) ptr);
case NATIVE_INT32:
return INT2NUM((signed int) *(ffi_sarg *) ptr);
case NATIVE_LONG:
return LONG2NUM((signed long) *(ffi_sarg *) ptr);
case NATIVE_INT64:
return LL2NUM(*(signed long long *) ptr);
case NATIVE_UINT8:
return UINT2NUM((unsigned char) *(ffi_arg *) ptr);
case NATIVE_UINT16:
return UINT2NUM((unsigned short) *(ffi_arg *) ptr);
case NATIVE_UINT32:
return UINT2NUM((unsigned int) *(ffi_arg *) ptr);
case NATIVE_ULONG:
return ULONG2NUM((unsigned long) *(ffi_arg *) ptr);
case NATIVE_UINT64:
return ULL2NUM(*(unsigned long long *) ptr);
case NATIVE_FLOAT32:
return rb_float_new(*(float *) ptr);
case NATIVE_FLOAT64:
return rb_float_new(*(double *) ptr);
case NATIVE_LONGDOUBLE:
return rbffi_longdouble_new(*(long double *) ptr);
case NATIVE_STRING:
return (*(void **) ptr != NULL) ? rb_tainted_str_new2(*(char **) ptr) : Qnil;
case NATIVE_POINTER:
return rbffi_Pointer_NewInstance(*(void **) ptr);
case NATIVE_BOOL:
return ((unsigned char) *(ffi_arg *) ptr) ? Qtrue : Qfalse;
case NATIVE_FUNCTION:
case NATIVE_CALLBACK: {
return *(void **) ptr != NULL
? rbffi_Function_NewInstance(rbType, rbffi_Pointer_NewInstance(*(void **) ptr))
: Qnil;
}
case NATIVE_STRUCT: {
StructByValue* sbv = (StructByValue *)type;
AbstractMemory* mem;
VALUE rbMemory = rbffi_MemoryPointer_NewInstance(1, sbv->base.ffiType->size, false);
Data_Get_Struct(rbMemory, AbstractMemory, mem);
memcpy(mem->address, ptr, sbv->base.ffiType->size);
RB_GC_GUARD(rbMemory);
RB_GC_GUARD(rbType);
return rb_class_new_instance(1, &rbMemory, sbv->rbStructClass);
}
case NATIVE_MAPPED: {
/*
* For mapped types, first convert to the real native type, then upcall to
* ruby to convert to the expected return type
*/
MappedType* m = (MappedType *) type;
VALUE values[2], rbReturnValue;
values[0] = rbffi_NativeValue_ToRuby(m->type, m->rbType, ptr);
values[1] = Qnil;
rbReturnValue = rb_funcall2(m->rbConverter, id_from_native, 2, values);
RB_GC_GUARD(values[0]);
RB_GC_GUARD(rbType);
return rbReturnValue;
}
default:
rb_raise(rb_eRuntimeError, "Unknown type: %d", type->nativeType);
return Qnil;
}
}
开发者ID:SFEley,项目名称:ffi,代码行数:87,代码来源:Types.c
示例9: _safe_call_func
/**
* this function will safely be executed (gvl acquired)
* this should not create a blocking/bottleneck situation since the access to rb_mKernel is
* mutex-protected by proxenet before
*
*
*/
static void* _safe_call_func(void* arg)
{
struct proxenet_ruby_args* args = (struct proxenet_ruby_args*) arg;
VALUE rRet = rb_funcall2(args->rVM, args->rFunc, 3, args->rArgs);
return (void*)rRet;
}
开发者ID:thorgul,项目名称:proxenet,代码行数:13,代码来源:plugin-ruby.c
示例10: rb_digest_class_s_hexdigest
/*
* call-seq:
* Digest::Class.hexdigest(string[, ...]) -> hash_string
*
* Returns the hex-encoded hash value of a given _string_. This is
* almost equivalent to
* Digest.hexencode(Digest::Class.new(*parameters).digest(string)).
*/
static VALUE
rb_digest_class_s_hexdigest(int argc, VALUE *argv, VALUE klass)
{
return hexencode_str_new(rb_funcall2(klass, id_digest, argc, argv));
}
开发者ID:DashYang,项目名称:sim,代码行数:13,代码来源:digest.c
示例11: fntype_initialize
static VALUE
fntype_initialize(int argc, VALUE* argv, VALUE self)
{
FunctionType *fnInfo;
ffi_status status;
VALUE rbReturnType = Qnil, rbParamTypes = Qnil, rbOptions = Qnil;
VALUE rbEnums = Qnil, rbConvention = Qnil, rbBlocking = Qnil;
#if defined(_WIN32) || defined(__WIN32__)
VALUE rbConventionStr;
#endif
int i, nargs;
nargs = rb_scan_args(argc, argv, "21", &rbReturnType, &rbParamTypes, &rbOptions);
if (nargs >= 3 && rbOptions != Qnil) {
rbConvention = rb_hash_aref(rbOptions, ID2SYM(rb_intern("convention")));
rbEnums = rb_hash_aref(rbOptions, ID2SYM(rb_intern("enums")));
rbBlocking = rb_hash_aref(rbOptions, ID2SYM(rb_intern("blocking")));
}
Check_Type(rbParamTypes, T_ARRAY);
Data_Get_Struct(self, FunctionType, fnInfo);
fnInfo->parameterCount = (int) RARRAY_LEN(rbParamTypes);
fnInfo->parameterTypes = xcalloc(fnInfo->parameterCount, sizeof(*fnInfo->parameterTypes));
fnInfo->ffiParameterTypes = xcalloc(fnInfo->parameterCount, sizeof(ffi_type *));
fnInfo->nativeParameterTypes = xcalloc(fnInfo->parameterCount, sizeof(*fnInfo->nativeParameterTypes));
fnInfo->rbParameterTypes = rb_ary_new2(fnInfo->parameterCount);
fnInfo->rbEnums = rbEnums;
fnInfo->blocking = RTEST(rbBlocking);
fnInfo->hasStruct = false;
for (i = 0; i < fnInfo->parameterCount; ++i) {
VALUE entry = rb_ary_entry(rbParamTypes, i);
VALUE type = rbffi_Type_Lookup(entry);
if (!RTEST(type)) {
VALUE typeName = rb_funcall2(entry, rb_intern("inspect"), 0, NULL);
rb_raise(rb_eTypeError, "Invalid parameter type (%s)", RSTRING_PTR(typeName));
}
if (rb_obj_is_kind_of(type, rbffi_FunctionTypeClass)) {
REALLOC_N(fnInfo->callbackParameters, VALUE, fnInfo->callbackCount + 1);
fnInfo->callbackParameters[fnInfo->callbackCount++] = type;
}
if (rb_obj_is_kind_of(type, rbffi_StructByValueClass)) {
fnInfo->hasStruct = true;
}
rb_ary_push(fnInfo->rbParameterTypes, type);
Data_Get_Struct(type, Type, fnInfo->parameterTypes[i]);
fnInfo->ffiParameterTypes[i] = fnInfo->parameterTypes[i]->ffiType;
fnInfo->nativeParameterTypes[i] = fnInfo->parameterTypes[i]->nativeType;
}
fnInfo->rbReturnType = rbffi_Type_Lookup(rbReturnType);
if (!RTEST(fnInfo->rbReturnType)) {
VALUE typeName = rb_funcall2(rbReturnType, rb_intern("inspect"), 0, NULL);
rb_raise(rb_eTypeError, "Invalid return type (%s)", RSTRING_PTR(typeName));
}
if (rb_obj_is_kind_of(fnInfo->rbReturnType, rbffi_StructByValueClass)) {
fnInfo->hasStruct = true;
}
Data_Get_Struct(fnInfo->rbReturnType, Type, fnInfo->returnType);
fnInfo->ffiReturnType = fnInfo->returnType->ffiType;
#if defined(_WIN32) || defined(__WIN32__)
rbConventionStr = (rbConvention != Qnil) ? rb_funcall2(rbConvention, rb_intern("to_s"), 0, NULL) : Qnil;
fnInfo->abi = (rbConventionStr != Qnil && strcmp(StringValueCStr(rbConventionStr), "stdcall") == 0)
? FFI_STDCALL : FFI_DEFAULT_ABI;
#else
fnInfo->abi = FFI_DEFAULT_ABI;
#endif
status = ffi_prep_cif(&fnInfo->ffi_cif, fnInfo->abi, fnInfo->parameterCount,
fnInfo->ffiReturnType, fnInfo->ffiParameterTypes);
switch (status) {
case FFI_BAD_ABI:
rb_raise(rb_eArgError, "Invalid ABI specified");
case FFI_BAD_TYPEDEF:
rb_raise(rb_eArgError, "Invalid argument type specified");
case FFI_OK:
break;
default:
rb_raise(rb_eArgError, "Unknown FFI error");
}
fnInfo->invoke = rbffi_GetInvoker(fnInfo);
return self;
}
开发者ID:amarburg,项目名称:ffi,代码行数:94,代码来源:FunctionInfo.c
示例12: rbclt_callback_func_invoke
VALUE
rbclt_callback_func_invoke (RBCLTCallbackFunc *func, int arg_count,
const VALUE *argv)
{
return rb_funcall2 (func->proc, id_call, arg_count, argv);
}
开发者ID:orospakr,项目名称:rbclutter,代码行数:6,代码来源:rbcltcallbackfunc.c
示例13: FunCallWrap
/**
* Call a ruby function with parameters
*
* @arg the callback structure
* @return the value returned the called ruby function
*/
VALUE FunCallWrap(VALUE rdata) {
struct my_callback* data = (struct my_callback*) rdata;
return rb_funcall2(data->obj,data->method_id,data->nargs,data->args);
}
开发者ID:OSGeo,项目名称:zoo-project,代码行数:10,代码来源:service_internal_ruby.c
示例14: pkcs11_library_new
static VALUE
pkcs11_library_new(int argc, VALUE *argv, VALUE self)
{
return rb_funcall2(cPKCS11, sNEW, argc, argv);
}
开发者ID:cprice404,项目名称:pkcs11,代码行数:5,代码来源:pk11.c
示例15: rbffi_SetupCallParams
void
rbffi_SetupCallParams(int argc, VALUE* argv, int paramCount, Type** paramTypes,
FFIStorage* paramStorage, void** ffiValues,
VALUE* callbackParameters, int callbackCount, VALUE enums)
{
VALUE callbackProc = Qnil;
FFIStorage* param = ¶mStorage[0];
int i, argidx, cbidx, argCount;
if (unlikely(paramCount != -1 && paramCount != argc)) {
if (argc == (paramCount - 1) && callbackCount == 1 && rb_block_given_p()) {
callbackProc = rb_block_proc();
} else {
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", argc, paramCount);
}
}
argCount = paramCount != -1 ? paramCount : argc;
for (i = 0, argidx = 0, cbidx = 0; i < argCount; ++i) {
Type* paramType = paramTypes[i];
int type;
if (unlikely(paramType->nativeType == NATIVE_MAPPED)) {
VALUE values[] = { argv[argidx], Qnil };
argv[argidx] = rb_funcall2(((MappedType *) paramType)->rbConverter, id_to_native, 2, values);
paramType = ((MappedType *) paramType)->type;
}
type = argidx < argc ? TYPE(argv[argidx]) : T_NONE;
ffiValues[i] = param;
switch (paramType->nativeType) {
case NATIVE_INT8:
param->s8 = NUM2INT(argv[argidx]);
++argidx;
ADJ(param, INT8);
break;
case NATIVE_INT16:
param->s16 = NUM2INT(argv[argidx]);
++argidx;
ADJ(param, INT16);
break;
case NATIVE_INT32:
if (unlikely(type == T_SYMBOL && enums != Qnil)) {
VALUE value = rb_funcall(enums, id_map_symbol, 1, argv[argidx]);
param->s32 = NUM2INT(value);
} else {
param->s32 = NUM2INT(argv[argidx]);
}
++argidx;
ADJ(param, INT32);
break;
case NATIVE_BOOL:
if (type != T_TRUE && type != T_FALSE) {
rb_raise(rb_eTypeError, "wrong argument type (expected a boolean parameter)");
}
param->s8 = argv[argidx++] == Qtrue;
ADJ(param, INT8);
break;
case NATIVE_UINT8:
param->u8 = NUM2UINT(argv[argidx]);
ADJ(param, INT8);
++argidx;
break;
case NATIVE_UINT16:
param->u16 = NUM2UINT(argv[argidx]);
ADJ(param, INT16);
++argidx;
break;
case NATIVE_UINT32:
param->u32 = NUM2UINT(argv[argidx]);
ADJ(param, INT32);
++argidx;
break;
case NATIVE_INT64:
param->i64 = NUM2LL(argv[argidx]);
ADJ(param, INT64);
++argidx;
break;
//.........这里部分代码省略.........
开发者ID:JackCameo,项目名称:sample_app,代码行数:101,代码来源:Call.c
示例16: vm_call_method
static inline VALUE
vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp,
int num, const rb_block_t *blockptr, VALUE flag,
ID id, const rb_method_entry_t *me, VALUE recv)
{
VALUE val;
start_method_dispatch:
if (me != 0) {
if ((me->flag == 0)) {
normal_method_dispatch:
switch (me->def->type) {
case VM_METHOD_TYPE_ISEQ:{
vm_setup_method(th, cfp, recv, num, blockptr, flag, me);
return Qundef;
}
case VM_METHOD_TYPE_NOTIMPLEMENTED:
case VM_METHOD_TYPE_CFUNC:{
val = vm_call_cfunc(th, cfp, num, recv, blockptr, me);
break;
}
case VM_METHOD_TYPE_ATTRSET:{
if (num != 1) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", num);
}
val = rb_ivar_set(recv, me->def->body.attr.id, *(cfp->sp - 1));
cfp->sp -= 2;
break;
}
case VM_METHOD_TYPE_IVAR:{
if (num != 0) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", num);
}
val = rb_attr_get(recv, me->def->body.attr.id);
cfp->sp -= 1;
break;
}
case VM_METHOD_TYPE_MISSING:{
VALUE *argv = ALLOCA_N(VALUE, num+1);
argv[0] = ID2SYM(me->def->original_id);
MEMCPY(argv+1, cfp->sp - num, VALUE, num);
cfp->sp += - num - 1;
th->passed_block = blockptr;
val = rb_funcall2(recv, rb_intern("method_missing"), num+1, argv);
break;
}
case VM_METHOD_TYPE_BMETHOD:{
VALUE *argv = ALLOCA_N(VALUE, num);
MEMCPY(argv, cfp->sp - num, VALUE, num);
cfp->sp += - num - 1;
val = vm_call_bmethod(th, recv, num, argv, blockptr, me);
break;
}
case VM_METHOD_TYPE_ZSUPER:{
VALUE klass = RCLASS_SUPER(me->klass);
me = rb_method_entry(klass, id);
if (me != 0) {
goto normal_method_dispatch;
}
else {
goto start_method_dispatch;
}
}
case VM_METHOD_TYPE_OPTIMIZED:{
switch (me->def->body.optimize_type) {
case OPTIMIZED_METHOD_TYPE_SEND: {
rb_control_frame_t *reg_cfp = cfp;
rb_num_t i = num - 1;
VALUE sym;
if (num == 0) {
rb_raise(rb_eArgError, "no method name given");
}
sym = TOPN(i);
id = SYMBOL_P(sym) ? SYM2ID(sym) : rb_to_id(sym);
/* shift arguments */
if (i > 0) {
MEMMOVE(&TOPN(i), &TOPN(i-1), VALUE, i);
}
me = rb_method_entry(CLASS_OF(recv), id);
num -= 1;
DEC_SP(1);
flag |= VM_CALL_FCALL_BIT | VM_CALL_OPT_SEND_BIT;
goto start_method_dispatch;
}
case OPTIMIZED_METHOD_TYPE_CALL: {
rb_proc_t *proc;
int argc = num;
VALUE *argv = ALLOCA_N(VALUE, num);
GetProcPtr(recv, proc);
MEMCPY(argv, cfp->sp - num, VALUE, num);
cfp->sp -= num + 1;
val = rb_vm_invoke_proc(th, proc, proc->block.self, argc, argv, blockptr);
break;
}
//.........这里部分代码省略.........
开发者ID:MosesMendoza,项目名称:crossfader,代码行数:101,代码来源:vm_insnhelper.c
示例17: lp_respond_to_missing
static VALUE lp_respond_to_missing(int argc, VALUE* argv, VALUE self) {
VALUE obj = lp_get_resolv(self);
return rb_funcall2(obj, id_respond_to, argc, argv);
}
开发者ID:mavax,项目名称:lazy_proxy,代码行数:5,代码来源:lazy_proxy.c
示例18: lazy_flat_map_i
static VALUE
lazy_flat_map_i(VALUE i, VALUE yielder, int argc, VALUE *argv)
{
return rb_funcall2(yielder, id_yield, argc, argv);
}
开发者ID:takuto-h,项目名称:ruby,代码行数:5,代码来源:enumerator.c
示例19: bdb_deleg_each
static VALUE
bdb_deleg_each(VALUE *tmp)
{
return rb_funcall2(tmp[0], id_send, (int)tmp[1], (VALUE *)tmp[2]);
}
开发者ID:knu,项目名称:ruby-bdb,代码行数:5,代码来源:delegator.c
示例20: ruby_funcall
static void ruby_funcall(xmlXPathParserContextPtr ctx, int nargs)
{
VALUE xpath_handler = Qnil;
VALUE result;
VALUE *argv;
VALUE doc;
VALUE node_set = Qnil;
xmlNodeSetPtr xml_node_set = NULL;
xmlXPathObjectPtr obj;
int i;
nokogiriNodeSetTuple *node_set_tuple;
assert(ctx);
assert(ctx->context);
assert(ctx->context->userData);
assert(ctx->context->doc);
assert(DOC_RUBY_OBJECT_TEST(ctx->context->doc));
xpath_handler = (VALUE)(ctx->context->userData);
argv = (VALUE *)calloc((size_t)nargs, sizeof(VALUE));
for (i = 0 ; i < nargs ; ++i) {
rb_gc_register_address(&argv[i]);
}
doc = DOC_RUBY_OBJECT(ctx->context->doc);
if (nargs > 0) {
i = nargs - 1;
do {
obj = valuePop(ctx);
switch(obj->type) {
case XPATH_STRING:
argv[i] = NOKOGIRI_STR_NEW2(obj->stringval);
break;
case XPATH_BOOLEAN:
argv[i] = obj->boolval == 1 ? Qtrue : Qfalse;
break;
case XPATH_NUMBER:
argv[i] = rb_float_new(obj->floatval);
break;
case XPATH_NODESET:
argv[i] = Nokogiri_wrap_xml_node_set(obj->nodesetval, doc);
break;
default:
argv[i] = NOKOGIRI_STR_NEW2(xmlXPathCastToString(obj));
}
xmlXPathFreeNodeSetList(obj);
} while(i-- > 0);
}
result = rb_funcall2(
xpath_handler,
rb_intern((const char *)ctx->context->function),
nargs,
argv
);
for (i = 0 ; i < nargs ; ++i) {
rb_gc_unregister_address(&argv[i]);
}
free(argv);
switch(TYPE(result)) {
case T_FLOAT:
case T_BIGNUM:
case T_FIXNUM:
xmlXPathReturnNumber(ctx, NUM2DBL(result));
break;
case T_STRING:
xmlXPathReturnString(
ctx,
(xmlChar *)xmlXPathWrapCString(StringValuePtr(result))
);
break;
case T_TRUE:
xmlXPathReturnTrue(ctx);
break;
case T_FALSE:
xmlXPathReturnFalse(ctx);
break;
case T_NIL:
break;
case T_ARRAY:
{
VALUE args[2];
args[0] = doc;
args[1] = result;
node_set = rb_class_new_instance(2, args, cNokogiriXmlNodeSet);
Data_Get_Struct(node_set, nokogiriNodeSetTuple, node_set_tuple);
xml_node_set = node_set_tuple->node_set;
xmlXPathReturnNodeSet(ctx, xmlXPathNodeSetMerge(NULL, xml_node_set));
}
break;
case T_DATA:
if(rb_obj_is_kind_of(result, cNokogiriXmlNodeSet)) {
Data_Get_Struct(result, nokogiriNodeSetTuple, node_set_tuple);
xml_node_set = node_set_tuple->node_set;
/* Copy the node set, otherwise it will get GC'd. */
xmlXPathReturnNodeSet(ctx, xmlXPathNodeSetMerge(NULL, xml_node_set));
//.........这里部分代码省略.........
开发者ID:railsfactory-biswajitsahoo,项目名称:nokogiri,代码行数:101,代码来源:xml_xpath_context.c
注:本文中的rb_funcall2函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论