summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Bindings/ManualBindings.cpp151
1 files changed, 151 insertions, 0 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 69d16ac2b..a6ae4869b 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -31,6 +31,7 @@
#include "../LineBlockTracer.h"
#include "../WorldStorage/SchematicFileSerializer.h"
#include "../CompositeChat.h"
+#include "../StringCompression.h"
@@ -110,6 +111,146 @@ static int tolua_Clamp(lua_State * tolua_S)
+static int tolua_CompressStringZLIB(lua_State * tolua_S)
+{
+ cLuaState S(tolua_S);
+ if (
+ !S.CheckParamString(1) ||
+ (
+ !S.CheckParamNumber(2) &&
+ !S.CheckParamEnd(2)
+ )
+ )
+ {
+ cLuaState::LogStackTrace(tolua_S);
+ return 0;
+ }
+
+ // Get the params:
+ AString ToCompress;
+ int CompressionLevel = 5;
+ S.GetStackValues(1, ToCompress, CompressionLevel);
+
+ // Compress the string:
+ AString res;
+ CompressString(ToCompress.data(), ToCompress.size(), res, CompressionLevel);
+ S.Push(res);
+ return 1;
+}
+
+
+
+
+
+static int tolua_UncompressStringZLIB(lua_State * tolua_S)
+{
+ cLuaState S(tolua_S);
+ if (
+ !S.CheckParamString(1) ||
+ !S.CheckParamNumber(2)
+ )
+ {
+ cLuaState::LogStackTrace(tolua_S);
+ return 0;
+ }
+
+ // Get the params:
+ AString ToUncompress;
+ int UncompressedSize;
+ S.GetStackValues(1, ToUncompress, UncompressedSize);
+
+ // Compress the string:
+ AString res;
+ UncompressString(ToUncompress.data(), ToUncompress.size(), res, UncompressedSize);
+ S.Push(res);
+ return 1;
+}
+
+
+
+
+
+static int tolua_CompressStringGZIP(lua_State * tolua_S)
+{
+ cLuaState S(tolua_S);
+ if (
+ !S.CheckParamString(1) ||
+ !S.CheckParamEnd(2)
+ )
+ {
+ cLuaState::LogStackTrace(tolua_S);
+ return 0;
+ }
+
+ // Get the params:
+ AString ToCompress;
+ S.GetStackValues(1, ToCompress);
+
+ // Compress the string:
+ AString res;
+ CompressStringGZIP(ToCompress.data(), ToCompress.size(), res);
+ S.Push(res);
+ return 1;
+}
+
+
+
+
+
+static int tolua_UncompressStringGZIP(lua_State * tolua_S)
+{
+ cLuaState S(tolua_S);
+ if (
+ !S.CheckParamString(1) ||
+ !S.CheckParamEnd(2)
+ )
+ {
+ cLuaState::LogStackTrace(tolua_S);
+ return 0;
+ }
+
+ // Get the params:
+ AString ToUncompress;
+ S.GetStackValues(1, ToUncompress);
+
+ // Compress the string:
+ AString res;
+ UncompressStringGZIP(ToUncompress.data(), ToUncompress.size(), res);
+ S.Push(res);
+ return 1;
+}
+
+
+
+
+
+static int tolua_InflateString(lua_State * tolua_S)
+{
+ cLuaState S(tolua_S);
+ if (
+ !S.CheckParamString(1) ||
+ !S.CheckParamEnd(2)
+ )
+ {
+ cLuaState::LogStackTrace(tolua_S);
+ return 0;
+ }
+
+ // Get the params:
+ AString ToUncompress;
+ S.GetStackValues(1, ToUncompress);
+
+ // Compress the string:
+ AString res;
+ InflateString(ToUncompress.data(), ToUncompress.size(), res);
+ S.Push(res);
+ return 1;
+}
+
+
+
+
+
static int tolua_StringSplit(lua_State * tolua_S)
{
cLuaState LuaState(tolua_S);
@@ -3516,6 +3657,8 @@ void ManualBindings::Bind(lua_State * tolua_S)
// Create the new classes:
tolua_usertype(tolua_S, "cCryptoHash");
tolua_cclass(tolua_S, "cCryptoHash", "cCryptoHash", "", nullptr);
+ tolua_usertype(tolua_S, "cStringCompression");
+ tolua_cclass(tolua_S, "cStringCompression", "cStringCompression", "", nullptr);
// Globals:
tolua_function(tolua_S, "Clamp", tolua_Clamp);
@@ -3692,6 +3835,14 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "sha1HexString", tolua_sha1HexString);
tolua_endmodule(tolua_S);
+ tolua_beginmodule(tolua_S, "cStringCompression");
+ tolua_function(tolua_S, "CompressStringZLIB", tolua_CompressStringZLIB);
+ tolua_function(tolua_S, "UncompressStringZLIB", tolua_UncompressStringZLIB);
+ tolua_function(tolua_S, "CompressStringGZIP", tolua_CompressStringGZIP);
+ tolua_function(tolua_S, "UncompressStringGZIP", tolua_UncompressStringGZIP);
+ tolua_function(tolua_S, "InflateString", tolua_InflateString);
+ tolua_endmodule(tolua_S);
+
BindRankManager(tolua_S);
BindNetwork(tolua_S);