Skip to content

Commit

Permalink
adds lua printing to android, fixes null id from string construction
Browse files Browse the repository at this point in the history
tested lua printing on android device
  • Loading branch information
Jerboa-app committed Feb 27, 2024
1 parent 0a9a288 commit 9d7dd9a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ else()
string(TIMESTAMP TODAY "%Y-%m-%d:%H:%M:%S")
add_compile_definitions(TIMESTAMP="${TODAY}")

if (ANDROID)
add_compile_definitions(ANDROID)
elseif (WINDOWS)
add_compile_definitions(WINDOWS)
endif()

if (RELEASE)
if (ANDROID)
message("ANDROID MinSizeRel!")
Expand Down
32 changes: 20 additions & 12 deletions include/Object/id.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,32 @@ namespace Hop::Object

Id(std::string sid)
{
size_t delim = sid.find("-");

if (delim == sid.npos || delim == sid.size())

if (sid == "")
{
throw std::runtime_error("Cannot construct id from string: "+sid);
id = Id::NULL_ID_CODE;
}
else
{
size_t delim = sid.find("-");

if (delim == sid.npos || delim == sid.size())
{
throw std::runtime_error("Cannot construct id from string: "+sid);
}

std::string index, code;
std::string index, code;

index = sid.substr(0, delim);
code = sid.substr(delim+1, sid.size());
index = sid.substr(0, delim);
code = sid.substr(delim+1, sid.size());

if (code != uuids::to_string(getRunUUID()))
{
throw std::runtime_error("Cannot construct id from string, invalid run uuid: "+sid);
}
if (code != uuids::to_string(getRunUUID()))
{
throw std::runtime_error("Cannot construct id from string, invalid run uuid: "+sid);
}

id = uint64_t(std::stoull(index));
id = uint64_t(std::stoull(index));
}
}

static uint64_t next(){uint64_t thisId = nextId; nextId++; return thisId;}
Expand Down
8 changes: 8 additions & 0 deletions include/vendored/lua/src/lbaselib.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
#include "lauxlib.h"
#include "lualib.h"

#ifdef ANDROID
#include <android/log.h>
#endif


#if !defined(ANDROID) && !defined(WINDOWS)
const char * LUA_PRINT_ENTRY = "\033[1;34m[LUA] \033[0m\0";
const size_t LUA_ENTRY_LENGTH = 23;
Expand All @@ -41,6 +46,9 @@ static int luaB_print (lua_State *L) {
if (i > 1) /* not the first element? */
lua_writestring("\t", 1); /* add a tab before it */
lua_writestring(s, l); /* print it */
#if defined(ANDROID)
__android_log_print(ANDROID_LOG_INFO,"LUA","%s",s);
#endif
lua_pop(L, 1); /* pop result */
}
lua_writeline();
Expand Down

0 comments on commit 9d7dd9a

Please sign in to comment.