summaryrefslogtreecommitdiffhomepage
path: root/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'object.c')
-rw-r--r--object.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/object.c b/object.c
index 5841f76..4e49ac4 100644
--- a/object.c
+++ b/object.c
@@ -316,6 +316,29 @@ uc_prototype_new(uc_prototype *parent)
return proto;
}
+uc_prototype *
+uc_protoref_new(json_object *value, uc_prototype *proto)
+{
+ uc_prototype *ref;
+
+ if (!json_object_is_type(value, json_type_object) &&
+ !json_object_is_type(value, json_type_array))
+ return NULL;
+
+ ref = xalloc(sizeof(*ref));
+ ref->header.type = UC_OBJ_PROTOTYPE;
+ ref->header.jso = value;
+
+ if (proto) {
+ ref->parent = proto;
+ uc_value_get(proto->header.jso);
+ }
+
+ json_object_set_serializer(ref->header.jso, NULL, ref, uc_prototype_gc);
+
+ return ref;
+}
+
static uc_ressource_types res_types;