mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-13 16:15:26 +00:00
Compare commits
1075 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf9eb67ab9 | ||
|
|
9e7e8cbe9f | ||
|
|
b72a75f87d | ||
|
|
6cfcd8628a | ||
|
|
ddb12c0192 | ||
|
|
2032b94f61 | ||
|
|
860dc803fe | ||
|
|
5b43e4bbb8 | ||
|
|
ecd76e898d | ||
|
|
f55d4388e0 | ||
|
|
e7340c390f | ||
|
|
90441c2078 | ||
|
|
cef8f928bb | ||
|
|
98b9b5a933 | ||
|
|
d07a3d2f4c | ||
|
|
640df2c1f5 | ||
|
|
60340ac529 | ||
|
|
2bd4a27550 | ||
|
|
23bb57401c | ||
|
|
dd6daa709b | ||
|
|
dd85c3b721 | ||
|
|
94cb1ff9ea | ||
|
|
3ff6cdf491 | ||
|
|
c329d6fa90 | ||
|
|
249f3b3714 | ||
|
|
2d67de3151 | ||
|
|
5cdbd02404 | ||
|
|
b2ce86ef8a | ||
|
|
8e7acae013 | ||
|
|
343bbe808e | ||
|
|
cb9ab2fe58 | ||
|
|
4cbff97c43 | ||
|
|
88abae649c | ||
|
|
a7461433c6 | ||
|
|
440a70f4a3 | ||
|
|
02e73e1ae9 | ||
|
|
f93d0f6ac1 | ||
|
|
fd51fadaac | ||
|
|
11198f10f5 | ||
|
|
3b23ff18ea | ||
|
|
4f066c39ce | ||
|
|
ca68d8b043 | ||
|
|
407fb5d537 | ||
|
|
73a648b685 | ||
|
|
eb2a81f73d | ||
|
|
3968d00568 | ||
|
|
4f10da8d99 | ||
|
|
9e82ee2527 | ||
|
|
e237f53bfc | ||
|
|
98be491e72 | ||
|
|
71628dad0d | ||
|
|
cb7b2bf87e | ||
|
|
bfa430309a | ||
|
|
1c7d91cc55 | ||
|
|
2e865f4d4e | ||
|
|
13c9c674fd | ||
|
|
034275c6e2 | ||
|
|
4e5152d886 | ||
|
|
dc61512f20 | ||
|
|
1d60824d56 | ||
|
|
f89badd30f | ||
|
|
1b9d1b0110 | ||
|
|
6e2d530d61 | ||
|
|
9bf9b18f0a | ||
|
|
537c6ec1e6 | ||
|
|
a1f14005ab | ||
|
|
0cdacdfb35 | ||
|
|
bb58442054 | ||
|
|
4567b13115 | ||
|
|
8f8fb2b367 | ||
|
|
69d761d15e | ||
|
|
4f32cbf268 | ||
|
|
0eaaf18192 | ||
|
|
957d167199 | ||
|
|
e9d9d64527 | ||
|
|
78c50e340b | ||
|
|
9d483a3f0b | ||
|
|
b650dfba49 | ||
|
|
6980818337 | ||
|
|
224f7527e3 | ||
|
|
a66a88034a | ||
|
|
e1defaae5e | ||
|
|
78fdce28c7 | ||
|
|
60e94cf083 | ||
|
|
cf47f27164 | ||
|
|
cc7f9b89f3 | ||
|
|
600f3fbcd4 | ||
|
|
76a024137f | ||
|
|
31e34faa15 | ||
|
|
4d98faa515 | ||
|
|
d8210d5a83 | ||
|
|
7d3930a2fd | ||
|
|
347dba8501 | ||
|
|
fcacb46d01 | ||
|
|
3f388ec747 | ||
|
|
38bf4cfc03 | ||
|
|
c2f40c37b2 | ||
|
|
63d51afd11 | ||
|
|
d44931656a | ||
|
|
bbfd12eb11 | ||
|
|
7c94ff6c30 | ||
|
|
4fa4d36706 | ||
|
|
46208b1e91 | ||
|
|
b99332efd7 | ||
|
|
dd288f71f3 | ||
|
|
155c55900f | ||
|
|
0eb7b3beb0 | ||
|
|
a821b15634 | ||
|
|
87704e987e | ||
|
|
cb99116aca | ||
|
|
9ad73bf5a7 | ||
|
|
dba962ebb8 | ||
|
|
60a0f35fbc | ||
|
|
58e8552da0 | ||
|
|
d56a4055da | ||
|
|
30c4948541 | ||
|
|
80d148b175 | ||
|
|
2aa0d9a54d | ||
|
|
79cd55bd3a | ||
|
|
b378b8eb69 | ||
|
|
9635d494b3 | ||
|
|
0143f4e364 | ||
|
|
e161ade68c | ||
|
|
f575b02fda | ||
|
|
5f32f94810 | ||
|
|
d6b1ce09cf | ||
|
|
f23009f04f | ||
|
|
30bae01ea3 | ||
|
|
9068b0ee63 | ||
|
|
f8a0d3889b | ||
|
|
688fc77460 | ||
|
|
dd8922878d | ||
|
|
ab54e61805 | ||
|
|
f445c1eb4a | ||
|
|
980a6d66d3 | ||
|
|
21591916af | ||
|
|
b6c3d7b899 | ||
|
|
db0fcdd906 | ||
|
|
91fe9ba93f | ||
|
|
4c3b6c247d | ||
|
|
160e8f2fdc | ||
|
|
705577de51 | ||
|
|
0fb1d44bc4 | ||
|
|
bd20a60d6a | ||
|
|
b78c4332be | ||
|
|
636b516492 | ||
|
|
560718e976 | ||
|
|
ff687ae9c1 | ||
|
|
ca417426c7 | ||
|
|
55b30827f2 | ||
|
|
efbb11e093 | ||
|
|
5c0f914f38 | ||
|
|
802639e40d | ||
|
|
ad8b1e5dbd | ||
|
|
76d31e1b5e | ||
|
|
20396a1760 | ||
|
|
a3d8391f7b | ||
|
|
241e87d143 | ||
|
|
35f0b41fed | ||
|
|
cb5422c398 | ||
|
|
4ed6fafdfa | ||
|
|
53ce80ce91 | ||
|
|
233976c821 | ||
|
|
99fe1dc80f | ||
|
|
a4f9d1bfcc | ||
|
|
a4c362a1ba | ||
|
|
7c3c027295 | ||
|
|
569492e890 | ||
|
|
d840856093 | ||
|
|
925c1d77fc | ||
|
|
c0698cc33f | ||
|
|
ea8a4296e7 | ||
|
|
f85af46262 | ||
|
|
7a43775661 | ||
|
|
062dcf7007 | ||
|
|
ebb410062b | ||
|
|
4b864fd172 | ||
|
|
7e711f80d7 | ||
|
|
bf871ffd7f | ||
|
|
a89be8739c | ||
|
|
0bffce5aef | ||
|
|
d48f08acfe | ||
|
|
43132560f9 | ||
|
|
c56fff88a2 | ||
|
|
49fed8c4f6 | ||
|
|
b1a925dfc2 | ||
|
|
33791dc7b0 | ||
|
|
873a60b0d8 | ||
|
|
4b10656f9b | ||
|
|
e317b148dc | ||
|
|
ed03faaf07 | ||
|
|
02a7807dd8 | ||
|
|
615885e889 | ||
|
|
528ccdd458 | ||
|
|
c23ba6756f | ||
|
|
10e1d1a69e | ||
|
|
660c491265 | ||
|
|
c504a45404 | ||
|
|
919c929d30 | ||
|
|
ba4a02b46a | ||
|
|
be3d0b9c64 | ||
|
|
872fad049e | ||
|
|
9e648c392b | ||
|
|
d4f65bb8a3 | ||
|
|
3c54fd964b | ||
|
|
e7578548a5 | ||
|
|
99acd0bcd7 | ||
|
|
d0321df8cf | ||
|
|
e1f48ad35a | ||
|
|
d8f49e18d7 | ||
|
|
1f5eae5d6a | ||
|
|
ea9d60bbdf | ||
|
|
c2c3a84aaf | ||
|
|
1f03becd24 | ||
|
|
c721009491 | ||
|
|
55289c55bf | ||
|
|
ed2415eb72 | ||
|
|
aaa89429d3 | ||
|
|
12e5cf0b29 | ||
|
|
75601b81cc | ||
|
|
e203882d54 | ||
|
|
b9f1103b8a | ||
|
|
fd40cc61a4 | ||
|
|
38a6623f34 | ||
|
|
27e4f43b77 | ||
|
|
42515cfd33 | ||
|
|
5d3648b88a | ||
|
|
fc3ce7d1ab | ||
|
|
4898809eca | ||
|
|
ca5aaf62d3 | ||
|
|
c80f8d18c1 | ||
|
|
0d1559bdd4 | ||
|
|
8b39a0ee53 | ||
|
|
f675f6433c | ||
|
|
118093b613 | ||
|
|
1bb2a3bd08 | ||
|
|
2361dfb66a | ||
|
|
7b50004ec9 | ||
|
|
6e185d06a7 | ||
|
|
c949229395 | ||
|
|
e1d5fda5d4 | ||
|
|
a2603ec27e | ||
|
|
5f1b1ad42c | ||
|
|
4235a25640 | ||
|
|
88cd182349 | ||
|
|
7c824ef690 | ||
|
|
6bfa107f4e | ||
|
|
0cd8daf14e | ||
|
|
79f2adc50a | ||
|
|
dcfe38c58f | ||
|
|
51d9641de6 | ||
|
|
af6c0e6839 | ||
|
|
7c3cb5caa1 | ||
|
|
8f1bebba05 | ||
|
|
cda1525f84 | ||
|
|
72b05bc865 | ||
|
|
b3e4d9169b | ||
|
|
e2eb6af3e3 | ||
|
|
b188fde27e | ||
|
|
ba5eb3b5cf | ||
|
|
8ea293b988 | ||
|
|
f19803d364 | ||
|
|
b2d69aacf4 | ||
|
|
3331805a1c | ||
|
|
ea06768ad1 | ||
|
|
741c63052d | ||
|
|
e9912e9298 | ||
|
|
7dbc8f564a | ||
|
|
a2fe49b498 | ||
|
|
7dd5cfb510 | ||
|
|
00b741e5fb | ||
|
|
bb321fbe19 | ||
|
|
7330436713 | ||
|
|
f9c64891dd | ||
|
|
b752e4a9bb | ||
|
|
3e3c770c4e | ||
|
|
5a3f18d17d | ||
|
|
10bdcefa4a | ||
|
|
9bab626cbf | ||
|
|
effb608027 | ||
|
|
a96f2bd6ca | ||
|
|
ab3b721a54 | ||
|
|
4cfe36ae8e | ||
|
|
c7a797b966 | ||
|
|
ecc07e7793 | ||
|
|
43944a0ab1 | ||
|
|
27ce09860a | ||
|
|
3a2f6d5300 | ||
|
|
06d3229dc3 | ||
|
|
348fcb5b88 | ||
|
|
b4ca4d3cde | ||
|
|
0848f58cdd | ||
|
|
8e42f44807 | ||
|
|
88912640d0 | ||
|
|
c43a0beff0 | ||
|
|
a9640bd9e1 | ||
|
|
f11ffedb2b | ||
|
|
5d42c8352e | ||
|
|
7c1203d44c | ||
|
|
a0a33d94a7 | ||
|
|
b10123ff63 | ||
|
|
3a2c535592 | ||
|
|
6621424308 | ||
|
|
d215852f52 | ||
|
|
12c4c2238c | ||
|
|
85faa46fb3 | ||
|
|
cc354ea368 | ||
|
|
bed19a5340 | ||
|
|
9bb88a026a | ||
|
|
34cb163e38 | ||
|
|
a66f9e769b | ||
|
|
86153fd740 | ||
|
|
7eb4c6098e | ||
|
|
af3c598189 | ||
|
|
eac0bc6490 | ||
|
|
20a400e940 | ||
|
|
676f0248aa | ||
|
|
34b8b80f15 | ||
|
|
0998861e0f | ||
|
|
2e3d3cbcb5 | ||
|
|
d3a00f7730 | ||
|
|
cc54963830 | ||
|
|
79f62ee353 | ||
|
|
c0a6e5120d | ||
|
|
08cf50c54a | ||
|
|
6b3f057bdc | ||
|
|
60de374486 | ||
|
|
e78825e7a0 | ||
|
|
cc158e7009 | ||
|
|
5377957b14 | ||
|
|
4bc6de9a88 | ||
|
|
3a62813f0e | ||
|
|
fb94af8899 | ||
|
|
77b458bee5 | ||
|
|
9ce98dd77d | ||
|
|
4ea1be53d4 | ||
|
|
0068b25132 | ||
|
|
ec74f58b94 | ||
|
|
48d8232584 | ||
|
|
55ddb84eb2 | ||
|
|
6e2e909b5c | ||
|
|
b24c0b07a3 | ||
|
|
59e26017cb | ||
|
|
132e6a8220 | ||
|
|
19c81b11b3 | ||
|
|
36f8564846 | ||
|
|
daf0a420be | ||
|
|
474ba68bba | ||
|
|
9de0861104 | ||
|
|
b513db86c7 | ||
|
|
6a1acdc23b | ||
|
|
c696422558 | ||
|
|
e93d2bda07 | ||
|
|
bbf4dac6a3 | ||
|
|
8df2d9a3ef | ||
|
|
462ce03ebe | ||
|
|
020012e69c | ||
|
|
f431a96523 | ||
|
|
3694ae0817 | ||
|
|
2265129e14 | ||
|
|
4bddc6cc0c | ||
|
|
e162366b3f | ||
|
|
fee9afd80b | ||
|
|
98f681deb0 | ||
|
|
5cee340ad3 | ||
|
|
f0769b60ab | ||
|
|
79b80f84df | ||
|
|
dfe68566e4 | ||
|
|
0aa36101f4 | ||
|
|
70f345012d | ||
|
|
a056402f56 | ||
|
|
d7b1d418ee | ||
|
|
9dae3eac60 | ||
|
|
99a8a68a80 | ||
|
|
0c86929e39 | ||
|
|
b24f2016a1 | ||
|
|
1d73b3b9fc | ||
|
|
a4dbe13486 | ||
|
|
89711c9c47 | ||
|
|
5d9930aa0d | ||
|
|
8518b3fb4e | ||
|
|
61f4a46c43 | ||
|
|
dd73b53e28 | ||
|
|
c1901f2c01 | ||
|
|
4071b6f68b | ||
|
|
142401f50a | ||
|
|
7799642270 | ||
|
|
67b29d4e43 | ||
|
|
85b131a719 | ||
|
|
0e8a21854c | ||
|
|
53a897731e | ||
|
|
ba08b0ec02 | ||
|
|
da0bda6be3 | ||
|
|
617bbc9b0c | ||
|
|
0c8b4c7614 | ||
|
|
34aea4361f | ||
|
|
be1ad33910 | ||
|
|
0cf04ad9d5 | ||
|
|
fe483fa380 | ||
|
|
8a8dc4e111 | ||
|
|
7e803c410c | ||
|
|
1336d26252 | ||
|
|
853f7033e0 | ||
|
|
e2c7196ea8 | ||
|
|
61fe2a4fac | ||
|
|
d233b38008 | ||
|
|
ca52bfefc0 | ||
|
|
2edb1dcdda | ||
|
|
6eb031de9a | ||
|
|
5f2af34e02 | ||
|
|
f3f113b24a | ||
|
|
6bb0a728d3 | ||
|
|
97face1527 | ||
|
|
f2627e16ac | ||
|
|
01bac38c84 | ||
|
|
a1b5f565d9 | ||
|
|
0780a7db24 | ||
|
|
9234ddcf11 | ||
|
|
6d9a226f75 | ||
|
|
b0fd1a8c66 | ||
|
|
a0e5d78353 | ||
|
|
bc8a1608a8 | ||
|
|
30e7d16104 | ||
|
|
9c3920d0ab | ||
|
|
5b4acf809e | ||
|
|
86fb05d320 | ||
|
|
5e4739184f | ||
|
|
971a68110e | ||
|
|
7a6b2bf521 | ||
|
|
03e2899985 | ||
|
|
72a99abfb7 | ||
|
|
21a8121982 | ||
|
|
28920aff8f | ||
|
|
77b22aed5a | ||
|
|
cc25516d3e | ||
|
|
1d444f63d3 | ||
|
|
5fa00630af | ||
|
|
97af3d798b | ||
|
|
bb736091f3 | ||
|
|
d5b4db0692 | ||
|
|
5808f7fb03 | ||
|
|
42611f9a83 | ||
|
|
1f0bd12851 | ||
|
|
321a1c9dc0 | ||
|
|
ac1015e3c4 | ||
|
|
513958ea72 | ||
|
|
2f2e4cced4 | ||
|
|
f779962e3e | ||
|
|
69776b9e7e | ||
|
|
00d726fc4c | ||
|
|
ad0f48d7e7 | ||
|
|
801e1b7699 | ||
|
|
432e7582c6 | ||
|
|
d76113100a | ||
|
|
dca33ddb75 | ||
|
|
76744a4345 | ||
|
|
b4e91091ec | ||
|
|
d5f5d382eb | ||
|
|
ffddbdc7ab | ||
|
|
46bb05d952 | ||
|
|
7cc72e4b11 | ||
|
|
a6a3f59253 | ||
|
|
8a58aafda1 | ||
|
|
8dc1641c8a | ||
|
|
4b27c92910 | ||
|
|
7fe281295f | ||
|
|
917ff81b46 | ||
|
|
8a2cc7cc4e | ||
|
|
a64d968473 | ||
|
|
a2b1bfc107 | ||
|
|
f2b3705c2c | ||
|
|
3282a84e30 | ||
|
|
89a68942ac | ||
|
|
360c34467c | ||
|
|
265e43faf0 | ||
|
|
f064a6cc60 | ||
|
|
7fead0f140 | ||
|
|
d6f14b704f | ||
|
|
a892322203 | ||
|
|
2e2063cbeb | ||
|
|
625c989875 | ||
|
|
f20204180d | ||
|
|
0e85eeef2c | ||
|
|
b0fa5e0f42 | ||
|
|
25a15950f5 | ||
|
|
6f94fb51b1 | ||
|
|
57f3752d5e | ||
|
|
f52f848b95 | ||
|
|
3c3742a54a | ||
|
|
f325cce6fd | ||
|
|
88a85ffbbd | ||
|
|
35cbd23f63 | ||
|
|
210a1ab969 | ||
|
|
90c8ded449 | ||
|
|
8f864aad7b | ||
|
|
dddd0865cb | ||
|
|
0a81eb6463 | ||
|
|
b1740688bf | ||
|
|
86b505e412 | ||
|
|
da67c0a71f | ||
|
|
dadd1a926e | ||
|
|
01c50d57a6 | ||
|
|
e9f1f4d9b7 | ||
|
|
dd05f3249a | ||
|
|
43611fcc0b | ||
|
|
642254bee6 | ||
|
|
22743ca45a | ||
|
|
fb87c0d3c6 | ||
|
|
398ae0cb6b | ||
|
|
aaf5598a03 | ||
|
|
3d2cf554d7 | ||
|
|
55dec4d2f8 | ||
|
|
0f5f7faa9f | ||
|
|
90daabd5b1 | ||
|
|
262e1d7bf9 | ||
|
|
c559eb451e | ||
|
|
6a7ec85e83 | ||
|
|
81ecc98e02 | ||
|
|
9aeeddf5ac | ||
|
|
c7bfe06c54 | ||
|
|
349a391208 | ||
|
|
9d01bfaea3 | ||
|
|
cfbab31fb1 | ||
|
|
cb2481efdc | ||
|
|
d7ac3788e8 | ||
|
|
a0a313b101 | ||
|
|
93c0960c3a | ||
|
|
04d734d6d2 | ||
|
|
8468ea1ab4 | ||
|
|
0920d663d5 | ||
|
|
bbb72f0b73 | ||
|
|
8f8a27d6e5 | ||
|
|
86777bd66b | ||
|
|
8b92122f33 | ||
|
|
e93a5652d0 | ||
|
|
0c80b3a7cc | ||
|
|
f52ddfbd68 | ||
|
|
808b44f87a | ||
|
|
340d1a3447 | ||
|
|
ba20d9bff3 | ||
|
|
370693a200 | ||
|
|
33932ceea4 | ||
|
|
fb03f78fb4 | ||
|
|
523f3833eb | ||
|
|
46497e4f9a | ||
|
|
b627b7c6c6 | ||
|
|
e093f72d00 | ||
|
|
728bb64fed | ||
|
|
a07f0d428d | ||
|
|
b90d4e049d | ||
|
|
b0752e179b | ||
|
|
1fc12e0e5b | ||
|
|
e6fa7b1133 | ||
|
|
28e7dbd3d3 | ||
|
|
adc50051e0 | ||
|
|
2aec880347 | ||
|
|
238a8ebb15 | ||
|
|
86992476da | ||
|
|
751aeabc80 | ||
|
|
b4bb1b103f | ||
|
|
cffd187fc7 | ||
|
|
ccfa317486 | ||
|
|
a5cc2092a6 | ||
|
|
89041a1686 | ||
|
|
7a36419f24 | ||
|
|
281284fa5d | ||
|
|
1a27c7017a | ||
|
|
b8f5f84437 | ||
|
|
f2071e4f80 | ||
|
|
9c25ecdcd1 | ||
|
|
1beed12e59 | ||
|
|
4cd71d67f1 | ||
|
|
d9bc5ec047 | ||
|
|
c04c143cf0 | ||
|
|
c6aae45364 | ||
|
|
7f2a1c90d5 | ||
|
|
f5387387de | ||
|
|
e7e4dc755d | ||
|
|
b8224809ad | ||
|
|
bb22fb5756 | ||
|
|
ff274771ba | ||
|
|
15bf626191 | ||
|
|
ac106e835c | ||
|
|
640b525e83 | ||
|
|
0b379211dc | ||
|
|
bb223da258 | ||
|
|
17c5f89d4f | ||
|
|
695d26183a | ||
|
|
f5120a2aaf | ||
|
|
037314a059 | ||
|
|
ebcfbbadf0 | ||
|
|
6561c7a31f | ||
|
|
a6d98fb067 | ||
|
|
3a2d3a232f | ||
|
|
cebdad4d23 | ||
|
|
d798100be9 | ||
|
|
1fb6b9ee6f | ||
|
|
2d6e8f096b | ||
|
|
ec8038cc3d | ||
|
|
2df3d1c965 | ||
|
|
2272229983 | ||
|
|
b7bfecb4ee | ||
|
|
c7c4bbfce2 | ||
|
|
d7ba17dfe5 | ||
|
|
60b11435e6 | ||
|
|
ed2110d7b3 | ||
|
|
a9514de978 | ||
|
|
c57ab92e60 | ||
|
|
f878024d0b | ||
|
|
aac6be1153 | ||
|
|
dabe030890 | ||
|
|
29574282a2 | ||
|
|
2dd6ba57d1 | ||
|
|
6cc2307c71 | ||
|
|
74c8c7137a | ||
|
|
f9055ff9a7 | ||
|
|
9b3d8b318a | ||
|
|
87e29b25de | ||
|
|
f7bc9bd51b | ||
|
|
3dee617c86 | ||
|
|
2fb25e2bb3 | ||
|
|
b395359b6e | ||
|
|
fd61d70205 | ||
|
|
4f4495a693 | ||
|
|
68bbe983e9 | ||
|
|
bbef92c17d | ||
|
|
25c884158f | ||
|
|
3f936c5655 | ||
|
|
42a265b419 | ||
|
|
4bc4979acc | ||
|
|
b095367d17 | ||
|
|
eac2905568 | ||
|
|
12fd0c6838 | ||
|
|
19101826a8 | ||
|
|
7b94eab2b1 | ||
|
|
1a21b54560 | ||
|
|
b55f18649a | ||
|
|
e2373668d9 | ||
|
|
8c1a723ba5 | ||
|
|
ab7949dc16 | ||
|
|
2c4dce5ba7 | ||
|
|
cc84240098 | ||
|
|
b29ba4c70c | ||
|
|
fea6b525ee | ||
|
|
69dc71b5ed | ||
|
|
1a89682251 | ||
|
|
5fd0fefab6 | ||
|
|
f8a964d2b0 | ||
|
|
84033ae035 | ||
|
|
b9efbf6a3d | ||
|
|
13194ececa | ||
|
|
9ec9303abb | ||
|
|
03ee3db240 | ||
|
|
cf825b8819 | ||
|
|
377a8ba6b2 | ||
|
|
13cf6e66e3 | ||
|
|
81b6bacead | ||
|
|
e6fa14a08d | ||
|
|
c66683f27f | ||
|
|
6d6271db2f | ||
|
|
ab76c57ec8 | ||
|
|
d1e8899310 | ||
|
|
ccba2edb7c | ||
|
|
2a7a44be33 | ||
|
|
6301da75d1 | ||
|
|
059661b9ac | ||
|
|
dc5975ba7a | ||
|
|
0de4f3f75b | ||
|
|
b59aafc659 | ||
|
|
92a6ae93fa | ||
|
|
a31ddd2bb3 | ||
|
|
bc2ec7119b | ||
|
|
641b397f8b | ||
|
|
d342918790 | ||
|
|
c4377390a8 | ||
|
|
5608be0f96 | ||
|
|
dbecdf209d | ||
|
|
c05803bf96 | ||
|
|
d298adc4e6 | ||
|
|
c2050aa0e3 | ||
|
|
290e9f270b | ||
|
|
76ae10df42 | ||
|
|
cf0d7829a6 | ||
|
|
af21b9064d | ||
|
|
e31fbb0b23 | ||
|
|
43ba7c6369 | ||
|
|
dae513e0e7 | ||
|
|
d8944e45a2 | ||
|
|
5b5fcbfc00 | ||
|
|
6862b2ff08 | ||
|
|
22e87071dd | ||
|
|
606098cac8 | ||
|
|
b5c622762b | ||
|
|
2beb985fcc | ||
|
|
fd97404c51 | ||
|
|
d9fe4e2769 | ||
|
|
424fc0c3ac | ||
|
|
c81239f6ea | ||
|
|
b830dac266 | ||
|
|
dc38f93ca8 | ||
|
|
f9025eeb52 | ||
|
|
486c048a0d | ||
|
|
ab51b03093 | ||
|
|
dc2fa215b8 | ||
|
|
199157e8f4 | ||
|
|
520d68449f | ||
|
|
b075b8c49d | ||
|
|
f6c1a1ebcf | ||
|
|
c4aede2268 | ||
|
|
4a43c2bb2c | ||
|
|
b2e55c556e | ||
|
|
df0991b7de | ||
|
|
3368407aff | ||
|
|
25f3f358a0 | ||
|
|
00e8aa87b3 | ||
|
|
09ee46a83e | ||
|
|
02dfa64a89 | ||
|
|
f136570417 | ||
|
|
b6ba322a04 | ||
|
|
4b79ff5351 | ||
|
|
edd77ae2f3 | ||
|
|
985de211af | ||
|
|
8e3fa336eb | ||
|
|
582fd90c4a | ||
|
|
a15659e9f8 | ||
|
|
afd230af8d | ||
|
|
52ca75506a | ||
|
|
3bb9b839b8 | ||
|
|
5e7bfd0461 | ||
|
|
d05d114523 | ||
|
|
722b903f89 | ||
|
|
2ff6152204 | ||
|
|
98f9af8ecc | ||
|
|
481d332e72 | ||
|
|
1a18122e3f | ||
|
|
ee56418cef | ||
|
|
e1f8037cb5 | ||
|
|
ea9ee4c99e | ||
|
|
4026117ba1 | ||
|
|
49ee30a207 | ||
|
|
7c69c5dc3d | ||
|
|
223ebebbeb | ||
|
|
f96eb472b3 | ||
|
|
c1b0abe079 | ||
|
|
b04e21db16 | ||
|
|
756050b62c | ||
|
|
ef67a58410 | ||
|
|
2da0821286 | ||
|
|
928effd198 | ||
|
|
2e7806ede0 | ||
|
|
67967476b2 | ||
|
|
79d127c863 | ||
|
|
4f3e1c2831 | ||
|
|
199a49b5b3 | ||
|
|
96ab6ade5a | ||
|
|
9f16090f90 | ||
|
|
63b240ec7b | ||
|
|
c4ba502f57 | ||
|
|
94d5643f97 | ||
|
|
f0d91fa143 | ||
|
|
726a5f523e | ||
|
|
eba6b6f7c9 | ||
|
|
fa74ce6d16 | ||
|
|
8fdced4e11 | ||
|
|
9031597f49 | ||
|
|
a0b8f669ee | ||
|
|
18d67ed83b | ||
|
|
205ddb175f | ||
|
|
be908939da | ||
|
|
c96fc7fcef | ||
|
|
026c6ddb17 | ||
|
|
3eebba789f | ||
|
|
b36bd67b39 | ||
|
|
dc7f5bc0d8 | ||
|
|
ec20233fab | ||
|
|
867dfc5957 | ||
|
|
73d5bf46b4 | ||
|
|
f6416d8471 | ||
|
|
52acb4b347 | ||
|
|
d70f5ac6b0 | ||
|
|
c9b9fd0407 | ||
|
|
6897bb99bb | ||
|
|
4c861daa3e | ||
|
|
c9ee9fb99d | ||
|
|
50e13ef9c6 | ||
|
|
f624065eaa | ||
|
|
03adfa7b1a | ||
|
|
97a9a82324 | ||
|
|
307694e397 | ||
|
|
d268d11ca2 | ||
|
|
094f4d1bad | ||
|
|
a0398ce0f5 | ||
|
|
30c07f4e55 | ||
|
|
fc19f746b0 | ||
|
|
a351124cfd | ||
|
|
0230a7173f | ||
|
|
5f351a35a2 | ||
|
|
2d427e0502 | ||
|
|
1bba4fd9ea | ||
|
|
f98870715a | ||
|
|
b7a26d73ee | ||
|
|
1ba4d3c4c7 | ||
|
|
f61f0449c7 | ||
|
|
06c1ad5a73 | ||
|
|
38b3893211 | ||
|
|
42e0b02149 | ||
|
|
a56c6e5195 | ||
|
|
5efa22447e | ||
|
|
bdd668df7b | ||
|
|
05b00c50ad | ||
|
|
77e9122681 | ||
|
|
e067040375 | ||
|
|
370e101a69 | ||
|
|
91f5cf357c | ||
|
|
7c7c571bbe | ||
|
|
3101e327c0 | ||
|
|
46bf9f5177 | ||
|
|
694725beb0 | ||
|
|
ce3e7fbd72 | ||
|
|
53e9606ea2 | ||
|
|
ffc0d6209a | ||
|
|
9fdb6dcf1f | ||
|
|
298dd21ec8 | ||
|
|
64fa8ba9a9 | ||
|
|
36daedf35f | ||
|
|
a8d2eeee34 | ||
|
|
e21a61d458 | ||
|
|
410fb15a07 | ||
|
|
a69b19fa8f | ||
|
|
58924538a3 | ||
|
|
e750268f0c | ||
|
|
0328dedab5 | ||
|
|
9605dc5981 | ||
|
|
00694d271e | ||
|
|
b22db6e8eb | ||
|
|
14e7e8260e | ||
|
|
3a1f776132 | ||
|
|
4b53762cf2 | ||
|
|
0d56276102 | ||
|
|
98c7a0c169 | ||
|
|
676f0712fd | ||
|
|
7a3f1cf78e | ||
|
|
49c10bc219 | ||
|
|
df9990acf5 | ||
|
|
3d7b1a32a3 | ||
|
|
db99c1aa64 | ||
|
|
247388a20c | ||
|
|
f6f88e567e | ||
|
|
e527b992f9 | ||
|
|
aade31b263 | ||
|
|
e733d95e66 | ||
|
|
14bdce41fe | ||
|
|
4a49493e27 | ||
|
|
df5575de17 | ||
|
|
f0b2cc8f6e | ||
|
|
5f2b4e7872 | ||
|
|
22697722d9 | ||
|
|
ffbc93526e | ||
|
|
d9d47a53bd | ||
|
|
71d30d5c02 | ||
|
|
1661f3a2e8 | ||
|
|
d9767b8315 | ||
|
|
193a631708 | ||
|
|
a6764b9bf1 | ||
|
|
0f5dc152b8 | ||
|
|
8e1aae0fd6 | ||
|
|
084e5dbc4b | ||
|
|
dfbda986d7 | ||
|
|
248432b92d | ||
|
|
f738981ed5 | ||
|
|
4bb6ab3cd5 | ||
|
|
72e8219a65 | ||
|
|
7a955a09f4 | ||
|
|
b730a74a19 | ||
|
|
cc2b04ce1c | ||
|
|
4f8abaaf10 | ||
|
|
5043764247 | ||
|
|
9fd4d66438 | ||
|
|
aae48e3a9d | ||
|
|
ff57f52b72 | ||
|
|
7d84a4914f | ||
|
|
c2411e9c8c | ||
|
|
bf26a0eccc | ||
|
|
68a83eddd4 | ||
|
|
b999d49945 | ||
|
|
c94cb6dae9 | ||
|
|
5ea2b49f58 | ||
|
|
70deb70b76 | ||
|
|
48f37f9e0a | ||
|
|
6dff7c68f1 | ||
|
|
ec59dc026f | ||
|
|
c97abb1eea | ||
|
|
2fdafa9a49 | ||
|
|
f794f97d88 | ||
|
|
03ad8fa4d9 | ||
|
|
43fedfa8ba | ||
|
|
2f52618c4e | ||
|
|
a9e21170bc | ||
|
|
cb6cc3dfb6 | ||
|
|
66f2aac26f | ||
|
|
4a249752ff | ||
|
|
f0695e0edf | ||
|
|
07d4066847 | ||
|
|
57ba8a4d46 | ||
|
|
9e6c5f9f2c | ||
|
|
3639032d1e | ||
|
|
6f75ec8490 | ||
|
|
fd43d3709e | ||
|
|
6e177bf03f | ||
|
|
d3ac0bc149 | ||
|
|
afa276288c | ||
|
|
4832238708 | ||
|
|
1f8e3c13e6 | ||
|
|
5a401aef57 | ||
|
|
78ecf45527 | ||
|
|
3ae503a191 | ||
|
|
bafd48d96c | ||
|
|
cf7e4b027a | ||
|
|
15863c34a0 | ||
|
|
9875b0e0f8 | ||
|
|
2bdf44a25d | ||
|
|
4ffc881fb6 | ||
|
|
e92ae5199d | ||
|
|
a3a2bf890f | ||
|
|
a9194c4c68 | ||
|
|
ca32eb77f3 | ||
|
|
886441df98 | ||
|
|
e02ceca54b | ||
|
|
b3c35750c2 | ||
|
|
3e52fecd1e | ||
|
|
cccd7003ed | ||
|
|
038ea7c1d3 | ||
|
|
0b0cf58f24 | ||
|
|
7d1f372ba6 | ||
|
|
25e4ad19f6 | ||
|
|
7dfe8e726b | ||
|
|
61b101d442 | ||
|
|
cd1493b082 | ||
|
|
a98bff3ea1 | ||
|
|
06eb6e94e3 | ||
|
|
4a8801da34 | ||
|
|
b1e8be27a9 | ||
|
|
b922a3c952 | ||
|
|
b52826e7cc | ||
|
|
0ef72db7bf | ||
|
|
505d0f2288 | ||
|
|
6704b19db6 | ||
|
|
64b91da9cf | ||
|
|
fe9787e58d | ||
|
|
d06e571b31 | ||
|
|
208c15f29d | ||
|
|
a82dbb6e01 | ||
|
|
a42a99029f | ||
|
|
0c7b700895 | ||
|
|
1aa3ee2170 | ||
|
|
8c0d56d55a | ||
|
|
c41a0453c1 | ||
|
|
1a161a8333 | ||
|
|
9d8ae1b0c3 | ||
|
|
2de558057d | ||
|
|
0756caa42e | ||
|
|
99c1ddc792 | ||
|
|
69eef0a0ec | ||
|
|
42bd6447c0 | ||
|
|
747a8c628e | ||
|
|
023fec627e | ||
|
|
3a8bc309e2 | ||
|
|
3400727fff | ||
|
|
77742a3fba | ||
|
|
7cce55d8f0 | ||
|
|
933c195e51 | ||
|
|
d0898fd0c8 | ||
|
|
6765c19d45 | ||
|
|
599f5e3915 | ||
|
|
ba7204a7b7 | ||
|
|
e8ac0f293e | ||
|
|
a0d1161feb | ||
|
|
828b2680c0 | ||
|
|
c17cf022ea | ||
|
|
f6330ab8f1 | ||
|
|
6908826f95 | ||
|
|
fd542c71e3 | ||
|
|
9fb87f813b | ||
|
|
b0146b3d9a | ||
|
|
286587d151 | ||
|
|
6f751d5d26 | ||
|
|
4d7890c2c9 | ||
|
|
fdfaf23361 | ||
|
|
38597160f2 | ||
|
|
791c83aa7e | ||
|
|
29d957ed5e | ||
|
|
8d8b7c19b7 | ||
|
|
039ab48b7a | ||
|
|
8a64afabfd | ||
|
|
4a04bac250 | ||
|
|
72fc45aa6a | ||
|
|
9f2b05df1b | ||
|
|
83dc5ed4a7 | ||
|
|
e597ad8f0f | ||
|
|
3ea5446680 | ||
|
|
8b18e487bd | ||
|
|
c837d29eab | ||
|
|
ec1daef858 | ||
|
|
7d396bc2e7 | ||
|
|
8128df7655 | ||
|
|
cfaa7782b6 | ||
|
|
5e3f9d5175 | ||
|
|
cdc5d5b18d | ||
|
|
e98b1912b3 | ||
|
|
c8c0082413 | ||
|
|
1c1d079113 | ||
|
|
7523e4ad49 | ||
|
|
f4a5c9de50 | ||
|
|
1db9783bfc | ||
|
|
5b38134431 | ||
|
|
4c16038e72 | ||
|
|
2f7f50b8cb | ||
|
|
a1633055f7 | ||
|
|
35f6bb5060 | ||
|
|
28a3c939e7 | ||
|
|
7d9779fc67 | ||
|
|
9b8c91c90b | ||
|
|
47d4b46950 | ||
|
|
a649cb7db5 | ||
|
|
68c69b3717 | ||
|
|
ce4d3316d3 | ||
|
|
e6b79f0002 | ||
|
|
1a63eb46bb | ||
|
|
91c27148c0 | ||
|
|
1e7310e6cd | ||
|
|
b49a7d146d | ||
|
|
fbc8af40e3 | ||
|
|
709e720839 | ||
|
|
3cd9181ef8 | ||
|
|
81e4d3c6c3 | ||
|
|
958fc6ec49 | ||
|
|
19afcdc704 | ||
|
|
51d48bd953 | ||
|
|
26f15bcd77 | ||
|
|
412b8d2c80 | ||
|
|
617fedf349 | ||
|
|
59caa536ed | ||
|
|
3d5f7f64f8 | ||
|
|
66126cc32d | ||
|
|
31b30335f6 | ||
|
|
959866b848 | ||
|
|
cbab26673b | ||
|
|
1cf5e3f751 | ||
|
|
9a76ce8a65 | ||
|
|
574404e2ee | ||
|
|
20c0082ee5 | ||
|
|
9d92aeb182 | ||
|
|
2f5d7ae645 | ||
|
|
d2bc73bbbe | ||
|
|
697cad7027 | ||
|
|
472fb12273 | ||
|
|
d779308b3e | ||
|
|
a03f3287b3 | ||
|
|
a88cf317fd | ||
|
|
4802e8a285 | ||
|
|
b611dc4b99 | ||
|
|
5f19ea5e45 | ||
|
|
e4abeef65c | ||
|
|
ac49eda053 | ||
|
|
1fa803d187 | ||
|
|
6d1ff8a525 | ||
|
|
59dc29a19a | ||
|
|
6db667b6b1 | ||
|
|
07da3fc216 | ||
|
|
c5835b896c | ||
|
|
345e8ca804 | ||
|
|
9202f0cf09 | ||
|
|
d10f9a6abc | ||
|
|
ec0c0b14ca | ||
|
|
6267f8c6c0 |
40
.appveyor/check-generate-code.bat
Normal file
40
.appveyor/check-generate-code.bat
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
:: 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 buildtype=Release
|
||||||
|
if "%1"=="-b" set buildtype=%2
|
||||||
|
|
||||||
|
cd tests
|
||||||
|
call generate_code.bat -b %buildtype% || goto FAIL
|
||||||
|
|
||||||
|
:: TODO: Release and Debug builds produce differences here for some reason.
|
||||||
|
git checkout HEAD -- monster_test.bfbs
|
||||||
|
|
||||||
|
git -c core.autocrlf=true diff --exit-code --quiet || goto :DIFFFOUND
|
||||||
|
goto SUCCESS
|
||||||
|
|
||||||
|
:DIFFFOUND
|
||||||
|
@echo "" >&2
|
||||||
|
@echo "ERROR: ********************************************************" >&2
|
||||||
|
@echo "ERROR: The following differences were found after running the" >&2
|
||||||
|
@echo "ERROR: tests/generate_code.sh script. Maybe you forgot to run" >&2
|
||||||
|
@echo "ERROR: it after making changes in a generator or schema?" >&2
|
||||||
|
@echo "ERROR: ********************************************************" >&2
|
||||||
|
@echo "" >&2
|
||||||
|
@git -c core.autocrlf=true --no-pager diff --binary
|
||||||
|
|
||||||
|
:FAIL
|
||||||
|
set EXITCODE=1
|
||||||
|
:SUCCESS
|
||||||
|
cd ..
|
||||||
|
EXIT /B %EXITCODE%
|
||||||
18
.bazelci/presubmit.yml
Normal file
18
.bazelci/presubmit.yml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
buildifier: latest
|
||||||
|
platforms:
|
||||||
|
ubuntu1604:
|
||||||
|
build_targets:
|
||||||
|
- "..."
|
||||||
|
test_targets:
|
||||||
|
- "..."
|
||||||
|
ubuntu1804:
|
||||||
|
build_targets:
|
||||||
|
- "..."
|
||||||
|
test_targets:
|
||||||
|
- "..."
|
||||||
|
macos:
|
||||||
|
build_targets:
|
||||||
|
- "..."
|
||||||
|
test_targets:
|
||||||
|
- "..."
|
||||||
13
.clang-format
Normal file
13
.clang-format
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
BasedOnStyle: Google
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
PointerAlignment: Right
|
||||||
|
IndentPPDirectives: AfterHash
|
||||||
|
Cpp11BracedListStyle: false
|
||||||
|
AlwaysBreakTemplateDeclarations: false
|
||||||
|
AllowShortCaseLabelsOnASingleLine: true
|
||||||
|
SpaceAfterTemplateKeyword: false
|
||||||
|
AllowShortBlocksOnASingleLine: true
|
||||||
|
...
|
||||||
|
|
||||||
7
.editorconfig
Normal file
7
.editorconfig
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
root = true
|
||||||
|
# Don't set line endings to avoid conflict with core.autocrlf flag.
|
||||||
|
# Line endings on checkout/checkin are controlled by .gitattributes file.
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
insert_final_newline = true
|
||||||
1
.gitattributes
vendored
Executable file → Normal file
1
.gitattributes
vendored
Executable file → Normal file
@@ -1 +1,2 @@
|
|||||||
|
# Set the default behavior, in case people don't have core.autocrlf set.
|
||||||
* text=auto
|
* text=auto
|
||||||
|
|||||||
12
.github/ISSUE_TEMPLATE.md
vendored
Normal file
12
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
Thank you for submitting an issue!
|
||||||
|
|
||||||
|
Please make sure you include the names of the affected language(s), compiler version(s), operating system version(s), and FlatBuffers version(s) in your issue title.
|
||||||
|
|
||||||
|
This helps us get the correct maintainers to look at your issue. Here are examples of good titles:
|
||||||
|
|
||||||
|
- Crash when accessing FlatBuffer [C++, gcc 4.8, OS X, master]
|
||||||
|
- Flatc converts a protobuf 'bytes' field to 'string' in fbs schema file [all languages, FlatBuffers 1.4]
|
||||||
|
|
||||||
|
Include other details as appropriate.
|
||||||
|
|
||||||
|
Thanks!
|
||||||
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
Thank you for submitting a PR!
|
||||||
|
|
||||||
|
Please make sure you include the names of the affected language(s) in your PR title.
|
||||||
|
This helps us get the correct maintainers to look at your issue.
|
||||||
|
|
||||||
|
If you make changes to any of the code generators, be sure to run
|
||||||
|
`cd tests && sh generate_code.sh` (or equivalent .bat) and include the generated
|
||||||
|
code changes in the PR. This allows us to better see the effect of the PR.
|
||||||
|
|
||||||
|
If your PR includes C++ code, please adhere to the Google C++ Style Guide,
|
||||||
|
and don't forget we try to support older compilers (e.g. VS2010, GCC 4.6.3),
|
||||||
|
so only some C++11 support is available.
|
||||||
|
|
||||||
|
Include other details as appropriate.
|
||||||
|
|
||||||
|
Thanks!
|
||||||
59
.gitignore
vendored
Executable file → Normal file
59
.gitignore
vendored
Executable file → Normal file
@@ -5,14 +5,18 @@
|
|||||||
*.o.d
|
*.o.d
|
||||||
*.class
|
*.class
|
||||||
*.a
|
*.a
|
||||||
|
*.swp
|
||||||
*~
|
*~
|
||||||
*.vcxproj
|
*.vcxproj
|
||||||
*.vcxproj.filters
|
*.vcxproj.filters
|
||||||
*.vcxproj.user
|
*.vcxproj.user
|
||||||
*.sln
|
*.sln
|
||||||
*.suo
|
*.suo
|
||||||
|
*.opendb
|
||||||
*.keystore
|
*.keystore
|
||||||
|
**/.vs/**
|
||||||
**/bin/**
|
**/bin/**
|
||||||
|
!tests/rust_usage_test/bin/**
|
||||||
**/gen/**
|
**/gen/**
|
||||||
**/libs/**
|
**/libs/**
|
||||||
**/obj/**
|
**/obj/**
|
||||||
@@ -22,8 +26,13 @@
|
|||||||
**/install_manifest.txt
|
**/install_manifest.txt
|
||||||
**/CMakeCache.txt
|
**/CMakeCache.txt
|
||||||
**/CMakeTestfile.cmake
|
**/CMakeTestfile.cmake
|
||||||
|
**/CPackConfig.cmake
|
||||||
|
**/CPackSourceConfig.cmake
|
||||||
|
**/compile_commands.json
|
||||||
**/Debug/**
|
**/Debug/**
|
||||||
**/Release/**
|
**/Release/**
|
||||||
|
**/RelWithDebInfo/**
|
||||||
|
**/x64/ #build artifacts from VS
|
||||||
build.xml
|
build.xml
|
||||||
local.properties
|
local.properties
|
||||||
project.properties
|
project.properties
|
||||||
@@ -40,24 +49,70 @@ flatsamplebinary
|
|||||||
flatsamplebinary.exe
|
flatsamplebinary.exe
|
||||||
flatsampletext
|
flatsampletext
|
||||||
flatsampletext.exe
|
flatsampletext.exe
|
||||||
|
flatsamplebfbs
|
||||||
|
flatsamplebfbs.exe
|
||||||
|
grpctest
|
||||||
|
grpctest.exe
|
||||||
snapshot.sh
|
snapshot.sh
|
||||||
|
tags
|
||||||
|
tests/dart_gen
|
||||||
tests/go_gen
|
tests/go_gen
|
||||||
tests/monsterdata_java_wire.mon
|
tests/monsterdata_java_wire.mon
|
||||||
|
tests/monsterdata_java_wire_sp.mon
|
||||||
tests/monsterdata_go_wire.mon
|
tests/monsterdata_go_wire.mon
|
||||||
tests/monsterdata_javascript_wire.mon
|
tests/monsterdata_javascript_wire.mon
|
||||||
|
tests/monsterdata_lobster_wire.mon
|
||||||
|
tests/monsterdata_rust_wire.mon
|
||||||
tests/unicode_test.mon
|
tests/unicode_test.mon
|
||||||
|
tests/ts/
|
||||||
|
tests/php/
|
||||||
CMakeLists.txt.user
|
CMakeLists.txt.user
|
||||||
CMakeScripts/**
|
CMakeScripts/**
|
||||||
CTestTestfile.cmake
|
CTestTestfile.cmake
|
||||||
|
FlatbuffersConfigVersion.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/**
|
||||||
FlatBuffers.xcodeproj/
|
FlatBuffers.xcodeproj/
|
||||||
java/.idea
|
java/.idea
|
||||||
java/*.iml
|
java/*.iml
|
||||||
java/target
|
|
||||||
**/*.pyc
|
|
||||||
.idea
|
.idea
|
||||||
|
*.iml
|
||||||
|
target
|
||||||
|
**/*.pyc
|
||||||
build/VS2010/FlatBuffers.sdf
|
build/VS2010/FlatBuffers.sdf
|
||||||
build/VS2010/FlatBuffers.opensdf
|
build/VS2010/FlatBuffers.opensdf
|
||||||
build/VS2010/ipch/**/*.ipch
|
build/VS2010/ipch/**/*.ipch
|
||||||
|
*.so
|
||||||
|
Testing/Temporary
|
||||||
|
.cproject
|
||||||
|
.settings/
|
||||||
|
.project
|
||||||
|
net/**/obj
|
||||||
|
node_modules/
|
||||||
|
android/.externalNativeBuild/
|
||||||
|
android/.gradle/
|
||||||
|
android/build/
|
||||||
|
samples/android/.externalNativeBuild/
|
||||||
|
samples/android/.gradle/
|
||||||
|
samples/android/build/
|
||||||
|
js/flatbuffers.mjs
|
||||||
|
/bazel-bin
|
||||||
|
/bazel-flatbuffers
|
||||||
|
/bazel-genfiles
|
||||||
|
/bazel-out
|
||||||
|
/bazel-testlogs
|
||||||
|
.ninja_deps
|
||||||
|
.ninja_log
|
||||||
|
build.ninja
|
||||||
|
rules.ninja
|
||||||
|
.vscode
|
||||||
|
dart/.pub/
|
||||||
|
dart/.packages
|
||||||
|
dart/pubspec.lock
|
||||||
|
dart/.dart_tool/
|
||||||
|
dart/build/
|
||||||
|
dart/doc/api/
|
||||||
|
Cargo.lock
|
||||||
|
.corpus**
|
||||||
|
.seed**
|
||||||
|
|||||||
206
.travis.yml
206
.travis.yml
@@ -1,30 +1,186 @@
|
|||||||
language: cpp
|
|
||||||
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
- osx
|
|
||||||
|
|
||||||
compiler:
|
|
||||||
- gcc
|
|
||||||
#- clang
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
matrix:
|
|
||||||
- BUILD_TYPE=Debug BIICODE=false
|
|
||||||
- BUILD_TYPE=Release BIICODE=false
|
|
||||||
- BUILD_TYPE=Release BIICODE=true
|
|
||||||
- BUILD_TYPE=Debug BIICODE=true
|
|
||||||
global:
|
global:
|
||||||
|
# Set at the root level as this is ignored when set under matrix.env.
|
||||||
- GCC_VERSION="4.9"
|
- 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"
|
||||||
|
|
||||||
before_install:
|
conan-linux: &conan-linux
|
||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; fi
|
os: linux
|
||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq; fi
|
dist: xenial
|
||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq g++-$GCC_VERSION; fi
|
language: python
|
||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq gcc-$GCC_VERSION; fi
|
python: "3.7"
|
||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which g++-$GCC_VERSION) /usr/bin/g++; fi
|
services:
|
||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which gcc-$GCC_VERSION) /usr/bin/gcc; fi
|
- docker
|
||||||
|
install:
|
||||||
|
- ./conan/travis/install.sh
|
||||||
|
script:
|
||||||
|
- ./conan/travis/build.sh
|
||||||
|
if: tag IS present
|
||||||
|
|
||||||
script:
|
conan-osx: &conan-osx
|
||||||
- if [ "$BIICODE" == "false" ]; then cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE . && make && make test; fi
|
os: osx
|
||||||
- if [ "$BIICODE" == "true" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then ./biicode/support/bii-travis.sh $BUILD_TYPE; fi
|
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 CONAN=true
|
||||||
|
|
||||||
|
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:
|
||||||
|
- 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 . -- -j${JOBS}
|
||||||
|
- LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/google/grpc/install/lib ctest --extra-verbose --output-on-failure
|
||||||
|
- bash .travis/check-generate-code.sh
|
||||||
|
- if [ "$CONAN" == "true" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo pip install conan && conan create . flatbuffers/${TRAVIS_BRANCH}@google/testing -s build_type=$BUILD_TYPE -tf conan/test_package; fi
|
||||||
|
|
||||||
|
- language: cpp
|
||||||
|
os: osx
|
||||||
|
osx_image: xcode9.3
|
||||||
|
env:
|
||||||
|
matrix:
|
||||||
|
- BUILD_TYPE=Debug
|
||||||
|
- BUILD_TYPE=Release
|
||||||
|
|
||||||
|
script:
|
||||||
|
- 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
|
||||||
|
- bash .travis/check-generate-code.sh
|
||||||
|
|
||||||
|
- <<: *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_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-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
|
||||||
|
env: CONAN_APPLE_CLANG_VERSIONS=10.0
|
||||||
|
|
||||||
|
- language: android
|
||||||
|
sudo: true
|
||||||
|
android:
|
||||||
|
components:
|
||||||
|
- tools
|
||||||
|
- platform-tools
|
||||||
|
- build-tools-25.0.2
|
||||||
|
- android-25
|
||||||
|
- extra-android-m2repository
|
||||||
|
compiler:
|
||||||
|
- gcc
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
# Output something every 10 minutes or Travis kills the job
|
||||||
|
- while sleep 540; do echo "=====[ $SECONDS seconds still running ]====="; done &
|
||||||
|
- git clone https://github.com/urho3d/android-ndk.git $HOME/android-ndk-root
|
||||||
|
- export ANDROID_NDK_HOME=$HOME/android-ndk-root
|
||||||
|
# Setup environment for Linux build which is required to build the sample.
|
||||||
|
- 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:
|
||||||
|
- failed=0; for build_gradle in $(git ls-files | grep build.gradle); do ( cd "$(dirname "${build_gradle}")" && ./gradlew build ) || failed=1; done; exit $((failed))
|
||||||
|
# Kill the sleep loop
|
||||||
|
- kill %1
|
||||||
|
|||||||
40
.travis/build-and-run-docker-test-containers.sh
Executable file
40
.travis/build-and-run-docker-test-containers.sh
Executable file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
# build flatc on debian once to speed up the test loop below
|
||||||
|
docker build -t build_flatc_debian_stretch -f tests/docker/Dockerfile.testing.build_flatc_debian_stretch .
|
||||||
|
BUILD_CONTAINER_ID=$(docker create --read-only build_flatc_debian_stretch)
|
||||||
|
docker cp ${BUILD_CONTAINER_ID}:/code/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
|
||||||
34
.travis/check-generate-code.sh
Executable file
34
.travis/check-generate-code.sh
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
cd tests
|
||||||
|
./generate_code.sh
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# TODO: Linux and macos builds produce differences here for some reason.
|
||||||
|
git checkout HEAD -- tests/monster_test.bfbs
|
||||||
|
|
||||||
|
if ! git diff --quiet; then
|
||||||
|
echo >&2
|
||||||
|
echo "ERROR: ********************************************************" >&2
|
||||||
|
echo "ERROR: The following differences were found after running the" >&2
|
||||||
|
echo "ERROR: tests/generate_code.sh script. Maybe you forgot to run" >&2
|
||||||
|
echo "ERROR: it after making changes in a generator or schema?" >&2
|
||||||
|
echo "ERROR: ********************************************************" >&2
|
||||||
|
echo >&2
|
||||||
|
git diff --binary --exit-code
|
||||||
|
fi
|
||||||
33
.travis/check-sources.sh
Normal file
33
.travis/check-sources.sh
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/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$"
|
||||||
35
.travis/check-sources.sh.py
Normal file
35
.travis/check-sources.sh.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
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)
|
||||||
12
.travis/deploy-python.sh
Executable file
12
.travis/deploy-python.sh
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/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/"*
|
||||||
|
|
||||||
186
BUILD
Normal file
186
BUILD
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
licenses(["notice"])
|
||||||
|
|
||||||
|
package(
|
||||||
|
default_visibility = ["//visibility:public"],
|
||||||
|
features = [
|
||||||
|
"-layering_check",
|
||||||
|
"-parse_headers",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
exports_files([
|
||||||
|
"LICENSE",
|
||||||
|
])
|
||||||
|
|
||||||
|
load(":build_defs.bzl", "flatbuffer_cc_library")
|
||||||
|
|
||||||
|
# Public flatc library to compile flatbuffer files at runtime.
|
||||||
|
cc_library(
|
||||||
|
name = "flatbuffers",
|
||||||
|
srcs = [
|
||||||
|
"src/code_generators.cpp",
|
||||||
|
"src/idl_gen_fbs.cpp",
|
||||||
|
"src/idl_gen_general.cpp",
|
||||||
|
"src/idl_gen_text.cpp",
|
||||||
|
"src/idl_parser.cpp",
|
||||||
|
"src/reflection.cpp",
|
||||||
|
"src/util.cpp",
|
||||||
|
],
|
||||||
|
hdrs = [":public_headers"],
|
||||||
|
includes = ["include/"],
|
||||||
|
linkstatic = 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Public C++ headers for the Flatbuffers library.
|
||||||
|
filegroup(
|
||||||
|
name = "public_headers",
|
||||||
|
srcs = [
|
||||||
|
"include/flatbuffers/base.h",
|
||||||
|
"include/flatbuffers/code_generators.h",
|
||||||
|
"include/flatbuffers/flatbuffers.h",
|
||||||
|
"include/flatbuffers/flexbuffers.h",
|
||||||
|
"include/flatbuffers/hash.h",
|
||||||
|
"include/flatbuffers/idl.h",
|
||||||
|
"include/flatbuffers/minireflect.h",
|
||||||
|
"include/flatbuffers/reflection.h",
|
||||||
|
"include/flatbuffers/reflection_generated.h",
|
||||||
|
"include/flatbuffers/stl_emulation.h",
|
||||||
|
"include/flatbuffers/util.h",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Public flatc compiler library.
|
||||||
|
cc_library(
|
||||||
|
name = "flatc_library",
|
||||||
|
srcs = [
|
||||||
|
"src/code_generators.cpp",
|
||||||
|
"src/flatc.cpp",
|
||||||
|
"src/idl_gen_fbs.cpp",
|
||||||
|
"src/idl_parser.cpp",
|
||||||
|
"src/reflection.cpp",
|
||||||
|
"src/util.cpp",
|
||||||
|
],
|
||||||
|
hdrs = [
|
||||||
|
"include/flatbuffers/flatc.h",
|
||||||
|
":public_headers",
|
||||||
|
],
|
||||||
|
includes = [
|
||||||
|
"grpc/",
|
||||||
|
"include/",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Public flatc compiler.
|
||||||
|
cc_binary(
|
||||||
|
name = "flatc",
|
||||||
|
srcs = [
|
||||||
|
"grpc/src/compiler/config.h",
|
||||||
|
"grpc/src/compiler/cpp_generator.cc",
|
||||||
|
"grpc/src/compiler/cpp_generator.h",
|
||||||
|
"grpc/src/compiler/go_generator.cc",
|
||||||
|
"grpc/src/compiler/go_generator.h",
|
||||||
|
"grpc/src/compiler/java_generator.cc",
|
||||||
|
"grpc/src/compiler/java_generator.h",
|
||||||
|
"grpc/src/compiler/schema_interface.h",
|
||||||
|
"src/flatc_main.cpp",
|
||||||
|
"src/idl_gen_cpp.cpp",
|
||||||
|
"src/idl_gen_dart.cpp",
|
||||||
|
"src/idl_gen_general.cpp",
|
||||||
|
"src/idl_gen_go.cpp",
|
||||||
|
"src/idl_gen_grpc.cpp",
|
||||||
|
"src/idl_gen_js_ts.cpp",
|
||||||
|
"src/idl_gen_json_schema.cpp",
|
||||||
|
"src/idl_gen_lobster.cpp",
|
||||||
|
"src/idl_gen_lua.cpp",
|
||||||
|
"src/idl_gen_php.cpp",
|
||||||
|
"src/idl_gen_python.cpp",
|
||||||
|
"src/idl_gen_rust.cpp",
|
||||||
|
"src/idl_gen_text.cpp",
|
||||||
|
],
|
||||||
|
includes = [
|
||||||
|
"grpc/",
|
||||||
|
"include/",
|
||||||
|
],
|
||||||
|
deps = [
|
||||||
|
":flatc_library",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "runtime_cc",
|
||||||
|
hdrs = [
|
||||||
|
"include/flatbuffers/base.h",
|
||||||
|
"include/flatbuffers/flatbuffers.h",
|
||||||
|
"include/flatbuffers/flexbuffers.h",
|
||||||
|
"include/flatbuffers/stl_emulation.h",
|
||||||
|
"include/flatbuffers/util.h",
|
||||||
|
],
|
||||||
|
includes = ["include/"],
|
||||||
|
linkstatic = 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test binary.
|
||||||
|
cc_test(
|
||||||
|
name = "flatbuffers_test",
|
||||||
|
testonly = 1,
|
||||||
|
srcs = [
|
||||||
|
"include/flatbuffers/minireflect.h",
|
||||||
|
"include/flatbuffers/registry.h",
|
||||||
|
"src/code_generators.cpp",
|
||||||
|
"src/idl_gen_fbs.cpp",
|
||||||
|
"src/idl_gen_general.cpp",
|
||||||
|
"src/idl_gen_text.cpp",
|
||||||
|
"src/idl_parser.cpp",
|
||||||
|
"src/reflection.cpp",
|
||||||
|
"src/util.cpp",
|
||||||
|
"tests/namespace_test/namespace_test1_generated.h",
|
||||||
|
"tests/namespace_test/namespace_test2_generated.h",
|
||||||
|
"tests/test.cpp",
|
||||||
|
"tests/test_assert.cpp",
|
||||||
|
"tests/test_assert.h",
|
||||||
|
"tests/test_builder.cpp",
|
||||||
|
"tests/test_builder.h",
|
||||||
|
"tests/union_vector/union_vector_generated.h",
|
||||||
|
":public_headers",
|
||||||
|
],
|
||||||
|
copts = [
|
||||||
|
"-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",
|
||||||
|
"-DBAZEL_TEST_DATA_PATH",
|
||||||
|
],
|
||||||
|
data = [
|
||||||
|
":tests/include_test/include_test1.fbs",
|
||||||
|
":tests/include_test/sub/include_test2.fbs",
|
||||||
|
":tests/monster_test.bfbs",
|
||||||
|
":tests/monster_test.fbs",
|
||||||
|
":tests/monsterdata_test.golden",
|
||||||
|
":tests/prototest/imported.proto",
|
||||||
|
":tests/prototest/test.golden",
|
||||||
|
":tests/prototest/test.proto",
|
||||||
|
":tests/prototest/test_union.golden",
|
||||||
|
":tests/unicode_test.json",
|
||||||
|
":tests/union_vector/union_vector.fbs",
|
||||||
|
":tests/union_vector/union_vector.json",
|
||||||
|
],
|
||||||
|
includes = ["include/"],
|
||||||
|
deps = [
|
||||||
|
":monster_extra_cc_fbs",
|
||||||
|
":monster_test_cc_fbs",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test bzl rules
|
||||||
|
|
||||||
|
flatbuffer_cc_library(
|
||||||
|
name = "monster_test_cc_fbs",
|
||||||
|
srcs = ["tests/monster_test.fbs"],
|
||||||
|
include_paths = ["tests/include_test"],
|
||||||
|
includes = [
|
||||||
|
"tests/include_test/include_test1.fbs",
|
||||||
|
"tests/include_test/sub/include_test2.fbs",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
flatbuffer_cc_library(
|
||||||
|
name = "monster_extra_cc_fbs",
|
||||||
|
srcs = ["tests/monster_extra.fbs"],
|
||||||
|
)
|
||||||
@@ -63,6 +63,15 @@ function(build_flatbuffers flatbuffers_schemas
|
|||||||
set(FLATC_TARGET flatc)
|
set(FLATC_TARGET flatc)
|
||||||
set(FLATC flatc)
|
set(FLATC flatc)
|
||||||
endif()
|
endif()
|
||||||
|
set(FLATC_SCHEMA_ARGS --gen-mutable)
|
||||||
|
if(FLATBUFFERS_FLATC_SCHEMA_EXTRA_ARGS)
|
||||||
|
set(FLATC_SCHEMA_ARGS
|
||||||
|
${FLATBUFFERS_FLATC_SCHEMA_EXTRA_ARGS}
|
||||||
|
${FLATC_SCHEMA_ARGS}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(working_dir "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|
||||||
set(schema_glob "*.fbs")
|
set(schema_glob "*.fbs")
|
||||||
# Generate the include files parameters.
|
# Generate the include files parameters.
|
||||||
@@ -86,11 +95,12 @@ 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} --gen-mutable
|
COMMAND ${FLATC} ${FLATC_SCHEMA_ARGS}
|
||||||
-o ${generated_includes_dir}
|
-o ${generated_includes_dir}
|
||||||
${include_params}
|
${include_params}
|
||||||
-c ${schema}
|
-c ${schema}
|
||||||
DEPENDS ${FLATC_TARGET} ${schema} ${additional_dependencies})
|
DEPENDS ${FLATC_TARGET} ${schema} ${additional_dependencies}
|
||||||
|
WORKING_DIRECTORY "${working_dir}")
|
||||||
list(APPEND all_generated_files ${generated_include})
|
list(APPEND all_generated_files ${generated_include})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -102,7 +112,8 @@ function(build_flatbuffers flatbuffers_schemas
|
|||||||
-o ${binary_schemas_dir}
|
-o ${binary_schemas_dir}
|
||||||
${include_params}
|
${include_params}
|
||||||
${schema}
|
${schema}
|
||||||
DEPENDS ${FLATC_TARGET} ${schema} ${additional_dependencies})
|
DEPENDS ${FLATC_TARGET} ${schema} ${additional_dependencies}
|
||||||
|
WORKING_DIRECTORY "${working_dir}")
|
||||||
list(APPEND all_generated_files ${binary_schema})
|
list(APPEND all_generated_files ${binary_schema})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
4
CMake/DESCRIPTION.txt
Normal file
4
CMake/DESCRIPTION.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
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.
|
||||||
@@ -45,6 +45,7 @@ if(FLATBUFFERS_FOUND)
|
|||||||
add_custom_command(OUTPUT ${FLATC_OUTPUT}
|
add_custom_command(OUTPUT ${FLATC_OUTPUT}
|
||||||
COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE}
|
COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE}
|
||||||
ARGS -c -o "${CMAKE_CURRENT_BINARY_DIR}/" ${FILE}
|
ARGS -c -o "${CMAKE_CURRENT_BINARY_DIR}/" ${FILE}
|
||||||
|
DEPENDS ${FILE}
|
||||||
COMMENT "Building C++ header for ${FILE}"
|
COMMENT "Building C++ header for ${FILE}"
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|||||||
4
CMake/FlatbuffersConfig.cmake
Normal file
4
CMake/FlatbuffersConfig.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)
|
||||||
|
|
||||||
11
CMake/FlatbuffersConfigVersion.cmake.in
Normal file
11
CMake/FlatbuffersConfigVersion.cmake.in
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
set(PACKAGE_VERSION "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@")
|
||||||
|
|
||||||
|
# Check whether the requested PACKAGE_FIND_VERSION is compatible
|
||||||
|
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||||
|
else()
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||||
|
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
|
||||||
|
set(PACKAGE_VERSION_EXACT TRUE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
39
CMake/PackageDebian.cmake
Normal file
39
CMake/PackageDebian.cmake
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# ------------------- Debianization ---------------------
|
||||||
|
if (UNIX)
|
||||||
|
|
||||||
|
# Set build environment
|
||||||
|
SET(CPACK_GENERATOR "TGZ;DEB")
|
||||||
|
SET(CPACK_SOURCE_TGZ "ON")
|
||||||
|
|
||||||
|
# Common package information
|
||||||
|
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
|
||||||
|
"FlatBuffers is an efficient cross platform serialization library for C++, with support for Java, C# and Go. It was created at Google specifically for game development and other performance-critical applications.")
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/google/flatbuffers")
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Vitaly Isaev <vitalyisaev2@gmail.com>")
|
||||||
|
|
||||||
|
SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
|
||||||
|
SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
|
||||||
|
SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
|
||||||
|
SET(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_COMMIT}")
|
||||||
|
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
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_NAME "flatbuffers")
|
||||||
|
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)
|
||||||
|
SET(CPACK_PACKAGE_FILE_NAME
|
||||||
|
"${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
|
||||||
|
|
||||||
|
endif(UNIX)
|
||||||
34
CMake/PackageRedhat.cmake
Normal file
34
CMake/PackageRedhat.cmake
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
if (UNIX)
|
||||||
|
set(CPACK_GENERATOR "RPM")
|
||||||
|
set(CPACK_SOURCE_TGZ "ON")
|
||||||
|
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "FlatBuffers serialization library and schema compiler.")
|
||||||
|
|
||||||
|
set(CPACK_RPM_PACKAGE_HOMEPAGE "https://github.com/google/flatbuffers")
|
||||||
|
set(CPACK_RPM_PACKAGE_MAINTAINER "Marc Butler <mockbutler@gmail.com>")
|
||||||
|
|
||||||
|
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
|
||||||
|
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
|
||||||
|
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
|
||||||
|
set(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_COMMIT}")
|
||||||
|
set(CPACK_RPM_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
|
||||||
|
|
||||||
|
set(CPACK_RPM_PACKAGE_NAME "flatbuffers")
|
||||||
|
|
||||||
|
# Assume this is not a cross complation build.
|
||||||
|
if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
|
||||||
|
set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}")
|
||||||
|
endif(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
|
||||||
|
|
||||||
|
set(CPACK_RPM_PACKAGE_VENDOR "Google, Inc.")
|
||||||
|
set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0")
|
||||||
|
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/CMake/DESCRIPTION.txt)
|
||||||
|
|
||||||
|
# This may reduce rpm compatiblity with very old systems.
|
||||||
|
set(CPACK_RPM_COMPRESSION_TYPE lzma)
|
||||||
|
|
||||||
|
set(CPACK_RPM_PACKAGE_NAME "flatbuffers")
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME
|
||||||
|
"${CPACK_RPM_PACKAGE_NAME}_${CPACK_RPM_PACKAGE_VERSION}_${CPACK_RPM_PACKAGE_ARCHITECTURE}")
|
||||||
|
endif(UNIX)
|
||||||
11
CMake/Version.cmake
Normal file
11
CMake/Version.cmake
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
find_program(GIT git)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT} describe
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_DESCRIBE_DIRTY
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${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}")
|
||||||
349
CMakeLists.txt
349
CMakeLists.txt
@@ -1,4 +1,7 @@
|
|||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
# generate compile_commands.json
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
include(CheckCXXSymbolExists)
|
||||||
|
|
||||||
project(FlatBuffers)
|
project(FlatBuffers)
|
||||||
|
|
||||||
@@ -6,9 +9,26 @@ project(FlatBuffers)
|
|||||||
option(FLATBUFFERS_CODE_COVERAGE "Enable the code coverage build option." OFF)
|
option(FLATBUFFERS_CODE_COVERAGE "Enable the code coverage build option." OFF)
|
||||||
option(FLATBUFFERS_BUILD_TESTS "Enable the build of tests and samples." ON)
|
option(FLATBUFFERS_BUILD_TESTS "Enable the build of tests and samples." ON)
|
||||||
option(FLATBUFFERS_INSTALL "Enable the installation of targets." ON)
|
option(FLATBUFFERS_INSTALL "Enable the installation of targets." ON)
|
||||||
option(FLATBUFFERS_BUILD_FLATLIB "Enable the build of the flatbuffers library" ON)
|
option(FLATBUFFERS_BUILD_FLATLIB "Enable the build of the flatbuffers library"
|
||||||
option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler" ON)
|
ON)
|
||||||
|
option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler"
|
||||||
|
ON)
|
||||||
option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" ON)
|
option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" ON)
|
||||||
|
option(FLATBUFFERS_BUILD_GRPCTEST "Enable the build of grpctest" OFF)
|
||||||
|
option(FLATBUFFERS_BUILD_SHAREDLIB
|
||||||
|
"Enable the build of the flatbuffers shared library"
|
||||||
|
OFF)
|
||||||
|
option(FLATBUFFERS_LIBCXX_WITH_CLANG "Force libc++ when using Clang" ON)
|
||||||
|
# NOTE: Sanitizer check only works on Linux & OSX (gcc & llvm).
|
||||||
|
option(FLATBUFFERS_CODE_SANITIZE
|
||||||
|
"Add '-fsanitize' flags to 'flattests' and 'flatc' targets."
|
||||||
|
OFF)
|
||||||
|
option(FLATBUFFERS_PACKAGE_REDHAT
|
||||||
|
"Build an rpm using the 'package' target."
|
||||||
|
OFF)
|
||||||
|
option(FLATBUFFERS_PACKAGE_DEBIAN
|
||||||
|
"Build an deb using the 'package' target."
|
||||||
|
OFF)
|
||||||
|
|
||||||
if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
|
if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
|
||||||
message(WARNING
|
message(WARNING
|
||||||
@@ -16,28 +36,66 @@ if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
|
|||||||
set(FLATBUFFERS_BUILD_TESTS OFF)
|
set(FLATBUFFERS_BUILD_TESTS OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED FLATBUFFERS_MAX_PARSING_DEPTH)
|
||||||
|
# Override the default recursion depth limit.
|
||||||
|
add_definitions(-DFLATBUFFERS_MAX_PARSING_DEPTH=${FLATBUFFERS_MAX_PARSING_DEPTH})
|
||||||
|
message(STATUS "FLATBUFFERS_MAX_PARSING_DEPTH: ${FLATBUFFERS_MAX_PARSING_DEPTH}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Auto-detect locale-narrow 'strtod_l' function.
|
||||||
|
if(NOT DEFINED FLATBUFFERS_LOCALE_INDEPENDENT)
|
||||||
|
if(MSVC)
|
||||||
|
check_cxx_symbol_exists(_strtof_l stdlib.h FLATBUFFERS_LOCALE_INDEPENDENT)
|
||||||
|
else()
|
||||||
|
check_cxx_symbol_exists(strtof_l stdlib.h FLATBUFFERS_LOCALE_INDEPENDENT)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
add_definitions(-DFLATBUFFERS_LOCALE_INDEPENDENT=$<BOOL:${FLATBUFFERS_LOCALE_INDEPENDENT}>)
|
||||||
|
|
||||||
set(FlatBuffers_Library_SRCS
|
set(FlatBuffers_Library_SRCS
|
||||||
|
include/flatbuffers/code_generators.h
|
||||||
|
include/flatbuffers/base.h
|
||||||
include/flatbuffers/flatbuffers.h
|
include/flatbuffers/flatbuffers.h
|
||||||
include/flatbuffers/hash.h
|
include/flatbuffers/hash.h
|
||||||
include/flatbuffers/idl.h
|
include/flatbuffers/idl.h
|
||||||
include/flatbuffers/util.h
|
include/flatbuffers/util.h
|
||||||
include/flatbuffers/reflection.h
|
include/flatbuffers/reflection.h
|
||||||
include/flatbuffers/reflection_generated.h
|
include/flatbuffers/reflection_generated.h
|
||||||
|
include/flatbuffers/stl_emulation.h
|
||||||
|
include/flatbuffers/flexbuffers.h
|
||||||
|
include/flatbuffers/registry.h
|
||||||
|
include/flatbuffers/minireflect.h
|
||||||
|
src/code_generators.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
|
||||||
|
src/util.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FlatBuffers_Compiler_SRCS
|
set(FlatBuffers_Compiler_SRCS
|
||||||
${FlatBuffers_Library_SRCS}
|
${FlatBuffers_Library_SRCS}
|
||||||
src/idl_gen_cpp.cpp
|
src/idl_gen_cpp.cpp
|
||||||
|
src/idl_gen_dart.cpp
|
||||||
src/idl_gen_general.cpp
|
src/idl_gen_general.cpp
|
||||||
src/idl_gen_go.cpp
|
src/idl_gen_go.cpp
|
||||||
src/idl_gen_js.cpp
|
src/idl_gen_js_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_lua.cpp
|
||||||
|
src/idl_gen_rust.cpp
|
||||||
src/idl_gen_fbs.cpp
|
src/idl_gen_fbs.cpp
|
||||||
|
src/idl_gen_grpc.cpp
|
||||||
|
src/idl_gen_json_schema.cpp
|
||||||
src/flatc.cpp
|
src/flatc.cpp
|
||||||
|
src/flatc_main.cpp
|
||||||
|
grpc/src/compiler/schema_interface.h
|
||||||
|
grpc/src/compiler/cpp_generator.h
|
||||||
|
grpc/src/compiler/cpp_generator.cc
|
||||||
|
grpc/src/compiler/go_generator.h
|
||||||
|
grpc/src/compiler/go_generator.cc
|
||||||
|
grpc/src/compiler/java_generator.h
|
||||||
|
grpc/src/compiler/java_generator.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FlatHash_SRCS
|
set(FlatHash_SRCS
|
||||||
@@ -48,8 +106,11 @@ 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
|
||||||
src/idl_gen_general.cpp
|
|
||||||
tests/test.cpp
|
tests/test.cpp
|
||||||
|
tests/test_assert.h
|
||||||
|
tests/test_assert.cpp
|
||||||
|
tests/test_builder.h
|
||||||
|
tests/test_builder.cpp
|
||||||
# file generate by running compiler on tests/monster_test.fbs
|
# file generate by running compiler on tests/monster_test.fbs
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
|
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
|
||||||
)
|
)
|
||||||
@@ -62,31 +123,100 @@ set(FlatBuffers_Sample_Binary_SRCS
|
|||||||
)
|
)
|
||||||
|
|
||||||
set(FlatBuffers_Sample_Text_SRCS
|
set(FlatBuffers_Sample_Text_SRCS
|
||||||
include/flatbuffers/flatbuffers.h
|
${FlatBuffers_Library_SRCS}
|
||||||
include/flatbuffers/hash.h
|
|
||||||
include/flatbuffers/idl.h
|
|
||||||
include/flatbuffers/util.h
|
|
||||||
src/idl_parser.cpp
|
|
||||||
src/idl_gen_text.cpp
|
|
||||||
samples/sample_text.cpp
|
samples/sample_text.cpp
|
||||||
# file generated by running compiler on samples/monster.fbs
|
# file generated by running compiler on samples/monster.fbs
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(FlatBuffers_Sample_BFBS_SRCS
|
||||||
|
${FlatBuffers_Library_SRCS}
|
||||||
|
src/idl_gen_general.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
|
||||||
|
include/flatbuffers/flatbuffers.h
|
||||||
|
include/flatbuffers/grpc.h
|
||||||
|
tests/monster_test.grpc.fb.h
|
||||||
|
tests/test_assert.h
|
||||||
|
tests/test_builder.h
|
||||||
|
tests/monster_test.grpc.fb.cc
|
||||||
|
tests/test_assert.cpp
|
||||||
|
tests/test_builder.cpp
|
||||||
|
grpc/tests/grpctest.cpp
|
||||||
|
grpc/tests/message_builder_test.cpp
|
||||||
|
# file generated by running compiler on samples/monster.fbs
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||||
|
)
|
||||||
|
|
||||||
# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS})
|
# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS})
|
||||||
# source_group(Tests FILES ${FlatBuffers_Tests_SRCS})
|
# source_group(Tests FILES ${FlatBuffers_Tests_SRCS})
|
||||||
|
|
||||||
if(APPLE)
|
if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||||
set(CMAKE_CXX_FLAGS
|
# do not apply any global settings if the toolchain
|
||||||
"${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++ -Wall -pedantic -Werror -Wextra")
|
# is being configured externally
|
||||||
|
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
|
||||||
|
elseif(APPLE)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Wno-unused-parameter")
|
||||||
|
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
|
||||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
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
|
set(CMAKE_CXX_FLAGS
|
||||||
"${CMAKE_CXX_FLAGS} -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow -Wunused-result -Werror=unused-result")
|
"${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Werror=shadow")
|
||||||
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
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
|
set(CMAKE_CXX_FLAGS
|
||||||
"${CMAKE_CXX_FLAGS} -std=c++0x -stdlib=libc++ -Wall -pedantic -Werror -Wextra")
|
"${CMAKE_CXX_FLAGS} -fsigned-char")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS
|
|
||||||
"${CMAKE_EXE_LINKER_FLAGS} -lc++abi")
|
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
||||||
|
set(CMAKE_CXX_FLAGS
|
||||||
|
"${CMAKE_CXX_FLAGS} -std=c++0x -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")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FLATBUFFERS_CODE_COVERAGE)
|
if(FLATBUFFERS_CODE_COVERAGE)
|
||||||
@@ -95,31 +225,87 @@ if(FLATBUFFERS_CODE_COVERAGE)
|
|||||||
"${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
"${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
function(add_fsanitize_to_target _target _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".
|
||||||
|
if((${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") OR
|
||||||
|
((${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9"))
|
||||||
|
)
|
||||||
|
set(_sanitizer_flags "=address,undefined")
|
||||||
|
if(_sanitizer MATCHES "=.*")
|
||||||
|
# override default by user-defined sanitizer list
|
||||||
|
set(_sanitizer_flags ${_sanitizer})
|
||||||
|
endif()
|
||||||
|
target_compile_options(${_target} PRIVATE
|
||||||
|
-g -fsigned-char -fno-omit-frame-pointer
|
||||||
|
"-fsanitize${_sanitizer_flags}")
|
||||||
|
target_link_libraries(${_target} PRIVATE
|
||||||
|
"-fsanitize${_sanitizer_flags}")
|
||||||
|
set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
|
message(STATUS "Sanitizer ${_sanitizer_flags} added to ${_target}")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
if(BIICODE)
|
if(BIICODE)
|
||||||
include(biicode/cmake/biicode.cmake)
|
include(biicode/cmake/biicode.cmake)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(include)
|
include_directories(include)
|
||||||
|
include_directories(grpc)
|
||||||
|
|
||||||
if(FLATBUFFERS_BUILD_FLATLIB)
|
if(FLATBUFFERS_BUILD_FLATLIB)
|
||||||
add_library(flatbuffers STATIC ${FlatBuffers_Library_SRCS})
|
add_library(flatbuffers STATIC ${FlatBuffers_Library_SRCS})
|
||||||
|
# CMake > 2.8.11: Attach header directory for when build via add_subdirectory().
|
||||||
|
target_include_directories(flatbuffers INTERFACE
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
||||||
|
target_compile_options(flatbuffers PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FLATBUFFERS_BUILD_FLATC)
|
if(FLATBUFFERS_BUILD_FLATC)
|
||||||
add_executable(flatc ${FlatBuffers_Compiler_SRCS})
|
add_executable(flatc ${FlatBuffers_Compiler_SRCS})
|
||||||
|
target_compile_options(flatc PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
|
||||||
|
if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
|
||||||
|
add_fsanitize_to_target(flatc ${FLATBUFFERS_CODE_SANITIZE})
|
||||||
|
endif()
|
||||||
|
if(NOT FLATBUFFERS_FLATC_EXECUTABLE)
|
||||||
|
set(FLATBUFFERS_FLATC_EXECUTABLE $<TARGET_FILE:flatc>)
|
||||||
|
endif()
|
||||||
|
if(MSVC)
|
||||||
|
# Make flatc.exe not depend on runtime dlls for easy distribution.
|
||||||
|
target_compile_options(flatc PUBLIC $<$<CONFIG:Release>:/MT>)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FLATBUFFERS_BUILD_FLATHASH)
|
if(FLATBUFFERS_BUILD_FLATHASH)
|
||||||
add_executable(flathash ${FlatHash_SRCS})
|
add_executable(flathash ${FlatHash_SRCS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
||||||
|
add_library(flatbuffers_shared SHARED ${FlatBuffers_Library_SRCS})
|
||||||
|
|
||||||
|
# Shared object version: "major.minor.micro"
|
||||||
|
# - micro updated every release when there is no API/ABI changes
|
||||||
|
# - minor updated when there are additions in API/ABI
|
||||||
|
# - major (ABI number) updated when there are changes in ABI (or removals)
|
||||||
|
set(FlatBuffers_Library_SONAME_MAJOR "1")
|
||||||
|
set(FlatBuffers_Library_SONAME_FULL "${FlatBuffers_Library_SONAME_MAJOR}.11.0")
|
||||||
|
set_target_properties(flatbuffers_shared PROPERTIES OUTPUT_NAME flatbuffers
|
||||||
|
SOVERSION "${FlatBuffers_Library_SONAME_MAJOR}"
|
||||||
|
VERSION "${FlatBuffers_Library_SONAME_FULL}")
|
||||||
|
endif()
|
||||||
|
|
||||||
function(compile_flatbuffers_schema_to_cpp SRC_FBS)
|
function(compile_flatbuffers_schema_to_cpp SRC_FBS)
|
||||||
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$" "_generated.h" GEN_HEADER ${SRC_FBS})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${GEN_HEADER}
|
OUTPUT ${GEN_HEADER}
|
||||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -c --no-includes --gen-mutable -o "${SRC_FBS_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -c --no-includes --gen-mutable
|
||||||
|
--gen-object-api --gen-compare -o "${SRC_FBS_DIR}"
|
||||||
|
--cpp-ptr-type flatbuffers::unique_ptr # Used to test with C++98 STLs
|
||||||
|
--reflect-names
|
||||||
|
-I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||||
DEPENDS flatc)
|
DEPENDS flatc)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
@@ -128,7 +314,8 @@ function(compile_flatbuffers_schema_to_binary SRC_FBS)
|
|||||||
string(REGEX REPLACE "\\.fbs$" ".bfbs" GEN_BINARY_SCHEMA ${SRC_FBS})
|
string(REGEX REPLACE "\\.fbs$" ".bfbs" GEN_BINARY_SCHEMA ${SRC_FBS})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${GEN_BINARY_SCHEMA}
|
OUTPUT ${GEN_BINARY_SCHEMA}
|
||||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -b --schema -o "${SRC_FBS_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -b --schema -o "${SRC_FBS_DIR}"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||||
DEPENDS flatc)
|
DEPENDS flatc)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
@@ -136,20 +323,116 @@ if(FLATBUFFERS_BUILD_TESTS)
|
|||||||
compile_flatbuffers_schema_to_cpp(tests/monster_test.fbs)
|
compile_flatbuffers_schema_to_cpp(tests/monster_test.fbs)
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests)
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests)
|
||||||
add_executable(flattests ${FlatBuffers_Tests_SRCS})
|
add_executable(flattests ${FlatBuffers_Tests_SRCS})
|
||||||
|
set_property(TARGET flattests
|
||||||
|
PROPERTY COMPILE_DEFINITIONS FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
|
||||||
|
FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1)
|
||||||
|
if(FLATBUFFERS_CODE_SANITIZE)
|
||||||
|
if(WIN32)
|
||||||
|
target_compile_definitions(flattests PRIVATE FLATBUFFERS_MEMORY_LEAK_TRACKING)
|
||||||
|
message(STATUS "Sanitizer MSVC::_CrtDumpMemoryLeaks added to flattests")
|
||||||
|
else()
|
||||||
|
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
compile_flatbuffers_schema_to_cpp(samples/monster.fbs)
|
compile_flatbuffers_schema_to_cpp(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_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
|
add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
|
||||||
|
add_executable(flatsamplebfbs ${FlatBuffers_Sample_BFBS_SRCS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FLATBUFFERS_INSTALL)
|
if(FLATBUFFERS_BUILD_GRPCTEST)
|
||||||
install(DIRECTORY include/flatbuffers DESTINATION include)
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
if(FLATBUFFERS_BUILD_FLATLIB)
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-shadow")
|
||||||
install(TARGETS flatbuffers DESTINATION lib)
|
|
||||||
endif()
|
endif()
|
||||||
|
if(NOT GRPC_INSTALL_PATH)
|
||||||
|
message(SEND_ERROR "GRPC_INSTALL_PATH variable is not defined. See grpc/README.md")
|
||||||
|
endif()
|
||||||
|
if(NOT PROTOBUF_DOWNLOAD_PATH)
|
||||||
|
message(SEND_ERROR "PROTOBUF_DOWNLOAD_PATH variable is not defined. See grpc/README.md")
|
||||||
|
endif()
|
||||||
|
INCLUDE_DIRECTORIES(${GRPC_INSTALL_PATH}/include)
|
||||||
|
INCLUDE_DIRECTORIES(${PROTOBUF_DOWNLOAD_PATH}/src)
|
||||||
|
LINK_DIRECTORIES(${GRPC_INSTALL_PATH}/lib)
|
||||||
|
add_executable(grpctest ${FlatBuffers_GRPCTest_SRCS})
|
||||||
|
target_link_libraries(grpctest grpc++_unsecure grpc_unsecure gpr pthread dl)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CMake/Version.cmake)
|
||||||
|
|
||||||
|
if(FLATBUFFERS_INSTALL)
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
install(DIRECTORY include/flatbuffers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||||
|
|
||||||
|
set(FB_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/flatbuffers")
|
||||||
|
|
||||||
|
configure_file(CMake/FlatbuffersConfigVersion.cmake.in FlatbuffersConfigVersion.cmake @ONLY)
|
||||||
|
install(
|
||||||
|
FILES "CMake/FlatbuffersConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/FlatbuffersConfigVersion.cmake"
|
||||||
|
DESTINATION ${FB_CMAKE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(FLATBUFFERS_BUILD_FLATLIB)
|
||||||
|
if(CMAKE_VERSION VERSION_LESS 3.0)
|
||||||
|
install(
|
||||||
|
TARGETS flatbuffers EXPORT FlatbuffersTargets
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
install(
|
||||||
|
TARGETS flatbuffers EXPORT FlatbuffersTargets
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(EXPORT FlatbuffersTargets
|
||||||
|
FILE FlatbuffersTargets.cmake
|
||||||
|
NAMESPACE flatbuffers::
|
||||||
|
DESTINATION ${FB_CMAKE_DIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(FLATBUFFERS_BUILD_FLATC)
|
if(FLATBUFFERS_BUILD_FLATC)
|
||||||
install(TARGETS flatc DESTINATION bin)
|
install(
|
||||||
|
TARGETS flatc EXPORT FlatcTargets
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
EXPORT FlatcTargets
|
||||||
|
FILE FlatcTargets.cmake
|
||||||
|
NAMESPACE flatbuffers::
|
||||||
|
DESTINATION ${FB_CMAKE_DIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
||||||
|
if(CMAKE_VERSION VERSION_LESS 3.0)
|
||||||
|
install(
|
||||||
|
TARGETS flatbuffers_shared EXPORT FlatbuffersSharedTargets
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
)
|
||||||
|
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(
|
||||||
|
EXPORT FlatbuffersSharedTargets
|
||||||
|
FILE FlatbuffersSharedTargets.cmake
|
||||||
|
NAMESPACE flatbuffers::
|
||||||
|
DESTINATION ${FB_CMAKE_DIR}
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -159,6 +442,20 @@ if(FLATBUFFERS_BUILD_TESTS)
|
|||||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests" DESTINATION
|
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests" DESTINATION
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}")
|
"${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
add_test(NAME flattests COMMAND flattests)
|
add_test(NAME flattests COMMAND flattests)
|
||||||
|
if(FLATBUFFERS_BUILD_GRPCTEST)
|
||||||
|
add_test(NAME grpctest COMMAND grpctest)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(CMake/BuildFlatBuffers.cmake)
|
include(CMake/BuildFlatBuffers.cmake)
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
# Use of CPack only supported on Linux systems.
|
||||||
|
if(FLATBUFFERS_PACKAGE_DEBIAN)
|
||||||
|
include(CMake/PackageDebian.cmake)
|
||||||
|
endif()
|
||||||
|
if (FLATBUFFERS_PACKAGE_REDHAT)
|
||||||
|
include(CMake/PackageRedhat.cmake)
|
||||||
|
endif()
|
||||||
|
include(CPack)
|
||||||
|
endif()
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ use Github pull requests for this purpose.
|
|||||||
|
|
||||||
Some tips for good pull requests:
|
Some tips for good pull requests:
|
||||||
* Use our code
|
* Use our code
|
||||||
[style guide](http://google-styleguide.googlecode.com/svn/trunk/cppguide.html).
|
[style guide](https://google.github.io/styleguide/cppguide.html).
|
||||||
When in doubt, try to stay true to the existing code of the project.
|
When in doubt, try to stay true to the existing code of the project.
|
||||||
* 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:
|
||||||
15
WORKSPACE
Normal file
15
WORKSPACE
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
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 = "492c3ac68ed9dcf527a07e6a1b2dcbf199c6bf8b35517951467ac32e421c06c1",
|
||||||
|
urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.17.0/rules_go-0.17.0.tar.gz"],
|
||||||
|
)
|
||||||
|
|
||||||
|
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
|
||||||
|
|
||||||
|
go_rules_dependencies()
|
||||||
|
|
||||||
|
go_register_toolchains()
|
||||||
0
android/.project
Executable file → Normal file
0
android/.project
Executable file → Normal file
11
android/AndroidManifest.xml
Executable file → Normal file
11
android/AndroidManifest.xml
Executable file → Normal file
@@ -17,17 +17,14 @@
|
|||||||
-->
|
-->
|
||||||
<!-- 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">
|
||||||
android:versionCode="1"
|
|
||||||
android:versionName="1.0">
|
|
||||||
|
|
||||||
<uses-feature android:glEsVersion="0x00020000"></uses-feature>
|
<uses-feature android:glEsVersion="0x00020000"></uses-feature>
|
||||||
<!-- This is the platform API where NativeActivity was introduced. -->
|
|
||||||
<uses-sdk android:minSdkVersion="9" />
|
|
||||||
|
|
||||||
<!-- 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" android:hasCode="false">
|
<application android:label="@string/app_name"
|
||||||
|
android:hasCode="false"
|
||||||
|
android:allowBackup="false">
|
||||||
<!-- Our activity is the built-in NativeActivity framework class.
|
<!-- Our activity is the built-in NativeActivity framework class.
|
||||||
This will take care of integrating with our NDK code. -->
|
This will take care of integrating with our NDK code. -->
|
||||||
<activity android:name="android.app.NativeActivity"
|
<activity android:name="android.app.NativeActivity"
|
||||||
|
|||||||
108
android/build.gradle
Normal file
108
android/build.gradle
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
// Copyright (c) 2017 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.
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:2.3.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 25
|
||||||
|
buildToolsVersion '25.0.2'
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
manifest.srcFile 'AndroidManifest.xml'
|
||||||
|
res.srcDirs = ['res']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
externalNativeBuild {
|
||||||
|
ndkBuild {
|
||||||
|
path "jni/Android.mk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId 'com.example.FlatBufferTest'
|
||||||
|
// This is the platform API where NativeActivity was introduced.
|
||||||
|
minSdkVersion 9
|
||||||
|
targetSdkVersion 25
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
externalNativeBuild {
|
||||||
|
ndkBuild {
|
||||||
|
targets "FlatBufferTest"
|
||||||
|
arguments "-j" + Runtime.getRuntime().availableProcessors()
|
||||||
|
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lintOptions {
|
||||||
|
abortOnError false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build with each STL variant.
|
||||||
|
productFlavors {
|
||||||
|
stlport {
|
||||||
|
applicationIdSuffix ".stlport"
|
||||||
|
versionNameSuffix "-stlport"
|
||||||
|
externalNativeBuild {
|
||||||
|
ndkBuild {
|
||||||
|
arguments "APP_STL=stlport_static"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gnustl {
|
||||||
|
applicationIdSuffix ".gnustl"
|
||||||
|
versionNameSuffix "-gnustl"
|
||||||
|
externalNativeBuild {
|
||||||
|
ndkBuild {
|
||||||
|
arguments "APP_STL=gnustl_static"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
libcpp {
|
||||||
|
applicationIdSuffix ".libcpp"
|
||||||
|
versionNameSuffix "-libcpp"
|
||||||
|
externalNativeBuild {
|
||||||
|
ndkBuild {
|
||||||
|
arguments "APP_STL=c++_static"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,510 +0,0 @@
|
|||||||
#!/bin/bash -eu
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
# Build, deploy, debug / execute a native Android package based upon
|
|
||||||
# NativeActivity.
|
|
||||||
|
|
||||||
declare -r script_directory=$(dirname $0)
|
|
||||||
declare -r android_root=${script_directory}/../../../../../../
|
|
||||||
declare -r script_name=$(basename $0)
|
|
||||||
declare -r android_manifest=AndroidManifest.xml
|
|
||||||
declare -r os_name=$(uname -s)
|
|
||||||
|
|
||||||
# Minimum Android target version supported by this project.
|
|
||||||
: ${BUILDAPK_ANDROID_TARGET_MINVERSION:=10}
|
|
||||||
# Directory containing the Android SDK
|
|
||||||
# (http://developer.android.com/sdk/index.html).
|
|
||||||
: ${ANDROID_SDK_HOME:=}
|
|
||||||
# Directory containing the Android NDK
|
|
||||||
# (http://developer.android.com/tools/sdk/ndk/index.html).
|
|
||||||
: ${NDK_HOME:=}
|
|
||||||
|
|
||||||
# Display script help and exit.
|
|
||||||
usage() {
|
|
||||||
echo "
|
|
||||||
Build the Android package in the current directory and deploy it to a
|
|
||||||
connected device.
|
|
||||||
|
|
||||||
Usage: ${script_name} \\
|
|
||||||
[ADB_DEVICE=serial_number] [BUILD=0] [DEPLOY=0] [RUN_DEBUGGER=1] \
|
|
||||||
[LAUNCH=0] [SWIG_BIN=swig_binary_directory] [SWIG_LIB=swig_include_directory] [ndk-build arguments ...]
|
|
||||||
|
|
||||||
ADB_DEVICE=serial_number:
|
|
||||||
serial_number specifies the device to deploy the built apk to if multiple
|
|
||||||
Android devices are connected to the host.
|
|
||||||
BUILD=0:
|
|
||||||
Disables the build of the package.
|
|
||||||
DEPLOY=0:
|
|
||||||
Disables the deployment of the built apk to the Android device.
|
|
||||||
RUN_DEBUGGER=1:
|
|
||||||
Launches the application in gdb after it has been deployed. To debug in
|
|
||||||
gdb, NDK_DEBUG=1 must also be specified on the command line to build a
|
|
||||||
debug apk.
|
|
||||||
LAUNCH=0:
|
|
||||||
Disable the launch of the apk on the Android device.
|
|
||||||
SWIG_BIN=swig_binary_directory:
|
|
||||||
The directory where the SWIG binary lives. No need to set this if SWIG is
|
|
||||||
installed and point to from your PATH variable.
|
|
||||||
SWIG_LIB=swig_include_directory:
|
|
||||||
The directory where SWIG shared include files are, usually obtainable from
|
|
||||||
commandline with \"swig -swiglib\". No need to set this if SWIG is installed
|
|
||||||
and point to from your PATH variable.
|
|
||||||
ndk-build arguments...:
|
|
||||||
Additional arguments for ndk-build. See ndk-build -h for more information.
|
|
||||||
" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get the number of CPU cores present on the host.
|
|
||||||
get_number_of_cores() {
|
|
||||||
case ${os_name} in
|
|
||||||
Darwin)
|
|
||||||
sysctl hw.ncpu | awk '{ print $2 }'
|
|
||||||
;;
|
|
||||||
CYGWIN*|Linux)
|
|
||||||
awk '/^processor/ { n=$3 } END { print n + 1 }' /proc/cpuinfo
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get the package name from an AndroidManifest.xml file.
|
|
||||||
get_package_name_from_manifest() {
|
|
||||||
xmllint --xpath 'string(/manifest/@package)' "${1}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get the library name from an AndroidManifest.xml file.
|
|
||||||
get_library_name_from_manifest() {
|
|
||||||
echo "\
|
|
||||||
setns android=http://schemas.android.com/apk/res/android
|
|
||||||
xpath string(/manifest/application/activity\
|
|
||||||
[@android:name=\"android.app.NativeActivity\"]/meta-data\
|
|
||||||
[@android:name=\"android.app.lib_name\"]/@android:value)" |
|
|
||||||
xmllint --shell "${1}" | awk '/Object is a string/ { print $NF }'
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get the number of Android devices connected to the system.
|
|
||||||
get_number_of_devices_connected() {
|
|
||||||
adb devices -l | \
|
|
||||||
awk '/^..*$/ { if (p) { print $0 } }
|
|
||||||
/List of devices attached/ { p = 1 }' | \
|
|
||||||
wc -l
|
|
||||||
return ${PIPESTATUS[0]}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Kill a process and its' children. This is provided for cygwin which
|
|
||||||
# doesn't ship with pkill.
|
|
||||||
kill_process_group() {
|
|
||||||
local parent_pid="${1}"
|
|
||||||
local child_pid=
|
|
||||||
for child_pid in $(ps -f | \
|
|
||||||
awk '{ if ($3 == '"${parent_pid}"') { print $2 } }'); do
|
|
||||||
kill_process_group "${child_pid}"
|
|
||||||
done
|
|
||||||
kill "${parent_pid}" 2>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
# Find and run "adb".
|
|
||||||
adb() {
|
|
||||||
local adb_path=
|
|
||||||
for path in "$(which adb 2>/dev/null)" \
|
|
||||||
"${ANDROID_SDK_HOME}/sdk/platform-tools/adb" \
|
|
||||||
"${android_root}/prebuilts/sdk/platform-tools/adb"; do
|
|
||||||
if [[ -e "${path}" ]]; then
|
|
||||||
adb_path="${path}"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [[ "${adb_path}" == "" ]]; then
|
|
||||||
echo -e "Unable to find adb." \
|
|
||||||
"\nAdd the Android ADT sdk/platform-tools directory to the" \
|
|
||||||
"PATH." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
"${adb_path}" "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Find and run "android".
|
|
||||||
android() {
|
|
||||||
local android_executable=android
|
|
||||||
if echo "${os_name}" | grep -q CYGWIN; then
|
|
||||||
android_executable=android.bat
|
|
||||||
fi
|
|
||||||
local android_path=
|
|
||||||
for path in "$(which ${android_executable})" \
|
|
||||||
"${ANDROID_SDK_HOME}/sdk/tools/${android_executable}" \
|
|
||||||
"${android_root}/prebuilts/sdk/tools/${android_executable}"; do
|
|
||||||
if [[ -e "${path}" ]]; then
|
|
||||||
android_path="${path}"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [[ "${android_path}" == "" ]]; then
|
|
||||||
echo -e "Unable to find android tool." \
|
|
||||||
"\nAdd the Android ADT sdk/tools directory to the PATH." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# Make sure ant is installed.
|
|
||||||
if [[ "$(which ant)" == "" ]]; then
|
|
||||||
echo -e "Unable to find ant." \
|
|
||||||
"\nPlease install ant and add to the PATH." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
"${android_path}" "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Find and run "ndk-build"
|
|
||||||
ndkbuild() {
|
|
||||||
local ndkbuild_path=
|
|
||||||
for path in "$(which ndk-build 2>/dev/null)" \
|
|
||||||
"${NDK_HOME}/ndk-build" \
|
|
||||||
"${android_root}/prebuilts/ndk/current/ndk-build"; do
|
|
||||||
if [[ -e "${path}" ]]; then
|
|
||||||
ndkbuild_path="${path}"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [[ "${ndkbuild_path}" == "" ]]; then
|
|
||||||
echo -e "Unable to find ndk-build." \
|
|
||||||
"\nAdd the Android NDK directory to the PATH." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
"${ndkbuild_path}" "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get file modification time of $1 in seconds since the epoch.
|
|
||||||
stat_mtime() {
|
|
||||||
local filename="${1}"
|
|
||||||
case ${os_name} in
|
|
||||||
Darwin) stat -f%m "${filename}" 2>/dev/null || echo 0 ;;
|
|
||||||
*) stat -c%Y "${filename}" 2>/dev/null || echo 0 ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
# Build the native (C/C++) build targets in the current directory.
|
|
||||||
build_native_targets() {
|
|
||||||
# Save the list of output modules in the install directory so that it's
|
|
||||||
# possible to restore their timestamps after the build is complete. This
|
|
||||||
# works around a bug in ndk/build/core/setup-app.mk which results in the
|
|
||||||
# unconditional execution of the clean-installed-binaries rule.
|
|
||||||
restore_libraries="$(find libs -type f 2>/dev/null | \
|
|
||||||
sed -E 's@^libs/(.*)@\1@')"
|
|
||||||
|
|
||||||
# Build native code.
|
|
||||||
ndkbuild -j$(get_number_of_cores) "$@"
|
|
||||||
|
|
||||||
# Restore installed libraries.
|
|
||||||
# Obviously this is a nasty hack (along with ${restore_libraries} above) as
|
|
||||||
# it assumes it knows where the NDK will be placing output files.
|
|
||||||
(
|
|
||||||
IFS=$'\n'
|
|
||||||
for libpath in ${restore_libraries}; do
|
|
||||||
source_library="obj/local/${libpath}"
|
|
||||||
target_library="libs/${libpath}"
|
|
||||||
if [[ -e "${source_library}" ]]; then
|
|
||||||
cp -a "${source_library}" "${target_library}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
# Select the oldest installed android build target that is at least as new as
|
|
||||||
# BUILDAPK_ANDROID_TARGET_MINVERSION. If a suitable build target isn't found,
|
|
||||||
# this function prints an error message and exits with an error.
|
|
||||||
select_android_build_target() {
|
|
||||||
local -r android_targets_installed=$( \
|
|
||||||
android list targets | \
|
|
||||||
awk -F'"' '/^id:.*android/ { print $2 }')
|
|
||||||
local android_build_target=
|
|
||||||
for android_target in $(echo "${android_targets_installed}" | \
|
|
||||||
awk -F- '{ print $2 }' | sort -n); do
|
|
||||||
local isNumber='^[0-9]+$'
|
|
||||||
# skip preview API releases e.g. 'android-L'
|
|
||||||
if [[ $android_target =~ $isNumber ]]; then
|
|
||||||
if [[ $((android_target)) -ge \
|
|
||||||
$((BUILDAPK_ANDROID_TARGET_MINVERSION)) ]]; then
|
|
||||||
android_build_target="android-${android_target}"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
# else
|
|
||||||
# The API version is a letter, so skip it.
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [[ "${android_build_target}" == "" ]]; then
|
|
||||||
echo -e \
|
|
||||||
"Found installed Android targets:" \
|
|
||||||
"$(echo ${android_targets_installed} | sed 's/ /\n /g;s/^/\n /;')" \
|
|
||||||
"\nAndroid SDK platform" \
|
|
||||||
"android-$((BUILDAPK_ANDROID_TARGET_MINVERSION))" \
|
|
||||||
"must be installed to build this project." \
|
|
||||||
"\nUse the \"android\" application to install API" \
|
|
||||||
"$((BUILDAPK_ANDROID_TARGET_MINVERSION)) or newer." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "${android_build_target}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Sign unsigned apk $1 and write the result to $2 with key store file $3 and
|
|
||||||
# password $4.
|
|
||||||
# If a key store file $3 and password $4 aren't specified, a temporary
|
|
||||||
# (60 day) key is generated and used to sign the package.
|
|
||||||
sign_apk() {
|
|
||||||
local unsigned_apk="${1}"
|
|
||||||
local signed_apk="${2}"
|
|
||||||
if [[ $(stat_mtime "${unsigned_apk}") -gt \
|
|
||||||
$(stat_mtime "${signed_apk}") ]]; then
|
|
||||||
local -r key_alias=$(basename ${signed_apk} .apk)
|
|
||||||
local keystore="${3}"
|
|
||||||
local key_password="${4}"
|
|
||||||
[[ "${keystore}" == "" ]] && keystore="${unsigned_apk}.keystore"
|
|
||||||
[[ "${key_password}" == "" ]] && \
|
|
||||||
key_password="${key_alias}123456"
|
|
||||||
if [[ ! -e ${keystore} ]]; then
|
|
||||||
keytool -genkey -v -dname "cn=, ou=${key_alias}, o=fpl" \
|
|
||||||
-storepass ${key_password} \
|
|
||||||
-keypass ${key_password} -keystore ${keystore} \
|
|
||||||
-alias ${key_alias} -keyalg RSA -keysize 2048 -validity 60
|
|
||||||
fi
|
|
||||||
cp "${unsigned_apk}" "${signed_apk}"
|
|
||||||
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 \
|
|
||||||
-keystore ${keystore} -storepass ${key_password} \
|
|
||||||
-keypass ${key_password} "${signed_apk}" ${key_alias}
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Build the apk $1 for package filename $2 in the current directory using the
|
|
||||||
# ant build target $3.
|
|
||||||
build_apk() {
|
|
||||||
local -r output_apk="${1}"
|
|
||||||
local -r package_filename="${2}"
|
|
||||||
local -r ant_target="${3}"
|
|
||||||
# Get the list of installed android targets and select the oldest target
|
|
||||||
# that is at least as new as BUILDAPK_ANDROID_TARGET_MINVERSION.
|
|
||||||
local -r android_build_target=$(select_android_build_target)
|
|
||||||
[[ "${android_build_target}" == "" ]] && exit 1
|
|
||||||
echo "Building ${output_apk} for target ${android_build_target}" >&2
|
|
||||||
|
|
||||||
# Create / update build.xml and local.properties files.
|
|
||||||
if [[ $(stat_mtime "${android_manifest}") -gt \
|
|
||||||
$(stat_mtime build.xml) ]]; then
|
|
||||||
android update project --target "${android_build_target}" \
|
|
||||||
-n ${package_filename} --path .
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use ant to build the apk.
|
|
||||||
ant -quiet ${ant_target}
|
|
||||||
|
|
||||||
# Sign release apks with a temporary key as these packages will not be
|
|
||||||
# redistributed.
|
|
||||||
local unsigned_apk="bin/${package_filename}-${ant_target}-unsigned.apk"
|
|
||||||
if [[ "${ant_target}" == "release" ]]; then
|
|
||||||
sign_apk "${unsigned_apk}" "${output_apk}" "" ""
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Uninstall package $1 and install apk $2 on device $3 where $3 is "-s device"
|
|
||||||
# or an empty string. If $3 is an empty string adb will fail when multiple
|
|
||||||
# devices are connected to the host system.
|
|
||||||
install_apk() {
|
|
||||||
local -r uninstall_package_name="${1}"
|
|
||||||
local -r install_apk="${2}"
|
|
||||||
local -r adb_device="${3}"
|
|
||||||
# Uninstall the package if it's already installed.
|
|
||||||
adb ${adb_device} uninstall "${uninstall_package_name}" 1>&2 > /dev/null || \
|
|
||||||
true # no error check
|
|
||||||
|
|
||||||
# Install the apk.
|
|
||||||
# NOTE: The following works around adb not returning an error code when
|
|
||||||
# it fails to install an apk.
|
|
||||||
echo "Install ${install_apk}" >&2
|
|
||||||
local -r adb_install_result=$(adb ${adb_device} install "${install_apk}")
|
|
||||||
echo "${adb_install_result}"
|
|
||||||
if echo "${adb_install_result}" | grep -qF 'Failure ['; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Launch previously installed package $1 on device $2.
|
|
||||||
# If $2 is an empty string adb will fail when multiple devices are connected
|
|
||||||
# to the host system.
|
|
||||||
launch_package() {
|
|
||||||
(
|
|
||||||
# Determine the SDK version of Android on the device.
|
|
||||||
local -r android_sdk_version=$(
|
|
||||||
adb ${adb_device} shell cat system/build.prop | \
|
|
||||||
awk -F= '/ro.build.version.sdk/ {
|
|
||||||
v=$2; sub(/[ \r\n]/, "", v); print v
|
|
||||||
}')
|
|
||||||
|
|
||||||
# Clear logs from previous runs.
|
|
||||||
# Note that logcat does not just 'tail' the logs, it dumps the entire log
|
|
||||||
# history.
|
|
||||||
adb ${adb_device} logcat -c
|
|
||||||
|
|
||||||
local finished_msg='Displayed '"${package_name}"
|
|
||||||
local timeout_msg='Activity destroy timeout.*'"${package_name}"
|
|
||||||
# Maximum time to wait before stopping log monitoring. 0 = infinity.
|
|
||||||
local launch_timeout=0
|
|
||||||
# If this is a Gingerbread device, kill log monitoring after 10 seconds.
|
|
||||||
if [[ $((android_sdk_version)) -le 10 ]]; then
|
|
||||||
launch_timeout=10
|
|
||||||
fi
|
|
||||||
# Display logcat in the background.
|
|
||||||
# Stop displaying the log when the app launch / execution completes or the
|
|
||||||
# logcat
|
|
||||||
(
|
|
||||||
adb ${adb_device} logcat | \
|
|
||||||
awk "
|
|
||||||
{
|
|
||||||
print \$0
|
|
||||||
}
|
|
||||||
|
|
||||||
/ActivityManager.*: ${finished_msg}/ {
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
/ActivityManager.*: ${timeout_msg}/ {
|
|
||||||
exit 0
|
|
||||||
}" &
|
|
||||||
adb_logcat_pid=$!;
|
|
||||||
if [[ $((launch_timeout)) -gt 0 ]]; then
|
|
||||||
sleep $((launch_timeout));
|
|
||||||
kill ${adb_logcat_pid};
|
|
||||||
else
|
|
||||||
wait ${adb_logcat_pid};
|
|
||||||
fi
|
|
||||||
) &
|
|
||||||
logcat_pid=$!
|
|
||||||
# Kill adb logcat if this shell exits.
|
|
||||||
trap "kill_process_group ${logcat_pid}" SIGINT SIGTERM EXIT
|
|
||||||
|
|
||||||
# If the SDK is newer than 10, "am" supports stopping an activity.
|
|
||||||
adb_stop_activity=
|
|
||||||
if [[ $((android_sdk_version)) -gt 10 ]]; then
|
|
||||||
adb_stop_activity=-S
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Launch the activity and wait for it to complete.
|
|
||||||
adb ${adb_device} shell am start ${adb_stop_activity} -n \
|
|
||||||
${package_name}/android.app.NativeActivity
|
|
||||||
|
|
||||||
wait "${logcat_pid}"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
# See usage().
|
|
||||||
main() {
|
|
||||||
# Parse arguments for this script.
|
|
||||||
local adb_device=
|
|
||||||
local ant_target=release
|
|
||||||
local disable_deploy=0
|
|
||||||
local disable_build=0
|
|
||||||
local run_debugger=0
|
|
||||||
local launch=1
|
|
||||||
local build_package=1
|
|
||||||
for opt; do
|
|
||||||
case ${opt} in
|
|
||||||
# NDK_DEBUG=0 tells ndk-build to build this as debuggable but to not
|
|
||||||
# modify the underlying code whereas NDK_DEBUG=1 also builds as debuggable
|
|
||||||
# but does modify the code
|
|
||||||
NDK_DEBUG=1) ant_target=debug ;;
|
|
||||||
NDK_DEBUG=0) ant_target=debug ;;
|
|
||||||
ADB_DEVICE*) adb_device="$(\
|
|
||||||
echo "${opt}" | sed -E 's/^ADB_DEVICE=([^ ]+)$/-s \1/;t;s/.*//')" ;;
|
|
||||||
BUILD=0) disable_build=1 ;;
|
|
||||||
DEPLOY=0) disable_deploy=1 ;;
|
|
||||||
RUN_DEBUGGER=1) run_debugger=1 ;;
|
|
||||||
LAUNCH=0) launch=0 ;;
|
|
||||||
clean) build_package=0 disable_deploy=1 launch=0 ;;
|
|
||||||
-h|--help|help) usage ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# If a target device hasn't been specified and multiple devices are connected
|
|
||||||
# to the host machine, display an error.
|
|
||||||
local -r devices_connected=$(get_number_of_devices_connected)
|
|
||||||
if [[ "${adb_device}" == "" && $((devices_connected)) -gt 1 && \
|
|
||||||
($((disable_deploy)) -eq 0 || $((launch)) -ne 0 || \
|
|
||||||
$((run_debugger)) -ne 0) ]]; then
|
|
||||||
if [[ $((disable_deploy)) -ne 0 ]]; then
|
|
||||||
echo "Deployment enabled, disable using DEPLOY=0" >&2
|
|
||||||
fi
|
|
||||||
if [[ $((launch)) -ne 0 ]]; then
|
|
||||||
echo "Launch enabled." >&2
|
|
||||||
fi
|
|
||||||
if [[ $((disable_deploy)) -eq 0 ]]; then
|
|
||||||
echo "Deployment enabled." >&2
|
|
||||||
fi
|
|
||||||
if [[ $((run_debugger)) -ne 0 ]]; then
|
|
||||||
echo "Debugger launch enabled." >&2
|
|
||||||
fi
|
|
||||||
echo "
|
|
||||||
Multiple Android devices are connected to this host. Either disable deployment
|
|
||||||
and execution of the built .apk using:
|
|
||||||
\"${script_name} DEPLOY=0 LAUNCH=0\"
|
|
||||||
|
|
||||||
or specify a device to deploy to using:
|
|
||||||
\"${script_name} ADB_DEVICE=\${device_serial}\".
|
|
||||||
|
|
||||||
The Android devices connected to this machine are:
|
|
||||||
$(adb devices -l)
|
|
||||||
" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $((disable_build)) -eq 0 ]]; then
|
|
||||||
# Build the native target.
|
|
||||||
build_native_targets "$@"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get the package name from the manifest.
|
|
||||||
local -r package_name=$(get_package_name_from_manifest "${android_manifest}")
|
|
||||||
if [[ "${package_name}" == "" ]]; then
|
|
||||||
echo -e "No package name specified in ${android_manifest},"\
|
|
||||||
"skipping apk build, deploy"
|
|
||||||
"\nand launch steps." >&2
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
local -r package_basename=${package_name/*./}
|
|
||||||
local package_filename=$(get_library_name_from_manifest ${android_manifest})
|
|
||||||
[[ "${package_filename}" == "" ]] && package_filename="${package_basename}"
|
|
||||||
|
|
||||||
# Output apk name.
|
|
||||||
local -r output_apk="bin/${package_filename}-${ant_target}.apk"
|
|
||||||
|
|
||||||
if [[ $((disable_build)) -eq 0 && $((build_package)) -eq 1 ]]; then
|
|
||||||
# Build the apk.
|
|
||||||
build_apk "${output_apk}" "${package_filename}" "${ant_target}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Deploy to the device.
|
|
||||||
if [[ $((disable_deploy)) -eq 0 ]]; then
|
|
||||||
install_apk "${package_name}" "${output_apk}" "${adb_device}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${ant_target}" == "debug" && $((run_debugger)) -eq 1 ]]; then
|
|
||||||
# Start debugging.
|
|
||||||
ndk-gdb ${adb_device} --start
|
|
||||||
elif [[ $((launch)) -eq 1 ]]; then
|
|
||||||
launch_package "${package_name}" "${adb_device}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
BIN
android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#Mon Jun 19 11:54:59 PDT 2017
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip
|
||||||
172
android/gradlew
vendored
Executable file
172
android/gradlew
vendored
Executable file
@@ -0,0 +1,172 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
84
android/gradlew.bat
vendored
Normal file
84
android/gradlew.bat
vendored
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
15
android/jni/Android.mk
Executable file → Normal file
15
android/jni/Android.mk
Executable file → Normal file
@@ -24,7 +24,9 @@ LOCAL_PATH := $(call realpath-portable,$(LOCAL_PATH))
|
|||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
LOCAL_MODULE := flatbuffers
|
LOCAL_MODULE := flatbuffers
|
||||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
|
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
|
||||||
LOCAL_EXPORT_CPPFLAGS := -std=c++11 -fexceptions -Wall -Wno-literal-suffix
|
LOCAL_EXPORT_CPPFLAGS := -std=c++11 -fexceptions -Wall \
|
||||||
|
-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
|
||||||
|
|
||||||
include $(BUILD_STATIC_LIBRARY)
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
# static library that additionally includes text parsing/generation/reflection
|
# static library that additionally includes text parsing/generation/reflection
|
||||||
@@ -33,8 +35,11 @@ include $(CLEAR_VARS)
|
|||||||
LOCAL_MODULE := flatbuffers_extra
|
LOCAL_MODULE := flatbuffers_extra
|
||||||
LOCAL_SRC_FILES := src/idl_parser.cpp \
|
LOCAL_SRC_FILES := src/idl_parser.cpp \
|
||||||
src/idl_gen_text.cpp \
|
src/idl_gen_text.cpp \
|
||||||
src/reflection.cpp
|
src/reflection.cpp \
|
||||||
|
src/util.cpp \
|
||||||
|
src/code_generators.cpp
|
||||||
LOCAL_STATIC_LIBRARIES := flatbuffers
|
LOCAL_STATIC_LIBRARIES := flatbuffers
|
||||||
|
LOCAL_ARM_MODE := arm
|
||||||
include $(BUILD_STATIC_LIBRARY)
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
# FlatBuffers test
|
# FlatBuffers test
|
||||||
@@ -42,9 +47,13 @@ include $(CLEAR_VARS)
|
|||||||
LOCAL_MODULE := FlatBufferTest
|
LOCAL_MODULE := FlatBufferTest
|
||||||
LOCAL_SRC_FILES := android/jni/main.cpp \
|
LOCAL_SRC_FILES := android/jni/main.cpp \
|
||||||
tests/test.cpp \
|
tests/test.cpp \
|
||||||
|
tests/test_assert.h \
|
||||||
|
tests/test_builder.h \
|
||||||
|
tests/test_assert.cpp \
|
||||||
|
tests/test_builder.cpp \
|
||||||
src/idl_gen_fbs.cpp \
|
src/idl_gen_fbs.cpp \
|
||||||
src/idl_gen_general.cpp
|
src/idl_gen_general.cpp
|
||||||
LOCAL_LDLIBS := -llog -landroid
|
LOCAL_LDLIBS := -llog -landroid -latomic
|
||||||
LOCAL_STATIC_LIBRARIES := android_native_app_glue flatbuffers_extra
|
LOCAL_STATIC_LIBRARIES := android_native_app_glue flatbuffers_extra
|
||||||
LOCAL_ARM_MODE := arm
|
LOCAL_ARM_MODE := arm
|
||||||
include $(BUILD_SHARED_LIBRARY)
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
|||||||
6
android/jni/Application.mk
Executable file → Normal file
6
android/jni/Application.mk
Executable file → Normal file
@@ -13,10 +13,8 @@
|
|||||||
# 2. Altered source versions must be plainly marked as such, and must not be
|
# 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
# misrepresented as being the original software.
|
# misrepresented as being the original software.
|
||||||
# 3. This notice may not be removed or altered from any source distribution.
|
# 3. This notice may not be removed or altered from any source distribution.
|
||||||
APP_PLATFORM := android-10
|
APP_PLATFORM := android-9
|
||||||
APP_PROJECT_PATH := $(call my-dir)/..
|
APP_PROJECT_PATH := $(call my-dir)/..
|
||||||
APP_STL := gnustl_static
|
APP_STL ?= stlport_static
|
||||||
|
|
||||||
APP_ABI := armeabi-v7a
|
APP_ABI := armeabi-v7a
|
||||||
NDK_TOOLCHAIN_VERSION := 4.8
|
|
||||||
APP_CPPFLAGS += -std=c++11
|
APP_CPPFLAGS += -std=c++11
|
||||||
|
|||||||
0
android/jni/build_flatc.bat
Executable file → Normal file
0
android/jni/build_flatc.bat
Executable file → Normal file
0
android/res/values/strings.xml
Executable file → Normal file
0
android/res/values/strings.xml
Executable file → Normal file
105
appveyor.yml
Normal file
105
appveyor.yml
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
|
||||||
|
os: Visual Studio 2015
|
||||||
|
|
||||||
|
environment:
|
||||||
|
|
||||||
|
global:
|
||||||
|
# Workaround for https://github.com/conda/conda-build/issues/636
|
||||||
|
PYTHONIOENCODING: UTF-8
|
||||||
|
CONDA_INSTALL_LOCN: "C:\\Miniconda35-x64"
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
- CMAKE_VS_VERSION: "10 2010"
|
||||||
|
MONSTER_EXTRA: "skip"
|
||||||
|
|
||||||
|
- CMAKE_VS_VERSION: "12 2013"
|
||||||
|
MONSTER_EXTRA: "skip"
|
||||||
|
|
||||||
|
- CMAKE_VS_VERSION: "14 2015"
|
||||||
|
MONSTER_EXTRA: ""
|
||||||
|
|
||||||
|
platform:
|
||||||
|
- x86
|
||||||
|
- x64
|
||||||
|
|
||||||
|
configuration:
|
||||||
|
- Debug
|
||||||
|
- Release
|
||||||
|
|
||||||
|
before_build:
|
||||||
|
- set MONSTER_EXTRA=%MONSTER_EXTRA%
|
||||||
|
- cmake -G"Visual Studio %CMAKE_VS_VERSION%" -DFLATBUFFERS_CODE_SANITIZE=1 .
|
||||||
|
# This cuts down on a lot of noise generated by xamarin warnings.
|
||||||
|
- 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%;
|
||||||
|
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
|
||||||
|
- rustup-init.exe -y
|
||||||
|
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
|
||||||
|
- rustc -V
|
||||||
|
- cargo -V
|
||||||
|
|
||||||
|
test_script:
|
||||||
|
- call .appveyor\check-generate-code.bat -b %CONFIGURATION%
|
||||||
|
- "cd tests"
|
||||||
|
- rem "Building all code"
|
||||||
|
- generate_code.bat -b %CONFIGURATION%
|
||||||
|
- 7z a GeneratedMyGameCode.zip MyGame\
|
||||||
|
- rem "---------------- C++ -----------------"
|
||||||
|
- "cd .."
|
||||||
|
- "%CONFIGURATION%\\flattests.exe"
|
||||||
|
- "cd tests"
|
||||||
|
- rem "---------------- Java -----------------"
|
||||||
|
- "java -version"
|
||||||
|
- "JavaTest.bat"
|
||||||
|
- rem "---------------- Rust ----------------"
|
||||||
|
- "RustTest.bat"
|
||||||
|
- rem "---------------- JS -----------------"
|
||||||
|
- "node --version"
|
||||||
|
- "..\\%CONFIGURATION%\\flatc -b -I include_test monster_test.fbs unicode_test.json"
|
||||||
|
- "node JavaScriptTest ./monster_test_generated"
|
||||||
|
- rem "-------------- Python ---------------"
|
||||||
|
- where python
|
||||||
|
- python --version
|
||||||
|
- where pip
|
||||||
|
- pip --version
|
||||||
|
- where conda
|
||||||
|
- conda --version
|
||||||
|
- rem "installing flatbuffers python library"
|
||||||
|
- pip install ../python
|
||||||
|
- rem "testing without installing Numpy"
|
||||||
|
- python py_test.py 0 0 0
|
||||||
|
- rem "testing after installing Numpy - disabled"
|
||||||
|
# FIXME: This has a LOT of unnecessary dependencies and makes the tests fail
|
||||||
|
# with timeouts.
|
||||||
|
# - conda install --yes numpy
|
||||||
|
# - python py_test.py 0 0 0
|
||||||
|
- rem "---------------- C# -----------------"
|
||||||
|
# Have to compile this here rather than in "build" above because AppVeyor only
|
||||||
|
# supports building one project??
|
||||||
|
- "cd FlatBuffers.Test"
|
||||||
|
- "msbuild.exe /property:Configuration=Release;OutputPath=tempcs /verbosity:minimal FlatBuffers.Test.csproj"
|
||||||
|
- "tempcs\\FlatBuffers.Test.exe"
|
||||||
|
# Run tests with UNSAFE_BYTEBUFFER
|
||||||
|
- "msbuild.exe /property:Configuration=Release;UnsafeByteBuffer=true;OutputPath=tempcsUnsafe /verbosity:minimal FlatBuffers.Test.csproj"
|
||||||
|
- "tempcsUnsafe\\FlatBuffers.Test.exe"
|
||||||
|
# TODO: add more languages.
|
||||||
|
- "cd ..\\.."
|
||||||
|
|
||||||
|
artifacts:
|
||||||
|
- path: $(CONFIGURATION)\flatc.exe
|
||||||
|
name: flatc.exe
|
||||||
|
- path: tests\GeneratedMyGameCode.zip
|
||||||
|
name: GeneratedMyGameCode.zip
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
# Biicode configuration file
|
|
||||||
[paths]
|
|
||||||
include
|
|
||||||
[mains]
|
|
||||||
!android/*
|
|
||||||
[tests]
|
|
||||||
tests/*
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
Biicode C/C++ dependency manager
|
|
||||||
=================================
|
|
||||||
|
|
||||||
[](https://www.biicode.com/fenix/flatbuffers)
|
|
||||||
|
|
||||||
New with biicode? Check the [Getting Started Guide](http://docs.biicode.com/c++/gettingstarted.html).
|
|
||||||
|
|
||||||
How to build it?
|
|
||||||
------------------
|
|
||||||
Building it is too easy:
|
|
||||||
|
|
||||||
$ git clone git@github.com:google/flatbuffers.git
|
|
||||||
$ cd flatbuffers
|
|
||||||
$ bii init -L && bii build
|
|
||||||
$ ./bin/any_executable
|
|
||||||
|
|
||||||
Or run its tests:
|
|
||||||
|
|
||||||
$ bii test
|
|
||||||
|
|
||||||
You can check [the examples/flatbuffers block](https://www.biicode.com/examples/flatbuffers).
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
set(BII_TESTS_WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
||||||
# Copying data files to project/bin folder
|
|
||||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/samples")
|
|
||||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/samples/monster.fbs"
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/samples/monsterdata.json"
|
|
||||||
DESTINATION
|
|
||||||
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/samples")
|
|
||||||
endif()
|
|
||||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
|
|
||||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests"
|
|
||||||
DESTINATION
|
|
||||||
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
ADD_BIICODE_TARGETS()
|
|
||||||
|
|
||||||
string(REPLACE " " ";" REPLACED_FLAGS ${CMAKE_CXX_FLAGS})
|
|
||||||
target_compile_options(${BII_BLOCK_TARGET} INTERFACE ${REPLACED_FLAGS})
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
sudo apt-get update -qq
|
|
||||||
sudo apt-get install libglu1-mesa-dev xorg-dev
|
|
||||||
wget http://www.biicode.com/downloads/latest/ubuntu64
|
|
||||||
mv ubuntu64 bii-ubuntu64.deb
|
|
||||||
(sudo dpkg -i bii-ubuntu64.deb) && sudo apt-get -f install
|
|
||||||
rm bii-ubuntu64.deb
|
|
||||||
wget https://s3.amazonaws.com/biibinaries/thirdparty/cmake-3.0.2-Linux-64.tar.gz
|
|
||||||
tar -xzf cmake-3.0.2-Linux-64.tar.gz
|
|
||||||
sudo cp -fR cmake-3.0.2-Linux-64/* /usr
|
|
||||||
rm -rf cmake-3.0.2-Linux-64
|
|
||||||
rm cmake-3.0.2-Linux-64.tar.gz
|
|
||||||
|
|
||||||
cmake --version
|
|
||||||
bii init -l && bii configure -DCMAKE_BUILD_TYPE=$1 && bii test
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
|
||||||
# Visual Studio 2010
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "flatc", "flatc.vcxproj", "{5B5857E1-64E2-4CED-A12E-45E1B3880496}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "flatsamplebinary", "flatsamplebinary.vcxproj", "{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "flatsampletext", "flatsampletext.vcxproj", "{F0A15675-1017-4217-BB5B-3372F2C636AB}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "flattests", "flattests.vcxproj", "{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Win32 = Debug|Win32
|
|
||||||
Debug|x64 = Debug|x64
|
|
||||||
Release|Win32 = Release|Win32
|
|
||||||
Release|x64 = Release|x64
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{5B5857E1-64E2-4CED-A12E-45E1B3880496}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{5B5857E1-64E2-4CED-A12E-45E1B3880496}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{5B5857E1-64E2-4CED-A12E-45E1B3880496}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{5B5857E1-64E2-4CED-A12E-45E1B3880496}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{5B5857E1-64E2-4CED-A12E-45E1B3880496}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{5B5857E1-64E2-4CED-A12E-45E1B3880496}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{5B5857E1-64E2-4CED-A12E-45E1B3880496}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{5B5857E1-64E2-4CED-A12E-45E1B3880496}.Release|x64.Build.0 = Release|x64
|
|
||||||
{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}.Release|x64.Build.0 = Release|x64
|
|
||||||
{F0A15675-1017-4217-BB5B-3372F2C636AB}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{F0A15675-1017-4217-BB5B-3372F2C636AB}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{F0A15675-1017-4217-BB5B-3372F2C636AB}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{F0A15675-1017-4217-BB5B-3372F2C636AB}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{F0A15675-1017-4217-BB5B-3372F2C636AB}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{F0A15675-1017-4217-BB5B-3372F2C636AB}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{F0A15675-1017-4217-BB5B-3372F2C636AB}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{F0A15675-1017-4217-BB5B-3372F2C636AB}.Release|x64.Build.0 = Release|x64
|
|
||||||
{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}.Release|x64.Build.0 = Release|x64
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
@@ -1,285 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGUID>{5B5857E1-64E2-4CED-A12E-45E1B3880496}</ProjectGUID>
|
|
||||||
<Keyword>Win32Proj</Keyword>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
<ProjectName>flatc</ProjectName>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)</OutDir>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)</OutDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">flatc.dir\Debug\</IntDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">flatc.dir\Debug\</IntDir>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">flatc</TargetName>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">flatc</TargetName>
|
|
||||||
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.exe</TargetExt>
|
|
||||||
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.exe</TargetExt>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
|
|
||||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</GenerateManifest>
|
|
||||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</GenerateManifest>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)</OutDir>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)</OutDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">flatc.dir\Release\</IntDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">flatc.dir\Release\</IntDir>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">flatc</TargetName>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">flatc</TargetName>
|
|
||||||
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.exe</TargetExt>
|
|
||||||
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.exe</TargetExt>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
|
|
||||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</GenerateManifest>
|
|
||||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</GenerateManifest>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
|
||||||
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AssemblerListingLocation>Debug</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>../../Debug/flatc.pdb</ProgramDataBaseFileName>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Midl>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<OutputDirectory>$(IntDir)</OutputDirectory>
|
|
||||||
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
||||||
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
||||||
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
||||||
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
||||||
</Midl>
|
|
||||||
<Link>
|
|
||||||
<AdditionalOptions> /machine:X86 /debug %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<ImportLibrary>../../Debug/flatc.lib</ImportLibrary>
|
|
||||||
<ProgramDataBaseFile>../../Debug/flatc.pdb</ProgramDataBaseFile>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<Version>
|
|
||||||
</Version>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
|
||||||
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AssemblerListingLocation>Debug</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>../../Debug/flatc.pdb</ProgramDataBaseFileName>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Midl>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<OutputDirectory>$(IntDir)</OutputDirectory>
|
|
||||||
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
||||||
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
||||||
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
||||||
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
||||||
</Midl>
|
|
||||||
<Link>
|
|
||||||
<AdditionalOptions>/debug %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<ImportLibrary>../../Debug/flatc.lib</ImportLibrary>
|
|
||||||
<ProgramDataBaseFile>../../Debug/flatc.pdb</ProgramDataBaseFile>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<Version>
|
|
||||||
</Version>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<DebugInformationFormat>
|
|
||||||
</DebugInformationFormat>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AssemblerListingLocation>Release</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>../../Release/flatc.pdb</ProgramDataBaseFileName>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Midl>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<OutputDirectory>$(IntDir)</OutputDirectory>
|
|
||||||
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
||||||
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
||||||
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
||||||
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
||||||
</Midl>
|
|
||||||
<Link>
|
|
||||||
<AdditionalOptions> /machine:X86 %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
|
||||||
<ImportLibrary>../../Release/flatc.lib</ImportLibrary>
|
|
||||||
<ProgramDataBaseFile>../../Release/flatc.pdb</ProgramDataBaseFile>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<Version>
|
|
||||||
</Version>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<DebugInformationFormat>
|
|
||||||
</DebugInformationFormat>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AssemblerListingLocation>Release</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>../../Release/flatc.pdb</ProgramDataBaseFileName>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Midl>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<OutputDirectory>$(IntDir)</OutputDirectory>
|
|
||||||
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
||||||
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
||||||
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
||||||
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
||||||
</Midl>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
|
||||||
<ImportLibrary>../../Release/flatc.lib</ImportLibrary>
|
|
||||||
<ProgramDataBaseFile>../../Release/flatc.pdb</ProgramDataBaseFile>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<Version>
|
|
||||||
</Version>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="..\..\include\flatbuffers\flatbuffers.h" />
|
|
||||||
<ClInclude Include="..\..\include\flatbuffers\idl.h" />
|
|
||||||
<ClInclude Include="..\..\include\flatbuffers\util.h" />
|
|
||||||
<ClCompile Include="..\..\src\idl_gen_fbs.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\idl_gen_general.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\idl_gen_go.cpp">
|
|
||||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Level4</WarningLevel>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\idl_gen_js.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\idl_gen_php.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\idl_gen_python.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\idl_parser.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\idl_gen_cpp.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\idl_gen_text.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\flatc.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LocalDebuggerWorkingDirectory>..\..\tests</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
<LocalDebuggerCommandArguments>-j -c -n -g --php --no-includes --gen-mutable monster_test.fbs</LocalDebuggerCommandArguments>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LocalDebuggerWorkingDirectory>..\..</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
<LocalDebuggerCommandArguments>-j -c -n -g -b -t monster_test.fbs monsterdata_test.golden</LocalDebuggerCommandArguments>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<LocalDebuggerCommandArguments>-j -c -g -n -b -t monster_test.fbs monsterdata_test.golden</LocalDebuggerCommandArguments>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<LocalDebuggerWorkingDirectory>..\..\tests</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LocalDebuggerCommandArguments>-j -c -g -b -t monster_test.fbs monsterdata_test.json</LocalDebuggerCommandArguments>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LocalDebuggerWorkingDirectory>..\..\tests</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,273 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGUID>{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}</ProjectGUID>
|
|
||||||
<Keyword>Win32Proj</Keyword>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
<ProjectName>flatsamplebinary</ProjectName>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)</OutDir>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)</OutDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">flatsamplebinary.dir\Debug\</IntDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">flatsamplebinary.dir\Debug\</IntDir>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">flatsamplebinary</TargetName>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">flatsamplebinary</TargetName>
|
|
||||||
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.exe</TargetExt>
|
|
||||||
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.exe</TargetExt>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
|
|
||||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</GenerateManifest>
|
|
||||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</GenerateManifest>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)</OutDir>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)</OutDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">flatsamplebinary.dir\Release\</IntDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">flatsamplebinary.dir\Release\</IntDir>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">flatsamplebinary</TargetName>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">flatsamplebinary</TargetName>
|
|
||||||
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.exe</TargetExt>
|
|
||||||
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.exe</TargetExt>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
|
|
||||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</GenerateManifest>
|
|
||||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</GenerateManifest>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
|
||||||
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AssemblerListingLocation>Debug</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>../../Debug/flatsamplebinary.pdb</ProgramDataBaseFileName>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Midl>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<OutputDirectory>$(IntDir)</OutputDirectory>
|
|
||||||
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
||||||
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
||||||
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
||||||
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
||||||
</Midl>
|
|
||||||
<Link>
|
|
||||||
<AdditionalOptions> /machine:X86 /debug %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<ImportLibrary>../../Debug/flatsamplebinary.lib</ImportLibrary>
|
|
||||||
<ProgramDataBaseFile>../../Debug/flatsamplebinary.pdb</ProgramDataBaseFile>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<Version>
|
|
||||||
</Version>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
|
||||||
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AssemblerListingLocation>Debug</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>../../Debug/flatsamplebinary.pdb</ProgramDataBaseFileName>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Midl>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<OutputDirectory>$(IntDir)</OutputDirectory>
|
|
||||||
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
||||||
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
||||||
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
||||||
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
||||||
</Midl>
|
|
||||||
<Link>
|
|
||||||
<AdditionalOptions>/debug %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<ImportLibrary>../../Debug/flatsamplebinary.lib</ImportLibrary>
|
|
||||||
<ProgramDataBaseFile>../../Debug/flatsamplebinary.pdb</ProgramDataBaseFile>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<Version>
|
|
||||||
</Version>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<DebugInformationFormat>
|
|
||||||
</DebugInformationFormat>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AssemblerListingLocation>Release</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>../../Release/flatsamplebinary.pdb</ProgramDataBaseFileName>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Midl>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<OutputDirectory>$(IntDir)</OutputDirectory>
|
|
||||||
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
||||||
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
||||||
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
||||||
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
||||||
</Midl>
|
|
||||||
<Link>
|
|
||||||
<AdditionalOptions> /machine:X86 %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
|
||||||
<ImportLibrary>../../Release/flatsamplebinary.lib</ImportLibrary>
|
|
||||||
<ProgramDataBaseFile>../../Release/flatsamplebinary.pdb</ProgramDataBaseFile>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<Version>
|
|
||||||
</Version>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<DebugInformationFormat>
|
|
||||||
</DebugInformationFormat>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AssemblerListingLocation>Release</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>../../Release/flatsamplebinary.pdb</ProgramDataBaseFileName>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Midl>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<OutputDirectory>$(IntDir)</OutputDirectory>
|
|
||||||
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
||||||
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
||||||
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
||||||
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
||||||
</Midl>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
|
||||||
<ImportLibrary>../../Release/flatsamplebinary.lib</ImportLibrary>
|
|
||||||
<ProgramDataBaseFile>../../Release/flatsamplebinary.pdb</ProgramDataBaseFile>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<Version>
|
|
||||||
</Version>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="..\..\include\flatbuffers\flatbuffers.h" />
|
|
||||||
<ClInclude Include="..\..\samples\monster_generated.h" />
|
|
||||||
<ClCompile Include="..\..\samples\sample_binary.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<LocalDebuggerWorkingDirectory>..\..</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LocalDebuggerWorkingDirectory>..\..</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,277 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGUID>{F0A15675-1017-4217-BB5B-3372F2C636AB}</ProjectGUID>
|
|
||||||
<Keyword>Win32Proj</Keyword>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
<ProjectName>flatsampletext</ProjectName>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)</OutDir>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)</OutDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">flatsampletext.dir\Debug\</IntDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">flatsampletext.dir\Debug\</IntDir>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">flatsampletext</TargetName>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">flatsampletext</TargetName>
|
|
||||||
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.exe</TargetExt>
|
|
||||||
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.exe</TargetExt>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
|
|
||||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</GenerateManifest>
|
|
||||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</GenerateManifest>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)</OutDir>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)</OutDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">flatsampletext.dir\Release\</IntDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">flatsampletext.dir\Release\</IntDir>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">flatsampletext</TargetName>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">flatsampletext</TargetName>
|
|
||||||
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.exe</TargetExt>
|
|
||||||
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.exe</TargetExt>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
|
|
||||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</GenerateManifest>
|
|
||||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</GenerateManifest>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
|
||||||
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AssemblerListingLocation>Debug</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>../../Debug/flatsampletext.pdb</ProgramDataBaseFileName>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Midl>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<OutputDirectory>$(IntDir)</OutputDirectory>
|
|
||||||
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
||||||
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
||||||
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
||||||
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
||||||
</Midl>
|
|
||||||
<Link>
|
|
||||||
<AdditionalOptions> /machine:X86 /debug %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<ImportLibrary>../../Debug/flatsampletext.lib</ImportLibrary>
|
|
||||||
<ProgramDataBaseFile>../../Debug/flatsampletext.pdb</ProgramDataBaseFile>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<Version>
|
|
||||||
</Version>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
|
||||||
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AssemblerListingLocation>Debug</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>../../Debug/flatsampletext.pdb</ProgramDataBaseFileName>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Midl>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<OutputDirectory>$(IntDir)</OutputDirectory>
|
|
||||||
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
||||||
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
||||||
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
||||||
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
||||||
</Midl>
|
|
||||||
<Link>
|
|
||||||
<AdditionalOptions>/debug %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<ImportLibrary>../../Debug/flatsampletext.lib</ImportLibrary>
|
|
||||||
<ProgramDataBaseFile>../../Debug/flatsampletext.pdb</ProgramDataBaseFile>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<Version>
|
|
||||||
</Version>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<DebugInformationFormat>
|
|
||||||
</DebugInformationFormat>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AssemblerListingLocation>Release</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>../../Release/flatsampletext.pdb</ProgramDataBaseFileName>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Midl>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<OutputDirectory>$(IntDir)</OutputDirectory>
|
|
||||||
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
||||||
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
||||||
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
||||||
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
||||||
</Midl>
|
|
||||||
<Link>
|
|
||||||
<AdditionalOptions> /machine:X86 %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
|
||||||
<ImportLibrary>../../Release/flatsampletext.lib</ImportLibrary>
|
|
||||||
<ProgramDataBaseFile>../../Release/flatsampletext.pdb</ProgramDataBaseFile>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<Version>
|
|
||||||
</Version>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<DebugInformationFormat>
|
|
||||||
</DebugInformationFormat>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AssemblerListingLocation>Release</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>../../Release/flatsampletext.pdb</ProgramDataBaseFileName>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Midl>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<OutputDirectory>$(IntDir)</OutputDirectory>
|
|
||||||
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
||||||
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
||||||
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
||||||
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
||||||
</Midl>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
|
||||||
<ImportLibrary>../../Release/flatsampletext.lib</ImportLibrary>
|
|
||||||
<ProgramDataBaseFile>../../Release/flatsampletext.pdb</ProgramDataBaseFile>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<Version>
|
|
||||||
</Version>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="..\..\include\flatbuffers\flatbuffers.h" />
|
|
||||||
<ClInclude Include="..\..\include\flatbuffers\idl.h" />
|
|
||||||
<ClInclude Include="..\..\include\flatbuffers\util.h" />
|
|
||||||
<ClInclude Include="..\..\samples\monster_generated.h" />
|
|
||||||
<ClCompile Include="..\..\src\idl_parser.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\idl_gen_text.cpp" />
|
|
||||||
<ClCompile Include="..\..\samples\sample_text.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LocalDebuggerWorkingDirectory>..\..</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LocalDebuggerWorkingDirectory>..\..</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<LocalDebuggerWorkingDirectory>..\..</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LocalDebuggerWorkingDirectory>..\..</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,281 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGUID>{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}</ProjectGUID>
|
|
||||||
<Keyword>Win32Proj</Keyword>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
<ProjectName>flattests</ProjectName>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)</OutDir>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)</OutDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">flattests.dir\Debug\</IntDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">flattests.dir\Debug\</IntDir>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">flattests</TargetName>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">flattests</TargetName>
|
|
||||||
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.exe</TargetExt>
|
|
||||||
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.exe</TargetExt>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
|
|
||||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</GenerateManifest>
|
|
||||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</GenerateManifest>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)</OutDir>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)</OutDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">flattests.dir\Release\</IntDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">flattests.dir\Release\</IntDir>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">flattests</TargetName>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">flattests</TargetName>
|
|
||||||
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.exe</TargetExt>
|
|
||||||
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.exe</TargetExt>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
|
|
||||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</GenerateManifest>
|
|
||||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</GenerateManifest>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
|
||||||
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AssemblerListingLocation>Debug</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>../../Debug/flattests.pdb</ProgramDataBaseFileName>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Midl>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<OutputDirectory>$(IntDir)</OutputDirectory>
|
|
||||||
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
||||||
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
||||||
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
||||||
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
||||||
</Midl>
|
|
||||||
<Link>
|
|
||||||
<AdditionalOptions> /machine:X86 /debug %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<ImportLibrary>../../Debug/flattests.lib</ImportLibrary>
|
|
||||||
<ProgramDataBaseFile>../../Debug/flattests.pdb</ProgramDataBaseFile>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<Version>
|
|
||||||
</Version>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
|
||||||
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AssemblerListingLocation>Debug</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>../../Debug/flattests.pdb</ProgramDataBaseFileName>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Midl>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<OutputDirectory>$(IntDir)</OutputDirectory>
|
|
||||||
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
||||||
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
||||||
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
||||||
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
||||||
</Midl>
|
|
||||||
<Link>
|
|
||||||
<AdditionalOptions>/debug %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<ImportLibrary>../../Debug/flattests.lib</ImportLibrary>
|
|
||||||
<ProgramDataBaseFile>../../Debug/flattests.pdb</ProgramDataBaseFile>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<Version>
|
|
||||||
</Version>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<DebugInformationFormat>
|
|
||||||
</DebugInformationFormat>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AssemblerListingLocation>Release</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>../../Release/flattests.pdb</ProgramDataBaseFileName>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Midl>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<OutputDirectory>$(IntDir)</OutputDirectory>
|
|
||||||
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
||||||
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
||||||
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
||||||
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
||||||
</Midl>
|
|
||||||
<Link>
|
|
||||||
<AdditionalOptions> /machine:X86 %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
|
||||||
<ImportLibrary>../../Release/flattests.lib</ImportLibrary>
|
|
||||||
<ProgramDataBaseFile>../../Release/flattests.pdb</ProgramDataBaseFile>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<Version>
|
|
||||||
</Version>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<DebugInformationFormat>
|
|
||||||
</DebugInformationFormat>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AssemblerListingLocation>Release</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>../../Release/flattests.pdb</ProgramDataBaseFileName>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Midl>
|
|
||||||
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<OutputDirectory>$(IntDir)</OutputDirectory>
|
|
||||||
<HeaderFileName>%(Filename).h</HeaderFileName>
|
|
||||||
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
|
|
||||||
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
|
|
||||||
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
|
|
||||||
</Midl>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
|
||||||
<ImportLibrary>../../Release/flattests.lib</ImportLibrary>
|
|
||||||
<ProgramDataBaseFile>../../Release/flattests.pdb</ProgramDataBaseFile>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<Version>
|
|
||||||
</Version>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="..\..\include\flatbuffers\flatbuffers.h" />
|
|
||||||
<ClInclude Include="..\..\include\flatbuffers\idl.h" />
|
|
||||||
<ClInclude Include="..\..\include\flatbuffers\reflection.h" />
|
|
||||||
<ClInclude Include="..\..\include\flatbuffers\util.h" />
|
|
||||||
<ClInclude Include="..\..\tests\monster_test_generated.h" />
|
|
||||||
<ClCompile Include="..\..\src\idl_gen_fbs.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\idl_gen_general.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\idl_parser.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\idl_gen_text.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\reflection.cpp" />
|
|
||||||
<ClCompile Include="..\..\tests\test.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LocalDebuggerWorkingDirectory>..\..</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LocalDebuggerWorkingDirectory>..\..</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<LocalDebuggerWorkingDirectory>..\..</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LocalDebuggerWorkingDirectory>..\..</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||
File diff suppressed because it is too large
Load Diff
237
build_defs.bzl
Normal file
237
build_defs.bzl
Normal file
@@ -0,0 +1,237 @@
|
|||||||
|
# Description:
|
||||||
|
# BUILD rules for generating flatbuffer files in various languages.
|
||||||
|
|
||||||
|
"""
|
||||||
|
Rules for building C++ flatbuffers with Bazel.
|
||||||
|
"""
|
||||||
|
|
||||||
|
flatc_path = "@com_github_google_flatbuffers//:flatc"
|
||||||
|
|
||||||
|
DEFAULT_INCLUDE_PATHS = [
|
||||||
|
"./",
|
||||||
|
"$(GENDIR)",
|
||||||
|
"$(BINDIR)",
|
||||||
|
]
|
||||||
|
|
||||||
|
DEFAULT_FLATC_ARGS = [
|
||||||
|
"--gen-object-api",
|
||||||
|
"--gen-compare",
|
||||||
|
"--no-includes",
|
||||||
|
"--gen-mutable",
|
||||||
|
"--reflect-names",
|
||||||
|
"--cpp-ptr-type flatbuffers::unique_ptr",
|
||||||
|
]
|
||||||
|
|
||||||
|
def flatbuffer_library_public(
|
||||||
|
name,
|
||||||
|
srcs,
|
||||||
|
outs,
|
||||||
|
language_flag,
|
||||||
|
out_prefix = "",
|
||||||
|
includes = [],
|
||||||
|
include_paths = DEFAULT_INCLUDE_PATHS,
|
||||||
|
flatc_args = DEFAULT_FLATC_ARGS,
|
||||||
|
reflection_name = "",
|
||||||
|
reflection_visiblity = None,
|
||||||
|
output_to_bindir = False):
|
||||||
|
"""Generates code files for reading/writing the given flatbuffers in the requested language using the public compiler.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
name: Rule name.
|
||||||
|
srcs: Source .fbs files. Sent in order to the compiler.
|
||||||
|
outs: Output files from flatc.
|
||||||
|
language_flag: Target language flag. One of [-c, -j, -js].
|
||||||
|
out_prefix: Prepend this path to the front of all generated files except on
|
||||||
|
single source targets. Usually is a directory name.
|
||||||
|
includes: Optional, list of filegroups of schemas that the srcs depend on.
|
||||||
|
include_paths: Optional, list of paths the includes files can be found in.
|
||||||
|
flatc_args: Optional, list of additional arguments to pass to flatc.
|
||||||
|
reflection_name: Optional, if set this will generate the flatbuffer
|
||||||
|
reflection binaries for the schemas.
|
||||||
|
reflection_visiblity: The visibility of the generated reflection Fileset.
|
||||||
|
output_to_bindir: Passed to genrule for output to bin directory.
|
||||||
|
|
||||||
|
|
||||||
|
This rule creates a filegroup(name) with all generated source files, and
|
||||||
|
optionally a Fileset([reflection_name]) with all generated reflection
|
||||||
|
binaries.
|
||||||
|
"""
|
||||||
|
include_paths_cmd = ["-I %s" % (s) for s in include_paths]
|
||||||
|
|
||||||
|
# '$(@D)' when given a single source target will give the appropriate
|
||||||
|
# directory. Appending 'out_prefix' is only necessary when given a build
|
||||||
|
# target with multiple sources.
|
||||||
|
output_directory = (
|
||||||
|
("-o $(@D)/%s" % (out_prefix)) if len(srcs) > 1 else ("-o $(@D)")
|
||||||
|
)
|
||||||
|
genrule_cmd = " ".join([
|
||||||
|
"SRCS=($(SRCS));",
|
||||||
|
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
|
||||||
|
"$(location %s)" % (flatc_path),
|
||||||
|
" ".join(include_paths_cmd),
|
||||||
|
" ".join(flatc_args),
|
||||||
|
language_flag,
|
||||||
|
output_directory,
|
||||||
|
"$$f;",
|
||||||
|
"done",
|
||||||
|
])
|
||||||
|
native.genrule(
|
||||||
|
name = name,
|
||||||
|
srcs = srcs + includes,
|
||||||
|
outs = outs,
|
||||||
|
output_to_bindir = output_to_bindir,
|
||||||
|
tools = [flatc_path],
|
||||||
|
cmd = genrule_cmd,
|
||||||
|
message = "Generating flatbuffer files for %s:" % (name),
|
||||||
|
)
|
||||||
|
if reflection_name:
|
||||||
|
reflection_genrule_cmd = " ".join([
|
||||||
|
"SRCS=($(SRCS));",
|
||||||
|
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
|
||||||
|
"$(location %s)" % (flatc_path),
|
||||||
|
"-b --schema",
|
||||||
|
" ".join(flatc_args),
|
||||||
|
" ".join(include_paths_cmd),
|
||||||
|
language_flag,
|
||||||
|
output_directory,
|
||||||
|
"$$f;",
|
||||||
|
"done",
|
||||||
|
])
|
||||||
|
reflection_outs = [
|
||||||
|
(out_prefix + "%s.bfbs") % (s.replace(".fbs", "").split("/")[-1])
|
||||||
|
for s in srcs
|
||||||
|
]
|
||||||
|
native.genrule(
|
||||||
|
name = "%s_srcs" % reflection_name,
|
||||||
|
srcs = srcs + includes,
|
||||||
|
outs = reflection_outs,
|
||||||
|
output_to_bindir = output_to_bindir,
|
||||||
|
tools = [flatc_path],
|
||||||
|
cmd = reflection_genrule_cmd,
|
||||||
|
message = "Generating flatbuffer reflection binary for %s:" % (name),
|
||||||
|
)
|
||||||
|
native.Fileset(
|
||||||
|
name = reflection_name,
|
||||||
|
out = "%s_out" % reflection_name,
|
||||||
|
entries = [
|
||||||
|
native.FilesetEntry(files = reflection_outs),
|
||||||
|
],
|
||||||
|
visibility = reflection_visiblity,
|
||||||
|
)
|
||||||
|
|
||||||
|
def flatbuffer_cc_library(
|
||||||
|
name,
|
||||||
|
srcs,
|
||||||
|
srcs_filegroup_name = "",
|
||||||
|
out_prefix = "",
|
||||||
|
includes = [],
|
||||||
|
include_paths = DEFAULT_INCLUDE_PATHS,
|
||||||
|
flatc_args = DEFAULT_FLATC_ARGS,
|
||||||
|
visibility = None,
|
||||||
|
srcs_filegroup_visibility = None,
|
||||||
|
gen_reflections = False):
|
||||||
|
'''A cc_library with the generated reader/writers for the given flatbuffer definitions.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
name: Rule name.
|
||||||
|
srcs: Source .fbs files. Sent in order to the compiler.
|
||||||
|
srcs_filegroup_name: Name of the output filegroup that holds srcs. Pass this
|
||||||
|
filegroup into the `includes` parameter of any other
|
||||||
|
flatbuffer_cc_library that depends on this one's schemas.
|
||||||
|
out_prefix: Prepend this path to the front of all generated files. Usually
|
||||||
|
is a directory name.
|
||||||
|
includes: Optional, list of filegroups of schemas that the srcs depend on.
|
||||||
|
** SEE REMARKS BELOW **
|
||||||
|
include_paths: Optional, list of paths the includes files can be found in.
|
||||||
|
flatc_args: Optional list of additional arguments to pass to flatc
|
||||||
|
(e.g. --gen-mutable).
|
||||||
|
visibility: The visibility of the generated cc_library. By default, use the
|
||||||
|
default visibility of the project.
|
||||||
|
srcs_filegroup_visibility: The visibility of the generated srcs filegroup.
|
||||||
|
By default, use the value of the visibility parameter above.
|
||||||
|
gen_reflections: Optional, if true this will generate the flatbuffer
|
||||||
|
reflection binaries for the schemas.
|
||||||
|
|
||||||
|
This produces:
|
||||||
|
filegroup([name]_srcs): all generated .h files.
|
||||||
|
filegroup(srcs_filegroup_name if specified, or [name]_includes if not):
|
||||||
|
Other flatbuffer_cc_library's can pass this in for their `includes`
|
||||||
|
parameter, if they depend on the schemas in this library.
|
||||||
|
Fileset([name]_reflection): (Optional) all generated reflection binaries.
|
||||||
|
cc_library([name]): library with sources and flatbuffers deps.
|
||||||
|
|
||||||
|
Remarks:
|
||||||
|
** Because the genrule used to call flatc does not have any trivial way of
|
||||||
|
computing the output list of files transitively generated by includes and
|
||||||
|
--gen-includes (the default) being defined for flatc, the --gen-includes
|
||||||
|
flag will not work as expected. The way around this is to add a dependency
|
||||||
|
to the flatbuffer_cc_library defined alongside the flatc included Fileset.
|
||||||
|
For example you might define:
|
||||||
|
|
||||||
|
flatbuffer_cc_library(
|
||||||
|
name = "my_fbs",
|
||||||
|
srcs = [ "schemas/foo.fbs" ],
|
||||||
|
includes = [ "//third_party/bazz:bazz_fbs_includes" ],
|
||||||
|
)
|
||||||
|
|
||||||
|
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])
|
||||||
|
for s in srcs
|
||||||
|
]
|
||||||
|
reflection_name = "%s_reflection" % name if gen_reflections else ""
|
||||||
|
|
||||||
|
srcs_lib = "%s_srcs" % (name)
|
||||||
|
flatbuffer_library_public(
|
||||||
|
name = srcs_lib,
|
||||||
|
srcs = srcs,
|
||||||
|
outs = output_headers,
|
||||||
|
language_flag = "-c",
|
||||||
|
out_prefix = out_prefix,
|
||||||
|
includes = includes,
|
||||||
|
include_paths = include_paths,
|
||||||
|
flatc_args = flatc_args,
|
||||||
|
reflection_name = reflection_name,
|
||||||
|
reflection_visiblity = visibility,
|
||||||
|
)
|
||||||
|
native.cc_library(
|
||||||
|
name = name,
|
||||||
|
hdrs = [
|
||||||
|
":" + srcs_lib,
|
||||||
|
],
|
||||||
|
srcs = [
|
||||||
|
":" + srcs_lib,
|
||||||
|
],
|
||||||
|
features = [
|
||||||
|
"-parse_headers",
|
||||||
|
],
|
||||||
|
deps = [
|
||||||
|
"@com_github_google_flatbuffers//:runtime_cc",
|
||||||
|
],
|
||||||
|
includes = [],
|
||||||
|
linkstatic = 1,
|
||||||
|
visibility = visibility,
|
||||||
|
)
|
||||||
|
|
||||||
|
# A filegroup for the `srcs`. That is, all the schema files for this
|
||||||
|
# Flatbuffer set.
|
||||||
|
native.filegroup(
|
||||||
|
name = srcs_filegroup_name if srcs_filegroup_name else "%s_includes" % (name),
|
||||||
|
srcs = srcs,
|
||||||
|
visibility = srcs_filegroup_visibility if srcs_filegroup_visibility != None else visibility,
|
||||||
|
)
|
||||||
12
conan/CMakeLists.txt
Normal file
12
conan/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
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)
|
||||||
8
conan/appveyor/build.py
Normal file
8
conan/appveyor/build.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/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")
|
||||||
8
conan/appveyor/install.py
Normal file
8
conan/appveyor/install.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/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")
|
||||||
69
conan/build.py
Normal file
69
conan/build.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#!/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()
|
||||||
9
conan/test_package/CMakeLists.txt
Normal file
9
conan/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
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)
|
||||||
21
conan/test_package/conanfile.py
Normal file
21
conan/test_package/conanfile.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/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)
|
||||||
35
conan/test_package/test_package.cpp
Normal file
35
conan/test_package/test_package.cpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
14
conan/travis/build.sh
Executable file
14
conan/travis/build.sh
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/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
|
||||||
22
conan/travis/install.sh
Executable file
22
conan/travis/install.sh
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/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
Normal file
75
conanfile.py
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
#!/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")
|
||||||
14
dart/CHANGELOG.md
Normal file
14
dart/CHANGELOG.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# CHANGELOG
|
||||||
|
|
||||||
|
## 1.9.2
|
||||||
|
|
||||||
|
- Ensure `_writeString` adds enough padding to null terminate strings.
|
||||||
|
|
||||||
|
## 1.9.1
|
||||||
|
|
||||||
|
- Changed constant identifiers to be compatible with Dart 2.x
|
||||||
|
- No longer supports Dart 1.x
|
||||||
|
|
||||||
|
## 1.9.0
|
||||||
|
|
||||||
|
- Initial release, supports Dart 1.x and many dev versions of Dart 2.x
|
||||||
233
dart/LICENSE
Normal file
233
dart/LICENSE
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
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
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright 2014 Google Inc.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
13
dart/README.md
Normal file
13
dart/README.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# FlatBuffers for Dart
|
||||||
|
|
||||||
|
This package is used to read and write FlatBuffer files in Dart.
|
||||||
|
|
||||||
|
Most consumers will want to use the [`flatc`](https://github.com/google/flatbuffers)
|
||||||
|
compiler to generate Dart code from a FlatBuffers IDL schema. For example, the
|
||||||
|
`monster_my_game.sample_generated.dart` was generated with `flatc` from
|
||||||
|
`monster.fbs` in the example folder. The generated classes can be used to read
|
||||||
|
or write binary files that are interoperable with other languages and platforms
|
||||||
|
supported by FlatBuffers, as illustrated in the `example.dart` in the
|
||||||
|
examples folder.
|
||||||
|
|
||||||
|
Additional documentation and examples are available [at the FlatBuffers site](https://google.github.io/flatbuffers/index.html)
|
||||||
155
dart/example/example.dart
Normal file
155
dart/example/example.dart
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 Dan Field. 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 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||||
|
import './monster_my_game.sample_generated.dart' as myGame;
|
||||||
|
|
||||||
|
// Example how to use FlatBuffers to create and read binary buffers.
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
builderTest();
|
||||||
|
objectBuilderTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
void builderTest() {
|
||||||
|
final builder = new fb.Builder(initialSize: 1024);
|
||||||
|
final int weaponOneName = builder.writeString("Sword");
|
||||||
|
final int weaponOneDamage = 3;
|
||||||
|
|
||||||
|
final int weaponTwoName = builder.writeString("Axe");
|
||||||
|
final int weaponTwoDamage = 5;
|
||||||
|
|
||||||
|
final swordBuilder = new myGame.WeaponBuilder(builder)
|
||||||
|
..begin()
|
||||||
|
..addNameOffset(weaponOneName)
|
||||||
|
..addDamage(weaponOneDamage);
|
||||||
|
final int sword = swordBuilder.finish();
|
||||||
|
|
||||||
|
final axeBuilder = new myGame.WeaponBuilder(builder)
|
||||||
|
..begin()
|
||||||
|
..addNameOffset(weaponTwoName)
|
||||||
|
..addDamage(weaponTwoDamage);
|
||||||
|
final int axe = axeBuilder.finish();
|
||||||
|
|
||||||
|
// Serialize a name for our monster, called "Orc".
|
||||||
|
final int name = builder.writeString('Orc');
|
||||||
|
|
||||||
|
// Create a list representing the inventory of the Orc. Each number
|
||||||
|
// could correspond to an item that can be claimed after he is slain.
|
||||||
|
final List<int> treasure = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||||
|
final inventory = builder.writeListUint8(treasure);
|
||||||
|
final weapons = builder.writeList([sword, axe]);
|
||||||
|
|
||||||
|
// Struct builders are very easy to reuse.
|
||||||
|
final vec3Builder = new myGame.Vec3Builder(builder);
|
||||||
|
|
||||||
|
vec3Builder.finish(4.0, 5.0, 6.0);
|
||||||
|
vec3Builder.finish(1.0, 2.0, 3.0);
|
||||||
|
// Set his hit points to 300 and his mana to 150.
|
||||||
|
final int hp = 300;
|
||||||
|
final int mana = 150;
|
||||||
|
|
||||||
|
final monster = new myGame.MonsterBuilder(builder)
|
||||||
|
..begin()
|
||||||
|
..addNameOffset(name)
|
||||||
|
..addInventoryOffset(inventory)
|
||||||
|
..addWeaponsOffset(weapons)
|
||||||
|
..addEquippedType(myGame.EquipmentTypeId.Weapon)
|
||||||
|
..addEquippedOffset(axe)
|
||||||
|
..addHp(hp)
|
||||||
|
..addMana(mana)
|
||||||
|
..addPos(vec3Builder.finish(1.0, 2.0, 3.0))
|
||||||
|
..addColor(myGame.Color.Red);
|
||||||
|
|
||||||
|
final int monsteroff = monster.finish();
|
||||||
|
final buffer = builder.finish(monsteroff);
|
||||||
|
if (verify(buffer)) {
|
||||||
|
print(
|
||||||
|
"The FlatBuffer was successfully created with a builder and verified!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void objectBuilderTest() {
|
||||||
|
// Create the builder here so we can use it for both weapons and equipped
|
||||||
|
// the actual data will only be written to the buffer once.
|
||||||
|
var axe = new myGame.WeaponObjectBuilder(name: 'Axe', damage: 5);
|
||||||
|
|
||||||
|
var monsterBuilder = new myGame.MonsterObjectBuilder(
|
||||||
|
pos: new myGame.Vec3ObjectBuilder(x: 1.0, y: 2.0, z: 3.0),
|
||||||
|
mana: 150,
|
||||||
|
hp: 300,
|
||||||
|
name: 'Orc',
|
||||||
|
inventory: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
||||||
|
color: myGame.Color.Red,
|
||||||
|
weapons: [new myGame.WeaponObjectBuilder(name: 'Sword', damage: 3), axe],
|
||||||
|
equippedType: myGame.EquipmentTypeId.Weapon,
|
||||||
|
equipped: axe,
|
||||||
|
);
|
||||||
|
|
||||||
|
var buffer = monsterBuilder.toBytes();
|
||||||
|
|
||||||
|
// We now have a FlatBuffer we can store on disk or send over a network.
|
||||||
|
|
||||||
|
// ** file/network code goes here :) **
|
||||||
|
|
||||||
|
// Instead, we're going to access it right away (as if we just received it).
|
||||||
|
if (verify(buffer)) {
|
||||||
|
print(
|
||||||
|
"The FlatBuffer was successfully created with an object builder and verified!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool verify(List<int> buffer) {
|
||||||
|
// Get access to the root:
|
||||||
|
var monster = new myGame.Monster(buffer);
|
||||||
|
|
||||||
|
// Get and test some scalar types from the FlatBuffer.
|
||||||
|
assert(monster.hp == 80);
|
||||||
|
assert(monster.mana == 150); // default
|
||||||
|
assert(monster.name == "MyMonster");
|
||||||
|
|
||||||
|
// Get and test a field of the FlatBuffer's `struct`.
|
||||||
|
var pos = monster.pos;
|
||||||
|
assert(pos != null);
|
||||||
|
assert(pos.z == 3.0);
|
||||||
|
|
||||||
|
// Get a test an element from the `inventory` FlatBuffer's `vector`.
|
||||||
|
var inv = monster.inventory;
|
||||||
|
assert(inv != null);
|
||||||
|
assert(inv.length == 10);
|
||||||
|
assert(inv[9] == 9);
|
||||||
|
|
||||||
|
// Get and test the `weapons` FlatBuffers's `vector`.
|
||||||
|
var expected_weapon_names = ["Sword", "Axe"];
|
||||||
|
var expected_weapon_damages = [3, 5];
|
||||||
|
var weps = monster.weapons;
|
||||||
|
for (int i = 0; i < weps.length; i++) {
|
||||||
|
assert(weps[i].name == expected_weapon_names[i]);
|
||||||
|
assert(weps[i].damage == expected_weapon_damages[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get and test the `Equipment` union (`equipped` field).
|
||||||
|
assert(monster.equippedType.value == myGame.EquipmentTypeId.Weapon.value);
|
||||||
|
assert(monster.equippedType == myGame.EquipmentTypeId.Weapon);
|
||||||
|
|
||||||
|
assert(monster.equipped is myGame.Weapon);
|
||||||
|
var equipped = monster.equipped as myGame.Weapon;
|
||||||
|
assert(equipped.name == "Axe");
|
||||||
|
assert(equipped.damage == 5);
|
||||||
|
|
||||||
|
print(monster);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
440
dart/example/monster_my_game.sample_generated.dart
Normal file
440
dart/example/monster_my_game.sample_generated.dart
Normal file
@@ -0,0 +1,440 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
// ignore_for_file: unused_import, non_constant_identifier_names
|
||||||
|
|
||||||
|
library my_game.sample;
|
||||||
|
|
||||||
|
import 'dart:typed_data' show Uint8List;
|
||||||
|
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||||
|
|
||||||
|
|
||||||
|
class Color {
|
||||||
|
final int value;
|
||||||
|
const Color._(this.value);
|
||||||
|
|
||||||
|
factory Color.fromValue(int value) {
|
||||||
|
if (value == null) return null;
|
||||||
|
if (!values.containsKey(value)) {
|
||||||
|
throw new StateError('Invalid value $value for bit flag enum Color');
|
||||||
|
}
|
||||||
|
return values[value];
|
||||||
|
}
|
||||||
|
|
||||||
|
static const int minValue = 0;
|
||||||
|
static const int maxValue = 2;
|
||||||
|
static bool containsValue(int value) => values.containsKey(value);
|
||||||
|
|
||||||
|
static const Color Red = const Color._(0);
|
||||||
|
static const Color Green = const Color._(1);
|
||||||
|
static const Color Blue = const Color._(2);
|
||||||
|
static get values => {0: Red,1: Green,2: Blue,};
|
||||||
|
|
||||||
|
static const fb.Reader<Color> reader = const _ColorReader();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'Color{value: $value}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ColorReader extends fb.Reader<Color> {
|
||||||
|
const _ColorReader();
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get size => 1;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color read(fb.BufferContext bc, int offset) =>
|
||||||
|
new Color.fromValue(const fb.Int8Reader().read(bc, offset));
|
||||||
|
}
|
||||||
|
|
||||||
|
class EquipmentTypeId {
|
||||||
|
final int value;
|
||||||
|
const EquipmentTypeId._(this.value);
|
||||||
|
|
||||||
|
factory EquipmentTypeId.fromValue(int value) {
|
||||||
|
if (value == null) return null;
|
||||||
|
if (!values.containsKey(value)) {
|
||||||
|
throw new StateError('Invalid value $value for bit flag enum EquipmentTypeId');
|
||||||
|
}
|
||||||
|
return values[value];
|
||||||
|
}
|
||||||
|
|
||||||
|
static const int minValue = 0;
|
||||||
|
static const int maxValue = 1;
|
||||||
|
static bool containsValue(int value) => values.containsKey(value);
|
||||||
|
|
||||||
|
static const EquipmentTypeId NONE = const EquipmentTypeId._(0);
|
||||||
|
static const EquipmentTypeId Weapon = const EquipmentTypeId._(1);
|
||||||
|
static get values => {0: NONE,1: Weapon,};
|
||||||
|
|
||||||
|
static const fb.Reader<EquipmentTypeId> reader = const _EquipmentTypeIdReader();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'EquipmentTypeId{value: $value}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _EquipmentTypeIdReader extends fb.Reader<EquipmentTypeId> {
|
||||||
|
const _EquipmentTypeIdReader();
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get size => 1;
|
||||||
|
|
||||||
|
@override
|
||||||
|
EquipmentTypeId read(fb.BufferContext bc, int offset) =>
|
||||||
|
new EquipmentTypeId.fromValue(const fb.Uint8Reader().read(bc, offset));
|
||||||
|
}
|
||||||
|
|
||||||
|
class Vec3 {
|
||||||
|
Vec3._(this._bc, this._bcOffset);
|
||||||
|
|
||||||
|
static const fb.Reader<Vec3> reader = const _Vec3Reader();
|
||||||
|
|
||||||
|
final fb.BufferContext _bc;
|
||||||
|
final int _bcOffset;
|
||||||
|
|
||||||
|
double get x => const fb.Float32Reader().read(_bc, _bcOffset + 0);
|
||||||
|
double get y => const fb.Float32Reader().read(_bc, _bcOffset + 4);
|
||||||
|
double get z => const fb.Float32Reader().read(_bc, _bcOffset + 8);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'Vec3{x: $x, y: $y, z: $z}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Vec3Reader extends fb.StructReader<Vec3> {
|
||||||
|
const _Vec3Reader();
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get size => 12;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Vec3 createObject(fb.BufferContext bc, int offset) =>
|
||||||
|
new Vec3._(bc, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Vec3Builder {
|
||||||
|
Vec3Builder(this.fbBuilder) {
|
||||||
|
assert(fbBuilder != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
final fb.Builder fbBuilder;
|
||||||
|
|
||||||
|
int finish(double x, double y, double z) {
|
||||||
|
fbBuilder.putFloat32(z);
|
||||||
|
fbBuilder.putFloat32(y);
|
||||||
|
fbBuilder.putFloat32(x);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class Vec3ObjectBuilder extends fb.ObjectBuilder {
|
||||||
|
final double _x;
|
||||||
|
final double _y;
|
||||||
|
final double _z;
|
||||||
|
|
||||||
|
Vec3ObjectBuilder({
|
||||||
|
double x,
|
||||||
|
double y,
|
||||||
|
double z,
|
||||||
|
})
|
||||||
|
: _x = x,
|
||||||
|
_y = y,
|
||||||
|
_z = z;
|
||||||
|
|
||||||
|
/// Finish building, and store into the [fbBuilder].
|
||||||
|
@override
|
||||||
|
int finish(
|
||||||
|
fb.Builder fbBuilder) {
|
||||||
|
assert(fbBuilder != null);
|
||||||
|
|
||||||
|
fbBuilder.putFloat32(_z);
|
||||||
|
fbBuilder.putFloat32(_y);
|
||||||
|
fbBuilder.putFloat32(_x);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convenience method to serialize to byte list.
|
||||||
|
@override
|
||||||
|
Uint8List toBytes([String fileIdentifier]) {
|
||||||
|
fb.Builder fbBuilder = new fb.Builder();
|
||||||
|
int offset = finish(fbBuilder);
|
||||||
|
return fbBuilder.finish(offset, fileIdentifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class Monster {
|
||||||
|
Monster._(this._bc, this._bcOffset);
|
||||||
|
factory Monster(List<int> bytes) {
|
||||||
|
fb.BufferContext rootRef = new fb.BufferContext.fromBytes(bytes);
|
||||||
|
return reader.read(rootRef, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const fb.Reader<Monster> reader = const _MonsterReader();
|
||||||
|
|
||||||
|
final fb.BufferContext _bc;
|
||||||
|
final int _bcOffset;
|
||||||
|
|
||||||
|
Vec3 get pos => Vec3.reader.vTableGet(_bc, _bcOffset, 4, null);
|
||||||
|
int get mana => const fb.Int16Reader().vTableGet(_bc, _bcOffset, 6, 150);
|
||||||
|
int get hp => const fb.Int16Reader().vTableGet(_bc, _bcOffset, 8, 100);
|
||||||
|
String get name => const fb.StringReader().vTableGet(_bc, _bcOffset, 10, null);
|
||||||
|
List<int> get inventory => const fb.ListReader<int>(const fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 14, null);
|
||||||
|
Color get color => new Color.fromValue(const fb.Int8Reader().vTableGet(_bc, _bcOffset, 16, 2));
|
||||||
|
List<Weapon> get weapons => const fb.ListReader<Weapon>(Weapon.reader).vTableGet(_bc, _bcOffset, 18, null);
|
||||||
|
EquipmentTypeId get equippedType => new EquipmentTypeId.fromValue(const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 20, null));
|
||||||
|
dynamic get equipped {
|
||||||
|
switch (equippedType?.value) {
|
||||||
|
case 1: return Weapon.reader.vTableGet(_bc, _bcOffset, 22, null);
|
||||||
|
default: return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<Vec3> get path => const fb.ListReader<Vec3>(Vec3.reader).vTableGet(_bc, _bcOffset, 24, null);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'Monster{pos: $pos, mana: $mana, hp: $hp, name: $name, inventory: $inventory, color: $color, weapons: $weapons, equippedType: $equippedType, equipped: $equipped, path: $path}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MonsterReader extends fb.TableReader<Monster> {
|
||||||
|
const _MonsterReader();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Monster createObject(fb.BufferContext bc, int offset) =>
|
||||||
|
new Monster._(bc, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
class MonsterBuilder {
|
||||||
|
MonsterBuilder(this.fbBuilder) {
|
||||||
|
assert(fbBuilder != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
final fb.Builder fbBuilder;
|
||||||
|
|
||||||
|
void begin() {
|
||||||
|
fbBuilder.startTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
int addPos(int offset) {
|
||||||
|
fbBuilder.addStruct(0, offset);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
int addMana(int mana) {
|
||||||
|
fbBuilder.addInt16(1, mana);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
int addHp(int hp) {
|
||||||
|
fbBuilder.addInt16(2, hp);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
int addNameOffset(int offset) {
|
||||||
|
fbBuilder.addOffset(3, offset);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
int addInventoryOffset(int offset) {
|
||||||
|
fbBuilder.addOffset(5, offset);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
int addColor(Color color) {
|
||||||
|
fbBuilder.addInt8(6, color?.value);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
int addWeaponsOffset(int offset) {
|
||||||
|
fbBuilder.addOffset(7, offset);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
int addEquippedType(EquipmentTypeId equippedType) {
|
||||||
|
fbBuilder.addUint8(8, equippedType?.value);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
int addEquippedOffset(int offset) {
|
||||||
|
fbBuilder.addOffset(9, offset);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
int addPathOffset(int offset) {
|
||||||
|
fbBuilder.addOffset(10, offset);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
int finish() {
|
||||||
|
return fbBuilder.endTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||||
|
final Vec3ObjectBuilder _pos;
|
||||||
|
final int _mana;
|
||||||
|
final int _hp;
|
||||||
|
final String _name;
|
||||||
|
final List<int> _inventory;
|
||||||
|
final Color _color;
|
||||||
|
final List<WeaponObjectBuilder> _weapons;
|
||||||
|
final EquipmentTypeId _equippedType;
|
||||||
|
final dynamic _equipped;
|
||||||
|
final List<Vec3ObjectBuilder> _path;
|
||||||
|
|
||||||
|
MonsterObjectBuilder({
|
||||||
|
Vec3ObjectBuilder pos,
|
||||||
|
int mana,
|
||||||
|
int hp,
|
||||||
|
String name,
|
||||||
|
List<int> inventory,
|
||||||
|
Color color,
|
||||||
|
List<WeaponObjectBuilder> weapons,
|
||||||
|
EquipmentTypeId equippedType,
|
||||||
|
dynamic equipped,
|
||||||
|
List<Vec3ObjectBuilder> path,
|
||||||
|
})
|
||||||
|
: _pos = pos,
|
||||||
|
_mana = mana,
|
||||||
|
_hp = hp,
|
||||||
|
_name = name,
|
||||||
|
_inventory = inventory,
|
||||||
|
_color = color,
|
||||||
|
_weapons = weapons,
|
||||||
|
_equippedType = equippedType,
|
||||||
|
_equipped = equipped,
|
||||||
|
_path = path;
|
||||||
|
|
||||||
|
/// Finish building, and store into the [fbBuilder].
|
||||||
|
@override
|
||||||
|
int finish(
|
||||||
|
fb.Builder fbBuilder) {
|
||||||
|
assert(fbBuilder != null);
|
||||||
|
final int nameOffset = fbBuilder.writeString(_name);
|
||||||
|
final int inventoryOffset = _inventory?.isNotEmpty == true
|
||||||
|
? fbBuilder.writeListUint8(_inventory)
|
||||||
|
: null;
|
||||||
|
final int weaponsOffset = _weapons?.isNotEmpty == true
|
||||||
|
? fbBuilder.writeList(_weapons.map((b) => b.getOrCreateOffset(fbBuilder)).toList())
|
||||||
|
: null;
|
||||||
|
final int equippedOffset = _equipped?.getOrCreateOffset(fbBuilder);
|
||||||
|
final int pathOffset = _path?.isNotEmpty == true
|
||||||
|
? fbBuilder.writeListOfStructs(_path)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
fbBuilder.startTable();
|
||||||
|
if (_pos != null) {
|
||||||
|
fbBuilder.addStruct(0, _pos.finish(fbBuilder));
|
||||||
|
}
|
||||||
|
fbBuilder.addInt16(1, _mana);
|
||||||
|
fbBuilder.addInt16(2, _hp);
|
||||||
|
if (nameOffset != null) {
|
||||||
|
fbBuilder.addOffset(3, nameOffset);
|
||||||
|
}
|
||||||
|
if (inventoryOffset != null) {
|
||||||
|
fbBuilder.addOffset(5, inventoryOffset);
|
||||||
|
}
|
||||||
|
fbBuilder.addInt8(6, _color?.value);
|
||||||
|
if (weaponsOffset != null) {
|
||||||
|
fbBuilder.addOffset(7, weaponsOffset);
|
||||||
|
}
|
||||||
|
fbBuilder.addUint8(8, _equippedType?.value);
|
||||||
|
if (equippedOffset != null) {
|
||||||
|
fbBuilder.addOffset(9, equippedOffset);
|
||||||
|
}
|
||||||
|
if (pathOffset != null) {
|
||||||
|
fbBuilder.addOffset(10, pathOffset);
|
||||||
|
}
|
||||||
|
return fbBuilder.endTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convenience method to serialize to byte list.
|
||||||
|
@override
|
||||||
|
Uint8List toBytes([String fileIdentifier]) {
|
||||||
|
fb.Builder fbBuilder = new fb.Builder();
|
||||||
|
int offset = finish(fbBuilder);
|
||||||
|
return fbBuilder.finish(offset, fileIdentifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class Weapon {
|
||||||
|
Weapon._(this._bc, this._bcOffset);
|
||||||
|
factory Weapon(List<int> bytes) {
|
||||||
|
fb.BufferContext rootRef = new fb.BufferContext.fromBytes(bytes);
|
||||||
|
return reader.read(rootRef, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const fb.Reader<Weapon> reader = const _WeaponReader();
|
||||||
|
|
||||||
|
final fb.BufferContext _bc;
|
||||||
|
final int _bcOffset;
|
||||||
|
|
||||||
|
String get name => const fb.StringReader().vTableGet(_bc, _bcOffset, 4, null);
|
||||||
|
int get damage => const fb.Int16Reader().vTableGet(_bc, _bcOffset, 6, null);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'Weapon{name: $name, damage: $damage}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _WeaponReader extends fb.TableReader<Weapon> {
|
||||||
|
const _WeaponReader();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Weapon createObject(fb.BufferContext bc, int offset) =>
|
||||||
|
new Weapon._(bc, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
class WeaponBuilder {
|
||||||
|
WeaponBuilder(this.fbBuilder) {
|
||||||
|
assert(fbBuilder != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
final fb.Builder fbBuilder;
|
||||||
|
|
||||||
|
void begin() {
|
||||||
|
fbBuilder.startTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
int addNameOffset(int offset) {
|
||||||
|
fbBuilder.addOffset(0, offset);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
int addDamage(int damage) {
|
||||||
|
fbBuilder.addInt16(1, damage);
|
||||||
|
return fbBuilder.offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
int finish() {
|
||||||
|
return fbBuilder.endTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class WeaponObjectBuilder extends fb.ObjectBuilder {
|
||||||
|
final String _name;
|
||||||
|
final int _damage;
|
||||||
|
|
||||||
|
WeaponObjectBuilder({
|
||||||
|
String name,
|
||||||
|
int damage,
|
||||||
|
})
|
||||||
|
: _name = name,
|
||||||
|
_damage = damage;
|
||||||
|
|
||||||
|
/// Finish building, and store into the [fbBuilder].
|
||||||
|
@override
|
||||||
|
int finish(
|
||||||
|
fb.Builder fbBuilder) {
|
||||||
|
assert(fbBuilder != null);
|
||||||
|
final int nameOffset = fbBuilder.writeString(_name);
|
||||||
|
|
||||||
|
fbBuilder.startTable();
|
||||||
|
if (nameOffset != null) {
|
||||||
|
fbBuilder.addOffset(0, nameOffset);
|
||||||
|
}
|
||||||
|
fbBuilder.addInt16(1, _damage);
|
||||||
|
return fbBuilder.endTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convenience method to serialize to byte list.
|
||||||
|
@override
|
||||||
|
Uint8List toBytes([String fileIdentifier]) {
|
||||||
|
fb.Builder fbBuilder = new fb.Builder();
|
||||||
|
int offset = finish(fbBuilder);
|
||||||
|
return fbBuilder.finish(offset, fileIdentifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
1241
dart/lib/flat_buffers.dart
Normal file
1241
dart/lib/flat_buffers.dart
Normal file
File diff suppressed because it is too large
Load Diff
28
dart/publish.sh
Executable file
28
dart/publish.sh
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# Note to pub consumers: this file is used to assist with publishing the
|
||||||
|
# pub package from the flatbuffers repository and is not meant for general use.
|
||||||
|
# As pub does not currently provide a way to exclude files, it is included here.
|
||||||
|
|
||||||
|
command -v pub >/dev/null 2>&1 || { echo >&2 "Require `pub` but it's not installed. Aborting."; exit 1; }
|
||||||
|
|
||||||
|
cp ../samples/monster.fbs example/
|
||||||
|
cp ../tests/monster_test.fbs test/
|
||||||
|
pub publish
|
||||||
|
|
||||||
|
rm example/monster.fbs
|
||||||
|
rm test/monster_test.fbs
|
||||||
20
dart/pubspec.yaml
Normal file
20
dart/pubspec.yaml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
name: flat_buffers
|
||||||
|
version: 1.11.0
|
||||||
|
description: >
|
||||||
|
FlatBuffers reading and writing library for Dart. Use the flatc compiler to
|
||||||
|
generate Dart classes for a FlatBuffers schema, and this library to assist with
|
||||||
|
reading and writing the binary format.
|
||||||
|
|
||||||
|
Based on original work by Konstantin Scheglov and Paul Berry of the Dart SDK team.
|
||||||
|
authors:
|
||||||
|
- Dan Field <dfield@gmail.com>
|
||||||
|
- Konstantin Scheglov
|
||||||
|
- Paul Berry
|
||||||
|
homepage: https://github.com/google/flatbuffers
|
||||||
|
documentation: https://google.github.io/flatbuffers/index.html
|
||||||
|
dev_dependencies:
|
||||||
|
test: ^1.3.0
|
||||||
|
test_reflective_loader: ^0.1.4
|
||||||
|
path: ^1.5.1
|
||||||
|
environment:
|
||||||
|
sdk: '>=2.0.0-dev.28.0 <3.0.0'
|
||||||
573
dart/test/flat_buffers_test.dart
Normal file
573
dart/test/flat_buffers_test.dart
Normal file
@@ -0,0 +1,573 @@
|
|||||||
|
// 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 'package:path/path.dart' as path;
|
||||||
|
|
||||||
|
import 'package:flat_buffers/flat_buffers.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import './monster_test_my_game.example_generated.dart' as example;
|
||||||
|
|
||||||
|
main() {
|
||||||
|
defineReflectiveSuite(() {
|
||||||
|
defineReflectiveTests(BuilderTest);
|
||||||
|
defineReflectiveTests(CheckOtherLangaugesData);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
int indexToField(int index) {
|
||||||
|
return (1 + 1 + index) * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@reflectiveTest
|
||||||
|
class CheckOtherLangaugesData {
|
||||||
|
test_cppData() async {
|
||||||
|
List<int> data = await new io.File(path.join(
|
||||||
|
path.dirname(io.Platform.script.path),
|
||||||
|
'monsterdata_test.mon',
|
||||||
|
))
|
||||||
|
.readAsBytes();
|
||||||
|
example.Monster mon = new example.Monster(data);
|
||||||
|
expect(mon.hp, 80);
|
||||||
|
expect(mon.mana, 150);
|
||||||
|
expect(mon.name, 'MyMonster');
|
||||||
|
expect(mon.pos.x, 1.0);
|
||||||
|
expect(mon.pos.y, 2.0);
|
||||||
|
expect(mon.pos.z, 3.0);
|
||||||
|
expect(mon.pos.test1, 3.0);
|
||||||
|
expect(mon.pos.test2.value, 2.0);
|
||||||
|
expect(mon.pos.test3.a, 5);
|
||||||
|
expect(mon.pos.test3.b, 6);
|
||||||
|
expect(mon.testType.value, example.AnyTypeId.Monster.value);
|
||||||
|
expect(mon.test is example.Monster, true);
|
||||||
|
final monster2 = mon.test as example.Monster;
|
||||||
|
expect(monster2.name, "Fred");
|
||||||
|
|
||||||
|
expect(mon.inventory.length, 5);
|
||||||
|
expect(mon.inventory.reduce((cur, next) => cur + next), 10);
|
||||||
|
expect(mon.test4.length, 2);
|
||||||
|
expect(
|
||||||
|
mon.test4[0].a + mon.test4[0].b + mon.test4[1].a + mon.test4[1].b, 100);
|
||||||
|
expect(mon.testarrayofstring.length, 2);
|
||||||
|
expect(mon.testarrayofstring[0], "test1");
|
||||||
|
expect(mon.testarrayofstring[1], "test2");
|
||||||
|
|
||||||
|
// this will fail if accessing any field fails.
|
||||||
|
expect(mon.toString(),
|
||||||
|
'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}}, mana: 150, hp: 80, name: MyMonster, inventory: [0, 1, 2, 3, 4], color: Color{value: 8}, testType: AnyTypeId{value: 1}, test: Monster{pos: null, mana: 150, hp: 100, name: Fred, inventory: null, color: Color{value: 8}, testType: AnyTypeId{value: 0}, test: null, test4: null, testarrayofstring: null, testarrayoftables: null, enemy: null, testnestedflatbuffer: null, testempty: null, testbool: false, testhashs32Fnv1: 0, testhashu32Fnv1: 0, testhashs64Fnv1: 0, testhashu64Fnv1: 0, testhashs32Fnv1a: 0, testhashu32Fnv1a: 0, testhashs64Fnv1a: 0, testhashu64Fnv1a: 0, testarrayofbools: null, testf: 3.14159, testf2: 3.0, testf3: 0.0, testarrayofstring2: null, testarrayofsortedstruct: null, flex: null, test5: null, vectorOfLongs: null, vectorOfDoubles: null, parentNamespaceTest: null, vectorOfReferrables: null, singleWeakReference: 0, vectorOfWeakReferences: null, vectorOfStrongReferrables: null, coOwningReference: 0, vectorOfCoOwningReferences: null, nonOwningReference: 0, vectorOfNonOwningReferences: null}, test4: [Test{a: 10, b: 20}, Test{a: 30, b: 40}], testarrayofstring: [test1, test2], testarrayoftables: null, enemy: Monster{pos: null, mana: 150, hp: 100, name: Fred, inventory: null, color: Color{value: 8}, testType: AnyTypeId{value: 0}, test: null, test4: null, testarrayofstring: null, testarrayoftables: null, enemy: null, testnestedflatbuffer: null, testempty: null, testbool: false, testhashs32Fnv1: 0, testhashu32Fnv1: 0, testhashs64Fnv1: 0, testhashu64Fnv1: 0, testhashs32Fnv1a: 0, testhashu32Fnv1a: 0, testhashs64Fnv1a: 0, testhashu64Fnv1a: 0, testarrayofbools: null, testf: 3.14159, testf2: 3.0, testf3: 0.0, testarrayofstring2: null, testarrayofsortedstruct: null, flex: null, test5: null, vectorOfLongs: null, vectorOfDoubles: null, parentNamespaceTest: null, vectorOfReferrables: null, singleWeakReference: 0, vectorOfWeakReferences: null, vectorOfStrongReferrables: null, coOwningReference: 0, vectorOfCoOwningReferences: null, nonOwningReference: 0, vectorOfNonOwningReferences: null}, testnestedflatbuffer: null, testempty: null, testbool: false, testhashs32Fnv1: -579221183, testhashu32Fnv1: 3715746113, testhashs64Fnv1: 7930699090847568257, testhashu64Fnv1: 7930699090847568257, testhashs32Fnv1a: -1904106383, testhashu32Fnv1a: 2390860913, testhashs64Fnv1a: 4898026182817603057, testhashu64Fnv1a: 4898026182817603057, testarrayofbools: [true, false, true], testf: 3.14159, testf2: 3.0, testf3: 0.0, testarrayofstring2: null, testarrayofsortedstruct: null, flex: null, test5: [Test{a: 10, b: 20}, Test{a: 30, b: 40}], vectorOfLongs: [1, 100, 10000, 1000000, 100000000], vectorOfDoubles: [-1.7976931348623157e+308, 0.0, 1.7976931348623157e+308], parentNamespaceTest: null, vectorOfReferrables: null, singleWeakReference: 0, vectorOfWeakReferences: null, vectorOfStrongReferrables: null, coOwningReference: 0, vectorOfCoOwningReferences: null, nonOwningReference: 0, vectorOfNonOwningReferences: null}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@reflectiveTest
|
||||||
|
class BuilderTest {
|
||||||
|
void test_monsterBuilder() {
|
||||||
|
final fbBuilder = new Builder();
|
||||||
|
final str = fbBuilder.writeString('MyMonster');
|
||||||
|
|
||||||
|
fbBuilder.writeString('test1');
|
||||||
|
fbBuilder.writeString('test2');
|
||||||
|
final testArrayOfString = fbBuilder.endStructVector(2);
|
||||||
|
|
||||||
|
final fred = fbBuilder.writeString('Fred');
|
||||||
|
|
||||||
|
final List<int> treasure = [0, 1, 2, 3, 4];
|
||||||
|
final inventory = fbBuilder.writeListUint8(treasure);
|
||||||
|
|
||||||
|
final monBuilder = new example.MonsterBuilder(fbBuilder)
|
||||||
|
..begin()
|
||||||
|
..addNameOffset(fred);
|
||||||
|
final mon2 = monBuilder.finish();
|
||||||
|
|
||||||
|
final testBuilder = new example.TestBuilder(fbBuilder);
|
||||||
|
testBuilder.finish(10, 20);
|
||||||
|
testBuilder.finish(30, 40);
|
||||||
|
final test4 = fbBuilder.endStructVector(2);
|
||||||
|
|
||||||
|
|
||||||
|
monBuilder
|
||||||
|
..begin()
|
||||||
|
..addPos(
|
||||||
|
new example.Vec3Builder(fbBuilder).finish(
|
||||||
|
1.0,
|
||||||
|
2.0,
|
||||||
|
3.0,
|
||||||
|
3.0,
|
||||||
|
example.Color.Green,
|
||||||
|
() => testBuilder.finish(5, 6),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
..addHp(80)
|
||||||
|
..addNameOffset(str)
|
||||||
|
..addInventoryOffset(inventory)
|
||||||
|
..addTestType(example.AnyTypeId.Monster)
|
||||||
|
..addTestOffset(mon2)
|
||||||
|
..addTest4Offset(test4)
|
||||||
|
..addTestarrayofstringOffset(testArrayOfString);
|
||||||
|
final mon = monBuilder.finish();
|
||||||
|
fbBuilder.finish(mon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_error_addInt32_withoutStartTable() {
|
||||||
|
Builder builder = new Builder();
|
||||||
|
expect(() {
|
||||||
|
builder.addInt32(0, 0);
|
||||||
|
}, throwsStateError);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_error_addOffset_withoutStartTable() {
|
||||||
|
Builder builder = new Builder();
|
||||||
|
expect(() {
|
||||||
|
builder.addOffset(0, 0);
|
||||||
|
}, throwsStateError);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_error_endTable_withoutStartTable() {
|
||||||
|
Builder builder = new Builder();
|
||||||
|
expect(() {
|
||||||
|
builder.endTable();
|
||||||
|
}, throwsStateError);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_error_startTable_duringTable() {
|
||||||
|
Builder builder = new Builder();
|
||||||
|
builder.startTable();
|
||||||
|
expect(() {
|
||||||
|
builder.startTable();
|
||||||
|
}, throwsStateError);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_error_writeString_duringTable() {
|
||||||
|
Builder builder = new Builder();
|
||||||
|
builder.startTable();
|
||||||
|
expect(() {
|
||||||
|
builder.writeString('12345');
|
||||||
|
}, throwsStateError);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_file_identifier() {
|
||||||
|
Uint8List byteList;
|
||||||
|
{
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
builder.startTable();
|
||||||
|
int offset = builder.endTable();
|
||||||
|
byteList = builder.finish(offset, 'Az~ÿ');
|
||||||
|
}
|
||||||
|
// Convert byteList to a ByteData so that we can read data from it.
|
||||||
|
ByteData byteData = byteList.buffer.asByteData(byteList.offsetInBytes);
|
||||||
|
// First 4 bytes are an offset to the table data.
|
||||||
|
int tableDataLoc = byteData.getUint32(0, Endian.little);
|
||||||
|
// Next 4 bytes are the file identifier.
|
||||||
|
expect(byteData.getUint8(4), 65); // 'a'
|
||||||
|
expect(byteData.getUint8(5), 122); // 'z'
|
||||||
|
expect(byteData.getUint8(6), 126); // '~'
|
||||||
|
expect(byteData.getUint8(7), 255); // 'ÿ'
|
||||||
|
// First 4 bytes of the table data are a backwards offset to the vtable.
|
||||||
|
int vTableLoc = tableDataLoc -
|
||||||
|
byteData.getInt32(tableDataLoc, Endian.little);
|
||||||
|
// First 2 bytes of the vtable are the size of the vtable in bytes, which
|
||||||
|
// should be 4.
|
||||||
|
expect(byteData.getUint16(vTableLoc, Endian.little), 4);
|
||||||
|
// Next 2 bytes are the size of the object in bytes (including the vtable
|
||||||
|
// pointer), which should be 4.
|
||||||
|
expect(byteData.getUint16(vTableLoc + 2, Endian.little), 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_low() {
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
expect((builder..putUint8(1)).lowFinish(), [1]);
|
||||||
|
expect((builder..putUint32(2)).lowFinish(), [2, 0, 0, 0, 0, 0, 0, 1]);
|
||||||
|
expect((builder..putUint8(3)).lowFinish(),
|
||||||
|
[0, 0, 0, 3, 2, 0, 0, 0, 0, 0, 0, 1]);
|
||||||
|
expect((builder..putUint8(4)).lowFinish(),
|
||||||
|
[0, 0, 4, 3, 2, 0, 0, 0, 0, 0, 0, 1]);
|
||||||
|
expect((builder..putUint8(5)).lowFinish(),
|
||||||
|
[0, 5, 4, 3, 2, 0, 0, 0, 0, 0, 0, 1]);
|
||||||
|
expect((builder..putUint32(6)).lowFinish(),
|
||||||
|
[6, 0, 0, 0, 0, 5, 4, 3, 2, 0, 0, 0, 0, 0, 0, 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_table_default() {
|
||||||
|
List<int> byteList;
|
||||||
|
{
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
builder.startTable();
|
||||||
|
builder.addInt32(0, 10, 10);
|
||||||
|
builder.addInt32(1, 20, 10);
|
||||||
|
int offset = builder.endTable();
|
||||||
|
byteList = builder.finish(offset);
|
||||||
|
}
|
||||||
|
// read and verify
|
||||||
|
BufferContext buffer = new BufferContext.fromBytes(byteList);
|
||||||
|
int objectOffset = buffer.derefObject(0);
|
||||||
|
// was not written, so uses the new default value
|
||||||
|
expect(
|
||||||
|
const Int32Reader()
|
||||||
|
.vTableGet(buffer, objectOffset, indexToField(0), 15),
|
||||||
|
15);
|
||||||
|
// has the written value
|
||||||
|
expect(
|
||||||
|
const Int32Reader()
|
||||||
|
.vTableGet(buffer, objectOffset, indexToField(1), 15),
|
||||||
|
20);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_table_format() {
|
||||||
|
Uint8List byteList;
|
||||||
|
{
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
builder.startTable();
|
||||||
|
builder.addInt32(0, 10);
|
||||||
|
builder.addInt32(1, 20);
|
||||||
|
builder.addInt32(2, 30);
|
||||||
|
byteList = builder.finish(builder.endTable());
|
||||||
|
}
|
||||||
|
// Convert byteList to a ByteData so that we can read data from it.
|
||||||
|
ByteData byteData = byteList.buffer.asByteData(byteList.offsetInBytes);
|
||||||
|
// First 4 bytes are an offset to the table data.
|
||||||
|
int tableDataLoc = byteData.getUint32(0, Endian.little);
|
||||||
|
// First 4 bytes of the table data are a backwards offset to the vtable.
|
||||||
|
int vTableLoc = tableDataLoc -
|
||||||
|
byteData.getInt32(tableDataLoc, Endian.little);
|
||||||
|
// First 2 bytes of the vtable are the size of the vtable in bytes, which
|
||||||
|
// should be 10.
|
||||||
|
expect(byteData.getUint16(vTableLoc, Endian.little), 10);
|
||||||
|
// Next 2 bytes are the size of the object in bytes (including the vtable
|
||||||
|
// pointer), which should be 16.
|
||||||
|
expect(byteData.getUint16(vTableLoc + 2, Endian.little), 16);
|
||||||
|
// Remaining 6 bytes are the offsets within the object where the ints are
|
||||||
|
// located.
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
int offset =
|
||||||
|
byteData.getUint16(vTableLoc + 4 + 2 * i, Endian.little);
|
||||||
|
expect(byteData.getInt32(tableDataLoc + offset, Endian.little),
|
||||||
|
10 + 10 * i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_table_string() {
|
||||||
|
String latinString = 'test';
|
||||||
|
String unicodeString = 'Проба пера';
|
||||||
|
List<int> byteList;
|
||||||
|
{
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
int latinStringOffset = builder.writeString(latinString);
|
||||||
|
int unicodeStringOffset = builder.writeString(unicodeString);
|
||||||
|
builder.startTable();
|
||||||
|
builder.addOffset(0, latinStringOffset);
|
||||||
|
builder.addOffset(1, unicodeStringOffset);
|
||||||
|
int offset = builder.endTable();
|
||||||
|
byteList = builder.finish(offset);
|
||||||
|
}
|
||||||
|
// read and verify
|
||||||
|
BufferContext buf = new BufferContext.fromBytes(byteList);
|
||||||
|
int objectOffset = buf.derefObject(0);
|
||||||
|
expect(const StringReader().vTableGet(buf, objectOffset, indexToField(0)),
|
||||||
|
latinString);
|
||||||
|
expect(const StringReader().vTableGet(buf, objectOffset, indexToField(1)),
|
||||||
|
unicodeString);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_table_types() {
|
||||||
|
List<int> byteList;
|
||||||
|
{
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
int stringOffset = builder.writeString('12345');
|
||||||
|
builder.startTable();
|
||||||
|
builder.addBool(0, true);
|
||||||
|
builder.addInt8(1, 10);
|
||||||
|
builder.addInt32(2, 20);
|
||||||
|
builder.addOffset(3, stringOffset);
|
||||||
|
builder.addInt32(4, 40);
|
||||||
|
builder.addUint32(5, 0x9ABCDEF0);
|
||||||
|
builder.addUint8(6, 0x9A);
|
||||||
|
int offset = builder.endTable();
|
||||||
|
byteList = builder.finish(offset);
|
||||||
|
}
|
||||||
|
// read and verify
|
||||||
|
BufferContext buf = new BufferContext.fromBytes(byteList);
|
||||||
|
int objectOffset = buf.derefObject(0);
|
||||||
|
expect(
|
||||||
|
const BoolReader().vTableGet(buf, objectOffset, indexToField(0)), true);
|
||||||
|
expect(
|
||||||
|
const Int8Reader().vTableGet(buf, objectOffset, indexToField(1)), 10);
|
||||||
|
expect(
|
||||||
|
const Int32Reader().vTableGet(buf, objectOffset, indexToField(2)), 20);
|
||||||
|
expect(const StringReader().vTableGet(buf, objectOffset, indexToField(3)),
|
||||||
|
'12345');
|
||||||
|
expect(
|
||||||
|
const Int32Reader().vTableGet(buf, objectOffset, indexToField(4)), 40);
|
||||||
|
expect(const Uint32Reader().vTableGet(buf, objectOffset, indexToField(5)),
|
||||||
|
0x9ABCDEF0);
|
||||||
|
expect(const Uint8Reader().vTableGet(buf, objectOffset, indexToField(6)),
|
||||||
|
0x9A);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_writeList_of_Uint32() {
|
||||||
|
List<int> values = <int>[10, 100, 12345, 0x9abcdef0];
|
||||||
|
// write
|
||||||
|
List<int> byteList;
|
||||||
|
{
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
int offset = builder.writeListUint32(values);
|
||||||
|
byteList = builder.finish(offset);
|
||||||
|
}
|
||||||
|
// read and verify
|
||||||
|
BufferContext buf = new BufferContext.fromBytes(byteList);
|
||||||
|
List<int> items = const Uint32ListReader().read(buf, 0);
|
||||||
|
expect(items, hasLength(4));
|
||||||
|
expect(items, orderedEquals(values));
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_writeList_ofBool() {
|
||||||
|
void verifyListBooleans(int len, List<int> trueBits) {
|
||||||
|
// write
|
||||||
|
List<int> byteList;
|
||||||
|
{
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
List<bool> values = new List<bool>.filled(len, false);
|
||||||
|
for (int bit in trueBits) {
|
||||||
|
values[bit] = true;
|
||||||
|
}
|
||||||
|
int offset = builder.writeListBool(values);
|
||||||
|
byteList = builder.finish(offset);
|
||||||
|
}
|
||||||
|
// read and verify
|
||||||
|
BufferContext buf = new BufferContext.fromBytes(byteList);
|
||||||
|
List<bool> items = const BoolListReader().read(buf, 0);
|
||||||
|
expect(items, hasLength(len));
|
||||||
|
for (int i = 0; i < items.length; i++) {
|
||||||
|
expect(items[i], trueBits.contains(i), reason: 'bit $i of $len');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
verifyListBooleans(0, <int>[]);
|
||||||
|
verifyListBooleans(1, <int>[]);
|
||||||
|
verifyListBooleans(1, <int>[0]);
|
||||||
|
verifyListBooleans(31, <int>[0, 1]);
|
||||||
|
verifyListBooleans(31, <int>[1, 2, 24, 25, 30]);
|
||||||
|
verifyListBooleans(31, <int>[0, 30]);
|
||||||
|
verifyListBooleans(32, <int>[1, 2, 24, 25, 31]);
|
||||||
|
verifyListBooleans(33, <int>[1, 2, 24, 25, 32]);
|
||||||
|
verifyListBooleans(33, <int>[1, 2, 24, 25, 31, 32]);
|
||||||
|
verifyListBooleans(63, <int>[]);
|
||||||
|
verifyListBooleans(63, <int>[0, 1, 2, 61, 62]);
|
||||||
|
verifyListBooleans(63, new List<int>.generate(63, (i) => i));
|
||||||
|
verifyListBooleans(64, <int>[]);
|
||||||
|
verifyListBooleans(64, <int>[0, 1, 2, 61, 62, 63]);
|
||||||
|
verifyListBooleans(64, <int>[1, 2, 62]);
|
||||||
|
verifyListBooleans(64, <int>[0, 1, 2, 63]);
|
||||||
|
verifyListBooleans(64, new List<int>.generate(64, (i) => i));
|
||||||
|
verifyListBooleans(100, <int>[0, 3, 30, 60, 90, 99]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_writeList_ofInt32() {
|
||||||
|
List<int> byteList;
|
||||||
|
{
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
int offset = builder.writeListInt32(<int>[1, 2, 3, 4, 5]);
|
||||||
|
byteList = builder.finish(offset);
|
||||||
|
}
|
||||||
|
// read and verify
|
||||||
|
BufferContext buf = new BufferContext.fromBytes(byteList);
|
||||||
|
List<int> items = const ListReader<int>(const Int32Reader()).read(buf, 0);
|
||||||
|
expect(items, hasLength(5));
|
||||||
|
expect(items, orderedEquals(<int>[1, 2, 3, 4, 5]));
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_writeList_ofFloat64() {
|
||||||
|
List<double> values = <double>[-1.234567, 3.4E+9, -5.6E-13, 7.8, 12.13];
|
||||||
|
// write
|
||||||
|
List<int> byteList;
|
||||||
|
{
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
int offset = builder.writeListFloat64(values);
|
||||||
|
byteList = builder.finish(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
// read and verify
|
||||||
|
BufferContext buf = new BufferContext.fromBytes(byteList);
|
||||||
|
List<double> items = const Float64ListReader().read(buf, 0);
|
||||||
|
|
||||||
|
expect(items, hasLength(values.length));
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
expect(values[i], closeTo(items[i], .001));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_writeList_ofFloat32() {
|
||||||
|
List<double> values = [1.0, 2.23, -3.213, 7.8, 12.13];
|
||||||
|
// write
|
||||||
|
List<int> byteList;
|
||||||
|
{
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
int offset = builder.writeListFloat32(values);
|
||||||
|
byteList = builder.finish(offset);
|
||||||
|
}
|
||||||
|
// read and verify
|
||||||
|
BufferContext buf = new BufferContext.fromBytes(byteList);
|
||||||
|
List<double> items = const Float32ListReader().read(buf, 0);
|
||||||
|
expect(items, hasLength(5));
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
expect(values[i], closeTo(items[i], .001));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_writeList_ofObjects() {
|
||||||
|
List<int> byteList;
|
||||||
|
{
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
// write the object #1
|
||||||
|
int object1;
|
||||||
|
{
|
||||||
|
builder.startTable();
|
||||||
|
builder.addInt32(0, 10);
|
||||||
|
builder.addInt32(1, 20);
|
||||||
|
object1 = builder.endTable();
|
||||||
|
}
|
||||||
|
// write the object #1
|
||||||
|
int object2;
|
||||||
|
{
|
||||||
|
builder.startTable();
|
||||||
|
builder.addInt32(0, 100);
|
||||||
|
builder.addInt32(1, 200);
|
||||||
|
object2 = builder.endTable();
|
||||||
|
}
|
||||||
|
// write the list
|
||||||
|
int offset = builder.writeList([object1, object2]);
|
||||||
|
byteList = builder.finish(offset);
|
||||||
|
}
|
||||||
|
// read and verify
|
||||||
|
BufferContext buf = new BufferContext.fromBytes(byteList);
|
||||||
|
List<TestPointImpl> items =
|
||||||
|
const ListReader<TestPointImpl>(const TestPointReader()).read(buf, 0);
|
||||||
|
expect(items, hasLength(2));
|
||||||
|
expect(items[0].x, 10);
|
||||||
|
expect(items[0].y, 20);
|
||||||
|
expect(items[1].x, 100);
|
||||||
|
expect(items[1].y, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_writeList_ofStrings_asRoot() {
|
||||||
|
List<int> byteList;
|
||||||
|
{
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
int str1 = builder.writeString('12345');
|
||||||
|
int str2 = builder.writeString('ABC');
|
||||||
|
int offset = builder.writeList([str1, str2]);
|
||||||
|
byteList = builder.finish(offset);
|
||||||
|
}
|
||||||
|
// read and verify
|
||||||
|
BufferContext buf = new BufferContext.fromBytes(byteList);
|
||||||
|
List<String> items =
|
||||||
|
const ListReader<String>(const StringReader()).read(buf, 0);
|
||||||
|
expect(items, hasLength(2));
|
||||||
|
expect(items, contains('12345'));
|
||||||
|
expect(items, contains('ABC'));
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_writeList_ofStrings_inObject() {
|
||||||
|
List<int> byteList;
|
||||||
|
{
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
int listOffset = builder.writeList(
|
||||||
|
[builder.writeString('12345'), builder.writeString('ABC')]);
|
||||||
|
builder.startTable();
|
||||||
|
builder.addOffset(0, listOffset);
|
||||||
|
int offset = builder.endTable();
|
||||||
|
byteList = builder.finish(offset);
|
||||||
|
}
|
||||||
|
// read and verify
|
||||||
|
BufferContext buf = new BufferContext.fromBytes(byteList);
|
||||||
|
StringListWrapperImpl reader = new StringListWrapperReader().read(buf, 0);
|
||||||
|
List<String> items = reader.items;
|
||||||
|
expect(items, hasLength(2));
|
||||||
|
expect(items, contains('12345'));
|
||||||
|
expect(items, contains('ABC'));
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_writeList_ofUint32() {
|
||||||
|
List<int> byteList;
|
||||||
|
{
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
int offset = builder.writeListUint32(<int>[1, 2, 0x9ABCDEF0]);
|
||||||
|
byteList = builder.finish(offset);
|
||||||
|
}
|
||||||
|
// read and verify
|
||||||
|
BufferContext buf = new BufferContext.fromBytes(byteList);
|
||||||
|
List<int> items = const Uint32ListReader().read(buf, 0);
|
||||||
|
expect(items, hasLength(3));
|
||||||
|
expect(items, orderedEquals(<int>[1, 2, 0x9ABCDEF0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_writeList_ofUint16() {
|
||||||
|
List<int> byteList;
|
||||||
|
{
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
int offset = builder.writeListUint16(<int>[1, 2, 60000]);
|
||||||
|
byteList = builder.finish(offset);
|
||||||
|
}
|
||||||
|
// read and verify
|
||||||
|
BufferContext buf = new BufferContext.fromBytes(byteList);
|
||||||
|
List<int> items = const Uint16ListReader().read(buf, 0);
|
||||||
|
expect(items, hasLength(3));
|
||||||
|
expect(items, orderedEquals(<int>[1, 2, 60000]));
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_writeList_ofUint8() {
|
||||||
|
List<int> byteList;
|
||||||
|
{
|
||||||
|
Builder builder = new Builder(initialSize: 0);
|
||||||
|
int offset = builder.writeListUint8(<int>[1, 2, 3, 4, 0x9A]);
|
||||||
|
byteList = builder.finish(offset);
|
||||||
|
}
|
||||||
|
// read and verify
|
||||||
|
BufferContext buf = new BufferContext.fromBytes(byteList);
|
||||||
|
List<int> items = const Uint8ListReader().read(buf, 0);
|
||||||
|
expect(items, hasLength(5));
|
||||||
|
expect(items, orderedEquals(<int>[1, 2, 3, 4, 0x9A]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class StringListWrapperImpl {
|
||||||
|
final BufferContext bp;
|
||||||
|
final int offset;
|
||||||
|
|
||||||
|
StringListWrapperImpl(this.bp, this.offset);
|
||||||
|
|
||||||
|
List<String> get items => const ListReader<String>(const StringReader())
|
||||||
|
.vTableGet(bp, offset, indexToField(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
class StringListWrapperReader extends TableReader<StringListWrapperImpl> {
|
||||||
|
const StringListWrapperReader();
|
||||||
|
|
||||||
|
@override
|
||||||
|
StringListWrapperImpl createObject(BufferContext object, int offset) {
|
||||||
|
return new StringListWrapperImpl(object, offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestPointImpl {
|
||||||
|
final BufferContext bp;
|
||||||
|
final int offset;
|
||||||
|
|
||||||
|
TestPointImpl(this.bp, this.offset);
|
||||||
|
|
||||||
|
int get x => const Int32Reader().vTableGet(bp, offset, indexToField(0), 0);
|
||||||
|
|
||||||
|
int get y => const Int32Reader().vTableGet(bp, offset, indexToField(1), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestPointReader extends TableReader<TestPointImpl> {
|
||||||
|
const TestPointReader();
|
||||||
|
|
||||||
|
@override
|
||||||
|
TestPointImpl createObject(BufferContext object, int offset) {
|
||||||
|
return new TestPointImpl(object, offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
62
dart/test/monster_test_my_game.example2_generated.dart
Normal file
62
dart/test/monster_test_my_game.example2_generated.dart
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
// ignore_for_file: unused_import, unused_field, unused_local_variable
|
||||||
|
|
||||||
|
library my_game.example2;
|
||||||
|
|
||||||
|
import 'dart:typed_data' show Uint8List;
|
||||||
|
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||||
|
|
||||||
|
import 'include_test1_my_game.example2_generated.dart';
|
||||||
|
import 'include_test2_my_game.example2_generated.dart';
|
||||||
|
import './monster_test_my_game_generated.dart' as my_game;
|
||||||
|
import './monster_test_my_game.example_generated.dart' as my_game_example;
|
||||||
|
|
||||||
|
class Monster {
|
||||||
|
Monster._(this._bc, this._bcOffset);
|
||||||
|
factory Monster(List<int> bytes) {
|
||||||
|
fb.BufferContext rootRef = new fb.BufferContext.fromBytes(bytes);
|
||||||
|
return reader.read(rootRef, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const fb.Reader<Monster> reader = const _MonsterReader();
|
||||||
|
|
||||||
|
final fb.BufferContext _bc;
|
||||||
|
final int _bcOffset;
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'Monster{}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MonsterReader extends fb.TableReader<Monster> {
|
||||||
|
const _MonsterReader();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Monster createObject(fb.BufferContext bc, int offset) =>
|
||||||
|
new Monster._(bc, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||||
|
|
||||||
|
MonsterObjectBuilder();
|
||||||
|
|
||||||
|
/// Finish building, and store into the [fbBuilder].
|
||||||
|
@override
|
||||||
|
int finish(
|
||||||
|
fb.Builder fbBuilder) {
|
||||||
|
assert(fbBuilder != null);
|
||||||
|
|
||||||
|
fbBuilder.startTable();
|
||||||
|
return fbBuilder.endTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convenience method to serialize to byte list.
|
||||||
|
@override
|
||||||
|
Uint8List toBytes([String fileIdentifier]) {
|
||||||
|
fb.Builder fbBuilder = new fb.Builder();
|
||||||
|
int offset = finish(fbBuilder);
|
||||||
|
return fbBuilder.finish(offset, fileIdentifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
1486
dart/test/monster_test_my_game.example_generated.dart
Normal file
1486
dart/test/monster_test_my_game.example_generated.dart
Normal file
File diff suppressed because it is too large
Load Diff
62
dart/test/monster_test_my_game_generated.dart
Normal file
62
dart/test/monster_test_my_game_generated.dart
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
// ignore_for_file: unused_import, unused_field, unused_local_variable
|
||||||
|
|
||||||
|
library my_game;
|
||||||
|
|
||||||
|
import 'dart:typed_data' show Uint8List;
|
||||||
|
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||||
|
|
||||||
|
import 'include_test1_my_game_generated.dart';
|
||||||
|
import 'include_test2_my_game_generated.dart';
|
||||||
|
import './monster_test_my_game.example_generated.dart' as my_game_example;
|
||||||
|
import './monster_test_my_game.example2_generated.dart' as my_game_example2;
|
||||||
|
|
||||||
|
class InParentNamespace {
|
||||||
|
InParentNamespace._(this._bc, this._bcOffset);
|
||||||
|
factory InParentNamespace(List<int> bytes) {
|
||||||
|
fb.BufferContext rootRef = new fb.BufferContext.fromBytes(bytes);
|
||||||
|
return reader.read(rootRef, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const fb.Reader<InParentNamespace> reader = const _InParentNamespaceReader();
|
||||||
|
|
||||||
|
final fb.BufferContext _bc;
|
||||||
|
final int _bcOffset;
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'InParentNamespace{}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _InParentNamespaceReader extends fb.TableReader<InParentNamespace> {
|
||||||
|
const _InParentNamespaceReader();
|
||||||
|
|
||||||
|
@override
|
||||||
|
InParentNamespace createObject(fb.BufferContext bc, int offset) =>
|
||||||
|
new InParentNamespace._(bc, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
class InParentNamespaceObjectBuilder extends fb.ObjectBuilder {
|
||||||
|
|
||||||
|
InParentNamespaceObjectBuilder();
|
||||||
|
|
||||||
|
/// Finish building, and store into the [fbBuilder].
|
||||||
|
@override
|
||||||
|
int finish(
|
||||||
|
fb.Builder fbBuilder) {
|
||||||
|
assert(fbBuilder != null);
|
||||||
|
|
||||||
|
fbBuilder.startTable();
|
||||||
|
return fbBuilder.endTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convenience method to serialize to byte list.
|
||||||
|
@override
|
||||||
|
Uint8List toBytes([String fileIdentifier]) {
|
||||||
|
fb.Builder fbBuilder = new fb.Builder();
|
||||||
|
int offset = finish(fbBuilder);
|
||||||
|
return fbBuilder.finish(offset, fileIdentifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
0
docs/footer.html
Executable file → Normal file
0
docs/footer.html
Executable file → Normal file
2
docs/source/Benchmarks.md
Executable file → Normal file
2
docs/source/Benchmarks.md
Executable file → Normal file
@@ -1,4 +1,4 @@
|
|||||||
Benchmarks {#flatbuffers_benchmarks}
|
C++ Benchmarks {#flatbuffers_benchmarks}
|
||||||
==========
|
==========
|
||||||
|
|
||||||
Comparing against other serialization solutions, running on Windows 7
|
Comparing against other serialization solutions, running on Windows 7
|
||||||
|
|||||||
50
docs/source/Building.md
Executable file → Normal file
50
docs/source/Building.md
Executable file → Normal file
@@ -1,21 +1,16 @@
|
|||||||
Building {#flatbuffers_guide_building}
|
Building {#flatbuffers_guide_building}
|
||||||
========
|
========
|
||||||
|
|
||||||
## Building with Visual Studio or Xcode projects
|
|
||||||
|
|
||||||
There are project files for Visual Studio and Xcode that should allow you
|
|
||||||
to build the compiler `flatc`, the samples and the tests out of the box.
|
|
||||||
|
|
||||||
## Building with CMake
|
## Building with CMake
|
||||||
|
|
||||||
Alternatively, the distribution comes with a `cmake` file that should allow
|
The distribution comes with a `cmake` file that should allow
|
||||||
you to build project/make files for any platform. For details on `cmake`, see
|
you to build project/make files for any platform. For details on `cmake`, see
|
||||||
<http://www.cmake.org>. In brief, depending on your platform, use one of
|
<https://www.cmake.org>. In brief, depending on your platform, use one of
|
||||||
e.g.:
|
e.g.:
|
||||||
|
|
||||||
cmake -G "Unix Makefiles"
|
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
|
||||||
cmake -G "Visual Studio 10"
|
cmake -G "Visual Studio 10" -DCMAKE_BUILD_TYPE=Release
|
||||||
cmake -G "Xcode"
|
cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release
|
||||||
|
|
||||||
Then, build as normal for your platform. This should result in a `flatc`
|
Then, build as normal for your platform. This should result in a `flatc`
|
||||||
executable, essential for the next steps.
|
executable, essential for the next steps.
|
||||||
@@ -46,7 +41,7 @@ running the `android_sample.sh` script. Optionally, you may go to the
|
|||||||
`flatbuffers/samples/android` folder and build the sample with the
|
`flatbuffers/samples/android` folder and build the sample with the
|
||||||
`build_apk.sh` script or `ndk_build` / `adb` etc.
|
`build_apk.sh` script or `ndk_build` / `adb` etc.
|
||||||
|
|
||||||
## Using FlatBuffers in your own projects.
|
## Using FlatBuffers in your own projects
|
||||||
|
|
||||||
For C++, there is usually no runtime to compile, as the code consists of a
|
For C++, there is usually no runtime to compile, as the code consists of a
|
||||||
single header, `include/flatbuffers/flatbuffers.h`. You should add the
|
single header, `include/flatbuffers/flatbuffers.h`. You should add the
|
||||||
@@ -60,6 +55,39 @@ To see how to include FlatBuffers in any of our supported languages, please
|
|||||||
view the [Tutorial](@ref flatbuffers_guide_tutorial) and select your appropriate
|
view the [Tutorial](@ref flatbuffers_guide_tutorial) and select your appropriate
|
||||||
language using the radio buttons.
|
language using the radio buttons.
|
||||||
|
|
||||||
|
### Using in CMake-based projects
|
||||||
|
If you want to use FlatBuffers in a project which already uses CMake, then a more
|
||||||
|
robust and flexible approach is to build FlatBuffers as part of that project directly.
|
||||||
|
This is done by making the FlatBuffers source code available to the main build
|
||||||
|
and adding it using CMake's `add_subdirectory()` command. This has the
|
||||||
|
significant advantage that the same compiler and linker settings are used
|
||||||
|
between FlatBuffers and the rest of your project, so issues associated with using
|
||||||
|
incompatible libraries (eg debug/release), etc. are avoided. This is
|
||||||
|
particularly useful on Windows.
|
||||||
|
|
||||||
|
Suppose you put FlatBuffers source code in directory `${FLATBUFFERS_SRC_DIR}`.
|
||||||
|
To build it as part of your project, add following code to your `CMakeLists.txt` file:
|
||||||
|
```cmake
|
||||||
|
# Add FlatBuffers directly to our build. This defines the `flatbuffers` target.
|
||||||
|
add_subdirectory(${FLATBUFFERS_SRC_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-build
|
||||||
|
EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
|
# Now simply link against flatbuffers as needed to your already declared target.
|
||||||
|
# The flatbuffers target carry header search path automatically if CMake > 2.8.11.
|
||||||
|
target_link_libraries(own_project_target PRIVATE flatbuffers)
|
||||||
|
```
|
||||||
|
When build your project the `flatbuffers` library will be compiled and linked
|
||||||
|
to a target as part of your project.
|
||||||
|
|
||||||
|
#### Override default depth limit of nested objects
|
||||||
|
To override [the depth limit of recursion](@ref flatbuffers_guide_use_cpp),
|
||||||
|
add this directive:
|
||||||
|
```cmake
|
||||||
|
set(FLATBUFFERS_MAX_PARSING_DEPTH 16)
|
||||||
|
```
|
||||||
|
to `CMakeLists.txt` file before `add_subdirectory(${FLATBUFFERS_SRC_DIR})` line.
|
||||||
|
|
||||||
#### For Google Play apps
|
#### For Google Play apps
|
||||||
|
|
||||||
For applications on Google Play that integrate this library, usage is tracked.
|
For applications on Google Play that integrate this library, usage is tracked.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
../../CONTRIBUTING
|
../../CONTRIBUTING.md
|
||||||
224
docs/source/CUsage.md
Normal file
224
docs/source/CUsage.md
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
Use in C {#flatbuffers_guide_use_c}
|
||||||
|
==========
|
||||||
|
|
||||||
|
The C language binding exists in a separate project named [FlatCC](https://github.com/dvidelabs/flatcc).
|
||||||
|
|
||||||
|
The `flatcc` C schema compiler can generate code offline as well as
|
||||||
|
online via a C library. It can also generate buffer verifiers and fast
|
||||||
|
JSON parsers, printers.
|
||||||
|
|
||||||
|
Great care has been taken to ensure compatibily with the main `flatc`
|
||||||
|
project.
|
||||||
|
|
||||||
|
## General Documention
|
||||||
|
|
||||||
|
- [Tutorial](@ref flatbuffers_guide_tutorial) - select C as language
|
||||||
|
when scrolling down
|
||||||
|
- [FlatCC Guide](https://github.com/dvidelabs/flatcc#flatcc-flatbuffers-in-c-for-c)
|
||||||
|
- [The C Builder Interface](https://github.com/dvidelabs/flatcc/blob/master/doc/builder.md#the-builder-interface)
|
||||||
|
- [The Monster Sample in C](https://github.com/dvidelabs/flatcc/blob/master/samples/monster/monster.c)
|
||||||
|
- [GitHub](https://github.com/dvidelabs/flatcc)
|
||||||
|
|
||||||
|
|
||||||
|
## Supported Platforms
|
||||||
|
|
||||||
|
- Ubuntu (clang / gcc, ninja / gnu make)
|
||||||
|
- OS-X (clang / gcc, ninja / gnu make)
|
||||||
|
- Windows MSVC 2010, 2013, 2015
|
||||||
|
|
||||||
|
CI builds recent versions of gcc, clang and MSVC on OS-X, Ubuntu, and
|
||||||
|
Windows, and occasionally older compiler versions. See main project [Status](https://github.com/dvidelabs/flatcc#status).
|
||||||
|
|
||||||
|
Other platforms may well work, including Centos, but are not tested
|
||||||
|
regularly.
|
||||||
|
|
||||||
|
The monster sample project was specifically written for C99 in order to
|
||||||
|
follow the C++ version and for that reason it will not work with MSVC
|
||||||
|
2010.
|
||||||
|
|
||||||
|
## Modular Object Creation
|
||||||
|
|
||||||
|
In the tutorial we used the call `Monster_create_as_root` to create the
|
||||||
|
root buffer object since this is easier in simple use cases. Sometimes
|
||||||
|
we need more modularity so we can reuse a function to create nested
|
||||||
|
tables and root tables the same way. For this we need the
|
||||||
|
`flatcc_builder_buffer_create_call`. It is best to keep `flatcc_builder`
|
||||||
|
calls isolated at the top driver level, so we get:
|
||||||
|
|
||||||
|
<div class="language-c">
|
||||||
|
~~~{.c}
|
||||||
|
ns(Monster_ref_t) create_orc(flatcc_builder_t *B)
|
||||||
|
{
|
||||||
|
// ... same as in the tutorial.
|
||||||
|
return s(Monster_create(B, ...));
|
||||||
|
}
|
||||||
|
|
||||||
|
void create_monster_buffer()
|
||||||
|
{
|
||||||
|
uint8_t *buf;
|
||||||
|
size_t size;
|
||||||
|
flatcc_builder_t builder, *B;
|
||||||
|
|
||||||
|
// Initialize the builder object.
|
||||||
|
B = &builder;
|
||||||
|
flatcc_builder_init(B);
|
||||||
|
// Only use `buffer_create` without `create/start/end_as_root`.
|
||||||
|
flatcc_builder_buffer_create(create_orc(B));
|
||||||
|
// Allocate and copy buffer to user memory.
|
||||||
|
buf = flatcc_builder_finalize_buffer(B, &size);
|
||||||
|
// ... write the buffer to disk or network, or something.
|
||||||
|
|
||||||
|
free(buf);
|
||||||
|
flatcc_builder_clear(B);
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
</div>
|
||||||
|
|
||||||
|
The same principle applies with `start/end` vs `start/end_as_root` in
|
||||||
|
the top-down approach.
|
||||||
|
|
||||||
|
|
||||||
|
## Top Down Example
|
||||||
|
|
||||||
|
The tutorial uses a bottom up approach. In C it is also possible to use
|
||||||
|
a top-down approach by starting and ending objects nested within each
|
||||||
|
other. In the tutorial there is no deep nesting, so the difference is
|
||||||
|
limited, but it shows the idea:
|
||||||
|
|
||||||
|
<div class="language-c">
|
||||||
|
<br>
|
||||||
|
~~~{.c}
|
||||||
|
uint8_t treasure[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||||
|
size_t treasure_count = c_vec_len(treasure);
|
||||||
|
ns(Weapon_ref_t) axe;
|
||||||
|
|
||||||
|
// NOTE: if we use end_as_root, we MUST also start as root.
|
||||||
|
ns(Monster_start_as_root(B));
|
||||||
|
ns(Monster_pos_create(B, 1.0f, 2.0f, 3.0f));
|
||||||
|
ns(Monster_hp_add(B, 300));
|
||||||
|
ns(Monster_mana_add(B, 150));
|
||||||
|
// We use create_str instead of add because we have no existing string reference.
|
||||||
|
ns(Monster_name_create_str(B, "Orc"));
|
||||||
|
// Again we use create because we no existing vector object, only a C-array.
|
||||||
|
ns(Monster_inventory_create(B, treasure, treasure_count));
|
||||||
|
ns(Monster_color_add(B, ns(Color_Red)));
|
||||||
|
if (1) {
|
||||||
|
ns(Monster_weapons_start(B));
|
||||||
|
ns(Monster_weapons_push_create(B, flatbuffers_string_create_str(B, "Sword"), 3));
|
||||||
|
// We reuse the axe object later. Note that we dereference a pointer
|
||||||
|
// because push always returns a short-term pointer to the stored element.
|
||||||
|
// We could also have created the axe object first and simply pushed it.
|
||||||
|
axe = *ns(Monster_weapons_push_create(B, flatbuffers_string_create_str(B, "Axe"), 5));
|
||||||
|
ns(Monster_weapons_end(B));
|
||||||
|
} else {
|
||||||
|
// We can have more control with the table elements added to a vector:
|
||||||
|
//
|
||||||
|
ns(Monster_weapons_start(B));
|
||||||
|
ns(Monster_weapons_push_start(B));
|
||||||
|
ns(Weapon_name_create_str(B, "Sword"));
|
||||||
|
ns(Weapon_damage_add(B, 3));
|
||||||
|
ns(Monster_weapons_push_end(B));
|
||||||
|
ns(Monster_weapons_push_start(B));
|
||||||
|
ns(Monster_weapons_push_start(B));
|
||||||
|
ns(Weapon_name_create_str(B, "Axe"));
|
||||||
|
ns(Weapon_damage_add(B, 5));
|
||||||
|
axe = *ns(Monster_weapons_push_end(B));
|
||||||
|
ns(Monster_weapons_end(B));
|
||||||
|
}
|
||||||
|
// Unions can get their type by using a type-specific add/create/start method.
|
||||||
|
ns(Monster_equipped_Weapon_add(B, axe));
|
||||||
|
|
||||||
|
ns(Monster_end_as_root(B));
|
||||||
|
~~~
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
## Basic Reflection
|
||||||
|
|
||||||
|
The C-API does support reading binary schema (.bfbs)
|
||||||
|
files via code generated from the `reflection.fbs` schema, and an
|
||||||
|
[example usage](https://github.com/dvidelabs/flatcc/tree/master/samples/reflection)
|
||||||
|
shows how to use this. The reflection schema files are pre-generated
|
||||||
|
in the [runtime distribution](https://github.com/dvidelabs/flatcc/tree/master/include/flatcc/reflection).
|
||||||
|
|
||||||
|
|
||||||
|
## Mutations and Reflection
|
||||||
|
|
||||||
|
The C-API does not support mutating reflection like C++ does, nor does
|
||||||
|
the reader interface support mutating scalars (and it is generally
|
||||||
|
unsafe to do so even after verification).
|
||||||
|
|
||||||
|
The generated reader interface supports sorting vectors in-place after
|
||||||
|
casting them to a mutating type because it is not practical to do so
|
||||||
|
while building a buffer. This is covered in the builder documentation.
|
||||||
|
The reflection example makes use of this feature to look up objects by
|
||||||
|
name.
|
||||||
|
|
||||||
|
It is possible to build new buffers using complex objects from existing
|
||||||
|
buffers as source. This can be very efficient due to direct copy
|
||||||
|
semantics without endian conversion or temporary stack allocation.
|
||||||
|
|
||||||
|
Scalars, structs and strings can be used as source, as well vectors of
|
||||||
|
these.
|
||||||
|
|
||||||
|
It is currently not possible to use an existing table or vector of table
|
||||||
|
as source, but it would be possible to add support for this at some
|
||||||
|
point.
|
||||||
|
|
||||||
|
|
||||||
|
## Namespaces
|
||||||
|
|
||||||
|
The `FLATBUFFERS_WRAP_NAMESPACE` approach used in the tutorial is convenient
|
||||||
|
when each function has a very long namespace prefix. But it isn't always
|
||||||
|
the best approach. If the namespace is absent, or simple and
|
||||||
|
informative, we might as well use the prefix directly. The
|
||||||
|
[reflection example](https://github.com/dvidelabs/flatcc/blob/master/samples/reflection/bfbs2json.c)
|
||||||
|
mentioned above uses this approach.
|
||||||
|
|
||||||
|
|
||||||
|
## Checking for Present Members
|
||||||
|
|
||||||
|
Not all languages support testing if a field is present, but in C we can
|
||||||
|
elaborate the reader section of the tutorial with tests for this. Recall
|
||||||
|
that `mana` was set to the default value `150` and therefore shouldn't
|
||||||
|
be present.
|
||||||
|
|
||||||
|
<div class="language-c">
|
||||||
|
~~~{.c}
|
||||||
|
int hp_present = ns(Monster_hp_is_present(monster)); // 1
|
||||||
|
int mana_present = ns(Monster_mana_is_present(monster)); // 0
|
||||||
|
~~~
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Alternative ways to add a Union
|
||||||
|
|
||||||
|
In the tutorial we used a single call to add a union. Here we show
|
||||||
|
different ways to accomplish the same thing. The last form is rarely
|
||||||
|
used, but is the low-level way to do it. It can be used to group small
|
||||||
|
values together in the table by adding type and data at different
|
||||||
|
points in time.
|
||||||
|
|
||||||
|
<div class="language-c">
|
||||||
|
~~~{.c}
|
||||||
|
ns(Equipment_union_ref_t) equipped = ns(Equipment_as_Weapon(axe));
|
||||||
|
ns(Monster_equipped_add(B, equipped));
|
||||||
|
// or alternatively
|
||||||
|
ns(Monster_equipped_Weapon_add(B, axe);
|
||||||
|
// or alternatively
|
||||||
|
ns(Monster_equipped_add_type(B, ns(Equipment_Weapon));
|
||||||
|
ns(Monster_equipped_add_member(B, axe));
|
||||||
|
~~~
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Why not integrate with the `flatc` tool?
|
||||||
|
|
||||||
|
[It was considered how the C code generator could be integrated into the
|
||||||
|
`flatc` tool](https://github.com/dvidelabs/flatcc/issues/1), but it
|
||||||
|
would either require that the standalone C implementation of the schema
|
||||||
|
compiler was dropped, or it would lead to excessive code duplication, or
|
||||||
|
a complicated intermediate representation would have to be invented.
|
||||||
|
Neither of these alternatives are very attractive, and it isn't a big
|
||||||
|
deal to use the `flatcc` tool instead of `flatc` given that the
|
||||||
|
FlatBuffers C runtime library needs to be made available regardless.
|
||||||
|
|
||||||
|
|
||||||
104
docs/source/Compiler.md
Executable file → Normal file
104
docs/source/Compiler.md
Executable file → Normal file
@@ -29,10 +29,22 @@ For any schema input files, one or more generators can be specified:
|
|||||||
|
|
||||||
- `--python`, `-p`: Generate Python code.
|
- `--python`, `-p`: Generate Python code.
|
||||||
|
|
||||||
- `--javascript`, `-s`: Generate JavaScript code.
|
- `--js`, `-s`: Generate JavaScript code.
|
||||||
|
|
||||||
|
- `--ts`: Generate TypeScript code.
|
||||||
|
|
||||||
- `--php`: Generate PHP code.
|
- `--php`: Generate PHP code.
|
||||||
|
|
||||||
|
- `--grpc`: Generate RPC stub code for GRPC.
|
||||||
|
|
||||||
|
- `--dart`: Generate Dart code.
|
||||||
|
|
||||||
|
- `--lua`: Generate Lua code.
|
||||||
|
|
||||||
|
- `--lobster`: Generate Lobster code.
|
||||||
|
|
||||||
|
- `--rust`, `-r` : Generate Rust code.
|
||||||
|
|
||||||
For any data input files:
|
For any data input files:
|
||||||
|
|
||||||
- `--binary`, `-b` : If data is contained in this file, generate a
|
- `--binary`, `-b` : If data is contained in this file, generate a
|
||||||
@@ -60,6 +72,12 @@ Additional options:
|
|||||||
in quotes, no trailing commas in tables/vectors). By default, no quotes are
|
in quotes, no trailing commas in tables/vectors). By default, no quotes are
|
||||||
required/generated, and trailing commas are allowed.
|
required/generated, and trailing commas are allowed.
|
||||||
|
|
||||||
|
- `--allow-non-utf8` : Pass non-UTF-8 input through parser and emit nonstandard
|
||||||
|
\x escapes in JSON. (Default is to raise parse error on non-UTF-8 input.)
|
||||||
|
|
||||||
|
- `--natural-utf8` : Output strings with UTF-8 as human-readable strings.
|
||||||
|
By default, UTF-8 characters are printed as \uXXXX escapes."
|
||||||
|
|
||||||
- `--defaults-json` : Output fields whose value is equal to the default value
|
- `--defaults-json` : Output fields whose value is equal to the default value
|
||||||
when writing JSON text.
|
when writing JSON text.
|
||||||
|
|
||||||
@@ -79,16 +97,61 @@ Additional options:
|
|||||||
- `--gen-mutable` : Generate additional non-const accessors for mutating
|
- `--gen-mutable` : Generate additional non-const accessors for mutating
|
||||||
FlatBuffers in-place.
|
FlatBuffers in-place.
|
||||||
|
|
||||||
- `--gen-onefile` : Generate single output file (useful for C#)
|
- `--gen-onefile` : Generate single output file for C# and Go.
|
||||||
|
|
||||||
- `--gen-all`: Generate not just code for the current schema files, but
|
- `--gen-name-strings` : Generate type name functions for C++.
|
||||||
|
|
||||||
|
- `--gen-object-api` : Generate an additional object-based API. This API is
|
||||||
|
more convenient for object construction and mutation than the base API,
|
||||||
|
at the cost of efficiency (object allocation). Recommended only to be used
|
||||||
|
if other options are insufficient.
|
||||||
|
|
||||||
|
- `--gen-compare` : Generate operator== for object-based API types.
|
||||||
|
|
||||||
|
- `--gen-nullable` : Add Clang _Nullable for C++ pointer. or @Nullable for Java.
|
||||||
|
|
||||||
|
- `--gen-generated` : Add @Generated annotation for Java.
|
||||||
|
|
||||||
|
- `--gen-all` : Generate not just code for the current schema files, but
|
||||||
for all files it includes as well. If the language uses a single file for
|
for all files it includes as well. If the language uses a single file for
|
||||||
output (by default the case for C++ and JS), all code will end up in
|
output (by default the case for C++ and JS), all code will end up in
|
||||||
this one file.
|
this one file.
|
||||||
|
|
||||||
|
- `--cpp-ptr-type T` : Set object API pointer type (default std::unique_ptr)
|
||||||
|
|
||||||
|
- `--cpp-str-type T` : Set object API string type (default std::string)
|
||||||
|
T::c_str(), T::length() and T::empty() must be supported.
|
||||||
|
The custom type also needs to be constructible from std::string (see the
|
||||||
|
--cpp-str-flex-ctor option to change this behavior).
|
||||||
|
|
||||||
|
- `--cpp-str-flex-ctor` : Don't construct custom string types by passing
|
||||||
|
std::string from Flatbuffers, but (char* + length). This allows efficient
|
||||||
|
construction of custom string types, including zero-copy construction.
|
||||||
|
|
||||||
|
- `--object-prefix` : Customise class prefix for C++ object-based API.
|
||||||
|
|
||||||
|
- `--object-suffix` : Customise class suffix for C++ object-based API.
|
||||||
|
|
||||||
|
- `--no-js-exports` : Removes Node.js style export lines (useful for JS)
|
||||||
|
|
||||||
|
- `--goog-js-export` : Uses goog.exportsSymbol and goog.exportsProperty
|
||||||
|
instead of Node.js style exporting. Needed for compatibility with the
|
||||||
|
Google closure compiler (useful for JS).
|
||||||
|
|
||||||
|
- `--es6-js-export` : Generates ECMAScript v6 style export definitions
|
||||||
|
instead of Node.js style exporting. Useful when integrating flatbuffers
|
||||||
|
with modern Javascript projects.
|
||||||
|
|
||||||
|
- `--go-namespace` : Generate the overrided namespace in Golang.
|
||||||
|
|
||||||
|
- `--go-import` : Generate the overrided import for flatbuffers in Golang.
|
||||||
|
(default is "github.com/google/flatbuffers/go").
|
||||||
|
|
||||||
- `--raw-binary` : Allow binaries without a file_indentifier to be read.
|
- `--raw-binary` : Allow binaries without a file_indentifier to be read.
|
||||||
This may crash flatc given a mismatched schema.
|
This may crash flatc given a mismatched schema.
|
||||||
|
|
||||||
|
- `--size-prefixed` : Input binaries are size prefixed buffers.
|
||||||
|
|
||||||
- `--proto`: Expect input files to be .proto files (protocol buffers).
|
- `--proto`: Expect input files to be .proto files (protocol buffers).
|
||||||
Output the corresponding .fbs file.
|
Output the corresponding .fbs file.
|
||||||
Currently supports: `package`, `message`, `enum`, nested declarations,
|
Currently supports: `package`, `message`, `enum`, nested declarations,
|
||||||
@@ -96,10 +159,45 @@ Additional options:
|
|||||||
Does not support, but will skip without error: `option`, `service`,
|
Does not support, but will skip without error: `option`, `service`,
|
||||||
`extensions`, and most everything else.
|
`extensions`, and most everything else.
|
||||||
|
|
||||||
|
- `--oneof-union` : Translate .proto oneofs to flatbuffer unions.
|
||||||
|
|
||||||
|
- `--grpc` : Generate GRPC interfaces for the specified languages.
|
||||||
|
|
||||||
- `--schema`: Serialize schemas instead of JSON (use with -b). This will
|
- `--schema`: Serialize schemas instead of JSON (use with -b). This will
|
||||||
output a binary version of the specified schema that itself corresponds
|
output a binary version of the specified schema that itself corresponds
|
||||||
to the reflection/reflection.fbs schema. Loading this binary file is the
|
to the reflection/reflection.fbs schema. Loading this binary file is the
|
||||||
basis for reflection functionality.
|
basis for reflection functionality.
|
||||||
|
|
||||||
|
- `--bfbs-comments`: Add doc comments to the binary schema files.
|
||||||
|
|
||||||
|
- `--conform FILE` : Specify a schema the following schemas should be
|
||||||
|
an evolution of. Gives errors if not. Useful to check if schema
|
||||||
|
modifications don't break schema evolution rules.
|
||||||
|
|
||||||
|
- `--conform-includes PATH` : Include path for the schema given with
|
||||||
|
`--conform PATH`.
|
||||||
|
|
||||||
|
- `--include-prefix PATH` : Prefix this path to any generated include
|
||||||
|
statements.
|
||||||
|
|
||||||
|
- `--keep-prefix` : Keep original prefix of schema include statement.
|
||||||
|
|
||||||
|
- `--no-fb-impor` : Don't include flatbuffers import statement for TypeScript.
|
||||||
|
|
||||||
|
- `--no-ts-reexpor` : Don't re-export imported dependencies for TypeScript.
|
||||||
|
|
||||||
|
- `--short-name` : Use short function names for JS and TypeScript.
|
||||||
|
|
||||||
|
- `--reflect-types` : Add minimal type reflection to code generation.
|
||||||
|
|
||||||
|
- `--reflect-names` : Add minimal type/name reflection.
|
||||||
|
|
||||||
|
- `--root-type T` : Select or override the default root_type.
|
||||||
|
|
||||||
|
- `--force-defaults` : Emit default values in binary output from JSON.
|
||||||
|
|
||||||
|
- `--force-empty` : When serializing from object API representation, force
|
||||||
|
strings and vectors to empty rather than null.
|
||||||
|
|
||||||
NOTE: short-form options for generators are deprecated, use the long form
|
NOTE: short-form options for generators are deprecated, use the long form
|
||||||
whenever possible.
|
whenever possible.
|
||||||
|
|||||||
301
docs/source/CppUsage.md
Executable file → Normal file
301
docs/source/CppUsage.md
Executable file → Normal file
@@ -26,8 +26,7 @@ your program by including the header. As noted, this header relies on
|
|||||||
|
|
||||||
The code for the FlatBuffers C++ library can be found at
|
The code for the FlatBuffers C++ library can be found at
|
||||||
`flatbuffers/include/flatbuffers`. You can browse the library code on the
|
`flatbuffers/include/flatbuffers`. You can browse the library code on the
|
||||||
[FlatBuffers GitHub page](https://github.com/google/flatbuffers/tree/master/
|
[FlatBuffers GitHub page](https://github.com/google/flatbuffers/tree/master/include/flatbuffers).
|
||||||
include/flatbuffers).
|
|
||||||
|
|
||||||
## Testing the FlatBuffers C++ library
|
## Testing the FlatBuffers C++ library
|
||||||
|
|
||||||
@@ -60,15 +59,18 @@ a `char *` array, which you pass to `GetMonster()`.
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||||
#include "flatbuffers/flatbuffers.h"
|
#include "flatbuffers/flatbuffers.h"
|
||||||
#include "monster_test_generate.h"
|
#include "monster_test_generate.h"
|
||||||
#include <cstdio> // For printing and file access.
|
#include <iostream> // C++ header file for printing
|
||||||
|
#include <fstream> // C++ header file for file access
|
||||||
|
|
||||||
FILE* file = fopen("monsterdata_test.mon", "rb");
|
|
||||||
fseek(file, 0L, SEEK_END);
|
std::ifstream infile;
|
||||||
int length = ftell(file);
|
infile.open("monsterdata_test.mon", std::ios::binary | std::ios::in);
|
||||||
fseek(file, 0L, SEEK_SET);
|
infile.seekg(0,std::ios::end);
|
||||||
|
int length = infile.tellg();
|
||||||
|
infile.seekg(0,std::ios::beg);
|
||||||
char *data = new char[length];
|
char *data = new char[length];
|
||||||
fread(data, sizeof(char), length, file);
|
infile.read(data, length);
|
||||||
fclose(file);
|
infile.close();
|
||||||
|
|
||||||
auto monster = GetMonster(data);
|
auto monster = GetMonster(data);
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@@ -79,13 +81,199 @@ If you look in your generated header, you'll see it has
|
|||||||
convenient accessors for all fields, e.g. `hp()`, `mana()`, etc:
|
convenient accessors for all fields, e.g. `hp()`, `mana()`, etc:
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||||
printf("%d\n", monster->hp()); // `80`
|
std::cout << "hp : " << monster->hp() << std::endl; // `80`
|
||||||
printf("%d\n", monster->mana()); // default value of `150`
|
std::cout << "mana : " << monster->mana() << std::endl; // default value of `150`
|
||||||
printf("%s\n", monster->name()->c_str()); // "MyMonster"
|
std::cout << "name : " << monster->name()->c_str() << std::endl; // "MyMonster"
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
*Note: That we never stored a `mana` value, so it will return the default.*
|
*Note: That we never stored a `mana` value, so it will return the default.*
|
||||||
|
|
||||||
|
The following attributes are supported:
|
||||||
|
|
||||||
|
- `shared` (on a field): For string fields, this enables the usage of string
|
||||||
|
pooling (i.e. `CreateSharedString`) as default serialization behavior.
|
||||||
|
|
||||||
|
Specifically, `CreateXxxDirect` functions and `Pack` functions for object
|
||||||
|
based API (see below) will use `CreateSharedString` to create strings.
|
||||||
|
|
||||||
|
## Object based API. {#flatbuffers_cpp_object_based_api}
|
||||||
|
|
||||||
|
FlatBuffers is all about memory efficiency, which is why its base API is written
|
||||||
|
around using as little as possible of it. This does make the API clumsier
|
||||||
|
(requiring pre-order construction of all data, and making mutation harder).
|
||||||
|
|
||||||
|
For times when efficiency is less important a more convenient object based API
|
||||||
|
can be used (through `--gen-object-api`) that is able to unpack & pack a
|
||||||
|
FlatBuffer into objects and standard STL containers, allowing for convenient
|
||||||
|
construction, access and mutation.
|
||||||
|
|
||||||
|
To use:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||||
|
// Autogenerated class from table Monster.
|
||||||
|
MonsterT monsterobj;
|
||||||
|
|
||||||
|
// Deserialize from buffer into object.
|
||||||
|
UnPackTo(&monsterobj, flatbuffer);
|
||||||
|
|
||||||
|
// Update object directly like a C++ class instance.
|
||||||
|
cout << monsterobj->name; // This is now a std::string!
|
||||||
|
monsterobj->name = "Bob"; // Change the name.
|
||||||
|
|
||||||
|
// Serialize into new flatbuffer.
|
||||||
|
FlatBufferBuilder fbb;
|
||||||
|
Pack(fbb, &monsterobj);
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
The following attributes are specific to the object-based API code generation:
|
||||||
|
|
||||||
|
- `native_inline` (on a field): Because FlatBuffer tables and structs are
|
||||||
|
optionally present in a given buffer, they are best represented as pointers
|
||||||
|
(specifically std::unique_ptrs) in the native class since they can be null.
|
||||||
|
This attribute changes the member declaration to use the type directly
|
||||||
|
rather than wrapped in a unique_ptr.
|
||||||
|
|
||||||
|
- `native_default`: "value" (on a field): For members that are declared
|
||||||
|
"native_inline", the value specified with this attribute will be included
|
||||||
|
verbatim in the class constructor initializer list for this member.
|
||||||
|
|
||||||
|
- `native_custom_alloc`:"custom_allocator" (on a table or struct): When using the
|
||||||
|
object-based API all generated NativeTables that are allocated when unpacking
|
||||||
|
your flatbuffer will use "custom allocator". The allocator is also used by
|
||||||
|
any std::vector that appears in a table defined with `native_custom_alloc`.
|
||||||
|
This can be used to provide allocation from a pool for example, for faster
|
||||||
|
unpacking when using the object-based API.
|
||||||
|
|
||||||
|
Minimal Example:
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
table mytable(native_custom_alloc:"custom_allocator") {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
with custom_allocator defined before flatbuffers.h is included, as:
|
||||||
|
|
||||||
|
template <typename T> struct custom_allocator : public std::allocator<T> {
|
||||||
|
|
||||||
|
typedef T *pointer;
|
||||||
|
|
||||||
|
template <class U>
|
||||||
|
struct rebind {
|
||||||
|
typedef custom_allocator<U> other;
|
||||||
|
};
|
||||||
|
|
||||||
|
pointer allocate(const std::size_t n) {
|
||||||
|
return std::allocator<T>::allocate(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void deallocate(T* ptr, std::size_t n) {
|
||||||
|
return std::allocator<T>::deallocate(ptr,n);
|
||||||
|
}
|
||||||
|
|
||||||
|
custom_allocator() throw() {}
|
||||||
|
template <class U>
|
||||||
|
custom_allocator(const custom_allocator<U>&) throw() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
- `native_type`' "type" (on a struct): In some cases, a more optimal C++ data
|
||||||
|
type exists for a given struct. For example, the following schema:
|
||||||
|
|
||||||
|
struct Vec2 {
|
||||||
|
x: float;
|
||||||
|
y: float;
|
||||||
|
}
|
||||||
|
|
||||||
|
generates the following Object-Based API class:
|
||||||
|
|
||||||
|
struct Vec2T : flatbuffers::NativeTable {
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
};
|
||||||
|
|
||||||
|
However, it can be useful to instead use a user-defined C++ type since it
|
||||||
|
can provide more functionality, eg.
|
||||||
|
|
||||||
|
struct vector2 {
|
||||||
|
float x = 0, y = 0;
|
||||||
|
vector2 operator+(vector2 rhs) const { ... }
|
||||||
|
vector2 operator-(vector2 rhs) const { ... }
|
||||||
|
float length() const { ... }
|
||||||
|
// etc.
|
||||||
|
};
|
||||||
|
|
||||||
|
The `native_type` attribute will replace the usage of the generated class
|
||||||
|
with the given type. So, continuing with the example, the generated
|
||||||
|
code would use |vector2| in place of |Vec2T| for all generated code.
|
||||||
|
|
||||||
|
However, becuase the native_type is unknown to flatbuffers, the user must
|
||||||
|
provide the following functions to aide in the serialization process:
|
||||||
|
|
||||||
|
namespace flatbuffers {
|
||||||
|
FlatbufferStruct Pack(const native_type& obj);
|
||||||
|
native_type UnPack(const FlatbufferStruct& obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
Finally, the following top-level attribute
|
||||||
|
|
||||||
|
- `native_include`: "path" (at file level): Because the `native_type` attribute
|
||||||
|
can be used to introduce types that are unknown to flatbuffers, it may be
|
||||||
|
necessary to include "external" header files in the generated code. This
|
||||||
|
attribute can be used to directly add an #include directive to the top of
|
||||||
|
the generated code that includes the specified path directly.
|
||||||
|
|
||||||
|
- `force_align`: this attribute may not be respected in the object API,
|
||||||
|
depending on the aligned of the allocator used with `new`.
|
||||||
|
|
||||||
|
# External references.
|
||||||
|
|
||||||
|
An additional feature of the object API is the ability to allow you to load
|
||||||
|
multiple independent FlatBuffers, and have them refer to eachothers objects
|
||||||
|
using hashes which are then represented as typed pointers in the object API.
|
||||||
|
|
||||||
|
To make this work have a field in the objects you want to referred to which is
|
||||||
|
using the string hashing feature (see `hash` attribute in the
|
||||||
|
[schema](@ref flatbuffers_guide_writing_schema) documentation). Then you have
|
||||||
|
a similar hash in the field referring to it, along with a `cpp_type`
|
||||||
|
attribute specifying the C++ type this will refer to (this can be any C++
|
||||||
|
type, and will get a `*` added).
|
||||||
|
|
||||||
|
Then, in JSON or however you create these buffers, make sure they use the
|
||||||
|
same string (or hash).
|
||||||
|
|
||||||
|
When you call `UnPack` (or `Create`), you'll need a function that maps from
|
||||||
|
hash to the object (see `resolver_function_t` for details).
|
||||||
|
|
||||||
|
# Using different pointer types.
|
||||||
|
|
||||||
|
By default the object tree is built out of `std::unique_ptr`, but you can
|
||||||
|
influence this either globally (using the `--cpp-ptr-type` argument to
|
||||||
|
`flatc`) or per field (using the `cpp_ptr_type` attribute) to by any smart
|
||||||
|
pointer type (`my_ptr<T>`), or by specifying `naked` as the type to get `T *`
|
||||||
|
pointers. Unlike the smart pointers, naked pointers do not manage memory for
|
||||||
|
you, so you'll have to manage their lifecycles manually. To reference the
|
||||||
|
pointer type specified by the `--cpp-ptr-type` argument to `flatc` from a
|
||||||
|
flatbuffer field set the `cpp_ptr_type` attribute to `default_ptr_type`.
|
||||||
|
|
||||||
|
# Using different string type.
|
||||||
|
|
||||||
|
By default the object tree is built out of `std::string`, but you can
|
||||||
|
influence this either globally (using the `--cpp-str-type` argument to
|
||||||
|
`flatc`) or per field using the `cpp_str_type` attribute.
|
||||||
|
|
||||||
|
The type must support T::c_str(), T::length() and T::empty() as member functions.
|
||||||
|
|
||||||
|
Further, the type must be constructible from std::string, as by default a
|
||||||
|
std::string instance is constructed and then used to initialize the custom
|
||||||
|
string type. This behavior impedes efficient and zero-copy construction of
|
||||||
|
custom string types; the `--cpp-str-flex-ctor` argument to `flatc` or the
|
||||||
|
per field attribute `cpp_str_flex_ctor` can be used to change this behavior,
|
||||||
|
so that the custom string type is constructed by passing the pointer and
|
||||||
|
length of the FlatBuffers String. The custom string class will require a
|
||||||
|
constructor in the following format: custom_str_class(const char *, size_t).
|
||||||
|
Please note that the character array is not guaranteed to be NULL terminated,
|
||||||
|
you should always use the provided size to determine end of string.
|
||||||
|
|
||||||
## Reflection (& Resizing)
|
## Reflection (& Resizing)
|
||||||
|
|
||||||
There is experimental support for reflection in FlatBuffers, allowing you to
|
There is experimental support for reflection in FlatBuffers, allowing you to
|
||||||
@@ -108,6 +296,30 @@ schema, as well as a lot of helper functions.
|
|||||||
And example of usage, for the time being, can be found in
|
And example of usage, for the time being, can be found in
|
||||||
`test.cpp/ReflectionTest()`.
|
`test.cpp/ReflectionTest()`.
|
||||||
|
|
||||||
|
## Mini Reflection
|
||||||
|
|
||||||
|
A more limited form of reflection is available for direct inclusion in
|
||||||
|
generated code, which doesn't any (binary) schema access at all. It was designed
|
||||||
|
to keep the overhead of reflection as low as possible (on the order of 2-6
|
||||||
|
bytes per field added to your executable), but doesn't contain all the
|
||||||
|
information the (binary) schema contains.
|
||||||
|
|
||||||
|
You add this information to your generated code by specifying `--reflect-types`
|
||||||
|
(or instead `--reflect-names` if you also want field / enum names).
|
||||||
|
|
||||||
|
You can now use this information, for example to print a FlatBuffer to text:
|
||||||
|
|
||||||
|
auto s = flatbuffers::FlatBufferToString(flatbuf, MonsterTypeTable());
|
||||||
|
|
||||||
|
`MonsterTypeTable()` is declared in the generated code for each type. The
|
||||||
|
string produced is very similar to the JSON produced by the `Parser` based
|
||||||
|
text generator.
|
||||||
|
|
||||||
|
You'll need `flatbuffers/minireflect.h` for this functionality. In there is also
|
||||||
|
a convenient visitor/iterator so you can write your own output / functionality
|
||||||
|
based on the mini reflection tables without having to know the FlatBuffers or
|
||||||
|
reflection encoding.
|
||||||
|
|
||||||
## Storing maps / dictionaries in a FlatBuffer
|
## Storing maps / dictionaries in a FlatBuffer
|
||||||
|
|
||||||
FlatBuffers doesn't support maps natively, but there is support to
|
FlatBuffers doesn't support maps natively, but there is support to
|
||||||
@@ -143,7 +355,7 @@ performs a swap operation on big endian machines), and also because
|
|||||||
the layout of things is generally not known to the user.
|
the layout of things is generally not known to the user.
|
||||||
|
|
||||||
For structs, layout is deterministic and guaranteed to be the same
|
For structs, layout is deterministic and guaranteed to be the same
|
||||||
accross platforms (scalars are aligned to their
|
across platforms (scalars are aligned to their
|
||||||
own size, and structs themselves to their largest member), and you
|
own size, and structs themselves to their largest member), and you
|
||||||
are allowed to access this memory directly by using `sizeof()` and
|
are allowed to access this memory directly by using `sizeof()` and
|
||||||
`memcpy` on the pointer to a struct, or even an array of structs.
|
`memcpy` on the pointer to a struct, or even an array of structs.
|
||||||
@@ -288,4 +500,67 @@ manually wrap it in synchronisation primites. There's no automatic way to
|
|||||||
accomplish this, by design, as we feel multithreaded construction
|
accomplish this, by design, as we feel multithreaded construction
|
||||||
of a single buffer will be rare, and synchronisation overhead would be costly.
|
of a single buffer will be rare, and synchronisation overhead would be costly.
|
||||||
|
|
||||||
|
## Advanced union features
|
||||||
|
|
||||||
|
The C++ implementation currently supports vectors of unions (i.e. you can
|
||||||
|
declare a field as `[T]` where `T` is a union type instead of a table type). It
|
||||||
|
also supports structs and strings in unions, besides tables.
|
||||||
|
|
||||||
|
For an example of these features, see `tests/union_vector`, and
|
||||||
|
`UnionVectorTest` in `test.cpp`.
|
||||||
|
|
||||||
|
Since these features haven't been ported to other languages yet, if you
|
||||||
|
choose to use them, you won't be able to use these buffers in other languages
|
||||||
|
(`flatc` will refuse to compile a schema that uses these features).
|
||||||
|
|
||||||
|
These features reduce the amount of "table wrapping" that was previously
|
||||||
|
needed to use unions.
|
||||||
|
|
||||||
|
To use scalars, simply wrap them in a struct.
|
||||||
|
|
||||||
|
## Depth limit of nested objects and stack-overflow control
|
||||||
|
The parser of Flatbuffers schema or json-files is kind of recursive parser.
|
||||||
|
To avoid stack-overflow problem the parser has a built-in limiter of
|
||||||
|
recursion depth. Number of nested declarations in a schema or number of
|
||||||
|
nested json-objects is limited. By default, this depth limit set to `64`.
|
||||||
|
It is possible to override this limit with `FLATBUFFERS_MAX_PARSING_DEPTH`
|
||||||
|
definition. This definition can be helpful for testing purposes or embedded
|
||||||
|
applications. For details see [build](@ref flatbuffers_guide_building) of
|
||||||
|
CMake-based projects.
|
||||||
|
|
||||||
|
## Dependence from C-locale {#flatbuffers_locale_cpp}
|
||||||
|
The Flatbuffers [grammar](@ref flatbuffers grammar) uses ASCII
|
||||||
|
character set for identifiers, alphanumeric literals, reserved words.
|
||||||
|
|
||||||
|
Internal implementation of the Flatbuffers depends from functions which
|
||||||
|
depend from C-locale: `strtod()` or `strtof()`, for example.
|
||||||
|
The library expects the dot `.` symbol as the separator of an integer
|
||||||
|
part from the fractional part of a float number.
|
||||||
|
Another separator symbols (`,` for example) will break the compatibility
|
||||||
|
and may lead to an error while parsing a Flatbuffers schema or a json file.
|
||||||
|
|
||||||
|
The Standard C locale is a global resource, there is only one locale for
|
||||||
|
the entire application. Some modern compilers and platforms have
|
||||||
|
locale-independent or locale-narrow functions `strtof_l`, `strtod_l`,
|
||||||
|
`strtoll_l`, `strtoull_l` to resolve this dependency.
|
||||||
|
These functions use specified locale rather than the global or per-thread
|
||||||
|
locale instead. They are part of POSIX-2008 but not part of the C/C++
|
||||||
|
standard library, therefore, may be missing on some platforms.
|
||||||
|
|
||||||
|
The Flatbuffers library try to detect these functions at configuration and
|
||||||
|
compile time:
|
||||||
|
- `_MSC_VER >= 1900`: check MSVC2012 or higher for MSVC buid
|
||||||
|
- `_XOPEN_SOURCE>=700`: check POSIX-2008 for GCC/Clang build
|
||||||
|
- `check_cxx_symbol_exists(strtof_l stdlib.h)`: CMake check of `strtod_f`
|
||||||
|
|
||||||
|
After detection, the definition `FLATBUFFERS_LOCALE_INDEPENDENT` will be
|
||||||
|
set to `0` or `1`.
|
||||||
|
|
||||||
|
It is possible to test the compatibility of the Flatbuffers library with
|
||||||
|
a specific locale using the environment variable `FLATBUFFERS_TEST_LOCALE`:
|
||||||
|
```sh
|
||||||
|
>FLATBUFFERS_TEST_LOCALE="" ./flattests
|
||||||
|
>FLATBUFFERS_TEST_LOCALE="ru_RU.CP1251" ./flattests
|
||||||
|
```
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
108
docs/source/DartUsage.md
Normal file
108
docs/source/DartUsage.md
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
Use in Dart {#flatbuffers_guide_use_dart}
|
||||||
|
===========
|
||||||
|
|
||||||
|
## Before you get started
|
||||||
|
|
||||||
|
Before diving into the FlatBuffers usage in Dart, it should be noted that
|
||||||
|
the [Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide
|
||||||
|
to general FlatBuffers usage in all of the supported languages (including Dart).
|
||||||
|
This page is designed to cover the nuances of FlatBuffers usage, specific to
|
||||||
|
Dart.
|
||||||
|
|
||||||
|
You should also have read the [Building](@ref flatbuffers_guide_building)
|
||||||
|
documentation to build `flatc` and should be familiar with
|
||||||
|
[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler) and
|
||||||
|
[Writing a schema](@ref flatbuffers_guide_writing_schema).
|
||||||
|
|
||||||
|
## FlatBuffers Dart library code location
|
||||||
|
|
||||||
|
The code for the FlatBuffers Dart library can be found at
|
||||||
|
`flatbuffers/dart`. You can browse the library code on the [FlatBuffers
|
||||||
|
GitHub page](https://github.com/google/flatbuffers/tree/master/dart).
|
||||||
|
|
||||||
|
## Testing the FlatBuffers Dart library
|
||||||
|
|
||||||
|
The code to test the Dart library can be found at `flatbuffers/tests`.
|
||||||
|
The test code itself is located in [dart_test.dart](https://github.com/google/
|
||||||
|
flatbuffers/blob/master/tests/dart_test.dart).
|
||||||
|
|
||||||
|
To run the tests, use the [DartTest.sh](https://github.com/google/flatbuffers/
|
||||||
|
blob/master/tests/DartTest.sh) shell script.
|
||||||
|
|
||||||
|
*Note: The shell script requires the [Dart SDK](https://www.dartlang.org/tools/sdk)
|
||||||
|
to be installed.*
|
||||||
|
|
||||||
|
## Using the FlatBuffers Dart library
|
||||||
|
|
||||||
|
*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth
|
||||||
|
example of how to use FlatBuffers in Dart.*
|
||||||
|
|
||||||
|
FlatBuffers supports reading and writing binary FlatBuffers in Dart.
|
||||||
|
|
||||||
|
To use FlatBuffers in your own code, first generate Dart classes from your
|
||||||
|
schema with the `--dart` option to `flatc`. Then you can include both FlatBuffers
|
||||||
|
and the generated code to read or write a FlatBuffer.
|
||||||
|
|
||||||
|
For example, here is how you would read a FlatBuffer binary file in Dart: First,
|
||||||
|
include the library and generated code. Then read a FlatBuffer binary file into
|
||||||
|
a `List<int>`, which you pass to the factory constructor for `Monster`:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.dart}
|
||||||
|
import 'dart:io' as io;
|
||||||
|
|
||||||
|
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||||
|
import './monster_my_game.sample_generated.dart' as myGame;
|
||||||
|
|
||||||
|
List<int> data = await new io.File('monster.dat').readAsBytes();
|
||||||
|
var monster = new myGame.Monster(data);
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Now you can access values like this:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.dart}
|
||||||
|
var hp = monster.hp;
|
||||||
|
var pos = monster.pos;
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
## Differences from the Dart SDK Front End flat_buffers
|
||||||
|
|
||||||
|
The work in this repository is signfiicantly based on the implementation used
|
||||||
|
internally by the Dart SDK in the front end/analyzer package. Several
|
||||||
|
significant changes have been made.
|
||||||
|
|
||||||
|
1. Support for packed boolean lists has been removed. This is not standard
|
||||||
|
in other implementations and is not compatible with them. Do note that,
|
||||||
|
like in the JavaScript implementation, __null values in boolean lists
|
||||||
|
will be treated as false__. It is also still entirely possible to pack data
|
||||||
|
in a single scalar field, but that would have to be done on the application
|
||||||
|
side.
|
||||||
|
2. The SDK implementation supports enums with regular Dart enums, which
|
||||||
|
works if enums are always indexed at 1; however, FlatBuffers does not
|
||||||
|
require that. This implementation uses specialized enum-like classes to
|
||||||
|
ensure proper mapping from FlatBuffers to Dart and other platforms.
|
||||||
|
3. The SDK implementation does not appear to support FlatBuffer structs or
|
||||||
|
vectors of structs - it treated everything as a built-in scalar or a table.
|
||||||
|
This implementation treats structs in a way that is compatible with other
|
||||||
|
non-Dart implementations, and properly handles vectors of structs. Many of
|
||||||
|
the methods prefixed with 'low' have been prepurposed to support this.
|
||||||
|
4. The SDK implementation treats int64 and uint64 as float64s. This
|
||||||
|
implementation does not. This may cause problems with JavaScript
|
||||||
|
compatibility - however, it should be possible to use the JavaScript
|
||||||
|
implementation, or to do a customized implementation that treats all 64 bit
|
||||||
|
numbers as floats. Supporting the Dart VM and Flutter was a more important
|
||||||
|
goal of this implementation. Support for 16 bit integers was also added.
|
||||||
|
5. The code generation in this offers an "ObjectBuilder", which generates code
|
||||||
|
very similar to the SDK classes that consume FlatBuffers, as well as Builder
|
||||||
|
classes, which produces code which more closely resembles the builders in
|
||||||
|
other languages. The ObjectBuilder classes are easier to use, at the cost of
|
||||||
|
additional references allocated.
|
||||||
|
|
||||||
|
## Text Parsing
|
||||||
|
|
||||||
|
There currently is no support for parsing text (Schema's and JSON) directly
|
||||||
|
from Dart, though you could use the C++ parser through Dart Native Extensions.
|
||||||
|
Please see the C++ documentation for more on text parsing (note that this is
|
||||||
|
not currently an option in Flutter - follow [this issue](https://github.com/flutter/flutter/issues/7053)
|
||||||
|
for the latest).
|
||||||
|
|
||||||
|
<br>
|
||||||
@@ -4,9 +4,9 @@ FlatBuffers {#flatbuffers_index}
|
|||||||
# Overview {#flatbuffers_overview}
|
# Overview {#flatbuffers_overview}
|
||||||
|
|
||||||
[FlatBuffers](@ref flatbuffers_overview) is an efficient cross platform
|
[FlatBuffers](@ref flatbuffers_overview) is an efficient cross platform
|
||||||
serialization library for C++, C#, Go, Java, JavaScript, PHP, and Python
|
serialization library for C++, C#, C, Go, Java, JavaScript, Lobster, Lua, TypeScript, PHP, Python, and Rust.
|
||||||
(C and Ruby in progress). It was originally created at Google for game
|
It was originally created at Google for game development and other
|
||||||
development and other performance-critical applications.
|
performance-critical applications.
|
||||||
|
|
||||||
It is available as Open Source on [GitHub](http://github.com/google/flatbuffers)
|
It is available as Open Source on [GitHub](http://github.com/google/flatbuffers)
|
||||||
under the Apache license, v2 (see LICENSE.txt).
|
under the Apache license, v2 (see LICENSE.txt).
|
||||||
@@ -78,6 +78,9 @@ inefficiency, but also forces you to write *more* code to access data
|
|||||||
In this context, it is only a better choice for systems that have very
|
In this context, it is only a better choice for systems that have very
|
||||||
little to no information ahead of time about what data needs to be stored.
|
little to no information ahead of time about what data needs to be stored.
|
||||||
|
|
||||||
|
If you do need to store data that doesn't fit a schema, FlatBuffers also
|
||||||
|
offers a schema-less (self-describing) version!
|
||||||
|
|
||||||
Read more about the "why" of FlatBuffers in the
|
Read more about the "why" of FlatBuffers in the
|
||||||
[white paper](@ref flatbuffers_white_paper).
|
[white paper](@ref flatbuffers_white_paper).
|
||||||
|
|
||||||
@@ -131,11 +134,25 @@ sections provide a more in-depth usage guide.
|
|||||||
in your own programs.
|
in your own programs.
|
||||||
- How to [use the generated Go code](@ref flatbuffers_guide_use_go) in your
|
- How to [use the generated Go code](@ref flatbuffers_guide_use_go) in your
|
||||||
own programs.
|
own programs.
|
||||||
|
- How to [use the generated Lua code](@ref flatbuffers_guide_use_lua) in your
|
||||||
|
own programs.
|
||||||
|
- How to [use the generated JavaScript code](@ref flatbuffers_guide_use_javascript) in your
|
||||||
|
own programs.
|
||||||
|
- How to [use the generated TypeScript code](@ref flatbuffers_guide_use_typescript) in your
|
||||||
|
own programs.
|
||||||
|
- How to [use FlatBuffers in C with `flatcc`](@ref flatbuffers_guide_use_c) in your
|
||||||
|
own programs.
|
||||||
|
- How to [use the generated Lobster code](@ref flatbuffers_guide_use_lobster) in your
|
||||||
|
own programs.
|
||||||
|
- How to [use the generated Rust code](@ref flatbuffers_guide_use_rust) in your
|
||||||
|
own programs.
|
||||||
- [Support matrix](@ref flatbuffers_support) for platforms/languages/features.
|
- [Support matrix](@ref flatbuffers_support) for platforms/languages/features.
|
||||||
- Some [benchmarks](@ref flatbuffers_benchmarks) showing the advantage of
|
- Some [benchmarks](@ref flatbuffers_benchmarks) showing the advantage of
|
||||||
using FlatBuffers.
|
using FlatBuffers.
|
||||||
- A [white paper](@ref flatbuffers_white_paper) explaining the "why" of
|
- A [white paper](@ref flatbuffers_white_paper) explaining the "why" of
|
||||||
FlatBuffers.
|
FlatBuffers.
|
||||||
|
- How to use the [schema-less](@ref flexbuffers) version of
|
||||||
|
FlatBuffers.
|
||||||
- A description of the [internals](@ref flatbuffers_internals) of FlatBuffers.
|
- A description of the [internals](@ref flatbuffers_internals) of FlatBuffers.
|
||||||
- A formal [grammar](@ref flatbuffers_grammar) of the schema language.
|
- A formal [grammar](@ref flatbuffers_grammar) of the schema language.
|
||||||
|
|
||||||
@@ -143,7 +160,7 @@ sections provide a more in-depth usage guide.
|
|||||||
|
|
||||||
- [GitHub repository](http://github.com/google/flatbuffers)
|
- [GitHub repository](http://github.com/google/flatbuffers)
|
||||||
- [Landing page](http://google.github.io/flatbuffers)
|
- [Landing page](http://google.github.io/flatbuffers)
|
||||||
- [FlatBuffers Google Group](http://group.google.com/group/flatbuffers)
|
- [FlatBuffers Google Group](https://groups.google.com/forum/#!forum/flatbuffers)
|
||||||
- [FlatBuffers Issues Tracker](http://github.com/google/flatbuffers/issues)
|
- [FlatBuffers Issues Tracker](http://github.com/google/flatbuffers/issues)
|
||||||
- Independent implementations & tools:
|
- Independent implementations & tools:
|
||||||
- [FlatCC](https://github.com/dvidelabs/flatcc) Alternative FlatBuffers
|
- [FlatCC](https://github.com/dvidelabs/flatcc) Alternative FlatBuffers
|
||||||
|
|||||||
166
docs/source/FlexBuffers.md
Normal file
166
docs/source/FlexBuffers.md
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
FlexBuffers {#flexbuffers}
|
||||||
|
==========
|
||||||
|
|
||||||
|
FlatBuffers was designed around schemas, because when you want maximum
|
||||||
|
performance and data consistency, strong typing is helpful.
|
||||||
|
|
||||||
|
There are however times when you want to store data that doesn't fit a
|
||||||
|
schema, because you can't know ahead of time what all needs to be stored.
|
||||||
|
|
||||||
|
For this, FlatBuffers has a dedicated format, called FlexBuffers.
|
||||||
|
This is a binary format that can be used in conjunction
|
||||||
|
with FlatBuffers (by storing a part of a buffer in FlexBuffers
|
||||||
|
format), or also as its own independent serialization format.
|
||||||
|
|
||||||
|
While it loses the strong typing, you retain the most unique advantage
|
||||||
|
FlatBuffers has over other serialization formats (schema-based or not):
|
||||||
|
FlexBuffers can also be accessed without parsing / copying / object allocation.
|
||||||
|
This is a huge win in efficiency / memory friendly-ness, and allows unique
|
||||||
|
use cases such as mmap-ing large amounts of free-form data.
|
||||||
|
|
||||||
|
FlexBuffers' design and implementation allows for a very compact encoding,
|
||||||
|
combining automatic pooling of strings with automatic sizing of containers to
|
||||||
|
their smallest possible representation (8/16/32/64 bits). Many values and
|
||||||
|
offsets can be encoded in just 8 bits. While a schema-less representation is
|
||||||
|
usually more bulky because of the need to be self-descriptive, FlexBuffers
|
||||||
|
generates smaller binaries for many cases than regular FlatBuffers.
|
||||||
|
|
||||||
|
FlexBuffers is still slower than regular FlatBuffers though, so we recommend to
|
||||||
|
only use it if you need it.
|
||||||
|
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
This is for C++, other languages may follow.
|
||||||
|
|
||||||
|
Include the header `flexbuffers.h`, which in turn depends on `flatbuffers.h`
|
||||||
|
and `util.h`.
|
||||||
|
|
||||||
|
To create a buffer:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||||
|
flexbuffers::Builder fbb;
|
||||||
|
fbb.Int(13);
|
||||||
|
fbb.Finish();
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
You create any value, followed by `Finish`. Unlike FlatBuffers which requires
|
||||||
|
the root value to be a table, here any value can be the root, including a lonely
|
||||||
|
int value.
|
||||||
|
|
||||||
|
You can now access the `std::vector<uint8_t>` that contains the encoded value
|
||||||
|
as `fbb.GetBuffer()`. Write it, send it, or store it in a parent FlatBuffer. In
|
||||||
|
this case, the buffer is just 3 bytes in size.
|
||||||
|
|
||||||
|
To read this value back, you could just say:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||||
|
auto root = flexbuffers::GetRoot(my_buffer);
|
||||||
|
int64_t i = root.AsInt64();
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
FlexBuffers stores ints only as big as needed, so it doesn't differentiate
|
||||||
|
between different sizes of ints. You can ask for the 64 bit version,
|
||||||
|
regardless of what you put in. In fact, since you demand to read the root
|
||||||
|
as an int, if you supply a buffer that actually contains a float, or a
|
||||||
|
string with numbers in it, it will convert it for you on the fly as well,
|
||||||
|
or return 0 if it can't. If instead you actually want to know what is inside
|
||||||
|
the buffer before you access it, you can call `root.GetType()` or `root.IsInt()`
|
||||||
|
etc.
|
||||||
|
|
||||||
|
Here's a slightly more complex value you could write instead of `fbb.Int` above:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||||
|
fbb.Map([&]() {
|
||||||
|
fbb.Vector("vec", [&]() {
|
||||||
|
fbb.Int(-100);
|
||||||
|
fbb.String("Fred");
|
||||||
|
fbb.IndirectFloat(4.0f);
|
||||||
|
});
|
||||||
|
fbb.UInt("foo", 100);
|
||||||
|
});
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
This stores the equivalent of the JSON value
|
||||||
|
`{ vec: [ -100, "Fred", 4.0 ], foo: 100 }`. The root is a dictionary that has
|
||||||
|
just two key-value pairs, with keys `vec` and `foo`. Unlike FlatBuffers, it
|
||||||
|
actually has to store these keys in the buffer (which it does only once if
|
||||||
|
you store multiple such objects, by pooling key values), but also unlike
|
||||||
|
FlatBuffers it has no restriction on the keys (fields) that you use.
|
||||||
|
|
||||||
|
The map constructor uses a C++11 Lambda to group its children, but you can
|
||||||
|
also use more conventional start/end calls if you prefer.
|
||||||
|
|
||||||
|
The first value in the map is a vector. You'll notice that unlike FlatBuffers,
|
||||||
|
you can use mixed types. There is also a `TypedVector` variant that only
|
||||||
|
allows a single type, and uses a bit less memory.
|
||||||
|
|
||||||
|
`IndirectFloat` is an interesting feature that allows you to store values
|
||||||
|
by offset rather than inline. Though that doesn't make any visible change
|
||||||
|
to the user, the consequence is that large values (especially doubles or
|
||||||
|
64 bit ints) that occur more than once can be shared. Another use case is
|
||||||
|
inside of vectors, where the largest element makes up the size of all elements
|
||||||
|
(e.g. a single double forces all elements to 64bit), so storing a lot of small
|
||||||
|
integers together with a double is more efficient if the double is indirect.
|
||||||
|
|
||||||
|
Accessing it:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||||
|
auto map = flexbuffers::GetRoot(my_buffer).AsMap();
|
||||||
|
map.size(); // 2
|
||||||
|
auto vec = map["vec"].AsVector();
|
||||||
|
vec.size(); // 3
|
||||||
|
vec[0].AsInt64(); // -100;
|
||||||
|
vec[1].AsString().c_str(); // "Fred";
|
||||||
|
vec[1].AsInt64(); // 0 (Number parsing failed).
|
||||||
|
vec[2].AsDouble(); // 4.0
|
||||||
|
vec[2].AsString().IsTheEmptyString(); // true (Wrong Type).
|
||||||
|
vec[2].AsString().c_str(); // "" (This still works though).
|
||||||
|
vec[2].ToString().c_str(); // "4" (Or have it converted).
|
||||||
|
map["foo"].AsUInt8(); // 100
|
||||||
|
map["unknown"].IsNull(); // true
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
# Binary encoding
|
||||||
|
|
||||||
|
A description of how FlexBuffers are encoded is in the
|
||||||
|
[internals](@ref flatbuffers_internals) document.
|
||||||
|
|
||||||
|
|
||||||
|
# Nesting inside a FlatBuffer
|
||||||
|
|
||||||
|
You can mark a field as containing a FlexBuffer, e.g.
|
||||||
|
|
||||||
|
a:[ubyte] (flexbuffer);
|
||||||
|
|
||||||
|
A special accessor will be generated that allows you to access the root value
|
||||||
|
directly, e.g. `a_flexbuffer_root().AsInt64()`.
|
||||||
|
|
||||||
|
|
||||||
|
# Efficiency tips
|
||||||
|
|
||||||
|
* Vectors generally are a lot more efficient than maps, so prefer them over maps
|
||||||
|
when possible for small objects. Instead of a map with keys `x`, `y` and `z`,
|
||||||
|
use a vector. Better yet, use a typed vector. Or even better, use a fixed
|
||||||
|
size typed vector.
|
||||||
|
* Maps are backwards compatible with vectors, and can be iterated as such.
|
||||||
|
You can iterate either just the values (`map.Values()`), or in parallel with
|
||||||
|
the keys vector (`map.Keys()`). If you intend
|
||||||
|
to access most or all elements, this is faster than looking up each element
|
||||||
|
by key, since that involves a binary search of the key vector.
|
||||||
|
* When possible, don't mix values that require a big bit width (such as double)
|
||||||
|
in a large vector of smaller values, since all elements will take on this
|
||||||
|
width. Use `IndirectDouble` when this is a possibility. Note that
|
||||||
|
integers automatically use the smallest width possible, i.e. if you ask
|
||||||
|
to serialize an int64_t whose value is actually small, you will use less
|
||||||
|
bits. Doubles are represented as floats whenever possible losslessly, but
|
||||||
|
this is only possible for few values.
|
||||||
|
Since nested vectors/maps are stored over offsets, they typically don't
|
||||||
|
affect the vector width.
|
||||||
|
* To store large arrays of byte data, use a blob. If you'd use a typed
|
||||||
|
vector, the bit width of the size field may make it use more space than
|
||||||
|
expected, and may not be compatible with `memcpy`.
|
||||||
|
Similarly, large arrays of (u)int16_t may be better off stored as a
|
||||||
|
binary blob if their size could exceed 64k elements.
|
||||||
|
Construction and use are otherwise similar to strings.
|
||||||
@@ -67,6 +67,29 @@ Now you can access values like this:
|
|||||||
pos := monster.Pos(nil)
|
pos := monster.Pos(nil)
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
In some cases it's necessary to modify values in an existing FlatBuffer in place (without creating a copy). For this reason, scalar fields of a Flatbuffer table or struct can be mutated.
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.go}
|
||||||
|
monster := example.GetRootAsMonster(buf, 0)
|
||||||
|
|
||||||
|
// Set table field.
|
||||||
|
if ok := monster.MutateHp(10); !ok {
|
||||||
|
panic("failed to mutate Hp")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set struct field.
|
||||||
|
monster.Pos().MutateZ(4)
|
||||||
|
|
||||||
|
// This mutation will fail because the mana field is not available in
|
||||||
|
// the buffer. It should be set when creating the buffer.
|
||||||
|
if ok := monster.MutateMana(20); !ok {
|
||||||
|
panic("failed to mutate Hp")
|
||||||
|
}
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
The term `mutate` is used instead of `set` to indicate that this is a special use case. All mutate functions return a boolean value which is false if the field we're trying to mutate is not available in the buffer.
|
||||||
|
|
||||||
## Text Parsing
|
## Text Parsing
|
||||||
|
|
||||||
There currently is no support for parsing text (Schema's and JSON) directly
|
There currently is no support for parsing text (Schema's and JSON) directly
|
||||||
|
|||||||
42
docs/source/Grammar.md
Executable file → Normal file
42
docs/source/Grammar.md
Executable file → Normal file
@@ -4,26 +4,32 @@ Grammar of the schema language {#flatbuffers_grammar}
|
|||||||
schema = include*
|
schema = include*
|
||||||
( namespace\_decl | type\_decl | enum\_decl | root\_decl |
|
( namespace\_decl | type\_decl | enum\_decl | root\_decl |
|
||||||
file_extension_decl | file_identifier_decl |
|
file_extension_decl | file_identifier_decl |
|
||||||
attribute\_decl | object )*
|
attribute\_decl | rpc\_decl | object )*
|
||||||
|
|
||||||
include = `include` string\_constant `;`
|
include = `include` string\_constant `;`
|
||||||
|
|
||||||
namespace\_decl = `namespace` ident ( `.` ident )* `;`
|
namespace\_decl = `namespace` ident ( `.` ident )* `;`
|
||||||
|
|
||||||
attribute\_decl = `attribute` string\_constant `;`
|
attribute\_decl = `attribute` ident | `"`ident`"` `;`
|
||||||
|
|
||||||
type\_decl = ( `table` | `struct` ) ident metadata `{` field\_decl+ `}`
|
type\_decl = ( `table` | `struct` ) ident metadata `{` field\_decl+ `}`
|
||||||
|
|
||||||
enum\_decl = ( `enum` | `union` ) ident [ `:` type ] metadata `{` commasep(
|
enum\_decl = ( `enum` ident `:` type | `union` ident ) metadata `{`
|
||||||
enumval\_decl ) `}`
|
commasep( enumval\_decl ) `}`
|
||||||
|
|
||||||
root\_decl = `root_type` ident `;`
|
root\_decl = `root_type` ident `;`
|
||||||
|
|
||||||
field\_decl = ident `:` type [ `=` scalar ] metadata `;`
|
field\_decl = ident `:` type [ `=` scalar ] metadata `;`
|
||||||
|
|
||||||
|
rpc\_decl = `rpc_service` ident `{` rpc\_method+ `}`
|
||||||
|
|
||||||
|
rpc\_method = ident `(` ident `)` `:` ident metadata `;`
|
||||||
|
|
||||||
type = `bool` | `byte` | `ubyte` | `short` | `ushort` | `int` | `uint` |
|
type = `bool` | `byte` | `ubyte` | `short` | `ushort` | `int` | `uint` |
|
||||||
`float` | `long` | `ulong` | `double`
|
`float` | `long` | `ulong` | `double` |
|
||||||
| `string` | `[` type `]` | ident
|
`int8` | `uint8` | `int16` | `uint16` | `int32` | `uint32`| `int64` | `uint64` |
|
||||||
|
`float32` | `float64` |
|
||||||
|
`string` | `[` type `]` | ident
|
||||||
|
|
||||||
enumval\_decl = ident [ `=` integer\_constant ]
|
enumval\_decl = ident [ `=` integer\_constant ]
|
||||||
|
|
||||||
@@ -43,6 +49,26 @@ file_extension_decl = `file_extension` string\_constant `;`
|
|||||||
|
|
||||||
file_identifier_decl = `file_identifier` string\_constant `;`
|
file_identifier_decl = `file_identifier` string\_constant `;`
|
||||||
|
|
||||||
integer\_constant = -?[0-9]+ | `true` | `false`
|
string\_constant = `\".*?\"`
|
||||||
|
|
||||||
float\_constant = -?[0-9]+.[0-9]+((e|E)(+|-)?[0-9]+)?
|
ident = `[a-zA-Z_][a-zA-Z0-9_]*`
|
||||||
|
|
||||||
|
`[:digit:]` = `[0-9]`
|
||||||
|
|
||||||
|
`[:xdigit:]` = `[0-9a-fA-F]`
|
||||||
|
|
||||||
|
dec\_integer\_constant = `[-+]?[:digit:]+`
|
||||||
|
|
||||||
|
hex\_integer\_constant = `[-+]?0[xX][:xdigit:]+`
|
||||||
|
|
||||||
|
integer\_constant = dec\_integer\_constant | hex\_integer\_constant
|
||||||
|
|
||||||
|
dec\_float\_constant = `[-+]?(([.][:digit:]+)|([:digit:]+[.][:digit:]*)|([:digit:]+))([eE][-+]?[:digit:]+)?`
|
||||||
|
|
||||||
|
hex\_float\_constant = `[-+]?0[xX](([.][:xdigit:]+)|([:xdigit:]+[.][:xdigit:]*)|([:xdigit:]+))([pP][-+]?[:digit:]+)`
|
||||||
|
|
||||||
|
special\_float\_constant = `[-+]?(nan|inf|infinity)`
|
||||||
|
|
||||||
|
float\_constant = decimal\_float\_constant | hexadecimal\_float\_constant | special\_float\_constant
|
||||||
|
|
||||||
|
boolean\_constant = `(true|false)` | (integer\_constant ? `true` : `false`)
|
||||||
|
|||||||
158
docs/source/Internals.md
Executable file → Normal file
158
docs/source/Internals.md
Executable file → Normal file
@@ -169,7 +169,7 @@ Unions share a lot with enums.
|
|||||||
Predeclare all data types since circular references between types are allowed
|
Predeclare all data types since circular references between types are allowed
|
||||||
(circular references between object are not, though).
|
(circular references between object are not, though).
|
||||||
|
|
||||||
MANUALLY_ALIGNED_STRUCT(4) Vec3 {
|
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vec3 {
|
||||||
private:
|
private:
|
||||||
float x_;
|
float x_;
|
||||||
float y_;
|
float y_;
|
||||||
@@ -183,7 +183,7 @@ Predeclare all data types since circular references between types are allowed
|
|||||||
float y() const { return flatbuffers::EndianScalar(y_); }
|
float y() const { return flatbuffers::EndianScalar(y_); }
|
||||||
float z() const { return flatbuffers::EndianScalar(z_); }
|
float z() const { return flatbuffers::EndianScalar(z_); }
|
||||||
};
|
};
|
||||||
STRUCT_END(Vec3, 12);
|
FLATBUFFERS_STRUCT_END(Vec3, 12);
|
||||||
|
|
||||||
These ugly macros do a couple of things: they turn off any padding the compiler
|
These ugly macros do a couple of things: they turn off any padding the compiler
|
||||||
might normally do, since we add padding manually (though none in this example),
|
might normally do, since we add padding manually (though none in this example),
|
||||||
@@ -292,4 +292,158 @@ flexibility in which of the children of root object to write first (though in
|
|||||||
this case there's only one string), and what order to write the fields in.
|
this case there's only one string), and what order to write the fields in.
|
||||||
Different orders may also cause different alignments to happen.
|
Different orders may also cause different alignments to happen.
|
||||||
|
|
||||||
|
### Additional reading.
|
||||||
|
|
||||||
|
The author of the C language implementation has made a similar
|
||||||
|
[document](https://github.com/dvidelabs/flatcc/blob/master/doc/binary-format.md#flatbuffers-binary-format)
|
||||||
|
that may further help clarify the format.
|
||||||
|
|
||||||
|
# FlexBuffers
|
||||||
|
|
||||||
|
The [schema-less](@ref flexbuffers) version of FlatBuffers have their
|
||||||
|
own encoding, detailed here.
|
||||||
|
|
||||||
|
It shares many properties mentioned above, in that all data is accessed
|
||||||
|
over offsets, all scalars are aligned to their own size, and
|
||||||
|
all data is always stored in little endian format.
|
||||||
|
|
||||||
|
One difference is that FlexBuffers are built front to back, so children are
|
||||||
|
stored before parents, and the root of the data starts at the last byte.
|
||||||
|
|
||||||
|
Another difference is that scalar data is stored with a variable number of bits
|
||||||
|
(8/16/32/64). The current width is always determined by the *parent*, i.e. if
|
||||||
|
the scalar sits in a vector, the vector determines the bit width for all
|
||||||
|
elements at once. Selecting the minimum bit width for a particular vector is
|
||||||
|
something the encoder does automatically and thus is typically of no concern
|
||||||
|
to the user, though being aware of this feature (and not sticking a double in
|
||||||
|
the same vector as a bunch of byte sized elements) is helpful for efficiency.
|
||||||
|
|
||||||
|
Unlike FlatBuffers there is only one kind of offset, and that is an unsigned
|
||||||
|
integer indicating the number of bytes in a negative direction from the address
|
||||||
|
of itself (where the offset is stored).
|
||||||
|
|
||||||
|
### Vectors
|
||||||
|
|
||||||
|
The representation of the vector is at the core of how FlexBuffers works (since
|
||||||
|
maps are really just a combination of 2 vectors), so it is worth starting there.
|
||||||
|
|
||||||
|
As mentioned, a vector is governed by a single bit width (supplied by its
|
||||||
|
parent). This includes the size field. For example, a vector that stores the
|
||||||
|
integer values `1, 2, 3` is encoded as follows:
|
||||||
|
|
||||||
|
uint8_t 3, 1, 2, 3, 4, 4, 4
|
||||||
|
|
||||||
|
The first `3` is the size field, and is placed before the vector (an offset
|
||||||
|
from the parent to this vector points to the first element, not the size
|
||||||
|
field, so the size field is effectively at index -1).
|
||||||
|
Since this is an untyped vector `SL_VECTOR`, it is followed by 3 type
|
||||||
|
bytes (one per element of the vector), which are always following the vector,
|
||||||
|
and are always a uint8_t even if the vector is made up of bigger scalars.
|
||||||
|
|
||||||
|
### Types
|
||||||
|
|
||||||
|
A type byte is made up of 2 components (see flexbuffers.h for exact values):
|
||||||
|
|
||||||
|
* 2 lower bits representing the bit-width of the child (8, 16, 32, 64).
|
||||||
|
This is only used if the child is accessed over an offset, such as a child
|
||||||
|
vector. It is ignored for inline types.
|
||||||
|
* 6 bits representing the actual type (see flexbuffers.h).
|
||||||
|
|
||||||
|
Thus, in this example `4` means 8 bit child (value 0, unused, since the value is
|
||||||
|
in-line), type `SL_INT` (value 1).
|
||||||
|
|
||||||
|
### Typed Vectors
|
||||||
|
|
||||||
|
These are like the Vectors above, but omit the type bytes. The type is instead
|
||||||
|
determined by the vector type supplied by the parent. Typed vectors are only
|
||||||
|
available for a subset of types for which these savings can be significant,
|
||||||
|
namely inline signed/unsigned integers (`TYPE_VECTOR_INT` / `TYPE_VECTOR_UINT`),
|
||||||
|
floats (`TYPE_VECTOR_FLOAT`), and keys (`TYPE_VECTOR_KEY`, see below).
|
||||||
|
|
||||||
|
Additionally, for scalars, there are fixed length vectors of sizes 2 / 3 / 4
|
||||||
|
that don't store the size (`TYPE_VECTOR_INT2` etc.), for an additional savings
|
||||||
|
in space when storing common vector or color data.
|
||||||
|
|
||||||
|
### Scalars
|
||||||
|
|
||||||
|
FlexBuffers supports integers (`TYPE_INT` and `TYPE_UINT`) and floats
|
||||||
|
(`TYPE_FLOAT`), available in the bit-widths mentioned above. They can be stored
|
||||||
|
both inline and over an offset (`TYPE_INDIRECT_*`).
|
||||||
|
|
||||||
|
The offset version is useful to encode costly 64bit (or even 32bit) quantities
|
||||||
|
into vectors / maps of smaller sizes, and to share / repeat a value multiple
|
||||||
|
times.
|
||||||
|
|
||||||
|
### Booleans and Nulls
|
||||||
|
|
||||||
|
Booleans (`TYPE_BOOL`) and nulls (`TYPE_NULL`) are encoded as inlined unsigned integers.
|
||||||
|
|
||||||
|
### Blobs, Strings and Keys.
|
||||||
|
|
||||||
|
A blob (`TYPE_BLOB`) is encoded similar to a vector, with one difference: the
|
||||||
|
elements are always `uint8_t`. The parent bit width only determines the width of
|
||||||
|
the size field, allowing blobs to be large without the elements being large.
|
||||||
|
|
||||||
|
Strings (`TYPE_STRING`) are similar to blobs, except they have an additional 0
|
||||||
|
termination byte for convenience, and they MUST be UTF-8 encoded (since an
|
||||||
|
accessor in a language that does not support pointers to UTF-8 data may have to
|
||||||
|
convert them to a native string type).
|
||||||
|
|
||||||
|
A "Key" (`TYPE_KEY`) is similar to a string, but doesn't store the size
|
||||||
|
field. They're so named because they are used with maps, which don't care
|
||||||
|
for the size, and can thus be even more compact. Unlike strings, keys cannot
|
||||||
|
contain bytes of value 0 as part of their data (size can only be determined by
|
||||||
|
`strlen`), so while you can use them outside the context of maps if you so
|
||||||
|
desire, you're usually better off with strings.
|
||||||
|
|
||||||
|
### Maps
|
||||||
|
|
||||||
|
A map (`TYPE_MAP`) is like an (untyped) vector, but with 2 prefixes before the
|
||||||
|
size field:
|
||||||
|
|
||||||
|
| index | field |
|
||||||
|
| ----: | :----------------------------------------------------------- |
|
||||||
|
| -3 | An offset to the keys vector (may be shared between tables). |
|
||||||
|
| -2 | Byte width of the keys vector. |
|
||||||
|
| -1 | Size (from here on it is compatible with `TYPE_VECTOR`) |
|
||||||
|
| 0 | Elements. |
|
||||||
|
| Size | Types. |
|
||||||
|
|
||||||
|
Since a map is otherwise the same as a vector, it can be iterated like
|
||||||
|
a vector (which is probably faster than lookup by key).
|
||||||
|
|
||||||
|
The keys vector is a typed vector of keys. Both the keys and corresponding
|
||||||
|
values *have* to be stored in sorted order (as determined by `strcmp`), such
|
||||||
|
that lookups can be made using binary search.
|
||||||
|
|
||||||
|
The reason the key vector is a seperate structure from the value vector is
|
||||||
|
such that it can be shared between multiple value vectors, and also to
|
||||||
|
allow it to be treated as its own individual vector in code.
|
||||||
|
|
||||||
|
An example map { foo: 13, bar: 14 } would be encoded as:
|
||||||
|
|
||||||
|
0 : uint8_t 'b', 'a', 'r', 0
|
||||||
|
4 : uint8_t 'f', 'o', 'o', 0
|
||||||
|
8 : uint8_t 2 // key vector of size 2
|
||||||
|
// key vector offset points here
|
||||||
|
9 : uint8_t 9, 6 // offsets to bar_key and foo_key
|
||||||
|
11: uint8_t 2, 1 // offset to key vector, and its byte width
|
||||||
|
13: uint8_t 2 // value vector of size
|
||||||
|
// value vector offset points here
|
||||||
|
14: uint8_t 14, 13 // values
|
||||||
|
16: uint8_t 4, 4 // types
|
||||||
|
|
||||||
|
### The root
|
||||||
|
|
||||||
|
As mentioned, the root starts at the end of the buffer.
|
||||||
|
The last uint8_t is the width in bytes of the root (normally the parent
|
||||||
|
determines the width, but the root has no parent). The uint8_t before this is
|
||||||
|
the type of the root, and the bytes before that are the root value (of the
|
||||||
|
number of bytes specified by the last byte).
|
||||||
|
|
||||||
|
So for example, the integer value `13` as root would be:
|
||||||
|
|
||||||
|
uint8_t 13, 4, 1 // Value, type, root byte width.
|
||||||
|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
31
docs/source/JavaCsharpUsage.md
Executable file → Normal file
31
docs/source/JavaCsharpUsage.md
Executable file → Normal file
@@ -131,6 +131,37 @@ object are prefixed with `Get`, e.g.:
|
|||||||
monster.GetPos(preconstructedPos);
|
monster.GetPos(preconstructedPos);
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
## Storing dictionaries in a FlatBuffer
|
||||||
|
|
||||||
|
FlatBuffers doesn't support dictionaries natively, but there is support to
|
||||||
|
emulate their behavior with vectors and binary search, which means you
|
||||||
|
can have fast lookups directly from a FlatBuffer without having to unpack
|
||||||
|
your data into a `Dictionary` or similar.
|
||||||
|
|
||||||
|
To use it:
|
||||||
|
- Designate one of the fields in a table as the "key" field. You do this
|
||||||
|
by setting the `key` attribute on this field, e.g.
|
||||||
|
`name:string (key)`.
|
||||||
|
You may only have one key field, and it must be of string or scalar type.
|
||||||
|
- Write out tables of this type as usual, collect their offsets in an
|
||||||
|
array.
|
||||||
|
- Instead of calling standard generated method,
|
||||||
|
e.g.: `Monster.createTestarrayoftablesVector`,
|
||||||
|
call `CreateSortedVectorOfMonster` in C# or
|
||||||
|
`createSortedVectorOfTables` (from the `FlatBufferBuilder` object) in Java,
|
||||||
|
which will first sort all offsets such that the tables they refer to
|
||||||
|
are sorted by the key field, then serialize it.
|
||||||
|
- Now when you're accessing the FlatBuffer, you can use
|
||||||
|
the `ByKey` accessor to access elements of the vector, e.g.:
|
||||||
|
`monster.testarrayoftablesByKey("Frodo")` in Java or
|
||||||
|
`monster.TestarrayoftablesByKey("Frodo")` in C#,
|
||||||
|
which returns an object of the corresponding table type,
|
||||||
|
or `null` if not found.
|
||||||
|
`ByKey` performs a binary search, so should have a similar
|
||||||
|
speed to `Dictionary`, though may be faster because of better caching.
|
||||||
|
`ByKey` only works if the vector has been sorted, it will
|
||||||
|
likely not find elements if it hasn't been sorted.
|
||||||
|
|
||||||
## Text parsing
|
## Text parsing
|
||||||
|
|
||||||
There currently is no support for parsing text (Schema's and JSON) directly
|
There currently is no support for parsing text (Schema's and JSON) directly
|
||||||
|
|||||||
0
docs/source/JavaScriptUsage.md
Executable file → Normal file
0
docs/source/JavaScriptUsage.md
Executable file → Normal file
85
docs/source/LobsterUsage.md
Normal file
85
docs/source/LobsterUsage.md
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
Use in Lobster {#flatbuffers_guide_use_lobster}
|
||||||
|
==============
|
||||||
|
|
||||||
|
## Before you get started
|
||||||
|
|
||||||
|
Before diving into the FlatBuffers usage in Lobster, it should be noted that the
|
||||||
|
[Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide to general
|
||||||
|
FlatBuffers usage in all of the supported languages (including Lobster). This
|
||||||
|
page is designed to cover the nuances of FlatBuffers usage, specific to
|
||||||
|
Lobster.
|
||||||
|
|
||||||
|
You should also have read the [Building](@ref flatbuffers_guide_building)
|
||||||
|
documentation to build `flatc` and should be familiar with
|
||||||
|
[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler) and
|
||||||
|
[Writing a schema](@ref flatbuffers_guide_writing_schema).
|
||||||
|
|
||||||
|
## FlatBuffers Lobster library code location
|
||||||
|
|
||||||
|
The code for the FlatBuffers Lobster library can be found at
|
||||||
|
`flatbuffers/lobster`. You can browse the library code on the
|
||||||
|
[FlatBuffers GitHub page](https://github.com/google/flatbuffers/tree/master/
|
||||||
|
lobster).
|
||||||
|
|
||||||
|
## Testing the FlatBuffers Lobster library
|
||||||
|
|
||||||
|
The code to test the Lobster library can be found at `flatbuffers/tests`.
|
||||||
|
The test code itself is located in [lobstertest.lobster](https://github.com/google/
|
||||||
|
flatbuffers/blob/master/tests/lobstertest.lobster).
|
||||||
|
|
||||||
|
To run the tests, run `lobster lobstertest.lobster`. To obtain Lobster itself,
|
||||||
|
go to the [Lobster homepage](http://strlen.com/lobster) or
|
||||||
|
[github](https://github.com/aardappel/lobster) to learn how to build it for your
|
||||||
|
platform.
|
||||||
|
|
||||||
|
## Using the FlatBuffers Lobster library
|
||||||
|
|
||||||
|
*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth
|
||||||
|
example of how to use FlatBuffers in Lobster.*
|
||||||
|
|
||||||
|
There is support for both reading and writing FlatBuffers in Lobster.
|
||||||
|
|
||||||
|
To use FlatBuffers in your own code, first generate Lobster classes from your
|
||||||
|
schema with the `--lobster` option to `flatc`. Then you can include both
|
||||||
|
FlatBuffers and the generated code to read or write a FlatBuffer.
|
||||||
|
|
||||||
|
For example, here is how you would read a FlatBuffer binary file in Lobster:
|
||||||
|
First, import the library and the generated code. Then read a FlatBuffer binary
|
||||||
|
file into a string, which you pass to the `GetRootAsMonster` function:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.lobster}
|
||||||
|
include "monster_generated.lobster"
|
||||||
|
|
||||||
|
let fb = read_file("monsterdata_test.mon")
|
||||||
|
assert fb
|
||||||
|
let monster = MyGame_Example_GetRootAsMonster(fb)
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Now you can access values like this:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.lobster}
|
||||||
|
let hp = monster.hp
|
||||||
|
let pos = monster.pos
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
As you can see, even though `hp` and `pos` are functions that access FlatBuffer
|
||||||
|
data in-place in the string buffer, they appear as field accesses.
|
||||||
|
|
||||||
|
## Speed
|
||||||
|
|
||||||
|
Using FlatBuffers in Lobster should be relatively fast, as the implementation
|
||||||
|
makes use of native support for writing binary values, and access of vtables.
|
||||||
|
Both generated code and the runtime library are therefore small and fast.
|
||||||
|
|
||||||
|
Actual speed will depend on wether you use Lobster as bytecode VM or compiled to
|
||||||
|
C++.
|
||||||
|
|
||||||
|
## Text Parsing
|
||||||
|
|
||||||
|
Lobster has full support for parsing JSON into FlatBuffers, or generating
|
||||||
|
JSON from FlatBuffers. See `samples/sample_test.lobster` for an example.
|
||||||
|
|
||||||
|
This uses the C++ parser and generator underneath, so should be both fast and
|
||||||
|
conformant.
|
||||||
|
|
||||||
|
<br>
|
||||||
81
docs/source/LuaUsage.md
Normal file
81
docs/source/LuaUsage.md
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
Use in Lua {#flatbuffers_guide_use_lua}
|
||||||
|
=============
|
||||||
|
|
||||||
|
## Before you get started
|
||||||
|
|
||||||
|
Before diving into the FlatBuffers usage in Lua, it should be noted that the
|
||||||
|
[Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide to general
|
||||||
|
FlatBuffers usage in all of the supported languages (including Lua). This
|
||||||
|
page is designed to cover the nuances of FlatBuffers usage, specific to
|
||||||
|
Lua.
|
||||||
|
|
||||||
|
You should also have read the [Building](@ref flatbuffers_guide_building)
|
||||||
|
documentation to build `flatc` and should be familiar with
|
||||||
|
[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler) and
|
||||||
|
[Writing a schema](@ref flatbuffers_guide_writing_schema).
|
||||||
|
|
||||||
|
## FlatBuffers Lua library code location
|
||||||
|
|
||||||
|
The code for the FlatBuffers Lua library can be found at
|
||||||
|
`flatbuffers/lua`. You can browse the library code on the
|
||||||
|
[FlatBuffers GitHub page](https://github.com/google/flatbuffers/tree/master/lua).
|
||||||
|
|
||||||
|
## Testing the FlatBuffers Lua library
|
||||||
|
|
||||||
|
The code to test the Lua library can be found at `flatbuffers/tests`.
|
||||||
|
The test code itself is located in [luatest.lua](https://github.com/google/
|
||||||
|
flatbuffers/blob/master/tests/luatest.lua).
|
||||||
|
|
||||||
|
To run the tests, use the [LuaTest.sh](https://github.com/google/flatbuffers/
|
||||||
|
blob/master/tests/LuaTest.sh) shell script.
|
||||||
|
|
||||||
|
*Note: This script requires [Lua 5.3](https://www.lua.org/) to be
|
||||||
|
installed.*
|
||||||
|
|
||||||
|
## Using the FlatBuffers Lua library
|
||||||
|
|
||||||
|
*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth
|
||||||
|
example of how to use FlatBuffers in Lua.*
|
||||||
|
|
||||||
|
There is support for both reading and writing FlatBuffers in Lua.
|
||||||
|
|
||||||
|
To use FlatBuffers in your own code, first generate Lua classes from your
|
||||||
|
schema with the `--lua` option to `flatc`. Then you can include both
|
||||||
|
FlatBuffers and the generated code to read or write a FlatBuffer.
|
||||||
|
|
||||||
|
For example, here is how you would read a FlatBuffer binary file in Lua:
|
||||||
|
First, require the module and the generated code. Then read a FlatBuffer binary
|
||||||
|
file into a `string`, which you pass to the `GetRootAsMonster` function:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.lua}
|
||||||
|
-- require the library
|
||||||
|
local flatbuffers = require("flatbuffers")
|
||||||
|
|
||||||
|
-- require the generated code
|
||||||
|
local monster = require("MyGame.Sample.Monster")
|
||||||
|
|
||||||
|
-- read the flatbuffer from a file into a string
|
||||||
|
local f = io.open('monster.dat', 'rb')
|
||||||
|
local buf = f:read('*a')
|
||||||
|
f:close()
|
||||||
|
|
||||||
|
-- parse the flatbuffer to get an instance to the root monster
|
||||||
|
local monster1 = monster.GetRootAsMonster(buf, 0)
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Now you can access values like this:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.lua}
|
||||||
|
-- use the : notation to access member data
|
||||||
|
local hp = monster1:Hp()
|
||||||
|
local pos = monster1:Pos()
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
## Text Parsing
|
||||||
|
|
||||||
|
There currently is no support for parsing text (Schema's and JSON) directly
|
||||||
|
from Lua, though you could use the C++ parser through SWIG or ctypes. Please
|
||||||
|
see the C++ documentation for more on text parsing.
|
||||||
|
|
||||||
|
<br>
|
||||||
27
docs/source/PythonUsage.md
Executable file → Normal file
27
docs/source/PythonUsage.md
Executable file → Normal file
@@ -64,6 +64,33 @@ Now you can access values like this:
|
|||||||
pos = monster.Pos()
|
pos = monster.Pos()
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
## Support for Numpy arrays
|
||||||
|
|
||||||
|
The Flatbuffers python library also has support for accessing scalar
|
||||||
|
vectors as numpy arrays. This can be orders of magnitude faster than
|
||||||
|
iterating over the vector one element at a time, and is particularly
|
||||||
|
useful when unpacking large nested flatbuffers. The generated code for
|
||||||
|
a scalar vector will have a method `<vector name>AsNumpy()`. In the
|
||||||
|
case of the Monster example, you could access the inventory vector
|
||||||
|
like this:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.py}
|
||||||
|
inventory = monster.InventoryAsNumpy()
|
||||||
|
# inventory is a numpy array of type np.dtype('uint8')
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
instead of
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.py}
|
||||||
|
inventory = []
|
||||||
|
for i in range(monster.InventoryLength()):
|
||||||
|
inventory.append(int(monster.Inventory(i)))
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Numpy is not a requirement. If numpy is not installed on your system,
|
||||||
|
then attempting to access one of the `*asNumpy()` methods will result
|
||||||
|
in a `NumpyRequiredForThisFeature` exception.
|
||||||
|
|
||||||
## Text Parsing
|
## Text Parsing
|
||||||
|
|
||||||
There currently is no support for parsing text (Schema's and JSON) directly
|
There currently is no support for parsing text (Schema's and JSON) directly
|
||||||
|
|||||||
174
docs/source/RustUsage.md
Normal file
174
docs/source/RustUsage.md
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
Use in Rust {#flatbuffers_guide_use_rust}
|
||||||
|
==========
|
||||||
|
|
||||||
|
## Before you get started
|
||||||
|
|
||||||
|
Before diving into the FlatBuffers usage in Rust, it should be noted that
|
||||||
|
the [Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide
|
||||||
|
to general FlatBuffers usage in all of the supported languages (including Rust).
|
||||||
|
This page is designed to cover the nuances of FlatBuffers usage, specific to
|
||||||
|
Rust.
|
||||||
|
|
||||||
|
#### Prerequisites
|
||||||
|
|
||||||
|
This page assumes you have written a FlatBuffers schema and compiled it
|
||||||
|
with the Schema Compiler. If you have not, please see
|
||||||
|
[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler)
|
||||||
|
and [Writing a schema](@ref flatbuffers_guide_writing_schema).
|
||||||
|
|
||||||
|
Assuming you wrote a schema, say `mygame.fbs` (though the extension doesn't
|
||||||
|
matter), you've generated a Rust file called `mygame_generated.rs` using the
|
||||||
|
compiler (e.g. `flatc --rust mygame.fbs` or via helpers listed in "Useful
|
||||||
|
tools created by others" section bellow), you can now start using this in
|
||||||
|
your program by including the file. As noted, this header relies on the crate
|
||||||
|
`flatbuffers`, which should be in your include `Cargo.toml`.
|
||||||
|
|
||||||
|
## FlatBuffers Rust library code location
|
||||||
|
|
||||||
|
The code for the FlatBuffers Rust library can be found at
|
||||||
|
`flatbuffers/rust`. You can browse the library code on the
|
||||||
|
[FlatBuffers GitHub page](https://github.com/google/flatbuffers/tree/master/rust).
|
||||||
|
|
||||||
|
## Testing the FlatBuffers Rust library
|
||||||
|
|
||||||
|
The code to test the Rust library can be found at `flatbuffers/tests/rust_usage_test`.
|
||||||
|
The test code itself is located in
|
||||||
|
[integration_test.rs](https://github.com/google/flatbuffers/blob/master/tests/rust_usage_test/tests/integration_test.rs)
|
||||||
|
|
||||||
|
This test file requires `flatc` to be present. To review how to build the project,
|
||||||
|
please read the [Building](@ref flatbuffers_guide_building) documenation.
|
||||||
|
|
||||||
|
To run the tests, execute `RustTest.sh` from the `flatbuffers/tests` directory.
|
||||||
|
For example, on [Linux](https://en.wikipedia.org/wiki/Linux), you would simply
|
||||||
|
run: `cd tests && ./RustTest.sh`.
|
||||||
|
|
||||||
|
*Note: The shell script requires [Rust](https://www.rust-lang.org) to
|
||||||
|
be installed.*
|
||||||
|
|
||||||
|
## Using the FlatBuffers Rust library
|
||||||
|
|
||||||
|
*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth
|
||||||
|
example of how to use FlatBuffers in Rust.*
|
||||||
|
|
||||||
|
FlatBuffers supports both reading and writing FlatBuffers in Rust.
|
||||||
|
|
||||||
|
To use FlatBuffers in your code, first generate the Rust modules from your
|
||||||
|
schema with the `--rust` option to `flatc`. Then you can import both FlatBuffers
|
||||||
|
and the generated code to read or write FlatBuffers.
|
||||||
|
|
||||||
|
For example, here is how you would read a FlatBuffer binary file in Rust:
|
||||||
|
First, include the library and generated code. Then read the file into
|
||||||
|
a `u8` vector, which you pass, as a byte slice, to `get_root_as_monster()`.
|
||||||
|
|
||||||
|
This full example program is available in the Rust test suite:
|
||||||
|
[monster_example.rs](https://github.com/google/flatbuffers/blob/master/tests/rust_usage_test/bin/monster_example.rs)
|
||||||
|
|
||||||
|
It can be run by `cd`ing to the `rust_usage_test` directory and executing: `cargo run monster_example`.
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.rs}
|
||||||
|
extern crate flatbuffers;
|
||||||
|
|
||||||
|
#[allow(dead_code, unused_imports)]
|
||||||
|
#[path = "../../monster_test_generated.rs"]
|
||||||
|
mod monster_test_generated;
|
||||||
|
pub use monster_test_generated::my_game;
|
||||||
|
|
||||||
|
use std::io::Read;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut f = std::fs::File::open("../monsterdata_test.mon").unwrap();
|
||||||
|
let mut buf = Vec::new();
|
||||||
|
f.read_to_end(&mut buf).expect("file reading failed");
|
||||||
|
|
||||||
|
let monster = my_game::example::get_root_as_monster(&buf[..]);
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
`monster` is of type `Monster`, and points to somewhere *inside* your
|
||||||
|
buffer (root object pointers are not the same as `buffer_pointer` !).
|
||||||
|
If you look in your generated header, you'll see it has
|
||||||
|
convenient accessors for all fields, e.g. `hp()`, `mana()`, etc:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.rs}
|
||||||
|
println!("{}", monster.hp()); // `80`
|
||||||
|
println!("{}", monster.mana()); // default value of `150`
|
||||||
|
println!("{:?}", monster.name()); // Some("MyMonster")
|
||||||
|
}
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
*Note: That we never stored a `mana` value, so it will return the default.*
|
||||||
|
|
||||||
|
## Direct memory access
|
||||||
|
|
||||||
|
As you can see from the above examples, all elements in a buffer are
|
||||||
|
accessed through generated accessors. This is because everything is
|
||||||
|
stored in little endian format on all platforms (the accessor
|
||||||
|
performs a swap operation on big endian machines), and also because
|
||||||
|
the layout of things is generally not known to the user.
|
||||||
|
|
||||||
|
For structs, layout is deterministic and guaranteed to be the same
|
||||||
|
across platforms (scalars are aligned to their
|
||||||
|
own size, and structs themselves to their largest member), and you
|
||||||
|
are allowed to access this memory directly by using `safe_slice` and
|
||||||
|
on the reference to a struct, or even an array of structs.
|
||||||
|
|
||||||
|
To compute offsets to sub-elements of a struct, make sure they
|
||||||
|
are structs themselves, as then you can use the pointers to
|
||||||
|
figure out the offset without having to hardcode it. This is
|
||||||
|
handy for use of arrays of structs with calls like `glVertexAttribPointer`
|
||||||
|
in OpenGL or similar APIs.
|
||||||
|
|
||||||
|
It is important to note is that structs are still little endian on all
|
||||||
|
machines, so only use tricks like this if you can guarantee you're not
|
||||||
|
shipping on a big endian machine (using an `#[cfg(target_endian = "little")]`
|
||||||
|
attribute would be wise).
|
||||||
|
|
||||||
|
The special function `safe_slice` is implemented on Vector objects that are
|
||||||
|
represented in memory the same way as they are represented on the wire. This
|
||||||
|
function is always available on vectors of struct, bool, u8, and i8. It is
|
||||||
|
conditionally-compiled on little-endian systems for all the remaining scalar
|
||||||
|
types.
|
||||||
|
|
||||||
|
The FlatBufferBuilder function `create_vector_direct` is implemented for all
|
||||||
|
types that are endian-safe to write with a `memcpy`. It is the write-equivalent
|
||||||
|
of `safe_slice`.
|
||||||
|
|
||||||
|
## Access of untrusted buffers
|
||||||
|
|
||||||
|
The generated accessor functions access fields over offsets, which is
|
||||||
|
very quick. These offsets are used to index into Rust slices, so they are
|
||||||
|
bounds-checked by the Rust runtime. However, our Rust implementation may
|
||||||
|
change: we may convert access functions to use direct pointer dereferencing, to
|
||||||
|
improve lookup speed. As a result, users should not rely on the aforementioned
|
||||||
|
bounds-checking behavior.
|
||||||
|
|
||||||
|
When you're processing large amounts of data from a source you know (e.g.
|
||||||
|
your own generated data on disk), this is acceptable, but when reading
|
||||||
|
data from the network that can potentially have been modified by an
|
||||||
|
attacker, this is undesirable.
|
||||||
|
|
||||||
|
The C++ port provides a buffer verifier. At this time, Rust does not. Rust may
|
||||||
|
provide a verifier in a future version. In the meantime, Rust users can access
|
||||||
|
the buffer verifier generated by the C++ port through a foreign function
|
||||||
|
interface (FFI).
|
||||||
|
|
||||||
|
## Threading
|
||||||
|
|
||||||
|
Reading a FlatBuffer does not touch any memory outside the original buffer,
|
||||||
|
and is entirely read-only (all immutable), so is safe to access from multiple
|
||||||
|
threads even without synchronisation primitives.
|
||||||
|
|
||||||
|
Creating a FlatBuffer is not thread safe. All state related to building
|
||||||
|
a FlatBuffer is contained in a FlatBufferBuilder instance, and no memory
|
||||||
|
outside of it is touched. To make this thread safe, either do not
|
||||||
|
share instances of FlatBufferBuilder between threads (recommended), or
|
||||||
|
manually wrap it in synchronisation primitives. There's no automatic way to
|
||||||
|
accomplish this, by design, as we feel multithreaded construction
|
||||||
|
of a single buffer will be rare, and synchronisation overhead would be costly.
|
||||||
|
|
||||||
|
## Useful tools created by others
|
||||||
|
|
||||||
|
* [flatc-rust](https://github.com/frol/flatc-rust) - FlatBuffers compiler
|
||||||
|
(flatc) as API for transparent `.fbs` to `.rs` code-generation via Cargo
|
||||||
|
build scripts integration.
|
||||||
|
|
||||||
|
<br>
|
||||||
209
docs/source/Schemas.md
Executable file → Normal file
209
docs/source/Schemas.md
Executable file → Normal file
@@ -84,15 +84,19 @@ parent object, and use no virtual table).
|
|||||||
|
|
||||||
### Types
|
### Types
|
||||||
|
|
||||||
Built-in scalar types are:
|
Built-in scalar types are
|
||||||
|
|
||||||
- 8 bit: `byte`, `ubyte`, `bool`
|
- 8 bit: `byte` (`int8`), `ubyte` (`uint8`), `bool`
|
||||||
|
|
||||||
- 16 bit: `short`, `ushort`
|
- 16 bit: `short` (`int16`), `ushort` (`uint16`)
|
||||||
|
|
||||||
- 32 bit: `int`, `uint`, `float`
|
- 32 bit: `int` (`int32`), `uint` (`uint32`), `float` (`float32`)
|
||||||
|
|
||||||
- 64 bit: `long`, `ulong`, `double`
|
- 64 bit: `long` (`int64`), `ulong` (`uint64`), `double` (`float64`)
|
||||||
|
|
||||||
|
The type names in parentheses are alias names such that for example
|
||||||
|
`uint8` can be used in place of `ubyte`, and `int32` can be used in
|
||||||
|
place of `int` without affecting code generation.
|
||||||
|
|
||||||
Built-in non-scalar types:
|
Built-in non-scalar types:
|
||||||
|
|
||||||
@@ -122,7 +126,8 @@ default to `NULL` when not present.
|
|||||||
|
|
||||||
You generally do not want to change default values after they're initially
|
You generally do not want to change default values after they're initially
|
||||||
defined. Fields that have the default value are not actually stored in the
|
defined. Fields that have the default value are not actually stored in the
|
||||||
serialized data but are generated in code, so when you change the default, you'd
|
serialized data (see also Gotchas below) but are generated in code,
|
||||||
|
so when you change the default, you'd
|
||||||
now get a different value than from code generated from an older version of
|
now get a different value than from code generated from an older version of
|
||||||
the schema. There are situations, however, where this may be
|
the schema. There are situations, however, where this may be
|
||||||
desirable, especially if you can ensure a simultaneous rebuild of
|
desirable, especially if you can ensure a simultaneous rebuild of
|
||||||
@@ -136,6 +141,9 @@ is `0`. As you can see in the enum declaration, you specify the underlying
|
|||||||
integral type of the enum with `:` (in this case `byte`), which then determines
|
integral type of the enum with `:` (in this case `byte`), which then determines
|
||||||
the type of any fields declared with this enum type.
|
the type of any fields declared with this enum type.
|
||||||
|
|
||||||
|
Only integer types are allowed, i.e. `byte`, `ubyte`, `short` `ushort`, `int`,
|
||||||
|
`uint`, `long` and `ulong`.
|
||||||
|
|
||||||
Typically, enum values should only ever be added, never removed (there is no
|
Typically, enum values should only ever be added, never removed (there is no
|
||||||
deprecation for enums). This requires code to handle forwards compatibility
|
deprecation for enums). This requires code to handle forwards compatibility
|
||||||
itself, by handling unknown enum values.
|
itself, by handling unknown enum values.
|
||||||
@@ -145,9 +153,23 @@ itself, by handling unknown enum values.
|
|||||||
Unions share a lot of properties with enums, but instead of new names
|
Unions share a lot of properties with enums, but instead of new names
|
||||||
for constants, you use names of tables. You can then declare
|
for constants, you use names of tables. You can then declare
|
||||||
a union field, which can hold a reference to any of those types, and
|
a union field, which can hold a reference to any of those types, and
|
||||||
additionally a hidden field with the suffix `_type` is generated that
|
additionally a field with the suffix `_type` is generated that holds
|
||||||
holds the corresponding enum value, allowing you to know which type to
|
the corresponding enum value, allowing you to know which type to cast
|
||||||
cast to at runtime.
|
to at runtime.
|
||||||
|
|
||||||
|
It's possible to give an alias name to a type union. This way a type can even be
|
||||||
|
used to mean different things depending on the name used:
|
||||||
|
|
||||||
|
table PointPosition { x:uint; y:uint; }
|
||||||
|
table MarkerPosition {}
|
||||||
|
union Position {
|
||||||
|
Start:MarkerPosition,
|
||||||
|
Point:PointPosition,
|
||||||
|
Finish:MarkerPosition
|
||||||
|
}
|
||||||
|
|
||||||
|
Unions contain a special `NONE` marker to denote that no value is stored so that
|
||||||
|
name cannot be used as an alias.
|
||||||
|
|
||||||
Unions are a good way to be able to send multiple message types as a FlatBuffer.
|
Unions are a good way to be able to send multiple message types as a FlatBuffer.
|
||||||
Note that because a union field is really two fields, it must always be
|
Note that because a union field is really two fields, it must always be
|
||||||
@@ -157,6 +179,10 @@ If you have a need to distinguish between different FlatBuffers in a more
|
|||||||
open-ended way, for example for use as files, see the file identification
|
open-ended way, for example for use as files, see the file identification
|
||||||
feature below.
|
feature below.
|
||||||
|
|
||||||
|
There is an experimental support only in C++ for a vector of unions
|
||||||
|
(and types). In the example IDL file above, use [Any] to add a
|
||||||
|
vector of Any to Monster table.
|
||||||
|
|
||||||
### Namespaces
|
### Namespaces
|
||||||
|
|
||||||
These will generate the corresponding namespace in C++ for all helper
|
These will generate the corresponding namespace in C++ for all helper
|
||||||
@@ -224,6 +250,21 @@ This declaration in the schema will change that to whatever you want:
|
|||||||
|
|
||||||
file_extension "ext";
|
file_extension "ext";
|
||||||
|
|
||||||
|
### RPC interface declarations
|
||||||
|
|
||||||
|
You can declare RPC calls in a schema, that define a set of functions
|
||||||
|
that take a FlatBuffer as an argument (the request) and return a FlatBuffer
|
||||||
|
as the response (both of which must be table types):
|
||||||
|
|
||||||
|
rpc_service MonsterStorage {
|
||||||
|
Store(Monster):StoreResponse;
|
||||||
|
Retrieve(MonsterId):Monster;
|
||||||
|
}
|
||||||
|
|
||||||
|
What code this produces and how it is used depends on language and RPC system
|
||||||
|
used, there is preliminary support for GRPC through the `--grpc` code generator,
|
||||||
|
see `grpc/tests` for an example.
|
||||||
|
|
||||||
### Comments & documentation
|
### Comments & documentation
|
||||||
|
|
||||||
May be written as in most C-based languages. Additionally, a triple
|
May be written as in most C-based languages. Additionally, a triple
|
||||||
@@ -256,9 +297,12 @@ Current understood attributes:
|
|||||||
the union field should have id 8, and the unions type field will
|
the union field should have id 8, and the unions type field will
|
||||||
implicitly be 7.
|
implicitly be 7.
|
||||||
IDs allow the fields to be placed in any order in the schema.
|
IDs allow the fields to be placed in any order in the schema.
|
||||||
When a new field is added to the schema is must use the next available ID.
|
When a new field is added to the schema it must use the next available ID.
|
||||||
- `deprecated` (on a field): do not generate accessors for this field
|
- `deprecated` (on a field): do not generate accessors for this field
|
||||||
anymore, code should stop using this data.
|
anymore, code should stop using this data. Old data may still contain this
|
||||||
|
field, but it won't be accessible anymore by newer code. Note that if you
|
||||||
|
deprecate a field that was previous required, old code may fail to validate
|
||||||
|
new data (when using the optional verifier).
|
||||||
- `required` (on a non-scalar table field): this field must always be set.
|
- `required` (on a non-scalar table field): this field must always be set.
|
||||||
By default, all fields are optional, i.e. may be left out. This is
|
By default, all fields are optional, i.e. may be left out. This is
|
||||||
desirable, as it helps with forwards/backwards compatibility, and
|
desirable, as it helps with forwards/backwards compatibility, and
|
||||||
@@ -268,26 +312,44 @@ Current understood attributes:
|
|||||||
constructs FlatBuffers to ensure this field is initialized, so the reading
|
constructs FlatBuffers to ensure this field is initialized, so the reading
|
||||||
code may access it directly, without checking for NULL. If the constructing
|
code may access it directly, without checking for NULL. If the constructing
|
||||||
code does not initialize this field, they will get an assert, and also
|
code does not initialize this field, they will get an assert, and also
|
||||||
the verifier will fail on buffers that have missing required fields.
|
the verifier will fail on buffers that have missing required fields. Note
|
||||||
- `original_order` (on a table): since elements in a table do not need
|
that if you add this attribute to an existing field, this will only be
|
||||||
to be stored in any particular order, they are often optimized for
|
valid if existing data always contains this field / existing code always
|
||||||
space by sorting them to size. This attribute stops that from happening.
|
writes this field.
|
||||||
- `force_align: size` (on a struct): force the alignment of this struct
|
- `force_align: size` (on a struct): force the alignment of this struct
|
||||||
to be something higher than what it is naturally aligned to. Causes
|
to be something higher than what it is naturally aligned to. Causes
|
||||||
these structs to be aligned to that amount inside a buffer, IF that
|
these structs to be aligned to that amount inside a buffer, IF that
|
||||||
buffer is allocated with that alignment (which is not necessarily
|
buffer is allocated with that alignment (which is not necessarily
|
||||||
the case for buffers accessed directly inside a `FlatBufferBuilder`).
|
the case for buffers accessed directly inside a `FlatBufferBuilder`).
|
||||||
- `bit_flags` (on an enum): the values of this field indicate bits,
|
Note: currently not guaranteed to have an effect when used with
|
||||||
meaning that any value N specified in the schema will end up
|
`--object-api`, since that may allocate objects at alignments less than
|
||||||
|
what you specify with `force_align`.
|
||||||
|
- `bit_flags` (on an unsigned enum): the values of this field indicate bits,
|
||||||
|
meaning that any unsigned value N specified in the schema will end up
|
||||||
representing 1<<N, or if you don't specify values at all, you'll get
|
representing 1<<N, or if you don't specify values at all, you'll get
|
||||||
the sequence 1, 2, 4, 8, ...
|
the sequence 1, 2, 4, 8, ...
|
||||||
- `nested_flatbuffer: "table_name"` (on a field): this indicates that the field
|
- `nested_flatbuffer: "table_name"` (on a field): this indicates that the field
|
||||||
(which must be a vector of ubyte) contains flatbuffer data, for which the
|
(which must be a vector of ubyte) contains flatbuffer data, for which the
|
||||||
root type is given by `table_name`. The generated code will then produce
|
root type is given by `table_name`. The generated code will then produce
|
||||||
a convenient accessor for the nested FlatBuffer.
|
a convenient accessor for the nested FlatBuffer.
|
||||||
|
- `flexbuffer` (on a field): this indicates that the field
|
||||||
|
(which must be a vector of ubyte) contains flexbuffer data. The generated
|
||||||
|
code will then produce a convenient accessor for the FlexBuffer root.
|
||||||
- `key` (on a field): this field is meant to be used as a key when sorting
|
- `key` (on a field): this field is meant to be used as a key when sorting
|
||||||
a vector of the type of table it sits in. Can be used for in-place
|
a vector of the type of table it sits in. Can be used for in-place
|
||||||
binary search.
|
binary search.
|
||||||
|
- `hash` (on a field). This is an (un)signed 32/64 bit integer field, whose
|
||||||
|
value during JSON parsing is allowed to be a string, which will then be
|
||||||
|
stored as its hash. The value of attribute is the hashing algorithm to
|
||||||
|
use, one of `fnv1_32` `fnv1_64` `fnv1a_32` `fnv1a_64`.
|
||||||
|
- `original_order` (on a table): since elements in a table do not need
|
||||||
|
to be stored in any particular order, they are often optimized for
|
||||||
|
space by sorting them to size. This attribute stops that from happening.
|
||||||
|
There should generally not be any reason to use this flag.
|
||||||
|
- 'native_*'. Several attributes have been added to support the [C++ object
|
||||||
|
Based API](@ref flatbuffers_cpp_object_based_api). All such attributes
|
||||||
|
are prefixed with the term "native_".
|
||||||
|
|
||||||
|
|
||||||
## JSON Parsing
|
## JSON Parsing
|
||||||
|
|
||||||
@@ -318,6 +380,10 @@ JSON:
|
|||||||
- A field that has the value `null` (e.g. `field: null`) is intended to
|
- A field that has the value `null` (e.g. `field: null`) is intended to
|
||||||
have the default value for that field (thus has the same effect as if
|
have the default value for that field (thus has the same effect as if
|
||||||
that field wasn't specified at all).
|
that field wasn't specified at all).
|
||||||
|
- It has some built in conversion functions, so you can write for example
|
||||||
|
`rad(180)` where ever you'd normally write `3.14159`.
|
||||||
|
Currently supports the following functions: `rad`, `deg`, `cos`, `sin`,
|
||||||
|
`tan`, `acos`, `asin`, `atan`.
|
||||||
|
|
||||||
When parsing JSON, it recognizes the following escape codes in strings:
|
When parsing JSON, it recognizes the following escape codes in strings:
|
||||||
|
|
||||||
@@ -339,6 +405,91 @@ When parsing JSON, it recognizes the following escape codes in strings:
|
|||||||
It also generates these escape codes back again when generating JSON from a
|
It also generates these escape codes back again when generating JSON from a
|
||||||
binary representation.
|
binary representation.
|
||||||
|
|
||||||
|
When parsing numbers, the parser is more flexible than JSON.
|
||||||
|
A format of numeric literals is more close to the C/C++.
|
||||||
|
According to the [grammar](@ref flatbuffers_grammar), it accepts the following
|
||||||
|
numerical literals:
|
||||||
|
|
||||||
|
- An integer literal can have any number of leading zero `0` digits.
|
||||||
|
Unlike C/C++, the parser ignores a leading zero, not interpreting it as the
|
||||||
|
beginning of the octal number.
|
||||||
|
The numbers `[081, -00094]` are equal to `[81, -94]` decimal integers.
|
||||||
|
- The parser accepts unsigned and signed hexadecimal integer numbers.
|
||||||
|
For example: `[0x123, +0x45, -0x67]` are equal to `[291, 69, -103]` decimals.
|
||||||
|
- The format of float-point numbers is fully compatible with C/C++ format.
|
||||||
|
If a modern C++ compiler is used the parser accepts hexadecimal and special
|
||||||
|
float-point literals as well:
|
||||||
|
`[-1.0, 2., .3e0, 3.e4, 0x21.34p-5, -inf, nan]`.
|
||||||
|
The exponent suffix of hexadecimal float-point number is mandatory.
|
||||||
|
|
||||||
|
Extended float-point support was tested with:
|
||||||
|
- x64 Windows: `MSVC2015` and higher.
|
||||||
|
- x64 Linux: `LLVM 6.0`, `GCC 4.9` and higher.
|
||||||
|
|
||||||
|
- For compatibility with a JSON lint tool all numeric literals of scalar
|
||||||
|
fields can be wrapped to quoted string:
|
||||||
|
`"1", "2.0", "0x48A", "0x0C.0Ep-1", "-inf", "true"`.
|
||||||
|
|
||||||
|
## Guidelines
|
||||||
|
|
||||||
|
### Efficiency
|
||||||
|
|
||||||
|
FlatBuffers is all about efficiency, but to realize that efficiency you
|
||||||
|
require an efficient schema. There are usually multiple choices on
|
||||||
|
how to represent data that have vastly different size characteristics.
|
||||||
|
|
||||||
|
It is very common nowadays to represent any kind of data as dictionaries
|
||||||
|
(as in e.g. JSON), because of its flexibility and extensibility. While
|
||||||
|
it is possible to emulate this in FlatBuffers (as a vector
|
||||||
|
of tables with key and value(s)), this is a bad match for a strongly
|
||||||
|
typed system like FlatBuffers, leading to relatively large binaries.
|
||||||
|
FlatBuffer tables are more flexible than classes/structs in most systems,
|
||||||
|
since having a large number of fields only few of which are actually
|
||||||
|
used is still efficient. You should thus try to organize your data
|
||||||
|
as much as possible such that you can use tables where you might be
|
||||||
|
tempted to use a dictionary.
|
||||||
|
|
||||||
|
Similarly, strings as values should only be used when they are
|
||||||
|
truely open-ended. If you can, always use an enum instead.
|
||||||
|
|
||||||
|
FlatBuffers doesn't have inheritance, so the way to represent a set
|
||||||
|
of related data structures is a union. Unions do have a cost however,
|
||||||
|
so an alternative to a union is to have a single table that has
|
||||||
|
all the fields of all the data structures you are trying to
|
||||||
|
represent, if they are relatively similar / share many fields.
|
||||||
|
Again, this is efficient because optional fields are cheap.
|
||||||
|
|
||||||
|
FlatBuffers supports the full range of integer sizes, so try to pick
|
||||||
|
the smallest size needed, rather than defaulting to int/long.
|
||||||
|
|
||||||
|
Remember that you can share data (refer to the same string/table
|
||||||
|
within a buffer), so factoring out repeating data into its own
|
||||||
|
data structure may be worth it.
|
||||||
|
|
||||||
|
### Style guide
|
||||||
|
|
||||||
|
Identifiers in a schema are meant to translate to many different programming
|
||||||
|
languages, so using the style of your "main" language is generally a bad idea.
|
||||||
|
|
||||||
|
For this reason, below is a suggested style guide to adhere to, to keep schemas
|
||||||
|
consistent for interoperation regardless of the target language.
|
||||||
|
|
||||||
|
Where possible, the code generators for specific languages will generate
|
||||||
|
identifiers that adhere to the language style, based on the schema identifiers.
|
||||||
|
|
||||||
|
- Table, struct, enum and rpc names (types): UpperCamelCase.
|
||||||
|
- Table and struct field names: snake_case. This is translated to lowerCamelCase
|
||||||
|
automatically for some languages, e.g. Java.
|
||||||
|
- Enum values: UpperCamelCase.
|
||||||
|
- namespaces: UpperCamelCase.
|
||||||
|
|
||||||
|
Formatting (this is less important, but still worth adhering to):
|
||||||
|
|
||||||
|
- Opening brace: on the same line as the start of the declaration.
|
||||||
|
- Spacing: Indent by 2 spaces. None around `:` for types, on both sides for `=`.
|
||||||
|
|
||||||
|
For an example, see the schema at the top of this file.
|
||||||
|
|
||||||
## Gotchas
|
## Gotchas
|
||||||
|
|
||||||
### Schemas and version control
|
### Schemas and version control
|
||||||
@@ -425,4 +576,28 @@ incompatible with the actual binary buffers, since those only ever address
|
|||||||
fields by id/offset.
|
fields by id/offset.
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
### Testing whether a field is present in a table
|
||||||
|
|
||||||
|
Most serialization formats (e.g. JSON or Protocol Buffers) make it very
|
||||||
|
explicit in the format whether a field is present in an object or not,
|
||||||
|
allowing you to use this as "extra" information.
|
||||||
|
|
||||||
|
In FlatBuffers, this also holds for everything except scalar values.
|
||||||
|
|
||||||
|
FlatBuffers by default will not write fields that are equal to the default
|
||||||
|
value (for scalars), sometimes resulting in a significant space savings.
|
||||||
|
|
||||||
|
However, this also means testing whether a field is "present" is somewhat
|
||||||
|
meaningless, since it does not tell you if the field was actually written by
|
||||||
|
calling `add_field` style calls, unless you're only interested in this
|
||||||
|
information for non-default values.
|
||||||
|
|
||||||
|
Some `FlatBufferBuilder` implementations have an option called `force_defaults`
|
||||||
|
that circumvents this behavior, and writes fields even if they are equal to
|
||||||
|
the default. You can then use `IsFieldPresent` to query this.
|
||||||
|
|
||||||
|
Another option that works in all languages is to wrap a scalar field in a
|
||||||
|
struct. This way it will return null if it is not present. The cool thing
|
||||||
|
is that structs don't take up any more space than the scalar they represent.
|
||||||
|
|
||||||
[Interface Definition Language]: https://en.wikipedia.org/wiki/Interface_description_language
|
[Interface Definition Language]: https://en.wikipedia.org/wiki/Interface_description_language
|
||||||
|
|||||||
36
docs/source/Support.md
Executable file → Normal file
36
docs/source/Support.md
Executable file → Normal file
@@ -18,27 +18,29 @@ In general:
|
|||||||
|
|
||||||
NOTE: this table is a start, it needs to be extended.
|
NOTE: this table is a start, it needs to be extended.
|
||||||
|
|
||||||
Feature | C++ | Java | C# | Go | Python | JS | C | PHP | Ruby
|
Feature | C++ | Java | C# | Go | Python | JS | TS | C | PHP | Dart | Lobster | Rust
|
||||||
------------------------------ | ------ | ------ | ------ | ------ | ------ | --------- | ---- | --- | ----
|
------------------------------ | ------ | ------ | ------ | ------ | ------ | --------- | --------- | ------ | --- | ------- | ------- | ----
|
||||||
Codegen for all basic features | Yes | Yes | Yes | Yes | Yes | Yes | WiP | WiP | WiP
|
Codegen for all basic features | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | WiP | Yes | Yes | Yes
|
||||||
JSON parsing | Yes | No | No | No | No | No | No | No | No
|
JSON parsing | Yes | No | No | No | No | No | No | Yes | No | No | Yes | No
|
||||||
Simple mutation | Yes | WIP | WIP | No | No | No | No | No | No
|
Simple mutation | Yes | Yes | Yes | Yes | No | No | No | No | No | No | No | No
|
||||||
Reflection | Yes | No | No | No | No | No | No | No | No
|
Reflection | Yes | No | No | No | No | No | No | Basic | No | No | No | No
|
||||||
Buffer verifier | Yes | No | No | No | No | No | No | No | No
|
Buffer verifier | Yes | No | No | No | No | No | No | Yes | No | No | No | No
|
||||||
Testing: basic | Yes | Yes | Yes | Yes | Yes | Yes | ? | ? | ?
|
Testing: basic | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? | Yes | Yes | Yes
|
||||||
Testing: fuzz | Yes | No | No | Yes | Yes | No | ? | ? | ?
|
Testing: fuzz | Yes | No | No | Yes | Yes | No | No | No | ? | No | No | Yes
|
||||||
Performance: | Superb | Great | Great | Great | Ok | ? |Superb| ? | ?
|
Performance: | Superb | Great | Great | Great | Ok | ? | ? | Superb | ? | ? | Great | Superb
|
||||||
Platform: Windows | VS2010 | Yes | Yes | ? | ? | ? | ? | ? | ?
|
Platform: Windows | VS2010 | Yes | Yes | ? | ? | ? | Yes | VS2010 | ? | Yes | Yes | Yes
|
||||||
Platform: Linux | GCC282 | Yes | ? | Yes | Yes | ? | ? | ? | ?
|
Platform: Linux | GCC282 | Yes | ? | Yes | Yes | ? | Yes | Yes | ? | Yes | Yes | Yes
|
||||||
Platform: OS X | Xcode4 | ? | ? | ? | Yes | ? | ? | ? | ?
|
Platform: OS X | Xcode4 | ? | ? | ? | Yes | ? | Yes | Yes | ? | Yes | Yes | Yes
|
||||||
Platform: Android | NDK10d | Yes | ? | ? | ? | ? | ? | ? | ?
|
Platform: Android | NDK10d | Yes | ? | ? | ? | ? | ? | ? | ? | Flutter | Yes | ?
|
||||||
Platform: iOS | ? | ? | ? | ? | ? | ? | ? | ? | ?
|
Platform: iOS | ? | ? | ? | ? | ? | ? | ? | ? | ? | Flutter | Yes | ?
|
||||||
Engine: Unity | ? | ? | Yes | ? | ? | ? | ? | ? | ?
|
Engine: Unity | ? | ? | Yes | ? | ? | ? | ? | ? | ? | ? | No | ?
|
||||||
Primary authors (github) | gwvo | gwvo | ev*/js*| rw | rw | evanw/ev* | mik* | ch* | rw
|
Primary authors (github) | aard* | aard* | ev*/js*| rw | rw | evanw/ev* | kr* | mik* | ch* | dnfield | aard* | rw
|
||||||
|
|
||||||
|
* aard = aardappel (previously: gwvo)
|
||||||
* ev = evolutional
|
* ev = evolutional
|
||||||
* js = jonsimantov
|
* js = jonsimantov
|
||||||
* mik = mikkelfj
|
* mik = mikkelfj
|
||||||
* ch = chobie
|
* ch = chobie
|
||||||
|
* kr = krojew
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
66
docs/source/TypeScriptUsage.md
Normal file
66
docs/source/TypeScriptUsage.md
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
Use in TypeScript {#flatbuffers_guide_use_typescript}
|
||||||
|
=================
|
||||||
|
|
||||||
|
## Before you get started
|
||||||
|
|
||||||
|
Before diving into the FlatBuffers usage in TypeScript, it should be noted that
|
||||||
|
the [Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide to
|
||||||
|
general FlatBuffers usage in all of the supported languages
|
||||||
|
(including TypeScript). This page is specifically designed to cover the nuances
|
||||||
|
of FlatBuffers usage in TypeScript.
|
||||||
|
|
||||||
|
You should also have read the [Building](@ref flatbuffers_guide_building)
|
||||||
|
documentation to build `flatc` and should be familiar with
|
||||||
|
[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler) and
|
||||||
|
[Writing a schema](@ref flatbuffers_guide_writing_schema).
|
||||||
|
|
||||||
|
## FlatBuffers TypeScript library code location
|
||||||
|
|
||||||
|
The code for the FlatBuffers TypeScript library can be found at
|
||||||
|
`flatbuffers/js` with typings available at `@types/flatbuffers`.
|
||||||
|
|
||||||
|
## Testing the FlatBuffers TypeScript library
|
||||||
|
|
||||||
|
To run the tests, use the [TypeScriptTest.sh](https://github.com/google/
|
||||||
|
flatbuffers/blob/master/tests/TypeScriptTest.sh) shell script.
|
||||||
|
|
||||||
|
*Note: The TypeScript test file requires [Node.js](https://nodejs.org/en/).*
|
||||||
|
|
||||||
|
## Using the FlatBuffers TypeScript libary
|
||||||
|
|
||||||
|
*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth
|
||||||
|
example of how to use FlatBuffers in TypeScript.*
|
||||||
|
|
||||||
|
FlatBuffers supports both reading and writing FlatBuffers in TypeScript.
|
||||||
|
|
||||||
|
To use FlatBuffers in your own code, first generate TypeScript classes from your
|
||||||
|
schema with the `--ts` option to `flatc`. Then you can include both FlatBuffers
|
||||||
|
and the generated code to read or write a FlatBuffer.
|
||||||
|
|
||||||
|
For example, here is how you would read a FlatBuffer binary file in TypeScript:
|
||||||
|
First, include the library and generated code. Then read the file into an
|
||||||
|
`Uint8Array`. Make a `flatbuffers.ByteBuffer` out of the `Uint8Array`, and pass
|
||||||
|
the ByteBuffer to the `getRootAsMonster` function.
|
||||||
|
|
||||||
|
~~~{.ts}
|
||||||
|
// note: import flabuffers with your desired import method
|
||||||
|
|
||||||
|
import { MyGame } from './monster_generated';
|
||||||
|
|
||||||
|
let data = new Uint8Array(fs.readFileSync('monster.dat'));
|
||||||
|
let buf = new flatbuffers.ByteBuffer(data);
|
||||||
|
|
||||||
|
let monster = MyGame.Example.Monster.getRootAsMonster(buf);
|
||||||
|
~~~
|
||||||
|
|
||||||
|
Now you can access values like this:
|
||||||
|
|
||||||
|
~~~{.ts}
|
||||||
|
let hp = monster.hp();
|
||||||
|
let pos = monster.pos();
|
||||||
|
~~~
|
||||||
|
|
||||||
|
## Text parsing FlatBuffers in TypeScript
|
||||||
|
|
||||||
|
There currently is no support for parsing text (Schema's and JSON) directly
|
||||||
|
from TypeScript.
|
||||||
0
docs/source/WhitePaper.md
Executable file → Normal file
0
docs/source/WhitePaper.md
Executable file → Normal file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user