-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.5.0
- Loading branch information
Showing
34 changed files
with
997 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.pluto linguist-language=Lua |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
require ../../Soup/soup include_dir=../../Soup | ||
+*.cpp | ||
-lua.cpp | ||
-luac.cpp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "lauxlib.h" | ||
#include "lualib.h" | ||
|
||
#ifdef PLUTO_USE_SOUP | ||
|
||
#include <soup/base32.hpp> | ||
|
||
static int encode(lua_State* L) { | ||
lua_pushstring(L, soup::base32::encode(luaL_checkstring(L, 1), (bool)lua_toboolean(L, 2)).c_str()); | ||
return 1; | ||
} | ||
|
||
static int decode(lua_State* L) { | ||
lua_pushstring(L, soup::base32::decode(luaL_checkstring(L, 1)).c_str()); | ||
return 1; | ||
} | ||
|
||
static const luaL_Reg funcs[] = { | ||
{"encode", encode}, | ||
{"decode", decode}, | ||
{nullptr, nullptr} | ||
}; | ||
|
||
LUAMOD_API int luaopen_base32(lua_State* L) { | ||
luaL_newlib(L, funcs); | ||
return 1; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "lauxlib.h" | ||
#include "lualib.h" | ||
|
||
#ifdef PLUTO_USE_SOUP | ||
|
||
#include <soup/string.hpp> | ||
#include <soup/base58.hpp> | ||
|
||
static int decode(lua_State* L) { | ||
try { | ||
lua_pushstring(L, soup::string::bin2hex(soup::base58::decode(luaL_checkstring(L, 1))).c_str()); | ||
} | ||
catch (...) { | ||
luaL_error(L, "Attempted to decode non-base58 string."); | ||
} | ||
return 1; | ||
} | ||
|
||
static int is_valid(lua_State* L) { | ||
try { | ||
const auto discarding = soup::base58::decode(luaL_checkstring(L, 1)); | ||
lua_pushboolean(L, true); | ||
} | ||
catch (...) { | ||
lua_pushboolean(L, false); | ||
} | ||
return 1; | ||
} | ||
|
||
static const luaL_Reg funcs[] = { | ||
{"is_valid", is_valid}, | ||
{"decode", decode}, | ||
{nullptr, nullptr} | ||
}; | ||
|
||
LUAMOD_API int luaopen_base58(lua_State* L) { | ||
luaL_newlib(L, funcs); | ||
return 1; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "lauxlib.h" | ||
#include "lualib.h" | ||
|
||
#ifdef PLUTO_USE_SOUP | ||
|
||
#include <string> | ||
#include <soup/base64.hpp> | ||
|
||
static int encode(lua_State* L) { | ||
lua_pushstring(L, soup::base64::encode(luaL_checkstring(L, 1), (bool)lua_toboolean(L, 2)).c_str()); | ||
return 1; | ||
} | ||
|
||
static int decode(lua_State* L) { | ||
lua_pushstring(L, soup::base64::decode(luaL_checkstring(L, 1)).c_str()); | ||
return 1; | ||
} | ||
|
||
static int urlEncode(lua_State* L) { | ||
lua_pushstring(L, soup::base64::urlEncode(luaL_checkstring(L, 1), (bool)lua_toboolean(L, 2)).c_str()); | ||
return 1; | ||
} | ||
|
||
static int urlDecode(lua_State* L) { | ||
lua_pushstring(L, soup::base64::urlDecode(luaL_checkstring(L, 1)).c_str()); | ||
return 1; | ||
} | ||
|
||
static const luaL_Reg funcs[] = { | ||
{"url_encode", urlEncode}, | ||
{"url_decode", urlDecode}, | ||
{"encode", encode}, | ||
{"decode", decode}, | ||
{nullptr, nullptr} | ||
}; | ||
|
||
LUAMOD_API int luaopen_base64(lua_State* L) { | ||
luaL_newlib(L, funcs); | ||
return 1; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "lauxlib.h" | ||
#include "lualib.h" | ||
|
||
#ifdef PLUTO_USE_SOUP | ||
|
||
#include "ljson.hpp" | ||
|
||
static int encode(lua_State* L) { | ||
auto root = checkJson(L, 1); | ||
if (lua_gettop(L) >= 2 && lua_toboolean(L, 2)) | ||
{ | ||
lua_pushstring(L, root->encodePretty()); | ||
} | ||
else | ||
{ | ||
lua_pushstring(L, root->encode()); | ||
} | ||
return 1; | ||
} | ||
|
||
static int decode(lua_State* L) | ||
{ | ||
auto root = soup::json::decodeForDedicatedVariable(luaL_checkstring(L, 1)); | ||
pushFromJson(L, *root); | ||
return 1; | ||
} | ||
|
||
static const luaL_Reg funcs[] = { | ||
{"encode", encode}, | ||
{"decode", decode}, | ||
{nullptr, nullptr} | ||
}; | ||
|
||
LUA_API int luaopen_json(lua_State *L) { | ||
luaL_newlib(L, funcs); | ||
return 1; | ||
} | ||
|
||
#endif |
Oops, something went wrong.