Compare commits
569 Commits
jsd
...
SpiderMonk
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbfd7f01fe | ||
|
|
73f2660ed2 | ||
|
|
fee90a8957 | ||
|
|
6ec5dfc64d | ||
|
|
a06b5c6b43 | ||
|
|
355b53b5fe | ||
|
|
5c64026eac | ||
|
|
7325e1c20f | ||
|
|
0bbdc94cc4 | ||
|
|
ec9253f786 | ||
|
|
0500df149a | ||
|
|
de3fa77ffc | ||
|
|
518d51a9ec | ||
|
|
fab904a686 | ||
|
|
9ad512eeab | ||
|
|
21fc1f7e73 | ||
|
|
58ab95e611 | ||
|
|
c3f008663a | ||
|
|
9fa3c9698f | ||
|
|
9769518cba | ||
|
|
e2231f6a3a | ||
|
|
f598b3e021 | ||
|
|
e93ab2efac | ||
|
|
79938c01fa | ||
|
|
1859233a0b | ||
|
|
28c740b405 | ||
|
|
2156d2be56 | ||
|
|
a3fdd6235d | ||
|
|
44e6c3dc85 | ||
|
|
e8616bb5ed | ||
|
|
4facd47a6e | ||
|
|
f53b9bf184 | ||
|
|
84c04e6a6d | ||
|
|
fe10d5d381 | ||
|
|
789e71d9af | ||
|
|
9321d6682b | ||
|
|
9fe2aa2ca2 | ||
|
|
04ddf77eef | ||
|
|
09729fd690 | ||
|
|
c79334436c | ||
|
|
046ce3b5dc | ||
|
|
a661ab5259 | ||
|
|
826ba71ddb | ||
|
|
9df8eca261 | ||
|
|
8372413ff3 | ||
|
|
d42976d59d | ||
|
|
d24eb0c782 | ||
|
|
0335741901 | ||
|
|
48e66b0e7f | ||
|
|
08defea6d7 | ||
|
|
975e0e362a | ||
|
|
33a2edccfc | ||
|
|
26aaa4202d | ||
|
|
6e4d5d85f1 | ||
|
|
0abe8629bb | ||
|
|
16cc9dc3a9 | ||
|
|
0205e1b7b9 | ||
|
|
c0800e4292 | ||
|
|
44f6440277 | ||
|
|
ac0b428d56 | ||
|
|
e0e6bba682 | ||
|
|
bebb6591d0 | ||
|
|
3c1a81432a | ||
|
|
164e644851 | ||
|
|
e28f099ddb | ||
|
|
ee5a76d98b | ||
|
|
9a49b757fb | ||
|
|
6b926e4950 | ||
|
|
5019a3c5b9 | ||
|
|
9ac73e3124 | ||
|
|
20bf98292d | ||
|
|
a1adcfd4c6 | ||
|
|
cd06317d05 | ||
|
|
a9cc2970c0 | ||
|
|
c01031dcb2 | ||
|
|
da31d13ec5 | ||
|
|
e1b0908632 | ||
|
|
dd9145fcf5 | ||
|
|
27454bc38d | ||
|
|
cb18b19c46 | ||
|
|
a38a6bc16c | ||
|
|
ac15592e5f | ||
|
|
9804662800 | ||
|
|
65d80b8466 | ||
|
|
965c11842c | ||
|
|
0a495234b4 | ||
|
|
887a21a0e7 | ||
|
|
efca1506bd | ||
|
|
91158a94cb | ||
|
|
ae2cc93515 | ||
|
|
c270ae3981 | ||
|
|
6f4eb491de | ||
|
|
c707508714 | ||
|
|
f58d6c411b | ||
|
|
dcc66fb3a0 | ||
|
|
c6d8fdb4a1 | ||
|
|
b4a66cfc99 | ||
|
|
f2ddafa75e | ||
|
|
fffea903d8 | ||
|
|
c009b8e4da | ||
|
|
953180821d | ||
|
|
0bb2e88fe0 | ||
|
|
d9d8155903 | ||
|
|
64ed8f2b55 | ||
|
|
0ce684e959 | ||
|
|
986d13c1f7 | ||
|
|
0aa6a5db5e | ||
|
|
e0d15ea7d9 | ||
|
|
4ac9dc131d | ||
|
|
b7535ac0ea | ||
|
|
12657eb0fb | ||
|
|
b7933c7e32 | ||
|
|
41de941212 | ||
|
|
14a9d9707a | ||
|
|
a681ff5887 | ||
|
|
a93b32c92a | ||
|
|
5cac420f14 | ||
|
|
8004e1197e | ||
|
|
f3363cc91e | ||
|
|
9230455c06 | ||
|
|
3960dc9ee5 | ||
|
|
0c0ec2821c | ||
|
|
f1e069a0b5 | ||
|
|
99bb12444a | ||
|
|
767898db6f | ||
|
|
3c8b7655d6 | ||
|
|
29e83f3f00 | ||
|
|
f58c655e5f | ||
|
|
cbd36689b8 | ||
|
|
0c9f1faa8f | ||
|
|
11577bea97 | ||
|
|
8b21f213f2 | ||
|
|
85b9e9e338 | ||
|
|
4d44d44aa6 | ||
|
|
cb143c735d | ||
|
|
67ac0c53b7 | ||
|
|
40537730db | ||
|
|
73f07616ca | ||
|
|
e37c6c58e4 | ||
|
|
cfefdf035b | ||
|
|
26b643e9cf | ||
|
|
0ed5bbeda3 | ||
|
|
d22fe3ce0b | ||
|
|
0bcfd5c015 | ||
|
|
11d157cd32 | ||
|
|
ed256cba9a | ||
|
|
afea1b0d6d | ||
|
|
465e3db54a | ||
|
|
3ebdcb2f29 | ||
|
|
a198deb328 | ||
|
|
ad167c6106 | ||
|
|
6cc77db7b6 | ||
|
|
c8d1223362 | ||
|
|
f0c9781f09 | ||
|
|
3f3ecbc08a | ||
|
|
6b9bdfec42 | ||
|
|
b5361f54b7 | ||
|
|
31431e4dcd | ||
|
|
3c0b753eb3 | ||
|
|
6c4639603b | ||
|
|
6135a00aba | ||
|
|
7e021bc7b6 | ||
|
|
e72e613ee4 | ||
|
|
0f8ee32b40 | ||
|
|
d469ea9fb0 | ||
|
|
6563f56749 | ||
|
|
7cfa27ae3e | ||
|
|
df2143dd3e | ||
|
|
8f5eecd125 | ||
|
|
f5bd095197 | ||
|
|
bb573693da | ||
|
|
6b0ec81b7d | ||
|
|
a298bbdd7a | ||
|
|
4704eaa6b0 | ||
|
|
27b2b41087 | ||
|
|
5482ed1dd6 | ||
|
|
18990eae9f | ||
|
|
98fed0e388 | ||
|
|
05b3c1feba | ||
|
|
763a52754a | ||
|
|
869b786447 | ||
|
|
877ec80ac9 | ||
|
|
2d4fb99438 | ||
|
|
8937da7e07 | ||
|
|
c1ae1240f0 | ||
|
|
39978272c7 | ||
|
|
e35e5fc1a2 | ||
|
|
72970118bb | ||
|
|
0b8141bb35 | ||
|
|
cf6032ba80 | ||
|
|
f4d17774f7 | ||
|
|
fbdad4090a | ||
|
|
2a051d9305 | ||
|
|
49a03a8d3a | ||
|
|
e8c1dbab30 | ||
|
|
134056767c | ||
|
|
5d4f73f8d9 | ||
|
|
2c0f27d985 | ||
|
|
440708a434 | ||
|
|
adb1a82ea5 | ||
|
|
a7d94f9340 | ||
|
|
a99d73f83f | ||
|
|
8b62670504 | ||
|
|
ca76e82e7a | ||
|
|
e53f7bebb4 | ||
|
|
e3f7dcc298 | ||
|
|
b2663eab6a | ||
|
|
3afc15660d | ||
|
|
e4c99be06d | ||
|
|
34d98661bc | ||
|
|
75d9ce90d0 | ||
|
|
c28d22e190 | ||
|
|
d763678802 | ||
|
|
d2ec51db02 | ||
|
|
8118d76c54 | ||
|
|
1e545e45f4 | ||
|
|
773987c3dc | ||
|
|
0405c4e93f | ||
|
|
88ac0c1df0 | ||
|
|
b3e84af06b | ||
|
|
7aed5cdcb5 | ||
|
|
90daf10163 | ||
|
|
f5156071db | ||
|
|
3f66410d0e | ||
|
|
68da4b0d15 | ||
|
|
b247b70b8f | ||
|
|
61a8633ee5 | ||
|
|
195415f91a | ||
|
|
2245830eca | ||
|
|
226e7c6182 | ||
|
|
759f28cd80 | ||
|
|
d34d20f735 | ||
|
|
8d3b460728 | ||
|
|
e888619c62 | ||
|
|
ccaa088be9 | ||
|
|
02417b3d15 | ||
|
|
e0cf93383f | ||
|
|
93b52b4c6b | ||
|
|
524971b786 | ||
|
|
0feefb7733 | ||
|
|
df197a44ac | ||
|
|
2cc51c1051 | ||
|
|
b8cb580424 | ||
|
|
712ca7d5ca | ||
|
|
3dc5e3dd91 | ||
|
|
f140c0c81b | ||
|
|
52d6b91235 | ||
|
|
55dc58958a | ||
|
|
682df8db3e | ||
|
|
8ed39db9a8 | ||
|
|
33d0464867 | ||
|
|
490b91850b | ||
|
|
25da940352 | ||
|
|
f0ca36ba7d | ||
|
|
480dbe043f | ||
|
|
19b9471938 | ||
|
|
68fe0d88b6 | ||
|
|
a6fcbc6e38 | ||
|
|
a0f85cea3a | ||
|
|
3f5735fcf7 | ||
|
|
0ab0796234 | ||
|
|
0e145d79c2 | ||
|
|
3e89c252c4 | ||
|
|
6e0204a004 | ||
|
|
4b9ed1baa8 | ||
|
|
b9f4c69e12 | ||
|
|
5f6a0b9c3a | ||
|
|
f68735a6bb | ||
|
|
8616bd54f5 | ||
|
|
09e0785f68 | ||
|
|
dd8953010a | ||
|
|
a67d8ed2fe | ||
|
|
935f0e5ac8 | ||
|
|
97aa1f7699 | ||
|
|
f399e21216 | ||
|
|
823cb6e29e | ||
|
|
84e135cd01 | ||
|
|
ac3516411a | ||
|
|
db237360fa | ||
|
|
92e443d317 | ||
|
|
87c9e8ae4d | ||
|
|
3fa38c1d6a | ||
|
|
ce487f127c | ||
|
|
cc1651828e | ||
|
|
22f7fd9b4a | ||
|
|
ad72e12927 | ||
|
|
b6ada3318c | ||
|
|
82ac5c4e2f | ||
|
|
5430e4b688 | ||
|
|
33219cbcb1 | ||
|
|
e10c7eb54b | ||
|
|
70bd48b576 | ||
|
|
6bc17963c7 | ||
|
|
168c0f6f50 | ||
|
|
eef72a91bc | ||
|
|
76e06e7e4d | ||
|
|
6d03a825d3 | ||
|
|
9a0cc72a2d | ||
|
|
6139484b7e | ||
|
|
b576db0575 | ||
|
|
1858d69e49 | ||
|
|
76326b2efb | ||
|
|
06a7abeacf | ||
|
|
2ae04afc70 | ||
|
|
754415d2a7 | ||
|
|
d719a6f851 | ||
|
|
cdcef88024 | ||
|
|
34fd322859 | ||
|
|
d848312079 | ||
|
|
cdc32c49b5 | ||
|
|
93a992bb20 | ||
|
|
256ad44f6c | ||
|
|
c76f45fb75 | ||
|
|
a7a3555cc8 | ||
|
|
3140821cd1 | ||
|
|
befd55d8ba | ||
|
|
3962bfda99 | ||
|
|
faca6b626e | ||
|
|
8c1af11605 | ||
|
|
6c8f42225c | ||
|
|
847bebb065 | ||
|
|
2c9b897958 | ||
|
|
b01cc3080f | ||
|
|
9cd7750dd1 | ||
|
|
ed9c4d7ee1 | ||
|
|
ceb34941c8 | ||
|
|
f20e53875b | ||
|
|
7c8275aae3 | ||
|
|
30e0d801a7 | ||
|
|
a899984e09 | ||
|
|
54e5a64304 | ||
|
|
4016979d0d | ||
|
|
663693cafe | ||
|
|
aed4dd4310 | ||
|
|
6c7c73d822 | ||
|
|
28c93d2218 | ||
|
|
ca95b9b63a | ||
|
|
67d738630a | ||
|
|
f018a06aa7 | ||
|
|
eb89b3d136 | ||
|
|
6c156d7134 | ||
|
|
7f123a804d | ||
|
|
ec0edbcba0 | ||
|
|
2687debc8e | ||
|
|
5fb184d473 | ||
|
|
4885772ba8 | ||
|
|
3d0da2df12 | ||
|
|
030655be79 | ||
|
|
c21e3de07e | ||
|
|
f654a47a49 | ||
|
|
c11ef38890 | ||
|
|
d8f121d794 | ||
|
|
47f4088f27 | ||
|
|
9d8444be44 | ||
|
|
0bd94e4384 | ||
|
|
e0a486e300 | ||
|
|
4bf9c6a227 | ||
|
|
3277bdac18 | ||
|
|
87c868ffbe | ||
|
|
5f6bbab561 | ||
|
|
55cebfe0cb | ||
|
|
26c815ff77 | ||
|
|
facfc365cb | ||
|
|
63ace590d6 | ||
|
|
31c250eee9 | ||
|
|
60b5308f58 | ||
|
|
d2b9c6a168 | ||
|
|
b6525cde8b | ||
|
|
c4741a81fe | ||
|
|
0649a670ac | ||
|
|
d418df2eb7 | ||
|
|
e86bd6fd57 | ||
|
|
6d79b5ec64 | ||
|
|
46800959c2 | ||
|
|
e29596b37b | ||
|
|
1419ca574a | ||
|
|
e5892b8370 | ||
|
|
60fe37f18d | ||
|
|
98c0f47746 | ||
|
|
55a926e2c4 | ||
|
|
f7387ecdae | ||
|
|
ecf83e4f36 | ||
|
|
7d02cdd1c2 | ||
|
|
0bd5df16b7 | ||
|
|
145eb6f922 | ||
|
|
f98b15d6d3 | ||
|
|
da9f65325b | ||
|
|
25bbd958a9 | ||
|
|
3e8f4b2074 | ||
|
|
6547ff01ff | ||
|
|
dd55af2615 | ||
|
|
619f867c2d | ||
|
|
2ffc6eb8cf | ||
|
|
444ed356ed | ||
|
|
ad709b1cfa | ||
|
|
90dc42fec0 | ||
|
|
7b3a25dde6 | ||
|
|
3b086e1130 | ||
|
|
43ea6c73ea | ||
|
|
8b37303301 | ||
|
|
a9d4091b08 | ||
|
|
0e74fd5849 | ||
|
|
9bbc9990a2 | ||
|
|
5cea729be2 | ||
|
|
c7838f766a | ||
|
|
d6adc823ec | ||
|
|
65fea2e956 | ||
|
|
bc6d33a86b | ||
|
|
f9446c3323 | ||
|
|
f2dde02af9 | ||
|
|
41ebf8c0e0 | ||
|
|
ab971b977f | ||
|
|
9c77f182aa | ||
|
|
b25aef6c55 | ||
|
|
a82b563a25 | ||
|
|
02314c78f6 | ||
|
|
425d07341a | ||
|
|
268dfb88cb | ||
|
|
bc2ec58a7b | ||
|
|
cf373daa53 | ||
|
|
7fe8465ded | ||
|
|
37ec2963c9 | ||
|
|
5ea0bc5e25 | ||
|
|
a492c3a964 | ||
|
|
a256793772 | ||
|
|
fa7759865b | ||
|
|
7a57c4b47a | ||
|
|
a2ebae060e | ||
|
|
a8dc44aaa9 | ||
|
|
3c18b0c3ba | ||
|
|
c122de69b8 | ||
|
|
4a3d57e324 | ||
|
|
a3f846bbf0 | ||
|
|
189fd42355 | ||
|
|
63410ef469 | ||
|
|
7f25afca90 | ||
|
|
81d08cb271 | ||
|
|
deefcc6b8d | ||
|
|
e9b1c82736 | ||
|
|
27a80cf6d2 | ||
|
|
1022f9e0ce | ||
|
|
c9bb9195dd | ||
|
|
095999e32b | ||
|
|
d76a5a9080 | ||
|
|
a70e9a2aaa | ||
|
|
e359fd71fc | ||
|
|
04e1b5c3d1 | ||
|
|
fa2407ee2e | ||
|
|
49bb4bd95c | ||
|
|
3c49adc57b | ||
|
|
3f7cdf786b | ||
|
|
78fba657bd | ||
|
|
5b6a656e48 | ||
|
|
fbbe5d2674 | ||
|
|
d9d717001f | ||
|
|
1dde42d623 | ||
|
|
1ed0446da5 | ||
|
|
3fd73fdffd | ||
|
|
cfa1a86909 | ||
|
|
6b78529f1f | ||
|
|
4fd0fc55ca | ||
|
|
b1e460a74a | ||
|
|
a5a20628a0 | ||
|
|
d9eb58cdec | ||
|
|
037c43596e | ||
|
|
79b38ca130 | ||
|
|
2f59039158 | ||
|
|
d32e31eda5 | ||
|
|
ccf4b130af | ||
|
|
c66acfa187 | ||
|
|
89d32f85be | ||
|
|
0f8d890868 | ||
|
|
3c8ae5aafe | ||
|
|
f909920e91 | ||
|
|
ad73f38c85 | ||
|
|
e18fa8a56f | ||
|
|
e81b4d3657 | ||
|
|
19c49a56be | ||
|
|
3e2489f92c | ||
|
|
b9e217c7e8 | ||
|
|
940ee6966f | ||
|
|
13337f0a89 | ||
|
|
aabb8920ae | ||
|
|
bd32e33753 | ||
|
|
c68e984b99 | ||
|
|
35b4a8183d | ||
|
|
f746d5d6c5 | ||
|
|
dccd95eeaa | ||
|
|
0dc9a5a868 | ||
|
|
f46f66eea8 | ||
|
|
8ade5f78d3 | ||
|
|
58a8a3d984 | ||
|
|
e539af4e6f | ||
|
|
27e172913a | ||
|
|
b54505be31 | ||
|
|
2433dae015 | ||
|
|
c2bcde8466 | ||
|
|
90fb1dfb90 | ||
|
|
132d1f5b26 | ||
|
|
4c69c950da | ||
|
|
d5329cfd00 | ||
|
|
83cb0cf419 | ||
|
|
d3eee3f5c6 | ||
|
|
c78787a61a | ||
|
|
fd99e42a1e | ||
|
|
f536714915 | ||
|
|
16977a5881 | ||
|
|
d58d92ba30 | ||
|
|
70aa311f1a | ||
|
|
d6d4547e60 | ||
|
|
cddb4bee49 | ||
|
|
215e4f521a | ||
|
|
b374ece734 | ||
|
|
db88d15e60 | ||
|
|
17a3a3fede | ||
|
|
802ea94da2 | ||
|
|
87987c22eb | ||
|
|
92e75b047c | ||
|
|
d72d172d7a | ||
|
|
8e7b173eef | ||
|
|
d898e8430d | ||
|
|
55edce6a15 | ||
|
|
f962f59ccc | ||
|
|
75187e5e57 | ||
|
|
3522f2112e | ||
|
|
b2bc5afac7 | ||
|
|
1b857628d4 | ||
|
|
4034d6af4c | ||
|
|
1d5e647e2c | ||
|
|
2aabababd7 | ||
|
|
024311a2ab | ||
|
|
55fcddec90 | ||
|
|
0c95c94909 | ||
|
|
8da98334c6 | ||
|
|
defa10fc43 | ||
|
|
f0cdddb20c | ||
|
|
a17e03c381 | ||
|
|
595794ecfe | ||
|
|
1a0b1b8a29 | ||
|
|
670d4d69fa | ||
|
|
c5a6bb1af7 | ||
|
|
00a574acf2 | ||
|
|
68900225d1 | ||
|
|
97a1eacae2 | ||
|
|
1061a7961a | ||
|
|
95f197f31a | ||
|
|
aeb19b804e | ||
|
|
22b83ef992 | ||
|
|
cf89f9dbea | ||
|
|
b9f52d961c | ||
|
|
b9b66713eb | ||
|
|
3287009b56 | ||
|
|
d0ad9c946c | ||
|
|
b3c707fd61 | ||
|
|
03332fd3ac | ||
|
|
ef97812295 | ||
|
|
ca0614a7b6 | ||
|
|
4c1594b677 | ||
|
|
914637bd3e | ||
|
|
91dbe3c171 | ||
|
|
c3bd0c5f7d | ||
|
|
cff140c431 | ||
|
|
923990dd99 | ||
|
|
45291c870a | ||
|
|
33d0d8a72b | ||
|
|
2066c6b9ce | ||
|
|
46e77ac0e1 | ||
|
|
7507e060b5 | ||
|
|
1cc86f1b54 |
18
mozilla/js/jsd/README
Normal file
18
mozilla/js/jsd/README
Normal file
@@ -0,0 +1,18 @@
|
||||
/* jband - 10/26/98 - */
|
||||
|
||||
js/jsd contains code for debugging support for the C-based JavaScript engine
|
||||
in js/src.
|
||||
|
||||
Currently the makefiles are for Win32 only (using MS nmake.exe from MSDEV 4.2).
|
||||
jsd.mak will build a standalone dll. jsdshell.mak will build the dll and also
|
||||
a version of the js/src/js.c shell which will launch a Java VM and run the
|
||||
JavaSript Debugger (built in js/jsdj). This version assumes that you have a
|
||||
JRE compatible JVM installed. Only Windows is supported for this Java-based
|
||||
debugging.
|
||||
|
||||
Though only Windows makefiles are supplied, the basic code in js/jsd should
|
||||
compile for other platforms -- it is a newer version of code that builds and
|
||||
ships with Communicator 4.x on many platforms.
|
||||
|
||||
js/jsd/jsdb is a console debugger using only native code (see README in that
|
||||
directory)
|
||||
@@ -16,26 +16,20 @@
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nspr_linux_defs_h___
|
||||
#define nspr_linux_defs_h___
|
||||
/*
|
||||
* This supplies non-functional stubs for a couple of JNI functions we need
|
||||
* in order to link LiveConnect
|
||||
*/
|
||||
|
||||
#include <linux/autoconf.h>
|
||||
#undef HAVE_LONG_LONG
|
||||
#undef HAVE_ALIGNED_DOUBLES
|
||||
#undef HAVE_ALIGNED_LONGLONGS
|
||||
#include "jni.h"
|
||||
|
||||
/*
|
||||
* ELF linux supports dl* functions.
|
||||
* Allow ELF functions for static or modular ELF support.
|
||||
*/
|
||||
#if defined(CONFIG_BINFMT_ELF) || defined(CONFIG_BINFMT_ELF_MODULE)
|
||||
#define HAVE_DLL
|
||||
#define USE_DLFCN
|
||||
#else
|
||||
#undef HAVE_DLL
|
||||
#undef USE_DLFCN
|
||||
#endif
|
||||
jint JNICALL JNI_GetDefaultJavaVMInitArgs(void * ignored)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define NEED_TIME_R
|
||||
jint JNICALL JNI_CreateJavaVM(JavaVM ** vm, JNIEnv ** env, void * ignored)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* nspr_linux_defs_h___ */
|
||||
33
mozilla/js/jsd/java/jniheadr.mak
Normal file
33
mozilla/js/jsd/java/jniheadr.mak
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
JSDJNI = .
|
||||
#CLASS_DIR_BASE = $(JSDJNI)\..\..\..\jsdj\dist\classes
|
||||
# until jsdj moves to mozilla...
|
||||
CLASS_DIR_BASE = $(JSDJNI)\..\..\..\..\..\ns\js\jsdj\dist\classes
|
||||
GEN = $(JSDJNI)\_jni
|
||||
HEADER_FILE = $(GEN)\jsdjnih.h
|
||||
|
||||
PACKAGE_SLASH = netscape\jsdebug
|
||||
PACKAGE_DOT = netscape.jsdebug
|
||||
|
||||
STD_CLASSPATH = -classpath $(CLASS_DIR_BASE);$(CLASSPATH)
|
||||
|
||||
CLASSES_WITH_NATIVES = \
|
||||
$(PACKAGE_DOT).DebugController \
|
||||
$(PACKAGE_DOT).JSPC \
|
||||
$(PACKAGE_DOT).JSSourceTextProvider \
|
||||
$(PACKAGE_DOT).JSStackFrameInfo \
|
||||
$(PACKAGE_DOT).JSThreadState \
|
||||
$(PACKAGE_DOT).Script \
|
||||
$(PACKAGE_DOT).SourceTextProvider \
|
||||
$(PACKAGE_DOT).ThreadStateBase \
|
||||
$(PACKAGE_DOT).Value
|
||||
|
||||
all: $(GEN)
|
||||
@echo generating JNI headers
|
||||
@javah -jni -o "$(HEADER_FILE)" $(STD_CLASSPATH) $(CLASSES_WITH_NATIVES)
|
||||
|
||||
$(GEN) :
|
||||
@mkdir $(GEN)
|
||||
|
||||
clean:
|
||||
@if exist $(HEADER_FILE) @del $(HEADER_FILE) > NUL
|
||||
134
mozilla/js/jsd/java/jre/jre.c
Normal file
134
mozilla/js/jsd/java/jre/jre.c
Normal file
@@ -0,0 +1,134 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Sun Microsystems, Inc.
|
||||
* Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
|
||||
* modify and redistribute this software in source and binary code form,
|
||||
* provided that i) this copyright notice and license appear on all copies of
|
||||
* the software; and ii) Licensee does not utilize the software in a manner
|
||||
* which is disparaging to Sun.
|
||||
*
|
||||
* This software is provided "AS IS," without a warranty of any kind. ALL
|
||||
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
|
||||
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
|
||||
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
|
||||
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
|
||||
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
|
||||
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
|
||||
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* This software is not designed or intended for use in on-line control of
|
||||
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
|
||||
* the design, construction, operation or maintenance of any nuclear
|
||||
* facility. Licensee represents and warrants that it will not use or
|
||||
* redistribute the Software for such purposes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portable JRE support functions - pared this down to minimal set I need
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <jni.h>
|
||||
#include "jre.h"
|
||||
|
||||
/*
|
||||
* Exits the runtime with the specified error message.
|
||||
*/
|
||||
void
|
||||
JRE_FatalError(JNIEnv *env, const char *msg)
|
||||
{
|
||||
if ((*env)->ExceptionOccurred(env)) {
|
||||
(*env)->ExceptionDescribe(env);
|
||||
}
|
||||
(*env)->FatalError(env, msg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Parses a runtime version string. Returns 0 if the successful, otherwise
|
||||
* returns -1 if the format of the version string was invalid.
|
||||
*/
|
||||
jint
|
||||
JRE_ParseVersion(const char *ver, char **majorp, char **minorp, char **microp)
|
||||
{
|
||||
int n1 = 0, n2 = 0, n3 = 0;
|
||||
|
||||
sscanf(ver, "%*[0-9]%n.%*[0-9]%n.%*[0-9a-zA-Z]%n", &n1, &n2, &n3);
|
||||
if (n1 == 0 || n2 == 0) {
|
||||
return -1;
|
||||
}
|
||||
if (n3 != 0) {
|
||||
if (n3 != (int)strlen(ver)) {
|
||||
return -1;
|
||||
}
|
||||
} else if (n2 != (int)strlen(ver)) {
|
||||
return -1;
|
||||
}
|
||||
*majorp = JRE_Malloc(n1 + 1);
|
||||
strncpy(*majorp, ver, n1);
|
||||
(*majorp)[n1] = 0;
|
||||
*minorp = JRE_Malloc(n2 - n1);
|
||||
strncpy(*minorp, ver + n1 + 1, n2 - n1 - 1);
|
||||
(*minorp)[n2 - n1 - 1] = 0;
|
||||
if (n3 != 0) {
|
||||
*microp = JRE_Malloc(n3 - n2);
|
||||
strncpy(*microp, ver + n2 + 1, n3 - n2 - 1);
|
||||
(*microp)[n3 - n2 - 1] = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a version number string from the specified major, minor, and
|
||||
* micro version numbers.
|
||||
*/
|
||||
char *
|
||||
JRE_MakeVersion(const char *major, const char *minor, const char *micro)
|
||||
{
|
||||
char *ver = 0;
|
||||
|
||||
if (major != 0 && minor != 0) {
|
||||
int len = strlen(major) + strlen(minor);
|
||||
if (micro != 0) {
|
||||
ver = JRE_Malloc(len + strlen(micro) + 3);
|
||||
sprintf(ver, "%s.%s.%s", major, minor, micro);
|
||||
} else {
|
||||
ver = JRE_Malloc(len + 2);
|
||||
sprintf(ver, "%s.%s", major, minor);
|
||||
}
|
||||
}
|
||||
return ver;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate memory or die.
|
||||
*/
|
||||
void *
|
||||
JRE_Malloc(size_t size)
|
||||
{
|
||||
void *p = malloc(size);
|
||||
if (p == 0) {
|
||||
perror("malloc");
|
||||
exit(1);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
85
mozilla/js/jsd/java/jre/jre.h
Normal file
85
mozilla/js/jsd/java/jre/jre.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Sun Microsystems, Inc.
|
||||
* Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
|
||||
* modify and redistribute this software in source and binary code form,
|
||||
* provided that i) this copyright notice and license appear on all copies of
|
||||
* the software; and ii) Licensee does not utilize the software in a manner
|
||||
* which is disparaging to Sun.
|
||||
*
|
||||
* This software is provided "AS IS," without a warranty of any kind. ALL
|
||||
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
|
||||
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
|
||||
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
|
||||
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
|
||||
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
|
||||
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
|
||||
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* This software is not designed or intended for use in on-line control of
|
||||
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
|
||||
* the design, construction, operation or maintenance of any nuclear
|
||||
* facility. Licensee represents and warrants that it will not use or
|
||||
* redistribute the Software for such purposes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portable JRE support functions - pared this down to minimal set I need
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <jni.h>
|
||||
|
||||
#include "jre_md.h"
|
||||
|
||||
/*
|
||||
* Java runtime settings.
|
||||
*/
|
||||
typedef struct JRESettings {
|
||||
char *javaHome; /* Java home directory */
|
||||
char *runtimeLib; /* Runtime shared library or DLL */
|
||||
char *classPath; /* Default class path */
|
||||
char *compiler; /* Just-in-time (JIT) compiler */
|
||||
char *majorVersion; /* Major version of runtime */
|
||||
char *minorVersion; /* Minor version of runtime */
|
||||
char *microVersion; /* Micro version of runtime */
|
||||
} JRESettings;
|
||||
|
||||
/*
|
||||
* JRE functions.
|
||||
*/
|
||||
void *JRE_LoadLibrary(const char *path);
|
||||
void JRE_UnloadLibrary(void *handle);
|
||||
jint JRE_GetDefaultJavaVMInitArgs(void *handle, void *vmargsp);
|
||||
jint JRE_CreateJavaVM(void *handle, JavaVM **vmp, JNIEnv **envp,
|
||||
void *vmargsp);
|
||||
jint JRE_GetCurrentSettings(JRESettings *set);
|
||||
jint JRE_GetSettings(JRESettings *set, const char *ver);
|
||||
jint JRE_GetDefaultSettings(JRESettings *set);
|
||||
jint JRE_ParseVersion(const char *version,
|
||||
char **majorp, char **minorp, char **microp);
|
||||
char *JRE_MakeVersion(const char *major, const char *minor, const char *micro);
|
||||
void *JRE_Malloc(size_t size);
|
||||
void JRE_FatalError(JNIEnv *env, const char *msg);
|
||||
char *JRE_GetDefaultRuntimeLib(const char *dir);
|
||||
char *JRE_GetDefaultClassPath(const char *dir);
|
||||
290
mozilla/js/jsd/java/jre/win32/jre_md.c
Normal file
290
mozilla/js/jsd/java/jre/win32/jre_md.c
Normal file
@@ -0,0 +1,290 @@
|
||||
/*
|
||||
* @(#)jre_md.c 1.6 97/05/15 David Connelly
|
||||
*
|
||||
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
|
||||
* modify and redistribute this software in source and binary code form,
|
||||
* provided that i) this copyright notice and license appear on all copies of
|
||||
* the software; and ii) Licensee does not utilize the software in a manner
|
||||
* which is disparaging to Sun.
|
||||
*
|
||||
* This software is provided "AS IS," without a warranty of any kind. ALL
|
||||
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
|
||||
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
|
||||
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
|
||||
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
|
||||
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
|
||||
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
|
||||
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* This software is not designed or intended for use in on-line control of
|
||||
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
|
||||
* the design, construction, operation or maintenance of any nuclear
|
||||
* facility. Licensee represents and warrants that it will not use or
|
||||
* redistribute the Software for such purposes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Win32 specific JRE support functions
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <jni.h>
|
||||
#include "jre.h"
|
||||
|
||||
#define JRE_KEY "Software\\JavaSoft\\Java Runtime Environment"
|
||||
#define JDK_KEY "Software\\JavaSoft\\Java Development Kit"
|
||||
|
||||
#define RUNTIME_LIB "javai.dll"
|
||||
|
||||
/* From jre_main.c */
|
||||
extern jboolean debug;
|
||||
|
||||
/* Forward Declarations */
|
||||
jint LoadSettings(JRESettings *set, HKEY key);
|
||||
jint GetSettings(JRESettings *set, const char *version, const char *keyname);
|
||||
char *GetStringValue(HKEY key, const char *name);
|
||||
|
||||
/*
|
||||
* Retrieve settings from registry for current runtime version. Returns
|
||||
* 0 if successful otherwise returns -1 if no installed runtime was found
|
||||
* or the registry data was invalid.
|
||||
*/
|
||||
jint
|
||||
JRE_GetCurrentSettings(JRESettings *set)
|
||||
{
|
||||
jint r = -1;
|
||||
HKEY key;
|
||||
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, JRE_KEY, 0, KEY_READ, &key) == 0) {
|
||||
char *ver = GetStringValue(key, "CurrentVersion");
|
||||
if (ver != 0) {
|
||||
r = JRE_GetSettings(set, ver);
|
||||
}
|
||||
free(ver);
|
||||
RegCloseKey(key);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieves settings from registry for specified runtime version.
|
||||
* Searches for either installed JRE and JDK runtimes. Returns 0 if
|
||||
* successful otherwise returns -1 if requested version of runtime
|
||||
* could not be found.
|
||||
*/
|
||||
jint
|
||||
JRE_GetSettings(JRESettings *set, const char *version)
|
||||
{
|
||||
if (GetSettings(set, version, JRE_KEY) != 0) {
|
||||
return GetSettings(set, version, JDK_KEY);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
jint
|
||||
GetSettings(JRESettings *set, const char *version, const char *keyname)
|
||||
{
|
||||
HKEY key;
|
||||
int r = -1;
|
||||
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyname, 0, KEY_READ, &key) == 0) {
|
||||
char *major, *minor, *micro = 0;
|
||||
if (JRE_ParseVersion(version, &major, &minor, µ) == 0) {
|
||||
HKEY subkey;
|
||||
char *ver = JRE_MakeVersion(major, minor, 0);
|
||||
set->majorVersion = major;
|
||||
set->minorVersion = minor;
|
||||
if (RegOpenKeyEx(key, ver, 0, KEY_READ, &subkey) == 0) {
|
||||
if ((r = LoadSettings(set, subkey)) == 0) {
|
||||
if (micro != 0) {
|
||||
if (set->microVersion == 0 ||
|
||||
strcmp(micro, set->microVersion) != 0) {
|
||||
r = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
RegCloseKey(subkey);
|
||||
}
|
||||
free(ver);
|
||||
}
|
||||
RegCloseKey(key);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* Load runtime settings from specified registry key. Returns 0 if
|
||||
* successful otherwise -1 if the registry data was invalid.
|
||||
*/
|
||||
static jint
|
||||
LoadSettings(JRESettings *set, HKEY key)
|
||||
{
|
||||
/* Full path name of JRE home directory (required) */
|
||||
set->javaHome = GetStringValue(key, "JavaHome");
|
||||
if (set->javaHome == 0) {
|
||||
return -1;
|
||||
}
|
||||
/* Full path name of JRE runtime DLL */
|
||||
set->runtimeLib = GetStringValue(key, "RuntimeLib");
|
||||
if (set->runtimeLib == 0) {
|
||||
set->runtimeLib = JRE_GetDefaultRuntimeLib(set->javaHome);
|
||||
}
|
||||
/* Class path setting to override default */
|
||||
set->classPath = GetStringValue(key, "ClassPath");
|
||||
if (set->classPath == 0) {
|
||||
set->classPath = JRE_GetDefaultClassPath(set->javaHome);
|
||||
}
|
||||
/* Optional JIT compiler library name */
|
||||
set->compiler = GetStringValue(key, "Compiler");
|
||||
/* Release micro-version */
|
||||
set->microVersion = GetStringValue(key, "MicroVersion");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns string data for the specified registry value name, or
|
||||
* NULL if not found.
|
||||
*/
|
||||
static char *
|
||||
GetStringValue(HKEY key, const char *name)
|
||||
{
|
||||
DWORD type, size;
|
||||
char *value = 0;
|
||||
|
||||
if (RegQueryValueEx(key, name, 0, &type, 0, &size) == 0 &&
|
||||
type == REG_SZ ) {
|
||||
value = JRE_Malloc(size);
|
||||
if (RegQueryValueEx(key, name, 0, 0, value, &size) != 0) {
|
||||
free(value);
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns default runtime settings based on location of this program.
|
||||
* Makes best attempt at determining location of runtime. Returns 0
|
||||
* if successful or -1 if a runtime could not be found.
|
||||
*/
|
||||
jint
|
||||
JRE_GetDefaultSettings(JRESettings *set)
|
||||
{
|
||||
char buf[MAX_PATH], *bp;
|
||||
int n;
|
||||
|
||||
// Try to obtain default value for Java home directory based on
|
||||
// location of this executable.
|
||||
|
||||
if ((n = GetModuleFileName(0, buf, MAX_PATH)) == 0) {
|
||||
return -1;
|
||||
}
|
||||
bp = buf + n;
|
||||
while (*--bp != '\\') ;
|
||||
bp -= 4;
|
||||
if (bp < buf || strnicmp(bp, "\\bin", 4) != 0) {
|
||||
return -1;
|
||||
}
|
||||
*bp = '\0';
|
||||
set->javaHome = strdup(buf);
|
||||
|
||||
// Get default runtime library
|
||||
set->runtimeLib = JRE_GetDefaultRuntimeLib(set->javaHome);
|
||||
|
||||
// Get default class path
|
||||
set->classPath = JRE_GetDefaultClassPath(set->javaHome);
|
||||
|
||||
// Reset other fields since these are unknown
|
||||
set->compiler = 0;
|
||||
set->majorVersion = 0;
|
||||
set->minorVersion = 0;
|
||||
set->microVersion = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return default runtime library for specified Java home directory.
|
||||
*/
|
||||
char *
|
||||
JRE_GetDefaultRuntimeLib(const char *dir)
|
||||
{
|
||||
char *cp = JRE_Malloc(strlen(dir) + sizeof(RUNTIME_LIB) + 8);
|
||||
sprintf(cp, "%s\\bin\\" RUNTIME_LIB, dir);
|
||||
return cp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return default class path for specified Java home directory.
|
||||
*/
|
||||
char *
|
||||
JRE_GetDefaultClassPath(const char *dir)
|
||||
{
|
||||
char *cp = JRE_Malloc(strlen(dir) * 4 + 64);
|
||||
sprintf(cp, "%s\\lib\\rt.jar;%s\\lib\\i18n.jar;%s\\lib\\classes.zip;"
|
||||
"%s\\classes", dir, dir, dir, dir);
|
||||
return cp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Loads the runtime library corresponding to 'libname' and returns
|
||||
* an opaque handle to the library.
|
||||
*/
|
||||
void *
|
||||
JRE_LoadLibrary(const char *path)
|
||||
{
|
||||
return (void *)LoadLibrary(path);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unloads the runtime library associated with handle.
|
||||
*/
|
||||
void
|
||||
JRE_UnloadLibrary(void *handle)
|
||||
{
|
||||
FreeLibrary(handle);
|
||||
}
|
||||
|
||||
/*
|
||||
* Loads default VM args for the specified runtime library handle.
|
||||
*/
|
||||
jint
|
||||
JRE_GetDefaultJavaVMInitArgs(void *handle, void *vmargs)
|
||||
{
|
||||
FARPROC proc = GetProcAddress(handle, "JNI_GetDefaultJavaVMInitArgs");
|
||||
return proc != 0 ? ((*proc)(vmargs), 0) : -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a Java VM for the specified runtime library handle.
|
||||
*/
|
||||
jint
|
||||
JRE_CreateJavaVM(void *handle, JavaVM **vmp, JNIEnv **envp, void *vmargs)
|
||||
{
|
||||
FARPROC proc = GetProcAddress(handle, "JNI_CreateJavaVM");
|
||||
return proc != 0 ? (*proc)(vmp, envp, vmargs) : -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Entry point for JREW (Windows-only) version of the runtime loader.
|
||||
* This entry point is called when the '-subsystem:windows' linker
|
||||
* option is used, and will cause the resulting executable to run
|
||||
* detached from the console.
|
||||
*/
|
||||
|
||||
/**
|
||||
* int WINAPI
|
||||
* WinMain(HINSTANCE inst, HINSTANCE prevInst, LPSTR cmdLine, int cmdShow)
|
||||
* {
|
||||
* __declspec(dllimport) char **__initenv;
|
||||
*
|
||||
* __initenv = _environ;
|
||||
* exit(main(__argc, __argv));
|
||||
* }
|
||||
*/
|
||||
36
mozilla/js/jsd/java/jre/win32/jre_md.h
Normal file
36
mozilla/js/jsd/java/jre/win32/jre_md.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* @(#)jre_md.h 1.1 97/05/19 David Connelly
|
||||
*
|
||||
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
|
||||
* modify and redistribute this software in source and binary code form,
|
||||
* provided that i) this copyright notice and license appear on all copies of
|
||||
* the software; and ii) Licensee does not utilize the software in a manner
|
||||
* which is disparaging to Sun.
|
||||
*
|
||||
* This software is provided "AS IS," without a warranty of any kind. ALL
|
||||
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
|
||||
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
|
||||
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
|
||||
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
|
||||
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
|
||||
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
|
||||
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* This software is not designed or intended for use in on-line control of
|
||||
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
|
||||
* the design, construction, operation or maintenance of any nuclear
|
||||
* facility. Licensee represents and warrants that it will not use or
|
||||
* redistribute the Software for such purposes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Win32 specific JRE support definitions
|
||||
*/
|
||||
|
||||
#define FILE_SEPARATOR '\\'
|
||||
#define PATH_SEPARATOR ';'
|
||||
2694
mozilla/js/jsd/java/jsd_jntv.c
Normal file
2694
mozilla/js/jsd/java/jsd_jntv.c
Normal file
File diff suppressed because it is too large
Load Diff
349
mozilla/js/jsd/java/jsd_jvm.c
Normal file
349
mozilla/js/jsd/java/jsd_jvm.c
Normal file
@@ -0,0 +1,349 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Sun Microsystems, Inc.
|
||||
* Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
|
||||
* modify and redistribute this software in source and binary code form,
|
||||
* provided that i) this copyright notice and license appear on all copies of
|
||||
* the software; and ii) Licensee does not utilize the software in a manner
|
||||
* which is disparaging to Sun.
|
||||
*
|
||||
* This software is provided "AS IS," without a warranty of any kind. ALL
|
||||
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
|
||||
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
|
||||
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
|
||||
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
|
||||
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
|
||||
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
|
||||
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* This software is not designed or intended for use in on-line control of
|
||||
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
|
||||
* the design, construction, operation or maintenance of any nuclear
|
||||
* facility. Licensee represents and warrants that it will not use or
|
||||
* redistribute the Software for such purposes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Code to start a Java VM (*some* code from the JRE)
|
||||
*/
|
||||
|
||||
#include "jsdj.h"
|
||||
|
||||
/***************************************************************************/
|
||||
#ifdef JSD_STANDALONE_JAVA_VM
|
||||
#include "jre.h"
|
||||
|
||||
static char* more_classpath[] =
|
||||
{
|
||||
{"..\\..\\jsdj\\dist\\classes"},
|
||||
{"..\\..\\jsdj\\dist\\classes\\ifc11.jar"},
|
||||
|
||||
/*
|
||||
* {"..\\..\\..\\jsdj\\dist\\classes"},
|
||||
* {"..\\..\\..\\jsdj\\dist\\classes\\ifc12.jar"},
|
||||
*/
|
||||
|
||||
/*
|
||||
* {"..\\..\\samples\\jslogger"},
|
||||
* {"classes"},
|
||||
* {"ifc12.jar"},
|
||||
* {"jsd10.jar"},
|
||||
* {"jsdeb15.jar"}
|
||||
*/
|
||||
};
|
||||
#define MORE_CLASSPATH_COUNT (sizeof(more_classpath)/sizeof(more_classpath[0]))
|
||||
|
||||
/*
|
||||
* static char main_class[] = "callnative";
|
||||
* static char main_class[] = "simpleIFC";
|
||||
* static char* params[] = {"16 Dec 1997"};
|
||||
* #define PARAM_COUNT (sizeof(params)/sizeof(params[0]))
|
||||
*/
|
||||
|
||||
/*
|
||||
* static char main_class[] = "netscape/jslogger/JSLogger";
|
||||
* static char main_class[] = "LaunchJSDebugger";
|
||||
*/
|
||||
static char main_class[] = "com/netscape/jsdebugging/ifcui/launcher/local/LaunchJSDebugger";
|
||||
static char* params[] = {NULL};
|
||||
#define PARAM_COUNT 0
|
||||
|
||||
/* Globals */
|
||||
static char **props; /* User-defined properties */
|
||||
static int numProps, maxProps; /* Current, max number of properties */
|
||||
|
||||
static void *handle;
|
||||
static JavaVM *jvm;
|
||||
static JNIEnv *env;
|
||||
|
||||
/* Check for null value and return */
|
||||
#define NULL_CHECK(e) if ((e) == 0) return 0
|
||||
|
||||
/*
|
||||
* Adds a user-defined system property definition.
|
||||
*/
|
||||
void AddProperty(char *def)
|
||||
{
|
||||
if (numProps >= maxProps) {
|
||||
if (props == 0) {
|
||||
maxProps = 4;
|
||||
props = JRE_Malloc(maxProps * sizeof(char **));
|
||||
} else {
|
||||
char **tmp;
|
||||
maxProps *= 2;
|
||||
tmp = JRE_Malloc(maxProps * sizeof(char **));
|
||||
memcpy(tmp, props, numProps * sizeof(char **));
|
||||
free(props);
|
||||
props = tmp;
|
||||
}
|
||||
}
|
||||
props[numProps++] = def;
|
||||
}
|
||||
|
||||
/*
|
||||
* Deletes a property definition by name.
|
||||
*/
|
||||
void DeleteProperty(const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < numProps; ) {
|
||||
char *def = props[i];
|
||||
char *c = strchr(def, '=');
|
||||
int n;
|
||||
if (c != 0) {
|
||||
n = c - def;
|
||||
} else {
|
||||
n = strlen(def);
|
||||
}
|
||||
if (strncmp(name, def, n) == 0) {
|
||||
if (i < --numProps) {
|
||||
memmove(&props[i], &props[i+1], (numProps-i) * sizeof(char **));
|
||||
}
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates an array of Java string objects from the specified array of C
|
||||
* strings. Returns 0 if the array could not be created.
|
||||
*/
|
||||
jarray NewStringArray(JNIEnv *env, char **cpp, int count)
|
||||
{
|
||||
jclass cls;
|
||||
jarray ary;
|
||||
int i;
|
||||
|
||||
NULL_CHECK(cls = (*env)->FindClass(env, "java/lang/String"));
|
||||
NULL_CHECK(ary = (*env)->NewObjectArray(env, count, cls, 0));
|
||||
for (i = 0; i < count; i++) {
|
||||
jstring str = (*env)->NewStringUTF(env, *cpp++);
|
||||
NULL_CHECK(str);
|
||||
(*env)->SetObjectArrayElement(env, ary, i, str);
|
||||
(*env)->DeleteLocalRef(env, str);
|
||||
}
|
||||
return ary;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
static JNIEnv*
|
||||
_CreateJavaVM(void)
|
||||
{
|
||||
JNIEnv* env = NULL;
|
||||
JDK1_1InitArgs vmargs;
|
||||
JRESettings set;
|
||||
|
||||
printf("Starting Java...\n");
|
||||
|
||||
if(JRE_GetCurrentSettings(&set) != 0)
|
||||
{
|
||||
if(JRE_GetDefaultSettings(&set) != 0)
|
||||
{
|
||||
fprintf(stderr, "Could not locate Java runtime\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Load runtime library */
|
||||
handle = JRE_LoadLibrary(set.runtimeLib);
|
||||
if (handle == 0) {
|
||||
fprintf(stderr, "Could not load runtime library: %s\n",
|
||||
set.runtimeLib);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Add pre-defined system properties */
|
||||
if (set.javaHome != 0) {
|
||||
char *def = JRE_Malloc(strlen(set.javaHome) + 16);
|
||||
sprintf(def, "java.home=%s", set.javaHome);
|
||||
AddProperty(def);
|
||||
}
|
||||
|
||||
if (set.compiler != 0) {
|
||||
char *def = JRE_Malloc(strlen(set.compiler) + 16);
|
||||
sprintf(def, "java.compiler=%s", set.compiler);
|
||||
AddProperty(def);
|
||||
}
|
||||
|
||||
/*
|
||||
* The following is used to specify that we require at least
|
||||
* JNI version 1.1. Currently, this field is not checked but
|
||||
* will be starting with JDK/JRE 1.2. The value returned after
|
||||
* calling JNI_GetDefaultJavaVMInitArgs() is the actual JNI version
|
||||
* supported, and is always higher that the requested version.
|
||||
*/
|
||||
vmargs.version = 0x00010001;
|
||||
|
||||
if (JRE_GetDefaultJavaVMInitArgs(handle, &vmargs) != 0) {
|
||||
fprintf(stderr, "Could not initialize Java VM\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Tack on our classpath */
|
||||
if(MORE_CLASSPATH_COUNT)
|
||||
{
|
||||
int i;
|
||||
int size = strlen(set.classPath) + 1;
|
||||
char sep[2];
|
||||
|
||||
sep[0] = PATH_SEPARATOR;
|
||||
sep[1] = 0;
|
||||
|
||||
for(i = 0; i < MORE_CLASSPATH_COUNT; i++)
|
||||
size += strlen(more_classpath[i]) + 1;
|
||||
|
||||
vmargs.classpath = malloc(size);
|
||||
if(vmargs.classpath == 0)
|
||||
{
|
||||
fprintf(stderr, "malloc error\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strcpy(vmargs.classpath, set.classPath);
|
||||
for(i = 0; i < MORE_CLASSPATH_COUNT; i++)
|
||||
{
|
||||
strcat(vmargs.classpath, sep);
|
||||
strcat(vmargs.classpath, more_classpath[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vmargs.classpath = set.classPath;
|
||||
}
|
||||
|
||||
/*
|
||||
* fprintf(stderr, "classpath: %s\n", vmargs.classpath);
|
||||
*/
|
||||
|
||||
/* Set user-defined system properties for Java VM */
|
||||
if (props != 0) {
|
||||
if (numProps == maxProps) {
|
||||
char **tmp = JRE_Malloc((numProps + 1) * sizeof(char **));
|
||||
memcpy(tmp, props, numProps * sizeof(char **));
|
||||
free(props);
|
||||
props = tmp;
|
||||
}
|
||||
props[numProps] = 0;
|
||||
vmargs.properties = props;
|
||||
}
|
||||
|
||||
|
||||
/* verbose? */
|
||||
/*
|
||||
* vmargs.verbose = JNI_TRUE;
|
||||
*/
|
||||
|
||||
/* Load and initialize Java VM */
|
||||
if (JRE_CreateJavaVM(handle, &jvm, &env, &vmargs) != 0) {
|
||||
fprintf(stderr, "Could not create Java VM\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Free properties */
|
||||
if (props != 0) {
|
||||
free(props);
|
||||
}
|
||||
return env;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
_StartDebuggerFE(JNIEnv* env)
|
||||
{
|
||||
jclass clazz;
|
||||
jmethodID mid;
|
||||
jarray args;
|
||||
|
||||
/* Find class */
|
||||
clazz = (*env)->FindClass(env, main_class);
|
||||
if (clazz == 0) {
|
||||
fprintf(stderr, "Class not found: %s\n", main_class);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
/* Find main method of class */
|
||||
mid = (*env)->GetStaticMethodID(env, clazz, "main",
|
||||
"([Ljava/lang/String;)V");
|
||||
if (mid == 0) {
|
||||
fprintf(stderr, "In class %s: public static void main(String args[])"
|
||||
" is not defined\n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
/* Invoke main method */
|
||||
args = NewStringArray(env, params, PARAM_COUNT);
|
||||
|
||||
if (args == 0) {
|
||||
JRE_FatalError(env, "Couldn't build argument list for main\n");
|
||||
}
|
||||
(*env)->CallStaticVoidMethod(env, clazz, mid, args);
|
||||
if ((*env)->ExceptionOccurred(env)) {
|
||||
(*env)->ExceptionDescribe(env);
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JNIEnv*
|
||||
jsdj_CreateJavaVMAndStartDebugger(JSDJContext* jsdjc)
|
||||
{
|
||||
JNIEnv* env = NULL;
|
||||
|
||||
env = _CreateJavaVM();
|
||||
if( ! env )
|
||||
return NULL;
|
||||
|
||||
jsdj_SetJNIEnvForCurrentThread(jsdjc, env);
|
||||
if( ! jsdj_RegisterNatives(jsdjc) )
|
||||
return NULL;
|
||||
if( ! _StartDebuggerFE(env) )
|
||||
return NULL;
|
||||
|
||||
return env;
|
||||
}
|
||||
|
||||
|
||||
#endif /* JSD_STANDALONE_JAVA_VM */
|
||||
/***************************************************************************/
|
||||
|
||||
147
mozilla/js/jsd/java/jsdj.h
Normal file
147
mozilla/js/jsd/java/jsdj.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Header for JavaScript Debugger JNI support (internal functions)
|
||||
*/
|
||||
|
||||
#ifndef jsdj_h___
|
||||
#define jsdj_h___
|
||||
|
||||
/* Get jstypes.h included first. After that we can use PR macros for doing
|
||||
* this extern "C" stuff!
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#include "jstypes.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jshash.h" /* Added by JSIFY */
|
||||
#include "jsdjava.h"
|
||||
#include "jsobj.h"
|
||||
#include "jsfun.h"
|
||||
#include "jsdbgapi.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
JS_END_EXTERN_C
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
/***************************************************************************/
|
||||
/* defines copied from Java sources.
|
||||
** NOTE: javah used to put these in the h files, but with JNI does not seem
|
||||
** to do this anymore. Be careful with synchronization of these
|
||||
**
|
||||
*/
|
||||
|
||||
/* From: ThreadStateBase.java */
|
||||
|
||||
#define THR_STATUS_UNKNOWN 0x01
|
||||
#define THR_STATUS_ZOMBIE 0x02
|
||||
#define THR_STATUS_RUNNING 0x03
|
||||
#define THR_STATUS_SLEEPING 0x04
|
||||
#define THR_STATUS_MONWAIT 0x05
|
||||
#define THR_STATUS_CONDWAIT 0x06
|
||||
#define THR_STATUS_SUSPENDED 0x07
|
||||
#define THR_STATUS_BREAK 0x08
|
||||
|
||||
#define DEBUG_STATE_DEAD 0x01
|
||||
#define DEBUG_STATE_RUN 0x02
|
||||
#define DEBUG_STATE_RETURN 0x03
|
||||
#define DEBUG_STATE_THROW 0x04
|
||||
|
||||
/***************************************************************************/
|
||||
/* Our structures */
|
||||
|
||||
typedef struct JSDJContext
|
||||
{
|
||||
JSDContext* jsdc;
|
||||
JSHashTable* envTable;
|
||||
jobject controller;
|
||||
JSDJ_UserCallbacks callbacks;
|
||||
void* user;
|
||||
JSBool ownJSDC;
|
||||
} JSDJContext;
|
||||
|
||||
/***************************************************************************/
|
||||
/* Code validation support */
|
||||
|
||||
#ifdef DEBUG
|
||||
extern void JSDJ_ASSERT_VALID_CONTEXT(JSDJContext* jsdjc);
|
||||
#else
|
||||
#define JSDJ_ASSERT_VALID_CONTEXT(x) ((void)0)
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
/* higher level functions */
|
||||
|
||||
extern JSDJContext*
|
||||
jsdj_SimpleInitForSingleContextMode(JSDContext* jsdc,
|
||||
JSDJ_GetJNIEnvProc getEnvProc, void* user);
|
||||
extern JSBool
|
||||
jsdj_SetSingleContextMode();
|
||||
|
||||
extern JSDJContext*
|
||||
jsdj_CreateContext();
|
||||
|
||||
extern void
|
||||
jsdj_DestroyContext(JSDJContext* jsdjc);
|
||||
|
||||
extern void
|
||||
jsdj_SetUserCallbacks(JSDJContext* jsdjc, JSDJ_UserCallbacks* callbacks,
|
||||
void* user);
|
||||
extern void
|
||||
jsdj_SetJNIEnvForCurrentThread(JSDJContext* jsdjc, JNIEnv* env);
|
||||
|
||||
extern JNIEnv*
|
||||
jsdj_GetJNIEnvForCurrentThread(JSDJContext* jsdjc);
|
||||
|
||||
extern void
|
||||
jsdj_SetJSDContext(JSDJContext* jsdjc, JSDContext* jsdc);
|
||||
|
||||
extern JSDContext*
|
||||
jsdj_GetJSDContext(JSDJContext* jsdjc);
|
||||
|
||||
extern JSBool
|
||||
jsdj_RegisterNatives(JSDJContext* jsdjc);
|
||||
|
||||
/***************************************************************************/
|
||||
#ifdef JSD_STANDALONE_JAVA_VM
|
||||
|
||||
extern JNIEnv*
|
||||
jsdj_CreateJavaVMAndStartDebugger(JSDJContext* jsdjc);
|
||||
|
||||
/**
|
||||
* extern JNIEnv*
|
||||
* jsdj_CreateJavaVM(JSDContext* jsdc);
|
||||
*/
|
||||
|
||||
#endif /* JSD_STANDALONE_JAVA_VM */
|
||||
/***************************************************************************/
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsdj_h___ */
|
||||
|
||||
110
mozilla/js/jsd/java/jsdjava.c
Normal file
110
mozilla/js/jsd/java/jsdjava.c
Normal file
@@ -0,0 +1,110 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Public functions to reflect JSD into Java
|
||||
*/
|
||||
|
||||
#include "jsdj.h"
|
||||
|
||||
JSDJ_PUBLIC_API(JSDJContext*)
|
||||
JSDJ_SimpleInitForSingleContextMode(JSDContext* jsdc,
|
||||
JSDJ_GetJNIEnvProc getEnvProc, void* user)
|
||||
{
|
||||
return jsdj_SimpleInitForSingleContextMode(jsdc, getEnvProc, user);
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(JSBool)
|
||||
JSDJ_SetSingleContextMode()
|
||||
{
|
||||
return jsdj_SetSingleContextMode();
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(JSDJContext*)
|
||||
JSDJ_CreateContext()
|
||||
{
|
||||
return jsdj_CreateContext();
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(void)
|
||||
JSDJ_DestroyContext(JSDJContext* jsdjc)
|
||||
{
|
||||
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
|
||||
jsdj_DestroyContext(jsdjc);
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(void)
|
||||
JSDJ_SetUserCallbacks(JSDJContext* jsdjc, JSDJ_UserCallbacks* callbacks,
|
||||
void* user)
|
||||
{
|
||||
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
|
||||
JS_ASSERT(!callbacks ||
|
||||
(callbacks->size > 0 &&
|
||||
callbacks->size <= sizeof(JSDJ_UserCallbacks)));
|
||||
jsdj_SetUserCallbacks(jsdjc, callbacks, user);
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(void)
|
||||
JSDJ_SetJNIEnvForCurrentThread(JSDJContext* jsdjc, JNIEnv* env)
|
||||
{
|
||||
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
|
||||
JS_ASSERT(env);
|
||||
jsdj_SetJNIEnvForCurrentThread(jsdjc, env);
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(JNIEnv*)
|
||||
JSDJ_GetJNIEnvForCurrentThread(JSDJContext* jsdjc)
|
||||
{
|
||||
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
|
||||
return jsdj_GetJNIEnvForCurrentThread(jsdjc);
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(void)
|
||||
JSDJ_SetJSDContext(JSDJContext* jsdjc, JSDContext* jsdc)
|
||||
{
|
||||
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
|
||||
JS_ASSERT(jsdc);
|
||||
jsdj_SetJSDContext(jsdjc, jsdc);
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(JSDContext*)
|
||||
JSDJ_GetJSDContext(JSDJContext* jsdjc)
|
||||
{
|
||||
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
|
||||
return jsdj_GetJSDContext(jsdjc);
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(JSBool)
|
||||
JSDJ_RegisterNatives(JSDJContext* jsdjc)
|
||||
{
|
||||
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
|
||||
return jsdj_RegisterNatives(jsdjc);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
#ifdef JSD_STANDALONE_JAVA_VM
|
||||
|
||||
JSDJ_PUBLIC_API(JNIEnv*)
|
||||
JSDJ_CreateJavaVMAndStartDebugger(JSDJContext* jsdjc)
|
||||
{
|
||||
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
|
||||
return jsdj_CreateJavaVMAndStartDebugger(jsdjc);
|
||||
}
|
||||
|
||||
#endif /* JSD_STANDALONE_JAVA_VM */
|
||||
/***************************************************************************/
|
||||
133
mozilla/js/jsd/java/jsdjava.h
Normal file
133
mozilla/js/jsd/java/jsdjava.h
Normal file
@@ -0,0 +1,133 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Header for JavaScript Debugger JNI interfaces
|
||||
*/
|
||||
|
||||
#ifndef jsdjava_h___
|
||||
#define jsdjava_h___
|
||||
|
||||
/* Get jstypes.h included first. After that we can use PR macros for doing
|
||||
* this extern "C" stuff!
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#include "jstypes.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
#include "jsdebug.h"
|
||||
#include "jni.h"
|
||||
JS_END_EXTERN_C
|
||||
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
/*
|
||||
* The linkage of JSDJ API functions differs depending on whether the file is
|
||||
* used within the JSDJ library or not. Any source file within the JSDJ
|
||||
* libraray should define EXPORT_JSDJ_API whereas any client of the library
|
||||
* should not.
|
||||
*/
|
||||
#ifdef EXPORT_JSDJ_API
|
||||
#define JSDJ_PUBLIC_API(t) JS_EXPORT_API(t)
|
||||
#define JSDJ_PUBLIC_DATA(t) JS_EXPORT_DATA(t)
|
||||
#else
|
||||
#define JSDJ_PUBLIC_API(t) JS_IMPORT_API(t)
|
||||
#define JSDJ_PUBLIC_DATA(t) JS_IMPORT_DATA(t)
|
||||
#endif
|
||||
|
||||
#define JSDJ_FRIEND_API(t) JSDJ_PUBLIC_API(t)
|
||||
#define JSDJ_FRIEND_DATA(t) JSDJ_PUBLIC_DATA(t)
|
||||
|
||||
/***************************************************************************/
|
||||
/* Opaque typedefs for handles */
|
||||
|
||||
typedef struct JSDJContext JSDJContext;
|
||||
|
||||
/***************************************************************************/
|
||||
/* High Level functions */
|
||||
|
||||
#define JSDJ_START_SUCCESS 1
|
||||
#define JSDJ_START_FAILURE 2
|
||||
#define JSDJ_STOP 3
|
||||
|
||||
typedef void
|
||||
(*JSDJ_StartStopProc)(JSDJContext* jsdjc, int event, void *user);
|
||||
|
||||
typedef JNIEnv*
|
||||
(*JSDJ_GetJNIEnvProc)(JSDJContext* jsdjc, void* user);
|
||||
|
||||
/* This struct could have more fields in future versions */
|
||||
typedef struct
|
||||
{
|
||||
uintN size; /* size of this struct (init before use)*/
|
||||
JSDJ_StartStopProc startStop;
|
||||
JSDJ_GetJNIEnvProc getJNIEnv;
|
||||
} JSDJ_UserCallbacks;
|
||||
|
||||
extern JSDJ_PUBLIC_API(JSDJContext*)
|
||||
JSDJ_SimpleInitForSingleContextMode(JSDContext* jsdc,
|
||||
JSDJ_GetJNIEnvProc getEnvProc, void* user);
|
||||
|
||||
extern JSDJ_PUBLIC_API(JSBool)
|
||||
JSDJ_SetSingleContextMode();
|
||||
|
||||
extern JSDJ_PUBLIC_API(JSDJContext*)
|
||||
JSDJ_CreateContext();
|
||||
|
||||
extern JSDJ_PUBLIC_API(void)
|
||||
JSDJ_DestroyContext(JSDJContext* jsdjc);
|
||||
|
||||
extern JSDJ_PUBLIC_API(void)
|
||||
JSDJ_SetUserCallbacks(JSDJContext* jsdjc, JSDJ_UserCallbacks* callbacks,
|
||||
void* user);
|
||||
|
||||
extern JSDJ_PUBLIC_API(void)
|
||||
JSDJ_SetJNIEnvForCurrentThread(JSDJContext* jsdjc, JNIEnv* env);
|
||||
|
||||
extern JSDJ_PUBLIC_API(JNIEnv*)
|
||||
JSDJ_GetJNIEnvForCurrentThread(JSDJContext* jsdjc);
|
||||
|
||||
extern JSDJ_PUBLIC_API(void)
|
||||
JSDJ_SetJSDContext(JSDJContext* jsdjc, JSDContext* jsdc);
|
||||
|
||||
extern JSDJ_PUBLIC_API(JSDContext*)
|
||||
JSDJ_GetJSDContext(JSDJContext* jsdjc);
|
||||
|
||||
extern JSDJ_PUBLIC_API(JSBool)
|
||||
JSDJ_RegisterNatives(JSDJContext* jsdjc);
|
||||
|
||||
/***************************************************************************/
|
||||
#ifdef JSD_STANDALONE_JAVA_VM
|
||||
|
||||
extern JSDJ_PUBLIC_API(JNIEnv*)
|
||||
JSDJ_CreateJavaVMAndStartDebugger(JSDJContext* jsdjc);
|
||||
|
||||
#endif /* JSD_STANDALONE_JAVA_VM */
|
||||
/***************************************************************************/
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsdjava_h___ */
|
||||
|
||||
78
mozilla/js/jsd/java/jsdjava.mak
Normal file
78
mozilla/js/jsd/java/jsdjava.mak
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
PROJ = jsdjava
|
||||
JSDJAVA = .
|
||||
JSD = $(JSDJAVA)\..
|
||||
JS = $(JSD)\..\src
|
||||
JSPROJ = js32
|
||||
JSDPROJ = jsd
|
||||
|
||||
!IF "$(BUILD_OPT)" != ""
|
||||
OBJ = Release
|
||||
CC_FLAGS = /DNDEBUG
|
||||
!ELSE
|
||||
OBJ = Debug
|
||||
CC_FLAGS = /DDEBUG
|
||||
LINK_FLAGS = /DEBUG
|
||||
!ENDIF
|
||||
|
||||
QUIET=@
|
||||
|
||||
CFLAGS = /nologo /MDd /W3 /Gm /GX /Zi /Od\
|
||||
/I $(JS)\
|
||||
/I $(JSD)\
|
||||
/I $(JSDJAVA)\
|
||||
/DDEBUG /DWIN32 /DXP_PC /D_WINDOWS /D_WIN32\
|
||||
/DJSD_THREADSAFE\
|
||||
/DEXPORT_JSDJ_API\
|
||||
/DJSDEBUGGER\
|
||||
!IF "$(JSD_STANDALONE_JAVA_VM)" != ""
|
||||
/I $(JSDJAVA)\jre\
|
||||
/I $(JSDJAVA)\jre\win32\
|
||||
/DJSD_STANDALONE_JAVA_VM\
|
||||
!ENDIF
|
||||
$(CC_FLAGS)\
|
||||
/c /Fp$(OBJ)\$(PROJ).pch /Fd$(OBJ)\$(PROJ).pdb /YX -Fo$@ $<
|
||||
|
||||
LFLAGS = /nologo /subsystem:console /DLL /incremental:no /machine:I386 \
|
||||
$(LINK_FLAGS) /pdb:$(OBJ)\$(PROJ).pdb -out:$(OBJ)\$(PROJ).dll
|
||||
|
||||
LLIBS = kernel32.lib advapi32.lib \
|
||||
$(JS)\$(OBJ)\$(JSPROJ).lib $(JSD)\$(OBJ)\$(JSDPROJ).lib
|
||||
|
||||
CPP=cl.exe
|
||||
LINK32=link.exe
|
||||
|
||||
all: $(OBJ) $(OBJ)\$(PROJ).dll
|
||||
|
||||
|
||||
$(OBJ)\$(PROJ).dll: \
|
||||
!IF "$(JSD_STANDALONE_JAVA_VM)" != ""
|
||||
$(OBJ)\jsd_jvm.obj \
|
||||
$(OBJ)\jre.obj \
|
||||
$(OBJ)\jre_md.obj \
|
||||
!ENDIF
|
||||
$(OBJ)\jsdjava.obj \
|
||||
$(OBJ)\jsd_jntv.obj
|
||||
$(QUIET)$(LINK32) $(LFLAGS) $** $(LLIBS)
|
||||
|
||||
{$(JSDJAVA)}.c{$(OBJ)}.obj :
|
||||
$(QUIET)$(CPP) $(CFLAGS)
|
||||
|
||||
{$(JSDJAVA)\jre}.c{$(OBJ)}.obj :
|
||||
$(QUIET)$(CPP) $(CFLAGS)
|
||||
|
||||
{$(JSDJAVA)\jre\win32}.c{$(OBJ)}.obj :
|
||||
$(QUIET)$(CPP) $(CFLAGS)
|
||||
|
||||
$(OBJ) :
|
||||
$(QUIET)mkdir $(OBJ)
|
||||
|
||||
clean:
|
||||
@echo deleting old output
|
||||
$(QUIET)del $(OBJ)\*.pch >NUL
|
||||
$(QUIET)del $(OBJ)\*.obj >NUL
|
||||
$(QUIET)del $(OBJ)\*.exp >NUL
|
||||
$(QUIET)del $(OBJ)\*.lib >NUL
|
||||
$(QUIET)del $(OBJ)\*.idb >NUL
|
||||
$(QUIET)del $(OBJ)\*.pdb >NUL
|
||||
$(QUIET)del $(OBJ)\*.dll >NUL
|
||||
147
mozilla/js/jsd/javawrap/javawrap.mak
Normal file
147
mozilla/js/jsd/javawrap/javawrap.mak
Normal file
@@ -0,0 +1,147 @@
|
||||
|
||||
PROJ = nativejsengine
|
||||
PACKAGE_DOT = com.netscape.nativejsengine
|
||||
|
||||
NJSE = .
|
||||
TESTS = $(NJSE)\tests
|
||||
GEN = $(NJSE)\_jni
|
||||
JSD = $(NJSE)\..
|
||||
JS = $(JSD)\..\src
|
||||
JSDJAVA = $(JSD)\java
|
||||
|
||||
JSPROJ = js32
|
||||
JSDPROJ = jsd
|
||||
JSDJAVAPROJ = jsdjava
|
||||
|
||||
EXPORT_BIN_BASE_DIR = $(NJSE)\..\..\jsdj\dist\bin
|
||||
EXPORT_CLASSES_BASE_DIR = $(NJSE)\..\..\jsdj\dist\classes
|
||||
|
||||
!IF "$(BUILD_OPT)" != ""
|
||||
OBJ = Release
|
||||
CC_FLAGS = /DNDEBUG
|
||||
!ELSE
|
||||
OBJ = Debug
|
||||
CC_FLAGS = /DDEBUG
|
||||
LINK_FLAGS = /DEBUG
|
||||
!ENDIF
|
||||
|
||||
QUIET=@
|
||||
|
||||
EXPORT_BIN_DIR = $(EXPORT_BIN_BASE_DIR)\$(OBJ)
|
||||
|
||||
STD_CLASSPATH = -classpath $(EXPORT_CLASSES_BASE_DIR);$(CLASSPATH)
|
||||
|
||||
CFLAGS = /nologo /MDd /W3 /Gm /GX /Zi /Od\
|
||||
/DWIN32 /DXP_PC /D_WINDOWS /D_WIN32\
|
||||
/I $(JS)\
|
||||
/I $(JSD)\
|
||||
/I $(JSDJAVA)\
|
||||
/DJSDEBUGGER\
|
||||
/DJSD_THREADSAFE\
|
||||
$(CC_FLAGS)\
|
||||
/c /Fp$(OBJ)\$(PROJ).pch /Fd$(OBJ)\$(PROJ).pdb /YX -Fo$@ $<
|
||||
|
||||
LFLAGS = /nologo /subsystem:console /incremental:no /DLL /machine:I386 \
|
||||
$(LINK_FLAGS) /pdb:$(OBJ)\$(PROJ).pdb -out:$(OBJ)\$(PROJ).dll
|
||||
|
||||
LLIBS = kernel32.lib advapi32.lib \
|
||||
$(JS)\$(OBJ)\$(JSPROJ).lib \
|
||||
$(JSD)\$(OBJ)\$(JSDPROJ).lib \
|
||||
$(JSDJAVA)\$(OBJ)\$(JSDJAVAPROJ).lib
|
||||
|
||||
CPP=cl.exe
|
||||
LINK32=link.exe
|
||||
|
||||
CLASSES_WITH_NATIVES = \
|
||||
$(PACKAGE_DOT).JSRuntime\
|
||||
$(PACKAGE_DOT).JSContext
|
||||
|
||||
|
||||
all: $(GEN) $(OBJ) dlls mkjniheaders $(OBJ)\$(PROJ).dll export_binaries
|
||||
|
||||
$(OBJ)\$(PROJ).dll: \
|
||||
$(OBJ)\nativejsengine.obj
|
||||
$(QUIET)$(LINK32) $(LFLAGS) $** $(LLIBS)
|
||||
|
||||
.c{$(OBJ)}.obj:
|
||||
$(QUIET)$(CPP) $(CFLAGS)
|
||||
|
||||
$(GEN) :
|
||||
@mkdir $(GEN)
|
||||
|
||||
$(OBJ) :
|
||||
@mkdir $(OBJ)
|
||||
|
||||
dlls :
|
||||
$(QUIET)cd ..\..\src
|
||||
!IF "$(BUILD_OPT)" != ""
|
||||
$(QUIET)nmake -f js.mak CFG="js - Win32 Release"
|
||||
!ELSE
|
||||
$(QUIET)nmake -f js.mak CFG="js - Win32 Debug"
|
||||
!ENDIF
|
||||
$(QUIET)cd ..\jsd\javawrap
|
||||
$(QUIET)cd ..
|
||||
$(QUIET)nmake -f jsd.mak JSD_THREADSAFE=1 $(OPT)
|
||||
$(QUIET)cd javawrap
|
||||
$(QUIET)cd ..\java
|
||||
$(QUIET)nmake -f jsdjava.mak $(OPT)
|
||||
$(QUIET)cd ..\javawrap
|
||||
|
||||
|
||||
export_binaries : mk_export_dirs
|
||||
@echo exporting binaries
|
||||
$(QUIET)copy $(JS)\$(OBJ)\$(JSPROJ).dll $(EXPORT_BIN_DIR) >NUL
|
||||
$(QUIET)copy $(JS)\$(OBJ)\$(JSPROJ).pdb $(EXPORT_BIN_DIR) >NUL
|
||||
$(QUIET)copy $(JSD)\$(OBJ)\$(JSDPROJ).dll $(EXPORT_BIN_DIR) >NUL
|
||||
$(QUIET)copy $(JSD)\$(OBJ)\$(JSDPROJ).pdb $(EXPORT_BIN_DIR) >NUL
|
||||
$(QUIET)copy $(JSDJAVA)\$(OBJ)\$(JSDJAVAPROJ).dll $(EXPORT_BIN_DIR) >NUL
|
||||
$(QUIET)copy $(JSDJAVA)\$(OBJ)\$(JSDJAVAPROJ).pdb $(EXPORT_BIN_DIR) >NUL
|
||||
$(QUIET)copy $(OBJ)\$(PROJ).pdb $(EXPORT_BIN_DIR) >NUL
|
||||
$(QUIET)copy $(OBJ)\$(PROJ).dll $(EXPORT_BIN_DIR) >NUL
|
||||
|
||||
mkjniheaders :
|
||||
@echo generating JNI header
|
||||
$(QUIET)javah -jni -d "$(GEN)" $(STD_CLASSPATH) $(CLASSES_WITH_NATIVES)
|
||||
@touch *.c >NUL
|
||||
|
||||
mk_export_dirs:
|
||||
@if not exist $(JS)\..\jsdj\dist\NUL @mkdir $(JS)\..\jsdj\dist
|
||||
@if not exist $(JS)\..\jsdj\dist\bin\NUL @mkdir $(JS)\..\jsdj\dist\bin
|
||||
@if not exist $(EXPORT_BIN_DIR)\NUL @mkdir $(EXPORT_BIN_DIR)
|
||||
|
||||
#mktest :
|
||||
# @echo compiling Java test file
|
||||
# @sj $(JAVAFLAGS) $(TEST_CLASSPATH) $(TESTS)\Main.java
|
||||
# @echo copying js and jsd dlls
|
||||
# @copy $(JS)\$(OBJ)\$(JSPROJ).dll $(OBJ) >NUL
|
||||
# @copy $(JS)\$(OBJ)\$(JSPROJ).pdb $(OBJ) >NUL
|
||||
# @copy $(JSD)\$(OBJ)\$(JSDPROJ).dll $(OBJ) >NUL
|
||||
# @copy $(JSD)\$(OBJ)\$(JSDPROJ).pdb $(OBJ) >NUL
|
||||
# @copy $(TESTS)\*.js $(OBJ) >NUL
|
||||
|
||||
clean:
|
||||
@echo deleting old output
|
||||
$(QUIET)del $(OBJ)\*.pch >NUL
|
||||
$(QUIET)del $(OBJ)\*.obj >NUL
|
||||
$(QUIET)del $(OBJ)\*.exp >NUL
|
||||
$(QUIET)del $(OBJ)\*.lib >NUL
|
||||
$(QUIET)del $(OBJ)\*.idb >NUL
|
||||
$(QUIET)del $(OBJ)\*.pdb >NUL
|
||||
$(QUIET)del $(OBJ)\*.dll >NUL
|
||||
$(QUIET)del $(GEN)\*.h >NUL
|
||||
|
||||
|
||||
deep_clean: clean
|
||||
$(QUIET)cd ..\..\src
|
||||
!IF "$(BUILD_OPT)" != ""
|
||||
$(QUIET)nmake -f js.mak CFG="js - Win32 Release" clean
|
||||
!ELSE
|
||||
$(QUIET)nmake -f js.mak CFG="js - Win32 Debug" clean
|
||||
!ENDIF
|
||||
$(QUIET)cd ..\jsd\javawrap
|
||||
$(QUIET)cd ..
|
||||
$(QUIET)nmake -f jsd.mak clean
|
||||
$(QUIET)cd javawrap
|
||||
$(QUIET)cd ..\java
|
||||
$(QUIET)nmake -f jsdjava.mak clean
|
||||
$(QUIET)cd ..\javawrap
|
||||
1
mozilla/js/jsd/javawrap/mk.bat
Executable file
1
mozilla/js/jsd/javawrap/mk.bat
Executable file
@@ -0,0 +1 @@
|
||||
nmake -f javawrap.mak %1 %2 %3 %4 %5
|
||||
616
mozilla/js/jsd/javawrap/nativejsengine.c
Normal file
616
mozilla/js/jsd/javawrap/nativejsengine.c
Normal file
@@ -0,0 +1,616 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "_jni/com_netscape_nativejsengine_JSRuntime.h"
|
||||
#include "_jni/com_netscape_nativejsengine_JSContext.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jstypes.h"
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
#include "jsdebug.h"
|
||||
#include "jsdjava.h"
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#define ASSERT_RETURN_VOID(x) \
|
||||
JS_BEGIN_MACRO \
|
||||
if(!(x)) \
|
||||
{ \
|
||||
JS_ASSERT(0); \
|
||||
return; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
#define ASSERT_RETURN_VALUE(x,v)\
|
||||
JS_BEGIN_MACRO \
|
||||
if(!(x)) \
|
||||
{ \
|
||||
JS_ASSERT(0); \
|
||||
return v; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
#define CHECK_RETURN_VOID(x) \
|
||||
JS_BEGIN_MACRO \
|
||||
if(!(x)) \
|
||||
{ \
|
||||
return; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
#define CHECK_RETURN_VALUE(x,v) \
|
||||
JS_BEGIN_MACRO \
|
||||
if(!(x)) \
|
||||
{ \
|
||||
return v; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
#define ASSERT_GOTO(x,w) \
|
||||
JS_BEGIN_MACRO \
|
||||
if(!(x)) \
|
||||
{ \
|
||||
JS_ASSERT(0); \
|
||||
goto w; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
#define CHECK_GOTO(x,w) \
|
||||
JS_BEGIN_MACRO \
|
||||
if(!(x)) \
|
||||
{ \
|
||||
goto w; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
#ifdef DEBUG
|
||||
#define ASSERT_CLEAR_EXCEPTION(e) \
|
||||
JS_BEGIN_MACRO \
|
||||
if((*e)->ExceptionOccurred(e)) \
|
||||
{ \
|
||||
(*e)->ExceptionDescribe(e); \
|
||||
JS_ASSERT(0); \
|
||||
} \
|
||||
(*e)->ExceptionClear(e); \
|
||||
JS_END_MACRO
|
||||
#else /* ! DEBUG */
|
||||
#define ASSERT_CLEAR_EXCEPTION(e) (*e)->ExceptionClear(e)
|
||||
#endif /* DEBUG */
|
||||
|
||||
#define CHECK_CLEAR_EXCEPTION(e) (*e)->ExceptionClear(e)
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef struct ContextInfo {
|
||||
JNIEnv* env;
|
||||
jobject contextObject;
|
||||
} ContextInfo;
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
static void
|
||||
_jamSourceIntoJSD(JSContext *cx, const char* src, int len, const char* filename)
|
||||
{
|
||||
jclass clazz_self;
|
||||
jclass clazz;
|
||||
JSDJContext* jsdjc;
|
||||
jobject rtObject;
|
||||
jobject contextObject;
|
||||
jmethodID mid;
|
||||
jfieldID fid;
|
||||
ContextInfo* info;
|
||||
JNIEnv* env;
|
||||
|
||||
info = (ContextInfo*) JS_GetContextPrivate(cx);
|
||||
ASSERT_RETURN_VOID(info);
|
||||
|
||||
env = info->env;
|
||||
ASSERT_RETURN_VOID(env);
|
||||
|
||||
contextObject = info->contextObject;
|
||||
ASSERT_RETURN_VOID(contextObject);
|
||||
|
||||
clazz_self = (*env)->GetObjectClass(env, contextObject);
|
||||
ASSERT_RETURN_VOID(clazz_self);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz_self, "_runtime",
|
||||
"Lcom/netscape/nativejsengine/JSRuntime;");
|
||||
ASSERT_RETURN_VOID(fid);
|
||||
|
||||
rtObject = (*env)->GetObjectField(env, contextObject, fid);
|
||||
ASSERT_RETURN_VOID(rtObject);
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, rtObject);
|
||||
ASSERT_RETURN_VOID(clazz);
|
||||
|
||||
mid = (*env)->GetMethodID(env, clazz, "getNativeDebugSupport", "()J");
|
||||
ASSERT_RETURN_VOID(mid);
|
||||
|
||||
jsdjc = (JSDJContext*) (*env)->CallObjectMethod(env, rtObject, mid);
|
||||
if(jsdjc)
|
||||
{
|
||||
JSDContext* jsdc;
|
||||
|
||||
jsdc = JSDJ_GetJSDContext(jsdjc);
|
||||
ASSERT_RETURN_VOID(jsdc);
|
||||
|
||||
JSD_AddFullSourceText(jsdc, src, len, filename);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static JSBool
|
||||
_loadSingleFile(JSContext *cx, JSObject *obj, const char* filename)
|
||||
{
|
||||
char* buf;
|
||||
FILE* file;
|
||||
int file_len;
|
||||
jsval result;
|
||||
|
||||
errno = 0;
|
||||
file = fopen(filename, "rb");
|
||||
if (!file) {
|
||||
JS_ReportError(cx, "can't open %s: %s", filename, strerror(errno));
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
file_len = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
if(! file_len) {
|
||||
fclose(file);
|
||||
JS_ReportError(cx, "%s is empty", filename);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
buf = (char*) malloc(file_len);
|
||||
if(! buf) {
|
||||
fclose(file);
|
||||
JS_ReportError(cx, "memory alloc error while trying to read %s", filename);
|
||||
return JS_FALSE;
|
||||
}
|
||||
fread(buf, 1, file_len, file);
|
||||
fclose(file);
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
_jamSourceIntoJSD(cx, buf, file_len, filename);
|
||||
#endif
|
||||
|
||||
JS_EvaluateScript(cx, obj, buf, file_len, filename, 1, &result);
|
||||
|
||||
free(buf);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void _sendPrintStringToJava(JNIEnv* env, jobject contextObject,
|
||||
jmethodID mid, const char* str)
|
||||
{
|
||||
if(! str)
|
||||
return;
|
||||
(*env)->CallObjectMethod(env, contextObject, mid,
|
||||
(*env)->NewStringUTF(env, str));
|
||||
}
|
||||
|
||||
static JSBool
|
||||
Print(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
uintN i, n;
|
||||
JSString *str;
|
||||
|
||||
ContextInfo* info;
|
||||
jmethodID mid;
|
||||
jclass clazz;
|
||||
JNIEnv* env;
|
||||
|
||||
info = (ContextInfo*) JS_GetContextPrivate(cx);
|
||||
ASSERT_RETURN_VALUE(info, JS_FALSE);
|
||||
|
||||
env = info->env;
|
||||
ASSERT_RETURN_VALUE(env, JS_FALSE);
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, info->contextObject);
|
||||
ASSERT_RETURN_VALUE(clazz, JS_FALSE);
|
||||
|
||||
mid = (*env)->GetMethodID(env, clazz, "_print", "(Ljava/lang/String;)V");
|
||||
ASSERT_RETURN_VALUE(mid, JS_FALSE);
|
||||
|
||||
for (i = n = 0; i < argc; i++) {
|
||||
str = JS_ValueToString(cx, argv[i]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
|
||||
if(i)
|
||||
_sendPrintStringToJava(env, info->contextObject, mid, "");
|
||||
_sendPrintStringToJava(env, info->contextObject, mid, JS_GetStringBytes(str));
|
||||
n++;
|
||||
}
|
||||
if (n)
|
||||
_sendPrintStringToJava(env, info->contextObject, mid, "\n");
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
Version(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
if (argc > 0 && JSVAL_IS_INT(argv[0]))
|
||||
*rval = INT_TO_JSVAL(JS_SetVersion(cx, JSVAL_TO_INT(argv[0])));
|
||||
else
|
||||
*rval = INT_TO_JSVAL(JS_GetVersion(cx));
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
Load(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
uintN i;
|
||||
JSString *str;
|
||||
const char *filename;
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
str = JS_ValueToString(cx, argv[i]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
argv[i] = STRING_TO_JSVAL(str);
|
||||
filename = JS_GetStringBytes(str);
|
||||
|
||||
if(! _loadSingleFile(cx, obj, filename))
|
||||
return JS_FALSE;
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSFunctionSpec shell_functions[] = {
|
||||
{"version", Version, 0},
|
||||
{"load", Load, 1},
|
||||
{"print", Print, 0},
|
||||
{0}
|
||||
};
|
||||
|
||||
static void
|
||||
my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
|
||||
{
|
||||
ContextInfo* info;
|
||||
jmethodID mid;
|
||||
jclass clazz;
|
||||
JNIEnv* env;
|
||||
|
||||
jobject msg = NULL;
|
||||
jobject filename = NULL;
|
||||
jobject lineBuf = NULL;
|
||||
int lineno = 0;
|
||||
int offset = 0;
|
||||
|
||||
info = (ContextInfo*) JS_GetContextPrivate(cx);
|
||||
ASSERT_RETURN_VOID(info);
|
||||
|
||||
env = info->env;
|
||||
ASSERT_RETURN_VOID(env);
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, info->contextObject);
|
||||
ASSERT_RETURN_VOID(clazz);
|
||||
|
||||
mid = (*env)->GetMethodID(env, clazz, "_reportError",
|
||||
"(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;I)V");
|
||||
ASSERT_RETURN_VOID(mid);
|
||||
|
||||
|
||||
if(message)
|
||||
msg = (*env)->NewStringUTF(env, message);
|
||||
|
||||
if(report)
|
||||
{
|
||||
lineno = report->lineno;
|
||||
if(report->filename)
|
||||
filename = (*env)->NewStringUTF(env, report->filename);
|
||||
|
||||
if(report->linebuf)
|
||||
{
|
||||
lineBuf = (*env)->NewStringUTF(env, report->linebuf);
|
||||
if(report->tokenptr)
|
||||
offset = report->tokenptr - report->linebuf;
|
||||
}
|
||||
}
|
||||
|
||||
(*env)->CallObjectMethod(env, info->contextObject, mid,
|
||||
msg, filename, lineno, lineBuf, offset);
|
||||
|
||||
}
|
||||
|
||||
static JSClass global_class = {
|
||||
"global", 0,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
|
||||
};
|
||||
|
||||
/*
|
||||
* Class: com_netscape_nativejsengine_JSRuntime
|
||||
* Method: _init
|
||||
* Signature: (Z)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_com_netscape_nativejsengine_JSRuntime__1init
|
||||
(JNIEnv * env, jobject self, jboolean enableDebugging)
|
||||
{
|
||||
JSRuntime *rt;
|
||||
jclass clazz;
|
||||
jfieldID fid;
|
||||
|
||||
rt = JS_NewRuntime(8L * 1024L * 1024L);
|
||||
ASSERT_RETURN_VALUE(rt, JNI_FALSE);
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, self);
|
||||
ASSERT_RETURN_VALUE(clazz, JNI_FALSE);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz, "_nativeRuntime", "J");
|
||||
ASSERT_RETURN_VALUE(fid, JNI_FALSE);
|
||||
(*env)->SetLongField(env, self, fid, (long) rt);
|
||||
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
if(enableDebugging)
|
||||
{
|
||||
JSDJContext* jsdjc;
|
||||
JSDContext* jsdc;
|
||||
|
||||
jsdc = JSD_DebuggerOnForUser(rt, NULL, NULL);
|
||||
ASSERT_RETURN_VALUE(jsdc, JNI_FALSE);
|
||||
|
||||
jsdjc = JSDJ_CreateContext();
|
||||
ASSERT_RETURN_VALUE(jsdjc, JNI_FALSE);
|
||||
|
||||
JSDJ_SetJSDContext(jsdjc, jsdc);
|
||||
JSDJ_SetJNIEnvForCurrentThread(jsdjc, env);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz, "_nativeDebugSupport", "J");
|
||||
ASSERT_RETURN_VALUE(fid, JNI_FALSE);
|
||||
(*env)->SetLongField(env, self, fid, (long) jsdjc);
|
||||
}
|
||||
#else
|
||||
if(enableDebugging)
|
||||
printf("ERROR - Context created with enableDebugging flag, but no debugging support compiled in!");
|
||||
#endif
|
||||
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: com_netscape_nativejsengine_JSRuntime
|
||||
* Method: _exit
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_com_netscape_nativejsengine_JSRuntime__1exit
|
||||
(JNIEnv * env, jobject self)
|
||||
{
|
||||
jfieldID fid;
|
||||
jclass clazz;
|
||||
JSRuntime *rt;
|
||||
JSContext *iterp = NULL;
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, self);
|
||||
ASSERT_RETURN_VOID(clazz);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz, "_nativeRuntime", "J");
|
||||
ASSERT_RETURN_VOID(fid);
|
||||
rt = (JSRuntime *) (*env)->GetLongField(env, self, fid);
|
||||
ASSERT_RETURN_VOID(rt);
|
||||
|
||||
|
||||
/*
|
||||
* Can't kill runtime if it holds any contexts
|
||||
*
|
||||
* However, JSD may make it's own context(s), so don't ASSERT
|
||||
*/
|
||||
CHECK_RETURN_VOID(!JS_ContextIterator(rt, &iterp));
|
||||
|
||||
printf("runtime = %d\n", (int)rt);
|
||||
|
||||
JS_DestroyRuntime(rt);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/*
|
||||
* Class: com_netscape_nativejsengine_JSContext
|
||||
* Method: _init
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_com_netscape_nativejsengine_JSContext__1init
|
||||
(JNIEnv *env, jobject self)
|
||||
{
|
||||
JSContext *cx;
|
||||
JSObject *glob;
|
||||
jfieldID fid;
|
||||
jmethodID mid;
|
||||
JSRuntime *rt;
|
||||
jobject rtObject;
|
||||
jclass clazz;
|
||||
jclass clazz_self;
|
||||
JSBool ok;
|
||||
ContextInfo* info;
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
JSDJContext* jsdjc;
|
||||
#endif
|
||||
|
||||
clazz_self = (*env)->GetObjectClass(env, self);
|
||||
ASSERT_RETURN_VALUE(clazz_self, JNI_FALSE);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz_self, "_runtime",
|
||||
"Lcom/netscape/nativejsengine/JSRuntime;");
|
||||
ASSERT_RETURN_VALUE(fid, JNI_FALSE);
|
||||
|
||||
rtObject = (*env)->GetObjectField(env, self, fid);
|
||||
ASSERT_RETURN_VALUE(rtObject, JNI_FALSE);
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, rtObject);
|
||||
ASSERT_RETURN_VALUE(clazz, JNI_FALSE);
|
||||
|
||||
mid = (*env)->GetMethodID(env, clazz, "getNativeRuntime", "()J");
|
||||
ASSERT_RETURN_VALUE(mid, JNI_FALSE);
|
||||
|
||||
rt = (JSRuntime *) (*env)->CallObjectMethod(env, rtObject, mid);
|
||||
ASSERT_RETURN_VALUE(rt, JNI_FALSE);
|
||||
|
||||
cx = JS_NewContext(rt, 8192);
|
||||
ASSERT_RETURN_VALUE(cx, JNI_FALSE);
|
||||
|
||||
JS_SetErrorReporter(cx, my_ErrorReporter);
|
||||
|
||||
glob = JS_NewObject(cx, &global_class, NULL, NULL);
|
||||
ASSERT_RETURN_VALUE(glob, JNI_FALSE);
|
||||
|
||||
ok = JS_InitStandardClasses(cx, glob);
|
||||
ASSERT_RETURN_VALUE(ok, JNI_FALSE);
|
||||
|
||||
ok = JS_DefineFunctions(cx, glob, shell_functions);
|
||||
ASSERT_RETURN_VALUE(ok, JNI_FALSE);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz_self, "_nativeContext", "J");
|
||||
ASSERT_RETURN_VALUE(fid, JNI_FALSE);
|
||||
(*env)->SetLongField(env, self, fid, (long) cx);
|
||||
|
||||
|
||||
info = (ContextInfo*) malloc(sizeof(ContextInfo));
|
||||
ASSERT_RETURN_VALUE(info, JNI_FALSE);
|
||||
|
||||
info->env = env;
|
||||
info->contextObject = self;
|
||||
|
||||
JS_SetContextPrivate(cx, info);
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
mid = (*env)->GetMethodID(env, clazz, "getNativeDebugSupport", "()J");
|
||||
ASSERT_RETURN_VALUE(mid, JNI_FALSE);
|
||||
|
||||
jsdjc = (JSDJContext*) (*env)->CallObjectMethod(env, rtObject, mid);
|
||||
if(jsdjc)
|
||||
{
|
||||
JSDContext* jsdc = JSDJ_GetJSDContext(jsdjc);
|
||||
ASSERT_RETURN_VALUE(jsdc, JNI_FALSE);
|
||||
|
||||
JSDJ_SetJNIEnvForCurrentThread(jsdjc, env);
|
||||
JSD_JSContextInUse(jsdc, cx);
|
||||
}
|
||||
#endif
|
||||
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: com_netscape_nativejsengine_JSContext
|
||||
* Method: _exit
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_com_netscape_nativejsengine_JSContext__1exit
|
||||
(JNIEnv *env, jobject self)
|
||||
{
|
||||
jfieldID fid;
|
||||
jclass clazz;
|
||||
JSContext *cx;
|
||||
ContextInfo* info;
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, self);
|
||||
ASSERT_RETURN_VOID(clazz);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz, "_nativeContext", "J");
|
||||
ASSERT_RETURN_VOID(fid);
|
||||
|
||||
cx = (JSContext *) (*env)->GetLongField(env, self, fid);
|
||||
ASSERT_RETURN_VOID(cx);
|
||||
|
||||
info = (ContextInfo*) JS_GetContextPrivate(cx);
|
||||
ASSERT_RETURN_VOID(info);
|
||||
free(info);
|
||||
|
||||
printf("context = %d\n", (int)cx);
|
||||
|
||||
JS_DestroyContext(cx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: com_netscape_nativejsengine_JSContext
|
||||
* Method: _eval
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_com_netscape_nativejsengine_JSContext__1eval
|
||||
(JNIEnv * env, jobject self, jstring str, jstring filename, jint lineno)
|
||||
{
|
||||
jfieldID fid;
|
||||
jclass clazz_self;
|
||||
JSContext *cx;
|
||||
JSObject *glob;
|
||||
jsval rval;
|
||||
int len;
|
||||
const char* Cstr;
|
||||
const char* Cfilename;
|
||||
jboolean isCopy;
|
||||
|
||||
clazz_self = (*env)->GetObjectClass(env, self);
|
||||
ASSERT_RETURN_VOID(clazz_self);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz_self, "_nativeContext", "J");
|
||||
ASSERT_RETURN_VOID(fid);
|
||||
|
||||
cx = (JSContext *) (*env)->GetLongField(env, self, fid);
|
||||
ASSERT_RETURN_VOID(cx);
|
||||
|
||||
glob = JS_GetGlobalObject(cx);
|
||||
ASSERT_RETURN_VOID(glob);
|
||||
|
||||
len = (*env)->GetStringUTFLength(env, str);
|
||||
Cstr = (*env)->GetStringUTFChars(env, str, &isCopy);
|
||||
Cfilename = (*env)->GetStringUTFChars(env, filename, &isCopy);
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
/*
|
||||
* XXX this just overwrites any previous source for this url!
|
||||
*/
|
||||
_jamSourceIntoJSD(cx, Cstr, len, Cfilename);
|
||||
#endif
|
||||
|
||||
JS_EvaluateScript(cx, glob, Cstr, len, Cfilename, lineno, &rval);
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, str, Cstr);
|
||||
(*env)->ReleaseStringUTFChars(env, filename, Cfilename);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: com_netscape_nativejsengine_JSContext
|
||||
* Method: _load
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_com_netscape_nativejsengine_JSContext__1load
|
||||
(JNIEnv *env, jobject self, jstring filename)
|
||||
{
|
||||
jfieldID fid;
|
||||
jclass clazz;
|
||||
JSContext *cx;
|
||||
const char* Cfilename;
|
||||
jboolean isCopy;
|
||||
JSObject *glob;
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, self);
|
||||
ASSERT_RETURN_VOID(clazz);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz, "_nativeContext", "J");
|
||||
ASSERT_RETURN_VOID(fid);
|
||||
|
||||
cx = (JSContext *) (*env)->GetLongField(env, self, fid);
|
||||
ASSERT_RETURN_VOID(cx);
|
||||
|
||||
glob = JS_GetGlobalObject(cx);
|
||||
ASSERT_RETURN_VOID(glob);
|
||||
|
||||
Cfilename = (*env)->GetStringUTFChars(env, filename, &isCopy);
|
||||
|
||||
_loadSingleFile(cx, glob, Cfilename);
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, filename, Cfilename);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
70
mozilla/js/jsd/jsd.mak
Normal file
70
mozilla/js/jsd/jsd.mak
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
PROJ = jsd
|
||||
JSD = .
|
||||
JS = $(JSD)\..\src
|
||||
JSPROJ = js32
|
||||
|
||||
!IF "$(BUILD_OPT)" != ""
|
||||
OBJ = Release
|
||||
CC_FLAGS = /DNDEBUG
|
||||
!ELSE
|
||||
OBJ = Debug
|
||||
CC_FLAGS = /DDEBUG
|
||||
LINK_FLAGS = /DEBUG
|
||||
!ENDIF
|
||||
|
||||
QUIET=@
|
||||
|
||||
CFLAGS = /nologo /MDd /W3 /Gm /GX /Zi /Od\
|
||||
/I $(JS)\
|
||||
/I $(JSD)\
|
||||
/DDEBUG /DWIN32 /D_CONSOLE /DXP_PC /D_WINDOWS /D_WIN32\
|
||||
/DJSDEBUGGER\
|
||||
!IF "$(JSD_THREADSAFE)" != ""
|
||||
/DJSD_THREADSAFE\
|
||||
!ENDIF
|
||||
/DEXPORT_JSD_API\
|
||||
$(CC_FLAGS)\
|
||||
/c /Fp$(OBJ)\$(PROJ).pch /Fd$(OBJ)\$(PROJ).pdb /YX -Fo$@ $<
|
||||
|
||||
LFLAGS = /nologo /subsystem:console /DLL /incremental:no /machine:I386 \
|
||||
$(LINK_FLAGS) /pdb:$(OBJ)\$(PROJ).pdb -out:$(OBJ)\$(PROJ).dll
|
||||
|
||||
LLIBS = kernel32.lib advapi32.lib $(JS)\$(OBJ)\$(JSPROJ).lib
|
||||
# unused... user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib
|
||||
|
||||
CPP=cl.exe
|
||||
LINK32=link.exe
|
||||
|
||||
all: $(OBJ) $(OBJ)\$(PROJ).dll
|
||||
|
||||
|
||||
$(OBJ)\$(PROJ).dll: \
|
||||
$(OBJ)\jsdebug.obj \
|
||||
$(OBJ)\jsd_atom.obj \
|
||||
$(OBJ)\jsd_high.obj \
|
||||
$(OBJ)\jsd_hook.obj \
|
||||
$(OBJ)\jsd_obj.obj \
|
||||
$(OBJ)\jsd_scpt.obj \
|
||||
$(OBJ)\jsd_stak.obj \
|
||||
$(OBJ)\jsd_step.obj \
|
||||
$(OBJ)\jsd_text.obj \
|
||||
$(OBJ)\jsd_lock.obj \
|
||||
$(OBJ)\jsd_val.obj
|
||||
$(QUIET)$(LINK32) $(LFLAGS) $** $(LLIBS)
|
||||
|
||||
{$(JSD)}.c{$(OBJ)}.obj :
|
||||
$(QUIET)$(CPP) $(CFLAGS)
|
||||
|
||||
$(OBJ) :
|
||||
$(QUIET)mkdir $(OBJ)
|
||||
|
||||
clean:
|
||||
@echo deleting old output
|
||||
$(QUIET)del $(OBJ)\*.pch >NUL
|
||||
$(QUIET)del $(OBJ)\*.obj >NUL
|
||||
$(QUIET)del $(OBJ)\*.exp >NUL
|
||||
$(QUIET)del $(OBJ)\*.lib >NUL
|
||||
$(QUIET)del $(OBJ)\*.idb >NUL
|
||||
$(QUIET)del $(OBJ)\*.pdb >NUL
|
||||
$(QUIET)del $(OBJ)\*.dll >NUL
|
||||
159
mozilla/js/jsd/jsd_atom.c
Normal file
159
mozilla/js/jsd/jsd_atom.c
Normal file
@@ -0,0 +1,159 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* JavaScript Debugging support - Atom support
|
||||
*/
|
||||
|
||||
#include "jsd.h"
|
||||
|
||||
/* #define TEST_ATOMS 1 */
|
||||
|
||||
#ifdef TEST_ATOMS
|
||||
static void
|
||||
_testAtoms(JSDContext*jsdc)
|
||||
{
|
||||
JSDAtom* atom0 = jsd_AddAtom(jsdc, "foo");
|
||||
JSDAtom* atom1 = jsd_AddAtom(jsdc, "foo");
|
||||
JSDAtom* atom2 = jsd_AddAtom(jsdc, "bar");
|
||||
JSDAtom* atom3 = jsd_CloneAtom(jsdc, atom1);
|
||||
JSDAtom* atom4 = jsd_CloneAtom(jsdc, atom2);
|
||||
|
||||
const char* c0 = JSD_ATOM_TO_STRING(atom0);
|
||||
const char* c1 = JSD_ATOM_TO_STRING(atom1);
|
||||
const char* c2 = JSD_ATOM_TO_STRING(atom2);
|
||||
const char* c3 = JSD_ATOM_TO_STRING(atom3);
|
||||
const char* c4 = JSD_ATOM_TO_STRING(atom4);
|
||||
|
||||
jsd_DropAtom(jsdc, atom0);
|
||||
jsd_DropAtom(jsdc, atom1);
|
||||
jsd_DropAtom(jsdc, atom2);
|
||||
jsd_DropAtom(jsdc, atom3);
|
||||
jsd_DropAtom(jsdc, atom4);
|
||||
}
|
||||
#endif
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(intN)
|
||||
_atom_smasher(JSHashEntry *he, intN i, void *arg)
|
||||
{
|
||||
JS_ASSERT(he);
|
||||
JS_ASSERT(he->value);
|
||||
JS_ASSERT(((JSDAtom*)(he->value))->str);
|
||||
|
||||
free(((JSDAtom*)(he->value))->str);
|
||||
free(he->value);
|
||||
he->value = NULL;
|
||||
he->key = NULL;
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(intN)
|
||||
_compareAtomKeys(const void *v1, const void *v2)
|
||||
{
|
||||
return 0 == strcmp((const char*)v1, (const char*)v2);
|
||||
}
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(intN)
|
||||
_compareAtoms(const void *v1, const void *v2)
|
||||
{
|
||||
return 0 == strcmp(((JSDAtom*)v1)->str, ((JSDAtom*)v2)->str);
|
||||
}
|
||||
|
||||
|
||||
JSBool
|
||||
jsd_CreateAtomTable(JSDContext* jsdc)
|
||||
{
|
||||
jsdc->atoms = JS_NewHashTable(256, JS_HashString,
|
||||
_compareAtomKeys, _compareAtoms,
|
||||
NULL, NULL);
|
||||
#ifdef TEST_ATOMS
|
||||
_testAtoms(jsdc);
|
||||
#endif
|
||||
return (JSBool) jsdc->atoms;
|
||||
}
|
||||
|
||||
void
|
||||
jsd_DestroyAtomTable(JSDContext* jsdc)
|
||||
{
|
||||
if( jsdc->atoms )
|
||||
{
|
||||
JS_HashTableEnumerateEntries(jsdc->atoms, _atom_smasher, NULL);
|
||||
JS_HashTableDestroy(jsdc->atoms);
|
||||
jsdc->atoms = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
JSDAtom*
|
||||
jsd_AddAtom(JSDContext* jsdc, const char* str)
|
||||
{
|
||||
JSDAtom* atom;
|
||||
|
||||
if(!str)
|
||||
{
|
||||
JS_ASSERT(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSD_LOCK_ATOMS(jsdc);
|
||||
|
||||
atom = (JSDAtom*) JS_HashTableLookup(jsdc->atoms, str);
|
||||
|
||||
if( atom )
|
||||
atom->refcount++;
|
||||
else
|
||||
{
|
||||
atom = (JSDAtom*) malloc(sizeof(JSDAtom));
|
||||
if( atom )
|
||||
{
|
||||
atom->str = strdup(str);
|
||||
atom->refcount = 1;
|
||||
if(!JS_HashTableAdd(jsdc->atoms, atom->str, atom))
|
||||
{
|
||||
free(atom->str);
|
||||
free(atom);
|
||||
atom = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSD_UNLOCK_ATOMS(jsdc);
|
||||
return atom;
|
||||
}
|
||||
|
||||
JSDAtom*
|
||||
jsd_CloneAtom(JSDContext* jsdc, JSDAtom* atom)
|
||||
{
|
||||
JSD_LOCK_ATOMS(jsdc);
|
||||
atom->refcount++;
|
||||
JSD_UNLOCK_ATOMS(jsdc);
|
||||
return atom;
|
||||
}
|
||||
|
||||
void
|
||||
jsd_DropAtom(JSDContext* jsdc, JSDAtom* atom)
|
||||
{
|
||||
JSD_LOCK_ATOMS(jsdc);
|
||||
if(! --atom->refcount)
|
||||
{
|
||||
JS_HashTableRemove(jsdc->atoms, atom->str);
|
||||
free(atom->str);
|
||||
free(atom);
|
||||
}
|
||||
JSD_UNLOCK_ATOMS(jsdc);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
@@ -17,39 +17,38 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
** JavaScript Debugger Navigator API - 'High Level' functions
|
||||
*/
|
||||
* JavaScript Debugging support - 'High Level' functions
|
||||
*/
|
||||
|
||||
#include "jsd.h"
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* use a global context for now (avoid direct references to it!) */
|
||||
static JSDContext _static_context;
|
||||
|
||||
/* these are global now, they transcend our concept of JSDContext...*/
|
||||
/* XXX not 'static' because of old Mac CodeWarrior bug */
|
||||
JSCList _jsd_context_list = JS_INIT_STATIC_CLIST(&_jsd_context_list);
|
||||
|
||||
/* these are used to connect JSD_SetUserCallbacks() with JSD_DebuggerOn() */
|
||||
static JSD_UserCallbacks _callbacks;
|
||||
static void* _user;
|
||||
static JSTaskState* _jstaskstate;
|
||||
static PRThread * _dangerousThread1;
|
||||
static void* _user = NULL;
|
||||
static JSRuntime* _jsrt = NULL;
|
||||
|
||||
#ifdef DEBUG
|
||||
void JSD_ASSERT_VALID_CONTEXT( JSDContext* jsdc )
|
||||
{
|
||||
PR_ASSERT( jsdc == &_static_context );
|
||||
PR_ASSERT( jsdc->inited );
|
||||
PR_ASSERT( jsdc->jstaskstate );
|
||||
PR_ASSERT( jsdc->jscontexts );
|
||||
}
|
||||
#ifdef JSD_HAS_DANGEROUS_THREAD
|
||||
static void* _dangerousThread = NULL;
|
||||
#endif
|
||||
|
||||
static PRHashNumber
|
||||
_hash_root(const void *key)
|
||||
#ifdef JSD_THREADSAFE
|
||||
void* _jsd_global_lock = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
void JSD_ASSERT_VALID_CONTEXT(JSDContext* jsdc)
|
||||
{
|
||||
PRHashNumber num = (PRHashNumber) key;
|
||||
return num >> 2;
|
||||
JS_ASSERT(jsdc->inited);
|
||||
JS_ASSERT(jsdc->jsrt);
|
||||
JS_ASSERT(jsdc->dumbContext);
|
||||
JS_ASSERT(jsdc->glob);
|
||||
}
|
||||
#endif
|
||||
|
||||
static JSClass global_class = {
|
||||
"JSDGlobal", 0,
|
||||
@@ -57,242 +56,293 @@ static JSClass global_class = {
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
|
||||
};
|
||||
|
||||
static JSDContext*
|
||||
NewJSDContext(void)
|
||||
static JSBool
|
||||
_validateUserCallbacks(JSD_UserCallbacks* callbacks)
|
||||
{
|
||||
JSDContext* jsdc = &_static_context;
|
||||
return !callbacks ||
|
||||
(callbacks->size && callbacks->size <= sizeof(JSD_UserCallbacks));
|
||||
}
|
||||
|
||||
static JSDContext*
|
||||
_newJSDContext(JSRuntime* jsrt,
|
||||
JSD_UserCallbacks* callbacks,
|
||||
void* user)
|
||||
{
|
||||
JSDContext* jsdc = NULL;
|
||||
|
||||
if( ! jsrt )
|
||||
return NULL;
|
||||
|
||||
if( ! _validateUserCallbacks(callbacks) )
|
||||
return NULL;
|
||||
|
||||
jsdc = (JSDContext*) calloc(1, sizeof(JSDContext));
|
||||
if( ! jsdc )
|
||||
goto label_newJSDContext_failure;
|
||||
|
||||
if( ! JSD_INIT_LOCKS(jsdc) )
|
||||
goto label_newJSDContext_failure;
|
||||
|
||||
JS_INIT_CLIST(&jsdc->links);
|
||||
|
||||
jsdc->jsrt = jsrt;
|
||||
|
||||
if( callbacks )
|
||||
memcpy(&jsdc->userCallbacks, callbacks, callbacks->size);
|
||||
|
||||
if( jsdc->inited )
|
||||
return NULL;
|
||||
jsdc->user = user;
|
||||
|
||||
if( ! _jstaskstate )
|
||||
return NULL;
|
||||
#ifdef JSD_HAS_DANGEROUS_THREAD
|
||||
jsdc->dangerousThread = _dangerousThread;
|
||||
#endif
|
||||
|
||||
memset( jsdc, 0, sizeof(JSDContext) );
|
||||
jsdc->jstaskstate = _jstaskstate;
|
||||
JS_INIT_CLIST(&jsdc->threadsStates);
|
||||
JS_INIT_CLIST(&jsdc->scripts);
|
||||
JS_INIT_CLIST(&jsdc->sources);
|
||||
JS_INIT_CLIST(&jsdc->removedSources);
|
||||
|
||||
PR_INIT_CLIST(&jsdc->threadsStates);
|
||||
jsdc->sourceAlterCount = 1;
|
||||
|
||||
jsdc->dumbContext = JS_NewContext( _jstaskstate, 256 );
|
||||
if( ! jsd_CreateAtomTable(jsdc) )
|
||||
goto label_newJSDContext_failure;
|
||||
|
||||
if( ! jsd_InitObjectManager(jsdc) )
|
||||
goto label_newJSDContext_failure;
|
||||
|
||||
jsdc->dumbContext = JS_NewContext(jsdc->jsrt, 256);
|
||||
if( ! jsdc->dumbContext )
|
||||
return NULL;
|
||||
goto label_newJSDContext_failure;
|
||||
|
||||
jsdc->glob = JS_NewObject(jsdc->dumbContext, &global_class, NULL, NULL);
|
||||
if( ! jsdc->glob )
|
||||
return NULL;
|
||||
goto label_newJSDContext_failure;
|
||||
|
||||
if( ! JS_InitStandardClasses(jsdc->dumbContext, jsdc->glob) )
|
||||
return NULL;
|
||||
|
||||
jsdc->jscontexts = PR_NewHashTable(256, _hash_root,
|
||||
PR_CompareValues, PR_CompareValues,
|
||||
NULL, NULL);
|
||||
if( ! jsdc->jscontexts )
|
||||
return NULL;
|
||||
goto label_newJSDContext_failure;
|
||||
|
||||
jsdc->inited = JS_TRUE;
|
||||
return jsdc;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PRIntn)
|
||||
_hash_entry_zapper(PRHashEntry *he, PRIntn i, void *arg)
|
||||
{
|
||||
PR_FREEIF(he->value);
|
||||
he->value = NULL;
|
||||
he->key = NULL;
|
||||
return HT_ENUMERATE_NEXT;
|
||||
JSD_LOCK();
|
||||
JS_INSERT_LINK(&jsdc->links, &_jsd_context_list);
|
||||
JSD_UNLOCK();
|
||||
|
||||
return jsdc;
|
||||
|
||||
label_newJSDContext_failure:
|
||||
jsd_DestroyObjectManager(jsdc);
|
||||
jsd_DestroyAtomTable(jsdc);
|
||||
if( jsdc )
|
||||
free(jsdc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
DestroyJSDContext( JSDContext* jsdc )
|
||||
_destroyJSDContext(JSDContext* jsdc)
|
||||
{
|
||||
JSD_ASSERT_VALID_CONTEXT(jsdc);
|
||||
if( jsdc->jscontexts )
|
||||
{
|
||||
PR_HashTableEnumerateEntries(jsdc->jscontexts, _hash_entry_zapper, NULL);
|
||||
PR_HashTableDestroy(jsdc->jscontexts);
|
||||
}
|
||||
jsdc->inited = JS_FALSE;
|
||||
}
|
||||
|
||||
JSDContext*
|
||||
jsd_GetDefaultJSDContext(void)
|
||||
{
|
||||
JSDContext* jsdc = &_static_context;
|
||||
if( ! jsdc->inited )
|
||||
return NULL;
|
||||
return jsdc;
|
||||
JSD_LOCK();
|
||||
JS_REMOVE_LINK(&jsdc->links);
|
||||
JSD_UNLOCK();
|
||||
|
||||
jsd_DestroyObjectManager(jsdc);
|
||||
jsd_DestroyAtomTable(jsdc);
|
||||
|
||||
jsdc->inited = JS_FALSE;
|
||||
|
||||
/*
|
||||
* We should free jsdc here, but we let it leak in case there are any
|
||||
* asynchronous hooks calling into the system using it as a handle
|
||||
*
|
||||
* XXX we also leak the locks
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
JSDContext*
|
||||
jsd_DebuggerOnForUser(JSRuntime* jsrt,
|
||||
JSD_UserCallbacks* callbacks,
|
||||
void* user)
|
||||
{
|
||||
JSDContext* jsdc;
|
||||
JSContext* iter = NULL;
|
||||
|
||||
jsdc = _newJSDContext(jsrt, callbacks, user);
|
||||
if( ! jsdc )
|
||||
return NULL;
|
||||
|
||||
/* set hooks here */
|
||||
JS_SetNewScriptHookProc(jsdc->jsrt, jsd_NewScriptHookProc, jsdc);
|
||||
JS_SetDestroyScriptHookProc(jsdc->jsrt, jsd_DestroyScriptHookProc, jsdc);
|
||||
JS_SetDebuggerHandler(jsdc->jsrt, jsd_DebuggerHandler, jsdc);
|
||||
JS_SetExecuteHook(jsdc->jsrt, jsd_InterpreterHook, jsdc);
|
||||
JS_SetCallHook(jsdc->jsrt, jsd_InterpreterHook, jsdc);
|
||||
JS_SetObjectHook(jsdc->jsrt, jsd_ObjectHook, jsdc);
|
||||
JS_SetThrowHook(jsdc->jsrt, jsd_ThrowHandler, jsdc);
|
||||
JS_SetDebugErrorHook(jsdc->jsrt, jsd_DebugErrorHook, jsdc);
|
||||
#ifdef LIVEWIRE
|
||||
LWDBG_SetNewScriptHookProc(jsd_NewScriptHookProc, jsdc);
|
||||
#endif
|
||||
if( jsdc->userCallbacks.setContext )
|
||||
jsdc->userCallbacks.setContext(jsdc, jsdc->user);
|
||||
return jsdc;
|
||||
}
|
||||
|
||||
JSDContext*
|
||||
jsd_DebuggerOn(void)
|
||||
{
|
||||
JSDContext* jsdc = NewJSDContext();
|
||||
JSContext* iter = NULL;
|
||||
JSContext* cx;
|
||||
|
||||
if( ! jsdc )
|
||||
return NULL;
|
||||
|
||||
/* set hooks here */
|
||||
JS_SetNewScriptHookProc( jsdc->jstaskstate, jsd_NewScriptHookProc, jsdc );
|
||||
JS_SetDestroyScriptHookProc( jsdc->jstaskstate, jsd_DestroyScriptHookProc, jsdc );
|
||||
|
||||
/* enumerate contexts for JSTaskState and add them to our table */
|
||||
while( NULL != (cx = JS_ContextIterator(jsdc->jstaskstate, &iter)) )
|
||||
jsd_JSContextUsed( jsdc, cx );
|
||||
|
||||
if( _callbacks.setContext )
|
||||
_callbacks.setContext( jsdc, _user );
|
||||
|
||||
return jsdc;
|
||||
JS_ASSERT(_jsrt);
|
||||
JS_ASSERT(_validateUserCallbacks(&_callbacks));
|
||||
return jsd_DebuggerOnForUser(_jsrt, &_callbacks, _user);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
jsd_DebuggerOff(JSDContext* jsdc)
|
||||
{
|
||||
/* clear hooks here */
|
||||
JS_SetNewScriptHookProc( jsdc->jstaskstate, NULL, NULL );
|
||||
JS_SetDestroyScriptHookProc( jsdc->jstaskstate, NULL, NULL );
|
||||
JS_SetNewScriptHookProc(jsdc->jsrt, NULL, NULL);
|
||||
JS_SetDestroyScriptHookProc(jsdc->jsrt, NULL, NULL);
|
||||
JS_SetDebuggerHandler(jsdc->jsrt, NULL, NULL);
|
||||
JS_SetExecuteHook(jsdc->jsrt, NULL, NULL);
|
||||
JS_SetCallHook(jsdc->jsrt, NULL, NULL);
|
||||
JS_SetObjectHook(jsdc->jsrt, NULL, NULL);
|
||||
JS_SetThrowHook(jsdc->jsrt, NULL, NULL);
|
||||
JS_SetDebugErrorHook(jsdc->jsrt, NULL, NULL);
|
||||
#ifdef LIVEWIRE
|
||||
LWDBG_SetNewScriptHookProc(NULL,NULL);
|
||||
#endif
|
||||
|
||||
/* clean up */
|
||||
jsd_DestroyAllJSDScripts( jsdc );
|
||||
jsd_DestroyAllSources( jsdc );
|
||||
jsd_DestroyAllJSDScripts(jsdc);
|
||||
jsd_DestroyAllSources(jsdc);
|
||||
|
||||
DestroyJSDContext( jsdc );
|
||||
_destroyJSDContext(jsdc);
|
||||
|
||||
if( _callbacks.setContext )
|
||||
_callbacks.setContext( NULL, _user );
|
||||
if( jsdc->userCallbacks.setContext )
|
||||
jsdc->userCallbacks.setContext(NULL, jsdc->user);
|
||||
}
|
||||
|
||||
void
|
||||
jsd_SetUserCallbacks(JSTaskState* jstaskstate, JSD_UserCallbacks* callbacks, void* user)
|
||||
jsd_SetUserCallbacks(JSRuntime* jsrt, JSD_UserCallbacks* callbacks, void* user)
|
||||
{
|
||||
_jstaskstate = jstaskstate;
|
||||
_jsrt = jsrt;
|
||||
_user = user;
|
||||
_dangerousThread1 = PR_CurrentThread();
|
||||
|
||||
#ifdef JSD_HAS_DANGEROUS_THREAD
|
||||
_dangerousThread = JSD_CURRENT_THREAD();
|
||||
#endif
|
||||
|
||||
if( callbacks )
|
||||
memcpy( &_callbacks, callbacks, sizeof(JSD_UserCallbacks) );
|
||||
memcpy(&_callbacks, callbacks, sizeof(JSD_UserCallbacks));
|
||||
else
|
||||
memset( &_callbacks, 0 , sizeof(JSD_UserCallbacks) );
|
||||
|
||||
if( _callbacks.setContext && _static_context.inited )
|
||||
_callbacks.setContext( &_static_context, _user );
|
||||
memset(&_callbacks, 0 , sizeof(JSD_UserCallbacks));
|
||||
}
|
||||
|
||||
JSDContextWrapper*
|
||||
jsd_JSDContextWrapperForJSContext( JSDContext* jsdc, JSContext* context )
|
||||
JSDContext*
|
||||
jsd_JSDContextForJSContext(JSContext* context)
|
||||
{
|
||||
return (JSDContextWrapper*) PR_HashTableLookup(jsdc->jscontexts, context);
|
||||
}
|
||||
JSDContext* iter;
|
||||
JSDContext* jsdc = NULL;
|
||||
JSRuntime* runtime = JS_GetRuntime(context);
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
jsd_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
|
||||
JSD_LOCK();
|
||||
for( iter = (JSDContext*)_jsd_context_list.next;
|
||||
iter != (JSDContext*)&_jsd_context_list;
|
||||
iter = (JSDContext*)iter->links.next )
|
||||
{
|
||||
if( runtime == iter->jsrt )
|
||||
{
|
||||
jsdc = iter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
JSD_UNLOCK();
|
||||
return jsdc;
|
||||
}
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(JSBool)
|
||||
jsd_DebugErrorHook(JSContext *cx, const char *message,
|
||||
JSErrorReport *report, void *closure)
|
||||
{
|
||||
JSDContextWrapper* wrapper;
|
||||
JSDContext* jsdc;
|
||||
PRUintn action = JSD_ERROR_REPORTER_PASS_ALONG;
|
||||
|
||||
jsdc = jsd_GetDefaultJSDContext();
|
||||
JSDContext* jsdc = (JSDContext*) closure;
|
||||
JSD_ErrorReporter errorReporter;
|
||||
void* errorReporterData;
|
||||
|
||||
if( ! jsdc )
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return;
|
||||
JS_ASSERT(0);
|
||||
return JS_TRUE;
|
||||
}
|
||||
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
|
||||
return JS_TRUE;
|
||||
|
||||
wrapper = jsd_JSDContextWrapperForJSContext( jsdc, cx );
|
||||
if( ! wrapper )
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return;
|
||||
}
|
||||
/* local in case hook gets cleared on another thread */
|
||||
JSD_LOCK();
|
||||
errorReporter = jsdc->errorReporter;
|
||||
errorReporterData = jsdc->errorReporterData;
|
||||
JSD_UNLOCK();
|
||||
|
||||
if( jsdc->errorReporter && ! jsd_IsCurrentThreadDangerous() )
|
||||
action = jsdc->errorReporter(jsdc, cx, message, report,
|
||||
jsdc->errorReporterData);
|
||||
if(!errorReporter)
|
||||
return JS_TRUE;
|
||||
|
||||
switch(action)
|
||||
switch(errorReporter(jsdc, cx, message, report, errorReporterData))
|
||||
{
|
||||
case JSD_ERROR_REPORTER_PASS_ALONG:
|
||||
if( wrapper->originalErrorReporter )
|
||||
wrapper->originalErrorReporter(cx, message, report);
|
||||
break;
|
||||
case JSD_ERROR_REPORTER_RETURN:
|
||||
break;
|
||||
return JS_TRUE;
|
||||
case JSD_ERROR_REPORTER_RETURN:
|
||||
return JS_FALSE;
|
||||
case JSD_ERROR_REPORTER_DEBUG:
|
||||
{
|
||||
JSDThreadState* jsdthreadstate;
|
||||
jsval rval;
|
||||
JSD_ExecutionHookProc hook;
|
||||
void* hookData;
|
||||
|
||||
if( ! jsdc->debugBreakHook )
|
||||
return;
|
||||
/* local in case hook gets cleared on another thread */
|
||||
JSD_LOCK();
|
||||
hook = jsdc->debugBreakHook;
|
||||
hookData = jsdc->debugBreakHookData;
|
||||
JSD_UNLOCK();
|
||||
|
||||
jsdthreadstate = jsd_NewThreadState(jsdc,cx);
|
||||
if( jsdthreadstate )
|
||||
{
|
||||
(*jsdc->debugBreakHook)(jsdc, jsdthreadstate,
|
||||
JSD_HOOK_DEBUG_REQUESTED,
|
||||
jsdc->debugBreakHookData );
|
||||
|
||||
jsd_DestroyThreadState(jsdc, jsdthreadstate);
|
||||
}
|
||||
jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_DEBUG_REQUESTED,
|
||||
hook, hookData, &rval);
|
||||
/* XXX Should make this dependent on ExecutionHook retval */
|
||||
return JS_TRUE;
|
||||
}
|
||||
default:;
|
||||
case JSD_ERROR_REPORTER_CLEAR_RETURN:
|
||||
if(report && JSREPORT_IS_EXCEPTION(report->flags))
|
||||
JS_ClearPendingException(cx);
|
||||
return JS_FALSE;
|
||||
default:
|
||||
JS_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
jsd_JSContextUsed( JSDContext* jsdc, JSContext* context )
|
||||
{
|
||||
JSDContextWrapper* wrapper;
|
||||
|
||||
wrapper = jsd_JSDContextWrapperForJSContext(jsdc, context);
|
||||
if( wrapper )
|
||||
{
|
||||
/* error reporters are sometimes overwritten by other code... */
|
||||
JSErrorReporter oldrep = JS_SetErrorReporter(context, jsd_ErrorReporter);
|
||||
if( jsd_ErrorReporter != oldrep )
|
||||
wrapper->originalErrorReporter = oldrep;
|
||||
return;
|
||||
}
|
||||
|
||||
/* else... */
|
||||
wrapper = PR_NEWZAP(JSDContextWrapper);
|
||||
if( ! wrapper )
|
||||
return;
|
||||
|
||||
if( ! PR_HashTableAdd(jsdc->jscontexts, context, wrapper ) )
|
||||
{
|
||||
PR_FREEIF(wrapper);
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper->context = context;
|
||||
wrapper->jsdc = jsdc;
|
||||
|
||||
/* add our error reporter */
|
||||
wrapper->originalErrorReporter = JS_SetErrorReporter(context, jsd_ErrorReporter);
|
||||
|
||||
/* add our printer */
|
||||
/* add our loader */
|
||||
}
|
||||
|
||||
JSD_ErrorReporter
|
||||
jsd_SetErrorReporter( JSDContext* jsdc, JSD_ErrorReporter reporter, void* callerdata)
|
||||
{
|
||||
JSD_ErrorReporter old = jsdc->errorReporter;
|
||||
|
||||
jsdc->errorReporter = reporter;
|
||||
jsdc->errorReporterData = callerdata;
|
||||
return old;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_IsCurrentThreadDangerous()
|
||||
jsd_SetErrorReporter(JSDContext* jsdc,
|
||||
JSD_ErrorReporter reporter,
|
||||
void* callerdata)
|
||||
{
|
||||
return PR_CurrentThread() == _dangerousThread1;
|
||||
JSD_LOCK();
|
||||
jsdc->errorReporter = reporter;
|
||||
jsdc->errorReporterData = callerdata;
|
||||
JSD_UNLOCK();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_GetErrorReporter(JSDContext* jsdc,
|
||||
JSD_ErrorReporter* reporter,
|
||||
void** callerdata)
|
||||
{
|
||||
JSD_LOCK();
|
||||
if( reporter )
|
||||
*reporter = jsdc->errorReporter;
|
||||
if( callerdata )
|
||||
*callerdata = jsdc->errorReporterData;
|
||||
JSD_UNLOCK();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
@@ -17,85 +17,244 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
** JavaScript Debugger Navigator API - Hook support
|
||||
*/
|
||||
* JavaScript Debugging support - Hook support
|
||||
*/
|
||||
|
||||
#include "jsd.h"
|
||||
|
||||
JSTrapStatus PR_CALLBACK
|
||||
JSTrapStatus JS_DLL_CALLBACK
|
||||
jsd_InterruptHandler(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
|
||||
void *closure)
|
||||
{
|
||||
PRUintn hookanswer = JSD_HOOK_RETURN_CONTINUE;
|
||||
JSDThreadState* jsdthreadstate;
|
||||
JSDScript* jsdscript;
|
||||
JSDContext* jsdc = (JSDContext*) closure;
|
||||
|
||||
if( jsd_IsCurrentThreadDangerous() )
|
||||
return JSTRAP_CONTINUE;
|
||||
JSD_ExecutionHookProc hook;
|
||||
void* hookData;
|
||||
|
||||
if( ! jsdc || ! jsdc->inited )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
jsd_JSContextUsed(jsdc, cx);
|
||||
|
||||
if( ! jsdc->interruptHook )
|
||||
|
||||
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
jsdscript = jsd_FindJSDScript(jsdc, script);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
if( ! jsdscript )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
jsdthreadstate = jsd_NewThreadState(jsdc,cx);
|
||||
if( jsdthreadstate )
|
||||
{
|
||||
hookanswer =
|
||||
(*jsdc->interruptHook)(jsdc, jsdthreadstate,
|
||||
JSD_HOOK_INTERRUPTED,
|
||||
jsdc->interruptHookData );
|
||||
#ifdef LIVEWIRE
|
||||
if( ! jsdlw_UserCodeAtPC(jsdc, jsdscript, (jsuword)pc) )
|
||||
return JSTRAP_CONTINUE;
|
||||
#endif
|
||||
|
||||
/* local in case jsdc->interruptHook gets cleared on another thread */
|
||||
JSD_LOCK();
|
||||
hook = jsdc->interruptHook;
|
||||
hookData = jsdc->interruptHookData;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_INTERRUPTED,
|
||||
hook, hookData, rval);
|
||||
}
|
||||
|
||||
JSTrapStatus JS_DLL_CALLBACK
|
||||
jsd_DebuggerHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||
jsval *rval, void *closure)
|
||||
{
|
||||
JSDScript* jsdscript;
|
||||
JSDContext* jsdc = (JSDContext*) closure;
|
||||
JSD_ExecutionHookProc hook;
|
||||
void* hookData;
|
||||
|
||||
if( ! jsdc || ! jsdc->inited )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
jsdscript = jsd_FindJSDScript(jsdc, script);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
if( ! jsdscript )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
/* local in case jsdc->debuggerHook gets cleared on another thread */
|
||||
JSD_LOCK();
|
||||
hook = jsdc->debuggerHook;
|
||||
hookData = jsdc->debuggerHookData;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_DEBUGGER_KEYWORD,
|
||||
hook, hookData, rval);
|
||||
}
|
||||
|
||||
|
||||
JSTrapStatus JS_DLL_CALLBACK
|
||||
jsd_ThrowHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||
jsval *rval, void *closure)
|
||||
{
|
||||
JSDScript* jsdscript;
|
||||
JSDContext* jsdc = (JSDContext*) closure;
|
||||
JSD_ExecutionHookProc hook;
|
||||
void* hookData;
|
||||
|
||||
JS_GetPendingException(cx, rval);
|
||||
|
||||
if( ! jsdc || ! jsdc->inited )
|
||||
return JSD_HOOK_RETURN_CONTINUE_THROW;
|
||||
|
||||
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
|
||||
return JSD_HOOK_RETURN_CONTINUE_THROW;
|
||||
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
jsdscript = jsd_FindJSDScript(jsdc, script);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
if( ! jsdscript )
|
||||
return JSD_HOOK_RETURN_CONTINUE_THROW;
|
||||
|
||||
/* local in case jsdc->throwHook gets cleared on another thread */
|
||||
JSD_LOCK();
|
||||
hook = jsdc->throwHook;
|
||||
hookData = jsdc->throwHookData;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_THROW,
|
||||
hook, hookData, rval);
|
||||
}
|
||||
|
||||
JSTrapStatus
|
||||
jsd_CallExecutionHook(JSDContext* jsdc,
|
||||
JSContext *cx,
|
||||
uintN type,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* hookData,
|
||||
jsval* rval)
|
||||
{
|
||||
uintN hookanswer = JSD_HOOK_THROW == type ?
|
||||
JSD_HOOK_RETURN_CONTINUE_THROW :
|
||||
JSD_HOOK_RETURN_CONTINUE;
|
||||
JSDThreadState* jsdthreadstate;
|
||||
|
||||
if(hook && NULL != (jsdthreadstate = jsd_NewThreadState(jsdc,cx)))
|
||||
{
|
||||
hookanswer = hook(jsdc, jsdthreadstate, type, hookData, rval);
|
||||
jsd_DestroyThreadState(jsdc, jsdthreadstate);
|
||||
}
|
||||
|
||||
*rval = NULL; /* XXX fix this!!! */
|
||||
|
||||
if( JSD_HOOK_RETURN_ABORT == hookanswer )
|
||||
return JSTRAP_ERROR;
|
||||
|
||||
return JSTRAP_CONTINUE; /* XXX fix this!!! */
|
||||
switch(hookanswer)
|
||||
{
|
||||
case JSD_HOOK_RETURN_ABORT:
|
||||
case JSD_HOOK_RETURN_HOOK_ERROR:
|
||||
return JSTRAP_ERROR;
|
||||
case JSD_HOOK_RETURN_RET_WITH_VAL:
|
||||
return JSTRAP_RETURN;
|
||||
case JSD_HOOK_RETURN_THROW_WITH_VAL:
|
||||
return JSTRAP_THROW;
|
||||
case JSD_HOOK_RETURN_CONTINUE:
|
||||
break;
|
||||
case JSD_HOOK_RETURN_CONTINUE_THROW:
|
||||
/* only makes sense for jsd_ThrowHandler (which init'd rval) */
|
||||
JS_ASSERT(JSD_HOOK_THROW == type);
|
||||
return JSTRAP_THROW;
|
||||
default:
|
||||
JS_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
return JSTRAP_CONTINUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_SetInterruptHook(JSDContext* jsdc,
|
||||
jsd_SetInterruptHook(JSDContext* jsdc,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* callerdata)
|
||||
{
|
||||
jsdc->interruptHook = hook;
|
||||
JSD_LOCK();
|
||||
jsdc->interruptHookData = callerdata;
|
||||
jsdc->interruptHook = hook;
|
||||
JS_SetInterrupt(jsdc->jsrt, jsd_InterruptHandler, (void*) jsdc);
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_SetInterrupt(jsdc->jstaskstate, jsd_InterruptHandler, (void*) jsdc);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_ClearInterruptHook(JSDContext* jsdc)
|
||||
jsd_ClearInterruptHook(JSDContext* jsdc)
|
||||
{
|
||||
JSD_LOCK();
|
||||
JS_ClearInterrupt(jsdc->jsrt, NULL, NULL );
|
||||
jsdc->interruptHook = NULL;
|
||||
return JS_ClearInterrupt(jsdc->jstaskstate, NULL, NULL );
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_SetDebugBreakHook(JSDContext* jsdc,
|
||||
jsd_SetDebugBreakHook(JSDContext* jsdc,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* callerdata)
|
||||
{
|
||||
jsdc->debugBreakHook = hook;
|
||||
JSD_LOCK();
|
||||
jsdc->debugBreakHookData = callerdata;
|
||||
jsdc->debugBreakHook = hook;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_ClearDebugBreakHook(JSDContext* jsdc)
|
||||
jsd_ClearDebugBreakHook(JSDContext* jsdc)
|
||||
{
|
||||
JSD_LOCK();
|
||||
jsdc->debugBreakHook = NULL;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_SetDebuggerHook(JSDContext* jsdc,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* callerdata)
|
||||
{
|
||||
JSD_LOCK();
|
||||
jsdc->debuggerHookData = callerdata;
|
||||
jsdc->debuggerHook = hook;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_ClearDebuggerHook(JSDContext* jsdc)
|
||||
{
|
||||
JSD_LOCK();
|
||||
jsdc->debuggerHook = NULL;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_SetThrowHook(JSDContext* jsdc,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* callerdata)
|
||||
{
|
||||
JSD_LOCK();
|
||||
jsdc->throwHookData = callerdata;
|
||||
jsdc->throwHook = hook;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_ClearThrowHook(JSDContext* jsdc)
|
||||
{
|
||||
JSD_LOCK();
|
||||
jsdc->throwHook = NULL;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* this is all going away... replaced by code in js/jsd/java */
|
||||
|
||||
#if 0
|
||||
|
||||
#include "native.h"
|
||||
#include "jsdebug.h"
|
||||
|
||||
@@ -794,4 +798,4 @@ void netscape_jsdebug_JSSourceTextProvider_refreshSourceTextVector(struct Hnetsc
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
@@ -17,8 +17,220 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* 2/17/98 jband
|
||||
* This is a temporary placeholder for this file
|
||||
* to supporet adding this file to existing makefiles before
|
||||
* the real file is pulled in off of a branch
|
||||
*/
|
||||
* JavaScript Debugging support - Locking and threading support
|
||||
*/
|
||||
|
||||
/*
|
||||
* ifdef JSD_USE_NSPR_LOCKS then you musat build and run against NSPR2.
|
||||
* Otherwise, there are stubs that can be filled in with your own locking
|
||||
* code. Also, note that these stubs include a jsd_CurrentThread()
|
||||
* implementation that only works on Win32 - this is needed for the inprocess
|
||||
* Java-based debugger.
|
||||
*/
|
||||
|
||||
#include "jsd.h"
|
||||
|
||||
#ifdef JSD_THREADSAFE
|
||||
|
||||
#ifdef JSD_USE_NSPR_LOCKS
|
||||
|
||||
#include "prlock.h"
|
||||
#include "prthread.h"
|
||||
|
||||
#ifdef JSD_ATTACH_THREAD_HACK
|
||||
#include "pprthred.h" /* need this as long as JS_AttachThread is needed */
|
||||
#endif
|
||||
|
||||
typedef struct JSDStaticLock
|
||||
{
|
||||
void* owner;
|
||||
PRLock* lock;
|
||||
int count;
|
||||
#ifdef DEBUG
|
||||
uint16 sig;
|
||||
#endif
|
||||
} JSDStaticLock;
|
||||
|
||||
/*
|
||||
* This exists to wrap non-NSPR theads (e.g. Java threads) in NSPR wrappers.
|
||||
* XXX We ignore the memory leak issue.
|
||||
* It is claimed that future versions of NSPR will automatically wrap on
|
||||
* the call to PR_GetCurrentThread.
|
||||
*
|
||||
* XXX We ignore the memory leak issue - i.e. we never call PR_DetachThread.
|
||||
*
|
||||
*/
|
||||
#undef _CURRENT_THREAD
|
||||
#ifdef JSD_ATTACH_THREAD_HACK
|
||||
#define _CURRENT_THREAD(out) \
|
||||
JS_BEGIN_MACRO \
|
||||
out = (void*) PR_GetCurrentThread(); \
|
||||
if(!out) \
|
||||
out = (void*) JS_AttachThread(PR_USER_THREAD,PR_PRIORITY_NORMAL,NULL);\
|
||||
JS_ASSERT(out); \
|
||||
JS_END_MACRO
|
||||
#else
|
||||
#define _CURRENT_THREAD(out) \
|
||||
JS_BEGIN_MACRO \
|
||||
out = (void*) PR_GetCurrentThread(); \
|
||||
JS_ASSERT(out); \
|
||||
JS_END_MACRO
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define JSD_LOCK_SIG 0x10CC10CC
|
||||
void ASSERT_VALID_LOCK(JSDStaticLock* lock)
|
||||
{
|
||||
JS_ASSERT(lock);
|
||||
JS_ASSERT(lock->lock);
|
||||
JS_ASSERT(lock->count >= 0);
|
||||
JS_ASSERT((! lock->count && ! lock->owner) || (lock->count && lock->owner));
|
||||
JS_ASSERT(lock->sig == (uint16) JSD_LOCK_SIG);
|
||||
}
|
||||
#else
|
||||
#define ASSERT_VALID_LOCK(x) ((void)0)
|
||||
#endif
|
||||
|
||||
void*
|
||||
jsd_CreateLock()
|
||||
{
|
||||
JSDStaticLock* lock;
|
||||
|
||||
if( ! (lock = calloc(1, sizeof(JSDStaticLock))) ||
|
||||
! (lock->lock = PR_NewLock()) )
|
||||
{
|
||||
if(lock)
|
||||
{
|
||||
free(lock);
|
||||
lock = NULL;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if(lock) lock->sig = (uint16) JSD_LOCK_SIG;
|
||||
#endif
|
||||
return lock;
|
||||
}
|
||||
|
||||
void
|
||||
jsd_Lock(JSDStaticLock* lock)
|
||||
{
|
||||
void* me;
|
||||
|
||||
_CURRENT_THREAD(me);
|
||||
|
||||
ASSERT_VALID_LOCK(lock);
|
||||
|
||||
if(lock->owner == me)
|
||||
lock->count++;
|
||||
else
|
||||
{
|
||||
PR_Lock(lock->lock); /* this can block... */
|
||||
JS_ASSERT(lock->owner == 0);
|
||||
lock->count = 1;
|
||||
lock->owner = me;
|
||||
}
|
||||
ASSERT_VALID_LOCK(lock);
|
||||
}
|
||||
|
||||
void
|
||||
jsd_Unlock(JSDStaticLock* lock)
|
||||
{
|
||||
void* me;
|
||||
|
||||
ASSERT_VALID_LOCK(lock);
|
||||
_CURRENT_THREAD(me);
|
||||
|
||||
if(lock->owner != me)
|
||||
{
|
||||
JS_ASSERT(0); /* it's an error to unlock a lock you don't own */
|
||||
return;
|
||||
}
|
||||
if(--lock->count == 0)
|
||||
{
|
||||
lock->owner = NULL;
|
||||
PR_Unlock(lock->lock);
|
||||
}
|
||||
ASSERT_VALID_LOCK(lock);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
JSBool
|
||||
jsd_IsLocked(JSDStaticLock* lock)
|
||||
{
|
||||
void* me;
|
||||
ASSERT_VALID_LOCK(lock);
|
||||
_CURRENT_THREAD(me);
|
||||
return lock->owner == me ? JS_TRUE : JS_FALSE;
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
void*
|
||||
jsd_CurrentThread()
|
||||
{
|
||||
void* me;
|
||||
_CURRENT_THREAD(me);
|
||||
return me;
|
||||
}
|
||||
|
||||
|
||||
#else /* ! JSD_USE_NSPR_LOCKS */
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma message("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||
#pragma message("!! you are compiling the stubbed version of jsd_lock.c !!")
|
||||
#pragma message("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NOTE: 'Real' versions of these locks must be reentrant in the sense that
|
||||
* they support nested calls to lock and unlock.
|
||||
*/
|
||||
|
||||
void*
|
||||
jsd_CreateLock()
|
||||
{
|
||||
return (void*)1;
|
||||
}
|
||||
|
||||
void
|
||||
jsd_Lock(void* lock)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
jsd_Unlock(void* lock)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
JSBool
|
||||
jsd_IsLocked(void* lock)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
/*
|
||||
* This Windows only thread id code is here to allow the Java-based
|
||||
* JSDebugger to work with the single threaded js.c shell (even without
|
||||
* real locking and threading support).
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
/* bogus (but good enough) declaration*/
|
||||
extern void* __stdcall GetCurrentThreadId(void);
|
||||
#endif
|
||||
|
||||
void*
|
||||
jsd_CurrentThread()
|
||||
{
|
||||
#ifdef WIN32
|
||||
return GetCurrentThreadId();
|
||||
#else
|
||||
return (void*)1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* JSD_USE_NSPR_LOCKS */
|
||||
|
||||
#endif /* JSD_THREADSAFE */
|
||||
|
||||
@@ -17,22 +17,37 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* sinix.h
|
||||
* 5/18/96
|
||||
* Taken from nec.h by Christian.Kaiser@mch.sni.de
|
||||
* Header for JavaScript Debugging support - Locking and threading functions
|
||||
*/
|
||||
#ifndef nspr_sinix_defs_h___
|
||||
#define nspr_sinix_defs_h___
|
||||
|
||||
#undef HAVE_STACK_GROWING_UP
|
||||
#undef HAVE_LONG_LONG
|
||||
#undef HAVE_ALIGNED_DOUBLES
|
||||
#undef HAVE_ALIGNED_LONGLONGS
|
||||
#define HAVE_WEAK_IO_SYMBOLS
|
||||
#define HAVE_WEAK_MALLOC_SYMBOLS
|
||||
#define HAVE_DLL
|
||||
#define USE_DLFCN
|
||||
#ifndef jsd_lock_h___
|
||||
#define jsd_lock_h___
|
||||
|
||||
#define NEED_TIME_R
|
||||
/*
|
||||
* If you want to support threading and locking, define JSD_THREADSAFE and
|
||||
* implement the functions below.
|
||||
*/
|
||||
|
||||
#endif /* nspr_sinix_defs_h___ */
|
||||
/*
|
||||
* NOTE: These locks must be reentrant in the sense that they support
|
||||
* nested calls to lock and unlock.
|
||||
*/
|
||||
|
||||
extern void*
|
||||
jsd_CreateLock();
|
||||
|
||||
extern void
|
||||
jsd_Lock(void* lock);
|
||||
|
||||
extern void
|
||||
jsd_Unlock(void* lock);
|
||||
|
||||
#ifdef DEBUG
|
||||
extern JSBool
|
||||
jsd_IsLocked(void* lock);
|
||||
#endif /* DEBUG */
|
||||
|
||||
extern void*
|
||||
jsd_CurrentThread();
|
||||
|
||||
#endif /* jsd_lock_h___ */
|
||||
307
mozilla/js/jsd/jsd_obj.c
Normal file
307
mozilla/js/jsd/jsd_obj.c
Normal file
@@ -0,0 +1,307 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* JavaScript Debugging support - Object support
|
||||
*/
|
||||
|
||||
#include "jsd.h"
|
||||
|
||||
/*
|
||||
* #define JSD_TRACE 1
|
||||
*/
|
||||
|
||||
#ifdef JSD_TRACE
|
||||
#define TRACEOBJ(jsdc, jsdobj, which) _traceObj(jsdc, jsdobj, which)
|
||||
|
||||
static char *
|
||||
_describeObj(JSDContext* jsdc, JSDObject *jsdobj)
|
||||
{
|
||||
return
|
||||
JS_smprintf("%0x new'd in %s at line %d using ctor %s in %s at line %d",
|
||||
(int)jsdobj,
|
||||
JSD_GetObjectNewURL(jsdc, jsdobj),
|
||||
JSD_GetObjectNewLineNumber(jsdc, jsdobj),
|
||||
JSD_GetObjectConstructorName(jsdc, jsdobj),
|
||||
JSD_GetObjectConstructorURL(jsdc, jsdobj),
|
||||
JSD_GetObjectConstructorLineNumber(jsdc, jsdobj));
|
||||
}
|
||||
|
||||
static void
|
||||
_traceObj(JSDContext* jsdc, JSDObject* jsdobj, int which)
|
||||
{
|
||||
char* description;
|
||||
|
||||
if( !jsdobj )
|
||||
return;
|
||||
|
||||
description = _describeObj(jsdc, jsdobj);
|
||||
|
||||
printf("%s : %s\n",
|
||||
which == 0 ? "new " :
|
||||
which == 1 ? "final" :
|
||||
"ctor ",
|
||||
description);
|
||||
if(description)
|
||||
free(description);
|
||||
}
|
||||
#else
|
||||
#define TRACEOBJ(jsdc, jsdobj, which) ((void)0)
|
||||
#endif /* JSD_TRACE */
|
||||
|
||||
#ifdef DEBUG
|
||||
void JSD_ASSERT_VALID_OBJECT(JSDObject* jsdobj)
|
||||
{
|
||||
JS_ASSERT(jsdobj);
|
||||
JS_ASSERT(!JS_CLIST_IS_EMPTY(&jsdobj->links));
|
||||
JS_ASSERT(jsdobj->obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
_destroyJSDObject(JSDContext* jsdc, JSDObject* jsdobj)
|
||||
{
|
||||
JS_ASSERT(JSD_OBJECTS_LOCKED(jsdc));
|
||||
|
||||
JS_REMOVE_LINK(&jsdobj->links);
|
||||
JS_HashTableRemove(jsdc->objectsTable, jsdobj->obj);
|
||||
|
||||
if(jsdobj->newURL)
|
||||
jsd_DropAtom(jsdc, jsdobj->newURL);
|
||||
if(jsdobj->ctorURL)
|
||||
jsd_DropAtom(jsdc, jsdobj->ctorURL);
|
||||
if(jsdobj->ctorName)
|
||||
jsd_DropAtom(jsdc, jsdobj->ctorName);
|
||||
free(jsdobj);
|
||||
}
|
||||
|
||||
static JSDObject*
|
||||
_createJSDObject(JSDContext* jsdc, JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSDObject* jsdobj;
|
||||
JSStackFrame* fp;
|
||||
JSStackFrame* iter = NULL;
|
||||
const char* newURL;
|
||||
jsbytecode* pc;
|
||||
|
||||
JS_ASSERT(JSD_OBJECTS_LOCKED(jsdc));
|
||||
|
||||
jsdobj = (JSDObject*) calloc(1, sizeof(JSDObject));
|
||||
if( jsdobj )
|
||||
{
|
||||
JS_INIT_CLIST(&jsdobj->links);
|
||||
JS_APPEND_LINK(&jsdobj->links, &jsdc->objectsList);
|
||||
jsdobj->obj = obj;
|
||||
JS_HashTableAdd(jsdc->objectsTable, obj, jsdobj);
|
||||
|
||||
/* walk the stack to find js frame (if any) causing creation */
|
||||
while( NULL != (fp = JS_FrameIterator(cx, &iter)) )
|
||||
{
|
||||
if( !JS_IsNativeFrame(cx, fp) )
|
||||
{
|
||||
JSScript* script = JS_GetFrameScript(cx, fp);
|
||||
if( !script )
|
||||
continue;
|
||||
|
||||
newURL = JS_GetScriptFilename(cx, script);
|
||||
if( newURL )
|
||||
jsdobj->newURL = jsd_AddAtom(jsdc, newURL);
|
||||
|
||||
pc = JS_GetFramePC(cx, fp);
|
||||
if( pc )
|
||||
jsdobj->newLineno = JS_PCToLineNumber(cx, script, pc);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return jsdobj;
|
||||
}
|
||||
|
||||
void JS_DLL_CALLBACK
|
||||
jsd_ObjectHook(JSContext *cx, JSObject *obj, JSBool isNew, void *closure)
|
||||
{
|
||||
JSDObject* jsdobj;
|
||||
JSDContext* jsdc = (JSDContext*) closure;
|
||||
|
||||
if( ! jsdc || ! jsdc->inited )
|
||||
return;
|
||||
|
||||
JSD_LOCK_OBJECTS(jsdc);
|
||||
if(isNew)
|
||||
{
|
||||
jsdobj = _createJSDObject(jsdc, cx, obj);
|
||||
TRACEOBJ(jsdc, jsdobj, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
jsdobj = jsd_GetJSDObjectForJSObject(jsdc, obj);
|
||||
if( jsdobj )
|
||||
{
|
||||
TRACEOBJ(jsdc, jsdobj, 1);
|
||||
_destroyJSDObject(jsdc, jsdobj);
|
||||
}
|
||||
}
|
||||
JSD_UNLOCK_OBJECTS(jsdc);
|
||||
}
|
||||
|
||||
void
|
||||
jsd_Constructing(JSDContext* jsdc, JSContext *cx, JSObject *obj,
|
||||
JSStackFrame *fp)
|
||||
{
|
||||
JSDObject* jsdobj;
|
||||
JSScript* script;
|
||||
JSDScript* jsdscript;
|
||||
const char* ctorURL;
|
||||
const char* ctorName;
|
||||
|
||||
JSD_LOCK_OBJECTS(jsdc);
|
||||
jsdobj = jsd_GetJSDObjectForJSObject(jsdc, obj);
|
||||
if( jsdobj && !jsdobj->ctorURL && !JS_IsNativeFrame(cx, fp) )
|
||||
{
|
||||
script = JS_GetFrameScript(cx, fp);
|
||||
if( script )
|
||||
{
|
||||
ctorURL = JS_GetScriptFilename(cx, script);
|
||||
if( ctorURL )
|
||||
jsdobj->ctorURL = jsd_AddAtom(jsdc, ctorURL);
|
||||
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
jsdscript = jsd_FindJSDScript(jsdc, script);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
if( jsdscript )
|
||||
{
|
||||
ctorName = jsd_GetScriptFunctionName(jsdc, jsdscript);
|
||||
if( ctorName )
|
||||
jsdobj->ctorName = jsd_AddAtom(jsdc, ctorName);
|
||||
}
|
||||
jsdobj->ctorLineno = JS_GetScriptBaseLineNumber(cx, script);
|
||||
}
|
||||
}
|
||||
TRACEOBJ(jsdc, jsdobj, 3);
|
||||
JSD_UNLOCK_OBJECTS(jsdc);
|
||||
}
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(JSHashNumber)
|
||||
_hash_root(const void *key)
|
||||
{
|
||||
return ((JSHashNumber) key) >> 2; /* help lame MSVC1.5 on Win16 */
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_InitObjectManager(JSDContext* jsdc)
|
||||
{
|
||||
JS_INIT_CLIST(&jsdc->objectsList);
|
||||
jsdc->objectsTable = JS_NewHashTable(256, _hash_root,
|
||||
JS_CompareValues, JS_CompareValues,
|
||||
NULL, NULL);
|
||||
return (JSBool) jsdc->objectsTable;
|
||||
}
|
||||
|
||||
void
|
||||
jsd_DestroyObjectManager(JSDContext* jsdc)
|
||||
{
|
||||
JSD_LOCK_OBJECTS(jsdc);
|
||||
while( !JS_CLIST_IS_EMPTY(&jsdc->objectsList) )
|
||||
_destroyJSDObject(jsdc, (JSDObject*)JS_NEXT_LINK(&jsdc->objectsList));
|
||||
JS_HashTableDestroy(jsdc->objectsTable);
|
||||
JSD_UNLOCK_OBJECTS(jsdc);
|
||||
}
|
||||
|
||||
JSDObject*
|
||||
jsd_IterateObjects(JSDContext* jsdc, JSDObject** iterp)
|
||||
{
|
||||
JSDObject *jsdobj = *iterp;
|
||||
|
||||
JS_ASSERT(JSD_OBJECTS_LOCKED(jsdc));
|
||||
|
||||
if( !jsdobj )
|
||||
jsdobj = (JSDObject *)jsdc->objectsList.next;
|
||||
if( jsdobj == (JSDObject *)&jsdc->objectsList )
|
||||
return NULL;
|
||||
*iterp = (JSDObject*) jsdobj->links.next;
|
||||
return jsdobj;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
jsd_GetWrappedObject(JSDContext* jsdc, JSDObject* jsdobj)
|
||||
{
|
||||
return jsdobj->obj;
|
||||
}
|
||||
|
||||
const char*
|
||||
jsd_GetObjectNewURL(JSDContext* jsdc, JSDObject* jsdobj)
|
||||
{
|
||||
if( jsdobj->newURL )
|
||||
return JSD_ATOM_TO_STRING(jsdobj->newURL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uintN
|
||||
jsd_GetObjectNewLineNumber(JSDContext* jsdc, JSDObject* jsdobj)
|
||||
{
|
||||
return jsdobj->newLineno;
|
||||
}
|
||||
|
||||
const char*
|
||||
jsd_GetObjectConstructorURL(JSDContext* jsdc, JSDObject* jsdobj)
|
||||
{
|
||||
if( jsdobj->ctorURL )
|
||||
return JSD_ATOM_TO_STRING(jsdobj->ctorURL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uintN
|
||||
jsd_GetObjectConstructorLineNumber(JSDContext* jsdc, JSDObject* jsdobj)
|
||||
{
|
||||
return jsdobj->ctorLineno;
|
||||
}
|
||||
|
||||
const char*
|
||||
jsd_GetObjectConstructorName(JSDContext* jsdc, JSDObject* jsdobj)
|
||||
{
|
||||
if( jsdobj->ctorName )
|
||||
return JSD_ATOM_TO_STRING(jsdobj->ctorName);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSDObject*
|
||||
jsd_GetJSDObjectForJSObject(JSDContext* jsdc, JSObject* jsobj)
|
||||
{
|
||||
JSDObject* jsdobj;
|
||||
|
||||
JSD_LOCK_OBJECTS(jsdc);
|
||||
jsdobj = (JSDObject*) JS_HashTableLookup(jsdc->objectsTable, jsobj);
|
||||
JSD_UNLOCK_OBJECTS(jsdc);
|
||||
return jsdobj;
|
||||
}
|
||||
|
||||
JSDObject*
|
||||
jsd_GetObjectForValue(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
return jsd_GetJSDObjectForJSObject(jsdc, JSVAL_TO_OBJECT(jsdval->val));
|
||||
}
|
||||
|
||||
JSDValue*
|
||||
jsd_GetValueForObject(JSDContext* jsdc, JSDObject* jsdobj)
|
||||
{
|
||||
return jsd_NewValue(jsdc, OBJECT_TO_JSVAL(jsdobj->obj));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
@@ -17,17 +17,10 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
** JavaScript Debugger Navigator API - Script support
|
||||
*/
|
||||
* JavaScript Debugging support - Script support
|
||||
*/
|
||||
|
||||
#include "jsd.h"
|
||||
#ifdef NSPR20
|
||||
#ifdef XP_MAC
|
||||
#include "prpriv.h"
|
||||
#else
|
||||
#include "private/prpriv.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Comment this out to disable (NT specific) dumping as we go */
|
||||
/*
|
||||
@@ -39,75 +32,130 @@
|
||||
#define NOT_SET_YET -1
|
||||
|
||||
/***************************************************************************/
|
||||
PRCList jsd_script_list = PR_INIT_STATIC_CLIST(&jsd_script_list);
|
||||
|
||||
#ifdef DEBUG
|
||||
void JSD_ASSERT_VALID_SCRIPT( JSDScript* jsdscript )
|
||||
void JSD_ASSERT_VALID_SCRIPT(JSDScript* jsdscript)
|
||||
{
|
||||
PR_ASSERT( jsdscript );
|
||||
PR_ASSERT( jsdscript->script );
|
||||
JS_ASSERT(jsdscript);
|
||||
JS_ASSERT(jsdscript->script);
|
||||
}
|
||||
void JSD_ASSERT_VALID_EXEC_HOOK( JSDExecHook* jsdhook )
|
||||
void JSD_ASSERT_VALID_EXEC_HOOK(JSDExecHook* jsdhook)
|
||||
{
|
||||
PR_ASSERT( jsdhook );
|
||||
PR_ASSERT( jsdhook->hook );
|
||||
JS_ASSERT(jsdhook);
|
||||
JS_ASSERT(jsdhook->hook);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LIVEWIRE
|
||||
static JSBool
|
||||
HasFileExtention(const char* name, const char* ext)
|
||||
{
|
||||
int i;
|
||||
int len = strlen(ext);
|
||||
const char* p = strrchr(name,'.');
|
||||
if( !p )
|
||||
return JS_FALSE;
|
||||
p++;
|
||||
for(i = 0; i < len; i++ )
|
||||
{
|
||||
JS_ASSERT(islower(ext[i]));
|
||||
if( 0 == p[i] || tolower(p[i]) != ext[i] )
|
||||
return JS_FALSE;
|
||||
}
|
||||
if( 0 != p[i] )
|
||||
return JS_FALSE;
|
||||
return JS_TRUE;
|
||||
}
|
||||
#endif /* LIVEWIRE */
|
||||
|
||||
static JSDScript*
|
||||
NewJSDScript( JSDContext* jsdc,
|
||||
_newJSDScript(JSDContext* jsdc,
|
||||
JSContext *cx,
|
||||
JSScript *script,
|
||||
JSFunction* function )
|
||||
JSFunction* function)
|
||||
{
|
||||
JSDScript* jsdscript;
|
||||
PRUintn lineno;
|
||||
uintN lineno;
|
||||
const char* raw_filename;
|
||||
|
||||
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
|
||||
|
||||
/* these are inlined javascript: urls and we can't handle them now */
|
||||
lineno = (PRUintn) JS_GetScriptBaseLineNumber(cx, script);
|
||||
lineno = (uintN) JS_GetScriptBaseLineNumber(cx, script);
|
||||
if( lineno == 0 )
|
||||
return NULL;
|
||||
|
||||
jsdscript = PR_NEWZAP(JSDScript);
|
||||
jsdscript = (JSDScript*) calloc(1, sizeof(JSDScript));
|
||||
if( ! jsdscript )
|
||||
return NULL;
|
||||
|
||||
raw_filename = JS_GetScriptFilename(cx,script);
|
||||
|
||||
PR_APPEND_LINK(&jsdscript->links, &jsd_script_list);
|
||||
JS_APPEND_LINK(&jsdscript->links, &jsdc->scripts);
|
||||
jsdscript->jsdc = jsdc;
|
||||
jsdscript->script = script;
|
||||
jsdscript->function = function;
|
||||
jsdscript->lineBase = lineno;
|
||||
jsdscript->lineExtent = (PRUintn)NOT_SET_YET;
|
||||
jsdscript->url = (char*)jsd_BuildNormalizedURL(JS_GetScriptFilename(cx,script));
|
||||
jsdscript->lineExtent = (uintN)NOT_SET_YET;
|
||||
#ifndef LIVEWIRE
|
||||
jsdscript->url = (char*) jsd_BuildNormalizedURL(raw_filename);
|
||||
#else
|
||||
jsdscript->app = LWDBG_GetCurrentApp();
|
||||
if( jsdscript->app && raw_filename )
|
||||
{
|
||||
jsdscript->url = jsdlw_BuildAppRelativeFilename(jsdscript->app, raw_filename);
|
||||
if( function )
|
||||
{
|
||||
jsdscript->lwscript =
|
||||
LWDBG_GetScriptOfFunction(jsdscript->app,
|
||||
JS_GetFunctionName(function));
|
||||
|
||||
/* also, make sure this file is added to filelist if is .js file */
|
||||
if( HasFileExtention(raw_filename,"js") ||
|
||||
HasFileExtention(raw_filename,"sjs") )
|
||||
{
|
||||
jsdlw_PreLoadSource(jsdc, jsdscript->app, raw_filename, JS_FALSE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
jsdscript->lwscript = LWDBG_GetCurrentTopLevelScript();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
PR_INIT_CLIST(&jsdscript->hooks);
|
||||
JS_INIT_CLIST(&jsdscript->hooks);
|
||||
|
||||
return jsdscript;
|
||||
}
|
||||
|
||||
static void
|
||||
DestroyJSDScript( JSDContext* jsdc,
|
||||
JSDScript* jsdscript )
|
||||
_destroyJSDScript(JSDContext* jsdc,
|
||||
JSDScript* jsdscript)
|
||||
{
|
||||
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
|
||||
|
||||
/* destroy all hooks */
|
||||
jsd_ClearAllExecutionHooksForScript(jsdc, jsdscript);
|
||||
|
||||
PR_REMOVE_LINK(&jsdscript->links);
|
||||
PR_FREEIF(jsdscript->url);
|
||||
JS_REMOVE_LINK(&jsdscript->links);
|
||||
if(jsdscript->url)
|
||||
free(jsdscript->url);
|
||||
|
||||
PR_FREEIF(jsdscript);
|
||||
if(jsdscript)
|
||||
free(jsdscript);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifdef JSD_DUMP
|
||||
static void
|
||||
DumpJSDScript( JSDContext* jsdc, JSDScript* jsdscript, const char* leadingtext)
|
||||
_dumpJSDScript(JSDContext* jsdc, JSDScript* jsdscript, const char* leadingtext)
|
||||
{
|
||||
const char* name;
|
||||
const char* fun;
|
||||
PRUintn base;
|
||||
PRUintn extent;
|
||||
uintN base;
|
||||
uintN extent;
|
||||
char Buf[256];
|
||||
|
||||
name = jsd_GetScriptFilename(jsdc, jsdscript);
|
||||
@@ -125,54 +173,32 @@ DumpJSDScript( JSDContext* jsdc, JSDScript* jsdscript, const char* leadingtext)
|
||||
}
|
||||
|
||||
static void
|
||||
DumpJSDScriptList( JSDContext* jsdc )
|
||||
_dumpJSDScriptList( JSDContext* jsdc )
|
||||
{
|
||||
JSDScript* iterp = NULL;
|
||||
JSDScript* jsdscript = NULL;
|
||||
|
||||
OutputDebugString( "*** JSDScriptDump\n" );
|
||||
while( NULL != (jsdscript = jsd_IterateScripts(jsdc, &iterp)) )
|
||||
DumpJSDScript( jsdc, jsdscript, " script: " );
|
||||
_dumpJSDScript( jsdc, jsdscript, " script: " );
|
||||
}
|
||||
#endif /* JSD_DUMP */
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifndef JSD_SIMULATION
|
||||
static PRMonitor *jsd_script_mon = NULL;
|
||||
#endif /* JSD_SIMULATION */
|
||||
|
||||
void
|
||||
jsd_LockScriptSubsystem(JSDContext* jsdc)
|
||||
{
|
||||
#ifndef JSD_SIMULATION
|
||||
if (jsd_script_mon == NULL)
|
||||
jsd_script_mon = PR_NewNamedMonitor("jsd-script-monitor");
|
||||
|
||||
PR_EnterMonitor(jsd_script_mon);
|
||||
#endif /* JSD_SIMULATION */
|
||||
}
|
||||
|
||||
void
|
||||
jsd_UnlockScriptSubsystem(JSDContext* jsdc)
|
||||
{
|
||||
#ifndef JSD_SIMULATION
|
||||
PR_ExitMonitor(jsd_script_mon);
|
||||
#endif /* JSD_SIMULATION */
|
||||
}
|
||||
|
||||
void
|
||||
jsd_DestroyAllJSDScripts( JSDContext* jsdc )
|
||||
{
|
||||
JSDScript *jsdscript;
|
||||
JSDScript *next;
|
||||
|
||||
for (jsdscript = (JSDScript*)jsd_script_list.next;
|
||||
jsdscript != (JSDScript*)&jsd_script_list;
|
||||
jsdscript = next)
|
||||
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
|
||||
|
||||
for( jsdscript = (JSDScript*)jsdc->scripts.next;
|
||||
jsdscript != (JSDScript*)&jsdc->scripts;
|
||||
jsdscript = next )
|
||||
{
|
||||
next = (JSDScript*)jsdscript->links.next;
|
||||
DestroyJSDScript( jsdc, jsdscript );
|
||||
_destroyJSDScript( jsdc, jsdscript );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,9 +208,12 @@ jsd_FindJSDScript( JSDContext* jsdc,
|
||||
{
|
||||
JSDScript *jsdscript;
|
||||
|
||||
for (jsdscript = (JSDScript *)jsd_script_list.next;
|
||||
jsdscript != (JSDScript *)&jsd_script_list;
|
||||
jsdscript = (JSDScript *)jsdscript->links.next) {
|
||||
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
|
||||
|
||||
for( jsdscript = (JSDScript *)jsdc->scripts.next;
|
||||
jsdscript != (JSDScript *)&jsdc->scripts;
|
||||
jsdscript = (JSDScript *)jsdscript->links.next )
|
||||
{
|
||||
if (jsdscript->script == script)
|
||||
return jsdscript;
|
||||
}
|
||||
@@ -196,14 +225,33 @@ jsd_IterateScripts(JSDContext* jsdc, JSDScript **iterp)
|
||||
{
|
||||
JSDScript *jsdscript = *iterp;
|
||||
|
||||
if (!jsdscript)
|
||||
jsdscript = (JSDScript *)jsd_script_list.next;
|
||||
if (jsdscript == (JSDScript *)&jsd_script_list)
|
||||
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
|
||||
|
||||
if( !jsdscript )
|
||||
jsdscript = (JSDScript *)jsdc->scripts.next;
|
||||
if( jsdscript == (JSDScript *)&jsdc->scripts )
|
||||
return NULL;
|
||||
*iterp = (JSDScript *)jsdscript->links.next;
|
||||
*iterp = (JSDScript*) jsdscript->links.next;
|
||||
return jsdscript;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_IsActiveScript(JSDContext* jsdc, JSDScript *jsdscript)
|
||||
{
|
||||
JSDScript *current;
|
||||
|
||||
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
|
||||
|
||||
for( current = (JSDScript *)jsdc->scripts.next;
|
||||
current != (JSDScript *)&jsdc->scripts;
|
||||
current = (JSDScript *)current->links.next )
|
||||
{
|
||||
if(jsdscript == current)
|
||||
return JS_TRUE;
|
||||
}
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
const char*
|
||||
jsd_GetScriptFilename(JSDContext* jsdc, JSDScript *jsdscript)
|
||||
{
|
||||
@@ -218,13 +266,13 @@ jsd_GetScriptFunctionName(JSDContext* jsdc, JSDScript *jsdscript)
|
||||
return JS_GetFunctionName(jsdscript->function);
|
||||
}
|
||||
|
||||
PRUintn
|
||||
uintN
|
||||
jsd_GetScriptBaseLineNumber(JSDContext* jsdc, JSDScript *jsdscript)
|
||||
{
|
||||
return jsdscript->lineBase;
|
||||
}
|
||||
|
||||
PRUintn
|
||||
uintN
|
||||
jsd_GetScriptLineExtent(JSDContext* jsdc, JSDScript *jsdscript)
|
||||
{
|
||||
if( NOT_SET_YET == jsdscript->lineExtent )
|
||||
@@ -232,88 +280,120 @@ jsd_GetScriptLineExtent(JSDContext* jsdc, JSDScript *jsdscript)
|
||||
return jsdscript->lineExtent;
|
||||
}
|
||||
|
||||
prword_t
|
||||
jsd_GetClosestPC(JSDContext* jsdc, JSDScript* jsdscript, PRUintn line)
|
||||
jsuword
|
||||
jsd_GetClosestPC(JSDContext* jsdc, JSDScript* jsdscript, uintN line)
|
||||
{
|
||||
return (prword_t) JS_LineNumberToPC(jsdc->dumbContext,
|
||||
#ifdef LIVEWIRE
|
||||
if( jsdscript && jsdscript->lwscript )
|
||||
{
|
||||
uintN newline;
|
||||
jsdlw_RawToProcessedLineNumber(jsdc, jsdscript, line, &newline);
|
||||
if( line != newline )
|
||||
line = newline;
|
||||
}
|
||||
#endif
|
||||
|
||||
return (jsuword) JS_LineNumberToPC(jsdc->dumbContext,
|
||||
jsdscript->script, line );
|
||||
}
|
||||
|
||||
PRUintn
|
||||
jsd_GetClosestLine(JSDContext* jsdc, JSDScript* jsdscript, prword_t pc)
|
||||
uintN
|
||||
jsd_GetClosestLine(JSDContext* jsdc, JSDScript* jsdscript, jsuword pc)
|
||||
{
|
||||
PRUintn first = jsdscript->lineBase;
|
||||
PRUintn last = first + jsd_GetScriptLineExtent(jsdc, jsdscript) - 1;
|
||||
PRUintn line = JS_PCToLineNumber(jsdc->dumbContext,
|
||||
uintN first = jsdscript->lineBase;
|
||||
uintN last = first + jsd_GetScriptLineExtent(jsdc, jsdscript) - 1;
|
||||
uintN line = JS_PCToLineNumber(jsdc->dumbContext,
|
||||
jsdscript->script, (jsbytecode*)pc);
|
||||
|
||||
if( line < first )
|
||||
return first;
|
||||
if( line > last )
|
||||
return last;
|
||||
|
||||
#ifdef LIVEWIRE
|
||||
if( jsdscript && jsdscript->lwscript )
|
||||
{
|
||||
uintN newline;
|
||||
jsdlw_ProcessedToRawLineNumber(jsdc, jsdscript, line, &newline);
|
||||
line = newline;
|
||||
}
|
||||
#endif
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
JSD_ScriptHookProc
|
||||
JSBool
|
||||
jsd_SetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc hook, void* callerdata)
|
||||
{
|
||||
JSD_ScriptHookProc oldHook = jsdc->scriptHook;
|
||||
JSD_LOCK();
|
||||
jsdc->scriptHook = hook;
|
||||
jsdc->scriptHookData = callerdata;
|
||||
return oldHook;
|
||||
JSD_UNLOCK();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSD_ScriptHookProc
|
||||
jsd_GetScriptHook(JSDContext* jsdc)
|
||||
JSBool
|
||||
jsd_GetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc* hook, void** callerdata)
|
||||
{
|
||||
return jsdc->scriptHook;
|
||||
}
|
||||
JSD_LOCK();
|
||||
if( hook )
|
||||
*hook = jsdc->scriptHook;
|
||||
if( callerdata )
|
||||
*callerdata = jsdc->scriptHookData;
|
||||
JSD_UNLOCK();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
void PR_CALLBACK
|
||||
void JS_DLL_CALLBACK
|
||||
jsd_NewScriptHookProc(
|
||||
JSContext *cx,
|
||||
const char *filename, /* URL this script loads from */
|
||||
PRUintn lineno, /* line where this script starts */
|
||||
uintN lineno, /* line where this script starts */
|
||||
JSScript *script,
|
||||
JSFunction *fun,
|
||||
void* callerdata )
|
||||
{
|
||||
JSDScript* jsdscript = NULL;
|
||||
JSDContext* jsdc = (JSDContext*) callerdata;
|
||||
|
||||
if( jsd_IsCurrentThreadDangerous() )
|
||||
return;
|
||||
JSD_ScriptHookProc hook;
|
||||
void* hookData;
|
||||
|
||||
JSD_ASSERT_VALID_CONTEXT(jsdc);
|
||||
|
||||
jsd_LockScriptSubsystem(jsdc);
|
||||
|
||||
jsd_JSContextUsed(jsdc, cx);
|
||||
|
||||
jsdscript = NewJSDScript( jsdc, cx, script, fun );
|
||||
if( ! jsdscript )
|
||||
{
|
||||
jsd_UnlockScriptSubsystem(jsdc);
|
||||
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef LIVEWIRE
|
||||
if( 1 == lineno )
|
||||
jsdlw_PreLoadSource(jsdc, LWDBG_GetCurrentApp(), filename, JS_TRUE );
|
||||
#endif
|
||||
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
jsdscript = _newJSDScript(jsdc, cx, script, fun);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
if( ! jsdscript )
|
||||
return;
|
||||
|
||||
#ifdef JSD_DUMP
|
||||
if( jsdscript )
|
||||
{
|
||||
DumpJSDScript( jsdc, jsdscript, "***NEW Script: " );
|
||||
DumpJSDScriptList( jsdc );
|
||||
}
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
_dumpJSDScript(jsdc, jsdscript, "***NEW Script: ");
|
||||
_dumpJSDScriptList( jsdc );
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
#endif /* JSD_DUMP */
|
||||
|
||||
if( jsdc->scriptHook )
|
||||
jsdc->scriptHook( jsdc, jsdscript, TRUE, jsdc->scriptHookData );
|
||||
|
||||
jsd_UnlockScriptSubsystem(jsdc);
|
||||
/* local in case jsdc->scriptHook gets cleared on another thread */
|
||||
JSD_LOCK();
|
||||
hook = jsdc->scriptHook;
|
||||
hookData = jsdc->scriptHookData;
|
||||
JSD_UNLOCK();
|
||||
|
||||
if( hook )
|
||||
hook(jsdc, jsdscript, JS_TRUE, hookData);
|
||||
}
|
||||
|
||||
void PR_CALLBACK
|
||||
void JS_DLL_CALLBACK
|
||||
jsd_DestroyScriptHookProc(
|
||||
JSContext *cx,
|
||||
JSScript *script,
|
||||
@@ -321,51 +401,59 @@ jsd_DestroyScriptHookProc(
|
||||
{
|
||||
JSDScript* jsdscript = NULL;
|
||||
JSDContext* jsdc = (JSDContext*) callerdata;
|
||||
JSD_ScriptHookProc hook;
|
||||
void* hookData;
|
||||
|
||||
if( jsd_IsCurrentThreadDangerous() )
|
||||
return;
|
||||
|
||||
JSD_ASSERT_VALID_CONTEXT(jsdc);
|
||||
|
||||
jsd_LockScriptSubsystem(jsdc);
|
||||
|
||||
jsd_JSContextUsed(jsdc, cx);
|
||||
|
||||
jsdscript = jsd_FindJSDScript( jsdc, script );
|
||||
if( ! jsdscript )
|
||||
{
|
||||
jsd_UnlockScriptSubsystem(jsdc);
|
||||
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef JSD_DUMP
|
||||
DumpJSDScript( jsdc, jsdscript, "***DESTROY Script: " );
|
||||
#endif /* JSD_DUMP */
|
||||
|
||||
if( jsdc->scriptHook )
|
||||
jsdc->scriptHook( jsdc, jsdscript, FALSE, jsdc->scriptHookData );
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
jsdscript = jsd_FindJSDScript(jsdc, script);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
|
||||
if( ! jsdscript )
|
||||
return;
|
||||
|
||||
DestroyJSDScript( jsdc, jsdscript );
|
||||
|
||||
#ifdef JSD_DUMP
|
||||
DumpJSDScriptList( jsdc );
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
_dumpJSDScript(jsdc, jsdscript, "***DESTROY Script: ");
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
#endif /* JSD_DUMP */
|
||||
|
||||
jsd_UnlockScriptSubsystem(jsdc);
|
||||
/* local in case hook gets cleared on another thread */
|
||||
JSD_LOCK();
|
||||
hook = jsdc->scriptHook;
|
||||
hookData = jsdc->scriptHookData;
|
||||
JSD_UNLOCK();
|
||||
|
||||
if( hook )
|
||||
hook(jsdc, jsdscript, JS_FALSE, hookData);
|
||||
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
_destroyJSDScript(jsdc, jsdscript);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
|
||||
#ifdef JSD_DUMP
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
_dumpJSDScriptList(jsdc);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
#endif /* JSD_DUMP */
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
static JSDExecHook*
|
||||
FindHook( JSDContext* jsdc, JSDScript* jsdscript, prword_t pc)
|
||||
_findHook(JSDContext* jsdc, JSDScript* jsdscript, jsuword pc)
|
||||
{
|
||||
JSDExecHook* jsdhook;
|
||||
PRCList* list = &jsdscript->hooks;
|
||||
JSCList* list = &jsdscript->hooks;
|
||||
|
||||
for (jsdhook = (JSDExecHook*)list->next;
|
||||
for( jsdhook = (JSDExecHook*)list->next;
|
||||
jsdhook != (JSDExecHook*)list;
|
||||
jsdhook = (JSDExecHook*)jsdhook->links.next)
|
||||
jsdhook = (JSDExecHook*)jsdhook->links.next )
|
||||
{
|
||||
if (jsdhook->pc == pc)
|
||||
return jsdhook;
|
||||
@@ -373,45 +461,82 @@ FindHook( JSDContext* jsdc, JSDScript* jsdscript, prword_t pc)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSTrapStatus PR_CALLBACK
|
||||
static JSBool
|
||||
_isActiveHook(JSDContext* jsdc, JSScript *script, JSDExecHook* jsdhook)
|
||||
{
|
||||
JSDExecHook* current;
|
||||
JSCList* list;
|
||||
JSDScript* jsdscript;
|
||||
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
jsdscript = jsd_FindJSDScript(jsdc, script);
|
||||
if( ! jsdscript)
|
||||
{
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
list = &jsdscript->hooks;
|
||||
|
||||
for( current = (JSDExecHook*)list->next;
|
||||
current != (JSDExecHook*)list;
|
||||
current = (JSDExecHook*)current->links.next )
|
||||
{
|
||||
if(current == jsdhook)
|
||||
{
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
return JS_TRUE;
|
||||
}
|
||||
}
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
JSTrapStatus JS_DLL_CALLBACK
|
||||
jsd_TrapHandler(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
|
||||
void *closure)
|
||||
{
|
||||
PRUintn hookanswer = JSD_HOOK_RETURN_CONTINUE;
|
||||
JSDThreadState* jsdthreadstate;
|
||||
JSDExecHook* jsdhook = (JSDExecHook*) closure;
|
||||
JSD_ExecutionHookProc hook;
|
||||
void* hookData;
|
||||
JSDContext* jsdc;
|
||||
JSDScript* jsdscript;
|
||||
|
||||
if( jsd_IsCurrentThreadDangerous() )
|
||||
JSD_LOCK();
|
||||
|
||||
if( NULL == (jsdc = jsd_JSDContextForJSContext(cx)) ||
|
||||
! _isActiveHook(jsdc, script, jsdhook) )
|
||||
{
|
||||
JSD_UNLOCK();
|
||||
return JSTRAP_CONTINUE;
|
||||
}
|
||||
|
||||
JSD_ASSERT_VALID_EXEC_HOOK(jsdhook);
|
||||
PR_ASSERT(jsdhook->pc == (prword_t)pc);
|
||||
PR_ASSERT(jsdhook->jsdscript->script == script);
|
||||
JS_ASSERT(jsdhook->pc == (jsuword)pc);
|
||||
JS_ASSERT(jsdhook->jsdscript->script == script);
|
||||
JS_ASSERT(jsdhook->jsdscript->jsdc == jsdc);
|
||||
|
||||
hook = jsdhook->hook;
|
||||
hookData = jsdhook->callerdata;
|
||||
jsdscript = jsdhook->jsdscript;
|
||||
|
||||
/* do not use jsdhook-> after this point */
|
||||
JSD_UNLOCK();
|
||||
|
||||
jsdc = jsdhook->jsdscript->jsdc;
|
||||
if( ! jsdc || ! jsdc->inited )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
jsd_JSContextUsed(jsdc, cx);
|
||||
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
jsdthreadstate = jsd_NewThreadState(jsdc,cx);
|
||||
if( jsdthreadstate )
|
||||
{
|
||||
hookanswer =
|
||||
(*jsdhook->hook)(jsdc, jsdthreadstate,
|
||||
JSD_HOOK_BREAKPOINT,
|
||||
jsdhook->callerdata );
|
||||
#ifdef LIVEWIRE
|
||||
if( ! jsdlw_UserCodeAtPC(jsdc, jsdscript, (jsuword)pc) )
|
||||
return JSTRAP_CONTINUE;
|
||||
#endif
|
||||
|
||||
jsd_DestroyThreadState(jsdc, jsdthreadstate);
|
||||
}
|
||||
|
||||
*rval = NULL; /* XXX fix this!!! */
|
||||
|
||||
if( JSD_HOOK_RETURN_ABORT == hookanswer )
|
||||
return JSTRAP_ERROR;
|
||||
|
||||
return JSTRAP_CONTINUE; /* XXX fix this!!! */
|
||||
return jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_BREAKPOINT,
|
||||
hook, hookData, rval);
|
||||
}
|
||||
|
||||
|
||||
@@ -419,16 +544,21 @@ jsd_TrapHandler(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
|
||||
JSBool
|
||||
jsd_SetExecutionHook(JSDContext* jsdc,
|
||||
JSDScript* jsdscript,
|
||||
prword_t pc,
|
||||
jsuword pc,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* callerdata)
|
||||
{
|
||||
JSDExecHook* jsdhook;
|
||||
|
||||
JSD_LOCK();
|
||||
if( ! hook )
|
||||
return jsd_ClearExecutionHook(jsdc, jsdscript, pc);
|
||||
{
|
||||
jsd_ClearExecutionHook(jsdc, jsdscript, pc);
|
||||
JSD_UNLOCK();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
jsdhook = FindHook(jsdc, jsdscript, pc);
|
||||
jsdhook = _findHook(jsdc, jsdscript, pc);
|
||||
if( jsdhook )
|
||||
{
|
||||
jsdhook->hook = hook;
|
||||
@@ -437,7 +567,7 @@ jsd_SetExecutionHook(JSDContext* jsdc,
|
||||
}
|
||||
/* else... */
|
||||
|
||||
jsdhook = PR_NEWZAP(JSDExecHook);
|
||||
jsdhook = (JSDExecHook*)calloc(1, sizeof(JSDExecHook));
|
||||
if( ! jsdhook )
|
||||
return JS_FALSE;
|
||||
jsdhook->jsdscript = jsdscript;
|
||||
@@ -448,34 +578,40 @@ jsd_SetExecutionHook(JSDContext* jsdc,
|
||||
if( ! JS_SetTrap(jsdc->dumbContext, jsdscript->script,
|
||||
(jsbytecode*)pc, jsd_TrapHandler, (void*) jsdhook) )
|
||||
{
|
||||
PR_FREEIF(jsdhook);
|
||||
free(jsdhook);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
PR_APPEND_LINK(&jsdhook->links, &jsdscript->hooks);
|
||||
JS_APPEND_LINK(&jsdhook->links, &jsdscript->hooks);
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_ClearExecutionHook(JSDContext* jsdc,
|
||||
JSDScript* jsdscript,
|
||||
prword_t pc)
|
||||
jsuword pc)
|
||||
{
|
||||
JSDExecHook* jsdhook;
|
||||
|
||||
jsdhook = FindHook(jsdc, jsdscript, pc);
|
||||
JSD_LOCK();
|
||||
|
||||
jsdhook = _findHook(jsdc, jsdscript, pc);
|
||||
if( ! jsdhook )
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
JS_ASSERT(0);
|
||||
JSD_UNLOCK();
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JS_ClearTrap(jsdc->dumbContext, jsdscript->script,
|
||||
(jsbytecode*)pc, NULL, NULL );
|
||||
|
||||
PR_REMOVE_LINK(&jsdhook->links);
|
||||
PR_FREEIF(jsdhook);
|
||||
JS_REMOVE_LINK(&jsdhook->links);
|
||||
free(jsdhook);
|
||||
|
||||
JSD_UNLOCK();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@@ -483,15 +619,19 @@ JSBool
|
||||
jsd_ClearAllExecutionHooksForScript(JSDContext* jsdc, JSDScript* jsdscript)
|
||||
{
|
||||
JSDExecHook* jsdhook;
|
||||
PRCList* list = &jsdscript->hooks;
|
||||
JSCList* list = &jsdscript->hooks;
|
||||
|
||||
JSD_LOCK();
|
||||
|
||||
while( (JSDExecHook*)list != (jsdhook = (JSDExecHook*)list->next) )
|
||||
{
|
||||
PR_REMOVE_LINK(&jsdhook->links);
|
||||
PR_FREEIF(jsdhook);
|
||||
JS_REMOVE_LINK(&jsdhook->links);
|
||||
free(jsdhook);
|
||||
}
|
||||
|
||||
JS_ClearScriptTraps(jsdc->dumbContext, jsdscript->script);
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@@ -501,8 +641,28 @@ jsd_ClearAllExecutionHooks(JSDContext* jsdc)
|
||||
JSDScript* jsdscript;
|
||||
JSDScript* iterp = NULL;
|
||||
|
||||
JSD_LOCK();
|
||||
while( NULL != (jsdscript = jsd_IterateScripts(jsdc, &iterp)) )
|
||||
jsd_ClearAllExecutionHooksForScript(jsdc, jsdscript);
|
||||
JSD_UNLOCK();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
jsd_ScriptCreated(JSDContext* jsdc,
|
||||
JSContext *cx,
|
||||
const char *filename, /* URL this script loads from */
|
||||
uintN lineno, /* line where this script starts */
|
||||
JSScript *script,
|
||||
JSFunction *fun)
|
||||
{
|
||||
jsd_NewScriptHookProc(cx, filename, lineno, script, fun, jsdc);
|
||||
}
|
||||
|
||||
void
|
||||
jsd_ScriptDestroyed(JSDContext* jsdc,
|
||||
JSContext *cx,
|
||||
JSScript *script)
|
||||
{
|
||||
jsd_DestroyScriptHookProc(cx, script, jsdc);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
@@ -17,71 +17,63 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
** JavaScript Debugger Navigator API - Call Stack support
|
||||
*/
|
||||
* JavaScript Debugging support - Call stack support
|
||||
*/
|
||||
|
||||
#include "jsd.h"
|
||||
#ifdef NSPR20
|
||||
#ifdef XP_MAC
|
||||
#include "prpriv.h"
|
||||
#else
|
||||
#include "private/prpriv.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
void JSD_ASSERT_VALID_THREAD_STATE( JSDThreadState* jsdthreadstate )
|
||||
void JSD_ASSERT_VALID_THREAD_STATE(JSDThreadState* jsdthreadstate)
|
||||
{
|
||||
PR_ASSERT(jsdthreadstate);
|
||||
PR_ASSERT(jsdthreadstate->stackDepth > 0);
|
||||
JS_ASSERT(jsdthreadstate);
|
||||
JS_ASSERT(jsdthreadstate->stackDepth > 0);
|
||||
}
|
||||
|
||||
void JSD_ASSERT_VALID_STACK_FRAME( JSDStackFrameInfo* jsdframe )
|
||||
void JSD_ASSERT_VALID_STACK_FRAME(JSDStackFrameInfo* jsdframe)
|
||||
{
|
||||
PR_ASSERT(jsdframe);
|
||||
PR_ASSERT(jsdframe->jsdthreadstate);
|
||||
JS_ASSERT(jsdframe);
|
||||
JS_ASSERT(jsdframe->jsdthreadstate);
|
||||
}
|
||||
#endif
|
||||
|
||||
static JSDStackFrameInfo*
|
||||
AddNewFrame( JSDContext* jsdc,
|
||||
_addNewFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSScript* script,
|
||||
prword_t pc,
|
||||
JSObject* object,
|
||||
JSObject* thisp,
|
||||
JSStackFrame* fp )
|
||||
jsuword pc,
|
||||
JSStackFrame* fp)
|
||||
{
|
||||
JSDStackFrameInfo* jsdframe;
|
||||
JSDScript* jsdscript;
|
||||
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
jsdscript = jsd_FindJSDScript(jsdc, script);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
if( ! jsdscript )
|
||||
return NULL;
|
||||
|
||||
jsdframe = PR_NEWZAP(JSDStackFrameInfo);
|
||||
jsdframe = (JSDStackFrameInfo*) calloc(1, sizeof(JSDStackFrameInfo));
|
||||
if( ! jsdframe )
|
||||
return NULL;
|
||||
|
||||
jsdframe->jsdthreadstate = jsdthreadstate;
|
||||
jsdframe->jsdscript = jsdscript ;
|
||||
jsdframe->pc = pc ;
|
||||
jsdframe->object = object ;
|
||||
jsdframe->thisp = thisp ;
|
||||
jsdframe->fp = fp ;
|
||||
|
||||
PR_APPEND_LINK(&jsdframe->links, &jsdthreadstate->stack);
|
||||
JS_APPEND_LINK(&jsdframe->links, &jsdthreadstate->stack);
|
||||
jsdthreadstate->stackDepth++;
|
||||
|
||||
return jsdframe;
|
||||
}
|
||||
|
||||
static void
|
||||
DestroyFrame(JSDStackFrameInfo* jsdframe)
|
||||
_destroyFrame(JSDStackFrameInfo* jsdframe)
|
||||
{
|
||||
/* kill any alloc'd objects in frame here... */
|
||||
|
||||
PR_FREEIF(jsdframe);
|
||||
if( jsdframe )
|
||||
free(jsdframe);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,31 +84,36 @@ jsd_NewThreadState(JSDContext* jsdc, JSContext *cx )
|
||||
JSStackFrame * iter = NULL;
|
||||
JSStackFrame * fp;
|
||||
|
||||
jsdthreadstate = PR_NEWZAP(JSDThreadState);
|
||||
jsdthreadstate = (JSDThreadState*)calloc(1, sizeof(JSDThreadState));
|
||||
if( ! jsdthreadstate )
|
||||
return NULL;
|
||||
|
||||
jsdthreadstate->context = cx;
|
||||
jsdthreadstate->thread = PR_CurrentThread();
|
||||
PR_INIT_CLIST(&jsdthreadstate->stack);
|
||||
jsdthreadstate->thread = JSD_CURRENT_THREAD();
|
||||
JS_INIT_CLIST(&jsdthreadstate->stack);
|
||||
jsdthreadstate->stackDepth = 0;
|
||||
|
||||
while( NULL != (fp = JS_FrameIterator(cx, &iter)) )
|
||||
{
|
||||
JSScript* script = JS_GetFrameScript(cx, fp);
|
||||
prword_t pc = (prword_t) JS_GetFramePC(cx, fp);
|
||||
jsuword pc = (jsuword) JS_GetFramePC(cx, fp);
|
||||
|
||||
if( ! script || ! pc || JS_IsNativeFrame(cx, fp) )
|
||||
continue;
|
||||
|
||||
AddNewFrame( jsdc, jsdthreadstate, script, pc,
|
||||
JS_GetFrameObject(cx, fp),
|
||||
JS_GetFrameThis(cx, fp), fp );
|
||||
_addNewFrame( jsdc, jsdthreadstate, script, pc, fp );
|
||||
}
|
||||
|
||||
/* if there is no stack, then this threadstate can not be constructed */
|
||||
if( 0 == jsdthreadstate->stackDepth )
|
||||
{
|
||||
free(jsdthreadstate);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jsd_LockThreadsStates(jsdc);
|
||||
PR_APPEND_LINK(&jsdthreadstate->links, &jsdc->threadsStates);
|
||||
jsd_UnlockThreadStates(jsdc);
|
||||
JSD_LOCK_THREADSTATES(jsdc);
|
||||
JS_APPEND_LINK(&jsdthreadstate->links, &jsdc->threadsStates);
|
||||
JSD_UNLOCK_THREADSTATES(jsdc);
|
||||
|
||||
return jsdthreadstate;
|
||||
}
|
||||
@@ -125,50 +122,35 @@ void
|
||||
jsd_DestroyThreadState(JSDContext* jsdc, JSDThreadState* jsdthreadstate)
|
||||
{
|
||||
JSDStackFrameInfo* jsdframe;
|
||||
PRCList* list;
|
||||
int64 i;
|
||||
JSCList* list;
|
||||
|
||||
#ifndef NSPR20
|
||||
LL_I2L(i,100);
|
||||
#endif
|
||||
|
||||
/* we need to wait if someone else is using the threadstate */
|
||||
|
||||
jsd_LockThreadsStates(jsdc);
|
||||
while( jsdthreadstate->wait )
|
||||
{
|
||||
jsd_UnlockThreadStates(jsdc);
|
||||
#ifndef NSPR20
|
||||
PR_Sleep(i);
|
||||
#else
|
||||
PR_Sleep(PR_MicrosecondsToInterval(100));
|
||||
#endif
|
||||
jsd_LockThreadsStates(jsdc);
|
||||
}
|
||||
PR_REMOVE_LINK(&jsdthreadstate->links);
|
||||
jsd_UnlockThreadStates(jsdc);
|
||||
JSD_ASSERT_VALID_THREAD_STATE(jsdthreadstate);
|
||||
JS_ASSERT(JSD_CURRENT_THREAD() == jsdthreadstate->thread);
|
||||
|
||||
JSD_LOCK_THREADSTATES(jsdc);
|
||||
JS_REMOVE_LINK(&jsdthreadstate->links);
|
||||
JSD_UNLOCK_THREADSTATES(jsdc);
|
||||
|
||||
list = &jsdthreadstate->stack;
|
||||
while( (JSDStackFrameInfo*)list != (jsdframe = (JSDStackFrameInfo*)list->next) )
|
||||
{
|
||||
PR_REMOVE_LINK(&jsdframe->links);
|
||||
DestroyFrame(jsdframe);
|
||||
JS_REMOVE_LINK(&jsdframe->links);
|
||||
_destroyFrame(jsdframe);
|
||||
}
|
||||
PR_FREEIF(jsdthreadstate);
|
||||
free(jsdthreadstate);
|
||||
}
|
||||
|
||||
PRUintn
|
||||
uintN
|
||||
jsd_GetCountOfStackFrames(JSDContext* jsdc, JSDThreadState* jsdthreadstate)
|
||||
{
|
||||
PRUintn count = 0;
|
||||
uintN count = 0;
|
||||
|
||||
jsd_LockThreadsStates(jsdc);
|
||||
JSD_LOCK_THREADSTATES(jsdc);
|
||||
|
||||
if( jsd_IsValidThreadState(jsdc, jsdthreadstate) )
|
||||
count = jsdthreadstate->stackDepth;
|
||||
|
||||
jsd_UnlockThreadStates(jsdc);
|
||||
JSD_UNLOCK_THREADSTATES(jsdc);
|
||||
|
||||
return count;
|
||||
}
|
||||
@@ -178,12 +160,11 @@ jsd_GetStackFrame(JSDContext* jsdc, JSDThreadState* jsdthreadstate)
|
||||
{
|
||||
JSDStackFrameInfo* jsdframe = NULL;
|
||||
|
||||
jsd_LockThreadsStates(jsdc);
|
||||
JSD_LOCK_THREADSTATES(jsdc);
|
||||
|
||||
if( jsd_IsValidThreadState(jsdc, jsdthreadstate) )
|
||||
jsdframe = (JSDStackFrameInfo*) PR_LIST_HEAD(&jsdthreadstate->stack);
|
||||
|
||||
jsd_UnlockThreadStates(jsdc);
|
||||
jsdframe = (JSDStackFrameInfo*) JS_LIST_HEAD(&jsdthreadstate->stack);
|
||||
JSD_UNLOCK_THREADSTATES(jsdc);
|
||||
|
||||
return jsdframe;
|
||||
}
|
||||
@@ -195,13 +176,13 @@ jsd_GetCallingStackFrame(JSDContext* jsdc,
|
||||
{
|
||||
JSDStackFrameInfo* nextjsdframe = NULL;
|
||||
|
||||
jsd_LockThreadsStates(jsdc);
|
||||
JSD_LOCK_THREADSTATES(jsdc);
|
||||
|
||||
if( jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
|
||||
if( PR_LIST_HEAD(&jsdframe->links) != &jsdframe->jsdthreadstate->stack )
|
||||
nextjsdframe = (JSDStackFrameInfo*) PR_LIST_HEAD(&jsdframe->links);
|
||||
if( JS_LIST_HEAD(&jsdframe->links) != &jsdframe->jsdthreadstate->stack )
|
||||
nextjsdframe = (JSDStackFrameInfo*) JS_LIST_HEAD(&jsdframe->links);
|
||||
|
||||
jsd_UnlockThreadStates(jsdc);
|
||||
JSD_UNLOCK_THREADSTATES(jsdc);
|
||||
|
||||
return nextjsdframe;
|
||||
}
|
||||
@@ -213,58 +194,130 @@ jsd_GetScriptForStackFrame(JSDContext* jsdc,
|
||||
{
|
||||
JSDScript* jsdscript = NULL;
|
||||
|
||||
jsd_LockThreadsStates(jsdc);
|
||||
JSD_LOCK_THREADSTATES(jsdc);
|
||||
|
||||
if( jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
|
||||
jsdscript = jsdframe->jsdscript;
|
||||
|
||||
jsd_UnlockThreadStates(jsdc);
|
||||
JSD_UNLOCK_THREADSTATES(jsdc);
|
||||
|
||||
return jsdscript;
|
||||
}
|
||||
|
||||
prword_t
|
||||
jsuword
|
||||
jsd_GetPCForStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe)
|
||||
{
|
||||
prword_t pc = 0;
|
||||
jsuword pc = 0;
|
||||
|
||||
jsd_LockThreadsStates(jsdc);
|
||||
JSD_LOCK_THREADSTATES(jsdc);
|
||||
|
||||
if( jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
|
||||
pc = jsdframe->pc;
|
||||
|
||||
jsd_UnlockThreadStates(jsdc);
|
||||
JSD_UNLOCK_THREADSTATES(jsdc);
|
||||
|
||||
return pc;
|
||||
}
|
||||
|
||||
JSDValue*
|
||||
jsd_GetCallObjectForStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe)
|
||||
{
|
||||
JSObject* obj;
|
||||
JSDValue* jsdval = NULL;
|
||||
|
||||
JSD_LOCK_THREADSTATES(jsdc);
|
||||
|
||||
if( jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
|
||||
{
|
||||
obj = JS_GetFrameCallObject(jsdthreadstate->context, jsdframe->fp);
|
||||
if(obj)
|
||||
jsdval = JSD_NewValue(jsdc, OBJECT_TO_JSVAL(obj));
|
||||
}
|
||||
|
||||
JSD_UNLOCK_THREADSTATES(jsdc);
|
||||
|
||||
return jsdval;
|
||||
}
|
||||
|
||||
JSDValue*
|
||||
jsd_GetScopeChainForStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe)
|
||||
{
|
||||
JSObject* obj;
|
||||
JSDValue* jsdval = NULL;
|
||||
|
||||
JSD_LOCK_THREADSTATES(jsdc);
|
||||
|
||||
if( jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
|
||||
{
|
||||
obj = JS_GetFrameScopeChain(jsdthreadstate->context, jsdframe->fp);
|
||||
if(obj)
|
||||
jsdval = JSD_NewValue(jsdc, OBJECT_TO_JSVAL(obj));
|
||||
}
|
||||
|
||||
JSD_UNLOCK_THREADSTATES(jsdc);
|
||||
|
||||
return jsdval;
|
||||
}
|
||||
|
||||
JSDValue*
|
||||
jsd_GetThisForStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe)
|
||||
{
|
||||
JSObject* obj;
|
||||
JSDValue* jsdval = NULL;
|
||||
|
||||
JSD_LOCK_THREADSTATES(jsdc);
|
||||
|
||||
if( jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
|
||||
{
|
||||
obj = JS_GetFrameThis(jsdthreadstate->context, jsdframe->fp);
|
||||
if(obj)
|
||||
jsdval = JSD_NewValue(jsdc, OBJECT_TO_JSVAL(obj));
|
||||
}
|
||||
|
||||
JSD_UNLOCK_THREADSTATES(jsdc);
|
||||
|
||||
return jsdval;
|
||||
}
|
||||
|
||||
|
||||
JSBool
|
||||
jsd_EvaluateScriptInStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe,
|
||||
const char *bytes, PRUintn length,
|
||||
const char *filename, PRUintn lineno, jsval *rval)
|
||||
const char *bytes, uintN length,
|
||||
const char *filename, uintN lineno, jsval *rval)
|
||||
{
|
||||
JSBool retval;
|
||||
JSBool valid;
|
||||
JSExceptionState* exceptionState;
|
||||
JSContext* cx;
|
||||
|
||||
jsd_LockThreadsStates(jsdc);
|
||||
JS_ASSERT(JSD_CURRENT_THREAD() == jsdthreadstate->thread);
|
||||
|
||||
if( ! jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
|
||||
{
|
||||
jsd_UnlockThreadStates(jsdc);
|
||||
JSD_LOCK_THREADSTATES(jsdc);
|
||||
valid = jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe);
|
||||
JSD_UNLOCK_THREADSTATES(jsdc);
|
||||
|
||||
if( ! valid )
|
||||
return JS_FALSE;
|
||||
}
|
||||
jsdthreadstate->wait++ ;
|
||||
jsd_UnlockThreadStates(jsdc);
|
||||
|
||||
retval = JS_EvaluateInStackFrame(jsdthreadstate->context, jsdframe->fp,
|
||||
bytes, length, filename, lineno, rval);
|
||||
cx = jsdthreadstate->context;
|
||||
JS_ASSERT(cx);
|
||||
|
||||
jsd_LockThreadsStates(jsdc);
|
||||
jsdthreadstate->wait-- ;
|
||||
jsd_UnlockThreadStates(jsdc);
|
||||
exceptionState = JS_SaveExceptionState(cx);
|
||||
jsd_StartingEvalUsingFilename(jsdc, filename);
|
||||
retval = JS_EvaluateInStackFrame(cx, jsdframe->fp, bytes, length,
|
||||
filename, lineno, rval);
|
||||
jsd_FinishedEvalUsingFilename(jsdc, filename);
|
||||
JS_RestoreExceptionState(cx, exceptionState);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -275,72 +328,37 @@ jsd_ValToStringInStackFrame(JSDContext* jsdc,
|
||||
JSDStackFrameInfo* jsdframe,
|
||||
jsval val)
|
||||
{
|
||||
JSString* jsstr = NULL;
|
||||
JSBool valid;
|
||||
JSString* retval;
|
||||
JSExceptionState* exceptionState;
|
||||
JSContext* cx;
|
||||
|
||||
jsd_LockThreadsStates(jsdc);
|
||||
JSD_LOCK_THREADSTATES(jsdc);
|
||||
valid = jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe);
|
||||
JSD_UNLOCK_THREADSTATES(jsdc);
|
||||
|
||||
if( ! jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
|
||||
{
|
||||
jsd_UnlockThreadStates(jsdc);
|
||||
if( ! valid )
|
||||
return NULL;
|
||||
}
|
||||
jsdthreadstate->wait++ ;
|
||||
jsd_UnlockThreadStates(jsdc);
|
||||
|
||||
jsstr = JS_ValueToString(jsdthreadstate->context, val);
|
||||
cx = jsdthreadstate->context;
|
||||
JS_ASSERT(cx);
|
||||
|
||||
jsd_LockThreadsStates(jsdc);
|
||||
jsdthreadstate->wait-- ;
|
||||
jsd_UnlockThreadStates(jsdc);
|
||||
exceptionState = JS_SaveExceptionState(cx);
|
||||
retval = JS_ValueToString(cx, val);
|
||||
JS_RestoreExceptionState(cx, exceptionState);
|
||||
|
||||
return jsstr;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifndef JSD_SIMULATION
|
||||
static PRMonitor *jsd_threadstate_mon = NULL;
|
||||
#endif /* JSD_SIMULATION */
|
||||
|
||||
void
|
||||
jsd_LockThreadsStates(JSDContext* jsdc)
|
||||
{
|
||||
#ifndef JSD_SIMULATION
|
||||
if (jsd_threadstate_mon == NULL)
|
||||
jsd_threadstate_mon = PR_NewNamedMonitor("jsd-threadstate-monitor");
|
||||
|
||||
PR_EnterMonitor(jsd_threadstate_mon);
|
||||
#endif /* JSD_SIMULATION */
|
||||
}
|
||||
|
||||
void
|
||||
jsd_UnlockThreadStates(JSDContext* jsdc)
|
||||
{
|
||||
#ifndef JSD_SIMULATION
|
||||
PR_ExitMonitor(jsd_threadstate_mon);
|
||||
#endif /* JSD_SIMULATION */
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_ThreadStatesIsLocked(JSDContext* jsdc)
|
||||
{
|
||||
#ifndef JSD_SIMULATION
|
||||
return jsd_threadstate_mon && PR_InMonitor(jsd_threadstate_mon);
|
||||
#else
|
||||
return JS_TRUE;
|
||||
#endif /* JSD_SIMULATION */
|
||||
return retval;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_IsValidThreadState(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate )
|
||||
JSDThreadState* jsdthreadstate)
|
||||
{
|
||||
JSDThreadState *cur;
|
||||
|
||||
PR_ASSERT( jsd_ThreadStatesIsLocked(jsdc) );
|
||||
JS_ASSERT( JSD_THREADSTATES_LOCKED(jsdc) );
|
||||
|
||||
for (cur = (JSDThreadState*)jsdc->threadsStates.next;
|
||||
for( cur = (JSDThreadState*)jsdc->threadsStates.next;
|
||||
cur != (JSDThreadState*)&jsdc->threadsStates;
|
||||
cur = (JSDThreadState*)cur->links.next )
|
||||
{
|
||||
@@ -353,9 +371,9 @@ jsd_IsValidThreadState(JSDContext* jsdc,
|
||||
JSBool
|
||||
jsd_IsValidFrameInThreadState(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe )
|
||||
JSDStackFrameInfo* jsdframe)
|
||||
{
|
||||
PR_ASSERT( jsd_ThreadStatesIsLocked(jsdc) );
|
||||
JS_ASSERT(JSD_THREADSTATES_LOCKED(jsdc));
|
||||
|
||||
if( ! jsd_IsValidThreadState(jsdc, jsdthreadstate) )
|
||||
return JS_FALSE;
|
||||
@@ -367,3 +385,45 @@ jsd_IsValidFrameInThreadState(JSDContext* jsdc,
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSContext*
|
||||
_getContextForThreadState(JSDContext* jsdc, JSDThreadState* jsdthreadstate)
|
||||
{
|
||||
JSBool valid;
|
||||
JSD_LOCK_THREADSTATES(jsdc);
|
||||
valid = jsd_IsValidThreadState(jsdc, jsdthreadstate);
|
||||
JSD_UNLOCK_THREADSTATES(jsdc);
|
||||
if( valid )
|
||||
return jsdthreadstate->context;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSDValue*
|
||||
jsd_GetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate)
|
||||
{
|
||||
JSContext* cx;
|
||||
jsval val;
|
||||
|
||||
if(!(cx = _getContextForThreadState(jsdc, jsdthreadstate)))
|
||||
return NULL;
|
||||
|
||||
if(JS_GetPendingException(cx, &val))
|
||||
return jsd_NewValue(jsdc, val);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_SetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate,
|
||||
JSDValue* jsdval)
|
||||
{
|
||||
JSContext* cx;
|
||||
|
||||
if(!(cx = _getContextForThreadState(jsdc, jsdthreadstate)))
|
||||
return JS_FALSE;
|
||||
|
||||
if(jsdval)
|
||||
JS_SetPendingException(cx, JSD_GetValueWrappedJSVal(jsdc, jsdval));
|
||||
else
|
||||
JS_ClearPendingException(cx);
|
||||
return JS_TRUE;
|
||||
}
|
||||
116
mozilla/js/jsd/jsd_step.c
Normal file
116
mozilla/js/jsd/jsd_step.c
Normal file
@@ -0,0 +1,116 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* JavaScript Debugging support - Stepping support
|
||||
*/
|
||||
|
||||
#include "jsd.h"
|
||||
|
||||
/*
|
||||
* #define JSD_TRACE 1
|
||||
*/
|
||||
|
||||
#ifdef JSD_TRACE
|
||||
|
||||
static char*
|
||||
_indentSpaces(int i)
|
||||
{
|
||||
#define MAX_INDENT 63
|
||||
static char* p = NULL;
|
||||
if(!p)
|
||||
{
|
||||
p = calloc(1, MAX_INDENT+1);
|
||||
if(!p) return "";
|
||||
memset(p, ' ', MAX_INDENT);
|
||||
}
|
||||
if(i > MAX_INDENT) return p;
|
||||
return p + MAX_INDENT-i;
|
||||
}
|
||||
|
||||
static void
|
||||
_interpreterTrace(JSDContext* jsdc, JSContext *cx, JSStackFrame *fp,
|
||||
JSBool before, JSBool *ok)
|
||||
{
|
||||
JSDScript* jsdscript = NULL;
|
||||
JSScript * script;
|
||||
static indent = 0;
|
||||
char* buf;
|
||||
const char* funName = NULL;
|
||||
|
||||
script = JS_GetFrameScript(cx, fp);
|
||||
if(script)
|
||||
{
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
jsdscript = jsd_FindJSDScript(jsdc, script);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
if(jsdscript)
|
||||
funName = JSD_GetScriptFunctionName(jsdc, jsdscript);
|
||||
}
|
||||
if(!funName)
|
||||
funName = "TOP_LEVEL";
|
||||
|
||||
if(before)
|
||||
{
|
||||
buf = JS_smprintf("%sentering %s %s this: %0x\n",
|
||||
_indentSpaces(indent++),
|
||||
funName,
|
||||
JS_IsContructorFrame(cx, fp) ? "constructing":"",
|
||||
(int)JS_GetFrameThis(cx, fp));
|
||||
}
|
||||
else
|
||||
{
|
||||
buf = JS_smprintf("%sleaving %s\n",
|
||||
_indentSpaces(--indent),
|
||||
funName);
|
||||
}
|
||||
JS_ASSERT(indent >= 0);
|
||||
|
||||
if(!buf)
|
||||
return;
|
||||
|
||||
printf(buf);
|
||||
free(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
void * JS_DLL_CALLBACK
|
||||
jsd_InterpreterHook(JSContext *cx, JSStackFrame *fp, JSBool before,
|
||||
JSBool *ok, void *closure)
|
||||
{
|
||||
JSDContext* jsdc = (JSDContext*) closure;
|
||||
|
||||
if( ! jsdc || ! jsdc->inited )
|
||||
return NULL;
|
||||
|
||||
if(before && JS_IsContructorFrame(cx, fp))
|
||||
jsd_Constructing(jsdc, cx, JS_GetFrameThis(cx, fp), fp);
|
||||
|
||||
#ifdef JSD_TRACE
|
||||
_interpreterTrace(jsdc, cx, fp, before, ok);
|
||||
return closure;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
/*
|
||||
* use this before calling any hook...
|
||||
* if( JSD_IS_DANGEROUS_THREAD(jsdc) )
|
||||
* return NULL;
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
@@ -17,182 +17,149 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
** JavaScript Debugger Navigator API - Source Text functions
|
||||
*/
|
||||
* JavaScript Debugging support - Source Text functions
|
||||
*/
|
||||
|
||||
#include "jsd.h"
|
||||
#ifdef NSPR20
|
||||
#ifdef XP_MAC
|
||||
#include "prpriv.h"
|
||||
#else
|
||||
#include "private/prpriv.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* XXX convert this and jsd_conv so that all accumulation of text done here
|
||||
* Also, use handle oriented alloc for Win16 64k limit problem
|
||||
*/
|
||||
|
||||
PRCList jsd_source_list = PR_INIT_STATIC_CLIST(&jsd_source_list);
|
||||
PRCList jsd_removed_source_list = PR_INIT_STATIC_CLIST(&jsd_removed_source_list);
|
||||
|
||||
/***************************************************************************/
|
||||
/*
|
||||
* typedef enum
|
||||
* {
|
||||
* JSD_SOURCE_INITED,
|
||||
* JSD_SOURCE_PARTIAL,
|
||||
* JSD_SOURCE_COMPLETED,
|
||||
* JSD_SOURCE_ABORTED,
|
||||
* JSD_SOURCE_FAILED
|
||||
*
|
||||
* } JSDSourceStatus;
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
void JSD_ASSERT_VALID_SOURCE_TEXT( JSDSourceText* jsdsrc )
|
||||
void JSD_ASSERT_VALID_SOURCE_TEXT(JSDSourceText* jsdsrc)
|
||||
{
|
||||
PR_ASSERT( jsdsrc );
|
||||
PR_ASSERT( jsdsrc->url );
|
||||
JS_ASSERT(jsdsrc);
|
||||
JS_ASSERT(jsdsrc->url);
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* XXX add serial number instead of dirty */
|
||||
/* XXX add notification */
|
||||
|
||||
static PRUintn g_alterCount = 1;
|
||||
|
||||
|
||||
static void
|
||||
ClearText( JSDContext* jsdc, JSDSourceText* jsdsrc )
|
||||
_clearText(JSDContext* jsdc, JSDSourceText* jsdsrc)
|
||||
{
|
||||
if( jsdsrc->text )
|
||||
MY_XP_HUGE_FREE(jsdsrc->text);
|
||||
free(jsdsrc->text);
|
||||
jsdsrc->text = NULL;
|
||||
jsdsrc->textLength = 0;
|
||||
jsdsrc->textSpace = 0;
|
||||
jsdsrc->status = JSD_SOURCE_CLEARED;
|
||||
jsdsrc->dirty = JS_TRUE;
|
||||
jsdsrc->alterCount = g_alterCount++ ;
|
||||
jsdsrc->alterCount = jsdc->sourceAlterCount++ ;
|
||||
jsdsrc->doingEval = JS_FALSE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
AppendText( JSDContext* jsdc, JSDSourceText* jsdsrc,
|
||||
const char* text, size_t length )
|
||||
_appendText(JSDContext* jsdc, JSDSourceText* jsdsrc,
|
||||
const char* text, size_t length)
|
||||
{
|
||||
#define MEMBUF_GROW 1000
|
||||
|
||||
PRUintn neededSize = jsdsrc->textLength + length;
|
||||
uintN neededSize = jsdsrc->textLength + length;
|
||||
|
||||
if( neededSize > jsdsrc->textSpace )
|
||||
{
|
||||
MY_XP_HUGE_CHAR_PTR pBuf;
|
||||
PRUintn iNewSize;
|
||||
char* newBuf;
|
||||
uintN iNewSize;
|
||||
|
||||
/* if this is the first alloc, the req might be all that's needed*/
|
||||
if( ! jsdsrc->textSpace )
|
||||
iNewSize = length;
|
||||
iNewSize = length;
|
||||
else
|
||||
iNewSize = (neededSize * 5 / 4) + MEMBUF_GROW;
|
||||
iNewSize = (neededSize * 5 / 4) + MEMBUF_GROW;
|
||||
|
||||
pBuf = (MY_XP_HUGE_CHAR_PTR) MY_XP_HUGE_ALLOC(iNewSize);
|
||||
if( pBuf )
|
||||
newBuf = (char*) realloc(jsdsrc->text, iNewSize);
|
||||
if( ! newBuf )
|
||||
{
|
||||
if( jsdsrc->text )
|
||||
/* try again with the minimal size really asked for */
|
||||
iNewSize = neededSize;
|
||||
newBuf = (char*) realloc(jsdsrc->text, iNewSize);
|
||||
if( ! newBuf )
|
||||
{
|
||||
MY_XP_HUGE_MEMCPY(pBuf, jsdsrc->text, jsdsrc->textLength);
|
||||
MY_XP_HUGE_FREE(jsdsrc->text);
|
||||
/* out of memory */
|
||||
_clearText( jsdc, jsdsrc );
|
||||
jsdsrc->status = JSD_SOURCE_FAILED;
|
||||
return JS_FALSE;
|
||||
}
|
||||
jsdsrc->text = pBuf;
|
||||
jsdsrc->textSpace = iNewSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* LTNOTE: throw an out of memory exception */
|
||||
ClearText( jsdc, jsdsrc );
|
||||
jsdsrc->status = JSD_SOURCE_FAILED;
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
jsdsrc->text = newBuf;
|
||||
jsdsrc->textSpace = iNewSize;
|
||||
}
|
||||
|
||||
MY_XP_HUGE_MEMCPY( &jsdsrc->text[jsdsrc->textLength], text, length );
|
||||
memcpy(jsdsrc->text + jsdsrc->textLength, text, length);
|
||||
jsdsrc->textLength += length;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSDSourceText*
|
||||
NewSource( JSDContext* jsdc, const char* url )
|
||||
_newSource(JSDContext* jsdc, const char* url)
|
||||
{
|
||||
JSDSourceText* jsdsrc = PR_NEWZAP(JSDSourceText);
|
||||
JSDSourceText* jsdsrc = (JSDSourceText*)calloc(1,sizeof(JSDSourceText));
|
||||
if( ! jsdsrc )
|
||||
return NULL;
|
||||
|
||||
jsdsrc->url = (char*) url; /* already a copy */
|
||||
jsdsrc->status = JSD_SOURCE_INITED;
|
||||
jsdsrc->dirty = JS_TRUE;
|
||||
jsdsrc->alterCount = g_alterCount++ ;
|
||||
jsdsrc->url = (char*) url; /* already a copy */
|
||||
jsdsrc->status = JSD_SOURCE_INITED;
|
||||
jsdsrc->dirty = JS_TRUE;
|
||||
jsdsrc->alterCount = jsdc->sourceAlterCount++ ;
|
||||
|
||||
return jsdsrc;
|
||||
}
|
||||
|
||||
static void
|
||||
DestroySource( JSDContext* jsdc, JSDSourceText* jsdsrc )
|
||||
_destroySource(JSDContext* jsdc, JSDSourceText* jsdsrc)
|
||||
{
|
||||
PR_ASSERT( NULL == jsdsrc->text ); /* must ClearText() first */
|
||||
MY_XP_FREE(jsdsrc->url);
|
||||
MY_XP_FREE(jsdsrc);
|
||||
JS_ASSERT(NULL == jsdsrc->text); /* must _clearText() first */
|
||||
free(jsdsrc->url);
|
||||
free(jsdsrc);
|
||||
}
|
||||
|
||||
static void
|
||||
RemoveSource( JSDContext* jsdc, JSDSourceText* jsdsrc )
|
||||
_removeSource(JSDContext* jsdc, JSDSourceText* jsdsrc)
|
||||
{
|
||||
PR_REMOVE_LINK(&jsdsrc->links);
|
||||
ClearText( jsdc, jsdsrc );
|
||||
DestroySource( jsdc, jsdsrc );
|
||||
JS_REMOVE_LINK(&jsdsrc->links);
|
||||
_clearText(jsdc, jsdsrc);
|
||||
_destroySource(jsdc, jsdsrc);
|
||||
}
|
||||
|
||||
static JSDSourceText*
|
||||
AddSource( JSDContext* jsdc, const char* url )
|
||||
_addSource(JSDContext* jsdc, const char* url)
|
||||
{
|
||||
JSDSourceText* jsdsrc = NewSource( jsdc, url );
|
||||
JSDSourceText* jsdsrc = _newSource(jsdc, url);
|
||||
if( ! jsdsrc )
|
||||
return NULL;
|
||||
PR_INSERT_LINK(&jsdsrc->links, &jsd_source_list);
|
||||
JS_INSERT_LINK(&jsdsrc->links, &jsdc->sources);
|
||||
return jsdsrc;
|
||||
}
|
||||
|
||||
static void
|
||||
MoveSourceToFront( JSDContext* jsdc, JSDSourceText* jsdsrc )
|
||||
_moveSourceToFront(JSDContext* jsdc, JSDSourceText* jsdsrc)
|
||||
{
|
||||
PR_REMOVE_LINK(&jsdsrc->links);
|
||||
PR_INSERT_LINK(&jsdsrc->links, &jsd_source_list);
|
||||
JS_REMOVE_LINK(&jsdsrc->links);
|
||||
JS_INSERT_LINK(&jsdsrc->links, &jsdc->sources);
|
||||
}
|
||||
|
||||
static void
|
||||
MoveSourceToRemovedList( JSDContext* jsdc, JSDSourceText* jsdsrc )
|
||||
_moveSourceToRemovedList(JSDContext* jsdc, JSDSourceText* jsdsrc)
|
||||
{
|
||||
ClearText(jsdc, jsdsrc);
|
||||
PR_REMOVE_LINK(&jsdsrc->links);
|
||||
PR_INSERT_LINK(&jsdsrc->links, &jsd_removed_source_list);
|
||||
_clearText(jsdc, jsdsrc);
|
||||
JS_REMOVE_LINK(&jsdsrc->links);
|
||||
JS_INSERT_LINK(&jsdsrc->links, &jsdc->removedSources);
|
||||
}
|
||||
|
||||
static void
|
||||
RemoveSourceFromRemovedList( JSDContext* jsdc, JSDSourceText* jsdsrc )
|
||||
_removeSourceFromRemovedList( JSDContext* jsdc, JSDSourceText* jsdsrc )
|
||||
{
|
||||
PR_REMOVE_LINK(&jsdsrc->links);
|
||||
DestroySource( jsdc, jsdsrc );
|
||||
JS_REMOVE_LINK(&jsdsrc->links);
|
||||
_destroySource( jsdc, jsdsrc );
|
||||
}
|
||||
|
||||
static JSBool
|
||||
IsSourceInSourceList( JSDContext* jsdc, JSDSourceText* jsdsrcToFind )
|
||||
_isSourceInSourceList(JSDContext* jsdc, JSDSourceText* jsdsrcToFind)
|
||||
{
|
||||
JSDSourceText *jsdsrc;
|
||||
|
||||
for (jsdsrc = (JSDSourceText*)jsd_source_list.next;
|
||||
jsdsrc != (JSDSourceText*)&jsd_source_list;
|
||||
for( jsdsrc = (JSDSourceText*)jsdc->sources.next;
|
||||
jsdsrc != (JSDSourceText*)&jsdc->sources;
|
||||
jsdsrc = (JSDSourceText*)jsdsrc->links.next )
|
||||
{
|
||||
if( jsdsrc == jsdsrcToFind )
|
||||
@@ -201,26 +168,26 @@ IsSourceInSourceList( JSDContext* jsdc, JSDSourceText* jsdsrcToFind )
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
/* compare strings in a case insensitive manner with a length limit
|
||||
/* compare strings in a case insensitive manner with a length limit
|
||||
*/
|
||||
|
||||
static int
|
||||
strncasecomp (const char* one, const char * two, int n)
|
||||
{
|
||||
const char *pA;
|
||||
const char *pB;
|
||||
|
||||
for(pA=one, pB=two;; pA++, pB++)
|
||||
{
|
||||
int tmp;
|
||||
if (pA == one+n)
|
||||
return 0;
|
||||
if (!(*pA && *pB))
|
||||
return *pA - *pB;
|
||||
tmp = MY_XP_TO_LOWER(*pA) - MY_XP_TO_LOWER(*pB);
|
||||
if (tmp)
|
||||
return tmp;
|
||||
}
|
||||
const char *pA;
|
||||
const char *pB;
|
||||
|
||||
for(pA=one, pB=two;; pA++, pB++)
|
||||
{
|
||||
int tmp;
|
||||
if (pA == one+n)
|
||||
return 0;
|
||||
if (!(*pA && *pB))
|
||||
return *pA - *pB;
|
||||
tmp = tolower(*pA) - tolower(*pB);
|
||||
if (tmp)
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
|
||||
static char file_url_prefix[] = "file:";
|
||||
@@ -234,63 +201,40 @@ jsd_BuildNormalizedURL( const char* url_string )
|
||||
if( ! url_string )
|
||||
return NULL;
|
||||
|
||||
if (!MY_XP_STRNCASECMP(url_string, file_url_prefix, FILE_URL_PREFIX_LEN) &&
|
||||
if (!strncasecomp(url_string, file_url_prefix, FILE_URL_PREFIX_LEN) &&
|
||||
url_string[FILE_URL_PREFIX_LEN + 0] == '/' &&
|
||||
url_string[FILE_URL_PREFIX_LEN + 1] == '/') {
|
||||
new_url_string = PR_smprintf("%s%s",
|
||||
new_url_string = JS_smprintf("%s%s",
|
||||
file_url_prefix,
|
||||
url_string + FILE_URL_PREFIX_LEN + 2);
|
||||
} else {
|
||||
new_url_string = MY_XP_STRDUP(url_string);
|
||||
new_url_string = strdup(url_string);
|
||||
}
|
||||
return new_url_string;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifndef JSD_SIMULATION
|
||||
static PRMonitor *jsd_text_mon = NULL;
|
||||
#endif /* JSD_SIMULATION */
|
||||
|
||||
void
|
||||
jsd_LockSourceTextSubsystem(JSDContext* jsdc)
|
||||
{
|
||||
#ifndef JSD_SIMULATION
|
||||
if (jsd_text_mon == NULL)
|
||||
jsd_text_mon = PR_NewNamedMonitor("jsd-text-monitor");
|
||||
|
||||
PR_EnterMonitor(jsd_text_mon);
|
||||
#endif /* JSD_SIMULATION */
|
||||
}
|
||||
|
||||
void
|
||||
jsd_UnlockSourceTextSubsystem(JSDContext* jsdc)
|
||||
{
|
||||
#ifndef JSD_SIMULATION
|
||||
PR_ExitMonitor(jsd_text_mon);
|
||||
#endif /* JSD_SIMULATION */
|
||||
}
|
||||
|
||||
void
|
||||
jsd_DestroyAllSources( JSDContext* jsdc )
|
||||
{
|
||||
JSDSourceText *jsdsrc;
|
||||
JSDSourceText *next;
|
||||
|
||||
for (jsdsrc = (JSDSourceText*)jsd_source_list.next;
|
||||
jsdsrc != (JSDSourceText*)&jsd_source_list;
|
||||
jsdsrc = next)
|
||||
for( jsdsrc = (JSDSourceText*)jsdc->sources.next;
|
||||
jsdsrc != (JSDSourceText*)&jsdc->sources;
|
||||
jsdsrc = next )
|
||||
{
|
||||
next = (JSDSourceText*)jsdsrc->links.next;
|
||||
RemoveSource( jsdc, jsdsrc );
|
||||
_removeSource( jsdc, jsdsrc );
|
||||
}
|
||||
|
||||
for (jsdsrc = (JSDSourceText*)jsd_removed_source_list.next;
|
||||
jsdsrc != (JSDSourceText*)&jsd_removed_source_list;
|
||||
jsdsrc = next)
|
||||
for( jsdsrc = (JSDSourceText*)jsdc->removedSources.next;
|
||||
jsdsrc != (JSDSourceText*)&jsdc->removedSources;
|
||||
jsdsrc = next )
|
||||
{
|
||||
next = (JSDSourceText*)jsdsrc->links.next;
|
||||
RemoveSourceFromRemovedList( jsdc, jsdsrc );
|
||||
_removeSourceFromRemovedList( jsdc, jsdsrc );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -300,9 +244,9 @@ jsd_IterateSources(JSDContext* jsdc, JSDSourceText **iterp)
|
||||
{
|
||||
JSDSourceText *jsdsrc = *iterp;
|
||||
|
||||
if (!jsdsrc)
|
||||
jsdsrc = (JSDSourceText *)jsd_source_list.next;
|
||||
if (jsdsrc == (JSDSourceText *)&jsd_source_list)
|
||||
if( !jsdsrc )
|
||||
jsdsrc = (JSDSourceText *)jsdc->sources.next;
|
||||
if( jsdsrc == (JSDSourceText *)&jsdc->sources )
|
||||
return NULL;
|
||||
*iterp = (JSDSourceText *)jsdsrc->links.next;
|
||||
return jsdsrc;
|
||||
@@ -313,10 +257,11 @@ jsd_FindSourceForURL(JSDContext* jsdc, const char* url)
|
||||
{
|
||||
JSDSourceText *jsdsrc;
|
||||
|
||||
for (jsdsrc = (JSDSourceText *)jsd_source_list.next;
|
||||
jsdsrc != (JSDSourceText *)&jsd_source_list;
|
||||
jsdsrc = (JSDSourceText *)jsdsrc->links.next) {
|
||||
if (0 == strcmp(jsdsrc->url, url))
|
||||
for( jsdsrc = (JSDSourceText *)jsdc->sources.next;
|
||||
jsdsrc != (JSDSourceText *)&jsdc->sources;
|
||||
jsdsrc = (JSDSourceText *)jsdsrc->links.next )
|
||||
{
|
||||
if( 0 == strcmp(jsdsrc->url, url) )
|
||||
return jsdsrc;
|
||||
}
|
||||
return NULL;
|
||||
@@ -330,7 +275,7 @@ jsd_GetSourceURL(JSDContext* jsdc, JSDSourceText* jsdsrc)
|
||||
|
||||
JSBool
|
||||
jsd_GetSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc,
|
||||
const char** ppBuf, int* pLen )
|
||||
const char** ppBuf, intN* pLen )
|
||||
{
|
||||
*ppBuf = jsdsrc->text;
|
||||
*pLen = jsdsrc->textLength;
|
||||
@@ -343,7 +288,7 @@ jsd_ClearSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc)
|
||||
if( JSD_SOURCE_INITED != jsdsrc->status &&
|
||||
JSD_SOURCE_PARTIAL != jsdsrc->status )
|
||||
{
|
||||
ClearText(jsdc, jsdsrc);
|
||||
_clearText(jsdc, jsdsrc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,16 +310,16 @@ jsd_SetSourceDirty(JSDContext* jsdc, JSDSourceText* jsdsrc, JSBool dirty)
|
||||
jsdsrc->dirty = dirty;
|
||||
}
|
||||
|
||||
PRUintn
|
||||
uintN
|
||||
jsd_GetSourceAlterCount(JSDContext* jsdc, JSDSourceText* jsdsrc)
|
||||
{
|
||||
return jsdsrc->alterCount;
|
||||
}
|
||||
|
||||
PRUintn
|
||||
uintN
|
||||
jsd_IncrementSourceAlterCount(JSDContext* jsdc, JSDSourceText* jsdsrc)
|
||||
{
|
||||
return ++jsdsrc->alterCount;
|
||||
return jsdsrc->alterCount = jsdc->sourceAlterCount++;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
@@ -415,20 +360,35 @@ jsd_NewSourceText(JSDContext* jsdc, const char* url)
|
||||
JSDSourceText* jsdsrc;
|
||||
const char* new_url_string;
|
||||
|
||||
jsd_LockSourceTextSubsystem(jsdc);
|
||||
JSD_LOCK_SOURCE_TEXT(jsdc);
|
||||
|
||||
#ifdef LIVEWIRE
|
||||
new_url_string = url; /* we take ownership of alloc'd string */
|
||||
#else
|
||||
new_url_string = jsd_BuildNormalizedURL(url);
|
||||
#endif
|
||||
if( ! new_url_string )
|
||||
return NULL;
|
||||
|
||||
jsdsrc = jsd_FindSourceForURL(jsdc, new_url_string);
|
||||
|
||||
if( jsdsrc )
|
||||
MoveSourceToRemovedList(jsdc, jsdsrc);
|
||||
{
|
||||
if( jsdsrc->doingEval )
|
||||
{
|
||||
#ifdef LIVEWIRE
|
||||
free((char*)new_url_string);
|
||||
#endif
|
||||
JSD_UNLOCK_SOURCE_TEXT(jsdc);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
_moveSourceToRemovedList(jsdc, jsdsrc);
|
||||
}
|
||||
|
||||
jsdsrc = AddSource( jsdc, new_url_string );
|
||||
jsdsrc = _addSource( jsdc, new_url_string );
|
||||
|
||||
jsd_UnlockSourceTextSubsystem(jsdc);
|
||||
JSD_UNLOCK_SOURCE_TEXT(jsdc);
|
||||
|
||||
return jsdsrc;
|
||||
}
|
||||
@@ -440,32 +400,148 @@ jsd_AppendSourceText(JSDContext* jsdc,
|
||||
size_t length,
|
||||
JSDSourceStatus status)
|
||||
{
|
||||
jsd_LockSourceTextSubsystem(jsdc);
|
||||
JSD_LOCK_SOURCE_TEXT(jsdc);
|
||||
|
||||
if( ! IsSourceInSourceList( jsdc, jsdsrc ) )
|
||||
if( jsdsrc->doingEval )
|
||||
{
|
||||
RemoveSourceFromRemovedList( jsdc, jsdsrc );
|
||||
jsd_UnlockSourceTextSubsystem(jsdc);
|
||||
JSD_UNLOCK_SOURCE_TEXT(jsdc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( text && length && ! AppendText( jsdc, jsdsrc, text, length ) )
|
||||
if( ! _isSourceInSourceList( jsdc, jsdsrc ) )
|
||||
{
|
||||
_removeSourceFromRemovedList( jsdc, jsdsrc );
|
||||
JSD_UNLOCK_SOURCE_TEXT(jsdc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( text && length && ! _appendText( jsdc, jsdsrc, text, length ) )
|
||||
{
|
||||
jsdsrc->dirty = JS_TRUE;
|
||||
jsdsrc->alterCount = g_alterCount++ ;
|
||||
jsdsrc->alterCount = jsdc->sourceAlterCount++ ;
|
||||
jsdsrc->status = JSD_SOURCE_FAILED;
|
||||
MoveSourceToRemovedList(jsdc, jsdsrc);
|
||||
jsd_UnlockSourceTextSubsystem(jsdc);
|
||||
_moveSourceToRemovedList(jsdc, jsdsrc);
|
||||
JSD_UNLOCK_SOURCE_TEXT(jsdc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jsdsrc->dirty = JS_TRUE;
|
||||
jsdsrc->alterCount = g_alterCount++ ;
|
||||
jsdsrc->alterCount = jsdc->sourceAlterCount++ ;
|
||||
jsdsrc->status = status;
|
||||
DEBUG_ITERATE_SOURCES(jsdc);
|
||||
jsd_UnlockSourceTextSubsystem(jsdc);
|
||||
JSD_UNLOCK_SOURCE_TEXT(jsdc);
|
||||
return jsdsrc;
|
||||
}
|
||||
|
||||
JSDSourceText*
|
||||
jsd_AppendUCSourceText(JSDContext* jsdc,
|
||||
JSDSourceText* jsdsrc,
|
||||
const jschar* text, /* *not* zero terminated */
|
||||
size_t length,
|
||||
JSDSourceStatus status)
|
||||
{
|
||||
#define UNICODE_TRUNCATE_BUF_SIZE 1024
|
||||
static char* buf = NULL;
|
||||
int remaining = length;
|
||||
|
||||
if(!text || !length)
|
||||
return jsd_AppendSourceText(jsdc, jsdsrc, NULL, 0, status);
|
||||
|
||||
JSD_LOCK_SOURCE_TEXT(jsdc);
|
||||
if(!buf)
|
||||
{
|
||||
buf = malloc(UNICODE_TRUNCATE_BUF_SIZE);
|
||||
if(!buf)
|
||||
{
|
||||
JSD_UNLOCK_SOURCE_TEXT(jsdc);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
while(remaining && jsdsrc) {
|
||||
int bytes = JS_MIN(remaining, UNICODE_TRUNCATE_BUF_SIZE);
|
||||
int i;
|
||||
for(i = 0; i < bytes; i++)
|
||||
buf[i] = (const char) *(text++);
|
||||
jsdsrc = jsd_AppendSourceText(jsdc,jsdsrc,
|
||||
buf, bytes,
|
||||
JSD_SOURCE_PARTIAL);
|
||||
remaining -= bytes;
|
||||
}
|
||||
if(jsdsrc && status != JSD_SOURCE_PARTIAL)
|
||||
jsdsrc = jsd_AppendSourceText(jsdc, jsdsrc, NULL, 0, status);
|
||||
|
||||
JSD_UNLOCK_SOURCE_TEXT(jsdc);
|
||||
return jsdsrc;
|
||||
}
|
||||
|
||||
/* convienence function for adding complete source of url in one call */
|
||||
JSBool
|
||||
jsd_AddFullSourceText(JSDContext* jsdc,
|
||||
const char* text, /* *not* zero terminated */
|
||||
size_t length,
|
||||
const char* url)
|
||||
{
|
||||
JSDSourceText* jsdsrc;
|
||||
|
||||
JSD_LOCK_SOURCE_TEXT(jsdc);
|
||||
|
||||
jsdsrc = jsd_NewSourceText(jsdc, url);
|
||||
if( jsdsrc )
|
||||
jsdsrc = jsd_AppendSourceText(jsdc, jsdsrc,
|
||||
text, length, JSD_SOURCE_PARTIAL );
|
||||
if( jsdsrc )
|
||||
jsdsrc = jsd_AppendSourceText(jsdc, jsdsrc,
|
||||
NULL, 0, JSD_SOURCE_COMPLETED );
|
||||
|
||||
JSD_UNLOCK_SOURCE_TEXT(jsdc);
|
||||
|
||||
return jsdsrc ? JS_TRUE : JS_FALSE;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
void
|
||||
jsd_StartingEvalUsingFilename(JSDContext* jsdc, const char* url)
|
||||
{
|
||||
JSDSourceText* jsdsrc;
|
||||
|
||||
/* NOTE: We leave it locked! */
|
||||
JSD_LOCK_SOURCE_TEXT(jsdc);
|
||||
|
||||
jsdsrc = jsd_FindSourceForURL(jsdc, url);
|
||||
if(jsdsrc)
|
||||
{
|
||||
#if 0
|
||||
#ifndef JSD_LOWLEVEL_SOURCE
|
||||
JS_ASSERT(! jsdsrc->doingEval);
|
||||
#endif
|
||||
#endif
|
||||
jsdsrc->doingEval = JS_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
jsd_FinishedEvalUsingFilename(JSDContext* jsdc, const char* url)
|
||||
{
|
||||
JSDSourceText* jsdsrc;
|
||||
|
||||
/* NOTE: We ASSUME it is locked! */
|
||||
|
||||
jsdsrc = jsd_FindSourceForURL(jsdc, url);
|
||||
if(jsdsrc)
|
||||
{
|
||||
#if 0
|
||||
#ifndef JSD_LOWLEVEL_SOURCE
|
||||
/*
|
||||
* when using this low level source addition, this jsdsrc might
|
||||
* not have existed before the eval, but does exist now (without
|
||||
* this flag set!)
|
||||
*/
|
||||
JS_ASSERT(jsdsrc->doingEval);
|
||||
#endif
|
||||
#endif
|
||||
jsdsrc->doingEval = JS_FALSE;
|
||||
}
|
||||
|
||||
JSD_UNLOCK_SOURCE_TEXT(jsdc);
|
||||
}
|
||||
|
||||
601
mozilla/js/jsd/jsd_val.c
Normal file
601
mozilla/js/jsd/jsd_val.c
Normal file
@@ -0,0 +1,601 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* JavaScript Debugging support - Value and Property support
|
||||
*/
|
||||
|
||||
#include "jsd.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
void JSD_ASSERT_VALID_VALUE(JSDValue* jsdval)
|
||||
{
|
||||
JS_ASSERT(jsdval);
|
||||
JS_ASSERT(jsdval->nref > 0);
|
||||
if(!JS_CLIST_IS_EMPTY(&jsdval->props))
|
||||
{
|
||||
JS_ASSERT(CHECK_BIT_FLAG(jsdval->flags, GOT_PROPS));
|
||||
JS_ASSERT(JSVAL_IS_OBJECT(jsdval->val));
|
||||
}
|
||||
|
||||
if(jsdval->proto)
|
||||
{
|
||||
JS_ASSERT(CHECK_BIT_FLAG(jsdval->flags, GOT_PROTO));
|
||||
JS_ASSERT(jsdval->proto->nref > 0);
|
||||
}
|
||||
if(jsdval->parent)
|
||||
{
|
||||
JS_ASSERT(CHECK_BIT_FLAG(jsdval->flags, GOT_PARENT));
|
||||
JS_ASSERT(jsdval->parent->nref > 0);
|
||||
}
|
||||
if(jsdval->ctor)
|
||||
{
|
||||
JS_ASSERT(CHECK_BIT_FLAG(jsdval->flags, GOT_CTOR));
|
||||
JS_ASSERT(jsdval->ctor->nref > 0);
|
||||
}
|
||||
}
|
||||
|
||||
void JSD_ASSERT_VALID_PROPERTY(JSDProperty* jsdprop)
|
||||
{
|
||||
JS_ASSERT(jsdprop);
|
||||
JS_ASSERT(jsdprop->name);
|
||||
JS_ASSERT(jsdprop->name->nref > 0);
|
||||
JS_ASSERT(jsdprop->val);
|
||||
JS_ASSERT(jsdprop->val->nref > 0);
|
||||
if(jsdprop->alias)
|
||||
JS_ASSERT(jsdprop->alias->nref > 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
JSBool
|
||||
jsd_IsValueObject(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
return JSVAL_IS_OBJECT(jsdval->val);
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_IsValueNumber(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
return JSVAL_IS_NUMBER(jsdval->val);
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_IsValueInt(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
return JSVAL_IS_INT(jsdval->val);
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_IsValueDouble(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
return JSVAL_IS_DOUBLE(jsdval->val);
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_IsValueString(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
return JSVAL_IS_STRING(jsdval->val);
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_IsValueBoolean(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
return JSVAL_IS_BOOLEAN(jsdval->val);
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_IsValueNull(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
return JSVAL_IS_NULL(jsdval->val);
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_IsValueVoid(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
return JSVAL_IS_VOID(jsdval->val);
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_IsValuePrimitive(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
return JSVAL_IS_PRIMITIVE(jsdval->val);
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_IsValueFunction(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
return JSVAL_IS_FUNCTION(jsdc->dumbContext, jsdval->val);
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_IsValueNative(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
JSContext* cx = jsdc->dumbContext;
|
||||
jsval val = jsdval->val;
|
||||
JSFunction* fun;
|
||||
JSExceptionState* exceptionState;
|
||||
|
||||
if(!JSVAL_IS_OBJECT(val))
|
||||
return JS_FALSE;
|
||||
|
||||
if(JSVAL_IS_FUNCTION(cx, val))
|
||||
{
|
||||
exceptionState = JS_SaveExceptionState(cx);
|
||||
fun = JS_ValueToFunction(cx, val);
|
||||
JS_RestoreExceptionState(cx, exceptionState);
|
||||
if(!fun)
|
||||
{
|
||||
JS_ASSERT(0);
|
||||
return JS_FALSE;
|
||||
}
|
||||
return JS_GetFunctionScript(cx, fun) ? JS_FALSE : JS_TRUE;
|
||||
}
|
||||
return JSVAL_TO_OBJECT(val) && OBJ_IS_NATIVE(JSVAL_TO_OBJECT(val));
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
JSBool
|
||||
jsd_GetValueBoolean(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
jsval val = jsdval->val;
|
||||
if(!JSVAL_IS_BOOLEAN(val))
|
||||
return JS_FALSE;
|
||||
return JSVAL_TO_BOOLEAN(val);
|
||||
}
|
||||
|
||||
int32
|
||||
jsd_GetValueInt(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
jsval val = jsdval->val;
|
||||
if(!JSVAL_IS_INT(val))
|
||||
return 0;
|
||||
return JSVAL_TO_INT(val);
|
||||
}
|
||||
|
||||
jsdouble*
|
||||
jsd_GetValueDouble(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
jsval val = jsdval->val;
|
||||
if(!JSVAL_IS_DOUBLE(val))
|
||||
return 0;
|
||||
return JSVAL_TO_DOUBLE(val);
|
||||
}
|
||||
|
||||
JSString*
|
||||
jsd_GetValueString(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
JSContext* cx = jsdc->dumbContext;
|
||||
JSExceptionState* exceptionState;
|
||||
|
||||
if(!jsdval->string)
|
||||
{
|
||||
/* if the jsval is a string, then we don't need to double root it */
|
||||
if(JSVAL_IS_STRING(jsdval->val))
|
||||
jsdval->string = JSVAL_TO_STRING(jsdval->val);
|
||||
else
|
||||
{
|
||||
exceptionState = JS_SaveExceptionState(cx);
|
||||
jsdval->string = JS_ValueToString(cx, jsdval->val);
|
||||
JS_RestoreExceptionState(cx, exceptionState);
|
||||
if(jsdval->string)
|
||||
{
|
||||
if(!JS_AddRoot(cx, &jsdval->string))
|
||||
jsdval->string = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return jsdval->string;
|
||||
}
|
||||
|
||||
const char*
|
||||
jsd_GetValueFunctionName(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
JSContext* cx = jsdc->dumbContext;
|
||||
jsval val = jsdval->val;
|
||||
JSFunction* fun;
|
||||
JSExceptionState* exceptionState;
|
||||
|
||||
if(!jsdval->funName && JSVAL_IS_FUNCTION(cx, val))
|
||||
{
|
||||
exceptionState = JS_SaveExceptionState(cx);
|
||||
fun = JS_ValueToFunction(cx, val);
|
||||
JS_RestoreExceptionState(cx, exceptionState);
|
||||
if(!fun)
|
||||
return NULL;
|
||||
jsdval->funName = JS_GetFunctionName(fun);
|
||||
}
|
||||
return jsdval->funName;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
JSDValue*
|
||||
jsd_NewValue(JSDContext* jsdc, jsval val)
|
||||
{
|
||||
JSDValue* jsdval;
|
||||
|
||||
if(!(jsdval = (JSDValue*) calloc(1, sizeof(JSDValue))))
|
||||
return NULL;
|
||||
|
||||
if(JSVAL_IS_GCTHING(val))
|
||||
{
|
||||
if(!JS_AddRoot(jsdc->dumbContext, &jsdval->val))
|
||||
{
|
||||
free(jsdval);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
jsdval->val = val;
|
||||
jsdval->nref = 1;
|
||||
JS_INIT_CLIST(&jsdval->props);
|
||||
|
||||
return jsdval;
|
||||
}
|
||||
|
||||
void
|
||||
jsd_DropValue(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
JS_ASSERT(jsdval->nref > 0);
|
||||
if(0 == --jsdval->nref)
|
||||
{
|
||||
jsd_RefreshValue(jsdc, jsdval);
|
||||
if(JSVAL_IS_GCTHING(jsdval->val))
|
||||
JS_RemoveRoot(jsdc->dumbContext, &jsdval->val);
|
||||
free(jsdval);
|
||||
}
|
||||
}
|
||||
|
||||
jsval
|
||||
jsd_GetValueWrappedJSVal(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
return jsdval->val;
|
||||
}
|
||||
|
||||
static JSDProperty* _newProperty(JSDContext* jsdc, JSPropertyDesc* pd,
|
||||
uintN additionalFlags)
|
||||
{
|
||||
JSDProperty* jsdprop;
|
||||
|
||||
if(!(jsdprop = (JSDProperty*) calloc(1, sizeof(JSDProperty))))
|
||||
return NULL;
|
||||
|
||||
JS_INIT_CLIST(&jsdprop->links);
|
||||
jsdprop->nref = 1;
|
||||
jsdprop->flags = pd->flags | additionalFlags;
|
||||
jsdprop->slot = pd->slot;
|
||||
|
||||
if(!(jsdprop->name = jsd_NewValue(jsdc, pd->id)))
|
||||
goto new_prop_fail;
|
||||
|
||||
if(!(jsdprop->val = jsd_NewValue(jsdc, pd->value)))
|
||||
goto new_prop_fail;
|
||||
|
||||
if((jsdprop->flags & JSDPD_ALIAS) &&
|
||||
!(jsdprop->alias = jsd_NewValue(jsdc, pd->alias)))
|
||||
goto new_prop_fail;
|
||||
|
||||
return jsdprop;
|
||||
new_prop_fail:
|
||||
jsd_DropProperty(jsdc, jsdprop);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void _freeProps(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
JSDProperty* jsdprop;
|
||||
|
||||
while(jsdprop = (JSDProperty*)jsdval->props.next,
|
||||
jsdprop != (JSDProperty*)&jsdval->props)
|
||||
{
|
||||
JS_REMOVE_AND_INIT_LINK(&jsdprop->links);
|
||||
jsd_DropProperty(jsdc, jsdprop);
|
||||
}
|
||||
JS_ASSERT(JS_CLIST_IS_EMPTY(&jsdval->props));
|
||||
CLEAR_BIT_FLAG(jsdval->flags, GOT_PROPS);
|
||||
}
|
||||
|
||||
static JSBool _buildProps(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
JSContext* cx = jsdc->dumbContext;
|
||||
JSPropertyDescArray pda;
|
||||
uintN i;
|
||||
|
||||
JS_ASSERT(JS_CLIST_IS_EMPTY(&jsdval->props));
|
||||
JS_ASSERT(!(CHECK_BIT_FLAG(jsdval->flags, GOT_PROPS)));
|
||||
JS_ASSERT(JSVAL_IS_OBJECT(jsdval->val));
|
||||
|
||||
if(!JSVAL_IS_OBJECT(jsdval->val) || JSVAL_IS_NULL(jsdval->val))
|
||||
return JS_FALSE;
|
||||
|
||||
if(!JS_GetPropertyDescArray(cx, JSVAL_TO_OBJECT(jsdval->val), &pda))
|
||||
return JS_FALSE;
|
||||
|
||||
for(i = 0; i < pda.length; i++)
|
||||
{
|
||||
JSDProperty* prop = _newProperty(jsdc, &pda.array[i], 0);
|
||||
if(!prop)
|
||||
{
|
||||
_freeProps(jsdc, jsdval);
|
||||
break;
|
||||
}
|
||||
JS_APPEND_LINK(&prop->links, &jsdval->props);
|
||||
}
|
||||
JS_PutPropertyDescArray(cx, &pda);
|
||||
SET_BIT_FLAG(jsdval->flags, GOT_PROPS);
|
||||
return !JS_CLIST_IS_EMPTY(&jsdval->props);
|
||||
}
|
||||
|
||||
#undef DROP_CLEAR_VALUE
|
||||
#define DROP_CLEAR_VALUE(jsdc, x) if(x){jsd_DropValue(jsdc,x); x = NULL;}
|
||||
|
||||
void
|
||||
jsd_RefreshValue(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
JSContext* cx = jsdc->dumbContext;
|
||||
|
||||
if(jsdval->string)
|
||||
{
|
||||
/* if the jsval is a string, then we didn't need to root the string */
|
||||
if(!JSVAL_IS_STRING(jsdval->val))
|
||||
JS_RemoveRoot(cx, &jsdval->string);
|
||||
jsdval->string = NULL;
|
||||
}
|
||||
|
||||
jsdval->funName = NULL;
|
||||
jsdval->className = NULL;
|
||||
DROP_CLEAR_VALUE(jsdc, jsdval->proto);
|
||||
DROP_CLEAR_VALUE(jsdc, jsdval->parent);
|
||||
DROP_CLEAR_VALUE(jsdc, jsdval->ctor);
|
||||
_freeProps(jsdc, jsdval);
|
||||
jsdval->flags = 0;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
uintN
|
||||
jsd_GetCountOfProperties(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
JSDProperty* jsdprop;
|
||||
uintN count = 0;
|
||||
|
||||
if(!(CHECK_BIT_FLAG(jsdval->flags, GOT_PROPS)))
|
||||
if(!_buildProps(jsdc, jsdval))
|
||||
return 0;
|
||||
|
||||
for(jsdprop = (JSDProperty*)jsdval->props.next;
|
||||
jsdprop != (JSDProperty*)&jsdval->props;
|
||||
jsdprop = (JSDProperty*)jsdprop->links.next)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
JSDProperty*
|
||||
jsd_IterateProperties(JSDContext* jsdc, JSDValue* jsdval, JSDProperty **iterp)
|
||||
{
|
||||
JSDProperty* jsdprop = *iterp;
|
||||
if(!(CHECK_BIT_FLAG(jsdval->flags, GOT_PROPS)))
|
||||
{
|
||||
JS_ASSERT(!jsdprop);
|
||||
if(!_buildProps(jsdc, jsdval))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!jsdprop)
|
||||
jsdprop = (JSDProperty*)jsdval->props.next;
|
||||
if(jsdprop == (JSDProperty*)&jsdval->props)
|
||||
return NULL;
|
||||
*iterp = (JSDProperty*)jsdprop->links.next;
|
||||
|
||||
JS_ASSERT(jsdprop);
|
||||
jsdprop->nref++;
|
||||
return jsdprop;
|
||||
}
|
||||
|
||||
JSDProperty*
|
||||
jsd_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* name)
|
||||
{
|
||||
JSContext* cx = jsdc->dumbContext;
|
||||
JSDProperty* jsdprop;
|
||||
JSDProperty* iter = NULL;
|
||||
JSObject* obj;
|
||||
uintN attrs = 0;
|
||||
JSBool found;
|
||||
JSPropertyDesc pd;
|
||||
const jschar * nameChars;
|
||||
size_t nameLen;
|
||||
jsval val;
|
||||
|
||||
if(!jsd_IsValueObject(jsdc, jsdval))
|
||||
return NULL;
|
||||
|
||||
/* If we already have the prop, then return it */
|
||||
while(NULL != (jsdprop = jsd_IterateProperties(jsdc, jsdval, &iter)))
|
||||
{
|
||||
JSString* propName = jsd_GetValueString(jsdc, jsdprop->name);
|
||||
if(propName && !JS_CompareStrings(propName, name))
|
||||
return jsdprop;
|
||||
JSD_DropProperty(jsdc, jsdprop);
|
||||
}
|
||||
/* Not found in property list, look it up explicitly */
|
||||
|
||||
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
|
||||
return NULL;
|
||||
|
||||
nameChars = JS_GetStringChars(name);
|
||||
nameLen = JS_GetStringLength(name);
|
||||
|
||||
/* It's OK if this fails - we just don't get attribs */
|
||||
JS_GetUCPropertyAttributes(cx, obj, nameChars, nameLen, &attrs, &found);
|
||||
|
||||
if(!JS_GetUCProperty(cx, obj, nameChars, nameLen, &val))
|
||||
return NULL;
|
||||
|
||||
/* XXX screwy! no good way to detect that property does not exist at all */
|
||||
if(!found && JSVAL_IS_VOID(val))
|
||||
return NULL;
|
||||
|
||||
pd.id = STRING_TO_JSVAL(name);
|
||||
pd.value = val;
|
||||
pd.alias = pd.slot = pd.spare = 0;
|
||||
pd.flags = 0
|
||||
| (attrs & JSPROP_ENUMERATE) ? JSPD_ENUMERATE : 0
|
||||
| (attrs & JSPROP_READONLY) ? JSPD_READONLY : 0
|
||||
| (attrs & JSPROP_PERMANENT) ? JSPD_PERMANENT : 0;
|
||||
|
||||
return _newProperty(jsdc, &pd, JSDPD_HINTED);
|
||||
}
|
||||
|
||||
|
||||
JSDValue*
|
||||
jsd_GetValuePrototype(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
if(!(CHECK_BIT_FLAG(jsdval->flags, GOT_PROTO)))
|
||||
{
|
||||
JSObject* obj;
|
||||
JSObject* proto;
|
||||
JS_ASSERT(!jsdval->proto);
|
||||
SET_BIT_FLAG(jsdval->flags, GOT_PROTO);
|
||||
if(!JSVAL_IS_OBJECT(jsdval->val))
|
||||
return NULL;
|
||||
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
|
||||
return NULL;
|
||||
if(!(proto = OBJ_GET_PROTO(jsdc->dumbContext,obj)))
|
||||
return NULL;
|
||||
jsdval->proto = jsd_NewValue(jsdc, OBJECT_TO_JSVAL(proto));
|
||||
}
|
||||
if(jsdval->proto)
|
||||
jsdval->proto->nref++;
|
||||
return jsdval->proto;
|
||||
}
|
||||
|
||||
JSDValue*
|
||||
jsd_GetValueParent(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
if(!(CHECK_BIT_FLAG(jsdval->flags, GOT_PARENT)))
|
||||
{
|
||||
JSObject* obj;
|
||||
JSObject* parent;
|
||||
JS_ASSERT(!jsdval->parent);
|
||||
SET_BIT_FLAG(jsdval->flags, GOT_PARENT);
|
||||
if(!JSVAL_IS_OBJECT(jsdval->val))
|
||||
return NULL;
|
||||
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
|
||||
return NULL;
|
||||
if(!(parent = OBJ_GET_PARENT(jsdc->dumbContext,obj)))
|
||||
return NULL;
|
||||
jsdval->parent = jsd_NewValue(jsdc, OBJECT_TO_JSVAL(parent));
|
||||
}
|
||||
if(jsdval->parent)
|
||||
jsdval->parent->nref++;
|
||||
return jsdval->parent;
|
||||
}
|
||||
|
||||
JSDValue*
|
||||
jsd_GetValueConstructor(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
if(!(CHECK_BIT_FLAG(jsdval->flags, GOT_CTOR)))
|
||||
{
|
||||
JSObject* obj;
|
||||
JSObject* proto;
|
||||
JSObject* ctor;
|
||||
JS_ASSERT(!jsdval->ctor);
|
||||
SET_BIT_FLAG(jsdval->flags, GOT_CTOR);
|
||||
if(!JSVAL_IS_OBJECT(jsdval->val))
|
||||
return NULL;
|
||||
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
|
||||
return NULL;
|
||||
if(!(proto = OBJ_GET_PROTO(jsdc->dumbContext,obj)))
|
||||
return NULL;
|
||||
if(!(ctor = JS_GetConstructor(jsdc->dumbContext,proto)))
|
||||
return NULL;
|
||||
jsdval->ctor = jsd_NewValue(jsdc, OBJECT_TO_JSVAL(ctor));
|
||||
}
|
||||
if(jsdval->ctor)
|
||||
jsdval->ctor->nref++;
|
||||
return jsdval->ctor;
|
||||
}
|
||||
|
||||
const char*
|
||||
jsd_GetValueClassName(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
jsval val = jsdval->val;
|
||||
if(!jsdval->className && JSVAL_IS_OBJECT(val))
|
||||
{
|
||||
JSObject* obj;
|
||||
if(!(obj = JSVAL_TO_OBJECT(val)))
|
||||
return NULL;
|
||||
if(OBJ_GET_CLASS(jsdc->dumbContext, obj))
|
||||
jsdval->className = OBJ_GET_CLASS(jsdc->dumbContext, obj)->name;
|
||||
}
|
||||
return jsdval->className;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
|
||||
JSDValue*
|
||||
jsd_GetPropertyName(JSDContext* jsdc, JSDProperty* jsdprop)
|
||||
{
|
||||
jsdprop->name->nref++;
|
||||
return jsdprop->name;
|
||||
}
|
||||
|
||||
JSDValue*
|
||||
jsd_GetPropertyValue(JSDContext* jsdc, JSDProperty* jsdprop)
|
||||
{
|
||||
jsdprop->val->nref++;
|
||||
return jsdprop->val;
|
||||
}
|
||||
|
||||
JSDValue*
|
||||
jsd_GetPropertyAlias(JSDContext* jsdc, JSDProperty* jsdprop)
|
||||
{
|
||||
if(jsdprop->alias)
|
||||
jsdprop->alias->nref++;
|
||||
return jsdprop->alias;
|
||||
}
|
||||
|
||||
uintN
|
||||
jsd_GetPropertyFlags(JSDContext* jsdc, JSDProperty* jsdprop)
|
||||
{
|
||||
return jsdprop->flags;
|
||||
}
|
||||
|
||||
uintN
|
||||
jsd_GetPropertyVarArgSlot(JSDContext* jsdc, JSDProperty* jsdprop)
|
||||
{
|
||||
return jsdprop->slot;
|
||||
}
|
||||
|
||||
void
|
||||
jsd_DropProperty(JSDContext* jsdc, JSDProperty* jsdprop)
|
||||
{
|
||||
JS_ASSERT(jsdprop->nref > 0);
|
||||
if(0 == --jsdprop->nref)
|
||||
{
|
||||
JS_ASSERT(JS_CLIST_IS_EMPTY(&jsdprop->links));
|
||||
DROP_CLEAR_VALUE(jsdc, jsdprop->val);
|
||||
DROP_CLEAR_VALUE(jsdc, jsdprop->name);
|
||||
DROP_CLEAR_VALUE(jsdc, jsdprop->alias);
|
||||
free(jsdprop);
|
||||
}
|
||||
}
|
||||
12
mozilla/js/jsd/jsdb/README
Normal file
12
mozilla/js/jsd/jsdb/README
Normal file
@@ -0,0 +1,12 @@
|
||||
/* jband - 10/26/98 - */
|
||||
|
||||
js/jsd/jsdb is a console debugger using only native code. It is experimental.
|
||||
The only makefile supplied is for Win32.
|
||||
|
||||
jsdb.mak will build a debugger enabled js/src/js.c shell. The debugger is
|
||||
implemented by reflecting the JSD api into JavaScript. The actual debugger
|
||||
logic is fully implemented in debugger.js. The debugger can debug itself. It
|
||||
can also be modified and reloaded at runtime.
|
||||
|
||||
The JavaScript keyword 'debugger' is used to break into the debugger. A 'help()'
|
||||
command is supplied to show available commands when exectution is stopped.
|
||||
1017
mozilla/js/jsd/jsdb/debugger.js
Normal file
1017
mozilla/js/jsd/jsdb/debugger.js
Normal file
File diff suppressed because it is too large
Load Diff
46
mozilla/js/jsd/jsdb/f.js
Normal file
46
mozilla/js/jsd/jsdb/f.js
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
/**
|
||||
* for(var p in Script.scripts) {
|
||||
*
|
||||
* var script = Script.scripts[p];
|
||||
* var handle = script.handle;
|
||||
* var base = script.base;
|
||||
* var limit = base + script.extent;
|
||||
*
|
||||
* print(script+"\n");
|
||||
*
|
||||
* for(var i = base; i < limit; i++) {
|
||||
* var pc = jsd.GetClosestPC(handle,i)
|
||||
* var hascode = String(pc).length && i == jsd.GetClosestLine(handle,pc);
|
||||
* print("line "+i+" "+ (hascode ? "has code" : "has NO code"));
|
||||
* }
|
||||
* print("...............................\n");
|
||||
* }
|
||||
*/
|
||||
|
||||
function rlocals()
|
||||
{
|
||||
var retval = "";
|
||||
var name = "___UNIQUE_NAME__";
|
||||
var fun = ""+
|
||||
"var text = \\\"\\\";"+
|
||||
"for(var p in ob)"+
|
||||
"{"+
|
||||
" if(text != \\\"\\\")"+
|
||||
" text += \\\",\\\";"+
|
||||
" text += p;"+
|
||||
"}"+
|
||||
"return text;";
|
||||
|
||||
reval(name+" = new Function(\"ob\",\""+fun+"\")");
|
||||
// show(name);
|
||||
retval = _reval([name+"("+"arguments.callee"+")"]);
|
||||
reval("delete "+name);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
function e(a)
|
||||
{
|
||||
return eval(a);
|
||||
}
|
||||
449
mozilla/js/jsd/jsdb/jsdb.c
Normal file
449
mozilla/js/jsd/jsdb/jsdb.c
Normal file
@@ -0,0 +1,449 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* JSDB public and callback functions
|
||||
*/
|
||||
|
||||
#include "jsdbpriv.h"
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(void)
|
||||
_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
|
||||
{
|
||||
int i, j, k, n;
|
||||
|
||||
fputs("jsdb: ", stderr);
|
||||
if (!report) {
|
||||
fprintf(stderr, "%s\n", message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (report->filename)
|
||||
fprintf(stderr, "%s, ", report->filename);
|
||||
if (report->lineno)
|
||||
fprintf(stderr, "line %u: ", report->lineno);
|
||||
fputs(message, stderr);
|
||||
if (!report->linebuf) {
|
||||
putc('\n', stderr);
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, ":\n%s\n", report->linebuf);
|
||||
n = report->tokenptr - report->linebuf;
|
||||
for (i = j = 0; i < n; i++) {
|
||||
if (report->linebuf[i] == '\t') {
|
||||
for (k = (j + 8) & ~7; j < k; j++)
|
||||
putc('.', stderr);
|
||||
continue;
|
||||
}
|
||||
putc('.', stderr);
|
||||
j++;
|
||||
}
|
||||
fputs("^\n", stderr);
|
||||
}
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(void)
|
||||
jsdb_ScriptHookProc(JSDContext* jsdc,
|
||||
JSDScript* jsdscript,
|
||||
JSBool creating,
|
||||
void* callerdata)
|
||||
{
|
||||
JSDB_Data* data = (JSDB_Data*) callerdata;
|
||||
JSFunction* fun;
|
||||
|
||||
if(data->jsScriptHook &&
|
||||
NULL != (fun = JS_ValueToFunction(data->cxDebugger, data->jsScriptHook)))
|
||||
{
|
||||
jsval result;
|
||||
jsval args[2] = {P2H_SCRIPT(data->cxDebugger, jsdscript),
|
||||
creating ? JSVAL_TRUE : JSVAL_FALSE };
|
||||
JS_CallFunction(data->cxDebugger, NULL, fun, 2, args, &result);
|
||||
}
|
||||
}
|
||||
|
||||
uintN JS_DLL_CALLBACK
|
||||
jsdb_ExecHookHandler(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
uintN type,
|
||||
void* callerdata,
|
||||
jsval* rval)
|
||||
{
|
||||
uintN ourRetVal = JSD_HOOK_RETURN_CONTINUE;
|
||||
jsval result;
|
||||
JSFunction* fun;
|
||||
int answer;
|
||||
JSDB_Data* data = (JSDB_Data*) callerdata;
|
||||
JS_ASSERT(data);
|
||||
|
||||
/* if we're already stopped, then don't stop */
|
||||
if(data->jsdthreadstate)
|
||||
return JSD_HOOK_RETURN_CONTINUE;
|
||||
|
||||
if(!jsdb_SetThreadState(data, jsdthreadstate))
|
||||
goto label_bail;
|
||||
|
||||
if(data->jsExecutionHook &&
|
||||
NULL != (fun = JS_ValueToFunction(data->cxDebugger, data->jsExecutionHook)))
|
||||
{
|
||||
jsval arg = INT_TO_JSVAL((int)type);
|
||||
if(!JS_CallFunction(data->cxDebugger, NULL, fun, 1, &arg, &result))
|
||||
goto label_bail;
|
||||
if(!JSVAL_IS_INT(result))
|
||||
goto label_bail;
|
||||
answer = JSVAL_TO_INT(result);
|
||||
|
||||
|
||||
if((answer == JSD_HOOK_RETURN_RET_WITH_VAL ||
|
||||
answer == JSD_HOOK_RETURN_THROW_WITH_VAL) &&
|
||||
!jsdb_EvalReturnExpression(data, rval))
|
||||
{
|
||||
goto label_bail;
|
||||
}
|
||||
|
||||
if(answer >= JSD_HOOK_RETURN_HOOK_ERROR &&
|
||||
answer <= JSD_HOOK_RETURN_CONTINUE_THROW)
|
||||
ourRetVal = answer;
|
||||
else
|
||||
ourRetVal = JSD_HOOK_RETURN_CONTINUE;
|
||||
}
|
||||
|
||||
label_bail:
|
||||
jsdb_SetThreadState(data, NULL);
|
||||
return ourRetVal;
|
||||
}
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ARG_MSG = 0,
|
||||
ARG_FILENAME,
|
||||
ARG_LINENO,
|
||||
ARG_LINEBUF,
|
||||
ARG_TOKEN_OFFSET,
|
||||
ARG_LIMIT
|
||||
} ER_ARGS;
|
||||
|
||||
uintN JS_DLL_CALLBACK
|
||||
jsdb_ErrorReporter(JSDContext* jsdc,
|
||||
JSContext* cx,
|
||||
const char* message,
|
||||
JSErrorReport* report,
|
||||
void* callerdata)
|
||||
{
|
||||
uintN ourRetVal = JSD_ERROR_REPORTER_PASS_ALONG;
|
||||
jsval result;
|
||||
JSFunction* fun;
|
||||
int32 answer;
|
||||
JSDB_Data* data = (JSDB_Data*) callerdata;
|
||||
JS_ASSERT(data);
|
||||
|
||||
if(data->jsErrorReporterHook &&
|
||||
NULL != (fun = JS_ValueToFunction(data->cxDebugger,
|
||||
data->jsErrorReporterHook)))
|
||||
{
|
||||
jsval args[ARG_LIMIT] = {JSVAL_NULL};
|
||||
|
||||
if(message)
|
||||
args[ARG_MSG] =
|
||||
STRING_TO_JSVAL(JS_NewStringCopyZ(cx, message));
|
||||
if(report && report->filename)
|
||||
args[ARG_FILENAME] =
|
||||
STRING_TO_JSVAL(JS_NewStringCopyZ(cx, report->filename));
|
||||
if(report && report->linebuf)
|
||||
args[ARG_LINEBUF] =
|
||||
STRING_TO_JSVAL(JS_NewStringCopyZ(cx, report->linebuf));
|
||||
if(report)
|
||||
args[ARG_LINENO] =
|
||||
INT_TO_JSVAL(report->lineno);
|
||||
if(report && report->linebuf && report->tokenptr)
|
||||
args[ARG_TOKEN_OFFSET] =
|
||||
INT_TO_JSVAL((int)(report->tokenptr - report->linebuf));
|
||||
|
||||
if(!JS_CallFunction(data->cxDebugger, NULL, fun, ARG_LIMIT, args, &result))
|
||||
return ourRetVal;
|
||||
|
||||
if(JS_ValueToInt32(data->cxDebugger, result, &answer))
|
||||
ourRetVal = (uintN) answer;
|
||||
}
|
||||
return ourRetVal;
|
||||
}
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(JSBool)
|
||||
Load(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
uintN i;
|
||||
JSString *str;
|
||||
const char *filename;
|
||||
JSScript *script;
|
||||
JSBool ok;
|
||||
jsval result;
|
||||
|
||||
ok = JS_TRUE;
|
||||
for (i = 0; i < argc; i++) {
|
||||
str = JS_ValueToString(cx, argv[i]);
|
||||
if (!str) {
|
||||
ok = JS_FALSE;
|
||||
break;
|
||||
}
|
||||
argv[i] = STRING_TO_JSVAL(str);
|
||||
filename = JS_GetStringBytes(str);
|
||||
errno = 0;
|
||||
script = JS_CompileFile(cx, obj, filename);
|
||||
if (!script)
|
||||
continue;
|
||||
ok = JS_ExecuteScript(cx, obj, script, &result);
|
||||
JS_DestroyScript(cx, script);
|
||||
if (!ok)
|
||||
break;
|
||||
}
|
||||
JS_GC(cx);
|
||||
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,""));
|
||||
return ok;
|
||||
}
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(JSBool)
|
||||
Write(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
JSString *str = JS_ValueToString(cx, argv[0]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
printf(JS_GetStringBytes(str));
|
||||
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,""));
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(JSBool)
|
||||
Gets(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
char buf[1024];
|
||||
if(! gets(buf))
|
||||
return JS_FALSE;
|
||||
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, buf));
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(JSBool)
|
||||
Version(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
if (argc > 0 && JSVAL_IS_INT(argv[0]))
|
||||
*rval = INT_TO_JSVAL(JS_SetVersion(cx, JSVAL_TO_INT(argv[0])));
|
||||
else
|
||||
*rval = INT_TO_JSVAL(JS_GetVersion(cx));
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(JSBool)
|
||||
SafeEval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
static char default_filename[] = "jsdb_eval";
|
||||
/* JSContext *cx2; */
|
||||
JSString* textJSString;
|
||||
char* filename;
|
||||
int32 lineno;
|
||||
JSDB_Data* data = (JSDB_Data*) JS_GetContextPrivate(cx);
|
||||
JS_ASSERT(data);
|
||||
|
||||
if(argc < 1 || !(textJSString = JS_ValueToString(cx, argv[0])))
|
||||
{
|
||||
JS_ReportError(cx, "safeEval requires source text as a first argument");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if(argc < 2)
|
||||
filename = default_filename;
|
||||
else
|
||||
{
|
||||
JSString* filenameJSString;
|
||||
if(!(filenameJSString = JS_ValueToString(cx, argv[1])))
|
||||
{
|
||||
JS_ReportError(cx, "safeEval passed non-string filename as 2nd param");
|
||||
return JS_FALSE;
|
||||
}
|
||||
filename = JS_GetStringBytes(filenameJSString);
|
||||
}
|
||||
|
||||
if(argc < 3)
|
||||
lineno = 1;
|
||||
else
|
||||
{
|
||||
if(!JS_ValueToInt32(cx, argv[2], &lineno))
|
||||
{
|
||||
JS_ReportError(cx, "safeEval passed non-int lineno as 3rd param");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(! JS_EvaluateScript(cx, obj,
|
||||
JS_GetStringBytes(textJSString),
|
||||
JS_GetStringLength(textJSString),
|
||||
filename, lineno, rval))
|
||||
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,""));
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(JSBool)
|
||||
NativeBreak(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
_asm int 3;
|
||||
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,"did _asm int 3;"));
|
||||
#else
|
||||
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,"only supported for Windows"));
|
||||
#endif
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSFunctionSpec debugger_functions[] = {
|
||||
{"version", Version, 0},
|
||||
{"load", Load, 1},
|
||||
{"write", Write, 0},
|
||||
{"gets", Gets, 0},
|
||||
{"safeEval", SafeEval, 3},
|
||||
{"nativeBreak", NativeBreak, 0},
|
||||
{0}
|
||||
};
|
||||
|
||||
static JSClass debugger_global_class = {
|
||||
"debugger_global", 0,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifdef JSD_LOWLEVEL_SOURCE
|
||||
/*
|
||||
* This facilitates sending source to JSD (the debugger system) in the shell
|
||||
* where the source is loaded using the JSFILE hack in jsscan. The function
|
||||
* below is used as a callback for the jsdbgapi JS_SetSourceHandler hook.
|
||||
* A more normal embedding (e.g. mozilla) loads source itself and can send
|
||||
* source directly to JSD without using this hook scheme.
|
||||
*/
|
||||
static void
|
||||
SendSourceToJSDebugger(const char *filename, uintN lineno,
|
||||
jschar *str, size_t length,
|
||||
void **listenerTSData, JSDContext* jsdc)
|
||||
{
|
||||
JSDSourceText *jsdsrc = (JSDSourceText *) *listenerTSData;
|
||||
|
||||
if (!jsdsrc) {
|
||||
if (!filename)
|
||||
filename = "typein";
|
||||
if (1 == lineno) {
|
||||
jsdsrc = JSD_NewSourceText(jsdc, filename);
|
||||
} else {
|
||||
jsdsrc = JSD_FindSourceForURL(jsdc, filename);
|
||||
if (jsdsrc && JSD_SOURCE_PARTIAL !=
|
||||
JSD_GetSourceStatus(jsdc, jsdsrc)) {
|
||||
jsdsrc = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (jsdsrc) {
|
||||
jsdsrc = JSD_AppendUCSourceText(jsdc,jsdsrc, str, length,
|
||||
JSD_SOURCE_PARTIAL);
|
||||
}
|
||||
*listenerTSData = jsdsrc;
|
||||
}
|
||||
#endif /* JSD_LOWLEVEL_SOURCE */
|
||||
|
||||
static JSBool
|
||||
_initReturn(const char* str, JSBool retval)
|
||||
{
|
||||
if(str)
|
||||
printf("%s\n", str);
|
||||
if(retval)
|
||||
; /* printf("debugger initialized\n"); */
|
||||
else
|
||||
{
|
||||
JS_ASSERT(0);
|
||||
printf("debugger FAILED to initialize\n");
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
#define MAX_DEBUGGER_DEPTH 3
|
||||
|
||||
JS_EXPORT_API(JSBool)
|
||||
JSDB_InitDebugger(JSRuntime* rt, JSDContext* jsdc, int depth)
|
||||
{
|
||||
jsval rvalIgnore;
|
||||
static char load_deb[] = "load('debugger.js')";
|
||||
|
||||
JSDB_Data* data = (JSDB_Data*) calloc(1, sizeof(JSDB_Data));
|
||||
if(!data)
|
||||
return _initReturn("memory alloc error", JS_FALSE);
|
||||
|
||||
data->rtTarget = rt;
|
||||
data->jsdcTarget = jsdc;
|
||||
data->debuggerDepth = depth+1;
|
||||
|
||||
if(!(data->rtDebugger = JS_NewRuntime(8L * 1024L * 1024L)))
|
||||
return _initReturn("debugger runtime creation error", JS_FALSE);
|
||||
|
||||
if(!(data->cxDebugger = JS_NewContext(data->rtDebugger, 8192)))
|
||||
return _initReturn("debugger creation error", JS_FALSE);
|
||||
|
||||
JS_SetContextPrivate(data->cxDebugger, data);
|
||||
|
||||
JS_SetErrorReporter(data->cxDebugger, _ErrorReporter);
|
||||
|
||||
if(!(data->globDebugger =
|
||||
JS_NewObject(data->cxDebugger, &debugger_global_class, NULL, NULL)))
|
||||
return _initReturn("debugger global object creation error", JS_FALSE);
|
||||
|
||||
if(!JS_InitStandardClasses(data->cxDebugger, data->globDebugger))
|
||||
return _initReturn("debugger InitStandardClasses error", JS_FALSE);
|
||||
|
||||
if(!JS_DefineFunctions(data->cxDebugger, data->globDebugger, debugger_functions))
|
||||
return _initReturn("debugger DefineFunctions error", JS_FALSE);
|
||||
|
||||
if(!jsdb_ReflectJSD(data))
|
||||
return _initReturn("debugger reflection of JSD API error", JS_FALSE);
|
||||
|
||||
if(data->debuggerDepth < MAX_DEBUGGER_DEPTH)
|
||||
{
|
||||
JSDContext* jsdc;
|
||||
if(!(jsdc = JSD_DebuggerOnForUser(data->rtDebugger, NULL, NULL)))
|
||||
return _initReturn("failed to create jsdc for nested debugger", JS_FALSE);
|
||||
JSD_JSContextInUse(jsdc, data->cxDebugger);
|
||||
if(!JSDB_InitDebugger(data->rtDebugger, jsdc, data->debuggerDepth))
|
||||
return _initReturn("failed to init nested debugger", JS_FALSE);
|
||||
}
|
||||
|
||||
JSD_SetScriptHook(jsdc, jsdb_ScriptHookProc, data);
|
||||
JSD_SetDebuggerHook(jsdc, jsdb_ExecHookHandler, data);
|
||||
JSD_SetThrowHook(jsdc, jsdb_ExecHookHandler, data);
|
||||
JSD_SetDebugBreakHook(jsdc, jsdb_ExecHookHandler, data);
|
||||
JSD_SetErrorReporter(jsdc, jsdb_ErrorReporter, data);
|
||||
|
||||
#ifdef JSD_LOWLEVEL_SOURCE
|
||||
JS_SetSourceHandler(data->rtDebugger, SendSourceToJSDebugger, jsdc);
|
||||
#endif /* JSD_LOWLEVEL_SOURCE */
|
||||
|
||||
JS_EvaluateScript(data->cxDebugger, data->globDebugger,
|
||||
load_deb, sizeof(load_deb)-1, "jsdb_autoload", 1,
|
||||
&rvalIgnore);
|
||||
|
||||
return _initReturn(NULL, JS_TRUE);
|
||||
}
|
||||
|
||||
@@ -16,22 +16,35 @@
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef jsmacos_h___
|
||||
#define jsmacos_h___
|
||||
//
|
||||
// This file contains all changes and additions that need to be made to the
|
||||
// runtime for the Macintosh platform hosting the Metrowerks environment.
|
||||
// This file should only be included in Macintosh builds.
|
||||
//
|
||||
/*
|
||||
* Public headers for JSDB
|
||||
*/
|
||||
|
||||
#ifndef jsdb_h___
|
||||
#define jsdb_h___
|
||||
|
||||
/* Get jstypes.h included first. After that we can use PR macros for doing
|
||||
* this extern "C" stuff!
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#include "jstypes.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
#include "jsapi.h"
|
||||
#include "jsdebug.h"
|
||||
JS_END_EXTERN_C
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
extern void* reallocSmaller(void* block, size_t newSize);
|
||||
|
||||
extern char* strdup(const char* str);
|
||||
extern JS_EXPORT_API(JSBool)
|
||||
JSDB_InitDebugger(JSRuntime* rt, JSDContext* jsdc, int depth);
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsmacos_h___ */
|
||||
#endif /* jsdb_h___ */
|
||||
102
mozilla/js/jsd/jsdb/jsdb.mak
Normal file
102
mozilla/js/jsd/jsdb/jsdb.mak
Normal file
@@ -0,0 +1,102 @@
|
||||
|
||||
PROJ = jsdb
|
||||
JSDB = .
|
||||
JSD = $(JSDB)\..
|
||||
JSSRC = $(JSD)\..\src
|
||||
|
||||
!IF "$(BUILD_OPT)" != ""
|
||||
OBJ = Release
|
||||
CC_FLAGS = /DNDEBUG
|
||||
!ELSE
|
||||
OBJ = Debug
|
||||
CC_FLAGS = /DDEBUG
|
||||
LINK_FLAGS = /DEBUG
|
||||
!ENDIF
|
||||
|
||||
CFLAGS = /nologo /MDd /W3 /Gm /GX /Zi /Od\
|
||||
/I $(JSSRC)\
|
||||
/I $(JSD)\
|
||||
/I $(JSDB)\
|
||||
$(CC_FLAGS)\
|
||||
/DWIN32 /DXP_PC /D_WINDOWS /D_WIN32\
|
||||
/DJSDEBUGGER\
|
||||
/DJSDEBUGGER_C_UI\
|
||||
/DJSD_LOWLEVEL_SOURCE\
|
||||
/DJSFILE\
|
||||
/c /Fp$(OBJ)\$(PROJ).pch /Fd$(OBJ)\$(PROJ).pdb /YX -Fo$@ $<
|
||||
|
||||
LFLAGS = /nologo /subsystem:console /incremental:no /machine:I386 $(LINK_FLAGS)\
|
||||
/pdb:$(OBJ)\$(PROJ).pdb -out:$(OBJ)\$(PROJ).exe
|
||||
|
||||
LLIBS = kernel32.lib advapi32.lib $(JSSRC)\$(OBJ)\js32.lib $(JSD)\$(OBJ)\jsd.lib
|
||||
|
||||
CPP=cl.exe
|
||||
LINK32=link.exe
|
||||
|
||||
all: $(OBJ) dlls $(OBJ)\$(PROJ).exe $(OBJ)\debugger.js
|
||||
|
||||
|
||||
HEADERS = $(JSDB)\jsdb.h \
|
||||
$(JSDB)\jsdbpriv.h
|
||||
|
||||
|
||||
OBJECTS = $(OBJ)\js.obj \
|
||||
$(OBJ)\jsdb.obj \
|
||||
$(OBJ)\jsdrefl.obj
|
||||
|
||||
|
||||
$(OBJECTS) : $(HEADERS)
|
||||
|
||||
|
||||
$(OBJ)\$(PROJ).exe: $(OBJECTS)
|
||||
$(LINK32) $(LFLAGS) $** $(LLIBS)
|
||||
|
||||
.c{$(OBJ)}.obj:
|
||||
$(CPP) $(CFLAGS)
|
||||
|
||||
{$(JSSRC)}.c.obj:
|
||||
$(CPP) $(CFLAGS)
|
||||
|
||||
$(OBJ) :
|
||||
mkdir $(OBJ)
|
||||
|
||||
$(OBJ)\js32.dll :
|
||||
@cd ..\..\src
|
||||
@nmake -f js.mak CFG="js - Win32 Debug"
|
||||
@cd ..\jsd\jsdb
|
||||
@echo Copying dll from js/src
|
||||
@copy $(JSSRC)\$(OBJ)\js32.dll $(OBJ) >NUL
|
||||
@copy $(JSSRC)\$(OBJ)\js32.pdb $(OBJ) >NUL
|
||||
|
||||
$(OBJ)\jsd.dll :
|
||||
@cd ..
|
||||
@nmake -f jsd.mak JSD_THREADSAFE=1
|
||||
@cd jsdb
|
||||
@echo Copying dll from js/jsd
|
||||
@copy $(JSD)\$(OBJ)\jsd.dll $(OBJ) >NUL
|
||||
@copy $(JSD)\$(OBJ)\jsd.pdb $(OBJ) >NUL
|
||||
|
||||
dlls : $(OBJ)\js32.dll $(OBJ)\jsd.dll
|
||||
|
||||
$(OBJ)\debugger.js: *.js
|
||||
@echo Copying *.js
|
||||
@copy *.js $(OBJ) >NUL
|
||||
|
||||
clean:
|
||||
@echo Deleting built files
|
||||
@del $(OBJ)\*.pch >NUL
|
||||
@del $(OBJ)\*.obj >NUL
|
||||
@del $(OBJ)\*.exp >NUL
|
||||
@del $(OBJ)\*.lib >NUL
|
||||
@del $(OBJ)\*.idb >NUL
|
||||
@del $(OBJ)\*.pdb >NUL
|
||||
@del $(OBJ)\*.dll >NUL
|
||||
@del $(OBJ)\*.exe >NUL
|
||||
|
||||
deep_clean: clean
|
||||
@cd ..\..\src
|
||||
@nmake -f js.mak CFG="js - Win32 Debug" clean
|
||||
@cd ..\jsd\jsdb
|
||||
@cd ..
|
||||
@nmake -f jsd.mak clean
|
||||
@cd jsdb
|
||||
117
mozilla/js/jsd/jsdb/jsdbpriv.h
Normal file
117
mozilla/js/jsd/jsdb/jsdbpriv.h
Normal file
@@ -0,0 +1,117 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Private Headers for JSDB
|
||||
*/
|
||||
|
||||
#ifndef jsdbpriv_h___
|
||||
#define jsdbpriv_h___
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsprf.h"
|
||||
#include "jsdbgapi.h"
|
||||
#include "jsdb.h"
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef struct JSDB_Data
|
||||
{
|
||||
JSDContext* jsdcTarget;
|
||||
JSRuntime* rtTarget;
|
||||
JSRuntime* rtDebugger;
|
||||
JSContext* cxDebugger;
|
||||
JSObject* globDebugger;
|
||||
JSObject* jsdOb;
|
||||
jsval jsScriptHook;
|
||||
jsval jsExecutionHook;
|
||||
jsval jsErrorReporterHook;
|
||||
JSDThreadState* jsdthreadstate;
|
||||
int debuggerDepth;
|
||||
|
||||
} JSDB_Data;
|
||||
|
||||
extern JSBool
|
||||
jsdb_ReflectJSD(JSDB_Data* data);
|
||||
|
||||
/***********************************/
|
||||
/*
|
||||
* System to store JSD_xxx handles in jsvals. This supports tracking the
|
||||
* handle's type - both for debugging and for automatic 'dropping' of
|
||||
* reference counted handle types (e.g. JSDValue).
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
JSDB_GENERIC = 0,
|
||||
JSDB_CONTEXT,
|
||||
JSDB_SCRIPT,
|
||||
JSDB_SOURCETEXT,
|
||||
JSDB_THREADSTATE,
|
||||
JSDB_STACKFRAMEINFO,
|
||||
JSDB_VALUE,
|
||||
JSDB_PROPERTY,
|
||||
JSDB_OBJECT
|
||||
} JSDBHandleType;
|
||||
|
||||
#define H2P_GENERIC(cx,val) (void*) jsdb_HandleValToPointer((cx),(val),JSDB_GENERIC)
|
||||
#define H2P_CONTEXT(cx,val) (JSDContext*) jsdb_HandleValToPointer((cx),(val),JSDB_CONTEXT)
|
||||
#define H2P_SCRIPT(cx,val) (JSDScript*) jsdb_HandleValToPointer((cx),(val),JSDB_SCRIPT)
|
||||
#define H2P_SOURCETEXT(cx,val) (JSDSourceText*) jsdb_HandleValToPointer((cx),(val),JSDB_SOURCETEXT)
|
||||
#define H2P_THREADSTATE(cx,val) (JSDThreadState*) jsdb_HandleValToPointer((cx),(val),JSDB_THREADSTATE)
|
||||
#define H2P_STACKFRAMEINFO(cx,val) (JSDStackFrameInfo*) jsdb_HandleValToPointer((cx),(val),JSDB_STACKFRAMEINFO)
|
||||
#define H2P_VALUE(cx,val) (JSDValue*) jsdb_HandleValToPointer((cx),(val),JSDB_VALUE)
|
||||
#define H2P_PROPERTY(cx,val) (JSDProperty*) jsdb_HandleValToPointer((cx),(val),JSDB_PROPERTY)
|
||||
#define H2P_OBJECT(cx,val) (JSDObject*) jsdb_HandleValToPointer((cx),(val),JSDB_OBJECT)
|
||||
|
||||
#define P2H_GENERIC(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_GENERIC)
|
||||
#define P2H_CONTEXT(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_CONTEXT)
|
||||
#define P2H_SCRIPT(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_SCRIPT)
|
||||
#define P2H_SOURCETEXT(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_SOURCETEXT)
|
||||
#define P2H_THREADSTATE(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_THREADSTATE)
|
||||
#define P2H_STACKFRAMEINFO(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_STACKFRAMEINFO)
|
||||
#define P2H_VALUE(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_VALUE)
|
||||
#define P2H_PROPERTY(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_PROPERTY)
|
||||
#define P2H_OBJECT(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_OBJECT)
|
||||
|
||||
extern jsval
|
||||
jsdb_PointerToNewHandleVal(JSContext *cx, void* ptr, JSDBHandleType type);
|
||||
|
||||
extern void*
|
||||
jsdb_HandleValToPointer(JSContext *cx, jsval val, JSDBHandleType type);
|
||||
|
||||
/***********************************/
|
||||
|
||||
extern JSBool
|
||||
jsdb_SetThreadState(JSDB_Data* data, JSDThreadState* jsdthreadstate);
|
||||
|
||||
extern uintN JS_DLL_CALLBACK
|
||||
jsdb_ExecHookHandler(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
uintN type,
|
||||
void* callerdata,
|
||||
jsval* rval);
|
||||
|
||||
extern JSBool
|
||||
jsdb_EvalReturnExpression(JSDB_Data* data, jsval* rval);
|
||||
|
||||
#endif /* jsdbpriv_h___ */
|
||||
2184
mozilla/js/jsd/jsdb/jsdrefl.c
Normal file
2184
mozilla/js/jsd/jsdb/jsdrefl.c
Normal file
File diff suppressed because it is too large
Load Diff
1
mozilla/js/jsd/jsdb/mk.bat
Executable file
1
mozilla/js/jsd/jsdb/mk.bat
Executable file
@@ -0,0 +1 @@
|
||||
nmake -f jsdb.mak %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
56
mozilla/js/jsd/jsdb/objects.js
Normal file
56
mozilla/js/jsd/jsdb/objects.js
Normal file
@@ -0,0 +1,56 @@
|
||||
// some tests...
|
||||
|
||||
function set_a(a) {this.a = a;}
|
||||
function set_b(b) {this.b = b;}
|
||||
function set_c(c) {this.c = c;}
|
||||
|
||||
function f_ctor(a,b,c)
|
||||
{
|
||||
this.set_a = set_a;
|
||||
this.set_b = set_b;
|
||||
this.set_c = set_c;
|
||||
|
||||
// NOTE: these break JSD_LOWLEVEL_SOURCE in shell debugger
|
||||
this.get_a = new Function("return this.a;");
|
||||
// this.get_b = new Function("return this.b;");
|
||||
// this.get_c = new Function("return this.c;");
|
||||
|
||||
// this.get_a = function() {return this.a;};
|
||||
this.get_b = function() {return this.b;};
|
||||
this.get_c = function() {return this.c;};
|
||||
|
||||
this.set_a(a);
|
||||
this.set_b(b);
|
||||
this.set_c(c);
|
||||
}
|
||||
|
||||
function f2_ctor(param)
|
||||
{
|
||||
this.A = new f_ctor(1,2,3);
|
||||
this.b = new f_ctor("A","B","C");
|
||||
this.number = param;
|
||||
}
|
||||
|
||||
function callMe()
|
||||
{
|
||||
var A = new f2_ctor(1);
|
||||
debugger;
|
||||
var b = new f2_ctor(5);
|
||||
}
|
||||
|
||||
function foo(a,b,c,d,e,f)
|
||||
{
|
||||
var g;
|
||||
var h;
|
||||
var i;
|
||||
var j;
|
||||
debugger;
|
||||
}
|
||||
|
||||
A = new f2_ctor(0);
|
||||
AA = new f2_ctor(100);
|
||||
callMe();
|
||||
foo(1,2,3,4,5);
|
||||
|
||||
A.A.set_b(8);
|
||||
print(A.A.get_b());
|
||||
1
mozilla/js/jsd/jsdb/test.js
Normal file
1
mozilla/js/jsd/jsdb/test.js
Normal file
@@ -0,0 +1 @@
|
||||
load('objects.js')
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
112
mozilla/js/jsd/jsdshell.mak
Normal file
112
mozilla/js/jsd/jsdshell.mak
Normal file
@@ -0,0 +1,112 @@
|
||||
|
||||
PROJ = jsdshell
|
||||
JSD = .
|
||||
JSDJAVA = $(JSD)\java
|
||||
JS = $(JSD)\..\src
|
||||
RUN = $(JSD)\run
|
||||
JSPROJ = js32
|
||||
JSDPROJ = jsd
|
||||
JSDJAVAPROJ = jsdjava
|
||||
|
||||
!IF "$(BUILD_OPT)" != ""
|
||||
OPT = BUILD_OPT=1
|
||||
OBJ = Release
|
||||
CC_FLAGS = /DNDEBUG
|
||||
!ELSE
|
||||
OPT =
|
||||
OBJ = Debug
|
||||
CC_FLAGS = /DDEBUG
|
||||
LINK_FLAGS = /DEBUG
|
||||
!ENDIF
|
||||
|
||||
QUIET=@
|
||||
|
||||
CFLAGS = /nologo /MDd /W3 /Gm /GX /Zi /Od\
|
||||
/I $(JS)\
|
||||
/I $(JSD)\
|
||||
/DDEBUG /DWIN32 /D_CONSOLE /DXP_PC /D_WINDOWS /D_WIN32\
|
||||
/DJSDEBUGGER\
|
||||
!IF "$(JSDEBUGGER_JAVA_UI)" != ""
|
||||
/I $(JSDJAVA)\
|
||||
/DJSDEBUGGER_JAVA_UI\
|
||||
/DJSD_STANDALONE_JAVA_VM\
|
||||
!ENDIF
|
||||
/DJSD_LOWLEVEL_SOURCE\
|
||||
/DJSFILE\
|
||||
$(CC_FLAGS)\
|
||||
/c /Fp$(OBJ)\$(PROJ).pch /Fd$(OBJ)\$(PROJ).pdb /YX -Fo$@ $<
|
||||
|
||||
LFLAGS = /nologo /subsystem:console /incremental:no /machine:I386 \
|
||||
$(LINK_FLAGS) /pdb:$(OBJ)\$(PROJ).pdb -out:$(OBJ)\$(PROJ).exe
|
||||
|
||||
LLIBS = kernel32.lib advapi32.lib \
|
||||
$(JS)\$(OBJ)\$(JSPROJ).lib \
|
||||
$(JSD)\$(OBJ)\$(JSDPROJ).lib \
|
||||
$(JSDJAVA)\$(OBJ)\$(JSDJAVAPROJ).lib
|
||||
|
||||
CPP=cl.exe
|
||||
LINK32=link.exe
|
||||
|
||||
all: $(OBJ) $(RUN) dlls $(OBJ)\$(PROJ).exe copy_binaries
|
||||
|
||||
$(OBJ)\$(PROJ).exe: \
|
||||
$(OBJ)\js.obj
|
||||
$(QUIET)$(LINK32) $(LFLAGS) $** $(LLIBS)
|
||||
|
||||
|
||||
{$(JS)}.c{$(OBJ)}.obj :
|
||||
$(QUIET)$(CPP) $(CFLAGS)
|
||||
|
||||
dlls :
|
||||
$(QUIET)cd ..\src
|
||||
!IF "$(BUILD_OPT)" != ""
|
||||
$(QUIET)nmake -f js.mak CFG="js - Win32 Release"
|
||||
!ELSE
|
||||
$(QUIET)nmake -f js.mak CFG="js - Win32 Debug"
|
||||
!ENDIF
|
||||
$(QUIET)cd ..\jsd
|
||||
$(QUIET)nmake -f jsd.mak JSD_THREADSAFE=1 $(OPT)
|
||||
$(QUIET)cd java
|
||||
$(QUIET)nmake -f jsdjava.mak JSD_STANDALONE_JAVA_VM=1 $(OPT)
|
||||
$(QUIET)cd ..
|
||||
|
||||
copy_binaries :
|
||||
@echo copying binaries
|
||||
$(QUIET)copy $(JS)\$(OBJ)\$(JSPROJ).dll $(RUN) >NUL
|
||||
$(QUIET)copy $(JS)\$(OBJ)\$(JSPROJ).pdb $(RUN) >NUL
|
||||
$(QUIET)copy $(JSD)\$(OBJ)\$(JSDPROJ).dll $(RUN) >NUL
|
||||
$(QUIET)copy $(JSD)\$(OBJ)\$(JSDPROJ).pdb $(RUN) >NUL
|
||||
$(QUIET)copy $(JSDJAVA)\$(OBJ)\$(JSDJAVAPROJ).dll $(RUN) >NUL
|
||||
$(QUIET)copy $(JSDJAVA)\$(OBJ)\$(JSDJAVAPROJ).pdb $(RUN) >NUL
|
||||
$(QUIET)copy $(OBJ)\$(PROJ).pdb $(RUN) >NUL
|
||||
$(QUIET)copy $(OBJ)\$(PROJ).exe $(RUN) >NUL
|
||||
|
||||
$(OBJ) :
|
||||
$(QUIET)mkdir $(OBJ)
|
||||
|
||||
$(RUN) :
|
||||
$(QUIET)mkdir $(RUN)
|
||||
|
||||
clean:
|
||||
@echo deleting old output
|
||||
$(QUIET)del $(OBJ)\js.obj >NUL
|
||||
$(QUIET)del $(OBJ)\$(PROJ).pch >NUL
|
||||
$(QUIET)del $(OBJ)\$(PROJ)*.idb >NUL
|
||||
$(QUIET)del $(OBJ)\$(PROJ).pdb >NUL
|
||||
$(QUIET)del $(OBJ)\$(PROJ).exe >NUL
|
||||
$(QUIET)del $(RUN)\*.pdb >NUL
|
||||
$(QUIET)del $(RUN)\*.exe >NUL
|
||||
$(QUIET)del $(RUN)\*.dll >NUL
|
||||
|
||||
deep_clean: clean
|
||||
$(QUIET)cd ..\src
|
||||
!IF "$(BUILD_OPT)" != ""
|
||||
$(QUIET)nmake -f js.mak CFG="js - Win32 Release" clean
|
||||
!ELSE
|
||||
$(QUIET)nmake -f js.mak CFG="js - Win32 Debug" clean
|
||||
!ENDIF
|
||||
$(QUIET)cd ..\jsd
|
||||
$(QUIET)nmake -f jsd.mak clean
|
||||
$(QUIET)cd java
|
||||
$(QUIET)nmake -f jsdjava.mak clean
|
||||
$(QUIET)cd ..
|
||||
@@ -16,6 +16,10 @@
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* this is all going away... replaced by code in js/jsd/java */
|
||||
|
||||
#if 0
|
||||
|
||||
#ifndef XP_MAC
|
||||
#include "_stubs/netscape_jsdebug_Script.c"
|
||||
#include "_stubs/netscape_jsdebug_DebugController.c"
|
||||
@@ -31,3 +35,5 @@
|
||||
#include "netscape_jsdebug_JSPC.c"
|
||||
#include "n_j_JSSourceTextProvider.c"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,35 +1,29 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#// The contents of this file are subject to the Netscape Public License
|
||||
#// Version 1.0 (the "NPL"); you may not use this file except in
|
||||
#// compliance with the NPL. You may obtain a copy of the NPL at
|
||||
#// http://www.mozilla.org/NPL/
|
||||
#//
|
||||
#// Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
#// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
#// for the specific language governing rights and limitations under the
|
||||
#// NPL.
|
||||
#//
|
||||
#// The Initial Developer of this code under the NPL is Netscape
|
||||
#// Communications Corporation. Portions created by Netscape are
|
||||
#// Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
#// Reserved.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
#
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify the depth of the current directory relative to the
|
||||
#// root of NS
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DEPTH=..\..
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
DEPTH = ..\..
|
||||
|
||||
# Turn on/off depending on
|
||||
!ifdef MOZ_JSD
|
||||
DIRS = classes
|
||||
!ifdef MOZ_OJI
|
||||
# DIRS = java classes
|
||||
!endif
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
@@ -41,87 +35,58 @@ DIRS = classes
|
||||
DLLNAME = jsd$(MOZ_BITS)$(VERSION_NUMBER)
|
||||
PDBFILE = $(DLLNAME).pdb
|
||||
MAPFILE = $(DLLNAME).map
|
||||
RESFILE = $(DLLNAME).res
|
||||
RESFILE = jsd$(MOZ_BITS)40.res
|
||||
DLL =.\$(OBJDIR)\$(DLLNAME).dll
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
|
||||
!if "$(MOZ_BITS)" != "16"
|
||||
LINCS = -I$(PUBLIC)/java \
|
||||
-I$(PUBLIC)/applet \
|
||||
-I$(DEPTH)\include
|
||||
LINCS = -I$(DEPTH)\include \
|
||||
-I$(PUBLIC)\js
|
||||
!endif
|
||||
|
||||
!if "$(MOZ_BITS)" == "16"
|
||||
DEFFILE = $(DLLNAME).def
|
||||
!endif
|
||||
|
||||
# LCFLAGS= $(LCFLAGS) -DEXPORT_JSD_API -DJSD_THREADSAFE
|
||||
|
||||
LLIBS= $(LIBNSPR) \
|
||||
$(DIST)\lib\js$(MOZ_BITS)$(VERSION_NUMBER).lib \
|
||||
$(DIST)\lib\jrt$(MOZ_BITS)$(VERSION_NUMBER).lib
|
||||
!ifdef MOZ_OJI
|
||||
$(DIST)\lib\oji$(MOZ_BITS).lib
|
||||
!endif
|
||||
|
||||
!if "$(MOZ_BITS)"=="32" && defined(MOZ_DEBUG) && defined(GLOWCODE)
|
||||
LLIBS=$(LLIBS) $(GLOWDIR)\glowcode.lib
|
||||
!endif
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define the files necessary to build the target (ie. OBJS)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\jsdebug.obj \
|
||||
.\$(OBJDIR)\jsd_high.obj \
|
||||
.\$(OBJDIR)\jsd_hook.obj \
|
||||
.\$(OBJDIR)\jsd_lock.obj \
|
||||
.\$(OBJDIR)\jsd_scpt.obj \
|
||||
.\$(OBJDIR)\jsd_stak.obj \
|
||||
.\$(OBJDIR)\jsd_step.obj \
|
||||
.\$(OBJDIR)\jsd_text.obj \
|
||||
.\$(OBJDIR)\jsd_val.obj \
|
||||
$(NULL)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// install headers
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
INSTALL_DIR=$(PUBLIC)\jsdebug
|
||||
|
||||
INSTALL_DIR=$(PUBLIC)\jsd
|
||||
INSTALL_FILE_LIST= \
|
||||
jsdebug.h \
|
||||
$(NULL)
|
||||
|
||||
|
||||
MODULE=jsdebug
|
||||
|
||||
REQUIRES=java js nspr
|
||||
|
||||
CSRCS= \
|
||||
jsdebug.c \
|
||||
jsd_high.c \
|
||||
jsd_hook.c \
|
||||
!ifdef MOZ_JSD
|
||||
jsdstubs.c \
|
||||
jsd_java.c \
|
||||
!endif
|
||||
jsd_scpt.c \
|
||||
jsd_stak.c \
|
||||
jsd_text.c
|
||||
|
||||
LIBRARY_NAME=jsd
|
||||
|
||||
!ifdef MOZ_JSD
|
||||
JDK_GEN=netscape.jsdebug.Script netscape.jsdebug.DebugController \
|
||||
netscape.jsdebug.JSThreadState netscape.jsdebug.JSStackFrameInfo \
|
||||
netscape.jsdebug.JSPC netscape.jsdebug.JSSourceTextProvider \
|
||||
netscape.jsdebug.JSErrorReporter
|
||||
!endif
|
||||
|
||||
EXPORTS=jsdebug.h
|
||||
|
||||
C_OBJS= \
|
||||
.\$(OBJDIR)\jsdebug.obj \
|
||||
.\$(OBJDIR)\jsd_high.obj \
|
||||
.\$(OBJDIR)\jsd_hook.obj \
|
||||
!ifdef MOZ_JSD
|
||||
.\$(OBJDIR)\jsdstubs.obj \
|
||||
.\$(OBJDIR)\jsd_java.obj \
|
||||
!endif
|
||||
.\$(OBJDIR)\jsd_scpt.obj \
|
||||
.\$(OBJDIR)\jsd_stak.obj \
|
||||
.\$(OBJDIR)\jsd_text.obj
|
||||
|
||||
|
||||
!if "$(MOZ_BITS)" != "16"
|
||||
LINCS=-I$(XPDIST)\public\java -I$(XPDIST)\public\js \
|
||||
-I$(XPDIST)\public\nspr
|
||||
!endif
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Include the common makefile rules
|
||||
@@ -133,18 +98,6 @@ install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
$(RM_R) _gen
|
||||
$(RM_R) _stubs
|
||||
|
||||
.\$(OBJDIR)\jsdstubs.o: \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_Script.c \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_DebugController.c \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_JSThreadState.c \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_JSStackFrameInfo.c \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_JSPC.c \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_JSSourceTextProvider.c
|
||||
|
||||
export:: INSTALL_FILES
|
||||
|
||||
|
||||
|
||||
4
mozilla/js/jsd/mkshell.bat
Executable file
4
mozilla/js/jsd/mkshell.bat
Executable file
@@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
REM nmake -f jsdshell.mak JSDEBUGGER_JAVA_UI=1 LIVECONNECT=1 %1 %2 %3 %4 %5
|
||||
@echo on
|
||||
nmake -f jsdshell.mak JSDEBUGGER_JAVA_UI=1 %1 %2 %3 %4 %5
|
||||
@@ -11,6 +11,7 @@ The notable subdirs are:
|
||||
build - stuff to build the code
|
||||
classes - trees of source files
|
||||
dist - generated output dir
|
||||
doc - some documents
|
||||
ifcui - auxilary pieces of the JavaScript Debugger
|
||||
jslogger - auxilary pieces of a smaple JavaScript logging app
|
||||
stub_classes - stubbed out mozilla classes to allow standalone debugging
|
||||
@@ -22,9 +23,3 @@ The source to the debugger lives in:
|
||||
All building is done in:
|
||||
jsdj/build
|
||||
|
||||
***************************************************************************
|
||||
*** 09/15/98
|
||||
*** NOTE: some of this relates to code in js/jsd that is not yet checked in.
|
||||
*** New stuff in js/jsd will go in when new js/src lands (later this week).
|
||||
*** I decided to check this in anyway...
|
||||
***************************************************************************
|
||||
|
||||
@@ -13,7 +13,7 @@ to the public. The flag 'NO_RHINO=1' is necessary for many of the makefile
|
||||
targets when used outside of Netscape.
|
||||
|
||||
There is code here to also build a Corba/iiop connection for remote debugging to
|
||||
a Netscape Internal version of Enterprise Server 3.51. This is not fully
|
||||
a Netscape internal version of Enterprise Server 3.51. This is not fully
|
||||
functional on the server side. You should normally use the NO_CORBA=1 build
|
||||
flag. If you want to play with this stuff then you need an install of ES3.51 and
|
||||
you need to set the ES3_ROOT environment variable to point to that install.
|
||||
@@ -29,5 +29,43 @@ up to date :).
|
||||
|
||||
There are a few .bat files for convenience to build the targets I often build.
|
||||
|
||||
'mk_ifcui_std_with_rhino.bat' will build the whole thing (except Corba parts)
|
||||
and ASSUMEs that you want Rhino support and that you have already built Rhino
|
||||
in the 'correct' relative directory.
|
||||
|
||||
The directory structure used at Netscape for Rhino is:
|
||||
|
||||
someroot/ns/js/rhino
|
||||
someroot/mozilla/js/src
|
||||
someroot/mozilla/js/jsd
|
||||
someroot/mozilla/js/jsdj
|
||||
|
||||
where 'someroot' can be anything. The salient point is that from the jsdj/build
|
||||
directory the relative path to the rhino classes is:
|
||||
|
||||
.\..\..\..\..\ns\js\rhino
|
||||
|
||||
This can be adjusted by hacking the 'RHINO_CLASSES' var near the top of
|
||||
jsdj.mak.
|
||||
|
||||
------------------------
|
||||
FOR THE JS 1.4 RELEASE:
|
||||
|
||||
Rhino (JavaScript for Java) is packaged as 'jsjava.jar'. It unzips so that the
|
||||
root directory is named 'jsjava'.
|
||||
|
||||
To simplify building js/jsdj for this release jsdj.mak has been modified to
|
||||
include:
|
||||
|
||||
RHINO_CLASSROOT = $(BUILD_DIR)\..\..\jsjava
|
||||
RHINO_CLASSES = $(RHINO_CLASSROOT)\js.jar;$(RHINO_CLASSROOT)\jsdebug.jar
|
||||
|
||||
This supports unzipping jsjava.jar into mozilla/js for a directory tree like:
|
||||
|
||||
someroot/mozilla/js/jsjava
|
||||
someroot/mozilla/js/src
|
||||
someroot/mozilla/js/jsd
|
||||
someroot/mozilla/js/jsdj
|
||||
|
||||
mk_ifcui_std_with_rhino.bat can then be run from mozilla/js/jsdj/build to build
|
||||
all of js/jsdj including Rhino support.
|
||||
|
||||
31
mozilla/js/jsdj/build/gen_date.awk
Normal file
31
mozilla/js/jsdj/build/gen_date.awk
Normal file
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# This requires -vpackage_name=whatever.the.name.of.the.package.is
|
||||
#
|
||||
|
||||
BEGIN{
|
||||
print
|
||||
print "/* generated by gen_date.awk to provide access to build date at runtime */"
|
||||
print
|
||||
print "package "package_name";"
|
||||
print
|
||||
print "class BuildDate"
|
||||
print "{"
|
||||
print strftime(" // %A, %B %d, %Y at %I:%M %p");
|
||||
print
|
||||
print " public static final long buildDate = " systime() "000L;"
|
||||
print
|
||||
print " public static final java.util.Date date()"
|
||||
print " {"
|
||||
print " return new java.util.Date(buildDate);"
|
||||
print " }"
|
||||
print
|
||||
print " public static final String display()"
|
||||
print " {"
|
||||
print " return date().toString();"
|
||||
print " }"
|
||||
print "}"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
16
mozilla/js/jsdj/build/gen_dbg.awk
Normal file
16
mozilla/js/jsdj/build/gen_dbg.awk
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# This requires -vpackage_name=name.of.the.package -vvalue=[true|false]
|
||||
#
|
||||
|
||||
BEGIN{
|
||||
print
|
||||
print "/* generated by gen_dbg.awk to set DEBUG on or off */"
|
||||
print
|
||||
print "package "package_name";"
|
||||
print
|
||||
print "public interface AS"
|
||||
print "{"
|
||||
print " public static final boolean S = "value";"
|
||||
print " public static final boolean DEBUG = "value";"
|
||||
print "}"
|
||||
}
|
||||
534
mozilla/js/jsdj/build/jsdj.mak
Normal file
534
mozilla/js/jsdj/build/jsdj.mak
Normal file
@@ -0,0 +1,534 @@
|
||||
# jband - 09/14/98
|
||||
|
||||
BUILD_DIR = .
|
||||
DIST = $(BUILD_DIR)\..\dist
|
||||
DIST_CLASSES = $(BUILD_DIR)\..\dist\classes
|
||||
CLASS_SRC = $(BUILD_DIR)\..\classes
|
||||
|
||||
JSDEBUGGING_DIR = $(BUILD_DIR)\..\classes\com\netscape\jsdebugging
|
||||
PALOMAR_DIR = $(JSDEBUGGING_DIR)\ifcui\palomar
|
||||
|
||||
IFC_DIST_FILE = $(DIST_CLASSES)\ifc11.jar
|
||||
|
||||
!IF "$(NO_RHINO)" == ""
|
||||
RHINO_CLASSROOT = $(BUILD_DIR)\..\..\jsjava
|
||||
RHINO_CLASSES = $(RHINO_CLASSROOT)\js.jar;$(RHINO_CLASSROOT)\jsdebug.jar
|
||||
|
||||
#RHINO_CLASSES = $(BUILD_DIR)\..\..\..\..\ns\js\rhino
|
||||
!ENDIF
|
||||
|
||||
#these are used for CD
|
||||
FROM_BUILD_TO_DIST_CLASSES = ..\dist\classes
|
||||
FROM_DIST_CLASSES_TO_BUILD = ..\..\build
|
||||
|
||||
JSLOGGER_JARFILE = jslogger.jar
|
||||
JSLOGGER_MAIN_DIR = $(BUILD_DIR)\..\jslogger
|
||||
|
||||
NETSCAPE_JSDEBUG_JARFILE = jsd11.jar
|
||||
|
||||
IFCUI_JARFILE = jsdeb12.jar
|
||||
IFCUI_RUN_DIR = $(BUILD_DIR)\..\ifcui\run
|
||||
|
||||
OUR_CLASSPATH = $(DIST_CLASSES);$(IFC_DIST_FILE);$(RHINO_CLASSES);$(CLASSPATH)
|
||||
STD_JAVA_FLAGS = -d $(DIST_CLASSES) -classpath $(OUR_CLASSPATH)
|
||||
|
||||
CORBA_CLASSPATH = $(OUR_CLASSPATH);$(ES3_ROOT)\wai\java\nisb.zip;$(ES3_ROOT)\wai\java\WAI.zip;$(ES3_ROOT)\plugins\Java\classes\serv3_0.zip
|
||||
CORBA_JAVA_FLAGS = -d $(DIST_CLASSES) -classpath $(CORBA_CLASSPATH)
|
||||
|
||||
!IF "$(NO_CORBA)" == ""
|
||||
JAVADOC_CLASSPATH = $(CORBA_CLASSPATH)
|
||||
!ELSE
|
||||
JAVADOC_CLASSPATH = $(OUR_CLASSPATH)
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(BUILD_OPT)" != ""
|
||||
JAVAFLAGS = $(STD_JAVA_FLAGS) -O
|
||||
!ELSE
|
||||
JAVAFLAGS = $(STD_JAVA_FLAGS) -g
|
||||
!ENDIF
|
||||
|
||||
all: core jsdb ifcui ifcui_lanchers jslogger apitests tools \
|
||||
dependency_checks jars netscape_applet javadoc_all
|
||||
|
||||
all_clean : clean all
|
||||
|
||||
help :
|
||||
@echo targets:
|
||||
@echo --------
|
||||
@echo all
|
||||
@echo all_clean
|
||||
@echo help
|
||||
@echo clean
|
||||
@echo core
|
||||
@echo jsdb
|
||||
@echo apitests
|
||||
@echo ifcui
|
||||
@echo ifcui_fast
|
||||
@echo ifcui_lanchers
|
||||
@echo jslogger
|
||||
@echo jslogger_fast
|
||||
@echo depend_tool
|
||||
@echo tools
|
||||
@echo dependency_checks
|
||||
@echo jars
|
||||
@echo netscape_security
|
||||
@echo netscape_jsdebug
|
||||
@echo netscape_javascript
|
||||
@echo netscape_applet
|
||||
@echo com_netscape_nativejsengine
|
||||
@echo com_netscape_jsdebugging_api
|
||||
@echo com_netscape_jsdebugging_engine
|
||||
@echo com_netscape_jsdebugging_api_local
|
||||
@echo com_netscape_jsdebugging_engine_local
|
||||
@echo com_netscape_jsdebugging_api_rhino
|
||||
@echo com_netscape_jsdebugging_engine_rhino
|
||||
@echo com_netscape_jsdebugging_jsdb
|
||||
@echo com_netscape_jsdebugging_ifcui_palomar
|
||||
@echo com_netscape_jsdebugging_ifcui
|
||||
@echo com_netscape_jsdebugging_ifcui_launcher_local
|
||||
@echo com_netscape_jsdebugging_ifcui_launcher_rhino
|
||||
@echo com_netscape_jsdebugging_apitests
|
||||
@echo com_netscape_jsdebugging_jslogger
|
||||
@echo com_netscape_jsdebugging_tools_depend
|
||||
@echo check_depend_jslogger
|
||||
@echo jslogger_jar
|
||||
@echo check_depend_netscape_jsdebug
|
||||
@echo netscape_jsdebug_jar
|
||||
|
||||
core: initial_state \
|
||||
netscape_security \
|
||||
netscape_jsdebug \
|
||||
com_netscape_jsdebugging_api \
|
||||
com_netscape_jsdebugging_engine \
|
||||
com_netscape_jsdebugging_api_local \
|
||||
com_netscape_jsdebugging_engine_local \
|
||||
!IF "$(NO_RHINO)" == ""
|
||||
com_netscape_jsdebugging_api_rhino \
|
||||
com_netscape_jsdebugging_engine_rhino \
|
||||
!ENDIF
|
||||
!IF "$(NO_CORBA)" == ""
|
||||
com_netscape_jsdebugging_remote_corba \
|
||||
com_netscape_jsdebugging_api_corba \
|
||||
!ENDIF
|
||||
|
||||
jsdb : com_netscape_jsdebugging_jsdb
|
||||
|
||||
apitests : com_netscape_jsdebugging_apitests
|
||||
|
||||
ifcui : initial_state \
|
||||
netscape_security \
|
||||
netscape_javascript \
|
||||
netscape_jsdebug \
|
||||
com_netscape_jsdebugging_api \
|
||||
com_netscape_jsdebugging_ifcui_palomar \
|
||||
com_netscape_jsdebugging_ifcui \
|
||||
CP_DIST_CLASSES_RESOURCES
|
||||
|
||||
ifcui_fast : com_netscape_jsdebugging_ifcui
|
||||
|
||||
ifcui_lanchers : com_netscape_jsdebugging_ifcui_launcher_local \
|
||||
!IF "$(NO_RHINO)" == ""
|
||||
com_netscape_jsdebugging_ifcui_launcher_rhino
|
||||
!ENDIF
|
||||
|
||||
jslogger : ifcui com_netscape_jsdebugging_jslogger
|
||||
|
||||
jslogger_fast : com_netscape_jsdebugging_jslogger
|
||||
|
||||
depend_tool : initial_state com_netscape_jsdebugging_tools_depend
|
||||
|
||||
tools : depend_tool
|
||||
|
||||
dependency_checks : check_depend_jslogger \
|
||||
check_depend_netscape_jsdebug \
|
||||
check_depend_ifcui
|
||||
|
||||
jars : jslogger_jar \
|
||||
netscape_jsdebug_jar \
|
||||
ifcui_jar
|
||||
|
||||
netscape_security : initial_state
|
||||
@echo building stubbed netscape.security classes
|
||||
@sj $(JAVAFLAGS) $(BUILD_DIR)\..\stub_classes\netscape\security\*.java
|
||||
|
||||
netscape_applet : initial_state
|
||||
@echo building stubbed netscape.applet classes
|
||||
@sj $(JAVAFLAGS) $(BUILD_DIR)\..\stub_classes\netscape\applet\*.java
|
||||
|
||||
netscape_jsdebug : netscape_security
|
||||
@echo building netscape.jsdebug
|
||||
@sj $(JAVAFLAGS) $(BUILD_DIR)\..\classes\netscape\jsdebug\*.java
|
||||
|
||||
netscape_javascript: netscape_security
|
||||
@echo building netscape.javascript
|
||||
@sj $(JAVAFLAGS) $(BUILD_DIR)\..\stub_classes\netscape\javascript\*.java
|
||||
|
||||
com_netscape_jsdebugging_api : netscape_security
|
||||
@echo building com.netscape.jsdebugging.api
|
||||
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\api\*.java
|
||||
|
||||
com_netscape_jsdebugging_engine : com_netscape_jsdebugging_api
|
||||
@echo building com.netscape.jsdebugging.engine
|
||||
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\engine\*.java
|
||||
|
||||
com_netscape_jsdebugging_api_local : com_netscape_jsdebugging_api netscape_jsdebug
|
||||
@echo building com.netscape.jsdebugging.api.local
|
||||
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\api\local\*.java
|
||||
|
||||
com_netscape_jsdebugging_engine_local : com_netscape_nativejsengine com_netscape_jsdebugging_engine netscape_jsdebug
|
||||
@echo building com.netscape.jsdebugging.engine.local
|
||||
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\engine\local\*.java
|
||||
|
||||
com_netscape_nativejsengine :
|
||||
@echo building com.netscape.nativejsengine
|
||||
@sj $(JAVAFLAGS) $(CLASS_SRC)\com\netscape\nativejsengine\*.java
|
||||
|
||||
com_netscape_jsdebugging_api_rhino : com_netscape_jsdebugging_api
|
||||
@echo building com.netscape.jsdebugging.api.rhino
|
||||
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\api\rhino\*.java
|
||||
|
||||
com_netscape_jsdebugging_engine_rhino : com_netscape_jsdebugging_engine
|
||||
@echo building com.netscape.jsdebugging.engine.rhino
|
||||
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\engine\rhino\*.java
|
||||
|
||||
com_netscape_jsdebugging_jsdb : core
|
||||
@echo building com.netscape.jsdebugging.jsdb
|
||||
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\jsdb\*.java
|
||||
|
||||
com_netscape_jsdebugging_ifcui_palomar : initial_state
|
||||
@echo building com.netscape.jsdebugging.ifcui.palomar etc...
|
||||
@sj $(JAVAFLAGS)\
|
||||
$(PALOMAR_DIR)\util\*.java\
|
||||
$(PALOMAR_DIR)\widget\*.java\
|
||||
$(PALOMAR_DIR)\widget\layout\*.java\
|
||||
$(PALOMAR_DIR)\widget\layout\math\*.java\
|
||||
$(PALOMAR_DIR)\widget\toolbar\*.java\
|
||||
$(PALOMAR_DIR)\widget\toolTip\*.java
|
||||
|
||||
com_netscape_jsdebugging_ifcui :
|
||||
@echo generating com.netscape.jsdebugging.ifcui.BuildDate
|
||||
@gawk -f $(BUILD_DIR)\gen_date.awk -vpackage_name=com.netscape.jsdebugging.ifcui > $(JSDEBUGGING_DIR)\ifcui\BuildDate.java
|
||||
@echo building com.netscape.jsdebugging.ifcui
|
||||
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\ifcui\*.java
|
||||
|
||||
com_netscape_jsdebugging_ifcui_launcher_local : ifcui
|
||||
@echo building com.netscape.jsdebugging.ifcui.launcher.local
|
||||
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\ifcui\launcher\local\*.java
|
||||
|
||||
com_netscape_jsdebugging_ifcui_launcher_rhino : com_netscape_jsdebugging_api_rhino ifcui
|
||||
@echo building com.netscape.jsdebugging.ifcui.launcher.rhino
|
||||
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\ifcui\launcher\rhino\*.java
|
||||
|
||||
com_netscape_jsdebugging_apitests : core
|
||||
@echo building com.netscape.jsdebugging.apitests etc...
|
||||
@sj $(JAVAFLAGS)\
|
||||
$(JSDEBUGGING_DIR)\apitests\*.java\
|
||||
$(JSDEBUGGING_DIR)\apitests\xml\*.java\
|
||||
$(JSDEBUGGING_DIR)\apitests\testing\*.java\
|
||||
$(JSDEBUGGING_DIR)\apitests\testing\desc\*.java\
|
||||
$(JSDEBUGGING_DIR)\apitests\testing\tests\*.java\
|
||||
$(JSDEBUGGING_DIR)\apitests\analyzing\*.java\
|
||||
$(JSDEBUGGING_DIR)\apitests\analyzing\analyzers\*.java\
|
||||
$(JSDEBUGGING_DIR)\apitests\analyzing\data\*.java\
|
||||
$(JSDEBUGGING_DIR)\apitests\analyzing\tree\*.java
|
||||
|
||||
com_netscape_jsdebugging_jslogger :
|
||||
@echo building com.netscape.jsdebugging.jslogger
|
||||
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\jslogger\*.java
|
||||
|
||||
com_netscape_jsdebugging_tools_depend :
|
||||
@echo building com.netscape.jsdebugging.tools.depend
|
||||
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\tools\depend\*.java
|
||||
|
||||
com_netscape_jsdebugging_remote_corba : initial_state
|
||||
@echo building com.netscape.jsdebugging.remote.corba
|
||||
@if "$(ES3_ROOT)" == "" @echo !!! ES3_ROOT is not set !!!
|
||||
@if not exist $(ES3_ROOT)\NUL @echo !!! $(ES3_ROOT) does not exist !!!
|
||||
@sj $(CORBA_JAVA_FLAGS) \
|
||||
$(JSDEBUGGING_DIR)\remote\corba\*.java \
|
||||
$(JSDEBUGGING_DIR)\remote\corba\ISourceTextProviderPackage\*.java \
|
||||
$(JSDEBUGGING_DIR)\remote\corba\TestInterfacePackage\*.java \
|
||||
|
||||
com_netscape_jsdebugging_api_corba : com_netscape_jsdebugging_api com_netscape_jsdebugging_remote_corba ifcui
|
||||
@echo building com.netscape.jsdebugging.api.corba
|
||||
@sj $(CORBA_JAVA_FLAGS) $(JSDEBUGGING_DIR)\api\corba\*.java
|
||||
|
||||
api_corba_fast :
|
||||
@echo building com.netscape.jsdebugging.api.corba
|
||||
@sj $(CORBA_JAVA_FLAGS) $(JSDEBUGGING_DIR)\api\corba\*.java
|
||||
|
||||
palomar_assert_on :
|
||||
@echo generating com.netscape.jsdebugging.ifcui.palomar.util with assert on
|
||||
@gawk -f $(BUILD_DIR)\gen_dbg.awk -vvalue=true -vpackage_name=com.netscape.jsdebugging.ifcui.palomar.util > $(JSDEBUGGING_DIR)\ifcui\palomar\util\AS.java
|
||||
@echo building com.netscape.jsdebugging.ifcui.palomar.util
|
||||
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\ifcui\palomar\util\*.java
|
||||
|
||||
palomar_assert_off :
|
||||
@echo generating com.netscape.jsdebugging.ifcui.palomar.util with assert on
|
||||
@gawk -f $(BUILD_DIR)\gen_dbg.awk -vvalue=false -vpackage_name=com.netscape.jsdebugging.ifcui.palomar.util > $(JSDEBUGGING_DIR)\ifcui\palomar\util\AS.java
|
||||
@echo building com.netscape.jsdebugging.ifcui.palomar.util
|
||||
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\ifcui\palomar\util\*.java
|
||||
|
||||
########## packaging #################
|
||||
|
||||
JSLOGGER_CLASS_FILES = \
|
||||
com\netscape\jsdebugging\jslogger\*.class \
|
||||
com\netscape\jsdebugging\ifcui\Log.class \
|
||||
com\netscape\jsdebugging\ifcui\Env.class \
|
||||
com\netscape\jsdebugging\ifcui\palomar\util\*.class
|
||||
|
||||
JSLOGGER_EXPECTED_DEPENDENCIES = \
|
||||
-i java \
|
||||
-i netscape/application \
|
||||
-i netscape/util \
|
||||
-i netscape/jsdebug \
|
||||
-i netscape/security
|
||||
|
||||
check_depend_jslogger :
|
||||
@echo checking for unexpected dependencies in jslogger
|
||||
@cd $(FROM_BUILD_TO_DIST_CLASSES)
|
||||
@jre -cp . com.netscape.jsdebugging.tools.depend.Main \
|
||||
$(JSLOGGER_CLASS_FILES) $(JSLOGGER_EXPECTED_DEPENDENCIES)
|
||||
@cd $(FROM_DIST_CLASSES_TO_BUILD)
|
||||
|
||||
jslogger_jar :
|
||||
@echo building $(JSLOGGER_JARFILE)
|
||||
@cd $(FROM_BUILD_TO_DIST_CLASSES)
|
||||
@if exist $(JSLOGGER_JARFILE) @del $(JSLOGGER_JARFILE) >NUL
|
||||
@zip -q -r $(JSLOGGER_JARFILE) $(JSLOGGER_CLASS_FILES)
|
||||
@cd $(FROM_DIST_CLASSES_TO_BUILD)
|
||||
@echo copying $(JSLOGGER_JARFILE) to $(JSLOGGER_MAIN_DIR)
|
||||
@copy $(DIST_CLASSES)\$(JSLOGGER_JARFILE) $(JSLOGGER_MAIN_DIR) >NUL
|
||||
|
||||
##########
|
||||
|
||||
NETSCAPE_JSDEBUG_CLASS_FILES = netscape\jsdebug\*.class
|
||||
|
||||
NETSCAPE_JSDEBUG_EXPECTED_DEPENDENCIES = \
|
||||
-i java \
|
||||
-i netscape/security \
|
||||
-i netscape/util \
|
||||
|
||||
check_depend_netscape_jsdebug :
|
||||
@echo checking for unexpected dependencies in netscape.jsdebug
|
||||
@cd $(FROM_BUILD_TO_DIST_CLASSES)
|
||||
@jre -cp . com.netscape.jsdebugging.tools.depend.Main \
|
||||
$(NETSCAPE_JSDEBUG_CLASS_FILES) $(NETSCAPE_JSDEBUG_EXPECTED_DEPENDENCIES)
|
||||
@cd $(FROM_DIST_CLASSES_TO_BUILD)
|
||||
|
||||
netscape_jsdebug_jar :
|
||||
@echo building $(NETSCAPE_JSDEBUG_JARFILE)
|
||||
@cd $(FROM_BUILD_TO_DIST_CLASSES)
|
||||
@if exist $(NETSCAPE_JSDEBUG_JARFILE) @del $(NETSCAPE_JSDEBUG_JARFILE) >NUL
|
||||
@zip -q -r $(NETSCAPE_JSDEBUG_JARFILE) $(NETSCAPE_JSDEBUG_CLASS_FILES)
|
||||
@cd $(FROM_DIST_CLASSES_TO_BUILD)
|
||||
# @echo copying $(JSLOGGER_JARFILE) to $(JSLOGGER_MAIN_DIR)
|
||||
# @copy $(DIST_CLASSES)\$(JSLOGGER_JARFILE) $(JSLOGGER_MAIN_DIR) >NUL
|
||||
|
||||
##########
|
||||
|
||||
IFCUI_CLASS_FILES = \
|
||||
com\netscape\jsdebugging\ifcui\*.class \
|
||||
com\netscape\jsdebugging\ifcui\palomar\util\*.class \
|
||||
com\netscape\jsdebugging\ifcui\palomar\widget\*.class \
|
||||
com\netscape\jsdebugging\ifcui\palomar\widget\layout\*.class \
|
||||
com\netscape\jsdebugging\ifcui\palomar\widget\layout\math\*.class \
|
||||
com\netscape\jsdebugging\ifcui\palomar\widget\toolbar\*.class \
|
||||
com\netscape\jsdebugging\ifcui\palomar\widget\toolTip\*.class \
|
||||
com\netscape\jsdebugging\api\*.class \
|
||||
!IF "$(INCLUDE_SECURITY)" != ""
|
||||
netscape\security\*.class \
|
||||
!ENDIF
|
||||
!IF "$(INCLUDE_LOCAL_ADAPTER)" != ""
|
||||
com\netscape\jsdebugging\api\local\*.class \
|
||||
!ENDIF
|
||||
!IF "$(INCLUDE_RHINO_ADAPTER)" != ""
|
||||
com\netscape\jsdebugging\api\rhino\*.class \
|
||||
!ENDIF
|
||||
!IF "$(INCLUDE_CORBA_ADAPTER)" != ""
|
||||
com\netscape\jsdebugging\api\corba\*.class \
|
||||
!ENDIF
|
||||
!IF "$(INCLUDE_LOCAL_LAUNCHER)" != ""
|
||||
com\netscape\jsdebugging\ifcui\launcher\local\*.class \
|
||||
!ENDIF
|
||||
!IF "$(INCLUDE_RHINO_LAUNCHER)" != ""
|
||||
com\netscape\jsdebugging\ifcui\launcher\rhino\*.class \
|
||||
!ENDIF
|
||||
|
||||
IFCUI_OTHER_FILES = \
|
||||
!IF "$(INCLUDE_IMAGES)" != ""
|
||||
images\*.gif \
|
||||
!ENDIF
|
||||
!IF "$(INCLUDE_SOUNDS)" != ""
|
||||
sounds\*.au \
|
||||
!ENDIF
|
||||
|
||||
IFCUI_EXPECTED_DEPENDENCIES = \
|
||||
-i java \
|
||||
-i netscape/security \
|
||||
-i netscape/util \
|
||||
-i netscape/application \
|
||||
-i netscape/javascript \
|
||||
!IF "$(INCLUDE_LOCAL_ADAPTER)" != ""
|
||||
-i netscape/jsdebug \
|
||||
!ENDIF
|
||||
!IF "$(INCLUDE_RHINO_ADAPTER)" != ""
|
||||
-i com/netscape/javascript \
|
||||
!ENDIF
|
||||
|
||||
check_depend_ifcui :
|
||||
@echo checking for unexpected dependencies for ifcui
|
||||
@cd $(FROM_BUILD_TO_DIST_CLASSES)
|
||||
@jre -cp . com.netscape.jsdebugging.tools.depend.Main \
|
||||
$(IFCUI_CLASS_FILES) $(IFCUI_EXPECTED_DEPENDENCIES)
|
||||
@cd $(FROM_DIST_CLASSES_TO_BUILD)
|
||||
|
||||
ifcui_jar :
|
||||
@echo building $(IFCUI_JARFILE)
|
||||
@cd $(FROM_BUILD_TO_DIST_CLASSES)
|
||||
@if exist $(IFCUI_JARFILE) @del $(IFCUI_JARFILE) >NUL
|
||||
@zip -q -r $(IFCUI_JARFILE) $(IFCUI_CLASS_FILES) $(IFCUI_OTHER_FILES)
|
||||
@cd $(FROM_DIST_CLASSES_TO_BUILD)
|
||||
@echo copying $(IFCUI_JARFILE) to $(IFCUI_RUN_DIR)
|
||||
@copy $(DIST_CLASSES)\$(IFCUI_JARFILE) $(IFCUI_RUN_DIR) >NUL
|
||||
|
||||
|
||||
########## javadoc stuff #################
|
||||
|
||||
ALL_PACKAGES = \
|
||||
netscape.security \
|
||||
netscape.jsdebug \
|
||||
netscape.javascript \
|
||||
netscape.applet \
|
||||
com.netscape.jsdebugging.api \
|
||||
com.netscape.jsdebugging.api.local \
|
||||
com.netscape.jsdebugging.engine \
|
||||
com.netscape.jsdebugging.engine.local \
|
||||
com.netscape.jsdebugging.jsdb \
|
||||
com.netscape.jsdebugging.ifcui \
|
||||
com.netscape.jsdebugging.ifcui.palomar.util \
|
||||
com.netscape.jsdebugging.ifcui.palomar.widget \
|
||||
com.netscape.jsdebugging.ifcui.palomar.widget.layout \
|
||||
com.netscape.jsdebugging.ifcui.palomar.widget.layout.math \
|
||||
com.netscape.jsdebugging.ifcui.palomar.widget.toolbar \
|
||||
com.netscape.jsdebugging.ifcui.palomar.widget.toolTip \
|
||||
com.netscape.jsdebugging.ifcui.launcher.local \
|
||||
com.netscape.jsdebugging.apitests \
|
||||
com.netscape.jsdebugging.apitests.xml \
|
||||
com.netscape.jsdebugging.apitests.testing \
|
||||
com.netscape.jsdebugging.apitests.testing.desc \
|
||||
com.netscape.jsdebugging.apitests.testing.tests \
|
||||
com.netscape.jsdebugging.apitests.analyzing.analyzers \
|
||||
com.netscape.jsdebugging.apitests.analyzing.data \
|
||||
com.netscape.jsdebugging.apitests.analyzing.tree \
|
||||
com.netscape.jsdebugging.jslogger \
|
||||
com.netscape.jsdebugging.tools.depend \
|
||||
com.netscape.nativejsengine \
|
||||
!IF "$(NO_RHINO)" == ""
|
||||
com.netscape.jsdebugging.api.rhino \
|
||||
com.netscape.jsdebugging.engine.rhino \
|
||||
com.netscape.jsdebugging.ifcui.launcher.rhino \
|
||||
!ENDIF
|
||||
!IF "$(NO_CORBA)" == ""
|
||||
com.netscape.jsdebugging.api.corba \
|
||||
com.netscape.jsdebugging.remote.corba \
|
||||
com.netscape.jsdebugging.remote.corba.ISourceTextProviderPackage \
|
||||
com.netscape.jsdebugging.remote.corba.TestInterfacePackage \
|
||||
!ENDIF
|
||||
|
||||
javadoc_all : initial_state
|
||||
@echo cleaning up old stuff in javadoc directory
|
||||
@if exist $(DIST)\javadocs\*.html @del $(DIST)\javadocs\*.html > NUL
|
||||
@echo copying javadoc images to the dist dir
|
||||
@copy $(BUILD_DIR)\images\*.gif $(DIST)\javadocs\images > NUL
|
||||
@echo building javadoc for EVERYTHING
|
||||
@javadoc -sourcepath $(JAVADOC_CLASSPATH);$(CLASS_SRC);$(BUILD_DIR)\..\stub_classes -d $(DIST)\javadocs $(ALL_PACKAGES)
|
||||
|
||||
|
||||
########## before anything can happen... #################
|
||||
|
||||
initial_state : MK_DIST_CLASSES_DIRS $(IFC_DIST_FILE)
|
||||
|
||||
$(IFC_DIST_FILE) :
|
||||
@echo getting ifc11.jar -- if this fails you need to copy it to dist/classes yourself
|
||||
copy ..\..\..\nav-java\stubs\classes\ifc11.jar $(DIST_CLASSES) > NUL
|
||||
|
||||
########## directory stuff #################
|
||||
|
||||
#
|
||||
# This list got too long so I split it in two. If you need to add more items
|
||||
# then add them to the second list...
|
||||
#
|
||||
DIST_CLASSES_DIRS_0 = \
|
||||
$(DIST) \
|
||||
$(DIST_CLASSES) \
|
||||
$(DIST_CLASSES)\images \
|
||||
$(DIST_CLASSES)\sounds \
|
||||
$(DIST_CLASSES)\netscape \
|
||||
$(DIST_CLASSES)\netscape\security \
|
||||
$(DIST_CLASSES)\netscape\jsdebug \
|
||||
$(DIST_CLASSES)\netscape\javascript \
|
||||
$(DIST_CLASSES)\netscape\applet \
|
||||
$(DIST_CLASSES)\com \
|
||||
$(DIST_CLASSES)\com\netscape \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\api \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\api\local \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\api\rhino \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\api\corba \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\engine \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\engine\local \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\engine\rhino \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\jsdb \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\util \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget\layout \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget\layout\math \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget\toolbar \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget\toolTip \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\launcher \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\launcher\local \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\launcher\rhino \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\xml \
|
||||
|
||||
DIST_CLASSES_DIRS_1 = \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\testing \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\testing\desc \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\testing\tests \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\analyzing \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\analyzing\analyzers \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\analyzing\data \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\analyzing\tree \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\jslogger \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\tools \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\tools\depend \
|
||||
$(DIST_CLASSES)\com\netscape\nativejsengine \
|
||||
$(DIST)\javadocs \
|
||||
$(DIST)\javadocs\images \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\remote \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\remote\corba \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\remote\corba\ISourceTextProviderPackage \
|
||||
$(DIST_CLASSES)\com\netscape\jsdebugging\remote\corba\TestInterfacePackage \
|
||||
|
||||
|
||||
MK_DIST_CLASSES_DIRS :
|
||||
@echo making any non existent classfile output directories
|
||||
@for %i in ($(DIST_CLASSES_DIRS_0)) do @if not exist %i\NUL mkdir %i > NUL
|
||||
@for %i in ($(DIST_CLASSES_DIRS_1)) do @if not exist %i\NUL mkdir %i > NUL
|
||||
|
||||
CP_DIST_CLASSES_RESOURCES : initial_state
|
||||
@echo copying images and sounds to dist directory
|
||||
@xcopy $(BUILD_DIR)\..\ifcui\run\images\*.* $(DIST_CLASSES)\images > NUL
|
||||
@xcopy $(BUILD_DIR)\..\ifcui\run\sounds\*.* $(DIST_CLASSES)\sounds > NUL
|
||||
|
||||
clean:
|
||||
@echo deleting built classes
|
||||
@for %i in ($(DIST_CLASSES_DIRS_0)) do @if exist %i\*.class @del %i\*.class > NUL
|
||||
@for %i in ($(DIST_CLASSES_DIRS_1)) do @if exist %i\*.class @del %i\*.class > NUL
|
||||
@echo deleting ifcui image and sound resources
|
||||
@if exist $(DIST_CLASSES)\images\*.gif @del $(DIST_CLASSES)\images\*.gif > NUL
|
||||
@if exist $(DIST_CLASSES)\sounds\*.au @del $(DIST_CLASSES)\sounds\*.au > NUL
|
||||
1
mozilla/js/jsdj/build/mk_ifcui_std_fast_jar_with_rhino.bat
Executable file
1
mozilla/js/jsdj/build/mk_ifcui_std_fast_jar_with_rhino.bat
Executable file
@@ -0,0 +1 @@
|
||||
call mk_ifcui_std.bat ifcui_fast ifcui_jar INCLUDE_RHINO_ADAPTER=1 INCLUDE_RHINO_LAUNCHER=1
|
||||
2
mozilla/js/jsdj/build/mk_ifcui_std_with_rhino.bat
Executable file
2
mozilla/js/jsdj/build/mk_ifcui_std_with_rhino.bat
Executable file
@@ -0,0 +1,2 @@
|
||||
nmake -f jsdj.mak INCLUDE_SECURITY=1 INCLUDE_LOCAL_ADAPTER=1 INCLUDE_LOCAL_LAUNCHER=1 INCLUDE_IMAGES=1 INCLUDE_SOUNDS=1 INCLUDE_RHINO_ADAPTER=1 INCLUDE_RHINO_LAUNCHER=1 NO_CORBA=1 %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
/* generated by gen_date.awk to provide access to build date at runtime */
|
||||
|
||||
package com.netscape.jsdebugging.ifcui;
|
||||
|
||||
class BuildDate
|
||||
{
|
||||
// Wednesday, September 23, 1998 at 05:12 PM
|
||||
|
||||
public static final long buildDate = 906595979000L;
|
||||
|
||||
public static final java.util.Date date()
|
||||
{
|
||||
return new java.util.Date(buildDate);
|
||||
}
|
||||
|
||||
public static final String display()
|
||||
{
|
||||
return date().toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* helper class to trim a string and its rect to fit a clip rect width
|
||||
*/
|
||||
|
||||
// when who what
|
||||
// 09/23/98 jband created file
|
||||
//
|
||||
|
||||
package com.netscape.jsdebugging.ifcui;
|
||||
|
||||
import netscape.application.*;
|
||||
import netscape.util.*;
|
||||
|
||||
/* NOTE: results are in object vars -- caller must handle synchronization */
|
||||
|
||||
public class DrawStringClipper
|
||||
{
|
||||
public DrawStringClipper( int charWidth ) {_charWidth = charWidth;}
|
||||
|
||||
public void setCharWidth( int charWidth ) {_charWidth = charWidth;}
|
||||
|
||||
public int doClip(String str, Rect rect, Rect clipRect)
|
||||
{
|
||||
_str = str;
|
||||
_rect = rect;
|
||||
_len = _str.length();
|
||||
|
||||
int charsToTrim;
|
||||
int space;
|
||||
if( _len > 0 )
|
||||
{
|
||||
space = (_rect.x + _rect.width) - (clipRect.x + clipRect.width);
|
||||
if( space > _charWidth )
|
||||
{
|
||||
space = (space/_charWidth)*_charWidth;
|
||||
int trail = (_rect.width/_charWidth) - _len;
|
||||
charsToTrim = Math.min(_len, (space/_charWidth)- trail);
|
||||
if( charsToTrim > 0 )
|
||||
{
|
||||
_rect.width -= space;
|
||||
_str = _str.substring(0, _len-charsToTrim);
|
||||
_len -= charsToTrim;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( _len > 0 )
|
||||
{
|
||||
space = clipRect.x - _rect.x;
|
||||
if( space > _charWidth )
|
||||
{
|
||||
space = (space/_charWidth)*_charWidth;
|
||||
charsToTrim = Math.min(_len, space / _charWidth);
|
||||
if( charsToTrim > 0 )
|
||||
{
|
||||
_rect.x += space;
|
||||
_rect.width -= space;
|
||||
_str = _str.substring(charsToTrim);
|
||||
_len -= charsToTrim;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _len;
|
||||
}
|
||||
|
||||
public String getString() {return _str;}
|
||||
public int getStringLength() {return _len;}
|
||||
public Rect getRect() {return _rect;}
|
||||
|
||||
private String _str;
|
||||
private int _len;
|
||||
private Rect _rect;
|
||||
private int _charWidth;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
|
||||
/* generated by gen_dbg.awk to set DEBUG on or off */
|
||||
|
||||
package com.netscape.jsdebugging.ifcui.palomar.util;
|
||||
|
||||
public interface AS
|
||||
{
|
||||
public static final boolean S = true;
|
||||
public static final boolean DEBUG = true;
|
||||
}
|
||||
162
mozilla/js/jsdj/doc/jsd_arch.html
Normal file
162
mozilla/js/jsdj/doc/jsd_arch.html
Normal file
@@ -0,0 +1,162 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>JSD Architecture</title>
|
||||
</head>
|
||||
|
||||
<body bgcolor=white>
|
||||
<h1><center>JSD Architecture</center></h1>
|
||||
<a href="mailto:jband@netscape.com"><center>John Bandhauer</center></a>
|
||||
<i><center>6 July 1998</center></i>
|
||||
<p>
|
||||
|
||||
<center><img src="jsd_arch.jpg" border=1><br></center>
|
||||
<center><i>Basic JSD architecture for both C and Java engines</i></center>
|
||||
<p>
|
||||
|
||||
<table>
|
||||
|
||||
<tr>
|
||||
<td valign=top><font color=red>(1)</font></td>
|
||||
<td>
|
||||
Spider Monkey JavaScript engine. This is an unmodified engine which exposes
|
||||
a low-level debug interface via <code>js/src/jsdbgapi.h</code>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top><font color=red>(2)</font></td>
|
||||
<td>
|
||||
Spider Monkey JavaScript debug support. This provides a wrapper and does
|
||||
bookkeeping.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top><font color=red>(3)</font></td>
|
||||
<td>
|
||||
Corba adapter. Using only public interfaces of JSD this module remotes
|
||||
the debug interface over a Corba connection.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top><font color=red>(4)</font></td>
|
||||
<td>
|
||||
JNI native adapter. This implements the natives of <code>netscape.debug</code>
|
||||
using JNI natives.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top><font color=red>(5)</font></td>
|
||||
<td>
|
||||
Old JDK native adapter. This implements the natives of <code>netscape.debug</code>
|
||||
using old style JDK natives. This is currently in use in Communicator 4.x.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top><font color=red>(6)</font></td>
|
||||
<td>
|
||||
Rhino <i>JavaScript for Java</i> engine. This is the unmodified Rhino engine.
|
||||
It exposes the low-level debug interface via various interface classesand support
|
||||
built into the Context and Codegen classes.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top><font color=red>(7)</font></td>
|
||||
<td>
|
||||
Rhino debug support package. This exposes a higher level debug interface for
|
||||
Rhino and includes a reference implementation of that interface.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top><font color=red>(8)</font></td>
|
||||
<td>
|
||||
Client end of Corba adapter. This implements <code>com.netscape.jsdebugging.api</code>
|
||||
to provide debugger clients access to an engine running in a different process
|
||||
space.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top><font color=red>(9)</font></td>
|
||||
<td>
|
||||
<code>netscape.debug</code> is a package included in Communiator 4.x.
|
||||
The JNI and JDK natives supply the bridge from C to Java that is exposed on the
|
||||
Java side by this package.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top><font color=red>(10)</font></td>
|
||||
<td>
|
||||
The local adapter implements <code>com.netscape.jsdebugging.api</code> in a form that
|
||||
allows the debugger client to connect to <code>netscape.debug</code>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top><font color=red>(11)</font></td>
|
||||
<td>
|
||||
The rhino adapter implements <code>com.netscape.jsdebugging.api</code> in a form that
|
||||
allows the debugger client to connect to <code>com.netscape.javascript.debug</code>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top><font color=red>(12)</font></td>
|
||||
<td>
|
||||
<code>com.netscape.jsdebugging.api</code> is an interface only package that allows
|
||||
debugger clients to talk to any of the adapters transparently and with no
|
||||
compile-time coupling to the adapters.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top><font color=red>(13)</font></td>
|
||||
<td>
|
||||
Java-based Graphical Debugger. Currently we have one debugger written using IFC
|
||||
and shipping in it's 1.1 form. Version 1.2 is unfinished and under development
|
||||
in the mozilla tree in <code>js/sjdj/classes</code> in the package
|
||||
<code>com.netscape.jsdebugging.ifcui</code>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top><font color=red>(14)</font></td>
|
||||
<td>
|
||||
Java-based Console Debugger. Currently we have a version of this checked in
|
||||
to the mozilla tree in <code>com.netscape.jsdebugging.jsdb</code>. This version
|
||||
will work with either Rhino or the C engine using engine abstraction classes in
|
||||
<code>com.netscape.jsdebugging.engine</code>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top><font color=red>(15)</font></td>
|
||||
<td>
|
||||
Java-based debug api tests are implemented in
|
||||
<code>com.netscape.jsdebugging.apitests</code>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top><font color=red>(n/a)</font></td>
|
||||
<td>
|
||||
Not shown is a purely native console debugger which uses only js/src and js/jsd.
|
||||
It can be found in js/jsd/jsdb. This debugger uses the JS shell and reflects
|
||||
the JSD api into the JavaScript language. The actual debugger is written in
|
||||
JavaScript. It can be modified and extended as it runs and can debug itself.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</table>
|
||||
<HR>
|
||||
last updated: 28 September 1998 - jband
|
||||
|
||||
</body>
|
||||
</html>
|
||||
BIN
mozilla/js/jsdj/doc/jsd_arch.jpg
Normal file
BIN
mozilla/js/jsdj/doc/jsd_arch.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 71 KiB |
BIN
mozilla/js/macbuild/JavaScriptPPC.mcp
Normal file
BIN
mozilla/js/macbuild/JavaScriptPPC.mcp
Normal file
Binary file not shown.
BIN
mozilla/js/macbuild/LiveConnect.mcp
Normal file
BIN
mozilla/js/macbuild/LiveConnect.mcp
Normal file
Binary file not shown.
@@ -16,10 +16,13 @@
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nspr_win16_defs_h___
|
||||
#define nspr_win16_defs_h___
|
||||
/*
|
||||
* global data definitions
|
||||
*/
|
||||
|
||||
#define HAVE_DLL
|
||||
#undef HAVE_LONG_LONG
|
||||
#include "headers.h"
|
||||
|
||||
#endif /* nspr_win16_defs_h___ */
|
||||
/* Globals */
|
||||
|
||||
HINSTANCE g_hInstance = 0;
|
||||
HWND g_hMainDlg = 0;
|
||||
104
mozilla/js/samples/jsdraw/draw.c
Normal file
104
mozilla/js/samples/jsdraw/draw.c
Normal file
@@ -0,0 +1,104 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* drawing wrappers
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
|
||||
static int _maxX;
|
||||
static int _maxY;
|
||||
static int _offsetX;
|
||||
static int _offsetY;
|
||||
static int _lastX;
|
||||
static int _lastY;
|
||||
static COLORREF _penColor = RGB(0,0,0);
|
||||
static int _penWidth = 1;
|
||||
static HPEN _pen = 0;
|
||||
|
||||
static void _newPen()
|
||||
{
|
||||
if( _pen )
|
||||
DeleteObject(_pen);
|
||||
_pen = CreatePen(PS_SOLID, _penWidth, _penColor);
|
||||
}
|
||||
|
||||
void SetPenColor( COLORREF color )
|
||||
{
|
||||
_penColor = color;
|
||||
_newPen();
|
||||
}
|
||||
|
||||
void SetPenWidth( int width )
|
||||
{
|
||||
_penWidth = width;
|
||||
_newPen();
|
||||
}
|
||||
|
||||
void SetSurfaceSize( int dx, int dy )
|
||||
{
|
||||
_maxX = dx;
|
||||
_maxY = dy;
|
||||
}
|
||||
|
||||
void SetSurfaceOffset( int dx, int dy )
|
||||
{
|
||||
_offsetX = dx;
|
||||
_offsetY = dy;
|
||||
}
|
||||
|
||||
void DlgToSurface( POINT* ppt )
|
||||
{
|
||||
ppt->x -= _offsetX;
|
||||
ppt->y -= _offsetY;
|
||||
}
|
||||
|
||||
void SurfaceToDlg( POINT* ppt )
|
||||
{
|
||||
ppt->x += _offsetX;
|
||||
ppt->y += _offsetY;
|
||||
}
|
||||
|
||||
void DrawMoveTo(int x, int y)
|
||||
{
|
||||
x = min(_maxX-_penWidth/2,max(_penWidth/2,x));
|
||||
y = min(_maxY-_penWidth/2,max(_penWidth/2,y));
|
||||
|
||||
_lastX = x;
|
||||
_lastY = y;
|
||||
}
|
||||
|
||||
void DrawLineTo(int x, int y)
|
||||
{
|
||||
HDC hdc;
|
||||
HGDIOBJ oldPen;
|
||||
|
||||
x = min(_maxX-_penWidth/2,max(_penWidth/2,x));
|
||||
y = min(_maxY-_penWidth/2,max(_penWidth/2,y));
|
||||
|
||||
hdc = GetDC(g_hMainDlg);
|
||||
oldPen = SelectObject(hdc, _pen);
|
||||
MoveToEx(hdc, _lastX + _offsetX, _lastY + _offsetY, NULL);
|
||||
LineTo(hdc, x + _offsetX, y + _offsetY);
|
||||
SelectObject(hdc, oldPen);
|
||||
ReleaseDC(g_hMainDlg, hdc);
|
||||
_lastX = x;
|
||||
_lastY = y;
|
||||
}
|
||||
|
||||
@@ -16,15 +16,28 @@
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nspr_scoos5_defs_h___
|
||||
#define nspr_scoos5_defs_h___
|
||||
/*
|
||||
* Windows header files
|
||||
*/
|
||||
|
||||
#undef HAVE_LONG_LONG
|
||||
#undef HAVE_ALIGNED_DOUBLES
|
||||
#undef HAVE_ALIGNED_LONGLONGS
|
||||
#define HAVE_DLL
|
||||
#define USE_DLFCN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <commdlg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
#include "jsdebug.h"
|
||||
#include "jsdjava.h"
|
||||
#endif
|
||||
|
||||
#include "jsdraw.h"
|
||||
#include "resource.h"
|
||||
|
||||
#define NEED_TIME_R
|
||||
|
||||
#endif /* nspr_scoos5_defs_h___ */
|
||||
434
mozilla/js/samples/jsdraw/jsdraw.c
Normal file
434
mozilla/js/samples/jsdraw/jsdraw.c
Normal file
@@ -0,0 +1,434 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Top-level windows code
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
|
||||
static JSContext* _cx;
|
||||
static JSObject* _glob;
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
static JSDContext* _jsdc = NULL;
|
||||
static JSDSourceText* _jsdsrc = NULL;
|
||||
static JSDJContext* _jsdjc = NULL;
|
||||
#endif
|
||||
|
||||
/********************************/
|
||||
|
||||
static char*
|
||||
_readFile(const char* filename)
|
||||
{
|
||||
int fh;
|
||||
int len;
|
||||
char* buf;
|
||||
|
||||
|
||||
fh = _open(filename, _O_RDONLY | _O_BINARY);
|
||||
if(-1 ==fh)
|
||||
return NULL;
|
||||
len = _lseek(fh, 0, SEEK_END);
|
||||
if(-1 == len)
|
||||
{
|
||||
_close(fh);
|
||||
return NULL;
|
||||
}
|
||||
_lseek(fh, 0, SEEK_SET);
|
||||
buf = malloc(len+1);
|
||||
if(! buf)
|
||||
{
|
||||
_close(fh);
|
||||
return NULL;
|
||||
}
|
||||
_read(fh, buf, len);
|
||||
_close(fh);
|
||||
buf[len] = 0;
|
||||
return buf;
|
||||
}
|
||||
|
||||
/********************************/
|
||||
|
||||
static void
|
||||
ignore_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
|
||||
{
|
||||
char buf[1024];
|
||||
char bigBuf[2048];
|
||||
|
||||
bigBuf[0] = 0;
|
||||
|
||||
if(report && report->filename)
|
||||
{
|
||||
sprintf( buf, "FILE: %s\n", report->filename );
|
||||
strcat( bigBuf, buf );
|
||||
}
|
||||
if(report && report->lineno)
|
||||
{
|
||||
sprintf( buf, "LINE: %d\n", report->lineno );
|
||||
strcat( bigBuf, buf );
|
||||
}
|
||||
strcat( bigBuf, message );
|
||||
strcat( bigBuf, "\n\n" );
|
||||
|
||||
if(report && report->linebuf)
|
||||
strcat( bigBuf, report->linebuf );
|
||||
|
||||
MessageBox( g_hMainDlg, bigBuf, "JavaScript Error", MB_ICONHAND );
|
||||
}
|
||||
|
||||
/********************************/
|
||||
|
||||
static JSBool
|
||||
_MoveTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
|
||||
if( argc != 2 ||
|
||||
! JS_ValueToInt32(cx, argv[0], &x) ||
|
||||
! JS_ValueToInt32(cx, argv[1], &y) )
|
||||
{
|
||||
JS_ReportError(cx, "MoveTo requires 2 numerical args");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
DrawMoveTo(x, y);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
_LineTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
|
||||
if( argc != 2 ||
|
||||
! JS_ValueToInt32(cx, argv[0], &x) ||
|
||||
! JS_ValueToInt32(cx, argv[1], &y) )
|
||||
{
|
||||
JS_ReportError(cx, "LineTo requires 2 numerical args");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
DrawLineTo(x, y);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
_Load(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
char* source;
|
||||
const char* filename;
|
||||
JSString* s;
|
||||
|
||||
if( argc != 1 )
|
||||
{
|
||||
JS_ReportError(cx, "requires 1 arg");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if( ! (s = JS_ValueToString(cx, argv[0])) )
|
||||
{
|
||||
JS_ReportError(cx, "param must be a string");
|
||||
return JS_FALSE;
|
||||
}
|
||||
filename = JS_GetStringBytes(s);
|
||||
|
||||
source = _readFile(filename);
|
||||
if(! source)
|
||||
{
|
||||
JS_ReportError(cx, "failed to load source");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
if(_jsdc)
|
||||
JSD_AddFullSourceText(_jsdc, source, strlen(source), filename);
|
||||
#endif
|
||||
JS_EvaluateScript(cx, _glob, source, strlen(source), filename, 1, rval);
|
||||
free(source);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
_Save(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
const char* filename;
|
||||
JSString* s;
|
||||
|
||||
if( DoingRedraw() )
|
||||
return JS_TRUE;
|
||||
|
||||
if( argc != 1 )
|
||||
{
|
||||
JS_ReportError(cx, "requires 1 arg");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if( ! (s = JS_ValueToString(cx, argv[0])) )
|
||||
{
|
||||
JS_ReportError(cx, "param must be a string");
|
||||
return JS_FALSE;
|
||||
}
|
||||
filename = JS_GetStringBytes(s);
|
||||
|
||||
if( ! SaveRecordedHistory(filename) )
|
||||
{
|
||||
JS_ReportError(cx, "failed to save recorded history");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
_StartRecord(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
/* just the statement in the history is enough to get the action */
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
_SetPenWidth(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
jsdouble width;
|
||||
|
||||
if( argc != 1 )
|
||||
{
|
||||
JS_ReportError(cx, "requires 1 arg");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if( ! JS_ValueToNumber(cx, argv[0], &width) ||
|
||||
width < 1 || width > 100 )
|
||||
{
|
||||
JS_ReportError(cx, "width must be set to a value between 1 and 100");
|
||||
return JS_FALSE;
|
||||
}
|
||||
SetPenWidth( (int) width );
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char* name;
|
||||
COLORREF color;
|
||||
|
||||
} COLOR_DEF;
|
||||
static COLOR_DEF colors[] =
|
||||
{
|
||||
{"white", RGB(255,255,255)},
|
||||
{"black", RGB(0,0,0)},
|
||||
{"red" , RGB(255,0,0)},
|
||||
{"green", RGB(0,255,0)},
|
||||
{"blue" , RGB(0,0,255)},
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
static JSBool
|
||||
_SetPenColor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
jsdouble dblColor;
|
||||
COLORREF color;
|
||||
int i;
|
||||
|
||||
if( argc != 1 )
|
||||
{
|
||||
JS_ReportError(cx, "requires 1 arg");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if( JSVAL_IS_NUMBER(argv[0]) && JS_ValueToNumber(cx, argv[0], &dblColor) )
|
||||
{
|
||||
color = (COLORREF) dblColor;
|
||||
if( color < RGB(0,0,0) || color > RGB(255,255,255) )
|
||||
{
|
||||
JS_ReportError(cx, "color value is out of range");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else if( JSVAL_IS_STRING(argv[0]) )
|
||||
{
|
||||
JSString* s = JS_ValueToString(cx, argv[0]);
|
||||
const char* colorname;
|
||||
if(!s)
|
||||
{
|
||||
JS_ReportError(cx, "param must be a color string or value");
|
||||
return JS_FALSE;
|
||||
}
|
||||
colorname = JS_GetStringBytes(s);
|
||||
|
||||
for( i = 0; colors[i].name; i++ )
|
||||
{
|
||||
if( 0 == strcmp(colors[i].name, colorname) )
|
||||
{
|
||||
color = colors[i].color;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( ! colors[i].name )
|
||||
{
|
||||
JS_ReportError(cx, "unknown color");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
SetPenColor( color );
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
/********************************/
|
||||
|
||||
static JSFunctionSpec my_functions[] = {
|
||||
{"MoveTo", _MoveTo, 2},
|
||||
{"LineTo", _LineTo, 2},
|
||||
{"load", _Load, 1},
|
||||
{"save", _Save, 1},
|
||||
{"start_record", _StartRecord, 0},
|
||||
{"setPenWidth", _SetPenWidth, 1},
|
||||
{"setPenColor", _SetPenColor, 1},
|
||||
{0}
|
||||
};
|
||||
|
||||
static JSClass global_class = {
|
||||
"global", 0,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
|
||||
};
|
||||
|
||||
BOOL Eval(char* str, int lineno)
|
||||
{
|
||||
jsval rval;
|
||||
#ifdef JSDEBUGGER
|
||||
if(_jsdc)
|
||||
{
|
||||
if(1 == lineno)
|
||||
_jsdsrc = JSD_NewSourceText(_jsdc, "drawer");
|
||||
if(_jsdsrc)
|
||||
_jsdsrc = JSD_AppendSourceText(_jsdc, _jsdsrc, str, strlen(str),
|
||||
JSD_SOURCE_PARTIAL);
|
||||
}
|
||||
#endif
|
||||
return JS_EvaluateScript(_cx, _glob, str, strlen(str), "drawer", lineno, &rval);
|
||||
}
|
||||
|
||||
static char autoload[] = "load(\"autoload.js\")";
|
||||
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
static void
|
||||
_startStopCallback(JSDJContext* jsdjc, int event, void *closure)
|
||||
{
|
||||
*((int*)closure) = event;
|
||||
}
|
||||
#endif
|
||||
|
||||
int WINAPI
|
||||
WinMain( HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nCmdShow )
|
||||
{
|
||||
JSRuntime* rt;
|
||||
jsval rval;
|
||||
#ifdef JSDEBUGGER
|
||||
int startupFlag;
|
||||
int timeoutCounter;
|
||||
#endif
|
||||
|
||||
rt = JS_Init(8L * 1024L * 1024L);
|
||||
if (!rt)
|
||||
return 1;
|
||||
|
||||
_cx = JS_NewContext(rt, 8192);
|
||||
if (!_cx)
|
||||
return 1;
|
||||
|
||||
_glob = JS_NewObject(_cx, &global_class, NULL, NULL);
|
||||
if (!_glob)
|
||||
return 1;
|
||||
|
||||
if (!JS_InitStandardClasses(_cx, _glob))
|
||||
return 1;
|
||||
|
||||
JS_SetErrorReporter(_cx, my_ErrorReporter);
|
||||
|
||||
if (!JS_DefineFunctions(_cx, _glob, my_functions))
|
||||
return 1;
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
if( strstr(lpCmdLine, "DEBUG") )
|
||||
{
|
||||
_jsdc = JSD_DebuggerOnForUser(rt, NULL, NULL);
|
||||
if(!_jsdc)
|
||||
return 1;
|
||||
_jsdjc = JSDJ_CreateContext();
|
||||
if( ! _jsdjc )
|
||||
return 1;
|
||||
JSDJ_SetJSDContext(_jsdjc, _jsdc);
|
||||
|
||||
JSDJ_SetStartStopCallback(_jsdjc, _startStopCallback, &startupFlag);
|
||||
JSD_JSContextInUse(_jsdc, _cx);
|
||||
JSDJ_CreateJavaVMAndStartDebugger(_jsdjc);
|
||||
|
||||
// timout debugger startup after 30 seconds
|
||||
startupFlag = 0;
|
||||
for(timeoutCounter = 0; timeoutCounter < 300; timeoutCounter++)
|
||||
{
|
||||
if(startupFlag)
|
||||
break;
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
/**
|
||||
* XXX Hack here because current DebugController as no iterateScripts
|
||||
* method and thus the debugger can only see the scripts created
|
||||
* after *it* has set it's hooks. The debugger has code to iterate
|
||||
* scripts and thus learn about scripts which were in place before
|
||||
* the debugger has set its hooks. But, the underlying code does not
|
||||
* yet support it.
|
||||
* So... we wait for an arbitrary amount of time here to let the
|
||||
* debugger get its hooks in before we load any scripts
|
||||
*/
|
||||
Sleep(2000);
|
||||
|
||||
JSDJ_SetStartStopCallback(_jsdjc, NULL, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
g_hInstance = hInstance;
|
||||
|
||||
JS_SetErrorReporter(_cx, ignore_ErrorReporter);
|
||||
JS_EvaluateScript(_cx, _glob, autoload, strlen(autoload), "autoload", 1, &rval);
|
||||
JS_SetErrorReporter(_cx, my_ErrorReporter);
|
||||
|
||||
DialogBox(hInstance, MAKEINTRESOURCE(IDDIALOG_MAIN), NULL, MainDlgProc );
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
if(_jsdc)
|
||||
JSD_DebuggerOff(_jsdc);
|
||||
#endif
|
||||
|
||||
JS_DestroyContext(_cx);
|
||||
JS_Finish(rt);
|
||||
return 0;
|
||||
}
|
||||
@@ -16,26 +16,27 @@
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nspr_sunos_defs_h___
|
||||
#define nspr_sunos_defs_h___
|
||||
/* Globals */
|
||||
|
||||
#undef HAVE_LONG_LONG
|
||||
#define HAVE_ALIGNED_DOUBLES
|
||||
#define HAVE_ALIGNED_LONGLONGS
|
||||
#define HAVE_DLL
|
||||
extern HINSTANCE g_hInstance;
|
||||
extern HWND g_hMainDlg;
|
||||
|
||||
#define NEED_TIME_R
|
||||
#define USE_DLFCN
|
||||
BOOL WINAPI MainDlgProc(HWND hDlg, UINT msg, UINT wParam, LONG lParam);
|
||||
|
||||
/*
|
||||
** Missing function prototypes
|
||||
*/
|
||||
/* from prompt.c */
|
||||
void Prompt( char* prompt, char* answer, int maxAnswer );
|
||||
|
||||
extern int socket (int domain, int type, int protocol);
|
||||
extern int getsockname (int s, struct sockaddr *name, int *namelen);
|
||||
extern int accept (int s, struct sockaddr *addr, int *addrlen);
|
||||
extern int listen (int s, int backlog);
|
||||
extern int brk(void *);
|
||||
extern void *sbrk(int);
|
||||
/* from draw.c */
|
||||
void SetSurfaceSize( int dx, int dy );
|
||||
void SetSurfaceOffset( int dx, int dy );
|
||||
void DlgToSurface( POINT* ppt );
|
||||
void SurfaceToDlg( POINT* ppt );
|
||||
void SetPenColor( COLORREF color );
|
||||
void SetPenWidth( int width );
|
||||
void DrawMoveTo(int x, int y);
|
||||
void DrawLineTo(int x, int y);
|
||||
BOOL DoingRedraw();
|
||||
|
||||
#endif /* nspr_sunos_defs_h___ */
|
||||
BOOL SaveRecordedHistory(const char* filename);
|
||||
|
||||
BOOL Eval(char* str, int lineno);
|
||||
118
mozilla/js/samples/jsdraw/jsdraw.mak
Normal file
118
mozilla/js/samples/jsdraw/jsdraw.mak
Normal file
@@ -0,0 +1,118 @@
|
||||
|
||||
#
|
||||
# jband - 11/08/97 -
|
||||
#
|
||||
|
||||
#
|
||||
# jband - 22 Sept 1998 - ripped out JSD stuff just to get this compiling
|
||||
#
|
||||
|
||||
PROJ = jsdraw
|
||||
JSSRC = ..\..\SRC
|
||||
OBJ = Debug
|
||||
RUN = Run
|
||||
|
||||
CFLAGS = /nologo /MDd /W3 /Gm /GX /Zi /Od\
|
||||
/I $(JSSRC)\
|
||||
/DDEBUG /DWIN32 /D_CONSOLE /DXP_PC /D_WINDOWS /D_WIN32\
|
||||
/c /Fp$(OBJ)\$(PROJ).pch /Fd$(OBJ)\$(PROJ).pdb /YX -Fo$@ $<
|
||||
|
||||
LFLAGS = /nologo /subsystem:windows /entry:WinMainCRTStartup /incremental:no\
|
||||
/machine:I386 /DEBUG\
|
||||
/pdb:$(OBJ)\$(PROJ).pdb -out:$(OBJ)\$(PROJ).exe
|
||||
|
||||
LLIBS = kernel32.lib advapi32.lib $(JSSRC)\Debug\js32.lib \
|
||||
user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib
|
||||
|
||||
RCFLAGS = /r -DWIN32 -D_WIN32
|
||||
|
||||
CPP=cl.exe
|
||||
LINK32=link.exe
|
||||
RC=rc.exe
|
||||
|
||||
all: $(OBJ) $(RUN) $(RUN)\$(PROJ).exe $(RUN)\$(PROJ).pdb \
|
||||
$(RUN)\js32.dll $(RUN)\js32.pdb
|
||||
|
||||
|
||||
$(OBJ)\$(PROJ).exe: \
|
||||
$(OBJ)\jsdraw.obj \
|
||||
$(OBJ)\maindlg.obj \
|
||||
$(OBJ)\prompt.obj \
|
||||
$(OBJ)\data.obj \
|
||||
$(OBJ)\draw.obj \
|
||||
$(OBJ)\jsdraw.res
|
||||
$(LINK32) $(LFLAGS) $** $(LLIBS)
|
||||
|
||||
$(OBJ)\$(PROJ).res: $(PROJ).rc resource.h
|
||||
|
||||
.rc{$(OBJ)}.res:
|
||||
$(RC) $(RCFLAGS) /fo$@ $<
|
||||
|
||||
.c{$(OBJ)}.obj:
|
||||
$(CPP) $(CFLAGS)
|
||||
|
||||
$(OBJ) :
|
||||
mkdir $(OBJ)
|
||||
|
||||
$(RUN) :
|
||||
mkdir $(RUN)
|
||||
|
||||
$(RUN)\$(PROJ).exe: $(OBJ)\$(PROJ).exe
|
||||
copy $(OBJ)\$(PROJ).exe $(RUN)
|
||||
|
||||
$(RUN)\$(PROJ).pdb: $(OBJ)\$(PROJ).pdb
|
||||
copy $(OBJ)\$(PROJ).pdb $(RUN)
|
||||
|
||||
$(RUN)\js32.dll :
|
||||
copy $(JSSRC)\Debug\js32.dll $(RUN)
|
||||
|
||||
$(RUN)\js32.pdb :
|
||||
copy $(JSSRC)\Debug\js32.pdb $(RUN)
|
||||
|
||||
clean:
|
||||
del $(OBJ)\*.pch
|
||||
del $(OBJ)\*.obj
|
||||
del $(OBJ)\*.exp
|
||||
del $(OBJ)\*.lib
|
||||
del $(OBJ)\*.res
|
||||
del $(OBJ)\*.idb
|
||||
del $(OBJ)\*.pdb
|
||||
del $(OBJ)\*.exe
|
||||
del $(RUN)\*.pdb
|
||||
del $(RUN)\*.exe
|
||||
|
||||
|
||||
|
||||
|
||||
##
|
||||
## jband - 11/08/97 -
|
||||
##
|
||||
#
|
||||
#TARGETOS = WINNT
|
||||
#
|
||||
#!include <win32.mak>
|
||||
#
|
||||
#all: jsdraw.exe
|
||||
#
|
||||
## Update the resources if necessary
|
||||
#
|
||||
#jsdraw.res: jsdraw.rc resource.h
|
||||
# $(rc) $(rcflags) $(rcvars) jsdraw.rc
|
||||
#
|
||||
#jsdraw.exe: \
|
||||
# jsdraw.obj \
|
||||
# maindlg.obj \
|
||||
# prompt.obj \
|
||||
# data.obj \
|
||||
# draw.obj \
|
||||
# jsdraw.res
|
||||
# $(link) $(linkdebug) $(guiflags) -out:$*.exe $** ..\JSSRC\Debug\js32.lib $(guilibs)
|
||||
#
|
||||
#.c.obj:
|
||||
# $(cc) $(cdebug) $(cflags) $(cvars) /I..\JSSRC /YX $*.c
|
||||
#
|
||||
#clean:
|
||||
# del *.obj
|
||||
# del *.pch
|
||||
# del jsdraw.res
|
||||
# del jsdraw.exe
|
||||
54
mozilla/js/samples/jsdraw/jsdraw.rc
Normal file
54
mozilla/js/samples/jsdraw/jsdraw.rc
Normal file
@@ -0,0 +1,54 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Windows resources
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include "resource.h"
|
||||
|
||||
IDDIALOG_MAIN DIALOG 59, 26, 281, 368
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
|
||||
CAPTION "JSDraw"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
CONTROL "", IDD_SURFACE, "Static", SS_BLACKFRAME, 6, 2, 268, 194
|
||||
EDITTEXT IDD_CONSOLE, 2, 309, 230, 55, ES_MULTILINE |
|
||||
ES_AUTOHSCROLL | WS_VSCROLL
|
||||
LISTBOX IDD_HISTORY, 2, 201, 230, 114, WS_VSCROLL
|
||||
PUSHBUTTON "Set Color", IDD_SET_COLOR, 237, 203, 40, 14
|
||||
PUSHBUTTON "Set Width", IDD_SET_WIDTH, 237, 220, 40, 14
|
||||
PUSHBUTTON "Record", IDD_RECORD, 237, 237, 40, 14
|
||||
PUSHBUTTON "Save", IDD_SAVE, 237, 254, 40, 14
|
||||
PUSHBUTTON "Load", IDD_LOAD, 237, 271, 40, 14
|
||||
PUSHBUTTON "Clear",IDD_CLEAR, 237, 289, 40, 14
|
||||
DEFPUSHBUTTON "Eval", IDD_EVAL, 237, 310, 40, 30
|
||||
PUSHBUTTON "Exit", IDCANCEL, 237, 350, 40, 14
|
||||
END
|
||||
|
||||
|
||||
IDDIALOG_PROMPT DIALOG 143, 110, 182, 56
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "JSDraw - Prompt"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LTEXT "Prompt here..", IDD_PROMPT_PROMPT, 3, 5, 178, 8
|
||||
EDITTEXT IDD_PROMPT_ANSWER, 1, 18, 179, 12, ES_AUTOHSCROLL
|
||||
DEFPUSHBUTTON "OK", IDOK, 69, 35, 40, 14
|
||||
END
|
||||
423
mozilla/js/samples/jsdraw/maindlg.c
Normal file
423
mozilla/js/samples/jsdraw/maindlg.c
Normal file
@@ -0,0 +1,423 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* main window code
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
|
||||
static BOOL _doingRedraw = FALSE;
|
||||
|
||||
BOOL DoingRedraw()
|
||||
{
|
||||
return _doingRedraw;
|
||||
}
|
||||
|
||||
void AddToHistory( char* str )
|
||||
{
|
||||
int len = strlen(str);
|
||||
HWND list = GetDlgItem(g_hMainDlg, IDD_HISTORY);
|
||||
if(len && '\n' == str[len-1])
|
||||
str[len-1] = 0;
|
||||
SendMessage(list, LB_ADDSTRING, 0, (LPARAM) str );
|
||||
SendMessage(list, LB_SETCURSEL,
|
||||
(WPARAM) SendMessage(list, LB_GETCOUNT, 0, 0) - 1, 0 );
|
||||
if(len && 0 == str[len-1])
|
||||
str[len-1] = '\n';
|
||||
}
|
||||
|
||||
void ClearHistory()
|
||||
{
|
||||
HWND list = GetDlgItem(g_hMainDlg, IDD_HISTORY);
|
||||
int i;
|
||||
|
||||
for( i = SendMessage(list, LB_GETCOUNT, 0, 0); i >= 0; i-- )
|
||||
SendMessage(list, LB_DELETESTRING, i, 0 );
|
||||
}
|
||||
|
||||
void EvalAllOfHistory()
|
||||
{
|
||||
HWND list = GetDlgItem(g_hMainDlg, IDD_HISTORY);
|
||||
int count = SendMessage(list, LB_GETCOUNT, 0, 0);
|
||||
int cursize;
|
||||
int size = 0;
|
||||
int index = 0;
|
||||
int i;
|
||||
char* buf;
|
||||
|
||||
_doingRedraw = TRUE;
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
cursize = SendMessage(list, LB_GETTEXTLEN, i, 0);
|
||||
if(-1 != cursize)
|
||||
size += cursize+1;
|
||||
}
|
||||
if( ! size)
|
||||
{
|
||||
_doingRedraw = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
buf = malloc(size+1);
|
||||
if(! buf)
|
||||
{
|
||||
_doingRedraw = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
cursize = SendMessage(list, LB_GETTEXT, i, (LPARAM)&buf[index]);
|
||||
if(-1 != cursize)
|
||||
{
|
||||
index += cursize+1;
|
||||
buf[index-1] = '\n';
|
||||
}
|
||||
}
|
||||
buf[index] = 0;
|
||||
if(index)
|
||||
Eval(buf,1);
|
||||
free(buf);
|
||||
_doingRedraw = FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
SaveRecordedHistory(const char* filename)
|
||||
{
|
||||
HWND list = GetDlgItem(g_hMainDlg, IDD_HISTORY);
|
||||
int count = SendMessage(list, LB_GETCOUNT, 0, 0);
|
||||
int size = 0;
|
||||
int start = 0;
|
||||
char* buf;
|
||||
int fh;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
size = max(SendMessage(list, LB_GETTEXTLEN, i, 0),size);
|
||||
|
||||
if( ! size )
|
||||
return FALSE;
|
||||
|
||||
buf = malloc(size+2);
|
||||
if(! buf)
|
||||
return FALSE;
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
if(-1 != SendMessage(list, LB_GETTEXT, i, (LPARAM)buf))
|
||||
{
|
||||
if( strstr(buf, "start_record") )
|
||||
start = i+1;
|
||||
}
|
||||
}
|
||||
|
||||
if( start == count )
|
||||
{
|
||||
free(buf);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fh = _open(filename, _O_CREAT | _O_TRUNC | _O_BINARY | _O_RDWR);
|
||||
if(-1 ==fh)
|
||||
{
|
||||
free(buf);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for( i = start; i < count; i++ )
|
||||
{
|
||||
if(-1 != SendMessage(list, LB_GETTEXT, i, (LPARAM)buf))
|
||||
{
|
||||
strcat(buf, "\n");
|
||||
_write(fh, buf, strlen(buf));
|
||||
}
|
||||
}
|
||||
|
||||
_close(fh);
|
||||
free(buf);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
EvalAndAddToHistory(char* expr, int* lineno)
|
||||
{
|
||||
if( Eval(expr, *(lineno)+1) )
|
||||
{
|
||||
AddToHistory(expr);
|
||||
*(lineno)++;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
EvalAllOfHistory();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL WINAPI
|
||||
MainDlgProc(HWND hDlg, UINT msg, UINT wParam, LONG lParam)
|
||||
{
|
||||
static BOOL _drawing = FALSE;
|
||||
static RECT _rectSurface;
|
||||
static lineno = 0;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
RECT r;
|
||||
POINT pt;
|
||||
|
||||
g_hMainDlg = hDlg;
|
||||
|
||||
SetPenColor(RGB(255,0,0));
|
||||
SetPenWidth(2);
|
||||
|
||||
SendMessage( GetDlgItem(hDlg, IDD_CONSOLE), WM_SETFONT,
|
||||
(WPARAM)GetStockObject(ANSI_FIXED_FONT),0);
|
||||
|
||||
SendMessage( GetDlgItem(hDlg, IDD_HISTORY), WM_SETFONT,
|
||||
(WPARAM)GetStockObject(ANSI_FIXED_FONT),0);
|
||||
|
||||
/* Calc offsets for our drawing surface */
|
||||
GetClientRect(hDlg, &r);
|
||||
pt.x = r.left;
|
||||
pt.y = r.top;
|
||||
ClientToScreen(hDlg, &pt);
|
||||
GetWindowRect(GetDlgItem(hDlg, IDD_SURFACE), &_rectSurface);
|
||||
|
||||
SetSurfaceSize(_rectSurface.right - _rectSurface.left,
|
||||
_rectSurface.bottom - _rectSurface.top);
|
||||
|
||||
SetSurfaceOffset(_rectSurface.left - pt.x,
|
||||
_rectSurface.top - pt.y);
|
||||
|
||||
OffsetRect(&_rectSurface, -pt.x, -pt.y);
|
||||
|
||||
SetForegroundWindow(hDlg);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
case WM_ERASEBKGND:
|
||||
{
|
||||
/* This is a hack to give us a white drawing surface */
|
||||
static HRGN hrgnSurface = 0;
|
||||
static HRGN hrgnTemp = 0;
|
||||
RECT r;
|
||||
|
||||
if( 0 == hrgnSurface )
|
||||
hrgnSurface = CreateRectRgn(_rectSurface.left,
|
||||
_rectSurface.top,
|
||||
_rectSurface.right,
|
||||
_rectSurface.bottom);
|
||||
if( 0 == hrgnTemp )
|
||||
hrgnTemp = CreateRectRgn(0,0,1,1);
|
||||
|
||||
GetClipRgn( (HDC)wParam, hrgnTemp );
|
||||
FillRect((HDC)wParam, &_rectSurface, GetStockObject(WHITE_BRUSH));
|
||||
ExtSelectClipRgn((HDC)wParam,hrgnSurface,RGN_XOR);
|
||||
GetClientRect(hDlg, &r);
|
||||
FillRect((HDC)wParam, &r, GetStockObject(LTGRAY_BRUSH));
|
||||
SelectClipRgn((HDC)wParam,hrgnTemp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
case WM_PAINT:
|
||||
{
|
||||
EvalAllOfHistory();
|
||||
return FALSE;
|
||||
}
|
||||
case WM_LBUTTONDOWN:
|
||||
{
|
||||
POINT pt = {LOWORD(lParam), HIWORD(lParam)};
|
||||
if( PtInRect(&_rectSurface, pt) )
|
||||
{
|
||||
char buf[32];
|
||||
RECT r;
|
||||
GetWindowRect(GetDlgItem(hDlg, IDD_SURFACE), &r);
|
||||
ClipCursor(&r);
|
||||
SetCapture(hDlg);
|
||||
_drawing = TRUE;
|
||||
DlgToSurface(&pt);
|
||||
sprintf( buf, "MoveTo(%d,%d)\n", pt.x, pt.y );
|
||||
EvalAndAddToHistory(buf,&lineno);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
if( _drawing )
|
||||
{
|
||||
POINT pt = {LOWORD(lParam), HIWORD(lParam)};
|
||||
char buf[32];
|
||||
DlgToSurface(&pt);
|
||||
sprintf( buf, "LineTo(%d,%d)\n", pt.x, pt.y );
|
||||
EvalAndAddToHistory(buf,&lineno);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
if( _drawing )
|
||||
{
|
||||
POINT pt = {LOWORD(lParam), HIWORD(lParam)};
|
||||
char buf[32];
|
||||
DlgToSurface(&pt);
|
||||
sprintf( buf, "LineTo(%d,%d)\n", pt.x, pt.y );
|
||||
EvalAndAddToHistory(buf,&lineno);
|
||||
ReleaseCapture();
|
||||
ClipCursor(NULL);
|
||||
_drawing = FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch( LOWORD(wParam) )
|
||||
{
|
||||
case IDOK:
|
||||
case IDCANCEL:
|
||||
EndDialog(hDlg, 0);
|
||||
return TRUE;
|
||||
case IDD_CLEAR:
|
||||
if( BN_CLICKED == HIWORD(wParam) )
|
||||
{
|
||||
ClearHistory();
|
||||
lineno = 0;
|
||||
InvalidateRect(hDlg, NULL, TRUE);
|
||||
}
|
||||
return TRUE;
|
||||
case IDD_EVAL:
|
||||
if( BN_CLICKED == HIWORD(wParam) )
|
||||
{
|
||||
char* p;
|
||||
int len;
|
||||
HWND edit = GetDlgItem(hDlg, IDD_CONSOLE);
|
||||
len = SendMessage(edit, WM_GETTEXTLENGTH, 0, 0 );
|
||||
p = malloc(len+2);
|
||||
SendMessage(edit, WM_GETTEXT, len+1, (LPARAM) p);
|
||||
strcat(p,"\n");
|
||||
if( EvalAndAddToHistory(p,&lineno) )
|
||||
SendMessage(edit, WM_SETTEXT, 0, (LPARAM)"");
|
||||
free(p);
|
||||
SetFocus(edit);
|
||||
}
|
||||
return TRUE;
|
||||
case IDD_SET_COLOR:
|
||||
if( BN_CLICKED == HIWORD(wParam) )
|
||||
{
|
||||
char Buf[256];
|
||||
char Buf2[256];
|
||||
Prompt( "Enter value or quoted color name", (char*)&Buf, 256 );
|
||||
sprintf(Buf2, "setPenColor(%s);\n", Buf);
|
||||
EvalAndAddToHistory(Buf2,&lineno);
|
||||
}
|
||||
return TRUE;
|
||||
case IDD_SET_WIDTH:
|
||||
if( BN_CLICKED == HIWORD(wParam) )
|
||||
{
|
||||
char Buf[256];
|
||||
char Buf2[256];
|
||||
Prompt( "Enter New Width (1-100)", (char*)&Buf, 256 );
|
||||
sprintf(Buf2, "setPenWidth(%s);\n", Buf);
|
||||
EvalAndAddToHistory(Buf2,&lineno);
|
||||
}
|
||||
return TRUE;
|
||||
case IDD_RECORD:
|
||||
if( BN_CLICKED == HIWORD(wParam) )
|
||||
{
|
||||
EvalAndAddToHistory("start_record()\n",&lineno);
|
||||
}
|
||||
return TRUE;
|
||||
case IDD_LOAD:
|
||||
if( BN_CLICKED == HIWORD(wParam) )
|
||||
{
|
||||
char Buf[_MAX_PATH+1];
|
||||
char Buf2[_MAX_PATH+32];
|
||||
OPENFILENAME ofn;
|
||||
|
||||
memset(&ofn,0,sizeof(ofn));
|
||||
Buf[0] = 0;
|
||||
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.lpstrFilter = "JavaScript Source (*.js)\0*.JS\0All Files (*.*)\0*.*\0\0";
|
||||
ofn.lpstrFile = Buf;
|
||||
ofn.nMaxFile = _MAX_PATH;
|
||||
ofn.lpstrTitle = "Load";
|
||||
ofn.lpstrDefExt = "JS";
|
||||
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
|
||||
|
||||
if( GetOpenFileName(&ofn) )
|
||||
{
|
||||
// escape all backslashes
|
||||
char c;
|
||||
int i1 = 0;
|
||||
int i2 = 0;
|
||||
while( 0 != (c = Buf2[i2++] = Buf[i1++]) )
|
||||
{
|
||||
if( c == '\\' )
|
||||
Buf2[i2++] = '\\';
|
||||
}
|
||||
|
||||
sprintf(Buf, "load(\"%s\");\n", Buf2);
|
||||
EvalAndAddToHistory(Buf,&lineno);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
case IDD_SAVE:
|
||||
if( BN_CLICKED == HIWORD(wParam) )
|
||||
{
|
||||
char Buf[_MAX_PATH+1];
|
||||
char Buf2[_MAX_PATH+32];
|
||||
OPENFILENAME ofn;
|
||||
|
||||
memset(&ofn,0,sizeof(ofn));
|
||||
Buf[0] = 0;
|
||||
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.lpstrFilter = "JavaScript Source (*.js)\0*.JS\0All Files (*.*)\0*.*\0\0";
|
||||
ofn.lpstrFile = Buf;
|
||||
ofn.nMaxFile = _MAX_PATH;
|
||||
ofn.lpstrTitle = "Save As";
|
||||
ofn.lpstrDefExt = "JS";
|
||||
ofn.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
|
||||
|
||||
if( GetSaveFileName(&ofn) )
|
||||
{
|
||||
// escape all backslashes
|
||||
char c;
|
||||
int i1 = 0;
|
||||
int i2 = 0;
|
||||
while( 0 != (c = Buf2[i2++] = Buf[i1++]) )
|
||||
{
|
||||
if( c == '\\' )
|
||||
Buf2[i2++] = '\\';
|
||||
}
|
||||
|
||||
sprintf(Buf, "save(\"%s\");\n", Buf2);
|
||||
EvalAndAddToHistory(Buf,&lineno);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
76
mozilla/js/samples/jsdraw/prompt.c
Normal file
76
mozilla/js/samples/jsdraw/prompt.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* user prompting code
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char* prompt;
|
||||
char* answer;
|
||||
int maxAnswer;
|
||||
} PROMPTDATA;
|
||||
|
||||
BOOL WINAPI
|
||||
PromptDlgProc(HWND hDlg, UINT msg, UINT wParam, LONG lParam)
|
||||
{
|
||||
static PROMPTDATA* pd;
|
||||
switch(msg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
pd = (PROMPTDATA*) lParam;
|
||||
SendMessage(GetDlgItem(hDlg, IDD_PROMPT_PROMPT),
|
||||
WM_SETTEXT, 0, (LPARAM) pd->prompt );
|
||||
SendMessage(GetDlgItem(hDlg, IDD_PROMPT_ANSWER),
|
||||
EM_LIMITTEXT, pd->maxAnswer, 0 );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_COMMAND:
|
||||
switch( LOWORD(wParam) )
|
||||
{
|
||||
case IDOK:
|
||||
case IDCANCEL:
|
||||
SendMessage(GetDlgItem(hDlg, IDD_PROMPT_ANSWER),
|
||||
WM_GETTEXT, pd->maxAnswer,
|
||||
(LPARAM) pd->answer );
|
||||
EndDialog(hDlg, 0);
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void Prompt( char* prompt, char* answer, int maxAnswer )
|
||||
{
|
||||
PROMPTDATA pd;
|
||||
pd.prompt = prompt;
|
||||
pd.answer = answer;
|
||||
pd.maxAnswer = maxAnswer;
|
||||
|
||||
DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDDIALOG_PROMPT),
|
||||
NULL, PromptDlgProc, (LPARAM) &pd);
|
||||
}
|
||||
|
||||
@@ -16,15 +16,22 @@
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nspr_aix_defs_h___
|
||||
#define nspr_aix_defs_h___
|
||||
/*
|
||||
* Windows resource ids
|
||||
*/
|
||||
|
||||
#define HAVE_LONG_LONG
|
||||
#undef HAVE_ALIGNED_DOUBLES
|
||||
#undef HAVE_ALIGNED_LONGLONGS
|
||||
#undef HAVE_WEAK_IO_SYMBOLS
|
||||
#undef HAVE_WEAK_MALLOC_SYMBOLS
|
||||
#undef HAVE_DLL
|
||||
#undef USE_DLFCN
|
||||
#define IDDIALOG_MAIN 100
|
||||
#define IDD_SURFACE 101
|
||||
#define IDD_CONSOLE 102
|
||||
#define IDD_HISTORY 103
|
||||
#define IDD_SET_COLOR 104
|
||||
#define IDD_SET_WIDTH 105
|
||||
#define IDD_RECORD 106
|
||||
#define IDD_SAVE 107
|
||||
#define IDD_LOAD 108
|
||||
#define IDD_CLEAR 109
|
||||
#define IDD_EVAL 110
|
||||
|
||||
#endif /* nspr_aix_defs_h___ */
|
||||
#define IDDIALOG_PROMPT 200
|
||||
#define IDD_PROMPT_PROMPT 201
|
||||
#define IDD_PROMPT_ANSWER 202
|
||||
17
mozilla/js/samples/jsdraw/run/autoload.js
Normal file
17
mozilla/js/samples/jsdraw/run/autoload.js
Normal file
@@ -0,0 +1,17 @@
|
||||
function drawRect(x,y,dx,dy)
|
||||
{
|
||||
MoveTo(x,y);
|
||||
LineTo(x+dx,y);
|
||||
LineTo(x+dx,y+dy);
|
||||
LineTo(x,y+dy);
|
||||
LineTo(x,y);
|
||||
}
|
||||
|
||||
function drawSquare(x,y,d)
|
||||
{
|
||||
MoveTo(x,y);
|
||||
LineTo(x+d,y);
|
||||
LineTo(x+d,y+d);
|
||||
LineTo(x,y+d);
|
||||
LineTo(x,y);
|
||||
}
|
||||
@@ -1,27 +1,38 @@
|
||||
# This file is required for the Mac client mozilla build.
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
js.msg
|
||||
jsapi.h
|
||||
jsarena.h
|
||||
jspubtd.h
|
||||
jsarray.h
|
||||
jsatom.h
|
||||
jsbool.h
|
||||
jsclist.h
|
||||
jscntxt.h
|
||||
jscompat.h
|
||||
jsconfig.h
|
||||
jscpucfg.h
|
||||
jsdate.h
|
||||
jsdbgapi.h
|
||||
jsdtoa.h
|
||||
jsemit.h
|
||||
jsfun.h
|
||||
jsgc.h
|
||||
jshash.h
|
||||
jsinterp.h
|
||||
jslock.h
|
||||
jslong.h
|
||||
jsmath.h
|
||||
jsnum.h
|
||||
jsobj.h
|
||||
jsopcode.def
|
||||
jsopcode.tbl
|
||||
jsopcode.h
|
||||
jsosdep.h
|
||||
jsotypes.h
|
||||
jsparse.h
|
||||
jsprf.h
|
||||
jsprvtd.h
|
||||
jspubtd.h
|
||||
jsregexp.h
|
||||
@@ -29,3 +40,8 @@ jsscan.h
|
||||
jsscope.h
|
||||
jsscript.h
|
||||
jsstr.h
|
||||
jstypes.h
|
||||
jsutil.h
|
||||
jsxdrapi.h
|
||||
|
||||
|
||||
|
||||
@@ -1,236 +0,0 @@
|
||||
#! gmake
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../..
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
ifdef MOZ_OJI
|
||||
DIRS = liveconnect
|
||||
endif
|
||||
|
||||
LIBRARY_NAME = js
|
||||
|
||||
ifeq ($(subst /,_,$(shell uname -s)),OS2)
|
||||
ifndef XCFLAGS
|
||||
OS2_IMPLIB=1
|
||||
LIBRARY = js$(MOZ_BITS)$(VERSION_NUMBER).$(LIB_SUFFIX)
|
||||
DEF_FILE = jsos2$(VERSION_NUMBER).def
|
||||
EXTRA_LIBS = $(LIBNSPR) $(LIBNSJAVA)
|
||||
else
|
||||
EXTRA_LIBS = $(LIBNSPR) $(LIBNSJAVA) $(OBJDIR)/libjs.lib
|
||||
endif
|
||||
endif
|
||||
|
||||
MODULE = js
|
||||
|
||||
CSRCS = jsapi.c \
|
||||
jsarray.c \
|
||||
jsatom.c \
|
||||
jsbool.c \
|
||||
jscntxt.c \
|
||||
jsdate.c \
|
||||
jsdbgapi.c \
|
||||
jsemit.c \
|
||||
jsfun.c \
|
||||
jsgc.c \
|
||||
jsinterp.c \
|
||||
jsmath.c \
|
||||
jsnum.c \
|
||||
jsobj.c \
|
||||
jsopcode.c \
|
||||
jsparse.c \
|
||||
jsregexp.c \
|
||||
jsscan.c \
|
||||
jsscope.c \
|
||||
jsscript.c \
|
||||
jsstr.c \
|
||||
jslock.c \
|
||||
jsxdrapi.c \
|
||||
prmjtime.c \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = jsapi.h \
|
||||
jsarray.h \
|
||||
jsatom.h \
|
||||
jsbool.h \
|
||||
jscntxt.h \
|
||||
jscompat.h \
|
||||
jsconfig.h \
|
||||
jsdate.h \
|
||||
jsdbgapi.h \
|
||||
jsemit.h \
|
||||
jsfun.h \
|
||||
jsgc.h \
|
||||
jsinterp.h \
|
||||
jslock.h \
|
||||
jsmath.h \
|
||||
jsnum.h \
|
||||
jsobj.h \
|
||||
jsopcode.def \
|
||||
jsopcode.h \
|
||||
jsparse.h \
|
||||
jsprvtd.h \
|
||||
jspubtd.h \
|
||||
jsregexp.h \
|
||||
jsscan.h \
|
||||
jsscope.h \
|
||||
jsscript.h \
|
||||
jsstr.h \
|
||||
jsxdrapi.h \
|
||||
$(NULL)
|
||||
|
||||
# when using gcc the assembly is inlined in the C-file (see jslock.c)
|
||||
ifdef NS_USE_NATIVE
|
||||
ASFILES = $(wildcard *_$(OS_ARCH).s)
|
||||
endif
|
||||
|
||||
JS_SAFE_ARENA = 1
|
||||
|
||||
ifdef JS_SAFE_ARENA
|
||||
DEFINES += -DJS_USE_SAFE_ARENA
|
||||
CSRCS += prarena.c
|
||||
endif
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
ifndef BUILD_OPT
|
||||
MOCHAFILE = 1
|
||||
endif
|
||||
|
||||
ifdef JSFILE
|
||||
DEFINES += -DJSFILE
|
||||
endif
|
||||
|
||||
ifdef JS_THREADSAFE
|
||||
DEFINES += -DJS_THREADSAFE
|
||||
endif
|
||||
|
||||
ifdef JS_NO_THIN_LOCKS
|
||||
DEFINES += -DJS_USE_ONLY_NSPR_LOCKS
|
||||
endif
|
||||
|
||||
ifdef JS_VERSION
|
||||
DEFINES += -DJS_VERSION=$(JS_VERSION)
|
||||
endif
|
||||
|
||||
ifeq ($(CPU_ARCH),sparc)
|
||||
|
||||
ifndef JS_NO_ULTRA
|
||||
ULTRA_OPTIONS := -xarch=v8plus,-DULTRA_SPARC
|
||||
ULTRA_OPTIONSCC := -DULTRA_SPARC
|
||||
else
|
||||
ULTRA_OPTIONS := -xarch=v8
|
||||
ULTRA_OPTIONSCC :=
|
||||
endif
|
||||
|
||||
ifeq ($(shell uname -m),sun4u)
|
||||
ASFLAGS += -Wa,$(ULTRA_OPTIONS),-P,-L,-D_ASM,-D__STDC__=0 $(ULTRA_OPTIONSCC)
|
||||
else
|
||||
ASFLAGS += -Wa,-xarch=v8,-P,-L,-D_ASM,-D__STDC__=0
|
||||
endif
|
||||
|
||||
endif # sparc
|
||||
|
||||
INCLUDES += -I.
|
||||
|
||||
ifdef NSPR20
|
||||
INCLUDES += -I$(DIST)/include/nspr20/pr
|
||||
else
|
||||
INCLUDES += -I$(XPDIST)/public/nspr
|
||||
endif
|
||||
|
||||
ifndef NSBUILDROOT
|
||||
JSJAVA_STUBHEADERS = -I$(DEPTH)/sun-java/include/_gen \
|
||||
-I$(DEPTH)/sun-java/netscape/javascript/_jri \
|
||||
-I$(DEPTH)/sun-java/netscape/security/_jri
|
||||
else
|
||||
JSJAVA_STUBHEADERS = -I$(JRI_GEN_DIR) -I$(JDK_GEN_DIR)
|
||||
endif
|
||||
|
||||
JSJAVA_CFLAGS = -I$(DEPTH)/sun-java/md-include \
|
||||
-I$(DEPTH)/sun-java/include \
|
||||
$(JSJAVA_STUBHEADERS)
|
||||
|
||||
# LIBNSPR includes unneeded libmsgc21.a, but abstracts nspr version,
|
||||
# etc. nicely.
|
||||
LDFLAGS = $(LIBNSPR) -lm
|
||||
|
||||
ifeq ($(OS_ARCH), OSF1)
|
||||
LDFLAGS += -lc_r
|
||||
endif
|
||||
ifeq ($(OS_ARCH), SunOS)
|
||||
LDFLAGS += -lposix4 -ldl -lnsl -lsocket
|
||||
endif
|
||||
ifeq ($(OS_ARCH), Linux)
|
||||
LDFLAGS += -ldl
|
||||
endif
|
||||
|
||||
# this requires clobbering and recompiling with XCFLAGS=-DJSFILE
|
||||
js:
|
||||
$(MAKE) clobber
|
||||
$(MAKE) XCFLAGS=-DJSFILE $(OBJDIR)/js$(BIN_SUFFIX)
|
||||
|
||||
.PHONY: js$(BIN_SUFFIX)
|
||||
|
||||
ifneq ($(OS_ARCH),OS2)
|
||||
$(OBJDIR)/js$(BIN_SUFFIX): $(OBJDIR)/js.o $(LIBRARY)
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CC) -o $@ $(OBJDIR)/js.o $(LIBRARY) $(LDFLAGS)
|
||||
else
|
||||
OS_CFLAGS += -tm-
|
||||
$(OBJDIR)/js$(BIN_SUFFIX): $(OBJDIR)/js.o $(LIBRARY)
|
||||
@$(MAKE_OBJDIR)
|
||||
$(LINK_EXE) -OUT:$@ $(OBJDIR)/js.o $(LIBRARIES) $(EXTRA_LIBS)
|
||||
endif
|
||||
|
||||
# hardwire dependencies on jsopcode.def
|
||||
jsopcode.h jsopcode.c: jsopcode.def
|
||||
|
||||
# this section was put in the merged by danda into the
|
||||
# JAVA_*_MERGE section and normally would have
|
||||
# been removed. However it looks like it shouldn't have
|
||||
# been put there in the first place, so we're leaving it
|
||||
# here until danda can confirm (we don't have OS/2 machines
|
||||
# to build on) - hshaw/sudu
|
||||
#
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
$(OBJDIR)/js.o: js.c
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CC) -Fo$@ -c $(CFLAGS) $(JSJAVA_CFLAGS) js.c
|
||||
endif
|
||||
|
||||
|
||||
refdiff:
|
||||
@for f in `cat commfiles`; do \
|
||||
t=/tmp/refdiff.$$$$; \
|
||||
trap 'rm -f $$t' 0 1 2 15; \
|
||||
sed -f prconv.sed ../ref/$$f > $$t; \
|
||||
cmp -s $$t $$f; \
|
||||
if test $$? -ne 0; then \
|
||||
echo "=== $$f"; \
|
||||
diff $$f $$t; \
|
||||
fi; \
|
||||
rm -f $$t; \
|
||||
done
|
||||
|
||||
refconv:
|
||||
@for f in `cat commfiles`; do \
|
||||
echo "=== $$f"; \
|
||||
sed -f prconv.sed ../ref/$$f > $$f; \
|
||||
done
|
||||
|
||||
.PHONY: refdiff refconv
|
||||
@@ -1,4 +1,4 @@
|
||||
#! gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
@@ -13,63 +13,87 @@
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
FDLIBM_LIBRARY = fdlibm/libfdm.a
|
||||
JSMATH_PRELINK = jsmathtemp.o
|
||||
JS_SAFE_ARENA = 1
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
ifdef MOZ_OJI
|
||||
DIRS = liveconnect
|
||||
endif
|
||||
|
||||
LIBRARY_NAME = js
|
||||
|
||||
ifeq ($(subst /,_,$(shell uname -s)),OS2)
|
||||
ifndef XCFLAGS
|
||||
OS2_IMPLIB=1
|
||||
LIBRARY = js$(MOZ_BITS)$(VERSION_NUMBER).$(LIB_SUFFIX)
|
||||
DEF_FILE = jsos2$(VERSION_NUMBER).def
|
||||
EXTRA_LIBS = $(LIBNSPR) $(LIBNSJAVA)
|
||||
else
|
||||
EXTRA_LIBS = $(LIBNSPR) $(LIBNSJAVA) $(OBJDIR)/libjs.lib
|
||||
endif
|
||||
endif
|
||||
|
||||
LIBRARY_NAME = $(MOZ_LIB_JS_PREFIX)js
|
||||
MODULE = js
|
||||
|
||||
SIMPLE_PROGRAMS = jscpucfg
|
||||
|
||||
ifdef MOZ_OJI
|
||||
DIRS = liveconnect
|
||||
endif
|
||||
|
||||
DIRS += fdlibm xpconnect
|
||||
|
||||
GARBAGE += $(JSMATH_PRELINK) $(OBJDIR)/jscpucfg.o $(OBJDIR)/jsautocfg.h
|
||||
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
ifndef XCFLAGS
|
||||
OS2_IMPLIB = 1
|
||||
LIBRARY = js$(MOZ_BITS)$(VERSION_NUMBER).$(LIB_SUFFIX)
|
||||
DEF_FILE = jsos2$(VERSION_NUMBER).def
|
||||
EXTRA_LIBS = $(NSPR_LIBS) $(LIBNSJAVA)
|
||||
else
|
||||
EXTRA_LIBS = $(NSPR_LIBS) $(LIBNSJAVA) $(OBJDIR)/libjs.lib
|
||||
endif
|
||||
OS_CFLAGS += -tm-
|
||||
endif
|
||||
|
||||
CSRCS = jsapi.c \
|
||||
jsarena.c \
|
||||
jsarray.c \
|
||||
jsatom.c \
|
||||
jsbool.c \
|
||||
jscntxt.c \
|
||||
jsdate.c \
|
||||
jsdbgapi.c \
|
||||
jsdtoa.c \
|
||||
jsemit.c \
|
||||
jsexn.c \
|
||||
jsfun.c \
|
||||
jsgc.c \
|
||||
jshash.c \
|
||||
jsinterp.c \
|
||||
jslock.c \
|
||||
jslog2.c \
|
||||
jslong.c \
|
||||
jsmath.c \
|
||||
jsnum.c \
|
||||
jsobj.c \
|
||||
jsopcode.c \
|
||||
jsparse.c \
|
||||
jsprf.c \
|
||||
jsregexp.c \
|
||||
jsscan.c \
|
||||
jsscope.c \
|
||||
jsscript.c \
|
||||
jsstr.c \
|
||||
jslock.c \
|
||||
jsutil.c \
|
||||
jsxdrapi.c \
|
||||
prmjtime.c \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = jsapi.h \
|
||||
EXPORTS = js.msg \
|
||||
jsapi.h \
|
||||
jsarray.h \
|
||||
jsarena.h \
|
||||
jsatom.h \
|
||||
jsbit.h \
|
||||
jsbool.h \
|
||||
jsclist.h \
|
||||
jscntxt.h \
|
||||
jscompat.h \
|
||||
jsconfig.h \
|
||||
@@ -78,14 +102,19 @@ EXPORTS = jsapi.h \
|
||||
jsemit.h \
|
||||
jsfun.h \
|
||||
jsgc.h \
|
||||
jshash.h \
|
||||
jsinterp.h \
|
||||
jslock.h \
|
||||
jslong.h \
|
||||
jsmath.h \
|
||||
jsnum.h \
|
||||
jsobj.h \
|
||||
jsopcode.def \
|
||||
jsopcode.tbl \
|
||||
jsopcode.h \
|
||||
jsosdep.h \
|
||||
jsotypes.h \
|
||||
jsparse.h \
|
||||
jsprf.h \
|
||||
jsprvtd.h \
|
||||
jspubtd.h \
|
||||
jsregexp.h \
|
||||
@@ -93,71 +122,68 @@ EXPORTS = jsapi.h \
|
||||
jsscope.h \
|
||||
jsscript.h \
|
||||
jsstr.h \
|
||||
jstypes.h \
|
||||
jsutil.h \
|
||||
jsxdrapi.h \
|
||||
jsstddef.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
# when using gcc the assembly is inlined in the C-file (see jslock.c)
|
||||
# When using gcc the assembly is inlined in the C-file (see jslock.c)
|
||||
ifdef NS_USE_NATIVE
|
||||
ASFILES = $(wildcard $(srcdir)/*_$(OS_ARCH).s)
|
||||
ASFILES = $(notdir $(wildcard $(srcdir)/*_$(OS_ARCH).s))
|
||||
endif
|
||||
|
||||
JS_SAFE_ARENA = 1
|
||||
|
||||
ifdef JS_SAFE_ARENA
|
||||
DEFINES += -DJS_USE_SAFE_ARENA
|
||||
CSRCS += prarena.c
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifndef BUILD_OPT
|
||||
MOCHAFILE = 1
|
||||
endif
|
||||
|
||||
ifdef JSFILE
|
||||
DEFINES += -DJSFILE
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir)
|
||||
|
||||
ifneq ($(findstring -L,$(NSPR_LIBS)),)
|
||||
NSPR_STATIC_PATH = $(subst -L,,$(findstring -L,$(NSPR_LIBS)))
|
||||
else
|
||||
NSPR_STATIC_PATH = $(DIST)/lib
|
||||
endif
|
||||
LDFLAGS = $(pathsubst -l%,$(NSPR_STATIC_PATH)/%.a,$(NSPR_LIBS)) -lm
|
||||
|
||||
ifdef JS_SAFE_ARENA
|
||||
DEFINES += -DJS_USE_SAFE_ARENA
|
||||
endif
|
||||
|
||||
ifdef JS_THREADSAFE
|
||||
DEFINES += -DJS_THREADSAFE
|
||||
DEFINES += -DJS_THREADSAFE
|
||||
endif
|
||||
|
||||
ifdef JS_NO_THIN_LOCKS
|
||||
DEFINES += -DJS_USE_ONLY_NSPR_LOCKS
|
||||
DEFINES += -DJS_USE_ONLY_NSPR_LOCKS
|
||||
endif
|
||||
|
||||
ifdef JS_VERSION
|
||||
DEFINES += -DJS_VERSION=$(JS_VERSION)
|
||||
DEFINES += -DJS_VERSION=$(JS_VERSION)
|
||||
endif
|
||||
|
||||
ifeq ($(CPU_ARCH),sparc)
|
||||
|
||||
ifndef JS_NO_ULTRA
|
||||
ULTRA_OPTIONS := -xarch=v8plus,-DULTRA_SPARC
|
||||
ULTRA_OPTIONSCC := -DULTRA_SPARC
|
||||
ULTRA_OPTIONS := -xarch=v8plus,-DULTRA_SPARC
|
||||
ULTRA_OPTIONSCC := -DULTRA_SPARC
|
||||
else
|
||||
ULTRA_OPTIONS := -xarch=v8
|
||||
ULTRA_OPTIONSCC :=
|
||||
ULTRA_OPTIONS := -xarch=v8
|
||||
ULTRA_OPTIONSCC :=
|
||||
endif
|
||||
|
||||
ifeq ($(shell uname -m),sun4u)
|
||||
ASFLAGS += -Wa,$(ULTRA_OPTIONS),-P,-L,-D_ASM,-D__STDC__=0 $(ULTRA_OPTIONSCC)
|
||||
ASFLAGS += -Wa,$(ULTRA_OPTIONS),-P,-L,-D_ASM,-D__STDC__=0 $(ULTRA_OPTIONSCC)
|
||||
else
|
||||
ASFLAGS += -Wa,-xarch=v8,-P,-L,-D_ASM,-D__STDC__=0
|
||||
ASFLAGS += -Wa,-xarch=v8,-P,-L,-D_ASM,-D__STDC__=0
|
||||
endif
|
||||
|
||||
endif # sparc
|
||||
|
||||
INCLUDES += -I$(srcdir)
|
||||
|
||||
ifdef NSPR20
|
||||
INCLUDES += -I$(DIST)/include/nspr20/pr
|
||||
else
|
||||
INCLUDES += -I$(XPDIST)/public/nspr
|
||||
endif
|
||||
|
||||
ifndef NSBUILDROOT
|
||||
JSJAVA_STUBHEADERS = -I$(topsrcdir)/sun-java/include/_gen \
|
||||
-I$(topsrcdir)/sun-java/netscape/javascript/_jri \
|
||||
@@ -170,72 +196,68 @@ JSJAVA_CFLAGS = -I$(topsrcdir)/sun-java/md-include \
|
||||
-I$(topsrcdir)/sun-java/include \
|
||||
$(JSJAVA_STUBHEADERS)
|
||||
|
||||
# LIBNSPR includes unneeded libmsgc21.a, but abstracts nspr version,
|
||||
# etc. nicely.
|
||||
LDFLAGS = $(LIBNSPR) -lm
|
||||
DASH_R = -r
|
||||
|
||||
ifeq ($(OS_ARCH), OSF1)
|
||||
LDFLAGS += -lc_r
|
||||
endif
|
||||
ifeq ($(OS_ARCH), SunOS)
|
||||
LDFLAGS += -lposix4 -ldl -lnsl -lsocket
|
||||
ifeq ($(OS_ARCH), IRIX)
|
||||
LDFLAGS += -n32
|
||||
endif
|
||||
ifeq ($(OS_ARCH), Linux)
|
||||
LDFLAGS += -ldl
|
||||
LDFLAGS += -ldl
|
||||
endif
|
||||
|
||||
# this requires clobbering and recompiling with XCFLAGS=-DJSFILE
|
||||
js:
|
||||
$(MAKE) clobber
|
||||
$(MAKE) XCFLAGS=-DJSFILE $(OBJDIR)/js$(BIN_SUFFIX)
|
||||
|
||||
.PHONY: js$(BIN_SUFFIX)
|
||||
|
||||
ifneq ($(OS_ARCH),OS2)
|
||||
$(OBJDIR)/js$(BIN_SUFFIX): $(OBJDIR)/js.o $(LIBRARY)
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CC) -o $@ $(OBJDIR)/js.o $(LIBRARY) $(LDFLAGS)
|
||||
ifeq ($(OS_ARCH), FreeBSD)
|
||||
LDFLAGS += -pthread
|
||||
endif
|
||||
ifeq ($(OS_ARCH), OSF1)
|
||||
LDFLAGS += -lc_r
|
||||
endif
|
||||
ifeq ($(OS_ARCH), QNX)
|
||||
DASH_R =
|
||||
endif
|
||||
ifeq ($(OS_ARCH), SunOS)
|
||||
ifeq ($(OS_RELEASE),4.1)
|
||||
LDFLAGS += -ldl -lnsl
|
||||
else
|
||||
OS_CFLAGS += -tm-
|
||||
$(OBJDIR)/js$(BIN_SUFFIX): $(OBJDIR)/js.o $(LIBRARY)
|
||||
@$(MAKE_OBJDIR)
|
||||
$(LINK_EXE) -OUT:$@ $(OBJDIR)/js.o $(LIBRARIES) $(EXTRA_LIBS)
|
||||
LDFLAGS += -lposix4 -ldl -lnsl -lsocket
|
||||
endif
|
||||
endif
|
||||
|
||||
# hardwire dependencies on jsopcode.def
|
||||
jsopcode.h jsopcode.c: jsopcode.def
|
||||
|
||||
# this section was put in the merged by danda into the
|
||||
# JAVA_*_MERGE section and normally would have
|
||||
# been removed. However it looks like it shouldn't have
|
||||
# been put there in the first place, so we're leaving it
|
||||
# here until danda can confirm (we don't have OS/2 machines
|
||||
# to build on) - hshaw/sudu
|
||||
#
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
$(OBJDIR)/js.o: js.c
|
||||
# special rule for jsmath.o since we want to incrementally link
|
||||
# against fdlibm to pull in only what is needed
|
||||
jsmath.o: $(FDLIBM_LIBRARY) $(JSMATH_PRELINK)
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CC) -Fo$@ -c $(CFLAGS) $(JSJAVA_CFLAGS) js.c
|
||||
$(LD) $(DASH_R) -o $@ $(JSMATH_PRELINK) $(FDLIBM_LIBRARY)
|
||||
|
||||
$(JSMATH_PRELINK): jsmath.c
|
||||
@$(MAKE_OBJDIR)
|
||||
ifneq (,$(filter OS2 WINNT,$(OS_ARCH)))
|
||||
$(CC) -Fo$@ -c $(CFLAGS) $<
|
||||
else
|
||||
$(CC) -o $@ -c $(CFLAGS) $<
|
||||
endif
|
||||
|
||||
# An AIX Optimization bug causes PR_dtoa() & JS_dtoa to produce wrong result.
|
||||
# This suppresses optimization for this single compilation unit.
|
||||
ifeq ($(OS_ARCH), AIX)
|
||||
$(OBJDIR)/jsdtoa.o: jsdtoa.c
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CC) -o $@ -c $(filter-out -O, $(CFLAGS)) $<
|
||||
endif
|
||||
|
||||
refdiff:
|
||||
@for f in `cat commfiles`; do \
|
||||
t=/tmp/refdiff.$$$$; \
|
||||
trap 'rm -f $$t' 0 1 2 15; \
|
||||
sed -f prconv.sed ../ref/$$f > $$t; \
|
||||
cmp -s $$t $$f; \
|
||||
if test $$? -ne 0; then \
|
||||
echo "=== $$f"; \
|
||||
diff $$f $$t; \
|
||||
fi; \
|
||||
rm -f $$t; \
|
||||
done
|
||||
# ripped from $(topsrcdir)/config/rules.mk
|
||||
$(FDLIBM_LIBRARY):
|
||||
set -e; \
|
||||
set $(EXIT_ON_ERROR); \
|
||||
echo "cd $(@D); $(MAKE) $(@F)"; \
|
||||
oldDir=`pwd`; \
|
||||
cd $(@D); $(MAKE) $(@F); cd $$oldDir; \
|
||||
set +e;
|
||||
|
||||
refconv:
|
||||
@for f in `cat commfiles`; do \
|
||||
echo "=== $$f"; \
|
||||
sed -f prconv.sed ../ref/$$f > $$f; \
|
||||
done
|
||||
jsopcode.h jsopcode.c: jsopcode.tbl
|
||||
|
||||
$(OBJDIR)/jsautocfg.h: $(OBJDIR)/jscpucfg
|
||||
rm -f $@
|
||||
$(OBJDIR)/jscpucfg > $@
|
||||
|
||||
export:: $(OBJDIR)/jsautocfg.h
|
||||
$(INSTALL) -m 444 $< $(DIST)/include
|
||||
|
||||
.PHONY: refdiff refconv
|
||||
|
||||
@@ -18,86 +18,47 @@
|
||||
# JSRef GNUmake makefile.
|
||||
#
|
||||
|
||||
# Set os+release dependent make variables
|
||||
OS_ARCH := $(subst /,_,$(shell uname -s))
|
||||
DEPTH = .
|
||||
|
||||
# Attempt to differentiate between SunOS 5.4 and x86 5.4
|
||||
OS_CPUARCH := $(shell uname -m)
|
||||
ifeq ($(OS_CPUARCH),i86pc)
|
||||
OS_RELEASE := $(shell uname -r)_$(OS_CPUARCH)
|
||||
else
|
||||
ifeq ($(OS_ARCH),AIX)
|
||||
OS_RELEASE := $(shell uname -v).$(shell uname -r)
|
||||
else
|
||||
OS_RELEASE := $(shell uname -r)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Virtually all Linux versions are identical.
|
||||
# Any distinctions are handled in linux.h
|
||||
ifeq ($(OS_ARCH),Linux)
|
||||
OS_CONFIG := Linux_All
|
||||
else
|
||||
ifeq ($(OS_ARCH),dgux)
|
||||
OS_CONFIG := dgux
|
||||
else
|
||||
OS_CONFIG := $(OS_ARCH)$(OS_OBJTYPE)$(OS_RELEASE)
|
||||
endif
|
||||
endif
|
||||
|
||||
ASFLAGS =
|
||||
DEFINES =
|
||||
include config.mk
|
||||
|
||||
#NS_USE_NATIVE = 1
|
||||
|
||||
include config/$(OS_CONFIG).mk
|
||||
|
||||
ifdef BUILD_OPT
|
||||
OPTIMIZER += -O
|
||||
DEFINES += -UDEBUG -DNDEBUG -UDEBUG_$(shell whoami)
|
||||
OBJDIR_TAG = _OPT
|
||||
else
|
||||
ifdef USE_MSVC
|
||||
OPTIMIZER = -Zi
|
||||
OTHER_LIBS += fdlibm/$(OBJDIR)/fdlibm.lib
|
||||
else
|
||||
OPTIMIZER = -g
|
||||
endif
|
||||
DEFINES += -DDEBUG -DDEBUG_$(shell whoami)
|
||||
OBJDIR_TAG = _DBG
|
||||
OTHER_LIBS += -Lfdlibm/$(OBJDIR) -lfdm
|
||||
endif
|
||||
|
||||
#DEFINES += -DJS_THREADSAFE
|
||||
ifdef JS_THREADSAFE
|
||||
DEFINES += -DJS_THREADSAFE
|
||||
INCLUDES += -I../../dist/$(OBJDIR)/include
|
||||
ifdef USE_MSVC
|
||||
OTHER_LIBS += ../../dist/$(OBJDIR)/lib/libnspr3.lib
|
||||
else
|
||||
OTHER_LIBS += -L../../dist/$(OBJDIR)/lib -lnspr3
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef JS_NO_THIN_LOCKS
|
||||
DEFINES += -DJS_USE_ONLY_NSPR_LOCKS
|
||||
endif
|
||||
|
||||
# Name of the binary code directories
|
||||
OBJDIR = $(OS_CONFIG)$(OBJDIR_TAG).OBJ
|
||||
VPATH = $(OBJDIR)
|
||||
|
||||
# Automatic make dependencies file
|
||||
DEPENDENCIES = $(OBJDIR)/.md
|
||||
|
||||
define MAKE_OBJDIR
|
||||
if test ! -d $(@D); then rm -rf $(@D); mkdir $(@D); fi
|
||||
endef
|
||||
|
||||
# Look in OBJDIR to find prcpucfg.h
|
||||
INCLUDES = -I$(OBJDIR)
|
||||
ifdef JS_HAS_FILE_OBJECT
|
||||
DEFINES += -DJS_HAS_FILE_OBJECT
|
||||
endif
|
||||
|
||||
#
|
||||
# XCFLAGS may be set in the environment or on the gmake command line
|
||||
#
|
||||
CFLAGS = $(OPTIMIZER) $(OS_CFLAGS) $(DEFINES) $(INCLUDES) \
|
||||
-DJSFILE $(XCFLAGS)
|
||||
CFLAGS += $(OPTIMIZER) $(OS_CFLAGS) $(DEFINES) $(INCLUDES) $(XCFLAGS)
|
||||
LDFLAGS = -lm $(XLDFLAGS)
|
||||
|
||||
#
|
||||
# Ask perl what flags it was built with, so we can build js with similar flags
|
||||
# and link properly. Viva gmake.
|
||||
#
|
||||
ifdef PERLCONNECT
|
||||
ifdef JS_PERLCONNECT
|
||||
DEFINES += -DPERLCONNECT
|
||||
|
||||
PERLCFLAGS := $(shell perl -MExtUtils::Embed -e ccopts)
|
||||
@@ -107,6 +68,20 @@ CFLAGS += $(PERLCFLAGS)
|
||||
LDFLAGS += $(PERLLDFLAGS)
|
||||
endif
|
||||
|
||||
#
|
||||
# Line editing support.
|
||||
#
|
||||
ifdef JS_READLINE
|
||||
DEFINES += -DEDITLINE
|
||||
PROG_LIBS += -lreadline
|
||||
else
|
||||
ifdef JS_EDITLINE
|
||||
PREDIRS += editline
|
||||
DEFINES += -DEDITLINE
|
||||
PROG_LIBS += -Leditline/$(OBJDIR) -ledit
|
||||
endif
|
||||
endif
|
||||
|
||||
# For purify
|
||||
PURE_CFLAGS = -DXP_UNIX $(OPTIMIZER) $(PURE_OS_CFLAGS) $(DEFINES) \
|
||||
$(INCLUDES) $(XCFLAGS)
|
||||
@@ -126,6 +101,7 @@ JS_HFILES = \
|
||||
jsfun.h \
|
||||
jsgc.h \
|
||||
jsinterp.h \
|
||||
jslibmath.h \
|
||||
jslock.h \
|
||||
jsmath.h \
|
||||
jsnum.h \
|
||||
@@ -137,11 +113,7 @@ JS_HFILES = \
|
||||
jsdtoa.h \
|
||||
jshash.h \
|
||||
jslong.h \
|
||||
jsmacos.h \
|
||||
jsosdep.h \
|
||||
jspcos.h \
|
||||
jsprintf.h \
|
||||
jstime.h \
|
||||
jstypes.h \
|
||||
jsprvtd.h \
|
||||
jspubtd.h \
|
||||
@@ -158,32 +130,50 @@ API_HFILES = \
|
||||
jsdbgapi.h \
|
||||
$(NULL)
|
||||
|
||||
HFILES = $(JS_HFILES) $(API_HFILES)
|
||||
OTHER_HFILES = \
|
||||
jsaddr.h \
|
||||
jsbit.h \
|
||||
jscompat.h \
|
||||
jscpucfg.h \
|
||||
jsotypes.h \
|
||||
jsstddef.h \
|
||||
prmjtime.h \
|
||||
resource.h \
|
||||
jsopcode.tbl \
|
||||
js.msg \
|
||||
jsshell.msg \
|
||||
$(NULL)
|
||||
|
||||
ifndef PREBUILT_CPUCFG
|
||||
OTHER_HFILES += $(OBJDIR)/jsautocfg.h
|
||||
endif
|
||||
|
||||
HFILES = $(JS_HFILES) $(API_HFILES) $(OTHER_HFILES)
|
||||
|
||||
JS_CFILES = \
|
||||
jsapi.c \
|
||||
jsarena.c \
|
||||
jsarray.c \
|
||||
jsatom.c \
|
||||
jsbool.c \
|
||||
jscntxt.c \
|
||||
jsdate.c \
|
||||
jsdbgapi.c \
|
||||
jsdtoa.c \
|
||||
jsemit.c \
|
||||
jsexn.c \
|
||||
jsfun.c \
|
||||
jsgc.c \
|
||||
jshash.c \
|
||||
jsinterp.c \
|
||||
jslock.c \
|
||||
jslog2.c \
|
||||
jslong.c \
|
||||
jsmath.c \
|
||||
jsnum.c \
|
||||
jsobj.c \
|
||||
jsopcode.c \
|
||||
jsparse.c \
|
||||
jsarena.c \
|
||||
jsdtoa.c \
|
||||
jshash.c \
|
||||
jslog2.c \
|
||||
jslong.c \
|
||||
jsprf.c \
|
||||
jsregexp.c \
|
||||
jsscan.c \
|
||||
@@ -195,106 +185,76 @@ JS_CFILES = \
|
||||
prmjtime.c \
|
||||
$(NULL)
|
||||
|
||||
ifdef PERLCONNECT
|
||||
PREDIRS += fdlibm
|
||||
ifdef JS_LIVECONNECT
|
||||
DIRS += liveconnect
|
||||
endif
|
||||
|
||||
ifdef JS_PERLCONNECT
|
||||
JS_CFILES += jsperl.c
|
||||
endif
|
||||
|
||||
ifdef JS_HAS_FILE_OBJECT
|
||||
JS_CFILES += jsfile.c
|
||||
JS_HFILES += jsfile.h
|
||||
endif
|
||||
|
||||
LIB_CFILES = $(JS_CFILES)
|
||||
LIB_ASFILES := $(wildcard *_$(OS_ARCH).s)
|
||||
PROG_CFILES = js.c
|
||||
|
||||
ifdef USE_MSVC
|
||||
LIB_OBJS = $(addprefix $(OBJDIR)/, $(LIB_CFILES:.c=.obj))
|
||||
PROG_OBJS = $(addprefix $(OBJDIR)/, $(PROG_CFILES:.c=.obj))
|
||||
else
|
||||
LIB_OBJS = $(addprefix $(OBJDIR)/, $(LIB_CFILES:.c=.o))
|
||||
LIB_OBJS += $(addprefix $(OBJDIR)/, $(LIB_ASFILES:.s=.o))
|
||||
PROG_OBJS = $(addprefix $(OBJDIR)/, $(PROG_CFILES:.c=.o))
|
||||
endif
|
||||
|
||||
CFILES = $(LIB_CFILES) $(PROG_CFILES)
|
||||
OBJS = $(LIB_OBJS) $(PROG_OBJS)
|
||||
|
||||
ifdef USE_MSVC
|
||||
LIBRARY = $(OBJDIR)/js32.dll
|
||||
PROGRAM = $(OBJDIR)/js
|
||||
LIBRARY = $(OBJDIR)/js32.lib
|
||||
SHARED_LIBRARY = $(OBJDIR)/js32.dll
|
||||
PROGRAM = $(OBJDIR)/js.exe
|
||||
else
|
||||
LIBRARY = $(OBJDIR)/libjs.a
|
||||
SHARED_LIBRARY = $(OBJDIR)/libjs.$(SO_SUFFIX)
|
||||
PROGRAM = $(OBJDIR)/js
|
||||
endif
|
||||
|
||||
ifdef USE_MSVC
|
||||
TARGETS = $(LIBRARY) # $(PROGRAM) not supported for MSVC yet
|
||||
FDLIBM_LIBRARY = fdlibm.lib
|
||||
else
|
||||
TARGETS = $(LIBRARY) $(PROGRAM)
|
||||
FDLIBM_LIBRARY = libfdm.a
|
||||
endif
|
||||
|
||||
all: $(TARGETS)
|
||||
include rules.mk
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJS)
|
||||
MOZ_DEPTH = ../..
|
||||
include jsconfig.mk
|
||||
|
||||
clobber:
|
||||
rm -rf $(OBJS) $(TARGETS) $(DEPENDENCIES)
|
||||
|
||||
depend:
|
||||
gcc -MM $(CFLAGS) $(JS_CFILES)
|
||||
|
||||
$(OBJDIR)/%: %.c
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CC) -o $@ $(CFLAGS) $*.c $(LDFLAGS)
|
||||
|
||||
$(OBJDIR)/%.o: %.c
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CC) -o $@ -c $(CFLAGS) $*.c
|
||||
|
||||
$(OBJDIR)/%.o: %.s
|
||||
@$(MAKE_OBJDIR)
|
||||
$(AS) -o $@ $(ASFLAGS) $*.s
|
||||
|
||||
# windows only
|
||||
$(OBJDIR)/%.obj: %.c
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CC) -Fo$(OBJDIR)/ -c $(CFLAGS) $*.c
|
||||
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
$(LIBRARY): $(LIB_OBJS)
|
||||
$(AR) $@ $? $(AR_OS2_SUFFIX)
|
||||
$(RANLIB) $@
|
||||
else
|
||||
nsinstall-target:
|
||||
cd ../../config; $(MAKE) OBJDIR=$(OBJDIR) OBJDIR_NAME=$(OBJDIR)
|
||||
ifdef USE_MSVC
|
||||
$(LIBRARY): $(LIB_OBJS)
|
||||
link.exe $(LIB_LINK_FLAGS) /base:0x61000000 \
|
||||
/out:"$@" /pdb:"$(OBJDIR)/js32.pdb" /implib:"$(OBJDIR)/js32.lib" $?
|
||||
$(PROGRAM): $(PROG_OBJS) $(LIBRARY) fdlibm/$(OBJDIR)/$(FDLIBM_LIBRARY)
|
||||
link.exe -out:"$@" $(EXE_LINK_FLAGS) $^
|
||||
else
|
||||
$(LIBRARY): $(LIB_OBJS)
|
||||
$(AR) rv $@ $?
|
||||
$(RANLIB) $@
|
||||
$(PROGRAM): $(PROG_OBJS) $(LIBRARY) fdlibm/$(OBJDIR)/$(FDLIBM_LIBRARY)
|
||||
$(CC) -o $@ $(CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS) $(OTHER_LIBS) \
|
||||
$(PROG_LIBS)
|
||||
endif
|
||||
endif
|
||||
|
||||
#NSPR_LIBRARY = ../../dist/$(OBJDIR)/lib/libnspr21.so
|
||||
NSPR_LIBRARY =
|
||||
|
||||
$(PROGRAM): $(PROG_OBJS) $(LIBRARY)
|
||||
$(CC) -o $@ $(CFLAGS) $(PROG_OBJS) $(LIBRARY) $(NSPR_LIBRARY) $(LDFLAGS)
|
||||
|
||||
$(PROGRAM).pure: $(PROG_OBJS) $(LIBRARY)
|
||||
purify $(PUREFLAGS) \
|
||||
$(CC) -o $@ $(PURE_OS_CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS)
|
||||
$(CC) -o $@ $(PURE_OS_CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS) \
|
||||
$(OTHER_LIBS) $(PROG_LIBS)
|
||||
|
||||
$(HFILES) $(CFILES): $(OBJDIR)/jscpucfg.h
|
||||
ifndef PREBUILT_CPUCFG
|
||||
all export libs $(HFILES) $(CFILES): $(OBJDIR)/jsautocfg.h
|
||||
|
||||
ifdef PREBUILT_CPUCFG
|
||||
$(OBJDIR)/jscpucfg.h: jscpucfg.h
|
||||
cp jscpucfg.h $(OBJDIR)
|
||||
else
|
||||
$(OBJDIR)/jscpucfg.h: $(OBJDIR)/jscpucfg
|
||||
$(OBJDIR)/jsautocfg.h: $(OBJDIR)/jscpucfg
|
||||
rm -f $@
|
||||
$(OBJDIR)/jscpucfg > $@
|
||||
|
||||
$(OBJDIR)/jscpucfg: $(OBJDIR)/jscpucfg.o
|
||||
$(CC) -o $@ $(OBJDIR)/jscpucfg.o
|
||||
|
||||
# Look in OBJDIR to find jsautocfg.h
|
||||
INCLUDES += -I$(OBJDIR)
|
||||
|
||||
# Add to TARGETS for clobber rule
|
||||
TARGETS += $(OBJDIR)/jsautocfg.h $(OBJDIR)/jscpucfg $(OBJDIR)/jscpucfg.o
|
||||
endif
|
||||
|
||||
#
|
||||
@@ -307,10 +267,6 @@ jsopcode.h jsopcode.c: jsopcode.tbl
|
||||
TARNAME = jsref.tar
|
||||
TARFILES = files `cat files`
|
||||
|
||||
tar:
|
||||
tar cvf $(TARNAME) $(TARFILES)
|
||||
gzip $(TARNAME)
|
||||
|
||||
SUFFIXES: .i
|
||||
%.i: %.c
|
||||
$(CC) -C -E $(CFLAGS) $< > $*.i
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
The js/ref directory contains standalone ANSI-C source for the Netscape
|
||||
JavaScript Reference implementation, JSRef, which was licensed to over 180
|
||||
companies as part of Netscape ONE, starting in fall 1996. Now, JSRef is
|
||||
available under NPL from http://www.mozilla.org.
|
||||
|
||||
The js/src directory contains source files listed in the file "commfiles",
|
||||
that are derived via prconv.sed from counterparts in the js/ref directory.
|
||||
It also contains files such as jscompat.h that are not needed in js/ref.
|
||||
The Makefile in js/src has refconv and refdiff targets to help keep js/ref
|
||||
and js/src in synch.
|
||||
|
||||
If you think you need to change a file listed in commfiles here, please
|
||||
make the change in js/ref first and then use prconv.sed or gmake refconv to
|
||||
get it into js/src. If you have trouble, please let us know by mailing the
|
||||
JS owner and peers listed in http://www.mozilla.org/owners.html#JavaScript.
|
||||
|
||||
Brendan Eich (brendan@mozilla.org), 15-May-98
|
||||
755
mozilla/js/src/README.html
Normal file
755
mozilla/js/src/README.html
Normal file
@@ -0,0 +1,755 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR" content="Mozilla/4.5 [en] (WinNT; I) [Netscape]">
|
||||
<title>JavaScript Reference Implementation (JSRef) README</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>
|
||||
Table of Contents</h2>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="#Introduction">Introduction</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#Build">Build conventions (standalone JS engine and shell)</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#Debugging">Debugging notes</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#Conventions">Naming and coding conventions</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#JSAPI">Using the JS API</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#Design">Design walk-through</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>
|
||||
<a NAME="Introduction"></a>Introduction</h2>
|
||||
This is the README file for the <span CLASS=LXRSHORTDESC>JavaScript
|
||||
Reference (JSRef) implementation.</span> It consists of build conventions
|
||||
and instructions, source code conventions, a design walk-through, and a
|
||||
brief file-by-file description of the source.
|
||||
<p><span CLASS=LXRLONGDESC>JSRef builds a library or DLL containing the
|
||||
JavaScript runtime (compiler, interpreter, decompiler, garbage collector,
|
||||
atom manager, standard classes). It then compiles a small "shell" program
|
||||
and links that with the library to make an interpreter that can be used
|
||||
interactively and with test .js files to run scripts. The code has
|
||||
no dependencies on the Navigator code.</span>
|
||||
<p><i>Quick start tip</i>: skip to "Using the JS API" below, build the
|
||||
js shell, and play with the object named "it" (start by setting 'it.noisy
|
||||
= true').
|
||||
<h2>
|
||||
<a NAME="Build"></a>Build conventions (standalone JS engine and shell)</h2>
|
||||
These build directions refer only to building the standalone JavaScript
|
||||
engine and shell. To build within the browser, refer to the <a href="http://www.mozilla.org/docs/">build
|
||||
directions</a> on the mozilla.org website.
|
||||
<p>By default, all platforms build a version of the JS engine that is <i>not</i>
|
||||
threadsafe. If you require thread-safety, you must also populate
|
||||
the <tt>mozilla/dist</tt> directory with <a href="http://www.mozilla.org/docs/tplist/catCode/nsprdesc.htm">NSPR</a>
|
||||
headers and libraries. (NSPR implements a portable threading library,
|
||||
among other things. The source is downloadable via <a href="http://www.mozilla.org/cvs.html">CVS</a>
|
||||
from <tt><a href="http://cvs-mirror.mozilla.org/webtools/lxr/source/nsprpub">mozilla/nsprpub</a></tt>.)
|
||||
Next, you must define <tt>JS_THREADSAFE</tt> when building the JS engine,
|
||||
either on the command-line (gmake/nmake) or in a universal header file.
|
||||
<h3>
|
||||
Windows</h3>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Use MSVC 4.2 or 5.0.</li>
|
||||
|
||||
<li>
|
||||
For building from the IDE use <tt>js/src/js.mdp</tt>. (<tt>js.mdp</tt>
|
||||
is an MSVC4.2 project file, but if you load it into MSVC5, it will be converted
|
||||
to the newer project file format.) <font color="#CC0000">NOTE: makefile.win
|
||||
is an nmake file used only for building the JS-engine in the Mozilla browser.
|
||||
Don't attempt to use it to build the standalone JS-engine.</font></li>
|
||||
|
||||
<li>
|
||||
If you prefer to build from the command-line, use '<tt>nmake -f js.mak</tt>'</li>
|
||||
|
||||
<li>
|
||||
Executable shell <tt>js.exe</tt> and runtime library <tt>js32.dll</tt>
|
||||
are created in either <tt>js/src/Debug</tt> or <tt>js/src/Release</tt>.</li>
|
||||
</ul>
|
||||
|
||||
<h3>
|
||||
Macintosh</h3>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Use CodeWarrior 3.x</li>
|
||||
|
||||
<li>
|
||||
Load the project file <tt>js:src:macbuild:JSRef.mcp </tt>and select "Make"
|
||||
from the menu.</li>
|
||||
</ul>
|
||||
|
||||
<h3>
|
||||
Unix</h3>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Use '<tt>gmake -f Makefile.ref</tt>' to build. To compile optimized code,
|
||||
pass <tt>BUILD_OPT=1</tt> on the gmake command line or preset it in the
|
||||
environment or <tt>Makefile.ref</tt>. <font color="#CC0000">NOTE:
|
||||
Do not attempt to use Makefile to build the standalone JavaScript engine.
|
||||
This file is used only for building the JS-engine in the Mozilla browser.</font></li>
|
||||
|
||||
<li>
|
||||
<font color="#000000">Each platform on which JS is built must have a <tt>*.mk</tt>
|
||||
configuration file in the <tt>js/src/config</tt> directory. The configuration
|
||||
file specifies the compiler/linker to be used and allows for customization
|
||||
of command-line options. To date, the build system has been tested
|
||||
on Solaris, AIX, HP/UX, OSF, IRIX, x86 Linux and Windows NT.</font></li>
|
||||
|
||||
<li>
|
||||
<font color="#000000">Most platforms will work with either the vendor compiler
|
||||
</font>or
|
||||
<a href="ftp://prep.ai.mit.edu/pub/gnu">gcc</a>.
|
||||
(Except that HP builds only work using the native compiler. gcc won't
|
||||
link correctly with shared libraries on that platform. If someone
|
||||
knows a way to fix this, <a href="mailto:wynholds@netscape.com">let us
|
||||
know</a>.)</li>
|
||||
|
||||
<li>
|
||||
<font color="#000000">If you define <tt>JS_LIVECONNECT</tt>, gmake will
|
||||
descend into the liveconnect directory and build <a href="http://cvs-mirror.mozilla.org/webtools/lxr/source/js/src/liveconnect/README.html">LiveConnect</a>
|
||||
after building the JS engine.</font></li>
|
||||
|
||||
<li>
|
||||
To build a binary drop (a zip'ed up file of headers, libraries, binaries),
|
||||
check out <tt>mozilla/config</tt> and <tt>mozilla/nsprpub/config</tt>.
|
||||
Use '<tt>gmake -f Makefile.ref nsinstall-target all export ship</tt>'</li>
|
||||
</ul>
|
||||
|
||||
<h2>
|
||||
<a NAME="Debugging"></a>Debugging notes</h2>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
To turn on GC instrumentation, define <tt>JS_GCMETER</tt>.</li>
|
||||
|
||||
<li>
|
||||
To turn on the arena package's instrumentation, define <tt>JS_ARENAMETER</tt>.</li>
|
||||
|
||||
<li>
|
||||
To turn on the hash table package's metering, define <tt>JS_HASHMETER</tt>.</li>
|
||||
</ul>
|
||||
|
||||
<h2>
|
||||
<a NAME="Conventions"></a>Naming and coding conventions</h2>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Public function names begin with <tt>JS_</tt> followed by capitalized "intercaps",
|
||||
e.g. <tt>JS_NewObject</tt>.</li>
|
||||
|
||||
<li>
|
||||
Extern but library-private function names use a <tt>js_</tt> prefix and
|
||||
mixed case, e.g. <tt>js_LookupSymbol</tt>.</li>
|
||||
|
||||
<li>
|
||||
Most static function names have unprefixed, mixed-case names: <tt>GetChar</tt>.</li>
|
||||
|
||||
<li>
|
||||
But static native methods of JS objects have lowercase, underscore-separated
|
||||
or intercaps names, e.g., <tt>str_indexOf</tt>.</li>
|
||||
|
||||
<li>
|
||||
And library-private and static data use underscores, not intercaps (but
|
||||
library-private data do use a <tt>js_</tt> prefix).</li>
|
||||
|
||||
<li>
|
||||
Scalar type names are lowercase and js-prefixed: <tt>jsdouble</tt>.</li>
|
||||
|
||||
<li>
|
||||
Aggregate type names are JS-prefixed and mixed-case: <tt>JSObject.</tt></li>
|
||||
|
||||
<li>
|
||||
Macros are generally <tt>ALL_CAPS </tt>and underscored, to call out potential
|
||||
side effects, multiple uses of a formal argument, etc. - Four spaces of
|
||||
indentation per statement nesting level.</li>
|
||||
|
||||
<li>
|
||||
Tabs are taken to be eight spaces, and an Emacs magic comment at the top
|
||||
of each file tries to help. If you're using MSVC or similar, you'll want
|
||||
to set tab width to 8, or convert these files to be space-filled.</li>
|
||||
|
||||
<li>
|
||||
DLL entry points have their return type expanded within a <tt>JS_PUBLIC_API()</tt>
|
||||
macro call, to get the right Windows secret type qualifiers in the right
|
||||
places for both 16- and 32-bit builds.</li>
|
||||
|
||||
<li>
|
||||
Callback functions that might be called from a DLL are similarly macroized
|
||||
with <tt>JS_STATIC_DLL_CALLBACK</tt> (if the function otherwise would be
|
||||
static to hide its name) or <tt>JS_DLL_CALLBACK</tt> (this macro takes
|
||||
no type argument; it should be used after the return type and before the
|
||||
function name).</li>
|
||||
</ul>
|
||||
|
||||
<h2>
|
||||
<a NAME="JSAPI"></a>Using the JS API</h2>
|
||||
|
||||
<h4>
|
||||
Starting up</h4>
|
||||
|
||||
<pre><tt> /*
|
||||
* Tune this to avoid wasting space for shallow stacks, while saving on
|
||||
* malloc overhead/fragmentation for deep or highly-variable stacks.
|
||||
*/
|
||||
#define STACK_CHUNK_SIZE 8192
|
||||
|
||||
JSRuntime *rt;
|
||||
JSContext *cx;
|
||||
|
||||
/* You need a runtime and one or more contexts to do anything with JS. */
|
||||
rt = JS_Init(1000000L);
|
||||
if (!rt)
|
||||
fail("can't create JavaScript runtime");
|
||||
cx = JS_NewContext(rt, STACK_CHUNK_SIZE);
|
||||
if (!cx)
|
||||
fail("can't create JavaScript context");
|
||||
|
||||
/*
|
||||
* The context definitely wants a global object, in order to have standard
|
||||
* classes and functions like Date and parseInt. See below for details on
|
||||
* JS_NewObject.
|
||||
*/
|
||||
JSObject *globalObj;
|
||||
|
||||
globalObj = JS_NewObject(cx, &my_global_class, 0, 0);
|
||||
JS_InitStandardClasses(cx, globalObj);</tt></pre>
|
||||
|
||||
<h4>
|
||||
Defining objects and properties</h4>
|
||||
|
||||
<pre><tt> /* Statically initialize a class to make "one-off" objects. */
|
||||
JSClass my_class = {
|
||||
"MyClass",
|
||||
|
||||
/* All of these can be replaced with the corresponding JS_*Stub
|
||||
function pointers. */
|
||||
my_addProperty, my_delProperty, my_getProperty, my_setProperty,
|
||||
my_enumerate, my_resolve, my_convert, my_finalize
|
||||
};
|
||||
|
||||
JSObject *obj;
|
||||
|
||||
/*
|
||||
* Define an object named in the global scope that can be enumerated by
|
||||
* for/in loops. The parent object is passed as the second argument, as
|
||||
* with all other API calls that take an object/name pair. The prototype
|
||||
* passed in is null, so the default object prototype will be used.
|
||||
*/
|
||||
obj = JS_DefineObject(cx, globalObj, "myObject", &my_class, 0,
|
||||
JSPROP_ENUMERATE);
|
||||
|
||||
/*
|
||||
* Define a bunch of properties with a JSPropertySpec array statically
|
||||
* initialized and terminated with a null-name entry. Besides its name,
|
||||
* each property has a "tiny" identifier (MY_COLOR, e.g.) that can be used
|
||||
* in switch statements (in a common my_getProperty function, for example).
|
||||
*/
|
||||
enum my_tinyid {
|
||||
MY_COLOR, MY_HEIGHT, MY_WIDTH, MY_FUNNY, MY_ARRAY, MY_RDONLY
|
||||
};
|
||||
|
||||
static JSPropertySpec my_props[] = {
|
||||
{"color", MY_COLOR, JSPROP_ENUMERATE},
|
||||
{"height", MY_HEIGHT, JSPROP_ENUMERATE},
|
||||
{"width", MY_WIDTH, JSPROP_ENUMERATE},
|
||||
{"funny", MY_FUNNY, JSPROP_ENUMERATE},
|
||||
{"array", MY_ARRAY, JSPROP_ENUMERATE},
|
||||
{"rdonly", MY_RDONLY, JSPROP_READONLY},
|
||||
{0}
|
||||
};
|
||||
|
||||
JS_DefineProperties(cx, obj, my_props);
|
||||
|
||||
/*
|
||||
* Given the above definitions and call to JS_DefineProperties, obj will
|
||||
* need this sort of "getter" method in its class (my_class, above). See
|
||||
* the example for the "It" class in js.c.
|
||||
*/
|
||||
static JSBool
|
||||
my_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch (JSVAL_TO_INT(id)) {
|
||||
case MY_COLOR: *vp = . . .; break;
|
||||
case MY_HEIGHT: *vp = . . .; break;
|
||||
case MY_WIDTH: *vp = . . .; break;
|
||||
case MY_FUNNY: *vp = . . .; break;
|
||||
case MY_ARRAY: *vp = . . .; break;
|
||||
case MY_RDONLY: *vp = . . .; break;
|
||||
}
|
||||
}
|
||||
return JS_TRUE;
|
||||
}</tt></pre>
|
||||
|
||||
<h4>
|
||||
Defining functions</h4>
|
||||
|
||||
<pre><tt> /* Define a bunch of native functions first: */
|
||||
static JSBool
|
||||
my_abs(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
jsdouble x, z;
|
||||
|
||||
if (!JS_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
z = (x < 0) ? -x : x;
|
||||
return JS_NewDoubleValue(cx, z, rval);
|
||||
}
|
||||
|
||||
. . .
|
||||
|
||||
/*
|
||||
* Use a JSFunctionSpec array terminated with a null name to define a
|
||||
* bunch of native functions.
|
||||
*/
|
||||
static JSFunctionSpec my_functions[] = {
|
||||
/* name native nargs */
|
||||
{"abs", my_abs, 1},
|
||||
{"acos", my_acos, 1},
|
||||
{"asin", my_asin, 1},
|
||||
. . .
|
||||
{0}
|
||||
};
|
||||
|
||||
/*
|
||||
* Pass a particular object to define methods for it alone. If you pass
|
||||
* a prototype object, the methods will apply to all instances past and
|
||||
* future of the prototype's class (see below for classes).
|
||||
*/
|
||||
JS_DefineFunctions(cx, globalObj, my_functions);</tt></pre>
|
||||
|
||||
<h4>
|
||||
Defining classes</h4>
|
||||
|
||||
<pre><tt> /*
|
||||
* This pulls together the above API elements by defining a constructor
|
||||
* function, a prototype object, and properties of the prototype and of
|
||||
* the constructor, all with one API call.
|
||||
*
|
||||
* Initialize a class by defining its constructor function, prototype, and
|
||||
* per-instance and per-class properties. The latter are called "static"
|
||||
* below by analogy to Java. They are defined in the constructor object's
|
||||
* scope, so that 'MyClass.myStaticProp' works along with 'new MyClass()'.
|
||||
*
|
||||
* JS_InitClass takes a lot of arguments, but you can pass null for any of
|
||||
* the last four if there are no such properties or methods.
|
||||
*
|
||||
* Note that you do not need to call JS_InitClass to make a new instance of
|
||||
* that class -- otherwise there would be a chicken-and-egg problem making
|
||||
* the global object -- but you should call JS_InitClass if you require a
|
||||
* constructor function for script authors to call via new, and/or a class
|
||||
* prototype object ('MyClass.prototype') for authors to extend with new
|
||||
* properties at run-time.
|
||||
*/
|
||||
protoObj = JS_InitClass(cx, globalObj, &my_class,
|
||||
|
||||
/* native constructor function and min arg count */
|
||||
MyClass, 0,
|
||||
|
||||
/* prototype object properties and methods -- these
|
||||
will be "inherited" by all instances through
|
||||
delegation up the instance's prototype link. */
|
||||
my_props, my_methods,
|
||||
|
||||
/* class constructor properties and methods */
|
||||
my_static_props, my_static_methods);</tt></pre>
|
||||
|
||||
<h4>
|
||||
Running scripts</h4>
|
||||
|
||||
<pre><tt> /* These should indicate source location for diagnostics. */
|
||||
char *filename;
|
||||
uintN lineno;
|
||||
|
||||
/*
|
||||
* The return value comes back here -- if it could be a GC thing, you must
|
||||
* add it to the GC's "root set" with JS_AddRoot(cx, &thing) where thing
|
||||
* is a JSString *, JSObject *, or jsdouble *, and remove the root before
|
||||
* rval goes out of scope, or when rval is no longer needed.
|
||||
*/
|
||||
jsval rval;
|
||||
JSBool ok;
|
||||
|
||||
/*
|
||||
* Some example source in a C string. Larger, non-null-terminated buffers
|
||||
* can be used, if you pass the buffer length to JS_EvaluateScript.
|
||||
*/
|
||||
char *source = "x * f(y)";
|
||||
|
||||
ok = JS_EvaluateScript(cx, globalObj, source, strlen(source),
|
||||
filename, lineno, &rval);
|
||||
|
||||
if (ok) {
|
||||
/* Should get a number back from the example source. */
|
||||
jsdouble d;
|
||||
|
||||
ok = JS_ValueToNumber(cx, rval, &d);
|
||||
. . .
|
||||
}</tt></pre>
|
||||
|
||||
<h4>
|
||||
Calling functions</h4>
|
||||
|
||||
<pre><tt> /* Call a global function named "foo" that takes no arguments. */
|
||||
ok = JS_CallFunctionName(cx, globalObj, "foo", 0, 0, &rval);
|
||||
|
||||
jsval argv[2];
|
||||
|
||||
/* Call a function in obj's scope named "method", passing two arguments. */
|
||||
argv[0] = . . .;
|
||||
argv[1] = . . .;
|
||||
ok = JS_CallFunctionName(cx, obj, "method", 2, argv, &rval);</tt></pre>
|
||||
|
||||
<h4>
|
||||
Shutting down</h4>
|
||||
|
||||
<pre><tt> /* For each context you've created: */
|
||||
JS_DestroyContext(cx);
|
||||
|
||||
/* And finally: */
|
||||
JS_Finish(rt);</tt></pre>
|
||||
|
||||
<h4>
|
||||
Debugging API</h4>
|
||||
See the<tt> trap, untrap, watch, unwatch, line2pc</tt>, and <tt>pc2line</tt>
|
||||
commands in <tt>js.c</tt>. Also the (scant) comments in <i>jsdbgapi.h</i>.
|
||||
<h2>
|
||||
<a NAME="Design"></a>Design walk-through</h2>
|
||||
This section must be brief for now -- it could easily turn into a book.
|
||||
<h4>
|
||||
JS "JavaScript Proper"</h4>
|
||||
JS modules declare and implement the JavaScript compiler, interpreter,
|
||||
decompiler, GC and atom manager, and standard classes.
|
||||
<p>JavaScript uses untyped bytecode and runtime type tagging of data values.
|
||||
The <tt>jsval</tt> type is a signed machine word that contains either a
|
||||
signed integer value (if the low bit is set), or a type-tagged pointer
|
||||
or boolean value (if the low bit is clear). Tagged pointers all refer to
|
||||
8-byte-aligned things in the GC heap.
|
||||
<p>Objects consist of a possibly shared structural description, called
|
||||
the map or scope; and unshared property values in a vector, called the
|
||||
slots. Object properties are associated with nonnegative integers stored
|
||||
in <tt>jsval</tt>'s, or with atoms (unique string descriptors) if named
|
||||
by an identifier or a non-integral index expression.
|
||||
<p>Scripts contain bytecode, source annotations, and a pool of string,
|
||||
number, and identifier literals. Functions are objects that extend scripts
|
||||
or native functions with formal parameters, a literal syntax, and a distinct
|
||||
primitive type ("function").
|
||||
<p>The compiler consists of a recursive-descent parser and a random-logic
|
||||
rather than table-driven lexical scanner. Semantic and lexical feedback
|
||||
are used to disambiguate hard cases such as missing semicolons, assignable
|
||||
expressions ("lvalues" in C parlance), etc. The parser generates bytecode
|
||||
as it parses, using fixup lists for downward branches and code buffering
|
||||
and rewriting for exceptional cases such as for loops. It attempts no error
|
||||
recovery. The interpreter executes the bytecode of top-level scripts, and
|
||||
calls itself indirectly to interpret function bodies (which are also scripts).
|
||||
All state associated with an interpreter instance is passed through formal
|
||||
parameters to the interpreter entry point; most implicit state is collected
|
||||
in a type named JSContext. Therefore, all API and almost all other functions
|
||||
in JSRef take a JSContext pointer as their first argument.
|
||||
<p>The decompiler translates postfix bytecode into infix source by consulting
|
||||
a separate byte-sized code, called source notes, to disambiguate bytecodes
|
||||
that result from more than one grammatical production.
|
||||
<p>The GC is a mark-and-sweep, non-conservative (perfect) collector. It
|
||||
can allocate only fixed-sized things -- the current size is two machine
|
||||
words. It is used to hold JS object and string descriptors (but not property
|
||||
lists or string bytes), and double-precision floating point numbers. It
|
||||
runs automatically only when maxbytes (as passed to <tt>JS_Init()</tt>)
|
||||
bytes of GC things have been allocated and another thing-allocation request
|
||||
is made. JS API users should call <tt>JS_GC()</tt> or <tt>JS_MaybeGC()</tt>
|
||||
between script executions or from the branch callback, as often as necessary.
|
||||
<p>An important point about the GC's "perfection": you must add roots for
|
||||
new objects created by your native methods if you store references to them
|
||||
into a non-JS structure in the malloc heap or in static data. Also, if
|
||||
you make a new object in a native method, but do not store it through the
|
||||
<tt>rval</tt>
|
||||
result parameter (see math_abs in the "Using the JS API" section above)
|
||||
so that it is in a known root, the object is guaranteed to survive only
|
||||
until another new object is created. Either lock the first new object when
|
||||
making two in a row, or store it in a root you've added, or store it via
|
||||
rval.
|
||||
<p>The atom manager consists of a hash table associating strings uniquely
|
||||
with scanner/parser information such as keyword type, index in script or
|
||||
function literal pool, etc. Atoms play three roles in JSRef: as literals
|
||||
referred to by unaligned 16-bit immediate bytecode operands, as unique
|
||||
string descriptors for efficient property name hashing, and as members
|
||||
of the root GC set for perfect GC. This design therefore requires atoms
|
||||
to be manually reference counted, from script literal pools (<tt>JSAtomMap</tt>)
|
||||
and object symbol (<tt>JSSymbol</tt>) entry keys.
|
||||
<p>Native objects and methods for arrays, booleans, dates, functions, numbers,
|
||||
and strings are implemented using the JS API and certain internal interfaces
|
||||
used as "fast paths".
|
||||
<p>In general, errors are signaled by false or unoverloaded-null return
|
||||
values, and are reported using <tt>JS_ReportError()</tt> or one of its
|
||||
variants by the lowest level in order to provide the most detail. Client
|
||||
code can substitute its own error reporting function and suppress errors,
|
||||
or reflect them into Java or some other runtime system as exceptions, GUI
|
||||
dialogs, etc..
|
||||
<h2>
|
||||
File walk-through (BADLY OUT OF DATE!)</h2>
|
||||
|
||||
<h4>
|
||||
jsapi.c, jsapi.h</h4>
|
||||
The public API to be used by almost all client code. If your client
|
||||
code can't make do with <tt>jsapi.h</tt>, and must reach into a friend
|
||||
or private js* file, please let us know so we can extend <tt>jsapi.h</tt>
|
||||
to include what you need in a fashion that we can support over the long
|
||||
run.
|
||||
<h4>
|
||||
jspubtd.h, jsprvtd.h</h4>
|
||||
These files exist to group struct and scalar typedefs so they can be used
|
||||
everywhere without dragging in struct definitions from N different files.
|
||||
The <tt>jspubtd.h</tt> file contains public typedefs, and is included by
|
||||
<tt>jsapi.h</tt>.
|
||||
The <tt>jsprvtd.h</tt> file contains private typedefs and is included by
|
||||
various .h files that need type names, but not type sizes or declarations.
|
||||
<h4>
|
||||
jsdbgapi.c, jsdbgapi.h</h4>
|
||||
The Debugging API, still very much under development. Provided so far:
|
||||
<ul>
|
||||
<li>
|
||||
Traps, with which breakpoints, single-stepping, step over, step out, and
|
||||
so on can be implemented. The debugger will have to consult jsopcode.def
|
||||
on its own to figure out where to plant trap instructions to implement
|
||||
functions like step out, but a future jsdbgapi.h will provide convenience
|
||||
interfaces to do these things. At most one trap per bytecode can be set.
|
||||
When a script (<tt>JSScript</tt>) is destroyed, all traps set in its bytecode
|
||||
are cleared.</li>
|
||||
|
||||
<li>
|
||||
Watchpoints, for intercepting set operations on properties and running
|
||||
a debugger-supplied function that receives the old value and a pointer
|
||||
to the new one, which it can use to modify the new value being set.</li>
|
||||
|
||||
<li>
|
||||
Line number to PC and back mapping functions. The line-to-PC direction
|
||||
"rounds" toward the next bytecode generated from a line greater than or
|
||||
equal to the input line, and may return the PC of a for-loop update part,
|
||||
if given the line number of the loop body's closing brace. Any line after
|
||||
the last one in a script or function maps to a PC one byte beyond the last
|
||||
bytecode in the script. An example, from perfect.js:</li>
|
||||
|
||||
<pre><tt>14 function perfect(n)
|
||||
15 {
|
||||
16 print("The perfect numbers up to " + n + " are:");
|
||||
17
|
||||
18 // We build sumOfDivisors[i] to hold a string expression for
|
||||
19 // the sum of the divisors of i, excluding i itself.
|
||||
20 var sumOfDivisors = new ExprArray(n+1,1);
|
||||
21 for (var divisor = 2; divisor <= n; divisor++) {
|
||||
22 for (var j = divisor + divisor; j <= n; j += divisor) {
|
||||
23 sumOfDivisors[j] += " + " + divisor;
|
||||
24 }
|
||||
25 // At this point everything up to 'divisor' has its sumOfDivisors
|
||||
26 // expression calculated, so we can determine whether it's perfect
|
||||
27 // already by evaluating.
|
||||
28 if (eval(sumOfDivisors[divisor]) == divisor) {
|
||||
29 print("" + divisor + " = " + sumOfDivisors[divisor]);
|
||||
30 }
|
||||
31 }
|
||||
32 delete sumOfDivisors;
|
||||
33 print("That's all.");
|
||||
34 }</tt></pre>
|
||||
The line number to PC and back mappings can be tested using the js program
|
||||
with the following script:
|
||||
<pre><tt> load("perfect.js")
|
||||
print(perfect)
|
||||
dis(perfect)
|
||||
|
||||
print()
|
||||
for (var ln = 0; ln <= 40; ln++) {
|
||||
var pc = line2pc(perfect,ln)
|
||||
var ln2 = pc2line(perfect,pc)
|
||||
print("\tline " + ln + " => pc " + pc + " => line " + ln2)
|
||||
}</tt></pre>
|
||||
The result of the for loop over lines 0 to 40 inclusive is:
|
||||
<pre><tt> line 0 => pc 0 => line 16
|
||||
line 1 => pc 0 => line 16
|
||||
line 2 => pc 0 => line 16
|
||||
line 3 => pc 0 => line 16
|
||||
line 4 => pc 0 => line 16
|
||||
line 5 => pc 0 => line 16
|
||||
line 6 => pc 0 => line 16
|
||||
line 7 => pc 0 => line 16
|
||||
line 8 => pc 0 => line 16
|
||||
line 9 => pc 0 => line 16
|
||||
line 10 => pc 0 => line 16
|
||||
line 11 => pc 0 => line 16
|
||||
line 12 => pc 0 => line 16
|
||||
line 13 => pc 0 => line 16
|
||||
line 14 => pc 0 => line 16
|
||||
line 15 => pc 0 => line 16
|
||||
line 16 => pc 0 => line 16
|
||||
line 17 => pc 19 => line 20
|
||||
line 18 => pc 19 => line 20
|
||||
line 19 => pc 19 => line 20
|
||||
line 20 => pc 19 => line 20
|
||||
line 21 => pc 36 => line 21
|
||||
line 22 => pc 53 => line 22
|
||||
line 23 => pc 74 => line 23
|
||||
line 24 => pc 92 => line 22
|
||||
line 25 => pc 106 => line 28
|
||||
line 26 => pc 106 => line 28
|
||||
line 27 => pc 106 => line 28
|
||||
line 28 => pc 106 => line 28
|
||||
line 29 => pc 127 => line 29
|
||||
line 30 => pc 154 => line 21
|
||||
line 31 => pc 154 => line 21
|
||||
line 32 => pc 161 => line 32
|
||||
line 33 => pc 172 => line 33
|
||||
line 34 => pc 172 => line 33
|
||||
line 35 => pc 172 => line 33
|
||||
line 36 => pc 172 => line 33
|
||||
line 37 => pc 172 => line 33
|
||||
line 38 => pc 172 => line 33
|
||||
line 39 => pc 172 => line 33
|
||||
line 40 => pc 172 => line 33</tt></pre>
|
||||
</ul>
|
||||
|
||||
<h4>
|
||||
jsconfig.h</h4>
|
||||
Various configuration macros defined as 0 or 1 depending on how <tt>JS_VERSION</tt>
|
||||
is defined (as 10 for JavaScript 1.0, 11 for JavaScript 1.1, etc.). Not
|
||||
all macros are tested around related code yet. In particular, JS 1.0 support
|
||||
is missing from JSRef. JS 1.2 support will appear in a future JSRef release.
|
||||
<br>
|
||||
<h4>
|
||||
js.c</h4>
|
||||
The "JS shell", a simple interpreter program that uses the JS API and more
|
||||
than a few internal interfaces (some of these internal interfaces could
|
||||
be replaced by <tt>jsapi.h</tt> calls). The js program built from this
|
||||
source provides a test vehicle for evaluating scripts and calling functions,
|
||||
trying out new debugger primitives, etc.
|
||||
<h4>
|
||||
jsarray.*, jsbool.*, jdsdate.*, jsfun.*, jsmath.*, jsnum.*, jsstr.*</h4>
|
||||
These file pairs implement the standard classes and (where they exist)
|
||||
their underlying primitive types. They have similar structure, generally
|
||||
starting with class definitions and continuing with internal constructors,
|
||||
finalizers, and helper functions.
|
||||
<h4>
|
||||
jsobj.*, jsscope.*</h4>
|
||||
These two pairs declare and implement the JS object system. All of the
|
||||
following happen here:
|
||||
<ul>
|
||||
<li>
|
||||
creating objects by class and prototype, and finalizing objects;</li>
|
||||
|
||||
<li>
|
||||
defining, looking up, getting, setting, and deleting properties;</li>
|
||||
|
||||
<li>
|
||||
creating and destroying properties and binding names to them.</li>
|
||||
</ul>
|
||||
The details of an object map (scope) are mostly hidden in <tt>jsscope.[ch]</tt>,
|
||||
where scopes start out as linked lists of symbols, and grow after some
|
||||
threshold into PR hash tables.
|
||||
<h4>
|
||||
jsatom.c, jsatom.h</h4>
|
||||
The atom manager. Contains well-known string constants, their atoms, the
|
||||
global atom hash table and related state, the js_Atomize() function that
|
||||
turns a counted string of bytes into an atom, and literal pool (<tt>JSAtomMap</tt>)
|
||||
methods.
|
||||
<h4>
|
||||
jsgc.c, jsgc.h</h4>
|
||||
[TBD]
|
||||
<h4>
|
||||
jsinterp.*, jscntxt.*</h4>
|
||||
The bytecode interpreter, and related functions such as Call and AllocStack,
|
||||
live in <i>jsinterp.c</i>. The JSContext constructor and destructor are
|
||||
factored out into <i>jscntxt.c</i> for minimal linking when the compiler
|
||||
part of JS is split from the interpreter part into a separate program.
|
||||
<h4>
|
||||
jsemit.*, jsopcode.tbl, jsopcode.*, jsparse.*, jsscan.*, jsscript.*</h4>
|
||||
Compiler and decompiler modules. The <i>jsopcode.tbl</i> file is a C preprocessor
|
||||
source that defines almost everything there is to know about JS bytecodes.
|
||||
See its major comment for how to use it. For now, a debugger will use it
|
||||
and its dependents such as <i>jsopcode.h</i> directly, but over time we
|
||||
intend to extend <i>jsdbgapi.h</i> to hide uninteresting details and provide
|
||||
conveniences. The code generator is split across paragraphs of code in
|
||||
<i>jsparse.c</i>,
|
||||
and the utility methods called on <tt>JSCodeGenerator</tt> appear in <i>jsemit.c</i>.
|
||||
Source notes generated by <i>jsparse.c</i> and
|
||||
<i>jsemit.c</i> are used
|
||||
in <i>jsscript.c</i> to map line number to program counter and back.
|
||||
<h4>
|
||||
jstypes.h, jslog2.c</h4>
|
||||
Fundamental representation types and utility macros. This file alone among
|
||||
all .h files in JSRef must be included first by .c files. It is not nested
|
||||
in .h files, as other prerequisite .h files generally are, since it is
|
||||
also a direct dependency of most .c files and would be over-included if
|
||||
nested in addition to being directly included. The one "not-quite-a-macro
|
||||
macro" is the <tt>JS_CeilingLog2()</tt> function in <i>jslog2.c</i>.
|
||||
<h4>
|
||||
jsarena.c, jsarena.h</h4>
|
||||
Last-In-First-Out allocation macros that amortize malloc costs and allow
|
||||
for en-masse freeing. See the paper mentioned in prarena.h's major comment.
|
||||
<h4>
|
||||
jsutil.c, jsutil.h</h4>
|
||||
The <tt>JS_ASSERT</tt> macro is used throughout JSRef source as a proof
|
||||
device to make invariants and preconditions clear to the reader, and to
|
||||
hold the line during maintenance and evolution against regressions or violations
|
||||
of assumptions that it would be too expensive to test unconditionally at
|
||||
run-time. Certain assertions are followed by run-time tests that cope with
|
||||
assertion failure, but only where I'm too smart or paranoid to believe
|
||||
the assertion will never fail...
|
||||
<h4>
|
||||
jsclist.h</h4>
|
||||
Doubly-linked circular list struct and macros.
|
||||
<h4>
|
||||
jscpucfg.c</h4>
|
||||
This standalone program generates <i>jscpucfg.h</i>, a header file containing
|
||||
bytes per word and other constants that depend on CPU architecture and
|
||||
C compiler type model. It tries to discover most of these constants by
|
||||
running its own experiments on the build host, so if you are cross-compiling,
|
||||
beware.
|
||||
<h4>
|
||||
prdtoa.c, prdtoa.h</h4>
|
||||
David Gay's portable double-precision floating point to string conversion
|
||||
code, with Permission To Use notice included.
|
||||
<h4>
|
||||
prhash.c, prhash.h</h4>
|
||||
Portable, extensible hash tables. These use multiplicative hash for strength
|
||||
reduction over division hash, yet with very good key distribution over
|
||||
power of two table sizes. Collisions resolve via chaining, so each entry
|
||||
burns a malloc and can fragment the heap.
|
||||
<h4>
|
||||
prlong.c, prlong.h</h4>
|
||||
64-bit integer emulation, and compatible macros that use C's long long
|
||||
type where it exists (my last company mapped long long to a 128-bit type,
|
||||
but no real architecture does 128-bit ints yet).
|
||||
<h4>
|
||||
jsosdep.h</h4>
|
||||
Annoying OS dependencies rationalized into a few "feature-test" macros
|
||||
such as <tt>JS_HAVE_LONG_LONG</tt>.
|
||||
<h4>
|
||||
jsprf.*</h4>
|
||||
Portable, buffer-overrun-resistant sprintf and friends. For no good reason
|
||||
save lack of time, the %e, %f, and %g formats cause your system's native
|
||||
sprintf, rather than <tt>JS_dtoa()</tt>, to be used. This bug doesn't affect
|
||||
JSRef, because it uses its own <tt>JS_dtoa()</tt> call in <i>jsnum.c</i>
|
||||
to convert from double to string, but it's a bug that we'll fix later,
|
||||
and one you should be aware of if you intend to use a <tt>JS_*printf()</tt>
|
||||
function with your own floating type arguments - various vendor sprintf's
|
||||
mishandle NaN, +/-Inf, and some even print normal floating values inaccurately.
|
||||
<h4>
|
||||
prmjtime.c, prmjtime.h</h4>
|
||||
Time functions. These interfaces are named in a way that makes local vs.
|
||||
universal time confusion likely. Caveat emptor, and we're working on it.
|
||||
To make matters worse, Java (and therefore JavaScript) uses "local" time
|
||||
numbers (offsets from the epoch) in its Date class.
|
||||
</body>
|
||||
</html>
|
||||
12
mozilla/js/src/SpiderMonkey.rsp
Normal file
12
mozilla/js/src/SpiderMonkey.rsp
Normal file
@@ -0,0 +1,12 @@
|
||||
mozilla/js/src/*
|
||||
mozilla/js/src/config/*
|
||||
mozilla/js/src/fdlibm/*
|
||||
mozilla/js/src/liveconnect/*
|
||||
mozilla/js/src/liveconnect/_jni/*
|
||||
mozilla/js/src/liveconnect/classes/*
|
||||
mozilla/js/src/liveconnect/classes/netscape/*
|
||||
mozilla/js/src/liveconnect/classes/netscape/javascript/*
|
||||
mozilla/js/src/liveconnect/config/*
|
||||
mozilla/js/src/liveconnect/macbuild/*
|
||||
mozilla/js/src/liveconnect/macbuild/JavaSession/*
|
||||
mozilla/js/src/macbuild/*
|
||||
@@ -1,100 +0,0 @@
|
||||
#! gmake
|
||||
|
||||
#
|
||||
# Since everyone seems to need to have their own build configuration
|
||||
# system these days, this is yet another makefile to build JavaScript.
|
||||
# This makefile conforms to the NSPR20 build rules. If you have built
|
||||
# NSPR20 this will build JS and stick the lib and bin files over in
|
||||
# the dist area created by NSPR (which is different from the dist
|
||||
# expected by the client and also the dist expected by LiveWire, but
|
||||
# don't get me started).
|
||||
#
|
||||
# I don't currently know enough about what sort of JS-engine the Actra
|
||||
# projects are going to expect so I don't know if we need to add
|
||||
# to CFLAGS for -DJS_THREADSAFE or -DJSFILE
|
||||
#
|
||||
|
||||
MOD_DEPTH = ../../nspr20
|
||||
|
||||
include $(MOD_DEPTH)/config/config.mk
|
||||
|
||||
INCLUDES = -I$(DIST)/include
|
||||
CFLAGS += -DNSPR20
|
||||
|
||||
CSRCS = prmjtime.c \
|
||||
jsapi.c \
|
||||
jsarray.c \
|
||||
jsatom.c \
|
||||
jsbool.c \
|
||||
jscntxt.c \
|
||||
jsdate.c \
|
||||
jsdbgapi.c \
|
||||
jsemit.c \
|
||||
jsfun.c \
|
||||
jsgc.c \
|
||||
jsinterp.c \
|
||||
jsmath.c \
|
||||
jsnum.c \
|
||||
jsobj.c \
|
||||
jsopcode.c \
|
||||
jsparse.c \
|
||||
jsregexp.c \
|
||||
jsscan.c \
|
||||
jsscope.c \
|
||||
jsscript.c \
|
||||
jsstr.c \
|
||||
jslock.c \
|
||||
$(NULL)
|
||||
|
||||
HEADERS = jsapi.h \
|
||||
jsarray.h \
|
||||
jsatom.h \
|
||||
jsbool.h \
|
||||
jscntxt.h \
|
||||
jscompat.h \
|
||||
jsconfig.h \
|
||||
jsdate.h \
|
||||
jsdbgapi.h \
|
||||
jsemit.h \
|
||||
jsfun.h \
|
||||
jsgc.h \
|
||||
jsinterp.h \
|
||||
jslock.h \
|
||||
jsmath.h \
|
||||
jsnum.h \
|
||||
jsobj.h \
|
||||
jsopcode.def \
|
||||
jsopcode.h \
|
||||
jsparse.h \
|
||||
jsprvtd.h \
|
||||
jspubtd.h \
|
||||
jsregexp.h \
|
||||
jsscan.h \
|
||||
jsscope.h \
|
||||
jsscript.h \
|
||||
jsstr.h \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
EXTRA_LIBS += $(DIST)/lib/libnspr$(MOD_VERSION).lib
|
||||
EXTRA_LIBS += $(DIST)/lib/libplds$(MOD_VERSION).lib
|
||||
else
|
||||
EXTRA_LIBS += -L$(DIST)/lib -lnspr$(MOD_VERSION) -lnplds$(MOD_VERSION)
|
||||
endif
|
||||
|
||||
LIBRARY_NAME = js
|
||||
LIBRARY_VERSION = $(MOD_VERSION)
|
||||
|
||||
RELEASE_HEADERS = $(HEADERS)
|
||||
RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
|
||||
RELEASE_LIBS = $(TARGETS)
|
||||
|
||||
include $(MOD_DEPTH)/config/rules.mk
|
||||
|
||||
export:: $(TARGETS)
|
||||
$(INSTALL) -m 444 $(HEADERS) $(MOD_DEPTH)/../dist/public/$(LIBRARY_NAME)
|
||||
$(INSTALL) -m 444 $(TARGETS) $(DIST)/lib
|
||||
$(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/bin
|
||||
|
||||
install:: export
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
js.c
|
||||
jsapi.c
|
||||
jsapi.h
|
||||
jsarray.c
|
||||
jsarray.h
|
||||
jsatom.c
|
||||
jsatom.h
|
||||
jsbool.c
|
||||
jsbool.h
|
||||
jscntxt.c
|
||||
jscntxt.h
|
||||
jsconfig.h
|
||||
jsdate.c
|
||||
jsdate.h
|
||||
jsdbgapi.c
|
||||
jsdbgapi.h
|
||||
jsemit.c
|
||||
jsemit.h
|
||||
jsfun.c
|
||||
jsfun.h
|
||||
jsgc.c
|
||||
jsgc.h
|
||||
jsinterp.c
|
||||
jsinterp.h
|
||||
jslock.h
|
||||
jslock.c
|
||||
jsmath.c
|
||||
jsmath.h
|
||||
jsnum.c
|
||||
jsnum.h
|
||||
jsobj.c
|
||||
jsobj.h
|
||||
jsopcode.c
|
||||
jsopcode.def
|
||||
jsopcode.h
|
||||
jsparse.c
|
||||
jsparse.h
|
||||
jsprvtd.h
|
||||
jspubtd.h
|
||||
jsregexp.c
|
||||
jsregexp.h
|
||||
jsscan.c
|
||||
jsscan.h
|
||||
jsscope.c
|
||||
jsscope.h
|
||||
jsscript.c
|
||||
jsscript.h
|
||||
jsstr.c
|
||||
jsstr.h
|
||||
jsxdrapi.h
|
||||
jsxdrapi.c
|
||||
92
mozilla/js/src/config.mk
Normal file
92
mozilla/js/src/config.mk
Normal file
@@ -0,0 +1,92 @@
|
||||
ifdef JS_DIST
|
||||
DIST = $(JS_DIST)
|
||||
else
|
||||
DIST = $(DEPTH)/../../dist/$(OBJDIR)
|
||||
endif
|
||||
|
||||
# Set os+release dependent make variables
|
||||
OS_ARCH := $(subst /,_,$(shell uname -s))
|
||||
|
||||
# Attempt to differentiate between SunOS 5.4 and x86 5.4
|
||||
OS_CPUARCH := $(shell uname -m)
|
||||
ifeq ($(OS_CPUARCH),i86pc)
|
||||
OS_RELEASE := $(shell uname -r)_$(OS_CPUARCH)
|
||||
else
|
||||
ifeq ($(OS_ARCH),AIX)
|
||||
OS_RELEASE := $(shell uname -v).$(shell uname -r)
|
||||
else
|
||||
OS_RELEASE := $(shell uname -r)
|
||||
endif
|
||||
endif
|
||||
ifeq ($(OS_ARCH),IRIX64)
|
||||
OS_ARCH := IRIX
|
||||
endif
|
||||
|
||||
# Virtually all Linux versions are identical.
|
||||
# Any distinctions are handled in linux.h
|
||||
ifeq ($(OS_ARCH),Linux)
|
||||
OS_CONFIG := Linux_All
|
||||
else
|
||||
ifeq ($(OS_ARCH),dgux)
|
||||
OS_CONFIG := dgux
|
||||
else
|
||||
OS_CONFIG := $(OS_ARCH)$(OS_OBJTYPE)$(OS_RELEASE)
|
||||
endif
|
||||
endif
|
||||
|
||||
ASFLAGS =
|
||||
DEFINES =
|
||||
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
INSTALL = nsinstall
|
||||
CP = cp
|
||||
else
|
||||
INSTALL = $(DEPTH)/../../dist/$(OBJDIR)/bin/nsinstall
|
||||
CP = cp
|
||||
endif
|
||||
|
||||
ifdef BUILD_OPT
|
||||
OPTIMIZER = -O
|
||||
DEFINES += -UDEBUG -DNDEBUG -UDEBUG_$(shell whoami)
|
||||
OBJDIR_TAG = _OPT
|
||||
else
|
||||
ifdef USE_MSVC
|
||||
OPTIMIZER = -Zi
|
||||
else
|
||||
OPTIMIZER = -g
|
||||
endif
|
||||
DEFINES += -DDEBUG -DDEBUG_$(shell whoami)
|
||||
OBJDIR_TAG = _DBG
|
||||
endif
|
||||
|
||||
SO_SUFFIX = so
|
||||
|
||||
NS_USE_NATIVE = 1
|
||||
|
||||
# Java stuff
|
||||
CLASSDIR = $(DEPTH)/liveconnect/classes
|
||||
JAVA_CLASSES = $(patsubst %.java,%.class,$(JAVA_SRCS))
|
||||
TARGETS += $(addprefix $(CLASSDIR)/$(OBJDIR)/$(JARPATH)/, $(JAVA_CLASSES))
|
||||
JAVAC = $(JDK)/bin/javac
|
||||
JAVAC_FLAGS = -classpath "$(CLASSPATH)" -d $(CLASSDIR)/$(OBJDIR)
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
SEP = ;
|
||||
else
|
||||
SEP = :
|
||||
endif
|
||||
CLASSPATH = $(JDK)/lib/classes.zip$(SEP)$(CLASSDIR)/$(OBJDIR)
|
||||
|
||||
include $(DEPTH)/config/$(OS_CONFIG).mk
|
||||
|
||||
# Name of the binary code directories
|
||||
ifdef BUILD_IDG
|
||||
OBJDIR = $(OS_CONFIG)$(OBJDIR_TAG).OBJD
|
||||
else
|
||||
OBJDIR = $(OS_CONFIG)$(OBJDIR_TAG).OBJ
|
||||
endif
|
||||
VPATH = $(OBJDIR)
|
||||
|
||||
# Automatic make dependencies file
|
||||
DEPENDENCIES = $(OBJDIR)/.md
|
||||
|
||||
LCJAR = js14lc30.jar
|
||||
@@ -35,3 +35,9 @@ OS_CFLAGS = -qarch=com -qinline+$(INLINES) -DXP_UNIX -DAIX -DAIXV3 -DSYSV
|
||||
OS_LIBS = -lbsd -lsvld -lm
|
||||
#-lpthreads -lc_r
|
||||
|
||||
MKSHLIB = $(LD) -bM:SRE -bh:4 -bnoentry -berok
|
||||
XLDFLAGS += -lc
|
||||
|
||||
ifdef JS_THREADSAFE
|
||||
XLDFLAGS += -lsvld
|
||||
endif
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
CC = xlC_r
|
||||
CCC = xlC_r
|
||||
CFLAGS += -qarch=com -qnoansialias -qinline+$(INLINES) -DXP_UNIX -DAIX -DAIXV3 -DSYSV
|
||||
|
||||
RANLIB = ranlib
|
||||
|
||||
@@ -31,7 +32,11 @@ CPU_ARCH = rs6000
|
||||
GFX_ARCH = x
|
||||
INLINES = js_compare_and_swap:js_fast_lock1:js_fast_unlock1:js_lock_get_slot:js_lock_set_slot:js_lock_scope1
|
||||
|
||||
OS_CFLAGS = -qarch=com -qinline+$(INLINES) -DXP_UNIX -DAIX -DAIXV3 -DSYSV
|
||||
OS_LIBS = -lbsd -lsvld -lm
|
||||
#-lpthreads -lc_r
|
||||
|
||||
MKSHLIB = /usr/lpp/xlC/bin/makeC++SharedLib_r -p 0 -G -berok
|
||||
|
||||
ifdef JS_THREADSAFE
|
||||
XLDFLAGS += -ldl
|
||||
endif
|
||||
|
||||
|
||||
@@ -19,10 +19,17 @@
|
||||
# Config stuff for HPUX
|
||||
#
|
||||
|
||||
CC = gcc -Wall -Wno-format
|
||||
CCC = g++ -Wall -Wno-format
|
||||
# CC = gcc
|
||||
# CCC = g++
|
||||
# CFLAGS += -Wall -Wno-format -fPIC
|
||||
|
||||
CC = cc -Ae +Z
|
||||
CCC = CC -Ae +a1 +eh +Z
|
||||
|
||||
RANLIB = echo
|
||||
MKSHLIB = $(LD) -b
|
||||
|
||||
SO_SUFFIX = sl
|
||||
|
||||
#.c.o:
|
||||
# $(CC) -c -MD $*.d $(CFLAGS) $<
|
||||
@@ -30,7 +37,7 @@ RANLIB = echo
|
||||
CPU_ARCH = hppa
|
||||
GFX_ARCH = x
|
||||
|
||||
OS_CFLAGS = -DXP_UNIX -DHPUX -DSYSV -D_SVID_GETTOD
|
||||
OS_CFLAGS = -DXP_UNIX -DHPUX -DSYSV
|
||||
OS_LIBS = -ldld
|
||||
|
||||
ifeq ($(OS_RELEASE),B.10)
|
||||
|
||||
55
mozilla/js/src/config/HP-UXB.10.20.mk
Normal file
55
mozilla/js/src/config/HP-UXB.10.20.mk
Normal file
@@ -0,0 +1,55 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
#
|
||||
# Config stuff for HPUX
|
||||
#
|
||||
|
||||
# CC = gcc
|
||||
# CCC = g++
|
||||
# CFLAGS += -Wall -Wno-format -fPIC
|
||||
|
||||
CC = cc -Ae +Z
|
||||
CCC = CC -Ae +a1 +eh +Z
|
||||
|
||||
RANLIB = echo
|
||||
MKSHLIB = $(LD) -b
|
||||
|
||||
SO_SUFFIX = sl
|
||||
|
||||
#.c.o:
|
||||
# $(CC) -c -MD $*.d $(CFLAGS) $<
|
||||
|
||||
CPU_ARCH = hppa
|
||||
GFX_ARCH = x
|
||||
|
||||
OS_CFLAGS = -DXP_UNIX -DHPUX -DSYSV
|
||||
OS_LIBS = -ldld
|
||||
|
||||
ifeq ($(OS_RELEASE),B.10)
|
||||
PLATFORM_FLAGS += -DHPUX10 -Dhpux10
|
||||
PORT_FLAGS += -DRW_NO_OVERLOAD_SCHAR -DHAVE_MODEL_H
|
||||
ifeq ($(OS_VERSION),.10)
|
||||
PLATFORM_FLAGS += -DHPUX10_10
|
||||
endif
|
||||
ifeq ($(OS_VERSION),.20)
|
||||
PLATFORM_FLAGS += -DHPUX10_20
|
||||
endif
|
||||
ifeq ($(OS_VERSION),.30)
|
||||
PLATFORM_FLAGS += -DHPUX10_30
|
||||
endif
|
||||
endif
|
||||
@@ -19,10 +19,18 @@
|
||||
# Config stuff for HPUX
|
||||
#
|
||||
|
||||
CC = gcc -Wall -Wno-format
|
||||
CCC = g++ -Wall -Wno-format
|
||||
ifdef NS_USE_NATIVE
|
||||
CC = cc +Z +DAportable +DS2.0 +u4
|
||||
# LD = aCC +Z -b -Wl,+s -Wl,-B,symbolic
|
||||
else
|
||||
CC = gcc -Wall -Wno-format -fPIC
|
||||
CCC = g++ -Wall -Wno-format -fPIC
|
||||
endif
|
||||
|
||||
RANLIB = echo
|
||||
MKSHLIB = $(LD) -b
|
||||
|
||||
SO_SUFFIX = sl
|
||||
|
||||
#.c.o:
|
||||
# $(CC) -c -MD $*.d $(CFLAGS) $<
|
||||
@@ -30,9 +38,11 @@ RANLIB = echo
|
||||
CPU_ARCH = hppa
|
||||
GFX_ARCH = x
|
||||
|
||||
OS_CFLAGS = -DXP_UNIX -DHPUX -DSYSV -D_SVID_GETTOD
|
||||
OS_CFLAGS = -DXP_UNIX -DHPUX -DSYSV -D_HPUX -DNATIVE -D_POSIX_C_SOURCE=199506L
|
||||
OS_LIBS = -ldld
|
||||
|
||||
XLDFLAGS = -lpthread
|
||||
|
||||
ifeq ($(OS_RELEASE),B.10)
|
||||
PLATFORM_FLAGS += -DHPUX10 -Dhpux10
|
||||
PORT_FLAGS += -DRW_NO_OVERLOAD_SCHAR -DHAVE_MODEL_H
|
||||
|
||||
@@ -26,7 +26,7 @@ RANLIB = /bin/true
|
||||
|
||||
#NS_USE_GCC = 1
|
||||
|
||||
ifdef NS_USE_GCC
|
||||
ifndef NS_USE_NATIVE
|
||||
CC = gcc
|
||||
CCC = g++
|
||||
AS = $(CC) -x assembler-with-cpp
|
||||
@@ -36,13 +36,17 @@ OPTIMIZER = -O6
|
||||
endif
|
||||
else
|
||||
ifeq ($(OS_RELEASE),6.2)
|
||||
CC = cc -32 -DIRIX6_2
|
||||
CC = cc -n32 -DIRIX6_2
|
||||
endif
|
||||
ifeq ($(OS_RELEASE),6.3)
|
||||
CC = cc -32 -DIRIX6_3
|
||||
CC = cc -n32 -DIRIX6_3
|
||||
endif
|
||||
ifeq ($(OS_RELEASE),6.5)
|
||||
CC = cc -n32 -DIRIX6_5
|
||||
endif
|
||||
CCC = CC
|
||||
ODD_CFLAGS = -fullwarn -xansi
|
||||
# LD = CC
|
||||
ODD_CFLAGS = -xansi
|
||||
ifdef BUILD_OPT
|
||||
OPTIMIZER += -Olimit 4000
|
||||
endif
|
||||
@@ -55,4 +59,7 @@ PURE_OS_CFLAGS = $(ODD_CFLAGS) -DXP_UNIX -DSVR4 -DSW_THREADS -DIRIX
|
||||
OS_CFLAGS = $(PURE_OS_CFLAGS) -MDupdate $(DEPENDENCIES)
|
||||
|
||||
BSDECHO = echo
|
||||
MKSHLIB = $(LD) -shared
|
||||
MKSHLIB = $(LD) -n32 -shared
|
||||
|
||||
# Use the editline library to provide line-editing support.
|
||||
JS_EDITLINE = 1
|
||||
|
||||
@@ -19,4 +19,4 @@
|
||||
# Config stuff for IRIX5.3
|
||||
#
|
||||
|
||||
include config/IRIX.mk
|
||||
include $(DEPTH)/config/IRIX.mk
|
||||
|
||||
@@ -19,4 +19,4 @@
|
||||
# Config stuff for IRIX6.3
|
||||
#
|
||||
|
||||
include config/IRIX.mk
|
||||
include $(DEPTH)/config/IRIX.mk
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Config stuff for IRIX6.2
|
||||
# Config stuff for IRIX6.3
|
||||
#
|
||||
|
||||
include config/IRIX.mk
|
||||
include $(DEPTH)/config/IRIX.mk
|
||||
|
||||
@@ -19,4 +19,4 @@
|
||||
# Config stuff for IRIX6.3
|
||||
#
|
||||
|
||||
include config/IRIX.mk
|
||||
include $(DEPTH)/config/IRIX.mk
|
||||
|
||||
22
mozilla/js/src/config/IRIX6.5.mk
Normal file
22
mozilla/js/src/config/IRIX6.5.mk
Normal file
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
#
|
||||
# Config stuff for IRIX6.3
|
||||
#
|
||||
|
||||
include $(DEPTH)/config/IRIX.mk
|
||||
@@ -19,10 +19,12 @@
|
||||
# Config for all versions of Linux
|
||||
#
|
||||
|
||||
CC = gcc -Wall -Wno-format
|
||||
CCC = g++ -Wall -Wno-format
|
||||
CC = /usr/bin/gcc
|
||||
CCC = /usr/bin/g++
|
||||
CFLAGS += -Wall -Wno-format
|
||||
|
||||
RANLIB = echo
|
||||
MKSHLIB = $(LD) -shared $(XMKSHLIBOPTS)
|
||||
|
||||
#.c.o:
|
||||
# $(CC) -c -MD $*.d $(CFLAGS) $<
|
||||
@@ -33,7 +35,7 @@ CPU_ARCH = x86
|
||||
endif
|
||||
GFX_ARCH = x
|
||||
|
||||
OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DLINUX
|
||||
OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE
|
||||
OS_LIBS = -lm -lc
|
||||
|
||||
ASFLAGS += -x assembler-with-cpp
|
||||
@@ -45,3 +47,6 @@ ifeq ($(CPU_ARCH),alpha)
|
||||
|
||||
OS_CFLAGS += -mieee
|
||||
endif
|
||||
|
||||
# Use the editline library to provide line-editing support.
|
||||
JS_EDITLINE = 1
|
||||
|
||||
50
mozilla/js/src/config/OSF1V4.0.mk
Normal file
50
mozilla/js/src/config/OSF1V4.0.mk
Normal file
@@ -0,0 +1,50 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
#
|
||||
# Config stuff for Data General DG/UX
|
||||
#
|
||||
|
||||
#
|
||||
# Initial DG/UX port by Marc Fraioli (fraioli@dg-rtp.dg.com)
|
||||
#
|
||||
|
||||
ifndef NS_USE_NATIVE
|
||||
CC = gcc
|
||||
CCC = g++
|
||||
CFLAGS += -mieee -Wall -Wno-format
|
||||
else
|
||||
CC = cc
|
||||
CCC = cxx
|
||||
CFLAGS += -ieee -std
|
||||
# LD = cxx
|
||||
endif
|
||||
|
||||
RANLIB = echo
|
||||
MKSHLIB = $(LD) -shared -taso -all -expect_unresolved "*"
|
||||
|
||||
#
|
||||
# _DGUX_SOURCE is needed to turn on a lot of stuff in the headers if
|
||||
# you're not using DG's compiler. It shouldn't hurt if you are.
|
||||
#
|
||||
# _POSIX4A_DRAFT10_SOURCE is needed to pick up localtime_r, used in
|
||||
# prtime.c
|
||||
#
|
||||
OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -DDGUX -D_DGUX_SOURCE -D_POSIX4A_DRAFT10_SOURCE -DOSF1
|
||||
OS_LIBS = -lsocket -lnsl
|
||||
|
||||
NOSUCHFILE = /no-such-file
|
||||
@@ -19,8 +19,9 @@
|
||||
# Config stuff for SunOS5.3
|
||||
#
|
||||
|
||||
CC = gcc -Wall -Wno-format
|
||||
CCC = g++ -Wall -Wno-format
|
||||
CC = gcc
|
||||
CCC = g++
|
||||
CFLAGS += -Wall -Wno-format
|
||||
|
||||
#CC = /opt/SUNWspro/SC3.0.1/bin/cc
|
||||
RANLIB = echo
|
||||
@@ -64,3 +65,5 @@ else
|
||||
ASFLAGS += -xarch=v8
|
||||
endif
|
||||
endif
|
||||
|
||||
MKSHLIB = $(LD) -G
|
||||
|
||||
@@ -23,8 +23,9 @@ ifdef NS_USE_NATIVE
|
||||
CC = cc
|
||||
CCC = CC
|
||||
else
|
||||
CC = gcc -Wall -Wno-format
|
||||
CCC = g++ -Wall -Wno-format
|
||||
CC = gcc
|
||||
CCC = g++
|
||||
CFLAGS += -Wall -Wno-format
|
||||
endif
|
||||
|
||||
RANLIB = echo
|
||||
@@ -65,3 +66,5 @@ else
|
||||
ASFLAGS += -xarch=v8
|
||||
endif
|
||||
endif
|
||||
|
||||
MKSHLIB = $(LD) -G
|
||||
|
||||
@@ -16,56 +16,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Config stuff for SunOS5.5
|
||||
# Config stuff for SunOS5.5.1
|
||||
#
|
||||
|
||||
AS = as
|
||||
ifndef NS_USE_NATIVE
|
||||
CC = gcc -Wall -Wno-format
|
||||
CCC = g++ -Wall
|
||||
else
|
||||
CC = cc
|
||||
CCC = CC
|
||||
endif
|
||||
|
||||
RANLIB = echo
|
||||
|
||||
#.c.o:
|
||||
# $(CC) -c -MD $*.d $(CFLAGS) $<
|
||||
|
||||
CPU_ARCH = sparc
|
||||
GFX_ARCH = x
|
||||
|
||||
OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -DSOLARIS -D_SVID_GETTOD
|
||||
OS_LIBS = -lsocket -lnsl -ldl
|
||||
|
||||
ASFLAGS += -P -L -K PIC -D_ASM -D__STDC__=0
|
||||
|
||||
HAVE_PURIFY = 1
|
||||
|
||||
NOSUCHFILE = /solaris-rm-f-sucks
|
||||
|
||||
ifndef JS_NO_ULTRA
|
||||
ULTRA_OPTIONS := -xarch=v8plus
|
||||
ULTRA_OPTIONSD := -DULTRA_SPARC
|
||||
else
|
||||
ULTRA_OPTIONS := -xarch=v8
|
||||
ULTRA_OPTIONSD :=
|
||||
endif
|
||||
|
||||
ifeq ($(OS_CPUARCH),sun4u)
|
||||
DEFINES += $(ULTRA_OPTIONSD)
|
||||
ifeq ($(findstring gcc,$(CC)),gcc)
|
||||
DEFINES += -Wa,$(ULTRA_OPTIONS),$(ULTRA_OPTIONSD)
|
||||
else
|
||||
ASFLAGS += $(ULTRA_OPTIONS) $(ULTRA_OPTIONSD)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_CPUARCH),sun4m)
|
||||
ifeq ($(findstring gcc,$(CC)),gcc)
|
||||
DEFINES += -Wa,-xarch=v8
|
||||
else
|
||||
ASFLAGS += -xarch=v8
|
||||
endif
|
||||
endif
|
||||
include $(DEPTH)/config/SunOS5.5.mk
|
||||
|
||||
@@ -20,10 +20,15 @@
|
||||
#
|
||||
|
||||
AS = as
|
||||
CC = gcc -Wall -Wno-format
|
||||
CCC = g++ -Wall -Wno-format
|
||||
ifndef NS_USE_NATIVE
|
||||
CC = gcc
|
||||
CCC = g++
|
||||
CFLAGS += -Wall -Wno-format
|
||||
else
|
||||
CC = cc
|
||||
CCC = CC
|
||||
endif
|
||||
|
||||
#CC = /opt/SUNWspro/SC3.0.1/bin/cc
|
||||
RANLIB = echo
|
||||
|
||||
#.c.o:
|
||||
@@ -32,7 +37,7 @@ RANLIB = echo
|
||||
CPU_ARCH = sparc
|
||||
GFX_ARCH = x
|
||||
|
||||
OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -DSOLARIS -D_SVID_GETTOD
|
||||
OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -DSOLARIS
|
||||
OS_LIBS = -lsocket -lnsl -ldl
|
||||
|
||||
ASFLAGS += -P -L -K PIC -D_ASM -D__STDC__=0
|
||||
@@ -41,22 +46,20 @@ HAVE_PURIFY = 1
|
||||
|
||||
NOSUCHFILE = /solaris-rm-f-sucks
|
||||
|
||||
ifndef JS_NO_ULTRA
|
||||
ULTRA_OPTIONS := -xarch=v8plus -DULTRA_SPARC
|
||||
ifeq ($(OS_CPUARCH),sun4u) # ultra sparc?
|
||||
ifeq ($(CC),gcc) # using gcc?
|
||||
ifndef JS_NO_ULTRA # do we want ultra?
|
||||
ifdef JS_THREADSAFE # only in thread-safe mode
|
||||
DEFINES += -DULTRA_SPARC
|
||||
DEFINES += -Wa,-xarch=v8plus,-DULTRA_SPARC
|
||||
else
|
||||
ULTRA_OPTIONS := -xarch=v8
|
||||
ASFLAGS += -xarch=v8plus -DULTRA_SPARC
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_CPUARCH),sun4u)
|
||||
ASFLAGS += $(ULTRA_OPTIONS)
|
||||
ifeq ($(findstring gcc,$(CC)),gcc)
|
||||
DEFINES += -Wa,$(ULTRA_OPTIONS)
|
||||
endif
|
||||
else
|
||||
ifeq ($(OS_CPUARCH),sun4m)
|
||||
ASFLAGS += -xarch=v8
|
||||
ifeq ($(findstring gcc,$(CC)),gcc)
|
||||
DEFINES += -Wa,-xarch=v8
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
MKSHLIB = $(LD) -G
|
||||
|
||||
# Use the editline library to provide line-editing support.
|
||||
JS_EDITLINE = 1
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user