mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 17:10:20 -10:00
Compare commits
627
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6bf50d107b | ||
|
|
98aef175b2 | ||
|
|
cfbb707d77 | ||
|
|
26b44adfee | ||
|
|
7cc63291b9 | ||
|
|
242738b9b4 | ||
|
|
23daaa8f3d | ||
|
|
d26916f86c | ||
|
|
96debf77d1 | ||
|
|
26831a86d2 | ||
|
|
281208244f | ||
|
|
88eb6b008e | ||
|
|
87048f03df | ||
|
|
982f710571 | ||
|
|
fd12f0b05e | ||
|
|
b2cc26aa81 | ||
|
|
60fd58a157 | ||
|
|
4ec59639b7 | ||
|
|
8e5e7ea505 | ||
|
|
94e8ad6ef0 | ||
|
|
cf0b31248a | ||
|
|
16013bc247 | ||
|
|
71d6896925 | ||
|
|
8c2c29d41c | ||
|
|
46e571eaf1 | ||
|
|
eb25dfce5c | ||
|
|
0d864b08c0 | ||
|
|
3b846d3d4c | ||
|
|
722ace9131 | ||
|
|
20d08fd8da | ||
|
|
29c42bf0dc | ||
|
|
3673d051fb | ||
|
|
cfa7bad1d7 | ||
|
|
33bd2503de | ||
|
|
95a6979c3b | ||
|
|
9bcd33f029 | ||
|
|
b46b038f33 | ||
|
|
7770413fac | ||
|
|
f2e7f36368 | ||
|
|
41290d39db | ||
|
|
a700784767 | ||
|
|
de2efdbd0f | ||
|
|
d71ca46641 | ||
|
|
91e22b4d37 | ||
|
|
2d6335f6a7 | ||
|
|
bfff327c10 | ||
|
|
8cb8add995 | ||
|
|
e0c4e5bf88 | ||
|
|
0152cee92d | ||
|
|
7685ca6271 | ||
|
|
ac146cb037 | ||
|
|
c187e5ea14 | ||
|
|
ba8d128834 | ||
|
|
c686f20fbe | ||
|
|
74fc821cf6 | ||
|
|
e50f95626b | ||
|
|
25961ac5cf | ||
|
|
9c1b3cba34 | ||
|
|
f36257e03b | ||
|
|
cabe0f95ed | ||
|
|
a257338394 | ||
|
|
2bec46815c | ||
|
|
4a61680549 | ||
|
|
7694b5dbae | ||
|
|
1269b409b3 | ||
|
|
cbca01b433 | ||
|
|
1fe24728bd | ||
|
|
88dadaaf10 | ||
|
|
52a67a6219 | ||
|
|
0ef5f49c1f | ||
|
|
b43211d101 | ||
|
|
6508d62869 | ||
|
|
8ab849eb82 | ||
|
|
70b14ec733 | ||
|
|
e9f871dfe4 | ||
|
|
ada7e135c9 | ||
|
|
f81e067e01 | ||
|
|
cad5315ebf | ||
|
|
e86837b7d2 | ||
|
|
a208b628e9 | ||
|
|
1044b36c14 | ||
|
|
f9391f934a | ||
|
|
a8cbb84a2c | ||
|
|
8d291a2e77 | ||
|
|
6a4dcd4f6c | ||
|
|
f117b64a5d | ||
|
|
0c8d56025e | ||
|
|
b05f24e810 | ||
|
|
349c84032e | ||
|
|
17a8120548 | ||
|
|
4060edb4fa | ||
|
|
0e9c53b052 | ||
|
|
9d94a06e6a | ||
|
|
37e7f2fb50 | ||
|
|
a81cd6dae8 | ||
|
|
384f1d8af5 | ||
|
|
a385a2bac2 | ||
|
|
58e8550d5c | ||
|
|
93b0f40d43 | ||
|
|
516c4d85f5 | ||
|
|
c7a91f9309 | ||
|
|
2b39b6a926 | ||
|
|
00f152cfc4 | ||
|
|
6a14275371 | ||
|
|
effa6dcf44 | ||
|
|
5047a9c314 | ||
|
|
4f021d81ca | ||
|
|
64dcc45998 | ||
|
|
26099534a0 | ||
|
|
e789b6abbb | ||
|
|
2940861c80 | ||
|
|
6930f1a8ee | ||
|
|
a31b580fdc | ||
|
|
fd80c70838 | ||
|
|
18068d5b4f | ||
|
|
2f19eee32f | ||
|
|
cca57fa576 | ||
|
|
9fd216db06 | ||
|
|
b609cbb543 | ||
|
|
bd130f3a2c | ||
|
|
91bf902e2e | ||
|
|
82219acd3c | ||
|
|
94f12d815e | ||
|
|
2448e73caa | ||
|
|
92d3a7b0b6 | ||
|
|
fad3d7f588 | ||
|
|
c0365e5748 | ||
|
|
c98df65bfa | ||
|
|
af8e11988d | ||
|
|
398c7fc21f | ||
|
|
0e7dc370e3 | ||
|
|
2ab52ceae2 | ||
|
|
27e36aef37 | ||
|
|
f447c860f5 | ||
|
|
c529dc59df | ||
|
|
56a02b9285 | ||
|
|
d0715eeb4b | ||
|
|
0585e7cb9a | ||
|
|
9883ab8b8a | ||
|
|
d5b8fd8e6d | ||
|
|
51b648a118 | ||
|
|
b1d7375726 | ||
|
|
b5188e8b4e | ||
|
|
7839312e84 | ||
|
|
529b920b35 | ||
|
|
06dea0679d | ||
|
|
21e5a22980 | ||
|
|
f436736f30 | ||
|
|
699ef5e948 | ||
|
|
fa0f423dc5 | ||
|
|
2c45af25e2 | ||
|
|
7bd34e5715 | ||
|
|
b62bb260ec | ||
|
|
2f334102cd | ||
|
|
ded10b24e9 | ||
|
|
d21b0aa3d9 | ||
|
|
fde407c873 | ||
|
|
53a68c9e20 | ||
|
|
ccab57808d | ||
|
|
4c0a69874e | ||
|
|
ebfd12313e | ||
|
|
77f1fafb58 | ||
|
|
04f533820d | ||
|
|
d1fcb53e15 | ||
|
|
d41a06ca08 | ||
|
|
c65fe47d44 | ||
|
|
468cb8d277 | ||
|
|
2cc36e3331 | ||
|
|
5c55eea17e | ||
|
|
09139111a5 | ||
|
|
1eb75507a6 | ||
|
|
f2524362fc | ||
|
|
b5a856e716 | ||
|
|
0487904629 | ||
|
|
9c65ad34a9 | ||
|
|
5d37fac7c8 | ||
|
|
56f98e18dd | ||
|
|
0c22492321 | ||
|
|
6a4c57e05b | ||
|
|
3e2f5ef8fc | ||
|
|
874d3b1389 | ||
|
|
155df94118 | ||
|
|
b22667cd23 | ||
|
|
3448cab291 | ||
|
|
72d14cca36 | ||
|
|
b213facf8e | ||
|
|
b0406462f6 | ||
|
|
f9adf72b40 | ||
|
|
72855152a6 | ||
|
|
3942cbcf71 | ||
|
|
060669d19a | ||
|
|
b0b4fdb5ee | ||
|
|
afef0a0f59 | ||
|
|
dcd27aa93f | ||
|
|
1496eac3f4 | ||
|
|
19d7806b73 | ||
|
|
5db03c67c1 | ||
|
|
a0bba405d1 | ||
|
|
82a197e41c | ||
|
|
b4f1c73e83 | ||
|
|
261ec28e7c | ||
|
|
c5c858d823 | ||
|
|
aa5da06469 | ||
|
|
6129ec4d09 | ||
|
|
20d02fae27 | ||
|
|
67a116c863 | ||
|
|
aa5657b7fa | ||
|
|
f04968359d | ||
|
|
c234f6e2dc | ||
|
|
903d21bac7 | ||
|
|
8263101015 | ||
|
|
559570da6d | ||
|
|
571444246f | ||
|
|
7f50298027 | ||
|
|
1a2de021ca | ||
|
|
a9201c5b00 | ||
|
|
a6331506cb | ||
|
|
5682a6430e | ||
|
|
cf17ecb829 | ||
|
|
e12b9a2c61 | ||
|
|
ae40175ca0 | ||
|
|
26d0b81c26 | ||
|
|
ab92538d5a | ||
|
|
6cca13b657 | ||
|
|
1188277099 | ||
|
|
439046726f | ||
|
|
70d411b525 | ||
|
|
1f6effb1e1 | ||
|
|
37ac7d16dc | ||
|
|
300f015223 | ||
|
|
809b7ed950 | ||
|
|
6128710873 | ||
|
|
fb24aa7b1a | ||
|
|
8b3b6a5208 | ||
|
|
f4c24efe89 | ||
|
|
0b016adf56 | ||
|
|
5ad97cca6c | ||
|
|
7cda2dd37c | ||
|
|
8a10b06610 | ||
|
|
5a9472a254 | ||
|
|
568e0bc803 | ||
|
|
e7a9566734 | ||
|
|
23548657e1 | ||
|
|
41a154d096 | ||
|
|
cbbd711017 | ||
|
|
9a1ddb9f0c | ||
|
|
09219a1459 | ||
|
|
d4e750970c | ||
|
|
849fb05887 | ||
|
|
6944d48c68 | ||
|
|
0721c1fb28 | ||
|
|
d84a165c8e | ||
|
|
57224013a8 | ||
|
|
1e93b054ec | ||
|
|
316061e2dc | ||
|
|
057fc20fa4 | ||
|
|
8a019b64fe | ||
|
|
9cb7a839eb | ||
|
|
01697c1f78 | ||
|
|
2a62fb90b5 | ||
|
|
6608f5db66 | ||
|
|
8ffb6b1981 | ||
|
|
b6da6da507 | ||
|
|
c4ced34e1c | ||
|
|
b181fa6d91 | ||
|
|
2a4e1e127b | ||
|
|
b6d1b4492f | ||
|
|
81e3a33c79 | ||
|
|
ff9f71c44e | ||
|
|
4ed1d92610 | ||
|
|
77d2f31ac1 | ||
|
|
adbe98f12d | ||
|
|
694d67d582 | ||
|
|
d90decc417 | ||
|
|
fa8dc3c5e5 | ||
|
|
ebff81b3d5 | ||
|
|
df60ae8379 | ||
|
|
5c3ea0d668 | ||
|
|
0b839ce9ea | ||
|
|
dd53968422 | ||
|
|
73caba4f68 | ||
|
|
eea85080a6 | ||
|
|
77986a10be | ||
|
|
d673f23cad | ||
|
|
e99ecebd51 | ||
|
|
76e680de20 | ||
|
|
277758cdab | ||
|
|
0b7e53aa89 | ||
|
|
d1711cf941 | ||
|
|
0c1a0270bc | ||
|
|
9aa6a601e4 | ||
|
|
15eed77288 | ||
|
|
e1107c0b30 | ||
|
|
c83b58b942 | ||
|
|
b5e4d2de43 | ||
|
|
c6914fe1b1 | ||
|
|
65b50fc464 | ||
|
|
ce3e843793 | ||
|
|
7101724538 | ||
|
|
4d74cc9c57 | ||
|
|
9543cd8c27 | ||
|
|
01536c4acf | ||
|
|
9fdd8bc9b2 | ||
|
|
727520fbdd | ||
|
|
c65b7e486f | ||
|
|
48b37187ef | ||
|
|
8165563a4c | ||
|
|
c676050454 | ||
|
|
0da8d969d3 | ||
|
|
6a9e457af2 | ||
|
|
d0cfdc22b4 | ||
|
|
a7debabcd4 | ||
|
|
000d442b50 | ||
|
|
02820da410 | ||
|
|
90e4ae45ea | ||
|
|
12aa2ee3ca | ||
|
|
cd49ed4b02 | ||
|
|
01ee50f7d6 | ||
|
|
e906cecb4c | ||
|
|
e8f477f90a | ||
|
|
0a93160fdc | ||
|
|
e338775ecd | ||
|
|
52300170c7 | ||
|
|
c732e37828 | ||
|
|
a157487ca7 | ||
|
|
8b9d426608 | ||
|
|
62cd47529d | ||
|
|
374c94876a | ||
|
|
c3d818e1ba | ||
|
|
2864dd1bad | ||
|
|
ea8e3bfa07 | ||
|
|
ad32f65e9b | ||
|
|
a1e5ba803f | ||
|
|
77c1ea1999 | ||
|
|
eb13855b98 | ||
|
|
0a3b65804b | ||
|
|
40546e633d | ||
|
|
0d6d70b299 | ||
|
|
9b824c31c8 | ||
|
|
98dec22c8f | ||
|
|
7c89014866 | ||
|
|
9036063250 | ||
|
|
c1f4854661 | ||
|
|
ff3f2aca0e | ||
|
|
14ac833855 | ||
|
|
2cde7a3eca | ||
|
|
fa60f1033b | ||
|
|
76890ae042 | ||
|
|
e2478f0c75 | ||
|
|
02964f35a8 | ||
|
|
dbf1626dc0 | ||
|
|
69d356081a | ||
|
|
b96c455ef9 | ||
|
|
439ef67c99 | ||
|
|
f7e2304843 | ||
|
|
a667b8846d | ||
|
|
78db50f208 | ||
|
|
7a307b7068 | ||
|
|
567f714b26 | ||
|
|
6ff60ff56e | ||
|
|
bd54b2b72d | ||
|
|
912074c481 | ||
|
|
41d5852ba0 | ||
|
|
79dfbe5192 | ||
|
|
84c483ae45 | ||
|
|
6b55ac5530 | ||
|
|
4085776a67 | ||
|
|
d199de6270 | ||
|
|
482f6c7b55 | ||
|
|
a3c12804f0 | ||
|
|
a54d96b37e | ||
|
|
180fb9b3f9 | ||
|
|
ff41b501ea | ||
|
|
a4800b96b2 | ||
|
|
365da8343a | ||
|
|
f9d78260db | ||
|
|
b69d833414 | ||
|
|
0497877695 | ||
|
|
a707a3dadb | ||
|
|
1022c50752 | ||
|
|
75ffa3d011 | ||
|
|
e5942fbc7b | ||
|
|
f0a95b71e3 | ||
|
|
37502a86d5 | ||
|
|
ad639e3e99 | ||
|
|
c931c463c2 | ||
|
|
76e8c8ba0f | ||
|
|
2c6dc87269 | ||
|
|
17d1c098bf | ||
|
|
487b05c2b6 | ||
|
|
7f8fa9a8a5 | ||
|
|
883998ce2d | ||
|
|
44690a038a | ||
|
|
e085ba9991 | ||
|
|
fdc96789c4 | ||
|
|
8ba2023998 | ||
|
|
7f7a747893 | ||
|
|
5d357d8bde | ||
|
|
20f022d489 | ||
|
|
da42adba1d | ||
|
|
96cf763430 | ||
|
|
bb8f31f1a8 | ||
|
|
ccbc9e3a8f | ||
|
|
c537883799 | ||
|
|
bc2ace8f20 | ||
|
|
d62166b91a | ||
|
|
0ffa570a3a | ||
|
|
2ee134a8ea | ||
|
|
160c8d3015 | ||
|
|
94e78fd162 | ||
|
|
a31c107f59 | ||
|
|
ee48fc81a9 | ||
|
|
53b3d6532a | ||
|
|
b269b884fa | ||
|
|
03c3fbe77a | ||
|
|
6a2d71f889 | ||
|
|
9114f339f9 | ||
|
|
5c85e41f84 | ||
|
|
ba79efb593 | ||
|
|
fbdc2a7639 | ||
|
|
23ac11d001 | ||
|
|
89d5527369 | ||
|
|
4579fb3d43 | ||
|
|
8a9d70fabc | ||
|
|
2719711a51 | ||
|
|
5385752588 | ||
|
|
33ffb757d2 | ||
|
|
16d2bcaa37 | ||
|
|
9691284796 | ||
|
|
0938c69a52 | ||
|
|
5e1c9a8ffe | ||
|
|
b166ec8b48 | ||
|
|
354027fe22 | ||
|
|
929bdf2f1d | ||
|
|
f8bf28804c | ||
|
|
4e54e9e05f | ||
|
|
920d873ff3 | ||
|
|
93acdb1fcc | ||
|
|
579148e2d6 | ||
|
|
778fc600e0 | ||
|
|
ca747a3a1c | ||
|
|
80b8412a11 | ||
|
|
27c3736aac | ||
|
|
a256df77aa | ||
|
|
24c84e6f31 | ||
|
|
08d4170b8c | ||
|
|
bfefbf3460 | ||
|
|
5e9f57b92f | ||
|
|
cfb36e518a | ||
|
|
50faec743e | ||
|
|
ad0c77db0f | ||
|
|
0b09bfc495 | ||
|
|
0de54a335a | ||
|
|
be1042379a | ||
|
|
951f9a7912 | ||
|
|
9b63f759fb | ||
|
|
2e255604b2 | ||
|
|
bb6cd4b722 | ||
|
|
37bad99b16 | ||
|
|
b92bac52bf | ||
|
|
ff23e80e3e | ||
|
|
e19fa7926a | ||
|
|
a3272f7b44 | ||
|
|
bfd1c73b7d | ||
|
|
6cd895de20 | ||
|
|
645991d363 | ||
|
|
d1df1729ba | ||
|
|
32be89f0f2 | ||
|
|
d64dc48f1f | ||
|
|
beb9cee5b5 | ||
|
|
442ccb9676 | ||
|
|
070c3abecf | ||
|
|
8f9a0185b3 | ||
|
|
9999ea4a68 | ||
|
|
aef4b77ea7 | ||
|
|
614f3f9049 | ||
|
|
fc1145ae84 | ||
|
|
e90505c29f | ||
|
|
1eff479c71 | ||
|
|
2226f02696 | ||
|
|
b65deac489 | ||
|
|
20aaf27c90 | ||
|
|
453654552e | ||
|
|
b652b273af | ||
|
|
61923824ce | ||
|
|
1c7fc8195f | ||
|
|
9d719ab6d0 | ||
|
|
b7bed40197 | ||
|
|
56e1d8fca6 | ||
|
|
846d80f19e | ||
|
|
8f99af4eec | ||
|
|
b511f6d141 | ||
|
|
9694eb7dbd | ||
|
|
946e182bd9 | ||
|
|
bf6a13bcb4 | ||
|
|
132a16ca07 | ||
|
|
5e497f0de4 | ||
|
|
fab9077c17 | ||
|
|
fb2546951c | ||
|
|
238785a3e3 | ||
|
|
479cfc6980 | ||
|
|
035214bee1 | ||
|
|
0ea5ed961e | ||
|
|
abbf953e28 | ||
|
|
5b8a026a06 | ||
|
|
392bae3c45 | ||
|
|
61cd9ee8b6 | ||
|
|
2e6266606a | ||
|
|
22892bc401 | ||
|
|
f99f84a429 | ||
|
|
718ceb8601 | ||
|
|
de60d57559 | ||
|
|
54f3f6ae21 | ||
|
|
5de235b376 | ||
|
|
233e828938 | ||
|
|
4ce97be553 | ||
|
|
fa69e58cc6 | ||
|
|
4d4e3c3d5b | ||
|
|
26a0904c82 | ||
|
|
cee5749a81 | ||
|
|
1f337115cd | ||
|
|
3dfaaa542d | ||
|
|
83ed15e19d | ||
|
|
005dbf7840 | ||
|
|
24f08876a8 | ||
|
|
80d3d461c3 | ||
|
|
9d55be425d | ||
|
|
9645cd9249 | ||
|
|
faff4654c8 | ||
|
|
938d3fa4cb | ||
|
|
208d5648fe | ||
|
|
de00f9d473 | ||
|
|
29cb82c254 | ||
|
|
2e6f26e1a8 | ||
|
|
5fd4d99fe8 | ||
|
|
66fb7ce67e | ||
|
|
2172220087 | ||
|
|
35aec39910 | ||
|
|
251c170d3f | ||
|
|
f0ae724eaf | ||
|
|
1a552aefd4 | ||
|
|
d401698972 | ||
|
|
4bed597229 | ||
|
|
66ce1e4960 | ||
|
|
77dc2ebb66 | ||
|
|
6f54e4a2fc | ||
|
|
ec3513c3fd | ||
|
|
0e67acba31 | ||
|
|
04ffec1684 | ||
|
|
c7e874a982 | ||
|
|
24ac85a90f | ||
|
|
cf1f9138eb | ||
|
|
871a24a580 | ||
|
|
4ce0e7e848 | ||
|
|
d7fe5b8a89 | ||
|
|
2ab53f953f | ||
|
|
5dd394c77c | ||
|
|
fb9400fd06 | ||
|
|
7ff2a90ad5 | ||
|
|
ef205e5df2 | ||
|
|
0ec1a19ac7 | ||
|
|
7554e7cd95 | ||
|
|
fc7ceab083 | ||
|
|
a872ebb614 | ||
|
|
71739e6420 | ||
|
|
9e8e9a6d36 | ||
|
|
75f4e90d4b | ||
|
|
5705602f1b | ||
|
|
ed1838b4e7 | ||
|
|
cbe746f29f | ||
|
|
a4edd897b5 | ||
|
|
d51dc95fb9 | ||
|
|
6c54381300 | ||
|
|
f3cc3bf544 | ||
|
|
924c7c5514 | ||
|
|
9ccd495f33 | ||
|
|
5c4b348e80 | ||
|
|
a5ba6ad54d | ||
|
|
b9cbade24a | ||
|
|
94660dd77f | ||
|
|
be2e73c7e8 | ||
|
|
2d868f3690 | ||
|
|
e40775d0dc | ||
|
|
b5e9e3a965 | ||
|
|
e779592fb6 | ||
|
|
18a3253788 | ||
|
|
ca1529df5b | ||
|
|
5a161c7d2d | ||
|
|
9bb552dcc0 | ||
|
|
4beada2892 | ||
|
|
d63cedf256 | ||
|
|
ffe8719327 | ||
|
|
432633827b | ||
|
|
5d36460657 | ||
|
|
e147105e52 | ||
|
|
2c5cf355d8 | ||
|
|
45d70b772a | ||
|
|
0f05bb55f4 | ||
|
|
b84ad279fb | ||
|
|
3600480ced | ||
|
|
2bc6e4b228 | ||
|
|
51c7b8892d | ||
|
|
e2ac2a9e45 | ||
|
|
576dfed659 | ||
|
|
2fa83f0a8c | ||
|
|
72ed65fdd8 | ||
|
|
bf9b74f05a | ||
|
|
c22ce0e053 | ||
|
|
34aa103a3c | ||
|
|
ade6a99d9e | ||
|
|
6ad7f75a37 | ||
|
|
ce246f6a5b | ||
|
|
062dfd03eb | ||
|
|
d624211706 | ||
|
|
b87ca2196c | ||
|
|
05643bef22 | ||
|
|
34222916bf | ||
|
|
4c7bcaaca3 | ||
|
|
c9e3b37bb8 | ||
|
|
b07a494bb6 | ||
|
|
a93fa79df7 | ||
|
|
1eb5cd8654 | ||
|
|
026a80eea2 | ||
|
|
e62924259a | ||
|
|
8f6a053b80 | ||
|
|
a0a12c128d | ||
|
|
e6b8be8cba |
No files matched your search
+1
-1
@@ -55,7 +55,7 @@ _ReSharper*/
|
||||
~$*
|
||||
|
||||
# Autotools-generated files
|
||||
Makefile
|
||||
/Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
|
||||
Regular → Executable
+93
-41
@@ -1,7 +1,7 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
#AC_PREREQ([2.62])
|
||||
|
||||
AC_INIT(mono, [3.1.0],
|
||||
AC_INIT(mono, [3.3.0],
|
||||
[http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono])
|
||||
|
||||
AC_CONFIG_SRCDIR([README])
|
||||
@@ -105,22 +105,6 @@ case "$host" in
|
||||
if test "x$host" == "x$build" -a "x$host" == "x$target"; then
|
||||
AC_DEFINE(TARGET_WIN32,1,[Target OS is Win32])
|
||||
fi
|
||||
#
|
||||
# gcc-3/g++-3 are from the gcc-core/gcc-g++ cygwin packages.
|
||||
# Other gcc packages will not work:
|
||||
# - the gcc-4 packages no longer support -mno-cygwin
|
||||
# - the mingw-gcc packages produce executables which depends on a libgcc<...>
|
||||
# dll, which means we would have to distribute that file too.
|
||||
#
|
||||
if test "x$CC" != "x"; then
|
||||
AC_ERROR(Don't set CC. mono can only be compiled with gcc-3 from the 'gcc-core' package)
|
||||
fi
|
||||
CC="gcc-3.exe -mno-cygwin -g"
|
||||
CXX="g++-3.exe -mno-cygwin -g"
|
||||
# So libgc configure gets -mno-cygwin
|
||||
export CC
|
||||
export CXX
|
||||
CFLAGS_FOR_EGLIB="$CFLAGS_FOR_EGLIB -mno-cygwin"
|
||||
else
|
||||
target_win32=yes
|
||||
AC_DEFINE(TARGET_WIN32,1,[Target OS is Win32/MinGW])
|
||||
@@ -130,8 +114,8 @@ case "$host" in
|
||||
# Windows 2000 is required that includes Internet Explorer 5.01
|
||||
CPPFLAGS="$CPPFLAGS -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -D_WIN32_IE=0x0501 -D_UNICODE -DUNICODE -DWIN32_THREADS -DFD_SETSIZE=1024"
|
||||
LDFLAGS="$LDFLAGS -lmswsock -lws2_32 -lole32 -loleaut32 -lpsapi -lversion -ladvapi32 -lwinmm -lkernel32"
|
||||
libmono_cflags="-mno-cygwin -mms-bitfields -mwindows"
|
||||
libmono_ldflags="-mno-cygwin -mms-bitfields -mwindows"
|
||||
libmono_cflags="-mms-bitfields -mwindows"
|
||||
libmono_ldflags="-mms-bitfields -mwindows"
|
||||
libdl=
|
||||
libgc_threads=win32
|
||||
gc_default=included
|
||||
@@ -491,6 +475,12 @@ AC_TRY_LINK([#include <math.h>], [
|
||||
# We'll have to use signals
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
# mingw
|
||||
AC_CHECK_FUNCS(_finite, , AC_MSG_CHECKING(for _finite in math.h)
|
||||
AC_TRY_LINK([#include <math.h>],
|
||||
[ _finite(0.0); ],
|
||||
AC_DEFINE(HAVE__FINITE, 1, [Have _finite in -lm]) AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(no)))
|
||||
|
||||
# for Linux statfs support
|
||||
AC_CHECK_HEADERS(linux/magic.h)
|
||||
@@ -1150,6 +1140,8 @@ if test x$target_win32 = xno; then
|
||||
|
||||
AC_CHECK_HEADERS(execinfo.h)
|
||||
|
||||
AC_CHECK_HEADERS(sys/auxv.h)
|
||||
|
||||
AC_CHECK_FUNCS(getgrgid_r)
|
||||
AC_CHECK_FUNCS(getgrnam_r)
|
||||
AC_CHECK_FUNCS(getpwnam_r)
|
||||
@@ -1583,6 +1575,10 @@ if test x$target_win32 = xno; then
|
||||
AC_MSG_RESULT(disabled)
|
||||
else
|
||||
AC_TRY_RUN([
|
||||
#if defined(__APPLE__) && defined(__clang__)
|
||||
#error "__thread does not currently work with clang on Mac OS X"
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
__thread int i;
|
||||
static int res1, res2;
|
||||
@@ -2375,14 +2371,18 @@ if test "x$enable_llvm" = "xyes"; then
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# The output of --cflags seems to include optimizations flags too
|
||||
LLVM_CFLAGS=`$LLVM_CONFIG --cflags | sed -e 's/-O2//g' | sed -e 's/-O0//g' | sed -e 's/-fomit-frame-pointer//g' | sed -e 's/-fPIC//g'`
|
||||
# LLVM is compiled with -fno-rtti, so we need this too, since our classes inherit
|
||||
# from LLVM classes.
|
||||
LLVM_CXXFLAGS="`$LLVM_CONFIG --cxxflags` -fno-rtti"
|
||||
LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
|
||||
LLVM_LIBS=`$LLVM_CONFIG --libs core bitwriter jit mcjit $llvm_codegen`
|
||||
if test "x$host" != "x$target"; then
|
||||
# No need for jit libs
|
||||
LLVM_LIBS=`$LLVM_CONFIG --libs core bitwriter`
|
||||
else
|
||||
LLVM_LIBS=`$LLVM_CONFIG --libs core bitwriter jit mcjit $llvm_codegen`
|
||||
fi
|
||||
LLVM_LIBS="$LLVM_LDFLAGS $LLVM_LIBS -lstdc++"
|
||||
|
||||
# Should be something like '2.6' or '2.7svn'
|
||||
@@ -2486,7 +2486,7 @@ case "$host" in
|
||||
have_visibility_hidden=no
|
||||
sgen_supported=true
|
||||
;;
|
||||
cygwin*)
|
||||
mingw*|cygwin*)
|
||||
sgen_supported=true
|
||||
have_visibility_hidden=no
|
||||
;;
|
||||
@@ -2592,9 +2592,9 @@ case "$host" in
|
||||
arch_target=arm;
|
||||
ACCESS_UNALIGNED="no"
|
||||
JIT_SUPPORTED=yes
|
||||
CPPFLAGS="$CPPFLAGS -D__ARM_EABI__ -DHAVE_ARMV6=1"
|
||||
CPPFLAGS="$CPPFLAGS -D__ARM_EABI__"
|
||||
# libgc's gc_locks.h depends on this
|
||||
CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DHAVE_ARMV6"
|
||||
CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC"
|
||||
sgen_supported=true
|
||||
;;
|
||||
arm*-linux*)
|
||||
@@ -2616,7 +2616,7 @@ case "$host" in
|
||||
# AOT_SUPPORTED="no"
|
||||
# ;;
|
||||
s390x-*-linux*)
|
||||
TARGET=S390x;
|
||||
TARGET=S390X;
|
||||
arch_target=s390x;
|
||||
ACCESS_UNALIGNED="yes"
|
||||
JIT_SUPPORTED=yes
|
||||
@@ -2636,7 +2636,7 @@ if test "x$host" != "x$target"; then
|
||||
arch_target=arm;
|
||||
ACCESS_UNALIGNED="no"
|
||||
JIT_SUPPORTED=yes
|
||||
CPPFLAGS="$CPPFLAGS -D__ARM_EABI__ -DHAVE_ARMV6=1"
|
||||
CPPFLAGS="$CPPFLAGS -D__ARM_EABI__"
|
||||
jit_wanted=true
|
||||
# Can't use tls, since it depends on the runtime detection of tls offsets
|
||||
# in mono-compiler.h
|
||||
@@ -2725,7 +2725,6 @@ if test "x$host" != "x$target"; then
|
||||
esac
|
||||
fi
|
||||
|
||||
# FIXME: Define the others as well
|
||||
case "$TARGET" in
|
||||
X86)
|
||||
AC_DEFINE(TARGET_X86, 1, [...])
|
||||
@@ -2743,14 +2742,32 @@ POWERPC64)
|
||||
AC_DEFINE(TARGET_POWERPC, 1, [...])
|
||||
AC_DEFINE(TARGET_POWERPC64, 1, [...])
|
||||
;;
|
||||
S390x)
|
||||
S390X)
|
||||
AC_DEFINE(TARGET_S390X, 1, [...])
|
||||
;;
|
||||
MIPS)
|
||||
AC_DEFINE(TARGET_MIPS, 1, [...])
|
||||
;;
|
||||
IA64)
|
||||
AC_DEFINE(TARGET_IA64, 1, [...])
|
||||
;;
|
||||
SPARC)
|
||||
AC_DEFINE(TARGET_SPARC, 1, [...])
|
||||
;;
|
||||
SPARC64)
|
||||
AC_DEFINE(TARGET_SPARC64, 1, [...])
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl Use GCC atomic ops if they work on the target.
|
||||
if test x$GCC = "xyes"; then
|
||||
case $TARGET in
|
||||
X86 | AMD64 | ARM | POWERPC | POWERPC64 | MIPS)
|
||||
AC_DEFINE(USE_GCC_ATOMIC_OPS, 1, [...])
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if test "x$target_mach" = "xyes"; then
|
||||
if test "x$TARGET" = "xARM"; then
|
||||
AC_DEFINE(TARGET_IOS,1,[The JIT/AOT targets iOS])
|
||||
@@ -3035,18 +3052,54 @@ if test ${TARGET} = ARM; then
|
||||
CPPFLAGS="$CPPFLAGS -DARM_FPU_$fpu=1"
|
||||
unset fpu
|
||||
|
||||
if test x$cross_compiling = xno; then
|
||||
AC_MSG_CHECKING(for ARMV6)
|
||||
AC_TRY_RUN([
|
||||
int main () { __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory"); return 0; }
|
||||
], armv6=yes, armv6=no)
|
||||
dnl *********************************************
|
||||
dnl *** Check which ARM version(s) we can use ***
|
||||
dnl *********************************************
|
||||
AC_MSG_CHECKING(which ARM version to use)
|
||||
|
||||
AC_MSG_RESULT($armv6)
|
||||
if test ${armv6} = yes; then
|
||||
AC_DEFINE(HAVE_ARMV6, 1, "Host supports ARMV6 instructions")
|
||||
# libgc's gc_locks.h depends on this
|
||||
CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DHAVE_ARMV6"
|
||||
fi
|
||||
AC_TRY_COMPILE([], [
|
||||
#if !defined(__ARM_ARCH_5T__) && !defined(__ARM_ARCH_5TE__) && !defined(__ARM_ARCH_5TEJ__)
|
||||
#error Not on ARM v5.
|
||||
#endif
|
||||
return 0;
|
||||
], [
|
||||
arm_v5=yes
|
||||
], [])
|
||||
|
||||
AC_TRY_COMPILE([], [
|
||||
#if !defined(__ARM_ARCH_6J__) && !defined(__ARM_ARCH_6ZK__) && !defined(__ARM_ARCH_6K__) && !defined(__ARM_ARCH_6T2__) && !defined(__ARM_ARCH_6M__)
|
||||
#error Not on ARM v6.
|
||||
#endif
|
||||
return 0;
|
||||
], [
|
||||
arm_v5=yes
|
||||
arm_v6=yes
|
||||
], [])
|
||||
|
||||
AC_TRY_COMPILE([], [
|
||||
#if !defined(__ARM_ARCH_7A__) && !defined(__ARM_ARCH_7R__) && !defined(__ARM_ARCH_7EM__) && !defined(__ARM_ARCH_7M__) && !defined(__ARM_ARCH_7S__)
|
||||
#error Not on ARM v7.
|
||||
#endif
|
||||
return 0;
|
||||
], [
|
||||
arm_v5=yes
|
||||
arm_v6=yes
|
||||
arm_v7=yes
|
||||
], [])
|
||||
|
||||
if test x$arm_v5 = xyes; then
|
||||
AC_DEFINE(HAVE_ARMV5, 1, [ARM v5])
|
||||
CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DHAVE_ARMV5=1"
|
||||
fi
|
||||
|
||||
if test x$arm_v6 = xyes; then
|
||||
AC_DEFINE(HAVE_ARMV6, 1, [ARM v6])
|
||||
CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DHAVE_ARMV6=1"
|
||||
fi
|
||||
|
||||
if test x$arm_v7 = xyes; then
|
||||
AC_DEFINE(HAVE_ARMV7, 1, [ARM v7])
|
||||
CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DHAVE_ARMV7=1"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -3217,12 +3270,11 @@ AM_CONDITIONAL(SPARC64, test x$TARGET = xSPARC64)
|
||||
AM_CONDITIONAL(X86, test x$TARGET = xX86)
|
||||
AM_CONDITIONAL(AMD64, test x$TARGET = xAMD64)
|
||||
AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
|
||||
AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
|
||||
AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS)
|
||||
AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
|
||||
AM_CONDITIONAL(POWERPC64, test x$TARGET = xPOWERPC64)
|
||||
AM_CONDITIONAL(ARM, test x$TARGET = xARM)
|
||||
AM_CONDITIONAL(S390x, test x$TARGET = xS390x)
|
||||
AM_CONDITIONAL(S390X, test x$TARGET = xS390X)
|
||||
AM_CONDITIONAL(HOST_X86, test x$HOST = xX86)
|
||||
AM_CONDITIONAL(HOST_AMD64, test x$HOST = xAMD64)
|
||||
AM_CONDITIONAL(HOST_ARM, test x$HOST = xARM)
|
||||
|
||||
@@ -156,7 +156,7 @@ g_get_current_dir (void)
|
||||
{
|
||||
#ifdef __native_client__
|
||||
char *buffer;
|
||||
if ((buffer = getenv("NACL_PWD"))) {
|
||||
if ((buffer = g_getenv("NACL_PWD"))) {
|
||||
buffer = g_strdup(buffer);
|
||||
} else {
|
||||
buffer = g_strdup(".");
|
||||
|
||||
@@ -61,6 +61,7 @@ int mkstemp (char *tmp_template)
|
||||
fd = _wopen( utf16_template, _O_BINARY | _O_CREAT /*| _O_TEMPORARY*/ | _O_EXCL, _S_IREAD | _S_IWRITE);
|
||||
}
|
||||
|
||||
/* FIXME: this will crash if utf16_template == NULL */
|
||||
sprintf (tmp_template + strlen (tmp_template) - 6, "%S", utf16_template + wcslen (utf16_template) - 6);
|
||||
|
||||
g_free (utf16_template);
|
||||
|
||||
+58
-28
@@ -174,14 +174,34 @@ gsize
|
||||
g_iconv (GIConv cd, gchar **inbytes, gsize *inbytesleft,
|
||||
gchar **outbytes, gsize *outbytesleft)
|
||||
{
|
||||
size_t inleft, outleft;
|
||||
gsize inleft, outleft;
|
||||
char *inptr, *outptr;
|
||||
gunichar c;
|
||||
int rc = 0;
|
||||
|
||||
#ifdef HAVE_ICONV
|
||||
if (cd->cd != (iconv_t) -1)
|
||||
return iconv (cd->cd, inbytes, inbytesleft, outbytes, outbytesleft);
|
||||
if (cd->cd != (iconv_t) -1) {
|
||||
/* Note: gsize may have a different size than size_t, so we need to
|
||||
remap inbytesleft and outbytesleft to size_t's. */
|
||||
size_t *outleftptr, *inleftptr;
|
||||
size_t n_outleft, n_inleft;
|
||||
|
||||
if (inbytesleft) {
|
||||
n_inleft = *inbytesleft;
|
||||
inleftptr = &n_inleft;
|
||||
} else {
|
||||
inleftptr = NULL;
|
||||
}
|
||||
|
||||
if (outbytesleft) {
|
||||
n_outleft = *outbytesleft;
|
||||
outleftptr = &n_outleft;
|
||||
} else {
|
||||
outleftptr = NULL;
|
||||
}
|
||||
|
||||
return iconv (cd->cd, inbytes, inleftptr, outbytes, outleftptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (outbytes == NULL || outbytesleft == NULL) {
|
||||
@@ -640,7 +660,7 @@ gchar *
|
||||
g_convert (const gchar *str, gssize len, const gchar *to_charset, const gchar *from_charset,
|
||||
gsize *bytes_read, gsize *bytes_written, GError **err)
|
||||
{
|
||||
size_t outsize, outused, outleft, inleft, grow, rc;
|
||||
gsize outsize, outused, outleft, inleft, grow, rc;
|
||||
char *result, *outbuf, *inbuf;
|
||||
gboolean flush = FALSE;
|
||||
gboolean done = FALSE;
|
||||
@@ -676,7 +696,7 @@ g_convert (const gchar *str, gssize len, const gchar *to_charset, const gchar *f
|
||||
else
|
||||
rc = g_iconv (cd, NULL, NULL, &outbuf, &outleft);
|
||||
|
||||
if (rc == (size_t) -1) {
|
||||
if (rc == (gsize) -1) {
|
||||
switch (errno) {
|
||||
case E2BIG:
|
||||
/* grow our result buffer */
|
||||
@@ -901,7 +921,7 @@ eg_utf8_to_utf16_general (const gchar *str, glong len, glong *items_read, glong
|
||||
size_t inleft;
|
||||
char *inptr;
|
||||
gunichar c;
|
||||
int n;
|
||||
int u, n;
|
||||
|
||||
g_return_val_if_fail (str != NULL, NULL);
|
||||
|
||||
@@ -910,6 +930,7 @@ eg_utf8_to_utf16_general (const gchar *str, glong len, glong *items_read, glong
|
||||
g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED, "Conversions with embedded nulls must pass the string length");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = strlen (str);
|
||||
}
|
||||
|
||||
@@ -917,29 +938,18 @@ eg_utf8_to_utf16_general (const gchar *str, glong len, glong *items_read, glong
|
||||
inleft = len;
|
||||
|
||||
while (inleft > 0) {
|
||||
if ((n = decode_utf8 (inptr, inleft, &c)) < 0) {
|
||||
if (errno == EILSEQ) {
|
||||
g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
|
||||
"Illegal byte sequence encounted in the input.");
|
||||
} else if (items_read) {
|
||||
/* partial input is ok if we can let our caller know... */
|
||||
break;
|
||||
} else {
|
||||
g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
|
||||
"Partial byte sequence encountered in the input.");
|
||||
}
|
||||
|
||||
if (items_read)
|
||||
*items_read = inptr - str;
|
||||
|
||||
if (items_written)
|
||||
*items_written = 0;
|
||||
|
||||
return NULL;
|
||||
} else if (c == 0 && !include_nuls)
|
||||
if ((n = decode_utf8 (inptr, inleft, &c)) < 0)
|
||||
goto error;
|
||||
|
||||
if (c == 0 && !include_nuls)
|
||||
break;
|
||||
|
||||
outlen += g_unichar_to_utf16 (c, NULL);
|
||||
if ((u = g_unichar_to_utf16 (c, NULL)) < 0) {
|
||||
errno = EILSEQ;
|
||||
goto error;
|
||||
}
|
||||
|
||||
outlen += u;
|
||||
inleft -= n;
|
||||
inptr += n;
|
||||
}
|
||||
@@ -957,7 +967,8 @@ eg_utf8_to_utf16_general (const gchar *str, glong len, glong *items_read, glong
|
||||
while (inleft > 0) {
|
||||
if ((n = decode_utf8 (inptr, inleft, &c)) < 0)
|
||||
break;
|
||||
else if (c == 0 && !include_nuls)
|
||||
|
||||
if (c == 0 && !include_nuls)
|
||||
break;
|
||||
|
||||
outptr += g_unichar_to_utf16 (c, outptr);
|
||||
@@ -968,6 +979,25 @@ eg_utf8_to_utf16_general (const gchar *str, glong len, glong *items_read, glong
|
||||
*outptr = '\0';
|
||||
|
||||
return outbuf;
|
||||
|
||||
error:
|
||||
if (errno == EILSEQ) {
|
||||
g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
|
||||
"Illegal byte sequence encounted in the input.");
|
||||
} else if (items_read) {
|
||||
/* partial input is ok if we can let our caller know... */
|
||||
} else {
|
||||
g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
|
||||
"Partial byte sequence encountered in the input.");
|
||||
}
|
||||
|
||||
if (items_read)
|
||||
*items_read = inptr - str;
|
||||
|
||||
if (items_written)
|
||||
*items_written = 0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gunichar2 *
|
||||
|
||||
@@ -141,6 +141,7 @@ g_module_error (void)
|
||||
TCHAR* buf = NULL;
|
||||
DWORD code = GetLastError ();
|
||||
|
||||
/* FIXME: buf must not be NULL! */
|
||||
FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL,
|
||||
code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 0, NULL);
|
||||
|
||||
|
||||
+1
-2
@@ -235,9 +235,8 @@ g_string_truncate (GString *string, gsize len)
|
||||
g_return_val_if_fail (string != NULL, string);
|
||||
|
||||
/* Silent return */
|
||||
if (len < 0 || len >= string->len) {
|
||||
if (len >= string->len)
|
||||
return string;
|
||||
}
|
||||
|
||||
string->len = len;
|
||||
string->str[len] = 0;
|
||||
|
||||
+1
-1
@@ -969,7 +969,7 @@ word n;
|
||||
}
|
||||
# endif
|
||||
expansion_slop = WORDS_TO_BYTES(min_words_allocd()) + 4*MAXHINCR*HBLKSIZE;
|
||||
if (GC_last_heap_addr == 0 && !((word)space & SIGNB)
|
||||
if ((GC_last_heap_addr == 0 && !((word)space & SIGNB))
|
||||
|| (GC_last_heap_addr != 0 && GC_last_heap_addr < (ptr_t)space)) {
|
||||
/* Assume the heap is growing up */
|
||||
GC_greatest_plausible_heap_addr =
|
||||
|
||||
@@ -231,46 +231,12 @@
|
||||
# define NACL_ALIGN()
|
||||
# endif
|
||||
inline static int GC_test_and_set(volatile unsigned int *addr) {
|
||||
#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7__)
|
||||
int ret, tmp;
|
||||
__asm__ __volatile__ (
|
||||
"1:\n"
|
||||
NACL_ALIGN()
|
||||
MASK_REGISTER("%3", "al")
|
||||
"ldrex %0, [%3]\n"
|
||||
MASK_REGISTER("%3", "al")
|
||||
"strex %1, %2, [%3]\n"
|
||||
"teq %1, #0\n"
|
||||
"bne 1b\n"
|
||||
: "=&r" (ret), "=&r" (tmp)
|
||||
: "r" (1), "r" (addr)
|
||||
: "memory", "cc");
|
||||
return ret;
|
||||
#else
|
||||
int oldval;
|
||||
/* SWP on ARM is very similar to XCHG on x86. Doesn't lock the
|
||||
* bus because there are no SMP ARM machines. If/when there are,
|
||||
* this code will likely need to be updated. */
|
||||
/* See linuxthreads/sysdeps/arm/pt-machine.h in glibc-2.1 */
|
||||
__asm__ __volatile__(MASK_REGISTER("%2", "al")
|
||||
"swp %0, %1, [%2]"
|
||||
: "=&r"(oldval)
|
||||
: "r"(1), "r"(addr)
|
||||
: "memory");
|
||||
return oldval;
|
||||
#endif
|
||||
return (int) __sync_lock_test_and_set (addr, 1);
|
||||
}
|
||||
# define GC_TEST_AND_SET_DEFINED
|
||||
inline static void GC_clear(volatile unsigned int *addr) {
|
||||
#ifdef HAVE_ARMV6
|
||||
/* Memory barrier */
|
||||
#ifdef __native_client__
|
||||
/* NaCl requires ARMv7 CPUs. */
|
||||
__asm__ __volatile__("dsb" : : : "memory");
|
||||
#else
|
||||
__asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory");
|
||||
#endif
|
||||
#endif
|
||||
__sync_synchronize ();
|
||||
|
||||
*(addr) = 0;
|
||||
}
|
||||
# define GC_CLEAR_DEFINED
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
# include "private/gc_priv.h"
|
||||
|
||||
map_entry_type * GC_invalid_map = 0;
|
||||
static max_valid_offset = 0;
|
||||
static word max_valid_offset = 0;
|
||||
|
||||
/* Invalidate the object map associated with a block. Free blocks */
|
||||
/* are identified by invalid maps. */
|
||||
|
||||
+1
-1
@@ -165,7 +165,7 @@ void (*GC_is_valid_displacement_print_proc) GC_PROTO((GC_PTR)) =
|
||||
pdispl = HBLKDISPL(p);
|
||||
map_entry = MAP_ENTRY((hhdr -> hb_map), pdispl);
|
||||
if (map_entry == OBJ_INVALID
|
||||
|| sz > MAXOBJBYTES && (ptr_t)p >= (ptr_t)h + sz) {
|
||||
|| (sz > MAXOBJBYTES && (ptr_t)p >= (ptr_t)h + sz)) {
|
||||
goto fail;
|
||||
}
|
||||
return(p);
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ gcc-mingw and as packages.
|
||||
Assembler command. The default is "as".
|
||||
.TP
|
||||
.I "CC"
|
||||
C compiler command. The default is "cc" under Linux and "gcc -mno-cygwin"
|
||||
C compiler command. The default is "cc" under Linux and "gcc"
|
||||
under Windows.
|
||||
.TP
|
||||
.I "MONO_BUNDLED_OPTIONS"
|
||||
|
||||
+5
-1
@@ -418,7 +418,7 @@ the global assembly cache is always trusted.
|
||||
.TP
|
||||
\fB--server\fR
|
||||
Configures the virtual machine to be better suited for server
|
||||
operations (currently, a no-op).
|
||||
operations (currently, allows a heavier threadpool initialization).
|
||||
.TP
|
||||
\fB--verify-all\fR
|
||||
Verifies mscorlib and assemblies in the global
|
||||
@@ -1628,6 +1628,10 @@ for example, to see managed frame names on gdb backtraces.
|
||||
Enables the maximum JIT verbosity for the specified method. This is
|
||||
very helpfull to diagnose a miscompilation problems of a specific
|
||||
method.
|
||||
.TP
|
||||
\fBMONO_VERBOSE_HWCAP\fR
|
||||
If set, makes the JIT output information about detected CPU features
|
||||
(such as SSE, CMOV, FCMOV, etc) to stdout.
|
||||
.SH VALGRIND
|
||||
If you want to use Valgrind, you will find the file `mono.supp'
|
||||
useful, it contains the suppressions for the GC which trigger
|
||||
|
||||
+14
-5
@@ -4,6 +4,7 @@ outfile=$1
|
||||
incfile=$2
|
||||
excfile=$3
|
||||
extfile=$4
|
||||
extexcfile=$5
|
||||
|
||||
process_includes_1() {
|
||||
sed -e '/^[ \t]*$/d' -e '/^[ \t]*#/d' $1 > $2
|
||||
@@ -39,16 +40,24 @@ fi
|
||||
sort -u $outfile.inc > $outfile.inc_s
|
||||
rm -f $outfile.inc
|
||||
|
||||
if test -z "$excfile"; then
|
||||
mv $outfile.inc_s $outfile
|
||||
else
|
||||
|
||||
if test -n "$excfile"; then
|
||||
process_includes $excfile $outfile.exc
|
||||
fi
|
||||
|
||||
sort -u $outfile.exc > $outfile.exc_s
|
||||
rm -f $outfile.exc
|
||||
if test -n "$extexcfile"; then
|
||||
process_includes $extexcfile $outfile.ext_exc
|
||||
cat $outfile.ext_exc >> $outfile.exc
|
||||
rm -f $outfile.ext_exc
|
||||
fi
|
||||
|
||||
if test -f $outfile.exc; then
|
||||
sort -u $outfile.exc > $outfile.exc_s
|
||||
rm -f $outfile.exc
|
||||
sort -m $outfile.inc_s $outfile.exc_s | uniq -u > $outfile
|
||||
rm -f $outfile.inc_s $outfile.exc_s
|
||||
else
|
||||
mv $outfile.inc_s $outfile
|
||||
fi
|
||||
|
||||
|
||||
@@ -23,11 +23,18 @@ else
|
||||
EXTENSION_include = $(wildcard $(PROFILE)_opt_$(LIBRARY).sources)
|
||||
endif
|
||||
|
||||
|
||||
ifdef EXTENSION_MODULE
|
||||
EXTENSION_exclude = $(wildcard $(topdir)/../../mono-extensions/mcs/$(thisdir)/$(PROFILE)_$(LIBRARY).exclude.sources)
|
||||
else
|
||||
EXTENSION_exclude = $(wildcard $(PROFILE)_opt_$(LIBRARY).exclude.sources)
|
||||
endif
|
||||
|
||||
# Note, gensources.sh can create a $(sourcefile).makefrag if it sees any '#include's
|
||||
# We don't include it in the dependencies since it isn't always created
|
||||
$(sourcefile): $(PROFILE_sources) $(PROFILE_excludes) $(topdir)/build/gensources.sh $(EXTENSION_include)
|
||||
@echo Creating the per profile list $@ ...
|
||||
$(SHELL) $(topdir)/build/gensources.sh $@ '$(PROFILE_sources)' '$(PROFILE_excludes)' '$(EXTENSION_include)'
|
||||
$(SHELL) $(topdir)/build/gensources.sh $@ '$(PROFILE_sources)' '$(PROFILE_excludes)' '$(EXTENSION_include)' '$(EXTENSION_exclude)'
|
||||
endif
|
||||
|
||||
PLATFORM_excludes := $(wildcard $(LIBRARY).$(PLATFORM)-excludes)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#! -*- makefile -*-
|
||||
|
||||
BOOTSTRAP_PROFILE = build
|
||||
|
||||
BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
|
||||
# Use system resgen as we don't want local System.Windows.Forms dependency
|
||||
RESGEN = resgen2
|
||||
|
||||
profile-check:
|
||||
@:
|
||||
|
||||
DEFAULT_REFERENCES = -r:mscorlib.dll
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:NET_3_5 -d:NET_4_0 -d:NET_4_5 -d:MOBILE -d:FULL_AOT_RUNTIME -d:DISABLE_REMOTING -d:DISABLE_COM -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS)
|
||||
FRAMEWORK_VERSION = 2.1
|
||||
NO_TEST = yes
|
||||
|
||||
# the tuner takes care of the install
|
||||
NO_INSTALL = yes
|
||||
@@ -12,9 +12,9 @@ profile-check:
|
||||
@:
|
||||
|
||||
DEFAULT_REFERENCES = -r:mscorlib.dll
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:NET_3_5 -d:NET_4_0 -d:NET_4_5 -d:MOBILE -d:MONOTOUCH -d:DISABLE_REMOTING -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS)
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:NET_3_5 -d:NET_4_0 -d:NET_4_5 -d:MOBILE -d:MONOTOUCH -d:DISABLE_REMOTING -d:DISABLE_COM -d:FULL_AOT_RUNTIME -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS)
|
||||
FRAMEWORK_VERSION = 2.1
|
||||
NO_TEST = yes
|
||||
|
||||
# the tuner takes care of the install
|
||||
NO_INSTALL = yes
|
||||
NO_INSTALL = yes
|
||||
@@ -14,9 +14,9 @@ profile-check:
|
||||
@:
|
||||
|
||||
DEFAULT_REFERENCES = -r:mscorlib.dll
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_0 -d:NET_3_5 -d:NET_4_0 -d:NET_4_5 -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS)
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:NET_3_5 -d:NET_4_0 -d:NET_4_5 -d:MOBILE -d:MONOTOUCH -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS)
|
||||
|
||||
FRAMEWORK_VERSION = 4.5
|
||||
FRAMEWORK_VERSION = 2.1
|
||||
|
||||
# This is utility build only
|
||||
NO_INSTALL = yes
|
||||
@@ -81,8 +81,10 @@ include $(topdir)/build/config-default.make
|
||||
|
||||
ifndef PLATFORM
|
||||
ifeq ($(OS),Windows_NT)
|
||||
$(info *** Assuming PLATFORM is 'win32'.)
|
||||
PLATFORM = win32
|
||||
else
|
||||
$(info *** Assuming PLATFORM is 'linux'.)
|
||||
PLATFORM = linux
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -29,4 +29,45 @@
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.IQueryable<>))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.IOrderedQueryable<>))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.IQueryProvider))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.Expression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.BinaryExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.ConditionalExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.ConstantExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.ElementInit))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.LambdaExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.Expression<>))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.ExpressionType))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.ExpressionVisitor))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.InvocationExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.ListInitExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.MemberBinding))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.MemberAssignment))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.MemberBindingType))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.MemberExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.MemberInitExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.MemberListBinding))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.MemberMemberBinding))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.MethodCallExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.NewArrayExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.NewExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.ParameterExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.TypeBinaryExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.UnaryExpression))]
|
||||
|
||||
#if !FULL_AOT_RUNTIME
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.BlockExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.CatchBlock))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.DebugInfoExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.DefaultExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.GotoExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.GotoExpressionKind))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.IndexExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.LabelExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.LabelTarget))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.LoopExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.RuntimeVariablesExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.SwitchCase))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.SwitchExpression))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.SymbolDocumentInfo))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Linq.Expressions.TryExpression))]
|
||||
#endif
|
||||
+3
-27
@@ -68,6 +68,7 @@ common_dirs := \
|
||||
Novell.Directory.Ldap \
|
||||
Mono.Security.Win32 \
|
||||
System.DirectoryServices \
|
||||
System.DirectoryServices.Protocols \
|
||||
RabbitMQ.Client \
|
||||
Mono.Messaging \
|
||||
System.Messaging \
|
||||
@@ -164,33 +165,7 @@ monodroid_dirs := \
|
||||
System.Net.Http
|
||||
|
||||
monotouch_runtime_dirs := \
|
||||
corlib \
|
||||
System \
|
||||
System.XML \
|
||||
Mono.Posix \
|
||||
System.Core \
|
||||
Mono.Security \
|
||||
System \
|
||||
System.Security \
|
||||
System.Configuration \
|
||||
System \
|
||||
System.XML \
|
||||
$(resgen_dir) \
|
||||
System.Drawing \
|
||||
System.Transactions \
|
||||
System.EnterpriseServices \
|
||||
Mono.Data.Tds \
|
||||
System.Data \
|
||||
Accessibility \
|
||||
Mono.WebBrowser \
|
||||
System.Runtime.Serialization.Formatters.Soap \
|
||||
Managed.Windows.Forms \
|
||||
Mono.Data.Sqlite \
|
||||
System.Web.ApplicationServices \
|
||||
System.Web \
|
||||
Mono.Web \
|
||||
System.Web.Services \
|
||||
System.Web
|
||||
corlib
|
||||
|
||||
net_3_5_only_dirs := \
|
||||
Microsoft.Build.Framework \
|
||||
@@ -257,6 +232,7 @@ net_2_0_SUBDIRS := $(common_dirs) $(net_2_0_dirs) $(net_2_0_only_dirs) aot-compi
|
||||
monodroid_SUBDIRS := $(mobile_dirs) $(monodroid_dirs)
|
||||
monotouch_SUBDIRS := $(mobile_dirs)
|
||||
monotouch_runtime_SUBDIRS := $(monotouch_runtime_dirs)
|
||||
mobile_static_SUBDIRS := $(mobile_dirs)
|
||||
mobile_SUBDIRS := $(mobile_dirs)
|
||||
net_3_5_SUBDIRS := $(net_3_5_only_dirs)
|
||||
net_4_0_SUBDIRS := $(common_dirs) $(net_2_0_dirs) $(net_4_0_dirs) $(net_4_0_only_dirs)
|
||||
|
||||
@@ -177,7 +177,7 @@ SWFresourcelist()
|
||||
{
|
||||
cat $Resource | while read SRC; do
|
||||
SRC=`echo $SRC | $tr '/' '\\\\'`
|
||||
SRC=`echo $SRC | sed 's/-resource://' | gawk -F , '{print " RelPath = \"" $1 "\"\n CustomToolNameSpace = \"" $2 "\""}' | fgrep -v \"\"`
|
||||
SRC=`echo $SRC | sed 's/-resource://' | awk -F , '{print " RelPath = \"" $1 "\"\n CustomToolNameSpace = \"" $2 "\""}' | fgrep -v \"\"`
|
||||
|
||||
cat << EOT
|
||||
<File
|
||||
|
||||
@@ -60,6 +60,8 @@ namespace Microsoft.Build.Tasks
|
||||
Log.LogWarning ("Unable to find framework corresponding to the target framework moniker '{0}'. " +
|
||||
"Framework assembly references will be resolved from the GAC, which might not be " +
|
||||
"the intended behavior.", TargetFrameworkMoniker);
|
||||
if (moniker.Identifier.Equals (".NETPortable"))
|
||||
return CheckPclReferenceAssemblies (moniker);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -69,6 +71,17 @@ namespace Microsoft.Build.Tasks
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CheckPclReferenceAssemblies (FrameworkMoniker moniker)
|
||||
{
|
||||
// Check for a supported profile
|
||||
var check = new FrameworkMoniker (".NETPortable", "v4.0", "Profile24");
|
||||
if (GetFrameworkDirectoriesForMoniker (check) != null)
|
||||
Log.LogError ("Unsupported PCL Profile '{0}'.", moniker);
|
||||
else
|
||||
Log.LogError ("PCL Reference Assemblies not installed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Framework GetFrameworkDirectoriesForMoniker (FrameworkMoniker moniker)
|
||||
{
|
||||
string dirs = String.Join (PathSeparatorAsString, new string [] {
|
||||
|
||||
@@ -59,3 +59,4 @@ using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: ComVisible (false)]
|
||||
|
||||
[assembly: InternalsVisibleTo ("PlayScript.Core, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
|
||||
+19
-2
@@ -41,9 +41,10 @@ namespace Microsoft.CSharp.RuntimeBinder
|
||||
IList<CSharpArgumentInfo> argumentInfo;
|
||||
readonly CSharpBinderFlags flags;
|
||||
readonly Type context;
|
||||
readonly ExpressionType operation;
|
||||
|
||||
public CSharpBinaryOperationBinder (ExpressionType operation, CSharpBinderFlags flags, Type context, IEnumerable<CSharpArgumentInfo> argumentInfo)
|
||||
: base (operation)
|
||||
: base (GetOperation (operation))
|
||||
{
|
||||
this.argumentInfo = new ReadOnlyCollectionBuilder<CSharpArgumentInfo> (argumentInfo);
|
||||
if (this.argumentInfo.Count != 2)
|
||||
@@ -51,12 +52,24 @@ namespace Microsoft.CSharp.RuntimeBinder
|
||||
|
||||
this.flags = flags;
|
||||
this.context = context;
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
static ExpressionType GetOperation (ExpressionType exprType)
|
||||
{
|
||||
switch (exprType) {
|
||||
case (ExpressionType) 0x80000:
|
||||
case (ExpressionType) 0x80001:
|
||||
return ExpressionType.Extension;
|
||||
default:
|
||||
return exprType;
|
||||
}
|
||||
}
|
||||
|
||||
Compiler.Binary.Operator GetOperator (out bool isCompound)
|
||||
{
|
||||
isCompound = false;
|
||||
switch (Operation) {
|
||||
switch (operation) {
|
||||
case ExpressionType.Add:
|
||||
return Compiler.Binary.Operator.Addition;
|
||||
case ExpressionType.AddAssign:
|
||||
@@ -123,6 +136,10 @@ namespace Microsoft.CSharp.RuntimeBinder
|
||||
case ExpressionType.SubtractAssign:
|
||||
isCompound = true;
|
||||
return Compiler.Binary.Operator.Subtraction;
|
||||
case (ExpressionType) 0x80000:
|
||||
return Compiler.Binary.Operator.StrictEquality;
|
||||
case (ExpressionType) 0x80001:
|
||||
return Compiler.Binary.Operator.StrictInequality;
|
||||
default:
|
||||
throw new NotImplementedException (Operation.ToString ());
|
||||
}
|
||||
|
||||
@@ -66,11 +66,14 @@ namespace Microsoft.CSharp.RuntimeBinder
|
||||
}
|
||||
|
||||
public DynamicMetaObject Bind (DynamicContext ctx, Type callingType)
|
||||
{
|
||||
return Bind (new Compiler.ResolveContext (new RuntimeBinderContext (ctx, callingType), ResolveOptions));
|
||||
}
|
||||
|
||||
public DynamicMetaObject Bind (Compiler.ResolveContext rc)
|
||||
{
|
||||
Expression res;
|
||||
try {
|
||||
var rc = new Compiler.ResolveContext (new RuntimeBinderContext (ctx, callingType), ResolveOptions);
|
||||
|
||||
// Static typemanager and internal caches are not thread-safe
|
||||
lock (resolver) {
|
||||
expr = expr.Resolve (rc, Compiler.ResolveFlags.VariableOrValue);
|
||||
|
||||
@@ -55,4 +55,7 @@
|
||||
../../build/common/Consts.cs
|
||||
../../tools/monop/outline.cs
|
||||
../../mcs/cs-parser.cs
|
||||
../../mcs/ps-parser.cs
|
||||
../../mcs/ps-tokenizer.cs
|
||||
../../mcs/playscript.cs
|
||||
Assembly/AssemblyInfo.cs
|
||||
@@ -139,5 +139,16 @@ namespace MonoTests.EvaluatorTest
|
||||
Evaluator.Run ("d.GetType ();");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NET_4_5
|
||||
[Test]
|
||||
public void AwaitExpression ()
|
||||
{
|
||||
Evaluator.WaitOnTask = true;
|
||||
var res = Evaluator.Evaluate("var res = await System.Threading.Tasks.Task.FromResult (1) + await System.Threading.Tasks.Task.FromResult (2);");
|
||||
res = Evaluator.Evaluate ("res;");
|
||||
Assert.AreEqual (3, res, "#1");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -193,6 +193,7 @@ public class Tests : TestsBase
|
||||
public AStruct field_struct;
|
||||
public object field_boxed_struct;
|
||||
public GStruct<int> generic_field_struct;
|
||||
public KeyValuePair<int, object> boxed_struct_field;
|
||||
[ThreadStatic]
|
||||
public static int tls_i;
|
||||
public static bool is_attached = Debugger.IsAttached;
|
||||
@@ -498,7 +499,7 @@ public class Tests : TestsBase
|
||||
}
|
||||
|
||||
public static void vtypes () {
|
||||
Tests t = new Tests () { field_struct = new AStruct () { i = 42, s = "S", k = 43 }, generic_field_struct = new GStruct<int> () { i = 42 }, field_boxed_struct = new AStruct () { i = 42 }};
|
||||
Tests t = new Tests () { field_struct = new AStruct () { i = 42, s = "S", k = 43 }, generic_field_struct = new GStruct<int> () { i = 42 }, field_boxed_struct = new AStruct () { i = 42 }, boxed_struct_field = new KeyValuePair<int, object> (1, (long)42 ) };
|
||||
AStruct s = new AStruct { i = 44, s = "T", k = 45 };
|
||||
AStruct[] arr = new AStruct[] {
|
||||
new AStruct () { i = 1, s = "S1" },
|
||||
|
||||
@@ -135,6 +135,16 @@ public class DebuggerTests
|
||||
return e;
|
||||
}
|
||||
|
||||
Event step_until (ThreadMirror t, string method_name) {
|
||||
Event e;
|
||||
while (true) {
|
||||
e = single_step (t);
|
||||
if ((e as StepEvent).Method.Name == method_name)
|
||||
break;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
void check_arg_val (StackFrame frame, int pos, Type type, object eval) {
|
||||
object val = frame.GetArgument (pos);
|
||||
Assert.IsTrue (val is PrimitiveValue);
|
||||
@@ -1325,6 +1335,17 @@ public class DebuggerTests
|
||||
Assert.AreEqual ("AStruct", s.Type.Name);
|
||||
AssertValue (42, s ["i"]);
|
||||
|
||||
// Check round tripping of boxed struct fields (#12354)
|
||||
obj = o.GetValue (o.Type.GetField ("boxed_struct_field"));
|
||||
o.SetValue (o.Type.GetField ("boxed_struct_field"), obj);
|
||||
obj = o.GetValue (o.Type.GetField ("boxed_struct_field"));
|
||||
s = obj as StructMirror;
|
||||
AssertValue (1, s ["key"]);
|
||||
obj = s ["value"];
|
||||
Assert.IsTrue (obj is StructMirror);
|
||||
s = obj as StructMirror;
|
||||
AssertValue (42, s ["m_value"]);
|
||||
|
||||
// vtypes as arguments
|
||||
s = frame.GetArgument (0) as StructMirror;
|
||||
AssertValue (44, s ["i"]);
|
||||
@@ -1361,11 +1382,7 @@ public class DebuggerTests
|
||||
|
||||
// this on vtype methods
|
||||
e = run_until ("vtypes2");
|
||||
|
||||
// Skip nop
|
||||
e = single_step (e.Thread);
|
||||
|
||||
e = single_step (e.Thread);
|
||||
e = step_until (e.Thread, "foo");
|
||||
|
||||
frame = e.Thread.GetFrames () [0];
|
||||
|
||||
@@ -1380,11 +1397,7 @@ public class DebuggerTests
|
||||
|
||||
// this on static vtype methods
|
||||
e = run_until ("vtypes3");
|
||||
|
||||
// Skip nop
|
||||
e = single_step (e.Thread);
|
||||
|
||||
e = single_step (e.Thread);
|
||||
e = step_until (e.Thread, "static_foo");
|
||||
|
||||
frame = e.Thread.GetFrames () [0];
|
||||
|
||||
@@ -1691,13 +1704,26 @@ public class DebuggerTests
|
||||
|
||||
Location l;
|
||||
|
||||
vm.Resume ();
|
||||
while (true) {
|
||||
vm.Resume ();
|
||||
|
||||
e = GetNextEvent ();
|
||||
Assert.IsTrue (e is StepEvent);
|
||||
if (e.Thread.GetFrames ()[0].Method.Name == "ln1")
|
||||
break;
|
||||
}
|
||||
|
||||
// Do an additional step over so we are not on the beginning line of the method
|
||||
step_req.Disable ();
|
||||
step_req.Depth = StepDepth.Over;
|
||||
step_req.Enable ();
|
||||
vm.Resume ();
|
||||
e = GetNextEvent ();
|
||||
Assert.IsTrue (e is StepEvent);
|
||||
Assert.IsTrue (e is StepEvent);
|
||||
|
||||
l = e.Thread.GetFrames ()[0].Location;
|
||||
|
||||
Console.WriteLine (l);
|
||||
Assert.AreEqual (3, l.ColumnNumber);
|
||||
|
||||
step_req.Disable ();
|
||||
|
||||
@@ -42,20 +42,7 @@ namespace Mono.Attach
|
||||
}
|
||||
|
||||
public string GetWorkingDirectory () {
|
||||
int len = 256;
|
||||
|
||||
while (true) {
|
||||
StringBuilder sb = new StringBuilder (len);
|
||||
|
||||
int res = Syscall.readlink ("/proc/" + pid + "/cwd", sb);
|
||||
if (res == -1)
|
||||
throw new IOException ("Syscall.readlink () failed with error " + res + ".");
|
||||
else if (res == len) {
|
||||
len = len * 2;
|
||||
} else {
|
||||
return sb.ToString ();
|
||||
}
|
||||
}
|
||||
return UnixPath.ReadLink ("/proc/" + pid + "/cwd");
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
Mono.Unix/ReadlinkTest.cs
|
||||
Mono.Unix/StdioFileStreamTest.cs
|
||||
Mono.Unix/UnixEncodingTest.cs
|
||||
Mono.Unix/UnixGroupTest.cs
|
||||
|
||||
@@ -3937,19 +3937,53 @@ namespace Mono.Unix.Native {
|
||||
[MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
|
||||
string newpath);
|
||||
|
||||
delegate long DoReadlinkFun (byte[] target);
|
||||
|
||||
// Helper function for readlink(string, StringBuilder) and readlinkat (int, string, StringBuilder)
|
||||
static int ReadlinkIntoStringBuilder (DoReadlinkFun doReadlink, [Out] StringBuilder buf, ulong bufsiz)
|
||||
{
|
||||
// bufsiz > int.MaxValue can't work because StringBuilder can store only int.MaxValue chars
|
||||
int bufsizInt = checked ((int) bufsiz);
|
||||
var target = new byte [bufsizInt];
|
||||
|
||||
var r = doReadlink (target);
|
||||
if (r < 0)
|
||||
return checked ((int) r);
|
||||
|
||||
buf.Length = 0;
|
||||
var chars = UnixEncoding.Instance.GetChars (target, 0, checked ((int) r));
|
||||
// Make sure that at more bufsiz chars are written
|
||||
buf.Append (chars, 0, System.Math.Min (bufsizInt, chars.Length));
|
||||
if (r == bufsizInt) {
|
||||
// may not have read full contents; fill 'buf' so that caller can properly check
|
||||
buf.Append (new string ('\x00', bufsizInt - buf.Length));
|
||||
}
|
||||
return buf.Length;
|
||||
}
|
||||
|
||||
// readlink(2)
|
||||
// int readlink(const char *path, char *buf, size_t bufsize);
|
||||
[DllImport (MPH, SetLastError=true,
|
||||
EntryPoint="Mono_Posix_Syscall_readlink")]
|
||||
public static extern int readlink (
|
||||
[MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
|
||||
string path, [Out] StringBuilder buf, ulong bufsiz);
|
||||
// ssize_t readlink(const char *path, char *buf, size_t bufsize);
|
||||
public static int readlink (string path, [Out] StringBuilder buf, ulong bufsiz)
|
||||
{
|
||||
return ReadlinkIntoStringBuilder (target => readlink (path, target), buf, bufsiz);
|
||||
}
|
||||
|
||||
public static int readlink (string path, [Out] StringBuilder buf)
|
||||
{
|
||||
return readlink (path, buf, (ulong) buf.Capacity);
|
||||
}
|
||||
|
||||
[DllImport (MPH, SetLastError=true,
|
||||
EntryPoint="Mono_Posix_Syscall_readlink")]
|
||||
private static extern long readlink (
|
||||
[MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
|
||||
string path, byte[] buf, ulong bufsiz);
|
||||
|
||||
public static long readlink (string path, byte[] buf)
|
||||
{
|
||||
return readlink (path, buf, (ulong) buf.LongLength);
|
||||
}
|
||||
|
||||
[DllImport (LIBC, SetLastError=true)]
|
||||
public static extern int unlink (
|
||||
[MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
|
||||
@@ -4226,18 +4260,28 @@ namespace Mono.Unix.Native {
|
||||
}
|
||||
|
||||
// readlinkat(2)
|
||||
// int readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsize);
|
||||
[DllImport (MPH, SetLastError=true,
|
||||
EntryPoint="Mono_Posix_Syscall_readlinkat")]
|
||||
public static extern int readlinkat (int dirfd,
|
||||
[MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
|
||||
string pathname, [Out] StringBuilder buf, ulong bufsiz);
|
||||
// ssize_t readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsize);
|
||||
public static int readlinkat (int dirfd, string pathname, [Out] StringBuilder buf, ulong bufsiz)
|
||||
{
|
||||
return ReadlinkIntoStringBuilder (target => readlinkat (dirfd, pathname, target), buf, bufsiz);
|
||||
}
|
||||
|
||||
public static int readlinkat (int dirfd, string pathname, [Out] StringBuilder buf)
|
||||
{
|
||||
return readlinkat (dirfd, pathname, buf, (ulong) buf.Capacity);
|
||||
}
|
||||
|
||||
[DllImport (MPH, SetLastError=true,
|
||||
EntryPoint="Mono_Posix_Syscall_readlinkat")]
|
||||
private static extern long readlinkat (int dirfd,
|
||||
[MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
|
||||
string pathname, byte[] buf, ulong bufsiz);
|
||||
|
||||
public static long readlinkat (int dirfd, string pathname, byte[] buf)
|
||||
{
|
||||
return readlinkat (dirfd, pathname, buf, (ulong) buf.LongLength);
|
||||
}
|
||||
|
||||
[DllImport (LIBC, SetLastError=true)]
|
||||
public static extern int symlinkat (
|
||||
[MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
|
||||
|
||||
@@ -209,69 +209,59 @@ namespace Mono.Unix {
|
||||
|
||||
// Read the specified symbolic link. If the file isn't a symbolic link,
|
||||
// return null; otherwise, return the contents of the symbolic link.
|
||||
//
|
||||
// readlink(2) is horribly evil, as there is no way to query how big the
|
||||
// symlink contents are. Consequently, it's trial and error...
|
||||
internal static string ReadSymbolicLink (string path)
|
||||
{
|
||||
StringBuilder buf = new StringBuilder (256);
|
||||
do {
|
||||
int r = Native.Syscall.readlink (path, buf);
|
||||
if (r < 0) {
|
||||
Native.Errno e;
|
||||
switch (e = Native.Stdlib.GetLastError()) {
|
||||
case Native.Errno.EINVAL:
|
||||
// path isn't a symbolic link
|
||||
return null;
|
||||
default:
|
||||
UnixMarshal.ThrowExceptionForError (e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (r == buf.Capacity) {
|
||||
buf.Capacity *= 2;
|
||||
}
|
||||
else
|
||||
return buf.ToString (0, r);
|
||||
} while (true);
|
||||
}
|
||||
|
||||
// Read the specified symbolic link. If the file isn't a symbolic link,
|
||||
// return null; otherwise, return the contents of the symbolic link.
|
||||
//
|
||||
// readlink(2) is horribly evil, as there is no way to query how big the
|
||||
// symlink contents are. Consequently, it's trial and error...
|
||||
private static string ReadSymbolicLink (string path, out Native.Errno errno)
|
||||
{
|
||||
errno = (Native.Errno) 0;
|
||||
StringBuilder buf = new StringBuilder (256);
|
||||
do {
|
||||
int r = Native.Syscall.readlink (path, buf);
|
||||
if (r < 0) {
|
||||
errno = Native.Stdlib.GetLastError ();
|
||||
return null;
|
||||
}
|
||||
else if (r == buf.Capacity) {
|
||||
buf.Capacity *= 2;
|
||||
}
|
||||
else
|
||||
return buf.ToString (0, r);
|
||||
} while (true);
|
||||
string target = TryReadLink (path);
|
||||
if (target == null) {
|
||||
Native.Errno errno = Native.Stdlib.GetLastError ();
|
||||
if (errno != Native.Errno.EINVAL)
|
||||
UnixMarshal.ThrowExceptionForError (errno);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
public static string TryReadLink (string path)
|
||||
{
|
||||
Native.Errno errno;
|
||||
return ReadSymbolicLink (path, out errno);
|
||||
byte[] buf = new byte[256];
|
||||
do {
|
||||
long r = Native.Syscall.readlink (path, buf);
|
||||
if (r < 0)
|
||||
return null;
|
||||
else if (r == buf.Length)
|
||||
buf = new byte[checked (buf.LongLength * 2)];
|
||||
else
|
||||
return UnixEncoding.Instance.GetString (buf, 0, checked ((int) r));
|
||||
} while (true);
|
||||
}
|
||||
|
||||
public static string TryReadLinkAt (int dirfd, string path)
|
||||
{
|
||||
byte[] buf = new byte[256];
|
||||
do {
|
||||
long r = Native.Syscall.readlinkat (dirfd, path, buf);
|
||||
if (r < 0)
|
||||
return null;
|
||||
else if (r == buf.Length)
|
||||
buf = new byte[checked (buf.LongLength * 2)];
|
||||
else
|
||||
return UnixEncoding.Instance.GetString (buf, 0, checked ((int) r));
|
||||
} while (true);
|
||||
}
|
||||
|
||||
public static string ReadLink (string path)
|
||||
{
|
||||
Native.Errno errno;
|
||||
path = ReadSymbolicLink (path, out errno);
|
||||
if (errno != 0)
|
||||
UnixMarshal.ThrowExceptionForError (errno);
|
||||
return path;
|
||||
string target = TryReadLink (path);
|
||||
if (target == null)
|
||||
UnixMarshal.ThrowExceptionForLastError ();
|
||||
return target;
|
||||
}
|
||||
|
||||
public static string ReadLinkAt (int dirfd, string path)
|
||||
{
|
||||
string target = TryReadLinkAt (dirfd, path);
|
||||
if (target == null)
|
||||
UnixMarshal.ThrowExceptionForLastError ();
|
||||
return target;
|
||||
}
|
||||
|
||||
public static bool IsPathRooted (string path)
|
||||
|
||||
@@ -56,19 +56,18 @@ namespace Mono.Unix {
|
||||
|
||||
public string ContentsPath {
|
||||
get {
|
||||
return ReadLink ();
|
||||
return UnixPath.ReadLink (FullPath);
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasContents {
|
||||
get {
|
||||
return TryReadLink () != null;
|
||||
return UnixPath.TryReadLink (FullPath) != null;
|
||||
}
|
||||
}
|
||||
|
||||
public UnixFileSystemInfo GetContents ()
|
||||
{
|
||||
ReadLink ();
|
||||
return UnixFileSystemInfo.GetFileSystemEntry (
|
||||
UnixPath.Combine (UnixPath.GetDirectoryName (FullPath),
|
||||
ContentsPath));
|
||||
@@ -103,23 +102,6 @@ namespace Mono.Unix {
|
||||
{
|
||||
return Native.Syscall.lstat (path, out stat) == 0;
|
||||
}
|
||||
|
||||
private string ReadLink ()
|
||||
{
|
||||
string r = TryReadLink ();
|
||||
if (r == null)
|
||||
UnixMarshal.ThrowExceptionForLastError ();
|
||||
return r;
|
||||
}
|
||||
|
||||
private string TryReadLink ()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ((int) base.Length+1);
|
||||
int r = Native.Syscall.readlink (FullPath, sb);
|
||||
if (r == -1)
|
||||
return null;
|
||||
return sb.ToString (0, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
//
|
||||
// readlink() / readlinkat() Test Cases
|
||||
//
|
||||
// Authors:
|
||||
// Steffen Kiess ([email protected])
|
||||
//
|
||||
// Copyright (C) 2013 Steffen Kiess
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
using Mono.Unix;
|
||||
using Mono.Unix.Native;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.Mono.Unix
|
||||
{
|
||||
[TestFixture, Category ("NotDotNet")]
|
||||
public class ReadlinkTest {
|
||||
|
||||
static string[] Targets = {
|
||||
// Simple test cases
|
||||
"a",
|
||||
"test",
|
||||
// With non-ASCII characters
|
||||
"ä",
|
||||
"test ö test",
|
||||
// With non-UTF8 bytes
|
||||
UnixEncoding.Instance.GetString (new byte[] {0xff, 0x80, 0x41, 0x80}),
|
||||
// Size is roughly initial size of buffer
|
||||
new string ('a', 255),
|
||||
new string ('a', 256),
|
||||
new string ('a', 257),
|
||||
// With non-ASCII characters, size is roughly initial size of buffer
|
||||
"ä" + new string ('a', 253), // 254 chars, 255 bytes
|
||||
"ä" + new string ('a', 254), // 255 chars, 256 bytes
|
||||
"ä" + new string ('a', 255), // 256 chars, 257 bytes
|
||||
"ä" + new string ('a', 256), // 257 chars, 258 bytes
|
||||
new string ('a', 253) + "ä", // 254 chars, 255 bytes
|
||||
new string ('a', 254) + "ä", // 255 chars, 256 bytes
|
||||
new string ('a', 255) + "ä", // 256 chars, 257 bytes
|
||||
new string ('a', 256) + "ä", // 257 chars, 258 bytes
|
||||
// With non-UTF8 bytes, size is roughly initial size of buffer
|
||||
"\0\u00ff" + new string ('a', 253), // 255 chars, 254 bytes
|
||||
"\0\u00ff" + new string ('a', 254), // 256 chars, 255 bytes
|
||||
"\0\u00ff" + new string ('a', 255), // 257 chars, 256 bytes
|
||||
"\0\u00ff" + new string ('a', 256), // 258 chars, 257 bytes
|
||||
new string ('a', 253) + "\0\u00ff", // 255 chars, 254 bytes
|
||||
new string ('a', 254) + "\0\u00ff", // 256 chars, 255 bytes
|
||||
new string ('a', 255) + "\0\u00ff", // 257 chars, 256 bytes
|
||||
new string ('a', 256) + "\0\u00ff", // 258 chars, 257 bytes
|
||||
};
|
||||
|
||||
bool HaveReadlinkAt;
|
||||
string TempFolder;
|
||||
int TempFD;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp ()
|
||||
{
|
||||
HaveReadlinkAt = false;
|
||||
try {
|
||||
Syscall.readlinkat (-1, "", new byte[1]);
|
||||
HaveReadlinkAt = true;
|
||||
} catch (EntryPointNotFoundException) {
|
||||
}
|
||||
|
||||
|
||||
TempFolder = Path.Combine (Path.GetTempPath (), this.GetType ().FullName);
|
||||
|
||||
if (Directory.Exists (TempFolder))
|
||||
//Directory.Delete (TempFolder, true); // Fails for long link target paths
|
||||
new UnixDirectoryInfo (TempFolder).Delete (true);
|
||||
|
||||
Directory.CreateDirectory (TempFolder);
|
||||
|
||||
TempFD = Syscall.open (TempFolder, OpenFlags.O_RDONLY | OpenFlags.O_DIRECTORY);
|
||||
if (TempFD < 0)
|
||||
UnixMarshal.ThrowExceptionForLastError ();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
if (Syscall.close (TempFD) < 0)
|
||||
UnixMarshal.ThrowExceptionForLastError ();
|
||||
|
||||
if (Directory.Exists (TempFolder))
|
||||
//Directory.Delete (TempFolder, true); // Fails for long link target paths
|
||||
new UnixDirectoryInfo (TempFolder).Delete (true);
|
||||
}
|
||||
|
||||
void CreateLink (string s)
|
||||
{
|
||||
string link = UnixPath.Combine (TempFolder, "link");
|
||||
|
||||
//File.Delete (link); // Fails for long link target paths
|
||||
if (Syscall.unlink (link) < 0 && Stdlib.GetLastError () != Errno.ENOENT)
|
||||
UnixMarshal.ThrowExceptionForLastError ();
|
||||
|
||||
if (Syscall.symlink (s, link) < 0)
|
||||
UnixMarshal.ThrowExceptionForLastError ();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadLink ()
|
||||
{
|
||||
foreach (string s in Targets) {
|
||||
string link = UnixPath.Combine (TempFolder, "link");
|
||||
|
||||
CreateLink (s);
|
||||
|
||||
var target = UnixPath.ReadLink (link);
|
||||
Assert.AreEqual (s, target);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadLinkAt ()
|
||||
{
|
||||
if (!HaveReadlinkAt)
|
||||
return;
|
||||
|
||||
foreach (string s in Targets) {
|
||||
CreateLink (s);
|
||||
|
||||
var target = UnixPath.ReadLinkAt (TempFD, "link");
|
||||
Assert.AreEqual (s, target);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TryReadLink ()
|
||||
{
|
||||
foreach (string s in Targets) {
|
||||
string link = UnixPath.Combine (TempFolder, "link");
|
||||
|
||||
CreateLink (s);
|
||||
|
||||
var target = UnixPath.TryReadLink (link);
|
||||
Assert.AreEqual (s, target);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TryReadLinkAt ()
|
||||
{
|
||||
if (!HaveReadlinkAt)
|
||||
return;
|
||||
|
||||
foreach (string s in Targets) {
|
||||
CreateLink (s);
|
||||
|
||||
var target = UnixPath.TryReadLinkAt (TempFD, "link");
|
||||
Assert.AreEqual (s, target);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void readlink_byte ()
|
||||
{
|
||||
foreach (string s in Targets) {
|
||||
string link = UnixPath.Combine (TempFolder, "link");
|
||||
|
||||
CreateLink (s);
|
||||
|
||||
string target = null;
|
||||
byte[] buf = new byte[256];
|
||||
do {
|
||||
long r = Syscall.readlink (link, buf);
|
||||
if (r < 0)
|
||||
UnixMarshal.ThrowExceptionForLastError ();
|
||||
Assert.GreaterOrEqual (buf.Length, r);
|
||||
if (r == buf.Length)
|
||||
buf = new byte[checked (buf.Length * 2)];
|
||||
else
|
||||
target = UnixEncoding.Instance.GetString (buf, 0, checked ((int) r));
|
||||
} while (target == null);
|
||||
|
||||
Assert.AreEqual (s, target);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void readlinkat_byte ()
|
||||
{
|
||||
if (!HaveReadlinkAt)
|
||||
return;
|
||||
|
||||
foreach (string s in Targets) {
|
||||
CreateLink (s);
|
||||
|
||||
string target = null;
|
||||
byte[] buf = new byte[256];
|
||||
do {
|
||||
long r = Syscall.readlinkat (TempFD, "link", buf);
|
||||
if (r < 0)
|
||||
UnixMarshal.ThrowExceptionForLastError ();
|
||||
Assert.GreaterOrEqual (buf.Length, r);
|
||||
if (r == buf.Length)
|
||||
buf = new byte[checked (buf.Length * 2)];
|
||||
else
|
||||
target = UnixEncoding.Instance.GetString (buf, 0, checked ((int) r));
|
||||
} while (target == null);
|
||||
|
||||
Assert.AreEqual (s, target);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void readlink_char ()
|
||||
{
|
||||
foreach (string s in Targets) {
|
||||
string link = UnixPath.Combine (TempFolder, "link");
|
||||
|
||||
CreateLink (s);
|
||||
|
||||
var sb = new StringBuilder (256);
|
||||
do {
|
||||
int oldCapacity = sb.Capacity;
|
||||
int r = Syscall.readlink (link, sb);
|
||||
Assert.AreEqual (oldCapacity, sb.Capacity);
|
||||
if (r < 0)
|
||||
UnixMarshal.ThrowExceptionForLastError ();
|
||||
Assert.AreEqual (r, sb.Length);
|
||||
Assert.GreaterOrEqual (sb.Capacity, r);
|
||||
if (r == sb.Capacity)
|
||||
checked { sb.Capacity *= 2; }
|
||||
else
|
||||
break;
|
||||
} while (true);
|
||||
var target = sb.ToString ();
|
||||
|
||||
Assert.AreEqual (s, target);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void readlinkat_char ()
|
||||
{
|
||||
if (!HaveReadlinkAt)
|
||||
return;
|
||||
|
||||
foreach (string s in Targets) {
|
||||
CreateLink (s);
|
||||
|
||||
var sb = new StringBuilder (256);
|
||||
do {
|
||||
int oldCapacity = sb.Capacity;
|
||||
int r = Syscall.readlinkat (TempFD, "link", sb);
|
||||
Assert.AreEqual (oldCapacity, sb.Capacity);
|
||||
if (r < 0)
|
||||
UnixMarshal.ThrowExceptionForLastError ();
|
||||
Assert.AreEqual (r, sb.Length);
|
||||
Assert.GreaterOrEqual (sb.Capacity, r);
|
||||
if (r == sb.Capacity)
|
||||
checked { sb.Capacity *= 2; }
|
||||
else
|
||||
break;
|
||||
} while (true);
|
||||
var target = sb.ToString ();
|
||||
|
||||
Assert.AreEqual (s, target);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadlinkMultiByteChar ()
|
||||
{
|
||||
string link = UnixPath.Combine (TempFolder, "link");
|
||||
|
||||
CreateLink ("á");
|
||||
|
||||
var sb = new StringBuilder (2);
|
||||
int res = Syscall.readlink (link, sb);
|
||||
if (res < 0)
|
||||
UnixMarshal.ThrowExceptionForLastError ();
|
||||
|
||||
Assert.AreEqual (res, 2);
|
||||
Assert.AreEqual (sb.Length, 2);
|
||||
Assert.AreEqual (sb.Capacity, 2);
|
||||
Assert.AreEqual (sb.ToString (), "á\u0000");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class ArgumentError extends Error {
|
||||
|
||||
public function ArgumentError(message:String = "") {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
//
|
||||
// Array.play
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
package {
|
||||
public dynamic class Array
|
||||
{
|
||||
public static const CASEINSENSITIVE:uint = 1;
|
||||
public static const DESCENDING:uint = 2;
|
||||
public static const UNIQUESORT:uint = 4;
|
||||
public static const RETURNINDEXEDARRAY:uint = 8;
|
||||
public static const NUMERIC:uint = 16;
|
||||
|
||||
private static const DELETED:Object = new Object ();
|
||||
|
||||
var vector:Vector.<Object>;
|
||||
|
||||
public function Array (numElements:int = 0)
|
||||
{
|
||||
vector = new Vector.<Object> (numElements);
|
||||
}
|
||||
|
||||
public function Array (...rest)
|
||||
{
|
||||
vector = new Vector.<Object> (rest);
|
||||
}
|
||||
|
||||
public function get length ():uint
|
||||
{
|
||||
return vector.length;
|
||||
}
|
||||
|
||||
public function set length (value:uint):void
|
||||
{
|
||||
vector.length = value;
|
||||
}
|
||||
|
||||
// TODO:
|
||||
//public function push (...rest):uint
|
||||
//{
|
||||
// throw new System.NotImplementedException ();
|
||||
// // TODO: return vector.push (rest);
|
||||
//}
|
||||
|
||||
|
||||
public function splice (startIndex:int = 0, deleteCount:uint = 4294967295 /*uint.MAX_VALUE*/, ...values):Array
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
|
||||
//
|
||||
// Extensions to AS3
|
||||
//
|
||||
public function push (value:Object):uint
|
||||
{
|
||||
return vector.push (value);
|
||||
}
|
||||
|
||||
internal function setValue (index:uint, value:Object):void
|
||||
{
|
||||
if (index < 0)
|
||||
throw new System.NotImplementedException (); // TODO: Allowed but how to handle
|
||||
|
||||
//
|
||||
// Assigning out of array range
|
||||
//
|
||||
if (index >= vector.length) {
|
||||
// while (length < index - 1)
|
||||
// list.Add (default (T)); // TODO: Need better "invisible" value, perhaps DELETED would work ?
|
||||
|
||||
vector.push (value);
|
||||
return;
|
||||
}
|
||||
|
||||
vector.setValue (index, value);
|
||||
}
|
||||
|
||||
internal function getValue (index:uint):*
|
||||
{
|
||||
if (index < 0 || index > vector.length)
|
||||
return undefined;
|
||||
|
||||
return vector.getValue (index);
|
||||
}
|
||||
|
||||
internal function deleteValue (index:uint):void
|
||||
{
|
||||
setValue (index, DELETED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// AssemblyInfo.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar ([email protected])
|
||||
//
|
||||
// Copyright 2013 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about the assembly
|
||||
|
||||
[assembly: AssemblyTitle ("PlayScript.Core.dll")]
|
||||
[assembly: AssemblyDescription ("PlayScript.Core.dll")]
|
||||
[assembly: AssemblyDefaultAlias ("PlayScript.Core.dll")]
|
||||
|
||||
[assembly: AssemblyCompany (Consts.MonoCompany)]
|
||||
[assembly: AssemblyProduct (Consts.MonoProduct)]
|
||||
[assembly: AssemblyCopyright (Consts.MonoCopyright)]
|
||||
[assembly: AssemblyVersion (Consts.FxVersion)]
|
||||
[assembly: SatelliteContractVersion (Consts.FxVersion)]
|
||||
[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
|
||||
[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
|
||||
|
||||
[assembly: NeutralResourcesLanguage ("en-US")]
|
||||
[assembly: CLSCompliant (false)]
|
||||
|
||||
[assembly: ComVisible (false)]
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
public static class Boolean
|
||||
{
|
||||
public static string toString(this bool b) {
|
||||
return b ? "true" : "false";
|
||||
}
|
||||
|
||||
public static bool valueOf(this bool b) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Date.play
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
package {
|
||||
public final dynamic class Date
|
||||
{
|
||||
public function Date (yearOrTimevalue:Object = null, month:Number = 1, date:Number = 1, hour:Number = 0, minute:Number = 0, second:Number = 0, millisecond:Number = 0)
|
||||
{
|
||||
}
|
||||
|
||||
public static function UTC (year:Number, month:Number, date:Number = 1, hour:Number = 0, minute:Number = 0, second:Number = 0, millisecond:Number = 0):Number
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class DefinitionError extends Error {
|
||||
|
||||
public function DefinitionError(message:String = "") {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
|
||||
public class DeprecatedAttribute : Attribute
|
||||
{
|
||||
public DeprecatedAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
public string message {get;set;}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
|
||||
public class EmbedAttribute : Attribute
|
||||
{
|
||||
public string source { get; set; }
|
||||
|
||||
public string mimeType { get; set; }
|
||||
|
||||
public string embedAsCFF { get; set; }
|
||||
|
||||
public string fontFamily { get; set; }
|
||||
|
||||
public string symbol { get; set; }
|
||||
|
||||
public EmbedAttribute (string _source = null)
|
||||
{
|
||||
source = _source;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
//
|
||||
// Error.play
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright 2013 Zynga Inc.
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
package {
|
||||
|
||||
public dynamic class Error extends System.Exception
|
||||
{
|
||||
private var error_id : int;
|
||||
|
||||
public function Error (message:String = "", id:int = 0)
|
||||
{
|
||||
super (message);
|
||||
error_id = id;
|
||||
}
|
||||
|
||||
public function get errorID () : int
|
||||
{
|
||||
return error_id;
|
||||
}
|
||||
|
||||
public function get message () : String
|
||||
{
|
||||
return Message;
|
||||
}
|
||||
|
||||
public function set message (value:String): void
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function get name () : String
|
||||
{
|
||||
return GetType().Name;
|
||||
}
|
||||
|
||||
public function set name (value:String): void
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function getStackTrace () : String
|
||||
{
|
||||
return StackTrace;
|
||||
}
|
||||
|
||||
public static function getErrorMessage (index:int) : String
|
||||
{
|
||||
// TODO: Finish all error messages
|
||||
var msg:String;
|
||||
switch (index) {
|
||||
case 1000:
|
||||
msg = "The system is out of memory.";
|
||||
break;
|
||||
case 1001:
|
||||
msg = "The method {0} is not implemented.";
|
||||
break;
|
||||
case 1002:
|
||||
msg = "Number.toPrecision has a range of 1 to 21. Number.toFixed and Number.toExponential have a range of 0 to 20. Specified value is not within expected range.";
|
||||
break;
|
||||
case 1007:
|
||||
msg = "Instantiation attempted on a non-constructor.";
|
||||
break;
|
||||
case 1009:
|
||||
msg = "Cannot access a property or method of a null object reference.";
|
||||
break;
|
||||
}
|
||||
|
||||
if (msg == null)
|
||||
return System.String.Format ("#{0}", index);
|
||||
|
||||
return System.String.Format ("#{0}: {1}", index, msg);
|
||||
}
|
||||
|
||||
public static function throwError (type:Class, index:uint, ...rest) : *
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
|
||||
public class EventAttribute : Attribute
|
||||
{
|
||||
public string name { get; set; }
|
||||
|
||||
public string type { get; set; }
|
||||
|
||||
public EventAttribute ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
// public static string toString(this object o)
|
||||
// {
|
||||
// return o.ToString ();
|
||||
// }
|
||||
|
||||
public static string toLocaleString(this object o)
|
||||
{
|
||||
return o.ToString ();
|
||||
}
|
||||
|
||||
public static bool hasOwnProperty(this object o, string name)
|
||||
{
|
||||
var t = o.GetType ();
|
||||
return t.GetProperty(name) != null || t.GetField(name) != null;
|
||||
}
|
||||
|
||||
public static string toString(this uint o, int radix = 10)
|
||||
{
|
||||
return Convert.ToString (o, radix);
|
||||
}
|
||||
|
||||
//
|
||||
// IList extensions (for arrays, etc).
|
||||
//
|
||||
|
||||
// public static int get_length(this IList list)
|
||||
// {
|
||||
// return list.Count;
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// FunctionExtensions.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright 2013 Zynga Inc.
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace _root {
|
||||
|
||||
public static class FunctionExtensions {
|
||||
|
||||
public static dynamic apply (this Delegate d, object thisArg = null, Array argArray = null)
|
||||
{
|
||||
return d.DynamicInvoke (argArray != null ? argArray.ToArray() : null);
|
||||
}
|
||||
|
||||
public static dynamic call (this Delegate d, object thisArg = null, params object[] rest)
|
||||
{
|
||||
return d.DynamicInvoke (rest);
|
||||
}
|
||||
|
||||
// this returns the number of arguments to the delegate method
|
||||
//public static int get_length(this Delegate d) {
|
||||
// return d.Method.GetParameters().Length;
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class JSON {
|
||||
|
||||
public static function parse(text:String, reviver:Function = null):Object {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public static function stringify(value:Object, replacer:* = null, space:* = null):String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
thisdir = class/PlayScript.Core
|
||||
include ../../build/rules.make
|
||||
|
||||
LIBRARY = PlayScript.Core.dll
|
||||
LIBRARY_SNK = ../mono.snk
|
||||
LIBRARY_PACKAGE = none
|
||||
|
||||
LIB_MCS_FLAGS = -d:DYNAMIC_SUPPORT -keyfile:$(LIBRARY_SNK) -delaysign -r:System.dll -r:System.Core.dll -r:System.Xml.dll -r:Microsoft.CSharp.dll -r:Mono.CSharp.dll
|
||||
|
||||
NO_TEST = yes
|
||||
|
||||
include ../../build/library.make
|
||||
@@ -0,0 +1,127 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class Math {
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
public static const E : Number = 2.71828182845905;
|
||||
|
||||
public static const LN10 : Number = 2.302585092994046;
|
||||
|
||||
public static const LN2 : Number = 0.6931471805599453;
|
||||
|
||||
public static const LOG10E : Number = 0.4342944819032518;
|
||||
|
||||
public static const LOG2E : Number = 1.442695040888963387;
|
||||
|
||||
public static const PI : Number = 3.141592653589793;
|
||||
|
||||
public static const SQRT1_2 : Number = 0.7071067811865476;
|
||||
|
||||
public static const SQRT2 : Number = 1.4142135623730951;
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
public static function abs(val:Number):Number {
|
||||
return System.Math.Abs(val);
|
||||
}
|
||||
|
||||
public static function acos(val:Number):Number {
|
||||
return System.Math.Acos(val);
|
||||
}
|
||||
|
||||
public static function asin(val:Number):Number {
|
||||
return System.Math.Asin(val);
|
||||
}
|
||||
|
||||
public static function atan(val:Number):Number {
|
||||
return System.Math.Atan(val);
|
||||
}
|
||||
|
||||
public static function atan2(y:Number, x:Number):Number {
|
||||
return System.Math.Atan2(y, x);
|
||||
}
|
||||
|
||||
public static function ceil(val:Number):Number {
|
||||
return System.Math.Ceiling(val);
|
||||
}
|
||||
|
||||
public static function cos(angleRadians:Number):Number {
|
||||
return System.Math.Cos(angleRadians);
|
||||
}
|
||||
|
||||
public static function exp(val:Number):Number {
|
||||
return System.Math.Exp(val);
|
||||
}
|
||||
|
||||
public static function floor(val:Number):Number {
|
||||
return System.Math.Floor(val);
|
||||
}
|
||||
|
||||
public static function log(val:Number):Number {
|
||||
return System.Math.Log(val);
|
||||
}
|
||||
|
||||
public static function max(val1:Number, val2:Number):Number {
|
||||
return System.Math.Max(val1, val2);
|
||||
}
|
||||
|
||||
public static function max(val1:Number, val2:Number, ... rest):Number {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public static function min(val1:Number, val2:Number):Number {
|
||||
return System.Math.Min(val1, val2);
|
||||
}
|
||||
|
||||
public static function min(val1:Number, val2:Number, ... rest):Number {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public static function pow(base:Number, pow:Number):Number {
|
||||
return System.Math.Pow(base, pow);
|
||||
}
|
||||
|
||||
private static var sRandom:System.Random = new System.Random();
|
||||
|
||||
public static function random():Number {
|
||||
return sRandom.NextDouble();
|
||||
}
|
||||
|
||||
public static function round(val:Number):Number {
|
||||
return System.Math.Round(val);
|
||||
}
|
||||
|
||||
public static function sin(angleRadians:Number):Number {
|
||||
return System.Math.Sin(angleRadians);
|
||||
}
|
||||
|
||||
public static function sqrt(val:Number):Number {
|
||||
return System.Math.Sqrt(val);
|
||||
}
|
||||
|
||||
public static function tan(angleRadians:Number):Number {
|
||||
return System.Math.Tan(angleRadians);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// Namespace.play
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright 2013 Zynga Inc.
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public final class Namespace
|
||||
{
|
||||
private var prefix_value:String;
|
||||
private var uri_value:String;
|
||||
|
||||
public function Namespace (prefix:*=null, uri:*=null)
|
||||
{
|
||||
prefix_value = prefix;
|
||||
uri_value = uri;
|
||||
}
|
||||
|
||||
//
|
||||
// Properties
|
||||
//
|
||||
public function get prefix () : String
|
||||
{
|
||||
return prefix_value;
|
||||
}
|
||||
|
||||
public function get uri () : String
|
||||
{
|
||||
return uri_value;
|
||||
}
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
public function toString ():String
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function valueOf ():Object
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
namespace _root {
|
||||
|
||||
public static class Number {
|
||||
|
||||
//
|
||||
// Extension Methods
|
||||
//
|
||||
|
||||
public static string toExponential(this double d, uint fractionDigits) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public static string toFixed(this double d, uint fractionDigits) {
|
||||
return d.ToString ( "F" + fractionDigits.ToString() );
|
||||
}
|
||||
|
||||
public static string toPrecision(this double d, uint precision) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public static string toString(this double d) {
|
||||
return d.ToString();
|
||||
}
|
||||
|
||||
public static string toString(this double d, double radix) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public static double valueOf(this double d) {
|
||||
return d;
|
||||
}
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
public const double MAX_VALUE = System.Double.MaxValue;
|
||||
|
||||
public const double MIN_VALUE = System.Double.MinValue;
|
||||
|
||||
public const double @NaN = System.Double.NaN;
|
||||
|
||||
public const double NEGATIVE_INFINITY = System.Double.NegativeInfinity;
|
||||
|
||||
public const double POSITIVE_INFINITY = System.Double.PositiveInfinity;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
../../build/common/Consts.cs
|
||||
./Assembly/AssemblyInfo.cs
|
||||
./Array.play
|
||||
./Boolean.cs
|
||||
./Date.play
|
||||
./DeprecatedAttribute.cs
|
||||
./EmbedAttribute.cs
|
||||
./EventAttribute.cs
|
||||
./Extensions.cs
|
||||
./FunctionExtensions.cs
|
||||
./functions.cs
|
||||
./int.cs
|
||||
./Number.cs
|
||||
./StringExtensions.cs
|
||||
./ArgumentError.play
|
||||
./DefinitionError.play
|
||||
./Error.play
|
||||
./JSON.play
|
||||
./Math.play
|
||||
./Namespace.play
|
||||
./QName.play
|
||||
./RangeError.play
|
||||
./ReferenceError.play
|
||||
./RegExp.play
|
||||
./SecurityError.play
|
||||
./SyntaxError.play
|
||||
./SWFAttribute.cs
|
||||
./toplevel.play
|
||||
./TypeError.play
|
||||
./URIError.play
|
||||
./Vector.cs
|
||||
./VerifyError.play
|
||||
./XML.play
|
||||
./XMLList.play
|
||||
|
||||
./PlayScript.Runtime/BinaryOperator.cs
|
||||
./PlayScript.Runtime/Binder.cs
|
||||
./PlayScript.Runtime/DefaultObjectContext.cs
|
||||
./PlayScript.Runtime/IsPropertyBinder.cs
|
||||
./PlayScript.Runtime/PlayScriptGetMemberBinder.cs
|
||||
./PlayScript.Runtime/Operations.cs
|
||||
./PlayScript.Runtime/Undefined.cs
|
||||
./PlayScript.Runtime.CompilerServices/ConstantFieldAttribute.cs
|
||||
./PlayScript.Runtime.CompilerServices/DynamicClassAttribute.cs
|
||||
./PlayScript.Runtime.CompilerServices/NamespaceFieldAttribute.cs
|
||||
./PlayScript.Runtime.CompilerServices/PlayScriptAttribute.cs
|
||||
./PlayScript.Runtime.CompilerServices/RestArrayParameterAttribute.cs
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// ConstantFieldAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace PlayScript.Runtime.CompilerServices
|
||||
{
|
||||
[AttributeUsage (AttributeTargets.Field)]
|
||||
public sealed class ConstantFieldAttribute : Attribute
|
||||
{
|
||||
public ConstantFieldAttribute ()
|
||||
{
|
||||
}
|
||||
|
||||
public ConstantFieldAttribute (object value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public object Value { get; private set; }
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// DynamicClassAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace PlayScript.Runtime.CompilerServices
|
||||
{
|
||||
[AttributeUsage (AttributeTargets.Class)]
|
||||
public sealed class DynamicClassAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// NamespaceFieldAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace PlayScript.Runtime.CompilerServices
|
||||
{
|
||||
[AttributeUsage (AttributeTargets.Field)]
|
||||
public sealed class NamespaceFieldAttribute : Attribute
|
||||
{
|
||||
public NamespaceFieldAttribute (string uri)
|
||||
{
|
||||
Uri = uri;
|
||||
}
|
||||
|
||||
public string Uri { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// PlayScriptAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace PlayScript.Runtime.CompilerServices
|
||||
{
|
||||
[AttributeUsage (AttributeTargets.Class)]
|
||||
public sealed class PlayScriptAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// RestArrayAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace PlayScript.Runtime.CompilerServices
|
||||
{
|
||||
[AttributeUsage (AttributeTargets.Parameter)]
|
||||
public sealed class RestArrayParameterAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// BinaryOperator.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
namespace PlayScript.Runtime
|
||||
{
|
||||
public enum BinaryOperator
|
||||
{
|
||||
Multiply = 1,
|
||||
Division = 2,
|
||||
Modulus = 3,
|
||||
Addition = 4,
|
||||
Subtraction = 5,
|
||||
|
||||
LeftShift = 10,
|
||||
RightShift = 11,
|
||||
UnsignedRightShift = 12,
|
||||
|
||||
LessThan = 20,
|
||||
GreaterThan = 21,
|
||||
LessThanOrEqual = 22,
|
||||
GreaterThanOrEqual = 23,
|
||||
Equality = 24,
|
||||
Inequality = 25,
|
||||
|
||||
BitwiseAnd = 30,
|
||||
ExclusiveOr = 31,
|
||||
BitwiseOr = 32,
|
||||
|
||||
LogicalAnd = 40,
|
||||
LogicalOr = 41,
|
||||
|
||||
StrictEquality = 50 | StrictMask,
|
||||
StrictInequality = 51 | StrictMask,
|
||||
|
||||
StrictMask = 1 >> 16
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
//
|
||||
// Binder.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using System.Globalization;
|
||||
|
||||
namespace PlayScript.Runtime
|
||||
{
|
||||
public static class Binder
|
||||
{
|
||||
static readonly ConditionalWeakTable<object, ConcurrentDictionary<string, object>> dynamic_classes = new ConditionalWeakTable<object, ConcurrentDictionary<string, object>> ();
|
||||
|
||||
public static dynamic GetMember (object instance, Type context, object name)
|
||||
{
|
||||
if (instance == null)
|
||||
throw GetNullObjectReferenceException ();
|
||||
|
||||
//
|
||||
// Use index getter when name can be converted to number on array instances
|
||||
//
|
||||
var array = instance as _root.Array;
|
||||
if (array != null) {
|
||||
var index = GetArrayIndex (name);
|
||||
if (index != null) {
|
||||
return array.getValue (index.Value);
|
||||
}
|
||||
}
|
||||
|
||||
var sname = GetName (name);
|
||||
|
||||
ConcurrentDictionary<string, object> members;
|
||||
if (dynamic_classes.TryGetValue (instance, out members)) {
|
||||
object value;
|
||||
if (members.TryGetValue (sname, out value))
|
||||
return value;
|
||||
}
|
||||
|
||||
var binder = Microsoft.CSharp.RuntimeBinder.Binder.GetMember (CSharpBinderFlags.None, sname, context, new[] { CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null) });
|
||||
var callsite = CallSite<Func<CallSite, object, object>>.Create (binder);
|
||||
|
||||
// TODO: Add caching to avoid expensive Resolve
|
||||
return callsite.Target (callsite, instance);
|
||||
}
|
||||
|
||||
public static CallSiteBinder GetMember (string name, Type context, DefaultObjectContext objectContext)
|
||||
{
|
||||
return new PlayScriptGetMemberBinder (name, context, objectContext);
|
||||
}
|
||||
|
||||
public static void SetMember (object instance, Type context, object name, object value)
|
||||
{
|
||||
if (instance == null)
|
||||
throw GetNullObjectReferenceException ();
|
||||
|
||||
//
|
||||
// Use index setter when name can be converted to number on array instances
|
||||
//
|
||||
var array = instance as _root.Array;
|
||||
if (array != null) {
|
||||
var index = GetArrayIndex (name);
|
||||
if (index != null) {
|
||||
array.setValue (index.Value, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var sname = GetName (name);
|
||||
|
||||
var binder = Microsoft.CSharp.RuntimeBinder.Binder.SetMember (CSharpBinderFlags.None, sname, context,
|
||||
new[] { CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null) });
|
||||
var callsite = CallSite<Func<CallSite, object, object, object>>.Create (binder);
|
||||
|
||||
// TODO: Better handling
|
||||
try {
|
||||
// TODO: Add caching to avoid expensive Resolve
|
||||
callsite.Target (callsite, instance, value);
|
||||
} catch (RuntimeBinderException) {
|
||||
var members = dynamic_classes.GetOrCreateValue (instance);
|
||||
|
||||
// TODO: Not thread safe
|
||||
members[sname] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<string> GetKeys (object instance)
|
||||
{
|
||||
if (instance == null)
|
||||
return new string [0];
|
||||
|
||||
//
|
||||
// Array's are different
|
||||
//
|
||||
var array = instance as _root.Array;
|
||||
if (array != null) {
|
||||
return CreateArrayKeysIterator (array.length);
|
||||
}
|
||||
|
||||
ConcurrentDictionary<string, object> members;
|
||||
if (dynamic_classes.TryGetValue (instance, out members)) {
|
||||
return CreateMemberKeysIterator (members.Keys);
|
||||
}
|
||||
|
||||
return new string [0];
|
||||
}
|
||||
|
||||
static IEnumerable<string> CreateArrayKeysIterator (uint length)
|
||||
{
|
||||
for (uint i = 0; i < length; ++i)
|
||||
yield return i.ToString (CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
static IEnumerable<string> CreateMemberKeysIterator (ICollection<string> keys)
|
||||
{
|
||||
foreach (var key in keys)
|
||||
yield return key;
|
||||
}
|
||||
|
||||
public static IEnumerable<dynamic> GetValues (object instance)
|
||||
{
|
||||
if (instance == null)
|
||||
return new dynamic [0];
|
||||
|
||||
//
|
||||
// Array's are different
|
||||
//
|
||||
var array = instance as _root.Array;
|
||||
if (array != null) {
|
||||
return CreateArrayValuesIterator (array);
|
||||
}
|
||||
|
||||
ConcurrentDictionary<string, object> members;
|
||||
if (dynamic_classes.TryGetValue (instance, out members)) {
|
||||
return CreateMemberValuesIterator (members.Values);
|
||||
}
|
||||
|
||||
return new dynamic [0];
|
||||
}
|
||||
|
||||
static IEnumerable<object> CreateArrayValuesIterator (_root.Array array)
|
||||
{
|
||||
for (uint i = 0; i < array.length; ++i)
|
||||
yield return array [i];
|
||||
}
|
||||
|
||||
static IEnumerable<object> CreateMemberValuesIterator (ICollection<object> values)
|
||||
{
|
||||
foreach (var value in values)
|
||||
yield return value;
|
||||
}
|
||||
|
||||
public static bool HasProperty (object instance, Type context, object property)
|
||||
{
|
||||
if (instance == null)
|
||||
throw GetNullObjectReferenceException ();
|
||||
|
||||
//
|
||||
// Calling in operator on Array instance means something different
|
||||
//
|
||||
var array = instance as _root.Array;
|
||||
if (array != null) {
|
||||
var index = GetArrayIndex (property);
|
||||
if (index == null)
|
||||
return false;
|
||||
|
||||
return array.length > index;
|
||||
}
|
||||
|
||||
var type = instance as Type;
|
||||
var sname = GetName (property);
|
||||
bool static_only;
|
||||
|
||||
//
|
||||
// It's null when it's not static
|
||||
//
|
||||
if (type == null) {
|
||||
ConcurrentDictionary<string, object> members;
|
||||
if (dynamic_classes.TryGetValue (instance, out members) && members.ContainsKey (sname)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
type = instance.GetType ();
|
||||
static_only = false;
|
||||
} else {
|
||||
static_only = true;
|
||||
}
|
||||
|
||||
var binder = new IsPropertyBinder (sname, context, static_only);
|
||||
|
||||
var callsite = CallSite<Func<CallSite, Type, bool>>.Create (binder);
|
||||
|
||||
// TODO: Better handling
|
||||
try {
|
||||
// TODO: Add caching to avoid expensive Resolve
|
||||
return callsite.Target (callsite, type);
|
||||
} catch (RuntimeBinderException) {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool DeleteProperty (object instance, object property)
|
||||
{
|
||||
//
|
||||
// delete operator on Array instances
|
||||
//
|
||||
var array = instance as _root.Array;
|
||||
if (array != null) {
|
||||
var index = GetArrayIndex (property);
|
||||
if (index != null) {
|
||||
array.deleteValue (index.Value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ConcurrentDictionary<string, object> members;
|
||||
if (dynamic_classes.TryGetValue (instance, out members)) {
|
||||
var sname = GetName (property);
|
||||
|
||||
object value;
|
||||
members.TryRemove (sname, out value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static dynamic DelegateInvoke (Delegate instance, params object[] args)
|
||||
{
|
||||
if (instance == null)
|
||||
throw new NotImplementedException ();
|
||||
|
||||
return instance.DynamicInvoke (args);
|
||||
}
|
||||
|
||||
static uint? GetArrayIndex (object value)
|
||||
{
|
||||
try {
|
||||
return Convert.ToUInt32 (value);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static string GetName (object name)
|
||||
{
|
||||
// TODO: Will be special token for null key enough?
|
||||
if (name == null)
|
||||
throw new NotImplementedException ("null name");
|
||||
|
||||
return name.ToString ();
|
||||
}
|
||||
|
||||
static Exception GetNullObjectReferenceException ()
|
||||
{
|
||||
return new _root.Error ("Cannot access a property or method of a null object reference.", 1009);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// DefaultObjectContext.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using Compiler = Mono.CSharp;
|
||||
using PSCompiler = Mono.PlayScript;
|
||||
|
||||
namespace PlayScript.Runtime
|
||||
{
|
||||
public class DefaultObjectContext
|
||||
{
|
||||
readonly Stack<Compiler.Expression> stack;
|
||||
|
||||
private DefaultObjectContext ()
|
||||
{
|
||||
stack = new Stack<Compiler.Expression> ();
|
||||
}
|
||||
|
||||
internal Stack<Compiler.Expression> Context {
|
||||
get {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
public static DefaultObjectContext Create ()
|
||||
{
|
||||
return new DefaultObjectContext ();
|
||||
}
|
||||
|
||||
// TODO: Will likely need extra argument for something similar to CSharpArgumentInfoFlags to correctly
|
||||
// recreate source expression
|
||||
public void Register (object instance)
|
||||
{
|
||||
if (instance == null)
|
||||
throw new _root.TypeError (_root.Error.getErrorMessage (1009), 1009);
|
||||
|
||||
var ctx = DynamicContext.Create ();
|
||||
var expr = new PSCompiler.ObjectContextRuntimeExpression (ctx.ImportType (instance.GetType ()));
|
||||
|
||||
stack.Push (expr);
|
||||
}
|
||||
|
||||
public void Unregister ()
|
||||
{
|
||||
stack.Pop ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// IsPropertyBinder.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Dynamic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using Compiler = Mono.CSharp;
|
||||
|
||||
namespace PlayScript.Runtime
|
||||
{
|
||||
class IsPropertyBinder : DynamicMetaObjectBinder
|
||||
{
|
||||
Type callingContext;
|
||||
string name;
|
||||
bool static_only;
|
||||
|
||||
public IsPropertyBinder (string name, Type callingContext, bool staticOnly)
|
||||
{
|
||||
this.name = name;
|
||||
this.callingContext = callingContext;
|
||||
this.static_only = staticOnly;
|
||||
}
|
||||
|
||||
public override DynamicMetaObject Bind (DynamicMetaObject target, DynamicMetaObject[] args)
|
||||
{
|
||||
var ctx = DynamicContext.Create ();
|
||||
var context_type = ctx.ImportType (callingContext);
|
||||
var queried_type = ctx.ImportType ((Type) target.Value);
|
||||
var rc = new Compiler.ResolveContext (new RuntimeBinderContext (ctx, context_type), 0);
|
||||
|
||||
var expr = Compiler.Expression.MemberLookup (rc, false, queried_type,
|
||||
name, 0, Compiler.Expression.MemberLookupRestrictions.ExactArity, Compiler.Location.Null);
|
||||
|
||||
var pe = expr as Compiler.PropertyExpr;
|
||||
var result = pe != null && pe.IsStatic == static_only;
|
||||
|
||||
var binder = new CSharpBinder (
|
||||
this, new Compiler.BoolConstant (ctx.CompilerContext.BuiltinTypes, result, Compiler.Location.Null), null);
|
||||
|
||||
binder.AddRestrictions (target);
|
||||
return binder.Bind (ctx, callingContext);
|
||||
}
|
||||
|
||||
public override Type ReturnType {
|
||||
get {
|
||||
return typeof (bool);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
//
|
||||
// Operations.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace PlayScript.Runtime
|
||||
{
|
||||
public static class Operations
|
||||
{
|
||||
public static bool Comparison (BinaryOperator binaryOperator, object left, object right)
|
||||
{
|
||||
if (right is int)
|
||||
return Comparison (binaryOperator, left, (int) right);
|
||||
|
||||
if (right is string)
|
||||
return Comparison (binaryOperator, left, (string) right);
|
||||
|
||||
// TODO: uint, string, double, etc
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool Comparison (BinaryOperator binaryOperator, object left, int right)
|
||||
{
|
||||
if (left is int) {
|
||||
var l = (int) left;
|
||||
switch (binaryOperator) {
|
||||
case BinaryOperator.Equality:
|
||||
case BinaryOperator.StrictEquality:
|
||||
return l == right;
|
||||
case BinaryOperator.Inequality:
|
||||
return l != right;
|
||||
case BinaryOperator.GreaterThan:
|
||||
return l > right;
|
||||
case BinaryOperator.GreaterThanOrEqual:
|
||||
return l >= right;
|
||||
case BinaryOperator.LessThan:
|
||||
return l < right;
|
||||
case BinaryOperator.LessThanOrEqual:
|
||||
return l <= right;
|
||||
default:
|
||||
throw new NotImplementedException (binaryOperator.ToString ());
|
||||
}
|
||||
}
|
||||
|
||||
if ((binaryOperator & BinaryOperator.StrictMask) != 0)
|
||||
return binaryOperator == BinaryOperator.StrictInequality;
|
||||
|
||||
// TODO: uint, string, double, etc
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool Comparison (BinaryOperator binaryOperator, int left, object right)
|
||||
{
|
||||
if (right is int) {
|
||||
var r = (int) right;
|
||||
switch (binaryOperator) {
|
||||
case BinaryOperator.Equality:
|
||||
case BinaryOperator.StrictEquality:
|
||||
return left == r;
|
||||
case BinaryOperator.Inequality:
|
||||
case BinaryOperator.StrictInequality:
|
||||
return left != r;
|
||||
case BinaryOperator.GreaterThan:
|
||||
return left > r;
|
||||
case BinaryOperator.GreaterThanOrEqual:
|
||||
return left >= r;
|
||||
case BinaryOperator.LessThan:
|
||||
return left < r;
|
||||
case BinaryOperator.LessThanOrEqual:
|
||||
return left <= r;
|
||||
default:
|
||||
throw new NotImplementedException (binaryOperator.ToString ());
|
||||
}
|
||||
}
|
||||
|
||||
if ((binaryOperator & BinaryOperator.StrictMask) != 0)
|
||||
return binaryOperator == BinaryOperator.StrictInequality;
|
||||
|
||||
// TODO: uint, string, double, etc
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool Comparison (BinaryOperator binaryOperator, object left, string right)
|
||||
{
|
||||
if (right is string) {
|
||||
var l = (string) left;
|
||||
switch (binaryOperator) {
|
||||
case BinaryOperator.Equality:
|
||||
case BinaryOperator.StrictEquality:
|
||||
return l == right;
|
||||
case BinaryOperator.Inequality:
|
||||
case BinaryOperator.StrictInequality:
|
||||
return l != right;
|
||||
/* TODO: rules base on char comparison but how does it work with unicode
|
||||
case BinaryOperator.GreaterThan:
|
||||
return l > right;
|
||||
case BinaryOperator.GreaterThanOrEqual:
|
||||
return l >= right;
|
||||
case BinaryOperator.LessThan:
|
||||
return l < right;
|
||||
case BinaryOperator.LessThanOrEqual:
|
||||
return l <= right;
|
||||
default:
|
||||
throw new NotImplementedException (binaryOperator.ToString ());
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
if ((binaryOperator & BinaryOperator.StrictMask) != 0)
|
||||
return binaryOperator == BinaryOperator.StrictInequality;
|
||||
|
||||
// TODO: uint, string, double, etc
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Type ClassOf (object instance)
|
||||
{
|
||||
var type = instance as Type;
|
||||
if (type == null)
|
||||
throw new _root.TypeError (_root.Error.getErrorMessage (1007), 1007);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
public static bool IsOfType<T> (ref T instance, Type expectedType)
|
||||
{
|
||||
if (expectedType == null)
|
||||
throw new _root.TypeError (_root.Error.getErrorMessage (1009), 1009);
|
||||
|
||||
if (instance == null)
|
||||
return false;
|
||||
|
||||
return expectedType.IsAssignableFrom (instance.GetType ());
|
||||
}
|
||||
|
||||
public static string TypeOf (object instance)
|
||||
{
|
||||
if (instance == null)
|
||||
return "object";
|
||||
|
||||
if (instance is string)
|
||||
return "string";
|
||||
|
||||
if (instance is int || instance is uint || instance is double)
|
||||
return "number";
|
||||
|
||||
if (instance is bool)
|
||||
return "boolean";
|
||||
|
||||
// TODO: Wrong, it has to be of a special type
|
||||
if (instance == Undefined.Value)
|
||||
return "undefined";
|
||||
|
||||
// TODO: Wrong, it has to be of a special type
|
||||
if (instance is _root.XML || instance is _root.XMLList)
|
||||
return "xml";
|
||||
|
||||
if (instance is Delegate)
|
||||
return "function";
|
||||
|
||||
return "object";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// PlayScriptGetMemberBinder.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.Dynamic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using Compiler = Mono.CSharp;
|
||||
using PSCompiler = Mono.PlayScript;
|
||||
|
||||
namespace PlayScript.Runtime
|
||||
{
|
||||
class PlayScriptGetMemberBinder : GetMemberBinder
|
||||
{
|
||||
Type callingContext;
|
||||
DefaultObjectContext objectContext;
|
||||
|
||||
public PlayScriptGetMemberBinder (string name, Type callingContext, DefaultObjectContext objectContext)
|
||||
: base (name, false)
|
||||
{
|
||||
this.callingContext = callingContext;
|
||||
this.objectContext = objectContext;
|
||||
}
|
||||
|
||||
public override DynamicMetaObject FallbackGetMember (DynamicMetaObject target, DynamicMetaObject errorSuggestion)
|
||||
{
|
||||
var ctx = DynamicContext.Create ();
|
||||
|
||||
Compiler.Expression expr = new PSCompiler.SimpleName (Name, Compiler.Location.Null);
|
||||
expr = new Compiler.Cast (new Compiler.TypeExpression (ctx.ImportType (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
|
||||
|
||||
var binder = new CSharpBinder (this, expr, errorSuggestion);
|
||||
binder.AddRestrictions (target);
|
||||
|
||||
// TODO: RuntimeBinderContext is not enough, it won't search global extension methods for builtin types
|
||||
var rc = new Compiler.ResolveContext (new RuntimeBinderContext (ctx, callingContext), binder.ResolveOptions);
|
||||
rc.DefaultObjectContext = new PSCompiler.WithContext (objectContext.Context);
|
||||
|
||||
return binder.Bind (rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Undefined.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
namespace PlayScript.Runtime
|
||||
{
|
||||
public static class Undefined
|
||||
{
|
||||
public static readonly object Value = new object ();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// QName.play
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright 2013 Zynga Inc.
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
package {
|
||||
|
||||
public final class QName
|
||||
{
|
||||
private var mUri:String;
|
||||
private var mLocalName:String;
|
||||
|
||||
public function QName(@namespace:String=null, name:String=null)
|
||||
{
|
||||
mUri = uri;
|
||||
mLocalName = localName;
|
||||
}
|
||||
|
||||
public function get localName () : String
|
||||
{
|
||||
return mLocalName;
|
||||
}
|
||||
|
||||
public function get uri () : String
|
||||
{
|
||||
return mUri;
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function valueOf():Object {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// RangeError.play
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright 2013 Zynga Inc.
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
package {
|
||||
|
||||
public dynamic class RangeError extends Error {
|
||||
|
||||
public function RangeError (message:String = "", id:int = 0)
|
||||
{
|
||||
super (message, id);
|
||||
}
|
||||
|
||||
internal static function CreateIndexError (index:uint, range:uint):RangeError
|
||||
{
|
||||
return new RangeError (System.String.Format ("The index {0} is out of range {1}.", index, range), 1125);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class ReferenceError extends Error {
|
||||
|
||||
public function ReferenceError(message:String = "") {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
import System.*;
|
||||
import System.Text.RegularExpressions.*;
|
||||
|
||||
public class RegExp {
|
||||
|
||||
//
|
||||
// Properties
|
||||
//
|
||||
/*
|
||||
public property dotall : Boolean {
|
||||
get { return mDoTail;}
|
||||
}
|
||||
public property extended : Boolean {
|
||||
get { return mExtended;}
|
||||
}
|
||||
public property global : Boolean {
|
||||
get { return mGlobal;}
|
||||
}
|
||||
public property ignoreCase : Boolean {
|
||||
get { return (mRegex.Options & RegexOptions.IgnoreCase) != 0;}
|
||||
}
|
||||
public property lastIndex : Number {
|
||||
get { throw new NotImplementedException();}
|
||||
}
|
||||
public property multiline : Boolean {
|
||||
get { return (mRegex.Options & RegexOptions.Multiline) != 0;}
|
||||
}
|
||||
|
||||
public property source : String {
|
||||
get { return mSource;}
|
||||
}
|
||||
*/
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
public function RegExp(re:String, flags:String) {
|
||||
var options:RegexOptions = RegexOptions.None;
|
||||
for (var i:int=0; i < flags.Length; i++) {
|
||||
switch (flags.charAt(i)) {
|
||||
case "m":
|
||||
options |= RegexOptions.Multiline;
|
||||
break;
|
||||
case "i":
|
||||
options |= RegexOptions.IgnoreCase;
|
||||
break;
|
||||
case "g":
|
||||
mGlobal = true;
|
||||
break;
|
||||
case "x":
|
||||
mExtended = true;
|
||||
break;
|
||||
case "s":
|
||||
mDoTail = true;
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
mSource = re;
|
||||
mRegex = new Regex(re, options);
|
||||
}
|
||||
|
||||
public function exec(str:String):Object {
|
||||
var m = mRegex.Match(str);
|
||||
if (m.Success) {
|
||||
var a:Array = [];
|
||||
// a.push(m.Value);
|
||||
for each (var g:Group in m.Groups) {
|
||||
a.push(g.Value);
|
||||
}
|
||||
return a;
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function test(str:String):Boolean {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public function replace(str:String, replaceWith:String):String {
|
||||
return mRegex.Replace(str, replaceWith);
|
||||
}
|
||||
|
||||
public function search(str:String):int {
|
||||
var m = mRegex.Match(str);
|
||||
if (!m.Success) {
|
||||
return -1;
|
||||
}
|
||||
return m.Index;
|
||||
}
|
||||
|
||||
public function match(str:String):Array {
|
||||
var a:Array = null;
|
||||
var m = mRegex.Match(str);
|
||||
while (m.Success) {
|
||||
if (a == null) a = new Array();
|
||||
a.push( m.Value );
|
||||
m = m.NextMatch();
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
public function split(str:String):Array
|
||||
{
|
||||
var a:Array = new Array();
|
||||
|
||||
var lastIndex:int = 0;
|
||||
|
||||
var m = mRegex.Match(str);
|
||||
while (m.Success) {
|
||||
|
||||
// get everything before the match
|
||||
var before:String = str.Substring(lastIndex, m.Index - lastIndex);
|
||||
|
||||
a.push(before);
|
||||
|
||||
// push all matching groups
|
||||
for (var i:int = 1; i < m.Groups.Count; i++)
|
||||
{
|
||||
a.push(m.Groups[i].Value);
|
||||
}
|
||||
|
||||
// set last index
|
||||
lastIndex = m.Index + m.Length;
|
||||
|
||||
// next match
|
||||
m = m.NextMatch();
|
||||
}
|
||||
|
||||
// push everything after last match
|
||||
var end:String = str.Substring(lastIndex, str.Length - lastIndex);
|
||||
a.push(end);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
var mRegex:Regex;
|
||||
var mSource:String;
|
||||
var mGlobal:Boolean;
|
||||
var mExtended:Boolean;
|
||||
var mDoTail:Boolean;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false)]
|
||||
public class SWFAttribute : Attribute
|
||||
{
|
||||
public object width { get; set; }
|
||||
public object height { get; set; }
|
||||
public object frameRate { get; set; }
|
||||
public object backgroundColor { get; set; }
|
||||
public object quality {get;set;}
|
||||
|
||||
public SWFAttribute ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class SecurityError extends Error {
|
||||
|
||||
public function SecurityError(message:String = "") {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static int get_length(this String s) {
|
||||
return s.Length;
|
||||
}
|
||||
|
||||
public static String charAt (this String s, double index = 0) {
|
||||
return s[ (int)index ].ToString();
|
||||
}
|
||||
|
||||
public static int charCodeAt(this String s, double index) {
|
||||
return s[(int)index];
|
||||
}
|
||||
|
||||
public static String concat(this String s, params object[] args) {
|
||||
foreach (object arg in args)
|
||||
{
|
||||
s += arg.ToString();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
private static char objectToChar(object o)
|
||||
{
|
||||
if (o is int) {
|
||||
return (char)(int)o;
|
||||
} else if (o is uint) {
|
||||
return (char)(uint)o;
|
||||
} else if (o is char) {
|
||||
return (char)o;
|
||||
} else {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public static String fromCharCode (params object[] charCodes)
|
||||
{
|
||||
if (charCodes.Length == 1)
|
||||
{
|
||||
return new String(objectToChar(charCodes[0]), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
var chars = new char[charCodes.Length];
|
||||
for (int i=0; i < charCodes.Length; i++) {
|
||||
chars[i] = objectToChar(charCodes[i]);
|
||||
}
|
||||
return new String(chars);
|
||||
}
|
||||
}
|
||||
|
||||
public static int indexOf(this String s, String val, double startIndex = 0) {
|
||||
if (s == null) return -1;
|
||||
return s.IndexOf(val, (int)startIndex);
|
||||
}
|
||||
|
||||
public static int lastIndexOf(this String s, String val, double startIndex = 0x7FFFFFFF) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static int localeCompare(this String s, String other, params object[] values) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static Array match(this String s, object pattern) {
|
||||
if (pattern is RegExp) {
|
||||
// pattern is a regexp
|
||||
var re = pattern as RegExp;
|
||||
return re.match(s);
|
||||
} else {
|
||||
// pattern is a String or other object
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public static String replace (this String s, object pattern, object repl)
|
||||
{
|
||||
if (pattern is RegExp) {
|
||||
// pattern is a regexp
|
||||
var re = pattern as RegExp;
|
||||
return re.replace(s, repl.ToString());
|
||||
} else {
|
||||
// pattern is a String or other object
|
||||
return s.Replace(pattern.ToString (), repl.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static int search(this String s, object pattern) {
|
||||
if (pattern is RegExp) {
|
||||
// pattern is a regexp
|
||||
var re = pattern as RegExp;
|
||||
return re.search(s);
|
||||
} else {
|
||||
// pattern is a String or other object
|
||||
return s.IndexOf(pattern.ToString ());
|
||||
}
|
||||
}
|
||||
|
||||
public static String slice(this String s) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static String slice(this String s, int startIndex) {
|
||||
return s.Substring(startIndex);
|
||||
}
|
||||
|
||||
public static String slice(this String s, int startIndex, int endIndex) {
|
||||
return s.Substring(startIndex, endIndex - startIndex);
|
||||
}
|
||||
|
||||
public static Array split (this String s, object delimiter, int limit = 0x7fffffff)
|
||||
{
|
||||
if (limit != 0x7fffffff) {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
if (delimiter is RegExp) {
|
||||
var re = delimiter as RegExp;
|
||||
return re.split(s);
|
||||
} else if (delimiter is String) {
|
||||
return new Array( s.Split(new String[] {(String)delimiter}, StringSplitOptions.None ));
|
||||
} else {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public static String substr (this String s, double startIndex = 0, double len = 0x7fffffff) {
|
||||
if (len == 0x7fffffff) {
|
||||
return s.Substring((int)startIndex);
|
||||
} else {
|
||||
// TODO: should this throw or be silent if length exceeded?
|
||||
return s.Substring((int)startIndex, (int)len);
|
||||
}
|
||||
}
|
||||
|
||||
public static String substring (this String s, double startIndex = 0, double endIndex = 0x7fffffff) {
|
||||
if (endIndex == 0x7fffffff) {
|
||||
return s.Substring((int)startIndex);
|
||||
} else {
|
||||
// TODO: should this throw or be silent if length exceeded?
|
||||
return s.Substring((int)startIndex, (int)endIndex - (int)startIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public static String toLocaleLowerCase(this String s) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static String toLocaleUpperCase(this String s) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static String toLowerCase(this String s) {
|
||||
return s.ToLowerInvariant();
|
||||
}
|
||||
|
||||
public static String toUpperCase(this String s) {
|
||||
return s.ToUpperInvariant();
|
||||
}
|
||||
|
||||
public static String valueOf(this String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class SyntaxError extends Error {
|
||||
|
||||
public function SyntaxError(message:String = "") {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// TypeError.play
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright 2013 Zynga Inc.
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
package {
|
||||
|
||||
public dynamic class TypeError extends Error {
|
||||
|
||||
public function TypeError (message:String = "", id:int = 0)
|
||||
{
|
||||
super (message, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class URIError extends Error {
|
||||
|
||||
public function URIError(message:String = "") {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
//
|
||||
// Vector.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using PlayScript.Runtime.CompilerServices;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
[DynamicClass]
|
||||
public class Vector<T>
|
||||
{
|
||||
readonly List<T> list;
|
||||
|
||||
public Vector (int length = 0, bool @fixed = false)
|
||||
{
|
||||
list = new List<T> (length);
|
||||
this.@fixed = @fixed;
|
||||
}
|
||||
|
||||
public Vector (params T[] values)
|
||||
{
|
||||
list = new List<T> (values);
|
||||
}
|
||||
|
||||
private Vector (List<T> list)
|
||||
{
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public bool @fixed { get; set; }
|
||||
|
||||
public uint length {
|
||||
get {
|
||||
return (uint) list.Count;
|
||||
}
|
||||
set {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public Vector<T> concat ([RestArrayParameter] Array args)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public Vector<T> concat (params T[] args)
|
||||
{
|
||||
var res = new List<T> (list);
|
||||
res.AddRange (args);
|
||||
return new Vector<T> (res);
|
||||
}
|
||||
|
||||
public int indexOf (T searchElement, int fromIndex)
|
||||
{
|
||||
return list.IndexOf (searchElement, fromIndex);
|
||||
}
|
||||
|
||||
public int lastIndexOf (T searchElement, int fromIndex = 0x7fffffff)
|
||||
{
|
||||
return list.LastIndexOf (searchElement, fromIndex);
|
||||
}
|
||||
|
||||
public uint push (T value)
|
||||
{
|
||||
list.Add (value);
|
||||
return length;
|
||||
}
|
||||
|
||||
public uint unshift ([RestArrayParameter] Array args)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public uint unshift (params T[] args)
|
||||
{
|
||||
list.InsertRange (0, args);
|
||||
return length;
|
||||
}
|
||||
|
||||
internal void setValue (uint index, T value)
|
||||
{
|
||||
if (index < 0 || index >= length)
|
||||
throw RangeError.CreateIndexError (index, length);
|
||||
|
||||
list [(int) index] = value;
|
||||
}
|
||||
|
||||
internal T getValue (uint index)
|
||||
{
|
||||
if (index < 0 || index >= length)
|
||||
throw RangeError.CreateIndexError (index, length);
|
||||
|
||||
return list [(int) index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class VerifyError extends Error {
|
||||
|
||||
public function VerifyError(message:String = "") {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,283 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
import System.*;
|
||||
import System.Xml.*;
|
||||
|
||||
public class XML {
|
||||
|
||||
var mElement:XmlElement;
|
||||
|
||||
//
|
||||
// Properties
|
||||
//
|
||||
/*
|
||||
public static property ignoreComments : Boolean {
|
||||
get { throw new System.NotImplementedException(); }
|
||||
set { throw new System.NotImplementedException(); }
|
||||
}
|
||||
|
||||
public static property ignoreProcessingInstructions : Boolean {
|
||||
get { throw new System.NotImplementedException(); }
|
||||
set { throw new System.NotImplementedException(); }
|
||||
}
|
||||
|
||||
public static property ignoreWhitespace : Boolean {
|
||||
get { throw new System.NotImplementedException(); }
|
||||
set { throw new System.NotImplementedException(); }
|
||||
}
|
||||
|
||||
public static property prettyIndent : int {
|
||||
get { throw new System.NotImplementedException(); }
|
||||
set { throw new System.NotImplementedException(); }
|
||||
}
|
||||
|
||||
public static property prettyPrinting : Boolean {
|
||||
get { throw new System.NotImplementedException(); }
|
||||
set { throw new System.NotImplementedException(); }
|
||||
}
|
||||
*/
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
public function XML(value:Object) {
|
||||
/*
|
||||
if (value is XmlElement)
|
||||
{
|
||||
mElement = value as XmlElement;
|
||||
} else if (value is flash.utils.ByteArray)
|
||||
{
|
||||
var ba:flash.utils.ByteArray = value as flash.utils.ByteArray;
|
||||
|
||||
// read string from byte array
|
||||
ba.position = 0;
|
||||
var xmlString:String = ba.readAllUTF();
|
||||
|
||||
// parse xml document from string
|
||||
var doc:XmlDocument = new XmlDocument();
|
||||
doc.LoadXml(xmlString);
|
||||
mElement = doc.DocumentElement;
|
||||
} else if (value is String)
|
||||
{
|
||||
// parse xml document from string
|
||||
var doc:XmlDocument = new XmlDocument();
|
||||
doc.LoadXml(value as String);
|
||||
mElement = doc.DocumentElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public function XML(value:XmlNode)
|
||||
{
|
||||
// TODO: mElement = value;
|
||||
}
|
||||
|
||||
public function addNamespace(ns:Object):XML {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function appendChild(child:Object):XML {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
/*
|
||||
public function attribute(attributeName:String):XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}*/
|
||||
|
||||
public function attribute(attributeName:String):String {
|
||||
return mElement.HasAttribute(attributeName) ? mElement.GetAttribute(attributeName) : null;
|
||||
}
|
||||
|
||||
public function attributes():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function child(propertyName:Object):XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function childIndex():int {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function children():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function comments():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function contains(value:XML):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function copy():XML {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public static function defaultSettings():Object {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function descendants():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function descendants(name:Object):XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function elements():XMLList {
|
||||
return new XMLList(mElement.GetElementsByTagName("*"));
|
||||
}
|
||||
|
||||
public function elements(name:String):XMLList {
|
||||
return new XMLList(mElement.GetElementsByTagName(name));
|
||||
}
|
||||
|
||||
public function hasComplexContent():Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function hasOwnProperty(p:String):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function hasSimpleContent():Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function inScopeNamespaces():Array {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function insertChildAfter(child1:Object, child2:Object):* {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function insertChildBefore(child1:Object, child2:Object):* {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function length():int {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function localName():String {
|
||||
return mElement.LocalName;
|
||||
}
|
||||
|
||||
public function name():QName {
|
||||
return new QName(mElement.NamespaceURI, mElement.Name);
|
||||
}
|
||||
|
||||
public function @namespace(prefix:String = null):* {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function namespaceDeclarations():Array {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function nodeKind():String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function normalize():XML {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function parent():* {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function prependChild(value:Object):XML {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function processingInstructions(name:String):XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function propertyIsEnumerable(p:String):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function removeNamespace(ns:Namespace):XML {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function replace(propertyName:Object, value:XML):XML {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function setChildren(value:Object):XML {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function setLocalName(name:String):void {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function setName(name:String):void {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function setNamespace(ns:Namespace):void {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function setSettings(... rest):void {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function settings():Object {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function text():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function toJSON(k:String):* {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function toXMLString():String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function valueOf():Object {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
/*
|
||||
public static implicit operator String (xml:XML) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public /*final*/ dynamic class XMLList
|
||||
{
|
||||
public function XMLList (value:*=null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
import System.Xml.*;
|
||||
import System.Collections.*;
|
||||
import System.Collections.Generic.*;
|
||||
import System.Linq.*;
|
||||
|
||||
public class XMLList implements IEnumerable.<XML> {
|
||||
|
||||
var mList:List.<XML> = new List.<XML>();
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
public function XMLList(value:Object) {
|
||||
if (value == null) {
|
||||
// empty
|
||||
}
|
||||
else {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
internal function XMLList(value:XmlNodeList)
|
||||
{
|
||||
// create list of XML from node list
|
||||
|
||||
for each ( var node:XmlNode in value) {
|
||||
if (node is XmlElement) {
|
||||
mList.Add(new XML(node));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal function XMLList ()
|
||||
{
|
||||
}
|
||||
|
||||
public function attribute(attributeName:String):String {
|
||||
if (mList.Count != 1)
|
||||
throw new System.NotImplementedException();
|
||||
|
||||
return mList[0].attribute(attributeName);
|
||||
}
|
||||
|
||||
public function attributes():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function child(propertyName:Object):XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function children():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function comments():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function contains(value:XML):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function copy():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function descendants():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function descendants(name:Object):XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function elements():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function elements(name:String):XMLList {
|
||||
if (mList.Count == 0)
|
||||
return new XMLList();
|
||||
|
||||
if (mList.Count != 1)
|
||||
throw new System.NotImplementedException();
|
||||
|
||||
return mList[0].elements(name);
|
||||
}
|
||||
|
||||
public function hasComplexContent():Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function hasOwnProperty(p:String):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function hasSimpleContent():Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function length():int {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function normalize():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function parent():Object {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function processingInstructions(name:String = "*"):XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function propertyIsEnumerable(p:String):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function text():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function toXMLString():String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function valueOf():Object {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public indexer this(index:int):XML {
|
||||
get { throw new System.NotImplementedException(); }
|
||||
}
|
||||
|
||||
public static implicit operator String (list:XMLList) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
function IEnumerable.<XML>.GetEnumerator() : IEnumerator.<XML> {
|
||||
return mList.GetEnumerator();
|
||||
}
|
||||
|
||||
function IEnumerable.GetEnumerator() : IEnumerator {
|
||||
return mList.GetEnumerator();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
|
||||
//
|
||||
// Conversions (must be in C# to avoid conflicts).
|
||||
//
|
||||
|
||||
public static class String_fn
|
||||
{
|
||||
public static string String (object o)
|
||||
{
|
||||
return o.ToString();
|
||||
}
|
||||
|
||||
public static string String (string s)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
public static string String (int i)
|
||||
{
|
||||
return i.ToString ();
|
||||
}
|
||||
|
||||
public static string String (uint u)
|
||||
{
|
||||
return u.ToString ();
|
||||
}
|
||||
|
||||
public static string String (double d)
|
||||
{
|
||||
return d.ToString ();
|
||||
}
|
||||
|
||||
public static string String (bool b)
|
||||
{
|
||||
return b.ToString ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Number_fn
|
||||
{
|
||||
// Inlineable method
|
||||
public static double Number (string s)
|
||||
{
|
||||
double d;
|
||||
double.TryParse(s, out d);
|
||||
return d;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class int_fn
|
||||
{
|
||||
// Inlineable method
|
||||
public static int @int (string s)
|
||||
{
|
||||
int i;
|
||||
int.TryParse(s, out i);
|
||||
return i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class uint_fn
|
||||
{
|
||||
|
||||
// Inlineable method
|
||||
public static uint @uint (string s)
|
||||
{
|
||||
uint u;
|
||||
uint.TryParse(s, out u);
|
||||
return u;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Boolean_fn
|
||||
{
|
||||
|
||||
// Not inlinable.. but required to get correct results in flash.
|
||||
public static bool Boolean (object d)
|
||||
{
|
||||
if (d == null) return false;
|
||||
|
||||
TypeCode tc = Type.GetTypeCode(d.GetType());
|
||||
switch (tc) {
|
||||
case TypeCode.Boolean:
|
||||
return (bool)d;
|
||||
case TypeCode.SByte:
|
||||
return (sbyte)d != 0;
|
||||
case TypeCode.Byte:
|
||||
return (byte)d != 0;
|
||||
case TypeCode.Int16:
|
||||
return (short)d != 0;
|
||||
case TypeCode.UInt16:
|
||||
return (ushort)d != 0;
|
||||
case TypeCode.Int32:
|
||||
return (int)d != 0;
|
||||
case TypeCode.UInt32:
|
||||
return (uint)d != 0;
|
||||
case TypeCode.Int64:
|
||||
return (long)d != 0;
|
||||
case TypeCode.UInt64:
|
||||
return (ulong)d != 0;
|
||||
case TypeCode.Single:
|
||||
return (float)d != 0.0f;
|
||||
case TypeCode.Double:
|
||||
return (double)d != 0.0;
|
||||
case TypeCode.Decimal:
|
||||
return (decimal)d != 0;
|
||||
case TypeCode.String:
|
||||
var s = (string)d;
|
||||
return !string.IsNullOrEmpty(s) && s != "0" && s != "false";
|
||||
case TypeCode.Empty:
|
||||
return false;
|
||||
case TypeCode.Object:
|
||||
return d != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Inlineable method
|
||||
public static bool Boolean (string s)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
public static class @int
|
||||
{
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
public static string toExponential(this int i, uint fractionDigits) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static string toFixed(this int i, uint fractionDigits) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static string toPrecision(this int i, uint precision) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static string toString(this int i) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static string toString(this int i, uint radix) {
|
||||
return Convert.ToString(i, (int)radix);
|
||||
}
|
||||
|
||||
public static int valueOf(this int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
public const int MAX_VALUE = 2147483647;
|
||||
|
||||
public const int MIN_VALUE = -2147483648;
|
||||
|
||||
}
|
||||
|
||||
public static class @uint
|
||||
{
|
||||
public const uint MAX_VALUE = System.UInt32.MaxValue;
|
||||
public const uint MIN_VALUE = System.UInt32.MinValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
//
|
||||
// toplevel.play
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright 2013 Zynga Inc.
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public function isA(obj:*, cl:Class):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function decodeURI(uri:String):String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function decodeURIComponent(uri:String):String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function encodeURI(uri:String):String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function encodeURIComponent(uri:String):String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function escape(str:String):String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function isFinite(num:Number):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function isNaN (num:Number = NaN):Boolean
|
||||
{
|
||||
return System.Double.IsNaN (num);
|
||||
}
|
||||
|
||||
public function isXMLName(str:String):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function parseFloat(str:String):Number {
|
||||
if (!System.String.IsNullOrEmpty(str))
|
||||
{
|
||||
return System.Double.Parse(str);
|
||||
} else {
|
||||
return System.Double.NaN;
|
||||
}
|
||||
}
|
||||
|
||||
public function trace(o:System.Object):void {
|
||||
// System.Diagnostics.Debug.WriteLine(o);
|
||||
System.Console.WriteLine(o);
|
||||
}
|
||||
|
||||
public function trace(o1:System.Object, o2:System.Object):void {
|
||||
// System.Diagnostics.Debug.WriteLine("{0}{1}", o1, o2);
|
||||
System.Console.WriteLine("{0} {1}", o1, o2);
|
||||
}
|
||||
|
||||
public function trace(o1:System.Object, o2:System.Object, o3:System.Object):void {
|
||||
// System.Diagnostics.Debug.WriteLine("{0}{1}{2}", o1, o2, o3);
|
||||
System.Console.WriteLine("{0} {1} {2}", o1, o2, o3);
|
||||
}
|
||||
|
||||
public function trace(o1:System.Object, o2:System.Object, o3:System.Object, ...args):void {
|
||||
var argsStr = System.String.Concat(args);
|
||||
// System.Diagnostics.Debug.WriteLine("{0}{1}{2}{3}", o1, o2, o3, argsStr);
|
||||
System.Console.WriteLine("{0} {1} {2} {3}", o1, o2, o3, argsStr);
|
||||
}
|
||||
|
||||
public function parseInt(str:String, radix:uint = 0):int {
|
||||
if (radix != 0 && radix != 10)
|
||||
throw new System.NotImplementedException();
|
||||
|
||||
return System.Int32.Parse(str);
|
||||
}
|
||||
|
||||
public function unescape(str:String):String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
//
|
||||
// Constants
|
||||
// Non-static in AS but why not make them static
|
||||
//
|
||||
public static const undefined : * = PlayScript.Runtime.Undefined.Value;
|
||||
public static const Infinity : Number = System.Double.PositiveInfinity;
|
||||
public static const NaN : Number = System.Double.NaN;
|
||||
|
||||
/*
|
||||
public function loadEmbed(baseObject:Object, fieldName:String):Object
|
||||
{
|
||||
// pass this off to C# code
|
||||
return PlayScript.Player.LoadEmbed(baseObject, fieldName);
|
||||
}
|
||||
|
||||
public function invokeStaticMethod(type:Class, methodName:String, args:Array):Object
|
||||
{
|
||||
// pass this off to C# code
|
||||
return PlayScript.Player.InvokeStaticMethod(type, methodName, args);
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -12,7 +12,7 @@ CLEAN_FILES += $(STRING_MESSAGES)
|
||||
EXTRA_DISTFILES = \
|
||||
src/ComponentModel/Strings.resx
|
||||
|
||||
VALID_PROFILE := $(filter net_4_0 net_4_5 monotouch monodroid, $(PROFILE))
|
||||
VALID_PROFILE := $(filter net_4_0 net_4_5 monotouch monodroid mobile_static, $(PROFILE))
|
||||
ifndef VALID_PROFILE
|
||||
LIBRARY_NAME = dummy-System.ComponentModel.Composition.dll
|
||||
NO_INSTALL = yes
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#if !MONOTOUCH
|
||||
#if !FULL_AOT_RUNTIME
|
||||
// -----------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#if !MONOTOUCH
|
||||
#if !FULL_AOT_RUNTIME
|
||||
// -----------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ namespace System.ComponentModel.Composition
|
||||
{
|
||||
if(!metadataViewType.IsAttributeDefined<MetadataViewImplementationAttribute>())
|
||||
{
|
||||
#if !MONOTOUCH
|
||||
#if !FULL_AOT_RUNTIME
|
||||
try
|
||||
{
|
||||
proxyType = MetadataViewGenerator.GenerateView(metadataViewType);
|
||||
@@ -87,7 +87,7 @@ namespace System.ComponentModel.Composition
|
||||
}
|
||||
catch (TargetInvocationException ex)
|
||||
{
|
||||
#if !MONOTOUCH
|
||||
#if !FULL_AOT_RUNTIME
|
||||
//Unwrap known failures that we want to present as CompositionContractMismatchException
|
||||
if(metadataViewType.IsInterface)
|
||||
{
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ namespace System.ComponentModel.Composition.Primitives
|
||||
|
||||
private Type CreateStandardDelegateType()
|
||||
{
|
||||
#if MONOTOUCH
|
||||
#if FULL_AOT_RUNTIME
|
||||
throw new NotImplementedException ();
|
||||
#else
|
||||
ParameterInfo[] parameters = this._method.GetParameters();
|
||||
|
||||
@@ -18,7 +18,7 @@ endif
|
||||
TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
|
||||
|
||||
# This is a .NET 3.5+ assembly
|
||||
VALID_PROFILE := $(filter net_2_0 net_4_0 net_4_5 monotouch monodroid, $(PROFILE))
|
||||
VALID_PROFILE := $(filter net_2_0 net_4_0 net_4_5 monotouch monodroid mobile_static, $(PROFILE))
|
||||
ifndef VALID_PROFILE
|
||||
LIBRARY_NAME = dummy-System.ComponentModel.DataAnnotations.dll
|
||||
NO_INSTALL = yes
|
||||
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// CompareAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Pablo Ruiz García <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
|
||||
// Copyright (C) 2013 Pablo Ruiz García
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if NET_4_5
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace System.ComponentModel.DataAnnotations
|
||||
{
|
||||
[AttributeUsageAttribute (AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
|
||||
public class CompareAttribute : ValidationAttribute
|
||||
{
|
||||
private const string DefaultErrorMessage = "'{0}' and '{1}' do not match.";
|
||||
private const string NonExistingPropertyErrorMessage = "Could not find a property named {0}.";
|
||||
private string _otherProperty;
|
||||
private string _otherPropertyDisplayName;
|
||||
|
||||
public CompareAttribute (string otherProperty)
|
||||
: base (() => DefaultErrorMessage)
|
||||
{
|
||||
if (string.IsNullOrEmpty (otherProperty))
|
||||
throw new ArgumentNullException ("otherProperty");
|
||||
|
||||
_otherProperty = otherProperty;
|
||||
}
|
||||
|
||||
public string OtherProperty { get { return _otherProperty; } }
|
||||
public string OtherPropertyDisplayName { get { return _otherPropertyDisplayName; } }
|
||||
public override bool RequiresValidationContext { get { return true; } }
|
||||
|
||||
private IEnumerable<Attribute> GetPropertyAttributes (Type type, string propertyName)
|
||||
{
|
||||
#if MOBILE
|
||||
return TypeDescriptor.GetProperties (type).Find (propertyName, false).Attributes.OfType<Attribute> ();
|
||||
#else
|
||||
// Using AMTTDP seems the way to go to be able to relay on attributes declared
|
||||
// by means of associated classes not directly decorating the property.
|
||||
// See: http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.associatedmetadatatypetypedescriptionprovider.aspx
|
||||
return new AssociatedMetadataTypeTypeDescriptionProvider (type)
|
||||
.GetTypeDescriptor (type)
|
||||
.GetProperties ()
|
||||
.Find (propertyName, false)
|
||||
.Attributes.OfType<Attribute> ();
|
||||
#endif
|
||||
}
|
||||
|
||||
private void ResolveOtherPropertyDisplayName (ValidationContext context)
|
||||
{
|
||||
if (_otherPropertyDisplayName == null)
|
||||
{
|
||||
// NOTE: From my own tests, it seems MS.NET looksup displayName from various sources, what follows
|
||||
// is a best guess from my on tests, however, I am probably missing some corner cases. (pruiz)
|
||||
var attributes = GetPropertyAttributes (context.ObjectType, _otherProperty);
|
||||
var displayAttr = attributes.FirstOrDefault (x => x is DisplayAttribute) as DisplayAttribute;
|
||||
var displayNameAttr = attributes.FirstOrDefault (x => x is DisplayNameAttribute) as DisplayNameAttribute;
|
||||
|
||||
if (displayAttr != null) _otherPropertyDisplayName = displayAttr.GetName ();
|
||||
else if (displayNameAttr != null) _otherPropertyDisplayName = displayNameAttr.DisplayName;
|
||||
_otherPropertyDisplayName = _otherProperty;
|
||||
}
|
||||
}
|
||||
|
||||
public override string FormatErrorMessage (string name)
|
||||
{
|
||||
var oname = string.IsNullOrEmpty (_otherPropertyDisplayName) ? _otherProperty : _otherPropertyDisplayName;
|
||||
return string.Format (ErrorMessageString, name, oname);
|
||||
}
|
||||
|
||||
protected override ValidationResult IsValid(object value, ValidationContext context)
|
||||
{
|
||||
var property = context.ObjectType.GetProperty (_otherProperty);
|
||||
|
||||
if (property == null) {
|
||||
string message = string.Format (NonExistingPropertyErrorMessage, _otherProperty);
|
||||
return new ValidationResult (message);
|
||||
}
|
||||
|
||||
// XXX: Could not find a better place to call this, as this is
|
||||
// the only place we have access to a ValidationContext. (pruiz)
|
||||
ResolveOtherPropertyDisplayName (context);
|
||||
|
||||
return object.Equals (property.GetValue (context.ObjectInstance, null), value) ? null
|
||||
: new ValidationResult (FormatErrorMessage (context.DisplayName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// CreditCardAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
// Pablo Ruiz García <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin Inc (http://www.xamarin.com)
|
||||
// Copyright (C) 2013 Pablo Ruiz García
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if NET_4_5
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
|
||||
namespace System.ComponentModel.DataAnnotations
|
||||
{
|
||||
[AttributeUsageAttribute (AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
|
||||
public class CreditCardAttribute : DataTypeAttribute
|
||||
{
|
||||
private const string DefaultErrorMessage = "The {0} field is not a valid credit card number.";
|
||||
|
||||
public CreditCardAttribute ()
|
||||
: base(DataType.CreditCard)
|
||||
{
|
||||
// XXX: There is no .ctor accepting Func<string> on DataTypeAttribute.. :?
|
||||
base.ErrorMessage = DefaultErrorMessage;
|
||||
}
|
||||
|
||||
public override bool IsValid(object value)
|
||||
{
|
||||
if (value == null)
|
||||
return true;
|
||||
|
||||
if (string.IsNullOrEmpty(value as string))
|
||||
return false;
|
||||
|
||||
// Remove any invalid characters..
|
||||
var creditCardNumber = (value as string).Replace("-", "").Replace(" ", "");
|
||||
|
||||
if (creditCardNumber.Any (x => !Char.IsDigit (x)))
|
||||
return false;
|
||||
|
||||
// Performan a Luhn-based check against credit card number.
|
||||
//
|
||||
// See: http://en.wikipedia.org/wiki/Luhn_algorithm
|
||||
// See: http://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers
|
||||
// See: http://www.codeproject.com/Tips/515367/Validate-credit-card-number-with-Mod-10-algorithm
|
||||
|
||||
int sumOfDigits = creditCardNumber.Where((e) => e >= '0' && e <= '9')
|
||||
.Reverse()
|
||||
.Select((e, i) => ((int)e - 48) * (i % 2 == 0 ? 1 : 2))
|
||||
.Sum((e) => e / 10 + e % 10);
|
||||
|
||||
return sumOfDigits % 10 == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
+6
-1
@@ -46,7 +46,12 @@ namespace System.ComponentModel.DataAnnotations
|
||||
Password,
|
||||
Url,
|
||||
#if NET_4_0
|
||||
ImageUrl
|
||||
ImageUrl,
|
||||
#endif
|
||||
#if NET_4_5
|
||||
CreditCard,
|
||||
PostalCode,
|
||||
Upload
|
||||
#endif
|
||||
}
|
||||
}
|
||||
+23
-2
@@ -3,10 +3,10 @@
|
||||
//
|
||||
// Author:
|
||||
// Atsushi Enomoto <[email protected]>
|
||||
// Pablo Ruiz García <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2008 Novell Inc. http://novell.com
|
||||
//
|
||||
|
||||
// Copyright (C) 2013 Pablo Ruiz García
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@@ -50,6 +50,27 @@ namespace System.ComponentModel.DataAnnotations
|
||||
displayFormat.ApplyFormatInEditMode = true;
|
||||
displayFormat.ConvertEmptyStringToNull = true;
|
||||
displayFormat.DataFormatString = "{0:t}";
|
||||
#if NET_4_0
|
||||
displayFormat.HtmlEncode = true;
|
||||
#endif
|
||||
break;
|
||||
case DataType.Date:
|
||||
displayFormat = new DisplayFormatAttribute ();
|
||||
displayFormat.ApplyFormatInEditMode = true;
|
||||
displayFormat.ConvertEmptyStringToNull = true;
|
||||
displayFormat.DataFormatString = "{0:d}";
|
||||
#if NET_4_0
|
||||
displayFormat.HtmlEncode = true;
|
||||
#endif
|
||||
break;
|
||||
case DataType.Currency:
|
||||
displayFormat = new DisplayFormatAttribute ();
|
||||
displayFormat.ApplyFormatInEditMode = false;
|
||||
displayFormat.ConvertEmptyStringToNull = true;
|
||||
displayFormat.DataFormatString = "{0:C}";
|
||||
#if NET_4_0
|
||||
displayFormat.HtmlEncode = true;
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// EmailAddressAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
// Pablo Ruiz García <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin Inc (http://www.xamarin.com)
|
||||
// Copyright (C) 2013 Pablo Ruiz García
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if NET_4_5
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace System.ComponentModel.DataAnnotations
|
||||
{
|
||||
[AttributeUsageAttribute (AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
|
||||
public class EmailAddressAttribute : DataTypeAttribute
|
||||
{
|
||||
private const string DefaultErrorMessage = "The {0} field is not a valid e-mail address.";
|
||||
// See: http://stackoverflow.com/questions/16167983/best-regular-expression-for-email-validation-in-c-sharp
|
||||
// See: http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains
|
||||
private const string _emailRegexStr = @"[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*" +
|
||||
@"@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-z0-9])?\.)+(?:[A-Za-z]{2}|" +
|
||||
@"com|org|net|edu|gov|cat|mil|biz|info|mobi|name|aero|asia|jobs|museum|coop|travel|post|pro|tel|int|xxx)\b";
|
||||
private static Regex _emailRegex = new Regex (_emailRegexStr, RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
public EmailAddressAttribute ()
|
||||
: base(DataType.EmailAddress)
|
||||
{
|
||||
// XXX: There is no .ctor accepting Func<string> on DataTypeAttribute.. :?
|
||||
base.ErrorMessage = DefaultErrorMessage;
|
||||
}
|
||||
|
||||
public override bool IsValid(object value)
|
||||
{
|
||||
if (value == null)
|
||||
return true;
|
||||
|
||||
if (value is string)
|
||||
{
|
||||
var str = value as string;
|
||||
return !string.IsNullOrEmpty(str) ? _emailRegex.IsMatch(str) : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
//
|
||||
// FileExtensionAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
// Pablo Ruiz García <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin Inc (http://www.xamarin.com)
|
||||
// Copyright (C) 2013 Pablo Ruiz García
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if NET_4_5
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace System.ComponentModel.DataAnnotations
|
||||
{
|
||||
// See: http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.fileextensionsattribute.aspx
|
||||
|
||||
[AttributeUsageAttribute (AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
|
||||
public class FileExtensionsAttribute : DataTypeAttribute
|
||||
{
|
||||
private const string DefaultErrorMessage = "The {0} field only accepts files with the following extensions: {1}.";
|
||||
private const string DefaultExtensions = "png,jpg,jpeg,gif";
|
||||
|
||||
public FileExtensionsAttribute ()
|
||||
: base (DataType.Upload)
|
||||
{
|
||||
// XXX: There is no .ctor accepting Func<string> on DataTypeAttribute.. :?
|
||||
base.ErrorMessage = DefaultErrorMessage;
|
||||
this.Extensions = DefaultExtensions;
|
||||
}
|
||||
|
||||
public string Extensions { get; set; }
|
||||
|
||||
private string[] GetExtensionList ()
|
||||
{
|
||||
return (Extensions ?? "").Split (',');
|
||||
}
|
||||
|
||||
private string GetExtension (string filename)
|
||||
{
|
||||
var parts = filename.Split ('.');
|
||||
return parts.Length > 0 ? parts [parts.Length - 1] : "";
|
||||
}
|
||||
|
||||
public override string FormatErrorMessage (string name)
|
||||
{
|
||||
var extensions = GetExtensionList().Aggregate ((cur, next) => cur + ", " + next);
|
||||
return string.Format (ErrorMessageString, name, extensions);
|
||||
}
|
||||
|
||||
public override bool IsValid(object value)
|
||||
{
|
||||
if (value == null)
|
||||
return true;
|
||||
|
||||
if (value is string)
|
||||
{
|
||||
var str = value as string;
|
||||
var ext = GetExtension (str);
|
||||
return GetExtensionList ().Any (x => string.Equals (x, ext, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
+43
-1
@@ -3,6 +3,7 @@
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
// Pablo Ruiz García <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
@@ -28,22 +29,63 @@
|
||||
|
||||
#if NET_4_5
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace System.ComponentModel.DataAnnotations
|
||||
{
|
||||
[AttributeUsageAttribute (AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
|
||||
public class MaxLengthAttribute : ValidationAttribute
|
||||
{
|
||||
private const string DefaultErrorMessage = "The field {0} must be a string or array type with a maximum length of '{1}'.";
|
||||
private const string InvalidLengthErrorMessage = "MaxLengthAttribute must have a Length value that is greater than zero. " +
|
||||
"Use MaxLength() without parameters to indicate that the string or array can have the maximum allowable length.";
|
||||
private bool _maxLength = true;
|
||||
|
||||
public MaxLengthAttribute ()
|
||||
: base (() => DefaultErrorMessage)
|
||||
{
|
||||
}
|
||||
|
||||
public MaxLengthAttribute (int length)
|
||||
: this ()
|
||||
{
|
||||
Length = length;
|
||||
_maxLength = false;
|
||||
}
|
||||
|
||||
public int Length { get; private set; }
|
||||
|
||||
public override string FormatErrorMessage (string name)
|
||||
{
|
||||
return string.Format (ErrorMessageString, name, Length);
|
||||
}
|
||||
|
||||
public override bool IsValid (object value)
|
||||
{
|
||||
// See: http://msdn.microsoft.com/en-us/library/gg696614.aspx
|
||||
|
||||
if (this.Length == 0 || this.Length < -1)
|
||||
throw new InvalidOperationException (InvalidLengthErrorMessage);
|
||||
|
||||
// Weird, but using 'MaxLength' with no length seems to be valid
|
||||
// and we should be returning true, and not throwing. (pablo)
|
||||
if (value != null && !_maxLength) {
|
||||
|
||||
if (value is string) {
|
||||
return (value as string).Length <= this.Length;
|
||||
}
|
||||
|
||||
if (value is Array) {
|
||||
return (value as Array).Length <= this.Length;
|
||||
}
|
||||
|
||||
// NOTE: from my tests, MS.NET does not support IEnumerable as value. :(
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
+34
-9
@@ -3,6 +3,7 @@
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
// Pablo Ruiz García <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
@@ -28,30 +29,54 @@
|
||||
|
||||
#if NET_4_5
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace System.ComponentModel.DataAnnotations
|
||||
{
|
||||
[AttributeUsageAttribute (AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
|
||||
public class MinLengthAttribute : ValidationAttribute
|
||||
{
|
||||
private const string DefaultErrorMessage = "The field {0} must be a string or array type with a minimum length of '{1}'.";
|
||||
private const string InvalidLengthErrorMessage = "MinLengthAttribute must have a Length value that is zero or greater.";
|
||||
|
||||
public MinLengthAttribute ()
|
||||
{
|
||||
}
|
||||
|
||||
public MinLengthAttribute (int length)
|
||||
{
|
||||
Length = length;
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public override bool IsValid (object value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public int Length { get; private set; }
|
||||
|
||||
public override string FormatErrorMessage (string name)
|
||||
{
|
||||
// TODO:
|
||||
return base.FormatErrorMessage (name);
|
||||
return string.Format (ErrorMessageString, name, Length);
|
||||
}
|
||||
|
||||
public override bool IsValid (object value)
|
||||
{
|
||||
if (this.Length < 0)
|
||||
throw new InvalidOperationException (InvalidLengthErrorMessage);
|
||||
|
||||
if (value != null) {
|
||||
|
||||
if (value is string) {
|
||||
return (value as string).Length >= this.Length;
|
||||
}
|
||||
|
||||
if (value is Array) {
|
||||
return (value as Array).Length >= this.Length;
|
||||
}
|
||||
|
||||
// NOTE: from my tests, MS.NET does not support IEnumerable as value. :(
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// PhoneAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
// Pablo Ruiz García <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin Inc (http://www.xamarin.com)
|
||||
// Copyright (C) 2013 Pablo Ruiz García
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if NET_4_5
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace System.ComponentModel.DataAnnotations
|
||||
{
|
||||
[AttributeUsageAttribute (AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
|
||||
public class PhoneAttribute : DataTypeAttribute
|
||||
{
|
||||
private const string DefaultErrorMessage = "The {0} field is not a valid phone number.";
|
||||
private const string _regexStr = @"^\+?(\d[\d-. ]+)?(\([\d-. ]+\))?[\d-. ]+\d$";
|
||||
private static Regex _regex = new Regex (_regexStr, RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
public PhoneAttribute ()
|
||||
: base(DataType.PhoneNumber)
|
||||
{
|
||||
// XXX: There is no .ctor accepting Func<string> on DataTypeAttribute.. :?
|
||||
base.ErrorMessage = DefaultErrorMessage;
|
||||
}
|
||||
|
||||
public override bool IsValid(object value)
|
||||
{
|
||||
if (value == null)
|
||||
return true;
|
||||
|
||||
if (value is string)
|
||||
{
|
||||
var str = value as string;
|
||||
return !string.IsNullOrEmpty(str) ? _regex.IsMatch(str) : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
+1
@@ -28,6 +28,7 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace System.ComponentModel.DataAnnotations
|
||||
|
||||
+2
-1
@@ -30,6 +30,7 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.ComponentModel;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@@ -60,7 +61,7 @@ namespace System.ComponentModel.DataAnnotations
|
||||
|
||||
public override string FormatErrorMessage (string name)
|
||||
{
|
||||
return string.Format(ErrorMessageString, name, Pattern);
|
||||
return string.Format (ErrorMessageString, name, Pattern);
|
||||
}
|
||||
|
||||
// LAMESPEC: does not throw ValidationException when value does not match the regular expression
|
||||
|
||||
Loaded 100 of 992 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user