Updated rcheevos to 7.1.0
This commit is contained in:
parent
60010b4545
commit
3aa200e3ba
|
@ -3,6 +3,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#ifndef RC_DISABLE_LUA
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,6 +16,8 @@ extern "C" {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* RC_DISABLE_LUA */
|
||||||
|
|
||||||
static int rc_parse_operand_lua(rc_operand_t* self, const char** memaddr, lua_State* L, int funcs_ndx) {
|
static int rc_parse_operand_lua(rc_operand_t* self, const char** memaddr, lua_State* L, int funcs_ndx) {
|
||||||
const char* aux = *memaddr;
|
const char* aux = *memaddr;
|
||||||
const char* id;
|
const char* id;
|
||||||
|
@ -32,6 +36,8 @@ static int rc_parse_operand_lua(rc_operand_t* self, const char** memaddr, lua_St
|
||||||
aux++;
|
aux++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef RC_DISABLE_LUA
|
||||||
|
|
||||||
if (L != 0) {
|
if (L != 0) {
|
||||||
if (!lua_istable(L, funcs_ndx)) {
|
if (!lua_istable(L, funcs_ndx)) {
|
||||||
return RC_INVALID_LUA_OPERAND;
|
return RC_INVALID_LUA_OPERAND;
|
||||||
|
@ -48,6 +54,8 @@ static int rc_parse_operand_lua(rc_operand_t* self, const char** memaddr, lua_St
|
||||||
self->function_ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
self->function_ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* RC_DISABLE_LUA */
|
||||||
|
|
||||||
self->type = RC_OPERAND_LUA;
|
self->type = RC_OPERAND_LUA;
|
||||||
*memaddr = aux;
|
*memaddr = aux;
|
||||||
return RC_OK;
|
return RC_OK;
|
||||||
|
@ -288,6 +296,8 @@ int rc_parse_operand(rc_operand_t* self, const char** memaddr, int is_trigger, l
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef RC_DISABLE_LUA
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
rc_peek_t peek;
|
rc_peek_t peek;
|
||||||
void* ud;
|
void* ud;
|
||||||
|
@ -305,8 +315,13 @@ static int rc_luapeek(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* RC_DISABLE_LUA */
|
||||||
|
|
||||||
unsigned rc_evaluate_operand(rc_operand_t* self, rc_peek_t peek, void* ud, lua_State* L) {
|
unsigned rc_evaluate_operand(rc_operand_t* self, rc_peek_t peek, void* ud, lua_State* L) {
|
||||||
|
#ifndef RC_DISABLE_LUA
|
||||||
rc_luapeek_t luapeek;
|
rc_luapeek_t luapeek;
|
||||||
|
#endif /* RC_DISABLE_LUA */
|
||||||
|
|
||||||
unsigned value = 0;
|
unsigned value = 0;
|
||||||
|
|
||||||
switch (self->type) {
|
switch (self->type) {
|
||||||
|
@ -319,6 +334,8 @@ unsigned rc_evaluate_operand(rc_operand_t* self, rc_peek_t peek, void* ud, lua_S
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case RC_OPERAND_LUA:
|
case RC_OPERAND_LUA:
|
||||||
|
#ifndef RC_DISABLE_LUA
|
||||||
|
|
||||||
if (L != 0) {
|
if (L != 0) {
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, self->function_ref);
|
lua_rawgeti(L, LUA_REGISTRYINDEX, self->function_ref);
|
||||||
lua_pushcfunction(L, rc_luapeek);
|
lua_pushcfunction(L, rc_luapeek);
|
||||||
|
@ -340,6 +357,8 @@ unsigned rc_evaluate_operand(rc_operand_t* self, rc_peek_t peek, void* ud, lua_S
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* RC_DISABLE_LUA */
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RC_OPERAND_ADDRESS:
|
case RC_OPERAND_ADDRESS:
|
||||||
|
|
|
@ -5,16 +5,16 @@ LUA_SRC=lua/src
|
||||||
OBJ=$(RC_SRC)/trigger.o $(RC_SRC)/condset.o $(RC_SRC)/condition.o $(RC_SRC)/operand.o \
|
OBJ=$(RC_SRC)/trigger.o $(RC_SRC)/condset.o $(RC_SRC)/condition.o $(RC_SRC)/operand.o \
|
||||||
$(RC_SRC)/term.o $(RC_SRC)/expression.o $(RC_SRC)/value.o $(RC_SRC)/lboard.o \
|
$(RC_SRC)/term.o $(RC_SRC)/expression.o $(RC_SRC)/value.o $(RC_SRC)/lboard.o \
|
||||||
$(RC_SRC)/alloc.o $(RC_SRC)/format.o \
|
$(RC_SRC)/alloc.o $(RC_SRC)/format.o \
|
||||||
$(RC_URL_SRC)/url.o \
|
$(RC_URL_SRC)/url.o \
|
||||||
$(LUA_SRC)/lapi.o $(LUA_SRC)/lcode.o $(LUA_SRC)/lctype.o $(LUA_SRC)/ldebug.o \
|
$(LUA_SRC)/lapi.o $(LUA_SRC)/lcode.o $(LUA_SRC)/lctype.o $(LUA_SRC)/ldebug.o \
|
||||||
$(LUA_SRC)/ldo.o $(LUA_SRC)/ldump.o $(LUA_SRC)/lfunc.o $(LUA_SRC)/lgc.o $(LUA_SRC)/llex.o \
|
$(LUA_SRC)/ldo.o $(LUA_SRC)/ldump.o $(LUA_SRC)/lfunc.o $(LUA_SRC)/lgc.o $(LUA_SRC)/llex.o \
|
||||||
$(LUA_SRC)/lmem.o $(LUA_SRC)/lobject.o $(LUA_SRC)/lopcodes.o $(LUA_SRC)/lparser.o \
|
$(LUA_SRC)/lmem.o $(LUA_SRC)/lobject.o $(LUA_SRC)/lopcodes.o $(LUA_SRC)/lparser.o \
|
||||||
$(LUA_SRC)/lstate.o $(LUA_SRC)/lstring.o $(LUA_SRC)/ltable.o $(LUA_SRC)/ltm.o \
|
$(LUA_SRC)/lstate.o $(LUA_SRC)/lstring.o $(LUA_SRC)/ltable.o $(LUA_SRC)/ltm.o \
|
||||||
$(LUA_SRC)/lundump.o $(LUA_SRC)/lvm.o $(LUA_SRC)/lzio.o $(LUA_SRC)/lauxlib.o \
|
$(LUA_SRC)/lundump.o $(LUA_SRC)/lvm.o $(LUA_SRC)/lzio.o $(LUA_SRC)/lauxlib.o \
|
||||||
$(LUA_SRC)/lbaselib.o $(LUA_SRC)/lbitlib.o $(LUA_SRC)/lcorolib.o $(LUA_SRC)/ldblib.o \
|
$(LUA_SRC)/lbaselib.o $(LUA_SRC)/lbitlib.o $(LUA_SRC)/lcorolib.o $(LUA_SRC)/ldblib.o \
|
||||||
$(LUA_SRC)/liolib.o $(LUA_SRC)/lmathlib.o $(LUA_SRC)/loslib.o $(LUA_SRC)/lstrlib.o \
|
$(LUA_SRC)/liolib.o $(LUA_SRC)/lmathlib.o $(LUA_SRC)/loslib.o $(LUA_SRC)/lstrlib.o \
|
||||||
$(LUA_SRC)/ltablib.o $(LUA_SRC)/lutf8lib.o $(LUA_SRC)/loadlib.o $(LUA_SRC)/linit.o \
|
$(LUA_SRC)/ltablib.o $(LUA_SRC)/lutf8lib.o $(LUA_SRC)/loadlib.o $(LUA_SRC)/linit.o \
|
||||||
test.o
|
test.o
|
||||||
|
|
||||||
all: test
|
all: test
|
||||||
|
|
||||||
|
|
|
@ -2065,9 +2065,11 @@ static void test_lboard(void) {
|
||||||
static void test_lua(void) {
|
static void test_lua(void) {
|
||||||
{
|
{
|
||||||
/*------------------------------------------------------------------------
|
/*------------------------------------------------------------------------
|
||||||
TestJson
|
TestLua
|
||||||
------------------------------------------------------------------------*/
|
------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef RC_DISABLE_LUA
|
||||||
|
|
||||||
lua_State* L;
|
lua_State* L;
|
||||||
const char* luacheevo = "return { test = function(peek, ud) return peek(0, 4, ud) end }";
|
const char* luacheevo = "return { test = function(peek, ud) return peek(0, 4, ud) end }";
|
||||||
unsigned char ram[] = {0x00, 0x12, 0x34, 0xAB, 0x56};
|
unsigned char ram[] = {0x00, 0x12, 0x34, 0xAB, 0x56};
|
||||||
|
@ -2087,6 +2089,8 @@ static void test_lua(void) {
|
||||||
|
|
||||||
trigger = rc_parse_trigger(buffer, "@test=0xX0", L, 1);
|
trigger = rc_parse_trigger(buffer, "@test=0xX0", L, 1);
|
||||||
assert(rc_test_trigger(trigger, peek, &memory, L) != 0);
|
assert(rc_test_trigger(trigger, peek, &memory, L) != 0);
|
||||||
|
|
||||||
|
#endif /* RC_DISABLE_LUA */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue