eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'InlineObject':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: InlineObject


Inheritance:

   Object
   |
   +--InlineObject
      |
      +--InlineObject::InlineObjectPrototype

Package:
stx:libbasic
Category:
Kernel-Classes
Version:
rev: 1.30 date: 2023/09/28 09:57:35
user: stefan
file: InlineObject.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


WARNING: InlineObjects are an experimental feature.

InlineObjects are written as literals of the form:

    #{
        fieldName1: value1.
        fieldName2: value2.
        ...
        fieldNameN: valueN.
    }

For example:

    #{
        firstName: 'Peter'.
        lastName: 'Miller'.
        age: 25.
    }

The above was an inline literal: all field values must be again literals.

WARNING: the following is currently ONLY experimental,
and may or may not be supported by stc.
Do not use non-literal inline objects at the moment.

However, similar to brace-Arrays, inline objects can also be dynamically created (constructed):
    {
        date:  Date today.
        time:  Time now.
    }

All inlineObjects will be instances of an anonymous subclass of me,
and provide getter protocol for their fields (e.g. firstName, lastName and age in the above example.
Literal InlineObjects are immutable (no setters), whereas constructed are not.

    |foo|
    foo := { date:  Date today. time:  Time now }.
    foo date:(Date yesterday).
    foo  

copyright

COPYRIGHT (c) 2009 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

flushing
o  flushMapOfClasses

instance creation
o  slotNames: names values: slotValues
return a new inline object given slot names and slot values

Usage example(s):

     InlineObject slotNames:#('foo' 'bar' 'baz') values:#(1 2 3)
     InlineObject slotNames:#('foo' 'bar' 'baz') values:#(1 2 3) mutable:false

o  slotNames: names values: slotValues mutable: mutable
return a new inline object given slot names and slot values

Usage example(s):

     InlineObject slotNames:#('foo' 'bar' 'baz') values:#(1 2 3)
     InlineObject slotNames:#('foo' 'bar') values:#(1 2)

o  slotNamesAndValues: namesAndValues
return a new inline object given slot names and slot values as alternating elements
in the argument, namesAndValues

Usage example(s):

     InlineObject slotNamesAndValues:#('foo' 10 'bar' 20 'baz' 30)

o  slotNamesAndValues: namesAndValues mutable: beMutable
return a new inline object given slot names and slot values either as alternating elements
in the argument, namesAndValues, or as a dictionary associating values to slotnames

Usage example(s):

     InlineObject slotNamesAndValues:#('foo' 10 'bar' 20 'baz' 30)

o  slotNamesAndValuesFromDictionary: namesAndValuesDict
return a new inline object given slot names and slot values as elements
in the argument, namesAndValuesDict

Usage example(s):

     InlineObject slotNamesAndValuesFromDictionary:(Dictionary withKeyValuePairs:#(('foo' 10) ('bar' 20) ('baz' 30)))

o  slotNamesAndValuesFromDictionary: namesAndValuesDict mutable: beMutable
return a new inline object, given slot names and slot values as elements
in the argument, namesAndValuesDict.
If the dictionary is unordered, slots are created in the sorted key order

Usage example(s):

     InlineObject 
        slotNamesAndValuesFromDictionary:(
            Dictionary withKeyValuePairs:#(('foo' 10) ('bar' 20) ('baz' 30))
        )

     InlineObject 
        slotNamesAndValuesFromDictionary:(
            OrderedDictionary withKeyValuePairs:#( ('bar' 20) ('baz' 30) ('foo' 10) )
        )

prototype access
o  prototype

queries
o  classForSlotNames: slotNames mutable: mutable
return either an existing or a new class to represent
an inline object given its slot names

Usage example(s):

     |cls1 cls2|

     cls1 := self classForSlotNames:#('foo' 'bar' 'baz') mutable:false.
     cls2 := self classForSlotNames:#('foo' 'bar' 'baz') mutable:true.
     self assert:(self classForSlotNames:#('foo' 'bar' 'baz') mutable:false) == cls1.
     self assert:(self classForSlotNames:#('foo' 'bar' 'baz') mutable:true) == cls2.

o  isAbstract
Return if this class is an abstract class.
True is returned here for myself only; false for subclasses.
Abstract subclasses must redefine this again.


Instance protocol:

collection protocol
o  _at: key
(comment from inherited method)
this is a synthetic selector, generated by the compiler,
if a construct of the form expr[idx] is parsed.
I.e.
foo[n]
generates
foo _at: n

o  _at: key put: newValue
(comment from inherited method)
this is a synthetic selector, generated by the compiler,
if a construct of the form expr[idx...] := val is parsed.
I.e.
foo[n] := val
generates
foo _at:n put:val

comparing
o  = someObject
I conside someObject to be equal, if it has the same slotnames

o  hash
I redefine =; so I also have to redefine hash

o  isInlineObject
(comment from inherited method)
return true if the receiver is some kind of inline object;
false is returned here - the method is only redefined in InlineObject.

printing & storing
o  displayOn: aStream
#{ foo: 1 . bar: 2 } displayString

o  storeOn: aStream
#{ foo: 1 . bar: 2 } storeString
Object readFrom:( #{ foo: 1 . bar: 2 } storeString)


Private classes:

    InlineObjectClassDescription
    InlineObjectPrototype


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 04:28:52 GMT