Index:
ChangeLog =================================================================== RCS
file: /home/tools/org.eclipse.cdt.debug.core/ChangeLog,v retrieving revision
1.138 diff -u -r1.138 ChangeLog --- ChangeLog 25 Feb 2003 01:48:05
-0000 1.138 +++ ChangeLog 9 Mar 2003 22:44:34 -0000 @@ -1,3
+1,10 @@ +2003-03-09 Mikhail Khodjaiants + Core support of the "Cast
To Type" and "Restore Default Type" actions. + * ICastToType.java:
new + * CLocalVariable.java + * CStackFrame.java + *
CVariable.java + 2003-02-24 Alain
Magloire *
src/org/eclipse/cdt/debug/core/cdi/ICDIRegisterObject.java: Index:
src/org/eclipse/cdt/debug/core/model/ICastToType.java =================================================================== RCS
file: src/org/eclipse/cdt/debug/core/model/ICastToType.java diff -N
src/org/eclipse/cdt/debug/core/model/ICastToType.java --- /dev/null 1
Jan 1970 00:00:00 -0000 +++
src/org/eclipse/cdt/debug/core/model/ICastToType.java 9 Mar 2003 22:44:35
-0000 @@ -0,0 +1,28 @@ +/* + *(c) Copyright QNX Software Systems Ltd.
2002. + * All Rights Reserved. + * + */ + +package
org.eclipse.cdt.debug.core.model; + +import
org.eclipse.core.runtime.IAdaptable; +import
org.eclipse.debug.core.DebugException; + +/** + * Enter type
comment. + * + * @since Mar 7, 2003 + */ +public interface
ICastToType extends IAdaptable +{ + boolean
supportsCasting(); + + String
getCurrentType(); + + void cast( String type ) throws
DebugException; + + void restoreDefault() throws
DebugException; + + boolean isCasted(); +} Index:
src/org/eclipse/cdt/debug/internal/core/model/CLocalVariable.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CLocalVariable.java,v retrieving
revision 1.5 diff -u -r1.5 CLocalVariable.java ---
src/org/eclipse/cdt/debug/internal/core/model/CLocalVariable.java 2 Oct
2002 19:37:13 -0000 1.5 +++
src/org/eclipse/cdt/debug/internal/core/model/CLocalVariable.java 9 Mar
2003 22:44:35 -0000 @@ -6,6 +6,9 @@ package
org.eclipse.cdt.debug.internal.core.model; import
org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; +import
org.eclipse.cdt.debug.core.model.ICValue; +import
org.eclipse.debug.core.DebugException; +import
org.eclipse.debug.core.model.IValue; /** * @@
-15,12 +18,36 @@ */ public class CLocalVariable extends
CModificationVariable { - /** - * Constructor for
CLocalVariable. - * @param target - */ public
CLocalVariable( CDebugElement parent, ICDIVariable cdiVariable
) { super( parent, cdiVariable
); } + + /* (non-Javadoc) + * @see
org.eclipse.cdt.debug.core.model.ICastToType#supportsCasting() +
*/ + public boolean
supportsCasting() + { + boolean enabled =
false; + try + { + IValue value
= getValue(); + if ( value instanceof ICValue
) + { + switch(
((ICValue)value).getType()
) + { + case
ICValue.TYPE_SIMPLE: + case
ICValue.TYPE_POINTER: + case
ICValue.TYPE_CHAR: + enabled =
true; + break; + } + } + } + catch(
DebugException e ) + { + logError( e
); + } + return
enabled; + } } Index:
src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java,v retrieving
revision 1.16 diff -u -r1.16 CStackFrame.java ---
src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java 4 Feb 2003
23:47:54 -0000 1.16 +++
src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java 9 Mar 2003
22:44:36 -0000 @@ -129,7 +129,7 @@ while( index <
fVariables.size()
) { CLocalVariable local =
(CLocalVariable)fVariables.get( index ); - ICDIVariable var
= findVariable( locals, local.getCDIVariable()
); + ICDIVariable var = findVariable( locals,
local.getOriginalCDIVariable() ); if ( var != null
) { locals.remove(
var ); @@ -684,7 +684,7 @@ for ( int i = 0; i <
vars.length; ++i ) { if (
vars[i] instanceof CLocalVariable && -
((CLocalVariable)vars[i]).getCDIVariable() instanceof ICDIArgument
) +
((CLocalVariable)vars[i]).getOriginalCDIVariable() instanceof ICDIArgument
) { list.add(
vars[i] ); } 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.14 diff -u -r1.14 CVariable.java ---
src/org/eclipse/cdt/debug/internal/core/model/CVariable.java 17 Dec 2002
18:42:49 -0000 1.14 +++
src/org/eclipse/cdt/debug/internal/core/model/CVariable.java 9 Mar 2003
22:44:37 -0000 @@ -5,16 +5,21 @@ */ 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.model.ICValue; import
org.eclipse.cdt.debug.core.model.ICVariable; +import
org.eclipse.cdt.debug.core.model.ICastToType; import
org.eclipse.debug.core.DebugEvent; import
org.eclipse.debug.core.DebugException; import
org.eclipse.debug.core.model.IDebugTarget; @@ -29,7 +34,8 @@
*/ public abstract class CVariable extends CDebugElement
implements
ICVariable, -
ICDIEventListener +
ICDIEventListener, +
ICastToType { /** * The parent object
this variable is contained in. @@ -42,6 +48,11 @@ private
ICDIVariable fCDIVariable; /** + * The
shadow CDI variable used for casting. + */ + private
ICDIVariable fShadow; + + /** * Cache of
current value - see #getValue(). */ protected
ICValue fValue; @@ -79,6 +90,7 @@ super(
(CDebugTarget)parent.getDebugTarget() ); fParent =
parent; fCDIVariable = cdiVariable; + fShadow
= null; getCDISession().getEventManager().addEventListener(
this ); } @@ -158,6 +170,8 @@
*/ public Object getAdapter( Class adapter
) { + if ( adapter.equals( ICastToType.class )
) + return this; if ( adapter.equals(
IVariable.class ) ) return
this; if ( adapter.equals( ICVariable.class ) ) @@
-229,6 +243,15
@@ ((CValue)fValue).dispose(); } getCDISession().getEventManager().removeEventListener(
this ); + try + { + if (
getShadow() != null ) + destroyShadow( getShadow()
); + } + catch( DebugException e
) + { + logError( e
); + } } protected
synchronized void setChanged( boolean changed ) throws DebugException @@
-300,12 +323,9 @@ */ protected ICDIVariable
getCDIVariable() { - return
fCDIVariable; - } - - protected void setCDIVariable(
ICDIVariable newVar ) - { - fCDIVariable =
newVar; + if ( fShadow != null ) + return
fShadow; + return
getOriginalCDIVariable(); } /** @@
-325,7 +345,7 @@ String name =
null; try { - name
= getCDIVariable().getName(); + name =
getOriginalCDIVariable().getName(); } catch(
CDIException e ) { @@ -390,5 +410,126
@@ { ((ICValue)getValue()).setChanged( true
); fireChangeEvent( DebugEvent.STATE
); + } + + /* (non-Javadoc) + * @see
org.eclipse.cdt.debug.core.model.ICastToType#cast(java.lang.String) +
*/ + public void cast( String type ) throws
DebugException + { + try + { + String
newName = MessageFormat.format( "({0})({1})", new String[] { type,
getOriginalCDIVariable().getName() } ); + ICDIVariable
newVar = createShadow( getOriginalCDIVariable().getStackFrame(), newName
); + 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; + } + fireChangeEvent(
DebugEvent.STATE ); + } + } + + /*
(non-Javadoc) + * @see
org.eclipse.cdt.debug.core.model.ICastToType#getCurrentType() +
*/ + public String
getCurrentType() + { + try + { + return
getReferenceTypeName(); + } + catch( DebugException
e ) + { + logError( e
); + } + return ""; + } + + /*
(non-Javadoc) + * @see
org.eclipse.cdt.debug.core.model.ICastToType#restoreDefault() +
*/ + public void restoreDefault() throws
DebugException + { + ICDIVariable oldVar =
getShadow(); + setShadow( null ); + if ( oldVar !=
null ) + destroyShadow( oldVar ); + if (
fValue != null
) + { + ((CValue)fValue).dispose(); + fValue
= null; + } + fireChangeEvent( DebugEvent.STATE
); + } + + /* (non-Javadoc) + * @see
org.eclipse.cdt.debug.core.model.ICastToType#supportsCasting() +
*/ + public boolean supportsCasting() + { + return
false; + } + + protected ICDIVariable
getOriginalCDIVariable() + { + return
fCDIVariable; + } + + private ICDIVariable
getShadow() + { + return
fShadow; + } + + private void setShadow( ICDIVariable shadow
) + { + fShadow =
shadow; + } + + private ICDIVariable createShadow(
ICDIStackFrame cdiFrame, String _expression_ ) throws
DebugException + { + try + { +// ICDIVariableObject
varObject = getCDISession().getVariableManager().getVariableObject(
getCDIVariable().getStackFrame(), newName ); +// return
getCDISession().getVariableManager().createVariable( varObject
); + return
getCDISession().getExpressionManager().createExpression( _expression_
); + } + catch( CDIException e
) + { + targetRequestFailed( e.getMessage(),
null ); + } + return
null; + } + + private void destroyShadow( ICDIVariable
shadow ) throws
DebugException + { + try + { +// getCDISession().getVariableManager().destroyVariable(
shadow
); + getCDISession().getExpressionManager().destroyExpression(
(ICDIExpression)shadow ); + } + catch( CDIException
e ) + { + targetRequestFailed( e.getMessage(),
null ); + } + } + + /* (non-Javadoc) +
* @see org.eclipse.cdt.debug.core.model.ICastToType#isCasted() +
*/ + public boolean isCasted() + { + return (
getShadow() != null
); } }
|