forked from BigfootDev/flatbuffers
Compare commits
991 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81edeb17d9 | ||
|
|
5982eb6495 | ||
|
|
38df29380a | ||
|
|
1f438bd40f | ||
|
|
392165432a | ||
|
|
e6bbb3d22e | ||
|
|
a6979fe14a | ||
|
|
bab10754d9 | ||
|
|
ac7ef1176a | ||
|
|
d6444fb7fc | ||
|
|
e223d69b36 | ||
|
|
05cc7a2eff | ||
|
|
8a12183c3b | ||
|
|
21b706b62d | ||
|
|
c5f151ab33 | ||
|
|
3860f1cf7f | ||
|
|
4e582b0c1d | ||
|
|
8396e00dd8 | ||
|
|
48babd417d | ||
|
|
22770f7e85 | ||
|
|
21b033227e | ||
|
|
93f587a6d3 | ||
|
|
8afb68f074 | ||
|
|
2e07f269b9 | ||
|
|
10c994155c | ||
|
|
fc9909c30a | ||
|
|
e35817577c | ||
|
|
9e3fe5d3f6 | ||
|
|
dc9217347e | ||
|
|
a7fed2ce67 | ||
|
|
de3b97355d | ||
|
|
8aa7084f01 | ||
|
|
0f469cad54 | ||
|
|
72e51c61f7 | ||
|
|
31590a8a3b | ||
|
|
24c2432d99 | ||
|
|
292870612c | ||
|
|
57659d9f38 | ||
|
|
2b8e4d3af0 | ||
|
|
08b6372a36 | ||
|
|
9c383559e0 | ||
|
|
c13c3bf956 | ||
|
|
47eeb8f4e9 | ||
|
|
e7c6874192 | ||
|
|
8d2c333b36 | ||
|
|
abc9bfebff | ||
|
|
94d6b8086b | ||
|
|
fa709636b4 | ||
|
|
60463e25a8 | ||
|
|
b8e3d215b8 | ||
|
|
d71c0ab4ac | ||
|
|
fcf75449b8 | ||
|
|
c21bda1649 | ||
|
|
03fffb25e2 | ||
|
|
1a7495a6dd | ||
|
|
3c1bb67ae1 | ||
|
|
5b9de8b6c0 | ||
|
|
ea0a73d168 | ||
|
|
4623cfa4bc | ||
|
|
9c2c56dc6a | ||
|
|
429c28c783 | ||
|
|
e5a9ff757f | ||
|
|
e53732b9b9 | ||
|
|
b84b676c89 | ||
|
|
3211f857d1 | ||
|
|
95ff1f1d80 | ||
|
|
af8997b567 | ||
|
|
0d67abde45 | ||
|
|
d74e2945f7 | ||
|
|
8914d06ab7 | ||
|
|
522f2379a6 | ||
|
|
7cb0bcb212 | ||
|
|
b1e7868db6 | ||
|
|
68e3c839c3 | ||
|
|
0723245085 | ||
|
|
9d64b9c0c0 | ||
|
|
d01f20f2fb | ||
|
|
7e163021e5 | ||
|
|
57fdd4f995 | ||
|
|
8cb53ccc95 | ||
|
|
fb55e0c9de | ||
|
|
d9fde67eb5 | ||
|
|
f74fda299d | ||
|
|
15802fa26c | ||
|
|
a86afae939 | ||
|
|
60910fb7f5 | ||
|
|
7bfaabc358 | ||
|
|
e1407e4341 | ||
|
|
c9a301e601 | ||
|
|
19b2300f93 | ||
|
|
e60c0ab9e2 | ||
|
|
541dd1a8f5 | ||
|
|
7711e84919 | ||
|
|
89430a14d6 | ||
|
|
cfce38ec99 | ||
|
|
5469bc9ef1 | ||
|
|
b39f79e5e9 | ||
|
|
dc623919bd | ||
|
|
a1e125af11 | ||
|
|
0b60686e3d | ||
|
|
17ceaae16e | ||
|
|
a5343d6116 | ||
|
|
4786322b90 | ||
|
|
646a8bc96a | ||
|
|
0e3471d6a7 | ||
|
|
b07589a0f9 | ||
|
|
2062c33cd4 | ||
|
|
adb7add87e | ||
|
|
29f99937c4 | ||
|
|
597e76a268 | ||
|
|
a577050817 | ||
|
|
31ab0bf6c8 | ||
|
|
e4775aa3fe | ||
|
|
97d26ab4ae | ||
|
|
7dd38fa23a | ||
|
|
7350c3668f | ||
|
|
49d2db93a7 | ||
|
|
807b43c0d7 | ||
|
|
4b823b1b98 | ||
|
|
4c47f4c11e | ||
|
|
2b107e20c5 | ||
|
|
84f4b83d3e | ||
|
|
185e41fac4 | ||
|
|
8b02fe6178 | ||
|
|
6e0dad8c5f | ||
|
|
e3e355d498 | ||
|
|
8e901ce17c | ||
|
|
7808ae5c88 | ||
|
|
20068cfa05 | ||
|
|
afd07bdec5 | ||
|
|
2951d5383a | ||
|
|
ba563de877 | ||
|
|
46a2f3f2c2 | ||
|
|
7675121eab | ||
|
|
ea2b5148e5 | ||
|
|
20548ff3b6 | ||
|
|
7ea8db05d8 | ||
|
|
c7b6b66ccb | ||
|
|
ac8b124496 | ||
|
|
88b033b964 | ||
|
|
e68355cb22 | ||
|
|
e3ee24830e | ||
|
|
2a8f4568e0 | ||
|
|
cbf0850828 | ||
|
|
7150dfb5c4 | ||
|
|
fa87eccd1a | ||
|
|
a62f45fed8 | ||
|
|
599847236c | ||
|
|
4173b84d4b | ||
|
|
5fe90a9160 | ||
|
|
78a3d59a65 | ||
|
|
5ed02dc04a | ||
|
|
592dc50037 | ||
|
|
dd77af75b7 | ||
|
|
051604aeb5 | ||
|
|
4b09586652 | ||
|
|
4c0eecd25a | ||
|
|
de25052c72 | ||
|
|
95053e6a47 | ||
|
|
27325e002a | ||
|
|
1872409707 | ||
|
|
c427e1a65d | ||
|
|
caf3b494db | ||
|
|
0e047869da | ||
|
|
881eaab706 | ||
|
|
48eccb83db | ||
|
|
3c0511fa6a | ||
|
|
82396fa0fe | ||
|
|
a6b337f803 | ||
|
|
35230bd70c | ||
|
|
deb3d93454 | ||
|
|
b87d04af8c | ||
|
|
1e6c851dba | ||
|
|
6164edf558 | ||
|
|
ef1030ff0b | ||
|
|
53c8c2ef16 | ||
|
|
f83525fe67 | ||
|
|
b2cce474ba | ||
|
|
067bfdbde9 | ||
|
|
5218e29aa4 | ||
|
|
957e09d684 | ||
|
|
af4b99a1d7 | ||
|
|
b85b90e346 | ||
|
|
ae3821233c | ||
|
|
ff9cba2bff | ||
|
|
1759061908 | ||
|
|
34af7fff70 | ||
|
|
518bf42df8 | ||
|
|
575d616e60 | ||
|
|
f32a7dcbd2 | ||
|
|
860d645349 | ||
|
|
06a53df0d3 | ||
|
|
c526cb640b | ||
|
|
ca73ff34b7 | ||
|
|
2e49b3ba60 | ||
|
|
f830c47d68 | ||
|
|
501810f4d1 | ||
|
|
1047d7ec13 | ||
|
|
07c2eb5fe7 | ||
|
|
c7b9dc83f5 | ||
|
|
4c9079e31b | ||
|
|
64e5252b4e | ||
|
|
00c30807ff | ||
|
|
c15fe421ba | ||
|
|
6b251aa1cf | ||
|
|
6fe8afb3b6 | ||
|
|
00eec2445b | ||
|
|
b8db3a9a6a | ||
|
|
75556437cc | ||
|
|
31beb0fb2f | ||
|
|
dfd92124aa | ||
|
|
a2916d37e7 | ||
|
|
5a95b7b6bc | ||
|
|
595ac94a6a | ||
|
|
5822c1c8dd | ||
|
|
609c72ca1a | ||
|
|
bd1b2d0baf | ||
|
|
1c514626e8 | ||
|
|
820a7f277f | ||
|
|
396c3f56df | ||
|
|
c49e81d6ec | ||
|
|
a285e7ef1a | ||
|
|
0312061985 | ||
|
|
9f94ceedbc | ||
|
|
bcd2b9d039 | ||
|
|
82fefbf252 | ||
|
|
65e49faf76 | ||
|
|
50be3cfe8c | ||
|
|
026c243dc5 | ||
|
|
a9257b6963 | ||
|
|
fceafd438d | ||
|
|
33a15d63cf | ||
|
|
ad6d6638f3 | ||
|
|
69ac6a712d | ||
|
|
4b69b27d43 | ||
|
|
9318c6c981 | ||
|
|
df287ee6a7 | ||
|
|
0d7bf7e8a7 | ||
|
|
e67310bf1c | ||
|
|
121c4c99ae | ||
|
|
27f5a0fdae | ||
|
|
3592b19150 | ||
|
|
733e432bfd | ||
|
|
5414e04b45 | ||
|
|
c9a286bf29 | ||
|
|
f9a70c79f1 | ||
|
|
1eb4bd3ca7 | ||
|
|
41e47e4951 | ||
|
|
4999936289 | ||
|
|
8e2852fa73 | ||
|
|
7e52f59f14 | ||
|
|
1ff248739e | ||
|
|
2cffba28b4 | ||
|
|
34f0728ea2 | ||
|
|
569e6cb461 | ||
|
|
086097ff94 | ||
|
|
2b0ce37b12 | ||
|
|
67bf1084c0 | ||
|
|
f82c4ac904 | ||
|
|
9a40ab2495 | ||
|
|
5c14ee7e8b | ||
|
|
26e77dce41 | ||
|
|
6913c34e62 | ||
|
|
0222cd4a63 | ||
|
|
0042afa5e2 | ||
|
|
8852f10a84 | ||
|
|
a8df3c8f35 | ||
|
|
b8629d402e | ||
|
|
ccdab58c11 | ||
|
|
a96fe8f206 | ||
|
|
99fda81905 | ||
|
|
8694806f14 | ||
|
|
5a75ad407d | ||
|
|
2d86857bec | ||
|
|
0f90dc8290 | ||
|
|
c9125e6385 | ||
|
|
28ddfaeda7 | ||
|
|
7e59e0727c | ||
|
|
79d9e33ea3 | ||
|
|
bbb6b932fc | ||
|
|
46cc3d6432 | ||
|
|
fb3ccd36c0 | ||
|
|
492475a1b2 | ||
|
|
c75a0154eb | ||
|
|
a2cd1ea3b6 | ||
|
|
32e63af684 | ||
|
|
1f4a9038ce | ||
|
|
a9df44828d | ||
|
|
5f453ef738 | ||
|
|
49061f8c7c | ||
|
|
807adb73b2 | ||
|
|
2f59a0319b | ||
|
|
6a8898573c | ||
|
|
d7a70db6ac | ||
|
|
b127c57ff0 | ||
|
|
2436bd8175 | ||
|
|
69a53e495d | ||
|
|
c7a8102b12 | ||
|
|
2146bacd2e | ||
|
|
8db59321d9 | ||
|
|
42879f6ea6 | ||
|
|
7833affd7e | ||
|
|
c065e972db | ||
|
|
06b12d55ea | ||
|
|
baddf90599 | ||
|
|
8b35a6bc32 | ||
|
|
6cb4d671a8 | ||
|
|
fb9afbafc7 | ||
|
|
dafd2f1f29 | ||
|
|
6ede1ccc9e | ||
|
|
8755c35a18 | ||
|
|
75f05d6389 | ||
|
|
3b27f5396e | ||
|
|
58c8eb5847 | ||
|
|
0e034ecdba | ||
|
|
0f8b71180f | ||
|
|
a5a2da0161 | ||
|
|
28783927af | ||
|
|
a1378fbd16 | ||
|
|
dcacfc5b11 | ||
|
|
f9dabf511a | ||
|
|
5ba66f71c5 | ||
|
|
5adfac9fc3 | ||
|
|
c6fce30e9b | ||
|
|
ef30729a71 | ||
|
|
30ae5f189c | ||
|
|
299725fe2e | ||
|
|
a41fefa1a8 | ||
|
|
d89f611f6f | ||
|
|
150644d7f4 | ||
|
|
c696275eaf | ||
|
|
7106d86685 | ||
|
|
da6472013f | ||
|
|
e646392647 | ||
|
|
e040f4e975 | ||
|
|
f4a9c5325b | ||
|
|
8f2e1dbd88 | ||
|
|
595bf0007a | ||
|
|
0cfb7eb80b | ||
|
|
67eb95de92 | ||
|
|
b1f617fcb2 | ||
|
|
960cd4d635 | ||
|
|
6ff9e90e7e | ||
|
|
5b32e8f5c2 | ||
|
|
0bed8cd4a0 | ||
|
|
7cd216c51e | ||
|
|
129ef422e8 | ||
|
|
e5fc3b16d8 | ||
|
|
c0d16995a4 | ||
|
|
70c8292c29 | ||
|
|
d47cd10d77 | ||
|
|
66bd3d7400 | ||
|
|
0cc1edb3ad | ||
|
|
57375a9e1c | ||
|
|
0346535221 | ||
|
|
7d62dcc422 | ||
|
|
b3cd878dfe | ||
|
|
09486a9f97 | ||
|
|
dd79eed495 | ||
|
|
0e1305c8e2 | ||
|
|
88549130e1 | ||
|
|
6dfc59dfcc | ||
|
|
5ba80c24e0 | ||
|
|
da55ac3a27 | ||
|
|
c6f9e010bb | ||
|
|
94ff188a3e | ||
|
|
5a937f1ba1 | ||
|
|
e1c3690a2a | ||
|
|
b08abbbbf6 | ||
|
|
7d6d99c6be | ||
|
|
d3055a97e7 | ||
|
|
0dc5a75dc0 | ||
|
|
f175e60998 | ||
|
|
a632c3c004 | ||
|
|
11789e41b6 | ||
|
|
a9c0845504 | ||
|
|
526c92546f | ||
|
|
eb80ead90b | ||
|
|
386b6353ed | ||
|
|
d09696bbe6 | ||
|
|
a228e8c9b8 | ||
|
|
91a3172519 | ||
|
|
e0d4562782 | ||
|
|
49677b0b70 | ||
|
|
8e34ad5db7 | ||
|
|
eb64390080 | ||
|
|
46577d0d2f | ||
|
|
32029ac699 | ||
|
|
4354945727 | ||
|
|
755573bcda | ||
|
|
205285c35c | ||
|
|
f4e23bf91e | ||
|
|
1fdb5d263a | ||
|
|
c4211538bd | ||
|
|
bcb9ef1876 | ||
|
|
c5441dc199 | ||
|
|
7f417e3397 | ||
|
|
3c35a143ea | ||
|
|
56e2bc30b0 | ||
|
|
eb40a54672 | ||
|
|
15f16f149e | ||
|
|
053d39adaf | ||
|
|
6f71b76e6f | ||
|
|
4b7d8e0df9 | ||
|
|
0def91105f | ||
|
|
8176a204fc | ||
|
|
e8b2492cf1 | ||
|
|
5d4386b1bc | ||
|
|
a6a3989dd4 | ||
|
|
696f47f1f7 | ||
|
|
a3dfcf3326 | ||
|
|
d3e8cb60a1 | ||
|
|
0343396e49 | ||
|
|
f625ff3330 | ||
|
|
362dd663f8 | ||
|
|
5a8a395756 | ||
|
|
afafd206a3 | ||
|
|
48da238920 | ||
|
|
8836ddab41 | ||
|
|
23922e7eba | ||
|
|
f8fe811d5c | ||
|
|
0cc525b722 | ||
|
|
28861d1d7d | ||
|
|
204473cdb5 | ||
|
|
85088a196d | ||
|
|
6e214c3a49 | ||
|
|
96294e9f84 | ||
|
|
b7856f8e27 | ||
|
|
0100f6a577 | ||
|
|
e0a87e36d5 | ||
|
|
b67f1ad6d0 | ||
|
|
ae6753684e | ||
|
|
a352bdbc34 | ||
|
|
cb14043f82 | ||
|
|
d64dc6200a | ||
|
|
ea7cfcd591 | ||
|
|
067553156a | ||
|
|
b128b802d9 | ||
|
|
1d3afb90c5 | ||
|
|
fe5e4c71c5 | ||
|
|
17b9eed4e1 | ||
|
|
cbc8872b99 | ||
|
|
05743591e1 | ||
|
|
2bc2529245 | ||
|
|
18cadc79c1 | ||
|
|
426f3b8bf2 | ||
|
|
950a71ab89 | ||
|
|
86486a1735 | ||
|
|
c2f764c22b | ||
|
|
e97ff95970 | ||
|
|
33212657ae | ||
|
|
66e9d9823a | ||
|
|
9fc153a8f8 | ||
|
|
c2bf810638 | ||
|
|
0ce6957763 | ||
|
|
82c6712606 | ||
|
|
b5957975c5 | ||
|
|
85f71321fd | ||
|
|
3e6cd51b63 | ||
|
|
10b79d87c1 | ||
|
|
16a7df46f0 | ||
|
|
76f5e9816a | ||
|
|
368428cb94 | ||
|
|
72b56fd081 | ||
|
|
63b7b25289 | ||
|
|
13fc75cb6b | ||
|
|
e6e38a8d17 | ||
|
|
d9f2cc2d62 | ||
|
|
197ae6cc7e | ||
|
|
489d9735e9 | ||
|
|
3308444147 | ||
|
|
ef5ae488dd | ||
|
|
08efe60954 | ||
|
|
01a7bc3c58 | ||
|
|
67084b9921 | ||
|
|
ed11b08fc9 | ||
|
|
c1e7aee489 | ||
|
|
75143f836b | ||
|
|
fb4f6fb894 | ||
|
|
19d8942943 | ||
|
|
dbce69c63b | ||
|
|
aeba096403 | ||
|
|
966aae2144 | ||
|
|
e7dc252b0e | ||
|
|
4172c3f0bd | ||
|
|
417821fdd7 | ||
|
|
c192ab423b | ||
|
|
a397dd7e8c | ||
|
|
6eae49a79a | ||
|
|
f6af2087ee | ||
|
|
ab716ee41d | ||
|
|
d6d83c3a92 | ||
|
|
aa6848fbf6 | ||
|
|
6c8a8d054d | ||
|
|
63495b935a | ||
|
|
56ecc1f548 | ||
|
|
3fda20d7c7 | ||
|
|
fa3fa91936 | ||
|
|
52f2596e15 | ||
|
|
0916f1c87e | ||
|
|
0888e7cb4d | ||
|
|
876a64aae1 | ||
|
|
2803983c70 | ||
|
|
88dd92de40 | ||
|
|
477b1b5d13 | ||
|
|
1cb1c4baee | ||
|
|
50cdf92e1e | ||
|
|
9a7fb4d68a | ||
|
|
3cb27fa241 | ||
|
|
d3d7e2ef99 | ||
|
|
d4d355d883 | ||
|
|
0fde16e426 | ||
|
|
32a6744286 | ||
|
|
42ee479c31 | ||
|
|
df007dfde8 | ||
|
|
d44ce00af1 | ||
|
|
01834de25e | ||
|
|
6f9ea7c23c | ||
|
|
de9791e0a9 | ||
|
|
3e778aca4d | ||
|
|
01f4138618 | ||
|
|
b90cc35a10 | ||
|
|
79d6abb42e | ||
|
|
d1e4daa178 | ||
|
|
4a34cd70dc | ||
|
|
6a9cd4411f | ||
|
|
f7a75173f1 | ||
|
|
a56f9ec50e | ||
|
|
4c71f87619 | ||
|
|
6af83a7d05 | ||
|
|
535ead8d8c | ||
|
|
85aee1f5c3 | ||
|
|
f3a3f45159 | ||
|
|
02d7859f8b | ||
|
|
5785784c8a | ||
|
|
0fb5519585 | ||
|
|
f838017860 | ||
|
|
08ebd202e2 | ||
|
|
a6f4194489 | ||
|
|
7fb785fd89 | ||
|
|
ca71fdfb9a | ||
|
|
a105c26eca | ||
|
|
5b7a02d037 | ||
|
|
f5121615d9 | ||
|
|
34c821f4ad | ||
|
|
802a3a056a | ||
|
|
ee848a02e1 | ||
|
|
ef76b5ece4 | ||
|
|
1703662285 | ||
|
|
991b39edbe | ||
|
|
81799203f1 | ||
|
|
62e4d2e5b2 | ||
|
|
40758674b1 | ||
|
|
4e75867bd2 | ||
|
|
b17d59b18c | ||
|
|
b23493a7d2 | ||
|
|
b50b6be60a | ||
|
|
7bf83f5ea0 | ||
|
|
ca6381bcc8 | ||
|
|
3b8644d32c | ||
|
|
641fbe4658 | ||
|
|
5638a6a900 | ||
|
|
c2668fc0e2 | ||
|
|
b5802b57f2 | ||
|
|
06f2a3dce9 | ||
|
|
75af533e95 | ||
|
|
c95cf661af | ||
|
|
920f3827a0 | ||
|
|
81724e5b20 | ||
|
|
4d6a7aa8b7 | ||
|
|
e61b00359b | ||
|
|
74b5195089 | ||
|
|
07d9485146 | ||
|
|
82da3da3f6 | ||
|
|
a809a2d3f7 | ||
|
|
af9ceabeef | ||
|
|
3b2eb77595 | ||
|
|
6420fa5c88 | ||
|
|
01589630ba | ||
|
|
e0d68bdda2 | ||
|
|
e43a80c322 | ||
|
|
449d5649d6 | ||
|
|
96d438df47 | ||
|
|
4e396d47bc | ||
|
|
b47ba1d5ff | ||
|
|
a078130c87 | ||
|
|
9ed76559df | ||
|
|
9927747d4e | ||
|
|
52d1b77941 | ||
|
|
40aa964057 | ||
|
|
e1a2f688e0 | ||
|
|
c0797b22ae | ||
|
|
97ee210826 | ||
|
|
3be296ec8a | ||
|
|
acf39ff056 | ||
|
|
0e79e56427 | ||
|
|
aadc4cb8be | ||
|
|
b5ebd3fd78 | ||
|
|
11394575bc | ||
|
|
5b7b36e8be | ||
|
|
c0230d839b | ||
|
|
a8d49f2972 | ||
|
|
416c6020eb | ||
|
|
6d95867a8f | ||
|
|
2eaf790638 | ||
|
|
3b2ced0131 | ||
|
|
00af4e23b3 | ||
|
|
7e00b754f0 | ||
|
|
cf89d1e756 | ||
|
|
ad6054c600 | ||
|
|
c3a01c7228 | ||
|
|
533f75d91b | ||
|
|
fcab80f1bb | ||
|
|
5d2d0b92b1 | ||
|
|
ae6662374d | ||
|
|
7b6c9f4a3c | ||
|
|
5a42b2c76c | ||
|
|
8f625561d0 | ||
|
|
9d2c04d629 | ||
|
|
e000458bb1 | ||
|
|
60975d6f7e | ||
|
|
1cba8b2b49 | ||
|
|
eead6c6219 | ||
|
|
bb9b9dad5f | ||
|
|
ade9e19be0 | ||
|
|
eb1abb51ea | ||
|
|
1fa6091000 | ||
|
|
634c2ee7e3 | ||
|
|
6f895f54c2 | ||
|
|
41d6903294 | ||
|
|
7b038e3277 | ||
|
|
74756e5d1b | ||
|
|
879622fc57 | ||
|
|
83e7a98f69 | ||
|
|
f20b0a45b3 | ||
|
|
207708efef | ||
|
|
225578a8b3 | ||
|
|
459e8acc37 | ||
|
|
8aa8b9139e | ||
|
|
001adf782d | ||
|
|
dbc58ab77c | ||
|
|
2facfeec7e | ||
|
|
4de2814c7b | ||
|
|
37b1acdaff | ||
|
|
a22434e2a1 | ||
|
|
214cc94681 | ||
|
|
a4ff275d9b | ||
|
|
15f32c6907 | ||
|
|
051afd8825 | ||
|
|
728c033ad6 | ||
|
|
4c514483d8 | ||
|
|
c2d9c20803 | ||
|
|
e34ae4c6b6 | ||
|
|
e54536127c | ||
|
|
49d9f941c0 | ||
|
|
cefc21c1f9 | ||
|
|
3e64fa7246 | ||
|
|
b15f3c57ea | ||
|
|
ff802c6802 | ||
|
|
b401957d5f | ||
|
|
8c8151f8f9 | ||
|
|
ebb7c203d3 | ||
|
|
203241ed32 | ||
|
|
ac485609c4 | ||
|
|
de5b85aa66 | ||
|
|
de3df2d88b | ||
|
|
043a24f2e4 | ||
|
|
5a48b0d7d6 | ||
|
|
ce307556fb | ||
|
|
cb616e27cb | ||
|
|
a54ca1e759 | ||
|
|
5b3fadcc16 | ||
|
|
872a497464 | ||
|
|
e301702964 | ||
|
|
f7b734438d | ||
|
|
5792623df4 | ||
|
|
0edb275285 | ||
|
|
acc6a20d39 | ||
|
|
04cd037ba2 | ||
|
|
e1c5db988a | ||
|
|
b80142b901 | ||
|
|
54418f371b | ||
|
|
c92e78a9f8 | ||
|
|
d243b904cc | ||
|
|
374f8fb5fb | ||
|
|
dadbff5714 | ||
|
|
76ddae006f | ||
|
|
cfe157ec56 | ||
|
|
413115858c | ||
|
|
88046190ee | ||
|
|
72aa85a759 | ||
|
|
bfceebb7fb | ||
|
|
bc44fad352 | ||
|
|
4fca4dc60c | ||
|
|
036032373b | ||
|
|
89dfb43f3b | ||
|
|
c49aff4b6f | ||
|
|
56e60223c3 | ||
|
|
89b1f5aa1b | ||
|
|
b901598233 | ||
|
|
8cdc6a2885 | ||
|
|
a67e35aff9 | ||
|
|
f124e41ae6 | ||
|
|
4c954181cd | ||
|
|
7f7547737e | ||
|
|
a79d61ea85 | ||
|
|
d465b39c3e | ||
|
|
c5a609dc20 | ||
|
|
5634dc3d0d | ||
|
|
37e37b8cad | ||
|
|
8fd4534fbe | ||
|
|
d5427da52f | ||
|
|
06c5c7ed0b | ||
|
|
b190ce11b0 | ||
|
|
bf5d23230a | ||
|
|
ce382d6dd3 | ||
|
|
41d9add7ef | ||
|
|
6a87427540 | ||
|
|
694add668b | ||
|
|
7edf8c9084 | ||
|
|
b86387442e | ||
|
|
e2eb5ee670 | ||
|
|
994502b6dd | ||
|
|
fa41e83679 | ||
|
|
799cc8f7b9 | ||
|
|
b7eb441470 | ||
|
|
8d01c5859c | ||
|
|
237e8b71fe | ||
|
|
eeb8fd60d5 | ||
|
|
fef2ffc4d0 | ||
|
|
8367664f15 | ||
|
|
d6f06c33f7 | ||
|
|
627e8bf364 | ||
|
|
883c42b7db | ||
|
|
7aae0af305 | ||
|
|
b057aa917f | ||
|
|
f1b26ff7fb | ||
|
|
9610a666b1 | ||
|
|
1e0f75a647 | ||
|
|
82b75407a3 | ||
|
|
f7c511957f | ||
|
|
a66de58af9 | ||
|
|
a3508f36d5 | ||
|
|
137fec7164 | ||
|
|
214125e417 | ||
|
|
44a7dc9995 | ||
|
|
3cc2daa78f | ||
|
|
fa1174aa7b | ||
|
|
83d4e2a100 | ||
|
|
8a09f3fb0b | ||
|
|
9dbe819efd | ||
|
|
67c4149588 | ||
|
|
8b8c7dbdfc | ||
|
|
2ee20a5f3d | ||
|
|
4be605604e | ||
|
|
fc5d86f1e7 | ||
|
|
9dce287adb | ||
|
|
7798be3bb6 | ||
|
|
966362e074 | ||
|
|
a89c279ed6 | ||
|
|
a212b3c036 | ||
|
|
9230f600d7 | ||
|
|
c793621567 | ||
|
|
ee2ced236d | ||
|
|
468c00a3fe | ||
|
|
47c757f714 | ||
|
|
9a5ff89003 | ||
|
|
950444a343 | ||
|
|
30d76198c7 | ||
|
|
cce3a66f0d | ||
|
|
8d1cc6ac7d | ||
|
|
5b207639a1 | ||
|
|
359e0f9d66 | ||
|
|
ebbed05137 | ||
|
|
aa395e5a59 | ||
|
|
32328075d8 | ||
|
|
97e89c5acd | ||
|
|
5f6672be44 | ||
|
|
28e858c855 | ||
|
|
987bebe678 | ||
|
|
ec0129369c | ||
|
|
50dd385b30 | ||
|
|
da702cfd8f | ||
|
|
6e2791640e | ||
|
|
52fce5e532 | ||
|
|
b7f13cd8e8 | ||
|
|
e42985e5aa | ||
|
|
0a80646371 | ||
|
|
b9eea76a86 | ||
|
|
1b90300150 | ||
|
|
83a43fc797 | ||
|
|
5f01376027 | ||
|
|
9a1913a87a | ||
|
|
b4647beb8f | ||
|
|
d6060977ad | ||
|
|
987aa5b5ee | ||
|
|
42acdb63c3 | ||
|
|
0cc1aeb8ca | ||
|
|
ba6c671705 | ||
|
|
d2f33fc454 | ||
|
|
0d1b72cbc2 | ||
|
|
9fce2fbf2a | ||
|
|
a18ea40d6a | ||
|
|
090caa2809 | ||
|
|
49e1ea3335 | ||
|
|
11a1988705 | ||
|
|
967df08b1d | ||
|
|
9aa08a429e | ||
|
|
9e8c758f54 | ||
|
|
74a25536be | ||
|
|
12917af8a2 | ||
|
|
1ea2472f7a | ||
|
|
0fe13cb28c | ||
|
|
385dddc66a | ||
|
|
750dde7669 | ||
|
|
9917a168cd | ||
|
|
76d3cca19c | ||
|
|
c86e6d0e30 | ||
|
|
d34dc32c20 | ||
|
|
234d86c92a | ||
|
|
746c73b910 | ||
|
|
0bbfd4b2e3 | ||
|
|
7165219535 | ||
|
|
a45f564cf1 | ||
|
|
9d45a64036 | ||
|
|
ccfb4c20bf | ||
|
|
7bcd857b87 | ||
|
|
23c8ab34c1 | ||
|
|
70002dc5ca | ||
|
|
6e0e79f24f | ||
|
|
b856368d75 | ||
|
|
e37156a305 | ||
|
|
a10b0e5464 | ||
|
|
275b739944 | ||
|
|
9d1ce9a100 | ||
|
|
79afe6c3d2 | ||
|
|
c6dbb22300 | ||
|
|
18bacd3ea5 | ||
|
|
a2c913aec3 | ||
|
|
67b33b2942 | ||
|
|
7b5fd2bd05 | ||
|
|
7181d77700 | ||
|
|
7f663b1204 | ||
|
|
173ebb6944 | ||
|
|
d658239484 | ||
|
|
ab4bf59e8c | ||
|
|
eee44bbb26 | ||
|
|
a63fa51a15 | ||
|
|
2049e52101 | ||
|
|
832c618f5f | ||
|
|
14615699fa | ||
|
|
20aad0c41e | ||
|
|
f083b33f2a | ||
|
|
bf17df346e | ||
|
|
35281dedb5 | ||
|
|
c9651b7420 | ||
|
|
26c3b3adab | ||
|
|
da6e1b9856 | ||
|
|
ad27d751e3 | ||
|
|
0aab623cb1 | ||
|
|
6a446bdd83 | ||
|
|
21fb5cbbc9 | ||
|
|
0da6f94867 | ||
|
|
59e9713081 | ||
|
|
40866a8927 | ||
|
|
b71d968fad | ||
|
|
fac0d7be02 | ||
|
|
6c5603fd98 | ||
|
|
2d21853a7e | ||
|
|
fec1a8d015 | ||
|
|
7fd8576233 | ||
|
|
a4cb1599d8 | ||
|
|
ae4ce72651 | ||
|
|
e2be0c0b06 | ||
|
|
2ad408697f | ||
|
|
4213d91054 | ||
|
|
5a13f622cf | ||
|
|
23a7e4e0b0 | ||
|
|
eeb49c2757 | ||
|
|
824763b316 | ||
|
|
d3aeee32bb | ||
|
|
0bceba24db | ||
|
|
b8c77d4041 | ||
|
|
8468eab83b | ||
|
|
2b2e8d4aec | ||
|
|
b80b32bfaf | ||
|
|
e5f331db99 | ||
|
|
2f84c60385 | ||
|
|
d648396515 | ||
|
|
777e78d8dd | ||
|
|
4016c549d3 | ||
|
|
40827b21b2 | ||
|
|
65a10b6e32 | ||
|
|
8db2fef3f7 | ||
|
|
9ed1323044 | ||
|
|
1a4c405662 | ||
|
|
318594e4b4 | ||
|
|
3d903302c3 | ||
|
|
c9571d9897 | ||
|
|
3694b830a2 | ||
|
|
0471fa807c | ||
|
|
914344ea9b | ||
|
|
b40266c56f | ||
|
|
8a9303d464 | ||
|
|
30c4bf47f9 | ||
|
|
46ce45601b | ||
|
|
433312c55a | ||
|
|
9c52ec3744 | ||
|
|
70e2f49bff | ||
|
|
5ac0367ed3 | ||
|
|
5d101afb52 | ||
|
|
06f4af11b6 | ||
|
|
57e338f819 | ||
|
|
615616cb55 | ||
|
|
3413c33004 | ||
|
|
69f5660a44 | ||
|
|
d5add9fca5 | ||
|
|
15df50eb7f | ||
|
|
a94132a45f | ||
|
|
48befb6bef | ||
|
|
b300691336 | ||
|
|
faadbc10ea | ||
|
|
ed6ae8d322 | ||
|
|
e910bddbcc | ||
|
|
c85fb690f4 | ||
|
|
c1daa6ba0c | ||
|
|
4c71c7b023 | ||
|
|
f5664d33fb | ||
|
|
39c8a19ce2 | ||
|
|
826193ff68 | ||
|
|
fd0d1ed929 | ||
|
|
424988f308 | ||
|
|
b2550dbaa9 | ||
|
|
a2b238960f | ||
|
|
619b784374 | ||
|
|
68a7661546 | ||
|
|
7dac9961f0 | ||
|
|
c65c389c6d | ||
|
|
6446dcf3d6 | ||
|
|
e090d8da17 | ||
|
|
bc901436db | ||
|
|
240be9b5ae | ||
|
|
bc366a7f9e | ||
|
|
14b19d446f | ||
|
|
9e6f17b94d | ||
|
|
c3801ad375 | ||
|
|
4f3b24db09 | ||
|
|
1d294a31b8 | ||
|
|
dd8fccfb1b | ||
|
|
7089c9ecdd | ||
|
|
43203984f7 | ||
|
|
5993338ee3 | ||
|
|
19920db39f | ||
|
|
dbbaeac85c | ||
|
|
028f0fde62 | ||
|
|
87343631b9 | ||
|
|
1fbfaf5c5e | ||
|
|
4421375bb6 | ||
|
|
162ad7a37e | ||
|
|
a0a6c3f8c6 | ||
|
|
a2d38fbb98 | ||
|
|
9ef1524d3f | ||
|
|
0c9de0352a | ||
|
|
a783bc9267 | ||
|
|
aff818cebf | ||
|
|
d7b75417fc | ||
|
|
a42e898979 | ||
|
|
96cc2f3ee3 | ||
|
|
3250a1f8dd | ||
|
|
ace4a37f22 | ||
|
|
f28c2b2936 | ||
|
|
96f3cf690f | ||
|
|
b3edfdbfb7 | ||
|
|
b8aaccee82 | ||
|
|
2dc8ae7742 | ||
|
|
5b0d491127 | ||
|
|
d8b7041d7e | ||
|
|
5a0c3366c3 | ||
|
|
f8148b8dad | ||
|
|
a22b1b6267 | ||
|
|
4264daadd2 | ||
|
|
3cbc120a08 | ||
|
|
8dcd2682c7 | ||
|
|
b78002ff3e | ||
|
|
c555ee8fac | ||
|
|
b92bb0584d | ||
|
|
956d11569e | ||
|
|
e367ca32ad | ||
|
|
705f27f6ee | ||
|
|
5fc87f4c4b | ||
|
|
11749095a1 |
@@ -1,18 +1,60 @@
|
|||||||
---
|
---
|
||||||
buildifier: latest
|
buildifier: latest
|
||||||
platforms:
|
matrix:
|
||||||
ubuntu1804:
|
bazel:
|
||||||
|
- 7.x
|
||||||
|
- 8.x
|
||||||
|
tasks:
|
||||||
|
verify_ubuntu2004:
|
||||||
|
platform: ubuntu2004
|
||||||
|
bazel: ${{ bazel }}
|
||||||
|
environment:
|
||||||
|
CC: clang
|
||||||
|
SWIFT_VERSION: "5.10"
|
||||||
|
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
|
||||||
|
PATH: "$PATH:$SWIFT_HOME/usr/bin"
|
||||||
|
shell_commands:
|
||||||
|
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
|
||||||
|
- "mkdir $SWIFT_HOME"
|
||||||
|
- "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2004/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu20.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
|
||||||
build_targets:
|
build_targets:
|
||||||
- "//..."
|
- "//..."
|
||||||
test_targets:
|
test_targets:
|
||||||
- "//..."
|
- "//..."
|
||||||
ubuntu2004:
|
verify_ubuntu2204:
|
||||||
|
platform: ubuntu2204
|
||||||
|
bazel: ${{ bazel }}
|
||||||
|
environment:
|
||||||
|
CC: clang
|
||||||
|
SWIFT_VERSION: "5.10"
|
||||||
|
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
|
||||||
|
PATH: "$PATH:$SWIFT_HOME/usr/bin"
|
||||||
|
shell_commands:
|
||||||
|
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
|
||||||
|
- "mkdir $SWIFT_HOME"
|
||||||
|
- "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2204/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu22.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
|
||||||
build_targets:
|
build_targets:
|
||||||
- "//..."
|
- "//..."
|
||||||
test_targets:
|
test_targets:
|
||||||
- "//..."
|
- "//..."
|
||||||
macos:
|
test_module_cpp:
|
||||||
|
platform: ubuntu2204
|
||||||
|
bazel: ${{ bazel }}
|
||||||
|
working_directory: tests/bazel_repository_test_dir
|
||||||
build_targets:
|
build_targets:
|
||||||
- "//..."
|
- "//..."
|
||||||
|
test_module_ts:
|
||||||
|
platform: ubuntu2204
|
||||||
|
bazel: ${{ bazel }}
|
||||||
|
working_directory: tests/ts/bazel_repository_test_dir
|
||||||
test_targets:
|
test_targets:
|
||||||
- "//..."
|
- "//..."
|
||||||
|
verify_macos:
|
||||||
|
platform: macos
|
||||||
|
bazel: ${{ bazel }}
|
||||||
|
xcode_version: "15.2"
|
||||||
|
build_targets:
|
||||||
|
- "//:flatbuffers"
|
||||||
|
- "//:flatc"
|
||||||
|
test_targets:
|
||||||
|
- "//tests:flatbuffers_test"
|
||||||
|
|||||||
5
.bazelignore
Normal file
5
.bazelignore
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
ts/node_modules
|
||||||
|
|
||||||
|
# Test workspaces
|
||||||
|
tests/bazel_repository_test_dir
|
||||||
|
tests/ts/bazel_repository_test_dir
|
||||||
18
.bazelrc
Normal file
18
.bazelrc
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# We cannot use "common" here because the "version" command doesn't support
|
||||||
|
# --deleted_packages. We need to specify it for both build and query instead.
|
||||||
|
build --deleted_packages=tests/bazel_repository_test_dir,tests/ts/bazel_repository_test_dir
|
||||||
|
query --deleted_packages=tests/bazel_repository_test_dir,tests/ts/bazel_repository_test_dir
|
||||||
|
# Point tools such as coursier (used in rules_jvm_external) to Bazel's internal JDK
|
||||||
|
# suggested in https://github.com/bazelbuild/rules_jvm_external/issues/445
|
||||||
|
common --repo_env=JAVA_HOME=../bazel_tools/jdk
|
||||||
|
common --action_env=JAVA_HOME=../bazel_tools/jdk
|
||||||
|
# Workaround "Error: need --enable_runfiles on Windows for to support rules_js"
|
||||||
|
common:windows --enable_runfiles
|
||||||
|
# Swift is not required on Windows
|
||||||
|
common:windows --deleted_packages=swift
|
||||||
|
# Ignore warnings in external dependencies
|
||||||
|
build --per_file_copt=external/.*@-Wno-everything --host_per_file_copt=external/.*@-Wno-everything
|
||||||
|
# Honor the setting of `skipLibCheck` in the tsconfig.json file.
|
||||||
|
common --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
|
||||||
|
# Use "tsc" as the transpiler when ts_project has no `transpiler` set.
|
||||||
|
common --@aspect_rules_ts//ts:default_to_tsc_transpiler
|
||||||
@@ -1,13 +1,5 @@
|
|||||||
---
|
---
|
||||||
Language: Cpp
|
Language: Cpp
|
||||||
BasedOnStyle: Google
|
BasedOnStyle: Google
|
||||||
DerivePointerAlignment: false
|
|
||||||
PointerAlignment: Right
|
|
||||||
IndentPPDirectives: AfterHash
|
|
||||||
Cpp11BracedListStyle: false
|
|
||||||
AlwaysBreakTemplateDeclarations: false
|
|
||||||
AllowShortCaseLabelsOnASingleLine: true
|
|
||||||
SpaceAfterTemplateKeyword: false
|
|
||||||
AllowShortBlocksOnASingleLine: true
|
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|||||||
347
.clang-tidy
Normal file
347
.clang-tidy
Normal file
@@ -0,0 +1,347 @@
|
|||||||
|
---
|
||||||
|
FormatStyle: "file"
|
||||||
|
WarningsAsErrors: "*"
|
||||||
|
HeaderFilterRegex: ".*"
|
||||||
|
Checks: "google-build-explicit-make-pair,
|
||||||
|
google-build-namespaces,
|
||||||
|
google-build-using-namespace,
|
||||||
|
google-default-arguments,
|
||||||
|
google-explicit-constructor,
|
||||||
|
google-global-names-in-headers,
|
||||||
|
google-objc-avoid-nsobject-new,
|
||||||
|
google-objc-avoid-throwing-exception,
|
||||||
|
google-objc-function-naming,
|
||||||
|
google-objc-global-variable-declaration,
|
||||||
|
google-readability-avoid-underscore-in-googletest-name,
|
||||||
|
google-readability-braces-around-statements,
|
||||||
|
google-readability-casting,
|
||||||
|
google-readability-function-size,
|
||||||
|
google-readability-namespace-comments,
|
||||||
|
google-runtime-int,
|
||||||
|
google-runtime-operator,
|
||||||
|
google-upgrade-googletest-case,
|
||||||
|
clang-analyzer-apiModeling.StdCLibraryFunctions,
|
||||||
|
clang-analyzer-apiModeling.TrustNonnull,
|
||||||
|
clang-analyzer-apiModeling.google.GTest,
|
||||||
|
clang-analyzer-apiModeling.llvm.CastValue,
|
||||||
|
clang-analyzer-apiModeling.llvm.ReturnValue,
|
||||||
|
clang-analyzer-core.CallAndMessage,
|
||||||
|
clang-analyzer-core.CallAndMessageModeling,
|
||||||
|
clang-analyzer-core.DivideZero,
|
||||||
|
clang-analyzer-core.DynamicTypePropagation,
|
||||||
|
clang-analyzer-core.NonNullParamChecker,
|
||||||
|
clang-analyzer-core.NonnilStringConstants,
|
||||||
|
clang-analyzer-core.NullDereference,
|
||||||
|
clang-analyzer-core.StackAddrEscapeBase,
|
||||||
|
clang-analyzer-core.StackAddressEscape,
|
||||||
|
clang-analyzer-core.UndefinedBinaryOperatorResult,
|
||||||
|
clang-analyzer-core.VLASize,
|
||||||
|
clang-analyzer-core.builtin.BuiltinFunctions,
|
||||||
|
clang-analyzer-core.builtin.NoReturnFunctions,
|
||||||
|
clang-analyzer-core.uninitialized.ArraySubscript,
|
||||||
|
clang-analyzer-core.uninitialized.Assign,
|
||||||
|
clang-analyzer-core.uninitialized.Branch,
|
||||||
|
clang-analyzer-core.uninitialized.CapturedBlockVariable,
|
||||||
|
clang-analyzer-core.uninitialized.UndefReturn,
|
||||||
|
clang-analyzer-cplusplus.InnerPointer,
|
||||||
|
clang-analyzer-cplusplus.Move,
|
||||||
|
clang-analyzer-cplusplus.NewDelete,
|
||||||
|
clang-analyzer-cplusplus.NewDeleteLeaks,
|
||||||
|
clang-analyzer-cplusplus.PlacementNew,
|
||||||
|
clang-analyzer-cplusplus.PureVirtualCall,
|
||||||
|
clang-analyzer-cplusplus.SelfAssignment,
|
||||||
|
clang-analyzer-cplusplus.SmartPtrModeling,
|
||||||
|
clang-analyzer-cplusplus.StringChecker,
|
||||||
|
clang-analyzer-cplusplus.VirtualCallModeling,
|
||||||
|
clang-analyzer-deadcode.DeadStores,
|
||||||
|
clang-analyzer-fuchsia.HandleChecker,
|
||||||
|
clang-analyzer-nullability.NullPassedToNonnull,
|
||||||
|
clang-analyzer-nullability.NullReturnedFromNonnull,
|
||||||
|
clang-analyzer-nullability.NullabilityBase,
|
||||||
|
clang-analyzer-nullability.NullableDereferenced,
|
||||||
|
clang-analyzer-nullability.NullablePassedToNonnull,
|
||||||
|
clang-analyzer-nullability.NullableReturnedFromNonnull,
|
||||||
|
clang-analyzer-optin.cplusplus.UninitializedObject,
|
||||||
|
clang-analyzer-optin.cplusplus.VirtualCall,
|
||||||
|
clang-analyzer-optin.mpi.MPI-Checker,
|
||||||
|
clang-analyzer-optin.osx.OSObjectCStyleCast,
|
||||||
|
clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker,
|
||||||
|
clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker,
|
||||||
|
clang-analyzer-optin.performance.GCDAntipattern,
|
||||||
|
clang-analyzer-optin.performance.Padding,
|
||||||
|
clang-analyzer-optin.portability.UnixAPI,
|
||||||
|
clang-analyzer-osx.API,
|
||||||
|
clang-analyzer-osx.MIG,
|
||||||
|
clang-analyzer-osx.NSOrCFErrorDerefChecker,
|
||||||
|
clang-analyzer-osx.NumberObjectConversion,
|
||||||
|
clang-analyzer-osx.OSObjectRetainCount,
|
||||||
|
clang-analyzer-osx.ObjCProperty,
|
||||||
|
clang-analyzer-osx.SecKeychainAPI,
|
||||||
|
clang-analyzer-osx.cocoa.AtSync,
|
||||||
|
clang-analyzer-osx.cocoa.AutoreleaseWrite,
|
||||||
|
clang-analyzer-osx.cocoa.ClassRelease,
|
||||||
|
clang-analyzer-osx.cocoa.Dealloc,
|
||||||
|
clang-analyzer-osx.cocoa.IncompatibleMethodTypes,
|
||||||
|
clang-analyzer-osx.cocoa.Loops,
|
||||||
|
clang-analyzer-osx.cocoa.MissingSuperCall,
|
||||||
|
clang-analyzer-osx.cocoa.NSAutoreleasePool,
|
||||||
|
clang-analyzer-osx.cocoa.NSError,
|
||||||
|
clang-analyzer-osx.cocoa.NilArg,
|
||||||
|
clang-analyzer-osx.cocoa.NonNilReturnValue,
|
||||||
|
clang-analyzer-osx.cocoa.ObjCGenerics,
|
||||||
|
clang-analyzer-osx.cocoa.RetainCount,
|
||||||
|
clang-analyzer-osx.cocoa.RetainCountBase,
|
||||||
|
clang-analyzer-osx.cocoa.RunLoopAutoreleaseLeak,
|
||||||
|
clang-analyzer-osx.cocoa.SelfInit,
|
||||||
|
clang-analyzer-osx.cocoa.SuperDealloc,
|
||||||
|
clang-analyzer-osx.cocoa.UnusedIvars,
|
||||||
|
clang-analyzer-osx.cocoa.VariadicMethodTypes,
|
||||||
|
clang-analyzer-osx.coreFoundation.CFError,
|
||||||
|
clang-analyzer-osx.coreFoundation.CFNumber,
|
||||||
|
clang-analyzer-osx.coreFoundation.CFRetainRelease,
|
||||||
|
clang-analyzer-osx.coreFoundation.containers.OutOfBounds,
|
||||||
|
clang-analyzer-osx.coreFoundation.containers.PointerSizedValues,
|
||||||
|
clang-analyzer-security.FloatLoopCounter,
|
||||||
|
clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
|
||||||
|
clang-analyzer-security.insecureAPI.SecuritySyntaxChecker,
|
||||||
|
clang-analyzer-security.insecureAPI.UncheckedReturn,
|
||||||
|
clang-analyzer-security.insecureAPI.bcmp,
|
||||||
|
clang-analyzer-security.insecureAPI.bcopy,
|
||||||
|
clang-analyzer-security.insecureAPI.bzero,
|
||||||
|
clang-analyzer-security.insecureAPI.decodeValueOfObjCType,
|
||||||
|
clang-analyzer-security.insecureAPI.getpw,
|
||||||
|
clang-analyzer-security.insecureAPI.gets,
|
||||||
|
clang-analyzer-security.insecureAPI.mkstemp,
|
||||||
|
clang-analyzer-security.insecureAPI.mktemp,
|
||||||
|
clang-analyzer-security.insecureAPI.rand,
|
||||||
|
clang-analyzer-security.insecureAPI.strcpy,
|
||||||
|
clang-analyzer-security.insecureAPI.vfork,
|
||||||
|
clang-analyzer-unix.API,
|
||||||
|
clang-analyzer-unix.DynamicMemoryModeling,
|
||||||
|
clang-analyzer-unix.Malloc,
|
||||||
|
clang-analyzer-unix.MallocSizeof,
|
||||||
|
clang-analyzer-unix.MismatchedDeallocator,
|
||||||
|
clang-analyzer-unix.Vfork,
|
||||||
|
clang-analyzer-unix.cstring.BadSizeArg,
|
||||||
|
clang-analyzer-unix.cstring.CStringModeling,
|
||||||
|
clang-analyzer-unix.cstring.NullArg,
|
||||||
|
clang-analyzer-valist.CopyToSelf,
|
||||||
|
clang-analyzer-valist.Uninitialized,
|
||||||
|
clang-analyzer-valist.Unterminated,
|
||||||
|
clang-analyzer-valist.ValistBase,
|
||||||
|
clang-analyzer-webkit.NoUncountedMemberChecker,
|
||||||
|
clang-analyzer-webkit.RefCntblBaseVirtualDtor,
|
||||||
|
clang-analyzer-webkit.UncountedLambdaCapturesChecker,
|
||||||
|
|
||||||
|
################################################ Optional checks ################################################
|
||||||
|
|
||||||
|
#google-readability-todo,
|
||||||
|
#bugprone-argument-comment,
|
||||||
|
#bugprone-assert-side-effect,
|
||||||
|
#bugprone-bad-signal-to-kill-thread,
|
||||||
|
#bugprone-bool-pointer-implicit-conversion,
|
||||||
|
#bugprone-branch-clone,
|
||||||
|
#bugprone-copy-constructor-init,
|
||||||
|
#bugprone-dangling-handle,
|
||||||
|
#bugprone-dynamic-static-initializers,
|
||||||
|
#bugprone-easily-swappable-parameters,
|
||||||
|
#bugprone-exception-escape,
|
||||||
|
#bugprone-fold-init-type,
|
||||||
|
#bugprone-forward-declaration-namespace,
|
||||||
|
#bugprone-forwarding-reference-overload,
|
||||||
|
#bugprone-implicit-widening-of-multiplication-result,
|
||||||
|
#bugprone-inaccurate-erase,
|
||||||
|
#bugprone-incorrect-roundings,
|
||||||
|
#bugprone-infinite-loop,
|
||||||
|
#bugprone-integer-division,
|
||||||
|
#bugprone-lambda-function-name,
|
||||||
|
#bugprone-macro-parentheses,
|
||||||
|
#bugprone-macro-repeated-side-effects,
|
||||||
|
#bugprone-misplaced-operator-in-strlen-in-alloc,
|
||||||
|
#bugprone-misplaced-pointer-arithmetic-in-alloc,
|
||||||
|
#bugprone-misplaced-widening-cast,
|
||||||
|
#bugprone-move-forwarding-reference,
|
||||||
|
#bugprone-multiple-statement-macro,
|
||||||
|
#bugprone-narrowing-conversions,
|
||||||
|
#bugprone-no-escape,
|
||||||
|
#bugprone-not-null-terminated-result,
|
||||||
|
#bugprone-parent-virtual-call,
|
||||||
|
#bugprone-posix-return,
|
||||||
|
#bugprone-redundant-branch-condition,
|
||||||
|
#bugprone-reserved-identifier,
|
||||||
|
#bugprone-signal-handler,
|
||||||
|
#bugprone-signed-char-misuse,
|
||||||
|
#bugprone-sizeof-container,
|
||||||
|
#bugprone-sizeof-expression,
|
||||||
|
#bugprone-spuriously-wake-up-functions,
|
||||||
|
#bugprone-string-constructor,
|
||||||
|
#bugprone-string-integer-assignment,
|
||||||
|
#bugprone-string-literal-with-embedded-nul,
|
||||||
|
#bugprone-stringview-nullptr,
|
||||||
|
#bugprone-suspicious-enum-usage,
|
||||||
|
#bugprone-suspicious-include,
|
||||||
|
#bugprone-suspicious-memory-comparison,
|
||||||
|
#bugprone-suspicious-memset-usage,
|
||||||
|
#bugprone-suspicious-missing-comma,
|
||||||
|
#bugprone-suspicious-semicolon,
|
||||||
|
#bugprone-suspicious-string-compare,
|
||||||
|
#bugprone-swapped-arguments,
|
||||||
|
#bugprone-terminating-continue,
|
||||||
|
#bugprone-throw-keyword-missing,
|
||||||
|
#bugprone-too-small-loop-variable,
|
||||||
|
#bugprone-undefined-memory-manipulation,
|
||||||
|
#bugprone-undelegated-constructor,
|
||||||
|
#bugprone-unhandled-exception-at-new,
|
||||||
|
#bugprone-unhandled-self-assignment,
|
||||||
|
#bugprone-unused-raii,
|
||||||
|
#bugprone-unused-return-value,
|
||||||
|
#bugprone-use-after-move,
|
||||||
|
#bugprone-virtual-near-miss,
|
||||||
|
#cppcoreguidelines-avoid-c-arrays,
|
||||||
|
#cppcoreguidelines-avoid-goto,
|
||||||
|
#cppcoreguidelines-avoid-magic-numbers,
|
||||||
|
#cppcoreguidelines-avoid-non-const-global-variables,
|
||||||
|
#cppcoreguidelines-c-copy-assignment-signature,
|
||||||
|
#cppcoreguidelines-explicit-virtual-functions,
|
||||||
|
#cppcoreguidelines-init-variables,
|
||||||
|
#cppcoreguidelines-interfaces-global-init,
|
||||||
|
#cppcoreguidelines-macro-usage,
|
||||||
|
#cppcoreguidelines-narrowing-conversions,
|
||||||
|
#cppcoreguidelines-no-malloc,
|
||||||
|
#cppcoreguidelines-non-private-member-variables-in-classes,
|
||||||
|
#cppcoreguidelines-owning-memory,
|
||||||
|
#cppcoreguidelines-prefer-member-initializer,
|
||||||
|
#cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||||
|
#cppcoreguidelines-pro-bounds-constant-array-index,
|
||||||
|
#cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
||||||
|
#cppcoreguidelines-pro-type-const-cast,
|
||||||
|
#cppcoreguidelines-pro-type-cstyle-cast,
|
||||||
|
#cppcoreguidelines-pro-type-member-init,
|
||||||
|
#cppcoreguidelines-pro-type-reinterpret-cast,
|
||||||
|
#cppcoreguidelines-pro-type-static-cast-downcast,
|
||||||
|
#cppcoreguidelines-pro-type-union-access,
|
||||||
|
#cppcoreguidelines-pro-type-vararg,
|
||||||
|
#cppcoreguidelines-slicing,
|
||||||
|
#cppcoreguidelines-special-member-functions,
|
||||||
|
#cppcoreguidelines-virtual-class-destructor,
|
||||||
|
#hicpp-avoid-c-arrays,
|
||||||
|
#hicpp-avoid-goto,
|
||||||
|
#hicpp-braces-around-statements,
|
||||||
|
#hicpp-deprecated-headers,
|
||||||
|
#hicpp-exception-baseclass,
|
||||||
|
#hicpp-explicit-conversions,
|
||||||
|
#hicpp-function-size,
|
||||||
|
#hicpp-invalid-access-moved,
|
||||||
|
#hicpp-member-init,
|
||||||
|
#hicpp-move-const-arg,
|
||||||
|
#hicpp-multiway-paths-covered,
|
||||||
|
#hicpp-named-parameter,
|
||||||
|
#hicpp-new-delete-operators,
|
||||||
|
#hicpp-no-array-decay,
|
||||||
|
#hicpp-no-assembler,
|
||||||
|
#hicpp-no-malloc,
|
||||||
|
#hicpp-noexcept-move,
|
||||||
|
#hicpp-signed-bitwise,
|
||||||
|
#hicpp-special-member-functions,
|
||||||
|
#hicpp-static-assert,
|
||||||
|
#hicpp-undelegated-constructor,
|
||||||
|
#hicpp-uppercase-literal-suffix,
|
||||||
|
#hicpp-use-auto,
|
||||||
|
#hicpp-use-emplace,
|
||||||
|
#hicpp-use-equals-default,
|
||||||
|
#hicpp-use-equals-delete,
|
||||||
|
#hicpp-use-noexcept,
|
||||||
|
#hicpp-use-nullptr,
|
||||||
|
#hicpp-use-override,
|
||||||
|
#hicpp-vararg,
|
||||||
|
#modernize-avoid-bind,
|
||||||
|
#modernize-avoid-c-arrays,
|
||||||
|
#modernize-concat-nested-namespaces,
|
||||||
|
#modernize-deprecated-headers,
|
||||||
|
#modernize-deprecated-ios-base-aliases,
|
||||||
|
#modernize-loop-convert,
|
||||||
|
#modernize-make-shared,
|
||||||
|
#modernize-make-unique,
|
||||||
|
#modernize-pass-by-value,
|
||||||
|
#modernize-raw-string-literal,
|
||||||
|
#modernize-redundant-void-arg,
|
||||||
|
#modernize-replace-auto-ptr,
|
||||||
|
#modernize-replace-disallow-copy-and-assign-macro,
|
||||||
|
#modernize-replace-random-shuffle,
|
||||||
|
#modernize-return-braced-init-list,
|
||||||
|
#modernize-shrink-to-fit,
|
||||||
|
#modernize-unary-static-assert,
|
||||||
|
#modernize-use-auto,
|
||||||
|
#modernize-use-bool-literals,
|
||||||
|
#modernize-use-default-member-init,
|
||||||
|
#modernize-use-emplace,
|
||||||
|
#modernize-use-equals-default,
|
||||||
|
#modernize-use-equals-delete,
|
||||||
|
#modernize-use-nodiscard,
|
||||||
|
#modernize-use-noexcept,
|
||||||
|
#modernize-use-nullptr,
|
||||||
|
#modernize-use-override,
|
||||||
|
#modernize-use-trailing-return-type,
|
||||||
|
#modernize-use-transparent-functors,
|
||||||
|
#modernize-use-uncaught-exceptions,
|
||||||
|
#modernize-use-using,
|
||||||
|
#performance-faster-string-find,
|
||||||
|
#performance-for-range-copy,
|
||||||
|
#performance-implicit-conversion-in-loop,
|
||||||
|
#performance-inefficient-algorithm,
|
||||||
|
#performance-inefficient-string-concatenation,
|
||||||
|
#performance-inefficient-vector-operation,
|
||||||
|
#performance-move-const-arg,
|
||||||
|
#performance-move-constructor-init,
|
||||||
|
#performance-no-automatic-move,
|
||||||
|
#performance-no-int-to-ptr,
|
||||||
|
#performance-noexcept-move-constructor,
|
||||||
|
#performance-trivially-destructible,
|
||||||
|
#performance-type-promotion-in-math-fn,
|
||||||
|
#performance-unnecessary-copy-initialization,
|
||||||
|
#performance-unnecessary-value-param,
|
||||||
|
#portability-restrict-system-includes,
|
||||||
|
#portability-simd-intrinsics,
|
||||||
|
#readability-avoid-const-params-in-decls,
|
||||||
|
#readability-braces-around-statements,
|
||||||
|
#readability-const-return-type,
|
||||||
|
#readability-container-contains,
|
||||||
|
#readability-container-data-pointer,
|
||||||
|
#readability-container-size-empty,
|
||||||
|
#readability-convert-member-functions-to-static,
|
||||||
|
#readability-delete-null-pointer,
|
||||||
|
#readability-duplicate-include,
|
||||||
|
#readability-else-after-return,
|
||||||
|
#readability-function-cognitive-complexity,
|
||||||
|
#readability-function-size,
|
||||||
|
#readability-identifier-length,
|
||||||
|
#readability-identifier-naming,
|
||||||
|
#readability-implicit-bool-conversion,
|
||||||
|
#readability-inconsistent-declaration-parameter-name,
|
||||||
|
#readability-isolate-declaration,
|
||||||
|
#readability-magic-numbers,
|
||||||
|
#readability-make-member-function-const,
|
||||||
|
#readability-misleading-indentation,
|
||||||
|
#readability-misplaced-array-index,
|
||||||
|
#readability-named-parameter,
|
||||||
|
#readability-non-const-parameter,
|
||||||
|
#readability-qualified-auto,
|
||||||
|
#readability-redundant-access-specifiers,
|
||||||
|
#readability-redundant-control-flow,
|
||||||
|
#readability-redundant-declaration,
|
||||||
|
#readability-redundant-function-ptr-dereference,
|
||||||
|
#readability-redundant-member-init,
|
||||||
|
#readability-redundant-preprocessor,
|
||||||
|
#readability-redundant-smartptr-get,
|
||||||
|
#readability-redundant-string-cstr,
|
||||||
|
#readability-redundant-string-init,
|
||||||
|
#readability-simplify-boolean-expr,
|
||||||
|
#readability-simplify-subscript-expr,
|
||||||
|
#readability-static-accessed-through-instance,
|
||||||
|
#readability-static-definition-in-anonymous-namespace,
|
||||||
|
#readability-string-compare,
|
||||||
|
#readability-suspicious-call-argument,
|
||||||
|
#readability-uniqueptr-delete-release,
|
||||||
|
#readability-uppercase-literal-suffix,
|
||||||
|
#readability-use-anyofallof
|
||||||
|
"
|
||||||
@@ -5,3 +5,4 @@ root = true
|
|||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|||||||
13
.eslintrc.js
13
.eslintrc.js
@@ -1,13 +0,0 @@
|
|||||||
/* eslint-env node */
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
root: true,
|
|
||||||
parser: '@typescript-eslint/parser',
|
|
||||||
plugins: [
|
|
||||||
'@typescript-eslint',
|
|
||||||
],
|
|
||||||
extends: [
|
|
||||||
'eslint:recommended',
|
|
||||||
'plugin:@typescript-eslint/recommended',
|
|
||||||
]
|
|
||||||
};
|
|
||||||
5
.github/CODEOWNERS
vendored
Normal file
5
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Default owner
|
||||||
|
* @dbaileychess derekbailey@google.com
|
||||||
|
|
||||||
|
# Prevent modification of this file
|
||||||
|
.github/CODEOWNERS @dbaileychess derekbailey@google.com
|
||||||
11
.github/ISSUE_TEMPLATE/404-doc.md
vendored
Normal file
11
.github/ISSUE_TEMPLATE/404-doc.md
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
name: 404 Doc
|
||||||
|
about: To fix broken documentation links
|
||||||
|
title: "[Doc 404]"
|
||||||
|
labels: documentation
|
||||||
|
assignees: dbaileychess
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Target URL:
|
||||||
|
[Optional] Source Site:
|
||||||
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -3,7 +3,7 @@ Thank you for submitting a PR!
|
|||||||
Please delete this standard text once you've created your own description.
|
Please delete this standard text once you've created your own description.
|
||||||
|
|
||||||
If you make changes to any of the code generators (`src/idl_gen*`) be sure to
|
If you make changes to any of the code generators (`src/idl_gen*`) be sure to
|
||||||
build your project, as it will generate code based on the changes. If necessary
|
[build](https://google.github.io/flatbuffers/flatbuffers_guide_building.html) your project, as it will generate code based on the changes. If necessary
|
||||||
the code generation script can be directly run (`scripts/generate_code.py`),
|
the code generation script can be directly run (`scripts/generate_code.py`),
|
||||||
requires Python3. This allows us to better see the effect of the PR.
|
requires Python3. This allows us to better see the effect of the PR.
|
||||||
|
|
||||||
|
|||||||
6
.github/dependabot.yml
vendored
Normal file
6
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
154
.github/labeler.yml
vendored
154
.github/labeler.yml
vendored
@@ -5,93 +5,133 @@
|
|||||||
#
|
#
|
||||||
# See .github/workflows/label.yml for Github Action workflow script
|
# See .github/workflows/label.yml for Github Action workflow script
|
||||||
|
|
||||||
c#:
|
"c#":
|
||||||
- '**/*.cs'
|
- changed-files:
|
||||||
- net/**/*
|
- any-glob-to-any-file:
|
||||||
- tests/FlatBuffers.Test/**/*
|
- '**/*.cs'
|
||||||
- tests/FlatBuffers.Benchmarks/**/*
|
- 'net/**/*'
|
||||||
- src/idl_gen_csharp.cpp
|
- 'tests/FlatBuffers.Test/**/*'
|
||||||
|
- 'tests/FlatBuffers.Benchmarks/**/*'
|
||||||
|
- 'src/idl_gen_csharp.cpp'
|
||||||
|
|
||||||
swift:
|
swift:
|
||||||
- '**/*.swift'
|
- changed-files:
|
||||||
- swift/**/*
|
- any-glob-to-any-file:
|
||||||
- tests/FlatBuffers.GRPC.Swift/**/*
|
- '**/*.swift'
|
||||||
- tests/FlatBuffers.Benchmarks.swift/**/*
|
- 'swift/**/*'
|
||||||
- tests/FlatBuffers.Test.Swift/**/*
|
- 'tests/swift/**'
|
||||||
- src/idl_gen_swift.cpp
|
- 'src/idl_gen_swift.cpp'
|
||||||
|
|
||||||
|
nim:
|
||||||
|
- changed-files:
|
||||||
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.nim'
|
||||||
|
- 'nim/**/*'
|
||||||
|
- 'src/idl_gen_nim.cpp'
|
||||||
|
- 'src/bfbs_gen_nim.cpp'
|
||||||
|
|
||||||
javascript:
|
javascript:
|
||||||
- '**/*.js'
|
- changed-files:
|
||||||
- src/idl_gen_ts.cpp
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.js'
|
||||||
|
- 'src/idl_gen_ts.cpp'
|
||||||
|
|
||||||
typescript:
|
typescript:
|
||||||
- '**/*.ts'
|
- changed-files:
|
||||||
- src/idl_gen_ts.cpp
|
- any-glob-to-any-file:
|
||||||
- grpc/flatbuffers-js-grpc/**/*.ts
|
- '**/*.ts'
|
||||||
|
- 'src/idl_gen_ts.cpp'
|
||||||
|
- 'grpc/flatbuffers-js-grpc/**/*.ts'
|
||||||
|
|
||||||
golang:
|
golang:
|
||||||
- '**/*.go'
|
- changed-files:
|
||||||
- src/idl_gen_go.cpp
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.go'
|
||||||
|
- 'src/idl_gen_go.cpp'
|
||||||
|
|
||||||
python:
|
python:
|
||||||
- '**/*.py'
|
- changed-files:
|
||||||
- src/idl_gen_python.cpp
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.py'
|
||||||
|
- 'src/idl_gen_python.cpp'
|
||||||
|
|
||||||
java:
|
java:
|
||||||
- '**/*.java'
|
- changed-files:
|
||||||
- src/idl_gen_java.cpp
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.java'
|
||||||
|
- 'src/idl_gen_java.cpp'
|
||||||
|
|
||||||
kotlin:
|
kotlin:
|
||||||
- '**/*.kt'
|
- changed-files:
|
||||||
- src/idl_gen_kotlin.cpp
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.kt'
|
||||||
|
- 'src/idl_gen_kotlin.cpp'
|
||||||
|
- 'src/idl_gen_kotlin_kmp.cpp'
|
||||||
|
|
||||||
lua:
|
lua:
|
||||||
- '**/*.lua'
|
- changed-files:
|
||||||
- lua/**/*
|
- any-glob-to-any-file:
|
||||||
- src/idl_gen_lua.cpp
|
- '**/*.lua'
|
||||||
- src/bfbs_gen_lua.cpp
|
- 'lua/**/*'
|
||||||
|
- 'src/bfbs_gen_lua.cpp'
|
||||||
|
|
||||||
lobster:
|
lobster:
|
||||||
- '**/*.lobster'
|
- changed-files:
|
||||||
- src/idl_gen_lobster.cpp
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.lobster'
|
||||||
|
- 'src/idl_gen_lobster.cpp'
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- '**/*.php'
|
- changed-files:
|
||||||
- src/idl_gen_php.cpp
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.php'
|
||||||
|
- 'src/idl_gen_php.cpp'
|
||||||
|
|
||||||
rust:
|
rust:
|
||||||
- '**/*.rs'
|
- changed-files:
|
||||||
- rust/**/*
|
- any-glob-to-any-file:
|
||||||
- src/idl_gen_rust.cpp
|
- '**/*.rs'
|
||||||
|
- 'rust/**/*'
|
||||||
dart:
|
- 'src/idl_gen_rust.cpp'
|
||||||
- '**/*.dart'
|
|
||||||
- src/idl_gen_dart.cpp
|
|
||||||
|
|
||||||
c++:
|
dart:
|
||||||
- '**/*.cc'
|
- changed-files:
|
||||||
- '**/*.cpp'
|
- any-glob-to-any-file:
|
||||||
- '**/*.h'
|
- '**/*.dart'
|
||||||
|
- 'src/idl_gen_dart.cpp'
|
||||||
|
|
||||||
|
"c++":
|
||||||
|
- changed-files:
|
||||||
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.cc'
|
||||||
|
- '**/*.cpp'
|
||||||
|
- '**/*.h'
|
||||||
|
|
||||||
json:
|
json:
|
||||||
- '**/*.json'
|
- changed-files:
|
||||||
- src/idl_gen_json_schema.cpp
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.json'
|
||||||
|
- 'src/idl_gen_json_schema.cpp'
|
||||||
|
|
||||||
codegen:
|
codegen:
|
||||||
- src/**/*
|
- changed-files:
|
||||||
|
- any-glob-to-any-file:
|
||||||
|
- 'src/**/*'
|
||||||
|
|
||||||
documentation:
|
documentation:
|
||||||
- docs/**/*
|
- changed-files:
|
||||||
- '**/*.md'
|
- any-glob-to-any-file:
|
||||||
|
- 'docs/**/*'
|
||||||
|
- '**/*.md'
|
||||||
|
|
||||||
CI:
|
CI:
|
||||||
- '.github/**/*'
|
- changed-files:
|
||||||
- '.appveyor/**/*'
|
- any-glob-to-any-file:
|
||||||
- '.travis/**/*'
|
- '.github/**/*'
|
||||||
- '.bazelci/**/*'
|
- '.bazelci/**/*'
|
||||||
- .travis.yml
|
|
||||||
- appveyor.yml
|
|
||||||
|
|
||||||
grpc:
|
grpc:
|
||||||
- grpc/**/*
|
- changed-files:
|
||||||
- src/idl_gen_grpc.cpp
|
- any-glob-to-any-file:
|
||||||
|
- 'grpc/**/*'
|
||||||
|
- 'src/idl_gen_grpc.cpp'
|
||||||
|
|||||||
623
.github/workflows/build.yml
vendored
623
.github/workflows/build.yml
vendored
@@ -1,26 +1,40 @@
|
|||||||
name: CI
|
name: CI
|
||||||
|
permissions: read-all
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
# For manual tests.
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
|
tags:
|
||||||
|
- "*" # new tag version, like `0.8.4` or else
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
schedule:
|
||||||
|
# Run daily at 4:45 A.M. to catch dependencies that break us.
|
||||||
|
- cron: '45 4 * * *'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-linux:
|
build-linux:
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
outputs:
|
||||||
|
digests-gcc: ${{ steps.hash-gcc.outputs.hashes }}
|
||||||
|
digests-clang: ${{ steps.hash-clang.outputs.hashes }}
|
||||||
name: Build Linux
|
name: Build Linux
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-24.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
cxx: [g++-10, clang++-12]
|
cxx: [g++-13, clang++-18]
|
||||||
|
fail-fast: false
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v6
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .
|
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON -DFLATBUFFERS_STATIC_FLATC=ON .
|
||||||
- name: build
|
- name: build
|
||||||
run: make -j4
|
run: make -j
|
||||||
- name: test
|
- name: test
|
||||||
run: ./flattests
|
run: ./flattests
|
||||||
- name: make flatc executable
|
- name: make flatc executable
|
||||||
@@ -28,247 +42,602 @@ jobs:
|
|||||||
chmod +x flatc
|
chmod +x flatc
|
||||||
./flatc --version
|
./flatc --version
|
||||||
- name: upload build artifacts
|
- name: upload build artifacts
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Linux flatc binary ${{ matrix.cxx }}
|
name: Linux flatc binary ${{ matrix.cxx }}
|
||||||
path: flatc
|
path: flatc
|
||||||
|
# Below if only for release.
|
||||||
|
- name: Zip file
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
run: zip Linux.flatc.binary.${{ matrix.cxx }}.zip flatc
|
||||||
|
- name: Release zip file
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
with:
|
||||||
|
files: Linux.flatc.binary.${{ matrix.cxx }}.zip
|
||||||
|
- name: Generate SLSA subjects - clang
|
||||||
|
if: matrix.cxx == 'clang++-18' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
id: hash-clang
|
||||||
|
run: echo "hashes=$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)" >> $GITHUB_OUTPUT
|
||||||
|
- name: Generate SLSA subjects - gcc
|
||||||
|
if: matrix.cxx == 'g++-13' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
id: hash-gcc
|
||||||
|
run: echo "hashes=$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
build-linux-no-file-tests:
|
||||||
|
name: Build Linux with -DFLATBUFFERS_NO_FILE_TESTS
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: cmake
|
||||||
|
run: CXX=clang++-18 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON -DFLATBUFFERS_CXX_FLAGS="-DFLATBUFFERS_NO_FILE_TESTS" .
|
||||||
|
- name: build
|
||||||
|
run: make -j
|
||||||
|
- name: test
|
||||||
|
run: ./flattests
|
||||||
|
|
||||||
|
build-linux-out-of-source:
|
||||||
|
name: Build Linux with out-of-source build location
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: make build directory
|
||||||
|
run: mkdir build
|
||||||
|
- name: cmake
|
||||||
|
working-directory: build
|
||||||
|
run: >
|
||||||
|
CXX=clang++-18 cmake .. -G "Unix Makefiles" -DFLATBUFFERS_STRICT_MODE=ON
|
||||||
|
-DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_CPP_STD=17
|
||||||
|
- name: build
|
||||||
|
working-directory: build
|
||||||
|
run: make -j
|
||||||
|
- name: test
|
||||||
|
working-directory: build
|
||||||
|
run: pwd && ./flattests
|
||||||
|
- name: test C++17
|
||||||
|
working-directory: build
|
||||||
|
run: ./flattests_cpp17
|
||||||
|
|
||||||
|
build-linux-cpp-std:
|
||||||
|
name: Build Linux C++
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
std: [11, 14, 17, 20, 23]
|
||||||
|
cxx: [g++-13, clang++-18]
|
||||||
|
exclude:
|
||||||
|
# Clang++15 10.3.0 stdlibc++ doesn't fully support std 23
|
||||||
|
- cxx: clang++-18
|
||||||
|
std: 23
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: cmake
|
||||||
|
run: >
|
||||||
|
CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles"
|
||||||
|
-DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON
|
||||||
|
-DFLATBUFFERS_CPP_STD=${{ matrix.std }}
|
||||||
|
-DFLATBUFFERS_BUILD_CPP17=${{ matrix.std >= 17 && 'On' || 'Off'}}
|
||||||
|
- name: build
|
||||||
|
run: make -j
|
||||||
|
- name: test
|
||||||
|
run: ./flattests
|
||||||
|
- name: test C++17
|
||||||
|
if: matrix.std >= 17
|
||||||
|
run: ./flattests_cpp17
|
||||||
|
|
||||||
|
build-cpp-std:
|
||||||
|
name: Build Windows C++
|
||||||
|
runs-on: windows-2022
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
std: [11, 14, 17, 20, 23]
|
||||||
|
fail-fast: false
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Add msbuild to PATH
|
||||||
|
uses: microsoft/setup-msbuild@v2
|
||||||
|
- name: cmake
|
||||||
|
run: >
|
||||||
|
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release
|
||||||
|
-DFLATBUFFERS_STRICT_MODE=ON
|
||||||
|
-DFLATBUFFERS_CPP_STD=${{ matrix.std }}
|
||||||
|
-DFLATBUFFERS_BUILD_CPP17=${{ matrix.std >= 17 && 'On' || 'Off'}}
|
||||||
|
- name: build
|
||||||
|
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
|
||||||
|
- name: test
|
||||||
|
run: Release\flattests.exe
|
||||||
|
- name: test C++17
|
||||||
|
if: matrix.std >= 17
|
||||||
|
run: Release\flattests_cpp17.exe
|
||||||
|
|
||||||
build-windows:
|
build-windows:
|
||||||
name: Build Windows 2019
|
permissions:
|
||||||
runs-on: windows-latest
|
contents: write
|
||||||
|
outputs:
|
||||||
|
digests: ${{ steps.hash.outputs.hashes }}
|
||||||
|
name: Build Windows 2022
|
||||||
|
runs-on: windows-2022
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v6
|
||||||
- name: Add msbuild to PATH
|
- name: Add msbuild to PATH
|
||||||
uses: microsoft/setup-msbuild@v1.1
|
uses: microsoft/setup-msbuild@v2
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON .
|
run: cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON .
|
||||||
- name: build
|
- name: build
|
||||||
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
|
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
|
||||||
- name: test
|
- name: test
|
||||||
run: Release\flattests.exe
|
run: Release\flattests.exe
|
||||||
- name: upload build artifacts
|
- name: upload build artifacts
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Windows flatc binary
|
name: Windows flatc binary
|
||||||
path: Release\flatc.exe
|
path: Release\flatc.exe
|
||||||
|
# Below if only for release.
|
||||||
|
- name: Zip file
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
run: move Release/flatc.exe . && Compress-Archive flatc.exe Windows.flatc.binary.zip
|
||||||
|
- name: Release binary
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
with:
|
||||||
|
files: Windows.flatc.binary.zip
|
||||||
|
- name: Generate SLSA subjects
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
id: hash
|
||||||
|
shell: bash
|
||||||
|
run: echo "hashes=$(sha256sum Windows.flatc.binary.zip | base64 -w0)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
build-windows-2017:
|
build-dotnet-windows:
|
||||||
name: Build Windows 2017
|
name: Build .NET Windows
|
||||||
runs-on: windows-latest
|
runs-on: windows-2022
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
configuration: [
|
||||||
|
'',
|
||||||
|
'-p:UnsafeByteBuffer=true',
|
||||||
|
'-p:EnableSpanT=true,UnsafeByteBuffer=true'
|
||||||
|
]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v6
|
||||||
- name: Add msbuild to PATH
|
- name: Setup .NET Core SDK
|
||||||
uses: microsoft/setup-msbuild@v1.1
|
uses: actions/setup-dotnet@v5
|
||||||
- name: cmake
|
with:
|
||||||
run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release .
|
dotnet-version: '8.0.x'
|
||||||
- name: build tool version 15 (VS 2017)
|
- name: Build
|
||||||
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=15.0
|
|
||||||
- name: test
|
|
||||||
run: Release\flattests.exe
|
|
||||||
|
|
||||||
build-windows-2015:
|
|
||||||
name: Build Windows 2015
|
|
||||||
runs-on: windows-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
- name: Add msbuild to PATH
|
|
||||||
uses: microsoft/setup-msbuild@v1.1
|
|
||||||
- name: cmake
|
|
||||||
run: cmake -G "Visual Studio 14 2015" -A x64 -DCMAKE_BUILD_TYPE=Release .
|
|
||||||
- name: build tool version 14 (VS 2015)
|
|
||||||
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=14.0
|
|
||||||
- name: test
|
|
||||||
run: Release\flattests.exe
|
|
||||||
|
|
||||||
build-mac:
|
|
||||||
name: Build Mac
|
|
||||||
runs-on: macos-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
- name: cmake
|
|
||||||
run: cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_FLATC_EXECUTABLE=_build/Release/flatc .
|
|
||||||
- name: build
|
|
||||||
# NOTE: we need this _build dir to not have xcodebuild's default ./build dir clash with the BUILD file.
|
|
||||||
run: xcodebuild -toolchain clang -configuration Release -target flattests SYMROOT=$(PWD)/_build
|
|
||||||
- name: check that the binary is "universal"
|
|
||||||
run: |
|
run: |
|
||||||
info=$(file _build/Release/flatc)
|
cd tests\FlatBuffers.Test
|
||||||
|
dotnet new sln --force --name FlatBuffers.Test --format sln
|
||||||
|
dotnet sln FlatBuffers.Test.sln add FlatBuffers.Test.csproj
|
||||||
|
dotnet build -c Release ${{matrix.configuration}} FlatBuffers.Test.sln
|
||||||
|
- name: Run net6.0
|
||||||
|
run: |
|
||||||
|
cd tests\FlatBuffers.Test\bin\Release\net6.0
|
||||||
|
dir
|
||||||
|
.\FlatBuffers.Test.exe
|
||||||
|
- name: Run net8.0
|
||||||
|
run: |
|
||||||
|
cd tests\FlatBuffers.Test\bin\Release\net8.0
|
||||||
|
.\FlatBuffers.Test.exe
|
||||||
|
|
||||||
|
build-mac-intel:
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
outputs:
|
||||||
|
digests: ${{ steps.hash.outputs.hashes }}
|
||||||
|
name: Build Mac (for Intel)
|
||||||
|
runs-on: macos-15-intel
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: cmake
|
||||||
|
run: cmake -G "Xcode" -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
||||||
|
- name: build
|
||||||
|
run: xcodebuild -toolchain clang -configuration Release -target flattests
|
||||||
|
- name: check that the binary is x86_64
|
||||||
|
run: |
|
||||||
|
info=$(file Release/flatc)
|
||||||
echo $info
|
echo $info
|
||||||
echo $info | grep "universal binary with 2 architectures"
|
echo $info | grep "Mach-O 64-bit executable x86_64"
|
||||||
- name: test
|
- name: test
|
||||||
run: _build/Release/flattests
|
run: Release/flattests
|
||||||
- name: make flatc executable
|
- name: make flatc executable
|
||||||
run: |
|
run: |
|
||||||
chmod +x _build/Release/flatc
|
chmod +x Release/flatc
|
||||||
./_build/Release/flatc --version
|
Release/flatc --version
|
||||||
- name: upload build artifacts
|
- name: upload build artifacts
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Mac flatc binary
|
name: Mac flatc binary Intel
|
||||||
path: _build/Release/flatc
|
path: Release/flatc
|
||||||
|
# Below if only for release.
|
||||||
|
- name: Zip file
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
run: mv Release/flatc . && zip MacIntel.flatc.binary.zip flatc
|
||||||
|
- name: Release binary
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
with:
|
||||||
|
files: MacIntel.flatc.binary.zip
|
||||||
|
- name: Generate SLSA subjects
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
id: hash
|
||||||
|
run: echo "hashes=$(shasum -a 256 MacIntel.flatc.binary.zip | base64)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
build-mac-universal:
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
outputs:
|
||||||
|
digests: ${{ steps.hash.outputs.hashes }}
|
||||||
|
name: Build Mac (universal build)
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: cmake
|
||||||
|
run: cmake -G "Xcode" -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
||||||
|
- name: build
|
||||||
|
run: xcodebuild -toolchain clang -configuration Release -target flattests
|
||||||
|
- name: check that the binary is "universal"
|
||||||
|
run: |
|
||||||
|
info=$(file Release/flatc)
|
||||||
|
echo $info
|
||||||
|
echo $info | grep "Mach-O universal binary with 2 architectures"
|
||||||
|
- name: test
|
||||||
|
run: Release/flattests
|
||||||
|
- name: make flatc executable
|
||||||
|
run: |
|
||||||
|
chmod +x Release/flatc
|
||||||
|
Release/flatc --version
|
||||||
|
- name: upload build artifacts
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: Mac flatc binary Universal
|
||||||
|
path: Release/flatc
|
||||||
|
# Below if only for release.
|
||||||
|
- name: Zip file
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
run: mv Release/flatc . && zip Mac.flatc.binary.zip flatc
|
||||||
|
- name: Release binary
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
with:
|
||||||
|
files: Mac.flatc.binary.zip
|
||||||
|
- name: Generate SLSA subjects
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
id: hash
|
||||||
|
run: echo "hashes=$(shasum -a 256 Mac.flatc.binary.zip | base64)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
build-android:
|
build-android:
|
||||||
name: Build Android (on Linux)
|
name: Build Android (on Linux)
|
||||||
runs-on: ubuntu-latest
|
if: false #disabled due to continual failure
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v6
|
||||||
- name: set up JDK 1.8
|
- name: set up Java
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
java-version: 1.8
|
distribution: temurin
|
||||||
|
java-version: 17
|
||||||
|
- name: set up Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@v5
|
||||||
- name: set up flatc
|
- name: set up flatc
|
||||||
run: |
|
run: |
|
||||||
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
|
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON .
|
||||||
make
|
make -j
|
||||||
echo "${PWD}" >> $GITHUB_PATH
|
echo "${PWD}" >> $GITHUB_PATH
|
||||||
- name: build
|
- name: build
|
||||||
working-directory: android
|
working-directory: android
|
||||||
run: bash ./gradlew clean build
|
run: gradle clean build
|
||||||
|
|
||||||
build-generator:
|
build-generator:
|
||||||
name: Check Generated Code
|
name: Check Generated Code
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-24.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
cxx: [g++-10, clang++-12]
|
cxx: [g++-13, clang++-18]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v6
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release . && make -j4
|
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
||||||
- name: Generate
|
- name: Generate
|
||||||
run: scripts/check_generate_code.py
|
run: scripts/check_generate_code.py
|
||||||
- name: Generate gRPC
|
- name: Generate gRPC
|
||||||
run: bash scripts/check-grpc-generated-code.sh
|
run: scripts/check-grpc-generated-code.py
|
||||||
|
|
||||||
|
build-generator-windows:
|
||||||
|
name: Check Generated Code on Windows
|
||||||
|
runs-on: windows-2022
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Add msbuild to PATH
|
||||||
|
uses: microsoft/setup-msbuild@v2
|
||||||
|
- name: cmake
|
||||||
|
run: cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON .
|
||||||
|
- name: build
|
||||||
|
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
|
||||||
|
- name: Generate
|
||||||
|
run: python3 scripts/check_generate_code.py --flatc Release\flatc.exe
|
||||||
|
- name: Generate gRPC
|
||||||
|
run: python3 scripts/check-grpc-generated-code.py --flatc Release\flatc.exe
|
||||||
|
|
||||||
build-benchmarks:
|
build-benchmarks:
|
||||||
name: Build Benchmarks (on Linux)
|
name: Build Benchmarks (on Linux)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-24.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
cxx: [g++-10]
|
cxx: [g++-13]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v6
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_CXX_FLAGS="-Wno-unused-parameter -fno-aligned-new" -DFLATBUFFERS_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release . && make -j4
|
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_CXX_FLAGS="-Wno-unused-parameter -fno-aligned-new" -DFLATBUFFERS_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
||||||
- name: Run benchmarks
|
- name: Run benchmarks
|
||||||
run: ./flatbenchmark --benchmark_repetitions=5 --benchmark_display_aggregates_only=true --benchmark_out_format=console --benchmark_out=benchmarks/results_${{matrix.cxx}}
|
run: ./flatbenchmark --benchmark_repetitions=5 --benchmark_display_aggregates_only=true --benchmark_out_format=console --benchmark_out=benchmarks/results_${{matrix.cxx}}
|
||||||
- name: Upload benchmarks results
|
- name: Upload benchmarks results
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Linux flatbenchmark results ${{matrix.cxx}}
|
name: Linux flatbenchmark results ${{matrix.cxx}}
|
||||||
path: benchmarks/results_${{matrix.cxx}}
|
path: benchmarks/results_${{matrix.cxx}}
|
||||||
|
|
||||||
build-java:
|
build-java:
|
||||||
name: Build Java
|
name: Build Java
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v6
|
||||||
- name: test
|
- name: test
|
||||||
working-directory: tests
|
working-directory: java
|
||||||
run: bash JavaTest.sh
|
run: mvn test
|
||||||
|
|
||||||
build-kotlin-macos:
|
build-kotlin-macos:
|
||||||
name: Build Kotlin MacOS
|
name: Build Kotlin MacOS
|
||||||
runs-on: macos-latest
|
runs-on: macos-15
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v6
|
||||||
- uses: actions/setup-java@v2
|
- name: set up Java
|
||||||
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: 'adopt-hotspot'
|
distribution: temurin
|
||||||
java-version: '11'
|
java-version: 17
|
||||||
|
- name: set up Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@v5
|
||||||
|
- name: Build flatc
|
||||||
|
run: |
|
||||||
|
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
|
||||||
|
make -j
|
||||||
|
echo "${PWD}" >> $GITHUB_PATH
|
||||||
- name: Build
|
- name: Build
|
||||||
working-directory: kotlin
|
working-directory: kotlin
|
||||||
run: ./gradlew clean iosX64Test macosX64Test jsTest jsBrowserTest
|
run: ./gradlew clean iosSimulatorArm64Test macosX64Test macosArm64Test
|
||||||
|
|
||||||
build-kotlin-linux:
|
build-kotlin-linux:
|
||||||
name: Build Kotlin Linux
|
name: Build Kotlin Linux
|
||||||
runs-on: ubuntu-latest
|
if: false #disabled due to continual failure
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v6
|
||||||
- uses: actions/setup-java@v2
|
- name: set up Java
|
||||||
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: 'adopt-hotspot'
|
distribution: temurin
|
||||||
java-version: '8'
|
java-version: 17
|
||||||
|
- name: set up Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@v5
|
||||||
|
- name: Build flatc
|
||||||
|
run: |
|
||||||
|
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
|
||||||
|
make -j
|
||||||
|
echo "${PWD}" >> $GITHUB_PATH
|
||||||
- name: Build
|
- name: Build
|
||||||
working-directory: kotlin
|
working-directory: kotlin
|
||||||
run: ./gradlew jvmMainClasses jvmTest
|
# we are using docker's version of gradle
|
||||||
- name: Run Benchmark
|
# so no need for wrapper validation or user
|
||||||
working-directory: kotlin
|
# gradlew
|
||||||
run: ./gradlew jvmBenchmark
|
run: gradle jvmMainClasses jvmTest jsTest jsBrowserTest
|
||||||
- name: Generate Benchmark Report
|
|
||||||
working-directory: kotlin
|
|
||||||
run: |
|
|
||||||
./gradlew jmhReport;
|
|
||||||
mv benchmark/build/reports/benchmarks/main/* benchmark_latest
|
|
||||||
- name: Archive benchmark report
|
|
||||||
uses: actions/upload-artifact@v1
|
|
||||||
with:
|
|
||||||
name: Kotlin Benchmark Report
|
|
||||||
path: kotlin/benchmark_latest
|
|
||||||
|
|
||||||
build-rust:
|
build-rust-linux:
|
||||||
name: Build Rust
|
name: Build Rust Linux
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v6
|
||||||
- name: test
|
- name: test
|
||||||
working-directory: tests
|
working-directory: tests
|
||||||
run: bash RustTest.sh
|
run: bash RustTest.sh
|
||||||
|
|
||||||
|
build-rust-windows:
|
||||||
|
name: Build Rust Windows
|
||||||
|
runs-on: windows-2022
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: test
|
||||||
|
working-directory: tests
|
||||||
|
run: ./RustTest.bat
|
||||||
|
|
||||||
build-python:
|
build-python:
|
||||||
name: Build Python
|
name: Build Python
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v6
|
||||||
|
- name: flatc
|
||||||
|
# FIXME: make test script not rely on flatc
|
||||||
|
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
||||||
- name: test
|
- name: test
|
||||||
working-directory: tests
|
working-directory: tests
|
||||||
run: bash PythonTest.sh
|
run: bash PythonTest.sh
|
||||||
|
|
||||||
build-go:
|
build-go:
|
||||||
name: Build Go
|
name: Build Go
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v6
|
||||||
- name: flatc
|
- name: flatc
|
||||||
# FIXME: make test script not rely on flatc
|
# FIXME: make test script not rely on flatc
|
||||||
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j4
|
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
||||||
- name: test
|
- name: test
|
||||||
working-directory: tests
|
working-directory: tests
|
||||||
run: bash GoTest.sh
|
run: bash GoTest.sh
|
||||||
|
|
||||||
|
build-php:
|
||||||
|
name: Build PHP
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: flatc
|
||||||
|
# FIXME: make test script not rely on flatc
|
||||||
|
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
||||||
|
- name: test
|
||||||
|
working-directory: tests
|
||||||
|
run: |
|
||||||
|
php phpTest.php
|
||||||
|
sh phpUnionVectorTest.sh
|
||||||
|
|
||||||
build-swift:
|
build-swift:
|
||||||
name: Build Swift
|
name: Test Swift Linux
|
||||||
runs-on: ubuntu-latest
|
strategy:
|
||||||
|
matrix:
|
||||||
|
swift: ["6.0", "6.1", "6.2"]
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v6
|
||||||
|
- uses: swift-actions/setup-swift@v2
|
||||||
|
with:
|
||||||
|
swift-version: ${{ matrix.swift }}
|
||||||
|
- name: Get swift version
|
||||||
|
run: swift --version
|
||||||
- name: test
|
- name: test
|
||||||
working-directory: tests/FlatBuffers.Test.Swift
|
run: swift test
|
||||||
run: sh SwiftTest.sh
|
|
||||||
|
build-swift-windows:
|
||||||
|
name: Test swift windows
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: SwiftyLab/setup-swift@latest
|
||||||
|
with:
|
||||||
|
swift-version: '6.1'
|
||||||
|
- run: swift build
|
||||||
|
- run: swift test
|
||||||
|
|
||||||
|
build-swift-wasm:
|
||||||
|
name: Test Swift Wasm
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: swift-actions/setup-swift@v2
|
||||||
|
with:
|
||||||
|
swift-version: 6.2.1
|
||||||
|
- uses: bytecodealliance/actions/wasmtime/setup@v1
|
||||||
|
- name: Install Swift SDK
|
||||||
|
run: swift sdk install https://download.swift.org/swift-6.2.1-release/wasm-sdk/swift-6.2.1-RELEASE/swift-6.2.1-RELEASE_wasm.artifactbundle.tar.gz --checksum 482b9f95462b87bedfafca94a092cf9ec4496671ca13b43745097122d20f18af
|
||||||
|
- name: Test
|
||||||
|
working-directory: tests/swift/Wasm.tests
|
||||||
|
run: |
|
||||||
|
swift sdk list
|
||||||
|
swift build --build-tests --swift-sdk swift-6.2.1-RELEASE_wasm
|
||||||
|
wasmtime --dir . .build/wasm32-unknown-wasip1/debug/FlatBuffers.Test.Swift.WasmPackageTests.xctest --testing-library swift-testing
|
||||||
|
|
||||||
build-ts:
|
build-ts:
|
||||||
name: Build TS
|
name: Build TS
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v6
|
||||||
|
- name: flatc
|
||||||
|
# FIXME: make test script not rely on flatc
|
||||||
|
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j
|
||||||
|
- name: pnpm
|
||||||
|
run: npm install -g pnpm@10
|
||||||
|
- name: deps
|
||||||
|
run: pnpm i
|
||||||
- name: compile
|
- name: compile
|
||||||
run: npm run compile
|
run: pnpm compile
|
||||||
- name: test
|
- name: test
|
||||||
working-directory: tests
|
working-directory: tests/ts
|
||||||
run: sh TypeScriptTest.sh
|
run: |
|
||||||
|
python3 TypeScriptTest.py
|
||||||
|
|
||||||
build-dart:
|
build-dart:
|
||||||
name: Build Dart
|
name: Build Dart
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v6
|
||||||
- uses: dart-lang/setup-dart@v1
|
- uses: dart-lang/setup-dart@v1
|
||||||
with:
|
with:
|
||||||
sdk: stable
|
sdk: stable
|
||||||
- name: flatc
|
- name: flatc
|
||||||
# FIXME: make test script not rely on flatc
|
# FIXME: make test script not rely on flatc
|
||||||
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j4
|
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
||||||
- name: test
|
- name: test
|
||||||
working-directory: tests
|
working-directory: tests
|
||||||
run: bash DartTest.sh
|
run: bash DartTest.sh
|
||||||
|
|
||||||
|
build-nim:
|
||||||
|
name: Build Nim
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: flatc
|
||||||
|
# FIXME: make test script not rely on flatc
|
||||||
|
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j
|
||||||
|
- uses: jiro4989/setup-nim-action@v2
|
||||||
|
- name: install library
|
||||||
|
working-directory: nim
|
||||||
|
run: nimble -y develop && nimble install
|
||||||
|
- name: test
|
||||||
|
working-directory: tests/nim
|
||||||
|
run: python3 testnim.py
|
||||||
|
|
||||||
|
bazel:
|
||||||
|
name: Bazel
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
# Explicitly use 8.5.1 until we can update or https://github.com/actions/runner-images/issues/13564 is fixed.
|
||||||
|
- name: Set env
|
||||||
|
run: >
|
||||||
|
echo "USE_BAZEL_VERSION=8.5.1" >> $GITHUB_ENV
|
||||||
|
- name: bazel build
|
||||||
|
run: >
|
||||||
|
bazel build
|
||||||
|
//:flatc
|
||||||
|
//:flatbuffers
|
||||||
|
//tests:flatbuffers_test
|
||||||
|
- name: bazel test
|
||||||
|
run: >
|
||||||
|
bazel test
|
||||||
|
//tests:flatbuffers_test
|
||||||
|
|
||||||
|
release-digests:
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
needs: [build-linux, build-windows, build-mac-intel, build-mac-universal]
|
||||||
|
outputs:
|
||||||
|
digests: ${{ steps.hash.outputs.digests }}
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- name: Merge results
|
||||||
|
id: hash
|
||||||
|
env:
|
||||||
|
LINUXGCC_DIGESTS: "${{ needs.build-linux.outputs.digests-gcc }}"
|
||||||
|
LINUXCLANG_DIGESTS: "${{ needs.build-linux.outputs.digests-clang }}"
|
||||||
|
MAC_DIGESTS: "${{ needs.build-mac-universal.outputs.digests }}"
|
||||||
|
MACINTEL_DIGESTS: "${{ needs.build-mac-intel.outputs.digests }}"
|
||||||
|
WINDOWS_DIGESTS: "${{ needs.build-windows.outputs.digests }}"
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
echo "$LINUXGCC_DIGESTS" | base64 -d > checksums.txt
|
||||||
|
echo "$LINUXCLANG_DIGESTS" | base64 -d >> checksums.txt
|
||||||
|
echo "$MAC_DIGESTS" | base64 -d >> checksums.txt
|
||||||
|
echo "$MACINTEL_DIGESTS" | base64 -d >> checksums.txt
|
||||||
|
echo "$WINDOWS_DIGESTS" | base64 -d >> checksums.txt
|
||||||
|
echo "digests=$(cat checksums.txt | base64 -w0)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
provenance:
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
needs: [release-digests]
|
||||||
|
permissions:
|
||||||
|
actions: read # To read the workflow path.
|
||||||
|
id-token: write # To sign the provenance.
|
||||||
|
contents: write # To add assets to a release.
|
||||||
|
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.1.0
|
||||||
|
with:
|
||||||
|
base64-subjects: "${{ needs.release-digests.outputs.digests }}"
|
||||||
|
upload-assets: true # Optional: Upload to a new release
|
||||||
|
|||||||
36
.github/workflows/docs.yml
vendored
Normal file
36
.github/workflows/docs.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
name: docs
|
||||||
|
on:
|
||||||
|
# For manual pushes.
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# Pushes to main that touch the documentation directory.
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths:
|
||||||
|
- 'docs/**'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Configure Git Credentials
|
||||||
|
run: |
|
||||||
|
git config user.name github-actions[bot]
|
||||||
|
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
||||||
|
- uses: actions/setup-python@v6
|
||||||
|
with:
|
||||||
|
python-version: 3.x
|
||||||
|
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
|
||||||
|
- uses: actions/cache@v5
|
||||||
|
with:
|
||||||
|
key: mkdocs-material-${{ env.cache_id }}
|
||||||
|
path: .cache
|
||||||
|
restore-keys: |
|
||||||
|
mkdocs-material-
|
||||||
|
- run: pip install mkdocs-material
|
||||||
|
- run: pip install mkdocs-redirects
|
||||||
|
- run: mkdocs gh-deploy --force -f docs/mkdocs.yml
|
||||||
11
.github/workflows/label.yml
vendored
11
.github/workflows/label.yml
vendored
@@ -6,14 +6,19 @@
|
|||||||
# https://github.com/actions/labeler
|
# https://github.com/actions/labeler
|
||||||
|
|
||||||
name: Labeler
|
name: Labeler
|
||||||
|
permissions: read-all
|
||||||
|
|
||||||
on: [pull_request_target]
|
on: [pull_request_target]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
label:
|
label:
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/labeler@main
|
- uses: actions/labeler@v6
|
||||||
with:
|
with:
|
||||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
|||||||
34
.github/workflows/main.yml
vendored
Normal file
34
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
name: OSS-Fuzz
|
||||||
|
permissions: read-all
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths:
|
||||||
|
- include/**
|
||||||
|
- src/**
|
||||||
|
- tests/**.cpp
|
||||||
|
- tests/**.h
|
||||||
|
jobs:
|
||||||
|
Fuzzing:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Build Fuzzers
|
||||||
|
id: build
|
||||||
|
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
|
||||||
|
with:
|
||||||
|
oss-fuzz-project-name: 'flatbuffers'
|
||||||
|
language: c++
|
||||||
|
- name: Run Fuzzers
|
||||||
|
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
|
||||||
|
with:
|
||||||
|
oss-fuzz-project-name: 'flatbuffers'
|
||||||
|
language: c++
|
||||||
|
fuzz-seconds: 60
|
||||||
|
- name: Upload Crash
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
if: failure() && steps.build.outcome == 'success'
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: ./out/artifacts
|
||||||
152
.github/workflows/release.yml
vendored
Normal file
152
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
name: Release
|
||||||
|
permissions: read-all
|
||||||
|
|
||||||
|
on:
|
||||||
|
# For manual tests.
|
||||||
|
workflow_dispatch:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish-npm:
|
||||||
|
name: Publish NPM
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '20.x'
|
||||||
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
|
||||||
|
- run: npm publish
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
|
publish-pypi:
|
||||||
|
name: Publish PyPi
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: ./python
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-python@v6
|
||||||
|
with:
|
||||||
|
python-version: '3.10'
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: |
|
||||||
|
python3 -m pip install --upgrade pip
|
||||||
|
python3 -m pip install build twine
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
python3 -m build .
|
||||||
|
|
||||||
|
- name: Upload to PyPi
|
||||||
|
run: |
|
||||||
|
python3 -m twine upload dist/*
|
||||||
|
env:
|
||||||
|
TWINE_USERNAME: __token__
|
||||||
|
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }}
|
||||||
|
|
||||||
|
publish-nuget:
|
||||||
|
name: Publish NuGet
|
||||||
|
runs-on: windows-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: ./net/flatbuffers
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-dotnet@v5
|
||||||
|
with:
|
||||||
|
dotnet-version: '8.0.x'
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
dotnet build Google.FlatBuffers.csproj -c Release
|
||||||
|
|
||||||
|
- name: Pack
|
||||||
|
run: |
|
||||||
|
dotnet pack Google.FlatBuffers.csproj -c Release
|
||||||
|
|
||||||
|
- name: Upload to NuGet
|
||||||
|
run: |
|
||||||
|
dotnet nuget push .\bin\Release\Google.FlatBuffers.*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
|
||||||
|
|
||||||
|
publish-maven:
|
||||||
|
name: Publish Maven
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: ./java
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Set up Maven Central Repository
|
||||||
|
uses: actions/setup-java@v5
|
||||||
|
with:
|
||||||
|
java-version: '11'
|
||||||
|
distribution: 'adopt'
|
||||||
|
cache: 'maven'
|
||||||
|
server-id: ossrh
|
||||||
|
server-username: OSSRH_USERNAME
|
||||||
|
server-password: OSSRH_PASSWORD
|
||||||
|
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
|
||||||
|
gpg-passphrase: MAVEN_GPG_PASSPHRASE # this needs to be an env var
|
||||||
|
|
||||||
|
- name: Publish Maven
|
||||||
|
run: mvn --batch-mode clean deploy
|
||||||
|
env:
|
||||||
|
OSSRH_USERNAME: ${{ secrets.OSSRH_USER_V2 }}
|
||||||
|
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN_V2 }}
|
||||||
|
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
|
||||||
|
|
||||||
|
publish-maven-kotlin:
|
||||||
|
name: Publish Maven - Kotlin
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: ./kotlin
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Set up Maven Central Repository
|
||||||
|
uses: actions/setup-java@v5
|
||||||
|
with:
|
||||||
|
java-version: '11'
|
||||||
|
distribution: 'adopt'
|
||||||
|
cache: 'maven'
|
||||||
|
server-id: ossrh
|
||||||
|
server-username: OSSRH_USERNAME
|
||||||
|
server-password: OSSRH_PASSWORD
|
||||||
|
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
|
||||||
|
gpg-passphrase: MAVEN_GPG_PASSPHRASE # this needs to be an env var
|
||||||
|
|
||||||
|
- name: Publish Kotlin Library on Maven
|
||||||
|
run: ./gradlew publishAllPublicationsToSonatypeRepository
|
||||||
|
env:
|
||||||
|
OSSRH_USERNAME: ${{ secrets.OSSRH_USER_V2 }}
|
||||||
|
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN_V2 }}
|
||||||
|
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
|
||||||
|
|
||||||
|
|
||||||
|
publish-crates:
|
||||||
|
name: Publish crates.io
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Publish Flatbuffers
|
||||||
|
uses: katyo/publish-crates@v2
|
||||||
|
with:
|
||||||
|
path: ./rust/flatbuffers
|
||||||
|
registry-token: ${{ secrets.CARGO_TOKEN }}
|
||||||
|
|
||||||
|
- name: Publish Flexbuffers
|
||||||
|
uses: katyo/publish-crates@v2
|
||||||
|
with:
|
||||||
|
path: ./rust/flexbuffers
|
||||||
|
registry-token: ${{ secrets.CARGO_TOKEN }}
|
||||||
32
.github/workflows/stale.yml
vendored
32
.github/workflows/stale.yml
vendored
@@ -1,8 +1,13 @@
|
|||||||
name: Mark stale issues and pull requests
|
name: Mark stale issues and pull requests
|
||||||
|
permissions:
|
||||||
|
issues: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
# For manual tests.
|
||||||
|
workflow_dispatch:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "30 20 * * *"
|
- cron: "30 20 * * *"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
stale:
|
stale:
|
||||||
@@ -10,14 +15,23 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@v4.0.0
|
- uses: actions/stale@v10
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
stale-pr-message: 'This pull request is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.'
|
operations-per-run: 500
|
||||||
stale-issue-message: 'This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.'
|
|
||||||
days-before-stale: 182 # 6 months
|
|
||||||
days-before-close: 14
|
|
||||||
operations-per-run: 1500
|
|
||||||
exempt-issue-labels: not-stale
|
|
||||||
exempt-pr-labels: not-stale
|
|
||||||
exempt-all-milestones: true
|
exempt-all-milestones: true
|
||||||
|
remove-stale-when-updated: true
|
||||||
|
|
||||||
|
stale-issue-message: 'This issue is stale because it has been open 6 months with no activity. Please comment or label `not-stale`, or this will be closed in 14 days.'
|
||||||
|
close-issue-message: 'This issue was automatically closed due to no activity for 6 months plus the 14 day notice period.'
|
||||||
|
days-before-issue-stale: 182 # 6 months
|
||||||
|
days-before-issue-close: 14 # 2 weeks
|
||||||
|
exempt-issue-labels: not-stale
|
||||||
|
|
||||||
|
stale-pr-message: 'This pull request is stale because it has been open 6 months with no activity. Please comment or label `not-stale`, or this will be closed in 14 days.'
|
||||||
|
close-pr-message: 'This pull request was automatically closed due to no activity for 6 months plus the 14 day notice period.'
|
||||||
|
days-before-pr-stale: 182 # 6 months
|
||||||
|
days-before-pr-close: 14 # 2 week
|
||||||
|
exempt-pr-labels: not-stale
|
||||||
|
exempt-draft-pr: false
|
||||||
|
|
||||||
|
|||||||
17
.gitignore
vendored
17
.gitignore
vendored
@@ -54,6 +54,8 @@ flathash
|
|||||||
flathash.exe
|
flathash.exe
|
||||||
flattests
|
flattests
|
||||||
flattests.exe
|
flattests.exe
|
||||||
|
flattests_cpp17
|
||||||
|
flattests_cpp17.exe
|
||||||
flatsamplebinary
|
flatsamplebinary
|
||||||
flatsamplebinary.exe
|
flatsamplebinary.exe
|
||||||
flatsampletext
|
flatsampletext
|
||||||
@@ -76,7 +78,7 @@ tests/php/
|
|||||||
CMakeLists.txt.user
|
CMakeLists.txt.user
|
||||||
CMakeScripts/**
|
CMakeScripts/**
|
||||||
CTestTestfile.cmake
|
CTestTestfile.cmake
|
||||||
FlatbuffersConfigVersion.cmake
|
flatbuffers-config-version.cmake
|
||||||
FlatBuffers.cbp
|
FlatBuffers.cbp
|
||||||
build/Xcode/FlatBuffers.xcodeproj/project.xcworkspace/**
|
build/Xcode/FlatBuffers.xcodeproj/project.xcworkspace/**
|
||||||
build/Xcode/FlatBuffers.xcodeproj/xcuserdata/**
|
build/Xcode/FlatBuffers.xcodeproj/xcuserdata/**
|
||||||
@@ -86,6 +88,7 @@ java/*.iml
|
|||||||
.idea
|
.idea
|
||||||
*.iml
|
*.iml
|
||||||
target
|
target
|
||||||
|
java/target
|
||||||
**/*.pyc
|
**/*.pyc
|
||||||
build/VS2010/FlatBuffers.sdf
|
build/VS2010/FlatBuffers.sdf
|
||||||
build/VS2010/FlatBuffers.opensdf
|
build/VS2010/FlatBuffers.opensdf
|
||||||
@@ -146,4 +149,14 @@ flatbuffers.pc
|
|||||||
**/html/**
|
**/html/**
|
||||||
**/latex/**
|
**/latex/**
|
||||||
# https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_BASE_DIR
|
# https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_BASE_DIR
|
||||||
_deps/
|
cmake-build-debug/
|
||||||
|
_deps/
|
||||||
|
**/.gradle/**
|
||||||
|
kotlin/**/generated
|
||||||
|
MODULE.bazel.lock
|
||||||
|
|
||||||
|
# Ignore the generated docs
|
||||||
|
docs/site
|
||||||
|
|
||||||
|
# Ignore generated files
|
||||||
|
*.fbs.h
|
||||||
|
|||||||
215
.travis.yml
215
.travis.yml
@@ -1,215 +0,0 @@
|
|||||||
env:
|
|
||||||
global:
|
|
||||||
# Set at the root level as this is ignored when set under matrix.env.
|
|
||||||
- GCC_VERSION="4.9"
|
|
||||||
# Fail on first error if UBSAN or ASAN enabled for a target
|
|
||||||
- UBSAN_OPTIONS=halt_on_error=1
|
|
||||||
- ASAN_OPTIONS=halt_on_error=1
|
|
||||||
# Travis machines have 2 cores
|
|
||||||
- JOBS=2
|
|
||||||
- MAKEFLAGS="-j 2"
|
|
||||||
|
|
||||||
conan-linux: &conan-linux
|
|
||||||
os: linux
|
|
||||||
dist: xenial
|
|
||||||
language: python
|
|
||||||
python: "3.7"
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
install:
|
|
||||||
- ./conan/travis/install.sh
|
|
||||||
script:
|
|
||||||
- ./conan/travis/build.sh
|
|
||||||
if: tag IS present
|
|
||||||
|
|
||||||
conan-linux-master: &conan-linux-master
|
|
||||||
os: linux
|
|
||||||
dist: xenial
|
|
||||||
language: python
|
|
||||||
python: "3.7"
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
install:
|
|
||||||
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./conan/travis/install.sh; fi'
|
|
||||||
script:
|
|
||||||
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./conan/travis/build.sh; fi'
|
|
||||||
branches:
|
|
||||||
only:
|
|
||||||
- master
|
|
||||||
|
|
||||||
conan-osx: &conan-osx
|
|
||||||
os: osx
|
|
||||||
language: generic
|
|
||||||
install:
|
|
||||||
- ./conan/travis/install.sh
|
|
||||||
script:
|
|
||||||
- ./conan/travis/build.sh
|
|
||||||
if: tag IS present
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
#- language: python
|
|
||||||
# python: "2.7"
|
|
||||||
# install:
|
|
||||||
# - "pip install wheel twine"
|
|
||||||
# script:
|
|
||||||
# - "cd python/"
|
|
||||||
# - 'VERSION="$TRAVIS_TAG" python setup.py sdist bdist_wheel'
|
|
||||||
# - "cd ../"
|
|
||||||
# deploy:
|
|
||||||
# # Checkpointed release builds.
|
|
||||||
# - provider: script
|
|
||||||
# script: .travis/deploy-python.sh
|
|
||||||
# skip_cleanup: true
|
|
||||||
# on:
|
|
||||||
# tags: true
|
|
||||||
# # all_branches must be set with tags: true. See below post:
|
|
||||||
# # https://stackoverflow.com/a/27775257/1076585
|
|
||||||
# all_branches: true
|
|
||||||
# # Produce a new build for the cutting edge when master changes.
|
|
||||||
# - provider: script
|
|
||||||
# script: .travis/deploy-python.sh
|
|
||||||
# skip_cleanup: true
|
|
||||||
# on:
|
|
||||||
# branch: master
|
|
||||||
- language: cpp
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- docker-ce
|
|
||||||
script:
|
|
||||||
- bash .travis/build-and-run-docker-test-containers.sh
|
|
||||||
|
|
||||||
- language: cpp
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
|
|
||||||
compiler:
|
|
||||||
- gcc
|
|
||||||
|
|
||||||
env:
|
|
||||||
matrix:
|
|
||||||
- BUILD_TYPE=Debug
|
|
||||||
- BUILD_TYPE=Release
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; fi
|
|
||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq; fi
|
|
||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq g++-$GCC_VERSION; fi
|
|
||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq gcc-$GCC_VERSION; fi
|
|
||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which g++-$GCC_VERSION) /usr/bin/g++; fi
|
|
||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which gcc-$GCC_VERSION) /usr/bin/gcc; fi
|
|
||||||
|
|
||||||
script:
|
|
||||||
- pip install cmake
|
|
||||||
- bash .travis/check-sources.sh
|
|
||||||
- bash grpc/build_grpc.sh
|
|
||||||
- cmake .
|
|
||||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
|
||||||
-DFLATBUFFERS_BUILD_GRPCTEST=ON
|
|
||||||
-DGRPC_INSTALL_PATH=$TRAVIS_BUILD_DIR/google/grpc/install
|
|
||||||
-DPROTOBUF_DOWNLOAD_PATH=$TRAVIS_BUILD_DIR/google/grpc/third_party/protobuf
|
|
||||||
-DFLATBUFFERS_CODE_SANITIZE=ON
|
|
||||||
- cmake --build . --target all --clean-first -- -j${JOBS}
|
|
||||||
- LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/google/grpc/install/lib ctest --extra-verbose --output-on-failure
|
|
||||||
|
|
||||||
- language: cpp
|
|
||||||
os: osx
|
|
||||||
osx_image: xcode9.3
|
|
||||||
env:
|
|
||||||
matrix:
|
|
||||||
- BUILD_TYPE=Debug
|
|
||||||
- BUILD_TYPE=Release
|
|
||||||
|
|
||||||
script:
|
|
||||||
- pip install --user cmake
|
|
||||||
- mkdir ~/cmake_path
|
|
||||||
- ln -s $(find ~/Library/Python -name cmake -type f | head -n 1) ~/cmake_path/cmake
|
|
||||||
- ln -s $(find ~/Library/Python -name ctest -type f | head -n 1) ~/cmake_path/ctest
|
|
||||||
- export PATH=~/cmake_path:${PATH}
|
|
||||||
- bash grpc/build_grpc.sh
|
|
||||||
- cmake .
|
|
||||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
|
||||||
-DFLATBUFFERS_BUILD_GRPCTEST=ON
|
|
||||||
-DGRPC_INSTALL_PATH=$TRAVIS_BUILD_DIR/google/grpc/install
|
|
||||||
-DPROTOBUF_DOWNLOAD_PATH=$TRAVIS_BUILD_DIR/google/grpc/third_party/protobuf
|
|
||||||
-DFLATBUFFERS_CODE_SANITIZE=ON
|
|
||||||
- cmake --build . -- -j${JOBS}
|
|
||||||
- DYLD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/google/grpc/install/lib ctest --extra-verbose --output-on-failure
|
|
||||||
|
|
||||||
- <<: *conan-linux-master
|
|
||||||
env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8
|
|
||||||
- <<: *conan-linux
|
|
||||||
env: CONAN_GCC_VERSIONS=4.9 CONAN_DOCKER_IMAGE=conanio/gcc49
|
|
||||||
- <<: *conan-linux
|
|
||||||
env: CONAN_GCC_VERSIONS=5 CONAN_DOCKER_IMAGE=conanio/gcc5
|
|
||||||
- <<: *conan-linux
|
|
||||||
env: CONAN_GCC_VERSIONS=6 CONAN_DOCKER_IMAGE=conanio/gcc6
|
|
||||||
- <<: *conan-linux
|
|
||||||
env: CONAN_GCC_VERSIONS=7 CONAN_DOCKER_IMAGE=conanio/gcc7
|
|
||||||
- <<: *conan-linux
|
|
||||||
env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8
|
|
||||||
- <<: *conan-linux
|
|
||||||
env: CONAN_GCC_VERSIONS=9 CONAN_DOCKER_IMAGE=conanio/gcc9
|
|
||||||
- <<: *conan-linux
|
|
||||||
env: CONAN_CLANG_VERSIONS=3.9 CONAN_DOCKER_IMAGE=conanio/clang39
|
|
||||||
- <<: *conan-linux
|
|
||||||
env: CONAN_CLANG_VERSIONS=4.0 CONAN_DOCKER_IMAGE=conanio/clang40
|
|
||||||
- <<: *conan-linux
|
|
||||||
env: CONAN_CLANG_VERSIONS=5.0 CONAN_DOCKER_IMAGE=conanio/clang50
|
|
||||||
- <<: *conan-linux
|
|
||||||
env: CONAN_CLANG_VERSIONS=6.0 CONAN_DOCKER_IMAGE=conanio/clang60
|
|
||||||
- <<: *conan-linux
|
|
||||||
env: CONAN_CLANG_VERSIONS=7.0 CONAN_DOCKER_IMAGE=conanio/clang7
|
|
||||||
- <<: *conan-linux
|
|
||||||
env: CONAN_CLANG_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/clang8
|
|
||||||
- <<: *conan-osx
|
|
||||||
osx_image: xcode7.3
|
|
||||||
env: CONAN_APPLE_CLANG_VERSIONS=7.3
|
|
||||||
- <<: *conan-osx
|
|
||||||
osx_image: xcode8.3
|
|
||||||
env: CONAN_APPLE_CLANG_VERSIONS=8.1
|
|
||||||
- <<: *conan-osx
|
|
||||||
osx_image: xcode9
|
|
||||||
env: CONAN_APPLE_CLANG_VERSIONS=9.0
|
|
||||||
- <<: *conan-osx
|
|
||||||
osx_image: xcode9.4
|
|
||||||
env: CONAN_APPLE_CLANG_VERSIONS=9.1
|
|
||||||
- <<: *conan-osx
|
|
||||||
osx_image: xcode10.2
|
|
||||||
env: CONAN_APPLE_CLANG_VERSIONS=10.0
|
|
||||||
|
|
||||||
- language: android
|
|
||||||
sudo: true
|
|
||||||
dist: trusty
|
|
||||||
android:
|
|
||||||
components:
|
|
||||||
- tools
|
|
||||||
- platform-tools
|
|
||||||
- extra-android-m2repository
|
|
||||||
licenses:
|
|
||||||
- 'android-sdk-preview-license-52d11cd2'
|
|
||||||
- 'android-sdk-license-.+'
|
|
||||||
- 'google-gdk-license-.+'
|
|
||||||
compiler:
|
|
||||||
- gcc
|
|
||||||
before_install:
|
|
||||||
- echo y | sdkmanager "platforms;android-30"
|
|
||||||
- echo y | sdkmanager "build-tools;30.0.2"
|
|
||||||
- echo y | sdkmanager "ndk-bundle"
|
|
||||||
- echo y | sdkmanager "cmake;3.6.4111459"
|
|
||||||
script:
|
|
||||||
- cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .; make; export PATH="$PATH:${PWD}"
|
|
||||||
- cd android; ./gradlew clean build
|
|
||||||
|
|
||||||
- language: generic
|
|
||||||
if: type IN (pull_request)
|
|
||||||
os: linux
|
|
||||||
install:
|
|
||||||
- bash .travis/format_install.sh
|
|
||||||
|
|
||||||
script:
|
|
||||||
- bash .travis/format_check.sh
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Copyright 2018 Google Inc. 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.
|
|
||||||
set -e
|
|
||||||
|
|
||||||
docker build -t build_cpp_image -f tests/docker/Dockerfile.testing.cpp.debian_buster .
|
|
||||||
# Run tests with sanitizers (--cap-add SYS_PTRACE), both GCC and Clang.
|
|
||||||
cpp_test_args="--cap-add SYS_PTRACE build_cpp_image sh ./tests/docker/cpp_test.run.sh Debug"
|
|
||||||
docker run --rm $cpp_test_args
|
|
||||||
docker run --rm --env CC=/usr/bin/clang --env CXX=/usr/bin/clang++ $cpp_test_args
|
|
||||||
# Build flatc on debian once to speed up the test loop below.
|
|
||||||
docker run --name flatc_container build_cpp_image sh ./tests/docker/build_flatc.run.sh Debug
|
|
||||||
# All dependent dockers refer to 'flatc_debian_stretch'.
|
|
||||||
docker cp flatc_container:/flatbuffers/flatc flatc_debian_stretch
|
|
||||||
|
|
||||||
for f in $(ls tests/docker/languages | sort)
|
|
||||||
do
|
|
||||||
# docker pull sometimes fails for unknown reasons, probably travisci-related. this retries the pull we need a few times.
|
|
||||||
REQUIRED_BASE_IMAGE=$(cat tests/docker/languages/${f} | head -n 1 | awk ' { print $2 } ')
|
|
||||||
|
|
||||||
set +e
|
|
||||||
n=0
|
|
||||||
until [ $n -ge 5 ]
|
|
||||||
do
|
|
||||||
docker pull $REQUIRED_BASE_IMAGE && break
|
|
||||||
n=$[$n+1]
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
set -e
|
|
||||||
|
|
||||||
docker build -t $(echo ${f} | cut -f 3- -d .) -f tests/docker/languages/${f} .
|
|
||||||
echo "TEST OK: ${f}"
|
|
||||||
done
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Copyright 2018 Google Inc. 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.
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ -n "$1" ]; then
|
|
||||||
scan_dir="$1"
|
|
||||||
else
|
|
||||||
scan_dir="$( pwd )"
|
|
||||||
fi
|
|
||||||
|
|
||||||
py_checker="$0.py"
|
|
||||||
|
|
||||||
echo "scan root directory = '$scan_dir'"
|
|
||||||
python3 --version
|
|
||||||
# Scan recursively and search all *.cpp and *.h files using regex patterns.
|
|
||||||
# Assume that script running from a root of Flatbuffers working dir.
|
|
||||||
python3 $py_checker "ascii" "$scan_dir/include" "\.h$"
|
|
||||||
python3 $py_checker "ascii" "$scan_dir/src" "\.cpp$"
|
|
||||||
python3 $py_checker "ascii" "$scan_dir/tests" "\.h$"
|
|
||||||
python3 $py_checker "utf-8" "$scan_dir/tests" "\.cpp$"
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
import os
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def check_encoding(encoding, scan_dir, regex_pattern):
|
|
||||||
fname = None
|
|
||||||
try:
|
|
||||||
assert encoding in ['ascii', 'utf-8'], "unexpected encoding"
|
|
||||||
cmp = re.compile(regex_pattern)
|
|
||||||
for root, dirs, files in os.walk(scan_dir):
|
|
||||||
fname = root
|
|
||||||
cmp_list = [f for f in files if cmp.search(f) is not None]
|
|
||||||
for f in cmp_list:
|
|
||||||
fname = os.path.join(root, f)
|
|
||||||
with open(fname, mode='rb') as test_file:
|
|
||||||
btext = test_file.read()
|
|
||||||
# check encoding
|
|
||||||
btext.decode(encoding=encoding, errors="strict")
|
|
||||||
if encoding == "utf-8" and btext.startswith(b'\xEF\xBB\xBF'):
|
|
||||||
raise ValueError("unexpected BOM in file")
|
|
||||||
# check LF line endings
|
|
||||||
LF = btext.count(b'\n')
|
|
||||||
CR = btext.count(b'\r')
|
|
||||||
if CR!=0:
|
|
||||||
raise ValueError("invalid line endings: LF({})/CR({})".format(LF, CR))
|
|
||||||
except Exception as err:
|
|
||||||
print("ERROR with [{}]: {}".format(fname, err))
|
|
||||||
return -1
|
|
||||||
else:
|
|
||||||
return 0
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
# python check-sources.sh.py 'ascii' '.' '.*\.(cpp|h)$'
|
|
||||||
res = check_encoding(sys.argv[1], sys.argv[2], sys.argv[3])
|
|
||||||
sys.exit(0 if res == 0 else -1)
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
PROD_REPOSITORY="https://upload.pypi.org/legacy/"
|
|
||||||
TEST_REPOSITORY="https://test.pypi.org/legacy/"
|
|
||||||
|
|
||||||
twine upload \
|
|
||||||
--username "$PYPI_USERNAME" \
|
|
||||||
--password "$PYPI_PASSWORD" \
|
|
||||||
--repository-url "$PROD_REPOSITORY" \
|
|
||||||
"$DIR/../python/dist/"*
|
|
||||||
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Copyright 2021 Google Inc. 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.
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# HACKY solution to make nodejs work.
|
|
||||||
source ~/.nvm/nvm.sh
|
|
||||||
nvm alias default node
|
|
||||||
nvm use default
|
|
||||||
|
|
||||||
sh scripts/clang-format-git.sh
|
|
||||||
|
|
||||||
# Check formatting for go lang
|
|
||||||
|
|
||||||
cd go
|
|
||||||
gofmt -w .
|
|
||||||
cd ..
|
|
||||||
cd grpc/examples/go
|
|
||||||
sh format.sh
|
|
||||||
cd ../../..
|
|
||||||
|
|
||||||
node_modules/.bin/eslint ts/** --ext .ts --quiet --fix
|
|
||||||
|
|
||||||
#PYTHON IS DISABLED UNTIL WE CREATE A .pylintrc FILE FOR IT
|
|
||||||
pylint python/** --disable=all
|
|
||||||
|
|
||||||
swiftformat --config swift.swiftformat .
|
|
||||||
|
|
||||||
|
|
||||||
if ! git diff --quiet; then
|
|
||||||
echo >&2
|
|
||||||
echo "ERROR: ********************************************************" >&2
|
|
||||||
echo "ERROR: The following differences were found after running" >&2
|
|
||||||
echo "ERROR: .travis/format_check.sh script. Maybe you forgot to format" >&2
|
|
||||||
echo "ERROR: the code after making changes? please check Formatters.md" >&2
|
|
||||||
echo "ERROR: ********************************************************" >&2
|
|
||||||
echo >&2
|
|
||||||
git diff --binary --exit-code
|
|
||||||
fi
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Copyright 2020 Google Inc. 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.
|
|
||||||
|
|
||||||
set -e
|
|
||||||
set -x
|
|
||||||
|
|
||||||
# install devtools
|
|
||||||
install_languages() {
|
|
||||||
sudo apt update
|
|
||||||
|
|
||||||
# Install nodeJS and yarn
|
|
||||||
wget https://raw.githubusercontent.com/creationix/nvm/v0.31.0/nvm.sh -O ~/.nvm/nvm.sh
|
|
||||||
source ~/.nvm/nvm.sh
|
|
||||||
nvm install node
|
|
||||||
node --version
|
|
||||||
curl -o- -L https://yarnpkg.com/install.sh | bash
|
|
||||||
export PATH="$HOME/.yarn/bin:$PATH"
|
|
||||||
yarn config set prefix ~/.yarn -g
|
|
||||||
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
|
|
||||||
|
|
||||||
# Install swift
|
|
||||||
sudo apt-get install \
|
|
||||||
binutils \
|
|
||||||
git \
|
|
||||||
libc6-dev \
|
|
||||||
libcurl3 \
|
|
||||||
libedit2 \
|
|
||||||
libgcc-5-dev \
|
|
||||||
libpython2.7 \
|
|
||||||
libsqlite3-0 \
|
|
||||||
libstdc++-5-dev \
|
|
||||||
libxml2 \
|
|
||||||
pkg-config \
|
|
||||||
tzdata \
|
|
||||||
zlib1g-dev
|
|
||||||
|
|
||||||
SWIFT_URL=https://swift.org/builds/swift-5.3.1-release/ubuntu1604/swift-5.3.1-RELEASE/swift-5.3.1-RELEASE-ubuntu16.04.tar.gz
|
|
||||||
curl -fSsL "$SWIFT_URL" -o swift.tar.gz
|
|
||||||
|
|
||||||
mkdir ~/swiftbuild
|
|
||||||
tar -xvzf swift.tar.gz -C ~/swiftbuild
|
|
||||||
|
|
||||||
export PATH="~/swiftbuild/swift-5.3.1-RELEASE-ubuntu16.04/usr/bin:$PATH"
|
|
||||||
|
|
||||||
|
|
||||||
mkdir ~/gobuild
|
|
||||||
wget -c https://golang.org/dl/go1.15.2.linux-amd64.tar.gz
|
|
||||||
tar -xvzf go1.15.2.linux-amd64.tar.gz -C ~/gobuild
|
|
||||||
|
|
||||||
export PATH="~/gobuild/go/bin:$PATH"
|
|
||||||
|
|
||||||
swift --version
|
|
||||||
go version
|
|
||||||
yarn -v
|
|
||||||
node -v
|
|
||||||
}
|
|
||||||
|
|
||||||
install_formatters() {
|
|
||||||
# installing swift formatter
|
|
||||||
git clone --depth 1 --branch 0.47.4 https://github.com/nicklockwood/SwiftFormat.git
|
|
||||||
cd SwiftFormat
|
|
||||||
swift build -c release
|
|
||||||
sudo cp .build/release/swiftformat /usr/local/bin/swiftformat
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
which yarn
|
|
||||||
which node
|
|
||||||
yarn -v
|
|
||||||
node -v
|
|
||||||
|
|
||||||
yarn install
|
|
||||||
pip install pylint
|
|
||||||
}
|
|
||||||
|
|
||||||
install_languages
|
|
||||||
export PATH="~/swift/swift/usr/bin:$PATH"
|
|
||||||
install_formatters
|
|
||||||
38
BUILD.bazel
38
BUILD.bazel
@@ -8,6 +8,7 @@ package(
|
|||||||
|
|
||||||
exports_files([
|
exports_files([
|
||||||
"LICENSE",
|
"LICENSE",
|
||||||
|
"tsconfig.json",
|
||||||
])
|
])
|
||||||
|
|
||||||
config_setting(
|
config_setting(
|
||||||
@@ -24,6 +25,28 @@ config_setting(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
filegroup(
|
||||||
|
name = "distribution",
|
||||||
|
srcs = [
|
||||||
|
".bazelignore",
|
||||||
|
".npmrc",
|
||||||
|
"BUILD.bazel",
|
||||||
|
"MODULE.bazel",
|
||||||
|
"build_defs.bzl",
|
||||||
|
"package.json",
|
||||||
|
"pnpm-lock.yaml",
|
||||||
|
"typescript.bzl",
|
||||||
|
"//grpc/src/compiler:distribution",
|
||||||
|
"//include/codegen:distribution",
|
||||||
|
"//reflection:distribution",
|
||||||
|
"//src:distribution",
|
||||||
|
"//ts:distribution",
|
||||||
|
] + glob([
|
||||||
|
"include/flatbuffers/*.h",
|
||||||
|
]),
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
|
||||||
# Public flatc library to compile flatbuffer files at runtime.
|
# Public flatc library to compile flatbuffer files at runtime.
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "flatbuffers",
|
name = "flatbuffers",
|
||||||
@@ -40,14 +63,16 @@ filegroup(
|
|||||||
"include/flatbuffers/allocator.h",
|
"include/flatbuffers/allocator.h",
|
||||||
"include/flatbuffers/array.h",
|
"include/flatbuffers/array.h",
|
||||||
"include/flatbuffers/base.h",
|
"include/flatbuffers/base.h",
|
||||||
"include/flatbuffers/bfbs_generator.h",
|
|
||||||
"include/flatbuffers/buffer.h",
|
"include/flatbuffers/buffer.h",
|
||||||
"include/flatbuffers/buffer_ref.h",
|
"include/flatbuffers/buffer_ref.h",
|
||||||
|
"include/flatbuffers/code_generator.h",
|
||||||
"include/flatbuffers/code_generators.h",
|
"include/flatbuffers/code_generators.h",
|
||||||
"include/flatbuffers/default_allocator.h",
|
"include/flatbuffers/default_allocator.h",
|
||||||
"include/flatbuffers/detached_buffer.h",
|
"include/flatbuffers/detached_buffer.h",
|
||||||
|
"include/flatbuffers/file_manager.h",
|
||||||
"include/flatbuffers/flatbuffer_builder.h",
|
"include/flatbuffers/flatbuffer_builder.h",
|
||||||
"include/flatbuffers/flatbuffers.h",
|
"include/flatbuffers/flatbuffers.h",
|
||||||
|
"include/flatbuffers/flex_flat_util.h",
|
||||||
"include/flatbuffers/flexbuffers.h",
|
"include/flatbuffers/flexbuffers.h",
|
||||||
"include/flatbuffers/grpc.h",
|
"include/flatbuffers/grpc.h",
|
||||||
"include/flatbuffers/hash.h",
|
"include/flatbuffers/hash.h",
|
||||||
@@ -79,6 +104,7 @@ cc_library(
|
|||||||
# Public flatc compiler.
|
# Public flatc compiler.
|
||||||
cc_binary(
|
cc_binary(
|
||||||
name = "flatc",
|
name = "flatc",
|
||||||
|
data = ["//reflection:reflection_fbs_schema"],
|
||||||
deps = [
|
deps = [
|
||||||
"//src:flatc",
|
"//src:flatc",
|
||||||
],
|
],
|
||||||
@@ -95,15 +121,7 @@ filegroup(
|
|||||||
# Library used by flatbuffer_cc_library rules.
|
# Library used by flatbuffer_cc_library rules.
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "runtime_cc",
|
name = "runtime_cc",
|
||||||
hdrs = [
|
hdrs = ["//:public_headers"],
|
||||||
"include/flatbuffers/base.h",
|
|
||||||
"include/flatbuffers/flatbuffers.h",
|
|
||||||
"include/flatbuffers/flexbuffers.h",
|
|
||||||
"include/flatbuffers/stl_emulation.h",
|
|
||||||
"include/flatbuffers/util.h",
|
|
||||||
"include/flatbuffers/vector.h",
|
|
||||||
"include/flatbuffers/verifier.h",
|
|
||||||
],
|
|
||||||
linkstatic = 1,
|
linkstatic = 1,
|
||||||
strip_include_prefix = "/include",
|
strip_include_prefix = "/include",
|
||||||
)
|
)
|
||||||
|
|||||||
201
CHANGELOG.md
Normal file
201
CHANGELOG.md
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
# Flatbuffers Change Log
|
||||||
|
|
||||||
|
All major or breaking changes will be documented in this file, as well as any
|
||||||
|
new features that should be highlighted. Minor fixes or improvements are not
|
||||||
|
necessarily listed.
|
||||||
|
|
||||||
|
## [25.12.19] (December 19 2025)(https://github.com/google/flatbuffers/releases/tag/v25.12.19)
|
||||||
|
|
||||||
|
* [C++] Default emptry vector support (#8870)
|
||||||
|
* [C++] Add --gen-absl-hash option (#8868)
|
||||||
|
* [Kotlin] Upgrade to MacOS 15 (#8845)
|
||||||
|
* [C++] Fix vector of table with naked ptrs (#8830)
|
||||||
|
* [Python] Optimize Offset/Pad/Prep (#8808)
|
||||||
|
* Implement `--file-names-only` (#8788)
|
||||||
|
* [C++] Fix size verifer (#8740)
|
||||||
|
|
||||||
|
## [25.9.23] (September 23 2025)(https://github.com/google/flatbuffers/releases/tag/v25.9.23)
|
||||||
|
|
||||||
|
* flatc: `--grpc-callback-api` flag generates C++ gRPC Callback API server `CallbackService` skeletons AND client native callback/async stubs (unary + all streaming reactor forms) (opt-in, non-breaking, issue #8596).
|
||||||
|
* Swift - Adds new API to reduce memory copying within swift (#8484)
|
||||||
|
* Rust - Support Rust edition 2024 (#8638)
|
||||||
|
* [C++] - Use the Google Style for clang-format without exceptions (#8706)
|
||||||
|
|
||||||
|
## [25.2.10] (February 10 2025)(https://github.com/google/flatbuffers/releases/tag/v25.2.10)
|
||||||
|
|
||||||
|
* Removed the old documentation pages. The new one is live at https://flatbuffers.dev
|
||||||
|
* Swift version 6.0 support (#8414)
|
||||||
|
|
||||||
|
## [25.1.24] (January 24 2025)(https://github.com/google/flatbuffers/releases/tag/v25.1.24)
|
||||||
|
|
||||||
|
* Mostly related to bazel build support.
|
||||||
|
* Min bazel supported is now 7 or higher, as WORKSPACE files are removed (#8509)
|
||||||
|
* Minor C++ codegen fix removing extra semicolon (#8488)
|
||||||
|
|
||||||
|
## [25.1.21] (January 21 2025)(https://github.com/google/flatbuffers/releases/tag/v25.1.21)
|
||||||
|
|
||||||
|
* Rust Full Reflection (#8102)
|
||||||
|
* Mostly documentation updates hosted at https://flatbuffers.dev
|
||||||
|
|
||||||
|
## [24.3.25] (March 25 2024)(https://github.com/google/flatbuffers/releases/tag/v24.3.25)
|
||||||
|
|
||||||
|
* Fixed license metadata parsing (#8253)
|
||||||
|
* [C++] Allow string_view in `LookUpByKey` in addition to null-terminated c-style strings (#8203)
|
||||||
|
|
||||||
|
## [24.3.7] (March 7 2024)(https://github.com/google/flatbuffers/releases/tag/v24.3.7)
|
||||||
|
|
||||||
|
* Just to fix some of the CI build issues from the 24.3.6 release.
|
||||||
|
|
||||||
|
## [24.3.6] (March 6 2024)(https://github.com/google/flatbuffers/releases/tag/v24.3.6)
|
||||||
|
|
||||||
|
* Fix typescript object API to allow 0 values for null-default scalars (#7864)
|
||||||
|
|
||||||
|
## [23.5.26 (May 26 2023)](https://github.com/google/flatbuffers/releases/tag/v23.5.26)
|
||||||
|
|
||||||
|
* Mostly bug fixing for 64-bit support
|
||||||
|
* Adds support for specifying underling type of unions in C++ and TS/JS (#7954)
|
||||||
|
|
||||||
|
## [23.5.9 (May 9 2023)](https://github.com/google/flatbuffers/releases/tag/v23.5.9)
|
||||||
|
|
||||||
|
* 64-bit support for C++ (#7935)
|
||||||
|
|
||||||
|
## [23.5.8 (May 8 2023)](https://github.com/google/flatbuffers/releases/tag/v23.5.8)
|
||||||
|
|
||||||
|
* add key_field to compiled tests
|
||||||
|
* Add golden language directory
|
||||||
|
* Rework cmake flatc codegeneration (#7938)
|
||||||
|
* remove defining generated files in test srcs
|
||||||
|
* Add binary schema reflection (#7932)
|
||||||
|
* Migrate from rules_nodejs to rules_js/rules_ts (take 2) (#7928)
|
||||||
|
* `flat_buffers.dart`: mark const variable finals for internal Dart linters
|
||||||
|
* fixed some windows warnings (#7929)
|
||||||
|
* inject no long for FBS generation to remove logs in flattests (#7926)
|
||||||
|
* Revert "Migrate from rules_nodejs to rules_js/rules_ts (#7923)" (#7927)
|
||||||
|
* Migrate from rules_nodejs to rules_js/rules_ts (#7923)
|
||||||
|
* Only generate @kotlin.ExperimentalUnsigned annotation on create*Vector methods having an unsigned array type parameter. (#7881)
|
||||||
|
* additional check for absl::string_view availability (#7897)
|
||||||
|
* Optionally generate Python type annotations (#7858)
|
||||||
|
* Replace deprecated command with environment file (#7921)
|
||||||
|
* drop glibc from runtime dependencies (#7906)
|
||||||
|
* Make JSON supporting advanced union features (#7869)
|
||||||
|
* Allow to use functions from `BuildFlatBuffers.cmake` from a flatbuffers installation installed with CMake. (#7912)
|
||||||
|
* TS/JS: Use TypeError instead of Error when appropriate (#7910)
|
||||||
|
* Go: make generated code more compliant to "go fmt" (#7907)
|
||||||
|
* Support file_identifier in Go (#7904)
|
||||||
|
* Optionally generate type prefixes and suffixes for python code (#7857)
|
||||||
|
* Go: add test for FinishWithFileIdentifier (#7905)
|
||||||
|
* Fix go_sample.sh (#7903)
|
||||||
|
* [TS/JS] Upgrade dependencies (#7889)
|
||||||
|
* Add a FileWriter interface (#7821)
|
||||||
|
* TS/JS: Use minvalue from enum if not found (#7888)
|
||||||
|
* [CS] Verifier (#7850)
|
||||||
|
* README.md: PyPI case typo (#7880)
|
||||||
|
* Update go documentation link to point to root module (#7879)
|
||||||
|
* use Bool for flatbuffers bool instead of Byte (#7876)
|
||||||
|
* fix using null string in vector (#7872)
|
||||||
|
* Add `flatbuffers-64` branch to CI for pushes
|
||||||
|
* made changes to the rust docs so they would compile. new_with_capacity is deprecated should use with_capacity, get_root_as_monster should be root_as_monster (#7871)
|
||||||
|
* Adding comment for code clarification (#7856)
|
||||||
|
* ToCamelCase() when kLowerCamel now converts first char to lower. (#7838)
|
||||||
|
* Fix help output for --java-checkerframework (#7854)
|
||||||
|
* Update filename to README.md and improve formatting (#7855)
|
||||||
|
* Update stale.yml
|
||||||
|
* Updated remaining usages of LICENSE.txt
|
||||||
|
|
||||||
|
## [23.3.3 (Mar 3 2023)](https://github.com/google/flatbuffers/releases/tag/v23.3.3)
|
||||||
|
|
||||||
|
* Refactoring of `flatc` generators to use an interface (#7797).
|
||||||
|
|
||||||
|
* Removed legacy cmake support and set min to 3.8 (#7801).
|
||||||
|
|
||||||
|
## [23.1.21 (Jan 21 2023)](https://github.com/google/flatbuffers/releases/tag/v23.1.20)
|
||||||
|
|
||||||
|
* Reworked entry points for Typescript/Javascript and compatibility for single
|
||||||
|
file build (#7510)
|
||||||
|
|
||||||
|
## [23.1.20 (Jan 20 2023)](https://github.com/google/flatbuffers/releases/tag/v23.1.20)
|
||||||
|
|
||||||
|
* Removed go.mod files after some versioning issues were being report (#7780).
|
||||||
|
|
||||||
|
## [23.1.4 (Jan 4 2023)](https://github.com/google/flatbuffers/releases/tag/v23.1.4)
|
||||||
|
|
||||||
|
* Major release! Just kidding, we are continuing the
|
||||||
|
[versioning scheme](https://github.com/google/flatbuffers/wiki/Versioning) of
|
||||||
|
using a date to signify releases. This results in the first release of the new
|
||||||
|
year to bump the tradition major version field.
|
||||||
|
|
||||||
|
* Go minimum version is now 1.19 (#7720) with the addition of Go modules.
|
||||||
|
|
||||||
|
* Added CI support for Big Endian regression testing (#7707).
|
||||||
|
|
||||||
|
* Fixed `getFullyQualifiedName` in typescript to return name delimited by '.'
|
||||||
|
instead of '_' (#7730).
|
||||||
|
|
||||||
|
* Fixed the versioning scheme to not include leading zeros which are not
|
||||||
|
consistently handled by every package manager. Only the last release
|
||||||
|
(12.12.06) should have suffered from this.
|
||||||
|
|
||||||
|
## [22.12.06 (Dec 06 2022)](https://github.com/google/flatbuffers/releases/tag/v22.12.06)
|
||||||
|
|
||||||
|
* Bug fixing release, no major changes.
|
||||||
|
|
||||||
|
## [22.10.25 (Oct 25 2022)](https://github.com/google/flatbuffers/releases/tag/v22.10.25)
|
||||||
|
|
||||||
|
* Added Nim language support with generator and runtime libraries (#7534).
|
||||||
|
|
||||||
|
## [22.9.29 (Sept 29 2022)](https://github.com/google/flatbuffers/releases/tag/v22.9.29)
|
||||||
|
|
||||||
|
* Rust soundness fixes to avoid the crate from bing labelled unsafe (#7518).
|
||||||
|
|
||||||
|
## [22.9.24 (Sept 24 2022)](https://github.com/google/flatbuffers/releases/tag/v22.9.24)
|
||||||
|
|
||||||
|
* 20 Major releases in a row? Nope, we switched to a new
|
||||||
|
[versioning scheme](https://github.com/google/flatbuffers/wiki/Versioning)
|
||||||
|
that is based on date.
|
||||||
|
|
||||||
|
* Python supports fixed size arrays now (#7529).
|
||||||
|
|
||||||
|
* Behavior change in how C++ object API uses `UnPackTo`. The original intent of
|
||||||
|
this was to reduce allocations by reusing an existing object to pack data
|
||||||
|
into. At some point, this logic started to merge the states of the two objects
|
||||||
|
instead of clearing the state of the packee. This change goes back to the
|
||||||
|
original intention, the packed object is cleared when getting data packed into
|
||||||
|
it (#7527).
|
||||||
|
|
||||||
|
* Fixed a bug in C++ alignment that was using `sizeof()` instead of the intended
|
||||||
|
`AlignOf()` for structs (#7520).
|
||||||
|
|
||||||
|
* C# has an
|
||||||
|
[official Nuget package](https://www.nuget.org/packages/Google.FlatBuffers)
|
||||||
|
now (#7496).
|
||||||
|
|
||||||
|
## 2.0.8 (Aug 29 2022)
|
||||||
|
|
||||||
|
* Fix for `--keep-prefix` the was generating the wrong include statements for
|
||||||
|
C++ (#7469). The bug was introduced in 2.0.7.
|
||||||
|
|
||||||
|
* Added the `Verifier::Options` option struct to allow specifying runtime
|
||||||
|
configuration settings for the verifier (#7489). This allows to skip verifying
|
||||||
|
nested flatbuffers, a on-by-default change that was introduced in 2.0.7. This
|
||||||
|
deprecates the existing `Verifier` constructor, which may be removed in a
|
||||||
|
future version.
|
||||||
|
|
||||||
|
* Refactor of `tests/test.cpp` that lead to ~10% speedup in compilation of the
|
||||||
|
entire project (#7487).
|
||||||
|
|
||||||
|
## 2.0.7 (Aug 22 2022)
|
||||||
|
|
||||||
|
* This is the first version with an explicit change log, so all the previous
|
||||||
|
features will not be listed.
|
||||||
|
|
||||||
|
* Verifier now checks that buffers are at least the minimum size required to be
|
||||||
|
a flatbuffers (12 bytes). This includes nested flatbuffers, which previously
|
||||||
|
could be declared valid at size 0.
|
||||||
|
|
||||||
|
* Annotated binaries. Given a flatbuffer binary and a schema (or binary schema)
|
||||||
|
one can generate an annotated flatbuffer (.afb) to describe each byte in the
|
||||||
|
binary with schema metadata and value.
|
||||||
|
|
||||||
|
* First binary schema generator (Lua) to generate Lua code via a .bfbs file.
|
||||||
|
This is mostly an implementation detail of flatc internals, but will be slowly
|
||||||
|
applied to the other language generators.
|
||||||
@@ -59,6 +59,9 @@ function(build_flatbuffers flatbuffers_schemas
|
|||||||
if(FLATBUFFERS_FLATC_EXECUTABLE)
|
if(FLATBUFFERS_FLATC_EXECUTABLE)
|
||||||
set(FLATC_TARGET "")
|
set(FLATC_TARGET "")
|
||||||
set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE})
|
set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE})
|
||||||
|
elseif(TARGET flatbuffers::flatc)
|
||||||
|
set(FLATC_TARGET flatbuffers::flatc)
|
||||||
|
set(FLATC flatbuffers::flatc)
|
||||||
else()
|
else()
|
||||||
set(FLATC_TARGET flatc)
|
set(FLATC_TARGET flatc)
|
||||||
set(FLATC flatc)
|
set(FLATC flatc)
|
||||||
@@ -95,7 +98,7 @@ function(build_flatbuffers flatbuffers_schemas
|
|||||||
set(generated_include ${generated_includes_dir}/${filename}_generated.h)
|
set(generated_include ${generated_includes_dir}/${filename}_generated.h)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${generated_include}
|
OUTPUT ${generated_include}
|
||||||
COMMAND ${FLATC} ${FLATC_ARGS}
|
COMMAND ${FLATC} ${FLATC_SCHEMA_ARGS}
|
||||||
-o ${generated_includes_dir}
|
-o ${generated_includes_dir}
|
||||||
${include_params}
|
${include_params}
|
||||||
-c ${schema}
|
-c ${schema}
|
||||||
@@ -157,6 +160,10 @@ endfunction()
|
|||||||
# other flagc flags using the FLAGS option to change the behavior of the flatc
|
# other flagc flags using the FLAGS option to change the behavior of the flatc
|
||||||
# tool.
|
# tool.
|
||||||
#
|
#
|
||||||
|
# When the target_link_libraries is done within a different directory than
|
||||||
|
# flatbuffers_generate_headers is called, then the target should also be dependent
|
||||||
|
# the custom generation target called GENERATE_<TARGET>.
|
||||||
|
#
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# TARGET: The name of the target to generate.
|
# TARGET: The name of the target to generate.
|
||||||
# SCHEMAS: The list of schema files to generate code for.
|
# SCHEMAS: The list of schema files to generate code for.
|
||||||
@@ -182,6 +189,9 @@ endfunction()
|
|||||||
# target_link_libraries(MyExecutableTarget
|
# target_link_libraries(MyExecutableTarget
|
||||||
# PRIVATE my_generated_headers_target
|
# PRIVATE my_generated_headers_target
|
||||||
# )
|
# )
|
||||||
|
#
|
||||||
|
# Optional (only needed within different directory):
|
||||||
|
# add_dependencies(app GENERATE_my_generated_headers_target)
|
||||||
function(flatbuffers_generate_headers)
|
function(flatbuffers_generate_headers)
|
||||||
# Parse function arguments.
|
# Parse function arguments.
|
||||||
set(options)
|
set(options)
|
||||||
@@ -204,6 +214,9 @@ function(flatbuffers_generate_headers)
|
|||||||
if(FLATBUFFERS_FLATC_EXECUTABLE)
|
if(FLATBUFFERS_FLATC_EXECUTABLE)
|
||||||
set(FLATC_TARGET "")
|
set(FLATC_TARGET "")
|
||||||
set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE})
|
set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE})
|
||||||
|
elseif(TARGET flatbuffers::flatc)
|
||||||
|
set(FLATC_TARGET flatbuffers::flatc)
|
||||||
|
set(FLATC flatbuffers::flatc)
|
||||||
else()
|
else()
|
||||||
set(FLATC_TARGET flatc)
|
set(FLATC_TARGET flatc)
|
||||||
set(FLATC flatc)
|
set(FLATC flatc)
|
||||||
@@ -226,20 +239,37 @@ function(flatbuffers_generate_headers)
|
|||||||
"--include-prefix" ${FLATBUFFERS_GENERATE_HEADERS_INCLUDE_PREFIX})
|
"--include-prefix" ${FLATBUFFERS_GENERATE_HEADERS_INCLUDE_PREFIX})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(generated_custom_commands)
|
||||||
|
|
||||||
# Create rules to generate the code for each schema.
|
# Create rules to generate the code for each schema.
|
||||||
foreach(schema ${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
foreach(schema ${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
||||||
get_filename_component(filename ${schema} NAME_WE)
|
get_filename_component(filename ${schema} NAME_WE)
|
||||||
set(generated_include "${generated_include_dir}/${filename}_generated.h")
|
set(generated_include "${generated_include_dir}/${filename}_generated.h")
|
||||||
|
|
||||||
|
# Generate files for grpc if needed
|
||||||
|
set(generated_source_file)
|
||||||
|
if("${FLATBUFFERS_GENERATE_HEADERS_FLAGS}" MATCHES "--grpc")
|
||||||
|
# Check if schema file contain a rpc_service definition
|
||||||
|
file(STRINGS ${schema} has_grpc REGEX "rpc_service")
|
||||||
|
if(has_grpc)
|
||||||
|
list(APPEND generated_include "${generated_include_dir}/${filename}.grpc.fb.h")
|
||||||
|
set(generated_source_file "${generated_include_dir}/${filename}.grpc.fb.cc")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${generated_include}
|
OUTPUT ${generated_include} ${generated_source_file}
|
||||||
COMMAND ${FLATC} ${FLATC_ARGS}
|
COMMAND ${FLATC} ${FLATC_ARGS}
|
||||||
-o ${generated_include_dir}
|
-o ${generated_include_dir}
|
||||||
${include_params}
|
${include_params}
|
||||||
-c ${schema}
|
-c ${schema}
|
||||||
${FLATBUFFERS_GENERATE_HEADERS_FLAGS}
|
${FLATBUFFERS_GENERATE_HEADERS_FLAGS}
|
||||||
DEPENDS ${FLATC_TARGET} ${schema}
|
DEPENDS ${FLATC_TARGET} ${schema}
|
||||||
WORKING_DIRECTORY "${working_dir}")
|
WORKING_DIRECTORY "${working_dir}"
|
||||||
|
COMMENT "Building ${schema} flatbuffers...")
|
||||||
list(APPEND all_generated_header_files ${generated_include})
|
list(APPEND all_generated_header_files ${generated_include})
|
||||||
|
list(APPEND all_generated_source_files ${generated_source_file})
|
||||||
|
list(APPEND generated_custom_commands "${generated_include}" "${generated_source_file}")
|
||||||
|
|
||||||
# Geneate the binary flatbuffers schemas if instructed to.
|
# Geneate the binary flatbuffers schemas if instructed to.
|
||||||
if (NOT ${FLATBUFFERS_GENERATE_HEADERS_BINARY_SCHEMAS_DIR} STREQUAL "")
|
if (NOT ${FLATBUFFERS_GENERATE_HEADERS_BINARY_SCHEMAS_DIR} STREQUAL "")
|
||||||
@@ -253,10 +283,17 @@ function(flatbuffers_generate_headers)
|
|||||||
${schema}
|
${schema}
|
||||||
DEPENDS ${FLATC_TARGET} ${schema}
|
DEPENDS ${FLATC_TARGET} ${schema}
|
||||||
WORKING_DIRECTORY "${working_dir}")
|
WORKING_DIRECTORY "${working_dir}")
|
||||||
|
list(APPEND generated_custom_commands "${binary_schema}")
|
||||||
list(APPEND all_generated_binary_files ${binary_schema})
|
list(APPEND all_generated_binary_files ${binary_schema})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
# Create an additional target as add_custom_command scope is only within same directory (CMakeFile.txt)
|
||||||
|
set(generate_target GENERATE_${FLATBUFFERS_GENERATE_HEADERS_TARGET})
|
||||||
|
add_custom_target(${generate_target} ALL
|
||||||
|
DEPENDS ${generated_custom_commands}
|
||||||
|
COMMENT "Generating flatbuffer target ${FLATBUFFERS_GENERATE_HEADERS_TARGET}")
|
||||||
|
|
||||||
# Set up interface library
|
# Set up interface library
|
||||||
add_library(${FLATBUFFERS_GENERATE_HEADERS_TARGET} INTERFACE)
|
add_library(${FLATBUFFERS_GENERATE_HEADERS_TARGET} INTERFACE)
|
||||||
target_sources(
|
target_sources(
|
||||||
@@ -264,11 +301,11 @@ function(flatbuffers_generate_headers)
|
|||||||
INTERFACE
|
INTERFACE
|
||||||
${all_generated_header_files}
|
${all_generated_header_files}
|
||||||
${all_generated_binary_files}
|
${all_generated_binary_files}
|
||||||
|
${all_generated_source_files}
|
||||||
${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
||||||
add_dependencies(
|
add_dependencies(
|
||||||
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
||||||
${FLATC}
|
${FLATC_TARGET})
|
||||||
${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
||||||
INTERFACE ${generated_target_dir})
|
INTERFACE ${generated_target_dir})
|
||||||
@@ -278,6 +315,10 @@ function(flatbuffers_generate_headers)
|
|||||||
TREE "${generated_target_dir}"
|
TREE "${generated_target_dir}"
|
||||||
PREFIX "Flatbuffers/Generated/Headers Files"
|
PREFIX "Flatbuffers/Generated/Headers Files"
|
||||||
FILES ${all_generated_header_files})
|
FILES ${all_generated_header_files})
|
||||||
|
source_group(
|
||||||
|
TREE "${generated_target_dir}"
|
||||||
|
PREFIX "Flatbuffers/Generated/Source Files"
|
||||||
|
FILES ${all_generated_source_files})
|
||||||
source_group(
|
source_group(
|
||||||
TREE ${working_dir}
|
TREE ${working_dir}
|
||||||
PREFIX "Flatbuffers/Schemas"
|
PREFIX "Flatbuffers/Schemas"
|
||||||
@@ -346,6 +387,9 @@ function(flatbuffers_generate_binary_files)
|
|||||||
if(FLATBUFFERS_FLATC_EXECUTABLE)
|
if(FLATBUFFERS_FLATC_EXECUTABLE)
|
||||||
set(FLATC_TARGET "")
|
set(FLATC_TARGET "")
|
||||||
set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE})
|
set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE})
|
||||||
|
elseif(TARGET flatbuffers::flatc)
|
||||||
|
set(FLATC_TARGET flatbuffers::flatc)
|
||||||
|
set(FLATC flatbuffers::flatc)
|
||||||
else()
|
else()
|
||||||
set(FLATC_TARGET flatc)
|
set(FLATC_TARGET flatc)
|
||||||
set(FLATC flatc)
|
set(FLATC flatc)
|
||||||
@@ -371,7 +415,8 @@ function(flatbuffers_generate_binary_files)
|
|||||||
-b ${FLATBUFFERS_GENERATE_BINARY_FILES_SCHEMA} ${json_file}
|
-b ${FLATBUFFERS_GENERATE_BINARY_FILES_SCHEMA} ${json_file}
|
||||||
${FLATBUFFERS_GENERATE_BINARY_FILES_FLAGS}
|
${FLATBUFFERS_GENERATE_BINARY_FILES_FLAGS}
|
||||||
DEPENDS ${FLATC_TARGET} ${json_file}
|
DEPENDS ${FLATC_TARGET} ${json_file}
|
||||||
WORKING_DIRECTORY "${working_dir}")
|
WORKING_DIRECTORY "${working_dir}"
|
||||||
|
COMMENT "Building ${json_file} binary flatbuffers...")
|
||||||
list(APPEND all_generated_binary_files ${generated_binary_file})
|
list(APPEND all_generated_binary_files ${generated_binary_file})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
include("${CMAKE_CURRENT_LIST_DIR}/FlatbuffersTargets.cmake" OPTIONAL)
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/FlatcTargets.cmake" OPTIONAL)
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/FlatbuffersSharedTargets.cmake" OPTIONAL)
|
|
||||||
|
|
||||||
@@ -17,23 +17,9 @@ if (UNIX)
|
|||||||
SET(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_COMMIT}")
|
SET(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_COMMIT}")
|
||||||
SET(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
|
SET(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
|
||||||
|
|
||||||
# Derive architecture
|
|
||||||
IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
|
|
||||||
FIND_PROGRAM(DPKG_CMD dpkg)
|
|
||||||
IF(NOT DPKG_CMD)
|
|
||||||
MESSAGE(STATUS "Can not find dpkg in your path, default to i386.")
|
|
||||||
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
|
|
||||||
ENDIF(NOT DPKG_CMD)
|
|
||||||
EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture
|
|
||||||
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
ENDIF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
|
|
||||||
|
|
||||||
# Package name
|
# Package name
|
||||||
SET(CPACK_DEBIAN_PACKAGE_NAME "flatbuffers")
|
SET(CPACK_DEBIAN_PACKAGE_NAME "flatbuffers")
|
||||||
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)
|
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE)
|
||||||
SET(CPACK_PACKAGE_FILE_NAME
|
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
|
||||||
"${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
|
|
||||||
|
|
||||||
endif(UNIX)
|
endif(UNIX)
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ if (UNIX)
|
|||||||
|
|
||||||
set(CPACK_RPM_PACKAGE_NAME "flatbuffers")
|
set(CPACK_RPM_PACKAGE_NAME "flatbuffers")
|
||||||
|
|
||||||
# Assume this is not a cross complation build.
|
# Assume this is not a cross compilation build.
|
||||||
if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
|
if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
|
||||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}")
|
set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}")
|
||||||
endif(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
|
endif(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
|
||||||
|
|
||||||
set(CPACK_RPM_PACKAGE_VENDOR "Google, Inc.")
|
set(CPACK_RPM_PACKAGE_VENDOR "Google, Inc.")
|
||||||
set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0")
|
set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0")
|
||||||
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)
|
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE)
|
||||||
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/CMake/DESCRIPTION.txt)
|
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/CMake/DESCRIPTION.txt)
|
||||||
|
|
||||||
# This may reduce rpm compatiblity with very old systems.
|
# This may reduce rpm compatiblity with very old systems.
|
||||||
|
|||||||
@@ -1,28 +1,39 @@
|
|||||||
set(VERSION_MAJOR 2)
|
set(VERSION_MAJOR 25)
|
||||||
set(VERSION_MINOR 0)
|
set(VERSION_MINOR 12)
|
||||||
set(VERSION_PATCH 5)
|
set(VERSION_PATCH 19)
|
||||||
set(VERSION_COMMIT 0)
|
set(VERSION_COMMIT 0)
|
||||||
|
|
||||||
find_program(GIT git)
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||||
if(GIT)
|
find_program(GIT git)
|
||||||
execute_process(
|
if(GIT)
|
||||||
|
execute_process(
|
||||||
COMMAND ${GIT} describe --tags
|
COMMAND ${GIT} describe --tags
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
OUTPUT_VARIABLE GIT_DESCRIBE_DIRTY
|
OUTPUT_VARIABLE GIT_DESCRIBE_DIRTY
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
RESULT_VARIABLE GIT_DESCRIBE_RESULT
|
RESULT_VARIABLE GIT_DESCRIBE_RESULT
|
||||||
)
|
)
|
||||||
|
|
||||||
if(GIT_DESCRIBE_RESULT EQUAL 0)
|
if(GIT_DESCRIBE_RESULT EQUAL 0)
|
||||||
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY}")
|
# Test if the most recent Git tag matches the pattern "v<major>.<minor>.<patch>*"
|
||||||
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY}")
|
if(GIT_DESCRIBE_DIRTY MATCHES "^v[0-9]+\\.[0-9]+\\.[0-9]+.*")
|
||||||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY}")
|
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY}")
|
||||||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY}")
|
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY}")
|
||||||
|
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY}")
|
||||||
|
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY}")
|
||||||
|
# If the tag points to the commit, then only the tag is shown in "git describe"
|
||||||
|
if(VERSION_COMMIT STREQUAL GIT_DESCRIBE_DIRTY)
|
||||||
|
set(VERSION_COMMIT 0)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(WARNING "\"${GIT_DESCRIBE_DIRTY}\" does not match pattern v<major>.<minor>.<patch>-<commit>")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(WARNING "git describe failed with exit code: ${GIT_DESCRIBE_RESULT}\nMake sure you cloned with tags or run 'git fetch --tags'.")
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
message(WARNING "git describe failed with exit code: ${GIT_DESCRIBE_RESULT}")
|
message(WARNING "git is not found")
|
||||||
endif()
|
endif()
|
||||||
else()
|
|
||||||
message(WARNING "git is not found")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "Proceeding with version: ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_COMMIT}")
|
message(STATUS "Proceeding with version: ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_COMMIT}")
|
||||||
|
|||||||
4
CMake/flatbuffers-config.cmake
Normal file
4
CMake/flatbuffers-config.cmake
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/FlatBuffersTargets.cmake" OPTIONAL)
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/FlatcTargets.cmake" OPTIONAL)
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/FlatBuffersSharedTargets.cmake" OPTIONAL)
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/BuildFlatBuffers.cmake" OPTIONAL)
|
||||||
686
CMakeLists.txt
686
CMakeLists.txt
@@ -1,17 +1,13 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.12)
|
# This is the legacy minimum version flatbuffers supported for a while.
|
||||||
|
cmake_minimum_required(VERSION 3.8...3.25.2)
|
||||||
if (POLICY CMP0048)
|
|
||||||
cmake_policy(SET CMP0048 NEW)
|
|
||||||
project(FlatBuffers
|
|
||||||
DESCRIPTION "Flatbuffers serialization library"
|
|
||||||
VERSION 2.0.0
|
|
||||||
LANGUAGES CXX)
|
|
||||||
else()
|
|
||||||
project(FlatBuffers)
|
|
||||||
endif (POLICY CMP0048)
|
|
||||||
|
|
||||||
|
# Attempt to read the current version of flatbuffers by looking at the latest tag.
|
||||||
include(CMake/Version.cmake)
|
include(CMake/Version.cmake)
|
||||||
|
|
||||||
|
project(FlatBuffers
|
||||||
|
VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||||
|
LANGUAGES CXX)
|
||||||
|
|
||||||
# generate compile_commands.json
|
# generate compile_commands.json
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
@@ -25,9 +21,8 @@ option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler"
|
|||||||
ON)
|
ON)
|
||||||
option(FLATBUFFERS_STATIC_FLATC "Build flatbuffers compiler with -static flag"
|
option(FLATBUFFERS_STATIC_FLATC "Build flatbuffers compiler with -static flag"
|
||||||
OFF)
|
OFF)
|
||||||
option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" ON)
|
option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" OFF)
|
||||||
option(FLATBUFFERS_BUILD_BENCHMARKS "Enable the build of flatbenchmark. \"
|
option(FLATBUFFERS_BUILD_BENCHMARKS "Enable the build of flatbenchmark."
|
||||||
Requires C++11."
|
|
||||||
OFF)
|
OFF)
|
||||||
option(FLATBUFFERS_BUILD_GRPCTEST "Enable the build of grpctest" OFF)
|
option(FLATBUFFERS_BUILD_GRPCTEST "Enable the build of grpctest" OFF)
|
||||||
option(FLATBUFFERS_BUILD_SHAREDLIB
|
option(FLATBUFFERS_BUILD_SHAREDLIB
|
||||||
@@ -56,9 +51,35 @@ option(FLATBUFFERS_ENABLE_PCH
|
|||||||
Only work if CMake supports 'target_precompile_headers'. \"
|
Only work if CMake supports 'target_precompile_headers'. \"
|
||||||
This can speed up compilation time."
|
This can speed up compilation time."
|
||||||
OFF)
|
OFF)
|
||||||
option(FLATBUFFERS_SKIP_MONSTER_EXTRA
|
option(FLATBUFFERS_SKIP_MONSTER_EXTRA
|
||||||
"Skip generating monster_extra.fbs that contains non-supported numerical\"
|
"Skip generating monster_extra.fbs that contains non-supported numerical\"
|
||||||
types." OFF)
|
types." OFF)
|
||||||
|
option(FLATBUFFERS_STRICT_MODE
|
||||||
|
"Build flatbuffers with all warnings as errors (-Werror or /WX)."
|
||||||
|
OFF)
|
||||||
|
|
||||||
|
if(NOT DEFINED FLATBUFFERS_CPP_STD)
|
||||||
|
set(FLATBUFFERS_CPP_STD 11)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(MSVC_LIKE OFF)
|
||||||
|
if(MSVC OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
||||||
|
set(MSVC_LIKE ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
set(IS_CLANG ON)
|
||||||
|
else()
|
||||||
|
set(IS_CLANG OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED FLATBUFFERS_COMPILATION_TIMINGS)
|
||||||
|
message("Recording Compilation Timings to ${FLATBUFFERS_COMPILATION_TIMINGS}")
|
||||||
|
file(REMOVE ${FLATBUFFERS_COMPILATION_TIMINGS})
|
||||||
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
|
||||||
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_CUSTOM "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
|
||||||
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
|
if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
|
||||||
message(WARNING
|
message(WARNING
|
||||||
@@ -77,7 +98,7 @@ if(NOT DEFINED FLATBUFFERS_LOCALE_INDEPENDENT)
|
|||||||
include(CheckCXXSymbolExists)
|
include(CheckCXXSymbolExists)
|
||||||
|
|
||||||
set(FLATBUFFERS_LOCALE_INDEPENDENT 0)
|
set(FLATBUFFERS_LOCALE_INDEPENDENT 0)
|
||||||
if(MSVC)
|
if(MSVC_LIKE)
|
||||||
check_cxx_symbol_exists(_strtof_l stdlib.h FLATBUFFERS_HAS_STRTOF_L)
|
check_cxx_symbol_exists(_strtof_l stdlib.h FLATBUFFERS_HAS_STRTOF_L)
|
||||||
check_cxx_symbol_exists(_strtoui64_l stdlib.h FLATBUFFERS_HAS_STRTOULL_L)
|
check_cxx_symbol_exists(_strtoui64_l stdlib.h FLATBUFFERS_HAS_STRTOULL_L)
|
||||||
else()
|
else()
|
||||||
@@ -90,18 +111,28 @@ if(NOT DEFINED FLATBUFFERS_LOCALE_INDEPENDENT)
|
|||||||
endif()
|
endif()
|
||||||
add_definitions(-DFLATBUFFERS_LOCALE_INDEPENDENT=$<BOOL:${FLATBUFFERS_LOCALE_INDEPENDENT}>)
|
add_definitions(-DFLATBUFFERS_LOCALE_INDEPENDENT=$<BOOL:${FLATBUFFERS_LOCALE_INDEPENDENT}>)
|
||||||
|
|
||||||
|
if(NOT WIN32)
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
check_symbol_exists(realpath "stdlib.h" HAVE_REALPATH)
|
||||||
|
if(NOT HAVE_REALPATH)
|
||||||
|
add_definitions(-DFLATBUFFERS_NO_ABSOLUTE_PATH_RESOLUTION)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
set(FlatBuffers_Library_SRCS
|
set(FlatBuffers_Library_SRCS
|
||||||
include/flatbuffers/allocator.h
|
include/flatbuffers/allocator.h
|
||||||
include/flatbuffers/array.h
|
include/flatbuffers/array.h
|
||||||
include/flatbuffers/base.h
|
include/flatbuffers/base.h
|
||||||
include/flatbuffers/bfbs_generator.h
|
|
||||||
include/flatbuffers/buffer.h
|
include/flatbuffers/buffer.h
|
||||||
include/flatbuffers/buffer_ref.h
|
include/flatbuffers/buffer_ref.h
|
||||||
include/flatbuffers/default_allocator.h
|
include/flatbuffers/default_allocator.h
|
||||||
include/flatbuffers/detached_buffer.h
|
include/flatbuffers/detached_buffer.h
|
||||||
|
include/flatbuffers/code_generator.h
|
||||||
|
include/flatbuffers/file_manager.h
|
||||||
include/flatbuffers/flatbuffer_builder.h
|
include/flatbuffers/flatbuffer_builder.h
|
||||||
include/flatbuffers/flatbuffers.h
|
include/flatbuffers/flatbuffers.h
|
||||||
include/flatbuffers/flexbuffers.h
|
include/flatbuffers/flexbuffers.h
|
||||||
|
include/flatbuffers/flex_flat_util.h
|
||||||
include/flatbuffers/hash.h
|
include/flatbuffers/hash.h
|
||||||
include/flatbuffers/idl.h
|
include/flatbuffers/idl.h
|
||||||
include/flatbuffers/minireflect.h
|
include/flatbuffers/minireflect.h
|
||||||
@@ -116,6 +147,8 @@ set(FlatBuffers_Library_SRCS
|
|||||||
include/flatbuffers/vector.h
|
include/flatbuffers/vector.h
|
||||||
include/flatbuffers/vector_downward.h
|
include/flatbuffers/vector_downward.h
|
||||||
include/flatbuffers/verifier.h
|
include/flatbuffers/verifier.h
|
||||||
|
src/file_manager.cpp
|
||||||
|
src/file_name_manager.cpp
|
||||||
src/idl_parser.cpp
|
src/idl_parser.cpp
|
||||||
src/idl_gen_text.cpp
|
src/idl_gen_text.cpp
|
||||||
src/reflection.cpp
|
src/reflection.cpp
|
||||||
@@ -124,28 +157,43 @@ set(FlatBuffers_Library_SRCS
|
|||||||
|
|
||||||
set(FlatBuffers_Compiler_SRCS
|
set(FlatBuffers_Compiler_SRCS
|
||||||
${FlatBuffers_Library_SRCS}
|
${FlatBuffers_Library_SRCS}
|
||||||
|
src/idl_gen_binary.cpp
|
||||||
|
src/idl_gen_text.cpp
|
||||||
src/idl_gen_cpp.cpp
|
src/idl_gen_cpp.cpp
|
||||||
src/idl_gen_csharp.cpp
|
src/idl_gen_csharp.cpp
|
||||||
src/idl_gen_dart.cpp
|
src/idl_gen_dart.cpp
|
||||||
src/idl_gen_kotlin.cpp
|
src/idl_gen_kotlin.cpp
|
||||||
|
src/idl_gen_kotlin_kmp.cpp
|
||||||
src/idl_gen_go.cpp
|
src/idl_gen_go.cpp
|
||||||
src/idl_gen_java.cpp
|
src/idl_gen_java.cpp
|
||||||
src/idl_gen_ts.cpp
|
src/idl_gen_ts.cpp
|
||||||
src/idl_gen_php.cpp
|
src/idl_gen_php.cpp
|
||||||
src/idl_gen_python.cpp
|
src/idl_gen_python.cpp
|
||||||
src/idl_gen_lobster.cpp
|
src/idl_gen_lobster.cpp
|
||||||
src/idl_gen_lua.cpp
|
|
||||||
src/idl_gen_rust.cpp
|
src/idl_gen_rust.cpp
|
||||||
src/idl_gen_fbs.cpp
|
src/idl_gen_fbs.cpp
|
||||||
src/idl_gen_grpc.cpp
|
src/idl_gen_grpc.cpp
|
||||||
src/idl_gen_json_schema.cpp
|
src/idl_gen_json_schema.cpp
|
||||||
src/idl_gen_swift.cpp
|
src/idl_gen_swift.cpp
|
||||||
|
src/idl_namer.h
|
||||||
|
src/namer.h
|
||||||
src/flatc.cpp
|
src/flatc.cpp
|
||||||
src/flatc_main.cpp
|
src/flatc_main.cpp
|
||||||
src/bfbs_gen.h
|
src/bfbs_gen.h
|
||||||
src/bfbs_gen_lua.h
|
src/bfbs_gen_lua.h
|
||||||
|
src/bfbs_gen_nim.h
|
||||||
|
src/bfbs_namer.h
|
||||||
|
include/codegen/idl_namer.h
|
||||||
|
include/codegen/namer.h
|
||||||
|
include/codegen/python.h
|
||||||
|
include/codegen/python.cc
|
||||||
include/flatbuffers/code_generators.h
|
include/flatbuffers/code_generators.h
|
||||||
|
src/binary_annotator.h
|
||||||
|
src/binary_annotator.cpp
|
||||||
|
src/annotated_binary_text_gen.h
|
||||||
|
src/annotated_binary_text_gen.cpp
|
||||||
src/bfbs_gen_lua.cpp
|
src/bfbs_gen_lua.cpp
|
||||||
|
src/bfbs_gen_nim.cpp
|
||||||
src/code_generators.cpp
|
src/code_generators.cpp
|
||||||
grpc/src/compiler/schema_interface.h
|
grpc/src/compiler/schema_interface.h
|
||||||
grpc/src/compiler/cpp_generator.h
|
grpc/src/compiler/cpp_generator.h
|
||||||
@@ -170,32 +218,34 @@ set(FlatHash_SRCS
|
|||||||
set(FlatBuffers_Tests_SRCS
|
set(FlatBuffers_Tests_SRCS
|
||||||
${FlatBuffers_Library_SRCS}
|
${FlatBuffers_Library_SRCS}
|
||||||
src/idl_gen_fbs.cpp
|
src/idl_gen_fbs.cpp
|
||||||
|
tests/default_vectors_strings_test.cpp
|
||||||
|
tests/default_vectors_strings_test.h
|
||||||
|
tests/evolution_test.cpp
|
||||||
|
tests/flexbuffers_test.cpp
|
||||||
|
tests/fuzz_test.cpp
|
||||||
|
tests/json_test.cpp
|
||||||
|
tests/key_field_test.cpp
|
||||||
|
tests/monster_test.cpp
|
||||||
|
tests/optional_scalars_test.cpp
|
||||||
|
tests/parser_test.cpp
|
||||||
|
tests/proto_test.cpp
|
||||||
|
tests/reflection_test.cpp
|
||||||
tests/test.cpp
|
tests/test.cpp
|
||||||
tests/test_assert.h
|
tests/test_assert.h
|
||||||
tests/test_assert.cpp
|
tests/test_assert.cpp
|
||||||
tests/test_builder.h
|
tests/test_builder.h
|
||||||
tests/test_builder.cpp
|
tests/test_builder.cpp
|
||||||
|
tests/util_test.cpp
|
||||||
|
tests/vector_table_naked_ptr_test.h
|
||||||
|
tests/vector_table_naked_ptr_test.cpp
|
||||||
tests/native_type_test_impl.h
|
tests/native_type_test_impl.h
|
||||||
tests/native_type_test_impl.cpp
|
tests/native_type_test_impl.cpp
|
||||||
|
tests/alignment_test.h
|
||||||
|
tests/alignment_test.cpp
|
||||||
|
tests/64bit/offset64_test.h
|
||||||
|
tests/64bit/offset64_test.cpp
|
||||||
include/flatbuffers/code_generators.h
|
include/flatbuffers/code_generators.h
|
||||||
src/code_generators.cpp
|
src/code_generators.cpp
|
||||||
# file generate by running compiler on tests/monster_test.fbs
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
|
|
||||||
# file generate by running compiler on namespace_test/namespace_test1.fbs
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/tests/namespace_test/namespace_test1_generated.h
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/tests/namespace_test/namespace_test2_generated.h
|
|
||||||
# file generate by running compiler on union_vector/union_vector.fbs
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/tests/union_vector/union_vector_generated.h
|
|
||||||
# file generate by running compiler on tests/arrays_test.fbs
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/tests/arrays_test_generated.h
|
|
||||||
# file generate by running compiler on tests/native_type_test.fbs
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/tests/native_type_test_generated.h
|
|
||||||
# file generate by running compiler on tests/monster_extra.fbs
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_extra_generated.h
|
|
||||||
# file generate by running compiler on tests/monster_test.fbs
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_bfbs_generated.h
|
|
||||||
# file generate by running compiler on tests/optional_scalars.fbs
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/tests/optional_scalars_generated.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FlatBuffers_Tests_CPP17_SRCS
|
set(FlatBuffers_Tests_CPP17_SRCS
|
||||||
@@ -203,32 +253,20 @@ set(FlatBuffers_Tests_CPP17_SRCS
|
|||||||
tests/test_assert.h
|
tests/test_assert.h
|
||||||
tests/test_assert.cpp
|
tests/test_assert.cpp
|
||||||
tests/cpp17/test_cpp17.cpp
|
tests/cpp17/test_cpp17.cpp
|
||||||
# file generate by running compiler on tests/monster_test.fbs
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/tests/cpp17/generated_cpp17/monster_test_generated.h
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/tests/cpp17/generated_cpp17/optional_scalars_generated.h
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/tests/optional_scalars_generated.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FlatBuffers_Sample_Binary_SRCS
|
set(FlatBuffers_Sample_Binary_SRCS
|
||||||
include/flatbuffers/flatbuffers.h
|
|
||||||
samples/sample_binary.cpp
|
samples/sample_binary.cpp
|
||||||
# file generated by running compiler on samples/monster.fbs
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FlatBuffers_Sample_Text_SRCS
|
set(FlatBuffers_Sample_Text_SRCS
|
||||||
${FlatBuffers_Library_SRCS}
|
${FlatBuffers_Library_SRCS}
|
||||||
samples/sample_text.cpp
|
samples/sample_text.cpp
|
||||||
# file generated by running compiler on samples/monster.fbs
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FlatBuffers_Sample_BFBS_SRCS
|
set(FlatBuffers_Sample_BFBS_SRCS
|
||||||
${FlatBuffers_Library_SRCS}
|
${FlatBuffers_Library_SRCS}
|
||||||
samples/sample_bfbs.cpp
|
samples/sample_bfbs.cpp
|
||||||
# file generated by running compiler on samples/monster.fbs
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FlatBuffers_GRPCTest_SRCS
|
set(FlatBuffers_GRPCTest_SRCS
|
||||||
@@ -244,95 +282,19 @@ set(FlatBuffers_GRPCTest_SRCS
|
|||||||
tests/test_builder.cpp
|
tests/test_builder.cpp
|
||||||
grpc/tests/grpctest.cpp
|
grpc/tests/grpctest.cpp
|
||||||
grpc/tests/message_builder_test.cpp
|
grpc/tests/message_builder_test.cpp
|
||||||
# file generate by running compiler on tests/monster_test.fbs
|
grpc/tests/grpctest_callback_compile.cpp
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
|
grpc/tests/grpctest_callback_client_compile.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS})
|
# TODO(dbaileychess): Figure out how this would now work. I posted a question on
|
||||||
# source_group(Tests FILES ${FlatBuffers_Tests_SRCS})
|
# https://stackoverflow.com/questions/71772330/override-target-compile-options-via-cmake-command-line.
|
||||||
|
|
||||||
if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
|
||||||
# do not apply any global settings if the toolchain
|
|
||||||
# is being configured externally
|
|
||||||
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
|
|
||||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
|
||||||
if(CYGWIN)
|
|
||||||
set(CMAKE_CXX_FLAGS
|
|
||||||
"${CMAKE_CXX_FLAGS} -std=gnu++11")
|
|
||||||
else(CYGWIN)
|
|
||||||
set(CMAKE_CXX_FLAGS
|
|
||||||
"${CMAKE_CXX_FLAGS} -std=c++0x")
|
|
||||||
endif(CYGWIN)
|
|
||||||
set(CMAKE_CXX_FLAGS
|
|
||||||
"${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Werror=shadow")
|
|
||||||
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
|
|
||||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4)
|
|
||||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
|
|
||||||
set(CMAKE_CXX_FLAGS
|
|
||||||
"${CMAKE_CXX_FLAGS} -faligned-new -Werror=implicit-fallthrough=2")
|
|
||||||
endif()
|
|
||||||
set(CMAKE_CXX_FLAGS
|
|
||||||
"${CMAKE_CXX_FLAGS} -Wunused-result -Werror=unused-result -Wunused-parameter -Werror=unused-parameter")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Certain platforms such as ARM do not use signed chars by default
|
|
||||||
# which causes issues with certain bounds checks.
|
|
||||||
set(CMAKE_CXX_FLAGS
|
|
||||||
"${CMAKE_CXX_FLAGS} -fsigned-char")
|
|
||||||
|
|
||||||
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
|
||||||
if(APPLE)
|
|
||||||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
|
||||||
else()
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Wno-unused-parameter")
|
|
||||||
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
|
|
||||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.8)
|
|
||||||
list(APPEND FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wimplicit-fallthrough" "-Wextra-semi" "-Werror=unused-private-field") # enable warning
|
|
||||||
endif()
|
|
||||||
if(FLATBUFFERS_LIBCXX_WITH_CLANG)
|
|
||||||
if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
|
||||||
set(CMAKE_CXX_FLAGS
|
|
||||||
"${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
|
||||||
endif()
|
|
||||||
if(NOT ("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD" OR
|
|
||||||
"${CMAKE_SYSTEM_NAME}" MATCHES "Linux"))
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS
|
|
||||||
"${CMAKE_EXE_LINKER_FLAGS} -lc++abi")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Certain platforms such as ARM do not use signed chars by default
|
|
||||||
# which causes issues with certain bounds checks.
|
|
||||||
set(CMAKE_CXX_FLAGS
|
|
||||||
"${CMAKE_CXX_FLAGS} -fsigned-char")
|
|
||||||
|
|
||||||
elseif(MSVC)
|
|
||||||
# Visual Studio pedantic build settings
|
|
||||||
# warning C4512: assignment operator could not be generated
|
|
||||||
# warning C4316: object allocated on the heap may not be aligned
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /wd4512 /wd4316")
|
|
||||||
|
|
||||||
# multi-core build.
|
|
||||||
add_definitions("/MP")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Append FLATBUFFERS_CXX_FLAGS to CMAKE_CXX_FLAGS.
|
# Append FLATBUFFERS_CXX_FLAGS to CMAKE_CXX_FLAGS.
|
||||||
if(DEFINED FLATBUFFERS_CXX_FLAGS AND NOT EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
if(DEFINED FLATBUFFERS_CXX_FLAGS)
|
||||||
message(STATUS "extend CXX_FLAGS with ${FLATBUFFERS_CXX_FLAGS}")
|
message(STATUS "extend CXX_FLAGS with ${FLATBUFFERS_CXX_FLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLATBUFFERS_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLATBUFFERS_CXX_FLAGS}")
|
||||||
endif()
|
endif()
|
||||||
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
|
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
|
||||||
|
|
||||||
if(FLATBUFFERS_CODE_COVERAGE)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage")
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS
|
|
||||||
"${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
function(add_fsanitize_to_target _target _sanitizer)
|
function(add_fsanitize_to_target _target _sanitizer)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_compile_definitions(${_target} PRIVATE FLATBUFFERS_MEMORY_LEAK_TRACKING)
|
target_compile_definitions(${_target} PRIVATE FLATBUFFERS_MEMORY_LEAK_TRACKING)
|
||||||
@@ -340,9 +302,7 @@ function(add_fsanitize_to_target _target _sanitizer)
|
|||||||
else()
|
else()
|
||||||
# FLATBUFFERS_CODE_SANITIZE: boolean {ON,OFF,YES,NO} or string with list of sanitizer.
|
# FLATBUFFERS_CODE_SANITIZE: boolean {ON,OFF,YES,NO} or string with list of sanitizer.
|
||||||
# List of sanitizer is string starts with '=': "=address,undefined,thread,memory".
|
# List of sanitizer is string starts with '=': "=address,undefined,thread,memory".
|
||||||
if((${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") OR
|
if(IS_CLANG OR (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 4.9))
|
||||||
((${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9"))
|
|
||||||
)
|
|
||||||
set(_sanitizer_flags "=address,undefined")
|
set(_sanitizer_flags "=address,undefined")
|
||||||
if(_sanitizer MATCHES "=.*")
|
if(_sanitizer MATCHES "=.*")
|
||||||
# override default by user-defined sanitizer list
|
# override default by user-defined sanitizer list
|
||||||
@@ -353,13 +313,14 @@ function(add_fsanitize_to_target _target _sanitizer)
|
|||||||
"-fsanitize${_sanitizer_flags}")
|
"-fsanitize${_sanitizer_flags}")
|
||||||
target_link_libraries(${_target} PRIVATE
|
target_link_libraries(${_target} PRIVATE
|
||||||
"-fsanitize${_sanitizer_flags}")
|
"-fsanitize${_sanitizer_flags}")
|
||||||
set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ON)
|
set_target_properties(${_target} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||||
message(STATUS "Sanitizer ${_sanitizer_flags} added to ${_target}")
|
message(STATUS "Sanitizer ${_sanitizer_flags} added to ${_target}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(add_pch_to_target _target _pch_header)
|
function(add_pch_to_target _target _pch_header)
|
||||||
|
# the command is available since cmake 3.16
|
||||||
if(COMMAND target_precompile_headers)
|
if(COMMAND target_precompile_headers)
|
||||||
target_precompile_headers(${_target} PRIVATE ${_pch_header})
|
target_precompile_headers(${_target} PRIVATE ${_pch_header})
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
@@ -368,20 +329,124 @@ function(add_pch_to_target _target _pch_header)
|
|||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
if(BIICODE)
|
|
||||||
include(biicode/cmake/biicode.cmake)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include_directories(include)
|
include_directories(include)
|
||||||
include_directories(grpc)
|
include_directories(grpc)
|
||||||
|
|
||||||
|
# Creates an interface library that stores the configuration settings that each
|
||||||
|
# target links too. This is a compromise between setting configuration globally
|
||||||
|
# with add_compile_options() and the more targetted target_compile_options().
|
||||||
|
# This way each target in this file can share settings and override them if
|
||||||
|
# needed.
|
||||||
|
add_library(ProjectConfig INTERFACE)
|
||||||
|
target_compile_features(ProjectConfig
|
||||||
|
INTERFACE
|
||||||
|
cxx_std_${FLATBUFFERS_CPP_STD}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Force the standard to be met.
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
# We shouldn't rely on any compiler-extensions to make things work.
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
if(MSVC_LIKE)
|
||||||
|
target_compile_options(ProjectConfig
|
||||||
|
INTERFACE
|
||||||
|
/W4
|
||||||
|
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
|
||||||
|
/WX # Treat all compiler warnings as errors
|
||||||
|
>
|
||||||
|
/wd4512 # C4512: assignment operator could not be generated
|
||||||
|
/wd4316 # C4316: object allocated on the heap may not be aligned
|
||||||
|
/wd4456 # C4456: hides previous local declaration
|
||||||
|
$<$<CXX_COMPILER_ID:Clang>:
|
||||||
|
/D_CRT_SECURE_NO_WARNINGS
|
||||||
|
>
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
target_compile_options(ProjectConfig
|
||||||
|
INTERFACE
|
||||||
|
-Wall
|
||||||
|
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
|
||||||
|
-Werror # Treat all compiler warnings as errors
|
||||||
|
|
||||||
|
-fno-rtti # Disable runtime type information
|
||||||
|
|
||||||
|
$<$<CXX_COMPILER_ID:GNU>:
|
||||||
|
# False positive string overflow
|
||||||
|
# https://github.com/google/flatbuffers/issues/7366
|
||||||
|
-Wno-error=stringop-overflow
|
||||||
|
>
|
||||||
|
>
|
||||||
|
-pedantic
|
||||||
|
-Wextra
|
||||||
|
-Wno-unused-parameter
|
||||||
|
-Wold-style-cast
|
||||||
|
-fsigned-char
|
||||||
|
-Wnon-virtual-dtor
|
||||||
|
|
||||||
|
# This isn't working for some reason: $<$<CXX_COMPILER_ID:CLANG>:
|
||||||
|
$<$<BOOL:${IS_CLANG}>:
|
||||||
|
-Wnewline-eof
|
||||||
|
-Wno-unknown-warning-option
|
||||||
|
-Wmissing-declarations
|
||||||
|
-Wzero-as-null-pointer-constant
|
||||||
|
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,3.8>:
|
||||||
|
-Wimplicit-fallthrough
|
||||||
|
-Wextra-semi
|
||||||
|
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
|
||||||
|
-Werror=unused-private-field
|
||||||
|
>
|
||||||
|
>
|
||||||
|
>
|
||||||
|
|
||||||
|
$<$<CXX_COMPILER_ID:GNU>:
|
||||||
|
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,4.4>:
|
||||||
|
-Wunused-result
|
||||||
|
-Wunused-parameter
|
||||||
|
-Werror=unused-parameter
|
||||||
|
-Wmissing-declarations
|
||||||
|
>
|
||||||
|
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,4.7>:
|
||||||
|
-Wzero-as-null-pointer-constant
|
||||||
|
>
|
||||||
|
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,7.0>:
|
||||||
|
-faligned-new
|
||||||
|
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
|
||||||
|
-Werror=implicit-fallthrough=2
|
||||||
|
>
|
||||||
|
>
|
||||||
|
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,8.0>:
|
||||||
|
-Wextra-semi
|
||||||
|
>
|
||||||
|
>
|
||||||
|
|
||||||
|
$<$<BOOL:${FLATBUFFERS_CODE_COVERAGE}>:
|
||||||
|
-g
|
||||||
|
-fprofile-arcs
|
||||||
|
-ftest-coverage
|
||||||
|
>
|
||||||
|
)
|
||||||
|
|
||||||
|
if(FLATBUFFERS_CODE_COVERAGE)
|
||||||
|
target_link_options(ProjectConfig
|
||||||
|
INTERFACE
|
||||||
|
-fprofile-arcs
|
||||||
|
-ftest-coverage
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(FLATBUFFERS_BUILD_FLATLIB)
|
if(FLATBUFFERS_BUILD_FLATLIB)
|
||||||
add_library(flatbuffers STATIC ${FlatBuffers_Library_SRCS})
|
add_library(flatbuffers STATIC ${FlatBuffers_Library_SRCS})
|
||||||
|
|
||||||
# Attach header directory for when build via add_subdirectory().
|
# Attach header directory for when build via add_subdirectory().
|
||||||
target_include_directories(flatbuffers INTERFACE
|
target_include_directories(flatbuffers
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
INTERFACE
|
||||||
target_compile_options(flatbuffers PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
)
|
||||||
|
target_link_libraries(flatbuffers PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||||
|
|
||||||
if(FLATBUFFERS_ENABLE_PCH)
|
if(FLATBUFFERS_ENABLE_PCH)
|
||||||
add_pch_to_target(flatbuffers include/flatbuffers/pch/pch.h)
|
add_pch_to_target(flatbuffers include/flatbuffers/pch/pch.h)
|
||||||
endif()
|
endif()
|
||||||
@@ -392,17 +457,21 @@ if(FLATBUFFERS_BUILD_FLATC)
|
|||||||
if(FLATBUFFERS_ENABLE_PCH)
|
if(FLATBUFFERS_ENABLE_PCH)
|
||||||
add_pch_to_target(flatc include/flatbuffers/pch/flatc_pch.h)
|
add_pch_to_target(flatc include/flatbuffers/pch/flatc_pch.h)
|
||||||
endif()
|
endif()
|
||||||
target_compile_options(flatc PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
|
|
||||||
|
target_link_libraries(flatc PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||||
|
target_compile_options(flatc
|
||||||
|
PRIVATE
|
||||||
|
$<$<AND:$<BOOL:${MSVC_LIKE}>,$<CONFIG:Release>>:
|
||||||
|
/MT
|
||||||
|
>
|
||||||
|
)
|
||||||
|
|
||||||
if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
|
if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
|
||||||
add_fsanitize_to_target(flatc ${FLATBUFFERS_CODE_SANITIZE})
|
add_fsanitize_to_target(flatc ${FLATBUFFERS_CODE_SANITIZE})
|
||||||
endif()
|
endif()
|
||||||
if(NOT FLATBUFFERS_FLATC_EXECUTABLE)
|
if(NOT FLATBUFFERS_FLATC_EXECUTABLE)
|
||||||
set(FLATBUFFERS_FLATC_EXECUTABLE $<TARGET_FILE:flatc>)
|
set(FLATBUFFERS_FLATC_EXECUTABLE $<TARGET_FILE:flatc>)
|
||||||
endif()
|
endif()
|
||||||
if(MSVC)
|
|
||||||
# Make flatc.exe not depend on runtime dlls for easy distribution.
|
|
||||||
target_compile_options(flatc PUBLIC $<$<CONFIG:Release>:/MT>)
|
|
||||||
endif()
|
|
||||||
if(FLATBUFFERS_STATIC_FLATC AND NOT MSVC)
|
if(FLATBUFFERS_STATIC_FLATC AND NOT MSVC)
|
||||||
target_link_libraries(flatc PRIVATE -static)
|
target_link_libraries(flatc PRIVATE -static)
|
||||||
endif()
|
endif()
|
||||||
@@ -410,191 +479,119 @@ endif()
|
|||||||
|
|
||||||
if(FLATBUFFERS_BUILD_FLATHASH)
|
if(FLATBUFFERS_BUILD_FLATHASH)
|
||||||
add_executable(flathash ${FlatHash_SRCS})
|
add_executable(flathash ${FlatHash_SRCS})
|
||||||
|
target_link_libraries(flathash PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
||||||
add_library(flatbuffers_shared SHARED ${FlatBuffers_Library_SRCS})
|
add_library(flatbuffers_shared SHARED ${FlatBuffers_Library_SRCS})
|
||||||
|
target_link_libraries(flatbuffers_shared PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||||
# Shared object version: "major.minor.micro"
|
# FlatBuffers use calendar-based versioning and do not provide any ABI
|
||||||
# - micro updated every release when there is no API/ABI changes
|
# stability guarantees. Therefore, always use the full version as SOVERSION
|
||||||
# - minor updated when there are additions in API/ABI
|
# in order to avoid breaking reverse dependencies on upgrades.
|
||||||
# - major (ABI number) updated when there are changes in ABI (or removals)
|
set(FlatBuffers_Library_SONAME_FULL "${PROJECT_VERSION}")
|
||||||
set(FlatBuffers_Library_SONAME_MAJOR ${VERSION_MAJOR})
|
set_target_properties(flatbuffers_shared PROPERTIES
|
||||||
set(FlatBuffers_Library_SONAME_FULL "${FlatBuffers_Library_SONAME_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
OUTPUT_NAME flatbuffers
|
||||||
set_target_properties(flatbuffers_shared PROPERTIES OUTPUT_NAME flatbuffers
|
SOVERSION "${FlatBuffers_Library_SONAME_FULL}"
|
||||||
SOVERSION "${FlatBuffers_Library_SONAME_MAJOR}"
|
|
||||||
VERSION "${FlatBuffers_Library_SONAME_FULL}")
|
VERSION "${FlatBuffers_Library_SONAME_FULL}")
|
||||||
if(FLATBUFFERS_ENABLE_PCH)
|
if(FLATBUFFERS_ENABLE_PCH)
|
||||||
add_pch_to_target(flatbuffers_shared include/flatbuffers/pch/pch.h)
|
add_pch_to_target(flatbuffers_shared include/flatbuffers/pch/pch.h)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Global list of generated files.
|
function(compile_schema SRC_FBS OPT SUFFIX OUT_GEN_FILE)
|
||||||
# Use the global property to be independent of PARENT_SCOPE.
|
|
||||||
set_property(GLOBAL PROPERTY FBS_GENERATED_OUTPUTS)
|
|
||||||
|
|
||||||
function(get_generated_output generated_files)
|
|
||||||
get_property(tmp GLOBAL PROPERTY FBS_GENERATED_OUTPUTS)
|
|
||||||
set(${generated_files} ${tmp} PARENT_SCOPE)
|
|
||||||
endfunction(get_generated_output)
|
|
||||||
|
|
||||||
function(register_generated_output file_name)
|
|
||||||
get_property(tmp GLOBAL PROPERTY FBS_GENERATED_OUTPUTS)
|
|
||||||
list(APPEND tmp ${file_name})
|
|
||||||
set_property(GLOBAL PROPERTY FBS_GENERATED_OUTPUTS ${tmp})
|
|
||||||
endfunction(register_generated_output)
|
|
||||||
|
|
||||||
function(compile_flatbuffers_schema_to_cpp_opt SRC_FBS OPT)
|
|
||||||
if(FLATBUFFERS_BUILD_LEGACY)
|
|
||||||
set(OPT ${OPT};--cpp-std c++0x)
|
|
||||||
else()
|
|
||||||
# --cpp-std is defined by flatc default settings.
|
|
||||||
endif()
|
|
||||||
message(STATUS "`${SRC_FBS}`: add generation of C++ code with '${OPT}'")
|
|
||||||
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
||||||
string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS})
|
string(REGEX REPLACE "\\.fbs$" "${SUFFIX}.h" GEN_HEADER ${SRC_FBS})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${GEN_HEADER}
|
OUTPUT ${GEN_HEADER}
|
||||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
||||||
--cpp --gen-mutable --gen-object-api --reflect-names
|
${OPT}
|
||||||
--cpp-ptr-type flatbuffers::unique_ptr # Used to test with C++98 STLs
|
--filename-suffix ${SUFFIX}
|
||||||
${OPT}
|
-o "${SRC_FBS_DIR}"
|
||||||
-I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test"
|
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||||
-o "${SRC_FBS_DIR}"
|
DEPENDS flatc ${SRC_FBS}
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
COMMENT "flatc generation: `${SRC_FBS}` -> `${GEN_HEADER}`"
|
||||||
DEPENDS flatc
|
)
|
||||||
COMMENT "Run generation: '${GEN_HEADER}'")
|
set(${OUT_GEN_FILE} ${GEN_HEADER} PARENT_SCOPE)
|
||||||
register_generated_output(${GEN_HEADER})
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(compile_flatbuffers_schema_to_cpp SRC_FBS)
|
function(compile_schema_for_test SRC_FBS OPT)
|
||||||
compile_flatbuffers_schema_to_cpp_opt(${SRC_FBS} "--no-includes;--gen-compare")
|
compile_schema("${SRC_FBS}" "${OPT}" "_generated" GEN_FILE)
|
||||||
|
target_sources(flattests PRIVATE ${GEN_FILE})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(compile_flatbuffers_schema_to_binary SRC_FBS)
|
function(compile_schema_for_test_fbsh SRC_FBS OPT)
|
||||||
message(STATUS "`${SRC_FBS}`: add generation of binary (.bfbs) schema")
|
compile_schema("${SRC_FBS}" "${OPT}" ".fbs" GEN_FILE)
|
||||||
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
target_sources(flattests PRIVATE ${GEN_FILE})
|
||||||
string(REGEX REPLACE "\\.fbs$" ".bfbs" GEN_BINARY_SCHEMA ${SRC_FBS})
|
|
||||||
# For details about flags see generate_code.py
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${GEN_BINARY_SCHEMA}
|
|
||||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
|
||||||
-b --schema --bfbs-comments --bfbs-builtins
|
|
||||||
--bfbs-filenames ${SRC_FBS_DIR}
|
|
||||||
-I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test"
|
|
||||||
-o "${SRC_FBS_DIR}"
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
|
||||||
DEPENDS flatc
|
|
||||||
COMMENT "Run generation: '${GEN_BINARY_SCHEMA}'")
|
|
||||||
register_generated_output(${GEN_BINARY_SCHEMA})
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(compile_flatbuffers_schema_to_embedded_binary SRC_FBS OPT)
|
function(compile_schema_for_samples SRC_FBS OPT)
|
||||||
if(FLATBUFFERS_BUILD_LEGACY)
|
compile_schema("${SRC_FBS}" "${OPT}" "_generated" GEN_FILE)
|
||||||
set(OPT ${OPT};--cpp-std c++0x)
|
target_sources(flatsample PRIVATE ${GEN_FILE})
|
||||||
else()
|
|
||||||
# --cpp-std is defined by flatc default settings.
|
|
||||||
endif()
|
|
||||||
message(STATUS "`${SRC_FBS}`: add generation of C++ embedded binary schema code with '${OPT}'")
|
|
||||||
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
|
||||||
string(REGEX REPLACE "\\.fbs$" "_bfbs_generated.h" GEN_BFBS_HEADER ${SRC_FBS})
|
|
||||||
# For details about flags see generate_code.py
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${GEN_BFBS_HEADER}
|
|
||||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
|
||||||
--cpp --gen-mutable --gen-object-api --reflect-names
|
|
||||||
--cpp-ptr-type flatbuffers::unique_ptr # Used to test with C++98 STLs
|
|
||||||
${OPT}
|
|
||||||
--bfbs-comments --bfbs-builtins --bfbs-gen-embed
|
|
||||||
--bfbs-filenames ${SRC_FBS_DIR}
|
|
||||||
-I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test"
|
|
||||||
-o "${SRC_FBS_DIR}"
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
|
||||||
DEPENDS flatc
|
|
||||||
COMMENT "Run generation: '${GEN_BFBS_HEADER}'")
|
|
||||||
register_generated_output(${GEN_BFBS_HEADER})
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Look if we have python 3 installed so that we can run the generate code python
|
|
||||||
# script after flatc is built.
|
|
||||||
find_package(PythonInterp 3)
|
|
||||||
|
|
||||||
if(PYTHONINTERP_FOUND AND
|
|
||||||
# Skip doing this if the MSVC version is below VS 12.
|
|
||||||
# https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
|
|
||||||
(NOT MSVC OR MSVC_VERSION GREATER 1800))
|
|
||||||
if(WIN32)
|
|
||||||
set(GENERATION_SCRIPT py scripts/generate_code.py)
|
|
||||||
else()
|
|
||||||
set(GENERATION_SCRIPT scripts/generate_code.py)
|
|
||||||
endif()
|
|
||||||
if(FLATBUFFERS_BUILD_LEGACY)
|
|
||||||
# Need to set --cpp-std c++-0x options
|
|
||||||
set(GENERATION_SCRIPT ${GENERATION_SCRIPT} --cpp-0x)
|
|
||||||
endif()
|
|
||||||
if(FLATBUFFERS_SKIP_MONSTER_EXTRA)
|
|
||||||
set(GENERATION_SCRIPT ${GENERATION_SCRIPT} --skip-monster-extra)
|
|
||||||
endif()
|
|
||||||
add_custom_command(
|
|
||||||
TARGET flatc
|
|
||||||
POST_BUILD
|
|
||||||
COMMAND ${GENERATION_SCRIPT} --flatc "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
|
||||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
||||||
COMMENT "Running ${GENERATION_SCRIPT}..."
|
|
||||||
VERBATIM)
|
|
||||||
else()
|
|
||||||
message("No Python3 interpreter found! Unable to generate files automatically.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(FLATBUFFERS_BUILD_TESTS)
|
if(FLATBUFFERS_BUILD_TESTS)
|
||||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
|
|
||||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/samples" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
|
|
||||||
|
|
||||||
# TODO Add (monster_test.fbs monsterdata_test.json)->monsterdata_test.mon
|
|
||||||
compile_flatbuffers_schema_to_cpp(tests/monster_test.fbs)
|
|
||||||
compile_flatbuffers_schema_to_binary(tests/monster_test.fbs)
|
|
||||||
compile_flatbuffers_schema_to_cpp_opt(tests/namespace_test/namespace_test1.fbs "--no-includes;--gen-compare;--gen-name-strings")
|
|
||||||
compile_flatbuffers_schema_to_cpp_opt(tests/namespace_test/namespace_test2.fbs "--no-includes;--gen-compare;--gen-name-strings")
|
|
||||||
compile_flatbuffers_schema_to_cpp_opt(tests/union_vector/union_vector.fbs "--no-includes;--gen-compare;--gen-name-strings")
|
|
||||||
compile_flatbuffers_schema_to_cpp(tests/optional_scalars.fbs)
|
|
||||||
compile_flatbuffers_schema_to_cpp_opt(tests/native_type_test.fbs "")
|
|
||||||
compile_flatbuffers_schema_to_cpp_opt(tests/arrays_test.fbs "--scoped-enums;--gen-compare")
|
|
||||||
compile_flatbuffers_schema_to_binary(tests/arrays_test.fbs)
|
|
||||||
compile_flatbuffers_schema_to_embedded_binary(tests/monster_test.fbs "--no-includes;--gen-compare")
|
|
||||||
if(NOT (MSVC AND (MSVC_VERSION LESS 1900)))
|
|
||||||
compile_flatbuffers_schema_to_cpp(tests/monster_extra.fbs) # Test floating-point NAN/INF.
|
|
||||||
endif()
|
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests)
|
|
||||||
add_executable(flattests ${FlatBuffers_Tests_SRCS})
|
add_executable(flattests ${FlatBuffers_Tests_SRCS})
|
||||||
add_dependencies(flattests generated_code)
|
target_link_libraries(flattests PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||||
set_property(TARGET flattests
|
target_include_directories(flattests PUBLIC
|
||||||
PROPERTY COMPILE_DEFINITIONS FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
|
# Ideally everything is fully qualified from the root directories
|
||||||
FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1)
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
# TODO(derekbailey): update includes to fully qualify src/ and tests/
|
||||||
|
src
|
||||||
|
tests
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/tests
|
||||||
|
)
|
||||||
|
|
||||||
|
# Have tests load data from the source directory, not the build directory.
|
||||||
|
add_definitions(-DFLATBUFFERS_TEST_PATH_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/)
|
||||||
|
|
||||||
|
# The flattest target needs some generated files
|
||||||
|
SET(FLATC_OPT_COMP --cpp --gen-compare --gen-mutable --gen-object-api --reflect-names)
|
||||||
|
SET(FLATC_OPT_SCOPED_ENUMS ${FLATC_OPT_COMP};--scoped-enums)
|
||||||
|
|
||||||
|
compile_schema_for_test(tests/alignment_test.fbs "${FLATC_OPT_COMP}")
|
||||||
|
compile_schema_for_test_fbsh(tests/default_vectors_strings_test.fbs "${FLATC_OPT_COMP}")
|
||||||
|
compile_schema_for_test(tests/arrays_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
||||||
|
compile_schema_for_test(tests/native_inline_table_test.fbs "${FLATC_OPT_COMP}")
|
||||||
|
compile_schema_for_test(tests/native_type_test.fbs "${FLATC_OPT_COMP}")
|
||||||
|
compile_schema_for_test(tests/key_field/key_field_sample.fbs "${FLATC_OPT_COMP}")
|
||||||
|
compile_schema_for_test(tests/64bit/test_64bit.fbs "${FLATC_OPT_COMP};--bfbs-gen-embed")
|
||||||
|
compile_schema_for_test(tests/64bit/evolution/v1.fbs "${FLATC_OPT_COMP}")
|
||||||
|
compile_schema_for_test(tests/64bit/evolution/v2.fbs "${FLATC_OPT_COMP}")
|
||||||
|
compile_schema_for_test(tests/union_underlying_type_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
||||||
|
compile_schema_for_test(tests/cross_namespace_pack_test.fbs "${FLATC_OPT_COMP}")
|
||||||
|
|
||||||
if(FLATBUFFERS_CODE_SANITIZE)
|
if(FLATBUFFERS_CODE_SANITIZE)
|
||||||
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
compile_flatbuffers_schema_to_cpp(samples/monster.fbs)
|
|
||||||
compile_flatbuffers_schema_to_binary(samples/monster.fbs)
|
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/samples)
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/samples)
|
||||||
|
|
||||||
add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
|
add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
|
||||||
add_dependencies(flatsamplebinary generated_code)
|
|
||||||
add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
|
add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
|
||||||
add_dependencies(flatsampletext generated_code)
|
|
||||||
add_executable(flatsamplebfbs ${FlatBuffers_Sample_BFBS_SRCS})
|
add_executable(flatsamplebfbs ${FlatBuffers_Sample_BFBS_SRCS})
|
||||||
add_dependencies(flatsamplebfbs generated_code)
|
|
||||||
|
# Add a library so there is a single target that the generated samples can
|
||||||
|
# link too.
|
||||||
|
if(MSVC OR ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.20.0")
|
||||||
|
add_library(flatsample INTERFACE)
|
||||||
|
else()
|
||||||
|
add_library(flatsample STATIC)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Since flatsample has no sources, we have to explicitly set the linker lang.
|
||||||
|
set_target_properties(flatsample PROPERTIES LINKER_LANGUAGE CXX)
|
||||||
|
|
||||||
|
target_link_libraries(flatsamplebinary PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
|
||||||
|
target_link_libraries(flatsampletext PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
|
||||||
|
target_link_libraries(flatsamplebfbs PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
|
||||||
|
|
||||||
if(FLATBUFFERS_BUILD_CPP17)
|
if(FLATBUFFERS_BUILD_CPP17)
|
||||||
# Don't generate header for flattests_cpp17 target.
|
|
||||||
# This target uses "generated_cpp17/monster_test_generated.h"
|
|
||||||
# produced by direct call of generate_code.py script.
|
|
||||||
add_executable(flattests_cpp17 ${FlatBuffers_Tests_CPP17_SRCS})
|
add_executable(flattests_cpp17 ${FlatBuffers_Tests_CPP17_SRCS})
|
||||||
add_dependencies(flattests_cpp17 generated_code)
|
target_link_libraries(flattests_cpp17 PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||||
target_compile_features(flattests_cpp17 PRIVATE cxx_std_17)
|
target_include_directories(flattests_cpp17 PUBLIC src tests)
|
||||||
target_compile_definitions(flattests_cpp17 PRIVATE
|
target_compile_features(flattests_cpp17 PRIVATE cxx_std_17) # requires cmake 3.8
|
||||||
FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
|
|
||||||
FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1
|
|
||||||
)
|
|
||||||
if(FLATBUFFERS_CODE_SANITIZE)
|
if(FLATBUFFERS_CODE_SANITIZE)
|
||||||
add_fsanitize_to_target(flattests_cpp17 ${FLATBUFFERS_CODE_SANITIZE})
|
add_fsanitize_to_target(flattests_cpp17 ${FLATBUFFERS_CODE_SANITIZE})
|
||||||
endif()
|
endif()
|
||||||
@@ -602,9 +599,6 @@ if(FLATBUFFERS_BUILD_TESTS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FLATBUFFERS_BUILD_GRPCTEST)
|
if(FLATBUFFERS_BUILD_GRPCTEST)
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-shadow")
|
|
||||||
endif()
|
|
||||||
if(NOT GRPC_INSTALL_PATH)
|
if(NOT GRPC_INSTALL_PATH)
|
||||||
message(SEND_ERROR "GRPC_INSTALL_PATH variable is not defined. See grpc/README.md")
|
message(SEND_ERROR "GRPC_INSTALL_PATH variable is not defined. See grpc/README.md")
|
||||||
endif()
|
endif()
|
||||||
@@ -619,15 +613,16 @@ if(FLATBUFFERS_BUILD_GRPCTEST)
|
|||||||
find_package(protobuf CONFIG REQUIRED)
|
find_package(protobuf CONFIG REQUIRED)
|
||||||
find_package(gRPC CONFIG REQUIRED)
|
find_package(gRPC CONFIG REQUIRED)
|
||||||
add_executable(grpctest ${FlatBuffers_GRPCTest_SRCS})
|
add_executable(grpctest ${FlatBuffers_GRPCTest_SRCS})
|
||||||
add_dependencies(grpctest generated_code)
|
target_link_libraries(grpctest
|
||||||
target_link_libraries(grpctest PRIVATE gRPC::grpc++_unsecure gRPC::grpc_unsecure gRPC::gpr pthread dl)
|
PRIVATE
|
||||||
if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
|
$<BUILD_INTERFACE:ProjectConfig>
|
||||||
# GRPC test has problems with alignment and will fail under ASAN/UBSAN.
|
gRPC::grpc++_unsecure
|
||||||
# add_fsanitize_to_target(grpctest ${FLATBUFFERS_CODE_SANITIZE})
|
gRPC::gpr
|
||||||
endif()
|
pthread
|
||||||
|
dl
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(FLATBUFFERS_INSTALL)
|
if(FLATBUFFERS_INSTALL)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
@@ -635,28 +630,24 @@ if(FLATBUFFERS_INSTALL)
|
|||||||
|
|
||||||
set(FB_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/flatbuffers")
|
set(FB_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/flatbuffers")
|
||||||
|
|
||||||
configure_file(CMake/FlatbuffersConfigVersion.cmake.in FlatbuffersConfigVersion.cmake @ONLY)
|
configure_file(CMake/flatbuffers-config-version.cmake.in flatbuffers-config-version.cmake @ONLY)
|
||||||
install(
|
install(
|
||||||
FILES "CMake/FlatbuffersConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/FlatbuffersConfigVersion.cmake"
|
FILES
|
||||||
|
"CMake/flatbuffers-config.cmake"
|
||||||
|
"CMake/BuildFlatBuffers.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-config-version.cmake"
|
||||||
DESTINATION ${FB_CMAKE_DIR}
|
DESTINATION ${FB_CMAKE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(FLATBUFFERS_BUILD_FLATLIB)
|
if(FLATBUFFERS_BUILD_FLATLIB)
|
||||||
if(CMAKE_VERSION VERSION_LESS 3.0)
|
install(
|
||||||
install(
|
TARGETS flatbuffers EXPORT FlatBuffersTargets
|
||||||
TARGETS flatbuffers EXPORT FlatbuffersTargets
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
else()
|
|
||||||
install(
|
|
||||||
TARGETS flatbuffers EXPORT FlatbuffersTargets
|
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
||||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(EXPORT FlatbuffersTargets
|
install(EXPORT FlatBuffersTargets
|
||||||
FILE FlatbuffersTargets.cmake
|
FILE FlatBuffersTargets.cmake
|
||||||
NAMESPACE flatbuffers::
|
NAMESPACE flatbuffers::
|
||||||
DESTINATION ${FB_CMAKE_DIR}
|
DESTINATION ${FB_CMAKE_DIR}
|
||||||
)
|
)
|
||||||
@@ -677,26 +668,17 @@ if(FLATBUFFERS_INSTALL)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
||||||
if(CMAKE_VERSION VERSION_LESS 3.0)
|
install(
|
||||||
install(
|
TARGETS flatbuffers_shared EXPORT FlatBuffersSharedTargets
|
||||||
TARGETS flatbuffers_shared EXPORT FlatbuffersSharedTargets
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
else()
|
|
||||||
install(
|
|
||||||
TARGETS flatbuffers_shared EXPORT FlatbuffersSharedTargets
|
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
||||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(
|
install(
|
||||||
EXPORT FlatbuffersSharedTargets
|
EXPORT FlatBuffersSharedTargets
|
||||||
FILE FlatbuffersSharedTargets.cmake
|
FILE FlatBuffersSharedTargets.cmake
|
||||||
NAMESPACE flatbuffers::
|
NAMESPACE flatbuffers::
|
||||||
DESTINATION ${FB_CMAKE_DIR}
|
DESTINATION ${FB_CMAKE_DIR}
|
||||||
)
|
)
|
||||||
@@ -723,16 +705,6 @@ if(FLATBUFFERS_BUILD_TESTS)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# This target is sync-barrier.
|
|
||||||
# Other generate-dependent targets can depend on 'generated_code' only.
|
|
||||||
get_generated_output(fbs_generated)
|
|
||||||
if(fbs_generated)
|
|
||||||
# message(STATUS "Add generated_code target with files:${fbs_generated}")
|
|
||||||
add_custom_target(generated_code
|
|
||||||
DEPENDS ${fbs_generated}
|
|
||||||
COMMENT "All generated files were updated.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(CMake/BuildFlatBuffers.cmake)
|
include(CMake/BuildFlatBuffers.cmake)
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
@@ -748,6 +720,14 @@ if(UNIX)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Include for running Google Benchmarks.
|
# Include for running Google Benchmarks.
|
||||||
if(FLATBUFFERS_BUILD_BENCHMARKS AND CMAKE_VERSION VERSION_GREATER 3.13)
|
if(FLATBUFFERS_BUILD_BENCHMARKS)
|
||||||
add_subdirectory(benchmarks)
|
add_subdirectory(benchmarks)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Add FlatBuffers::FlatBuffers interface, needed for FetchContent_Declare
|
||||||
|
add_library(FlatBuffers INTERFACE)
|
||||||
|
add_library(FlatBuffers::FlatBuffers ALIAS FlatBuffers)
|
||||||
|
target_include_directories(
|
||||||
|
FlatBuffers
|
||||||
|
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ Some tips for good pull requests:
|
|||||||
* Write a descriptive commit message. What problem are you solving and what
|
* Write a descriptive commit message. What problem are you solving and what
|
||||||
are the consequences? Where and what did you test? Some good tips:
|
are the consequences? Where and what did you test? Some good tips:
|
||||||
[here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message)
|
[here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message)
|
||||||
and [here](https://www.kernel.org/doc/Documentation/SubmittingPatches).
|
and [here](https://www.kernel.org/doc/Documentation/process/submitting-patches.rst).
|
||||||
* If your PR consists of multiple commits which are successive improvements /
|
* If your PR consists of multiple commits which are successive improvements /
|
||||||
fixes to your first commit, consider squashing them into a single commit
|
fixes to your first commit, consider squashing them into a single commit
|
||||||
(`git rebase -i`) such that your PR is a single commit on top of the current
|
(`git rebase -i`) such that your PR is a single commit on top of the current
|
||||||
@@ -40,3 +40,26 @@ Some tips for good pull requests:
|
|||||||
# The small print
|
# The small print
|
||||||
Contributions made by corporations are covered by a different agreement than
|
Contributions made by corporations are covered by a different agreement than
|
||||||
the one above, the Software Grant and Corporate Contributor License Agreement.
|
the one above, the Software Grant and Corporate Contributor License Agreement.
|
||||||
|
|
||||||
|
# Code
|
||||||
|
|
||||||
|
TL/DR
|
||||||
|
|
||||||
|
See [how to build flatc](https://flatbuffers.dev/building/).
|
||||||
|
|
||||||
|
When making changes, build `flatc` and then re-generate the goldens files to see the effect of your changes:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ cp build/flatc .
|
||||||
|
$ goldens/generate_goldens.py
|
||||||
|
```
|
||||||
|
|
||||||
|
Re-generate other code files to see the effects of the changes:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ scripts/generate_code.py
|
||||||
|
```
|
||||||
|
|
||||||
|
Run tests with [TestAll.sh](tests/TestAll.sh) in [tests](tests), or directly any of the sub-scripts run by it.
|
||||||
|
|
||||||
|
[Format the code](Formatters.md) before submitting a PR.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = 'FlatBuffers'
|
s.name = 'FlatBuffers'
|
||||||
s.version = '2.0.0'
|
s.version = '25.12.19'
|
||||||
s.summary = 'FlatBuffers: Memory Efficient Serialization Library'
|
s.summary = 'FlatBuffers: Memory Efficient Serialization Library'
|
||||||
|
|
||||||
s.description = "FlatBuffers is a cross platform serialization library architected for
|
s.description = "FlatBuffers is a cross platform serialization library architected for
|
||||||
@@ -10,12 +10,15 @@ Pod::Spec.new do |s|
|
|||||||
|
|
||||||
s.homepage = 'https://github.com/google/flatbuffers'
|
s.homepage = 'https://github.com/google/flatbuffers'
|
||||||
s.license = { :type => 'Apache2.0', :file => 'LICENSE' }
|
s.license = { :type => 'Apache2.0', :file => 'LICENSE' }
|
||||||
s.author = { 'mustii' => 'mustii@mmk.one' }
|
s.author = { 'mustii' => 'me@mustiikhalil.se' }
|
||||||
s.source = { :git => 'https://github.com/mustiikhalil/flatbuffers.git', :tag => s.version.to_s, :submodules => true }
|
s.source = { :git => 'https://github.com/google/flatbuffers.git', :tag => "v" + s.version.to_s, :submodules => true }
|
||||||
|
|
||||||
s.ios.deployment_target = '11.0'
|
s.ios.deployment_target = '11.0'
|
||||||
s.osx.deployment_target = '10.14'
|
s.osx.deployment_target = '10.14'
|
||||||
|
|
||||||
s.swift_version = '5.0'
|
s.swift_version = '5.10'
|
||||||
s.source_files = 'Sources/**/*'
|
s.source_files = 'swift/Sources/Flatbuffers/*.swift'
|
||||||
|
s.pod_target_xcconfig = {
|
||||||
|
'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
@@ -19,4 +19,4 @@ Swift uses swiftformat as it's formatter. Take a look at [how to install here](h
|
|||||||
|
|
||||||
## Typescript
|
## Typescript
|
||||||
|
|
||||||
Typescript uses eslint as it's linter. Take a look at [how to install here](https://eslint.org/docs/user-guide/getting-started). Run the following command `eslint ts/** --ext .ts` in the root directory of the project
|
Typescript uses eslint as it's linter. Take a look at [how to install here](https://eslint.org/docs/user-guide/getting-started). Run the following command `eslint ts/** --ext .ts` in the root directory of the project
|
||||||
|
|||||||
75
MODULE.bazel
Normal file
75
MODULE.bazel
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
module(
|
||||||
|
name = "flatbuffers",
|
||||||
|
version = "25.12.19",
|
||||||
|
compatibility_level = 1,
|
||||||
|
repo_name = "com_github_google_flatbuffers",
|
||||||
|
)
|
||||||
|
|
||||||
|
bazel_dep(
|
||||||
|
name = "aspect_bazel_lib",
|
||||||
|
version = "2.14.0",
|
||||||
|
)
|
||||||
|
bazel_dep(
|
||||||
|
name = "aspect_rules_esbuild",
|
||||||
|
version = "0.21.0",
|
||||||
|
)
|
||||||
|
bazel_dep(
|
||||||
|
name = "aspect_rules_js",
|
||||||
|
version = "2.3.8",
|
||||||
|
)
|
||||||
|
bazel_dep(
|
||||||
|
name = "aspect_rules_ts",
|
||||||
|
version = "3.6.0",
|
||||||
|
)
|
||||||
|
bazel_dep(
|
||||||
|
name = "grpc",
|
||||||
|
version = "1.76.0",
|
||||||
|
repo_name = "com_github_grpc_grpc",
|
||||||
|
)
|
||||||
|
bazel_dep(
|
||||||
|
name = "platforms",
|
||||||
|
version = "0.0.11",
|
||||||
|
)
|
||||||
|
bazel_dep(
|
||||||
|
name = "rules_cc",
|
||||||
|
version = "0.1.1",
|
||||||
|
)
|
||||||
|
bazel_dep(
|
||||||
|
name = "rules_go",
|
||||||
|
version = "0.50.1",
|
||||||
|
repo_name = "io_bazel_rules_go",
|
||||||
|
)
|
||||||
|
bazel_dep(
|
||||||
|
name = "rules_nodejs",
|
||||||
|
version = "6.3.3",
|
||||||
|
)
|
||||||
|
bazel_dep(
|
||||||
|
name = "rules_shell",
|
||||||
|
version = "0.3.0",
|
||||||
|
)
|
||||||
|
bazel_dep(
|
||||||
|
name = "rules_swift",
|
||||||
|
version = "3.1.2",
|
||||||
|
max_compatibility_level = 3,
|
||||||
|
repo_name = "build_bazel_rules_swift",
|
||||||
|
)
|
||||||
|
bazel_dep(
|
||||||
|
name = "bazel_skylib",
|
||||||
|
version = "1.7.1",
|
||||||
|
)
|
||||||
|
|
||||||
|
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
|
||||||
|
npm.npm_translate_lock(
|
||||||
|
name = "flatbuffers_npm",
|
||||||
|
npmrc = "//:.npmrc",
|
||||||
|
pnpm_lock = "//ts:pnpm-lock.yaml",
|
||||||
|
verify_node_modules_ignored = "//:.bazelignore",
|
||||||
|
)
|
||||||
|
use_repo(npm, "flatbuffers_npm")
|
||||||
|
|
||||||
|
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
|
||||||
|
use_repo(node, "nodejs_linux_amd64")
|
||||||
|
|
||||||
|
rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext", dev_dependency = True)
|
||||||
|
rules_ts_ext.deps()
|
||||||
|
use_repo(rules_ts_ext, "npm_typescript")
|
||||||
98
Package.swift
Normal file
98
Package.swift
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
// swift-tools-version:6.0
|
||||||
|
/*
|
||||||
|
* Copyright 2020 Google Inc. 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import PackageDescription
|
||||||
|
|
||||||
|
let package = Package(
|
||||||
|
name: "FlatBuffers",
|
||||||
|
platforms: [
|
||||||
|
.iOS(.v12),
|
||||||
|
.macOS(.v10_14),
|
||||||
|
],
|
||||||
|
products: [
|
||||||
|
.library(
|
||||||
|
name: "FlatBuffers",
|
||||||
|
targets: ["FlatBuffers"]),
|
||||||
|
.library(
|
||||||
|
name: "FlexBuffers",
|
||||||
|
targets: ["FlexBuffers"]),
|
||||||
|
],
|
||||||
|
dependencies: .dependencies,
|
||||||
|
targets: [
|
||||||
|
.target(
|
||||||
|
name: "FlatBuffers",
|
||||||
|
dependencies: ["Common"],
|
||||||
|
path: "swift/Sources/FlatBuffers",
|
||||||
|
swiftSettings: .settings),
|
||||||
|
.target(
|
||||||
|
name: "FlexBuffers",
|
||||||
|
dependencies: ["Common"],
|
||||||
|
path: "swift/Sources/FlexBuffers",
|
||||||
|
swiftSettings: .settings),
|
||||||
|
.target(
|
||||||
|
name: "Common",
|
||||||
|
path: "swift/Sources/Common",
|
||||||
|
swiftSettings: .settings),
|
||||||
|
.testTarget(
|
||||||
|
name: "FlatbuffersTests",
|
||||||
|
dependencies: .dependencies,
|
||||||
|
path: "tests/swift/Tests/Flatbuffers"),
|
||||||
|
.testTarget(
|
||||||
|
name: "FlexbuffersTests",
|
||||||
|
dependencies: ["FlexBuffers"],
|
||||||
|
path: "tests/swift/Tests/Flexbuffers"),
|
||||||
|
],
|
||||||
|
swiftLanguageModes: [.v6])
|
||||||
|
|
||||||
|
extension Array where Element == SwiftSetting {
|
||||||
|
static var settings: [SwiftSetting] {
|
||||||
|
[.enableUpcomingFeature("ExistentialAny")]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Array where Element == Package.Dependency {
|
||||||
|
static var dependencies: [Package.Dependency] {
|
||||||
|
#if os(Windows)
|
||||||
|
[]
|
||||||
|
#else
|
||||||
|
// Test only Dependency
|
||||||
|
[
|
||||||
|
.package(url: "https://github.com/grpc/grpc-swift-2.git", from: "2.0.0"),
|
||||||
|
.package(
|
||||||
|
url: "https://github.com/grpc/grpc-swift-nio-transport.git",
|
||||||
|
from: "2.0.0"),
|
||||||
|
]
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Array where Element == PackageDescription.Target.Dependency {
|
||||||
|
static var dependencies: [PackageDescription.Target.Dependency] {
|
||||||
|
#if os(Windows)
|
||||||
|
["FlatBuffers"]
|
||||||
|
#else
|
||||||
|
// Test only Dependency
|
||||||
|
[
|
||||||
|
.product(name: "GRPCCore", package: "grpc-swift-2"),
|
||||||
|
.product(
|
||||||
|
name: "GRPCNIOTransportHTTP2",
|
||||||
|
package: "grpc-swift-nio-transport"),
|
||||||
|
"FlatBuffers",
|
||||||
|
]
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
116
README.md
Normal file
116
README.md
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
 FlatBuffers
|
||||||
|
===========
|
||||||
|
|
||||||
|

|
||||||
|
[](https://buildkite.com/bazel/flatbuffers)
|
||||||
|
[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:flatbuffers)
|
||||||
|
[](https:///discord.gg/6qgKs3R)
|
||||||
|
[](https://twitter.com/wvo)
|
||||||
|
[](https://twitter.com/dbaileychess)
|
||||||
|
|
||||||
|
|
||||||
|
**FlatBuffers** is a cross platform serialization library architected for
|
||||||
|
maximum memory efficiency. It allows you to directly access serialized data without parsing/unpacking it first, while still having great forwards/backwards compatibility.
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
1. Build the compiler for flatbuffers (`flatc`)
|
||||||
|
|
||||||
|
Use `cmake` to create the build files for your platform and then perform the compilation (Linux example).
|
||||||
|
|
||||||
|
```
|
||||||
|
cmake -G "Unix Makefiles"
|
||||||
|
make -j
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Define your flatbuffer schema (`.fbs`)
|
||||||
|
|
||||||
|
Write the [schema](https://flatbuffers.dev/flatbuffers_guide_writing_schema.html) to define the data you want to serialize. See [monster.fbs](https://github.com/google/flatbuffers/blob/master/samples/monster.fbs) for an example.
|
||||||
|
|
||||||
|
3. Generate code for your language(s)
|
||||||
|
|
||||||
|
Use the `flatc` compiler to take your schema and generate language-specific code:
|
||||||
|
|
||||||
|
```
|
||||||
|
./flatc --cpp --rust monster.fbs
|
||||||
|
```
|
||||||
|
|
||||||
|
Which generates `monster_generated.h` and `monster_generated.rs` files.
|
||||||
|
|
||||||
|
4. Serialize data
|
||||||
|
|
||||||
|
Use the generated code, as well as the `FlatBufferBuilder` to construct your serialized buffer. ([`C++` example](https://github.com/google/flatbuffers/blob/master/samples/sample_binary.cpp#L24-L56))
|
||||||
|
|
||||||
|
5. Transmit/store/save Buffer
|
||||||
|
|
||||||
|
Use your serialized buffer however you want. Send it to someone, save it for later, etc...
|
||||||
|
|
||||||
|
6. Read the data
|
||||||
|
|
||||||
|
Use the generated accessors to read the data from the serialized buffer.
|
||||||
|
|
||||||
|
It doesn't need to be the same language/schema version, FlatBuffers ensures the data is readable across languages and schema versions. See the [`Rust` example](https://github.com/google/flatbuffers/blob/master/samples/sample_binary.rs#L92-L106) reading the data written by `C++`.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
**Go to our [landing page][] to browse our documentation.**
|
||||||
|
|
||||||
|
## Supported operating systems
|
||||||
|
- Windows
|
||||||
|
- macOS
|
||||||
|
- Linux
|
||||||
|
- Android
|
||||||
|
- And any others with a recent C++ compiler (C++ 11 and newer)
|
||||||
|
|
||||||
|
## Supported programming languages
|
||||||
|
|
||||||
|
Code generation and runtime libraries for many popular languages.
|
||||||
|
|
||||||
|
1. C
|
||||||
|
1. C++ - [snapcraft.io](https://snapcraft.io/flatbuffers)
|
||||||
|
1. C# - [nuget.org](https://www.nuget.org/packages/Google.FlatBuffers)
|
||||||
|
1. Dart - [pub.dev](https://pub.dev/packages/flat_buffers)
|
||||||
|
1. Go - [go.dev](https://pkg.go.dev/github.com/google/flatbuffers)
|
||||||
|
1. Java - [Maven](https://search.maven.org/artifact/com.google.flatbuffers/flatbuffers-java)
|
||||||
|
1. JavaScript - [NPM](https://www.npmjs.com/package/flatbuffers)
|
||||||
|
1. Kotlin
|
||||||
|
1. Lobster
|
||||||
|
1. Lua
|
||||||
|
1. PHP
|
||||||
|
1. Python - [PyPI](https://pypi.org/project/flatbuffers/)
|
||||||
|
1. Rust - [crates.io](https://crates.io/crates/flatbuffers)
|
||||||
|
1. Swift - [swiftpackageindex](https://swiftpackageindex.com/google/flatbuffers)
|
||||||
|
1. TypeScript - [NPM](https://www.npmjs.com/package/flatbuffers)
|
||||||
|
1. Nim
|
||||||
|
|
||||||
|
## Versioning
|
||||||
|
|
||||||
|
FlatBuffers does not follow traditional SemVer versioning (see [rationale](https://github.com/google/flatbuffers/wiki/Versioning)) but rather uses a format of the date of the release.
|
||||||
|
|
||||||
|
## Contribution
|
||||||
|
|
||||||
|
* [FlatBuffers Issues Tracker][] to submit an issue.
|
||||||
|
* [stackoverflow.com][] with [`flatbuffers` tag][] for any questions regarding FlatBuffers.
|
||||||
|
|
||||||
|
*To contribute to this project,* see [CONTRIBUTING][].
|
||||||
|
|
||||||
|
## Community
|
||||||
|
|
||||||
|
* [Discord Server](https:///discord.gg/6qgKs3R)
|
||||||
|
|
||||||
|
## Security
|
||||||
|
|
||||||
|
Please see our [Security Policy](SECURITY.md) for reporting vulnerabilities.
|
||||||
|
|
||||||
|
## Licensing
|
||||||
|
*Flatbuffers* is licensed under the Apache License, Version 2.0. See [LICENSE][] for the full license text.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
[CONTRIBUTING]: http://github.com/google/flatbuffers/blob/master/CONTRIBUTING.md
|
||||||
|
[`flatbuffers` tag]: https://stackoverflow.com/questions/tagged/flatbuffers
|
||||||
|
[FlatBuffers Google Group]: https://groups.google.com/forum/#!forum/flatbuffers
|
||||||
|
[FlatBuffers Issues Tracker]: http://github.com/google/flatbuffers/issues
|
||||||
|
[stackoverflow.com]: http://stackoverflow.com/search?q=flatbuffers
|
||||||
|
[landing page]: https://google.github.io/flatbuffers
|
||||||
|
[LICENSE]: https://github.com/google/flatbuffers/blob/master/LICENSE
|
||||||
46
WORKSPACE
46
WORKSPACE
@@ -1,46 +0,0 @@
|
|||||||
workspace(name = "com_github_google_flatbuffers")
|
|
||||||
|
|
||||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
|
||||||
|
|
||||||
http_archive(
|
|
||||||
name = "io_bazel_rules_go",
|
|
||||||
sha256 = "d1ffd055969c8f8d431e2d439813e42326961d0942bdf734d2c95dc30c369566",
|
|
||||||
urls = [
|
|
||||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
|
|
||||||
"https://github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
|
|
||||||
|
|
||||||
go_rules_dependencies()
|
|
||||||
|
|
||||||
go_register_toolchains()
|
|
||||||
|
|
||||||
##### Protobuf
|
|
||||||
_PROTOBUF_VERSION = "3.15.2"
|
|
||||||
|
|
||||||
http_archive(
|
|
||||||
name = "com_google_protobuf",
|
|
||||||
strip_prefix = "protobuf-" + _PROTOBUF_VERSION,
|
|
||||||
urls = [
|
|
||||||
"https://github.com/protocolbuffers/protobuf/archive/v" + _PROTOBUF_VERSION + ".tar.gz",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
##### GRPC
|
|
||||||
_GRPC_VERSION = "1.39.0"
|
|
||||||
|
|
||||||
http_archive(
|
|
||||||
name = "com_github_grpc_grpc",
|
|
||||||
strip_prefix = "grpc-" + _GRPC_VERSION,
|
|
||||||
urls = ["https://github.com/grpc/grpc/archive/v" + _GRPC_VERSION + ".tar.gz"],
|
|
||||||
)
|
|
||||||
|
|
||||||
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
|
|
||||||
|
|
||||||
grpc_deps()
|
|
||||||
|
|
||||||
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
|
|
||||||
|
|
||||||
grpc_extra_deps()
|
|
||||||
@@ -1,20 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!-- Copyright (c) 2014 Google, Inc.
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
|
||||||
-->
|
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>FlatBufferTest</name>
|
<name>FlatBufferTest</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
</natures>
|
||||||
|
<filteredResources>
|
||||||
|
<filter>
|
||||||
|
<id>1672434305228</id>
|
||||||
|
<name></name>
|
||||||
|
<type>30</type>
|
||||||
|
<matcher>
|
||||||
|
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||||
|
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||||
|
</matcher>
|
||||||
|
</filter>
|
||||||
|
</filteredResources>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
|||||||
@@ -1,28 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- Copyright (c) 2013 Google, Inc.
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
|
||||||
-->
|
|
||||||
<!-- BEGIN_INCLUDE(manifest) -->
|
<!-- BEGIN_INCLUDE(manifest) -->
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.example.FlatBufferTest">
|
package="com.example.FlatBufferTest">
|
||||||
|
|
||||||
|
<uses-sdk android:minSdkVersion="14"/>
|
||||||
<uses-feature android:glEsVersion="0x00020000"></uses-feature>
|
<uses-feature android:glEsVersion="0x00020000"></uses-feature>
|
||||||
|
|
||||||
<!-- This .apk has no Java code itself, so set hasCode to false. -->
|
<!-- This .apk has no Java code itself, so set hasCode to false. -->
|
||||||
<application android:label="@string/app_name"
|
<application android:name="android.support.multidex.MultiDexApplication"
|
||||||
|
android:label="@string/app_name"
|
||||||
android:hasCode="false"
|
android:hasCode="false"
|
||||||
android:allowBackup="false">
|
android:allowBackup="false">
|
||||||
<!-- Our activity is the built-in NativeActivity framework class.
|
<!-- Our activity is the built-in NativeActivity framework class.
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
apply plugin: 'kotlin-android-extensions'
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 30
|
compileSdk 33
|
||||||
buildToolsVersion "30.0.2"
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.flatbuffers.app"
|
applicationId "com.flatbuffers.app"
|
||||||
minSdkVersion 16
|
minSdkVersion 26
|
||||||
targetSdkVersion 30
|
targetSdkVersion 33
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
|
||||||
@@ -18,6 +16,18 @@ android {
|
|||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
java {
|
||||||
|
srcDir '../../java/src/main/java/'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ndk {
|
||||||
|
abiFilters 'arm64-v8a', 'armeabi-v7a'
|
||||||
|
}
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
@@ -33,7 +43,6 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ndkVersion "21.3.6528147"
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
path "src/main/cpp/CMakeLists.txt"
|
path "src/main/cpp/CMakeLists.txt"
|
||||||
@@ -52,16 +61,17 @@ android {
|
|||||||
fbsFiles.forEach{
|
fbsFiles.forEach{
|
||||||
commandLineArgs.add(it.path)
|
commandLineArgs.add(it.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
commandLine commandLineArgs
|
commandLine commandLineArgs
|
||||||
|
|
||||||
doFirst {
|
doFirst {
|
||||||
delete "$outputCppDir/"
|
delete "$outputCppDir/"
|
||||||
mkdir "$outputCppDir/"
|
mkdir "$outputCppDir/"
|
||||||
}
|
}
|
||||||
|
|
||||||
doLast {
|
doLast {
|
||||||
if (execResult.getExitValue() != 0) {
|
if (executionResult.get().exitValue != 0) {
|
||||||
println(standardOutput.toString())
|
throw new GradleException("flatc failed with: ${executionResult.get().toString()}")
|
||||||
throw new GradleException("flatc command line failed")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,6 +84,10 @@ android {
|
|||||||
|
|
||||||
standardOutput = new ByteArrayOutputStream()
|
standardOutput = new ByteArrayOutputStream()
|
||||||
errorOutput = new ByteArrayOutputStream()
|
errorOutput = new ByteArrayOutputStream()
|
||||||
|
|
||||||
|
setErrorOutput(errorOutput)
|
||||||
|
setStandardOutput(standardOutput)
|
||||||
|
|
||||||
def commandLineArgs = ['flatc', '-o', outputKotlinDir, '--kotlin']
|
def commandLineArgs = ['flatc', '-o', outputKotlinDir, '--kotlin']
|
||||||
fbsFiles.forEach{
|
fbsFiles.forEach{
|
||||||
commandLineArgs.add(it.path)
|
commandLineArgs.add(it.path)
|
||||||
@@ -85,50 +99,27 @@ android {
|
|||||||
mkdir "$outputKotlinDir/"
|
mkdir "$outputKotlinDir/"
|
||||||
}
|
}
|
||||||
doLast {
|
doLast {
|
||||||
if (execResult.getExitValue() != 0) {
|
if (executionResult.get().exitValue != 0) {
|
||||||
println(standardOutput.toString())
|
throw new GradleException("flatc failed with: ${executionResult.get().toString()}")
|
||||||
throw new GradleException("flatc command line failed")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
android.applicationVariants.all { variant ->
|
tasks.named("preBuild") {
|
||||||
variant.javaCompiler.dependsOn(generateFbsKotlin)
|
dependsOn(generateFbsKotlin)
|
||||||
variant.javaCompiler.dependsOn(generateFbsCpp)
|
dependsOn(generateFbsCpp)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
flavorDimensions "stl-variant"
|
|
||||||
productFlavors {
|
|
||||||
gnustl {
|
|
||||||
dimension "stl-variant"
|
|
||||||
applicationIdSuffix ".gnustl"
|
|
||||||
versionNameSuffix "-gnustl"
|
|
||||||
externalNativeBuild {
|
|
||||||
ndkBuild {
|
|
||||||
arguments "APP_STL=gnustl_static"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
libcpp {
|
|
||||||
dimension "stl-variant"
|
|
||||||
applicationIdSuffix ".libcpp"
|
|
||||||
versionNameSuffix "-libcpp"
|
|
||||||
externalNativeBuild {
|
|
||||||
ndkBuild {
|
|
||||||
arguments "APP_STL=c++_static"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
namespace 'com.flatbuffers.app'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
implementation 'androidx.core:core-ktx:1.3.2'
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
|
||||||
implementation 'com.google.flatbuffers:flatbuffers-java:2.0.0'
|
// If you using java runtime you can add its dependency as the example below
|
||||||
|
// implementation 'com.google.flatbuffers:flatbuffers-java:$latest_version'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
21
android/app/proguard-rules.pro
vendored
21
android/app/proguard-rules.pro
vendored
@@ -1,21 +0,0 @@
|
|||||||
# Add project specific ProGuard rules here.
|
|
||||||
# You can control the set of applied configuration files using the
|
|
||||||
# proguardFiles setting in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
|
|
||||||
# Uncomment this to preserve the line number information for
|
|
||||||
# debugging stack traces.
|
|
||||||
#-keepattributes SourceFile,LineNumberTable
|
|
||||||
|
|
||||||
# If you keep the line number information, uncomment this to
|
|
||||||
# hide the original source file name.
|
|
||||||
#-renamesourcefileattribute SourceFile
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
package="com.flatbuffers.app">
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
@@ -9,7 +8,8 @@
|
|||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
<activity android:name=".MainActivity">
|
<activity android:name=".MainActivity"
|
||||||
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ find_library( # Sets the name of the path variable.
|
|||||||
target_link_libraries( # Specifies the target library.
|
target_link_libraries( # Specifies the target library.
|
||||||
native-lib
|
native-lib
|
||||||
flatbuffers
|
flatbuffers
|
||||||
flatbuffers_tests
|
|
||||||
# Links the target library to the log library
|
# Links the target library to the log library
|
||||||
# included in the NDK.
|
# included in the NDK.
|
||||||
${log-lib} )
|
${log-lib} )
|
||||||
|
|||||||
@@ -15,25 +15,27 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
#include <string>
|
|
||||||
#include <search.h>
|
#include <search.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "generated/animal_generated.h"
|
#include "generated/animal_generated.h"
|
||||||
|
|
||||||
using namespace com::fbs::app;
|
using namespace com::fbs::app;
|
||||||
using namespace flatbuffers;
|
using namespace flatbuffers;
|
||||||
|
|
||||||
extern "C" JNIEXPORT jbyteArray JNICALL Java_com_flatbuffers_app_MainActivity_createAnimalFromJNI(
|
extern "C" JNIEXPORT jbyteArray JNICALL
|
||||||
JNIEnv* env,
|
Java_com_flatbuffers_app_MainActivity_createAnimalFromJNI(JNIEnv* env,
|
||||||
jobject /* this */) {
|
jobject /* this */) {
|
||||||
// create a new animal flatbuffers
|
// create a new animal flatbuffers
|
||||||
auto fb = FlatBufferBuilder(1024);
|
auto fb = FlatBufferBuilder(1024);
|
||||||
auto tiger = CreateAnimalDirect(fb, "Tiger", "Roar", 300);
|
auto tiger = CreateAnimalDirect(fb, "Tiger", "Roar", 300);
|
||||||
fb.Finish(tiger);
|
fb.Finish(tiger);
|
||||||
|
|
||||||
// copies it to a Java byte array.
|
// copies it to a Java byte array.
|
||||||
auto buf = reinterpret_cast<jbyte*>(fb.GetBufferPointer());
|
auto buf = reinterpret_cast<jbyte*>(fb.GetBufferPointer());
|
||||||
int size = fb.GetSize();
|
int size = fb.GetSize();
|
||||||
auto ret = env->NewByteArray(size);
|
auto ret = env->NewByteArray(size);
|
||||||
env->SetByteArrayRegion (ret, 0, fb.GetSize(), buf);
|
env->SetByteArrayRegion(ret, 0, fb.GetSize(), buf);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ set(FlatBuffers_Library_SRCS
|
|||||||
${FLATBUFFERS_SRC}/include/flatbuffers/allocator.h
|
${FLATBUFFERS_SRC}/include/flatbuffers/allocator.h
|
||||||
${FLATBUFFERS_SRC}/include/flatbuffers/array.h
|
${FLATBUFFERS_SRC}/include/flatbuffers/array.h
|
||||||
${FLATBUFFERS_SRC}/include/flatbuffers/base.h
|
${FLATBUFFERS_SRC}/include/flatbuffers/base.h
|
||||||
${FLATBUFFERS_SRC}/include/flatbuffers/bfbs_generator.h
|
|
||||||
${FLATBUFFERS_SRC}/include/flatbuffers/buffer.h
|
${FLATBUFFERS_SRC}/include/flatbuffers/buffer.h
|
||||||
${FLATBUFFERS_SRC}/include/flatbuffers/buffer_ref.h
|
${FLATBUFFERS_SRC}/include/flatbuffers/buffer_ref.h
|
||||||
${FLATBUFFERS_SRC}/include/flatbuffers/default_allocator.h
|
${FLATBUFFERS_SRC}/include/flatbuffers/default_allocator.h
|
||||||
@@ -26,6 +25,7 @@ set(FlatBuffers_Library_SRCS
|
|||||||
${FLATBUFFERS_SRC}/include/flatbuffers/flatbuffer_builder.h
|
${FLATBUFFERS_SRC}/include/flatbuffers/flatbuffer_builder.h
|
||||||
${FLATBUFFERS_SRC}/include/flatbuffers/flatbuffers.h
|
${FLATBUFFERS_SRC}/include/flatbuffers/flatbuffers.h
|
||||||
${FLATBUFFERS_SRC}/include/flatbuffers/flexbuffers.h
|
${FLATBUFFERS_SRC}/include/flatbuffers/flexbuffers.h
|
||||||
|
${FLATBUFFERS_SRC}/include/flatbuffers/flex_flat_util.h
|
||||||
${FLATBUFFERS_SRC}/include/flatbuffers/hash.h
|
${FLATBUFFERS_SRC}/include/flatbuffers/hash.h
|
||||||
${FLATBUFFERS_SRC}/include/flatbuffers/idl.h
|
${FLATBUFFERS_SRC}/include/flatbuffers/idl.h
|
||||||
${FLATBUFFERS_SRC}/include/flatbuffers/minireflect.h
|
${FLATBUFFERS_SRC}/include/flatbuffers/minireflect.h
|
||||||
@@ -48,26 +48,9 @@ set(FlatBuffers_Library_SRCS
|
|||||||
${FLATBUFFERS_SRC}/src/code_generators.cpp
|
${FLATBUFFERS_SRC}/src/code_generators.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FlatBuffers_Test_SRCS
|
|
||||||
${FLATBUFFERS_SRC}/tests/test.cpp
|
|
||||||
${FLATBUFFERS_SRC}/tests/test_assert.h
|
|
||||||
${FLATBUFFERS_SRC}/tests/test_builder.h
|
|
||||||
${FLATBUFFERS_SRC}/tests/test_assert.cpp
|
|
||||||
${FLATBUFFERS_SRC}/tests/test_builder.cpp
|
|
||||||
${FLATBUFFERS_SRC}/tests/native_type_test_impl.h
|
|
||||||
${FLATBUFFERS_SRC}/tests/native_type_test_impl.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library( # Sets the name of the library.
|
add_library( # Sets the name of the library.
|
||||||
flatbuffers
|
flatbuffers
|
||||||
|
|
||||||
${FlatBuffers_Library_SRCS}
|
${FlatBuffers_Library_SRCS}
|
||||||
${FlatBuffers_Test_SRCS}
|
|
||||||
${Generated_SRCS}
|
${Generated_SRCS}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library( # Sets the name of the library.
|
|
||||||
flatbuffers_tests
|
|
||||||
|
|
||||||
${FlatBuffers_Test_SRCS}
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
// automatically generated by the FlatBuffers compiler, do not modify
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_GENERATED_ANIMAL_COM_FBS_APP_H_
|
#ifndef FLATBUFFERS_GENERATED_ANIMAL_COM_FBS_APP_H_
|
||||||
#define FLATBUFFERS_GENERATED_ANIMAL_COM_FBS_APP_H_
|
#define FLATBUFFERS_GENERATED_ANIMAL_COM_FBS_APP_H_
|
||||||
|
|
||||||
#include "flatbuffers/flatbuffers.h"
|
#include "flatbuffers/flatbuffers.h"
|
||||||
|
|
||||||
|
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||||
|
// generated, otherwise it may not be compatible.
|
||||||
|
static_assert(FLATBUFFERS_VERSION_MAJOR == 24 &&
|
||||||
|
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||||
|
FLATBUFFERS_VERSION_REVISION == 23,
|
||||||
|
"Non-compatible flatbuffers version included");
|
||||||
|
|
||||||
namespace com {
|
namespace com {
|
||||||
namespace fbs {
|
namespace fbs {
|
||||||
namespace app {
|
namespace app {
|
||||||
@@ -13,62 +19,55 @@ namespace app {
|
|||||||
struct Animal;
|
struct Animal;
|
||||||
struct AnimalBuilder;
|
struct AnimalBuilder;
|
||||||
|
|
||||||
struct Animal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
struct Animal FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
typedef AnimalBuilder Builder;
|
typedef AnimalBuilder Builder;
|
||||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
VT_NAME = 4,
|
VT_NAME = 4,
|
||||||
VT_SOUND = 6,
|
VT_SOUND = 6,
|
||||||
VT_WEIGHT = 8
|
VT_WEIGHT = 8
|
||||||
};
|
};
|
||||||
const flatbuffers::String *name() const {
|
const ::flatbuffers::String* name() const {
|
||||||
return GetPointer<const flatbuffers::String *>(VT_NAME);
|
return GetPointer<const ::flatbuffers::String*>(VT_NAME);
|
||||||
}
|
}
|
||||||
const flatbuffers::String *sound() const {
|
const ::flatbuffers::String* sound() const {
|
||||||
return GetPointer<const flatbuffers::String *>(VT_SOUND);
|
return GetPointer<const ::flatbuffers::String*>(VT_SOUND);
|
||||||
}
|
}
|
||||||
uint16_t weight() const {
|
uint16_t weight() const { return GetField<uint16_t>(VT_WEIGHT, 0); }
|
||||||
return GetField<uint16_t>(VT_WEIGHT, 0);
|
bool Verify(::flatbuffers::Verifier& verifier) const {
|
||||||
}
|
return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NAME) &&
|
||||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
verifier.VerifyString(name()) && VerifyOffset(verifier, VT_SOUND) &&
|
||||||
return VerifyTableStart(verifier) &&
|
|
||||||
VerifyOffset(verifier, VT_NAME) &&
|
|
||||||
verifier.VerifyString(name()) &&
|
|
||||||
VerifyOffset(verifier, VT_SOUND) &&
|
|
||||||
verifier.VerifyString(sound()) &&
|
verifier.VerifyString(sound()) &&
|
||||||
VerifyField<uint16_t>(verifier, VT_WEIGHT) &&
|
VerifyField<uint16_t>(verifier, VT_WEIGHT, 2) && verifier.EndTable();
|
||||||
verifier.EndTable();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AnimalBuilder {
|
struct AnimalBuilder {
|
||||||
typedef Animal Table;
|
typedef Animal Table;
|
||||||
flatbuffers::FlatBufferBuilder &fbb_;
|
::flatbuffers::FlatBufferBuilder& fbb_;
|
||||||
flatbuffers::uoffset_t start_;
|
::flatbuffers::uoffset_t start_;
|
||||||
void add_name(flatbuffers::Offset<flatbuffers::String> name) {
|
void add_name(::flatbuffers::Offset<::flatbuffers::String> name) {
|
||||||
fbb_.AddOffset(Animal::VT_NAME, name);
|
fbb_.AddOffset(Animal::VT_NAME, name);
|
||||||
}
|
}
|
||||||
void add_sound(flatbuffers::Offset<flatbuffers::String> sound) {
|
void add_sound(::flatbuffers::Offset<::flatbuffers::String> sound) {
|
||||||
fbb_.AddOffset(Animal::VT_SOUND, sound);
|
fbb_.AddOffset(Animal::VT_SOUND, sound);
|
||||||
}
|
}
|
||||||
void add_weight(uint16_t weight) {
|
void add_weight(uint16_t weight) {
|
||||||
fbb_.AddElement<uint16_t>(Animal::VT_WEIGHT, weight, 0);
|
fbb_.AddElement<uint16_t>(Animal::VT_WEIGHT, weight, 0);
|
||||||
}
|
}
|
||||||
explicit AnimalBuilder(flatbuffers::FlatBufferBuilder &_fbb)
|
explicit AnimalBuilder(::flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) {
|
||||||
: fbb_(_fbb) {
|
|
||||||
start_ = fbb_.StartTable();
|
start_ = fbb_.StartTable();
|
||||||
}
|
}
|
||||||
AnimalBuilder &operator=(const AnimalBuilder &);
|
::flatbuffers::Offset<Animal> Finish() {
|
||||||
flatbuffers::Offset<Animal> Finish() {
|
|
||||||
const auto end = fbb_.EndTable(start_);
|
const auto end = fbb_.EndTable(start_);
|
||||||
auto o = flatbuffers::Offset<Animal>(end);
|
auto o = ::flatbuffers::Offset<Animal>(end);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline flatbuffers::Offset<Animal> CreateAnimal(
|
inline ::flatbuffers::Offset<Animal> CreateAnimal(
|
||||||
flatbuffers::FlatBufferBuilder &_fbb,
|
::flatbuffers::FlatBufferBuilder& _fbb,
|
||||||
flatbuffers::Offset<flatbuffers::String> name = 0,
|
::flatbuffers::Offset<::flatbuffers::String> name = 0,
|
||||||
flatbuffers::Offset<flatbuffers::String> sound = 0,
|
::flatbuffers::Offset<::flatbuffers::String> sound = 0,
|
||||||
uint16_t weight = 0) {
|
uint16_t weight = 0) {
|
||||||
AnimalBuilder builder_(_fbb);
|
AnimalBuilder builder_(_fbb);
|
||||||
builder_.add_sound(sound);
|
builder_.add_sound(sound);
|
||||||
@@ -77,47 +76,39 @@ inline flatbuffers::Offset<Animal> CreateAnimal(
|
|||||||
return builder_.Finish();
|
return builder_.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline flatbuffers::Offset<Animal> CreateAnimalDirect(
|
inline ::flatbuffers::Offset<Animal> CreateAnimalDirect(
|
||||||
flatbuffers::FlatBufferBuilder &_fbb,
|
::flatbuffers::FlatBufferBuilder& _fbb, const char* name = nullptr,
|
||||||
const char *name = nullptr,
|
const char* sound = nullptr, uint16_t weight = 0) {
|
||||||
const char *sound = nullptr,
|
|
||||||
uint16_t weight = 0) {
|
|
||||||
auto name__ = name ? _fbb.CreateString(name) : 0;
|
auto name__ = name ? _fbb.CreateString(name) : 0;
|
||||||
auto sound__ = sound ? _fbb.CreateString(sound) : 0;
|
auto sound__ = sound ? _fbb.CreateString(sound) : 0;
|
||||||
return com::fbs::app::CreateAnimal(
|
return com::fbs::app::CreateAnimal(_fbb, name__, sound__, weight);
|
||||||
_fbb,
|
|
||||||
name__,
|
|
||||||
sound__,
|
|
||||||
weight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const com::fbs::app::Animal *GetAnimal(const void *buf) {
|
inline const com::fbs::app::Animal* GetAnimal(const void* buf) {
|
||||||
return flatbuffers::GetRoot<com::fbs::app::Animal>(buf);
|
return ::flatbuffers::GetRoot<com::fbs::app::Animal>(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const com::fbs::app::Animal *GetSizePrefixedAnimal(const void *buf) {
|
inline const com::fbs::app::Animal* GetSizePrefixedAnimal(const void* buf) {
|
||||||
return flatbuffers::GetSizePrefixedRoot<com::fbs::app::Animal>(buf);
|
return ::flatbuffers::GetSizePrefixedRoot<com::fbs::app::Animal>(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool VerifyAnimalBuffer(
|
inline bool VerifyAnimalBuffer(::flatbuffers::Verifier& verifier) {
|
||||||
flatbuffers::Verifier &verifier) {
|
|
||||||
return verifier.VerifyBuffer<com::fbs::app::Animal>(nullptr);
|
return verifier.VerifyBuffer<com::fbs::app::Animal>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool VerifySizePrefixedAnimalBuffer(
|
inline bool VerifySizePrefixedAnimalBuffer(::flatbuffers::Verifier& verifier) {
|
||||||
flatbuffers::Verifier &verifier) {
|
|
||||||
return verifier.VerifySizePrefixedBuffer<com::fbs::app::Animal>(nullptr);
|
return verifier.VerifySizePrefixedBuffer<com::fbs::app::Animal>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FinishAnimalBuffer(
|
inline void FinishAnimalBuffer(
|
||||||
flatbuffers::FlatBufferBuilder &fbb,
|
::flatbuffers::FlatBufferBuilder& fbb,
|
||||||
flatbuffers::Offset<com::fbs::app::Animal> root) {
|
::flatbuffers::Offset<com::fbs::app::Animal> root) {
|
||||||
fbb.Finish(root);
|
fbb.Finish(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FinishSizePrefixedAnimalBuffer(
|
inline void FinishSizePrefixedAnimalBuffer(
|
||||||
flatbuffers::FlatBufferBuilder &fbb,
|
::flatbuffers::FlatBufferBuilder& fbb,
|
||||||
flatbuffers::Offset<com::fbs::app::Animal> root) {
|
::flatbuffers::Offset<com::fbs::app::Animal> root) {
|
||||||
fbb.FinishSizePrefixed(root);
|
fbb.FinishSizePrefixed(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.flatbuffers.app
|
package com.flatbuffers.app
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.fbs.app.Animal
|
import com.fbs.app.Animal
|
||||||
import com.google.flatbuffers.FlatBufferBuilder
|
import com.google.flatbuffers.FlatBufferBuilder
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
@@ -27,14 +27,15 @@ class MainActivity : AppCompatActivity() {
|
|||||||
private external fun createAnimalFromJNI(): ByteArray
|
private external fun createAnimalFromJNI(): ByteArray
|
||||||
|
|
||||||
// Create a "Cow" Animal flatbuffers from Kotlin
|
// Create a "Cow" Animal flatbuffers from Kotlin
|
||||||
private fun createAnimalFromKotlin():Animal {
|
private fun createAnimalFromKotlin(): Animal {
|
||||||
val fb = FlatBufferBuilder(100)
|
val fb = FlatBufferBuilder(100)
|
||||||
val cowOffset = Animal.createAnimal(
|
val cowOffset =
|
||||||
builder = fb,
|
Animal.createAnimal(
|
||||||
nameOffset = fb.createString("Cow"),
|
builder = fb,
|
||||||
soundOffset = fb.createString("Moo"),
|
nameOffset = fb.createString("Cow"),
|
||||||
weight = 720u
|
soundOffset = fb.createString("Moo"),
|
||||||
)
|
weight = 720u,
|
||||||
|
)
|
||||||
fb.finish(cowOffset)
|
fb.finish(cowOffset)
|
||||||
return Animal.getRootAsAnimal(fb.dataBuffer())
|
return Animal.getRootAsAnimal(fb.dataBuffer())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,63 +2,101 @@
|
|||||||
|
|
||||||
package com.fbs.app
|
package com.fbs.app
|
||||||
|
|
||||||
import java.nio.*
|
import com.google.flatbuffers.Constants
|
||||||
import kotlin.math.sign
|
import com.google.flatbuffers.FlatBufferBuilder
|
||||||
import com.google.flatbuffers.*
|
import com.google.flatbuffers.Table
|
||||||
|
import java.nio.ByteBuffer
|
||||||
|
import java.nio.ByteOrder
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@ExperimentalUnsignedTypes
|
@kotlin.ExperimentalUnsignedTypes
|
||||||
class Animal : Table() {
|
class Animal : Table() {
|
||||||
|
|
||||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||||
__reset(_i, _bb)
|
__reset(_i, _bb)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun __assign(_i: Int, _bb: ByteBuffer): Animal {
|
||||||
|
__init(_i, _bb)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
val name: String?
|
||||||
|
get() {
|
||||||
|
val o = __offset(4)
|
||||||
|
return if (o != 0) {
|
||||||
|
__string(o + bb_pos)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fun __assign(_i: Int, _bb: ByteBuffer) : Animal {
|
|
||||||
__init(_i, _bb)
|
val nameAsByteBuffer: ByteBuffer
|
||||||
return this
|
get() = __vector_as_bytebuffer(4, 1)
|
||||||
|
|
||||||
|
fun nameInByteBuffer(_bb: ByteBuffer): ByteBuffer = __vector_in_bytebuffer(_bb, 4, 1)
|
||||||
|
|
||||||
|
val sound: String?
|
||||||
|
get() {
|
||||||
|
val o = __offset(6)
|
||||||
|
return if (o != 0) {
|
||||||
|
__string(o + bb_pos)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val name : String?
|
|
||||||
get() {
|
val soundAsByteBuffer: ByteBuffer
|
||||||
val o = __offset(4)
|
get() = __vector_as_bytebuffer(6, 1)
|
||||||
return if (o != 0) __string(o + bb_pos) else null
|
|
||||||
}
|
fun soundInByteBuffer(_bb: ByteBuffer): ByteBuffer = __vector_in_bytebuffer(_bb, 6, 1)
|
||||||
val nameAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(4, 1)
|
|
||||||
fun nameInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 4, 1)
|
val weight: UShort
|
||||||
val sound : String?
|
get() {
|
||||||
get() {
|
val o = __offset(8)
|
||||||
val o = __offset(6)
|
return if (o != 0) bb.getShort(o + bb_pos).toUShort() else 0u
|
||||||
return if (o != 0) __string(o + bb_pos) else null
|
|
||||||
}
|
|
||||||
val soundAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(6, 1)
|
|
||||||
fun soundInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 6, 1)
|
|
||||||
val weight : UShort
|
|
||||||
get() {
|
|
||||||
val o = __offset(8)
|
|
||||||
return if(o != 0) bb.getShort(o + bb_pos).toUShort() else 0u
|
|
||||||
}
|
|
||||||
companion object {
|
|
||||||
fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
|
|
||||||
fun getRootAsAnimal(_bb: ByteBuffer): Animal = getRootAsAnimal(_bb, Animal())
|
|
||||||
fun getRootAsAnimal(_bb: ByteBuffer, obj: Animal): Animal {
|
|
||||||
_bb.order(ByteOrder.LITTLE_ENDIAN)
|
|
||||||
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
|
|
||||||
}
|
|
||||||
fun createAnimal(builder: FlatBufferBuilder, nameOffset: Int, soundOffset: Int, weight: UShort) : Int {
|
|
||||||
builder.startTable(3)
|
|
||||||
addSound(builder, soundOffset)
|
|
||||||
addName(builder, nameOffset)
|
|
||||||
addWeight(builder, weight)
|
|
||||||
return endAnimal(builder)
|
|
||||||
}
|
|
||||||
fun startAnimal(builder: FlatBufferBuilder) = builder.startTable(3)
|
|
||||||
fun addName(builder: FlatBufferBuilder, name: Int) = builder.addOffset(0, name, 0)
|
|
||||||
fun addSound(builder: FlatBufferBuilder, sound: Int) = builder.addOffset(1, sound, 0)
|
|
||||||
fun addWeight(builder: FlatBufferBuilder, weight: UShort) = builder.addShort(2, weight.toShort(), 0)
|
|
||||||
fun endAnimal(builder: FlatBufferBuilder) : Int {
|
|
||||||
val o = builder.endTable()
|
|
||||||
return o
|
|
||||||
}
|
|
||||||
fun finishAnimalBuffer(builder: FlatBufferBuilder, offset: Int) = builder.finish(offset)
|
|
||||||
fun finishSizePrefixedAnimalBuffer(builder: FlatBufferBuilder, offset: Int) = builder.finishSizePrefixed(offset)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun validateVersion() = Constants.FLATBUFFERS_25_12_19()
|
||||||
|
|
||||||
|
fun getRootAsAnimal(_bb: ByteBuffer): Animal = getRootAsAnimal(_bb, Animal())
|
||||||
|
|
||||||
|
fun getRootAsAnimal(_bb: ByteBuffer, obj: Animal): Animal {
|
||||||
|
_bb.order(ByteOrder.LITTLE_ENDIAN)
|
||||||
|
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun createAnimal(
|
||||||
|
builder: FlatBufferBuilder,
|
||||||
|
nameOffset: Int,
|
||||||
|
soundOffset: Int,
|
||||||
|
weight: UShort,
|
||||||
|
): Int {
|
||||||
|
builder.startTable(3)
|
||||||
|
addSound(builder, soundOffset)
|
||||||
|
addName(builder, nameOffset)
|
||||||
|
addWeight(builder, weight)
|
||||||
|
return endAnimal(builder)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun startAnimal(builder: FlatBufferBuilder) = builder.startTable(3)
|
||||||
|
|
||||||
|
fun addName(builder: FlatBufferBuilder, name: Int) = builder.addOffset(0, name, 0)
|
||||||
|
|
||||||
|
fun addSound(builder: FlatBufferBuilder, sound: Int) = builder.addOffset(1, sound, 0)
|
||||||
|
|
||||||
|
fun addWeight(builder: FlatBufferBuilder, weight: UShort) =
|
||||||
|
builder.addShort(2, weight.toShort(), 0)
|
||||||
|
|
||||||
|
fun endAnimal(builder: FlatBufferBuilder): Int {
|
||||||
|
val o = builder.endTable()
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
fun finishAnimalBuffer(builder: FlatBufferBuilder, offset: Int) = builder.finish(offset)
|
||||||
|
|
||||||
|
fun finishSizePrefixedAnimalBuffer(builder: FlatBufferBuilder, offset: Int) =
|
||||||
|
builder.finishSizePrefixed(offset)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = "1.4.10"
|
ext.kotlin_version = "1.7.21"
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
classpath 'com.android.tools.build:gradle:7.4.1'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
@@ -17,7 +17,7 @@ buildscript {
|
|||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,3 +19,5 @@ android.useAndroidX=true
|
|||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
# Kotlin code style for this project: "official" or "obsolete":
|
# Kotlin code style for this project: "official" or "obsolete":
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
|
# Use parallel builds
|
||||||
|
org.gradle.parallel=true
|
||||||
BIN
android/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
android/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
@@ -1,6 +1,5 @@
|
|||||||
#Thu Oct 29 19:47:23 CET 2020
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
|
|
||||||
|
|||||||
76
appveyor.yml
76
appveyor.yml
@@ -1,76 +0,0 @@
|
|||||||
branches:
|
|
||||||
only:
|
|
||||||
- master
|
|
||||||
|
|
||||||
environment:
|
|
||||||
nodejs_version: "14"
|
|
||||||
|
|
||||||
global:
|
|
||||||
# Workaround for https://github.com/conda/conda-build/issues/636
|
|
||||||
PYTHONIOENCODING: UTF-8
|
|
||||||
CONDA_INSTALL_LOCN: "C:\\Miniconda35-x64"
|
|
||||||
CMAKE_OPTIONS: ""
|
|
||||||
CPP_TEST_OPTIONS: ""
|
|
||||||
CHECK_GEN_CODE: 1
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
|
||||||
CMAKE_VS_VERSION: "14 2015"
|
|
||||||
|
|
||||||
platform:
|
|
||||||
- x86
|
|
||||||
- x64
|
|
||||||
|
|
||||||
configuration:
|
|
||||||
- Debug
|
|
||||||
- Release
|
|
||||||
|
|
||||||
before_build:
|
|
||||||
- cmake . -G"Visual Studio %CMAKE_VS_VERSION%" -DFLATBUFFERS_CODE_SANITIZE=1 %CMAKE_OPTIONS%
|
|
||||||
# This cuts down on a lot of noise generated by xamarin warnings.
|
|
||||||
- if exist "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets" del "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets"
|
|
||||||
|
|
||||||
build:
|
|
||||||
project: ALL_BUILD.vcxproj
|
|
||||||
verbosity: minimal
|
|
||||||
|
|
||||||
after_build:
|
|
||||||
- python conan/appveyor/install.py
|
|
||||||
- python conan/appveyor/build.py
|
|
||||||
|
|
||||||
install:
|
|
||||||
- set PATH=%CONDA_INSTALL_LOCN%;%CONDA_INSTALL_LOCN%\scripts;%PATH%;
|
|
||||||
- ps: Install-Product node $env:nodejs_version
|
|
||||||
|
|
||||||
test_script:
|
|
||||||
- if [%CHECK_GEN_CODE%]==[1] (call py scripts/check_generate_code.py "%CPP_TEST_OPTIONS%")
|
|
||||||
- "cd tests"
|
|
||||||
- 7z a GeneratedMyGameCode.zip MyGame\
|
|
||||||
- rem "---------------- C++ -----------------"
|
|
||||||
- "cd .."
|
|
||||||
- "%CONFIGURATION%\\flattests.exe"
|
|
||||||
- rem "---------------- JS -----------------"
|
|
||||||
- "node --version"
|
|
||||||
- "npm install"
|
|
||||||
- "npm run compile"
|
|
||||||
- "cd tests"
|
|
||||||
- "TypeScriptTest.bat"
|
|
||||||
- rem "---------------- C# -----------------"
|
|
||||||
# Have to compile this here rather than in "build" above because AppVeyor only
|
|
||||||
# supports building one project??
|
|
||||||
- "cd FlatBuffers.Test"
|
|
||||||
- "dotnet new sln"
|
|
||||||
- "dotnet sln add FlatBuffers.Test.csproj"
|
|
||||||
- "nuget restore"
|
|
||||||
- "mkdir .tmp"
|
|
||||||
- "msbuild.exe /property:Configuration=Release;OutputPath=.tmp /verbosity:minimal FlatBuffers.Test.csproj"
|
|
||||||
- ".tmp\\FlatBuffers.Test.exe"
|
|
||||||
# Run tests with UNSAFE_BYTEBUFFER
|
|
||||||
- "msbuild.exe /property:Configuration=Release;UnsafeByteBuffer=true;OutputPath=.tmp /verbosity:minimal FlatBuffers.Test.csproj"
|
|
||||||
- ".tmp\\FlatBuffers.Test.exe"
|
|
||||||
|
|
||||||
artifacts:
|
|
||||||
- path: $(CONFIGURATION)\flatc.exe
|
|
||||||
name: flatc.exe
|
|
||||||
- path: tests\GeneratedMyGameCode.zip
|
|
||||||
name: GeneratedMyGameCode.zip
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
# Setup for running Google Benchmarks (https://github.com/google/benchmark) on
|
# Setup for running Google Benchmarks (https://github.com/google/benchmark) on
|
||||||
# flatbuffers. This requires both that benchmark library and its depenency gtest
|
# flatbuffers. This requires both that benchmark library and its dependency gtest
|
||||||
# to build. Instead of including them here or doing a submodule, this uses
|
# to build. Instead of including them here or doing a submodule, this uses
|
||||||
# FetchContent (https://cmake.org/cmake/help/latest/module/FetchContent.html) to
|
# FetchContent (https://cmake.org/cmake/help/latest/module/FetchContent.html) to
|
||||||
# grab the dependencies at config time. This requires CMake 3.14 or higher.
|
# grab the dependencies at config time. This requires CMake 3.14 or higher.
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ FetchContent_Declare(
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
googlebenchmark
|
googlebenchmark
|
||||||
GIT_REPOSITORY https://github.com/google/benchmark.git
|
GIT_REPOSITORY https://github.com/google/benchmark.git
|
||||||
GIT_TAG f91b6b42b1b9854772a90ae9501464a161707d1e # v1.6.0
|
GIT_TAG 0d98dba29d66e93259db7daa53a9327df767a415 # v1.6.1
|
||||||
)
|
)
|
||||||
|
|
||||||
# For Windows: Prevent overriding the parent project's compiler/linker
|
# For Windows: Prevent overriding the parent project's compiler/linker
|
||||||
@@ -27,7 +28,7 @@ FetchContent_MakeAvailable(
|
|||||||
googlebenchmark
|
googlebenchmark
|
||||||
)
|
)
|
||||||
|
|
||||||
set(CPP_BENCH_DIR cpp)
|
set(CPP_BENCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cpp)
|
||||||
set(CPP_FB_BENCH_DIR ${CPP_BENCH_DIR}/flatbuffers)
|
set(CPP_FB_BENCH_DIR ${CPP_BENCH_DIR}/flatbuffers)
|
||||||
set(CPP_RAW_BENCH_DIR ${CPP_BENCH_DIR}/raw)
|
set(CPP_RAW_BENCH_DIR ${CPP_BENCH_DIR}/raw)
|
||||||
set(CPP_BENCH_FBS ${CPP_FB_BENCH_DIR}/bench.fbs)
|
set(CPP_BENCH_FBS ${CPP_FB_BENCH_DIR}/bench.fbs)
|
||||||
@@ -62,8 +63,14 @@ add_custom_command(
|
|||||||
add_executable(flatbenchmark ${FlatBenchmark_SRCS})
|
add_executable(flatbenchmark ${FlatBenchmark_SRCS})
|
||||||
|
|
||||||
# Benchmark requires C++11
|
# Benchmark requires C++11
|
||||||
target_compile_features(flatbenchmark PUBLIC
|
target_compile_features(flatbenchmark PRIVATE
|
||||||
cxx_std_11
|
cxx_std_11 # requires cmake 3.8
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_options(flatbenchmark
|
||||||
|
PRIVATE
|
||||||
|
-fno-aligned-new
|
||||||
|
-Wno-deprecated-declarations
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set the output directory to the root binary directory
|
# Set the output directory to the root binary directory
|
||||||
@@ -75,7 +82,7 @@ set_target_properties(flatbenchmark
|
|||||||
# The includes of the benchmark files are fully qualified from flatbuffers root.
|
# The includes of the benchmark files are fully qualified from flatbuffers root.
|
||||||
target_include_directories(flatbenchmark PUBLIC ${CMAKE_SOURCE_DIR})
|
target_include_directories(flatbenchmark PUBLIC ${CMAKE_SOURCE_DIR})
|
||||||
|
|
||||||
target_link_libraries(flatbenchmark
|
target_link_libraries(flatbenchmark PRIVATE
|
||||||
benchmark::benchmark_main # _main to use their entry point
|
benchmark::benchmark_main # _main to use their entry point
|
||||||
gtest # Link to gtest so we can also assert in the benchmarks
|
gtest # Link to gtest so we can also assert in the benchmarks
|
||||||
)
|
)
|
||||||
@@ -8,12 +8,12 @@ struct Bench {
|
|||||||
|
|
||||||
inline void Add(int64_t value) { sum += value; }
|
inline void Add(int64_t value) { sum += value; }
|
||||||
|
|
||||||
virtual uint8_t *Encode(void *buf, int64_t &len) = 0;
|
virtual uint8_t* Encode(void* buf, int64_t& len) = 0;
|
||||||
virtual void *Decode(void *buf, int64_t len) = 0;
|
virtual void* Decode(void* buf, int64_t len) = 0;
|
||||||
virtual int64_t Use(void *decoded) = 0;
|
virtual int64_t Use(void* decoded) = 0;
|
||||||
virtual void Dealloc(void *decoded) = 0;
|
virtual void Dealloc(void* decoded) = 0;
|
||||||
|
|
||||||
int64_t sum = 0;
|
int64_t sum = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BENCHMARKS_CPP_BENCH_H_
|
#endif // BENCHMARKS_CPP_BENCH_H_
|
||||||
@@ -5,8 +5,8 @@
|
|||||||
#include "benchmarks/cpp/flatbuffers/fb_bench.h"
|
#include "benchmarks/cpp/flatbuffers/fb_bench.h"
|
||||||
#include "benchmarks/cpp/raw/raw_bench.h"
|
#include "benchmarks/cpp/raw/raw_bench.h"
|
||||||
|
|
||||||
static inline void Encode(benchmark::State &state,
|
static inline void Encode(benchmark::State& state,
|
||||||
std::unique_ptr<Bench> &bench, uint8_t *buffer) {
|
std::unique_ptr<Bench>& bench, uint8_t* buffer) {
|
||||||
int64_t length;
|
int64_t length;
|
||||||
for (auto _ : state) {
|
for (auto _ : state) {
|
||||||
bench->Encode(buffer, length);
|
bench->Encode(buffer, length);
|
||||||
@@ -14,31 +14,33 @@ static inline void Encode(benchmark::State &state,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Decode(benchmark::State &state,
|
static inline void Decode(benchmark::State& state,
|
||||||
std::unique_ptr<Bench> &bench, uint8_t *buffer) {
|
std::unique_ptr<Bench>& bench, uint8_t* buffer) {
|
||||||
int64_t length;
|
int64_t length;
|
||||||
uint8_t *encoded = bench->Encode(buffer, length);
|
uint8_t* encoded = bench->Encode(buffer, length);
|
||||||
|
|
||||||
for (auto _ : state) {
|
for (auto _ : state) {
|
||||||
void *decoded = bench->Decode(encoded, length);
|
void* decoded = bench->Decode(encoded, length);
|
||||||
benchmark::DoNotOptimize(decoded);
|
benchmark::DoNotOptimize(decoded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Use(benchmark::State &state, std::unique_ptr<Bench> &bench,
|
static inline void Use(benchmark::State& state, std::unique_ptr<Bench>& bench,
|
||||||
uint8_t *buffer, int64_t check_sum) {
|
uint8_t* buffer, int64_t check_sum) {
|
||||||
int64_t length;
|
int64_t length;
|
||||||
uint8_t *encoded = bench->Encode(buffer, length);
|
uint8_t* encoded = bench->Encode(buffer, length);
|
||||||
void *decoded = bench->Decode(encoded, length);
|
void* decoded = bench->Decode(encoded, length);
|
||||||
|
|
||||||
int64_t sum = 0;
|
int64_t sum = 0;
|
||||||
|
|
||||||
for (auto _ : state) { sum = bench->Use(decoded); }
|
for (auto _ : state) {
|
||||||
|
sum = bench->Use(decoded);
|
||||||
|
}
|
||||||
|
|
||||||
EXPECT_EQ(sum, check_sum);
|
EXPECT_EQ(sum, check_sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BM_Flatbuffers_Encode(benchmark::State &state) {
|
static void BM_Flatbuffers_Encode(benchmark::State& state) {
|
||||||
const int64_t kBufferLength = 1024;
|
const int64_t kBufferLength = 1024;
|
||||||
uint8_t buffer[kBufferLength];
|
uint8_t buffer[kBufferLength];
|
||||||
|
|
||||||
@@ -48,7 +50,7 @@ static void BM_Flatbuffers_Encode(benchmark::State &state) {
|
|||||||
}
|
}
|
||||||
BENCHMARK(BM_Flatbuffers_Encode);
|
BENCHMARK(BM_Flatbuffers_Encode);
|
||||||
|
|
||||||
static void BM_Flatbuffers_Decode(benchmark::State &state) {
|
static void BM_Flatbuffers_Decode(benchmark::State& state) {
|
||||||
const int64_t kBufferLength = 1024;
|
const int64_t kBufferLength = 1024;
|
||||||
uint8_t buffer[kBufferLength];
|
uint8_t buffer[kBufferLength];
|
||||||
|
|
||||||
@@ -58,7 +60,7 @@ static void BM_Flatbuffers_Decode(benchmark::State &state) {
|
|||||||
}
|
}
|
||||||
BENCHMARK(BM_Flatbuffers_Decode);
|
BENCHMARK(BM_Flatbuffers_Decode);
|
||||||
|
|
||||||
static void BM_Flatbuffers_Use(benchmark::State &state) {
|
static void BM_Flatbuffers_Use(benchmark::State& state) {
|
||||||
const int64_t kBufferLength = 1024;
|
const int64_t kBufferLength = 1024;
|
||||||
uint8_t buffer[kBufferLength];
|
uint8_t buffer[kBufferLength];
|
||||||
|
|
||||||
@@ -68,7 +70,7 @@ static void BM_Flatbuffers_Use(benchmark::State &state) {
|
|||||||
}
|
}
|
||||||
BENCHMARK(BM_Flatbuffers_Use);
|
BENCHMARK(BM_Flatbuffers_Use);
|
||||||
|
|
||||||
static void BM_Raw_Encode(benchmark::State &state) {
|
static void BM_Raw_Encode(benchmark::State& state) {
|
||||||
const int64_t kBufferLength = 1024;
|
const int64_t kBufferLength = 1024;
|
||||||
uint8_t buffer[kBufferLength];
|
uint8_t buffer[kBufferLength];
|
||||||
|
|
||||||
@@ -77,7 +79,7 @@ static void BM_Raw_Encode(benchmark::State &state) {
|
|||||||
}
|
}
|
||||||
BENCHMARK(BM_Raw_Encode);
|
BENCHMARK(BM_Raw_Encode);
|
||||||
|
|
||||||
static void BM_Raw_Decode(benchmark::State &state) {
|
static void BM_Raw_Decode(benchmark::State& state) {
|
||||||
const int64_t kBufferLength = 1024;
|
const int64_t kBufferLength = 1024;
|
||||||
uint8_t buffer[kBufferLength];
|
uint8_t buffer[kBufferLength];
|
||||||
|
|
||||||
@@ -86,7 +88,7 @@ static void BM_Raw_Decode(benchmark::State &state) {
|
|||||||
}
|
}
|
||||||
BENCHMARK(BM_Raw_Decode);
|
BENCHMARK(BM_Raw_Decode);
|
||||||
|
|
||||||
static void BM_Raw_Use(benchmark::State &state) {
|
static void BM_Raw_Use(benchmark::State& state) {
|
||||||
const int64_t kBufferLength = 1024;
|
const int64_t kBufferLength = 1024;
|
||||||
uint8_t buffer[kBufferLength];
|
uint8_t buffer[kBufferLength];
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
// automatically generated by the FlatBuffers compiler, do not modify
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_GENERATED_BENCH_BENCHMARKS_FLATBUFFERS_H_
|
#ifndef FLATBUFFERS_GENERATED_BENCH_BENCHMARKS_FLATBUFFERS_H_
|
||||||
#define FLATBUFFERS_GENERATED_BENCH_BENCHMARKS_FLATBUFFERS_H_
|
#define FLATBUFFERS_GENERATED_BENCH_BENCHMARKS_FLATBUFFERS_H_
|
||||||
|
|
||||||
#include "flatbuffers/flatbuffers.h"
|
#include "flatbuffers/flatbuffers.h"
|
||||||
|
|
||||||
|
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||||
|
// generated, otherwise it may not be compatible.
|
||||||
|
static_assert(FLATBUFFERS_VERSION_MAJOR == 24 &&
|
||||||
|
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||||
|
FLATBUFFERS_VERSION_REVISION == 23,
|
||||||
|
"Non-compatible flatbuffers version included");
|
||||||
|
|
||||||
namespace benchmarks_flatbuffers {
|
namespace benchmarks_flatbuffers {
|
||||||
|
|
||||||
struct Foo;
|
struct Foo;
|
||||||
@@ -27,25 +33,16 @@ enum Enum : int16_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline const Enum (&EnumValuesEnum())[3] {
|
inline const Enum (&EnumValuesEnum())[3] {
|
||||||
static const Enum values[] = {
|
static const Enum values[] = {Enum_Apples, Enum_Pears, Enum_Bananas};
|
||||||
Enum_Apples,
|
|
||||||
Enum_Pears,
|
|
||||||
Enum_Bananas
|
|
||||||
};
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char * const *EnumNamesEnum() {
|
inline const char* const* EnumNamesEnum() {
|
||||||
static const char * const names[4] = {
|
static const char* const names[4] = {"Apples", "Pears", "Bananas", nullptr};
|
||||||
"Apples",
|
|
||||||
"Pears",
|
|
||||||
"Bananas",
|
|
||||||
nullptr
|
|
||||||
};
|
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char *EnumNameEnum(Enum e) {
|
inline const char* EnumNameEnum(Enum e) {
|
||||||
if (flatbuffers::IsOutRange(e, Enum_Apples, Enum_Bananas)) return "";
|
if (flatbuffers::IsOutRange(e, Enum_Apples, Enum_Bananas)) return "";
|
||||||
const size_t index = static_cast<size_t>(e);
|
const size_t index = static_cast<size_t>(e);
|
||||||
return EnumNamesEnum()[index];
|
return EnumNamesEnum()[index];
|
||||||
@@ -60,12 +57,7 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Foo FLATBUFFERS_FINAL_CLASS {
|
|||||||
uint32_t length_;
|
uint32_t length_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Foo()
|
Foo() : id_(0), count_(0), prefix_(0), padding0__(0), length_(0) {
|
||||||
: id_(0),
|
|
||||||
count_(0),
|
|
||||||
prefix_(0),
|
|
||||||
padding0__(0),
|
|
||||||
length_(0) {
|
|
||||||
(void)padding0__;
|
(void)padding0__;
|
||||||
}
|
}
|
||||||
Foo(uint64_t _id, int16_t _count, int8_t _prefix, uint32_t _length)
|
Foo(uint64_t _id, int16_t _count, int8_t _prefix, uint32_t _length)
|
||||||
@@ -76,18 +68,10 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Foo FLATBUFFERS_FINAL_CLASS {
|
|||||||
length_(flatbuffers::EndianScalar(_length)) {
|
length_(flatbuffers::EndianScalar(_length)) {
|
||||||
(void)padding0__;
|
(void)padding0__;
|
||||||
}
|
}
|
||||||
uint64_t id() const {
|
uint64_t id() const { return flatbuffers::EndianScalar(id_); }
|
||||||
return flatbuffers::EndianScalar(id_);
|
int16_t count() const { return flatbuffers::EndianScalar(count_); }
|
||||||
}
|
int8_t prefix() const { return flatbuffers::EndianScalar(prefix_); }
|
||||||
int16_t count() const {
|
uint32_t length() const { return flatbuffers::EndianScalar(length_); }
|
||||||
return flatbuffers::EndianScalar(count_);
|
|
||||||
}
|
|
||||||
int8_t prefix() const {
|
|
||||||
return flatbuffers::EndianScalar(prefix_);
|
|
||||||
}
|
|
||||||
uint32_t length() const {
|
|
||||||
return flatbuffers::EndianScalar(length_);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
FLATBUFFERS_STRUCT_END(Foo, 16);
|
FLATBUFFERS_STRUCT_END(Foo, 16);
|
||||||
|
|
||||||
@@ -97,20 +81,17 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Bar FLATBUFFERS_FINAL_CLASS {
|
|||||||
int32_t time_;
|
int32_t time_;
|
||||||
float ratio_;
|
float ratio_;
|
||||||
uint16_t size_;
|
uint16_t size_;
|
||||||
int16_t padding0__; int32_t padding1__;
|
int16_t padding0__;
|
||||||
|
int32_t padding1__;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Bar()
|
Bar()
|
||||||
: parent_(),
|
: parent_(), time_(0), ratio_(0), size_(0), padding0__(0), padding1__(0) {
|
||||||
time_(0),
|
|
||||||
ratio_(0),
|
|
||||||
size_(0),
|
|
||||||
padding0__(0),
|
|
||||||
padding1__(0) {
|
|
||||||
(void)padding0__;
|
(void)padding0__;
|
||||||
(void)padding1__;
|
(void)padding1__;
|
||||||
}
|
}
|
||||||
Bar(const benchmarks_flatbuffers::Foo &_parent, int32_t _time, float _ratio, uint16_t _size)
|
Bar(const benchmarks_flatbuffers::Foo& _parent, int32_t _time, float _ratio,
|
||||||
|
uint16_t _size)
|
||||||
: parent_(_parent),
|
: parent_(_parent),
|
||||||
time_(flatbuffers::EndianScalar(_time)),
|
time_(flatbuffers::EndianScalar(_time)),
|
||||||
ratio_(flatbuffers::EndianScalar(_ratio)),
|
ratio_(flatbuffers::EndianScalar(_ratio)),
|
||||||
@@ -120,18 +101,10 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Bar FLATBUFFERS_FINAL_CLASS {
|
|||||||
(void)padding0__;
|
(void)padding0__;
|
||||||
(void)padding1__;
|
(void)padding1__;
|
||||||
}
|
}
|
||||||
const benchmarks_flatbuffers::Foo &parent() const {
|
const benchmarks_flatbuffers::Foo& parent() const { return parent_; }
|
||||||
return parent_;
|
int32_t time() const { return flatbuffers::EndianScalar(time_); }
|
||||||
}
|
float ratio() const { return flatbuffers::EndianScalar(ratio_); }
|
||||||
int32_t time() const {
|
uint16_t size() const { return flatbuffers::EndianScalar(size_); }
|
||||||
return flatbuffers::EndianScalar(time_);
|
|
||||||
}
|
|
||||||
float ratio() const {
|
|
||||||
return flatbuffers::EndianScalar(ratio_);
|
|
||||||
}
|
|
||||||
uint16_t size() const {
|
|
||||||
return flatbuffers::EndianScalar(size_);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
FLATBUFFERS_STRUCT_END(Bar, 32);
|
FLATBUFFERS_STRUCT_END(Bar, 32);
|
||||||
|
|
||||||
@@ -143,34 +116,28 @@ struct FooBar FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
|||||||
VT_RATING = 8,
|
VT_RATING = 8,
|
||||||
VT_POSTFIX = 10
|
VT_POSTFIX = 10
|
||||||
};
|
};
|
||||||
const benchmarks_flatbuffers::Bar *sibling() const {
|
const benchmarks_flatbuffers::Bar* sibling() const {
|
||||||
return GetStruct<const benchmarks_flatbuffers::Bar *>(VT_SIBLING);
|
return GetStruct<const benchmarks_flatbuffers::Bar*>(VT_SIBLING);
|
||||||
}
|
}
|
||||||
const flatbuffers::String *name() const {
|
const flatbuffers::String* name() const {
|
||||||
return GetPointer<const flatbuffers::String *>(VT_NAME);
|
return GetPointer<const flatbuffers::String*>(VT_NAME);
|
||||||
}
|
}
|
||||||
double rating() const {
|
double rating() const { return GetField<double>(VT_RATING, 0.0); }
|
||||||
return GetField<double>(VT_RATING, 0.0);
|
uint8_t postfix() const { return GetField<uint8_t>(VT_POSTFIX, 0); }
|
||||||
}
|
bool Verify(flatbuffers::Verifier& verifier) const {
|
||||||
uint8_t postfix() const {
|
|
||||||
return GetField<uint8_t>(VT_POSTFIX, 0);
|
|
||||||
}
|
|
||||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
VerifyField<benchmarks_flatbuffers::Bar>(verifier, VT_SIBLING) &&
|
VerifyField<benchmarks_flatbuffers::Bar>(verifier, VT_SIBLING, 8) &&
|
||||||
VerifyOffset(verifier, VT_NAME) &&
|
VerifyOffset(verifier, VT_NAME) && verifier.VerifyString(name()) &&
|
||||||
verifier.VerifyString(name()) &&
|
VerifyField<double>(verifier, VT_RATING, 8) &&
|
||||||
VerifyField<double>(verifier, VT_RATING) &&
|
VerifyField<uint8_t>(verifier, VT_POSTFIX, 1) && verifier.EndTable();
|
||||||
VerifyField<uint8_t>(verifier, VT_POSTFIX) &&
|
|
||||||
verifier.EndTable();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FooBarBuilder {
|
struct FooBarBuilder {
|
||||||
typedef FooBar Table;
|
typedef FooBar Table;
|
||||||
flatbuffers::FlatBufferBuilder &fbb_;
|
flatbuffers::FlatBufferBuilder& fbb_;
|
||||||
flatbuffers::uoffset_t start_;
|
flatbuffers::uoffset_t start_;
|
||||||
void add_sibling(const benchmarks_flatbuffers::Bar *sibling) {
|
void add_sibling(const benchmarks_flatbuffers::Bar* sibling) {
|
||||||
fbb_.AddStruct(FooBar::VT_SIBLING, sibling);
|
fbb_.AddStruct(FooBar::VT_SIBLING, sibling);
|
||||||
}
|
}
|
||||||
void add_name(flatbuffers::Offset<flatbuffers::String> name) {
|
void add_name(flatbuffers::Offset<flatbuffers::String> name) {
|
||||||
@@ -182,8 +149,7 @@ struct FooBarBuilder {
|
|||||||
void add_postfix(uint8_t postfix) {
|
void add_postfix(uint8_t postfix) {
|
||||||
fbb_.AddElement<uint8_t>(FooBar::VT_POSTFIX, postfix, 0);
|
fbb_.AddElement<uint8_t>(FooBar::VT_POSTFIX, postfix, 0);
|
||||||
}
|
}
|
||||||
explicit FooBarBuilder(flatbuffers::FlatBufferBuilder &_fbb)
|
explicit FooBarBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) {
|
||||||
: fbb_(_fbb) {
|
|
||||||
start_ = fbb_.StartTable();
|
start_ = fbb_.StartTable();
|
||||||
}
|
}
|
||||||
flatbuffers::Offset<FooBar> Finish() {
|
flatbuffers::Offset<FooBar> Finish() {
|
||||||
@@ -194,10 +160,9 @@ struct FooBarBuilder {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline flatbuffers::Offset<FooBar> CreateFooBar(
|
inline flatbuffers::Offset<FooBar> CreateFooBar(
|
||||||
flatbuffers::FlatBufferBuilder &_fbb,
|
flatbuffers::FlatBufferBuilder& _fbb,
|
||||||
const benchmarks_flatbuffers::Bar *sibling = nullptr,
|
const benchmarks_flatbuffers::Bar* sibling = nullptr,
|
||||||
flatbuffers::Offset<flatbuffers::String> name = 0,
|
flatbuffers::Offset<flatbuffers::String> name = 0, double rating = 0.0,
|
||||||
double rating = 0.0,
|
|
||||||
uint8_t postfix = 0) {
|
uint8_t postfix = 0) {
|
||||||
FooBarBuilder builder_(_fbb);
|
FooBarBuilder builder_(_fbb);
|
||||||
builder_.add_rating(rating);
|
builder_.add_rating(rating);
|
||||||
@@ -208,18 +173,12 @@ inline flatbuffers::Offset<FooBar> CreateFooBar(
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline flatbuffers::Offset<FooBar> CreateFooBarDirect(
|
inline flatbuffers::Offset<FooBar> CreateFooBarDirect(
|
||||||
flatbuffers::FlatBufferBuilder &_fbb,
|
flatbuffers::FlatBufferBuilder& _fbb,
|
||||||
const benchmarks_flatbuffers::Bar *sibling = nullptr,
|
const benchmarks_flatbuffers::Bar* sibling = nullptr,
|
||||||
const char *name = nullptr,
|
const char* name = nullptr, double rating = 0.0, uint8_t postfix = 0) {
|
||||||
double rating = 0.0,
|
|
||||||
uint8_t postfix = 0) {
|
|
||||||
auto name__ = name ? _fbb.CreateString(name) : 0;
|
auto name__ = name ? _fbb.CreateString(name) : 0;
|
||||||
return benchmarks_flatbuffers::CreateFooBar(
|
return benchmarks_flatbuffers::CreateFooBar(_fbb, sibling, name__, rating,
|
||||||
_fbb,
|
postfix);
|
||||||
sibling,
|
|
||||||
name__,
|
|
||||||
rating,
|
|
||||||
postfix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FooBarContainer FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
struct FooBarContainer FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||||
@@ -230,49 +189,53 @@ struct FooBarContainer FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
|||||||
VT_FRUIT = 8,
|
VT_FRUIT = 8,
|
||||||
VT_LOCATION = 10
|
VT_LOCATION = 10
|
||||||
};
|
};
|
||||||
const flatbuffers::Vector<flatbuffers::Offset<benchmarks_flatbuffers::FooBar>> *list() const {
|
const flatbuffers::Vector<
|
||||||
return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<benchmarks_flatbuffers::FooBar>> *>(VT_LIST);
|
flatbuffers::Offset<benchmarks_flatbuffers::FooBar>>*
|
||||||
}
|
list() const {
|
||||||
bool initialized() const {
|
return GetPointer<const flatbuffers::Vector<
|
||||||
return GetField<uint8_t>(VT_INITIALIZED, 0) != 0;
|
flatbuffers::Offset<benchmarks_flatbuffers::FooBar>>*>(VT_LIST);
|
||||||
}
|
}
|
||||||
|
bool initialized() const { return GetField<uint8_t>(VT_INITIALIZED, 0) != 0; }
|
||||||
benchmarks_flatbuffers::Enum fruit() const {
|
benchmarks_flatbuffers::Enum fruit() const {
|
||||||
return static_cast<benchmarks_flatbuffers::Enum>(GetField<int16_t>(VT_FRUIT, 0));
|
return static_cast<benchmarks_flatbuffers::Enum>(
|
||||||
|
GetField<int16_t>(VT_FRUIT, 0));
|
||||||
}
|
}
|
||||||
const flatbuffers::String *location() const {
|
const flatbuffers::String* location() const {
|
||||||
return GetPointer<const flatbuffers::String *>(VT_LOCATION);
|
return GetPointer<const flatbuffers::String*>(VT_LOCATION);
|
||||||
}
|
}
|
||||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
bool Verify(flatbuffers::Verifier& verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_LIST) &&
|
||||||
VerifyOffset(verifier, VT_LIST) &&
|
|
||||||
verifier.VerifyVector(list()) &&
|
verifier.VerifyVector(list()) &&
|
||||||
verifier.VerifyVectorOfTables(list()) &&
|
verifier.VerifyVectorOfTables(list()) &&
|
||||||
VerifyField<uint8_t>(verifier, VT_INITIALIZED) &&
|
VerifyField<uint8_t>(verifier, VT_INITIALIZED, 1) &&
|
||||||
VerifyField<int16_t>(verifier, VT_FRUIT) &&
|
VerifyField<int16_t>(verifier, VT_FRUIT, 2) &&
|
||||||
VerifyOffset(verifier, VT_LOCATION) &&
|
VerifyOffset(verifier, VT_LOCATION) &&
|
||||||
verifier.VerifyString(location()) &&
|
verifier.VerifyString(location()) && verifier.EndTable();
|
||||||
verifier.EndTable();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FooBarContainerBuilder {
|
struct FooBarContainerBuilder {
|
||||||
typedef FooBarContainer Table;
|
typedef FooBarContainer Table;
|
||||||
flatbuffers::FlatBufferBuilder &fbb_;
|
flatbuffers::FlatBufferBuilder& fbb_;
|
||||||
flatbuffers::uoffset_t start_;
|
flatbuffers::uoffset_t start_;
|
||||||
void add_list(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<benchmarks_flatbuffers::FooBar>>> list) {
|
void add_list(flatbuffers::Offset<flatbuffers::Vector<
|
||||||
|
flatbuffers::Offset<benchmarks_flatbuffers::FooBar>>>
|
||||||
|
list) {
|
||||||
fbb_.AddOffset(FooBarContainer::VT_LIST, list);
|
fbb_.AddOffset(FooBarContainer::VT_LIST, list);
|
||||||
}
|
}
|
||||||
void add_initialized(bool initialized) {
|
void add_initialized(bool initialized) {
|
||||||
fbb_.AddElement<uint8_t>(FooBarContainer::VT_INITIALIZED, static_cast<uint8_t>(initialized), 0);
|
fbb_.AddElement<uint8_t>(FooBarContainer::VT_INITIALIZED,
|
||||||
|
static_cast<uint8_t>(initialized), 0);
|
||||||
}
|
}
|
||||||
void add_fruit(benchmarks_flatbuffers::Enum fruit) {
|
void add_fruit(benchmarks_flatbuffers::Enum fruit) {
|
||||||
fbb_.AddElement<int16_t>(FooBarContainer::VT_FRUIT, static_cast<int16_t>(fruit), 0);
|
fbb_.AddElement<int16_t>(FooBarContainer::VT_FRUIT,
|
||||||
|
static_cast<int16_t>(fruit), 0);
|
||||||
}
|
}
|
||||||
void add_location(flatbuffers::Offset<flatbuffers::String> location) {
|
void add_location(flatbuffers::Offset<flatbuffers::String> location) {
|
||||||
fbb_.AddOffset(FooBarContainer::VT_LOCATION, location);
|
fbb_.AddOffset(FooBarContainer::VT_LOCATION, location);
|
||||||
}
|
}
|
||||||
explicit FooBarContainerBuilder(flatbuffers::FlatBufferBuilder &_fbb)
|
explicit FooBarContainerBuilder(flatbuffers::FlatBufferBuilder& _fbb)
|
||||||
: fbb_(_fbb) {
|
: fbb_(_fbb) {
|
||||||
start_ = fbb_.StartTable();
|
start_ = fbb_.StartTable();
|
||||||
}
|
}
|
||||||
flatbuffers::Offset<FooBarContainer> Finish() {
|
flatbuffers::Offset<FooBarContainer> Finish() {
|
||||||
@@ -283,8 +246,10 @@ struct FooBarContainerBuilder {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline flatbuffers::Offset<FooBarContainer> CreateFooBarContainer(
|
inline flatbuffers::Offset<FooBarContainer> CreateFooBarContainer(
|
||||||
flatbuffers::FlatBufferBuilder &_fbb,
|
flatbuffers::FlatBufferBuilder& _fbb,
|
||||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<benchmarks_flatbuffers::FooBar>>> list = 0,
|
flatbuffers::Offset<flatbuffers::Vector<
|
||||||
|
flatbuffers::Offset<benchmarks_flatbuffers::FooBar>>>
|
||||||
|
list = 0,
|
||||||
bool initialized = false,
|
bool initialized = false,
|
||||||
benchmarks_flatbuffers::Enum fruit = benchmarks_flatbuffers::Enum_Apples,
|
benchmarks_flatbuffers::Enum fruit = benchmarks_flatbuffers::Enum_Apples,
|
||||||
flatbuffers::Offset<flatbuffers::String> location = 0) {
|
flatbuffers::Offset<flatbuffers::String> location = 0) {
|
||||||
@@ -297,47 +262,52 @@ inline flatbuffers::Offset<FooBarContainer> CreateFooBarContainer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline flatbuffers::Offset<FooBarContainer> CreateFooBarContainerDirect(
|
inline flatbuffers::Offset<FooBarContainer> CreateFooBarContainerDirect(
|
||||||
flatbuffers::FlatBufferBuilder &_fbb,
|
flatbuffers::FlatBufferBuilder& _fbb,
|
||||||
const std::vector<flatbuffers::Offset<benchmarks_flatbuffers::FooBar>> *list = nullptr,
|
const std::vector<flatbuffers::Offset<benchmarks_flatbuffers::FooBar>>*
|
||||||
|
list = nullptr,
|
||||||
bool initialized = false,
|
bool initialized = false,
|
||||||
benchmarks_flatbuffers::Enum fruit = benchmarks_flatbuffers::Enum_Apples,
|
benchmarks_flatbuffers::Enum fruit = benchmarks_flatbuffers::Enum_Apples,
|
||||||
const char *location = nullptr) {
|
const char* location = nullptr) {
|
||||||
auto list__ = list ? _fbb.CreateVector<flatbuffers::Offset<benchmarks_flatbuffers::FooBar>>(*list) : 0;
|
auto list__ =
|
||||||
|
list ? _fbb.CreateVector<
|
||||||
|
flatbuffers::Offset<benchmarks_flatbuffers::FooBar>>(*list)
|
||||||
|
: 0;
|
||||||
auto location__ = location ? _fbb.CreateString(location) : 0;
|
auto location__ = location ? _fbb.CreateString(location) : 0;
|
||||||
return benchmarks_flatbuffers::CreateFooBarContainer(
|
return benchmarks_flatbuffers::CreateFooBarContainer(
|
||||||
_fbb,
|
_fbb, list__, initialized, fruit, location__);
|
||||||
list__,
|
|
||||||
initialized,
|
|
||||||
fruit,
|
|
||||||
location__);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const benchmarks_flatbuffers::FooBarContainer *GetFooBarContainer(const void *buf) {
|
inline const benchmarks_flatbuffers::FooBarContainer* GetFooBarContainer(
|
||||||
|
const void* buf) {
|
||||||
return flatbuffers::GetRoot<benchmarks_flatbuffers::FooBarContainer>(buf);
|
return flatbuffers::GetRoot<benchmarks_flatbuffers::FooBarContainer>(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const benchmarks_flatbuffers::FooBarContainer *GetSizePrefixedFooBarContainer(const void *buf) {
|
inline const benchmarks_flatbuffers::FooBarContainer*
|
||||||
return flatbuffers::GetSizePrefixedRoot<benchmarks_flatbuffers::FooBarContainer>(buf);
|
GetSizePrefixedFooBarContainer(const void* buf) {
|
||||||
|
return flatbuffers::GetSizePrefixedRoot<
|
||||||
|
benchmarks_flatbuffers::FooBarContainer>(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool VerifyFooBarContainerBuffer(
|
inline bool VerifyFooBarContainerBuffer(flatbuffers::Verifier& verifier) {
|
||||||
flatbuffers::Verifier &verifier) {
|
return verifier.VerifyBuffer<benchmarks_flatbuffers::FooBarContainer>(
|
||||||
return verifier.VerifyBuffer<benchmarks_flatbuffers::FooBarContainer>(nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool VerifySizePrefixedFooBarContainerBuffer(
|
inline bool VerifySizePrefixedFooBarContainerBuffer(
|
||||||
flatbuffers::Verifier &verifier) {
|
flatbuffers::Verifier& verifier) {
|
||||||
return verifier.VerifySizePrefixedBuffer<benchmarks_flatbuffers::FooBarContainer>(nullptr);
|
return verifier
|
||||||
|
.VerifySizePrefixedBuffer<benchmarks_flatbuffers::FooBarContainer>(
|
||||||
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FinishFooBarContainerBuffer(
|
inline void FinishFooBarContainerBuffer(
|
||||||
flatbuffers::FlatBufferBuilder &fbb,
|
flatbuffers::FlatBufferBuilder& fbb,
|
||||||
flatbuffers::Offset<benchmarks_flatbuffers::FooBarContainer> root) {
|
flatbuffers::Offset<benchmarks_flatbuffers::FooBarContainer> root) {
|
||||||
fbb.Finish(root);
|
fbb.Finish(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FinishSizePrefixedFooBarContainerBuffer(
|
inline void FinishSizePrefixedFooBarContainerBuffer(
|
||||||
flatbuffers::FlatBufferBuilder &fbb,
|
flatbuffers::FlatBufferBuilder& fbb,
|
||||||
flatbuffers::Offset<benchmarks_flatbuffers::FooBarContainer> root) {
|
flatbuffers::Offset<benchmarks_flatbuffers::FooBarContainer> root) {
|
||||||
fbb.FinishSizePrefixed(root);
|
fbb.FinishSizePrefixed(root);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ using namespace benchmarks_flatbuffers;
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct FlatBufferBench : Bench {
|
struct FlatBufferBench : Bench {
|
||||||
explicit FlatBufferBench(int64_t initial_size, Allocator *allocator)
|
explicit FlatBufferBench(int64_t initial_size, Allocator* allocator)
|
||||||
: fbb(initial_size, allocator, false) {}
|
: fbb(initial_size, allocator, false) {}
|
||||||
|
|
||||||
uint8_t *Encode(void *, int64_t &len) {
|
uint8_t* Encode(void*, int64_t& len) override {
|
||||||
fbb.Clear();
|
fbb.Clear();
|
||||||
|
|
||||||
const int kVectorLength = 3;
|
const int kVectorLength = 3;
|
||||||
@@ -40,7 +40,7 @@ struct FlatBufferBench : Bench {
|
|||||||
return fbb.GetBufferPointer();
|
return fbb.GetBufferPointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t Use(void *decoded) {
|
int64_t Use(void* decoded) override {
|
||||||
sum = 0;
|
sum = 0;
|
||||||
auto foobarcontainer = GetFooBarContainer(decoded);
|
auto foobarcontainer = GetFooBarContainer(decoded);
|
||||||
sum = 0;
|
sum = 0;
|
||||||
@@ -56,7 +56,7 @@ struct FlatBufferBench : Bench {
|
|||||||
Add(static_cast<int64_t>(bar->ratio()));
|
Add(static_cast<int64_t>(bar->ratio()));
|
||||||
Add(bar->size());
|
Add(bar->size());
|
||||||
Add(bar->time());
|
Add(bar->time());
|
||||||
auto &foo = bar->parent();
|
auto& foo = bar->parent();
|
||||||
Add(foo.count());
|
Add(foo.count());
|
||||||
Add(foo.id());
|
Add(foo.id());
|
||||||
Add(foo.length());
|
Add(foo.length());
|
||||||
@@ -65,8 +65,8 @@ struct FlatBufferBench : Bench {
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *Decode(void *buffer, int64_t) { return buffer; }
|
void* Decode(void* buffer, int64_t) override { return buffer; }
|
||||||
void Dealloc(void *) override{};
|
void Dealloc(void*) override {};
|
||||||
|
|
||||||
FlatBufferBuilder fbb;
|
FlatBufferBuilder fbb;
|
||||||
};
|
};
|
||||||
@@ -74,7 +74,7 @@ struct FlatBufferBench : Bench {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::unique_ptr<Bench> NewFlatBuffersBench(int64_t initial_size,
|
std::unique_ptr<Bench> NewFlatBuffersBench(int64_t initial_size,
|
||||||
Allocator *allocator) {
|
Allocator* allocator) {
|
||||||
return std::unique_ptr<FlatBufferBench>(
|
return std::unique_ptr<FlatBufferBench>(
|
||||||
new FlatBufferBench(initial_size, allocator));
|
new FlatBufferBench(initial_size, allocator));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,16 +8,16 @@
|
|||||||
#include "include/flatbuffers/flatbuffers.h"
|
#include "include/flatbuffers/flatbuffers.h"
|
||||||
|
|
||||||
struct StaticAllocator : public flatbuffers::Allocator {
|
struct StaticAllocator : public flatbuffers::Allocator {
|
||||||
explicit StaticAllocator(uint8_t *buffer) : buffer_(buffer) {}
|
explicit StaticAllocator(uint8_t* buffer) : buffer_(buffer) {}
|
||||||
|
|
||||||
uint8_t *allocate(size_t) override { return buffer_; }
|
uint8_t* allocate(size_t) override { return buffer_; }
|
||||||
|
|
||||||
void deallocate(uint8_t *, size_t) override {}
|
void deallocate(uint8_t*, size_t) override {}
|
||||||
|
|
||||||
uint8_t *buffer_;
|
uint8_t* buffer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<Bench> NewFlatBuffersBench(
|
std::unique_ptr<Bench> NewFlatBuffersBench(
|
||||||
int64_t initial_size = 1024, flatbuffers::Allocator *allocator = nullptr);
|
int64_t initial_size = 1024, flatbuffers::Allocator* allocator = nullptr);
|
||||||
|
|
||||||
#endif // BENCHMARKS_CPP_FLATBUFFERS_FB_BENCH_H_
|
#endif // BENCHMARKS_CPP_FLATBUFFERS_FB_BENCH_H_
|
||||||
@@ -45,8 +45,8 @@ struct FooBarContainer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct RawBench : Bench {
|
struct RawBench : Bench {
|
||||||
uint8_t *Encode(void *buf, int64_t &len) {
|
uint8_t* Encode(void* buf, int64_t& len) override {
|
||||||
FooBarContainer *fbc = new (buf) FooBarContainer;
|
FooBarContainer* fbc = new (buf) FooBarContainer;
|
||||||
strcpy(fbc->location, "http://google.com/flatbuffers/"); // Unsafe eek!
|
strcpy(fbc->location, "http://google.com/flatbuffers/"); // Unsafe eek!
|
||||||
fbc->location_len = (int)strlen(fbc->location);
|
fbc->location_len = (int)strlen(fbc->location);
|
||||||
fbc->fruit = Bananas;
|
fbc->fruit = Bananas;
|
||||||
@@ -54,16 +54,16 @@ struct RawBench : Bench {
|
|||||||
for (int i = 0; i < kVectorLength; i++) {
|
for (int i = 0; i < kVectorLength; i++) {
|
||||||
// We add + i to not make these identical copies for a more realistic
|
// We add + i to not make these identical copies for a more realistic
|
||||||
// compression test.
|
// compression test.
|
||||||
auto &foobar = fbc->list[i];
|
auto& foobar = fbc->list[i];
|
||||||
foobar.rating = 3.1415432432445543543 + i;
|
foobar.rating = 3.1415432432445543543 + i;
|
||||||
foobar.postfix = '!' + i;
|
foobar.postfix = '!' + i;
|
||||||
strcpy(foobar.name, "Hello, World!");
|
strcpy(foobar.name, "Hello, World!");
|
||||||
foobar.name_len = (int)strlen(foobar.name);
|
foobar.name_len = (int)strlen(foobar.name);
|
||||||
auto &bar = foobar.sibling;
|
auto& bar = foobar.sibling;
|
||||||
bar.ratio = 3.14159f + i;
|
bar.ratio = 3.14159f + i;
|
||||||
bar.size = 10000 + i;
|
bar.size = 10000 + i;
|
||||||
bar.time = 123456 + i;
|
bar.time = 123456 + i;
|
||||||
auto &foo = bar.parent;
|
auto& foo = bar.parent;
|
||||||
foo.id = 0xABADCAFEABADCAFE + i;
|
foo.id = 0xABADCAFEABADCAFE + i;
|
||||||
foo.count = 10000 + i;
|
foo.count = 10000 + i;
|
||||||
foo.length = 1000000 + i;
|
foo.length = 1000000 + i;
|
||||||
@@ -71,11 +71,11 @@ struct RawBench : Bench {
|
|||||||
}
|
}
|
||||||
|
|
||||||
len = sizeof(FooBarContainer);
|
len = sizeof(FooBarContainer);
|
||||||
return reinterpret_cast<uint8_t *>(fbc);
|
return reinterpret_cast<uint8_t*>(fbc);
|
||||||
};
|
};
|
||||||
|
|
||||||
int64_t Use(void *decoded) {
|
int64_t Use(void* decoded) override {
|
||||||
auto foobarcontainer = reinterpret_cast<FooBarContainer *>(decoded);
|
auto foobarcontainer = reinterpret_cast<FooBarContainer*>(decoded);
|
||||||
sum = 0;
|
sum = 0;
|
||||||
Add(foobarcontainer->initialized);
|
Add(foobarcontainer->initialized);
|
||||||
Add(foobarcontainer->location_len);
|
Add(foobarcontainer->location_len);
|
||||||
@@ -89,7 +89,7 @@ struct RawBench : Bench {
|
|||||||
Add(static_cast<int64_t>(bar->ratio));
|
Add(static_cast<int64_t>(bar->ratio));
|
||||||
Add(bar->size);
|
Add(bar->size);
|
||||||
Add(bar->time);
|
Add(bar->time);
|
||||||
auto &foo = bar->parent;
|
auto& foo = bar->parent;
|
||||||
Add(foo.count);
|
Add(foo.count);
|
||||||
Add(foo.id);
|
Add(foo.id);
|
||||||
Add(foo.length);
|
Add(foo.length);
|
||||||
@@ -98,8 +98,8 @@ struct RawBench : Bench {
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *Decode(void *buf, int64_t) { return buf; }
|
void* Decode(void* buf, int64_t) override { return buf; }
|
||||||
void Dealloc(void *) override{};
|
void Dealloc(void*) override {};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -0,0 +1,266 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2024 Google Inc. 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Benchmark
|
||||||
|
import FlatBuffers
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
@usableFromInline
|
||||||
|
struct AA: NativeStruct {
|
||||||
|
public init(a: Double, b: Double) {
|
||||||
|
self.a = a
|
||||||
|
self.b = b
|
||||||
|
}
|
||||||
|
var a: Double
|
||||||
|
var b: Double
|
||||||
|
}
|
||||||
|
|
||||||
|
let benchmarks = {
|
||||||
|
let oneGB: Int32 = 1_024_000_000
|
||||||
|
let data = {
|
||||||
|
var array = [8888.88, 8888.88]
|
||||||
|
var data = Data()
|
||||||
|
array.withUnsafeBytes { ptr in
|
||||||
|
data.append(contentsOf: ptr)
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
}()
|
||||||
|
let ints: [Int] = Array(repeating: 42, count: 100)
|
||||||
|
let bytes: [UInt8] = Array(repeating: 42, count: 100)
|
||||||
|
let str10 = (0...9).map { _ -> String in "x" }.joined()
|
||||||
|
let str100 = (0...99).map { _ -> String in "x" }.joined()
|
||||||
|
let array: [AA] = [
|
||||||
|
AA(a: 2.4, b: 2.4),
|
||||||
|
AA(a: 2.4, b: 2.4),
|
||||||
|
AA(a: 2.4, b: 2.4),
|
||||||
|
AA(a: 2.4, b: 2.4),
|
||||||
|
AA(a: 2.4, b: 2.4),
|
||||||
|
]
|
||||||
|
|
||||||
|
let metrics: [BenchmarkMetric] = [
|
||||||
|
.cpuTotal,
|
||||||
|
.wallClock,
|
||||||
|
.mallocCountTotal,
|
||||||
|
.releaseCount,
|
||||||
|
.peakMemoryResident,
|
||||||
|
]
|
||||||
|
let maxIterations = 1_000_000
|
||||||
|
let maxDuration: Duration = .seconds(3)
|
||||||
|
let singleConfiguration: Benchmark.Configuration = .init(
|
||||||
|
metrics: metrics,
|
||||||
|
warmupIterations: 1,
|
||||||
|
scalingFactor: .one,
|
||||||
|
maxDuration: maxDuration,
|
||||||
|
maxIterations: maxIterations)
|
||||||
|
let kiloConfiguration: Benchmark.Configuration = .init(
|
||||||
|
metrics: metrics,
|
||||||
|
warmupIterations: 1,
|
||||||
|
scalingFactor: .kilo,
|
||||||
|
maxDuration: maxDuration,
|
||||||
|
maxIterations: maxIterations)
|
||||||
|
let megaConfiguration: Benchmark.Configuration = .init(
|
||||||
|
metrics: metrics,
|
||||||
|
warmupIterations: 1,
|
||||||
|
scalingFactor: .mega,
|
||||||
|
maxDuration: maxDuration,
|
||||||
|
maxIterations: maxIterations)
|
||||||
|
|
||||||
|
Benchmark.defaultConfiguration = megaConfiguration
|
||||||
|
|
||||||
|
Benchmark("Allocating 1GB", configuration: singleConfiguration) { benchmark in
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
blackHole(FlatBufferBuilder(initialSize: oneGB))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark(
|
||||||
|
"Allocating ByteBuffer 1GB",
|
||||||
|
configuration: singleConfiguration)
|
||||||
|
{ benchmark in
|
||||||
|
let memory = UnsafeMutableRawPointer.allocate(
|
||||||
|
byteCount: 1_024_000_000,
|
||||||
|
alignment: 1)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
blackHole(ByteBuffer(assumingMemoryBound: memory, capacity: Int(oneGB)))
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark("Clearing 1GB", configuration: singleConfiguration) { benchmark in
|
||||||
|
var fb = FlatBufferBuilder(initialSize: oneGB)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
blackHole(fb.clear())
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark("Strings 10") { benchmark in
|
||||||
|
var fb = FlatBufferBuilder(initialSize: 1 << 20)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
blackHole(fb.create(string: str10))
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark("Strings 100") { benchmark in
|
||||||
|
var fb = FlatBufferBuilder(initialSize: 1 << 20)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
blackHole(fb.create(string: str100))
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark("Vector 1 Bytes") { benchmark in
|
||||||
|
var fb = FlatBufferBuilder(initialSize: 1 << 20)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
blackHole(fb.createVector(bytes: bytes))
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark("Vector 1 Ints") { benchmark in
|
||||||
|
var fb = FlatBufferBuilder(initialSize: 1 << 20)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
blackHole(fb.createVector(ints))
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark("Vector 100 Ints") { benchmark in
|
||||||
|
var fb = FlatBufferBuilder(initialSize: 1 << 20)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for i in benchmark.scaledIterations {
|
||||||
|
blackHole(fb.createVector(ints))
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark("Vector 100 Bytes") { benchmark in
|
||||||
|
var fb = FlatBufferBuilder(initialSize: 1 << 20)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for i in benchmark.scaledIterations {
|
||||||
|
blackHole(fb.createVector(bytes))
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark("Vector 100 ContiguousBytes") { benchmark in
|
||||||
|
var fb = FlatBufferBuilder(initialSize: 1 << 20)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for i in benchmark.scaledIterations {
|
||||||
|
blackHole(fb.createVector(bytes: bytes))
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark(
|
||||||
|
"FlatBufferBuilder Add",
|
||||||
|
configuration: kiloConfiguration)
|
||||||
|
{ benchmark in
|
||||||
|
var fb = FlatBufferBuilder(initialSize: 1024 * 1024 * 32)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
let off = fb.create(string: "T")
|
||||||
|
let s = fb.startTable(with: 4)
|
||||||
|
fb.add(element: 3.2, def: 0, at: 2)
|
||||||
|
fb.add(element: 4.2, def: 0, at: 4)
|
||||||
|
fb.add(element: 5.2, def: 0, at: 6)
|
||||||
|
fb.add(offset: off, at: 8)
|
||||||
|
blackHole(fb.endTable(at: s))
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark(
|
||||||
|
"FlatBufferBuilder Start table",
|
||||||
|
configuration: kiloConfiguration)
|
||||||
|
{ benchmark in
|
||||||
|
var fb = FlatBufferBuilder(initialSize: 1024 * 1024 * 32)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
let s = fb.startTable(with: 4)
|
||||||
|
blackHole(fb.endTable(at: s))
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark("Struct") { benchmark in
|
||||||
|
var fb = FlatBufferBuilder(initialSize: 1024 * 1024 * 32)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
blackHole(fb.create(struct: array.first!))
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark("Structs") { benchmark in
|
||||||
|
let rawSize = ((16 * 5) * benchmark.scaledIterations.count) / 1024
|
||||||
|
var fb = FlatBufferBuilder(initialSize: Int32(rawSize * 1600))
|
||||||
|
var offsets: [Offset] = []
|
||||||
|
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
let vector = fb.createVector(
|
||||||
|
ofStructs: array)
|
||||||
|
let start = fb.startTable(with: 1)
|
||||||
|
fb.add(offset: vector, at: 4)
|
||||||
|
offsets.append(Offset(offset: fb.endTable(at: start)))
|
||||||
|
}
|
||||||
|
|
||||||
|
let vector = fb.createVector(ofOffsets: offsets)
|
||||||
|
let start = fb.startTable(with: 1)
|
||||||
|
fb.add(offset: vector, at: 4)
|
||||||
|
let root = Offset(offset: fb.endTable(at: start))
|
||||||
|
blackHole(fb.finish(offset: root))
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark("Vector of Offsets") { benchmark in
|
||||||
|
let rawSize = ((16 * 5) * benchmark.scaledIterations.count) / 1024
|
||||||
|
var fb = FlatBufferBuilder(initialSize: Int32(rawSize * 1600))
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
let offsets = [
|
||||||
|
fb.create(string: "T"),
|
||||||
|
fb.create(string: "2"),
|
||||||
|
fb.create(string: "3"),
|
||||||
|
]
|
||||||
|
let off = fb.createVector(ofOffsets: [
|
||||||
|
fb.createVector(ofOffsets: offsets),
|
||||||
|
fb.createVector(ofOffsets: offsets),
|
||||||
|
])
|
||||||
|
let s = fb.startTable(with: 2)
|
||||||
|
fb.add(offset: off, at: 2)
|
||||||
|
blackHole(fb.endTable(at: s))
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark("Reading Doubles") { benchmark in
|
||||||
|
let byteBuffer = ByteBuffer(data: data)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
blackHole(byteBuffer.read(def: Double.self, position: 0))
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2024 Google Inc. 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Benchmark
|
||||||
|
import FlexBuffers
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
let benchmarks = {
|
||||||
|
let data = {
|
||||||
|
var array = [8888.88, 8888.88]
|
||||||
|
var data = Data()
|
||||||
|
array.withUnsafeBytes { ptr in
|
||||||
|
data.append(contentsOf: ptr)
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
}()
|
||||||
|
let ints: [Int32] = Array(repeating: 42, count: 100)
|
||||||
|
let str10 = (0...9).map { _ -> String in "x" }.joined()
|
||||||
|
let str100 = (0...99).map { _ -> String in "x" }.joined()
|
||||||
|
|
||||||
|
// A representative map: 50 keyed scalars, a keyed string and a keyed vector
|
||||||
|
// of 100 scalars. Used for the realistic decode benchmarks.
|
||||||
|
let mapBuffer: ByteBuffer = {
|
||||||
|
var fbx = FlexBuffersWriter(initialSize: 1 << 16)
|
||||||
|
fbx.map {
|
||||||
|
for i in 0..<50 { $0.add(int: i, key: "i\(i)") }
|
||||||
|
$0.add(string: "hello world", key: "s")
|
||||||
|
$0.vector(key: "v") { v in
|
||||||
|
for x in 0..<100 { v.add(int: x) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fbx.finish()
|
||||||
|
return fbx.sizedByteBuffer
|
||||||
|
}()
|
||||||
|
|
||||||
|
let metrics: [BenchmarkMetric] = [
|
||||||
|
.cpuTotal,
|
||||||
|
.wallClock,
|
||||||
|
.mallocCountTotal,
|
||||||
|
.releaseCount,
|
||||||
|
.peakMemoryResident,
|
||||||
|
]
|
||||||
|
let maxIterations = 1_000_000
|
||||||
|
let maxDuration: Duration = .seconds(3)
|
||||||
|
let megaConfiguration: Benchmark.Configuration = .init(
|
||||||
|
metrics: metrics,
|
||||||
|
warmupIterations: 1,
|
||||||
|
scalingFactor: .mega,
|
||||||
|
maxDuration: maxDuration,
|
||||||
|
maxIterations: maxIterations)
|
||||||
|
|
||||||
|
Benchmark.defaultConfiguration = megaConfiguration
|
||||||
|
|
||||||
|
// Decode (read path)
|
||||||
|
|
||||||
|
// Raw scalar read: isolates `read<T: BitwiseCopyable>` and the `let` blob.
|
||||||
|
Benchmark("Reading Doubles") { benchmark in
|
||||||
|
let byteBuffer = ByteBuffer(data: data)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
blackHole(byteBuffer.read(def: Double.self, position: 0))
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Realistic decode: resolve root map and read a keyed scalar.
|
||||||
|
Benchmark("Decode Map Scalar") { benchmark in
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
let map = try! getRoot(buffer: mapBuffer)!.map!
|
||||||
|
blackHole(map["i25"]?.int)
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Realistic decode: resolve root map and read a keyed string.
|
||||||
|
Benchmark("Decode Map String") { benchmark in
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
let map = try! getRoot(buffer: mapBuffer)!.map!
|
||||||
|
blackHole(map["s"]?.string())
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Realistic decode: resolve a nested vector and sum its scalars.
|
||||||
|
Benchmark("Decode Vector") { benchmark in
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
let map = try! getRoot(buffer: mapBuffer)!.map!
|
||||||
|
let vector = map["v"]!.vector!
|
||||||
|
var sum: Int64 = 0
|
||||||
|
for i in 0..<vector.count {
|
||||||
|
sum &+= vector[i]?.int ?? 0
|
||||||
|
}
|
||||||
|
blackHole(sum)
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encode (write path)
|
||||||
|
// Writers are reused with `reset(keepingCapacity:)` so per-iteration
|
||||||
|
// allocation does not dominate and mask the write-path cost (which is what
|
||||||
|
// the `@exclusivity(unchecked)` storage pointer affects).
|
||||||
|
|
||||||
|
Benchmark("Strings 10") { benchmark in
|
||||||
|
var fbx = FlexBuffersWriter(initialSize: 1 << 20)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
fbx.add(string: str10)
|
||||||
|
fbx.finish()
|
||||||
|
blackHole(fbx.sizedByteBuffer)
|
||||||
|
fbx.reset(keepingCapacity: true)
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark("Strings 100") { benchmark in
|
||||||
|
var fbx = FlexBuffersWriter(initialSize: 1 << 20)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
fbx.add(string: str100)
|
||||||
|
fbx.finish()
|
||||||
|
blackHole(fbx.sizedByteBuffer)
|
||||||
|
fbx.reset(keepingCapacity: true)
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark("Encoding Vector Of Ints") { benchmark in
|
||||||
|
var fbx = FlexBuffersWriter(initialSize: 1 << 20)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
fbx.vector {
|
||||||
|
$0.create(vector: ints)
|
||||||
|
}
|
||||||
|
fbx.finish()
|
||||||
|
blackHole(fbx.sizedByteBuffer)
|
||||||
|
fbx.reset(keepingCapacity: true)
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
|
||||||
|
Benchmark("Encoding Map") { benchmark in
|
||||||
|
var fbx = FlexBuffersWriter(initialSize: 1 << 20)
|
||||||
|
benchmark.startMeasurement()
|
||||||
|
for _ in benchmark.scaledIterations {
|
||||||
|
fbx.map {
|
||||||
|
for i in 0..<50 { $0.add(int: i, key: "i\(i)") }
|
||||||
|
$0.add(string: "hello world", key: "s")
|
||||||
|
$0.vector(key: "v") { v in
|
||||||
|
for x in 0..<100 { v.add(int: x) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fbx.finish()
|
||||||
|
blackHole(fbx.sizedByteBuffer)
|
||||||
|
fbx.reset(keepingCapacity: true)
|
||||||
|
}
|
||||||
|
benchmark.stopMeasurement()
|
||||||
|
}
|
||||||
|
}
|
||||||
52
benchmarks/swift/Package.swift
Normal file
52
benchmarks/swift/Package.swift
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
// swift-tools-version:5.10
|
||||||
|
/*
|
||||||
|
* Copyright 2020 Google Inc. 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import PackageDescription
|
||||||
|
|
||||||
|
let package = Package(
|
||||||
|
name: "benchmarks",
|
||||||
|
platforms: [
|
||||||
|
.macOS(.v13),
|
||||||
|
],
|
||||||
|
dependencies: [
|
||||||
|
.package(path: "../.."),
|
||||||
|
.package(
|
||||||
|
url: "https://github.com/ordo-one/package-benchmark",
|
||||||
|
from: "1.27.0"),
|
||||||
|
],
|
||||||
|
targets: [
|
||||||
|
.executableTarget(
|
||||||
|
name: "FlatbuffersBenchmarks",
|
||||||
|
dependencies: [
|
||||||
|
.product(name: "FlatBuffers", package: "flatbuffers"),
|
||||||
|
.product(name: "Benchmark", package: "package-benchmark"),
|
||||||
|
],
|
||||||
|
path: "Benchmarks/FlatbuffersBenchmarks",
|
||||||
|
plugins: [
|
||||||
|
.plugin(name: "BenchmarkPlugin", package: "package-benchmark"),
|
||||||
|
]),
|
||||||
|
.executableTarget(
|
||||||
|
name: "FlexBuffersBenchmarks",
|
||||||
|
dependencies: [
|
||||||
|
.product(name: "FlexBuffers", package: "flatbuffers"),
|
||||||
|
.product(name: "Benchmark", package: "package-benchmark"),
|
||||||
|
],
|
||||||
|
path: "Benchmarks/FlexBuffersBenchmarks",
|
||||||
|
plugins: [
|
||||||
|
.plugin(name: "BenchmarkPlugin", package: "package-benchmark"),
|
||||||
|
]),
|
||||||
|
])
|
||||||
9
benchmarks/swift/README.md
Normal file
9
benchmarks/swift/README.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Benchmarks
|
||||||
|
|
||||||
|
To open the benchmarks in xcode use:
|
||||||
|
|
||||||
|
`open --env BENCHMARK_DISABLE_JEMALLOC=true Package.swift`
|
||||||
|
|
||||||
|
or running them directly within terminal using:
|
||||||
|
|
||||||
|
`swift package benchmark`
|
||||||
135
build_defs.bzl
135
build_defs.bzl
@@ -7,14 +7,23 @@ Rules for building C++ flatbuffers with Bazel.
|
|||||||
|
|
||||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||||
|
|
||||||
flatc_path = "@com_github_google_flatbuffers//:flatc"
|
TRUE_FLATC_PATH = Label("//:flatc")
|
||||||
|
|
||||||
DEFAULT_INCLUDE_PATHS = [
|
DEFAULT_INCLUDE_PATHS = [
|
||||||
"./",
|
"./",
|
||||||
"$(GENDIR)",
|
"$(GENDIR)",
|
||||||
"$(BINDIR)",
|
"$(BINDIR)",
|
||||||
|
"$(execpath %s).runfiles/%s" % (TRUE_FLATC_PATH, TRUE_FLATC_PATH.repo_name),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def default_include_paths(flatc_path):
|
||||||
|
return [
|
||||||
|
"./",
|
||||||
|
"$(GENDIR)",
|
||||||
|
"$(BINDIR)",
|
||||||
|
"$(execpath %s).runfiles/%s" % (flatc_path, flatc_path.repo_name),
|
||||||
|
]
|
||||||
|
|
||||||
DEFAULT_FLATC_ARGS = [
|
DEFAULT_FLATC_ARGS = [
|
||||||
"--gen-object-api",
|
"--gen-object-api",
|
||||||
"--gen-compare",
|
"--gen-compare",
|
||||||
@@ -31,13 +40,18 @@ def flatbuffer_library_public(
|
|||||||
language_flag,
|
language_flag,
|
||||||
out_prefix = "",
|
out_prefix = "",
|
||||||
includes = [],
|
includes = [],
|
||||||
include_paths = DEFAULT_INCLUDE_PATHS,
|
include_paths = None,
|
||||||
flatc_args = DEFAULT_FLATC_ARGS,
|
flatc_args = DEFAULT_FLATC_ARGS,
|
||||||
reflection_name = "",
|
reflection_name = "",
|
||||||
reflection_visibility = None,
|
reflection_visibility = None,
|
||||||
compatible_with = None,
|
compatible_with = None,
|
||||||
restricted_to = None,
|
restricted_to = None,
|
||||||
output_to_bindir = False):
|
target_compatible_with = None,
|
||||||
|
flatc_path = None,
|
||||||
|
output_to_bindir = False,
|
||||||
|
tools = None,
|
||||||
|
extra_env = None,
|
||||||
|
**kwargs):
|
||||||
"""Generates code files for reading/writing the given flatbuffers in the requested language using the public compiler.
|
"""Generates code files for reading/writing the given flatbuffers in the requested language using the public compiler.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -58,15 +72,33 @@ def flatbuffer_library_public(
|
|||||||
built for, in addition to default-supported environments.
|
built for, in addition to default-supported environments.
|
||||||
restricted_to: Optional, The list of environments this rule can be built
|
restricted_to: Optional, The list of environments this rule can be built
|
||||||
for, instead of default-supported environments.
|
for, instead of default-supported environments.
|
||||||
|
target_compatible_with: Optional, The list of target platform constraints
|
||||||
|
to use.
|
||||||
|
flatc_path: Bazel target corresponding to the flatc compiler to use.
|
||||||
output_to_bindir: Passed to genrule for output to bin directory.
|
output_to_bindir: Passed to genrule for output to bin directory.
|
||||||
|
tools: Optional, passed to genrule for list of tools to make available
|
||||||
|
during the action.
|
||||||
|
extra_env: Optional, must be a string of "VAR1=VAL1 VAR2=VAL2". These get
|
||||||
|
set as environment variables that "flatc_path" sees.
|
||||||
|
**kwargs: Passed to the underlying genrule.
|
||||||
|
|
||||||
|
|
||||||
This rule creates a filegroup(name) with all generated source files, and
|
This rule creates a filegroup(name) with all generated source files, and
|
||||||
optionally a Fileset([reflection_name]) with all generated reflection
|
optionally a Fileset([reflection_name]) with all generated reflection
|
||||||
binaries.
|
binaries.
|
||||||
"""
|
"""
|
||||||
|
if flatc_path == None:
|
||||||
|
flatc_path = TRUE_FLATC_PATH
|
||||||
|
else:
|
||||||
|
flatc_path = native.package_relative_label(flatc_path)
|
||||||
|
|
||||||
|
reflection_include_paths = include_paths
|
||||||
|
if include_paths == None:
|
||||||
|
include_paths = default_include_paths(flatc_path)
|
||||||
include_paths_cmd = ["-I %s" % (s) for s in include_paths]
|
include_paths_cmd = ["-I %s" % (s) for s in include_paths]
|
||||||
|
|
||||||
|
extra_env = extra_env or ""
|
||||||
|
|
||||||
# '$(@D)' when given a single source target will give the appropriate
|
# '$(@D)' when given a single source target will give the appropriate
|
||||||
# directory. Appending 'out_prefix' is only necessary when given a build
|
# directory. Appending 'out_prefix' is only necessary when given a build
|
||||||
# target with multiple sources.
|
# target with multiple sources.
|
||||||
@@ -76,7 +108,7 @@ def flatbuffer_library_public(
|
|||||||
genrule_cmd = " ".join([
|
genrule_cmd = " ".join([
|
||||||
"SRCS=($(SRCS));",
|
"SRCS=($(SRCS));",
|
||||||
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
|
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
|
||||||
"$(location %s)" % (flatc_path),
|
"OUTPUT_FILE=\"$(OUTS)\" %s $(location %s)" % (extra_env, flatc_path),
|
||||||
" ".join(include_paths_cmd),
|
" ".join(include_paths_cmd),
|
||||||
" ".join(flatc_args),
|
" ".join(flatc_args),
|
||||||
language_flag,
|
language_flag,
|
||||||
@@ -89,39 +121,49 @@ def flatbuffer_library_public(
|
|||||||
srcs = srcs + includes,
|
srcs = srcs + includes,
|
||||||
outs = outs,
|
outs = outs,
|
||||||
output_to_bindir = output_to_bindir,
|
output_to_bindir = output_to_bindir,
|
||||||
tools = [flatc_path],
|
tools = (tools or []) + [flatc_path],
|
||||||
cmd = genrule_cmd,
|
cmd = genrule_cmd,
|
||||||
compatible_with = compatible_with,
|
compatible_with = compatible_with,
|
||||||
|
target_compatible_with = target_compatible_with,
|
||||||
restricted_to = restricted_to,
|
restricted_to = restricted_to,
|
||||||
message = "Generating flatbuffer files for %s:" % (name),
|
message = "Generating flatbuffer files for %s:" % (name),
|
||||||
|
**kwargs
|
||||||
)
|
)
|
||||||
if reflection_name:
|
if reflection_name:
|
||||||
|
if reflection_include_paths == None:
|
||||||
|
reflection_include_paths = default_include_paths(TRUE_FLATC_PATH)
|
||||||
|
reflection_include_paths_cmd = ["-I %s" % (s) for s in reflection_include_paths]
|
||||||
reflection_genrule_cmd = " ".join([
|
reflection_genrule_cmd = " ".join([
|
||||||
"SRCS=($(SRCS));",
|
"SRCS=($(SRCS));",
|
||||||
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
|
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
|
||||||
"$(location %s)" % (flatc_path),
|
# Move the .fbs file into the current package if it is not there already
|
||||||
|
'if [[ $$(dirname $$f) != "{0}" ]]; then s="$$f"; f="{0}/$$(basename "$$f")"; mkdir -p "{0}"; mv "$$s" "$$f"; fi;'.format(native.package_relative_label(":invalid").package),
|
||||||
|
"$(location %s)" % (TRUE_FLATC_PATH),
|
||||||
"-b --schema",
|
"-b --schema",
|
||||||
" ".join(flatc_args),
|
" ".join(flatc_args),
|
||||||
" ".join(include_paths_cmd),
|
" ".join(reflection_include_paths_cmd),
|
||||||
language_flag,
|
language_flag,
|
||||||
output_directory,
|
output_directory,
|
||||||
"$$f;",
|
"$$f;",
|
||||||
"done",
|
"done",
|
||||||
])
|
])
|
||||||
reflection_outs = [
|
reflection_outs = [
|
||||||
(out_prefix + "%s.bfbs") % (s.replace(".fbs", "").split("/")[-1])
|
(out_prefix + "%s.bfbs") % (native.package_relative_label(s).name.removesuffix(".fbs"))
|
||||||
for s in srcs
|
for s in srcs
|
||||||
]
|
]
|
||||||
|
|
||||||
native.genrule(
|
native.genrule(
|
||||||
name = "%s_srcs" % reflection_name,
|
name = "%s_srcs" % reflection_name,
|
||||||
srcs = srcs + includes,
|
srcs = srcs + includes,
|
||||||
outs = reflection_outs,
|
outs = reflection_outs,
|
||||||
output_to_bindir = output_to_bindir,
|
output_to_bindir = output_to_bindir,
|
||||||
tools = [flatc_path],
|
tools = [TRUE_FLATC_PATH],
|
||||||
compatible_with = compatible_with,
|
compatible_with = compatible_with,
|
||||||
restricted_to = restricted_to,
|
restricted_to = restricted_to,
|
||||||
|
target_compatible_with = target_compatible_with,
|
||||||
cmd = reflection_genrule_cmd,
|
cmd = reflection_genrule_cmd,
|
||||||
message = "Generating flatbuffer reflection binary for %s:" % (name),
|
message = "Generating flatbuffer reflection binary for %s:" % (name),
|
||||||
|
visibility = reflection_visibility,
|
||||||
)
|
)
|
||||||
native.filegroup(
|
native.filegroup(
|
||||||
name = "%s_out" % reflection_name,
|
name = "%s_out" % reflection_name,
|
||||||
@@ -135,16 +177,21 @@ def flatbuffer_cc_library(
|
|||||||
name,
|
name,
|
||||||
srcs,
|
srcs,
|
||||||
srcs_filegroup_name = "",
|
srcs_filegroup_name = "",
|
||||||
|
outs = [],
|
||||||
out_prefix = "",
|
out_prefix = "",
|
||||||
|
deps = [],
|
||||||
includes = [],
|
includes = [],
|
||||||
include_paths = DEFAULT_INCLUDE_PATHS,
|
include_paths = None,
|
||||||
|
cc_include_paths = [],
|
||||||
flatc_args = DEFAULT_FLATC_ARGS,
|
flatc_args = DEFAULT_FLATC_ARGS,
|
||||||
visibility = None,
|
visibility = None,
|
||||||
compatible_with = None,
|
compatible_with = None,
|
||||||
restricted_to = None,
|
restricted_to = None,
|
||||||
|
filename_suffix = "_generated",
|
||||||
|
target_compatible_with = None,
|
||||||
srcs_filegroup_visibility = None,
|
srcs_filegroup_visibility = None,
|
||||||
gen_reflections = False):
|
gen_reflections = False):
|
||||||
'''A cc_library with the generated reader/writers for the given flatbuffer definitions.
|
"""A cc_library with the generated reader/writers for the given flatbuffer definitions.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
name: Rule name.
|
name: Rule name.
|
||||||
@@ -152,11 +199,15 @@ def flatbuffer_cc_library(
|
|||||||
srcs_filegroup_name: Name of the output filegroup that holds srcs. Pass this
|
srcs_filegroup_name: Name of the output filegroup that holds srcs. Pass this
|
||||||
filegroup into the `includes` parameter of any other
|
filegroup into the `includes` parameter of any other
|
||||||
flatbuffer_cc_library that depends on this one's schemas.
|
flatbuffer_cc_library that depends on this one's schemas.
|
||||||
|
outs: Additional outputs expected to be generated by flatc.
|
||||||
out_prefix: Prepend this path to the front of all generated files. Usually
|
out_prefix: Prepend this path to the front of all generated files. Usually
|
||||||
is a directory name.
|
is a directory name.
|
||||||
|
deps: Optional, list of other flatbuffer_cc_library's to depend on. Cannot be specified
|
||||||
|
alongside includes.
|
||||||
includes: Optional, list of filegroups of schemas that the srcs depend on.
|
includes: Optional, list of filegroups of schemas that the srcs depend on.
|
||||||
** SEE REMARKS BELOW **
|
Use of this is discouraged, and may be deprecated.
|
||||||
include_paths: Optional, list of paths the includes files can be found in.
|
include_paths: Optional, list of paths the includes files can be found in.
|
||||||
|
cc_include_paths: Optional, list of paths to add to the cc_library includes attribute.
|
||||||
flatc_args: Optional list of additional arguments to pass to flatc
|
flatc_args: Optional list of additional arguments to pass to flatc
|
||||||
(e.g. --gen-mutable).
|
(e.g. --gen-mutable).
|
||||||
visibility: The visibility of the generated cc_library. By default, use the
|
visibility: The visibility of the generated cc_library. By default, use the
|
||||||
@@ -169,6 +220,8 @@ def flatbuffer_cc_library(
|
|||||||
for, in addition to default-supported environments.
|
for, in addition to default-supported environments.
|
||||||
restricted_to: Optional, The list of environments this rule can be built
|
restricted_to: Optional, The list of environments this rule can be built
|
||||||
for, instead of default-supported environments.
|
for, instead of default-supported environments.
|
||||||
|
target_compatible_with: Optional, The list of target platform constraints
|
||||||
|
to use.
|
||||||
|
|
||||||
This produces:
|
This produces:
|
||||||
filegroup([name]_srcs): all generated .h files.
|
filegroup([name]_srcs): all generated .h files.
|
||||||
@@ -177,48 +230,27 @@ def flatbuffer_cc_library(
|
|||||||
parameter, if they depend on the schemas in this library.
|
parameter, if they depend on the schemas in this library.
|
||||||
Fileset([name]_reflection): (Optional) all generated reflection binaries.
|
Fileset([name]_reflection): (Optional) all generated reflection binaries.
|
||||||
cc_library([name]): library with sources and flatbuffers deps.
|
cc_library([name]): library with sources and flatbuffers deps.
|
||||||
|
"""
|
||||||
|
|
||||||
Remarks:
|
output_headers = []
|
||||||
** Because the genrule used to call flatc does not have any trivial way of
|
for s in srcs:
|
||||||
computing the output list of files transitively generated by includes and
|
base_name = s.split("/")[-1].split(":")[-1].replace(".fbs", "")
|
||||||
--gen-includes (the default) being defined for flatc, the --gen-includes
|
header = out_prefix + base_name + filename_suffix + ".h"
|
||||||
flag will not work as expected. The way around this is to add a dependency
|
output_headers.append(header)
|
||||||
to the flatbuffer_cc_library defined alongside the flatc included Fileset.
|
|
||||||
For example you might define:
|
|
||||||
|
|
||||||
flatbuffer_cc_library(
|
if deps and includes:
|
||||||
name = "my_fbs",
|
# There is no inherent reason we couldn't support both, but this discourages
|
||||||
srcs = [ "schemas/foo.fbs" ],
|
# use of includes without good reason.
|
||||||
includes = [ "//third_party/bazz:bazz_fbs_includes" ],
|
fail("Cannot specify both deps and include in flatbuffer_cc_library.")
|
||||||
)
|
if deps:
|
||||||
|
includes = [d + "_includes" for d in deps]
|
||||||
In which foo.fbs includes a few files from the Fileset defined at
|
|
||||||
//third_party/bazz:bazz_fbs_includes. When compiling the library that
|
|
||||||
includes foo_generated.h, and therefore has my_fbs as a dependency, it
|
|
||||||
will fail to find any of the bazz *_generated.h files unless you also
|
|
||||||
add bazz's flatbuffer_cc_library to your own dependency list, e.g.:
|
|
||||||
|
|
||||||
cc_library(
|
|
||||||
name = "my_lib",
|
|
||||||
deps = [
|
|
||||||
":my_fbs",
|
|
||||||
"//third_party/bazz:bazz_fbs"
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
Happy dependent Flatbuffering!
|
|
||||||
'''
|
|
||||||
output_headers = [
|
|
||||||
(out_prefix + "%s_generated.h") % (s.replace(".fbs", "").split("/")[-1].split(":")[-1])
|
|
||||||
for s in srcs
|
|
||||||
]
|
|
||||||
reflection_name = "%s_reflection" % name if gen_reflections else ""
|
reflection_name = "%s_reflection" % name if gen_reflections else ""
|
||||||
|
|
||||||
srcs_lib = "%s_srcs" % (name)
|
srcs_lib = "%s_srcs" % (name)
|
||||||
flatbuffer_library_public(
|
flatbuffer_library_public(
|
||||||
name = srcs_lib,
|
name = srcs_lib,
|
||||||
srcs = srcs,
|
srcs = srcs,
|
||||||
outs = output_headers,
|
outs = outs + output_headers,
|
||||||
language_flag = "-c",
|
language_flag = "-c",
|
||||||
out_prefix = out_prefix,
|
out_prefix = out_prefix,
|
||||||
includes = includes,
|
includes = includes,
|
||||||
@@ -226,6 +258,7 @@ def flatbuffer_cc_library(
|
|||||||
flatc_args = flatc_args,
|
flatc_args = flatc_args,
|
||||||
compatible_with = compatible_with,
|
compatible_with = compatible_with,
|
||||||
restricted_to = restricted_to,
|
restricted_to = restricted_to,
|
||||||
|
target_compatible_with = target_compatible_with,
|
||||||
reflection_name = reflection_name,
|
reflection_name = reflection_name,
|
||||||
reflection_visibility = visibility,
|
reflection_visibility = visibility,
|
||||||
)
|
)
|
||||||
@@ -241,11 +274,13 @@ def flatbuffer_cc_library(
|
|||||||
"-parse_headers",
|
"-parse_headers",
|
||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
"@com_github_google_flatbuffers//:runtime_cc",
|
Label("//:runtime_cc"),
|
||||||
],
|
Label("//:flatbuffers"),
|
||||||
includes = [],
|
] + deps,
|
||||||
|
includes = cc_include_paths,
|
||||||
compatible_with = compatible_with,
|
compatible_with = compatible_with,
|
||||||
restricted_to = restricted_to,
|
restricted_to = restricted_to,
|
||||||
|
target_compatible_with = target_compatible_with,
|
||||||
linkstatic = 1,
|
linkstatic = 1,
|
||||||
visibility = visibility,
|
visibility = visibility,
|
||||||
)
|
)
|
||||||
@@ -254,7 +289,7 @@ def flatbuffer_cc_library(
|
|||||||
# Flatbuffer set.
|
# Flatbuffer set.
|
||||||
native.filegroup(
|
native.filegroup(
|
||||||
name = srcs_filegroup_name if srcs_filegroup_name else "%s_includes" % (name),
|
name = srcs_filegroup_name if srcs_filegroup_name else "%s_includes" % (name),
|
||||||
srcs = srcs,
|
srcs = srcs + includes,
|
||||||
compatible_with = compatible_with,
|
compatible_with = compatible_with,
|
||||||
restricted_to = restricted_to,
|
restricted_to = restricted_to,
|
||||||
visibility = srcs_filegroup_visibility if srcs_filegroup_visibility != None else visibility,
|
visibility = srcs_filegroup_visibility if srcs_filegroup_visibility != None else visibility,
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 2.8)
|
|
||||||
|
|
||||||
message(STATUS "Conan FlatBuffers Wrapper")
|
|
||||||
|
|
||||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
|
||||||
conan_basic_setup()
|
|
||||||
|
|
||||||
if (WIN32 AND MSVC AND FLATBUFFERS_BUILD_SHAREDLIB)
|
|
||||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
|
||||||
endif(WIN32 AND MSVC AND FLATBUFFERS_BUILD_SHAREDLIB)
|
|
||||||
|
|
||||||
include(${CMAKE_SOURCE_DIR}/CMakeListsOriginal.txt)
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import os
|
|
||||||
|
|
||||||
if os.getenv("APPVEYOR_REPO_TAG") != "true":
|
|
||||||
print("Skip build step. It's not TAG")
|
|
||||||
else:
|
|
||||||
os.system("python conan/build.py")
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import os
|
|
||||||
|
|
||||||
if os.getenv("APPVEYOR_REPO_TAG") != "true":
|
|
||||||
print("Skip step. It's not TAG")
|
|
||||||
else:
|
|
||||||
os.system("pip install conan conan-package-tools")
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import subprocess
|
|
||||||
from cpt.packager import ConanMultiPackager
|
|
||||||
|
|
||||||
|
|
||||||
def set_appveyor_environment():
|
|
||||||
if os.getenv("APPVEYOR") is not None:
|
|
||||||
compiler_version = os.getenv("CMAKE_VS_VERSION").split(" ")[0].replace('"', '')
|
|
||||||
os.environ["CONAN_VISUAL_VERSIONS"] = compiler_version
|
|
||||||
os.environ["CONAN_STABLE_BRANCH_PATTERN"] = "master"
|
|
||||||
ci_platform = os.getenv("Platform").replace('"', '')
|
|
||||||
ci_platform = "x86" if ci_platform == "x86" else "x86_64"
|
|
||||||
os.environ["CONAN_ARCHS"] = ci_platform
|
|
||||||
os.environ["CONAN_BUILD_TYPES"] = os.getenv("Configuration").replace('"', '')
|
|
||||||
|
|
||||||
|
|
||||||
def get_branch():
|
|
||||||
try:
|
|
||||||
for line in subprocess.check_output("git branch", shell=True).decode().splitlines():
|
|
||||||
line = line.strip()
|
|
||||||
if line.startswith("*") and " (HEAD detached" not in line:
|
|
||||||
return line.replace("*", "", 1).strip()
|
|
||||||
return ""
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
return ""
|
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
|
||||||
version = get_branch()
|
|
||||||
if os.getenv("TRAVIS", False):
|
|
||||||
version = os.getenv("TRAVIS_BRANCH")
|
|
||||||
|
|
||||||
if os.getenv("APPVEYOR", False):
|
|
||||||
version = os.getenv("APPVEYOR_REPO_BRANCH")
|
|
||||||
if os.getenv("APPVEYOR_REPO_TAG") == "true":
|
|
||||||
version = os.getenv("APPVEYOR_REPO_TAG_NAME")
|
|
||||||
|
|
||||||
match = re.search(r"v(\d+\.\d+\.\d+.*)", version)
|
|
||||||
if match:
|
|
||||||
return match.group(1)
|
|
||||||
return version
|
|
||||||
|
|
||||||
|
|
||||||
def get_reference(username):
|
|
||||||
return "flatbuffers/{}@google/stable".format(get_version())
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
login_username = os.getenv("CONAN_LOGIN_USERNAME", "aardappel")
|
|
||||||
username = os.getenv("CONAN_USERNAME", "google")
|
|
||||||
upload = os.getenv("CONAN_UPLOAD", "https://api.bintray.com/conan/aardappel/flatbuffers")
|
|
||||||
stable_branch_pattern = os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"v\d+\.\d+\.\d+.*")
|
|
||||||
test_folder = os.getenv("CPT_TEST_FOLDER", os.path.join("conan", "test_package"))
|
|
||||||
upload_only_when_stable = os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", True)
|
|
||||||
set_appveyor_environment()
|
|
||||||
|
|
||||||
builder = ConanMultiPackager(reference=get_reference(username),
|
|
||||||
username=username,
|
|
||||||
login_username=login_username,
|
|
||||||
upload=upload,
|
|
||||||
stable_branch_pattern=stable_branch_pattern,
|
|
||||||
upload_only_when_stable=upload_only_when_stable,
|
|
||||||
test_folder=test_folder)
|
|
||||||
builder.add_common_builds(pure_c=False)
|
|
||||||
builder.run()
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
project(test_package CXX)
|
|
||||||
cmake_minimum_required(VERSION 2.8.11)
|
|
||||||
|
|
||||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
|
||||||
conan_basic_setup()
|
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} test_package.cpp)
|
|
||||||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
|
|
||||||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from conans import ConanFile, CMake
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
class TestPackageConan(ConanFile):
|
|
||||||
settings = "os", "compiler", "build_type", "arch"
|
|
||||||
generators = "cmake"
|
|
||||||
|
|
||||||
def build(self):
|
|
||||||
cmake = CMake(self)
|
|
||||||
cmake.configure()
|
|
||||||
cmake.build()
|
|
||||||
|
|
||||||
def test(self):
|
|
||||||
bin_path = os.path.join("bin", "test_package")
|
|
||||||
self.run(bin_path, run_environment=True)
|
|
||||||
self.run("flatc --version", run_environment=True)
|
|
||||||
self.run("flathash fnv1_16 conan", run_environment=True)
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2018 Google Inc. 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <iostream>
|
|
||||||
#include "flatbuffers/util.h"
|
|
||||||
|
|
||||||
// Test to validate Conan package generated
|
|
||||||
|
|
||||||
int main(int /*argc*/, const char * /*argv*/ []) {
|
|
||||||
|
|
||||||
const std::string filename("conanbuildinfo.cmake");
|
|
||||||
|
|
||||||
if (flatbuffers::FileExists(filename.c_str())) {
|
|
||||||
std::cout << "File " << filename << " exists.\n";
|
|
||||||
} else {
|
|
||||||
std::cout << "File " << filename << " does not exist.\n";
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
set -x
|
|
||||||
|
|
||||||
if [[ "$(uname -s)" == 'Darwin' ]]; then
|
|
||||||
if which pyenv > /dev/null; then
|
|
||||||
eval "$(pyenv init -)"
|
|
||||||
fi
|
|
||||||
pyenv activate conan
|
|
||||||
fi
|
|
||||||
|
|
||||||
conan user
|
|
||||||
python conan/build.py
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
set -x
|
|
||||||
|
|
||||||
if [[ "$(uname -s)" == 'Darwin' ]]; then
|
|
||||||
brew update || brew update
|
|
||||||
brew outdated pyenv || brew upgrade pyenv
|
|
||||||
brew install pyenv-virtualenv
|
|
||||||
brew install cmake || true
|
|
||||||
|
|
||||||
if which pyenv > /dev/null; then
|
|
||||||
eval "$(pyenv init -)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
pyenv install 2.7.10
|
|
||||||
pyenv virtualenv 2.7.10 conan
|
|
||||||
pyenv rehash
|
|
||||||
pyenv activate conan
|
|
||||||
fi
|
|
||||||
|
|
||||||
pip install -U conan_package_tools conan
|
|
||||||
75
conanfile.py
75
conanfile.py
@@ -1,75 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
"""Conan recipe package for Google FlatBuffers
|
|
||||||
"""
|
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
from conans import ConanFile, CMake, tools
|
|
||||||
|
|
||||||
|
|
||||||
class FlatbuffersConan(ConanFile):
|
|
||||||
name = "flatbuffers"
|
|
||||||
license = "Apache-2.0"
|
|
||||||
url = "https://github.com/google/flatbuffers"
|
|
||||||
homepage = "http://google.github.io/flatbuffers/"
|
|
||||||
author = "Wouter van Oortmerssen"
|
|
||||||
topics = ("conan", "flatbuffers", "serialization", "rpc", "json-parser")
|
|
||||||
description = "Memory Efficient Serialization Library"
|
|
||||||
settings = "os", "compiler", "build_type", "arch"
|
|
||||||
options = {"shared": [True, False], "fPIC": [True, False]}
|
|
||||||
default_options = {"shared": False, "fPIC": True}
|
|
||||||
generators = "cmake"
|
|
||||||
exports = "LICENSE.txt"
|
|
||||||
exports_sources = ["CMake/*", "include/*", "src/*", "grpc/*", "CMakeLists.txt", "conan/CMakeLists.txt"]
|
|
||||||
|
|
||||||
def source(self):
|
|
||||||
"""Wrap the original CMake file to call conan_basic_setup
|
|
||||||
"""
|
|
||||||
shutil.move("CMakeLists.txt", "CMakeListsOriginal.txt")
|
|
||||||
shutil.move(os.path.join("conan", "CMakeLists.txt"), "CMakeLists.txt")
|
|
||||||
|
|
||||||
def config_options(self):
|
|
||||||
"""Remove fPIC option on Windows platform
|
|
||||||
"""
|
|
||||||
if self.settings.os == "Windows":
|
|
||||||
self.options.remove("fPIC")
|
|
||||||
|
|
||||||
def configure_cmake(self):
|
|
||||||
"""Create CMake instance and execute configure step
|
|
||||||
"""
|
|
||||||
cmake = CMake(self)
|
|
||||||
cmake.definitions["FLATBUFFERS_BUILD_TESTS"] = False
|
|
||||||
cmake.definitions["FLATBUFFERS_BUILD_SHAREDLIB"] = self.options.shared
|
|
||||||
cmake.definitions["FLATBUFFERS_BUILD_FLATLIB"] = not self.options.shared
|
|
||||||
cmake.configure()
|
|
||||||
return cmake
|
|
||||||
|
|
||||||
def build(self):
|
|
||||||
"""Configure, build and install FlatBuffers using CMake.
|
|
||||||
"""
|
|
||||||
cmake = self.configure_cmake()
|
|
||||||
cmake.build()
|
|
||||||
|
|
||||||
def package(self):
|
|
||||||
"""Copy Flatbuffers' artifacts to package folder
|
|
||||||
"""
|
|
||||||
cmake = self.configure_cmake()
|
|
||||||
cmake.install()
|
|
||||||
self.copy(pattern="LICENSE.txt", dst="licenses")
|
|
||||||
self.copy(pattern="FindFlatBuffers.cmake", dst=os.path.join("lib", "cmake", "flatbuffers"), src="CMake")
|
|
||||||
self.copy(pattern="flathash*", dst="bin", src="bin")
|
|
||||||
self.copy(pattern="flatc*", dst="bin", src="bin")
|
|
||||||
if self.settings.os == "Windows" and self.options.shared:
|
|
||||||
if self.settings.compiler == "Visual Studio":
|
|
||||||
shutil.move(os.path.join(self.package_folder, "lib", "%s.dll" % self.name),
|
|
||||||
os.path.join(self.package_folder, "bin", "%s.dll" % self.name))
|
|
||||||
elif self.settings.compiler == "gcc":
|
|
||||||
shutil.move(os.path.join(self.package_folder, "lib", "lib%s.dll" % self.name),
|
|
||||||
os.path.join(self.package_folder, "bin", "lib%s.dll" % self.name))
|
|
||||||
|
|
||||||
def package_info(self):
|
|
||||||
"""Collect built libraries names and solve flatc path.
|
|
||||||
"""
|
|
||||||
self.cpp_info.libs = tools.collect_libs(self)
|
|
||||||
self.user_info.flatc = os.path.join(self.package_folder, "bin", "flatc")
|
|
||||||
@@ -1,4 +1,24 @@
|
|||||||
## 2.0.0
|
# Changelog
|
||||||
|
|
||||||
|
## 25.9.23
|
||||||
|
|
||||||
|
- use enhanced enums (#8313)
|
||||||
|
- fix incorrect write in Float64 write method (#8290)
|
||||||
|
- code format improvements (#8707)
|
||||||
|
|
||||||
|
## 23.5.26
|
||||||
|
|
||||||
|
- omit type annotationes for local variables (#7067, #7069, #7070)
|
||||||
|
- remove BSD 3-clause license (#7073)
|
||||||
|
- correctly parse lists of enums (#7157)
|
||||||
|
- align naming conventions for generated code (#7187)
|
||||||
|
- add `putBool` to fix errors when serializing structs with booleans (#7359)
|
||||||
|
- fix handling of +/-inf defaults in codegen (#7588)
|
||||||
|
- fix import issues in generated code (#7621)
|
||||||
|
- Fix incorrect storage of floats as ints in some cases (#7703)
|
||||||
|
- add final modifiers to the library implementation (#7943)
|
||||||
|
|
||||||
|
## 2.0.5
|
||||||
|
|
||||||
- switch to null safety (#6696)
|
- switch to null safety (#6696)
|
||||||
- add Object APIs (pack/unpack) (#6682, #6723, #6846)
|
- add Object APIs (pack/unpack) (#6682, #6723, #6846)
|
||||||
|
|||||||
32
dart/LICENSE
32
dart/LICENSE
@@ -1,35 +1,3 @@
|
|||||||
The code in lib/flat_buffers.dart is based on code that was releases under the
|
|
||||||
following license:
|
|
||||||
|
|
||||||
Copyright 2012, the Dart project authors. All rights reserved.
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are
|
|
||||||
met:
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the following
|
|
||||||
disclaimer in the documentation and/or other materials provided
|
|
||||||
with the distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived
|
|
||||||
from this software without specific prior written permission.
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
To the extent permissible, the changes to that code and the other assets in
|
|
||||||
this package are licensed under the Apache2 license:
|
|
||||||
|
|
||||||
|
|
||||||
Apache License
|
Apache License
|
||||||
Version 2.0, January 2004
|
Version 2.0, January 2004
|
||||||
http://www.apache.org/licenses/
|
http://www.apache.org/licenses/
|
||||||
|
|||||||
@@ -2,10 +2,8 @@
|
|||||||
|
|
||||||
This package is used to read and write [FlatBuffers](https://google.github.io/flatbuffers/).
|
This package is used to read and write [FlatBuffers](https://google.github.io/flatbuffers/).
|
||||||
|
|
||||||
Most consumers will want to use the [`flatc` - FlatBuffer compiler](https://github.com/google/flatbuffers) binary for your platform:
|
Most consumers will want to use the [`flatc` - FlatBuffer compiler](https://github.com/google/flatbuffers) binary for your platform.
|
||||||
* [Linux](https://github.com/google/flatbuffers/suites/4363603985/artifacts/114682272)
|
You can download the flatc version matching your dart package version from [GitHub releases](https://github.com/google/flatbuffers/releases).
|
||||||
* [macOS](https://github.com/google/flatbuffers/suites/4363603985/artifacts/114682273)
|
|
||||||
* [Windows](https://github.com/google/flatbuffers/suites/4363603985/artifacts/114682274)
|
|
||||||
|
|
||||||
The FlatBuffer compiler `flatc` reads a FlatBuffers IDL schema and generates Dart code.
|
The FlatBuffer compiler `flatc` reads a FlatBuffers IDL schema and generates Dart code.
|
||||||
The generated classes can be used to read or write binary data/files that are interoperable with
|
The generated classes can be used to read or write binary data/files that are interoperable with
|
||||||
@@ -14,4 +12,4 @@ examples folder.
|
|||||||
|
|
||||||
For more details and documentation, head over to the official site and read the
|
For more details and documentation, head over to the official site and read the
|
||||||
[Tutorial](https://google.github.io/flatbuffers/flatbuffers_guide_tutorial.html) and how to
|
[Tutorial](https://google.github.io/flatbuffers/flatbuffers_guide_tutorial.html) and how to
|
||||||
[use FlatBuffers in Dart](https://google.github.io/flatbuffers/flatbuffers_guide_use_dart.html).
|
[use FlatBuffers in Dart](https://google.github.io/flatbuffers/flatbuffers_guide_use_dart.html).
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||||
|
|
||||||
import './monster_my_game.sample_generated.dart' as my_game;
|
import './monster_my_game.sample_generated.dart' as my_game;
|
||||||
|
|
||||||
// Example how to use FlatBuffers to create and read binary buffers.
|
// Example how to use FlatBuffers to create and read binary buffers.
|
||||||
@@ -78,7 +79,8 @@ void builderTest() {
|
|||||||
builder.finish(monsteroff);
|
builder.finish(monsteroff);
|
||||||
if (verify(builder.buffer)) {
|
if (verify(builder.buffer)) {
|
||||||
print(
|
print(
|
||||||
"The FlatBuffer was successfully created with a builder and verified!");
|
"The FlatBuffer was successfully created with a builder and verified!",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +96,10 @@ void objectBuilderTest() {
|
|||||||
name: 'Orc',
|
name: 'Orc',
|
||||||
inventory: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
inventory: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
||||||
color: my_game.Color.Red,
|
color: my_game.Color.Red,
|
||||||
weapons: [my_game.WeaponObjectBuilder(name: 'Sword', damage: 3), axe],
|
weapons: [
|
||||||
|
my_game.WeaponObjectBuilder(name: 'Sword', damage: 3),
|
||||||
|
axe,
|
||||||
|
],
|
||||||
equippedType: my_game.EquipmentTypeId.Weapon,
|
equippedType: my_game.EquipmentTypeId.Weapon,
|
||||||
equipped: axe,
|
equipped: axe,
|
||||||
);
|
);
|
||||||
@@ -108,7 +113,8 @@ void objectBuilderTest() {
|
|||||||
// Instead, we're going to access it right away (as if we just received it).
|
// Instead, we're going to access it right away (as if we just received it).
|
||||||
if (verify(buffer)) {
|
if (verify(buffer)) {
|
||||||
print(
|
print(
|
||||||
"The FlatBuffer was successfully created with an object builder and verified!");
|
"The FlatBuffer was successfully created with an object builder and verified!",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
library my_game.sample;
|
library my_game.sample;
|
||||||
|
|
||||||
import 'dart:typed_data' show Uint8List;
|
import 'dart:typed_data' show Uint8List;
|
||||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
|
||||||
|
|
||||||
|
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||||
|
|
||||||
class Color {
|
class Color {
|
||||||
final int value;
|
final int value;
|
||||||
@@ -19,7 +19,7 @@ class Color {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Color? _createOrNull(int? value) =>
|
static Color? _createOrNull(int? value) =>
|
||||||
value == null ? null : Color.fromValue(value);
|
value == null ? null : Color.fromValue(value);
|
||||||
|
|
||||||
static const int minValue = 0;
|
static const int minValue = 0;
|
||||||
@@ -29,10 +29,7 @@ class Color {
|
|||||||
static const Color Red = Color._(0);
|
static const Color Red = Color._(0);
|
||||||
static const Color Green = Color._(1);
|
static const Color Green = Color._(1);
|
||||||
static const Color Blue = Color._(2);
|
static const Color Blue = Color._(2);
|
||||||
static const Map<int, Color> values = {
|
static const Map<int, Color> values = {0: Red, 1: Green, 2: Blue};
|
||||||
0: Red,
|
|
||||||
1: Green,
|
|
||||||
2: Blue};
|
|
||||||
|
|
||||||
static const fb.Reader<Color> reader = _ColorReader();
|
static const fb.Reader<Color> reader = _ColorReader();
|
||||||
|
|
||||||
@@ -60,12 +57,14 @@ class EquipmentTypeId {
|
|||||||
factory EquipmentTypeId.fromValue(int value) {
|
factory EquipmentTypeId.fromValue(int value) {
|
||||||
final result = values[value];
|
final result = values[value];
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
throw StateError('Invalid value $value for bit flag enum EquipmentTypeId');
|
throw StateError(
|
||||||
|
'Invalid value $value for bit flag enum EquipmentTypeId',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EquipmentTypeId? _createOrNull(int? value) =>
|
static EquipmentTypeId? _createOrNull(int? value) =>
|
||||||
value == null ? null : EquipmentTypeId.fromValue(value);
|
value == null ? null : EquipmentTypeId.fromValue(value);
|
||||||
|
|
||||||
static const int minValue = 0;
|
static const int minValue = 0;
|
||||||
@@ -74,9 +73,7 @@ class EquipmentTypeId {
|
|||||||
|
|
||||||
static const EquipmentTypeId NONE = EquipmentTypeId._(0);
|
static const EquipmentTypeId NONE = EquipmentTypeId._(0);
|
||||||
static const EquipmentTypeId Weapon = EquipmentTypeId._(1);
|
static const EquipmentTypeId Weapon = EquipmentTypeId._(1);
|
||||||
static const Map<int, EquipmentTypeId> values = {
|
static const Map<int, EquipmentTypeId> values = {0: NONE, 1: Weapon};
|
||||||
0: NONE,
|
|
||||||
1: Weapon};
|
|
||||||
|
|
||||||
static const fb.Reader<EquipmentTypeId> reader = _EquipmentTypeIdReader();
|
static const fb.Reader<EquipmentTypeId> reader = _EquipmentTypeIdReader();
|
||||||
|
|
||||||
@@ -122,8 +119,7 @@ class _Vec3Reader extends fb.StructReader<Vec3> {
|
|||||||
int get size => 12;
|
int get size => 12;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Vec3 createObject(fb.BufferContext bc, int offset) =>
|
Vec3 createObject(fb.BufferContext bc, int offset) => Vec3._(bc, offset);
|
||||||
Vec3._(bc, offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Vec3Builder {
|
class Vec3Builder {
|
||||||
@@ -137,7 +133,6 @@ class Vec3Builder {
|
|||||||
fbBuilder.putFloat32(x);
|
fbBuilder.putFloat32(x);
|
||||||
return fbBuilder.offset;
|
return fbBuilder.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Vec3ObjectBuilder extends fb.ObjectBuilder {
|
class Vec3ObjectBuilder extends fb.ObjectBuilder {
|
||||||
@@ -145,14 +140,10 @@ class Vec3ObjectBuilder extends fb.ObjectBuilder {
|
|||||||
final double _y;
|
final double _y;
|
||||||
final double _z;
|
final double _z;
|
||||||
|
|
||||||
Vec3ObjectBuilder({
|
Vec3ObjectBuilder({required double x, required double y, required double z})
|
||||||
required double x,
|
: _x = x,
|
||||||
required double y,
|
_y = y,
|
||||||
required double z,
|
_z = z;
|
||||||
})
|
|
||||||
: _x = x,
|
|
||||||
_y = y,
|
|
||||||
_z = z;
|
|
||||||
|
|
||||||
/// Finish building, and store into the [fbBuilder].
|
/// Finish building, and store into the [fbBuilder].
|
||||||
@override
|
@override
|
||||||
@@ -171,6 +162,7 @@ class Vec3ObjectBuilder extends fb.ObjectBuilder {
|
|||||||
return fbBuilder.buffer;
|
return fbBuilder.buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Monster {
|
class Monster {
|
||||||
Monster._(this._bc, this._bcOffset);
|
Monster._(this._bc, this._bcOffset);
|
||||||
factory Monster(List<int> bytes) {
|
factory Monster(List<int> bytes) {
|
||||||
@@ -186,18 +178,30 @@ class Monster {
|
|||||||
Vec3? get pos => Vec3.reader.vTableGetNullable(_bc, _bcOffset, 4);
|
Vec3? get pos => Vec3.reader.vTableGetNullable(_bc, _bcOffset, 4);
|
||||||
int get mana => const fb.Int16Reader().vTableGet(_bc, _bcOffset, 6, 150);
|
int get mana => const fb.Int16Reader().vTableGet(_bc, _bcOffset, 6, 150);
|
||||||
int get hp => const fb.Int16Reader().vTableGet(_bc, _bcOffset, 8, 100);
|
int get hp => const fb.Int16Reader().vTableGet(_bc, _bcOffset, 8, 100);
|
||||||
String? get name => const fb.StringReader().vTableGetNullable(_bc, _bcOffset, 10);
|
String? get name =>
|
||||||
List<int>? get inventory => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 14);
|
const fb.StringReader().vTableGetNullable(_bc, _bcOffset, 10);
|
||||||
Color get color => Color.fromValue(const fb.Int8Reader().vTableGet(_bc, _bcOffset, 16, 2));
|
List<int>? get inventory =>
|
||||||
List<Weapon>? get weapons => const fb.ListReader<Weapon>(Weapon.reader).vTableGetNullable(_bc, _bcOffset, 18);
|
const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 14);
|
||||||
EquipmentTypeId? get equippedType => EquipmentTypeId._createOrNull(const fb.Uint8Reader().vTableGetNullable(_bc, _bcOffset, 20));
|
Color get color =>
|
||||||
|
Color.fromValue(const fb.Int8Reader().vTableGet(_bc, _bcOffset, 16, 2));
|
||||||
|
List<Weapon>? get weapons => const fb.ListReader<Weapon>(
|
||||||
|
Weapon.reader,
|
||||||
|
).vTableGetNullable(_bc, _bcOffset, 18);
|
||||||
|
EquipmentTypeId? get equippedType => EquipmentTypeId._createOrNull(
|
||||||
|
const fb.Uint8Reader().vTableGetNullable(_bc, _bcOffset, 20),
|
||||||
|
);
|
||||||
dynamic get equipped {
|
dynamic get equipped {
|
||||||
switch (equippedType?.value) {
|
switch (equippedType?.value) {
|
||||||
case 1: return Weapon.reader.vTableGetNullable(_bc, _bcOffset, 22);
|
case 1:
|
||||||
default: return null;
|
return Weapon.reader.vTableGetNullable(_bc, _bcOffset, 22);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<Vec3>? get path => const fb.ListReader<Vec3>(Vec3.reader).vTableGetNullable(_bc, _bcOffset, 24);
|
|
||||||
|
List<Vec3>? get path => const fb.ListReader<Vec3>(
|
||||||
|
Vec3.reader,
|
||||||
|
).vTableGetNullable(_bc, _bcOffset, 24);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@@ -209,8 +213,8 @@ class _MonsterReader extends fb.TableReader<Monster> {
|
|||||||
const _MonsterReader();
|
const _MonsterReader();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Monster createObject(fb.BufferContext bc, int offset) =>
|
Monster createObject(fb.BufferContext bc, int offset) =>
|
||||||
Monster._(bc, offset);
|
Monster._(bc, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
class MonsterBuilder {
|
class MonsterBuilder {
|
||||||
@@ -226,38 +230,47 @@ class MonsterBuilder {
|
|||||||
fbBuilder.addStruct(0, offset);
|
fbBuilder.addStruct(0, offset);
|
||||||
return fbBuilder.offset;
|
return fbBuilder.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int addMana(int? mana) {
|
int addMana(int? mana) {
|
||||||
fbBuilder.addInt16(1, mana);
|
fbBuilder.addInt16(1, mana);
|
||||||
return fbBuilder.offset;
|
return fbBuilder.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int addHp(int? hp) {
|
int addHp(int? hp) {
|
||||||
fbBuilder.addInt16(2, hp);
|
fbBuilder.addInt16(2, hp);
|
||||||
return fbBuilder.offset;
|
return fbBuilder.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int addNameOffset(int? offset) {
|
int addNameOffset(int? offset) {
|
||||||
fbBuilder.addOffset(3, offset);
|
fbBuilder.addOffset(3, offset);
|
||||||
return fbBuilder.offset;
|
return fbBuilder.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int addInventoryOffset(int? offset) {
|
int addInventoryOffset(int? offset) {
|
||||||
fbBuilder.addOffset(5, offset);
|
fbBuilder.addOffset(5, offset);
|
||||||
return fbBuilder.offset;
|
return fbBuilder.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int addColor(Color? color) {
|
int addColor(Color? color) {
|
||||||
fbBuilder.addInt8(6, color?.value);
|
fbBuilder.addInt8(6, color?.value);
|
||||||
return fbBuilder.offset;
|
return fbBuilder.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int addWeaponsOffset(int? offset) {
|
int addWeaponsOffset(int? offset) {
|
||||||
fbBuilder.addOffset(7, offset);
|
fbBuilder.addOffset(7, offset);
|
||||||
return fbBuilder.offset;
|
return fbBuilder.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int addEquippedType(EquipmentTypeId? equippedType) {
|
int addEquippedType(EquipmentTypeId? equippedType) {
|
||||||
fbBuilder.addUint8(8, equippedType?.value);
|
fbBuilder.addUint8(8, equippedType?.value);
|
||||||
return fbBuilder.offset;
|
return fbBuilder.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int addEquippedOffset(int? offset) {
|
int addEquippedOffset(int? offset) {
|
||||||
fbBuilder.addOffset(9, offset);
|
fbBuilder.addOffset(9, offset);
|
||||||
return fbBuilder.offset;
|
return fbBuilder.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int addPathOffset(int? offset) {
|
int addPathOffset(int? offset) {
|
||||||
fbBuilder.addOffset(10, offset);
|
fbBuilder.addOffset(10, offset);
|
||||||
return fbBuilder.offset;
|
return fbBuilder.offset;
|
||||||
@@ -291,29 +304,34 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
|||||||
EquipmentTypeId? equippedType,
|
EquipmentTypeId? equippedType,
|
||||||
dynamic equipped,
|
dynamic equipped,
|
||||||
List<Vec3ObjectBuilder>? path,
|
List<Vec3ObjectBuilder>? path,
|
||||||
})
|
}) : _pos = pos,
|
||||||
: _pos = pos,
|
_mana = mana,
|
||||||
_mana = mana,
|
_hp = hp,
|
||||||
_hp = hp,
|
_name = name,
|
||||||
_name = name,
|
_inventory = inventory,
|
||||||
_inventory = inventory,
|
_color = color,
|
||||||
_color = color,
|
_weapons = weapons,
|
||||||
_weapons = weapons,
|
_equippedType = equippedType,
|
||||||
_equippedType = equippedType,
|
_equipped = equipped,
|
||||||
_equipped = equipped,
|
_path = path;
|
||||||
_path = path;
|
|
||||||
|
|
||||||
/// Finish building, and store into the [fbBuilder].
|
/// Finish building, and store into the [fbBuilder].
|
||||||
@override
|
@override
|
||||||
int finish(fb.Builder fbBuilder) {
|
int finish(fb.Builder fbBuilder) {
|
||||||
final int? nameOffset = _name == null ? null
|
final int? nameOffset = _name == null
|
||||||
|
? null
|
||||||
: fbBuilder.writeString(_name!);
|
: fbBuilder.writeString(_name!);
|
||||||
final int? inventoryOffset = _inventory == null ? null
|
final int? inventoryOffset = _inventory == null
|
||||||
|
? null
|
||||||
: fbBuilder.writeListUint8(_inventory!);
|
: fbBuilder.writeListUint8(_inventory!);
|
||||||
final int? weaponsOffset = _weapons == null ? null
|
final int? weaponsOffset = _weapons == null
|
||||||
: fbBuilder.writeList(_weapons!.map((b) => b.getOrCreateOffset(fbBuilder)).toList());
|
? null
|
||||||
|
: fbBuilder.writeList(
|
||||||
|
_weapons!.map((b) => b.getOrCreateOffset(fbBuilder)).toList(),
|
||||||
|
);
|
||||||
final int? equippedOffset = _equipped?.getOrCreateOffset(fbBuilder);
|
final int? equippedOffset = _equipped?.getOrCreateOffset(fbBuilder);
|
||||||
final int? pathOffset = _path == null ? null
|
final int? pathOffset = _path == null
|
||||||
|
? null
|
||||||
: fbBuilder.writeListOfStructs(_path!);
|
: fbBuilder.writeListOfStructs(_path!);
|
||||||
fbBuilder.startTable(10);
|
fbBuilder.startTable(10);
|
||||||
if (_pos != null) {
|
if (_pos != null) {
|
||||||
@@ -339,6 +357,7 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
|||||||
return fbBuilder.buffer;
|
return fbBuilder.buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Weapon {
|
class Weapon {
|
||||||
Weapon._(this._bc, this._bcOffset);
|
Weapon._(this._bc, this._bcOffset);
|
||||||
factory Weapon(List<int> bytes) {
|
factory Weapon(List<int> bytes) {
|
||||||
@@ -351,7 +370,8 @@ class Weapon {
|
|||||||
final fb.BufferContext _bc;
|
final fb.BufferContext _bc;
|
||||||
final int _bcOffset;
|
final int _bcOffset;
|
||||||
|
|
||||||
String? get name => const fb.StringReader().vTableGetNullable(_bc, _bcOffset, 4);
|
String? get name =>
|
||||||
|
const fb.StringReader().vTableGetNullable(_bc, _bcOffset, 4);
|
||||||
int get damage => const fb.Int16Reader().vTableGet(_bc, _bcOffset, 6, 0);
|
int get damage => const fb.Int16Reader().vTableGet(_bc, _bcOffset, 6, 0);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -364,8 +384,7 @@ class _WeaponReader extends fb.TableReader<Weapon> {
|
|||||||
const _WeaponReader();
|
const _WeaponReader();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Weapon createObject(fb.BufferContext bc, int offset) =>
|
Weapon createObject(fb.BufferContext bc, int offset) => Weapon._(bc, offset);
|
||||||
Weapon._(bc, offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class WeaponBuilder {
|
class WeaponBuilder {
|
||||||
@@ -381,6 +400,7 @@ class WeaponBuilder {
|
|||||||
fbBuilder.addOffset(0, offset);
|
fbBuilder.addOffset(0, offset);
|
||||||
return fbBuilder.offset;
|
return fbBuilder.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int addDamage(int? damage) {
|
int addDamage(int? damage) {
|
||||||
fbBuilder.addInt16(1, damage);
|
fbBuilder.addInt16(1, damage);
|
||||||
return fbBuilder.offset;
|
return fbBuilder.offset;
|
||||||
@@ -395,17 +415,15 @@ class WeaponObjectBuilder extends fb.ObjectBuilder {
|
|||||||
final String? _name;
|
final String? _name;
|
||||||
final int? _damage;
|
final int? _damage;
|
||||||
|
|
||||||
WeaponObjectBuilder({
|
WeaponObjectBuilder({String? name, int? damage})
|
||||||
String? name,
|
: _name = name,
|
||||||
int? damage,
|
_damage = damage;
|
||||||
})
|
|
||||||
: _name = name,
|
|
||||||
_damage = damage;
|
|
||||||
|
|
||||||
/// Finish building, and store into the [fbBuilder].
|
/// Finish building, and store into the [fbBuilder].
|
||||||
@override
|
@override
|
||||||
int finish(fb.Builder fbBuilder) {
|
int finish(fb.Builder fbBuilder) {
|
||||||
final int? nameOffset = _name == null ? null
|
final int? nameOffset = _name == null
|
||||||
|
? null
|
||||||
: fbBuilder.writeString(_name!);
|
: fbBuilder.writeString(_name!);
|
||||||
fbBuilder.startTable(2);
|
fbBuilder.startTable(2);
|
||||||
fbBuilder.addOffset(0, nameOffset);
|
fbBuilder.addOffset(0, nameOffset);
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
|
||||||
// for details. All rights reserved. Use of this source code is governed by a
|
|
||||||
// BSD-style license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
@@ -31,10 +27,11 @@ class BufferContext {
|
|||||||
ByteData get buffer => _buffer;
|
ByteData get buffer => _buffer;
|
||||||
|
|
||||||
/// Create from a FlatBuffer represented by a list of bytes (uint8).
|
/// Create from a FlatBuffer represented by a list of bytes (uint8).
|
||||||
factory BufferContext.fromBytes(List<int> byteList) =>
|
factory BufferContext.fromBytes(List<int> byteList) => BufferContext(
|
||||||
BufferContext(byteList is Uint8List
|
byteList is Uint8List
|
||||||
? byteList.buffer.asByteData(byteList.offsetInBytes)
|
? byteList.buffer.asByteData(byteList.offsetInBytes)
|
||||||
: ByteData.view(Uint8List.fromList(byteList).buffer));
|
: ByteData.view(Uint8List.fromList(byteList).buffer),
|
||||||
|
);
|
||||||
|
|
||||||
/// Create from a FlatBuffer represented by ByteData.
|
/// Create from a FlatBuffer represented by ByteData.
|
||||||
BufferContext(this._buffer);
|
BufferContext(this._buffer);
|
||||||
@@ -153,9 +150,9 @@ class Builder {
|
|||||||
bool internStrings = false,
|
bool internStrings = false,
|
||||||
Allocator allocator = const DefaultAllocator(),
|
Allocator allocator = const DefaultAllocator(),
|
||||||
this.deduplicateTables = true,
|
this.deduplicateTables = true,
|
||||||
}) : _allocator = allocator,
|
}) : _allocator = allocator,
|
||||||
_buf = allocator.allocate(initialSize),
|
_buf = allocator.allocate(initialSize),
|
||||||
_vTables = deduplicateTables ? [] : const [] {
|
_vTables = deduplicateTables ? [] : const [] {
|
||||||
if (internStrings) {
|
if (internStrings) {
|
||||||
_strings = <String, int>{};
|
_strings = <String, int>{};
|
||||||
}
|
}
|
||||||
@@ -308,7 +305,7 @@ class Builder {
|
|||||||
assert(_inVTable);
|
assert(_inVTable);
|
||||||
// Prepare for writing the VTable.
|
// Prepare for writing the VTable.
|
||||||
_prepare(_sizeofInt32, 1);
|
_prepare(_sizeofInt32, 1);
|
||||||
int tableTail = _tail;
|
final tableTail = _tail;
|
||||||
// Prepare the size of the current table.
|
// Prepare the size of the current table.
|
||||||
final currentVTable = _currentVTable!;
|
final currentVTable = _currentVTable!;
|
||||||
currentVTable.tableSize = tableTail - _currentTableEndTail;
|
currentVTable.tableSize = tableTail - _currentTableEndTail;
|
||||||
@@ -320,10 +317,10 @@ class Builder {
|
|||||||
// Try to find an existing compatible VTable.
|
// Try to find an existing compatible VTable.
|
||||||
if (deduplicateTables) {
|
if (deduplicateTables) {
|
||||||
// Search backward - more likely to have recently used one
|
// Search backward - more likely to have recently used one
|
||||||
for (int i = _vTables.length - 1; i >= 0; i--) {
|
for (var i = _vTables.length - 1; i >= 0; i--) {
|
||||||
final int vt2Offset = _vTables[i];
|
final vt2Offset = _vTables[i];
|
||||||
final int vt2Start = _buf.lengthInBytes - vt2Offset;
|
final vt2Start = _buf.lengthInBytes - vt2Offset;
|
||||||
final int vt2Size = _buf.getUint16(vt2Start, Endian.little);
|
final vt2Size = _buf.getUint16(vt2Start, Endian.little);
|
||||||
|
|
||||||
if (currentVTable._vTableSize == vt2Size &&
|
if (currentVTable._vTableSize == vt2Size &&
|
||||||
currentVTable._offsetsMatch(vt2Start, _buf)) {
|
currentVTable._offsetsMatch(vt2Start, _buf)) {
|
||||||
@@ -354,8 +351,10 @@ class Builder {
|
|||||||
Uint8List get buffer {
|
Uint8List get buffer {
|
||||||
assert(_finished);
|
assert(_finished);
|
||||||
final finishedSize = size();
|
final finishedSize = size();
|
||||||
return _buf.buffer
|
return _buf.buffer.asUint8List(
|
||||||
.asUint8List(_buf.lengthInBytes - finishedSize, finishedSize);
|
_buf.lengthInBytes - finishedSize,
|
||||||
|
finishedSize,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Finish off the creation of the buffer. The given [offset] is used as the
|
/// Finish off the creation of the buffer. The given [offset] is used as the
|
||||||
@@ -370,16 +369,20 @@ class Builder {
|
|||||||
final finishedSize = size();
|
final finishedSize = size();
|
||||||
_setUint32AtTail(finishedSize, finishedSize - offset);
|
_setUint32AtTail(finishedSize, finishedSize - offset);
|
||||||
if (fileIdentifier != null) {
|
if (fileIdentifier != null) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (var i = 0; i < 4; i++) {
|
||||||
_setUint8AtTail(
|
_setUint8AtTail(
|
||||||
finishedSize - _sizeofUint32 - i, fileIdentifier.codeUnitAt(i));
|
finishedSize - _sizeofUint32 - i,
|
||||||
|
fileIdentifier.codeUnitAt(i),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// zero out the added padding
|
// zero out the added padding
|
||||||
for (var i = sizeBeforePadding + 1;
|
for (
|
||||||
i <= finishedSize - requiredBytes;
|
var i = sizeBeforePadding + 1;
|
||||||
i++) {
|
i <= finishedSize - requiredBytes;
|
||||||
|
i++
|
||||||
|
) {
|
||||||
_setUint8AtTail(i, 0);
|
_setUint8AtTail(i, 0);
|
||||||
}
|
}
|
||||||
_finished = true;
|
_finished = true;
|
||||||
@@ -390,7 +393,7 @@ class Builder {
|
|||||||
/// Updates the [offset] pointer. This method is intended for use when writing structs to the buffer.
|
/// Updates the [offset] pointer. This method is intended for use when writing structs to the buffer.
|
||||||
void putFloat64(double value) {
|
void putFloat64(double value) {
|
||||||
_prepare(_sizeofFloat64, 1);
|
_prepare(_sizeofFloat64, 1);
|
||||||
_setFloat32AtTail(_tail, value);
|
_setFloat64AtTail(_tail, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Writes a Float32 to the tail of the buffer after preparing space for it.
|
/// Writes a Float32 to the tail of the buffer after preparing space for it.
|
||||||
@@ -401,6 +404,15 @@ class Builder {
|
|||||||
_setFloat32AtTail(_tail, value);
|
_setFloat32AtTail(_tail, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Writes a bool to the tail of the buffer after preparing space for it.
|
||||||
|
/// Bools are represented as a Uint8, with the value set to '1' for true, and '0' for false
|
||||||
|
///
|
||||||
|
/// Updates the [offset] pointer. This method is intended for use when writing structs to the buffer.
|
||||||
|
void putBool(bool value) {
|
||||||
|
_prepare(_sizeofUint8, 1);
|
||||||
|
_buf.setInt8(_buf.lengthInBytes - _tail, value ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
/// Writes a Int64 to the tail of the buffer after preparing space for it.
|
/// Writes a Int64 to the tail of the buffer after preparing space for it.
|
||||||
///
|
///
|
||||||
/// Updates the [offset] pointer. This method is intended for use when writing structs to the buffer.
|
/// Updates the [offset] pointer. This method is intended for use when writing structs to the buffer.
|
||||||
@@ -495,7 +507,7 @@ class Builder {
|
|||||||
/// Writes a list of Structs to the buffer, returning the offset
|
/// Writes a list of Structs to the buffer, returning the offset
|
||||||
int writeListOfStructs(List<ObjectBuilder> structBuilders) {
|
int writeListOfStructs(List<ObjectBuilder> structBuilders) {
|
||||||
assert(!_inVTable);
|
assert(!_inVTable);
|
||||||
for (int i = structBuilders.length - 1; i >= 0; i--) {
|
for (var i = structBuilders.length - 1; i >= 0; i--) {
|
||||||
structBuilders[i].finish(this);
|
structBuilders[i].finish(this);
|
||||||
}
|
}
|
||||||
return endStructVector(structBuilders.length);
|
return endStructVector(structBuilders.length);
|
||||||
@@ -505,11 +517,11 @@ class Builder {
|
|||||||
int writeList(List<int> values) {
|
int writeList(List<int> values) {
|
||||||
assert(!_inVTable);
|
assert(!_inVTable);
|
||||||
_prepare(_sizeofUint32, 1 + values.length);
|
_prepare(_sizeofUint32, 1 + values.length);
|
||||||
final int result = _tail;
|
final result = _tail;
|
||||||
int tail = _tail;
|
var tail = _tail;
|
||||||
_setUint32AtTail(tail, values.length);
|
_setUint32AtTail(tail, values.length);
|
||||||
tail -= _sizeofUint32;
|
tail -= _sizeofUint32;
|
||||||
for (int value in values) {
|
for (final value in values) {
|
||||||
_setUint32AtTail(tail, tail - value);
|
_setUint32AtTail(tail, tail - value);
|
||||||
tail -= _sizeofUint32;
|
tail -= _sizeofUint32;
|
||||||
}
|
}
|
||||||
@@ -520,11 +532,11 @@ class Builder {
|
|||||||
int writeListFloat64(List<double> values) {
|
int writeListFloat64(List<double> values) {
|
||||||
assert(!_inVTable);
|
assert(!_inVTable);
|
||||||
_prepare(_sizeofFloat64, values.length, additionalBytes: _sizeofUint32);
|
_prepare(_sizeofFloat64, values.length, additionalBytes: _sizeofUint32);
|
||||||
final int result = _tail;
|
final result = _tail;
|
||||||
int tail = _tail;
|
var tail = _tail;
|
||||||
_setUint32AtTail(tail, values.length);
|
_setUint32AtTail(tail, values.length);
|
||||||
tail -= _sizeofUint32;
|
tail -= _sizeofUint32;
|
||||||
for (double value in values) {
|
for (final value in values) {
|
||||||
_setFloat64AtTail(tail, value);
|
_setFloat64AtTail(tail, value);
|
||||||
tail -= _sizeofFloat64;
|
tail -= _sizeofFloat64;
|
||||||
}
|
}
|
||||||
@@ -535,11 +547,11 @@ class Builder {
|
|||||||
int writeListFloat32(List<double> values) {
|
int writeListFloat32(List<double> values) {
|
||||||
assert(!_inVTable);
|
assert(!_inVTable);
|
||||||
_prepare(_sizeofFloat32, 1 + values.length);
|
_prepare(_sizeofFloat32, 1 + values.length);
|
||||||
final int result = _tail;
|
final result = _tail;
|
||||||
int tail = _tail;
|
var tail = _tail;
|
||||||
_setUint32AtTail(tail, values.length);
|
_setUint32AtTail(tail, values.length);
|
||||||
tail -= _sizeofUint32;
|
tail -= _sizeofUint32;
|
||||||
for (double value in values) {
|
for (final value in values) {
|
||||||
_setFloat32AtTail(tail, value);
|
_setFloat32AtTail(tail, value);
|
||||||
tail -= _sizeofFloat32;
|
tail -= _sizeofFloat32;
|
||||||
}
|
}
|
||||||
@@ -550,11 +562,11 @@ class Builder {
|
|||||||
int writeListInt64(List<int> values) {
|
int writeListInt64(List<int> values) {
|
||||||
assert(!_inVTable);
|
assert(!_inVTable);
|
||||||
_prepare(_sizeofInt64, values.length, additionalBytes: _sizeofUint32);
|
_prepare(_sizeofInt64, values.length, additionalBytes: _sizeofUint32);
|
||||||
final int result = _tail;
|
final result = _tail;
|
||||||
int tail = _tail;
|
var tail = _tail;
|
||||||
_setUint32AtTail(tail, values.length);
|
_setUint32AtTail(tail, values.length);
|
||||||
tail -= _sizeofUint32;
|
tail -= _sizeofUint32;
|
||||||
for (int value in values) {
|
for (final value in values) {
|
||||||
_setInt64AtTail(tail, value);
|
_setInt64AtTail(tail, value);
|
||||||
tail -= _sizeofInt64;
|
tail -= _sizeofInt64;
|
||||||
}
|
}
|
||||||
@@ -565,11 +577,11 @@ class Builder {
|
|||||||
int writeListUint64(List<int> values) {
|
int writeListUint64(List<int> values) {
|
||||||
assert(!_inVTable);
|
assert(!_inVTable);
|
||||||
_prepare(_sizeofUint64, values.length, additionalBytes: _sizeofUint32);
|
_prepare(_sizeofUint64, values.length, additionalBytes: _sizeofUint32);
|
||||||
final int result = _tail;
|
final result = _tail;
|
||||||
int tail = _tail;
|
var tail = _tail;
|
||||||
_setUint32AtTail(tail, values.length);
|
_setUint32AtTail(tail, values.length);
|
||||||
tail -= _sizeofUint32;
|
tail -= _sizeofUint32;
|
||||||
for (int value in values) {
|
for (final value in values) {
|
||||||
_setUint64AtTail(tail, value);
|
_setUint64AtTail(tail, value);
|
||||||
tail -= _sizeofUint64;
|
tail -= _sizeofUint64;
|
||||||
}
|
}
|
||||||
@@ -580,11 +592,11 @@ class Builder {
|
|||||||
int writeListInt32(List<int> values) {
|
int writeListInt32(List<int> values) {
|
||||||
assert(!_inVTable);
|
assert(!_inVTable);
|
||||||
_prepare(_sizeofUint32, 1 + values.length);
|
_prepare(_sizeofUint32, 1 + values.length);
|
||||||
final int result = _tail;
|
final result = _tail;
|
||||||
int tail = _tail;
|
var tail = _tail;
|
||||||
_setUint32AtTail(tail, values.length);
|
_setUint32AtTail(tail, values.length);
|
||||||
tail -= _sizeofUint32;
|
tail -= _sizeofUint32;
|
||||||
for (int value in values) {
|
for (final value in values) {
|
||||||
_setInt32AtTail(tail, value);
|
_setInt32AtTail(tail, value);
|
||||||
tail -= _sizeofInt32;
|
tail -= _sizeofInt32;
|
||||||
}
|
}
|
||||||
@@ -595,11 +607,11 @@ class Builder {
|
|||||||
int writeListUint32(List<int> values) {
|
int writeListUint32(List<int> values) {
|
||||||
assert(!_inVTable);
|
assert(!_inVTable);
|
||||||
_prepare(_sizeofUint32, 1 + values.length);
|
_prepare(_sizeofUint32, 1 + values.length);
|
||||||
final int result = _tail;
|
final result = _tail;
|
||||||
int tail = _tail;
|
var tail = _tail;
|
||||||
_setUint32AtTail(tail, values.length);
|
_setUint32AtTail(tail, values.length);
|
||||||
tail -= _sizeofUint32;
|
tail -= _sizeofUint32;
|
||||||
for (int value in values) {
|
for (final value in values) {
|
||||||
_setUint32AtTail(tail, value);
|
_setUint32AtTail(tail, value);
|
||||||
tail -= _sizeofUint32;
|
tail -= _sizeofUint32;
|
||||||
}
|
}
|
||||||
@@ -610,11 +622,11 @@ class Builder {
|
|||||||
int writeListInt16(List<int> values) {
|
int writeListInt16(List<int> values) {
|
||||||
assert(!_inVTable);
|
assert(!_inVTable);
|
||||||
_prepare(_sizeofUint32, 1, additionalBytes: 2 * values.length);
|
_prepare(_sizeofUint32, 1, additionalBytes: 2 * values.length);
|
||||||
final int result = _tail;
|
final result = _tail;
|
||||||
int tail = _tail;
|
var tail = _tail;
|
||||||
_setUint32AtTail(tail, values.length);
|
_setUint32AtTail(tail, values.length);
|
||||||
tail -= _sizeofUint32;
|
tail -= _sizeofUint32;
|
||||||
for (int value in values) {
|
for (final value in values) {
|
||||||
_setInt16AtTail(tail, value);
|
_setInt16AtTail(tail, value);
|
||||||
tail -= _sizeofInt16;
|
tail -= _sizeofInt16;
|
||||||
}
|
}
|
||||||
@@ -625,11 +637,11 @@ class Builder {
|
|||||||
int writeListUint16(List<int> values) {
|
int writeListUint16(List<int> values) {
|
||||||
assert(!_inVTable);
|
assert(!_inVTable);
|
||||||
_prepare(_sizeofUint32, 1, additionalBytes: 2 * values.length);
|
_prepare(_sizeofUint32, 1, additionalBytes: 2 * values.length);
|
||||||
final int result = _tail;
|
final result = _tail;
|
||||||
int tail = _tail;
|
var tail = _tail;
|
||||||
_setUint32AtTail(tail, values.length);
|
_setUint32AtTail(tail, values.length);
|
||||||
tail -= _sizeofUint32;
|
tail -= _sizeofUint32;
|
||||||
for (int value in values) {
|
for (final value in values) {
|
||||||
_setUint16AtTail(tail, value);
|
_setUint16AtTail(tail, value);
|
||||||
tail -= _sizeofUint16;
|
tail -= _sizeofUint16;
|
||||||
}
|
}
|
||||||
@@ -645,11 +657,11 @@ class Builder {
|
|||||||
int writeListInt8(List<int> values) {
|
int writeListInt8(List<int> values) {
|
||||||
assert(!_inVTable);
|
assert(!_inVTable);
|
||||||
_prepare(_sizeofUint32, 1, additionalBytes: values.length);
|
_prepare(_sizeofUint32, 1, additionalBytes: values.length);
|
||||||
final int result = _tail;
|
final result = _tail;
|
||||||
int tail = _tail;
|
var tail = _tail;
|
||||||
_setUint32AtTail(tail, values.length);
|
_setUint32AtTail(tail, values.length);
|
||||||
tail -= _sizeofUint32;
|
tail -= _sizeofUint32;
|
||||||
for (int value in values) {
|
for (final value in values) {
|
||||||
_setInt8AtTail(tail, value);
|
_setInt8AtTail(tail, value);
|
||||||
tail -= _sizeofUint8;
|
tail -= _sizeofUint8;
|
||||||
}
|
}
|
||||||
@@ -660,11 +672,11 @@ class Builder {
|
|||||||
int writeListUint8(List<int> values) {
|
int writeListUint8(List<int> values) {
|
||||||
assert(!_inVTable);
|
assert(!_inVTable);
|
||||||
_prepare(_sizeofUint32, 1, additionalBytes: values.length);
|
_prepare(_sizeofUint32, 1, additionalBytes: values.length);
|
||||||
final int result = _tail;
|
final result = _tail;
|
||||||
int tail = _tail;
|
var tail = _tail;
|
||||||
_setUint32AtTail(tail, values.length);
|
_setUint32AtTail(tail, values.length);
|
||||||
tail -= _sizeofUint32;
|
tail -= _sizeofUint32;
|
||||||
for (int value in values) {
|
for (final value in values) {
|
||||||
_setUint8AtTail(tail, value);
|
_setUint8AtTail(tail, value);
|
||||||
tail -= _sizeofUint8;
|
tail -= _sizeofUint8;
|
||||||
}
|
}
|
||||||
@@ -682,8 +694,10 @@ class Builder {
|
|||||||
int writeString(String value, {bool asciiOptimization = false}) {
|
int writeString(String value, {bool asciiOptimization = false}) {
|
||||||
assert(!_inVTable);
|
assert(!_inVTable);
|
||||||
if (_strings != null) {
|
if (_strings != null) {
|
||||||
return _strings!
|
return _strings!.putIfAbsent(
|
||||||
.putIfAbsent(value, () => _writeString(value, asciiOptimization));
|
value,
|
||||||
|
() => _writeString(value, asciiOptimization),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return _writeString(value, asciiOptimization);
|
return _writeString(value, asciiOptimization);
|
||||||
}
|
}
|
||||||
@@ -729,7 +743,7 @@ class Builder {
|
|||||||
_prepare(4, 1, additionalBytes: length + 1);
|
_prepare(4, 1, additionalBytes: length + 1);
|
||||||
_setUint32AtTail(_tail, length);
|
_setUint32AtTail(_tail, length);
|
||||||
var offset = _buf.lengthInBytes - _tail + 4;
|
var offset = _buf.lengthInBytes - _tail + 4;
|
||||||
for (int i = 0; i < length; i++) {
|
for (var i = 0; i < length; i++) {
|
||||||
_buf.setUint8(offset++, bytes[i]);
|
_buf.setUint8(offset++, bytes[i]);
|
||||||
}
|
}
|
||||||
_buf.setUint8(offset, 0); // trailing zero
|
_buf.setUint8(offset, 0); // trailing zero
|
||||||
@@ -756,7 +770,7 @@ class Builder {
|
|||||||
/// Zero-pads the buffer, which may be required for some struct layouts.
|
/// Zero-pads the buffer, which may be required for some struct layouts.
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
void pad(int howManyBytes) {
|
void pad(int howManyBytes) {
|
||||||
for (int i = 0; i < howManyBytes; i++) {
|
for (var i = 0; i < howManyBytes; i++) {
|
||||||
putUint8(0);
|
putUint8(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -772,17 +786,17 @@ class Builder {
|
|||||||
_maxAlign = size;
|
_maxAlign = size;
|
||||||
}
|
}
|
||||||
// Prepare amount of required space.
|
// Prepare amount of required space.
|
||||||
int dataSize = size * count + additionalBytes;
|
final dataSize = size * count + additionalBytes;
|
||||||
int alignDelta = (-(_tail + dataSize)) & (size - 1);
|
final alignDelta = (-(_tail + dataSize)) & (size - 1);
|
||||||
int bufSize = alignDelta + dataSize;
|
final bufSize = alignDelta + dataSize;
|
||||||
// Ensure that we have the required amount of space.
|
// Ensure that we have the required amount of space.
|
||||||
{
|
{
|
||||||
int oldCapacity = _buf.lengthInBytes;
|
final oldCapacity = _buf.lengthInBytes;
|
||||||
if (_tail + bufSize > oldCapacity) {
|
if (_tail + bufSize > oldCapacity) {
|
||||||
int desiredNewCapacity = (oldCapacity + bufSize) * 2;
|
final desiredNewCapacity = (oldCapacity + bufSize) * 2;
|
||||||
int deltaCapacity = desiredNewCapacity - oldCapacity;
|
var deltaCapacity = desiredNewCapacity - oldCapacity;
|
||||||
deltaCapacity += (-deltaCapacity) & (_maxAlign - 1);
|
deltaCapacity += (-deltaCapacity) & (_maxAlign - 1);
|
||||||
int newCapacity = oldCapacity + deltaCapacity;
|
final newCapacity = oldCapacity + deltaCapacity;
|
||||||
_buf = _allocator.resize(_buf, newCapacity, _tail, 0);
|
_buf = _allocator.resize(_buf, newCapacity, _tail, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1000,8 +1014,11 @@ class ListReader<E> extends Reader<List<E>> {
|
|||||||
: List<E>.generate(
|
: List<E>.generate(
|
||||||
bc.buffer.getUint32(listOffset, Endian.little),
|
bc.buffer.getUint32(listOffset, Endian.little),
|
||||||
(int index) => _elementReader.read(
|
(int index) => _elementReader.read(
|
||||||
bc, listOffset + size + _elementReader.size * index),
|
bc,
|
||||||
growable: true);
|
listOffset + size + _elementReader.size * index,
|
||||||
|
),
|
||||||
|
growable: true,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1018,22 +1035,22 @@ abstract class Reader<T> {
|
|||||||
/// Read the value of the given [field] in the given [object].
|
/// Read the value of the given [field] in the given [object].
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
T vTableGet(BufferContext object, int offset, int field, T defaultValue) {
|
T vTableGet(BufferContext object, int offset, int field, T defaultValue) {
|
||||||
int fieldOffset = _vTableFieldOffset(object, offset, field);
|
final fieldOffset = _vTableFieldOffset(object, offset, field);
|
||||||
return fieldOffset == 0 ? defaultValue : read(object, offset + fieldOffset);
|
return fieldOffset == 0 ? defaultValue : read(object, offset + fieldOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read the value of the given [field] in the given [object].
|
/// Read the value of the given [field] in the given [object].
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
T? vTableGetNullable(BufferContext object, int offset, int field) {
|
T? vTableGetNullable(BufferContext object, int offset, int field) {
|
||||||
int fieldOffset = _vTableFieldOffset(object, offset, field);
|
final fieldOffset = _vTableFieldOffset(object, offset, field);
|
||||||
return fieldOffset == 0 ? null : read(object, offset + fieldOffset);
|
return fieldOffset == 0 ? null : read(object, offset + fieldOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
int _vTableFieldOffset(BufferContext object, int offset, int field) {
|
int _vTableFieldOffset(BufferContext object, int offset, int field) {
|
||||||
int vTableSOffset = object._getInt32(offset);
|
final vTableSOffset = object._getInt32(offset);
|
||||||
int vTableOffset = offset - vTableSOffset;
|
final vTableOffset = offset - vTableSOffset;
|
||||||
int vTableSize = object._getUint16(vTableOffset);
|
final vTableSize = object._getUint16(vTableOffset);
|
||||||
if (field >= vTableSize) return 0;
|
if (field >= vTableSize) return 0;
|
||||||
return object._getUint16(vTableOffset + field);
|
return object._getUint16(vTableOffset + field);
|
||||||
}
|
}
|
||||||
@@ -1052,9 +1069,9 @@ class StringReader extends Reader<String> {
|
|||||||
@override
|
@override
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
String read(BufferContext bc, int offset) {
|
String read(BufferContext bc, int offset) {
|
||||||
int strOffset = bc.derefObject(offset);
|
final strOffset = bc.derefObject(offset);
|
||||||
int length = bc._getUint32(strOffset);
|
final length = bc._getUint32(strOffset);
|
||||||
Uint8List bytes = bc._asUint8List(strOffset + _sizeofUint32, length);
|
final bytes = bc._asUint8List(strOffset + _sizeofUint32, length);
|
||||||
if (asciiOptimization && _isLatin(bytes)) {
|
if (asciiOptimization && _isLatin(bytes)) {
|
||||||
return String.fromCharCodes(bytes);
|
return String.fromCharCodes(bytes);
|
||||||
}
|
}
|
||||||
@@ -1063,8 +1080,8 @@ class StringReader extends Reader<String> {
|
|||||||
|
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
static bool _isLatin(Uint8List bytes) {
|
static bool _isLatin(Uint8List bytes) {
|
||||||
int length = bytes.length;
|
final length = bytes.length;
|
||||||
for (int i = 0; i < length; i++) {
|
for (var i = 0; i < length; i++) {
|
||||||
if (bytes[i] > 127) {
|
if (bytes[i] > 127) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1099,7 +1116,7 @@ abstract class TableReader<T> extends Reader<T> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
T read(BufferContext bc, int offset) {
|
T read(BufferContext bc, int offset) {
|
||||||
int objectOffset = bc.derefObject(offset);
|
final objectOffset = bc.derefObject(offset);
|
||||||
return createObject(bc, objectOffset);
|
return createObject(bc, objectOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1279,13 +1296,13 @@ class _FbGenericList<E> extends _FbList<E> {
|
|||||||
List<E?>? _items;
|
List<E?>? _items;
|
||||||
|
|
||||||
_FbGenericList(this.elementReader, BufferContext bp, int offset)
|
_FbGenericList(this.elementReader, BufferContext bp, int offset)
|
||||||
: super(bp, offset);
|
: super(bp, offset);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
E operator [](int i) {
|
E operator [](int i) {
|
||||||
_items ??= List<E?>.filled(length, null);
|
_items ??= List<E?>.filled(length, null);
|
||||||
E? item = _items![i];
|
var item = _items![i];
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
item = elementReader.read(bc, offset + 4 + elementReader.size * i);
|
item = elementReader.read(bc, offset + 4 + elementReader.size * i);
|
||||||
_items![i] = item;
|
_items![i] = item;
|
||||||
@@ -1394,7 +1411,7 @@ class _VTable {
|
|||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
bool _offsetsMatch(int vt2Start, ByteData buf) {
|
bool _offsetsMatch(int vt2Start, ByteData buf) {
|
||||||
assert(offsetsComputed);
|
assert(offsetsComputed);
|
||||||
for (int i = 0; i < numFields; i++) {
|
for (var i = 0; i < numFields; i++) {
|
||||||
if (fieldOffsets[i] !=
|
if (fieldOffsets[i] !=
|
||||||
buf.getUint16(vt2Start + _metadataLength + (2 * i), Endian.little)) {
|
buf.getUint16(vt2Start + _metadataLength + (2 * i), Endian.little)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -1427,7 +1444,7 @@ class _VTable {
|
|||||||
buf.setUint16(bufOffset, tableSize, Endian.little);
|
buf.setUint16(bufOffset, tableSize, Endian.little);
|
||||||
bufOffset += 2;
|
bufOffset += 2;
|
||||||
// Field offsets.
|
// Field offsets.
|
||||||
for (int i = 0; i < numFields; i++) {
|
for (var i = 0; i < numFields; i++) {
|
||||||
buf.setUint16(bufOffset, fieldOffsets[i], Endian.little);
|
buf.setUint16(bufOffset, fieldOffsets[i], Endian.little);
|
||||||
bufOffset += 2;
|
bufOffset += 2;
|
||||||
}
|
}
|
||||||
@@ -1449,7 +1466,11 @@ abstract class Allocator {
|
|||||||
/// Params [inUseBack] and [inUseFront] indicate how much of [oldData] is
|
/// Params [inUseBack] and [inUseFront] indicate how much of [oldData] is
|
||||||
/// actually in use at each end, and needs to be copied.
|
/// actually in use at each end, and needs to be copied.
|
||||||
ByteData resize(
|
ByteData resize(
|
||||||
ByteData oldData, int newSize, int inUseBack, int inUseFront) {
|
ByteData oldData,
|
||||||
|
int newSize,
|
||||||
|
int inUseBack,
|
||||||
|
int inUseFront,
|
||||||
|
) {
|
||||||
final newData = allocate(newSize);
|
final newData = allocate(newSize);
|
||||||
_copyDownward(oldData, newData, inUseBack, inUseFront);
|
_copyDownward(oldData, newData, inUseBack, inUseFront);
|
||||||
deallocate(oldData);
|
deallocate(oldData);
|
||||||
@@ -1460,17 +1481,25 @@ abstract class Allocator {
|
|||||||
/// memory of size [inUseFront] and [inUseBack] will be copied from the front
|
/// memory of size [inUseFront] and [inUseBack] will be copied from the front
|
||||||
/// and back of the old memory allocation.
|
/// and back of the old memory allocation.
|
||||||
void _copyDownward(
|
void _copyDownward(
|
||||||
ByteData oldData, ByteData newData, int inUseBack, int inUseFront) {
|
ByteData oldData,
|
||||||
|
ByteData newData,
|
||||||
|
int inUseBack,
|
||||||
|
int inUseFront,
|
||||||
|
) {
|
||||||
if (inUseBack != 0) {
|
if (inUseBack != 0) {
|
||||||
newData.buffer.asUint8List().setAll(
|
newData.buffer.asUint8List().setAll(
|
||||||
newData.lengthInBytes - inUseBack,
|
newData.lengthInBytes - inUseBack,
|
||||||
oldData.buffer.asUint8List().getRange(
|
oldData.buffer.asUint8List().getRange(
|
||||||
oldData.lengthInBytes - inUseBack, oldData.lengthInBytes));
|
oldData.lengthInBytes - inUseBack,
|
||||||
|
oldData.lengthInBytes,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (inUseFront != 0) {
|
if (inUseFront != 0) {
|
||||||
newData.buffer
|
newData.buffer.asUint8List().setAll(
|
||||||
.asUint8List()
|
0,
|
||||||
.setAll(0, oldData.buffer.asUint8List().getRange(0, inUseFront));
|
oldData.buffer.asUint8List().getRange(0, inUseFront),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import 'types.dart';
|
|||||||
|
|
||||||
/// The main builder class for creation of a FlexBuffer.
|
/// The main builder class for creation of a FlexBuffer.
|
||||||
class Builder {
|
class Builder {
|
||||||
final ByteData _buffer;
|
ByteData _buffer;
|
||||||
List<_StackValue> _stack = [];
|
List<_StackValue> _stack = [];
|
||||||
List<_StackPointer> _stackPointers = [];
|
List<_StackPointer> _stackPointers = [];
|
||||||
int _offset = 0;
|
int _offset = 0;
|
||||||
@@ -17,7 +17,7 @@ class Builder {
|
|||||||
final Map<double, _StackValue> _indirectDoubleCache = {};
|
final Map<double, _StackValue> _indirectDoubleCache = {};
|
||||||
|
|
||||||
/// Instantiate the builder if you intent to gradually build up the buffer by calling
|
/// Instantiate the builder if you intent to gradually build up the buffer by calling
|
||||||
/// add... methods and calling [finish] to receive the the resulting byte array.
|
/// add... methods and calling [finish] to receive the resulting byte array.
|
||||||
///
|
///
|
||||||
/// The default size of internal buffer is set to 2048. Provide a different value in order to avoid buffer copies.
|
/// The default size of internal buffer is set to 2048. Provide a different value in order to avoid buffer copies.
|
||||||
Builder({int size = 2048}) : _buffer = ByteData(size);
|
Builder({int size = 2048}) : _buffer = ByteData(size);
|
||||||
@@ -107,8 +107,11 @@ class Builder {
|
|||||||
final newOffset = _newOffset(length + 1);
|
final newOffset = _newOffset(length + 1);
|
||||||
_pushBuffer(utf8String);
|
_pushBuffer(utf8String);
|
||||||
_offset = newOffset;
|
_offset = newOffset;
|
||||||
final stackValue =
|
final stackValue = _StackValue.withOffset(
|
||||||
_StackValue.withOffset(stringOffset, ValueType.String, bitWidth);
|
stringOffset,
|
||||||
|
ValueType.String,
|
||||||
|
bitWidth,
|
||||||
|
);
|
||||||
_stack.add(stackValue);
|
_stack.add(stackValue);
|
||||||
_stringCache[value] = stackValue;
|
_stringCache[value] = stackValue;
|
||||||
}
|
}
|
||||||
@@ -128,8 +131,11 @@ class Builder {
|
|||||||
final newOffset = _newOffset(length + 1);
|
final newOffset = _newOffset(length + 1);
|
||||||
_pushBuffer(utf8String);
|
_pushBuffer(utf8String);
|
||||||
_offset = newOffset;
|
_offset = newOffset;
|
||||||
final stackValue =
|
final stackValue = _StackValue.withOffset(
|
||||||
_StackValue.withOffset(keyOffset, ValueType.Key, BitWidth.width8);
|
keyOffset,
|
||||||
|
ValueType.Key,
|
||||||
|
BitWidth.width8,
|
||||||
|
);
|
||||||
_stack.add(stackValue);
|
_stack.add(stackValue);
|
||||||
_keyCache[value] = stackValue;
|
_keyCache[value] = stackValue;
|
||||||
}
|
}
|
||||||
@@ -147,8 +153,11 @@ class Builder {
|
|||||||
final newOffset = _newOffset(length);
|
final newOffset = _newOffset(length);
|
||||||
_pushBuffer(value.asUint8List());
|
_pushBuffer(value.asUint8List());
|
||||||
_offset = newOffset;
|
_offset = newOffset;
|
||||||
final stackValue =
|
final stackValue = _StackValue.withOffset(
|
||||||
_StackValue.withOffset(blobOffset, ValueType.Blob, bitWidth);
|
blobOffset,
|
||||||
|
ValueType.Blob,
|
||||||
|
bitWidth,
|
||||||
|
);
|
||||||
_stack.add(stackValue);
|
_stack.add(stackValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +179,10 @@ class Builder {
|
|||||||
final valueOffset = _offset;
|
final valueOffset = _offset;
|
||||||
_pushBuffer(stackValue.asU8List(stackValue.width));
|
_pushBuffer(stackValue.asU8List(stackValue.width));
|
||||||
final stackOffset = _StackValue.withOffset(
|
final stackOffset = _StackValue.withOffset(
|
||||||
valueOffset, ValueType.IndirectInt, stackValue.width);
|
valueOffset,
|
||||||
|
ValueType.IndirectInt,
|
||||||
|
stackValue.width,
|
||||||
|
);
|
||||||
_stack.add(stackOffset);
|
_stack.add(stackOffset);
|
||||||
_offset = newOffset;
|
_offset = newOffset;
|
||||||
if (cache) {
|
if (cache) {
|
||||||
@@ -195,7 +207,10 @@ class Builder {
|
|||||||
final valueOffset = _offset;
|
final valueOffset = _offset;
|
||||||
_pushBuffer(stackValue.asU8List(stackValue.width));
|
_pushBuffer(stackValue.asU8List(stackValue.width));
|
||||||
final stackOffset = _StackValue.withOffset(
|
final stackOffset = _StackValue.withOffset(
|
||||||
valueOffset, ValueType.IndirectFloat, stackValue.width);
|
valueOffset,
|
||||||
|
ValueType.IndirectFloat,
|
||||||
|
stackValue.width,
|
||||||
|
);
|
||||||
_stack.add(stackOffset);
|
_stack.add(stackOffset);
|
||||||
_offset = newOffset;
|
_offset = newOffset;
|
||||||
if (cache) {
|
if (cache) {
|
||||||
@@ -252,9 +267,10 @@ class Builder {
|
|||||||
tmp._offset = _offset;
|
tmp._offset = _offset;
|
||||||
tmp._stack = List.from(_stack);
|
tmp._stack = List.from(_stack);
|
||||||
tmp._stackPointers = List.from(_stackPointers);
|
tmp._stackPointers = List.from(_stackPointers);
|
||||||
tmp._buffer.buffer
|
tmp._buffer.buffer.asUint8List().setAll(
|
||||||
.asUint8List()
|
0,
|
||||||
.setAll(0, _buffer.buffer.asUint8List(0, _offset));
|
_buffer.buffer.asUint8List(0, _offset),
|
||||||
|
);
|
||||||
for (var i = 0; i < tmp._stackPointers.length; i++) {
|
for (var i = 0; i < tmp._stackPointers.length; i++) {
|
||||||
tmp.end();
|
tmp.end();
|
||||||
}
|
}
|
||||||
@@ -271,7 +287,8 @@ class Builder {
|
|||||||
if (_stackPointers.isNotEmpty && _stackPointers.last.isVector == false) {
|
if (_stackPointers.isNotEmpty && _stackPointers.last.isVector == false) {
|
||||||
if (_stack.last.type != ValueType.Key) {
|
if (_stack.last.type != ValueType.Key) {
|
||||||
throw StateError(
|
throw StateError(
|
||||||
'Adding value to a map before adding a key is prohibited');
|
'Adding value to a map before adding a key is prohibited',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -288,7 +305,8 @@ class Builder {
|
|||||||
void _finish() {
|
void _finish() {
|
||||||
if (_stack.length != 1) {
|
if (_stack.length != 1) {
|
||||||
throw StateError(
|
throw StateError(
|
||||||
'Stack has to be exactly 1, but is ${_stack.length}. You have to end all started vectors and maps, before calling [finish]');
|
'Stack has to be exactly 1, but is ${_stack.length}. You have to end all started vectors and maps, before calling [finish]',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
final value = _stack[0];
|
final value = _stack[0];
|
||||||
final byteWidth = _align(value.elementWidth(_offset, 0));
|
final byteWidth = _align(value.elementWidth(_offset, 0));
|
||||||
@@ -298,8 +316,12 @@ class Builder {
|
|||||||
_finished = true;
|
_finished = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_StackValue _createVector(int start, int vecLength, int step,
|
_StackValue _createVector(
|
||||||
[_StackValue? keys]) {
|
int start,
|
||||||
|
int vecLength,
|
||||||
|
int step, [
|
||||||
|
_StackValue? keys,
|
||||||
|
]) {
|
||||||
var bitWidth = BitWidthUtil.uwidth(vecLength);
|
var bitWidth = BitWidthUtil.uwidth(vecLength);
|
||||||
var prefixElements = 1;
|
var prefixElements = 1;
|
||||||
if (keys != null) {
|
if (keys != null) {
|
||||||
@@ -326,7 +348,8 @@ class Builder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final byteWidth = _align(bitWidth);
|
final byteWidth = _align(bitWidth);
|
||||||
final fix = typed & ValueTypeUtils.isNumber(vectorType) &&
|
final fix =
|
||||||
|
typed & ValueTypeUtils.isNumber(vectorType) &&
|
||||||
vecLength >= 2 &&
|
vecLength >= 2 &&
|
||||||
vecLength <= 4;
|
vecLength <= 4;
|
||||||
if (keys != null) {
|
if (keys != null) {
|
||||||
@@ -349,8 +372,10 @@ class Builder {
|
|||||||
return _StackValue.withOffset(vecOffset, ValueType.Map, bitWidth);
|
return _StackValue.withOffset(vecOffset, ValueType.Map, bitWidth);
|
||||||
}
|
}
|
||||||
if (typed) {
|
if (typed) {
|
||||||
final vType =
|
final vType = ValueTypeUtils.toTypedVector(
|
||||||
ValueTypeUtils.toTypedVector(vectorType, fix ? vecLength : 0);
|
vectorType,
|
||||||
|
fix ? vecLength : 0,
|
||||||
|
);
|
||||||
return _StackValue.withOffset(vecOffset, vType, bitWidth);
|
return _StackValue.withOffset(vecOffset, vType, bitWidth);
|
||||||
}
|
}
|
||||||
return _StackValue.withOffset(vecOffset, ValueType.Vector, bitWidth);
|
return _StackValue.withOffset(vecOffset, ValueType.Vector, bitWidth);
|
||||||
@@ -366,7 +391,8 @@ class Builder {
|
|||||||
void _sortKeysAndEndMap(_StackPointer pointer) {
|
void _sortKeysAndEndMap(_StackPointer pointer) {
|
||||||
if (((_stack.length - pointer.stackPosition) & 1) == 1) {
|
if (((_stack.length - pointer.stackPosition) & 1) == 1) {
|
||||||
throw StateError(
|
throw StateError(
|
||||||
'The stack needs to hold key value pairs (even number of elements). Check if you combined [addKey] with add... method calls properly.');
|
'The stack needs to hold key value pairs (even number of elements). Check if you combined [addKey] with add... method calls properly.',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var sorted = true;
|
var sorted = true;
|
||||||
@@ -412,8 +438,12 @@ class Builder {
|
|||||||
keysStackValue = _createVector(pointer.stackPosition, vecLength, 2);
|
keysStackValue = _createVector(pointer.stackPosition, vecLength, 2);
|
||||||
_keyVectorCache[keysHash] = keysStackValue;
|
_keyVectorCache[keysHash] = keysStackValue;
|
||||||
}
|
}
|
||||||
final vec =
|
final vec = _createVector(
|
||||||
_createVector(pointer.stackPosition + 1, vecLength, 2, keysStackValue);
|
pointer.stackPosition + 1,
|
||||||
|
vecLength,
|
||||||
|
2,
|
||||||
|
keysStackValue,
|
||||||
|
);
|
||||||
_stack.removeRange(pointer.stackPosition, _stack.length);
|
_stack.removeRange(pointer.stackPosition, _stack.length);
|
||||||
_stack.add(vec);
|
_stack.add(vec);
|
||||||
}
|
}
|
||||||
@@ -421,7 +451,8 @@ class Builder {
|
|||||||
bool _shouldFlip(_StackValue v1, _StackValue v2) {
|
bool _shouldFlip(_StackValue v1, _StackValue v2) {
|
||||||
if (v1.type != ValueType.Key || v2.type != ValueType.Key) {
|
if (v1.type != ValueType.Key || v2.type != ValueType.Key) {
|
||||||
throw StateError(
|
throw StateError(
|
||||||
'Stack values are not keys $v1 | $v2. Check if you combined [addKey] with add... method calls properly.');
|
'Stack values are not keys $v1 | $v2. Check if you combined [addKey] with add... method calls properly.',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
late int c1, c2;
|
late int c1, c2;
|
||||||
@@ -450,7 +481,8 @@ class Builder {
|
|||||||
_writeUInt(relativeOffset, byteWidth);
|
_writeUInt(relativeOffset, byteWidth);
|
||||||
} else {
|
} else {
|
||||||
throw StateError(
|
throw StateError(
|
||||||
'Unexpected size $byteWidth. This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new');
|
'Unexpected size $byteWidth. This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_pushBuffer(value.asU8List(BitWidthUtil.fromByteWidth(byteWidth)));
|
_pushBuffer(value.asU8List(BitWidthUtil.fromByteWidth(byteWidth)));
|
||||||
@@ -474,6 +506,7 @@ class Builder {
|
|||||||
if (prevSize < size) {
|
if (prevSize < size) {
|
||||||
final newBuf = ByteData(size);
|
final newBuf = ByteData(size);
|
||||||
newBuf.buffer.asUint8List().setAll(0, _buffer.buffer.asUint8List());
|
newBuf.buffer.asUint8List().setAll(0, _buffer.buffer.asUint8List());
|
||||||
|
_buffer = newBuf;
|
||||||
}
|
}
|
||||||
return newOffset;
|
return newOffset;
|
||||||
}
|
}
|
||||||
@@ -523,29 +556,27 @@ class _StackValue {
|
|||||||
final ValueType _type;
|
final ValueType _type;
|
||||||
final BitWidth _width;
|
final BitWidth _width;
|
||||||
|
|
||||||
_StackValue.withNull()
|
_StackValue.withNull() : _type = ValueType.Null, _width = BitWidth.width8;
|
||||||
: _type = ValueType.Null,
|
|
||||||
_width = BitWidth.width8;
|
|
||||||
|
|
||||||
_StackValue.withInt(int value)
|
_StackValue.withInt(int value)
|
||||||
: _type = ValueType.Int,
|
: _type = ValueType.Int,
|
||||||
_width = BitWidthUtil.width(value),
|
_width = BitWidthUtil.width(value),
|
||||||
_value = value;
|
_value = value;
|
||||||
|
|
||||||
_StackValue.withBool(bool value)
|
_StackValue.withBool(bool value)
|
||||||
: _type = ValueType.Bool,
|
: _type = ValueType.Bool,
|
||||||
_width = BitWidth.width8,
|
_width = BitWidth.width8,
|
||||||
_value = value;
|
_value = value;
|
||||||
|
|
||||||
_StackValue.withDouble(double value)
|
_StackValue.withDouble(double value)
|
||||||
: _type = ValueType.Float,
|
: _type = ValueType.Float,
|
||||||
_width = BitWidthUtil.width(value),
|
_width = BitWidthUtil.width(value),
|
||||||
_value = value;
|
_value = value;
|
||||||
|
|
||||||
_StackValue.withOffset(int value, ValueType type, BitWidth width)
|
_StackValue.withOffset(int value, ValueType type, BitWidth width)
|
||||||
: _offset = value,
|
: _offset = value,
|
||||||
_type = type,
|
_type = type,
|
||||||
_width = width;
|
_width = width;
|
||||||
|
|
||||||
BitWidth storedWidth({BitWidth width = BitWidth.width8}) {
|
BitWidth storedWidth({BitWidth width = BitWidth.width8}) {
|
||||||
return ValueTypeUtils.isInline(_type)
|
return ValueTypeUtils.isInline(_type)
|
||||||
@@ -562,16 +593,16 @@ class _StackValue {
|
|||||||
final offset = _offset!;
|
final offset = _offset!;
|
||||||
for (var i = 0; i < 4; i++) {
|
for (var i = 0; i < 4; i++) {
|
||||||
final width = 1 << i;
|
final width = 1 << i;
|
||||||
final bitWidth = BitWidthUtil.uwidth(size +
|
final bitWidth = BitWidthUtil.uwidth(
|
||||||
BitWidthUtil.paddingSize(size, width) +
|
size + BitWidthUtil.paddingSize(size, width) + index * width - offset,
|
||||||
index * width -
|
);
|
||||||
offset);
|
|
||||||
if (1 << bitWidth.index == width) {
|
if (1 << bitWidth.index == width) {
|
||||||
return bitWidth;
|
return bitWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw StateError(
|
throw StateError(
|
||||||
'Element is of unknown. Size: $size at index: $index. This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new');
|
'Element is of unknown. Size: $size at index: $index. This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<int> asU8List(BitWidth width) {
|
List<int> asU8List(BitWidth width) {
|
||||||
@@ -619,7 +650,8 @@ class _StackValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
throw StateError(
|
throw StateError(
|
||||||
'Unexpected type: $_type. This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new');
|
'Unexpected type: $_type. This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueType get type {
|
ValueType get type {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'types.dart';
|
import 'types.dart';
|
||||||
|
|
||||||
/// Main class to read a value out of a FlexBuffer.
|
/// Main class to read a value out of a FlexBuffer.
|
||||||
@@ -16,10 +17,15 @@ class Reference {
|
|||||||
int? _length;
|
int? _length;
|
||||||
|
|
||||||
Reference._(
|
Reference._(
|
||||||
this._buffer, this._offset, this._parentWidth, int packedType, this._path,
|
this._buffer,
|
||||||
[int? byteWidth, ValueType? valueType])
|
this._offset,
|
||||||
: _byteWidth = byteWidth ?? 1 << (packedType & 3),
|
this._parentWidth,
|
||||||
_valueType = valueType ?? ValueTypeUtils.fromInt(packedType >> 2);
|
int packedType,
|
||||||
|
this._path, [
|
||||||
|
int? byteWidth,
|
||||||
|
ValueType? valueType,
|
||||||
|
]) : _byteWidth = byteWidth ?? 1 << (packedType & 3),
|
||||||
|
_valueType = valueType ?? ValueTypeUtils.fromInt(packedType >> 2);
|
||||||
|
|
||||||
/// Use this method to access the root value of a FlexBuffer.
|
/// Use this method to access the root value of a FlexBuffer.
|
||||||
static Reference fromBuffer(ByteBuffer buffer) {
|
static Reference fromBuffer(ByteBuffer buffer) {
|
||||||
@@ -31,8 +37,13 @@ class Reference {
|
|||||||
final byteWidth = byteData.getUint8(len - 1);
|
final byteWidth = byteData.getUint8(len - 1);
|
||||||
final packedType = byteData.getUint8(len - 2);
|
final packedType = byteData.getUint8(len - 2);
|
||||||
final offset = len - byteWidth - 2;
|
final offset = len - byteWidth - 2;
|
||||||
return Reference._(ByteData.view(buffer), offset,
|
return Reference._(
|
||||||
BitWidthUtil.fromByteWidth(byteWidth), packedType, "/");
|
ByteData.view(buffer),
|
||||||
|
offset,
|
||||||
|
BitWidthUtil.fromByteWidth(byteWidth),
|
||||||
|
packedType,
|
||||||
|
"/",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if the underlying value is null.
|
/// Returns true if the underlying value is null.
|
||||||
@@ -138,7 +149,8 @@ class Reference {
|
|||||||
final index = key;
|
final index = key;
|
||||||
if (index >= length || index < 0) {
|
if (index >= length || index < 0) {
|
||||||
throw ArgumentError(
|
throw ArgumentError(
|
||||||
'Key: [$key] is not applicable on: $_path of: $_valueType length: $length');
|
'Key: [$key] is not applicable on: $_path of: $_valueType length: $length',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
final elementOffset = _indirect + index * _byteWidth;
|
final elementOffset = _indirect + index * _byteWidth;
|
||||||
int packedType = 0;
|
int packedType = 0;
|
||||||
@@ -154,13 +166,14 @@ class Reference {
|
|||||||
packedType = _buffer.getUint8(_indirect + length * _byteWidth + index);
|
packedType = _buffer.getUint8(_indirect + length * _byteWidth + index);
|
||||||
}
|
}
|
||||||
return Reference._(
|
return Reference._(
|
||||||
_buffer,
|
_buffer,
|
||||||
elementOffset,
|
elementOffset,
|
||||||
BitWidthUtil.fromByteWidth(_byteWidth),
|
BitWidthUtil.fromByteWidth(_byteWidth),
|
||||||
packedType,
|
packedType,
|
||||||
"$_path[$index]",
|
"$_path[$index]",
|
||||||
byteWidth,
|
byteWidth,
|
||||||
valueType);
|
valueType,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (key is String && _valueType == ValueType.Map) {
|
if (key is String && _valueType == ValueType.Map) {
|
||||||
final index = _keyIndex(key);
|
final index = _keyIndex(key);
|
||||||
@@ -169,7 +182,8 @@ class Reference {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw ArgumentError(
|
throw ArgumentError(
|
||||||
'Key: [$key] is not applicable on: $_path of: $_valueType');
|
'Key: [$key] is not applicable on: $_path of: $_valueType',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get an iterable if the underlying flexBuffer value is a vector.
|
/// Get an iterable if the underlying flexBuffer value is a vector.
|
||||||
@@ -199,7 +213,7 @@ class Reference {
|
|||||||
return _MapValueIterator(this);
|
return _MapValueIterator(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the length of the the underlying FlexBuffer value.
|
/// Returns the length of the underlying FlexBuffer value.
|
||||||
/// If the underlying value is [null] the length is 0.
|
/// If the underlying value is [null] the length is 0.
|
||||||
/// If the underlying value is a number, or a bool, the length is 1.
|
/// If the underlying value is a number, or a bool, the length is 1.
|
||||||
/// If the underlying value is a vector, or map, the length reflects number of elements / element pairs.
|
/// If the underlying value is a vector, or map, the length reflects number of elements / element pairs.
|
||||||
@@ -213,18 +227,24 @@ class Reference {
|
|||||||
ValueTypeUtils.isAVector(_valueType) ||
|
ValueTypeUtils.isAVector(_valueType) ||
|
||||||
_valueType == ValueType.Map) {
|
_valueType == ValueType.Map) {
|
||||||
_length = _readUInt(
|
_length = _readUInt(
|
||||||
_indirect - _byteWidth, BitWidthUtil.fromByteWidth(_byteWidth));
|
_indirect - _byteWidth,
|
||||||
|
BitWidthUtil.fromByteWidth(_byteWidth),
|
||||||
|
);
|
||||||
} else if (_valueType == ValueType.Null) {
|
} else if (_valueType == ValueType.Null) {
|
||||||
_length = 0;
|
_length = 0;
|
||||||
} else if (_valueType == ValueType.String) {
|
} else if (_valueType == ValueType.String) {
|
||||||
final indirect = _indirect;
|
final indirect = _indirect;
|
||||||
var sizeByteWidth = _byteWidth;
|
var sizeByteWidth = _byteWidth;
|
||||||
var size = _readUInt(indirect - sizeByteWidth,
|
var size = _readUInt(
|
||||||
BitWidthUtil.fromByteWidth(sizeByteWidth));
|
indirect - sizeByteWidth,
|
||||||
|
BitWidthUtil.fromByteWidth(sizeByteWidth),
|
||||||
|
);
|
||||||
while (_buffer.getInt8(indirect + size) != 0) {
|
while (_buffer.getInt8(indirect + size) != 0) {
|
||||||
sizeByteWidth <<= 1;
|
sizeByteWidth <<= 1;
|
||||||
size = _readUInt(indirect - sizeByteWidth,
|
size = _readUInt(
|
||||||
BitWidthUtil.fromByteWidth(sizeByteWidth));
|
indirect - sizeByteWidth,
|
||||||
|
BitWidthUtil.fromByteWidth(sizeByteWidth),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
_length = size;
|
_length = size;
|
||||||
} else if (_valueType == ValueType.Key) {
|
} else if (_valueType == ValueType.Key) {
|
||||||
@@ -289,7 +309,8 @@ class Reference {
|
|||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
throw UnsupportedError(
|
throw UnsupportedError(
|
||||||
'Type: $_valueType is not supported for JSON conversion');
|
'Type: $_valueType is not supported for JSON conversion',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes the indirect offset of the value.
|
/// Computes the indirect offset of the value.
|
||||||
@@ -354,10 +375,13 @@ class Reference {
|
|||||||
int? _keyIndex(String key) {
|
int? _keyIndex(String key) {
|
||||||
final input = utf8.encode(key);
|
final input = utf8.encode(key);
|
||||||
final keysVectorOffset = _indirect - _byteWidth * 3;
|
final keysVectorOffset = _indirect - _byteWidth * 3;
|
||||||
final indirectOffset = keysVectorOffset -
|
final indirectOffset =
|
||||||
|
keysVectorOffset -
|
||||||
_readUInt(keysVectorOffset, BitWidthUtil.fromByteWidth(_byteWidth));
|
_readUInt(keysVectorOffset, BitWidthUtil.fromByteWidth(_byteWidth));
|
||||||
final byteWidth = _readUInt(
|
final byteWidth = _readUInt(
|
||||||
keysVectorOffset + _byteWidth, BitWidthUtil.fromByteWidth(_byteWidth));
|
keysVectorOffset + _byteWidth,
|
||||||
|
BitWidthUtil.fromByteWidth(_byteWidth),
|
||||||
|
);
|
||||||
var low = 0;
|
var low = 0;
|
||||||
var high = length - 1;
|
var high = length - 1;
|
||||||
while (low <= high) {
|
while (low <= high) {
|
||||||
@@ -390,24 +414,37 @@ class Reference {
|
|||||||
final indirect = _indirect;
|
final indirect = _indirect;
|
||||||
final elementOffset = indirect + index * _byteWidth;
|
final elementOffset = indirect + index * _byteWidth;
|
||||||
final packedType = _buffer.getUint8(indirect + length * _byteWidth + index);
|
final packedType = _buffer.getUint8(indirect + length * _byteWidth + index);
|
||||||
return Reference._(_buffer, elementOffset,
|
return Reference._(
|
||||||
BitWidthUtil.fromByteWidth(_byteWidth), packedType, "$_path/$key");
|
_buffer,
|
||||||
|
elementOffset,
|
||||||
|
BitWidthUtil.fromByteWidth(_byteWidth),
|
||||||
|
packedType,
|
||||||
|
"$_path/$key",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference _valueForIndex(int index) {
|
Reference _valueForIndex(int index) {
|
||||||
final indirect = _indirect;
|
final indirect = _indirect;
|
||||||
final elementOffset = indirect + index * _byteWidth;
|
final elementOffset = indirect + index * _byteWidth;
|
||||||
final packedType = _buffer.getUint8(indirect + length * _byteWidth + index);
|
final packedType = _buffer.getUint8(indirect + length * _byteWidth + index);
|
||||||
return Reference._(_buffer, elementOffset,
|
return Reference._(
|
||||||
BitWidthUtil.fromByteWidth(_byteWidth), packedType, "$_path/[$index]");
|
_buffer,
|
||||||
|
elementOffset,
|
||||||
|
BitWidthUtil.fromByteWidth(_byteWidth),
|
||||||
|
packedType,
|
||||||
|
"$_path/[$index]",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String _keyForIndex(int index) {
|
String _keyForIndex(int index) {
|
||||||
final keysVectorOffset = _indirect - _byteWidth * 3;
|
final keysVectorOffset = _indirect - _byteWidth * 3;
|
||||||
final indirectOffset = keysVectorOffset -
|
final indirectOffset =
|
||||||
|
keysVectorOffset -
|
||||||
_readUInt(keysVectorOffset, BitWidthUtil.fromByteWidth(_byteWidth));
|
_readUInt(keysVectorOffset, BitWidthUtil.fromByteWidth(_byteWidth));
|
||||||
final byteWidth = _readUInt(
|
final byteWidth = _readUInt(
|
||||||
keysVectorOffset + _byteWidth, BitWidthUtil.fromByteWidth(_byteWidth));
|
keysVectorOffset + _byteWidth,
|
||||||
|
BitWidthUtil.fromByteWidth(_byteWidth),
|
||||||
|
);
|
||||||
final keyOffset = indirectOffset + index * byteWidth;
|
final keyOffset = indirectOffset + index * byteWidth;
|
||||||
final keyIndirectOffset =
|
final keyIndirectOffset =
|
||||||
keyOffset - _readUInt(keyOffset, BitWidthUtil.fromByteWidth(byteWidth));
|
keyOffset - _readUInt(keyOffset, BitWidthUtil.fromByteWidth(byteWidth));
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class BitWidthUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static BitWidth width(num value) {
|
static BitWidth width(num value) {
|
||||||
if (value.toInt() == value) {
|
if (value is int) {
|
||||||
var v = value.toInt().abs();
|
var v = value.toInt().abs();
|
||||||
if (v >> 7 == 0) return BitWidth.width8;
|
if (v >> 7 == 0) return BitWidth.width8;
|
||||||
if (v >> 15 == 0) return BitWidth.width16;
|
if (v >> 15 == 0) return BitWidth.width16;
|
||||||
@@ -86,7 +86,8 @@ enum ValueType {
|
|||||||
VectorFloat,
|
VectorFloat,
|
||||||
VectorKey,
|
VectorKey,
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
'VectorString is deprecated due to a flaw in the binary format (https://github.com/google/flatbuffers/issues/5627)')
|
'VectorString is deprecated due to a flaw in the binary format (https://github.com/google/flatbuffers/issues/5627)',
|
||||||
|
)
|
||||||
VectorString,
|
VectorString,
|
||||||
VectorInt2,
|
VectorInt2,
|
||||||
VectorUInt2,
|
VectorUInt2,
|
||||||
@@ -99,7 +100,7 @@ enum ValueType {
|
|||||||
VectorFloat4,
|
VectorFloat4,
|
||||||
Blob,
|
Blob,
|
||||||
Bool,
|
Bool,
|
||||||
VectorBool
|
VectorBool,
|
||||||
}
|
}
|
||||||
|
|
||||||
class ValueTypeUtils {
|
class ValueTypeUtils {
|
||||||
@@ -153,31 +154,37 @@ class ValueTypeUtils {
|
|||||||
static ValueType toTypedVector(ValueType self, int length) {
|
static ValueType toTypedVector(ValueType self, int length) {
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
return ValueTypeUtils.fromInt(
|
return ValueTypeUtils.fromInt(
|
||||||
toInt(self) - toInt(ValueType.Int) + toInt(ValueType.VectorInt));
|
toInt(self) - toInt(ValueType.Int) + toInt(ValueType.VectorInt),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (length == 2) {
|
if (length == 2) {
|
||||||
return ValueTypeUtils.fromInt(
|
return ValueTypeUtils.fromInt(
|
||||||
toInt(self) - toInt(ValueType.Int) + toInt(ValueType.VectorInt2));
|
toInt(self) - toInt(ValueType.Int) + toInt(ValueType.VectorInt2),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (length == 3) {
|
if (length == 3) {
|
||||||
return ValueTypeUtils.fromInt(
|
return ValueTypeUtils.fromInt(
|
||||||
toInt(self) - toInt(ValueType.Int) + toInt(ValueType.VectorInt3));
|
toInt(self) - toInt(ValueType.Int) + toInt(ValueType.VectorInt3),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (length == 4) {
|
if (length == 4) {
|
||||||
return ValueTypeUtils.fromInt(
|
return ValueTypeUtils.fromInt(
|
||||||
toInt(self) - toInt(ValueType.Int) + toInt(ValueType.VectorInt4));
|
toInt(self) - toInt(ValueType.Int) + toInt(ValueType.VectorInt4),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
throw Exception('unexpected length ' + length.toString());
|
throw Exception('unexpected length ' + length.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
static ValueType typedVectorElementType(ValueType self) {
|
static ValueType typedVectorElementType(ValueType self) {
|
||||||
return ValueTypeUtils.fromInt(
|
return ValueTypeUtils.fromInt(
|
||||||
toInt(self) - toInt(ValueType.VectorInt) + toInt(ValueType.Int));
|
toInt(self) - toInt(ValueType.VectorInt) + toInt(ValueType.Int),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ValueType fixedTypedVectorElementType(ValueType self) {
|
static ValueType fixedTypedVectorElementType(ValueType self) {
|
||||||
return ValueTypeUtils.fromInt(
|
return ValueTypeUtils.fromInt(
|
||||||
(toInt(self) - toInt(ValueType.VectorInt2)) % 3 + toInt(ValueType.Int));
|
(toInt(self) - toInt(ValueType.VectorInt2)) % 3 + toInt(ValueType.Int),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fixedTypedVectorElementSize(ValueType self) {
|
static int fixedTypedVectorElementSize(ValueType self) {
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
name: flat_buffers
|
name: flat_buffers
|
||||||
version: 2.0.0
|
version: 25.12.19
|
||||||
description: FlatBuffers reading and writing library for Dart. Based on original work by Konstantin Scheglov and Paul Berry of the Dart SDK team.
|
description: FlatBuffers reading and writing library for Dart. Based on original work by Konstantin Scheglov and Paul Berry of the Dart SDK team.
|
||||||
homepage: https://github.com/google/flatbuffers
|
homepage: https://github.com/google/flatbuffers
|
||||||
documentation: https://google.github.io/flatbuffers/index.html
|
documentation: https://google.github.io/flatbuffers/index.html
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.12.0 <3.0.0'
|
sdk: '>=2.17.0 <4.0.0'
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
test: ^1.17.7
|
test: ^1.17.7
|
||||||
test_reflective_loader: ^0.2.0
|
test_reflective_loader: ^0.2.0
|
||||||
path: ^1.8.0
|
path: ^1.8.0
|
||||||
lints: ^1.0.1
|
lints: ^1.0.1
|
||||||
|
|
||||||
|
|||||||
10
dart/test/bool_structs.fbs
Normal file
10
dart/test/bool_structs.fbs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
// Test for #7355
|
||||||
|
table Foo {
|
||||||
|
my_foo : foo_properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct foo_properties
|
||||||
|
{
|
||||||
|
a : bool;
|
||||||
|
b : bool;
|
||||||
|
}
|
||||||
195
dart/test/bool_structs_generated.dart
Normal file
195
dart/test/bool_structs_generated.dart
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names
|
||||||
|
|
||||||
|
import 'dart:typed_data' show Uint8List;
|
||||||
|
|
||||||
|
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||||
|
|
||||||
|
class Foo {
|
||||||
|
Foo._(this._bc, this._bcOffset);
|
||||||
|
factory Foo(List<int> bytes) {
|
||||||
|
final rootRef = fb.BufferContext.fromBytes(bytes);
|
||||||
|
return reader.read(rootRef, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const fb.Reader<Foo> reader = _FooReader();
|
||||||
|
|
||||||
|
final fb.BufferContext _bc;
|
||||||
|
final int _bcOffset;
|
||||||
|
|
||||||
|
FooProperties? get myFoo =>
|
||||||
|
FooProperties.reader.vTableGetNullable(_bc, _bcOffset, 4);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'Foo{myFoo: ${myFoo}}';
|
||||||
|
}
|
||||||
|
|
||||||
|
FooT unpack() => FooT(myFoo: myFoo?.unpack());
|
||||||
|
|
||||||
|
static int pack(fb.Builder fbBuilder, FooT? object) {
|
||||||
|
if (object == null) return 0;
|
||||||
|
return object.pack(fbBuilder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FooT implements fb.Packable {
|
||||||
|
FooPropertiesT? myFoo;
|
||||||
|
|
||||||
|
FooT({this.myFoo});
|
||||||
|
|
||||||
|
@override
|
||||||
|
int pack(fb.Builder fbBuilder) {
|
||||||
|
fbBuilder.startTable(1);
|
||||||
|
if (myFoo != null) {
|
||||||
|
fbBuilder.addStruct(0, myFoo!.pack(fbBuilder));
|
||||||
|
}
|
||||||
|
return fbBuilder.endTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'FooT{myFoo: ${myFoo}}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FooReader extends fb.TableReader<Foo> {
|
||||||
|
const _FooReader();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Foo createObject(fb.BufferContext bc, int offset) => Foo._(bc, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
class FooBuilder {
|
||||||
|
FooBuilder(this.fbBuilder);
|
||||||
|
|
||||||
|
final fb.Builder fbBuilder;
|
||||||
|
|
||||||
|
void begin() {
|
||||||
|
fbBuilder.startTable(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int addMyFoo(int offset) {
|
||||||
|
fbBuilder.addStruct(0, offset);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
int finish() {
|
||||||
|
return fbBuilder.endTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FooObjectBuilder extends fb.ObjectBuilder {
|
||||||
|
final FooPropertiesObjectBuilder? _myFoo;
|
||||||
|
|
||||||
|
FooObjectBuilder({FooPropertiesObjectBuilder? myFoo}) : _myFoo = myFoo;
|
||||||
|
|
||||||
|
/// Finish building, and store into the [fbBuilder].
|
||||||
|
@override
|
||||||
|
int finish(fb.Builder fbBuilder) {
|
||||||
|
fbBuilder.startTable(1);
|
||||||
|
if (_myFoo != null) {
|
||||||
|
fbBuilder.addStruct(0, _myFoo!.finish(fbBuilder));
|
||||||
|
}
|
||||||
|
return fbBuilder.endTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convenience method to serialize to byte list.
|
||||||
|
@override
|
||||||
|
Uint8List toBytes([String? fileIdentifier]) {
|
||||||
|
final fbBuilder = fb.Builder(deduplicateTables: false);
|
||||||
|
fbBuilder.finish(finish(fbBuilder), fileIdentifier);
|
||||||
|
return fbBuilder.buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FooProperties {
|
||||||
|
FooProperties._(this._bc, this._bcOffset);
|
||||||
|
|
||||||
|
static const fb.Reader<FooProperties> reader = _FooPropertiesReader();
|
||||||
|
|
||||||
|
final fb.BufferContext _bc;
|
||||||
|
final int _bcOffset;
|
||||||
|
|
||||||
|
bool get a => const fb.BoolReader().read(_bc, _bcOffset + 0);
|
||||||
|
bool get b => const fb.BoolReader().read(_bc, _bcOffset + 1);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'FooProperties{a: ${a}, b: ${b}}';
|
||||||
|
}
|
||||||
|
|
||||||
|
FooPropertiesT unpack() => FooPropertiesT(a: a, b: b);
|
||||||
|
|
||||||
|
static int pack(fb.Builder fbBuilder, FooPropertiesT? object) {
|
||||||
|
if (object == null) return 0;
|
||||||
|
return object.pack(fbBuilder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FooPropertiesT implements fb.Packable {
|
||||||
|
bool a;
|
||||||
|
bool b;
|
||||||
|
|
||||||
|
FooPropertiesT({required this.a, required this.b});
|
||||||
|
|
||||||
|
@override
|
||||||
|
int pack(fb.Builder fbBuilder) {
|
||||||
|
fbBuilder.putBool(b);
|
||||||
|
fbBuilder.putBool(a);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'FooPropertiesT{a: ${a}, b: ${b}}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FooPropertiesReader extends fb.StructReader<FooProperties> {
|
||||||
|
const _FooPropertiesReader();
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get size => 2;
|
||||||
|
|
||||||
|
@override
|
||||||
|
FooProperties createObject(fb.BufferContext bc, int offset) =>
|
||||||
|
FooProperties._(bc, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
class FooPropertiesBuilder {
|
||||||
|
FooPropertiesBuilder(this.fbBuilder);
|
||||||
|
|
||||||
|
final fb.Builder fbBuilder;
|
||||||
|
|
||||||
|
int finish(bool a, bool b) {
|
||||||
|
fbBuilder.putBool(b);
|
||||||
|
fbBuilder.putBool(a);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FooPropertiesObjectBuilder extends fb.ObjectBuilder {
|
||||||
|
final bool _a;
|
||||||
|
final bool _b;
|
||||||
|
|
||||||
|
FooPropertiesObjectBuilder({required bool a, required bool b})
|
||||||
|
: _a = a,
|
||||||
|
_b = b;
|
||||||
|
|
||||||
|
/// Finish building, and store into the [fbBuilder].
|
||||||
|
@override
|
||||||
|
int finish(fb.Builder fbBuilder) {
|
||||||
|
fbBuilder.putBool(_b);
|
||||||
|
fbBuilder.putBool(_a);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convenience method to serialize to byte list.
|
||||||
|
@override
|
||||||
|
Uint8List toBytes([String? fileIdentifier]) {
|
||||||
|
final fbBuilder = fb.Builder(deduplicateTables: false);
|
||||||
|
fbBuilder.finish(finish(fbBuilder), fileIdentifier);
|
||||||
|
return fbBuilder.buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
10
dart/test/enums.fbs
Normal file
10
dart/test/enums.fbs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
enum OptionsEnum : uint32
|
||||||
|
{
|
||||||
|
A = 1,
|
||||||
|
B = 2,
|
||||||
|
C = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
table MyTable {
|
||||||
|
options : [OptionsEnum];
|
||||||
|
}
|
||||||
153
dart/test/enums_generated.dart
Normal file
153
dart/test/enums_generated.dart
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names
|
||||||
|
|
||||||
|
import 'dart:typed_data' show Uint8List;
|
||||||
|
|
||||||
|
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||||
|
|
||||||
|
enum OptionsEnum {
|
||||||
|
A(1),
|
||||||
|
B(2),
|
||||||
|
C(3);
|
||||||
|
|
||||||
|
final int value;
|
||||||
|
const OptionsEnum(this.value);
|
||||||
|
|
||||||
|
factory OptionsEnum.fromValue(int value) {
|
||||||
|
switch (value) {
|
||||||
|
case 1:
|
||||||
|
return OptionsEnum.A;
|
||||||
|
case 2:
|
||||||
|
return OptionsEnum.B;
|
||||||
|
case 3:
|
||||||
|
return OptionsEnum.C;
|
||||||
|
default:
|
||||||
|
throw StateError('Invalid value $value for bit flag enum');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static OptionsEnum? _createOrNull(int? value) =>
|
||||||
|
value == null ? null : OptionsEnum.fromValue(value);
|
||||||
|
|
||||||
|
static const int minValue = 1;
|
||||||
|
static const int maxValue = 3;
|
||||||
|
static const fb.Reader<OptionsEnum> reader = _OptionsEnumReader();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OptionsEnumReader extends fb.Reader<OptionsEnum> {
|
||||||
|
const _OptionsEnumReader();
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get size => 4;
|
||||||
|
|
||||||
|
@override
|
||||||
|
OptionsEnum read(fb.BufferContext bc, int offset) =>
|
||||||
|
OptionsEnum.fromValue(const fb.Uint32Reader().read(bc, offset));
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyTable {
|
||||||
|
MyTable._(this._bc, this._bcOffset);
|
||||||
|
factory MyTable(List<int> bytes) {
|
||||||
|
final rootRef = fb.BufferContext.fromBytes(bytes);
|
||||||
|
return reader.read(rootRef, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const fb.Reader<MyTable> reader = _MyTableReader();
|
||||||
|
|
||||||
|
final fb.BufferContext _bc;
|
||||||
|
final int _bcOffset;
|
||||||
|
|
||||||
|
List<OptionsEnum>? get options => const fb.ListReader<OptionsEnum>(
|
||||||
|
OptionsEnum.reader,
|
||||||
|
).vTableGetNullable(_bc, _bcOffset, 4);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'MyTable{options: ${options}}';
|
||||||
|
}
|
||||||
|
|
||||||
|
MyTableT unpack() => MyTableT(
|
||||||
|
options: const fb.ListReader<OptionsEnum>(
|
||||||
|
OptionsEnum.reader,
|
||||||
|
lazy: false,
|
||||||
|
).vTableGetNullable(_bc, _bcOffset, 4),
|
||||||
|
);
|
||||||
|
|
||||||
|
static int pack(fb.Builder fbBuilder, MyTableT? object) {
|
||||||
|
if (object == null) return 0;
|
||||||
|
return object.pack(fbBuilder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyTableT implements fb.Packable {
|
||||||
|
List<OptionsEnum>? options;
|
||||||
|
|
||||||
|
MyTableT({this.options});
|
||||||
|
|
||||||
|
@override
|
||||||
|
int pack(fb.Builder fbBuilder) {
|
||||||
|
final int? optionsOffset = options == null
|
||||||
|
? null
|
||||||
|
: fbBuilder.writeListUint32(options!.map((f) => f.value).toList());
|
||||||
|
fbBuilder.startTable(1);
|
||||||
|
fbBuilder.addOffset(0, optionsOffset);
|
||||||
|
return fbBuilder.endTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'MyTableT{options: ${options}}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MyTableReader extends fb.TableReader<MyTable> {
|
||||||
|
const _MyTableReader();
|
||||||
|
|
||||||
|
@override
|
||||||
|
MyTable createObject(fb.BufferContext bc, int offset) =>
|
||||||
|
MyTable._(bc, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyTableBuilder {
|
||||||
|
MyTableBuilder(this.fbBuilder);
|
||||||
|
|
||||||
|
final fb.Builder fbBuilder;
|
||||||
|
|
||||||
|
void begin() {
|
||||||
|
fbBuilder.startTable(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int addOptionsOffset(int? offset) {
|
||||||
|
fbBuilder.addOffset(0, offset);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
int finish() {
|
||||||
|
return fbBuilder.endTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyTableObjectBuilder extends fb.ObjectBuilder {
|
||||||
|
final List<OptionsEnum>? _options;
|
||||||
|
|
||||||
|
MyTableObjectBuilder({List<OptionsEnum>? options}) : _options = options;
|
||||||
|
|
||||||
|
/// Finish building, and store into the [fbBuilder].
|
||||||
|
@override
|
||||||
|
int finish(fb.Builder fbBuilder) {
|
||||||
|
final int? optionsOffset = _options == null
|
||||||
|
? null
|
||||||
|
: fbBuilder.writeListUint32(_options!.map((f) => f.value).toList());
|
||||||
|
fbBuilder.startTable(1);
|
||||||
|
fbBuilder.addOffset(0, optionsOffset);
|
||||||
|
return fbBuilder.endTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convenience method to serialize to byte list.
|
||||||
|
@override
|
||||||
|
Uint8List toBytes([String? fileIdentifier]) {
|
||||||
|
final fbBuilder = fb.Builder(deduplicateTables: false);
|
||||||
|
fbBuilder.finish(finish(fbBuilder), fileIdentifier);
|
||||||
|
return fbBuilder.buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,18 +1,15 @@
|
|||||||
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
|
||||||
// for details. All rights reserved. Use of this source code is governed by a
|
|
||||||
// BSD-style license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
import 'dart:typed_data';
|
|
||||||
import 'dart:io' as io;
|
import 'dart:io' as io;
|
||||||
|
import 'dart:typed_data';
|
||||||
import 'package:path/path.dart' as path;
|
|
||||||
|
|
||||||
import 'package:flat_buffers/flat_buffers.dart';
|
import 'package:flat_buffers/flat_buffers.dart';
|
||||||
|
import 'package:path/path.dart' as path;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
import './monster_test_my_game.example_generated.dart' as example;
|
import './bool_structs_generated.dart' as example4;
|
||||||
import './monster_test_my_game.example2_generated.dart' as example2;
|
import './monster_test_my_game.example2_generated.dart' as example2;
|
||||||
|
import './monster_test_my_game.example_generated.dart' as example;
|
||||||
|
import 'enums_generated.dart' as example3;
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
@@ -20,6 +17,7 @@ main() {
|
|||||||
defineReflectiveTests(ObjectAPITest);
|
defineReflectiveTests(ObjectAPITest);
|
||||||
defineReflectiveTests(CheckOtherLangaugesData);
|
defineReflectiveTests(CheckOtherLangaugesData);
|
||||||
defineReflectiveTests(GeneratorTest);
|
defineReflectiveTests(GeneratorTest);
|
||||||
|
defineReflectiveTests(ListOfEnumsTest);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,11 +28,9 @@ int indexToField(int index) {
|
|||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class CheckOtherLangaugesData {
|
class CheckOtherLangaugesData {
|
||||||
test_cppData() async {
|
test_cppData() async {
|
||||||
List<int> data = await io.File(path.join(
|
List<int> data = await io.File(
|
||||||
path.context.current,
|
path.join(path.context.current, 'test', 'monsterdata_test.mon'),
|
||||||
'test',
|
).readAsBytes();
|
||||||
'monsterdata_test.mon',
|
|
||||||
)).readAsBytes();
|
|
||||||
example.Monster mon = example.Monster(data);
|
example.Monster mon = example.Monster(data);
|
||||||
expect(mon.hp, 80);
|
expect(mon.hp, 80);
|
||||||
expect(mon.mana, 150);
|
expect(mon.mana, 150);
|
||||||
@@ -64,11 +60,11 @@ class CheckOtherLangaugesData {
|
|||||||
expect(
|
expect(
|
||||||
mon.toString(),
|
mon.toString(),
|
||||||
'Monster{'
|
'Monster{'
|
||||||
'pos: Vec3{x: 1.0, y: 2.0, z: 3.0, test1: 3.0, test2: Color{value: 2}, test3: Test{a: 5, b: 6}}, '
|
'pos: Vec3{x: 1.0, y: 2.0, z: 3.0, test1: 3.0, test2: Color.Green, test3: Test{a: 5, b: 6}}, '
|
||||||
'mana: 150, hp: 80, name: MyMonster, inventory: [0, 1, 2, 3, 4], '
|
'mana: 150, hp: 80, name: MyMonster, inventory: [0, 1, 2, 3, 4], '
|
||||||
'color: Color{value: 8}, testType: AnyTypeId{value: 1}, '
|
'color: Color.Blue, testType: AnyTypeId.Monster, '
|
||||||
'test: Monster{pos: null, mana: 150, hp: 100, name: Fred, '
|
'test: Monster{pos: null, mana: 150, hp: 100, name: Fred, '
|
||||||
'inventory: null, color: Color{value: 8}, testType: null, '
|
'inventory: null, color: Color.Blue, testType: null, '
|
||||||
'test: null, test4: null, testarrayofstring: null, '
|
'test: null, test4: null, testarrayofstring: null, '
|
||||||
'testarrayoftables: null, enemy: null, testnestedflatbuffer: null, '
|
'testarrayoftables: null, enemy: null, testnestedflatbuffer: null, '
|
||||||
'testempty: null, testbool: false, testhashs32Fnv1: 0, '
|
'testempty: null, testbool: false, testhashs32Fnv1: 0, '
|
||||||
@@ -83,12 +79,18 @@ class CheckOtherLangaugesData {
|
|||||||
'coOwningReference: 0, vectorOfCoOwningReferences: null, '
|
'coOwningReference: 0, vectorOfCoOwningReferences: null, '
|
||||||
'nonOwningReference: 0, vectorOfNonOwningReferences: null, '
|
'nonOwningReference: 0, vectorOfNonOwningReferences: null, '
|
||||||
'anyUniqueType: null, anyUnique: null, anyAmbiguousType: null, '
|
'anyUniqueType: null, anyUnique: null, anyAmbiguousType: null, '
|
||||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race.None, '
|
||||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: null}, '
|
'testrequirednestedflatbuffer: null, scalarKeySortedTables: null, '
|
||||||
|
'nativeInline: null, '
|
||||||
|
'longEnumNonEnumDefault: LongEnum._default, '
|
||||||
|
'longEnumNormalDefault: LongEnum.LongOne, nanDefault: NaN, '
|
||||||
|
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||||
|
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||||
|
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}, '
|
||||||
'test4: [Test{a: 10, b: 20}, Test{a: 30, b: 40}], '
|
'test4: [Test{a: 10, b: 20}, Test{a: 30, b: 40}], '
|
||||||
'testarrayofstring: [test1, test2], testarrayoftables: null, '
|
'testarrayofstring: [test1, test2], testarrayoftables: null, '
|
||||||
'enemy: Monster{pos: null, mana: 150, hp: 100, name: Fred, '
|
'enemy: Monster{pos: null, mana: 150, hp: 100, name: Fred, '
|
||||||
'inventory: null, color: Color{value: 8}, testType: null, '
|
'inventory: null, color: Color.Blue, testType: null, '
|
||||||
'test: null, test4: null, testarrayofstring: null, '
|
'test: null, test4: null, testarrayofstring: null, '
|
||||||
'testarrayoftables: null, enemy: null, testnestedflatbuffer: null, '
|
'testarrayoftables: null, enemy: null, testnestedflatbuffer: null, '
|
||||||
'testempty: null, testbool: false, testhashs32Fnv1: 0, '
|
'testempty: null, testbool: false, testhashs32Fnv1: 0, '
|
||||||
@@ -103,8 +105,14 @@ class CheckOtherLangaugesData {
|
|||||||
'coOwningReference: 0, vectorOfCoOwningReferences: null, '
|
'coOwningReference: 0, vectorOfCoOwningReferences: null, '
|
||||||
'nonOwningReference: 0, vectorOfNonOwningReferences: null, '
|
'nonOwningReference: 0, vectorOfNonOwningReferences: null, '
|
||||||
'anyUniqueType: null, anyUnique: null, anyAmbiguousType: null, '
|
'anyUniqueType: null, anyUnique: null, anyAmbiguousType: null, '
|
||||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race.None, '
|
||||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: null}, '
|
'testrequirednestedflatbuffer: null, scalarKeySortedTables: null, '
|
||||||
|
'nativeInline: null, '
|
||||||
|
'longEnumNonEnumDefault: LongEnum._default, '
|
||||||
|
'longEnumNormalDefault: LongEnum.LongOne, nanDefault: NaN, '
|
||||||
|
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||||
|
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||||
|
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}, '
|
||||||
'testnestedflatbuffer: null, testempty: null, testbool: true, '
|
'testnestedflatbuffer: null, testempty: null, testbool: true, '
|
||||||
'testhashs32Fnv1: -579221183, testhashu32Fnv1: 3715746113, '
|
'testhashs32Fnv1: -579221183, testhashu32Fnv1: 3715746113, '
|
||||||
'testhashs64Fnv1: 7930699090847568257, '
|
'testhashs64Fnv1: 7930699090847568257, '
|
||||||
@@ -126,9 +134,15 @@ class CheckOtherLangaugesData {
|
|||||||
'vectorOfNonOwningReferences: null, '
|
'vectorOfNonOwningReferences: null, '
|
||||||
'anyUniqueType: null, anyUnique: null, '
|
'anyUniqueType: null, anyUnique: null, '
|
||||||
'anyAmbiguousType: null, '
|
'anyAmbiguousType: null, '
|
||||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race.None, '
|
||||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: [Stat{id: '
|
'testrequirednestedflatbuffer: null, scalarKeySortedTables: [Stat{id: '
|
||||||
'miss, val: 0, count: 0}, Stat{id: hit, val: 10, count: 1}]}',
|
'miss, val: 0, count: 0}, Stat{id: hit, val: 10, count: 1}], '
|
||||||
|
'nativeInline: Test{a: 1, b: 2}, '
|
||||||
|
'longEnumNonEnumDefault: LongEnum._default, '
|
||||||
|
'longEnumNormalDefault: LongEnum.LongOne, nanDefault: NaN, '
|
||||||
|
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||||
|
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||||
|
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,6 +213,10 @@ class BuilderTest {
|
|||||||
..addTestarrayofstringOffset(testArrayOfString);
|
..addTestarrayofstringOffset(testArrayOfString);
|
||||||
final mon = monBuilder.finish();
|
final mon = monBuilder.finish();
|
||||||
fbBuilder.finish(mon);
|
fbBuilder.finish(mon);
|
||||||
|
|
||||||
|
final mon3 = example.Monster(fbBuilder.buffer);
|
||||||
|
expect(mon3.name, 'MyMonster');
|
||||||
|
expect(mon3.pos!.test1, 3.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_error_addInt32_withoutStartTable([Builder? builder]) {
|
void test_error_addInt32_withoutStartTable([Builder? builder]) {
|
||||||
@@ -278,20 +296,72 @@ class BuilderTest {
|
|||||||
expect(allocator.buffer(builder.size()), [2, 0, 0, 0, 0, 0, 0, 1]);
|
expect(allocator.buffer(builder.size()), [2, 0, 0, 0, 0, 0, 0, 1]);
|
||||||
|
|
||||||
builder.putUint8(3);
|
builder.putUint8(3);
|
||||||
expect(
|
expect(allocator.buffer(builder.size()), [
|
||||||
allocator.buffer(builder.size()), [0, 0, 0, 3, 2, 0, 0, 0, 0, 0, 0, 1]);
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
3,
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
]);
|
||||||
|
|
||||||
builder.putUint8(4);
|
builder.putUint8(4);
|
||||||
expect(
|
expect(allocator.buffer(builder.size()), [
|
||||||
allocator.buffer(builder.size()), [0, 0, 4, 3, 2, 0, 0, 0, 0, 0, 0, 1]);
|
0,
|
||||||
|
0,
|
||||||
|
4,
|
||||||
|
3,
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
]);
|
||||||
|
|
||||||
builder.putUint8(5);
|
builder.putUint8(5);
|
||||||
expect(
|
expect(allocator.buffer(builder.size()), [
|
||||||
allocator.buffer(builder.size()), [0, 5, 4, 3, 2, 0, 0, 0, 0, 0, 0, 1]);
|
0,
|
||||||
|
5,
|
||||||
|
4,
|
||||||
|
3,
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
]);
|
||||||
|
|
||||||
builder.putUint32(6);
|
builder.putUint32(6);
|
||||||
expect(allocator.buffer(builder.size()),
|
expect(allocator.buffer(builder.size()), [
|
||||||
[6, 0, 0, 0, 0, 5, 4, 3, 2, 0, 0, 0, 0, 0, 0, 1]);
|
6,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
5,
|
||||||
|
4,
|
||||||
|
3,
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_table_default() {
|
void test_table_default() {
|
||||||
@@ -311,14 +381,14 @@ class BuilderTest {
|
|||||||
int objectOffset = buffer.derefObject(0);
|
int objectOffset = buffer.derefObject(0);
|
||||||
// was not written, so uses the new default value
|
// was not written, so uses the new default value
|
||||||
expect(
|
expect(
|
||||||
const Int32Reader()
|
const Int32Reader().vTableGet(buffer, objectOffset, indexToField(0), 15),
|
||||||
.vTableGet(buffer, objectOffset, indexToField(0), 15),
|
15,
|
||||||
15);
|
);
|
||||||
// has the written value
|
// has the written value
|
||||||
expect(
|
expect(
|
||||||
const Int32Reader()
|
const Int32Reader().vTableGet(buffer, objectOffset, indexToField(1), 15),
|
||||||
.vTableGet(buffer, objectOffset, indexToField(1), 15),
|
20,
|
||||||
20);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_table_format([Builder? builder]) {
|
void test_table_format([Builder? builder]) {
|
||||||
@@ -350,7 +420,9 @@ class BuilderTest {
|
|||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
int offset = byteData.getUint16(vTableLoc + 4 + 2 * i, Endian.little);
|
int offset = byteData.getUint16(vTableLoc + 4 + 2 * i, Endian.little);
|
||||||
expect(
|
expect(
|
||||||
byteData.getInt32(tableDataLoc + offset, Endian.little), 10 + 10 * i);
|
byteData.getInt32(tableDataLoc + offset, Endian.little),
|
||||||
|
10 + 10 * i,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,10 +432,14 @@ class BuilderTest {
|
|||||||
List<int> byteList;
|
List<int> byteList;
|
||||||
{
|
{
|
||||||
Builder builder = Builder(initialSize: 0);
|
Builder builder = Builder(initialSize: 0);
|
||||||
int? latinStringOffset =
|
int? latinStringOffset = builder.writeString(
|
||||||
builder.writeString(latinString, asciiOptimization: true);
|
latinString,
|
||||||
int? unicodeStringOffset =
|
asciiOptimization: true,
|
||||||
builder.writeString(unicodeString, asciiOptimization: true);
|
);
|
||||||
|
int? unicodeStringOffset = builder.writeString(
|
||||||
|
unicodeString,
|
||||||
|
asciiOptimization: true,
|
||||||
|
);
|
||||||
builder.startTable(2);
|
builder.startTable(2);
|
||||||
builder.addOffset(0, latinStringOffset);
|
builder.addOffset(0, latinStringOffset);
|
||||||
builder.addOffset(1, unicodeStringOffset);
|
builder.addOffset(1, unicodeStringOffset);
|
||||||
@@ -375,13 +451,19 @@ class BuilderTest {
|
|||||||
BufferContext buf = BufferContext.fromBytes(byteList);
|
BufferContext buf = BufferContext.fromBytes(byteList);
|
||||||
int objectOffset = buf.derefObject(0);
|
int objectOffset = buf.derefObject(0);
|
||||||
expect(
|
expect(
|
||||||
const StringReader()
|
const StringReader().vTableGetNullable(
|
||||||
.vTableGetNullable(buf, objectOffset, indexToField(0)),
|
buf,
|
||||||
latinString);
|
objectOffset,
|
||||||
|
indexToField(0),
|
||||||
|
),
|
||||||
|
latinString,
|
||||||
|
);
|
||||||
expect(
|
expect(
|
||||||
const StringReader(asciiOptimization: true)
|
const StringReader(
|
||||||
.vTableGetNullable(buf, objectOffset, indexToField(1)),
|
asciiOptimization: true,
|
||||||
unicodeString);
|
).vTableGetNullable(buf, objectOffset, indexToField(1)),
|
||||||
|
unicodeString,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_table_types([Builder? builder]) {
|
void test_table_types([Builder? builder]) {
|
||||||
@@ -405,33 +487,41 @@ class BuilderTest {
|
|||||||
BufferContext buf = BufferContext.fromBytes(byteList);
|
BufferContext buf = BufferContext.fromBytes(byteList);
|
||||||
int objectOffset = buf.derefObject(0);
|
int objectOffset = buf.derefObject(0);
|
||||||
expect(
|
expect(
|
||||||
const BoolReader()
|
const BoolReader().vTableGetNullable(buf, objectOffset, indexToField(0)),
|
||||||
.vTableGetNullable(buf, objectOffset, indexToField(0)),
|
true,
|
||||||
true);
|
);
|
||||||
expect(
|
expect(
|
||||||
const Int8Reader()
|
const Int8Reader().vTableGetNullable(buf, objectOffset, indexToField(1)),
|
||||||
.vTableGetNullable(buf, objectOffset, indexToField(1)),
|
10,
|
||||||
10);
|
);
|
||||||
expect(
|
expect(
|
||||||
const Int32Reader()
|
const Int32Reader().vTableGetNullable(buf, objectOffset, indexToField(2)),
|
||||||
.vTableGetNullable(buf, objectOffset, indexToField(2)),
|
20,
|
||||||
20);
|
);
|
||||||
expect(
|
expect(
|
||||||
const StringReader()
|
const StringReader().vTableGetNullable(
|
||||||
.vTableGetNullable(buf, objectOffset, indexToField(3)),
|
buf,
|
||||||
'12345');
|
objectOffset,
|
||||||
|
indexToField(3),
|
||||||
|
),
|
||||||
|
'12345',
|
||||||
|
);
|
||||||
expect(
|
expect(
|
||||||
const Int32Reader()
|
const Int32Reader().vTableGetNullable(buf, objectOffset, indexToField(4)),
|
||||||
.vTableGetNullable(buf, objectOffset, indexToField(4)),
|
40,
|
||||||
40);
|
);
|
||||||
expect(
|
expect(
|
||||||
const Uint32Reader()
|
const Uint32Reader().vTableGetNullable(
|
||||||
.vTableGetNullable(buf, objectOffset, indexToField(5)),
|
buf,
|
||||||
0x9ABCDEF0);
|
objectOffset,
|
||||||
|
indexToField(5),
|
||||||
|
),
|
||||||
|
0x9ABCDEF0,
|
||||||
|
);
|
||||||
expect(
|
expect(
|
||||||
const Uint8Reader()
|
const Uint8Reader().vTableGetNullable(buf, objectOffset, indexToField(6)),
|
||||||
.vTableGetNullable(buf, objectOffset, indexToField(6)),
|
0x9A,
|
||||||
0x9A);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_writeList_of_Uint32() {
|
void test_writeList_of_Uint32() {
|
||||||
@@ -576,8 +666,9 @@ class BuilderTest {
|
|||||||
}
|
}
|
||||||
// read and verify
|
// read and verify
|
||||||
BufferContext buf = BufferContext.fromBytes(byteList);
|
BufferContext buf = BufferContext.fromBytes(byteList);
|
||||||
List<TestPointImpl> items =
|
List<TestPointImpl> items = const ListReader<TestPointImpl>(
|
||||||
const ListReader<TestPointImpl>(TestPointReader()).read(buf, 0);
|
TestPointReader(),
|
||||||
|
).read(buf, 0);
|
||||||
expect(items, hasLength(2));
|
expect(items, hasLength(2));
|
||||||
expect(items[0].x, 10);
|
expect(items[0].x, 10);
|
||||||
expect(items[0].y, 20);
|
expect(items[0].y, 20);
|
||||||
@@ -607,8 +698,10 @@ class BuilderTest {
|
|||||||
List<int> byteList;
|
List<int> byteList;
|
||||||
{
|
{
|
||||||
builder ??= Builder(initialSize: 0);
|
builder ??= Builder(initialSize: 0);
|
||||||
int listOffset = builder.writeList(
|
int listOffset = builder.writeList([
|
||||||
[builder.writeString('12345'), builder.writeString('ABC')]);
|
builder.writeString('12345'),
|
||||||
|
builder.writeString('ABC'),
|
||||||
|
]);
|
||||||
builder.startTable(1);
|
builder.startTable(1);
|
||||||
builder.addOffset(0, listOffset);
|
builder.addOffset(0, listOffset);
|
||||||
int offset = builder.endTable();
|
int offset = builder.endTable();
|
||||||
@@ -687,13 +780,14 @@ class BuilderTest {
|
|||||||
test_table_format,
|
test_table_format,
|
||||||
test_table_types,
|
test_table_types,
|
||||||
test_writeList_ofObjects,
|
test_writeList_ofObjects,
|
||||||
test_writeList_ofStrings_inObject
|
test_writeList_ofStrings_inObject,
|
||||||
];
|
];
|
||||||
|
|
||||||
// Execute all test cases in all permutations of their order.
|
// Execute all test cases in all permutations of their order.
|
||||||
// To do that, we generate permutations of test case indexes.
|
// To do that, we generate permutations of test case indexes.
|
||||||
final testCasesPermutations =
|
final testCasesPermutations = _permutationsOf(
|
||||||
_permutationsOf(List.generate(testCases.length, (index) => index));
|
List.generate(testCases.length, (index) => index),
|
||||||
|
);
|
||||||
expect(testCasesPermutations.length, _factorial(testCases.length));
|
expect(testCasesPermutations.length, _factorial(testCases.length));
|
||||||
|
|
||||||
for (var indexes in testCasesPermutations) {
|
for (var indexes in testCasesPermutations) {
|
||||||
@@ -751,7 +845,6 @@ class BuilderTest {
|
|||||||
class ObjectAPITest {
|
class ObjectAPITest {
|
||||||
void test_tableStat() {
|
void test_tableStat() {
|
||||||
final object1 = example.StatT(count: 3, id: "foo", val: 4);
|
final object1 = example.StatT(count: 3, id: "foo", val: 4);
|
||||||
expect(object1 is Packable, isTrue);
|
|
||||||
final fbb = Builder();
|
final fbb = Builder();
|
||||||
fbb.finish(object1.pack(fbb));
|
fbb.finish(object1.pack(fbb));
|
||||||
final object2 = example.Stat(fbb.buffer).unpack();
|
final object2 = example.Stat(fbb.buffer).unpack();
|
||||||
@@ -764,28 +857,28 @@ class ObjectAPITest {
|
|||||||
void test_tableMonster() {
|
void test_tableMonster() {
|
||||||
final monster = example.MonsterT()
|
final monster = example.MonsterT()
|
||||||
..pos = example.Vec3T(
|
..pos = example.Vec3T(
|
||||||
x: 1,
|
x: 1,
|
||||||
y: 2,
|
y: 2,
|
||||||
z: 3,
|
z: 3,
|
||||||
test1: 4.0,
|
test1: 4.0,
|
||||||
test2: example.Color.Red,
|
test2: example.Color.Red,
|
||||||
test3: example.TestT(a: 1, b: 2))
|
test3: example.TestT(a: 1, b: 2),
|
||||||
|
)
|
||||||
..mana = 2
|
..mana = 2
|
||||||
..name = 'Monstrous'
|
..name = 'Monstrous'
|
||||||
..inventory = [24, 42]
|
..inventory = [24, 42]
|
||||||
..color = example.Color.Green
|
..color = example.Color.Green
|
||||||
// TODO be smarter for unions and automatically set the `type` field?
|
|
||||||
..testType = example.AnyTypeId.MyGame_Example2_Monster
|
..testType = example.AnyTypeId.MyGame_Example2_Monster
|
||||||
..test = example2.MonsterT()
|
..test = example2.MonsterT()
|
||||||
..test4 = [example.TestT(a: 3, b: 4), example.TestT(a: 5, b: 6)]
|
..test4 = [example.TestT(a: 3, b: 4), example.TestT(a: 5, b: 6)]
|
||||||
..testarrayofstring = ["foo", "bar"]
|
..testarrayofstring = ["foo", "bar"]
|
||||||
..testarrayoftables = [example.MonsterT(name: 'Oof')]
|
..testarrayoftables = [example.MonsterT(name: 'Oof', testf: 2.75)]
|
||||||
..enemy = example.MonsterT(name: 'Enemy')
|
..enemy = example.MonsterT(name: 'Enemy', testf: 2.5)
|
||||||
..testarrayofbools = [false, true, false]
|
..testarrayofbools = [false, true, false]
|
||||||
..testf = 42.24
|
..testf = 42.25
|
||||||
..testarrayofsortedstruct = [
|
..testarrayofsortedstruct = [
|
||||||
example.AbilityT(id: 1, distance: 5),
|
example.AbilityT(id: 1, distance: 5),
|
||||||
example.AbilityT(id: 3, distance: 7)
|
example.AbilityT(id: 3, distance: 7),
|
||||||
]
|
]
|
||||||
..vectorOfLongs = [5, 6, 7]
|
..vectorOfLongs = [5, 6, 7]
|
||||||
..vectorOfDoubles = [8.9, 9.0, 10.1, 11.2]
|
..vectorOfDoubles = [8.9, 9.0, 10.1, 11.2]
|
||||||
@@ -800,16 +893,15 @@ class ObjectAPITest {
|
|||||||
fbBuilder.finish(offset);
|
fbBuilder.finish(offset);
|
||||||
final data = fbBuilder.buffer;
|
final data = fbBuilder.buffer;
|
||||||
|
|
||||||
// TODO currently broken because of struct builder issue, see #6688
|
final monster2 = example.Monster(data); // Monster (reader)
|
||||||
// final monster2 = example.Monster(data); // Monster (reader)
|
expect(
|
||||||
// expect(
|
// map Monster => MonsterT, Vec3 => Vec3T, ...
|
||||||
// // map Monster => MonsterT, Vec3 => Vec3T, ...
|
monster2.toString().replaceAllMapped(
|
||||||
// monster2.toString().replaceAllMapped(
|
RegExp('([a-zA-z0-9]+){'), (match) => match.group(1)! + 'T{'),
|
||||||
// RegExp('([a-zA-z0-9]+){'), (match) => match.group(1) + 'T{'),
|
monster.toString());
|
||||||
// monster.toString());
|
|
||||||
//
|
final monster3 = monster2.unpack(); // MonsterT
|
||||||
// final monster3 = monster2.unpack(); // MonsterT
|
expect(monster3.toString(), monster.toString());
|
||||||
// expect(monster3.toString(), monster.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_Lists() {
|
void test_Lists() {
|
||||||
@@ -848,8 +940,9 @@ class StringListWrapperImpl {
|
|||||||
|
|
||||||
StringListWrapperImpl(this.bp, this.offset);
|
StringListWrapperImpl(this.bp, this.offset);
|
||||||
|
|
||||||
List<String>? get items => const ListReader<String>(StringReader())
|
List<String>? get items => const ListReader<String>(
|
||||||
.vTableGetNullable(bp, offset, indexToField(0));
|
StringReader(),
|
||||||
|
).vTableGetNullable(bp, offset, indexToField(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
class StringListWrapperReader extends TableReader<StringListWrapperImpl> {
|
class StringListWrapperReader extends TableReader<StringListWrapperImpl> {
|
||||||
@@ -887,9 +980,45 @@ class GeneratorTest {
|
|||||||
expect(example.Color.values, same(example.Color.values));
|
expect(example.Color.values, same(example.Color.values));
|
||||||
expect(example.Race.values, same(example.Race.values));
|
expect(example.Race.values, same(example.Race.values));
|
||||||
expect(example.AnyTypeId.values, same(example.AnyTypeId.values));
|
expect(example.AnyTypeId.values, same(example.AnyTypeId.values));
|
||||||
expect(example.AnyUniqueAliasesTypeId.values,
|
expect(
|
||||||
same(example.AnyUniqueAliasesTypeId.values));
|
example.AnyUniqueAliasesTypeId.values,
|
||||||
expect(example.AnyAmbiguousAliasesTypeId.values,
|
same(example.AnyUniqueAliasesTypeId.values),
|
||||||
same(example.AnyAmbiguousAliasesTypeId.values));
|
);
|
||||||
|
expect(
|
||||||
|
example.AnyAmbiguousAliasesTypeId.values,
|
||||||
|
same(example.AnyAmbiguousAliasesTypeId.values),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// See #6869
|
||||||
|
@reflectiveTest
|
||||||
|
class ListOfEnumsTest {
|
||||||
|
void test_listOfEnums() async {
|
||||||
|
var mytable = example3.MyTableObjectBuilder(
|
||||||
|
options: [
|
||||||
|
example3.OptionsEnum.A,
|
||||||
|
example3.OptionsEnum.B,
|
||||||
|
example3.OptionsEnum.C,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
var bytes = mytable.toBytes();
|
||||||
|
var mytable_read = example3.MyTable(bytes);
|
||||||
|
expect(mytable_read.options![0].value, example3.OptionsEnum.A.value);
|
||||||
|
expect(mytable_read.options![1].value, example3.OptionsEnum.B.value);
|
||||||
|
expect(mytable_read.options![2].value, example3.OptionsEnum.C.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@reflectiveTest
|
||||||
|
class BoolInStructTest {
|
||||||
|
void test_boolInStruct() async {
|
||||||
|
var mystruct = example4.FooObjectBuilder(
|
||||||
|
myFoo: example4.FooPropertiesObjectBuilder(a: true, b: false),
|
||||||
|
);
|
||||||
|
var bytes = mystruct.toBytes();
|
||||||
|
var mystruct_read = example4.Foo(bytes);
|
||||||
|
expect(mystruct_read.myFoo!.a, true);
|
||||||
|
expect(mystruct_read.myFoo!.b, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ void main() {
|
|||||||
flx.addInt(-1025);
|
flx.addInt(-1025);
|
||||||
expect(flx.finish(), [255, 251, 5, 2]);
|
expect(flx.finish(), [255, 251, 5, 2]);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
var builder = Builder()..addDouble(1.0);
|
||||||
|
expect(builder.finish(), [0, 0, 128, 63, 14, 4]);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
var flx = Builder();
|
var flx = Builder();
|
||||||
flx.addDouble(0.1);
|
flx.addDouble(0.1);
|
||||||
@@ -58,8 +62,23 @@ void main() {
|
|||||||
{
|
{
|
||||||
var flx = Builder();
|
var flx = Builder();
|
||||||
flx.addString('hello 😱');
|
flx.addString('hello 😱');
|
||||||
expect(flx.finish(),
|
expect(flx.finish(), [
|
||||||
[10, 104, 101, 108, 108, 111, 32, 240, 159, 152, 177, 0, 11, 20, 1]);
|
10,
|
||||||
|
104,
|
||||||
|
101,
|
||||||
|
108,
|
||||||
|
108,
|
||||||
|
111,
|
||||||
|
32,
|
||||||
|
240,
|
||||||
|
159,
|
||||||
|
152,
|
||||||
|
177,
|
||||||
|
0,
|
||||||
|
11,
|
||||||
|
20,
|
||||||
|
1,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -113,7 +132,7 @@ void main() {
|
|||||||
192,
|
192,
|
||||||
16,
|
16,
|
||||||
75,
|
75,
|
||||||
1
|
1,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -173,7 +192,7 @@ void main() {
|
|||||||
7,
|
7,
|
||||||
3,
|
3,
|
||||||
60,
|
60,
|
||||||
1
|
1,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -211,7 +230,7 @@ void main() {
|
|||||||
10,
|
10,
|
||||||
6,
|
6,
|
||||||
60,
|
60,
|
||||||
1
|
1,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -296,9 +315,24 @@ void main() {
|
|||||||
104,
|
104,
|
||||||
45,
|
45,
|
||||||
43,
|
43,
|
||||||
1
|
1,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
// Default buffer is 2048 bytes, add 2300 bytes of strings that force it
|
||||||
|
// to grow.
|
||||||
|
final s1 = 'A' * 1000;
|
||||||
|
final s2 = 'B' * 800;
|
||||||
|
final s3 = 'C' * 500;
|
||||||
|
|
||||||
|
var flx = Builder()
|
||||||
|
..startVector()
|
||||||
|
..addString(s1)
|
||||||
|
..addString(s2)
|
||||||
|
..addString(s3)
|
||||||
|
..end();
|
||||||
|
expect(flx.finish().length, 2323);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('build map', () {
|
test('build map', () {
|
||||||
@@ -318,8 +352,24 @@ void main() {
|
|||||||
..addKey('')
|
..addKey('')
|
||||||
..addInt(45)
|
..addInt(45)
|
||||||
..end();
|
..end();
|
||||||
expect(
|
expect(flx.finish(), [
|
||||||
flx.finish(), [97, 0, 0, 2, 2, 5, 2, 1, 2, 45, 12, 4, 4, 4, 36, 1]);
|
97,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
5,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
45,
|
||||||
|
12,
|
||||||
|
4,
|
||||||
|
4,
|
||||||
|
4,
|
||||||
|
36,
|
||||||
|
1,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
var flx = Builder()
|
var flx = Builder()
|
||||||
@@ -363,7 +413,7 @@ void main() {
|
|||||||
36,
|
36,
|
||||||
4,
|
4,
|
||||||
40,
|
40,
|
||||||
1
|
1,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -377,133 +427,152 @@ void main() {
|
|||||||
|
|
||||||
test('build from object', () {
|
test('build from object', () {
|
||||||
expect(
|
expect(
|
||||||
Builder.buildFromObject(Uint8List.fromList([1, 2, 3]).buffer)
|
Builder.buildFromObject(
|
||||||
.asUint8List(),
|
Uint8List.fromList([1, 2, 3]).buffer,
|
||||||
[3, 1, 2, 3, 3, 100, 1]);
|
).asUint8List(),
|
||||||
|
[3, 1, 2, 3, 3, 100, 1],
|
||||||
|
);
|
||||||
expect(Builder.buildFromObject(null).asUint8List(), [0, 0, 1]);
|
expect(Builder.buildFromObject(null).asUint8List(), [0, 0, 1]);
|
||||||
expect(Builder.buildFromObject(true).asUint8List(), [1, 104, 1]);
|
expect(Builder.buildFromObject(true).asUint8List(), [1, 104, 1]);
|
||||||
expect(Builder.buildFromObject(false).asUint8List(), [0, 104, 1]);
|
expect(Builder.buildFromObject(false).asUint8List(), [0, 104, 1]);
|
||||||
expect(Builder.buildFromObject(25).asUint8List(), [25, 4, 1]);
|
expect(Builder.buildFromObject(25).asUint8List(), [25, 4, 1]);
|
||||||
expect(Builder.buildFromObject(-250).asUint8List(), [6, 255, 5, 2]);
|
expect(Builder.buildFromObject(-250).asUint8List(), [6, 255, 5, 2]);
|
||||||
|
expect(Builder.buildFromObject(-2.50).asUint8List(), [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
32,
|
||||||
|
192,
|
||||||
|
14,
|
||||||
|
4,
|
||||||
|
]);
|
||||||
|
expect(Builder.buildFromObject('Maxim').asUint8List(), [
|
||||||
|
5,
|
||||||
|
77,
|
||||||
|
97,
|
||||||
|
120,
|
||||||
|
105,
|
||||||
|
109,
|
||||||
|
0,
|
||||||
|
6,
|
||||||
|
20,
|
||||||
|
1,
|
||||||
|
]);
|
||||||
expect(
|
expect(
|
||||||
Builder.buildFromObject(-2.50).asUint8List(), [0, 0, 32, 192, 14, 4]);
|
Builder.buildFromObject([1, 3.3, 'max', true, null, false]).asUint8List(),
|
||||||
expect(Builder.buildFromObject('Maxim').asUint8List(),
|
[
|
||||||
[5, 77, 97, 120, 105, 109, 0, 6, 20, 1]);
|
3,
|
||||||
|
109,
|
||||||
|
97,
|
||||||
|
120,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
6,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
102,
|
||||||
|
102,
|
||||||
|
102,
|
||||||
|
102,
|
||||||
|
102,
|
||||||
|
102,
|
||||||
|
10,
|
||||||
|
64,
|
||||||
|
31,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
4,
|
||||||
|
15,
|
||||||
|
20,
|
||||||
|
104,
|
||||||
|
0,
|
||||||
|
104,
|
||||||
|
54,
|
||||||
|
43,
|
||||||
|
1,
|
||||||
|
],
|
||||||
|
);
|
||||||
expect(
|
expect(
|
||||||
Builder.buildFromObject([1, 3.3, 'max', true, null, false])
|
Builder.buildFromObject([
|
||||||
.asUint8List(),
|
{'something': 12},
|
||||||
[
|
{'something': 45},
|
||||||
3,
|
]).asUint8List(),
|
||||||
109,
|
[
|
||||||
97,
|
115,
|
||||||
120,
|
111,
|
||||||
0,
|
109,
|
||||||
0,
|
101,
|
||||||
0,
|
116,
|
||||||
0,
|
104,
|
||||||
6,
|
105,
|
||||||
0,
|
110,
|
||||||
0,
|
103,
|
||||||
0,
|
0,
|
||||||
0,
|
1,
|
||||||
0,
|
11,
|
||||||
0,
|
1,
|
||||||
0,
|
1,
|
||||||
1,
|
1,
|
||||||
0,
|
12,
|
||||||
0,
|
4,
|
||||||
0,
|
6,
|
||||||
0,
|
1,
|
||||||
0,
|
1,
|
||||||
0,
|
45,
|
||||||
0,
|
4,
|
||||||
102,
|
2,
|
||||||
102,
|
8,
|
||||||
102,
|
4,
|
||||||
102,
|
36,
|
||||||
102,
|
36,
|
||||||
102,
|
4,
|
||||||
10,
|
40,
|
||||||
64,
|
1,
|
||||||
31,
|
],
|
||||||
0,
|
);
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
4,
|
|
||||||
15,
|
|
||||||
20,
|
|
||||||
104,
|
|
||||||
0,
|
|
||||||
104,
|
|
||||||
54,
|
|
||||||
43,
|
|
||||||
1
|
|
||||||
]);
|
|
||||||
expect(
|
|
||||||
Builder.buildFromObject([
|
|
||||||
{'something': 12},
|
|
||||||
{'something': 45}
|
|
||||||
]).asUint8List(),
|
|
||||||
[
|
|
||||||
115,
|
|
||||||
111,
|
|
||||||
109,
|
|
||||||
101,
|
|
||||||
116,
|
|
||||||
104,
|
|
||||||
105,
|
|
||||||
110,
|
|
||||||
103,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
11,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
12,
|
|
||||||
4,
|
|
||||||
6,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
45,
|
|
||||||
4,
|
|
||||||
2,
|
|
||||||
8,
|
|
||||||
4,
|
|
||||||
36,
|
|
||||||
36,
|
|
||||||
4,
|
|
||||||
40,
|
|
||||||
1
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('add double indirectly', () {
|
test('add double indirectly', () {
|
||||||
@@ -539,7 +608,7 @@ void main() {
|
|||||||
35,
|
35,
|
||||||
8,
|
8,
|
||||||
40,
|
40,
|
||||||
1
|
1,
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -576,7 +645,7 @@ void main() {
|
|||||||
27,
|
27,
|
||||||
8,
|
8,
|
||||||
40,
|
40,
|
||||||
1
|
1,
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
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