Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds lua printing to android, fixes null id from string construction #173

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading