JavaScriptObject.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 24 Sep 2013 23:18:24 +0200
branchinitialV
changeset 1180 01c6be61f29c
parent 586 804af0afff5c
permissions -rw-r--r--
checkin from stx browser

"
 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.
"
"{ Package: 'stx:libjavascript' }"

IdentityDictionary subclass:#JavaScriptObject
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Languages-JavaScript-Compiling & Parsing'
!

!JavaScriptObject class methodsFor:'documentation'!

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.
"
! !

!JavaScriptObject class methodsFor:'instance creation'!

newWith:slotNames values:slotValues
    |newObj|

    newObj := self new.
    slotNames with:slotValues do:[:k :v |
        newObj at:k put:v
    ].
    ^ newObj
! !

!JavaScriptObject methodsFor:'hashing'!

hash
    ^ self identityHash
! !

!JavaScriptObject methodsFor:'printing'!

printOn:aStream
    aStream nextPutAll:'{'.
    self notEmpty ifTrue:[
        aStream cr.
        self keysAndValuesDo:[:k :v |
            aStream nextPutAll:'    '.
            k printOn:aStream.
            aStream nextPutAll:': '.
            v printOn:aStream.
            aStream cr.
        ].
    ].
    aStream nextPutAll:'}'.
! !

!JavaScriptObject methodsFor:'slot access'!

doesNotUnderstand:aMessage
    |na value|

    na := aMessage numArgs.
    na == 0 ifTrue:[
        ^ self at:(aMessage selector) ifAbsent:[super doesNotUnderstand:aMessage].
    ].
    na == 1 ifTrue:[
        aMessage selector first isLetter ifTrue:[
            value := aMessage arguments at:1.
            self at:(aMessage selector copyButLast:1) asSymbol put:value.
            ^ value
        ]
    ].
    ^ super doesNotUnderstand:aMessage
! !

!JavaScriptObject methodsFor:'special accessing'!

thisContext
    ^ thisContext sender
! !

!JavaScriptObject class methodsFor:'documentation'!

version_CVS
    ^ '$Header$'
! !