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


C++ HSQUIRRELVM类代码示例

本文整理汇总了C++中HSQUIRRELVM的典型用法代码示例。如果您正苦于以下问题:C++ HSQUIRRELVM类的具体用法?C++ HSQUIRRELVM怎么用?C++ HSQUIRRELVM使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HSQUIRRELVM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sq_newclass

SQRESULT sq_newclass(HSQUIRRELVM v,SQBool hasbase)
{
	SQClass *baseclass = NULL;
	if(hasbase) {
		SQObjectPtr &base = stack_get(v,-1);
		if(type(base) != OT_CLASS)
			return sq_throwerror(v,_SC("invalid base type"));
		baseclass = _class(base);
	}
	SQClass *newclass = SQClass::Create(_ss(v), baseclass);
	if(baseclass) v->Pop();
	v->Push(newclass);	
	return SQ_OK;
}
开发者ID:Azon099,项目名称:networked-iv,代码行数:14,代码来源:sqapi.cpp

示例2: sq_newclass

SQRESULT sq_newclass(HSQUIRRELVM v,SQBool hasbase, const SQChar* name)
{
	SQClass *baseclass = NULL;
	if(hasbase) {
		SQObjectPtr &base = stack_get(v,-1);
		if(sqi_type(base) != OT_CLASS)
			return sq_throwerror(v,_SC("invalid base type"));
		baseclass = sqi_class(base);
	}
	SQClass *newclass = SQClass::Create(_ss(v), baseclass);
	if (name) newclass->_methods[0].val = SQString::Create(_ss(v), name, -1);
	if(baseclass) v->Pop();
	v->Push(newclass);	
	return SQ_OK;
}
开发者ID:noriter,项目名称:nit,代码行数:15,代码来源:sqapi.cpp

示例3: __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

示例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:benjeffery,项目名称:openttd,代码行数:17,代码来源:sqbaselib.cpp

示例5: 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

示例6: 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

示例7: 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

示例8: ReadObject

bool ReadObject(HSQUIRRELVM v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &o)
{
	SQObjectType t;
	_CHECK_IO(SafeRead(v,read,up,&t,sizeof(SQObjectType)));
	switch(t){
	case OT_STRING:{
		SQInteger len;
		_CHECK_IO(SafeRead(v,read,up,&len,sizeof(SQInteger)));
		_CHECK_IO(SafeRead(v,read,up,_ss(v)->GetScratchPad(rsl(len)),rsl(len)));
		o=SQString::Create(_ss(v),_ss(v)->GetScratchPad(-1),len);
				   }
		break;
	case OT_INTEGER:{
		SQInteger i;
		_CHECK_IO(SafeRead(v,read,up,&i,sizeof(SQInteger))); o = i; break;
					}
	case OT_FLOAT:{
		SQFloat f;
		_CHECK_IO(SafeRead(v,read,up,&f,sizeof(SQFloat))); o = f; break;
				  }
	case OT_NULL:
		o=_null_;
		break;
	default:
		v->Raise_Error(_SC("cannot serialize a %s"),IdType2Name(t));
		return false;
	}
	return true;
}
开发者ID:Heartbroken,项目名称:bikini,代码行数:29,代码来源:sqobject.cpp

示例9: _qsort

//QSORT ala Sedgewick
bool _qsort(HSQUIRRELVM v,SQObjectPtr &arr, SQInteger l, SQInteger r,SQInteger func)
{
	SQInteger i, j;
	SQArray *a=_array(arr);
	SQObjectPtr pivot,t;
	if( l < r ){
		pivot = a->_values[l];
		i = l; j = r+1;
		while(1){
			SQInteger ret;
			do { 
				++i; 
				if(i > r) break;
				if(!_qsort_compare(v,arr,a->_values[i],pivot,func,ret))
					return false;
			} while( ret <= 0);
			do {
				--j;
				if ( j < 0 ) {
					v->Raise_Error( _SC("Invalid qsort, probably compare function defect") ); 
					return false; 
				}
				if(!_qsort_compare(v,arr,a->_values[j],pivot,func,ret))
					return false;
			}
			while( ret > 0 );
			if( i >= j ) break;
			t = a->_values[i]; a->_values[i] = a->_values[j]; a->_values[j] = t;
		}
		t = a->_values[l]; a->_values[l] = a->_values[j]; a->_values[j] = t;
		if(!_qsort( v, arr, l, j-1,func)) return false;
		if(!_qsort( v, arr, j+1, r,func)) return false;
	}
	return true;
}
开发者ID:jack9267,项目名称:vcmpserver,代码行数:36,代码来源: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: SafeRead

bool SafeRead( HSQUIRRELVM v, SQWRITEFUNC read, SQUserPointer up, SQUserPointer dest, SQInteger size ) {
	if ( size && read( up, dest, size ) != size ) {
		v->Raise_Error( _SC( "io error, read function failure, the origin stream could be corrupted/trucated" ) );
		return false;
	}
	return true;
}
开发者ID:q4a,项目名称:scourge,代码行数:7,代码来源:sqobject.cpp

示例12: SafeWrite

bool SafeWrite( HSQUIRRELVM v, SQWRITEFUNC write, SQUserPointer up, SQUserPointer dest, SQInteger size ) {
	if ( write( up, dest, size ) != size ) {
		v->Raise_Error( _SC( "io error (write function failure)" ) );
		return false;
	}
	return true;
}
开发者ID:q4a,项目名称:scourge,代码行数:7,代码来源:sqobject.cpp

示例13: base_assert

static SQInteger base_assert(HSQUIRRELVM v)
{
	if(v->IsFalse(stack_get(v,2))){
		return sq_throwerror(v,_SC("assertion failed"));
	}
	return 0;
}
开发者ID:jack9267,项目名称:vcmpserver,代码行数:7,代码来源:sqbaselib.cpp

示例14: sq_setdebughook

void sq_setdebughook(HSQUIRRELVM v)
{
	SQObject o = stack_get(v,-1);
	if(sq_isclosure(o) || sq_isnativeclosure(o) || sq_isnull(o)) {
		v->_debughook = o;
		v->Pop();
	}
}
开发者ID:bruian,项目名称:AutoBot-plugin,代码行数:8,代码来源:sqapi.cpp

示例15: sq_seterrorhandler

void sq_seterrorhandler(HSQUIRRELVM v)
{
	SQObject o = stack_get(v, -1);
	if(sq_isclosure(o) || sq_isnativeclosure(o) || sq_isnull(o)) {
		v->_errorhandler = o;
		v->Pop();
	}
}
开发者ID:ACMEware,项目名称:Paper-Hurricane,代码行数:8,代码来源:sqapi.cpp


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