Squirrel

The programming language
Welcome to Squirrel Sign in | Join | Help
in Search

Variable Arguments in Closures

Last post 01-18-2010, 7:22 PM by localplayer. 0 replies.
Sort Posts: Previous Next
  •  01-18-2010, 7:22 PM 3618

    Variable Arguments in Closures

    Hi Alberto,

    We’ve extended the variable argument support in closures. If it’s possible can you fold it into squirrel.

    SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars)
    {
    SQObject o = stack_get(v, idx);
    if(sq_isclosure(o)) {
    SQClosure *c = _closure(o);
    SQFunctionProto *proto = _funcproto(c->_function);
    *nparams = (SQUnsignedInteger)proto->_nparameters;
    *nfreevars = (SQUnsignedInteger)c->_outervalues.size();
    return SQ_OK;
    } else if(sq_isnativeclosure(o)) {
    SQNativeClosure *c = _nativeclosure(o);
    *nparams = c->_nparamscheck;
    *nfreevars = 0;
    return SQ_OK;
    }

    return sq_throwerror(v,_SC("the object is not a closure"));
    }

    SQBool sq_getvarargs(HSQUIRRELVM v,SQInteger idx)
    {
    SQObject o = stack_get(v, idx);
    if(sq_isclosure(o)) {
    SQClosure *c = _closure(o);
    SQFunctionProto *proto = _funcproto(c->_function);
    return proto->_varparams;
    }

    return sq_throwerror(v,_SC("the object is not a closure"));
    }

    Chris.
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems