added cosmoO_setUserData and cosmoO_getUserData

This commit is contained in:
CPunch 2020-12-06 13:38:05 -06:00
parent 9ca67c8408
commit 005e2acd1e
2 changed files with 11 additions and 0 deletions

View File

@ -250,6 +250,14 @@ void cosmoO_setObject(CState *state, CObjObject *object, CValue key, CValue val)
} }
} }
void cosmoO_setUserData(CState *state, CObjObject *object, void *p) {
object->user = p;
}
void *cosmoO_getUserData(CState *state, CObjObject *object) {
return object->user;
}
bool cosmoO_getIString(CState *state, CObjObject *object, int flag, CValue *val) { bool cosmoO_getIString(CState *state, CObjObject *object, int flag, CValue *val) {
if (readFlag(object->istringFlags, flag)) if (readFlag(object->istringFlags, flag))
return false; // it's been cached as bad return false; // it's been cached as bad

View File

@ -118,6 +118,9 @@ CObjUpval *cosmoO_newUpvalue(CState *state, CValue *val);
bool cosmoO_getObject(CState *state, CObjObject *object, CValue key, CValue *val); bool cosmoO_getObject(CState *state, CObjObject *object, CValue key, CValue *val);
void cosmoO_setObject(CState *state, CObjObject *object, CValue key, CValue val); void cosmoO_setObject(CState *state, CObjObject *object, CValue key, CValue val);
void cosmoO_setUserData(CState *state, CObjObject *object, void *p);
void *cosmoO_getUserData(CState *state, CObjObject *object);
// internal string // internal string
bool cosmoO_getIString(CState *state, CObjObject *object, int flag, CValue *val); bool cosmoO_getIString(CState *state, CObjObject *object, int flag, CValue *val);