Example #1
0
void onDraw(int c, int r) {
	switch(map->array[1-map->array[r*map->w]+r*map->w+c]) {
		case 64:// MAKE ZERO
			map->array[1-map->array[(r)*map->w]+r*map->w+c] = 0;
			break;

		case 62:
		case 63:// INCREMENT
			map->array[1-map->array[(r)*map->w]+r*map->w+c]++;
			break;

		case 46:
		case 47:
		case 50:
		case 51:// SPIKE ANIMATION
			if(game->frame%5 == 0) {
				switch(map->array[1-map->array[(r)*map->w]+r*map->w+c]) {
					case 46:
					case 50:
						//pause('a');
						map->array[1-map->array[(r)*map->w]+r*map->w+c]++;
						break;
					case 51:
					case 47:
						map->array[1-map->array[(r)*map->w]+r*map->w+c]--;
						break;
				}
			}
			break;

		case 58:// MISSILE TANK
			map->array[1-map->array[(r)*map->w]+r*map->w+c] = 0;
			pushObject(c*8,(r+1)*8,0,0,&templates->items.missile);
			break;
		case 59:// SUPER MISSILE TANK
			map->array[1-map->array[(r)*map->w]+r*map->w+c] = 0;
			pushObject(c*8,(r+1)*8,0,0,&templates->items.superMissile);
			break;
		case 60:// POWERBOMB TANK
			map->array[1-map->array[(r)*map->w]+r*map->w+c] = 0;
			pushObject(c*8,(r+1)*8,0,0,&templates->items.powerBomb);
			break;
		case 61:// ENERGY TANK
			map->array[1-map->array[(r)*map->w]+r*map->w+c] = 0;
			pushObject(c*8,(r+1)*8,0,0,&templates->items.energy);
			break;
	}
}
Example #2
0
int onCollide(char dir, int x, int y) {
	switch(map->array[1-map->array[(y/8)*map->w]+(y/8)*map->w+x/8]) {
		case 7:
		case 49:
		case 50:
		case 51:
		case 52://	BREAKAWAY
			if(dir == 't') {
				pushObject(x,y+8,0,0,&templates->effects.crumble);
				objects->first->value->timer = 17;
				objects->first->value->e1 = 7;
				map->array[1-map->array[(y/8)*map->w]+(y/8)*map->w+x/8] = 63;
			}
			break;
		case 46:
		case 47://  SPIKES
			if(dir == 't') {
				hurtSamus(30);
			}
			break;
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:// SPIDER BALL BLOCKS
			return 1;
			break;
	}
	return 0;
}
Example #3
0
void DBCCArmatureNode::registerMovementEventHandler(cocos2d::LUA_FUNCTION func)
{
	unregisterMovementEventHandler();
	_movementEventHandler = func;

	auto dispatcher = getCCEventDispatcher();

	auto f = [this](cocos2d::EventCustom *event)
	{
		auto eventData = (dragonBones::EventData*)(event->getUserData());
		auto type = (int) eventData->getType();
		auto movementId = eventData->animationState->name;
        auto lastState = eventData->armature->getAnimation()->getLastAnimationState();

		auto stack = cocos2d::LuaEngine::getInstance()->getLuaStack();
		stack->pushObject(this, "db.DBCCArmatureNode");
		stack->pushInt(type);
		stack->pushString(movementId.c_str(), movementId.size());
        stack->pushBoolean(lastState == eventData->animationState);
        
		stack->executeFunctionByHandler(_movementEventHandler, 4);
	};

	dispatcher->addCustomEventListener(dragonBones::EventData::COMPLETE, f);
	dispatcher->addCustomEventListener(dragonBones::EventData::LOOP_COMPLETE, f);
}
Example #4
0
void LuaStack::pushLuaValue(const LuaValue& value)
{
    const LuaValueType type = value.getType();
    if (type == LuaValueTypeInt)
    {
        return pushInt(value.intValue());
    }
    else if (type == LuaValueTypeFloat)
    {
        return pushFloat(value.floatValue());
    }
    else if (type == LuaValueTypeBoolean)
    {
        return pushBoolean(value.booleanValue());
    }
    else if (type == LuaValueTypeString)
    {
        return pushString(value.stringValue().c_str());
    }
    else if (type == LuaValueTypeDict)
    {
        pushLuaValueDict(value.dictValue());
    }
    else if (type == LuaValueTypeArray)
    {
        pushLuaValueArray(value.arrayValue());
    }
    else if (type == LuaValueTypeObject)
    {
        pushObject(value.ccobjectValue(), value.getObjectTypename().c_str());
    }
}
void pushUpValue(lua_State *luaState, UpVal *upval) {
	TValue obj;

	obj.value.gc = cast(GCObject *, upval);
	obj.tt = LUA_TUPVAL;
	checkliveness(G(L), obj);

	pushObject(luaState, &obj);
}
Example #6
0
 virtual void pushTrailingArgs() {
     if (UseHSAILDeoptimization) {
         // Last argument is the exception info block
         if (TraceGPUInteraction) {
             tty->print_cr("[HSAIL] exception block=" PTR_FORMAT, _exceptionHolder);
         }
         pushObject(_exceptionHolder);
     }
 }
