Change uobject to u_object, and export all symbols starting with u_.
The library is starting to include package stuff which will use the
u_pkg prefix.
loadable.c exportable.c
libuobject_la_CPPFLAGS = $(GLIB_CFLAGS) $(LTDLINCL)
libuobject_la_LIBADD = $(LIBLTDL) $(GLIB_LIBS)
-libuobject_la_LDFLAGS = -export-symbols-regex '^uobject_'
+libuobject_la_LDFLAGS = -export-symbols-regex '^u_'
libupkg_la_SOURCES = libupkg.c pack.c
static void exportable_init(UObjectExportable *);
static void loadable_init(UObjectLoadable *);
-G_DEFINE_DYNAMIC_TYPE_EXTENDED(EngineMusic, engine_music, UOBJECT_TYPE, 0,
- G_IMPLEMENT_INTERFACE(UOBJECT_TYPE_EXPORTABLE, exportable_init)
- G_IMPLEMENT_INTERFACE(UOBJECT_TYPE_LOADABLE, loadable_init)
+G_DEFINE_DYNAMIC_TYPE_EXTENDED(EngineMusic, engine_music, U_OBJECT_TYPE, 0,
+ G_IMPLEMENT_INTERFACE(U_OBJECT_TYPE_EXPORTABLE, exportable_init)
+ G_IMPLEMENT_INTERFACE(U_OBJECT_TYPE_LOADABLE, loadable_init)
);
static int load(GObject *o)
unsigned char buf[32];
long size;
- UOBJECT_CLASS(engine_music_parent_class)->deserialize(o, f);
+ U_OBJECT_CLASS(engine_music_parent_class)->deserialize(o, f);
buflen = upkg_export_read(f, buf, sizeof buf);
static void engine_music_class_init(EngineMusicClass *class)
{
- UObjectClass *uo = UOBJECT_CLASS(class);
+ UObjectClass *uo = U_OBJECT_CLASS(class);
GObjectClass *go = G_OBJECT_CLASS(class);
g_type_class_add_private(class, sizeof (struct music_priv));
{
}
-G_DEFINE_DYNAMIC_TYPE(EngineTexture, engine_texture, UOBJECT_TYPE);
+G_DEFINE_DYNAMIC_TYPE(EngineTexture, engine_texture, U_OBJECT_TYPE);
static int deserialize(UObject *o, struct upkg_file *f)
{
struct texture_priv *priv = TEXTURE_GET_PRIV(o);
EngineTexture *t = ENGINE_TEXTURE(o);
- UOBJECT_CLASS(engine_texture_parent_class)->deserialize(o, f);
+ U_OBJECT_CLASS(engine_texture_parent_class)->deserialize(o, f);
printf("Texture size: %ux%u\n", t->usize, t->vsize);
static void engine_texture_class_init(EngineTextureClass *class)
{
- UObjectClass *uo = UOBJECT_CLASS(class);
+ UObjectClass *uo = U_OBJECT_CLASS(class);
GObjectClass *go = G_OBJECT_CLASS(class);
g_type_class_add_private(class, sizeof (struct texture_priv));
#include <glib-object.h>
#include <uobject/exportable.h>
-GType uobject_exportable_get_type(void)
+GType u_object_exportable_get_type(void)
{
static GType type = 0;
if (type == 0) {
return type;
}
-int uobject_export(GObject *obj, FILE *f)
+int u_object_export(GObject *obj, FILE *f)
{
- g_return_val_if_fail(UOBJECT_IS_EXPORTABLE(obj), -1);
- return UOBJECT_EXPORTABLE_GET_INTERFACE(obj)->export(obj, f);
+ g_return_val_if_fail(U_OBJECT_IS_EXPORTABLE(obj), -1);
+ return U_OBJECT_EXPORTABLE_GET_INTERFACE(obj)->export(obj, f);
}
-int uobject_export_name(GObject *obj, char *buf, size_t n)
+int u_object_export_name(GObject *obj, char *buf, size_t n)
{
- g_return_val_if_fail(UOBJECT_IS_EXPORTABLE(obj), -1);
- return UOBJECT_EXPORTABLE_GET_INTERFACE(obj)->export_name(obj, buf, n);
+ g_return_val_if_fail(U_OBJECT_IS_EXPORTABLE(obj), -1);
+ return U_OBJECT_EXPORTABLE_GET_INTERFACE(obj)->export_name(obj, buf, n);
}
#include <glib-object.h>
#include <uobject/loadable.h>
-GType uobject_loadable_get_type(void)
+GType u_object_loadable_get_type(void)
{
static GType type = 0;
if (type == 0) {
return type;
}
-int uobject_load(GObject *obj)
+int u_object_load(GObject *obj)
{
- g_return_val_if_fail(UOBJECT_IS_LOADABLE(obj), -1);
- return UOBJECT_LOADABLE_GET_INTERFACE(obj)->load(obj);
+ g_return_val_if_fail(U_OBJECT_IS_LOADABLE(obj), -1);
+ return U_OBJECT_LOADABLE_GET_INTERFACE(obj)->load(obj);
}
-void uobject_unload(GObject *obj)
+void u_object_unload(GObject *obj)
{
- g_return_if_fail(UOBJECT_IS_LOADABLE(obj));
- UOBJECT_LOADABLE_GET_INTERFACE(obj)->unload(obj);
+ g_return_if_fail(U_OBJECT_IS_LOADABLE(obj));
+ U_OBJECT_LOADABLE_GET_INTERFACE(obj)->unload(obj);
}
return strcmp(ma->name, mb->name);
}
-int uobject_module_init(void)
+int u_object_module_init(void)
{
if (!initialized) {
package_tree = avl_create(modcmp, NULL, NULL);
return 0;
}
-int uobject_module_exit(void)
+int u_object_module_exit(void)
{
if (--initialized)
return 0;
return 0;
}
-GType uobject_module_get_class(const char *package, const char *class)
+GType u_object_module_get_class(const char *package, const char *class)
{
char buf[strlen(package) + strlen(class) + 1];
GTypeModule search = { .name = str_cpy_lower(buf, package) };
#include "upkg.h"
#include "pack.h"
-#define UOBJECT_GET_PRIV(o) \
- G_TYPE_INSTANCE_GET_PRIVATE(o, UOBJECT_TYPE, struct uobject_priv)
+#define U_OBJECT_GET_PRIV(o) \
+ G_TYPE_INSTANCE_GET_PRIVATE(o, U_OBJECT_TYPE, struct u_object_priv)
enum {
PROPERTY_BYTE = 1,
PROPERTY_FIXEDARRAY,
};
-struct uobject_property {
- const char *name;
- GValue val;
-};
-
-struct uobject_priv {
+struct u_object_priv {
struct upkg_file *f;
size_t base, len;
unsigned long nbuf;
};
-G_DEFINE_TYPE(UObject, uobject, G_TYPE_OBJECT);
+G_DEFINE_TYPE(UObject, u_object, G_TYPE_OBJECT);
static unsigned long
get_real_size(unsigned long *real, unsigned size, unsigned char *buf, size_t n)
static unsigned long
decode_property(UObject *o, const char *name, struct upkg_file *f, unsigned long len)
{
- struct uobject_priv *priv = UOBJECT_GET_PRIV(o);
+ struct u_object_priv *priv = U_OBJECT_GET_PRIV(o);
unsigned long real_size, rc;
int type, size, top;
GValue val = {0};
/* Deserialize properties from an Unreal package. */
static int deserialize(UObject *o, struct upkg_file *f)
{
- struct uobject_priv *priv = UOBJECT_GET_PRIV(o);
+ struct u_object_priv *priv = U_OBJECT_GET_PRIV(o);
unsigned long rc, tot_len = 0;
while (1) {
break;
}
- rc = decode_property(UOBJECT(o), name, f, len);
+ rc = decode_property(U_OBJECT(o), name, f, len);
if (rc == 0)
return -1;
len = rc;
return 0;
}
-int uobject_deserialize(GObject *obj, struct upkg *pkg, unsigned long idx)
+int u_object_deserialize(GObject *obj, struct upkg *pkg, unsigned long idx)
{
- g_return_val_if_fail(IS_UOBJECT(obj), -1);
- UObject *uo = UOBJECT(obj);
+ g_return_val_if_fail(IS_U_OBJECT(obj), -1);
+ UObject *uo = U_OBJECT(obj);
struct upkg_file *f;
int rc;
return -1;
}
- rc = UOBJECT_GET_CLASS(obj)->deserialize(uo, f);
+ rc = U_OBJECT_GET_CLASS(obj)->deserialize(uo, f);
if (rc != 0) {
upkg_export_close(f);
} else {
return rc;
}
-static void uobject_init(UObject *o)
+static void u_object_init(UObject *o)
{
o->pkg = NULL;
o->pkg_file = NULL;
o->pkg_idx = 0;
}
-static void uobject_finalize(GObject *o)
+static void u_object_finalize(GObject *o)
{
- UObject *uo = UOBJECT(o);
+ UObject *uo = U_OBJECT(o);
if (uo->pkg_file) {
upkg_export_close(uo->pkg_file);
}
- G_OBJECT_CLASS(uobject_parent_class)->finalize(o);
+ G_OBJECT_CLASS(u_object_parent_class)->finalize(o);
}
-static void uobject_class_init(UObjectClass *class)
+static void u_object_class_init(UObjectClass *class)
{
- g_type_class_add_private(class, sizeof (struct uobject_priv));
+ g_type_class_add_private(class, sizeof (struct u_object_priv));
GObjectClass *go = G_OBJECT_CLASS(class);
class->deserialize = deserialize;
- go->finalize = uobject_finalize;
+ go->finalize = u_object_finalize;
}
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef UOBJECT_EXPORTABLE_H_
-#define UOBJECT_EXPORTABLE_H_
+#ifndef U_OBJECT_EXPORTABLE_H_
+#define U_OBJECT_EXPORTABLE_H_
#include <stdio.h>
#include <glib-object.h>
-#define UOBJECT_TYPE_EXPORTABLE (uobject_exportable_get_type())
-#define UOBJECT_EXPORTABLE(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, \
- UOBJECT_TYPE_EXPORTABLE, UObjectExportable)
-#define UOBJECT_IS_EXPORTABLE(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, \
- UOBJECT_TYPE_EXPORTABLE)
-#define UOBJECT_EXPORTABLE_GET_INTERFACE(inst) G_TYPE_INSTANCE_GET_INTERFACE \
- (inst, UOBJECT_TYPE_EXPORTABLE, UObjectExportable)
+#define U_OBJECT_TYPE_EXPORTABLE (u_object_exportable_get_type())
+#define U_OBJECT_EXPORTABLE(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, \
+ U_OBJECT_TYPE_EXPORTABLE, UObjectExportable)
+#define U_OBJECT_IS_EXPORTABLE(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, \
+ U_OBJECT_TYPE_EXPORTABLE)
+#define U_OBJECT_EXPORTABLE_GET_INTERFACE(inst) G_TYPE_INSTANCE_GET_INTERFACE \
+ (inst, U_OBJECT_TYPE_EXPORTABLE, UObjectExportable)
typedef struct UObjectExportable UObjectExportable;
int (*export_name)(GObject *obj, char *buf, size_t n);
};
-GType uobject_exportable_get_type(void);
+GType u_object_exportable_get_type(void);
/*
* Export the object by writing it to the given FILE handle, which must have
* been opened for writing in binary mode.
*/
-int uobject_export(GObject *obj, FILE *f);
+int u_object_export(GObject *obj, FILE *f);
/*
* Get the suggested output filename. Not more than n-1 characters of the
* not bounded. It is valid to call this function with a NULL buffer and a 0
* size in order to determine how large the buffer needs to be.
*/
-int uobject_export_name(GObject *obj, char *buf, size_t n);
+int u_object_export_name(GObject *obj, char *buf, size_t n);
#endif
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef UOBJECT_LOADABLE_H_
-#define UOBJECT_LOADABLE_H_
+#ifndef U_OBJECT_LOADABLE_H_
+#define U_OBJECT_LOADABLE_H_
#include <stdio.h>
#include <glib-object.h>
-#define UOBJECT_TYPE_LOADABLE (uobject_loadable_get_type())
-#define UOBJECT_LOADABLE(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, \
- UOBJECT_TYPE_LOADABLE, UObjectLoadable)
-#define UOBJECT_IS_LOADABLE(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, \
- UOBJECT_TYPE_LOADABLE)
-#define UOBJECT_LOADABLE_GET_INTERFACE(inst) G_TYPE_INSTANCE_GET_INTERFACE \
- (inst, UOBJECT_TYPE_LOADABLE, UObjectLoadable)
+#define U_OBJECT_TYPE_LOADABLE (u_object_loadable_get_type())
+#define U_OBJECT_LOADABLE(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, \
+ U_OBJECT_TYPE_LOADABLE, UObjectLoadable)
+#define U_OBJECT_IS_LOADABLE(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, \
+ U_OBJECT_TYPE_LOADABLE)
+#define U_OBJECT_LOADABLE_GET_INTERFACE(inst) G_TYPE_INSTANCE_GET_INTERFACE \
+ (inst, U_OBJECT_TYPE_LOADABLE, UObjectLoadable)
typedef struct UObjectLoadable UObjectLoadable;
void (*unload)(GObject *obj);
};
-GType uobject_loadable_get_type(void);
+GType u_object_loadable_get_type(void);
-int uobject_load(GObject *obj);
-void uobject_unload(GObject *obj);
+int u_object_load(GObject *obj);
+void u_object_unload(GObject *obj);
#endif
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef UOBJECT_MODULE_H_
-#define UOBJECT_MODULE_H_
+#ifndef U_OBJECT_MODULE_H_
+#define U_OBJECT_MODULE_H_
#include <glib-object.h>
* Initialize the UObject module system. Returns 0 on success, -1 otherwise.
* The module system can be safely initialized multiple times.
*/
-int uobject_module_init(void);
+int u_object_module_init(void);
/*
* Shutdown the UObject module system. Returns 0 on success, -1 otherwise.
* The module system is only shut down when this function has been called as
- * many times as uobject_module_init.
+ * many times as u_object_module_init.
*/
-int uobject_module_exit(void);
+int u_object_module_exit(void);
/*
* Get a class handle from the UObject module system. This will load the
*
* Returns 0 on failure.
*/
-GType uobject_module_get_class(const char *package, const char *class);
+GType u_object_module_get_class(const char *package, const char *class);
#endif
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef UOBJECT_PACKAGE_H_
-#define UOBJECT_PACKAGE_H_
+#ifndef U_OBJECT_PACKAGE_H_
+#define U_OBJECT_PACKAGE_H_
#include <glib-object.h>
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef UOBJECT_UOBJECT_H_
-#define UOBJECT_UOBJECT_H_
+#ifndef U_OBJECT_H_
+#define U_OBJECT_H_
#include <glib-object.h>
#include "upkg.h"
-#define UOBJECT_TYPE uobject_get_type()
-#define UOBJECT(obj) \
- G_TYPE_CHECK_INSTANCE_CAST(obj, UOBJECT_TYPE, UObject)
-#define UOBJECT_CLASS(class) \
- G_TYPE_CHECK_CLASS_CAST(class, UOBJECT_TYPE, UObjectClass)
-#define IS_UOBJECT(obj) \
- G_TYPE_CHECK_INSTANCE_TYPE(obj, UOBJECT_TYPE)
-#define IS_UOBJECT_CLASS(class) \
- G_TYPE_CHECK_CLASS_TYPE(class, UOBJECT_TYPE, UObjectClass)
-#define UOBJECT_GET_CLASS(obj) \
- G_TYPE_INSTANCE_GET_CLASS(obj, UOBJECT_TYPE, UObjectClass)
+#define U_OBJECT_TYPE u_object_get_type()
+#define U_OBJECT(obj) \
+ G_TYPE_CHECK_INSTANCE_CAST(obj, U_OBJECT_TYPE, UObject)
+#define U_OBJECT_CLASS(class) \
+ G_TYPE_CHECK_CLASS_CAST(class, U_OBJECT_TYPE, UObjectClass)
+#define IS_U_OBJECT(obj) \
+ G_TYPE_CHECK_INSTANCE_TYPE(obj, U_OBJECT_TYPE)
+#define IS_U_OBJECT_CLASS(class) \
+ G_TYPE_CHECK_CLASS_TYPE(class, U_OBJECT_TYPE, UObjectClass)
+#define U_OBJECT_GET_CLASS(obj) \
+ G_TYPE_INSTANCE_GET_CLASS(obj, U_OBJECT_TYPE, UObjectClass)
typedef struct UObject UObject;
typedef struct UObjectClass UObjectClass;
int (*deserialize)(UObject *obj, struct upkg_file *f);
};
-GType uobject_get_type(void);
+GType u_object_get_type(void);
-int uobject_deserialize(GObject *obj, struct upkg *pkg, unsigned long idx);
+int u_object_deserialize(GObject *obj, struct upkg *pkg, unsigned long idx);
#endif
char name[256];
FILE *of;
- if (uobject_deserialize(obj, pkg, idx) != 0) {
+ if (u_object_deserialize(obj, pkg, idx) != 0) {
return -1;
}
- if (UOBJECT_IS_LOADABLE(obj) && uobject_load(obj) != 0) {
+ if (U_OBJECT_IS_LOADABLE(obj) && u_object_load(obj) != 0) {
return -1;
}
- uobject_export_name(obj, name, sizeof name);
+ u_object_export_name(obj, name, sizeof name);
printf("exporting %s to %s\n", upkg_export_name(pkg, idx), name);
of = fopen(name, "wb");
return -1;
}
- uobject_export(obj, of);
+ u_object_export(obj, of);
if (fclose(of) != 0) {
perror(name);
return -1;
}
- if (UOBJECT_IS_LOADABLE(obj)) {
- uobject_unload(obj);
+ if (U_OBJECT_IS_LOADABLE(obj)) {
+ u_object_unload(obj);
}
return 0;
return EXIT_FAILURE;
}
- type = uobject_module_get_class(package, class);
+ type = u_object_module_get_class(package, class);
if (!type) continue;
obj = g_object_new(type, NULL);
- if (UOBJECT_IS_EXPORTABLE(obj)) {
+ if (U_OBJECT_IS_EXPORTABLE(obj)) {
if (export(pkg, obj, i) != 0) {
rc = EXIT_FAILURE;
}
return EXIT_FAILURE;
}
- if (uobject_module_init() != 0)
+ if (u_object_module_init() != 0)
return EXIT_FAILURE;
pkg = upkg_fopen(argv[optind]);
}
upkg_close(pkg);
- uobject_module_exit();
+ u_object_module_exit();
return rc;
}