Skip to content

Commit

Permalink
- add test testDoubleArraysHaveCorrectLayout
Browse files Browse the repository at this point in the history
- fix MC #kindOfSubclass to ask the layout for a string
- add minimal old style class definition methods for DoubleWord and DoubleByte subclasses
- change the layout of DoubleByteArray/DoubleWordArray, the fixes make sure that Iceberg does indeed save this fix

fixes #5956
  • Loading branch information
MarcusDenker committed Oct 1, 2020
1 parent 4a5cfab commit 5e764be
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Collections-Native/DoubleByteArray.class.st
Expand Up @@ -6,7 +6,7 @@ For further comments read comments of `WordArray`.
Class {
#name : #DoubleByteArray,
#superclass : #ArrayedCollection,
#type : #words,
#type : #DoubleByteLayout,
#category : #'Collections-Native-Base'
}

Expand Down
2 changes: 1 addition & 1 deletion src/Collections-Native/DoubleWordArray.class.st
Expand Up @@ -6,7 +6,7 @@ For further comments read comments of `WordArray`.
Class {
#name : #DoubleWordArray,
#superclass : #ArrayedCollection,
#type : #words,
#type : #DoubleWordLayout,
#category : #'Collections-Native-Base'
}

Expand Down
6 changes: 6 additions & 0 deletions src/Collections-Tests/NativeArrayTest.class.st
Expand Up @@ -91,6 +91,12 @@ NativeArrayTest >> testAtPutExactSizeNumber [
]
]

{ #category : #tests }
NativeArrayTest >> testDoubleArraysHaveCorrectLayout [
self assert: DoubleWordArray classLayout class equals: DoubleWordLayout.
self assert: DoubleByteArray classLayout class equals: DoubleByteLayout
]

{ #category : #tests }
NativeArrayTest >> testReplaceFromToWithStartingAt [
"Makes sure the primitive works correctly with different data structures"
Expand Down
3 changes: 2 additions & 1 deletion src/Kernel/AbstractLayout.class.st
Expand Up @@ -120,7 +120,8 @@ AbstractLayout >> isWeak [

{ #category : #accessing }
AbstractLayout >> kindOfSubclass [
^self subclassResponsibility
"As a fallback we just return a standard class creation substring. This will be called for user defined Layouts, for old style class definitions that can not support user defined Layouts"
^' subclass: '
]

{ #category : #accessing }
Expand Down
30 changes: 30 additions & 0 deletions src/Kernel/Class.class.st
Expand Up @@ -1409,6 +1409,36 @@ Class >> variableByteSubclass: t instanceVariableNames: f classVariableNames: d
environment: self environment ]
]

{ #category : #'subclass creation - variableByte' }
Class >> variableDoubleByteSubclass: className instanceVariableNames: instVarNameList classVariableNames: classVarNames package: cat [

^ self classInstaller
make: [ :builder |
builder
superclass: self;
name: className;
layoutClass: DoubleByteLayout;
slots: instVarNameList asSlotCollection;
sharedVariablesFromString: classVarNames;
category: cat;
environment: self environment ]
]

{ #category : #'subclass creation - variableByte' }
Class >> variableDoubleWordSubclass: className instanceVariableNames: instVarNameList classVariableNames: classVarNames package: cat [

^ self classInstaller
make: [ :builder |
builder
superclass: self;
name: className;
layoutClass: DoubleWordLayout;
slots: instVarNameList asSlotCollection;
sharedVariablesFromString: classVarNames;
category: cat;
environment: self environment ]
]

{ #category : #'subclass creation - deprecated' }
Class >> variableSubclass: className instanceVariableNames: instVarNameList classVariableNames: classVarNames category: cat [
"Added to allow for a simplified subclass creation experience. "
Expand Down
2 changes: 1 addition & 1 deletion src/Monticello/MCClassDefinition.class.st
Expand Up @@ -353,7 +353,7 @@ MCClassDefinition >> kindOfSubclass [
type = #immediate ifTrue: [ ^ ' immediateSubclass: ' ].
type = #ephemeron ifTrue: [ ^ ' ephemeronSubclass: ' ].
"hack to support user defined layouts"
(Smalltalk hasClassNamed: type) ifTrue: [ ^type asString].
(Smalltalk hasClassNamed: type) ifTrue: [ ^(Smalltalk globals at: type) new kindOfSubclass].
self error: 'Unrecognized class type'
]

Expand Down

0 comments on commit 5e764be

Please sign in to comment.