当前位置: 首页>>代码示例>>C++>>正文


C++ HSQUIRRELVM::Push方法代码示例

本文整理汇总了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;
}
开发者ID:jack9267,项目名称:vcmpserver,代码行数:27,代码来源:sqbaselib.cpp

示例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;
}
开发者ID:benjeffery,项目名称:openttd,代码行数:26,代码来源:sqbaselib.cpp

示例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;
}
开发者ID:jack9267,项目名称:vcmpserver,代码行数:8,代码来源:sqbaselib.cpp

示例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;
}
开发者ID:jack9267,项目名称:vcmpserver,代码行数:11,代码来源:sqbaselib.cpp

示例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;
}
开发者ID:jack9267,项目名称:vcmpserver,代码行数:15,代码来源:sqbaselib.cpp

示例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;
}
开发者ID:Cucurbitace,项目名称:attract,代码行数:7,代码来源:sqbaselib.cpp

示例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;
}
开发者ID:Cucurbitace,项目名称:attract,代码行数:7,代码来源:sqbaselib.cpp

示例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;
}
开发者ID:jack9267,项目名称:vcmpserver,代码行数:7,代码来源:sqbaselib.cpp

示例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;
}
开发者ID:Ayutac,项目名称:OpenTTD,代码行数:25,代码来源:sqbaselib.cpp

示例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;
}
开发者ID:jack9267,项目名称:vcmpserver,代码行数:7,代码来源:sqbaselib.cpp

示例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"));
}
开发者ID:Cucurbitace,项目名称:attract,代码行数:9,代码来源:sqbaselib.cpp

示例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"));
}
开发者ID:jack9267,项目名称:vcmpserver,代码行数:9,代码来源:sqbaselib.cpp

示例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;
 }
开发者ID:wanderwaltz,项目名称:SqUTF8,代码行数:57,代码来源:squtf8_string_at.cpp

示例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;
}
开发者ID:bruian,项目名称:AutoBot-plugin,代码行数:9,代码来源:sqapi.cpp

示例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;
}
开发者ID:jack9267,项目名称:vcmpserver,代码行数:10,代码来源:sqbaselib.cpp


注:本文中的HSQUIRRELVM::Push方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。