diff options
author | Joakim Sindholt <opensource@zhasha.com> | 2010-04-09 04:10:39 +0200 |
---|---|---|
committer | Joakim Sindholt <opensource@zhasha.com> | 2010-04-09 04:10:39 +0200 |
commit | f2c1934bc758c5c990b175a3bf0087fa254ed5df (patch) | |
tree | 2b5bbf9704518551ca2cc1d82ae0771a7945f527 | |
parent | 59bc73420093f4d6e220b2a429b995417c051bdc (diff) |
csview/csexport: support bitfield enum value name resolution
To put it bluntly, this means that you can now see a name on the
values that are otherwise just shown as numeric
-rw-r--r-- | src/csexport.c | 91 | ||||
-rw-r--r-- | src/csexport.vala | 35 | ||||
-rw-r--r-- | src/csview.c | 55 | ||||
-rw-r--r-- | src/csview.vala | 15 |
4 files changed, 159 insertions, 37 deletions
diff --git a/src/csexport.c b/src/csexport.c index 43e6e0b..091178b 100644 --- a/src/csexport.c +++ b/src/csexport.c @@ -201,6 +201,26 @@ typedef struct _EmulationBitfieldIteratorClass EmulationBitfieldIteratorClass; typedef struct _EmulationBitfield EmulationBitfield; typedef struct _EmulationBitfieldClass EmulationBitfieldClass; + +#define EMULATION_TYPE_BITFIELD_ENUM (emulation_bitfield_enum_get_type ()) +#define EMULATION_BITFIELD_ENUM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMULATION_TYPE_BITFIELD_ENUM, EmulationBitfieldEnum)) +#define EMULATION_BITFIELD_ENUM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMULATION_TYPE_BITFIELD_ENUM, EmulationBitfieldEnumClass)) +#define EMULATION_IS_BITFIELD_ENUM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMULATION_TYPE_BITFIELD_ENUM)) +#define EMULATION_IS_BITFIELD_ENUM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMULATION_TYPE_BITFIELD_ENUM)) +#define EMULATION_BITFIELD_ENUM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMULATION_TYPE_BITFIELD_ENUM, EmulationBitfieldEnumClass)) + +typedef struct _EmulationBitfieldEnum EmulationBitfieldEnum; +typedef struct _EmulationBitfieldEnumClass EmulationBitfieldEnumClass; + +#define EMULATION_TYPE_BITFIELD_VALUE (emulation_bitfield_value_get_type ()) +#define EMULATION_BITFIELD_VALUE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMULATION_TYPE_BITFIELD_VALUE, EmulationBitfieldValue)) +#define EMULATION_BITFIELD_VALUE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMULATION_TYPE_BITFIELD_VALUE, EmulationBitfieldValueClass)) +#define EMULATION_IS_BITFIELD_VALUE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMULATION_TYPE_BITFIELD_VALUE)) +#define EMULATION_IS_BITFIELD_VALUE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMULATION_TYPE_BITFIELD_VALUE)) +#define EMULATION_BITFIELD_VALUE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMULATION_TYPE_BITFIELD_VALUE, EmulationBitfieldValueClass)) + +typedef struct _EmulationBitfieldValue EmulationBitfieldValue; +typedef struct _EmulationBitfieldValueClass EmulationBitfieldValueClass; #define _emulation_bitfield_iterator_unref0(var) ((var == NULL) ? NULL : (var = (emulation_bitfield_iterator_unref (var), NULL))) struct _GUICSExport { @@ -218,6 +238,7 @@ struct _GUICSExportPrivate { GtkFrame* info_frame; GtkComboBox* chip_combo; GtkCheckButton* check_pkttype; + GtkCheckButton* check_resolve_enums; GtkCheckButton* check_pkt0_addr; GtkCheckButton* check_pkt0_one; GtkCheckButton* check_pkt0_count; @@ -309,7 +330,7 @@ EmulationRegisterIterator* emulation_register_list_iterator (EmulationRegisterLi gboolean emulation_register_iterator_next (EmulationRegisterIterator* self); GType emulation_register_get_type (void); EmulationRegister* emulation_register_iterator_get (EmulationRegisterIterator* self); -static inline void gui_cs_export_print_dest_reg (GUICSExport* self, FILE* fs, gchar nextpkg, gchar nextdw, gchar nextreg, EmulationRegister* reg, guint32 dword); +static inline void gui_cs_export_print_dest_reg (GUICSExport* self, FILE* fs, gchar nextpkg, gchar nextdw, gchar nextreg, EmulationRegister* reg, guint32 dword, gboolean resolve); GType emulation_register_info_get_type (void); EmulationRegisterInfo* emulation_register_get_info (EmulationRegister* self); guint emulation_register_info_get_count (EmulationRegisterInfo* self); @@ -328,6 +349,11 @@ GType emulation_bitfield_get_type (void); EmulationBitfield* emulation_bitfield_iterator_get (EmulationBitfieldIterator* self); guint8 emulation_bitfield_get_low (EmulationBitfield* self); guint8 emulation_bitfield_get_high (EmulationBitfield* self); +GType emulation_bitfield_enum_get_type (void); +EmulationBitfieldEnum* emulation_bitfield_get_enu (EmulationBitfield* self); +GType emulation_bitfield_value_get_type (void); +EmulationBitfieldValue* emulation_bitfield_enum_lookup (EmulationBitfieldEnum* self, guint32 key); +const char* emulation_bitfield_value_get_name (EmulationBitfieldValue* self); const char* emulation_bitfield_get_name (EmulationBitfield* self); static void gui_cs_export_finalize (GObject* obj); @@ -392,10 +418,12 @@ GUICSExport* gui_cs_export_construct (GType object_type, EmulationCS* cs) { GObject* _tmp21_; GtkCheckButton* _tmp24_; GObject* _tmp23_; + GtkCheckButton* _tmp26_; GObject* _tmp25_; + GObject* _tmp27_; GtkAlignment* chip_combo_align; - GtkComboBox* _tmp26_; - EmulationCS* _tmp28_; + GtkComboBox* _tmp28_; + EmulationCS* _tmp30_; g_return_val_if_fail (cs != NULL, NULL); _inner_error_ = NULL; self = g_object_newv (object_type, 0, NULL); @@ -436,28 +464,29 @@ GUICSExport* gui_cs_export_construct (GType object_type, EmulationCS* cs) { self->priv->tree_radio = (_tmp4_ = _g_object_ref0 ((_tmp3_ = gtk_builder_get_object (builder, "tree_radio"), GTK_IS_RADIO_BUTTON (_tmp3_) ? ((GtkRadioButton*) _tmp3_) : NULL)), _g_object_unref0 (self->priv->tree_radio), _tmp4_); self->priv->info_frame = (_tmp6_ = _g_object_ref0 ((_tmp5_ = gtk_builder_get_object (builder, "info_frame"), GTK_IS_FRAME (_tmp5_) ? ((GtkFrame*) _tmp5_) : NULL)), _g_object_unref0 (self->priv->info_frame), _tmp6_); self->priv->check_pkttype = (_tmp8_ = _g_object_ref0 ((_tmp7_ = gtk_builder_get_object (builder, "check_pkttype"), GTK_IS_CHECK_BUTTON (_tmp7_) ? ((GtkCheckButton*) _tmp7_) : NULL)), _g_object_unref0 (self->priv->check_pkttype), _tmp8_); - self->priv->check_pkt0_addr = (_tmp10_ = _g_object_ref0 ((_tmp9_ = gtk_builder_get_object (builder, "check_pkt0_addr"), GTK_IS_CHECK_BUTTON (_tmp9_) ? ((GtkCheckButton*) _tmp9_) : NULL)), _g_object_unref0 (self->priv->check_pkt0_addr), _tmp10_); - self->priv->check_pkt0_one = (_tmp12_ = _g_object_ref0 ((_tmp11_ = gtk_builder_get_object (builder, "check_pkt0_one"), GTK_IS_CHECK_BUTTON (_tmp11_) ? ((GtkCheckButton*) _tmp11_) : NULL)), _g_object_unref0 (self->priv->check_pkt0_one), _tmp12_); - self->priv->check_pkt0_count = (_tmp14_ = _g_object_ref0 ((_tmp13_ = gtk_builder_get_object (builder, "check_pkt0_count"), GTK_IS_CHECK_BUTTON (_tmp13_) ? ((GtkCheckButton*) _tmp13_) : NULL)), _g_object_unref0 (self->priv->check_pkt0_count), _tmp14_); - self->priv->check_pkt1_addr1 = (_tmp16_ = _g_object_ref0 ((_tmp15_ = gtk_builder_get_object (builder, "check_pkt1_addr1"), GTK_IS_CHECK_BUTTON (_tmp15_) ? ((GtkCheckButton*) _tmp15_) : NULL)), _g_object_unref0 (self->priv->check_pkt1_addr1), _tmp16_); - self->priv->check_pkt1_addr2 = (_tmp18_ = _g_object_ref0 ((_tmp17_ = gtk_builder_get_object (builder, "check_pkt1_addr2"), GTK_IS_CHECK_BUTTON (_tmp17_) ? ((GtkCheckButton*) _tmp17_) : NULL)), _g_object_unref0 (self->priv->check_pkt1_addr2), _tmp18_); - 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_); + self->priv->check_resolve_enums = (_tmp10_ = _g_object_ref0 ((_tmp9_ = gtk_builder_get_object (builder, "check_resolve_enums"), GTK_IS_CHECK_BUTTON (_tmp9_) ? ((GtkCheckButton*) _tmp9_) : NULL)), _g_object_unref0 (self->priv->check_resolve_enums), _tmp10_); + self->priv->check_pkt0_addr = (_tmp12_ = _g_object_ref0 ((_tmp11_ = gtk_builder_get_object (builder, "check_pkt0_addr"), GTK_IS_CHECK_BUTTON (_tmp11_) ? ((GtkCheckButton*) _tmp11_) : NULL)), _g_object_unref0 (self->priv->check_pkt0_addr), _tmp12_); + self->priv->check_pkt0_one = (_tmp14_ = _g_object_ref0 ((_tmp13_ = gtk_builder_get_object (builder, "check_pkt0_one"), GTK_IS_CHECK_BUTTON (_tmp13_) ? ((GtkCheckButton*) _tmp13_) : NULL)), _g_object_unref0 (self->priv->check_pkt0_one), _tmp14_); + self->priv->check_pkt0_count = (_tmp16_ = _g_object_ref0 ((_tmp15_ = gtk_builder_get_object (builder, "check_pkt0_count"), GTK_IS_CHECK_BUTTON (_tmp15_) ? ((GtkCheckButton*) _tmp15_) : NULL)), _g_object_unref0 (self->priv->check_pkt0_count), _tmp16_); + self->priv->check_pkt1_addr1 = (_tmp18_ = _g_object_ref0 ((_tmp17_ = gtk_builder_get_object (builder, "check_pkt1_addr1"), GTK_IS_CHECK_BUTTON (_tmp17_) ? ((GtkCheckButton*) _tmp17_) : NULL)), _g_object_unref0 (self->priv->check_pkt1_addr1), _tmp18_); + self->priv->check_pkt1_addr2 = (_tmp20_ = _g_object_ref0 ((_tmp19_ = gtk_builder_get_object (builder, "check_pkt1_addr2"), GTK_IS_CHECK_BUTTON (_tmp19_) ? ((GtkCheckButton*) _tmp19_) : NULL)), _g_object_unref0 (self->priv->check_pkt1_addr2), _tmp20_); + self->priv->check_pkt3_opcode = (_tmp22_ = _g_object_ref0 ((_tmp21_ = gtk_builder_get_object (builder, "check_pkt3_opcode"), GTK_IS_CHECK_BUTTON (_tmp21_) ? ((GtkCheckButton*) _tmp21_) : NULL)), _g_object_unref0 (self->priv->check_pkt3_opcode), _tmp22_); + self->priv->check_pkt3_opcode_text = (_tmp24_ = _g_object_ref0 ((_tmp23_ = gtk_builder_get_object (builder, "check_pkt3_opcode_text"), GTK_IS_CHECK_BUTTON (_tmp23_) ? ((GtkCheckButton*) _tmp23_) : NULL)), _g_object_unref0 (self->priv->check_pkt3_opcode_text), _tmp24_); + self->priv->check_pkt3_count = (_tmp26_ = _g_object_ref0 ((_tmp25_ = gtk_builder_get_object (builder, "check_pkt3_count"), GTK_IS_CHECK_BUTTON (_tmp25_) ? ((GtkCheckButton*) _tmp25_) : NULL)), _g_object_unref0 (self->priv->check_pkt3_count), _tmp26_); 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_))); + chip_combo_align = _g_object_ref0 ((_tmp27_ = gtk_builder_get_object (builder, "chip_combo_align"), GTK_IS_ALIGNMENT (_tmp27_) ? ((GtkAlignment*) _tmp27_) : NULL)); + gtk_container_add ((GtkContainer*) chip_combo_align, (GtkWidget*) (self->priv->chip_combo = (_tmp28_ = g_object_ref_sink ((GtkComboBox*) gtk_combo_box_new_text ()), _g_object_unref0 (self->priv->chip_combo), _tmp28_))); { guint i; i = (guint) 0; { - gboolean _tmp27_; - _tmp27_ = TRUE; + gboolean _tmp29_; + _tmp29_ = TRUE; while (TRUE) { - if (!_tmp27_) { + if (!_tmp29_) { i++; } - _tmp27_ = FALSE; + _tmp29_ = FALSE; if (!(i < emulation_specs_length1)) { break; } @@ -467,7 +496,7 @@ GUICSExport* gui_cs_export_construct (GType object_type, EmulationCS* cs) { } gtk_combo_box_set_active (self->priv->chip_combo, (gint) emulation_spec_default); gtk_widget_set_visible ((GtkWidget*) self->priv->chip_combo, TRUE); - self->priv->cs = (_tmp28_ = _g_object_ref0 (cs), _g_object_unref0 (self->priv->cs), _tmp28_); + self->priv->cs = (_tmp30_ = _g_object_ref0 (cs), _g_object_unref0 (self->priv->cs), _tmp30_); g_signal_connect_object ((GtkDialog*) self, "response", (GCallback) _gui_cs_export_on_response_gtk_dialog_response, self, 0); _g_object_unref0 (builder); _g_object_unref0 (mainbox); @@ -557,6 +586,7 @@ static void gui_cs_export_export_plain (GUICSExport* self, FILE* fs) { static void gui_cs_export_export_tree (GUICSExport* self, FILE* fs) { gboolean pkt_type; + gboolean resolve_enums; gboolean pkt0_addr; gboolean pkt0_one; gboolean pkt0_count; @@ -570,6 +600,7 @@ static void gui_cs_export_export_tree (GUICSExport* self, FILE* fs) { g_return_if_fail (self != NULL); g_return_if_fail (fs != NULL); pkt_type = gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->check_pkttype); + resolve_enums = gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->check_resolve_enums); pkt0_addr = gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->check_pkt0_addr); pkt0_one = gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->check_pkt0_one); pkt0_count = gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->check_pkt0_count); @@ -747,7 +778,7 @@ static void gui_cs_export_export_tree (GUICSExport* self, FILE* fs) { _tmp11_ = ' '; } nextreg = _tmp11_; - gui_cs_export_print_dest_reg (self, fs, nextpkg, nextdw, nextreg, reg, emulation_packet_get (p, i)); + gui_cs_export_print_dest_reg (self, fs, nextpkg, nextdw, nextreg, reg, emulation_packet_get (p, i), resolve_enums); } _emulation_register_iterator_unref0 (_reg_it); } @@ -767,7 +798,7 @@ static void gui_cs_export_export_tree (GUICSExport* self, FILE* fs) { } -static inline void gui_cs_export_print_dest_reg (GUICSExport* self, FILE* fs, gchar nextpkg, gchar nextdw, gchar nextreg, EmulationRegister* reg, guint32 dword) { +static inline void gui_cs_export_print_dest_reg (GUICSExport* self, FILE* fs, gchar nextpkg, gchar nextdw, gchar nextreg, EmulationRegister* reg, guint32 dword, gboolean resolve) { guint length; guint i; g_return_if_fail (self != NULL); @@ -788,6 +819,7 @@ static inline void gui_cs_export_print_dest_reg (GUICSExport* self, FILE* fs, gc guint32 bfval; gchar _tmp0_ = '\0'; gchar nextbf; + char* resolution; if (!emulation_bitfield_iterator_next (_bf_it)) { break; } @@ -799,7 +831,21 @@ static inline void gui_cs_export_print_dest_reg (GUICSExport* self, FILE* fs, gc _tmp0_ = '|'; } nextbf = _tmp0_; - fprintf (fs, "%c %c %c %c--- %u -> %s\n", (gint) nextpkg, (gint) nextdw, (gint) nextreg, (gint) nextbf, (guint) bfval, emulation_bitfield_get_name (bf)); + resolution = g_strdup (""); + if (resolve) { + if (emulation_bitfield_get_enu (bf) != NULL) { + EmulationBitfieldValue* enuval; + enuval = emulation_bitfield_enum_lookup (emulation_bitfield_get_enu (bf), bfval); + if (enuval != NULL) { + char* _tmp2_; + char* _tmp1_; + resolution = (_tmp2_ = g_strconcat (_tmp1_ = g_strconcat (" (", emulation_bitfield_value_get_name (enuval), NULL), ")", NULL), _g_free0 (resolution), _tmp2_); + _g_free0 (_tmp1_); + } + } + } + fprintf (fs, "%c %c %c %c--- %u%s -> %s\n", (gint) nextpkg, (gint) nextdw, (gint) nextreg, (gint) nextbf, (guint) bfval, resolution, emulation_bitfield_get_name (bf)); + _g_free0 (resolution); } _emulation_bitfield_iterator_unref0 (_bf_it); } @@ -813,7 +859,7 @@ static void gui_cs_export_class_init (GUICSExportClass * klass) { gui_cs_export_parent_class = g_type_class_peek_parent (klass); g_type_class_add_private (klass, sizeof (GUICSExportPrivate)); G_OBJECT_CLASS (klass)->finalize = gui_cs_export_finalize; - gui_cs_export_ui_xml = g_strdup ("\n <?xml version=\"1.0\"?>\n <interface>\n <requires lib=\"gtk+\" version=\"2.16\"/>\n <object class=\"GtkVBox\" id=\"mainbox\">\n <property name=\"visible\">True</property>\n <property name=\"orientation\">vertical</property>\n <property name=\"spacing\">8</property>\n <child>\n <object class=\"GtkFrame\" id=\"frame2\">\n <property name=\"visible\">True</property>\n <property name=\"label_xalign\">0</property>\n <property name=\"shadow_type\">none</property>\n <child>\n <object class=\"GtkAlignment\" id=\"alignment1\">\n <property name=\"visible\">True</property>\n <property name=\"left_padding\">12</property>\n <child>\n <object class=\"GtkHBox\" id=\"hbox1\">\n <property name=\"visible\">True</property>\n <property name=\"spacing\">12</property>\n <child>\n <object class=\"GtkRadioButton\" id=\"plain_radio\">\n <property name=\"label\" translatable=\"yes\">Plain text</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"expand\">False</property>\n <property name=\"position\">0</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkRadioButton\" id=\"tree_radio\">\n <property name=\"label\" translatable=\"yes\">Structured tree</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"active\">True</property>\n <property name=\"draw_indicator\">True</property>\n <property name=\"group\">plain_radio</property>\n </object>\n <packing>\n <property name=\"position\">1</property>\n </packing>\n </child>\n </object>\n </child>\n </object>\n </child>\n <child type=\"label\">\n <object class=\"GtkLabel\" id=\"label2\">\n <property name=\"visible\">True</property>\n <property name=\"label\" translatable=\"yes\"><b>Structure</b></property>\n <property name=\"use_markup\">True</property>\n </object>\n </child>\n </object>\n <packing>\n <property name=\"expand\">False</property>\n <property name=\"position\">0</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkFrame\" id=\"info_frame\">\n <property name=\"visible\">True</property>\n <property name=\"sensitive\">False</property>\n <property name=\"label_xalign\">0</property>\n <property name=\"shadow_type\">none</property>\n <child>\n <object class=\"GtkAlignment\" id=\"alignment2\">\n <property name=\"visible\">True</property>\n <property name=\"left_padding\">12</property>\n <child>\n <object class=\"GtkVBox\" id=\"vbox2\">\n <property name=\"visible\">True</property>\n <property name=\"orientation\">vertical</property>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkttype\">\n <property name=\"label\" translatable=\"yes\">Packet type</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">0</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkExpander\" id=\"expander1\">\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <child>\n <object class=\"GtkAlignment\" id=\"alignment3\">\n <property name=\"visible\">True</property>\n <property name=\"left_padding\">12</property>\n <child>\n <object class=\"GtkVBox\" id=\"vbox3\">\n <property name=\"visible\">True</property>\n <property name=\"orientation\">vertical</property>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkt0_addr\">\n <property name=\"label\" translatable=\"yes\">Base address (with correction)</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">0</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkt0_one\">\n <property name=\"label\" translatable=\"yes\">ONE_REG_WR</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">1</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkt0_count\">\n <property name=\"label\" translatable=\"yes\">DWORD count</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">2</property>\n </packing>\n </child>\n </object>\n </child>\n </object>\n </child>\n <child type=\"label\">\n <object class=\"GtkLabel\" id=\"label3\">\n <property name=\"visible\">True</property>\n <property name=\"label\" translatable=\"yes\">Packet0</property>\n </object>\n </child>\n </object>\n <packing>\n <property name=\"expand\">False</property>\n <property name=\"position\">1</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkExpander\" id=\"expander2\">\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <child>\n <object class=\"GtkAlignment\" id=\"alignment4\">\n <property name=\"visible\">True</property>\n <property name=\"left_padding\">12</property>\n <child>\n <object class=\"GtkVBox\" id=\"vbox4\">\n <property name=\"visible\">True</property>\n <property name=\"orientation\">vertical</property>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkt1_addr1\">\n <property name=\"label\" translatable=\"yes\">Base address 1 (with correction)</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">0</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkt1_addr2\">\n <property name=\"label\" translatable=\"yes\">Base address 2 (with correction)</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">1</property>\n </packing>\n </child>\n </object>\n </child>\n </object>\n </child>\n <child type=\"label\">\n <object class=\"GtkLabel\" id=\"label4\">\n <property name=\"visible\">True</property>\n <property name=\"label\" translatable=\"yes\">Packet1</property>\n </object>\n </child>\n </object>\n <packing>\n <property name=\"expand\">False</property>\n <property name=\"position\">2</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkExpander\" id=\"expander4\">\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <child>\n <object class=\"GtkAlignment\" id=\"alignment6\">\n <property name=\"visible\">True</property>\n <property name=\"left_padding\">12</property>\n <child>\n <object class=\"GtkVBox\" id=\"vbox5\">\n <property name=\"visible\">True</property>\n <property name=\"orientation\">vertical</property>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkt3_opcode\">\n <property name=\"label\" translatable=\"yes\">Opcode (Hex)</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">0</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkt3_opcode_text\">\n <property name=\"label\" translatable=\"yes\">Opcode (Name)</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">1</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkt3_count\">\n <property name=\"label\" translatable=\"yes\">DWORD count</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">2</property>\n </packing>\n </child>\n </object>\n </child>\n </object>\n </child>\n <child type=\"label\">\n <object class=\"GtkLabel\" id=\"label6\">\n <property name=\"visible\">True</property>\n <property name=\"label\" translatable=\"yes\">Packet3</property>\n </object>\n </child>\n </object>\n <packing>\n <property name=\"expand\">False</property>\n <property name=\"position\">3</property>\n </packing>\n </child>\n </object>\n </child>\n </object>\n </child>\n <child type=\"label\">\n <object class=\"GtkLabel\" id=\"label1\">\n <property name=\"visible\">True</property>\n <property name=\"label\" translatable=\"yes\"><b>Information</b></property>\n <property name=\"use_markup\">True</property>\n </object>\n </child>\n </object>\n <packing>\n <property name=\"expand\">False</property>\n <property name=\"position\">1</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkFrame\" id=\"frame3\">\n <property name=\"visible\">True</property>\n <property name=\"label_xalign\">0</property>\n <property name=\"shadow_type\">none</property>\n <child>\n <object class=\"GtkAlignment\" id=\"chip_combo_align\">\n <property name=\"visible\">True</property>\n <property name=\"left_padding\">12</property>\n </object>\n </child>\n <child type=\"label\">\n <object class=\"GtkLabel\" id=\"label5\">\n <property name=\"visible\">True</property>\n <property name=\"label\" translatable=\"yes\"><b>Chip</b></property>\n <property name=\"use_markup\">True</property>\n </object>\n </child>\n </object>\n <packing>\n <property name=\"expand\">False</property>\n <property name=\"position\">2</property>\n </packing>\n </child>\n </object>\n </interface>\n "); + gui_cs_export_ui_xml = g_strdup ("\n <?xml version=\"1.0\"?>\n <interface>\n <requires lib=\"gtk+\" version=\"2.16\"/>\n <object class=\"GtkVBox\" id=\"mainbox\">\n <property name=\"visible\">True</property>\n <property name=\"orientation\">vertical</property>\n <property name=\"spacing\">8</property>\n <child>\n <object class=\"GtkFrame\" id=\"frame2\">\n <property name=\"visible\">True</property>\n <property name=\"label_xalign\">0</property>\n <property name=\"shadow_type\">none</property>\n <child>\n <object class=\"GtkAlignment\" id=\"alignment1\">\n <property name=\"visible\">True</property>\n <property name=\"left_padding\">12</property>\n <child>\n <object class=\"GtkHBox\" id=\"hbox1\">\n <property name=\"visible\">True</property>\n <property name=\"spacing\">12</property>\n <child>\n <object class=\"GtkRadioButton\" id=\"plain_radio\">\n <property name=\"label\" translatable=\"yes\">Plain text</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"expand\">False</property>\n <property name=\"position\">0</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkRadioButton\" id=\"tree_radio\">\n <property name=\"label\" translatable=\"yes\">Structured tree</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"active\">True</property>\n <property name=\"draw_indicator\">True</property>\n <property name=\"group\">plain_radio</property>\n </object>\n <packing>\n <property name=\"position\">1</property>\n </packing>\n </child>\n </object>\n </child>\n </object>\n </child>\n <child type=\"label\">\n <object class=\"GtkLabel\" id=\"label2\">\n <property name=\"visible\">True</property>\n <property name=\"label\" translatable=\"yes\"><b>Structure</b></property>\n <property name=\"use_markup\">True</property>\n </object>\n </child>\n </object>\n <packing>\n <property name=\"expand\">False</property>\n <property name=\"position\">0</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkFrame\" id=\"info_frame\">\n <property name=\"visible\">True</property>\n <property name=\"sensitive\">False</property>\n <property name=\"label_xalign\">0</property>\n <property name=\"shadow_type\">none</property>\n <child>\n <object class=\"GtkAlignment\" id=\"alignment2\">\n <property name=\"visible\">True</property>\n <property name=\"left_padding\">12</property>\n <child>\n <object class=\"GtkVBox\" id=\"vbox2\">\n <property name=\"visible\">True</property>\n <property name=\"orientation\">vertical</property>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkttype\">\n <property name=\"label\" translatable=\"yes\">Packet type</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">0</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_resolve_enums\">\n <property name=\"label\" translatable=\"yes\">Resolve bitfield enums</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">1</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkExpander\" id=\"expander1\">\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <child>\n <object class=\"GtkAlignment\" id=\"alignment3\">\n <property name=\"visible\">True</property>\n <property name=\"left_padding\">12</property>\n <child>\n <object class=\"GtkVBox\" id=\"vbox3\">\n <property name=\"visible\">True</property>\n <property name=\"orientation\">vertical</property>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkt0_addr\">\n <property name=\"label\" translatable=\"yes\">Base address (with correction)</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">0</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkt0_one\">\n <property name=\"label\" translatable=\"yes\">ONE_REG_WR</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">1</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkt0_count\">\n <property name=\"label\" translatable=\"yes\">DWORD count</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">2</property>\n </packing>\n </child>\n </object>\n </child>\n </object>\n </child>\n <child type=\"label\">\n <object class=\"GtkLabel\" id=\"label3\">\n <property name=\"visible\">True</property>\n <property name=\"label\" translatable=\"yes\">Packet0</property>\n </object>\n </child>\n </object>\n <packing>\n <property name=\"expand\">False</property>\n <property name=\"position\">2</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkExpander\" id=\"expander2\">\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <child>\n <object class=\"GtkAlignment\" id=\"alignment4\">\n <property name=\"visible\">True</property>\n <property name=\"left_padding\">12</property>\n <child>\n <object class=\"GtkVBox\" id=\"vbox4\">\n <property name=\"visible\">True</property>\n <property name=\"orientation\">vertical</property>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkt1_addr1\">\n <property name=\"label\" translatable=\"yes\">Base address 1 (with correction)</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">0</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkt1_addr2\">\n <property name=\"label\" translatable=\"yes\">Base address 2 (with correction)</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">1</property>\n </packing>\n </child>\n </object>\n </child>\n </object>\n </child>\n <child type=\"label\">\n <object class=\"GtkLabel\" id=\"label4\">\n <property name=\"visible\">True</property>\n <property name=\"label\" translatable=\"yes\">Packet1</property>\n </object>\n </child>\n </object>\n <packing>\n <property name=\"expand\">False</property>\n <property name=\"position\">3</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkExpander\" id=\"expander4\">\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <child>\n <object class=\"GtkAlignment\" id=\"alignment6\">\n <property name=\"visible\">True</property>\n <property name=\"left_padding\">12</property>\n <child>\n <object class=\"GtkVBox\" id=\"vbox5\">\n <property name=\"visible\">True</property>\n <property name=\"orientation\">vertical</property>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkt3_opcode\">\n <property name=\"label\" translatable=\"yes\">Opcode (Hex)</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">0</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkt3_opcode_text\">\n <property name=\"label\" translatable=\"yes\">Opcode (Name)</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">1</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkCheckButton\" id=\"check_pkt3_count\">\n <property name=\"label\" translatable=\"yes\">DWORD count</property>\n <property name=\"active\">True</property>\n <property name=\"visible\">True</property>\n <property name=\"can_focus\">True</property>\n <property name=\"receives_default\">False</property>\n <property name=\"draw_indicator\">True</property>\n </object>\n <packing>\n <property name=\"position\">2</property>\n </packing>\n </child>\n </object>\n </child>\n </object>\n </child>\n <child type=\"label\">\n <object class=\"GtkLabel\" id=\"label6\">\n <property name=\"visible\">True</property>\n <property name=\"label\" translatable=\"yes\">Packet3</property>\n </object>\n </child>\n </object>\n <packing>\n <property name=\"expand\">False</property>\n <property name=\"position\">4</property>\n </packing>\n </child>\n </object>\n </child>\n </object>\n </child>\n <child type=\"label\">\n <object class=\"GtkLabel\" id=\"label1\">\n <property name=\"visible\">True</property>\n <property name=\"label\" translatable=\"yes\"><b>Information</b></property>\n <property name=\"use_markup\">True</property>\n </object>\n </child>\n </object>\n <packing>\n <property name=\"expand\">False</property>\n <property name=\"position\">1</property>\n </packing>\n </child>\n <child>\n <object class=\"GtkFrame\" id=\"frame3\">\n <property name=\"visible\">True</property>\n <property name=\"label_xalign\">0</property>\n <property name=\"shadow_type\">none</property>\n <child>\n <object class=\"GtkAlignment\" id=\"chip_combo_align\">\n <property name=\"visible\">True</property>\n <property name=\"left_padding\">12</property>\n </object>\n </child>\n <child type=\"label\">\n <object class=\"GtkLabel\" id=\"label5\">\n <property name=\"visible\">True</property>\n <property name=\"label\" translatable=\"yes\"><b>Chip</b></property>\n <property name=\"use_markup\">True</property>\n </object>\n </child>\n </object>\n <packing>\n <property name=\"expand\">False</property>\n <property name=\"position\">2</property>\n </packing>\n </child>\n </object>\n </interface>\n "); } @@ -830,6 +876,7 @@ static void gui_cs_export_finalize (GObject* obj) { _g_object_unref0 (self->priv->info_frame); _g_object_unref0 (self->priv->chip_combo); _g_object_unref0 (self->priv->check_pkttype); + _g_object_unref0 (self->priv->check_resolve_enums); _g_object_unref0 (self->priv->check_pkt0_addr); _g_object_unref0 (self->priv->check_pkt0_one); _g_object_unref0 (self->priv->check_pkt0_count); diff --git a/src/csexport.vala b/src/csexport.vala index d11f087..92310ea 100644 --- a/src/csexport.vala +++ b/src/csexport.vala @@ -120,6 +120,19 @@ namespace GUI </packing> </child> <child> + <object class="GtkCheckButton" id="check_resolve_enums"> + <property name="label" translatable="yes">Resolve bitfield enums</property> + <property name="active">True</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> <object class="GtkExpander" id="expander1"> <property name="visible">True</property> <property name="can_focus">True</property> @@ -183,7 +196,7 @@ namespace GUI </object> <packing> <property name="expand">False</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> <child> @@ -237,7 +250,7 @@ namespace GUI </object> <packing> <property name="expand">False</property> - <property name="position">2</property> + <property name="position">3</property> </packing> </child> <child> @@ -303,7 +316,7 @@ namespace GUI </object> <packing> <property name="expand">False</property> - <property name="position">3</property> + <property name="position">4</property> </packing> </child> </object> @@ -358,6 +371,7 @@ namespace GUI private ComboBox chip_combo; private CheckButton check_pkttype; + private CheckButton check_resolve_enums; private CheckButton check_pkt0_addr; private CheckButton check_pkt0_one; private CheckButton check_pkt0_count; @@ -391,6 +405,7 @@ namespace GUI tree_radio = builder.get_object("tree_radio") as RadioButton; info_frame = builder.get_object("info_frame") as Frame; check_pkttype = builder.get_object("check_pkttype") as CheckButton; + check_resolve_enums = builder.get_object("check_resolve_enums") as CheckButton; check_pkt0_addr = builder.get_object("check_pkt0_addr") as CheckButton; check_pkt0_one = builder.get_object("check_pkt0_one") as CheckButton; check_pkt0_count = builder.get_object("check_pkt0_count") as CheckButton; @@ -465,6 +480,7 @@ namespace GUI private void export_tree(FileStream fs) { bool pkt_type = check_pkttype.get_active(); + bool resolve_enums = check_resolve_enums.get_active(); bool pkt0_addr = check_pkt0_addr.get_active(); bool pkt0_one = check_pkt0_one.get_active(); bool pkt0_count = check_pkt0_count.get_active(); @@ -531,7 +547,7 @@ namespace GUI uint j = 0; foreach (var reg in list) { char nextreg = (j++ != length-1) ? '|' : ' '; - print_dest_reg(fs, nextpkg, nextdw, nextreg, reg, p[i]); + print_dest_reg(fs, nextpkg, nextdw, nextreg, reg, p[i], resolve_enums); } } } @@ -539,7 +555,7 @@ namespace GUI } } - private inline void print_dest_reg(FileStream fs, char nextpkg, char nextdw, char nextreg, Register reg, uint32 dword) + private inline void print_dest_reg(FileStream fs, char nextpkg, char nextdw, char nextreg, Register reg, uint32 dword, bool resolve) { if (reg.info.count == 1) { fs.printf("%c %c +-+- %s\n", nextpkg, nextdw, reg.info.name); @@ -552,7 +568,14 @@ namespace GUI foreach (var bf in reg.info) { uint32 bfval = (dword >> bf.low) & ((1 << (bf.high-bf.low+1))-1); char nextbf = (i++ == length-1) ? '+' : '|'; - fs.printf("%c %c %c %c--- %u -> %s\n", nextpkg, nextdw, nextreg, nextbf, bfval, bf.name); + string resolution = ""; + if (resolve) { + if (bf.enu != null) { + weak BitfieldValue? enuval = bf.enu.lookup(bfval); + if (enuval != null) { resolution = " (" + enuval.name + ")"; } + } + } + fs.printf("%c %c %c %c--- %u%s -> %s\n", nextpkg, nextdw, nextreg, nextbf, bfval, resolution, bf.name); } if (reg.info.length == 0) { fs.printf("%c %c %c +--- %u -> DATA_REGISTER\n", nextpkg, nextdw, nextreg, dword); diff --git a/src/csview.c b/src/csview.c index 9660801..9ba02b9 100644 --- a/src/csview.c +++ b/src/csview.c @@ -151,6 +151,26 @@ typedef struct _EmulationPacket1Class EmulationPacket1Class; typedef struct _EmulationBitfield EmulationBitfield; typedef struct _EmulationBitfieldClass EmulationBitfieldClass; +#define EMULATION_TYPE_BITFIELD_ENUM (emulation_bitfield_enum_get_type ()) +#define EMULATION_BITFIELD_ENUM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMULATION_TYPE_BITFIELD_ENUM, EmulationBitfieldEnum)) +#define EMULATION_BITFIELD_ENUM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMULATION_TYPE_BITFIELD_ENUM, EmulationBitfieldEnumClass)) +#define EMULATION_IS_BITFIELD_ENUM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMULATION_TYPE_BITFIELD_ENUM)) +#define EMULATION_IS_BITFIELD_ENUM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMULATION_TYPE_BITFIELD_ENUM)) +#define EMULATION_BITFIELD_ENUM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMULATION_TYPE_BITFIELD_ENUM, EmulationBitfieldEnumClass)) + +typedef struct _EmulationBitfieldEnum EmulationBitfieldEnum; +typedef struct _EmulationBitfieldEnumClass EmulationBitfieldEnumClass; + +#define EMULATION_TYPE_BITFIELD_VALUE (emulation_bitfield_value_get_type ()) +#define EMULATION_BITFIELD_VALUE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMULATION_TYPE_BITFIELD_VALUE, EmulationBitfieldValue)) +#define EMULATION_BITFIELD_VALUE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMULATION_TYPE_BITFIELD_VALUE, EmulationBitfieldValueClass)) +#define EMULATION_IS_BITFIELD_VALUE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMULATION_TYPE_BITFIELD_VALUE)) +#define EMULATION_IS_BITFIELD_VALUE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMULATION_TYPE_BITFIELD_VALUE)) +#define EMULATION_BITFIELD_VALUE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMULATION_TYPE_BITFIELD_VALUE, EmulationBitfieldValueClass)) + +typedef struct _EmulationBitfieldValue EmulationBitfieldValue; +typedef struct _EmulationBitfieldValueClass EmulationBitfieldValueClass; + #define EMULATION_TYPE_PACKET3 (emulation_packet3_get_type ()) #define EMULATION_PACKET3(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMULATION_TYPE_PACKET3, EmulationPacket3)) #define EMULATION_PACKET3_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMULATION_TYPE_PACKET3, EmulationPacket3Class)) @@ -369,9 +389,14 @@ GType emulation_bitfield_get_type (void); EmulationBitfield* emulation_register_info_get (EmulationRegisterInfo* self, guint index); const char* emulation_bitfield_get_name (EmulationBitfield* self); static const char* gui_cs_list_model_bitfield_name (GUICSListModel* self, guint32 addr, guint variant, guint bitfield); +GType emulation_bitfield_enum_get_type (void); guint8 emulation_bitfield_get_high (EmulationBitfield* self); guint8 emulation_bitfield_get_low (EmulationBitfield* self); -static guint32 gui_cs_list_model_bitfield_value (GUICSListModel* self, guint32 addr, guint variant, guint bitfield, guint32 dword); +EmulationBitfieldEnum* emulation_bitfield_get_enu (EmulationBitfield* self); +GType emulation_bitfield_value_get_type (void); +EmulationBitfieldValue* emulation_bitfield_enum_lookup (EmulationBitfieldEnum* self, guint32 key); +const char* emulation_bitfield_value_get_name (EmulationBitfieldValue* self); +static char* gui_cs_list_model_bitfield_value (GUICSListModel* self, guint32 addr, guint variant, guint bitfield, guint32 dword); GUICSListModelRowType gui_cs_list_model_cs_iter_get_row_type (GUICSListModelCSIter* self); guint32 emulation_packet_get_header (EmulationPacket* self); guint32 emulation_packet_target_addr (EmulationPacket* self, guint index); @@ -817,23 +842,41 @@ static const char* gui_cs_list_model_bitfield_name (GUICSListModel* self, guint3 } -static guint32 gui_cs_list_model_bitfield_value (GUICSListModel* self, guint32 addr, guint variant, guint bitfield, guint32 dword) { - guint32 result; +static char* gui_cs_list_model_bitfield_value (GUICSListModel* self, guint32 addr, guint variant, guint bitfield, guint32 dword) { + char* result; EmulationRegisterList* regs; guint high; guint low; - g_return_val_if_fail (self != NULL, 0U); + EmulationBitfieldEnum* enu; + guint32 val; + g_return_val_if_fail (self != NULL, NULL); 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; low = (guint) 0; + enu = NULL; if (emulation_register_info_get_length (emulation_register_get_info (emulation_register_list_get (regs, variant))) > 0) { g_assert (bitfield < emulation_register_info_get_length (emulation_register_get_info (emulation_register_list_get (regs, variant)))); high = (guint) emulation_bitfield_get_high (emulation_register_info_get (emulation_register_get_info (emulation_register_list_get (regs, variant)), bitfield)); low = (guint) emulation_bitfield_get_low (emulation_register_info_get (emulation_register_get_info (emulation_register_list_get (regs, variant)), bitfield)); + enu = emulation_bitfield_get_enu (emulation_register_info_get (emulation_register_get_info (emulation_register_list_get (regs, variant)), bitfield)); + } + val = (dword >> low) & ((1 << ((high - low) + 1)) - 1); + if (enu != NULL) { + EmulationBitfieldValue* enuval; + enuval = emulation_bitfield_enum_lookup (enu, val); + if (enuval != NULL) { + char* _tmp2_; + char* _tmp1_; + char* _tmp0_; + char* _tmp3_; + result = (_tmp3_ = g_strconcat (_tmp2_ = g_strconcat (_tmp1_ = g_strconcat (_tmp0_ = g_strdup_printf ("%u", val), " (", NULL), emulation_bitfield_value_get_name (enuval), NULL), ")", NULL), _g_free0 (_tmp2_), _g_free0 (_tmp1_), _g_free0 (_tmp0_), _tmp3_); + _g_object_unref0 (regs); + return result; + } } - result = (dword >> low) & ((1 << ((high - low) + 1)) - 1); + result = g_strdup_printf ("%u", val); _g_object_unref0 (regs); return result; } @@ -988,7 +1031,7 @@ static void gui_cs_list_model_real_get_value (GtkTreeModel* base, GtkTreeIter* i case GUI_CS_LIST_MODEL_COLUMNS_VALUE: { char* _tmp11_; - g_value_set_string (val, _tmp11_ = g_strdup_printf ("%u", gui_cs_list_model_bitfield_value (self, emulation_packet_target_addr (p, (guint) (gui_cs_list_model_cs_iter_get_dword (it) - 1)), (guint) gui_cs_list_model_cs_iter_get_variant (it), (guint) gui_cs_list_model_cs_iter_get_bitfield (it), emulation_packet_get (p, (guint) (gui_cs_list_model_cs_iter_get_dword (it) - 1))))); + g_value_set_string (val, _tmp11_ = gui_cs_list_model_bitfield_value (self, emulation_packet_target_addr (p, (guint) (gui_cs_list_model_cs_iter_get_dword (it) - 1)), (guint) gui_cs_list_model_cs_iter_get_variant (it), (guint) gui_cs_list_model_cs_iter_get_bitfield (it), emulation_packet_get (p, (guint) (gui_cs_list_model_cs_iter_get_dword (it) - 1)))); _g_free0 (_tmp11_); break; } diff --git a/src/csview.vala b/src/csview.vala index 5bed51d..a2ff8f5 100644 --- a/src/csview.vala +++ b/src/csview.vala @@ -363,18 +363,27 @@ namespace GUI return "DATA_REGISTER"; } - private uint32 bitfield_value(uint32 addr, uint variant, uint bitfield, uint32 dword) + private string bitfield_value(uint32 addr, uint variant, uint bitfield, uint32 dword) { var regs = m_spec.translate_addr((uint)addr); assert(regs != null); assert(variant < regs.length); + uint high = 31, low = 0; + weak BitfieldEnum? enu = null; if (regs[variant].info.length > 0) { assert(bitfield < regs[variant].info.length); high = regs[variant].info[bitfield].high; low = regs[variant].info[bitfield].low; + enu = regs[variant].info[bitfield].enu; + } + + uint32 val = (dword >> low) & ((1 << (high-low+1))-1); + if (enu != null) { + weak BitfieldValue? enuval = enu.lookup(val); + if (enuval != null) { return val.to_string() + " (" + enuval.name + ")"; } } - return (dword >> low) & ((1 << (high-low+1))-1); + return val.to_string(); } public void get_value(TreeIter iter, int column, out Value val) @@ -427,7 +436,7 @@ namespace GUI case RowType.BITFIELD: switch (column) { case Columns.NAME: val.set_static_string(bitfield_name(p.target_addr(it.dword-1), it.variant, it.bitfield)); break; - case Columns.VALUE: val.set_string(bitfield_value(p.target_addr(it.dword-1), it.variant, it.bitfield, p[it.dword-1]).to_string()); break; + case Columns.VALUE: val.set_string(bitfield_value(p.target_addr(it.dword-1), it.variant, it.bitfield, p[it.dword-1])); break; case Columns.TARGET: val.set_static_string(""); break; } break; |