forked from pharo-project/pharo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync to latest version of STON and add BaselineOfSton
- Loading branch information
Sven Van Caekenberghe
committed
Nov 19, 2019
1 parent
ab7728f
commit 80ebdd2
Showing
44 changed files
with
839 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
" | ||
I am BaselineOfSton, I load STON (Smalltalk Object Notation). | ||
I am a BaselineOf. | ||
" | ||
Class { | ||
#name : #BaselineOfSton, | ||
#superclass : #BaselineOf, | ||
#category : #BaselineOfSton | ||
} | ||
|
||
{ #category : #baselines } | ||
BaselineOfSton >> baseline: spec [ | ||
<baseline> | ||
spec | ||
for: #common | ||
do: [ spec blessing: #baseline. | ||
spec | ||
package: 'STON-Core'; | ||
package: 'STON-Tests'; | ||
package: 'STON-Text support'; | ||
group: 'Core' with: #('STON-Core'); | ||
group: 'default' with: #('STON-Core' 'STON-Text support' 'STON-Tests') ] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Package { #name : #BaselineOfSton } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Extension { #name : #Bag } | ||
|
||
{ #category : #'*STON-Core' } | ||
Bag class >> fromSton: stonReader [ | ||
"Read a map representation containing element/occurences pairs" | ||
|
||
| bag | | ||
bag := self new. | ||
stonReader parseMapDo: [ :key :value | | ||
bag add: key withOccurrences: value ]. | ||
^ bag | ||
] | ||
|
||
{ #category : #'*STON-Core' } | ||
Bag >> stonOn: stonWriter [ | ||
"Use a map with element-occurences pairs as representation" | ||
|
||
stonWriter | ||
writeObject: self | ||
do: [ stonWriter encodeMap: contents ] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Extension { #name : #Color } | ||
|
||
{ #category : #'*ston-core' } | ||
Color class >> fromSton: stonReader [ | ||
| representation | | ||
representation := stonReader parseMapOrListRepresentation. | ||
^ representation isArray | ||
ifTrue: [ | ||
self named: representation first ] | ||
ifFalse: [ | ||
(representation includesKey: #rgb) | ||
ifTrue: [ | ||
self basicNew setRGB: (representation at: #rgb); setAlpha: 1.0 "backwards compatibility" ] | ||
ifFalse: [ | ||
self | ||
r: (representation at: #red) | ||
g: (representation at: #green) | ||
b: (representation at: #blue) | ||
alpha: (representation at: #alpha) ] ] | ||
] | ||
|
||
{ #category : #'*ston-core' } | ||
Color >> stonContainSubObjects [ | ||
^ false | ||
] | ||
|
||
{ #category : #'*ston-core' } | ||
Color >> stonOn: stonWriter [ | ||
| name | | ||
(self isTranslucent or: [ (name := self name) = #unnamed ]) | ||
ifTrue: [ | ||
stonWriter writeObject: self streamMap: [ :map | | ||
#(red green blue alpha) do: [ :each | | ||
map at: each put: ((self perform: each) roundTo: 0.001) ] ] ] | ||
ifFalse: [ | ||
stonWriter writeObject: self listSingleton: name ] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Extension { #name : #FileReference } | ||
|
||
{ #category : #'*ston-core' } | ||
FileReference >> stonContainSubObjects [ | ||
^ false | ||
] | ||
|
||
{ #category : #'*ston-core' } | ||
FileReference >> stonOn: stonWriter [ | ||
self fileSystem isDiskFileSystem | ||
ifTrue: [ | diskFilePath | | ||
diskFilePath := String streamContents: [ :out | | ||
filesystem printPath: path on: out ]. | ||
stonWriter | ||
writeObject: self | ||
named: STONFileReference stonName | ||
listSingleton: diskFilePath ] | ||
ifFalse: [ | ||
super stonOn: stonWriter ] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Extension { #name : #Fraction } | ||
|
||
{ #category : #'*ston-core' } | ||
Fraction >> stonOn: stonWriter [ | ||
stonWriter writeFraction: self | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
Extension { #name : #Interval } | ||
|
||
{ #category : #'*ston-core' } | ||
Interval >> fromSton: stonReader [ | ||
"Overwritten to get back the standard object behavior" | ||
|
||
stonReader parseNamedInstVarsFor: self | ||
] | ||
|
||
{ #category : #'*ston-core' } | ||
Interval class >> fromSton: stonReader [ | ||
"Overwritten to get back the standard object behavior" | ||
|
||
^ self new | ||
fromSton: stonReader; | ||
yourself | ||
] | ||
|
||
{ #category : #'*ston-core' } | ||
Interval >> fromSton: stonReader [ | ||
stonReader parseNamedInstVarsFor: self | ||
] | ||
|
||
{ #category : #'*ston-core' } | ||
Interval >> stonOn: stonWriter [ | ||
"Overwritten to get back the standard object behavior" | ||
|
||
stonWriter writeObject: self | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
" | ||
I am STONFileReference, I am an implementation artifact to help reading objects with class tag equal to my #stonName. | ||
I am a FileReference. | ||
" | ||
Class { | ||
#name : #STONFileReference, | ||
#superclass : #FileReference, | ||
#category : #'STON-Core-Reader' | ||
} | ||
|
||
{ #category : #ston } | ||
STONFileReference class >> fromSton: stonReader [ | ||
^ stonReader parseListSingleton asFileReference. | ||
] | ||
|
||
{ #category : #ston } | ||
STONFileReference class >> stonName [ | ||
^ #FILE | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.