From 59bc73420093f4d6e220b2a429b995417c051bdc Mon Sep 17 00:00:00 2001 From: Joakim Sindholt Date: Fri, 9 Apr 2010 03:51:13 +0200 Subject: registers: attempt to not leak memory So far it seems ineffective. I have confirmed every object gets destroyed, but it doesn't change the memory statistics at all --- src/csexport.c | 71 ++++++------ src/csimport.c | 36 +++--- src/csview.c | 24 ++-- src/main.c | 108 +++++++++--------- src/main.vala | 4 +- src/registers.c | 323 ++++++++++++++++++++++++++++++++++++++++++----------- src/registers.vala | 32 +++--- 7 files changed, 395 insertions(+), 203 deletions(-) diff --git a/src/csexport.c b/src/csexport.c index 986b7d4..43e6e0b 100644 --- a/src/csexport.c +++ b/src/csexport.c @@ -170,6 +170,7 @@ typedef struct _EmulationRegisterIteratorClass EmulationRegisterIteratorClass; typedef struct _EmulationRegister EmulationRegister; typedef struct _EmulationRegisterClass EmulationRegisterClass; +#define _emulation_register_iterator_unref0(var) ((var == NULL) ? NULL : (var = (emulation_register_iterator_unref (var), NULL))) #define EMULATION_TYPE_REGISTER_INFO (emulation_register_info_get_type ()) #define EMULATION_REGISTER_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMULATION_TYPE_REGISTER_INFO, EmulationRegisterInfo)) @@ -249,8 +250,8 @@ enum { GUI_CS_EXPORT_DUMMY_PROPERTY }; GType gui_main_window_get_type (void); -static void _lambda9_ (GtkToggleButton* source, GUICSExport* self); -static void __lambda9__gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self); +static void _lambda10_ (GtkToggleButton* source, GUICSExport* self); +static void __lambda10__gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self); GType emulation_spec_entry_get_type (void); GType emulation_spec_get_type (void); EmulationSpecEntry* emulation_spec_entry_dup (const EmulationSpecEntry* self); @@ -298,6 +299,11 @@ EmulationRegisterList* emulation_spec_translate_addr (EmulationSpec* self, guint guint emulation_cs_get_length (EmulationCS* self); guint32 emulation_packet_get (EmulationPacket* self, guint index); guint emulation_register_list_get_length (EmulationRegisterList* self); +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); EmulationRegisterIterator* emulation_register_list_iterator (EmulationRegisterList* self); gboolean emulation_register_iterator_next (EmulationRegisterIterator* self); @@ -340,14 +346,14 @@ static gpointer _g_object_ref0 (gpointer self) { } -static void _lambda9_ (GtkToggleButton* source, GUICSExport* self) { +static void _lambda10_ (GtkToggleButton* source, GUICSExport* self) { g_return_if_fail (source != NULL); gtk_widget_set_sensitive ((GtkWidget*) self->priv->info_frame, gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->tree_radio)); } -static void __lambda9__gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) { - _lambda9_ (_sender, self); +static void __lambda10__gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) { + _lambda10_ (_sender, self); } @@ -438,7 +444,7 @@ GUICSExport* gui_cs_export_construct (GType object_type, EmulationCS* cs) { self->priv->check_pkt3_opcode = (_tmp20_ = _g_object_ref0 ((_tmp19_ = gtk_builder_get_object (builder, "check_pkt3_opcode"), GTK_IS_CHECK_BUTTON (_tmp19_) ? ((GtkCheckButton*) _tmp19_) : NULL)), _g_object_unref0 (self->priv->check_pkt3_opcode), _tmp20_); self->priv->check_pkt3_opcode_text = (_tmp22_ = _g_object_ref0 ((_tmp21_ = gtk_builder_get_object (builder, "check_pkt3_opcode_text"), GTK_IS_CHECK_BUTTON (_tmp21_) ? ((GtkCheckButton*) _tmp21_) : NULL)), _g_object_unref0 (self->priv->check_pkt3_opcode_text), _tmp22_); self->priv->check_pkt3_count = (_tmp24_ = _g_object_ref0 ((_tmp23_ = gtk_builder_get_object (builder, "check_pkt3_count"), GTK_IS_CHECK_BUTTON (_tmp23_) ? ((GtkCheckButton*) _tmp23_) : NULL)), _g_object_unref0 (self->priv->check_pkt3_count), _tmp24_); - g_signal_connect_object ((GtkToggleButton*) self->priv->plain_radio, "toggled", (GCallback) __lambda9__gtk_toggle_button_toggled, self, 0); + g_signal_connect_object ((GtkToggleButton*) self->priv->plain_radio, "toggled", (GCallback) __lambda10__gtk_toggle_button_toggled, self, 0); chip_combo_align = _g_object_ref0 ((_tmp25_ = gtk_builder_get_object (builder, "chip_combo_align"), GTK_IS_ALIGNMENT (_tmp25_) ? ((GtkAlignment*) _tmp25_) : NULL)); gtk_container_add ((GtkContainer*) chip_combo_align, (GtkWidget*) (self->priv->chip_combo = (_tmp26_ = g_object_ref_sink ((GtkComboBox*) gtk_combo_box_new_text ()), _g_object_unref0 (self->priv->chip_combo), _tmp26_))); { @@ -664,12 +670,12 @@ static void gui_cs_export_export_tree (GUICSExport* self, FILE* fs) { guint32 addr; EmulationRegisterList* _tmp5_; EmulationRegisterList* list; - gchar _tmp8_ = '\0'; + gchar _tmp6_ = '\0'; gchar nextpkg; + gchar _tmp7_ = '\0'; + gboolean _tmp8_ = FALSE; gchar _tmp9_ = '\0'; - gboolean _tmp10_ = FALSE; - gchar _tmp11_ = '\0'; - gchar _tmp12_ = '\0'; + gchar _tmp10_ = '\0'; gchar nextdw; if (!_tmp4_) { i++; @@ -681,46 +687,44 @@ static void gui_cs_export_export_tree (GUICSExport* self, FILE* fs) { addr = emulation_packet_target_addr (p, i); _tmp5_ = NULL; if (addr != 0) { - EmulationRegisterList* _tmp6_; - _tmp5_ = (_tmp6_ = emulation_spec_translate_addr (spec, (guint) addr), _g_object_unref0 (_tmp5_), _tmp6_); + _tmp5_ = emulation_spec_translate_addr (spec, (guint) addr); } else { - EmulationRegisterList* _tmp7_; - _tmp5_ = (_tmp7_ = NULL, _g_object_unref0 (_tmp5_), _tmp7_); + _tmp5_ = NULL; } list = _g_object_ref0 (_tmp5_); if (pkgn != (emulation_cs_get_length (self->priv->cs) - 1)) { - _tmp8_ = '|'; + _tmp6_ = '|'; } else { - _tmp8_ = ' '; + _tmp6_ = ' '; } - nextpkg = _tmp8_; + nextpkg = _tmp6_; if (list == NULL) { - _tmp10_ = i != (emulation_packet_get_length (p) - 1); + _tmp8_ = i != (emulation_packet_get_length (p) - 1); } else { - _tmp10_ = FALSE; + _tmp8_ = FALSE; } - if (_tmp10_) { - _tmp9_ = '|'; + if (_tmp8_) { + _tmp7_ = '|'; } else { - _tmp9_ = '+'; + _tmp7_ = '+'; } if (list == NULL) { - _tmp11_ = '-'; + _tmp9_ = '-'; } else { - _tmp11_ = '+'; + _tmp9_ = '+'; } - fprintf (fs, "%c %c-%c- 0x%08X", (gint) nextpkg, (gint) _tmp9_, (gint) _tmp11_, (guint) emulation_packet_get (p, i)); + fprintf (fs, "%c %c-%c- 0x%08X", (gint) nextpkg, (gint) _tmp7_, (gint) _tmp9_, (guint) emulation_packet_get (p, i)); if (addr != 0) { fprintf (fs, " -> 0x%04X\n", (guint) addr); } else { fprintf (fs, "\n"); } if (i != (emulation_packet_get_length (p) - 1)) { - _tmp12_ = '|'; + _tmp10_ = '|'; } else { - _tmp12_ = ' '; + _tmp10_ = ' '; } - nextdw = _tmp12_; + nextdw = _tmp10_; if (list != NULL) { guint length; guint j; @@ -731,24 +735,23 @@ static void gui_cs_export_export_tree (GUICSExport* self, FILE* fs) { _reg_it = emulation_register_list_iterator (list); while (TRUE) { EmulationRegister* reg; - gchar _tmp13_ = '\0'; + gchar _tmp11_ = '\0'; gchar nextreg; if (!emulation_register_iterator_next (_reg_it)) { break; } reg = emulation_register_iterator_get (_reg_it); if ((j++) != (length - 1)) { - _tmp13_ = '|'; + _tmp11_ = '|'; } else { - _tmp13_ = ' '; + _tmp11_ = ' '; } - nextreg = _tmp13_; + nextreg = _tmp11_; gui_cs_export_print_dest_reg (self, fs, nextpkg, nextdw, nextreg, reg, emulation_packet_get (p, i)); } - _g_object_unref0 (_reg_it); + _emulation_register_iterator_unref0 (_reg_it); } } - _g_object_unref0 (_tmp5_); _g_object_unref0 (list); } } diff --git a/src/csimport.c b/src/csimport.c index ae2f422..aff2663 100644 --- a/src/csimport.c +++ b/src/csimport.c @@ -114,19 +114,19 @@ enum { GUI_CS_IMPORT_DUMMY_PROPERTY }; GType gui_main_window_get_type (void); -static void _lambda19_ (GtkCellLayout* coll, GtkCellRenderer* celll, GtkTreeModel* model, GtkTreeIter* iter, GUICSImport* self); -static void __lambda19__gtk_cell_layout_data_func (GtkCellLayout* cell_layout, GtkCellRenderer* cell, GtkTreeModel* tree_model, GtkTreeIter* iter, gpointer self); +static void _lambda20_ (GtkCellLayout* coll, GtkCellRenderer* celll, GtkTreeModel* model, GtkTreeIter* iter, GUICSImport* self); +static void __lambda20__gtk_cell_layout_data_func (GtkCellLayout* cell_layout, GtkCellRenderer* cell, GtkTreeModel* tree_model, GtkTreeIter* iter, gpointer self); static void gui_cs_import_open_cs (GUICSImport* self, const char* filename); -static void _lambda20_ (GtkButton* source, GUICSImport* self); -static void __lambda20__gtk_button_clicked (GtkButton* _sender, gpointer self); +static void _lambda21_ (GtkButton* source, GUICSImport* self); +static void __lambda21__gtk_button_clicked (GtkButton* _sender, gpointer self); static void gui_cs_import_update_ok_button (GUICSImport* self); static void _gui_cs_import_update_ok_button_gtk_editable_changed (GtkEditable* _sender, gpointer self); GType emulation_cs_get_type (void); void gui_main_window_add_cs (GUIMainWindow* self, const char* name, EmulationCS* cs); EmulationCS* emulation_cs_new (guint32* dwords, guint len); EmulationCS* emulation_cs_construct (GType object_type, guint32* dwords, guint len); -static void _lambda21_ (GtkDialog* source, gint id, GUICSImport* self); -static void __lambda21__gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self); +static void _lambda22_ (GtkDialog* source, gint id, GUICSImport* self); +static void __lambda22__gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self); GUICSImport* gui_cs_import_new (void); GUICSImport* gui_cs_import_construct (GType object_type); GType emulation_packet_get_type (void); @@ -150,7 +150,7 @@ static gpointer _g_object_ref0 (gpointer self) { } -static void _lambda19_ (GtkCellLayout* coll, GtkCellRenderer* celll, GtkTreeModel* model, GtkTreeIter* iter, GUICSImport* self) { +static void _lambda20_ (GtkCellLayout* coll, GtkCellRenderer* celll, GtkTreeModel* model, GtkTreeIter* iter, GUICSImport* self) { GtkTreePath* path; gint* indices; char* _tmp0_; @@ -168,12 +168,12 @@ static void _lambda19_ (GtkCellLayout* coll, GtkCellRenderer* celll, GtkTreeMode } -static void __lambda19__gtk_cell_layout_data_func (GtkCellLayout* cell_layout, GtkCellRenderer* cell, GtkTreeModel* tree_model, GtkTreeIter* iter, gpointer self) { - _lambda19_ (cell_layout, cell, tree_model, iter, self); +static void __lambda20__gtk_cell_layout_data_func (GtkCellLayout* cell_layout, GtkCellRenderer* cell, GtkTreeModel* tree_model, GtkTreeIter* iter, gpointer self) { + _lambda20_ (cell_layout, cell, tree_model, iter, self); } -static void _lambda20_ (GtkButton* source, GUICSImport* self) { +static void _lambda21_ (GtkButton* source, GUICSImport* self) { GtkFileChooserDialog* fc; g_return_if_fail (source != NULL); fc = g_object_ref_sink ((GtkFileChooserDialog*) gtk_file_chooser_dialog_new ("Open File", (GtkWindow*) self, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL, NULL)); @@ -187,8 +187,8 @@ static void _lambda20_ (GtkButton* source, GUICSImport* self) { } -static void __lambda20__gtk_button_clicked (GtkButton* _sender, gpointer self) { - _lambda20_ (_sender, self); +static void __lambda21__gtk_button_clicked (GtkButton* _sender, gpointer self) { + _lambda21_ (_sender, self); } @@ -197,7 +197,7 @@ static void _gui_cs_import_update_ok_button_gtk_editable_changed (GtkEditable* _ } -static void _lambda21_ (GtkDialog* source, gint id, GUICSImport* self) { +static void _lambda22_ (GtkDialog* source, gint id, GUICSImport* self) { g_return_if_fail (source != NULL); if (id == GTK_RESPONSE_OK) { EmulationCS* _tmp0_; @@ -208,8 +208,8 @@ static void _lambda21_ (GtkDialog* source, gint id, GUICSImport* self) { } -static void __lambda21__gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self) { - _lambda21_ (_sender, response_id, self); +static void __lambda22__gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self) { + _lambda22_ (_sender, response_id, self); } @@ -268,13 +268,13 @@ GUICSImport* gui_cs_import_construct (GType object_type) { gtk_window_set_title ((GtkWindow*) self, "Import CS"); col = _g_object_ref0 ((_tmp0_ = gtk_builder_get_object (builder, "value_column"), GTK_IS_TREE_VIEW_COLUMN (_tmp0_) ? ((GtkTreeViewColumn*) _tmp0_) : NULL)); cell = _g_object_ref0 ((_tmp1_ = gtk_builder_get_object (builder, "value_cell"), GTK_IS_CELL_RENDERER_TEXT (_tmp1_) ? ((GtkCellRendererText*) _tmp1_) : NULL)); - gtk_cell_layout_set_cell_data_func ((GtkCellLayout*) col, (GtkCellRenderer*) cell, __lambda19__gtk_cell_layout_data_func, g_object_ref (self), g_object_unref); + gtk_cell_layout_set_cell_data_func ((GtkCellLayout*) col, (GtkCellRenderer*) cell, __lambda20__gtk_cell_layout_data_func, g_object_ref (self), g_object_unref); self->priv->meta_store = (_tmp3_ = _g_object_ref0 ((_tmp2_ = gtk_builder_get_object (builder, "meta_store"), GTK_IS_LIST_STORE (_tmp2_) ? ((GtkListStore*) _tmp2_) : NULL)), _g_object_unref0 (self->priv->meta_store), _tmp3_); gtk_dialog_add_button ((GtkDialog*) self, GTK_STOCK_CANCEL, (gint) GTK_RESPONSE_CANCEL); self->priv->ok_button = (_tmp5_ = _g_object_ref0 ((_tmp4_ = gtk_dialog_add_button ((GtkDialog*) self, GTK_STOCK_OK, (gint) GTK_RESPONSE_OK), GTK_IS_BUTTON (_tmp4_) ? ((GtkButton*) _tmp4_) : NULL)), _g_object_unref0 (self->priv->ok_button), _tmp5_); gtk_widget_set_sensitive ((GtkWidget*) self->priv->ok_button, FALSE); load_button = _g_object_ref0 ((_tmp6_ = gtk_builder_get_object (builder, "load_button"), GTK_IS_BUTTON (_tmp6_) ? ((GtkButton*) _tmp6_) : NULL)); - g_signal_connect_object (load_button, "clicked", (GCallback) __lambda20__gtk_button_clicked, self, 0); + g_signal_connect_object (load_button, "clicked", (GCallback) __lambda21__gtk_button_clicked, self, 0); self->priv->validcs = FALSE; self->priv->dwords = (_tmp7_ = g_array_new (FALSE, FALSE, (guint) sizeof (guint32)), _g_array_free0 (self->priv->dwords), _tmp7_); self->priv->name_entry = (_tmp9_ = _g_object_ref0 ((_tmp8_ = gtk_builder_get_object (builder, "name_entry"), GTK_IS_ENTRY (_tmp8_) ? ((GtkEntry*) _tmp8_) : NULL)), _g_object_unref0 (self->priv->name_entry), _tmp9_); @@ -286,7 +286,7 @@ GUICSImport* gui_cs_import_construct (GType object_type) { self->priv->status_label = (_tmp12_ = _g_object_ref0 ((_tmp11_ = gtk_builder_get_object (builder, "status_label"), GTK_IS_LABEL (_tmp11_) ? ((GtkLabel*) _tmp11_) : NULL)), _g_object_unref0 (self->priv->status_label), _tmp12_); gtk_widget_modify_fg ((GtkWidget*) self->priv->status_label, GTK_STATE_NORMAL, &color); gtk_box_pack_start ((GtkBox*) ((GtkDialog*) self)->vbox, (GtkWidget*) (_tmp13_ = gtk_builder_get_object (builder, "mainbox"), GTK_IS_VBOX (_tmp13_) ? ((GtkVBox*) _tmp13_) : NULL), TRUE, TRUE, (guint) 0); - g_signal_connect_object ((GtkDialog*) self, "response", (GCallback) __lambda21__gtk_dialog_response, self, 0); + g_signal_connect_object ((GtkDialog*) self, "response", (GCallback) __lambda22__gtk_dialog_response, self, 0); gtk_window_set_default_size ((GtkWindow*) self, 300, 400); _g_object_unref0 (builder); _g_object_unref0 (col); diff --git a/src/csview.c b/src/csview.c index 27a6709..9660801 100644 --- a/src/csview.c +++ b/src/csview.c @@ -414,8 +414,8 @@ EmulationSpecEntry* emulation_spec_entry_dup (const EmulationSpecEntry* self); void emulation_spec_entry_free (EmulationSpecEntry* self); void emulation_spec_entry_copy (const EmulationSpecEntry* self, EmulationSpecEntry* dest); void emulation_spec_entry_destroy (EmulationSpecEntry* self); -static void _lambda8_ (GtkComboBox* combo, GUICSView* self); -static void __lambda8__gtk_combo_box_changed (GtkComboBox* _sender, gpointer self); +static void _lambda9_ (GtkComboBox* combo, GUICSView* self); +static void __lambda9__gtk_combo_box_changed (GtkComboBox* _sender, gpointer self); GUICSView* gui_cs_view_new (EmulationCS* cs); GUICSView* gui_cs_view_construct (GType object_type, EmulationCS* cs); static void gui_cs_view_finalize (GObject* obj); @@ -552,7 +552,7 @@ static guint gui_cs_list_model_get_variant_count (GUICSListModel* self, guint32 EmulationRegisterList* regs; guint _tmp0_ = 0U; g_return_val_if_fail (self != NULL, 0U); - regs = emulation_spec_translate_addr (self->priv->m_spec, (guint) addr); + regs = _g_object_ref0 (emulation_spec_translate_addr (self->priv->m_spec, (guint) addr)); if (regs == NULL) { _tmp0_ = (guint) 0; } else { @@ -569,7 +569,7 @@ static guint gui_cs_list_model_get_bitfield_count (GUICSListModel* self, guint32 EmulationRegisterList* regs; guint _tmp0_ = 0U; g_return_val_if_fail (self != NULL, 0U); - regs = emulation_spec_translate_addr (self->priv->m_spec, (guint) addr); + regs = _g_object_ref0 (emulation_spec_translate_addr (self->priv->m_spec, (guint) addr)); g_assert (regs != NULL); g_assert (variant < emulation_register_list_get_length (regs)); if (emulation_register_info_get_length (emulation_register_get_info (emulation_register_list_get (regs, variant))) == 0) { @@ -760,7 +760,7 @@ static char* gui_cs_list_model_translate_addr (GUICSListModel* self, guint32 add result = g_strdup (""); return result; } - regs = emulation_spec_translate_addr (self->priv->m_spec, (guint) addr); + regs = _g_object_ref0 (emulation_spec_translate_addr (self->priv->m_spec, (guint) addr)); if (regs == NULL) { result = g_strdup_printf ("0x%04X", addr); _g_object_unref0 (regs); @@ -789,7 +789,7 @@ static const char* gui_cs_list_model_variant_name (GUICSListModel* self, guint32 const char* result; EmulationRegisterList* regs; g_return_val_if_fail (self != NULL, NULL); - regs = emulation_spec_translate_addr (self->priv->m_spec, (guint) addr); + regs = _g_object_ref0 (emulation_spec_translate_addr (self->priv->m_spec, (guint) addr)); g_assert (regs != NULL); g_assert (variant < emulation_register_list_get_length (regs)); result = emulation_register_info_get_name (emulation_register_get_info (emulation_register_list_get (regs, variant))); @@ -802,7 +802,7 @@ static const char* gui_cs_list_model_bitfield_name (GUICSListModel* self, guint3 const char* result; EmulationRegisterList* regs; g_return_val_if_fail (self != NULL, NULL); - regs = emulation_spec_translate_addr (self->priv->m_spec, (guint) addr); + regs = _g_object_ref0 (emulation_spec_translate_addr (self->priv->m_spec, (guint) addr)); g_assert (regs != NULL); g_assert (variant < emulation_register_list_get_length (regs)); if (emulation_register_info_get_length (emulation_register_get_info (emulation_register_list_get (regs, variant))) > 0) { @@ -823,7 +823,7 @@ static guint32 gui_cs_list_model_bitfield_value (GUICSListModel* self, guint32 a guint high; guint low; g_return_val_if_fail (self != NULL, 0U); - regs = emulation_spec_translate_addr (self->priv->m_spec, (guint) addr); + regs = _g_object_ref0 (emulation_spec_translate_addr (self->priv->m_spec, (guint) addr)); g_assert (regs != NULL); g_assert (variant < emulation_register_list_get_length (regs)); high = (guint) 31; @@ -2058,14 +2058,14 @@ static glong string_get_length (const char* self) { } -static void _lambda8_ (GtkComboBox* combo, GUICSView* self) { +static void _lambda9_ (GtkComboBox* combo, GUICSView* self) { g_return_if_fail (combo != NULL); gtk_tree_view_set_model (self->priv->cs_view, (GtkTreeModel*) self->priv->models[gtk_combo_box_get_active (combo)]); } -static void __lambda8__gtk_combo_box_changed (GtkComboBox* _sender, gpointer self) { - _lambda8_ (_sender, self); +static void __lambda9__gtk_combo_box_changed (GtkComboBox* _sender, gpointer self) { + _lambda9_ (_sender, self); } @@ -2146,7 +2146,7 @@ GUICSView* gui_cs_view_construct (GType object_type, EmulationCS* cs) { } } gtk_combo_box_set_active (chips, (gint) emulation_spec_default); - g_signal_connect_object (chips, "changed", (GCallback) __lambda8__gtk_combo_box_changed, self, 0); + g_signal_connect_object (chips, "changed", (GCallback) __lambda9__gtk_combo_box_changed, self, 0); chips_box = _g_object_ref0 ((_tmp3_ = gtk_builder_get_object (builder, "chips_box"), GTK_IS_HBOX (_tmp3_) ? ((GtkHBox*) _tmp3_) : NULL)); gtk_box_pack_start ((GtkBox*) chips_box, (GtkWidget*) chips, FALSE, FALSE, (guint) 0); self->priv->cs_view = (_tmp5_ = _g_object_ref0 ((_tmp4_ = gtk_builder_get_object (builder, "packet_tree"), GTK_IS_TREE_VIEW (_tmp4_) ? ((GtkTreeView*) _tmp4_) : NULL)), _g_object_unref0 (self->priv->cs_view), _tmp5_); diff --git a/src/main.c b/src/main.c index e5fa868..59afad0 100644 --- a/src/main.c +++ b/src/main.c @@ -123,10 +123,6 @@ struct _EmulationSpecEntry { }; -static char* gui_main_window_xml_ui; -static char* gui_main_window_xml_ui = NULL; -static char* gui_main_window_about_xml_ui; -static char* gui_main_window_about_xml_ui = NULL; static gpointer gui_main_window_parent_class = NULL; extern GUIMainWindow* gui_main; GUIMainWindow* gui_main = NULL; @@ -142,6 +138,8 @@ GType gui_main_window_get_type (void); enum { GUI_MAIN_WINDOW_DUMMY_PROPERTY }; +#define GUI_MAIN_WINDOW_xml_ui "\n \n \n \n \n \n \n \n \n \n New\n gtk-new\n \n \n \n \n Open\n gtk-open\n \n \n \n \n Save\n gtk-save\n \n \n \n \n SaveAs\n gtk-save-as\n \n \n \n \n Quit\n gtk-quit\n \n \n \n \n ViewCS\n _View CS\n View the selected command stream.\n gtk-open\n \n \n \n \n RemoveCS\n _Remove CS\n Remove the selected command stream from the current project.\n gtk-delete\n \n \n \n \n \n ImportCS\n _Import CS\n Import a new command stream to the current project.\n gtk-add\n \n \n \n \n \n ExportCS\n _Export CS\n Export the selected command stream to a file.\n gtk-convert\n \n \n \n \n \n About\n gtk-about\n \n \n \n \n \n FileMenu\n _File\n \n \n \n \n EditMenu\n _Edit\n \n \n \n \n HelpMenu\n _Help\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n True\n vertical\n \n \n True\n \n \n The menubar\n \n \n \n \n False\n \n \n \n \n True\n \n \n The toolbar\n \n \n \n \n False\n 1\n \n \n \n \n True\n True\n automatic\n automatic\n \n \n True\n True\n True\n cs_store\n \n \n Packets\n \n \n \n \n \n \n \n Name\n \n \n \n 0\n \n \n \n \n \n \n \n \n 2\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n The popup menu\n \n \n \n \n " +#define GUI_MAIN_WINDOW_about_xml_ui "\n \n \n \n \n \n 5\n normal\n True\n False\n Radeon Simulator\n Copyright © 2010 Joakim Sindholt\n A simulator for Radeon GPUs\n http://cgit.freedesktop.org/~jsindholt/rsim\n This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.\n Joakim Sindholt <opensource@zhasha.com>\n /usr/share/pixmaps/rsim.png\n True\n \n \n True\n vertical\n 2\n \n \n True\n end\n \n \n False\n end\n 0\n \n \n \n \n \n \n " static void gui_main_window_edit_set_sensitive (GUIMainWindow* self, gboolean setting); GType emulation_cs_get_type (void); static EmulationCS* gui_main_window_get_selected_cs (GUIMainWindow* self); @@ -158,27 +156,27 @@ static void gui_main_window_open_csexport (GUIMainWindow* self); GUIMainWindow* gui_main_window_new (void); GUIMainWindow* gui_main_window_construct (GType object_type); guint emulation_cs_get_length (EmulationCS* self); -static void _lambda10_ (GtkCellLayout* col, GtkCellRenderer* cell, GtkTreeModel* model, GtkTreeIter* iter, GUIMainWindow* self); -static void __lambda10__gtk_cell_layout_data_func (GtkCellLayout* cell_layout, GtkCellRenderer* cell, GtkTreeModel* tree_model, GtkTreeIter* iter, gpointer self); -static void _lambda11_ (GtkAction* source, GUIMainWindow* self); -static void __lambda11__gtk_action_activate (GtkAction* _sender, gpointer self); +static void _lambda11_ (GtkCellLayout* col, GtkCellRenderer* cell, GtkTreeModel* model, GtkTreeIter* iter, GUIMainWindow* self); +static void __lambda11__gtk_cell_layout_data_func (GtkCellLayout* cell_layout, GtkCellRenderer* cell, GtkTreeModel* tree_model, GtkTreeIter* iter, gpointer self); +static void _lambda12_ (GtkAction* source, GUIMainWindow* self); +static void __lambda12__gtk_action_activate (GtkAction* _sender, gpointer self); GUICSImport* gui_cs_import_new (void); GUICSImport* gui_cs_import_construct (GType object_type); GType gui_cs_import_get_type (void); -static void _lambda12_ (GtkAction* source, GUIMainWindow* self); -static void __lambda12__gtk_action_activate (GtkAction* _sender, gpointer self); static void _lambda13_ (GtkAction* source, GUIMainWindow* self); static void __lambda13__gtk_action_activate (GtkAction* _sender, gpointer self); static void _lambda14_ (GtkAction* source, GUIMainWindow* self); static void __lambda14__gtk_action_activate (GtkAction* _sender, gpointer self); static void _lambda15_ (GtkAction* source, GUIMainWindow* self); static void __lambda15__gtk_action_activate (GtkAction* _sender, gpointer self); -static void _lambda16_ (GtkTreePath* path, GtkTreeViewColumn* column, GUIMainWindow* self); -static void __lambda16__gtk_tree_view_row_activated (GtkTreeView* _sender, GtkTreePath* path, GtkTreeViewColumn* column, gpointer self); -static gboolean _lambda17_ (GdkEventButton* event, GUIMainWindow* self); -static gboolean __lambda17__gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self); -static void _lambda18_ (GtkTreeView* source, GUIMainWindow* self); -static void __lambda18__gtk_tree_view_cursor_changed (GtkTreeView* _sender, gpointer self); +static void _lambda16_ (GtkAction* source, GUIMainWindow* self); +static void __lambda16__gtk_action_activate (GtkAction* _sender, gpointer self); +static void _lambda17_ (GtkTreePath* path, GtkTreeViewColumn* column, GUIMainWindow* self); +static void __lambda17__gtk_tree_view_row_activated (GtkTreeView* _sender, GtkTreePath* path, GtkTreeViewColumn* column, gpointer self); +static gboolean _lambda18_ (GdkEventButton* event, GUIMainWindow* self); +static gboolean __lambda18__gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self); +static void _lambda19_ (GtkTreeView* source, GUIMainWindow* self); +static void __lambda19__gtk_tree_view_cursor_changed (GtkTreeView* _sender, gpointer self); static void _gtk_main_quit_gtk_object_destroy (GtkObject* _sender, gpointer self); static GObject * gui_main_window_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); static void gui_main_window_finalize (GObject* obj); @@ -302,7 +300,7 @@ static glong string_get_length (const char* self) { } -static void _lambda10_ (GtkCellLayout* col, GtkCellRenderer* cell, GtkTreeModel* model, GtkTreeIter* iter, GUIMainWindow* self) { +static void _lambda11_ (GtkCellLayout* col, GtkCellRenderer* cell, GtkTreeModel* model, GtkTreeIter* iter, GUIMainWindow* self) { EmulationCS* cs; char* _tmp0_; GtkCellRenderer* _tmp1_; @@ -318,23 +316,23 @@ static void _lambda10_ (GtkCellLayout* col, GtkCellRenderer* cell, GtkTreeModel* } -static void __lambda10__gtk_cell_layout_data_func (GtkCellLayout* cell_layout, GtkCellRenderer* cell, GtkTreeModel* tree_model, GtkTreeIter* iter, gpointer self) { - _lambda10_ (cell_layout, cell, tree_model, iter, self); +static void __lambda11__gtk_cell_layout_data_func (GtkCellLayout* cell_layout, GtkCellRenderer* cell, GtkTreeModel* tree_model, GtkTreeIter* iter, gpointer self) { + _lambda11_ (cell_layout, cell, tree_model, iter, self); } -static void _lambda11_ (GtkAction* source, GUIMainWindow* self) { +static void _lambda12_ (GtkAction* source, GUIMainWindow* self) { g_return_if_fail (source != NULL); gui_main_window_open_csview (self); } -static void __lambda11__gtk_action_activate (GtkAction* _sender, gpointer self) { - _lambda11_ (_sender, self); +static void __lambda12__gtk_action_activate (GtkAction* _sender, gpointer self) { + _lambda12_ (_sender, self); } -static void _lambda12_ (GtkAction* source, GUIMainWindow* self) { +static void _lambda13_ (GtkAction* source, GUIMainWindow* self) { GUICSImport* d; g_return_if_fail (source != NULL); d = g_object_ref_sink (gui_cs_import_new ()); @@ -343,34 +341,34 @@ static void _lambda12_ (GtkAction* source, GUIMainWindow* self) { } -static void __lambda12__gtk_action_activate (GtkAction* _sender, gpointer self) { - _lambda12_ (_sender, self); +static void __lambda13__gtk_action_activate (GtkAction* _sender, gpointer self) { + _lambda13_ (_sender, self); } -static void _lambda13_ (GtkAction* source, GUIMainWindow* self) { +static void _lambda14_ (GtkAction* source, GUIMainWindow* self) { g_return_if_fail (source != NULL); gui_main_window_open_csexport (self); } -static void __lambda13__gtk_action_activate (GtkAction* _sender, gpointer self) { - _lambda13_ (_sender, self); +static void __lambda14__gtk_action_activate (GtkAction* _sender, gpointer self) { + _lambda14_ (_sender, self); } -static void _lambda14_ (GtkAction* source, GUIMainWindow* self) { +static void _lambda15_ (GtkAction* source, GUIMainWindow* self) { g_return_if_fail (source != NULL); gui_main_window_remove_cs (self); } -static void __lambda14__gtk_action_activate (GtkAction* _sender, gpointer self) { - _lambda14_ (_sender, self); +static void __lambda15__gtk_action_activate (GtkAction* _sender, gpointer self) { + _lambda15_ (_sender, self); } -static void _lambda15_ (GtkAction* source, GUIMainWindow* self) { +static void _lambda16_ (GtkAction* source, GUIMainWindow* self) { GError * _inner_error_; GtkBuilder* about; g_return_if_fail (source != NULL); @@ -379,7 +377,7 @@ static void _lambda15_ (GtkAction* source, GUIMainWindow* self) { { GObject* _tmp0_; GtkAboutDialog* dlg; - gtk_builder_add_from_string (about, gui_main_window_about_xml_ui, (gsize) string_get_length (gui_main_window_about_xml_ui), &_inner_error_); + gtk_builder_add_from_string (about, GUI_MAIN_WINDOW_about_xml_ui, (gsize) string_get_length (GUI_MAIN_WINDOW_about_xml_ui), &_inner_error_); if (_inner_error_ != NULL) { goto __catch4_g_error; } @@ -409,24 +407,24 @@ static void _lambda15_ (GtkAction* source, GUIMainWindow* self) { } -static void __lambda15__gtk_action_activate (GtkAction* _sender, gpointer self) { - _lambda15_ (_sender, self); +static void __lambda16__gtk_action_activate (GtkAction* _sender, gpointer self) { + _lambda16_ (_sender, self); } -static void _lambda16_ (GtkTreePath* path, GtkTreeViewColumn* column, GUIMainWindow* self) { +static void _lambda17_ (GtkTreePath* path, GtkTreeViewColumn* column, GUIMainWindow* self) { g_return_if_fail (path != NULL); g_return_if_fail (column != NULL); gui_main_window_open_csview (self); } -static void __lambda16__gtk_tree_view_row_activated (GtkTreeView* _sender, GtkTreePath* path, GtkTreeViewColumn* column, gpointer self) { - _lambda16_ (path, column, self); +static void __lambda17__gtk_tree_view_row_activated (GtkTreeView* _sender, GtkTreePath* path, GtkTreeViewColumn* column, gpointer self) { + _lambda17_ (path, column, self); } -static gboolean _lambda17_ (GdkEventButton* event, GUIMainWindow* self) { +static gboolean _lambda18_ (GdkEventButton* event, GUIMainWindow* self) { gboolean result; EmulationCS* cs; gboolean _tmp0_ = FALSE; @@ -449,19 +447,19 @@ static gboolean _lambda17_ (GdkEventButton* event, GUIMainWindow* self) { } -static gboolean __lambda17__gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self) { - return _lambda17_ (event, self); +static gboolean __lambda18__gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self) { + return _lambda18_ (event, self); } -static void _lambda18_ (GtkTreeView* source, GUIMainWindow* self) { +static void _lambda19_ (GtkTreeView* source, GUIMainWindow* self) { g_return_if_fail (source != NULL); gui_main_window_edit_set_sensitive (self, gtk_tree_selection_get_selected (gtk_tree_view_get_selection (self->priv->cs_list), NULL, NULL)); } -static void __lambda18__gtk_tree_view_cursor_changed (GtkTreeView* _sender, gpointer self) { - _lambda18_ (_sender, self); +static void __lambda19__gtk_tree_view_cursor_changed (GtkTreeView* _sender, gpointer self) { + _lambda19_ (_sender, self); } @@ -503,7 +501,7 @@ static GObject * gui_main_window_constructor (GType type, guint n_construct_prop GObject* _tmp16_; builder = gtk_builder_new (); { - gtk_builder_add_from_string (builder, gui_main_window_xml_ui, (gsize) string_get_length (gui_main_window_xml_ui), &_inner_error_); + gtk_builder_add_from_string (builder, GUI_MAIN_WINDOW_xml_ui, (gsize) string_get_length (GUI_MAIN_WINDOW_xml_ui), &_inner_error_); if (_inner_error_ != NULL) { goto __catch3_g_error; } @@ -530,22 +528,22 @@ static GObject * gui_main_window_constructor (GType type, guint n_construct_prop gtk_window_set_title ((GtkWindow*) self, "Radeon Simulator"); col = _g_object_ref0 ((_tmp0_ = gtk_builder_get_object (builder, "pkts_column"), GTK_IS_TREE_VIEW_COLUMN (_tmp0_) ? ((GtkTreeViewColumn*) _tmp0_) : NULL)); cell = _g_object_ref0 ((_tmp1_ = gtk_builder_get_object (builder, "pkts_cell"), GTK_IS_CELL_RENDERER_TEXT (_tmp1_) ? ((GtkCellRendererText*) _tmp1_) : NULL)); - gtk_cell_layout_set_cell_data_func ((GtkCellLayout*) col, (GtkCellRenderer*) cell, __lambda10__gtk_cell_layout_data_func, g_object_ref (self), g_object_unref); + gtk_cell_layout_set_cell_data_func ((GtkCellLayout*) col, (GtkCellRenderer*) cell, __lambda11__gtk_cell_layout_data_func, g_object_ref (self), g_object_unref); self->priv->action_viewcs = (_tmp3_ = _g_object_ref0 ((_tmp2_ = gtk_builder_get_object (builder, "ViewCS"), GTK_IS_ACTION (_tmp2_) ? ((GtkAction*) _tmp2_) : NULL)), _g_object_unref0 (self->priv->action_viewcs), _tmp3_); self->priv->action_exportcs = (_tmp5_ = _g_object_ref0 ((_tmp4_ = gtk_builder_get_object (builder, "ExportCS"), GTK_IS_ACTION (_tmp4_) ? ((GtkAction*) _tmp4_) : NULL)), _g_object_unref0 (self->priv->action_exportcs), _tmp5_); self->priv->action_removecs = (_tmp7_ = _g_object_ref0 ((_tmp6_ = gtk_builder_get_object (builder, "RemoveCS"), GTK_IS_ACTION (_tmp6_) ? ((GtkAction*) _tmp6_) : NULL)), _g_object_unref0 (self->priv->action_removecs), _tmp7_); action_importcs = _g_object_ref0 ((_tmp8_ = gtk_builder_get_object (builder, "ImportCS"), GTK_IS_ACTION (_tmp8_) ? ((GtkAction*) _tmp8_) : NULL)); - g_signal_connect_object (self->priv->action_viewcs, "activate", (GCallback) __lambda11__gtk_action_activate, self, 0); - g_signal_connect_object (action_importcs, "activate", (GCallback) __lambda12__gtk_action_activate, self, 0); - g_signal_connect_object (self->priv->action_exportcs, "activate", (GCallback) __lambda13__gtk_action_activate, self, 0); - g_signal_connect_object (self->priv->action_removecs, "activate", (GCallback) __lambda14__gtk_action_activate, self, 0); - g_signal_connect_object ((_tmp9_ = gtk_builder_get_object (builder, "About"), GTK_IS_ACTION (_tmp9_) ? ((GtkAction*) _tmp9_) : NULL), "activate", (GCallback) __lambda15__gtk_action_activate, self, 0); + g_signal_connect_object (self->priv->action_viewcs, "activate", (GCallback) __lambda12__gtk_action_activate, self, 0); + g_signal_connect_object (action_importcs, "activate", (GCallback) __lambda13__gtk_action_activate, self, 0); + g_signal_connect_object (self->priv->action_exportcs, "activate", (GCallback) __lambda14__gtk_action_activate, self, 0); + g_signal_connect_object (self->priv->action_removecs, "activate", (GCallback) __lambda15__gtk_action_activate, self, 0); + g_signal_connect_object ((_tmp9_ = gtk_builder_get_object (builder, "About"), GTK_IS_ACTION (_tmp9_) ? ((GtkAction*) _tmp9_) : NULL), "activate", (GCallback) __lambda16__gtk_action_activate, self, 0); self->priv->cs_store = (_tmp11_ = _g_object_ref0 ((_tmp10_ = gtk_builder_get_object (builder, "cs_store"), GTK_IS_LIST_STORE (_tmp10_) ? ((GtkListStore*) _tmp10_) : NULL)), _g_object_unref0 (self->priv->cs_store), _tmp11_); self->priv->cs_list = (_tmp13_ = _g_object_ref0 ((_tmp12_ = gtk_builder_get_object (builder, "cs_list"), GTK_IS_TREE_VIEW (_tmp12_) ? ((GtkTreeView*) _tmp12_) : NULL)), _g_object_unref0 (self->priv->cs_list), _tmp13_); self->priv->edit_menu = (_tmp15_ = _g_object_ref0 ((_tmp14_ = gtk_builder_get_object (builder, "popup1"), GTK_IS_MENU (_tmp14_) ? ((GtkMenu*) _tmp14_) : NULL)), _g_object_unref0 (self->priv->edit_menu), _tmp15_); - g_signal_connect_object (self->priv->cs_list, "row-activated", (GCallback) __lambda16__gtk_tree_view_row_activated, self, 0); - g_signal_connect_object ((GtkWidget*) self->priv->cs_list, "button-press-event", (GCallback) __lambda17__gtk_widget_button_press_event, self, 0); - g_signal_connect_object (self->priv->cs_list, "cursor-changed", (GCallback) __lambda18__gtk_tree_view_cursor_changed, self, 0); + g_signal_connect_object (self->priv->cs_list, "row-activated", (GCallback) __lambda17__gtk_tree_view_row_activated, self, 0); + g_signal_connect_object ((GtkWidget*) self->priv->cs_list, "button-press-event", (GCallback) __lambda18__gtk_widget_button_press_event, self, 0); + g_signal_connect_object (self->priv->cs_list, "cursor-changed", (GCallback) __lambda19__gtk_tree_view_cursor_changed, self, 0); gui_main_window_edit_set_sensitive (self, FALSE); gtk_container_add ((GtkContainer*) self, (_tmp16_ = gtk_builder_get_object (builder, "mainbox"), GTK_IS_WIDGET (_tmp16_) ? ((GtkWidget*) _tmp16_) : NULL)); g_signal_connect ((GtkObject*) self, "destroy", (GCallback) _gtk_main_quit_gtk_object_destroy, NULL); @@ -588,8 +586,6 @@ static void gui_main_window_class_init (GUIMainWindowClass * klass) { g_type_class_add_private (klass, sizeof (GUIMainWindowPrivate)); G_OBJECT_CLASS (klass)->constructor = gui_main_window_constructor; G_OBJECT_CLASS (klass)->finalize = gui_main_window_finalize; - gui_main_window_xml_ui = g_strdup ("\n \n \n \n \n \n \n \n \n \n New\n gtk-new\n \n \n \n \n Open\n gtk-open\n \n \n \n \n Save\n gtk-save\n \n \n \n \n SaveAs\n gtk-save-as\n \n \n \n \n Quit\n gtk-quit\n \n \n \n \n ViewCS\n _View CS\n View the selected command stream.\n gtk-open\n \n \n \n \n RemoveCS\n _Remove CS\n Remove the selected command stream from the current project.\n gtk-delete\n \n \n \n \n \n ImportCS\n _Import CS\n Import a new command stream to the current project.\n gtk-add\n \n \n \n \n \n ExportCS\n _Export CS\n Export the selected command stream to a file.\n gtk-convert\n \n \n \n \n \n About\n gtk-about\n \n \n \n \n \n FileMenu\n _File\n \n \n \n \n EditMenu\n _Edit\n \n \n \n \n HelpMenu\n _Help\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n True\n vertical\n \n \n True\n \n \n The menubar\n \n \n \n \n False\n \n \n \n \n True\n \n \n The toolbar\n \n \n \n \n False\n 1\n \n \n \n \n True\n True\n automatic\n automatic\n \n \n True\n True\n True\n cs_store\n \n \n Packets\n \n \n \n \n \n \n \n Name\n \n \n \n 0\n \n \n \n \n \n \n \n \n 2\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n The popup menu\n \n \n \n \n "); - gui_main_window_about_xml_ui = g_strdup ("\n \n \n \n \n \n 5\n normal\n True\n False\n Radeon Simulator\n Copyright © 2010 Joakim Sindholt\n A simulator for Radeon GPUs\n http://cgit.freedesktop.org/~jsindholt/rsim\n This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.\n Joakim Sindholt <opensource@zhasha.com>\n /usr/share/pixmaps/rsim.png\n True\n \n \n True\n vertical\n 2\n \n \n True\n end\n \n \n False\n end\n 0\n \n \n \n \n \n \n "); } diff --git a/src/main.vala b/src/main.vala index 35bf7af..55b42db 100644 --- a/src/main.vala +++ b/src/main.vala @@ -27,7 +27,7 @@ namespace GUI { public class MainWindow : Window { - private static string xml_ui = """ + private static const string xml_ui = """ @@ -253,7 +253,7 @@ namespace GUI """; - private static string about_xml_ui = """ + private static const string about_xml_ui = """ 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; } diff --git a/src/registers.vala b/src/registers.vala index 03a9af5..85a71cd 100644 --- a/src/registers.vala +++ b/src/registers.vala @@ -27,14 +27,16 @@ namespace Emulation WRITE = 1<<1 } - public class BitfieldValue : Object + public class BitfieldValue : InitiallyUnowned { public string name { get; internal set; } public string doc { get; internal set; } public uint32 val { get; internal set; } + + construct { /* silence compiler warning */ } } - public class BitfieldEnum : Object + public class BitfieldEnum : InitiallyUnowned { private HashTable vals; @@ -46,13 +48,15 @@ namespace Emulation internal void append(BitfieldValue v) { vals.insert(v.val, v); } } - public class Bitfield : Object + public class Bitfield : InitiallyUnowned { public string name { get; internal set; default = null; } public string doc { get; internal set; default = null; } public uint8 high { get; internal set; default = 0; } public uint8 low { get; internal set; default = 0; } public BitfieldEnum? enu { get; internal set; default = null; } + + construct { /* silence compiler warning */ } } public class BitfieldIterator @@ -73,7 +77,7 @@ namespace Emulation } } - public class RegisterInfo : Object + public class RegisterInfo : InitiallyUnowned { public string name { get; internal set; default = null; } public string doc { get; internal set; default = null; } @@ -94,14 +98,16 @@ namespace Emulation internal void append(Bitfield b) { bitfields.append(b); } } - public class Register : Object + public class Register : InitiallyUnowned { public uint addr { get; internal set; } public uint num { get; internal set; } public weak RegisterInfo info { get; internal set; } + + construct { /* silence compiler warning */ } } - public class RegisterIterator : Object + public class RegisterIterator { private weak List m_list; @@ -119,7 +125,7 @@ namespace Emulation } } - public class RegisterList : Object + public class RegisterList : InitiallyUnowned { private List regs; @@ -137,8 +143,8 @@ namespace Emulation private class SpecParser { - private weak HashTable info; - private weak HashTable regs; + private HashTable info; + private HashTable regs; private HashTable groups_map; private HashTable enums_map; @@ -149,7 +155,7 @@ namespace Emulation { info = (_info = new HashTable.full(str_hash, str_equal, (ptr) => { delete ptr; }, (ptr) => { (ptr as Object).unref(); })); regs = (_regs = new HashTable.full(int_hash, int_equal, (ptr) => { delete ptr; }, (ptr) => { (ptr as Object).unref(); })); - groups_map = new HashTable(str_hash, str_equal); + groups_map = new HashTable.full(str_hash, str_equal, (ptr) => { delete ptr; }, null); enums_map = new HashTable.full(str_hash, str_equal, (ptr) => { delete ptr; }, (ptr) => { (ptr as Object).unref(); }); } @@ -331,14 +337,14 @@ namespace Emulation string name = _name + get_single_attrib(node, "name"); offset += (uint)get_single_attrib(node, "offset").to_ulong(); - var regarr = regs.lookup(offset); + weak RegisterList regarr = regs.lookup(offset); if (regarr == null) { regs.insert(offset, new RegisterList()); regarr = regs.lookup(offset); } bool prefound = true; - RegisterInfo reginfo = info.lookup(name); + weak RegisterInfo reginfo = info.lookup(name); if (reginfo == null) { var ri = new RegisterInfo(); ri.name = name; @@ -452,7 +458,7 @@ namespace Emulation xml.parse(filename, variant); } - public RegisterList? translate_addr(uint addr) + public weak RegisterList? translate_addr(uint addr) { return regs.lookup(addr); } -- cgit v1.2.3