Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] New ICDIVariableManager methods for the 'DisplayAsArray' and 'CastToType' actions

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/ChangeLog,v
retrieving revision 1.141
diff -u -r1.141 ChangeLog
--- ChangeLog 11 Mar 2003 15:56:04 -0000 1.141
+++ ChangeLog 11 Mar 2003 23:41:51 -0000
@@ -1,3 +1,7 @@
+2003-03-09 Mikhail Khodjaiants
+ New ICDIVariableManager methods for the 'DisplayAsArray' and 'CastToType' actions.
+ * CVariable.java
+
 2003-03-11 Alain Magloire
 
  * src/org/eclipse/cdt/debug/core/cdi/ICDIvariableManager.java:
Index: src/org/eclipse/cdt/debug/internal/core/model/CVariable.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java,v
retrieving revision 1.17
diff -u -r1.17 CVariable.java
--- src/org/eclipse/cdt/debug/internal/core/model/CVariable.java 10 Mar 2003 23:04:18 -0000 1.17
+++ src/org/eclipse/cdt/debug/internal/core/model/CVariable.java 11 Mar 2003 23:41:53 -0000
@@ -5,18 +5,16 @@
  */
 package org.eclipse.cdt.debug.internal.core.model;
 
-import java.text.MessageFormat;
-
 import org.eclipse.cdt.debug.core.cdi.CDIException;
 import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
 import org.eclipse.cdt.debug.core.cdi.event.ICDIChangedEvent;
 import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
 import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener;
-import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
 import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
 import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
 import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
 import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
 import org.eclipse.cdt.debug.core.model.ICValue;
 import org.eclipse.cdt.debug.core.model.ICVariable;
 import org.eclipse.cdt.debug.core.model.ICastToArray;
@@ -430,8 +428,7 @@
  {
   try
   {
-   String newName = MessageFormat.format( "({0})({1})", new String[] { type, getOriginalCDIVariable().getName() } );
-   ICDIVariable newVar = createShadow( getOriginalCDIVariable().getStackFrame(), newName );
+   ICDIVariable newVar = createShadow( getOriginalCDIVariable().getStackFrame(), type );
    ICDIVariable oldVar = getShadow();
    setShadow( newVar );
    if ( oldVar != null )
@@ -510,13 +507,28 @@
   fShadow = shadow;
  }
  
- private ICDIVariable createShadow( ICDIStackFrame cdiFrame, String _expression_ ) throws DebugException
+ private ICDIVariable createShadow( ICDIStackFrame cdiFrame, String type ) throws DebugException
  {
   try
   {
-//   ICDIVariableObject varObject = getCDISession().getVariableManager().getVariableObject( getCDIVariable().getStackFrame(), newName );
-//   return getCDISession().getVariableManager().createVariable( varObject );
-   return getCDISession().getExpressionManager().createExpression( _expression_ );
+   ICDIVariableObject originalVarObject = getCDISession().getVariableManager().getVariableObject( cdiFrame, getOriginalCDIVariable().getName() );
+   ICDIVariableObject varObject = getCDISession().getVariableManager().getVariableObjectAsType( originalVarObject, type );
+   return getCDISession().getVariableManager().createVariable( varObject );
+  }
+  catch( CDIException e )
+  {
+   targetRequestFailed( e.getMessage(), null );
+  }
+  return null;
+ }

+ private ICDIVariable createShadow( ICDIStackFrame cdiFrame, String type, int start, int end ) throws DebugException
+ {
+  try
+  {
+   ICDIVariableObject originalVarObject = getCDISession().getVariableManager().getVariableObject( cdiFrame, getOriginalCDIVariable().getName() );
+   ICDIVariableObject varObject = getCDISession().getVariableManager().getVariableObjectAsArray( originalVarObject, type, start, end );
+   return getCDISession().getVariableManager().createVariable( varObject );
   }
   catch( CDIException e )
   {
@@ -529,8 +541,7 @@
  {
   try
   {
-//   getCDISession().getVariableManager().destroyVariable( shadow );
-   getCDISession().getExpressionManager().destroyExpression( (ICDIExpression)shadow );
+   getCDISession().getVariableManager().destroyVariable( shadow );
   }
   catch( CDIException e )
   {
@@ -551,6 +562,28 @@
   */
  public void castToArray( String type, int startIndex, int endIndex ) throws DebugException
  {
+  try
+  {
+   ICDIVariable newVar = createShadow( getOriginalCDIVariable().getStackFrame(), type, startIndex, endIndex );
+   ICDIVariable oldVar = getShadow();
+   setShadow( newVar );
+   if ( oldVar != null )
+    destroyShadow( oldVar );
+  }
+  catch( CDIException e )
+  {
+   targetRequestFailed( e.getMessage(), null );
+  }
+  finally
+  {
+   if ( fValue != null )
+   {
+    ((CValue)fValue).dispose();
+    fValue = null;
+   }
+   fTypeName = null;
+   fireChangeEvent( DebugEvent.STATE );
+  }
  }
 
  /* (non-Javadoc)

Back to the top