Example #7
0
 // for kernel arguments, final obj parameter should be an object
 // stream source array (already checked in the base class) so for
 // a javacall we need to extract the correct obj from it based on
 // the workitemid
 virtual void handleFinalObjParameter(void* arg) {
   objArrayOop objArrayArg = (objArrayOop) arg;
   oop extractedObj = objArrayArg->obj_at(_workitemid);
   if (TraceGPUInteraction) {
     tty->print_cr("[HSAIL] HSAILJavaCallArguments, extracted obj #%d from array, 0x%08x is a %s",
                   _workitemid, (address) extractedObj,
                   (extractedObj == NULL ? "null" : extractedObj->klass()->external_name()));
   }
   pushObject(extractedObj);
 }
Example #8
0
static int __new(lua_State *L)
{
	lua_pushstring(L, "__classdata");
	lua_rawget(L, lua_upvalueindex(1));
	gnative_Class *cls = (gnative_Class*)lua_touserdata(L, -1);
	lua_pop(L, 1);
	
	gnative_Object *obj = gnative_CreateObject(cls, NULL, NULL);
	
	return pushObject(L, obj);
}
Example #9
0
//------------------------------------------------------------------------------
void
Canvas::DrawRoundRectangle(int left, int top, int right, int bottom,
                           unsigned ellipse_x,
                           unsigned ellipse_y)
  {
  unsigned radius = std::min(std::min(ellipse_x, ellipse_y),
                                      unsigned(std::min(bottom - top,
                                                        right - left))) / 2u;
  QPainterPath p;
  p.addRoundedRect(left, top, right - left, bottom - top, radius, radius);
  pushObject(p, this->pen(), this->brush());
  }
