summaryrefslogtreecommitdiff
path: root/src/registers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/registers.c')
-rw-r--r--src/registers.c323
1 files changed, 255 insertions, 68 deletions
diff --git a/src/registers.c b/src/registers.c
index 13bd69b..94711aa 100644
--- a/src/registers.c
+++ b/src/registers.c
@@ -116,6 +116,7 @@ typedef struct _EmulationRegisterPrivate EmulationRegisterPrivate;
typedef struct _EmulationRegisterIterator EmulationRegisterIterator;
typedef struct _EmulationRegisterIteratorClass EmulationRegisterIteratorClass;
typedef struct _EmulationRegisterIteratorPrivate EmulationRegisterIteratorPrivate;
+typedef struct _EmulationParamSpecRegisterIterator EmulationParamSpecRegisterIterator;
#define EMULATION_TYPE_REGISTER_LIST (emulation_register_list_get_type ())
#define EMULATION_REGISTER_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMULATION_TYPE_REGISTER_LIST, EmulationRegisterList))
@@ -158,12 +159,12 @@ typedef enum {
} EmulationAccessType;
struct _EmulationBitfieldValue {
- GObject parent_instance;
+ GInitiallyUnowned parent_instance;
EmulationBitfieldValuePrivate * priv;
};
struct _EmulationBitfieldValueClass {
- GObjectClass parent_class;
+ GInitiallyUnownedClass parent_class;
};
struct _EmulationBitfieldValuePrivate {
@@ -173,12 +174,12 @@ struct _EmulationBitfieldValuePrivate {
};
struct _EmulationBitfieldEnum {
- GObject parent_instance;
+ GInitiallyUnowned parent_instance;
EmulationBitfieldEnumPrivate * priv;
};
struct _EmulationBitfieldEnumClass {
- GObjectClass parent_class;
+ GInitiallyUnownedClass parent_class;
};
struct _EmulationBitfieldEnumPrivate {
@@ -186,12 +187,12 @@ struct _EmulationBitfieldEnumPrivate {
};
struct _EmulationBitfield {
- GObject parent_instance;
+ GInitiallyUnowned parent_instance;
EmulationBitfieldPrivate * priv;
};
struct _EmulationBitfieldClass {
- GObjectClass parent_class;
+ GInitiallyUnownedClass parent_class;
};
struct _EmulationBitfieldPrivate {
@@ -222,12 +223,12 @@ struct _EmulationParamSpecBitfieldIterator {
};
struct _EmulationRegisterInfo {
- GObject parent_instance;
+ GInitiallyUnowned parent_instance;
EmulationRegisterInfoPrivate * priv;
};
struct _EmulationRegisterInfoClass {
- GObjectClass parent_class;
+ GInitiallyUnownedClass parent_class;
};
struct _EmulationRegisterInfoPrivate {
@@ -240,12 +241,12 @@ struct _EmulationRegisterInfoPrivate {
};
struct _EmulationRegister {
- GObject parent_instance;
+ GInitiallyUnowned parent_instance;
EmulationRegisterPrivate * priv;
};
struct _EmulationRegisterClass {
- GObjectClass parent_class;
+ GInitiallyUnownedClass parent_class;
};
struct _EmulationRegisterPrivate {
@@ -255,25 +256,31 @@ struct _EmulationRegisterPrivate {
};
struct _EmulationRegisterIterator {
- GObject parent_instance;
+ GTypeInstance parent_instance;
+ volatile int ref_count;
EmulationRegisterIteratorPrivate * priv;
};
struct _EmulationRegisterIteratorClass {
- GObjectClass parent_class;
+ GTypeClass parent_class;
+ void (*finalize) (EmulationRegisterIterator *self);
};
struct _EmulationRegisterIteratorPrivate {
GList* m_list;
};
+struct _EmulationParamSpecRegisterIterator {
+ GParamSpec parent_instance;
+};
+
struct _EmulationRegisterList {
- GObject parent_instance;
+ GInitiallyUnowned parent_instance;
EmulationRegisterListPrivate * priv;
};
struct _EmulationRegisterListClass {
- GObjectClass parent_class;
+ GInitiallyUnownedClass parent_class;
};
struct _EmulationRegisterListPrivate {
@@ -347,6 +354,7 @@ const char* emulation_bitfield_value_get_doc (EmulationBitfieldValue* self);
void emulation_bitfield_value_set_doc (EmulationBitfieldValue* self, const char* value);
guint32 emulation_bitfield_value_get_val (EmulationBitfieldValue* self);
void emulation_bitfield_value_set_val (EmulationBitfieldValue* self, guint32 value);
+static GObject * emulation_bitfield_value_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void emulation_bitfield_value_finalize (GObject* obj);
static void emulation_bitfield_value_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void emulation_bitfield_value_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
@@ -388,6 +396,7 @@ guint8 emulation_bitfield_get_low (EmulationBitfield* self);
void emulation_bitfield_set_low (EmulationBitfield* self, guint8 value);
EmulationBitfieldEnum* emulation_bitfield_get_enu (EmulationBitfield* self);
void emulation_bitfield_set_enu (EmulationBitfield* self, EmulationBitfieldEnum* value);
+static GObject * emulation_bitfield_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void emulation_bitfield_finalize (GObject* obj);
static void emulation_bitfield_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void emulation_bitfield_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
@@ -456,9 +465,15 @@ guint emulation_register_get_num (EmulationRegister* self);
void emulation_register_set_num (EmulationRegister* self, guint value);
EmulationRegisterInfo* emulation_register_get_info (EmulationRegister* self);
void emulation_register_set_info (EmulationRegister* self, EmulationRegisterInfo* value);
+static GObject * emulation_register_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void emulation_register_finalize (GObject* obj);
static void emulation_register_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void emulation_register_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
+gpointer emulation_register_iterator_ref (gpointer instance);
+void emulation_register_iterator_unref (gpointer instance);
+GParamSpec* emulation_param_spec_register_iterator (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
+void emulation_value_set_register_iterator (GValue* value, gpointer v_object);
+gpointer emulation_value_get_register_iterator (const GValue* value);
GType emulation_register_iterator_get_type (void);
#define EMULATION_REGISTER_ITERATOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMULATION_TYPE_REGISTER_ITERATOR, EmulationRegisterIteratorPrivate))
enum {
@@ -468,7 +483,7 @@ EmulationRegisterIterator* emulation_register_iterator_new (GList* l);
EmulationRegisterIterator* emulation_register_iterator_construct (GType object_type, GList* l);
gboolean emulation_register_iterator_next (EmulationRegisterIterator* self);
EmulationRegister* emulation_register_iterator_get (EmulationRegisterIterator* self);
-static void emulation_register_iterator_finalize (GObject* obj);
+static void emulation_register_iterator_finalize (EmulationRegisterIterator* obj);
GType emulation_register_list_get_type (void);
#define EMULATION_REGISTER_LIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMULATION_TYPE_REGISTER_LIST, EmulationRegisterListPrivate))
enum {
@@ -508,6 +523,8 @@ static void _lambda6_ (void* ptr);
static void __lambda6__gdestroy_notify (void* data);
static void _lambda7_ (void* ptr);
static void __lambda7__gdestroy_notify (void* data);
+static void _lambda8_ (void* ptr);
+static void __lambda8__gdestroy_notify (void* data);
EmulationSpecParser* emulation_spec_parser_new (GHashTable** _info, GHashTable** _regs);
EmulationSpecParser* emulation_spec_parser_construct (GType object_type, GHashTable** _info, GHashTable** _regs);
static inline xmlNode* emulation_spec_parser_find_variant (EmulationSpecParser* self, const char* name);
@@ -552,7 +569,7 @@ GType emulation_access_type_get_type (void) {
EmulationBitfieldValue* emulation_bitfield_value_construct (GType object_type) {
EmulationBitfieldValue * self;
- self = (EmulationBitfieldValue*) g_object_new (object_type, NULL);
+ self = g_object_newv (object_type, 0, NULL);
return self;
}
@@ -609,11 +626,25 @@ void emulation_bitfield_value_set_val (EmulationBitfieldValue* self, guint32 val
}
+static GObject * emulation_bitfield_value_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
+ GObject * obj;
+ GObjectClass * parent_class;
+ EmulationBitfieldValue * self;
+ parent_class = G_OBJECT_CLASS (emulation_bitfield_value_parent_class);
+ obj = parent_class->constructor (type, n_construct_properties, construct_properties);
+ self = EMULATION_BITFIELD_VALUE (obj);
+ {
+ }
+ return obj;
+}
+
+
static void emulation_bitfield_value_class_init (EmulationBitfieldValueClass * klass) {
emulation_bitfield_value_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (EmulationBitfieldValuePrivate));
G_OBJECT_CLASS (klass)->get_property = emulation_bitfield_value_get_property;
G_OBJECT_CLASS (klass)->set_property = emulation_bitfield_value_set_property;
+ G_OBJECT_CLASS (klass)->constructor = emulation_bitfield_value_constructor;
G_OBJECT_CLASS (klass)->finalize = emulation_bitfield_value_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_BITFIELD_VALUE_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_BITFIELD_VALUE_DOC, g_param_spec_string ("doc", "doc", "doc", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
@@ -639,7 +670,7 @@ GType emulation_bitfield_value_get_type (void) {
static GType emulation_bitfield_value_type_id = 0;
if (emulation_bitfield_value_type_id == 0) {
static const GTypeInfo g_define_type_info = { sizeof (EmulationBitfieldValueClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emulation_bitfield_value_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmulationBitfieldValue), 0, (GInstanceInitFunc) emulation_bitfield_value_instance_init, NULL };
- emulation_bitfield_value_type_id = g_type_register_static (G_TYPE_OBJECT, "EmulationBitfieldValue", &g_define_type_info, 0);
+ emulation_bitfield_value_type_id = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, "EmulationBitfieldValue", &g_define_type_info, 0);
}
return emulation_bitfield_value_type_id;
}
@@ -792,7 +823,7 @@ GType emulation_bitfield_enum_get_type (void) {
static GType emulation_bitfield_enum_type_id = 0;
if (emulation_bitfield_enum_type_id == 0) {
static const GTypeInfo g_define_type_info = { sizeof (EmulationBitfieldEnumClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emulation_bitfield_enum_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmulationBitfieldEnum), 0, (GInstanceInitFunc) emulation_bitfield_enum_instance_init, NULL };
- emulation_bitfield_enum_type_id = g_type_register_static (G_TYPE_OBJECT, "EmulationBitfieldEnum", &g_define_type_info, 0);
+ emulation_bitfield_enum_type_id = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, "EmulationBitfieldEnum", &g_define_type_info, 0);
}
return emulation_bitfield_enum_type_id;
}
@@ -800,7 +831,7 @@ GType emulation_bitfield_enum_get_type (void) {
EmulationBitfield* emulation_bitfield_construct (GType object_type) {
EmulationBitfield * self;
- self = (EmulationBitfield*) g_object_new (object_type, NULL);
+ self = g_object_newv (object_type, 0, NULL);
return self;
}
@@ -888,11 +919,25 @@ void emulation_bitfield_set_enu (EmulationBitfield* self, EmulationBitfieldEnum*
}
+static GObject * emulation_bitfield_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
+ GObject * obj;
+ GObjectClass * parent_class;
+ EmulationBitfield * self;
+ parent_class = G_OBJECT_CLASS (emulation_bitfield_parent_class);
+ obj = parent_class->constructor (type, n_construct_properties, construct_properties);
+ self = EMULATION_BITFIELD (obj);
+ {
+ }
+ return obj;
+}
+
+
static void emulation_bitfield_class_init (EmulationBitfieldClass * klass) {
emulation_bitfield_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (EmulationBitfieldPrivate));
G_OBJECT_CLASS (klass)->get_property = emulation_bitfield_get_property;
G_OBJECT_CLASS (klass)->set_property = emulation_bitfield_set_property;
+ G_OBJECT_CLASS (klass)->constructor = emulation_bitfield_constructor;
G_OBJECT_CLASS (klass)->finalize = emulation_bitfield_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_BITFIELD_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_BITFIELD_DOC, g_param_spec_string ("doc", "doc", "doc", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
@@ -926,7 +971,7 @@ GType emulation_bitfield_get_type (void) {
static GType emulation_bitfield_type_id = 0;
if (emulation_bitfield_type_id == 0) {
static const GTypeInfo g_define_type_info = { sizeof (EmulationBitfieldClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emulation_bitfield_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmulationBitfield), 0, (GInstanceInitFunc) emulation_bitfield_instance_init, NULL };
- emulation_bitfield_type_id = g_type_register_static (G_TYPE_OBJECT, "EmulationBitfield", &g_define_type_info, 0);
+ emulation_bitfield_type_id = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, "EmulationBitfield", &g_define_type_info, 0);
}
return emulation_bitfield_type_id;
}
@@ -1348,7 +1393,7 @@ GType emulation_register_info_get_type (void) {
static GType emulation_register_info_type_id = 0;
if (emulation_register_info_type_id == 0) {
static const GTypeInfo g_define_type_info = { sizeof (EmulationRegisterInfoClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emulation_register_info_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmulationRegisterInfo), 0, (GInstanceInitFunc) emulation_register_info_instance_init, NULL };
- emulation_register_info_type_id = g_type_register_static (G_TYPE_OBJECT, "EmulationRegisterInfo", &g_define_type_info, 0);
+ emulation_register_info_type_id = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, "EmulationRegisterInfo", &g_define_type_info, 0);
}
return emulation_register_info_type_id;
}
@@ -1414,7 +1459,7 @@ static void emulation_register_info_set_property (GObject * object, guint proper
EmulationRegister* emulation_register_construct (GType object_type) {
EmulationRegister * self;
- self = (EmulationRegister*) g_object_new (object_type, NULL);
+ self = g_object_newv (object_type, 0, NULL);
return self;
}
@@ -1469,11 +1514,25 @@ void emulation_register_set_info (EmulationRegister* self, EmulationRegisterInfo
}
+static GObject * emulation_register_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
+ GObject * obj;
+ GObjectClass * parent_class;
+ EmulationRegister * self;
+ parent_class = G_OBJECT_CLASS (emulation_register_parent_class);
+ obj = parent_class->constructor (type, n_construct_properties, construct_properties);
+ self = EMULATION_REGISTER (obj);
+ {
+ }
+ return obj;
+}
+
+
static void emulation_register_class_init (EmulationRegisterClass * klass) {
emulation_register_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (EmulationRegisterPrivate));
G_OBJECT_CLASS (klass)->get_property = emulation_register_get_property;
G_OBJECT_CLASS (klass)->set_property = emulation_register_set_property;
+ G_OBJECT_CLASS (klass)->constructor = emulation_register_constructor;
G_OBJECT_CLASS (klass)->finalize = emulation_register_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_REGISTER_ADDR, g_param_spec_uint ("addr", "addr", "addr", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_REGISTER_NUM, g_param_spec_uint ("num", "num", "num", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
@@ -1497,7 +1556,7 @@ GType emulation_register_get_type (void) {
static GType emulation_register_type_id = 0;
if (emulation_register_type_id == 0) {
static const GTypeInfo g_define_type_info = { sizeof (EmulationRegisterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emulation_register_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmulationRegister), 0, (GInstanceInitFunc) emulation_register_instance_init, NULL };
- emulation_register_type_id = g_type_register_static (G_TYPE_OBJECT, "EmulationRegister", &g_define_type_info, 0);
+ emulation_register_type_id = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, "EmulationRegister", &g_define_type_info, 0);
}
return emulation_register_type_id;
}
@@ -1544,8 +1603,8 @@ static void emulation_register_set_property (GObject * object, guint property_id
EmulationRegisterIterator* emulation_register_iterator_construct (GType object_type, GList* l) {
- EmulationRegisterIterator * self;
- self = (EmulationRegisterIterator*) g_object_new (object_type, NULL);
+ EmulationRegisterIterator* self;
+ self = (EmulationRegisterIterator*) g_type_create_instance (object_type);
self->priv->m_list = g_list_first (l);
return self;
}
@@ -1575,35 +1634,148 @@ EmulationRegister* emulation_register_iterator_get (EmulationRegisterIterator* s
}
+static void emulation_value_register_iterator_init (GValue* value) {
+ value->data[0].v_pointer = NULL;
+}
+
+
+static void emulation_value_register_iterator_free_value (GValue* value) {
+ if (value->data[0].v_pointer) {
+ emulation_register_iterator_unref (value->data[0].v_pointer);
+ }
+}
+
+
+static void emulation_value_register_iterator_copy_value (const GValue* src_value, GValue* dest_value) {
+ if (src_value->data[0].v_pointer) {
+ dest_value->data[0].v_pointer = emulation_register_iterator_ref (src_value->data[0].v_pointer);
+ } else {
+ dest_value->data[0].v_pointer = NULL;
+ }
+}
+
+
+static gpointer emulation_value_register_iterator_peek_pointer (const GValue* value) {
+ return value->data[0].v_pointer;
+}
+
+
+static gchar* emulation_value_register_iterator_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
+ if (collect_values[0].v_pointer) {
+ EmulationRegisterIterator* object;
+ object = collect_values[0].v_pointer;
+ if (object->parent_instance.g_class == NULL) {
+ return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
+ } else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
+ return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
+ }
+ value->data[0].v_pointer = emulation_register_iterator_ref (object);
+ } else {
+ value->data[0].v_pointer = NULL;
+ }
+ return NULL;
+}
+
+
+static gchar* emulation_value_register_iterator_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
+ EmulationRegisterIterator** object_p;
+ object_p = collect_values[0].v_pointer;
+ if (!object_p) {
+ return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
+ }
+ if (!value->data[0].v_pointer) {
+ *object_p = NULL;
+ } else if (collect_flags && G_VALUE_NOCOPY_CONTENTS) {
+ *object_p = value->data[0].v_pointer;
+ } else {
+ *object_p = emulation_register_iterator_ref (value->data[0].v_pointer);
+ }
+ return NULL;
+}
+
+
+GParamSpec* emulation_param_spec_register_iterator (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
+ EmulationParamSpecRegisterIterator* spec;
+ g_return_val_if_fail (g_type_is_a (object_type, EMULATION_TYPE_REGISTER_ITERATOR), NULL);
+ spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
+ G_PARAM_SPEC (spec)->value_type = object_type;
+ return G_PARAM_SPEC (spec);
+}
+
+
+gpointer emulation_value_get_register_iterator (const GValue* value) {
+ g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EMULATION_TYPE_REGISTER_ITERATOR), NULL);
+ return value->data[0].v_pointer;
+}
+
+
+void emulation_value_set_register_iterator (GValue* value, gpointer v_object) {
+ EmulationRegisterIterator* old;
+ g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EMULATION_TYPE_REGISTER_ITERATOR));
+ old = value->data[0].v_pointer;
+ if (v_object) {
+ g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, EMULATION_TYPE_REGISTER_ITERATOR));
+ g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
+ value->data[0].v_pointer = v_object;
+ emulation_register_iterator_ref (value->data[0].v_pointer);
+ } else {
+ value->data[0].v_pointer = NULL;
+ }
+ if (old) {
+ emulation_register_iterator_unref (old);
+ }
+}
+
+
static void emulation_register_iterator_class_init (EmulationRegisterIteratorClass * klass) {
emulation_register_iterator_parent_class = g_type_class_peek_parent (klass);
+ EMULATION_REGISTER_ITERATOR_CLASS (klass)->finalize = emulation_register_iterator_finalize;
g_type_class_add_private (klass, sizeof (EmulationRegisterIteratorPrivate));
- G_OBJECT_CLASS (klass)->finalize = emulation_register_iterator_finalize;
}
static void emulation_register_iterator_instance_init (EmulationRegisterIterator * self) {
self->priv = EMULATION_REGISTER_ITERATOR_GET_PRIVATE (self);
+ self->ref_count = 1;
}
-static void emulation_register_iterator_finalize (GObject* obj) {
+static void emulation_register_iterator_finalize (EmulationRegisterIterator* obj) {
EmulationRegisterIterator * self;
self = EMULATION_REGISTER_ITERATOR (obj);
- G_OBJECT_CLASS (emulation_register_iterator_parent_class)->finalize (obj);
}
GType emulation_register_iterator_get_type (void) {
static GType emulation_register_iterator_type_id = 0;
if (emulation_register_iterator_type_id == 0) {
- static const GTypeInfo g_define_type_info = { sizeof (EmulationRegisterIteratorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emulation_register_iterator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmulationRegisterIterator), 0, (GInstanceInitFunc) emulation_register_iterator_instance_init, NULL };
- emulation_register_iterator_type_id = g_type_register_static (G_TYPE_OBJECT, "EmulationRegisterIterator", &g_define_type_info, 0);
+ static const GTypeValueTable g_define_type_value_table = { emulation_value_register_iterator_init, emulation_value_register_iterator_free_value, emulation_value_register_iterator_copy_value, emulation_value_register_iterator_peek_pointer, "p", emulation_value_register_iterator_collect_value, "p", emulation_value_register_iterator_lcopy_value };
+ static const GTypeInfo g_define_type_info = { sizeof (EmulationRegisterIteratorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emulation_register_iterator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmulationRegisterIterator), 0, (GInstanceInitFunc) emulation_register_iterator_instance_init, &g_define_type_value_table };
+ static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
+ emulation_register_iterator_type_id = g_type_register_fundamental (g_type_fundamental_next (), "EmulationRegisterIterator", &g_define_type_info, &g_define_type_fundamental_info, 0);
}
return emulation_register_iterator_type_id;
}
+gpointer emulation_register_iterator_ref (gpointer instance) {
+ EmulationRegisterIterator* self;
+ self = instance;
+ g_atomic_int_inc (&self->ref_count);
+ return instance;
+}
+
+
+void emulation_register_iterator_unref (gpointer instance) {
+ EmulationRegisterIterator* self;
+ self = instance;
+ if (g_atomic_int_dec_and_test (&self->ref_count)) {
+ EMULATION_REGISTER_ITERATOR_GET_CLASS (self)->finalize (self);
+ g_type_free_instance ((GTypeInstance *) self);
+ }
+}
+
+
EmulationRegisterIterator* emulation_register_list_iterator (EmulationRegisterList* self) {
EmulationRegisterIterator* result;
g_return_val_if_fail (self != NULL, NULL);
@@ -1698,7 +1870,7 @@ GType emulation_register_list_get_type (void) {
static GType emulation_register_list_type_id = 0;
if (emulation_register_list_type_id == 0) {
static const GTypeInfo g_define_type_info = { sizeof (EmulationRegisterListClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emulation_register_list_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmulationRegisterList), 0, (GInstanceInitFunc) emulation_register_list_instance_init, NULL };
- emulation_register_list_type_id = g_type_register_static (G_TYPE_OBJECT, "EmulationRegisterList", &g_define_type_info, 0);
+ emulation_register_list_type_id = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, "EmulationRegisterList", &g_define_type_info, 0);
}
return emulation_register_list_type_id;
}
@@ -1742,6 +1914,11 @@ static void __lambda3__gdestroy_notify (void* data) {
}
+static gpointer _g_hash_table_ref0 (gpointer self) {
+ return self ? g_hash_table_ref (self) : NULL;
+}
+
+
static void _lambda4_ (void* ptr) {
g_free (ptr);
}
@@ -1774,8 +1951,7 @@ static void __lambda6__gdestroy_notify (void* data) {
static void _lambda7_ (void* ptr) {
- void* _tmp0_;
- g_object_unref ((_tmp0_ = ptr, G_IS_OBJECT (_tmp0_) ? ((GObject*) _tmp0_) : NULL));
+ g_free (ptr);
}
@@ -1784,12 +1960,25 @@ static void __lambda7__gdestroy_notify (void* data) {
}
+static void _lambda8_ (void* ptr) {
+ void* _tmp0_;
+ g_object_unref ((_tmp0_ = ptr, G_IS_OBJECT (_tmp0_) ? ((GObject*) _tmp0_) : NULL));
+}
+
+
+static void __lambda8__gdestroy_notify (void* data) {
+ _lambda8_ (data);
+}
+
+
EmulationSpecParser* emulation_spec_parser_construct (GType object_type, GHashTable** _info, GHashTable** _regs) {
EmulationSpecParser* self;
- GHashTable* _tmp0_;
GHashTable* _tmp1_;
- GHashTable* _tmp2_;
+ GHashTable* _tmp0_;
GHashTable* _tmp3_;
+ GHashTable* _tmp2_;
+ GHashTable* _tmp4_;
+ GHashTable* _tmp5_;
if (_info != NULL) {
*_info = NULL;
}
@@ -1797,10 +1986,10 @@ EmulationSpecParser* emulation_spec_parser_construct (GType object_type, GHashTa
*_regs = NULL;
}
self = (EmulationSpecParser*) g_type_create_instance (object_type);
- self->priv->info = *_info = (_tmp0_ = g_hash_table_new_full (g_str_hash, g_str_equal, __lambda2__gdestroy_notify, __lambda3__gdestroy_notify), _g_hash_table_unref0 (*_info), _tmp0_);
- self->priv->regs = *_regs = (_tmp1_ = g_hash_table_new_full (g_int_hash, g_int_equal, __lambda4__gdestroy_notify, __lambda5__gdestroy_notify), _g_hash_table_unref0 (*_regs), _tmp1_);
- self->priv->groups_map = (_tmp2_ = g_hash_table_new (g_str_hash, g_str_equal), _g_hash_table_unref0 (self->priv->groups_map), _tmp2_);
- self->priv->enums_map = (_tmp3_ = g_hash_table_new_full (g_str_hash, g_str_equal, __lambda6__gdestroy_notify, __lambda7__gdestroy_notify), _g_hash_table_unref0 (self->priv->enums_map), _tmp3_);
+ self->priv->info = (_tmp1_ = _g_hash_table_ref0 (*_info = (_tmp0_ = g_hash_table_new_full (g_str_hash, g_str_equal, __lambda2__gdestroy_notify, __lambda3__gdestroy_notify), _g_hash_table_unref0 (*_info), _tmp0_)), _g_hash_table_unref0 (self->priv->info), _tmp1_);
+ self->priv->regs = (_tmp3_ = _g_hash_table_ref0 (*_regs = (_tmp2_ = g_hash_table_new_full (g_int_hash, g_int_equal, __lambda4__gdestroy_notify, __lambda5__gdestroy_notify), _g_hash_table_unref0 (*_regs), _tmp2_)), _g_hash_table_unref0 (self->priv->regs), _tmp3_);
+ self->priv->groups_map = (_tmp4_ = g_hash_table_new_full (g_str_hash, g_str_equal, __lambda6__gdestroy_notify, NULL), _g_hash_table_unref0 (self->priv->groups_map), _tmp4_);
+ self->priv->enums_map = (_tmp5_ = g_hash_table_new_full (g_str_hash, g_str_equal, __lambda7__gdestroy_notify, __lambda8__gdestroy_notify), _g_hash_table_unref0 (self->priv->enums_map), _tmp5_);
return self;
}
@@ -2227,24 +2416,22 @@ static void emulation_spec_parser_xmlparse_reg32 (EmulationSpecParser* self, xml
gboolean prefound;
EmulationRegisterInfo* reginfo;
EmulationRegister* reg;
- guint _tmp3_;
+ guint _tmp1_;
g_return_if_fail (self != NULL);
g_return_if_fail (_name != NULL);
name = g_strconcat (_name, emulation_spec_parser_get_single_attrib (self, node, "name"), NULL);
offset = offset + ((guint) strtoul (emulation_spec_parser_get_single_attrib (self, node, "offset"), NULL, 0));
- regarr = _g_object_ref0 ((EmulationRegisterList*) g_hash_table_lookup (self->priv->regs, &offset));
+ regarr = (EmulationRegisterList*) g_hash_table_lookup (self->priv->regs, &offset);
if (regarr == NULL) {
- EmulationRegisterList* _tmp0_;
- g_hash_table_insert (self->priv->regs, __uint_dup0 (&offset), emulation_register_list_new ());
- regarr = (_tmp0_ = _g_object_ref0 ((EmulationRegisterList*) g_hash_table_lookup (self->priv->regs, &offset)), _g_object_unref0 (regarr), _tmp0_);
+ g_hash_table_insert (self->priv->regs, __uint_dup0 (&offset), g_object_ref_sink (emulation_register_list_new ()));
+ regarr = (EmulationRegisterList*) g_hash_table_lookup (self->priv->regs, &offset);
}
prefound = TRUE;
- reginfo = _g_object_ref0 ((EmulationRegisterInfo*) g_hash_table_lookup (self->priv->info, name));
+ reginfo = (EmulationRegisterInfo*) g_hash_table_lookup (self->priv->info, name);
if (reginfo == NULL) {
EmulationRegisterInfo* ri;
char* access;
- EmulationRegisterInfo* _tmp2_;
- ri = emulation_register_info_new ();
+ ri = g_object_ref_sink (emulation_register_info_new ());
emulation_register_info_set_name (ri, name);
emulation_register_info_set_addr (ri, offset);
access = g_strdup (emulation_spec_parser_get_single_attrib (self, node, "access"));
@@ -2252,13 +2439,13 @@ static void emulation_spec_parser_xmlparse_reg32 (EmulationSpecParser* self, xml
gint i;
i = 0;
{
- gboolean _tmp1_;
- _tmp1_ = TRUE;
+ gboolean _tmp0_;
+ _tmp0_ = TRUE;
while (TRUE) {
- if (!_tmp1_) {
+ if (!_tmp0_) {
i++;
}
- _tmp1_ = FALSE;
+ _tmp0_ = FALSE;
if (!(i < string_get_length (access))) {
break;
}
@@ -2280,14 +2467,14 @@ static void emulation_spec_parser_xmlparse_reg32 (EmulationSpecParser* self, xml
}
}
g_hash_table_insert (self->priv->info, g_strdup (name), _g_object_ref0 (ri));
- reginfo = (_tmp2_ = _g_object_ref0 ((EmulationRegisterInfo*) g_hash_table_lookup (self->priv->info, name)), _g_object_unref0 (reginfo), _tmp2_);
+ reginfo = (EmulationRegisterInfo*) g_hash_table_lookup (self->priv->info, name);
prefound = FALSE;
_g_object_unref0 (ri);
_g_free0 (access);
}
- reg = emulation_register_new ();
+ reg = g_object_ref_sink (emulation_register_new ());
emulation_register_set_addr (reg, offset);
- emulation_register_set_num (reg, (_tmp3_ = emulation_register_info_get_count (reginfo), emulation_register_info_set_count (reginfo, _tmp3_ + 1), _tmp3_));
+ emulation_register_set_num (reg, (_tmp1_ = emulation_register_info_get_count (reginfo), emulation_register_info_set_count (reginfo, _tmp1_ + 1), _tmp1_));
emulation_register_set_info (reg, reginfo);
emulation_register_list_append (regarr, reg);
if (!prefound) {
@@ -2295,13 +2482,13 @@ static void emulation_spec_parser_xmlparse_reg32 (EmulationSpecParser* self, xml
xmlNode* iter;
iter = node->children;
{
- gboolean _tmp4_;
- _tmp4_ = TRUE;
+ gboolean _tmp2_;
+ _tmp2_ = TRUE;
while (TRUE) {
- if (!_tmp4_) {
+ if (!_tmp2_) {
iter = iter->next;
}
- _tmp4_ = FALSE;
+ _tmp2_ = FALSE;
if (!(iter != NULL)) {
break;
}
@@ -2313,9 +2500,9 @@ static void emulation_spec_parser_xmlparse_reg32 (EmulationSpecParser* self, xml
} else {
if (_vala_strcmp0 (iter->name, "doc") == 0) {
if (emulation_register_info_get_doc (reginfo) == NULL) {
- char* _tmp5_;
- emulation_register_info_set_doc (reginfo, _tmp5_ = xmlNodeGetContent (iter));
- _g_free0 (_tmp5_);
+ char* _tmp3_;
+ emulation_register_info_set_doc (reginfo, _tmp3_ = xmlNodeGetContent (iter));
+ _g_free0 (_tmp3_);
}
} else {
fprintf (stdout, "Warning: Unknown rules-ng tag '%s' in reg32.\n", iter->name);
@@ -2326,8 +2513,6 @@ static void emulation_spec_parser_xmlparse_reg32 (EmulationSpecParser* self, xml
}
}
_g_free0 (name);
- _g_object_unref0 (regarr);
- _g_object_unref0 (reginfo);
_g_object_unref0 (reg);
}
@@ -2338,7 +2523,7 @@ static void emulation_spec_parser_xmlparse_enum (EmulationSpecParser* self, xmlN
EmulationBitfieldEnum* enu;
g_return_if_fail (self != NULL);
name = emulation_spec_parser_get_single_attrib (self, node, "name");
- g_hash_table_insert (self->priv->enums_map, g_strdup (name), emulation_bitfield_enum_new ());
+ g_hash_table_insert (self->priv->enums_map, g_strdup (name), g_object_ref_sink (emulation_bitfield_enum_new ()));
enu = (_tmp0_ = (EmulationBitfieldEnum*) g_hash_table_lookup (self->priv->enums_map, name), EMULATION_IS_BITFIELD_ENUM (_tmp0_) ? ((EmulationBitfieldEnum*) _tmp0_) : NULL);
{
xmlNode* iter;
@@ -2372,7 +2557,7 @@ static void emulation_spec_parser_xmlparse_bitfield (EmulationSpecParser* self,
EmulationBitfield* b;
g_return_if_fail (self != NULL);
g_return_if_fail (reginfo != NULL);
- b = emulation_bitfield_new ();
+ b = g_object_ref_sink (emulation_bitfield_new ());
emulation_bitfield_set_name (b, emulation_spec_parser_get_single_attrib (self, node, "name"));
emulation_bitfield_set_high (b, (guint8) strtoul (emulation_spec_parser_get_single_attrib (self, node, "high"), NULL, 0));
emulation_bitfield_set_low (b, (guint8) strtoul (emulation_spec_parser_get_single_attrib (self, node, "low"), NULL, 0));
@@ -2397,7 +2582,7 @@ static void emulation_spec_parser_xmlparse_bitfield (EmulationSpecParser* self,
if (_vala_strcmp0 (iter->name, "value") == 0) {
if (emulation_bitfield_get_enu (b) == NULL) {
EmulationBitfieldEnum* _tmp1_;
- emulation_bitfield_set_enu (b, _tmp1_ = emulation_bitfield_enum_new ());
+ emulation_bitfield_set_enu (b, _tmp1_ = g_object_ref_sink (emulation_bitfield_enum_new ()));
_g_object_unref0 (_tmp1_);
}
emulation_spec_parser_xmlparse_value (self, iter, emulation_bitfield_get_enu (b));
@@ -2430,7 +2615,7 @@ static void emulation_spec_parser_xmlparse_value (EmulationSpecParser* self, xml
EmulationBitfieldValue* v;
g_return_if_fail (self != NULL);
g_return_if_fail (enu != NULL);
- v = emulation_bitfield_value_new ();
+ v = g_object_ref_sink (emulation_bitfield_value_new ());
emulation_bitfield_value_set_val (v, (guint32) strtoul (emulation_spec_parser_get_single_attrib (self, node, "value"), NULL, 0));
emulation_bitfield_value_set_name (v, emulation_spec_parser_get_single_attrib (self, node, "name"));
emulation_bitfield_value_set_doc (v, "");
@@ -2572,6 +2757,8 @@ static void emulation_spec_parser_instance_init (EmulationSpecParser * self) {
static void emulation_spec_parser_finalize (EmulationSpecParser* obj) {
EmulationSpecParser * self;
self = EMULATION_SPEC_PARSER (obj);
+ _g_hash_table_unref0 (self->priv->info);
+ _g_hash_table_unref0 (self->priv->regs);
_g_hash_table_unref0 (self->priv->groups_map);
_g_hash_table_unref0 (self->priv->enums_map);
}
@@ -2628,7 +2815,7 @@ EmulationSpec* emulation_spec_new (const char* filename, const char* variant) {
EmulationRegisterList* emulation_spec_translate_addr (EmulationSpec* self, guint addr) {
EmulationRegisterList* result;
g_return_val_if_fail (self != NULL, NULL);
- result = _g_object_ref0 ((EmulationRegisterList*) g_hash_table_lookup (self->priv->regs, &addr));
+ result = (EmulationRegisterList*) g_hash_table_lookup (self->priv->regs, &addr);
return result;
}