"
jv:libgdbs - GNU Debugger Interface Library
Copyright (C) 2015-now Jan Vrany
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"
"{ Package: 'jv:libgdbs' }"
"{ NameSpace: Smalltalk }"
Magritte::MAContainer subclass:#GDBMAContainer
instanceVariableNames:'klass'
classVariableNames:''
poolDictionaries:''
category:'GDB-Support'
!
!GDBMAContainer class methodsFor:'documentation'!
copyright
"
jv:libgdbs - GNU Debugger Interface Library
Copyright (C) 2015-now Jan Vrany
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"
! !
!GDBMAContainer class methodsFor:'instance creation'!
forClass: aClass
^ self new
klass:aClass;
yourself
"Created: / 23-09-2014 / 22:36:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!GDBMAContainer class methodsFor:'testing'!
isAbstract
^ false
"Created: / 23-09-2014 / 22:38:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!GDBMAContainer methodsFor:'accessing'!
klass
^ klass
!
klass:something
klass := something.
!
propertyDescriptorAt: name
^ children detect:[:each | (each accessor isKindOf: GDBMAPropertyAccessor) and:[ each accessor name = name ] ] ifNone:[ nil ]
"Created: / 23-09-2014 / 22:50:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 17-10-2018 / 21:54:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!GDBMAContainer methodsFor:'adding-easy shortcuts'!
define: property as: class
"/ Handle primitive types furst...
| description |
class == Boolean ifTrue:[
description := Magritte::MABooleanDescription new.
] ifFalse:[
class == Integer ifTrue:[
description := Magritte::MANumberDescription new
] ifFalse:[
class == String ifTrue:[
description := Magritte::MAStringDescription new
] ifFalse:[
class == ByteArray ifTrue:[
description :=GDBMAByteArrayDescription new
] ifFalse:[
description := (self descriptionOf: class).
]]]].
description accessor: (GDBMAPropertyAccessor forPropertyNamed: property).
self add: description.
^ description
"Created: / 23-09-2014 / 22:20:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 25-04-2019 / 16:20:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
define: property as: collectionClass of: elementClass
"/ Handle primitive types first...
| description |
elementClass == Boolean ifTrue:[
description := Magritte::MAToManyScalarRelationDescription new.
description reference: Magritte::MABooleanDescription new.
] ifFalse:[
elementClass == Integer ifTrue:[
description := Magritte::MAToManyScalarRelationDescription new.
description reference: Magritte::MANumberDescription new.
] ifFalse:[
elementClass == String ifTrue:[
description := Magritte::MAToManyScalarRelationDescription new.
description reference: Magritte::MAStringDescription new.
] ifFalse:[
elementClass == ByteArray ifTrue:[
description := Magritte::MAToManyScalarRelationDescription new.
description reference: GDBMAByteArrayDescription new.
] ifFalse:[
description := Magritte::MAToManyRelationDescription new.
description reference: (self descriptionOf: elementClass).
]]]].
description accessor: (GDBMAPropertyAccessor forPropertyNamed: property).
description classes: (Array with: elementClass).
description ordered: (collectionClass inheritsFrom: SequenceableCollection).
self add: description.
^ description.
"Created: / 23-09-2014 / 22:54:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 25-04-2019 / 16:19:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
define: property as: collectionClass of: elementClass1 whenTaggedBy: tag1 or: elementClass2 whenTaggedBy: tag2
"/ Handle primitive types first...
| description |
description := Magritte::MAToManyRelationDescription new.
description reference: (
GDBMADescriptionSwitch
forTag: tag1 use: (self descriptionOf: elementClass1)
forTag: tag2 use: (self descriptionOf: elementClass2)
).
description classes: (Array with: elementClass1 with: elementClass2).
description accessor: (GDBMAPropertyAccessor forPropertyNamed: property).
description ordered: (collectionClass inheritsFrom: SequenceableCollection).
self add: description.
^ description.
"Created: / 03-07-2018 / 17:10:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 25-04-2019 / 16:20:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!GDBMAContainer methodsFor:'parsing-GDB/MI'!
parseUsingGDBMIParser:aGDBMIParser
^ aGDBMIParser parseValueAsInstanceOf: klass describedBy: self.
"Created: / 23-09-2014 / 22:32:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!GDBMAContainer methodsFor:'private'!
descriptionOf: aClass
"
Return Magritte descrioption of a given class.
Essentially this is the same as `aClass description` except it
handles the case when `aClass` is the same a `klass`. In that case,
return self.
This is needed to support recursive structures (sich a GDBBreakpoint, where
each location is another breakpoint).
CAVEAT: this does not support mutually recursive structures like that
type A object holds on type B object which holds on another type A object.
To fix this, we'd need to fix Magritte itsef.
"
^ klass == aClass ifTrue:[ self ] ifFalse:[ aClass description ]
"Created: / 25-04-2019 / 16:19:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified (format): / 30-04-2019 / 16:37:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!GDBMAContainer class methodsFor:'documentation'!
version_HG
^ '$Changeset: <not expanded> $'
! !