mirror of
https://github.com/CPunch/Cosmo.git
synced 2026-01-02 13:50:18 +00:00
Added object.* library; added cosmoO_isDescendant to cobj.[ch]
The object library includes: - __proto getter and setter tables (might make an option to lock __proto in the future) - ischild() cosmoB_loadDebug was renamed to cosmoB_loadVM and now only loads the VM library
This commit is contained in:
14
src/cobj.c
14
src/cobj.c
@@ -288,6 +288,20 @@ CObjString *cosmoO_pushVFString(CState *state, const char *format, va_list args)
|
||||
return cosmoV_readString(*start); // start should be state->top - 1
|
||||
}
|
||||
|
||||
// walks the protos of obj and checks for proto
|
||||
bool cosmoO_isDescendant(CObj *obj, CObjObject *proto) {
|
||||
CObjObject *curr = obj->proto;
|
||||
|
||||
while (curr != NULL) {
|
||||
if (curr == proto)
|
||||
return true; // found proto! return true
|
||||
|
||||
curr = ((CObj*)curr)->proto;
|
||||
}
|
||||
|
||||
// we didn't find the proto
|
||||
return false;
|
||||
}
|
||||
|
||||
// returns false if error thrown
|
||||
bool cosmoO_getRawObject(CState *state, CObjObject *proto, CValue key, CValue *val, CObj *obj) {
|
||||
|
||||
Reference in New Issue
Block a user