GSM48: Refactor and share code to add variables
This commit is contained in:
parent
42f49c05c3
commit
d29b9b973a
18
GSM48.st
18
GSM48.st
|
@ -557,12 +557,17 @@ IEMessage subclass: GSM48MSG [
|
|||
<category: 'osmo-message'>
|
||||
<comment: 'GSM48 has helper code for mandantory types'>
|
||||
|
||||
GSM48MSG class >> addVariable: aName [
|
||||
"Check if the variable exists, otherwise add it"
|
||||
(self instVarNames includes: aName)
|
||||
ifFalse: [
|
||||
self addInstVarName: aName.
|
||||
].
|
||||
]
|
||||
|
||||
GSM48MSG class >> addMandantory: aName with: aClass [
|
||||
<comment: 'creation'>
|
||||
(self instVarNames includes: aName asSymbol)
|
||||
ifFalse: [
|
||||
self addInstVarName: aName asSymbol.
|
||||
].
|
||||
self addVariable: aName asSymbol.
|
||||
self compile: '%1 [ ^ %1 ifNil: [%1 := %2 createDefault.]]' % {aName. aClass}.
|
||||
self Mandantory add: (aName asSymbol -> aClass).
|
||||
]
|
||||
|
@ -575,10 +580,7 @@ IEMessage subclass: GSM48MSG [
|
|||
self error: 'Class should not be null for ', aName
|
||||
].
|
||||
|
||||
(self instVarNames includes: aName asSymbol)
|
||||
ifFalse: [
|
||||
self addInstVarName: aName asSymbol.
|
||||
].
|
||||
self addVariable: aName asSymbol.
|
||||
self compile: '%1 [ ^ %1 ]' % {aName}.
|
||||
self Optional add: (aName asSymbol -> aClass).
|
||||
]
|
||||
|
|
Reference in New Issue