Skip to content

Commit

Permalink
Exported CompressString and UncompressString to Lua
Browse files Browse the repository at this point in the history
  • Loading branch information
NiLSPACE committed Feb 22, 2015
1 parent 1bcc4ab commit 13f81a0
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/Bindings/ManualBindings.cpp
Expand Up @@ -31,6 +31,7 @@
#include "../LineBlockTracer.h"
#include "../WorldStorage/SchematicFileSerializer.h"
#include "../CompositeChat.h"
#include "../StringCompression.h"



Expand Down Expand Up @@ -110,6 +111,40 @@ static int tolua_Clamp(lua_State * tolua_S)



static int tolua_CompressString(lua_State * tolua_S)
{
cLuaState LuaState(tolua_S);
const char * ToCompress = tolua_tocppstring(LuaState, 1, 0);
int Length = (int)tolua_tonumber(LuaState, 2, 0);
int Factor = (int)tolua_tonumber(LuaState, 3, 0);
AString res;

CompressString(ToCompress, Length, res, Factor);
LuaState.Push(res);
return 1;
}





static int tolua_UncompressString(lua_State * tolua_S)
{
cLuaState LuaState(tolua_S);
const char * ToUncompress = tolua_tocppstring(LuaState, 1, 0);
int Length = (int)tolua_tonumber(LuaState, 2, 0);
int UncompressedSize = (int)tolua_tonumber(LuaState, 3, 0);
AString res;

UncompressString(ToUncompress, Length, res, UncompressedSize);
LuaState.Push(res);
return 1;
}





static int tolua_StringSplit(lua_State * tolua_S)
{
cLuaState LuaState(tolua_S);
Expand Down Expand Up @@ -3519,6 +3554,8 @@ void ManualBindings::Bind(lua_State * tolua_S)

// Globals:
tolua_function(tolua_S, "Clamp", tolua_Clamp);
tolua_function(tolua_S, "CompressString", tolua_CompressString);
tolua_function(tolua_S, "UncompressString", tolua_UncompressString);
tolua_function(tolua_S, "StringSplit", tolua_StringSplit);
tolua_function(tolua_S, "StringSplitAndTrim", tolua_StringSplitAndTrim);
tolua_function(tolua_S, "LOG", tolua_LOG);
Expand Down

0 comments on commit 13f81a0

Please sign in to comment.