diff --git a/CorpseMethods.h b/CorpseMethods.h index 3282295..fb85184 100644 --- a/CorpseMethods.h +++ b/CorpseMethods.h @@ -31,7 +31,7 @@ namespace LuaCorpse */ int GetGhostTime(Eluna* /*E*/, lua_State* L, Corpse* corpse) { - Eluna::Push(L, uint32(corpse->GetGhostTime())); + Eluna::Push(L, corpse->GetGhostTime()); return 1; } diff --git a/ElunaTemplate.h b/ElunaTemplate.h index 98fa444..e213949 100644 --- a/ElunaTemplate.h +++ b/ElunaTemplate.h @@ -425,19 +425,21 @@ public: return 1; } - static int Add(lua_State* L) { return 0; } - static int Substract(lua_State* L) { return 0; } - static int Multiply(lua_State* L) { return 0; } - static int Divide(lua_State* L) { return 0; } - static int Mod(lua_State* L) { return 0; } - static int Pow(lua_State* L) { return 0; } - static int UnaryMinus(lua_State* L) { return 0; } - static int Concat(lua_State* L) { return 0; } - static int Length(lua_State* L) { return 0; } - static int Equal(lua_State* L) { return 0; } - static int Less(lua_State* L) { return 0; } - static int LessOrEqual(lua_State* L) { return 0; } - static int Call(lua_State* L) { return 0; } + static int ArithmeticError(lua_State* L) { return luaL_error(L, "attempt to perform arithmetic on a %s value", tname); } + static int CompareError(lua_State* L) { return luaL_error(L, "attempt to compare %s", tname); } + static int Add(lua_State* L) { return ArithmeticError(L); } + static int Substract(lua_State* L) { return ArithmeticError(L); } + static int Multiply(lua_State* L) { return ArithmeticError(L); } + static int Divide(lua_State* L) { return ArithmeticError(L); } + static int Mod(lua_State* L) { return ArithmeticError(L); } + static int Pow(lua_State* L) { return ArithmeticError(L); } + static int UnaryMinus(lua_State* L) { return ArithmeticError(L); } + static int Concat(lua_State* L) { return luaL_error(L, "attempt to concatenate a %s value", tname); } + static int Length(lua_State* L) { return luaL_error(L, "attempt to get length of a %s value", tname); } + static int Equal(lua_State* L) { Eluna::Push(L, Eluna::CHECKOBJ(L, 1) == Eluna::CHECKOBJ(L, 2)); return 1; } + static int Less(lua_State* L) { return CompareError(L); } + static int LessOrEqual(lua_State* L) { return CompareError(L); } + static int Call(lua_State* L) { return luaL_error(L, "attempt to call a %s value", tname); } }; // //template const char* ElunaTemplate::tname; diff --git a/GlobalMethods.h b/GlobalMethods.h index b3b21e8..4a0f788 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -113,11 +113,7 @@ namespace LuaGlobalFunctions */ int GetGameTime(Eluna* /*E*/, lua_State* L) { - time_t time = eWorld->GetGameTime(); - if (time < 0) - Eluna::Push(L, int32(time)); - else - Eluna::Push(L, uint32(time)); + Eluna::Push(L, eWorld->GetGameTime()); return 1; } @@ -1182,10 +1178,10 @@ namespace LuaGlobalFunctions } /** - * Executes world database sql [Query] instantly and returns QueryResult object + * Executes an sql to your world database instantly and returns [ElunaQuery] * - * @param string query : sql [Query] to run - * @return QueryResult result + * @param string sql : sql to run + * @return [ElunaQuery] result */ int WorldDBQuery(Eluna* /*E*/, lua_State* L) { @@ -1208,9 +1204,9 @@ namespace LuaGlobalFunctions } /** - * Executes a sql [Query] (not instantly) to your world database + * Executes an sql to your character database. The SQL is not ran instantly. * - * @param string query : sql [Query] to execute + * @param string sql : sql [ElunaQuery] to execute */ int WorldDBExecute(Eluna* /*E*/, lua_State* L) { @@ -1220,10 +1216,10 @@ namespace LuaGlobalFunctions } /** - * Executes character database sql [Query] instantly and returns QueryResult object + * Executes an sql to your character database instantly and returns [ElunaQuery] * - * @param string query : sql [Query] to run - * @return [Query] result + * @param string sql : sql to run + * @return [ElunaQuery] result */ int CharDBQuery(Eluna* /*E*/, lua_State* L) { @@ -1246,9 +1242,9 @@ namespace LuaGlobalFunctions } /** - * Executes a [Query] (not instantly) to your character database + * Executes an sql to your character database. The SQL is not ran instantly. * - * @param string query : sql [Query] to execute + * @param string sql : sql to run */ int CharDBExecute(Eluna* /*E*/, lua_State* L) { @@ -1258,10 +1254,10 @@ namespace LuaGlobalFunctions } /** - * Executes auth database sql [Query] instantly and returns QueryResult object + * Executes an sql to your auth database instantly and returns [ElunaQuery] * - * @param string query : sql [Query] to run - * @return [Query] result + * @param string sql : sql to run + * @return [ElunaQuery] result */ int AuthDBQuery(Eluna* /*E*/, lua_State* L) { @@ -1284,9 +1280,9 @@ namespace LuaGlobalFunctions } /** - * Executes a [Query] (not instantly ) to your auth database + * Executes an sql to your auth database. The SQL is not ran instantly. * - * @param string query : sql [Query] to execute + * @param string sql : sql to run */ int AuthDBExecute(Eluna* /*E*/, lua_State* L) { @@ -2493,5 +2489,63 @@ namespace LuaGlobalFunctions ELUNA_LOG_DEBUG("%s", GetStackAsString(L).c_str()); return 0; } + + /** + * Returns an object represeting long long. + * The value by default is 0, but can be initialized to a value by passing a number or long long as a string. + * + * @proto value = () + * @proto value = (number) + * @proto value = (longlong) + * @proto value = (longlongstr) + * @param int32 number : regular lua number + * @param int64 longlong : a long long object + * @param string longlongstr : a long long as a string + * @return int64 value + */ + int CreateLongLong(Eluna* /*E*/, lua_State* L) + { + long long init = 0; + if (lua_isstring(L, 1)) + { + std::string str = Eluna::CHECKVAL(L, 1); + if (sscanf(str.c_str(), SI64FMTD, &init) != 1) + return luaL_argerror(L, 1, "long long (as string) could not be converted"); + } + else if (!lua_isnoneornil(L, 1)) + init = Eluna::CHECKVAL(L, 1); + + Eluna::Push(L, init); + return 1; + } + + /** + * Returns an object represeting unsigned long long. + * The value by default is 0, but can be initialized to a value by passing a number or unsigned long long as a string. + * + * @proto value = () + * @proto value = (number) + * @proto value = (ulonglong) + * @proto value = (ulonglongstr) + * @param uint32 number : regular lua number + * @param uint64 ulonglong : an unsigned long long object + * @param string ulonglongstr : an unsigned long long as a string + * @return uint64 value + */ + int CreateULongLong(Eluna* /*E*/, lua_State* L) + { + unsigned long long init = 0; + if (lua_isstring(L, 1)) + { + std::string str = Eluna::CHECKVAL(L, 1); + if (sscanf(str.c_str(), UI64FMTD, &init) != 1) + return luaL_argerror(L, 1, "unsigned long long (as string) could not be converted"); + } + else if (!lua_isnoneornil(L, 1)) + init = Eluna::CHECKVAL(L, 1); + + Eluna::Push(L, init); + return 1; + } } #endif diff --git a/LuaEngine.cpp b/LuaEngine.cpp index fbbbcfc..20845f6 100644 --- a/LuaEngine.cpp +++ b/LuaEngine.cpp @@ -450,30 +450,30 @@ void Eluna::Push(lua_State* L) { lua_pushnil(L); } -void Eluna::Push(lua_State* L, const uint64 l) +void Eluna::Push(lua_State* L, const long long l) { - ElunaTemplate::Push(L, new uint64(l)); + ElunaTemplate::Push(L, new long long(l)); } -void Eluna::Push(lua_State* L, const int64 l) +void Eluna::Push(lua_State* L, const unsigned long long l) { - ElunaTemplate::Push(L, new int64(l)); + ElunaTemplate::Push(L, new unsigned long long(l)); } -//void Eluna::Push(lua_State* L, const time_t l) -//{ -// ElunaTemplate::Push(L, new uint64(l)); -//} -//void Eluna::Push(lua_State* L, const size_t l) -//{ -// ElunaTemplate::Push(L, new int64(l)); -//} -void Eluna::Push(lua_State* L, const uint32 u) +void Eluna::Push(lua_State* L, const long l) { - lua_pushunsigned(L, u); + Push(L, static_cast(l)); } -void Eluna::Push(lua_State* L, const int32 i) +void Eluna::Push(lua_State* L, const unsigned long l) +{ + Push(L, static_cast(l)); +} +void Eluna::Push(lua_State* L, const int i) { lua_pushinteger(L, i); } +void Eluna::Push(lua_State* L, const unsigned int u) +{ + lua_pushunsigned(L, u); +} void Eluna::Push(lua_State* L, const double d) { lua_pushnumber(L, d); @@ -486,7 +486,7 @@ void Eluna::Push(lua_State* L, const bool b) { lua_pushboolean(L, b); } -void Eluna::Push(lua_State* L, const std::string str) +void Eluna::Push(lua_State* L, const std::string& str) { lua_pushstring(L, str.c_str()); } @@ -572,29 +572,29 @@ void Eluna::Push(lua_State* L, Object const* obj) } } -static int32 CheckIntegerRange(lua_State* L, int narg, int32 min, int32 max) +static int CheckIntegerRange(lua_State* L, int narg, int min, int max) { - int64 value = static_cast(luaL_checknumber(L, narg)); + double value = luaL_checknumber(L, narg); char error_buffer[64]; if (value > max) { - snprintf(error_buffer, 64, "value must be less than or equal to %d", max); + snprintf(error_buffer, 64, "value must be less than or equal to %i", max); return luaL_argerror(L, narg, error_buffer); } if (value < min) { - snprintf(error_buffer, 64, "value must be greater than or equal to %d", min); + snprintf(error_buffer, 64, "value must be greater than or equal to %i", min); return luaL_argerror(L, narg, error_buffer); } - return static_cast(value); + return static_cast(value); } -static uint32 CheckUnsignedRange(lua_State* L, int narg, uint32 max) +static unsigned int CheckUnsignedRange(lua_State* L, int narg, unsigned int max) { - int64 value = static_cast(luaL_checknumber(L, narg)); + double value = luaL_checknumber(L, narg); char error_buffer[64]; if (value < 0) @@ -606,7 +606,7 @@ static uint32 CheckUnsignedRange(lua_State* L, int narg, uint32 max) return luaL_argerror(L, narg, error_buffer); } - return static_cast(value); + return static_cast(value); } template<> bool Eluna::CHECKVAL(lua_State* L, int narg) @@ -621,27 +621,27 @@ template<> double Eluna::CHECKVAL(lua_State* L, int narg) { return luaL_checknumber(L, narg); } -template<> int8 Eluna::CHECKVAL(lua_State* L, int narg) +template<> signed char Eluna::CHECKVAL(lua_State* L, int narg) { return CheckIntegerRange(L, narg, SCHAR_MIN, SCHAR_MAX); } -template<> uint8 Eluna::CHECKVAL(lua_State* L, int narg) +template<> unsigned char Eluna::CHECKVAL(lua_State* L, int narg) { return CheckUnsignedRange(L, narg, UCHAR_MAX); } -template<> int16 Eluna::CHECKVAL(lua_State* L, int narg) +template<> short Eluna::CHECKVAL(lua_State* L, int narg) { return CheckIntegerRange(L, narg, SHRT_MIN, SHRT_MAX); } -template<> uint16 Eluna::CHECKVAL(lua_State* L, int narg) +template<> unsigned short Eluna::CHECKVAL(lua_State* L, int narg) { return CheckUnsignedRange(L, narg, USHRT_MAX); } -template<> int32 Eluna::CHECKVAL(lua_State* L, int narg) +template<> int Eluna::CHECKVAL(lua_State* L, int narg) { return CheckIntegerRange(L, narg, INT_MIN, INT_MAX); } -template<> uint32 Eluna::CHECKVAL(lua_State* L, int narg) +template<> unsigned int Eluna::CHECKVAL(lua_State* L, int narg) { return CheckUnsignedRange(L, narg, UINT_MAX); } @@ -653,30 +653,26 @@ template<> std::string Eluna::CHECKVAL(lua_State* L, int narg) { return luaL_checkstring(L, narg); } -template<> int64 Eluna::CHECKVAL(lua_State* L, int narg) +template<> long long Eluna::CHECKVAL(lua_State* L, int narg) { if (lua_isnumber(L, narg)) - return static_cast(CHECKVAL(L, narg)); - return *(Eluna::CHECKOBJ(L, narg, true)); + return static_cast(CHECKVAL(L, narg)); + return *(Eluna::CHECKOBJ(L, narg, true)); } -template<> uint64 Eluna::CHECKVAL(lua_State* L, int narg) +template<> unsigned long long Eluna::CHECKVAL(lua_State* L, int narg) { if (lua_isnumber(L, narg)) - return static_cast(CHECKVAL(L, narg)); - return *(Eluna::CHECKOBJ(L, narg, true)); + return static_cast(CHECKVAL(L, narg)); + return *(Eluna::CHECKOBJ(L, narg, true)); +} +template<> long Eluna::CHECKVAL(lua_State* L, int narg) +{ + return static_cast(CHECKVAL(L, narg)); +} +template<> unsigned long Eluna::CHECKVAL(lua_State* L, int narg) +{ + return static_cast(CHECKVAL(L, narg)); } -//template<> time_t Eluna::CHECKVAL(lua_State* L, int narg) -//{ -// if (lua_isnumber(L, narg)) -// return static_cast(CHECKVAL(L, narg)); -// return static_cast(*(Eluna::CHECKOBJ(L, narg, true))); -//} -//template<> size_t Eluna::CHECKVAL(lua_State* L, int narg) -//{ -// if (lua_isnumber(L, narg)) -// return static_cast(CHECKVAL(L, narg)); -// return static_cast(*(Eluna::CHECKOBJ(L, narg, true))); -//} template<> Object* Eluna::CHECKOBJ(lua_State* L, int narg, bool error) { diff --git a/LuaEngine.h b/LuaEngine.h index 4cee8ba..b719260 100644 --- a/LuaEngine.h +++ b/LuaEngine.h @@ -160,15 +160,17 @@ public: // Pushes static void Push(lua_State* L); // nil - static void Push(lua_State* L, const uint64); - static void Push(lua_State* L, const int64); - static void Push(lua_State* L, const uint32); - static void Push(lua_State* L, const int32); + static void Push(lua_State* L, const long long); + static void Push(lua_State* L, const unsigned long long); + static void Push(lua_State* L, const long); + static void Push(lua_State* L, const unsigned long); + static void Push(lua_State* L, const int); + static void Push(lua_State* L, const unsigned int); static void Push(lua_State* L, const bool); static void Push(lua_State* L, const float); static void Push(lua_State* L, const double); + static void Push(lua_State* L, const std::string&); static void Push(lua_State* L, const char*); - static void Push(lua_State* L, const std::string); template static void Push(lua_State* L, T const* ptr) { ElunaTemplate::Push(L, ptr); diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index a889023..e2bd1d0 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -127,6 +127,8 @@ ElunaGlobal::ElunaRegister GlobalMethods[] = { "AddWeather", &LuaGlobalFunctions::AddWeather }, { "RemoveWeather", &LuaGlobalFunctions::RemoveWeather }, { "SendFineWeatherToPlayer", &LuaGlobalFunctions::SendFineWeatherToPlayer }, + { "CreateInt64", &LuaGlobalFunctions::CreateLongLong }, + { "CreateUint64", &LuaGlobalFunctions::CreateULongLong }, { NULL, NULL }, }; @@ -1266,38 +1268,46 @@ template<> int ElunaTemplate::CollectGarbage(lua_State* L) #endif // Template by Mud from http://stackoverflow.com/questions/4484437/lua-integer-type/4485511#4485511 -template<> int ElunaTemplate::Add(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) + Eluna::CHECKVAL(L, 2)); return 1; } -template<> int ElunaTemplate::Substract(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) - Eluna::CHECKVAL(L, 2)); return 1; } -template<> int ElunaTemplate::Multiply(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) * Eluna::CHECKVAL(L, 2)); return 1; } -template<> int ElunaTemplate::Divide(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) / Eluna::CHECKVAL(L, 2)); return 1; } -template<> int ElunaTemplate::Mod(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) % Eluna::CHECKVAL(L, 2)); return 1; } -template<> int ElunaTemplate::Pow(lua_State* L) { Eluna::Push(L, pow(Eluna::CHECKVAL(L, 1), Eluna::CHECKVAL(L, 2))); return 1; } -// template<> int ElunaTemplate::UnaryMinus(lua_State* L) { Eluna::Push(L, -Eluna::CHECKVAL(L, 1)); return 1; } -template<> int ElunaTemplate::Equal(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) == Eluna::CHECKVAL(L, 2)); return 1; } -template<> int ElunaTemplate::Less(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) < Eluna::CHECKVAL(L, 2)); return 1; } -template<> int ElunaTemplate::LessOrEqual(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) <= Eluna::CHECKVAL(L, 2)); return 1; } -template<> int ElunaTemplate::ToString(lua_State* L) +template<> int ElunaTemplate::Add(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) + Eluna::CHECKVAL(L, 2)); return 1; } +template<> int ElunaTemplate::Substract(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) - Eluna::CHECKVAL(L, 2)); return 1; } +template<> int ElunaTemplate::Multiply(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) * Eluna::CHECKVAL(L, 2)); return 1; } +template<> int ElunaTemplate::Divide(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) / Eluna::CHECKVAL(L, 2)); return 1; } +template<> int ElunaTemplate::Mod(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) % Eluna::CHECKVAL(L, 2)); return 1; } +// template<> int ElunaTemplate::UnaryMinus(lua_State* L) { Eluna::Push(L, -Eluna::CHECKVAL(L, 1)); return 1; } +template<> int ElunaTemplate::Equal(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) == Eluna::CHECKVAL(L, 2)); return 1; } +template<> int ElunaTemplate::Less(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) < Eluna::CHECKVAL(L, 2)); return 1; } +template<> int ElunaTemplate::LessOrEqual(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) <= Eluna::CHECKVAL(L, 2)); return 1; } +template<> int ElunaTemplate::Pow(lua_State* L) { - uint64 l = Eluna::CHECKVAL(L, 1); + Eluna::Push(L, static_cast(std::powl(static_cast(Eluna::CHECKVAL(L, 1)), static_cast(Eluna::CHECKVAL(L, 2))))); + return 1; +} +template<> int ElunaTemplate::ToString(lua_State* L) +{ + unsigned long long l = Eluna::CHECKVAL(L, 1); std::ostringstream ss; ss << l; Eluna::Push(L, ss.str()); return 1; } -template<> int ElunaTemplate::Add(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) + Eluna::CHECKVAL(L, 2)); return 1; } -template<> int ElunaTemplate::Substract(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) - Eluna::CHECKVAL(L, 2)); return 1; } -template<> int ElunaTemplate::Multiply(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) * Eluna::CHECKVAL(L, 2)); return 1; } -template<> int ElunaTemplate::Divide(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) / Eluna::CHECKVAL(L, 2)); return 1; } -template<> int ElunaTemplate::Mod(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) % Eluna::CHECKVAL(L, 2)); return 1; } -template<> int ElunaTemplate::Pow(lua_State* L) { Eluna::Push(L, pow(Eluna::CHECKVAL(L, 1), Eluna::CHECKVAL(L, 2))); return 1; } -template<> int ElunaTemplate::UnaryMinus(lua_State* L) { Eluna::Push(L, -Eluna::CHECKVAL(L, 1)); return 1; } -template<> int ElunaTemplate::Equal(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) == Eluna::CHECKVAL(L, 2)); return 1; } -template<> int ElunaTemplate::Less(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) < Eluna::CHECKVAL(L, 2)); return 1; } -template<> int ElunaTemplate::LessOrEqual(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) <= Eluna::CHECKVAL(L, 2)); return 1; } -template<> int ElunaTemplate::ToString(lua_State* L) +template<> int ElunaTemplate::Add(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) + Eluna::CHECKVAL(L, 2)); return 1; } +template<> int ElunaTemplate::Substract(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) - Eluna::CHECKVAL(L, 2)); return 1; } +template<> int ElunaTemplate::Multiply(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) * Eluna::CHECKVAL(L, 2)); return 1; } +template<> int ElunaTemplate::Divide(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) / Eluna::CHECKVAL(L, 2)); return 1; } +template<> int ElunaTemplate::Mod(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) % Eluna::CHECKVAL(L, 2)); return 1; } +template<> int ElunaTemplate::UnaryMinus(lua_State* L) { Eluna::Push(L, -Eluna::CHECKVAL(L, 1)); return 1; } +template<> int ElunaTemplate::Equal(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) == Eluna::CHECKVAL(L, 2)); return 1; } +template<> int ElunaTemplate::Less(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) < Eluna::CHECKVAL(L, 2)); return 1; } +template<> int ElunaTemplate::LessOrEqual(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL(L, 1) <= Eluna::CHECKVAL(L, 2)); return 1; } +template<> int ElunaTemplate::Pow(lua_State* L) { - int64 l = Eluna::CHECKVAL(L, 1); + Eluna::Push(L, static_cast(std::powl(static_cast(Eluna::CHECKVAL(L, 1)), static_cast(Eluna::CHECKVAL(L, 2))))); + return 1; +} +template<> int ElunaTemplate::ToString(lua_State* L) +{ + long long l = Eluna::CHECKVAL(L, 1); std::ostringstream ss; ss << l; Eluna::Push(L, ss.str()); @@ -1386,7 +1396,7 @@ void RegisterFunctions(Eluna* E) ElunaTemplate::Register(E, "ElunaQuery", true); ElunaTemplate::SetMethods(E, QueryMethods); - ElunaTemplate::Register(E, "uint64", true); + ElunaTemplate::Register(E, "long long", true); - ElunaTemplate::Register(E, "int64", true); + ElunaTemplate::Register(E, "unsigned long long", true); } diff --git a/docs/DOC_GEN.md b/docs/DOC_GEN.md index bfedec3..60bd022 100644 --- a/docs/DOC_GEN.md +++ b/docs/DOC_GEN.md @@ -43,7 +43,10 @@ This is a template for a function that takes in different parameters. When defin * * @proto returnValue = (object) * @proto returnValue = (x, y, z) - * @param Type paramName = defaultValue : parameter description + * @param [WorldObject] object = defaultValue : parameter description + * @param float x = defaultValue : parameter description + * @param float y = defaultValue : parameter description + * @param float z = defaultValue : parameter description * @return Type returnName : return value description */ ``` diff --git a/docs/ElunaDoc/__main__.py b/docs/ElunaDoc/__main__.py index 8434ac9..85cbdba 100644 --- a/docs/ElunaDoc/__main__.py +++ b/docs/ElunaDoc/__main__.py @@ -118,6 +118,7 @@ if __name__ == '__main__': 'string': 'http://www.lua.org/pil/2.4.html', 'table': 'http://www.lua.org/pil/2.5.html', 'function': 'http://www.lua.org/pil/2.6.html', + '...': 'http://www.lua.org/pil/5.2.html', } def data_type_parser(content): @@ -132,6 +133,8 @@ if __name__ == '__main__': url = '{}{}/index.html'.format(('../' * level), class_name) return '{}'.format(url, class_name) + return content[1:-1] + return link_parser, data_type_parser # Create the render function with the template path and parser maker. diff --git a/docs/ElunaDoc/parser.py b/docs/ElunaDoc/parser.py index 4db5032..a8308cf 100644 --- a/docs/ElunaDoc/parser.py +++ b/docs/ElunaDoc/parser.py @@ -18,6 +18,8 @@ class ParameterDoc(object): 'uint16': ('0', '65,535'), 'int32': ('-2,147,483,647', '2,147,483,647'), 'uint32': ('0', '4,294,967,295'), + 'int64': ('-9,223,372,036,854,775,808', '9,223,372,036,854,775,807'), + 'uint64': ('0', '18,446,744,073,709,551,615'), } @params(self=object, name=unicode, data_type=str, description=unicode, default_value=Nullable(unicode)) @@ -47,8 +49,8 @@ class ParameterDoc(object): elif self.data_type == 'bool': self.data_type = 'boolean' - elif self.data_type == 'uint64' or self.data_type == 'int64': - self.data_type = 'string' + elif self.data_type == 'int64' or self.data_type == 'uint64': + self.data_type = '[' + self.data_type + ']' class MethodDoc(object): @@ -112,7 +114,7 @@ class ClassParser(object): # An extra optional space (\s?) was thrown in to make it different from `class_body_regex`. param_regex = re.compile(r"""\s*\*\s@param\s # The @param tag starts with opt. whitespace followed by "* @param ". - ([\[\]\w]+)\s(\w+) # The data type, a space, and the name of the param. + ([^\s]+)\s(\w+) # The data type, a space, and the name of the param. (?:\s=\s(\w+))? # The default value: a = surrounded by spaces, followed by text. (?:\s:\s(.+))? # The description: a colon surrounded by spaces, followed by text. """, re.X) @@ -183,11 +185,18 @@ class ClassParser(object): if parameters != '': parameters = ' ' + parameters + ' ' - if self.returned: - return_values = ', '.join([param.name for param in self.returned]) - prototype = '{0} = {1}:{2}({3})'.format(return_values, self.class_name, self.method_name, parameters) + if self.class_name == 'Global': + if self.returned: + return_values = ', '.join([param.name for param in self.returned]) + prototype = '{0} = {1}({2})'.format(return_values, self.method_name, parameters) + else: + prototype = '{0}({1})'.format(self.method_name, parameters) else: - prototype = '{0}:{1}({2})'.format(self.class_name, self.method_name, parameters) + if self.returned: + return_values = ', '.join([param.name for param in self.returned]) + prototype = '{0} = {1}:{2}({3})'.format(return_values, self.class_name, self.method_name, parameters) + else: + prototype = '{0}:{1}({2})'.format(self.class_name, self.method_name, parameters) self.prototypes.append(prototype) else: