Compare commits
975 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
683129b6a5 | ||
|
|
7f4022120e | ||
|
|
3f9e86c37a | ||
|
|
12f460e376 | ||
|
|
44c4488fcc | ||
|
|
44617b6554 | ||
|
|
ccc7d056ba | ||
|
|
566d5ef96f | ||
|
|
cf53f3a347 | ||
|
|
74b48ff56b | ||
|
|
9410370cc5 | ||
|
|
743ddf83c1 | ||
|
|
d2538d08a7 | ||
|
|
75fe9d61a3 | ||
|
|
fce0672282 | ||
|
|
69a2a01bc7 | ||
|
|
a2d4e79c20 | ||
|
|
6e0a9b2b48 | ||
|
|
276f2070ee | ||
|
|
1a158b5de3 | ||
|
|
d4a72bf661 | ||
|
|
caa707325a | ||
|
|
3c588e67b8 | ||
|
|
6c26dad048 | ||
|
|
393e2c125e | ||
|
|
e56dc2ed6a | ||
|
|
4a449ed85e | ||
|
|
88dbe90075 | ||
|
|
a6f6451434 | ||
|
|
8a4370c1f6 | ||
|
|
7a068450b3 | ||
|
|
ae3222e4c2 | ||
|
|
27b4bfa3fa | ||
|
|
8af229947f | ||
|
|
f235a2f539 | ||
|
|
b0ebb479f6 | ||
|
|
df92e21520 | ||
|
|
a1a25cc57f | ||
|
|
e9aaf8e0af | ||
|
|
7a80e407af | ||
|
|
57f8d535fb | ||
|
|
fcc444a100 | ||
|
|
8ccb3c21e1 | ||
|
|
3ce9567f62 | ||
|
|
765e812b77 | ||
|
|
1a63c9296b | ||
|
|
9510b5aea5 | ||
|
|
490e859fbf | ||
|
|
85c4a2fdc2 | ||
|
|
3b9c9f6a97 | ||
|
|
d1f64d3059 | ||
|
|
f62bcdc803 | ||
|
|
2434fd778f | ||
|
|
1a38726fb7 | ||
|
|
24cffb2a69 | ||
|
|
527918545e | ||
|
|
4d268f67ae | ||
|
|
a65c2f4312 | ||
|
|
c490f2b849 | ||
|
|
282f7fc2e3 | ||
|
|
52348af8ec | ||
|
|
39d15ead6f | ||
|
|
d232109fce | ||
|
|
8e9c43610d | ||
|
|
53a8c20cb9 | ||
|
|
333f60a2a6 | ||
|
|
0bacc20a58 | ||
|
|
3e932c9bdf | ||
|
|
cf8a170133 | ||
|
|
67a89d4b6b | ||
|
|
85c2cda7b6 | ||
|
|
61757a6518 | ||
|
|
e245d08e54 | ||
|
|
29f797dc24 | ||
|
|
54ce1d8d2f | ||
|
|
8e47f70066 | ||
|
|
01548089ee | ||
|
|
de8d598f46 | ||
|
|
63aad4b9bf | ||
|
|
33cdb7a541 | ||
|
|
7c2f769a9a | ||
|
|
e084550390 | ||
|
|
3c282e8cf9 | ||
|
|
3c4fbdb50e | ||
|
|
18cdc28963 | ||
|
|
5f004e7167 | ||
|
|
96489607ab | ||
|
|
7436e44416 | ||
|
|
8d30e51603 | ||
|
|
64b582e397 | ||
|
|
8b86d07bfc | ||
|
|
e3fefdebe1 | ||
|
|
46aec4a593 | ||
|
|
2feb3e1d7a | ||
|
|
2609f45799 | ||
|
|
9053cbb90f | ||
|
|
3794d7ab65 | ||
|
|
7eeca21a05 | ||
|
|
70464154c7 | ||
|
|
1b29078fad | ||
|
|
864b078610 | ||
|
|
1a8b319ce2 | ||
|
|
a353514fc8 | ||
|
|
06e294fb3e | ||
|
|
961d4c4a3a | ||
|
|
876aea39e5 | ||
|
|
67be2ba95b | ||
|
|
53d2d080f4 | ||
|
|
998fbeb381 | ||
|
|
1c6e4b7750 | ||
|
|
8fbe21c79c | ||
|
|
d6d0faac6e | ||
|
|
2d4f01e6cb | ||
|
|
b42ad3170e | ||
|
|
a8dddc81f1 | ||
|
|
2e1e6f784b | ||
|
|
2af9b95c7a | ||
|
|
90be010c2b | ||
|
|
3b6b16cf77 | ||
|
|
c0c5c87c29 | ||
|
|
f5bbf4b515 | ||
|
|
c7465608a7 | ||
|
|
03f0a4289b | ||
|
|
bb2a6b73fe | ||
|
|
8e66091dd2 | ||
|
|
a5c114a848 | ||
|
|
254b2c27ac | ||
|
|
29fcb4504c | ||
|
|
ec7402b80a | ||
|
|
4501519c4f | ||
|
|
58ad7dab1b | ||
|
|
4da26a2f8d | ||
|
|
9e6aed0760 | ||
|
|
7033f11d56 | ||
|
|
8fcac42f34 | ||
|
|
4a6a97ee75 | ||
|
|
2174d8fe8c | ||
|
|
eb6f487e2a | ||
|
|
6bbe68dfcb | ||
|
|
bbeceae42e | ||
|
|
cfe785762d | ||
|
|
fdbb329fb6 | ||
|
|
9f1100b967 | ||
|
|
94706d6139 | ||
|
|
b63609e2fa | ||
|
|
84c420139d | ||
|
|
027d21035e | ||
|
|
cc9de01c99 | ||
|
|
61c6f240e9 | ||
|
|
997d673b83 | ||
|
|
6c72846d63 | ||
|
|
8bd6e1d119 | ||
|
|
6484a8e6a4 | ||
|
|
0e8e108680 | ||
|
|
3435b6c4a4 | ||
|
|
d4af6af594 | ||
|
|
b834abd293 | ||
|
|
01a6dd79c4 | ||
|
|
948b6cf7e7 | ||
|
|
b1718f329e | ||
|
|
7237f549a6 | ||
|
|
30b1660005 | ||
|
|
200fe07473 | ||
|
|
86cb22d8c9 | ||
|
|
321766fd46 | ||
|
|
3eedad96ed | ||
|
|
4b26dac08a | ||
|
|
04ef069a20 | ||
|
|
b925ed60e3 | ||
|
|
dfd85a7c53 | ||
|
|
6ca63d4c68 | ||
|
|
2325b547fd | ||
|
|
34e454c054 | ||
|
|
302386d22c | ||
|
|
210c483635 | ||
|
|
8ca4212650 | ||
|
|
c91dba5ed6 | ||
|
|
c8de05f101 | ||
|
|
0ac7cde498 | ||
|
|
108829ad9c | ||
|
|
c5b96f4e9c | ||
|
|
4c2099d33e | ||
|
|
fe5de95008 | ||
|
|
4b0cfc0751 | ||
|
|
c2bf05942e | ||
|
|
df37f80c8e | ||
|
|
2c19d7218d | ||
|
|
34899e8d36 | ||
|
|
bf8c10ed25 | ||
|
|
93c33e08c2 | ||
|
|
3992dd1dd0 | ||
|
|
cab29c2be7 | ||
|
|
f582657ffd | ||
|
|
2823ac1aee | ||
|
|
289caa7cc2 | ||
|
|
0a8bad46b5 | ||
|
|
aa4f518262 | ||
|
|
f76fa879fc | ||
|
|
8d70aba1f5 | ||
|
|
a44bb35aec | ||
|
|
4fda2b656f | ||
|
|
e626d00fdf | ||
|
|
bf09e3c3ae | ||
|
|
753dcd3301 | ||
|
|
8b5dee510e | ||
|
|
9cb73fbf78 | ||
|
|
e6b4deb5c4 | ||
|
|
8848222728 | ||
|
|
3cd62994c7 | ||
|
|
dd93a97790 | ||
|
|
e40e2d2d14 | ||
|
|
26f8ce7b5a | ||
|
|
9a61e374b5 | ||
|
|
9b12e9819c | ||
|
|
5d0a91239c | ||
|
|
c848278690 | ||
|
|
2ebb929e2c | ||
|
|
b34334ba93 | ||
|
|
05a01cd803 | ||
|
|
9ac0c06f26 | ||
|
|
52af22b0e8 | ||
|
|
81cfc73b48 | ||
|
|
f892bfccdf | ||
|
|
dbed8fefac | ||
|
|
ca14637909 | ||
|
|
7db618fba5 | ||
|
|
29c74c09ce | ||
|
|
a2b5b9f97e | ||
|
|
6a05aa4e53 | ||
|
|
43fd5d233a | ||
|
|
0bd39ed035 | ||
|
|
1db8aad039 | ||
|
|
fb2d4267f5 | ||
|
|
d7b203ae08 | ||
|
|
3e07f2e3bc | ||
|
|
94cf6f6640 | ||
|
|
6da5fe4317 | ||
|
|
3a68dee850 | ||
|
|
2ccfa6a2e8 | ||
|
|
f7bf671050 | ||
|
|
4bff9cc3df | ||
|
|
13c68a0184 | ||
|
|
6d92949715 | ||
|
|
5cf31bd3f3 | ||
|
|
929d4c8d61 | ||
|
|
482f796bad | ||
|
|
d85f532ab1 | ||
|
|
b1654f7807 | ||
|
|
4f8526e527 | ||
|
|
4b568fc469 | ||
|
|
d06146ed97 | ||
|
|
8e0e809733 | ||
|
|
d1f33a6c4c | ||
|
|
b3e1b6fdbf | ||
|
|
0bd259403c | ||
|
|
c186846463 | ||
|
|
5f92c3b3fc | ||
|
|
0665091cef | ||
|
|
688d153427 | ||
|
|
bec5ba7a73 | ||
|
|
acedf4d6a3 | ||
|
|
5dd5494f93 | ||
|
|
f253e4fabe | ||
|
|
acd09d24d5 | ||
|
|
ceac95c81a | ||
|
|
47a05d0ea2 | ||
|
|
d2975479f2 | ||
|
|
3c238ffae7 | ||
|
|
69f8d1b717 | ||
|
|
45cd9e65d3 | ||
|
|
2e4b1d8c2b | ||
|
|
4e3b65188d | ||
|
|
0ab32e066b | ||
|
|
79d8b00b27 | ||
|
|
eb02c5a451 | ||
|
|
85509c777d | ||
|
|
27677f86e4 | ||
|
|
16174ca874 | ||
|
|
a4e9233231 | ||
|
|
4fdfafa17f | ||
|
|
c9a7dab419 | ||
|
|
8882d75132 | ||
|
|
f67b15b926 | ||
|
|
2d7958f726 | ||
|
|
36072584d0 | ||
|
|
2119e52f55 | ||
|
|
ca1aa6b663 | ||
|
|
10af671b76 | ||
|
|
a4ec6cce96 | ||
|
|
5082ba7102 | ||
|
|
7405e7001b | ||
|
|
4c70651b81 | ||
|
|
21b5b60278 | ||
|
|
0abc5ec452 | ||
|
|
b1d2d620fa | ||
|
|
af6e4abe84 | ||
|
|
45b4315842 | ||
|
|
d2cb96a9e5 | ||
|
|
a3ff845a14 | ||
|
|
621f05c687 | ||
|
|
daf97eabab | ||
|
|
ee3d11cb53 | ||
|
|
1bc7e5e0a5 | ||
|
|
9280d23b1a | ||
|
|
cacd52f81d | ||
|
|
95f64761ca | ||
|
|
6e24792b9b | ||
|
|
9afe26f1d6 | ||
|
|
e7d959da90 | ||
|
|
c3f0867d2c | ||
|
|
1eaf124d4e | ||
|
|
03076bdc76 | ||
|
|
cd32d6debe | ||
|
|
3212f059ff | ||
|
|
9ae4b93083 | ||
|
|
aae7af2194 | ||
|
|
63f4c73ef0 | ||
|
|
f93d3381e0 | ||
|
|
099c80e04b | ||
|
|
14face336e | ||
|
|
67b10d8d38 | ||
|
|
1219230168 | ||
|
|
8d840e694d | ||
|
|
87382aad4d | ||
|
|
aca3a05222 | ||
|
|
84ca145663 | ||
|
|
01d0338851 | ||
|
|
f427c0532d | ||
|
|
c8532a548c | ||
|
|
1e3aef5b94 | ||
|
|
0d3180271b | ||
|
|
f0d17b13f2 | ||
|
|
9a46301d46 | ||
|
|
3bd609ee41 | ||
|
|
2c7f0e8583 | ||
|
|
ce36a25ba3 | ||
|
|
c53484f92e | ||
|
|
f391ccb8e8 | ||
|
|
a96d6a8148 | ||
|
|
bdca09007d | ||
|
|
c0e84043c9 | ||
|
|
0a884df74f | ||
|
|
519b14d506 | ||
|
|
f008a65d91 | ||
|
|
61bb70cd30 | ||
|
|
68fa3dadb0 | ||
|
|
eb38d03976 | ||
|
|
d480bb3ecd | ||
|
|
dfdb6fa1a6 | ||
|
|
42352d9f57 | ||
|
|
eae1c5db70 | ||
|
|
cc37097164 | ||
|
|
6597cc9ce8 | ||
|
|
b3f752d46c | ||
|
|
679e2d0f6b | ||
|
|
4607079ca9 | ||
|
|
ad1a42d6a5 | ||
|
|
afdf31a66c | ||
|
|
37956e2f05 | ||
|
|
dc6aa66f9a | ||
|
|
f16f16c15e | ||
|
|
3b95cbd960 | ||
|
|
3b5e8edd37 | ||
|
|
5f4571e895 | ||
|
|
2d5e991eaf | ||
|
|
7ba8bb4405 | ||
|
|
82aa181540 | ||
|
|
1a3e17bae8 | ||
|
|
e0e3664fdb | ||
|
|
23bfaf1ba2 | ||
|
|
e7d72b6f53 | ||
|
|
eab26deab9 | ||
|
|
49540dbe5e | ||
|
|
cbd891785e | ||
|
|
b1cc732cb2 | ||
|
|
b3b4f55c68 | ||
|
|
8b6b039c13 | ||
|
|
9dca62ff8b | ||
|
|
e0892fcebb | ||
|
|
adf1443105 | ||
|
|
53c2558d26 | ||
|
|
a5ea240793 | ||
|
|
4cd1629118 | ||
|
|
ce32a73e86 | ||
|
|
8a13fc7cd9 | ||
|
|
708de50887 | ||
|
|
4df478316c | ||
|
|
a5dff9fb15 | ||
|
|
b51f4d53b6 | ||
|
|
7d045842dd | ||
|
|
a9ece9e49d | ||
|
|
e6da067cf8 | ||
|
|
bae40c82b9 | ||
|
|
651edf5bc0 | ||
|
|
3a8642b1e0 | ||
|
|
09b6b9259c | ||
|
|
907f326788 | ||
|
|
4a350d8ad9 | ||
|
|
3881db0b4e | ||
|
|
9edae3e877 | ||
|
|
236208e393 | ||
|
|
4ff98de707 | ||
|
|
54964629fe | ||
|
|
072f606784 | ||
|
|
21d2338ec1 | ||
|
|
0d468e0df4 | ||
|
|
5007d49c83 | ||
|
|
35ba69a175 | ||
|
|
fa0ce2a14c | ||
|
|
389750d7d8 | ||
|
|
6c7db7ad23 | ||
|
|
2986426251 | ||
|
|
56444ebcaf | ||
|
|
c63a1978cb | ||
|
|
9d9e998d49 | ||
|
|
f7c991fa9a | ||
|
|
4d14fbb1e7 | ||
|
|
5428730e7a | ||
|
|
bf773df099 | ||
|
|
6dea5100b1 | ||
|
|
aa55f4dceb | ||
|
|
516e92926a | ||
|
|
2cd9994321 | ||
|
|
e69306a2ba | ||
|
|
93ecd031bd | ||
|
|
4eaf69dfa7 | ||
|
|
bc93bda1b7 | ||
|
|
6923f0df2a | ||
|
|
bc584aa56e | ||
|
|
ec95d06f6c | ||
|
|
c5d18d9046 | ||
|
|
af06983c60 | ||
|
|
e027872f50 | ||
|
|
e98e4fde8d | ||
|
|
2daf9de890 | ||
|
|
ae50511135 | ||
|
|
2227f83b1d | ||
|
|
e764a2298d | ||
|
|
ed4a8c2a36 | ||
|
|
8cc3e571e3 | ||
|
|
66a89a7d54 | ||
|
|
666be94a71 | ||
|
|
49fabf23a8 | ||
|
|
a3b23e348a | ||
|
|
384e887fdb | ||
|
|
d3e84cbc4c | ||
|
|
1b06948fb0 | ||
|
|
98d075728f | ||
|
|
1a7ecda67c | ||
|
|
067078db86 | ||
|
|
37650fae75 | ||
|
|
13be3e3216 | ||
|
|
87a7809104 | ||
|
|
e82c33716a | ||
|
|
9ebdddad1f | ||
|
|
90f85bb9c3 | ||
|
|
002d04a3a1 | ||
|
|
88a0b12e73 | ||
|
|
5828e7f576 | ||
|
|
a11da90d10 | ||
|
|
d8026833dc | ||
|
|
8029bb6142 | ||
|
|
baaddd395c | ||
|
|
8bcbe7b3c6 | ||
|
|
4297320886 | ||
|
|
614994d8c7 | ||
|
|
65e1f261c0 | ||
|
|
aa4caa6938 | ||
|
|
9741574516 | ||
|
|
c27c654180 | ||
|
|
c63580ee38 | ||
|
|
e9d4328fad | ||
|
|
545f9f2cca | ||
|
|
db6930d9e4 | ||
|
|
9379a41b37 | ||
|
|
c0eeedc71a | ||
|
|
400197def8 | ||
|
|
0f8b202531 | ||
|
|
1eb9775f34 | ||
|
|
89bdb315d5 | ||
|
|
ab1afd68b7 | ||
|
|
e1109e9e51 | ||
|
|
7230e19166 | ||
|
|
eb7a94bb55 | ||
|
|
18de4e57eb | ||
|
|
74cc12133e | ||
|
|
7583354f44 | ||
|
|
14c49dd681 | ||
|
|
e060208417 | ||
|
|
635eea7acb | ||
|
|
2c47f4a23d | ||
|
|
2223577302 | ||
|
|
f42d235dec | ||
|
|
06a3e278ff | ||
|
|
17c30b5fdc | ||
|
|
024b30d0b7 | ||
|
|
a108610a67 | ||
|
|
12b6abe6a3 | ||
|
|
6f82b36962 | ||
|
|
ea6b397526 | ||
|
|
118bb3f3ba | ||
|
|
bd68075f4d | ||
|
|
5fa68f8cdd | ||
|
|
199aaf2d05 | ||
|
|
892efcc166 | ||
|
|
bc90c6b82f | ||
|
|
82d3d1f0f3 | ||
|
|
576b3198f1 | ||
|
|
f55cad8f1c | ||
|
|
d98654b50d | ||
|
|
675d9d8c09 | ||
|
|
bab0bb349f | ||
|
|
65d3ed8ce8 | ||
|
|
8fc4000b63 | ||
|
|
5b35f781cb | ||
|
|
2cd11b7da7 | ||
|
|
cf30d2923c | ||
|
|
8fc97794e8 | ||
|
|
df2ba37687 | ||
|
|
85b16b2a54 | ||
|
|
eeabc6b61a | ||
|
|
2b3dafed61 | ||
|
|
7232fc36ab | ||
|
|
a8e1fd1054 | ||
|
|
c248a50338 | ||
|
|
fa0ca23798 | ||
|
|
ed224cf912 | ||
|
|
b51df25371 | ||
|
|
db8cc8eb7b | ||
|
|
a027e9fe14 | ||
|
|
b882ca809a | ||
|
|
daf0a9dc9a | ||
|
|
f2dafa7544 | ||
|
|
7fe22875a6 | ||
|
|
3da3c8ecd8 | ||
|
|
254acbbbe2 | ||
|
|
519c850f17 | ||
|
|
1cf57508b0 | ||
|
|
f8bacfcc67 | ||
|
|
9daa77c1a4 | ||
|
|
c4775dd313 | ||
|
|
ae87cb031e | ||
|
|
3c049f25ee | ||
|
|
85a90b62b7 | ||
|
|
10b0124951 | ||
|
|
c0d7ff9543 | ||
|
|
74012d4869 | ||
|
|
830c40440f | ||
|
|
21a2f71ad9 | ||
|
|
cf75e3e664 | ||
|
|
ffc307323a | ||
|
|
ff0aec28c5 | ||
|
|
31394b03ae | ||
|
|
2ab93cb385 | ||
|
|
172b396dc9 | ||
|
|
9b82d08087 | ||
|
|
410617f73b | ||
|
|
ade0d38a7c | ||
|
|
3ce55a2ac4 | ||
|
|
cc6e4dbec0 | ||
|
|
2935ae7bf1 | ||
|
|
96e418e63b | ||
|
|
e4a84dcfe9 | ||
|
|
9ea91cfce3 | ||
|
|
8c7f0cf988 | ||
|
|
afa9a00259 | ||
|
|
a0ee11c300 | ||
|
|
6e02dace18 | ||
|
|
93bac6f26f | ||
|
|
8657fbd810 | ||
|
|
68203be004 | ||
|
|
b2323ef2e7 | ||
|
|
70b017fb72 | ||
|
|
607e3bbc11 | ||
|
|
315c9285de | ||
|
|
c22427b8fd | ||
|
|
2fcfac9e84 | ||
|
|
7cc857233f | ||
|
|
f85aa09784 | ||
|
|
0b0cecc2a9 | ||
|
|
3b5b9c9587 | ||
|
|
cbe190fa70 | ||
|
|
9156466351 | ||
|
|
f79caf095d | ||
|
|
d31dcd13fc | ||
|
|
552224bbfe | ||
|
|
5ba01674fb | ||
|
|
7390afc5e1 | ||
|
|
85ec23d552 | ||
|
|
007064c0ac | ||
|
|
fd53756170 | ||
|
|
9e6dd9f23d | ||
|
|
ef8be6c7c2 | ||
|
|
de4b5b70da | ||
|
|
9edeee4b3f | ||
|
|
767a0cc1fd | ||
|
|
ae09247e34 | ||
|
|
a3ea4798bc | ||
|
|
af54a22d16 | ||
|
|
b026bfc71b | ||
|
|
80d80ad8aa | ||
|
|
dbecf33924 | ||
|
|
2b08e3604d | ||
|
|
7d3a672c2b | ||
|
|
022e46ae38 | ||
|
|
3f930d228e | ||
|
|
5eba370f7b | ||
|
|
e138951e9e | ||
|
|
5cd18d7275 | ||
|
|
d7ff5a53a7 | ||
|
|
aa14bb6fdf | ||
|
|
c275f682a9 | ||
|
|
08894025bc | ||
|
|
b063a48520 | ||
|
|
858d38d314 | ||
|
|
f5875d09e9 | ||
|
|
34db181686 | ||
|
|
be55ea2b0b | ||
|
|
aa0dd4d10d | ||
|
|
39533e4209 | ||
|
|
4bba3bf1d2 | ||
|
|
2d29d1549a | ||
|
|
c7a078f17f | ||
|
|
2cf92037e9 | ||
|
|
452ee7a103 | ||
|
|
68f70af2f3 | ||
|
|
11682e487e | ||
|
|
4d006230f9 | ||
|
|
a32f4bb05c | ||
|
|
6d4e260127 | ||
|
|
45404b5bcf | ||
|
|
861551b2ba | ||
|
|
aac820a8d5 | ||
|
|
a5ff25b0fe | ||
|
|
b81638794f | ||
|
|
88cfeb2791 | ||
|
|
d0b57535ed | ||
|
|
528add4702 | ||
|
|
dd47971877 | ||
|
|
d51a99c8e2 | ||
|
|
e192f01dc3 | ||
|
|
aedaf57249 | ||
|
|
222e58e76e | ||
|
|
c8fc80f4a0 | ||
|
|
1ed180887d | ||
|
|
d6a38a567f | ||
|
|
ae9c3276bc | ||
|
|
35d34cd4e8 | ||
|
|
4f45824632 | ||
|
|
532da174dd | ||
|
|
dbe13feba2 | ||
|
|
1c93061a7f | ||
|
|
0e371930e6 | ||
|
|
06bd748bd6 | ||
|
|
b64775772b | ||
|
|
5f76314085 | ||
|
|
57588ea936 | ||
|
|
3f344b55bb | ||
|
|
e4ae0980b4 | ||
|
|
e41da0d697 | ||
|
|
ce3955d393 | ||
|
|
22a2cc564f | ||
|
|
2b19513a05 | ||
|
|
60f8fe6f41 | ||
|
|
a2fd010521 | ||
|
|
a36d5b6302 | ||
|
|
2c14dc16dd | ||
|
|
4c7f3f7972 | ||
|
|
794df59265 | ||
|
|
3dd71713c2 | ||
|
|
c0777d1a0a | ||
|
|
55392cb047 | ||
|
|
070eedda18 | ||
|
|
ae6ec78dc3 | ||
|
|
9fe1b2a565 | ||
|
|
f374419be3 | ||
|
|
0ff25cb116 | ||
|
|
d7e50f352a | ||
|
|
aa9254eeb0 | ||
|
|
c1eba336a8 | ||
|
|
a5d7fc484a | ||
|
|
7a294e6d4e | ||
|
|
2f79417d0d | ||
|
|
73b42f924d | ||
|
|
ccf915e798 | ||
|
|
62ffa14f10 | ||
|
|
5d7840a34c | ||
|
|
fd14f6ff73 | ||
|
|
88962f9358 | ||
|
|
5bec1729f1 | ||
|
|
f3662fc152 | ||
|
|
c5047186dd | ||
|
|
1e39bd8336 | ||
|
|
e58de234ac | ||
|
|
903cc181c4 | ||
|
|
2183a098c3 | ||
|
|
1d4cba9180 | ||
|
|
ed724c5280 | ||
|
|
fbd13ac42c | ||
|
|
ea6eab557b | ||
|
|
a1cb2a0589 | ||
|
|
5de5a8ca94 | ||
|
|
274026d338 | ||
|
|
3875bc34bd | ||
|
|
8db3ccce2e | ||
|
|
34bb6fd851 | ||
|
|
ffa74db136 | ||
|
|
66f2cbb91f | ||
|
|
a57d49b057 | ||
|
|
7b41a0ff16 | ||
|
|
4ca50f8973 | ||
|
|
abe2c6870b | ||
|
|
c0ae681d69 | ||
|
|
b4745c0134 | ||
|
|
d369a6429e | ||
|
|
af3e326178 | ||
|
|
8e256a2d5d | ||
|
|
bdcbd9008d | ||
|
|
453faa6a76 | ||
|
|
b0941faf88 | ||
|
|
91ba215568 | ||
|
|
be32f4072e | ||
|
|
bcb217c1da | ||
|
|
490a16a8df | ||
|
|
28d8c56534 | ||
|
|
46423ed166 | ||
|
|
4286a510b4 | ||
|
|
8d193ab39f | ||
|
|
439e377111 | ||
|
|
28ebce6b65 | ||
|
|
2ccd1625e7 | ||
|
|
e05e61a59b | ||
|
|
4660eae8c7 | ||
|
|
e55e90db1a | ||
|
|
23da63767c | ||
|
|
13b19c35c6 | ||
|
|
7e25ec1ac3 | ||
|
|
ab1d05642e | ||
|
|
079b28fddf | ||
|
|
d52d62badb | ||
|
|
fa53135c8a | ||
|
|
d6a3f9fd8f | ||
|
|
75ca4af74e | ||
|
|
dc5fc6bdc2 | ||
|
|
67f8ee61a4 | ||
|
|
2153cf39b5 | ||
|
|
0ead82ae21 | ||
|
|
98d4cf7585 | ||
|
|
3259536411 | ||
|
|
f3a79cc779 | ||
|
|
c45c6dbe67 | ||
|
|
a1518c33af | ||
|
|
a9f7cdb630 | ||
|
|
6f678294a0 | ||
|
|
de07abee98 | ||
|
|
437edefa0c | ||
|
|
f5b36ecbac | ||
|
|
8772c85964 | ||
|
|
a31454327a | ||
|
|
9e55cb114c | ||
|
|
04416a67d3 | ||
|
|
dd2cdaf49a | ||
|
|
8c45eb7524 | ||
|
|
c20bea50e3 | ||
|
|
fe18c35dab | ||
|
|
f6ef6abdf1 | ||
|
|
43a6837e81 | ||
|
|
dc4b933000 | ||
|
|
c90703dc13 | ||
|
|
2165941026 | ||
|
|
4a28893171 | ||
|
|
369581976a | ||
|
|
7fef683980 | ||
|
|
8358f68086 | ||
|
|
0aa6b03c2a | ||
|
|
44f8c98660 | ||
|
|
188ec6ea1d | ||
|
|
8169d8509f | ||
|
|
e217d39882 | ||
|
|
887ee0fd41 | ||
|
|
137e93319e | ||
|
|
48a1384197 | ||
|
|
8aed4d634b | ||
|
|
fd0cb4c458 | ||
|
|
82735f0fab | ||
|
|
1d3710afd8 | ||
|
|
e8ae92f4d4 | ||
|
|
b2e54a0590 | ||
|
|
d64d220b49 | ||
|
|
2523a95a9a | ||
|
|
207c41581c | ||
|
|
6fc4a3ed04 | ||
|
|
2fabb6951e | ||
|
|
8c2f5f91d5 | ||
|
|
7443d41444 | ||
|
|
4421734da1 | ||
|
|
4385ca0966 | ||
|
|
57fa592a13 | ||
|
|
1298118b59 | ||
|
|
3f2cb40cc1 | ||
|
|
5448abb304 | ||
|
|
892fab5455 | ||
|
|
ef3619350d | ||
|
|
846fb3e7f3 | ||
|
|
e00e9ba5aa | ||
|
|
f41511047e | ||
|
|
16352df5b1 | ||
|
|
5238c2457d | ||
|
|
4d57f414f5 | ||
|
|
6305088cb0 | ||
|
|
e2db1cd425 | ||
|
|
16561a8e84 | ||
|
|
cae1b3ebd4 | ||
|
|
e68737dcfb | ||
|
|
00448d23c0 | ||
|
|
272ae547ef | ||
|
|
3fd688191c | ||
|
|
5c0b6f2225 | ||
|
|
cc530e3446 | ||
|
|
fdc1d46b89 | ||
|
|
5dce677091 | ||
|
|
d0fb5a4b04 | ||
|
|
e27daed0ec | ||
|
|
d2183a8b32 | ||
|
|
0b2d6407dd | ||
|
|
ec1b1ffe16 | ||
|
|
32a66be555 | ||
|
|
c090c34491 | ||
|
|
4f7d3ad76c | ||
|
|
ce81872686 | ||
|
|
2314c41103 | ||
|
|
df39b66e11 | ||
|
|
adeb5de19f | ||
|
|
26312e0c0e | ||
|
|
cd6d4021b1 | ||
|
|
24d345a970 | ||
|
|
b4fd4a0c38 | ||
|
|
451e695006 | ||
|
|
26b771f9f9 | ||
|
|
0679aedb7e | ||
|
|
bfa4e08a4e | ||
|
|
c1185a34aa | ||
|
|
be0ce57375 | ||
|
|
b204b90ffc | ||
|
|
364b6938a5 | ||
|
|
e188925d2b | ||
|
|
10a47cdbbb | ||
|
|
67014ae4f8 | ||
|
|
b93fc3f028 | ||
|
|
b6e5980510 | ||
|
|
79e8921f76 | ||
|
|
34fe3ca4fc | ||
|
|
f26311c60e | ||
|
|
43f9907af7 | ||
|
|
0e6f5d154e | ||
|
|
7042dd8447 | ||
|
|
05031e0979 | ||
|
|
28b3f6780c | ||
|
|
f8335c6df9 | ||
|
|
9dcdc1f8f3 | ||
|
|
9ae7d4f2bf | ||
|
|
c158169bdf | ||
|
|
e4c1285eaf | ||
|
|
02a5375503 | ||
|
|
32883b4e18 | ||
|
|
6d585e88a4 | ||
|
|
73570b5628 | ||
|
|
e7fcb068d9 | ||
|
|
a137a70278 | ||
|
|
72113991a8 | ||
|
|
a04fb8e7de | ||
|
|
ca2f30cd61 | ||
|
|
ebfad05e3f | ||
|
|
f54ea9d978 | ||
|
|
d4c84cee19 | ||
|
|
4da59cdc97 | ||
|
|
d4e7eb5888 | ||
|
|
f8b0a7105b | ||
|
|
aecde91d33 | ||
|
|
870dde232a | ||
|
|
f7d7f81c49 | ||
|
|
1f04c61482 | ||
|
|
5d957a6b7c | ||
|
|
94f61b0a0c | ||
|
|
de6535b722 | ||
|
|
6dd18e4328 | ||
|
|
c46e4453c7 | ||
|
|
2e6312ec03 | ||
|
|
1566a834e1 | ||
|
|
607deaa3c4 | ||
|
|
686186d5ba | ||
|
|
0c1ef72285 | ||
|
|
d6bd12cfcd | ||
|
|
4a1712f4cd | ||
|
|
b4e298230d | ||
|
|
6cb42a4251 | ||
|
|
3ead4b4d4b | ||
|
|
3c0e321538 | ||
|
|
1f67434c8c | ||
|
|
6058b9851c | ||
|
|
c586319978 | ||
|
|
0591fe0e8b | ||
|
|
dabe3b17e6 | ||
|
|
fbf50d45cb | ||
|
|
d59075e897 | ||
|
|
2b491179f7 | ||
|
|
a62d17b1b1 | ||
|
|
2431758218 | ||
|
|
b94586fdf4 | ||
|
|
a6b83d77bd | ||
|
|
43c55b36c8 | ||
|
|
24c7928c4b | ||
|
|
8c876c302a | ||
|
|
778a4373ae | ||
|
|
7a15cf1157 | ||
|
|
54e3210d7e | ||
|
|
a3197c12a8 | ||
|
|
e7de841939 | ||
|
|
29ba00f370 | ||
|
|
e35d70f338 | ||
|
|
0271c65ca2 | ||
|
|
e604524301 | ||
|
|
298831d987 | ||
|
|
3b2e97a729 | ||
|
|
edaba44c87 | ||
|
|
dc2dc910e8 | ||
|
|
96bf260ce9 | ||
|
|
115ea4ccbb | ||
|
|
3fb400beb4 | ||
|
|
6442279a44 | ||
|
|
592500cb0c | ||
|
|
98f3e45c0a | ||
|
|
e365196ee3 | ||
|
|
f656499c23 | ||
|
|
180c019d2e | ||
|
|
7db50921bc | ||
|
|
257b3f3ee6 | ||
|
|
f7c69b6baf | ||
|
|
89a3b84ea1 | ||
|
|
bec29f99e6 | ||
|
|
72274bda82 | ||
|
|
04b62a62cb | ||
|
|
ab7329d3eb | ||
|
|
a819796ce2 | ||
|
|
8c6cdcc97e | ||
|
|
bf0148e047 | ||
|
|
bcf44b8ab2 | ||
|
|
ebc9711309 | ||
|
|
4097f90938 | ||
|
|
d73f77affc | ||
|
|
b4794dc541 | ||
|
|
5ee156057e | ||
|
|
68a63bb280 | ||
|
|
815677863f | ||
|
|
df2f13c9b6 | ||
|
|
3984037c98 | ||
|
|
9c8570b37d | ||
|
|
f7cddb81df | ||
|
|
dc1fbbf796 | ||
|
|
7b7b4e5f22 | ||
|
|
8c9b0285e4 | ||
|
|
3ff5caef94 | ||
|
|
4a3446a0a5 | ||
|
|
6f6d9b39ba | ||
|
|
7d2f68c5e4 | ||
|
|
5416e92dbf | ||
|
|
340b5bd165 | ||
|
|
fbd15a81b4 | ||
|
|
039d0abce2 | ||
|
|
aefb65b1b8 | ||
|
|
f7c322c311 | ||
|
|
b5507f79e4 | ||
|
|
a2703ce51b | ||
|
|
d48b12aa09 | ||
|
|
452c1fbfd4 |
93
.github/workflows/go.yml
vendored
93
.github/workflows/go.yml
vendored
@@ -5,45 +5,74 @@ name: Go
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
branches: [ "*" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
branches: [ "*" ]
|
||||
|
||||
jobs:
|
||||
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest]
|
||||
llvm: [17]
|
||||
runs-on: ${{ matrix.os }}
|
||||
os:
|
||||
- macos-latest
|
||||
- ubuntu-24.04
|
||||
llvm: [18]
|
||||
runs-on: ${{matrix.os}}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Update Homebrew
|
||||
# needed as long as LLVM 17 is still fresh
|
||||
if: matrix.llvm == 17 && startsWith(matrix.os, 'macos')
|
||||
run: brew update
|
||||
- name: Install LLVM ${{ matrix.llvm }} and bdw-gc
|
||||
- name: Install dependencies
|
||||
if: startsWith(matrix.os, 'macos')
|
||||
run: |
|
||||
HOMEBREW_NO_AUTO_UPDATE=1 brew install llvm@${{ matrix.llvm }} bdw-gc
|
||||
echo `brew --prefix llvm@${{ matrix.llvm }}`/bin >> $GITHUB_PATH
|
||||
- name: Install LLVM ${{ matrix.llvm }} and libgc-dev
|
||||
brew update
|
||||
brew install llvm@${{matrix.llvm}} pkg-config bdw-gc openssl
|
||||
echo "$(brew --prefix llvm@${{matrix.llvm}})/bin" >> $GITHUB_PATH
|
||||
|
||||
# Install optional deps for demos.
|
||||
#
|
||||
# NOTE: Keep this list updated as new deps are introduced.
|
||||
opt_deps=(
|
||||
cjson # for github.com/goplus/llgo/c/cjson
|
||||
sqlite # for github.com/goplus/llgo/c/sqlite
|
||||
python@3.12 # for github.com/goplus/llgo/py
|
||||
)
|
||||
brew install "${opt_deps[@]}"
|
||||
|
||||
- name: Install dependencies
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
run: |
|
||||
echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-${{ matrix.llvm }} main' | sudo tee /etc/apt/sources.list.d/llvm.list
|
||||
echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${{matrix.llvm}} main" | sudo tee /etc/apt/sources.list.d/llvm.list
|
||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||
sudo apt-get update
|
||||
sudo apt-get install --no-install-recommends clang-${{ matrix.llvm }} llvm-${{ matrix.llvm }}-dev libgc-dev
|
||||
echo /usr/lib/llvm-${{ matrix.llvm }}/bin >> $GITHUB_PATH
|
||||
|
||||
sudo apt-get install -y llvm-${{matrix.llvm}}-dev clang-${{matrix.llvm}} lld-${{matrix.llvm}} pkg-config libgc-dev libssl-dev zlib1g-dev
|
||||
echo "/usr/lib/llvm-${{matrix.llvm}}/bin" >> $GITHUB_PATH
|
||||
|
||||
# Install optional deps for demos.
|
||||
#
|
||||
# NOTE: Keep this list updated as new deps are introduced.
|
||||
opt_deps=(
|
||||
libcjson-dev # for github.com/goplus/llgo/c/cjson
|
||||
libsqlite3-dev # for github.com/goplus/llgo/c/sqlite
|
||||
python3.12-dev # for github.com/goplus/llgo/py
|
||||
)
|
||||
sudo apt-get install -y "${opt_deps[@]}"
|
||||
|
||||
- name: Install further optional dependencies for demos
|
||||
run: |
|
||||
wget -P ./_demo/llama2-c https://huggingface.co/karpathy/tinyllamas/resolve/main/stories15M.bin
|
||||
py_deps=(
|
||||
numpy # for github.com/goplus/llgo/py/numpy
|
||||
torch # for github.com/goplus/llgo/py/torch
|
||||
)
|
||||
pip3 install --break-system-packages "${py_deps[@]}"
|
||||
|
||||
- name: Clang information
|
||||
run: |
|
||||
echo $PATH
|
||||
which clang
|
||||
clang --version
|
||||
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
@@ -53,28 +82,26 @@ jobs:
|
||||
run: go build -v ./...
|
||||
|
||||
- name: Test
|
||||
if: matrix.os != 'macos-latest'
|
||||
if: ${{!startsWith(matrix.os, 'macos')}}
|
||||
run: go test -v ./...
|
||||
|
||||
- name: Test with coverage
|
||||
if: matrix.os == 'macos-latest'
|
||||
if: startsWith(matrix.os, 'macos')
|
||||
run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./...
|
||||
|
||||
- name: Install
|
||||
run: go install ./...
|
||||
|
||||
|
||||
- name: LLGO tests
|
||||
if: matrix.os != 'ubuntu-latest'
|
||||
if: ${{!startsWith(matrix.os, 'ubuntu')}}
|
||||
run: |
|
||||
echo "Test result on ${{ matrix.os }} with LLVM ${{ matrix.llvm }}" > result.md
|
||||
LLGOROOT=$PWD bash .github/workflows/test_llgo.sh
|
||||
|
||||
- name: Test _demo and _pydemo
|
||||
run: |
|
||||
set +e
|
||||
LLGOROOT=$PWD bash .github/workflows/test_demo.sh
|
||||
exit 0
|
||||
|
||||
echo "Test result on ${{matrix.os}} with LLVM ${{matrix.llvm}}" > result.md
|
||||
bash .github/workflows/test_llgo.sh
|
||||
|
||||
- name: Test demos
|
||||
continue-on-error: true
|
||||
run: bash .github/workflows/test_demo.sh
|
||||
|
||||
- name: Show test result
|
||||
run: cat result.md
|
||||
|
||||
@@ -83,10 +110,10 @@ jobs:
|
||||
if: false
|
||||
with:
|
||||
filePath: result.md
|
||||
comment_tag: test-result-on-${{ matrix.os }}-with-llvm-${{ matrix.llvm }}
|
||||
comment_tag: test-result-on-${{matrix.os}}-with-llvm-${{matrix.llvm}}
|
||||
|
||||
- name: Upload coverage reports to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
token: ${{secrets.CODECOV_TOKEN}}
|
||||
slug: goplus/llgo
|
||||
|
||||
40
.github/workflows/populate_darwin_sysroot.sh
vendored
Executable file
40
.github/workflows/populate_darwin_sysroot.sh
vendored
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
TMPDIR="$(mktemp -d)"
|
||||
export TMPDIR
|
||||
trap 'rm -rf "${TMPDIR}"' EXIT
|
||||
|
||||
DARWIN_AMD64_LLVM_PREFIX=.sysroot/darwin/amd64/usr/local/opt/llvm@18
|
||||
DARWIN_ARM64_LLVM_PREFIX=.sysroot/darwin/arm64/opt/homebrew/opt/llvm@18
|
||||
mkdir -p "${DARWIN_AMD64_LLVM_PREFIX}" "${DARWIN_ARM64_LLVM_PREFIX}"
|
||||
|
||||
BREW_LLVM_FORMULA_JSON="$(mktemp)"
|
||||
curl -fsSL https://formulae.brew.sh/api/formula/llvm.json > "${BREW_LLVM_FORMULA_JSON}"
|
||||
BREW_LLVM_AMD64_BOTTLE_URL=$(jq -r '.bottle.stable.files.sonoma.url' "${BREW_LLVM_FORMULA_JSON}")
|
||||
BREW_LLVM_ARM64_BOTTLE_URL=$(jq -r '.bottle.stable.files.arm64_sonoma.url' "${BREW_LLVM_FORMULA_JSON}")
|
||||
curl -fsSL -H "Authorization: Bearer QQ==" "${BREW_LLVM_AMD64_BOTTLE_URL}" | tar -xzf - --strip-components=2 -C "${DARWIN_AMD64_LLVM_PREFIX}"
|
||||
curl -fsSL -H "Authorization: Bearer QQ==" "${BREW_LLVM_ARM64_BOTTLE_URL}" | tar -xzf - --strip-components=2 -C "${DARWIN_ARM64_LLVM_PREFIX}"
|
||||
|
||||
patch_homebrew_lib_dir() {
|
||||
local LIB_DIR="$1"
|
||||
local HOMEBREW_PREFIX="$2"
|
||||
for DYLIB_FILE in "${LIB_DIR}"/*.dylib; do
|
||||
if [[ -f "${DYLIB_FILE}" ]]; then
|
||||
ID=$(otool -D "${DYLIB_FILE}" | grep '@@HOMEBREW_PREFIX@@' | awk '{print $1}')
|
||||
if [[ -n "${ID}" ]]; then
|
||||
NEW_ID=${ID/'@@HOMEBREW_PREFIX@@'/${HOMEBREW_PREFIX}}
|
||||
install_name_tool -id "${NEW_ID}" "${DYLIB_FILE}"
|
||||
fi
|
||||
|
||||
DEPS=$(otool -L "${DYLIB_FILE}" | grep '@@HOMEBREW_PREFIX@@' | awk '{print $1}')
|
||||
for DEP in ${DEPS}; do
|
||||
NEW_DEP=${DEP/'@@HOMEBREW_PREFIX@@'/${HOMEBREW_PREFIX}}
|
||||
install_name_tool -change "${DEP}" "${NEW_DEP}" "${DYLIB_FILE}"
|
||||
done
|
||||
fi
|
||||
done
|
||||
}
|
||||
patch_homebrew_lib_dir "${DARWIN_AMD64_LLVM_PREFIX}/lib" /usr/lib
|
||||
patch_homebrew_lib_dir "${DARWIN_ARM64_LLVM_PREFIX}/lib" /opt/homebrew
|
||||
143
.github/workflows/populate_linux_sysroot.sh
vendored
Executable file
143
.github/workflows/populate_linux_sysroot.sh
vendored
Executable file
@@ -0,0 +1,143 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
TMPDIR="$(mktemp -d)"
|
||||
export TMPDIR
|
||||
trap 'rm -rf "${TMPDIR}"' EXIT
|
||||
|
||||
LINUX_AMD64_PREFIX=.sysroot/linux/amd64
|
||||
LINUX_ARM64_PREFIX=.sysroot/linux/arm64
|
||||
mkdir -p "${LINUX_AMD64_PREFIX}" "${LINUX_ARM64_PREFIX}"
|
||||
|
||||
POPULATE_LINUX_SYSROOT_SCRIPT="$(mktemp)"
|
||||
cat > "${POPULATE_LINUX_SYSROOT_SCRIPT}" << EOF
|
||||
#!/bin/bash
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
apt-get update
|
||||
apt-get install -y lsb-release gnupg2 wget rsync
|
||||
|
||||
echo "deb http://apt.llvm.org/\$(lsb_release -cs)/ llvm-toolchain-\$(lsb_release -cs)-18 main" | tee /etc/apt/sources.list.d/llvm.list
|
||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
|
||||
apt-get update
|
||||
apt-get install -y llvm-18-dev
|
||||
|
||||
error() {
|
||||
echo -e "\$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
exclude_list=()
|
||||
include_list=()
|
||||
|
||||
exclude_list+=(--exclude "/bin")
|
||||
exclude_list+=(--exclude "/boot")
|
||||
exclude_list+=(--exclude "/boot*")
|
||||
exclude_list+=(--exclude "/dev")
|
||||
exclude_list+=(--exclude "/etc")
|
||||
exclude_list+=(--exclude "/home")
|
||||
exclude_list+=(--exclude "/lib/dhcpd")
|
||||
exclude_list+=(--exclude "/lib/firmware")
|
||||
exclude_list+=(--exclude "/lib/hdparm")
|
||||
exclude_list+=(--exclude "/lib/ifupdown")
|
||||
exclude_list+=(--exclude "/lib/modules")
|
||||
exclude_list+=(--exclude "/lib/modprobe.d")
|
||||
exclude_list+=(--exclude "/lib/modules-load.d")
|
||||
exclude_list+=(--exclude "/lib/resolvconf")
|
||||
exclude_list+=(--exclude "/lib/startpar")
|
||||
exclude_list+=(--exclude "/lib/systemd")
|
||||
exclude_list+=(--exclude "/lib/terminfo")
|
||||
exclude_list+=(--exclude "/lib/udev")
|
||||
exclude_list+=(--exclude "/lib/xtables")
|
||||
exclude_list+=(--exclude "/lib/ssl/private")
|
||||
exclude_list+=(--exclude "/lost+found")
|
||||
exclude_list+=(--exclude "/media")
|
||||
exclude_list+=(--exclude "/mnt")
|
||||
exclude_list+=(--exclude "/proc")
|
||||
exclude_list+=(--exclude "/root")
|
||||
exclude_list+=(--exclude "/run")
|
||||
exclude_list+=(--exclude "/sbin")
|
||||
exclude_list+=(--exclude "/srv")
|
||||
exclude_list+=(--exclude "/sys")
|
||||
exclude_list+=(--exclude "/tmp")
|
||||
exclude_list+=(--exclude "/usr/bin")
|
||||
exclude_list+=(--exclude "/usr/games")
|
||||
exclude_list+=(--exclude "/usr/sbin")
|
||||
exclude_list+=(--exclude "/usr/share")
|
||||
exclude_list+=(--exclude "/usr/src")
|
||||
exclude_list+=(--exclude "/usr/local/bin")
|
||||
exclude_list+=(--exclude "/usr/local/etc")
|
||||
exclude_list+=(--exclude "/usr/local/games")
|
||||
exclude_list+=(--exclude "/usr/local/man")
|
||||
exclude_list+=(--exclude "/usr/local/sbin")
|
||||
exclude_list+=(--exclude "/usr/local/share")
|
||||
exclude_list+=(--exclude "/usr/local/src")
|
||||
exclude_list+=(--exclude "/usr/lib/ssl/private")
|
||||
exclude_list+=(--exclude "/var")
|
||||
exclude_list+=(--exclude "/snap")
|
||||
exclude_list+=(--exclude "*python*")
|
||||
|
||||
include_list+=(--include "*.a")
|
||||
include_list+=(--include "*.so")
|
||||
include_list+=(--include "*.so.*")
|
||||
include_list+=(--include "*.h")
|
||||
include_list+=(--include "*.hh")
|
||||
include_list+=(--include "*.hpp")
|
||||
include_list+=(--include "*.hxx")
|
||||
include_list+=(--include "*.pc")
|
||||
include_list+=(--include "*.def")
|
||||
include_list+=(--include "*.inc")
|
||||
include_list+=(--include "/lib")
|
||||
include_list+=(--include "/lib32")
|
||||
include_list+=(--include "/lib64")
|
||||
include_list+=(--include "/libx32")
|
||||
include_list+=(--include "*/")
|
||||
|
||||
do-sync() {
|
||||
from=\$1
|
||||
to=\$2
|
||||
|
||||
args=()
|
||||
args+=(-a)
|
||||
args+=(-z)
|
||||
args+=(-m)
|
||||
args+=(-d)
|
||||
args+=(-h)
|
||||
args+=(--keep-dirlinks)
|
||||
args+=("--info=progress2")
|
||||
args+=(--delete)
|
||||
args+=(--prune-empty-dirs)
|
||||
args+=(--sparse)
|
||||
args+=(--links)
|
||||
args+=(--copy-unsafe-links)
|
||||
args+=("\${exclude_list[@]}")
|
||||
args+=("\${include_list[@]}")
|
||||
args+=(--exclude "*")
|
||||
args+=("\${from}")
|
||||
args+=("\${to}")
|
||||
|
||||
echo "\${args[@]}"
|
||||
rsync "\${args[@]}"
|
||||
|
||||
exit \$?
|
||||
}
|
||||
|
||||
do-sync / /sysroot/
|
||||
EOF
|
||||
chmod +x "${POPULATE_LINUX_SYSROOT_SCRIPT}"
|
||||
|
||||
populate_linux_sysroot() {
|
||||
local ARCH="$1"
|
||||
local PREFIX="$2"
|
||||
docker run \
|
||||
--rm \
|
||||
--platform "linux/${ARCH}" \
|
||||
-v "$(pwd)/${PREFIX}":/sysroot \
|
||||
-v "${POPULATE_LINUX_SYSROOT_SCRIPT}":/populate_linux_sysroot.sh \
|
||||
debian:bullseye \
|
||||
/populate_linux_sysroot.sh
|
||||
}
|
||||
populate_linux_sysroot amd64 "${LINUX_AMD64_PREFIX}"
|
||||
populate_linux_sysroot arm64 "${LINUX_ARM64_PREFIX}"
|
||||
58
.github/workflows/release-build.yml
vendored
Normal file
58
.github/workflows/release-build.yml
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
name: Release Build
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
populate-darwin-sysroot:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
- name: Populate Darwin sysroot
|
||||
run: bash .github/workflows/populate_darwin_sysroot.sh
|
||||
- name: Create Darwin sysroot tarball
|
||||
run: tar -czvf .sysroot/darwin.tar.gz -C .sysroot darwin
|
||||
- name: Upload Darwin sysroot tarball
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: darwin-sysroot-tarball
|
||||
path: .sysroot/darwin.tar.gz
|
||||
compression-level: 0
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: populate-darwin-sysroot
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: 1.20.x
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Download Darwin sysroot tarball
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: darwin-sysroot-tarball
|
||||
path: .sysroot
|
||||
- name: Populate Darwin sysroot
|
||||
run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot
|
||||
- name: Populate Linux sysroot
|
||||
run: bash .github/workflows/populate_linux_sysroot.sh
|
||||
- name: Run GoReleaser
|
||||
env:
|
||||
GITHUB_TOKEN: ${{github.token}}
|
||||
run: |
|
||||
docker run \
|
||||
--rm \
|
||||
-e GITHUB_TOKEN=${GITHUB_TOKEN} \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v $(pwd):/go/src/llgo \
|
||||
-w /go/src/llgo \
|
||||
ghcr.io/goreleaser/goreleaser-cross:v1.22 \
|
||||
release --clean --skip nfpm,snapcraft
|
||||
3
.github/workflows/test_demo.sh
vendored
3
.github/workflows/test_demo.sh
vendored
@@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# llgo run subdirectories under _demo and _pydemo
|
||||
total=0
|
||||
@@ -8,7 +9,7 @@ for d in ./_demo/* ./_pydemo/*; do
|
||||
total=$((total+1))
|
||||
if [ -d "$d" ]; then
|
||||
echo "Testing $d"
|
||||
if ! llgo run -v "$d"; then
|
||||
if ! (cd "$d" && llgo run .); then
|
||||
echo "FAIL"
|
||||
failed=$((failed+1))
|
||||
failed_cases="$failed_cases\n* :x: $d"
|
||||
|
||||
4
.github/workflows/test_llgo.sh
vendored
4
.github/workflows/test_llgo.sh
vendored
@@ -1,10 +1,8 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
export LLGOROOT=$PWD
|
||||
|
||||
testcmd=/tmp/test
|
||||
llgo build -o $testcmd ./_test
|
||||
llgo build -o $testcmd ./c/bdwgc/_test
|
||||
cases=$($testcmd)
|
||||
total=$(echo "$cases" | wc -l | tr -d ' ')
|
||||
failed=0
|
||||
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -19,6 +19,7 @@ numpy.txt
|
||||
_go/
|
||||
_runtime/
|
||||
_tinygo/
|
||||
_output/
|
||||
build.dir/
|
||||
.vscode/
|
||||
|
||||
@@ -34,3 +35,7 @@ build.dir/
|
||||
|
||||
# Go workspace file
|
||||
go.work*
|
||||
|
||||
# GoReleaser
|
||||
.dist/
|
||||
.sysroot/
|
||||
|
||||
145
.goreleaser.yaml
Normal file
145
.goreleaser.yaml
Normal file
@@ -0,0 +1,145 @@
|
||||
version: 2
|
||||
|
||||
dist: .dist
|
||||
|
||||
env:
|
||||
- SYSROOT_DARWIN_AMD64={{.Env.PWD}}/.sysroot/darwin/amd64
|
||||
- SYSROOT_DARWIN_ARM64={{.Env.PWD}}/.sysroot/darwin/arm64
|
||||
- SYSROOT_LINUX_AMD64={{.Env.PWD}}/.sysroot/linux/amd64
|
||||
- SYSROOT_LINUX_ARM64={{.Env.PWD}}/.sysroot/linux/arm64
|
||||
- CGO_ENABLED=1
|
||||
- CGO_CXXFLAGS=-std=c++17
|
||||
|
||||
before:
|
||||
hooks:
|
||||
- go mod download
|
||||
|
||||
builds:
|
||||
- id: llgo-darwin-amd64
|
||||
main: ./cmd/llgo
|
||||
flags:
|
||||
- -tags=darwin,amd64,byollvm
|
||||
ldflags:
|
||||
- -X github.com/goplus/llgo/x/env.buildVersion=v{{.Version}}
|
||||
- -X github.com/goplus/llgo/x/env.buildTime={{.Date}}
|
||||
- -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=/usr/local/opt/llvm@18/bin/llvm-config
|
||||
env:
|
||||
- CC=o64-clang
|
||||
- CXX=o64-clang++
|
||||
- CGO_CPPFLAGS=-I{{.Env.SYSROOT_DARWIN_AMD64}}/usr/local/opt/llvm@18/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
|
||||
- CGO_LDFLAGS=-L{{.Env.SYSROOT_DARWIN_AMD64}}/usr/local/opt/llvm@18/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM-18 -lz -lm
|
||||
targets:
|
||||
- darwin_amd64
|
||||
mod_timestamp: "{{.CommitTimestamp}}"
|
||||
- id: llgo-darwin-arm64
|
||||
main: ./cmd/llgo
|
||||
flags:
|
||||
- -tags=darwin,arm64,byollvm
|
||||
ldflags:
|
||||
- -X github.com/goplus/llgo/x/env.buildVersion=v{{.Version}}
|
||||
- -X github.com/goplus/llgo/x/env.buildTime={{.Date}}
|
||||
- -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=/opt/homebrew/opt/llvm@18/bin/llvm-config
|
||||
env:
|
||||
- CC=oa64-clang
|
||||
- CXX=oa64-clang++
|
||||
- CGO_CPPFLAGS=-I{{.Env.SYSROOT_DARWIN_ARM64}}/opt/homebrew/opt/llvm@18/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
|
||||
- CGO_LDFLAGS=-L{{.Env.SYSROOT_DARWIN_ARM64}}/opt/homebrew/opt/llvm@18/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM-18 -lz -lm
|
||||
targets:
|
||||
- darwin_arm64
|
||||
mod_timestamp: "{{.CommitTimestamp}}"
|
||||
- id: llgo-linux-amd64
|
||||
main: ./cmd/llgo
|
||||
flags:
|
||||
- -tags=linux,amd64,byollvm
|
||||
ldflags:
|
||||
- -X github.com/goplus/llgo/x/env.buildVersion=v{{.Version}}
|
||||
- -X github.com/goplus/llgo/x/env.buildTime={{.Date}}
|
||||
- -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=/usr/lib/llvm-18/bin/llvm-config
|
||||
env:
|
||||
- CC=x86_64-linux-gnu-gcc
|
||||
- CXX=x86_64-linux-gnu-g++
|
||||
- CGO_CPPFLAGS=--sysroot={{.Env.SYSROOT_LINUX_AMD64}} -I{{.Env.SYSROOT_LINUX_AMD64}}/usr/include/llvm-18 -I{{.Env.SYSROOT_LINUX_AMD64}}/usr/include/llvm-c-18 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
|
||||
- CGO_LDFLAGS=--sysroot={{.Env.SYSROOT_LINUX_AMD64}} -L{{.Env.SYSROOT_LINUX_AMD64}}/usr/lib/llvm-18/lib -lLLVM-18
|
||||
targets:
|
||||
- linux_amd64
|
||||
mod_timestamp: "{{.CommitTimestamp}}"
|
||||
- id: llgo-linux-arm64
|
||||
main: ./cmd/llgo
|
||||
flags:
|
||||
- -tags=linux,arm64,byollvm
|
||||
ldflags:
|
||||
- -X github.com/goplus/llgo/x/env.buildVersion=v{{.Version}}
|
||||
- -X github.com/goplus/llgo/x/env.buildTime={{.Date}}
|
||||
- -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=/usr/lib/llvm-18/bin/llvm-config
|
||||
env:
|
||||
- CC=aarch64-linux-gnu-gcc
|
||||
- CXX=aarch64-linux-gnu-g++
|
||||
- CGO_CPPFLAGS=--sysroot={{.Env.SYSROOT_LINUX_ARM64}} -I{{.Env.SYSROOT_LINUX_ARM64}}/usr/include/llvm-18 -I{{.Env.SYSROOT_LINUX_ARM64}}/usr/include/llvm-c-18 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
|
||||
- CGO_LDFLAGS=--sysroot={{.Env.SYSROOT_LINUX_ARM64}} -L{{.Env.SYSROOT_LINUX_ARM64}}/usr/lib/llvm-18/lib -lLLVM-18
|
||||
targets:
|
||||
- linux_arm64
|
||||
mod_timestamp: "{{.CommitTimestamp}}"
|
||||
|
||||
archives:
|
||||
- format: tar.gz
|
||||
name_template: >-
|
||||
{{.ProjectName}}{{.Version}}.{{.Os}}-{{.Arch}}
|
||||
{{- if .Arm}}v{{.Arm}}{{end}}
|
||||
files:
|
||||
- LICENSE
|
||||
- README.md
|
||||
|
||||
checksum:
|
||||
name_template: "{{.ProjectName}}{{.Version}}.checksums.txt"
|
||||
|
||||
nfpms:
|
||||
- package_name: llgo
|
||||
vendor: goplus
|
||||
homepage: https://github.com/goplus/llgo
|
||||
maintainer: Aofei Sheng <aofei@aofeisheng.com>
|
||||
description: |
|
||||
LLGo is a Go compiler based on LLVM in order to better integrate Go with the C ecosystem including Python. It's a
|
||||
subproject of the Go+ project.
|
||||
|
||||
LLGo aims to expand the boundaries of Go/Go+, providing limitless possibilities such as:
|
||||
|
||||
- Game development
|
||||
- AI and data science
|
||||
- WebAssembly
|
||||
- Embedded development
|
||||
- ...
|
||||
license: Apache-2.0
|
||||
formats:
|
||||
- deb
|
||||
- rpm
|
||||
file_name_template: >-
|
||||
{{.ProjectName}}{{.Version}}.{{.Os}}-{{.Arch}}
|
||||
{{- if .Arm}}v{{.Arm}}{{end}}
|
||||
bindir: /usr/local/bin
|
||||
|
||||
snapcrafts:
|
||||
- name: llgo
|
||||
title: A Go compiler based on LLVM
|
||||
summary: A Go compiler based on LLVM
|
||||
description: |
|
||||
LLGo is a Go compiler based on LLVM in order to better integrate Go with the C ecosystem including Python. It's a
|
||||
subproject of the Go+ project.
|
||||
|
||||
LLGo aims to expand the boundaries of Go/Go+, providing limitless possibilities such as:
|
||||
|
||||
- Game development
|
||||
- AI and data science
|
||||
- WebAssembly
|
||||
- Embedded development
|
||||
- ...
|
||||
license: Apache-2.0
|
||||
confinement: classic
|
||||
name_template: >-
|
||||
{{.ProjectName}}{{.Version}}.{{.Os}}-{{.Arch}}
|
||||
{{- if .Arm}}v{{.Arm}}{{end}}
|
||||
|
||||
snapshot:
|
||||
name_template: '{{trimprefix .Summary "v"}}'
|
||||
|
||||
release:
|
||||
prerelease: auto
|
||||
270
README.md
270
README.md
@@ -10,8 +10,42 @@ llgo - A Go compiler based on LLVM
|
||||
|
||||
LLGo is a Go compiler based on LLVM in order to better integrate Go with the C ecosystem including Python. It's a subproject of [the Go+ project](https://github.com/goplus/gop).
|
||||
|
||||
LLGo aims to expand the boundaries of Go/Go+, providing limitless possibilities such as:
|
||||
|
||||
## C standard libary support
|
||||
* Game development
|
||||
* AI and data science
|
||||
* WebAssembly
|
||||
* Embedded development
|
||||
* ...
|
||||
|
||||
How can these be achieved?
|
||||
|
||||
```
|
||||
LLGo := Go + C + Python
|
||||
```
|
||||
|
||||
LLGo is compatible with C and Python through the language's **Application Binary Interface (ABI)**, while LLGo is compatible with Go through its **syntax (source code)**.
|
||||
|
||||
|
||||
## C/C++ standard libary support
|
||||
|
||||
You can import a C/C++ standard library in LLGo!
|
||||
|
||||
* [c](https://pkg.go.dev/github.com/goplus/llgo/c)
|
||||
* [c/syscall](https://pkg.go.dev/github.com/goplus/llgo/c/syscall)
|
||||
* [c/sys](https://pkg.go.dev/github.com/goplus/llgo/c/sys)
|
||||
* [c/os](https://pkg.go.dev/github.com/goplus/llgo/c/os)
|
||||
* [c/math](https://pkg.go.dev/github.com/goplus/llgo/c/math)
|
||||
* [c/math/cmplx](https://pkg.go.dev/github.com/goplus/llgo/c/math/cmplx)
|
||||
* [c/math/rand](https://pkg.go.dev/github.com/goplus/llgo/c/math/rand)
|
||||
* [c/pthread](https://pkg.go.dev/github.com/goplus/llgo/c/pthread)
|
||||
* [c/pthread/sync](https://pkg.go.dev/github.com/goplus/llgo/c/pthread/sync)
|
||||
* [c/sync/atomic](https://pkg.go.dev/github.com/goplus/llgo/c/sync/atomic)
|
||||
* [c/time](https://pkg.go.dev/github.com/goplus/llgo/c/time)
|
||||
* [c/net](https://pkg.go.dev/github.com/goplus/llgo/c/net)
|
||||
* [cpp/std](https://pkg.go.dev/github.com/goplus/llgo/cpp/std)
|
||||
|
||||
Here is a simple example:
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -34,12 +68,48 @@ The `_demo` directory contains some C standard libary related demos (it start wi
|
||||
To run these demos (If you haven't installed `llgo` yet, please refer to [How to install](#how-to-install)):
|
||||
|
||||
```sh
|
||||
export LLGOROOT=`pwd`
|
||||
cd <demo-directory> # eg. cd _demo/hello
|
||||
llgo run .
|
||||
```
|
||||
|
||||
See [github.com/goplus/llgo/c](https://pkg.go.dev/github.com/goplus/llgo/c) for more detials.
|
||||
|
||||
## How support C/C++ and Python
|
||||
|
||||
LLGo use `go:linkname` to link an extern symbol througth its ABI:
|
||||
|
||||
```go
|
||||
import _ "unsafe" // for go:linkname
|
||||
|
||||
//go:linkname Sqrt C.sqrt
|
||||
func Sqrt(x float64) float64
|
||||
```
|
||||
|
||||
You can directly integrate it into [your own code](_demo/linkname/linkname.go):
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import _ "unsafe" // for go:linkname
|
||||
|
||||
//go:linkname Sqrt C.sqrt
|
||||
func Sqrt(x float64) float64
|
||||
|
||||
func main() {
|
||||
println("sqrt(2) =", Sqrt(2))
|
||||
}
|
||||
```
|
||||
|
||||
Or put it into a package (see [c/math](c/math/math.go)):
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import "github.com/goplus/llgo/c/math"
|
||||
|
||||
func main() {
|
||||
println("sqrt(2) =", math.Sqrt(2))
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Python support
|
||||
@@ -48,36 +118,48 @@ You can import a Python library in LLGo!
|
||||
|
||||
And you can import any Python library into `llgo` through a program called `llpyg` (see [Development tools](#development-tools)). The following libraries have been included in `llgo`:
|
||||
|
||||
* [builtins](https://pkg.go.dev/github.com/goplus/llgo/py/std)
|
||||
* [sys](https://pkg.go.dev/github.com/goplus/llgo/py/sys)
|
||||
* [os](https://pkg.go.dev/github.com/goplus/llgo/py/os)
|
||||
* [math](https://pkg.go.dev/github.com/goplus/llgo/py/math)
|
||||
* [json](https://pkg.go.dev/github.com/goplus/llgo/py/json)
|
||||
* [inspect](https://pkg.go.dev/github.com/goplus/llgo/py/inspect)
|
||||
* [statistics](https://pkg.go.dev/github.com/goplus/llgo/py/statistics)
|
||||
* [numpy](https://pkg.go.dev/github.com/goplus/llgo/py/numpy)
|
||||
* [pandas](https://pkg.go.dev/github.com/goplus/llgo/py/pandas)
|
||||
* [pytorch](https://pkg.go.dev/github.com/goplus/llgo/py/torch)
|
||||
* [matplotlib](https://pkg.go.dev/github.com/goplus/llgo/py/matplotlib)
|
||||
* [py](https://pkg.go.dev/github.com/goplus/llgo/py) (abi)
|
||||
* [py/std](https://pkg.go.dev/github.com/goplus/llgo/py/std) (builtins)
|
||||
* [py/sys](https://pkg.go.dev/github.com/goplus/llgo/py/sys)
|
||||
* [py/os](https://pkg.go.dev/github.com/goplus/llgo/py/os)
|
||||
* [py/math](https://pkg.go.dev/github.com/goplus/llgo/py/math)
|
||||
* [py/json](https://pkg.go.dev/github.com/goplus/llgo/py/json)
|
||||
* [py/inspect](https://pkg.go.dev/github.com/goplus/llgo/py/inspect)
|
||||
* [py/statistics](https://pkg.go.dev/github.com/goplus/llgo/py/statistics)
|
||||
* [py/numpy](https://pkg.go.dev/github.com/goplus/llgo/py/numpy)
|
||||
* [py/pandas](https://pkg.go.dev/github.com/goplus/llgo/py/pandas)
|
||||
* [py/torch](https://pkg.go.dev/github.com/goplus/llgo/py/torch)
|
||||
* [py/matplotlib](https://pkg.go.dev/github.com/goplus/llgo/py/matplotlib)
|
||||
|
||||
Here is an example using the Python `math` library:
|
||||
Note: For third-party libraries (such as pandas and pytorch), you still need to install the library files.
|
||||
|
||||
Here is an example:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/py"
|
||||
"github.com/goplus/llgo/py/math"
|
||||
"github.com/goplus/llgo/py/std"
|
||||
)
|
||||
|
||||
func main() {
|
||||
x := math.Sqrt(py.Float(2))
|
||||
c.Printf(c.Str("sqrt(2) = %f\n"), x.Float64())
|
||||
x := math.Sqrt(py.Float(2)) // x = sqrt(2)
|
||||
std.Print(py.Str("sqrt(2) ="), x) // print("sqrt(2) =", x)
|
||||
}
|
||||
```
|
||||
|
||||
Here, We call `py.Float(2)` to create a Python number 2, and pass it to Python’s `math.sqrt` to get `x`. Then use `x.Float64()` to convert x to Go's `float64` type, and print the value through the C `printf` function.
|
||||
It is equivalent to the following Python code:
|
||||
|
||||
```py
|
||||
import math
|
||||
|
||||
x = math.sqrt(2)
|
||||
print("sqrt =", x)
|
||||
```
|
||||
|
||||
Here, We call `py.Float(2)` to create a Python number 2, and pass it to Python’s `math.sqrt` to get `x`. Then we call `std.Print` to print the result.
|
||||
|
||||
Let's look at a slightly more complex example. For example, we use `numpy` to calculate:
|
||||
|
||||
@@ -85,9 +167,9 @@ Let's look at a slightly more complex example. For example, we use `numpy` to ca
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/py"
|
||||
"github.com/goplus/llgo/py/numpy"
|
||||
"github.com/goplus/llgo/py/std"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -102,7 +184,7 @@ func main() {
|
||||
py.List(3.0, 2.0, 1.0),
|
||||
)
|
||||
x := numpy.Add(a, b)
|
||||
c.Printf(c.Str("a+b = %s\n"), x.Str().CStr())
|
||||
std.Print(py.Str("a+b ="), x)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -115,38 +197,13 @@ The `_pydemo` directory contains some python related demos:
|
||||
* [statistics](_pydemo/statistics/statistics.go): define a python list and call `statistics.mean` to get the mean
|
||||
* [matrix](_pydemo/matrix/matrix.go): a basic `numpy` demo
|
||||
|
||||
To run these demos, you need to set the `LLGO_LIB_PYTHON` environment variable first.
|
||||
|
||||
If Python is in the search path for `clang` linking, then `LLGO_LIB_PYTHON` only needs to be set to the name of the Python library. For example:
|
||||
To run these demos (If you haven't installed `llgo` yet, please refer to [How to install](#how-to-install)):
|
||||
|
||||
```sh
|
||||
export LLGO_LIB_PYTHON=python3.12
|
||||
```
|
||||
|
||||
You can also specify the path to tell `llgo` where the Python library is located:
|
||||
|
||||
```sh
|
||||
export LLGO_LIB_PYTHON=/foo/bar/python3.12
|
||||
```
|
||||
|
||||
For example, `/opt/homebrew/Frameworks/Python.framework/Versions/3.12/lib/libpython3.12.dylib` is a typical python library location under macOS. So we should set it like this:
|
||||
|
||||
```sh
|
||||
export LLGO_LIB_PYTHON=/opt/homebrew/Frameworks/Python.framework/Versions/3.12/lib/python3.12
|
||||
```
|
||||
|
||||
Note that the file name must be written in a platform-independent format, using `python3.12` instead of `libpython3.12.dylib`.
|
||||
|
||||
Then you can run the demos:
|
||||
|
||||
```sh
|
||||
export LLGOROOT=`pwd`
|
||||
cd <demo-directory> # eg. cd _pydemo/callpy
|
||||
llgo run .
|
||||
```
|
||||
|
||||
See [github.com/goplus/llgo/py](https://pkg.go.dev/github.com/goplus/llgo/py) for more detials.
|
||||
|
||||
|
||||
## Other frequently used libraries
|
||||
|
||||
@@ -154,35 +211,40 @@ LLGo can easily import any libraries from the C ecosystem. Currently, this impor
|
||||
|
||||
The currently supported libraries include:
|
||||
|
||||
* [llama2.c](https://pkg.go.dev/github.com/goplus/llgo/c/llama2)
|
||||
* [cjson](https://pkg.go.dev/github.com/goplus/llgo/c/cjson)
|
||||
* [sqlite](https://pkg.go.dev/github.com/goplus/llgo/c/sqlite)
|
||||
* [c/bdwgc](https://pkg.go.dev/github.com/goplus/llgo/c/bdwgc)
|
||||
* [c/cjson](https://pkg.go.dev/github.com/goplus/llgo/c/cjson)
|
||||
* [c/clang](https://pkg.go.dev/github.com/goplus/llgo/c/clang)
|
||||
* [c/libuv](https://pkg.go.dev/github.com/goplus/llgo/c/libuv)
|
||||
* [c/llama2](https://pkg.go.dev/github.com/goplus/llgo/c/llama2)
|
||||
* [c/lua](https://pkg.go.dev/github.com/goplus/llgo/c/lua)
|
||||
* [c/neco](https://pkg.go.dev/github.com/goplus/llgo/c/neco)
|
||||
* [c/openssl](https://pkg.go.dev/github.com/goplus/llgo/c/openssl)
|
||||
* [c/raylib](https://pkg.go.dev/github.com/goplus/llgo/c/raylib)
|
||||
* [c/sqlite](https://pkg.go.dev/github.com/goplus/llgo/c/sqlite)
|
||||
* [c/zlib](https://pkg.go.dev/github.com/goplus/llgo/c/zlib)
|
||||
* [cpp/inih](https://pkg.go.dev/github.com/goplus/llgo/cpp/inih)
|
||||
* [cpp/llvm](https://pkg.go.dev/github.com/goplus/llgo/cpp/llvm)
|
||||
|
||||
Here are some examples related to them:
|
||||
|
||||
* [llama2-c](_demo/llama2-c): inference Llama 2 (It's the first llgo AI example)
|
||||
* [mkjson](c/cjson/_demo/mkjson/mkjson.go): create a json object and print it
|
||||
* [sqlitedemo](c/sqlite/_demo/sqlitedemo/demo.go): a basic sqlite demo
|
||||
* [tetris](c/raylib/_demo/tetris/tetris.go): a tetris game based on raylib
|
||||
|
||||
|
||||
## Go syntax support
|
||||
|
||||
Common Go syntax is already supported. Except for the following, which needs to be improved:
|
||||
|
||||
* map (Very limited support)
|
||||
* chan (Not supported yet)
|
||||
* generics (Not supported yet)
|
||||
|
||||
Here are some examples related to Go syntax:
|
||||
All Go syntax (not including `cgo`) is already supported. Here are some examples:
|
||||
|
||||
* [concat](_demo/concat/concat.go): define a variadic function
|
||||
* [genints](_demo/genints/genints.go): various forms of closure usage (including C function, recv.method and anonymous function)
|
||||
* [errors](_demo/errors/errors.go): demo to implement error interface
|
||||
* [defer](_demo/defer/defer.go): defer demo
|
||||
* [errors](_cmptest/errors/errors.go): demo to implement error interface
|
||||
* [defer](_cmptest/defer/defer.go): defer demo
|
||||
* [goroutine](_demo/goroutine/goroutine.go): goroutine demo
|
||||
|
||||
|
||||
## Defer
|
||||
### Defer
|
||||
|
||||
LLGo `defer` does not support usage in loops. This is not a bug but a feature, because we think that using `defer` in a loop is a very unrecommended practice.
|
||||
|
||||
@@ -206,10 +268,72 @@ Here are the Go packages that can be imported correctly:
|
||||
* [unicode](https://pkg.go.dev/unicode)
|
||||
* [unicode/utf8](https://pkg.go.dev/unicode/utf8)
|
||||
* [unicode/utf16](https://pkg.go.dev/unicode/utf16)
|
||||
* [math/bits](https://pkg.go.dev/math/bits)
|
||||
* [math](https://pkg.go.dev/math)
|
||||
* [math/big](https://pkg.go.dev/math/big) (partially)
|
||||
* [math/bits](https://pkg.go.dev/math/bits)
|
||||
* [math/cmplx](https://pkg.go.dev/math/cmplx)
|
||||
* [math/rand](https://pkg.go.dev/math/rand)
|
||||
* [net/url](https://pkg.go.dev/net/url)
|
||||
* [errors](https://pkg.go.dev/errors)
|
||||
* [context](https://pkg.go.dev/context)
|
||||
* [io](https://pkg.go.dev/io)
|
||||
* [io/fs](https://pkg.go.dev/io/fs)
|
||||
* [io/ioutil](https://pkg.go.dev/io/ioutil)
|
||||
* [log](https://pkg.go.dev/log)
|
||||
* [flag](https://pkg.go.dev/flag)
|
||||
* [sort](https://pkg.go.dev/sort)
|
||||
* [bytes](https://pkg.go.dev/bytes)
|
||||
* [bufio](https://pkg.go.dev/bufio)
|
||||
* [strings](https://pkg.go.dev/strings)
|
||||
* [strconv](https://pkg.go.dev/strconv)
|
||||
* [path](https://pkg.go.dev/path)
|
||||
* [path/filepath](https://pkg.go.dev/path/filepath)
|
||||
* [sync/atomic](https://pkg.go.dev/sync/atomic)
|
||||
* [sync](https://pkg.go.dev/sync) (partially)
|
||||
* [syscall](https://pkg.go.dev/syscall) (partially)
|
||||
* [runtime](https://pkg.go.dev/runtime) (partially)
|
||||
* [os](https://pkg.go.dev/os) (partially)
|
||||
* [os/exec](https://pkg.go.dev/os/exec) (partially)
|
||||
* [fmt](https://pkg.go.dev/fmt) (partially)
|
||||
* [reflect](https://pkg.go.dev/reflect) (partially)
|
||||
* [time](https://pkg.go.dev/time) (partially)
|
||||
* [encoding](https://pkg.go.dev/encoding)
|
||||
* [encoding/binary](https://pkg.go.dev/encoding/binary)
|
||||
* [encoding/hex](https://pkg.go.dev/encoding/hex)
|
||||
* [encoding/base32](https://pkg.go.dev/encoding/base32)
|
||||
* [encoding/base64](https://pkg.go.dev/encoding/base64)
|
||||
* [encoding/csv](https://pkg.go.dev/encoding/csv)
|
||||
* [net/textproto](https://pkg.go.dev/net/textproto)
|
||||
* [hash](https://pkg.go.dev/hash)
|
||||
* [hash/adler32](https://pkg.go.dev/hash/adler32)
|
||||
* [hash/crc32](https://pkg.go.dev/hash/crc32) (partially)
|
||||
* [hash/crc64](https://pkg.go.dev/hash/crc64)
|
||||
* [crypto](https://pkg.go.dev/crypto)
|
||||
* [crypto/md5](https://pkg.go.dev/crypto/md5)
|
||||
* [crypto/sha1](https://pkg.go.dev/crypto/sha1)
|
||||
* [crypto/sha256](https://pkg.go.dev/crypto/sha256)
|
||||
* [crypto/sha512](https://pkg.go.dev/crypto/sha512) (partially)
|
||||
* [crypto/hmac](https://pkg.go.dev/crypto/hmac) (partially)
|
||||
* [crypto/rand](https://pkg.go.dev/crypto/rand) (partially)
|
||||
* [crypto/subtle](https://pkg.go.dev/crypto/subtle) (partially)
|
||||
* [regexp](https://pkg.go.dev/regexp)
|
||||
* [regexp/syntax](https://pkg.go.dev/regexp/syntax)
|
||||
* [go/token](https://pkg.go.dev/go/token)
|
||||
* [go/scanner](https://pkg.go.dev/go/scanner)
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
- [Go 1.20+](https://go.dev)
|
||||
- [LLVM 18](https://llvm.org)
|
||||
- [LLD 18](https://lld.llvm.org)
|
||||
- [Clang 18](https://clang.llvm.org)
|
||||
- [pkg-config 0.29+](https://www.freedesktop.org/wiki/Software/pkg-config/)
|
||||
- [bdwgc/libgc 8.0+](https://www.hboehm.info/gc/)
|
||||
- [OpenSSL 3.0+](https://www.openssl.org/)
|
||||
- [zlib 1.2+](https://www.zlib.net)
|
||||
- [Python 3.12+](https://www.python.org) (optional, for [github.com/goplus/llgo/py](https://pkg.go.dev/github.com/goplus/llgo/py))
|
||||
|
||||
## How to install
|
||||
|
||||
Follow these steps to generate the `llgo` command (its usage is the same as the `go` command):
|
||||
@@ -217,21 +341,21 @@ Follow these steps to generate the `llgo` command (its usage is the same as the
|
||||
### on macOS
|
||||
|
||||
```sh
|
||||
brew update # execute if needed
|
||||
brew install libgc
|
||||
brew install llvm@17
|
||||
go install -v ./...
|
||||
brew update
|
||||
brew install llvm@18 pkg-config bdw-gc openssl
|
||||
brew install python@3.12 # optional
|
||||
go install -v github.com/goplus/llgo/cmd/llgo@latest
|
||||
```
|
||||
|
||||
### on Linux
|
||||
### on Linux (Debian/Ubuntu)
|
||||
|
||||
```sh
|
||||
echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main' | sudo tee /etc/apt/sources.list.d/llvm.list
|
||||
echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-18 main" | sudo tee /etc/apt/sources.list.d/llvm.list
|
||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||
sudo apt-get update # execute if needed
|
||||
sudo apt-get install libgc-dev
|
||||
sudo apt-get install --no-install-recommends llvm-17-dev
|
||||
go install -v ./...
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y llvm-18-dev clang-18 lld-18 pkg-config libgc-dev libssl-dev zlib1g-dev
|
||||
sudo apt-get install -y python3.12-dev # optional
|
||||
go install -v github.com/goplus/llgo/cmd/llgo@latest
|
||||
```
|
||||
|
||||
### on Windows
|
||||
@@ -250,7 +374,9 @@ TODO
|
||||
How do I generate these tools?
|
||||
|
||||
```sh
|
||||
go install -v ./... # compile all tools except pydump
|
||||
git clone https://github.com/goplus/llgo.git
|
||||
cd llgo
|
||||
go install -v ./chore/... # compile all tools except pydump
|
||||
cd chore/_xtool
|
||||
llgo install ./... # compile pydump
|
||||
go install github.com/goplus/hdq/chore/pysigfetch@v0.8.1 # compile pysigfetch
|
||||
|
||||
47
_cmptest/_bigsqrt2/sqrt2.go
Normal file
47
_cmptest/_bigsqrt2/sqrt2.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// We'll do computations with 200 bits of precision in the mantissa.
|
||||
const prec = 200
|
||||
|
||||
// Compute the square root of 2 using Newton's Method. We start with
|
||||
// an initial estimate for sqrt(2), and then iterate:
|
||||
// x_{n+1} = 1/2 * ( x_n + (2.0 / x_n) )
|
||||
|
||||
// Since Newton's Method doubles the number of correct digits at each
|
||||
// iteration, we need at least log_2(prec) steps.
|
||||
steps := int(math.Log2(prec))
|
||||
|
||||
// Initialize values we need for the computation.
|
||||
two := new(big.Float).SetPrec(prec).SetInt64(2)
|
||||
half := new(big.Float).SetPrec(prec).SetFloat64(0.5)
|
||||
|
||||
// Use 1 as the initial estimate.
|
||||
x := new(big.Float).SetPrec(prec).SetInt64(1)
|
||||
|
||||
// We use t as a temporary variable. There's no need to set its precision
|
||||
// since big.Float values with unset (== 0) precision automatically assume
|
||||
// the largest precision of the arguments when used as the result (receiver)
|
||||
// of a big.Float operation.
|
||||
t := new(big.Float)
|
||||
|
||||
// Iterate.
|
||||
for i := 0; i <= steps; i++ {
|
||||
t.Quo(two, x) // t = 2.0 / x_n
|
||||
t.Add(x, t) // t = x_n + (2.0 / x_n)
|
||||
x.Mul(half, t) // x_{n+1} = 0.5 * t
|
||||
}
|
||||
|
||||
// We can use the usual fmt.Printf verbs since big.Float implements fmt.Formatter
|
||||
fmt.Printf("sqrt(2) = %.50f\n", x)
|
||||
|
||||
// Print the error between 2 and x*x.
|
||||
t.Mul(x, x) // t = x*x
|
||||
fmt.Printf("error = %e\n", t.Sub(two, t))
|
||||
}
|
||||
21
_cmptest/_chandemo/chan.go
Normal file
21
_cmptest/_chandemo/chan.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
c1 := make(chan string)
|
||||
c2 := make(chan string, 1)
|
||||
go func() {
|
||||
c1 <- "ch1"
|
||||
}()
|
||||
go func() {
|
||||
c2 <- "ch2"
|
||||
}()
|
||||
|
||||
for i := 0; i < 2; i++ {
|
||||
select {
|
||||
case msg1 := <-c1:
|
||||
println(msg1)
|
||||
case msg2 := <-c2:
|
||||
println(msg2)
|
||||
}
|
||||
}
|
||||
}
|
||||
34
_cmptest/_goparsedemo/parse.go
Normal file
34
_cmptest/_goparsedemo/parse.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fset := token.NewFileSet() // positions are relative to fset
|
||||
|
||||
src := `package foo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func bar() {
|
||||
fmt.Println(time.Now())
|
||||
}`
|
||||
|
||||
// Parse src but stop after processing the imports.
|
||||
f, err := parser.ParseFile(fset, "", src, parser.ImportsOnly)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
// Print the imports from the file's AST.
|
||||
for _, s := range f.Imports {
|
||||
fmt.Println(s.Path.Value)
|
||||
}
|
||||
}
|
||||
16
_cmptest/_jsondemo/json.go
Normal file
16
_cmptest/_jsondemo/json.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := `{"name":"math","items":[{"name":"sqrt","sig":"(x, /)"},{"name":"pi"}]}`
|
||||
data := unsafe.Slice(unsafe.StringData(s), len(s))
|
||||
var v any
|
||||
json.Unmarshal(data, &v)
|
||||
b, _ := json.MarshalIndent(v, "", " ")
|
||||
fmt.Println(string(b))
|
||||
}
|
||||
19
_cmptest/_timeout/timer.go
Normal file
19
_cmptest/_timeout/timer.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
var c chan int
|
||||
|
||||
func handle(int) {}
|
||||
|
||||
func main() {
|
||||
select {
|
||||
case m := <-c:
|
||||
handle(m)
|
||||
case <-time.After(time.Second / 10):
|
||||
fmt.Println("timed out")
|
||||
}
|
||||
}
|
||||
48
_cmptest/base64demo/base64.go
Normal file
48
_cmptest/base64demo/base64.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/base32"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"log"
|
||||
)
|
||||
|
||||
func base64Demo() {
|
||||
msg := "Hello, 世界"
|
||||
encoded := base64.StdEncoding.EncodeToString([]byte(msg))
|
||||
fmt.Println(encoded)
|
||||
decoded, err := base64.StdEncoding.DecodeString(encoded)
|
||||
if err != nil {
|
||||
fmt.Println("decode error:", err)
|
||||
return
|
||||
}
|
||||
fmt.Println(string(decoded))
|
||||
}
|
||||
|
||||
func base32Demo() {
|
||||
str := "JBSWY3DPFQQHO33SNRSCC==="
|
||||
dst := make([]byte, base32.StdEncoding.DecodedLen(len(str)))
|
||||
n, err := base32.StdEncoding.Decode(dst, []byte(str))
|
||||
if err != nil {
|
||||
fmt.Println("decode error:", err)
|
||||
return
|
||||
}
|
||||
dst = dst[:n]
|
||||
fmt.Printf("%q\n", dst)
|
||||
}
|
||||
|
||||
func hexDemo() {
|
||||
const s = "48656c6c6f20476f7068657221"
|
||||
decoded, err := hex.DecodeString(s)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("%s\n", decoded)
|
||||
|
||||
}
|
||||
func main() {
|
||||
base64Demo()
|
||||
base32Demo()
|
||||
hexDemo()
|
||||
}
|
||||
63
_cmptest/bigintdemo/fib.go
Normal file
63
_cmptest/bigintdemo/fib.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
func fib() {
|
||||
// Initialize two big ints with the first two numbers in the sequence.
|
||||
a := big.NewInt(0)
|
||||
b := big.NewInt(1)
|
||||
|
||||
// Initialize limit as 10^99, the smallest integer with 100 digits.
|
||||
var limit big.Int
|
||||
limit.Exp(big.NewInt(10), big.NewInt(99), nil)
|
||||
|
||||
// Loop while a is smaller than 1e100.
|
||||
for a.Cmp(&limit) < 0 {
|
||||
// Compute the next Fibonacci number, storing it in a.
|
||||
a.Add(a, b)
|
||||
// Swap a and b so that b is the next number in the sequence.
|
||||
a, b = b, a
|
||||
}
|
||||
fmt.Println(a) // 100-digit Fibonacci number
|
||||
}
|
||||
|
||||
func abs() {
|
||||
a := big.NewInt(64)
|
||||
b := big.NewInt(-52)
|
||||
a.Set(b)
|
||||
a.Abs(a)
|
||||
a.Set(big.NewInt(-164))
|
||||
a.Abs(a)
|
||||
fmt.Println("value: ", a.String())
|
||||
}
|
||||
|
||||
func neg() {
|
||||
fmt.Println("value: ", big.NewInt(-64).Neg(big.NewInt(-64)))
|
||||
fmt.Println("value: ", big.NewInt(64).Neg(big.NewInt(64)))
|
||||
fmt.Println("value: ", big.NewInt(0).Neg(big.NewInt(0)))
|
||||
}
|
||||
|
||||
func calc() {
|
||||
a := big.NewInt(64)
|
||||
b := big.NewInt(-52)
|
||||
c := big.NewInt(54)
|
||||
fmt.Println("value:", a.Add(a, b))
|
||||
fmt.Println("value:", a.Sub(b, c))
|
||||
d := big.NewInt(10)
|
||||
e := big.NewInt(4)
|
||||
fmt.Println("value:", d.Mul(d, e))
|
||||
}
|
||||
|
||||
func bitop() {
|
||||
a := big.NewInt(4)
|
||||
fmt.Println("value:", a.Lsh(a, 1))
|
||||
b := big.NewInt(16)
|
||||
fmt.Println("value:", b.Rsh(b, 2))
|
||||
}
|
||||
|
||||
func main() {
|
||||
bitop()
|
||||
}
|
||||
11
_cmptest/chan/chan.go
Normal file
11
_cmptest/chan/chan.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
ch := make(chan int, 10)
|
||||
println(len(ch), cap(ch))
|
||||
go func() {
|
||||
ch <- 100
|
||||
}()
|
||||
n, ok := <-ch
|
||||
println(n, ok)
|
||||
}
|
||||
26
_cmptest/chansel/chansel.go
Normal file
26
_cmptest/chansel/chansel.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
func fibonacci(c, quit chan int) {
|
||||
x, y := 0, 1
|
||||
for {
|
||||
select {
|
||||
case c <- x:
|
||||
x, y = y, x+y
|
||||
case <-quit:
|
||||
println("quit")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
c := make(chan int)
|
||||
quit := make(chan int)
|
||||
go func() {
|
||||
for i := 0; i < 10; i++ {
|
||||
println(<-c)
|
||||
}
|
||||
close(quit)
|
||||
}()
|
||||
fibonacci(c, quit)
|
||||
}
|
||||
28
_cmptest/crcdemo/crc.go
Normal file
28
_cmptest/crcdemo/crc.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hash/adler32"
|
||||
"hash/crc32"
|
||||
"hash/crc64"
|
||||
)
|
||||
|
||||
func crc64Demo() {
|
||||
crc := crc64.MakeTable(crc64.ECMA)
|
||||
fmt.Printf("%016x\n", crc64.Checksum([]byte("Hello world"), crc))
|
||||
}
|
||||
|
||||
func crc32Demo() {
|
||||
crc32q := crc32.MakeTable(crc32.IEEE)
|
||||
fmt.Printf("%08x\n", crc32.Checksum([]byte("Hello world"), crc32q))
|
||||
}
|
||||
|
||||
func adler32Demo() {
|
||||
fmt.Printf("%08x\n", adler32.Checksum([]byte("Hello world")))
|
||||
}
|
||||
|
||||
func main() {
|
||||
adler32Demo()
|
||||
crc32Demo()
|
||||
crc64Demo()
|
||||
}
|
||||
30
_cmptest/csvdemo/csv.go
Normal file
30
_cmptest/csvdemo/csv.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
in := `first_name,last_name,username
|
||||
"Rob","Pike",rob
|
||||
Ken,Thompson,ken
|
||||
"Robert","Griesemer","gri"
|
||||
`
|
||||
r := csv.NewReader(strings.NewReader(in))
|
||||
|
||||
for {
|
||||
record, err := r.Read()
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Println(record)
|
||||
}
|
||||
}
|
||||
39
_cmptest/ctxcancel/ctx.go
Normal file
39
_cmptest/ctxcancel/ctx.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// gen generates integers in a separate goroutine and
|
||||
// sends them to the returned channel.
|
||||
// The callers of gen need to cancel the context once
|
||||
// they are done consuming generated integers not to leak
|
||||
// the internal goroutine started by gen.
|
||||
gen := func(ctx context.Context) <-chan int {
|
||||
dst := make(chan int)
|
||||
n := 1
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return // returning not to leak the goroutine
|
||||
case dst <- n:
|
||||
n++
|
||||
}
|
||||
}
|
||||
}()
|
||||
return dst
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel() // cancel when we are finished consuming integers
|
||||
|
||||
for n := range gen(ctx) {
|
||||
fmt.Println(n)
|
||||
if n == 5 {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
20
_cmptest/envexpand/expand.go
Normal file
20
_cmptest/envexpand/expand.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
mapper := func(placeholderName string) string {
|
||||
switch placeholderName {
|
||||
case "DAY_PART":
|
||||
return "morning"
|
||||
case "NAME":
|
||||
return "Gopher"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
fmt.Println(os.Expand("Good ${DAY_PART}, $NAME!", mapper))
|
||||
}
|
||||
@@ -17,6 +17,5 @@ func (e *errorString) Error() string {
|
||||
|
||||
func main() {
|
||||
err := New("an error")
|
||||
println(err)
|
||||
println(err.Error())
|
||||
}
|
||||
21
_cmptest/flagdemo/flagdemo.go
Normal file
21
_cmptest/flagdemo/flagdemo.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("args:", os.Args[1:])
|
||||
if len(os.Args) == 1 {
|
||||
os.Args = []string{"flagdemo", "-cpu", "100"}
|
||||
}
|
||||
|
||||
verbose := flag.Bool("v", false, "verbose")
|
||||
cpu := flag.Int("cpu", 1, "cpu number")
|
||||
host := flag.String("host", ":8888", "host")
|
||||
flag.Parse()
|
||||
|
||||
fmt.Println("host:", *host, "cpu:", *cpu, "verbose:", *verbose)
|
||||
}
|
||||
12
_cmptest/fmtdemo/fmt.go
Normal file
12
_cmptest/fmtdemo/fmt.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hello, world")
|
||||
fmt.Printf("%f\n", 3.14)
|
||||
fmt.Printf("%v\n", errors.New("error message"))
|
||||
}
|
||||
27
_cmptest/goscandemo/scan.go
Normal file
27
_cmptest/goscandemo/scan.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/scanner"
|
||||
"go/token"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// src is the input that we want to tokenize.
|
||||
src := []byte("cos(x) + 1i*sin(x) // Euler")
|
||||
|
||||
// Initialize the scanner.
|
||||
var s scanner.Scanner
|
||||
fset := token.NewFileSet() // positions are relative to fset
|
||||
file := fset.AddFile("", fset.Base(), len(src)) // register input "file"
|
||||
s.Init(file, src, nil /* no error handler */, scanner.ScanComments)
|
||||
|
||||
// Repeated calls to Scan yield the token sequence found in the input.
|
||||
for {
|
||||
pos, tok, lit := s.Scan()
|
||||
if tok == token.EOF {
|
||||
break
|
||||
}
|
||||
fmt.Printf("%s\t%s\t%q\n", fset.Position(pos), tok, lit)
|
||||
}
|
||||
}
|
||||
15
_cmptest/hmacdemo/hmac.go
Normal file
15
_cmptest/hmacdemo/hmac.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
"crypto/sha1"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
func main() {
|
||||
h := hmac.New(sha1.New, []byte("<key>"))
|
||||
io.WriteString(h, "The fog is getting thicker!")
|
||||
io.WriteString(h, "And Leon's getting laaarger!")
|
||||
fmt.Printf("%x", h.Sum(nil))
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/_demo/interf/foo"
|
||||
"github.com/goplus/llgo/_cmptest/interf/foo"
|
||||
)
|
||||
|
||||
func Foo() any {
|
||||
14
_cmptest/iodemo/io.go
Normal file
14
_cmptest/iodemo/io.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
func f(w io.Writer) {
|
||||
w.Write([]byte("Hello, world\n"))
|
||||
}
|
||||
|
||||
func main() {
|
||||
f(os.Stdout)
|
||||
}
|
||||
19
_cmptest/ioutildemo/ioutil.go
Normal file
19
_cmptest/ioutildemo/ioutil.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r := strings.NewReader("Go is a general-purpose language designed with systems programming in mind.")
|
||||
|
||||
b, err := ioutil.ReadAll(r)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Printf("%s\n", b)
|
||||
}
|
||||
20
_cmptest/md5demo/md5.go
Normal file
20
_cmptest/md5demo/md5.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto"
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
func main() {
|
||||
h := md5.New()
|
||||
io.WriteString(h, "The fog is getting thicker!")
|
||||
io.WriteString(h, "And Leon's getting laaarger!")
|
||||
fmt.Printf("%x\n", h.Sum(nil))
|
||||
|
||||
h = crypto.MD5.New()
|
||||
io.WriteString(h, "The fog is getting thicker!")
|
||||
io.WriteString(h, "And Leon's getting laaarger!")
|
||||
fmt.Printf("%x\n", h.Sum(nil))
|
||||
}
|
||||
18
_cmptest/osdemo/osd.go
Normal file
18
_cmptest/osdemo/osd.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
home, _ := os.UserHomeDir()
|
||||
println("home:", home)
|
||||
|
||||
cfgdir, _ := os.UserConfigDir()
|
||||
println("cfgdir:", cfgdir)
|
||||
|
||||
cache, _ := os.UserCacheDir()
|
||||
println("cachedir:", cache)
|
||||
|
||||
os.Stdout.Write([]byte("Hello, World\n"))
|
||||
}
|
||||
24
_cmptest/osexec/exec.go
Normal file
24
_cmptest/osexec/exec.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
|
||||
"github.com/goplus/llgo/xtool/env/llvm"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ls := "ls"
|
||||
if runtime.GOOS == "windows" {
|
||||
ls = "dir"
|
||||
}
|
||||
cmd := exec.Command(ls)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Run()
|
||||
|
||||
dir := llvm.New("").BinDir()
|
||||
fmt.Println(dir)
|
||||
}
|
||||
30
_cmptest/osproc/exec.go
Normal file
30
_cmptest/osproc/exec.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ls := "ls"
|
||||
args := []string{ls, "-l"}
|
||||
if runtime.GOOS == "windows" {
|
||||
ls = "dir"
|
||||
args = []string{ls}
|
||||
}
|
||||
lspath, _ := exec.LookPath(ls)
|
||||
if lspath != "" {
|
||||
ls = lspath
|
||||
}
|
||||
proc, err := os.StartProcess(ls, args, &os.ProcAttr{
|
||||
Files: []*os.File{nil, os.Stdout, os.Stderr},
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println("os.StartProcess error:", err)
|
||||
return
|
||||
}
|
||||
proc.Wait()
|
||||
fmt.Println("proc.Wait done")
|
||||
}
|
||||
26
_cmptest/pipedemo/pipe.go
Normal file
26
_cmptest/pipedemo/pipe.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
func main() {
|
||||
data := []byte("This is some data that needs to be stored in Body.")
|
||||
pr, pw := io.Pipe()
|
||||
go func() {
|
||||
defer pw.Close()
|
||||
if _, err := pw.Write(data); err != nil {
|
||||
fmt.Println("Error writing to pipe:", err)
|
||||
return
|
||||
}
|
||||
}()
|
||||
defer pr.Close()
|
||||
|
||||
readData, err := io.ReadAll(pr)
|
||||
if err != nil {
|
||||
fmt.Println("Error reading from Body:", err)
|
||||
return
|
||||
}
|
||||
fmt.Println("Body:", string(readData))
|
||||
}
|
||||
12
_cmptest/printfdemo/demo.go
Normal file
12
_cmptest/printfdemo/demo.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/goplus/llgo/xtool/nm"
|
||||
)
|
||||
|
||||
func main() {
|
||||
sym := nm.Symbol{Name: "abc", Type: nm.Text}
|
||||
fmt.Printf("%016x %c %s\n", sym.Addr, sym.Type, sym.Name)
|
||||
}
|
||||
25
_cmptest/readfiledemo/readf.go
Normal file
25
_cmptest/readfiledemo/readf.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fileName := "err.log"
|
||||
os.WriteFile(fileName, []byte("123"), 0644)
|
||||
|
||||
_, err := os.Stat(fileName)
|
||||
if os.IsNotExist(err) {
|
||||
fmt.Fprintf(os.Stderr, "File %s not found\n", fileName)
|
||||
return
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(fileName)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "ReadFile: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("%s\n", data)
|
||||
}
|
||||
13
_cmptest/reflect/reflect.go
Normal file
13
_cmptest/reflect/reflect.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import "reflect"
|
||||
|
||||
func main() {
|
||||
tyIntSlice := reflect.SliceOf(reflect.TypeOf(0))
|
||||
v := reflect.Zero(tyIntSlice)
|
||||
v = reflect.Append(v, reflect.ValueOf(1), reflect.ValueOf(2), reflect.ValueOf(3))
|
||||
for i, n := 0, v.Len(); i < n; i++ {
|
||||
item := v.Index(i)
|
||||
println(item.Int())
|
||||
}
|
||||
}
|
||||
11
_cmptest/regexdemo/regex.go
Normal file
11
_cmptest/regexdemo/regex.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/goplus/llgo/xtool/env"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(env.ExpandEnv("$(pkg-config --libs bdw-gc)"))
|
||||
}
|
||||
14
_cmptest/rtype/rtype.go
Normal file
14
_cmptest/rtype/rtype.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import "reflect"
|
||||
|
||||
func main() {
|
||||
tyIntSlice := reflect.SliceOf(reflect.TypeOf(0))
|
||||
println(tyIntSlice.String())
|
||||
|
||||
v := reflect.Zero(tyIntSlice)
|
||||
println(v.Len())
|
||||
|
||||
v = reflect.ValueOf(100)
|
||||
println(v.Int())
|
||||
}
|
||||
14
_cmptest/sha1demo/sha1.go
Normal file
14
_cmptest/sha1demo/sha1.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
func main() {
|
||||
h := sha1.New()
|
||||
io.WriteString(h, "The fog is getting thicker!")
|
||||
io.WriteString(h, "And Leon's getting laaarger!")
|
||||
fmt.Printf("%x", h.Sum(nil))
|
||||
}
|
||||
14
_cmptest/sha256demo/sha256.go
Normal file
14
_cmptest/sha256demo/sha256.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
func main() {
|
||||
h := sha256.New()
|
||||
io.WriteString(h, "The fog is getting thicker!")
|
||||
io.WriteString(h, "And Leon's getting laaarger!")
|
||||
fmt.Printf("%x", h.Sum(nil))
|
||||
}
|
||||
14
_cmptest/sha512demo/sha512.go
Normal file
14
_cmptest/sha512demo/sha512.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/sha512"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
func main() {
|
||||
h := sha512.New()
|
||||
io.WriteString(h, "The fog is getting thicker!")
|
||||
io.WriteString(h, "And Leon's getting laaarger!")
|
||||
fmt.Printf("%x", h.Sum(nil))
|
||||
}
|
||||
23
_cmptest/sortdemo/sort.go
Normal file
23
_cmptest/sortdemo/sort.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import "sort"
|
||||
|
||||
func main() {
|
||||
vals := []int{32, 58, 25, 92, 45, 78}
|
||||
sort.Ints(vals)
|
||||
for _, v := range vals {
|
||||
println(v)
|
||||
}
|
||||
|
||||
texts := []string{"apple", "banana", "cherry", "date", "elderberry", "fig"}
|
||||
sort.Slice(texts, func(i, j int) bool {
|
||||
leni, lenj := len(texts[i]), len(texts[j])
|
||||
if leni != lenj {
|
||||
return leni < lenj
|
||||
}
|
||||
return texts[i] < texts[j]
|
||||
})
|
||||
for _, v := range texts {
|
||||
println(v)
|
||||
}
|
||||
}
|
||||
12
_cmptest/strconv/strconv.go
Normal file
12
_cmptest/strconv/strconv.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(strconv.Itoa(-123))
|
||||
fmt.Println(strings.Split("abc,def,123", ","))
|
||||
}
|
||||
11
_cmptest/syscall/syscall.go
Normal file
11
_cmptest/syscall/syscall.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import "syscall"
|
||||
|
||||
func main() {
|
||||
wd, err := syscall.Getwd()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
println("cwd:", wd)
|
||||
}
|
||||
8
_cmptest/timedemo/time.go
Normal file
8
_cmptest/timedemo/time.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package main
|
||||
|
||||
import "time"
|
||||
|
||||
func main() {
|
||||
t := time.Date(2018, time.January, 1, 2, 3, 4, 5, time.UTC)
|
||||
println(t.String())
|
||||
}
|
||||
20
_cmptest/urldemo/url.go
Normal file
20
_cmptest/urldemo/url.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
func main() {
|
||||
u, err := url.Parse("http://foo.example.com/foo?bar=1")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
u.Scheme = "https"
|
||||
u.Host = "bar.example.com"
|
||||
q := u.Query()
|
||||
q.Set("bar", "2")
|
||||
u.RawQuery = q.Encode()
|
||||
fmt.Println(u)
|
||||
}
|
||||
24
_demo/catomic/atomic.go
Normal file
24
_demo/catomic/atomic.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c/sync/atomic"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var v int64
|
||||
|
||||
atomic.Store(&v, 100)
|
||||
println("store:", atomic.Load(&v))
|
||||
|
||||
ret := atomic.Add(&v, 1)
|
||||
println("ret:", ret, "v:", v)
|
||||
|
||||
ret, _ = atomic.CompareAndExchange(&v, 100, 102)
|
||||
println("ret:", ret, "vs 100, v:", v)
|
||||
|
||||
ret, _ = atomic.CompareAndExchange(&v, 101, 102)
|
||||
println("ret:", ret, "vs 101, v:", v)
|
||||
|
||||
ret = atomic.Sub(&v, 1)
|
||||
println("ret:", ret, "v:", v)
|
||||
}
|
||||
50
_demo/cchan/cchan.go
Normal file
50
_demo/cchan/cchan.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/internal/runtime"
|
||||
)
|
||||
|
||||
const (
|
||||
eltSize = int(unsafe.Sizeof(0))
|
||||
)
|
||||
|
||||
func doChan(cap int) {
|
||||
c := runtime.NewChan(eltSize, cap)
|
||||
go func() {
|
||||
v := 100
|
||||
runtime.ChanSend(c, unsafe.Pointer(&v), eltSize)
|
||||
}()
|
||||
var ret int
|
||||
runtime.ChanRecv(c, unsafe.Pointer(&ret), eltSize)
|
||||
println(ret)
|
||||
}
|
||||
|
||||
func main() {
|
||||
doChan(10)
|
||||
doChan(0)
|
||||
|
||||
c := runtime.NewChan(eltSize, 3)
|
||||
|
||||
v := 1
|
||||
runtime.ChanSend(c, unsafe.Pointer(&v), eltSize)
|
||||
v = 2
|
||||
runtime.ChanSend(c, unsafe.Pointer(&v), eltSize)
|
||||
v = 3
|
||||
runtime.ChanSend(c, unsafe.Pointer(&v), eltSize)
|
||||
runtime.ChanClose(c)
|
||||
|
||||
v = 10
|
||||
|
||||
if runtime.ChanTrySend(c, unsafe.Pointer(&v), eltSize) {
|
||||
println("error: chan send to closed chan")
|
||||
}
|
||||
|
||||
for {
|
||||
if ok := runtime.ChanRecv(c, unsafe.Pointer(&v), eltSize); !ok {
|
||||
break
|
||||
}
|
||||
println(v)
|
||||
}
|
||||
}
|
||||
41
_demo/cchansel/cchansel.go
Normal file
41
_demo/cchansel/cchansel.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/internal/runtime"
|
||||
)
|
||||
|
||||
const (
|
||||
eltSize = int(unsafe.Sizeof(0))
|
||||
)
|
||||
|
||||
func fibonacci(c, quit *runtime.Chan) {
|
||||
x, y := 0, 1
|
||||
for {
|
||||
isel, _ := runtime.Select(
|
||||
runtime.ChanOp{C: c, Send: true, Val: unsafe.Pointer(&x), Size: int32(eltSize)},
|
||||
runtime.ChanOp{C: quit},
|
||||
)
|
||||
if isel == 0 {
|
||||
x, y = y, x+y
|
||||
} else {
|
||||
println("quit")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
c := runtime.NewChan(eltSize, 0)
|
||||
quit := runtime.NewChan(eltSize, 0)
|
||||
go func() {
|
||||
for i := 0; i < 10; i++ {
|
||||
val := 0
|
||||
runtime.ChanRecv(c, unsafe.Pointer(&val), eltSize)
|
||||
println(val)
|
||||
}
|
||||
runtime.ChanClose(quit)
|
||||
}()
|
||||
fibonacci(c, quit)
|
||||
}
|
||||
11
_demo/cexec/exec.go
Normal file
11
_demo/cexec/exec.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ls := c.Str("ls")
|
||||
os.Execlp(ls, ls, c.Str("-l"), nil)
|
||||
}
|
||||
9
_demo/complex/cmplx.go
Normal file
9
_demo/complex/cmplx.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"math/cmplx"
|
||||
)
|
||||
|
||||
func main() {
|
||||
println("abs(3+4i):", cmplx.Abs(3+4i))
|
||||
}
|
||||
38
_demo/cppintf/cppintf.go
Normal file
38
_demo/cppintf/cppintf.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/_demo/cppintf/foo"
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/math"
|
||||
)
|
||||
|
||||
type Bar struct {
|
||||
foo.Callback
|
||||
a c.Int
|
||||
}
|
||||
|
||||
func NewBar(a c.Int) *Bar {
|
||||
return &Bar{
|
||||
Callback: foo.Callback{
|
||||
Vptr: &foo.CallbackVtbl{
|
||||
Val: c.Func((*Bar).getA),
|
||||
Calc: c.Func((*Bar).sqrt),
|
||||
},
|
||||
},
|
||||
a: a,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Bar) getA() c.Int {
|
||||
return p.a
|
||||
}
|
||||
|
||||
func (p *Bar) sqrt(v float64) float64 {
|
||||
return math.Sqrt(v)
|
||||
}
|
||||
|
||||
func main() {
|
||||
bar := NewBar(1)
|
||||
foo.F(&bar.Callback)
|
||||
foo.G(&bar.Callback)
|
||||
}
|
||||
15
_demo/cppintf/foo/bar/bar.cpp
Normal file
15
_demo/cppintf/foo/bar/bar.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
#define interface struct
|
||||
|
||||
interface ICallback {
|
||||
virtual int val() = 0;
|
||||
virtual double calc(double v) = 0;
|
||||
};
|
||||
|
||||
extern "C" void f(ICallback* cb) {
|
||||
printf("val: %d\ncalc(2): %lf\n", cb->val(), cb->calc(2));
|
||||
}
|
||||
|
||||
void g(ICallback* cb) {
|
||||
f(cb);
|
||||
}
|
||||
25
_demo/cppintf/foo/foo.go
Normal file
25
_demo/cppintf/foo/foo.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package foo
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
LLGoFiles = "bar/bar.cpp"
|
||||
LLGoPackage = "link"
|
||||
)
|
||||
|
||||
type Callback struct {
|
||||
Vptr *CallbackVtbl
|
||||
}
|
||||
|
||||
type CallbackVtbl struct {
|
||||
Val unsafe.Pointer
|
||||
Calc unsafe.Pointer
|
||||
}
|
||||
|
||||
//go:linkname F C.f
|
||||
func F(cb *Callback)
|
||||
|
||||
//go:linkname G C._Z1gP9ICallback
|
||||
func G(cb *Callback)
|
||||
50
_demo/cppmintf/cpp_multi_intf.go
Normal file
50
_demo/cppmintf/cpp_multi_intf.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/_demo/cppmintf/foo"
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/math"
|
||||
)
|
||||
|
||||
type Bar struct {
|
||||
foo.Callback
|
||||
a c.Int
|
||||
}
|
||||
|
||||
func NewBar(a c.Int) *Bar {
|
||||
return &Bar{
|
||||
Callback: foo.Callback{
|
||||
ICalc: foo.ICalc{
|
||||
Vptr: &foo.ICalcVtbl{
|
||||
Calc: c.Func((*Bar).sqrt),
|
||||
},
|
||||
},
|
||||
IVal: foo.IVal{
|
||||
Vptr: &foo.IValVtbl{
|
||||
Val: c.Func(bar_IVal_getA),
|
||||
},
|
||||
},
|
||||
},
|
||||
a: a,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Bar) getA() c.Int {
|
||||
return p.a
|
||||
}
|
||||
|
||||
func bar_IVal_getA(this c.Pointer) c.Int {
|
||||
const delta = -int(unsafe.Offsetof(foo.Callback{}.IVal))
|
||||
return (*Bar)(c.Advance(this, delta)).getA()
|
||||
}
|
||||
|
||||
func (p *Bar) sqrt(v float64) float64 {
|
||||
return math.Sqrt(v)
|
||||
}
|
||||
|
||||
func main() {
|
||||
bar := NewBar(1)
|
||||
foo.F(&bar.Callback)
|
||||
}
|
||||
17
_demo/cppmintf/foo/bar/bar.cpp
Normal file
17
_demo/cppmintf/foo/bar/bar.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#define interface struct
|
||||
|
||||
interface ICalc {
|
||||
virtual double calc(double v) = 0;
|
||||
};
|
||||
|
||||
interface IVal {
|
||||
virtual int val() = 0;
|
||||
};
|
||||
|
||||
class Callback : public ICalc, public IVal {
|
||||
};
|
||||
|
||||
extern "C" void f(Callback* cb) {
|
||||
printf("val: %d\ncalc(2): %lf\n", cb->val(), cb->calc(2));
|
||||
}
|
||||
42
_demo/cppmintf/foo/foo.go
Normal file
42
_demo/cppmintf/foo/foo.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package foo
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
LLGoFiles = "bar/bar.cpp"
|
||||
LLGoPackage = "link"
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
type ICalc struct {
|
||||
Vptr *ICalcVtbl
|
||||
}
|
||||
|
||||
type ICalcVtbl struct {
|
||||
Calc unsafe.Pointer
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
type IVal struct {
|
||||
Vptr *IValVtbl
|
||||
}
|
||||
|
||||
type IValVtbl struct {
|
||||
Val unsafe.Pointer
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
type Callback struct {
|
||||
ICalc
|
||||
IVal
|
||||
}
|
||||
|
||||
//go:linkname F C.f
|
||||
func F(cb *Callback)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
26
_demo/crand/rand.go
Normal file
26
_demo/crand/rand.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/math/rand"
|
||||
"github.com/goplus/llgo/c/time"
|
||||
)
|
||||
|
||||
func fastrand64() uint64 {
|
||||
v1 := uint64(rand.Random())
|
||||
v2 := uint64(rand.Random())
|
||||
return v1 ^ (v2 << 32)
|
||||
}
|
||||
|
||||
func main() {
|
||||
rand.Srand(c.Uint(time.Time(nil)))
|
||||
fmt.Printf("%x\n", rand.Rand())
|
||||
fmt.Printf("%x\n", rand.Rand())
|
||||
|
||||
rand.Srandom(c.Uint(time.Time(nil)))
|
||||
fmt.Printf("%x\n", rand.Random())
|
||||
fmt.Printf("%x\n", rand.Random())
|
||||
fmt.Printf("%x\n", fastrand64())
|
||||
}
|
||||
12
_demo/ctime/time.go
Normal file
12
_demo/ctime/time.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import "github.com/goplus/llgo/c/time"
|
||||
|
||||
func main() {
|
||||
var tv time.Timespec
|
||||
time.ClockGettime(time.CLOCK_REALTIME, &tv)
|
||||
println("REALTIME sec:", tv.Sec, "nsec:", tv.Nsec)
|
||||
|
||||
time.ClockGettime(time.CLOCK_MONOTONIC, &tv)
|
||||
println("MONOTONIC sec:", tv.Sec, "nsec:", tv.Nsec)
|
||||
}
|
||||
77
_demo/fcntl/fcntl.go
Normal file
77
_demo/fcntl/fcntl.go
Normal file
@@ -0,0 +1,77 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/os"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
filename := c.Str("testfile.txt")
|
||||
data := c.Str("Hello, os!")
|
||||
var buffer [20]c.Char
|
||||
|
||||
// Open a file, O_CREAT|O_WRONLY|O_TRUNC means create, write only, or clear the file
|
||||
fd := os.Open(filename, os.O_CREAT|os.O_WRONLY|os.O_TRUNC, 0644)
|
||||
if fd == -1 {
|
||||
c.Printf(c.Str("open error\n"))
|
||||
return
|
||||
}
|
||||
|
||||
// Writing data to a file
|
||||
bytesWritten := os.Write(fd, c.Pointer(data), c.Strlen(data))
|
||||
if bytesWritten == -1 {
|
||||
c.Printf(c.Str("write error\n"))
|
||||
os.Close(fd)
|
||||
return
|
||||
}
|
||||
c.Printf(c.Str("Written %ld bytes to %s\n"), bytesWritten, filename)
|
||||
|
||||
// Get file status flags
|
||||
flags := os.Fcntl(fd, os.F_GETFL)
|
||||
if flags == -1 {
|
||||
c.Printf(c.Str("os error\n"))
|
||||
os.Close(fd)
|
||||
return
|
||||
}
|
||||
c.Printf(c.Str("File flags: %d\n"), flags)
|
||||
|
||||
// Set the file status flag to non-blocking mode
|
||||
if os.Fcntl(fd, os.F_SETFL, flags|os.O_NONBLOCK) == -1 {
|
||||
c.Printf(c.Str("os error\n"))
|
||||
os.Close(fd)
|
||||
return
|
||||
}
|
||||
c.Printf(c.Str("set file status successfully\n"))
|
||||
|
||||
|
||||
|
||||
c.Printf(c.Str("111"))
|
||||
// Close file
|
||||
os.Close(fd)
|
||||
|
||||
// Reopen the file, O_RDONLY means read-only
|
||||
fd = os.Open(filename, os.O_RDONLY)
|
||||
if fd == -1 {
|
||||
c.Printf(c.Str("open error\n"))
|
||||
return
|
||||
}
|
||||
|
||||
// Reading data from a file
|
||||
// &buffer[:][0]
|
||||
// unsafe.SliceData(buffer[:])
|
||||
bytesRead := os.Read(fd, c.Pointer(unsafe.SliceData(buffer[:])), unsafe.Sizeof(buffer)-1)
|
||||
if bytesRead == -1 {
|
||||
c.Printf(c.Str("read error\n"))
|
||||
os.Close(fd)
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure that the buffer is null-terminated
|
||||
buffer[bytesRead] = c.Char(0)
|
||||
c.Printf(c.Str("Read %ld bytes: %s\n"), bytesRead, &buffer[0])
|
||||
|
||||
// Close file
|
||||
os.Close(fd)
|
||||
}
|
||||
11
_demo/getcwd/getcwd.go
Normal file
11
_demo/getcwd/getcwd.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
wd := os.Getcwd(c.Alloca(os.PATH_MAX), os.PATH_MAX)
|
||||
c.Printf(c.Str("cwd: %s\n"), wd)
|
||||
}
|
||||
7
_demo/gotime/time.go
Normal file
7
_demo/gotime/time.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "time"
|
||||
|
||||
func main() {
|
||||
println(time.Now().String())
|
||||
}
|
||||
@@ -9,5 +9,5 @@ func main() {
|
||||
}
|
||||
|
||||
/* Expected output:
|
||||
Hello World
|
||||
Hello world
|
||||
*/
|
||||
|
||||
10
_demo/linkname/linkname.go
Normal file
10
_demo/linkname/linkname.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
import _ "unsafe" // for go:linkname
|
||||
|
||||
//go:linkname Sqrt C.sqrt
|
||||
func Sqrt(x float64) float64
|
||||
|
||||
func main() {
|
||||
println("sqrt(2) =", Sqrt(2))
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/llama2"
|
||||
"github.com/goplus/llgo/c/time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -11,7 +12,7 @@ func main() {
|
||||
var tokenizerPath *c.Char = c.Str("tokenizer.bin")
|
||||
var temperature, topp c.Float = 1.0, 0.9
|
||||
var steps c.Int = 256
|
||||
var rngSeed uint64 = uint64(c.Time(nil))
|
||||
var rngSeed uint64 = uint64(time.Time(nil))
|
||||
|
||||
loop: // parse command line arguments
|
||||
for {
|
||||
|
||||
9
_demo/logdemo/log.go
Normal file
9
_demo/logdemo/log.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.Println("Hello")
|
||||
}
|
||||
13
_demo/mimeheader/mimeheader.go
Normal file
13
_demo/mimeheader/mimeheader.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import "net/textproto"
|
||||
|
||||
func main() {
|
||||
h := make(textproto.MIMEHeader)
|
||||
h.Set("host", "www.example.com")
|
||||
println(h.Get("Host"))
|
||||
}
|
||||
|
||||
/* Expected output:
|
||||
www.example.com
|
||||
*/
|
||||
34
_demo/mkdirdemo/mkdir.go
Normal file
34
_demo/mkdirdemo/mkdir.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func main() {
|
||||
tempDir, err := os.MkdirTemp("", "example*")
|
||||
if err != nil {
|
||||
fmt.Println("Failed to create temp directory:", err)
|
||||
return
|
||||
}
|
||||
defer os.Remove(tempDir)
|
||||
fmt.Println("Temp directory:", tempDir)
|
||||
|
||||
tempFile, err := os.CreateTemp("", "example*.txt")
|
||||
if err != nil {
|
||||
fmt.Println("Failed to create temp file:", err)
|
||||
return
|
||||
}
|
||||
defer tempFile.Close()
|
||||
defer os.Remove(tempFile.Name())
|
||||
fmt.Println("Temp file:", tempFile.Name())
|
||||
|
||||
nestedDir := filepath.Join("nested", "directory")
|
||||
err = os.MkdirAll(nestedDir, 0755)
|
||||
if err != nil {
|
||||
fmt.Println("Failed to create nested directory:", err)
|
||||
return
|
||||
}
|
||||
fmt.Println("Nest directory:", nestedDir)
|
||||
}
|
||||
20
_demo/netdbdemo/netdb.go
Normal file
20
_demo/netdbdemo/netdb.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/net"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var hints net.AddrInfo
|
||||
hints.Family = net.AF_UNSPEC
|
||||
hints.SockType = net.SOCK_STREAM
|
||||
|
||||
host := "httpbin.org"
|
||||
port := "80"
|
||||
|
||||
var result *net.AddrInfo
|
||||
c.Printf(c.Str("%d\n"), net.Getaddrinfo(c.Str(host), c.Str(port), &hints, &result))
|
||||
|
||||
c.Printf(c.Str("%d\n"), net.Freeaddrinfo(result))
|
||||
}
|
||||
19
_demo/oslookpath/lookpath.go
Normal file
19
_demo/oslookpath/lookpath.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ls := "ls"
|
||||
if runtime.GOOS == "windows" {
|
||||
ls = "dir"
|
||||
}
|
||||
lspath, _ := exec.LookPath(ls)
|
||||
if lspath != "" {
|
||||
ls = lspath
|
||||
}
|
||||
fmt.Println(ls)
|
||||
}
|
||||
18
_demo/randcrypt/rand.go
Normal file
18
_demo/randcrypt/rand.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
c := 10
|
||||
b := make([]byte, c)
|
||||
_, err := rand.Read(b)
|
||||
if err != nil {
|
||||
fmt.Println("error:", err)
|
||||
return
|
||||
}
|
||||
// The slice should now contain random bytes instead of only zeroes.
|
||||
fmt.Printf("%x\n", b)
|
||||
}
|
||||
12
_demo/randdemo/rand.go
Normal file
12
_demo/randdemo/rand.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(rand.Intn(100))
|
||||
fmt.Println(rand.Intn(100))
|
||||
fmt.Println(rand.Intn(100))
|
||||
}
|
||||
32
_demo/socket/client/client.go
Normal file
32
_demo/socket/client/client.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/net"
|
||||
"github.com/goplus/llgo/c/os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
sockfd := net.Socket(net.AF_INET, net.SOCK_STREAM, 0)
|
||||
msg := c.Str("Hello, World!")
|
||||
defer os.Close(sockfd)
|
||||
|
||||
server := net.GetHostByName(c.Str("localhost"))
|
||||
if server == nil {
|
||||
c.Perror(c.Str("hostname get error"))
|
||||
return
|
||||
}
|
||||
|
||||
servAddr := &net.SockaddrIn{}
|
||||
servAddr.Family = net.AF_INET
|
||||
servAddr.Port = net.Htons(uint16(1234))
|
||||
c.Memcpy(unsafe.Pointer(&servAddr.Addr.Addr), unsafe.Pointer(*server.AddrList), uintptr(server.Length))
|
||||
|
||||
if res := net.Connect(sockfd, (*net.SockAddr)(unsafe.Pointer(servAddr)), c.Uint(16)); res < 0 {
|
||||
c.Perror(c.Str("connect error"))
|
||||
return
|
||||
}
|
||||
os.Write(sockfd, unsafe.Pointer(msg), c.Strlen(msg))
|
||||
}
|
||||
43
_demo/socket/server/server.go
Normal file
43
_demo/socket/server/server.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/net"
|
||||
"github.com/goplus/llgo/c/os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var buffer [256]c.Char
|
||||
|
||||
sockfd := net.Socket(net.AF_INET, net.SOCK_STREAM, 0)
|
||||
defer os.Close(sockfd)
|
||||
|
||||
servAddr := &net.SockaddrIn{
|
||||
Family: net.AF_INET,
|
||||
Port: net.Htons(uint16(1234)),
|
||||
Addr: net.InAddr{Addr: 0x00000000},
|
||||
Zero: [8]c.Char{0, 0, 0, 0, 0, 0, 0, 0},
|
||||
}
|
||||
if res := net.Bind(sockfd, servAddr, c.Uint(unsafe.Sizeof(*servAddr))); res < 0 {
|
||||
c.Perror(c.Str("bind error"))
|
||||
return
|
||||
}
|
||||
|
||||
if net.Listen(sockfd, 5) < 0 {
|
||||
c.Printf(c.Str("listen error"))
|
||||
return
|
||||
}
|
||||
c.Printf(c.Str("Listening on port 1234...\n"))
|
||||
|
||||
cliAddr, clilen := &net.SockaddrIn{}, c.Uint(unsafe.Sizeof(servAddr))
|
||||
|
||||
newsockfd := net.Accept(sockfd, cliAddr, &clilen)
|
||||
defer os.Close(newsockfd)
|
||||
c.Printf(c.Str("Connection accepted."))
|
||||
|
||||
os.Read(newsockfd, unsafe.Pointer(unsafe.SliceData(buffer[:])), 256)
|
||||
c.Printf(c.Str("Received: %s"), &buffer[0])
|
||||
|
||||
}
|
||||
26
_demo/sysexec/exec.go
Normal file
26
_demo/sysexec/exec.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ls := "ls"
|
||||
args := []string{ls, "-l"}
|
||||
if runtime.GOOS == "windows" {
|
||||
ls = "dir"
|
||||
args = []string{ls}
|
||||
}
|
||||
lspath, _ := exec.LookPath(ls)
|
||||
if lspath != "" {
|
||||
ls = lspath
|
||||
}
|
||||
err := syscall.Exec(ls, args, nil)
|
||||
if err != nil {
|
||||
fmt.Println("syscall.Exec error:", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
11
_demo/timedur/timedur.go
Normal file
11
_demo/timedur/timedur.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
t := time.Now().Add(time.Second * 5)
|
||||
fmt.Println(time.Until(t))
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/py"
|
||||
"github.com/goplus/llgo/py/math"
|
||||
"github.com/goplus/llgo/py/std"
|
||||
)
|
||||
|
||||
func main() {
|
||||
x := math.Sqrt(py.Float(2))
|
||||
c.Printf(c.Str("sqrt(2) = %f\n"), x.Float64())
|
||||
x := math.Sqrt(py.Float(2)) // x = sqrt(2)
|
||||
std.Print(py.Str("sqrt(2) ="), x) // print("sqrt(2) =", x)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/py"
|
||||
"github.com/goplus/llgo/py/numpy"
|
||||
"github.com/goplus/llgo/py/std"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -18,5 +18,5 @@ func main() {
|
||||
py.List(3.0, 2.0, 1.0),
|
||||
)
|
||||
x := numpy.Add(a, b)
|
||||
c.Printf(c.Str("a+b = %s\n"), x.Str().CStr())
|
||||
std.Print(py.Str("a+b ="), x)
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ package main
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/_test/testing"
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/bdwgc"
|
||||
"github.com/goplus/llgo/c/bdwgc/_test/testing"
|
||||
)
|
||||
|
||||
// ------ Test malloc ------
|
||||
@@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/_test/testing"
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/bdwgc/_test/testing"
|
||||
)
|
||||
|
||||
type TestCase struct {
|
||||
Binary file not shown.
17
c/bitcast/_cast/cast.c
Normal file
17
c/bitcast/_cast/cast.c
Normal file
@@ -0,0 +1,17 @@
|
||||
typedef union {
|
||||
double d;
|
||||
float f;
|
||||
long v;
|
||||
} castUnion;
|
||||
|
||||
double llgoToFloat64(long v) {
|
||||
castUnion k;
|
||||
k.v = v;
|
||||
return k.d;
|
||||
}
|
||||
|
||||
float llgoToFloat32(long v) {
|
||||
castUnion k;
|
||||
k.v = v;
|
||||
return k.f;
|
||||
}
|
||||
30
c/bitcast/bitcast.go
Normal file
30
c/bitcast/bitcast.go
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package bitcast
|
||||
|
||||
import _ "unsafe"
|
||||
|
||||
const (
|
||||
LLGoFiles = "_cast/cast.c"
|
||||
LLGoPackage = "link"
|
||||
)
|
||||
|
||||
//go:linkname ToFloat64 C.llgoToFloat64
|
||||
func ToFloat64(v uintptr) float64
|
||||
|
||||
//go:linkname ToFloat32 C.llgoToFloat32
|
||||
func ToFloat32(v uintptr) float32
|
||||
125
c/c.go
125
c/c.go
@@ -17,6 +17,9 @@
|
||||
package c
|
||||
|
||||
// typedef unsigned int uint;
|
||||
// typedef unsigned long ulong;
|
||||
// typedef unsigned long long ulonglong;
|
||||
// typedef long long longlong;
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
@@ -25,17 +28,23 @@ const (
|
||||
)
|
||||
|
||||
type (
|
||||
Char = int8
|
||||
Int = C.int
|
||||
Uint = C.uint
|
||||
Long = int32
|
||||
Ulong = uint32
|
||||
LongLong = int64
|
||||
UlongLong = uint64
|
||||
Float = float32
|
||||
Double = float64
|
||||
Pointer = unsafe.Pointer
|
||||
FilePtr = unsafe.Pointer
|
||||
Void = [0]byte
|
||||
Char = int8
|
||||
Float = float32
|
||||
Double = float64
|
||||
Pointer = unsafe.Pointer
|
||||
FilePtr = unsafe.Pointer
|
||||
)
|
||||
|
||||
type (
|
||||
Int C.int
|
||||
Uint C.uint
|
||||
|
||||
Long C.long
|
||||
Ulong C.ulong
|
||||
|
||||
LongLong C.longlong
|
||||
UlongLong C.ulonglong
|
||||
)
|
||||
|
||||
type integer interface {
|
||||
@@ -45,6 +54,9 @@ type integer interface {
|
||||
//go:linkname Str llgo.cstr
|
||||
func Str(string) *Char
|
||||
|
||||
//go:linkname Func llgo.funcAddr
|
||||
func Func(any) Pointer
|
||||
|
||||
// llgo:link Advance llgo.advance
|
||||
func Advance[PtrT any, I integer](ptr PtrT, offset I) PtrT { return ptr }
|
||||
|
||||
@@ -57,9 +69,19 @@ func Alloca(size uintptr) Pointer
|
||||
//go:linkname AllocaCStr llgo.allocaCStr
|
||||
func AllocaCStr(s string) *Char
|
||||
|
||||
//go:linkname AllocaCStrs llgo.allocaCStrs
|
||||
func AllocaCStrs(strs []string, endWithNil bool) **Char
|
||||
|
||||
// TODO(xsw):
|
||||
// llgo:link AllocaNew llgo.allocaNew
|
||||
func AllocaNew[T any]() *T { return nil }
|
||||
|
||||
//go:linkname Malloc C.malloc
|
||||
func Malloc(size uintptr) Pointer
|
||||
|
||||
//go:linkname Calloc C.calloc
|
||||
func Calloc(num uintptr, size uintptr) Pointer
|
||||
|
||||
//go:linkname Free C.free
|
||||
func Free(ptr Pointer)
|
||||
|
||||
@@ -72,8 +94,73 @@ func Memmove(dst, src Pointer, n uintptr) Pointer
|
||||
//go:linkname Memset C.memset
|
||||
func Memset(s Pointer, c Int, n uintptr) Pointer
|
||||
|
||||
//go:linkname Memchr C.memchr
|
||||
func Memchr(s Pointer, c Int, n uintptr) Pointer
|
||||
|
||||
//go:linkname Memcmp C.memcmp
|
||||
func Memcmp(s1, s2 Pointer, n uintptr) Int
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
//go:linkname Strlen C.strlen
|
||||
func Strlen(s *Char) uintptr
|
||||
|
||||
//go:linkname Strcpy C.strcpy
|
||||
func Strcpy(dst, src *Char) *Char
|
||||
|
||||
//go:linkname Strncpy C.strncpy
|
||||
func Strncpy(dst, src *Char, n uintptr) *Char
|
||||
|
||||
//go:linkname Strcat C.strcat
|
||||
func Strcat(dst, src *Char) *Char
|
||||
|
||||
//go:linkname Strncat C.strncat
|
||||
func Strncat(dst, src *Char, n uintptr) *Char
|
||||
|
||||
//go:linkname Strcmp C.strcmp
|
||||
func Strcmp(s1, s2 *Char) Int
|
||||
|
||||
//go:linkname Strncmp C.strncmp
|
||||
func Strncmp(s1, s2 *Char, n uintptr) Int
|
||||
|
||||
//go:linkname Strchr C.strchr
|
||||
func Strchr(s *Char, c Int) *Char
|
||||
|
||||
//go:linkname Strrchr C.strrchr
|
||||
func Strrchr(s *Char, c Int) *Char
|
||||
|
||||
//go:linkname Strstr C.strstr
|
||||
func Strstr(s1, s2 *Char) *Char
|
||||
|
||||
//go:linkname Strdup C.strdup
|
||||
func Strdup(s *Char) *Char
|
||||
|
||||
//go:linkname Strndup C.strndup
|
||||
func Strndup(s *Char, n uintptr) *Char
|
||||
|
||||
//go:linkname Strtok C.strtok
|
||||
func Strtok(s, delim *Char) *Char
|
||||
|
||||
//go:linkname Strerror C.strerror
|
||||
func Strerror(errnum Int) *Char
|
||||
|
||||
//go:linkname Sprintf C.sprintf
|
||||
func Sprintf(s *Char, format *Char, __llgo_va_list ...any) Int
|
||||
|
||||
//go:linkname Snprintf C.snprintf
|
||||
func Snprintf(s *Char, n uintptr, format *Char, __llgo_va_list ...any) Int
|
||||
|
||||
//go:linkname Vsnprintf C.vsnprintf
|
||||
func Vsnprintf(s *Char, n uintptr, format *Char, ap Pointer) Int
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// GoString converts a C string to a Go string.
|
||||
// TODO(xsw): any => int
|
||||
//
|
||||
//go:linkname GoString llgo.string
|
||||
func GoString(cstr *Char, __llgo_va_list /* n */ ...any) string
|
||||
|
||||
//go:linkname GoStringData llgo.stringData
|
||||
func GoStringData(string) *Char
|
||||
|
||||
@@ -129,19 +216,23 @@ func Fputc(c Int, fp FilePtr) Int
|
||||
//go:linkname Fputs C.fputs
|
||||
func Fputs(s *Char, fp FilePtr) Int
|
||||
|
||||
//go:linkname Fread C.fread
|
||||
func Fread(data Pointer, size, count uintptr, fp FilePtr) uintptr
|
||||
|
||||
//go:linkname Fflush C.fflush
|
||||
func Fflush(fp FilePtr) Int
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
//go:linkname Fopen C.fopen
|
||||
func Fopen(c *Char, mod *Char) FilePtr
|
||||
|
||||
//go:linkname Remove C.remove
|
||||
func Remove(path *Char) Int
|
||||
//go:linkname Fclose C.fclose
|
||||
func Fclose(fp FilePtr) Int
|
||||
|
||||
//go:linkname Perror C.perror
|
||||
func Perror(s *Char)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
//go:linkname Time C.time
|
||||
func Time(*int32) int32
|
||||
|
||||
//go:linkname Usleep C.usleep
|
||||
func Usleep(useconds Uint) Int
|
||||
|
||||
|
||||
@@ -1,26 +1,18 @@
|
||||
LLGo wrapper of DaveGamble/cJSON
|
||||
=====
|
||||
[](https://github.com/goplus/cjson/actions/workflows/go.yml)
|
||||
[](https://github.com/goplus/cjson/releases)
|
||||
[](https://pkg.go.dev/github.com/goplus/cjson)
|
||||
[](https://github.com/goplus/llgo)
|
||||
[](https://github.com/goplus/gop)
|
||||
|
||||
## How to install
|
||||
|
||||
### on macOS (Homebrew)
|
||||
|
||||
```sh
|
||||
brew install cjson
|
||||
```
|
||||
### from source code
|
||||
|
||||
### on Linux (Debian/Ubuntu)
|
||||
|
||||
```sh
|
||||
git clone https://github.com/goplus/cjson.git
|
||||
cd cjson
|
||||
git submodule init
|
||||
git submodule update
|
||||
mkdir build.dir
|
||||
cd build.dir
|
||||
cmake ../cJSON
|
||||
sudo make install
|
||||
apt-get install -y libcjson-dev
|
||||
```
|
||||
|
||||
## Demos
|
||||
|
||||
@@ -22,6 +22,22 @@ func main() {
|
||||
|
||||
mod.SetItem(c.Str("items"), syms)
|
||||
|
||||
c.Printf(c.Str("%s\n"), mod.CStr())
|
||||
cstr := mod.CStr()
|
||||
str := c.GoString(cstr)
|
||||
c.Printf(c.Str("%s\n"), cstr)
|
||||
cjson.FreeCStr(cstr)
|
||||
|
||||
mod.Delete()
|
||||
|
||||
cjsonLoad(str)
|
||||
}
|
||||
|
||||
func cjsonLoad(str string) {
|
||||
mod := cjson.ParseString(str)
|
||||
|
||||
cstr := mod.Print()
|
||||
c.Printf(c.Str("%s\n"), cstr)
|
||||
cjson.FreeCStr(cstr)
|
||||
|
||||
mod.Delete()
|
||||
}
|
||||
|
||||
673
c/cjson/cjson.go
673
c/cjson/cjson.go
@@ -17,7 +17,7 @@
|
||||
package cjson
|
||||
|
||||
import (
|
||||
_ "unsafe"
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
@@ -26,73 +26,25 @@ const (
|
||||
LLGoPackage = "link: $(pkg-config --libs libcjson); -lcjson"
|
||||
)
|
||||
|
||||
type Bool c.Int
|
||||
|
||||
// llgo:type C
|
||||
type JSON struct {
|
||||
Unused [0]byte
|
||||
}
|
||||
|
||||
//go:linkname Null C.cJSON_CreateNull
|
||||
func Null() *JSON
|
||||
func ParseBytes(value []byte) *JSON {
|
||||
return ParseWithLength((*c.Char)(unsafe.Pointer(unsafe.SliceData(value))), uintptr(len(value)))
|
||||
}
|
||||
|
||||
//go:linkname True C.cJSON_CreateTrue
|
||||
func True() *JSON
|
||||
func ParseString(value string) *JSON {
|
||||
return ParseWithLength((*c.Char)(unsafe.Pointer(unsafe.StringData(value))), uintptr(len(value)))
|
||||
}
|
||||
|
||||
//go:linkname False C.cJSON_CreateFalse
|
||||
func False() *JSON
|
||||
|
||||
//go:linkname Bool C.cJSON_CreateBool
|
||||
func Bool(boolean c.Int) *JSON
|
||||
|
||||
//go:linkname Number C.cJSON_CreateNumber
|
||||
func Number(num float64) *JSON
|
||||
|
||||
//go:linkname String C.cJSON_CreateString
|
||||
func String(str *c.Char) *JSON
|
||||
|
||||
//go:linkname Array C.cJSON_CreateArray
|
||||
func Array() *JSON
|
||||
|
||||
//go:linkname Object C.cJSON_CreateObject
|
||||
func Object() *JSON
|
||||
|
||||
// raw json
|
||||
// CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
|
||||
//
|
||||
//go:linkname Raw C.cJSON_CreateRaw
|
||||
func Raw(raw *c.Char) *JSON
|
||||
|
||||
// Create a string where valuestring references a string so
|
||||
// it will not be freed by Delete
|
||||
// Render a cJSON entity to text for transfer/storage without any formatting.
|
||||
//
|
||||
//go:linkname StringRef C.cJSON_CreateStringReference
|
||||
func StringRef(str *c.Char) *JSON
|
||||
|
||||
// Create an object that only references it's elements so
|
||||
// they will not be freed by Delete
|
||||
//
|
||||
//go:linkname ObjectRef C.cJSON_CreateObjectReference
|
||||
func ObjectRef(child *JSON) *JSON
|
||||
|
||||
// Create an array that only references it's elements so
|
||||
// they will not be freed by Delete
|
||||
//
|
||||
//go:linkname ArrayRef C.cJSON_CreateArrayReference
|
||||
func ArrayRef(child *JSON) *JSON
|
||||
|
||||
// Delete a JSON entity and all subentities.
|
||||
//
|
||||
// llgo:link (*JSON).Delete C.cJSON_Delete
|
||||
func (o *JSON) Delete() {}
|
||||
|
||||
// Append item to the specified array.
|
||||
//
|
||||
// llgo:link (*JSON).AddItem C.cJSON_AddItemToArray
|
||||
func (o *JSON) AddItem(item *JSON) c.Int { return 0 }
|
||||
|
||||
// Append item to the specified object.
|
||||
//
|
||||
// llgo:link (*JSON).SetItem C.cJSON_AddItemToObject
|
||||
func (o *JSON) SetItem(key *c.Char, item *JSON) c.Int { return 0 }
|
||||
|
||||
// llgo:link (*JSON).CStr C.cJSON_PrintUnformatted
|
||||
func (o *JSON) CStr() *c.Char { return nil }
|
||||
|
||||
@@ -101,21 +53,618 @@ func (o *JSON) CStr() *c.Char { return nil }
|
||||
// llgo:link (*JSON).Cstr C.cJSON_PrintUnformatted
|
||||
func (o *JSON) Cstr() *c.Char { return nil }
|
||||
|
||||
// malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks
|
||||
//
|
||||
//go:linkname FreeCStr C.cJSON_free
|
||||
func FreeCStr(*c.Char)
|
||||
|
||||
// CJSON_PUBLIC(const char*) cJSON_Version(void);
|
||||
//
|
||||
// returns the version of cJSON as a string
|
||||
//
|
||||
//go:linkname Version C.cJSON_Version
|
||||
func Version() *c.Char
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
|
||||
//
|
||||
// Memory Management: the caller is always responsible to free
|
||||
// the results from all variants of cJSON_Parse (with cJSON_Delete)
|
||||
// and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or
|
||||
// cJSON_free as appropriate). The exception is cJSON_PrintPreallocated,
|
||||
// where the caller has full responsibility of the buffer.
|
||||
//
|
||||
//go:linkname Parse C.cJSON_Parse
|
||||
func Parse(value *c.Char) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length);
|
||||
//
|
||||
// Memory Management: the caller is always responsible to free
|
||||
// the results from all variants of cJSON_Parse (with cJSON_Delete)
|
||||
// and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or
|
||||
// cJSON_free as appropriate). The exception is cJSON_PrintPreallocated,
|
||||
// where the caller has full responsibility of the buffer.
|
||||
//
|
||||
//go:linkname ParseWithLength C.cJSON_ParseWithLength
|
||||
func ParseWithLength(value *c.Char, valueLength uintptr) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_Bool require_null_terminated);
|
||||
//
|
||||
// ParseWithOpts allows you to require (and check) that the JSON is null terminated,
|
||||
// and to retrieve the pointer to the final byte parsed.
|
||||
// If you supply a ptr in return_parse_end and parsing fails, then
|
||||
// return_parse_end will contain a pointer to the error so will match
|
||||
// cJSON_GetErrorPtr().
|
||||
//
|
||||
//go:linkname ParseWithOpts C.cJSON_ParseWithOpts
|
||||
func ParseWithOpts(value *c.Char, return_parse_end **c.Char, require_null_terminated Bool) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_Bool require_null_terminated);
|
||||
//
|
||||
// ParseWithOpts allows you to require (and check) that the JSON is null terminated,
|
||||
// and to retrieve the pointer to the final byte parsed.
|
||||
// If you supply a ptr in return_parse_end and parsing fails, then
|
||||
// return_parse_end will contain a pointer to the error so will match
|
||||
// cJSON_GetErrorPtr().
|
||||
//
|
||||
//go:linkname ParseWithLengthOpts C.cJSON_ParseWithLengthOpts
|
||||
func ParseWithLengthOpts(value *c.Char, buffer_length uintptr, return_parse_end **c.Char, require_null_terminated Bool) *JSON
|
||||
|
||||
// CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
|
||||
// Render a JSON entity to text for transfer/storage.
|
||||
//
|
||||
// llgo:link (*JSON).Print C.cJSON_Print
|
||||
func (o *JSON) Print() *c.Char { return nil }
|
||||
|
||||
// CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
|
||||
// Render a JSON entity to text for transfer/storage without any formatting.
|
||||
//
|
||||
// llgo:link (*JSON).PrintUnformatted C.cJSON_PrintUnformatted
|
||||
func (o *JSON) PrintUnformatted() *c.Char { return nil }
|
||||
|
||||
// CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_Bool fmt);
|
||||
//
|
||||
// Render a JSON entity to text using a buffered strategy.
|
||||
//
|
||||
// prebuffer is a guess at the final size. guessing well reduces reallocation.
|
||||
//
|
||||
// fmt=0 gives unformatted, =1 gives formatted.
|
||||
//
|
||||
// llgo:link (*JSON).PrintBuffered C.cJSON_PrintBuffered
|
||||
func (o *JSON) PrintBuffered(prebuffer c.Int, fmt c.Int) *c.Char { return nil }
|
||||
func (o *JSON) PrintBuffered(prebuffer c.Int, fmt Bool) *c.Char { return nil }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_Bool format);
|
||||
//
|
||||
// Render a cJSON entity to text using a buffer already allocated in memory with given
|
||||
// length. Returns 1 on success and 0 on failure.
|
||||
// note that cJSON is not always 100% accurate in estimating how much memory it will use,
|
||||
// so to be safe allocate 5 bytes more than you actually need
|
||||
//
|
||||
// llgo:link (*JSON).PrintPreallocated C.cJSON_PrintPreallocated
|
||||
func (o *JSON) PrintPreallocated(buffer *c.Char, length c.Int, format Bool) Bool {
|
||||
return Bool(0)
|
||||
}
|
||||
|
||||
// CJSON_PUBLIC(void) cJSON_Delete(cJSON *item);
|
||||
// Delete a JSON entity and all subentities.
|
||||
//
|
||||
// llgo:link (*JSON).Delete C.cJSON_Delete
|
||||
func (o *JSON) Delete() {}
|
||||
|
||||
// CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
|
||||
//
|
||||
// Returns the number of items in an array (or object).
|
||||
//
|
||||
// llgo:link (*JSON).GetArraySize C.cJSON_GetArraySize
|
||||
func (o *JSON) GetArraySize() c.Int { return 0 }
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
|
||||
//
|
||||
// Retrieve item number "index" from array "array". Returns NULL if unsuccessful.
|
||||
//
|
||||
// llgo:link (*JSON).GetArrayItem C.cJSON_GetArrayItem
|
||||
func (o *JSON) GetArrayItem(index c.Int) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
|
||||
//
|
||||
// Get item "string" from object. Case insensitive.
|
||||
//
|
||||
// llgo:link (*JSON).GetObjectItem C.cJSON_GetObjectItem
|
||||
func (o *JSON) GetObjectItem(s *c.Char) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
|
||||
//
|
||||
// Get item "string" from object. Case sensitive.
|
||||
//
|
||||
// llgo:link (*JSON).GetObjectItemCaseSensitive C.cJSON_GetObjectItemCaseSensitive
|
||||
func (o *JSON) GetObjectItemCaseSensitive(key *c.Char) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
||||
//
|
||||
// llgo:link (*JSON).HasObjectItem C.cJSON_HasObjectItem
|
||||
func (o *JSON) HasObjectItem(s *c.Char) Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
||||
//
|
||||
// For analysing failed parses. This returns a pointer to the parse error.
|
||||
// You'll probably need to look a few chars back to make sense of it.
|
||||
// Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds.
|
||||
//
|
||||
//go:linkname GetErrorPtr C.cJSON_GetErrorPtr
|
||||
func GetErrorPtr() *c.Char
|
||||
|
||||
// CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
|
||||
//
|
||||
// Check item type and return its value
|
||||
//
|
||||
// llgo:link (*JSON).GetStringValue C.cJSON_GetStringValue
|
||||
func (o *JSON) GetStringValue() *c.Char { return nil }
|
||||
|
||||
// CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item);
|
||||
//
|
||||
// Check item type and return its value
|
||||
//
|
||||
// llgo:link (*JSON).GetNumberValue C.cJSON_GetNumberValue
|
||||
func (o *JSON) GetNumberValue() c.Double { return 0 }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_IsInvalid(const cJSON * const item);
|
||||
//
|
||||
// These functions check the type of an item
|
||||
//
|
||||
// llgo:link (*JSON).IsInvalid C.cJSON_IsInvalid
|
||||
func (o *JSON) IsInvalid() Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_IsFalse(const cJSON * const item);
|
||||
//
|
||||
// These functions check the type of an item
|
||||
//
|
||||
// llgo:link (*JSON).IsFalse C.cJSON_IsFalse
|
||||
func (o *JSON) IsFalse() Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_IsTrue(const cJSON * const item);
|
||||
//
|
||||
// These functions check the type of an item
|
||||
//
|
||||
// llgo:link (*JSON).IsTrue C.cJSON_IsTrue
|
||||
func (o *JSON) IsTrue() Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_IsBool(const cJSON * const item);
|
||||
//
|
||||
// These functions check the type of an item
|
||||
//
|
||||
// llgo:link (*JSON).IsBool C.cJSON_IsBool
|
||||
func (o *JSON) IsBool() Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_IsNull(const cJSON * const item);
|
||||
//
|
||||
// These functions check the type of an item
|
||||
//
|
||||
// llgo:link (*JSON).IsNull C.cJSON_IsNull
|
||||
func (o *JSON) IsNull() Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_IsNumber(const cJSON * const item);
|
||||
//
|
||||
// These functions check the type of an item
|
||||
//
|
||||
// llgo:link (*JSON).IsNumber C.cJSON_IsNumber
|
||||
func (o *JSON) IsNumber() Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_IsString(const cJSON * const item);
|
||||
//
|
||||
// These functions check the type of an item
|
||||
//
|
||||
// llgo:link (*JSON).IsString C.cJSON_IsString
|
||||
func (o *JSON) IsString() Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_IsArray(const cJSON * const item);
|
||||
//
|
||||
// These functions check the type of an item
|
||||
//
|
||||
// llgo:link (*JSON).IsArray C.cJSON_IsArray
|
||||
func (o *JSON) IsArray() Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_IsObject(const cJSON * const item);
|
||||
//
|
||||
// These functions check the type of an item
|
||||
//
|
||||
// llgo:link (*JSON).IsObject C.cJSON_IsObject
|
||||
func (o *JSON) IsObject() Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_IsRaw(const cJSON * const item);
|
||||
//
|
||||
// These functions check the type of an item
|
||||
//
|
||||
// llgo:link (*JSON).IsRaw C.cJSON_IsRaw
|
||||
func (o *JSON) IsRaw() Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
|
||||
//
|
||||
// These calls create a cJSON item of the appropriate type.
|
||||
//
|
||||
//go:linkname Null C.cJSON_CreateNull
|
||||
func Null() *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
|
||||
//
|
||||
// same as Null func
|
||||
//
|
||||
//go:linkname CreateNull C.cJSON_CreateNull
|
||||
func CreateNull() *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
|
||||
//
|
||||
//go:linkname True C.cJSON_CreateTrue
|
||||
func True() *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
|
||||
//
|
||||
// same as True func
|
||||
//
|
||||
//go:linkname CreateTrue C.cJSON_CreateTrue
|
||||
func CreateTrue() *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
|
||||
//
|
||||
//go:linkname False C.cJSON_CreateFalse
|
||||
func False() *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
|
||||
//
|
||||
// same as False func
|
||||
//
|
||||
//go:linkname CreateFalse C.cJSON_CreateFalse
|
||||
func CreateFalse() *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_Bool boolean);
|
||||
//
|
||||
// same as Bool func
|
||||
//
|
||||
//go:linkname CreateBool C.cJSON_CreateBool
|
||||
func CreateBool(boolean c.Int) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
|
||||
//
|
||||
//go:linkname Number C.cJSON_CreateNumber
|
||||
func Number(num float64) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
|
||||
//
|
||||
// same as Number func
|
||||
//
|
||||
//go:linkname CreateNumber C.cJSON_CreateNumber
|
||||
func CreateNumber(num float64) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
|
||||
//
|
||||
//go:linkname String C.cJSON_CreateString
|
||||
func String(str *c.Char) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
|
||||
//
|
||||
// same as String func
|
||||
//
|
||||
//go:linkname CreateString C.cJSON_CreateString
|
||||
func CreateString(str *c.Char) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
|
||||
// raw json
|
||||
//
|
||||
//go:linkname Raw C.cJSON_CreateRaw
|
||||
func Raw(raw *c.Char) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
|
||||
//
|
||||
// same as Raw func
|
||||
//
|
||||
//go:linkname CreateRaw C.cJSON_CreateRaw
|
||||
func CreateRaw(raw *c.Char) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
|
||||
//
|
||||
//go:linkname Array C.cJSON_CreateArray
|
||||
func Array() *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
|
||||
//
|
||||
// same as Array func
|
||||
//
|
||||
//go:linkname CreateArray C.cJSON_CreateArray
|
||||
func CreateArray() *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
|
||||
//
|
||||
//go:linkname Object C.cJSON_CreateObject
|
||||
func Object() *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
|
||||
//
|
||||
// same as Object func
|
||||
//
|
||||
//go:linkname CreateObject C.cJSON_CreateObject
|
||||
func CreateObject() *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
|
||||
//
|
||||
// Create a string where valuestring references a string so
|
||||
// it will not be freed by Delete
|
||||
//
|
||||
//go:linkname StringRef C.cJSON_CreateStringReference
|
||||
func StringRef(str *c.Char) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
|
||||
//
|
||||
// same as StringRef func
|
||||
//
|
||||
//go:linkname CreateStringReference C.cJSON_CreateStringReference
|
||||
func CreateStringReference(str *c.Char) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
|
||||
//
|
||||
// Create an object that only references it's elements so
|
||||
// they will not be freed by Delete
|
||||
//
|
||||
//go:linkname ObjectRef C.cJSON_CreateObjectReference
|
||||
func ObjectRef(child *JSON) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
|
||||
//
|
||||
// same as ObjectRef func
|
||||
//
|
||||
//go:linkname CreateObjectReference C.cJSON_CreateObjectReference
|
||||
func CreateObjectReference(child *JSON) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
|
||||
//
|
||||
// Create an array that only references it's elements so
|
||||
// they will not be freed by Delete
|
||||
//
|
||||
//go:linkname ArrayRef C.cJSON_CreateArrayReference
|
||||
func ArrayRef(child *JSON) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
|
||||
//
|
||||
// same as ArrayRef func
|
||||
//
|
||||
//go:linkname CreateArrayReference C.cJSON_CreateArrayReference
|
||||
func CreateArrayReference(child *JSON) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
|
||||
//
|
||||
//go:linkname CreateIntArray C.cJSON_CreateIntArray
|
||||
func CreateIntArray(numbers *c.Int, count c.Int) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
|
||||
//
|
||||
//go:linkname CreateFloatArray C.cJSON_CreateFloatArray
|
||||
func CreateFloatArray(numbers *c.Float, count c.Int) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
|
||||
//
|
||||
//go:linkname CreateDoubleArray C.cJSON_CreateDoubleArray
|
||||
func CreateDoubleArray(numbers *c.Double, count c.Int) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count);
|
||||
//
|
||||
//go:linkname CreateStringArray C.cJSON_CreateStringArray
|
||||
func CreateStringArray(strings *c.Char, count c.Int) *JSON
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
//
|
||||
// Append item to the specified array.
|
||||
//
|
||||
// llgo:link (*JSON).AddItem C.cJSON_AddItemToArray
|
||||
func (o *JSON) AddItem(item *JSON) Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
//
|
||||
// same as AddItem func
|
||||
//
|
||||
// llgo:link (*JSON).AddItemToArray C.cJSON_AddItemToArray
|
||||
func (o *JSON) AddItemToArray(item *JSON) Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
|
||||
//
|
||||
// Append item to the specified object.
|
||||
//
|
||||
// llgo:link (*JSON).SetItem C.cJSON_AddItemToObject
|
||||
func (o *JSON) SetItem(key *c.Char, item *JSON) Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
|
||||
//
|
||||
// same as SetItem func
|
||||
//
|
||||
// llgo:link (*JSON).AddItemToObject C.cJSON_AddItemToObject
|
||||
func (o *JSON) AddItemToObject(key *c.Char, item *JSON) Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
|
||||
//
|
||||
// Use this when string is definitely const (i.e. a literal, or as good as),
|
||||
// and will definitely survive the cJSON object.
|
||||
// warning that When this function was used, make sure to always check that
|
||||
// (item->type & cJSON_StringIsConst) is zero before writing to `item->string`
|
||||
//
|
||||
// llgo:link (*JSON).AddItemToObjectCS C.cJSON_AddItemToObjectCS
|
||||
func (o *JSON) AddItemToObjectCS(s *c.Char, item *JSON) Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||
//
|
||||
// Append reference to item to the specified array/object.
|
||||
// Use this when you want to add an existing cJSON to a new cJSON,
|
||||
// but don't want to corrupt your existing cJSON.
|
||||
//
|
||||
// llgo:link (*JSON).AddItemReferenceToArray C.cJSON_AddItemReferenceToArray
|
||||
func (o *JSON) AddItemReferenceToArray(item *JSON) Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
|
||||
//
|
||||
// llgo:link (*JSON).AddItemReferenceToObject C.cJSON_AddItemReferenceToObject
|
||||
func (o *JSON) AddItemReferenceToObject(s *c.Char, item *JSON) Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
|
||||
//
|
||||
// Remove/Detach items from Arrays/Objects.
|
||||
//
|
||||
// llgo:link (*JSON).DetachItemViaPointer C.cJSON_DetachItemViaPointer
|
||||
func (o *JSON) DetachItemViaPointer(item *JSON) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
|
||||
//
|
||||
// llgo:link (*JSON).DetachItemFromArray C.cJSON_DetachItemFromArray
|
||||
func (o *JSON) DetachItemFromArray(which c.Int) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
|
||||
//
|
||||
// llgo:link (*JSON).DeleteItemFromArray C.cJSON_DeleteItemFromArray
|
||||
func (o *JSON) DeleteItemFromArray(which c.Int) {}
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
|
||||
//
|
||||
// llgo:link (*JSON).DetachItemFromObject C.cJSON_DetachItemFromObject
|
||||
func (o *JSON) DetachItemFromObject(s *c.Char) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
//
|
||||
// llgo:link (*JSON).DetachItemFromObjectCaseSensitive C.cJSON_DetachItemFromObjectCaseSensitive
|
||||
func (o *JSON) DetachItemFromObjectCaseSensitive(s *c.Char) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
|
||||
//
|
||||
// llgo:link (*JSON).DeleteItemFromObject C.cJSON_DeleteItemFromObject
|
||||
func (o *JSON) DeleteItemFromObject(s *c.Char) {}
|
||||
|
||||
// CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
//
|
||||
// llgo:link (*JSON).DeleteItemFromObjectCaseSensitive C.cJSON_DeleteItemFromObjectCaseSensitive
|
||||
func (o *JSON) DeleteItemFromObjectCaseSensitive(s *c.Char) {}
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem);
|
||||
//
|
||||
// Update array items.
|
||||
// Shifts pre-existing items to the right.
|
||||
//
|
||||
// llgo:link (*JSON).InsertItemInArray C.cJSON_InsertItemInArray
|
||||
func (o *JSON) InsertItemInArray(which c.Int, newitem *JSON) Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
|
||||
//
|
||||
// llgo:link (*JSON).ReplaceItemViaPointer C.cJSON_ReplaceItemViaPointer
|
||||
func (o *JSON) ReplaceItemViaPointer(item *JSON, replacement *JSON) Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
|
||||
//
|
||||
// llgo:link (*JSON).ReplaceItemInArray C.cJSON_ReplaceItemInArray
|
||||
func (o *JSON) ReplaceItemInArray(which c.Int, newitem *JSON) Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
|
||||
//
|
||||
// llgo:link (*JSON).ReplaceItemInObject C.cJSON_ReplaceItemInObject
|
||||
func (o *JSON) ReplaceItemInObject(s *c.Char, newitem *JSON) Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
|
||||
//
|
||||
// llgo:link (*JSON).ReplaceItemInObjectCaseSensitive C.cJSON_ReplaceItemInObjectCaseSensitive
|
||||
func (o *JSON) ReplaceItemInObjectCaseSensitive(s *c.Char, newitem *JSON) Bool {
|
||||
return Bool(0)
|
||||
}
|
||||
|
||||
// CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_Bool recurse);
|
||||
//
|
||||
// Duplicate a cJSON item
|
||||
//
|
||||
// Duplicate will create a new, identical cJSON item to the one you pass,
|
||||
// in new memory that will need to be released. With recurse!=0,
|
||||
// it will duplicate any children connected to the item.
|
||||
// The item->next and ->prev pointers are always zero on return from Duplicate.
|
||||
//
|
||||
// llgo:link (*JSON).Duplicate C.cJSON_Duplicate
|
||||
func (o *JSON) Duplicate(recurse Bool) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(cJSON_Bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_Bool case_sensitive);
|
||||
//
|
||||
// Recursively compare two cJSON items for equality. If either a or b is NULL or invalid,
|
||||
// they will be considered unequal. case_sensitive determines if object keys are treated
|
||||
// case sensitive (1) or case insensitive (0)
|
||||
//
|
||||
// llgo:link (*JSON).Compare C.cJSON_Compare
|
||||
func (o *JSON) Compare(b *JSON, case_sensitive Bool) Bool { return Bool(0) }
|
||||
|
||||
// CJSON_PUBLIC(void) cJSON_Minify(char *json);
|
||||
//
|
||||
// Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
|
||||
// The input pointer json cannot point to a read-only address area, such as a string constant,
|
||||
// but should point to a readable and writable address area.
|
||||
//
|
||||
//go:linkname Minify C.cJSON_Minify
|
||||
func Minify()
|
||||
|
||||
// CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
|
||||
//
|
||||
// Helper functions for creating and adding items to an object at the same time.
|
||||
// They return the added item or NULL on failure.
|
||||
//
|
||||
// llgo:link (*JSON).AddNullToObject C.cJSON_AddNullToObject
|
||||
func (o *JSON) AddNullToObject(name *c.Char) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
|
||||
//
|
||||
// llgo:link (*JSON).AddTrueToObject C.cJSON_AddTrueToObject
|
||||
func (o *JSON) AddTrueToObject(name *c.Char) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
|
||||
//
|
||||
// llgo:link (*JSON).AddFalseToObject C.cJSON_AddFalseToObject
|
||||
func (o *JSON) AddFalseToObject(name *c.Char) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_Bool boolean);
|
||||
//
|
||||
// llgo:link (*JSON).AddBoolToObject C.cJSON_AddBoolToObject
|
||||
func (o *JSON) AddBoolToObject(name *c.Char, b Bool) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
|
||||
//
|
||||
// llgo:link (*JSON).AddNumberToObject C.cJSON_AddNumberToObject
|
||||
func (o *JSON) AddNumberToObject(name *c.Char, num c.Double) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
|
||||
//
|
||||
// llgo:link (*JSON).AddStringToObject C.cJSON_AddStringToObject
|
||||
func (o *JSON) AddStringToObject(name *c.Char, s *c.Char) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
|
||||
//
|
||||
// llgo:link (*JSON).AddRawToObject C.cJSON_AddRawToObject
|
||||
func (o *JSON) AddRawToObject(name *c.Char, raw *c.Char) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
|
||||
//
|
||||
// llgo:link (*JSON).AddObjectToObject C.cJSON_AddObjectToObject
|
||||
func (o *JSON) AddObjectToObject(name *c.Char) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
|
||||
//
|
||||
// llgo:link (*JSON).AddArrayToObject C.cJSON_AddArrayToObject
|
||||
func (o *JSON) AddArrayToObject(name *c.Char) *JSON { return nil }
|
||||
|
||||
// CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
|
||||
//
|
||||
// helper for the cJSON_SetNumberValue macro
|
||||
//
|
||||
// llgo:link (*JSON).SetNumberHelper C.cJSON_SetNumberHelper
|
||||
func (o *JSON) SetNumberHelper(number c.Double) c.Double { return 0 }
|
||||
|
||||
// CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
|
||||
//
|
||||
// Change the valuestring of a cJSON_String object, only takes effect when type of
|
||||
// object is cJSON_String
|
||||
//
|
||||
// llgo:link (*JSON).SetValuestring C.cJSON_SetValuestring
|
||||
func (o *JSON) SetValuestring(v *c.Char) *c.Char { return nil }
|
||||
|
||||
// CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
|
||||
//
|
||||
// malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks
|
||||
//
|
||||
//go:linkname Malloc C.cJSON_malloc
|
||||
func Malloc(size uintptr)
|
||||
|
||||
// CJSON_PUBLIC(void) cJSON_free(void *object);
|
||||
//
|
||||
//go:linkname Free C.cJSON_free
|
||||
func Free(ptr unsafe.Pointer)
|
||||
|
||||
Binary file not shown.
163
c/clang/_demo/symboldump/symboldump.go
Normal file
163
c/clang/_demo/symboldump/symboldump.go
Normal file
@@ -0,0 +1,163 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/clang"
|
||||
)
|
||||
|
||||
type Context struct {
|
||||
namespaceName string
|
||||
className string
|
||||
unit *clang.TranslationUnit
|
||||
}
|
||||
|
||||
func newContext() *Context {
|
||||
return &Context{}
|
||||
}
|
||||
|
||||
func (c *Context) setNamespaceName(name string) {
|
||||
c.namespaceName = name
|
||||
}
|
||||
|
||||
func (c *Context) setClassName(name string) {
|
||||
c.className = name
|
||||
}
|
||||
|
||||
func (c *Context) setUnit(unit *clang.TranslationUnit) {
|
||||
c.unit = unit
|
||||
}
|
||||
|
||||
var context = newContext()
|
||||
|
||||
func printCursorLocation(cursor clang.Cursor) {
|
||||
loc := cursor.Location()
|
||||
var file clang.File
|
||||
var line, column c.Uint
|
||||
|
||||
loc.SpellingLocation(&file, &line, &column, nil)
|
||||
filename := file.FileName()
|
||||
defer filename.Dispose()
|
||||
|
||||
c.Printf(c.Str("%s:%d:%d\n"), filename.CStr(), line, column)
|
||||
}
|
||||
|
||||
func printMarcoInfo(cursor clang.Cursor) {
|
||||
printCursorLocation(cursor)
|
||||
name := cursor.String()
|
||||
c.Printf(c.Str("Marco Name: %s\n"), name.CStr())
|
||||
ran := cursor.Extent()
|
||||
var numTokens c.Uint
|
||||
var tokens *clang.Token
|
||||
context.unit.Tokenize(ran, &tokens, &numTokens)
|
||||
c.Printf(c.Str("Content: "))
|
||||
|
||||
tokensSlice := unsafe.Slice(tokens, int(numTokens))
|
||||
for _, tok := range tokensSlice {
|
||||
tokStr := context.unit.Token(tok)
|
||||
c.Printf(c.Str("%s "), tokStr.CStr())
|
||||
tokStr.Dispose()
|
||||
}
|
||||
|
||||
c.Printf(c.Str("\n"))
|
||||
println("--------------------------------")
|
||||
}
|
||||
func printFuncInfo(cursor clang.Cursor) {
|
||||
printCursorLocation(cursor)
|
||||
|
||||
cursorStr := cursor.String()
|
||||
symbol := cursor.Mangling()
|
||||
defer symbol.Dispose()
|
||||
defer cursorStr.Dispose()
|
||||
|
||||
if context.namespaceName != "" && context.className != "" {
|
||||
fmt.Printf("%s:%s:", context.namespaceName, context.className)
|
||||
} else if context.namespaceName != "" {
|
||||
fmt.Printf("%s:", context.namespaceName)
|
||||
}
|
||||
c.Printf(c.Str("%s\n"), cursorStr.CStr())
|
||||
|
||||
if cursor.Kind == clang.CursorCXXMethod || cursor.Kind == clang.CursorFunctionDecl {
|
||||
c.Printf(c.Str("symbol:%s\n"), symbol.CStr())
|
||||
|
||||
typeStr := cursor.ResultType().String()
|
||||
defer typeStr.Dispose()
|
||||
c.Printf(c.Str("Return Type: %s\n"), typeStr.CStr())
|
||||
c.Printf(c.Str("Parameters(%d): ( "), cursor.NumArguments())
|
||||
|
||||
for i := 0; i < int(cursor.NumArguments()); i++ {
|
||||
argCurSor := cursor.Argument(c.Uint(i))
|
||||
argType := argCurSor.Type().String()
|
||||
argName := argCurSor.String()
|
||||
c.Printf(c.Str("%s %s"), argType.CStr(), argName.CStr())
|
||||
if i < int(cursor.NumArguments())-1 {
|
||||
c.Printf(c.Str(", "))
|
||||
}
|
||||
|
||||
argType.Dispose()
|
||||
argName.Dispose()
|
||||
}
|
||||
|
||||
c.Printf(c.Str(" )\n"))
|
||||
println("--------------------------------")
|
||||
}
|
||||
}
|
||||
|
||||
func visit(cursor, parent clang.Cursor, clientData c.Pointer) clang.ChildVisitResult {
|
||||
if cursor.Kind == clang.CursorMacroDefinition {
|
||||
printMarcoInfo(cursor)
|
||||
} else if cursor.Kind == clang.CursorNamespace {
|
||||
nameStr := cursor.String()
|
||||
context.setNamespaceName(c.GoString(nameStr.CStr()))
|
||||
clang.VisitChildren(cursor, visit, nil)
|
||||
context.setNamespaceName("")
|
||||
} else if cursor.Kind == clang.CursorClassDecl {
|
||||
nameStr := cursor.String()
|
||||
context.setClassName(c.GoString(nameStr.CStr()))
|
||||
clang.VisitChildren(cursor, visit, nil)
|
||||
context.setClassName("")
|
||||
} else if cursor.Kind == clang.CursorCXXMethod || cursor.Kind == clang.CursorFunctionDecl {
|
||||
printFuncInfo(cursor)
|
||||
}
|
||||
|
||||
return clang.ChildVisit_Continue
|
||||
}
|
||||
|
||||
func parse(filename *c.Char) {
|
||||
index := clang.CreateIndex(0, 0)
|
||||
args := make([]*c.Char, 3)
|
||||
args[0] = c.Str("-x")
|
||||
args[1] = c.Str("c++")
|
||||
args[2] = c.Str("-std=c++11")
|
||||
unit := index.ParseTranslationUnit(
|
||||
filename,
|
||||
unsafe.SliceData(args), 3,
|
||||
nil, 0,
|
||||
clang.DetailedPreprocessingRecord,
|
||||
)
|
||||
|
||||
if unit == nil {
|
||||
println("Unable to parse translation unit. Quitting.")
|
||||
c.Exit(1)
|
||||
}
|
||||
|
||||
context.setUnit(unit)
|
||||
cursor := unit.Cursor()
|
||||
|
||||
clang.VisitChildren(cursor, visit, nil)
|
||||
unit.Dispose()
|
||||
index.Dispose()
|
||||
}
|
||||
|
||||
func main() {
|
||||
if c.Argc != 2 {
|
||||
fmt.Fprintln(os.Stderr, "Usage: <C++ header file>\n")
|
||||
return
|
||||
} else {
|
||||
sourceFile := *c.Advance(c.Argv, 1)
|
||||
parse(sourceFile)
|
||||
}
|
||||
}
|
||||
190
c/clang/_wrap/cursor.cpp
Normal file
190
c/clang/_wrap/cursor.cpp
Normal file
@@ -0,0 +1,190 @@
|
||||
#include <clang-c/Index.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef enum CXChildVisitResult (*wrap_CXCursorVisitor)(CXCursor *cursor, CXCursor *parent, CXClientData client_data);
|
||||
|
||||
typedef struct {
|
||||
CXClientData data;
|
||||
wrap_CXCursorVisitor visitor;
|
||||
} wrap_data;
|
||||
|
||||
CXChildVisitResult wrap_visitor(CXCursor cursor, CXCursor parent, CXClientData data) {
|
||||
wrap_data *d = (wrap_data *)(data);
|
||||
return d->visitor(&cursor, &parent, d->data);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
void wrap_clang_getTranslationUnitCursor(CXTranslationUnit uint, CXCursor *cur) {
|
||||
*cur = clang_getTranslationUnitCursor(uint);
|
||||
}
|
||||
|
||||
unsigned wrap_clang_equalCursors(CXCursor *cursor1, CXCursor *cursor2) {
|
||||
return clang_equalCursors(*cursor1, *cursor2);
|
||||
}
|
||||
|
||||
int wrap_clang_Cursor_isNull(CXCursor *cursor) { return clang_Cursor_isNull(*cursor); }
|
||||
|
||||
void wrap_clang_getCursorSemanticParent(CXCursor *C, CXCursor *parent) { *parent = clang_getCursorSemanticParent(*C); }
|
||||
|
||||
void wrap_clang_getCursorLexicalParent(CXCursor *C, CXCursor *parent) { *parent = clang_getCursorLexicalParent(*C); }
|
||||
|
||||
void wrap_clang_getOverriddenCursors(CXCursor *cursor, CXCursor **overridden, unsigned *num_overridden) {
|
||||
clang_getOverriddenCursors(*cursor, overridden, num_overridden);
|
||||
}
|
||||
|
||||
void wrap_clang_getCursorLocation(CXCursor *cur, CXSourceLocation *loc) { *loc = clang_getCursorLocation(*cur); }
|
||||
|
||||
void wrap_clang_getCursorExtent(CXCursor *cur, CXSourceRange *range) { *range = clang_getCursorExtent(*cur); }
|
||||
|
||||
void wrap_clang_getCursorType(CXCursor *cur, CXType *typ) { *typ = clang_getCursorType(*cur); }
|
||||
|
||||
CXString wrap_clang_getTypeSpelling(CXType *typ) { return clang_getTypeSpelling(*typ); }
|
||||
|
||||
void wrap_clang_getTypedefDeclUnderlyingType(CXCursor *cur, CXType *typ) {
|
||||
*typ = clang_getTypedefDeclUnderlyingType(*cur);
|
||||
}
|
||||
|
||||
long long wrap_clang_getEnumConstantDeclValue(CXCursor *cur) { return clang_getEnumConstantDeclValue(*cur); }
|
||||
|
||||
int wrap_clang_Cursor_getNumArguments(CXCursor *cur) { return clang_Cursor_getNumArguments(*cur); }
|
||||
|
||||
void wrap_clang_Cursor_getArgument(CXCursor *C, unsigned i, CXCursor *argCur) {
|
||||
*argCur = clang_Cursor_getArgument(*C, i);
|
||||
}
|
||||
|
||||
void wrap_clang_getCanonicalType(CXType *typ, CXType *canonicalType) { *canonicalType = clang_getCanonicalType(*typ); }
|
||||
|
||||
unsigned wrap_clang_isConstQualifiedType(CXType *typ) { return clang_isConstQualifiedType(*typ); }
|
||||
|
||||
unsigned wrap_clang_Cursor_isMacroFunctionLike(CXCursor *cur) { return clang_Cursor_isMacroFunctionLike(*cur); }
|
||||
|
||||
unsigned wrap_clang_Cursor_isMacroBuiltin(CXCursor *cur) { return clang_Cursor_isMacroBuiltin(*cur); }
|
||||
|
||||
unsigned wrap_clang_Cursor_isFunctionInlined(CXCursor *cur) { return clang_Cursor_isFunctionInlined(*cur); }
|
||||
|
||||
unsigned wrap_clang_isVolatileQualifiedType(CXType *T) { return clang_isVolatileQualifiedType(*T); }
|
||||
|
||||
unsigned wrap_clang_isRestrictQualifiedType(CXType *T) { return clang_isRestrictQualifiedType(*T); }
|
||||
|
||||
void wrap_clang_getPointeeType(CXType *pointerTyp, CXType *pointeeTyp) {
|
||||
*pointeeTyp = clang_getPointeeType(*pointerTyp);
|
||||
}
|
||||
|
||||
void wrap_clang_getNonReferenceType(CXType *typ, CXType *nonRefTyp) { *nonRefTyp = clang_getNonReferenceType(*typ); }
|
||||
|
||||
void wrap_clang_getTypeDeclaration(CXType *typ, CXCursor *cur) { *cur = clang_getTypeDeclaration(*typ); }
|
||||
|
||||
void wrap_clang_getResultType(CXType *typ, CXType *resultTyp) { *resultTyp = clang_getResultType(*typ); }
|
||||
|
||||
int wrap_clang_getNumArgTypes(CXType *typ) { return clang_getNumArgTypes(*typ); }
|
||||
|
||||
void wrap_clang_getArgType(CXType *typ, unsigned i, CXType *argTyp) { *argTyp = clang_getArgType(*typ, i); }
|
||||
|
||||
unsigned wrap_clang_isFunctionTypeVariadic(CXType *typ) { return clang_isFunctionTypeVariadic(*typ); }
|
||||
|
||||
void wrap_clang_getCursorResultType(CXCursor *cur, CXType *typ) { *typ = clang_getCursorResultType(*cur); }
|
||||
|
||||
void wrap_clang_getElementType(CXType *Typ, CXType *elemTyp) { *elemTyp = clang_getElementType(*Typ); }
|
||||
|
||||
void wrap_clang_getArrayElementType(CXType *arrayTyp, CXType *elemTyp) {
|
||||
*elemTyp = clang_getArrayElementType(*arrayTyp);
|
||||
}
|
||||
|
||||
long long wrap_clang_getArraySize(CXType *arrayTyp) { return clang_getArraySize(*arrayTyp); }
|
||||
|
||||
void wrap_clang_Type_getNamedType(CXType *typ, CXType *namedTyp) { *namedTyp = clang_Type_getNamedType(*typ); }
|
||||
|
||||
unsigned wrap_clang_Cursor_isAnonymous(CXCursor *cursor) { return clang_Cursor_isAnonymous(*cursor); }
|
||||
|
||||
unsigned wrap_clang_Cursor_isAnonymousRecordDecl(CXCursor *cursor) {
|
||||
return clang_Cursor_isAnonymousRecordDecl(*cursor);
|
||||
}
|
||||
|
||||
enum CX_CXXAccessSpecifier wrap_clang_getCXXAccessSpecifier(CXCursor *cursor) {
|
||||
return clang_getCXXAccessSpecifier(*cursor);
|
||||
}
|
||||
|
||||
enum CX_StorageClass wrap_clang_Cursor_getStorageClass(CXCursor *cursor) {
|
||||
return clang_Cursor_getStorageClass(*cursor);
|
||||
}
|
||||
|
||||
CXString wrap_clang_getCursorUSR(CXCursor *cur) { return clang_getCursorUSR(*cur); }
|
||||
|
||||
CXString wrap_clang_getCursorSpelling(CXCursor *cur) { return clang_getCursorSpelling(*cur); }
|
||||
|
||||
unsigned wrap_clang_Cursor_isVariadic(CXCursor *cur) { return clang_Cursor_isVariadic(*cur); }
|
||||
|
||||
CXString wrap_clang_Cursor_getRawCommentText(CXCursor *cursor) { return clang_Cursor_getRawCommentText(*cursor); }
|
||||
|
||||
CXString wrap_clang_Cursor_getMangling(CXCursor *cur) { return clang_Cursor_getMangling(*cur); }
|
||||
|
||||
unsigned wrap_clang_CXXConstructor_isConvertingConstructor(CXCursor *cursor) {
|
||||
return clang_CXXConstructor_isConvertingConstructor(*cursor);
|
||||
}
|
||||
|
||||
unsigned wrap_clang_CXXConstructor_isCopyConstructor(CXCursor *cursor) {
|
||||
return clang_CXXConstructor_isCopyConstructor(*cursor);
|
||||
}
|
||||
|
||||
unsigned wrap_clang_CXXConstructor_isDefaultConstructor(CXCursor *cursor) {
|
||||
return clang_CXXConstructor_isDefaultConstructor(*cursor);
|
||||
}
|
||||
|
||||
unsigned wrap_clang_CXXConstructor_isMoveConstructor(CXCursor *cursor) {
|
||||
return clang_CXXConstructor_isMoveConstructor(*cursor);
|
||||
}
|
||||
|
||||
unsigned wrap_clang_CXXField_isMutable(CXCursor *cursor) { return clang_CXXField_isMutable(*cursor); }
|
||||
|
||||
unsigned wrap_clang_CXXMethod_isDefaulted(CXCursor *cursor) { return clang_CXXMethod_isDefaulted(*cursor); }
|
||||
|
||||
unsigned wrap_clang_CXXMethod_isDeleted(CXCursor *cursor) { return clang_CXXMethod_isDeleted(*cursor); }
|
||||
|
||||
unsigned wrap_clang_CXXMethod_isPureVirtual(CXCursor *cursor) { return clang_CXXMethod_isPureVirtual(*cursor); }
|
||||
|
||||
unsigned wrap_clang_CXXMethod_isStatic(CXCursor *cursor) { return clang_CXXMethod_isStatic(*cursor); }
|
||||
|
||||
unsigned wrap_clang_CXXMethod_isVirtual(CXCursor *cursor) { return clang_CXXMethod_isVirtual(*cursor); }
|
||||
|
||||
unsigned wrap_clang_CXXMethod_isCopyAssignmentOperator(CXCursor *cursor) {
|
||||
return clang_CXXMethod_isCopyAssignmentOperator(*cursor);
|
||||
}
|
||||
|
||||
unsigned wrap_clang_CXXMethod_isMoveAssignmentOperator(CXCursor *cursor) {
|
||||
return clang_CXXMethod_isMoveAssignmentOperator(*cursor);
|
||||
}
|
||||
|
||||
unsigned wrap_clang_CXXMethod_isExplicit(CXCursor *cursor) { return clang_CXXMethod_isExplicit(*cursor); }
|
||||
|
||||
unsigned wrap_clang_CXXRecord_isAbstract(CXCursor *cursor) { return clang_CXXRecord_isAbstract(*cursor); }
|
||||
|
||||
unsigned wrap_clang_EnumDecl_isScoped(CXCursor *cursor) { return clang_EnumDecl_isScoped(*cursor); }
|
||||
|
||||
unsigned wrap_clang_CXXMethod_isConst(CXCursor *cursor) { return clang_CXXMethod_isConst(*cursor); }
|
||||
|
||||
CXTokenKind wrap_clang_getTokenKind(CXToken *token) { return clang_getTokenKind(*token); }
|
||||
|
||||
CXString wrap_clang_getTokenSpelling(CXTranslationUnit unit, CXToken *token) {
|
||||
return clang_getTokenSpelling(unit, *token);
|
||||
}
|
||||
|
||||
void wrap_clang_tokenize(CXTranslationUnit unit, CXSourceRange *Range, CXToken **Tokens, unsigned *NumTokens) {
|
||||
clang_tokenize(unit, *Range, Tokens, NumTokens);
|
||||
}
|
||||
|
||||
unsigned wrap_clang_visitChildren(CXCursor *parent, wrap_CXCursorVisitor visitor, CXClientData client_data) {
|
||||
wrap_data data = {client_data, visitor};
|
||||
return clang_visitChildren(*parent, wrap_visitor, CXClientData(&data));
|
||||
}
|
||||
|
||||
void wrap_clang_getSpellingLocation(CXSourceLocation *loc, CXFile *file, unsigned *line, unsigned *column,
|
||||
unsigned *offset) {
|
||||
clang_getSpellingLocation(*loc, file, line, column, offset);
|
||||
}
|
||||
|
||||
void wrap_clang_getRangeStart(CXSourceRange *range, CXSourceLocation *loc) { *loc = clang_getRangeStart(*range); }
|
||||
|
||||
void wrap_clang_getRangeEnd(CXSourceRange *range, CXSourceLocation *loc) { *loc = clang_getRangeEnd(*range); }
|
||||
|
||||
} // extern "C"
|
||||
7
c/clang/_wrap/llgo_check.cpp
Normal file
7
c/clang/_wrap/llgo_check.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <clang-c/Index.h>
|
||||
|
||||
int main() {
|
||||
printf("sizeof(clang.Cursor) = %lu\n", sizeof(CXCursor));
|
||||
return 0;
|
||||
}
|
||||
16
c/clang/_wrap/llgo_check.go
Normal file
16
c/clang/_wrap/llgo_check.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/clang"
|
||||
)
|
||||
|
||||
const (
|
||||
LLGoCFlags = "-I$(llvm-config --includedir)"
|
||||
)
|
||||
|
||||
func main() {
|
||||
c.Printf(c.Str("sizeof(clang.Cursor) = %lu\n"), unsafe.Sizeof(clang.Cursor{}))
|
||||
}
|
||||
59
c/clang/basic.go
Normal file
59
c/clang/basic.go
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package clang
|
||||
|
||||
import (
|
||||
_ "unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
/**
|
||||
* A character string.
|
||||
*
|
||||
* The \c CXString type is used to return strings from the interface when
|
||||
* the ownership of that string might differ from one call to the next.
|
||||
* Use \c clang_getCString() to retrieve the string data and, once finished
|
||||
* with the string data, call \c clang_disposeString() to free the string.
|
||||
*/
|
||||
type String struct {
|
||||
Data c.Pointer
|
||||
PrivateFlags c.Uint
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the character data associated with the given string.
|
||||
*/
|
||||
// llgo:link String.CStr C.clang_getCString
|
||||
func (String) CStr() *c.Char { return nil }
|
||||
|
||||
/**
|
||||
* Free the given string.
|
||||
*/
|
||||
// llgo:link String.Dispose C.clang_disposeString
|
||||
func (String) Dispose() {}
|
||||
|
||||
type StringSet struct {
|
||||
Strings *String
|
||||
Count c.Uint
|
||||
}
|
||||
|
||||
/**
|
||||
* Free the given string set.
|
||||
*/
|
||||
// llgo:link (*StringSet).Dispose C.clang_disposeStringSet
|
||||
func (*StringSet) Dispose() {}
|
||||
2683
c/clang/clang.go
Normal file
2683
c/clang/clang.go
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user