nsresult
txStylesheetCompilerState::pushChooseGotoList()
{
    nsresult rv = pushObject(mChooseGotoList);
    NS_ENSURE_SUCCESS(rv, rv);

    mChooseGotoList.forget();
    mChooseGotoList = new txList;
    NS_ENSURE_TRUE(mChooseGotoList, NS_ERROR_OUT_OF_MEMORY);

    return NS_OK;
}
Example #11
0
void onShot(int x, int y, struct object* shot) {
	int i;
	switch(map->array[1-map->array[(y/8)*map->w]+(y/8)*map->w+x/8]) {
		case 9:
		case 10:// BOMB BLOCK
			if(shot->behavior == bombShot) {
				pushObject(x,y+8,0,0,&templates->effects.crumble);
				objects->first->value->timer = 80;
				objects->first->value->e1 = 9;
				map->array[1-map->array[(y/8)*map->w]+(y/8)*map->w+x/8] = 0;
			}/* else {
				map->array[1-map->array[(y/8)*map->w]+(y/8)*map->w+x/8] = 9;
			}*/
			break;
		case 11:
		case 12:
		case 13:
		case 14:
		case 19:
		case 20:
		case 21:
		case 22:
		case 32:
		case 33:
		case 34:
		case 35:
		case 40:
		case 41:
		case 42:
		case 43:// DOORS
			for(i = 0; i < map->d; i++) {
				if(map->doors[i].state > 0)
					continue;
				switch(map->doors[i].dir) {
					case 'l':
					case 'r':
						//pause('a');
						if(x/8 - map->array[(y/8)*map->w] == map->doors[i].x && y/8 >= map->doors[i].y && y/8 <= map->doors[i].y + 3)
							map->doors[i].state = 1;
						break;
					case 'u':
					case 'd':
						if(y/8 == map->doors[i].y && x/8 - map->array[(y/8)*map->w] >= map->doors[i].x && x/8 - map->array[(y/8)*map->w] <= map->doors[i].x + 3)
							map->doors[i].state = 1;
						break;
				}
				if(map->doors[i].state > 0)
					break;
			}
			break;
	}
}
Example #12
0
int Viewport::pushValueToLua(CXLUAFUNC handler,Ref* value)
{
    int ret = -1;
    if (0 == handler) {
        return ret;
    }
    auto stack = LuaEngine::getInstance()->getLuaStack();
    
    stack->pushObject(value, "cc.Touch");
    ret = stack->executeFunctionByHandler(handler, 1);
    stack->clean();
    return ret;
}
nsresult
txStylesheetCompilerState::init(const nsAString& aStylesheetURI,
                                txStylesheet* aStylesheet,
                                txListIterator* aInsertPosition)
{
    NS_ASSERTION(!aStylesheet || aInsertPosition,
                 "must provide insertposition if loading subsheet");
    mStylesheetURI = aStylesheetURI;
    // Check for fragment identifier of an embedded stylesheet.
    PRInt32 fragment = aStylesheetURI.FindChar('#') + 1;
    if (fragment > 0) {
        PRInt32 fragmentLength = aStylesheetURI.Length() - fragment;
        if (fragmentLength > 0) {
            // This is really an embedded stylesheet, not just a
            // "url#". We may want to unescape the fragment.
            mTarget = Substring(aStylesheetURI, (PRUint32)fragment,
                                fragmentLength);
            mEmbedStatus = eNeedEmbed;
            mHandlerTable = gTxEmbedHandler;
        }
    }
    nsresult rv = NS_OK;
    if (aStylesheet) {
        mStylesheet = aStylesheet;
        mToplevelIterator = *aInsertPosition;
        mIsTopCompiler = PR_FALSE;
    }
    else {
        mStylesheet = new txStylesheet;
        NS_ENSURE_TRUE(mStylesheet, NS_ERROR_OUT_OF_MEMORY);
        
        rv = mStylesheet->init();
        NS_ENSURE_SUCCESS(rv, rv);
        
        mToplevelIterator =
            txListIterator(&mStylesheet->mRootFrame->mToplevelItems);
        mToplevelIterator.next(); // go to the end of the list
        mIsTopCompiler = PR_TRUE;
    }
   
    mElementContext = new txElementContext(aStylesheetURI);
    NS_ENSURE_TRUE(mElementContext && mElementContext->mMappings,
                   NS_ERROR_OUT_OF_MEMORY);

    // Push the "old" txElementContext
    rv = pushObject(0);
    NS_ENSURE_SUCCESS(rv, rv);
    
    return NS_OK;
}
Example #14
0
	void CustomGUIReader::setCustomProps(const std::string &classType, cocos2d::Ref *widget, const rapidjson::Value &customOptions)
	{
        if (_setPropsFunc != 0)
        {
            rapidjson::StringBuffer buffer;
            rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
            customOptions.Accept(writer);

            auto stack = LuaEngine::getInstance()->getLuaStack();
            stack->pushString(classType.c_str(), classType.size());
            stack->pushObject(widget, "cc.Ref");
            stack->pushString(buffer.GetString(), buffer.Size());
            stack->executeFunctionByHandler(_setPropsFunc, 3);
        }
	}
