Skip to content

Commit cd34844

Browse files
authored
Merge pull request #22 from mumez/develop
develop: Pharo 11 and 12 support
2 parents 6df91d9 + 592ebb2 commit cd34844

File tree

83 files changed

+497
-29
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+497
-29
lines changed

.github/workflows/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
smalltalk: [Pharo64-10, Squeak64-6.0]
11+
smalltalk: [Pharo64-10, Pharo64-11, Pharo64-12, Squeak64-6.0]
1212
experimental: [false]
1313
continue-on-error: ${{ matrix.experimental }}
1414
name: ${{ matrix.smalltalk }}
1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
- uses: hpi-swa/setup-smalltalkCI@v1
1818
with:
1919
smalltalk-image: ${{ matrix.smalltalk }}

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ SIXX is an XML serializer/deserializer written in Smalltalk. The purpose is to s
44

55
[![CI](https://github.com/mumez/SIXX/actions/workflows/main.yml/badge.svg)](https://github.com/mumez/SIXX/actions/workflows/main.yml)
66

7-
This repository is mainly for sources ([Cypress](<https://github.com/CampSmalltalk/Cypress>) format). For further info, see the [main site](http://www.mars.dti.ne.jp/~umejava/smalltalk/sixx/index.html) and [wiki site](https://swikis.ddo.jp/umejava/SIXX).
7+
This repository is mainly for sources ([Cypress](https://github.com/CampSmalltalk/Cypress) format). For further info, see the [main site](http://www.mars.dti.ne.jp/~umejava/smalltalk/sixx/index.html) and [wiki site](https://swikis.ddo.jp/umejava/SIXX).
88

99
## Installation using Metacello
1010

@@ -24,6 +24,10 @@ Metacello new
2424
```Smalltalk
2525
Installer squeaksource
2626
project: 'MetacelloRepository';
27-
install: 'ConfigurationOfSIXX'.
27+
install: 'ConfigurationOfSIXX'.
2828
(Smalltalk at: #ConfigurationOfSIXX) load
2929
```
30+
31+
## Features
32+
33+
Please see [features.md](./doc/features.md)

doc/features.md

+181
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# Features
2+
3+
SIXX is a multi-platform XML serializer/deserializer for Smalltalk. You can exchange various Smalltalk objects among different (dialect) images.
4+
5+
## How to use
6+
7+
### Basic writing/reading
8+
9+
SIXX is very easy to use. Like #storeString, You can generate a SIXX string by #sixxString.
10+
11+
```smalltalk
12+
array := Array with: 1 with: 'Hello' with: Date today.
13+
array sixxString.
14+
```
15+
16+
This code generates the following SIXX string:
17+
18+
```xml
19+
'<sixx.object sixx.id="0" sixx.type="Array">
20+
<sixx.object sixx.id="1" sixx.type="SmallInteger">1</sixx.object>
21+
<sixx.object sixx.id="2" sixx.type="String">Hello</sixx.object>
22+
<sixx.object sixx.id="3" sixx.type="Date">16 June 2002</sixx.object>
23+
</sixx.object>'
24+
```
25+
26+
This string can be read by #readSixxFrom:.
27+
28+
```smalltalk
29+
Object readSixxFrom: sixxString. "sixxString is the above string"
30+
```
31+
32+
### Stream writing/reading
33+
34+
SixxWriteStream and SixxReadStream are provided so that you can write/read Smalltalk objects in a way similar to binary object stream (BOSS in VW, and the ReferenceStream in Squeak).
35+
36+
In order to write objects to an external file, you can:
37+
38+
```smalltalk
39+
sws := SixxWriteStream newFileNamed: 'obj.sixx'.
40+
sws nextPut: object. "an object"
41+
sws nextPutAll: objects. "collection of objects"
42+
sws close.
43+
```
44+
45+
And to read objects from an external file:
46+
47+
```smalltalk
48+
srs := SixxReadStream readOnlyFileNamed: 'obj.sixx'.
49+
objects := srs contents.
50+
srs close.
51+
```
52+
53+
### SIXX hooks
54+
55+
#### Customizing serialization
56+
57+
| Hook method | Description |
58+
| --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
59+
| Object>>sixxPrepareWrite | It is called before the instance is written in SIXX. |
60+
| Object>>sixxWriteValue | Return the object actually serialized. |
61+
| Object>>sixxIgnorableInstVarNames | Specify the instance variables that are not written in SIXX. |
62+
| Object>>sixxNonReferencableInstVarNames | Specify the instance variables that should not be referenced in SIXX. Values are always written redundantly. It is useful for small literal objects like String, Number, etc. |
63+
| Object>>sixxReferenceIdInContext: | Return unique id that can be referenced from other objects in SIXX. It is useful when objects have their own unique id. |
64+
65+
#### Customizing deserialization
66+
67+
| Hook method | Description |
68+
| ---------------------- | ---------------------------------------------------------------- |
69+
| Object>>sixxInitialize | It is called immediately after the instance is read from SIXX |
70+
| Object>>sixxReadValue | Return the object for the client from the deserialized instance. |
71+
72+
### ShapeChanger
73+
74+
SixxShapeChangeReadStream enables you to read class shape changed instances. It supports renamed, removed and newly added instance variables.
75+
76+
```smalltalk
77+
srs := SixxShapeChangeReadStream on: oldSixx readStream.
78+
srs shapeChangers at:#SmallIntegerOLD put: SmallInteger . "simple renaming"
79+
80+
srs shapeChangers at: #SixxShapeChangedObject put: SixxMockShapeChanger.
81+
"You can implement ShapeChanger for more complex conversion. "
82+
```
83+
84+
To define a new ShapeChanger, you should subclass base ShapeChanger class and override three methods.
85+
86+
| Hook method | Description |
87+
| ------------------------------------------------------ | ------------------------------------------------------------------------------------- |
88+
| YourShapeChanger>>shapeChangedObjectClass | Return a newly introduced class for old instances. |
89+
| YourShapeChanger>>sixxInstVarNamed: varName put: value | Override this method for setting converted values to the shape changed object. |
90+
| YourShapeChanger>>initializeShapeChangedObject | Override this method for setting newly introduced values to the shape changed object. |
91+
92+
For example: (YourShapeChanger>>sixxInstVarNamed: varName put:)
93+
94+
```smalltalk
95+
sixxInstVarNamed: varName put: value
96+
"#oldNamedVar1 inst var was renamed to #renamedAtt1"
97+
varName == #oldNamedVar1 ifTrue: [^self attributesMap at: #renamedAtt1 put: value].
98+
99+
"#oldNamedVar2 inst var was removed."
100+
varName == #oldNamedVar2 ifTrue: [^self].
101+
102+
super sixxInstVarNamed: varName put: value
103+
```
104+
105+
From SIXX 0.3, you can apply ShapeChanger(s) without using SixxShapeChangeReadStream.
106+
107+
```smalltalk
108+
obj := SixxContext evaluate: [Object readSixxFrom: oldSixx] shapeChangersBy: [:shapeChangers | shapeChangers at: #SixxShapeChangedObject put: SixxSomeShapeChanger].
109+
```
110+
111+
### Formatter
112+
113+
Formatter is a new SIXX function for customizing SIXX format without subclassing.
114+
115+
Normally, you can customize SIXX serialization format by overriding hooks such as #sixxWriteValue, #sixxIgnorableInstVarNames. However, sometimes you would like to customize serialization format more dynamically.
116+
For example, you may want to change default Array serialization format to compact one, if the array includes only primitive (literal) elements.
117+
118+
Suppose there is an array like:
119+
120+
```smalltalk
121+
array := #(1 2 3 4 5).
122+
```
123+
124+
By default, the array will be serialized if you evaluate:
125+
126+
```smalltalk
127+
array sixxString. "print it"
128+
```
129+
130+
```xml
131+
'<sixx.object sixx.id="0" sixx.type="Array">
132+
<sixx.object sixx.id="1" sixx.type="SmallInteger">1</sixx.object>
133+
<sixx.object sixx.id="2" sixx.type="SmallInteger">2</sixx.object>
134+
<sixx.object sixx.id="3" sixx.type="SmallInteger">3</sixx.object>
135+
<sixx.object sixx.id="4" sixx.type="SmallInteger">4</sixx.object>
136+
<sixx.object sixx.id="5" sixx.type="SmallInteger">5</sixx.object>
137+
</sixx.object>'
138+
```
139+
140+
This format is reasonable for supporting complex array, but the format could be space-consuming if the array contains only primitive (literal) elements. By setting a Formatter, you can use more compact format for Array.
141+
142+
```smalltalk
143+
SixxContext formatters: {SixxMockLiteralArrayFormatter on: Array}.
144+
```
145+
146+
After that, the format will be:
147+
148+
```xml
149+
'<sixx.object
150+
sixx.id="0"
151+
sixx.type="Array"
152+
sixx.formatter="SixxMockLiteralArrayFormatter"
153+
>
154+
<sixx.object sixx.id="1" sixx.type="String">#(1 2 3 4 5)</sixx.object>
155+
</sixx.object>'
156+
```
157+
158+
You can reset the formatter by:
159+
160+
```smalltalk
161+
SixxContext resetFormatters.
162+
```
163+
164+
For convenience, there is a method to switch formatter temporarily.
165+
166+
```smalltalk
167+
SixxContext applyFormatters: {SixxMockLiteralArrayFormatter on: Array} while: [
168+
array sixxString.
169+
]
170+
```
171+
172+
Or, you can even use:
173+
174+
```smalltalk
175+
SixxContext evaluate: [array sixxString] formattersBy: [:formatters | formatters add: (SixxMockLiteralArrayFormatter on: Array)].
176+
```
177+
178+
In short, Formatter can be used:
179+
180+
- For customizing SIXX format dynamically.
181+
- For overriding SIXX format of the existing classes temporarily.
+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2-
"noMethodMetaData" : true,
32
"separateMethodMetaAndSource" : false,
4-
"useCypressPropertiesFile" : true }
3+
"noMethodMetaData" : true,
4+
"useCypressPropertiesFile" : true
5+
}

repository/BaselineOfSIXX.package/BaselineOfSIXX.class/instance/baseline..st

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ baseline: spec
2727
self xmlParser: spec.
2828
spec package: 'SIXX-Pharo'.
2929
spec package: 'SIXX-ParserAdapter' with: [spec requires: 'XMLParser'].
30+
spec package: 'SIXX-InOut-Common'.
31+
].
32+
spec for: #(#'pharo1.x' #'pharo2.x' #'pharo3.x' #'pharo4.x' #'pharo5.x' #'pharo6.x' #'pharo7.x' #'pharo8.x' #'pharo9.x' #'pharo10.x') do:[
3033
spec package: 'SIXX-InOut-Common' with: [spec includes: 'SIXX-InOut-Pharo'].
3134
spec package: 'SIXX-InOut-Pharo' with: [spec requires: #('SIXX-Pharo' 'SIXX-InOut-Common')].
35+
].
36+
spec for: #(#'pharo11.x' #'pharo12.x') do:[
37+
spec package: 'SIXX-InOut-Common' with: [spec includes: 'SIXX-InOut-Pharo110'].
38+
spec package: 'SIXX-InOut-Pharo110' with: [spec requires: #('SIXX-Pharo' 'SIXX-InOut-Common')].
3239
].

repository/BaselineOfSIXX.package/BaselineOfSIXX.class/methodProperties.json

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
{
2-
"category" : "BaselineOfSIXX",
3-
"classinstvars" : [
4-
],
5-
"classvars" : [
6-
],
72
"commentStamp" : "",
8-
"instvars" : [
9-
],
10-
"name" : "BaselineOfSIXX",
11-
"pools" : [
12-
],
133
"super" : "BaselineOf",
14-
"type" : "normal" }
4+
"category" : "BaselineOfSIXX",
5+
"classinstvars" : [ ],
6+
"pools" : [ ],
7+
"classvars" : [ ],
8+
"instvars" : [ ],
9+
"name" : "BaselineOfSIXX",
10+
"type" : "normal"
11+
}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
SystemOrganization addCategory: #BaselineOfSIXX!
1+
self packageOrganizer ensurePackage: #BaselineOfSIXX withTags: #()!

repository/BaselineOfSIXX.package/monticello.meta/version

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
{
2-
}
1+
{ }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"separateMethodMetaAndSource" : false,
3+
"noMethodMetaData" : true,
4+
"useCypressPropertiesFile" : true
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*SIXX-InOut-Pharo110-instance creation
2+
createInstanceOf: aClass withSixxElement: sixxElement
3+
4+
"For old format"
5+
| stream |
6+
(SixxXmlUtil hasSubElementsFrom: sixxElement ) ifTrue: [
7+
^super createInstanceOf: aClass withSixxElement: sixxElement
8+
].
9+
10+
stream := ReadStream on: (SixxXmlUtil characterDataFrom: sixxElement).
11+
^self readSixxContentStringFrom: stream
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*SIXX-InOut-Pharo110-instance creation
2+
readSixxContentStringFrom: aStream
3+
| space familyName size emphasisCode |
4+
space := Character space.
5+
familyName := aStream upTo: space.
6+
size := (aStream upTo: space) asInteger.
7+
emphasisCode := (aStream upTo: space) asInteger.
8+
^self sixxFamilyName: familyName size: size emphasized: emphasisCode.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*SIXX-InOut-Pharo110-instance creation
2+
sixxFamilyName: familyName size: size emphasized: emphasisCode
3+
^self familyName: familyName size: size emphasized: emphasisCode
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*SIXX-InOut-Pharo110-printing
2+
sixxContentOn: aStream indent: level context: dictionary
3+
aStream nextPutAll: self sixxContentString
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*SIXX-InOut-Pharo110-printing
2+
sixxContentString
3+
"Squeak Specific"
4+
^self fontNameWithPointSize, ' ', self emphasis asString
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name" : "AbstractFont"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*SIXX-InOut-Pharo110-printing
2+
sixxContentOn: aStream indent: level context: dictionary
3+
aStream
4+
nextPutAll: '(' , self class name;
5+
nextPutAll: ' r: '; print: (self red roundTo: 0.001);
6+
nextPutAll: ' g: '; print: (self green roundTo: 0.001);
7+
nextPutAll: ' b: '; print: (self blue roundTo: 0.001);
8+
nextPutAll: ')'.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name" : "Color"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*SIXX-InOut-Pharo110
2+
createInstanceOf: aClass withSixxElement: sixxElement
3+
SixxInvalidDeserialization signal: aClass name element: sixxElement.
4+
^nil
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*SIXX-InOut-Pharo110
2+
sixxContentOn: aStream indent: level context: dictionary
3+
SixxInvalidSerialization signal: self class name context: dictionary.
4+
SixxXmlUtil writeXmlText: self printString on: aStream
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name" : "CompiledCode"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*SIXX-InOut-Pharo110-instance creation
2+
createInstanceOf: aClass withSixxElement: sixxElement
3+
SixxInvalidDeserialization signal: aClass name element: sixxElement.
4+
^nil
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*SIXX-InOut-Pharo110-printing
2+
sixxContentOn: aStream indent: level context: dictionary
3+
SixxInvalidSerialization signal: self class name context: dictionary.
4+
SixxXmlUtil writeXmlText: self printString on: aStream
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name" : "Context"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*SIXX-InOut-Pharo110-private
2+
readSixxContentStringFrom: aStream
3+
"Squeak specific"
4+
^ self readFrom: aStream
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*SIXX-InOut-Pharo110-private
2+
sixxContentString
3+
"Squeak Specific"
4+
^self printString
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name" : "Date"
3+
}

0 commit comments

Comments
 (0)