/*
* upkg: tool for manipulating Unreal Tournament packages.
- * Copyright (C) 2009 Nick Bowler
+ * Copyright © 2009-2011 Nick Bowler
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <glib-object.h>
#include <uobject/uobject.h>
+#include <uobject/module.h>
#include "upkg.h"
#include "pack.h"
return -1;
len = rc;
- name = upkg_get_name(f->pkg, tmp);
+ name = upkg_get_name(uo->pkg, tmp);
if (!name) {
return -1;
} else if (strcmp(name, "None") == 0) {
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;