mirror of https://github.com/mgba-emu/mgba.git
Scripting: Add some helper macros
This commit is contained in:
parent
34752e95d5
commit
a2b0230c71
|
@ -155,6 +155,18 @@ CXX_GUARD_START
|
|||
.call = _binding_ ## NAME \
|
||||
};
|
||||
|
||||
#define mSCRIPT_MAKE(TYPE, FIELD, VALUE) (struct mScriptValue) { \
|
||||
.type = (TYPE), \
|
||||
.refs = mSCRIPT_VALUE_UNREF, \
|
||||
.value = { \
|
||||
.FIELD = (VALUE) \
|
||||
}, \
|
||||
} \
|
||||
|
||||
#define mSCRIPT_MAKE_S32(VALUE) mSCRIPT_MAKE(mSCRIPT_TYPE_MS_S32, s32, VALUE)
|
||||
#define mSCRIPT_MAKE_U32(VALUE) mSCRIPT_MAKE(mSCRIPT_TYPE_MS_U32, u32, VALUE)
|
||||
#define mSCRIPT_MAKE_F32(VALUE) mSCRIPT_MAKE(mSCRIPT_TYPE_MS_F32, f32, VALUE)
|
||||
|
||||
enum {
|
||||
mSCRIPT_TYPE_VOID = 0,
|
||||
mSCRIPT_TYPE_SINT,
|
||||
|
|
|
@ -180,21 +180,8 @@ M_TEST_DEFINE(hashTableBasic) {
|
|||
assert_int_equal(intValue->value.s32, 0);
|
||||
assert_int_equal(intValue->refs, 1);
|
||||
|
||||
struct mScriptValue intKey = {
|
||||
.type = mSCRIPT_TYPE_MS_S32,
|
||||
.value = {
|
||||
.s32 = 1234
|
||||
},
|
||||
.refs = mSCRIPT_VALUE_UNREF
|
||||
};
|
||||
|
||||
struct mScriptValue badKey = {
|
||||
.type = mSCRIPT_TYPE_MS_S32,
|
||||
.value = {
|
||||
.s32 = 1235
|
||||
},
|
||||
.refs = mSCRIPT_VALUE_UNREF
|
||||
};
|
||||
struct mScriptValue intKey = mSCRIPT_MAKE_S32(1234);
|
||||
struct mScriptValue badKey = mSCRIPT_MAKE_S32(1235);
|
||||
|
||||
assert_true(mScriptTableInsert(table, &intKey, intValue));
|
||||
assert_int_equal(intValue->refs, 2);
|
||||
|
|
Loading…
Reference in New Issue