Add Lua UTF-8 lib (#4)

Co-authored-by: MoNTE48 <MoNTE48@mail.ua>
master
Vitaliy 2021-02-11 17:04:22 +03:00 committed by MoNTE48
parent 2f0b47dbdd
commit ea2ddf2be7
9 changed files with 4938 additions and 1 deletions

View File

@ -207,6 +207,7 @@ endif()
find_package(GMP REQUIRED)
find_package(Json REQUIRED)
find_package(Lua REQUIRED)
add_subdirectory(lib/luautf8)
# JsonCPP doesn't compile well on GCC 4.8
if(NOT ENABLE_SYSTEM_JSONCPP)

View File

@ -145,6 +145,28 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
luautf8
---------------
Copyright (c) 2018 Xavier Wang
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Fonts
---------------

View File

@ -231,6 +231,9 @@ LOCAL_SRC_FILES += ../../../lib/gmp/mini-gmp.c
# JSONCPP
LOCAL_SRC_FILES += ../../../lib/jsoncpp/jsoncpp.cpp
# Lua UTF-8 Lib
LOCAL_SRC_FILES += ../../../lib/luautf8/lutf8lib.c
LOCAL_STATIC_LIBRARIES += Curl Gettext Freetype Irrlicht LevelDB OpenAL mbedTLS mbedx509 mbedcrypto Vorbis LuaJIT android_native_app_glue $(PROFILER_LIBS)
LOCAL_LDLIBS := -lEGL -lGLESv1_CM -lGLESv2 -landroid -lOpenSLES

View File

@ -0,0 +1,2 @@
add_library(luautf8 STATIC lutf8lib.c)
target_include_directories(luautf8 PUBLIC ${LUA_INCLUDE_DIR})

1300
lib/luautf8/lutf8lib.c Normal file

File diff suppressed because it is too large Load Diff

3602
lib/luautf8/unidata.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -568,6 +568,7 @@ if(BUILD_CLIENT)
${JSON_LIBRARY}
${PLATFORM_LIBS}
${CLIENT_PLATFORM_LIBS}
luautf8
)
target_link_libraries(
${client_LIBS}
@ -640,6 +641,7 @@ if(BUILD_SERVER)
${LUA_LIBRARY}
${GMP_LIBRARY}
${PLATFORM_LIBS}
luautf8
)
set_target_properties(${PROJECT_NAME}server PROPERTIES
COMPILE_DEFINITIONS "SERVER")

View File

@ -38,6 +38,7 @@ extern "C" {
#if USE_LUAJIT
#include "luajit.h"
#endif
LUALIB_API int luaopen_utf8(lua_State *L);
}
#include <cstdio>
@ -88,6 +89,9 @@ ScriptApiBase::ScriptApiBase(ScriptingType type):
else
luaL_openlibs(m_luastack);
lua_pushcfunction(m_luastack, luaopen_utf8);
lua_call(m_luastack, 0, 0);
// Make the ScriptApiBase* accessible to ModApiBase
#if INDIRECT_SCRIPTAPI_RIDX
*(void **)(lua_newuserdata(m_luastack, sizeof(void *))) = this;

View File

@ -89,6 +89,7 @@ void ScriptApiSecurity::initializeSecurity()
"string",
"table",
"math",
"utf8",
};
static const char *io_whitelist[] = {
"close",
@ -258,6 +259,7 @@ void ScriptApiSecurity::initializeSecurityClient()
"string",
"table",
"math",
"utf8",
};
static const char *os_whitelist[] = {
"clock",
@ -808,4 +810,3 @@ int ScriptApiSecurity::sl_os_remove(lua_State *L)
lua_call(L, 1, 2);
return 2;
}