本文整理汇总了C++中Arguments::get_argument方法的典型用法代码示例。如果您正苦于以下问题:C++ Arguments::get_argument方法的具体用法?C++ Arguments::get_argument怎么用?C++ Arguments::get_argument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arguments
的用法示例。
在下文中一共展示了Arguments::get_argument方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unpack_arguments
void Fiber::unpack_arguments(STATE, Arguments& args) {
switch(args.total()) {
case 0:
state->vm()->thread()->fiber_value(state, cNil);
break;
case 1:
state->vm()->thread()->fiber_value(state, args.get_argument(0));
break;
default:
state->vm()->thread()->fiber_value(state, args.as_array(state));
break;
}
}
示例2: rbx_destructure_args
int rbx_destructure_args(STATE, CallFrame* call_frame, Arguments& args) {
Object* obj = args.get_argument(0);
Array* ary = 0;
if(!(ary = try_as<Array>(obj))) {
if(CBOOL(obj->respond_to(state, G(sym_to_ary), cFalse))) {
if(!(obj = obj->send(state, call_frame, G(sym_to_ary)))) {
return -1;
}
if(!(ary = try_as<Array>(obj)) && !obj->nil_p()) {
Exception::type_error(state, "to_ary must return an Array", call_frame);
return -1;
}
}
}
if(ary) {
args.use_array(ary);
}
return args.total();
}
示例3: call
//.........这里部分代码省略.........
/* TODO: Clean up usage to uniformly refer to 'splat' as N arguments
* passed from sender at a single position and 'rest' as N arguments
* collected into a single argument at the receiver.
*/
const native_int RI = mcode->splat_position;
const bool RP = (RI >= 0);
// expecting 0, got 0.
if(T == 0 && N == 0) {
if(RP) {
scope->set_local(mcode->splat_position, Array::create(state, 0));
}
return true;
}
const bool lambda = ((flags & CallFrame::cIsLambda) == CallFrame::cIsLambda);
// Only do destructuring in non-lambda mode
if(!lambda) {
/* If only one argument was yielded and the block takes more than one
* argument or has form { |a, | }:
*
* 1. If the object is an Array, assign elements to arguments.
* 2. If the object returns 'nil' from #to_ary, assign the object
* to the first argument.
* 3. If the object returns an Array from #to_ary, assign the
* elements to the arguments.
* 4. If the object returns non-Array from #to_ary, raise a TypeError.
*/
if(N == 1 && (T > 1 || (RP && T > 0) || RI < -2)) {
Object* obj = args.get_argument(0);
Array* ary = 0;
if(!(ary = try_as<Array>(obj))) {
if(CBOOL(obj->respond_to(state, G(sym_to_ary), cFalse))) {
if(!(obj = obj->send(state, call_frame, G(sym_to_ary)))) {
return false;
}
if(!(ary = try_as<Array>(obj)) && !obj->nil_p()) {
Exception::type_error(state, "to_ary must return an Array", call_frame);
return false;
}
}
}
if(ary) {
if(RI == -4 && M == 1) {
args.use_argument(ary);
} else {
args.use_array(ary);
}
N = args.total();
}
}
}
const native_int P = mcode->post_args;
const native_int H = M - P;
// Too many args (no rest argument!)
if(!RP && N > T) {