本文整理汇总了C++中HSQUIRRELVM::Push方法的典型用法代码示例。如果您正苦于以下问题:C++ HSQUIRRELVM::Push方法的具体用法?C++ HSQUIRRELVM::Push怎么用?C++ HSQUIRRELVM::Push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HSQUIRRELVM
的用法示例。
在下文中一共展示了HSQUIRRELVM::Push方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: array_reduce
static SQInteger array_reduce(HSQUIRRELVM v)
{
SQObject &o = stack_get(v,1);
SQArray *a = _array(o);
SQInteger size = a->Size();
if(size == 0) {
return 0;
}
SQObjectPtr res;
a->Get(0,res);
if(size > 1) {
SQObjectPtr other;
for(SQInteger n = 1; n < size; n++) {
a->Get(n,other);
v->Push(o);
v->Push(res);
v->Push(other);
if(SQ_FAILED(sq_call(v,3,SQTrue,SQFalse))) {
return SQ_ERROR;
}
res = v->GetUp(-1);
v->Pop();
}
}
v->Push(res);
return 1;
}
示例2: default_delegate_tointeger
static SQInteger default_delegate_tointeger(HSQUIRRELVM v)
{
SQObjectPtr &o=stack_get(v,1);
switch(type(o)) {
case OT_STRING: {
SQObjectPtr res;
if(str2num(_stringval(o),res)) {
v->Push(SQObjectPtr(tointeger(res)));
break;
}
}
return sq_throwerror(v, _SC("cannot convert the string"));
break;
case OT_INTEGER:
case OT_FLOAT:
v->Push(SQObjectPtr(tointeger(o)));
break;
case OT_BOOL:
v->Push(SQObjectPtr(_integer(o)?(SQInteger)1:(SQInteger)0));
break;
default:
v->Push(_null_);
break;
}
return 1;
}
示例3: _closure_acall
static SQInteger _closure_acall(HSQUIRRELVM v,SQBool raiseerror)
{
SQArray *aparams=_array(stack_get(v,2));
SQInteger nparams=aparams->Size();
v->Push(stack_get(v,1));
for(SQInteger i=0;i<nparams;i++)v->Push(aparams->_values[i]);
return SQ_SUCCEEDED(sq_call(v,nparams,SQTrue,raiseerror))?1:SQ_ERROR;
}
示例4: generator_getstatus
//GENERATOR DEFAULT DELEGATE
static SQInteger generator_getstatus(HSQUIRRELVM v)
{
SQObject &o=stack_get(v,1);
switch(_generator(o)->_state){
case SQGenerator::eSuspended:v->Push(SQString::Create(_ss(v),_SC("suspended")));break;
case SQGenerator::eRunning:v->Push(SQString::Create(_ss(v),_SC("running")));break;
case SQGenerator::eDead:v->Push(SQString::Create(_ss(v),_SC("dead")));break;
}
return 1;
}
示例5: __map_array
static SQInteger __map_array(SQArray *dest,SQArray *src,HSQUIRRELVM v) {
SQObjectPtr temp;
SQInteger size = src->Size();
for(SQInteger n = 0; n < size; n++) {
src->Get(n,temp);
v->Push(src);
v->Push(temp);
if(SQ_FAILED(sq_call(v,2,SQTrue,SQFalse))) {
return SQ_ERROR;
}
dest->Set(n,v->GetUp(-1));
v->Pop();
}
return 0;
}
示例6: base_setroottable
static SQInteger base_setroottable(HSQUIRRELVM v)
{
SQObjectPtr o = v->_roottable;
if(SQ_FAILED(sq_setroottable(v))) return SQ_ERROR;
v->Push(o);
return 1;
}
示例7: base_setconsttable
static SQInteger base_setconsttable(HSQUIRRELVM v)
{
SQObjectPtr o = _ss(v)->_consts;
if(SQ_FAILED(sq_setconsttable(v))) return SQ_ERROR;
v->Push(o);
return 1;
}
示例8: number_delegate_tochar
static SQInteger number_delegate_tochar(HSQUIRRELVM v)
{
SQObject &o=stack_get(v,1);
SQChar c = (SQChar)tointeger(o);
v->Push(SQString::Create(_ss(v),(const SQChar *)&c,1));
return 1;
}
示例9: _sort_compare
bool _sort_compare(HSQUIRRELVM v,SQObjectPtr &a,SQObjectPtr &b,SQInteger func,SQInteger &ret)
{
if(func < 0) {
if(!v->ObjCmp(a,b,ret)) return false;
}
else {
SQInteger top = sq_gettop(v);
sq_push(v, func);
sq_pushroottable(v);
v->Push(a);
v->Push(b);
if(SQ_FAILED(sq_call(v, 3, SQTrue, SQFalse))) {
if(!sq_isstring( v->_lasterror))
v->Raise_Error(_SC("compare func failed"));
return false;
}
if(SQ_FAILED(sq_getinteger(v, -1, &ret))) {
v->Raise_Error(_SC("numeric value expected as return value of the compare function"));
return false;
}
sq_settop(v, top);
return true;
}
return true;
}
示例10: base_setconsttable
static SQInteger base_setconsttable(HSQUIRRELVM v)
{
SQObjectPtr &o=stack_get(v,2);
if(SQ_FAILED(sq_setconsttable(v))) return SQ_ERROR;
v->Push(o);
return 1;
}
示例11: base_callee
static SQInteger base_callee(HSQUIRRELVM v)
{
if(v->_callsstacksize > 1)
{
v->Push(v->_callsstack[v->_callsstacksize - 2]._closure);
return 1;
}
return sq_throwerror(v,_SC("no closure in the calls stack"));
}
示例12: array_top
static SQInteger array_top(HSQUIRRELVM v)
{
SQObject &o=stack_get(v,1);
if(_array(o)->Size()>0){
v->Push(_array(o)->Top());
return 1;
}
else return sq_throwerror(v,_SC("top() on a empty array"));
}
示例13: at
SQRESULT at(HSQUIRRELVM vm) {
SQObjectPtr self = vm->GetAt(vm->_top-2);
if (type(self) == OT_STRING) {
SQString *selfString = _string(self);
SQInteger index = selfString->_len;
sq_getinteger(vm, -1, &index);
auto begin = selfString->_val;
auto end = begin+selfString->_len;
try {
SQChar *from = NULL;
if (index >= 0) {
from = begin; utf8::advance(from, index, end);
}
else {
from = end;
for (auto i = index; i < 0; ++i) {
utf8::prior(from, begin);
}
}
auto to = from; utf8::advance(to, 1, end);
SQInteger resultLen = to-from;
assert((resultLen >= 0) && "Length of the resulting string should not be negative");
if (resultLen < 0) {
sq_pushnull(vm);
return 1;
}
SQChar *resultSequence = vm->_sharedstate->GetScratchPad(resultLen+1);
memset(resultSequence, 0, (resultLen+1)*sizeof(SQChar));
memcpy(resultSequence, from, resultLen*sizeof(SQChar));
SQString *result = SQString::Create(vm->_sharedstate, resultSequence);
vm->Push(result);
} catch (...) {
sq_pushnull(vm);
}
}
else {
vm->Raise_Error("string::at - Invalid receiver of type %s", GetTypeName(self));
return SQ_ERROR;
}
return 1;
}
示例14: sq_compile
SQRESULT sq_compile(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror)
{
SQObjectPtr o;
if(Compile(v, read, p, sourcename, o, raiseerror?true:false, _ss(v)->_debuginfo)) {
v->Push(SQClosure::Create(_ss(v), _funcproto(o)));
return SQ_OK;
}
return SQ_ERROR;
}
示例15: array_map
static SQInteger array_map(HSQUIRRELVM v)
{
SQObject &o = stack_get(v,1);
SQInteger size = _array(o)->Size();
SQObjectPtr ret = SQArray::Create(_ss(v),size);
if(SQ_FAILED(__map_array(_array(ret),_array(o),v)))
return SQ_ERROR;
v->Push(ret);
return 1;
}