Example #15
0
static int pushValue(lua_State *L, gnative_Value v, gnative_Type t, bool del)
{
	switch (t)
	{
	case GNATIVE_TYPE_VOID:
		return 0;
	case GNATIVE_TYPE_BOOLEAN:
		lua_pushboolean(L, v.z);
		return 1;
	case GNATIVE_TYPE_CHAR:
		lua_pushinteger(L, v.c);
		return 1;
	case GNATIVE_TYPE_SHORT:
		lua_pushinteger(L, v.s);
		return 1;
	case GNATIVE_TYPE_INT:
		lua_pushinteger(L, v.i);
		return 1;
	case GNATIVE_TYPE_LONG:
		lua_pushnumber(L, v.l);
		return 1;
	case GNATIVE_TYPE_FLOAT:
		lua_pushnumber(L, v.f);
		return 1;
	case GNATIVE_TYPE_DOUBLE:
		lua_pushnumber(L, v.d);
		return 1;
	case GNATIVE_TYPE_LONG_DOUBLE:
		lua_pushnumber(L, v.ld);
		return 1;
	case GNATIVE_TYPE_STRING:
		lua_pushstring(L, v.str);
		if (del)
			free((char*)v.str);
		return 1;
	case GNATIVE_TYPE_OBJECT:
		if (!del)
			gnative_ObjectRetain(v.obj);
		return pushObject(L, v.obj);
	case GNATIVE_TYPE_COMPLEX:
		return 0;
	case GNATIVE_TYPE_JAVA_CHAR:
		lua_pushinteger(L, v.jc);
		return 1;
	}
	
	return 0;
}
Example #16
0
//------------------------------------------------------------------------------
void
Canvas::DrawPolyline(const RasterPoint *points, unsigned num_points)
  {
  unsigned i;
  QPainterPath p;
  QPointF v[num_points];
  for (i = 0; i < num_points; i++)
    {
    v[i].setX(points[i].x);
    v[i].setY(points[i].y);
    }
  p.moveTo(v[0]);
  for (i = 1; i < num_points; i++)
    p.lineTo(v[i]);
  pushObject(p, this->pen(), this->brush());
  }
Example #17
0
void LuaObjectBase::runCallback(const char* functionName, const char* sig, ...)
{
	if (m_markedForDeletion)
		return;

#ifdef FULL_USER_DATA
	// Find the callback function.
	std::map<std::string,int>::iterator index = m_userTable.find( std::string(functionName) );
	if (index == m_userTable.end())
		return;
	int callbackFunction = index->second;

	MLUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB);
	MLUA->GetField(-1, "MsgN");
	MLUA->ReferencePush(callbackFunction);
#else
	if (!latestRef())
		return;
	ILuaObject* callbackFunction = latestRef()->GetMember(functionName);
	if (!callbackFunction)
		return;
	callbackFunction->Push();
	callbackFunction->UnReference();
