Added dictionary support to OP_ITER

ISTRING_RESERVED was added to iStrings
call & callCFunction now use memmove instead of memcpy
Additionally, added cosmoO_setUserP, cosmoO_getUserP, cosmoO_setUserI and cosmoO_getUserI to the C API.
This commit is contained in:
2020-12-17 19:44:04 -06:00
parent b2c1f73e01
commit 0beeee0fdf
7 changed files with 105 additions and 17 deletions

View File

@@ -47,7 +47,10 @@ typedef struct CObjObject {
CommonHeader; // "is a" CObj
cosmo_Flag istringFlags; // enables us to have a much faster lookup for reserved IStrings (like __init, __index, etc.)
CTable tbl;
void *user; // userdata (NULL by default)
union { // userdata (NULL by default)
void *userP;
int userI;
};
struct CObjObject *proto; // protoobject, describes the behavior of the object
} CObjObject;
@@ -136,8 +139,10 @@ void cosmoO_setObject(CState *state, CObjObject *object, CValue key, CValue val)
bool cosmoO_indexObject(CState *state, CObjObject *object, CValue key, CValue *val);
bool cosmoO_newIndexObject(CState *state, CObjObject *object, CValue key, CValue val);
void cosmoO_setUserData(CState *state, CObjObject *object, void *p);
void *cosmoO_getUserData(CState *state, CObjObject *object);
void cosmoO_setUserP(CState *state, CObjObject *object, void *p);
void *cosmoO_getUserP(CState *state, CObjObject *object);
void cosmoO_setUserI(CState *state, CObjObject *object, int i);
int cosmoO_getUserI(CState *state, CObjObject *object);
// internal string
bool cosmoO_getIString(CState *state, CObjObject *object, int flag, CValue *val);