12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277 |
- Smalltalk current createPackage: 'Kernel-Objects' properties: #{}!
- nil subclass: #Object
- instanceVariableNames: ''
- category: 'Kernel-Objects'!
- !Object methodsFor: 'accessing'!
- yourself
- ^self
- !
- class
- <return self.klass>
- !
- size
- self error: 'Object not indexable'
- !
- instVarAt: aSymbol
- | varname |
- varname := aSymbol asString.
- <return self['@'+varname]>
- !
- instVarAt: aSymbol put: anObject
- | varname |
- varname := aSymbol asString.
- <self['@' + varname] = anObject>
- !
- basicAt: aString
- <return self[aString]>
- !
- basicAt: aString put: anObject
- <return self[aString] = anObject>
- !
- basicDelete: aString
- <delete self[aString]; return aString>
- !
- identityHash
- <return self.identityHash || (self.identityHash = smalltalk.nextId());>
- ! !
- !Object methodsFor: 'comparing'!
- = anObject
- ^self == anObject
- !
- ~= anObject
- ^(self = anObject) = false
- !
- == anObject
- ^self identityHash = anObject identityHash
- !
- ~~ anObject
- ^(self == anObject) = false
- ! !
- !Object methodsFor: 'converting'!
- -> anObject
- ^Association key: self value: anObject
- !
- asString
- ^self printString
- !
- asJavascript
- ^self asString
- !
- asJSON
- ^JSON parse: self asJSONString
- !
- asJSONString
- ^JSON stringify: self
- ! !
- !Object methodsFor: 'copying'!
- copy
- ^self shallowCopy postCopy
- !
- shallowCopy
- <
- var copy = self.klass._new();
- for(var i in self) {
- if(/^@.+/.test(i)) {
- copy[i] = self[i];
- }
- }
- return copy;
- >
- !
- deepCopy
- <
- var copy = self.klass._new();
- for(var i in self) {
- if(/^@.+/.test(i)) {
- copy[i] = self[i]._deepCopy();
- }
- }
- return copy;
- >
- !
- postCopy
- ! !
- !Object methodsFor: 'error handling'!
- error: aString
- Error signal: aString
- !
- subclassResponsibility
- self error: 'This method is a responsibility of a subclass'
- !
- shouldNotImplement
- self error: 'This method should not be implemented in ', self class name
- !
- try: aBlock catch: anotherBlock
- <try{result = aBlock()} catch(e) {result = anotherBlock(e)};
- return result;>
- !
- doesNotUnderstand: aMessage
- MessageNotUnderstood new
- receiver: self;
- message: aMessage;
- signal
- !
- halt
- self error: 'Halt encountered'
- !
- deprecatedAPI
-
- console warn: thisContext home asString, ' is deprecated!! (in ', thisContext home home asString, ')'
- ! !
- !Object methodsFor: 'initialization'!
- initialize
- ! !
- !Object methodsFor: 'message handling'!
- perform: aSymbol
- ^self perform: aSymbol withArguments: #()
- !
- perform: aSymbol withArguments: aCollection
- ^self basicPerform: aSymbol asSelector withArguments: aCollection
- !
- basicPerform: aSymbol
- ^self basicPerform: aSymbol withArguments: #()
- !
- basicPerform: aSymbol withArguments: aCollection
- <return self[aSymbol].apply(self, aCollection);>
- ! !
- !Object methodsFor: 'printing'!
- printString
- ^'a ', self class name
- !
- printNl
- <console.log(self)>
- !
- log: aString block: aBlock
- | result |
- console log: aString, ' time: ', (Date millisecondsToRun: [result := aBlock value]) printString.
- ^result
- !
- storeString
-
- ^ String streamContents: [:s | self storeOn: s]
- !
- storeOn: aStream
- aStream nextPutAll: self printString
- ! !
- !Object methodsFor: 'testing'!
- isKindOf: aClass
- ^(self isMemberOf: aClass)
- ifTrue: [true]
- ifFalse: [self class inheritsFrom: aClass]
- !
- isMemberOf: aClass
- ^self class = aClass
- !
- ifNil: aBlock
-
- ^self
- !
- ifNil: aBlock ifNotNil: anotherBlock
-
- ^anotherBlock value
- !
- ifNotNil: aBlock
-
- ^aBlock value
- !
- ifNotNil: aBlock ifNil: anotherBlock
-
- ^aBlock value
- !
- isNil
- ^false
- !
- notNil
- ^self isNil not
- !
- isClass
- ^false
- !
- isMetaclass
- ^false
- !
- isNumber
- ^false
- !
- isString
- ^false
- !
- isParseFailure
- ^false
- !
- isSymbol
- ^false
- ! !
- !Object class methodsFor: 'initialization'!
- initialize
-
- ! !
- Object subclass: #Smalltalk
- instanceVariableNames: ''
- category: 'Kernel-Objects'!
- !Smalltalk methodsFor: 'accessing'!
- classes
- <return self.classes()>
- !
- at: aString
- <return self[aString]>
- !
- basicParse: aString
- <return smalltalk.parser.parse(aString)>
- !
- parse: aString
- | result |
- self try: [result := self basicParse: aString] catch: [:ex | (self parseError: ex parsing: aString) signal].
- ^result
- !
- parseError: anException parsing: aString
- | row col message lines badLine code |
- <row = anException.line;
- col = anException.column;
- message = anException.message;>.
- lines := aString lines.
- badLine := lines at: row.
- badLine := (badLine copyFrom: 1 to: col - 1), ' ===>', (badLine copyFrom: col to: badLine size).
- lines at: row put: badLine.
- code := String streamContents: [:s |
- lines withIndexDo: [:l :i |
- s nextPutAll: i asString, ': ', l, String lf]].
- ^ Error new messageText: ('Parse error on line ' , row , ' column ' , col , ' : ' , message , ' Below is code with line numbers and ===> marker inserted:' , String lf, code)
- !
- reservedWords
-
- <return self.reservedWords>
- !
- readJSObject: anObject
- <return self.readJSObject(anObject)>
- ! !
- !Smalltalk methodsFor: 'classes'!
- removeClass: aClass
- aClass isMetaclass ifTrue: [self error: aClass asString, ' is a Metaclass and cannot be removed!!'].
- aClass methodDictionary values do: [:each |
- aClass removeCompiledMethod: each].
- aClass class methodDictionary values do: [:each |
- aClass class removeCompiledMethod: each].
- self basicDelete: aClass name
- ! !
- !Smalltalk methodsFor: 'packages'!
- packages
-
- <return self.packages.all()>
- !
- packageAt: packageName
- <return self.packages[packageName]>
- !
- packageAt: packageName ifAbsent: aBlock
- ^(self packageAt: packageName) ifNil: aBlock
- !
- removePackage: packageName
-
- | pkg |
- pkg := self packageAt: packageName ifAbsent: [self error: 'Missing package: ', packageName].
- pkg classes do: [:each |
- self removeClass: each].
- self deletePackage: packageName
- !
- renamePackage: packageName to: newName
-
- | pkg |
- pkg := self packageAt: packageName ifAbsent: [self error: 'Missing package: ', packageName].
- (self packageAt: newName) ifNotNil: [self error: 'Already exists a package called: ', newName].
- <smalltalk.packages[newName] = smalltalk.packages[packageName]>.
- pkg name: newName.
- self deletePackage: packageName.
- ! !
- !Smalltalk methodsFor: 'private'!
- createPackage: packageName
-
- <return smalltalk.addPackage(packageName, nil)>
- !
- deletePackage: packageName
-
- <delete smalltalk.packages[packageName]>
- !
- createPackage: packageName properties: aDict
-
- | object |
- <object = {};>.
- aDict keysAndValuesDo: [:key :value |
- <object[key] = value>.
- ].
- <return smalltalk.addPackage(packageName, object)>
- ! !
- Smalltalk class instanceVariableNames: 'current'!
- !Smalltalk class methodsFor: 'accessing'!
- current
- <return smalltalk>
- ! !
- Object subclass: #Package
- instanceVariableNames: 'commitPathJs commitPathSt'
- category: 'Kernel-Objects'!
- !Package commentStamp!
- A Package is similar to a typically found in other Smalltalks like Pharo or Squeak. Amber does not have class categories anymore, it had in the beginning but now each class in the system knows which package it belongs to.
- A Package has a name, an Array of , a comment and a Dictionary with other optional key value attributes. A Package can also be queried for its classes, but it will then resort to a reverse scan of all classes to find them.
- Packages are manipulated through , like for example finding one based on a name:
- Smalltalk current packageAt: 'Kernel'
- ...but you can also use:
- Package named: 'Kernel'
- A Package differs slightly from a Monticello package which can span multiple class categories using a naming convention based on hyphenation. But just as in Monticello a Package supports so a Package
- can define behaviors in foreign classes using a naming convention for method categories where the category starts with an asterisk and then the name of the owning package follows. This can easily be seen in for example class
- String where the method category defines #inspectOn: which thus is a method belonging to the IDE package.!
- !Package methodsFor: 'accessing'!
- name
- <return self.pkgName>
- !
- name: aString
- <self.pkgName = aString>
- !
- dependencies
- ^self propertyAt: 'dependencies' ifAbsent: [#()]
- !
- dependencies: anArray
- ^self propertyAt: 'dependencies' put: anArray
- !
- properties
- ^Smalltalk current readJSObject: (self basicAt: 'properties')
- !
- properties: aDict
-
-
- | object |
- <object = {};>.
- aDict keysAndValuesDo: [:key :value |
- <object[key] = value>.
- ].
- <return self.properties = object>
- !
- commitPathJs
- ^ commitPathJs ifNil: [self class defaultCommitPathJs]
- !
- commitPathJs: aString
- commitPathJs := aString
- !
- commitPathSt
- ^ commitPathSt ifNil: [self class defaultCommitPathSt]
- !
- commitPathSt: aString
- commitPathSt := aString
- ! !
- !Package methodsFor: 'classes'!
- classes
-
- ^Smalltalk current classes select: [:c | c package == self]
- ! !
- !Package methodsFor: 'printing'!
- printString
- ^self name
- ! !
- !Package methodsFor: 'private'!
- propertiesAsJSON
- <return JSON.stringify(self.properties)>
- !
- jsProperties
- <return self.properties>
- !
- jsProperties: aJSObject
- <return self.properties = aJSObject>
- ! !
- !Package methodsFor: 'properties'!
- propertyAt: key
- <return self.properties[key]>
- !
- propertyAt: key put: value
- <return self.properties[key] = value>
- !
- propertyAt: key ifAbsent: block
- ^(self propertyAt: key) ifNil: [block value]
- ! !
- Package class instanceVariableNames: 'defaultCommitPathJs defaultCommitPathSt'!
- !Package class methodsFor: 'commit paths'!
- defaultCommitPathJs
- ^ defaultCommitPathJs ifNil: [ defaultCommitPathJs := 'js']
- !
- defaultCommitPathJs: aString
- defaultCommitPathJs := aString
- !
- defaultCommitPathSt
- ^ defaultCommitPathSt ifNil: [ defaultCommitPathSt := 'st']
- !
- defaultCommitPathSt: aString
- defaultCommitPathSt := aString
- !
- resetCommitPaths
- defaultCommitPathJs := nil.
- defaultCommitPathSt := nil.
- ! !
- !Package class methodsFor: 'not yet classified'!
- named: aPackageName
- ^Smalltalk current packageAt: aPackageName
- !
- named: aPackageName ifAbsent: aBlock
- ^Smalltalk current packageAt: aPackageName ifAbsent: aBlock
- ! !
- Object subclass: #Number
- instanceVariableNames: ''
- category: 'Kernel-Objects'!
- !Number methodsFor: ''!
- ! !
- !Number methodsFor: 'accessing'!
- identityHash
- ^self asString, 'n'
- ! !
- !Number methodsFor: 'arithmetic'!
- + aNumber
-
- <return self + aNumber>
- !
- - aNumber
-
- <return self - aNumber>
- !
- * aNumber
-
- <return self * aNumber>
- !
- / aNumber
-
- <return self / aNumber>
- !
- max: aNumber
- <return Math.max(self, aNumber);>
- !
- min: aNumber
- <return Math.min(self, aNumber);>
- !
- negated
- ^0 - self
- !
- \\ aNumber
- <return self % aNumber>
- !
- sqrt
- <return Math.sqrt(self)>
- !
- squared
- ^self * self
- ! !
- !Number methodsFor: 'comparing'!
- = aNumber
- aNumber isNumber ifFalse: [^false].
- <return Number(self) == aNumber>
- !
- > aNumber
-
- <return self >> aNumber>
- !
- < aNumber
-
- <return self < aNumber>
- !
- >= aNumber
-
- <return self >>= aNumber>
- !
- <= aNumber
-
- <return self <= aNumber>
- ! !
- !Number methodsFor: 'converting'!
- rounded
- <return Math.round(self);>
- !
- truncated
- |result|
- self >= 0
- ifTrue: [<result = Math.floor(self);>]
- ifFalse: [<result = (Math.floor(self * (-1)) * (-1));>].
- ^ result
- !
- to: aNumber
- | array first last count |
- first := self truncated.
- last := aNumber truncated + 1.
- count := 1.
- array := Array new.
- (last - first) timesRepeat: [
- array at: count put: first.
- count := count + 1.
- first := first + 1].
- ^array
- !
- asString
- ^self printString
- !
- asJavascript
- ^'(', self printString, ')'
- !
- atRandom
- ^(Random new next * self) truncated + 1
- !
- @ aNumber
- ^Point x: self y: aNumber
- !
- asPoint
- ^Point x: self y: self
- !
- to: stop by: step
- | array value pos |
- value := self.
- array := Array new.
- pos := 1.
- step = 0 ifTrue: [self error: 'step must be non-zero'].
- step < 0
- ifTrue: [[ value >= stop ] whileTrue: [
- array at: pos put: value.
- pos := pos + 1.
- value := value + step]]
- ifFalse: [[ value <= stop ] whileTrue: [
- array at: pos put: value.
- pos := pos + 1.
- value := value + step]].
- ^array
- ! !
- !Number methodsFor: 'copying'!
- deepCopy
- ^self copy
- !
- copy
- ^self
- ! !
- !Number methodsFor: 'enumerating'!
- timesRepeat: aBlock
- | integer count |
- integer := self truncated.
- count := 1.
- [count > self] whileFalse: [
- aBlock value.
- count := count + 1]
- !
- to: stop do: aBlock
-
- | nextValue |
- nextValue := self.
- [nextValue <= stop]
- whileTrue:
- [aBlock value: nextValue.
- nextValue := nextValue + 1]
- !
- to: stop by: step do: aBlock
- | value |
- value := self.
- step = 0 ifTrue: [self error: 'step must be non-zero'].
- step < 0
- ifTrue: [[ value >= stop ] whileTrue: [
- aBlock value: value.
- value := value + step]]
- ifFalse: [[ value <= stop ] whileTrue: [
- aBlock value: value.
- value := value + step]]
- ! !
- !Number methodsFor: 'printing'!
- printString
- <return String(self)>
- !
- printShowingDecimalPlaces: placesDesired
- <return self.toFixed(placesDesired)>
- ! !
- !Number methodsFor: 'testing'!
- isNumber
- ^true
- !
- even
- ^ 0 = (self \\ 2)
- !
- odd
- ^ self even not
- ! !
- !Number methodsFor: 'timeouts/intervals'!
- clearInterval
- <clearInterval(Number(self))>
- !
- clearTimeout
- <clearTimeout(Number(self))>
- ! !
- !Number class methodsFor: 'instance creation'!
- pi
- <return Math.PI>
- ! !
- Object subclass: #Boolean
- instanceVariableNames: ''
- category: 'Kernel-Objects'!
- !Boolean methodsFor: 'comparing'!
- = aBoolean
- aBoolean class = self class ifFalse: [^false].
- <return Boolean(self == true) == aBoolean>
- ! !
- !Boolean methodsFor: 'controlling'!
- ifTrue: aBlock
-
- ^self ifTrue: aBlock ifFalse: []
- !
- ifFalse: aBlock
-
- ^self ifTrue: [] ifFalse: aBlock
- !
- ifFalse: aBlock ifTrue: anotherBlock
-
- ^self ifTrue: anotherBlock ifFalse: aBlock
- !
- ifTrue: aBlock ifFalse: anotherBlock
-
- <
- if(self == true) {
- return aBlock();
- } else {
- return anotherBlock();
- }
- >
- !
- and: aBlock
- ^self = true
- ifTrue: aBlock
- ifFalse: [false]
- !
- or: aBlock
- ^self = true
- ifTrue: [true]
- ifFalse: aBlock
- !
- not
- ^self = false
- !
- & aBoolean
- <
- if(self == true) {
- return aBoolean;
- } else {
- return false;
- }
- >
- !
- | aBoolean
- <
- if(self == true) {
- return true;
- } else {
- return aBoolean;
- }
- >
- ! !
- !Boolean methodsFor: 'copying'!
- shallowCopy
- ^self
- !
- deepCopy
- ^self
- ! !
- !Boolean methodsFor: 'printing'!
- printString
- <return self.toString()>
- ! !
- Object subclass: #Date
- instanceVariableNames: ''
- category: 'Kernel-Objects'!
- !Date commentStamp!
- The Date class is used to work with dates and times.!
- !Date methodsFor: 'accessing'!
- year
- <return self.getFullYear()>
- !
- month
- <return self.getMonth() + 1>
- !
- month: aNumber
- <self.setMonth(aNumber - 1)>
- !
- day
- ^self dayOfWeek
- !
- dayOfWeek
- <return self.getDay() + 1>
- !
- dayOfWeek: aNumber
- <return self.setDay(aNumber - 1)>
- !
- day: aNumber
- self day: aNumber
- !
- year: aNumber
- <self.setFullYear(aNumber)>
- !
- dayOfMonth
- <return self.getDate()>
- !
- dayOfMonth: aNumber
- <self.setDate(aNumber)>
- !
- time
- <return self.getTime()>
- !
- time: aNumber
- <self.setTime(aNumber)>
- !
- hours: aNumber
- <self.setHours(aNumber)>
- !
- minutes: aNumber
- <self.setMinutes(aNumber)>
- !
- seconds: aNumber
- <self.setSeconds(aNumber)>
- !
- milliseconds: aNumber
- <self.setMilliseconds(aNumber)>
- !
- hours
- <return self.getHours()>
- !
- minutes
- <return self.getMinutes()>
- !
- seconds
- <return self.getSeconds()>
- !
- milliseconds
- <return self.getMilliseconds()>
- ! !
- !Date methodsFor: 'arithmetic'!
- - aDate
- <return self - aDate>
- !
- + aDate
- <return self + aDate>
- ! !
- !Date methodsFor: 'comparing'!
- < aDate
- <return self < aDate>
- !
- > aDate
- <return self >> aDate>
- !
- <= aDate
- <return self <= aDate>
- !
- >= aDate
- <return self >>= aDate>
- ! !
- !Date methodsFor: 'converting'!
- asString
- <return self.toString()>
- !
- asMilliseconds
- ^self time
- !
- asDateString
- <return self.toDateString()>
- !
- asTimeString
- <return self.toTimeString()>
- !
- asLocaleString
- <return self.toLocaleString()>
- !
- asNumber
- ^self asMilliseconds
- ! !
- !Date methodsFor: 'printing'!
- printString
- ^self asString
- ! !
- !Date class methodsFor: 'instance creation'!
- new: anObject
- <return new Date(anObject)>
- !
- fromString: aString
-
- ^self new: aString
- !
- fromSeconds: aNumber
- ^self fromMilliseconds: aNumber * 1000
- !
- fromMilliseconds: aNumber
- ^self new: aNumber
- !
- today
- ^self new
- !
- now
- ^self today
- !
- millisecondsToRun: aBlock
- | t |
- t := Date now.
- aBlock value.
- ^Date now - t
- ! !
- Object subclass: #UndefinedObject
- instanceVariableNames: ''
- category: 'Kernel-Objects'!
- !UndefinedObject methodsFor: 'class creation'!
- subclass: aString instanceVariableNames: anotherString
- ^self subclass: aString instanceVariableNames: anotherString package: nil
- !
- subclass: aString instanceVariableNames: aString2 category: aString3
-
- self deprecatedAPI.
- ^self subclass: aString instanceVariableNames: aString2 package: aString3
- !
- subclass: aString instanceVariableNames: aString2 package: aString3
- ^ClassBuilder new
- superclass: self subclass: aString instanceVariableNames: aString2 package: aString3
- ! !
- !UndefinedObject methodsFor: 'copying'!
- shallowCopy
- ^self
- !
- deepCopy
- ^self
- ! !
- !UndefinedObject methodsFor: 'printing'!
- printString
- ^'nil'
- ! !
- !UndefinedObject methodsFor: 'testing'!
- ifNil: aBlock
-
- ^self ifNil: aBlock ifNotNil: []
- !
- ifNotNil: aBlock
-
- ^self
- !
- ifNil: aBlock ifNotNil: anotherBlock
-
- ^aBlock value
- !
- ifNotNil: aBlock ifNil: anotherBlock
-
- ^anotherBlock value
- !
- isNil
- ^true
- !
- notNil
- ^false
- ! !
- !UndefinedObject class methodsFor: 'instance creation'!
- new
- self error: 'You cannot create new instances of UndefinedObject. Use nil'
- ! !
- Object subclass: #Random
- instanceVariableNames: ''
- category: 'Kernel-Objects'!
- !Random methodsFor: 'accessing'!
- next
- <return Math.random()>
- !
- next: anInteger
- ^(1 to: anInteger) collect: [:each | self next]
- ! !
- Object subclass: #Point
- instanceVariableNames: 'x y'
- category: 'Kernel-Objects'!
- !Point methodsFor: 'accessing'!
- x
- ^x
- !
- y
- ^y
- !
- y: aNumber
- y := aNumber
- !
- x: aNumber
- x := aNumber
- ! !
- !Point methodsFor: 'arithmetic'!
- * aPoint
- ^Point x: self x * aPoint asPoint x y: self y * aPoint asPoint y
- !
- + aPoint
- ^Point x: self x + aPoint asPoint x y: self y + aPoint asPoint y
- !
- - aPoint
- ^Point x: self x - aPoint asPoint x y: self y - aPoint asPoint y
- !
- / aPoint
- ^Point x: self x / aPoint asPoint x y: self y / aPoint asPoint y
- !
- = aPoint
- ^aPoint class = self class and: [
- (aPoint x = self x) & (aPoint y = self y)]
- ! !
- !Point methodsFor: 'converting'!
- asPoint
- ^self
- ! !
- !Point class methodsFor: 'instance creation'!
- x: aNumber y: anotherNumber
- ^self new
- x: aNumber;
- y: anotherNumber;
- yourself
- ! !
- Object subclass: #JSObjectProxy
- instanceVariableNames: 'jsObject'
- category: 'Kernel-Objects'!
- !JSObjectProxy methodsFor: 'accessing'!
- jsObject: aJSObject
- jsObject := aJSObject
- !
- jsObject
- ^jsObject
- !
- at: aSymbol
- | attr |
- attr := aSymbol asString.
- <return self['@jsObject'][attr]>
- !
- at: aSymbol put: anObject
- | attr |
- attr := aSymbol asString.
- <self['@jsObject'][attr] = anObject>
- ! !
- !JSObjectProxy methodsFor: 'proxy'!
- printString
- ^self jsObject toString
- !
- inspectOn: anInspector
- | variables |
- variables := Dictionary new.
- variables at: '#self' put: self jsObject.
- anInspector setLabel: self printString.
- <for(var i in self['@jsObject']) {
- variables._at_put_(i, self['@jsObject'][i]);
- }>.
- anInspector setVariables: variables
- !
- doesNotUnderstand: aMessage
- | obj selector jsSelector arguments |
- obj := self jsObject.
- selector := aMessage selector.
- jsSelector := selector asJavaScriptSelector.
- arguments := aMessage arguments.
- <if(obj[jsSelector] !!= undefined) {return smalltalk.send(obj, jsSelector, arguments)}>.
- super doesNotUnderstand: aMessage
- ! !
- !JSObjectProxy class methodsFor: 'instance creation'!
- on: aJSObject
- ^self new
- jsObject: aJSObject;
- yourself
- ! !
|