nemiver r690 - in trunk: . src/persp/dbgperspective
- From: dodji svn gnome org
- To: svn-commits-list gnome org
- Subject: nemiver r690 - in trunk: . src/persp/dbgperspective
- Date: Thu, 17 Jan 2008 22:07:09 +0000 (GMT)
Author: dodji
Date: Thu Jan 17 22:07:08 2008
New Revision: 690
URL: http://svn.gnome.org/viewvc/nemiver?rev=690&view=rev
Log:
[variables-utils] Added find_a_variable()
* src/persp/dbgperspective/nmv-variables-utils2.cc,h:
added find_a_variable(), to find a variable under a given
node. Made update_variable() use it.
Did a bit of cleanup.
Modified:
trunk/ChangeLog
trunk/src/persp/dbgperspective/nmv-variables-utils2.cc
trunk/src/persp/dbgperspective/nmv-variables-utils2.h
Modified: trunk/src/persp/dbgperspective/nmv-variables-utils2.cc
==============================================================================
--- trunk/src/persp/dbgperspective/nmv-variables-utils2.cc (original)
+++ trunk/src/persp/dbgperspective/nmv-variables-utils2.cc Thu Jan 17 22:07:08 2008
@@ -34,167 +34,177 @@
NEMIVER_BEGIN_NAMESPACE (nemiver)
NEMIVER_BEGIN_NAMESPACE (variables_utils2)
-static void update_a_variable_real (const IDebugger::VariableSafePtr &a_var,
+static void update_a_variable_real (const IDebugger::VariableSafePtr a_var,
const Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator &a_row_it,
bool a_handle_highlight,
- bool a_is_new_frame) ;
+ bool a_is_new_frame);
VariableColumns&
get_variable_columns ()
{
- static VariableColumns s_cols ;
- return s_cols ;
+ static VariableColumns s_cols;
+ return s_cols;
}
bool
is_type_a_pointer (const UString &a_type)
{
- LOG_FUNCTION_SCOPE_NORMAL_DD ;
- LOG_DD ("type: '" << a_type << "'") ;
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
+ LOG_DD ("type: '" << a_type << "'");
UString type (a_type);
- type.chomp () ;
+ type.chomp ();
if (type[type.size () - 1] == '*') {
- LOG_DD ("type is a pointer") ;
- return true ;
+ LOG_DD ("type is a pointer");
+ return true;
}
if (type.size () < 8) {
- LOG_DD ("type is not a pointer") ;
- return false ;
+ LOG_DD ("type is not a pointer");
+ return false;
}
- UString::size_type i = type.size () - 7 ;
+ UString::size_type i = type.size () - 7;
if (!a_type.compare (i, 7, "* const")) {
- LOG_DD ("type is a pointer") ;
- return true ;
+ LOG_DD ("type is a pointer");
+ return true;
}
- LOG_DD ("type is not a pointer") ;
- return false ;
+ LOG_DD ("type is not a pointer");
+ return false;
}
void
set_a_variable_node_type (Gtk::TreeModel::iterator &a_var_it,
const UString &a_type)
{
- THROW_IF_FAIL (a_var_it) ;
+ THROW_IF_FAIL (a_var_it);
a_var_it->set_value (get_variable_columns ().type,
- (Glib::ustring)a_type) ;
- int nb_lines = a_type.get_number_of_lines () ;
- UString type_caption = a_type ;
+ (Glib::ustring)a_type);
+ int nb_lines = a_type.get_number_of_lines ();
+ UString type_caption = a_type;
if (nb_lines) {--nb_lines;}
- UString::size_type truncation_index = 0 ;
- static const UString::size_type MAX_TYPE_STRING_LENGTH = 15 ;
+ UString::size_type truncation_index = 0;
+ static const UString::size_type MAX_TYPE_STRING_LENGTH = 15;
if (nb_lines) {
- truncation_index = a_type.find ('\n') ;
+ truncation_index = a_type.find ('\n');
} else if (a_type.size () > MAX_TYPE_STRING_LENGTH) {
- truncation_index = MAX_TYPE_STRING_LENGTH ;
+ truncation_index = MAX_TYPE_STRING_LENGTH;
}
if (truncation_index) {
- type_caption.erase (truncation_index) ;
- type_caption += "..." ;
+ type_caption.erase (truncation_index);
+ type_caption += "...";
}
a_var_it->set_value (get_variable_columns ().type_caption,
- (Glib::ustring)type_caption) ;
+ (Glib::ustring)type_caption);
IDebugger::VariableSafePtr variable =
(IDebugger::VariableSafePtr) a_var_it->get_value
(get_variable_columns ().variable);
- THROW_IF_FAIL (variable) ;
- variable->type (a_type) ;
+ THROW_IF_FAIL (variable);
+ variable->type (a_type);
}
void
-update_a_variable_node (const IDebugger::VariableSafePtr &a_var,
+update_a_variable_node (const IDebugger::VariableSafePtr a_var,
const Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator &a_iter,
bool a_handle_highlight,
bool a_is_new_frame)
{
- LOG_FUNCTION_SCOPE_NORMAL_DD ;
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
if (a_var) {
- LOG_DD ("going to really update variable '" << a_var->name () << "'") ;
+ LOG_DD ("going to really update variable '"
+ << a_var->name ()
+ << "'");
} else {
- LOG_DD ("eek, got null variable") ;
- return ;
+ LOG_DD ("eek, got null variable");
+ return;
}
- (*a_iter)[get_variable_columns ().variable] = a_var ;
- UString var_name = a_var->name ();
- var_name.chomp () ;
+ (*a_iter)[get_variable_columns ().variable] = a_var;
+ UString var_name = a_var->name_caption ();
+ var_name.chomp ();
UString prev_var_name =
- (Glib::ustring)(*a_iter)[get_variable_columns ().name] ;
- LOG_DD ("Prev variable name: " << prev_var_name) ;
- LOG_DD ("new variable name: " << var_name) ;
- LOG_DD ("Didn't update variable name") ;
+ (Glib::ustring)(*a_iter)[get_variable_columns ().name];
+ LOG_DD ("Prev variable name: " << prev_var_name);
+ LOG_DD ("new variable name: " << var_name);
+ LOG_DD ("Didn't update variable name");
if (prev_var_name.raw () == "") {
(*a_iter)[get_variable_columns ().name] = var_name;
}
- (*a_iter)[get_variable_columns ().is_highlighted]=false ;
- bool do_highlight = false ;
+ (*a_iter)[get_variable_columns ().is_highlighted]=false;
+ bool do_highlight = false;
if (a_handle_highlight && !a_is_new_frame) {
UString prev_value =
- (UString) (*a_iter)[get_variable_columns ().value] ;
+ (UString) (*a_iter)[get_variable_columns ().value];
if (prev_value != a_var->value ()) {
- do_highlight = true ;
+ do_highlight = true;
}
}
if (do_highlight) {
- LOG_DD ("do highlight variable") ;
+ LOG_DD ("do highlight variable");
(*a_iter)[get_variable_columns ().is_highlighted]=true;
(*a_iter)[get_variable_columns ().fg_color] = Gdk::Color ("red");
} else {
- LOG_DD ("remove highlight from variable") ;
+ LOG_DD ("remove highlight from variable");
(*a_iter)[get_variable_columns ().is_highlighted]=false;
(*a_iter)[get_variable_columns ().fg_color] =
a_tree_view.get_style ()->get_text (Gtk::STATE_NORMAL);
}
- (*a_iter)[get_variable_columns ().value] = a_var->value () ;
- set_a_variable_node_type (a_iter, a_var->type ()) ;
+ (*a_iter)[get_variable_columns ().value] = a_var->value ();
+ set_a_variable_node_type (a_iter, a_var->type ());
+}
+
+bool
+find_a_variable (const IDebugger::VariableSafePtr a_var,
+ const Gtk::TreeModel::iterator &a_parent_row_it,
+ Gtk::TreeModel::iterator &a_out_row_it)
+{
+ RETURN_VAL_IF_FAIL (a_var && a_parent_row_it, false);
+
+ Gtk::TreeModel::iterator row_it;
+ IDebugger::VariableSafePtr var;
+ for (row_it = a_parent_row_it->children ().begin ();
+ row_it != a_parent_row_it->children ().end ();
+ ++row_it) {
+ var = row_it->get_value (get_variable_columns ().variable);
+ if (!var) {
+ LOG_ERROR ("hit a null variable");
+ continue;
+ }
+ LOG_DD ("reading var: " << var->name ());
+ if (var->name ().raw () == a_var->name ().raw ()) {
+ a_out_row_it = row_it;
+ return true;
+ }
+ }
+ return false;
}
void
-update_a_variable (const IDebugger::VariableSafePtr &a_var,
+update_a_variable (const IDebugger::VariableSafePtr a_var,
const Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator &a_parent_row_it,
bool a_handle_highlight,
bool a_is_new_frame)
{
- LOG_FUNCTION_SCOPE_NORMAL_DD ;
- THROW_IF_FAIL (a_parent_row_it) ;
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
+ THROW_IF_FAIL (a_parent_row_it);
- Gtk::TreeModel::iterator row_it ;
- bool found=false;
- for (row_it = a_parent_row_it->children ().begin ();
- row_it != a_parent_row_it->children ().end ();
- ++row_it) {
- IDebugger::VariableSafePtr var =
- row_it->get_value (get_variable_columns ().variable);
- if (!var) {
- LOG_ERROR ("hit a null variable") ;
- continue ;
- }
- LOG_DD ("reading var: " << var->name ()) ;
- if (var->name ().raw () == a_var->name ().raw () /*&&
- var->type ().raw () == a_var->type ().raw ()*/) {
- found = true ;
- break ;
- }
- }
- if (!found) {
- THROW ("could not find variable in inspector: " + a_var->name ()) ;
- }
- update_a_variable_real (a_var,
- a_tree_view,
- row_it,
- a_handle_highlight,
- a_is_new_frame) ;
+ Gtk::TreeModel::iterator row_it;
+ if (!find_a_variable (a_var, a_parent_row_it, row_it)) {
+ THROW ("could not find variable in inspector: "
+ + a_var->name ());
+ }
+ update_a_variable_real (a_var, a_tree_view,
+ row_it, a_handle_highlight,
+ a_is_new_frame);
}
static void
-update_a_variable_real (const IDebugger::VariableSafePtr &a_var,
+update_a_variable_real (const IDebugger::VariableSafePtr a_var,
const Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator &a_row_it,
bool a_handle_highlight,
@@ -204,7 +214,7 @@
a_tree_view,
a_row_it,
a_handle_highlight,
- a_is_new_frame) ;
+ a_is_new_frame);
Gtk::TreeModel::iterator row_it;
list<IDebugger::VariableSafePtr>::const_iterator var_it;
Gtk::TreeModel::Children rows = a_row_it->children ();
@@ -215,45 +225,45 @@
++row_it, ++var_it) {
update_a_variable_real (*var_it, a_tree_view,
row_it, a_handle_highlight,
- a_is_new_frame) ;
+ a_is_new_frame);
}
}
void
-append_a_variable (const IDebugger::VariableSafePtr &a_var,
+append_a_variable (const IDebugger::VariableSafePtr a_var,
const Gtk::TreeView &a_tree_view,
const Glib::RefPtr<Gtk::TreeStore> &a_tree_store,
Gtk::TreeModel::iterator &a_parent_row_it)
{
- LOG_FUNCTION_SCOPE_NORMAL_DD ;
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
- Gtk::TreeModel::iterator row_it ;
+ Gtk::TreeModel::iterator row_it;
append_a_variable (a_var, a_tree_view, a_tree_store,
- a_parent_row_it, row_it) ;
+ a_parent_row_it, row_it);
}
void
-append_a_variable (const IDebugger::VariableSafePtr &a_var,
+append_a_variable (const IDebugger::VariableSafePtr a_var,
const Gtk::TreeView &a_tree_view,
const Glib::RefPtr<Gtk::TreeStore> &a_tree_store,
Gtk::TreeModel::iterator &a_parent_row_it,
Gtk::TreeModel::iterator &a_result)
{
- LOG_FUNCTION_SCOPE_NORMAL_DD ;
- THROW_IF_FAIL (a_tree_store) ;
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
+ THROW_IF_FAIL (a_tree_store);
- Gtk::TreeModel::iterator row_it ;
+ Gtk::TreeModel::iterator row_it;
if (!a_parent_row_it) {
- row_it = a_tree_store->append () ;
+ row_it = a_tree_store->append ();
} else {
- row_it = a_tree_store->append (a_parent_row_it->children ()) ;
+ row_it = a_tree_store->append (a_parent_row_it->children ());
}
- update_a_variable_node (a_var, a_tree_view, row_it, true, true) ;
+ update_a_variable_node (a_var, a_tree_view, row_it, true, true);
list<IDebugger::VariableSafePtr>::const_iterator it;
for (it = a_var->members ().begin (); it != a_var->members ().end (); ++it) {
- append_a_variable (*it, a_tree_view, a_tree_store, row_it) ;
+ append_a_variable (*it, a_tree_view, a_tree_store, row_it);
}
- a_result = row_it ;
+ a_result = row_it;
}
Modified: trunk/src/persp/dbgperspective/nmv-variables-utils2.h
==============================================================================
--- trunk/src/persp/dbgperspective/nmv-variables-utils2.h (original)
+++ trunk/src/persp/dbgperspective/nmv-variables-utils2.h Thu Jan 17 22:07:08 2008
@@ -74,28 +74,32 @@
void set_a_variable_node_type (Gtk::TreeModel::iterator &a_var_it,
const UString &a_type) ;
-void update_a_variable_node (const IDebugger::VariableSafePtr &a_var,
+void update_a_variable_node (const IDebugger::VariableSafePtr a_var,
const Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator &a_iter,
bool a_handle_highlight,
bool a_is_new_frame) ;
-void update_a_variable (const IDebugger::VariableSafePtr &a_var,
+bool find_a_variable (const IDebugger::VariableSafePtr a_var,
+ const Gtk::TreeModel::iterator &a_parent_row_it,
+ Gtk::TreeModel::iterator &a_out_row_it);
+
+void update_a_variable (const IDebugger::VariableSafePtr a_var,
const Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator &a_parent_row_it,
bool a_handle_highlight,
bool a_is_new_frame) ;
-void append_a_variable (const IDebugger::VariableSafePtr &a_var,
+void append_a_variable (const IDebugger::VariableSafePtr a_var,
const Gtk::TreeView &a_tree_view,
const Glib::RefPtr<Gtk::TreeStore> &a_tree_store,
Gtk::TreeModel::iterator &a_parent_row_it) ;
-void append_a_variable (const IDebugger::VariableSafePtr &a_var,
+void append_a_variable (const IDebugger::VariableSafePtr a_var,
const Gtk::TreeView &a_tree_view,
const Glib::RefPtr<Gtk::TreeStore> &a_tree_store,
Gtk::TreeModel::iterator &a_parent_row_it,
- Gtk::TreeModel::iterator &a_result /*the resulting row*/);
+ Gtk::TreeModel::iterator &a_result);
NEMIVER_END_NAMESPACE (variables_utils2)
NEMIVER_END_NAMESPACE (nemiver)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]