X-Git-Url: https://git.draconx.ca/gitweb/upkg.git/blobdiff_plain/bb5f99272ae78a2ddc07e0a54025baab39d84c49..559bcf15ef66d20d7e8527c690c0b4e5a66b6381:/src/uobject/uobject.c diff --git a/src/uobject/uobject.c b/src/uobject/uobject.c index 581ac07..7b0a79e 100644 --- a/src/uobject/uobject.c +++ b/src/uobject/uobject.c @@ -23,6 +23,7 @@ #include #include +#include #include "upkg.h" #include "pack.h" @@ -216,6 +217,27 @@ int u_object_deserialize(GObject *obj, struct upkg *pkg, unsigned long idx) return rc; } +GObject *u_object_new_from_package(struct upkg *upkg, unsigned long idx) +{ + const struct upkg_export *export; + const char *class, *package; + GObject *obj = NULL; + GType type; + + class = upkg_export_class(upkg, idx, &package); + + type = u_object_module_get_class(package, class); + if (type) { + obj = g_object_new(type, NULL); + if (u_object_deserialize(obj, upkg, idx) != 0) { + g_object_unref(obj); + return NULL; + } + } + + return obj; +} + static void u_object_init(UObject *o) { o->pkg = NULL;