--- a/InlineObject.st Mon Jan 21 13:15:04 2019 +0100
+++ b/InlineObject.st Mon Jan 21 13:15:58 2019 +0100
@@ -87,6 +87,50 @@
prototype
^ InlineObjectPrototype
+!
+
+slotNames:names values:slotValues
+ "return a new inline object given slot names and slot values"
+
+ |subclass inst|
+
+ Class withoutUpdatingChangesDo:[
+ subclass := self
+ subclass:#someInlineObject
+ instanceVariableNames:names
+ classVariableNames:nil
+ poolDictionaries:nil
+ category:nil
+ inEnvironment:nil.
+ names do:[:each |
+ subclass compile:('%1 ^ %1' bindWith:each)
+ categorized:'accessing'.
+ subclass compile:('%1:arg %1 := arg.' bindWith:each)
+ categorized:'accessing'.
+ ].
+ ].
+ inst := (Array withAll:slotValues) changeClassTo:subclass.
+ ^ inst
+
+ "
+ InlineObject slotNames:#('foo' 'bar' 'baz') values:#(1 2 3)
+ "
+
+ "Created: / 21-01-2019 / 13:10:14 / Claus Gittinger"
+!
+
+slotNamesAndValues:namesAndValues
+ "return a new inline object given slot names and slot values as alternating elements
+ in the argument, namesAndValues"
+
+ ^ self slotNames:(namesAndValues keysAndValuesSelect:[:idx :val | idx odd])
+ values:(namesAndValues keysAndValuesSelect:[:idx :val | idx even])
+
+ "
+ InlineObject slotNamesAndValues:#('foo' 10 'bar' 20 'baz' 30)
+ "
+
+ "Created: / 21-01-2019 / 13:15:46 / Claus Gittinger"
! !
!InlineObject methodsFor:'printing & storing'!
@@ -132,6 +176,8 @@
i1
^ i1
+
+ "Created: / 20-01-2019 / 14:49:52 / Claus Gittinger"
!
i10
@@ -224,10 +270,14 @@
i1:something
i1 := something.
+
+ "Created: / 20-01-2019 / 14:49:52 / Claus Gittinger"
!
i2
^ i2
+
+ "Created: / 20-01-2019 / 14:49:52 / Claus Gittinger"
!
i20
@@ -312,10 +362,14 @@
i2:something
i2 := something.
+
+ "Created: / 20-01-2019 / 14:49:52 / Claus Gittinger"
!
i3
^ i3
+
+ "Created: / 20-01-2019 / 14:49:52 / Claus Gittinger"
!
i30
@@ -400,6 +454,8 @@
i3:something
i3 := something.
+
+ "Created: / 20-01-2019 / 14:49:52 / Claus Gittinger"
!
i4