author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 24 Sep 2013 23:18:24 +0200 | |
branch | initialV |
changeset 1180 | 01c6be61f29c |
parent 648 | f6fc4fd5e4ed |
child 722 | 944c5b4027b9 |
permissions | -rw-r--r-- |
445
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
1 |
"{ Package: 'stx:libjavascript' }"! |
208 | 2 |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
3 |
!AbstractTime methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
4 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
5 |
getDate |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
6 |
"return the day of the month (1..31)" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
7 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
8 |
^ self asDate day |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
9 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
10 |
" |
337 | 11 |
JavaScriptParser |
12 |
evaluate:'Date.now.getDate;' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
13 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
14 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
15 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
16 |
!AbstractTime methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
17 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
18 |
getDay |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
19 |
"return the day of the week (0..6); Sunday is 0" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
20 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
21 |
^ self asDate dayOfWeek - 1 |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
22 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
23 |
" |
337 | 24 |
JavaScriptParser |
25 |
evaluate:'Date.now.getDay;' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
26 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
27 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
28 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
29 |
!AbstractTime methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
30 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
31 |
getFullYear |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
32 |
"return the year" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
33 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
34 |
^ self asDate year |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
35 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
36 |
" |
337 | 37 |
JavaScriptParser |
38 |
evaluate:'Date.now.getFullYear;' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
39 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
40 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
41 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
42 |
!AbstractTime methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
43 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
44 |
getHours |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
45 |
"return the hours (0..24)" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
46 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
47 |
^ self asTime hours |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
48 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
49 |
" |
337 | 50 |
JavaScriptParser |
51 |
evaluate:'Date.now.getHours;' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
52 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
53 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
54 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
55 |
!AbstractTime methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
56 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
57 |
getMinutes |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
58 |
"return the minutes (0..60)" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
59 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
60 |
^ self asTime minutes |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
61 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
62 |
" |
337 | 63 |
JavaScriptParser |
64 |
evaluate:'Date.now.getMinutes;' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
65 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
66 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
67 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
68 |
!AbstractTime methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
69 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
70 |
getMonth |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
71 |
"return the day of the month (1..12)" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
72 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
73 |
^ self asDate month |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
74 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
75 |
" |
337 | 76 |
JavaScriptParser |
77 |
evaluate:'Date.now.getMonth;' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
78 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
79 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
80 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
81 |
!AbstractTime methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
82 |
|
445
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
83 |
js_add: aNumberOrString |
345 | 84 |
"For JavaScript only: |
85 |
Generated for +-operator in javascript." |
|
86 |
||
445
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
87 |
^ aNumberOrString js_addFromTime:self |
467 | 88 |
"/^ self + aNumberOrString |
445
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
89 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
90 |
"Modified: / 19-05-2010 / 13:47:11 / cg" |
345 | 91 |
! ! |
92 |
||
93 |
!AbstractTime methodsFor:'Javascript support'! |
|
94 |
||
467 | 95 |
js_addFromTime: aTime |
96 |
"For JavaScript only: |
|
97 |
Generated for +-operator in javascript." |
|
98 |
||
99 |
^ aTime + self |
|
100 |
! ! |
|
101 |
||
102 |
!AbstractTime methodsFor:'Javascript support'! |
|
103 |
||
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
104 |
js_getMilliseconds |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
105 |
"return the millieconds (0..999)" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
106 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
107 |
^ self asTime milliseconds |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
108 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
109 |
" |
337 | 110 |
JavaScriptParser |
111 |
evaluate:'Date.now.js_getMilliseconds;' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
112 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
113 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
114 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
115 |
!AbstractTime methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
116 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
117 |
js_getSeconds |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
118 |
"return the seconds (0..60)" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
119 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
120 |
^ self asTime seconds |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
121 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
122 |
" |
337 | 123 |
JavaScriptParser |
124 |
evaluate:'Date.now.getSeconds;' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
125 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
126 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
127 |
|
208 | 128 |
!ArithmeticValue methodsFor:'JavaScript support'! |
129 |
||
445
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
130 |
js_add: aNumberOrString |
208 | 131 |
"For JavaScript only: |
132 |
Generated for +-operator in javascript." |
|
133 |
||
445
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
134 |
^ aNumberOrString js_addFromNumber:self |
208 | 135 |
|
136 |
"Created: / 08-08-2006 / 11:06:23 / cg" |
|
445
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
137 |
"Modified: / 19-05-2010 / 13:46:47 / cg" |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
138 |
! ! |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
139 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
140 |
!ArithmeticValue methodsFor:'JavaScript support'! |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
141 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
142 |
js_addFromNumber:aNumber |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
143 |
"For JavaScript only: |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
144 |
Generated for +-operator in javascript." |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
145 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
146 |
^ aNumber + self |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
147 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
148 |
"Created: / 19-05-2010 / 13:47:42 / cg" |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
149 |
! ! |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
150 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
151 |
!ArithmeticValue methodsFor:'JavaScript support'! |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
152 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
153 |
js_addFromTime: aTime |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
154 |
"For JavaScript only: |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
155 |
Generated for +-operator in javascript." |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
156 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
157 |
^ aTime + self |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
158 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
159 |
"Created: / 19-05-2010 / 13:48:44 / cg" |
208 | 160 |
! ! |
161 |
||
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
162 |
!Behavior methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
163 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
164 |
js_new |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
165 |
"redefinable JS-new" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
166 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
167 |
^ self new |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
168 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
169 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
170 |
!Behavior methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
171 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
172 |
js_new:argument |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
173 |
"redefinable JS-new:" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
174 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
175 |
^ self new:argument |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
176 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
177 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
178 |
!Block methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
179 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
180 |
typeof |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
181 |
"return a string describing what I am" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
182 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
183 |
^ 'function' |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
184 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
185 |
" |
337 | 186 |
JavaScriptParser |
187 |
evaluate:'''hello''.typeof()' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
188 |
|
337 | 189 |
JavaScriptParser |
190 |
evaluate:'(function (a,b) { return a; }).typeof();' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
191 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
192 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
193 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
194 |
!Boolean methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
195 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
196 |
typeof |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
197 |
"return a string describing what I am" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
198 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
199 |
^ 'boolean' |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
200 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
201 |
" |
337 | 202 |
JavaScriptParser |
203 |
evaluate:'''hello''.typeof()' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
204 |
|
337 | 205 |
JavaScriptParser |
206 |
evaluate:'false.typeof();' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
207 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
208 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
209 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
210 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
211 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
212 |
charAt0:index |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
213 |
"returns the n'th character, using a 0-based indexing scheme (sigh)" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
214 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
215 |
^ ( self at:(index-1) ) asString. |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
216 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
217 |
" |
337 | 218 |
JavaScriptParser |
219 |
evaluate:'''hello''.charAt0(0)' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
220 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
221 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
222 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
223 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
224 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
225 |
charAt1:index |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
226 |
"returns the n'th character, using a 1-based indexing scheme (sigh)" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
227 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
228 |
^ ( self at:index ) asString. |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
229 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
230 |
" |
337 | 231 |
JavaScriptParser |
232 |
evaluate:'''hello''.charAt1(1)' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
233 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
234 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
235 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
236 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
237 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
238 |
charCodeAt0:index |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
239 |
"returns the code of the n'th character, using a 0-based indexing scheme (sigh)" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
240 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
241 |
^ ( self at:(index-1) ) codePoint. |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
242 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
243 |
" |
337 | 244 |
JavaScriptParser |
245 |
evaluate:'''hello''.charCodeAt0(0)' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
246 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
247 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
248 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
249 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
250 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
251 |
charCodeAt1:index |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
252 |
"returns the code of the n'th character, using a 1-based indexing scheme (sigh)" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
253 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
254 |
^ ( self at:index ) codePoint. |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
255 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
256 |
" |
337 | 257 |
JavaScriptParser |
258 |
evaluate:'''hello''.charCodeAt1(1)' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
259 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
260 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
261 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
262 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
263 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
264 |
indexOf0:aCharacter |
317 | 265 |
"returns the index of aCharacter, using a 0-based indexing scheme; -1 if not found (sigh)" |
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
266 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
267 |
aCharacter isCharacter ifFalse:[ |
337 | 268 |
self assert:aCharacter size == 1. |
269 |
^ self indexOf0:(aCharacter at:1) |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
270 |
]. |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
271 |
^ (self indexOf:aCharacter) - 1 |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
272 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
273 |
" |
337 | 274 |
JavaScriptParser |
275 |
evaluate:'''hello''.indexOf0(''l'')' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
276 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
277 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
278 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
279 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
280 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
281 |
indexOf1:aCharacter |
317 | 282 |
"returns the index of aCharacter, using a 1-based indexing scheme; 0 if not found (sigh)" |
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
283 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
284 |
aCharacter isCharacter ifFalse:[ |
337 | 285 |
self assert:aCharacter size == 1. |
286 |
^ self indexOf1:(aCharacter at:1) |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
287 |
]. |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
288 |
^ (self indexOf:aCharacter) |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
289 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
290 |
" |
337 | 291 |
JavaScriptParser |
292 |
evaluate:'''hello''.indexOf0(''l'')' |
|
293 |
" |
|
294 |
! ! |
|
295 |
||
296 |
!CharacterArray methodsFor:'JavaScript support'! |
|
297 |
||
445
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
298 |
js_add:something |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
299 |
"For JavaScript only: |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
300 |
Generated for +-operator in javascript." |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
301 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
302 |
^ something js_addFromString:self |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
303 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
304 |
"Created: / 19-05-2010 / 13:50:28 / cg" |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
305 |
! ! |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
306 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
307 |
!CharacterArray methodsFor:'JavaScript support'! |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
308 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
309 |
js_addFromNumber:aNumber |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
310 |
"For JavaScript only: |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
311 |
Generated for +-operator in javascript." |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
312 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
313 |
^ aNumber printString , self |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
314 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
315 |
"Created: / 19-05-2010 / 13:49:34 / cg" |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
316 |
! ! |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
317 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
318 |
!CharacterArray methodsFor:'JavaScript support'! |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
319 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
320 |
js_addFromString:aString |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
321 |
"For JavaScript only: |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
322 |
Generated for +-operator in javascript." |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
323 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
324 |
^ aString , self |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
325 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
326 |
"Created: / 19-05-2010 / 13:50:42 / cg" |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
327 |
! ! |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
328 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
329 |
!CharacterArray methodsFor:'JavaScript support'! |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
330 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
331 |
js_addFromTime:aTime |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
332 |
"For JavaScript only: |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
333 |
Generated for +-operator in javascript." |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
334 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
335 |
^ aTime printString , self |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
336 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
337 |
"Created: / 19-05-2010 / 13:49:46 / cg" |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
338 |
! ! |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
339 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
340 |
!CharacterArray methodsFor:'JavaScript support'! |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
341 |
|
337 | 342 |
lastIndexOf0:aCharacter |
343 |
"returns the last index of aCharacter, using a 0-based indexing scheme; -1 if not found (sigh)" |
|
344 |
||
345 |
aCharacter isCharacter ifFalse:[ |
|
346 |
self assert:aCharacter size == 1. |
|
347 |
^ self lastIndexOf0:(aCharacter at:1) |
|
348 |
]. |
|
349 |
^ (self lastIndexOf:aCharacter) - 1 |
|
350 |
||
351 |
" |
|
352 |
JavaScriptParser |
|
353 |
evaluate:'''hello''.lastIndexOf0(''l'')' |
|
354 |
" |
|
355 |
! ! |
|
356 |
||
357 |
!CharacterArray methodsFor:'JavaScript support'! |
|
358 |
||
359 |
lastIndexOf1:aCharacter |
|
360 |
"returns the last index of aCharacter, using a 1-based indexing scheme; 0 if not found (sigh)" |
|
361 |
||
362 |
aCharacter isCharacter ifFalse:[ |
|
363 |
self assert:aCharacter size == 1. |
|
364 |
^ self lastIndexOf1:(aCharacter at:1) |
|
365 |
]. |
|
366 |
^ (self lastIndexOf:aCharacter) |
|
367 |
||
368 |
" |
|
369 |
JavaScriptParser |
|
370 |
evaluate:'''hello''.lastIndexOf1(''l'')' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
371 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
372 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
373 |
|
208 | 374 |
!CharacterArray methodsFor:'JavaScript support'! |
375 |
||
337 | 376 |
quote |
377 |
"wraps the receiver into quotes" |
|
378 |
||
379 |
^ '"',self,'"' |
|
318 | 380 |
|
337 | 381 |
" |
382 |
JavaScriptParser |
|
383 |
evaluate:'''hello''.quote' |
|
384 |
" |
|
318 | 385 |
! ! |
386 |
||
387 |
!CharacterArray methodsFor:'JavaScript support'! |
|
388 |
||
337 | 389 |
split:separator |
390 |
"splits into an array of substrings" |
|
391 |
||
392 |
separator isCharacter ifTrue:[ |
|
393 |
^ self asCollectionOfSubstringsSeparatedBy:separator |
|
394 |
]. |
|
395 |
(separator isString and:[separator size == 1]) ifTrue:[ |
|
396 |
^ self asCollectionOfSubstringsSeparatedBy:(separator first) |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
397 |
]. |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
398 |
^ self asCollectionOfSubstringsSeparatedByAll:separator |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
399 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
400 |
" |
337 | 401 |
JavaScriptParser |
402 |
evaluate:'''bla-fasel-suelz''.split(''-'')' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
403 |
|
337 | 404 |
JavaScriptParser |
405 |
evaluate:'''bla - fasel - suelz''.split('' - '')' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
406 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
407 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
408 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
409 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
410 |
|
337 | 411 |
substr0:index _:count |
412 |
"extracts a substring, using a 0-based indexing scheme (sigh)" |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
413 |
|
337 | 414 |
^ self copyFrom:(index+1) to:(index+count) |
415 |
||
416 |
" |
|
417 |
JavaScriptParser |
|
418 |
evaluate:'''helloWorld''.substr0(3,4)' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
419 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
420 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
421 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
422 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
423 |
|
337 | 424 |
substr1:index _:count |
425 |
"extracts a substring, using a 1-based indexing scheme (sigh)" |
|
426 |
||
427 |
^ self copyFrom:index to:(index-1+count) |
|
428 |
||
429 |
" |
|
430 |
JavaScriptParser |
|
431 |
evaluate:'''helloWorld''.substr1(3,4)' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
432 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
433 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
434 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
435 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
436 |
|
337 | 437 |
substring0:index1 |
438 |
"extracts a substring, using a 0-based indexing scheme (sigh)" |
|
439 |
||
440 |
^ self copyFrom:(index1+1) |
|
441 |
||
442 |
" |
|
443 |
JavaScriptParser |
|
444 |
evaluate:'''helloWorld''.substring0(3)' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
445 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
446 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
447 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
448 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
449 |
|
337 | 450 |
substring0:index1 _:index2 |
451 |
"extracts a substring, using a 0-based indexing scheme (sigh)" |
|
452 |
||
453 |
^ self copyFrom:(index1+1) to:(index2+1) |
|
454 |
||
455 |
" |
|
456 |
JavaScriptParser |
|
457 |
evaluate:'''helloWorld''.substring0(3,6)' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
458 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
459 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
460 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
461 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
462 |
|
337 | 463 |
substring1:index1 |
464 |
"extracts a substring, using a 1-based indexing scheme (sigh)" |
|
465 |
||
466 |
^ self copyFrom:index1 |
|
467 |
||
468 |
" |
|
469 |
JavaScriptParser |
|
470 |
evaluate:'''helloWorld''.substring1(3)' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
471 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
472 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
473 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
474 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
475 |
|
337 | 476 |
substring1:index1 _:index2 |
477 |
"extracts a substring, using a 1-based indexing scheme (sigh)" |
|
478 |
||
479 |
^ self copyFrom:index1 to:index2 |
|
480 |
||
481 |
" |
|
482 |
JavaScriptParser |
|
483 |
evaluate:'''helloWorld''.substring1(3,6)' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
484 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
485 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
486 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
487 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
488 |
|
337 | 489 |
toLowerCase |
490 |
"returns a copy of the receiver with all chars in lower case" |
|
491 |
||
492 |
^ self asLowercase |
|
493 |
||
494 |
" |
|
495 |
JavaScriptParser |
|
496 |
evaluate:'''HeLLo''.toLowerCase' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
497 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
498 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
499 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
500 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
501 |
|
337 | 502 |
toUpperCase |
503 |
"returns a copy of the receiver with all chars in upper case" |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
504 |
|
337 | 505 |
^ self asUppercase |
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
506 |
|
337 | 507 |
" |
508 |
JavaScriptParser |
|
509 |
evaluate:'''HeLLo''.toUpperCase' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
510 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
511 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
512 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
513 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
514 |
|
337 | 515 |
trim |
516 |
"returns a copy of the receiver with all leading and trailing whiteSpace removed" |
|
517 |
||
518 |
^ self withoutSeparators |
|
519 |
||
520 |
" |
|
521 |
JavaScriptParser |
|
522 |
evaluate:''' He LLo ''.trim' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
523 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
524 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
525 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
526 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
527 |
|
337 | 528 |
trimLeft |
529 |
"returns a copy of the receiver with all leading whiteSpace removed" |
|
530 |
||
531 |
^ self withoutLeadingSeparators |
|
532 |
||
533 |
" |
|
534 |
JavaScriptParser |
|
535 |
evaluate:''' HeLLo ''.trimLeft' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
536 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
537 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
538 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
539 |
!CharacterArray methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
540 |
|
337 | 541 |
trimRight |
542 |
"returns a copy of the receiver with all trailing whiteSpace removed" |
|
543 |
||
544 |
^ self withoutTrailingSeparators |
|
545 |
||
546 |
" |
|
547 |
JavaScriptParser |
|
548 |
evaluate:''' HeLLo ''.trimRight' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
549 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
550 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
551 |
|
336 | 552 |
!CharacterArray methodsFor:'JavaScript support'! |
553 |
||
337 | 554 |
typeof |
555 |
"return a string describing what I am" |
|
556 |
||
557 |
^ 'string' |
|
558 |
||
559 |
" |
|
560 |
JavaScriptParser |
|
561 |
evaluate:'''hello''.typeof()' |
|
562 |
||
563 |
JavaScriptParser |
|
564 |
evaluate:'1234.typeof()' |
|
565 |
" |
|
336 | 566 |
! ! |
567 |
||
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
568 |
!Collection methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
569 |
|
337 | 570 |
length |
571 |
"returns the length of the string" |
|
572 |
||
573 |
^ self size |
|
267
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
574 |
|
337 | 575 |
" |
576 |
JavaScriptParser |
|
577 |
evaluate:'''hello''.length' |
|
578 |
" |
|
267
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
579 |
! ! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
580 |
|
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
581 |
!Collection class methodsFor:'JS syntactic sugar'! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
582 |
|
337 | 583 |
with:el1 _:el2 |
584 |
"for JS easy syntax - allows: Array.with(el1, el2,...)" |
|
585 |
||
586 |
^ self with:el1 with:el2 |
|
587 |
! ! |
|
267
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
588 |
|
337 | 589 |
!Collection class methodsFor:'JS syntactic sugar'! |
590 |
||
591 |
with:el1 _:el2 _:el3 |
|
592 |
"for JS easy syntax - allows: Array.with(el1, el2,...)" |
|
593 |
||
594 |
^ self with:el1 with:el2 with:el3 |
|
267
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
595 |
! ! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
596 |
|
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
597 |
!Collection class methodsFor:'JS syntactic sugar'! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
598 |
|
337 | 599 |
with:el1 _:el2 _:el3 _:el4 |
600 |
"for JS easy syntax - allows: Array.with(el1, el2,...)" |
|
267
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
601 |
|
337 | 602 |
^ self with:el1 with:el2 with:el3 with:el4 |
267
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
603 |
! ! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
604 |
|
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
605 |
!Collection class methodsFor:'JS syntactic sugar'! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
606 |
|
337 | 607 |
with:el1 _:el2 _:el3 _:el4 _:el5 |
608 |
"for JS easy syntax - allows: Array.with(el1, el2,...)" |
|
609 |
||
610 |
^ self with:el1 with:el2 with:el3 with:el4 with:el5 |
|
611 |
! ! |
|
612 |
||
613 |
!Collection class methodsFor:'JS syntactic sugar'! |
|
614 |
||
615 |
with:el1 _:el2 _:el3 _:el4 _:el5 _:el6 |
|
267
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
616 |
"for JS easy syntax - allows: Array.with(el1, el2,...)" |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
617 |
|
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
618 |
^ self with:el1 with:el2 with:el3 with:el4 with:el5 with:el6 |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
619 |
! ! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
620 |
|
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
621 |
!Collection class methodsFor:'JS syntactic sugar'! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
622 |
|
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
623 |
with:el1 _:el2 _:el3 _:el4 _:el5 _:el6 _:el7 |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
624 |
"for JS easy syntax - allows: Array.with(el1, el2,...)" |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
625 |
|
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
626 |
^ self with:el1 with:el2 with:el3 with:el4 with:el5 with:el6 with:el7 |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
627 |
! ! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
628 |
|
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
629 |
!Collection class methodsFor:'JS syntactic sugar'! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
630 |
|
337 | 631 |
with:el1 _:el2 _:el3 _:el4 _:el5 _:el6 _:el7 _:el8 |
632 |
"for JS easy syntax - allows: Array.with(el1, el2,...)" |
|
633 |
||
634 |
^ self with:el1 with:el2 with:el3 with:el4 with:el5 with:el6 with:el7 with:el8 |
|
267
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
635 |
! ! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
636 |
|
337 | 637 |
!Date class methodsFor:'Javascript support'! |
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
638 |
|
337 | 639 |
js_new:aString |
640 |
"return a parsed dateobejct" |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
641 |
|
337 | 642 |
Timestamp readFrom:aString |
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
643 |
|
337 | 644 |
" |
645 |
JavaScriptParser |
|
646 |
evaluate:'(new Date(''July 21, 1983 01:15:00''));' |
|
647 |
" |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
648 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
649 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
650 |
!Date class methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
651 |
|
337 | 652 |
now |
653 |
"return the current date" |
|
654 |
||
655 |
^ Timestamp now |
|
656 |
||
657 |
" |
|
658 |
JavaScriptParser |
|
659 |
evaluate:'Date.now.getDate;' |
|
660 |
" |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
661 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
662 |
|
469 | 663 |
!GenericException class methodsFor:'instance creation'! |
664 |
||
470 | 665 |
js_new:errorString |
666 |
"sent from js in: |
|
469 | 667 |
throw new Error(msg) |
668 |
" |
|
470 | 669 |
|
670 |
^ self new |
|
671 |
errorString:errorString |
|
469 | 672 |
|
470 | 673 |
" |
674 |
(Error js_new:'hello') raise |
|
675 |
" |
|
676 |
||
677 |
"Modified: / 28-06-2010 / 17:49:24 / cg" |
|
469 | 678 |
! ! |
679 |
||
337 | 680 |
!Number methodsFor:'Javascript support'! |
681 |
||
682 |
toExponential:nDigits |
|
683 |
"return a string representing the number in exponential notation" |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
684 |
|
337 | 685 |
self assert:(nDigits isInteger). |
686 |
self assert:(nDigits between:0 and:50). |
|
687 |
||
688 |
^ self asFloat printfPrintString:('%.',nDigits printString,'f') |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
689 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
690 |
" |
337 | 691 |
JavaScriptParser |
692 |
evaluate:'new Number(10000);' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
693 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
694 |
" |
337 | 695 |
JavaScriptParser |
696 |
evaluate:'(new Number(10000)).toExponential(1)' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
697 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
698 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
699 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
700 |
!Number methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
701 |
|
337 | 702 |
toExponential:nDigits _:nDigitsAfter |
703 |
"return a string representing the number in exponential notation" |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
704 |
|
337 | 705 |
self assert:(nDigits isInteger). |
706 |
self assert:(nDigits between:0 and:50). |
|
707 |
self assert:(nDigitsAfter isInteger). |
|
708 |
self assert:(nDigitsAfter between:0 and:50). |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
709 |
|
337 | 710 |
^ self asFloat printfPrintString:('%',nDigits printString,'.',nDigitsAfter printString,'f') |
711 |
||
712 |
" |
|
713 |
JavaScriptParser |
|
714 |
evaluate:'(new Number(10000)).toExponential(4,2)' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
715 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
716 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
717 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
718 |
!Number methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
719 |
|
337 | 720 |
toFixed:nDigits |
721 |
"return a string representing the number in fixed notation" |
|
722 |
||
723 |
self assert:(nDigits isInteger). |
|
724 |
self assert:(nDigits between:0 and:50). |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
725 |
|
337 | 726 |
^ (self asFixedPoint:nDigits) printString |
313 | 727 |
|
337 | 728 |
" |
729 |
JavaScriptParser |
|
730 |
evaluate:'(new Number(10000)).toFixed(10)' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
731 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
732 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
733 |
|
336 | 734 |
!Number methodsFor:'Javascript support'! |
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
735 |
|
337 | 736 |
typeof |
737 |
"return a string describing what I am" |
|
738 |
||
739 |
^ 'number' |
|
740 |
||
741 |
" |
|
742 |
JavaScriptParser |
|
743 |
evaluate:'''hello''.typeof()' |
|
744 |
||
745 |
JavaScriptParser |
|
746 |
evaluate:'1234.typeof();' |
|
747 |
||
748 |
JavaScriptParser |
|
749 |
evaluate:'typeof (1234)' |
|
750 |
||
751 |
JavaScriptParser |
|
752 |
evaluate:'typeof 1234' |
|
753 |
" |
|
754 |
! ! |
|
755 |
||
756 |
!Number class methodsFor:'Javascript support'! |
|
757 |
||
758 |
MAX_VALUE |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
759 |
"in expecco/stx-JS, there is no MAX_VALUE; |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
760 |
return something useful (simulate 64bits)" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
761 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
762 |
^ 16r7FFFFFFFFFFFFFFF |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
763 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
764 |
" |
337 | 765 |
JavaScriptParser |
766 |
evaluate:'Number.MAX_VALUE;' |
|
767 |
" |
|
768 |
! ! |
|
769 |
||
770 |
!Number class methodsFor:'Javascript support'! |
|
771 |
||
772 |
MIN_VALUE |
|
773 |
"in expecco/stx-JS, there is no MIN_VALUE; |
|
774 |
return something useful (simulate 64bits)" |
|
775 |
||
776 |
^ -16r8000000000000000 |
|
777 |
||
778 |
" |
|
779 |
JavaScriptParser |
|
780 |
evaluate:'Number.MIN_VALUE;' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
781 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
782 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
783 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
784 |
!Number class methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
785 |
|
337 | 786 |
NEGATIVE_INFINITY |
787 |
"return the special 'negative infinity' value" |
|
788 |
||
789 |
^ Float negativeInfinity |
|
790 |
||
791 |
" |
|
792 |
JavaScriptParser |
|
793 |
evaluate:'Number.NEGATIVE_INFINITY;' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
794 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
795 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
796 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
797 |
!Number class methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
798 |
|
337 | 799 |
NaN |
800 |
"return the special 'not a number' value" |
|
801 |
||
802 |
^ Float NaN |
|
803 |
||
804 |
" |
|
805 |
JavaScriptParser |
|
806 |
evaluate:'Number.NaN;' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
807 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
808 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
809 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
810 |
!Number class methodsFor:'Javascript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
811 |
|
337 | 812 |
POSITIVE_INFINITY |
813 |
"return the special 'positive infinity' value" |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
814 |
|
337 | 815 |
^ Float infinity |
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
816 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
817 |
" |
337 | 818 |
JavaScriptParser |
819 |
evaluate:'Number.POSITIVE_INFINITY;' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
820 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
821 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
822 |
|
336 | 823 |
!Number class methodsFor:'Javascript support'! |
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
824 |
|
337 | 825 |
js_new:argument |
826 |
^ argument |
|
827 |
||
828 |
" |
|
829 |
JavaScriptParser |
|
469 | 830 |
evaluate:'new Number(100)' |
831 |
||
832 |
JavaScriptParser |
|
833 |
evaluate:'new Error(''hello'')' |
|
337 | 834 |
" |
469 | 835 |
|
836 |
"Modified: / 28-06-2010 / 17:27:52 / cg" |
|
336 | 837 |
! ! |
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
838 |
|
336 | 839 |
!Object methodsFor:'Javascript support'! |
840 |
||
445
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
841 |
js_addFromString:aString |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
842 |
"For JavaScript only: |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
843 |
Generated for +-operator in javascript." |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
844 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
845 |
^ aString , self printString |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
846 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
847 |
"Created: / 19-05-2010 / 13:51:24 / cg" |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
848 |
! ! |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
849 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
850 |
!Object methodsFor:'Javascript support'! |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
851 |
|
337 | 852 |
typeof |
853 |
"return a string describing what I am" |
|
854 |
||
855 |
^ 'object' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
856 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
857 |
" |
337 | 858 |
JavaScriptParser |
859 |
evaluate:'''hello''.typeof()' |
|
860 |
||
861 |
JavaScriptParser |
|
862 |
evaluate:'1234.typeof()' |
|
863 |
" |
|
864 |
! ! |
|
865 |
||
866 |
!SequenceableCollection methodsFor:'JavaScript support'! |
|
867 |
||
868 |
concat:aCollection |
|
869 |
"returns a new collection consisting of the concatenation of the receiver and the argument" |
|
870 |
||
871 |
^ self , aCollection |
|
872 |
||
873 |
" |
|
874 |
JavaScriptParser |
|
875 |
evaluate:'''hello''.concat(''world'')' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
876 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
877 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
878 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
879 |
!SequenceableCollection methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
880 |
|
337 | 881 |
every:filterFunction |
882 |
"return true, if filterFunction returns true for all elements" |
|
883 |
||
884 |
^ self conform:filterFunction |
|
885 |
! ! |
|
886 |
||
887 |
!SequenceableCollection methodsFor:'JavaScript support'! |
|
888 |
||
889 |
filter:filterFunction |
|
890 |
"select elements for which filterFunction returns true" |
|
891 |
||
892 |
^ self select:filterFunction |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
893 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
894 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
895 |
!SequenceableCollection methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
896 |
|
337 | 897 |
forEach:function |
898 |
"apply function for each element" |
|
899 |
||
900 |
^ self do:function |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
901 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
902 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
903 |
!SequenceableCollection methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
904 |
|
337 | 905 |
indexOf0:anElement |
906 |
"returns the index of anElement, using a 0-based indexing scheme; 0 if not found (sigh)" |
|
319 | 907 |
|
908 |
^ (self indexOf:anElement)-1 |
|
909 |
||
910 |
" |
|
337 | 911 |
JavaScriptParser |
912 |
evaluate:'[10,20,30,40].indexOf0(20)' |
|
319 | 913 |
" |
914 |
! ! |
|
915 |
||
916 |
!SequenceableCollection methodsFor:'JavaScript support'! |
|
917 |
||
337 | 918 |
indexOf1:anElement |
919 |
"returns the index of anElement, using a 1-based indexing scheme; 0 if not found (sigh)" |
|
319 | 920 |
|
337 | 921 |
^ (self indexOf:anElement) |
319 | 922 |
|
923 |
" |
|
337 | 924 |
JavaScriptParser |
925 |
evaluate:'[10,20,30,40].indexOf1(20)' |
|
319 | 926 |
" |
927 |
! ! |
|
928 |
||
929 |
!SequenceableCollection methodsFor:'JavaScript support'! |
|
930 |
||
337 | 931 |
join:separator |
932 |
"joins the strings of the receiver into a single string" |
|
933 |
||
934 |
^ self asStringWith:separator |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
935 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
936 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
937 |
!SequenceableCollection methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
938 |
|
338 | 939 |
js_add: aCollection |
940 |
"For JavaScript only: |
|
941 |
Alternative string-concatenation. |
|
942 |
Generated for +-operator in javascript." |
|
943 |
||
944 |
^ self , aCollection |
|
945 |
||
946 |
" |
|
947 |
'hello' + $1 - fails in ST |
|
948 |
'hello' + '1' - fails in ST |
|
949 |
||
950 |
'hello' js_add: $1 - ok in JS |
|
951 |
'hello' js_add: '1' - ok in JS |
|
952 |
" |
|
953 |
||
954 |
"Created: / 08-08-2006 / 11:05:45 / cg" |
|
955 |
! ! |
|
956 |
||
957 |
!SequenceableCollection methodsFor:'JavaScript support'! |
|
958 |
||
445
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
959 |
js_map:function |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
960 |
"return a new collection collecting the results of applying function to each |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
961 |
element in sequence" |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
962 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
963 |
^ self collect:function |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
964 |
! ! |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
965 |
|
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
966 |
!SequenceableCollection methodsFor:'JavaScript support'! |
5b96e383f224
double dispatching for '+' (add/string concatenation) operator.
Claus Gittinger <cg@exept.de>
parents:
419
diff
changeset
|
967 |
|
337 | 968 |
lastIndexOf0:anElement |
969 |
"returns the last index of anElement, using a 0-based indexing scheme; 0 if not found (sigh)" |
|
319 | 970 |
|
971 |
^ (self lastIndexOf:anElement)-1 |
|
972 |
||
973 |
" |
|
337 | 974 |
JavaScriptParser |
975 |
evaluate:'[10,20,30,20,40].lastIndexOf0(20)' |
|
319 | 976 |
" |
977 |
! ! |
|
978 |
||
979 |
!SequenceableCollection methodsFor:'JavaScript support'! |
|
980 |
||
337 | 981 |
lastIndexOf1:anElement |
982 |
"returns the last index of anElement, using a 1-based indexing scheme; 0 if not found (sigh)" |
|
336 | 983 |
|
337 | 984 |
^ (self lastIndexOf:anElement) |
336 | 985 |
|
986 |
" |
|
337 | 987 |
JavaScriptParser |
988 |
evaluate:'[10,20,30,20,40].lastIndexOf1(20)' |
|
336 | 989 |
" |
990 |
! ! |
|
991 |
||
992 |
!SequenceableCollection methodsFor:'JavaScript support'! |
|
993 |
||
337 | 994 |
pop |
995 |
"removes and returns the last element of the collection" |
|
996 |
||
997 |
^ self removeLast |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
998 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
999 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1000 |
!SequenceableCollection methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1001 |
|
337 | 1002 |
push:value |
1003 |
"adds value at the end of the collection; returns the new size" |
|
1004 |
||
1005 |
self addLast:value. |
|
1006 |
^ self size. |
|
1007 |
! ! |
|
1008 |
||
1009 |
!SequenceableCollection methodsFor:'JavaScript support'! |
|
1010 |
||
1011 |
reduce0:filterFunction |
|
1012 |
"apply function against two values, reducing from left to right. |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1013 |
Function must be declared as: f(previousValue, currentValue, index, arr). |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1014 |
Pass 0-based indices to the filter." |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1015 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1016 |
|accum| |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1017 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1018 |
accum := self first. |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1019 |
2 to:self size do:[:idx | |
337 | 1020 |
|current| |
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1021 |
|
337 | 1022 |
current := self at:idx. |
1023 |
accum := filterFunction value:accum value:current value:(idx-1) value:self. |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1024 |
]. |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1025 |
^ accum. |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1026 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1027 |
" |
337 | 1028 |
#(1 2 3 4 5 6 7 8 9 10) reduce0:[:prev :this :idx :arr | prev + this] |
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1029 |
|
337 | 1030 |
JavaScriptParser |
1031 |
evaluate:' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1032 |
[0,1,2,3,4].reduce(function(previousValue, currentValue, index, array){ |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1033 |
return previousValue + currentValue; |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1034 |
}); |
337 | 1035 |
' |
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1036 |
|
337 | 1037 |
JavaScriptParser |
1038 |
evaluate:'[0,1,2,3,4].length;' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1039 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1040 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1041 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1042 |
!SequenceableCollection methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1043 |
|
337 | 1044 |
reduce0:filterFunction _:initialValue |
1045 |
"apply function against two values, reducing from left to right. |
|
1046 |
Function must be declared as: f(previousValue, currentValue, index, arr). |
|
1047 |
Pass 0-based indices to the filter." |
|
336 | 1048 |
|
337 | 1049 |
|accum| |
336 | 1050 |
|
337 | 1051 |
accum := initialValue. |
1052 |
1 to:self size do:[:idx | |
|
1053 |
|current| |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1054 |
|
337 | 1055 |
current := self at:idx. |
1056 |
accum := filterFunction value:accum value:current value:(idx-1) value:self. |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1057 |
]. |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1058 |
^ accum. |
336 | 1059 |
! ! |
1060 |
||
1061 |
!SequenceableCollection methodsFor:'JavaScript support'! |
|
1062 |
||
337 | 1063 |
reduce1:filterFunction |
1064 |
"apply function against two values, reducing from left to right. |
|
1065 |
Function must be declared as: f(previousValue, currentValue, index, arr). |
|
1066 |
Pass 1-based indices to the filter." |
|
1067 |
||
1068 |
|accum| |
|
1069 |
||
1070 |
accum := self first. |
|
1071 |
2 to:self size do:[:idx | |
|
1072 |
|current| |
|
1073 |
||
1074 |
current := self at:idx. |
|
1075 |
accum := filterFunction value:accum value:current value:idx value:self. |
|
1076 |
]. |
|
1077 |
^ accum. |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1078 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1079 |
" |
337 | 1080 |
#(1 2 3 4 5 6 7 8 9 10) reduce1:[:prev :this :idx :arr | prev + this] |
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1081 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1082 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1083 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1084 |
!SequenceableCollection methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1085 |
|
337 | 1086 |
reduce1:filterFunction _:initialValue |
1087 |
"apply function against two values, reducing from left to right. |
|
1088 |
Function must be declared as: f(previousValue, currentValue, index, arr). |
|
1089 |
Pass 1-based indices to the filter." |
|
1090 |
||
1091 |
|accum| |
|
1092 |
||
1093 |
accum := initialValue. |
|
1094 |
1 to:self size do:[:idx | |
|
1095 |
|current| |
|
1096 |
||
1097 |
current := self at:idx. |
|
1098 |
accum := filterFunction value:accum value:current value:idx value:self. |
|
1099 |
]. |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1100 |
^ accum. |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1101 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1102 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1103 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1104 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1105 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1106 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1107 |
!SequenceableCollection methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1108 |
|
337 | 1109 |
shift |
1110 |
"removes and returns the first element of the collection" |
|
1111 |
||
1112 |
^ self removeFirst |
|
1113 |
! ! |
|
1114 |
||
1115 |
!SequenceableCollection methodsFor:'JavaScript support'! |
|
1116 |
||
1117 |
slice0:index1 _:index2 |
|
1118 |
"extracts a subcollection, using a 0-based indexing scheme" |
|
1119 |
||
1120 |
^ self copyFrom:(index1+1) to:(index2+1) |
|
1121 |
||
1122 |
" |
|
1123 |
JavaScriptParser |
|
1124 |
evaluate:'''hello''.slice0(1,3)' |
|
1125 |
" |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1126 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1127 |
|
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1128 |
!SequenceableCollection methodsFor:'JavaScript support'! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1129 |
|
337 | 1130 |
slice1:index1 _:index2 |
1131 |
"extracts a subcollection, using a 1-based indexing scheme" |
|
1132 |
||
1133 |
^ self copyFrom:index1 to:index2 |
|
1134 |
||
1135 |
" |
|
1136 |
JavaScriptParser |
|
1137 |
evaluate:'''hello''.slice0(1,3)' |
|
1138 |
" |
|
1139 |
! ! |
|
1140 |
||
1141 |
!SequenceableCollection methodsFor:'JavaScript support'! |
|
1142 |
||
1143 |
some:filterFunction |
|
1144 |
"return true, if filterfunction returns true for any element" |
|
1145 |
||
1146 |
^ self contains:filterFunction |
|
1147 |
! ! |
|
1148 |
||
1149 |
!SequenceableCollection methodsFor:'JavaScript support'! |
|
1150 |
||
1151 |
unshift:arg |
|
1152 |
"adds an element to the beginning of the collection" |
|
1153 |
||
1154 |
self addFirst:arg. |
|
1155 |
^ self size |
|
1156 |
! ! |
|
1157 |
||
267
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1158 |
!Stream methodsFor:'JS syntactic sugar'! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1159 |
|
337 | 1160 |
show:aString _:arg1 |
1161 |
"for JS easy syntax - allows: Transcript.show('format %1', arg1)" |
|
1162 |
||
1163 |
self show:(aString bindWith:arg1). |
|
1164 |
! ! |
|
1165 |
||
1166 |
!Stream methodsFor:'JS syntactic sugar'! |
|
1167 |
||
1168 |
show:aString _:arg1 _:arg2 |
|
1169 |
"for JS easy syntax - allows: Transcript.show('format %1 %2', arg1, arg2)" |
|
1170 |
||
1171 |
self show:(aString bindWith:arg1 with:arg2). |
|
1172 |
! ! |
|
1173 |
||
1174 |
!Stream methodsFor:'JS syntactic sugar'! |
|
1175 |
||
1176 |
show:aString _:arg1 _:arg2 _:arg3 |
|
1177 |
"for JS easy syntax - allows: Transcript.show('format %1 %2', arg1,...)" |
|
268
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1178 |
|
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1179 |
self show:(aString bindWith:arg1 with:arg2 with:arg3). |
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1180 |
! ! |
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1181 |
|
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1182 |
!Stream methodsFor:'JS syntactic sugar'! |
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1183 |
|
337 | 1184 |
show:aString _:arg1 _:arg2 _:arg3 _:arg4 |
268
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1185 |
"for JS easy syntax - allows: Transcript.show('format %1 %2', arg1,...)" |
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1186 |
|
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1187 |
self show:(aString bindWith:arg1 with:arg2 with:arg3 with:arg4). |
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1188 |
! ! |
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1189 |
|
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1190 |
!Stream methodsFor:'JS syntactic sugar'! |
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1191 |
|
337 | 1192 |
show:aString _:arg1 _:arg2 _:arg3 _:arg4 _:arg5 |
1193 |
"for JS easy syntax - allows: Transcript.show('format %1 %2', arg1,...)" |
|
1194 |
||
1195 |
self show:(aString bindWith:arg1 with:arg2 with:arg3 with:arg4 with:arg5). |
|
268
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1196 |
! ! |
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1197 |
|
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1198 |
!Stream methodsFor:'JS syntactic sugar'! |
b3bf0feaf0e7
syntactic sugar for stream-show
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
1199 |
|
479 | 1200 |
show:aString _:arg1 _:arg2 _:arg3 _:arg4 _:arg5 _:arg6 |
1201 |
"for JS easy syntax - allows: Transcript.show('format %1 %2', arg1,...)" |
|
1202 |
||
1203 |
self show:(aString bindWith:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6). |
|
1204 |
||
1205 |
"Created: / 19-08-2010 / 15:39:12 / cg" |
|
1206 |
! ! |
|
1207 |
||
1208 |
!Stream methodsFor:'JS syntactic sugar'! |
|
1209 |
||
337 | 1210 |
showCR:aString _:arg1 |
1211 |
"for JS easy syntax - allows: Transcript.showCR('format %1', arg1)" |
|
1212 |
||
1213 |
self showCR:(aString bindWith:arg1). |
|
267
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1214 |
! ! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1215 |
|
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1216 |
!Stream methodsFor:'JS syntactic sugar'! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1217 |
|
337 | 1218 |
showCR:aString _:arg1 _:arg2 |
1219 |
"for JS easy syntax - allows: Transcript.showCR('format %1 %2', arg1, arg2)" |
|
1220 |
||
1221 |
self showCR:(aString bindWith:arg1 with:arg2). |
|
267
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1222 |
! ! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1223 |
|
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1224 |
!Stream methodsFor:'JS syntactic sugar'! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1225 |
|
337 | 1226 |
showCR:aString _:arg1 _:arg2 _:arg3 |
1227 |
"for JS easy syntax - allows: Transcript.showCR('format %1 %2', arg1,...)" |
|
267
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1228 |
|
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1229 |
self showCR:(aString bindWith:arg1 with:arg2 with:arg3). |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1230 |
! ! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1231 |
|
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1232 |
!Stream methodsFor:'JS syntactic sugar'! |
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1233 |
|
337 | 1234 |
showCR:aString _:arg1 _:arg2 _:arg3 _:arg4 |
1235 |
"for JS easy syntax - allows: Transcript.showCR('format %1 %2', arg1,...)" |
|
267
5463b84d9bf0
syntactic sugar for stream-showCR and collection-with
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1236 |
|
337 | 1237 |
self showCR:(aString bindWith:arg1 with:arg2 with:arg3 with:arg4). |
336 | 1238 |
! ! |
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1239 |
|
336 | 1240 |
!Stream methodsFor:'JS syntactic sugar'! |
1241 |
||
337 | 1242 |
showCR:aString _:arg1 _:arg2 _:arg3 _:arg4 _:arg5 |
1243 |
"for JS easy syntax - allows: Transcript.showCR('format %1 %2', arg1,...)" |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1244 |
|
337 | 1245 |
self showCR:(aString bindWith:arg1 with:arg2 with:arg3 with:arg4 with:arg5). |
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1246 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1247 |
|
479 | 1248 |
!Stream methodsFor:'JS syntactic sugar'! |
1249 |
||
1250 |
showCR:aString _:arg1 _:arg2 _:arg3 _:arg4 _:arg5 _:arg6 |
|
1251 |
"for JS easy syntax - allows: Transcript.showCR('format %1 %2', arg1,...)" |
|
1252 |
||
1253 |
self showCR:(aString bindWith:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6). |
|
1254 |
||
1255 |
"Created: / 19-08-2010 / 15:38:59 / cg" |
|
1256 |
! ! |
|
1257 |
||
336 | 1258 |
!String class methodsFor:'Javascript support'! |
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1259 |
|
337 | 1260 |
fromCharCode:code |
1261 |
"return a string consisitng of a single character, given its code" |
|
1262 |
||
1263 |
|char| |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1264 |
|
337 | 1265 |
char := Character value:code. |
1266 |
^ char stringSpecies with:char |
|
1267 |
||
1268 |
" |
|
1269 |
JavaScriptParser |
|
1270 |
evaluate:'String.fromCharCode(97)' |
|
310
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1271 |
" |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1272 |
! ! |
cdfe8ae2c5e3
Math, Date, String and Array compatibility
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
1273 |
|
336 | 1274 |
!UndefinedObject methodsFor:'Javascript support'! |
1275 |
||
337 | 1276 |
typeof |
1277 |
"return a string describing what I am" |
|
1278 |
||
1279 |
^ 'undefined' |
|
1280 |
||
1281 |
" |
|
1282 |
JavaScriptParser |
|
1283 |
evaluate:'''hello''.typeof()' |
|
1284 |
||
1285 |
JavaScriptParser |
|
1286 |
evaluate:'null.typeof();' |
|
1287 |
" |
|
336 | 1288 |
! ! |
419 | 1289 |
|
1290 |
!stx_libjavascript class methodsFor:'documentation'! |
|
1291 |
||
1292 |
extensionsVersion_CVS |
|
1293 |
^ '$Header$' |
|
648
f6fc4fd5e4ed
Added JavaScriptParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
535
diff
changeset
|
1294 |
! ! |
f6fc4fd5e4ed
Added JavaScriptParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
535
diff
changeset
|
1295 |