コード例 #1
0
void myFunc() 
{
	//LogMsg("This is a test from squirrell");
	Sqrat::Object slotVal = Sqrat::RootTable().GetSlot("myVal");
	if (slotVal.IsNull() == false)
	{
		//LogMsg("%d", slotVal.Cast<int>());
	}
}
コード例 #2
0
void Android::transit(Sqrat::Object intent, int requestCode = -1) {
    std::string targetClass = intent.GetSlot("className").Cast<std::string>();
    int optionFlag = intent.GetSlot("optionFlag").Cast<int>();
    kvs_t* extras = new kvs_t();
    Sqrat::Array extraArray = intent.GetSlot("extras");
    for (int i = 0, size = extraArray.GetSize(); i < size; i++) {
        std::string key = extraArray[i].GetSlot("key").Cast<std::string>();
        std::string value = extraArray[i].GetSlot("value").Cast<std::string>();
        extras->insert(make_pair(key, value));
    }
    engine->javaGlue->transit(targetClass, extras, optionFlag,requestCode);
}
コード例 #3
0
ファイル: SqEvent.cpp プロジェクト: TheWhiteGoat/Goat
void SqEvent::HookEvent(Sqrat::Object instance, Sqrat::string eventname, Sqrat::Function function)
{
	if(instance.GetType() == OT_INSTANCE)
	{
		g_SqEvent->AddToTrie(eventname.data(), new Function(function.GetVM(),instance,function.GetFunc()),false);
	}
}
コード例 #4
0
ファイル: SquirrelObjects.cpp プロジェクト: kgrubb/iceee
void Printer::PrintValue(std::string *result, Sqrat::Object object) {
	if (object.IsNull()) {
		result->append("null");
	} else {
		if (object.GetType() == OT_TABLE) {
			PrintTable(result, object.Cast<Sqrat::Table>());
		} else if (object.GetType() == OT_ARRAY) {
			PrintArray(result, object.Cast<Sqrat::Array>());
		} else if (object.GetType() == OT_INTEGER) {
			Util::SafeFormat(mPrintBuffer, sizeof(mPrintBuffer), "%lu",
					object.Cast<unsigned long>());
			result->append(mPrintBuffer);
		} else if (object.GetType() == OT_STRING) {
			result->append("\"" + object.Cast<std::string>() + "\"");
		} else if (object.GetType() == OT_BOOL) {
			result->append(object.Cast<bool>() ? "true" : "false");
		} else if (object.GetType() == OT_FLOAT) {
			Util::SafeFormat(mPrintBuffer, sizeof(mPrintBuffer), "%f",
					object.Cast<double>());
			result->append(mPrintBuffer);
		} else {
			Vector3 *vec3 = object.Cast<Vector3*>();
			if (vec3 != NULL) {
				Util::SafeFormat(mPrintBuffer, sizeof(mPrintBuffer),
						"Vector3(%f,%f,%f)", vec3->mX, vec3->mY, vec3->mZ);
				result->append(mPrintBuffer);
			}

		}
	}
}
コード例 #5
0
ファイル: SquirrelObjects.cpp プロジェクト: kgrubb/iceee
Json::Value JsonPrinter::PrintValue(Sqrat::Object object) {
	if(!object.IsNull()) {
		if(object.GetType() == OT_TABLE) {
			Json::Value v;
			PrintTable(v, object.Cast<Sqrat::Table>());
			return v;
		}
		else if(object.GetType() == OT_ARRAY) {
			Json::Value v(Json::arrayValue);
			PrintArray(v, object.Cast<Sqrat::Array>());
			return v;
		}
		else if(object.GetType() == OT_INTEGER) {
			return Json::UInt64(object.Cast<unsigned long>());
		}
		else if(object.GetType() == OT_STRING) {
			return Json::Value(object.Cast<std::string>());
		}
		else if(object.GetType() == OT_BOOL) {
			return Json::Value(object.Cast<bool>());
		}
		else if(object.GetType() == OT_FLOAT) {
			return Json::Value(object.Cast<double>());
		}
		else {
			Vector3 *vec3 = object.Cast<Vector3*>();
			if(vec3 != NULL) {
				Json::Value v3;
				v3["x"] = vec3->mX;
				v3["y"] = vec3->mY;
				v3["z"] = vec3->mZ;
				return v3;
			}
		}
	}
	Json::Value v;
	return v;
}