Compare commits
767 Commits
es17.11
...
release-0.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f898df0ffa | ||
|
|
0375072540 | ||
|
|
ad3b975d0a | ||
|
|
37e60a1f92 | ||
|
|
c7db4529a3 | ||
|
|
7273f5086d | ||
|
|
4d7e427d7a | ||
|
|
5059f4eb1c | ||
|
|
2ac7633b80 | ||
|
|
e8fa284c79 | ||
|
|
51b602b42a | ||
|
|
50146cebf5 | ||
|
|
1d425d2947 | ||
|
|
74061f83b3 | ||
|
|
692ff182ca | ||
|
|
89110e3568 | ||
|
|
8e9db583cc | ||
|
|
1509d68ca6 | ||
|
|
3709dec5e9 | ||
|
|
ba7886f73d | ||
|
|
0217083d79 | ||
|
|
1260ebf999 | ||
|
|
f3e1c524db | ||
|
|
efeb372631 | ||
|
|
3389973a75 | ||
|
|
5f3749e463 | ||
|
|
0203e0fdc7 | ||
|
|
12d56861e6 | ||
|
|
23de980e57 | ||
|
|
ad5fed84ca | ||
|
|
aa38cf787a | ||
|
|
3702842337 | ||
|
|
2b730186a2 | ||
|
|
dbd5e481b8 | ||
|
|
b61cd7f512 | ||
|
|
0a31cb38a3 | ||
|
|
db448001a1 | ||
|
|
3df1a26220 | ||
|
|
369a63c797 | ||
|
|
52adff29aa | ||
|
|
8a58d62a7e | ||
|
|
36ed6f525c | ||
|
|
815b62153a | ||
|
|
a9cf373443 | ||
|
|
97b549cf83 | ||
|
|
7a619fa7a5 | ||
|
|
0d5011b03e | ||
|
|
8dd0cb29fa | ||
|
|
445a27ddf8 | ||
|
|
171be24d2a | ||
|
|
fb7d5054da | ||
|
|
03bf467ee5 | ||
|
|
fd73af2cf8 | ||
|
|
5504175d00 | ||
|
|
8283979a1e | ||
|
|
3982c46ac4 | ||
|
|
37a68dc778 | ||
|
|
dafd8335d2 | ||
|
|
4324b83cba | ||
|
|
b37a2bd17f | ||
|
|
2a781b9081 | ||
|
|
4bd8a24478 | ||
|
|
f1e7639e6c | ||
|
|
08347da643 | ||
|
|
6cff00428b | ||
|
|
aa6a1f2b8a | ||
|
|
0f42eb2af0 | ||
|
|
6d428cf078 | ||
|
|
bd5238cf10 | ||
|
|
e006b476af | ||
|
|
f07fbbe450 | ||
|
|
00a88e98e5 | ||
|
|
f1498e2a07 | ||
|
|
5899da6197 | ||
|
|
2ff3cff70f | ||
|
|
8fddfd6d22 | ||
|
|
a3ae808a59 | ||
|
|
1d82a55e76 | ||
|
|
cf68ce6681 | ||
|
|
1d89a2bd9f | ||
|
|
ddd9eb646d | ||
|
|
ff97b041a9 | ||
|
|
c3c27c5027 | ||
|
|
64eebd32db | ||
|
|
278a71eaaf | ||
|
|
e615026520 | ||
|
|
3a979915f5 | ||
|
|
4508a76683 | ||
|
|
d40cc5d669 | ||
|
|
3b27e093eb | ||
|
|
eb04ac5405 | ||
|
|
c4e25a3091 | ||
|
|
31cf64f4ad | ||
|
|
face4550f2 | ||
|
|
ee0e3df05f | ||
|
|
18ced46c99 | ||
|
|
7c95e514ad | ||
|
|
e304113984 | ||
|
|
07b3eddefe | ||
|
|
dc2e535fe8 | ||
|
|
bd33aabd93 | ||
|
|
80a1c85844 | ||
|
|
9ba3caba12 | ||
|
|
34c6288032 | ||
|
|
21b03a05fd | ||
|
|
0bd2d16c12 | ||
|
|
e6a727ee42 | ||
|
|
1403cc5c09 | ||
|
|
3bbf356f19 | ||
|
|
b541efcc8f | ||
|
|
082def2b70 | ||
|
|
79607600e6 | ||
|
|
0b6b7f793c | ||
|
|
badc2458c4 | ||
|
|
d4208c59f3 | ||
|
|
4bafa5b3c0 | ||
|
|
c89b19371e | ||
|
|
10ebc12852 | ||
|
|
593e48ec5b | ||
|
|
11b15ec5b7 | ||
|
|
ff713a42ab | ||
|
|
155c45be6c | ||
|
|
09fa1adaab | ||
|
|
425c276051 | ||
|
|
0040e4b0d0 | ||
|
|
b862065c04 | ||
|
|
874677ab7a | ||
|
|
ed200b93dd | ||
|
|
bcccfb22ed | ||
|
|
5c98d7ba4e | ||
|
|
40c6aff423 | ||
|
|
ac9cbb0bd2 | ||
|
|
95c3bbf6e5 | ||
|
|
b955912dc2 | ||
|
|
50223b12f7 | ||
|
|
6c7ba93062 | ||
|
|
743f26c376 | ||
|
|
d256ec3944 | ||
|
|
482f8e41e7 | ||
|
|
9eef812795 | ||
|
|
86fcaa2835 | ||
|
|
897aeb3132 | ||
|
|
48acdea73c | ||
|
|
cbaae12156 | ||
|
|
8344607eb6 | ||
|
|
71d5dc4795 | ||
|
|
3f0b745ecc | ||
|
|
3432e2d8b2 | ||
|
|
fea0f115a0 | ||
|
|
84a12447db | ||
|
|
876f9e02b7 | ||
|
|
e5323dd208 | ||
|
|
77834a3dd8 | ||
|
|
4906345a62 | ||
|
|
487487ad44 | ||
|
|
ef5ba19c46 | ||
|
|
b05ff01262 | ||
|
|
9f1940c46d | ||
|
|
f69ff42564 | ||
|
|
eb3e9f2186 | ||
|
|
03b10bdc14 | ||
|
|
46eb92ac37 | ||
|
|
25218996e0 | ||
|
|
081392529c | ||
|
|
68dbbdea9f | ||
|
|
5abc79b7c3 | ||
|
|
e85213689e | ||
|
|
c5fe539acb | ||
|
|
ac3e969b3c | ||
|
|
98f2efbd68 | ||
|
|
7314e92fe6 | ||
|
|
ab38345c25 | ||
|
|
c873d62efa | ||
|
|
468b2851be | ||
|
|
f1fe5464c6 | ||
|
|
d621987020 | ||
|
|
e541fdcb0c | ||
|
|
5950d768c9 | ||
|
|
413fdaf6cd | ||
|
|
9138ffedfb | ||
|
|
72cc05532c | ||
|
|
145b129b28 | ||
|
|
fbec89f354 | ||
|
|
f59d5cac32 | ||
|
|
4bb8a71c1b | ||
|
|
dd6b74326e | ||
|
|
e52cd6b352 | ||
|
|
ad2a498fc0 | ||
|
|
537bd8241f | ||
|
|
040c1d1c10 | ||
|
|
f3c779cf6e | ||
|
|
6cf35e90c6 | ||
|
|
497fe03d38 | ||
|
|
ca3a520bb9 | ||
|
|
3c755019aa | ||
|
|
3a9b67c8ad | ||
|
|
e21da4a591 | ||
|
|
69bc4d568c | ||
|
|
cf8d25c4e5 | ||
|
|
2b9ca86501 | ||
|
|
2f43660628 | ||
|
|
d8476edf36 | ||
|
|
67e6b460b3 | ||
|
|
962154fc81 | ||
|
|
645b35590b | ||
|
|
a1354136fa | ||
|
|
945ef79857 | ||
|
|
2c4df29877 | ||
|
|
e6687c7791 | ||
|
|
754d3f670c | ||
|
|
8e420de8ec | ||
|
|
6dc1c0d2b0 | ||
|
|
80d68699b1 | ||
|
|
fcdf4e456e | ||
|
|
c92c2a91b4 | ||
|
|
1ab3832685 | ||
|
|
da9fa4ecc2 | ||
|
|
abdd68863d | ||
|
|
83a8ad3879 | ||
|
|
1b55b09b64 | ||
|
|
4cf3393a13 | ||
|
|
4486df14cc | ||
|
|
60574ee85f | ||
|
|
7a6c51e47e | ||
|
|
d8c420c4b7 | ||
|
|
790aa40591 | ||
|
|
e506397406 | ||
|
|
434f031680 | ||
|
|
a6c52c0a7e | ||
|
|
d67e01eea6 | ||
|
|
e36533bc99 | ||
|
|
d90ecbd5fe | ||
|
|
20281bc922 | ||
|
|
6b3a2d3b43 | ||
|
|
83346c92a7 | ||
|
|
6b50ab8c55 | ||
|
|
c8efa04147 | ||
|
|
37860f43b5 | ||
|
|
65a998cec3 | ||
|
|
7207a021be | ||
|
|
32373addfa | ||
|
|
e16f03b1c2 | ||
|
|
1698a06ea0 | ||
|
|
da3594db50 | ||
|
|
bfa620eee3 | ||
|
|
1423412f31 | ||
|
|
0f51925ec1 | ||
|
|
b6784ee35c | ||
|
|
ab5b43d8ef | ||
|
|
c7366615cf | ||
|
|
b60c41ee1b | ||
|
|
f9dfeb0034 | ||
|
|
5e35bc59a9 | ||
|
|
2ed6d92e53 | ||
|
|
33d3071cad | ||
|
|
35dde23976 | ||
|
|
390c05b056 | ||
|
|
011f8746d6 | ||
|
|
0335226e8b | ||
|
|
68e4ac9a8f | ||
|
|
f6b293d4ae | ||
|
|
89572b4f33 | ||
|
|
8b4f774bab | ||
|
|
52e6944f37 | ||
|
|
bf056154d8 | ||
|
|
a3c50956f1 | ||
|
|
0d67533c83 | ||
|
|
c0c206e9ae | ||
|
|
36601fd3a4 | ||
|
|
9a85c24c0d | ||
|
|
5ef19021eb | ||
|
|
7495d0e6a7 | ||
|
|
f27c1f97a3 | ||
|
|
b96029a750 | ||
|
|
9ef10c749a | ||
|
|
0aa3d81b22 | ||
|
|
5d17b0dd29 | ||
|
|
5e2c2af18a | ||
|
|
de157be6f1 | ||
|
|
f601ae1c8b | ||
|
|
f6f94add80 | ||
|
|
a70e75f729 | ||
|
|
2dd43ad829 | ||
|
|
108396bd91 | ||
|
|
e9b7fc4c93 | ||
|
|
0dd2812574 | ||
|
|
d961544b8b | ||
|
|
3313e9cf81 | ||
|
|
39b5a70979 | ||
|
|
379e806166 | ||
|
|
c1e08a1bdc | ||
|
|
af21520e5d | ||
|
|
effc6ba81d | ||
|
|
019fb539ae | ||
|
|
03938b43c3 | ||
|
|
e70d67aed5 | ||
|
|
de38f46d1d | ||
|
|
8c79a64f0c | ||
|
|
fff7a5c96d | ||
|
|
1b92403045 | ||
|
|
59505ccdc4 | ||
|
|
8ae4a30ee8 | ||
|
|
8ffe2a8f73 | ||
|
|
800815c8dd | ||
|
|
769f2bb5a8 | ||
|
|
483f065ef1 | ||
|
|
8ff055803d | ||
|
|
3b30f4b994 | ||
|
|
f71bbc07e8 | ||
|
|
faafa894c2 | ||
|
|
89cd5a3b44 | ||
|
|
9b9bc1f190 | ||
|
|
6feaf5757f | ||
|
|
2b7043f670 | ||
|
|
6f4ec89404 | ||
|
|
cdfc6851e7 | ||
|
|
e0ec84611e | ||
|
|
2234d3712b | ||
|
|
c89ccfa768 | ||
|
|
1a88388ffe | ||
|
|
5eab38778a | ||
|
|
9d457bb978 | ||
|
|
42be0b2a4e | ||
|
|
48d4d26cda | ||
|
|
182749d010 | ||
|
|
fd0912904c | ||
|
|
3032b91ff7 | ||
|
|
772b88f257 | ||
|
|
a1cc2d1d1a | ||
|
|
9f90bf56a5 | ||
|
|
dbea0e509b | ||
|
|
a3f28e3945 | ||
|
|
379a6193e9 | ||
|
|
03d9c3785c | ||
|
|
612915c918 | ||
|
|
ff967d6332 | ||
|
|
8d75a04068 | ||
|
|
1b446caa27 | ||
|
|
202ad2861b | ||
|
|
24b1be7482 | ||
|
|
44857d28ec | ||
|
|
e3597c0f3b | ||
|
|
0cce4d8244 | ||
|
|
aab910ab64 | ||
|
|
257ede7586 | ||
|
|
b58e4e19e1 | ||
|
|
6ec37c90a2 | ||
|
|
49c3e8e789 | ||
|
|
cc11debf08 | ||
|
|
b71a22d040 | ||
|
|
7022206a73 | ||
|
|
b715d674ca | ||
|
|
02f5bdd801 | ||
|
|
203d51a97e | ||
|
|
733296e71e | ||
|
|
0a497b9a4d | ||
|
|
4ed91a91a2 | ||
|
|
a76eb75267 | ||
|
|
2c94a98730 | ||
|
|
cc960310e9 | ||
|
|
d9daac67d9 | ||
|
|
955f73dee9 | ||
|
|
137ed3888c | ||
|
|
8382e8f134 | ||
|
|
713978d70f | ||
|
|
b78c44f4a1 | ||
|
|
0b7ea3c427 | ||
|
|
1e7b370859 | ||
|
|
8c02b0d546 | ||
|
|
13b09adc8c | ||
|
|
9f2abab670 | ||
|
|
a46c08de11 | ||
|
|
bc2e8b8ee2 | ||
|
|
36493b4324 | ||
|
|
a09908c048 | ||
|
|
d96ee66a32 | ||
|
|
abd67c8caa | ||
|
|
7669ccfc1d | ||
|
|
53496e010b | ||
|
|
3a6e3592ae | ||
|
|
cef6f30251 | ||
|
|
00ffa50054 | ||
|
|
07f9a8cec7 | ||
|
|
cac126f2f1 | ||
|
|
c53d4d37a7 | ||
|
|
16cab53fb4 | ||
|
|
a2bf68e18a | ||
|
|
214255c4b9 | ||
|
|
082b8902ea | ||
|
|
ee9722fa18 | ||
|
|
4a81d02d12 | ||
|
|
0f5ae7e153 | ||
|
|
179dbceaba | ||
|
|
45292e0248 | ||
|
|
a38fca267b | ||
|
|
d4266a83ec | ||
|
|
83a181ebf1 | ||
|
|
54ecd2b1e8 | ||
|
|
da8a216448 | ||
|
|
085b520879 | ||
|
|
c115a40922 | ||
|
|
6f600362e3 | ||
|
|
bd36aa8b04 | ||
|
|
812f521c88 | ||
|
|
beb1bd1599 | ||
|
|
9bbcdc9927 | ||
|
|
0d637d478a | ||
|
|
8e4e7a5084 | ||
|
|
95d44890d9 | ||
|
|
161a5c720b | ||
|
|
35a4cd7df9 | ||
|
|
70ee7ff47a | ||
|
|
c9343688f3 | ||
|
|
f804a705d5 | ||
|
|
f17f785ee3 | ||
|
|
926c0a79b7 | ||
|
|
fb7854fbcc | ||
|
|
663a39d2ec | ||
|
|
6fb36da9ac | ||
|
|
3fbd81aeb1 | ||
|
|
6344f964fa | ||
|
|
14a2c01f41 | ||
|
|
79e12b8d04 | ||
|
|
aec0136739 | ||
|
|
7fd4cdbe44 | ||
|
|
9f53287226 | ||
|
|
eaa99c9c61 | ||
|
|
5f492d6fb6 | ||
|
|
c3f5376ef5 | ||
|
|
21e973f8a4 | ||
|
|
dec1958909 | ||
|
|
1453873b6c | ||
|
|
8255dfd996 | ||
|
|
e66c666e64 | ||
|
|
fcdc164214 | ||
|
|
4c36d75ef3 | ||
|
|
09030a27d9 | ||
|
|
b9ca22006b | ||
|
|
593b48fe90 | ||
|
|
735730b5a0 | ||
|
|
035a133b5b | ||
|
|
0144e97d69 | ||
|
|
26bfd72f5f | ||
|
|
88542c2762 | ||
|
|
12fc54a403 | ||
|
|
eb44eef885 | ||
|
|
c2b66d6ca6 | ||
|
|
6758c4aef4 | ||
|
|
6408bec628 | ||
|
|
f77ba9ccd8 | ||
|
|
c105c267e7 | ||
|
|
19da4d6fd0 | ||
|
|
a9e2dc1135 | ||
|
|
4cd1b67607 | ||
|
|
34bb793599 | ||
|
|
c836d75191 | ||
|
|
3739909e43 | ||
|
|
142dbc39b4 | ||
|
|
b17887d634 | ||
|
|
f443087e71 | ||
|
|
e5eb11b4e7 | ||
|
|
720d8be08a | ||
|
|
ed04b7fba0 | ||
|
|
4c9e7a4331 | ||
|
|
cc6992a6fc | ||
|
|
71c851ca39 | ||
|
|
900ed8baea | ||
|
|
dba55fcfd9 | ||
|
|
456299ccdf | ||
|
|
810208f176 | ||
|
|
27c637b066 | ||
|
|
a0df04a7f2 | ||
|
|
bc5d20b221 | ||
|
|
7ba3eb9ecd | ||
|
|
2b14a40898 | ||
|
|
aa20a1423f | ||
|
|
34c8cfa427 | ||
|
|
f7dcadccd5 | ||
|
|
f24df1d745 | ||
|
|
5adf40a9ed | ||
|
|
f20bc42b76 | ||
|
|
19637b616b | ||
|
|
a4df57a7ac | ||
|
|
df59ae579b | ||
|
|
738eb7555f | ||
|
|
d397d4e35d | ||
|
|
eeaa47d4f1 | ||
|
|
0db4317a49 | ||
|
|
668847f8e8 | ||
|
|
e7fd7af2c5 | ||
|
|
24a5c7613d | ||
|
|
d9f6cbe80e | ||
|
|
95ec2e77df | ||
|
|
19b5edd9b4 | ||
|
|
d25146dd27 | ||
|
|
ab1c696837 | ||
|
|
dae8e1d67d | ||
|
|
888bc61522 | ||
|
|
8291905da1 | ||
|
|
d9ba97d33b | ||
|
|
33eddd9197 | ||
|
|
458cb56f75 | ||
|
|
88c015470e | ||
|
|
58767bb1c1 | ||
|
|
f68a713c48 | ||
|
|
0414cd4501 | ||
|
|
284d7826c8 | ||
|
|
dff267cd58 | ||
|
|
c2f7c198e0 | ||
|
|
8034123683 | ||
|
|
b3ef7c846b | ||
|
|
111812c4e9 | ||
|
|
92d8357d09 | ||
|
|
64060cfa41 | ||
|
|
d3239ec41b | ||
|
|
7b1557a52a | ||
|
|
c9a4ebcb23 | ||
|
|
3f899f6aae | ||
|
|
18684d167b | ||
|
|
32bb75b9dc | ||
|
|
d06bc76944 | ||
|
|
86825854ca | ||
|
|
774cd004db | ||
|
|
c300cf5b6e | ||
|
|
68247a1849 | ||
|
|
22fd7490fe | ||
|
|
8b6e9273fa | ||
|
|
76fa3e9ff5 | ||
|
|
1e3770d724 | ||
|
|
840ae1e6e4 | ||
|
|
5626e03aa8 | ||
|
|
4bcea900a6 | ||
|
|
b1f5065e63 | ||
|
|
c37fe9ad79 | ||
|
|
2e53f7e0c4 | ||
|
|
512f2d2ce5 | ||
|
|
92105ca7b3 | ||
|
|
f0c6eec23d | ||
|
|
32197d0513 | ||
|
|
11286eeeef | ||
|
|
fb8412fcae | ||
|
|
9ec87a4329 | ||
|
|
0c7e6c08e7 | ||
|
|
c1120a4226 | ||
|
|
5c0cae35ef | ||
|
|
7bd5cdc232 | ||
|
|
ef85c07603 | ||
|
|
10db3c28a5 | ||
|
|
54dc7de189 | ||
|
|
2244d101ea | ||
|
|
244fdf1b02 | ||
|
|
3c9fce293f | ||
|
|
eee085dd5a | ||
|
|
2d9e2d12a0 | ||
|
|
9fef2d71f0 | ||
|
|
6a581f6d62 | ||
|
|
ed8f5d694f | ||
|
|
c20600f281 | ||
|
|
53ccaa3fde | ||
|
|
22afbd7ed0 | ||
|
|
f6b362217c | ||
|
|
e9ccf855b3 | ||
|
|
4d0148d562 | ||
|
|
ec6cc5f2b8 | ||
|
|
40018d36eb | ||
|
|
8e18329063 | ||
|
|
c372494713 | ||
|
|
10f4a99ee1 | ||
|
|
e9085c614c | ||
|
|
f7d3f519a7 | ||
|
|
4eb22d0272 | ||
|
|
bbcc9ef44b | ||
|
|
801caa4e69 | ||
|
|
1b49445077 | ||
|
|
f005d8bb06 | ||
|
|
a278537f7b | ||
|
|
78b5b6f5fe | ||
|
|
a215c1e4d2 | ||
|
|
fe3726677b | ||
|
|
94d4909644 | ||
|
|
0da4b7d61b | ||
|
|
5c5ba9f038 | ||
|
|
d65c8de1d2 | ||
|
|
3d93dbc66d | ||
|
|
436f2afd00 | ||
|
|
73284575d4 | ||
|
|
e9b05ffc0b | ||
|
|
012bb2f6c9 | ||
|
|
e883163fe9 | ||
|
|
e5fb3f8328 | ||
|
|
302ae8d030 | ||
|
|
694c0a193c | ||
|
|
4075b08b7e | ||
|
|
65800371cd | ||
|
|
2c6196017e | ||
|
|
5a155e0cee | ||
|
|
08bec49da4 | ||
|
|
4940ddb8f5 | ||
|
|
6599bf1a07 | ||
|
|
0ef88eadf5 | ||
|
|
e1ef4c390e | ||
|
|
11baeefe1c | ||
|
|
ac7f58722d | ||
|
|
acd395376a | ||
|
|
a7a27bee0a | ||
|
|
fc0a25acc9 | ||
|
|
0d363f065b | ||
|
|
51b70a2490 | ||
|
|
917f80c0c8 | ||
|
|
73e5fd6cd6 | ||
|
|
0abab83566 | ||
|
|
f764e63b45 | ||
|
|
0a1c4676a4 | ||
|
|
8a38519fb0 | ||
|
|
54c9addb30 | ||
|
|
9dd1439a2f | ||
|
|
30d4843a5b | ||
|
|
3e73298806 | ||
|
|
01b16d0a82 | ||
|
|
ac97d6019b | ||
|
|
4e2f0dbc72 | ||
|
|
9d1fb56cc1 | ||
|
|
bc98c5a317 | ||
|
|
681bb19ab7 | ||
|
|
026b4f8682 | ||
|
|
4a87d5822b | ||
|
|
f74ac66569 | ||
|
|
de77802546 | ||
|
|
f7cf91500c | ||
|
|
05b4bd90f5 | ||
|
|
6188f99615 | ||
|
|
4fb42df5fb | ||
|
|
f1d8d18811 | ||
|
|
28a699e5f2 | ||
|
|
591cfb6cfa | ||
|
|
f4c472cb9f | ||
|
|
94c5c90eaa | ||
|
|
545db51fc9 | ||
|
|
20bf9efaa0 | ||
|
|
a168cc62e7 | ||
|
|
b9e89758ce | ||
|
|
19da9436ff | ||
|
|
32ff399442 | ||
|
|
c7440a2ca0 | ||
|
|
63cd0610ec | ||
|
|
c772fc5194 | ||
|
|
0fda0dc34c | ||
|
|
f22f42c463 | ||
|
|
569a587ffd | ||
|
|
6317ca2fe5 | ||
|
|
12d9dcfff5 | ||
|
|
824750e748 | ||
|
|
c544da3561 | ||
|
|
e5e9f9486e | ||
|
|
720351871b | ||
|
|
54b95650c5 | ||
|
|
c553bd1e1e | ||
|
|
64cf2b6936 | ||
|
|
85cf39f3c6 | ||
|
|
af852498be | ||
|
|
dfa30471e3 | ||
|
|
094dc09354 | ||
|
|
3af8d34f0f | ||
|
|
d0ca77f104 | ||
|
|
3c0d342704 | ||
|
|
e78d34774e | ||
|
|
eb57cb1973 | ||
|
|
3d669e3043 | ||
|
|
e638eeaae4 | ||
|
|
5d63c63a39 | ||
|
|
a863e495ae | ||
|
|
327196a3cf | ||
|
|
805874dc9c | ||
|
|
11256d697d | ||
|
|
b389d532b7 | ||
|
|
a0e570226c | ||
|
|
2710cae1da | ||
|
|
8cd53b87eb | ||
|
|
6bef8ec387 | ||
|
|
f86abed2ff | ||
|
|
683aa808ad | ||
|
|
7717502363 | ||
|
|
eefd98c630 | ||
|
|
7a31e80f90 | ||
|
|
aed8d1a516 | ||
|
|
ab19cc2b16 | ||
|
|
d4da754a9c | ||
|
|
ee8bce82b2 | ||
|
|
764372f072 | ||
|
|
8ddc27b9cb | ||
|
|
5d63551002 | ||
|
|
03851ac02e | ||
|
|
7e2a847e39 | ||
|
|
0759dfe1a7 | ||
|
|
dae6d64f82 | ||
|
|
f1f1f5fbf6 | ||
|
|
548a320448 | ||
|
|
6bb5b0bac8 | ||
|
|
e3d8fbb263 | ||
|
|
caf6d8c528 | ||
|
|
e880fbde14 | ||
|
|
9e27a52670 | ||
|
|
816e5b4d6c | ||
|
|
9a4a1a3a40 | ||
|
|
93b74d0d5e | ||
|
|
925fdcd979 | ||
|
|
2f1e4e561b | ||
|
|
5506ab09dc | ||
|
|
544b5784ae | ||
|
|
1359a1ceae | ||
|
|
fc7c2d151f | ||
|
|
4e6935655f | ||
|
|
d940da7b13 | ||
|
|
31619fc88e | ||
|
|
bf781a9d25 | ||
|
|
31750efb8e | ||
|
|
f83c5d2643 | ||
|
|
c59bc37a40 | ||
|
|
b674dbddf7 | ||
|
|
ed5f8a9740 | ||
|
|
2c42c0dd1a | ||
|
|
d64e01641b | ||
|
|
fa35ab07a0 | ||
|
|
0bf10c633f | ||
|
|
9ef3391b26 | ||
|
|
bc1e6653ae | ||
|
|
b9ccf20d53 | ||
|
|
3e7f107b36 | ||
|
|
aa8c2d0a95 | ||
|
|
65cd9e8780 | ||
|
|
cb595d27f4 | ||
|
|
aaa10d178a | ||
|
|
1052c10b8d | ||
|
|
3083f378a6 | ||
|
|
8357bf5d72 | ||
|
|
8f3c7beba8 | ||
|
|
5a779fbb57 | ||
|
|
4559b7fef5 | ||
|
|
7dc33a52f6 | ||
|
|
de347f6c98 | ||
|
|
308fa7f2e7 | ||
|
|
a06fbd5f0b | ||
|
|
098032e815 | ||
|
|
893fce5706 | ||
|
|
839cb26d7e | ||
|
|
b1952a6e2c | ||
|
|
3b231019ea | ||
|
|
60b99e48d4 | ||
|
|
987c18198e | ||
|
|
5980a724cc | ||
|
|
7448567c53 | ||
|
|
ea4be7219b | ||
|
|
9a3e12fe12 | ||
|
|
c8c23ca064 | ||
|
|
4daf5b727a | ||
|
|
fe76c9eac5 | ||
|
|
81d91930ef | ||
|
|
7e024b589a | ||
|
|
65559b8b82 | ||
|
|
179ac3a128 | ||
|
|
6179b0f223 | ||
|
|
77c028a9cd | ||
|
|
09a1c2d34a | ||
|
|
2d99813b5d | ||
|
|
6cf3589a43 | ||
|
|
1b972b3e24 | ||
|
|
a99db5fd43 |
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
EIFGENs
|
||||
tests/temp/
|
||||
.svn/
|
||||
*.swp
|
||||
0
.gitmodules
vendored
Normal file
0
.gitmodules
vendored
Normal file
38
CHANGELOGS.txt
Normal file
38
CHANGELOGS.txt
Normal file
@@ -0,0 +1,38 @@
|
||||
History for Eiffel-Web-Framework
|
||||
|
||||
[2011-09-23] Jocelyn
|
||||
* library "ewsgi":
|
||||
- NEW simple autotest cases using Nino web server
|
||||
-fixed issue with RAW_POST_DATA being added in form_data_parameters
|
||||
instead of meta_variables ...
|
||||
- Implemented WGI_VALUE for parameter's type (query_parameter,
|
||||
form_data_parameter, item ...)
|
||||
* Nino connector: added feature to shutdown the server from the WGI application
|
||||
* NEW library "http_client": a new library to perform simple http requests
|
||||
such as get, head, post, put, ... (currently implemented with Eiffel cURL)
|
||||
* NEW library "http_authorization": added simple library to support
|
||||
HTTP_AUTHORIZATION. For now only "Basic" auth type is supported ..
|
||||
|
||||
[2011-09-22] Javier
|
||||
* NEW Example: added partial Restbuck example
|
||||
|
||||
[2011-09-21] Jocelyn
|
||||
* Nino connector: fixed an issue with missing value for Content-Type and Content-Length
|
||||
|
||||
[2011-09-13] Jocelyn
|
||||
* library "router": now using a generic design to allow customization of
|
||||
request handler context class.
|
||||
* NEW library "server/request/rest": first attempt to provide a library to
|
||||
help building RESTful application (the interfaces are likely to change
|
||||
soon) EXPERIMENTAL
|
||||
|
||||
[2011-09-09] Jocelyn
|
||||
* library "uri-template": better support for {/vars} and {?vars}
|
||||
|
||||
[2011-09-07] Jocelyn
|
||||
* library "router": now routing depends on uri (or uri template) and request methods
|
||||
* Nino connector: Fixed issue where HTTP_ prefix were missing for header meta variable.
|
||||
|
||||
[2011-09-07] Jocelyn
|
||||
* changelog: starting to write down changelogs file
|
||||
|
||||
20
LICENSE
Normal file
20
LICENSE
Normal file
@@ -0,0 +1,20 @@
|
||||
Eiffel Forum License, version 2
|
||||
|
||||
1. Permission is hereby granted to use, copy, modify and/or distribute
|
||||
this package, provided that:
|
||||
* copyright notices are retained unchanged,
|
||||
* any distribution of this package, whether modified or not,
|
||||
includes this license text.
|
||||
|
||||
2. Permission is hereby also granted to distribute binary programs which
|
||||
depend on this package. If the binary program depends on a modified
|
||||
version of this package, you are encouraged to publicly release the
|
||||
modified version of this package.
|
||||
|
||||
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT WARRANTY. ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE TO ANY PARTY FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THIS PACKAGE.
|
||||
|
||||
84
README.md
Normal file
84
README.md
Normal file
@@ -0,0 +1,84 @@
|
||||
# Eiffel Web Framework
|
||||
|
||||
## Version: v0.1
|
||||
|
||||
|
||||
## Overview
|
||||
|
||||
Official project site for Eiffel Web Framework:
|
||||
|
||||
* http://eiffelwebframework.github.com/EWF/
|
||||
|
||||
For more information please have a look at the related wiki:
|
||||
|
||||
* https://github.com/EiffelWebFramework/EWF/wiki
|
||||
|
||||
For download, check
|
||||
* https://github.com/EiffelWebFramework/EWF/downloads
|
||||
|
||||
## Requirements
|
||||
|
||||
* Developped using EiffelStudio 7.0 (on Windows, Linux)
|
||||
* Tested using EiffelStudio 7.0 with "jenkins" CI server (and v6.8 for time to time)
|
||||
* The code have to allow __void-safe__ compilation and non void-safe system (see [more about void-safety](http://docs.eiffel.com/book/method/void-safe-programming-eiffel) )
|
||||
|
||||
## How to get the source code?
|
||||
|
||||
Using git version >= 1.6.5
|
||||
* git clone --recursive https://github.com/EiffelWebFramework/EWF.git
|
||||
|
||||
Otherwise, try
|
||||
* git clone https://github.com/EiffelWebFramework/EWF.git
|
||||
* cd Eiffel-Web-Framework
|
||||
* git submodule update --init
|
||||
* git submodule foreach --recursive git checkout master
|
||||
|
||||
An alternative to the last 2 instructions is to use the script from tools folder:
|
||||
* cd tools
|
||||
* update_git_working_copy
|
||||
|
||||
* And to build the required and related Clibs
|
||||
* cd contrib/ise_library/cURL
|
||||
* geant compile
|
||||
|
||||
## Libraries under 'library'
|
||||
|
||||
### server
|
||||
* __ewsgi__: Eiffel Web Server Gateway Interface [read more](library/server/ewsgi)
|
||||
* connectors: various web server connectors for EWSGI
|
||||
* libfcgi: Wrapper for libfcgi SDK
|
||||
* __wsf__: Web Server Framework [read more](library/server/wsf)
|
||||
* include URL dispatching/routing based on uri, uri_template, or custom [read more](library/server/wsf/router)
|
||||
|
||||
### protocol
|
||||
* __http__: HTTP related classes, constants for status code, content types, ... [read more](library/protocol/http)
|
||||
* __uri_template__: URI Template library (parsing and expander) [read more](library/protocol/uri_template)
|
||||
* __CONNEG__: CONNEG library (Content-type Negociation) [read more](library/protocol/CONNEG)
|
||||
|
||||
### client
|
||||
* __http_client__: simple HTTP client based on cURL [read more](library/client/http_client)
|
||||
|
||||
### text
|
||||
* __encoder__: Various simpler encoders: base64, url-encoder, xml entities, html entities [read more](library/text/encoder)
|
||||
|
||||
### Others
|
||||
* error: very simple/basic library to handle error
|
||||
|
||||
## External libraries under 'contrib'
|
||||
* [Eiffel Web Nino](contrib/library/server/nino)
|
||||
* contrib/ise_library/cURL
|
||||
* contrib/ise_library/math/eapml
|
||||
* contrib/ise_library/text/encryption/eel
|
||||
* contrib/library/text/parser/json
|
||||
|
||||
## Draft folder = call for contribution ##
|
||||
### library/server/request ###
|
||||
* request
|
||||
* rest: (experimental) "a" RESTful library to help building RESTful services
|
||||
|
||||
## Examples
|
||||
..
|
||||
|
||||
|
||||
For more information please have a look at the related wiki:
|
||||
* https://github.com/EiffelWebFramework/EWF/wiki
|
||||
1
VERSION.txt
Normal file
1
VERSION.txt
Normal file
@@ -0,0 +1 @@
|
||||
Version v0.1
|
||||
35
build.eant
Normal file
35
build.eant
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<project name="build_library" default="help">
|
||||
<description>
|
||||
description: "Compile Eiffel Web Framework"
|
||||
</description>
|
||||
|
||||
<target name="help">
|
||||
<echo message="usage:"/>
|
||||
<echo message=" geant compile"/>
|
||||
<echo message=" geant clean"/>
|
||||
<echo message=" geant clobber"/>
|
||||
</target>
|
||||
|
||||
<target name="compile" >
|
||||
<echo message="- Compile EWF" />
|
||||
<geant target="_build_tpl_" arguments="compile" />
|
||||
</target>
|
||||
|
||||
<target name="clean" >
|
||||
<echo message="- Clean EWF" />
|
||||
<geant target="_build_tpl_" arguments="clean" />
|
||||
</target>
|
||||
|
||||
<target name="clobber" >
|
||||
<echo message="- Clobber EWF" />
|
||||
<geant target="_build_tpl_" arguments="clobber" />
|
||||
</target>
|
||||
|
||||
<target name="_build_tpl_" >
|
||||
<argument name="_target_name" />
|
||||
<geant target="${_target_name}" dir="contrib" file="build.eant" reuse_variables="true" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
35
contrib/build.eant
Normal file
35
contrib/build.eant
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<project name="build_library" default="help">
|
||||
<description>
|
||||
description: "Compile Eiffel Web Framework / Contrib"
|
||||
</description>
|
||||
|
||||
<target name="help">
|
||||
<echo message="usage:"/>
|
||||
<echo message=" geant compile"/>
|
||||
<echo message=" geant clean"/>
|
||||
<echo message=" geant clobber"/>
|
||||
</target>
|
||||
|
||||
<target name="compile" >
|
||||
<echo message="- Compile contrib" />
|
||||
<geant target="_build_tpl_" arguments="compile" />
|
||||
</target>
|
||||
|
||||
<target name="clean" >
|
||||
<echo message="- Clean contrib" />
|
||||
<geant target="_build_tpl_" arguments="clean" />
|
||||
</target>
|
||||
|
||||
<target name="clobber" >
|
||||
<echo message="- Clobber contrib" />
|
||||
<geant target="_build_tpl_" arguments="clobber" />
|
||||
</target>
|
||||
|
||||
<target name="_build_tpl_" >
|
||||
<argument name="_target_name" />
|
||||
<geant target="${_target_name}" dir="ise_library" file="build.eant" reuse_variables="true" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
35
contrib/ise_library/build.eant
Normal file
35
contrib/ise_library/build.eant
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<project name="build_library" default="help">
|
||||
<description>
|
||||
description: "Compile Eiffel Web Framework / Contrib / ISE library"
|
||||
</description>
|
||||
|
||||
<target name="help">
|
||||
<echo message="usage:"/>
|
||||
<echo message=" geant compile"/>
|
||||
<echo message=" geant clean"/>
|
||||
<echo message=" geant clobber"/>
|
||||
</target>
|
||||
|
||||
<target name="compile" >
|
||||
<echo message="- Compile ise_library" />
|
||||
<geant target="_build_tpl_" arguments="compile" />
|
||||
</target>
|
||||
|
||||
<target name="clean" >
|
||||
<echo message="- Clean ise_library" />
|
||||
<geant target="_build_tpl_" arguments="clean" />
|
||||
</target>
|
||||
|
||||
<target name="clobber" >
|
||||
<echo message="- Clobber ise_library" />
|
||||
<geant target="_build_tpl_" arguments="clobber" />
|
||||
</target>
|
||||
|
||||
<target name="_build_tpl_" >
|
||||
<argument name="_target_name" />
|
||||
<geant target="${_target_name}" dir="cURL" file="build.eant" reuse_variables="true" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
93
contrib/ise_library/cURL-safe.ecf
Normal file
93
contrib/ise_library/cURL-safe.ecf
Normal file
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-5-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-5-0 http://www.eiffel.com/developers/xml/configuration-1-5-0.xsd" name="curl" uuid="D51EF190-6157-4B47-8E73-FA93DCBB7A71" library_target="curl">
|
||||
<target name="curl">
|
||||
<description>cURL: libcURL wrapper library for Eiffel.
|
||||
Copyright (c) 1984-2006, Eiffel Software and others.
|
||||
Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt).</description>
|
||||
<root all_classes="true"/>
|
||||
<file_rule>
|
||||
<exclude>/\.svn$</exclude>
|
||||
<exclude>/EIFGEN.{0,1}$</exclude>
|
||||
<exclude>/temp$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true" cat_call_detection="false" is_attached_by_default="true" void_safety="all" namespace="EiffelSoftware.Library">
|
||||
</option>
|
||||
<setting name="dotnet_naming_convention" value="true"/>
|
||||
<external_include location="$(ECF_CONFIG_PATH)\cURL\spec\include">
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
</condition>
|
||||
</external_include>
|
||||
<external_include location="$(ECF_CONFIG_PATH)/cURL/spec/include">
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
</condition>
|
||||
</external_include>
|
||||
<external_object location="$(ECF_CONFIG_PATH)/cURL/spec/$(ISE_PLATFORM)/lib/eiffel_curl.o">
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
<multithreaded value="false"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<external_object location="$(ECF_CONFIG_PATH)/cURL/spec/$(ISE_PLATFORM)/lib/MTeiffel_curl.o">
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
<multithreaded value="true"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<external_object location="$(ECF_CONFIG_PATH)\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\eiffel_curl.lib">
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
<multithreaded value="false"/>
|
||||
<dotnet value="false"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<external_object location="$(ECF_CONFIG_PATH)\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\mteiffel_curl.lib">
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
<multithreaded value="true"/>
|
||||
<dotnet value="false"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<external_object location="$(ECF_CONFIG_PATH)\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\ileiffel_curl.lib">
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
<dotnet value="true"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<library name="api_wrapper" location="$ISE_LIBRARY\library\api_wrapper\api_wrapper-safe.ecf"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<cluster name="curl" location=".\cURL" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/spec$</exclude>
|
||||
<exclude>/Clib$</exclude>
|
||||
</file_rule>
|
||||
<file_rule>
|
||||
<exclude>/gtk$</exclude>
|
||||
<exclude>/mac$</exclude>
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
</condition>
|
||||
</file_rule>
|
||||
<file_rule>
|
||||
<exclude>/mswin$</exclude>
|
||||
<exclude>/gtk$</exclude>
|
||||
<condition>
|
||||
<platform value="macintosh"/>
|
||||
<custom name="vision_implementation" value="cocoa"/>
|
||||
</condition>
|
||||
</file_rule>
|
||||
<file_rule>
|
||||
<exclude>/mswin$</exclude>
|
||||
<exclude>/mac$</exclude>
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
<custom name="vision_implementation" excluded_value="cocoa"/>
|
||||
</condition>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
<target name="curl_dotnet" extends="curl">
|
||||
<setting name="msil_generation" value="true"/>
|
||||
</target>
|
||||
</system>
|
||||
93
contrib/ise_library/cURL.ecf
Normal file
93
contrib/ise_library/cURL.ecf
Normal file
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-5-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-5-0 http://www.eiffel.com/developers/xml/configuration-1-5-0.xsd" name="curl" uuid="D51EF190-6157-4B47-8E73-FA93DCBB7A71" library_target="curl">
|
||||
<target name="curl">
|
||||
<description>cURL: libcURL wrapper library for Eiffel.
|
||||
Copyright (c) 1984-2006, Eiffel Software and others.
|
||||
Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt).</description>
|
||||
<root all_classes="true"/>
|
||||
<file_rule>
|
||||
<exclude>/\.svn$</exclude>
|
||||
<exclude>/EIFGEN.{0,1}$</exclude>
|
||||
<exclude>/temp$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" namespace="EiffelSoftware.Library">
|
||||
</option>
|
||||
<setting name="dotnet_naming_convention" value="true"/>
|
||||
<external_include location="$(ECF_CONFIG_PATH)\cURL\spec\include">
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
</condition>
|
||||
</external_include>
|
||||
<external_include location="$(ECF_CONFIG_PATH)/cURL/spec/include">
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
</condition>
|
||||
</external_include>
|
||||
<external_object location="$(ECF_CONFIG_PATH)/cURL/spec/$(ISE_PLATFORM)/lib/eiffel_curl.o">
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
<multithreaded value="false"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<external_object location="$(ECF_CONFIG_PATH)/cURL/spec/$(ISE_PLATFORM)/lib/MTeiffel_curl.o">
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
<multithreaded value="true"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<external_object location="$(ECF_CONFIG_PATH)\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\eiffel_curl.lib">
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
<multithreaded value="false"/>
|
||||
<dotnet value="false"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<external_object location="$(ECF_CONFIG_PATH)\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\mteiffel_curl.lib">
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
<multithreaded value="true"/>
|
||||
<dotnet value="false"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<external_object location="$(ECF_CONFIG_PATH)\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\ileiffel_curl.lib">
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
<dotnet value="true"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<library name="api_wrapper" location="$ISE_LIBRARY\library\api_wrapper\api_wrapper.ecf"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<cluster name="curl" location=".\cURL" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/spec$</exclude>
|
||||
<exclude>/Clib$</exclude>
|
||||
</file_rule>
|
||||
<file_rule>
|
||||
<exclude>/gtk$</exclude>
|
||||
<exclude>/mac$</exclude>
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
</condition>
|
||||
</file_rule>
|
||||
<file_rule>
|
||||
<exclude>/mswin$</exclude>
|
||||
<exclude>/gtk$</exclude>
|
||||
<condition>
|
||||
<platform value="macintosh"/>
|
||||
<custom name="vision_implementation" value="cocoa"/>
|
||||
</condition>
|
||||
</file_rule>
|
||||
<file_rule>
|
||||
<exclude>/mswin$</exclude>
|
||||
<exclude>/mac$</exclude>
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
<custom name="vision_implementation" excluded_value="cocoa"/>
|
||||
</condition>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
<target name="curl_dotnet" extends="curl">
|
||||
<setting name="msil_generation" value="true"/>
|
||||
</target>
|
||||
</system>
|
||||
58
contrib/ise_library/cURL/Clib/Makefile-win.SH
Normal file
58
contrib/ise_library/cURL/Clib/Makefile-win.SH
Normal file
@@ -0,0 +1,58 @@
|
||||
TOP = ..
|
||||
DIR = $dir_sep
|
||||
OUTDIR= .
|
||||
INDIR= .
|
||||
CC = $cc
|
||||
OUTPUT_CMD = $output_cmd
|
||||
CFLAGS = -I"$rt_include" -I..$(DIR)spec$(DIR)include -I. \
|
||||
-I..$(DIR)..$(DIR)..$(DIR)C_library$(DIR)libpng -I..$(DIR)..$(DIR)..$(DIR)C_library$(DIR)zlib
|
||||
JCFLAGS = $(CFLAGS) $ccflags $optimize
|
||||
JMTCFLAGS = $(CFLAGS) $mtccflags $optimize
|
||||
JILCFLAGS = $(CFLAGS) $mtccflags $optimize -DEIF_IL_DLL
|
||||
LN = copy
|
||||
MV = $mv
|
||||
RM = $del
|
||||
MAKE = $make
|
||||
MKDIR = $mkdir
|
||||
LINK = $link32
|
||||
DLL_FLAGS = $dll_flags
|
||||
DLL_LIBS = $dll_libs
|
||||
OBJECTS = eiffel_curl.$obj
|
||||
MT_OBJECTS = MTeiffel_curl.$obj
|
||||
IL_OBJECTS = ILeiffel_curl.$obj
|
||||
|
||||
.c.$obj:
|
||||
$(CC) -c $(JCFLAGS) $<
|
||||
|
||||
all:: $output_libraries
|
||||
$(MAKE) clean
|
||||
|
||||
standard:: eiffel_curl.lib ileiffel_curl.lib
|
||||
mtstandard:: mteiffel_curl.lib
|
||||
|
||||
clean:
|
||||
$(RM) *.$obj
|
||||
$(RM) *.lib
|
||||
|
||||
eiffel_curl.lib: $(OBJECTS)
|
||||
$alib_line
|
||||
$(MKDIR) ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib
|
||||
$(MV) $@ ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib$(DIR)$@
|
||||
|
||||
mteiffel_curl.lib: $(MT_OBJECTS)
|
||||
$alib_line
|
||||
$(MKDIR) ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib
|
||||
$(MV) $@ ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib$(DIR)$@
|
||||
|
||||
ileiffel_curl.lib: $(IL_OBJECTS)
|
||||
$alib_line
|
||||
$(MKDIR) ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib
|
||||
$(MV) $@ ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib$(DIR)$@
|
||||
|
||||
#Multithreaded targets.
|
||||
MTeiffel_curl.$obj: eiffel_curl.c
|
||||
$(CC) $(JMTCFLAGS) $(OUTPUT_CMD)$@ -c $?
|
||||
|
||||
#.NET targets.
|
||||
ILeiffel_curl.$obj: eiffel_curl.c
|
||||
$(CC) $(JILCFLAGS) $(OUTPUT_CMD)$@ -c $?
|
||||
92
contrib/ise_library/cURL/Clib/Makefile.SH
Normal file
92
contrib/ise_library/cURL/Clib/Makefile.SH
Normal file
@@ -0,0 +1,92 @@
|
||||
case $CONFIG in
|
||||
'')
|
||||
if test ! -f config.sh; then
|
||||
(echo "Can't find config.sh."; exit 1)
|
||||
fi 2>/dev/null
|
||||
. ./config.sh
|
||||
;;
|
||||
esac
|
||||
case "$0" in
|
||||
*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
|
||||
esac
|
||||
echo "Extracting "."/Makefile (with variable substitutions)"
|
||||
$spitshell >Makefile <<!GROK!THIS!
|
||||
########################################################################
|
||||
# Makefile generated from Makefile.SH on $DATE
|
||||
|
||||
SHELL = /bin/sh
|
||||
AR = ar rc
|
||||
CC = $cc
|
||||
CTAGS = ctags
|
||||
INCLUDE = -I$rt_include -I../spec/include -I../../../C_library/libpng -I../../../C_library/zlib
|
||||
CFLAGS = $optimize $ccflags $large -g \$(INCLUDE)
|
||||
MTCFLAGS = $optimize $mtccflags $large -g \$(INCLUDE)
|
||||
SHAREDLINK = $sharedlink
|
||||
LDSHAREDFLAGS = $ldsharedflags
|
||||
LN = $ln
|
||||
MAKE = $make
|
||||
MKDEP = $mkdep \$(DPFLAGS) --
|
||||
RANLIB = $ranlib
|
||||
RM = $rm -f
|
||||
MV = $mv
|
||||
MKDIR = $mkdir -p
|
||||
PLATFORM = $ISE_PLATFORM
|
||||
|
||||
########################################################################
|
||||
# New suffixes and associated building rules -- edit with care
|
||||
|
||||
|
||||
!GROK!THIS!
|
||||
$spitshell >>Makefile <<'!NO!SUBS!'
|
||||
|
||||
MT_OBJECTS = MTeiffel_curl.o
|
||||
OBJECTS = eiffel_curl.o
|
||||
|
||||
ALL_OBJECTS = $(OBJECTS) $(MT_OBJECTS)
|
||||
|
||||
all: $(ALL_OBJECTS)
|
||||
$(MKDIR) ../spec/$(PLATFORM)/lib
|
||||
$(MV) $? ../spec/$(PLATFORM)/lib
|
||||
$(MAKE) clobber
|
||||
|
||||
MTeiffel_curl.o: eiffel_curl.c
|
||||
$(CC) -c $(MTCFLAGS) $? -o $@
|
||||
|
||||
########################################################################
|
||||
# Common rules for all Makefiles -- do not edit
|
||||
|
||||
emptyrule::
|
||||
|
||||
clean: local_clean
|
||||
realclean: local_realclean
|
||||
clobber: local_clobber
|
||||
|
||||
local_clean::
|
||||
$(RM) core *~ *.o *.so *.a
|
||||
|
||||
local_realclean:: local_clean
|
||||
|
||||
local_clobber:: local_realclean
|
||||
$(RM) Makefile config.sh
|
||||
|
||||
Makefile: Makefile.SH
|
||||
/bin/sh Makefile.SH
|
||||
|
||||
tags::
|
||||
$(CTAGS) -w *.[ch]
|
||||
$(CTAGS) -xw *.[ch] > tags
|
||||
|
||||
local_clobber::
|
||||
$(RM) tags
|
||||
|
||||
########################################################################
|
||||
# Dependencies generated by make depend
|
||||
# DO NOT DELETE THIS LINE -- make depend relies on it
|
||||
|
||||
# Put nothing here or make depend will gobble it up
|
||||
.FORCE_DEPEND::
|
||||
@echo "You must run 'make depend' in $(TOP) first."; exit 1
|
||||
!NO!SUBS!
|
||||
chmod 644 Makefile
|
||||
$eunicefix Makefile
|
||||
|
||||
24
contrib/ise_library/cURL/Clib/build.eant
Normal file
24
contrib/ise_library/cURL/Clib/build.eant
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0"?>
|
||||
<project name="build_curl_clib" default="help">
|
||||
|
||||
<description>
|
||||
description: "cURL Clib library compilation"
|
||||
</description>
|
||||
|
||||
<target name="help">
|
||||
<echo message="usage:"/>
|
||||
<echo message=" geant compile"/>
|
||||
<echo message=" geant clean"/>
|
||||
<echo message=" geant clobber"/>
|
||||
</target>
|
||||
|
||||
<target name="compile" >
|
||||
<exec executable="finish_freezing -library" />
|
||||
</target>
|
||||
|
||||
<target name="clean" >
|
||||
</target>
|
||||
|
||||
<target name="clobber" depend="clean" />
|
||||
|
||||
</project>
|
||||
188
contrib/ise_library/cURL/Clib/eiffel_curl.c
Normal file
188
contrib/ise_library/cURL/Clib/eiffel_curl.c
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
indexing
|
||||
description: "Functions used by the class CURL_FUNCTION."
|
||||
copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
356 Storke Road, Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
*/
|
||||
|
||||
#include "eiffel_curl.h"
|
||||
|
||||
typedef EIF_INTEGER (* EIF_CURL_PROGRESS_PROC) (
|
||||
#ifndef EIF_IL_DLL
|
||||
EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */
|
||||
#endif
|
||||
EIF_POINTER, /* a_user_pointer */
|
||||
EIF_REAL_64, /* a_dltotal */
|
||||
EIF_REAL_64, /* a_dlnow */
|
||||
EIF_REAL_64, /* a_ultotal */
|
||||
EIF_REAL_64 /* a_ulnow */
|
||||
);
|
||||
|
||||
typedef EIF_INTEGER (* EIF_CURL_WRITE_PROC) (
|
||||
#ifndef EIF_IL_DLL
|
||||
EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */
|
||||
#endif
|
||||
EIF_POINTER, /* a_data_pointer */
|
||||
EIF_INTEGER, /* a_size */
|
||||
EIF_INTEGER, /* a_nmemb */
|
||||
EIF_POINTER /* a_write_pointer */
|
||||
);
|
||||
|
||||
typedef EIF_INTEGER (* EIF_CURL_READ_PROC) (
|
||||
#ifndef EIF_IL_DLL
|
||||
EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */
|
||||
#endif
|
||||
EIF_POINTER, /* a_data_pointer */
|
||||
EIF_INTEGER, /* a_size */
|
||||
EIF_INTEGER, /* a_nmemb */
|
||||
EIF_POINTER /* a_write_pointer */
|
||||
);
|
||||
|
||||
|
||||
typedef EIF_INTEGER (* EIF_CURL_DEBUG_PROC) (
|
||||
#ifndef EIF_IL_DLL
|
||||
EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */
|
||||
#endif
|
||||
EIF_POINTER, /* a_curl_handle */
|
||||
EIF_INTEGER, /* a_curl_infotype */
|
||||
EIF_POINTER, /* a_char_pointer */
|
||||
EIF_INTEGER, /* a_size */
|
||||
EIF_POINTER /* a_user_pointer */
|
||||
);
|
||||
|
||||
static EIF_OBJECT eiffel_function_object = NULL;
|
||||
/* Address of Eiffel object CURL_FUNCTION */
|
||||
|
||||
static EIF_CURL_PROGRESS_PROC eiffel_progress_function = NULL;
|
||||
/* Address of Eiffel CURL_FUNCTION.progress_function */
|
||||
|
||||
static EIF_CURL_WRITE_PROC eiffel_write_function = NULL;
|
||||
/* Address of Eiffel CURL_FUNCTION.write_function */
|
||||
|
||||
static EIF_CURL_READ_PROC eiffel_read_function = NULL;
|
||||
/* Address of Eiffel CURL_FUNCTION.read_function */
|
||||
|
||||
static EIF_CURL_DEBUG_PROC eiffel_debug_function = NULL;
|
||||
/* Address of Eiffel CURL_FUNCTION.debug_function */
|
||||
|
||||
/* Set Eiffel CURL_FUNCTION object address */
|
||||
void c_set_object(EIF_REFERENCE a_address)
|
||||
{
|
||||
if (a_address) {
|
||||
eiffel_function_object = eif_protect (a_address);
|
||||
} else {
|
||||
eiffel_function_object = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Release Eiffel CURL_FUNCTION object address */
|
||||
void c_release_object()
|
||||
{
|
||||
eif_wean (eiffel_function_object);
|
||||
}
|
||||
|
||||
/* Set CURL_FUNCTOIN.progress_function address */
|
||||
void c_set_progress_function_address( EIF_POINTER a_address)
|
||||
{
|
||||
eiffel_progress_function = (EIF_CURL_PROGRESS_PROC) a_address;
|
||||
}
|
||||
|
||||
/* Set CURL_FUNCTOIN.write_function address */
|
||||
void c_set_write_function_address( EIF_POINTER a_address)
|
||||
{
|
||||
eiffel_write_function = (EIF_CURL_WRITE_PROC) a_address;
|
||||
}
|
||||
|
||||
/* Set CURL_FUNCTOIN.read_function address */
|
||||
void c_set_read_function_address( EIF_POINTER a_address)
|
||||
{
|
||||
eiffel_read_function = (EIF_CURL_READ_PROC) a_address;
|
||||
}
|
||||
|
||||
/* Set CURL_FUNCTOIN.debug_function address */
|
||||
void c_set_debug_function_address (EIF_POINTER a_address)
|
||||
{
|
||||
eiffel_debug_function = (EIF_CURL_DEBUG_PROC) a_address;
|
||||
}
|
||||
|
||||
/* Eiffel adapter function for CURLOPT_WRITEFUNCTION
|
||||
We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */
|
||||
size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data)
|
||||
{
|
||||
if (eiffel_function_object) {
|
||||
return (size_t) ((eiffel_write_function) (
|
||||
#ifndef EIF_IL_DLL
|
||||
(EIF_REFERENCE) eif_access (eiffel_function_object),
|
||||
#endif
|
||||
(EIF_POINTER) ptr,
|
||||
(EIF_INTEGER) size,
|
||||
(EIF_INTEGER) nmemb,
|
||||
(EIF_POINTER) data));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Eiffel adapter function for CURLOPT_READFUNCTION
|
||||
We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */
|
||||
size_t curl_read_function (void *ptr, size_t size, size_t nmemb, void *data)
|
||||
{
|
||||
if (eiffel_function_object) {
|
||||
return (size_t) ((eiffel_read_function) (
|
||||
#ifndef EIF_IL_DLL
|
||||
(EIF_REFERENCE) eif_access (eiffel_function_object),
|
||||
#endif
|
||||
(EIF_POINTER) ptr,
|
||||
(EIF_INTEGER) size,
|
||||
(EIF_INTEGER) nmemb,
|
||||
(EIF_POINTER) data));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Eiffel adapter function for CURLOPT_PROGRESSFUNCTION
|
||||
We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */
|
||||
size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dlnow, double a_ultotal, double a_ulnow)
|
||||
{
|
||||
if (eiffel_function_object) {
|
||||
return (size_t) ((eiffel_progress_function) (
|
||||
#ifndef EIF_IL_DLL
|
||||
(EIF_REFERENCE) eif_access (eiffel_function_object),
|
||||
#endif
|
||||
(EIF_POINTER) a_object_id,
|
||||
(EIF_REAL_64) a_dltotal,
|
||||
(EIF_REAL_64) a_dlnow,
|
||||
(EIF_REAL_64) a_ultotal,
|
||||
(EIF_REAL_64) a_ulnow));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Eiffel adapter function for CURLOPT_DEBUGFUNCTION
|
||||
We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */
|
||||
size_t curl_debug_function (CURL * a_curl_handle, curl_infotype a_curl_infotype, unsigned char * a_char_pointer, size_t a_size, void * a_object_id)
|
||||
{
|
||||
if (eiffel_function_object) {
|
||||
return (size_t) ((eiffel_debug_function) (
|
||||
#ifndef EIF_IL_DLL
|
||||
(EIF_REFERENCE) eif_access (eiffel_function_object),
|
||||
#endif
|
||||
(EIF_POINTER) a_curl_handle,
|
||||
(EIF_INTEGER) a_curl_infotype,
|
||||
(EIF_POINTER) a_char_pointer,
|
||||
(EIF_INTEGER) a_size,
|
||||
(EIF_POINTER) a_object_id));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
28
contrib/ise_library/cURL/build.eant
Normal file
28
contrib/ise_library/cURL/build.eant
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0"?>
|
||||
<project name="build_curl" default="help">
|
||||
|
||||
<description>
|
||||
description: "cURL library compilation"
|
||||
</description>
|
||||
|
||||
<target name="help">
|
||||
<echo message="usage:"/>
|
||||
<echo message=" geant compile"/>
|
||||
<echo message=" geant clean"/>
|
||||
<echo message=" geant clobber"/>
|
||||
</target>
|
||||
|
||||
<target name="compile">
|
||||
<echo message="- Compile [cURL]" />
|
||||
<geant target="compile" file="build.eant" dir="Clib"
|
||||
reuse_variables="true" />
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<echo message="- Clean [cURL]" />
|
||||
<delete directory="spec\${ISE_C_COMPILER}\${ISE_PLATFORM}" />
|
||||
</target>
|
||||
|
||||
<target name="clobber" depend="clean" />
|
||||
|
||||
</project>
|
||||
93
contrib/ise_library/cURL/cURL-safe.ecf
Normal file
93
contrib/ise_library/cURL/cURL-safe.ecf
Normal file
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-5-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-5-0 http://www.eiffel.com/developers/xml/configuration-1-5-0.xsd" name="curl" uuid="D51EF190-6157-4B47-8E73-FA93DCBB7A71" library_target="curl">
|
||||
<target name="curl">
|
||||
<description>cURL: libcURL wrapper library for Eiffel.
|
||||
Copyright (c) 1984-2006, Eiffel Software and others.
|
||||
Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt).</description>
|
||||
<root all_classes="true"/>
|
||||
<file_rule>
|
||||
<exclude>/\.svn$</exclude>
|
||||
<exclude>/EIFGEN.{0,1}$</exclude>
|
||||
<exclude>/temp$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true" cat_call_detection="false" is_attached_by_default="true" void_safety="all" namespace="EiffelSoftware.Library">
|
||||
</option>
|
||||
<setting name="dotnet_naming_convention" value="true"/>
|
||||
<external_include location="$(ISE_LIBRARY)\library\cURL\spec\include">
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
</condition>
|
||||
</external_include>
|
||||
<external_include location="$(ISE_LIBRARY)/library/cURL/spec/include">
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
</condition>
|
||||
</external_include>
|
||||
<external_object location="$(ISE_LIBRARY)/library/cURL/spec/$(ISE_PLATFORM)/lib/eiffel_curl.o">
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
<multithreaded value="false"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<external_object location="$(ISE_LIBRARY)/library/cURL/spec/$(ISE_PLATFORM)/lib/MTeiffel_curl.o">
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
<multithreaded value="true"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<external_object location="$(ISE_LIBRARY)\library\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\eiffel_curl.lib">
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
<multithreaded value="false"/>
|
||||
<dotnet value="false"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<external_object location="$(ISE_LIBRARY)\library\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\mteiffel_curl.lib">
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
<multithreaded value="true"/>
|
||||
<dotnet value="false"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<external_object location="$(ISE_LIBRARY)\library\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\ileiffel_curl.lib">
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
<dotnet value="true"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<library name="api_wrapper" location="$ISE_LIBRARY\library\api_wrapper\api_wrapper-safe.ecf"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<cluster name="curl" location=".\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/spec$</exclude>
|
||||
<exclude>/Clib$</exclude>
|
||||
</file_rule>
|
||||
<file_rule>
|
||||
<exclude>/gtk$</exclude>
|
||||
<exclude>/mac$</exclude>
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
</condition>
|
||||
</file_rule>
|
||||
<file_rule>
|
||||
<exclude>/mswin$</exclude>
|
||||
<exclude>/gtk$</exclude>
|
||||
<condition>
|
||||
<platform value="macintosh"/>
|
||||
<custom name="vision_implementation" value="cocoa"/>
|
||||
</condition>
|
||||
</file_rule>
|
||||
<file_rule>
|
||||
<exclude>/mswin$</exclude>
|
||||
<exclude>/mac$</exclude>
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
<custom name="vision_implementation" excluded_value="cocoa"/>
|
||||
</condition>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
<target name="curl_dotnet" extends="curl">
|
||||
<setting name="msil_generation" value="true"/>
|
||||
</target>
|
||||
</system>
|
||||
93
contrib/ise_library/cURL/cURL.ecf
Normal file
93
contrib/ise_library/cURL/cURL.ecf
Normal file
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-5-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-5-0 http://www.eiffel.com/developers/xml/configuration-1-5-0.xsd" name="curl" uuid="D51EF190-6157-4B47-8E73-FA93DCBB7A71" library_target="curl">
|
||||
<target name="curl">
|
||||
<description>cURL: libcURL wrapper library for Eiffel.
|
||||
Copyright (c) 1984-2006, Eiffel Software and others.
|
||||
Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt).</description>
|
||||
<root all_classes="true"/>
|
||||
<file_rule>
|
||||
<exclude>/\.svn$</exclude>
|
||||
<exclude>/EIFGEN.{0,1}$</exclude>
|
||||
<exclude>/temp$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" namespace="EiffelSoftware.Library">
|
||||
</option>
|
||||
<setting name="dotnet_naming_convention" value="true"/>
|
||||
<external_include location="$(ISE_LIBRARY)\library\cURL\spec\include">
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
</condition>
|
||||
</external_include>
|
||||
<external_include location="$(ISE_LIBRARY)/library/cURL/spec/include">
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
</condition>
|
||||
</external_include>
|
||||
<external_object location="$(ISE_LIBRARY)/library/cURL/spec/$(ISE_PLATFORM)/lib/eiffel_curl.o">
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
<multithreaded value="false"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<external_object location="$(ISE_LIBRARY)/library/cURL/spec/$(ISE_PLATFORM)/lib/MTeiffel_curl.o">
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
<multithreaded value="true"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<external_object location="$(ISE_LIBRARY)\library\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\eiffel_curl.lib">
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
<multithreaded value="false"/>
|
||||
<dotnet value="false"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<external_object location="$(ISE_LIBRARY)\library\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\mteiffel_curl.lib">
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
<multithreaded value="true"/>
|
||||
<dotnet value="false"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<external_object location="$(ISE_LIBRARY)\library\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\ileiffel_curl.lib">
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
<dotnet value="true"/>
|
||||
</condition>
|
||||
</external_object>
|
||||
<library name="api_wrapper" location="$ISE_LIBRARY\library\api_wrapper\api_wrapper.ecf"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<cluster name="curl" location=".\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/spec$</exclude>
|
||||
<exclude>/Clib$</exclude>
|
||||
</file_rule>
|
||||
<file_rule>
|
||||
<exclude>/gtk$</exclude>
|
||||
<exclude>/mac$</exclude>
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
</condition>
|
||||
</file_rule>
|
||||
<file_rule>
|
||||
<exclude>/mswin$</exclude>
|
||||
<exclude>/gtk$</exclude>
|
||||
<condition>
|
||||
<platform value="macintosh"/>
|
||||
<custom name="vision_implementation" value="cocoa"/>
|
||||
</condition>
|
||||
</file_rule>
|
||||
<file_rule>
|
||||
<exclude>/mswin$</exclude>
|
||||
<exclude>/mac$</exclude>
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
<custom name="vision_implementation" excluded_value="cocoa"/>
|
||||
</condition>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
<target name="curl_dotnet" extends="curl">
|
||||
<setting name="msil_generation" value="true"/>
|
||||
</target>
|
||||
</system>
|
||||
336
contrib/ise_library/cURL/curl_codes.e
Normal file
336
contrib/ise_library/cURL/curl_codes.e
Normal file
@@ -0,0 +1,336 @@
|
||||
note
|
||||
description: "[
|
||||
All possible error codes from all sorts of curl functions.
|
||||
Future versions may return other values, stay prepared.
|
||||
]"
|
||||
status: "See notice at end of class."
|
||||
legal: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CURL_CODES
|
||||
|
||||
feature -- Eiffel cURL: Constants
|
||||
|
||||
eiffelcurle_error_occurred: INTEGER = -1
|
||||
-- Error occurred in Eiffel cURL internals
|
||||
|
||||
feature -- Constants
|
||||
|
||||
curle_ok: INTEGER = 0
|
||||
-- Declared as CURLE_OK
|
||||
|
||||
curle_unsupported_protocol: INTEGER = 1
|
||||
-- Declared as CURLE_UNSUPPORTED_PROTOCOL
|
||||
|
||||
curle_failed_init: INTEGER = 2
|
||||
-- Declared as CURLE_FAILED_INIT
|
||||
|
||||
curle_url_malformat: INTEGER = 3
|
||||
-- Declared as CURLE_URL_MALFORMAT
|
||||
|
||||
curle_obsolete4: INTEGER = 4
|
||||
-- Declared as CURLE_OBSOLETE4
|
||||
-- NOT USED
|
||||
|
||||
curle_couldnt_resolve_proxy: INTEGER = 5
|
||||
-- Declared as CURLE_COULDNT_RESOLVE_PROXY
|
||||
|
||||
curle_couldnt_resolve_host: INTEGER = 6
|
||||
-- Declared as CURLE_COULDNT_RESOLVE_HOST
|
||||
|
||||
curle_couldnt_connect: INTEGER = 7
|
||||
-- Declared as CURLE_COULDNT_CONNECT
|
||||
|
||||
curle_ftp_weird_server_reply: INTEGER = 8
|
||||
-- Declared as CURLE_FTP_WEIRD_SERVER_REPLY
|
||||
|
||||
curle_remote_access_denied: INTEGER = 9
|
||||
-- Declared as CURLE_REMOTE_ACCESS_DENIED
|
||||
-- A service was denied by the server due to lack of access
|
||||
-- when login fails this is not returned.
|
||||
|
||||
curle_obsolete10: INTEGER = 10
|
||||
-- Declared as CURLE_OBSOLETE10 NOT USED
|
||||
|
||||
curle_ftp_weird_pass_reply: INTEGER = 11
|
||||
-- Declared as CURLE_FTP_WEIRD_PASS_REPLY
|
||||
|
||||
curle_obsolete12: INTEGER = 12
|
||||
-- Declared as CURLE_OBSOLETE12 NOT USED
|
||||
|
||||
curle_ftp_weird_pasv_reply: INTEGER = 13
|
||||
-- Declared as CURLE_FTP_WEIRD_PASV_REPLY
|
||||
|
||||
curle_ftp_weird_227_format: INTEGER = 14
|
||||
-- Declared as CURLE_FTP_WEIRD_227_FORMAT
|
||||
|
||||
curle_ftp_cant_get_host: INTEGER = 15
|
||||
-- Declared as CURLE_FTP_CANT_GET_HOST
|
||||
|
||||
curle_obsolete16: INTEGER = 16
|
||||
-- Declared as CURLE_OBSOLETE16
|
||||
-- NOT USED
|
||||
|
||||
curle_ftp_couldnt_set_type: INTEGER = 17
|
||||
-- Declared as CURLE_FTP_COULDNT_SET_TYPE
|
||||
|
||||
curle_partial_file: INTEGER = 18
|
||||
-- Declared as CURLE_PARTIAL_FILE
|
||||
|
||||
curle_ftp_couldnt_retr_file: INTEGER = 19
|
||||
-- Declared as CURLE_FTP_COULDNT_RETR_FILE
|
||||
|
||||
curle_obsolete20: INTEGER = 20
|
||||
-- Declared as CURLE_OBSOLETE20
|
||||
-- NOT USED
|
||||
|
||||
curle_quote_error: INTEGER = 21
|
||||
-- Declared as CURLE_QUOTE_ERROR
|
||||
-- quote command failure
|
||||
|
||||
curle_http_returned_error: INTEGER = 22
|
||||
-- Declared as CURLE_HTTP_RETURNED_ERROR
|
||||
|
||||
curle_write_error: INTEGER = 23
|
||||
-- Declared as CURLE_WRITE_ERROR
|
||||
|
||||
curle_obsolete24: INTEGER = 24
|
||||
-- Declared as CURLE_OBSOLETE24 NOT USED
|
||||
|
||||
curle_upload_failed: INTEGER = 25
|
||||
-- Declared as CURLE_UPLOAD_FAILED
|
||||
-- failed upload "command"
|
||||
|
||||
curle_read_error: INTEGER = 26
|
||||
-- Declared as CURLE_READ_ERROR
|
||||
-- couldn't open/read from file
|
||||
|
||||
curle_out_of_memory: INTEGER = 27
|
||||
-- Declared as CURLE_OUT_OF_MEMORY
|
||||
-- Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error
|
||||
-- instead of a memory allocation error if CURL_DOES_CONVERSIONS
|
||||
-- is defined
|
||||
|
||||
curle_operation_timedout: INTEGER = 28
|
||||
-- Declared as CURLE_OPERATION_TIMEDOUT
|
||||
-- the timeout time was reached
|
||||
|
||||
curle_obsolete29: INTEGER = 29
|
||||
-- Declared as CURLE_OBSOLETE29
|
||||
-- NOT USED
|
||||
|
||||
curle_ftp_port_failed: INTEGER = 30
|
||||
-- Declared as CURLE_FTP_PORT_FAILED
|
||||
-- FTP PORT operation failed
|
||||
|
||||
curle_ftp_couldnt_use_rest: INTEGER = 31
|
||||
-- Declared as CURLE_FTP_COULDNT_USE_REST
|
||||
-- the REST command failed
|
||||
|
||||
curle_obsolete32: INTEGER = 32
|
||||
-- Declared as CURLE_OBSOLETE32
|
||||
-- NOT USED
|
||||
|
||||
curle_range_error: INTEGER = 33
|
||||
-- Declared as CURLE_RANGE_ERROR
|
||||
-- RANGE "command" didn't work
|
||||
|
||||
curle_http_post_error: INTEGER = 34
|
||||
-- Declared as CURLE_HTTP_POST_ERROR
|
||||
|
||||
curle_ssl_connect_error: INTEGER = 35
|
||||
-- Declared CURLE_SSL_CONNECT_ERROR
|
||||
-- wrong when connecting with SSL
|
||||
|
||||
curle_bad_download_resume: INTEGER = 36
|
||||
-- Declared as CURLE_BAD_DOWNLOAD_RESUME
|
||||
-- couldn't resume download
|
||||
|
||||
curle_file_couldnt_read_file: INTEGER = 37
|
||||
-- Declared as CURLE_FILE_COULDNT_READ_FILE
|
||||
|
||||
curle_ldap_cannot_bind: INTEGER = 38
|
||||
-- Declared as CURLE_LDAP_CANNOT_BIND
|
||||
|
||||
curle_ldap_search_failed: INTEGER = 39
|
||||
-- Declared as CURLE_LDAP_SEARCH_FAILED
|
||||
|
||||
curle_obsolete40: INTEGER = 40
|
||||
-- Declared as CURLE_OBSOLETE40
|
||||
-- NOT USED
|
||||
|
||||
curle_function_not_found: INTEGER = 41
|
||||
-- Declared as CURLE_FUNCTION_NOT_FOUND
|
||||
|
||||
curle_aborted_by_callback: INTEGER = 42
|
||||
-- Declared as CURLE_ABORTED_BY_CALLBACK
|
||||
|
||||
curle_bad_function_argument: INTEGER = 43
|
||||
-- Declared as CURLE_BAD_FUNCTION_ARGUMENT
|
||||
|
||||
curle_obsolete44: INTEGER = 44
|
||||
-- Declared as CURLE_OBSOLETE44
|
||||
-- NOT USED
|
||||
|
||||
curle_interface_failed: INTEGER = 45
|
||||
-- Declared as CURLE_INTERFACE_FAILED
|
||||
-- CURLOPT_INTERFACE failed
|
||||
|
||||
curle_obsolete46: INTEGER = 46
|
||||
-- Declared as CURLE_OBSOLETE46
|
||||
-- NOT USED
|
||||
|
||||
curle_too_many_redirects: INTEGER = 47
|
||||
-- Declared as CURLE_TOO_MANY_REDIRECTS
|
||||
-- catch endless re-direct loops
|
||||
|
||||
curle_unknown_telnet_option: INTEGER = 48
|
||||
-- Declared as CURLE_UNKNOWN_TELNET_OPTION
|
||||
-- User specified an unknown option
|
||||
|
||||
curle_telnet_option_syntax: INTEGER = 49
|
||||
-- Declared as CURLE_TELNET_OPTION_SYNTAX
|
||||
-- Malformed telnet option
|
||||
|
||||
curle_obsolete50: INTEGER = 50
|
||||
-- Declared as CURLE_OBSOLETE50
|
||||
-- NOT USED
|
||||
|
||||
curle_ssl_peer_certificate: INTEGER = 51
|
||||
-- Declared as CURLE_SSL_PEER_CERTIFICATE
|
||||
-- peer's certificate wasn't ok
|
||||
|
||||
curle_got_nothing: INTEGER = 52
|
||||
-- Declared as CURLE_GOT_NOTHING
|
||||
-- when this is a specific error
|
||||
|
||||
curle_ssl_engine_notfound: INTEGER = 53
|
||||
-- Declared as CURLE_SSL_ENGINE_NOTFOUND
|
||||
-- SSL crypto engine not found */
|
||||
|
||||
curle_ssl_engine_setfailed: INTEGER = 54
|
||||
-- Declared as CURLE_SSL_ENGINE_SETFAILED
|
||||
-- can not set SSL crypto engine as default
|
||||
|
||||
curle_send_error: INTEGER = 55
|
||||
-- Declared as CURLE_SEND_ERROR
|
||||
-- failed sending network data
|
||||
|
||||
curle_recv_error: INTEGER = 56
|
||||
-- Declared as CURLE_RECV_ERROR
|
||||
-- failure in receiving network data
|
||||
|
||||
curle_obsolete57: INTEGER = 57
|
||||
-- Declared as CURLE_OBSOLETE57
|
||||
-- NOT IN USE
|
||||
|
||||
curle_ssl_certproblem: INTEGER = 58
|
||||
-- Declared as CURLE_SSL_CERTPROBLEM
|
||||
-- problem with the local certificate
|
||||
|
||||
curle_ssl_cipher: INTEGER = 59
|
||||
-- Declared as CURLE_SSL_CIPHER
|
||||
-- couldn't use specified cipher
|
||||
|
||||
curle_ssl_cacert: INTEGER = 60
|
||||
-- Declared as CURLE_SSL_CACERT
|
||||
-- problem with the CA cert (path?)
|
||||
|
||||
curle_bad_content_encoding: INTEGER = 61
|
||||
-- Declared as CURLE_BAD_CONTENT_ENCODING
|
||||
-- Unrecognized transfer encoding
|
||||
|
||||
curle_ldap_invalid_url: INTEGER = 62
|
||||
-- Declared as CURLE_LDAP_INVALID_URL
|
||||
-- Invalid LDAP URL
|
||||
|
||||
curle_filesize_exceeded: INTEGER = 63
|
||||
-- Declared as CURLE_FILESIZE_EXCEEDED
|
||||
-- Maximum file size exceeded
|
||||
|
||||
curle_use_ssl_failed: INTEGER = 64
|
||||
-- Declared as CURLE_USE_SSL_FAILED
|
||||
-- Requested FTP SSL level failed
|
||||
|
||||
curle_send_fail_rewind: INTEGER = 65
|
||||
-- Declared as CURLE_SEND_FAIL_REWIND
|
||||
-- Sending the data requires a rewind that failed
|
||||
|
||||
curle_ssl_engine_initfailed: INTEGER = 66
|
||||
-- Declared as CURLE_SSL_ENGINE_INITFAILED
|
||||
-- failed to initialise ENGINE
|
||||
|
||||
curle_login_denied: INTEGER = 67
|
||||
-- Declared as CURLE_LOGIN_DENIED
|
||||
-- user, password or similar was not accepted and we failed to login
|
||||
|
||||
curle_tftp_notfound: INTEGER = 68
|
||||
-- Declared as CURLE_TFTP_NOTFOUND
|
||||
-- file not found on server
|
||||
|
||||
curle_tftp_perm: INTEGER = 69
|
||||
-- Declared as CURLE_TFTP_PERM
|
||||
-- permission problem on server
|
||||
|
||||
curle_remote_disk_full: INTEGER = 70
|
||||
-- Declared as CURLE_REMOTE_DISK_FULL
|
||||
-- out of disk space on server
|
||||
|
||||
curle_tftp_illegal: INTEGER = 71
|
||||
-- Declared as CURLE_TFTP_ILLEGAL
|
||||
-- Illegal TFTP operation
|
||||
|
||||
curle_tftp_unknownid: INTEGER = 72
|
||||
-- Declared as CURLE_TFTP_UNKNOWNID
|
||||
-- Unknown transfer ID
|
||||
|
||||
curle_remote_file_exists: INTEGER = 73
|
||||
-- Declared as CURLE_REMOTE_FILE_EXISTS
|
||||
-- File already exists
|
||||
|
||||
curle_tftp_nosuchuser: INTEGER = 74
|
||||
-- Declared as CURLE_TFTP_NOSUCHUSER
|
||||
-- No such user
|
||||
|
||||
curle_conv_failed: INTEGER = 75
|
||||
-- Declared as CURLE_CONV_FAILED
|
||||
-- conversion failed
|
||||
|
||||
curle_conv_reqd: INTEGER = 76
|
||||
-- Declared as CURLE_CONV_REQD
|
||||
-- caller must register conversion callbacks using curl_easy_setopt options
|
||||
-- CURLOPT_CONV_FROM_NETWORK_FUNCTION, CURLOPT_CONV_TO_NETWORK_FUNCTION, and
|
||||
-- CURLOPT_CONV_FROM_UTF8_FUNCTION
|
||||
|
||||
curle_ssl_cacert_badfile: INTEGER = 77
|
||||
-- Declared as CURLE_SSL_CACERT_BADFILE
|
||||
-- could not load CACERT file, missing or wrong format
|
||||
|
||||
curle_remote_file_not_found: INTEGER = 78
|
||||
-- Declared as CURLE_REMOTE_FILE_NOT_FOUND
|
||||
-- remote file not found
|
||||
|
||||
curle_ssh: INTEGER = 79
|
||||
-- Declared as CURLE_SSH
|
||||
-- error from the SSH layer, somewhat generic so the error message will be of
|
||||
-- interest when this has happened
|
||||
|
||||
curle_ssl_shutdown_failed: INTEGER = 80;
|
||||
-- Declared as CURLE_SSL_SHUTDOWN_FAILED
|
||||
-- Failed to shut down the SSL connection
|
||||
|
||||
note
|
||||
library: "cURL: Library of reusable components for Eiffel."
|
||||
copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
356 Storke Road, Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
|
||||
end
|
||||
104
contrib/ise_library/cURL/curl_default_function.e
Normal file
104
contrib/ise_library/cURL/curl_default_function.e
Normal file
@@ -0,0 +1,104 @@
|
||||
note
|
||||
description: "[
|
||||
Default implementation of CURL_FUNCTION.
|
||||
]"
|
||||
status: "See notice at end of class."
|
||||
legal: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CURL_DEFAULT_FUNCTION
|
||||
|
||||
inherit
|
||||
CURL_FUNCTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Creation method
|
||||
do
|
||||
set_object_and_function_address
|
||||
end
|
||||
|
||||
feature -- Command
|
||||
|
||||
progress_function (a_object_id: POINTER; a_download_total, a_download_now, a_upload_total, a_upload_now: REAL_64): INTEGER
|
||||
do
|
||||
end
|
||||
|
||||
write_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER
|
||||
local
|
||||
l_c_string: C_STRING
|
||||
do
|
||||
-- Returns the number of bytes actually saved into object identified by `a_object_id'
|
||||
Result := a_size * a_nmemb
|
||||
create l_c_string.make_shared_from_pointer_and_count (a_data_pointer, Result)
|
||||
|
||||
check attached {CURL_STRING} (create {IDENTIFIED}).id_object (a_object_id.to_integer_32) as l_string then
|
||||
l_string.append (l_c_string.substring (1, Result))
|
||||
end
|
||||
end
|
||||
|
||||
read_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER
|
||||
-- A callback readfunction
|
||||
do
|
||||
end
|
||||
|
||||
debug_function (a_curl_handle: POINTER; a_curl_infotype: INTEGER; a_char_pointer: POINTER; a_size: INTEGER; a_object_id: POINTER): INTEGER
|
||||
local
|
||||
l_c_string: C_STRING
|
||||
do
|
||||
inspect
|
||||
a_curl_infotype
|
||||
when {CURL_INFO_TYPE}.curlinfo_data_in then
|
||||
dump ("<= Recv data", a_char_pointer, a_size)
|
||||
when {CURL_INFO_TYPE}.curlinfo_data_out then
|
||||
dump ("=> Send data", a_char_pointer, a_size)
|
||||
when {CURL_INFO_TYPE}.curlinfo_header_in then
|
||||
dump ("<= Recv header", a_char_pointer, a_size)
|
||||
when {CURL_INFO_TYPE}.curlinfo_header_out then
|
||||
dump ("=> Send header", a_char_pointer, a_size)
|
||||
when {CURL_INFO_TYPE}.curlinfo_ssl_data_in then
|
||||
dump ("<= Recv SSL data", a_char_pointer, a_size)
|
||||
when {CURL_INFO_TYPE}.curlinfo_ssl_data_out then
|
||||
dump ("=> Send SSL data", a_char_pointer, a_size)
|
||||
when {CURL_INFO_TYPE}.curlinfo_text then
|
||||
create l_c_string.make_by_pointer_and_count (a_char_pointer, a_size)
|
||||
print ("%N== Info: " + l_c_string.string)
|
||||
else
|
||||
check type_unknow: False end
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
dump (a_text: STRING; a_char_pointer: POINTER; a_size: INTEGER)
|
||||
-- Dump debug information
|
||||
require
|
||||
not_void: a_text /= Void
|
||||
exists: a_char_pointer /= default_pointer
|
||||
non_negative: a_size >= 0
|
||||
local
|
||||
l_c_string: C_STRING
|
||||
do
|
||||
create l_c_string.make_shared_from_pointer_and_count (a_char_pointer, a_size)
|
||||
print ("%N" + a_text + "%N" + l_c_string.string)
|
||||
end
|
||||
|
||||
note
|
||||
library: "cURL: Library of reusable components for Eiffel."
|
||||
copyright: "Copyright (c) 1984-2012, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
|
||||
end
|
||||
409
contrib/ise_library/cURL/curl_easy_externals.e
Normal file
409
contrib/ise_library/cURL/curl_easy_externals.e
Normal file
@@ -0,0 +1,409 @@
|
||||
note
|
||||
description: "[
|
||||
cURL easy externals.
|
||||
For more informaton see:
|
||||
http://curl.haxx.se/libcurl/c/
|
||||
]"
|
||||
status: "See notice at end of class."
|
||||
legal: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CURL_EASY_EXTERNALS
|
||||
|
||||
feature -- Command
|
||||
|
||||
init: POINTER
|
||||
-- Declared as curl_easy_init().
|
||||
require
|
||||
dynamic_library_exists: is_dynamic_library_exists
|
||||
local
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_easy_init")
|
||||
if l_api /= default_pointer then
|
||||
Result := c_init (l_api)
|
||||
end
|
||||
ensure
|
||||
exists: Result /= default_pointer
|
||||
end
|
||||
|
||||
setopt_string (a_curl_handle: POINTER; a_opt: INTEGER; a_string: READABLE_STRING_GENERAL)
|
||||
-- Declared as curl_easy_setopt().
|
||||
require
|
||||
exists: a_curl_handle /= default_pointer
|
||||
valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt)
|
||||
not_void: a_string /= Void
|
||||
local
|
||||
l_api: POINTER
|
||||
l_c_str: C_STRING
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_easy_setopt")
|
||||
if l_api /= default_pointer then
|
||||
create l_c_str.make (a_string)
|
||||
c_setopt (l_api, a_curl_handle, a_opt, l_c_str.item)
|
||||
end
|
||||
end
|
||||
|
||||
setopt_form (a_curl_handle: POINTER; a_opt: INTEGER; a_form: CURL_FORM)
|
||||
-- Declared as curl_easy_setopt().
|
||||
require
|
||||
exists: a_curl_handle /= default_pointer
|
||||
valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt)
|
||||
not_void: a_form /= Void and then a_form.is_exists
|
||||
do
|
||||
setopt_void_star (a_curl_handle, a_opt, a_form.item)
|
||||
end
|
||||
|
||||
setopt_slist (a_curl_handle: POINTER; a_opt: INTEGER; a_curl_slist: POINTER)
|
||||
-- Declared as curl_easy_setopt().
|
||||
require
|
||||
exists: a_curl_handle /= default_pointer
|
||||
valid: a_opt = {CURL_OPT_CONSTANTS}.curlopt_httpheader
|
||||
exists: a_curl_slist /= default_pointer
|
||||
do
|
||||
setopt_void_star (a_curl_handle, a_opt, a_curl_slist)
|
||||
end
|
||||
|
||||
setopt_curl_string (a_curl_handle: POINTER; a_opt: INTEGER; a_curl_string: CURL_STRING)
|
||||
-- Declared as curl_easy_setopt().
|
||||
require
|
||||
exists: a_curl_handle /= default_pointer
|
||||
valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt)
|
||||
not_void: a_curl_string /= Void
|
||||
local
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_easy_setopt")
|
||||
if l_api /= default_pointer then
|
||||
c_setopt_int (l_api, a_curl_handle, a_opt, a_curl_string.object_id)
|
||||
end
|
||||
end
|
||||
|
||||
setopt_integer (a_curl_handle: POINTER; a_opt: INTEGER; a_integer: INTEGER)
|
||||
-- Declared as curl_easy_setopt().
|
||||
require
|
||||
exists: a_curl_handle /= default_pointer
|
||||
valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt)
|
||||
local
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_easy_setopt")
|
||||
if l_api /= default_pointer then
|
||||
c_setopt_int (l_api, a_curl_handle, a_opt, a_integer)
|
||||
end
|
||||
end
|
||||
|
||||
setopt_file (a_curl_handle: POINTER; a_opt: INTEGER; a_file: FILE)
|
||||
-- Declared as curl_easy_setopt().
|
||||
require
|
||||
exists: a_curl_handle /= default_pointer
|
||||
valid: a_opt = {CURL_OPT_CONSTANTS}.curlopt_readdata
|
||||
readable: a_file /= Void and then a_file.file_readable
|
||||
do
|
||||
setopt_void_star (a_curl_handle, a_opt, a_file.file_pointer)
|
||||
end
|
||||
|
||||
perform (a_curl_handle: POINTER): INTEGER
|
||||
-- Declared as curl_easy_perform().
|
||||
-- Result is one value from {CURL_CODES}
|
||||
require
|
||||
exists: a_curl_handle /= default_pointer
|
||||
local
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_easy_perform")
|
||||
if l_api /= default_pointer then
|
||||
Result := c_perform (l_api, a_curl_handle)
|
||||
else
|
||||
Result := {CURL_CODES}.eiffelcurle_error_occurred
|
||||
end
|
||||
end
|
||||
|
||||
cleanup (a_curl_handle: POINTER)
|
||||
-- Declared as curl_easy_cleanup().
|
||||
require
|
||||
exists: a_curl_handle /= default_pointer
|
||||
local
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_easy_cleanup")
|
||||
if l_api /= default_pointer then
|
||||
c_cleanup (l_api, a_curl_handle)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
getinfo (a_curl_handle: POINTER; a_info: INTEGER; a_data: CELL [detachable ANY]): INTEGER
|
||||
-- `curl_getinfo
|
||||
--|* Request internal information from the curl session with this function. The
|
||||
--|* third argument MUST be a pointer to a long, a pointer to a char * or a
|
||||
--|* pointer to a double (as the documentation describes elsewhere). The data
|
||||
--|* pointed to will be filled in accordingly and can be relied upon only if the
|
||||
--|* function returns CURLE_OK. This function is intended to get used *AFTER* a
|
||||
--|* performed transfer, all results from this function are undefined until the
|
||||
--|* transfer is completed.
|
||||
require
|
||||
exists: a_curl_handle /= default_pointer
|
||||
valid: (create {CURL_INFO_CONSTANTS}).is_valid (a_info)
|
||||
local
|
||||
l_api: POINTER
|
||||
mp: detachable MANAGED_POINTER
|
||||
l: INTEGER
|
||||
cs: C_STRING
|
||||
d: REAL_64
|
||||
do
|
||||
a_data.replace (Void)
|
||||
l_api := api_loader.api_pointer ("curl_easy_getinfo")
|
||||
if l_api /= default_pointer then
|
||||
if a_info & {CURL_INFO_CONSTANTS}.curlinfo_long /= 0 then
|
||||
create mp.make ({PLATFORM}.integer_32_bytes)
|
||||
elseif a_info & {CURL_INFO_CONSTANTS}.curlinfo_string /= 0 then
|
||||
create mp.make ({PLATFORM}.pointer_bytes)
|
||||
elseif a_info & {CURL_INFO_CONSTANTS}.curlinfo_double /= 0 then
|
||||
create mp.make ({PLATFORM}.real_64_bytes)
|
||||
end
|
||||
if mp /= Void then
|
||||
Result := c_getinfo (l_api, a_curl_handle, a_info, mp.item)
|
||||
if Result = {CURL_CODES}.curle_ok then
|
||||
if a_info & {CURL_INFO_CONSTANTS}.curlinfo_long /= 0 then
|
||||
l := mp.read_integer_32 (0)
|
||||
a_data.put (l)
|
||||
elseif a_info & {CURL_INFO_CONSTANTS}.curlinfo_string /= 0 then
|
||||
create cs.make_shared_from_pointer (mp.read_pointer (0))
|
||||
a_data.put (cs.string)
|
||||
elseif a_info & {CURL_INFO_CONSTANTS}.curlinfo_double /= 0 then
|
||||
d := mp.read_real_64 (0)
|
||||
a_data.put (d)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
is_dynamic_library_exists: BOOLEAN
|
||||
-- If dll/so files exist?
|
||||
do
|
||||
Result := api_loader.is_interface_usable
|
||||
end
|
||||
|
||||
feature -- Special setting
|
||||
|
||||
set_curl_function (a_curl_function: CURL_FUNCTION)
|
||||
-- Set `curl_function' with `a_curl_function'
|
||||
do
|
||||
internal_curl_function := a_curl_function
|
||||
ensure
|
||||
set: a_curl_function /= Void implies curl_function = a_curl_function
|
||||
end
|
||||
|
||||
curl_function: CURL_FUNCTION
|
||||
-- cURL functions in curl_easy_setopt.
|
||||
do
|
||||
if attached internal_curl_function as l_curl_function then
|
||||
Result := l_curl_function
|
||||
else
|
||||
create {CURL_DEFAULT_FUNCTION} Result.make
|
||||
internal_curl_function := Result
|
||||
end
|
||||
ensure
|
||||
not_void: Result /= Void
|
||||
end
|
||||
|
||||
set_write_function (a_curl_handle: POINTER)
|
||||
-- Set cURL write function
|
||||
-- Set cURL write function with Eiffel default write function.
|
||||
-- So we can use CURL_STRING as parameter in {CURL_EASY_EXTERNALS}.setopt_curl_string when the option is {CURL_OPT_CONSTANTS}.curlopt_writedata
|
||||
require
|
||||
exists: a_curl_handle /= default_pointer
|
||||
local
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_easy_setopt")
|
||||
if l_api /= default_pointer then
|
||||
curl_function.c_set_write_function (l_api, a_curl_handle)
|
||||
end
|
||||
end
|
||||
|
||||
set_read_function (a_curl_handle: POINTER)
|
||||
-- Set cURL read function
|
||||
-- Set cURL read function with Eiffel default read function.
|
||||
-- So we can use a c file pointer as parameter in {CURL_EASY_EXTERNALS}.setopt_file_pointer when the option is {CURL_OPT_CONSTANTS}.curlopt_readdata
|
||||
require
|
||||
exists: a_curl_handle /= default_pointer
|
||||
local
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_easy_setopt")
|
||||
if l_api /= default_pointer then
|
||||
curl_function.c_set_read_function (l_api, a_curl_handle)
|
||||
end
|
||||
end
|
||||
|
||||
set_progress_function (a_curl_handle: POINTER)
|
||||
-- Set cURL progress function for upload/download progress.
|
||||
require
|
||||
exists: a_curl_handle /= default_pointer
|
||||
local
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_easy_setopt")
|
||||
if l_api /= default_pointer then
|
||||
curl_function.c_set_progress_function (l_api, a_curl_handle)
|
||||
end
|
||||
end
|
||||
|
||||
set_debug_function (a_curl_handle: POINTER)
|
||||
-- Set cURL debug function
|
||||
require
|
||||
exists: a_curl_handle /= default_pointer
|
||||
local
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_easy_setopt")
|
||||
if l_api /= default_pointer then
|
||||
curl_function.c_set_debug_function (l_api, a_curl_handle)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
internal_curl_function: detachable CURL_FUNCTION
|
||||
-- cURL functions.
|
||||
|
||||
api_loader: DYNAMIC_MODULE
|
||||
-- Module name.
|
||||
local
|
||||
l_utility: CURL_UTILITY
|
||||
once
|
||||
create l_utility
|
||||
Result := l_utility.api_loader
|
||||
end
|
||||
|
||||
setopt_void_star (a_curl_handle: POINTER; a_opt: INTEGER; a_data:POINTER)
|
||||
-- Declared as curl_easy_setopt().
|
||||
require
|
||||
exists: a_curl_handle /= default_pointer
|
||||
valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt)
|
||||
local
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_easy_setopt")
|
||||
if l_api /= default_pointer then
|
||||
c_setopt (l_api, a_curl_handle, a_opt, a_data)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- C externals
|
||||
|
||||
c_init (a_api: POINTER): POINTER
|
||||
-- Declared curl_easy_init ().
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
return (FUNCTION_CAST(CURL *, ()) $a_api)();
|
||||
]"
|
||||
end
|
||||
|
||||
c_cleanup (a_api: POINTER; a_curl_handle: POINTER)
|
||||
-- Decalred as curl_easy_cleanup ().
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
exists: a_curl_handle /= default_pointer
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
(FUNCTION_CAST(void, (CURL *)) $a_api)((CURL *)$a_curl_handle);
|
||||
]"
|
||||
end
|
||||
|
||||
c_perform (a_api: POINTER; a_curl_handle: POINTER): INTEGER
|
||||
-- Declared as curl_easy_perform().
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
exists: a_curl_handle /= default_pointer
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
return (FUNCTION_CAST(CURLcode, (CURL *)) $a_api)
|
||||
((CURL *) $a_curl_handle);
|
||||
]"
|
||||
end
|
||||
|
||||
c_setopt_int (a_api: POINTER; a_curl_handle: POINTER; a_opt: INTEGER; a_data: INTEGER)
|
||||
-- Same as `c_setopt' except we can pass `a_data' as integer.
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
exists: a_curl_handle /= default_pointer
|
||||
valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt)
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
{
|
||||
(FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_api)
|
||||
((CURL *) $a_curl_handle,
|
||||
(CURLoption)$a_opt,
|
||||
$a_data);
|
||||
}
|
||||
]"
|
||||
end
|
||||
|
||||
c_setopt (a_api: POINTER; a_curl_handle: POINTER; a_opt: INTEGER; a_data: POINTER)
|
||||
-- C implementation of `setopt_void_star'.
|
||||
-- Declared as curl_easy_setopt ().
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
exists: a_curl_handle /= default_pointer
|
||||
valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt)
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
{
|
||||
(FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_api)
|
||||
((CURL *) $a_curl_handle,
|
||||
(CURLoption)$a_opt,
|
||||
$a_data);
|
||||
}
|
||||
]"
|
||||
end
|
||||
|
||||
c_getinfo (a_api: POINTER; a_curl_handle: POINTER; a_opt: INTEGER; a_data: POINTER): INTEGER
|
||||
-- C implementation of `curl_easy_getinfo'.
|
||||
-- Declared as curl_easy_setopt ().
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
exists: a_curl_handle /= default_pointer
|
||||
valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt)
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
return (FUNCTION_CAST(CURLcode, (CURL *, CURLINFO info, ...)) $a_api)
|
||||
((CURL *) $a_curl_handle,
|
||||
(CURLINFO)$a_opt,
|
||||
$a_data);
|
||||
]"
|
||||
end
|
||||
|
||||
note
|
||||
library: "cURL: Library of reusable components for Eiffel."
|
||||
copyright: "Copyright (c) 1984-2010, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
|
||||
end
|
||||
254
contrib/ise_library/cURL/curl_externals.e
Normal file
254
contrib/ise_library/cURL/curl_externals.e
Normal file
@@ -0,0 +1,254 @@
|
||||
note
|
||||
description: "[
|
||||
cURL externals.
|
||||
For more information, see:
|
||||
http://curl.haxx.se/libcurl/c/
|
||||
]"
|
||||
status: "See notice at end of class."
|
||||
legal: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CURL_EXTERNALS
|
||||
|
||||
feature -- Command
|
||||
|
||||
global_init
|
||||
-- Declared as curl_global_init().
|
||||
require
|
||||
dynamic_library_exists: is_dynamic_library_exists
|
||||
local
|
||||
l_ptr: POINTER
|
||||
do
|
||||
l_ptr := api_loader.api_pointer ("curl_global_init")
|
||||
if l_ptr /= default_pointer then
|
||||
c_curl_global_init (l_ptr, {CURL_GLOBAL_CONSTANTS}.curl_global_all);
|
||||
end
|
||||
end
|
||||
|
||||
global_cleanup
|
||||
-- Declared as curl_global_cleanup().
|
||||
local
|
||||
l_ptr: POINTER
|
||||
do
|
||||
l_ptr := api_loader.api_pointer ("curl_global_cleanup")
|
||||
if l_ptr /= default_pointer then
|
||||
c_curl_global_cleanup (l_ptr);
|
||||
end
|
||||
end
|
||||
|
||||
formadd_string_string (a_form: CURL_FORM; a_last_pointer: CURL_FORM; a_arg_1: INTEGER; a_arg_1_value: READABLE_STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: READABLE_STRING_GENERAL; a_arg_3: INTEGER)
|
||||
-- Declared as curl_formadd ().
|
||||
require
|
||||
not_void: a_form /= Void
|
||||
not_void: a_last_pointer /= Void
|
||||
valid: (create {CURL_FORM_CONSTANTS}).is_valid (a_arg_1)
|
||||
not_void: a_arg_1_value /= Void
|
||||
valid: (create {CURL_FORM_CONSTANTS}).is_valid (a_arg_2)
|
||||
not_void: a_arg_2_value /= Void
|
||||
valid: (create {CURL_FORM_CONSTANTS}).is_valid (a_arg_3)
|
||||
local
|
||||
l_form_pointer, l_last_pointer: POINTER
|
||||
do
|
||||
l_form_pointer := a_form.item
|
||||
l_last_pointer := a_last_pointer.item
|
||||
|
||||
internal_formadd_string_string ($l_form_pointer, $l_last_pointer, a_arg_1, a_arg_1_value, a_arg_2, a_arg_2_value, a_arg_3)
|
||||
|
||||
if a_form.item /= l_form_pointer then
|
||||
check not_set: a_form.item = default_pointer end
|
||||
a_form.set_item (l_form_pointer)
|
||||
end
|
||||
if a_last_pointer.item /= l_last_pointer then
|
||||
a_last_pointer.set_item (l_last_pointer)
|
||||
end
|
||||
end
|
||||
|
||||
slist_append (a_list: POINTER; a_string: READABLE_STRING_GENERAL): POINTER
|
||||
-- Declared as curl_slist_append ().
|
||||
-- note: call with a null `a_list' to get initialized pointer as Result
|
||||
require
|
||||
not_void: a_string /= Void
|
||||
local
|
||||
l_c_string: C_STRING
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_slist_append")
|
||||
if l_api /= default_pointer then
|
||||
create l_c_string.make (a_string)
|
||||
Result := c_slist_append (l_api, a_list, l_c_string.item)
|
||||
end
|
||||
end
|
||||
|
||||
slist_free_all (a_curl_slist: POINTER)
|
||||
-- Declared as curl_slist_free_all ().
|
||||
-- See: http://curl.haxx.se/libcurl/c/curl_slist_free_all.html
|
||||
-- curl_slist_free_all - free an entire curl_slist list
|
||||
-- This must be called when the data has been used, which typically means after the curl_easy_perform(3) has been called.
|
||||
require
|
||||
exists: a_curl_slist /= default_pointer
|
||||
local
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_slist_free_all")
|
||||
if l_api /= default_pointer then
|
||||
c_slist_free_all (l_api, a_curl_slist)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
is_dynamic_library_exists: BOOLEAN
|
||||
-- If dll/so files exist?
|
||||
do
|
||||
Result := api_loader.is_interface_usable
|
||||
end
|
||||
|
||||
feature {CURL_FORM} -- Internal command
|
||||
|
||||
formfree (a_curl_form: POINTER)
|
||||
-- Declared as curl_formfree ().
|
||||
-- See: http://curl.askapache.com/libcurl/c/curl_formfree.html
|
||||
-- curl_formfree() is used to clean up data previously built/appended with curl_formadd(3).
|
||||
-- This must be called when the data has been used, which typically means after the curl_easy_perform(3) has been called.
|
||||
require
|
||||
exists: a_curl_form /= default_pointer
|
||||
local
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_formfree")
|
||||
if l_api /= default_pointer then
|
||||
c_formfree (l_api, a_curl_form)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
api_loader: DYNAMIC_MODULE
|
||||
-- Module name.
|
||||
local
|
||||
l_utility: CURL_UTILITY
|
||||
once
|
||||
create l_utility
|
||||
Result := l_utility.api_loader
|
||||
end
|
||||
|
||||
internal_formadd_string_string (a_form: TYPED_POINTER [POINTER]; a_last_pointer: TYPED_POINTER [POINTER]; a_arg_1: INTEGER; a_arg_1_value: READABLE_STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: READABLE_STRING_GENERAL; a_arg_3: INTEGER)
|
||||
-- Declared as curl_formadd ().
|
||||
local
|
||||
l_c_string_1, l_c_string_2: C_STRING
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_formadd");
|
||||
if l_api /= default_pointer then
|
||||
create l_c_string_1.make (a_arg_1_value)
|
||||
create l_c_string_2.make (a_arg_2_value)
|
||||
c_formadd_string_string (l_api, a_form, a_last_pointer, a_arg_1, l_c_string_1.item, a_arg_2, l_c_string_2.item, a_arg_3)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- C externals
|
||||
|
||||
c_formadd_string_string (a_api: POINTER; a_form: TYPED_POINTER [POINTER]; a_last_pointer: TYPED_POINTER [POINTER]; a_arg_1: INTEGER; a_arg_1_value: POINTER; a_arg_2: INTEGER; a_arg_2_value: POINTER; a_arg_3: INTEGER)
|
||||
-- C implementation of formadd_string_string ().
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
{
|
||||
(FUNCTION_CAST(void, (struct curl_httppost **, struct curl_httppost **, int, char *, int, char *, int)) $a_api)
|
||||
((struct curl_httppost **)$a_form,
|
||||
(struct curl_httppost **)$a_last_pointer,
|
||||
(int)$a_arg_1,
|
||||
(char *)$a_arg_1_value,
|
||||
(int)$a_arg_2,
|
||||
(char *)$a_arg_2_value,
|
||||
(int)$a_arg_3);
|
||||
}
|
||||
]"
|
||||
end
|
||||
|
||||
c_formfree (a_api: POINTER; a_curl_form: POINTER)
|
||||
-- Declared as curl_formfree ().
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
exists: a_curl_form /= default_pointer
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
(FUNCTION_CAST(void, (struct curl_httppost *)) $a_api)
|
||||
((struct curl_httppost *) $a_curl_form);
|
||||
]"
|
||||
end
|
||||
|
||||
c_curl_global_init (a_api: POINTER; a_opt: NATURAL_64)
|
||||
-- `a_api' point to API curl_global_init ()
|
||||
-- `a_opt' is intialization option.
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
(FUNCTION_CAST(void, (long)) $a_api)((long) $a_opt);
|
||||
]"
|
||||
end
|
||||
|
||||
c_curl_global_cleanup (a_api: POINTER)
|
||||
-- `a_api' point to API curl_global_cleanup()
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
(FUNCTION_CAST(void, ()) $a_api)();
|
||||
]"
|
||||
end
|
||||
|
||||
c_slist_append (a_api: POINTER; a_list_pointer: POINTER; a_string: POINTER): POINTER
|
||||
-- Declared as curl_slist_append ().
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
{
|
||||
return (FUNCTION_CAST(void *, (struct curl_slist *, const char *)) $a_api)
|
||||
((struct curl_slist *)$a_list_pointer,
|
||||
(const char *)$a_string);
|
||||
}
|
||||
]"
|
||||
end
|
||||
|
||||
c_slist_free_all (a_api: POINTER; a_list_pointer: POINTER)
|
||||
-- Declared as void curl_slist_free_all(struct curl_slist * list)
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
(FUNCTION_CAST(void *, (struct curl_slist *)) $a_api)
|
||||
((struct curl_slist *)$a_list_pointer);
|
||||
]"
|
||||
end
|
||||
|
||||
note
|
||||
library: "cURL: Library of reusable components for Eiffel."
|
||||
copyright: "Copyright (c) 1984-2010, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
|
||||
end
|
||||
94
contrib/ise_library/cURL/curl_form.e
Normal file
94
contrib/ise_library/cURL/curl_form.e
Normal file
@@ -0,0 +1,94 @@
|
||||
note
|
||||
description: "[
|
||||
cURL form.
|
||||
For more informaton see:
|
||||
http://curl.haxx.se/libcurl/c/curl_formadd.html
|
||||
]"
|
||||
status: "See notice at end of class."
|
||||
legal: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CURL_FORM
|
||||
|
||||
inherit
|
||||
DISPOSABLE
|
||||
|
||||
create
|
||||
make,
|
||||
share_with_pointer
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Creation method.
|
||||
do
|
||||
end
|
||||
|
||||
share_with_pointer (a_pointer: POINTER)
|
||||
-- Creation method.
|
||||
-- `item' share with `a_pointer'.
|
||||
require
|
||||
exists: a_pointer /= default_pointer
|
||||
do
|
||||
item := a_pointer
|
||||
ensure
|
||||
set: item = a_pointer
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
item: POINTER
|
||||
-- C pointer of Current.
|
||||
|
||||
is_exists: BOOLEAN
|
||||
-- If C pointer exists?
|
||||
do
|
||||
Result := item /= default_pointer
|
||||
end
|
||||
|
||||
feature -- Command
|
||||
|
||||
dispose
|
||||
-- Free memory if possible.
|
||||
local
|
||||
l_curl: CURL_EXTERNALS
|
||||
do
|
||||
if item /= default_pointer then
|
||||
create l_curl
|
||||
l_curl.formfree (item)
|
||||
item := default_pointer
|
||||
end
|
||||
end
|
||||
|
||||
release_item
|
||||
-- Release item
|
||||
-- NOT free memory! This is useful if Current generated by {CURL_EXTERNALS}.formadd_string_string.
|
||||
do
|
||||
item := default_pointer
|
||||
end
|
||||
|
||||
feature {CURL_EXTERNALS} -- Internal command
|
||||
|
||||
set_item (a_item: POINTER)
|
||||
-- Set `item' with `a_item'
|
||||
do
|
||||
item := a_item
|
||||
ensure
|
||||
set: item = a_item
|
||||
end
|
||||
|
||||
note
|
||||
library: "cURL: Library of reusable components for Eiffel."
|
||||
copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
356 Storke Road, Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
|
||||
end
|
||||
78
contrib/ise_library/cURL/curl_form_constants.e
Normal file
78
contrib/ise_library/cURL/curl_form_constants.e
Normal file
@@ -0,0 +1,78 @@
|
||||
note
|
||||
description: "[
|
||||
cURL form constants.
|
||||
For more informaton see:
|
||||
http://curl.haxx.se/libcurl/c/curl_formadd.html
|
||||
]"
|
||||
status: "See notice at end of class."
|
||||
legal: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CURL_FORM_CONSTANTS
|
||||
|
||||
feature -- Query
|
||||
|
||||
curlform_copyname: INTEGER
|
||||
-- Declared as CURLFORM_COPYNAME
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
CURLFORM_COPYNAME
|
||||
]"
|
||||
end
|
||||
|
||||
curlform_copycontents: INTEGER
|
||||
-- Declared as CURLFORM_COPYCONTENTS
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
CURLFORM_COPYCONTENTS
|
||||
]"
|
||||
end
|
||||
|
||||
curlform_end: INTEGER
|
||||
-- Declared as CURLFORM_END
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
CURLFORM_END
|
||||
]"
|
||||
end
|
||||
|
||||
curlform_file: INTEGER
|
||||
-- Declared as CURLFORM_FILE
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
CURLFORM_FILE
|
||||
]"
|
||||
end
|
||||
|
||||
is_valid (a_integer: INTEGER): BOOLEAN
|
||||
-- If `a_integer' valid?
|
||||
do
|
||||
Result := a_integer = curlform_copycontents or
|
||||
a_integer = curlform_copyname or
|
||||
a_integer = curlform_end or
|
||||
a_integer = curlform_file
|
||||
end
|
||||
|
||||
note
|
||||
library: "cURL: Library of reusable components for Eiffel."
|
||||
copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
356 Storke Road, Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
|
||||
end
|
||||
257
contrib/ise_library/cURL/curl_function.e
Normal file
257
contrib/ise_library/cURL/curl_function.e
Normal file
@@ -0,0 +1,257 @@
|
||||
note
|
||||
description: "[
|
||||
cURL curl_easy_setopt callback functions' Eiffel wrappers.
|
||||
We need this class since cURL need a c function pointer as value but
|
||||
Eiffel function need frist parameter of any funciton call is object address.
|
||||
Client programmers can inherit this class to fit their needs.
|
||||
|
||||
Note: descendants of this class have to call `set_object_and_function_address',
|
||||
otherwise cURL would not know how to call Eiffel features (such as `write_function').
|
||||
See example: $ISE_LIBRARY\examples\cURL\upload_and_read_function
|
||||
|
||||
See http://curl.haxx.se/libcurl/c/curl_easy_setopt.html for libcurl documentation
|
||||
]"
|
||||
status: "See notice at end of class."
|
||||
legal: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CURL_FUNCTION
|
||||
|
||||
inherit
|
||||
DISPOSABLE
|
||||
|
||||
feature -- Interactive with C
|
||||
|
||||
set_object_and_function_address
|
||||
-- Set object and function addresses.
|
||||
-- Call this feature before call `c_set_progress_function', `c_set_debug_function' and `c_set_write_function, c_set_read_function'.
|
||||
do
|
||||
c_set_object ($Current)
|
||||
c_set_progress_function_address ($progress_function)
|
||||
c_set_write_function_address ($write_function)
|
||||
c_set_read_function_address ($read_function)
|
||||
c_set_debug_function_address ($debug_function)
|
||||
end
|
||||
|
||||
c_set_progress_function (a_setopt_api: POINTER; a_curl_handle: POINTER)
|
||||
-- Setting CURLOPT_PROGRESSFUNCTION option of `a_curl_handle'.
|
||||
-- We need this function since cURL need a c function pointer as value.
|
||||
require
|
||||
exists: a_setopt_api /= default_pointer
|
||||
external
|
||||
"C inline use <eiffel_curl.h>"
|
||||
alias
|
||||
"[
|
||||
{
|
||||
(FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_setopt_api)
|
||||
((CURL *) $a_curl_handle,
|
||||
(CURLoption)CURLOPT_PROGRESSFUNCTION,
|
||||
curl_progress_function);
|
||||
}
|
||||
]"
|
||||
end
|
||||
|
||||
c_set_debug_function (a_setopt_api: POINTER; a_curl_handle: POINTER)
|
||||
-- Setting CURLOPT_DEBUGFUNCTION option of `a_curl_handle'.
|
||||
-- We need this function since cURL need a c function pointer as value.
|
||||
require
|
||||
exists: a_curl_handle /= default_pointer
|
||||
external
|
||||
"C inline use <eiffel_curl.h>"
|
||||
alias
|
||||
"[
|
||||
{
|
||||
(FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_setopt_api)
|
||||
((CURL *) $a_curl_handle,
|
||||
(CURLoption)CURLOPT_DEBUGFUNCTION,
|
||||
curl_debug_function);
|
||||
|
||||
}
|
||||
]"
|
||||
end
|
||||
|
||||
c_set_write_function (a_setopt_api: POINTER; a_curl_handle: POINTER)
|
||||
-- Setting CURLOPT_WRITEFUNCTION option of `a_curl_handle'.
|
||||
-- We need this function since cURL need a c function pointer as value.
|
||||
require
|
||||
exists: a_setopt_api /= default_pointer
|
||||
external
|
||||
"C inline use <eiffel_curl.h>"
|
||||
alias
|
||||
"[
|
||||
{
|
||||
(FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_setopt_api)
|
||||
((CURL *) $a_curl_handle,
|
||||
(CURLoption)CURLOPT_WRITEFUNCTION,
|
||||
curl_write_function);
|
||||
}
|
||||
]"
|
||||
end
|
||||
|
||||
c_set_read_function (a_setopt_api: POINTER; a_curl_handle: POINTER)
|
||||
-- Setting CURLOPT_READFUNCTION option of `a_curl_handle'.
|
||||
-- We need this function since cURL need a c function pointer as value.
|
||||
require
|
||||
exists: a_setopt_api /= default_pointer
|
||||
external
|
||||
"C inline use <eiffel_curl.h>"
|
||||
alias
|
||||
"[
|
||||
{
|
||||
(FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_setopt_api)
|
||||
((CURL *) $a_curl_handle,
|
||||
(CURLoption)CURLOPT_READFUNCTION,
|
||||
curl_read_function);
|
||||
}
|
||||
]"
|
||||
end
|
||||
|
||||
feature -- cURL curl_easy_setopt functions
|
||||
|
||||
progress_function (a_object_id: POINTER; a_download_total, a_download_now, a_upload_total, a_upload_now: REAL_64): INTEGER
|
||||
-- Function correspond to {CURL_OPT_CONSTANTS}.curlopt_progressfunction
|
||||
-- Note, pass a {IDENTIFIED}.object_id as `a_object_id' value is helpful since we can't directly pass an Eiffel Object address which
|
||||
-- may changed during GC.
|
||||
deferred
|
||||
end
|
||||
|
||||
write_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER
|
||||
-- Function called by libcurl as soon as there is data received that needs to be saved.
|
||||
-- The size of the data pointed to by `a_data_pointer' is `a_size' multiplied with `a_nmemb', it will not be null terminated.
|
||||
-- Returns the number of bytes actually taken care of
|
||||
--
|
||||
-- Function corresponds to {CURL_OPT_CONSTANTS}.curlopt_writefunction
|
||||
-- Note, pass a {IDENTIFIED}.object_id as `a_object_id' value is helpful since we can't directly pass an Eiffel Object address which
|
||||
-- may changed during GC.
|
||||
--| libcurl doc:
|
||||
--| Function pointer that should match the following prototype: size_t function( char *ptr, size_t size, size_t nmemb, void *userdata);
|
||||
--| This function gets called by libcurl as soon as there is data received that needs to be saved.
|
||||
--| The size of the data pointed to by ptr is size multiplied with nmemb, it will not be zero terminated.
|
||||
--| Return the number of bytes actually taken care of.
|
||||
--| If that amount differs from the amount passed to your function, it'll signal an error to the library.
|
||||
--| This will abort the transfer and return CURLE_WRITE_ERROR.
|
||||
--| From 7.18.0, the function can return CURL_WRITEFUNC_PAUSE which then will cause writing to this connection to become paused.
|
||||
--| See curl_easy_pause(3) for further details.
|
||||
--|
|
||||
--| This function may be called with zero bytes data if the transferred file is empty.
|
||||
--|
|
||||
--| Set this option to NULL to get the internal default function.
|
||||
--| The internal default function will write the data to the FILE * given with CURLOPT_WRITEDATA.
|
||||
--|
|
||||
--| Set the userdata argument with the CURLOPT_WRITEDATA option.
|
||||
--|
|
||||
--| The callback function will be passed as much data as possible in all invokes,
|
||||
--| but you cannot possibly make any assumptions. It may be one byte, it may be thousands.
|
||||
--| The maximum amount of body data that can be passed to the write callback is defined
|
||||
--| in the curl.h header file: CURL_MAX_WRITE_SIZE (the usual default is 16K).
|
||||
--| If you however have CURLOPT_HEADER set, which sends header data to the write callback,
|
||||
--| you can get up to CURL_MAX_HTTP_HEADER bytes of header data passed into it. This usually means 100K.
|
||||
deferred
|
||||
end
|
||||
|
||||
read_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER
|
||||
-- Function called by libcurl as soon as it needs to read data in order to send it to the peer.
|
||||
-- The data area pointed at by the pointer `a_data_pointer' may be filled with at most
|
||||
-- `a_size' multiplied with `a_nmemb' number of bytes.
|
||||
-- Returns the actual number of bytes stored in that memory area.
|
||||
-- Returning 0 will signal end-of-file to the library and cause it to stop the current transfer.
|
||||
--
|
||||
-- Function corresponds to {CURL_OPT_CONSTANTS}.curlopt_readfunction
|
||||
-- Note, pass a {IDENTIFIED}.object_id as `a_object_id' value is helpful since we can't directly pass an Eiffel Object address which
|
||||
-- may changed during GC.
|
||||
--| libcurl doc:
|
||||
--| Function pointer that should match the following prototype: size_t function( void *ptr, size_t size, size_t nmemb, void *userdata);
|
||||
--| This function gets called by libcurl as soon as it needs to read data in order to send it to the peer.
|
||||
--| The data area pointed at by the pointer ptr may be filled with at most size multiplied with nmemb number of bytes.
|
||||
--| Your function must return the actual number of bytes that you stored in that memory area.
|
||||
--| Returning 0 will signal end-of-file to the library and cause it to stop the current transfer.
|
||||
--|
|
||||
--| If you stop the current transfer by returning 0 "pre-maturely" (i.e before the server expected it,
|
||||
--| like when you've said you will upload N bytes and you upload less than N bytes),
|
||||
--| you may experience that the server "hangs" waiting for the rest of the data that won't come.
|
||||
--|
|
||||
--| The read callback may return CURL_READFUNC_ABORT to stop the current operation immediately,
|
||||
--| resulting in a CURLE_ABORTED_BY_CALLBACK error code from the transfer (Added in 7.12.1)
|
||||
--|
|
||||
--| From 7.18.0, the function can return CURL_READFUNC_PAUSE which then will cause reading from this connection to become paused.
|
||||
--| See curl_easy_pause(3) for further details.
|
||||
--|
|
||||
--| Bugs: when doing TFTP uploads, you must return the exact amount of data that the callback wants,
|
||||
--| or it will be considered the final packet by the server end and the transfer will end there.
|
||||
--|
|
||||
--| If you set this callback pointer to NULL, or don't set it at all, the default internal read function will be used.
|
||||
--| It is doing an fread() on the FILE * userdata set with CURLOPT_READDATA.
|
||||
deferred
|
||||
end
|
||||
|
||||
debug_function (a_curl_handle: POINTER; a_curl_infotype: INTEGER; a_char_pointer: POINTER; a_size: INTEGER; a_object_id: POINTER): INTEGER
|
||||
-- Function correspond to {CURL_OPT_CONSTANTS}.curlopt_debugfunction
|
||||
-- Note, pass a {IDENTIFIED}.object_id as `a_object_id' value is helpful since we can't directly pass an Eiffel Object address which
|
||||
-- may changed during GC.
|
||||
require
|
||||
vaild: (create {CURL_INFO_TYPE}).is_valid (a_curl_infotype)
|
||||
deferred
|
||||
end
|
||||
|
||||
feature {NONE} -- Externals
|
||||
|
||||
c_set_object (a_object: POINTER)
|
||||
-- Set Current object address.
|
||||
external
|
||||
"C signature (EIF_REFERENCE) use %"eiffel_curl.h%""
|
||||
end
|
||||
|
||||
c_release_object
|
||||
-- Release Current pointer in C
|
||||
external
|
||||
"C use %"eiffel_curl.h%""
|
||||
end
|
||||
|
||||
c_set_progress_function_address (a_address: POINTER)
|
||||
-- Set progress function address.
|
||||
external
|
||||
"C use %"eiffel_curl.h%""
|
||||
end
|
||||
|
||||
c_set_write_function_address (a_address: POINTER)
|
||||
-- Set write function address.
|
||||
external
|
||||
"C use %"eiffel_curl.h%""
|
||||
end
|
||||
|
||||
c_set_read_function_address (a_address: POINTER)
|
||||
-- Set read function address.
|
||||
external
|
||||
"C use %"eiffel_curl.h%""
|
||||
end
|
||||
|
||||
c_set_debug_function_address (a_address: POINTER)
|
||||
-- Set write function address.
|
||||
external
|
||||
"C use %"eiffel_curl.h%""
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
dispose
|
||||
-- Wean `Current'
|
||||
do
|
||||
c_release_object
|
||||
c_set_object (default_pointer)
|
||||
end
|
||||
|
||||
note
|
||||
library: "cURL: Library of reusable components for Eiffel."
|
||||
copyright: "Copyright (c) 1984-2012, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
|
||||
end
|
||||
78
contrib/ise_library/cURL/curl_global_constants.e
Normal file
78
contrib/ise_library/cURL/curl_global_constants.e
Normal file
@@ -0,0 +1,78 @@
|
||||
note
|
||||
description: "[
|
||||
cURL library constants used by curl_global_init ()
|
||||
]"
|
||||
status: "See notice at end of class."
|
||||
legal: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CURL_GLOBAL_CONSTANTS
|
||||
|
||||
feature -- Query
|
||||
|
||||
curl_global_ssl: NATURAL_64
|
||||
-- Delcared as CURL_GLOBAL_SSL
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
return CURL_GLOBAL_SSL;
|
||||
]"
|
||||
end
|
||||
|
||||
curl_global_win32: NATURAL_64
|
||||
-- Delcared as CURL_GLOBAL_WIN32
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
return CURL_GLOBAL_WIN32;
|
||||
]"
|
||||
end
|
||||
|
||||
curl_global_all: NATURAL_64
|
||||
-- Delcared as CURL_GLOBAL_ALL
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
return CURL_GLOBAL_ALL;
|
||||
]"
|
||||
end
|
||||
|
||||
curl_global_nothing: NATURAL_64
|
||||
-- Delcared as CURL_GLOBAL_NOTHING
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
return CURL_GLOBAL_NOTHING;
|
||||
]"
|
||||
end
|
||||
|
||||
curl_global_default: NATURAL_64
|
||||
-- Delcared as CURL_GLOBAL_DEFAULT
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
return CURL_GLOBAL_DEFAULT;
|
||||
]"
|
||||
end
|
||||
|
||||
note
|
||||
library: "cURL: Library of reusable components for Eiffel."
|
||||
copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
356 Storke Road, Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
|
||||
end
|
||||
|
||||
122
contrib/ise_library/cURL/curl_info_constants.e
Normal file
122
contrib/ise_library/cURL/curl_info_constants.e
Normal file
@@ -0,0 +1,122 @@
|
||||
note
|
||||
description: "[
|
||||
cURL library info constants.
|
||||
]"
|
||||
status: "See notice at end of class."
|
||||
legal: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CURL_INFO_CONSTANTS
|
||||
|
||||
feature -- Constants
|
||||
|
||||
curlinfo_string: INTEGER = 0x100000
|
||||
-- Declared as CURLINFO_STRING
|
||||
|
||||
curlinfo_long: INTEGER = 0x200000
|
||||
-- Declared as CURLINFO_LONG
|
||||
|
||||
curlinfo_double: INTEGER = 0x300000
|
||||
-- Declared as CURLINFO_DOUBLE
|
||||
|
||||
curlinfo_slist: INTEGER = 0x400000
|
||||
-- Declared as CURLINFO_SLIST
|
||||
|
||||
curlinfo_mask: INTEGER = 0x0fffff
|
||||
-- Declared as CURLINFO_MASK
|
||||
|
||||
curlinfo_typemask: INTEGER = 0xf00000
|
||||
-- Declared as CURLINFO_TYPEMASK
|
||||
|
||||
feature -- Info constants
|
||||
|
||||
curlinfo_effective_url: INTEGER = 0x100001 -- CURLINFO_STRING + 1,
|
||||
curlinfo_response_code: INTEGER = 0x200002 -- CURLINFO_LONG + 2,
|
||||
curlinfo_total_time: INTEGER = 0x300003 -- CURLINFO_DOUBLE + 3,
|
||||
curlinfo_namelookup_time: INTEGER = 0x300004 -- CURLINFO_DOUBLE + 4,
|
||||
curlinfo_connect_time: INTEGER = 0x300005 -- CURLINFO_DOUBLE + 5,
|
||||
curlinfo_pretransfer_time: INTEGER = 0x300006 -- CURLINFO_DOUBLE + 6,
|
||||
curlinfo_size_upload: INTEGER = 0x300007 -- CURLINFO_DOUBLE + 7,
|
||||
curlinfo_size_download: INTEGER = 0x300008 -- CURLINFO_DOUBLE + 8,
|
||||
curlinfo_speed_download: INTEGER = 0x300009 -- CURLINFO_DOUBLE + 9,
|
||||
curlinfo_speed_upload: INTEGER = 0x30000a -- CURLINFO_DOUBLE + 10,
|
||||
curlinfo_header_size: INTEGER = 0x20000b -- CURLINFO_LONG + 11,
|
||||
curlinfo_request_size: INTEGER = 0x20000c -- CURLINFO_LONG + 12,
|
||||
curlinfo_ssl_verifyresult: INTEGER = 0x20000d -- CURLINFO_LONG + 13,
|
||||
curlinfo_filetime: INTEGER = 0x20000e -- CURLINFO_LONG + 14,
|
||||
curlinfo_content_length_download: INTEGER = 0x30000f -- CURLINFO_DOUBLE + 15,
|
||||
curlinfo_content_length_upload: INTEGER = 0x300010 -- CURLINFO_DOUBLE + 16,
|
||||
curlinfo_starttransfer_time: INTEGER = 0x300011 -- CURLINFO_DOUBLE + 17,
|
||||
curlinfo_content_type: INTEGER = 0x100012 -- CURLINFO_STRING + 18,
|
||||
curlinfo_redirect_time: INTEGER = 0x300013 -- CURLINFO_DOUBLE + 19,
|
||||
curlinfo_redirect_count: INTEGER = 0x200014 -- CURLINFO_LONG + 20,
|
||||
curlinfo_private: INTEGER = 0x100015 -- CURLINFO_STRING + 21,
|
||||
curlinfo_http_connectcode: INTEGER = 0x200016 -- CURLINFO_LONG + 22,
|
||||
curlinfo_httpauth_avail: INTEGER = 0x200017 -- CURLINFO_LONG + 23,
|
||||
curlinfo_proxyauth_avail: INTEGER = 0x200018 -- CURLINFO_LONG + 24,
|
||||
curlinfo_os_errno: INTEGER = 0x200019 -- CURLINFO_LONG + 25,
|
||||
curlinfo_num_connects: INTEGER = 0x20001a -- CURLINFO_LONG + 26,
|
||||
curlinfo_ssl_engines: INTEGER = 0x40001b -- CURLINFO_SLIST + 27,
|
||||
curlinfo_cookielist: INTEGER = 0x40001c -- CURLINFO_SLIST + 28,
|
||||
curlinfo_lastsocket: INTEGER = 0x20001d -- CURLINFO_LONG + 29,
|
||||
curlinfo_ftp_entry_path: INTEGER = 0x10001e -- CURLINFO_STRING + 30,
|
||||
|
||||
feature -- Contract support
|
||||
|
||||
is_valid (a_code: INTEGER): BOOLEAN
|
||||
-- Is `a_code' valid?
|
||||
do
|
||||
inspect a_code
|
||||
when
|
||||
curlinfo_effective_url,
|
||||
curlinfo_response_code,
|
||||
curlinfo_total_time,
|
||||
curlinfo_namelookup_time,
|
||||
curlinfo_connect_time,
|
||||
curlinfo_pretransfer_time,
|
||||
curlinfo_size_upload,
|
||||
curlinfo_size_download,
|
||||
curlinfo_speed_download,
|
||||
curlinfo_speed_upload,
|
||||
curlinfo_header_size,
|
||||
curlinfo_request_size,
|
||||
curlinfo_ssl_verifyresult,
|
||||
curlinfo_filetime,
|
||||
curlinfo_content_length_download,
|
||||
curlinfo_content_length_upload,
|
||||
curlinfo_starttransfer_time,
|
||||
curlinfo_content_type,
|
||||
curlinfo_redirect_time,
|
||||
curlinfo_redirect_count,
|
||||
curlinfo_private,
|
||||
curlinfo_http_connectcode,
|
||||
curlinfo_httpauth_avail,
|
||||
curlinfo_proxyauth_avail,
|
||||
curlinfo_os_errno,
|
||||
curlinfo_num_connects,
|
||||
curlinfo_ssl_engines,
|
||||
curlinfo_cookielist,
|
||||
curlinfo_lastsocket,
|
||||
curlinfo_ftp_entry_path
|
||||
then
|
||||
Result := True
|
||||
else
|
||||
Result := False
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
library: "cURL: Library of reusable components for Eiffel."
|
||||
copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
356 Storke Road, Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
|
||||
end
|
||||
69
contrib/ise_library/cURL/curl_info_type.e
Normal file
69
contrib/ise_library/cURL/curl_info_type.e
Normal file
@@ -0,0 +1,69 @@
|
||||
note
|
||||
description: "[
|
||||
cURL library info type constants.
|
||||
]"
|
||||
status: "See notice at end of class."
|
||||
legal: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CURL_INFO_TYPE
|
||||
|
||||
feature -- Enumeration
|
||||
|
||||
curlinfo_text: INTEGER = 0
|
||||
-- Declared as CURLINFO_TEXT
|
||||
|
||||
curlinfo_header_in: INTEGER = 1
|
||||
-- Declared as CURLINFO_HEADER_IN
|
||||
|
||||
curlinfo_header_out: INTEGER = 2
|
||||
-- Declared as CURLINFO_HEADER_OUT
|
||||
|
||||
curlinfo_data_in: INTEGER = 3
|
||||
-- Declared as CURLINFO_DATA_IN
|
||||
|
||||
curlinfo_data_out: INTEGER = 4
|
||||
-- Declared as CURLINFO_DATA_OUT
|
||||
|
||||
curlinfo_ssl_data_in: INTEGER = 5
|
||||
-- Declared as CURLINFO_SSL_DATA_IN
|
||||
|
||||
curlinfo_ssl_data_out: INTEGER = 6
|
||||
-- Declared as CURLINFO_SSL_DATA_OUT
|
||||
|
||||
feature -- Contract support
|
||||
|
||||
is_valid (a_type: INTEGER): BOOLEAN
|
||||
-- If `a_type' valid?
|
||||
do
|
||||
inspect a_type
|
||||
when
|
||||
curlinfo_data_in,
|
||||
curlinfo_data_out,
|
||||
curlinfo_header_in,
|
||||
curlinfo_header_out,
|
||||
curlinfo_ssl_data_in,
|
||||
curlinfo_ssl_data_out,
|
||||
curlinfo_text
|
||||
then
|
||||
Result := True
|
||||
else
|
||||
Result := False
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
library: "cURL: Library of reusable components for Eiffel."
|
||||
copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
356 Storke Road, Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
|
||||
end
|
||||
51
contrib/ise_library/cURL/curl_msg.e
Normal file
51
contrib/ise_library/cURL/curl_msg.e
Normal file
@@ -0,0 +1,51 @@
|
||||
note
|
||||
description: "[
|
||||
C CURLMSG enum
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CURL_MSG
|
||||
|
||||
feature -- Query
|
||||
|
||||
curlmsg_done: INTEGER
|
||||
-- Declared as CURLMSG_DONE.
|
||||
-- This easy handle has completed.
|
||||
-- 'result' contains the CURLcode of the transfer
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"return CURLMSG_DONE;"
|
||||
end
|
||||
|
||||
curlmsg_none: INTEGER
|
||||
-- Declared as CURLMSG_NONE.
|
||||
-- First, not used
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"return CURLMSG_NONE;"
|
||||
end
|
||||
|
||||
curlmsg_last: INTEGER
|
||||
-- Declared as CURLMSG_LAST.
|
||||
-- Last, not used
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"return CURLMSG_LAST;"
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "Copyright (c) 1984-2012, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
83
contrib/ise_library/cURL/curl_msg_struct.e
Normal file
83
contrib/ise_library/cURL/curl_msg_struct.e
Normal file
@@ -0,0 +1,83 @@
|
||||
note
|
||||
description: "[
|
||||
|
||||
C Struct CURLMsg wrapper
|
||||
Read multi stack informationals
|
||||
|
||||
This class is used by {CURL_MSG_STRUCT}.info_read
|
||||
|
||||
More info:
|
||||
http://curl.haxx.se/libcurl/c/curl_multi_info_read.html
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CURL_MSG_STRUCT
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_pointer: POINTER)
|
||||
-- Creation method
|
||||
-- Bind message structure to the address `a_pointer'".
|
||||
require
|
||||
not_default: a_pointer /= default_pointer
|
||||
do
|
||||
item := a_pointer
|
||||
ensure
|
||||
set: item = a_pointer
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
curl_handle: POINTER
|
||||
-- CURL easy_handle
|
||||
-- The handle it concerns
|
||||
do
|
||||
Result := c_curl_handle (item)
|
||||
end
|
||||
|
||||
msg: INTEGER
|
||||
-- What does this message mean?
|
||||
-- It's one value from {CURLMSG}
|
||||
do
|
||||
Result := c_msg (item)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
item: POINTER
|
||||
-- C struct item
|
||||
|
||||
feature {NONE} -- C externals
|
||||
|
||||
c_curl_handle (a_item: POINTER): POINTER
|
||||
-- cURL easy handle it concerns
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"return (CURL *)((CURLMsg *)$a_item)->easy_handle;"
|
||||
end
|
||||
|
||||
c_msg (a_item: POINTER): INTEGER
|
||||
-- Get msg
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"return (CURLMSG)((CURLMsg *)$a_item)->msg;"
|
||||
end
|
||||
|
||||
;note
|
||||
copyright: "Copyright (c) 1984-2012, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
48
contrib/ise_library/cURL/curl_multi_codes.e
Normal file
48
contrib/ise_library/cURL/curl_multi_codes.e
Normal file
@@ -0,0 +1,48 @@
|
||||
note
|
||||
description: "[
|
||||
The generic return code used by functions in the libcurl multi interface.
|
||||
Also consider curl_multi_strerror(3).
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CURL_MULTI_CODES
|
||||
|
||||
feature -- Query
|
||||
|
||||
curlm_call_multi_perform: INTEGER = -1
|
||||
-- This is not really an error. It means you should call curl_multi_perform(3) again without doing select() or similar in between.
|
||||
|
||||
curlm_ok: INTEGER = 0
|
||||
-- Things are fine.
|
||||
|
||||
curlm_bad_handle: INTEGER = 1
|
||||
-- The passed-in handle is not a valid CURLM handle.
|
||||
|
||||
curlm_bad_easy_handle: INTEGER = 2
|
||||
-- An easy handle was not good/valid. It could mean that it isn't an easy handle at all, or possibly that the handle already is in used by this or another multi handle.
|
||||
|
||||
curlm_out_of_memory: INTEGER = 3
|
||||
-- You are doomed.
|
||||
|
||||
curlm_internal_error: INTEGER = 4
|
||||
-- This can only be returned if libcurl bugs. Please report it to us!
|
||||
|
||||
curlm_bad_socket: INTEGER = 5
|
||||
-- The passed-in socket is not a valid one that libcurl already knows about. (Added in 7.15.4)
|
||||
|
||||
curlm_unknown_option: INTEGER = 6
|
||||
-- curl_multi_setopt() with unsupported option (Added in 7.15.4)
|
||||
|
||||
note
|
||||
copyright: "Copyright (c) 1984-2012, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
251
contrib/ise_library/cURL/curl_multi_externals.e
Normal file
251
contrib/ise_library/cURL/curl_multi_externals.e
Normal file
@@ -0,0 +1,251 @@
|
||||
note
|
||||
description: "[
|
||||
The multi interface offers several abilities that the easy interface doesn't. They are mainly:
|
||||
1. Enable a "pull" interface. The application that uses libcurl decides where and when to ask libcurl to get/send data.
|
||||
2. Enable multiple simultaneous transfers in the same thread without making it complicated for the application.
|
||||
3. Enable the application to wait for action on its own file descriptors and curl's file descriptors simultaneous easily.
|
||||
|
||||
More info: http://curl.haxx.se/libcurl/c/libcurl-multi.html
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CURL_MULTI_EXTERNALS
|
||||
|
||||
feature -- Command
|
||||
|
||||
init
|
||||
-- Create a multi handle.
|
||||
-- If success, Result is a cURL multi hanlde just created.
|
||||
-- This feature maybe failed in some cases: cannot find required DLL, etc.
|
||||
-- Then the post condition would be violated.
|
||||
require
|
||||
dynamic_library_exists: is_dynamic_library_exists
|
||||
local
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_multi_init")
|
||||
if l_api /= default_pointer then
|
||||
item := c_init (l_api)
|
||||
end
|
||||
end
|
||||
|
||||
add_handle (a_easy_handle: POINTER)
|
||||
-- Add an easy handle to a multi session.
|
||||
require
|
||||
dynamic_library_exists: is_dynamic_library_exists
|
||||
is_multi_handle_exists: is_exists
|
||||
local
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_multi_add_handle")
|
||||
if l_api /= default_pointer then
|
||||
c_add_handle (l_api, item, a_easy_handle)
|
||||
end
|
||||
end
|
||||
|
||||
remove_handle (a_easy_handle: POINTER)
|
||||
-- Remove an easy handle from a multi session.
|
||||
require
|
||||
dynamic_library_exists: is_dynamic_library_exists
|
||||
is_multi_handle_exists: is_exists
|
||||
local
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_multi_remove_handle")
|
||||
if l_api /= default_pointer then
|
||||
c_remove_handle (l_api, item, a_easy_handle)
|
||||
end
|
||||
end
|
||||
|
||||
cleanup: INTEGER
|
||||
-- Close down a multi session.
|
||||
-- Result is one value from {CURL_MULTI_CODES}.
|
||||
require
|
||||
dynamic_library_exists: is_dynamic_library_exists
|
||||
is_multi_handle_exists: is_exists
|
||||
local
|
||||
l_api: POINTER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_multi_cleanup")
|
||||
if l_api /= default_pointer then
|
||||
Result := c_cleanup (l_api, item)
|
||||
end
|
||||
end
|
||||
|
||||
perform (a_running_handle: CELL [INTEGER]): INTEGER
|
||||
-- Reads/writes available data from each easy handle.
|
||||
-- Result is one value from {CURL_MULTI_CODES}.
|
||||
require
|
||||
dynamic_library_exists: is_dynamic_library_exists
|
||||
is_multi_handle_exists: is_exists
|
||||
local
|
||||
l_api: POINTER
|
||||
l_running_handle: INTEGER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_multi_perform")
|
||||
if l_api /= default_pointer then
|
||||
Result := c_perform (l_api, item, $l_running_handle)
|
||||
a_running_handle.put (l_running_handle)
|
||||
end
|
||||
end
|
||||
|
||||
info_read (a_msgs_in_queue: CELL [INTEGER]): POINTER
|
||||
-- Read multi stack informationals.
|
||||
-- The result is C struct CURLMsg {CURL_MSG_STRUCT}.
|
||||
-- Repeated calls to this function will return a new struct each time, until a NULL
|
||||
-- is returned as a signal that there is no more to get at this point. The integer
|
||||
-- pointed to with msgs_in_queue will contain the number of remaining messages after
|
||||
-- this function was called.
|
||||
-- When you fetch a message using this function, it is removed from the internal queue
|
||||
-- so calling this function again will not return the same message again. It will instead
|
||||
-- return new messages at each new invoke until the queue is emptied.
|
||||
require
|
||||
dynamic_library_exists: is_dynamic_library_exists
|
||||
is_multi_handle_exists: is_exists
|
||||
local
|
||||
l_api: POINTER
|
||||
l_msgs_in_queue: INTEGER
|
||||
do
|
||||
l_api := api_loader.api_pointer ("curl_multi_info_read")
|
||||
if l_api /= default_pointer then
|
||||
Result := c_info_read (l_api, item, $l_msgs_in_queue)
|
||||
a_msgs_in_queue.put (l_msgs_in_queue)
|
||||
end
|
||||
end
|
||||
|
||||
is_dynamic_library_exists: BOOLEAN
|
||||
-- Are required .dll/.so files available?
|
||||
do
|
||||
Result := api_loader.is_interface_usable
|
||||
end
|
||||
|
||||
-- Feature not yet wrapped/tested
|
||||
-- curl_multi_assign
|
||||
-- curl_multi_fdset
|
||||
-- curl_multi_setopt
|
||||
-- curl_multi_socket
|
||||
-- curl_multi_socket_action
|
||||
-- curl_multi_strerror
|
||||
-- curl_multi_timeout
|
||||
|
||||
feature -- Query
|
||||
|
||||
is_exists: BOOLEAN
|
||||
-- If C pointer exists?
|
||||
do
|
||||
Result := item /= default_pointer
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
item: POINTER
|
||||
-- C pointer item for cURL multi
|
||||
|
||||
feature {NONE} -- C externals
|
||||
|
||||
c_init (a_api: POINTER): POINTER
|
||||
-- Declared as curl_multi_init ().
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
return (FUNCTION_CAST(CURLM *, ()) $a_api)();
|
||||
]"
|
||||
end
|
||||
|
||||
c_cleanup (a_api: POINTER; a_multi_handle: POINTER): INTEGER
|
||||
-- Declared as curl_multi_cleanup ().
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
return (FUNCTION_CAST(CURLMcode, (CURLM *)) $a_api)
|
||||
((CURLM *)$a_multi_handle);
|
||||
]"
|
||||
end
|
||||
|
||||
c_add_handle (a_api: POINTER; a_multi_handle: POINTER; a_easy_handle: POINTER)
|
||||
-- Declared as curl_multi_add_handle ().
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
(FUNCTION_CAST(void, (CURLM *, CURL *)) $a_api)
|
||||
((CURLM *) $a_multi_handle,
|
||||
(CURL *) $a_easy_handle);
|
||||
]"
|
||||
end
|
||||
|
||||
c_remove_handle (a_api: POINTER; a_multi_handle: POINTER; a_easy_handle: POINTER)
|
||||
-- Declared as curl_multi_remove_handle ().
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
(FUNCTION_CAST(void, (CURLM *, CURL *)) $a_api)
|
||||
((CURLM *) $a_multi_handle,
|
||||
(CURL *) $a_easy_handle);
|
||||
]"
|
||||
end
|
||||
|
||||
c_perform (a_api: POINTER; a_multi_handle: POINTER; a_running_handles: TYPED_POINTER [INTEGER]): INTEGER
|
||||
-- Declared as curl_multi_perform.
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
return (FUNCTION_CAST(CURLMcode, (CURLM *, int *)) $a_api)
|
||||
((CURLM *) $a_multi_handle,
|
||||
(int *) $a_running_handles);
|
||||
]"
|
||||
end
|
||||
|
||||
c_info_read (a_api: POINTER; a_multi_handle: POINTER; a_msgs_in_queue: TYPED_POINTER [INTEGER]): POINTER
|
||||
-- Declared as curl_multi_info_read.
|
||||
require
|
||||
exists: a_api /= default_pointer
|
||||
external
|
||||
"C inline use <curl/curl.h>"
|
||||
alias
|
||||
"[
|
||||
return (FUNCTION_CAST(CURLMsg *, (CURLM *, int *)) $a_api)
|
||||
((CURLM *) $a_multi_handle,
|
||||
(int *) $a_msgs_in_queue);
|
||||
]"
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
api_loader: DYNAMIC_MODULE
|
||||
-- Module name.
|
||||
local
|
||||
l_utility: CURL_UTILITY
|
||||
once
|
||||
create l_utility
|
||||
Result := l_utility.api_loader
|
||||
end
|
||||
|
||||
|
||||
note
|
||||
copyright: "Copyright (c) 1984-2012, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
1117
contrib/ise_library/cURL/curl_opt_constants.e
Normal file
1117
contrib/ise_library/cURL/curl_opt_constants.e
Normal file
File diff suppressed because it is too large
Load Diff
50
contrib/ise_library/cURL/curl_string.e
Normal file
50
contrib/ise_library/cURL/curl_string.e
Normal file
@@ -0,0 +1,50 @@
|
||||
note
|
||||
description: "[
|
||||
String used by cURL wrapper library.
|
||||
Only added features from IDENTIFIED.
|
||||
]"
|
||||
status: "See notice at end of class."
|
||||
legal: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CURL_STRING
|
||||
|
||||
inherit
|
||||
STRING
|
||||
select
|
||||
is_equal,
|
||||
copy,
|
||||
out
|
||||
end
|
||||
|
||||
IDENTIFIED
|
||||
rename
|
||||
is_equal as identified_is_equal,
|
||||
copy as identified_copy,
|
||||
out as identified_out
|
||||
end
|
||||
|
||||
create
|
||||
make,
|
||||
make_empty,
|
||||
make_filled,
|
||||
make_from_string,
|
||||
make_from_c,
|
||||
make_from_cil
|
||||
|
||||
note
|
||||
library: "cURL: Library of reusable components for Eiffel."
|
||||
copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
356 Storke Road, Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
|
||||
end
|
||||
|
||||
51
contrib/ise_library/cURL/curl_utility.e
Normal file
51
contrib/ise_library/cURL/curl_utility.e
Normal file
@@ -0,0 +1,51 @@
|
||||
note
|
||||
description: "[
|
||||
Utilities for Eiffel cURL wrapper library.
|
||||
]"
|
||||
status: "See notice at end of class."
|
||||
legal: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CURL_UTILITY
|
||||
|
||||
feature -- Query
|
||||
|
||||
api_loader: DYNAMIC_MODULE
|
||||
-- API dynamic loader
|
||||
local
|
||||
l_platform: PLATFORM
|
||||
once
|
||||
create l_platform
|
||||
if l_platform.is_unix or l_platform.is_mac then
|
||||
create Result.make_with_version (module_name, "3")
|
||||
else
|
||||
check is_window: l_platform.is_windows end
|
||||
create Result.make (module_name)
|
||||
end
|
||||
ensure
|
||||
not_void: Result /= Void
|
||||
end
|
||||
|
||||
module_name: STRING
|
||||
-- Module name.
|
||||
once
|
||||
Result := "libcurl"
|
||||
ensure
|
||||
not_void: Result /= Void
|
||||
end
|
||||
|
||||
note
|
||||
library: "cURL: Library of reusable components for Eiffel."
|
||||
copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
356 Storke Road, Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
|
||||
end
|
||||
65
contrib/ise_library/cURL/implementation/mac/api_loader_imp.e
Normal file
65
contrib/ise_library/cURL/implementation/mac/api_loader_imp.e
Normal file
@@ -0,0 +1,65 @@
|
||||
note
|
||||
description: "[
|
||||
Interactive with native system APIs for dynamic loading.
|
||||
Cocoa verson.
|
||||
]"
|
||||
status: "See notice at end of class."
|
||||
legal: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
API_LOADER_IMP
|
||||
|
||||
feature -- Command
|
||||
|
||||
load_module (a_name: STRING): POINTER
|
||||
-- Load module with `a_name'.
|
||||
require
|
||||
exists: a_name /= Void
|
||||
do
|
||||
-- fixme: implement
|
||||
end
|
||||
|
||||
loal_api (a_module: POINTER; a_name: STRING): POINTER
|
||||
-- Load api which name is `a_name' in `a_module'
|
||||
require
|
||||
exists: a_module /= default_pointer
|
||||
exists: a_name /= Void
|
||||
do
|
||||
-- fixme: implement
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "Copyright (c) 1984-2007, Eiffel Software"
|
||||
license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
|
||||
licensing_options: "http://www.eiffel.com/licensing"
|
||||
copying: "[
|
||||
This file is part of Eiffel Software's Eiffel Development Environment.
|
||||
|
||||
Eiffel Software's Eiffel Development Environment is free
|
||||
software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published
|
||||
by the Free Software Foundation, version 2 of the License
|
||||
(available at the URL listed under "license" above).
|
||||
|
||||
Eiffel Software's Eiffel Development Environment is
|
||||
distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with Eiffel Software's Eiffel Development
|
||||
Environment; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
]"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
356 Storke Road, Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
|
||||
end
|
||||
1
contrib/ise_library/cURL/license.lic
Normal file
1
contrib/ise_library/cURL/license.lic
Normal file
@@ -0,0 +1 @@
|
||||
reference:forum2
|
||||
5
contrib/ise_library/cURL/readme.txt
Normal file
5
contrib/ise_library/cURL/readme.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
When your Eiffel executable running, Eiffel cURL library needs 3 DLLs, they are:
|
||||
|
||||
libcurl.dll, libeay32.dll and ssleay32.dll
|
||||
|
||||
Please make sure the 3 DLLs files can be found in your environment PATH or in same folder of your executable.
|
||||
1714
contrib/ise_library/cURL/spec/include/curl/curl.h
Normal file
1714
contrib/ise_library/cURL/spec/include/curl/curl.h
Normal file
File diff suppressed because it is too large
Load Diff
67
contrib/ise_library/cURL/spec/include/curl/curlver.h
Normal file
67
contrib/ise_library/cURL/spec/include/curl/curlver.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#ifndef __CURL_CURLVER_H
|
||||
#define __CURL_CURLVER_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* $Id$
|
||||
***************************************************************************/
|
||||
|
||||
/* This header file contains nothing but libcurl version info, generated by
|
||||
a script at release-time. This was made its own header file in 7.11.2 */
|
||||
|
||||
/* This is the version number of the libcurl package from which this header
|
||||
file origins: */
|
||||
#define LIBCURL_VERSION "7.17.0"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBCURL_VERSION_MAJOR 7
|
||||
#define LIBCURL_VERSION_MINOR 17
|
||||
#define LIBCURL_VERSION_PATCH 0
|
||||
|
||||
/* This is the numeric version of the libcurl version number, meant for easier
|
||||
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
|
||||
always follow this syntax:
|
||||
|
||||
0xXXYYZZ
|
||||
|
||||
Where XX, YY and ZZ are the main version, release and patch numbers in
|
||||
hexadecimal (using 8 bits each). All three numbers are always represented
|
||||
using two digits. 1.2 would appear as "0x010200" while version 9.11.7
|
||||
appears as "0x090b07".
|
||||
|
||||
This 6-digit (24 bits) hexadecimal number does not show pre-release number,
|
||||
and it is always a greater number in a more recent release. It makes
|
||||
comparisons with greater than and less than work.
|
||||
*/
|
||||
#define LIBCURL_VERSION_NUM 0x071100
|
||||
|
||||
/*
|
||||
* This is the date and time when the full source package was created. The
|
||||
* timestamp is not stored in CVS, as the timestamp is properly set in the
|
||||
* tarballs by the maketgz script.
|
||||
*
|
||||
* The format of the date should follow this template:
|
||||
*
|
||||
* "Mon Feb 12 11:35:33 UTC 2007"
|
||||
*/
|
||||
#define LIBCURL_TIMESTAMP "Thu Sep 13 20:22:24 UTC 2007"
|
||||
|
||||
#endif /* __CURL_CURLVER_H */
|
||||
81
contrib/ise_library/cURL/spec/include/curl/easy.h
Normal file
81
contrib/ise_library/cURL/spec/include/curl/easy.h
Normal file
@@ -0,0 +1,81 @@
|
||||
#ifndef __CURL_EASY_H
|
||||
#define __CURL_EASY_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* $Id$
|
||||
***************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
CURL_EXTERN CURL *curl_easy_init(void);
|
||||
CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
|
||||
CURL_EXTERN CURLcode curl_easy_perform(CURL *curl);
|
||||
CURL_EXTERN void curl_easy_cleanup(CURL *curl);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_getinfo()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Request internal information from the curl session with this function. The
|
||||
* third argument MUST be a pointer to a long, a pointer to a char * or a
|
||||
* pointer to a double (as the documentation describes elsewhere). The data
|
||||
* pointed to will be filled in accordingly and can be relied upon only if the
|
||||
* function returns CURLE_OK. This function is intended to get used *AFTER* a
|
||||
* performed transfer, all results from this function are undefined until the
|
||||
* transfer is completed.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
|
||||
|
||||
|
||||
/*
|
||||
* NAME curl_easy_duphandle()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Creates a new curl session handle with the same options set for the handle
|
||||
* passed in. Duplicating a handle could only be a matter of cloning data and
|
||||
* options, internal state info and things like persistant connections cannot
|
||||
* be transfered. It is useful in multithreaded applications when you can run
|
||||
* curl_easy_duphandle() for each new thread to avoid a series of identical
|
||||
* curl_easy_setopt() invokes in every thread.
|
||||
*/
|
||||
CURL_EXTERN CURL* curl_easy_duphandle(CURL *curl);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_reset()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Re-initializes a CURL handle to the default values. This puts back the
|
||||
* handle to the same state as it was in when it was just created.
|
||||
*
|
||||
* It does keep: live connections, the Session ID cache, the DNS cache and the
|
||||
* cookies.
|
||||
*/
|
||||
CURL_EXTERN void curl_easy_reset(CURL *curl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
80
contrib/ise_library/cURL/spec/include/curl/mprintf.h
Normal file
80
contrib/ise_library/cURL/spec/include/curl/mprintf.h
Normal file
@@ -0,0 +1,80 @@
|
||||
#ifndef __CURL_MPRINTF_H
|
||||
#define __CURL_MPRINTF_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* $Id$
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h> /* needed for FILE */
|
||||
|
||||
#include "curl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
CURL_EXTERN int curl_mprintf(const char *format, ...);
|
||||
CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...);
|
||||
CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...);
|
||||
CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength, const char *format, ...);
|
||||
CURL_EXTERN int curl_mvprintf(const char *format, va_list args);
|
||||
CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args);
|
||||
CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args);
|
||||
CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength, const char *format, va_list args);
|
||||
CURL_EXTERN char *curl_maprintf(const char *format, ...);
|
||||
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
|
||||
|
||||
#ifdef _MPRINTF_REPLACE
|
||||
# undef printf
|
||||
# undef fprintf
|
||||
# undef sprintf
|
||||
# undef vsprintf
|
||||
# undef snprintf
|
||||
# undef vprintf
|
||||
# undef vfprintf
|
||||
# undef vsnprintf
|
||||
# undef aprintf
|
||||
# undef vaprintf
|
||||
# define printf curl_mprintf
|
||||
# define fprintf curl_mfprintf
|
||||
#ifdef CURLDEBUG
|
||||
/* When built with CURLDEBUG we define away the sprintf() functions since we
|
||||
don't want internal code to be using them */
|
||||
# define sprintf sprintf_was_used
|
||||
# define vsprintf vsprintf_was_used
|
||||
#else
|
||||
# define sprintf curl_msprintf
|
||||
# define vsprintf curl_mvsprintf
|
||||
#endif
|
||||
# define snprintf curl_msnprintf
|
||||
# define vprintf curl_mvprintf
|
||||
# define vfprintf curl_mvfprintf
|
||||
# define vsnprintf curl_mvsnprintf
|
||||
# define aprintf curl_maprintf
|
||||
# define vaprintf curl_mvaprintf
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CURL_MPRINTF_H */
|
||||
346
contrib/ise_library/cURL/spec/include/curl/multi.h
Normal file
346
contrib/ise_library/cURL/spec/include/curl/multi.h
Normal file
@@ -0,0 +1,346 @@
|
||||
#ifndef __CURL_MULTI_H
|
||||
#define __CURL_MULTI_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* $Id$
|
||||
***************************************************************************/
|
||||
/*
|
||||
This is an "external" header file. Don't give away any internals here!
|
||||
|
||||
GOALS
|
||||
|
||||
o Enable a "pull" interface. The application that uses libcurl decides where
|
||||
and when to ask libcurl to get/send data.
|
||||
|
||||
o Enable multiple simultaneous transfers in the same thread without making it
|
||||
complicated for the application.
|
||||
|
||||
o Enable the application to select() on its own file descriptors and curl's
|
||||
file descriptors simultaneous easily.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* This header file should not really need to include "curl.h" since curl.h
|
||||
* itself includes this file and we expect user applications to do #include
|
||||
* <curl/curl.h> without the need for especially including multi.h.
|
||||
*
|
||||
* For some reason we added this include here at one point, and rather than to
|
||||
* break existing (wrongly written) libcurl applications, we leave it as-is
|
||||
* but with this warning attached.
|
||||
*/
|
||||
#include "curl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void CURLM;
|
||||
|
||||
typedef enum {
|
||||
CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
|
||||
curl_multi_socket*() soon */
|
||||
CURLM_OK,
|
||||
CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */
|
||||
CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
|
||||
CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */
|
||||
CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
|
||||
CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
|
||||
CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
|
||||
CURLM_LAST
|
||||
} CURLMcode;
|
||||
|
||||
/* just to make code nicer when using curl_multi_socket() you can now check
|
||||
for CURLM_CALL_MULTI_SOCKET too in the same style it works for
|
||||
curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
|
||||
#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM
|
||||
|
||||
typedef enum {
|
||||
CURLMSG_NONE, /* first, not used */
|
||||
CURLMSG_DONE, /* This easy handle has completed. 'result' contains
|
||||
the CURLcode of the transfer */
|
||||
CURLMSG_LAST /* last, not used */
|
||||
} CURLMSG;
|
||||
|
||||
struct CURLMsg {
|
||||
CURLMSG msg; /* what this message means */
|
||||
CURL *easy_handle; /* the handle it concerns */
|
||||
union {
|
||||
void *whatever; /* message-specific data */
|
||||
CURLcode result; /* return code for transfer */
|
||||
} data;
|
||||
};
|
||||
typedef struct CURLMsg CURLMsg;
|
||||
|
||||
/*
|
||||
* Name: curl_multi_init()
|
||||
*
|
||||
* Desc: inititalize multi-style curl usage
|
||||
*
|
||||
* Returns: a new CURLM handle to use in all 'curl_multi' functions.
|
||||
*/
|
||||
CURL_EXTERN CURLM *curl_multi_init(void);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_add_handle()
|
||||
*
|
||||
* Desc: add a standard curl handle to the multi stack
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_remove_handle()
|
||||
*
|
||||
* Desc: removes a curl handle from the multi stack again
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_fdset()
|
||||
*
|
||||
* Desc: Ask curl for its fd_set sets. The app can use these to select() or
|
||||
* poll() on. We want curl_multi_perform() called as soon as one of
|
||||
* them are ready.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
|
||||
fd_set *read_fd_set,
|
||||
fd_set *write_fd_set,
|
||||
fd_set *exc_fd_set,
|
||||
int *max_fd);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_perform()
|
||||
*
|
||||
* Desc: When the app thinks there's data available for curl it calls this
|
||||
* function to read/write whatever there is right now. This returns
|
||||
* as soon as the reads and writes are done. This function does not
|
||||
* require that there actually is data available for reading or that
|
||||
* data can be written, it can be called just in case. It returns
|
||||
* the number of handles that still transfer data in the second
|
||||
* argument's integer-pointer.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code. *NOTE* that this only
|
||||
* returns errors etc regarding the whole multi stack. There might
|
||||
* still have occurred problems on invidual transfers even when this
|
||||
* returns OK.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_cleanup()
|
||||
*
|
||||
* Desc: Cleans up and removes a whole multi stack. It does not free or
|
||||
* touch any individual easy handles in any way. We need to define
|
||||
* in what state those handles will be if this function is called
|
||||
* in the middle of a transfer.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_info_read()
|
||||
*
|
||||
* Desc: Ask the multi handle if there's any messages/informationals from
|
||||
* the individual transfers. Messages include informationals such as
|
||||
* error code from the transfer or just the fact that a transfer is
|
||||
* completed. More details on these should be written down as well.
|
||||
*
|
||||
* Repeated calls to this function will return a new struct each
|
||||
* time, until a special "end of msgs" struct is returned as a signal
|
||||
* that there is no more to get at this point.
|
||||
*
|
||||
* The data the returned pointer points to will not survive calling
|
||||
* curl_multi_cleanup().
|
||||
*
|
||||
* The 'CURLMsg' struct is meant to be very simple and only contain
|
||||
* very basic informations. If more involved information is wanted,
|
||||
* we will provide the particular "transfer handle" in that struct
|
||||
* and that should/could/would be used in subsequent
|
||||
* curl_easy_getinfo() calls (or similar). The point being that we
|
||||
* must never expose complex structs to applications, as then we'll
|
||||
* undoubtably get backwards compatibility problems in the future.
|
||||
*
|
||||
* Returns: A pointer to a filled-in struct, or NULL if it failed or ran out
|
||||
* of structs. It also writes the number of messages left in the
|
||||
* queue (after this read) in the integer the second argument points
|
||||
* to.
|
||||
*/
|
||||
CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,
|
||||
int *msgs_in_queue);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_strerror()
|
||||
*
|
||||
* Desc: The curl_multi_strerror function may be used to turn a CURLMcode
|
||||
* value into the equivalent human readable error string. This is
|
||||
* useful for printing meaningful error messages.
|
||||
*
|
||||
* Returns: A pointer to a zero-terminated error message.
|
||||
*/
|
||||
CURL_EXTERN const char *curl_multi_strerror(CURLMcode);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_socket() and
|
||||
* curl_multi_socket_all()
|
||||
*
|
||||
* Desc: An alternative version of curl_multi_perform() that allows the
|
||||
* application to pass in one of the file descriptors that have been
|
||||
* detected to have "action" on them and let libcurl perform.
|
||||
* See man page for details.
|
||||
*/
|
||||
#define CURL_POLL_NONE 0
|
||||
#define CURL_POLL_IN 1
|
||||
#define CURL_POLL_OUT 2
|
||||
#define CURL_POLL_INOUT 3
|
||||
#define CURL_POLL_REMOVE 4
|
||||
|
||||
#define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD
|
||||
|
||||
#define CURL_CSELECT_IN 0x01
|
||||
#define CURL_CSELECT_OUT 0x02
|
||||
#define CURL_CSELECT_ERR 0x04
|
||||
|
||||
typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */
|
||||
curl_socket_t s, /* socket */
|
||||
int what, /* see above */
|
||||
void *userp, /* private callback
|
||||
pointer */
|
||||
void *socketp); /* private socket
|
||||
pointer */
|
||||
/*
|
||||
* Name: curl_multi_timer_callback
|
||||
*
|
||||
* Desc: Called by libcurl whenever the library detects a change in the
|
||||
* maximum number of milliseconds the app is allowed to wait before
|
||||
* curl_multi_socket() or curl_multi_perform() must be called
|
||||
* (to allow libcurl's timed events to take place).
|
||||
*
|
||||
* Returns: The callback should return zero.
|
||||
*/
|
||||
typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */
|
||||
long timeout_ms, /* see above */
|
||||
void *userp); /* private callback
|
||||
pointer */
|
||||
|
||||
CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s,
|
||||
int *running_handles);
|
||||
|
||||
CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle,
|
||||
curl_socket_t s,
|
||||
int ev_bitmask,
|
||||
int *running_handles);
|
||||
|
||||
CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
|
||||
#ifndef CURL_ALLOW_OLD_MULTI_SOCKET
|
||||
/* This macro below was added in 7.16.3 to push users who recompile to use
|
||||
the new curl_multi_socket_action() instead of the old curl_multi_socket()
|
||||
*/
|
||||
#define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Name: curl_multi_timeout()
|
||||
*
|
||||
* Desc: Returns the maximum number of milliseconds the app is allowed to
|
||||
* wait before curl_multi_socket() or curl_multi_perform() must be
|
||||
* called (to allow libcurl's timed events to take place).
|
||||
*
|
||||
* Returns: CURLM error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
|
||||
long *milliseconds);
|
||||
|
||||
#undef CINIT /* re-using the same name as in curl.h */
|
||||
|
||||
#ifdef CURL_ISOCPP
|
||||
#define CINIT(name,type,number) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + number
|
||||
#else
|
||||
/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
|
||||
#define LONG CURLOPTTYPE_LONG
|
||||
#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT
|
||||
#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
|
||||
#define OFF_T CURLOPTTYPE_OFF_T
|
||||
#define CINIT(name,type,number) CURLMOPT_/**/name = type + number
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
/* This is the socket callback function pointer */
|
||||
CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1),
|
||||
|
||||
/* This is the argument passed to the socket callback */
|
||||
CINIT(SOCKETDATA, OBJECTPOINT, 2),
|
||||
|
||||
/* set to 1 to enable pipelining for this multi handle */
|
||||
CINIT(PIPELINING, LONG, 3),
|
||||
|
||||
/* This is the timer callback function pointer */
|
||||
CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4),
|
||||
|
||||
/* This is the argument passed to the timer callback */
|
||||
CINIT(TIMERDATA, OBJECTPOINT, 5),
|
||||
|
||||
/* maximum number of entries in the connection cache */
|
||||
CINIT(MAXCONNECTS, LONG, 6),
|
||||
|
||||
CURLMOPT_LASTENTRY /* the last unused */
|
||||
} CURLMoption;
|
||||
|
||||
|
||||
/*
|
||||
* Name: curl_multi_setopt()
|
||||
*
|
||||
* Desc: Sets options for the multi handle.
|
||||
*
|
||||
* Returns: CURLM error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
|
||||
CURLMoption option, ...);
|
||||
|
||||
|
||||
/*
|
||||
* Name: curl_multi_assign()
|
||||
*
|
||||
* Desc: This function sets an association in the multi handle between the
|
||||
* given socket and a private pointer of the application. This is
|
||||
* (only) useful for curl_multi_socket uses.
|
||||
*
|
||||
* Returns: CURLM error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
|
||||
curl_socket_t sockfd, void *sockp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
34
contrib/ise_library/cURL/spec/include/curl/stdcheaders.h
Normal file
34
contrib/ise_library/cURL/spec/include/curl/stdcheaders.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef __STDC_HEADERS_H
|
||||
#define __STDC_HEADERS_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* $Id$
|
||||
***************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
size_t fread (void *, size_t, size_t, FILE *);
|
||||
size_t fwrite (const void *, size_t, size_t, FILE *);
|
||||
|
||||
int strcasecmp(const char *, const char *);
|
||||
int strncasecmp(const char *, const char *, size_t);
|
||||
|
||||
#endif
|
||||
1
contrib/ise_library/cURL/spec/include/curl/types.h
Normal file
1
contrib/ise_library/cURL/spec/include/curl/types.h
Normal file
@@ -0,0 +1 @@
|
||||
/* not used */
|
||||
47
contrib/ise_library/cURL/spec/include/eiffel_curl.h
Normal file
47
contrib/ise_library/cURL/spec/include/eiffel_curl.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
indexing
|
||||
description: "Functions used by the class CURL_FUNCTION."
|
||||
copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
356 Storke Road, Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
*/
|
||||
|
||||
#ifndef _eiffel_curl_h_
|
||||
#define _eiffel_curl_h_
|
||||
|
||||
#include "eif_eiffel.h"
|
||||
|
||||
/* unix-specific */
|
||||
#ifndef EIF_WINDOWS
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void c_set_object(EIF_REFERENCE a_address);
|
||||
extern void c_release_object(void);
|
||||
extern void c_set_progress_function_address( EIF_POINTER a_address);
|
||||
extern void c_set_read_function_address( EIF_POINTER a_address);
|
||||
extern void c_set_write_function_address( EIF_POINTER a_address);
|
||||
extern void c_set_debug_function_address (EIF_POINTER a_address);
|
||||
extern size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data);
|
||||
extern size_t curl_read_function (void *ptr, size_t size, size_t nmemb, void *data);
|
||||
extern size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dlnow, double a_ultotal, double a_ulnow);
|
||||
extern size_t curl_debug_function (CURL * a_curl_handle, curl_infotype a_curl_infotype, unsigned char * a_char_pointer, size_t a_size, void * a_object_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
4
contrib/ise_library/math/eapml/README.txt
Normal file
4
contrib/ise_library/math/eapml/README.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
Eiffel Arbitrary Precision Mathematics Library
|
||||
|
||||
Contribution from Colin LeMahieu
|
||||
see original source: https://github.com/clemahieu/eapml
|
||||
67
contrib/ise_library/math/eapml/eapml-safe.ecf
Normal file
67
contrib/ise_library/math/eapml/eapml-safe.ecf
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-6-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-6-0 http://www.eiffel.com/developers/xml/configuration-1-6-0.xsd" name="eapml" uuid="3E9258E1-383A-40BF-864B-231FC8F25ADF" library_target="eapml">
|
||||
<description>Eiffel Arbitrary Precision Mathematics Library
|
||||
|
||||
Note: you should set 'eapml_scan_type' to 'gcc' or 'vc'
|
||||
and 'eapml_limb_type' to 'natural_32' (or 'natural_64')
|
||||
|
||||
If not, default values will be used depending on the platform
|
||||
</description>
|
||||
<target name="eapml">
|
||||
<file_rule>
|
||||
<exclude>/.svn$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.hg$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
</file_rule>
|
||||
<description>Eiffel Arbitrary Precision Mathematics</description>
|
||||
<root all_classes="true"/>
|
||||
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="standard">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<cluster name="bit_scan_gcc" location=".\src\bit_scan_gcc\" recursive="true">
|
||||
<condition>
|
||||
<custom name="eapml_scan_type" value="gcc"/>
|
||||
</condition>
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
<custom name="eapml_scan_type" excluded_value="vc"/>
|
||||
</condition>
|
||||
</cluster>
|
||||
<cluster name="bit_scan_vc" location=".\src\bit_scan_vc\" recursive="true">
|
||||
<condition>
|
||||
<custom name="eapml_scan_type" value="vc"/>
|
||||
</condition>
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
<custom name="eapml_scan_type" excluded_value="gcc"/>
|
||||
</condition>
|
||||
</cluster>
|
||||
<cluster name="eapml" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/bit_scan_vc$</exclude>
|
||||
<exclude>/bit_scan_gcc$</exclude>
|
||||
<exclude>/limb_natural_32$</exclude>
|
||||
<exclude>/limb_natural_64$</exclude>
|
||||
</file_rule>
|
||||
<file_rule>
|
||||
<exclude>^/mp/number/support$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
<cluster name="limb_natural_32" location=".\src\limb_natural_32\" recursive="true">
|
||||
<!--
|
||||
<condition>
|
||||
<custom name="eapml_limb_type" value="natural_32"/>
|
||||
</condition>
|
||||
-->
|
||||
</cluster>
|
||||
<!--
|
||||
<cluster name="limb_natural_64" location=".\src\limb_natural_64\" recursive="true">
|
||||
<condition>
|
||||
<custom name="eapml_limb_type" value="natural_64"/>
|
||||
</condition>
|
||||
</cluster>
|
||||
-->
|
||||
</target>
|
||||
</system>
|
||||
66
contrib/ise_library/math/eapml/eapml.ecf
Normal file
66
contrib/ise_library/math/eapml/eapml.ecf
Normal file
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-9-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-9-0 http://www.eiffel.com/developers/xml/configuration-1-9-0.xsd" name="eapml" uuid="3E9258E1-383A-40BF-864B-231FC8F25ADF" library_target="eapml">
|
||||
<description>Eiffel Arbitrary Precision Mathematics Library
|
||||
|
||||
Note: you should set 'eapml_scan_type' to 'gcc' or 'vc'
|
||||
and 'eapml_limb_type' to 'natural_32' (or 'natural_64')
|
||||
|
||||
If not, default values will be used depending on the platform
|
||||
</description>
|
||||
<target name="eapml">
|
||||
<root all_classes="true"/>
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/\.svn$</exclude>
|
||||
<exclude>/\.hg$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true" is_attached_by_default="false" void_safety="none" syntax="standard">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<cluster name="bit_scan_gcc" location=".\src\bit_scan_gcc\" recursive="true">
|
||||
<condition>
|
||||
<custom name="eapml_scan_type" value="gcc"/>
|
||||
</condition>
|
||||
<condition>
|
||||
<platform excluded_value="windows"/>
|
||||
<custom name="eapml_scan_type" excluded_value="vc"/>
|
||||
</condition>
|
||||
</cluster>
|
||||
<cluster name="bit_scan_vc" location=".\src\bit_scan_vc\" recursive="true">
|
||||
<condition>
|
||||
<custom name="eapml_scan_type" value="vc"/>
|
||||
</condition>
|
||||
<condition>
|
||||
<platform value="windows"/>
|
||||
<custom name="eapml_scan_type" excluded_value="gcc"/>
|
||||
</condition>
|
||||
</cluster>
|
||||
<cluster name="eapml" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/bit_scan_vc$</exclude>
|
||||
<exclude>/bit_scan_gcc$</exclude>
|
||||
<exclude>/limb_natural_32$</exclude>
|
||||
<exclude>/limb_natural_64$</exclude>
|
||||
</file_rule>
|
||||
<file_rule>
|
||||
<exclude>^/mp/number/support$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
<cluster name="limb_natural_32" location=".\src\limb_natural_32\" recursive="true">
|
||||
<!--
|
||||
<condition>
|
||||
<custom name="eapml_limb_type" value="natural_32"/>
|
||||
</condition>
|
||||
-->
|
||||
</cluster>
|
||||
<!--
|
||||
<cluster name="limb_natural_64" location=".\src\limb_natural_64\" recursive="true">
|
||||
<condition>
|
||||
<custom name="eapml_limb_type" value="natural_64"/>
|
||||
</condition>
|
||||
</cluster>
|
||||
-->
|
||||
</target>
|
||||
</system>
|
||||
@@ -0,0 +1,59 @@
|
||||
note
|
||||
description: "Summary description for {LIMB_BIT_SCANNING}."
|
||||
author: ""
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
|
||||
deferred class
|
||||
LIMB_BIT_SCANNING
|
||||
|
||||
inherit
|
||||
LIMB_DEFINITION
|
||||
|
||||
feature
|
||||
|
||||
leading_zeros (limb_a: NATURAL_32): INTEGER
|
||||
do
|
||||
if limb_a = 0 then
|
||||
Result := limb_bits
|
||||
else
|
||||
Result := count_leading_zeros (limb_a)
|
||||
end
|
||||
end
|
||||
|
||||
most_significant_one (limb_a: NATURAL_32): INTEGER
|
||||
-- 31 high, 0 low
|
||||
require
|
||||
limb_a /= 0
|
||||
do
|
||||
Result := limb_high_bit - leading_zeros (limb_a)
|
||||
end
|
||||
|
||||
trailing_zeros (limb_a: NATURAL_32): INTEGER
|
||||
-- 31 high, 0 low
|
||||
require
|
||||
limb_a /= 0
|
||||
do
|
||||
Result := count_trailing_zeros (limb_a)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
count_trailing_zeros (limb_a: NATURAL_32): INTEGER
|
||||
external
|
||||
"C inline"
|
||||
alias
|
||||
"[
|
||||
return __builtin_ctz ($limb_a);
|
||||
]"
|
||||
end
|
||||
|
||||
count_leading_zeros (limb_a: NATURAL_32): INTEGER
|
||||
external
|
||||
"C inline"
|
||||
alias
|
||||
"[
|
||||
return __builtin_clz ($limb_a);
|
||||
]"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,59 @@
|
||||
note
|
||||
description: "Summary description for {LIMB_BIT_SCANNING}."
|
||||
author: ""
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
|
||||
deferred class
|
||||
LIMB_BIT_SCANNING
|
||||
|
||||
inherit
|
||||
LIMB_DEFINITION
|
||||
|
||||
feature
|
||||
|
||||
leading_zeros (limb_a: NATURAL_32): INTEGER
|
||||
do
|
||||
if limb_a = 0 then
|
||||
Result := limb_bits
|
||||
else
|
||||
Result := limb_high_bit - most_significant_one (limb_a)
|
||||
end
|
||||
end
|
||||
|
||||
most_significant_one (limb_a: NATURAL_32): INTEGER
|
||||
-- 31 high, 0 low
|
||||
require
|
||||
limb_a /= 0
|
||||
do
|
||||
bit_scan_reverse ($Result, limb_a)
|
||||
end
|
||||
|
||||
trailing_zeros (limb_a: NATURAL_32): INTEGER
|
||||
-- 31 high, 0 low
|
||||
require
|
||||
limb_a /= 0
|
||||
do
|
||||
bit_scan_forward ($Result, limb_a)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
bit_scan_reverse (target: POINTER; limb_a: NATURAL_32)
|
||||
external
|
||||
"C inline use %"intrin.h%""
|
||||
alias
|
||||
"[
|
||||
_BitScanReverse ($target, $limb_a);
|
||||
]"
|
||||
end
|
||||
|
||||
bit_scan_forward (target: POINTER; limb_a: NATURAL_32)
|
||||
external
|
||||
"C inline use %"intrin.h%""
|
||||
alias
|
||||
"[
|
||||
_BitScanForward ($target, $limb_a);
|
||||
]"
|
||||
end
|
||||
end
|
||||
19
contrib/ise_library/math/eapml/src/divide_by_zero.e
Normal file
19
contrib/ise_library/math/eapml/src/divide_by_zero.e
Normal file
@@ -0,0 +1,19 @@
|
||||
note
|
||||
description: "An exception when dividing by zero"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "A right is not what someone gives you; it's what no one can take from you. - Ramsey Clark, U.S. Attorney General, New York Times, 10/02/77"
|
||||
|
||||
class
|
||||
DIVIDE_BY_ZERO
|
||||
|
||||
inherit
|
||||
DEVELOPER_EXCEPTION
|
||||
redefine
|
||||
internal_meaning
|
||||
end
|
||||
|
||||
feature
|
||||
internal_meaning: STRING = "Divide by zero"
|
||||
end
|
||||
@@ -0,0 +1,224 @@
|
||||
note
|
||||
description: "Convert between character codes and numbers ignoring case"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "There can be no freedom without freedom to fail. - Eric Hoffer (1902-1983), The Ordeal of Change, 1964"
|
||||
|
||||
class
|
||||
CASE_INSENSITIVE_STRATEGY
|
||||
|
||||
inherit
|
||||
CHARACTER_STRATEGY
|
||||
|
||||
feature
|
||||
|
||||
text_to_number (in: NATURAL_8): NATURAL_8
|
||||
do
|
||||
inspect
|
||||
in
|
||||
when 0x30 then
|
||||
Result := 0x0
|
||||
when 0x31 then
|
||||
Result := 1
|
||||
when 0x32 then
|
||||
Result := 2
|
||||
when 0x33 then
|
||||
Result := 3
|
||||
when 0x34 then
|
||||
Result := 4
|
||||
when 0x35 then
|
||||
Result := 5
|
||||
when 0x36 then
|
||||
Result := 6
|
||||
when 0x37 then
|
||||
Result := 7
|
||||
when 0x38 then
|
||||
Result := 8
|
||||
when 0x39 then
|
||||
Result := 9
|
||||
when 0x41 then
|
||||
Result := 10
|
||||
when 0x42 then
|
||||
Result := 11
|
||||
when 0x43 then
|
||||
Result := 12
|
||||
when 0x44 then
|
||||
Result := 13
|
||||
when 0x45 then
|
||||
Result := 14
|
||||
when 0x46 then
|
||||
Result := 15
|
||||
when 0x47 then
|
||||
Result := 16
|
||||
when 0x48 then
|
||||
Result := 17
|
||||
when 0x49 then
|
||||
Result := 18
|
||||
when 0x4a then
|
||||
Result := 19
|
||||
when 0x4b then
|
||||
Result := 20
|
||||
when 0x4c then
|
||||
Result := 21
|
||||
when 0x4d then
|
||||
Result := 22
|
||||
when 0x4e then
|
||||
Result := 23
|
||||
when 0x4f then
|
||||
Result := 24
|
||||
when 0x50 then
|
||||
Result := 25
|
||||
when 0x51 then
|
||||
Result := 26
|
||||
when 0x52 then
|
||||
Result := 27
|
||||
when 0x53 then
|
||||
Result := 28
|
||||
when 0x54 then
|
||||
Result := 29
|
||||
when 0x55 then
|
||||
Result := 30
|
||||
when 0x56 then
|
||||
Result := 31
|
||||
when 0x57 then
|
||||
Result := 32
|
||||
when 0x58 then
|
||||
Result := 33
|
||||
when 0x59 then
|
||||
Result := 34
|
||||
when 0x5a then
|
||||
Result := 35
|
||||
when 0x61 then
|
||||
Result := 10
|
||||
when 0x62 then
|
||||
Result := 11
|
||||
when 0x63 then
|
||||
Result := 12
|
||||
when 0x64 then
|
||||
Result := 13
|
||||
when 0x65 then
|
||||
Result := 14
|
||||
when 0x66 then
|
||||
Result := 15
|
||||
when 0x67 then
|
||||
Result := 16
|
||||
when 0x68 then
|
||||
Result := 17
|
||||
when 0x69 then
|
||||
Result := 18
|
||||
when 0x6a then
|
||||
Result := 19
|
||||
when 0x6b then
|
||||
Result := 20
|
||||
when 0x6c then
|
||||
Result := 21
|
||||
when 0x6d then
|
||||
Result := 22
|
||||
when 0x6e then
|
||||
Result := 23
|
||||
when 0x6f then
|
||||
Result := 24
|
||||
when 0x70 then
|
||||
Result := 25
|
||||
when 0x71 then
|
||||
Result := 26
|
||||
when 0x72 then
|
||||
Result := 27
|
||||
when 0x73 then
|
||||
Result := 28
|
||||
when 0x74 then
|
||||
Result := 29
|
||||
when 0x75 then
|
||||
Result := 30
|
||||
when 0x76 then
|
||||
Result := 31
|
||||
when 0x77 then
|
||||
Result := 32
|
||||
when 0x78 then
|
||||
Result := 33
|
||||
when 0x79 then
|
||||
Result := 34
|
||||
when 0x7a then
|
||||
Result := 35
|
||||
end
|
||||
end
|
||||
|
||||
number_to_text (in: NATURAL_8): NATURAL_8
|
||||
do
|
||||
inspect in
|
||||
when 0 then
|
||||
Result := 0x30
|
||||
when 1 then
|
||||
Result := 0x31
|
||||
when 2 then
|
||||
Result := 0x32
|
||||
when 3 then
|
||||
Result := 0x33
|
||||
when 4 then
|
||||
Result := 0x34
|
||||
when 5 then
|
||||
Result := 0x35
|
||||
when 6 then
|
||||
Result := 0x36
|
||||
when 7 then
|
||||
Result := 0x37
|
||||
when 8 then
|
||||
Result := 0x38
|
||||
when 9 then
|
||||
Result := 0x39
|
||||
when 10 then
|
||||
Result := 0x61
|
||||
when 11 then
|
||||
Result := 0x62
|
||||
when 12 then
|
||||
Result := 0x63
|
||||
when 13 then
|
||||
Result := 0x64
|
||||
when 14 then
|
||||
Result := 0x65
|
||||
when 15 then
|
||||
Result := 0x66
|
||||
when 16 then
|
||||
Result := 0x67
|
||||
when 17 then
|
||||
Result := 0x68
|
||||
when 18 then
|
||||
Result := 0x69
|
||||
when 19 then
|
||||
Result := 0x6a
|
||||
when 20 then
|
||||
Result := 0x6b
|
||||
when 21 then
|
||||
Result := 0x6c
|
||||
when 22 then
|
||||
Result := 0x6d
|
||||
when 23 then
|
||||
Result := 0x6e
|
||||
when 24 then
|
||||
Result := 0x6f
|
||||
when 25 then
|
||||
Result := 0x70
|
||||
when 26 then
|
||||
Result := 0x71
|
||||
when 27 then
|
||||
Result := 0x72
|
||||
when 28 then
|
||||
Result := 0x73
|
||||
when 29 then
|
||||
Result := 0x74
|
||||
when 30 then
|
||||
Result := 0x75
|
||||
when 31 then
|
||||
Result := 0x76
|
||||
when 32 then
|
||||
Result := 0x77
|
||||
when 33 then
|
||||
Result := 0x78
|
||||
when 34 then
|
||||
Result := 0x79
|
||||
when 35 then
|
||||
Result := 0x7a
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,276 @@
|
||||
note
|
||||
description: "Convert between character codes and numbers case-sensitive"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "I believe the State exists for the development of individual lives, not individuals for the development of the state. - Julian Huxley (1878-1975)"
|
||||
|
||||
class
|
||||
CASE_SENSITIVE_STRATEGY
|
||||
|
||||
inherit
|
||||
CHARACTER_STRATEGY
|
||||
|
||||
feature
|
||||
|
||||
text_to_number (in: NATURAL_8): NATURAL_8
|
||||
do
|
||||
inspect
|
||||
in
|
||||
when 0x30 then
|
||||
Result := 0x0
|
||||
when 0x31 then
|
||||
Result := 1
|
||||
when 0x32 then
|
||||
Result := 2
|
||||
when 0x33 then
|
||||
Result := 3
|
||||
when 0x34 then
|
||||
Result := 4
|
||||
when 0x35 then
|
||||
Result := 5
|
||||
when 0x36 then
|
||||
Result := 6
|
||||
when 0x37 then
|
||||
Result := 7
|
||||
when 0x38 then
|
||||
Result := 8
|
||||
when 0x39 then
|
||||
Result := 9
|
||||
when 0x41 then
|
||||
Result := 10
|
||||
when 0x42 then
|
||||
Result := 11
|
||||
when 0x43 then
|
||||
Result := 12
|
||||
when 0x44 then
|
||||
Result := 13
|
||||
when 0x45 then
|
||||
Result := 14
|
||||
when 0x46 then
|
||||
Result := 15
|
||||
when 0x47 then
|
||||
Result := 16
|
||||
when 0x48 then
|
||||
Result := 17
|
||||
when 0x49 then
|
||||
Result := 18
|
||||
when 0x4a then
|
||||
Result := 19
|
||||
when 0x4b then
|
||||
Result := 20
|
||||
when 0x4c then
|
||||
Result := 21
|
||||
when 0x4d then
|
||||
Result := 22
|
||||
when 0x4e then
|
||||
Result := 23
|
||||
when 0x4f then
|
||||
Result := 24
|
||||
when 0x50 then
|
||||
Result := 25
|
||||
when 0x51 then
|
||||
Result := 26
|
||||
when 0x52 then
|
||||
Result := 27
|
||||
when 0x53 then
|
||||
Result := 28
|
||||
when 0x54 then
|
||||
Result := 29
|
||||
when 0x55 then
|
||||
Result := 30
|
||||
when 0x56 then
|
||||
Result := 31
|
||||
when 0x57 then
|
||||
Result := 32
|
||||
when 0x58 then
|
||||
Result := 33
|
||||
when 0x59 then
|
||||
Result := 34
|
||||
when 0x5a then
|
||||
Result := 35
|
||||
when 0x61 then
|
||||
Result := 36
|
||||
when 0x62 then
|
||||
Result := 37
|
||||
when 0x63 then
|
||||
Result := 38
|
||||
when 0x64 then
|
||||
Result := 39
|
||||
when 0x65 then
|
||||
Result := 40
|
||||
when 0x66 then
|
||||
Result := 41
|
||||
when 0x67 then
|
||||
Result := 42
|
||||
when 0x68 then
|
||||
Result := 43
|
||||
when 0x69 then
|
||||
Result := 44
|
||||
when 0x6a then
|
||||
Result := 45
|
||||
when 0x6b then
|
||||
Result := 46
|
||||
when 0x6c then
|
||||
Result := 47
|
||||
when 0x6d then
|
||||
Result := 48
|
||||
when 0x6e then
|
||||
Result := 49
|
||||
when 0x6f then
|
||||
Result := 50
|
||||
when 0x70 then
|
||||
Result := 51
|
||||
when 0x71 then
|
||||
Result := 52
|
||||
when 0x72 then
|
||||
Result := 53
|
||||
when 0x73 then
|
||||
Result := 54
|
||||
when 0x74 then
|
||||
Result := 55
|
||||
when 0x75 then
|
||||
Result := 56
|
||||
when 0x76 then
|
||||
Result := 57
|
||||
when 0x77 then
|
||||
Result := 58
|
||||
when 0x78 then
|
||||
Result := 59
|
||||
when 0x79 then
|
||||
Result := 60
|
||||
when 0x7a then
|
||||
Result := 61
|
||||
end
|
||||
end
|
||||
|
||||
number_to_text (in: NATURAL_8): NATURAL_8
|
||||
do
|
||||
inspect in
|
||||
when 0 then
|
||||
Result := 0x30
|
||||
when 1 then
|
||||
Result := 0x31
|
||||
when 2 then
|
||||
Result := 0x32
|
||||
when 3 then
|
||||
Result := 0x33
|
||||
when 4 then
|
||||
Result := 0x34
|
||||
when 5 then
|
||||
Result := 0x35
|
||||
when 6 then
|
||||
Result := 0x36
|
||||
when 7 then
|
||||
Result := 0x37
|
||||
when 8 then
|
||||
Result := 0x38
|
||||
when 9 then
|
||||
Result := 0x39
|
||||
when 10 then
|
||||
Result := 0x41
|
||||
when 11 then
|
||||
Result := 0x42
|
||||
when 12 then
|
||||
Result := 0x43
|
||||
when 13 then
|
||||
Result := 0x44
|
||||
when 14 then
|
||||
Result := 0x45
|
||||
when 15 then
|
||||
Result := 0x46
|
||||
when 16 then
|
||||
Result := 0x47
|
||||
when 17 then
|
||||
Result := 0x48
|
||||
when 18 then
|
||||
Result := 0x49
|
||||
when 19 then
|
||||
Result := 0x4a
|
||||
when 20 then
|
||||
Result := 0x4b
|
||||
when 21 then
|
||||
Result := 0x4c
|
||||
when 22 then
|
||||
Result := 0x4d
|
||||
when 23 then
|
||||
Result := 0x4e
|
||||
when 24 then
|
||||
Result := 0x4f
|
||||
when 25 then
|
||||
Result := 0x50
|
||||
when 26 then
|
||||
Result := 0x51
|
||||
when 27 then
|
||||
Result := 0x52
|
||||
when 28 then
|
||||
Result := 0x53
|
||||
when 29 then
|
||||
Result := 0x54
|
||||
when 30 then
|
||||
Result := 0x55
|
||||
when 31 then
|
||||
Result := 0x56
|
||||
when 32 then
|
||||
Result := 0x57
|
||||
when 33 then
|
||||
Result := 0x58
|
||||
when 34 then
|
||||
Result := 0x59
|
||||
when 35 then
|
||||
Result := 0x5a
|
||||
when 36 then
|
||||
Result := 0x61
|
||||
when 37 then
|
||||
Result := 0x62
|
||||
when 38 then
|
||||
Result := 0x63
|
||||
when 39 then
|
||||
Result := 0x64
|
||||
when 40 then
|
||||
Result := 0x65
|
||||
when 41 then
|
||||
Result := 0x66
|
||||
when 42 then
|
||||
Result := 0x67
|
||||
when 43 then
|
||||
Result := 0x68
|
||||
when 44 then
|
||||
Result := 0x69
|
||||
when 45 then
|
||||
Result := 0x6a
|
||||
when 46 then
|
||||
Result := 0x6b
|
||||
when 47 then
|
||||
Result := 0x6c
|
||||
when 48 then
|
||||
Result := 0x6d
|
||||
when 49 then
|
||||
Result := 0x6e
|
||||
when 50 then
|
||||
Result := 0x6f
|
||||
when 51 then
|
||||
Result := 0x70
|
||||
when 52 then
|
||||
Result := 0x71
|
||||
when 53 then
|
||||
Result := 0x72
|
||||
when 54 then
|
||||
Result := 0x73
|
||||
when 55 then
|
||||
Result := 0x74
|
||||
when 56 then
|
||||
Result := 0x75
|
||||
when 57 then
|
||||
Result := 0x76
|
||||
when 58 then
|
||||
Result := 0x77
|
||||
when 59 then
|
||||
Result := 0x78
|
||||
when 60 then
|
||||
Result := 0x79
|
||||
when 61 then
|
||||
Result := 0x7a
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
note
|
||||
description: "A strategy for converting character codes to numbers and vica-versa"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "Free speech is meaningless unless it tolerates the speech that we hate. - Henry J. Hyde, U.S. Congressman, Speech, 5/3/91"
|
||||
|
||||
deferred class
|
||||
CHARACTER_STRATEGY
|
||||
|
||||
feature
|
||||
|
||||
text_to_number (in: NATURAL_8): NATURAL_8
|
||||
deferred
|
||||
end
|
||||
|
||||
number_to_text (in: NATURAL_8): NATURAL_8
|
||||
deferred
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,77 @@
|
||||
note
|
||||
description: "Summary description for {INTEGER_X_ACCESS}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "It is error alone which needs the support of government. Truth can stand by itself. - Thomas Jefferson (1743-1846), U.S. President, Notes on the State of Virginia, 1782"
|
||||
|
||||
deferred class
|
||||
INTEGER_X_ACCESS
|
||||
|
||||
inherit
|
||||
INTEGER_X_FACILITIES
|
||||
SPECIAL_SIZING
|
||||
SPECIAL_ACCESS
|
||||
rename
|
||||
get_str as get_str_special
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
get_string (op: READABLE_INTEGER_X; base: INTEGER): STRING_8
|
||||
require
|
||||
base >= 2
|
||||
base <= 62
|
||||
local
|
||||
xp: SPECIAL [NATURAL_32]
|
||||
xp_offset: INTEGER
|
||||
x_size: INTEGER
|
||||
str: STRING_8
|
||||
str_offset: INTEGER
|
||||
return_str: STRING_8
|
||||
return_str_offset: INTEGER
|
||||
str_size: INTEGER
|
||||
alloc_size: INTEGER
|
||||
num_to_text: CHARACTER_STRATEGY
|
||||
i: INTEGER
|
||||
do
|
||||
x_size := op.count
|
||||
if base <= 35 then
|
||||
create {CASE_INSENSITIVE_STRATEGY}num_to_text
|
||||
else
|
||||
create {CASE_SENSITIVE_STRATEGY}num_to_text
|
||||
end
|
||||
alloc_size := sizeinbase (op.item, 0, x_size.abs, base)
|
||||
alloc_size := alloc_size + (x_size < 0).to_integer
|
||||
create Result.make_filled ('%U', alloc_size)
|
||||
return_str := Result
|
||||
return_str_offset := 1
|
||||
if x_size < 0 then
|
||||
return_str [return_str_offset] := '-'
|
||||
return_str_offset := return_str_offset + 1
|
||||
x_size := -x_size
|
||||
end
|
||||
xp := op.item
|
||||
xp_offset := 0
|
||||
if not pow2_p (base.to_natural_32) then
|
||||
create xp.make_filled (0, x_size + 1)
|
||||
xp.copy_data (op.item, 0, 0, x_size)
|
||||
end
|
||||
str_size := get_str_special (return_str, return_str_offset, base, xp, xp_offset, x_size)
|
||||
str := return_str
|
||||
str.remove_tail (alloc_size - str_size - (return_str_offset - 1))
|
||||
str_offset := return_str_offset
|
||||
if str [str_offset] = (0x0).to_character_8 and str_size /= 1 then
|
||||
str_size := str_size - 1
|
||||
str_offset := str_offset + 1
|
||||
end
|
||||
from
|
||||
i := 0
|
||||
until
|
||||
i >= str_size
|
||||
loop
|
||||
return_str [return_str_offset + i] := num_to_text.number_to_text (str [str_offset + i].code.to_natural_8).to_character_8
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,914 @@
|
||||
note
|
||||
description: "Summary description for {INTEGER_X_ARITHMETIC}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "Every man should know that his conversations, his correspondence, and his personal life are private. - Lyndon B. Johnson (1908-1973), Remarks, 3/10/67"
|
||||
|
||||
deferred class
|
||||
INTEGER_X_ARITHMETIC
|
||||
|
||||
inherit
|
||||
INTEGER_X_FACILITIES
|
||||
SPECIAL_ARITHMETIC
|
||||
rename
|
||||
add as add_special,
|
||||
sub as sub_special,
|
||||
mul as mul_special
|
||||
export
|
||||
{NONE}
|
||||
all
|
||||
end
|
||||
SPECIAL_COMPARISON
|
||||
SPECIAL_UTILITY
|
||||
|
||||
feature
|
||||
|
||||
add (target: READABLE_INTEGER_X; op1_a: READABLE_INTEGER_X; op2_a: READABLE_INTEGER_X)
|
||||
-- Set `rop' to `op1' + `op2'.
|
||||
local
|
||||
wp: SPECIAL [NATURAL_32]
|
||||
wp_offset: INTEGER
|
||||
up: SPECIAL [NATURAL_32]
|
||||
vp: SPECIAL [NATURAL_32]
|
||||
usize: INTEGER_32
|
||||
vsize: INTEGER_32
|
||||
wsize: INTEGER_32
|
||||
abs_usize: INTEGER_32
|
||||
abs_vsize: INTEGER_32
|
||||
pointer_temp: READABLE_INTEGER_X
|
||||
int_temp: INTEGER_32
|
||||
junk2: NATURAL_32
|
||||
cy_limb: NATURAL_32
|
||||
op1: READABLE_INTEGER_X
|
||||
op2: READABLE_INTEGER_X
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
op1 := op1_a
|
||||
op2 := op2_a
|
||||
usize := op1.count
|
||||
vsize := op2.count
|
||||
abs_usize := usize.abs
|
||||
abs_vsize := vsize.abs
|
||||
if abs_usize < abs_vsize then
|
||||
pointer_temp := op1
|
||||
op1 := op2
|
||||
op2 := pointer_temp
|
||||
int_temp := usize
|
||||
usize := vsize
|
||||
vsize := int_temp
|
||||
int_temp := abs_usize
|
||||
abs_usize := abs_vsize
|
||||
abs_vsize := int_temp
|
||||
end
|
||||
wsize := abs_usize + 1
|
||||
target.resize (wsize)
|
||||
up := op1.item
|
||||
vp := op2.item
|
||||
wp := target.item
|
||||
if usize.bit_xor (vsize) < 0 then
|
||||
if abs_usize /= abs_vsize then
|
||||
sub_special (wp, 0, up, 0, abs_usize, vp, 0, abs_vsize, carry)
|
||||
junk2 := carry.item
|
||||
wsize := abs_usize
|
||||
wsize := normalize (wp, wp_offset, wsize)
|
||||
if usize < 0 then
|
||||
wsize := -wsize
|
||||
end
|
||||
elseif cmp (up, 0, vp, 0, abs_usize) < 0 then
|
||||
sub_n (wp, 0, vp, 0, up, 0, abs_usize, carry)
|
||||
junk2 := carry.item
|
||||
wsize := abs_usize
|
||||
wsize := normalize (wp, wp_offset, wsize)
|
||||
if usize >= 0 then
|
||||
wsize := -wsize
|
||||
end
|
||||
else
|
||||
sub_n (wp, 0, up, 0, vp, 0, abs_usize, carry)
|
||||
junk2 := carry.item
|
||||
wsize := abs_usize
|
||||
wsize := normalize (wp, wp_offset, wsize)
|
||||
if usize < 0 then
|
||||
wsize := -wsize
|
||||
end
|
||||
end
|
||||
else
|
||||
add_special (wp, 0, up, 0, abs_usize, vp, 0, abs_vsize, carry)
|
||||
cy_limb := carry.item
|
||||
wp [wp_offset + abs_usize] := cy_limb
|
||||
wsize := abs_usize + cy_limb.to_integer_32
|
||||
if usize < 0 then
|
||||
wsize := -wsize
|
||||
end
|
||||
end
|
||||
target.count := wsize
|
||||
end
|
||||
|
||||
add_ui (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: NATURAL)
|
||||
-- Set `rop' to `op1' + `op2'.
|
||||
local
|
||||
usize: INTEGER_32
|
||||
wsize: INTEGER_32
|
||||
abs_usize: INTEGER_32
|
||||
cy: NATURAL_32
|
||||
junk2: NATURAL_32
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
usize := op1.count
|
||||
abs_usize := usize.abs
|
||||
wsize := abs_usize + 1
|
||||
target.resize (wsize)
|
||||
if abs_usize = 0 then
|
||||
target.item [0] := op2
|
||||
if op2 /= 0 then
|
||||
target.count := 1
|
||||
else
|
||||
target.count := 0
|
||||
end
|
||||
else
|
||||
if usize >= 0 then
|
||||
add_1 (target.item, 0, op1.item, 0, abs_usize, op2, carry)
|
||||
cy := carry.item
|
||||
target.item [abs_usize] := cy
|
||||
wsize := abs_usize + cy.to_integer_32
|
||||
else
|
||||
if abs_usize = 1 and op1.item [0] < op2 then
|
||||
target.item [0] := op2 - op1.item [0]
|
||||
wsize := 1
|
||||
else
|
||||
sub_1 (target.item, 0, op1.item, 0, abs_usize, op2, carry)
|
||||
junk2 := carry.item
|
||||
if target.item [abs_usize - 1] = 0 then
|
||||
wsize := - (abs_usize - 1)
|
||||
else
|
||||
wsize := - (abs_usize)
|
||||
end
|
||||
end
|
||||
end
|
||||
target.count := wsize
|
||||
end
|
||||
end
|
||||
|
||||
aorsmul (target: READABLE_INTEGER_X; op1_a: READABLE_INTEGER_X; op2_a: READABLE_INTEGER_X; sub_a: INTEGER_32)
|
||||
local
|
||||
xsize: INTEGER_32
|
||||
ysize: INTEGER_32
|
||||
tsize: INTEGER_32
|
||||
wsize: INTEGER_32
|
||||
wsize_signed: INTEGER_32
|
||||
wp: INTEGER_32
|
||||
tp: SPECIAL [NATURAL_32]
|
||||
c: NATURAL_32
|
||||
high: NATURAL_32
|
||||
tmp_marker: SPECIAL [NATURAL_32]
|
||||
tp_offset: INTEGER_32
|
||||
current_temp: READABLE_INTEGER_X
|
||||
int_temp: INTEGER_32
|
||||
usize: INTEGER_32
|
||||
sub_l: INTEGER_32
|
||||
junk2: NATURAL_32
|
||||
op1: READABLE_INTEGER_X
|
||||
op2: READABLE_INTEGER_X
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
op1 := op1_a
|
||||
op2 := op2_a
|
||||
sub_l := sub_a
|
||||
xsize := op1.count
|
||||
ysize := op2.count
|
||||
if xsize = 0 or ysize = 0 then
|
||||
else
|
||||
if ysize.abs > xsize.abs then
|
||||
current_temp := op1
|
||||
op1 := op2
|
||||
op2 := current_temp
|
||||
int_temp := xsize
|
||||
xsize := ysize
|
||||
ysize := int_temp
|
||||
end
|
||||
sub_l := sub_l.bit_xor (ysize)
|
||||
ysize := ysize.abs
|
||||
if ysize = 1 then
|
||||
aorsmul_1 (target, op1, op2.item [0], sub_l)
|
||||
else
|
||||
sub_l := sub_l.bit_xor (xsize)
|
||||
xsize := xsize.abs
|
||||
wsize_signed := target.count
|
||||
sub_l := sub_l.bit_xor (wsize_signed)
|
||||
wsize := wsize_signed.abs
|
||||
tsize := xsize + ysize
|
||||
if wsize > tsize then
|
||||
if wsize + 1 > target.capacity then
|
||||
target.resize (wsize)
|
||||
end
|
||||
else
|
||||
if tsize + 1 > target.capacity then
|
||||
target.resize (tsize)
|
||||
end
|
||||
end
|
||||
if wsize_signed = 0 then
|
||||
mul_special (target.item, 0, op1.item, 0, xsize, op2.item, 0, ysize, carry)
|
||||
high := carry.item
|
||||
if high = 0 then
|
||||
tsize := tsize - 1
|
||||
end
|
||||
if sub_l >= 0 then
|
||||
target.count := tsize
|
||||
else
|
||||
target.count := -tsize
|
||||
end
|
||||
else
|
||||
create tmp_marker.make_filled (0, tsize)
|
||||
tp := tmp_marker
|
||||
tp_offset := 0
|
||||
mul_special (tmp_marker, 0, op1.item, 0, xsize, op2.item, 0, ysize, carry)
|
||||
high := carry.item
|
||||
if high = 0 then
|
||||
tsize := tsize - 1
|
||||
end
|
||||
if sub_l >= 0 then
|
||||
usize := wsize
|
||||
if usize < tsize then
|
||||
usize := tsize
|
||||
tp_offset := wp
|
||||
tsize := wsize
|
||||
wsize := usize
|
||||
end
|
||||
add_special (target.item, wp, op1.item, 0, usize, tp, 0, tsize, carry)
|
||||
c := carry.item
|
||||
target.item [wp + wsize] := c
|
||||
if c /= 0 then
|
||||
wsize := wsize + 1
|
||||
end
|
||||
else
|
||||
usize := wsize
|
||||
if usize < tsize or usize = tsize and cmp (target.item, wp, tmp_marker, 0, usize) < 0 then
|
||||
usize := tsize
|
||||
tp_offset := wp
|
||||
tsize := wsize
|
||||
wsize := usize
|
||||
wsize_signed := -wsize_signed
|
||||
end
|
||||
sub_special (target.item, wp, target.item, wp, usize, tp, tp_offset, tsize, carry)
|
||||
junk2 := carry.item
|
||||
wsize := usize
|
||||
from
|
||||
until
|
||||
wsize > 0 or target.item [wp + wsize - 1] /= 0
|
||||
loop
|
||||
wsize := wsize - 1
|
||||
end
|
||||
end
|
||||
if wsize_signed >= 0 then
|
||||
target.count := wsize
|
||||
else
|
||||
target.count := -wsize
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
aorsmul_1 (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: NATURAL_32; sub_a: INTEGER_32)
|
||||
local
|
||||
xsize: INTEGER_32
|
||||
wsize: INTEGER_32
|
||||
wsize_signed: INTEGER_32
|
||||
new_wsize: INTEGER_32
|
||||
min_size: INTEGER_32
|
||||
dsize: INTEGER_32
|
||||
xp: INTEGER_32
|
||||
wp: INTEGER_32
|
||||
cy: NATURAL_32
|
||||
sub_l: INTEGER_32
|
||||
cy2: NATURAL_32
|
||||
d: INTEGER_32
|
||||
s: INTEGER_32
|
||||
n: INTEGER_32
|
||||
x: NATURAL_32
|
||||
p: INTEGER_32
|
||||
cy__: NATURAL_32
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
sub_l := sub_a
|
||||
xsize := op1.count
|
||||
if xsize = 0 or op2 = 0 then
|
||||
else
|
||||
sub_l := sub_l.bit_xor (xsize)
|
||||
xsize := xsize.abs
|
||||
wsize_signed := target.count
|
||||
if wsize_signed = 0 then
|
||||
target.resize (xsize + 1)
|
||||
wp := 0
|
||||
mul_1 (target.item, 0, op1.item, 0, xsize, op2, carry)
|
||||
cy := carry.item
|
||||
target.item [xsize] := cy
|
||||
if cy /= 0 then
|
||||
xsize := xsize + 1
|
||||
end
|
||||
if sub_l >= 0 then
|
||||
target.count := xsize
|
||||
else
|
||||
target.count := -xsize
|
||||
end
|
||||
else
|
||||
sub_l := sub_l.bit_xor (wsize_signed)
|
||||
wsize := wsize_signed.abs
|
||||
new_wsize := wsize.max (xsize)
|
||||
target.resize (new_wsize + 1)
|
||||
wp := 0
|
||||
xp := 0
|
||||
min_size := wsize.min (xsize)
|
||||
if sub_l >= 0 then
|
||||
addmul_1 (target.item, 0, op1.item, 0, min_size, op2, carry)
|
||||
cy := carry.item
|
||||
wp := wp + min_size
|
||||
xp := xp + min_size
|
||||
dsize := xsize - wsize
|
||||
if dsize /= 0 then
|
||||
if dsize > 0 then
|
||||
mul_1 (target.item, wp, op1.item, xp, min_size, op2, carry)
|
||||
cy2 := carry.item
|
||||
else
|
||||
dsize := -dsize
|
||||
cy2 := 0
|
||||
end
|
||||
add_1 (target.item, wp, target.item, wp, dsize, cy, carry)
|
||||
cy := cy2 + carry.item
|
||||
end
|
||||
target.item [wp + dsize] := cy
|
||||
if cy /= 0 then
|
||||
new_wsize := new_wsize + 1
|
||||
end
|
||||
else
|
||||
submul_1 (target.item, wp, op1.item, xp, min_size, op2, carry)
|
||||
cy := carry.item
|
||||
if wsize >= xsize then
|
||||
if wsize /= xsize then
|
||||
sub_1 (target.item, wp + xsize, op1.item, wp + xsize, wsize - xsize, cy, carry)
|
||||
cy := carry.item
|
||||
if cy /= 0 then
|
||||
target.item [wp + new_wsize] := (-cy.to_integer_32).bit_not.to_natural_32
|
||||
d := wp
|
||||
s := wp
|
||||
n := new_wsize
|
||||
from
|
||||
target.item [d] := target.item [s].bit_not
|
||||
d := d + 1
|
||||
s := s + 1
|
||||
n := n - 1
|
||||
until
|
||||
n = 0
|
||||
loop
|
||||
target.item [d] := target.item [s].bit_not
|
||||
d := d + 1
|
||||
s := s + 1
|
||||
n := n - 1
|
||||
end
|
||||
new_wsize := new_wsize + 1
|
||||
p := wp
|
||||
x := target.item [p] + 1
|
||||
target.item [p] := x
|
||||
if x < 1 then
|
||||
from
|
||||
p := p + 1
|
||||
target.item [p] := target.item [p] + 1
|
||||
until
|
||||
target.item [p] /= 0
|
||||
loop
|
||||
p := p + 1
|
||||
target.item [p] := target.item [p] + 1
|
||||
end
|
||||
end
|
||||
wsize_signed := -wsize_signed
|
||||
end
|
||||
else
|
||||
d := wp
|
||||
s := wp
|
||||
n := wsize
|
||||
from
|
||||
target.item [d] := target.item [s].bit_not
|
||||
s := s + 1
|
||||
d := d + 1
|
||||
n := n - 1
|
||||
until
|
||||
n = 0
|
||||
loop
|
||||
target.item [d] := target.item [s].bit_not
|
||||
s := s + 1
|
||||
d := d + 1
|
||||
n := n - 1
|
||||
end
|
||||
add_1 (target.item, wp, target.item, wp, wsize, 1, carry)
|
||||
cy := carry.item
|
||||
cy := cy - 1
|
||||
if cy = (0).to_natural_32.bit_not then
|
||||
cy2 := cy2 + 1
|
||||
end
|
||||
cy := cy + cy2
|
||||
mul_1 (target.item, wp + wsize, target.item, xp + wsize, xsize - wsize, op2, carry)
|
||||
cy__ := carry.item
|
||||
add_1 (target.item, wp + wsize, target.item, wp + wsize, xsize - wsize, cy, carry)
|
||||
cy := cy__ + carry.item
|
||||
target.item [wp + new_wsize] := cy
|
||||
if cy /= 0 then
|
||||
new_wsize := new_wsize + 1
|
||||
end
|
||||
if cy2 /= 0 then
|
||||
p := wp + wsize
|
||||
x := target.item [p]
|
||||
target.item [p] := x - 1
|
||||
if x < 1 then
|
||||
from
|
||||
p := p + 1
|
||||
target.item [p] := target.item [p] - 1
|
||||
until
|
||||
target.item [p] = 0
|
||||
loop
|
||||
p := p + 1
|
||||
target.item [p] := target.item [p] - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
wsize_signed := -wsize_signed
|
||||
end
|
||||
end
|
||||
from
|
||||
until
|
||||
new_wsize <= 0 or target.item [(wp + new_wsize) * 4] /= 0
|
||||
loop
|
||||
new_wsize := new_wsize - 1
|
||||
end
|
||||
end
|
||||
if wsize_signed >= 0 then
|
||||
target.count := new_wsize
|
||||
else
|
||||
target.count := -new_wsize
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
sub (target: READABLE_INTEGER_X; op1_a: READABLE_INTEGER_X; op2_a: READABLE_INTEGER_X)
|
||||
-- Set `rop' to `op1' - `op2'.
|
||||
local
|
||||
usize: INTEGER_32
|
||||
vsize: INTEGER_32
|
||||
wsize: INTEGER_32
|
||||
abs_usize: INTEGER_32
|
||||
abs_vsize: INTEGER_32
|
||||
pointer_temp: READABLE_INTEGER_X
|
||||
integer_temp: INTEGER_32
|
||||
junk2: NATURAL_32
|
||||
cy_limb: NATURAL_32
|
||||
op1: READABLE_INTEGER_X
|
||||
op2: READABLE_INTEGER_X
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
op1 := op1_a
|
||||
op2 := op2_a
|
||||
usize := op1.count
|
||||
vsize := -op2.count
|
||||
abs_usize := usize.abs
|
||||
abs_vsize := vsize.abs
|
||||
if abs_usize < abs_vsize then
|
||||
pointer_temp := op1
|
||||
op1 := op2
|
||||
op2 := pointer_temp
|
||||
integer_temp := usize
|
||||
usize := vsize
|
||||
vsize := integer_temp
|
||||
integer_temp := abs_usize
|
||||
abs_usize := abs_vsize
|
||||
abs_vsize := integer_temp
|
||||
end
|
||||
wsize := abs_usize + 1
|
||||
target.resize (wsize)
|
||||
if usize.bit_xor (vsize) < 0 then
|
||||
if abs_usize /= abs_vsize then
|
||||
sub_special (target.item, 0, op1.item, 0, abs_usize, op2.item, 0, abs_vsize, carry)
|
||||
junk2 := carry.item
|
||||
wsize := abs_usize
|
||||
from
|
||||
until
|
||||
wsize <= 0 or target.item [wsize - 1] /= 0
|
||||
loop
|
||||
wsize := wsize - 1
|
||||
end
|
||||
if usize < 0 then
|
||||
wsize := -wsize
|
||||
end
|
||||
elseif cmp (op1.item, 0, op2.item, 0, abs_usize) < 0 then
|
||||
sub_n (target.item, 0, op2.item, 0, op1.item, 0, abs_usize, carry)
|
||||
junk2 := carry.item
|
||||
wsize := abs_usize
|
||||
from
|
||||
until
|
||||
wsize <= 0 or target.item [wsize - 1] /= 0
|
||||
loop
|
||||
wsize := wsize - 1
|
||||
end
|
||||
if usize >= 0 then
|
||||
wsize := -wsize
|
||||
end
|
||||
else
|
||||
sub_n (target.item, 0, op1.item, 0, op2.item, 0, abs_usize, carry)
|
||||
junk2 := carry.item
|
||||
wsize := abs_usize
|
||||
from
|
||||
until
|
||||
wsize <= 0 or target.item [wsize - 1] /= 0
|
||||
loop
|
||||
wsize := wsize - 1
|
||||
end
|
||||
if usize < 0 then
|
||||
wsize := -wsize
|
||||
end
|
||||
end
|
||||
else
|
||||
add_special (target.item, 0, op1.item, 0, abs_usize, op2.item, 0, abs_vsize, carry)
|
||||
cy_limb := carry.item
|
||||
target.item [abs_usize] := cy_limb
|
||||
wsize := abs_usize + cy_limb.to_integer_32
|
||||
if usize < 0 then
|
||||
wsize := -wsize
|
||||
end
|
||||
end
|
||||
target.count := wsize
|
||||
end
|
||||
|
||||
sub_ui (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: NATURAL)
|
||||
-- Set `rop' to `op1' - `op2'.
|
||||
local
|
||||
usize: INTEGER_32
|
||||
wsize: INTEGER_32
|
||||
abs_usize: INTEGER_32
|
||||
vval: NATURAL_32
|
||||
cy: NATURAL_32
|
||||
junk2: NATURAL_32
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
usize := op1.count
|
||||
abs_usize := usize.abs
|
||||
wsize := abs_usize + 1
|
||||
target.resize (wsize)
|
||||
if abs_usize = 0 then
|
||||
target.item [0] := vval
|
||||
if op2 /= 0 then
|
||||
target.count := -1
|
||||
else
|
||||
target.count := 0
|
||||
end
|
||||
else
|
||||
if usize < 0 then
|
||||
add_1 (target.item, 0, op1.item, 0, abs_usize, op2, carry)
|
||||
cy := carry.item
|
||||
target.item [abs_usize] := cy
|
||||
wsize := - (abs_usize + cy.to_integer_32)
|
||||
else
|
||||
if abs_usize = 1 and op1.item [0] < op2 then
|
||||
target.item [0] := op2 - op1.item [0]
|
||||
wsize := -1
|
||||
else
|
||||
sub_1 (target.item, 0, op1.item, 0, abs_usize, op2, carry)
|
||||
junk2 := carry.item
|
||||
if target.item [abs_usize - 1] = 0 then
|
||||
wsize := abs_usize - 1
|
||||
else
|
||||
wsize := abs_usize
|
||||
end
|
||||
end
|
||||
end
|
||||
target.count := wsize
|
||||
end
|
||||
end
|
||||
|
||||
ui_sub (target: READABLE_INTEGER_X; op1: NATURAL_32; op2: READABLE_INTEGER_X)
|
||||
-- Set `rop' to `op1' - `op2'.
|
||||
local
|
||||
vn: INTEGER_32
|
||||
wn: INTEGER_32
|
||||
cy: NATURAL_32
|
||||
junk2: NATURAL_32
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
vn := op2.count
|
||||
if vn > 1 then
|
||||
if vn > target.capacity then
|
||||
target.resize (vn)
|
||||
end
|
||||
sub_1 (target.item, 0, op2.item, 0, vn, op1, carry)
|
||||
junk2 := carry.item
|
||||
if target.item [vn - 1] = 0 then
|
||||
wn := - (vn - 1)
|
||||
else
|
||||
wn := - vn
|
||||
end
|
||||
elseif vn = 1 then
|
||||
if op1 >= op2.item [0] then
|
||||
target.item [0] := op1 - op2.item [0]
|
||||
if target.item [0] /= 0 then
|
||||
wn := 1
|
||||
else
|
||||
wn := 0
|
||||
end
|
||||
else
|
||||
target.item [0] := op2.item [0] - op1
|
||||
wn := -1
|
||||
end
|
||||
elseif vn = 0 then
|
||||
target.item [0] := op1
|
||||
if op1 /= 0 then
|
||||
wn := 1
|
||||
else
|
||||
wn := 0
|
||||
end
|
||||
else
|
||||
vn := -vn
|
||||
target.resize (vn + 1)
|
||||
add_1 (target.item, 0, op2.item, 0, vn, op1, carry)
|
||||
cy := carry.item
|
||||
target.item [vn] := cy
|
||||
if cy /= 0 then
|
||||
wn := vn + 1
|
||||
else
|
||||
wn := vn
|
||||
end
|
||||
end
|
||||
target.count := wn
|
||||
end
|
||||
|
||||
addmul (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: READABLE_INTEGER_X)
|
||||
-- Set `rop' to `rop' + `op1' times `op2'.
|
||||
do
|
||||
aorsmul (target, op1, op2, 0)
|
||||
end
|
||||
|
||||
addmul_ui (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: NATURAL)
|
||||
-- Set `rop' to `rop' + `op1' times `op2'.
|
||||
do
|
||||
aorsmul_1 (target, op1, op2, 0)
|
||||
end
|
||||
|
||||
submul (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: READABLE_INTEGER_X)
|
||||
-- Set `rop' to `rop' - `op1' times `op2'.
|
||||
do
|
||||
aorsmul (target, op1, op2, -1)
|
||||
end
|
||||
|
||||
submul_ui (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: NATURAL)
|
||||
-- Set `rop' to `rop' - `op1' times `op2'.
|
||||
do
|
||||
aorsmul_1 (target, op1, op2, -1)
|
||||
end
|
||||
|
||||
mul (target: READABLE_INTEGER_X; op1_a: READABLE_INTEGER_X; op2_a: READABLE_INTEGER_X)
|
||||
-- Set `rop' to `op1' times `op2'.
|
||||
local
|
||||
usize: INTEGER
|
||||
vsize: INTEGER
|
||||
wsize: INTEGER
|
||||
sign_product: INTEGER
|
||||
vp: SPECIAL [NATURAL_32]
|
||||
vp_offset: INTEGER
|
||||
up: SPECIAL [NATURAL_32]
|
||||
up_offset: INTEGER
|
||||
wp: SPECIAL [NATURAL_32]
|
||||
wp_offset: INTEGER
|
||||
cy_limb: NATURAL_32
|
||||
op_temp: READABLE_INTEGER_X
|
||||
size_temp: INTEGER_32
|
||||
op1: READABLE_INTEGER_X
|
||||
op2: READABLE_INTEGER_X
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
op1 := op1_a
|
||||
op2 := op2_a
|
||||
usize := op1.count
|
||||
vsize := op2.count
|
||||
sign_product := usize.bit_xor (vsize)
|
||||
usize := usize.abs
|
||||
vsize := vsize.abs
|
||||
if usize = 0 or vsize = 0 then
|
||||
target.count := 0
|
||||
else
|
||||
if vsize = 1 then
|
||||
if usize + 1 > target.capacity then
|
||||
target.resize (usize + 1)
|
||||
end
|
||||
wp := target.item
|
||||
mul_1 (target.item, 0, op1.item, 0, usize, op2.item [0], carry)
|
||||
cy_limb := carry.item
|
||||
target.item [usize] := cy_limb
|
||||
if cy_limb /= 0 then
|
||||
usize := usize + 1
|
||||
end
|
||||
if sign_product >= 0 then
|
||||
target.count := usize
|
||||
else
|
||||
target.count := -usize
|
||||
end
|
||||
else
|
||||
wsize := usize + vsize
|
||||
if wsize <= 32 and target /= op1 and target /= op2 then
|
||||
target.resize (wsize)
|
||||
wp := target.item
|
||||
if usize > vsize then
|
||||
mul_basecase (wp, 0, op1.item, 0, usize, op2.item, 0, vsize)
|
||||
else
|
||||
mul_basecase (wp, 0, op2.item, 0, vsize, op1.item, 0, usize)
|
||||
end
|
||||
wsize := wsize - (wp [wp_offset + wsize - 1] = 0).to_integer
|
||||
if sign_product >= 0 then
|
||||
target.count := wsize
|
||||
else
|
||||
target.count := -wsize
|
||||
end
|
||||
else
|
||||
if usize < vsize then
|
||||
op_temp := op1
|
||||
op1 := op2
|
||||
op2 := op_temp
|
||||
size_temp := usize
|
||||
usize := vsize
|
||||
vsize := size_temp
|
||||
end
|
||||
up := op1.item
|
||||
up_offset := 0
|
||||
vp := op2.item
|
||||
vp_offset := 0
|
||||
wp := target.item
|
||||
wp_offset := 0
|
||||
if target.capacity < wsize then
|
||||
create wp.make_filled (0, wsize)
|
||||
target.item := wp
|
||||
else
|
||||
if wp = up then
|
||||
create up.make_filled (0, usize)
|
||||
if wp = vp then
|
||||
vp := up
|
||||
end
|
||||
up.copy_data (wp, 0, 0, usize)
|
||||
elseif wp = vp then
|
||||
create vp.make_filled (0, vsize)
|
||||
vp.copy_data (wp, 0, 0, vsize)
|
||||
end
|
||||
end
|
||||
mul_special (wp, 0, up, 0, usize, vp, 0, vsize, carry)
|
||||
cy_limb := carry.item
|
||||
wsize := usize + vsize
|
||||
wsize := wsize - (cy_limb = 0).to_integer
|
||||
if sign_product < 0 then
|
||||
target.count := -wsize
|
||||
else
|
||||
target.count := wsize
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mul_2exp (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; count_a: INTEGER)
|
||||
local
|
||||
usize: INTEGER
|
||||
abs_usize: INTEGER
|
||||
wsize: INTEGER
|
||||
limb_count: INTEGER
|
||||
wp: SPECIAL [NATURAL_32]
|
||||
wp_offset: INTEGER
|
||||
wlimb: NATURAL_32
|
||||
count: INTEGER
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
count := count_a
|
||||
usize := op1.count
|
||||
abs_usize := usize.abs
|
||||
if usize = 0 then
|
||||
target.count := 0
|
||||
else
|
||||
limb_count := count // limb_bits
|
||||
wsize := abs_usize + limb_count + 1
|
||||
target.resize (wsize)
|
||||
wp := target.item
|
||||
wsize := abs_usize + limb_count
|
||||
count := count \\ limb_bits
|
||||
if count /= 0 then
|
||||
lshift (wp, wp_offset + limb_count, op1.item, 0, abs_usize, count, carry)
|
||||
wlimb := carry.item
|
||||
if wlimb /= 0 then
|
||||
wp [wp_offset + wsize] := wlimb
|
||||
wsize := wsize + 1
|
||||
end
|
||||
else
|
||||
wp.copy_data (op1.item, 0, wp_offset + limb_count, abs_usize)
|
||||
end
|
||||
wp.fill_with (0, wp_offset, wp_offset + limb_count - 1)
|
||||
if usize >= 0 then
|
||||
target.count := wsize
|
||||
else
|
||||
target.count := -wsize
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mul_si (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: INTEGER)
|
||||
local
|
||||
size: INTEGER
|
||||
sign_product: INTEGER
|
||||
sml: NATURAL_32
|
||||
cy: NATURAL_32
|
||||
pp: SPECIAL [NATURAL_32]
|
||||
pp_offset: INTEGER
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
size := op1.count
|
||||
sign_product := size
|
||||
if size = 0 or op2 = 0 then
|
||||
target.count := 0
|
||||
else
|
||||
size := size.abs
|
||||
sml := op2.abs.to_natural_32
|
||||
target.resize (size + 1)
|
||||
pp := target.item
|
||||
mul_1 (pp, pp_offset, op1.item, 0, size, sml, carry)
|
||||
cy := carry.item
|
||||
pp [pp_offset + size] := cy
|
||||
size := size + (cy /= 0).to_integer
|
||||
end
|
||||
if sign_product < 0 xor op2 < 0 then
|
||||
target.count := -size
|
||||
else
|
||||
target.count := size
|
||||
end
|
||||
end
|
||||
|
||||
mul_ui (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: NATURAL_32)
|
||||
local
|
||||
size: INTEGER
|
||||
sign_product: INTEGER
|
||||
sml: NATURAL_32
|
||||
cy: NATURAL_32
|
||||
pp: SPECIAL [NATURAL_32]
|
||||
pp_offset: INTEGER
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
size := op1.count
|
||||
sign_product := size
|
||||
if size = 0 or op2 = 0 then
|
||||
target.count := 0
|
||||
else
|
||||
size := size.abs
|
||||
sml := op2
|
||||
target.resize (size + 1)
|
||||
pp := target.item
|
||||
mul_1 (pp, pp_offset, op1.item, 0, size, sml, carry)
|
||||
cy := carry.item
|
||||
pp [pp_offset + size] := cy
|
||||
size := size + (cy /= 0).to_integer
|
||||
end
|
||||
if sign_product < 0 xor op2 < 0 then
|
||||
target.count := -size
|
||||
else
|
||||
target.count := size
|
||||
end
|
||||
end
|
||||
|
||||
neg (target: READABLE_INTEGER_X; op: READABLE_INTEGER_X)
|
||||
-- Set `rop' to -`op'.
|
||||
local
|
||||
usize: INTEGER_32
|
||||
size: INTEGER_32
|
||||
do
|
||||
usize := op.count
|
||||
if target /= op then
|
||||
size := usize.abs
|
||||
target.resize (size)
|
||||
target.item.copy_data (op.item, 0, 0, size)
|
||||
end
|
||||
target.count := -usize
|
||||
end
|
||||
|
||||
abs (target: READABLE_INTEGER_X; op: READABLE_INTEGER_X)
|
||||
-- Set `rop' to the absolute value of `op'.
|
||||
local
|
||||
size: INTEGER_32
|
||||
do
|
||||
size := op.count.abs
|
||||
if op /= target then
|
||||
target.resize (size)
|
||||
target.item.copy_data (op.item, 0, 0, size)
|
||||
end
|
||||
target.count := size
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,155 @@
|
||||
note
|
||||
description: "Summary description for {INTEGER_X_ASSIGNMENT}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "The object and practice of liberty lies in the limitation of governmental power. - General Douglas MacArthur"
|
||||
|
||||
deferred class
|
||||
INTEGER_X_ASSIGNMENT
|
||||
|
||||
inherit
|
||||
INTEGER_X_FACILITIES
|
||||
SPECIAL_ASSIGNMENT
|
||||
rename
|
||||
set_str as set_str_special
|
||||
end
|
||||
MP_BASES
|
||||
|
||||
feature
|
||||
|
||||
swap (target: READABLE_INTEGER_X; other_a: READABLE_INTEGER_X)
|
||||
-- Swap the values `rop1' and `rop2' efficiently.
|
||||
local
|
||||
other_size: INTEGER_32
|
||||
other_pointer: SPECIAL [NATURAL_32]
|
||||
do
|
||||
other_size := other_a.count
|
||||
other_pointer := other_a.item
|
||||
other_a.count := target.count
|
||||
other_a.item := target.item
|
||||
target.count := other_size
|
||||
target.item := other_pointer
|
||||
end
|
||||
|
||||
set_str (target: READABLE_INTEGER_X; str: READABLE_STRING_8; base_a: INTEGER)
|
||||
-- Set the value of `rop' from `str', a null-terminated C string in base `base'.
|
||||
-- White space is allowed in the string, and is simply ignored.
|
||||
-- The base may vary from 2 to 62, or if base is 0, then the leading characters
|
||||
-- are used: 0x and 0X for hexadecimal, 0b and 0B for binary, 0 for octal, or
|
||||
-- decimal otherwise.
|
||||
-- For bases up to 36, case is ignored; upper-case and lower-case letters have
|
||||
-- the same value.
|
||||
-- For bases 37 to 62, upper-case letter represent the usual 10..35 while
|
||||
-- lower-case letter represent 36..61.
|
||||
-- This function returns 0 if the entire string is a valid number in base base.
|
||||
-- Otherwise it returns -1.
|
||||
require
|
||||
base_a <= 62
|
||||
base_a >= 2 or base_a = 0
|
||||
local
|
||||
base: INTEGER
|
||||
str_offset: INTEGER
|
||||
s: SPECIAL [NATURAL_8]
|
||||
s_offset: INTEGER
|
||||
begs: INTEGER
|
||||
i: INTEGER
|
||||
xsize: INTEGER
|
||||
c: CHARACTER
|
||||
negative: BOOLEAN
|
||||
digit_value: CHARACTER_STRATEGY
|
||||
str_size: INTEGER
|
||||
dig: NATURAL_8
|
||||
do
|
||||
base := base_a
|
||||
if base > 36 then
|
||||
create {CASE_SENSITIVE_STRATEGY}digit_value
|
||||
else
|
||||
create {CASE_INSENSITIVE_STRATEGY}digit_value
|
||||
end
|
||||
from
|
||||
str_offset := 1
|
||||
c := ' '
|
||||
until
|
||||
not c.is_space or not str.valid_index (str_offset)
|
||||
loop
|
||||
c := str [str_offset]
|
||||
str_offset := str_offset + 1
|
||||
end
|
||||
if c = '-' then
|
||||
negative := True
|
||||
c := str [str_offset]
|
||||
str_offset := str_offset + 1
|
||||
end
|
||||
if base = 0 then
|
||||
if digit_value.text_to_number (c.code.to_natural_8) >= 10 then
|
||||
(create {INTEGER_X_STRING_EXCEPTION}).raise
|
||||
end
|
||||
else
|
||||
if digit_value.text_to_number (c.code.to_natural_8) >= base then
|
||||
(create {INTEGER_X_STRING_EXCEPTION}).raise
|
||||
end
|
||||
end
|
||||
if base = 0 then
|
||||
base := 10
|
||||
if c = '0' then
|
||||
base := 8
|
||||
if str.valid_index (str_offset) then
|
||||
c := str [str_offset]
|
||||
end
|
||||
str_offset := str_offset + 1
|
||||
if c = 'x' or c = 'X' then
|
||||
base := 16
|
||||
c := str [str_offset]
|
||||
str_offset := str_offset + 1
|
||||
elseif c = 'b' or c = 'B' then
|
||||
base := 2
|
||||
c := str [str_offset]
|
||||
str_offset := str_offset + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
from
|
||||
until
|
||||
c /= '0' and not c.is_space or not str.valid_index (str_offset)
|
||||
loop
|
||||
c := str [str_offset]
|
||||
str_offset := str_offset + 1
|
||||
end
|
||||
if c.code = 0 then
|
||||
target.count := 0
|
||||
target.item [0] := 0
|
||||
else
|
||||
str_size := str.count - str_offset + 2
|
||||
create s.make_filled (0, str_size)
|
||||
from
|
||||
i := 0
|
||||
until
|
||||
i >= str_size
|
||||
loop
|
||||
if not c.is_space then
|
||||
dig := digit_value.text_to_number (c.code.to_natural_8)
|
||||
if dig.to_integer_32 >= base then
|
||||
(create {INTEGER_X_STRING_EXCEPTION}).raise
|
||||
end
|
||||
s [s_offset] := dig
|
||||
s_offset := s_offset + 1
|
||||
end
|
||||
if str.valid_index (str_offset) then
|
||||
c := str [str_offset]
|
||||
end
|
||||
str_offset := str_offset + 1
|
||||
i := i + 1
|
||||
end
|
||||
str_size := s_offset - begs
|
||||
xsize := (str_size / chars_per_bit_exactly (base)).truncated_to_integer // 32 + 2
|
||||
target.resize (xsize)
|
||||
xsize := set_str_special (target.item, 0, s, begs, str_size, base)
|
||||
if negative then
|
||||
target.count := -xsize
|
||||
else
|
||||
target.count := xsize
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,200 @@
|
||||
note
|
||||
description: "Summary description for {INTEGER_X_COMPARISON}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "The marvel of all history is the patience with which men and women submit to burdens unnecessarily laid upon them by their governments. - U.S. Senator William Borah"
|
||||
|
||||
deferred class
|
||||
INTEGER_X_COMPARISON
|
||||
|
||||
inherit
|
||||
INTEGER_X_FACILITIES
|
||||
SPECIAL_COMPARISON
|
||||
rename
|
||||
cmp as cmp_special
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
compare (op1: READABLE_INTEGER_X; op2: READABLE_INTEGER_X): INTEGER
|
||||
-- Compare `op1' and `op2'.
|
||||
-- Return a positive value if `op1' > `op2', zero if `op1' = `op2', or a negative value if `op1' < `op2'.
|
||||
local
|
||||
usize: INTEGER_32
|
||||
vsize: INTEGER_32
|
||||
dsize: INTEGER_32
|
||||
asize: INTEGER_32
|
||||
cmp_l: INTEGER_32
|
||||
do
|
||||
usize := op1.count
|
||||
vsize := op2.count
|
||||
dsize := usize - vsize
|
||||
if dsize /= 0 then
|
||||
Result := dsize
|
||||
else
|
||||
asize := usize.abs
|
||||
cmp_l := cmp_special (op1.item, 0, op2.item, 0, asize)
|
||||
if usize >= 0 then
|
||||
Result := cmp_l
|
||||
else
|
||||
Result := -cmp_l
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
cmp_si (op1: READABLE_INTEGER_X; op: INTEGER_32): INTEGER
|
||||
-- Compare `op1' and `op2'.
|
||||
-- Return a positive value if `op1' > `op2', zero if `op1' = `op2', or a negative value if `op1' < `op2'.
|
||||
-- Is a macro and will evaluate their arguments more than once.
|
||||
local
|
||||
v_digit: INTEGER_32
|
||||
usize: INTEGER_32
|
||||
vsize: INTEGER_32
|
||||
u_digit: NATURAL_32
|
||||
do
|
||||
v_digit := op
|
||||
usize := op1.count
|
||||
vsize := 0
|
||||
if v_digit > 0 then
|
||||
vsize := 1
|
||||
elseif v_digit < 0 then
|
||||
vsize := -1
|
||||
v_digit := -v_digit
|
||||
end
|
||||
if usize /= vsize then
|
||||
Result := usize - vsize
|
||||
else
|
||||
if usize = 0 then
|
||||
Result := 0
|
||||
else
|
||||
u_digit := op1.item [0]
|
||||
if u_digit = v_digit.to_natural_32 then
|
||||
Result := 0
|
||||
else
|
||||
if u_digit > v_digit.to_natural_32 then
|
||||
Result := usize
|
||||
else
|
||||
Result := -usize
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
cmp_ui (op1: READABLE_INTEGER_X; op: NATURAL): INTEGER
|
||||
-- Compare `op1' and `op2'.
|
||||
-- Return a positive value if `op1' > `op2', zero if `op1' = `op2', or a negative value if `op1' < `op2'.
|
||||
-- Is a macro and will evaluate their arguments more than once.
|
||||
local
|
||||
un: INTEGER_32
|
||||
ul: NATURAL_32
|
||||
v_digit: NATURAL_32
|
||||
do
|
||||
v_digit := op
|
||||
un := op1.count
|
||||
if un = 0 then
|
||||
if v_digit /= 0 then
|
||||
Result := -1
|
||||
else
|
||||
Result := 0
|
||||
end
|
||||
else
|
||||
if un = 1 then
|
||||
ul := op1.item [0]
|
||||
if ul > v_digit then
|
||||
Result := 1
|
||||
else
|
||||
if ul < v_digit then
|
||||
Result := -1
|
||||
else
|
||||
Result := 0
|
||||
end
|
||||
end
|
||||
else
|
||||
if un > 0 then
|
||||
Result := 1
|
||||
else
|
||||
Result := -1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
cmpabs (op1: READABLE_INTEGER_X ;op2: READABLE_INTEGER_X): INTEGER
|
||||
-- Compare the absolute values of `op1' and `op2'.
|
||||
-- Return a positive value if abs(`op1') > abs(`op2'), zero if abs(`op1') = abs(`op2'),
|
||||
-- or a negative value if abs(`op1') < abs(`op2').
|
||||
local
|
||||
usize: INTEGER_32
|
||||
vsize: INTEGER_32
|
||||
dsize: INTEGER_32
|
||||
cmp_l: INTEGER_32
|
||||
i: INTEGER_32
|
||||
x: NATURAL_32
|
||||
y: NATURAL_32
|
||||
do
|
||||
usize := op1.count.abs
|
||||
vsize := op2.count.abs
|
||||
dsize := usize - vsize
|
||||
if dsize /= 0 then
|
||||
Result := dsize
|
||||
else
|
||||
cmp_l := 0
|
||||
from
|
||||
i := usize - 1
|
||||
until
|
||||
i < 0 or cmp_l /= 0
|
||||
loop
|
||||
x := op1.item [i]
|
||||
y := op2.item [i]
|
||||
if x /= y then
|
||||
if x > y then
|
||||
Result := 1
|
||||
else
|
||||
Result := -1
|
||||
end
|
||||
end
|
||||
i := i - 1
|
||||
variant
|
||||
i + 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
cmpabs_ui (op1: READABLE_INTEGER_X; op: NATURAL_32): INTEGER
|
||||
-- Compare the absolute values of `op1' and `op2'.
|
||||
-- Return a positive value if abs(`op1') > abs(`op2'), zero if abs(`op1') = abs(`op2'),
|
||||
-- or a negative value if abs(`op1') < abs(`op2').
|
||||
local
|
||||
un: INTEGER_32
|
||||
ul: NATURAL_32
|
||||
v_digit: NATURAL_32
|
||||
do
|
||||
v_digit := op
|
||||
un := op1.count
|
||||
if un = 0 then
|
||||
if v_digit /= 0 then
|
||||
Result := -1
|
||||
else
|
||||
Result := 0
|
||||
end
|
||||
else
|
||||
un := un.abs
|
||||
if un = 1 then
|
||||
ul := op1.item [0]
|
||||
if ul > v_digit then
|
||||
Result := 1
|
||||
else
|
||||
if ul < v_digit then
|
||||
Result := -1
|
||||
else
|
||||
Result := 0
|
||||
end
|
||||
end
|
||||
else
|
||||
Result := 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,429 @@
|
||||
note
|
||||
description: "Summary description for {INTEGER_X_DIVISION}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "Collecting more taxes than is absolutely necessary is legalized robbery. - President Calvin Coolidge"
|
||||
|
||||
deferred class
|
||||
INTEGER_X_DIVISION
|
||||
|
||||
inherit
|
||||
INTEGER_X_FACILITIES
|
||||
SPECIAL_UTILITY
|
||||
export
|
||||
{NONE}
|
||||
all
|
||||
end
|
||||
SPECIAL_DIVISION
|
||||
rename
|
||||
add as add_special,
|
||||
sub as sub_special,
|
||||
mul as mul_special,
|
||||
tdiv_qr as tdiv_qr_special
|
||||
export
|
||||
{NONE}
|
||||
all
|
||||
end
|
||||
INTEGER_X_ARITHMETIC
|
||||
INTEGER_X_ASSIGNMENT
|
||||
rename
|
||||
add as add_special,
|
||||
sub as sub_special,
|
||||
mul as mul_special
|
||||
export
|
||||
{NONE}
|
||||
all
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
fdiv_r_2exp (target: READABLE_INTEGER_X; u: READABLE_INTEGER_X; count: INTEGER)
|
||||
do
|
||||
cfdiv_r_2exp (target, u, count, -1)
|
||||
end
|
||||
|
||||
cdiv_r_2exp (target: READABLE_INTEGER_X; u: READABLE_INTEGER_X; count: INTEGER)
|
||||
do
|
||||
cfdiv_r_2exp (target, u, count, 1)
|
||||
end
|
||||
|
||||
cfdiv_r_2exp (target: READABLE_INTEGER_X; u: READABLE_INTEGER_X; count_a: INTEGER; direction: INTEGER)
|
||||
local
|
||||
usize: INTEGER
|
||||
abs_usize: INTEGER
|
||||
limb_count: INTEGER
|
||||
i: INTEGER
|
||||
up: SPECIAL [NATURAL_32]
|
||||
up_offset: INTEGER
|
||||
wp: SPECIAL [NATURAL_32]
|
||||
wp_offset: INTEGER
|
||||
high: NATURAL_32
|
||||
count: INTEGER
|
||||
returned: BOOLEAN
|
||||
negate: BOOLEAN
|
||||
do
|
||||
create wp.make_empty (0)
|
||||
count := count_a
|
||||
usize := u.count
|
||||
if usize = 0 then
|
||||
target.count := 0
|
||||
else
|
||||
limb_count := count // 32
|
||||
count := count \\ 32
|
||||
abs_usize := usize.abs
|
||||
up := u.item
|
||||
if usize.bit_xor (direction) < 0 and Current = u and abs_usize <= limb_count then
|
||||
returned := True
|
||||
else
|
||||
if usize.bit_xor (direction) < 0 then
|
||||
if Current = u then
|
||||
wp := target.item
|
||||
else
|
||||
i := abs_usize.min (limb_count + 1)
|
||||
target.resize (i)
|
||||
wp := target.item
|
||||
wp.copy_data (up, up_offset, wp_offset, i)
|
||||
if abs_usize <= limb_count then
|
||||
target.count := usize
|
||||
returned := True
|
||||
end
|
||||
end
|
||||
else
|
||||
if abs_usize <= limb_count then
|
||||
negate := True
|
||||
else
|
||||
from
|
||||
i := 0
|
||||
until
|
||||
i < limb_count or negate
|
||||
loop
|
||||
negate := up [up_offset + i] /= 0
|
||||
i := i + 1
|
||||
end
|
||||
if not negate then
|
||||
if up [up_offset + limb_count].bit_and (((1).to_natural_32 |<< count) - 1) /= 0 then
|
||||
negate := True
|
||||
else
|
||||
target.count := 0
|
||||
returned := True
|
||||
end
|
||||
end
|
||||
end
|
||||
if not returned and negate then
|
||||
target.resize (limb_count + 1)
|
||||
up := u.item
|
||||
up_offset := 0
|
||||
wp := target.item
|
||||
wp_offset := 0
|
||||
i := abs_usize.min (limb_count + 1)
|
||||
com_n (wp, wp_offset, up, up_offset, i)
|
||||
from
|
||||
until
|
||||
i > limb_count
|
||||
loop
|
||||
wp [wp_offset + i] := high.max_value
|
||||
i := i + 1
|
||||
end
|
||||
incr_u (wp, wp_offset, 1)
|
||||
usize := -usize
|
||||
end
|
||||
end
|
||||
end
|
||||
if not returned then
|
||||
high := wp [wp_offset + limb_count]
|
||||
high := high.bit_and (((1).to_natural_32 |<< count) - 1)
|
||||
wp [wp_offset + limb_count] := high
|
||||
from
|
||||
limb_count := limb_count - 1
|
||||
until
|
||||
high /= 0 or limb_count < 0
|
||||
loop
|
||||
high := wp [wp_offset + limb_count]
|
||||
end
|
||||
if limb_count < 0 then
|
||||
target.count := 0
|
||||
else
|
||||
limb_count := limb_count + 1
|
||||
if usize >= 0 then
|
||||
target.count := limb_count
|
||||
else
|
||||
target.count := -limb_count
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mod (target: READABLE_INTEGER_X; dividend: READABLE_INTEGER_X; divisor_a: READABLE_INTEGER_X)
|
||||
local
|
||||
divisor_size: INTEGER
|
||||
temp_divisor: INTEGER_X
|
||||
divisor: READABLE_INTEGER_X
|
||||
do
|
||||
divisor := divisor_a
|
||||
divisor_size := divisor.count
|
||||
if target = divisor then
|
||||
create temp_divisor.make_limbs (divisor_size.abs)
|
||||
temp_divisor.set_from_other (divisor)
|
||||
divisor := temp_divisor
|
||||
end
|
||||
tdiv_r (target, dividend, divisor)
|
||||
if target.count /= 0 then
|
||||
if dividend.count < 0 then
|
||||
if divisor.count < 0 then
|
||||
sub (target, target, divisor)
|
||||
else
|
||||
add (target, target, divisor)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tdiv_q (target: READABLE_INTEGER_X; numerator: READABLE_INTEGER_X; denominator: READABLE_INTEGER_X)
|
||||
local
|
||||
ql: INTEGER
|
||||
ns: INTEGER
|
||||
ds: INTEGER
|
||||
nl: INTEGER
|
||||
dl: INTEGER
|
||||
np: SPECIAL [NATURAL_32]
|
||||
np_offset: INTEGER
|
||||
dp: SPECIAL [NATURAL_32]
|
||||
dp_offset: INTEGER
|
||||
qp: SPECIAL [NATURAL_32]
|
||||
qp_offset: INTEGER
|
||||
rp: SPECIAL [NATURAL_32]
|
||||
rp_offset: INTEGER
|
||||
tp: SPECIAL [NATURAL_32]
|
||||
tp_offset: INTEGER
|
||||
do
|
||||
ns := numerator.count
|
||||
ds := denominator.count
|
||||
nl := ns.abs
|
||||
dl := ds.abs
|
||||
ql := nl - dl + 1
|
||||
|
||||
if dl = 0 then
|
||||
(create {DIVIDE_BY_ZERO}).raise
|
||||
end
|
||||
if ql <= 0 then
|
||||
target.count := 0
|
||||
else
|
||||
target.resize (ql)
|
||||
qp := target.item
|
||||
create rp.make_filled (0, dl)
|
||||
np := numerator.item
|
||||
dp := denominator.item
|
||||
if dp = qp then
|
||||
create tp.make_filled (0, dl)
|
||||
tp.copy_data (dp, dp_offset, tp_offset, dl)
|
||||
dp := tp
|
||||
end
|
||||
if np = qp then
|
||||
create tp.make_filled (0, nl)
|
||||
tp.copy_data (np, np_offset, tp_offset, nl)
|
||||
np := tp
|
||||
end
|
||||
tdiv_qr_special (qp, qp_offset, rp, rp_offset, np, np_offset, nl, dp, dp_offset, dl)
|
||||
ql := ql - (qp [qp_offset + ql - 1] = 0).to_integer
|
||||
if ns.bit_xor (ds) >= 0 then
|
||||
target.count := ql
|
||||
else
|
||||
target.count := -ql
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tdiv_q_2exp (target: READABLE_INTEGER_X; op: READABLE_INTEGER_X; count_a: INTEGER_32)
|
||||
local
|
||||
usize: INTEGER
|
||||
wsize: INTEGER
|
||||
limb_count: INTEGER
|
||||
wp: SPECIAL [NATURAL_32]
|
||||
wp_offset: INTEGER
|
||||
up: SPECIAL [NATURAL_32]
|
||||
up_offset: INTEGER
|
||||
junk: NATURAL_32
|
||||
count: INTEGER_32
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
count := count_a
|
||||
usize := op.count
|
||||
limb_count := count // 32
|
||||
wsize := usize.abs - limb_count
|
||||
if wsize <= 0 then
|
||||
target.count := 0
|
||||
else
|
||||
target.resize (wsize)
|
||||
wp := target.item
|
||||
up := op.item
|
||||
count := count \\ 32
|
||||
if count /= 0 then
|
||||
rshift (wp, wp_offset, up, up_offset + limb_count, wsize, count, carry)
|
||||
junk := carry.item
|
||||
wsize := wsize - (wp [wp_offset + wsize - 1] = 0).to_integer
|
||||
else
|
||||
wp.copy_data (up, up_offset + limb_count, wp_offset, wsize)
|
||||
end
|
||||
if usize >= 0 then
|
||||
target.count := wsize
|
||||
else
|
||||
target.count := -wsize
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tdiv_qr (target: READABLE_INTEGER_X; remainder: READABLE_INTEGER_X; numerator: READABLE_INTEGER_X; denominator: READABLE_INTEGER_X)
|
||||
local
|
||||
ql: INTEGER_32
|
||||
ns: INTEGER_32
|
||||
ds: INTEGER_32
|
||||
nl: INTEGER_32
|
||||
dl: INTEGER_32
|
||||
temp_dp: SPECIAL [NATURAL_32]
|
||||
temp_np: SPECIAL [NATURAL_32]
|
||||
do
|
||||
ns := numerator.count
|
||||
ds := denominator.count
|
||||
nl := ns.abs
|
||||
dl := ds.abs
|
||||
ql := nl - dl + 1
|
||||
if dl = 0 then
|
||||
(create {DIVIDE_BY_ZERO}).raise
|
||||
end
|
||||
remainder.resize (dl)
|
||||
if ql <= 0 then
|
||||
if numerator /= remainder then
|
||||
remainder.item.copy_data (numerator.item, 0, 0, nl)
|
||||
remainder.count := numerator.count
|
||||
end
|
||||
target.count := 0
|
||||
else
|
||||
target.resize (ql)
|
||||
if denominator = remainder or denominator = Current then
|
||||
create temp_dp.make_empty (dl)
|
||||
temp_dp.copy_data (denominator.item, 0, 0, dl)
|
||||
else
|
||||
temp_dp := denominator.item
|
||||
end
|
||||
if numerator = remainder or numerator = Current then
|
||||
create temp_np.make_empty (nl)
|
||||
temp_np.copy_data (numerator.item, 0, 0, nl)
|
||||
else
|
||||
temp_np := numerator.item
|
||||
end
|
||||
tdiv_qr_special (target.item, 0, remainder.item, 0, temp_np, 0, nl, temp_dp, 0, dl)
|
||||
if target.item [ql - 1] = 0 then
|
||||
ql := ql - 1
|
||||
end
|
||||
remainder.count := normalize (remainder.item, 0, remainder.count)
|
||||
dl := remainder.count
|
||||
if ns.bit_xor (ds) >= 0 then
|
||||
target.count := ql
|
||||
else
|
||||
target.count := -ql
|
||||
end
|
||||
if ns >= 0 then
|
||||
remainder.count := dl
|
||||
else
|
||||
remainder.count := -dl
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tdiv_r (remainder: READABLE_INTEGER_X; numerator: READABLE_INTEGER_X; denominator: READABLE_INTEGER_X)
|
||||
local
|
||||
ql: INTEGER
|
||||
ns: INTEGER
|
||||
ds: INTEGER
|
||||
nl: INTEGER
|
||||
dl: INTEGER
|
||||
np: SPECIAL [NATURAL_32]
|
||||
np_offset: INTEGER
|
||||
dp: SPECIAL [NATURAL_32]
|
||||
dp_offset: INTEGER
|
||||
qp: SPECIAL [NATURAL_32]
|
||||
qp_offset: INTEGER
|
||||
rp: SPECIAL [NATURAL_32]
|
||||
rp_offset: INTEGER
|
||||
tp: SPECIAL [NATURAL_32]
|
||||
tp_offset: INTEGER
|
||||
do
|
||||
ns := numerator.count
|
||||
ds := denominator.count
|
||||
nl := ns.abs
|
||||
dl := ds.abs
|
||||
ql := nl - dl + 1
|
||||
if dl = 0 then
|
||||
(create {DIVIDE_BY_ZERO}).raise
|
||||
end
|
||||
remainder.resize (dl)
|
||||
if ql <= 0 then
|
||||
if numerator /= remainder then
|
||||
np := numerator.item
|
||||
rp := remainder.item
|
||||
rp.copy_data (np, 0, 0, nl)
|
||||
remainder.count := numerator.count
|
||||
end
|
||||
else
|
||||
create qp.make_filled (0, ql)
|
||||
rp := remainder.item
|
||||
np := numerator.item
|
||||
dp := denominator.item
|
||||
if dp = rp then
|
||||
create tp.make_filled (0, nl)
|
||||
tp.copy_data (np, np_offset, tp_offset, nl)
|
||||
np := tp
|
||||
np_offset := tp_offset
|
||||
end
|
||||
tdiv_qr_special (qp, qp_offset, rp, rp_offset, np, np_offset, nl, dp, dp_offset, dl)
|
||||
dl := normalize (rp, rp_offset, dl)
|
||||
if ns >= 0 then
|
||||
remainder.count := dl
|
||||
else
|
||||
remainder.count := -dl
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tdiv_r_2exp (target: READABLE_INTEGER_X; op: READABLE_INTEGER_X; count: INTEGER)
|
||||
local
|
||||
in_size: INTEGER
|
||||
res_size: INTEGER
|
||||
limb_count: INTEGER
|
||||
in_ptr: SPECIAL [NATURAL_32]
|
||||
in_ptr_offset: INTEGER
|
||||
x: NATURAL_32
|
||||
do
|
||||
in_size := op.count.abs
|
||||
limb_count := count // 32
|
||||
in_ptr := op.item
|
||||
if in_size > limb_count then
|
||||
x := in_ptr [in_ptr_offset + limb_count].bit_and (((1).to_natural_32 |<< (count \\ 32)- 1))
|
||||
if x /= 0 then
|
||||
res_size := limb_count + 1
|
||||
target.resize (res_size)
|
||||
target.item [limb_count] := x
|
||||
else
|
||||
res_size := limb_count
|
||||
res_size := normalize (in_ptr, in_ptr_offset, res_size)
|
||||
target.resize (res_size)
|
||||
limb_count := res_size
|
||||
end
|
||||
else
|
||||
res_size := in_size
|
||||
target.resize (res_size)
|
||||
limb_count := res_size
|
||||
end
|
||||
if target /= op then
|
||||
target.item.copy_data (op.item, 0, 0, limb_count)
|
||||
end
|
||||
if op.count >= 0 then
|
||||
target.count := res_size
|
||||
else
|
||||
target.count := -res_size
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
note
|
||||
description: "Summary description for {INTEGER_X_FACILITIES}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "Concentrated power is not rendered harmless by the good intentions of those who create it. - Milton Friedman, Nobel prize-winning economist"
|
||||
|
||||
deferred class
|
||||
INTEGER_X_FACILITIES
|
||||
|
||||
end
|
||||
145
contrib/ise_library/math/eapml/src/facilities/integer_x_gcd.e
Normal file
145
contrib/ise_library/math/eapml/src/facilities/integer_x_gcd.e
Normal file
@@ -0,0 +1,145 @@
|
||||
note
|
||||
description: "Summary description for {INTEGER_X_GCD}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "'Need' now means wanting someone else's money. 'Greed' means wanting to keep your own. 'Compassion' is when a politician arranges the transfer. - Joseph Sobran, columnist."
|
||||
|
||||
deferred class
|
||||
INTEGER_X_GCD
|
||||
|
||||
inherit
|
||||
INTEGER_X_FACILITIES
|
||||
SPECIAL_GCD
|
||||
rename
|
||||
gcd as gcd_special
|
||||
export
|
||||
{NONE}
|
||||
all
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
gcd (g: READABLE_INTEGER_X; u: READABLE_INTEGER_X; v: READABLE_INTEGER_X)
|
||||
local
|
||||
g_zero_bits: INTEGER
|
||||
u_zero_bits: INTEGER
|
||||
v_zero_bits: INTEGER
|
||||
g_zero_limbs: INTEGER
|
||||
u_zero_limbs: INTEGER
|
||||
v_zero_limbs: INTEGER
|
||||
tp: SPECIAL [NATURAL_32]
|
||||
tp_offset: INTEGER
|
||||
up: SPECIAL [NATURAL_32]
|
||||
up_offset: INTEGER
|
||||
usize: INTEGER
|
||||
vp: SPECIAL [NATURAL_32]
|
||||
vp_offset: INTEGER
|
||||
vsize: INTEGER
|
||||
gsize: INTEGER
|
||||
junk: NATURAL_32
|
||||
cy_limb: NATURAL_32
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
up := u.item
|
||||
usize := u.count.abs
|
||||
vp := v.item
|
||||
vsize := v.count.abs
|
||||
if usize = 0 then
|
||||
g.count := vsize
|
||||
if g = v then
|
||||
else
|
||||
g.resize (vsize)
|
||||
g.item.copy_data (vp, 0, 0, vsize)
|
||||
end
|
||||
elseif vsize = 0 then
|
||||
g.count := usize
|
||||
if g = u then
|
||||
else
|
||||
g.resize (usize)
|
||||
g.item.copy_data (up, up_offset, 0, usize)
|
||||
end
|
||||
elseif usize = 1 then
|
||||
g.count := 1
|
||||
g.item [0] := gcd_1 (vp, vp_offset, vsize, up [up_offset])
|
||||
elseif vsize = 1 then
|
||||
g.count := 1
|
||||
g.item [0] := gcd_1 (up, up_offset, usize, vp [vp_offset])
|
||||
else
|
||||
from
|
||||
until
|
||||
up [up_offset] /= 0
|
||||
loop
|
||||
up_offset := up_offset + 1
|
||||
end
|
||||
u_zero_limbs := up_offset - 0
|
||||
usize := usize - u_zero_limbs
|
||||
u_zero_bits := trailing_zeros (up [up_offset])
|
||||
tp := up
|
||||
tp_offset := up_offset
|
||||
create up.make_filled (0, usize)
|
||||
if u_zero_bits /= 0 then
|
||||
rshift (up, up_offset, tp, tp_offset, usize, u_zero_bits, carry)
|
||||
junk := carry.item
|
||||
usize := usize - (up [up_offset + usize - 1] = 0).to_integer
|
||||
else
|
||||
up.copy_data (tp, tp_offset, up_offset, usize)
|
||||
end
|
||||
from
|
||||
until
|
||||
vp [vp_offset] /= 0
|
||||
loop
|
||||
vp_offset := vp_offset + 1
|
||||
end
|
||||
v_zero_limbs := vp_offset - 0
|
||||
vsize := vsize - v_zero_limbs
|
||||
v_zero_bits := trailing_zeros (vp [vp_offset])
|
||||
tp := vp
|
||||
tp_offset := vp_offset
|
||||
create vp.make_filled (0, vsize)
|
||||
if v_zero_bits /= 0 then
|
||||
rshift (vp, vp_offset, tp, tp_offset, vsize, v_zero_bits, carry)
|
||||
junk := carry.item
|
||||
vsize := vsize - (vp [vp_offset + vsize - 1] = 0).to_integer
|
||||
else
|
||||
vp.copy_data (tp, tp_offset, vp_offset, vsize)
|
||||
end
|
||||
if u_zero_limbs > v_zero_limbs then
|
||||
g_zero_limbs := v_zero_limbs
|
||||
g_zero_bits := v_zero_bits
|
||||
elseif u_zero_limbs < v_zero_limbs then
|
||||
g_zero_limbs := u_zero_limbs
|
||||
g_zero_bits := u_zero_bits
|
||||
else
|
||||
g_zero_limbs := u_zero_limbs
|
||||
g_zero_bits := u_zero_bits.min (v_zero_bits)
|
||||
end
|
||||
if usize < vsize or (usize = vsize and up [up_offset + usize - 1] < vp [vp_offset + vsize - 1]) then
|
||||
vsize := gcd_special (vp, vp_offset, vp, vp_offset, vsize, up, up_offset, usize)
|
||||
else
|
||||
vsize := gcd_special (vp, vp_offset, up, up_offset, usize, vp, vp_offset, vsize)
|
||||
end
|
||||
gsize := vsize + g_zero_limbs
|
||||
if g_zero_bits /= 0 then
|
||||
gsize := gsize + ((vp [vp_offset + vsize - 1] |>> (32 - g_zero_bits)) /= 0).to_integer
|
||||
g.resize (gsize)
|
||||
g.item.fill_with (0, 0, g_zero_limbs)
|
||||
tp := g.item
|
||||
tp_offset := g_zero_limbs
|
||||
lshift (tp, tp_offset, vp, vp_offset, vsize, g_zero_bits, carry)
|
||||
cy_limb := carry.item
|
||||
if cy_limb /= 0 then
|
||||
tp [tp_offset + vsize] := cy_limb
|
||||
end
|
||||
else
|
||||
g.resize (gsize)
|
||||
g.item.fill_with (0, 0, g_zero_limbs)
|
||||
g.item.copy_data (vp, vp_offset, g_zero_limbs, vsize)
|
||||
end
|
||||
g.count := gsize
|
||||
end
|
||||
ensure
|
||||
g.count /= 0
|
||||
end
|
||||
end
|
||||
335
contrib/ise_library/math/eapml/src/facilities/integer_x_io.e
Normal file
335
contrib/ise_library/math/eapml/src/facilities/integer_x_io.e
Normal file
@@ -0,0 +1,335 @@
|
||||
note
|
||||
description: "Summary description for {INTEGER_X_IO}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "I personally call the type of government which can be removed without violence 'democracy,' and the other, 'tyranny.' - Karl Popper"
|
||||
|
||||
deferred class
|
||||
INTEGER_X_IO
|
||||
|
||||
inherit
|
||||
INTEGER_X_FACILITIES
|
||||
SPECIAL_SIZING
|
||||
SPECIAL_UTILITY
|
||||
LIMB_MANIPULATION
|
||||
|
||||
feature
|
||||
|
||||
output (target: SPECIAL [NATURAL_8]; target_offset: INTEGER; countp: TUPLE [countp: INTEGER]; order: INTEGER; size: INTEGER; endian_a: INTEGER; z: READABLE_INTEGER_X)
|
||||
local
|
||||
zsize: INTEGER
|
||||
zp: SPECIAL [NATURAL_32]
|
||||
zp_offset: INTEGER
|
||||
count: INTEGER
|
||||
numb: INTEGER
|
||||
endian: INTEGER
|
||||
i: INTEGER
|
||||
j: INTEGER
|
||||
limb: NATURAL_32
|
||||
wbitsmask: NATURAL_32
|
||||
wbytes: INTEGER
|
||||
woffset: INTEGER
|
||||
dp: SPECIAL [NATURAL_8]
|
||||
dp_offset: INTEGER
|
||||
lbits: INTEGER
|
||||
wbits: INTEGER
|
||||
zend: INTEGER
|
||||
newlimb: NATURAL_32
|
||||
done: BOOLEAN
|
||||
do
|
||||
endian := endian_a
|
||||
zsize := z.count
|
||||
if zsize = 0 then
|
||||
countp.countp := 0
|
||||
else
|
||||
zsize := zsize.abs
|
||||
zp := z.item
|
||||
numb := 8 * size
|
||||
count := sizeinbase_2exp (zp, zp_offset, zsize, numb)
|
||||
countp.countp := count
|
||||
if endian = 0 then
|
||||
endian := -1
|
||||
end
|
||||
if size = 4 then
|
||||
if order = -1 and endian = -1 then
|
||||
from
|
||||
i := target_offset
|
||||
j := zp_offset
|
||||
until
|
||||
j >= zp_offset + count - 1
|
||||
loop
|
||||
write_limb (zp [zp_offset + j], target, target_offset + i)
|
||||
i := i + 4
|
||||
j := j + 1
|
||||
end
|
||||
done := True
|
||||
elseif order = 1 and endian = -1 then
|
||||
from
|
||||
i := target_offset
|
||||
j := zp_offset + count - 1
|
||||
until
|
||||
j < zp_offset
|
||||
loop
|
||||
write_limb (zp [zp_offset + j], target, target_offset + i)
|
||||
j := j - 1
|
||||
i := i + 4
|
||||
end
|
||||
done := True
|
||||
elseif order = -1 and endian = 1 then
|
||||
from
|
||||
i := target_offset
|
||||
j := zp_offset
|
||||
until
|
||||
j >= zp_offset + count - 1
|
||||
loop
|
||||
write_limb_be (zp [zp_offset + j], target, target_offset + i)
|
||||
j := j + 1
|
||||
i := i + 4
|
||||
end
|
||||
done := True
|
||||
elseif order = 1 and endian = 1 then
|
||||
from
|
||||
i := target_offset
|
||||
j := zp_offset + count - 1
|
||||
until
|
||||
j < zp_offset
|
||||
loop
|
||||
write_limb_be (zp [zp_offset + j], target, target_offset + i)
|
||||
j := j - 1
|
||||
i := i + 4
|
||||
end
|
||||
done := True
|
||||
end
|
||||
end
|
||||
if not done then
|
||||
numb := size * 8
|
||||
wbytes := numb // 8
|
||||
wbits := numb \\ 8
|
||||
wbitsmask := ((1).to_natural_8 |<< wbits) - 1
|
||||
if endian >= 0 then
|
||||
woffset := size
|
||||
else
|
||||
woffset := -size
|
||||
end
|
||||
if order < 0 then
|
||||
woffset := woffset + size
|
||||
else
|
||||
woffset := woffset + -size
|
||||
end
|
||||
dp := target
|
||||
dp_offset := target_offset
|
||||
if order >= 0 then
|
||||
dp_offset := dp_offset + (count - 1) * size
|
||||
else
|
||||
dp_offset := dp_offset + 0
|
||||
end
|
||||
if endian >= 0 then
|
||||
dp_offset := dp_offset + size - 1
|
||||
else
|
||||
dp_offset := dp_offset + 0
|
||||
end
|
||||
zend := zp_offset + zsize
|
||||
lbits := 0
|
||||
limb := 0
|
||||
from
|
||||
i := 0
|
||||
until
|
||||
i >= count
|
||||
loop
|
||||
from
|
||||
j := 0
|
||||
until
|
||||
j >= wbytes
|
||||
loop
|
||||
if lbits >= 8 then
|
||||
dp [dp_offset] := limb.to_natural_8
|
||||
limb := limb |>> 8
|
||||
lbits := lbits - 8
|
||||
else
|
||||
if zp_offset = zend then
|
||||
newlimb := 0
|
||||
else
|
||||
newlimb := zp [zp_offset]
|
||||
zp_offset := zp_offset + 1
|
||||
end
|
||||
dp [dp_offset] := (limb.bit_or (newlimb |<< lbits)).to_natural_8
|
||||
limb := newlimb |>> (8 - lbits)
|
||||
lbits := lbits + limb_bits - 8
|
||||
end
|
||||
dp_offset := dp_offset - endian
|
||||
j := j + 1
|
||||
end
|
||||
if wbits /= 0 then
|
||||
if lbits >= wbits then
|
||||
dp [dp_offset] := limb.bit_and (wbitsmask).to_natural_8
|
||||
limb := limb |>> wbits
|
||||
lbits := lbits - wbits
|
||||
else
|
||||
if zp_offset = zend then
|
||||
newlimb := 0
|
||||
else
|
||||
newlimb := zp [zp_offset]
|
||||
zp_offset := zp_offset + 1
|
||||
end
|
||||
dp [dp_offset] := (limb.bit_or (newlimb |<< lbits)).bit_and (wbitsmask).to_natural_8
|
||||
limb := newlimb |>> (wbits - lbits)
|
||||
lbits := lbits + limb_bits - wbits
|
||||
end
|
||||
end
|
||||
from
|
||||
until
|
||||
j >= size
|
||||
loop
|
||||
dp [dp_offset] := 0
|
||||
dp_offset := dp_offset - endian
|
||||
j := j + 1
|
||||
end
|
||||
dp_offset := dp_offset + woffset
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
input (z: READABLE_INTEGER_X; count: INTEGER; order: INTEGER; size: INTEGER; endian_a: INTEGER; source: SPECIAL [NATURAL_8]; source_offset: INTEGER)
|
||||
local
|
||||
zsize: INTEGER
|
||||
zp: SPECIAL [NATURAL_32]
|
||||
zp_offset: INTEGER
|
||||
i: INTEGER
|
||||
j: INTEGER
|
||||
done: BOOLEAN
|
||||
limb: NATURAL_32
|
||||
byte: NATURAL_32
|
||||
wbitsmask: NATURAL_8
|
||||
numb: INTEGER
|
||||
wbytes: INTEGER
|
||||
woffset: INTEGER
|
||||
dp: SPECIAL [NATURAL_8]
|
||||
dp_offset: INTEGER
|
||||
lbits: INTEGER
|
||||
wbits: INTEGER
|
||||
endian: INTEGER
|
||||
do
|
||||
endian := endian_a
|
||||
zsize := (count * (8 * size) + limb_bits - 1) // limb_bits
|
||||
z.resize (zsize)
|
||||
zp := z.item
|
||||
if endian = 0 then
|
||||
endian := -1
|
||||
end
|
||||
if order = -1 and size = 4 and endian = -1 then
|
||||
from
|
||||
i := zp_offset
|
||||
j := source_offset
|
||||
until
|
||||
i >= count + zp_offset - 1
|
||||
loop
|
||||
zp [zp_offset + i] := read_limb (source, source_offset + j)
|
||||
j := j + 4
|
||||
i := i + 1
|
||||
end
|
||||
done := True
|
||||
elseif order = -1 and size = 4 and endian = 1 then
|
||||
from
|
||||
i := zp_offset
|
||||
j := source_offset
|
||||
until
|
||||
i >= count + zp_offset - 1
|
||||
loop
|
||||
zp [zp_offset + i] := read_limb_be (source, source_offset + j)
|
||||
j := j + 4
|
||||
i := i + 1
|
||||
end
|
||||
done := True
|
||||
elseif order = 1 and size = 4 and endian = -1 then
|
||||
from
|
||||
i := zp_offset + count - 1
|
||||
j := source_offset
|
||||
until
|
||||
i < zp_offset
|
||||
loop
|
||||
zp [zp_offset + i] := read_limb (source, source_offset + j)
|
||||
j := j + 4
|
||||
i := i - 1
|
||||
end
|
||||
done := True
|
||||
end
|
||||
if not done then
|
||||
numb := size * 8
|
||||
wbytes := numb // 8
|
||||
wbits := numb \\ 8
|
||||
wbitsmask := ((1).to_natural_8 |<< wbits) - 1
|
||||
woffset := (numb + 7) // 8
|
||||
if endian >= 0 then
|
||||
woffset := woffset
|
||||
else
|
||||
woffset := -woffset
|
||||
end
|
||||
if order < 0 then
|
||||
woffset := woffset + size
|
||||
else
|
||||
woffset := woffset + -size
|
||||
end
|
||||
dp := source
|
||||
dp_offset := source_offset
|
||||
if order >= 0 then
|
||||
dp_offset := dp_offset + (count - 1) * size
|
||||
else
|
||||
dp_offset := dp_offset + 0
|
||||
end
|
||||
if endian >= 0 then
|
||||
dp_offset := dp_offset + size - 1
|
||||
else
|
||||
dp_offset := dp_offset + 0
|
||||
end
|
||||
limb := 0
|
||||
lbits := 0
|
||||
from
|
||||
i := 0
|
||||
until
|
||||
i >= count
|
||||
loop
|
||||
from
|
||||
j := 0
|
||||
until
|
||||
j >= wbytes
|
||||
loop
|
||||
byte := dp [dp_offset]
|
||||
dp_offset := dp_offset - endian
|
||||
limb := limb.bit_or (byte |<< lbits)
|
||||
lbits := lbits + 8
|
||||
if lbits >= limb_bits then
|
||||
zp [zp_offset] := limb
|
||||
zp_offset := zp_offset + 1
|
||||
lbits := lbits - limb_bits
|
||||
limb := byte |>> (8 - lbits)
|
||||
end
|
||||
j := j + 1
|
||||
end
|
||||
if wbits /= 0 then
|
||||
byte := dp [dp_offset].bit_and (wbitsmask)
|
||||
dp_offset := dp_offset - endian
|
||||
limb := limb.bit_or (byte |<< lbits)
|
||||
lbits := lbits + wbits
|
||||
if lbits >= limb_bits then
|
||||
zp [zp_offset] := limb
|
||||
zp_offset := zp_offset + 1
|
||||
lbits := lbits - limb_bits
|
||||
limb := byte |>> (wbits - lbits)
|
||||
end
|
||||
end
|
||||
dp_offset := dp_offset + woffset
|
||||
i := i + 1
|
||||
end
|
||||
if lbits /= 0 then
|
||||
zp [zp_offset] := limb
|
||||
zp_offset := zp_offset + 1
|
||||
end
|
||||
end
|
||||
zp := z.item
|
||||
zsize := normalize (zp, 0, zsize)
|
||||
z.count := zsize
|
||||
end
|
||||
end
|
||||
1037
contrib/ise_library/math/eapml/src/facilities/integer_x_logic.e
Normal file
1037
contrib/ise_library/math/eapml/src/facilities/integer_x_logic.e
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,967 @@
|
||||
note
|
||||
description: "Summary description for {INTEGER_X_NUMBER_THEORY}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "Gun registration is a gateway drug. - Mark Gilmore"
|
||||
|
||||
deferred class
|
||||
INTEGER_X_NUMBER_THEORY
|
||||
|
||||
inherit
|
||||
INTEGER_X_FACILITIES
|
||||
SPECIAL_ARITHMETIC
|
||||
rename
|
||||
add as add_special,
|
||||
sub as sub_special,
|
||||
mul as mul_special,
|
||||
bit_xor_lshift as bit_xor_lshift_special,
|
||||
bit_xor as bit_xor_special
|
||||
export
|
||||
{NONE}
|
||||
all
|
||||
end
|
||||
SPECIAL_DIVISION
|
||||
rename
|
||||
add as add_special,
|
||||
sub as sub_special,
|
||||
mul as mul_special,
|
||||
cmp as cmp_special,
|
||||
tdiv_qr as tdiv_qr_special,
|
||||
bit_xor_lshift as bit_xor_lshift_special,
|
||||
bit_xor as bit_xor_special
|
||||
export
|
||||
{NONE}
|
||||
all
|
||||
end
|
||||
SPECIAL_NUMBER_THEORETIC
|
||||
rename
|
||||
add as add_special,
|
||||
sub as sub_special,
|
||||
mul as mul_special,
|
||||
cmp as cmp_special,
|
||||
tdiv_qr as tdiv_qr_special,
|
||||
gcdext as gcdext_special,
|
||||
bit_xor_lshift as bit_xor_lshift_special,
|
||||
bit_xor as bit_xor_special,
|
||||
invert_gf as invert_gf_special
|
||||
export
|
||||
{NONE}
|
||||
all
|
||||
end
|
||||
INTEGER_X_ACCESS
|
||||
rename
|
||||
add as add_special,
|
||||
sub as sub_special,
|
||||
mul as mul_special,
|
||||
cmp as cmp_special,
|
||||
tdiv_qr as tdiv_qr_special,
|
||||
sizeinbase as sizeinbase_special,
|
||||
bit_xor_lshift as bit_xor_lshift_special,
|
||||
bit_xor as bit_xor_special
|
||||
end
|
||||
INTEGER_X_ARITHMETIC
|
||||
rename
|
||||
cmp as cmp_special,
|
||||
bit_xor_lshift as bit_xor_lshift_special,
|
||||
bit_xor as bit_xor_special
|
||||
end
|
||||
INTEGER_X_ASSIGNMENT
|
||||
rename
|
||||
add as add_special,
|
||||
sub as sub_special,
|
||||
mul as mul_special,
|
||||
bit_xor_lshift as bit_xor_lshift_special,
|
||||
bit_xor as bit_xor_special
|
||||
end
|
||||
INTEGER_X_COMPARISON
|
||||
INTEGER_X_LOGIC
|
||||
rename
|
||||
add as add_special,
|
||||
sub as sub_special,
|
||||
mul as mul_special
|
||||
end
|
||||
INTEGER_X_DIVISION
|
||||
rename
|
||||
cmp as cmp_special,
|
||||
bit_xor_lshift as bit_xor_lshift_special,
|
||||
bit_xor as bit_xor_special
|
||||
end
|
||||
INTEGER_X_RANDOM
|
||||
rename
|
||||
add as add_special,
|
||||
sub as sub_special,
|
||||
mul as mul_special,
|
||||
cmp as cmp_special,
|
||||
bit_xor_lshift as bit_xor_lshift_special,
|
||||
bit_xor as bit_xor_special
|
||||
end
|
||||
INTEGER_X_GCD
|
||||
rename
|
||||
add as add_special,
|
||||
sub as sub_special,
|
||||
mul as mul_special,
|
||||
cmp as cmp_special,
|
||||
tdiv_qr as tdiv_qr_special,
|
||||
bit_xor_lshift as bit_xor_lshift_special,
|
||||
bit_xor as bit_xor_special
|
||||
end
|
||||
INTEGER_X_SIZING
|
||||
|
||||
feature
|
||||
|
||||
millerrabin_test (n: READABLE_INTEGER_X; nm1: READABLE_INTEGER_X; x: READABLE_INTEGER_X; y: READABLE_INTEGER_X; q: READABLE_INTEGER_X; k: INTEGER): INTEGER
|
||||
local
|
||||
i: INTEGER
|
||||
do
|
||||
powm (y, x, q, n)
|
||||
if cmp_ui (y, 1) = 0 or compare (y, nm1) = 0 then
|
||||
Result := 1
|
||||
else
|
||||
from
|
||||
i := 1
|
||||
Result := -1
|
||||
until
|
||||
Result /= -1 or i >= k
|
||||
loop
|
||||
powm_ui (y, y, 2, n)
|
||||
if compare (y, nm1) = 0 then
|
||||
Result := 1
|
||||
elseif cmp_ui (y, 1) = 0 then
|
||||
Result := 0
|
||||
end
|
||||
i := i + 1
|
||||
end
|
||||
if Result = -1 then
|
||||
Result := 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
bin_uiui (target: READABLE_INTEGER_X; n_a: NATURAL_32; k_a: NATURAL_32)
|
||||
-- Compute the binomial coefficient `n' over `k' and store the result in `rop'.
|
||||
local
|
||||
i: NATURAL_32
|
||||
j: NATURAL_32
|
||||
cnt: NATURAL_32
|
||||
n1: CELL [NATURAL_32]
|
||||
n0: CELL [NATURAL_32]
|
||||
k0: NATURAL_32
|
||||
-- t: NATURAL_64
|
||||
k: NATURAL_32
|
||||
n: NATURAL_32
|
||||
rsize: CELL [INTEGER]
|
||||
ralloc: CELL [INTEGER]
|
||||
nacc: CELL [NATURAL_32]
|
||||
kacc: CELL [NATURAL_32]
|
||||
do
|
||||
create n0.put (0)
|
||||
create n1.put (0)
|
||||
create rsize.put (0)
|
||||
create ralloc.put (0)
|
||||
create nacc.put (0)
|
||||
create kacc.put (0)
|
||||
n := n_a
|
||||
k := k_a
|
||||
if n < k then
|
||||
target.count := 0
|
||||
else
|
||||
k := k.min (n - k)
|
||||
if k = 0 then
|
||||
target.count := 1
|
||||
target.item [0] := 1
|
||||
else
|
||||
j := n - k + 1
|
||||
target.item [0] := j
|
||||
target.count := 1
|
||||
ralloc.put (target.capacity)
|
||||
nacc.put (1)
|
||||
kacc.put (1)
|
||||
cnt := 0
|
||||
from
|
||||
i := 2
|
||||
until
|
||||
i > k
|
||||
loop
|
||||
j := j + 1
|
||||
cnt := nacc.item.bit_or (kacc.item).bit_and (1).bit_xor (1)
|
||||
nacc.put (nacc.item |>> cnt.to_integer_32)
|
||||
kacc.put (kacc.item |>> cnt.to_integer_32)
|
||||
umul_ppmm (n1, n0, nacc.item, j)
|
||||
k0 := kacc.item * i
|
||||
if n1.item /= 0 then
|
||||
muldiv (target, 32, rsize, ralloc, nacc, kacc)
|
||||
nacc.put (j)
|
||||
kacc.put (i)
|
||||
else
|
||||
nacc.put (n0.item)
|
||||
kacc.put (k0)
|
||||
end
|
||||
i := i + 1
|
||||
end
|
||||
muldiv (target, 1, rsize, ralloc, nacc, kacc)
|
||||
target.count := rsize.item
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
gcdext (g: READABLE_INTEGER_X; s: detachable READABLE_INTEGER_X; t: detachable READABLE_INTEGER_X; a: READABLE_INTEGER_X; b: READABLE_INTEGER_X)
|
||||
-- Set `g' to the greatest common divisor of `a' and `b', and in addition set `s' and `t' to
|
||||
-- coefficients satisfying `a*s + b*t = g'.
|
||||
-- `g' is always positive, even if one or both of `a' and `b' are negative.
|
||||
-- If `t' is NULL then that value is not computed.
|
||||
local
|
||||
asize: INTEGER
|
||||
bsize: INTEGER
|
||||
usize: INTEGER
|
||||
vsize: INTEGER
|
||||
ap: SPECIAL [NATURAL_32]
|
||||
ap_offset: INTEGER
|
||||
bp: SPECIAL [NATURAL_32]
|
||||
bp_offset: INTEGER
|
||||
up: SPECIAL [NATURAL_32]
|
||||
up_offset: INTEGER
|
||||
vp: SPECIAL [NATURAL_32]
|
||||
vp_offset: INTEGER
|
||||
gsize: INTEGER
|
||||
ssize: INTEGER
|
||||
tmp_ssize: TUPLE [tmp_ssize: INTEGER]
|
||||
gp: SPECIAL [NATURAL_32]
|
||||
sp: SPECIAL [NATURAL_32]
|
||||
tmp_gp: SPECIAL [NATURAL_32]
|
||||
tmp_gp_offset: INTEGER
|
||||
tmp_sp: SPECIAL [NATURAL_32]
|
||||
tmp_sp_offset: INTEGER
|
||||
u: READABLE_INTEGER_X
|
||||
v: READABLE_INTEGER_X
|
||||
ss: detachable READABLE_INTEGER_X
|
||||
tt: detachable READABLE_INTEGER_X
|
||||
gtmp: INTEGER_X
|
||||
stmp: INTEGER_X
|
||||
x: INTEGER_X
|
||||
do
|
||||
create tmp_ssize
|
||||
asize := a.count.abs
|
||||
bsize := b.count.abs
|
||||
ap := a.item
|
||||
bp := b.item
|
||||
if asize > bsize or (asize = bsize and cmp_special (ap, ap_offset, bp, bp_offset, asize) > 0) then
|
||||
usize := asize
|
||||
vsize := bsize
|
||||
create up.make_filled (0, usize + 1)
|
||||
create vp.make_filled (0, vsize + 1)
|
||||
up.copy_data (ap, ap_offset, up_offset, usize)
|
||||
vp.copy_data (bp, bp_offset, vp_offset, vsize)
|
||||
u := a
|
||||
v := b
|
||||
ss := s
|
||||
tt := t
|
||||
else
|
||||
usize := bsize
|
||||
vsize := asize
|
||||
create up.make_filled (0, usize + 1)
|
||||
create vp.make_filled (0, vsize + 1)
|
||||
up.copy_data (bp, bp_offset, up_offset, usize)
|
||||
vp.copy_data (ap, ap_offset, vp_offset, vsize)
|
||||
u := b
|
||||
v := a
|
||||
ss := t
|
||||
tt := s
|
||||
end
|
||||
create tmp_gp.make_filled (0, usize + 1)
|
||||
create tmp_sp.make_filled (0, usize + 1)
|
||||
if vsize = 0 then
|
||||
tmp_sp [tmp_sp_offset] := 1
|
||||
tmp_ssize.tmp_ssize := 1
|
||||
tmp_gp.copy_data (up, up_offset, tmp_gp_offset, usize)
|
||||
gsize := usize
|
||||
else
|
||||
gsize := gcdext_special (tmp_gp, tmp_gp_offset, tmp_sp, tmp_sp_offset, tmp_ssize, up, up_offset, usize, vp, vp_offset, vsize)
|
||||
end
|
||||
ssize := tmp_ssize.tmp_ssize.abs
|
||||
create gtmp
|
||||
gtmp.item := tmp_gp
|
||||
gtmp.count := gsize
|
||||
create stmp
|
||||
stmp.item := tmp_sp
|
||||
if tmp_ssize.tmp_ssize.bit_xor (u.count) >= 0 then
|
||||
stmp.count := ssize
|
||||
else
|
||||
stmp.count := -ssize
|
||||
end
|
||||
if attached {READABLE_INTEGER_X} tt as tt_l then
|
||||
if v.count = 0 then
|
||||
tt_l.count := 0
|
||||
else
|
||||
create x.make_limbs (ssize + usize + 1)
|
||||
mul (x, stmp, u)
|
||||
sub (x, gtmp, x)
|
||||
tdiv_q (tt_l, x, v)
|
||||
end
|
||||
end
|
||||
if attached {READABLE_INTEGER_X} ss as ss_l then
|
||||
ss_l.resize (ssize)
|
||||
sp := ss_l.item
|
||||
sp.copy_data (tmp_sp, tmp_sp_offset, 0, ssize)
|
||||
ss_l.count := stmp.count
|
||||
end
|
||||
g.resize (gsize)
|
||||
gp := g.item
|
||||
gp.copy_data (tmp_gp, tmp_gp_offset, 0, gsize)
|
||||
g.count := gsize
|
||||
end
|
||||
|
||||
invert (target: READABLE_INTEGER_X; x: READABLE_INTEGER_X; n: READABLE_INTEGER_X): BOOLEAN
|
||||
local
|
||||
gcd_l: INTEGER_X
|
||||
tmp: INTEGER_X
|
||||
xsize: INTEGER_32
|
||||
nsize: INTEGER_32
|
||||
size: INTEGER_32
|
||||
do
|
||||
xsize := x.count.abs
|
||||
nsize := n.count.abs
|
||||
size := xsize.max (nsize) + 1
|
||||
if xsize = 0 or (nsize = 1 and n.item [0] = 1) then
|
||||
Result := False
|
||||
else
|
||||
create gcd_l.make_limbs (size)
|
||||
create tmp.make_limbs (size)
|
||||
gcdext (gcd_l, tmp, void, x, n)
|
||||
if gcd_l.count /= 1 or gcd_l.item [0] /= 1 then
|
||||
Result := False
|
||||
else
|
||||
if tmp.count < 0 then
|
||||
if n.count < 0 then
|
||||
sub (target, tmp, n)
|
||||
else
|
||||
add (target, tmp, n)
|
||||
end
|
||||
else
|
||||
target.copy (tmp)
|
||||
end
|
||||
Result := True
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
millerrabin (source: READABLE_INTEGER_X; reps: INTEGER): INTEGER
|
||||
local
|
||||
r: INTEGER
|
||||
nm1: INTEGER_X
|
||||
nm3: INTEGER_X
|
||||
x: INTEGER_X
|
||||
y: INTEGER_X
|
||||
q: INTEGER_X
|
||||
k: INTEGER
|
||||
is_prime: INTEGER
|
||||
rstate: MERSENNE_TWISTER_RNG
|
||||
do
|
||||
create nm1.make_limbs (source.count + 1)
|
||||
sub_ui (nm1, source, 1)
|
||||
create x.make_limbs (source.count + 1)
|
||||
create y.make_limbs (2 * source.count)
|
||||
x.set_from_natural_32 (210)
|
||||
powm (y, x, nm1, source)
|
||||
if cmp_ui (y, 1) /= 0 then
|
||||
Result := 0
|
||||
else
|
||||
create q.make_limbs (source.count)
|
||||
k := bit_scan_1 (nm1, 0)
|
||||
tdiv_q_2exp (q, nm1, k)
|
||||
create nm3.make_limbs (source.count + 1)
|
||||
sub_ui (nm3, source, 3)
|
||||
create rstate.make
|
||||
is_prime := 1
|
||||
from
|
||||
r := 0
|
||||
until
|
||||
r >= reps or is_prime = 0
|
||||
loop
|
||||
urandomm (x, rstate, nm3)
|
||||
add_ui (x, x, 2)
|
||||
is_prime := millerrabin_test (source, nm1, x, y, q, k)
|
||||
r := r + 1
|
||||
end
|
||||
Result := is_prime
|
||||
end
|
||||
end
|
||||
|
||||
powm (r: READABLE_INTEGER_X; b_a: READABLE_INTEGER_X; e: READABLE_INTEGER_X; m: READABLE_INTEGER_X)
|
||||
local
|
||||
xp: SPECIAL [NATURAL_32]
|
||||
xp_offset: INTEGER
|
||||
tp: SPECIAL [NATURAL_32]
|
||||
tp_offset: INTEGER
|
||||
qp: SPECIAL [NATURAL_32]
|
||||
qp_offset: INTEGER
|
||||
gp: SPECIAL [NATURAL_32]
|
||||
gp_offset: INTEGER
|
||||
this_gp: SPECIAL [NATURAL_32]
|
||||
this_gp_offset: INTEGER
|
||||
bp: SPECIAL [NATURAL_32]
|
||||
bp_offset: INTEGER
|
||||
ep: SPECIAL [NATURAL_32]
|
||||
ep_offset: INTEGER
|
||||
mp: SPECIAL [NATURAL_32]
|
||||
mp_offset: INTEGER
|
||||
bn: INTEGER
|
||||
es: INTEGER
|
||||
en: INTEGER
|
||||
mn: INTEGER
|
||||
xn: INTEGER
|
||||
invm: NATURAL_32
|
||||
c: NATURAL_32
|
||||
enb: INTEGER
|
||||
i: INTEGER
|
||||
big_k: INTEGER
|
||||
j: INTEGER
|
||||
l: INTEGER
|
||||
small_k: INTEGER
|
||||
m_zero_cnt: INTEGER
|
||||
e_zero_cnt: INTEGER
|
||||
sh: INTEGER
|
||||
use_redc: BOOLEAN
|
||||
new_b: INTEGER_X
|
||||
b: READABLE_INTEGER_X
|
||||
new_mp: SPECIAL [NATURAL_32]
|
||||
new_mp_offset: INTEGER
|
||||
junk: NATURAL_32
|
||||
cy: NATURAL_32
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
b := b_a
|
||||
mp := m.item
|
||||
mn := m.count.abs
|
||||
if mn = 0 then
|
||||
(create {DIVIDE_BY_ZERO}).raise
|
||||
end
|
||||
es := e.count
|
||||
if es = 0 then
|
||||
if mn = 1 and mp [mp_offset] = 1 then
|
||||
r.count := 0
|
||||
else
|
||||
r.count := 1
|
||||
end
|
||||
r.item [0] := 1
|
||||
else
|
||||
if es < 0 then
|
||||
create new_b.make_limbs (mn + 1)
|
||||
if not invert (new_b, b, m) then
|
||||
(create {INVERSE_EXCEPTION}).raise
|
||||
end
|
||||
b := new_b
|
||||
es := -es
|
||||
end
|
||||
en := es
|
||||
use_redc := (mn < 170) and (mp [mp_offset] \\ 2 /= 0)
|
||||
if use_redc then
|
||||
invm := modlimb_invert (mp [mp_offset])
|
||||
invm := 0 - invm
|
||||
else
|
||||
m_zero_cnt := leading_zeros (mp [mp_offset + mn - 1])
|
||||
if m_zero_cnt /= 0 then
|
||||
create new_mp.make_filled (0, mn)
|
||||
lshift (new_mp, new_mp_offset, mp, mp_offset, mn, m_zero_cnt, carry)
|
||||
junk := carry.item
|
||||
mp := new_mp
|
||||
mp_offset := new_mp_offset
|
||||
end
|
||||
end
|
||||
e_zero_cnt := leading_zeros (e.item [en - 1])
|
||||
enb := en * limb_bits - e_zero_cnt
|
||||
small_k := 1
|
||||
big_k := 2
|
||||
from
|
||||
until
|
||||
small_k = 10 or 2 * enb <= big_k * (2 + small_k * (3 + small_k))
|
||||
loop
|
||||
small_k := small_k + 1
|
||||
big_k := big_k * 2
|
||||
end
|
||||
create tp.make_filled (0, 2 * mn)
|
||||
create qp.make_filled (0, mn + 1)
|
||||
create gp.make_filled (0, big_k // 2 * mn)
|
||||
bn := b.count.abs
|
||||
bp := b.item
|
||||
if bn > mn or (bn = mn and cmp_special (bp, bp_offset, mp, mp_offset, mn) >= 0) then
|
||||
if use_redc then
|
||||
reduce (tp, tp_offset + mn, bp, bp_offset, bn, mp, mp_offset, mn)
|
||||
tp.fill_with (0, tp_offset, mn - tp_offset - 1)
|
||||
tdiv_qr_special (qp, qp_offset, gp, gp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
|
||||
else
|
||||
reduce (gp, gp_offset, bp, bp_offset, bn, mp, mp_offset, mn)
|
||||
end
|
||||
else
|
||||
if use_redc then
|
||||
tp.copy_data (bp, bp_offset, tp_offset + mn, bn)
|
||||
tdiv_qr_special (qp, qp_offset, gp, gp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
|
||||
else
|
||||
gp.copy_data (bp, bp_offset, gp_offset, bn)
|
||||
gp.fill_with (0, gp_offset + bn, mn - bn - gp_offset - 1)
|
||||
end
|
||||
end
|
||||
create xp.make_filled (0, mn)
|
||||
sqr_n (tp, tp_offset, gp, gp_offset, mn)
|
||||
if use_redc then
|
||||
redc_basecase (xp, xp_offset, mp, mp_offset, mn, invm, tp, tp_offset)
|
||||
else
|
||||
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
|
||||
end
|
||||
this_gp := gp
|
||||
this_gp_offset := gp_offset
|
||||
from
|
||||
i := 1
|
||||
until
|
||||
i >= big_k // 2
|
||||
loop
|
||||
mul_n (tp, tp_offset, this_gp, this_gp_offset, xp, xp_offset, mn)
|
||||
this_gp_offset := this_gp_offset + mn
|
||||
if use_redc then
|
||||
redc_basecase (this_gp, this_gp_offset, mp, mp_offset, mn, invm, tp, tp_offset)
|
||||
else
|
||||
tdiv_qr_special (qp, qp_offset, this_gp, this_gp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
|
||||
end
|
||||
i := i + 1
|
||||
end
|
||||
ep := e.item
|
||||
i := en - 1
|
||||
c := ep [ep_offset + i]
|
||||
sh := limb_bits - e_zero_cnt
|
||||
sh := sh - small_k
|
||||
if sh < 0 then
|
||||
if i > 0 then
|
||||
i := i - 1
|
||||
c := c |<< (-sh)
|
||||
sh := sh + limb_bits
|
||||
c := c.bit_or (ep [ep_offset + i] |>> sh)
|
||||
end
|
||||
else
|
||||
c := c |>> sh
|
||||
end
|
||||
from
|
||||
j := 0
|
||||
until
|
||||
c \\ 2 /= 0
|
||||
loop
|
||||
c := c |>> 1
|
||||
j := j + 1
|
||||
end
|
||||
xp.copy_data (gp, gp_offset + mn * (c |>> 1).to_integer_32, xp_offset, mn)
|
||||
from
|
||||
j := j - 1
|
||||
until
|
||||
j < 0
|
||||
loop
|
||||
sqr_n (tp, tp_offset, xp, xp_offset, mn)
|
||||
if use_redc then
|
||||
redc_basecase (xp, xp_offset, mp, mp_offset, mn, invm, tp, tp_offset)
|
||||
else
|
||||
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
|
||||
end
|
||||
j := j - 1
|
||||
end
|
||||
from
|
||||
until
|
||||
i <= 0 and sh <= 0
|
||||
loop
|
||||
c := ep [ep_offset + i]
|
||||
l := small_k
|
||||
sh := sh - l
|
||||
if sh < 0 then
|
||||
if i > 0 then
|
||||
i := i - 1
|
||||
c := c |<< (-sh)
|
||||
sh := sh + limb_bits
|
||||
c := c.bit_or (ep [ep_offset + i] |>> sh)
|
||||
else
|
||||
l := l + sh
|
||||
end
|
||||
else
|
||||
c := c |>> sh
|
||||
end
|
||||
c := c.bit_and (((1).to_natural_32 |<< l) - 1)
|
||||
from
|
||||
until
|
||||
(c |>> (l - 1)) /= 0 or (i <= 0 and sh <= 0)
|
||||
loop
|
||||
sqr_n (tp, tp_offset, xp, xp_offset, mn)
|
||||
if use_redc then
|
||||
redc_basecase (xp, xp_offset, mp, mp_offset, mn, invm, tp, tp_offset)
|
||||
else
|
||||
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
|
||||
end
|
||||
if sh /= 0 then
|
||||
sh := sh - 1
|
||||
c := (c |<< 1) + ((ep [ep_offset + i] |>> sh).bit_and (1))
|
||||
else
|
||||
i := i - 1
|
||||
sh := limb_bits - 1
|
||||
c := (c |<< 1) + (ep [ep_offset + i] |>> sh)
|
||||
end
|
||||
end
|
||||
if c /= 0 then
|
||||
from
|
||||
j := 0
|
||||
until
|
||||
c \\ 2 /= 0
|
||||
loop
|
||||
c := c |>> 1
|
||||
j := j + 1
|
||||
end
|
||||
l := l - j
|
||||
from
|
||||
l := l - 1
|
||||
until
|
||||
l < 0
|
||||
loop
|
||||
sqr_n (tp, tp_offset, xp, xp_offset, mn)
|
||||
if use_redc then
|
||||
redc_basecase (xp, xp_offset, mp, mp_offset, mn, invm, tp, tp_offset)
|
||||
else
|
||||
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
|
||||
end
|
||||
l := l - 1
|
||||
end
|
||||
mul_n (tp, tp_offset, xp, xp_offset, gp, gp_offset + mn * (c |>> 1).to_integer_32, mn)
|
||||
if use_redc then
|
||||
redc_basecase (xp, xp_offset, mp, mp_offset, mn, invm, tp, tp_offset)
|
||||
else
|
||||
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
|
||||
end
|
||||
else
|
||||
j := l
|
||||
end
|
||||
from
|
||||
j := j - 1
|
||||
until
|
||||
j < 0
|
||||
loop
|
||||
sqr_n (tp, tp_offset, xp, xp_offset, mn)
|
||||
if use_redc then
|
||||
redc_basecase (xp, xp_offset, mp, mp_offset, mn, invm, tp, tp_offset)
|
||||
else
|
||||
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
|
||||
end
|
||||
j := j - 1
|
||||
end
|
||||
end
|
||||
if use_redc then
|
||||
tp.copy_data (xp, xp_offset, tp_offset, mn)
|
||||
tp.fill_with (0, tp_offset + mn, tp_offset + mn + mn - 1)
|
||||
redc_basecase (xp, xp_offset, mp, mp_offset, mn, invm, tp, tp_offset)
|
||||
if cmp_special (xp, xp_offset, mp, mp_offset, mn) >= 0 then
|
||||
sub_n (xp, xp_offset, xp, xp_offset, mp, mp_offset, mn, carry)
|
||||
junk := carry.item
|
||||
end
|
||||
else
|
||||
if m_zero_cnt /= 0 then
|
||||
lshift (tp, tp_offset, xp, xp_offset, mn, m_zero_cnt, carry)
|
||||
cy := carry.item
|
||||
tp [tp_offset + mn] := cy
|
||||
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, mn + (cy /= 0).to_integer, mp, mp_offset, mn)
|
||||
rshift (xp, xp_offset, xp, xp_offset, mn, m_zero_cnt, carry)
|
||||
junk := carry.item
|
||||
end
|
||||
end
|
||||
xn := mn
|
||||
xn := normalize (xp, xp_offset, xn)
|
||||
if ep [ep_offset].bit_and (1) /= 0 and b.count < 0 and xn /= 0 then
|
||||
mp := m.item
|
||||
sub_special (xp, xp_offset, mp, mp_offset, mn, xp, xp_offset, xn, carry)
|
||||
junk := carry.item
|
||||
xn := mn
|
||||
xn := normalize (xp, xp_offset, xn)
|
||||
end
|
||||
r.resize (xn)
|
||||
r.count := xn
|
||||
r.item.copy_data (xp, xp_offset, 0, xn)
|
||||
end
|
||||
end
|
||||
|
||||
powm_ui (target: READABLE_INTEGER_X; b: READABLE_INTEGER_X; el: NATURAL_32; m: READABLE_INTEGER_X)
|
||||
local
|
||||
xp: SPECIAL [NATURAL_32]
|
||||
xp_offset: INTEGER
|
||||
tp: SPECIAL [NATURAL_32]
|
||||
tp_offset: INTEGER
|
||||
qp: SPECIAL [NATURAL_32]
|
||||
qp_offset: INTEGER
|
||||
mp: SPECIAL [NATURAL_32]
|
||||
mp_offset: INTEGER
|
||||
bp: SPECIAL [NATURAL_32]
|
||||
bp_offset: INTEGER
|
||||
xn: INTEGER
|
||||
tn: INTEGER
|
||||
mn: INTEGER
|
||||
bn: INTEGER
|
||||
m_zero_count: INTEGER
|
||||
c: INTEGER
|
||||
e: NATURAL_32
|
||||
new_mp: SPECIAL [NATURAL_32]
|
||||
junk: NATURAL_32
|
||||
new_bp: SPECIAL [NATURAL_32]
|
||||
cy: NATURAL_32
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
mp := m.item
|
||||
mn := m.count.abs
|
||||
if mn = 0 then
|
||||
(create {DIVIDE_BY_ZERO}).raise
|
||||
end
|
||||
if el = 0 then
|
||||
target.count := (not (mn = 1 and then mp [mp_offset] = 1)).to_integer
|
||||
target.item [0] := 1
|
||||
else
|
||||
m_zero_count := leading_zeros (mp [mp_offset + mn - 1])
|
||||
if m_zero_count /= 0 then
|
||||
create new_mp.make_filled (0, mn)
|
||||
lshift (new_mp, 0, mp, mp_offset, mn, m_zero_count, carry)
|
||||
junk := carry.item
|
||||
mp := new_mp
|
||||
end
|
||||
bn := b.count.abs
|
||||
bp := b.item
|
||||
if bn > mn then
|
||||
create new_bp.make_filled (0, mn)
|
||||
reduce (new_bp, 0, bp, bp_offset, bn, mp, mp_offset, mn)
|
||||
bp := new_bp
|
||||
bn := mn
|
||||
bn := normalize (bp, 0, bn)
|
||||
end
|
||||
if bn = 0 then
|
||||
target.count := 0
|
||||
else
|
||||
create tp.make_filled (0, 2 * mn + 1)
|
||||
create xp.make_filled (0, mn)
|
||||
create qp.make_filled (0, mn + 1)
|
||||
xp.copy_data (bp, bp_offset, xp_offset, bn)
|
||||
xn := bn
|
||||
e := el
|
||||
c := leading_zeros (e)
|
||||
e := (e |<< c) |<< 1
|
||||
c := limb_bits - 1 - c
|
||||
if c = 0 and then xn = mn and cmp_special (xp, xp_offset, mp, mp_offset, mn) >= 0 then
|
||||
sub_n (xp, xp_offset, xp, xp_offset, mp, mp_offset, mn, carry)
|
||||
junk := carry.item
|
||||
else
|
||||
from
|
||||
until
|
||||
c = 0
|
||||
loop
|
||||
sqr_n (tp, tp_offset, xp, xp_offset, xn)
|
||||
tn := 2 * xn
|
||||
tn := tn - (tp [tp_offset + tn - 1] = 0).to_integer
|
||||
if tn < mn then
|
||||
xp.copy_data (tp, tp_offset, xp_offset, tn)
|
||||
xn := tn
|
||||
else
|
||||
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, tn, mp, mp_offset, mn)
|
||||
xn := mn
|
||||
end
|
||||
if e.to_integer_32 < 0 then
|
||||
mul_special (tp, tp_offset, xp, xp_offset, xn, bp, bp_offset, bn, carry)
|
||||
junk := carry.item
|
||||
tn := xn + bn
|
||||
tn := tn - (tp [tp_offset + tn - 1] = 0).to_integer
|
||||
if tn < mn then
|
||||
xp.copy_data (tp, tp_offset, xp_offset, tn)
|
||||
xn := tn
|
||||
else
|
||||
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, tn, mp, mp_offset, mn)
|
||||
xn := mn
|
||||
end
|
||||
end
|
||||
e := e |<< 1
|
||||
c := c - 1
|
||||
end
|
||||
end
|
||||
if m_zero_count /= 0 then
|
||||
lshift (tp, tp_offset, xp, xp_offset, xn, m_zero_count, carry)
|
||||
cy := carry.item
|
||||
tp [tp_offset + xn] := cy
|
||||
xn := xn + (cy /= 0).to_integer
|
||||
if xn < mn then
|
||||
xp.copy_data (tp, tp_offset, xp_offset, xn)
|
||||
else
|
||||
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, xn, mp, mp_offset, mn)
|
||||
xn := mn
|
||||
end
|
||||
rshift (xp, xp_offset, xp, xp_offset, xn, m_zero_count, carry)
|
||||
junk := carry.item
|
||||
end
|
||||
xn := normalize (xp, xp_offset, xn)
|
||||
if el.bit_test (0) and b.count < 0 and xn /= 0 then
|
||||
mp := m.item
|
||||
mp_offset := 0
|
||||
sub_special (xp, xp_offset, mp, mp_offset, mn, xp, xp_offset, xn, carry)
|
||||
junk := carry.item
|
||||
xn := mn
|
||||
xn := normalize (xp, xp_offset, xn)
|
||||
end
|
||||
target.resize (xn)
|
||||
target.count := xn
|
||||
target.item.copy_data (xp, xp_offset, 0, xn)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
probab_prime_isprime (t: NATURAL_32): BOOLEAN
|
||||
local
|
||||
q: NATURAL_32
|
||||
r: NATURAL_32
|
||||
d: NATURAL_32
|
||||
do
|
||||
if t < 3 or not t.bit_test (0) then
|
||||
Result := t = 2
|
||||
else
|
||||
from
|
||||
d := 3
|
||||
r := 1
|
||||
q := d
|
||||
until
|
||||
Result or r = 0
|
||||
loop
|
||||
q := t // d
|
||||
r := t - q * d
|
||||
Result := (q < d)
|
||||
d := d + 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
probab_prime_p (op1_a: READABLE_INTEGER_X; reps: INTEGER): INTEGER
|
||||
local
|
||||
r: NATURAL_32
|
||||
n2: INTEGER_X
|
||||
is_prime: BOOLEAN
|
||||
op1: READABLE_INTEGER_X
|
||||
done: BOOLEAN
|
||||
ln2: NATURAL_32
|
||||
q: NATURAL_32
|
||||
p1: CELL [NATURAL_32]
|
||||
p0: CELL [NATURAL_32]
|
||||
p: NATURAL_32
|
||||
primes: SPECIAL [NATURAL_32]
|
||||
nprimes: INTEGER
|
||||
do
|
||||
create p1.put (0)
|
||||
create p0.put (0)
|
||||
create primes.make_filled (0, 15)
|
||||
op1 := op1_a
|
||||
create n2
|
||||
if cmp_ui (op1, 1_000_000) <= 0 then
|
||||
if cmpabs_ui (op1, 1_000_000) <= 0 then
|
||||
is_prime := probab_prime_isprime (op1.as_natural_32)
|
||||
if is_prime then
|
||||
Result := 2
|
||||
else
|
||||
Result := 0
|
||||
end
|
||||
done := True
|
||||
else
|
||||
n2.item := op1.item
|
||||
n2.count := -op1.count
|
||||
op1 := n2
|
||||
end
|
||||
end
|
||||
if not done then
|
||||
if not op1.as_natural_32.bit_test (0) then
|
||||
done := True
|
||||
end
|
||||
end
|
||||
if not done then
|
||||
r := preinv_mod_1 (op1.item, 0, op1.count, pp, pp_inverted)
|
||||
if r \\ 3 = 0 or r \\ 5 = 0 or r \\ 7 = 0 or r \\ 11 = 0 or r \\ 13 = 0 or r \\ 17 = 0 or r \\ 19 = 0 or r \\ 23 = 0 or r \\ 29 = 0 then
|
||||
Result := 0
|
||||
done := True
|
||||
end
|
||||
end
|
||||
if not done then
|
||||
nprimes := 0
|
||||
p := 1
|
||||
ln2 := sizeinbase (op1, 2).to_natural_32
|
||||
from
|
||||
q := pp_first_omitted.to_natural_32
|
||||
until
|
||||
q >= ln2 or done
|
||||
loop
|
||||
if probab_prime_isprime (q) then
|
||||
umul_ppmm (p1, p0, p, q)
|
||||
if p1.item /= 0 then
|
||||
r := modexact_1c_odd (op1.item, 0, op1.count, p, 0)
|
||||
from
|
||||
nprimes := nprimes - 1
|
||||
until
|
||||
nprimes < 0 or done
|
||||
loop
|
||||
if r \\ primes [nprimes] = 0 then
|
||||
Result := 0
|
||||
done := True
|
||||
end
|
||||
nprimes := nprimes - 1
|
||||
end
|
||||
p := q
|
||||
nprimes := 0
|
||||
else
|
||||
p := p0.item
|
||||
end
|
||||
primes [nprimes] := q
|
||||
nprimes := nprimes + 1
|
||||
end
|
||||
q := q + 2
|
||||
end
|
||||
end
|
||||
if not done then
|
||||
Result := millerrabin (op1, reps)
|
||||
end
|
||||
end
|
||||
|
||||
pp: NATURAL_32 = 0xC0CFD797
|
||||
pp_inverted: NATURAL_32 = 0x53E5645C
|
||||
pp_first_omitted: INTEGER = 31
|
||||
|
||||
reduce (target: SPECIAL [NATURAL_32]; target_offset: INTEGER; ap: SPECIAL [NATURAL_32]; ap_offset: INTEGER; ap_count: INTEGER; mp: SPECIAL [NATURAL_32]; mp_offset: INTEGER; mp_count: INTEGER)
|
||||
local
|
||||
tmp: SPECIAL [NATURAL_32]
|
||||
do
|
||||
create tmp.make_filled (0, ap_count - mp_count + 1)
|
||||
tdiv_qr_special (tmp, 0, target, target_offset, ap, ap_offset, ap_count, mp, mp_offset, mp_count)
|
||||
end
|
||||
|
||||
muldiv (target: READABLE_INTEGER_X; inc: INTEGER_32; rsize: CELL [INTEGER_32]; ralloc: CELL [INTEGER_32]; nacc: CELL [NATURAL_32]; kacc: CELL [NATURAL_32])
|
||||
local
|
||||
new_ralloc: INTEGER_32
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
if rsize.item <= ralloc.item then
|
||||
new_ralloc := ralloc.item + inc
|
||||
target.resize (new_ralloc)
|
||||
ralloc.put (new_ralloc)
|
||||
end
|
||||
mul_1 (target.item, 0, target.item, 0, rsize.item, nacc.item, carry)
|
||||
target.item [rsize.item] := carry.item
|
||||
divexact_1 (target.item, 0, target.item, 0, rsize.item + 1, kacc.item)
|
||||
if target.item [rsize.item] /= 0 then
|
||||
rsize.put (rsize.item + 1)
|
||||
end
|
||||
end
|
||||
|
||||
invert_gf (target: READABLE_INTEGER_X op1: READABLE_INTEGER_X op2: READABLE_INTEGER_X)
|
||||
require
|
||||
not op1.is_negative
|
||||
not op2.is_negative
|
||||
local
|
||||
target_special: SPECIAL [NATURAL_32]
|
||||
op2_count: INTEGER
|
||||
do
|
||||
target.resize (op2.count)
|
||||
op2_count := op2.count
|
||||
target_special := target.item
|
||||
invert_gf_special (target_special, 0, op1.item, 0, op1.count, op2.item, 0, op2_count)
|
||||
target.count := normalize (target_special, 0, op2_count)
|
||||
end
|
||||
end
|
||||
108
contrib/ise_library/math/eapml/src/facilities/integer_x_random.e
Normal file
108
contrib/ise_library/math/eapml/src/facilities/integer_x_random.e
Normal file
@@ -0,0 +1,108 @@
|
||||
note
|
||||
description: "Summary description for {INTEGER_X_RANDOM}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "Letting lawyers make laws is like letting doctors make diseases. - Anonymous"
|
||||
|
||||
deferred class
|
||||
INTEGER_X_RANDOM
|
||||
|
||||
inherit
|
||||
INTEGER_X_FACILITIES
|
||||
LIMB_MANIPULATION
|
||||
SPECIAL_COMPARISON
|
||||
SPECIAL_ARITHMETIC
|
||||
SPECIAL_UTILITY
|
||||
|
||||
feature
|
||||
|
||||
urandomb (target: READABLE_INTEGER_X; state: RANDOM_NUMBER_GENERATOR; nbits: INTEGER)
|
||||
-- Generate a uniformly distributed random integer in the range 0 to 2^`n'-1, inclusive.
|
||||
-- `state' must be initialized by calling one of the randinit functions before invoking this function.
|
||||
local
|
||||
size: INTEGER_32
|
||||
do
|
||||
size := bits_to_limbs (nbits)
|
||||
target.resize (size)
|
||||
state.randget (target.item, 0, nbits)
|
||||
size := normalize (target.item, 0, size)
|
||||
target.count := size
|
||||
ensure
|
||||
target.bits <= nbits
|
||||
end
|
||||
|
||||
urandomm (target: READABLE_INTEGER_X; state: RANDOM_NUMBER_GENERATOR; n: READABLE_INTEGER_X)
|
||||
-- Generate a uniform random integer in the range 0 to n-1, inclusive.
|
||||
-- `state' must be initialized by calling one of the randinit functions before invoking this function.
|
||||
local
|
||||
rp: SPECIAL [NATURAL_32]
|
||||
rp_offset: INTEGER
|
||||
np: SPECIAL [NATURAL_32]
|
||||
np_offset: INTEGER
|
||||
nlast: INTEGER
|
||||
nbits: INTEGER
|
||||
size: INTEGER
|
||||
count: INTEGER
|
||||
pow2: BOOLEAN
|
||||
cmp_l: INTEGER
|
||||
overlap: BOOLEAN
|
||||
junk: NATURAL_32
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
size := n.count.abs
|
||||
if size = 0 then
|
||||
(create {DIVIDE_BY_ZERO}).raise
|
||||
end
|
||||
np := n.item
|
||||
nlast := size - 1
|
||||
pow2 := pow2_p (n.item [nlast])
|
||||
if pow2 then
|
||||
from
|
||||
np := n.item
|
||||
until
|
||||
not pow2 or np_offset >= nlast
|
||||
loop
|
||||
if np [np_offset] /= 0 then
|
||||
pow2 := False
|
||||
end
|
||||
np_offset := np_offset + 1
|
||||
end
|
||||
end
|
||||
count := leading_zeros (np [nlast])
|
||||
nbits := size * limb_bits - (count) - pow2.to_integer
|
||||
if nbits = 0 then
|
||||
target.count := 0
|
||||
else
|
||||
np := n.item
|
||||
np_offset := 0
|
||||
rp := target.item
|
||||
rp_offset := 0
|
||||
if np = rp then
|
||||
overlap := True
|
||||
create np.make_filled (0, size)
|
||||
np.copy_data (n.item, 0, 0, size)
|
||||
end
|
||||
target.resize (size)
|
||||
rp := target.item
|
||||
rp [rp_offset + size - 1] := 0
|
||||
count := 80
|
||||
from
|
||||
cmp_l := 0
|
||||
until
|
||||
cmp_l < 0 or count = 0
|
||||
loop
|
||||
state.randget (rp, rp_offset, nbits)
|
||||
cmp_l := cmp (rp, rp_offset, np, np_offset, size)
|
||||
count := count - 1
|
||||
end
|
||||
if count = 0 then
|
||||
sub_n (rp, rp_offset, rp, rp_offset, np, np_offset, size, carry)
|
||||
junk := carry.item
|
||||
end
|
||||
size := normalize (rp, rp_offset, size)
|
||||
target.count := size
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,49 @@
|
||||
note
|
||||
description: "Summary description for {INTEGER_X_SIZING}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "My freedom is more important than your great idea. - Anonymous"
|
||||
|
||||
deferred class
|
||||
INTEGER_X_SIZING
|
||||
|
||||
inherit
|
||||
INTEGER_X_FACILITIES
|
||||
LIMB_BIT_SCANNING
|
||||
LIMB_MANIPULATION
|
||||
MP_BASES
|
||||
|
||||
feature
|
||||
|
||||
sizeinbase (op: READABLE_INTEGER_X; base: INTEGER): INTEGER_32
|
||||
-- Return the size of `op' measured in number of digits in the given base.
|
||||
-- `base' can vary from 2 to 62.
|
||||
-- The sign of `op' is ignored, just the absolute value is used.
|
||||
-- The result will be either exact or 1 too big.
|
||||
-- If `base' is a power of 2, the result is always exact.
|
||||
-- If `op' is zero the return value is always 1.
|
||||
-- This function can be used to determine the space required when converting `op' to a string.
|
||||
-- The right amount of allocation is normally two more than the value returned, one extra for
|
||||
-- a minus sign and one for the null-terminator.
|
||||
-- It will be noted that `sizeinbase(op,2)' can be used to locate the most significant 1
|
||||
-- bit in `op', counting from 1. (Unlike the bitwise functions which start from 0.
|
||||
local
|
||||
lb_base: NATURAL_32
|
||||
cnt: INTEGER_32
|
||||
totbits: INTEGER_32
|
||||
do
|
||||
if op.count.abs = 0 then
|
||||
Result := 1
|
||||
else
|
||||
cnt := leading_zeros (op.item [op.count.abs - 1])
|
||||
totbits := op.count.abs * limb_bits - cnt
|
||||
if pow2_p (base.to_natural_32) then
|
||||
lb_base := big_base (base)
|
||||
Result := (totbits + lb_base.to_integer_32 - 1) // lb_base.to_integer_32
|
||||
else
|
||||
Result := ((totbits.to_double * chars_per_bit_exactly (base)) + 1).truncated_to_integer
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
1603
contrib/ise_library/math/eapml/src/facilities/mp_bases.e
Normal file
1603
contrib/ise_library/math/eapml/src/facilities/mp_bases.e
Normal file
File diff suppressed because it is too large
Load Diff
32
contrib/ise_library/math/eapml/src/facilities/powers.e
Normal file
32
contrib/ise_library/math/eapml/src/facilities/powers.e
Normal file
@@ -0,0 +1,32 @@
|
||||
note
|
||||
description: "Summary description for {POWERS}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "Giving a politician access to your wallet is like giving a dog access to your refrigerator. - Tim Barber"
|
||||
|
||||
class
|
||||
POWERS
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature
|
||||
|
||||
make (digits_in_base_a: INTEGER; p_a: SPECIAL [NATURAL_32]; p_offset_a: INTEGER; n_a: INTEGER; base_a: INTEGER)
|
||||
do
|
||||
digits_in_base := digits_in_base_a
|
||||
p := p_a
|
||||
p_offset := p_offset_a
|
||||
n := n_a
|
||||
base := base_a
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
digits_in_base: INTEGER
|
||||
p: SPECIAL [NATURAL_32]
|
||||
p_offset: INTEGER
|
||||
n: INTEGER
|
||||
base: INTEGER
|
||||
end
|
||||
@@ -0,0 +1,44 @@
|
||||
note
|
||||
description: "Summary description for {RAND_LC_STRUCT}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "Everyone wants to save the planet but no one wants to help Mom clean the dishes. - P.J. O'Rourke, in All the Trouble in the World "
|
||||
|
||||
class
|
||||
RAND_LC_STRUCT
|
||||
|
||||
inherit
|
||||
INTEGER_X_DIVISION
|
||||
LIMB_MANIPULATION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature
|
||||
|
||||
make (m2exp_a: INTEGER; a_a: READABLE_INTEGER_X; seedn: INTEGER; c: NATURAL_32)
|
||||
do
|
||||
create cp.make_filled (0, 1)
|
||||
m2exp := m2exp_a
|
||||
create seed.make_limbs (bits_to_limbs (m2exp))
|
||||
seed.count := seedn
|
||||
seed.item [0] := 1
|
||||
create a
|
||||
fdiv_r_2exp (a, a_a, m2exp)
|
||||
if a.count = 0 then
|
||||
a.count := 1
|
||||
a.item [0] := 0
|
||||
end
|
||||
cp [0] := c
|
||||
cn := (c /= 0).to_integer
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
seed: INTEGER_X
|
||||
a: INTEGER_X
|
||||
cn: INTEGER
|
||||
cp: SPECIAL [NATURAL_32]
|
||||
m2exp: INTEGER
|
||||
end
|
||||
262
contrib/ise_library/math/eapml/src/facilities/special_access.e
Normal file
262
contrib/ise_library/math/eapml/src/facilities/special_access.e
Normal file
@@ -0,0 +1,262 @@
|
||||
note
|
||||
description: "Summary description for {NUMBER_ACCESS}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "State-mandated compassion produces, not love for ones fellow man, but hatred and resentment. - Lizard"
|
||||
|
||||
deferred class
|
||||
SPECIAL_ACCESS
|
||||
|
||||
inherit
|
||||
LIMB_MANIPULATION
|
||||
MP_BASES
|
||||
SPECIAL_ARITHMETIC
|
||||
SPECIAL_DIVISION
|
||||
|
||||
feature
|
||||
|
||||
dc_get_str (target_a: STRING_8; target_offset_a: INTEGER; len_a: INTEGER; op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER; op1_count: INTEGER; powtab: SPECIAL [POWERS]; powtab_offset: INTEGER; tmp: SPECIAL [NATURAL_32]; tmp_offset: INTEGER): INTEGER
|
||||
local
|
||||
target: STRING_8
|
||||
len: INTEGER
|
||||
pwp: SPECIAL [NATURAL_32]
|
||||
pwp_offset: INTEGER
|
||||
qp: SPECIAL [NATURAL_32]
|
||||
qp_offset: INTEGER
|
||||
rp: SPECIAL [NATURAL_32]
|
||||
rp_offset: INTEGER
|
||||
pwn: INTEGER
|
||||
qn: INTEGER
|
||||
target_offset: INTEGER
|
||||
do
|
||||
target := target_a
|
||||
len := len_a
|
||||
target_offset := target_offset_a
|
||||
if op1_count < 15 then
|
||||
if op1_count /= 0 then
|
||||
target_offset := sb_get_str (target, target_offset, len, op1, op1_offset, op1_count, powtab, powtab_offset)
|
||||
else
|
||||
from
|
||||
until
|
||||
len /= 0
|
||||
loop
|
||||
target [target_offset] := '%U'
|
||||
target_offset := target_offset + 1
|
||||
len := len - 1
|
||||
end
|
||||
end
|
||||
else
|
||||
pwp := powtab [powtab_offset].p
|
||||
pwn := powtab [powtab_offset].n
|
||||
if op1_count < pwn or (op1_count = pwn and cmp (op1, op1_offset, pwp, pwp_offset, op1_count) < 0) then
|
||||
target_offset := dc_get_str (target, target_offset, len, op1, op1_offset, op1_count, powtab, powtab_offset - 1, tmp, tmp_offset)
|
||||
else
|
||||
qp := tmp
|
||||
qp_offset := tmp_offset
|
||||
rp := op1
|
||||
rp_offset := op1_offset
|
||||
tdiv_qr (qp, qp_offset, rp, rp_offset, op1, op1_offset, op1_count, pwp, pwp_offset, pwn)
|
||||
qn := op1_count - pwn
|
||||
qn := qn + (qp [qp_offset + qn] /= 0).to_integer
|
||||
if len /= 0 then
|
||||
len := len - powtab [powtab_offset].digits_in_base
|
||||
end
|
||||
target_offset := dc_get_str (target, target_offset, len, qp, qp_offset, qn, powtab, powtab_offset - 1, tmp, tmp_offset + op1_count - pwn + 1)
|
||||
target_offset := dc_get_str (target, target_offset, powtab [powtab_offset].digits_in_base, rp, rp_offset, pwn, powtab, powtab_offset - 1, tmp, tmp_offset)
|
||||
end
|
||||
end
|
||||
Result := target_offset
|
||||
end
|
||||
|
||||
get_str (target: STRING_8; target_offset: INTEGER; base: INTEGER; op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER; op1_count: INTEGER): INTEGER
|
||||
local
|
||||
powtab_mem_ptr: SPECIAL [NATURAL_32]
|
||||
powtab_mem_ptr_offset: INTEGER
|
||||
big_base_l: NATURAL_32
|
||||
digits_in_base: INTEGER
|
||||
powtab: SPECIAL [POWERS]
|
||||
pi: INTEGER
|
||||
n: INTEGER
|
||||
t: INTEGER
|
||||
p: SPECIAL [NATURAL_32]
|
||||
p_offset: INTEGER
|
||||
n1: NATURAL_32
|
||||
n0: NATURAL_32
|
||||
bits_per_digit: INTEGER
|
||||
count: INTEGER
|
||||
bit_pos: INTEGER
|
||||
i: INTEGER
|
||||
s: INTEGER
|
||||
bits: INTEGER
|
||||
do
|
||||
if op1_count = 0 then
|
||||
target [target_offset] := '%U'
|
||||
Result := 1
|
||||
else
|
||||
if pow2_p (base.to_natural_32) then
|
||||
bits_per_digit := big_base (base).to_integer_32
|
||||
s := target_offset
|
||||
n1 := op1 [op1_offset + op1_count - 1]
|
||||
count := leading_zeros (n1)
|
||||
bits := limb_bits * op1_count - count
|
||||
count := bits \\ bits_per_digit
|
||||
if count /= 0 then
|
||||
bits := bits + bits_per_digit - count
|
||||
end
|
||||
bit_pos := bits - (op1_count - 1) * limb_bits
|
||||
from
|
||||
i := op1_count - 1
|
||||
until
|
||||
i < 0
|
||||
loop
|
||||
bit_pos := bit_pos - bits_per_digit
|
||||
from
|
||||
until
|
||||
bit_pos < 0
|
||||
loop
|
||||
target [s] := ((n1 |>> bit_pos).bit_and (((1).to_natural_32 |<< bits_per_digit) - 1)).to_character_8
|
||||
s := s + 1
|
||||
bit_pos := bit_pos - bits_per_digit
|
||||
end
|
||||
i := i - 1
|
||||
if i >= 0 then
|
||||
n0 := (n1 |<< -bit_pos).bit_and (((1).to_natural_32 |<< bits_per_digit) - 1)
|
||||
n1 := op1 [op1_offset + i]
|
||||
bit_pos := bit_pos + limb_bits
|
||||
target [s] := (n0.bit_or (n1 |>> bit_pos)).to_character_8
|
||||
s := s + 1
|
||||
end
|
||||
end
|
||||
Result := s - target_offset
|
||||
else
|
||||
if op1_count < 30 then
|
||||
create powtab.make_empty (1)
|
||||
create p.make_empty (0)
|
||||
powtab.extend (create {POWERS}.make (0, p, 0, 0, base))
|
||||
Result := sb_get_str (target, target_offset, 0, op1, op1_offset, op1_count, powtab, 0)
|
||||
else
|
||||
create powtab_mem_ptr.make_filled (0, 2 * op1_count + 30)
|
||||
big_base_l := big_base (base)
|
||||
digits_in_base := chars_per_limb (base)
|
||||
create powtab.make_empty (30)
|
||||
create p.make_filled (0, 0)
|
||||
powtab.extend (create {POWERS}.make (0, p, 0, 0, base))
|
||||
create p.make_filled (big_base_l, 1)
|
||||
powtab.extend (create {POWERS}.make (digits_in_base, p, 0, 1, base))
|
||||
create p.make_filled (big_base_l, 1)
|
||||
powtab.extend (create {POWERS}.make (digits_in_base, p, 0, 1, base))
|
||||
n := 1
|
||||
pi := 2
|
||||
create p.make_filled (big_base_l, 1)
|
||||
p_offset := 0
|
||||
from
|
||||
until
|
||||
2 * n > op1_count
|
||||
loop
|
||||
pi := pi + 1
|
||||
t := powtab_mem_ptr_offset
|
||||
powtab_mem_ptr_offset := powtab_mem_ptr_offset + 2 * n
|
||||
sqr_n (powtab_mem_ptr, t, p, p_offset, n)
|
||||
n := n * 2
|
||||
n := n - (powtab_mem_ptr [t + n - 1] = 0).to_integer
|
||||
digits_in_base := digits_in_base * 2
|
||||
powtab_mem_ptr_offset := t
|
||||
powtab.extend (create {POWERS}.make (digits_in_base, p, 0, n, base))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
sb_get_str (target: STRING_8; target_offset_a: INTEGER; len_a: INTEGER; op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER; op1_count_a: INTEGER; powtab: SPECIAL [POWERS]; powtab_offset: INTEGER): INTEGER
|
||||
local
|
||||
rl: CELL [NATURAL_32]
|
||||
ul: CELL [NATURAL_32]
|
||||
s: INTEGER
|
||||
base: INTEGER
|
||||
l: INTEGER
|
||||
buf: SPECIAL [NATURAL_8]
|
||||
buf_offset: INTEGER
|
||||
rp: SPECIAL [NATURAL_32]
|
||||
rp_offset: INTEGER
|
||||
buff_alloc: INTEGER
|
||||
op1_count: INTEGER
|
||||
i: INTEGER
|
||||
frac: CELL [NATURAL_32]
|
||||
digit: CELL [NATURAL_32]
|
||||
junk: NATURAL_32
|
||||
chars_per_limb_l: INTEGER
|
||||
big_base_l: NATURAL_32
|
||||
big_base_inverted_l: NATURAL_32
|
||||
normalization_steps: INTEGER
|
||||
target_offset: INTEGER
|
||||
len: INTEGER
|
||||
do
|
||||
create digit.put (0)
|
||||
create frac.put (0)
|
||||
create ul.put (0)
|
||||
create rl.put (0)
|
||||
len := len_a
|
||||
target_offset := target_offset_a
|
||||
op1_count := op1_count_a
|
||||
buff_alloc := 30 * 8 * 4 * 7 // 11
|
||||
create buf.make_filled (0, buff_alloc)
|
||||
create rp.make_filled (0, 30)
|
||||
base := powtab [powtab_offset].base
|
||||
chars_per_limb_l := chars_per_limb (base)
|
||||
big_base_l := big_base (base)
|
||||
big_base_inverted_l := big_base_inverted (base)
|
||||
normalization_steps := leading_zeros (big_base_l)
|
||||
rp.copy_data (op1, op1_offset, rp_offset + 1, op1_count)
|
||||
s := buf_offset + buff_alloc
|
||||
from
|
||||
until
|
||||
op1_count <= 1
|
||||
loop
|
||||
junk := preinv_divrem_1 (rp, rp_offset, 1, rp, rp_offset + 1, op1_count, big_base_l, big_base_inverted_l, normalization_steps)
|
||||
op1_count := op1_count - (rp [rp_offset + op1_count] = 0).to_integer
|
||||
frac.put (rp [rp_offset] + 1)
|
||||
s := s - chars_per_limb_l
|
||||
i := chars_per_limb_l
|
||||
from
|
||||
until
|
||||
i = 0
|
||||
loop
|
||||
umul_ppmm (digit, frac, frac.item, base.to_natural_32)
|
||||
buf [s] := digit.item.to_natural_8
|
||||
s := s + 1
|
||||
i := i - 1
|
||||
end
|
||||
s := s - chars_per_limb_l
|
||||
end
|
||||
ul.put (rp [rp_offset + 1])
|
||||
from
|
||||
until
|
||||
ul.item = 0
|
||||
loop
|
||||
udiv_qrnd_unnorm (ul, rl, ul.item, base.to_natural_32)
|
||||
s := s - 1
|
||||
buf [s] := rl.item.to_natural_8
|
||||
end
|
||||
l := buf_offset + buff_alloc - s
|
||||
from
|
||||
until
|
||||
l >= len
|
||||
loop
|
||||
target [target_offset] := '%U'
|
||||
target_offset := target_offset + 1
|
||||
len := len - 1
|
||||
end
|
||||
from
|
||||
until
|
||||
l = 0
|
||||
loop
|
||||
target [target_offset] := buf [s].to_character_8
|
||||
s := s + 1
|
||||
target_offset := target_offset + 1
|
||||
l := l - 1
|
||||
end
|
||||
Result := target_offset - target_offset_a
|
||||
end
|
||||
end
|
||||
1022
contrib/ise_library/math/eapml/src/facilities/special_arithmetic.e
Normal file
1022
contrib/ise_library/math/eapml/src/facilities/special_arithmetic.e
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,159 @@
|
||||
note
|
||||
description: "Summary description for {NUMBER_ASSIGNMENT}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "Concentrated political power is the most dangerous thing on earth. - Rudolph Rummel"
|
||||
|
||||
deferred class
|
||||
SPECIAL_ASSIGNMENT
|
||||
|
||||
inherit
|
||||
MP_BASES
|
||||
LIMB_MANIPULATION
|
||||
SPECIAL_ARITHMETIC
|
||||
|
||||
feature
|
||||
|
||||
set_str (target: SPECIAL [NATURAL_32]; target_offset: INTEGER; str: SPECIAL [NATURAL_8]; str_offset_a: INTEGER; str_len: INTEGER; base: INTEGER): INTEGER
|
||||
require
|
||||
base >= 2
|
||||
-- str_len >= 1
|
||||
local
|
||||
str_offset: INTEGER
|
||||
size: INTEGER
|
||||
big_base_l: NATURAL_32
|
||||
chars_per_limb_l: INTEGER
|
||||
res_digit: NATURAL_32
|
||||
s: INTEGER
|
||||
next_bitpos: INTEGER
|
||||
bits_per_indigit: INTEGER
|
||||
inp_digit: NATURAL_8
|
||||
i: INTEGER
|
||||
j: INTEGER
|
||||
cy_limb: NATURAL_32
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
str_offset := str_offset_a
|
||||
big_base_l := big_base (base)
|
||||
chars_per_limb_l := chars_per_limb (base)
|
||||
size := 0
|
||||
if pow2_p (base.to_natural_32) then
|
||||
bits_per_indigit := big_base_l.to_integer_32
|
||||
res_digit := 0
|
||||
next_bitpos := 0
|
||||
from
|
||||
s := str_offset + str_len - 1
|
||||
until
|
||||
s < str_offset
|
||||
loop
|
||||
inp_digit := str [s]
|
||||
res_digit := res_digit.bit_or (inp_digit.to_natural_32 |<< next_bitpos)
|
||||
next_bitpos := next_bitpos + bits_per_indigit
|
||||
if next_bitpos >= limb_bits then
|
||||
target [target_offset + size] := res_digit
|
||||
size := size + 1
|
||||
next_bitpos := next_bitpos - limb_bits
|
||||
res_digit := inp_digit |>> (bits_per_indigit - next_bitpos)
|
||||
end
|
||||
s := s - 1
|
||||
end
|
||||
if res_digit /= 0 then
|
||||
target [target_offset + size] := res_digit
|
||||
size := size + 1
|
||||
end
|
||||
Result := size
|
||||
else
|
||||
if str_len < str_len.max_value then
|
||||
from
|
||||
i := chars_per_limb_l
|
||||
until
|
||||
i >= str_len
|
||||
loop
|
||||
res_digit := str [str_offset]
|
||||
str_offset := str_offset + 1
|
||||
if base = 10 then
|
||||
from
|
||||
j := 9 - 1
|
||||
until
|
||||
j = 0
|
||||
loop
|
||||
res_digit := res_digit * 10 + str [str_offset].to_natural_32
|
||||
str_offset := str_offset + 1
|
||||
j := j - 1
|
||||
end
|
||||
else
|
||||
from
|
||||
j := chars_per_limb_l - 1
|
||||
until
|
||||
j = 0
|
||||
loop
|
||||
res_digit := res_digit * base.to_natural_32 + str [str_offset].to_natural_32
|
||||
str_offset := str_offset + 1
|
||||
j := j - 1
|
||||
end
|
||||
end
|
||||
if size = 0 then
|
||||
if res_digit /= 0 then
|
||||
target [target_offset] := res_digit
|
||||
size := 1
|
||||
end
|
||||
else
|
||||
mul_1 (target, target_offset, target, target_offset, size, big_base_l, carry)
|
||||
cy_limb := carry.item
|
||||
add_1 (target, target_offset, target, target_offset, size, res_digit, carry)
|
||||
cy_limb := cy_limb + carry.item
|
||||
if cy_limb /= 0 then
|
||||
target [target_offset + size] := cy_limb
|
||||
size := size + 1
|
||||
end
|
||||
end
|
||||
i := i + chars_per_limb_l
|
||||
end
|
||||
big_base_l := base.to_natural_32
|
||||
res_digit := str [str_offset]
|
||||
str_offset := str_offset + 1
|
||||
if base = 10 then
|
||||
from
|
||||
j := str_len - (i - 9) - 1
|
||||
until
|
||||
j <= 0
|
||||
loop
|
||||
res_digit := res_digit * 10 + str [str_offset]
|
||||
str_offset := str_offset + 1
|
||||
big_base_l := big_base_l * 10
|
||||
j := j - 1
|
||||
end
|
||||
else
|
||||
from
|
||||
j := str_len - (i - chars_per_limb_l) - 1
|
||||
until
|
||||
j <= 0
|
||||
loop
|
||||
res_digit := res_digit * base.to_natural_32 + str [str_offset].to_natural_32
|
||||
str_offset := str_offset + 1
|
||||
big_base_l := big_base_l * base.to_natural_32
|
||||
j := j - 1
|
||||
end
|
||||
end
|
||||
if size = 0 then
|
||||
if res_digit /= 0 then
|
||||
target [target_offset] := res_digit
|
||||
size := 1
|
||||
end
|
||||
else
|
||||
mul_1 (target, target_offset, target, target_offset, size, big_base_l, carry)
|
||||
cy_limb := carry.item
|
||||
add_1 (target, target_offset, target, target_offset, size, res_digit, carry)
|
||||
cy_limb := cy_limb + carry.item
|
||||
if cy_limb /= 0 then
|
||||
target [target_offset + size] := cy_limb
|
||||
size := size + 1
|
||||
end
|
||||
end
|
||||
Result := size
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,39 @@
|
||||
note
|
||||
description: "Summary description for {NUMBER_COMPARISON}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "No nation was ever ruined by trade. - Benjamin Franklin"
|
||||
|
||||
deferred class
|
||||
SPECIAL_COMPARISON
|
||||
|
||||
feature
|
||||
|
||||
cmp (op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER; op2: SPECIAL [NATURAL_32]; op2_offset: INTEGER; size: INTEGER): INTEGER
|
||||
local
|
||||
i: INTEGER
|
||||
x: NATURAL_32
|
||||
y: NATURAL_32
|
||||
do
|
||||
Result := 0
|
||||
from
|
||||
i := size - 1
|
||||
until
|
||||
i < 0 or Result /= 0
|
||||
loop
|
||||
x := op1 [op1_offset + i]
|
||||
y := op2 [op2_offset + i]
|
||||
if x /= y then
|
||||
if x > y then
|
||||
Result := 1
|
||||
else
|
||||
Result := -1
|
||||
end
|
||||
end
|
||||
i := i - 1
|
||||
variant
|
||||
i + 2
|
||||
end
|
||||
end
|
||||
end
|
||||
1102
contrib/ise_library/math/eapml/src/facilities/special_division.e
Normal file
1102
contrib/ise_library/math/eapml/src/facilities/special_division.e
Normal file
File diff suppressed because it is too large
Load Diff
1103
contrib/ise_library/math/eapml/src/facilities/special_gcd.e
Normal file
1103
contrib/ise_library/math/eapml/src/facilities/special_gcd.e
Normal file
File diff suppressed because it is too large
Load Diff
332
contrib/ise_library/math/eapml/src/facilities/special_logic.e
Normal file
332
contrib/ise_library/math/eapml/src/facilities/special_logic.e
Normal file
@@ -0,0 +1,332 @@
|
||||
note
|
||||
description: "Summary description for {NUMBER_LOGIC}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "It is a free market that makes monopolies impossible. - Ayn Rand"
|
||||
|
||||
deferred class
|
||||
SPECIAL_LOGIC
|
||||
|
||||
inherit
|
||||
LIMB_MANIPULATION
|
||||
|
||||
feature
|
||||
|
||||
com_n (target: SPECIAL [NATURAL_32]; target_offset_a: INTEGER; op1: SPECIAL [NATURAL_32]; op1_offset_a: INTEGER; op1_count_a: INTEGER)
|
||||
require
|
||||
op1_count_a >= 1
|
||||
local
|
||||
target_offset: INTEGER
|
||||
op1_offset: INTEGER
|
||||
op1_count: INTEGER
|
||||
do
|
||||
target_offset := target_offset_a
|
||||
op1_offset := op1_offset_a
|
||||
op1_count := op1_count_a
|
||||
from
|
||||
until
|
||||
op1_count = 0
|
||||
loop
|
||||
target [target_offset] := op1 [op1_offset].bit_not
|
||||
target_offset := target_offset + 1
|
||||
op1_offset := op1_offset + 1
|
||||
op1_count := op1_count - 1
|
||||
end
|
||||
end
|
||||
|
||||
hamdist (op1: SPECIAL [NATURAL_32]; op1_offset_a: INTEGER; op2: SPECIAL [NATURAL_32]; op2_offset_a: INTEGER; n_a: INTEGER): INTEGER
|
||||
local
|
||||
p0: NATURAL_32
|
||||
p1: NATURAL_32
|
||||
p2: NATURAL_32
|
||||
p3: NATURAL_32
|
||||
x: NATURAL_32
|
||||
p01: NATURAL_32
|
||||
p23: NATURAL_32
|
||||
i: INTEGER
|
||||
op1_offset: INTEGER
|
||||
n: INTEGER
|
||||
op2_offset: INTEGER
|
||||
do
|
||||
op2_offset := op2_offset_a
|
||||
n := n_a
|
||||
op1_offset := op1_offset_a
|
||||
from
|
||||
i := n |>> 2
|
||||
until
|
||||
i = 0
|
||||
loop
|
||||
p0 := op1 [op1_offset].bit_xor (op2 [op2_offset])
|
||||
p0 := p0 - (p0 |>> 1).bit_and (limb_max // 3)
|
||||
p0 := (p0 |>> 2).bit_and (limb_max // 5) + p0.bit_and (limb_max // 5)
|
||||
|
||||
p1 := op1 [op1_offset + 1].bit_xor (op2 [op2_offset + 1])
|
||||
p1 := p1 - (p1 |>> 1).bit_and (limb_max // 3)
|
||||
p1 := (p1 |>> 2).bit_and (limb_max // 5) + p1.bit_and (limb_max // 5)
|
||||
|
||||
p01 := p0 + p1
|
||||
p01 := (p01 |>> 4).bit_and (limb_max // 17) + p01.bit_and (limb_max // 17)
|
||||
|
||||
p2 := op1 [op1_offset + 2].bit_xor (op2 [op2_offset + 2])
|
||||
p2 := p2 - (p2 |>> 1).bit_and (limb_max // 3)
|
||||
p2 := (p2 |>> 2).bit_and (limb_max // 5) + p2.bit_and (limb_max // 5)
|
||||
|
||||
p3 := op1 [op1_offset + 3].bit_xor (op2 [op2_offset + 3])
|
||||
p3 := p3 - (p3 |>> 1).bit_and (limb_max // 3)
|
||||
p3 := (p3 |>> 2).bit_and (limb_max // 5) + p3.bit_and (limb_max // 5)
|
||||
|
||||
p23 := p2 + p3
|
||||
p23 := (p23 |>> 4).bit_and (limb_max // 17) + p23.bit_and (limb_max // 17)
|
||||
|
||||
x := p01 + p23
|
||||
x := (x |>> 8) + x
|
||||
x := (x |>> 16) + x
|
||||
Result := Result + x.bit_and (0xff).to_integer_32
|
||||
op1_offset := op1_offset + 4
|
||||
op2_offset := op2_offset + 4
|
||||
i := i - 1
|
||||
end
|
||||
n := n.bit_and (3)
|
||||
if n /= 0 then
|
||||
x := 0
|
||||
from
|
||||
until
|
||||
n = 0
|
||||
loop
|
||||
p0 := op1 [op1_offset].bit_xor (op2 [op2_offset])
|
||||
p0 := p0 - (p0 |>> 1).bit_and (limb_max // 3)
|
||||
p0 := (p0 |>> 2).bit_and (limb_max // 5) + p0.bit_and (limb_max // 5)
|
||||
p0 := ((p0 |>> 4) | p0).bit_and (limb_max // 17)
|
||||
x := x + p0
|
||||
op1_offset := op1_offset + 1
|
||||
op2_offset := op2_offset + 1
|
||||
n := n - 1
|
||||
end
|
||||
x := (x |>> 8) + x
|
||||
x := (x |>> 16) + x
|
||||
Result := Result + x.bit_and (0xff).to_integer_32
|
||||
end
|
||||
end
|
||||
|
||||
lshift (target: SPECIAL [NATURAL_32]; target_offset: INTEGER_32; op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER_32; n: INTEGER_32; count: INTEGER_32; carry: CELL [NATURAL_32])
|
||||
require
|
||||
target.valid_index (target_offset)
|
||||
target.valid_index (target_offset + n - 1)
|
||||
op1.valid_index (op1_offset)
|
||||
op1.valid_index (op1_offset + n - 1)
|
||||
count > 0
|
||||
count < 32
|
||||
local
|
||||
high_limb: NATURAL_32
|
||||
low_limb: NATURAL_32
|
||||
tnc: INTEGER_32
|
||||
i: INTEGER_32
|
||||
up: INTEGER_32
|
||||
rp: INTEGER_32
|
||||
do
|
||||
up := op1_offset + n
|
||||
rp := target_offset + n
|
||||
tnc := 32 - count
|
||||
up := up - 1
|
||||
low_limb := op1 [up]
|
||||
carry.put (low_limb |>> tnc)
|
||||
high_limb := low_limb |<< count
|
||||
from
|
||||
i := n - 1
|
||||
until
|
||||
i = 0
|
||||
loop
|
||||
up := up - 1
|
||||
low_limb := op1 [up]
|
||||
rp := rp - 1
|
||||
target [rp] := high_limb.bit_or (low_limb |>> tnc)
|
||||
high_limb := low_limb |<< count
|
||||
i := i - 1
|
||||
end
|
||||
rp := rp - 1
|
||||
target [rp] := high_limb
|
||||
end
|
||||
|
||||
rshift (target: SPECIAL [NATURAL_32]; target_offset: INTEGER_32; op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER_32; n: INTEGER_32; count: INTEGER_32; carry: CELL [NATURAL_32])
|
||||
local
|
||||
high_limb: NATURAL_32
|
||||
low_limb: NATURAL_32
|
||||
tnc: INTEGER_32
|
||||
i: INTEGER_32
|
||||
op1_cursor: INTEGER_32
|
||||
target_cursor: INTEGER_32
|
||||
do
|
||||
tnc := 32 - count
|
||||
op1_cursor := op1_offset
|
||||
high_limb := op1 [op1_cursor]
|
||||
op1_cursor := op1_cursor + 1
|
||||
carry.put (high_limb |<< tnc)
|
||||
low_limb := high_limb |>> count
|
||||
from
|
||||
i := n - 1
|
||||
until
|
||||
i = 0
|
||||
loop
|
||||
high_limb := op1 [op1_cursor]
|
||||
op1_cursor := op1_cursor + 1
|
||||
target [target_cursor] := low_limb.bit_or (high_limb |<< tnc)
|
||||
target_cursor := target_cursor + 1
|
||||
low_limb := high_limb |>> count
|
||||
i := i - 1
|
||||
end
|
||||
target [target_cursor] := low_limb
|
||||
end
|
||||
|
||||
popcount (op1: SPECIAL [NATURAL_32]; op1_offset_a: INTEGER; n_a: INTEGER): INTEGER
|
||||
local
|
||||
p0: NATURAL_32
|
||||
p1: NATURAL_32
|
||||
p2: NATURAL_32
|
||||
p3: NATURAL_32
|
||||
x: NATURAL_32
|
||||
p01: NATURAL_32
|
||||
p23: NATURAL_32
|
||||
i: INTEGER
|
||||
op1_offset: INTEGER
|
||||
n: INTEGER
|
||||
do
|
||||
n := n_a
|
||||
op1_offset := op1_offset_a
|
||||
from
|
||||
i := n |>> 2
|
||||
until
|
||||
i = 0
|
||||
loop
|
||||
p0 := op1 [op1_offset]
|
||||
p0 := p0 - (p0 |>> 1).bit_and (limb_max // 3)
|
||||
p0 := (p0 |>> 2).bit_and (limb_max // 5) + p0.bit_and (limb_max // 5)
|
||||
|
||||
p1 := op1 [op1_offset + 1]
|
||||
p1 := p1 - (p1 |>> 1).bit_and (limb_max // 3)
|
||||
p1 := (p1 |>> 2).bit_and (limb_max // 5) + p1.bit_and (limb_max // 5)
|
||||
|
||||
p01 := p0 + p1
|
||||
p01 := (p01 |>> 4).bit_and (limb_max // 17) + p01.bit_and (limb_max // 17)
|
||||
|
||||
p2 := op1 [op1_offset + 2]
|
||||
p2 := p2 - (p2 |>> 1).bit_and (limb_max // 3)
|
||||
p2 := (p2 |>> 2).bit_and (limb_max // 5) + p2.bit_and (limb_max // 5)
|
||||
|
||||
p3 := op1 [op1_offset + 3]
|
||||
p3 := p3 - (p3 |>> 1).bit_and (limb_max // 3)
|
||||
p3 := (p3 |>> 2).bit_and (limb_max // 5) + p3.bit_and (limb_max // 5)
|
||||
|
||||
p23 := p2 + p3
|
||||
p23 := (p23 |>> 4).bit_and (limb_max // 17) + p23.bit_and (limb_max // 17)
|
||||
|
||||
x := p01 + p23
|
||||
x := (x |>> 8) + x
|
||||
x := (x |>> 16) + x
|
||||
Result := Result + x.bit_and (0xff).to_integer_32
|
||||
op1_offset := op1_offset + 4
|
||||
i := i - 1
|
||||
end
|
||||
n := n.bit_and (3)
|
||||
if n /= 0 then
|
||||
x := 0
|
||||
from
|
||||
until
|
||||
n = 0
|
||||
loop
|
||||
p0 := op1 [op1_offset]
|
||||
p0 := p0 - (p0 |>> 1).bit_and (limb_max // 3)
|
||||
p0 := (p0 |>> 2).bit_and (limb_max // 5) + p0.bit_and (limb_max // 5)
|
||||
p0 := ((p0 |>> 4) | p0).bit_and (limb_max // 17)
|
||||
x := x + p0
|
||||
op1_offset := op1_offset + 1
|
||||
n := n - 1
|
||||
end
|
||||
x := (x |>> 8) + x
|
||||
x := (x |>> 16) + x
|
||||
Result := Result + x.bit_and (0xff).to_integer_32
|
||||
end
|
||||
end
|
||||
|
||||
bit_xor_lshift (target: SPECIAL [NATURAL_32] target_offset: INTEGER op1: SPECIAL [NATURAL_32] op1_offset: INTEGER op1_count: INTEGER op2: SPECIAL [NATURAL_32] op2_offset: INTEGER op2_count: INTEGER op2_lshift: INTEGER)
|
||||
require
|
||||
op2_lshift >= 0
|
||||
op1 /= op2
|
||||
target /= op2
|
||||
op1_count = 0 or op1.valid_index (op1_offset)
|
||||
op1_count = 0 or op1.valid_index (op1_offset + op1_count - 1)
|
||||
op2_count = 0 or op2.valid_index (op2_offset)
|
||||
op2_count = 0 or op2.valid_index (op2_offset + op2_count - 1)
|
||||
(op1_count = 0 and op2_count = 0) or target.valid_index (target_offset)
|
||||
(op1_count = 0 and op2_count = 0) or target.valid_index (target_offset + op1_count.max (op2_count + bits_to_limbs (op2_lshift)) - 1)
|
||||
local
|
||||
op2_limb_high: NATURAL_32
|
||||
op2_limb_low: NATURAL_32
|
||||
op2_limb: NATURAL_32
|
||||
cursor: INTEGER
|
||||
shift_limbs: INTEGER
|
||||
shift_bits: INTEGER
|
||||
do
|
||||
shift_limbs := op2_lshift // limb_bits
|
||||
shift_bits := op2_lshift \\ limb_bits
|
||||
target.copy_data (op1, op1_offset, target_offset, shift_limbs)
|
||||
from
|
||||
until
|
||||
cursor >= op2_count or cursor >= op1_count - shift_limbs
|
||||
loop
|
||||
op2_limb_low := op2_limb_high
|
||||
op2_limb_high := op2 [op2_offset + cursor]
|
||||
op2_limb := extract_limb (shift_bits, op2_limb_high, op2_limb_low)
|
||||
target [target_offset + shift_limbs + cursor] := op2_limb.bit_xor (op1 [op1_offset + shift_limbs + cursor])
|
||||
cursor := cursor + 1
|
||||
end
|
||||
if cursor >= op2_count then
|
||||
op2_limb_low := op2_limb_high
|
||||
op2_limb := extract_limb (shift_bits, 0, op2_limb_low)
|
||||
if cursor >= op1_count - shift_limbs then
|
||||
target [target_offset + shift_limbs + cursor] := op2_limb
|
||||
else
|
||||
target [target_offset + shift_limbs + cursor] := op2_limb.bit_xor (op1 [op1_offset + shift_limbs + cursor])
|
||||
cursor := cursor + 1
|
||||
target.copy_data (op1, op1_offset + shift_limbs + cursor, target_offset + shift_limbs + cursor, op1_count - cursor - shift_limbs)
|
||||
end
|
||||
else
|
||||
from
|
||||
until
|
||||
cursor >= op2_count
|
||||
loop
|
||||
op2_limb_low := op2_limb_high
|
||||
op2_limb_high := op2 [op2_offset + cursor]
|
||||
op2_limb := extract_limb (shift_bits, op2_limb_high, op2_limb_low)
|
||||
target [target_offset + shift_limbs + cursor] := op2_limb
|
||||
cursor := cursor + 1
|
||||
end
|
||||
op2_limb_low := op2_limb_high
|
||||
op2_limb := extract_limb (shift_bits, 0, op2_limb_low)
|
||||
target [target_offset + shift_limbs + cursor] := op2_limb
|
||||
end
|
||||
end
|
||||
|
||||
bit_xor (target: SPECIAL [NATURAL_32]; target_offset: INTEGER; op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER; op1_count: INTEGER; op2: SPECIAL [NATURAL_32]; op2_offset: INTEGER; op2_count: INTEGER)
|
||||
require
|
||||
(op1_count = 0 and op2_count = 0) or target.valid_index (target_offset)
|
||||
(op1_count = 0 and op2_count = 0) or target.valid_index (target_offset + op1_count.max (op2_count) - 1)
|
||||
local
|
||||
cursor: INTEGER
|
||||
min: INTEGER
|
||||
do
|
||||
from
|
||||
min := op1_count.min (op2_count)
|
||||
until
|
||||
cursor >= min
|
||||
loop
|
||||
target [target_offset + cursor] := op1 [op1_offset + cursor].bit_xor (op2 [op2_offset + cursor])
|
||||
cursor := cursor + 1
|
||||
end
|
||||
if op1_count > op2_count then
|
||||
target.copy_data (op1, op1_offset + cursor, target_offset + cursor, op1_count - cursor)
|
||||
elseif op2_count > op1_count then
|
||||
target.copy_data (op2, op2_offset + cursor, target_offset + cursor, op2_count - cursor)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,849 @@
|
||||
note
|
||||
description: "Summary description for {NUMBER_NUMBER_THEORETIC}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "The best argument against democracy is a five-minute conversation with the average voter. - Winston Churchill"
|
||||
|
||||
deferred class
|
||||
SPECIAL_NUMBER_THEORETIC
|
||||
|
||||
inherit
|
||||
SPECIAL_DIVISION
|
||||
SPECIAL_UTILITY
|
||||
SPECIAL_LOGIC
|
||||
LIMB_MANIPULATION
|
||||
|
||||
feature
|
||||
|
||||
gcdext_div2 (n1_a: NATURAL_32; n0_a: NATURAL_32; d1_a: NATURAL_32; d0_a: NATURAL_32): NATURAL_32
|
||||
require
|
||||
d1_a /= 0 or d0_a /= 0
|
||||
local
|
||||
q: NATURAL_32
|
||||
count: INTEGER
|
||||
d1: NATURAL_32
|
||||
d0: NATURAL_32
|
||||
n1: CELL [NATURAL_32]
|
||||
n0: CELL [NATURAL_32]
|
||||
do
|
||||
create n1.put (n1_a)
|
||||
create n0.put (n0_a)
|
||||
d1 := d1_a
|
||||
d0 := d0_a
|
||||
if n1.item.bit_test (limb_high_bit) then
|
||||
from
|
||||
count := 1
|
||||
invariant
|
||||
d1 /= 0 or d0 /= 0
|
||||
until
|
||||
d1.bit_test (limb_high_bit)
|
||||
loop
|
||||
d1 := (d1 |<< 1).bit_or (d0 |>> (limb_bits - 1))
|
||||
d0 := d0 |<< 1
|
||||
count := count + 1
|
||||
end
|
||||
q := 0
|
||||
from
|
||||
until
|
||||
count = 0
|
||||
loop
|
||||
q := q |<< 1
|
||||
if n1.item > d1 or (n1.item = d1 and n0.item >= d0) then
|
||||
sub_ddmmss (n1, n0, n1.item, n0.item, d1, d0)
|
||||
q := q.bit_or (1)
|
||||
end
|
||||
d0 := (d1 |<< (limb_bits - 1)).bit_or (d0 |>> 1)
|
||||
d1 := d1 |>> 1
|
||||
count := count - 1
|
||||
end
|
||||
Result := q
|
||||
else
|
||||
from
|
||||
count := 0
|
||||
until
|
||||
n1.item <= d1 and (n1.item /= d1 or n0.item < d0)
|
||||
loop
|
||||
d1 := (d1 |<< 1).bit_or (d0 |>> (limb_bits - 1))
|
||||
d0 := d0 |<< 1
|
||||
count := count + 1
|
||||
end
|
||||
q := 0
|
||||
from
|
||||
until
|
||||
count = 0
|
||||
loop
|
||||
d0 := (d1 |<< (limb_bits - 1)).bit_or (d0 |>> 1)
|
||||
d1 := d1 |>> 1
|
||||
q := q |<< 1
|
||||
if n1.item > d1 or (n1.item = d1 and n0.item >= d0) then
|
||||
sub_ddmmss (n1, n0, n1.item, n0.item, d1, d0)
|
||||
q := q.bit_or (1)
|
||||
end
|
||||
count := count - 1
|
||||
end
|
||||
Result := q
|
||||
end
|
||||
end
|
||||
|
||||
basic_gcdext (target: SPECIAL [NATURAL_32]; target_offset: INTEGER_32; cofactor: SPECIAL [NATURAL_32]; cofactor_offset: INTEGER_32; cofactor_count: TUPLE [cofactor_count: INTEGER_32]; op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER_32; op1_count: INTEGER_32; op2: SPECIAL [NATURAL_32]; op2_offset: INTEGER_32; op2_count: INTEGER_32): INTEGER
|
||||
require
|
||||
op1_count >= op2_count
|
||||
target.valid_index (target_offset)
|
||||
target.valid_index (target_offset + op1_count - 1)
|
||||
cofactor.valid_index (cofactor_offset)
|
||||
cofactor.valid_index (cofactor_offset + op1_count - 1)
|
||||
op1.valid_index (op1_offset)
|
||||
op1.valid_index (op1_offset + op1_count - 0)
|
||||
op1 [op1_offset + op1_count - 1] /= 0
|
||||
op2.valid_index (op2_offset)
|
||||
op2.valid_index (op2_offset + op2_count - 0)
|
||||
op2 [op2_offset + op2_count - 1] /= 0
|
||||
op2_count >= 1
|
||||
local
|
||||
tp: SPECIAL [NATURAL_32]
|
||||
tp_offset: INTEGER_32
|
||||
s1p: SPECIAL [NATURAL_32]
|
||||
s1p_offset: INTEGER
|
||||
do
|
||||
create tp.make_filled (0, op1_count + 1)
|
||||
tp_offset := 0
|
||||
create s1p.make_filled (0, op1_count + 1)
|
||||
s1p_offset := 0
|
||||
cofactor.fill_with (0, cofactor_offset, cofactor_offset + op1_count - 1)
|
||||
s1p.fill_with (0, s1p_offset, s1p_offset + op1_count - 1)
|
||||
cofactor [cofactor_offset] := 1
|
||||
s1p [s1p_offset] := 0
|
||||
if op1_count > op2_count then
|
||||
tdiv_qr (tp, tp_offset, op1, op1_offset, op1, op1_offset, op1_count, op2, op2_offset, op2_count)
|
||||
cofactor [cofactor_offset] := 0
|
||||
s1p [s1p_offset] := 1
|
||||
Result := basic_gcdext_arranged (target, target_offset, cofactor, cofactor_offset, cofactor_count, op2, op2_offset, op2_count, op1, op1_offset, op1_count, -1, s1p, s1p_offset, tp, tp_offset)
|
||||
else
|
||||
Result := basic_gcdext_arranged (target, target_offset, cofactor, cofactor_offset, cofactor_count, op1, op1_offset, op1_count, op2, op2_offset, op2_count, 1, s1p, s1p_offset, tp, tp_offset)
|
||||
end
|
||||
end
|
||||
|
||||
basic_gcdext_arranged (target: SPECIAL [NATURAL_32]; target_offset: INTEGER_32; cofactor_a: SPECIAL [NATURAL_32]; cofactor_offset_a: INTEGER_32; cofactor_count: TUPLE [cofactor_count: INTEGER_32]; op1_a: SPECIAL [NATURAL_32]; op1_offset_a: INTEGER_32; op1_count_a: INTEGER_32; op2_a: SPECIAL [NATURAL_32]; op2_offset_a: INTEGER_32; op2_count_a: INTEGER_32; sign_a: INTEGER; s1p_a: SPECIAL [NATURAL_32]; s1p_offset_a: INTEGER; tp_a: SPECIAL [NATURAL_32]; tp_offset_a: INTEGER): INTEGER
|
||||
local
|
||||
a: NATURAL_32
|
||||
b: NATURAL_32
|
||||
c: NATURAL_32
|
||||
d: NATURAL_32
|
||||
wp: SPECIAL [NATURAL_32]
|
||||
wp_offset: INTEGER_32
|
||||
orig_s0p: SPECIAL [NATURAL_32]
|
||||
orig_s0p_offset: INTEGER
|
||||
use_double_flag: BOOLEAN
|
||||
cnt: INTEGER_32
|
||||
assign_l: NATURAL_32
|
||||
op2_count: INTEGER
|
||||
done: BOOLEAN
|
||||
done_2: BOOLEAN
|
||||
uh: NATURAL_32
|
||||
vh: NATURAL_32
|
||||
ul: NATURAL_32
|
||||
vl: NATURAL_32
|
||||
tac: NATURAL_32
|
||||
tbd: NATURAL_32
|
||||
q1: NATURAL_32
|
||||
q2: NATURAL_32
|
||||
nh: CELL [NATURAL_32]
|
||||
nl: CELL [NATURAL_32]
|
||||
dh: CELL [NATURAL_32]
|
||||
dl: CELL [NATURAL_32]
|
||||
t1: CELL [NATURAL_32]
|
||||
t0: CELL [NATURAL_32]
|
||||
thigh: CELL [NATURAL_32]
|
||||
tlow: CELL [NATURAL_32]
|
||||
sign: INTEGER
|
||||
q: NATURAL_32
|
||||
t: NATURAL_32
|
||||
ssize: INTEGER_32
|
||||
qsize: INTEGER_32
|
||||
i: INTEGER_32
|
||||
cy: NATURAL_32
|
||||
cofactor: SPECIAL [NATURAL_32]
|
||||
cofactor_offset: INTEGER_32
|
||||
op1: SPECIAL [NATURAL_32]
|
||||
op1_offset: INTEGER_32
|
||||
op2: SPECIAL [NATURAL_32]
|
||||
op2_offset: INTEGER_32
|
||||
tp: SPECIAL [NATURAL_32]
|
||||
tp_offset: INTEGER_32
|
||||
s1p: SPECIAL [NATURAL_32]
|
||||
s1p_offset: INTEGER_32
|
||||
temp_special: SPECIAL [NATURAL_32]
|
||||
temp_integer: INTEGER_32
|
||||
op1_count: INTEGER
|
||||
tsize: INTEGER
|
||||
wsize: INTEGER
|
||||
junk: NATURAL_32
|
||||
cy1: NATURAL_32
|
||||
cy2: NATURAL_32
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
cofactor := cofactor_a
|
||||
cofactor_offset := cofactor_offset_a
|
||||
op1 := op1_a
|
||||
op1_offset := op1_offset_a
|
||||
op1_count := op1_count_a
|
||||
op2 := op2_a
|
||||
op2_offset := op2_offset_a
|
||||
tp := tp_a
|
||||
tp_offset := tp_offset_a
|
||||
s1p := s1p_a
|
||||
s1p_offset := s1p_offset_a
|
||||
ssize := 1
|
||||
sign := sign_a
|
||||
op2_count := op2_count_a
|
||||
orig_s0p := cofactor
|
||||
orig_s0p_offset := cofactor_offset
|
||||
create wp.make_filled (0, op1_count + 1)
|
||||
wp_offset := 0
|
||||
use_double_flag := op1_count > 17
|
||||
from
|
||||
until
|
||||
done
|
||||
loop
|
||||
op2_count := op1_count
|
||||
op2_count := normalize (op2, op2_offset, op2_count)
|
||||
if op2_count <= 1 then
|
||||
done := True
|
||||
else
|
||||
if use_double_flag then
|
||||
uh := op1 [op1_count - 1]
|
||||
vh := op2 [op1_count - 1]
|
||||
ul := op1 [op1_count - 2]
|
||||
vl := op2 [op1_count - 2]
|
||||
cnt := leading_zeros (uh)
|
||||
if cnt /= 0 then
|
||||
uh := (uh |<< cnt).bit_or (ul |>> (32 - cnt))
|
||||
vh := (vh |<< cnt).bit_or (vl |>> (32 - cnt))
|
||||
vl := vl |<< cnt
|
||||
ul := ul |<< cnt
|
||||
if op1_count >= 3 then
|
||||
ul := ul.bit_or (op1 [op1_offset + op1_count - 3] |>> (32 - cnt))
|
||||
vl := vl.bit_or (op2 [op2_offset + op1_count - 3] |>> (32 - cnt))
|
||||
end
|
||||
end
|
||||
a := 1
|
||||
b := 0
|
||||
c := 0
|
||||
d := 1
|
||||
assign_l := 0
|
||||
from
|
||||
done_2 := False
|
||||
create nh.put (0)
|
||||
create nl.put (0)
|
||||
create dh.put (0)
|
||||
create dl.put (0)
|
||||
create thigh.put (0)
|
||||
create tlow.put (0)
|
||||
create t1.put (0)
|
||||
create t0.put (0)
|
||||
until
|
||||
done_2
|
||||
loop
|
||||
sub_ddmmss (dh, dl, vh, vl, 0, c)
|
||||
if dh.item = 0 then
|
||||
done_2 := True
|
||||
else
|
||||
add_ssaaaa (nh, nl, uh, ul, 0, a)
|
||||
q1 := gcdext_div2 (nh.item, nl.item, dh.item, dl.item)
|
||||
add_ssaaaa (dh, dl, vh, vl, 0, d)
|
||||
if dh.item = 0 then
|
||||
done_2 := True
|
||||
else
|
||||
sub_ddmmss (nh, nl, uh, ul, 0, b)
|
||||
q2 := gcdext_div2 (nh.item, nl.item, dh.item, dl.item)
|
||||
if q1 /= q2 then
|
||||
done_2 := True
|
||||
else
|
||||
tac := a + q1 * c
|
||||
tbd := b + q1 * d
|
||||
a := c
|
||||
c := tac
|
||||
b := d
|
||||
d := tbd
|
||||
umul_ppmm (t1, t0, q1, vl)
|
||||
t1.put (t1.item + q1 * vh)
|
||||
sub_ddmmss (thigh, tlow, uh, ul, t1.item, t0.item)
|
||||
uh := vh
|
||||
ul := vl
|
||||
vh := thigh.item
|
||||
vl := tlow.item
|
||||
assign_l := assign_l.bit_not
|
||||
add_ssaaaa (dh, dl, vh, vl, 0, c)
|
||||
sub_ddmmss (nh, nl, uh, ul, 0, a)
|
||||
q1 := gcdext_div2 (nh.item, nl.item, dh.item, dl.item)
|
||||
sub_ddmmss (dh, dl, vh, vl, 0, d)
|
||||
if dh.item = 0 then
|
||||
done_2 := True
|
||||
else
|
||||
add_ssaaaa (nh, nl, uh, ul, 0, b)
|
||||
q2 := gcdext_div2 (nh.item, nl.item, dh.item, dl.item)
|
||||
if q1 /= q2 then
|
||||
done_2 := True
|
||||
else
|
||||
tac := a + q1 * c
|
||||
tbd := b + q1 * d
|
||||
a := c
|
||||
c := tac
|
||||
b := d
|
||||
d := tbd
|
||||
umul_ppmm (t1, t0, q1, vl)
|
||||
t1.put (t1.item + (q1 * vh))
|
||||
sub_ddmmss (thigh, tlow, uh, ul, t1.item, t0.item)
|
||||
uh := vh
|
||||
ul := vl
|
||||
vh := thigh.item
|
||||
vl := tlow.item
|
||||
assign_l := assign_l.bit_not
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if assign_l /= 0 then
|
||||
sign := -sign
|
||||
end
|
||||
else
|
||||
uh := op1 [op1_offset + op1_count - 1]
|
||||
vh := op2 [op2_offset + op1_count - 1]
|
||||
cnt := leading_zeros (uh)
|
||||
if cnt /= 0 then
|
||||
uh := (uh |<< cnt).bit_or (op1 [op1_offset + op1_count - 2] |>> (limb_bits - cnt))
|
||||
vh := (vh |<< cnt).bit_or (op2 [op2_offset + op1_count - 2] |>> (limb_bits - cnt))
|
||||
end
|
||||
a := 1
|
||||
b := 0
|
||||
c := 0
|
||||
d := 1
|
||||
assign_l := 0
|
||||
from
|
||||
done_2 := False
|
||||
until
|
||||
done_2
|
||||
loop
|
||||
if vh - c = 0 or vh + d = 0 then
|
||||
done_2 := True
|
||||
else
|
||||
q := (uh + a) // (vh - c)
|
||||
if q /= (uh - b) // (vh + d) then
|
||||
done_2 := True
|
||||
else
|
||||
t := a + q * c
|
||||
a := c
|
||||
c := t
|
||||
t := b + q * d
|
||||
b := d
|
||||
d := t
|
||||
t := uh - q * vh
|
||||
uh := vh
|
||||
vh := t
|
||||
assign_l := assign_l.bit_not
|
||||
if vh - d = 0 then
|
||||
done_2 := True
|
||||
else
|
||||
q := (uh - a) // (vh + c)
|
||||
if q /= (uh + b) // (vh - d) then
|
||||
done_2 := True
|
||||
else
|
||||
t := a + q * c
|
||||
a := c
|
||||
c := t
|
||||
t := b + q * d
|
||||
b := d
|
||||
d := t
|
||||
t := uh - q * vh
|
||||
uh := vh
|
||||
vh := t
|
||||
assign_l := assign_l.bit_not
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if assign_l /= 0 then
|
||||
sign := -sign
|
||||
end
|
||||
end
|
||||
if b = 0 then
|
||||
tdiv_qr (wp, wp_offset, op1, op1_offset, op1, op1_offset, op1_count, op2, op2_offset, op2_count)
|
||||
tp.copy_data (cofactor, cofactor_offset, tp_offset, ssize)
|
||||
qsize := op1_count - op2_count + 1
|
||||
s1p.fill_with (0, s1p_offset + ssize, s1p_offset + ssize + qsize - 1)
|
||||
from
|
||||
i := 0
|
||||
until
|
||||
i >= qsize
|
||||
loop
|
||||
addmul_1 (tp, tp_offset + i, s1p, s1p_offset, ssize, wp [wp_offset + i], carry)
|
||||
cy := carry.item
|
||||
tp [tp_offset + ssize + i] := cy
|
||||
i := i + 1
|
||||
end
|
||||
ssize := ssize + qsize
|
||||
ssize := ssize - (tp [tp_offset + ssize - 1] = 0).to_integer
|
||||
sign := -sign
|
||||
temp_special := cofactor
|
||||
temp_integer := cofactor_offset
|
||||
cofactor := s1p
|
||||
cofactor_offset := s1p_offset
|
||||
s1p := temp_special
|
||||
s1p_offset := temp_integer
|
||||
temp_special := s1p
|
||||
temp_integer := s1p_offset
|
||||
s1p := tp
|
||||
s1p_offset := tp_offset
|
||||
tp := temp_special
|
||||
tp_offset := temp_integer
|
||||
op1_count := op2_count
|
||||
temp_special := op1
|
||||
temp_integer := op1_offset
|
||||
op1 := op2
|
||||
op1_offset := op2_offset
|
||||
op2 := temp_special
|
||||
op2_offset := temp_integer
|
||||
else
|
||||
if a = 0 then
|
||||
tp.copy_data (op2, op2_offset, tp_offset, op1_count)
|
||||
wp.copy_data (op1, op1_offset, wp_offset, op1_count)
|
||||
submul_1 (wp, wp_offset, op2, op2_offset, op1_count, d, carry)
|
||||
junk := carry.item
|
||||
temp_special := tp
|
||||
temp_integer := tp_offset
|
||||
tp := op1
|
||||
tp_offset := op1_offset
|
||||
op1 := temp_special
|
||||
op1_offset := temp_integer
|
||||
temp_special := wp
|
||||
temp_integer := wp_offset
|
||||
wp := op2
|
||||
wp_offset := op2_offset
|
||||
op2 := temp_special
|
||||
op2_offset := temp_integer
|
||||
tp.copy_data (s1p, s1p_offset, tp_offset, ssize)
|
||||
tsize := ssize
|
||||
tp [tp_offset + ssize] := 0
|
||||
wp.copy_data (cofactor, cofactor_offset, wp_offset, ssize)
|
||||
addmul_1 (wp, wp_offset, s1p, s1p_offset, ssize, d, carry)
|
||||
cy := carry.item
|
||||
wp [wp_offset + ssize] := cy
|
||||
wsize := ssize + (cy /= 0).to_integer
|
||||
temp_special := tp
|
||||
temp_integer := tp_offset
|
||||
tp := cofactor
|
||||
tp_offset := cofactor_offset
|
||||
cofactor := temp_special
|
||||
cofactor_offset := temp_integer
|
||||
temp_special := wp
|
||||
temp_integer := wp_offset
|
||||
wp := s1p
|
||||
wp_offset := s1p_offset
|
||||
s1p := temp_special
|
||||
s1p_offset := temp_integer
|
||||
ssize := wsize.max (tsize)
|
||||
else
|
||||
if assign_l /= 0 then
|
||||
mul_1 (tp, tp_offset, op2, op2_offset, op1_count, b, carry)
|
||||
junk := carry.item
|
||||
submul_1 (tp, tp_offset, op1, op1_offset, op1_count, a, carry)
|
||||
junk := carry.item
|
||||
mul_1 (wp, wp_offset, op1, op1_offset, op1_count, c, carry)
|
||||
junk := carry.item
|
||||
submul_1 (wp, wp_offset, op2, op2_offset, op1_count, d, carry)
|
||||
junk := carry.item
|
||||
else
|
||||
mul_1 (tp, tp_offset, op1, op1_offset, op1_count, a, carry)
|
||||
junk := carry.item
|
||||
submul_1 (tp, tp_offset, op2, op2_offset, op1_count, b, carry)
|
||||
junk := carry.item
|
||||
mul_1 (wp, wp_offset, op2, op2_offset, op1_count, d, carry)
|
||||
junk := carry.item
|
||||
submul_1 (wp, wp_offset, op1, op1_offset, op1_count, c, carry)
|
||||
junk := carry.item
|
||||
end
|
||||
temp_special := tp
|
||||
temp_integer := tp_offset
|
||||
tp := op1
|
||||
tp_offset := op1_offset
|
||||
op1 := temp_special
|
||||
op1_offset := temp_integer
|
||||
temp_special := wp
|
||||
temp_integer := wp_offset
|
||||
wp := op2
|
||||
wp_offset := op2_offset
|
||||
op2 := temp_special
|
||||
op2_offset := temp_integer
|
||||
mul_1 (tp, tp_offset, cofactor, cofactor_offset, ssize, a, carry)
|
||||
cy1 := carry.item
|
||||
addmul_1 (tp, tp_offset, s1p, s1p_offset, ssize, b, carry)
|
||||
cy2 := carry.item
|
||||
cy := cy1 + cy2
|
||||
tp [tp_offset + ssize] := cy
|
||||
tsize := ssize + (cy /= 0).to_integer
|
||||
if cy < cy1 then
|
||||
tp [tp_offset + tsize] := 1
|
||||
wp [wp_offset + tsize] := 0
|
||||
tsize := tsize + 1
|
||||
end
|
||||
mul_1 (wp, wp_offset, s1p, s1p_offset, ssize, d, carry)
|
||||
cy1 := carry.item
|
||||
addmul_1 (wp, wp_offset, cofactor, cofactor_offset, ssize, c, carry)
|
||||
cy2 := carry.item
|
||||
cy := cy1 + cy2
|
||||
wp [wp_offset + ssize] := cy
|
||||
wsize := ssize + (cy /= 0).to_integer
|
||||
if cy < cy1 then
|
||||
wp [wp_offset + wsize] := 1
|
||||
if wsize >= tsize then
|
||||
tp [tp_offset + wsize] := 0
|
||||
end
|
||||
wsize := wsize + 1
|
||||
end
|
||||
temp_special := tp
|
||||
temp_integer := tp_offset
|
||||
tp := cofactor
|
||||
tp_offset := cofactor_offset
|
||||
cofactor := temp_special
|
||||
cofactor_offset := temp_integer
|
||||
temp_special := wp
|
||||
temp_integer := wp_offset
|
||||
wp := s1p
|
||||
wp_offset := s1p_offset
|
||||
s1p := temp_special
|
||||
s1p_offset := temp_integer
|
||||
ssize := wsize.max (tsize)
|
||||
end
|
||||
op1_count := op1_count - (op1 [op1_offset + op1_count - 1] = 0).to_integer
|
||||
end
|
||||
end
|
||||
end
|
||||
if op2_count = 0 then
|
||||
if target /= op1 then
|
||||
target.copy_data (op1, op1_offset, target_offset, op1_count)
|
||||
end
|
||||
ssize := normalize (cofactor, cofactor_offset, ssize)
|
||||
if orig_s0p /= cofactor then
|
||||
orig_s0p.copy_data (cofactor, cofactor_offset, orig_s0p_offset, ssize)
|
||||
end
|
||||
if sign >= 0 then
|
||||
cofactor_count.cofactor_count := ssize
|
||||
else
|
||||
cofactor_count.cofactor_count := -ssize
|
||||
end
|
||||
Result := op1_count
|
||||
else
|
||||
vl := op2 [op2_offset]
|
||||
t := divrem_1 (wp, wp_offset, op1, op1_offset, op1_count, vl)
|
||||
tp.copy_data (cofactor, cofactor_offset, tp_offset, ssize)
|
||||
qsize := op1_count - (wp [wp_offset + op1_count - 1] = 0).to_integer
|
||||
if ssize < qsize then
|
||||
tp.fill_with (0, tp_offset + ssize, qsize - ssize)
|
||||
s1p.fill_with (0, s1p_offset + ssize, qsize)
|
||||
from
|
||||
i := 0
|
||||
until
|
||||
i >= ssize
|
||||
loop
|
||||
addmul_1 (tp, tp_offset + i, wp, wp_offset, qsize, s1p [s1p_offset + i], carry)
|
||||
cy := carry.item
|
||||
tp [tp_offset + qsize + i] := cy
|
||||
i := i + 1
|
||||
end
|
||||
else
|
||||
s1p.fill_with (0, s1p_offset + ssize, s1p_offset + ssize + qsize - 1)
|
||||
from
|
||||
i := 0
|
||||
until
|
||||
i >= qsize
|
||||
loop
|
||||
addmul_1 (tp, tp_offset + i, s1p, s1p_offset, ssize, wp [wp_offset + i], carry)
|
||||
cy := carry.item
|
||||
tp [tp_offset + ssize + i] := cy
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
ssize := ssize + qsize
|
||||
ssize := ssize - (tp [tp_offset + ssize - 1] = 0).to_integer
|
||||
sign := -sign
|
||||
temp_special := cofactor
|
||||
temp_integer := cofactor_offset
|
||||
cofactor := s1p
|
||||
cofactor_offset := s1p_offset
|
||||
s1p := temp_special
|
||||
s1p_offset := temp_integer
|
||||
temp_special := s1p
|
||||
temp_integer := s1p_offset
|
||||
s1p := tp
|
||||
s1p_offset := tp_offset
|
||||
tp := temp_special
|
||||
tp_offset := temp_integer
|
||||
ul := vl
|
||||
vl := t
|
||||
from
|
||||
until
|
||||
vl = 0
|
||||
loop
|
||||
q := ul // vl
|
||||
t := ul - q * vl
|
||||
tp.copy_data (cofactor, cofactor_offset, tp_offset, ssize)
|
||||
s1p.fill_with (0, s1p_offset + ssize, s1p_offset + ssize)
|
||||
addmul_1 (tp, tp_offset, s1p, s1p_offset, ssize, q, carry)
|
||||
cy := carry.item
|
||||
tp [tp_offset + ssize] := cy
|
||||
ssize := ssize + 1
|
||||
ssize := ssize - (tp [tp_offset + ssize - 1] = 0).to_integer
|
||||
sign := -sign
|
||||
temp_special := cofactor
|
||||
temp_integer := cofactor_offset
|
||||
cofactor := s1p
|
||||
cofactor_offset := s1p_offset
|
||||
s1p := temp_special
|
||||
s1p_offset := temp_integer
|
||||
temp_special := s1p
|
||||
temp_integer := s1p_offset
|
||||
s1p := tp
|
||||
s1p_offset := tp_offset
|
||||
tp := temp_special
|
||||
tp_offset := temp_integer
|
||||
ul := vl
|
||||
vl := t
|
||||
end
|
||||
target [target_offset] := ul
|
||||
ssize := normalize (cofactor, cofactor_offset, ssize)
|
||||
if orig_s0p /= cofactor then
|
||||
orig_s0p.copy_data (cofactor, cofactor_offset, orig_s0p_offset, ssize)
|
||||
end
|
||||
if sign >= 0 then
|
||||
cofactor_count.cofactor_count := ssize
|
||||
else
|
||||
cofactor_count.cofactor_count := -ssize
|
||||
end
|
||||
Result := 1
|
||||
end
|
||||
end
|
||||
|
||||
gcdext (target: SPECIAL [NATURAL_32]; target_offset: INTEGER; cofactor: SPECIAL [NATURAL_32]; cofactor_offset: INTEGER; cofactor_count: TUPLE [cofactor_count: INTEGER]; op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER; op1_count: INTEGER; op2: SPECIAL [NATURAL_32]; op2_offset: INTEGER; op2_count: INTEGER): INTEGER
|
||||
require
|
||||
op1_count >= op2_count
|
||||
op2_count >= 0
|
||||
op1.valid_index (op1_offset)
|
||||
op1.valid_index (op1_offset + op1_count - 0)
|
||||
op1 [op1_offset + op1_count - 1] /= 0
|
||||
op2.valid_index (op2_offset)
|
||||
op2.valid_index (op2_offset + op2_count - 0)
|
||||
op1 [op1_offset + op1_count - 1] /= 0
|
||||
target.valid_index (target_offset)
|
||||
target.valid_index (target_offset + op1_count - 1)
|
||||
cofactor.valid_index (cofactor_offset)
|
||||
cofactor.valid_index (cofactor_offset + op1_count - 1)
|
||||
local
|
||||
orig_n: INTEGER
|
||||
do
|
||||
orig_n := op2_count
|
||||
Result := basic_gcdext (target, target_offset, cofactor, cofactor_offset, cofactor_count, op1, op1_offset, op1_count, op2, op2_offset, op2_count)
|
||||
end
|
||||
|
||||
modexact_1c_odd (op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER; op1_count: INTEGER; d: NATURAL_32; orig_c: NATURAL_32): NATURAL_32
|
||||
require
|
||||
op1_count >= 1
|
||||
d.bit_test (0)
|
||||
local
|
||||
s: NATURAL_32
|
||||
h: CELL [NATURAL_32]
|
||||
l: CELL [NATURAL_32]
|
||||
inverse: NATURAL_32
|
||||
dummy: CELL [NATURAL_32]
|
||||
dmul: NATURAL_32
|
||||
c: CELL [NATURAL_32]
|
||||
i: INTEGER
|
||||
do
|
||||
create l.put (0)
|
||||
create c.put (orig_c)
|
||||
create h.put (0)
|
||||
create dummy.put (0)
|
||||
if op1_count = 1 then
|
||||
s := op1 [op1_offset]
|
||||
if s > c.item then
|
||||
l.put (s - c.item)
|
||||
h.put (l.item \\ d)
|
||||
if h.item /= 0 then
|
||||
h.put (d - h.item)
|
||||
end
|
||||
else
|
||||
l.put (c.item - s)
|
||||
h.put (l.item \\ d)
|
||||
end
|
||||
Result := h.item
|
||||
else
|
||||
inverse := modlimb_invert (d)
|
||||
dmul := d
|
||||
from
|
||||
i := 0
|
||||
until
|
||||
i >= op1_count - 1
|
||||
loop
|
||||
s := op1 [op1_offset + i]
|
||||
subc_limb (c, l, s, c.item)
|
||||
l.put (l.item * inverse)
|
||||
umul_ppmm (h, dummy, l.item, dmul)
|
||||
c.put (c.item + h.item)
|
||||
i := i + 1
|
||||
end
|
||||
s := op1 [op1_offset + i]
|
||||
if s <= d then
|
||||
l.put (c.item - s)
|
||||
if c.item < s then
|
||||
l.put (l.item + d)
|
||||
end
|
||||
Result := l.item
|
||||
else
|
||||
subc_limb (c, l, s, c.item)
|
||||
l.put (l.item * inverse)
|
||||
umul_ppmm (h, dummy, l.item, dmul)
|
||||
c.put (c.item + h.item)
|
||||
Result := c.item
|
||||
end
|
||||
end
|
||||
ensure
|
||||
orig_c < d implies Result < d
|
||||
orig_c >= d implies Result <= d
|
||||
end
|
||||
|
||||
preinv_mod_1 (up: SPECIAL [NATURAL_32]; up_offset: INTEGER; un: INTEGER; d: NATURAL_32; dinv: NATURAL_32): NATURAL_32
|
||||
require
|
||||
un >= 1
|
||||
d.bit_test (31)
|
||||
local
|
||||
i: INTEGER
|
||||
n0: NATURAL_32
|
||||
r: CELL [NATURAL_32]
|
||||
dummy: CELL [NATURAL_32]
|
||||
do
|
||||
create r.put (up [up_offset + un - 1])
|
||||
create dummy.put (0)
|
||||
if r.item >= d then
|
||||
r.put (r.item - d)
|
||||
end
|
||||
from
|
||||
i := un - 2
|
||||
until
|
||||
i < 0
|
||||
loop
|
||||
n0 := up [up_offset + i]
|
||||
udiv_qrnnd_preinv (dummy, r, r.item, n0, d, dinv)
|
||||
i := i - 1
|
||||
end
|
||||
Result := r.item
|
||||
end
|
||||
|
||||
redc_basecase (cp: SPECIAL [NATURAL_32]; cp_offset: INTEGER; mp: SPECIAL [NATURAL_32]; mp_offset: INTEGER; n: INTEGER; n_prim: NATURAL_32; tp: SPECIAL [NATURAL_32]; tp_offset_a: INTEGER)
|
||||
local
|
||||
cy: NATURAL_32
|
||||
q: NATURAL_32
|
||||
j: INTEGER
|
||||
tp_offset: INTEGER
|
||||
junk: NATURAL_32
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
tp_offset := tp_offset_a
|
||||
from
|
||||
j := 0
|
||||
until
|
||||
j >= n
|
||||
loop
|
||||
q := tp [tp_offset] * n_prim
|
||||
addmul_1 (tp, tp_offset, mp, mp_offset, n, q, carry)
|
||||
tp [tp_offset] := carry.item
|
||||
tp_offset := tp_offset + 1
|
||||
j := j + 1
|
||||
end
|
||||
add_n (cp, cp_offset, tp, tp_offset, tp, tp_offset - n, n, carry)
|
||||
cy := carry.item
|
||||
if cy /= 0 then
|
||||
sub_n (cp, cp_offset, cp, cp_offset, mp, mp_offset, n, carry)
|
||||
junk := carry.item
|
||||
end
|
||||
end
|
||||
|
||||
subc_limb (cout: CELL [NATURAL_32]; w: CELL [NATURAL_32]; x: NATURAL_32; y: NATURAL_32)
|
||||
do
|
||||
w.put (x - y)
|
||||
cout.put ((w.item > x).to_integer.to_natural_32)
|
||||
end
|
||||
|
||||
invert_gf (target: SPECIAL [NATURAL_32] target_offset: INTEGER op1_a: SPECIAL [NATURAL_32] op1_offset: INTEGER op1_count_a: INTEGER op2_a: SPECIAL [NATURAL_32] op2_offset: INTEGER op2_count_a: INTEGER)
|
||||
-- Invert `op1' over `op2' using the extended euclidian algorithm in F2M
|
||||
require
|
||||
op2_count_a > 0
|
||||
op1_count_a >= 0
|
||||
op1_count_a <= op2_count_a;
|
||||
(op1_count_a = op2_count_a) implies cmp (op1_a, op1_offset, op2_a, op2_offset, op2_count_a) <= 0
|
||||
local
|
||||
op1: SPECIAL [NATURAL_32]
|
||||
op1_count: INTEGER
|
||||
op1_leading_zeros: INTEGER
|
||||
op2: SPECIAL [NATURAL_32]
|
||||
op2_count: INTEGER
|
||||
op2_leading_zeros: INTEGER
|
||||
tmp_special: SPECIAL [NATURAL_32]
|
||||
tmp_integer: INTEGER
|
||||
g1: SPECIAL [NATURAL_32]
|
||||
g1_count: INTEGER
|
||||
g2: SPECIAL [NATURAL_32]
|
||||
g2_count: INTEGER
|
||||
operand_sizes: INTEGER
|
||||
left_shift_amount: INTEGER
|
||||
do
|
||||
operand_sizes := op2_count_a
|
||||
op1_count := op1_count_a
|
||||
op2_count := op2_count_a
|
||||
create op1.make_filled (0, operand_sizes + operand_sizes)
|
||||
create op2.make_filled (0, operand_sizes + operand_sizes)
|
||||
op1.copy_data (op1_a, op1_offset, 0, op1_count.min (operand_sizes))
|
||||
op2.copy_data (op2_a, op2_offset, 0, op2_count.min (operand_sizes))
|
||||
create g1.make_filled (0, operand_sizes + operand_sizes)
|
||||
create g2.make_filled (0, operand_sizes + operand_sizes)
|
||||
g1 [0] := 1
|
||||
g1_count := 1
|
||||
g2_count := 0
|
||||
from
|
||||
until
|
||||
op1_count = 0
|
||||
loop
|
||||
op1_leading_zeros := leading_zeros (op1 [op1_count - 1])
|
||||
op2_leading_zeros := leading_zeros (op2 [op2_count - 1])
|
||||
if op1_count < op2_count or (op1_count = op2_count and op1_leading_zeros > op2_leading_zeros) then
|
||||
tmp_special := op1
|
||||
op1 := op2
|
||||
op2 := tmp_special
|
||||
tmp_special := g1
|
||||
g1 := g2
|
||||
g2 := tmp_special
|
||||
tmp_integer := op1_count
|
||||
op1_count := op2_count
|
||||
op2_count := tmp_integer
|
||||
tmp_integer := op1_leading_zeros
|
||||
op1_leading_zeros := op2_leading_zeros
|
||||
op2_leading_zeros := tmp_integer
|
||||
end
|
||||
if op1_count /= op2_count or (op1_count = op2_count and op1_leading_zeros /= op2_leading_zeros) then
|
||||
left_shift_amount := (op1_count - op2_count) * limb_bits + op2_leading_zeros - op1_leading_zeros
|
||||
bit_xor_lshift (op1, 0, op1, 0, op1_count, op2, 0, op2_count, left_shift_amount)
|
||||
bit_xor_lshift (g1, 0, g1, 0, operand_sizes, g2, 0, operand_sizes, left_shift_amount)
|
||||
else
|
||||
bit_xor (op1, 0, op1, 0, op1_count, op2, 0, op2_count)
|
||||
bit_xor (g1, 0, g1, 0, operand_sizes, g2, 0, operand_sizes)
|
||||
end
|
||||
op1_count := normalize (op1, 0, op1_count)
|
||||
op2_count := normalize (op2, 0, op2_count)
|
||||
end
|
||||
target.copy_data (g2, 0, target_offset, operand_sizes)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,52 @@
|
||||
note
|
||||
description: "Summary description for {NUMBER_SIZING}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "Whatever you do will be insignificant, but it is very important that you do it. - Mahatma Gandhi"
|
||||
|
||||
deferred class
|
||||
SPECIAL_SIZING
|
||||
|
||||
inherit
|
||||
LIMB_MANIPULATION
|
||||
MP_BASES
|
||||
|
||||
feature
|
||||
|
||||
sizeinbase (source: SPECIAL [NATURAL_32]; source_offset: INTEGER; size: INTEGER; base: INTEGER): INTEGER
|
||||
require
|
||||
size >= 0
|
||||
base >= 2
|
||||
local
|
||||
lb_base: INTEGER
|
||||
count: INTEGER
|
||||
total_bits: INTEGER
|
||||
do
|
||||
if size = 0 then
|
||||
Result := 1
|
||||
else
|
||||
count := leading_zeros (source [source_offset + size - 1])
|
||||
total_bits := size * limb_bits - count
|
||||
if pow2_p (base.to_natural_32) then
|
||||
lb_base := big_base (base).to_integer_32
|
||||
Result := (total_bits + lb_base - 1) // lb_base
|
||||
else
|
||||
Result := ((total_bits * chars_per_bit_exactly (base)) + 1).truncated_to_integer
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
sizeinbase_2exp (ptr: SPECIAL [NATURAL_32]; ptr_offset: INTEGER; ptr_count: INTEGER; base2exp: INTEGER): INTEGER
|
||||
require
|
||||
ptr_count > 0
|
||||
ptr [ptr_offset + ptr_count - 1] /= 0
|
||||
local
|
||||
count: INTEGER
|
||||
totbits: INTEGER
|
||||
do
|
||||
count := leading_zeros (ptr [ptr_offset + ptr_count - 1])
|
||||
totbits := ptr_count * limb_bits - count
|
||||
Result := (totbits + base2exp - 1) // base2exp
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,37 @@
|
||||
note
|
||||
description: "Summary description for {NUMBER_UTILITY}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "If a law is unjust, a man is not only right to disobey it, he is obligated to do so. - Thomas Jefferson"
|
||||
|
||||
deferred class
|
||||
SPECIAL_UTILITY
|
||||
|
||||
feature
|
||||
|
||||
normalize (op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER; op1_count: INTEGER): INTEGER
|
||||
do
|
||||
from
|
||||
Result := op1_count
|
||||
until
|
||||
Result <= 0 or op1 [op1_offset + Result - 1] /= 0
|
||||
loop
|
||||
Result := Result - 1
|
||||
end
|
||||
end
|
||||
|
||||
reverse (target: SPECIAL [NATURAL_32]; target_offset: INTEGER; source: SPECIAL [NATURAL_32]; source_offset: INTEGER; count: INTEGER)
|
||||
local
|
||||
i: INTEGER
|
||||
do
|
||||
from
|
||||
i := 0
|
||||
until
|
||||
i >= count
|
||||
loop
|
||||
target [target_offset + i] := source [source_offset + count - 1 - i]
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
66
contrib/ise_library/math/eapml/src/immutable_integer_x.e
Normal file
66
contrib/ise_library/math/eapml/src/immutable_integer_x.e
Normal file
@@ -0,0 +1,66 @@
|
||||
note
|
||||
description: "An INTEGER_X whos value cannot change"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "Freedom is the emancipation from the arbitrary rule of other men. - Mortimer Adler (1902-2001)"
|
||||
|
||||
class
|
||||
IMMUTABLE_INTEGER_X
|
||||
|
||||
inherit
|
||||
READABLE_INTEGER_X
|
||||
|
||||
create
|
||||
default_create,
|
||||
make_from_integer,
|
||||
make_from_integer_64,
|
||||
make_from_integer_32,
|
||||
make_from_integer_16,
|
||||
make_from_integer_8,
|
||||
make_from_natural,
|
||||
make_from_natural_64,
|
||||
make_from_natural_32,
|
||||
make_from_natural_16,
|
||||
make_from_natural_8,
|
||||
make_from_string,
|
||||
make_from_hex_string,
|
||||
make_from_string_base,
|
||||
make_random,
|
||||
make_from_bytes,
|
||||
make_random_prime,
|
||||
make_random_max,
|
||||
make_limbs,
|
||||
make_bits,
|
||||
make_set
|
||||
|
||||
convert
|
||||
to_integer_64: {INTEGER_64},
|
||||
to_integer_32: {INTEGER_32},
|
||||
to_integer_16: {INTEGER_16},
|
||||
to_integer_8: {INTEGER_8},
|
||||
to_natural_64: {NATURAL_64},
|
||||
to_natural_32: {NATURAL_32},
|
||||
to_natural_16: {NATURAL_16},
|
||||
to_natural_8: {NATURAL_8},
|
||||
make_from_integer_64 ({INTEGER_64}),
|
||||
make_from_integer_32 ({INTEGER_32}),
|
||||
make_from_integer_16 ({INTEGER_16}),
|
||||
make_from_integer_8 ({INTEGER_8}),
|
||||
make_from_natural_64 ({NATURAL_64}),
|
||||
make_from_natural_32 ({NATURAL_32}),
|
||||
make_from_natural_16 ({NATURAL_16}),
|
||||
make_from_natural_8 ({NATURAL_8}),
|
||||
make_set ({READABLE_INTEGER_X})
|
||||
|
||||
feature
|
||||
one: like Current
|
||||
do
|
||||
create Result.make_from_integer (1)
|
||||
end
|
||||
|
||||
zero: like Current
|
||||
do
|
||||
create Result
|
||||
end
|
||||
end
|
||||
89
contrib/ise_library/math/eapml/src/integer_x.e
Normal file
89
contrib/ise_library/math/eapml/src/integer_x.e
Normal file
@@ -0,0 +1,89 @@
|
||||
note
|
||||
description: "An arbitrary precision integer"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "'For your own good' is a persuasive argument that will eventually make a man agree to his own destruction. - Janet Frame, Faces In The Water, 1982"
|
||||
|
||||
class
|
||||
INTEGER_X
|
||||
|
||||
inherit
|
||||
READABLE_INTEGER_X
|
||||
export
|
||||
{ANY}
|
||||
abs,
|
||||
plus,
|
||||
minus,
|
||||
product,
|
||||
quotient,
|
||||
opposite,
|
||||
bit_complement,
|
||||
bit_and,
|
||||
bit_or,
|
||||
bit_xor,
|
||||
bit_not,
|
||||
bit_xor_left_shift,
|
||||
bit_shift_right,
|
||||
bit_shift_left,
|
||||
set_bit,
|
||||
powm,
|
||||
inverse,
|
||||
modulo,
|
||||
gcd,
|
||||
invert_gf
|
||||
end
|
||||
|
||||
create
|
||||
default_create,
|
||||
make_from_integer,
|
||||
make_from_integer_64,
|
||||
make_from_integer_32,
|
||||
make_from_integer_16,
|
||||
make_from_integer_8,
|
||||
make_from_natural,
|
||||
make_from_natural_64,
|
||||
make_from_natural_32,
|
||||
make_from_natural_16,
|
||||
make_from_natural_8,
|
||||
make_from_string,
|
||||
make_from_hex_string,
|
||||
make_from_string_base,
|
||||
make_random,
|
||||
make_from_bytes,
|
||||
make_random_prime,
|
||||
make_random_max,
|
||||
make_limbs,
|
||||
make_bits,
|
||||
make_set
|
||||
|
||||
convert
|
||||
to_integer_64: {INTEGER_64},
|
||||
to_integer_32: {INTEGER_32},
|
||||
to_integer_16: {INTEGER_16},
|
||||
to_integer_8: {INTEGER_8},
|
||||
to_natural_64: {NATURAL_64},
|
||||
to_natural_32: {NATURAL_32},
|
||||
to_natural_16: {NATURAL_16},
|
||||
to_natural_8: {NATURAL_8},
|
||||
make_from_integer_64 ({INTEGER_64}),
|
||||
make_from_integer_32 ({INTEGER_32}),
|
||||
make_from_integer_16 ({INTEGER_16}),
|
||||
make_from_integer_8 ({INTEGER_8}),
|
||||
make_from_natural_64 ({NATURAL_64}),
|
||||
make_from_natural_32 ({NATURAL_32}),
|
||||
make_from_natural_16 ({NATURAL_16}),
|
||||
make_from_natural_8 ({NATURAL_8}),
|
||||
make_set ({READABLE_INTEGER_X})
|
||||
|
||||
feature -- Constants
|
||||
one: like Current
|
||||
do
|
||||
create Result.make_from_integer (1)
|
||||
end
|
||||
|
||||
zero: like Current
|
||||
do
|
||||
create Result
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
note
|
||||
description: "An exception when a {STRING} couldn't be parsed in to a {INTEGER_X}"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "Heresy is only another word for freedom of thought. - Graham Greene (1904-1991)"
|
||||
|
||||
class
|
||||
INTEGER_X_STRING_EXCEPTION
|
||||
|
||||
inherit
|
||||
DEVELOPER_EXCEPTION
|
||||
redefine
|
||||
internal_meaning
|
||||
end
|
||||
|
||||
feature
|
||||
internal_meaning: STRING = "Erorr parsing string as INTEGER_X"
|
||||
|
||||
end
|
||||
19
contrib/ise_library/math/eapml/src/inverse_exception.e
Normal file
19
contrib/ise_library/math/eapml/src/inverse_exception.e
Normal file
@@ -0,0 +1,19 @@
|
||||
note
|
||||
description: "An exception when an {INTEGER_X} doesn't have a modular inverse"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "Whenever they burn books they will also, in the end, burn human beings. - Heinrich Heine (1797-1856), Almansor: A Tragedy, 1823"
|
||||
|
||||
class
|
||||
INVERSE_EXCEPTION
|
||||
|
||||
inherit
|
||||
DEVELOPER_EXCEPTION
|
||||
redefine
|
||||
internal_meaning
|
||||
end
|
||||
|
||||
feature
|
||||
internal_meaning: STRING = "No modular inverse"
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
note
|
||||
description: "Summary description for {LIMB_DEFINITION}."
|
||||
author: ""
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
|
||||
deferred class
|
||||
LIMB_DEFINITION
|
||||
|
||||
feature
|
||||
|
||||
limb_high_bit: INTEGER = 31
|
||||
-- Index of the high bit of a limb
|
||||
|
||||
limb_bits: INTEGER = 32
|
||||
-- Number of bits in a limb
|
||||
end
|
||||
@@ -0,0 +1,458 @@
|
||||
note
|
||||
description: "Summary description for {LIMB_MANIPULATION}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
|
||||
deferred class
|
||||
LIMB_MANIPULATION
|
||||
|
||||
inherit
|
||||
LIMB_BIT_SCANNING
|
||||
LIMB_DEFINITION
|
||||
|
||||
feature
|
||||
|
||||
limb_low_bit: INTEGER = 0
|
||||
-- Index of the low bit of a limb
|
||||
|
||||
limb_max: NATURAL_32 = 0xffffffff
|
||||
-- Maximum value of limb type
|
||||
|
||||
integer_to_limb (integer: INTEGER): NATURAL_32
|
||||
require
|
||||
integer >= 0
|
||||
do
|
||||
Result := integer.to_natural_32
|
||||
end
|
||||
|
||||
boolean_to_integer (boolean: BOOLEAN): INTEGER
|
||||
do
|
||||
Result := boolean.to_integer
|
||||
ensure
|
||||
boolean implies Result = 1
|
||||
not boolean implies Result = 0
|
||||
end
|
||||
|
||||
boolean_to_limb (boolean: BOOLEAN): NATURAL_32
|
||||
do
|
||||
Result := boolean_to_integer (boolean).to_natural_32
|
||||
ensure
|
||||
boolean implies Result = 1
|
||||
not boolean implies Result = 0
|
||||
end
|
||||
|
||||
extract_limb (count: INTEGER; xh: NATURAL_32; xl: NATURAL_32): NATURAL_32
|
||||
require
|
||||
count < limb_bits
|
||||
count >= 0
|
||||
do
|
||||
if count = 0 then
|
||||
Result := xh
|
||||
else
|
||||
Result := (xh |<< count).bit_or (xl |>> (limb_bits - count))
|
||||
end
|
||||
end
|
||||
|
||||
write_limb (limb_a: NATURAL_32; target: SPECIAL [NATURAL_8]; target_offset: INTEGER)
|
||||
do
|
||||
target [target_offset] := limb_a.to_natural_8
|
||||
target [target_offset + 1] := (limb_a |>> 8).to_natural_8
|
||||
target [target_offset + 2] := (limb_a |>> 16).to_natural_8
|
||||
target [target_offset + 3] := (limb_a |>> 24).to_natural_8
|
||||
end
|
||||
|
||||
write_limb_be (limb_a: NATURAL_32; target: SPECIAL [NATURAL_8]; target_offset: INTEGER)
|
||||
do
|
||||
target [target_offset] := (limb_a |>> 24).to_natural_8
|
||||
target [target_offset + 1] := (limb_a |>> 16).to_natural_8
|
||||
target [target_offset + 2] := (limb_a |>> 8).to_natural_8
|
||||
target [target_offset + 3] := limb_a.to_natural_8
|
||||
end
|
||||
|
||||
read_limb (source: SPECIAL [NATURAL_8]; source_offset: INTEGER): NATURAL_32
|
||||
do
|
||||
Result := source [source_offset + 3].to_natural_32 |<< 24
|
||||
Result := Result.bit_or (source [source_offset + 2].to_natural_32 |<< 16)
|
||||
Result := Result.bit_or (source [source_offset + 1].to_natural_32 |<< 8)
|
||||
Result := Result.bit_or (source [source_offset].to_natural_32)
|
||||
end
|
||||
|
||||
read_limb_be (source: SPECIAL [NATURAL_8]; source_offset: INTEGER): NATURAL_32
|
||||
do
|
||||
Result := source [source_offset].to_natural_32 |<< 24
|
||||
Result := Result.bit_or (source [source_offset + 1].to_natural_32 |<< 16)
|
||||
Result := Result.bit_or (source [source_offset + 2].to_natural_32 |<< 8)
|
||||
Result := Result.bit_or (source [source_offset + 3].to_natural_32)
|
||||
end
|
||||
|
||||
udiv_qrnnd (q: TUPLE [q: NATURAL_32]; r: TUPLE [r: NATURAL_32]; n1: NATURAL_32; n0: NATURAL_32; d: NATURAL_32)
|
||||
require
|
||||
d /= 0
|
||||
n1 < d
|
||||
local
|
||||
d1: NATURAL_32
|
||||
d0: NATURAL_32
|
||||
q1: NATURAL_32
|
||||
q0: NATURAL_32
|
||||
r1: NATURAL_32
|
||||
r0: NATURAL_32
|
||||
m: NATURAL_32
|
||||
do
|
||||
d1 := d.bit_shift_right (16)
|
||||
d0 := d.bit_and (0xffff)
|
||||
q1 := n1 // d1
|
||||
r1 := n1 - q1 * d1
|
||||
m := q1 * d0
|
||||
r1 := (r1 * 0x10000).bit_or (n0.bit_shift_right (16))
|
||||
if r1 < m then
|
||||
q1 := q1 - 1
|
||||
r1 := r1 + d
|
||||
if r1 >= d then
|
||||
if r1 < m then
|
||||
q1 := q1 - 1
|
||||
r1 := r1 + d
|
||||
end
|
||||
end
|
||||
end
|
||||
r1 := r1 - m
|
||||
q0 := r1 // d1
|
||||
r0 := r1 - q0 * d1
|
||||
m := q0 * d0
|
||||
r0 := (r0 * 0x10000).bit_or (n0.bit_and (0xffff))
|
||||
if r0 < m then
|
||||
q0 := q0 - 1
|
||||
r0 := r0 + d
|
||||
if r0 >= d then
|
||||
if r0 < m then
|
||||
q0 := q0 - 1
|
||||
r0 := r0 + d
|
||||
end
|
||||
end
|
||||
end
|
||||
r0 := r0 - m
|
||||
q.q := (q1 * 0x10000).bit_or (q0)
|
||||
r.r := r0
|
||||
end
|
||||
|
||||
limb_inverse (limb_a: NATURAL_32): NATURAL_32
|
||||
local
|
||||
q: TUPLE [q: NATURAL_32]
|
||||
r: TUPLE [r: NATURAL_32]
|
||||
do
|
||||
create q
|
||||
create r
|
||||
udiv_qrnnd (q, r, limb_a.bit_not, limb_max, limb_a)
|
||||
Result := q.q
|
||||
end
|
||||
|
||||
modlimb_invert (limb_a: NATURAL_32): NATURAL_32
|
||||
require
|
||||
limb_a.bit_test (0)
|
||||
do
|
||||
Result := modlimb_invert_table ((limb_a // 2).bit_and (0x7f).to_natural_8).to_natural_32
|
||||
Result := 2 * Result - Result * Result * limb_a
|
||||
Result := 2 * Result - Result * Result * limb_a
|
||||
end
|
||||
|
||||
modlimb_invert_table (in: NATURAL_8): NATURAL_8
|
||||
require
|
||||
in >= 0
|
||||
in <= 0x7f
|
||||
do
|
||||
inspect in
|
||||
when 0 then
|
||||
Result := 0x01
|
||||
when 1 then
|
||||
Result := 0xab
|
||||
when 2 then
|
||||
Result := 0xcd
|
||||
when 3 then
|
||||
Result := 0xb7
|
||||
when 4 then
|
||||
Result := 0x39
|
||||
when 5 then
|
||||
Result := 0xa3
|
||||
when 6 then
|
||||
Result := 0xc5
|
||||
when 7 then
|
||||
Result := 0xef
|
||||
when 8 then
|
||||
Result := 0xf1
|
||||
when 9 then
|
||||
Result := 0x1b
|
||||
when 10 then
|
||||
Result := 0x3d
|
||||
when 11 then
|
||||
Result := 0xa7
|
||||
when 12 then
|
||||
Result := 0x29
|
||||
when 13 then
|
||||
Result := 0x13
|
||||
when 14 then
|
||||
Result := 0x35
|
||||
when 15 then
|
||||
Result := 0xdf
|
||||
when 16 then
|
||||
Result := 0xe1
|
||||
when 17 then
|
||||
Result := 0x8b
|
||||
when 18 then
|
||||
Result := 0xad
|
||||
when 19 then
|
||||
Result := 0x97
|
||||
when 20 then
|
||||
Result := 0x19
|
||||
when 21 then
|
||||
Result := 0x83
|
||||
when 22 then
|
||||
Result := 0xa5
|
||||
when 23 then
|
||||
Result := 0xcf
|
||||
when 24 then
|
||||
Result := 0xd1
|
||||
when 25 then
|
||||
Result := 0xfb
|
||||
when 26 then
|
||||
Result := 0x1d
|
||||
when 27 then
|
||||
Result := 0x87
|
||||
when 28 then
|
||||
Result := 0x09
|
||||
when 29 then
|
||||
Result := 0xf4
|
||||
when 30 then
|
||||
Result := 0x15
|
||||
when 31 then
|
||||
Result := 0xbf
|
||||
when 32 then
|
||||
Result := 0xc1
|
||||
when 33 then
|
||||
Result := 0x6b
|
||||
when 34 then
|
||||
Result := 0x8d
|
||||
when 35 then
|
||||
Result := 0x77
|
||||
when 36 then
|
||||
Result := 0xf9
|
||||
when 37 then
|
||||
Result := 0x63
|
||||
when 38 then
|
||||
Result := 0x85
|
||||
when 39 then
|
||||
Result := 0xaf
|
||||
when 40 then
|
||||
Result := 0xb1
|
||||
when 41 then
|
||||
Result := 0xdb
|
||||
when 42 then
|
||||
Result := 0xfd
|
||||
when 43 then
|
||||
Result := 0x67
|
||||
when 44 then
|
||||
Result := 0xe9
|
||||
when 45 then
|
||||
Result := 0xd3
|
||||
when 46 then
|
||||
Result := 0xf5
|
||||
when 47 then
|
||||
Result := 0x9f
|
||||
when 48 then
|
||||
Result := 0xa1
|
||||
when 49 then
|
||||
Result := 0x4b
|
||||
when 50 then
|
||||
Result := 0x6d
|
||||
when 51 then
|
||||
Result := 0x57
|
||||
when 52 then
|
||||
Result := 0xd9
|
||||
when 53 then
|
||||
Result := 0x43
|
||||
when 54 then
|
||||
Result := 0x65
|
||||
when 55 then
|
||||
Result := 0x8f
|
||||
when 56 then
|
||||
Result := 0x91
|
||||
when 57 then
|
||||
Result := 0xbb
|
||||
when 58 then
|
||||
Result := 0xdd
|
||||
when 59 then
|
||||
Result := 0x47
|
||||
when 60 then
|
||||
Result := 0xc9
|
||||
when 61 then
|
||||
Result := 0xb3
|
||||
when 62 then
|
||||
Result := 0xd5
|
||||
when 63 then
|
||||
Result := 0x7f
|
||||
when 64 then
|
||||
Result := 0x81
|
||||
when 65 then
|
||||
Result := 0x2b
|
||||
when 66 then
|
||||
Result := 0x4d
|
||||
when 67 then
|
||||
Result := 0x37
|
||||
when 68 then
|
||||
Result := 0xb9
|
||||
when 69 then
|
||||
Result := 0x23
|
||||
when 70 then
|
||||
Result := 0x45
|
||||
when 71 then
|
||||
Result := 0x6f
|
||||
when 72 then
|
||||
Result := 0x71
|
||||
when 73 then
|
||||
Result := 0x9b
|
||||
when 74 then
|
||||
Result := 0xbd
|
||||
when 75 then
|
||||
Result := 0x27
|
||||
when 76 then
|
||||
Result := 0xa9
|
||||
when 77 then
|
||||
Result := 0x93
|
||||
when 78 then
|
||||
Result := 0xb5
|
||||
when 79 then
|
||||
Result := 0x5f
|
||||
when 80 then
|
||||
Result := 0x61
|
||||
when 81 then
|
||||
Result := 0x0b
|
||||
when 82 then
|
||||
Result := 0x2d
|
||||
when 83 then
|
||||
Result := 0x17
|
||||
when 84 then
|
||||
Result := 0x99
|
||||
when 85 then
|
||||
Result := 0x03
|
||||
when 86 then
|
||||
Result := 0x25
|
||||
when 87 then
|
||||
Result := 0x4f
|
||||
when 88 then
|
||||
Result := 0x51
|
||||
when 89 then
|
||||
Result := 0x7b
|
||||
when 90 then
|
||||
Result := 0x9d
|
||||
when 91 then
|
||||
Result := 0x07
|
||||
when 92 then
|
||||
Result := 0x89
|
||||
when 93 then
|
||||
Result := 0x73
|
||||
when 94 then
|
||||
Result := 0x95
|
||||
when 95 then
|
||||
Result := 0x3f
|
||||
when 96 then
|
||||
Result := 0x41
|
||||
when 97 then
|
||||
Result := 0xeb
|
||||
when 98 then
|
||||
Result := 0x0d
|
||||
when 99 then
|
||||
Result := 0xf7
|
||||
when 100 then
|
||||
Result := 0x79
|
||||
when 101 then
|
||||
Result := 0xe3
|
||||
when 102 then
|
||||
Result := 0x05
|
||||
when 103 then
|
||||
Result := 0x2f
|
||||
when 104 then
|
||||
Result := 0x31
|
||||
when 105 then
|
||||
Result := 0x5b
|
||||
when 106 then
|
||||
Result := 0x7d
|
||||
when 107 then
|
||||
Result := 0xe7
|
||||
when 108 then
|
||||
Result := 0x69
|
||||
when 109 then
|
||||
Result := 0x53
|
||||
when 110 then
|
||||
Result := 0x75
|
||||
when 111 then
|
||||
Result := 0x1f
|
||||
when 112 then
|
||||
Result := 0x21
|
||||
when 113 then
|
||||
Result := 0xcb
|
||||
when 114 then
|
||||
Result := 0xed
|
||||
when 115 then
|
||||
Result := 0xd7
|
||||
when 116 then
|
||||
Result := 0x59
|
||||
when 117 then
|
||||
Result := 0xc3
|
||||
when 118 then
|
||||
Result := 0xe5
|
||||
when 119 then
|
||||
Result := 0x0f
|
||||
when 120 then
|
||||
Result := 0x11
|
||||
when 121 then
|
||||
Result := 0x3b
|
||||
when 122 then
|
||||
Result := 0x5d
|
||||
when 123 then
|
||||
Result := 0xc7
|
||||
when 124 then
|
||||
Result := 0x49
|
||||
when 125 then
|
||||
Result := 0x33
|
||||
when 126 then
|
||||
Result := 0x55
|
||||
when 127 then
|
||||
Result := 0xff
|
||||
end
|
||||
end
|
||||
|
||||
bit_index_to_limb_index (bit_a: INTEGER): INTEGER
|
||||
do
|
||||
Result := bit_a // limb_bits
|
||||
end
|
||||
|
||||
umul_ppmm (xh: CELL [NATURAL_32]; xl: CELL [NATURAL_32]; m0: NATURAL_32; m1: NATURAL_32)
|
||||
local
|
||||
t: NATURAL_64
|
||||
do
|
||||
t := limb_multiply (m0, m1)
|
||||
xl.put (t.to_natural_32)
|
||||
xh.put (t.bit_shift_right (limb_bits).to_natural_32)
|
||||
end
|
||||
|
||||
bits_to_limbs (n: INTEGER): INTEGER
|
||||
do
|
||||
Result := (n + limb_bits - 1) // limb_bits
|
||||
end
|
||||
|
||||
bits_top_limb (n: INTEGER): INTEGER
|
||||
-- How many bits of the top limb would be occupied with n bits total
|
||||
do
|
||||
Result := (n + limb_bits - 1) \\ limb_bits
|
||||
end
|
||||
|
||||
pow2_p (in: NATURAL_32): BOOLEAN
|
||||
do
|
||||
Result := in.bit_and (in - 1) = 0
|
||||
end
|
||||
|
||||
limb_multiply (one: NATURAL_32 two: NATURAL_32): NATURAL_64
|
||||
-- Return the lossless multiplication of `one' and `two'
|
||||
do
|
||||
Result := one.to_natural_64 * two.to_natural_64
|
||||
end
|
||||
end
|
||||
249
contrib/ise_library/math/eapml/src/linear_congruential_rng.e
Normal file
249
contrib/ise_library/math/eapml/src/linear_congruential_rng.e
Normal file
@@ -0,0 +1,249 @@
|
||||
note
|
||||
description: "A Linear congruential random number generator"
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "To limit the press is to insult a nation; to prohibit reading of certain books is to declare the inhabitants to be either fools or knaves. - Claude-Adrien Helvetius"
|
||||
|
||||
class
|
||||
LINEAR_CONGRUENTIAL_RNG
|
||||
|
||||
inherit
|
||||
RANDOM_NUMBER_GENERATOR
|
||||
LIMB_MANIPULATION
|
||||
SPECIAL_UTILITY
|
||||
SPECIAL_ARITHMETIC
|
||||
rename
|
||||
add as add_special,
|
||||
sub as sub_special,
|
||||
mul as mul_special
|
||||
export
|
||||
{NONE}
|
||||
all
|
||||
end
|
||||
INTEGER_X_DIVISION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature
|
||||
|
||||
make (size: INTEGER)
|
||||
require
|
||||
size >= 0
|
||||
size <= 128
|
||||
local
|
||||
a: INTEGER_X
|
||||
m2exp: INTEGER
|
||||
number: STRING_8
|
||||
do
|
||||
inspect size
|
||||
when 0..16 then
|
||||
m2exp := 32
|
||||
number := "29cf535"
|
||||
when 17 then
|
||||
m2exp := 34
|
||||
number := "A3D73AD"
|
||||
when 18 then
|
||||
m2exp := 36
|
||||
number := "28f825c5"
|
||||
when 19 then
|
||||
m2exp := 38
|
||||
number := "a3dd4cdd"
|
||||
when 20 then
|
||||
m2exp := 40
|
||||
number := "28f5da175"
|
||||
when 21..28 then
|
||||
m2exp := 56
|
||||
number := "AA7D735234C0DD"
|
||||
when 29..32 then
|
||||
m2exp := 64
|
||||
number := "BAECD515DAF0B49D"
|
||||
when 33..50 then
|
||||
m2exp := 100
|
||||
number := "292787EBD3329AD7E7575E2FD"
|
||||
when 51..64 then
|
||||
m2exp := 128
|
||||
number := "48A74F367FA7B5C8ACBB36901308FA85"
|
||||
when 65..78 then
|
||||
m2exp := 156
|
||||
number := "78A7FDDDC43611B527C3F1D760F36E5D7FC7C45"
|
||||
when 79..98 then
|
||||
m2exp := 196
|
||||
number := "41BA2E104EE34C66B3520CE706A56498DE6D44721E5E24F5"
|
||||
when 99..100 then
|
||||
m2exp := 200
|
||||
number := "4E5A24C38B981EAFE84CD9D0BEC48E83911362C114F30072C5"
|
||||
when 101..238 then
|
||||
m2exp := 256
|
||||
number := "AF66BA932AAF58A071FD8F0742A99A0C76982D648509973DB802303128A14CB5"
|
||||
end
|
||||
create a.make_from_string_base (number, 16)
|
||||
randinit_lc_2exp (a, 1, m2exp)
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
randinit_lc_2exp (a: READABLE_INTEGER_X; c: NATURAL_32; m2exp: INTEGER)
|
||||
local
|
||||
seedn: INTEGER
|
||||
do
|
||||
seedn := bits_to_limbs (m2exp)
|
||||
create seed.make (m2exp, a, seedn, c)
|
||||
end
|
||||
|
||||
seed: RAND_LC_STRUCT
|
||||
|
||||
randseed (seed_a: READABLE_INTEGER_X)
|
||||
local
|
||||
seedz: READABLE_INTEGER_X
|
||||
seedn: INTEGER
|
||||
do
|
||||
seedz := seed.seed
|
||||
seedn := bits_to_limbs (seed.m2exp)
|
||||
fdiv_r_2exp (seedz, seed_a, seed.m2exp)
|
||||
seedz.item.fill_with (0, seedz.count, seedz.count - (seedn - seedz.count))
|
||||
seedz.count := seedn
|
||||
end
|
||||
|
||||
randget (target: SPECIAL [NATURAL_32]; target_offset: INTEGER; nbits: INTEGER)
|
||||
local
|
||||
rbitpos: INTEGER
|
||||
chunk_nbits: INTEGER
|
||||
tp: SPECIAL [NATURAL_32]
|
||||
tp_offset: INTEGER
|
||||
tn: INTEGER
|
||||
r2p: SPECIAL [NATURAL_32]
|
||||
r2p_offset: INTEGER
|
||||
rcy: NATURAL_32
|
||||
junk: INTEGER
|
||||
last_nbits: INTEGER
|
||||
savelimb: NATURAL_32
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
chunk_nbits := seed.m2exp // 2
|
||||
tn := bits_to_limbs (chunk_nbits)
|
||||
create tp.make_filled (0, tn)
|
||||
from
|
||||
rbitpos := 0
|
||||
until
|
||||
rbitpos + chunk_nbits > nbits
|
||||
loop
|
||||
r2p := target
|
||||
r2p_offset := target_offset + rbitpos // limb_bits
|
||||
if rbitpos \\ limb_bits /= 0 then
|
||||
junk := lc (tp, tp_offset)
|
||||
savelimb := r2p [r2p_offset]
|
||||
lshift (r2p, r2p_offset, tp, tp_offset, tn, rbitpos \\ limb_bits, carry)
|
||||
rcy := carry.item
|
||||
r2p [r2p_offset] := r2p [r2p_offset].bit_or (savelimb)
|
||||
if (chunk_nbits \\ limb_bits + rbitpos \\ limb_bits) > limb_bits then
|
||||
r2p [r2p_offset + tn] := rcy
|
||||
end
|
||||
else
|
||||
junk := lc (r2p, r2p_offset)
|
||||
end
|
||||
rbitpos := rbitpos + chunk_nbits
|
||||
end
|
||||
if rbitpos /= nbits then
|
||||
r2p := target
|
||||
r2p_offset := target_offset + rbitpos // limb_bits
|
||||
last_nbits := nbits - rbitpos
|
||||
tn := bits_to_limbs (last_nbits)
|
||||
junk := lc (tp, tp_offset)
|
||||
if rbitpos \\ limb_bits /= 0 then
|
||||
savelimb := r2p [r2p_offset]
|
||||
lshift (r2p, r2p_offset, tp, tp_offset, tn, rbitpos \\ limb_bits, carry)
|
||||
rcy := carry.item
|
||||
r2p [r2p_offset] := r2p [r2p_offset].bit_or (savelimb)
|
||||
if rbitpos + tn * limb_bits - rbitpos \\ limb_bits < nbits then
|
||||
r2p [r2p_offset + tn] := rcy
|
||||
end
|
||||
else
|
||||
r2p.copy_data (tp, tp_offset, r2p_offset, tn)
|
||||
end
|
||||
if nbits \\ limb_bits /= 0 then
|
||||
target [target_offset + nbits // limb_bits] := target [target_offset + nbits // limb_bits].bit_and (((0).to_natural_32.bit_not |<< (nbits \\ limb_bits)).bit_not)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
lc (target: SPECIAL [NATURAL_32]; target_offset: INTEGER): INTEGER
|
||||
local
|
||||
tp: SPECIAL [NATURAL_32]
|
||||
tp_offset: INTEGER
|
||||
seedp: SPECIAL [NATURAL_32]
|
||||
seedp_offset: INTEGER
|
||||
ap: SPECIAL [NATURAL_32]
|
||||
ap_offset: INTEGER
|
||||
ta: INTEGER
|
||||
tn: INTEGER
|
||||
seedn: INTEGER
|
||||
an: INTEGER
|
||||
m2exp: INTEGER
|
||||
bits: INTEGER
|
||||
cy: INTEGER
|
||||
xn: INTEGER
|
||||
tmp: INTEGER
|
||||
i: INTEGER
|
||||
x: NATURAL_32
|
||||
limb: NATURAL_32
|
||||
count: INTEGER
|
||||
junk: NATURAL_32
|
||||
carry: CELL [NATURAL_32]
|
||||
do
|
||||
create carry.put (0)
|
||||
m2exp := seed.m2exp
|
||||
seedp := seed.seed.item
|
||||
seedn := seed.seed.count
|
||||
ap := seed.a.item
|
||||
an := seed.a.count
|
||||
ta := an + seedn + 1
|
||||
tn := bits_to_limbs (m2exp)
|
||||
if ta <= tn then
|
||||
tmp := an + seedn
|
||||
ta := tn + 1
|
||||
end
|
||||
create tp.make_filled (0, ta)
|
||||
mul_special (tp, tp_offset, seedp, seedp_offset, seedn, ap, ap_offset, an, carry)
|
||||
junk := carry.item
|
||||
i := seed.cn
|
||||
if i /= 0 then
|
||||
add_n (tp, tp_offset, tp, tp_offset, seed.cp, 0, i, carry)
|
||||
if carry.item /= 0 then
|
||||
from
|
||||
cy := 0
|
||||
limb := 1
|
||||
until
|
||||
cy /= 0 or limb = 0
|
||||
loop
|
||||
if i >= tn then
|
||||
cy := 1
|
||||
else
|
||||
x := tp [tp_offset + i]
|
||||
limb := x + 1
|
||||
tp [tp_offset + i] := limb
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
tp [tp_offset + m2exp // limb_bits] := tp [tp_offset + m2exp // limb_bits].bit_and ((integer_to_limb (1) |<< m2exp \\ integer_to_limb (limb_bits)) - 1)
|
||||
seed.seed.item.copy_data (tp, tp_offset, 0, tn)
|
||||
bits := m2exp // 2
|
||||
xn := bits // limb_bits
|
||||
tn := tn - xn
|
||||
if tn > 0 then
|
||||
count := bits \\ limb_bits
|
||||
if count /= 0 then
|
||||
rshift (tp, tp_offset, tp, tp_offset + xn, tn, count, carry)
|
||||
junk := carry.item
|
||||
target.copy_data (tp, tp_offset, target_offset, xn + 1)
|
||||
else
|
||||
target.copy_data (tp, tp_offset + xn, target_offset, tn)
|
||||
end
|
||||
end
|
||||
Result := (m2exp + 1) // 2
|
||||
end
|
||||
end
|
||||
1490
contrib/ise_library/math/eapml/src/mersenne_twister_rng.e
Normal file
1490
contrib/ise_library/math/eapml/src/mersenne_twister_rng.e
Normal file
File diff suppressed because it is too large
Load Diff
28
contrib/ise_library/math/eapml/src/random_number_generator.e
Normal file
28
contrib/ise_library/math/eapml/src/random_number_generator.e
Normal file
@@ -0,0 +1,28 @@
|
||||
note
|
||||
description: "Summary description for {RANDSTRUCT}."
|
||||
author: "Colin LeMahieu"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
quote: "Where men cannot freely convey their thoughts to one another, no other liberty is secure. - William E. Hocking (1873-1966), Freedom of the Press, 1947"
|
||||
|
||||
deferred class
|
||||
RANDOM_NUMBER_GENERATOR
|
||||
|
||||
inherit
|
||||
LIMB_MANIPULATION
|
||||
|
||||
feature
|
||||
|
||||
randseed (seed: READABLE_INTEGER_X)
|
||||
deferred
|
||||
end
|
||||
|
||||
randget (target: SPECIAL [NATURAL_32]; target_offset: INTEGER; count: INTEGER)
|
||||
require
|
||||
count = 0 or target.valid_index (target_offset)
|
||||
count = 0 or target.valid_index (target_offset + bits_to_limbs (count) - 1)
|
||||
deferred
|
||||
ensure
|
||||
target [target_offset + bits_to_limbs (count) - 1] = 0 or else most_significant_one (target [target_offset + bits_to_limbs (count) - 1]) <= bits_top_limb (count)
|
||||
end
|
||||
end
|
||||
1741
contrib/ise_library/math/eapml/src/readable_integer_x.e
Normal file
1741
contrib/ise_library/math/eapml/src/readable_integer_x.e
Normal file
File diff suppressed because it is too large
Load Diff
37
contrib/ise_library/math/eapml/tests/TODO.txt
Normal file
37
contrib/ise_library/math/eapml/tests/TODO.txt
Normal file
@@ -0,0 +1,37 @@
|
||||
Test suite order -
|
||||
|
||||
-Interfaces must be tested first (string conversions, Eiffel native construction conversions, etc, using known good large numbers verified by other big number libraries.
|
||||
(If we don't have at least this then nothing else can be trusted)
|
||||
|
||||
-Integer Interfaces
|
||||
-Real Interfaces
|
||||
* Real MPF
|
||||
* Real MPFR
|
||||
-Rational
|
||||
-Complex Integer
|
||||
-Complex Complex Real
|
||||
* Complex Real MPF
|
||||
* Complex Real MPFR
|
||||
-Complex Rational
|
||||
|
||||
|
||||
|
||||
-Test arithmetic functions for each eiffel MP constrcts using known values/solutions for "big" numbers and checking using previously tested known-good interfaces.
|
||||
|
||||
*Test arithmetic operations between similar types of MP constructs
|
||||
*Test arithmetic operations between different types of MP constructs
|
||||
|
||||
|
||||
TODO:
|
||||
Reformat test suite order
|
||||
Start testing interfaces
|
||||
-Integer Interfaces
|
||||
-Real Interfaces
|
||||
* Real MPF
|
||||
* Real MPFR
|
||||
-Rational
|
||||
-Complex Integer
|
||||
-Complex Complex Real
|
||||
* Complex Real MPF
|
||||
* Complex Real MPFR
|
||||
-Complex Rational
|
||||
43
contrib/ise_library/math/eapml/tests/test.e
Normal file
43
contrib/ise_library/math/eapml/tests/test.e
Normal file
@@ -0,0 +1,43 @@
|
||||
note
|
||||
description : "Library unit test root class"
|
||||
date : "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision : "$Revision: 87787 $"
|
||||
|
||||
class
|
||||
TEST
|
||||
|
||||
inherit
|
||||
ARGUMENTS
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
local
|
||||
do
|
||||
end
|
||||
|
||||
test1: detachable TEST_INTEGER_X
|
||||
test2: detachable TEST_INTEGER_FUNCTIONS
|
||||
test3: detachable TEST_INTEGER_X_ASSIGNMENT
|
||||
test4: detachable TEST_SPECIAL_ARITHMETIC
|
||||
test5: detachable TEST_SPECIAL_DIVISION
|
||||
test6: detachable TEST_SPECIAL_LOGIC
|
||||
test7: detachable TEST_SPECIAL_NUMBER_THEORETIC
|
||||
test9: detachable TEST_RANDSTRUCT_LC
|
||||
test10: detachable TEST_RANDSTRUCT_MT
|
||||
test11: detachable TEST_INTEGER_X_RANDOM
|
||||
test12: detachable TEST_INTEGER_X_ACCESS
|
||||
test13: detachable TEST_INTEGER_X_IO
|
||||
test14: detachable TEST_INTEGER_X_NUMBER_THEORY
|
||||
test15: detachable TEST_INTEGER_X_ARITHMETIC
|
||||
test16: detachable TEST_SPECIAL_GCD
|
||||
test17: detachable TEST_INTEGER_X_DIVISION
|
||||
test18: detachable TEST_INTEGER_X_GCD
|
||||
test19: detachable TEST_INTEGER_X_LOGIC
|
||||
test20: detachable TEST_LIMB_MANIPULATION
|
||||
test21: detachable IMMUTABLE_INTEGER_X
|
||||
test22: detachable INTEGER_X
|
||||
end
|
||||
@@ -0,0 +1,19 @@
|
||||
note
|
||||
description: "[
|
||||
Eiffel tests that can be executed by testing tool.
|
||||
]"
|
||||
author: "EiffelStudio test wizard"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
testing: "type/manual"
|
||||
|
||||
class
|
||||
TEST_INTEGER_FUNCTIONS
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
feature -- Test routines
|
||||
end
|
||||
|
||||
|
||||
557
contrib/ise_library/math/eapml/tests/test_integer_x.e
Normal file
557
contrib/ise_library/math/eapml/tests/test_integer_x.e
Normal file
@@ -0,0 +1,557 @@
|
||||
note
|
||||
description: "[
|
||||
Eiffel tests that can be executed by testing tool.
|
||||
]"
|
||||
author: "EiffelStudio test wizard"
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
testing: "type/manual"
|
||||
|
||||
class
|
||||
TEST_INTEGER_X
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
INTEGER_X_ASSIGNMENT
|
||||
undefine
|
||||
default_create
|
||||
end
|
||||
|
||||
feature -- Basic operations tests
|
||||
test_init
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one
|
||||
end
|
||||
|
||||
test_default_zero
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one
|
||||
assert ("{INTEGER_X}.default_create", one.to_integer_32 = 0)
|
||||
end
|
||||
|
||||
test_make_ui
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_natural (0xffffffff)
|
||||
assert ("{INTEGER_X}.make_ui", one.to_natural_32 = 0xffffffff)
|
||||
end
|
||||
|
||||
test_as_natural
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_natural (0xffffffff)
|
||||
assert ("{INTEGER_X}.as_natural", one.to_natural_32 = 0xffffffff)
|
||||
end
|
||||
|
||||
test_make_si
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (0x7fffffff)
|
||||
assert ("{INTEGER_X}.make_si", one.to_integer_32 = 0x7fffffff)
|
||||
end
|
||||
|
||||
test_as_integer
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (0x7fffffff)
|
||||
assert ("{INTEGER_X}.as_integer", one.to_integer_32 = 0x7fffffff)
|
||||
end
|
||||
|
||||
test_fits_natural_8_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: NATURAL_8
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
assert ("test fits natural 8 1", one.fits_natural_8)
|
||||
end
|
||||
|
||||
test_fits_natural_8_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: NATURAL_8
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
one.plus (one.one)
|
||||
assert ("test fits natural 8 2", not one.fits_natural_8)
|
||||
end
|
||||
|
||||
test_fits_natural_8_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (0)
|
||||
assert ("test fits natural 8 3", one.fits_natural_8)
|
||||
end
|
||||
|
||||
test_fits_natural_8_4
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (-1)
|
||||
assert ("test fits natural 8 4", not one.fits_natural_8)
|
||||
end
|
||||
|
||||
test_fits_natural_16_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: NATURAL_16
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
assert ("test fits natural 16 1", one.fits_natural_16)
|
||||
end
|
||||
|
||||
test_fits_natural_16_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: NATURAL_16
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
one.plus (one.one)
|
||||
assert ("test fits natural 16 2", not one.fits_natural_16)
|
||||
end
|
||||
|
||||
test_fits_natural_16_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (0)
|
||||
assert ("test fits natural 16 3", one.fits_natural_16)
|
||||
end
|
||||
|
||||
test_fits_natural_16_4
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (-1)
|
||||
assert ("test fits natural 16 4", not one.fits_natural_16)
|
||||
end
|
||||
|
||||
test_fits_natural_32_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: NATURAL_32
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
assert ("test fits natural 32 1", one.fits_natural_32)
|
||||
end
|
||||
|
||||
test_fits_natural_32_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: NATURAL_32
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
one.plus (one.one)
|
||||
assert ("test fits natural 32 2", not one.fits_natural_32)
|
||||
end
|
||||
|
||||
test_fits_natural_32_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (0)
|
||||
assert ("test fits natural 32 3", one.fits_natural_32)
|
||||
end
|
||||
|
||||
test_fits_natural_32_4
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (-1)
|
||||
assert ("test fits natural 32 4", not one.fits_natural_32)
|
||||
end
|
||||
|
||||
test_fits_natural_64_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: NATURAL_64
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
assert ("test fits natural 64 1", one.fits_natural_64)
|
||||
end
|
||||
|
||||
test_fits_natural_64_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: NATURAL_64
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
one.plus (one.one)
|
||||
assert ("test fits natural 64 2", not one.fits_natural_64)
|
||||
end
|
||||
|
||||
test_fits_natural_64_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (0)
|
||||
assert ("test fits natural 64 3", one.fits_natural_64)
|
||||
end
|
||||
|
||||
test_fits_natural_64_4
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (-1)
|
||||
assert ("test fits natural 64 4", not one.fits_natural_64)
|
||||
end
|
||||
|
||||
test_fits_integer_8_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_8
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
assert ("test fits integer 8 1", one.fits_integer_8)
|
||||
end
|
||||
|
||||
test_fits_integer_8_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_8
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
assert ("test fits integer 8 2", one.fits_integer_8)
|
||||
end
|
||||
|
||||
test_fits_integer_8_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_8
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
one.plus (one.one)
|
||||
assert ("test fits integer 8 3", not one.fits_integer_8)
|
||||
end
|
||||
|
||||
test_fits_integer_8_4
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_8
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
one.minus (one.one)
|
||||
assert ("test fits integer 8 4", not one.fits_integer_8)
|
||||
end
|
||||
|
||||
test_fits_integer_8_5
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (0)
|
||||
assert ("test fits integer 8 5", one.fits_integer_8)
|
||||
end
|
||||
|
||||
test_fits_integer_16_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_16
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
assert ("test fits integer 16 1", one.fits_integer_16)
|
||||
end
|
||||
|
||||
test_fits_integer_16_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_16
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
assert ("test fits integer 16 2", one.fits_integer_16)
|
||||
end
|
||||
|
||||
test_fits_integer_16_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_16
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
one.plus (one.one)
|
||||
assert ("test fits integer 16 3", not one.fits_integer_16)
|
||||
end
|
||||
|
||||
test_fits_integer_16_4
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_16
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
one.minus (one.one)
|
||||
assert ("test fits integer 16 4", not one.fits_integer_16)
|
||||
end
|
||||
|
||||
test_fits_integer_16_5
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (0)
|
||||
assert ("test fits integer 16 5", one.fits_integer_16)
|
||||
end
|
||||
|
||||
test_fits_integer_32_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_32
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
assert ("test fits integer 32 1", one.fits_integer_32)
|
||||
end
|
||||
|
||||
test_fits_integer_32_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_32
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
assert ("test fits integer 32 2", one.fits_integer_32)
|
||||
end
|
||||
|
||||
test_fits_integer_32_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_32
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
one.plus (one.one)
|
||||
assert ("test fits integer 32 3", not one.fits_integer_32)
|
||||
end
|
||||
|
||||
test_fits_integer_32_4
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_32
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
one.minus (one.one)
|
||||
assert ("test fits integer 32 4", not one.fits_integer_32)
|
||||
end
|
||||
|
||||
test_fits_integer_32_5
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (0)
|
||||
assert ("test fits integer 32 5", one.fits_integer_32)
|
||||
end
|
||||
|
||||
test_fits_integer_64_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_64
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
assert ("test fits integer 64 1", one.fits_integer_64)
|
||||
end
|
||||
|
||||
test_fits_integer_64_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_64
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
assert ("test fits integer 64 2", one.fits_integer_64)
|
||||
end
|
||||
|
||||
test_fits_integer_64_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_64
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
one.plus (one.one)
|
||||
assert ("test fits integer 64 3", not one.fits_integer_64)
|
||||
end
|
||||
|
||||
test_fits_integer_64_4
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_64
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
one.minus (one.one)
|
||||
assert ("test fits integer 64 4", not one.fits_integer_64)
|
||||
end
|
||||
|
||||
test_fits_integer_64_5
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_32
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
assert ("test fits integer 64 5", one.fits_integer_64)
|
||||
end
|
||||
|
||||
test_fits_integer_64_6
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_32
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
assert ("test fits integer 64 6", one.fits_integer_64)
|
||||
end
|
||||
|
||||
test_fits_integer_64_7
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (0)
|
||||
assert ("test fits integer 64 7", one.fits_integer_64)
|
||||
end
|
||||
|
||||
test_swap
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (1)
|
||||
create two.make_from_integer (2)
|
||||
swap (one, two)
|
||||
assert ("{INTEGER_X}.swap 1", two.to_integer_32 = 1)
|
||||
assert ("{INTEGER_X}.swap 2", one.to_integer_32 = 2)
|
||||
end
|
||||
|
||||
test_init_set
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
do
|
||||
create one.make_from_string ("0982430984230470238742037402394230948")
|
||||
create two.make_set (one)
|
||||
assert ("{INTEGER_X}.init_set", one ~ two)
|
||||
end
|
||||
|
||||
test_sub
|
||||
-- Test integer subtraction cases, ++ +- -+ --, 0 sum
|
||||
local
|
||||
posone: INTEGER_X
|
||||
postwo: INTEGER_X
|
||||
negone: INTEGER_X
|
||||
negtwo: INTEGER_X
|
||||
ans: INTEGER_X
|
||||
do
|
||||
create posone.make_from_integer (1000)
|
||||
create postwo.make_from_integer (2000)
|
||||
create negone.make_from_integer (-1000)
|
||||
create negtwo.make_from_integer (-2000)
|
||||
ans := posone - postwo
|
||||
assert ("{INTEGER_X}.sub test", ans.to_integer_32 = 1000 - 2000)
|
||||
ans := postwo - negone
|
||||
assert ("{INTEGER_X}.sub test", ans.to_integer_32 = 2000 - -1000)
|
||||
ans := negone - postwo
|
||||
assert ("{INTEGER_X}.sub test", ans.to_integer_32 = -1000 - 2000)
|
||||
ans := negone - negtwo
|
||||
assert ("{INTEGER_X}.sub test", ans.to_integer_32 = -1000 - -2000)
|
||||
ans := posone - posone
|
||||
assert ("{INTEGER_X}.sub test", ans.to_integer_32 = 1000 - 1000)
|
||||
end
|
||||
|
||||
test_negative
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (1)
|
||||
create two.make_from_integer (-1)
|
||||
assert ("test negative", one ~ two or one ~ -two)
|
||||
end
|
||||
|
||||
test_mul
|
||||
-- Test multiplication cases, +- -+
|
||||
local
|
||||
posone: INTEGER_X
|
||||
negone: INTEGER_X
|
||||
ans: INTEGER_X
|
||||
do
|
||||
create posone.make_from_integer (1000)
|
||||
create negone.make_from_integer (-1000)
|
||||
ans := posone * posone
|
||||
assert ("{INTEGER_X}.mul test", ans.to_integer_32 = 1000 * 1000)
|
||||
ans := posone * negone
|
||||
assert ("{INTEGER_X}.mul test", ans.to_integer_32 = 1000 * -1000)
|
||||
end
|
||||
|
||||
test_div
|
||||
-- Test integer division cases, pp, ppr, np, npr, nn, nnr
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
three: INTEGER_X
|
||||
four: INTEGER_X
|
||||
quot: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (42)
|
||||
create two.make_from_integer (2)
|
||||
create three.make_from_integer (-42)
|
||||
create four.make_from_integer (-2)
|
||||
quot := one / two
|
||||
assert ("{INTEGER_X}.div test", quot.to_integer_32 = 42 // 2)
|
||||
quot := two / one
|
||||
assert ("{INTEGER_X}.div test", quot.to_integer_32 = 2 // 42)
|
||||
quot := three / two
|
||||
assert ("{INTEGER_X}.div test", quot.to_integer_32 = -42 // 2)
|
||||
quot := two / three
|
||||
assert ("{INTEGER_X}.div test", quot.to_integer_32 = 2 // -42)
|
||||
quot := three / four
|
||||
assert ("{INTEGER_X}.div test", quot.to_integer_32 = -42 // -2)
|
||||
quot := four / three
|
||||
assert ("{INTEGER_X}.div test", quot.to_integer_32 = -2 // -42)
|
||||
end
|
||||
|
||||
test_abs
|
||||
-- Test absolute value cases
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
three: INTEGER_X
|
||||
ans: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (1)
|
||||
create two.make_from_integer (-1)
|
||||
create three.make_from_integer (0)
|
||||
ans := one.abs_value
|
||||
assert ("INTEGER_X.abs positive", ans.to_integer_32 = 1)
|
||||
ans := two.abs_value
|
||||
assert ("INTEGER_X.abs negative", ans.to_integer_32 = 1)
|
||||
ans := three.abs_value
|
||||
assert ("INTEGER_X.abs zero", ans.to_integer_32 = 0)
|
||||
end
|
||||
|
||||
test_comp
|
||||
-- Test comparison function cases
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
three:INTEGER_X
|
||||
do
|
||||
create one.make_from_integer (1000)
|
||||
create two.make_from_integer (2000)
|
||||
create three.make_from_integer (1000)
|
||||
|
||||
assert ("INTEGER_X.comp eq", one.is_equal (three) = TRUE)
|
||||
assert ("INTEGER_X.comp lt", one.is_less (two) = TRUE)
|
||||
assert ("INTEGER_X.comp lt", two.is_less (one) = FALSE)
|
||||
assert ("INTEGER_X.comp le", one.is_less_equal (two) = TRUE)
|
||||
assert ("INTEGER_X.comp le", one.is_less_equal (three) = TRUE)
|
||||
assert ("INTEGER_X.comp le", two.is_less_equal (one) = FALSE)
|
||||
assert ("INTEGER_X.comp gt", one.is_greater (two) = FALSE)
|
||||
assert ("INTEGER_X.comp gt", two.is_greater (one) = TRUE)
|
||||
assert ("INTEGER_X.comp ge", one.is_greater_equal (two) = FALSE)
|
||||
assert ("INTEGER_X.comp ge", one.is_greater_equal (three) = TRUE)
|
||||
assert ("INTEGER_X.comp ge", two.is_greater_equal (one) = TRUE)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
395
contrib/ise_library/math/eapml/tests/test_integer_x_access.e
Normal file
395
contrib/ise_library/math/eapml/tests/test_integer_x_access.e
Normal file
@@ -0,0 +1,395 @@
|
||||
note
|
||||
description: "Summary description for {TEST_INTEGER_X_ACCESS}."
|
||||
author: ""
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
|
||||
class
|
||||
TEST_INTEGER_X_ACCESS
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
INTEGER_X_ACCESS
|
||||
undefine
|
||||
default_create
|
||||
end
|
||||
|
||||
feature
|
||||
test_get_integer_64_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_64
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
assert ("test get integer 64 1 1", one.fits_integer_64)
|
||||
assert ("test get integer 64 1 2", one.as_integer_64 = int.max_value)
|
||||
end
|
||||
|
||||
test_get_integer_64_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_64
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
assert ("test get integer 64 2 1", one.fits_integer_64)
|
||||
assert ("test get integer 64 2 2", one.as_integer_64 = int.min_value)
|
||||
end
|
||||
|
||||
test_get_integer_64_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_string ("0")
|
||||
assert ("test get integer 64 3 1", one.fits_integer_64)
|
||||
assert ("test get integer 64 3 2", one.as_integer_64 = 0)
|
||||
end
|
||||
|
||||
test_get_integer_64_4
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_string ("-1")
|
||||
assert ("test get integer 64 4 1", one.fits_integer_64)
|
||||
assert ("test get integer 64 4 2", one.as_integer_64 = -1)
|
||||
end
|
||||
|
||||
test_get_integer_64_5
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_64
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
one.plus (one.one)
|
||||
assert ("test get integer 64 5 1", not one.fits_integer_64)
|
||||
assert ("test get integer 64 5 2", one.as_integer_64 = 0)
|
||||
end
|
||||
|
||||
test_get_integer_64_6
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_64
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
one.minus (one.one)
|
||||
assert ("test get integer 64 6 1", not one.fits_integer_64)
|
||||
assert ("test get integer 64 6 2", one.as_integer_64 = -1)
|
||||
end
|
||||
|
||||
test_get_integer_32_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_32
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
assert ("test get integer 32 1 1", one.fits_integer_32)
|
||||
assert ("test get integer 32 1 2", one.as_integer_32 = int.max_value)
|
||||
end
|
||||
|
||||
test_get_integer_32_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_32
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
assert ("test get integer 32 2 1", one.fits_integer_32)
|
||||
assert ("test get integer 32 2 2", one.as_integer_32 = int.min_value)
|
||||
end
|
||||
|
||||
test_get_integer_32_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_string ("0")
|
||||
assert ("test get integer 32 3 1", one.fits_integer_32)
|
||||
assert ("test get integer 32 3 2", one.as_integer_32 = 0)
|
||||
end
|
||||
|
||||
test_get_integer_32_4
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_string ("-1")
|
||||
assert ("test get integer 32 4 1", one.fits_integer_32)
|
||||
assert ("test get integer 32 4 2", one.as_integer_32 = -1)
|
||||
end
|
||||
|
||||
test_get_integer_32_5
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_32
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
one.plus (one.one)
|
||||
assert ("test get integer 32 5 1", not one.fits_integer_32)
|
||||
assert ("test get integer 32 5 2", one.as_integer_32 = 0)
|
||||
end
|
||||
|
||||
test_get_integer_32_6
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_32
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
one.minus (one.one)
|
||||
assert ("test get integer 32 6 1", not one.fits_integer_32)
|
||||
assert ("test get integer 32 6 2", one.as_integer_32 = -1)
|
||||
end
|
||||
|
||||
test_get_integer_16_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_16
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
assert ("test get integer 16 1 1", one.fits_integer_16)
|
||||
assert ("test get integer 16 1 2", one.as_integer_16 = int.max_value)
|
||||
end
|
||||
|
||||
test_get_integer_16_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_16
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
assert ("test get integer 16 2 1", one.fits_integer_16)
|
||||
assert ("test get integer 16 2 2", one.as_integer_16 = int.min_value)
|
||||
end
|
||||
|
||||
test_get_integer_16_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_string ("0")
|
||||
assert ("test get integer 16 3 1", one.fits_integer_16)
|
||||
assert ("test get integer 16 3 2", one.as_integer_16 = 0)
|
||||
end
|
||||
|
||||
test_get_integer_16_4
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_string ("-1")
|
||||
assert ("test get integer 16 4 1", one.fits_integer_16)
|
||||
assert ("test get integer 16 4 2", one.as_integer_16 = -1)
|
||||
end
|
||||
|
||||
test_get_integer_16_5
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_16
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
one.plus (one.one)
|
||||
assert ("test get integer 16 5 1", not one.fits_integer_16)
|
||||
assert ("test get integer 16 5 2", one.as_integer_16 = 0)
|
||||
end
|
||||
|
||||
test_get_integer_16_6
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_16
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
one.minus (one.one)
|
||||
assert ("test get integer 16 6 1", not one.fits_integer_16)
|
||||
assert ("test get integer 16 6 2", one.as_integer_16 = -1)
|
||||
end
|
||||
|
||||
test_get_integer_8_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_8
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
assert ("test get integer 8 1 1", one.fits_integer_8)
|
||||
assert ("test get integer 8 1 2", one.as_integer_8 = int.max_value)
|
||||
end
|
||||
|
||||
test_get_integer_8_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_8
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
assert ("test get integer 8 2 1", one.fits_integer_8)
|
||||
assert ("test get integer 8 2 2", one.as_integer_8 = int.min_value)
|
||||
end
|
||||
|
||||
test_get_integer_8_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_string ("0")
|
||||
assert ("test get integer 8 3 1", one.fits_integer_8)
|
||||
assert ("test get integer 8 3 2", one.as_integer_8 = 0)
|
||||
end
|
||||
|
||||
test_get_integer_8_4
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_string ("-1")
|
||||
assert ("test get integer 8 4 1", one.fits_integer_8)
|
||||
assert ("test get integer 8 4 2", one.as_integer_8 = -1)
|
||||
end
|
||||
|
||||
test_get_integer_8_5
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_8
|
||||
do
|
||||
create one.make_from_string (int.max_value.out)
|
||||
one.plus (one.one)
|
||||
assert ("test get integer 8 5 1", not one.fits_integer_8)
|
||||
assert ("test get integer 8 5 2", one.as_integer_8 = 0)
|
||||
end
|
||||
|
||||
test_get_integer_8_6
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_8
|
||||
do
|
||||
create one.make_from_string (int.min_value.out)
|
||||
one.minus (one.one)
|
||||
assert ("test get integer 8 6 1", not one.fits_integer_8)
|
||||
assert ("test get integer 8 6 2", one.as_integer_8 = -1)
|
||||
end
|
||||
|
||||
test_get_str_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
output: STRING
|
||||
do
|
||||
create one.make_limbs (4)
|
||||
one.item [0] := 0x87654321
|
||||
one.item [1] := 0xcccccccc
|
||||
one.item [2] := 0x33333333
|
||||
one.item [3] := 0xffffffff
|
||||
one.count := 4
|
||||
output := one.out_base (16)
|
||||
assert ("test get str 1", "ffffffff33333333cccccccc87654321" ~ output)
|
||||
end
|
||||
|
||||
test_get_str_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
output: STRING
|
||||
do
|
||||
create one.make_limbs (4)
|
||||
one.item [0] := 0x87654321
|
||||
one.item [1] := 0xcccccccc
|
||||
one.item [2] := 0x33333333
|
||||
one.item [3] := 0xffffffff
|
||||
one.count := 4
|
||||
output := one.out_base (10)
|
||||
assert ("test get str 2", "340282366857555933463031183799994368801" ~ output)
|
||||
end
|
||||
|
||||
test_get_str_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
output: STRING
|
||||
i: INTEGER
|
||||
base: INTEGER
|
||||
do
|
||||
from
|
||||
i := 0
|
||||
until
|
||||
i > 1000
|
||||
loop
|
||||
base := i \\ 61 + 2
|
||||
create one.make_random (256)
|
||||
output := one.out_base (base)
|
||||
create two.make_from_string_base (output, base)
|
||||
assert ("test get str 3", one ~ two)
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
|
||||
test_get_str_4
|
||||
local
|
||||
one: INTEGER_X
|
||||
output: STRING
|
||||
do
|
||||
create one.make_limbs (8)
|
||||
one.item [0] := 0x99811941
|
||||
one.item [1] := 0x841FD605
|
||||
one.item [2] := 0xD960A1BF
|
||||
one.item [3] := 0x5E433EFC
|
||||
one.item [4] := 0x48C9BC93
|
||||
one.item [5] := 0x1C8B6FB1
|
||||
one.item [6] := 0x8CA06DE0
|
||||
one.item [7] := 0xC6182337
|
||||
one.count := 8
|
||||
output := one.out_base (10)
|
||||
assert ("test get str 4", output ~ "89600591407770348063754312463218194105764385355557091513583682190076098451777")
|
||||
end
|
||||
|
||||
test_get_str_5
|
||||
local
|
||||
one: INTEGER_X
|
||||
output: STRING
|
||||
do
|
||||
create one.make_limbs (8)
|
||||
one.item [0] := 0x99811941
|
||||
one.item [1] := 0x841FD605
|
||||
one.item [2] := 0xD960A1BF
|
||||
one.item [3] := 0x5E433EFC
|
||||
one.item [4] := 0x48C9BC93
|
||||
one.item [5] := 0x1C8B6FB1
|
||||
one.item [6] := 0x8CA06DE0
|
||||
one.item [7] := 0xC6182337
|
||||
one.count := 8
|
||||
output := one.out_base (3)
|
||||
assert ("test get str 5", output ~ "110022012022022000201210111012211020111202020222100010210022020220110011011010201011020001011210101000122212110112010121211022120122101102102020102011202010010112")
|
||||
end
|
||||
|
||||
test_get_str_6
|
||||
local
|
||||
one: INTEGER_X
|
||||
output: STRING
|
||||
do
|
||||
create one.make_limbs (8)
|
||||
one.item [7] := 0x8134b7f7
|
||||
one.item [6] := 0x8d570cbf
|
||||
one.item [5] := 0xeb5f7c66
|
||||
one.item [4] := 0x7aa64334
|
||||
one.item [3] := 0xbb6cd783
|
||||
one.item [2] := 0x22792988
|
||||
one.item [1] := 0x6ec0f7ac
|
||||
one.item [0] := 0x4438ad87
|
||||
one.count := 8
|
||||
output := one.out_base (7)
|
||||
assert ("test get str 6", output ~ "5050422450443414252030234161450453214063666050554216601312032162510626626621233550541413260")
|
||||
end
|
||||
|
||||
test_get_str_7
|
||||
local
|
||||
one: INTEGER_X
|
||||
output: STRING
|
||||
do
|
||||
create one.make_limbs (8)
|
||||
one.item [0] := 0x8134b7f7
|
||||
one.item [1] := 0x8d570cbf
|
||||
one.item [2] := 0xeb5f7c66
|
||||
one.item [3] := 0x7aa64334
|
||||
one.item [4] := 0xbb6cd783
|
||||
one.item [5] := 0x22792988
|
||||
one.item [6] := 0x6ec0f7ac
|
||||
one.item [7] := 0x4438ad87
|
||||
one.count := 8
|
||||
output := one.out_base (7)
|
||||
assert ("test get str 7", output ~ "2460223246331335544520513341363224654146046636101125253015521231163466226621435340120452343")
|
||||
end
|
||||
|
||||
test_get_str_8
|
||||
local
|
||||
one: INTEGER_X
|
||||
output: STRING
|
||||
do
|
||||
create one.make_from_integer (-1)
|
||||
output := one.out_hex
|
||||
assert ("test get str 7", output ~ "-1")
|
||||
end
|
||||
end
|
||||
208
contrib/ise_library/math/eapml/tests/test_integer_x_arithmetic.e
Normal file
208
contrib/ise_library/math/eapml/tests/test_integer_x_arithmetic.e
Normal file
@@ -0,0 +1,208 @@
|
||||
note
|
||||
description: "Summary description for {TEST_INTEGER_ARITHMETIC}."
|
||||
author: ""
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
|
||||
class
|
||||
TEST_INTEGER_X_ARITHMETIC
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
INTEGER_X_ARITHMETIC
|
||||
undefine
|
||||
default_create
|
||||
end
|
||||
|
||||
feature
|
||||
test_add_1
|
||||
-- Test integer addition cases, ++ +- -+ --, 0 sum
|
||||
local
|
||||
posone: INTEGER_X
|
||||
postwo: INTEGER_X
|
||||
negone: INTEGER_X
|
||||
negtwo: INTEGER_X
|
||||
ans: INTEGER_X
|
||||
do
|
||||
create posone.make_from_integer (1000)
|
||||
create postwo.make_from_integer (2000)
|
||||
create negone.make_from_integer (-1000)
|
||||
create negtwo.make_from_integer (-2000)
|
||||
ans := posone + postwo
|
||||
assert ("{INTEGER_X}.add test", ans.to_integer_32 = 1000 + 2000)
|
||||
ans := postwo + negone
|
||||
assert ("{INTEGER_X}.add test", ans.to_integer_32 = 2000 + -1000)
|
||||
ans := negone + postwo
|
||||
assert ("{INTEGER_X}.add test", ans.to_integer_32 = -1000 + 2000)
|
||||
ans := negone + negtwo
|
||||
assert ("{INTEGER_X}.add test", ans.to_integer_32 = -1000 + -2000)
|
||||
ans := posone + negone
|
||||
assert ("{INTEGER_X}.add test", ans.to_integer_32 = 1000 + -1000)
|
||||
end
|
||||
|
||||
test_add_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
three: INTEGER_X
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one.make_limbs (6)
|
||||
create two.make_from_hex_string ("343bd97a 7e17702a 800c8f10 54ad58f6 1f07c505")
|
||||
create three.make_from_hex_string ("ffffffff ffffffff ffffffff ffffffff 7ffffffc")
|
||||
create expected.make_from_hex_string ("1343bd97a7e17702a800c8f1054ad58f59f07c501")
|
||||
add (one, two, three)
|
||||
assert ("test add 2", one ~ expected)
|
||||
end
|
||||
|
||||
test_add_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
three: INTEGER_X
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one
|
||||
create two.make_from_hex_string ("a9993e364706816aba3e25717850c26c9cd0d89d")
|
||||
create three.make_from_hex_string ("8913681113524c02ac9b2b8777f53c1feb356bfbc122bf1970d1ccc8fc43f9bb8aec1812ee98e4a2")
|
||||
create expected.make_from_hex_string ("8913681113524c02ac9b2b8777f53c1feb356bfc6abbfd4fb7d84e33b6821f2d033cda7f8b69bd3f")
|
||||
add (one, two, three)
|
||||
assert ("test add 3", one ~ expected)
|
||||
end
|
||||
|
||||
test_add_4
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
three: INTEGER_X
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one
|
||||
create two.make_from_hex_string ("-7231ea35689f4fd7ce163d502a7e14c99947e909fb2a9d7cad460fb337fae053af6e5a5419a6800c19f28b09a3a1f005621dd631b6d93fcc32e4e6069e76fb15")
|
||||
create three.make_from_hex_string ("1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
||||
create expected.make_from_hex_string ("1ff8dce15ca9760b02831e9c2afd581eb3666b816f604d5628352b9f04cc8051fac5091a5abe6597ff3e60d74f65c5e0ffa9de229ce4926c033cd1b19f9618904ea")
|
||||
add (one, two, three)
|
||||
assert ("test add 4", one ~ expected)
|
||||
end
|
||||
|
||||
test_sub_1
|
||||
local
|
||||
one_three: INTEGER_X
|
||||
two: INTEGER_X
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one_three.make_from_hex_string ("014fae42 56ad0915 2a7b2b66 fe887b52 e06ffa35 d359cd33 14156137 564096ef 90eb9c01 9ee82ea9")
|
||||
create two.make_from_hex_string ("1")
|
||||
create expected.make_from_hex_string ("-014fae42 56ad0915 2a7b2b66 fe887b52 e06ffa35 d359cd33 14156137 564096ef 90eb9c01 9ee82ea8")
|
||||
sub (one_three, two, one_three)
|
||||
assert ("test sub 1", one_three ~ expected)
|
||||
end
|
||||
|
||||
test_sub_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
three: INTEGER_X
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one
|
||||
create two.make_from_hex_string ("1429cb78799228669deb4a9025f308ab78be74ae")
|
||||
create three.make_from_hex_string ("-f7c5cdcb7d66c16bbf17e81de30488c02078684")
|
||||
create expected.make_from_hex_string ("23a628553168947d59dcc912042351377ac5fb32")
|
||||
sub (one, two, three)
|
||||
assert ("test sub 2", one ~ expected)
|
||||
end
|
||||
|
||||
test_mul_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
three: INTEGER_X
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one.make_limbs (10)
|
||||
create two.make_limbs (5)
|
||||
create three.make_limbs (6)
|
||||
create expected.make_from_hex_string ("30f2de49 bab11556 78be37e5 d4205117 663c6cc5 5fd1e2bd 41b4a8fd 35ce30b2 07939fb8 c29af9f6")
|
||||
two.item [0] := 0x9f07c4ff
|
||||
two.item [1] := 0xd4ad58f1
|
||||
two.item [2] := 0x800c8f0e
|
||||
two.item [3] := 0x7e17702a
|
||||
two.item [4] := 0x343bd97a
|
||||
two.count := 5
|
||||
three.item [0] := 0xfb4ab80a
|
||||
three.item [1] := 0x2077ac6a
|
||||
three.item [2] := 0x5bdd4431
|
||||
three.item [3] := 0x6672da8e
|
||||
three.item [4] := 0xefe650c5
|
||||
three.count := 5
|
||||
mul (one, two, three)
|
||||
assert ("test mul 1", expected ~ one)
|
||||
end
|
||||
|
||||
test_mul_2
|
||||
local
|
||||
one_three: INTEGER_X
|
||||
two: INTEGER_X
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one_three.make_limbs (6)
|
||||
create two.make_limbs (5)
|
||||
create expected.make_from_hex_string ("30f2de49 bab11556 78be37e5 d4205117 663c6cc5 5fd1e2bd 41b4a8fd 35ce30b2 07939fb8 c29af9f6")
|
||||
two.item [0] := 0x9f07c4ff
|
||||
two.item [1] := 0xd4ad58f1
|
||||
two.item [2] := 0x800c8f0e
|
||||
two.item [3] := 0x7e17702a
|
||||
two.item [4] := 0x343bd97a
|
||||
two.count := 5
|
||||
one_three.item [0] := 0xfb4ab80a
|
||||
one_three.item [1] := 0x2077ac6a
|
||||
one_three.item [2] := 0x5bdd4431
|
||||
one_three.item [3] := 0x6672da8e
|
||||
one_three.item [4] := 0xefe650c5
|
||||
one_three.count := 5
|
||||
mul (one_three, two, one_three)
|
||||
assert ("test mul 1", expected ~ one_three)
|
||||
end
|
||||
|
||||
test_mul_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
three: INTEGER_X
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one
|
||||
create two.make_from_hex_string ("-e69e4c55 8d0e2ed0 10128582 48b54fe8 8e87802e c871b791 5347fc54 8fb749de 9bc6e6b7 1868a715 859bcde6 96d6f196 37ad0367 26bc4cea 65f0d20e 67321392")
|
||||
create three.make_from_hex_string ("000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff")
|
||||
create expected.make_from_hex_string ("-1cd3c98ab1a1c5da020250b04916a9fd11d0f005d90e36f22a68ff8a91f6e93bd378dcd6e30d14e2b0b379bcd2dade32c6f5a06ce4d7899d4cbe1a41cce642723ff1961b3aa72f1d12fefed7a7db74ab01771787fd1378e486eacb803ab7048b62164391948e79758ea7a64321969290e69c852fc98d943b3159a0f2df198cdec6e")
|
||||
mul (one, two, three)
|
||||
assert ("test mul 3", one ~ expected)
|
||||
end
|
||||
|
||||
test_mul_2exp_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one.make_limbs (7)
|
||||
create two.make_from_hex_string ("2 fe13c053 7bbc11ac aa07d793 de4e6d5e 5c94eee8")
|
||||
create expected.make_from_hex_string ("0000000b f84f014d eef046b2 a81f5e4f 7939b579 7253bba0")
|
||||
mul_2exp (one, two, 2)
|
||||
assert ("test mul 2exp 1", one ~ expected)
|
||||
end
|
||||
|
||||
test_mul_2exp_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one
|
||||
create two.make_from_hex_string ("8 00000000 00000000 00000000 00000000 00000000")
|
||||
create expected.make_from_hex_string ("8 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000")
|
||||
mul_2exp (one, two, 0x80)
|
||||
assert ("test mul 2exp 2", one ~ expected)
|
||||
end
|
||||
end
|
||||
217
contrib/ise_library/math/eapml/tests/test_integer_x_assignment.e
Normal file
217
contrib/ise_library/math/eapml/tests/test_integer_x_assignment.e
Normal file
@@ -0,0 +1,217 @@
|
||||
note
|
||||
description: "Summary description for {TEST_INTEGER_X_ASSIGNMENT}."
|
||||
author: ""
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
|
||||
class
|
||||
TEST_INTEGER_X_ASSIGNMENT
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
INTEGER_X_ASSIGNMENT
|
||||
undefine
|
||||
default_create
|
||||
end
|
||||
|
||||
feature
|
||||
test_set_str_1
|
||||
local
|
||||
target: INTEGER_X
|
||||
do
|
||||
create target
|
||||
set_str (target, "100", 10)
|
||||
assert ("test set str 1 1", target.item [0] = 100 and target.count = 1)
|
||||
|
||||
set_str (target, "10000000000", 10)
|
||||
assert ("test set str 1 2", target.item [0] = 0x540be400 and target.item [1] = 0x00000002 and target.count = 2)
|
||||
end
|
||||
|
||||
test_set_str_2
|
||||
local
|
||||
target: INTEGER_X
|
||||
do
|
||||
create target
|
||||
set_str (target, "1000", 16)
|
||||
assert ("test set str 1 1", target.item [0] = 0x1000 and target.count = 1)
|
||||
|
||||
set_str (target, "100000000000", 16)
|
||||
assert ("test set str 1 2", target.item [0] = 0x00000000 and target.item [1] = 0x00001000 and target.count = 2)
|
||||
end
|
||||
|
||||
test_set_str_3
|
||||
local
|
||||
target: INTEGER_X
|
||||
do
|
||||
create target
|
||||
set_str (target, " 1 0 0 0 ", 16)
|
||||
assert ("test set str 3 1", target.item [0] = 0x1000 and target.count = 1)
|
||||
set_str (target, " 1 0 0 0 0 0 0 0 0 0 0 0 ", 16)
|
||||
assert ("test set str 3 2", target.item [0] = 0x00000000 and target.item [1] = 0x00001000 and target.count = 2)
|
||||
end
|
||||
|
||||
test_set_str_4
|
||||
local
|
||||
target: INTEGER_X
|
||||
do
|
||||
create target
|
||||
set_str (target, " 0x 1 0 0 0 ", 0)
|
||||
assert ("test set str 3 1", target.item [0] = 0x1000 and target.count = 1)
|
||||
set_str (target, " 0", 0)
|
||||
assert ("test set str 3 2", target.count = 0)
|
||||
end
|
||||
|
||||
test_set_str_5
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_string_base ("5050422450443414252030234161450453214063666050554216601312032162510626626621233550541413260", 7)
|
||||
assert ("test set str 5", one.item [7] = 0x8134b7f7 and one.item [6] = 0x8d570cbf and one.item [5] = 0xeb5f7c66 and one.item [4] = 0x7aa64334 and one.item [3] = 0xbb6cd783 and one.item [2] = 0x22792988 and one.item [1] = 0x6ec0f7ac and one.item [0] = 0x4438ad87 and one.count = 8)
|
||||
end
|
||||
|
||||
test_set_str_6
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_string_base ("2460223246331335544520513341363224654146046636101125253015521231163466226621435340120452343", 7)
|
||||
assert ("test set str 6", one.item [0] = 0x8134b7f7 and one.item [1] = 0x8d570cbf and one.item [2] = 0xeb5f7c66 and one.item [3] = 0x7aa64334 and one.item [4] = 0xbb6cd783 and one.item [5] = 0x22792988 and one.item [6] = 0x6ec0f7ac and one.item [7] = 0x4438ad87 and one.count = 8)
|
||||
end
|
||||
|
||||
test_set_str_7
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_hex_string ("1")
|
||||
assert ("test set str 7", one.item [0] = 0x1 and one.count = 1)
|
||||
end
|
||||
|
||||
test_set_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
do
|
||||
create one.make_from_hex_string ("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff")
|
||||
assert ("test set 1 1", one.item [0] = 0xfcfdfeff and one.item [1] = 0xf8f9fafb and one.item [2] = 0xf4f5f6f7 and one.item [3] = 0xf0f1f2f3 and one.count = 4)
|
||||
create two
|
||||
two.copy (one)
|
||||
assert ("test set 1 2", one ~ two)
|
||||
assert ("test set 1 3", one.item [0] = 0xfcfdfeff and one.item [1] = 0xf8f9fafb and one.item [2] = 0xf4f5f6f7 and one.item [3] = 0xf0f1f2f3 and one.count = 4)
|
||||
assert ("test set 1 4", two.item [0] = 0xfcfdfeff and two.item [1] = 0xf8f9fafb and two.item [2] = 0xf4f5f6f7 and two.item [3] = 0xf0f1f2f3 and two.count = 4)
|
||||
end
|
||||
|
||||
test_set_from_integer_64_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_64
|
||||
do
|
||||
create one.make_from_integer_64 (int.min_value)
|
||||
assert ("test set from integer 64 1 1", one.fits_integer_64)
|
||||
assert ("test set from integer 64 1 2", one.to_integer_64 = int.min_value)
|
||||
end
|
||||
|
||||
test_set_from_integer_64_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer_64 (-1)
|
||||
assert ("test set from integer 64 2 1", one.fits_integer_64)
|
||||
assert ("test set from integer 64 2 2", one.to_integer_64 = -1)
|
||||
end
|
||||
|
||||
test_set_from_integer_64_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_64
|
||||
do
|
||||
create one.make_from_integer_64 (int.max_value)
|
||||
assert ("test set from integer 64 3 1", one.fits_integer_64)
|
||||
assert ("test set from integer 64 3 2", one.to_integer_64 = int.max_value)
|
||||
end
|
||||
|
||||
test_set_from_integer_32_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_32
|
||||
do
|
||||
create one.make_from_integer_32 (int.min_value)
|
||||
assert ("test set from integer 32 1 1", one.fits_integer_32)
|
||||
assert ("test set from integer 32 1 2", one.to_integer_32 = int.min_value)
|
||||
end
|
||||
|
||||
test_set_from_integer_32_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer_32 (-1)
|
||||
assert ("test set from integer 32 2 1", one.fits_integer_32)
|
||||
assert ("test set from integer 32 2 2", one.to_integer_32 = -1)
|
||||
end
|
||||
|
||||
test_set_from_integer_32_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_32
|
||||
do
|
||||
create one.make_from_integer_32 (int.max_value)
|
||||
assert ("test set from integer 32 3 1", one.fits_integer_32)
|
||||
assert ("test set from integer 32 3 2", one.to_integer_32 = int.max_value)
|
||||
end
|
||||
|
||||
test_set_from_integer_16_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_16
|
||||
do
|
||||
create one.make_from_integer_16 (int.min_value)
|
||||
assert ("test set from integer 16 1 1", one.fits_integer_16)
|
||||
assert ("test set from integer 16 1 2", one.to_integer_16 = int.min_value)
|
||||
end
|
||||
|
||||
test_set_from_integer_16_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer_16 (-1)
|
||||
assert ("test set from integer 16 2 1", one.fits_integer_16)
|
||||
assert ("test set from integer 16 2 2", one.to_integer_16 = -1)
|
||||
end
|
||||
|
||||
test_set_from_integer_16_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_16
|
||||
do
|
||||
create one.make_from_integer_16 (int.max_value)
|
||||
assert ("test set from integer 16 3 1", one.fits_integer_16)
|
||||
assert ("test set from integer 16 3 2", one.to_integer_16 = int.max_value)
|
||||
end
|
||||
|
||||
test_set_from_integer_8_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_8
|
||||
do
|
||||
create one.make_from_integer_8 (int.min_value)
|
||||
assert ("test set from integer 8 1 1", one.fits_integer_8)
|
||||
assert ("test set from integer 8 1 2", one.to_integer_8 = int.min_value)
|
||||
end
|
||||
|
||||
test_set_from_integer_8_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
do
|
||||
create one.make_from_integer_8 (-1)
|
||||
assert ("test set from integer 8 2 1", one.fits_integer_8)
|
||||
assert ("test set from integer 8 2 2", one.to_integer_8 = -1)
|
||||
end
|
||||
|
||||
test_set_from_integer_8_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
int: INTEGER_8
|
||||
do
|
||||
create one.make_from_integer_8 (int.max_value)
|
||||
assert ("test set from integer 8 3 1", one.fits_integer_8)
|
||||
assert ("test set from integer 8 3 2", one.to_integer_8 = int.max_value)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,32 @@
|
||||
note
|
||||
description: "Summary description for {INTEGER_X_DIVISION}."
|
||||
author: ""
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
|
||||
class
|
||||
TEST_INTEGER_X_DIVISION
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
INTEGER_X_DIVISION
|
||||
undefine
|
||||
default_create
|
||||
end
|
||||
|
||||
feature
|
||||
test_tdiv_q_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
three: INTEGER_X
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one
|
||||
create two.make_from_hex_string ("-014fae42 56ad0915 2a7b2b66 fe887b52 e06ffa35 d359cd33 14156137 564096ef 90eb9c01 9ee82ea9")
|
||||
create three.make_from_hex_string ("474c50aa 62d128fa b3b99224 0846a26e f58bf664")
|
||||
create expected.make_from_hex_string ("-04b547f5 df885395 a422bbce 998d2570 9019af3a")
|
||||
tdiv_q (one, two, three)
|
||||
assert ("test tdiv q 1", one ~ expected)
|
||||
end
|
||||
end
|
||||
92
contrib/ise_library/math/eapml/tests/test_integer_x_gcd.e
Normal file
92
contrib/ise_library/math/eapml/tests/test_integer_x_gcd.e
Normal file
@@ -0,0 +1,92 @@
|
||||
note
|
||||
description: "Summary description for {TEST_INTEGER_X_GCD}."
|
||||
author: ""
|
||||
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
|
||||
revision: "$Revision: 87787 $"
|
||||
|
||||
class
|
||||
TEST_INTEGER_X_GCD
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
INTEGER_X_GCD
|
||||
undefine
|
||||
default_create
|
||||
end
|
||||
|
||||
feature
|
||||
test_gcd_1
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
three: INTEGER_X
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one
|
||||
create two.make_from_hex_string ("75bd a09fab66 22ddfba5 6141c975")
|
||||
create three.make_from_hex_string ("db7c 2abf62e3 5e668076 bead208b")
|
||||
create expected.make_from_integer (1)
|
||||
gcd (one, two, three)
|
||||
assert ("test gcd 1", one ~ expected)
|
||||
end
|
||||
|
||||
test_gcd_2
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
three: INTEGER_X
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one
|
||||
create two.make_from_hex_string ("1f3e 0565ad11 0943df37 0be1f345")
|
||||
create three.make_from_hex_string ("db7c 2abf62e3 5e668076 bead208b")
|
||||
create expected.make_from_integer (1)
|
||||
gcd (one, two, three)
|
||||
assert ("test gcd 2", one ~ expected)
|
||||
end
|
||||
|
||||
test_gcd_3
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
three: INTEGER_X
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one
|
||||
create two.make_from_hex_string ("b900 97df5038 7e2f36a6 2ed3a8f4")
|
||||
create three.make_from_hex_string ("db7c 2abf62e3 5e668076 bead208b")
|
||||
create expected.make_from_integer (1)
|
||||
gcd (one, two, three)
|
||||
assert ("test gcd 3", one ~ expected)
|
||||
end
|
||||
|
||||
test_gcd_4
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
three: INTEGER_X
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one
|
||||
create two.make_from_hex_string ("905a 1c3f4cec 73b96934 ac732c70")
|
||||
create three.make_from_hex_string ("db7c 2abf62e3 5e668076 bead208b")
|
||||
create expected.make_from_integer (1)
|
||||
gcd (one, two, three)
|
||||
assert ("test gcd 4", one ~ expected)
|
||||
end
|
||||
|
||||
test_gcd_5
|
||||
local
|
||||
one: INTEGER_X
|
||||
two: INTEGER_X
|
||||
three: INTEGER_X
|
||||
expected: INTEGER_X
|
||||
do
|
||||
create one
|
||||
create two.make_from_hex_string ("1ffb369d437c5d32145fd9a1223ab960e362ffd5545b675f7ead44be35a12c61699c05dd8ecafb643b9feb6912fb6df6c57eca1c0e4ff132ed5d77d6bb5d96a4395")
|
||||
create three.make_from_hex_string ("1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
||||
create expected.make_from_hex_string ("1")
|
||||
gcd (one, two, three)
|
||||
assert ("test gcd 5", one ~ expected)
|
||||
end
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user