diff options
Diffstat (limited to 'src/cs.c')
-rw-r--r-- | src/cs.c | 1018 |
1 files changed, 707 insertions, 311 deletions
@@ -25,21 +25,31 @@ #include <glib.h> #include <glib-object.h> +#include <stdlib.h> #include <string.h> #include <gobject/gvaluecollector.h> -#define EMULATION_TYPE_CHIP (emulation_chip_get_type ()) +#define EMULATION_TYPE_PACKET (emulation_packet_get_type ()) +#define EMULATION_PACKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMULATION_TYPE_PACKET, EmulationPacket)) +#define EMULATION_PACKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMULATION_TYPE_PACKET, EmulationPacketClass)) +#define EMULATION_IS_PACKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMULATION_TYPE_PACKET)) +#define EMULATION_IS_PACKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMULATION_TYPE_PACKET)) +#define EMULATION_PACKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMULATION_TYPE_PACKET, EmulationPacketClass)) -#define EMULATION_TYPE_PACKET_BASE (emulation_packet_base_get_type ()) -#define EMULATION_PACKET_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMULATION_TYPE_PACKET_BASE, EmulationPacketBase)) -#define EMULATION_PACKET_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMULATION_TYPE_PACKET_BASE, EmulationPacketBaseClass)) -#define EMULATION_IS_PACKET_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMULATION_TYPE_PACKET_BASE)) -#define EMULATION_IS_PACKET_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMULATION_TYPE_PACKET_BASE)) -#define EMULATION_PACKET_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMULATION_TYPE_PACKET_BASE, EmulationPacketBaseClass)) +typedef struct _EmulationPacket EmulationPacket; +typedef struct _EmulationPacketClass EmulationPacketClass; +typedef struct _EmulationPacketPrivate EmulationPacketPrivate; -typedef struct _EmulationPacketBase EmulationPacketBase; -typedef struct _EmulationPacketBaseClass EmulationPacketBaseClass; +#define EMULATION_PACKET_TYPE_ITERATOR (emulation_packet_iterator_get_type ()) +#define EMULATION_PACKET_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMULATION_PACKET_TYPE_ITERATOR, EmulationPacketIterator)) +#define EMULATION_PACKET_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMULATION_PACKET_TYPE_ITERATOR, EmulationPacketIteratorClass)) +#define EMULATION_PACKET_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMULATION_PACKET_TYPE_ITERATOR)) +#define EMULATION_PACKET_IS_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMULATION_PACKET_TYPE_ITERATOR)) +#define EMULATION_PACKET_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMULATION_PACKET_TYPE_ITERATOR, EmulationPacketIteratorClass)) + +typedef struct _EmulationPacketIterator EmulationPacketIterator; +typedef struct _EmulationPacketIteratorClass EmulationPacketIteratorClass; #define EMULATION_TYPE_PACKET0 (emulation_packet0_get_type ()) #define EMULATION_PACKET0(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMULATION_TYPE_PACKET0, EmulationPacket0)) @@ -80,19 +90,8 @@ typedef struct _EmulationPacket2Class EmulationPacket2Class; typedef struct _EmulationPacket3 EmulationPacket3; typedef struct _EmulationPacket3Class EmulationPacket3Class; - -#define EMULATION_TYPE_PACKET_ITERATOR (emulation_packet_iterator_get_type ()) -#define EMULATION_PACKET_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMULATION_TYPE_PACKET_ITERATOR, EmulationPacketIterator)) -#define EMULATION_PACKET_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMULATION_TYPE_PACKET_ITERATOR, EmulationPacketIteratorClass)) -#define EMULATION_IS_PACKET_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMULATION_TYPE_PACKET_ITERATOR)) -#define EMULATION_IS_PACKET_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMULATION_TYPE_PACKET_ITERATOR)) -#define EMULATION_PACKET_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMULATION_TYPE_PACKET_ITERATOR, EmulationPacketIteratorClass)) - -typedef struct _EmulationPacketIterator EmulationPacketIterator; -typedef struct _EmulationPacketIteratorClass EmulationPacketIteratorClass; typedef struct _EmulationPacketIteratorPrivate EmulationPacketIteratorPrivate; -typedef struct _EmulationPacketBasePrivate EmulationPacketBasePrivate; -typedef struct _EmulationParamSpecPacketIterator EmulationParamSpecPacketIterator; +typedef struct _EmulationPacketParamSpecIterator EmulationPacketParamSpecIterator; typedef struct _EmulationPacket0Private EmulationPacket0Private; typedef struct _EmulationPacket1Private EmulationPacket1Private; typedef struct _EmulationPacket2Private EmulationPacket2Private; @@ -110,10 +109,34 @@ typedef struct _EmulationCSClass EmulationCSClass; typedef struct _EmulationCSPrivate EmulationCSPrivate; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) -typedef enum { - EMULATION_CHIP_R300, - EMULATION_CHIP_R500 -} EmulationChip; +#define EMULATION_CS_TYPE_ITERATOR (emulation_cs_iterator_get_type ()) +#define EMULATION_CS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMULATION_CS_TYPE_ITERATOR, EmulationCSIterator)) +#define EMULATION_CS_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMULATION_CS_TYPE_ITERATOR, EmulationCSIteratorClass)) +#define EMULATION_CS_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMULATION_CS_TYPE_ITERATOR)) +#define EMULATION_CS_IS_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMULATION_CS_TYPE_ITERATOR)) +#define EMULATION_CS_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMULATION_CS_TYPE_ITERATOR, EmulationCSIteratorClass)) + +typedef struct _EmulationCSIterator EmulationCSIterator; +typedef struct _EmulationCSIteratorClass EmulationCSIteratorClass; +typedef struct _EmulationCSIteratorPrivate EmulationCSIteratorPrivate; +typedef struct _EmulationCSParamSpecIterator EmulationCSParamSpecIterator; + +struct _EmulationPacket { + GObject parent_instance; + EmulationPacketPrivate * priv; + guint32* dwords; + gint dwords_length1; +}; + +struct _EmulationPacketClass { + GObjectClass parent_class; + guint32 (*target_addr) (EmulationPacket* self, guint index); + guint (*get_length) (EmulationPacket* self); +}; + +struct _EmulationPacketPrivate { + guint32 _header; +}; struct _EmulationPacketIterator { GTypeInstance parent_instance; @@ -127,141 +150,155 @@ struct _EmulationPacketIteratorClass { }; struct _EmulationPacketIteratorPrivate { - EmulationPacketBase* m_packet; - guint m_pos; -}; - -struct _EmulationPacketBase { - GObject parent_instance; - EmulationPacketBasePrivate * priv; - guint32* dwords; - guint32 header; -}; - -struct _EmulationPacketBaseClass { - GObjectClass parent_class; - guint (*get_length) (EmulationPacketBase* self); + EmulationPacket* packet; + guint pos; }; -struct _EmulationParamSpecPacketIterator { +struct _EmulationPacketParamSpecIterator { GParamSpec parent_instance; }; struct _EmulationPacket0 { - EmulationPacketBase parent_instance; + EmulationPacket parent_instance; EmulationPacket0Private * priv; }; struct _EmulationPacket0Class { - EmulationPacketBaseClass parent_class; + EmulationPacketClass parent_class; }; struct _EmulationPacket1 { - EmulationPacketBase parent_instance; + EmulationPacket parent_instance; EmulationPacket1Private * priv; }; struct _EmulationPacket1Class { - EmulationPacketBaseClass parent_class; + EmulationPacketClass parent_class; }; struct _EmulationPacket2 { - EmulationPacketBase parent_instance; + EmulationPacket parent_instance; EmulationPacket2Private * priv; }; struct _EmulationPacket2Class { - EmulationPacketBaseClass parent_class; + EmulationPacketClass parent_class; }; struct _EmulationPacket3 { - EmulationPacketBase parent_instance; + EmulationPacket parent_instance; EmulationPacket3Private * priv; }; struct _EmulationPacket3Class { - EmulationPacketBaseClass parent_class; + EmulationPacketClass parent_class; }; struct _EmulationCS { GObject parent_instance; EmulationCSPrivate * priv; - EmulationPacketBase** packets; - gint packets_length1; - guint32* dwords; - gint dwords_length1; }; struct _EmulationCSClass { GObjectClass parent_class; }; +struct _EmulationCSPrivate { + EmulationPacket** packets; + gint packets_length1; + gint packets_size; +}; + +struct _EmulationCSIterator { + GTypeInstance parent_instance; + volatile int ref_count; + EmulationCSIteratorPrivate * priv; +}; + +struct _EmulationCSIteratorClass { + GTypeClass parent_class; + void (*finalize) (EmulationCSIterator *self); +}; + +struct _EmulationCSIteratorPrivate { + EmulationCS* cs; + guint pos; +}; + +struct _EmulationCSParamSpecIterator { + GParamSpec parent_instance; +}; + static gpointer emulation_packet_iterator_parent_class = NULL; -static gpointer emulation_packet_base_parent_class = NULL; +static gpointer emulation_packet_parent_class = NULL; static gpointer emulation_packet0_parent_class = NULL; static gpointer emulation_packet1_parent_class = NULL; static gpointer emulation_packet2_parent_class = NULL; static gpointer emulation_packet3_parent_class = NULL; +static gpointer emulation_cs_iterator_parent_class = NULL; static gpointer emulation_cs_parent_class = NULL; -GType emulation_chip_get_type (void); -guint emulation_packet_typeid (guint32 header); +GType emulation_packet_get_type (void); +#define EMULATION_PACKET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMULATION_TYPE_PACKET, EmulationPacketPrivate)) +enum { + EMULATION_PACKET_DUMMY_PROPERTY, + EMULATION_PACKET_HEADER, + EMULATION_PACKET_TYPE_ID, + EMULATION_PACKET_LENGTH +}; +EmulationPacketIterator* emulation_packet_iterator_new (EmulationPacket* p); +EmulationPacketIterator* emulation_packet_iterator_construct (GType object_type, EmulationPacket* p); +gpointer emulation_packet_iterator_ref (gpointer instance); +void emulation_packet_iterator_unref (gpointer instance); +GParamSpec* emulation_packet_param_spec_iterator (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags); +void emulation_packet_value_set_iterator (GValue* value, gpointer v_object); +gpointer emulation_packet_value_get_iterator (const GValue* value); +GType emulation_packet_iterator_get_type (void); +EmulationPacketIterator* emulation_packet_iterator (EmulationPacket* self); +guint32 emulation_packet_target_addr (EmulationPacket* self, guint index); +static guint32 emulation_packet_real_target_addr (EmulationPacket* self, guint index); +guint32 emulation_packet_get (EmulationPacket* self, guint index); +guint32 emulation_packet_get_header (EmulationPacket* self); +guint32 emulation_packet_extract_bits (EmulationPacket* self, guint high, guint low); EmulationPacket0* emulation_packet0_new (guint32 header, guint32* dwords); EmulationPacket0* emulation_packet0_construct (GType object_type, guint32 header, guint32* dwords); -GType emulation_packet_base_get_type (void); GType emulation_packet0_get_type (void); EmulationPacket1* emulation_packet1_new (guint32 header, guint32* dwords); EmulationPacket1* emulation_packet1_construct (GType object_type, guint32 header, guint32* dwords); GType emulation_packet1_get_type (void); -EmulationPacket2* emulation_packet2_new (guint32 header, guint32* dwords); -EmulationPacket2* emulation_packet2_construct (GType object_type, guint32 header, guint32* dwords); +EmulationPacket2* emulation_packet2_new (guint32 header); +EmulationPacket2* emulation_packet2_construct (GType object_type, guint32 header); GType emulation_packet2_get_type (void); EmulationPacket3* emulation_packet3_new (guint32 header, guint32* dwords); EmulationPacket3* emulation_packet3_construct (GType object_type, guint32 header, guint32* dwords); GType emulation_packet3_get_type (void); -EmulationPacketBase* emulation_packet_base_new (void); -EmulationPacketBase* emulation_packet_base_construct (GType object_type); -EmulationPacketBase* emulation_make_packet (guint32 header, guint32* dwords); -gpointer emulation_packet_iterator_ref (gpointer instance); -void emulation_packet_iterator_unref (gpointer instance); -GParamSpec* emulation_param_spec_packet_iterator (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags); -void emulation_value_set_packet_iterator (GValue* value, gpointer v_object); -gpointer emulation_value_get_packet_iterator (const GValue* value); -GType emulation_packet_iterator_get_type (void); -#define EMULATION_PACKET_ITERATOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMULATION_TYPE_PACKET_ITERATOR, EmulationPacketIteratorPrivate)) +EmulationPacket* emulation_packet_make (guint32 header, guint32* dwords); +EmulationPacket* emulation_packet_construct (GType object_type); +void emulation_packet_set_header (EmulationPacket* self, guint32 value); +guint emulation_packet_get_type_id (EmulationPacket* self); +guint emulation_packet_get_length (EmulationPacket* self); +#define EMULATION_PACKET_ITERATOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMULATION_PACKET_TYPE_ITERATOR, EmulationPacketIteratorPrivate)) enum { EMULATION_PACKET_ITERATOR_DUMMY_PROPERTY }; -EmulationPacketIterator* emulation_packet_iterator_new (EmulationPacketBase* p); -EmulationPacketIterator* emulation_packet_iterator_construct (GType object_type, EmulationPacketBase* p); -guint emulation_packet_base_get_length (EmulationPacketBase* self); gboolean emulation_packet_iterator_next (EmulationPacketIterator* self); guint32 emulation_packet_iterator_get (EmulationPacketIterator* self); static void emulation_packet_iterator_finalize (EmulationPacketIterator* obj); -enum { - EMULATION_PACKET_BASE_DUMMY_PROPERTY, - EMULATION_PACKET_BASE_ELEMENT_TYPE, - EMULATION_PACKET_BASE_TYPE_ID, - EMULATION_PACKET_BASE_LENGTH -}; -EmulationPacketIterator* emulation_packet_base_iterator (EmulationPacketBase* self); -guint32 emulation_packet_base_get (EmulationPacketBase* self, guint index); -guint32 emulation_packet_base_extract_bits (EmulationPacketBase* self, guint high, guint low); -GType emulation_packet_base_get_element_type (EmulationPacketBase* self); -guint emulation_packet_base_get_type_id (EmulationPacketBase* self); -static void emulation_packet_base_finalize (GObject* obj); -static void emulation_packet_base_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); +static void emulation_packet_finalize (GObject* obj); +static void emulation_packet_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); +static void emulation_packet_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); enum { EMULATION_PACKET0_DUMMY_PROPERTY, EMULATION_PACKET0_ADDR, EMULATION_PACKET0_ONE_REG_WR, EMULATION_PACKET0_LENGTH }; -guint32 emulation_packet0_get__ADDR (EmulationPacket0* self); +gboolean emulation_packet0_get_one_reg_wr (EmulationPacket0* self); guint32 emulation_packet0_get_addr (EmulationPacket0* self); +static guint32 emulation_packet0_real_target_addr (EmulationPacket* base, guint index); +guint32 emulation_packet0_get__ADDR (EmulationPacket0* self); guint32 emulation_packet0_get__ONE_REG_WR (EmulationPacket0* self); -gboolean emulation_packet0_get_one_reg_wr (EmulationPacket0* self); guint32 emulation_packet0_get__COUNT (EmulationPacket0* self); static void emulation_packet0_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); enum { @@ -270,107 +307,187 @@ enum { EMULATION_PACKET1_ADDR2, EMULATION_PACKET1_LENGTH }; -guint32 emulation_packet1_get__ADDR1 (EmulationPacket1* self); guint32 emulation_packet1_get_addr1 (EmulationPacket1* self); -guint32 emulation_packet1_get__ADDR2 (EmulationPacket1* self); guint32 emulation_packet1_get_addr2 (EmulationPacket1* self); +static guint32 emulation_packet1_real_target_addr (EmulationPacket* base, guint index); +guint32 emulation_packet1_get__ADDR1 (EmulationPacket1* self); +guint32 emulation_packet1_get__ADDR2 (EmulationPacket1* self); static void emulation_packet1_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); enum { EMULATION_PACKET2_DUMMY_PROPERTY, EMULATION_PACKET2_LENGTH }; +static guint32 emulation_packet2_real_target_addr (EmulationPacket* base, guint index); static void emulation_packet2_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); enum { EMULATION_PACKET3_DUMMY_PROPERTY, EMULATION_PACKET3_OPCODE, - EMULATION_PACKET3_LENGTH + EMULATION_PACKET3_LENGTH, + EMULATION_PACKET3_OPCODE_NAME }; +static guint32 emulation_packet3_real_target_addr (EmulationPacket* base, guint index); guint32 emulation_packet3_get__IT_OPCODE (EmulationPacket3* self); guint32 emulation_packet3_get_opcode (EmulationPacket3* self); guint32 emulation_packet3_get__COUNT (EmulationPacket3* self); +const char* emulation_packet3_get_opcode_name (EmulationPacket3* self); static void emulation_packet3_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); GType emulation_cs_get_type (void); +#define EMULATION_CS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMULATION_TYPE_CS, EmulationCSPrivate)) +enum { + EMULATION_CS_DUMMY_PROPERTY, + EMULATION_CS_ELEMENT_TYPE, + EMULATION_CS_LENGTH +}; +static guint emulation_cs_check (guint32* dwords, guint len); +EmulationCSIterator* emulation_cs_iterator_new (EmulationCS* cs); +EmulationCSIterator* emulation_cs_iterator_construct (GType object_type, EmulationCS* cs); +gpointer emulation_cs_iterator_ref (gpointer instance); +void emulation_cs_iterator_unref (gpointer instance); +GParamSpec* emulation_cs_param_spec_iterator (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags); +void emulation_cs_value_set_iterator (GValue* value, gpointer v_object); +gpointer emulation_cs_value_get_iterator (const GValue* value); +GType emulation_cs_iterator_get_type (void); +EmulationCSIterator* emulation_cs_iterator (EmulationCS* self); +EmulationPacket* emulation_cs_get (EmulationCS* self, guint index); +static EmulationPacket** _vala_array_dup1 (EmulationPacket** self, int length); +EmulationCS* emulation_cs_new (guint32* dwords, guint len); +EmulationCS* emulation_cs_construct (GType object_type, guint32* dwords, guint len); +GType emulation_cs_get_element_type (EmulationCS* self); +guint emulation_cs_get_length (EmulationCS* self); +#define EMULATION_CS_ITERATOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMULATION_CS_TYPE_ITERATOR, EmulationCSIteratorPrivate)) enum { - EMULATION_CS_DUMMY_PROPERTY + EMULATION_CS_ITERATOR_DUMMY_PROPERTY }; -static guint emulation_cs_check (guint32* cs, guint len); -static guint32* _vala_array_dup1 (guint32* self, int length); -static EmulationPacketBase** _vala_array_dup2 (EmulationPacketBase** self, int length); -EmulationCS* emulation_cs_new (guint32* cs, guint len); -EmulationCS* emulation_cs_construct (GType object_type, guint32* cs, guint len); +gboolean emulation_cs_iterator_next (EmulationCSIterator* self); +EmulationPacket* emulation_cs_iterator_get (EmulationCSIterator* self); +static void emulation_cs_iterator_finalize (EmulationCSIterator* obj); static void emulation_cs_finalize (GObject* obj); +static void emulation_cs_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func); static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func); +EmulationPacketIterator* emulation_packet_iterator (EmulationPacket* self) { + EmulationPacketIterator* result; + g_return_val_if_fail (self != NULL, NULL); + result = emulation_packet_iterator_new (self); + return result; +} + -GType emulation_chip_get_type (void) { - static GType emulation_chip_type_id = 0; - if (G_UNLIKELY (emulation_chip_type_id == 0)) { - static const GEnumValue values[] = {{EMULATION_CHIP_R300, "EMULATION_CHIP_R300", "r300"}, {EMULATION_CHIP_R500, "EMULATION_CHIP_R500", "r500"}, {0, NULL, NULL}}; - emulation_chip_type_id = g_enum_register_static ("EmulationChip", values); - } - return emulation_chip_type_id; +static guint32 emulation_packet_real_target_addr (EmulationPacket* self, guint index) { + g_return_val_if_fail (self != NULL, 0U); + g_critical ("Type `%s' does not implement abstract method `emulation_packet_target_addr'", g_type_name (G_TYPE_FROM_INSTANCE (self))); + return 0U; } -inline guint emulation_packet_typeid (guint32 header) { - guint result; - result = (guint) ((header >> 30) & 3); +guint32 emulation_packet_target_addr (EmulationPacket* self, guint index) { + return EMULATION_PACKET_GET_CLASS (self)->target_addr (self, index); +} + + +guint32 emulation_packet_get (EmulationPacket* self, guint index) { + guint32 result; + g_return_val_if_fail (self != NULL, 0U); + result = self->dwords[index]; + return result; +} + + +inline guint32 emulation_packet_extract_bits (EmulationPacket* self, guint high, guint low) { + guint32 result; + g_return_val_if_fail (self != NULL, 0U); + result = (self->priv->_header >> low) & ((1 << ((high - low) + 1)) - 1); return result; } -inline EmulationPacketBase* emulation_make_packet (guint32 header, guint32* dwords) { - EmulationPacketBase* result; - switch (emulation_packet_typeid (header)) { +EmulationPacket* emulation_packet_make (guint32 header, guint32* dwords) { + EmulationPacket* result; + switch ((header >> 30) & 3) { case 0: { - result = (EmulationPacketBase*) emulation_packet0_new (header, dwords); + result = (EmulationPacket*) emulation_packet0_new (header, dwords); return result; } case 1: { - result = (EmulationPacketBase*) emulation_packet1_new (header, dwords); + result = (EmulationPacket*) emulation_packet1_new (header, dwords); return result; } case 2: { - result = (EmulationPacketBase*) emulation_packet2_new (header, dwords); + result = (EmulationPacket*) emulation_packet2_new (header); return result; } case 3: { - result = (EmulationPacketBase*) emulation_packet3_new (header, dwords); + result = (EmulationPacket*) emulation_packet3_new (header, dwords); return result; } } g_assert (FALSE); - result = emulation_packet_base_new (); + result = (EmulationPacket*) emulation_packet2_new (header); return result; } -EmulationPacketIterator* emulation_packet_iterator_construct (GType object_type, EmulationPacketBase* p) { +EmulationPacket* emulation_packet_construct (GType object_type) { + EmulationPacket * self; + self = (EmulationPacket*) g_object_new (object_type, NULL); + return self; +} + + +guint32 emulation_packet_get_header (EmulationPacket* self) { + guint32 result; + g_return_val_if_fail (self != NULL, 0U); + result = self->priv->_header; + return result; +} + + +void emulation_packet_set_header (EmulationPacket* self, guint32 value) { + g_return_if_fail (self != NULL); + self->priv->_header = value; + g_object_notify ((GObject *) self, "header"); +} + + +guint emulation_packet_get_type_id (EmulationPacket* self) { + guint result; + g_return_val_if_fail (self != NULL, 0U); + result = (guint) ((self->priv->_header >> 30) & 3); + return result; +} + + +guint emulation_packet_get_length (EmulationPacket* self) { + return EMULATION_PACKET_GET_CLASS (self)->get_length (self); +} + + +EmulationPacketIterator* emulation_packet_iterator_construct (GType object_type, EmulationPacket* p) { EmulationPacketIterator* self; g_return_val_if_fail (p != NULL, NULL); self = (EmulationPacketIterator*) g_type_create_instance (object_type); - self->priv->m_packet = p; - self->priv->m_pos = (guint) 0; + self->priv->packet = p; + self->priv->pos = (guint) 0; return self; } -EmulationPacketIterator* emulation_packet_iterator_new (EmulationPacketBase* p) { - return emulation_packet_iterator_construct (EMULATION_TYPE_PACKET_ITERATOR, p); +EmulationPacketIterator* emulation_packet_iterator_new (EmulationPacket* p) { + return emulation_packet_iterator_construct (EMULATION_PACKET_TYPE_ITERATOR, p); } gboolean emulation_packet_iterator_next (EmulationPacketIterator* self) { gboolean result; g_return_val_if_fail (self != NULL, FALSE); - result = self->priv->m_pos < emulation_packet_base_get_length (self->priv->m_packet); + result = (self->priv->pos++) < emulation_packet_get_length (self->priv->packet); return result; } @@ -378,24 +495,24 @@ gboolean emulation_packet_iterator_next (EmulationPacketIterator* self) { guint32 emulation_packet_iterator_get (EmulationPacketIterator* self) { guint32 result; g_return_val_if_fail (self != NULL, 0U); - result = self->priv->m_packet->dwords[self->priv->m_pos++]; + result = emulation_packet_get (self->priv->packet, self->priv->pos - 1); return result; } -static void emulation_value_packet_iterator_init (GValue* value) { +static void emulation_packet_value_iterator_init (GValue* value) { value->data[0].v_pointer = NULL; } -static void emulation_value_packet_iterator_free_value (GValue* value) { +static void emulation_packet_value_iterator_free_value (GValue* value) { if (value->data[0].v_pointer) { emulation_packet_iterator_unref (value->data[0].v_pointer); } } -static void emulation_value_packet_iterator_copy_value (const GValue* src_value, GValue* dest_value) { +static void emulation_packet_value_iterator_copy_value (const GValue* src_value, GValue* dest_value) { if (src_value->data[0].v_pointer) { dest_value->data[0].v_pointer = emulation_packet_iterator_ref (src_value->data[0].v_pointer); } else { @@ -404,12 +521,12 @@ static void emulation_value_packet_iterator_copy_value (const GValue* src_value, } -static gpointer emulation_value_packet_iterator_peek_pointer (const GValue* value) { +static gpointer emulation_packet_value_iterator_peek_pointer (const GValue* value) { return value->data[0].v_pointer; } -static gchar* emulation_value_packet_iterator_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) { +static gchar* emulation_packet_value_iterator_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) { if (collect_values[0].v_pointer) { EmulationPacketIterator* object; object = collect_values[0].v_pointer; @@ -426,7 +543,7 @@ static gchar* emulation_value_packet_iterator_collect_value (GValue* value, guin } -static gchar* emulation_value_packet_iterator_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) { +static gchar* emulation_packet_value_iterator_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) { EmulationPacketIterator** object_p; object_p = collect_values[0].v_pointer; if (!object_p) { @@ -443,27 +560,27 @@ static gchar* emulation_value_packet_iterator_lcopy_value (const GValue* value, } -GParamSpec* emulation_param_spec_packet_iterator (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) { - EmulationParamSpecPacketIterator* spec; - g_return_val_if_fail (g_type_is_a (object_type, EMULATION_TYPE_PACKET_ITERATOR), NULL); +GParamSpec* emulation_packet_param_spec_iterator (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) { + EmulationPacketParamSpecIterator* spec; + g_return_val_if_fail (g_type_is_a (object_type, EMULATION_PACKET_TYPE_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_packet_iterator (const GValue* value) { - g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EMULATION_TYPE_PACKET_ITERATOR), NULL); +gpointer emulation_packet_value_get_iterator (const GValue* value) { + g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EMULATION_PACKET_TYPE_ITERATOR), NULL); return value->data[0].v_pointer; } -void emulation_value_set_packet_iterator (GValue* value, gpointer v_object) { +void emulation_packet_value_set_iterator (GValue* value, gpointer v_object) { EmulationPacketIterator* old; - g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EMULATION_TYPE_PACKET_ITERATOR)); + g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EMULATION_PACKET_TYPE_ITERATOR)); old = value->data[0].v_pointer; if (v_object) { - g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, EMULATION_TYPE_PACKET_ITERATOR)); + g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, EMULATION_PACKET_TYPE_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_packet_iterator_ref (value->data[0].v_pointer); @@ -498,7 +615,7 @@ static void emulation_packet_iterator_finalize (EmulationPacketIterator* obj) { GType emulation_packet_iterator_get_type (void) { static GType emulation_packet_iterator_type_id = 0; if (emulation_packet_iterator_type_id == 0) { - static const GTypeValueTable g_define_type_value_table = { emulation_value_packet_iterator_init, emulation_value_packet_iterator_free_value, emulation_value_packet_iterator_copy_value, emulation_value_packet_iterator_peek_pointer, "p", emulation_value_packet_iterator_collect_value, "p", emulation_value_packet_iterator_lcopy_value }; + static const GTypeValueTable g_define_type_value_table = { emulation_packet_value_iterator_init, emulation_packet_value_iterator_free_value, emulation_packet_value_iterator_copy_value, emulation_packet_value_iterator_peek_pointer, "p", emulation_packet_value_iterator_collect_value, "p", emulation_packet_value_iterator_lcopy_value }; static const GTypeInfo g_define_type_info = { sizeof (EmulationPacketIteratorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emulation_packet_iterator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmulationPacketIterator), 0, (GInstanceInitFunc) emulation_packet_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_packet_iterator_type_id = g_type_register_fundamental (g_type_fundamental_next (), "EmulationPacketIterator", &g_define_type_info, &g_define_type_fundamental_info, 0); @@ -525,103 +642,65 @@ void emulation_packet_iterator_unref (gpointer instance) { } -EmulationPacketIterator* emulation_packet_base_iterator (EmulationPacketBase* self) { - EmulationPacketIterator* result; - g_return_val_if_fail (self != NULL, NULL); - result = emulation_packet_iterator_new (self); - return result; -} - - -guint32 emulation_packet_base_get (EmulationPacketBase* self, guint index) { - guint32 result; - g_return_val_if_fail (self != NULL, 0U); - result = self->dwords[index]; - return result; -} - - -inline guint32 emulation_packet_base_extract_bits (EmulationPacketBase* self, guint high, guint low) { - guint32 result; - g_return_val_if_fail (self != NULL, 0U); - result = (self->header >> low) & ((1 << ((high - low) + 1)) - 1); - return result; -} - - -EmulationPacketBase* emulation_packet_base_construct (GType object_type) { - EmulationPacketBase * self; - self = (EmulationPacketBase*) g_object_new (object_type, NULL); - return self; -} - - -EmulationPacketBase* emulation_packet_base_new (void) { - return emulation_packet_base_construct (EMULATION_TYPE_PACKET_BASE); -} - - -GType emulation_packet_base_get_element_type (EmulationPacketBase* self) { - GType result; - g_return_val_if_fail (self != NULL, 0UL); - result = G_TYPE_UINT; - return result; -} - - -guint emulation_packet_base_get_type_id (EmulationPacketBase* self) { - guint result; - g_return_val_if_fail (self != NULL, 0U); - result = emulation_packet_typeid (self->header); - return result; +static void emulation_packet_class_init (EmulationPacketClass * klass) { + emulation_packet_parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (EmulationPacketPrivate)); + EMULATION_PACKET_CLASS (klass)->target_addr = emulation_packet_real_target_addr; + G_OBJECT_CLASS (klass)->get_property = emulation_packet_get_property; + G_OBJECT_CLASS (klass)->set_property = emulation_packet_set_property; + G_OBJECT_CLASS (klass)->finalize = emulation_packet_finalize; + g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_PACKET_HEADER, g_param_spec_uint ("header", "header", "header", 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_PACKET_TYPE_ID, g_param_spec_uint ("type-id", "type-id", "type-id", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_PACKET_LENGTH, g_param_spec_uint ("length", "length", "length", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); } -guint emulation_packet_base_get_length (EmulationPacketBase* self) { - return EMULATION_PACKET_BASE_GET_CLASS (self)->get_length (self); +static void emulation_packet_instance_init (EmulationPacket * self) { + self->priv = EMULATION_PACKET_GET_PRIVATE (self); } -static void emulation_packet_base_class_init (EmulationPacketBaseClass * klass) { - emulation_packet_base_parent_class = g_type_class_peek_parent (klass); - G_OBJECT_CLASS (klass)->get_property = emulation_packet_base_get_property; - G_OBJECT_CLASS (klass)->finalize = emulation_packet_base_finalize; - g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_PACKET_BASE_ELEMENT_TYPE, g_param_spec_gtype ("element-type", "element-type", "element-type", G_TYPE_NONE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_PACKET_BASE_TYPE_ID, g_param_spec_uint ("type-id", "type-id", "type-id", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_PACKET_BASE_LENGTH, g_param_spec_uint ("length", "length", "length", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); -} - - -static void emulation_packet_base_instance_init (EmulationPacketBase * self) { +static void emulation_packet_finalize (GObject* obj) { + EmulationPacket * self; + self = EMULATION_PACKET (obj); + self->dwords = (g_free (self->dwords), NULL); + G_OBJECT_CLASS (emulation_packet_parent_class)->finalize (obj); } -static void emulation_packet_base_finalize (GObject* obj) { - EmulationPacketBase * self; - self = EMULATION_PACKET_BASE (obj); - G_OBJECT_CLASS (emulation_packet_base_parent_class)->finalize (obj); +GType emulation_packet_get_type (void) { + static GType emulation_packet_type_id = 0; + if (emulation_packet_type_id == 0) { + static const GTypeInfo g_define_type_info = { sizeof (EmulationPacketClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emulation_packet_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmulationPacket), 0, (GInstanceInitFunc) emulation_packet_instance_init, NULL }; + emulation_packet_type_id = g_type_register_static (G_TYPE_OBJECT, "EmulationPacket", &g_define_type_info, G_TYPE_FLAG_ABSTRACT); + } + return emulation_packet_type_id; } -GType emulation_packet_base_get_type (void) { - static GType emulation_packet_base_type_id = 0; - if (emulation_packet_base_type_id == 0) { - static const GTypeInfo g_define_type_info = { sizeof (EmulationPacketBaseClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emulation_packet_base_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmulationPacketBase), 0, (GInstanceInitFunc) emulation_packet_base_instance_init, NULL }; - emulation_packet_base_type_id = g_type_register_static (G_TYPE_OBJECT, "EmulationPacketBase", &g_define_type_info, 0); +static void emulation_packet_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { + EmulationPacket * self; + self = EMULATION_PACKET (object); + switch (property_id) { + case EMULATION_PACKET_HEADER: + g_value_set_uint (value, emulation_packet_get_header (self)); + break; + case EMULATION_PACKET_TYPE_ID: + g_value_set_uint (value, emulation_packet_get_type_id (self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; } - return emulation_packet_base_type_id; } -static void emulation_packet_base_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { - EmulationPacketBase * self; - self = EMULATION_PACKET_BASE (object); +static void emulation_packet_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { + EmulationPacket * self; + self = EMULATION_PACKET (object); switch (property_id) { - case EMULATION_PACKET_BASE_ELEMENT_TYPE: - g_value_set_gtype (value, emulation_packet_base_get_element_type (self)); - break; - case EMULATION_PACKET_BASE_TYPE_ID: - g_value_set_uint (value, emulation_packet_base_get_type_id (self)); + case EMULATION_PACKET_HEADER: + emulation_packet_set_header (self, g_value_get_uint (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -630,11 +709,48 @@ static void emulation_packet_base_get_property (GObject * object, guint property } +static guint32 emulation_packet0_real_target_addr (EmulationPacket* base, guint index) { + EmulationPacket0 * self; + guint32 result; + guint32 _tmp0_ = 0U; + self = (EmulationPacket0*) base; + if (emulation_packet0_get_one_reg_wr (self)) { + _tmp0_ = emulation_packet0_get_addr (self); + } else { + _tmp0_ = emulation_packet0_get_addr (self) + (index * 4); + } + result = _tmp0_; + return result; +} + + EmulationPacket0* emulation_packet0_construct (GType object_type, guint32 header, guint32* dwords) { EmulationPacket0 * self; - self = (EmulationPacket0*) emulation_packet_base_construct (object_type); - ((EmulationPacketBase*) self)->header = header; - ((EmulationPacketBase*) self)->dwords = dwords; + self = (EmulationPacket0*) emulation_packet_construct (object_type); + emulation_packet_set_header ((EmulationPacket*) self, header); + if (dwords != NULL) { + guint32* _tmp1_; + gint _tmp0_; + ((EmulationPacket*) self)->dwords = (_tmp1_ = g_new0 (guint32, _tmp0_ = emulation_packet_get_length ((EmulationPacket*) self)), ((EmulationPacket*) self)->dwords = (g_free (((EmulationPacket*) self)->dwords), NULL), ((EmulationPacket*) self)->dwords_length1 = _tmp0_, _tmp1_); + { + guint i; + i = (guint) 0; + { + gboolean _tmp2_; + _tmp2_ = TRUE; + while (TRUE) { + if (!_tmp2_) { + i++; + } + _tmp2_ = FALSE; + if (!(i < emulation_packet_get_length ((EmulationPacket*) self))) { + break; + } + ((EmulationPacket*) self)->dwords[i] = dwords[i]; + } + } + } + } return self; } @@ -660,7 +776,7 @@ gboolean emulation_packet0_get_one_reg_wr (EmulationPacket0* self) { } -static guint emulation_packet0_real_get_length (EmulationPacketBase* base) { +static guint emulation_packet0_real_get_length (EmulationPacket* base) { guint result; EmulationPacket0* self; self = (EmulationPacket0*) base; @@ -672,7 +788,7 @@ static guint emulation_packet0_real_get_length (EmulationPacketBase* base) { guint32 emulation_packet0_get__ADDR (EmulationPacket0* self) { guint32 result; g_return_val_if_fail (self != NULL, 0U); - result = emulation_packet_base_extract_bits ((EmulationPacketBase*) self, (guint) 12, (guint) 0); + result = emulation_packet_extract_bits ((EmulationPacket*) self, (guint) 12, (guint) 0); return result; } @@ -680,7 +796,7 @@ guint32 emulation_packet0_get__ADDR (EmulationPacket0* self) { guint32 emulation_packet0_get__ONE_REG_WR (EmulationPacket0* self) { guint32 result; g_return_val_if_fail (self != NULL, 0U); - result = emulation_packet_base_extract_bits ((EmulationPacketBase*) self, (guint) 15, (guint) 15); + result = emulation_packet_extract_bits ((EmulationPacket*) self, (guint) 15, (guint) 15); return result; } @@ -688,14 +804,15 @@ guint32 emulation_packet0_get__ONE_REG_WR (EmulationPacket0* self) { guint32 emulation_packet0_get__COUNT (EmulationPacket0* self) { guint32 result; g_return_val_if_fail (self != NULL, 0U); - result = emulation_packet_base_extract_bits ((EmulationPacketBase*) self, (guint) 29, (guint) 16); + result = emulation_packet_extract_bits ((EmulationPacket*) self, (guint) 29, (guint) 16); return result; } static void emulation_packet0_class_init (EmulationPacket0Class * klass) { emulation_packet0_parent_class = g_type_class_peek_parent (klass); - EMULATION_PACKET_BASE_CLASS (klass)->get_length = emulation_packet0_real_get_length; + EMULATION_PACKET_CLASS (klass)->target_addr = emulation_packet0_real_target_addr; + EMULATION_PACKET_CLASS (klass)->get_length = emulation_packet0_real_get_length; G_OBJECT_CLASS (klass)->get_property = emulation_packet0_get_property; g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_PACKET0_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_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_PACKET0_ONE_REG_WR, g_param_spec_boolean ("one-reg-wr", "one-reg-wr", "one-reg-wr", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); @@ -711,7 +828,7 @@ GType emulation_packet0_get_type (void) { static GType emulation_packet0_type_id = 0; if (emulation_packet0_type_id == 0) { static const GTypeInfo g_define_type_info = { sizeof (EmulationPacket0Class), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emulation_packet0_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmulationPacket0), 0, (GInstanceInitFunc) emulation_packet0_instance_init, NULL }; - emulation_packet0_type_id = g_type_register_static (EMULATION_TYPE_PACKET_BASE, "EmulationPacket0", &g_define_type_info, 0); + emulation_packet0_type_id = g_type_register_static (EMULATION_TYPE_PACKET, "EmulationPacket0", &g_define_type_info, 0); } return emulation_packet0_type_id; } @@ -728,7 +845,7 @@ static void emulation_packet0_get_property (GObject * object, guint property_id, g_value_set_boolean (value, emulation_packet0_get_one_reg_wr (self)); break; case EMULATION_PACKET0_LENGTH: - g_value_set_uint (value, emulation_packet_base_get_length ((EmulationPacketBase*) self)); + g_value_set_uint (value, emulation_packet_get_length ((EmulationPacket*) self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -737,11 +854,31 @@ static void emulation_packet0_get_property (GObject * object, guint property_id, } +static guint32 emulation_packet1_real_target_addr (EmulationPacket* base, guint index) { + EmulationPacket1 * self; + guint32 result; + guint32 _tmp0_ = 0U; + self = (EmulationPacket1*) base; + if (index == 0) { + _tmp0_ = emulation_packet1_get_addr1 (self); + } else { + _tmp0_ = emulation_packet1_get_addr2 (self); + } + result = _tmp0_; + return result; +} + + EmulationPacket1* emulation_packet1_construct (GType object_type, guint32 header, guint32* dwords) { EmulationPacket1 * self; - self = (EmulationPacket1*) emulation_packet_base_construct (object_type); - ((EmulationPacketBase*) self)->header = header; - ((EmulationPacketBase*) self)->dwords = dwords; + self = (EmulationPacket1*) emulation_packet_construct (object_type); + emulation_packet_set_header ((EmulationPacket*) self, header); + if (dwords != NULL) { + guint32* _tmp0_; + ((EmulationPacket*) self)->dwords = (_tmp0_ = g_new0 (guint32, 2), ((EmulationPacket*) self)->dwords = (g_free (((EmulationPacket*) self)->dwords), NULL), ((EmulationPacket*) self)->dwords_length1 = 2, _tmp0_); + ((EmulationPacket*) self)->dwords[0] = dwords[0]; + ((EmulationPacket*) self)->dwords[1] = dwords[1]; + } return self; } @@ -767,7 +904,7 @@ guint32 emulation_packet1_get_addr2 (EmulationPacket1* self) { } -static guint emulation_packet1_real_get_length (EmulationPacketBase* base) { +static guint emulation_packet1_real_get_length (EmulationPacket* base) { guint result; EmulationPacket1* self; self = (EmulationPacket1*) base; @@ -779,7 +916,7 @@ static guint emulation_packet1_real_get_length (EmulationPacketBase* base) { guint32 emulation_packet1_get__ADDR1 (EmulationPacket1* self) { guint32 result; g_return_val_if_fail (self != NULL, 0U); - result = emulation_packet_base_extract_bits ((EmulationPacketBase*) self, (guint) 10, (guint) 0); + result = emulation_packet_extract_bits ((EmulationPacket*) self, (guint) 10, (guint) 0); return result; } @@ -787,14 +924,15 @@ guint32 emulation_packet1_get__ADDR1 (EmulationPacket1* self) { guint32 emulation_packet1_get__ADDR2 (EmulationPacket1* self) { guint32 result; g_return_val_if_fail (self != NULL, 0U); - result = emulation_packet_base_extract_bits ((EmulationPacketBase*) self, (guint) 21, (guint) 11); + result = emulation_packet_extract_bits ((EmulationPacket*) self, (guint) 21, (guint) 11); return result; } static void emulation_packet1_class_init (EmulationPacket1Class * klass) { emulation_packet1_parent_class = g_type_class_peek_parent (klass); - EMULATION_PACKET_BASE_CLASS (klass)->get_length = emulation_packet1_real_get_length; + EMULATION_PACKET_CLASS (klass)->target_addr = emulation_packet1_real_target_addr; + EMULATION_PACKET_CLASS (klass)->get_length = emulation_packet1_real_get_length; G_OBJECT_CLASS (klass)->get_property = emulation_packet1_get_property; g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_PACKET1_ADDR1, g_param_spec_uint ("addr1", "addr1", "addr1", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_PACKET1_ADDR2, g_param_spec_uint ("addr2", "addr2", "addr2", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); @@ -810,7 +948,7 @@ GType emulation_packet1_get_type (void) { static GType emulation_packet1_type_id = 0; if (emulation_packet1_type_id == 0) { static const GTypeInfo g_define_type_info = { sizeof (EmulationPacket1Class), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emulation_packet1_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmulationPacket1), 0, (GInstanceInitFunc) emulation_packet1_instance_init, NULL }; - emulation_packet1_type_id = g_type_register_static (EMULATION_TYPE_PACKET_BASE, "EmulationPacket1", &g_define_type_info, 0); + emulation_packet1_type_id = g_type_register_static (EMULATION_TYPE_PACKET, "EmulationPacket1", &g_define_type_info, 0); } return emulation_packet1_type_id; } @@ -827,7 +965,7 @@ static void emulation_packet1_get_property (GObject * object, guint property_id, g_value_set_uint (value, emulation_packet1_get_addr2 (self)); break; case EMULATION_PACKET1_LENGTH: - g_value_set_uint (value, emulation_packet_base_get_length ((EmulationPacketBase*) self)); + g_value_set_uint (value, emulation_packet_get_length ((EmulationPacket*) self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -836,21 +974,31 @@ static void emulation_packet1_get_property (GObject * object, guint property_id, } -EmulationPacket2* emulation_packet2_construct (GType object_type, guint32 header, guint32* dwords) { +static guint32 emulation_packet2_real_target_addr (EmulationPacket* base, guint index) { EmulationPacket2 * self; - self = (EmulationPacket2*) emulation_packet_base_construct (object_type); - ((EmulationPacketBase*) self)->header = header; - ((EmulationPacketBase*) self)->dwords = dwords; + guint32 result; + self = (EmulationPacket2*) base; + result = (guint32) 0; + return result; +} + + +EmulationPacket2* emulation_packet2_construct (GType object_type, guint32 header) { + EmulationPacket2 * self; + guint32* _tmp0_; + self = (EmulationPacket2*) emulation_packet_construct (object_type); + emulation_packet_set_header ((EmulationPacket*) self, header); + ((EmulationPacket*) self)->dwords = (_tmp0_ = NULL, ((EmulationPacket*) self)->dwords = (g_free (((EmulationPacket*) self)->dwords), NULL), ((EmulationPacket*) self)->dwords_length1 = 0, _tmp0_); return self; } -EmulationPacket2* emulation_packet2_new (guint32 header, guint32* dwords) { - return emulation_packet2_construct (EMULATION_TYPE_PACKET2, header, dwords); +EmulationPacket2* emulation_packet2_new (guint32 header) { + return emulation_packet2_construct (EMULATION_TYPE_PACKET2, header); } -static guint emulation_packet2_real_get_length (EmulationPacketBase* base) { +static guint emulation_packet2_real_get_length (EmulationPacket* base) { guint result; EmulationPacket2* self; self = (EmulationPacket2*) base; @@ -861,7 +1009,8 @@ static guint emulation_packet2_real_get_length (EmulationPacketBase* base) { static void emulation_packet2_class_init (EmulationPacket2Class * klass) { emulation_packet2_parent_class = g_type_class_peek_parent (klass); - EMULATION_PACKET_BASE_CLASS (klass)->get_length = emulation_packet2_real_get_length; + EMULATION_PACKET_CLASS (klass)->target_addr = emulation_packet2_real_target_addr; + EMULATION_PACKET_CLASS (klass)->get_length = emulation_packet2_real_get_length; G_OBJECT_CLASS (klass)->get_property = emulation_packet2_get_property; g_object_class_override_property (G_OBJECT_CLASS (klass), EMULATION_PACKET2_LENGTH, "length"); } @@ -875,7 +1024,7 @@ GType emulation_packet2_get_type (void) { static GType emulation_packet2_type_id = 0; if (emulation_packet2_type_id == 0) { static const GTypeInfo g_define_type_info = { sizeof (EmulationPacket2Class), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emulation_packet2_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmulationPacket2), 0, (GInstanceInitFunc) emulation_packet2_instance_init, NULL }; - emulation_packet2_type_id = g_type_register_static (EMULATION_TYPE_PACKET_BASE, "EmulationPacket2", &g_define_type_info, 0); + emulation_packet2_type_id = g_type_register_static (EMULATION_TYPE_PACKET, "EmulationPacket2", &g_define_type_info, 0); } return emulation_packet2_type_id; } @@ -886,7 +1035,7 @@ static void emulation_packet2_get_property (GObject * object, guint property_id, self = EMULATION_PACKET2 (object); switch (property_id) { case EMULATION_PACKET2_LENGTH: - g_value_set_uint (value, emulation_packet_base_get_length ((EmulationPacketBase*) self)); + g_value_set_uint (value, emulation_packet_get_length ((EmulationPacket*) self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -895,11 +1044,42 @@ static void emulation_packet2_get_property (GObject * object, guint property_id, } +static guint32 emulation_packet3_real_target_addr (EmulationPacket* base, guint index) { + EmulationPacket3 * self; + guint32 result; + self = (EmulationPacket3*) base; + result = (guint32) 0; + return result; +} + + EmulationPacket3* emulation_packet3_construct (GType object_type, guint32 header, guint32* dwords) { EmulationPacket3 * self; - self = (EmulationPacket3*) emulation_packet_base_construct (object_type); - ((EmulationPacketBase*) self)->header = header; - ((EmulationPacketBase*) self)->dwords = dwords; + self = (EmulationPacket3*) emulation_packet_construct (object_type); + emulation_packet_set_header ((EmulationPacket*) self, header); + if (dwords != NULL) { + guint32* _tmp1_; + gint _tmp0_; + ((EmulationPacket*) self)->dwords = (_tmp1_ = g_new0 (guint32, _tmp0_ = emulation_packet_get_length ((EmulationPacket*) self)), ((EmulationPacket*) self)->dwords = (g_free (((EmulationPacket*) self)->dwords), NULL), ((EmulationPacket*) self)->dwords_length1 = _tmp0_, _tmp1_); + { + guint i; + i = (guint) 0; + { + gboolean _tmp2_; + _tmp2_ = TRUE; + while (TRUE) { + if (!_tmp2_) { + i++; + } + _tmp2_ = FALSE; + if (!(i < emulation_packet_get_length ((EmulationPacket*) self))) { + break; + } + ((EmulationPacket*) self)->dwords[i] = dwords[i]; + } + } + } + } return self; } @@ -917,7 +1097,7 @@ guint32 emulation_packet3_get_opcode (EmulationPacket3* self) { } -static guint emulation_packet3_real_get_length (EmulationPacketBase* base) { +static guint emulation_packet3_real_get_length (EmulationPacket* base) { guint result; EmulationPacket3* self; self = (EmulationPacket3*) base; @@ -929,7 +1109,7 @@ static guint emulation_packet3_real_get_length (EmulationPacketBase* base) { guint32 emulation_packet3_get__IT_OPCODE (EmulationPacket3* self) { guint32 result; g_return_val_if_fail (self != NULL, 0U); - result = emulation_packet_base_extract_bits ((EmulationPacketBase*) self, (guint) 15, (guint) 8); + result = emulation_packet_extract_bits ((EmulationPacket*) self, (guint) 15, (guint) 8); return result; } @@ -937,17 +1117,27 @@ guint32 emulation_packet3_get__IT_OPCODE (EmulationPacket3* self) { guint32 emulation_packet3_get__COUNT (EmulationPacket3* self) { guint32 result; g_return_val_if_fail (self != NULL, 0U); - result = emulation_packet_base_extract_bits ((EmulationPacketBase*) self, (guint) 29, (guint) 16); + result = emulation_packet_extract_bits ((EmulationPacket*) self, (guint) 29, (guint) 16); + return result; +} + + +const char* emulation_packet3_get_opcode_name (EmulationPacket3* self) { + const char* result; + g_return_val_if_fail (self != NULL, NULL); + result = "TODO"; return result; } static void emulation_packet3_class_init (EmulationPacket3Class * klass) { emulation_packet3_parent_class = g_type_class_peek_parent (klass); - EMULATION_PACKET_BASE_CLASS (klass)->get_length = emulation_packet3_real_get_length; + EMULATION_PACKET_CLASS (klass)->target_addr = emulation_packet3_real_target_addr; + EMULATION_PACKET_CLASS (klass)->get_length = emulation_packet3_real_get_length; G_OBJECT_CLASS (klass)->get_property = emulation_packet3_get_property; g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_PACKET3_OPCODE, g_param_spec_uint ("opcode", "opcode", "opcode", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); g_object_class_override_property (G_OBJECT_CLASS (klass), EMULATION_PACKET3_LENGTH, "length"); + g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_PACKET3_OPCODE_NAME, g_param_spec_string ("opcode-name", "opcode-name", "opcode-name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); } @@ -959,7 +1149,7 @@ GType emulation_packet3_get_type (void) { static GType emulation_packet3_type_id = 0; if (emulation_packet3_type_id == 0) { static const GTypeInfo g_define_type_info = { sizeof (EmulationPacket3Class), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emulation_packet3_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmulationPacket3), 0, (GInstanceInitFunc) emulation_packet3_instance_init, NULL }; - emulation_packet3_type_id = g_type_register_static (EMULATION_TYPE_PACKET_BASE, "EmulationPacket3", &g_define_type_info, 0); + emulation_packet3_type_id = g_type_register_static (EMULATION_TYPE_PACKET, "EmulationPacket3", &g_define_type_info, 0); } return emulation_packet3_type_id; } @@ -973,7 +1163,10 @@ static void emulation_packet3_get_property (GObject * object, guint property_id, g_value_set_uint (value, emulation_packet3_get_opcode (self)); break; case EMULATION_PACKET3_LENGTH: - g_value_set_uint (value, emulation_packet_base_get_length ((EmulationPacketBase*) self)); + g_value_set_uint (value, emulation_packet_get_length ((EmulationPacket*) self)); + break; + case EMULATION_PACKET3_OPCODE_NAME: + g_value_set_string (value, emulation_packet3_get_opcode_name (self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -982,7 +1175,7 @@ static void emulation_packet3_get_property (GObject * object, guint property_id, } -static guint emulation_cs_check (guint32* cs, guint len) { +static guint emulation_cs_check (guint32* dwords, guint len) { guint result; gint pkt_count; pkt_count = 0; @@ -993,7 +1186,7 @@ static guint emulation_cs_check (guint32* cs, guint len) { gboolean _tmp0_; _tmp0_ = TRUE; while (TRUE) { - EmulationPacketBase* _tmp1_; + EmulationPacket* _tmp1_; if (!_tmp0_) { i++; pkt_count++; @@ -1002,7 +1195,7 @@ static guint emulation_cs_check (guint32* cs, guint len) { if (!(i < len)) { break; } - i = i + emulation_packet_base_get_length (_tmp1_ = emulation_make_packet (cs[i], NULL)); + i = i + emulation_packet_get_length (_tmp1_ = emulation_packet_make (dwords[i], NULL)); _g_object_unref0 (_tmp1_); if ((i + 1) > len) { result = (guint) 0; @@ -1016,8 +1209,11 @@ static guint emulation_cs_check (guint32* cs, guint len) { } -static guint32* _vala_array_dup1 (guint32* self, int length) { - return g_memdup (self, length * sizeof (guint32)); +EmulationCSIterator* emulation_cs_iterator (EmulationCS* self) { + EmulationCSIterator* result; + g_return_val_if_fail (self != NULL, NULL); + result = emulation_cs_iterator_new (self); + return result; } @@ -1026,10 +1222,18 @@ static gpointer _g_object_ref0 (gpointer self) { } -static EmulationPacketBase** _vala_array_dup2 (EmulationPacketBase** self, int length) { - EmulationPacketBase** result; +EmulationPacket* emulation_cs_get (EmulationCS* self, guint index) { + EmulationPacket* result; + g_return_val_if_fail (self != NULL, NULL); + result = _g_object_ref0 (self->priv->packets[index]); + return result; +} + + +static EmulationPacket** _vala_array_dup1 (EmulationPacket** self, int length) { + EmulationPacket** result; int i; - result = g_new0 (EmulationPacketBase*, length + 1); + result = g_new0 (EmulationPacket*, length + 1); for (i = 0; i < length; i++) { result[i] = _g_object_ref0 (self[i]); } @@ -1037,101 +1241,276 @@ static EmulationPacketBase** _vala_array_dup2 (EmulationPacketBase** self, int l } -EmulationCS* emulation_cs_construct (GType object_type, guint32* cs, guint len) { +EmulationCS* emulation_cs_construct (GType object_type, guint32* dwords, guint len) { EmulationCS * self; + guint pkt_count; gint _tmp0__size; gint _tmp0__length1; - guint32* _tmp0_; - guint32* _tmp4_; - guint32* _tmp3_; - guint pkt_count; - gint _tmp5__size; - gint _tmp5__length1; - EmulationPacketBase** _tmp5_; - EmulationPacketBase** _tmp9_; - EmulationPacketBase** _tmp8_; + EmulationPacket** _tmp0_; + EmulationPacket** _tmp4_; + EmulationPacket** _tmp3_; self = (EmulationCS*) g_object_new (object_type, NULL); if (len > 0) { - g_assert (cs != NULL); + g_assert (dwords != NULL); } + pkt_count = emulation_cs_check (dwords, len); _tmp0_ = (_tmp0__length1 = 0, NULL); - if (len > 0) { - guint32* _tmp1_; - _tmp0_ = (_tmp1_ = g_new0 (guint32, len), _tmp0_ = (g_free (_tmp0_), NULL), _tmp0__length1 = len, _tmp0__size = _tmp0__length1, _tmp1_); - } else { - guint32* _tmp2_; - _tmp0_ = (_tmp2_ = NULL, _tmp0_ = (g_free (_tmp0_), NULL), _tmp0__length1 = 0, _tmp0__size = _tmp0__length1, _tmp2_); - } - self->dwords = (_tmp4_ = (_tmp3_ = _tmp0_, (_tmp3_ == NULL) ? ((gpointer) _tmp3_) : _vala_array_dup1 (_tmp3_, _tmp0__length1)), self->dwords = (g_free (self->dwords), NULL), self->dwords_length1 = _tmp0__length1, _tmp4_); - if (len > 0) { - memcpy (self->dwords, cs, (gsize) (len * sizeof (guint32))); - } - pkt_count = emulation_cs_check (cs, len); - _tmp5_ = (_tmp5__length1 = 0, NULL); if (pkt_count > 0) { - EmulationPacketBase** _tmp6_; - _tmp5_ = (_tmp6_ = g_new0 (EmulationPacketBase*, pkt_count + 1), _tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) g_object_unref), NULL), _tmp5__length1 = pkt_count, _tmp5__size = _tmp5__length1, _tmp6_); + EmulationPacket** _tmp1_; + _tmp0_ = (_tmp1_ = g_new0 (EmulationPacket*, pkt_count + 1), _tmp0_ = (_vala_array_free (_tmp0_, _tmp0__length1, (GDestroyNotify) g_object_unref), NULL), _tmp0__length1 = pkt_count, _tmp0__size = _tmp0__length1, _tmp1_); } else { - EmulationPacketBase** _tmp7_; - _tmp5_ = (_tmp7_ = NULL, _tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) g_object_unref), NULL), _tmp5__length1 = 0, _tmp5__size = _tmp5__length1, _tmp7_); + EmulationPacket** _tmp2_; + _tmp0_ = (_tmp2_ = NULL, _tmp0_ = (_vala_array_free (_tmp0_, _tmp0__length1, (GDestroyNotify) g_object_unref), NULL), _tmp0__length1 = 0, _tmp0__size = _tmp0__length1, _tmp2_); } - self->packets = (_tmp9_ = (_tmp8_ = _tmp5_, (_tmp8_ == NULL) ? ((gpointer) _tmp8_) : _vala_array_dup2 (_tmp8_, _tmp5__length1)), self->packets = (_vala_array_free (self->packets, self->packets_length1, (GDestroyNotify) g_object_unref), NULL), self->packets_length1 = _tmp5__length1, _tmp9_); + self->priv->packets = (_tmp4_ = (_tmp3_ = _tmp0_, (_tmp3_ == NULL) ? ((gpointer) _tmp3_) : _vala_array_dup1 (_tmp3_, _tmp0__length1)), self->priv->packets = (_vala_array_free (self->priv->packets, self->priv->packets_length1, (GDestroyNotify) g_object_unref), NULL), self->priv->packets_length1 = _tmp0__length1, self->priv->packets_size = self->priv->packets_length1, _tmp4_); if (pkt_count > 0) { - guint pkt; - pkt = (guint) 0; { guint i; + guint pkt; i = (guint) 0; + pkt = (guint) 0; { - gboolean _tmp10_; - _tmp10_ = TRUE; + gboolean _tmp5_; + _tmp5_ = TRUE; while (TRUE) { - guint32* _tmp11_ = NULL; - EmulationPacketBase* _tmp12_; - if (!_tmp10_) { + EmulationPacket* _tmp6_; + if (!_tmp5_) { i++; } - _tmp10_ = FALSE; + _tmp5_ = FALSE; if (!(i < len)) { break; } - if (i < (len - 1)) { - _tmp11_ = &self->dwords[i + 1]; - } else { - _tmp11_ = NULL; - } - self->packets[pkt] = (_tmp12_ = emulation_make_packet (self->dwords[i], _tmp11_), _g_object_unref0 (self->packets[pkt]), _tmp12_); - i = i + emulation_packet_base_get_length (self->packets[pkt++]); + self->priv->packets[pkt] = (_tmp6_ = emulation_packet_make (dwords[i], (dwords + i) + 1), _g_object_unref0 (self->priv->packets[pkt]), _tmp6_); + i = i + emulation_packet_get_length (self->priv->packets[pkt++]); } } } } - _tmp0_ = (g_free (_tmp0_), NULL); - _tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) g_object_unref), NULL); + _tmp0_ = (_vala_array_free (_tmp0_, _tmp0__length1, (GDestroyNotify) g_object_unref), NULL); return self; } -EmulationCS* emulation_cs_new (guint32* cs, guint len) { - return emulation_cs_construct (EMULATION_TYPE_CS, cs, len); +EmulationCS* emulation_cs_new (guint32* dwords, guint len) { + return emulation_cs_construct (EMULATION_TYPE_CS, dwords, len); +} + + +GType emulation_cs_get_element_type (EmulationCS* self) { + GType result; + g_return_val_if_fail (self != NULL, 0UL); + result = EMULATION_TYPE_PACKET; + return result; +} + + +guint emulation_cs_get_length (EmulationCS* self) { + guint result; + gint _tmp0_ = 0; + g_return_val_if_fail (self != NULL, 0U); + if (self->priv->packets != NULL) { + _tmp0_ = self->priv->packets_length1; + } else { + _tmp0_ = 0; + } + result = (guint) _tmp0_; + return result; +} + + +EmulationCSIterator* emulation_cs_iterator_construct (GType object_type, EmulationCS* cs) { + EmulationCSIterator* self; + g_return_val_if_fail (cs != NULL, NULL); + self = (EmulationCSIterator*) g_type_create_instance (object_type); + self->priv->cs = cs; + self->priv->pos = (guint) 0; + return self; +} + + +EmulationCSIterator* emulation_cs_iterator_new (EmulationCS* cs) { + return emulation_cs_iterator_construct (EMULATION_CS_TYPE_ITERATOR, cs); +} + + +gboolean emulation_cs_iterator_next (EmulationCSIterator* self) { + gboolean result; + g_return_val_if_fail (self != NULL, FALSE); + result = (self->priv->pos++) < emulation_cs_get_length (self->priv->cs); + return result; +} + + +EmulationPacket* emulation_cs_iterator_get (EmulationCSIterator* self) { + EmulationPacket* result; + g_return_val_if_fail (self != NULL, NULL); + result = emulation_cs_get (self->priv->cs, self->priv->pos - 1); + return result; +} + + +static void emulation_cs_value_iterator_init (GValue* value) { + value->data[0].v_pointer = NULL; +} + + +static void emulation_cs_value_iterator_free_value (GValue* value) { + if (value->data[0].v_pointer) { + emulation_cs_iterator_unref (value->data[0].v_pointer); + } +} + + +static void emulation_cs_value_iterator_copy_value (const GValue* src_value, GValue* dest_value) { + if (src_value->data[0].v_pointer) { + dest_value->data[0].v_pointer = emulation_cs_iterator_ref (src_value->data[0].v_pointer); + } else { + dest_value->data[0].v_pointer = NULL; + } +} + + +static gpointer emulation_cs_value_iterator_peek_pointer (const GValue* value) { + return value->data[0].v_pointer; +} + + +static gchar* emulation_cs_value_iterator_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) { + if (collect_values[0].v_pointer) { + EmulationCSIterator* 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_cs_iterator_ref (object); + } else { + value->data[0].v_pointer = NULL; + } + return NULL; +} + + +static gchar* emulation_cs_value_iterator_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) { + EmulationCSIterator** 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_cs_iterator_ref (value->data[0].v_pointer); + } + return NULL; +} + + +GParamSpec* emulation_cs_param_spec_iterator (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) { + EmulationCSParamSpecIterator* spec; + g_return_val_if_fail (g_type_is_a (object_type, EMULATION_CS_TYPE_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_cs_value_get_iterator (const GValue* value) { + g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EMULATION_CS_TYPE_ITERATOR), NULL); + return value->data[0].v_pointer; +} + + +void emulation_cs_value_set_iterator (GValue* value, gpointer v_object) { + EmulationCSIterator* old; + g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EMULATION_CS_TYPE_ITERATOR)); + old = value->data[0].v_pointer; + if (v_object) { + g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, EMULATION_CS_TYPE_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_cs_iterator_ref (value->data[0].v_pointer); + } else { + value->data[0].v_pointer = NULL; + } + if (old) { + emulation_cs_iterator_unref (old); + } +} + + +static void emulation_cs_iterator_class_init (EmulationCSIteratorClass * klass) { + emulation_cs_iterator_parent_class = g_type_class_peek_parent (klass); + EMULATION_CS_ITERATOR_CLASS (klass)->finalize = emulation_cs_iterator_finalize; + g_type_class_add_private (klass, sizeof (EmulationCSIteratorPrivate)); +} + + +static void emulation_cs_iterator_instance_init (EmulationCSIterator * self) { + self->priv = EMULATION_CS_ITERATOR_GET_PRIVATE (self); + self->ref_count = 1; +} + + +static void emulation_cs_iterator_finalize (EmulationCSIterator* obj) { + EmulationCSIterator * self; + self = EMULATION_CS_ITERATOR (obj); +} + + +GType emulation_cs_iterator_get_type (void) { + static GType emulation_cs_iterator_type_id = 0; + if (emulation_cs_iterator_type_id == 0) { + static const GTypeValueTable g_define_type_value_table = { emulation_cs_value_iterator_init, emulation_cs_value_iterator_free_value, emulation_cs_value_iterator_copy_value, emulation_cs_value_iterator_peek_pointer, "p", emulation_cs_value_iterator_collect_value, "p", emulation_cs_value_iterator_lcopy_value }; + static const GTypeInfo g_define_type_info = { sizeof (EmulationCSIteratorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emulation_cs_iterator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmulationCSIterator), 0, (GInstanceInitFunc) emulation_cs_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_cs_iterator_type_id = g_type_register_fundamental (g_type_fundamental_next (), "EmulationCSIterator", &g_define_type_info, &g_define_type_fundamental_info, 0); + } + return emulation_cs_iterator_type_id; +} + + +gpointer emulation_cs_iterator_ref (gpointer instance) { + EmulationCSIterator* self; + self = instance; + g_atomic_int_inc (&self->ref_count); + return instance; +} + + +void emulation_cs_iterator_unref (gpointer instance) { + EmulationCSIterator* self; + self = instance; + if (g_atomic_int_dec_and_test (&self->ref_count)) { + EMULATION_CS_ITERATOR_GET_CLASS (self)->finalize (self); + g_type_free_instance ((GTypeInstance *) self); + } } static void emulation_cs_class_init (EmulationCSClass * klass) { emulation_cs_parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (EmulationCSPrivate)); + G_OBJECT_CLASS (klass)->get_property = emulation_cs_get_property; G_OBJECT_CLASS (klass)->finalize = emulation_cs_finalize; + g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_CS_ELEMENT_TYPE, g_param_spec_gtype ("element-type", "element-type", "element-type", G_TYPE_NONE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), EMULATION_CS_LENGTH, g_param_spec_uint ("length", "length", "length", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); } static void emulation_cs_instance_init (EmulationCS * self) { + self->priv = EMULATION_CS_GET_PRIVATE (self); } static void emulation_cs_finalize (GObject* obj) { EmulationCS * self; self = EMULATION_CS (obj); - self->packets = (_vala_array_free (self->packets, self->packets_length1, (GDestroyNotify) g_object_unref), NULL); - self->dwords = (g_free (self->dwords), NULL); + self->priv->packets = (_vala_array_free (self->priv->packets, self->priv->packets_length1, (GDestroyNotify) g_object_unref), NULL); G_OBJECT_CLASS (emulation_cs_parent_class)->finalize (obj); } @@ -1146,6 +1525,23 @@ GType emulation_cs_get_type (void) { } +static void emulation_cs_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { + EmulationCS * self; + self = EMULATION_CS (object); + switch (property_id) { + case EMULATION_CS_ELEMENT_TYPE: + g_value_set_gtype (value, emulation_cs_get_element_type (self)); + break; + case EMULATION_CS_LENGTH: + g_value_set_uint (value, emulation_cs_get_length (self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) { if ((array != NULL) && (destroy_func != NULL)) { int i; |