Permalink
Browse files

refactored CorValue display code out of _input_locals_cmd and into di…

…spaly_value
  • Loading branch information...
1 parent 1d6b8dc commit 9dd12dadb79469ceac57b84b8adb1b0b531337c4 @devhawk committed Mar 28, 2009
Showing with 15 additions and 14 deletions.
  1. +15 −14 ipydbg.py
View
@@ -223,7 +223,17 @@ def extract_value(value):
else:
raise (Exception,
"<processing CorValue of type: %s not implemented>" % str(value.Type))
-
+
+def display_value(value):
+ if type(value) == str:
+ return (('"%s"' % value), 'System.String')
+ elif type(value) == CorObjectValue:
+ return ("<...>", value.ExactType.Class.GetTypeInfo().FullName)
+ elif type(value) == NullCorValue:
+ return ("<None>", value.typename)
+ else:
+ return (str(value), value.GetType().FullName)
+
#--------------------------------------------
# main IPyDebugProcess class
@@ -313,20 +323,11 @@ def _input_locals_cmd(self, keyinfo):
locals = get_locals(self.active_thread.ActiveFrame, show_hidden_locals = show_hidden)
count = 0
for name,value in ((name, extract_value(value)) for name, value in locals):
- count = count + 1
+ display, type_name = display_value(value)
with CC.Magenta: print " ", name,
-
- if type(value) == CorObjectValue:
- print "<...>",
- with CC.Green:
- print value.ExactType.Class.GetTypeInfo().FullName
- elif type(value) == NullCorValue:
- print "<None>",
- with CC.Green:
- print value.typename
- else:
- print value if type(value) != unicode else '"%s"' % value,
- with CC.Green: print value.GetType().FullName
+ print display,
+ with CC.Green: print type_name
+ count+=1
else:
if count == 0:
with CC.Magenta: print " No Locals Found"

0 comments on commit 9dd12da

Please sign in to comment.