#endif
	pushObject();

	int numArguments = 1;
	if (sig)
	{
		va_list arguments;
		va_start(arguments, sig);
		for (unsigned int i=0; i<strlen(sig); i++)
		{
			char option = sig[i];
			if (option == 'i')
			{
				int value = va_arg(arguments, int);
				MLUA->PushNumber(value);
				numArguments++;
			}
			else if (option == 'f')
			{
				float value = static_cast<float>(va_arg(arguments, double));
				MLUA->PushNumber(value);
				numArguments++;
			}
Example #18
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void QcPlugin::generateAlert(const QcBuffer *shortBuffer,
                             const QcBuffer *longBuffer) const {
	if ( shortBuffer->empty() || longBuffer->empty() ) return;

	//shortBuffer->info(); Short Term buffer info
	//lta->info(); Long Term buffer info

	double sta = mean(shortBuffer);
	//double staStdDev = stdDev(shortBuffer, sta);

	double lta = mean(longBuffer);
	double ltaStdDev = stdDev(longBuffer, lta);

	double relative = 0.0;

	//! HACK
	if (ltaStdDev != 0.0)
		relative =  100.0 - ( (ltaStdDev - fabs(lta - sta)) / ltaStdDev ) * 100.0;

	string f = "\033[32m"; // green colour

	if (fabs(relative) > *(_qcConfig->alertThresholds().begin())) { // HACK multi thresholds not yet implemented!
		
		DataModel::WaveformQuality* obj = new DataModel::WaveformQuality();
		obj->setWaveformID(getWaveformID(_streamID));
		obj->setCreatorID(_app->creatorID());
		obj->setCreated(Core::Time::GMT());
		obj->setStart(shortBuffer->startTime());
		obj->setEnd(shortBuffer->endTime());
		obj->setType("alert");
		obj->setParameter(_parameterNames[0]);
		obj->setValue(sta);
		obj->setLowerUncertainty(relative);
		obj->setUpperUncertainty(lta);
		obj->setWindowLength((double)shortBuffer->length());

		pushObject(obj);
	
		f = "\033[31m"; // red colour
		SEISCOMP_WARNING("%s %s %s %.0f%% \033[30m  %.3f %.3f", _streamID.c_str(), _parameterNames[0].c_str(), f.c_str(), relative, fabs(relative), lta);
	}
}
Example #19
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void QcPlugin::generateNullReport() const {
	for (size_t i = 0; i < _parameterNames.size(); ++i) {
		SEISCOMP_DEBUG("%s: generateNullReport[%ld]: OK", _streamID.c_str(), (long int)i);

		DataModel::WaveformQuality* obj = new DataModel::WaveformQuality();
		obj->setWaveformID(getWaveformID(_streamID));
		obj->setCreatorID(_app->creatorID());
		obj->setCreated(Core::Time::GMT());
		obj->setStart(Core::Time::GMT());
		obj->setEnd(Core::Time::GMT());
		obj->setType("report");
		obj->setParameter(_parameterNames[i]);
		obj->setValue(0.0);
		obj->setLowerUncertainty(0.0);
		obj->setUpperUncertainty(0.0);
		obj->setWindowLength(-1.0);
		
		pushObject(DataModel::Object::Cast(obj));
	}
}
nsresult
txStylesheetCompiler::ensureNewElementContext()
{
    // Do we already have a new context?
    if (!mElementContext->mDepth) {
        return NS_OK;
    }
    
    nsAutoPtr<txElementContext>
        context(new txElementContext(*mElementContext));
    NS_ENSURE_TRUE(context, NS_ERROR_OUT_OF_MEMORY);

    nsresult rv = pushObject(mElementContext);
    NS_ENSURE_SUCCESS(rv, rv);

    mElementContext.forget();
    mElementContext = context;

    return NS_OK;
}
Example #21
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void QcPlugin::generateReport(const QcBuffer *buf) const {
	if ( buf->empty() ) return;

	double mean_ = mean(buf);
	double stdDev_ = stdDev(buf, mean_);

	DataModel::WaveformQuality* obj = new DataModel::WaveformQuality();
	obj->setWaveformID(getWaveformID(_streamID));
	obj->setCreatorID(_app->creatorID());
	obj->setCreated(Core::Time::GMT());
	obj->setStart(buf->startTime());
	obj->setEnd(buf->endTime());
	obj->setType("report");
	obj->setParameter(_parameterNames[0]);
	obj->setValue(mean_);
	obj->setLowerUncertainty(stdDev_);
	obj->setUpperUncertainty(stdDev_);
	obj->setWindowLength((double)buf->length());

	pushObject(obj);
}
Example #22
0
void DBCCArmatureNode::registerFrameEventHandler(cocos2d::LUA_FUNCTION func)
{
	unregisterFrameEventHandler();
	_frameEventHandler = func;

	auto dispatcher = getCCEventDispatcher();

	auto f = [this](cocos2d::EventCustom *event)
	{
		auto eventData = (dragonBones::EventData*)(event->getUserData());
		auto type = (int) eventData->getType();
		auto movementId = eventData->animationState->name;
		auto frameLabel = eventData->frameLabel;

		auto stack = cocos2d::LuaEngine::getInstance()->getLuaStack();
		stack->pushObject(this, "db.DBCCArmatureNode");
		stack->pushInt(type);
        stack->pushString(movementId.c_str(), movementId.size());
        stack->pushString(frameLabel.c_str(), frameLabel.size());
		stack->executeFunctionByHandler(_frameEventHandler, 4);
	};

	dispatcher->addCustomEventListener(dragonBones::EventData::ANIMATION_FRAME_EVENT, f);
}
void pushString(lua_State *luaState, TString *str) {
	TValue o;
	setsvalue(luaState, &o, str);

	pushObject(luaState, &o);
}
Example #24
0
Oop* __fastcall Interpreter::primitivePerformWithArgs()
{
	Oop* const sp = m_registers.m_stackPointer;
	ArrayOTE* argumentArray = reinterpret_cast<ArrayOTE*>(*(sp));
	BehaviorOTE* arrayClass = ObjectMemory::fetchClassOf(Oop(argumentArray));
	if (arrayClass != Pointers.ClassArray)
		return primitiveFailure(0);
	
	// N.B. We're using a large stack, so don't bother checking for overflow
	//		(standard stack overflow mechanism should catch it)
									   
	// We must not get the length outside, in case small integer arg
	const unsigned argCount = argumentArray->pointersSize();
	
	// Save old message selector in case of prim failure (need to reinstate)
	SymbolOTE* performSelector = m_oopMessageSelector;

	// To ensure the argumentArray doesn't go away when we push its contents
	// onto the stack, in case we need it for recovery from an argument
	// count mismatch we leave its ref. count elevated

	SymbolOTE* selectorToPerform = reinterpret_cast<SymbolOTE*>(*(sp-1));
	if (ObjectMemoryIsIntegerObject(selectorToPerform))
		return primitiveFailure(1);

	m_oopMessageSelector = selectorToPerform;	// Get selector from stack
	// Don't need to count down the stack ref.
	ASSERT(!selectorToPerform->isFree());

	Oop newReceiver = *(sp-2);			// receiver is under selector and arg array

	// Push the args from the array onto the stack. We must do this before
	// looking up the method, because if the receiver does not understand
	// the method then the lookup routines copy the arguments off the stack
	// into a Message object
	Array* args = argumentArray->m_location;
	for (MWORD i=0; i<argCount; i++)
	{
		Oop pushee = args->m_elements[i];
		// Note no need to inc the ref. count when pushing on the stack
		sp[i-1] = pushee;
	}
	// Args written over top of selector and argument array (hence -2)
	m_registers.m_stackPointer = sp+argCount-2;

	// There is a subtle complication here when the receiver does not
	// understand the message, by which lookupMethodInClass() converts
	// the message we're trying to perform to a #doesNotUnderstand: with
	// all arguments moved to a Message. We still want to execute this
	// does not understand, so we also execute the method if the argument
	// counts do not match, but it was not understood. Note that it is
	// possible for a doesNotUnderstand: to be executed thru the first
	// test if the argumentArray contained only one argument. We allow
	// this to happen to avoid testing for not understood in the normal
	// case - just be aware of this anomaly.
	MethodOTE* methodPointer = findNewMethodInClass(ObjectMemory::fetchClassOf(newReceiver), argCount);
	CompiledMethod& method = *methodPointer->m_location;
	const unsigned methodArgCount = method.m_header.argumentCount;
	if (methodArgCount == argCount ||
			m_oopMessageSelector == Pointers.DoesNotUnderstandSelector)
	{
		// WE no longer need the argument array, but don't count it down since we only have a stack ref.
		executeNewMethod(methodPointer, methodArgCount);
		return primitiveSuccess(0);
	}
	else
	{
		// Receiver must have understood the message, but we had wrong 
		// number of arguments, so reinstate the stack and fail the primitive
		pop(argCount);
		pushObject((OTE*)m_oopMessageSelector);
		// Argument array already has artificially increased ref. count
		push(Oop(argumentArray));
		m_oopMessageSelector = performSelector;
		return primitiveFailure(1);
	}
}
void pushProto(lua_State *luaState, Proto *proto) {
	TValue obj;
	setptvalue(luaState, &obj, proto);

	pushObject(luaState, &obj);
}
void pushClosure(lua_State *luaState, Closure *closure) {
	TValue obj;
	setclvalue(luaState, &obj, closure);
	pushObject(luaState, &obj);
}