Skip to content

Commit

Permalink
checking in latest versions from SS3
Browse files Browse the repository at this point in the history
Name: Ston-Core-SvenVanCaekenberghe.29
Author: SvenVanCaekenberghe
Time: 27 April 2012, 8:48:21 pm
UUID: da09472b-ff70-46e4-9896-a661d0c3e7a0
Ancestors: Ston-Core-SvenVanCaekenberghe.28

Name: Ston-Tests-SvenVanCaekenberghe.28
Author: SvenVanCaekenberghe
Time: 27 April 2012, 2:25:30 pm
UUID: f1afbac1-b9b5-4042-99b6-eceb9444dd8f
Ancestors: Ston-Tests-SvenVanCaekenberghe.27
  • Loading branch information
svenvc committed Apr 28, 2012
0 parents commit 87dbbe7
Show file tree
Hide file tree
Showing 319 changed files with 2,056 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
STON - Smalltalk Object Notation

A lightweight text-based, human-readable data interchange format
for class-based object-oriented languages like Smalltalk.
10 changes: 10 additions & 0 deletions license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
MIT License

Copyright (C) 2012 Sven Van Caekenberghe

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1 change: 1 addition & 0 deletions repository/.filetree
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "packageExtension" : ".package" }
4 changes: 4 additions & 0 deletions repository/Ston-Core.package/.filetree
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"noMethodMetaData" : true,
"separateMethodMetaAndSource" : false,
"useCypressPropertiesFile" : true }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*ston-core
stonOn: stonWriter
stonWriter writeBoolean: self
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*ston-core
stonProcessSubObjects: block
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "Boolean" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*ston-core
fromSton: stonReader
^ self readHexFrom: stonReader parseListSingleton
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*ston-core
stonOn: stonWriter
"Use a hex representation"

stonWriter writeObject: self listSingleton: self hex
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*ston-core
stonProcessSubObjects: block
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "ByteArray" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*ston-core
fromSton: stonReader
^ stonReader parseListSingleton first
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*ston-core
stonOn: stonWriter
stonWriter writeObject: self listSingleton: self asString
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "Character" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*ston-core
stonName
"Override to encode my instances using a different class name."

