X-Git-Url: http://git.draconx.ca/gitweb/upkg.git/blobdiff_plain/d32d8618e0dcf6e83872394f68fd1770d6bd803f..f8b626c27a45abf36ee0f3d65e8ef5d19b6ede98:/src/uobject/uobject.c diff --git a/src/uobject/uobject.c b/src/uobject/uobject.c index 7b0a79e..15a26b5 100644 --- a/src/uobject/uobject.c +++ b/src/uobject/uobject.c @@ -87,6 +87,34 @@ get_real_size(unsigned long *real, unsigned size, unsigned char *buf, size_t n) return 0; } +static int decode_object_property(UObject *uo, GValue *val, unsigned long len) +{ + struct u_object_priv *priv = U_OBJECT_GET_PRIV(uo); + GObject *obj = NULL; + long index; + int rc; + + rc = upkg_decode_index(&index, priv->buf+len, priv->nbuf-len); + if (rc == 0 || index == 0) + return -1; + + if (index < 0) { + fprintf(stderr, "Imports not supported yet.\n"); + } else { + obj = u_object_new_from_package(uo->pkg, index-1); + } + + g_value_init(val, U_OBJECT_TYPE); + g_value_take_object(val, obj); + return 0; +} + +/* + * XXX: I must have been smoking the happy plant when I started property + * decoding. The tracking of various sizes in these functions makes no + * sense at all. + */ + static unsigned long decode_property(UObject *o, const char *name, struct upkg_file *f, unsigned long len) { @@ -123,6 +151,12 @@ decode_property(UObject *o, const char *name, struct upkg_file *f, unsigned long g_value_set_ulong(&val, unpack_32_le(priv->buf+len)); g_object_set_property(G_OBJECT(o), name, &val); break; + case PROPERTY_OBJECT: + rc = decode_object_property(o, &val, len); + if (rc != 0) + return 0; + g_object_set_property(G_OBJECT(o), name, &val); + break; default: fprintf(stderr, "Unhandled property type %x\n", (unsigned)type); }