make native function support and start working on support for error catching
This commit is contained in:
@@ -26,7 +26,29 @@ void add_field(ArgonObject *target, char *name, ArgonObject *object) {
|
||||
object, 0);
|
||||
}
|
||||
|
||||
ArgonObject *get_field(ArgonObject *target, char *name) {
|
||||
uint64_t hash = siphash64_bytes(name, strlen(name), siphash_key);
|
||||
return hashmap_lookup_GC(target->dict, hash);
|
||||
ArgonObject *get_field_for_class(ArgonObject *target, char *name) {
|
||||
char *field = "__base__";
|
||||
while (target) {
|
||||
uint64_t hash = siphash64_bytes(name, strlen(name), siphash_key);
|
||||
ArgonObject *object = hashmap_lookup_GC(target->dict, hash);
|
||||
if (object)
|
||||
return object;
|
||||
hash = siphash64_bytes(field, strlen(field), siphash_key);
|
||||
target = hashmap_lookup_GC(target->dict, hash);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ArgonObject *get_field(ArgonObject *target, char *name, bool recursive) {
|
||||
char *field = "__class__";
|
||||
while (target) {
|
||||
uint64_t hash = siphash64_bytes(name, strlen(name), siphash_key);
|
||||
ArgonObject *object = hashmap_lookup_GC(target->dict, hash);
|
||||
if (!recursive || object)
|
||||
return object;
|
||||
hash = siphash64_bytes(field, strlen(field), siphash_key);
|
||||
target = hashmap_lookup_GC(target->dict, hash);
|
||||
field = "__base__";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user