^ self name
2 changes: 2 additions & 0 deletions repository/Ston-Core.package/Class.extension/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "Class" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*ston-core
fromSton: stonReader
| collection |
collection := self new.
stonReader parseListDo: [ :each |
collection add: each ].
^ collection
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*ston-core
stonOn: stonWriter
stonWriter writeObject: self do: [
stonWriter encodeList: self ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "Collection" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*ston-core
fromSton: stonReader
^ self readFrom: stonReader parseListSingleton readStream
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*ston-core
stonOn: stonWriter
"Use an ISO style YYYYMMDD representation"

stonWriter writeObject: self listSingleton: self yyyymmdd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*ston-core
stonProcessSubObjects: block
2 changes: 2 additions & 0 deletions repository/Ston-Core.package/Date.extension/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "Date" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*ston-core
fromSton: stonReader
^ DateAndTime readFrom: stonReader parseListSingleton readStream
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*ston-core
stonOn: stonWriter
"Use an ISO representation with all details"

stonWriter writeObject: self listSingleton:
(String streamContents: [ :stream |
self printOn: stream withLeadingSpace: false ])
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*ston-core
stonProcessSubObjects: block
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "DateAndTime" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*ston-core
fromSton: stonReader
"Instances of STON mapClass will be read directly and won't arrive here.
Other (sub)classes will use this method."

| dictionary |
dictionary := self new.
stonReader parseMapDo: [ :key :value |
dictionary at: key put: value ].
^ dictionary
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*ston-core
stonOn: stonWriter
"Instances of STON mapClass will be encoded directly, without a class tag.
Other (sub)classes will be encoded with a class tag and will use a map representation. "

self class == STON mapClass
ifTrue: [
stonWriter writeMap: self ]
ifFalse: [
stonWriter
writeObject: self
do: [ stonWriter encodeMap: self ] ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "Dictionary" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*ston-core
stonOn: stonWriter
stonWriter writeInteger: self
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "Integer" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*ston-core
stonOn: stonWriter
stonWriter writeFloat: self asFloat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*ston-core
stonProcessSubObjects: block
2 changes: 2 additions & 0 deletions repository/Ston-Core.package/Number.extension/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "Number" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*ston-core
fromSton: stonReader
"Create a new instance and delegate decoding to instance side.
Override only when new instance should be created directly (see implementors). "

^ self new
fromSton: stonReader;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*ston-core
fromSton: stonReader
"Decode non-variable classes from a map of their instance variables and values.
Override to customize and add a mathcing #toSton: (see implementors)."

self class isVariable
ifTrue: [
self subclassResponsibility ]
ifFalse: [
stonReader parseMapDo: [ :instVarName :value |
self instVarNamed: instVarName put: value ] ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*ston-core
isStonReference
^ false
12 changes: 12 additions & 0 deletions repository/Ston-Core.package/Object.extension/instance/stonOn..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*ston-core
stonOn: stonWriter
"Encode non-variable classes with a map of their instance variable and values.
Override to customize and add a matching #fromSton: (see implementors)."

self class isVariable
ifTrue: [
self subclassResponsibility ]
ifFalse: [
stonWriter writeObject: self streamMap: [ :dictionary |
self class allInstVarNames do: [ :each |
dictionary at: each asSymbol put: (self instVarNamed: each) ] ] ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*ston-core
stonProcessSubObjects: block
1 to: self class instSize do: [ :each |
self instVarAt: each put: (block value: (self instVarAt: each)) ].
(self class isVariable and: [ self class isBytes not ])
ifTrue: [
1 to: self basicSize do: [ :each |
self basicAt: each put: (block value: (self basicAt: each)) ] ]
2 changes: 2 additions & 0 deletions repository/Ston-Core.package/Object.extension/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "Object" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*ston-core
fromSton: stonReader
stonReader parseListDo: [ :each :index |
index = 1 ifTrue: [ x := each ].
index = 2 ifTrue: [ y := each ] ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*ston-core
stonOn: stonWriter
stonWriter writeObject: self streamShortList: [ :array |
array add: x; add: y ]
2 changes: 2 additions & 0 deletions repository/Ston-Core.package/Point.extension/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "Point" }
93 changes: 93 additions & 0 deletions repository/Ston-Core.package/STON.class/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
STON implements serialization and materialization using the Smalltalk Object Notation format.

S y n t a x

value
primitive-value
object-value
reference
nil
primitive-value
number
true
false
symbol
string
object-value
object
map
list
object
classname map
classname list
reference
@ int-index-previous-object-value
map
{}
{ members }
members
pair
pair , members
pair
string : value
symbol : value
number : value
list
[]
[ elements ]
elements
value
value , elements
string
''
' chars '
chars
char
char chars
char
any-printable-ASCII-character-
except-'-"-or-\
\'
\"
\\
\/
\b
\f
\n
\r
\t
\u four-hex-digits
symbol
# chars-limited
# ' chars '
chars-limited
char-limited
char-limited chars-limited
char-limited
a-z A-Z 0-9 - _ . /
classname
uppercase-alpha-char alphanumeric-char
number
int
int frac
int exp
int frac exp
int
digit
digit1-9 digits
- digit
- digit1-9 digits
frac
. digits
exp
e digits
digits
digit
digit digits
e
e
e+
e-
E
E+
E-
3 changes: 3 additions & 0 deletions repository/Ston-Core.package/STON.class/class/fromStream..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
convencience
fromStream: readStream
^ (self reader on: readStream) next
3 changes: 3 additions & 0 deletions repository/Ston-Core.package/STON.class/class/fromString..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
convencience
fromString: string
^ self fromStream: string readStream
3 changes: 3 additions & 0 deletions repository/Ston-Core.package/STON.class/class/listClass.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
listClass
^ Array
3 changes: 3 additions & 0 deletions repository/Ston-Core.package/STON.class/class/mapClass.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
mapClass
^ Dictionary
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
convencience
put: object onStream: stream
(self writer on: stream) nextPut: object
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
convencience
put: object onStreamPretty: stream
(self writer on: stream)
prettyPrint: true;
nextPut: object
3 changes: 3 additions & 0 deletions repository/Ston-Core.package/STON.class/class/reader.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
reader
^ STONReader new
4 changes: 4 additions & 0 deletions repository/Ston-Core.package/STON.class/class/toString..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
convencience
toString: object
^ String streamContents: [ :stream |
self put: object onStream: stream ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
convencience
toStringPretty: object
^ String streamContents: [ :stream |
self put: object onStreamPretty: stream ]
Loading

0 comments on commit 87dbbe7

Please sign in to comment.