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

Fix lua binding compatibility and some warnings with some compilers. #735

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions lua/def.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,11 @@ const upb_FileDef* lupb_FileDef_check(lua_State* L, int narg) {

static int lupb_FileDef_Dependency(lua_State* L) {
const upb_FileDef* f = lupb_FileDef_check(L, 1);
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
int index = luaL_checkinteger(L, 2);
#else
int index = luaL_checkint(L, 2);
#endif
const upb_FileDef* dep = upb_FileDef_Dependency(f, index);
lupb_wrapper_pushwrapper(L, 1, dep, LUPB_FILEDEF);
return 1;
Expand All @@ -631,7 +635,11 @@ static int lupb_FileDef_DependencyCount(lua_State* L) {

static int lupb_FileDef_enum(lua_State* L) {
const upb_FileDef* f = lupb_FileDef_check(L, 1);
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
int index = luaL_checkinteger(L, 2);
#else
int index = luaL_checkint(L, 2);
#endif
const upb_EnumDef* e = upb_FileDef_TopLevelEnum(f, index);
lupb_wrapper_pushwrapper(L, 1, e, LUPB_ENUMDEF);
return 1;
Expand All @@ -645,7 +653,11 @@ static int lupb_FileDef_enumcount(lua_State* L) {

static int lupb_FileDef_msg(lua_State* L) {
const upb_FileDef* f = lupb_FileDef_check(L, 1);
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
int index = luaL_checkinteger(L, 2);
#else
int index = luaL_checkint(L, 2);
#endif
const upb_MessageDef* m = upb_FileDef_TopLevelMessage(f, index);
lupb_wrapper_pushwrapper(L, 1, m, LUPB_MSGDEF);
return 1;
Expand Down
2 changes: 2 additions & 0 deletions lua/upb.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@
/* Lua compatibility code *****************************************************/

/* Shims for upcoming Lua 5.3 functionality. */
#if LUA_VERSION_NUM < 503
static bool lua_isinteger(lua_State* L, int argn) {
LUPB_UNUSED(L);
LUPB_UNUSED(argn);
return false;
}
#endif

/* Utility functions **********************************************************/

Expand Down
2 changes: 1 addition & 1 deletion lua/upbc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static void PrintString(int max_cols, absl::string_view* str,
} else if (ch == '\'') {
printer->PrintRaw("\\'");
max_cols--;
} else if (isprint(ch)) {
} else if (isprint(static_cast<int>(static_cast<unsigned char>(ch)))) {
printer->WriteRaw(&ch, 1);
max_cols--;
} else {
Expand Down
2 changes: 1 addition & 1 deletion upb/text/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ static void txtenc_map(txtenc* e, const upb_Map* map, const upb_FieldDef* f) {
#define CHK(x) \
do { \
if (!(x)) { \
return false; \
return NULL; \
} \
} while (0)

Expand Down