//----------------------------------------------------------------//
void MOAIHarness::ReceiveEvaluate(lua_State *L, json_t* node)
{
	// Get the evaluation.
	json_t* np_eval = json_object_get(node, "Evaluation");
	if (np_eval == NULL || json_typeof(np_eval) != JSON_STRING)
		return;

	// Get the current stack index so we know how many
	// positions to clear afterward.
	int top = lua_gettop(L);

	// Load the string from the message
	MOAIScopedLuaState state ( L );
	int status = luaL_loadstring ( state, json_string_value(np_eval) );
	if ( state.PrintErrors ( ZLLog::CONSOLE, status )) return;

	// Call the string
	state.DebugCall ( 0, 0 );

	// Now unload all of the things we just put on the stack
	// until the stack is the same size.
	std::string indent = "    ";
	json_t* result = MOAIHarness::ConvertStackPartialToJSON(L, top + 1, lua_gettop(L));
	lua_pop(L, lua_gettop(L) - top);

	// Send the message back to the IDE.
	MOAIHarness::SendResult(result);
}
Example #2
0
//----------------------------------------------------------------//
void MOAIInputMgr::SetConfigurationName ( cc8* name ) {

	MOAIScopedLuaState state = MOAILuaRuntime::Get ().State ();
	this->PushLuaClassTable ( state );
	
	state.SetField ( -1, LUAVAR_CONFIGURATION, name );
}
Example #3
0
//----------------------------------------------------------------//
void MOAIEnvironment::SetValue ( cc8* key ) {

	MOAIScopedLuaState state = MOAILuaRuntime::Get ().State ();
	this->PushLuaClassTable ( state );
	state.ClearField ( -1, key );
	state.Pop ( 1 );
}
Example #4
0
//----------------------------------------------------------------//
void MOAISim::SendFinalizeEvent () {

	MOAIScopedLuaState state = MOAILuaRuntime::Get ().State ();
	if ( this->PushListener ( EVENT_FINALIZE, state )) {
		state.DebugCall ( 0, 0 );
	}
}
Example #5
0
//----------------------------------------------------------------//
void MOAISim::SendResumeEvent () {

	MOAIScopedLuaState state = MOAILuaRuntime::Get ().State ();
	if ( this->PushListener ( EVENT_RESUME, state )) {
		state.DebugCall ( 0, 0 );
	}
}
//----------------------------------------------------------------//
extern "C" JNIEXPORT void JNICALL Java_com_ziplinegames_moai_MoaiTapjoy_AKUInvokeListenerWithCode ( JNIEnv* env, jclass obj, jint eventID, jint code ) {

	ZLLog::LogF ( ZLLog::CONSOLE, "Java_com_ziplinegames_moai_MoaiTapjoy_AKUInvokeListenerWithCode\n" );
	MOAIScopedLuaState state = MOAILuaRuntime::Get ().State ();
	if ( MOAITapjoyAndroid::Get ().PushListener ( eventID, state )) {
		state.Push ( code );
		state.DebugCall ( 1, 0 );
	}
}
Example #7
0
//----------------------------------------------------------------//
void MOAIGooglePlayServicesAndroid::NotifyConnectionComplete () {

	MOAILuaRef& callback = this->mListeners [ CONNECTION_COMPLETE ];

	if ( callback ) {

		MOAIScopedLuaState state = callback.GetSelf ();
		state.DebugCall ( 0, 0 );
	}
}
//----------------------------------------------------------------//
void MOAITstoreGamecenterAndroid::AKUNotifyUserInfoResponse ( cc8* jsonData ) {

	MOAILuaRef& callback = this->mListeners [ GET_USERINFO_RESPONSE ];

	if ( callback ) {
		MOAIScopedLuaState state = callback.GetSelf ();
		lua_pushstring ( state, jsonData );
		state.DebugCall ( 1, 0 );
	}
}
//----------------------------------------------------------------//
void MOAIChartBoostAndroid::NotifyInterstitialDismissed () {	
	
	MOAILuaRef& callback = this->mListeners [ INTERSTITIAL_DISMISSED ];
	
	if ( callback ) {
		
		MOAIScopedLuaState state = callback.GetSelf ();
		
		state.DebugCall ( 0, 0 );
	}
}
//----------------------------------------------------------------//
void MOAIChartBoostAndroid::NotifyInterstitialLoadFailed () {	
	
	MOAILuaRef& callback = this->mListeners [ INTERSTITIAL_LOAD_FAILED ];
	
	if ( callback ) {
		
		MOAIScopedLuaState state = callback.GetSelf ();
		
		state.DebugCall ( 0, 0 );
	}
}
//----------------------------------------------------------------//
void MOAIMoviePlayerAndroid::NotifyMoviePlayerReady () {
	
	MOAILuaRef& callback = this->mListeners [ MOVIE_PLAYER_READY ];
		
	if ( callback ) {
		
		MOAIScopedLuaState state = callback.GetSelf ();

		state.DebugCall ( 0, 0 );
	}
}
//----------------------------------------------------------------//
void MOAITstoreGamecenterAndroid::AKUNotifyAuthSuccessResponse () {

	MOAILuaRef& callback = this->mListeners [ AUTH_RESPONSE_SUCCESS ];

	if ( callback ) {

		MOAIScopedLuaState state = callback.GetSelf ();

		state.DebugCall ( 0, 0 );
	}
}
//----------------------------------------------------------------//
void MOAIScriptNode::OnDepNodeUpdate () {

	if ( this->mOnUpdate ) {
		
		MOAIScopedLuaState state = MOAILuaRuntime::Get ().State ();
		if ( this->mOnUpdate.PushRef ( state )) {
			this->PushLuaUserdata ( state );
			state.DebugCall ( 1, 0 );
		}
	}
}
//----------------------------------------------------------------//
void MOAIWheelSensor::ParseEvent ( ZLStream& eventStream ) {
	
	this->mDelta = eventStream.Read < float >( 0.0f );
	this->mValue += this->mDelta;
	
	if ( this->mCallback ) {
		MOAIScopedLuaState state = this->mCallback.GetSelf ();
		lua_pushnumber ( state, this->mDelta );
		state.DebugCall ( 1, 0 );
	}
}
Example #15
0
//----------------------------------------------------------------//
void MOAIAppAndroid::NotifyWillEndSession () {
	
	MOAILuaRef& callback = this->mListeners [ SESSION_END ];
	
	if ( callback ) {

		MOAIScopedLuaState state = callback.GetSelf ();
		
		state.DebugCall ( 0, 0 );
	}
}
//----------------------------------------------------------------//
void MOAITstoreGamecenterAndroid::AKUNotifyDisableSuccessResponse () {

	MOAILuaRef& callback = this->mListeners [ DISABLE_GAMECENTER_RESPONSE ];

	if ( callback ) {

		MOAIScopedLuaState state = callback.GetSelf ();

		state.DebugCall ( 0, 0 );
	}
}
//----------------------------------------------------------------//
void MOAIMoviePlayerAndroid::NotifyMoviePlayerCompleted () {
	
	MOAILuaRef& callback = this->mListeners [ MOVIE_PLAYER_COMPLETED ];
		
	if ( callback ) {
		
		MOAIScopedLuaState state = callback.GetSelf ();

		state.DebugCall ( 0, 0 );
	}
}
Example #18
0
//================================================================//
// MOAIAdColonyAndroid
//================================================================//
//----------------------------------------------------------------//
void MOAIAdColonyAndroid::NotifyVideoComplete () {	
	
	MOAILuaRef& callback = this->mListeners [ VIDEO_ENDED_IN_ZONE ];
	
	if ( callback ) {
		
		MOAIScopedLuaState state = callback.GetSelf ();
		
		state.DebugCall ( 0, 0 );
	}
}
//----------------------------------------------------------------//
void MOAITstoreWallAndroid::NotifyCurrencyAwarded ( int amount ) {
	
	MOAILuaRef& callback = this->mListeners [ TSTORE_CURRENCY_AWARDED ];
	
	if ( callback ) {
		
		MOAIScopedLuaState state = callback.GetSelf ();
		
		lua_pushinteger ( state, amount );
		
		state.DebugCall ( 1, 0 );
	}
}
Example #20
0
//----------------------------------------------------------------//
void MOAIDialogAndroid::NotifyDialogDismissed ( int dialogResult ) {

	if ( !mDialogCallback.IsNil ()) {
		
		MOAIScopedLuaState state = mDialogCallback.GetSelf ();

		lua_pushinteger ( state, dialogResult );
		
		state.DebugCall ( 1, 0 );
		
		mDialogCallback.Clear ();
	}
}
Example #21
0
//----------------------------------------------------------------//
void MOAIAppAndroid::NotifyDidStartSession ( bool resumed ) {

	MOAILuaRef& callback = this->mListeners [ SESSION_START ];
	
	if ( callback ) {
		
		MOAIScopedLuaState state = callback.GetSelf ();

		lua_pushboolean ( state, resumed );
			
		state.DebugCall ( 1, 0 );
	}
}
Example #22
0
//----------------------------------------------------------------//
void MOAIMotionSensor::HandleEvent ( ZLStream& eventStream ) {

	this->mX = eventStream.Read < float >( 0.0f );
	this->mY = eventStream.Read < float >( 0.0f );
	this->mZ = eventStream.Read < float >( 0.0f );
	
	if ( this->mCallback ) {
		MOAIScopedLuaState state = this->mCallback.GetSelf ();
		lua_pushnumber ( state, this->mX );
		lua_pushnumber ( state, this->mY );
		lua_pushnumber ( state, this->mZ );
		state.DebugCall ( 3, 0 );
	}
}
Example #23
0
//----------------------------------------------------------------//
void MOAIDataIOTask::Publish () {

	if ( this->mInflateOnLoad && ( !this->mInflateOnTaskThread )) {
		this->mData->Inflate ( this->mWindowBits );
	}

	if ( this->mOnFinish ) {
	
		MOAIScopedLuaState state = MOAILuaRuntime::Get ().State ();
		this->PushLocal ( state, this->mOnFinish );
		this->mData->PushLuaUserdata ( state );
		state.DebugCall ( 1, 0 );
	}
}
Example #24
0
//----------------------------------------------------------------//
void MOAIFacebookAndroid::NotifyLoginComplete ( int code ) {

	MOAILuaRef& callback = this->mListeners [ SESSION_DID_NOT_LOGIN ];
	if ( code == DIALOG_RESULT_SUCCESS ) {
		
		callback = this->mListeners [ SESSION_DID_LOGIN ];
	}

	if ( callback ) {
	
		MOAIScopedLuaState state = callback.GetSelf ();
	
		state.DebugCall ( 0, 0 );
	}
}
Example #25
0
//----------------------------------------------------------------//
void MOAIFacebookAndroid::NotifyDialogComplete ( int code ) {
	
	MOAILuaRef& callback = this->mListeners [ DIALOG_DID_NOT_COMPLETE ];
	if ( code == DIALOG_RESULT_SUCCESS ) {
		
		callback = this->mListeners [ DIALOG_DID_COMPLETE ];
	}

	if ( callback ) {
	
		MOAIScopedLuaState state = callback.GetSelf ();
	
		state.DebugCall ( 0, 0 );
	}
}
Example #26
0
//----------------------------------------------------------------//
void MOAITwitterAndroid::NotifyTweetComplete ( int code ) {

	MOAILuaRef& callback = this->mListeners [ TWEET_CANCELLED ];
	if ( code == RESULT_SUCCESS ) {

		callback = this->mListeners [ TWEET_SUCCESSFUL ];
	}

	if ( callback ) {

		MOAIScopedLuaState state = callback.GetSelf ();

		state.DebugCall ( 0, 0 );
	}
}
Example #27
0
//----------------------------------------------------------------//
void MOAINode::DepNodeUpdate () {
	
	if ( this->mState == STATE_SCHEDULED ) {
	
		this->mState = STATE_UPDATING;
		this->PullAttributes ();

		MOAIScopedLuaState state = MOAILuaRuntime::Get ().State ();
		if ( this->PushListenerAndSelf ( EVENT_UPDATE, state )) {
			state.DebugCall ( 1, 0 );
		}

		this->OnDepNodeUpdate ();
	}
	this->mState = STATE_ACTIVE;
}
//----------------------------------------------------------------//
void MOAIHarness::HandleError(const char* message, lua_State* L, int level)
{
    if (MOAIHarness::mSocketID == -1)
    {
        ZLLog::LogF ( "%s\n", message );
        MOAIScopedLuaState state ( L );
        state.PrintStackTrace ( ZLLog::CONSOLE, NULL, level );
    }
    else
    {
        // Package the call stack into a json object
    	json_t* stack = ConvertCallStackToJSON(L, 0);
        MOAIHarness::SendError(message, stack, level);
        MOAIHarness::Pause(L);
    }
}
Example #29
0
//----------------------------------------------------------------//
bool MOAIAppAndroid::NotifyBackButtonPressed () {
	
	MOAILuaRef& callback = this->mListeners [ BACK_BUTTON_PRESSED ];
	
	if ( callback ) {
		
		MOAIScopedLuaState state = callback.GetSelf ();

		state.DebugCall ( 0, 1 );

		return lua_toboolean ( state, -1 );
	} else {
		
		return false;
	}
}
Example #30
0
//----------------------------------------------------------------//
void MOAIButtonSensor::HandleEvent ( ZLStream& eventStream ) {

	bool down = eventStream.Read < bool >( false );
	
	if ( down ) {
		this->mState |= IS_DOWN | DOWN;
	}
	else {
		this->mState &= ~IS_DOWN;
		this->mState |= UP;
	}
	
	if ( this->mOnButton ) {
		MOAIScopedLuaState state = this->mOnButton.GetSelf ();
		lua_pushboolean ( state, down );
		state.DebugCall ( 1, 0 );
	}
}