1
0
Fork 0

GSM48: Refactor and share code to add variables

This commit is contained in:
Holger Hans Peter Freyther 2010-12-02 00:00:42 +01:00
parent 42f49c05c3
commit d29b9b973a
1 changed files with 10 additions and 8 deletions

View File

@ -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).
]