Missing Alternate TagMissing Alternate TagMissing Alternate TagMissing Alternate TagMissing Alternate TagMissing Alternate TagMissing Alternate TagMissing Alternate Tag

SIXX 0.3 Release Note


Improvements:


New SIXX Hooks:

Customizing serialization
Object>>sixxNonReferencableInstVarNamesSpecify 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.
Object>>sixxReferenceIdInContext:Return unique id that can be referenced from other objects in SIXX. It is useful when objects have their own unique id.

Formatter support:

Formatter is a new SIXX function for customizing SIXX format without subclassing.

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.
For example, you may want to change default Array serialization format to compact one, if the array includes only primitive (literal) elements.

Suppose there is an array like:

array := #(1 2 3 4 5).

By default, the array will be sixxed out if you evaluate:

array sixxString. "print it"


'<sixx.object sixx.id="0" sixx.type="Array" >
<sixx.object sixx.id="1" sixx.type="SmallInteger" >1</sixx.object>
<sixx.object sixx.id="2" sixx.type="SmallInteger" >2</sixx.object>
<sixx.object sixx.id="3" sixx.type="SmallInteger" >3</sixx.object>
<sixx.object sixx.id="4" sixx.type="SmallInteger" >4</sixx.object>
<sixx.object sixx.id="5" sixx.type="SmallInteger" >5</sixx.object>
</sixx.object>'

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.

SixxContext formatters: {SixxMockLiteralArrayFormatter on: Array}.

After that, the format will be:

'<sixx.object sixx.id="0" sixx.type="Array" sixx.formatter="SixxMockLiteralArrayFormatter" >
<sixx.object sixx.id="1" sixx.type="String" >&#35;&#40;1 2 3 4 5&#41;</sixx.object>
</sixx.object>'

You can reset the formatter by:

SixxContext resetFormatters.

For convenience, there is a method to switch formatter temporarily.

SixxContext applyFormatters: {SixxMockLiteralArrayFormatter on: Array} while: [
array sixxString.
]

Or, you can even use:

SixxContext evaluate: [array sixxString]
formattersBy: [:formatters | formatters add: (SixxMockLiteralArrayFormatter on: Array)].

In short, Formatter can be used:

New ShapeChanger registration API

From this version, ShapeChanger can be registered via SixxContext. The API is similar to using Formatter.

obj := SixxContext evaluate: [Object readSixxFrom: oldSixx]
shapeChangersBy: [:shapeChangers | shapeChangers at: #SixxShapeChangedObject put: SixxSomeShapeChanger].

-----------

You should also see SIXX 0.2 Release Note .

-----------

Link to this Page