This makes implementing the functions a little cleaner.
private unsigned loaded = 0;
interface U:Object:Loadable
private unsigned loaded = 0;
interface U:Object:Loadable
- private int load(G:Object *go)
+ private int load(U:Object *uo)
- struct upkg_file *f = U_OBJECT(go)->pkg_file;
- Self *self = SELF(go);
+ struct upkg_file *f = uo->pkg_file;
+ Self *self = SELF(uo);
if (!self->_priv->loaded) {
g_return_val_if_fail(f != NULL, -1);
if (!self->_priv->loaded) {
g_return_val_if_fail(f != NULL, -1);
}
interface U:Object:Loadable
}
interface U:Object:Loadable
- private void unload(G:Object *go)
+ private void unload(U:Object *uo)
g_return_if_fail(self->_priv->loaded > 0);
g_return_if_fail(self->_priv->loaded > 0);
}
interface U:Object:Exportable
}
interface U:Object:Exportable
- private int export(G:Object *go, FILE *f)
+ private int export(U:Object *uo, FILE *f)
- if (self_load(go) != 0)
+ if (self_load(uo) != 0)
return -1;
rc = music_mod_dump(self->_priv->mod, f);
return -1;
rc = music_mod_dump(self->_priv->mod, f);
return rc;
}
interface U:Object:Exportable
return rc;
}
interface U:Object:Exportable
- private int export_name(G:Object *go, char *buf, size_t n)
+ private int export_name(U:Object *uo, char *buf, size_t n)
const char *type;
int rc;
const char *type;
int rc;
- if (self_load(go) != 0) {
+ if (self_load(uo) != 0) {
if (n > 0)
buf[0] = '\0';
return 0;
}
type = music_mod_type(self->_priv->mod);
if (n > 0)
buf[0] = '\0';
return 0;
}
type = music_mod_type(self->_priv->mod);
- rc = snprintf(buf, n, "%s.%s", U_OBJECT(go)->pkg_file->name, type);
+ rc = snprintf(buf, n, "%s.%s", uo->pkg_file->name, type);
-#include <glib-object.h>
-#include <uobject/exportable.h>
GType u_object_exportable_get_type(void)
{
GType u_object_exportable_get_type(void)
{
-int u_object_export(GObject *obj, FILE *f)
+int u_object_export(GObject *go, FILE *f)
- g_return_val_if_fail(U_OBJECT_IS_EXPORTABLE(obj), -1);
- return U_OBJECT_EXPORTABLE_GET_INTERFACE(obj)->export(obj, f);
+ g_return_val_if_fail(IS_U_OBJECT(go), -1);
+ g_return_val_if_fail(U_OBJECT_IS_EXPORTABLE(go), -1);
+ UObject *uo = U_OBJECT(go);
+
+ return U_OBJECT_EXPORTABLE_GET_INTERFACE(go)->export(uo, f);
-int u_object_export_name(GObject *obj, char *buf, size_t n)
+int u_object_export_name(GObject *go, char *buf, size_t n)
- g_return_val_if_fail(U_OBJECT_IS_EXPORTABLE(obj), -1);
- return U_OBJECT_EXPORTABLE_GET_INTERFACE(obj)->export_name(obj, buf, n);
+ g_return_val_if_fail(IS_U_OBJECT(go), -1);
+ g_return_val_if_fail(U_OBJECT_IS_EXPORTABLE(go), -1);
+ UObject *uo = U_OBJECT(go);
+
+ return U_OBJECT_EXPORTABLE_GET_INTERFACE(go)->export_name(uo, buf, n);
#define U_OBJECT_EXPORTABLE_H_
#include <stdio.h>
#define U_OBJECT_EXPORTABLE_H_
#include <stdio.h>
-#include <glib-object.h>
+#include <uobject/uobject.h>
#define U_TYPE_OBJECT_EXPORTABLE (u_object_exportable_get_type())
#define U_OBJECT_EXPORTABLE(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, \
#define U_TYPE_OBJECT_EXPORTABLE (u_object_exportable_get_type())
#define U_OBJECT_EXPORTABLE(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, \
struct UObjectExportableIface {
GTypeInterface parent;
struct UObjectExportableIface {
GTypeInterface parent;
- int (*export)(GObject *obj, FILE *f);
- int (*export_name)(GObject *obj, char *buf, size_t n);
+ int (*export)(UObject *obj, FILE *f);
+ int (*export_name)(UObject *obj, char *buf, size_t n);
};
GType u_object_exportable_get_type(void);
};
GType u_object_exportable_get_type(void);
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdio.h>
-#include <glib-object.h>
-#include <uobject/loadable.h>
GType u_object_loadable_get_type(void)
{
GType u_object_loadable_get_type(void)
{
-int u_object_load(GObject *obj)
+int u_object_load(GObject *go)
- g_return_val_if_fail(U_OBJECT_IS_LOADABLE(obj), -1);
- return U_OBJECT_LOADABLE_GET_INTERFACE(obj)->load(obj);
+ g_return_val_if_fail(IS_U_OBJECT(go), -1);
+ g_return_val_if_fail(U_OBJECT_IS_LOADABLE(go), -1);
+
+ return U_OBJECT_LOADABLE_GET_INTERFACE(go)->load(U_OBJECT(go));
-void u_object_unload(GObject *obj)
+void u_object_unload(GObject *go)
- g_return_if_fail(U_OBJECT_IS_LOADABLE(obj));
- U_OBJECT_LOADABLE_GET_INTERFACE(obj)->unload(obj);
+ g_return_if_fail(IS_U_OBJECT(go));
+ g_return_if_fail(U_OBJECT_IS_LOADABLE(go));
+
+ U_OBJECT_LOADABLE_GET_INTERFACE(go)->unload(U_OBJECT(go));
#ifndef U_OBJECT_LOADABLE_H_
#define U_OBJECT_LOADABLE_H_
#ifndef U_OBJECT_LOADABLE_H_
#define U_OBJECT_LOADABLE_H_
-#include <stdio.h>
-#include <glib-object.h>
+#include <uobject/uobject.h>
#define U_TYPE_OBJECT_LOADABLE (u_object_loadable_get_type())
#define U_OBJECT_LOADABLE(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, \
#define U_TYPE_OBJECT_LOADABLE (u_object_loadable_get_type())
#define U_OBJECT_LOADABLE(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, \
struct UObjectLoadableIface {
GTypeInterface parent;
struct UObjectLoadableIface {
GTypeInterface parent;
- int (*load)(GObject *obj);
- void (*unload)(GObject *obj);
+ int (*load)(UObject *obj);
+ void (*unload)(UObject *obj);
};
GType u_object_loadable_get_type(void);
};
GType u_object_loadable_get_type(void);