Introduce new internal API `GDBDebuggerObject >> updateFrom:`
to update one ("old") object with another one ("new"). This is used
in cases when we want to preserve an identity of API objects.
--- a/GDBBreakpoint.st Mon Feb 18 10:49:02 2019 +0000
+++ b/GDBBreakpoint.st Mon Feb 25 17:55:20 2019 +0000
@@ -291,21 +291,10 @@
"Created: / 11-07-2017 / 14:11:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-updateFrom: aGDBBreakpoint
- | ignored |
+updateFromIgnoredInstvarNames
+ ^ super updateFromIgnoredInstvarNames , #(locations)
- self assert: number = aGDBBreakpoint number.
- ignored := self class instVarIndexFor: #locations.
- self class superclass instSize + 1 to: self class instSize do:[:i |
- i ~~ ignored ifTrue:[
- self instVarAt: i put: (aGDBBreakpoint instVarAt: i).
- ].
- ].
- properties := aGDBBreakpoint properties.
-
- "Created: / 06-07-2017 / 16:30:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 15-01-2018 / 23:12:02 / jv"
- "Modified: / 18-05-2018 / 21:44:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 25-02-2019 / 16:25:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!GDBBreakpoint methodsFor:'testing'!
--- a/GDBDebuggerObject.st Mon Feb 18 10:49:02 2019 +0000
+++ b/GDBDebuggerObject.st Mon Feb 25 17:55:20 2019 +0000
@@ -83,6 +83,43 @@
].
"Created: / 04-02-2018 / 21:27:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+updateFrom: anotherObject
+ "Update receiver from `anotherObject`. This can be (is) used to update
+ existing objects from 'new' ones in order to preseve identity of objects."
+
+ | names ignored |
+
+ self assert: self class == anotherObject class.
+ self assert: (debugger == anotherObject debugger or:[anotherObject debugger isNil]).
+
+ names := self class allInstVarNames.
+ ignored := self updateFromIgnoredInstvarNames collect:[ :name | names indexOf: name ].
+ 1 to: self class instSize do:[:index |
+ (ignored includes: index) ifFalse:[
+ self instVarAt: index put: (anotherObject instVarAt: index).
+ ].
+ ].
+
+ "Created: / 25-02-2019 / 15:04:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 25-02-2019 / 17:37:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+updateFromIgnoredInstvarNames
+ "Return an array of instvar names to be ignored (skipped) when
+ updating old object with 'new' one. See #updateFrom:.
+
+ When overriding, *always* concatenate with super, i.e.,
+
+ updateFromIgnoredInstvarNames
+ ^ super updateFromIgnoredInstvarNames , #(some instvar)
+
+ "
+ ^ #(debugger)
+
+ "Created: / 25-02-2019 / 15:06:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 25-02-2019 / 16:27:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!GDBDebuggerObject methodsFor:'testing'!
--- a/GDBFrame.st Mon Feb 18 10:49:02 2019 +0000
+++ b/GDBFrame.st Mon Feb 25 17:55:20 2019 +0000
@@ -233,8 +233,9 @@
oldVar := old at: i.
newVar := new at: i.
- newVar name = oldVar name ifTrue:[
- new at: i put: (old at: i)
+ newVar name = oldVar name ifTrue:[
+ oldVar updateFrom: newVar.
+ new at: i put: oldVar.
].
].
] ifFalse:[
@@ -252,7 +253,7 @@
^ variables value
"Created: / 27-02-2015 / 14:56:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 05-07-2018 / 11:10:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 25-02-2019 / 17:42:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!GDBFrame methodsFor:'initialization'!
--- a/GDBVariable.st Mon Feb 18 10:49:02 2019 +0000
+++ b/GDBVariable.st Mon Feb 25 17:55:20 2019 +0000
@@ -212,6 +212,14 @@
"Modified (comment): / 12-06-2017 / 09:26:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!GDBVariable methodsFor:'private'!
+
+updateFromIgnoredInstvarNames
+ ^ super updateFromIgnoredInstvarNames , #(varobj)
+
+ "Created: / 25-02-2019 / 17:43:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!GDBVariable methodsFor:'testing'!
hasChanged