mirror of https://github.com/mgba-emu/mgba.git
Scripting: Basic void type bringup
This commit is contained in:
parent
0b2cfb505f
commit
840e2806b5
|
@ -174,6 +174,8 @@ extern const struct mScriptType mSTWeakref;
|
||||||
extern const struct mScriptType mSTStringWrapper;
|
extern const struct mScriptType mSTStringWrapper;
|
||||||
extern const struct mScriptType mSTListWrapper;
|
extern const struct mScriptType mSTListWrapper;
|
||||||
|
|
||||||
|
extern struct mScriptValue mScriptValueNull;
|
||||||
|
|
||||||
struct mScriptType;
|
struct mScriptType;
|
||||||
struct mScriptValue {
|
struct mScriptValue {
|
||||||
const struct mScriptType* type;
|
const struct mScriptType* type;
|
||||||
|
|
|
@ -320,6 +320,9 @@ struct mScriptValue* _luaCoerce(struct mScriptEngineContextLua* luaContext, bool
|
||||||
const void* buffer;
|
const void* buffer;
|
||||||
struct mScriptValue* value = NULL;
|
struct mScriptValue* value = NULL;
|
||||||
switch (lua_type(luaContext->lua, -1)) {
|
switch (lua_type(luaContext->lua, -1)) {
|
||||||
|
case LUA_TNIL:
|
||||||
|
value = &mScriptValueNull;
|
||||||
|
break;
|
||||||
case LUA_TNUMBER:
|
case LUA_TNUMBER:
|
||||||
#if LUA_VERSION_NUM >= 503
|
#if LUA_VERSION_NUM >= 503
|
||||||
if (lua_isinteger(luaContext->lua, -1)) {
|
if (lua_isinteger(luaContext->lua, -1)) {
|
||||||
|
@ -398,6 +401,9 @@ bool _luaWrap(struct mScriptEngineContextLua* luaContext, struct mScriptValue* v
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
struct mScriptValue* newValue;
|
struct mScriptValue* newValue;
|
||||||
switch (value->type->base) {
|
switch (value->type->base) {
|
||||||
|
case mSCRIPT_TYPE_VOID:
|
||||||
|
lua_pushnil(luaContext->lua);
|
||||||
|
break;
|
||||||
case mSCRIPT_TYPE_SINT:
|
case mSCRIPT_TYPE_SINT:
|
||||||
if (value->type->size <= 4) {
|
if (value->type->size <= 4) {
|
||||||
lua_pushinteger(luaContext->lua, value->value.s32);
|
lua_pushinteger(luaContext->lua, value->value.s32);
|
||||||
|
|
|
@ -239,6 +239,11 @@ const struct mScriptType mSTWeakref = {
|
||||||
.hash = NULL,
|
.hash = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct mScriptValue mScriptValueNull = {
|
||||||
|
.type = &mSTVoid,
|
||||||
|
.refs = mSCRIPT_VALUE_UNREF
|
||||||
|
};
|
||||||
|
|
||||||
DEFINE_VECTOR(mScriptList, struct mScriptValue)
|
DEFINE_VECTOR(mScriptList, struct mScriptValue)
|
||||||
|
|
||||||
void _allocList(struct mScriptValue* val) {
|
void _allocList(struct mScriptValue* val) {
|
||||||
|
|
Loading…
Reference in New Issue