Compare commits
696 Commits
RELEASE_0_
...
RELEASE_0_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1818102ffe | ||
|
|
406d6dd6fc | ||
|
|
c8ef854f01 | ||
|
|
87dcaf5a00 | ||
|
|
c3bdd0e537 | ||
|
|
c23fd6e66f | ||
|
|
e809eee896 | ||
|
|
c44ef2126c | ||
|
|
e2bfb5633b | ||
|
|
064ee8ba8f | ||
|
|
a5c130446e | ||
|
|
4162817c0b | ||
|
|
81cab6e089 | ||
|
|
d78204d147 | ||
|
|
d8b523d067 | ||
|
|
c4cfad6069 | ||
|
|
5bddb88ce2 | ||
|
|
8c4ee69aeb | ||
|
|
b3a533f8ce | ||
|
|
a885314a39 | ||
|
|
0567a76445 | ||
|
|
d6dc2d6eab | ||
|
|
b75a694682 | ||
|
|
2e7e9b73a0 | ||
|
|
7a11523692 | ||
|
|
f85a9866fe | ||
|
|
9b05c27938 | ||
|
|
fd96729362 | ||
|
|
c57cc096f8 | ||
|
|
c8efd0a465 | ||
|
|
db60139845 | ||
|
|
cadefd323a | ||
|
|
baab88f42a | ||
|
|
767b74dd35 | ||
|
|
90e8287f43 | ||
|
|
d8b7e5b8fd | ||
|
|
7769447283 | ||
|
|
d6a790cf13 | ||
|
|
033c66363d | ||
|
|
3ff1789963 | ||
|
|
9737c0c4dd | ||
|
|
b201383a80 | ||
|
|
2253b82304 | ||
|
|
2581446d85 | ||
|
|
a6291b286c | ||
|
|
96a396bfcb | ||
|
|
0833a11686 | ||
|
|
9c7f7f3d32 | ||
|
|
7847fe8074 | ||
|
|
c57d25ac51 | ||
|
|
1341b5b9f8 | ||
|
|
fb54e9e103 | ||
|
|
3a835dde7d | ||
|
|
128a4a36ca | ||
|
|
255bb6dd07 | ||
|
|
786b1e3a30 | ||
|
|
d5f38a558e | ||
|
|
ce5d4b7db8 | ||
|
|
8c0b36fe9e | ||
|
|
c7e6459c64 | ||
|
|
86e31e696d | ||
|
|
be0b1bb994 | ||
|
|
03e74bfeb4 | ||
|
|
972223cd50 | ||
|
|
761b7b9354 | ||
|
|
6a3d1895d9 | ||
|
|
d1178a26ce | ||
|
|
8ffdfa3cb1 | ||
|
|
384e56b9b4 | ||
|
|
d198e962b0 | ||
|
|
0136fdadbb | ||
|
|
c616568830 | ||
|
|
995d2c1ede | ||
|
|
051a5e9a38 | ||
|
|
60d89097de | ||
|
|
6c35255549 | ||
|
|
c985d8846d | ||
|
|
9a8ab26381 | ||
|
|
711622fd5b | ||
|
|
96474823b5 | ||
|
|
bbf4b54613 | ||
|
|
9795c5dd6b | ||
|
|
addcace80d | ||
|
|
77e43a5fa8 | ||
|
|
b751188e56 | ||
|
|
1ad9a15864 | ||
|
|
d0d7878e0a | ||
|
|
be5d365348 | ||
|
|
a8e0002a64 | ||
|
|
bf75cf7225 | ||
|
|
c024b680bc | ||
|
|
c896475765 | ||
|
|
101fdb3598 | ||
|
|
b13505afdf | ||
|
|
9d96b171a0 | ||
|
|
8b5a0cde69 | ||
|
|
bed7593cdd | ||
|
|
9fed946567 | ||
|
|
4d0bc0ae39 | ||
|
|
f9824aa7de | ||
|
|
4d2522964a | ||
|
|
dbe4a59b8e | ||
|
|
918f8a3ed4 | ||
|
|
f645596606 | ||
|
|
d778dd081d | ||
|
|
f6ed02c3fb | ||
|
|
7fa5dd7a35 | ||
|
|
a3186af099 | ||
|
|
a2d95ac742 | ||
|
|
10715bbea7 | ||
|
|
89fcb12556 | ||
|
|
cc3d7ddee5 | ||
|
|
cc01f99acb | ||
|
|
62b75190bb | ||
|
|
520124c1be | ||
|
|
e251bfcbaf | ||
|
|
aef809348f | ||
|
|
2d4a8774b8 | ||
|
|
b55c8fd828 | ||
|
|
dfff091b5f | ||
|
|
47eb7efafa | ||
|
|
b2a7fff26e | ||
|
|
5f70123723 | ||
|
|
dd629da8d3 | ||
|
|
74f7d52d95 | ||
|
|
7a65a990ba | ||
|
|
fe0076e291 | ||
|
|
1a8bc06cc6 | ||
|
|
8c41081a5c | ||
|
|
5b40eed554 | ||
|
|
b1c4d34eef | ||
|
|
0152b607f8 | ||
|
|
ab6e72047b | ||
|
|
15399bfe95 | ||
|
|
0ff748987b | ||
|
|
58e0e7736b | ||
|
|
2d1b2ca938 | ||
|
|
9a4152eb2d | ||
|
|
6ab443545f | ||
|
|
98a9b4a10c | ||
|
|
a6251606dd | ||
|
|
c3b21e143c | ||
|
|
b496593883 | ||
|
|
4ef4b019ca | ||
|
|
a8021531ab | ||
|
|
93fd948978 | ||
|
|
a1b3740dc6 | ||
|
|
40920457cb | ||
|
|
5039c84fd0 | ||
|
|
220a43bf46 | ||
|
|
45d3e19c38 | ||
|
|
5bab565cfe | ||
|
|
319a4282c8 | ||
|
|
c6aa8bc8e9 | ||
|
|
6f1bfa202e | ||
|
|
6fa9f86d1c | ||
|
|
019a9527d2 | ||
|
|
d100ca485f | ||
|
|
35ab6900ee | ||
|
|
c8570302f5 | ||
|
|
74f10486bc | ||
|
|
2b12425a62 | ||
|
|
c600aad7a7 | ||
|
|
67b2f0a977 | ||
|
|
70c6b48a07 | ||
|
|
76084f8538 | ||
|
|
64c408d2b7 | ||
|
|
73b050ae34 | ||
|
|
59991393ca | ||
|
|
69b2717b62 | ||
|
|
f2a323e048 | ||
|
|
7d07e6ea51 | ||
|
|
7c846972bf | ||
|
|
4f76c258af | ||
|
|
eca2afb982 | ||
|
|
9ff6934c83 | ||
|
|
e04839765d | ||
|
|
d0c655109f | ||
|
|
b28b55abb1 | ||
|
|
c3a0db1aba | ||
|
|
5e929d7d01 | ||
|
|
17f113f8cd | ||
|
|
445cd4ccda | ||
|
|
55845bbbb9 | ||
|
|
1976481ba2 | ||
|
|
5f17edbc72 | ||
|
|
6f7fe4b481 | ||
|
|
66ebe6e690 | ||
|
|
a9cd67e0ce | ||
|
|
994a470fbf | ||
|
|
0ce0684dae | ||
|
|
377eb4782a | ||
|
|
f1a79e6b9f | ||
|
|
007a1e4659 | ||
|
|
fcb873b6dd | ||
|
|
a66d1ad855 | ||
|
|
76a5950f19 | ||
|
|
b7a91bdb03 | ||
|
|
e4bbc5c50b | ||
|
|
b481ccd749 | ||
|
|
e7b9e55599 | ||
|
|
05eaa7135f | ||
|
|
d063b319e8 | ||
|
|
be4fd56660 | ||
|
|
a406a3c00b | ||
|
|
c7295da5eb | ||
|
|
505f561e1c | ||
|
|
7bd8477fa1 | ||
|
|
36ef15940e | ||
|
|
f2ba7aefa6 | ||
|
|
73b58b0e87 | ||
|
|
6ce4f096b2 | ||
|
|
3e7ece7f5f | ||
|
|
48a219473e | ||
|
|
887ffd102f | ||
|
|
b1a719dd4c | ||
|
|
b4efe8f374 | ||
|
|
03f844d4be | ||
|
|
a212589865 | ||
|
|
29dfc5bd3c | ||
|
|
a6ac06c47a | ||
|
|
4d914db1db | ||
|
|
68572f106d | ||
|
|
c5ca4db94e | ||
|
|
3980f08cc5 | ||
|
|
f93fa4b613 | ||
|
|
06f2dba92c | ||
|
|
30a14741c9 | ||
|
|
2f39b688f4 | ||
|
|
724a2ef83b | ||
|
|
f7e0e46143 | ||
|
|
83acb47295 | ||
|
|
e5282caea5 | ||
|
|
6a481eed36 | ||
|
|
e145f903de | ||
|
|
2afd1c8663 | ||
|
|
948d02055d | ||
|
|
e2b4c0787a | ||
|
|
2d21e59b54 | ||
|
|
00ccafb90d | ||
|
|
b82e02b5ed | ||
|
|
096550f163 | ||
|
|
81e5963a5d | ||
|
|
14569e4fae | ||
|
|
6cc32a56b9 | ||
|
|
ebdb86c460 | ||
|
|
400c9d6a2d | ||
|
|
e9a1b06746 | ||
|
|
4f3aaa1ede | ||
|
|
187258cc3a | ||
|
|
dfbcb1566b | ||
|
|
e3b0a70eb9 | ||
|
|
790a40ec99 | ||
|
|
a824bec9e1 | ||
|
|
10db0c3c66 | ||
|
|
12620b6152 | ||
|
|
2294283506 | ||
|
|
cebcf6a4fc | ||
|
|
a79a78b6e6 | ||
|
|
c6ad744ce2 | ||
|
|
b430b3c8df | ||
|
|
0b316a8c5e | ||
|
|
b8e93e6099 | ||
|
|
a84a88bf09 | ||
|
|
02d54dd187 | ||
|
|
fb054c7f8d | ||
|
|
77da29b4f7 | ||
|
|
828a9a8c51 | ||
|
|
c680947db5 | ||
|
|
5348f4eafe | ||
|
|
7781498181 | ||
|
|
b8ce139b8a | ||
|
|
75911b6c64 | ||
|
|
bf0d95145d | ||
|
|
4326d560e9 | ||
|
|
65fa6f2f00 | ||
|
|
124629e1d9 | ||
|
|
557fade4a7 | ||
|
|
98a65b5d1d | ||
|
|
caaa35e5a7 | ||
|
|
a7459489ff | ||
|
|
87e59ff876 | ||
|
|
9d87c913e7 | ||
|
|
0e8c010645 | ||
|
|
470d01a508 | ||
|
|
c16b9ed25b | ||
|
|
d498199e8a | ||
|
|
013687dccd | ||
|
|
baf25ca7a7 | ||
|
|
6c28bd884b | ||
|
|
510091f082 | ||
|
|
7db44c113c | ||
|
|
6cbf4306e7 | ||
|
|
777386ea67 | ||
|
|
95e5e90791 | ||
|
|
a86868526e | ||
|
|
f1ab6e2533 | ||
|
|
9f516a8ccc | ||
|
|
e07af68018 | ||
|
|
a37d9a2d8e | ||
|
|
57811b5371 | ||
|
|
7ff9ba4fe6 | ||
|
|
fad34bdbc3 | ||
|
|
22b41d892a | ||
|
|
7a97c7575d | ||
|
|
b0e175ad3d | ||
|
|
0de60aa6aa | ||
|
|
933e10d8a0 | ||
|
|
2efac3d949 | ||
|
|
c33841329d | ||
|
|
f37800560f | ||
|
|
60e61a0627 | ||
|
|
260dbeb3d2 | ||
|
|
70f495b4e1 | ||
|
|
663db8f978 | ||
|
|
c412739040 | ||
|
|
8b13d71fcf | ||
|
|
1b129b289c | ||
|
|
a89ceb96b9 | ||
|
|
9af5f9f094 | ||
|
|
6776c2e536 | ||
|
|
4c3b4219fe | ||
|
|
a09806bb98 | ||
|
|
e175c8cc4d | ||
|
|
a53faf4565 | ||
|
|
dc653ac46c | ||
|
|
c544777d37 | ||
|
|
93a37df90a | ||
|
|
1da02cca4c | ||
|
|
4b1d777ad4 | ||
|
|
fb0916be0f | ||
|
|
806083cb25 | ||
|
|
5ba74e30b8 | ||
|
|
c39e08cb2a | ||
|
|
e4653be9a1 | ||
|
|
cd5765be1e | ||
|
|
c481b06451 | ||
|
|
91ba4618e7 | ||
|
|
fdc5521389 | ||
|
|
e88c915206 | ||
|
|
1e60698053 | ||
|
|
5702bd7ee8 | ||
|
|
8eef3eb582 | ||
|
|
31db353173 | ||
|
|
2c4a0dd998 | ||
|
|
7d7e41dacc | ||
|
|
453a53b372 | ||
|
|
ef68d18f64 | ||
|
|
ded1d2343f | ||
|
|
e6241a2f73 | ||
|
|
467254ec66 | ||
|
|
135e137921 | ||
|
|
e13a5b57d4 | ||
|
|
f1c00cdd18 | ||
|
|
8c3de351b0 | ||
|
|
0bcdb7eb70 | ||
|
|
a92b71fffc | ||
|
|
89960ab715 | ||
|
|
2a369803ae | ||
|
|
b0134a377e | ||
|
|
502c650cd9 | ||
|
|
a1bf8d2229 | ||
|
|
25b743bdec | ||
|
|
dbf7db02a2 | ||
|
|
8c998659c6 | ||
|
|
4e23b3dff5 | ||
|
|
159d3c4c6c | ||
|
|
612b5ae0bc | ||
|
|
60cbe9c1d4 | ||
|
|
4dadd29727 | ||
|
|
e4610b9baa | ||
|
|
926a0f2437 | ||
|
|
9325ec681e | ||
|
|
af383e6c39 | ||
|
|
b000691ab9 | ||
|
|
22812a0aae | ||
|
|
dda7ebfe0d | ||
|
|
9a211af659 | ||
|
|
82459a2802 | ||
|
|
1774fb2d02 | ||
|
|
f0081c7697 | ||
|
|
1e53bedca5 | ||
|
|
cf1c7e7378 | ||
|
|
5c3b569e97 | ||
|
|
cb29dcc238 | ||
|
|
d48b3f1e9a | ||
|
|
a4d60e7bd6 | ||
|
|
1a6e2509c7 | ||
|
|
8159b749f4 | ||
|
|
bec11c2939 | ||
|
|
8a189b6778 | ||
|
|
93c6845a6d | ||
|
|
b659c805fc | ||
|
|
15eaf8dc84 | ||
|
|
cafe89047c | ||
|
|
b5705ff47a | ||
|
|
1b07b25ad2 | ||
|
|
a46163bcd7 | ||
|
|
6531b1ebbc | ||
|
|
dc7bbdce11 | ||
|
|
a29cbc1112 | ||
|
|
afc2099865 | ||
|
|
7d251444e6 | ||
|
|
1c2289dacd | ||
|
|
044ac5d5d3 | ||
|
|
38167ed273 | ||
|
|
e15ffbc856 | ||
|
|
6cf2716615 | ||
|
|
0468b315d4 | ||
|
|
de66c74a91 | ||
|
|
7db73cd215 | ||
|
|
242eceb1c6 | ||
|
|
c2b84db5a2 | ||
|
|
487bee35ab | ||
|
|
9fabeb77bc | ||
|
|
bfea2dec4d | ||
|
|
2ed07850c6 | ||
|
|
b72d36d96f | ||
|
|
e3ff048ff6 | ||
|
|
ceef43681d | ||
|
|
3ec00676e4 | ||
|
|
e6575fb1db | ||
|
|
fa98d733d6 | ||
|
|
2981a10e62 | ||
|
|
551c06f885 | ||
|
|
a1c59071a1 | ||
|
|
13af443057 | ||
|
|
b8e2b0d0f9 | ||
|
|
53cd776bf6 | ||
|
|
180bba8767 | ||
|
|
377cf1662e | ||
|
|
420c747551 | ||
|
|
7c5b4a87f2 | ||
|
|
7ea241b412 | ||
|
|
1547d4ee2f | ||
|
|
3dde4113e7 | ||
|
|
205e6ef18f | ||
|
|
d53830076b | ||
|
|
296a01b7bd | ||
|
|
f47fdd63f7 | ||
|
|
b0b5f5035a | ||
|
|
629ece6e41 | ||
|
|
4c79263dcf | ||
|
|
856b6201dc | ||
|
|
f2160b1479 | ||
|
|
535f6a13b3 | ||
|
|
2ab760e456 | ||
|
|
8b75fbc1e6 | ||
|
|
82f410e955 | ||
|
|
68a19bd39f | ||
|
|
48689622b4 | ||
|
|
acc2075986 | ||
|
|
1984ae1583 | ||
|
|
427f309aea | ||
|
|
84482ad30d | ||
|
|
09b67e9440 | ||
|
|
80cf74d85f | ||
|
|
17e055a00e | ||
|
|
a8d8c9d24e | ||
|
|
99a59763f1 | ||
|
|
0fa3a329e8 | ||
|
|
5fbe532ec5 | ||
|
|
5f3de889d7 | ||
|
|
a8db14196a | ||
|
|
03b10d64a8 | ||
|
|
86892d87e9 | ||
|
|
41218272c4 | ||
|
|
8b5514fa9f | ||
|
|
f14de56712 | ||
|
|
ecc5c9865b | ||
|
|
929a56a6e8 | ||
|
|
4416df8c39 | ||
|
|
fc80610663 | ||
|
|
cb03bfcb80 | ||
|
|
35ed10e252 | ||
|
|
41fc1621b1 | ||
|
|
9fefaef31e | ||
|
|
689a942f19 | ||
|
|
cb9654f1f4 | ||
|
|
a8f8cef484 | ||
|
|
6cf51c3222 | ||
|
|
0d8ae0cabe | ||
|
|
49d6f93d8b | ||
|
|
5173d709e0 | ||
|
|
778c3ab25c | ||
|
|
aa17d9ac9a | ||
|
|
ffe1d9485e | ||
|
|
71abebe837 | ||
|
|
ca07b64af0 | ||
|
|
2fde2ce581 | ||
|
|
cb0da2ca5e | ||
|
|
c0422839b9 | ||
|
|
862b884f02 | ||
|
|
708e745cfd | ||
|
|
bb882a1239 | ||
|
|
6b2bf2fa8e | ||
|
|
2640b43355 | ||
|
|
d201e9b5c5 | ||
|
|
8f0f79506c | ||
|
|
121d2f92cb | ||
|
|
87e641aeda | ||
|
|
27403e2fef | ||
|
|
b5ceef5e68 | ||
|
|
5d68470c95 | ||
|
|
e176b4d8b6 | ||
|
|
218821f694 | ||
|
|
a8f4a61dc2 | ||
|
|
9221604424 | ||
|
|
5bddbd0ca9 | ||
|
|
f8dde93e05 | ||
|
|
489b562232 | ||
|
|
294a0dde63 | ||
|
|
53fbb98d4f | ||
|
|
8a2c08a0c1 | ||
|
|
b15b40ea10 | ||
|
|
0c865f540f | ||
|
|
ef4a92859c | ||
|
|
2a7b06f648 | ||
|
|
6c2ca22b3f | ||
|
|
592690f8f2 | ||
|
|
1eb87e7c73 | ||
|
|
a0e40c1fc1 | ||
|
|
2c920ae1df | ||
|
|
bbde3b36bf | ||
|
|
88a016c516 | ||
|
|
22d4058564 | ||
|
|
79e6c529ea | ||
|
|
7b22b8cd92 | ||
|
|
bc2ae82e81 | ||
|
|
764f4037b0 | ||
|
|
a60454a786 | ||
|
|
d136ad3e57 | ||
|
|
739588f9c3 | ||
|
|
505de4703b | ||
|
|
236a1f2a2d | ||
|
|
91efc5ad87 | ||
|
|
123c816048 | ||
|
|
fab6d05157 | ||
|
|
3240464c7c | ||
|
|
a2ffd27b7c | ||
|
|
af6c921757 | ||
|
|
180e2188ba | ||
|
|
23fbd5919f | ||
|
|
8aec98017a | ||
|
|
9b4fe7d92d | ||
|
|
99f11a01fc | ||
|
|
b3eacb19f6 | ||
|
|
f12840a72e | ||
|
|
f472bc563d | ||
|
|
3e05a5780d | ||
|
|
2454f8d269 | ||
|
|
b4a913e339 | ||
|
|
b82aef65e5 | ||
|
|
3730ce404f | ||
|
|
d7748704d7 | ||
|
|
1690f5475d | ||
|
|
a644bd2b03 | ||
|
|
62ca2e0227 | ||
|
|
d56289f897 | ||
|
|
aa02e72829 | ||
|
|
a878570a8d | ||
|
|
54352225f1 | ||
|
|
0b7d4c8c1e | ||
|
|
2091bf2144 | ||
|
|
0fec7b2599 | ||
|
|
74d314558c | ||
|
|
4fb45c4783 | ||
|
|
6816ecb3ea | ||
|
|
6766825159 | ||
|
|
3e63d6ca5d | ||
|
|
6ca9596807 | ||
|
|
5695fc84e1 | ||
|
|
2aea6362db | ||
|
|
bb70329c25 | ||
|
|
75bc07dc42 | ||
|
|
bac27f1ce3 | ||
|
|
787591dd79 | ||
|
|
c7c353df05 | ||
|
|
8470a9eda6 | ||
|
|
c5adb85741 | ||
|
|
2f9619f02a | ||
|
|
11cab90ce2 | ||
|
|
9ae48c2d7d | ||
|
|
00fc8205da | ||
|
|
62e85640da | ||
|
|
1b99b2a25d | ||
|
|
605ad52197 | ||
|
|
af80c5e018 | ||
|
|
18ac42b2e4 | ||
|
|
9ea57fcc30 | ||
|
|
7c27474164 | ||
|
|
afdee14332 | ||
|
|
7f5f12d37a | ||
|
|
cea0df71f8 | ||
|
|
aef484d5fc | ||
|
|
dacc051a57 | ||
|
|
e111f530c3 | ||
|
|
c00ca055bc | ||
|
|
305589cd01 | ||
|
|
6610244275 | ||
|
|
e462e64d42 | ||
|
|
39521df546 | ||
|
|
6dd8a1525c | ||
|
|
fca7a8fa47 | ||
|
|
1175179da1 | ||
|
|
06ab581edb | ||
|
|
dbcecbd3b8 | ||
|
|
4205c0a38d | ||
|
|
a76904c314 | ||
|
|
529ca14534 | ||
|
|
7423077f95 | ||
|
|
f116ee7802 | ||
|
|
09cf8c001e | ||
|
|
cfe0e18e4e | ||
|
|
2caad4a27b | ||
|
|
b5e7938ebe | ||
|
|
bd3e280fe5 | ||
|
|
39164d1438 | ||
|
|
a9c068ae3b | ||
|
|
6c7856549b | ||
|
|
d85cbc7b61 | ||
|
|
d8cbac4576 | ||
|
|
c0874a000e | ||
|
|
e317a39b2d | ||
|
|
61d4bd8adf | ||
|
|
a8deedaa66 | ||
|
|
15790ef4b4 | ||
|
|
8cf618ea75 | ||
|
|
5a81c9ecf0 | ||
|
|
4ccc2b3cfc | ||
|
|
ff8845de52 | ||
|
|
e4d4a2d8eb | ||
|
|
5a2a23cc2d | ||
|
|
8a233ddfbb | ||
|
|
2b40dc133d | ||
|
|
b26263c62d | ||
|
|
2df317eb49 | ||
|
|
5eef0e61ba | ||
|
|
021558d6dd | ||
|
|
7a6cab8381 | ||
|
|
1fcb70e553 | ||
|
|
712bbc9085 | ||
|
|
7b2370d608 | ||
|
|
98f398c99a | ||
|
|
e5efd5bf69 | ||
|
|
9d504a9e19 | ||
|
|
e96e09d112 | ||
|
|
28a6ec8065 | ||
|
|
875560b8dc | ||
|
|
fa360360cb | ||
|
|
e543b5228c | ||
|
|
63ea6cd15a | ||
|
|
79a773d25c | ||
|
|
dcc537e040 | ||
|
|
37488d0f7e | ||
|
|
aa645019e9 | ||
|
|
6179ec5319 | ||
|
|
331f91ba43 | ||
|
|
a50203dfec | ||
|
|
b7eab24f14 | ||
|
|
d824ffd02b | ||
|
|
238c6f7c88 | ||
|
|
0dd244fb0c | ||
|
|
61a8afa06a | ||
|
|
ed49eadb6a | ||
|
|
ecf19f8af4 | ||
|
|
9d5eb462c9 | ||
|
|
1088c5fa57 | ||
|
|
ad2bd3db0f | ||
|
|
abbcf855c4 | ||
|
|
83e648b7d6 | ||
|
|
89d049ff73 | ||
|
|
ac3a2bce72 | ||
|
|
ad20c2d242 | ||
|
|
6c9aa9527d | ||
|
|
7ad1e2be73 | ||
|
|
604f038cfb | ||
|
|
b185b1a4d9 | ||
|
|
89a65000a5 | ||
|
|
9c83903c2a | ||
|
|
68af57b759 | ||
|
|
9c4b4abb50 | ||
|
|
233ffb3b10 | ||
|
|
34e2bac4d0 | ||
|
|
6d4c38a3c8 | ||
|
|
b6ec5707e8 | ||
|
|
68d3b7b20c | ||
|
|
b84b36d885 | ||
|
|
f43e375d62 | ||
|
|
ab67fa2c15 | ||
|
|
7aff56c284 | ||
|
|
c13dc3a829 | ||
|
|
baf89c9d63 | ||
|
|
a8b4d21a65 | ||
|
|
6c20288ff1 | ||
|
|
935d4f3bda |
8
.cvsignore
Normal file
8
.cvsignore
Normal file
@@ -0,0 +1,8 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
SimGear.spec
|
||||
aclocal.m4
|
||||
config.cache
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
481
COPYING
Normal file
481
COPYING
Normal file
@@ -0,0 +1,481 @@
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is
|
||||
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some
|
||||
specially designated Free Software Foundation software, and to any
|
||||
other libraries whose authors decide to use it. You can use it for
|
||||
your libraries, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if
|
||||
you distribute copies of the library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link a program with the library, you must provide
|
||||
complete object files to the recipients so that they can relink them
|
||||
with the library, after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright
|
||||
the library, and (2) offer you this license which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
library. If the library is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original
|
||||
version, so that any problems introduced by others will not reflect on
|
||||
the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that companies distributing free
|
||||
software will individually obtain patent licenses, thus in effect
|
||||
transforming the program into proprietary software. To prevent this,
|
||||
we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary
|
||||
GNU General Public License, which was designed for utility programs. This
|
||||
license, the GNU Library General Public License, applies to certain
|
||||
designated libraries. This license is quite different from the ordinary
|
||||
one; be sure to read it in full, and don't assume that anything in it is
|
||||
the same as in the ordinary license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that
|
||||
they blur the distinction we usually make between modifying or adding to a
|
||||
program and simply using it. Linking a program with a library, without
|
||||
changing the library, is in some sense simply using the library, and is
|
||||
analogous to running a utility program or application program. However, in
|
||||
a textual and legal sense, the linked executable is a combined work, a
|
||||
derivative of the original library, and the ordinary General Public License
|
||||
treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General
|
||||
Public License for libraries did not effectively promote software
|
||||
sharing, because most developers did not use the libraries. We
|
||||
concluded that weaker conditions might promote sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the
|
||||
users of those programs of all benefit from the free status of the
|
||||
libraries themselves. This Library General Public License is intended to
|
||||
permit developers of non-free programs to use free libraries, while
|
||||
preserving your freedom as a user of such programs to change the free
|
||||
libraries that are incorporated in them. (We have not seen how to achieve
|
||||
this as regards changes in header files, but we have achieved it as regards
|
||||
changes in the actual functions of the Library.) The hope is that this
|
||||
will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, while the latter only
|
||||
works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary
|
||||
General Public License rather than by this special one.
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which
|
||||
contains a notice placed by the copyright holder or other authorized
|
||||
party saying it may be distributed under the terms of this Library
|
||||
General Public License (also called "this License"). Each licensee is
|
||||
addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the source code distributed need not include anything that is normally
|
||||
distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Library General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
806
Doxyfile
Normal file
806
Doxyfile
Normal file
@@ -0,0 +1,806 @@
|
||||
# Doxyfile 1.2.6
|
||||
|
||||
# This file describes the settings to be used by doxygen for a project
|
||||
#
|
||||
# All text after a hash (#) is considered a comment and will be ignored
|
||||
# The format is:
|
||||
# TAG = value [value, ...]
|
||||
# For lists items can also be appended using:
|
||||
# TAG += value [value, ...]
|
||||
# Values that contain spaces should be placed between quotes (" ")
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# General configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
|
||||
# by quotes) that should identify the project.
|
||||
|
||||
PROJECT_NAME = SimGear
|
||||
|
||||
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = 0.0.19pre2
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# base path where the generated documentation will be put.
|
||||
# If a relative path is entered, it will be relative to the location
|
||||
# where doxygen was started. If left blank the current directory will be used.
|
||||
|
||||
OUTPUT_DIRECTORY = ../doxy
|
||||
|
||||
# The OUTPUT_LANGUAGE tag is used to specify the language in which all
|
||||
# documentation generated by doxygen is written. Doxygen will use this
|
||||
# information to generate all constant output in the proper language.
|
||||
# The default language is English, other supported languages are:
|
||||
# Dutch, French, Italian, Czech, Swedish, German, Finnish, Japanese,
|
||||
# Korean, Hungarian, Norwegian, Spanish, Romanian, Russian, Croatian,
|
||||
# Polish, Portuguese and Slovene.
|
||||
|
||||
OUTPUT_LANGUAGE = English
|
||||
|
||||
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
|
||||
# documentation are documented, even if no documentation was available.
|
||||
# Private class members and static file members will be hidden unless
|
||||
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
|
||||
|
||||
EXTRACT_ALL = NO
|
||||
|
||||
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
|
||||
# will be included in the documentation.
|
||||
|
||||
EXTRACT_PRIVATE = NO
|
||||
|
||||
# If the EXTRACT_STATIC tag is set to YES all static members of a file
|
||||
# will be included in the documentation.
|
||||
|
||||
EXTRACT_STATIC = NO
|
||||
|
||||
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
|
||||
# undocumented members of documented classes, files or namespaces.
|
||||
# If set to NO (the default) these members will be included in the
|
||||
# various overviews, but no documentation section is generated.
|
||||
# This option has no effect if EXTRACT_ALL is enabled.
|
||||
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
|
||||
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
|
||||
# undocumented classes that are normally visible in the class hierarchy.
|
||||
# If set to NO (the default) these class will be included in the various
|
||||
# overviews. This option has no effect if EXTRACT_ALL is enabled.
|
||||
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
|
||||
# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
|
||||
# include brief member descriptions after the members that are listed in
|
||||
# the file and class documentation (similar to JavaDoc).
|
||||
# Set to NO to disable this.
|
||||
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
|
||||
# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
|
||||
# the brief description of a member or function before the detailed description.
|
||||
# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
|
||||
# brief descriptions will be completely suppressed.
|
||||
|
||||
REPEAT_BRIEF = YES
|
||||
|
||||
# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
|
||||
# Doxygen will generate a detailed section even if there is only a brief
|
||||
# description.
|
||||
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
|
||||
# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
|
||||
# path before files name in the file list and in the header files. If set
|
||||
# to NO the shortest path that makes the file name unique will be used.
|
||||
|
||||
FULL_PATH_NAMES = NO
|
||||
|
||||
# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
|
||||
# can be used to strip a user defined part of the path. Stripping is
|
||||
# only done if one of the specified strings matches the left-hand part of
|
||||
# the path. It is allowed to use relative paths in the argument list.
|
||||
|
||||
STRIP_FROM_PATH =
|
||||
|
||||
# The INTERNAL_DOCS tag determines if documentation
|
||||
# that is typed after a \internal command is included. If the tag is set
|
||||
# to NO (the default) then the documentation will be excluded.
|
||||
# Set it to YES to include the internal documentation.
|
||||
|
||||
INTERNAL_DOCS = NO
|
||||
|
||||
# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
|
||||
# generate a class diagram (in Html and LaTeX) for classes with base or
|
||||
# super classes. Setting the tag to NO turns the diagrams off.
|
||||
|
||||
CLASS_DIAGRAMS = YES
|
||||
|
||||
# If the SOURCE_BROWSER tag is set to YES then a list of source files will
|
||||
# be generated. Documented entities will be cross-referenced with these sources.
|
||||
|
||||
SOURCE_BROWSER = YES
|
||||
|
||||
# Setting the INLINE_SOURCES tag to YES will include the body
|
||||
# of functions and classes directly in the documentation.
|
||||
|
||||
INLINE_SOURCES = NO
|
||||
|
||||
# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
|
||||
# doxygen to hide any special comment blocks from generated source code
|
||||
# fragments. Normal C and C++ comments will always remain visible.
|
||||
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
|
||||
# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
|
||||
# file names in lower case letters. If set to YES upper case letters are also
|
||||
# allowed. This is useful if you have classes or files whose names only differ
|
||||
# in case and if your file system supports case sensitive file names. Windows
|
||||
# users are adviced to set this option to NO.
|
||||
|
||||
CASE_SENSE_NAMES = YES
|
||||
|
||||
# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
|
||||
# will show members with their full class and namespace scopes in the
|
||||
# documentation. If set to YES the scope will be hidden.
|
||||
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
|
||||
# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
|
||||
# will generate a verbatim copy of the header file for each class for
|
||||
# which an include is specified. Set to NO to disable this.
|
||||
|
||||
VERBATIM_HEADERS = YES
|
||||
|
||||
# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
|
||||
# will put list of the files that are included by a file in the documentation
|
||||
# of that file.
|
||||
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
|
||||
# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
|
||||
# will interpret the first line (until the first dot) of a JavaDoc-style
|
||||
# comment as the brief description. If set to NO, the JavaDoc
|
||||
# comments will behave just like the Qt-style comments (thus requiring an
|
||||
# explict @brief command for a brief description.
|
||||
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
|
||||
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
|
||||
# member inherits the documentation from any documented member that it
|
||||
# reimplements.
|
||||
|
||||
INHERIT_DOCS = YES
|
||||
|
||||
# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
|
||||
# is inserted in the documentation for inline members.
|
||||
|
||||
INLINE_INFO = YES
|
||||
|
||||
# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
|
||||
# will sort the (detailed) documentation of file and class members
|
||||
# alphabetically by member name. If set to NO the members will appear in
|
||||
# declaration order.
|
||||
|
||||
SORT_MEMBER_DOCS = YES
|
||||
|
||||
# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
|
||||
# tag is set to YES, then doxygen will reuse the documentation of the first
|
||||
# member in the group (if any) for the other members of the group. By default
|
||||
# all members of a group must be documented explicitly.
|
||||
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
|
||||
# The TAB_SIZE tag can be used to set the number of spaces in a tab.
|
||||
# Doxygen uses this value to replace tabs by spaces in code fragments.
|
||||
|
||||
TAB_SIZE = 8
|
||||
|
||||
# The ENABLE_SECTIONS tag can be used to enable conditional
|
||||
# documentation sections, marked by \if sectionname ... \endif.
|
||||
|
||||
ENABLED_SECTIONS =
|
||||
|
||||
# The GENERATE_TODOLIST tag can be used to enable (YES) or
|
||||
# disable (NO) the todo list. This list is created by putting \todo
|
||||
# commands in the documentation.
|
||||
|
||||
GENERATE_TODOLIST = YES
|
||||
|
||||
# The GENERATE_TESTLIST tag can be used to enable (YES) or
|
||||
# disable (NO) the test list. This list is created by putting \test
|
||||
# commands in the documentation.
|
||||
|
||||
GENERATE_TESTLIST = YES
|
||||
|
||||
# The GENERATE_BUGLIST tag can be used to enable (YES) or
|
||||
# disable (NO) the bug list. This list is created by putting \bug
|
||||
# commands in the documentation.
|
||||
|
||||
GENERATE_BUGLIST = YES
|
||||
|
||||
# This tag can be used to specify a number of aliases that acts
|
||||
# as commands in the documentation. An alias has the form "name=value".
|
||||
# For example adding "sideeffect=\par Side Effects:\n" will allow you to
|
||||
# put the command \sideeffect (or @sideeffect) in the documentation, which
|
||||
# will result in a user defined paragraph with heading "Side Effects:".
|
||||
# You can put \n's in the value part of an alias to insert newlines.
|
||||
|
||||
ALIASES =
|
||||
|
||||
# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
|
||||
# the initial value of a variable or define consist of for it to appear in
|
||||
# the documentation. If the initializer consists of more lines than specified
|
||||
# here it will be hidden. Use a value of 0 to hide initializers completely.
|
||||
# The appearance of the initializer of individual variables and defines in the
|
||||
# documentation can be controlled using \showinitializer or \hideinitializer
|
||||
# command in the documentation regardless of this setting.
|
||||
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
|
||||
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
|
||||
# only. Doxygen will then generate output that is more tailored for C.
|
||||
# For instance some of the names that are used will be different. The list
|
||||
# of all members will be omitted, etc.
|
||||
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
|
||||
# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
|
||||
# at the bottom of the documentation of classes and structs. If set to YES the
|
||||
# list will mention the files that were used to generate the documentation.
|
||||
|
||||
SHOW_USED_FILES = YES
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# The QUIET tag can be used to turn on/off the messages that are generated
|
||||
# by doxygen. Possible values are YES and NO. If left blank NO is used.
|
||||
|
||||
QUIET = NO
|
||||
|
||||
# The WARNINGS tag can be used to turn on/off the warning messages that are
|
||||
# generated by doxygen. Possible values are YES and NO. If left blank
|
||||
# NO is used.
|
||||
|
||||
WARNINGS = YES
|
||||
|
||||
# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
|
||||
# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
|
||||
# automatically be disabled.
|
||||
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
|
||||
# The WARN_FORMAT tag determines the format of the warning messages that
|
||||
# doxygen can produce. The string should contain the $file, $line, and $text
|
||||
# tags, which will be replaced by the file and line number from which the
|
||||
# warning originated and the warning text.
|
||||
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
|
||||
# The WARN_LOGFILE tag can be used to specify a file to which warning
|
||||
# and error messages should be written. If left blank the output is written
|
||||
# to stderr.
|
||||
|
||||
WARN_LOGFILE =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# The INPUT tag can be used to specify the files and/or directories that contain
|
||||
# documented source files. You may enter file names like "myfile.cpp" or
|
||||
# directories like "/usr/src/myproject". Separate the files or directories
|
||||
# with spaces.
|
||||
|
||||
INPUT = \
|
||||
simgear/bucket \
|
||||
simgear/compiler.h \
|
||||
simgear/constants.h \
|
||||
simgear/debug \
|
||||
simgear/ephemeris \
|
||||
simgear/io \
|
||||
simgear/magvar \
|
||||
simgear/math \
|
||||
simgear/misc \
|
||||
simgear/route \
|
||||
simgear/screen \
|
||||
simgear/serial \
|
||||
simgear/sg_inlines.h \
|
||||
simgear/sg_traits.hxx \
|
||||
simgear/sg_zlib.h \
|
||||
simgear/sky \
|
||||
simgear/threads \
|
||||
simgear/timing \
|
||||
simgear/xml
|
||||
|
||||
# If the value of the INPUT tag contains directories, you can use the
|
||||
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
|
||||
# and *.h) to filter out the source-files in the directories. If left
|
||||
# blank all files are included.
|
||||
|
||||
FILE_PATTERNS = *.h *.hxx *.c *.cxx *.cpp
|
||||
|
||||
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
|
||||
# should be searched for input files as well. Possible values are YES and NO.
|
||||
# If left blank NO is used.
|
||||
|
||||
RECURSIVE = YES
|
||||
|
||||
# The EXCLUDE tag can be used to specify files and/or directories that should
|
||||
# excluded from the INPUT source files. This way you can easily exclude a
|
||||
# subdirectory from a directory tree whose root is specified with the INPUT tag.
|
||||
|
||||
EXCLUDE = simgear/metakit simgear/zlib
|
||||
|
||||
# If the value of the INPUT tag contains directories, you can use the
|
||||
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
|
||||
# certain files from those directories.
|
||||
|
||||
EXCLUDE_PATTERNS =
|
||||
|
||||
# The EXAMPLE_PATH tag can be used to specify one or more files or
|
||||
# directories that contain example code fragments that are included (see
|
||||
# the \include command).
|
||||
|
||||
EXAMPLE_PATH =
|
||||
|
||||
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
|
||||
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
|
||||
# and *.h) to filter out the source-files in the directories. If left
|
||||
# blank all files are included.
|
||||
|
||||
EXAMPLE_PATTERNS =
|
||||
|
||||
# The IMAGE_PATH tag can be used to specify one or more files or
|
||||
# directories that contain image that are included in the documentation (see
|
||||
# the \image command).
|
||||
|
||||
IMAGE_PATH =
|
||||
|
||||
# The INPUT_FILTER tag can be used to specify a program that doxygen should
|
||||
# invoke to filter for each input file. Doxygen will invoke the filter program
|
||||
# by executing (via popen()) the command <filter> <input-file>, where <filter>
|
||||
# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
|
||||
# input file. Doxygen will then use the output that the filter program writes
|
||||
# to standard output.
|
||||
|
||||
INPUT_FILTER =
|
||||
|
||||
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
|
||||
# INPUT_FILTER) will be used to filter the input files when producing source
|
||||
# files to browse.
|
||||
|
||||
FILTER_SOURCE_FILES = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
|
||||
# of all compounds will be generated. Enable this if the project
|
||||
# contains a lot of classes, structs, unions or interfaces.
|
||||
|
||||
ALPHABETICAL_INDEX = NO
|
||||
|
||||
# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
|
||||
# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
|
||||
# in which this list will be split (can be a number in the range [1..20])
|
||||
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
|
||||
# In case all classes in a project start with a common prefix, all
|
||||
# classes will be put under the same header in the alphabetical index.
|
||||
# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
|
||||
# should be ignored while generating the index headers.
|
||||
|
||||
IGNORE_PREFIX =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
|
||||
# generate HTML output.
|
||||
|
||||
GENERATE_HTML = YES
|
||||
|
||||
# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
|
||||
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
|
||||
# put in front of it. If left blank `html' will be used as the default path.
|
||||
|
||||
HTML_OUTPUT = html
|
||||
|
||||
# The HTML_HEADER tag can be used to specify a personal HTML header for
|
||||
# each generated HTML page. If it is left blank doxygen will generate a
|
||||
# standard header.
|
||||
|
||||
HTML_HEADER =
|
||||
|
||||
# The HTML_FOOTER tag can be used to specify a personal HTML footer for
|
||||
# each generated HTML page. If it is left blank doxygen will generate a
|
||||
# standard footer.
|
||||
|
||||
HTML_FOOTER =
|
||||
|
||||
# The HTML_STYLESHEET tag can be used to specify a user defined cascading
|
||||
# style sheet that is used by each HTML page. It can be used to
|
||||
# fine-tune the look of the HTML output. If the tag is left blank doxygen
|
||||
# will generate a default style sheet
|
||||
|
||||
HTML_STYLESHEET =
|
||||
|
||||
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
|
||||
# files or namespaces will be aligned in HTML using tables. If set to
|
||||
# NO a bullet list will be used.
|
||||
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
|
||||
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
|
||||
# will be generated that can be used as input for tools like the
|
||||
# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
|
||||
# of the generated HTML documentation.
|
||||
|
||||
GENERATE_HTMLHELP = NO
|
||||
|
||||
# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
|
||||
# controls if a separate .chi index file is generated (YES) or that
|
||||
# it should be included in the master .chm file (NO).
|
||||
|
||||
GENERATE_CHI = NO
|
||||
|
||||
# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
|
||||
# controls whether a binary table of contents is generated (YES) or a
|
||||
# normal table of contents (NO) in the .chm file.
|
||||
|
||||
BINARY_TOC = NO
|
||||
|
||||
# The TOC_EXPAND flag can be set YES to add extra items for group members
|
||||
# to the contents of the Html help documentation and to the tree view.
|
||||
|
||||
TOC_EXPAND = NO
|
||||
|
||||
# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
|
||||
# top of each HTML page. The value NO (the default) enables the index and
|
||||
# the value YES disables it.
|
||||
|
||||
DISABLE_INDEX = NO
|
||||
|
||||
# This tag can be used to set the number of enum values (range [1..20])
|
||||
# that doxygen will group on one line in the generated HTML documentation.
|
||||
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
|
||||
# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
|
||||
# generated containing a tree-like index structure (just like the one that
|
||||
# is generated for HTML Help). For this to work a browser that supports
|
||||
# JavaScript and frames is required (for instance Netscape 4.0+
|
||||
# or Internet explorer 4.0+).
|
||||
|
||||
GENERATE_TREEVIEW = NO
|
||||
|
||||
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
|
||||
# used to set the initial width (in pixels) of the frame in which the tree
|
||||
# is shown.
|
||||
|
||||
TREEVIEW_WIDTH = 250
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
|
||||
# generate Latex output.
|
||||
|
||||
GENERATE_LATEX = YES
|
||||
|
||||
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
|
||||
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
|
||||
# put in front of it. If left blank `latex' will be used as the default path.
|
||||
|
||||
LATEX_OUTPUT = latex
|
||||
|
||||
# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
|
||||
# LaTeX documents. This may be useful for small projects and may help to
|
||||
# save some trees in general.
|
||||
|
||||
COMPACT_LATEX = NO
|
||||
|
||||
# The PAPER_TYPE tag can be used to set the paper type that is used
|
||||
# by the printer. Possible values are: a4, a4wide, letter, legal and
|
||||
# executive. If left blank a4wide will be used.
|
||||
|
||||
PAPER_TYPE = a4wide
|
||||
|
||||
# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
|
||||
# packages that should be included in the LaTeX output.
|
||||
|
||||
EXTRA_PACKAGES =
|
||||
|
||||
# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
|
||||
# the generated latex document. The header should contain everything until
|
||||
# the first chapter. If it is left blank doxygen will generate a
|
||||
# standard header. Notice: only use this tag if you know what you are doing!
|
||||
|
||||
LATEX_HEADER =
|
||||
|
||||
# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
|
||||
# is prepared for conversion to pdf (using ps2pdf). The pdf file will
|
||||
# contain links (just like the HTML output) instead of page references
|
||||
# This makes the output suitable for online browsing using a pdf viewer.
|
||||
|
||||
PDF_HYPERLINKS = NO
|
||||
|
||||
# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
|
||||
# plain latex in the generated Makefile. Set this option to YES to get a
|
||||
# higher quality PDF documentation.
|
||||
|
||||
USE_PDFLATEX = NO
|
||||
|
||||
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
|
||||
# command to the generated LaTeX files. This will instruct LaTeX to keep
|
||||
# running if errors occur, instead of asking the user for help.
|
||||
# This option is also used when generating formulas in HTML.
|
||||
|
||||
LATEX_BATCHMODE = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
|
||||
# The RTF output is optimised for Word 97 and may not look very pretty with
|
||||
# other RTF readers or editors.
|
||||
|
||||
GENERATE_RTF = YES
|
||||
|
||||
# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
|
||||
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
|
||||
# put in front of it. If left blank `rtf' will be used as the default path.
|
||||
|
||||
RTF_OUTPUT = rtf
|
||||
|
||||
# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
|
||||
# RTF documents. This may be useful for small projects and may help to
|
||||
# save some trees in general.
|
||||
|
||||
COMPACT_RTF = NO
|
||||
|
||||
# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
|
||||
# will contain hyperlink fields. The RTF file will
|
||||
# contain links (just like the HTML output) instead of page references.
|
||||
# This makes the output suitable for online browsing using a WORD or other.
|
||||
# programs which support those fields.
|
||||
# Note: wordpad (write) and others do not support links.
|
||||
|
||||
RTF_HYPERLINKS = NO
|
||||
|
||||
# Load stylesheet definitions from file. Syntax is similar to doxygen's
|
||||
# config file, i.e. a series of assigments. You only have to provide
|
||||
# replacements, missing definitions are set to their default value.
|
||||
|
||||
RTF_STYLESHEET_FILE =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
|
||||
# generate man pages
|
||||
|
||||
GENERATE_MAN = YES
|
||||
|
||||
# The MAN_OUTPUT tag is used to specify where the man pages will be put.
|
||||
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
|
||||
# put in front of it. If left blank `man' will be used as the default path.
|
||||
|
||||
MAN_OUTPUT = man
|
||||
|
||||
# The MAN_EXTENSION tag determines the extension that is added to
|
||||
# the generated man pages (default is the subroutine's section .3)
|
||||
|
||||
MAN_EXTENSION = .3
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
|
||||
# evaluate all C-preprocessor directives found in the sources and include
|
||||
# files.
|
||||
|
||||
ENABLE_PREPROCESSING = YES
|
||||
|
||||
# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
|
||||
# names in the source code. If set to NO (the default) only conditional
|
||||
# compilation will be performed. Macro expansion can be done in a controlled
|
||||
# way by setting EXPAND_ONLY_PREDEF to YES.
|
||||
|
||||
MACRO_EXPANSION = NO
|
||||
|
||||
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
|
||||
# then the macro expansion is limited to the macros specified with the
|
||||
# PREDEFINED and EXPAND_AS_PREDEFINED tags.
|
||||
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
|
||||
# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
|
||||
# in the INCLUDE_PATH (see below) will be search if a #include is found.
|
||||
|
||||
SEARCH_INCLUDES = YES
|
||||
|
||||
# The INCLUDE_PATH tag can be used to specify one or more directories that
|
||||
# contain include files that are not input files but should be processed by
|
||||
# the preprocessor.
|
||||
|
||||
INCLUDE_PATH =
|
||||
|
||||
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
|
||||
# patterns (like *.h and *.hpp) to filter out the header-files in the
|
||||
# directories. If left blank, the patterns specified with FILE_PATTERNS will
|
||||
# be used.
|
||||
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
|
||||
# The PREDEFINED tag can be used to specify one or more macro names that
|
||||
# are defined before the preprocessor is started (similar to the -D option of
|
||||
# gcc). The argument of the tag is a list of macros of the form: name
|
||||
# or name=definition (no spaces). If the definition and the = are
|
||||
# omitted =1 is assumed.
|
||||
|
||||
PREDEFINED =
|
||||
|
||||
# If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then
|
||||
# this tag can be used to specify a list of macro names that should be expanded.
|
||||
# The macro definition that is found in the sources will be used.
|
||||
# Use the PREDEFINED tag if you want to use a different macro definition.
|
||||
|
||||
EXPAND_AS_DEFINED =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::addtions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# The TAGFILES tag can be used to specify one or more tagfiles.
|
||||
|
||||
TAGFILES =
|
||||
|
||||
# When a file name is specified after GENERATE_TAGFILE, doxygen will create
|
||||
# a tag file that is based on the input files it reads.
|
||||
|
||||
GENERATE_TAGFILE =
|
||||
|
||||
# If the ALLEXTERNALS tag is set to YES all external classes will be listed
|
||||
# in the class index. If set to NO only the inherited external classes
|
||||
# will be listed.
|
||||
|
||||
ALLEXTERNALS = NO
|
||||
|
||||
# The PERL_PATH should be the absolute path and name of the perl script
|
||||
# interpreter (i.e. the result of `which perl').
|
||||
|
||||
PERL_PATH = /usr/bin/perl
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
|
||||
# available from the path. This tool is part of Graphviz, a graph visualization
|
||||
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
|
||||
# have no effect if this option is set to NO (the default)
|
||||
|
||||
HAVE_DOT = NO
|
||||
|
||||
# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
|
||||
# will generate a graph for each documented class showing the direct and
|
||||
# indirect inheritance relations. Setting this tag to YES will force the
|
||||
# the CLASS_DIAGRAMS tag to NO.
|
||||
|
||||
CLASS_GRAPH = YES
|
||||
|
||||
# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
|
||||
# will generate a graph for each documented class showing the direct and
|
||||
# indirect implementation dependencies (inheritance, containment, and
|
||||
# class references variables) of the class with other documented classes.
|
||||
|
||||
COLLABORATION_GRAPH = YES
|
||||
|
||||
# If the ENABLE_PREPROCESSING, INCLUDE_GRAPH, and HAVE_DOT tags are set to
|
||||
# YES then doxygen will generate a graph for each documented file showing
|
||||
# the direct and indirect include dependencies of the file with other
|
||||
# documented files.
|
||||
|
||||
INCLUDE_GRAPH = YES
|
||||
|
||||
# If the ENABLE_PREPROCESSING, INCLUDED_BY_GRAPH, and HAVE_DOT tags are set to
|
||||
# YES then doxygen will generate a graph for each documented header file showing
|
||||
# the documented files that directly or indirectly include this file
|
||||
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
|
||||
# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
|
||||
# will graphical hierarchy of all classes instead of a textual one.
|
||||
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
|
||||
# The tag DOT_PATH can be used to specify the path where the dot tool can be
|
||||
# found. If left blank, it is assumed the dot tool can be found on the path.
|
||||
|
||||
DOT_PATH =
|
||||
|
||||
# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
|
||||
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
|
||||
# this value, doxygen will try to truncate the graph, so that it fits within
|
||||
# the specified constraint. Beware that most browsers cannot cope with very
|
||||
# large images.
|
||||
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
|
||||
# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
|
||||
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
|
||||
# this value, doxygen will try to truncate the graph, so that it fits within
|
||||
# the specified constraint. Beware that most browsers cannot cope with very
|
||||
# large images.
|
||||
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
|
||||
# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
|
||||
# generate a legend page explaining the meaning of the various boxes and
|
||||
# arrows in the dot generated graphs.
|
||||
|
||||
GENERATE_LEGEND = YES
|
||||
|
||||
# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
|
||||
# remove the intermedate dot files that are used to generate
|
||||
# the various graphs.
|
||||
|
||||
DOT_CLEANUP = YES
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::addtions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# The SEARCHENGINE tag specifies whether or not a search engine should be
|
||||
# used. If set to NO the values of all tags below this one will be ignored.
|
||||
|
||||
SEARCHENGINE = NO
|
||||
|
||||
# The CGI_NAME tag should be the name of the CGI script that
|
||||
# starts the search engine (doxysearch) with the correct parameters.
|
||||
# A script with this name will be generated by doxygen.
|
||||
|
||||
CGI_NAME = search.cgi
|
||||
|
||||
# The CGI_URL tag should be the absolute URL to the directory where the
|
||||
# cgi binaries are located. See the documentation of your http daemon for
|
||||
# details.
|
||||
|
||||
CGI_URL =
|
||||
|
||||
# The DOC_URL tag should be the absolute URL to the directory where the
|
||||
# documentation is located. If left blank the absolute path to the
|
||||
# documentation, with file:// prepended to it, will be used.
|
||||
|
||||
DOC_URL =
|
||||
|
||||
# The DOC_ABSPATH tag should be the absolute path to the directory where the
|
||||
# documentation is located. If left blank the directory on the local machine
|
||||
# will be used.
|
||||
|
||||
DOC_ABSPATH =
|
||||
|
||||
# The BIN_ABSPATH tag must point to the directory where the doxysearch binary
|
||||
# is installed.
|
||||
|
||||
BIN_ABSPATH = /usr/local/bin/
|
||||
|
||||
# The EXT_DOC_PATHS tag can be used to specify one or more paths to
|
||||
# documentation generated for other projects. This allows doxysearch to search
|
||||
# the documentation for these projects as well.
|
||||
|
||||
EXT_DOC_PATHS =
|
||||
21
Makefile.am
Normal file
21
Makefile.am
Normal file
@@ -0,0 +1,21 @@
|
||||
EXTRA_DIST = \
|
||||
acinclude.m4 \
|
||||
autogen.sh \
|
||||
mksymlinks.sh \
|
||||
README.MSVC \
|
||||
README.metakit \
|
||||
README.zlib \
|
||||
SimGear.dsp \
|
||||
SimGear.dsw
|
||||
|
||||
SUBDIRS = src-libs simgear
|
||||
|
||||
dist-hook:
|
||||
(cd $(top_srcdir); $(HOME)/projects/FlightGear-0.7/admin/am2dsp.pl)
|
||||
|
||||
#
|
||||
# Rule to build RPM distribution package
|
||||
#
|
||||
rpm: dist
|
||||
rpm -ta $(PACKAGE)-$(VERSION).tar.gz
|
||||
|
||||
223
NEWS
Normal file
223
NEWS
Normal file
@@ -0,0 +1,223 @@
|
||||
New in 0.2.0
|
||||
* September 6, 2002
|
||||
|
||||
* Modernized the autoconf/make scripts, plus lots of tweaks and enhancements.
|
||||
* Removed efence support (in favor of valgrind.)
|
||||
|
||||
* Added a javascript interpreter.
|
||||
* SGSocket reimplimented on top of plib/net libs.
|
||||
* Added a new random number generation algorithm.
|
||||
* Total rewrite of the strutils package.
|
||||
|
||||
* Patch for the random number seed.
|
||||
* IA-64 w/ Intel compiler fixes.
|
||||
* MSVC/MINGW fixes.
|
||||
* Mac OS X fixes.
|
||||
* Irix fixes.
|
||||
* Code clean ups to remove warning messages.
|
||||
* Optimizations in sg_binobj to reduce the amout of memory copying
|
||||
needed when loading a binobj format file.
|
||||
* Fixed a couple places where variables could be used before they were
|
||||
initialized.
|
||||
* Various property manager fixes and improvements.
|
||||
* Fixes to cloud layer management code.
|
||||
* Made the sky dome more flexible to facilitate use in other applications.
|
||||
|
||||
|
||||
New in 0.0.18
|
||||
* April 20, 2002
|
||||
|
||||
* Created a src/libs subdirectory for several packages that need to be
|
||||
installed by the user but are used by many other packages and may already
|
||||
be installed. So we just bundle the source separately as a convenience
|
||||
if the user needs to build and install these.
|
||||
* Upgrade to zlib-1.1.4 (security fix)
|
||||
* Upgrade to metakit-2.4.2-32.tar.gz (latest upstream release)
|
||||
* Added support for point objects in the scenery file format.
|
||||
* Additions to the binary file format to make it *much* more flexible.
|
||||
For each major primative type: points, triangles, fans, and strips, you
|
||||
can specify an index list of vertices, normals, colors, and texture
|
||||
coordinates. You can skip any of these you like to save on space.
|
||||
* Added support for new file features in the binary -> ascii scenery file
|
||||
decoder.
|
||||
* Various code clean ups.
|
||||
* Separate XML I/O operations into a separate header file.
|
||||
* Major property manager rewrite, then lots of followup cleaning and
|
||||
improvements.
|
||||
|
||||
|
||||
New in 0.0.17 (final)
|
||||
* February 16, 2002
|
||||
|
||||
* Explicitely reset the glBlendFunc() after drawing the moon for the
|
||||
Voodoo2 linux driver since it seems to have a bug in glPopAttrib().
|
||||
|
||||
|
||||
New in 0.0.17pre2
|
||||
* February 13, 2002
|
||||
|
||||
* Replaced some cout's with SG_LOG's
|
||||
|
||||
|
||||
New in 0.0.17pre1
|
||||
* February 12, 2002
|
||||
|
||||
* Removed metakit and zlib from build process. Tarballs are still included
|
||||
for those who's systems don't provide these packages.
|
||||
* MSVC fixes.
|
||||
* IRIX fixes.
|
||||
* Mingwin fixes.
|
||||
* Mac OS X fixes.
|
||||
* FreeBSD fixes.
|
||||
* Added support for Intel's C++ compiler under Linux.
|
||||
* Attempt to build in support for various non-compatible automake/autoconf
|
||||
versions.
|
||||
* Fix for a problem that could lead to a bogus build for people with voodoo
|
||||
cards.
|
||||
* Added Norman's jpegfactory code which can create jpeg format screen shots
|
||||
of a live running application.
|
||||
* implemented set/get_log_classes and set/get_log_priority.
|
||||
* Socket library improvements.
|
||||
* Added a C++ exception abstraction.
|
||||
* Property manager fixes and improvements including node path caching
|
||||
and debug tracing of property reads/writes.
|
||||
* Updates/fixes to xml handling.
|
||||
|
||||
|
||||
New in 0.0.16
|
||||
* July 12, 2001
|
||||
* Various changes to the property manager implimentation to better support
|
||||
dumping out the desired portions of the property tree to file.
|
||||
* Don't compile the metakit demos by default (causes problems for Irix)'
|
||||
* Other various tweaks for Irix.
|
||||
* Added a virtual destructor to XMLVisitor to fix a warning message.
|
||||
* Check for valid hostname lookup in sg_socket.cxx
|
||||
* Add a function to return modified julian date without creating an
|
||||
entire SGTime class. This avoids an extraneous warning about not
|
||||
being able to find a timezone.
|
||||
* Created a mailing list for cvs commit messages.
|
||||
* Fixed a potential array under/over run bug in interpolator.cxx
|
||||
* Removed all references to SGValue from the property manager. Added
|
||||
support for an "archive" bit in the property manager to control
|
||||
which values get written out.
|
||||
* Added SGCommandState class so that commands can compile and save
|
||||
copies of their arguments for efficiency if they are called multiple
|
||||
times.
|
||||
* Added Brian Baul's "tr" tiled rendering low level support library.
|
||||
This along with some higher level code in flightgear allows us to do
|
||||
ultra-hires tiled screen dumps suitable for large format printers.
|
||||
(Norman Vine)
|
||||
|
||||
|
||||
New in 0.0.15
|
||||
* June 20, 2001
|
||||
* Various bug fixes, tweaks, and optimizations.
|
||||
* Added a command manager (analogous to the property manager)
|
||||
* Better Irix Mips support.
|
||||
* Various gcc-3.0 fixes.
|
||||
* Various MSVC fixes.
|
||||
* Added MSVC project files (automatically generated from the unix
|
||||
automake configuration files.)
|
||||
* Removed total size limitation on interpolation table module.
|
||||
* Various Cygwin fixes.
|
||||
* Added some convenience functions to point3d.
|
||||
* Various compiler warning fixes.
|
||||
* Added a thread wrapper class (currently only supports pthreads)
|
||||
* Added IO routines for a lowlevel, native simgear binary 3d file
|
||||
format optimized for TerraGear terrain.
|
||||
* Better endianness checking and support for the binary file
|
||||
read/write routines.
|
||||
* Added doxygen comments for all public interface code. Documentation
|
||||
can be accessed via the SimGear web page.
|
||||
* Many FG -> SG name space changes for better consistancy throughout
|
||||
this package.
|
||||
* Added property aliases, repeated name tags, and a general xml
|
||||
inclusion facilities. Many other property manager clean ups
|
||||
following a complete rewrite.
|
||||
* Fixed some critical null pointer bugs in property manager.
|
||||
* Magnetic variation can now be fetched for any arbitrary location.
|
||||
|
||||
|
||||
New in 0.0.14
|
||||
* December 14, 2000
|
||||
* Added a module to manage waypoints and routes, calculate bearing and
|
||||
distance to next waypoint, lateral distance off route, etc.
|
||||
* Moved some of the basic time management code over from flightgear.
|
||||
* Bucket dimensions can be returned in meters
|
||||
* Added SOCK_STREAM (TCP) socket support to the networking code.
|
||||
* Updated random number generator interface so application can provide
|
||||
it's own seed value as well as use the default time seed.
|
||||
* Added a routine to calculate the distance between a point and a line segment.
|
||||
* Updates to the property manager and the property list loader/saver.
|
||||
* Added an explanation of the rational behind our terrain texture coordinate
|
||||
generation code.
|
||||
* Fixed sky dome so that the color at the horizon will always match
|
||||
the specified fog color.
|
||||
* Did a fair amount of fg -> sg name space updating (lots left to do.)
|
||||
* Added support for KAI C++ on linux.
|
||||
* MSVC tweaks.
|
||||
* MacOS tweaks.
|
||||
* FreeBSD tweaks.
|
||||
|
||||
|
||||
New in 0.0.13
|
||||
* September 14, 2000
|
||||
* Added support for reading and writing xml files (easyxml)
|
||||
* Then updates to property manager and xml code.
|
||||
* Update magnetic variation code.
|
||||
* Sky code now uses glPushAttrib and glPopAttrib so it plays better with
|
||||
other ssg based apps.
|
||||
* MacOS tweaks.
|
||||
* MSVC tweaks.
|
||||
|
||||
|
||||
New in 0.0.12
|
||||
* July 19, 2000
|
||||
* Converted project license from GPL to LGPL.
|
||||
* Moved low level IO (socket, file, serial) code over to SimGear.
|
||||
* Moved ephemeral code into simgear
|
||||
* Moved basic world time code into simgear
|
||||
* Added a property manager (registry)
|
||||
* Some documentation added.
|
||||
|
||||
|
||||
New in 0.0.11
|
||||
* July 3, 2000
|
||||
* Replaced gdbm with metakit
|
||||
* Added drop in sky (depends on plib)
|
||||
* Added spherical course and dist given two points calculations
|
||||
* MSVC5 fixes
|
||||
* Math/bucket/tiling tweaks from Norman Vine
|
||||
|
||||
|
||||
New in 0.0.7
|
||||
* March 29, 2000
|
||||
* Added support for RedHat package building contributed by Habibie
|
||||
<habibie@MailandNews.com>
|
||||
* Added gdbm to SimGear. Many systems will already have gdbm installed so
|
||||
it is only built if it doesn't already exist on the user's platform.
|
||||
gdbm is a set of database routines that use extendible hashing and works
|
||||
similar to the standard UNIX dbm routines. This guarantees the availability
|
||||
of gdbm to any application that uses SimGear.
|
||||
* Optimizations and bullet proofing of magnetic variation code by Norman
|
||||
Vine and Ed Williams
|
||||
|
||||
|
||||
New in 0.0.6
|
||||
* March 27, 2000
|
||||
* Added Nima World Magnetic Model 2000 contributed by Ed Williams
|
||||
* Fixes for MSVC++
|
||||
|
||||
|
||||
New in 0.0.5
|
||||
* March 17, 2000
|
||||
* Restructured directory layout to facilitate windows/mac IDE builds.
|
||||
|
||||
|
||||
New in 0.0.4
|
||||
* Removed mat3.h and friends (we now use plib's sg lib for these sorts of
|
||||
things.)
|
||||
|
||||
|
||||
New in 0.0.3
|
||||
* Release that conincides with FlightGear-0.7.2
|
||||
24
README.MSVC
Normal file
24
README.MSVC
Normal file
@@ -0,0 +1,24 @@
|
||||
This document describes how to build SimGear using the supplied workspace and
|
||||
project files.
|
||||
|
||||
Unpack the SimGear source file into your work directory. This creates a new
|
||||
subdirectory called SimGear-X.Y.Z. Rename this to SimGear. Before we can
|
||||
build SimGear you must unpack and build the third party libraries metakit and
|
||||
zlib. Sources for these are included in the SimGear/src-libs directory.
|
||||
Unpack these into the top level SimGear directory. At this point your
|
||||
directory structure should look something like this:
|
||||
|
||||
<work_dir>/
|
||||
SimGear/
|
||||
metakit-x.y.z/
|
||||
simgear/
|
||||
src-libs/
|
||||
zlib-x.y.z/
|
||||
|
||||
Now open the SimGear workspace. This workspace file contains projects for
|
||||
building metakit(mklib), SimGear and zlib. Select each project as the active
|
||||
project and build all. Order is unimportant since there are no dependencies
|
||||
between the projects.
|
||||
|
||||
The workspace and project files are generated by a perl script with extra
|
||||
input from the am2dsp.cfg file.
|
||||
285
README.metakit
Normal file
285
README.metakit
Normal file
@@ -0,0 +1,285 @@
|
||||
For your convenience (and with the author's permission) a copy of the
|
||||
MetaKit source is bundled with SimGear in $(top_srcdir)/src-libs/.
|
||||
You must have metakit installed before you can build SimGear.
|
||||
|
||||
- Most linux distributions have a metakit package. For linux
|
||||
developers, we recommend ysou install your distributions package
|
||||
rather than building from source.
|
||||
|
||||
- For developers on most other platforms, you will have to build
|
||||
metakit from source and install it yourself. For your convenience a
|
||||
tar ball of the metakit source is included with the simgear source
|
||||
distribution. Untar the metakit source, and follow the included
|
||||
build and installation instructions.
|
||||
|
||||
Once metakit is installed you can return to configuring and building
|
||||
Simgear.
|
||||
|
||||
=============================================================================
|
||||
|
||||
Potentially important build note:
|
||||
|
||||
Later on when you are linking programs with -lmk4 (i.e. FlightGear or one
|
||||
of it's associated programs) if you come across an error similar to the
|
||||
following:
|
||||
|
||||
c++ -Wall -O2 -L/usr/local/lib -o gensimple gensimple.o libAirports.a
|
||||
-lsgdebug -lsgmisc -lmk4 -lz -lm
|
||||
/usr/local/lib/libmk4.a(view.o)(.text+0x1c8):view.cpp: multiple definition
|
||||
of `c4_View::~c4_View(void)'
|
||||
libAirports.a(simple.o)(.text$_$_7c4_View+0x0):simple.cxx: first defined
|
||||
here
|
||||
collect2: ld returned 1 exit status
|
||||
make[2]: *** [gensimple] Error 1
|
||||
make[2]: Leaving directory `/home/curt/FlightGear-0.7.7/src/Airports'
|
||||
make[1]: *** [all-recursive] Error 1
|
||||
make[1]: Leaving directory `/home/curt/FlightGear-0.7.7/src'
|
||||
make: *** [all-recursive] Error 1
|
||||
|
||||
Then you need to come back and rebuild Metakit with the -DNDEBUG flag.
|
||||
For unix/cygwin systems, modify the unix/Makefile file and add -DNDEBUG
|
||||
to the CFLAGS line.
|
||||
|
||||
Now we return you to the official metakit readme ... :-)
|
||||
|
||||
|
||||
The MetaKit Library 2.01 March 2000
|
||||
==============================================================================
|
||||
|
||||
|
||||
WHAT IT IS - MetaKit is an embeddable database which runs on Unix, Windows,
|
||||
Macintosh, and other platforms. It lets you build applications which
|
||||
store their data efficiently, in a portable way, and which will not need a
|
||||
complex runtime installation. In terms of the data model, MetaKit takes
|
||||
the middle ground between RDBMS, OODBMS, and flat-file databases - yet it
|
||||
is quite different from each of them.
|
||||
|
||||
WHAT IT ISN'T - MetaKit is not: 1) multi-user/-threading, 2) scalable to
|
||||
gigabytes, 3) proprietary software, 4) full of bugs, 5) just a toy.
|
||||
|
||||
TECHNOLOGY - Everything is stored variable-sized yet with efficient positional
|
||||
row access. Changing an existing datafile structure is as simple as re-
|
||||
opening it with that new structure. All changes are transacted. You can
|
||||
mix and match software written in C++, Python, and Tcl. Things can't get
|
||||
much more flexible...
|
||||
|
||||
CORE - The Metakit core library is written in C++. It has a code footprint of
|
||||
just over 100 Kb on Windows. It can be used as DLL, or linked statically.
|
||||
Debug builds include extensive assertion checks to catch problems early.
|
||||
|
||||
PYTHON - The binding for Python is called "Mk4py". It uses SCXX by Gordon
|
||||
McMillan as C++ glue interface. The source is in directory "python/".
|
||||
|
||||
TCL/TK - The MK extension for Tcl is called "Mk4tcl". It is being used in a
|
||||
number of commercial projects, for in-house use as well as in commercially
|
||||
distributed products. The source is in directory "tcl/".
|
||||
|
||||
LICENSE AND SUPPORT - MetaKit 2.01 is distributed as open source software (the
|
||||
X/MIT-style license is at the end of this document). Commercial support
|
||||
is available through an Enterprise License, see the URL mentioned below.
|
||||
|
||||
DOCUMENTATION - All documentation uses HTML. The main page is "MetaKit.html",
|
||||
which leads to the rest of the documentation in the "doc/" directory.
|
||||
|
||||
WEBSITE URLS - The main pages on the world wide web, for news and downloads:
|
||||
Homepage: http://www.equi4.com/metakit/
|
||||
Python news: http://www.equi4.com/metakit/python.html
|
||||
Tcl/Tk news: http://www.equi4.com/metakit/tcl.html
|
||||
License info: http://www.equi4.com/metakit/license.html
|
||||
Contact info: http://www.equi4.com/contact.html
|
||||
|
||||
|
||||
INSTALLATION
|
||||
============
|
||||
|
||||
Starting with this release, all platform builds and language bindings are now
|
||||
designed to work from a single common "builds/" directory. It turns out to
|
||||
be impossible to keep build side-effects limited to *just* this directory
|
||||
(CodeWarrior can't be told where to place its temp data, and Visual C++ still
|
||||
alters a few files next to the project ".dsw" file, to name two offenders).
|
||||
|
||||
UNIX
|
||||
|
||||
It is no longer advised to build the Unix code in the "unix/" directory.
|
||||
Instead, you should perform the following steps:
|
||||
% cd builds
|
||||
% ../unix/configure
|
||||
% make
|
||||
% make test
|
||||
And optionally (this only installs the core lib, not script extensions):
|
||||
% make install
|
||||
|
||||
By switching to the "builds/" directory, you will keep the distribution
|
||||
directory tree 100% unaltered. All changes are made in this subdir, and
|
||||
all final build results are left behind in this same subdir.
|
||||
|
||||
Nastiness: if you build Mk4tcl, please do a "make Mk4tcl.so" as well.
|
||||
And if you intend to create the Python extension, do a "make Mk4py.so".
|
||||
The "libmk4tcl.so.0.0.0" and "libMk4py.so.0.0.0" targets are bogus ones.
|
||||
|
||||
You will probably have to make changes in the makefile to locate the
|
||||
proper includes and libs for Python (Tcl has been fixed, see "--with-tcl).
|
||||
You probably only need to adjust "CXX_SWITCHES_PY" to find the headers.
|
||||
|
||||
To build with STL containers and strings, you can do the following:
|
||||
make CXXFLAGS='-Dq4_STD' test # add -O3 etc, as needed
|
||||
This passes the test suite on Linux RedHat 5.2 with gcc 2.95-2.
|
||||
|
||||
See below for some platform-specific build notes.
|
||||
|
||||
WINDOWS
|
||||
|
||||
There is a "win/" directory which contains subdirectories for a number of
|
||||
compiler systems. MetaKit has been built with many different compilers
|
||||
in the past (Microsoft, Borland, Watcom, Symantec, Metrowerks, Optima),
|
||||
but to preserve my sanity (there are 12 configurations for MSVC6 alone!),
|
||||
I am limiting myself to MSVC6, MWCW5, Borland C++ Builder 4, and Cygwin.
|
||||
|
||||
The MS Visual C++ 6.0 project is "win/msvc60/mksrc.dsw", with subprojects
|
||||
for the C++ demo (mkdemo), building dll's (mkdll), static libs (mklib),
|
||||
regression tests (mktest), as well as Tcl (mktcl) and Python (mkpython).
|
||||
It has been set up to place all intermediate files and final results in
|
||||
the "builds/" subdirectory, even though you'll launch it from "win/".
|
||||
|
||||
To build with STL containers and strings under MSVC, define "q4_STD".
|
||||
To build with MFC containers and strings under MSVC, define "q4_MFC".
|
||||
|
||||
The Metrowerks Codewarrior project is in the "mac/" directory, and can be
|
||||
used to build both Mac and Windows versions (on either Mac *or* Windows).
|
||||
The core libraries are built with "mac/cw5.mcp", demos / tests are built
|
||||
with "cw5apps.mcp", Tcl is "cw5tcl.mcp", and Python is "cw5python.mcp".
|
||||
|
||||
The Borland C++ Builder projects have not yet been incorporated in this
|
||||
release, but the "KitViewer" application is an example of how to use BCB.
|
||||
|
||||
The Cygwin build (B20.1 / gcc 2.95.2) is different, because it uses the
|
||||
unix autoconf system, and must be launched as described above for UNIX.
|
||||
I have upgraded to the latest development of libtool to be able to build
|
||||
DLL's with Cygwin. You can build the "-mno-cygwin" version by editing
|
||||
the Makefile by hand and adding that option to CXXFLAGS.
|
||||
|
||||
Rob Bloodgood adds that the following GCC options are for maximum code
|
||||
efficiency on x86 hardware: "-O2 -m486 -malign-loops=2 -malign-jumps=2".
|
||||
I have not yet tried this myself, but am passing on the tip.
|
||||
|
||||
MACINTOSH
|
||||
|
||||
The Mac version requires Metrowerks CodeWarrior 5. See the info above
|
||||
in the Windows section (MWCW is multi-platform). The projects are all
|
||||
located in the "mac/" folder, which is also where MWCW will place its own
|
||||
"... Data" folders with intermediate results. As with all other setups,
|
||||
final results are made to end up in the "builds/" directory.
|
||||
|
||||
Static 68K builds appear to work fine, the 68K CFM variants will need
|
||||
some more work (I couldn't get the libraries to export their symbols).
|
||||
|
||||
|
||||
PLATFORM-SPECIFIC NOTES
|
||||
=======================
|
||||
|
||||
* Linux RH 5.2 / gcc 2.95.2
|
||||
|
||||
Builds with gcc 2.95.2 work out of the box. The Tcl extension ends up as
|
||||
".libs/libmk4tcl.so.0.0.0" (to please libtool), and should be renamed to
|
||||
"Mk4tcl.so". Similarly, ".libs/libMk4py.so.0.0.0" is in fact the Python
|
||||
extension, and *must* be renamed to "Mk4py.so" to call it from Python.
|
||||
|
||||
The core MK libs end up as ".libs/libmk4.a" and ".libs/libmk4.so.0.0.0".
|
||||
|
||||
* Solaris 2.6 / gcc 2.8.1
|
||||
|
||||
The Solaris builds are nasty for several reasons:
|
||||
|
||||
- I do not own such a machine, and often have to make arrangements
|
||||
(or fight limited space on one of the machines I can telnet to).
|
||||
- The gcc 2.8.1 optimizer appears to be buggy, I have had to turn off
|
||||
the default "-O3" flag to prevent compiler crashes (several files).
|
||||
This problems appears to be resolved with gcc 2.95.
|
||||
- Locking on Solaris (especially w.r.t NFS) remains a mystery to me.
|
||||
The Tcl and Python extensions both use locking (the core not yet).
|
||||
See tcl/Mk4tcl.cpp around line 520, and python/PyStorage.cpp around
|
||||
line 80 for details. It's all pretty messy, and not 100% correct.
|
||||
|
||||
Despite this, I'm doing my best to resolve these issues. Having a solid
|
||||
build of the core *and* of Tcl / Python extensions is quite important.
|
||||
|
||||
* Other Unix systems
|
||||
|
||||
No further notes, though many systems will build fine out of the box.
|
||||
|
||||
* Windows
|
||||
|
||||
MSVC 6 builds MK as static lib and as DLL (universal config, I have not
|
||||
yet created build versions with MFC or STL, mainly because MK can now be
|
||||
used in all contexts regardless of how it was built). The Python and Tcl
|
||||
extensions build as dynamic extensions (a static build is easy to add).
|
||||
|
||||
MWCW 5 builds MK as static lib and as DLL (interestingly enough, the DLL
|
||||
is slightly smaller than MSVC 6 - 102 vs 108 Kb - when their runtimes are
|
||||
linked in dynamically as well). I have not added Win builds for Tcl or
|
||||
Python, since MSVC 6 has those already.
|
||||
|
||||
Cygwin B20.1, with gcc 2.95.2 ugrade, also builds MK as static lib and as
|
||||
DLL. Both "pure" Cygwin (i.e. requiring cygwin1.dll) and mingw32 (using
|
||||
the -mno-cygwin flag) build, but there are some hairy include issues when
|
||||
it comes to choosing the right locking model for Tcl and Python. These
|
||||
issues have not been resolved fully.
|
||||
|
||||
* Macintosh
|
||||
|
||||
MWCW 5 builds PPC shared libs, PPC static libs, and 68K static libraries.
|
||||
|
||||
Building 68K CFM libraries leads to a "MetaKit 68K.shlb" which comes out
|
||||
of the linker without errors, but the result does not seem to have any
|
||||
export symbols defined (despite the fact that the library is over 200 K).
|
||||
Because of that, I've been unable to build apps or Mk4tcl/Mk4py so far.
|
||||
|
||||
The other three configurations build, but for some reason MK's regression
|
||||
test stops at L03 (everything up to that point looks ok, i.e. over 90%).
|
||||
|
||||
The Mk4tcl PPC extension appears to work (quick manual test), and so does
|
||||
the Python extension, "Mk4py.PPC.slb". I have not yet given these two
|
||||
a serious workout, hoping to have a basic test harness in place soon.
|
||||
|
||||
* VMS, BeOS, ...
|
||||
|
||||
No news yet, please report your findings with any other platform builds.
|
||||
|
||||
|
||||
WHAT'S MISSING HERE
|
||||
===================
|
||||
|
||||
- a section on basic concepts (or maybe it doesn't belong here?)
|
||||
- a section on getting started (C++, Python, Tcl all differ - point to
|
||||
the respective intro pages)
|
||||
- maybe a small sample for each of C++ / Tcl / Python, to give an idea
|
||||
- mention TclKit, scripted docs (WiKit/Tequila?), VFS?
|
||||
- I forgot... please tell me :)
|
||||
|
||||
|
||||
LICENSE AND COPYRIGHT STATEMENT
|
||||
===============================
|
||||
|
||||
Copyright (c) 1996-2000 Jean-Claude Wippler
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
==============================================================================
|
||||
-- Jean-Claude Wippler <jcw@equi4.com>
|
||||
16
README.plib
Normal file
16
README.plib
Normal file
@@ -0,0 +1,16 @@
|
||||
[This file is mirrored in both the FlightGear and SimGear packages.]
|
||||
|
||||
You *must* have plib version 1.6.0 or later installed on your system
|
||||
to build FlightGear!" Flight Gear is no longer compatible with the
|
||||
earlier versions of the library.
|
||||
|
||||
You can get the latest version of plib from:
|
||||
|
||||
http://plib.sourceforge.net
|
||||
|
||||
Build notes:
|
||||
|
||||
You should be able to just run "./configure" to configure the package
|
||||
and use all of plib's defaults. Then run "make" followed by "make
|
||||
install". By default, plib installs itself into /usr so if you don't
|
||||
like this, be sure to specify an alternate prefix such as --prefix=/usr/local
|
||||
173
README.zlib
Normal file
173
README.zlib
Normal file
@@ -0,0 +1,173 @@
|
||||
For your convenience and allowed by zlib's license terms:
|
||||
http://www.gzip.org/zlib/zlib_license.html a copy of the zlib source
|
||||
is bundled with SimGear in $(top_srcdir)/src-libs/. You must have
|
||||
zlib installed before you can build SimGear.
|
||||
|
||||
- Most linux distributions have a zlib package. For linux
|
||||
developers, we recommend ysou install your distributions package
|
||||
rather than building from source.
|
||||
|
||||
- Cygwin installs zlib automatically.
|
||||
|
||||
- For developers on most other platforms, you will have to build
|
||||
zlib from source and install it yourself. For your convenience a
|
||||
tar ball of the zlib source is included with the simgear source
|
||||
distribution. Untar the zlib source, and follow the included
|
||||
build and installation instructions.
|
||||
|
||||
Once zlib is installed you can return to configuring and building
|
||||
Simgear.
|
||||
|
||||
We now send you to the official zlib README ...
|
||||
|
||||
|
||||
=============================================================================
|
||||
|
||||
|
||||
zlib 1.1.4 is a general purpose data compression library. All the code
|
||||
is thread safe. The data format used by the zlib library
|
||||
is described by RFCs (Request for Comments) 1950 to 1952 in the files
|
||||
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate
|
||||
format) and rfc1952.txt (gzip format). These documents are also available in
|
||||
other formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
|
||||
|
||||
All functions of the compression library are documented in the file zlib.h
|
||||
(volunteer to write man pages welcome, contact jloup@gzip.org). A usage
|
||||
example of the library is given in the file example.c which also tests that
|
||||
the library is working correctly. Another example is given in the file
|
||||
minigzip.c. The compression library itself is composed of all source files
|
||||
except example.c and minigzip.c.
|
||||
|
||||
To compile all files and run the test program, follow the instructions
|
||||
given at the top of Makefile. In short "make test; make install"
|
||||
should work for most machines. For Unix: "./configure; make test; make install"
|
||||
For MSDOS, use one of the special makefiles such as Makefile.msc.
|
||||
For VMS, use Make_vms.com or descrip.mms.
|
||||
|
||||
Questions about zlib should be sent to <zlib@gzip.org>, or to
|
||||
Gilles Vollant <info@winimage.com> for the Windows DLL version.
|
||||
The zlib home page is http://www.zlib.org or http://www.gzip.org/zlib/
|
||||
Before reporting a problem, please check this site to verify that
|
||||
you have the latest version of zlib; otherwise get the latest version and
|
||||
check whether the problem still exists or not.
|
||||
|
||||
PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html
|
||||
before asking for help.
|
||||
|
||||
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
|
||||
issue of Dr. Dobb's Journal; a copy of the article is available in
|
||||
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
|
||||
|
||||
The changes made in version 1.1.4 are documented in the file ChangeLog.
|
||||
The only changes made since 1.1.3 are bug corrections:
|
||||
|
||||
- ZFREE was repeated on same allocation on some error conditions.
|
||||
This creates a security problem described in
|
||||
http://www.zlib.org/advisory-2002-03-11.txt
|
||||
- Returned incorrect error (Z_MEM_ERROR) on some invalid data
|
||||
- Avoid accesses before window for invalid distances with inflate window
|
||||
less than 32K.
|
||||
- force windowBits > 8 to avoid a bug in the encoder for a window size
|
||||
of 256 bytes. (A complete fix will be available in 1.1.5).
|
||||
|
||||
The beta version 1.1.5beta includes many more changes. A new official
|
||||
version 1.1.5 will be released as soon as extensive testing has been
|
||||
completed on it.
|
||||
|
||||
|
||||
Unsupported third party contributions are provided in directory "contrib".
|
||||
|
||||
A Java implementation of zlib is available in the Java Development Kit
|
||||
http://www.javasoft.com/products/JDK/1.1/docs/api/Package-java.util.zip.html
|
||||
See the zlib home page http://www.zlib.org for details.
|
||||
|
||||
A Perl interface to zlib written by Paul Marquess <pmarquess@bfsec.bt.co.uk>
|
||||
is in the CPAN (Comprehensive Perl Archive Network) sites
|
||||
http://www.cpan.org/modules/by-module/Compress/
|
||||
|
||||
A Python interface to zlib written by A.M. Kuchling <amk@magnet.com>
|
||||
is available in Python 1.5 and later versions, see
|
||||
http://www.python.org/doc/lib/module-zlib.html
|
||||
|
||||
A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com>
|
||||
is availlable at http://www.westend.com/~kupries/doc/trf/man/man.html
|
||||
|
||||
An experimental package to read and write files in .zip format,
|
||||
written on top of zlib by Gilles Vollant <info@winimage.com>, is
|
||||
available at http://www.winimage.com/zLibDll/unzip.html
|
||||
and also in the contrib/minizip directory of zlib.
|
||||
|
||||
|
||||
Notes for some targets:
|
||||
|
||||
- To build a Windows DLL version, include in a DLL project zlib.def, zlib.rc
|
||||
and all .c files except example.c and minigzip.c; compile with -DZLIB_DLL
|
||||
The zlib DLL support was initially done by Alessandro Iacopetti and is
|
||||
now maintained by Gilles Vollant <info@winimage.com>. Check the zlib DLL
|
||||
home page at http://www.winimage.com/zLibDll
|
||||
|
||||
From Visual Basic, you can call the DLL functions which do not take
|
||||
a structure as argument: compress, uncompress and all gz* functions.
|
||||
See contrib/visual-basic.txt for more information, or get
|
||||
http://www.tcfb.com/dowseware/cmp-z-it.zip
|
||||
|
||||
- For 64-bit Irix, deflate.c must be compiled without any optimization.
|
||||
With -O, one libpng test fails. The test works in 32 bit mode (with
|
||||
the -n32 compiler flag). The compiler bug has been reported to SGI.
|
||||
|
||||
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1
|
||||
it works when compiled with cc.
|
||||
|
||||
- on Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1
|
||||
is necessary to get gzprintf working correctly. This is done by configure.
|
||||
|
||||
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works
|
||||
with other compilers. Use "make test" to check your compiler.
|
||||
|
||||
- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
|
||||
|
||||
- For Turbo C the small model is supported only with reduced performance to
|
||||
avoid any far allocation; it was tested with -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
|
||||
|
||||
- For PalmOs, see http://www.cs.uit.no/~perm/PASTA/pilot/software.html
|
||||
Per Harald Myrvang <perm@stud.cs.uit.no>
|
||||
|
||||
|
||||
Acknowledgments:
|
||||
|
||||
The deflate format used by zlib was defined by Phil Katz. The deflate
|
||||
and zlib specifications were written by L. Peter Deutsch. Thanks to all the
|
||||
people who reported problems and suggested various improvements in zlib;
|
||||
they are too numerous to cite here.
|
||||
|
||||
Copyright notice:
|
||||
|
||||
(C) 1995-2002 Jean-loup Gailly and Mark Adler
|
||||
|
||||
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.
|
||||
|
||||
Jean-loup Gailly Mark Adler
|
||||
jloup@gzip.org madler@alumni.caltech.edu
|
||||
|
||||
If you use the zlib library in a product, we would appreciate *not*
|
||||
receiving lengthy legal documents to sign. The sources are provided
|
||||
for free but without warranty of any kind. The library has been
|
||||
entirely written by Jean-loup Gailly and Mark Adler; it does not
|
||||
include third-party code.
|
||||
|
||||
If you redistribute modified sources, we would appreciate that you include
|
||||
in the file ChangeLog history information documenting your changes.
|
||||
2036
SimGear.dsp
Normal file
2036
SimGear.dsp
Normal file
File diff suppressed because it is too large
Load Diff
53
SimGear.dsw
Normal file
53
SimGear.dsw
Normal file
@@ -0,0 +1,53 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "SimGear"=".\SimGear.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "mklib"=".\SimGear\metakit-2.4.3\win\msvc60\mklib.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "zlib"=".\SimGear\zlib.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
76
SimGear.spec.in
Normal file
76
SimGear.spec.in
Normal file
@@ -0,0 +1,76 @@
|
||||
%define ver @VERSION@
|
||||
%define rel 1
|
||||
%define prefix /usr
|
||||
|
||||
Summary: Simulator Construction Gear.
|
||||
Name: @PACKAGE@
|
||||
Version: %ver
|
||||
Release: %rel
|
||||
Copyright: LGPL
|
||||
Group: Libraries/Graphics
|
||||
Source: %{name}-%{version}.tar.gz
|
||||
#URL:
|
||||
BuildRoot: /tmp/%{name}-%{version}-%{rel}-root
|
||||
Packager: Fill In As You Wish
|
||||
Docdir: %{prefix}/doc
|
||||
|
||||
%description
|
||||
This package contains a tools and libraries useful for constructing
|
||||
simulation and visualization applications such as FlightGear or TerraGear.
|
||||
|
||||
Authors:
|
||||
N/A
|
||||
|
||||
%prep
|
||||
%setup -n %{name}-%{version}
|
||||
|
||||
|
||||
%build
|
||||
# Needed for snapshot releases.
|
||||
if [ ! -f configure ]; then
|
||||
CFLAGS="$RPM_OPT_FLAGS" ./autogen.sh --prefix=%prefix
|
||||
else
|
||||
CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%prefix
|
||||
fi
|
||||
|
||||
if [ "$SMP" != "" ]; then
|
||||
JSMP = '"MAKE=make -k -j $SMP"'
|
||||
fi
|
||||
|
||||
make ${JSMP};
|
||||
|
||||
|
||||
%install
|
||||
[ -d ${RPM_BUILD_ROOT} ] && rm -rf ${RPM_BUILD_ROOT}
|
||||
|
||||
make prefix=${RPM_BUILD_ROOT}%{prefix} install
|
||||
|
||||
#
|
||||
# Generating file lists and store them in file-lists
|
||||
# Starting with the directory listings
|
||||
#
|
||||
find ${RPM_BUILD_ROOT}%{prefix}/{bin,include,lib} -type d | sed "s#^${RPM_BUILD_ROOT}#\%attr (-\,root\,root) \%dir #" > file-lists
|
||||
%{?ETCDR:find ${RPM_BUILD_ROOT}%{!?SYSCF:%{prefix}}/etc -type d | sed "s#^${RPM_BUILD_ROOT}#\%attr (-\,root\,root) \%dir #" >> file-lists}
|
||||
|
||||
#
|
||||
# Then, the file listings
|
||||
#
|
||||
echo "%defattr (-, root, root)" >> file-lists
|
||||
%{?ETCDR:find ${RPM_BUILD_ROOT}%{!?SYSCF:%{prefix}}/etc/%{name}.conf -type f | sed -e "s#^${RPM_BUILD_ROOT}#%config #g" >> file-lists}
|
||||
find ${RPM_BUILD_ROOT}%{prefix} -type f | sed -e "s#^${RPM_BUILD_ROOT}##g" >> file-lists
|
||||
|
||||
|
||||
%clean
|
||||
(cd ..; rm -rf %{name}-%{version} ${RPM_BUILD_ROOT})
|
||||
|
||||
|
||||
%files -f file-lists
|
||||
%defattr (-, root, root)
|
||||
%doc AUTHORS
|
||||
%doc COPYING
|
||||
%doc ChangeLog
|
||||
%doc INSTALL
|
||||
%doc NEWS
|
||||
%doc README
|
||||
%doc %{name}.spec.in
|
||||
|
||||
184
Thanks
Normal file
184
Thanks
Normal file
@@ -0,0 +1,184 @@
|
||||
A very special thanks is due to the following people and groups.
|
||||
|
||||
Note: as hard as we've tried, it is impossible to perfectly maintain
|
||||
this file. If you are aware of someone who you think should be
|
||||
included here, PLEASE let me know. Projects like this are made
|
||||
possible only by the help and hard work of others. I want to properly
|
||||
credit everyone who has contributed to this project.
|
||||
|
||||
|
||||
Raul Alonzo <amil@las.es>
|
||||
Mr. Alonzo is the author of Ssystem and provided his kind permission
|
||||
for using the moon texture. I also used parts of his code as a template
|
||||
when adding the texture. Ssystem Homepage can be found at:
|
||||
http://www1.las.es/~amil/ssystem
|
||||
|
||||
|
||||
Paul Bleisch <pbleisch@acm.org>
|
||||
Paul redid the "debug" system so that it would be much more flexible,
|
||||
so it could be easily disabled for production system, and so that
|
||||
messages for certain subsystems could be selectively enabled.
|
||||
Also contributed a first stab at a config file/command line parsing
|
||||
system.
|
||||
|
||||
|
||||
Bernie Bright <bbright@c031.aone.net.au>
|
||||
Many C++ style, usage, and implementation improvements.
|
||||
STL portability, tons o' stuff. :-)
|
||||
Currently trying to get a BeOS port together but life keeps getting
|
||||
in the way!
|
||||
|
||||
|
||||
Gene Buckle <geneb@deltasoft.com>
|
||||
Gene has done a lot of work getting FG to compile with the MSVC++
|
||||
compiler. Also, he has pushed, proded, and bugged me endlessly to
|
||||
do my stuff right. (I mean that in a good way, because sometimes
|
||||
when the little nudge in the right direction isn't working, I need
|
||||
a good hard shove.) :-)
|
||||
|
||||
|
||||
John Check <j4strngs@rockfish.net>
|
||||
Cloud textures
|
||||
|
||||
|
||||
Jean-Francois Doue
|
||||
Vector 2D, 3D, 4D and Matrix 3D and 4D inlined C++ classes. (Based on
|
||||
Graphics Gems IV ed. Paul S. Heckbert)
|
||||
http://www.animats.com/simpleppp/ftp/public_html/topics/developers.html
|
||||
|
||||
|
||||
Bruce Finney <bfinney@gte.net>
|
||||
MSVC5 compatibility.
|
||||
|
||||
|
||||
Jean-loup Gailly and Mark Adler <zlib@gzip.org>
|
||||
Authors of the zlib library. Used for on-the-fly compression and
|
||||
decompression routines.
|
||||
http://www.cdrom.com/pub/infozip/zlib/
|
||||
|
||||
|
||||
Thomas Gellekum <tg@ihf.rwth-aachen.de>
|
||||
Changes and updates for compiling on FreeBSD
|
||||
|
||||
|
||||
Habibie <habibie@MailandNews.com>
|
||||
RedHat package building changes for SimGear.
|
||||
|
||||
|
||||
Bruce Jackson of NASA <e.b.jackson@larc.nasa.gov>
|
||||
Developed the LaRCsim code under funding by NASA which we use to provide
|
||||
the flight model. Bruce has patiently answered my many, many questions.
|
||||
http://dcb.larc.nasa.gov/www/DCBStaff/ebj/ebj.html
|
||||
|
||||
|
||||
Richard Kaszeta <bofh@me.umn.edu>
|
||||
Contributed screen buffer to ppm screen shot routine.
|
||||
Rich has also helped in the early development of the Flight Gear "altitude
|
||||
hold autopilot module" by teaching Curt Olson the basics of Control Theory
|
||||
and helping him code and debug early versions. Curt's "Boss" Bob Hain
|
||||
also contributed <bob@me.umn.edu>. Further details available at:
|
||||
http://www.menet.umn.edu/~curt/fgfs/Docs/Autopilot/AltitudeHold/AltitudeHold.html
|
||||
Rich's Homepage: http://www.menet.umn.edu/~kaszeta
|
||||
|
||||
|
||||
Tom Knienieder <tom@knienieder.com>
|
||||
Ported Steve's Audio library first to OpenBSD and IRIX and
|
||||
after that also to Win32
|
||||
|
||||
|
||||
David Megginson <david@megginson.com>
|
||||
SimGear property manager/registry
|
||||
|
||||
|
||||
Curt Olson <curt@flightgear.org>
|
||||
Curt is responsible for overall project and source code management.
|
||||
He has his hands in many of the areas.
|
||||
|
||||
|
||||
Petter Reinholdtsen <pere@games.no>
|
||||
Incorporated the Gnu automake/autoconf system (with libtool).
|
||||
This should streamline and standardize the build process for all
|
||||
Unix-like platforms. It should have little effect on IDE type
|
||||
environments since the don't use the Unix make system.
|
||||
|
||||
|
||||
Paul Schlyter <pausch@saaf.se>
|
||||
Mr. Schlyter provided Durk Talsma with all the information
|
||||
he needed to write the astro code. Mr. S. is also willing
|
||||
to answer astro-related questions whenever one needs to.
|
||||
http://welcome.to/pausch
|
||||
|
||||
|
||||
Durk Talsma <d.talsma@chello.nl>
|
||||
Accurate Sun, Moon, and Planets.
|
||||
Sun changes color based on position in sky.
|
||||
Moon has correct phase and blends well into the sky.
|
||||
Planets are correctly positioned and have proper magnitude.
|
||||
Added time zone support in the SGTime class.
|
||||
Help with time functions, gui, and other misc stuff.
|
||||
http://people.a2000.nl/dtals
|
||||
|
||||
|
||||
Mark Vallevand <Mark.Vallevand@UNISYS.com>
|
||||
Contributed some METAR parsing code.
|
||||
Contributed some win32 screen printing routines.
|
||||
|
||||
|
||||
Gary R. Van Sickle <tiberius@braemarinc.com>
|
||||
Contributed some initial GameGLUT support and other fixes.
|
||||
Has done some interesting preliminary work on a binary file format
|
||||
http://www.woodsoup.org/projs/ORKiD/fgfs.htm
|
||||
|
||||
Has set up a 'Cygwin Tips' site that has been very helpful to many
|
||||
people in getting a Cygwin Unix-on-Windows build environment set up
|
||||
so they can build FG effectively.
|
||||
http://www.woodsoup.org/projs/ORKiD/cygwin.htm
|
||||
|
||||
|
||||
Norman Vine <nhv@yahoo.com>
|
||||
Provided more than uncountable URL's to the "FlightGear Community".
|
||||
Many performance optimizations throughout the code.
|
||||
Lots of windoze related contributions.
|
||||
Contributed wgs84 distance and course routines.
|
||||
Contributed a great circle route autopilot mode based on wgs84 routines.
|
||||
|
||||
|
||||
Ed Williams <Ed_Williams@compuserve.com>
|
||||
Contributed magnetic variation code (impliments Nima WMM 2000)
|
||||
We've also borrowed from Ed's wonderful aviation formulary at various
|
||||
times as well.
|
||||
http://www.best.com/~williams/index.html
|
||||
|
||||
|
||||
Jean-Claude Wippler <jcw@equi4.com>
|
||||
Author of MetaKit - a portable, embeddible database with a portable
|
||||
data file format. This software is not GPL'd but the author is kindly
|
||||
allowing us to bundle MetaKit with our code. MetaKit has a liberal
|
||||
X/MIT-style license. Please see the following URL for more info:
|
||||
http://www.equi4.com/metakit
|
||||
|
||||
|
||||
WoodSoup Project http://www.woodsoup.org
|
||||
Provided computing resources and services so that the Flight Gear
|
||||
project could have real home. This includes, web services,
|
||||
ftp services, shell accounts, email lists, dns services, etc.
|
||||
|
||||
|
||||
Robert Allan Zeh <raz@cmg.FCNBD.COM>
|
||||
Helped me tremendously in figuring out the Cygnus win32 compiler and
|
||||
how to link with .dll's. With out him the first runable win32
|
||||
version of FG would have been impossible.
|
||||
|
||||
|
||||
|
||||
NOTE:
|
||||
----
|
||||
|
||||
THIS DOCUMENT WAS INITIALLY WRITTEN BY
|
||||
Curt L. Olson <curt@flightgear.org>
|
||||
|
||||
|
||||
05 Jul 2000 Removed non-SimGear entries (CLO)
|
||||
|
||||
08 Mar 2000 CONTENTS RESEARCHED AND UPDATED by
|
||||
Oliver Delise <delise@mail.isis.de>
|
||||
415
acinclude.m4
Normal file
415
acinclude.m4
Normal file
@@ -0,0 +1,415 @@
|
||||
dnl
|
||||
dnl originally from ncftp 2.3.0
|
||||
dnl added wi_EXTRA_PDIR and wi_ANSI_C
|
||||
dnl $Id$
|
||||
dnl
|
||||
AC_DEFUN(wi_EXTRA_IDIR, [
|
||||
incdir="$1"
|
||||
if test -r $incdir ; then
|
||||
case "$CPPFLAGS" in
|
||||
*-I${incdir}*)
|
||||
# echo " + already had $incdir" 1>&6
|
||||
;;
|
||||
*)
|
||||
if test "$CPPFLAGS" = "" ; then
|
||||
CPPFLAGS="-I$incdir"
|
||||
else
|
||||
CPPFLAGS="$CPPFLAGS -I$incdir"
|
||||
fi
|
||||
echo " + found $incdir" 1>&6
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_EXTRA_LDIR, [
|
||||
mylibdir="$1"
|
||||
if test -r $mylibdir ; then
|
||||
case "$LDFLAGS" in
|
||||
*-L${mylibdir}*)
|
||||
# echo " + already had $mylibdir" 1>&6
|
||||
;;
|
||||
*)
|
||||
if test "$LDFLAGS" = "" ; then
|
||||
LDFLAGS="-L$mylibdir"
|
||||
else
|
||||
LDFLAGS="$LDFLAGS -L$mylibdir"
|
||||
fi
|
||||
echo " + found $mylibdir" 1>&6
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl __FP__
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_EXTRA_PDIR, [
|
||||
progdir="$1"
|
||||
if test -r $progdir ; then
|
||||
case "$PATH" in
|
||||
*:${progdir}*)
|
||||
# echo " + already had $progdir" 1>&6
|
||||
;;
|
||||
*${progdir}:*)
|
||||
# echo " + already had $progdir" 1>&6
|
||||
;;
|
||||
*)
|
||||
if test "$PATH" = "" ; then
|
||||
PATH="$progdir"
|
||||
else
|
||||
PATH="$PATH:$progdir"
|
||||
fi
|
||||
echo " + found $progdir" 1>&6
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl If you want to also look for include and lib subdirectories in the
|
||||
dnl $HOME tree, you supply "yes" as the first argument to this macro.
|
||||
dnl
|
||||
dnl If you want to look for subdirectories in include/lib directories,
|
||||
dnl you pass the names in argument 3, otherwise pass a dash.
|
||||
dnl
|
||||
AC_DEFUN(wi_EXTRA_DIRS, [echo "checking for extra include and lib directories..." 1>&6
|
||||
ifelse([$1], yes, [dnl
|
||||
b1=`cd .. ; pwd`
|
||||
b2=`cd ../.. ; pwd`
|
||||
exdirs="$HOME $j $b1 $b2 $prefix $2"
|
||||
],[dnl
|
||||
exdirs="$prefix $2"
|
||||
])
|
||||
subexdirs="$3"
|
||||
if test "$subexdirs" = "" ; then
|
||||
subexdirs="-"
|
||||
fi
|
||||
for subexdir in $subexdirs ; do
|
||||
if test "$subexdir" = "-" ; then
|
||||
subexdir=""
|
||||
else
|
||||
subexdir="/$subexdir"
|
||||
fi
|
||||
for exdir in $exdirs ; do
|
||||
if test "$exdir" != "/usr" || test "$subexdir" != ""; then
|
||||
incdir="${exdir}/include${subexdir}"
|
||||
wi_EXTRA_IDIR($incdir)
|
||||
|
||||
mylibdir="${exdir}/lib${subexdir}"
|
||||
wi_EXTRA_LDIR($mylibdir)
|
||||
|
||||
progdir="${exdir}/bin${subexdir}"
|
||||
wi_EXTRA_PDIR($progdir)
|
||||
fi
|
||||
done
|
||||
done
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_HPUX_CFLAGS,
|
||||
[AC_MSG_CHECKING(if HP-UX ansi C compiler flags are needed)
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
os=`uname -s | tr '[A-Z]' '[a-z]'`
|
||||
ac_cv_hpux_flags=no
|
||||
if test "$os" = hp-ux ; then
|
||||
if test "$ac_cv_prog_gcc" = yes ; then
|
||||
if test "$CFLAGS" != "" ; then
|
||||
# Shouldn't be in there.
|
||||
CFLAGS=`echo "$CFLAGS" | sed 's/-Aa//g'`
|
||||
fi
|
||||
else
|
||||
# If you're not using gcc, then you better have a cc/c89
|
||||
# that is usable. If you have the barebones compiler, it
|
||||
# won't work. The good compiler uses -Aa for the ANSI
|
||||
# compatible stuff.
|
||||
x=`echo $CFLAGS | grep 'Aa' 2>/dev/null`
|
||||
if test "$x" = "" ; then
|
||||
CFLAGS="$CFLAGS -Aa"
|
||||
fi
|
||||
ac_cv_hpux_flags=yes
|
||||
fi
|
||||
# Also add _HPUX_SOURCE to get the extended namespace.
|
||||
x=`echo $CFLAGS | grep '_HPUX_SOURCE' 2>/dev/null`
|
||||
if test "$x" = "" ; then
|
||||
CFLAGS="$CFLAGS -D_HPUX_SOURCE"
|
||||
fi
|
||||
fi
|
||||
AC_MSG_RESULT($ac_cv_hpux_flags)
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_CFLAGS, [AC_REQUIRE([AC_PROG_CC])
|
||||
wi_HPUX_CFLAGS
|
||||
if test "$CFLAGS" = "" ; then
|
||||
CFLAGS="-O"
|
||||
elif test "$ac_cv_prog_gcc" = "yes" ; then
|
||||
case "$CFLAGS" in
|
||||
*"-g -O"*)
|
||||
#echo "using -g as default gcc CFLAGS" 1>&6
|
||||
CFLAGS=`echo $CFLAGS | sed 's/-g\ -O/-O/'`
|
||||
;;
|
||||
*"-O -g"*)
|
||||
# Leave the -g, but remove all -O options.
|
||||
#echo "using -g as default gcc CFLAGS" 1>&6
|
||||
CFLAGS=`echo $CFLAGS | sed 's/-O\ -g/-O/'`
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_PROTOTYPES, [
|
||||
AC_MSG_CHECKING(if the compiler supports function prototypes)
|
||||
AC_TRY_COMPILE(,[extern void exit(int status);],[wi_cv_prototypes=yes
|
||||
AC_DEFINE(PROTOTYPES)],wi_cv_prototypes=no)
|
||||
AC_MSG_RESULT($wi_cv_prototypes)
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_ANSI_C, [
|
||||
AC_MSG_CHECKING(ANSI-style function definitions)
|
||||
AC_TRY_COMPILE(,[int blubb(int x) { return 0; }],[wi_cv_ansi_funcs=yes
|
||||
AC_DEFINE(ANSI_FUNCS)],wi_cv_ansi_funcs=no)
|
||||
AC_MSG_RESULT($wi_cv_ansi_funcs)
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_HEADER_SYS_SELECT_H, [
|
||||
# See if <sys/select.h> is includable after <sys/time.h>
|
||||
if test "$ac_cv_header_sys_time_h" = no ; then
|
||||
AC_CHECK_HEADERS(sys/time.h sys/select.h)
|
||||
else
|
||||
AC_CHECK_HEADERS(sys/select.h)
|
||||
fi
|
||||
if test "$ac_cv_header_sys_select_h" = yes ; then
|
||||
AC_MSG_CHECKING([if <sys/select.h> is compatible with <sys/time.h>])
|
||||
selecth=yes
|
||||
if test "$ac_cv_header_sys_time_h" = yes ; then
|
||||
AC_TRY_COMPILE([#include <sys/time.h>
|
||||
#include <sys/select.h>],[
|
||||
fd_set a;
|
||||
struct timeval tmval;
|
||||
|
||||
tmval.tv_sec = 0;],selecth=yes,selecth=no)
|
||||
|
||||
if test "$selecth" = yes ; then
|
||||
AC_DEFINE(CAN_USE_SYS_SELECT_H)
|
||||
fi
|
||||
fi
|
||||
AC_MSG_RESULT($selecth)
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_LIB_RESOLV, [
|
||||
# See if we could access two well-known sites without help of any special
|
||||
# libraries, like resolv.
|
||||
|
||||
AC_TRY_RUN([
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
|
||||
main()
|
||||
{
|
||||
struct hostent *hp1, *hp2;
|
||||
int result;
|
||||
|
||||
hp1 = gethostbyname("gatekeeper.dec.com");
|
||||
hp2 = gethostbyname("ftp.ncsa.uiuc.edu");
|
||||
result = ((hp1 != (struct hostent *) 0) && (hp2 != (struct hostent *) 0));
|
||||
exit(! result);
|
||||
}],look_for_resolv=no,look_for_resolv=yes,look_for_resolv=yes)
|
||||
|
||||
AC_MSG_CHECKING([if we need to look for -lresolv])
|
||||
AC_MSG_RESULT($look_for_resolv)
|
||||
if test "$look_for_resolv" = yes ; then
|
||||
AC_CHECK_LIB(resolv,main)
|
||||
else
|
||||
ac_cv_lib_resolv=no
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
|
||||
AC_DEFUN(wi_LIB_NSL, [
|
||||
AC_MSG_CHECKING(if we can use -lnsl)
|
||||
ac_save_LIBS="$LIBS";
|
||||
LIBS="$LIBS -lnsl";
|
||||
AC_CACHE_VAL(r_cv_use_libnsl, [
|
||||
AC_TRY_RUN(
|
||||
main() { if (getpwuid(getuid())) exit(0); exit(-1); },
|
||||
nc_cv_use_libnsl=yes, nc_cv_use_libnsl=no, nc_cv_use_libnsl=no)
|
||||
])
|
||||
if test "$nc_cv_use_libnsl" = "no"; then LIBS="$ac_save_LIBS"; fi
|
||||
AC_MSG_RESULT($nc_cv_use_libnsl)
|
||||
])dnl
|
||||
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
|
||||
AC_DEFUN(nc_PATH_PROG_ZCAT, [
|
||||
AC_PATH_PROG(GZCAT,gzcat)
|
||||
AC_PATH_PROG(ZCAT,zcat)
|
||||
if test "x$GZCAT" = x ; then
|
||||
if test "x$ZCAT" != x ; then
|
||||
# See if zcat is really gzcat. gzcat has a --version option, regular
|
||||
# zcat does not.
|
||||
AC_MSG_CHECKING(if zcat is really gzcat in disguise)
|
||||
if $ZCAT --version 2> /dev/null ; then
|
||||
AC_DEFINE_UNQUOTED(GZCAT, "$ZCAT")
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
fi
|
||||
else
|
||||
AC_DEFINE_UNQUOTED(GZCAT, "$GZCAT")
|
||||
fi
|
||||
|
||||
if test "x$ZCAT" != x ; then
|
||||
AC_DEFINE_UNQUOTED(ZCAT, "$ZCAT")
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_SYSV_EXTRA_DIRS, [
|
||||
# Use System V because their curses extensions are required. This must
|
||||
# be done early so we use the -I and -L in the library checks also.
|
||||
# This is mostly a Solaris/SunOS hack. Note that doing this will also
|
||||
# use all of the other System V libraries and headers.
|
||||
|
||||
AC_MSG_CHECKING(for alternative System V libraries)
|
||||
if test -f /usr/5include/curses.h ; then
|
||||
CPPFLAGS="$CPPFLAGS -I/usr/5include"
|
||||
LDFLAGS="$LDFLAGS -L/usr/5lib"
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_DEFINE_UNAME, [
|
||||
# Get first 127 chars of all uname information. Some folks have
|
||||
# way too much stuff there, so grab only the first 127.
|
||||
unam=`uname -a 2>/dev/null | cut -c1-127`
|
||||
if test "$unam" != "" ; then
|
||||
AC_DEFINE_UNQUOTED(UNAME, "$unam")
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_DEFUN(wi_READLINE_WITH_NCURSES, [
|
||||
# Readline and Ncurses could both define "backspace".
|
||||
# Warn about this if we have both things in our definitions list.
|
||||
|
||||
if test "$ac_cv_lib_readline" = yes && test "$ac_cv_lib_ncurses" = yes ; then
|
||||
|
||||
AC_MSG_CHECKING(if readline and ncurses will link together)
|
||||
j="$LIBS"
|
||||
LIBS="-lreadline -lncurses"
|
||||
AC_TRY_LINK(,[
|
||||
readline("prompt");
|
||||
endwin();
|
||||
],k=yes,k=no)
|
||||
if test "$k" = no ; then
|
||||
AC_MSG_RESULT(no)
|
||||
# Remove '-lreadline' from LIBS.
|
||||
LIBS=`echo $j | sed s/-lreadline//g`
|
||||
ac_cv_lib_readline=no
|
||||
AC_WARN([The versions of GNU readline and ncurses you have installed on this system
|
||||
can't be used together, because they use the same symbol, backspace. If
|
||||
possible, recompile one of the libraries with -Dbackspace=back_space, then
|
||||
re-run configure.])
|
||||
|
||||
else
|
||||
AC_MSG_RESULT(yes)
|
||||
LIBS="$j"
|
||||
fi
|
||||
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
|
||||
dnl AC_EXT_DAYLIGHT
|
||||
dnl Check for an external variable daylight. Stolen from w3c-libwww.
|
||||
AC_DEFUN(AC_EXT_DAYLIGHT,
|
||||
[ AC_MSG_CHECKING(int daylight variable)
|
||||
AC_TRY_COMPILE([#include <time.h>], [return daylight;],
|
||||
have_daylight=yes,
|
||||
have_daylight=no)
|
||||
AC_MSG_RESULT($have_daylight)
|
||||
])dnl
|
||||
|
||||
dnl AC_EXT_TIMEZONE
|
||||
dnl Check for an external variable timezone. Stolen from tcl-8.0.
|
||||
AC_DEFUN(AC_EXT_TIMEZONE,
|
||||
[
|
||||
#
|
||||
# Its important to include time.h in this check, as some systems (like convex)
|
||||
# have timezone functions, etc.
|
||||
#
|
||||
have_timezone=no
|
||||
AC_MSG_CHECKING([long timezone variable])
|
||||
AC_TRY_COMPILE([#include <time.h>],
|
||||
[extern long timezone;
|
||||
timezone += 1;
|
||||
exit (0);],
|
||||
[have_timezone=yes
|
||||
AC_MSG_RESULT(yes)],
|
||||
AC_MSG_RESULT(no))
|
||||
|
||||
#
|
||||
# On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
|
||||
#
|
||||
if test "$have_timezone" = no; then
|
||||
AC_MSG_CHECKING([time_t timezone variable])
|
||||
AC_TRY_COMPILE([#include <time.h>],
|
||||
[extern time_t timezone;
|
||||
timezone += 1;
|
||||
exit (0);],
|
||||
[have_timezone=yes
|
||||
AC_MSG_RESULT(yes)],
|
||||
AC_MSG_RESULT(no))
|
||||
fi
|
||||
])dnl
|
||||
|
||||
## AC_BZ_SET_COMPILER: Addition by Theodore Papadopoulo
|
||||
## Patch by Jim McKelvey: change sed -e 's/ /@/g' to sed -e 's/ /@/'
|
||||
AC_DEFUN(AC_SG_SET_COMPILER,
|
||||
[cxxwith=`echo $1 | sed -e 's/ /@/'`
|
||||
case "$cxxwith" in
|
||||
*:*@*) # Full initialization syntax
|
||||
CXX=`echo "$cxxwith" | sed -n -e 's/.*:\(.*\)@.*/\1/p'`
|
||||
CXXFLAGS=`echo "$cxxwith" | sed -n -e 's/.*:.*@\(.*\)/\1/p'`
|
||||
;;
|
||||
*:*) # Simple initialization syntax
|
||||
CXX=`echo "$cxxwith" | sed -n -e 's/.*:\(.*\)/\1/p'`
|
||||
CXXFLAGS=$3
|
||||
;;
|
||||
*) # Default values
|
||||
CXX=$2
|
||||
CXXFLAGS=$3
|
||||
CC="$2 --c"
|
||||
## CFLAGS=
|
||||
;;
|
||||
esac])
|
||||
39
am2dsp.cfg
Normal file
39
am2dsp.cfg
Normal file
@@ -0,0 +1,39 @@
|
||||
type = StaticLibrary,Multithreaded,
|
||||
exclude_dir = threads
|
||||
|
||||
include_path = .
|
||||
include_path = ..
|
||||
include_path = .\SimGear
|
||||
include_path = .\SimGear\metakit-2.4.3\include
|
||||
include_path = ..\SimGear\zlib-1.1.4
|
||||
|
||||
define = HAVE_CONFIG_H
|
||||
|
||||
add_project = .\SimGear\metakit-2.4.3\win\msvc60\mklib.dsp,mklib
|
||||
add_project = .\SimGear\zlib.dsp,zlib
|
||||
|
||||
# Rule to create simgear_config.h
|
||||
add_source_file = SOURCE=.\simgear\simgear_config.h.vc5\
|
||||
\
|
||||
!IF "$(CFG)" == "SimGear - Win32 Release"\
|
||||
\
|
||||
# Begin Custom Build - Creating config.h\
|
||||
InputPath=.\simgear\simgear_config.h.vc5\
|
||||
\
|
||||
".\simgear\simgear_config.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\
|
||||
copy .\simgear\simgear_config.h.vc5 .\simgear\simgear_config.h\
|
||||
\
|
||||
# End Custom Build\
|
||||
\
|
||||
!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"\
|
||||
\
|
||||
# Begin Custom Build - Creating config.h\
|
||||
InputPath=.\simgear\simgear_config.h.vc5\
|
||||
\
|
||||
".\simgear\simgear_config.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\
|
||||
copy .\simgear\simgear_config.h.vc5 .\simgear\simgear_config.h\
|
||||
\
|
||||
# End Custom Build\
|
||||
\
|
||||
!ENDIF\
|
||||
|
||||
52
autogen.sh
Executable file
52
autogen.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
|
||||
OSTYPE=`uname -s`
|
||||
MACHINE=`uname -m`
|
||||
AUTO_MAKE_VERSION=`automake --version | head -1 | awk '{print $4}' | sed -e 's/\.\([0-9]*\).*/\1/'`
|
||||
if test $AUTO_MAKE_VERSION -lt 15; then
|
||||
echo ""
|
||||
echo "You need to upgrade to automake version 1.5 or greater."
|
||||
echo "Most distributions have packages available to install or you can"
|
||||
echo "find the source for the most recent version at"
|
||||
echo "ftp://ftp.gnu.org/gnu/automake"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Host info: $OSTYPE $MACHINE"
|
||||
echo -n " automake: `automake --version | head -1 | awk '{print $4}'`"
|
||||
echo " ($AUTO_MAKE_VERSION)"
|
||||
echo ""
|
||||
|
||||
echo "Running aclocal"
|
||||
aclocal
|
||||
|
||||
echo "Running autoheader"
|
||||
autoheader
|
||||
if [ ! -e simgear/simgear_config.h.in ]; then
|
||||
echo "ERROR: autoheader didn't create simgear/simgear_config.h.in!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Running automake --add-missing"
|
||||
automake --add-missing
|
||||
|
||||
echo "Running autoconf"
|
||||
autoconf
|
||||
|
||||
if [ ! -e configure ]; then
|
||||
echo "ERROR: configure was not created!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "======================================"
|
||||
|
||||
if [ -f config.cache ]; then
|
||||
echo "config.cache exists. Removing the config.cache file will force"
|
||||
echo "the ./configure script to rerun all it's tests rather than using"
|
||||
echo "the previously cached values."
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo "Now you are ready to run './configure'"
|
||||
echo "======================================"
|
||||
407
configure.ac
Normal file
407
configure.ac
Normal file
@@ -0,0 +1,407 @@
|
||||
dnl Process this file with aclocal ; automake -a ; autoconf to produce a
|
||||
dnl working configure script.
|
||||
dnl
|
||||
dnl $Id$
|
||||
|
||||
AC_INIT
|
||||
AC_CONFIG_SRCDIR([simgear/bucket/newbucket.cxx])
|
||||
|
||||
# Require at least automake 2.52
|
||||
AC_PREREQ(2.52)
|
||||
|
||||
dnl Initialize the automake stuff
|
||||
AM_INIT_AUTOMAKE(SimGear, 0.2.0)
|
||||
|
||||
dnl Specify KAI C++ compiler and flags.
|
||||
dnl Borrowed with slight modification from blitz distribution.
|
||||
AC_ARG_WITH(cxx,
|
||||
[ --with-cxx=COMPILER[:name-flags] set options for COMPILER (KCC)],
|
||||
[case "$withval" in
|
||||
KCC*) # KAI C++ http://www.kai.com/
|
||||
echo "Configuring for KAI C++"
|
||||
AC_SG_SET_COMPILER($withval,"KCC","--restrict --strict_warnings")
|
||||
CXX_OPTIMIZE_FLAGS=="+K3 -O3"
|
||||
CXX_DEBUG_FLAGS="-g +K0"
|
||||
;;
|
||||
esac
|
||||
])
|
||||
|
||||
echo CXX = $CXX
|
||||
echo CC = $CC
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_PROG_CXX
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
|
||||
|
||||
# Used on the Irix platform
|
||||
AR="ar"
|
||||
ARFLAGS="cru"
|
||||
OS=`uname -s`
|
||||
if test "$OS" = "IRIX" -o "$OS" = "IRIX64"; then
|
||||
if test "$CXX" = "CC"; then
|
||||
AR="CC -ar"
|
||||
ARFLAGS="-o"
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(AR)
|
||||
AC_SUBST(ARFLAGS)
|
||||
|
||||
|
||||
if echo $includedir | egrep "simgear$" > /dev/null; then
|
||||
echo "includedir is" $includedir "libdir is" $libdir
|
||||
else
|
||||
includedir="${includedir}/simgear"
|
||||
echo "includedir changed to" $includedir "libdir is" $libdir
|
||||
fi
|
||||
|
||||
# set logging default value
|
||||
# with_logging=yes
|
||||
AC_ARG_WITH(logging, [ --with-logging Include logging output (default)])
|
||||
if test "x$with_logging" = "xno" ; then
|
||||
AC_DEFINE([FG_NDEBUG], 1, [Define for no logging output])
|
||||
fi
|
||||
|
||||
# Specify if we want to build with Norman's jpeg image server support.
|
||||
# This requires libjpeg to be installed and available.
|
||||
# Default to with_jpeg_server=no
|
||||
JPEGLIB=''
|
||||
AC_ARG_WITH(jpeg_factory, [ --with-jpeg-factory Include Norman's jpeg image factory support code])
|
||||
if test "x$with_jpeg_factory" = "xyes" ; then
|
||||
echo "Building with Norman's jpeg image factory support"
|
||||
AC_CHECK_LIB(jpeg, jpeg_start_compress)
|
||||
if test "x$ac_cv_lib_jpeg_jpeg_start_compress" != "xyes" ; then
|
||||
echo
|
||||
echo "In order to build the jpeg factory code you need libjpeg installed."
|
||||
echo "otherwise please configure with the --with-jpeg-sever=no option"
|
||||
echo
|
||||
echo "libjpeg is available at :"
|
||||
echo " ftp://ftp.uu.net in the directory graphics/jpeg"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Building without Norman's jpeg image server support"
|
||||
fi
|
||||
AM_CONDITIONAL(ENABLE_JPEG_SERVER, test "x$with_jpeg_factory" = "xyes")
|
||||
|
||||
|
||||
dnl Check for MS Windows environment
|
||||
AC_CHECK_HEADER(windows.h)
|
||||
|
||||
AC_EGREP_CPP(yes,
|
||||
[#ifdef __MINGW32__
|
||||
yes
|
||||
#endif
|
||||
],is_mingw=yes, is_mingw=no)
|
||||
|
||||
echo "IS_MINGW = $is_mingw"
|
||||
AM_CONDITIONAL(IS_MINGW, test "x$is_mingw" = "xyes")
|
||||
|
||||
AC_EGREP_CPP(yes,
|
||||
[#ifdef __CYGWIN__
|
||||
yes
|
||||
#endif
|
||||
],is_cygwin=yes, is_cygwin=no)
|
||||
|
||||
echo "IS_CYGWIN = $is_cygwin"
|
||||
AM_CONDITIONAL(IS_CYGWIN, test "x$is_cygwin" = "xyes")
|
||||
|
||||
if test "x$HOSTTYPE" != "xmacintosh" -a "x$is_mingw" != "xyes"; then
|
||||
dnl extra library and include directories
|
||||
EXTRA_DIRS="/usr/local /usr/X11R6"
|
||||
|
||||
if test -d /opt/X11R6 ; then
|
||||
EXTRA_DIRS="$EXTRA_DIRS /opt/X11R6"
|
||||
fi
|
||||
fi
|
||||
|
||||
wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
|
||||
|
||||
dnl Using AM_CONDITIONAL is a step out of the protected little
|
||||
dnl automake fold so it is potentially dangerous. But, we are
|
||||
dnl beginning to run into cases where the standard checks are not
|
||||
dnl enough. AM_CONDITIONALS are then referenced to conditionally
|
||||
dnl build a Makefile.in from a Makefile.am which lets us define custom
|
||||
dnl includes, compile alternative source files, etc.
|
||||
|
||||
dnl X11 might be installed on Mac OS X, don't want to use it if it is.
|
||||
if test "x$HOSTTYPE" != "xmacintosh" ; then
|
||||
dnl Check for X11 (fancy)
|
||||
AC_PATH_XTRA
|
||||
fi
|
||||
|
||||
dnl Checks for libraries.
|
||||
|
||||
null_LIBS="$LIBS"
|
||||
|
||||
AC_CHECK_LIB(m, cos)
|
||||
|
||||
base_LIBS="$LIBS"
|
||||
|
||||
dnl Thread related checks
|
||||
AC_CHECK_LIB(pthread, pthread_exit)
|
||||
AC_CHECK_HEADER(pthread.h)
|
||||
if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
|
||||
CXXFLAGS="$CXXFLAGS -D_REENTRANT"
|
||||
CFLAGS="$CFLAGS -D_REENTRANT"
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes")
|
||||
|
||||
AC_CHECK_LIB(socket, socket)
|
||||
|
||||
dnl X11 might be installed, but we don't want to use it for OSX -dw-
|
||||
if test "x$HOSTTYPE" != "xmacintosh" ; then
|
||||
AC_CHECK_LIB(X11, XCreateWindow)
|
||||
AC_CHECK_LIB(Xext, XShmCreateImage)
|
||||
AC_CHECK_LIB(Xi, XGetExtensionVersion)
|
||||
AC_CHECK_LIB(ICE, IceOpenConnection)
|
||||
AC_CHECK_LIB(SM, SmcOpenConnection)
|
||||
AC_CHECK_LIB(Xt, XtMalloc)
|
||||
AC_CHECK_LIB(Xmu, XmuLookupStandardColormap)
|
||||
fi
|
||||
|
||||
dnl check for OpenGL related libraries
|
||||
|
||||
if test "x$HOSTTYPE" = "xmacintosh" ; then
|
||||
dnl Macintosh OSX
|
||||
LIBS="$LIBS -framework OpenGL -framework GLUT"
|
||||
elif test "x$ac_cv_header_windows_h" != "xyes" ; then
|
||||
dnl Reasonable stuff for X-Windows based machines
|
||||
|
||||
AC_CHECK_LIB(GLcore, glNewList)
|
||||
if test "x$ac_cv_lib_GLcore_glNewList" = "xno" ; then
|
||||
dnl if no GLcore, check for GL
|
||||
AC_CHECK_LIB(GL, glNewList)
|
||||
if test "x$ac_cv_lib_GL_glNewList" = "xno" ; then
|
||||
dnl if no GL, check for MesaGL
|
||||
AC_CHECK_LIB(MesaGL, glNewList)
|
||||
fi
|
||||
else
|
||||
dnl if GLcore found, then also check for GL
|
||||
AC_CHECK_LIB(GL, glXCreateContext)
|
||||
fi
|
||||
|
||||
dnl if using mesa, check for xmesa.h
|
||||
if test "x$ac_cv_lib_MesaGL_glNewList" = "xyes" ; then
|
||||
AC_CHECK_HEADER(GL/fxmesa.h)
|
||||
if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
|
||||
AC_DEFINE([XMESA], 1, [Define for fxmesa])
|
||||
AC_DEFINE([FX], 1, [Define for fxmesa])
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB(GLU, gluLookAt)
|
||||
if test "x$ac_cv_lib_GLU_gluLookAt" = "xno" ; then
|
||||
dnl if no GLU, check for MesaGLU
|
||||
AC_CHECK_LIB(MesaGLU, gluLookAt)
|
||||
fi
|
||||
|
||||
dnl check for glut
|
||||
AC_CHECK_LIB(glut, glutGetModifiers)
|
||||
|
||||
dnl test for glutGameModeString, but avoid adding glut a second time into
|
||||
dnl the list of libraries
|
||||
save_LIBS="$LIBS"
|
||||
AC_CHECK_LIB(glut, glutGameModeString)
|
||||
LIBS="$save_LIBS"
|
||||
else
|
||||
dnl Win32 libs
|
||||
|
||||
echo Win32 specific hacks...
|
||||
AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
|
||||
|
||||
dnl just define these to true and hope for the best
|
||||
ac_cv_lib_glut_glutGetModifiers="yes"
|
||||
ac_cv_lib_glut_glutGameModeString="yes"
|
||||
|
||||
if test "x$with_sgi_opengl" = "xyes" ; then
|
||||
echo "Building with glut.dll, glu.dll, and opengl.dll"
|
||||
WIN32_GLUT=glut
|
||||
WIN32_GLU=glu
|
||||
WIN32_OPENGL=opengl
|
||||
else
|
||||
echo "Building with glut32.dll, glu32.dll, and opengl32.dll"
|
||||
WIN32_GLUT=glut32
|
||||
WIN32_GLU=glu32
|
||||
WIN32_OPENGL=opengl32
|
||||
fi
|
||||
|
||||
LIBS="$LIBS -l${WIN32_GLUT} -l${WIN32_GLU} -l${WIN32_OPENGL}"
|
||||
LIBS="$LIBS -luser32 -lgdi32"
|
||||
if test "x$is_mingw" = "xyes" ; then
|
||||
EXTRA_DIRS="${EXTRA_DIRS}"
|
||||
fi
|
||||
echo "Will link apps with $LIBS"
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_lib_glut_glutGetModifiers" = "xno"; then
|
||||
echo
|
||||
echo "Unable to find the necessary OpenGL or GLUT libraries."
|
||||
echo "See config.log for automated test details and results ..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_lib_glut_glutGameModeString" = "xno"; then
|
||||
echo
|
||||
echo "Your version of glut doesn't support game mode."
|
||||
echo "You need to install the latest version of glut. If your"
|
||||
echo "distribution doesn't provide a newer version, you can get the source"
|
||||
echo "code from:"
|
||||
echo
|
||||
echo " http://reality.sgi.com/opengl/glut3/glut3.html"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
opengl_LIBS="$LIBS"
|
||||
LIBS="$base_LIBS"
|
||||
|
||||
AC_SUBST(base_LIBS)
|
||||
AC_SUBST(opengl_LIBS)
|
||||
|
||||
AM_CONDITIONAL(HAVE_XWINDOWS, test "x$ac_cv_lib_X11_XCreateWindow" = "xyes" )
|
||||
|
||||
# The following are C++ items that need to be tested for with the c++
|
||||
# compiler
|
||||
|
||||
AC_LANG_PUSH(C++)
|
||||
|
||||
dnl Check for "plib" without which we cannot go on
|
||||
AC_CHECK_HEADER(plib/ul.h)
|
||||
if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
|
||||
echo
|
||||
echo "You *must* have the plib library installed on your system to build"
|
||||
echo "SimGear!"
|
||||
echo
|
||||
echo "Please see README.plib for more details."
|
||||
echo
|
||||
echo "configure aborted."
|
||||
exit
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for plib 1.6.0 or newer])
|
||||
AC_TRY_RUN([
|
||||
#include <plib/ul.h>
|
||||
|
||||
#define MIN_PLIB_VERSION 160
|
||||
|
||||
int main() {
|
||||
int major, minor, micro;
|
||||
|
||||
if ( PLIB_VERSION < MIN_PLIB_VERSION ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
],
|
||||
AC_MSG_RESULT(yes),
|
||||
[AC_MSG_RESULT(wrong version);
|
||||
AC_MSG_ERROR([Install plib 1.6.0 or later first...])],
|
||||
AC_MSG_RESULT(yes)
|
||||
)
|
||||
|
||||
dnl Check for system installed metakit
|
||||
AC_CHECK_HEADER(mk4.h)
|
||||
if test "x$ac_cv_header_mk4_h" != "xyes"; then
|
||||
echo
|
||||
echo "Metakit not found, you will need to install this first."
|
||||
echo "Please read the README.metakit for more information."
|
||||
exit
|
||||
fi
|
||||
|
||||
AC_LANG_POP
|
||||
|
||||
dnl Specify if we want logging (testing build) or not (release build)
|
||||
|
||||
dnl Check for system installed zlib
|
||||
AC_CHECK_HEADER(zlib.h)
|
||||
if test "x$ac_cv_header_zlib_h" != "xyes"; then
|
||||
echo
|
||||
echo "zlib not found, you will need to install this first."
|
||||
echo "Please read the README.zlib for more information."
|
||||
exit
|
||||
fi
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS( \
|
||||
fcntl.h getopt.h malloc.h memory.h stdint.h stdlib.h sys/param.h \
|
||||
sys/stat.h sys/time.h sys/timeb.h unistd.h windows.h winbase.h values.h )
|
||||
|
||||
if test "x$ac_cv_header_stdint_h" = "xyes"; then
|
||||
AC_DEFINE([HAVE_STDINT_H], 1, [Define if stdint.h exists])
|
||||
fi
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
AC_TYPE_SIZE_T
|
||||
AC_HEADER_TIME
|
||||
AC_STRUCT_TM
|
||||
|
||||
dnl Checks for library functions.
|
||||
AC_TYPE_SIGNAL
|
||||
AC_FUNC_VPRINTF
|
||||
AC_CHECK_FUNCS( ftime gettimeofday timegm memcpy bcopy mktime strstr rand \
|
||||
random drand48 setitimer getitimer signal GetLocalTime rint getrusage )
|
||||
|
||||
AM_CONFIG_HEADER(simgear/simgear_config.h)
|
||||
|
||||
AC_CONFIG_FILES([ \
|
||||
Makefile \
|
||||
SimGear.spec \
|
||||
src-libs/Makefile \
|
||||
simgear/Makefile \
|
||||
simgear/version.h \
|
||||
simgear/bucket/Makefile \
|
||||
simgear/debug/Makefile \
|
||||
simgear/ephemeris/Makefile \
|
||||
simgear/interpreter/Makefile \
|
||||
simgear/io/Makefile \
|
||||
simgear/magvar/Makefile \
|
||||
simgear/math/Makefile \
|
||||
simgear/metar/Makefile \
|
||||
simgear/misc/Makefile \
|
||||
simgear/route/Makefile \
|
||||
simgear/screen/Makefile \
|
||||
simgear/serial/Makefile \
|
||||
simgear/sky/Makefile \
|
||||
simgear/threads/Makefile \
|
||||
simgear/timing/Makefile \
|
||||
simgear/xgl/Makefile \
|
||||
simgear/xml/Makefile \
|
||||
])
|
||||
AC_OUTPUT
|
||||
|
||||
|
||||
echo ""
|
||||
echo "Configure Summary"
|
||||
echo "================="
|
||||
|
||||
echo "Prefix: $prefix"
|
||||
|
||||
if test "x$with_logging" != "x"; then
|
||||
echo "Debug messages: $with_logging"
|
||||
else
|
||||
echo "Debug messages: yes"
|
||||
fi
|
||||
|
||||
echo -n "Automake version: ($AUTO_MAKE_VERSION) "
|
||||
automake --version | head -1
|
||||
|
||||
if test "x$with_jpeg_factory" = "xyes"; then
|
||||
echo "With JPEG Factory support"
|
||||
else
|
||||
echo "Without JPEG Factory support"
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
|
||||
echo "Threads: pthread lib found."
|
||||
else
|
||||
echo "Threads: no threads (pthread lib not found.)"
|
||||
fi
|
||||
42
mksymlinks.sh
Executable file
42
mksymlinks.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#! /bin/sh
|
||||
|
||||
echo ""
|
||||
echo "running $0 to rebuild simgear include links"
|
||||
|
||||
# toast the old directory
|
||||
rm -rf src/simgear
|
||||
mkdir src/simgear
|
||||
mkdir src/simgear/bucket
|
||||
mkdir src/simgear/debug
|
||||
mkdir src/simgear/math
|
||||
mkdir src/simgear/misc
|
||||
mkdir src/simgear/screen
|
||||
mkdir src/simgear/serial
|
||||
mkdir src/simgear/xgl
|
||||
mkdir src/simgear/zlib
|
||||
|
||||
# build new links
|
||||
ln -s ../include/compiler.h src/simgear/compiler.h
|
||||
ln -s ../include/constants.h src/simgear/constants.h
|
||||
ln -s ../include/fg_traits.hxx src/simgear/fg_traits.hxx
|
||||
ln -s ../include/fg_zlib.h src/simgear/fg_zlib.h
|
||||
ln -s ../include/version.h src/simgear/version.h
|
||||
|
||||
ln -s ../../bucket/newbucket.hxx src/simgear/bucket/newbucket.hxx
|
||||
|
||||
ln -s ../../debug/debug_types.h src/simgear/debug/debug_types.h
|
||||
ln -s ../../debug/logstream.hxx src/simgear/debug/logstream.hxx
|
||||
|
||||
ln -s ../../math/fg_memory.h src/simgear/math/fg_memory.h
|
||||
ln -s ../../math/fg_types.hxx src/simgear/math/fg_types.hxx
|
||||
ln -s ../../math/point3d.hxx src/simgear/math/point3d.hxx
|
||||
ln -s ../../math/polar3d.hxx src/simgear/math/polar3d.hxx
|
||||
|
||||
ln -s ../../misc/fgpath.hxx src/simgear/misc/fgpath.hxx
|
||||
ln -s ../../misc/fgstream.hxx src/simgear/misc/fgstream.hxx
|
||||
ln -s ../../misc/zfstream.hxx src/simgear/misc/zfstream.hxx
|
||||
|
||||
ln -s ../../xgl/xgl.h src/simgear/xgl/xgl.h
|
||||
|
||||
ln -s ../../zlib/zlib.h src/simgear/zlib/zlib.h
|
||||
ln -s ../../zlib/zconf.h src/simgear/zlib/zconf.h
|
||||
7
simgear/.cvsignore
Normal file
7
simgear/.cvsignore
Normal file
@@ -0,0 +1,7 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
simgear_config.h
|
||||
simgear_config.h.in
|
||||
stamp-h
|
||||
stamp-h.in
|
||||
version.h
|
||||
33
simgear/Makefile.am
Normal file
33
simgear/Makefile.am
Normal file
@@ -0,0 +1,33 @@
|
||||
if HAVE_THREADS
|
||||
SGTHREAD_DIR = threads
|
||||
else
|
||||
SGTHREAD_DIR =
|
||||
endif
|
||||
|
||||
# METAR_DIRS =
|
||||
METAR_DIRS = metar
|
||||
|
||||
EXTRA_DIST = simgear_config.h.vc5 version.h.in
|
||||
|
||||
include_HEADERS = \
|
||||
compiler.h constants.h sg_inlines.h sg_traits.hxx sg_zlib.h version.h
|
||||
|
||||
SUBDIRS = \
|
||||
xml \
|
||||
debug \
|
||||
misc \
|
||||
bucket \
|
||||
ephemeris \
|
||||
io \
|
||||
magvar \
|
||||
math \
|
||||
$(METAR_DIRS) \
|
||||
route \
|
||||
screen \
|
||||
serial \
|
||||
sky \
|
||||
$(SGTHREAD_DIR) \
|
||||
timing \
|
||||
xgl
|
||||
|
||||
DIST_SUBDIRS = $(SUBDIRS) interpreter
|
||||
3
simgear/bucket/.cvsignore
Normal file
3
simgear/bucket/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
17
simgear/bucket/Makefile.am
Normal file
17
simgear/bucket/Makefile.am
Normal file
@@ -0,0 +1,17 @@
|
||||
includedir = @includedir@/bucket
|
||||
|
||||
lib_LIBRARIES = libsgbucket.a
|
||||
|
||||
include_HEADERS = newbucket.hxx
|
||||
|
||||
libsgbucket_a_SOURCES = newbucket.cxx
|
||||
|
||||
# noinst_PROGRAMS = testbucket
|
||||
|
||||
# testbucket_SOURCES = testbucket.cxx
|
||||
|
||||
# testbucket_LDADD = \
|
||||
# $(top_builddir)/bucket/libsgbucket.a \
|
||||
# $(top_builddir)/misc/libsgmisc.a
|
||||
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
291
simgear/bucket/newbucket.cxx
Normal file
291
simgear/bucket/newbucket.cxx
Normal file
@@ -0,0 +1,291 @@
|
||||
/**************************************************************************
|
||||
* newbucket.hxx -- new bucket routines for better world modeling
|
||||
*
|
||||
* Written by Curtis L. Olson, started February 1999.
|
||||
*
|
||||
* Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
||||
#include "newbucket.hxx"
|
||||
|
||||
|
||||
// default constructor
|
||||
SGBucket::SGBucket() {
|
||||
}
|
||||
|
||||
|
||||
// constructor for specified location
|
||||
SGBucket::SGBucket(const double dlon, const double dlat) {
|
||||
set_bucket(dlon, dlat);
|
||||
}
|
||||
|
||||
|
||||
// create an impossible bucket if false
|
||||
SGBucket::SGBucket(const bool is_good) {
|
||||
set_bucket(0.0, 0.0);
|
||||
if ( !is_good ) {
|
||||
lon = -1000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Parse a unique scenery tile index and find the lon, lat, x, and y
|
||||
SGBucket::SGBucket(const long int bindex) {
|
||||
long int index = bindex;
|
||||
|
||||
lon = index >> 14;
|
||||
index -= lon << 14;
|
||||
lon -= 180;
|
||||
|
||||
lat = index >> 6;
|
||||
index -= lat << 6;
|
||||
lat -= 90;
|
||||
|
||||
y = index >> 3;
|
||||
index -= y << 3;
|
||||
|
||||
x = index;
|
||||
}
|
||||
|
||||
|
||||
// default destructor
|
||||
SGBucket::~SGBucket() {
|
||||
}
|
||||
|
||||
|
||||
// Set the bucket params for the specified lat and lon
|
||||
void SGBucket::set_bucket( double *lonlat ) {
|
||||
set_bucket( lonlat[0], lonlat[1] );
|
||||
}
|
||||
|
||||
|
||||
// Set the bucket params for the specified lat and lon
|
||||
void SGBucket::set_bucket( double dlon, double dlat ) {
|
||||
//
|
||||
// latitude first
|
||||
//
|
||||
double span = sg_bucket_span( dlat );
|
||||
double diff = dlon - (double)(int)dlon;
|
||||
|
||||
// cout << "diff = " << diff << " span = " << span << endl;
|
||||
|
||||
if ( (dlon >= 0) || (fabs(diff) < SG_EPSILON) ) {
|
||||
lon = (int)dlon;
|
||||
} else {
|
||||
lon = (int)dlon - 1;
|
||||
}
|
||||
|
||||
// find subdivision or super lon if needed
|
||||
if ( span < SG_EPSILON ) {
|
||||
// polar cap
|
||||
lon = 0;
|
||||
x = 0;
|
||||
} else if ( span <= 1.0 ) {
|
||||
x = (int)((dlon - lon) / span);
|
||||
} else {
|
||||
if ( (dlon >= 0) || (fabs(diff) < SG_EPSILON) ) {
|
||||
lon = (int)( (int)(lon / span) * span);
|
||||
} else {
|
||||
// cout << " lon = " << lon
|
||||
// << " tmp = " << (int)((lon-1) / span) << endl;
|
||||
lon = (int)( (int)((lon + 1) / span) * span - span);
|
||||
if ( lon < -180 ) {
|
||||
lon = -180;
|
||||
}
|
||||
}
|
||||
x = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// then latitude
|
||||
//
|
||||
diff = dlat - (double)(int)dlat;
|
||||
|
||||
if ( (dlat >= 0) || (fabs(diff) < SG_EPSILON) ) {
|
||||
lat = (int)dlat;
|
||||
} else {
|
||||
lat = (int)dlat - 1;
|
||||
}
|
||||
y = (int)((dlat - lat) * 8);
|
||||
}
|
||||
|
||||
|
||||
// Build the path name for this bucket
|
||||
string SGBucket::gen_base_path() const {
|
||||
// long int index;
|
||||
int top_lon, top_lat, main_lon, main_lat;
|
||||
char hem, pole;
|
||||
char raw_path[256];
|
||||
|
||||
top_lon = lon / 10;
|
||||
main_lon = lon;
|
||||
if ( (lon < 0) && (top_lon * 10 != lon) ) {
|
||||
top_lon -= 1;
|
||||
}
|
||||
top_lon *= 10;
|
||||
if ( top_lon >= 0 ) {
|
||||
hem = 'e';
|
||||
} else {
|
||||
hem = 'w';
|
||||
top_lon *= -1;
|
||||
}
|
||||
if ( main_lon < 0 ) {
|
||||
main_lon *= -1;
|
||||
}
|
||||
|
||||
top_lat = lat / 10;
|
||||
main_lat = lat;
|
||||
if ( (lat < 0) && (top_lat * 10 != lat) ) {
|
||||
top_lat -= 1;
|
||||
}
|
||||
top_lat *= 10;
|
||||
if ( top_lat >= 0 ) {
|
||||
pole = 'n';
|
||||
} else {
|
||||
pole = 's';
|
||||
top_lat *= -1;
|
||||
}
|
||||
if ( main_lat < 0 ) {
|
||||
main_lat *= -1;
|
||||
}
|
||||
|
||||
sprintf(raw_path, "%c%03d%c%02d/%c%03d%c%02d",
|
||||
hem, top_lon, pole, top_lat,
|
||||
hem, main_lon, pole, main_lat);
|
||||
|
||||
SGPath path( raw_path );
|
||||
|
||||
return path.str();
|
||||
}
|
||||
|
||||
|
||||
// return width of the tile in degrees
|
||||
double SGBucket::get_width() const {
|
||||
return sg_bucket_span( get_center_lat() );
|
||||
}
|
||||
|
||||
|
||||
// return height of the tile in degrees
|
||||
double SGBucket::get_height() const {
|
||||
return SG_BUCKET_SPAN;
|
||||
}
|
||||
|
||||
|
||||
// return width of the tile in meters
|
||||
double SGBucket::get_width_m() const {
|
||||
double clat = (int)get_center_lat();
|
||||
if ( clat > 0 ) {
|
||||
clat = (int)clat + 0.5;
|
||||
} else {
|
||||
clat = (int)clat - 0.5;
|
||||
}
|
||||
double clat_rad = clat * SGD_DEGREES_TO_RADIANS;
|
||||
double cos_lat = cos( clat_rad );
|
||||
double local_radius = cos_lat * SG_EQUATORIAL_RADIUS_M;
|
||||
double local_perimeter = 2.0 * local_radius * SGD_PI;
|
||||
double degree_width = local_perimeter / 360.0;
|
||||
|
||||
return sg_bucket_span( get_center_lat() ) * degree_width;
|
||||
}
|
||||
|
||||
|
||||
// return height of the tile in meters
|
||||
double SGBucket::get_height_m() const {
|
||||
double perimeter = 2.0 * SG_EQUATORIAL_RADIUS_M * SGD_PI;
|
||||
double degree_height = perimeter / 360.0;
|
||||
|
||||
return SG_BUCKET_SPAN * degree_height;
|
||||
}
|
||||
|
||||
|
||||
// find the bucket which is offset by the specified tile units in the
|
||||
// X & Y direction. We need the current lon and lat to resolve
|
||||
// ambiguities when going from a wider tile to a narrower one above or
|
||||
// below. This assumes that we are feeding in
|
||||
SGBucket sgBucketOffset( double dlon, double dlat, int dx, int dy ) {
|
||||
SGBucket result( dlon, dlat );
|
||||
double clat = result.get_center_lat() + dy * SG_BUCKET_SPAN;
|
||||
|
||||
// walk dy units in the lat direction
|
||||
result.set_bucket( dlon, clat );
|
||||
|
||||
// find the lon span for the new latitude
|
||||
double span = sg_bucket_span( clat );
|
||||
|
||||
// walk dx units in the lon direction
|
||||
double tmp = dlon + dx * span;
|
||||
while ( tmp < -180.0 ) {
|
||||
tmp += 360.0;
|
||||
}
|
||||
while ( tmp >= 180.0 ) {
|
||||
tmp -= 360.0;
|
||||
}
|
||||
result.set_bucket( tmp, clat );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// calculate the offset between two buckets
|
||||
void sgBucketDiff( const SGBucket& b1, const SGBucket& b2, int *dx, int *dy ) {
|
||||
|
||||
// Latitude difference
|
||||
double c1_lat = b1.get_center_lat();
|
||||
double c2_lat = b2.get_center_lat();
|
||||
double diff_lat = c2_lat - c1_lat;
|
||||
|
||||
#ifdef HAVE_RINT
|
||||
*dy = (int)rint( diff_lat / SG_BUCKET_SPAN );
|
||||
#else
|
||||
if ( diff_lat > 0 ) {
|
||||
*dy = (int)( diff_lat / SG_BUCKET_SPAN + 0.5 );
|
||||
} else {
|
||||
*dy = (int)( diff_lat / SG_BUCKET_SPAN - 0.5 );
|
||||
}
|
||||
#endif
|
||||
|
||||
// longitude difference
|
||||
double c1_lon = b1.get_center_lon();
|
||||
double c2_lon = b2.get_center_lon();
|
||||
double diff_lon = c2_lon - c1_lon;
|
||||
double span;
|
||||
if ( sg_bucket_span(c1_lat) <= sg_bucket_span(c2_lat) ) {
|
||||
span = sg_bucket_span(c1_lat);
|
||||
} else {
|
||||
span = sg_bucket_span(c2_lat);
|
||||
}
|
||||
|
||||
#ifdef HAVE_RINT
|
||||
*dx = (int)rint( diff_lon / span );
|
||||
#else
|
||||
if ( diff_lon > 0 ) {
|
||||
*dx = (int)( diff_lon / span + 0.5 );
|
||||
} else {
|
||||
*dx = (int)( diff_lon / span - 0.5 );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
343
simgear/bucket/newbucket.hxx
Normal file
343
simgear/bucket/newbucket.hxx
Normal file
@@ -0,0 +1,343 @@
|
||||
/**************************************************************************
|
||||
* newbucket.hxx -- new bucket routines for better world modeling
|
||||
*
|
||||
* Written by Curtis L. Olson, started February 1999.
|
||||
*
|
||||
* Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
|
||||
/** \file newbucket.hxx
|
||||
* A class and associated utiltity functions to manage world scenery tiling.
|
||||
*/
|
||||
|
||||
#ifndef _NEWBUCKET_HXX
|
||||
#define _NEWBUCKET_HXX
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/constants.h>
|
||||
|
||||
#ifdef SG_HAVE_STD_INCLUDES
|
||||
# include <cmath>
|
||||
# include <cstdio> // sprintf()
|
||||
#else
|
||||
# include <math.h>
|
||||
# include <stdio.h> // sprintf()
|
||||
#endif
|
||||
|
||||
#include STL_IOSTREAM
|
||||
|
||||
// I don't understand ... <math.h> or <cmath> should be included
|
||||
// already depending on how you defined SG_HAVE_STD_INCLUDES, but I
|
||||
// can go ahead and add this -- CLO
|
||||
#ifdef __MWERKS__
|
||||
SG_USING_STD(sprintf);
|
||||
SG_USING_STD(fabs);
|
||||
#endif
|
||||
|
||||
#include STL_STRING
|
||||
|
||||
SG_USING_STD(string);
|
||||
|
||||
#if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )
|
||||
SG_USING_STD(ostream);
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* standard size of a bucket in degrees (1/8 of a degree)
|
||||
*/
|
||||
#define SG_BUCKET_SPAN 0.125
|
||||
|
||||
/**
|
||||
* half of a standard SG_BUCKET_SPAN
|
||||
*/
|
||||
#define SG_HALF_BUCKET_SPAN ( 0.5 * SG_BUCKET_SPAN )
|
||||
|
||||
|
||||
// return the horizontal tile span factor based on latitude
|
||||
static double sg_bucket_span( double l ) {
|
||||
if ( l >= 89.0 ) {
|
||||
return 360.0;
|
||||
} else if ( l >= 88.0 ) {
|
||||
return 8.0;
|
||||
} else if ( l >= 86.0 ) {
|
||||
return 4.0;
|
||||
} else if ( l >= 83.0 ) {
|
||||
return 2.0;
|
||||
} else if ( l >= 76.0 ) {
|
||||
return 1.0;
|
||||
} else if ( l >= 62.0 ) {
|
||||
return 0.5;
|
||||
} else if ( l >= 22.0 ) {
|
||||
return 0.25;
|
||||
} else if ( l >= -22.0 ) {
|
||||
return 0.125;
|
||||
} else if ( l >= -62.0 ) {
|
||||
return 0.25;
|
||||
} else if ( l >= -76.0 ) {
|
||||
return 0.5;
|
||||
} else if ( l >= -83.0 ) {
|
||||
return 1.0;
|
||||
} else if ( l >= -86.0 ) {
|
||||
return 2.0;
|
||||
} else if ( l >= -88.0 ) {
|
||||
return 4.0;
|
||||
} else if ( l >= -89.0 ) {
|
||||
return 8.0;
|
||||
} else {
|
||||
return 360.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A class to manage world scenery tiling.
|
||||
* This class encapsulates the world tiling scheme. It provides ways
|
||||
* to calculate a unique tile index from a lat/lon, and it can provide
|
||||
* information such as the dimensions of a given tile.
|
||||
*/
|
||||
|
||||
class SGBucket {
|
||||
|
||||
private:
|
||||
double cx, cy; // centerpoint (lon, lat) in degrees of bucket
|
||||
int lon; // longitude index (-180 to 179)
|
||||
int lat; // latitude index (-90 to 89)
|
||||
int x; // x subdivision (0 to 7)
|
||||
int y; // y subdivision (0 to 7)
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
SGBucket();
|
||||
|
||||
/**
|
||||
* Construct a bucket given a specific location.
|
||||
* @param dlon longitude specified in degrees
|
||||
* @param dlat latitude specified in degrees
|
||||
*/
|
||||
SGBucket(const double dlon, const double dlat);
|
||||
|
||||
/** Construct a bucket.
|
||||
* @param is_good if false, create an invalid bucket. This is
|
||||
* useful * if you are comparing cur_bucket to last_bucket and
|
||||
* you want to * make sure last_bucket starts out as something
|
||||
* impossible.
|
||||
*/
|
||||
SGBucket(const bool is_good);
|
||||
|
||||
/** Construct a bucket given a unique bucket index number.
|
||||
* @param bindex unique bucket index
|
||||
*/
|
||||
SGBucket(const long int bindex);
|
||||
|
||||
/**
|
||||
* Default destructor.
|
||||
*/
|
||||
~SGBucket();
|
||||
|
||||
/**
|
||||
* Reset a bucket to represent a new lat and lon
|
||||
* @param dlon longitude specified in degrees
|
||||
* @param dlat latitude specified in degrees
|
||||
*/
|
||||
void set_bucket( double dlon, double dlat );
|
||||
|
||||
/**
|
||||
* Reset a bucket to represent a new lat and lon
|
||||
* @param lonlat an array of double[2] holding lon and lat
|
||||
* (specified) in degrees
|
||||
*/
|
||||
void set_bucket( double *lonlat );
|
||||
|
||||
/**
|
||||
* Create an impossible bucket.
|
||||
* This is useful if you are comparing cur_bucket to last_bucket
|
||||
* and you want to make sure last_bucket starts out as something
|
||||
* impossible.
|
||||
*/
|
||||
inline void make_bad() {
|
||||
set_bucket(0.0, 0.0);
|
||||
lon = -1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the unique scenery tile index for this bucket
|
||||
*
|
||||
* The index is constructed as follows:
|
||||
*
|
||||
* 9 bits - to represent 360 degrees of longitude (-180 to 179)
|
||||
* 8 bits - to represent 180 degrees of latitude (-90 to 89)
|
||||
*
|
||||
* Each 1 degree by 1 degree tile is further broken down into an 8x8
|
||||
* grid. So we also need:
|
||||
*
|
||||
* 3 bits - to represent x (0 to 7)
|
||||
* 3 bits - to represent y (0 to 7)
|
||||
* @return tile index
|
||||
*/
|
||||
inline long int gen_index() const {
|
||||
return ((lon + 180) << 14) + ((lat + 90) << 6) + (y << 3) + x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the unique scenery tile index for this bucket in ascii
|
||||
* string form.
|
||||
* @return tile index in string form
|
||||
*/
|
||||
inline string gen_index_str() const {
|
||||
char tmp[20];
|
||||
sprintf(tmp, "%ld",
|
||||
(((long)lon + 180) << 14) + ((lat + 90) << 6) + (y << 3) + x);
|
||||
return (string)tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the base path name for this bucket.
|
||||
* @return base path in string form
|
||||
*/
|
||||
string gen_base_path() const;
|
||||
|
||||
/**
|
||||
* @return the center lon of a tile.
|
||||
*/
|
||||
inline double get_center_lon() const {
|
||||
double span = sg_bucket_span( lat + y / 8.0 + SG_HALF_BUCKET_SPAN );
|
||||
|
||||
if ( span >= 1.0 ) {
|
||||
return lon + span / 2.0;
|
||||
} else {
|
||||
return lon + x * span + span / 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the center lat of a tile.
|
||||
*/
|
||||
inline double get_center_lat() const {
|
||||
return lat + y / 8.0 + SG_HALF_BUCKET_SPAN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the width of the tile in degrees.
|
||||
*/
|
||||
double get_width() const;
|
||||
|
||||
/**
|
||||
* @return the height of the tile in degrees.
|
||||
*/
|
||||
double get_height() const;
|
||||
|
||||
/**
|
||||
* @return the width of the tile in meters.
|
||||
*/
|
||||
double get_width_m() const;
|
||||
|
||||
/**
|
||||
* @return the height of the tile in meters.
|
||||
*/
|
||||
double get_height_m() const;
|
||||
|
||||
// Informational methods.
|
||||
|
||||
/**
|
||||
* @return the lon of the lower left corner of this tile.
|
||||
*/
|
||||
inline int get_lon() const { return lon; }
|
||||
|
||||
/**
|
||||
* @return the lat of the lower left corner of this tile.
|
||||
*/
|
||||
inline int get_lat() const { return lat; }
|
||||
|
||||
/**
|
||||
* @return the x coord within the 1x1 degree chunk this tile.
|
||||
*/
|
||||
inline int get_x() const { return x; }
|
||||
|
||||
/**
|
||||
* @return the y coord within the 1x1 degree chunk this tile.
|
||||
*/
|
||||
inline int get_y() const { return y; }
|
||||
|
||||
// friends
|
||||
|
||||
friend ostream& operator<< ( ostream&, const SGBucket& );
|
||||
friend bool operator== ( const SGBucket&, const SGBucket& );
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \relates SGBucket
|
||||
* Return the bucket which is offset from the specified dlon, dlat by
|
||||
* the specified tile units in the X & Y direction.
|
||||
* @param dlon starting lon in degrees
|
||||
* @param dlat starting lat in degrees
|
||||
* @param x number of bucket units to offset in x (lon) direction
|
||||
* @param y number of bucket units to offset in y (lat) direction
|
||||
* @return offset bucket
|
||||
*/
|
||||
SGBucket sgBucketOffset( double dlon, double dlat, int x, int y );
|
||||
|
||||
|
||||
/**
|
||||
* \relates SGBucket
|
||||
* Calculate the offset between two buckets (in quantity of buckets).
|
||||
* @param b1 bucket 1
|
||||
* @param b2 bucket 2
|
||||
* @param dx offset distance (lon) in tile units
|
||||
* @param dy offset distance (lat) in tile units
|
||||
*/
|
||||
void sgBucketDiff( const SGBucket& b1, const SGBucket& b2, int *dx, int *dy );
|
||||
|
||||
|
||||
/**
|
||||
* Write the bucket lon, lat, x, and y to the output stream.
|
||||
* @param out output stream
|
||||
* @param b bucket
|
||||
*/
|
||||
inline ostream&
|
||||
operator<< ( ostream& out, const SGBucket& b )
|
||||
{
|
||||
return out << b.lon << ":" << b.x << ", " << b.lat << ":" << b.y;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compare two bucket structures for equality.
|
||||
* @param b1 bucket 1
|
||||
* @param b2 bucket 2
|
||||
* @return comparison result
|
||||
*/
|
||||
inline bool
|
||||
operator== ( const SGBucket& b1, const SGBucket& b2 )
|
||||
{
|
||||
return ( b1.lon == b2.lon &&
|
||||
b1.lat == b2.lat &&
|
||||
b1.x == b2.x &&
|
||||
b1.y == b2.y );
|
||||
}
|
||||
|
||||
|
||||
#endif // _NEWBUCKET_HXX
|
||||
|
||||
|
||||
450
simgear/compiler.h
Normal file
450
simgear/compiler.h
Normal file
@@ -0,0 +1,450 @@
|
||||
/**************************************************************************
|
||||
* compiler.h -- C++ Compiler Portability Macros
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/** \file compiler.h
|
||||
* A set of defines to encapsulate compiler and platform differences.
|
||||
* Please refer to the source code for full documentation on this file.
|
||||
*
|
||||
* Here is a summary of what this file does.
|
||||
*
|
||||
* (1) Defines macros for some STL includes which may be affected
|
||||
* by file name length limitations.
|
||||
*
|
||||
* (2) Defines macros for some features not supported by all C++ compilers.
|
||||
*
|
||||
* (3) Defines 'explicit' as a null macro if the compiler doesn't support
|
||||
* the explicit keyword.
|
||||
*
|
||||
* (4) Defines 'typename' as a null macro if the compiler doesn't support
|
||||
* the typename keyword.
|
||||
*
|
||||
* (5) Defines bool, true and false if the compiler doesn't do so.
|
||||
*
|
||||
* (6) Defines SG_EXPLICIT_FUNCTION_TMPL_ARGS if the compiler
|
||||
* supports calling a function template by providing its template
|
||||
* arguments explicitly.
|
||||
*
|
||||
* (7) Defines SG_NEED_AUTO_PTR if STL doesn't provide auto_ptr<>.
|
||||
*
|
||||
* (8) Defines SG_NO_ARROW_OPERATOR if the compiler is unable
|
||||
* to support operator->() for iterators.
|
||||
*
|
||||
* (9) Defines SG_USE_EXCEPTIONS if the compiler supports exceptions.
|
||||
* Note: no FlightGear code uses exceptions.
|
||||
*
|
||||
* (10) Define SG_NAMESPACES if the compiler supports namespaces.
|
||||
*
|
||||
* (11) SG_MATH_FN_IN_NAMESPACE_STD -- not used??
|
||||
*
|
||||
* (12) Define SG_HAVE_STD if std namespace is supported.
|
||||
*
|
||||
* (13) Defines SG_CLASS_PARTIAL_SPECIALIZATION if the compiler
|
||||
* supports partial specialization of class templates.
|
||||
*
|
||||
* (14) Defines SG_HAVE_STD_INCLUDES to use ISO C++ Standard headers.
|
||||
*
|
||||
* (15) Defines SG_HAVE_STREAMBUF if <streambuf> of <streambuf.h> are present.
|
||||
*
|
||||
* (16) Define SG_MATH_EXCEPTION_CLASH if math.h defines an exception class
|
||||
* that clashes with the one defined in <stdexcept>.
|
||||
*/
|
||||
|
||||
#ifndef _SG_COMPILER_H
|
||||
#define _SG_COMPILER_H
|
||||
|
||||
/*
|
||||
* Helper macro SG_STRINGIZE:
|
||||
* Converts the parameter X to a string after macro replacement
|
||||
* on X has been performed.
|
||||
*/
|
||||
#define SG_STRINGIZE(X) SG_DO_STRINGIZE(X)
|
||||
#define SG_DO_STRINGIZE(X) #X
|
||||
|
||||
#ifdef __GNUC__
|
||||
# if __GNUC__ == 2
|
||||
# if __GNUC_MINOR__ < 8
|
||||
|
||||
// g++-2.7.x
|
||||
# define STL_ALGORITHM <algorithm>
|
||||
# define STL_FUNCTIONAL <functional>
|
||||
# define STL_IOMANIP <iomanip.h>
|
||||
# define STL_IOSTREAM <iostream.h>
|
||||
# define STL_ITERATOR <iterator.h>
|
||||
# define STL_FSTREAM <fstream.h>
|
||||
# define STL_STDEXCEPT <stdexcept>
|
||||
# define STL_STRING <string>
|
||||
# define STL_STRSTREAM <strstream.h>
|
||||
|
||||
# define SG_NEED_AUTO_PTR
|
||||
# define SG_NO_DEFAULT_TEMPLATE_ARGS
|
||||
# define SG_INCOMPLETE_FUNCTIONAL
|
||||
# define SG_NO_ARROW_OPERATOR
|
||||
|
||||
# elif __GNUC_MINOR__ >= 8
|
||||
|
||||
// g++-2.8.x and egcs-1.x
|
||||
# define SG_EXPLICIT_FUNCTION_TMPL_ARGS
|
||||
# define SG_NEED_AUTO_PTR
|
||||
# define SG_MEMBER_TEMPLATES
|
||||
# define SG_NAMESPACES
|
||||
# define SG_HAVE_STD
|
||||
# define SG_HAVE_STREAMBUF
|
||||
# define SG_CLASS_PARTIAL_SPECIALIZATION
|
||||
|
||||
# define STL_ALGORITHM <algorithm>
|
||||
# define STL_FUNCTIONAL <functional>
|
||||
# define STL_IOMANIP <iomanip>
|
||||
# define STL_IOSTREAM <iostream>
|
||||
# define STL_ITERATOR <iterator>
|
||||
# define STL_FSTREAM <fstream>
|
||||
# define STL_STDEXCEPT <stdexcept>
|
||||
# define STL_STRING <string>
|
||||
# define STL_STRSTREAM <strstream>
|
||||
|
||||
# endif
|
||||
# elif __GNUC__ == 3
|
||||
// g++-3.0.x
|
||||
# define SG_EXPLICIT_FUNCTION_TMPL_ARGS
|
||||
# define SG_NEED_AUTO_PTR
|
||||
# define SG_MEMBER_TEMPLATES
|
||||
# define SG_NAMESPACES
|
||||
# define SG_HAVE_STD
|
||||
# define SG_HAVE_STREAMBUF
|
||||
# define SG_CLASS_PARTIAL_SPECIALIZATION
|
||||
# define SG_HAVE_STD_INCLUDES
|
||||
|
||||
# define STL_ALGORITHM <algorithm>
|
||||
# define STL_FUNCTIONAL <functional>
|
||||
# define STL_IOMANIP <iomanip>
|
||||
# define STL_IOSTREAM <iostream>
|
||||
# define STL_ITERATOR <iterator>
|
||||
# define STL_FSTREAM <fstream>
|
||||
# define STL_STDEXCEPT <stdexcept>
|
||||
# define STL_STRING <string>
|
||||
# define STL_STRSTREAM <strstream>
|
||||
|
||||
# else
|
||||
# error Time to upgrade. GNU compilers < 2.7 not supported
|
||||
# endif
|
||||
|
||||
# define SG_COMPILER_STR "GNU C++ version " SG_STRINGIZE(__GNUC__) "." SG_STRINGIZE(__GNUC_MINOR__)
|
||||
|
||||
#endif // __GNUC__
|
||||
|
||||
#if defined( __MINGW32__ )
|
||||
# define bcopy(from, to, n) memcpy(to, from, n)
|
||||
# define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
/* KAI C++ */
|
||||
#if defined(__KCC)
|
||||
|
||||
# define SG_NAMESPACES
|
||||
# define SG_HAVE_STD
|
||||
# define SG_HAVE_STREAMBUF
|
||||
# define SG_HAVE_TRAITS
|
||||
# define SG_HAVE_STD_INCLUDES
|
||||
|
||||
# define STL_ALGORITHM <algorithm>
|
||||
# define STL_FUNCTIONAL <functional>
|
||||
# define STL_IOMANIP <iomanip>
|
||||
# define STL_IOSTREAM <iostream>
|
||||
# define STL_ITERATOR <iterator>
|
||||
# define STL_FSTREAM <fstream>
|
||||
# define STL_STDEXCEPT <stdexcept>
|
||||
# define STL_STRING <string>
|
||||
# define STL_STRSTREAM <strstream>
|
||||
|
||||
# define SG_COMPILER_STR "Kai C++ version " SG_STRINGIZE(__KCC_VERSION)
|
||||
|
||||
#endif // __KCC
|
||||
|
||||
//
|
||||
// Metrowerks
|
||||
//
|
||||
#if defined(__MWERKS__)
|
||||
/*
|
||||
CodeWarrior compiler from Metrowerks, Inc.
|
||||
*/
|
||||
# define SG_HAVE_TRAITS
|
||||
# define SG_HAVE_STD_INCLUDES
|
||||
# define SG_HAVE_STD
|
||||
# define SG_NAMESPACES
|
||||
|
||||
# define STL_ALGORITHM <algorithm>
|
||||
# define STL_FUNCTIONAL <functional>
|
||||
# define STL_IOMANIP <iomanip>
|
||||
# define STL_IOSTREAM <iostream>
|
||||
# define STL_ITERATOR <iterator>
|
||||
# define STL_FSTREAM <fstream>
|
||||
# define STL_STDEXCEPT <stdexcept>
|
||||
# define STL_STRING <string>
|
||||
|
||||
// Temp:
|
||||
# define bcopy(from, to, n) memcpy(to, from, n)
|
||||
|
||||
// -rp- please use FG_MEM_COPY everywhere !
|
||||
// #define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
|
||||
|
||||
// -dw- currently used glut has no game mode stuff
|
||||
# define GLUT_WRONG_VERSION
|
||||
|
||||
# define SG_COMPILER_STR "Metrowerks CodeWarrior C++ version " SG_STRINGIZE(__MWERKS__)
|
||||
|
||||
#endif // __MWERKS__
|
||||
|
||||
//
|
||||
// Microsoft compilers.
|
||||
//
|
||||
#ifdef _MSC_VER
|
||||
# define bcopy(from, to, n) memcpy(to, from, n)
|
||||
# define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
|
||||
|
||||
# if _MSC_VER == 1200 // msvc++ 6.0
|
||||
# define SG_NAMESPACES
|
||||
# define SG_HAVE_STD
|
||||
# define SG_HAVE_STD_INCLUDES
|
||||
# define SG_HAVE_STREAMBUF
|
||||
|
||||
# define STL_ALGORITHM <algorithm>
|
||||
# define STL_FUNCTIONAL <functional>
|
||||
# define STL_IOMANIP <iomanip>
|
||||
# define STL_IOSTREAM <iostream>
|
||||
# define STL_ITERATOR <iterator>
|
||||
# define STL_FSTREAM <fstream>
|
||||
# define STL_STDEXCEPT <stdexcept>
|
||||
# define STL_STRING <string>
|
||||
# define STL_STRSTREAM <strstream>
|
||||
|
||||
# define snprintf _snprintf
|
||||
|
||||
# pragma warning(disable: 4786) // identifier was truncated to '255' characters
|
||||
# pragma warning(disable: 4244) // conversion from double to float
|
||||
# pragma warning(disable: 4305) //
|
||||
|
||||
# else
|
||||
# error What version of MSVC++ is this?
|
||||
# endif
|
||||
|
||||
# define SG_COMPILER_STR "Microsoft Visual C++ version " SG_STRINGIZE(_MSC_VER)
|
||||
|
||||
#endif // _MSC_VER
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# if defined(HAVE_SGI_STL_PORT)
|
||||
|
||||
// Use quotes around long file names to get around Borland's include hackery
|
||||
|
||||
# define STL_ALGORITHM "algorithm"
|
||||
# define STL_FUNCTIONAL "functional"
|
||||
|
||||
# define SG_MATH_EXCEPTION_CLASH
|
||||
|
||||
# else
|
||||
|
||||
# define STL_ALGORITHM <algorithm>
|
||||
# define STL_FUNCTIONAL <functional>
|
||||
# define STL_IOMANIP <iomanip>
|
||||
# define STL_STDEXCEPT <stdexcept>
|
||||
# define STL_STRSTREAM <strstream>
|
||||
|
||||
# define SG_INCOMPLETE_FUNCTIONAL
|
||||
|
||||
# endif // HAVE_SGI_STL_PORT
|
||||
|
||||
# define STL_IOSTREAM <iostream>
|
||||
# define STL_ITERATOR <iterator>
|
||||
# define STL_FSTREAM <fstream>
|
||||
# define STL_STRING <string>
|
||||
# define SG_NO_DEFAULT_TEMPLATE_ARGS
|
||||
# define SG_NAMESPACES
|
||||
// # define SG_HAVE_STD
|
||||
|
||||
# define SG_COMPILER_STR "Borland C++ version " SG_STRINGIZE(__BORLANDC__)
|
||||
|
||||
#endif // __BORLANDC__
|
||||
|
||||
//
|
||||
// Native SGI compilers
|
||||
//
|
||||
|
||||
#if defined ( sgi ) && !defined( __GNUC__ )
|
||||
# define SG_HAVE_NATIVE_SGI_COMPILERS
|
||||
|
||||
# define SG_EXPLICIT_FUNCTION_TMPL_ARGS
|
||||
# define SG_NEED_AUTO_PTR
|
||||
# define SG_MEMBER_TEMPLATES
|
||||
# define SG_NAMESPACES
|
||||
# define SG_HAVE_STD
|
||||
# define SG_CLASS_PARTIAL_SPECIALIZATION
|
||||
# define SG_HAVE_TRAITS
|
||||
|
||||
# define STL_ALGORITHM <algorithm>
|
||||
# define STL_FUNCTIONAL <functional>
|
||||
# define STL_IOMANIP <iomanip.h>
|
||||
# define STL_IOSTREAM <iostream.h>
|
||||
# define STL_ITERATOR <iterator.h>
|
||||
# define STL_FSTREAM <fstream.h>
|
||||
# define STL_STDEXCEPT <stdexcept>
|
||||
# define STL_STRING <string>
|
||||
# define STL_STRSTREAM <strstream.h>
|
||||
|
||||
// # define __STL_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
// typedef void PFNGLPOINTPARAMETERFEXTPROC
|
||||
|
||||
#define glPointParameterfEXT glPointParameterfSGIS
|
||||
#define glPointParameterfvEXT glPointParameterfvSGIS
|
||||
|
||||
#pragma set woff 1001,1012,1014,1116,1155,1172,1174
|
||||
#pragma set woff 1401,1460,1551,1552,1681
|
||||
|
||||
#ifdef __cplusplus
|
||||
#pragma set woff 1682,3303
|
||||
#endif
|
||||
|
||||
# define SG_COMPILER_STR "SGI Irix compiler version " SG_STRINGIZE(_COMPILER_VERSION)
|
||||
|
||||
#endif // Native SGI compilers
|
||||
|
||||
|
||||
#if defined ( sun )
|
||||
# include <strings.h>
|
||||
# include <memory.h>
|
||||
# if defined ( __cplusplus )
|
||||
// typedef unsigned int size_t;
|
||||
extern "C" {
|
||||
extern void *memmove(void *, const void *, size_t);
|
||||
}
|
||||
# else
|
||||
extern void *memmove(void *, const void *, size_t);
|
||||
# endif // __cplusplus
|
||||
|
||||
# define SG_COMPILER_STR "Sun compiler version " SG_STRINGIZE(__SUNPRO_CC)
|
||||
|
||||
#endif // sun
|
||||
|
||||
//
|
||||
// Intel C++ Compiler
|
||||
//
|
||||
#if defined(__ICC) || defined (__ECC)
|
||||
# define SG_NAMESPACES
|
||||
# define SG_HAVE_STD
|
||||
# define SG_HAVE_STREAMBUF
|
||||
# define SG_HAVE_TRAITS
|
||||
# define SG_HAVE_STD_INCLUDES
|
||||
|
||||
# define STL_ALGORITHM <algorithm>
|
||||
# define STL_FUNCTIONAL <functional>
|
||||
# define STL_IOMANIP <iomanip>
|
||||
# define STL_IOSTREAM <iostream>
|
||||
# define STL_ITERATOR <iterator>
|
||||
# define STL_FSTREAM <fstream>
|
||||
# define STL_STDEXCEPT <stdexcept>
|
||||
# define STL_STRING <string>
|
||||
# define STL_STRSTREAM <strstream>
|
||||
|
||||
# define SG_COMPILER_STR "Intel C++ version " SG_STRINGIZE(__ICC)
|
||||
|
||||
#endif // __ICC
|
||||
|
||||
//
|
||||
// No user modifiable definitions beyond here.
|
||||
//
|
||||
|
||||
#ifdef SG_NEED_EXPLICIT
|
||||
# define explicit
|
||||
#endif
|
||||
|
||||
#ifdef SG_NEED_TYPENAME
|
||||
# define typename
|
||||
#endif
|
||||
|
||||
#ifdef SG_NEED_MUTABLE
|
||||
# define mutable
|
||||
#endif
|
||||
|
||||
#ifdef SG_NEED_BOOL
|
||||
typedef int bool;
|
||||
# define true 1
|
||||
# define false 0
|
||||
#endif
|
||||
|
||||
#ifdef SG_EXPLICIT_FUNCTION_TMPL_ARGS
|
||||
# define SG_NULL_TMPL_ARGS <>
|
||||
#else
|
||||
# define SG_NULL_TMPL_ARGS
|
||||
#endif
|
||||
|
||||
#ifdef SG_CLASS_PARTIAL_SPECIALIZATION
|
||||
# define SG_TEMPLATE_NULL template<>
|
||||
#else
|
||||
# define SG_TEMPLATE_NULL
|
||||
#endif
|
||||
|
||||
// SG_NO_NAMESPACES is a hook so that users can disable namespaces
|
||||
// without having to edit library headers.
|
||||
#if defined(SG_NAMESPACES) && !defined(SG_NO_NAMESPACES)
|
||||
# define SG_NAMESPACE(X) namespace X {
|
||||
# define SG_NAMESPACE_END }
|
||||
# define SG_USING_NAMESPACE(X) using namespace X
|
||||
# else
|
||||
# define SG_NAMESPACE(X)
|
||||
# define SG_NAMESPACE_END
|
||||
# define SG_USING_NAMESPACE(X)
|
||||
#endif
|
||||
|
||||
/** \def SG_USING_STD(x)
|
||||
* Expands to using std::x if SG_HAVE_STD is defined
|
||||
*/
|
||||
# ifdef SG_HAVE_STD
|
||||
# define SG_USING_STD(X) using std::X
|
||||
# define STD std
|
||||
# else
|
||||
# define SG_USING_STD(X)
|
||||
# define STD
|
||||
# endif
|
||||
|
||||
// Additional <functional> implementation from SGI STL 3.11
|
||||
// Adapter function objects: pointers to member functions
|
||||
#ifdef SG_INCOMPLETE_FUNCTIONAL
|
||||
|
||||
template <class _Ret, class _Tp>
|
||||
class const_mem_fun_ref_t
|
||||
#ifndef __BORLANDC__
|
||||
: public unary_function<_Tp,_Ret>
|
||||
#endif // __BORLANDC__
|
||||
{
|
||||
public:
|
||||
explicit const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {}
|
||||
_Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); }
|
||||
private:
|
||||
_Ret (_Tp::*_M_f)() const;
|
||||
};
|
||||
|
||||
template <class _Ret, class _Tp>
|
||||
inline const_mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)() const)
|
||||
{ return const_mem_fun_ref_t<_Ret,_Tp>(__f); }
|
||||
|
||||
#endif // SG_INCOMPLETE_FUNCTIONAL
|
||||
|
||||
#endif // _SG_COMPILER_H
|
||||
132
simgear/constants.h
Normal file
132
simgear/constants.h
Normal file
@@ -0,0 +1,132 @@
|
||||
// constants.h -- various constant definitions
|
||||
//
|
||||
// Written by Curtis Olson, started February 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the
|
||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
/** \file constants.h
|
||||
* Various constant definitions.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SG_CONSTANTS_H
|
||||
#define _SG_CONSTANTS_H
|
||||
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#ifdef SG_HAVE_STD_INCLUDES
|
||||
# include <cmath>
|
||||
#else
|
||||
# ifdef SG_MATH_EXCEPTION_CLASH
|
||||
# define exception C_exception
|
||||
# endif
|
||||
# include <math.h>
|
||||
#endif
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
|
||||
// Make sure PI is defined in its various forms
|
||||
|
||||
// SG_PI and SGD_PI (float and double) come from plib/sg.h
|
||||
|
||||
/** 2 * PI */
|
||||
#define SGD_2PI 6.28318530717958647692
|
||||
|
||||
/** PI / 2 */
|
||||
#ifdef M_PI_2
|
||||
# define SGD_PI_2 M_PI_2
|
||||
#else
|
||||
# define SGD_PI_2 1.57079632679489661923
|
||||
#endif
|
||||
|
||||
/** PI / 4 */
|
||||
#define SGD_PI_4 0.78539816339744830961
|
||||
|
||||
/** \def SG_E "e" */
|
||||
#ifdef M_E
|
||||
# define SG_E M_E
|
||||
#else
|
||||
# define SG_E 2.7182818284590452354
|
||||
#endif
|
||||
|
||||
/** pi/180/60/60, or about 100 feet at earths' equator */
|
||||
#define SG_ONE_SECOND 4.848136811E-6
|
||||
|
||||
|
||||
/** Radius of Earth in kilometers at the equator. Another source had
|
||||
* 6378.165 but this is probably close enough */
|
||||
#define SG_EARTH_RAD 6378.155
|
||||
|
||||
|
||||
// Earth parameters for WGS 84, taken from LaRCsim/ls_constants.h
|
||||
|
||||
/** Value of earth radius from LaRCsim (ft) */
|
||||
#define SG_EQUATORIAL_RADIUS_FT 20925650.
|
||||
|
||||
/** Value of earth radius from LaRCsim (meter) */
|
||||
#define SG_EQUATORIAL_RADIUS_M 6378138.12
|
||||
|
||||
/** Radius squared (ft) */
|
||||
#define SG_EQ_RAD_SQUARE_FT 437882827922500.
|
||||
|
||||
/** Radius squared (meter) */
|
||||
#define SG_EQ_RAD_SQUARE_M 40680645877797.1344
|
||||
|
||||
// Conversions
|
||||
|
||||
/** Arc seconds to radians. (arcsec*pi)/(3600*180) = rad */
|
||||
#define SG_ARCSEC_TO_RAD 4.84813681109535993589e-06
|
||||
|
||||
/** Radians to arc seconds. (rad*3600*180)/pi = arcsec */
|
||||
#define SG_RAD_TO_ARCSEC 206264.806247096355156
|
||||
|
||||
/** Feet to Meters */
|
||||
#define SG_FEET_TO_METER 0.3048
|
||||
|
||||
/** Meters to Feet */
|
||||
#define SG_METER_TO_FEET 3.28083989501312335958
|
||||
|
||||
/** Meters to Nautical Miles. 1 nm = 6076.11549 feet */
|
||||
#define SG_METER_TO_NM 0.00053995680
|
||||
|
||||
/** Nautical Miles to Meters */
|
||||
#define SG_NM_TO_METER 1852.0000
|
||||
|
||||
/** Radians to Nautical Miles. 1 nm = 1/60 of a degree */
|
||||
#define SG_NM_TO_RAD 0.00029088820866572159
|
||||
|
||||
/** Nautical Miles to Radians */
|
||||
#define SG_RAD_TO_NM 3437.7467707849392526
|
||||
|
||||
/** For divide by zero avoidance, this will be close enough to zero */
|
||||
#define SG_EPSILON 0.0000001
|
||||
|
||||
|
||||
/** Highest binobj format version we know how to read/write. This starts at
|
||||
* 0 and can go up to 65535 */
|
||||
#define SG_BINOBJ_VERSION 6
|
||||
|
||||
/** for backwards compatibility */
|
||||
#define SG_SCENERY_FILE_FORMAT "0.4"
|
||||
|
||||
|
||||
#endif // _SG_CONSTANTS_H
|
||||
3
simgear/debug/.cvsignore
Normal file
3
simgear/debug/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
11
simgear/debug/Makefile.am
Normal file
11
simgear/debug/Makefile.am
Normal file
@@ -0,0 +1,11 @@
|
||||
includedir = @includedir@/debug
|
||||
|
||||
EXTRA_DIST = logtest.cxx
|
||||
|
||||
lib_LIBRARIES = libsgdebug.a
|
||||
|
||||
include_HEADERS = debug_types.h logstream.hxx
|
||||
|
||||
libsgdebug_a_SOURCES = logstream.cxx
|
||||
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
43
simgear/debug/debug_types.h
Normal file
43
simgear/debug/debug_types.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/** \file debug_types.h
|
||||
* Define the various logging classes and prioritiess
|
||||
*/
|
||||
|
||||
/**
|
||||
* Define the possible classes/categories of logging messages
|
||||
*/
|
||||
typedef enum {
|
||||
SG_NONE = 0x00000000,
|
||||
|
||||
SG_TERRAIN = 0x00000001,
|
||||
SG_ASTRO = 0x00000002,
|
||||
SG_FLIGHT = 0x00000004,
|
||||
SG_INPUT = 0x00000008,
|
||||
SG_GL = 0x00000010,
|
||||
SG_VIEW = 0x00000020,
|
||||
SG_COCKPIT = 0x00000040,
|
||||
SG_GENERAL = 0x00000080,
|
||||
SG_MATH = 0x00000100,
|
||||
SG_EVENT = 0x00000200,
|
||||
SG_AIRCRAFT = 0x00000400,
|
||||
SG_AUTOPILOT = 0x00000800,
|
||||
SG_IO = 0x00001000,
|
||||
SG_CLIPPER = 0x00002000,
|
||||
SG_NETWORK = 0x00004000,
|
||||
SG_UNDEFD = 0x00008000, // For range checking
|
||||
|
||||
SG_ALL = 0xFFFFFFFF
|
||||
} sgDebugClass;
|
||||
|
||||
|
||||
/**
|
||||
* Define the possible logging priorities (and their order).
|
||||
*/
|
||||
typedef enum {
|
||||
SG_BULK, // For frequent messages
|
||||
SG_DEBUG, // Less frequent debug type messages
|
||||
SG_INFO, // Informatory messages
|
||||
SG_WARN, // Possible impending problem
|
||||
SG_ALERT // Very possible impending problem
|
||||
// SG_EXIT, // Problem (no core)
|
||||
// SG_ABORT // Abandon ship (core)
|
||||
} sgDebugPriority;
|
||||
90
simgear/debug/logstream.cxx
Normal file
90
simgear/debug/logstream.cxx
Normal file
@@ -0,0 +1,90 @@
|
||||
// Stream based logging mechanism.
|
||||
//
|
||||
// Written by Bernie Bright, 1998
|
||||
//
|
||||
// Copyright (C) 1998 Bernie Bright - bbright@c031.aone.net.au
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the
|
||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
#include "logstream.hxx"
|
||||
|
||||
logstream *global_logstream = NULL;
|
||||
|
||||
bool logbuf::logging_enabled = true;
|
||||
sgDebugClass logbuf::logClass = SG_NONE;
|
||||
sgDebugPriority logbuf::logPriority = SG_INFO;
|
||||
streambuf* logbuf::sbuf = NULL;
|
||||
|
||||
logbuf::logbuf()
|
||||
{
|
||||
// if ( sbuf == NULL )
|
||||
// sbuf = cerr.rdbuf();
|
||||
}
|
||||
|
||||
logbuf::~logbuf()
|
||||
{
|
||||
if ( sbuf )
|
||||
sync();
|
||||
}
|
||||
|
||||
void
|
||||
logbuf::set_sb( streambuf* sb )
|
||||
{
|
||||
if ( sbuf )
|
||||
sync();
|
||||
|
||||
sbuf = sb;
|
||||
}
|
||||
|
||||
void
|
||||
logbuf::set_log_level( sgDebugClass c, sgDebugPriority p )
|
||||
{
|
||||
logClass = c;
|
||||
logPriority = p;
|
||||
}
|
||||
|
||||
void
|
||||
logbuf::set_log_classes (sgDebugClass c)
|
||||
{
|
||||
logClass = c;
|
||||
}
|
||||
|
||||
sgDebugClass
|
||||
logbuf::get_log_classes ()
|
||||
{
|
||||
return logClass;
|
||||
}
|
||||
|
||||
void
|
||||
logbuf::set_log_priority (sgDebugPriority p)
|
||||
{
|
||||
logPriority = p;
|
||||
}
|
||||
|
||||
sgDebugPriority
|
||||
logbuf::get_log_priority ()
|
||||
{
|
||||
return logPriority;
|
||||
}
|
||||
|
||||
void
|
||||
logstream::setLogLevels( sgDebugClass c, sgDebugPriority p )
|
||||
{
|
||||
logbuf::set_log_level( c, p );
|
||||
}
|
||||
|
||||
306
simgear/debug/logstream.hxx
Normal file
306
simgear/debug/logstream.hxx
Normal file
@@ -0,0 +1,306 @@
|
||||
/** \file logstream.hxx
|
||||
* Stream based logging mechanism.
|
||||
*/
|
||||
|
||||
// Written by Bernie Bright, 1998
|
||||
//
|
||||
// Copyright (C) 1998 Bernie Bright - bbright@c031.aone.net.au
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the
|
||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
#ifndef _LOGSTREAM_H
|
||||
#define _LOGSTREAM_H
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
// At least Irix needs this
|
||||
#ifdef SG_HAVE_NATIVE_SGI_COMPILERS
|
||||
#include <char_traits.h>
|
||||
#endif
|
||||
|
||||
#ifdef SG_HAVE_STD_INCLUDES
|
||||
# include <streambuf>
|
||||
# include <iostream>
|
||||
#else
|
||||
# include <iostream.h>
|
||||
# include <simgear/sg_traits.hxx>
|
||||
#endif
|
||||
|
||||
#include <simgear/debug/debug_types.h>
|
||||
|
||||
#ifndef SG_HAVE_NATIVE_SGI_COMPILERS
|
||||
SG_USING_STD(streambuf);
|
||||
SG_USING_STD(ostream);
|
||||
SG_USING_STD(cerr);
|
||||
SG_USING_STD(endl);
|
||||
#else
|
||||
SG_USING_STD(char_traits);
|
||||
#endif
|
||||
|
||||
#ifdef __MWERKS__
|
||||
SG_USING_STD(iostream);
|
||||
#endif
|
||||
|
||||
//
|
||||
// TODO:
|
||||
//
|
||||
// 1. Change output destination. Done.
|
||||
// 2. Make logbuf thread safe.
|
||||
// 3. Read environment for default debugClass and debugPriority.
|
||||
//
|
||||
|
||||
/**
|
||||
* logbuf is an output-only streambuf with the ability to disable sets of
|
||||
* messages at runtime. Only messages with priority >= logbuf::logPriority
|
||||
* and debugClass == logbuf::logClass are output.
|
||||
*/
|
||||
class logbuf : public streambuf
|
||||
{
|
||||
public:
|
||||
|
||||
#ifndef SG_HAVE_STD_INCLUDES
|
||||
typedef char_traits<char> traits_type;
|
||||
typedef char_traits<char>::int_type int_type;
|
||||
// typedef char_traits<char>::pos_type pos_type;
|
||||
// typedef char_traits<char>::off_type off_type;
|
||||
#endif
|
||||
// logbuf( streambuf* sb ) : sbuf(sb) {}
|
||||
/** Constructor */
|
||||
logbuf();
|
||||
|
||||
/** Destructor */
|
||||
~logbuf();
|
||||
|
||||
/**
|
||||
* Is logging enabled?
|
||||
* @return true or false*/
|
||||
bool enabled() { return logging_enabled; }
|
||||
|
||||
/**
|
||||
* Set the logging level of subsequent messages.
|
||||
* @param c debug class
|
||||
* @param p priority
|
||||
*/
|
||||
void set_log_state( sgDebugClass c, sgDebugPriority p );
|
||||
|
||||
/**
|
||||
* Set the global logging level.
|
||||
* @param c debug class
|
||||
* @param p priority
|
||||
*/
|
||||
static void set_log_level( sgDebugClass c, sgDebugPriority p );
|
||||
|
||||
|
||||
/**
|
||||
* Set the allowed logging classes.
|
||||
* @param c All enabled logging classes anded together.
|
||||
*/
|
||||
static void set_log_classes (sgDebugClass c);
|
||||
|
||||
|
||||
/**
|
||||
* Get the logging classes currently enabled.
|
||||
* @return All enabled debug logging anded together.
|
||||
*/
|
||||
static sgDebugClass get_log_classes ();
|
||||
|
||||
|
||||
/**
|
||||
* Set the logging priority.
|
||||
* @param c The priority cutoff for logging messages.
|
||||
*/
|
||||
static void set_log_priority (sgDebugPriority p);
|
||||
|
||||
|
||||
/**
|
||||
* Get the current logging priority.
|
||||
* @return The priority cutoff for logging messages.
|
||||
*/
|
||||
static sgDebugPriority get_log_priority ();
|
||||
|
||||
|
||||
/**
|
||||
* Set the stream buffer
|
||||
* @param sb stream buffer
|
||||
*/
|
||||
void set_sb( streambuf* sb );
|
||||
|
||||
protected:
|
||||
|
||||
/** sync/flush */
|
||||
inline virtual int sync();
|
||||
|
||||
/** overflow */
|
||||
int_type overflow( int ch );
|
||||
// int xsputn( const char* s, istreamsize n );
|
||||
|
||||
private:
|
||||
|
||||
// The streambuf used for actual output. Defaults to cerr.rdbuf().
|
||||
static streambuf* sbuf;
|
||||
|
||||
static bool logging_enabled;
|
||||
static sgDebugClass logClass;
|
||||
static sgDebugPriority logPriority;
|
||||
|
||||
private:
|
||||
|
||||
// Not defined.
|
||||
logbuf( const logbuf& );
|
||||
void operator= ( const logbuf& );
|
||||
};
|
||||
|
||||
inline int
|
||||
logbuf::sync()
|
||||
{
|
||||
#ifdef SG_HAVE_STD_INCLUDES
|
||||
return sbuf->pubsync();
|
||||
#else
|
||||
return sbuf->sync();
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void
|
||||
logbuf::set_log_state( sgDebugClass c, sgDebugPriority p )
|
||||
{
|
||||
logging_enabled = ((c & logClass) != 0 && p >= logPriority);
|
||||
}
|
||||
|
||||
inline logbuf::int_type
|
||||
logbuf::overflow( int c )
|
||||
{
|
||||
return logging_enabled ? sbuf->sputc(c) : (EOF == 0 ? 1: 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* logstream manipulator for setting the log level of a message.
|
||||
*/
|
||||
struct loglevel
|
||||
{
|
||||
loglevel( sgDebugClass c, sgDebugPriority p )
|
||||
: logClass(c), logPriority(p) {}
|
||||
|
||||
sgDebugClass logClass;
|
||||
sgDebugPriority logPriority;
|
||||
};
|
||||
|
||||
/**
|
||||
* A helper class that ensures a streambuf and ostream are constructed and
|
||||
* destroyed in the correct order. The streambuf must be created before the
|
||||
* ostream but bases are constructed before members. Thus, making this class
|
||||
* a private base of logstream, declared to the left of ostream, we ensure the
|
||||
* correct order of construction and destruction.
|
||||
*/
|
||||
struct logstream_base
|
||||
{
|
||||
// logstream_base( streambuf* sb ) : lbuf(sb) {}
|
||||
logstream_base() {}
|
||||
|
||||
logbuf lbuf;
|
||||
};
|
||||
|
||||
/**
|
||||
* Class to manage the debug logging stream.
|
||||
*/
|
||||
class logstream : private logstream_base, public ostream
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* The default is to send messages to cerr.
|
||||
* @param out output stream
|
||||
*/
|
||||
logstream( ostream& out )
|
||||
// : logstream_base(out.rdbuf()),
|
||||
: logstream_base(),
|
||||
ostream(&lbuf) { lbuf.set_sb(out.rdbuf());}
|
||||
|
||||
/**
|
||||
* Set the output stream
|
||||
* @param out output stream
|
||||
*/
|
||||
void set_output( ostream& out ) { lbuf.set_sb( out.rdbuf() ); }
|
||||
|
||||
/**
|
||||
* Set the global log class and priority level.
|
||||
* @param c debug class
|
||||
* @param p priority
|
||||
*/
|
||||
void setLogLevels( sgDebugClass c, sgDebugPriority p );
|
||||
|
||||
/**
|
||||
* Output operator to capture the debug level and priority of a message.
|
||||
* @param l log level
|
||||
*/
|
||||
inline ostream& operator<< ( const loglevel& l );
|
||||
};
|
||||
|
||||
inline ostream&
|
||||
logstream::operator<< ( const loglevel& l )
|
||||
{
|
||||
lbuf.set_log_state( l.logClass, l.logPriority );
|
||||
return *this;
|
||||
}
|
||||
|
||||
extern logstream *global_logstream;
|
||||
|
||||
/**
|
||||
* \relates logstream
|
||||
* Return the one and only logstream instance.
|
||||
* We use a function instead of a global object so we are assured that cerr
|
||||
* has been initialised.
|
||||
* @return current logstream
|
||||
*/
|
||||
inline logstream&
|
||||
sglog()
|
||||
{
|
||||
if (global_logstream == NULL) {
|
||||
|
||||
#ifdef __APPLE__
|
||||
/**
|
||||
* There appears to be a bug in the C++ runtime in Mac OS X that
|
||||
* will crash if certain funtions are called (in this case
|
||||
* cerr.rdbuf()) during static initialization of a class. This
|
||||
* print statement is hack to kick the library in the pants so it
|
||||
* won't crash when cerr.rdbuf() is first called -DW
|
||||
**/
|
||||
cout << "Using Mac OS X hack for initializing C++ stdio..." << endl;
|
||||
#endif
|
||||
global_logstream = new logstream (cerr);
|
||||
}
|
||||
|
||||
return *global_logstream;
|
||||
}
|
||||
|
||||
|
||||
/** \def SG_LOG(C,P,M)
|
||||
* Log a message.
|
||||
* @param C debug class
|
||||
* @param P priority
|
||||
* @param M message
|
||||
*/
|
||||
#ifdef FG_NDEBUG
|
||||
# define SG_LOG(C,P,M)
|
||||
#elif defined( __MWERKS__ )
|
||||
# define SG_LOG(C,P,M) ::sglog() << ::loglevel(C,P) << M << std::endl
|
||||
#else
|
||||
# define SG_LOG(C,P,M) sglog() << loglevel(C,P) << M << endl
|
||||
#endif
|
||||
|
||||
|
||||
#endif // _LOGSTREAM_H
|
||||
|
||||
50
simgear/debug/logtest.cxx
Normal file
50
simgear/debug/logtest.cxx
Normal file
@@ -0,0 +1,50 @@
|
||||
#include <string>
|
||||
#include "Debug/logstream.hxx"
|
||||
|
||||
class Test {
|
||||
|
||||
public:
|
||||
Test() {
|
||||
//cout << "Cout seems to work" << endl;
|
||||
//cerr << "Cerr seems to work" << endl;
|
||||
|
||||
sglog().setLogLevels( SG_ALL, SG_INFO );
|
||||
|
||||
SG_LOG(SG_EVENT, SG_INFO, "Test::Test" << "foo");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Test test;
|
||||
|
||||
int
|
||||
main( int argc, char* argv[] )
|
||||
{
|
||||
sglog().setLogLevels( SG_ALL, SG_INFO );
|
||||
|
||||
//SG_LOG( FG_TERRAIN, FG_BULK, "terrain::bulk" ); // shouldnt appear
|
||||
//SG_LOG( FG_TERRAIN, SG_DEBUG, "terrain::debug" ); // shouldnt appear
|
||||
//SG_LOG( FG_TERRAIN, SG_INFO, "terrain::info" );
|
||||
//SG_LOG( FG_TERRAIN, FG_WARN, "terrain::warn" );
|
||||
//SG_LOG( FG_TERRAIN, SG_ALERT, "terrain::alert" );
|
||||
|
||||
int i = 12345;
|
||||
long l = 54321L;
|
||||
double d = 3.14159;
|
||||
string s = "Hello world!";
|
||||
|
||||
SG_LOG( SG_EVENT, SG_INFO, "event::info "
|
||||
<< "i=" << i
|
||||
<< ", l=" << l
|
||||
<< ", d=" << d
|
||||
<< ", d*l=" << d*l
|
||||
<< ", s=\"" << s << "\"" );
|
||||
|
||||
// This shouldn't appear in log output:
|
||||
SG_LOG( SG_EVENT, SG_DEBUG, "event::debug "
|
||||
<< "- this should be seen - "
|
||||
<< "d=" << d
|
||||
<< ", s=\"" << s << "\"" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
3
simgear/ephemeris/.cvsignore
Normal file
3
simgear/ephemeris/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -1,19 +1,34 @@
|
||||
noinst_LIBRARIES = libAstro.a
|
||||
includedir = @includedir@/ephemeris
|
||||
|
||||
libAstro_a_SOURCES = \
|
||||
celestialBody.cxx celestialBody.hxx \
|
||||
jupiter.cxx jupiter.hxx \
|
||||
mars.cxx mars.hxx \
|
||||
mercury.cxx mercury.hxx \
|
||||
moon.cxx moon.hxx \
|
||||
neptune.cxx neptune.hxx \
|
||||
lib_LIBRARIES = libsgephem.a
|
||||
|
||||
include_HEADERS = \
|
||||
celestialBody.hxx \
|
||||
ephemeris.hxx \
|
||||
jupiter.hxx \
|
||||
mars.hxx \
|
||||
mercury.hxx \
|
||||
moonpos.hxx \
|
||||
neptune.hxx \
|
||||
saturn.hxx \
|
||||
star.hxx \
|
||||
stardata.hxx \
|
||||
uranus.hxx \
|
||||
venus.hxx
|
||||
|
||||
libsgephem_a_SOURCES = \
|
||||
celestialBody.cxx \
|
||||
ephemeris.cxx \
|
||||
jupiter.cxx \
|
||||
mars.cxx \
|
||||
mercury.cxx \
|
||||
moonpos.cxx \
|
||||
neptune.cxx \
|
||||
pluto.hxx \
|
||||
saturn.cxx saturn.hxx \
|
||||
sky.cxx sky.hxx \
|
||||
solarsystem.cxx solarsystem.hxx \
|
||||
star.cxx star.hxx \
|
||||
stars.cxx stars.hxx \
|
||||
uranus.cxx uranus.hxx \
|
||||
venus.cxx venus.hxx
|
||||
saturn.cxx \
|
||||
star.cxx \
|
||||
stardata.cxx \
|
||||
uranus.cxx \
|
||||
venus.cxx
|
||||
|
||||
INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
|
||||
@@ -5,34 +5,37 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
#include <Debug/logstream.hxx>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#ifdef FG_MATH_EXCEPTION_CLASH
|
||||
#ifdef SG_MATH_EXCEPTION_CLASH
|
||||
# define exception c_exception
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* void CelestialBody::updatePosition(fgTIME *t, Star *ourSun)
|
||||
* void CelestialBody::updatePosition(double mjd, Star *ourSun)
|
||||
*
|
||||
* Basically, this member function provides a general interface for
|
||||
* calculating the right ascension and declinaion. This function is
|
||||
@@ -43,25 +46,25 @@
|
||||
* position is calculated an a slightly different manner.
|
||||
*
|
||||
* arguments:
|
||||
* fgTIME t: provides the current time.
|
||||
* double mjd: provides the modified julian date.
|
||||
* Star *ourSun: the sun's position is needed to convert heliocentric
|
||||
* coordinates into geocentric coordinates.
|
||||
*
|
||||
* return value: none
|
||||
*
|
||||
*************************************************************************/
|
||||
void CelestialBody::updatePosition(FGTime *t, Star *ourSun)
|
||||
void CelestialBody::updatePosition(double mjd, Star *ourSun)
|
||||
{
|
||||
double eccAnom, v, ecl, actTime,
|
||||
xv, yv, xh, yh, zh, xg, yg, zg, xe, ye, ze;
|
||||
|
||||
updateOrbElements(t);
|
||||
actTime = fgCalcActTime(t);
|
||||
updateOrbElements(mjd);
|
||||
actTime = sgCalcActTime(mjd);
|
||||
|
||||
// calcualate the angle bewteen ecliptic and equatorial coordinate system
|
||||
ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 *actTime);
|
||||
ecl = SGD_DEGREES_TO_RADIANS * (23.4393 - 3.563E-7 *actTime);
|
||||
|
||||
eccAnom = fgCalcEccAnom(M, e); //calculate the eccentric anomaly
|
||||
eccAnom = sgCalcEccAnom(M, e); //calculate the eccentric anomaly
|
||||
xv = a * (cos(eccAnom) - e);
|
||||
yv = a * (sqrt (1.0 - e*e) * sin(eccAnom));
|
||||
v = atan2(yv, xv); // the planet's true anomaly
|
||||
@@ -85,8 +88,8 @@ void CelestialBody::updatePosition(FGTime *t, Star *ourSun)
|
||||
ze = yg * sin(ecl) + zg * cos(ecl);
|
||||
rightAscension = atan2(ye, xe);
|
||||
declination = atan2(ze, sqrt(xe*xe + ye*ye));
|
||||
FG_LOG(FG_GENERAL, FG_INFO, "Planet found at : "
|
||||
<< rightAscension << " (ra), " << declination << " (dec)" );
|
||||
/* SG_LOG(SG_GENERAL, SG_INFO, "Planet found at : "
|
||||
<< rightAscension << " (ra), " << declination << " (dec)" ); */
|
||||
|
||||
//calculate some variables specific to calculating the magnitude
|
||||
//of the planet
|
||||
@@ -104,11 +107,11 @@ void CelestialBody::updatePosition(FGTime *t, Star *ourSun)
|
||||
tmp = -1.0;
|
||||
}
|
||||
|
||||
FV = RAD_TO_DEG * acos( tmp );
|
||||
};
|
||||
FV = SGD_RADIANS_TO_DEGREES * acos( tmp );
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* double CelestialBody::fgCalcEccAnom(double M, double e)
|
||||
* double CelestialBody::sgCalcEccAnom(double M, double e)
|
||||
* this private member calculates the eccentric anomaly of a celestial body,
|
||||
* given its mean anomaly and eccentricity.
|
||||
*
|
||||
@@ -133,7 +136,7 @@ void CelestialBody::updatePosition(FGTime *t, Star *ourSun)
|
||||
* the eccentric anomaly
|
||||
*
|
||||
****************************************************************************/
|
||||
double CelestialBody::fgCalcEccAnom(double M, double e)
|
||||
double CelestialBody::sgCalcEccAnom(double M, double e)
|
||||
{
|
||||
double
|
||||
eccAnom, E0, E1, diff;
|
||||
@@ -149,28 +152,118 @@ double CelestialBody::fgCalcEccAnom(double M, double e)
|
||||
diff = fabs(E0 - E1);
|
||||
E0 = E1;
|
||||
}
|
||||
while (diff > (DEG_TO_RAD * 0.001));
|
||||
while (diff > (SGD_DEGREES_TO_RADIANS * 0.001));
|
||||
return E0;
|
||||
}
|
||||
return eccAnom;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* inline CelestialBody::CelestialBody
|
||||
* public constructor for a generic celestialBody object.
|
||||
* initializes the 6 primary orbital elements. The elements are:
|
||||
* N: longitude of the ascending node
|
||||
* i: inclination to the ecliptic
|
||||
* w: argument of perihelion
|
||||
* a: semi-major axis, or mean distance from the sun
|
||||
* e: eccenticity
|
||||
* M: mean anomaly
|
||||
* Each orbital element consists of a constant part and a variable part that
|
||||
* gradually changes over time.
|
||||
*
|
||||
* Argumetns:
|
||||
* the 13 arguments to the constructor constitute the first, constant
|
||||
* ([NiwaeM]f) and the second variable ([NiwaeM]s) part of the orbital
|
||||
* elements. The 13th argument is the current time. Note that the inclination
|
||||
* is written with a capital (If, Is), because 'if' is a reserved word in the
|
||||
* C/C++ programming language.
|
||||
***************************************************************************/
|
||||
CelestialBody::CelestialBody(double Nf, double Ns,
|
||||
double If, double Is,
|
||||
double wf, double ws,
|
||||
double af, double as,
|
||||
double ef, double es,
|
||||
double Mf, double Ms, double mjd)
|
||||
{
|
||||
NFirst = Nf; NSec = Ns;
|
||||
iFirst = If; iSec = Is;
|
||||
wFirst = wf; wSec = ws;
|
||||
aFirst = af; aSec = as;
|
||||
eFirst = ef; eSec = es;
|
||||
MFirst = Mf; MSec = Ms;
|
||||
updateOrbElements(mjd);
|
||||
}
|
||||
|
||||
CelestialBody::CelestialBody(double Nf, double Ns,
|
||||
double If, double Is,
|
||||
double wf, double ws,
|
||||
double af, double as,
|
||||
double ef, double es,
|
||||
double Mf, double Ms)
|
||||
{
|
||||
NFirst = Nf; NSec = Ns;
|
||||
iFirst = If; iSec = Is;
|
||||
wFirst = wf; wSec = ws;
|
||||
aFirst = af; aSec = as;
|
||||
eFirst = ef; eSec = es;
|
||||
MFirst = Mf; MSec = Ms;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* inline void CelestialBody::updateOrbElements(double mjd)
|
||||
* given the current time, this private member calculates the actual
|
||||
* orbital elements
|
||||
*
|
||||
* Arguments: double mjd: the current modified julian date:
|
||||
*
|
||||
* return value: none
|
||||
***************************************************************************/
|
||||
void CelestialBody::updateOrbElements(double mjd)
|
||||
{
|
||||
double actTime = sgCalcActTime(mjd);
|
||||
M = SGD_DEGREES_TO_RADIANS * (MFirst + (MSec * actTime));
|
||||
w = SGD_DEGREES_TO_RADIANS * (wFirst + (wSec * actTime));
|
||||
N = SGD_DEGREES_TO_RADIANS * (NFirst + (NSec * actTime));
|
||||
i = SGD_DEGREES_TO_RADIANS * (iFirst + (iSec * actTime));
|
||||
e = eFirst + (eSec * actTime);
|
||||
a = aFirst + (aSec * actTime);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* inline double CelestialBody::sgCalcActTime(double mjd)
|
||||
* this private member function returns the offset in days from the epoch for
|
||||
* wich the orbital elements are calculated (Jan, 1st, 2000).
|
||||
*
|
||||
* Argument: the current time
|
||||
*
|
||||
* return value: the (fractional) number of days until Jan 1, 2000.
|
||||
****************************************************************************/
|
||||
double CelestialBody::sgCalcActTime(double mjd)
|
||||
{
|
||||
return (mjd - 36523.5);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* inline void CelestialBody::getPos(double* ra, double* dec)
|
||||
* gives public access to Right Ascension and declination
|
||||
*
|
||||
****************************************************************************/
|
||||
void CelestialBody::getPos(double* ra, double* dec)
|
||||
{
|
||||
*ra = rightAscension;
|
||||
*dec = declination;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* inline void CelestialBody::getPos(double* ra, double* dec, double* magnitude
|
||||
* gives public acces to the current Right ascension, declination, and
|
||||
* magnitude
|
||||
****************************************************************************/
|
||||
void CelestialBody::getPos(double* ra, double* dec, double* magn)
|
||||
{
|
||||
*ra = rightAscension;
|
||||
*dec = declination;
|
||||
*magn = magnitude;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,19 +5,20 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
@@ -31,15 +32,14 @@
|
||||
#endif
|
||||
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include <Include/fg_constants.h>
|
||||
#include <simgear/constants.h>
|
||||
|
||||
class Star;
|
||||
|
||||
class CelestialBody
|
||||
{
|
||||
protected: // make the data protected, in order to give the inherited
|
||||
// classes direct access to the data
|
||||
protected: // make the data protected, in order to give the
|
||||
// inherited classes direct access to the data
|
||||
double NFirst; /* longitude of the ascending node first part */
|
||||
double NSec; /* longitude of the ascending node second part */
|
||||
double iFirst; /* inclination to the ecliptic first part */
|
||||
@@ -60,9 +60,9 @@ protected: // make the data protected, in order to give the inherit
|
||||
double magnitude;
|
||||
double lonEcl, latEcl;
|
||||
|
||||
double fgCalcEccAnom(double M, double e);
|
||||
double fgCalcActTime(FGTime *t);
|
||||
void updateOrbElements(FGTime *t);
|
||||
double sgCalcEccAnom(double M, double e);
|
||||
double sgCalcActTime(double mjd);
|
||||
void updateOrbElements(double mjd);
|
||||
|
||||
public:
|
||||
CelestialBody(double Nf, double Ns,
|
||||
@@ -70,105 +70,26 @@ public:
|
||||
double wf, double ws,
|
||||
double af, double as,
|
||||
double ef, double es,
|
||||
double Mf, double Ms, FGTime *t);
|
||||
double Mf, double Ms, double mjd);
|
||||
CelestialBody(double Nf, double Ns,
|
||||
double If, double Is,
|
||||
double wf, double ws,
|
||||
double af, double as,
|
||||
double ef, double es,
|
||||
double Mf, double Ms);
|
||||
void getPos(double *ra, double *dec);
|
||||
void getPos(double *ra, double *dec, double *magnitude);
|
||||
double getRightAscension();
|
||||
double getDeclination();
|
||||
double getMagnitude();
|
||||
double getLon();
|
||||
double getLat();
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
void updatePosition(double mjd, Star *ourSun);
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
* inline CelestialBody::CelestialBody
|
||||
* public constructor for a generic celestialBody object.
|
||||
* initializes the 6 primary orbital elements. The elements are:
|
||||
* N: longitude of the ascending node
|
||||
* i: inclination to the ecliptic
|
||||
* w: argument of perihelion
|
||||
* a: semi-major axis, or mean distance from the sun
|
||||
* e: eccenticity
|
||||
* M: mean anomaly
|
||||
* Each orbital element consists of a constant part and a variable part that
|
||||
* gradually changes over time.
|
||||
*
|
||||
* Argumetns:
|
||||
* the 13 arguments to the constructor constitute the first, constant
|
||||
* ([NiwaeM]f) and the second variable ([NiwaeM]s) part of the orbital
|
||||
* elements. The 13th argument is the current time. Note that the inclination
|
||||
* is written with a capital (If, Is), because 'if' is a reserved word in the
|
||||
* C/C++ programming language.
|
||||
***************************************************************************/
|
||||
inline CelestialBody::CelestialBody(double Nf, double Ns,
|
||||
double If, double Is,
|
||||
double wf, double ws,
|
||||
double af, double as,
|
||||
double ef, double es,
|
||||
double Mf, double Ms, FGTime *t)
|
||||
{
|
||||
NFirst = Nf; NSec = Ns;
|
||||
iFirst = If; iSec = Is;
|
||||
wFirst = wf; wSec = ws;
|
||||
aFirst = af; aSec = as;
|
||||
eFirst = ef; eSec = es;
|
||||
MFirst = Mf; MSec = Ms;
|
||||
updateOrbElements(t);
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* inline void CelestialBody::updateOrbElements(FGTime *t)
|
||||
* given the current time, this private member calculates the actual
|
||||
* orbital elements
|
||||
*
|
||||
* Arguments: FGTime *t: the current time:
|
||||
*
|
||||
* return value: none
|
||||
***************************************************************************/
|
||||
inline void CelestialBody::updateOrbElements(FGTime *t)
|
||||
{
|
||||
double actTime = fgCalcActTime(t);
|
||||
M = DEG_TO_RAD * (MFirst + (MSec * actTime));
|
||||
w = DEG_TO_RAD * (wFirst + (wSec * actTime));
|
||||
N = DEG_TO_RAD * (NFirst + (NSec * actTime));
|
||||
i = DEG_TO_RAD * (iFirst + (iSec * actTime));
|
||||
e = eFirst + (eSec * actTime);
|
||||
a = aFirst + (aSec * actTime);
|
||||
}
|
||||
/*****************************************************************************
|
||||
* inline double CelestialBody::fgCalcActTime(FGTime *t)
|
||||
* this private member function returns the offset in days from the epoch for
|
||||
* wich the orbital elements are calculated (Jan, 1st, 2000).
|
||||
*
|
||||
* Argument: the current time
|
||||
*
|
||||
* return value: the (fractional) number of days until Jan 1, 2000.
|
||||
****************************************************************************/
|
||||
inline double CelestialBody::fgCalcActTime(FGTime *t)
|
||||
{
|
||||
return (t->getMjd() - 36523.5);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* inline void CelestialBody::getPos(double* ra, double* dec)
|
||||
* gives public access to Right Ascension and declination
|
||||
*
|
||||
****************************************************************************/
|
||||
inline void CelestialBody::getPos(double* ra, double* dec)
|
||||
{
|
||||
*ra = rightAscension;
|
||||
*dec = declination;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* inline void CelestialBody::getPos(double* ra, double* dec, double* magnitude
|
||||
* gives public acces to the current Right ascension, declination, and
|
||||
* magnitude
|
||||
****************************************************************************/
|
||||
inline void CelestialBody::getPos(double* ra, double* dec, double* magn)
|
||||
{
|
||||
*ra = rightAscension;
|
||||
*dec = declination;
|
||||
*magn = magnitude;
|
||||
}
|
||||
inline double CelestialBody::getRightAscension() { return rightAscension; }
|
||||
inline double CelestialBody::getDeclination() { return declination; }
|
||||
inline double CelestialBody::getMagnitude() { return magnitude; }
|
||||
|
||||
inline double CelestialBody::getLon()
|
||||
{
|
||||
@@ -182,14 +103,3 @@ inline double CelestialBody::getLat()
|
||||
|
||||
#endif // _CELESTIALBODY_H_
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
83
simgear/ephemeris/ephemeris.cxx
Normal file
83
simgear/ephemeris/ephemeris.cxx
Normal file
@@ -0,0 +1,83 @@
|
||||
// ephemeris.cxx -- Top level class for calculating current positions of
|
||||
// astronomical objects
|
||||
//
|
||||
// Written by Curtis Olson, started March 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the
|
||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
|
||||
#include "ephemeris.hxx"
|
||||
|
||||
|
||||
// Constructor
|
||||
SGEphemeris::SGEphemeris( const string &path ) {
|
||||
our_sun = new Star;
|
||||
moon = new MoonPos;
|
||||
mercury = new Mercury;
|
||||
venus = new Venus;
|
||||
mars = new Mars;
|
||||
jupiter = new Jupiter;
|
||||
saturn = new Saturn;
|
||||
uranus = new Uranus;
|
||||
neptune = new Neptune;
|
||||
stars = new SGStarData( SGPath(path) );
|
||||
}
|
||||
|
||||
|
||||
// Destructor
|
||||
SGEphemeris::~SGEphemeris( void ) {
|
||||
delete our_sun;
|
||||
delete moon;
|
||||
delete mercury;
|
||||
delete venus;
|
||||
delete mars;
|
||||
delete jupiter;
|
||||
delete saturn;
|
||||
delete uranus;
|
||||
delete neptune;
|
||||
delete stars;
|
||||
}
|
||||
|
||||
|
||||
// Update (recalculate) the positions of all objects for the specified
|
||||
// time
|
||||
void SGEphemeris::update( double mjd, double lst, double lat ) {
|
||||
// update object positions
|
||||
our_sun->updatePosition( mjd );
|
||||
moon->updatePosition( mjd, lst, lat, our_sun );
|
||||
mercury->updatePosition( mjd, our_sun );
|
||||
venus->updatePosition( mjd, our_sun );
|
||||
mars->updatePosition( mjd, our_sun );
|
||||
jupiter->updatePosition( mjd, our_sun );
|
||||
saturn->updatePosition( mjd, our_sun );
|
||||
uranus->updatePosition( mjd, our_sun );
|
||||
neptune->updatePosition( mjd, our_sun );
|
||||
|
||||
// update planets list
|
||||
nplanets = 7;
|
||||
mercury->getPos( &planets[0][0], &planets[0][1], &planets[0][2] );
|
||||
venus ->getPos( &planets[1][0], &planets[1][1], &planets[1][2] );
|
||||
mars ->getPos( &planets[2][0], &planets[2][1], &planets[2][2] );
|
||||
jupiter->getPos( &planets[3][0], &planets[3][1], &planets[3][2] );
|
||||
saturn ->getPos( &planets[4][0], &planets[4][1], &planets[4][2] );
|
||||
uranus ->getPos( &planets[5][0], &planets[5][1], &planets[5][2] );
|
||||
neptune->getPos( &planets[6][0], &planets[6][1], &planets[6][2] );
|
||||
}
|
||||
|
||||
177
simgear/ephemeris/ephemeris.hxx
Normal file
177
simgear/ephemeris/ephemeris.hxx
Normal file
@@ -0,0 +1,177 @@
|
||||
/** \file ephemeris.hxx
|
||||
* Top level class for calculating current positions of astronomical objects.
|
||||
*/
|
||||
|
||||
// Top level interface written by Curtis Olson, started March 2000.
|
||||
//
|
||||
// All the core code underneath this is written by Durk Talsma. See
|
||||
// the headers of all the other individual files for details.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the
|
||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
|
||||
#ifndef _EPHEMERIS_HXX
|
||||
#define _EPHEMERIS_HXX
|
||||
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
#include <simgear/ephemeris/moonpos.hxx>
|
||||
#include <simgear/ephemeris/mercury.hxx>
|
||||
#include <simgear/ephemeris/venus.hxx>
|
||||
#include <simgear/ephemeris/mars.hxx>
|
||||
#include <simgear/ephemeris/jupiter.hxx>
|
||||
#include <simgear/ephemeris/saturn.hxx>
|
||||
#include <simgear/ephemeris/uranus.hxx>
|
||||
#include <simgear/ephemeris/neptune.hxx>
|
||||
#include <simgear/ephemeris/stardata.hxx>
|
||||
|
||||
|
||||
/** Ephemeris class
|
||||
*
|
||||
* Written by Durk Talsma <d.talsma@direct.a2000.nl> and Curtis Olson
|
||||
* <curt@flightgear.org>
|
||||
*
|
||||
* Introduction
|
||||
*
|
||||
* The SGEphemeris class computes and stores the positions of the Sun,
|
||||
* the Moon, the planets, and the brightest stars. These positions
|
||||
* can then be used to accurately render the dominant visible items in
|
||||
* the Earth's sky. Note, this class isn't intended for use in an
|
||||
* interplanetary/interstellar/intergalactic type application. It is
|
||||
* calculates everything relative to the Earth and is therefore best
|
||||
* suited for Earth centric applications.
|
||||
*
|
||||
* The positions of the various astronomical objects are time
|
||||
* dependent, so to maintain accuracy, you will need to periodically
|
||||
* call the update() method. The SGTime class conveniently provides
|
||||
* the two time related values you need to pass to the update()
|
||||
* method.
|
||||
*/
|
||||
|
||||
class SGEphemeris {
|
||||
|
||||
Star *our_sun;
|
||||
MoonPos *moon;
|
||||
Mercury *mercury;
|
||||
Venus *venus;
|
||||
Mars *mars;
|
||||
Jupiter *jupiter;
|
||||
Saturn *saturn;
|
||||
Uranus *uranus;
|
||||
Neptune *neptune;
|
||||
|
||||
// 9 planets, minus earth, minus pluto which we don't draw = 7
|
||||
// planets[i][0] = Right Ascension
|
||||
// planets[i][1] = Declination
|
||||
// planets[i][2] = Magnitude
|
||||
int nplanets;
|
||||
sgdVec3 planets[7];
|
||||
|
||||
SGStarData *stars;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* This creates an instance of the SGEphemeris object. When
|
||||
* calling the constructor you need to provide a path pointing to
|
||||
* your star database file.
|
||||
* @param path path to your star database */
|
||||
SGEphemeris( const string &path );
|
||||
|
||||
/** Destructor */
|
||||
~SGEphemeris( void );
|
||||
|
||||
/**
|
||||
* Update (recalculate) the positions of all objects for the
|
||||
* specified time. The update() method requires you to pass in
|
||||
* the current modified Julian date, the current local sidereal
|
||||
* time, and the current latitude. The update() method is designed
|
||||
* to be called by the host application before every frame.
|
||||
* @param mjd modified julian date
|
||||
* @param lst current local sidereal time
|
||||
* @param lat current latitude
|
||||
*/
|
||||
void update(double mjd, double lst, double lat);
|
||||
|
||||
/**
|
||||
* @return a pointer to a Star class containing all the positional
|
||||
* information for Earth's Sun.
|
||||
*/
|
||||
inline Star *get_sun() const { return our_sun; }
|
||||
|
||||
/** @return the right ascension of the Sun. */
|
||||
inline double getSunRightAscension() const {
|
||||
return our_sun->getRightAscension();
|
||||
}
|
||||
|
||||
/** @return the declination of the Sun. */
|
||||
inline double getSunDeclination() const {
|
||||
return our_sun->getDeclination();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a pointer to a Moon class containing all the positional
|
||||
* information for Earth's Moon.
|
||||
*/
|
||||
inline MoonPos *get_moon() const { return moon; }
|
||||
|
||||
/** @return the right ascension of the Moon. */
|
||||
inline double getMoonRightAscension() const {
|
||||
return moon->getRightAscension();
|
||||
}
|
||||
|
||||
/** @return the declination of the Moon. */
|
||||
inline double getMoonDeclination() const {
|
||||
return moon->getDeclination();
|
||||
}
|
||||
|
||||
/** @return the numbers of defined planets. */
|
||||
inline int getNumPlanets() const { return nplanets; }
|
||||
|
||||
/**
|
||||
* Returns a pointer to an array of planet data in sgdVec3
|
||||
* format. (See plib.sourceforge.net for information on plib and
|
||||
* the ``sg'' package.) An sgdVec3 is a 3 element double
|
||||
* array. The first element is the right ascension of the planet,
|
||||
* the second is the declination, and the third is the magnitude.
|
||||
* @return planets array
|
||||
*/
|
||||
inline sgdVec3 *getPlanets() { return planets; }
|
||||
|
||||
/** @return the numbers of defined stars. */
|
||||
inline int getNumStars() const { return stars->getNumStars(); }
|
||||
|
||||
/**
|
||||
* Returns a pointer to an array of star data in sgdVec3
|
||||
* format. An The first element of the sgdVec3 is the right
|
||||
* ascension of the planet, the second is the declination, and the
|
||||
* third is the magnitude.
|
||||
* @returns star array
|
||||
*/
|
||||
inline sgdVec3 *getStars() { return stars->getStars(); }
|
||||
};
|
||||
|
||||
|
||||
#endif // _EPHEMERIS_HXX
|
||||
|
||||
|
||||
@@ -5,19 +5,20 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
@@ -31,32 +32,42 @@
|
||||
#include "jupiter.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Jupiter::Jupiter(FGTime *t)
|
||||
* Jupiter::Jupiter(double mjd)
|
||||
* Public constructor for class Jupiter
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Jupiter are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Jupiter::Jupiter(FGTime *t) :
|
||||
Jupiter::Jupiter(double mjd) :
|
||||
CelestialBody(100.4542, 2.7685400E-5,
|
||||
1.3030, -1.557E-7,
|
||||
273.8777, 1.6450500E-5,
|
||||
5.2025600, 0.000000,
|
||||
0.048498, 4.469E-9,
|
||||
19.89500, 0.08308530010, t)
|
||||
19.89500, 0.08308530010, mjd)
|
||||
{
|
||||
}
|
||||
|
||||
Jupiter::Jupiter() :
|
||||
CelestialBody(100.4542, 2.7685400E-5,
|
||||
1.3030, -1.557E-7,
|
||||
273.8777, 1.6450500E-5,
|
||||
5.2025600, 0.000000,
|
||||
0.048498, 4.469E-9,
|
||||
19.89500, 0.08308530010)
|
||||
{
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* void Jupiter::updatePosition(FGTime *t, Star *ourSun)
|
||||
* void Jupiter::updatePosition(double mjd, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Jupiter, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Jupiter specific equation
|
||||
*************************************************************************/
|
||||
void Jupiter::updatePosition(FGTime *t, Star *ourSun)
|
||||
void Jupiter::updatePosition(double mjd, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
CelestialBody::updatePosition(mjd, ourSun);
|
||||
magnitude = -9.25 + 5*log10( r*R ) + 0.014 * FV;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,34 +5,35 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
#ifndef _JUPITER_HXX_
|
||||
#define _JUPITER_HXX_
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
#include <simgear/ephemeris/celestialBody.hxx>
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
|
||||
class Jupiter : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Jupiter (FGTime *t);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
Jupiter (double mjd);
|
||||
Jupiter ();
|
||||
void updatePosition(double mjd, Star *ourSun);
|
||||
};
|
||||
|
||||
#endif // _JUPITER_HXX_
|
||||
|
||||
@@ -5,19 +5,20 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
@@ -30,30 +31,39 @@
|
||||
#include "mars.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Mars::Mars(FGTime *t)
|
||||
* Mars::Mars(double mjd)
|
||||
* Public constructor for class Mars
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Mars are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Mars::Mars(FGTime *t) :
|
||||
Mars::Mars(double mjd) :
|
||||
CelestialBody(49.55740, 2.1108100E-5,
|
||||
1.8497, -1.78E-8,
|
||||
286.5016, 2.9296100E-5,
|
||||
1.5236880, 0.000000,
|
||||
0.093405, 2.516E-9,
|
||||
18.60210, 0.52402077660, t)
|
||||
18.60210, 0.52402077660, mjd)
|
||||
{
|
||||
}
|
||||
Mars::Mars() :
|
||||
CelestialBody(49.55740, 2.1108100E-5,
|
||||
1.8497, -1.78E-8,
|
||||
286.5016, 2.9296100E-5,
|
||||
1.5236880, 0.000000,
|
||||
0.093405, 2.516E-9,
|
||||
18.60210, 0.52402077660)
|
||||
{
|
||||
}
|
||||
/*************************************************************************
|
||||
* void Mars::updatePosition(FGTime *t, Star *ourSun)
|
||||
* void Mars::updatePosition(double mjd, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Mars, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Mars specific equation
|
||||
*************************************************************************/
|
||||
void Mars::updatePosition(FGTime *t, Star *ourSun)
|
||||
void Mars::updatePosition(double mjd, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
CelestialBody::updatePosition(mjd, ourSun);
|
||||
magnitude = -1.51 + 5*log10( r*R ) + 0.016 * FV;
|
||||
}
|
||||
|
||||
@@ -5,34 +5,35 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
#ifndef _MARS_HXX_
|
||||
#define _MARS_HXX_
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
#include <simgear/ephemeris/celestialBody.hxx>
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
|
||||
class Mars : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Mars ( FGTime *t);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
Mars ( double mjd );
|
||||
Mars ();
|
||||
void updatePosition(double mjd, Star *ourSun);
|
||||
};
|
||||
|
||||
#endif // _MARS_HXX_
|
||||
|
||||
@@ -5,19 +5,20 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
@@ -30,31 +31,40 @@
|
||||
#include "mercury.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Mercury::Mercury(FGTime *t)
|
||||
* Mercury::Mercury(double mjd)
|
||||
* Public constructor for class Mercury
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Mercury are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Mercury::Mercury(FGTime *t) :
|
||||
Mercury::Mercury(double mjd) :
|
||||
CelestialBody (48.33130, 3.2458700E-5,
|
||||
7.0047, 5.00E-8,
|
||||
29.12410, 1.0144400E-5,
|
||||
0.3870980, 0.000000,
|
||||
0.205635, 5.59E-10,
|
||||
168.6562, 4.09233443680, t)
|
||||
168.6562, 4.09233443680, mjd)
|
||||
{
|
||||
}
|
||||
Mercury::Mercury() :
|
||||
CelestialBody (48.33130, 3.2458700E-5,
|
||||
7.0047, 5.00E-8,
|
||||
29.12410, 1.0144400E-5,
|
||||
0.3870980, 0.000000,
|
||||
0.205635, 5.59E-10,
|
||||
168.6562, 4.09233443680)
|
||||
{
|
||||
}
|
||||
/*************************************************************************
|
||||
* void Mercury::updatePosition(FGTime *t, Star *ourSun)
|
||||
* void Mercury::updatePosition(double mjd, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Mercury, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Mercury specific equation
|
||||
*************************************************************************/
|
||||
void Mercury::updatePosition(FGTime *t, Star *ourSun)
|
||||
void Mercury::updatePosition(double mjd, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
CelestialBody::updatePosition(mjd, ourSun);
|
||||
magnitude = -0.36 + 5*log10( r*R ) + 0.027 * FV + 2.2E-13 * pow(FV, 6);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,34 +5,35 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
#ifndef _MERCURY_HXX_
|
||||
#define _MERCURY_HXX_
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
#include <simgear/ephemeris/celestialBody.hxx>
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
|
||||
class Mercury : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Mercury ( FGTime *t);
|
||||
void updatePosition(FGTime *t, Star* ourSun);
|
||||
Mercury (double mjd);
|
||||
Mercury ();
|
||||
void updatePosition(double mjd, Star* ourSun);
|
||||
};
|
||||
|
||||
#endif // _MERURY_HXX_
|
||||
|
||||
@@ -1,400 +0,0 @@
|
||||
/**************************************************************************
|
||||
* moon.cxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
|
||||
#include <FDM/flight.hxx>
|
||||
|
||||
#include <string.h>
|
||||
#include "moon.hxx"
|
||||
|
||||
#include <Debug/logstream.hxx>
|
||||
#include <Main/options.hxx>
|
||||
#include <Misc/fgpath.hxx>
|
||||
#include <Objects/texload.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# define exception c_exception
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Moon::Moon(FGTime *t)
|
||||
* Public constructor for class Moon. Initializes the orbital elements and
|
||||
* sets up the moon texture.
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Moon are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Moon::Moon(FGTime *t) :
|
||||
CelestialBody(125.1228, -0.0529538083,
|
||||
5.1454, 0.00000,
|
||||
318.0634, 0.1643573223,
|
||||
60.266600, 0.000000,
|
||||
0.054900, 0.000000,
|
||||
115.3654, 13.0649929509, t)
|
||||
{
|
||||
int width, height;
|
||||
|
||||
FG_LOG( FG_GENERAL, FG_INFO, "Initializing Moon Texture");
|
||||
#ifdef GL_VERSION_1_1
|
||||
xglGenTextures(1, &moon_texid);
|
||||
xglBindTexture(GL_TEXTURE_2D, moon_texid);
|
||||
#elif GL_EXT_texture_object
|
||||
xglGenTexturesEXT(1, &moon_texid);
|
||||
xglBindTextureEXT(GL_TEXTURE_2D, moon_texid);
|
||||
#else
|
||||
# error port me
|
||||
#endif
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
// load in the texture data
|
||||
FGPath tpath( current_options.get_fg_root() );
|
||||
tpath.append( "Textures" );
|
||||
tpath.append( "moon.rgb" );
|
||||
|
||||
if ( (moon_texbuf = read_rgb_texture(tpath.c_str(), &width, &height))
|
||||
== NULL )
|
||||
{
|
||||
// Try compressed
|
||||
FGPath fg_tpath = tpath;
|
||||
fg_tpath.append( ".gz" );
|
||||
if ( (moon_texbuf = read_rgb_texture(fg_tpath.c_str(), &width, &height))
|
||||
== NULL )
|
||||
{
|
||||
FG_LOG( FG_GENERAL, FG_ALERT,
|
||||
"Error in loading moon texture " << tpath.str() );
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
glTexImage2D( GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGB,
|
||||
256, 256,
|
||||
0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE,
|
||||
moon_texbuf);
|
||||
|
||||
// setup the halo texture
|
||||
FG_LOG( FG_GENERAL, FG_INFO, "Initializing Moon Texture");
|
||||
#ifdef GL_VERSION_1_1
|
||||
xglGenTextures(1, &moon_halotexid);
|
||||
xglBindTexture(GL_TEXTURE_2D, moon_halotexid);
|
||||
#elif GL_EXT_texture_object
|
||||
xglGenTexturesEXT(1, &moon_halotexid);
|
||||
xglBindTextureEXT(GL_TEXTURE_2D, moon_halotexid);
|
||||
#else
|
||||
# error port me
|
||||
#endif
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
setHalo();
|
||||
glTexImage2D( GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGBA,
|
||||
256, 256,
|
||||
0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
moon_halotexbuf);
|
||||
moonObject = gluNewQuadric();
|
||||
}
|
||||
|
||||
Moon::~Moon()
|
||||
{
|
||||
//delete moonObject;
|
||||
delete moon_texbuf;
|
||||
delete moon_halotexbuf;
|
||||
}
|
||||
|
||||
|
||||
static int texWidth = 256; /* 64x64 is plenty */
|
||||
|
||||
void Moon::setHalo()
|
||||
{
|
||||
int texSize;
|
||||
//void *textureBuf;
|
||||
GLubyte *p;
|
||||
int i,j;
|
||||
double radius;
|
||||
|
||||
texSize = texWidth*texWidth;
|
||||
|
||||
moon_halotexbuf = new GLubyte[texSize*4];
|
||||
if (!moon_halotexbuf)
|
||||
return; // Ugly!
|
||||
|
||||
p = moon_halotexbuf;
|
||||
|
||||
radius = (double)(texWidth / 2);
|
||||
|
||||
for (i=0; i < texWidth; i++) {
|
||||
for (j=0; j < texWidth; j++) {
|
||||
double x, y, d;
|
||||
|
||||
x = fabs((double)(i - (texWidth / 2)));
|
||||
y = fabs((double)(j - (texWidth / 2)));
|
||||
|
||||
d = sqrt((x * x) + (y * y));
|
||||
if (d < radius)
|
||||
{
|
||||
double t = 1.0 - (d / radius); // t is 1.0 at center, 0.0 at edge */
|
||||
// inverse square looks nice
|
||||
*p = (int)((double)0xff * (t * t));
|
||||
*(p+1) = (int)((double) 0xff * (t*t));
|
||||
*(p+2) = (int)((double) 0xff * (t*t));
|
||||
*(p+3) = 0x11;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p = 0x00;
|
||||
*(p+1) = 0x00;
|
||||
*(p+2) = 0x00;
|
||||
*(p+3) = 0x11;
|
||||
}
|
||||
p += 4;
|
||||
}
|
||||
}
|
||||
//gluBuild2DMipmaps(GL_TEXTURE_2D, 1, texWidth, texWidth,
|
||||
// GL_LUMINANCE,
|
||||
// GL_UNSIGNED_BYTE, textureBuf);
|
||||
//free(textureBuf);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* void Moon::updatePosition(FGTime *t, Star *ourSun)
|
||||
* this member function calculates the actual topocentric position (i.e.)
|
||||
* the position of the moon as seen from the current position on the surface
|
||||
* of the moon.
|
||||
****************************************************************************/
|
||||
void Moon::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
double
|
||||
eccAnom, ecl, actTime,
|
||||
xv, yv, v, r, xh, yh, zh, xg, yg, zg, xe, ye, ze,
|
||||
Ls, Lm, D, F, mpar, gclat, rho, HA, g,
|
||||
geoRa, geoDec;
|
||||
|
||||
fgAIRCRAFT *air;
|
||||
FGInterface *f;
|
||||
|
||||
air = ¤t_aircraft;
|
||||
f = air->fdm_state;
|
||||
|
||||
updateOrbElements(t);
|
||||
actTime = fgCalcActTime(t);
|
||||
|
||||
// calculate the angle between ecliptic and equatorial coordinate system
|
||||
// in Radians
|
||||
ecl = ((DEG_TO_RAD * 23.4393) - (DEG_TO_RAD * 3.563E-7) * actTime);
|
||||
eccAnom = fgCalcEccAnom(M, e); // Calculate the eccentric anomaly
|
||||
xv = a * (cos(eccAnom) - e);
|
||||
yv = a * (sqrt(1.0 - e*e) * sin(eccAnom));
|
||||
v = atan2(yv, xv); // the moon's true anomaly
|
||||
r = sqrt (xv*xv + yv*yv); // and its distance
|
||||
|
||||
// estimate the geocentric rectangular coordinates here
|
||||
xh = r * (cos(N) * cos (v+w) - sin (N) * sin(v+w) * cos(i));
|
||||
yh = r * (sin(N) * cos (v+w) + cos (N) * sin(v+w) * cos(i));
|
||||
zh = r * (sin(v+w) * sin(i));
|
||||
|
||||
// calculate the ecliptic latitude and longitude here
|
||||
lonEcl = atan2 (yh, xh);
|
||||
latEcl = atan2(zh, sqrt(xh*xh + yh*yh));
|
||||
|
||||
/* Calculate a number of perturbatioin, i.e. disturbances caused by the
|
||||
* gravitational infuence of the sun and the other major planets.
|
||||
* The largest of these even have a name */
|
||||
Ls = ourSun->getM() + ourSun->getw();
|
||||
Lm = M + w + N;
|
||||
D = Lm - Ls;
|
||||
F = Lm - N;
|
||||
|
||||
lonEcl += DEG_TO_RAD * (-1.274 * sin (M - 2*D)
|
||||
+0.658 * sin (2*D)
|
||||
-0.186 * sin(ourSun->getM())
|
||||
-0.059 * sin(2*M - 2*D)
|
||||
-0.057 * sin(M - 2*D + ourSun->getM())
|
||||
+0.053 * sin(M + 2*D)
|
||||
+0.046 * sin(2*D - ourSun->getM())
|
||||
+0.041 * sin(M - ourSun->getM())
|
||||
-0.035 * sin(D)
|
||||
-0.031 * sin(M + ourSun->getM())
|
||||
-0.015 * sin(2*F - 2*D)
|
||||
+0.011 * sin(M - 4*D)
|
||||
);
|
||||
latEcl += DEG_TO_RAD * (-0.173 * sin(F-2*D)
|
||||
-0.055 * sin(M - F - 2*D)
|
||||
-0.046 * sin(M + F - 2*D)
|
||||
+0.033 * sin(F + 2*D)
|
||||
+0.017 * sin(2*M + F)
|
||||
);
|
||||
r += (-0.58 * cos(M - 2*D)
|
||||
-0.46 * cos(2*D)
|
||||
);
|
||||
FG_LOG(FG_GENERAL, FG_INFO, "Running moon update");
|
||||
xg = r * cos(lonEcl) * cos(latEcl);
|
||||
yg = r * sin(lonEcl) * cos(latEcl);
|
||||
zg = r * sin(latEcl);
|
||||
|
||||
xe = xg;
|
||||
ye = yg * cos(ecl) -zg * sin(ecl);
|
||||
ze = yg * sin(ecl) +zg * cos(ecl);
|
||||
|
||||
geoRa = atan2(ye, xe);
|
||||
geoDec = atan2(ze, sqrt(xe*xe + ye*ye));
|
||||
|
||||
/* FG_LOG( FG_GENERAL, FG_INFO,
|
||||
"(geocentric) geoRa = (" << (RAD_TO_DEG * geoRa)
|
||||
<< "), geoDec= (" << (RAD_TO_DEG * geoDec) << ")" ); */
|
||||
|
||||
|
||||
// Given the moon's geocentric ra and dec, calculate its
|
||||
// topocentric ra and dec. i.e. the position as seen from the
|
||||
// surface of the earth, instead of the center of the earth
|
||||
|
||||
// First calculate the moon's parrallax, that is, the apparent size of the
|
||||
// (equatorial) radius of the earth, as seen from the moon
|
||||
mpar = asin ( 1 / r);
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "r = " << r << " mpar = " << mpar );
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "lat = " << f->get_Latitude() );
|
||||
|
||||
gclat = f->get_Latitude() - 0.003358 *
|
||||
sin (2 * DEG_TO_RAD * f->get_Latitude() );
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "gclat = " << gclat );
|
||||
|
||||
rho = 0.99883 + 0.00167 * cos(2 * DEG_TO_RAD * f->get_Latitude());
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "rho = " << rho );
|
||||
|
||||
if (geoRa < 0)
|
||||
geoRa += (2*FG_PI);
|
||||
|
||||
HA = t->getLst() - (3.8197186 * geoRa);
|
||||
/* FG_LOG( FG_GENERAL, FG_INFO, "t->getLst() = " << t->getLst()
|
||||
<< " HA = " << HA ); */
|
||||
|
||||
g = atan (tan(gclat) / cos ((HA / 3.8197186)));
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "g = " << g );
|
||||
|
||||
rightAscension = geoRa - mpar * rho * cos(gclat) * sin(HA) / cos (geoDec);
|
||||
declination = geoDec - mpar * rho * sin (gclat) * sin (g - geoDec) / sin(g);
|
||||
|
||||
/* FG_LOG( FG_GENERAL, FG_INFO,
|
||||
"Ra = (" << (RAD_TO_DEG *rightAscension)
|
||||
<< "), Dec= (" << (RAD_TO_DEG *declination) << ")" ); */
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* void Moon::newImage()
|
||||
*
|
||||
* This function regenerates a new visual image of the moon, which is added to
|
||||
* solarSystem display list.
|
||||
*
|
||||
* Arguments: Right Ascension and declination
|
||||
*
|
||||
* return value: none
|
||||
**************************************************************************/
|
||||
void Moon::newImage()
|
||||
{
|
||||
fgLIGHT *l = &cur_light_params;
|
||||
float moon_angle = l->moon_angle;
|
||||
|
||||
/*double x_2, x_4, x_8, x_10;
|
||||
GLfloat ambient;
|
||||
GLfloat amb[4];*/
|
||||
int moonSize = 550;
|
||||
|
||||
GLfloat moonColor[4] = {0.85, 0.75, 0.35, 1.0};
|
||||
GLfloat black[4] = {0.0, 0.0, 0.0, 1.0};
|
||||
GLfloat white[4] = {1.0, 1.0, 1.0, 0.0};
|
||||
|
||||
if( moon_angle*RAD_TO_DEG < 100 )
|
||||
{
|
||||
FG_LOG( FG_ASTRO, FG_INFO, "Generating Moon Image" );
|
||||
|
||||
xglPushMatrix();
|
||||
{
|
||||
xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
|
||||
xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
|
||||
|
||||
FG_LOG( FG_GENERAL, FG_INFO,
|
||||
"Ra = (" << (RAD_TO_DEG *rightAscension)
|
||||
<< "), Dec= (" << (RAD_TO_DEG *declination) << ")" );
|
||||
xglTranslatef(0.0, 60000.0, 0.0);
|
||||
glEnable(GL_BLEND); // BLEND ENABLED
|
||||
|
||||
// Draw the halo...
|
||||
if (current_options.get_textures())
|
||||
{
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glBindTexture(GL_TEXTURE_2D, moon_halotexid);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0f, 0.0f); glVertex3f(-5000, 0.0, -5000);
|
||||
glTexCoord2f(1.0f, 0.0f); glVertex3f( 5000, 0.0, -5000);
|
||||
glTexCoord2f(1.0f, 1.0f); glVertex3f( 5000, 0.0, 5000);
|
||||
glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
xglEnable(GL_LIGHTING); // LIGHTING ENABLED
|
||||
xglEnable( GL_LIGHT0 );
|
||||
// set lighting parameters
|
||||
xglLightfv(GL_LIGHT0, GL_AMBIENT, white );
|
||||
xglLightfv(GL_LIGHT0, GL_DIFFUSE, white );
|
||||
// Enable( GL_CULL_FACE );
|
||||
xglMaterialfv(GL_FRONT, GL_AMBIENT, black);
|
||||
xglMaterialfv(GL_FRONT, GL_DIFFUSE, moonColor);
|
||||
//glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
|
||||
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
// Draw the moon-proper
|
||||
|
||||
if (current_options.get_textures())
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, moon_texid);
|
||||
gluQuadricTexture(moonObject, GL_TRUE );
|
||||
}
|
||||
gluSphere(moonObject, moonSize, 12, 12 );
|
||||
glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
|
||||
glDisable(GL_BLEND); // BLEND DISABLED
|
||||
}
|
||||
xglPopMatrix();
|
||||
glDisable(GL_LIGHTING); // Lighting Disabled.
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/**************************************************************************
|
||||
* moon.hxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
#ifndef _MOON_HXX_
|
||||
#define _MOON_HXX_
|
||||
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Main/views.hxx>
|
||||
#include <Time/fg_time.hxx>
|
||||
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
|
||||
class Moon : public CelestialBody
|
||||
{
|
||||
private:
|
||||
void TexInit(); // This should move to the constructor eventually.
|
||||
|
||||
GLUquadricObj *moonObject;
|
||||
GLuint Sphere;
|
||||
GLuint moon_texid;
|
||||
GLuint moon_halotexid;
|
||||
GLubyte *moon_texbuf;
|
||||
GLubyte *moon_halotexbuf;
|
||||
|
||||
void setHalo();
|
||||
public:
|
||||
Moon ( FGTime *t);
|
||||
~Moon();
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
void newImage();
|
||||
};
|
||||
|
||||
|
||||
#endif // _MOON_HXX_
|
||||
200
simgear/ephemeris/moonpos.cxx
Normal file
200
simgear/ephemeris/moonpos.cxx
Normal file
@@ -0,0 +1,200 @@
|
||||
/**************************************************************************
|
||||
* moonpos.cxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# define exception c_exception
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
// #include <FDM/flight.hxx>
|
||||
|
||||
#include "moonpos.hxx"
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* MoonPos::MoonPos(double mjd)
|
||||
* Public constructor for class MoonPos. Initializes the orbital elements and
|
||||
* sets up the moon texture.
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for MoonPos are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
MoonPos::MoonPos(double mjd) :
|
||||
CelestialBody(125.1228, -0.0529538083,
|
||||
5.1454, 0.00000,
|
||||
318.0634, 0.1643573223,
|
||||
60.266600, 0.000000,
|
||||
0.054900, 0.000000,
|
||||
115.3654, 13.0649929509, mjd)
|
||||
{
|
||||
}
|
||||
|
||||
MoonPos::MoonPos() :
|
||||
CelestialBody(125.1228, -0.0529538083,
|
||||
5.1454, 0.00000,
|
||||
318.0634, 0.1643573223,
|
||||
60.266600, 0.000000,
|
||||
0.054900, 0.000000,
|
||||
115.3654, 13.0649929509)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
MoonPos::~MoonPos()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* void MoonPos::updatePosition(double mjd, Star *ourSun)
|
||||
* this member function calculates the actual topocentric position (i.e.)
|
||||
* the position of the moon as seen from the current position on the surface
|
||||
* of the moon.
|
||||
****************************************************************************/
|
||||
void MoonPos::updatePosition(double mjd, double lst, double lat, Star *ourSun)
|
||||
{
|
||||
double
|
||||
eccAnom, ecl, actTime,
|
||||
xv, yv, v, r, xh, yh, zh, xg, yg, zg, xe, ye, ze,
|
||||
Ls, Lm, D, F, mpar, gclat, rho, HA, g,
|
||||
geoRa, geoDec;
|
||||
|
||||
updateOrbElements(mjd);
|
||||
actTime = sgCalcActTime(mjd);
|
||||
|
||||
// calculate the angle between ecliptic and equatorial coordinate system
|
||||
// in Radians
|
||||
ecl = ((SGD_DEGREES_TO_RADIANS * 23.4393) - (SGD_DEGREES_TO_RADIANS * 3.563E-7) * actTime);
|
||||
eccAnom = sgCalcEccAnom(M, e); // Calculate the eccentric anomaly
|
||||
xv = a * (cos(eccAnom) - e);
|
||||
yv = a * (sqrt(1.0 - e*e) * sin(eccAnom));
|
||||
v = atan2(yv, xv); // the moon's true anomaly
|
||||
r = sqrt (xv*xv + yv*yv); // and its distance
|
||||
|
||||
// estimate the geocentric rectangular coordinates here
|
||||
xh = r * (cos(N) * cos (v+w) - sin (N) * sin(v+w) * cos(i));
|
||||
yh = r * (sin(N) * cos (v+w) + cos (N) * sin(v+w) * cos(i));
|
||||
zh = r * (sin(v+w) * sin(i));
|
||||
|
||||
// calculate the ecliptic latitude and longitude here
|
||||
lonEcl = atan2 (yh, xh);
|
||||
latEcl = atan2(zh, sqrt(xh*xh + yh*yh));
|
||||
|
||||
/* Calculate a number of perturbatioin, i.e. disturbances caused by the
|
||||
* gravitational infuence of the sun and the other major planets.
|
||||
* The largest of these even have a name */
|
||||
Ls = ourSun->getM() + ourSun->getw();
|
||||
Lm = M + w + N;
|
||||
D = Lm - Ls;
|
||||
F = Lm - N;
|
||||
|
||||
lonEcl += SGD_DEGREES_TO_RADIANS * (-1.274 * sin (M - 2*D)
|
||||
+0.658 * sin (2*D)
|
||||
-0.186 * sin(ourSun->getM())
|
||||
-0.059 * sin(2*M - 2*D)
|
||||
-0.057 * sin(M - 2*D + ourSun->getM())
|
||||
+0.053 * sin(M + 2*D)
|
||||
+0.046 * sin(2*D - ourSun->getM())
|
||||
+0.041 * sin(M - ourSun->getM())
|
||||
-0.035 * sin(D)
|
||||
-0.031 * sin(M + ourSun->getM())
|
||||
-0.015 * sin(2*F - 2*D)
|
||||
+0.011 * sin(M - 4*D)
|
||||
);
|
||||
latEcl += SGD_DEGREES_TO_RADIANS * (-0.173 * sin(F-2*D)
|
||||
-0.055 * sin(M - F - 2*D)
|
||||
-0.046 * sin(M + F - 2*D)
|
||||
+0.033 * sin(F + 2*D)
|
||||
+0.017 * sin(2*M + F)
|
||||
);
|
||||
r += (-0.58 * cos(M - 2*D)
|
||||
-0.46 * cos(2*D)
|
||||
);
|
||||
// SG_LOG(SG_GENERAL, SG_INFO, "Running moon update");
|
||||
xg = r * cos(lonEcl) * cos(latEcl);
|
||||
yg = r * sin(lonEcl) * cos(latEcl);
|
||||
zg = r * sin(latEcl);
|
||||
|
||||
xe = xg;
|
||||
ye = yg * cos(ecl) -zg * sin(ecl);
|
||||
ze = yg * sin(ecl) +zg * cos(ecl);
|
||||
|
||||
geoRa = atan2(ye, xe);
|
||||
geoDec = atan2(ze, sqrt(xe*xe + ye*ye));
|
||||
|
||||
/* SG_LOG( SG_GENERAL, SG_INFO,
|
||||
"(geocentric) geoRa = (" << (SGD_RADIANS_TO_DEGREES * geoRa)
|
||||
<< "), geoDec= (" << (SGD_RADIANS_TO_DEGREES * geoDec) << ")" ); */
|
||||
|
||||
|
||||
// Given the moon's geocentric ra and dec, calculate its
|
||||
// topocentric ra and dec. i.e. the position as seen from the
|
||||
// surface of the earth, instead of the center of the earth
|
||||
|
||||
// First calculate the moon's parrallax, that is, the apparent size of the
|
||||
// (equatorial) radius of the earth, as seen from the moon
|
||||
mpar = asin ( 1 / r);
|
||||
// SG_LOG( SG_GENERAL, SG_INFO, "r = " << r << " mpar = " << mpar );
|
||||
// SG_LOG( SG_GENERAL, SG_INFO, "lat = " << f->get_Latitude() );
|
||||
|
||||
gclat = lat - 0.003358 *
|
||||
sin (2 * SGD_DEGREES_TO_RADIANS * lat );
|
||||
// SG_LOG( SG_GENERAL, SG_INFO, "gclat = " << gclat );
|
||||
|
||||
rho = 0.99883 + 0.00167 * cos(2 * SGD_DEGREES_TO_RADIANS * lat);
|
||||
// SG_LOG( SG_GENERAL, SG_INFO, "rho = " << rho );
|
||||
|
||||
if (geoRa < 0)
|
||||
geoRa += (2*SGD_PI);
|
||||
|
||||
HA = lst - (3.8197186 * geoRa);
|
||||
/* SG_LOG( SG_GENERAL, SG_INFO, "t->getLst() = " << t->getLst()
|
||||
<< " HA = " << HA ); */
|
||||
|
||||
g = atan (tan(gclat) / cos ((HA / 3.8197186)));
|
||||
// SG_LOG( SG_GENERAL, SG_INFO, "g = " << g );
|
||||
|
||||
rightAscension = geoRa - mpar * rho * cos(gclat) * sin(HA) / cos (geoDec);
|
||||
if (fabs(lat) > 0) {
|
||||
declination
|
||||
= geoDec - mpar * rho * sin (gclat) * sin (g - geoDec) / sin(g);
|
||||
} else {
|
||||
declination = geoDec;
|
||||
// cerr << "Geocentric vs. Topocentric position" << endl;
|
||||
// cerr << "RA (difference) : "
|
||||
// << SGD_RADIANS_TO_DEGREES * (geoRa - rightAscension) << endl;
|
||||
// cerr << "Dec (difference) : "
|
||||
// << SGD_RADIANS_TO_DEGREES * (geoDec - declination) << endl;
|
||||
}
|
||||
|
||||
/* SG_LOG( SG_GENERAL, SG_INFO,
|
||||
"Ra = (" << (SGD_RADIANS_TO_DEGREES *rightAscension)
|
||||
<< "), Dec= (" << (SGD_RADIANS_TO_DEGREES *declination) << ")" ); */
|
||||
}
|
||||
61
simgear/ephemeris/moonpos.hxx
Normal file
61
simgear/ephemeris/moonpos.hxx
Normal file
@@ -0,0 +1,61 @@
|
||||
/**************************************************************************
|
||||
* moonpos.hxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
#ifndef _MOONPOS_HXX_
|
||||
#define _MOONPOS_HXX_
|
||||
|
||||
|
||||
#include <simgear/constants.h>
|
||||
|
||||
#include <simgear/ephemeris/celestialBody.hxx>
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
|
||||
|
||||
class MoonPos : public CelestialBody
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// void TexInit(); // This should move to the constructor eventually.
|
||||
|
||||
// GLUquadricObj *moonObject;
|
||||
// GLuint Sphere;
|
||||
// GLuint moon_texid;
|
||||
// GLuint moon_halotexid;
|
||||
// GLubyte *moon_texbuf;
|
||||
// GLubyte *moon_halotexbuf;
|
||||
|
||||
// void setHalo();
|
||||
|
||||
public:
|
||||
|
||||
MoonPos(double mjd);
|
||||
MoonPos();
|
||||
~MoonPos();
|
||||
void updatePosition(double mjd, double lst, double lat, Star *ourSun);
|
||||
// void newImage();
|
||||
};
|
||||
|
||||
|
||||
#endif // _MOONPOS_HXX_
|
||||
@@ -5,19 +5,20 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
@@ -30,30 +31,39 @@
|
||||
#include "neptune.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Neptune::Neptune(FGTime *t)
|
||||
* Neptune::Neptune(double mjd)
|
||||
* Public constructor for class Neptune
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Neptune are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Neptune::Neptune(FGTime *t) :
|
||||
Neptune::Neptune(double mjd) :
|
||||
CelestialBody(131.7806, 3.0173000E-5,
|
||||
1.7700, -2.550E-7,
|
||||
272.8461, -6.027000E-6,
|
||||
30.058260, 3.313E-8,
|
||||
0.008606, 2.150E-9,
|
||||
260.2471, 0.00599514700, t)
|
||||
260.2471, 0.00599514700, mjd)
|
||||
{
|
||||
}
|
||||
Neptune::Neptune() :
|
||||
CelestialBody(131.7806, 3.0173000E-5,
|
||||
1.7700, -2.550E-7,
|
||||
272.8461, -6.027000E-6,
|
||||
30.058260, 3.313E-8,
|
||||
0.008606, 2.150E-9,
|
||||
260.2471, 0.00599514700)
|
||||
{
|
||||
}
|
||||
/*************************************************************************
|
||||
* void Neptune::updatePosition(FGTime *t, Star *ourSun)
|
||||
* void Neptune::updatePosition(double mjd, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Neptune, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Neptune specific equation
|
||||
*************************************************************************/
|
||||
void Neptune::updatePosition(FGTime *t, Star *ourSun)
|
||||
void Neptune::updatePosition(double mjd, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
CelestialBody::updatePosition(mjd, ourSun);
|
||||
magnitude = -6.90 + 5*log10 (r*R) + 0.001 *FV;
|
||||
}
|
||||
|
||||
@@ -5,34 +5,35 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
#ifndef _NEPTUNE_HXX_
|
||||
#define _NEPTUNE_HXX_
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
#include <simgear/ephemeris/celestialBody.hxx>
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
|
||||
class Neptune : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Neptune ( FGTime *t);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
Neptune (double mjd);
|
||||
Neptune ();
|
||||
void updatePosition(double mjd, Star *ourSun);
|
||||
};
|
||||
|
||||
#endif // _NEPTUNE_HXX_
|
||||
|
||||
@@ -5,32 +5,33 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
#ifndef _PLUTO_HXX_
|
||||
#define _PLUTO_HXX_
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "celestialBody.hxx"
|
||||
|
||||
class Pluto : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Pluto ( FGTime t);
|
||||
Pluto (double mjd);
|
||||
Pluto ();
|
||||
};
|
||||
|
||||
#endif // _PLUTO_HXX_
|
||||
|
||||
@@ -5,19 +5,20 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
@@ -30,34 +31,43 @@
|
||||
#include "saturn.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Saturn::Saturn(FGTime *t)
|
||||
* Saturn::Saturn(double mjd)
|
||||
* Public constructor for class Saturn
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Saturn are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Saturn::Saturn(FGTime *t) :
|
||||
Saturn::Saturn(double mjd) :
|
||||
CelestialBody(113.6634, 2.3898000E-5,
|
||||
2.4886, -1.081E-7,
|
||||
339.3939, 2.9766100E-5,
|
||||
9.5547500, 0.000000,
|
||||
0.055546, -9.499E-9,
|
||||
316.9670, 0.03344422820, t)
|
||||
316.9670, 0.03344422820, mjd)
|
||||
{
|
||||
}
|
||||
Saturn::Saturn() :
|
||||
CelestialBody(113.6634, 2.3898000E-5,
|
||||
2.4886, -1.081E-7,
|
||||
339.3939, 2.9766100E-5,
|
||||
9.5547500, 0.000000,
|
||||
0.055546, -9.499E-9,
|
||||
316.9670, 0.03344422820)
|
||||
{
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* void Saturn::updatePosition(FGTime *t, Star *ourSun)
|
||||
* void Saturn::updatePosition(double mjd, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Saturn, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Saturn specific equation
|
||||
*************************************************************************/
|
||||
void Saturn::updatePosition(FGTime *t, Star *ourSun)
|
||||
void Saturn::updatePosition(double mjd, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
CelestialBody::updatePosition(mjd, ourSun);
|
||||
|
||||
double actTime = fgCalcActTime(t);
|
||||
double actTime = sgCalcActTime(mjd);
|
||||
double ir = 0.4897394;
|
||||
double Nr = 2.9585076 + 6.6672E-7*actTime;
|
||||
double B = asin (sin(declination) * cos(ir) -
|
||||
|
||||
@@ -5,34 +5,35 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
#ifndef _SATURN_HXX_
|
||||
#define _SATURN_HXX_
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
#include <simgear/ephemeris/celestialBody.hxx>
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
|
||||
class Saturn : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Saturn ( FGTime *t);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
Saturn (double mjd);
|
||||
Saturn ();
|
||||
void updatePosition(double mjd, Star *ourSun);
|
||||
};
|
||||
|
||||
#endif // _SATURN_HXX_
|
||||
|
||||
@@ -1,367 +0,0 @@
|
||||
// sky.cxx -- model sky with an upside down "bowl"
|
||||
//
|
||||
// Written by Curtis Olson, started December 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include <XGL/xgl.h>
|
||||
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
#include <Debug/logstream.hxx>
|
||||
#include <FDM/flight.hxx>
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Main/views.hxx>
|
||||
#include <Math/fg_random.h>
|
||||
#include <Time/event.hxx>
|
||||
#include <Time/fg_time.hxx>
|
||||
|
||||
#include "sky.hxx"
|
||||
|
||||
|
||||
#ifdef __MWERKS__
|
||||
# pragma global_optimizer off
|
||||
#endif
|
||||
|
||||
|
||||
// in meters of course
|
||||
#define CENTER_ELEV 25000.0
|
||||
|
||||
#define INNER_RADIUS 50000.0
|
||||
#define INNER_ELEV 20000.0
|
||||
|
||||
#define MIDDLE_RADIUS 70000.0
|
||||
#define MIDDLE_ELEV 8000.0
|
||||
|
||||
#define OUTER_RADIUS 80000.0
|
||||
#define OUTER_ELEV 0.0
|
||||
|
||||
#define BOTTOM_RADIUS 50000.0
|
||||
#define BOTTOM_ELEV -2000.0
|
||||
|
||||
|
||||
static float inner_vertex[12][3];
|
||||
static float middle_vertex[12][3];
|
||||
static float outer_vertex[12][3];
|
||||
static float bottom_vertex[12][3];
|
||||
|
||||
static float inner_color[12][4];
|
||||
static float middle_color[12][4];
|
||||
static float outer_color[12][4];
|
||||
|
||||
|
||||
// Calculate the sky structure vertices
|
||||
void fgSkyVerticesInit( void ) {
|
||||
float theta;
|
||||
int i;
|
||||
|
||||
FG_LOG(FG_ASTRO, FG_INFO, " Generating the sky dome vertices.");
|
||||
|
||||
for ( i = 0; i < 12; i++ ) {
|
||||
theta = (i * 30.0) * DEG_TO_RAD;
|
||||
|
||||
inner_vertex[i][0] = cos(theta) * INNER_RADIUS;
|
||||
inner_vertex[i][1] = sin(theta) * INNER_RADIUS;
|
||||
inner_vertex[i][2] = INNER_ELEV;
|
||||
|
||||
// printf(" %.2f %.2f\n", cos(theta) * INNER_RADIUS,
|
||||
// sin(theta) * INNER_RADIUS);
|
||||
|
||||
middle_vertex[i][0] = cos((double)theta) * MIDDLE_RADIUS;
|
||||
middle_vertex[i][1] = sin((double)theta) * MIDDLE_RADIUS;
|
||||
middle_vertex[i][2] = MIDDLE_ELEV;
|
||||
|
||||
outer_vertex[i][0] = cos((double)theta) * OUTER_RADIUS;
|
||||
outer_vertex[i][1] = sin((double)theta) * OUTER_RADIUS;
|
||||
outer_vertex[i][2] = OUTER_ELEV;
|
||||
|
||||
bottom_vertex[i][0] = cos((double)theta) * BOTTOM_RADIUS;
|
||||
bottom_vertex[i][1] = sin((double)theta) * BOTTOM_RADIUS;
|
||||
bottom_vertex[i][2] = BOTTOM_ELEV;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// (Re)calculate the sky colors at each vertex
|
||||
void fgSkyColorsInit( void ) {
|
||||
fgLIGHT *l;
|
||||
double sun_angle, diff;
|
||||
double outer_param[3], outer_amt[3], outer_diff[3];
|
||||
double middle_param[3], middle_amt[3], middle_diff[3];
|
||||
int i, j;
|
||||
|
||||
l = &cur_light_params;
|
||||
|
||||
FG_LOG( FG_ASTRO, FG_INFO,
|
||||
" Generating the sky colors for each vertex." );
|
||||
|
||||
// setup for the possibility of sunset effects
|
||||
sun_angle = l->sun_angle * RAD_TO_DEG;
|
||||
// fgPrintf( FG_ASTRO, FG_INFO,
|
||||
// " Sun angle in degrees = %.2f\n", sun_angle);
|
||||
|
||||
if ( (sun_angle > 80.0) && (sun_angle < 100.0) ) {
|
||||
// 0.0 - 0.4
|
||||
outer_param[0] = (10.0 - fabs(90.0 - sun_angle)) / 20.0;
|
||||
outer_param[1] = (10.0 - fabs(90.0 - sun_angle)) / 40.0;
|
||||
outer_param[2] = -(10.0 - fabs(90.0 - sun_angle)) / 30.0;
|
||||
// outer_param[2] = 0.0;
|
||||
|
||||
middle_param[0] = (10.0 - fabs(90.0 - sun_angle)) / 40.0;
|
||||
middle_param[1] = (10.0 - fabs(90.0 - sun_angle)) / 80.0;
|
||||
middle_param[2] = 0.0;
|
||||
|
||||
outer_diff[0] = outer_param[0] / 6.0;
|
||||
outer_diff[1] = outer_param[1] / 6.0;
|
||||
outer_diff[2] = outer_param[2] / 6.0;
|
||||
|
||||
middle_diff[0] = middle_param[0] / 6.0;
|
||||
middle_diff[1] = middle_param[1] / 6.0;
|
||||
middle_diff[2] = middle_param[2] / 6.0;
|
||||
} else {
|
||||
outer_param[0] = outer_param[1] = outer_param[2] = 0.0;
|
||||
middle_param[0] = middle_param[1] = middle_param[2] = 0.0;
|
||||
|
||||
outer_diff[0] = outer_diff[1] = outer_diff[2] = 0.0;
|
||||
middle_diff[0] = middle_diff[1] = middle_diff[2] = 0.0;
|
||||
}
|
||||
// printf(" outer_red_param = %.2f outer_red_diff = %.2f\n",
|
||||
// outer_red_param, outer_red_diff);
|
||||
|
||||
// calculate transition colors between sky and fog
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
outer_amt[j] = outer_param[j];
|
||||
middle_amt[j] = middle_param[j];
|
||||
}
|
||||
|
||||
for ( i = 0; i < 6; i++ ) {
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
diff = l->sky_color[j] - l->fog_color[j];
|
||||
|
||||
// printf("sky = %.2f fog = %.2f diff = %.2f\n",
|
||||
// l->sky_color[j], l->fog_color[j], diff);
|
||||
|
||||
inner_color[i][j] = l->sky_color[j] - diff * 0.3;
|
||||
middle_color[i][j] = l->sky_color[j] - diff * 0.9 + middle_amt[j];
|
||||
outer_color[i][j] = l->fog_color[j] + outer_amt[j];
|
||||
|
||||
if ( inner_color[i][j] > 1.00 ) { inner_color[i][j] = 1.00; }
|
||||
if ( inner_color[i][j] < 0.10 ) { inner_color[i][j] = 0.10; }
|
||||
if ( middle_color[i][j] > 1.00 ) { middle_color[i][j] = 1.00; }
|
||||
if ( middle_color[i][j] < 0.10 ) { middle_color[i][j] = 0.10; }
|
||||
if ( outer_color[i][j] > 1.00 ) { outer_color[i][j] = 1.00; }
|
||||
if ( outer_color[i][j] < 0.10 ) { outer_color[i][j] = 0.10; }
|
||||
}
|
||||
inner_color[i][3] = middle_color[i][3] = outer_color[i][3] =
|
||||
l->sky_color[3];
|
||||
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
outer_amt[j] -= outer_diff[j];
|
||||
middle_amt[j] -= middle_diff[j];
|
||||
}
|
||||
|
||||
/*
|
||||
printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i, inner_color[i][0],
|
||||
inner_color[i][1], inner_color[i][2], inner_color[i][3]);
|
||||
printf("middle_color[%d] = %.2f %.2f %.2f %.2f\n", i,
|
||||
middle_color[i][0], middle_color[i][1], middle_color[i][2],
|
||||
middle_color[i][3]);
|
||||
printf("outer_color[%d] = %.2f %.2f %.2f %.2f\n", i,
|
||||
outer_color[i][0], outer_color[i][1], outer_color[i][2],
|
||||
outer_color[i][3]);
|
||||
*/
|
||||
}
|
||||
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
outer_amt[j] = 0.0;
|
||||
middle_amt[j] = 0.0;
|
||||
}
|
||||
|
||||
for ( i = 6; i < 12; i++ ) {
|
||||
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
diff = l->sky_color[j] - l->fog_color[j];
|
||||
|
||||
// printf("sky = %.2f fog = %.2f diff = %.2f\n",
|
||||
// l->sky_color[j], l->fog_color[j], diff);
|
||||
|
||||
inner_color[i][j] = l->sky_color[j] - diff * 0.3;
|
||||
middle_color[i][j] = l->sky_color[j] - diff * 0.9 + middle_amt[j];
|
||||
outer_color[i][j] = l->fog_color[j] + outer_amt[j];
|
||||
|
||||
if ( inner_color[i][j] > 1.00 ) { inner_color[i][j] = 1.00; }
|
||||
if ( inner_color[i][j] < 0.10 ) { inner_color[i][j] = 0.10; }
|
||||
if ( middle_color[i][j] > 1.00 ) { middle_color[i][j] = 1.00; }
|
||||
if ( middle_color[i][j] < 0.10 ) { middle_color[i][j] = 0.10; }
|
||||
if ( outer_color[i][j] > 1.00 ) { outer_color[i][j] = 1.00; }
|
||||
if ( outer_color[i][j] < 0.15 ) { outer_color[i][j] = 0.15; }
|
||||
}
|
||||
inner_color[i][3] = middle_color[i][3] = outer_color[i][3] =
|
||||
l->sky_color[3];
|
||||
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
outer_amt[j] += outer_diff[j];
|
||||
middle_amt[j] += middle_diff[j];
|
||||
}
|
||||
|
||||
/*
|
||||
printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i, inner_color[i][0],
|
||||
inner_color[i][1], inner_color[i][2], inner_color[i][3]);
|
||||
printf("middle_color[%d] = %.2f %.2f %.2f %.2f\n", i,
|
||||
middle_color[i][0], middle_color[i][1], middle_color[i][2],
|
||||
middle_color[i][3]);
|
||||
printf("outer_color[%d] = %.2f %.2f %.2f %.2f\n", i,
|
||||
outer_color[i][0], outer_color[i][1], outer_color[i][2],
|
||||
outer_color[i][3]);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Initialize the sky structure and colors
|
||||
void fgSkyInit( void ) {
|
||||
FG_LOG( FG_ASTRO, FG_INFO, "Initializing the sky" );
|
||||
|
||||
fgSkyVerticesInit();
|
||||
|
||||
// regester fgSkyColorsInit() as an event to be run periodically
|
||||
global_events.Register( "fgSkyColorsInit()", fgSkyColorsInit,
|
||||
fgEVENT::FG_EVENT_READY, 30000);
|
||||
}
|
||||
|
||||
|
||||
// Draw the Sky
|
||||
void fgSkyRender( void ) {
|
||||
FGInterface *f;
|
||||
fgLIGHT *l;
|
||||
float inner_color[4];
|
||||
float middle_color[4];
|
||||
float outer_color[4];
|
||||
double diff;
|
||||
int i;
|
||||
|
||||
f = current_aircraft.fdm_state;
|
||||
l = &cur_light_params;
|
||||
|
||||
// printf("Rendering the sky.\n");
|
||||
|
||||
// calculate the proper colors
|
||||
for ( i = 0; i < 3; i++ ) {
|
||||
diff = l->sky_color[i] - l->adj_fog_color[i];
|
||||
|
||||
// printf("sky = %.2f fog = %.2f diff = %.2f\n",
|
||||
// l->sky_color[j], l->adj_fog_color[j], diff);
|
||||
|
||||
inner_color[i] = l->sky_color[i] - diff * 0.3;
|
||||
middle_color[i] = l->sky_color[i] - diff * 0.9;
|
||||
outer_color[i] = l->adj_fog_color[i];
|
||||
}
|
||||
inner_color[3] = middle_color[3] = outer_color[3] = l->adj_fog_color[3];
|
||||
|
||||
xglPushMatrix();
|
||||
|
||||
// Translate to view position
|
||||
Point3D zero_elev = current_view.get_cur_zero_elev();
|
||||
xglTranslatef( zero_elev.x(), zero_elev.y(), zero_elev.z() );
|
||||
// printf(" Translated to %.2f %.2f %.2f\n",
|
||||
// zero_elev.x, zero_elev.y, zero_elev.z );
|
||||
|
||||
// Rotate to proper orientation
|
||||
// printf(" lon = %.2f lat = %.2f\n", FG_Longitude * RAD_TO_DEG,
|
||||
// FG_Latitude * RAD_TO_DEG);
|
||||
xglRotatef( f->get_Longitude() * RAD_TO_DEG, 0.0, 0.0, 1.0 );
|
||||
xglRotatef( 90.0 - f->get_Latitude() * RAD_TO_DEG, 0.0, 1.0, 0.0 );
|
||||
xglRotatef( l->sun_rotation * RAD_TO_DEG, 0.0, 0.0, 1.0 );
|
||||
|
||||
// Draw inner/center section of sky*/
|
||||
xglBegin( GL_TRIANGLE_FAN );
|
||||
xglColor4fv(l->sky_color);
|
||||
xglVertex3f(0.0, 0.0, CENTER_ELEV);
|
||||
for ( i = 11; i >= 0; i-- ) {
|
||||
xglColor4fv( inner_color );
|
||||
xglVertex3fv( inner_vertex[i] );
|
||||
}
|
||||
xglColor4fv( inner_color );
|
||||
xglVertex3fv( inner_vertex[11] );
|
||||
xglEnd();
|
||||
|
||||
// Draw the middle ring
|
||||
xglBegin( GL_TRIANGLE_STRIP );
|
||||
for ( i = 0; i < 12; i++ ) {
|
||||
xglColor4fv( middle_color );
|
||||
// printf("middle_color[%d] = %.2f %.2f %.2f %.2f\n", i,
|
||||
// middle_color[i][0], middle_color[i][1], middle_color[i][2],
|
||||
// middle_color[i][3]);
|
||||
// xglColor4f(1.0, 0.0, 0.0, 1.0);
|
||||
xglVertex3fv( middle_vertex[i] );
|
||||
xglColor4fv( inner_color );
|
||||
// printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i,
|
||||
// inner_color[i][0], inner_color[i][1], inner_color[i][2],
|
||||
// inner_color[i][3]);
|
||||
// xglColor4f(0.0, 0.0, 1.0, 1.0);
|
||||
xglVertex3fv( inner_vertex[i] );
|
||||
}
|
||||
xglColor4fv( middle_color );
|
||||
// xglColor4f(1.0, 0.0, 0.0, 1.0);
|
||||
xglVertex3fv( middle_vertex[0] );
|
||||
xglColor4fv( inner_color );
|
||||
// xglColor4f(0.0, 0.0, 1.0, 1.0);
|
||||
xglVertex3fv( inner_vertex[0] );
|
||||
xglEnd();
|
||||
|
||||
// Draw the outer ring
|
||||
xglBegin( GL_TRIANGLE_STRIP );
|
||||
for ( i = 0; i < 12; i++ ) {
|
||||
xglColor4fv( outer_color );
|
||||
xglVertex3fv( outer_vertex[i] );
|
||||
xglColor4fv( middle_color );
|
||||
xglVertex3fv( middle_vertex[i] );
|
||||
}
|
||||
xglColor4fv( outer_color );
|
||||
xglVertex3fv( outer_vertex[0] );
|
||||
xglColor4fv( middle_color );
|
||||
xglVertex3fv( middle_vertex[0] );
|
||||
xglEnd();
|
||||
|
||||
// Draw the bottom skirt
|
||||
xglBegin( GL_TRIANGLE_STRIP );
|
||||
xglColor4fv( outer_color );
|
||||
for ( i = 0; i < 12; i++ ) {
|
||||
xglVertex3fv( bottom_vertex[i] );
|
||||
xglVertex3fv( outer_vertex[i] );
|
||||
}
|
||||
xglVertex3fv( bottom_vertex[0] );
|
||||
xglVertex3fv( outer_vertex[0] );
|
||||
xglEnd();
|
||||
|
||||
xglPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
// sky.hxx -- model sky with an upside down "bowl"
|
||||
//
|
||||
// Written by Curtis Olson, started December 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
|
||||
#ifndef _SKY_HXX
|
||||
#define _SKY_HXX
|
||||
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
|
||||
#include <ssg.h> // plib include
|
||||
|
||||
|
||||
class fgSky : ssgLeaf
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
// (Re)generate the display list
|
||||
void fgSkyInit( void );
|
||||
|
||||
// (Re)calculate the sky colors at each vertex
|
||||
void fgSkyColorsInit( void );
|
||||
|
||||
// Draw the Sky
|
||||
void fgSkyRender( void );
|
||||
|
||||
|
||||
#endif // _SKY_HXX
|
||||
|
||||
|
||||
@@ -1,215 +0,0 @@
|
||||
/**************************************************************************
|
||||
* solarsystem.cxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# define exception c_exception
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include <XGL/xgl.h>
|
||||
#include <Debug/logstream.hxx>
|
||||
#include <Time/sunpos.hxx>
|
||||
#include <Time/moonpos.hxx>
|
||||
#include "solarsystem.hxx"
|
||||
|
||||
/***************************************************************************
|
||||
* default constructor for class SolarSystem:
|
||||
* or course there can only be one way to create an entire solar system -:) )
|
||||
* the FGTime argument is needed to properly initialize the the current orbital
|
||||
* elements
|
||||
*************************************************************************/
|
||||
SolarSystem::SolarSystem(FGTime *t)
|
||||
{
|
||||
if (theSolarSystem)
|
||||
{
|
||||
FG_LOG( FG_GENERAL, FG_ALERT, "Error: only one solarsystem allowed" );
|
||||
exit(-1);
|
||||
}
|
||||
theSolarSystem = this;
|
||||
ourSun = new Star(t);
|
||||
earthsMoon = new Moon(t);
|
||||
mercury = new Mercury(t);
|
||||
venus = new Venus(t);
|
||||
mars = new Mars(t);
|
||||
jupiter = new Jupiter(t);
|
||||
saturn = new Saturn(t);
|
||||
uranus = new Uranus(t);
|
||||
neptune = new Neptune(t);
|
||||
|
||||
displayList = 0;
|
||||
};
|
||||
|
||||
/**************************************************************************
|
||||
* the destructor for class SolarSystem;
|
||||
**************************************************************************/
|
||||
SolarSystem::~SolarSystem()
|
||||
{
|
||||
delete ourSun;
|
||||
delete earthsMoon;
|
||||
delete mercury;
|
||||
delete venus;
|
||||
delete mars;
|
||||
delete jupiter;
|
||||
delete saturn;
|
||||
delete uranus;
|
||||
delete neptune;
|
||||
}
|
||||
/****************************************************************************
|
||||
* void SolarSystem::rebuild()
|
||||
*
|
||||
* this member function updates the positions for the sun, moon, and planets,
|
||||
* and then rebuilds the display list.
|
||||
*
|
||||
* arguments: none
|
||||
* return value: none
|
||||
***************************************************************************/
|
||||
void SolarSystem::rebuild()
|
||||
{
|
||||
//fgLIGHT *l = &cur_light_params;
|
||||
FGTime *t = FGTime::cur_time_params;
|
||||
//float x, y, z;
|
||||
//double sun_angle;
|
||||
double ra, dec;
|
||||
//double x_2, x_4, x_8, x_10;*/
|
||||
double magnitude;
|
||||
//GLfloat ambient;
|
||||
//GLfloat amb[4];
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
// Step 1: update all the positions
|
||||
ourSun->updatePosition(t);
|
||||
earthsMoon->updatePosition(t, ourSun);
|
||||
mercury->updatePosition(t, ourSun);
|
||||
venus->updatePosition(t, ourSun);
|
||||
mars->updatePosition(t, ourSun);
|
||||
jupiter->updatePosition(t, ourSun);
|
||||
saturn->updatePosition(t, ourSun);
|
||||
uranus->updatePosition(t, ourSun);
|
||||
neptune->updatePosition(t, ourSun);
|
||||
|
||||
fgUpdateSunPos(); // get the right sun angle (especially important when
|
||||
// running for the first time).
|
||||
fgUpdateMoonPos();
|
||||
|
||||
if (displayList)
|
||||
xglDeleteLists(displayList, 1);
|
||||
|
||||
displayList = xglGenLists(1);
|
||||
|
||||
FG_LOG( FG_ASTRO, FG_INFO, "Rebuilding astro display list" );
|
||||
|
||||
// Step 2: rebuild the display list
|
||||
xglNewList( displayList, GL_COMPILE);
|
||||
{
|
||||
// Step 2a: Add the moon...
|
||||
// Not that it is preferred to draw the moon first, and the sun next, in order to mime a
|
||||
// solar eclipse. This is yet untested though...
|
||||
// Euhh, actually the ecplise doesn't work...
|
||||
|
||||
earthsMoon->newImage();
|
||||
// Step 2b: Add the sun
|
||||
ourSun->newImage();
|
||||
// Step 2c: Add the planets
|
||||
xglBegin(GL_POINTS);
|
||||
mercury->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
|
||||
venus ->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
|
||||
mars ->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
|
||||
jupiter->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
|
||||
saturn ->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
|
||||
uranus ->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
|
||||
neptune->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
|
||||
xglEnd();
|
||||
xglEnable(GL_LIGHTING);
|
||||
}
|
||||
xglEndList();
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* double SolarSystem::scaleMagnitude(double magn)
|
||||
* This private member function rescales the original magnitude, as used in the
|
||||
* astronomical sense of the word, into a value used by OpenGL to draw a
|
||||
* convincing Star or planet
|
||||
*
|
||||
* Argument: the astronomical magnitude
|
||||
*
|
||||
* return value: the rescaled magnitude
|
||||
****************************************************************************/
|
||||
double SolarSystem::scaleMagnitude(double magn)
|
||||
{
|
||||
double magnitude = (0.0 - magn) / 5.0 + 1.0;
|
||||
magnitude = magnitude * 0.7 + (3 * 0.1);
|
||||
if (magnitude > 1.0) magnitude = 1.0;
|
||||
if (magnitude < 0.0) magnitude = 0.0;
|
||||
return magnitude;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* void SolarSytem::addPlanetToList(double ra, double dec, double magn);
|
||||
*
|
||||
* This private member function first causes the magnitude to be properly
|
||||
* rescaled, and then adds the planet to the display list.
|
||||
*
|
||||
* arguments: Right Ascension, declination, and magnitude
|
||||
*
|
||||
* return value: none
|
||||
**************************************************************************/
|
||||
void SolarSystem::addPlanetToList(double ra, double dec, double magn)
|
||||
{
|
||||
double
|
||||
magnitude = scaleMagnitude ( magn );
|
||||
|
||||
fgLIGHT *l = &cur_light_params;
|
||||
|
||||
if ((double) (l->sun_angle - FG_PI_2) >
|
||||
((magnitude - 1.0) * - 20 * DEG_TO_RAD))
|
||||
{
|
||||
xglColor3f (magnitude, magnitude, magnitude);
|
||||
xglVertex3f( 50000.0 * cos (ra) * cos (dec),
|
||||
50000.0 * sin (ra) * cos (dec),
|
||||
50000.0 * sin (dec));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SolarSystem* SolarSystem::theSolarSystem = 0;
|
||||
|
||||
/******************************************************************************
|
||||
* void solarSystemRebuild()
|
||||
* this a just a wrapper function, provided for use as an interface to the
|
||||
* event manager
|
||||
*****************************************************************************/
|
||||
void solarSystemRebuild()
|
||||
{
|
||||
SolarSystem::theSolarSystem->rebuild();
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
/**************************************************************************
|
||||
* solarsystem.hxx
|
||||
* Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
* with the FlightGear project. Version 2 was written in August and
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
#ifndef _SOLARSYSTEM_H_
|
||||
#define _SOLARSYSTEM_H_
|
||||
|
||||
#include <Time/light.hxx>
|
||||
#include <Time/fg_time.hxx>
|
||||
#include <Main/views.hxx>
|
||||
|
||||
#include "star.hxx"
|
||||
#include "moon.hxx"
|
||||
#include "mercury.hxx"
|
||||
#include "venus.hxx"
|
||||
#include "mars.hxx"
|
||||
#include "jupiter.hxx"
|
||||
#include "saturn.hxx"
|
||||
#include "uranus.hxx"
|
||||
#include "neptune.hxx"
|
||||
#include "pluto.hxx"
|
||||
|
||||
|
||||
class SolarSystem
|
||||
{
|
||||
private:
|
||||
Star* ourSun;
|
||||
Moon* earthsMoon;
|
||||
Mercury* mercury;
|
||||
Venus* venus;
|
||||
Mars* mars;
|
||||
Jupiter* jupiter;
|
||||
Saturn* saturn;
|
||||
Uranus* uranus;
|
||||
Neptune* neptune;
|
||||
//Pluto* pluto;
|
||||
|
||||
GLint displayList;
|
||||
double scaleMagnitude(double magn);
|
||||
void addPlanetToList(double ra, double dec, double magn);
|
||||
|
||||
|
||||
public:
|
||||
SolarSystem(FGTime *t);
|
||||
CelestialBody *getSun();
|
||||
CelestialBody *getMoon();
|
||||
~SolarSystem();
|
||||
|
||||
static SolarSystem *theSolarSystem; // thanks to Bernie Bright!
|
||||
void rebuild();
|
||||
friend void solarSystemRebuild();
|
||||
void draw();
|
||||
};
|
||||
|
||||
inline CelestialBody* SolarSystem::getSun()
|
||||
{
|
||||
return ourSun;
|
||||
}
|
||||
|
||||
inline CelestialBody* SolarSystem::getMoon()
|
||||
{
|
||||
return earthsMoon;
|
||||
}
|
||||
|
||||
inline void SolarSystem::draw()
|
||||
{
|
||||
xglCallList(displayList);
|
||||
}
|
||||
|
||||
extern void solarSystemRebuild();
|
||||
|
||||
#endif // _SOLARSYSTEM_H_
|
||||
@@ -5,35 +5,37 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# define exception c_exception
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <Time/sunpos.hxx>
|
||||
#include <Debug/logstream.hxx>
|
||||
#include <Time/light.hxx>
|
||||
#include <Main/options.hxx>
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include "star.hxx"
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Star::Star(FGTime *t)
|
||||
* Star::Star(double mjd)
|
||||
* Public constructor for class Star
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements our sun are passed to
|
||||
@@ -41,126 +43,50 @@
|
||||
* note that the word sun is avoided, in order to prevent some compilation
|
||||
* problems on sun systems
|
||||
************************************************************************/
|
||||
Star::Star(FGTime *t) :
|
||||
CelestialBody (0.000000, 0.0000000000,
|
||||
0.0000, 0.00000,
|
||||
282.9404, 4.7093500E-5,
|
||||
1.0000000, 0.000000,
|
||||
0.016709, -1.151E-9,
|
||||
356.0470, 0.98560025850, t)
|
||||
Star::Star(double mjd) :
|
||||
CelestialBody (0.000000, 0.0000000000,
|
||||
0.0000, 0.00000,
|
||||
282.9404, 4.7093500E-5,
|
||||
1.0000000, 0.000000,
|
||||
0.016709, -1.151E-9,
|
||||
356.0470, 0.98560025850, mjd)
|
||||
{
|
||||
|
||||
FG_LOG( FG_GENERAL, FG_INFO, "Initializing Sun Texture");
|
||||
#ifdef GL_VERSION_1_1
|
||||
xglGenTextures(1, &sun_texid);
|
||||
xglBindTexture(GL_TEXTURE_2D, sun_texid);
|
||||
#elif GL_EXT_texture_object
|
||||
xglGenTexturesEXT(1, &sun_texid);
|
||||
xglBindTextureEXT(GL_TEXTURE_2D, sun_texid);
|
||||
#else
|
||||
# error port me
|
||||
#endif
|
||||
distance = 0.0;
|
||||
}
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
setTexture();
|
||||
glTexImage2D( GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGBA,
|
||||
256, 256,
|
||||
0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
sun_texbuf);
|
||||
|
||||
SunObject = gluNewQuadric();
|
||||
if(SunObject == NULL)
|
||||
{
|
||||
printf("gluNewQuadric(SunObject) failed !\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
//SunList = 0;
|
||||
distance = 0.0;
|
||||
Star::Star() :
|
||||
CelestialBody (0.000000, 0.0000000000,
|
||||
0.0000, 0.00000,
|
||||
282.9404, 4.7093500E-5,
|
||||
1.0000000, 0.000000,
|
||||
0.016709, -1.151E-9,
|
||||
356.0470, 0.98560025850)
|
||||
{
|
||||
distance = 0.0;
|
||||
}
|
||||
|
||||
Star::~Star()
|
||||
{
|
||||
//delete SunObject;
|
||||
delete [] sun_texbuf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int texWidth = 256; /* 64x64 is plenty */
|
||||
|
||||
void Star::setTexture()
|
||||
{
|
||||
int texSize;
|
||||
//void *textureBuf;
|
||||
GLubyte *p;
|
||||
int i,j;
|
||||
double radius;
|
||||
|
||||
texSize = texWidth*texWidth;
|
||||
|
||||
sun_texbuf = new GLubyte[texSize*4];
|
||||
if (!sun_texbuf)
|
||||
return; // Ugly!
|
||||
|
||||
p = sun_texbuf;
|
||||
|
||||
radius = (double)(texWidth / 2);
|
||||
|
||||
for (i=0; i < texWidth; i++) {
|
||||
for (j=0; j < texWidth; j++) {
|
||||
double x, y, d;
|
||||
|
||||
x = fabs((double)(i - (texWidth / 2)));
|
||||
y = fabs((double)(j - (texWidth / 2)));
|
||||
|
||||
d = sqrt((x * x) + (y * y));
|
||||
if (d < radius)
|
||||
{
|
||||
double t = 1.0 - (d / radius); // t is 1.0 at center, 0.0 at edge */
|
||||
// inverse square looks nice
|
||||
*p = (int)((double)0xff * (t * t));
|
||||
*(p+1) = (int)((double) 0xff * (t*t));
|
||||
*(p+2) = (int)((double) 0xff * (t*t));
|
||||
*(p+3) = (int)((double) 0xff * (t*t));
|
||||
}
|
||||
else
|
||||
{
|
||||
*p = 0x00;
|
||||
*(p+1) = 0x00;
|
||||
*(p+2) = 0x00;
|
||||
*(p+3) = 0x00;
|
||||
}
|
||||
p += 4;
|
||||
}
|
||||
}
|
||||
//gluBuild2DMipmaps(GL_TEXTURE_2D, 1, texWidth, texWidth,
|
||||
// GL_LUMINANCE,
|
||||
// GL_UNSIGNED_BYTE, textureBuf);
|
||||
//free(textureBuf);
|
||||
}
|
||||
/*************************************************************************
|
||||
* void Jupiter::updatePosition(FGTime *t, Star *ourSun)
|
||||
* void Star::updatePosition(double mjd, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of our sun.
|
||||
*************************************************************************/
|
||||
void Star::updatePosition(FGTime *t)
|
||||
void Star::updatePosition(double mjd)
|
||||
{
|
||||
double
|
||||
actTime, eccAnom,
|
||||
xv, yv, v, r,
|
||||
xe, ye, ze, ecl;
|
||||
|
||||
updateOrbElements(t);
|
||||
updateOrbElements(mjd);
|
||||
|
||||
actTime = fgCalcActTime(t);
|
||||
ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime); // Angle in Radians
|
||||
eccAnom = fgCalcEccAnom(M, e); // Calculate the eccentric Anomaly (also known as solving Kepler's equation)
|
||||
actTime = sgCalcActTime(mjd);
|
||||
ecl = SGD_DEGREES_TO_RADIANS * (23.4393 - 3.563E-7 * actTime); // Angle in Radians
|
||||
eccAnom = sgCalcEccAnom(M, e); // Calculate the eccentric Anomaly (also known as solving Kepler's equation)
|
||||
|
||||
xv = cos(eccAnom) - e;
|
||||
yv = sqrt (1.0 - e*e) * sin(eccAnom);
|
||||
@@ -186,86 +112,3 @@ void Star::updatePosition(FGTime *t)
|
||||
rightAscension = atan2 (ye, xe);
|
||||
declination = atan2 (ze, sqrt (xe*xe + ye*ye));
|
||||
}
|
||||
|
||||
void Star::newImage(void)
|
||||
{
|
||||
/*static float stars[3];
|
||||
stars[0] = 0.0;
|
||||
stars[1] = 0.0;
|
||||
stars[2] = 1.0;*/
|
||||
|
||||
fgLIGHT *l = &cur_light_params;
|
||||
float sun_angle = l->sun_angle;
|
||||
|
||||
if( sun_angle*RAD_TO_DEG < 100 ) { // else no need to draw sun
|
||||
|
||||
|
||||
double x_2, x_4, x_8, x_10;
|
||||
GLfloat ambient;
|
||||
GLfloat amb[4];
|
||||
int sun_size = 550;
|
||||
|
||||
// daily variation sun gets larger near horizon
|
||||
/*if(sun_angle*RAD_TO_DEG > 84.0 && sun_angle*RAD_TO_DEG < 95)
|
||||
{
|
||||
double sun_grow = 9*fabs(94-sun_angle*RAD_TO_DEG);
|
||||
sun_size = (int)(sun_size + sun_size * cos(sun_grow*DEG_TO_RAD));
|
||||
}*/
|
||||
x_2 = sun_angle * sun_angle;
|
||||
x_4 = x_2 * x_2;
|
||||
x_8 = x_4 * x_4;
|
||||
x_10 = x_8 * x_2;
|
||||
ambient = (float)(0.4 * pow (1.1, - x_10 / 30.0));
|
||||
if (ambient < 0.3) ambient = 0.3;
|
||||
if (ambient > 1.0) ambient = 1.0;
|
||||
|
||||
amb[0] = ((ambient * 6.0) - 1.0); // minimum value = 0.8
|
||||
amb[1] = ((ambient * 11.0) - 3.0); // minimum value = 0.3
|
||||
amb[2] = ((ambient * 12.0) - 3.6); // minimum value = 0.0
|
||||
amb[3] = 1.00;
|
||||
|
||||
if (amb[0] > 1.0) amb[0] = 1.0;
|
||||
if (amb[1] > 1.0) amb[1] = 1.0;
|
||||
if (amb[2] > 1.0) amb[2] = 1.0;
|
||||
xglColor3fv(amb);
|
||||
glPushMatrix();
|
||||
{
|
||||
xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
|
||||
xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
|
||||
xglTranslatef(0,60000,0);
|
||||
if (current_options.get_textures())
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
|
||||
glEnable(GL_BLEND); // BLEND ENABLED
|
||||
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glBindTexture(GL_TEXTURE_2D, sun_texid);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0f, 0.0f); glVertex3f(-5000, 0.0, -5000);
|
||||
glTexCoord2f(1.0f, 0.0f); glVertex3f( 5000, 0.0, -5000);
|
||||
glTexCoord2f(1.0f, 1.0f); glVertex3f( 5000, 0.0, 5000);
|
||||
glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000);
|
||||
glEnd();
|
||||
}
|
||||
xglDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
|
||||
xglDisable(GL_BLEND); // BLEND DISABLED
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
glDisable(GL_LIGHTING); //LIGHTING DISABLED
|
||||
glDisable(GL_BLEND); //BLEND DISABLED
|
||||
glPushMatrix();
|
||||
{
|
||||
xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
|
||||
xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
|
||||
xglColor4fv(amb);
|
||||
xglTranslatef(0,60000,0);
|
||||
gluSphere( SunObject, sun_size, 10, 10 );
|
||||
}
|
||||
glPopMatrix();
|
||||
glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
|
||||
glDisable(GL_BLEND); // BLEND DISABLED
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,54 +5,50 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
#ifndef _STAR_HXX_
|
||||
#define _STAR_HXX_
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "celestialBody.hxx"
|
||||
|
||||
#include <simgear/ephemeris/celestialBody.hxx>
|
||||
|
||||
|
||||
class Star : public CelestialBody
|
||||
{
|
||||
|
||||
private:
|
||||
//double longitude; // the sun's true longitude - this is depreciated by
|
||||
// CelestialBody::lonEcl
|
||||
double xs, ys; // the sun's rectangular geocentric coordinates
|
||||
double distance; // the sun's distance to the earth
|
||||
GLUquadricObj *SunObject;
|
||||
GLuint sun_texid;
|
||||
GLubyte *sun_texbuf;
|
||||
|
||||
void setTexture();
|
||||
double xs, ys; // the sun's rectangular geocentric coordinates
|
||||
double distance; // the sun's distance to the earth
|
||||
|
||||
public:
|
||||
Star (FGTime *t);
|
||||
~Star();
|
||||
void updatePosition(FGTime *t);
|
||||
double getM();
|
||||
double getw();
|
||||
//double getLon();
|
||||
double getxs();
|
||||
double getys();
|
||||
double getDistance();
|
||||
void newImage();
|
||||
};
|
||||
|
||||
Star (double mjd);
|
||||
Star ();
|
||||
~Star();
|
||||
void updatePosition(double mjd);
|
||||
double getM();
|
||||
double getw();
|
||||
double getxs();
|
||||
double getys();
|
||||
double getDistance();
|
||||
};
|
||||
|
||||
|
||||
inline double Star::getM()
|
||||
|
||||
126
simgear/ephemeris/stardata.cxx
Normal file
126
simgear/ephemeris/stardata.cxx
Normal file
@@ -0,0 +1,126 @@
|
||||
// stardata.cxx -- manage star data
|
||||
//
|
||||
// Written by Curtis Olson, started March 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the
|
||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/sgstream.hxx>
|
||||
|
||||
#include "stardata.hxx"
|
||||
|
||||
#if defined (_MSC_VER) || defined (SG_HAVE_NATIVE_SGI_COMPILERS)
|
||||
SG_USING_STD(getline);
|
||||
#endif
|
||||
|
||||
// Constructor
|
||||
SGStarData::SGStarData() :
|
||||
nstars(0)
|
||||
{
|
||||
}
|
||||
|
||||
SGStarData::SGStarData( SGPath path ) :
|
||||
nstars(0)
|
||||
{
|
||||
data_path = SGPath( path );
|
||||
load();
|
||||
}
|
||||
|
||||
|
||||
// Destructor
|
||||
SGStarData::~SGStarData() {
|
||||
}
|
||||
|
||||
|
||||
bool SGStarData::load() {
|
||||
|
||||
// -dw- avoid local data > 32k error by dynamic allocation of the
|
||||
// array, problem for some compilers
|
||||
stars = new sgdVec3[SG_MAX_STARS];
|
||||
|
||||
// build the full path name to the stars data base file
|
||||
data_path.append( "stars" );
|
||||
SG_LOG( SG_ASTRO, SG_INFO, " Loading stars from " << data_path.str() );
|
||||
|
||||
sg_gzifstream in( data_path.str() );
|
||||
if ( ! in.is_open() ) {
|
||||
SG_LOG( SG_ASTRO, SG_ALERT, "Cannot open star file: "
|
||||
<< data_path.str() );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
double ra, dec, mag;
|
||||
char c;
|
||||
string name;
|
||||
|
||||
nstars = 0;
|
||||
|
||||
// read in each line of the file
|
||||
while ( ! in.eof() && nstars < SG_MAX_STARS ) {
|
||||
in >> skipcomment;
|
||||
|
||||
getline( in, name, ',' );
|
||||
// cout << " data = " << name << endl;
|
||||
|
||||
// read name and first comma
|
||||
while ( in.get(c) ) {
|
||||
if ( (c != ' ') && (c != ',') ) {
|
||||
// push back on the stream
|
||||
in.putback(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
in >> ra;
|
||||
|
||||
// read past optional comma
|
||||
while ( in.get(c) ) {
|
||||
if ( (c != ' ') && (c != ',') ) {
|
||||
// push back on the stream
|
||||
in.putback(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
in >> dec;
|
||||
|
||||
// read past optional comma
|
||||
while ( in.get(c) ) {
|
||||
if ( (c != ' ') && (c != ',') ) {
|
||||
// push back on the stream
|
||||
in.putback(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
in >> mag;
|
||||
|
||||
// cout << " star data = " << ra << " " << dec << " " << mag << endl;
|
||||
|
||||
sgdSetVec3( stars[nstars], ra, dec, mag );
|
||||
|
||||
++nstars;
|
||||
}
|
||||
|
||||
SG_LOG( SG_ASTRO, SG_INFO, " Loaded " << nstars << " stars" );
|
||||
|
||||
return true;
|
||||
}
|
||||
62
simgear/ephemeris/stardata.hxx
Normal file
62
simgear/ephemeris/stardata.hxx
Normal file
@@ -0,0 +1,62 @@
|
||||
// stardata.hxx -- manage star data
|
||||
//
|
||||
// Written by Curtis Olson, started March 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the
|
||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
|
||||
#ifndef _SG_STARDATA_HXX
|
||||
#define _SG_STARDATA_HXX
|
||||
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
||||
|
||||
#define SG_MAX_STARS 850
|
||||
|
||||
|
||||
class SGStarData {
|
||||
|
||||
int nstars;
|
||||
sgdVec3 *stars;
|
||||
|
||||
SGPath data_path;
|
||||
|
||||
public:
|
||||
|
||||
// Constructor
|
||||
SGStarData();
|
||||
SGStarData( SGPath path );
|
||||
|
||||
// Destructor
|
||||
~SGStarData();
|
||||
|
||||
// load the stars database
|
||||
bool load();
|
||||
|
||||
// stars
|
||||
inline int getNumStars() const { return nstars; }
|
||||
inline sgdVec3 *getStars() { return stars; }
|
||||
};
|
||||
|
||||
|
||||
#endif // _SG_STARDATA_HXX
|
||||
@@ -1,267 +0,0 @@
|
||||
// stars.cxx -- data structures and routines for managing and rendering stars.
|
||||
//
|
||||
// Written by Curtis Olson, started August 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@me.umn.edu
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
//*************************************************************************/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "Include/compiler.h"
|
||||
#ifdef FG_HAVE_STD_INCLUDES
|
||||
# include <cmath>
|
||||
# include <cstdio>
|
||||
# include <cstring>
|
||||
# include <ctime>
|
||||
#else
|
||||
# include <math.h>
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <time.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include <XGL/xgl.h>
|
||||
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
#include <Debug/logstream.hxx>
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Misc/fgpath.hxx>
|
||||
#include <Misc/fgstream.hxx>
|
||||
#include <Misc/stopwatch.hxx>
|
||||
#include <Main/options.hxx>
|
||||
#include <Main/views.hxx>
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "Misc/stopwatch.hxx"
|
||||
|
||||
#include "stars.hxx"
|
||||
|
||||
FG_USING_STD(getline);
|
||||
|
||||
#define EpochStart (631065600)
|
||||
#define DaysSinceEpoch(secs) (((secs)-EpochStart)*(1.0/(24*3600)))
|
||||
#define FG_MAX_STARS 3500
|
||||
|
||||
// Define four structures, each with varying amounts of stars
|
||||
static GLint stars[FG_STAR_LEVELS];
|
||||
|
||||
|
||||
// Initialize the Star Management Subsystem
|
||||
int fgStarsInit( void ) {
|
||||
// -dw- avoid local data > 32k error by dynamic allocation of the
|
||||
// array, problem for some compilers
|
||||
Point3D *starlist = new Point3D[FG_MAX_STARS];
|
||||
// struct CelestialCoord pltPos;
|
||||
double right_ascension, declination, magnitude;
|
||||
double min_magnitude[FG_STAR_LEVELS];
|
||||
// double ra_save, decl_save;
|
||||
// double ra_save1, decl_save1;
|
||||
int i, j, starcount, count;
|
||||
|
||||
FG_LOG( FG_ASTRO, FG_INFO, "Initializing stars" );
|
||||
|
||||
if ( FG_STAR_LEVELS < 4 ) {
|
||||
FG_LOG( FG_ASTRO, FG_ALERT, "Big whups in stars.cxx" );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// build the full path name to the stars data base file
|
||||
FGPath path ( current_options.get_fg_root() );
|
||||
path.append( "Astro/stars" );
|
||||
FG_LOG( FG_ASTRO, FG_INFO, " Loading stars from " << path.str() );
|
||||
|
||||
fg_gzifstream in( path.str() );
|
||||
if ( ! in ) {
|
||||
FG_LOG( FG_ASTRO, FG_ALERT, "Cannot open star file: " << path.str() );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
starcount = 0;
|
||||
|
||||
StopWatch timer;
|
||||
timer.start();
|
||||
|
||||
// read in each line of the file
|
||||
while ( ! in.eof() && starcount < FG_MAX_STARS )
|
||||
{
|
||||
in >> skipcomment;
|
||||
string name;
|
||||
getline( in, name, ',' );
|
||||
in >> starlist[starcount];
|
||||
++starcount;
|
||||
}
|
||||
|
||||
timer.stop();
|
||||
FG_LOG( FG_ASTRO, FG_INFO,
|
||||
"Loaded " << starcount << " stars in "
|
||||
<< timer.elapsedSeconds() << " seconds" );
|
||||
|
||||
min_magnitude[0] = 4.2;
|
||||
min_magnitude[1] = 3.6;
|
||||
min_magnitude[2] = 3.0;
|
||||
min_magnitude[3] = 2.4;
|
||||
min_magnitude[4] = 1.8;
|
||||
min_magnitude[5] = 1.2;
|
||||
min_magnitude[6] = 0.6;
|
||||
min_magnitude[7] = 0.0;
|
||||
|
||||
// build the various star display lists
|
||||
for ( i = 0; i < FG_STAR_LEVELS; i++ ) {
|
||||
|
||||
stars[i] = xglGenLists(1);
|
||||
xglNewList( stars[i], GL_COMPILE );
|
||||
xglBegin( GL_POINTS );
|
||||
|
||||
count = 0;
|
||||
|
||||
for ( j = 0; j < starcount; j++ ) {
|
||||
magnitude = starlist[j].z();
|
||||
// printf("magnitude = %.2f\n", magnitude);
|
||||
|
||||
if ( magnitude < min_magnitude[i] ) {
|
||||
right_ascension = starlist[j].x();
|
||||
declination = starlist[j].y();
|
||||
|
||||
count++;
|
||||
|
||||
// scale magnitudes to (0.0 - 1.0)
|
||||
magnitude = (0.0 - magnitude) / 5.0 + 1.0;
|
||||
|
||||
// scale magnitudes again so they look ok
|
||||
if ( magnitude > 1.0 ) { magnitude = 1.0; }
|
||||
if ( magnitude < 0.0 ) { magnitude = 0.0; }
|
||||
// magnitude =
|
||||
// magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.042);
|
||||
|
||||
magnitude = magnitude * 0.9 +
|
||||
(((FG_STAR_LEVELS - 1) - i) * 0.014);
|
||||
// printf(" Found star: %d %s, %.3f %.3f %.3f\n", count,
|
||||
// name, right_ascension, declination, magnitude);
|
||||
|
||||
xglColor3f( magnitude, magnitude, magnitude );
|
||||
//xglColor3f(0,0,0);*/
|
||||
xglVertex3f( 50000.0*cos(right_ascension)*cos(declination),
|
||||
50000.0*sin(right_ascension)*cos(declination),
|
||||
50000.0*sin(declination) );
|
||||
}
|
||||
} // while
|
||||
|
||||
xglEnd();
|
||||
|
||||
/*
|
||||
xglBegin(GL_LINE_LOOP);
|
||||
xglColor3f(1.0, 0.0, 0.0);
|
||||
xglVertex3f( 50000.0 * cos(ra_save-0.2) * cos(decl_save-0.2),
|
||||
50000.0 * sin(ra_save-0.2) * cos(decl_save-0.2),
|
||||
50000.0 * sin(decl_save-0.2) );
|
||||
xglVertex3f( 50000.0 * cos(ra_save+0.2) * cos(decl_save-0.2),
|
||||
50000.0 * sin(ra_save+0.2) * cos(decl_save-0.2),
|
||||
50000.0 * sin(decl_save-0.2) );
|
||||
xglVertex3f( 50000.0 * cos(ra_save+0.2) * cos(decl_save+0.2),
|
||||
50000.0 * sin(ra_save+0.2) * cos(decl_save+0.2),
|
||||
50000.0 * sin(decl_save+0.2) );
|
||||
xglVertex3f( 50000.0 * cos(ra_save-0.2) * cos(decl_save+0.2),
|
||||
50000.0 * sin(ra_save-0.2) * cos(decl_save+0.2),
|
||||
50000.0 * sin(decl_save+0.2) );
|
||||
xglEnd();
|
||||
*/
|
||||
|
||||
/*
|
||||
xglBegin(GL_LINE_LOOP);
|
||||
xglColor3f(0.0, 1.0, 0.0);
|
||||
xglVertex3f( 50000.0 * cos(ra_save1-0.2) * cos(decl_save1-0.2),
|
||||
50000.0 * sin(ra_save1-0.2) * cos(decl_save1-0.2),
|
||||
50000.0 * sin(decl_save1-0.2) );
|
||||
xglVertex3f( 50000.0 * cos(ra_save1+0.2) * cos(decl_save1-0.2),
|
||||
50000.0 * sin(ra_save1+0.2) * cos(decl_save1-0.2),
|
||||
50000.0 * sin(decl_save1-0.2) );
|
||||
xglVertex3f( 50000.0 * cos(ra_save1+0.2) * cos(decl_save1+0.2),
|
||||
50000.0 * sin(ra_save1+0.2) * cos(decl_save1+0.2),
|
||||
50000.0 * sin(decl_save1+0.2) );
|
||||
xglVertex3f( 50000.0 * cos(ra_save1-0.2) * cos(decl_save1+0.2),
|
||||
50000.0 * sin(ra_save1-0.2) * cos(decl_save1+0.2),
|
||||
50000.0 * sin(decl_save1+0.2) );
|
||||
xglEnd();
|
||||
*/
|
||||
|
||||
xglEndList();
|
||||
|
||||
FG_LOG( FG_ASTRO, FG_INFO,
|
||||
" Loading " << count << " stars brighter than "
|
||||
<< min_magnitude[i] );
|
||||
}
|
||||
|
||||
return 1; // OK, we got here because initialization worked.
|
||||
}
|
||||
|
||||
|
||||
// Draw the Stars
|
||||
void fgStarsRender( void ) {
|
||||
FGInterface *f;
|
||||
fgLIGHT *l;
|
||||
FGTime *t;
|
||||
int i;
|
||||
|
||||
f = current_aircraft.fdm_state;
|
||||
l = &cur_light_params;
|
||||
t = FGTime::cur_time_params;
|
||||
|
||||
// FG_PI_2 + 0.1 is about 6 degrees after sundown and before sunrise
|
||||
|
||||
// t->sun_angle = 3.0; // to force stars to be drawn (for testing)
|
||||
|
||||
// render the stars
|
||||
if ( l->sun_angle > (FG_PI_2 + 5 * DEG_TO_RAD ) ) {
|
||||
// determine which star structure to draw
|
||||
if ( l->sun_angle > (FG_PI_2 + 10.0 * DEG_TO_RAD ) ) {
|
||||
i = 0;
|
||||
} else if ( l->sun_angle > (FG_PI_2 + 8.8 * DEG_TO_RAD ) ) {
|
||||
i = 1;
|
||||
} else if ( l->sun_angle > (FG_PI_2 + 7.5 * DEG_TO_RAD ) ) {
|
||||
i = 2;
|
||||
} else if ( l->sun_angle > (FG_PI_2 + 7.0 * DEG_TO_RAD ) ) {
|
||||
i = 3;
|
||||
} else if ( l->sun_angle > (FG_PI_2 + 6.5 * DEG_TO_RAD ) ) {
|
||||
i = 4;
|
||||
} else if ( l->sun_angle > (FG_PI_2 + 6.0 * DEG_TO_RAD ) ) {
|
||||
i = 5;
|
||||
} else if ( l->sun_angle > (FG_PI_2 + 5.5 * DEG_TO_RAD ) ) {
|
||||
i = 6;
|
||||
} else {
|
||||
i = 7;
|
||||
}
|
||||
|
||||
// printf("RENDERING STARS = %d (night)\n", i);
|
||||
|
||||
xglCallList(stars[i]);
|
||||
} else {
|
||||
// printf("not RENDERING STARS (day)\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
// stars.hxx -- data structures and routines for managing and rendering stars.
|
||||
//
|
||||
// Written by Curtis Olson, started August 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@me.umn.edu
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
|
||||
#ifndef _STARS_HXX
|
||||
#define _STARS_HXX
|
||||
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
|
||||
#define FG_STAR_LEVELS 8 // how many star transitions
|
||||
|
||||
// Initialize the Star Management Subsystem
|
||||
int fgStarsInit( void );
|
||||
|
||||
// Draw the Stars
|
||||
void fgStarsRender( void );
|
||||
|
||||
// [no longer used?] extern FGTime cur_time_params;
|
||||
|
||||
|
||||
#endif // _STARS_HXX
|
||||
|
||||
|
||||
@@ -5,19 +5,20 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
@@ -30,31 +31,40 @@
|
||||
#include "uranus.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Uranus::Uranus(FGTime *t)
|
||||
* Uranus::Uranus(double mjd)
|
||||
* Public constructor for class Uranus
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Uranus are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Uranus::Uranus(FGTime *t) :
|
||||
Uranus::Uranus(double mjd) :
|
||||
CelestialBody(74.00050, 1.3978000E-5,
|
||||
0.7733, 1.900E-8,
|
||||
96.66120, 3.0565000E-5,
|
||||
19.181710, -1.55E-8,
|
||||
0.047318, 7.450E-9,
|
||||
142.5905, 0.01172580600, t)
|
||||
142.5905, 0.01172580600, mjd)
|
||||
{
|
||||
}
|
||||
Uranus::Uranus() :
|
||||
CelestialBody(74.00050, 1.3978000E-5,
|
||||
0.7733, 1.900E-8,
|
||||
96.66120, 3.0565000E-5,
|
||||
19.181710, -1.55E-8,
|
||||
0.047318, 7.450E-9,
|
||||
142.5905, 0.01172580600)
|
||||
{
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* void Uranus::updatePosition(FGTime *t, Star *ourSun)
|
||||
* void Uranus::updatePosition(double mjd, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Uranus, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Uranus specific equation
|
||||
*************************************************************************/
|
||||
void Uranus::updatePosition(FGTime *t, Star *ourSun)
|
||||
void Uranus::updatePosition(double mjd, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
CelestialBody::updatePosition(mjd, ourSun);
|
||||
magnitude = -7.15 + 5*log10( r*R) + 0.001 * FV;
|
||||
}
|
||||
|
||||
@@ -5,34 +5,35 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
#ifndef _URANUS_HXX_
|
||||
#define _URANUS_HXX_
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
#include <simgear/ephemeris/celestialBody.hxx>
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
|
||||
class Uranus : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Uranus ( FGTime *t);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
Uranus (double mjd);
|
||||
Uranus ();
|
||||
void updatePosition(double mjd, Star *ourSun);
|
||||
};
|
||||
|
||||
#endif // _URANUS_HXX_
|
||||
|
||||
@@ -5,19 +5,20 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
@@ -30,31 +31,40 @@
|
||||
#include "venus.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Venus::Venus(FGTime *t)
|
||||
* Venus::Venus(double mjd)
|
||||
* Public constructor for class Venus
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Venus are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Venus::Venus(FGTime *t) :
|
||||
Venus::Venus(double mjd) :
|
||||
CelestialBody(76.67990, 2.4659000E-5,
|
||||
3.3946, 2.75E-8,
|
||||
54.89100, 1.3837400E-5,
|
||||
0.7233300, 0.000000,
|
||||
0.006773, -1.302E-9,
|
||||
48.00520, 1.60213022440, t)
|
||||
48.00520, 1.60213022440, mjd)
|
||||
{
|
||||
}
|
||||
Venus::Venus() :
|
||||
CelestialBody(76.67990, 2.4659000E-5,
|
||||
3.3946, 2.75E-8,
|
||||
54.89100, 1.3837400E-5,
|
||||
0.7233300, 0.000000,
|
||||
0.006773, -1.302E-9,
|
||||
48.00520, 1.60213022440)
|
||||
{
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* void Venus::updatePosition(FGTime *t, Star *ourSun)
|
||||
* void Venus::updatePosition(double mjd, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Venus, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Venus specific equation
|
||||
*************************************************************************/
|
||||
void Venus::updatePosition(FGTime *t, Star *ourSun)
|
||||
void Venus::updatePosition(double mjd, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
CelestialBody::updatePosition(mjd, ourSun);
|
||||
magnitude = -4.34 + 5*log10( r*R ) + 0.013 * FV + 4.2E-07 * pow(FV,3);
|
||||
}
|
||||
|
||||
@@ -5,34 +5,35 @@
|
||||
* September 1998. This code is based upon algorithms and data kindly
|
||||
* provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
#ifndef _VENUS_HXX_
|
||||
#define _VENUS_HXX_
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
#include <simgear/ephemeris/celestialBody.hxx>
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
|
||||
class Venus : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Venus ( FGTime *t);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
Venus (double mjd);
|
||||
Venus ();
|
||||
void updatePosition(double mjd, Star *ourSun);
|
||||
};
|
||||
|
||||
#endif // _VENUS_HXX_
|
||||
|
||||
3
simgear/interpreter/.cvsignore
Normal file
3
simgear/interpreter/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
33
simgear/interpreter/Makefile.am
Normal file
33
simgear/interpreter/Makefile.am
Normal file
@@ -0,0 +1,33 @@
|
||||
includedir = @includedir@/js
|
||||
|
||||
lib_LIBRARIES = libsginterp.a
|
||||
|
||||
include_HEADERS = \
|
||||
interpreter.hxx
|
||||
|
||||
libsginterp_a_SOURCES = \
|
||||
interpreter.cxx interpreter.hxx \
|
||||
ixlib_javascript.hh \
|
||||
js_array.cc \
|
||||
js_expression.cc \
|
||||
js_interpreter.cc \
|
||||
js_value.cc \
|
||||
js_declaration.cc \
|
||||
js_instruction.cc \
|
||||
js_library.cc \
|
||||
lex.javascript.cc ixlib_token_lex.hh ixlib_token_javascript.hh \
|
||||
scanner.cc ixlib_scanner.hh ixlib_scanjs.hh \
|
||||
exbase.cc \
|
||||
numeric.cc ixlib_numeric.hh \
|
||||
numconv.cc ixlib_numconv.hh \
|
||||
re.cc ixlib_re.hh ixlib_re_impl.hh \
|
||||
exgen.cc ixlib_exgen.hh \
|
||||
string.cc ixlib_string.hh \
|
||||
ixlib_base.hh \
|
||||
ixlib_exbase.hh \
|
||||
ixlib_garbage.hh \
|
||||
ixlib_i18n.hh \
|
||||
ixlib_js_internals.hh \
|
||||
ixlib_random.hh
|
||||
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
77
simgear/interpreter/exbase.cc
Normal file
77
simgear/interpreter/exbase.cc
Normal file
@@ -0,0 +1,77 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Exception handling
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 1996 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <ixlib_exbase.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
using namespace ixion;
|
||||
|
||||
|
||||
|
||||
|
||||
// Description forms ----------------------------------------------------------
|
||||
#define T_DESCRIPTION1 "[%s%04X] %s"
|
||||
#define T_DESCRIPTION2 "[%s%04X] %s <%s>"
|
||||
#define T_DESCRIPTION3 "[%s%04X] %s <%s,%d>"
|
||||
#define T_DESCRIPTION1I "[%s%04X] %s (%s)"
|
||||
#define T_DESCRIPTION2I "[%s%04X] %s (%s) <%s>"
|
||||
#define T_DESCRIPTION3I "[%s%04X] %s (%s) <%s,%d>"
|
||||
|
||||
|
||||
|
||||
|
||||
// base_exception -------------------------------------------------------------
|
||||
char base_exception::RenderBuffer[EX_INFOMAX+1+100];
|
||||
|
||||
|
||||
|
||||
|
||||
base_exception::base_exception(TErrorCode error,char const *info,char *module,
|
||||
TIndex line,char *category)
|
||||
: Error(error),Module(module),Line(line),Category(category) {
|
||||
HasInfo = (info!=NULL);
|
||||
if (info) {
|
||||
if (strlen(info)>EX_INFOMAX) {
|
||||
strncpy(Info,info,EX_INFOMAX);
|
||||
Info[EX_INFOMAX] = '\0';
|
||||
}
|
||||
else strcpy(Info,info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
char const *base_exception::what() const throw () {
|
||||
if (HasInfo) {
|
||||
if (Module) {
|
||||
if (Line)
|
||||
sprintf(RenderBuffer,T_DESCRIPTION3I,Category,Error,getText(),Info,Module,Line);
|
||||
else
|
||||
sprintf(RenderBuffer,T_DESCRIPTION2I,Category,Error,getText(),Info,Module);
|
||||
}
|
||||
else
|
||||
sprintf(RenderBuffer,T_DESCRIPTION1I,Category,Error,getText(),Info);
|
||||
}
|
||||
else {
|
||||
if (Module) {
|
||||
if (Line)
|
||||
sprintf(RenderBuffer,T_DESCRIPTION3,Category,Error,getText(),Module,Line);
|
||||
else
|
||||
sprintf(RenderBuffer,T_DESCRIPTION2,Category,Error,getText(),Module);
|
||||
}
|
||||
else
|
||||
sprintf(RenderBuffer,T_DESCRIPTION1,Category,Error,getText());
|
||||
}
|
||||
return RenderBuffer;
|
||||
}
|
||||
46
simgear/interpreter/exgen.cc
Normal file
46
simgear/interpreter/exgen.cc
Normal file
@@ -0,0 +1,46 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Generic exceptions
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 1996 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#include "ixlib_i18n.hh"
|
||||
#include <ixlib_exgen.hh>
|
||||
#include <ixlib_numconv.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
using namespace ixion;
|
||||
|
||||
|
||||
|
||||
|
||||
static char *(PlainText[]) = {
|
||||
N_("Unable to evaluate expression"),
|
||||
N_("Function not yet implemented"),
|
||||
N_("General error"),
|
||||
N_("NULL pointer encountered"),
|
||||
N_("Invalid parameter"),
|
||||
N_("Index out of range"),
|
||||
N_("Buffer overrun"),
|
||||
N_("Buffer underrun"),
|
||||
N_("Item not found"),
|
||||
N_("Invalid operation"),
|
||||
N_("Dimension mismatch"),
|
||||
N_("Operation cancelled"),
|
||||
N_("Unable to operate on empty set"),
|
||||
N_("Unable to remove GC entry"),
|
||||
N_("Unable to protect non-freeable entry")
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// generic_exception ----------------------------------------------------------
|
||||
char const *generic_exception::getText() const {
|
||||
return _(PlainText[Error]);
|
||||
}
|
||||
9
simgear/interpreter/interpreter.cxx
Normal file
9
simgear/interpreter/interpreter.cxx
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "interpreter.hxx"
|
||||
|
||||
SGInterpreter::SGInterpreter ()
|
||||
{
|
||||
}
|
||||
|
||||
SGInterpreter::~SGInterpreter ()
|
||||
{
|
||||
}
|
||||
13
simgear/interpreter/interpreter.hxx
Normal file
13
simgear/interpreter/interpreter.hxx
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef __INTERPRETER_HXX
|
||||
#define __INTERPRETER_HXX 1
|
||||
|
||||
class SGInterpreter
|
||||
{
|
||||
public:
|
||||
|
||||
SGInterpreter ();
|
||||
virtual ~SGInterpreter ();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
107
simgear/interpreter/ixlib_base.hh
Normal file
107
simgear/interpreter/ixlib_base.hh
Normal file
@@ -0,0 +1,107 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
Description : iXiONmedia library base declarations
|
||||
----------------------------------------------------------------------------
|
||||
(c) Copyright 1996 by iXiONmedia, all rights reserved.
|
||||
----------------------------------------------------------------------------
|
||||
This header must be C-safe for autoconf purposes.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef IXLIB_BASE
|
||||
#define IXLIB_BASE
|
||||
|
||||
|
||||
#undef HAVE_CONFIG_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <ixlib_config.hh>
|
||||
#undef PACKAGE
|
||||
#undef VERSION
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace ixion {
|
||||
extern "C" {
|
||||
#endif
|
||||
/* Aliases --------------------------------------------------------------------
|
||||
*/
|
||||
const double Pi = 3.141592653589793285;
|
||||
const double Euler = 2.718281828;
|
||||
const double Gravity = 9.8065; // m/s^2
|
||||
const double UniGravity = 6.673e-11; // m^3/kg s^2
|
||||
const double Epsilon0 = 8.8542e-12; // F/m
|
||||
const double Mu0 = 1.2566e-6; // H/m
|
||||
const double LightSpeed = 2.9972e8; // m/s
|
||||
const double Planck = 6.6261e-34; // Js
|
||||
|
||||
|
||||
|
||||
|
||||
/* STL Helper macro -----------------------------------------------------------
|
||||
*/
|
||||
#define FOREACH(VAR,LIST,LISTTYPE) \
|
||||
for (LISTTYPE::iterator VAR = (LIST).begin(),last = (LIST).end();VAR != last;VAR++)
|
||||
#define FOREACH_CONST(VAR,LIST,LISTTYPE) \
|
||||
for (LISTTYPE::const_iterator VAR = (LIST).begin(),last = (LIST).end();VAR != last;VAR++)
|
||||
|
||||
|
||||
|
||||
|
||||
/* Nomenclature typedefs ------------------------------------------------------
|
||||
*/
|
||||
typedef unsigned char TUnsigned8;
|
||||
typedef unsigned short TUnsigned16;
|
||||
typedef unsigned long TUnsigned32;
|
||||
typedef unsigned long long TUnsigned64;
|
||||
|
||||
typedef signed char TSigned8;
|
||||
typedef signed short TSigned16;
|
||||
typedef signed long TSigned32;
|
||||
typedef signed long long TSigned64;
|
||||
|
||||
typedef TSigned8 TDelta8;
|
||||
typedef TSigned16 TDelta16;
|
||||
typedef TSigned32 TDelta32;
|
||||
typedef TSigned64 TDelta64;
|
||||
typedef signed TDelta;
|
||||
|
||||
typedef TUnsigned8 TSize8;
|
||||
typedef TUnsigned16 TSize16;
|
||||
typedef TUnsigned32 TSize32;
|
||||
typedef TUnsigned64 TSize64;
|
||||
typedef unsigned TSize;
|
||||
|
||||
typedef TUnsigned8 TIndex8;
|
||||
typedef TUnsigned16 TIndex16;
|
||||
typedef TUnsigned32 TIndex32;
|
||||
typedef TUnsigned64 TIndex64;
|
||||
typedef unsigned TIndex;
|
||||
|
||||
typedef TUnsigned8 TByte;
|
||||
|
||||
|
||||
|
||||
|
||||
int ixlibGetMajorVersion();
|
||||
int ixlibGetMinorVersion();
|
||||
int ixlibGetMicroVersion();
|
||||
|
||||
void ixlibInitI18n();
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
72
simgear/interpreter/ixlib_exbase.hh
Normal file
72
simgear/interpreter/ixlib_exbase.hh
Normal file
@@ -0,0 +1,72 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Exception handling
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 1996 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef IXLIB_EXBASE
|
||||
#define IXLIB_EXBASE
|
||||
|
||||
|
||||
|
||||
|
||||
#include <stdexcept>
|
||||
#include <ixlib_base.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
// constants ------------------------------------------------------------------
|
||||
#define EX_INFOMAX 255
|
||||
|
||||
|
||||
|
||||
|
||||
// throw macro ----------------------------------------------------------------
|
||||
#define EX_THROW(TYPE,CODE)\
|
||||
throw ::ixion::TYPE##_exception(CODE,NULL,__FILE__,__LINE__);
|
||||
#define EX_THROWINFO(TYPE,CODE,INFO)\
|
||||
throw ::ixion::TYPE##_exception(CODE,(char const *) INFO,__FILE__,__LINE__);
|
||||
#define EX_CATCHCODE(TYPE,CODE,HANDLER)\
|
||||
catch (TYPE##_exception &ex) { \
|
||||
if (ex.Error != CODE) throw; \
|
||||
HANDLER \
|
||||
}
|
||||
#define EX_CONVERT(TYPE,CODE,DESTTYPE,DESTCODE)\
|
||||
catch (TYPE##_exception &ex) { \
|
||||
if (ex.Error != CODE) throw; \
|
||||
throw DESTTYPE##_exception(DESTCODE,ex.Info,__FILE__,__LINE__); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// xBaseException -------------------------------------------------------------
|
||||
namespace ixion {
|
||||
typedef unsigned int TErrorCode;
|
||||
|
||||
|
||||
|
||||
|
||||
struct base_exception : public std::exception {
|
||||
TErrorCode Error;
|
||||
char *Module;
|
||||
TIndex Line;
|
||||
char *Category;
|
||||
bool HasInfo;
|
||||
char Info[EX_INFOMAX+1];
|
||||
static char RenderBuffer[EX_INFOMAX+1+100];
|
||||
|
||||
base_exception(TErrorCode error,char const *info = NULL,char *module = NULL,
|
||||
TIndex line = 0,char *category = NULL);
|
||||
char const *what() const throw ();
|
||||
virtual const char *getText() const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
67
simgear/interpreter/ixlib_exgen.hh
Normal file
67
simgear/interpreter/ixlib_exgen.hh
Normal file
@@ -0,0 +1,67 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Generic exceptions
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 1996 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef IXLIB_EXGEN
|
||||
#define IXLIB_EXGEN
|
||||
|
||||
|
||||
|
||||
|
||||
#include <ixlib_exbase.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
// Error codes ----------------------------------------------------------------
|
||||
#define EC_CANNOTEVALUATE 0
|
||||
#define EC_NOTYETIMPLEMENTED 1
|
||||
#define EC_ERROR 2
|
||||
#define EC_NULLPOINTER 3
|
||||
#define EC_INVALIDPAR 4
|
||||
#define EC_INDEX 5
|
||||
#define EC_BUFFEROVERFLOW 6
|
||||
#define EC_BUFFERUNDERFLOW 7
|
||||
#define EC_ITEMNOTFOUND 8
|
||||
#define EC_INVALIDOP 9
|
||||
#define EC_DIMENSIONMISMATCH 10
|
||||
#define EC_CANCELLED 11
|
||||
#define EC_EMPTYSET 12
|
||||
#define EC_CANNOTREMOVEFROMGC 13
|
||||
#define EC_REMAININGREF 14
|
||||
|
||||
#define ECMEM_GENERAL 0
|
||||
|
||||
|
||||
|
||||
// Throw macro ----------------------------------------------------------------
|
||||
#define EXGEN_THROW(CODE)\
|
||||
EX_THROW(generic,CODE)
|
||||
#define EXGEN_THROWINFO(CODE,INFO)\
|
||||
EX_THROWINFO(generic,CODE,INFO)
|
||||
#define EXGEN_NYI\
|
||||
EXGEN_THROW(EC_NOTYETIMPLEMENTED)
|
||||
|
||||
|
||||
|
||||
|
||||
namespace ixion {
|
||||
// generic_exception ----------------------------------------------------------
|
||||
struct generic_exception : public base_exception {
|
||||
generic_exception(TErrorCode error,char const *info = NULL,char *module = NULL,
|
||||
TIndex line = 0)
|
||||
: base_exception(error,info,module,line,"GEN") {
|
||||
}
|
||||
virtual char const *getText() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
491
simgear/interpreter/ixlib_garbage.hh
Normal file
491
simgear/interpreter/ixlib_garbage.hh
Normal file
@@ -0,0 +1,491 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Garbage collection
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 2000 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef IXLIB_GARBAGE
|
||||
#define IXLIB_GARBAGE
|
||||
|
||||
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <ixlib_exgen.hh>
|
||||
#include <ixlib_base.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
namespace ixion {
|
||||
template<class T>
|
||||
class delete_deallocator {
|
||||
public:
|
||||
void operator()(T const *instance) {
|
||||
delete instance;
|
||||
}
|
||||
};
|
||||
template<class T>
|
||||
class delete_array_deallocator {
|
||||
public:
|
||||
void operator()(T const *instance) {
|
||||
delete[] instance;
|
||||
}
|
||||
};
|
||||
|
||||
template<class T,class Deallocator = delete_deallocator<T> >
|
||||
class reference_manager;
|
||||
|
||||
template<class T>
|
||||
class ref_base {
|
||||
protected:
|
||||
T *Instance;
|
||||
|
||||
public:
|
||||
ref_base(T *instance = NULL)
|
||||
: Instance(instance) {
|
||||
}
|
||||
ref_base(ref_base const &src)
|
||||
: Instance(src.Instance) {
|
||||
}
|
||||
|
||||
// comparison
|
||||
bool operator==(ref_base const &op2) const {
|
||||
return Instance == op2.Instance;
|
||||
}
|
||||
|
||||
// smart pointer nitty-gritty
|
||||
T &operator*() const {
|
||||
return *Instance;
|
||||
}
|
||||
T *operator->() const {
|
||||
return Instance;
|
||||
}
|
||||
T *operator+(TIndex index) const {
|
||||
return Instance + index;
|
||||
}
|
||||
T &operator[](TIndex index) const {
|
||||
return Instance[index];
|
||||
}
|
||||
|
||||
// methods
|
||||
T *get() const {
|
||||
return Instance;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T,class T_Managed = T>
|
||||
class ref;
|
||||
template<class T,class T_Managed = T>
|
||||
class no_free_ref;
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T_Managed>
|
||||
class reference_manager_keeper {
|
||||
public:
|
||||
// *** FIXME should be private, but cannot be
|
||||
// (partial specializations cannot be declared friends)
|
||||
static reference_manager<T_Managed> Manager;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
An object that acts like a reference-counted pointer to an object.
|
||||
The corresponding reference_manager is identified implicitly through
|
||||
static references.
|
||||
|
||||
Example:
|
||||
<code>
|
||||
IXLIB_GARBAGE_DECLARE_MANAGER(int)
|
||||
|
||||
int main() {
|
||||
ref<int> my_int = new int(5);
|
||||
*my_int = 17;
|
||||
ref<int> another_int = my_int;
|
||||
*another_int = 12;
|
||||
|
||||
*my_int == 12; // true
|
||||
}
|
||||
</code>
|
||||
*/
|
||||
template<class T,class T_Managed>
|
||||
class ref : public ref_base<T> {
|
||||
public:
|
||||
// we have to have an explicit copy constructor, otherwise the
|
||||
// compiler generates one, which is *ahem* - fatal
|
||||
ref(ref const &src)
|
||||
: ref_base<T>(src) {
|
||||
reference_manager_keeper<T_Managed>::Manager.addReference(Instance);
|
||||
}
|
||||
template<class T2>
|
||||
ref(ref<T2,T_Managed> const &src)
|
||||
: ref_base<T>(src.get()) {
|
||||
reference_manager_keeper<T_Managed>::Manager.addReference(Instance);
|
||||
}
|
||||
template<class T2>
|
||||
ref(no_free_ref<T2,T_Managed> const &src)
|
||||
: ref_base<T>(src.get()) {
|
||||
reference_manager_keeper<T_Managed>::Manager.addReference(Instance);
|
||||
}
|
||||
ref(T *instance = NULL)
|
||||
: ref_base<T>(instance) {
|
||||
reference_manager_keeper<T_Managed>::Manager.addReference(Instance);
|
||||
}
|
||||
~ref() {
|
||||
reference_manager_keeper<T_Managed>::Manager.freeReference(Instance);
|
||||
}
|
||||
|
||||
ref &operator=(ref const &src) {
|
||||
set(src.get());
|
||||
return *this;
|
||||
}
|
||||
ref &operator=(T *ptr) {
|
||||
set(ptr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// methods
|
||||
void release() {
|
||||
reference_manager_keeper<T_Managed>::Manager.freeReference(Instance);
|
||||
Instance = NULL;
|
||||
}
|
||||
void set(T *instance) {
|
||||
if (instance == Instance) return;
|
||||
|
||||
reference_manager_keeper<T_Managed>::Manager.freeReference(Instance);
|
||||
Instance = instance;
|
||||
reference_manager_keeper<T_Managed>::Manager.addReference(Instance);
|
||||
}
|
||||
T *releaseFromGCArena() {
|
||||
T *oldinst = Instance;
|
||||
reference_manager_keeper<T_Managed>::Manager.forgetReference(Instance);
|
||||
Instance = NULL;
|
||||
return oldinst;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
An object that acts like a reference-counted pointer to an object.
|
||||
However, the referenced object is not freed if the no_free_ref
|
||||
is the last reference to the object to go out of scope.
|
||||
|
||||
This is useful to pass objects allocated e.g. on the stack along
|
||||
inside ref's, while making sure they aren't freed.
|
||||
(which would most probably lead to disaster)
|
||||
|
||||
no_free_ref's are mostly a hack, but there are situations where you cannot
|
||||
avoid them. But even so, you should try not to use them where possible.
|
||||
|
||||
The corresponding reference_manager is identified implicitly through
|
||||
static references.
|
||||
*/
|
||||
template<class T,class T_Managed>
|
||||
class no_free_ref : public ref_base<T>{
|
||||
public:
|
||||
// we have to have an explicit copy constructor, otherwise the
|
||||
// compiler generates one, which is *ahem* - fatal
|
||||
no_free_ref(no_free_ref const &src)
|
||||
: ref_base<T>(src) {
|
||||
reference_manager_keeper<T_Managed>::Manager.addNoFreeReference(Instance);
|
||||
}
|
||||
template<class T2>
|
||||
no_free_ref(ref<T2,T_Managed> const &src)
|
||||
: ref_base<T>(src.get()) {
|
||||
reference_manager_keeper<T_Managed>::Manager.addNoFreeReference(Instance);
|
||||
}
|
||||
template<class T2>
|
||||
no_free_ref(no_free_ref<T2,T_Managed> const &src)
|
||||
: ref_base<T>(src.get()) {
|
||||
reference_manager_keeper<T_Managed>::Manager.addNoFreeReference(Instance);
|
||||
}
|
||||
no_free_ref(T *instance = NULL)
|
||||
: ref_base<T>(instance) {
|
||||
reference_manager_keeper<T_Managed>::Manager.addNoFreeReference(Instance);
|
||||
}
|
||||
~no_free_ref() {
|
||||
reference_manager_keeper<T_Managed>::Manager.removeNoFreeReference(Instance);
|
||||
}
|
||||
|
||||
// assignment
|
||||
no_free_ref &operator=(no_free_ref const &src) {
|
||||
set(src.get());
|
||||
return *this;
|
||||
}
|
||||
no_free_ref &operator=(T *ptr) {
|
||||
set(ptr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// methods
|
||||
void release() {
|
||||
reference_manager_keeper<T_Managed>::Manager.removeNoFreeReference(Instance);
|
||||
Instance = NULL;
|
||||
}
|
||||
void set(T *instance) {
|
||||
if (instance == Instance) return;
|
||||
|
||||
reference_manager_keeper<T_Managed>::Manager.removeNoFreeReference(Instance);
|
||||
Instance = instance;
|
||||
reference_manager_keeper<T_Managed>::Manager.addNoFreeReference(Instance);
|
||||
}
|
||||
T *releaseFromGCArena() {
|
||||
T *oldinst = Instance;
|
||||
reference_manager_keeper<T_Managed>::Manager.forgetReference(Instance);
|
||||
Instance = NULL;
|
||||
return oldinst;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
An object that acts like a reference-counted pointer to an object.
|
||||
The corresponding reference_manager is identified explicitly.
|
||||
*/
|
||||
template<class T>
|
||||
class dynamic_ref : public ref_base<T> {
|
||||
protected:
|
||||
reference_manager<T> &Manager;
|
||||
|
||||
public:
|
||||
dynamic_ref(dynamic_ref const &src)
|
||||
: ref_base<T>(src),Manager(src.Manager) {
|
||||
Manager.addReference(Instance);
|
||||
}
|
||||
dynamic_ref(reference_manager<T> &mgr,T *instance = NULL)
|
||||
: ref_base<T>(instance),Manager(mgr) {
|
||||
Manager.addReference(Instance);
|
||||
}
|
||||
~dynamic_ref() {
|
||||
Manager.freeReference(Instance);
|
||||
}
|
||||
|
||||
// assignment
|
||||
dynamic_ref &operator=(dynamic_ref const &src) {
|
||||
set(src.get());
|
||||
return *this;
|
||||
}
|
||||
dynamic_ref &operator=(T *ptr) {
|
||||
set(ptr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// methods
|
||||
void release() {
|
||||
Manager.freeReference(Instance);
|
||||
Instance = NULL;
|
||||
}
|
||||
void set(T *instance) {
|
||||
if (instance == Instance) return;
|
||||
|
||||
Manager.freeReference(Instance);
|
||||
Instance = instance;
|
||||
Manager.addReference(Instance);
|
||||
}
|
||||
T *releaseFromGCArena() {
|
||||
T *oldinst = Instance;
|
||||
Manager.forgetReference(Instance);
|
||||
Instance = NULL;
|
||||
return oldinst;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
An object that acts like a reference-counted pointer to an object.
|
||||
However, the referenced object is not freed if the no_free_ref
|
||||
is the last reference to the object to go out of scope.
|
||||
|
||||
This is useful to pass objects allocated e.g. on the stack along
|
||||
inside ref's, while making sure they aren't freed.
|
||||
(which would most probably lead to disaster)
|
||||
|
||||
no_free_ref's are mostly a hack, but there are situations where you cannot
|
||||
avoid them. But even so, you should try not to use them where possible.
|
||||
|
||||
The corresponding reference_manager is identified explicitly.
|
||||
*/
|
||||
template<class T>
|
||||
class no_free_dynamic_ref : public ref_base<T> {
|
||||
protected:
|
||||
reference_manager<T> &Manager;
|
||||
|
||||
public:
|
||||
no_free_dynamic_ref(no_free_dynamic_ref const &src)
|
||||
: ref_base<T>(src),Manager(src.Manager) {
|
||||
Manager.addNoFreeReference(Instance);
|
||||
}
|
||||
no_free_dynamic_ref(reference_manager<T> &mgr,T *instance = NULL)
|
||||
: ref_base<T>(instance),Manager(mgr) {
|
||||
Manager.addNoFreeReference(Instance);
|
||||
}
|
||||
~no_free_dynamic_ref() {
|
||||
Manager.removeNoFreeReference(Instance);
|
||||
}
|
||||
|
||||
// assignment
|
||||
no_free_dynamic_ref &operator=(no_free_dynamic_ref const &src) {
|
||||
set(src.get());
|
||||
return *this;
|
||||
}
|
||||
no_free_dynamic_ref &operator=(T *ptr) {
|
||||
set(ptr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// methods
|
||||
void release() {
|
||||
Manager.removeNoFreeReference(Instance);
|
||||
Instance = NULL;
|
||||
}
|
||||
void set(T *instance) {
|
||||
if (instance == Instance) return;
|
||||
|
||||
Manager.removeNoFreeReference(Instance);
|
||||
Instance = instance;
|
||||
Manager.addNoFreeReference(Instance);
|
||||
}
|
||||
T *releaseFromGCArena() {
|
||||
T *oldinst = Instance;
|
||||
Manager.forgetReference(Instance);
|
||||
Instance = NULL;
|
||||
return oldinst;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T,class Deallocator>
|
||||
class reference_manager {
|
||||
protected:
|
||||
|
||||
struct instance_data {
|
||||
T const *Instance;
|
||||
TSize ReferenceCount,NoFreeReferenceCount;
|
||||
instance_data *Next,*Previous;
|
||||
};
|
||||
|
||||
class pointer_hash {
|
||||
public:
|
||||
};
|
||||
|
||||
typedef unsigned hash_value;
|
||||
static hash_value const HASH_MAX = 0x3ff;
|
||||
|
||||
instance_data *Instances[HASH_MAX+1];
|
||||
Deallocator Dealloc;
|
||||
|
||||
public:
|
||||
reference_manager(Deallocator const &dealloc = Deallocator())
|
||||
: Dealloc(dealloc) {
|
||||
for (hash_value hv = 0;hv <= HASH_MAX;hv++)
|
||||
Instances[hv] = NULL;
|
||||
}
|
||||
|
||||
// *** FIXME should be
|
||||
// protected:
|
||||
// but cannot because partial specializations cannot be declared friends
|
||||
void addReference(T const *instance) {
|
||||
if (!instance) return;
|
||||
instance_data *data = getHashEntry(instance);
|
||||
data->ReferenceCount++;
|
||||
}
|
||||
void freeReference(T const *instance) {
|
||||
if (!instance) return;
|
||||
instance_data *data = getHashEntry(instance);
|
||||
if (--data->ReferenceCount == 0 && data->NoFreeReferenceCount == 0) {
|
||||
removeHashEntry(data);
|
||||
Dealloc(instance);
|
||||
}
|
||||
}
|
||||
void addNoFreeReference(T const *instance) {
|
||||
if (!instance) return;
|
||||
instance_data *data = getHashEntry(instance);
|
||||
data->NoFreeReferenceCount++;
|
||||
}
|
||||
void removeNoFreeReference(T const *instance) {
|
||||
if (!instance) return;
|
||||
instance_data *data = getHashEntry(instance);
|
||||
if (--data->NoFreeReferenceCount == 0) {
|
||||
if (data->ReferenceCount != 0)
|
||||
EXGEN_THROW(EC_REMAININGREF)
|
||||
removeHashEntry(data);
|
||||
}
|
||||
}
|
||||
void forgetReference(T const *instance) {
|
||||
if (!instance) return;
|
||||
instance_data *data = getHashEntry(instance);
|
||||
if (data->ReferenceCount != 1)
|
||||
EXGEN_THROW(EC_CANNOTREMOVEFROMGC)
|
||||
removeHashEntry(data);
|
||||
}
|
||||
|
||||
private:
|
||||
hash_value hash(T const *ptr) const {
|
||||
unsigned u = reinterpret_cast<unsigned>(ptr);
|
||||
return (u ^ (u >> 8) ^ (u >> 16) ^ (u >> 24)) & HASH_MAX;
|
||||
}
|
||||
instance_data *getHashEntry(T const *instance) {
|
||||
instance_data *data = Instances[hash(instance)];
|
||||
while (data) {
|
||||
if (data->Instance == instance) return data;
|
||||
data = data->Next;
|
||||
}
|
||||
|
||||
// not found, add new at front
|
||||
instance_data *link = Instances[hash(instance)];
|
||||
data = new instance_data;
|
||||
|
||||
data->Instance = instance;
|
||||
data->ReferenceCount = 0;
|
||||
data->NoFreeReferenceCount = 0;
|
||||
data->Previous = NULL;
|
||||
data->Next = link;
|
||||
if (link) link->Previous = data;
|
||||
Instances[hash(instance)] = data;
|
||||
return data;
|
||||
}
|
||||
void removeHashEntry(instance_data *data) {
|
||||
instance_data *prev = data->Previous;
|
||||
if (prev) {
|
||||
prev->Next = data->Next;
|
||||
if (data->Next) data->Next->Previous = prev;
|
||||
delete data;
|
||||
}
|
||||
else {
|
||||
Instances[hash(data->Instance)] = data->Next;
|
||||
if (data->Next) data->Next->Previous = NULL;
|
||||
delete data;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#define IXLIB_GARBAGE_DECLARE_MANAGER(TYPE) \
|
||||
ixion::reference_manager<TYPE> ixion::reference_manager_keeper<TYPE>::Manager;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
23
simgear/interpreter/ixlib_i18n.hh
Normal file
23
simgear/interpreter/ixlib_i18n.hh
Normal file
@@ -0,0 +1,23 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : ixlib internationalization wrapper
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 2001 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef IXLIB_I18N
|
||||
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <libintl.h>
|
||||
#define _(String) gettext(String)
|
||||
#define N_(String) (String)
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
380
simgear/interpreter/ixlib_javascript.hh
Normal file
380
simgear/interpreter/ixlib_javascript.hh
Normal file
@@ -0,0 +1,380 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Javascript interpreter
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 2000 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef IXLIB_JAVASCRIPT
|
||||
#define IXLIB_JAVASCRIPT
|
||||
|
||||
|
||||
|
||||
|
||||
#include <vector>
|
||||
#if __GNUC__ < 3
|
||||
#include <hash_map>
|
||||
#else
|
||||
#include <ext/hash_map>
|
||||
#endif
|
||||
#include <ixlib_string.hh>
|
||||
#include <ixlib_exbase.hh>
|
||||
#include <ixlib_garbage.hh>
|
||||
#include <ixlib_scanner.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
// Error codes ----------------------------------------------------------------
|
||||
#define ECJS_UNTERMINATED_COMMENT 0
|
||||
#define ECJS_CANNOT_CONVERT 1
|
||||
#define ECJS_INVALID_OPERATION 2
|
||||
#define ECJS_UNEXPECTED 3
|
||||
#define ECJS_UNEXPECTED_EOF 4
|
||||
#define ECJS_CANNOT_MODIFY_RVALUE 5
|
||||
#define ECJS_UNKNOWN_IDENTIFIER 6
|
||||
#define ECJS_UNKNOWN_OPERATOR 7
|
||||
#define ECJS_INVALID_NON_LOCAL_EXIT 8
|
||||
#define ECJS_INVALID_NUMBER_OF_ARGUMENTS 9
|
||||
#define ECJS_INVALID_TOKEN 10
|
||||
#define ECJS_CANNOT_REDECLARE 11
|
||||
#define ECJS_DOUBLE_CONSTRUCTION 12
|
||||
#define ECJS_NO_SUPERCLASS 13
|
||||
#define ECJS_DIVISION_BY_ZERO 14
|
||||
|
||||
|
||||
|
||||
|
||||
// helpful macros -------------------------------------------------------------
|
||||
#define IXLIB_JS_ASSERT_PARAMETERS(NAME,ARGMIN,ARGMAX) \
|
||||
if (parameters.size() < ARGMIN || parameters.size() > ARGMAX) \
|
||||
EXJS_THROWINFO(ECJS_INVALID_NUMBER_OF_ARGUMENTS,NAME)
|
||||
|
||||
#define IXLIB_JS_IF_METHOD(NAME,ARGMIN,ARGMAX) \
|
||||
if (identifier == NAME) \
|
||||
if (parameters.size() < ARGMIN || parameters.size() > ARGMAX) \
|
||||
EXJS_THROWINFO(ECJS_INVALID_NUMBER_OF_ARGUMENTS,NAME) \
|
||||
else
|
||||
|
||||
#define IXLIB_JS_DECLARE_FUNCTION(NAME) \
|
||||
namespace { \
|
||||
class NAME : public value { \
|
||||
public: \
|
||||
value_type getType() const { \
|
||||
return VT_FUNCTION; \
|
||||
} \
|
||||
ixion::ref<ixion::javascript::value> call(parameter_list const ¶meters); \
|
||||
}; \
|
||||
} \
|
||||
ixion::ref<ixion::javascript::value> NAME::call(parameter_list const ¶meters)
|
||||
|
||||
#define IXLIB_JS_CONVERT_PARAMETERS_0 \
|
||||
|
||||
|
||||
|
||||
|
||||
// Exception throw macros -----------------------------------------------------
|
||||
#define EXJS_THROW(CODE)\
|
||||
EX_THROW(javascript,CODE)
|
||||
#define EXJS_THROWINFO(CODE,INFO)\
|
||||
EX_THROWINFO(javascript,CODE,INFO)
|
||||
#define EXJS_THROW_NO_LOCATION(CODE)\
|
||||
EX_THROW(no_location_javascript,CODE)
|
||||
#define EXJS_THROWINFO_NO_LOCATION(CODE,INFO)\
|
||||
EX_THROWINFO(no_location_javascript,CODE,INFO)
|
||||
#define EXJS_THROWINFOLOCATION(CODE,INFO,LOCATION)\
|
||||
throw ixion::javascript_exception(CODE,LOCATION,INFO,__FILE__,__LINE__);
|
||||
#define EXJS_THROWINFOTOKEN(CODE,INFO,TOKEN)\
|
||||
EXJS_THROWINFOLOCATION(CODE,INFO,code_location(TOKEN))
|
||||
#define EXJS_THROWINFOEXPRESSION(CODE,INFO,EXPR)\
|
||||
EXJS_THROWINFOLOCATION(CODE,INFO,(EXPR).getCodeLocation())
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace ixion {
|
||||
namespace javascript {
|
||||
struct code_location;
|
||||
}
|
||||
|
||||
// exceptions ---------------------------------------------------------------
|
||||
struct no_location_javascript_exception : public base_exception {
|
||||
no_location_javascript_exception(TErrorCode error,char const *info = NULL,char *module = NULL,
|
||||
TIndex line = 0)
|
||||
: base_exception(error,info,module,line,"JS") {
|
||||
}
|
||||
virtual char *getText() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
struct javascript_exception : public base_exception {
|
||||
javascript_exception(TErrorCode error,char const *info = NULL,char *module = NULL,
|
||||
TIndex line = 0)
|
||||
: base_exception(error,info,module,line,"JS") {
|
||||
}
|
||||
javascript_exception(TErrorCode error,javascript::code_location const &loc,char const *info = 0,char *module = NULL,
|
||||
TIndex line = 0);
|
||||
javascript_exception(no_location_javascript_exception const &half_ex,javascript::code_location const &loc);
|
||||
virtual char *getText() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// javascript ---------------------------------------------------------------
|
||||
/**
|
||||
This code tries to be an implementation of ECMAScript 4, as available at
|
||||
http://www.mozilla.org/js/language/
|
||||
Note that ES4 is still in the process of standardization.
|
||||
|
||||
It is meant to behave like an ES4 interpreter in strict mode, none
|
||||
of the backward-compatible braindead-isms like newline semicolon
|
||||
insertion and other stuff will ever be implemented.
|
||||
|
||||
This is the list of its shortcomings:
|
||||
<ul>
|
||||
<li> exceptions
|
||||
<li> namespaces,packages
|
||||
<li> constness
|
||||
<li> Number/String constructor and class methods
|
||||
<li> real regexp's
|
||||
<li> the methods listed in FIXME's (js_library.cc js_value.cc)
|
||||
<li> cannot cross-assign predefined methods [won't be]
|
||||
<li> Grammatical semicolon insertion [won't be]
|
||||
<li> type declaration [won't be]
|
||||
</ul>
|
||||
|
||||
Be advised that a javascript value that is passed to you through the
|
||||
interpreter, e.g. as a call parameter, may not be of the type that
|
||||
you expect. For example, in "var x = 4; f(x);", what comes in as
|
||||
the parameter x into f is a wrapper value that adds assign()ability
|
||||
to a value that is wrapped inside. The advised solution to get the
|
||||
object that you expect is to call eliminateWrappers() on the potentially
|
||||
wrapped value.
|
||||
*/
|
||||
namespace javascript {
|
||||
class value;
|
||||
class list_scope;
|
||||
struct context {
|
||||
ref<list_scope,value> DeclarationScope;
|
||||
ref<value> LookupScope;
|
||||
|
||||
context(ref<list_scope,value> scope);
|
||||
context(ref<value> scope);
|
||||
context(ref<list_scope,value> decl_scope,ref<value> lookup_scope);
|
||||
};
|
||||
|
||||
class expression;
|
||||
|
||||
class value {
|
||||
public:
|
||||
enum operator_id {
|
||||
// unary, modifying
|
||||
OP_PRE_INCREMENT,OP_POST_INCREMENT,
|
||||
OP_PRE_DECREMENT,OP_POST_DECREMENT,
|
||||
// unary, non-modifying
|
||||
OP_UNARY_PLUS,OP_UNARY_MINUS,
|
||||
OP_LOG_NOT,OP_BIN_NOT,
|
||||
// binary, modifying
|
||||
OP_PLUS_ASSIGN,OP_MINUS_ASSIGN,
|
||||
OP_MUTLIPLY_ASSIGN,OP_DIVIDE_ASSIGN,OP_MODULO_ASSIGN,
|
||||
OP_BIT_AND_ASSIGN,OP_BIT_OR_ASSIGN,OP_BIT_XOR_ASSIGN,
|
||||
OP_LEFT_SHIFT_ASSIGN,OP_RIGHT_SHIFT_ASSIGN,
|
||||
// binary, non-modifying
|
||||
OP_PLUS,OP_MINUS,
|
||||
OP_MULTIPLY,OP_DIVIDE,OP_MODULO,
|
||||
OP_BIT_AND,OP_BIT_OR,OP_BIT_XOR,
|
||||
OP_LEFT_SHIFT,OP_RIGHT_SHIFT,
|
||||
OP_LOGICAL_OR,OP_LOGICAL_AND,
|
||||
OP_EQUAL,OP_NOT_EQUAL,OP_IDENTICAL,OP_NOT_IDENTICAL,
|
||||
OP_LESS_EQUAL,OP_GREATER_EQUAL,OP_LESS,OP_GREATER,
|
||||
// special
|
||||
OP_ASSIGN,
|
||||
};
|
||||
|
||||
enum value_type {
|
||||
VT_UNDEFINED,VT_NULL,
|
||||
VT_INTEGER,VT_FLOATING_POINT,VT_STRING,
|
||||
VT_FUNCTION,VT_OBJECT,VT_BUILTIN,VT_HOST,
|
||||
VT_SCOPE,VT_BOUND_METHOD,VT_TYPE
|
||||
};
|
||||
typedef std::vector<ref<value> > parameter_list;
|
||||
|
||||
virtual ~value() {
|
||||
}
|
||||
|
||||
virtual value_type getType() const = 0;
|
||||
virtual std::string toString() const;
|
||||
virtual int toInt() const;
|
||||
virtual double toFloat() const;
|
||||
virtual bool toBoolean() const;
|
||||
// toString is meant as a type conversion, whereas stringify
|
||||
// is for debuggers and the like
|
||||
virtual std::string stringify() const;
|
||||
|
||||
virtual ref<value> eliminateWrappers();
|
||||
virtual ref<value> duplicate();
|
||||
|
||||
virtual ref<value> lookup(std::string const &identifier);
|
||||
virtual ref<value> subscript(value const &index);
|
||||
virtual ref<value> call(parameter_list const ¶meters);
|
||||
virtual ref<value> callAsMethod(ref<value> instance,parameter_list const ¶meters);
|
||||
virtual ref<value> construct(parameter_list const ¶meters);
|
||||
virtual ref<value> assign(ref<value> op2);
|
||||
|
||||
virtual ref<value> operatorUnary(operator_id op) const;
|
||||
virtual ref<value> operatorBinary(operator_id op,ref<value> op2) const;
|
||||
virtual ref<value> operatorBinaryShortcut(operator_id op,expression const &op2,context const &ctx) const;
|
||||
virtual ref<value> operatorUnaryModifying(operator_id op);
|
||||
virtual ref<value> operatorBinaryModifying(operator_id op,ref<value> op2);
|
||||
|
||||
static operator_id token2operator(scanner::token const &token,bool unary = false,bool prefix = false);
|
||||
static std::string operator2string(operator_id op);
|
||||
static std::string valueType2string(value_type vt);
|
||||
};
|
||||
|
||||
// obviously, any value can have methods, but with this neat little
|
||||
// interface implementing methods has just become easier.
|
||||
class value_with_methods : public value {
|
||||
class bound_method : public value {
|
||||
std::string Identifier;
|
||||
ref<value_with_methods,value> Parent;
|
||||
|
||||
public:
|
||||
bound_method(std::string const &identifier,ref<value_with_methods,value> parent);
|
||||
|
||||
value_type getType() const {
|
||||
return VT_BOUND_METHOD;
|
||||
}
|
||||
|
||||
ref<value> duplicate();
|
||||
ref<value> call(parameter_list const ¶meters);
|
||||
};
|
||||
|
||||
public:
|
||||
ref<value> lookup(std::string const &identifier);
|
||||
virtual ref<value> callMethod(std::string const &identifier,parameter_list const ¶meters) = 0;
|
||||
};
|
||||
|
||||
// obviously, any value can already represent a scope ("lookup" member!).
|
||||
// the list_scope class is an explicit scope that can "swallow"
|
||||
// (=unite with) other scopes and keeps a list of registered members
|
||||
class list_scope : public value {
|
||||
protected:
|
||||
typedef std::hash_map<std::string,ref<value>,string_hash> member_map;
|
||||
typedef std::vector<ref<value> > swallowed_list;
|
||||
|
||||
member_map MemberMap;
|
||||
swallowed_list SwallowedList;
|
||||
|
||||
public:
|
||||
value_type getType() const {
|
||||
return VT_SCOPE;
|
||||
}
|
||||
|
||||
ref<value> lookup(std::string const &identifier);
|
||||
|
||||
void unite(ref<value> scope);
|
||||
void separate(ref<value> scope);
|
||||
void clearScopes();
|
||||
|
||||
bool hasMember(std::string const &name) const;
|
||||
void addMember(std::string const &name,ref<value> member);
|
||||
void removeMember(std::string const &name);
|
||||
void clearMembers();
|
||||
|
||||
void clear();
|
||||
};
|
||||
|
||||
class js_array : public value_with_methods {
|
||||
private:
|
||||
typedef value_with_methods super;
|
||||
|
||||
protected:
|
||||
typedef std::vector<ref<value> > value_array;
|
||||
value_array Array;
|
||||
|
||||
public:
|
||||
js_array() {
|
||||
}
|
||||
js_array(TSize size);
|
||||
js_array(value_array::const_iterator first,value_array::const_iterator last)
|
||||
: Array(first,last) {
|
||||
}
|
||||
js_array(js_array const &src)
|
||||
: Array(src.Array) {
|
||||
}
|
||||
|
||||
value_type getType() const {
|
||||
return VT_BUILTIN;
|
||||
}
|
||||
|
||||
std::string stringify() const;
|
||||
|
||||
ref<value> duplicate();
|
||||
|
||||
ref<value> lookup(std::string const &identifier);
|
||||
ref<value> subscript(value const &index);
|
||||
ref<value> callMethod(std::string const &identifier,parameter_list const ¶meters);
|
||||
|
||||
TSize size() const {
|
||||
return Array.size();
|
||||
}
|
||||
void resize(TSize size);
|
||||
ref<value> &operator[](TIndex idx);
|
||||
void push_back(ref<value> val);
|
||||
};
|
||||
|
||||
class expression;
|
||||
|
||||
ref<value> makeUndefined();
|
||||
ref<value> makeNull();
|
||||
ref<value> makeValue(signed long val);
|
||||
ref<value> makeConstant(signed long val);
|
||||
ref<value> makeValue(signed int val);
|
||||
ref<value> makeConstant(signed int val);
|
||||
ref<value> makeValue(unsigned long val);
|
||||
ref<value> makeConstant(unsigned long val);
|
||||
ref<value> makeValue(unsigned int val);
|
||||
ref<value> makeConstant(unsigned int val);
|
||||
ref<value> makeValue(double val);
|
||||
ref<value> makeConstant(double val);
|
||||
ref<value> makeValue(std::string const &val);
|
||||
ref<value> makeConstant(std::string const &val);
|
||||
ref<value> makeArray(TSize size = 0);
|
||||
ref<value> makeLValue(ref<value> target);
|
||||
ref<value> wrapConstant(ref<value> val);
|
||||
|
||||
class interpreter {
|
||||
public:
|
||||
ref<list_scope,value> RootScope;
|
||||
|
||||
public:
|
||||
interpreter();
|
||||
~interpreter();
|
||||
|
||||
ref<expression> parse(std::string const &str);
|
||||
ref<expression> parse(std::istream &istr);
|
||||
ref<value> execute(std::string const &str);
|
||||
ref<value> execute(std::istream &istr);
|
||||
ref<value> execute(ref<expression> expr);
|
||||
|
||||
private:
|
||||
ref<value> evaluateCatchExits(ref<expression> expr);
|
||||
};
|
||||
|
||||
void addGlobal(interpreter &ip);
|
||||
void addMath(interpreter &ip);
|
||||
void addStandardLibrary(interpreter &ip);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
760
simgear/interpreter/ixlib_js_internals.hh
Normal file
760
simgear/interpreter/ixlib_js_internals.hh
Normal file
@@ -0,0 +1,760 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Javascript interpreter
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 2000 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef IXLIB_JS_INTERNALS
|
||||
#define IXLIB_JS_INTERNALS
|
||||
|
||||
|
||||
|
||||
|
||||
#include <ixlib_javascript.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace ixion {
|
||||
namespace javascript {
|
||||
struct code_location {
|
||||
TIndex Line;
|
||||
|
||||
code_location(scanner::token &tok);
|
||||
explicit code_location(TIndex line);
|
||||
string stringify() const;
|
||||
};
|
||||
|
||||
struct return_exception {
|
||||
ref<value> ReturnValue;
|
||||
code_location Location;
|
||||
|
||||
return_exception(ref<value> retval,code_location const &loc)
|
||||
: ReturnValue(retval),Location(loc) {
|
||||
}
|
||||
};
|
||||
|
||||
struct break_exception {
|
||||
bool HasLabel;
|
||||
string Label;
|
||||
code_location Location;
|
||||
|
||||
break_exception(bool has_label,string const &label,code_location const &loc)
|
||||
: HasLabel(has_label),Label(label),Location(loc) {
|
||||
}
|
||||
};
|
||||
|
||||
struct continue_exception {
|
||||
bool HasLabel;
|
||||
string Label;
|
||||
code_location Location;
|
||||
|
||||
continue_exception(bool has_label,string const &label,code_location const &loc)
|
||||
: HasLabel(has_label),Label(label),Location(loc) {
|
||||
}
|
||||
};
|
||||
|
||||
// values -----------------------------------------------------------------
|
||||
class null : public value {
|
||||
private:
|
||||
typedef value super;
|
||||
|
||||
public:
|
||||
value_type getType() const;
|
||||
bool toBoolean() const;
|
||||
|
||||
ref<value> duplicate();
|
||||
};
|
||||
|
||||
class const_floating_point : public value_with_methods {
|
||||
private:
|
||||
typedef value_with_methods super;
|
||||
|
||||
protected:
|
||||
double Value;
|
||||
|
||||
public:
|
||||
const_floating_point(double value);
|
||||
|
||||
value_type getType() const;
|
||||
int toInt() const;
|
||||
double toFloat() const;
|
||||
bool toBoolean() const;
|
||||
string toString() const;
|
||||
|
||||
ref<value> duplicate();
|
||||
|
||||
ref<value> callMethod(string const &identifier,parameter_list const ¶meters);
|
||||
|
||||
ref<value> operatorUnary(operator_id op) const;
|
||||
ref<value> operatorBinary(operator_id op,ref<value> op2) const;
|
||||
};
|
||||
|
||||
class floating_point : public const_floating_point {
|
||||
private:
|
||||
typedef const_floating_point super;
|
||||
|
||||
public:
|
||||
floating_point(double value);
|
||||
|
||||
ref<value> operatorUnaryModifying(operator_id op);
|
||||
ref<value> operatorBinaryModifying(operator_id op,ref<value> op2);
|
||||
};
|
||||
|
||||
class const_integer : public value_with_methods {
|
||||
private:
|
||||
typedef value_with_methods super;
|
||||
|
||||
protected:
|
||||
long Value;
|
||||
|
||||
public:
|
||||
const_integer(long value);
|
||||
|
||||
value_type getType() const;
|
||||
int toInt() const;
|
||||
double toFloat() const;
|
||||
bool toBoolean() const;
|
||||
string toString() const;
|
||||
|
||||
ref<value> duplicate();
|
||||
|
||||
ref<value> callMethod(string const &identifier,parameter_list const ¶meters);
|
||||
|
||||
ref<value> operatorUnary(operator_id op) const;
|
||||
ref<value> operatorBinary(operator_id op,ref<value> op2) const;
|
||||
};
|
||||
|
||||
class integer : public const_integer {
|
||||
private:
|
||||
typedef const_integer super;
|
||||
|
||||
public:
|
||||
integer(long value);
|
||||
|
||||
ref<value> operatorUnaryModifying(operator_id op);
|
||||
ref<value> operatorBinaryModifying(operator_id op,ref<value> op2);
|
||||
};
|
||||
|
||||
class js_string : public value_with_methods {
|
||||
private:
|
||||
typedef value_with_methods super;
|
||||
|
||||
protected:
|
||||
string Value;
|
||||
|
||||
public:
|
||||
js_string(string const &value);
|
||||
|
||||
value_type getType() const;
|
||||
string toString() const;
|
||||
bool toBoolean() const;
|
||||
string stringify() const;
|
||||
|
||||
ref<value> duplicate();
|
||||
|
||||
ref<value> lookup(string const &identifier);
|
||||
ref<value> callMethod(string const &identifier,parameter_list const ¶meters);
|
||||
|
||||
ref<value> operatorBinary(operator_id op,ref<value> op2) const;
|
||||
ref<value> operatorBinaryModifying(operator_id op,ref<value> op2);
|
||||
};
|
||||
|
||||
class lvalue : public value {
|
||||
protected:
|
||||
ref<value> Reference;
|
||||
|
||||
public:
|
||||
lvalue(ref<value> ref);
|
||||
|
||||
value_type getType() const;
|
||||
string toString() const;
|
||||
int toInt() const;
|
||||
double toFloat() const;
|
||||
bool toBoolean() const;
|
||||
string stringify() const;
|
||||
|
||||
ref<value> eliminateWrappers();
|
||||
ref<value> duplicate();
|
||||
|
||||
ref<value> lookup(string const &identifier);
|
||||
ref<value> subscript(value const &index);
|
||||
ref<value> call(parameter_list const ¶meters);
|
||||
ref<value> callAsMethod(ref<value> instance,parameter_list const ¶meters);
|
||||
ref<value> construct(parameter_list const ¶meters);
|
||||
ref<value> assign(ref<value> op2);
|
||||
|
||||
ref<value> operatorUnary(operator_id op) const;
|
||||
ref<value> operatorBinary(operator_id op,ref<value> op2) const;
|
||||
ref<value> operatorBinaryShortcut(operator_id op,expression const &op2,context const &ctx) const;
|
||||
ref<value> operatorUnaryModifying(operator_id op);
|
||||
ref<value> operatorBinaryModifying(operator_id op,ref<value> op2);
|
||||
};
|
||||
|
||||
class constant_wrapper : public value {
|
||||
protected:
|
||||
ref<value> Constant;
|
||||
|
||||
public:
|
||||
constant_wrapper(ref<value> val);
|
||||
|
||||
value_type getType() const;
|
||||
string toString() const;
|
||||
int toInt() const;
|
||||
double toFloat() const;
|
||||
bool toBoolean() const;
|
||||
string stringify() const;
|
||||
|
||||
ref<value> eliminateWrappers();
|
||||
ref<value> duplicate();
|
||||
|
||||
ref<value> lookup(string const &identifier);
|
||||
ref<value> subscript(value const &index);
|
||||
ref<value> call(parameter_list const ¶meters) const;
|
||||
ref<value> callAsMethod(ref<value> instance,parameter_list const ¶meters);
|
||||
ref<value> construct(parameter_list const ¶meters);
|
||||
ref<value> assign(ref<value> value);
|
||||
|
||||
ref<value> operatorUnary(operator_id op) const;
|
||||
ref<value> operatorBinary(operator_id op,ref<value> op2) const;
|
||||
ref<value> operatorBinaryShortcut(operator_id op,expression const &op2,context const &ctx) const;
|
||||
ref<value> operatorUnaryModifying(operator_id op);
|
||||
ref<value> operatorBinaryModifying(operator_id op,ref<value> op2);
|
||||
};
|
||||
|
||||
class callable_with_parameters : public value {
|
||||
public:
|
||||
typedef vector<string> parameter_name_list;
|
||||
|
||||
protected:
|
||||
parameter_name_list ParameterNameList;
|
||||
|
||||
public:
|
||||
callable_with_parameters(parameter_name_list const &pnames);
|
||||
|
||||
void addParametersTo(list_scope &scope,parameter_list const ¶meters) const;
|
||||
static ref<value> evaluateBody(expression &body,context const &ctx);
|
||||
};
|
||||
|
||||
class function : public callable_with_parameters {
|
||||
typedef callable_with_parameters super;
|
||||
ref<expression> Body;
|
||||
ref<value> LexicalScope;
|
||||
|
||||
public:
|
||||
function(parameter_name_list const &pnames,ref<expression> body,ref<value> lex_scope);
|
||||
|
||||
value_type getType() const{
|
||||
return VT_FUNCTION;
|
||||
}
|
||||
|
||||
ref<value> duplicate();
|
||||
|
||||
ref<value> call(parameter_list const ¶meters);
|
||||
};
|
||||
|
||||
class method : public callable_with_parameters {
|
||||
typedef callable_with_parameters super;
|
||||
ref<expression> Body;
|
||||
ref<value> LexicalScope;
|
||||
|
||||
public:
|
||||
method(parameter_name_list const &pnames,ref<expression> body,ref<value> lex_scope);
|
||||
|
||||
value_type getType() const{
|
||||
return VT_FUNCTION;
|
||||
}
|
||||
|
||||
ref<value> duplicate();
|
||||
|
||||
ref<value> callAsMethod(ref<value> instance,parameter_list const ¶meters);
|
||||
};
|
||||
|
||||
class constructor : public callable_with_parameters {
|
||||
typedef callable_with_parameters super;
|
||||
ref<expression> Body;
|
||||
ref<value> LexicalScope;
|
||||
|
||||
public:
|
||||
constructor(parameter_name_list const &pnames,ref<expression> body,ref<value> lex_scope);
|
||||
|
||||
value_type getType() const{
|
||||
return VT_FUNCTION;
|
||||
}
|
||||
|
||||
ref<value> duplicate();
|
||||
ref<value> callAsMethod(ref<value> instance,parameter_list const ¶meters);
|
||||
};
|
||||
|
||||
class js_class : public value {
|
||||
class super_instance_during_construction : public value {
|
||||
// this object constructs the superclass
|
||||
// a) if it is called, by calling the super constructor
|
||||
// with the aprropriate parameters
|
||||
// b) implicitly with no super constructor arguments,
|
||||
// if the super object is referenced explicitly
|
||||
|
||||
ref<value> SuperClass;
|
||||
ref<value> SuperClassInstance;
|
||||
|
||||
public:
|
||||
super_instance_during_construction(ref<value> super_class);
|
||||
|
||||
value_type getType() const {
|
||||
return VT_OBJECT;
|
||||
}
|
||||
|
||||
ref<value> call(parameter_list const ¶meters);
|
||||
ref<value> lookup(string const &identifier);
|
||||
|
||||
ref<value> getSuperClassInstance();
|
||||
};
|
||||
|
||||
typedef vector<ref<expression> > declaration_list;
|
||||
|
||||
ref<value> LexicalScope;
|
||||
ref<value> SuperClass;
|
||||
ref<value> Constructor;
|
||||
ref<value> StaticMethodScope;
|
||||
ref<value> MethodScope;
|
||||
ref<value> StaticVariableScope;
|
||||
declaration_list VariableList;
|
||||
|
||||
public:
|
||||
js_class(ref<value> lex_scope,ref<value> super_class,ref<value> constructor,
|
||||
ref<value> static_method_scope,ref<value> method_scope,
|
||||
ref<value> static_variable_scope,declaration_list const &variable_list);
|
||||
|
||||
value_type getType() const {
|
||||
return VT_TYPE;
|
||||
}
|
||||
|
||||
ref<value> duplicate();
|
||||
ref<value> lookup(string const &identifier);
|
||||
ref<value> lookupLocal(string const &identifier);
|
||||
ref<value> construct(parameter_list const ¶meters);
|
||||
};
|
||||
|
||||
class js_class_instance : public value {
|
||||
class bound_method : public value {
|
||||
ref<value> Instance;
|
||||
ref<value> Method;
|
||||
|
||||
public:
|
||||
bound_method(ref<value> instance,ref<value> method);
|
||||
|
||||
value_type getType() const {
|
||||
return VT_BOUND_METHOD;
|
||||
}
|
||||
|
||||
ref<value> call(parameter_list const ¶meters);
|
||||
};
|
||||
|
||||
ref<value> SuperClassInstance;
|
||||
ref<js_class,value> Class;
|
||||
ref<value> MethodScope;
|
||||
ref<value> VariableScope;
|
||||
|
||||
public:
|
||||
js_class_instance(ref<js_class,value> cls,ref<value> method_scope,
|
||||
ref<value> variable_scope);
|
||||
|
||||
void setSuperClassInstance(ref<value> super_class_instance);
|
||||
|
||||
value_type getType() const {
|
||||
return VT_OBJECT;
|
||||
}
|
||||
|
||||
ref<value> duplicate();
|
||||
ref<value> lookup(string const &identifier);
|
||||
};
|
||||
|
||||
class js_array_constructor : public value {
|
||||
public:
|
||||
value_type getType() const {
|
||||
return VT_TYPE;
|
||||
}
|
||||
|
||||
ref<value> duplicate();
|
||||
ref<value> construct(parameter_list const ¶meters);
|
||||
};
|
||||
|
||||
// expressions ----------------------------------------------------------
|
||||
class expression {
|
||||
code_location Location;
|
||||
|
||||
public:
|
||||
expression(code_location const &loc);
|
||||
virtual ~expression();
|
||||
virtual ref<value> evaluate(context const &ctx) const = 0;
|
||||
|
||||
code_location const &getCodeLocation() const {
|
||||
return Location;
|
||||
}
|
||||
};
|
||||
|
||||
class constant : public expression {
|
||||
ref<value> Value;
|
||||
public:
|
||||
constant(ref<value> val,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class unary_operator : public expression {
|
||||
value::operator_id Operator;
|
||||
ref<expression> Operand;
|
||||
|
||||
public:
|
||||
unary_operator(value::operator_id opt,ref<expression> opn,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class modifying_unary_operator : public expression {
|
||||
value::operator_id Operator;
|
||||
ref<expression> Operand;
|
||||
|
||||
public:
|
||||
modifying_unary_operator(value::operator_id opt,ref<expression> opn,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class binary_operator : public expression {
|
||||
value::operator_id Operator;
|
||||
ref<expression> Operand1;
|
||||
ref<expression> Operand2;
|
||||
|
||||
public:
|
||||
binary_operator(value::operator_id opt,ref<expression> opn1,ref<expression> opn2,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class binary_shortcut_operator : public expression {
|
||||
value::operator_id Operator;
|
||||
ref<expression> Operand1;
|
||||
ref<expression> Operand2;
|
||||
|
||||
public:
|
||||
binary_shortcut_operator(value::operator_id opt,ref<expression> opn1,ref<expression> opn2,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class modifying_binary_operator : public expression {
|
||||
value::operator_id Operator;
|
||||
ref<expression> Operand1;
|
||||
ref<expression> Operand2;
|
||||
|
||||
public:
|
||||
modifying_binary_operator(value::operator_id opt,ref<expression> opn1,ref<expression> opn2,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class ternary_operator : public expression {
|
||||
ref<expression> Operand1;
|
||||
ref<expression> Operand2;
|
||||
ref<expression> Operand3;
|
||||
|
||||
public:
|
||||
ternary_operator(ref<expression> opn1,ref<expression> opn2,ref<expression> opn3,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class subscript_operation : public expression {
|
||||
ref<expression> Operand1;
|
||||
ref<expression> Operand2;
|
||||
|
||||
public:
|
||||
subscript_operation(ref<expression> opn1,ref<expression> opn2,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class lookup_operation : public expression {
|
||||
ref<expression> Operand;
|
||||
string Identifier;
|
||||
|
||||
public:
|
||||
lookup_operation(string const &id,code_location const &loc);
|
||||
lookup_operation(ref<expression> opn,string const &id,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class assignment : public expression {
|
||||
ref<expression> Operand1;
|
||||
ref<expression> Operand2;
|
||||
|
||||
public:
|
||||
assignment(ref<expression> opn1,ref<expression> opn2,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class basic_call : public expression {
|
||||
public:
|
||||
typedef vector<ref<expression> > parameter_expression_list;
|
||||
typedef vector<ref<value> > parameter_value_list;
|
||||
|
||||
private:
|
||||
parameter_expression_list ParameterExpressionList;
|
||||
|
||||
public:
|
||||
basic_call(parameter_expression_list const &pexps,code_location const &loc);
|
||||
void makeParameterValueList(context const &ctx,parameter_value_list &pvalues) const;
|
||||
};
|
||||
|
||||
class function_call : public basic_call {
|
||||
typedef basic_call super;
|
||||
ref<expression> Function;
|
||||
|
||||
public:
|
||||
function_call(ref<expression> fun,parameter_expression_list const &pexps,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class construction : public basic_call {
|
||||
typedef basic_call super;
|
||||
ref<expression> Class;
|
||||
|
||||
public:
|
||||
construction(ref<expression> cls,parameter_expression_list const &pexps,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
// declarations -----------------------------------------------------------
|
||||
class variable_declaration : public expression {
|
||||
protected:
|
||||
string Identifier;
|
||||
ref<expression> DefaultValue;
|
||||
|
||||
public:
|
||||
variable_declaration(string const &id,ref<expression> def_value,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class constant_declaration : public expression {
|
||||
protected:
|
||||
string Identifier;
|
||||
ref<expression> DefaultValue;
|
||||
|
||||
public:
|
||||
constant_declaration(string const &id,ref<expression> def_value,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class function_declaration : public expression {
|
||||
public:
|
||||
typedef function::parameter_name_list parameter_name_list;
|
||||
|
||||
private:
|
||||
string Identifier;
|
||||
parameter_name_list ParameterNameList;
|
||||
ref<expression> Body;
|
||||
|
||||
public:
|
||||
function_declaration(string const &id,parameter_name_list const &pnames,
|
||||
ref<expression> body,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class method_declaration : public expression {
|
||||
public:
|
||||
typedef method::parameter_name_list parameter_name_list;
|
||||
|
||||
private:
|
||||
string Identifier;
|
||||
parameter_name_list ParameterNameList;
|
||||
ref<expression> Body;
|
||||
|
||||
public:
|
||||
method_declaration(string const &id,parameter_name_list const &pnames,
|
||||
ref<expression> body,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class constructor_declaration : public expression {
|
||||
public:
|
||||
typedef method::parameter_name_list parameter_name_list;
|
||||
|
||||
private:
|
||||
parameter_name_list ParameterNameList;
|
||||
ref<expression> Body;
|
||||
|
||||
public:
|
||||
constructor_declaration(parameter_name_list const &pnames,
|
||||
ref<expression> body,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class js_class_declaration : public expression {
|
||||
typedef vector<ref<expression> > declaration_list;
|
||||
|
||||
string Identifier;
|
||||
ref<expression> SuperClass;
|
||||
ref<expression> ConstructorDeclaration;
|
||||
declaration_list StaticMethodList;
|
||||
declaration_list MethodList;
|
||||
declaration_list StaticVariableList;
|
||||
declaration_list VariableList;
|
||||
|
||||
public:
|
||||
js_class_declaration(string const &id,ref<expression> superclass,
|
||||
code_location const &loc);
|
||||
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
|
||||
void setConstructor(ref<expression> decl);
|
||||
void addStaticMethod(ref<expression> decl);
|
||||
void addMethod(ref<expression> decl);
|
||||
void addStaticVariable(ref<expression> decl);
|
||||
void addVariable(ref<expression> decl);
|
||||
};
|
||||
|
||||
// instructions ---------------------------------------------------------
|
||||
class instruction_list : public expression {
|
||||
typedef vector<ref<expression> > expression_list;
|
||||
expression_list ExpressionList;
|
||||
|
||||
public:
|
||||
instruction_list(code_location const &loc)
|
||||
: expression(loc) {
|
||||
}
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
void add(ref<expression> expr);
|
||||
};
|
||||
|
||||
class scoped_instruction_list : public instruction_list {
|
||||
public:
|
||||
scoped_instruction_list(code_location const &loc)
|
||||
: instruction_list(loc) {
|
||||
}
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class js_if : public expression {
|
||||
ref<expression> Conditional;
|
||||
ref<expression> IfExpression;
|
||||
ref<expression> IfNotExpression;
|
||||
|
||||
public:
|
||||
js_if(ref<expression> cond,ref<expression> ifex,ref<expression> ifnotex,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class js_while : public expression {
|
||||
ref<expression> Conditional;
|
||||
ref<expression> LoopExpression;
|
||||
bool HasLabel;
|
||||
string Label;
|
||||
|
||||
public:
|
||||
js_while(ref<expression> cond,ref<expression> loopex,code_location const &loc);
|
||||
js_while(ref<expression> cond,ref<expression> loopex,string const &Label,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class js_do_while : public expression {
|
||||
ref<expression> Conditional;
|
||||
ref<expression> LoopExpression;
|
||||
bool HasLabel;
|
||||
string Label;
|
||||
|
||||
public:
|
||||
js_do_while(ref<expression> cond,ref<expression> loopex,code_location const &loc);
|
||||
js_do_while(ref<expression> cond,ref<expression> loopex,string const &Label,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class js_for : public expression {
|
||||
ref<expression> Initialization;
|
||||
ref<expression> Conditional;
|
||||
ref<expression> Update;
|
||||
ref<expression> LoopExpression;
|
||||
bool HasLabel;
|
||||
string Label;
|
||||
|
||||
public:
|
||||
js_for(ref<expression> init,ref<expression> cond,ref<expression> update,ref<expression> loop,code_location const &loc);
|
||||
js_for(ref<expression> init,ref<expression> cond,ref<expression> update,ref<expression> loop,string const &label,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class js_for_in : public expression {
|
||||
ref<expression> Iterator;
|
||||
ref<expression> Array;
|
||||
ref<expression> LoopExpression;
|
||||
bool HasLabel;
|
||||
string Label;
|
||||
|
||||
public:
|
||||
js_for_in(ref<expression> iter,ref<expression> array,ref<expression> loop,code_location const &loc);
|
||||
js_for_in(ref<expression> iter,ref<expression> array,ref<expression> loop,string const &label,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class js_return : public expression {
|
||||
ref<expression> ReturnValue;
|
||||
|
||||
public:
|
||||
js_return(ref<expression> retval,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class js_break : public expression {
|
||||
bool HasLabel;
|
||||
string Label;
|
||||
|
||||
public:
|
||||
js_break(code_location const &loc);
|
||||
js_break(string const &label,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class js_continue : public expression {
|
||||
bool HasLabel;
|
||||
string Label;
|
||||
|
||||
public:
|
||||
js_continue(code_location const &loc);
|
||||
js_continue(string const &label,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class break_label : public expression {
|
||||
string Label;
|
||||
ref<expression> Expression;
|
||||
|
||||
public:
|
||||
break_label(string const &label,ref<expression> expr,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
};
|
||||
|
||||
class js_switch : public expression {
|
||||
bool HasLabel;
|
||||
string Label;
|
||||
ref<expression> Discriminant;
|
||||
|
||||
struct case_label {
|
||||
ref<expression> DiscriminantValue;
|
||||
ref<expression> Expression;
|
||||
};
|
||||
typedef vector<case_label> case_list;
|
||||
case_list CaseList;
|
||||
|
||||
public:
|
||||
js_switch(ref<expression> discriminant,code_location const &loc);
|
||||
js_switch(ref<expression> discriminant,string const &label,code_location const &loc);
|
||||
ref<value> evaluate(context const &ctx) const;
|
||||
void addCase(ref<expression> dvalue,ref<expression> expr);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
62
simgear/interpreter/ixlib_numconv.hh
Normal file
62
simgear/interpreter/ixlib_numconv.hh
Normal file
@@ -0,0 +1,62 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Numeric conversions
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 1999 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef IXLIB_NUMCONV
|
||||
#define IXLIB_NUMCONV
|
||||
|
||||
|
||||
|
||||
|
||||
#include <ixlib_base.hh>
|
||||
#include <ixlib_string.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
// Macros ---------------------------------------------------------------------
|
||||
#define IXLIB_NUMCHARS "0123456789ABCDEF"
|
||||
|
||||
|
||||
|
||||
|
||||
// Functions ------------------------------------------------------------------
|
||||
namespace ixion {
|
||||
std::string float2dec(double value);
|
||||
std::string float2dec(double value,unsigned int precision);
|
||||
std::string unsigned2base(unsigned long value,char digits = 0,char radix = 10);
|
||||
inline std::string unsigned2dec(unsigned long value,char digits = 0)
|
||||
{ return unsigned2base(value,digits,10); }
|
||||
inline std::string unsigned2hex(unsigned long value,char digits = 0)
|
||||
{ return unsigned2base(value,digits,16); }
|
||||
inline std::string unsigned2bin(unsigned long value,char digits = 0)
|
||||
{ return unsigned2base(value,digits,2); }
|
||||
inline std::string unsigned2oct(unsigned long value,char digits = 0)
|
||||
{ return unsigned2base(value,digits,8); }
|
||||
std::string signed2base(signed long value,char digits = 0,char radix = 10);
|
||||
inline std::string signed2dec(signed long value,char digits = 0)
|
||||
{ return signed2base(value,digits,10); }
|
||||
inline std::string signed2hex(signed long value,char digits = 0)
|
||||
{ return signed2base(value,digits,16); }
|
||||
inline std::string signed2bin(signed long value,char digits = 0)
|
||||
{ return signed2base(value,digits,2); }
|
||||
inline std::string signed2oct(signed long value,char digits = 0)
|
||||
{ return signed2base(value,digits,8); }
|
||||
|
||||
std::string bytes2dec(TSize bytes);
|
||||
|
||||
unsigned long evalNumeral(std::string const &numeral,unsigned radix = 10);
|
||||
double evalFloat(std::string const &numeral);
|
||||
unsigned long evalUnsigned(std::string const &numeral,unsigned default_base = 10);
|
||||
signed long evalSigned(std::string const &numeral,unsigned default_base = 10);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
127
simgear/interpreter/ixlib_numeric.hh
Normal file
127
simgear/interpreter/ixlib_numeric.hh
Normal file
@@ -0,0 +1,127 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : numeric / order processing
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 1996 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef IXLIB_NUMERIC
|
||||
#define IXLIB_NUMERIC
|
||||
|
||||
|
||||
|
||||
|
||||
#include <cstring>
|
||||
#include <ixlib_base.hh>
|
||||
#include <ixlib_exgen.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
// Macros ---------------------------------------------------------------------
|
||||
#ifdef _GNUC_
|
||||
#define NUM_MIN(a,b) ( (a)<?(b) )
|
||||
#define NUM_MAX(a,b) ( (a)>?(b) )
|
||||
#define NUM_ABS(a) ( (a)<0 ? (-(a)) : (a) )
|
||||
#else
|
||||
#define NUM_MIN(a,b) ( (a)<(b) ? (a) : (b) )
|
||||
#define NUM_MAX(a,b) ( (a)>(b) ? (a) : (b) )
|
||||
#define NUM_ABS(a) ( (a)<0 ? (-(a)) : (a) )
|
||||
#endif
|
||||
|
||||
#define NUM_LIMIT(lower,value,upper) \
|
||||
( NUM_MAX(lower,NUM_MIN(upper,vallue)) )
|
||||
#define NUM_INBOUND(lower,value,upper) \
|
||||
(((lower) <= (value)) && ((value) <= (upper)))
|
||||
#define NUM_OVERLAP(a1,a2,b1,b2) \
|
||||
((((a1)<=(b1))&&((a2)>(b1)))||(((a1)<(b2))&&((a2)>(b2)))||(((a1)>=(b1))&&((a2)<=(b2))))
|
||||
#define NUM_CIRCLEINC(index,size) \
|
||||
( ((index)+1) >= (size) ? 0 : ((index)+1) )
|
||||
#define NUM_CIRCLEDIST(head,tail,size) \
|
||||
( (head)<(tail) ? ((head)+(size)-(tail)) : ((head)-(tail)) )
|
||||
|
||||
|
||||
|
||||
|
||||
// Primitive inlines ---------------------------------------------------------
|
||||
namespace ixion {
|
||||
inline signed short sgn(signed long value);
|
||||
inline bool getBit(unsigned long value,char bit);
|
||||
inline TUnsigned8 hiByte(TUnsigned16 value);
|
||||
inline TUnsigned16 hiWord(TUnsigned32 value);
|
||||
inline TUnsigned8 loByte(TUnsigned16 value);
|
||||
inline TUnsigned16 loWord(TUnsigned32 value);
|
||||
inline TUnsigned16 makeWord(TUnsigned8 hi,TUnsigned8 lo);
|
||||
inline TUnsigned32 makeDWord(TUnsigned16 hi,TUnsigned16 lo);
|
||||
|
||||
|
||||
|
||||
|
||||
// BCD encoding ---------------------------------------------------------------
|
||||
unsigned long unsigned2BCD(unsigned long value);
|
||||
unsigned long BCD2unsigned(unsigned long value);
|
||||
|
||||
|
||||
|
||||
|
||||
// Primitive inlines ---------------------------------------------------------
|
||||
inline signed short ixion::sgn(signed long value) {
|
||||
return (value<0) ? -1 : ( (value>0) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline bool ixion::getBit(unsigned long value,char bit) {
|
||||
return (value >> bit) & 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline TUnsigned8 ixion::hiByte(TUnsigned16 value) {
|
||||
return value >> 8;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline TUnsigned16 ixion::hiWord(TUnsigned32 value) {
|
||||
return value >> 16;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline TUnsigned8 ixion::loByte(TUnsigned16 value) {
|
||||
return value & 0xff;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline TUnsigned16 ixion::loWord(TUnsigned32 value) {
|
||||
return value & 0xffff;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline TUnsigned16 ixion::makeWord(TUnsigned8 hi,TUnsigned8 lo) {
|
||||
return (TUnsigned16) hi << 8 | lo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline TUnsigned32 ixion::makeDWord(TUnsigned16 hi,TUnsigned16 lo) {
|
||||
return (TUnsigned32) hi << 16 | lo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
82
simgear/interpreter/ixlib_random.hh
Normal file
82
simgear/interpreter/ixlib_random.hh
Normal file
@@ -0,0 +1,82 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Random numbers
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 1996 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef IXLIB_RANDOM
|
||||
#define IXLIB_RANDOM
|
||||
|
||||
|
||||
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include <ctime>
|
||||
#include <ixlib_base.hh>
|
||||
#include <ixlib_numeric.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
namespace ixion {
|
||||
class float_random {
|
||||
double Seed;
|
||||
|
||||
public:
|
||||
float_random()
|
||||
: Seed(1)
|
||||
{ }
|
||||
|
||||
void init() {
|
||||
double current_time = time(NULL);
|
||||
Seed = current_time*sin(current_time);
|
||||
}
|
||||
void init(double seed)
|
||||
{ Seed = NUM_ABS(seed); }
|
||||
|
||||
/// Generate one random number in the interval [0,max).
|
||||
double operator()(double max = 1) {
|
||||
// normalize
|
||||
while (Seed > 3) Seed = log(Seed);
|
||||
Seed -= floor(Seed);
|
||||
Seed = pow(Seed+Pi,8);
|
||||
Seed -= floor(Seed);
|
||||
return Seed*max;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class int_random {
|
||||
float_random Generator;
|
||||
|
||||
public:
|
||||
int_random()
|
||||
{ }
|
||||
|
||||
void init()
|
||||
{ Generator.init(); }
|
||||
void init(unsigned seed)
|
||||
{ Generator.init(seed); }
|
||||
|
||||
/// Generate one random number in the interval [0,max).
|
||||
unsigned operator()(unsigned max = 32768) {
|
||||
unsigned num = rng8() + (rng8() << 7) + (rng8() << 14) + (rng8() << 21) + (rng8() << 28);
|
||||
return num % max;
|
||||
}
|
||||
private:
|
||||
TUnsigned8 rng8() {
|
||||
return (TUnsigned8) (Generator()*256);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
493
simgear/interpreter/ixlib_re.hh
Normal file
493
simgear/interpreter/ixlib_re.hh
Normal file
@@ -0,0 +1,493 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Regular expressions string object
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 1998 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef IXLIB_RE
|
||||
#define IXLIB_RE
|
||||
|
||||
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <ixlib_exgen.hh>
|
||||
#include <ixlib_string.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
// Regex exceptions -----------------------------------------------------------
|
||||
#define ECRE_INVQUANTIFIER 0
|
||||
#define ECRE_UNBALBACKREF 1
|
||||
#define ECRE_INVESCAPE 2
|
||||
#define ECRE_INVBACKREF 3
|
||||
#define ECRE_UNTERMCLASS 4
|
||||
#define ECRE_NOPATTERN 5
|
||||
|
||||
|
||||
|
||||
|
||||
namespace ixion {
|
||||
class regex_exception : public base_exception {
|
||||
public:
|
||||
regex_exception(TErrorCode error,char const *info = NULL,char *module = NULL,TIndex line = 0);
|
||||
virtual char *getText() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Regex token macros ---------------------------------------------------------
|
||||
#define XSTRRE_LITERAL '\\'
|
||||
#define XSTRRE_BACKREF '\\'
|
||||
#define XSTRRE_ESCAPESEQ '\\'
|
||||
#define XSTRRE_ANYCHAR '.'
|
||||
#define XSTRRE_START '^'
|
||||
#define XSTRRE_END '$'
|
||||
#define XSTRRE_ALTERNATIVE '|'
|
||||
#define XSTRRE_CLASSSTART '['
|
||||
#define XSTRRE_CLASSNEG '^'
|
||||
#define XSTRRE_CLASSRANGE '-'
|
||||
#define XSTRRE_CLASSSTOP ']'
|
||||
|
||||
#define XSTRRE_BACKREFSTART '('
|
||||
#define XSTRRE_BACKREFSTOP ')'
|
||||
|
||||
#define XSTRREQ_0PLUS '*'
|
||||
#define XSTRREQ_1PLUS '+'
|
||||
#define XSTRREQ_01 '?'
|
||||
#define XSTRREQ_START '{'
|
||||
#define XSTRREQ_RANGE ','
|
||||
#define XSTRREQ_STOP '}'
|
||||
#define XSTRREQ_NONGREEDY '?'
|
||||
|
||||
|
||||
|
||||
|
||||
namespace ixion {
|
||||
/**
|
||||
A class implementing a generic regular expression matcher not only for strings.
|
||||
If you are looking for a usual regular expresion parser, look at
|
||||
ixion::regex_string.
|
||||
|
||||
If you query anything about the last match, and that last match did
|
||||
never happen, behavior is undefined.
|
||||
*/
|
||||
|
||||
template<class T>
|
||||
class regex {
|
||||
protected:
|
||||
// various helper classes -----------------------------------------------
|
||||
class backref_stack {
|
||||
private:
|
||||
struct backref_entry {
|
||||
enum { OPEN,CLOSE } Type;
|
||||
TIndex Index;
|
||||
};
|
||||
|
||||
typedef std::vector<backref_entry> internal_stack;
|
||||
|
||||
internal_stack Stack;
|
||||
|
||||
public:
|
||||
typedef TSize rewind_info;
|
||||
|
||||
void open(TIndex index);
|
||||
void close(TIndex index);
|
||||
|
||||
rewind_info getRewindInfo() const;
|
||||
void rewind(rewind_info ri);
|
||||
void clear();
|
||||
|
||||
TSize size();
|
||||
T get(TIndex number,T const &candidate) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// matchers -------------------------------------------------------------
|
||||
class matcher {
|
||||
protected:
|
||||
matcher *Next;
|
||||
bool OwnNext;
|
||||
TSize MatchLength;
|
||||
|
||||
public:
|
||||
matcher();
|
||||
virtual ~matcher();
|
||||
|
||||
virtual matcher *duplicate() const = 0;
|
||||
|
||||
TSize getMatchLength() const {
|
||||
return MatchLength;
|
||||
}
|
||||
TSize subsequentMatchLength() const;
|
||||
virtual TSize minimumMatchLength() const = 0;
|
||||
TSize minimumSubsequentMatchLength() const;
|
||||
|
||||
matcher *getNext() const {
|
||||
return Next;
|
||||
}
|
||||
virtual void setNext(matcher *next,bool ownnext = true) {
|
||||
Next = next;
|
||||
OwnNext = ownnext;
|
||||
}
|
||||
|
||||
// this routine must set the MatchLength member correctly.
|
||||
virtual bool match(backref_stack &brstack,T const &candidate,TIndex at)
|
||||
= 0;
|
||||
|
||||
protected:
|
||||
bool matchNext(backref_stack &brstack,T const &candidate,TIndex at) const {
|
||||
return Next ? Next->match(brstack,candidate,at) : true;
|
||||
}
|
||||
void copy(matcher const *src);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class quantifier : public matcher {
|
||||
private:
|
||||
typedef matcher super;
|
||||
bool Greedy,MaxValid;
|
||||
TSize MinCount,MaxCount;
|
||||
matcher *Quantified;
|
||||
|
||||
struct backtrack_stack_entry {
|
||||
TIndex Index;
|
||||
backref_stack::rewind_info RewindInfo;
|
||||
};
|
||||
|
||||
public:
|
||||
quantifier()
|
||||
: Quantified(NULL) {
|
||||
}
|
||||
quantifier(bool greedy,TSize mincount);
|
||||
quantifier(bool greedy,TSize mincount,TSize maxcount);
|
||||
~quantifier();
|
||||
|
||||
matcher *duplicate() const;
|
||||
|
||||
TSize minimumMatchLength() const;
|
||||
|
||||
void setQuantified(matcher *quantified) {
|
||||
Quantified = quantified;
|
||||
}
|
||||
bool match(backref_stack &brstack,T const &candidate,TIndex at);
|
||||
|
||||
protected:
|
||||
void copy(quantifier const *src);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class sequence_matcher : public matcher {
|
||||
T MatchStr;
|
||||
|
||||
public:
|
||||
sequence_matcher(T const &matchstr);
|
||||
|
||||
matcher *duplicate() const;
|
||||
|
||||
TSize minimumMatchLength() const {
|
||||
return MatchStr.size();
|
||||
}
|
||||
bool match(backref_stack &brstack,T const &candidate,TIndex at);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class any_matcher : public matcher {
|
||||
public:
|
||||
any_matcher() {
|
||||
MatchLength = 1;
|
||||
}
|
||||
|
||||
matcher *duplicate() const;
|
||||
|
||||
TSize minimumMatchLength() const {
|
||||
return 1;
|
||||
}
|
||||
bool match(backref_stack &brstack,T const &candidate,TIndex at) {
|
||||
return at < candidate.size() && matchNext(brstack,candidate,at+1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class start_matcher : public matcher {
|
||||
public:
|
||||
start_matcher() {
|
||||
MatchLength = 0;
|
||||
}
|
||||
|
||||
matcher *duplicate() const;
|
||||
|
||||
TSize minimumMatchLength() const {
|
||||
return 0;
|
||||
}
|
||||
bool match(backref_stack &brstack,T const &candidate,TIndex at);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class end_matcher : public matcher {
|
||||
public:
|
||||
end_matcher() {
|
||||
MatchLength = 0;
|
||||
}
|
||||
|
||||
matcher *duplicate() const;
|
||||
|
||||
TSize minimumMatchLength() const {
|
||||
return 0;
|
||||
}
|
||||
bool match(backref_stack &brstack,T const &candidate,TIndex at);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class backref_open_matcher : public matcher {
|
||||
public:
|
||||
backref_open_matcher() {
|
||||
MatchLength = 0;
|
||||
}
|
||||
|
||||
matcher *duplicate() const;
|
||||
|
||||
TSize minimumMatchLength() const {
|
||||
return 0;
|
||||
}
|
||||
bool match(backref_stack &brstack,T const &candidate,TIndex at);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class backref_close_matcher : public matcher {
|
||||
public:
|
||||
backref_close_matcher() {
|
||||
MatchLength = 0;
|
||||
}
|
||||
|
||||
matcher *duplicate() const;
|
||||
|
||||
TSize minimumMatchLength() const {
|
||||
return 0;
|
||||
}
|
||||
bool match(backref_stack &brstack,T const &candidate,TIndex at);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class alternative_matcher : public matcher {
|
||||
// The connector serves two purposes:
|
||||
// a) be a null-matcher that re-unites the different alternate token
|
||||
// sequences
|
||||
// b) make the end of each sequence identifiable to be able to compute
|
||||
// the match length
|
||||
|
||||
class connector : public matcher {
|
||||
public:
|
||||
matcher *duplicate() const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TSize minimumMatchLength() const {
|
||||
return 0;
|
||||
}
|
||||
bool match(backref_stack &brstack,T const &candidate,TIndex at);
|
||||
};
|
||||
|
||||
typedef matcher super;
|
||||
typedef std::vector<matcher *> alt_list;
|
||||
alt_list AltList;
|
||||
connector Connector;
|
||||
|
||||
public:
|
||||
~alternative_matcher();
|
||||
|
||||
matcher *duplicate() const;
|
||||
|
||||
TSize minimumMatchLength() const;
|
||||
void setNext(matcher *next,bool ownnext = true);
|
||||
void addAlternative(matcher *alternative);
|
||||
bool match(backref_stack &brstack,T const &candidate,TIndex at);
|
||||
|
||||
protected:
|
||||
void copy(alternative_matcher const *src);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class backref_matcher : public matcher {
|
||||
TIndex Backref;
|
||||
|
||||
public:
|
||||
backref_matcher(TIndex backref);
|
||||
|
||||
matcher *duplicate() const;
|
||||
|
||||
TSize minimumMatchLength() const {
|
||||
return 0;
|
||||
}
|
||||
bool match(backref_stack &brstack,T const &candidate,TIndex at);
|
||||
};
|
||||
|
||||
// instance data --------------------------------------------------------
|
||||
std::auto_ptr<matcher> ParsedRegex;
|
||||
backref_stack BackrefStack;
|
||||
T LastCandidate;
|
||||
TIndex MatchIndex;
|
||||
TSize MatchLength;
|
||||
|
||||
public:
|
||||
// interface ------------------------------------------------------------
|
||||
regex();
|
||||
regex(regex const &src);
|
||||
|
||||
regex &operator=(regex const &src);
|
||||
|
||||
bool match(T const &candidate,TIndex from = 0);
|
||||
bool matchAt(T const &candidate,TIndex at = 0);
|
||||
|
||||
// Queries pertaining to the last match
|
||||
TIndex getMatchIndex() {
|
||||
return MatchIndex;
|
||||
}
|
||||
TSize getMatchLength() {
|
||||
return MatchLength;
|
||||
}
|
||||
std::string getMatch() {
|
||||
return T(LastCandidate.begin()+MatchIndex,
|
||||
LastCandidate.begin()+MatchIndex+MatchLength);
|
||||
}
|
||||
TSize countBackrefs() {
|
||||
return BackrefStack.size();
|
||||
}
|
||||
T getBackref(TIndex index) {
|
||||
return BackrefStack.get(index,LastCandidate);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
A regular expression parser and matcher.
|
||||
|
||||
Backref numbering starts at \0.
|
||||
|
||||
ReplaceAll does not set the MatchIndex/MatchGlobal members.
|
||||
|
||||
What is there is compatible with perl5. (See man perlre or
|
||||
http://www.cpan.org/doc/manual/html/pod/perlre.html)
|
||||
However, not everything is there. Here's what's missing:
|
||||
|
||||
<ul>
|
||||
<li> \Q-\E,\b,\B,\A,\Z,\z
|
||||
<li> discerning between line and string
|
||||
<li> (?#comments)
|
||||
<li> (?:clustering)
|
||||
<li> (?=positive lookahead assumptions)
|
||||
<li> (?!negative lookahead assumptions
|
||||
<li> (?<=positive lookbehind assumptions)
|
||||
<li> (?<!negative lookbehind assumptions
|
||||
<li> (?>independent substrings)
|
||||
<li> modifiers such as "case independent"
|
||||
</ul>
|
||||
|
||||
as well as all the stuff involving perl code, naturally.
|
||||
None of these is actually hard to hack in. If you want them,
|
||||
pester me or try for yourself (and submit patches!)
|
||||
*/
|
||||
class regex_string : public regex<std::string> {
|
||||
private:
|
||||
class class_matcher : public regex<std::string>::matcher {
|
||||
private:
|
||||
typedef regex<std::string>::matcher super;
|
||||
static TSize const CharValues = 256;
|
||||
bool Set[CharValues];
|
||||
bool Negated;
|
||||
|
||||
public:
|
||||
class_matcher();
|
||||
class_matcher(std::string const &cls);
|
||||
|
||||
matcher *duplicate() const;
|
||||
|
||||
TSize minimumMatchLength() const {
|
||||
return 1;
|
||||
}
|
||||
bool match(backref_stack &brstack,std::string const &candidate,TIndex at);
|
||||
|
||||
private:
|
||||
void expandClass(std::string const &cls);
|
||||
|
||||
protected:
|
||||
void copy(class_matcher const *src);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class special_class_matcher : public regex<std::string>::matcher {
|
||||
public:
|
||||
enum type { DIGIT,NONDIGIT,ALNUM,NONALNUM,SPACE,NONSPACE };
|
||||
|
||||
private:
|
||||
type Type;
|
||||
|
||||
public:
|
||||
special_class_matcher(type tp);
|
||||
|
||||
matcher *duplicate() const;
|
||||
|
||||
TSize minimumMatchLength() const {
|
||||
return 1;
|
||||
}
|
||||
bool match(backref_stack &brstack,std::string const &candidate,TIndex at);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
public:
|
||||
regex_string() {
|
||||
}
|
||||
regex_string(std::string const &str) {
|
||||
parse(str);
|
||||
}
|
||||
regex_string(char const *s) {
|
||||
parse(s);
|
||||
}
|
||||
|
||||
void parse(std::string const &expr);
|
||||
|
||||
std::string replaceAll(std::string const &candidate,std::string const &replacement,
|
||||
TIndex from = 0);
|
||||
|
||||
private:
|
||||
regex<std::string>::matcher *parseRegex(std::string const &expr);
|
||||
quantifier *parseQuantifier(std::string const &expr,TIndex &at);
|
||||
bool isGreedy(std::string const &expr,TIndex &at);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
652
simgear/interpreter/ixlib_re_impl.hh
Normal file
652
simgear/interpreter/ixlib_re_impl.hh
Normal file
@@ -0,0 +1,652 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Regular expressions string object.
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 1998 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#include <stack>
|
||||
#include <cctype>
|
||||
#include "ixlib_i18n.hh"
|
||||
#include <ixlib_exgen.hh>
|
||||
#include <ixlib_numeric.hh>
|
||||
#include <ixlib_numconv.hh>
|
||||
#include <ixlib_re.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
// regex::backref_stack -------------------------------------------------------
|
||||
template<class T>
|
||||
void ixion::regex<T>::backref_stack::open(TIndex index) {
|
||||
backref_entry entry = { backref_entry::OPEN,index };
|
||||
Stack.push_back(entry);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
void ixion::regex<T>::backref_stack::close(TIndex index) {
|
||||
backref_entry entry = { backref_entry::CLOSE,index };
|
||||
Stack.push_back(entry);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
ixion::regex<T>::backref_stack::rewind_info
|
||||
ixion::regex<T>::backref_stack::getRewindInfo() const {
|
||||
return Stack.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
void ixion::regex<T>::backref_stack::rewind(rewind_info ri) {
|
||||
Stack.erase(Stack.begin()+ri,Stack.end());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
void ixion::regex<T>::backref_stack::clear() {
|
||||
Stack.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
ixion::TSize ixion::regex<T>::backref_stack::size() {
|
||||
TSize result = 0;
|
||||
FOREACH_CONST(first,Stack,internal_stack)
|
||||
if (first->Type == backref_entry::OPEN) result++;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
T ixion::regex<T>::backref_stack::get(TIndex number,T const &candidate) const {
|
||||
TIndex level = 0,next_index = 0;
|
||||
TIndex start;
|
||||
TIndex startlevel;
|
||||
|
||||
internal_stack::const_iterator first = Stack.begin(),last = Stack.end();
|
||||
while (first != last) {
|
||||
if (first->Type == backref_entry::OPEN) {
|
||||
if (number == next_index) {
|
||||
start = first->Index;
|
||||
startlevel = level;
|
||||
level++;
|
||||
break;
|
||||
}
|
||||
next_index++;
|
||||
level++;
|
||||
}
|
||||
if (first->Type == backref_entry::CLOSE)
|
||||
level--;
|
||||
first++;
|
||||
}
|
||||
|
||||
if (first == last)
|
||||
EX_THROW(regex,ECRE_INVBACKREF)
|
||||
|
||||
first++;
|
||||
|
||||
while (first != last) {
|
||||
if (first->Type == backref_entry::OPEN)
|
||||
level++;
|
||||
if (first->Type == backref_entry::CLOSE) {
|
||||
level--;
|
||||
if (startlevel == level)
|
||||
return candidate.substr(start,first->Index - start);
|
||||
}
|
||||
first++;
|
||||
}
|
||||
EX_THROW(regex,ECRE_UNBALBACKREF)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// regex::matcher -------------------------------------------------------------
|
||||
template<class T>
|
||||
ixion::regex<T>::matcher::matcher()
|
||||
: Next(NULL) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
ixion::regex<T>::matcher::~matcher() {
|
||||
if (Next && OwnNext)
|
||||
delete Next;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
ixion::TSize ixion::regex<T>::matcher::subsequentMatchLength() const {
|
||||
TSize totalml = 0;
|
||||
matcher const *object = this;
|
||||
while (object) {
|
||||
totalml += object->MatchLength;
|
||||
object = object->Next;
|
||||
}
|
||||
return totalml;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
ixion::TSize ixion::regex<T>::matcher::minimumSubsequentMatchLength() const {
|
||||
TSize totalml = 0;
|
||||
matcher const *object = this;
|
||||
while (object) {
|
||||
totalml += object->minimumMatchLength();
|
||||
object = object->Next;
|
||||
}
|
||||
return totalml;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
void ixion::regex<T>::matcher::copy(matcher const *src) {
|
||||
if (src->Next && src->OwnNext)
|
||||
setNext(src->Next->duplicate(),src->OwnNext);
|
||||
else
|
||||
setNext(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// regex::quantifier ----------------------------------------------------------
|
||||
template<class T>
|
||||
ixion::regex<T>::quantifier::quantifier(bool greedy,TSize mincount)
|
||||
: Greedy(greedy),MaxValid(false),MinCount(mincount) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
ixion::regex<T>::quantifier::quantifier(bool greedy,TSize mincount,TSize maxcount)
|
||||
: Greedy(greedy),MaxValid(true),MinCount(mincount),MaxCount(maxcount) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
ixion::regex<T>::quantifier::~quantifier() {
|
||||
if (Quantified)
|
||||
delete Quantified;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
ixion::regex<T>::matcher *ixion::regex<T>::quantifier::duplicate() const {
|
||||
quantifier *dupe = new quantifier();
|
||||
dupe->copy(this);
|
||||
return dupe;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
ixion::TSize ixion::regex<T>::quantifier::minimumMatchLength() const {
|
||||
if (Quantified)
|
||||
return MinCount * Quantified->minimumMatchLength();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
bool ixion::regex<T>::quantifier::match(backref_stack &brstack,T const &candidate,TIndex at) {
|
||||
// this routine does speculative matching, so it must pay close attention
|
||||
// to rewind the backref stack appropriately.
|
||||
// NB: matchNext does the rewinding automatically, whereas speculative
|
||||
// matches of the quantified portion must be rewound.
|
||||
|
||||
// There should be at least one character in each match, we'd
|
||||
// run to Baghdad otherwise.
|
||||
|
||||
if (!Quantified)
|
||||
return matchNext(brstack,candidate,at);
|
||||
|
||||
// calculate accurate maximum match count
|
||||
TSize quant_min = Quantified->minimumSubsequentMatchLength();
|
||||
if (quant_min == 0) quant_min = 1;
|
||||
|
||||
TSize max_count = candidate.size() - at;
|
||||
if (Next) max_count -= Next->minimumSubsequentMatchLength();
|
||||
max_count = max_count/quant_min + 1;
|
||||
|
||||
if (MaxValid) max_count = NUM_MIN(max_count,MaxCount);
|
||||
|
||||
// check that at least MinCount matches take place (non-speculative)
|
||||
TIndex idx = at;
|
||||
for (TSize c = 1;c <= MinCount;c++)
|
||||
if (Quantified->match(brstack,candidate,idx))
|
||||
idx += Quantified->subsequentMatchLength();
|
||||
else
|
||||
return false;
|
||||
|
||||
// determine number of remaining matches
|
||||
TSize remcount = max_count-MinCount;
|
||||
|
||||
// test for the remaining matches in a way that depends on Greedy flag
|
||||
if (Greedy) {
|
||||
// try to gobble up as many matches of quantified part as possible
|
||||
// (speculative)
|
||||
|
||||
std::stack<backtrack_stack_entry> successful_indices;
|
||||
{ backtrack_stack_entry entry = { idx,brstack.getRewindInfo() };
|
||||
successful_indices.push(entry);
|
||||
}
|
||||
|
||||
while (Quantified->match(brstack,candidate,idx) && successful_indices.size()-1 < remcount) {
|
||||
idx += Quantified->subsequentMatchLength();
|
||||
backtrack_stack_entry entry = { idx,brstack.getRewindInfo() };
|
||||
successful_indices.push(entry);
|
||||
}
|
||||
|
||||
// backtrack until rest of sequence also matches
|
||||
while (successful_indices.size() && !matchNext(brstack,candidate,successful_indices.top().Index)) {
|
||||
brstack.rewind(successful_indices.top().RewindInfo);
|
||||
successful_indices.pop();
|
||||
}
|
||||
|
||||
if (successful_indices.size()) {
|
||||
MatchLength = successful_indices.top().Index - at;
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
else {
|
||||
for (TSize c = 0;c <= remcount;c++) {
|
||||
if (matchNext(brstack,candidate,idx)) {
|
||||
MatchLength = idx-at;
|
||||
return true;
|
||||
}
|
||||
// following part runs once too much, effectively:
|
||||
// if c == remcount, idx may be increased, but the search fails anyway
|
||||
// => no problem
|
||||
if (Quantified->match(brstack,candidate,idx))
|
||||
idx += Quantified->subsequentMatchLength();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
void ixion::regex<T>::quantifier::copy(quantifier const *src) {
|
||||
super::copy(src);
|
||||
Greedy = src->Greedy;
|
||||
MaxValid = src->MaxValid;
|
||||
MinCount = src->MinCount;
|
||||
MaxCount = src->MaxCount;
|
||||
Quantified = src->Quantified->duplicate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// regex::sequence_matcher ------------------------------------------------------
|
||||
template<class T>
|
||||
ixion::regex<T>::sequence_matcher::sequence_matcher(T const &matchstr)
|
||||
: MatchStr(matchstr) {
|
||||
MatchLength = MatchStr.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
ixion::regex<T>::matcher *ixion::regex<T>::sequence_matcher::duplicate() const {
|
||||
sequence_matcher *dupe = new sequence_matcher(MatchStr);
|
||||
dupe->copy(this);
|
||||
return dupe;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
bool ixion::regex<T>::sequence_matcher::match(backref_stack &brstack,T const &candidate,TIndex at) {
|
||||
if (at+MatchStr.size() > candidate.size()) return false;
|
||||
return (T(candidate.begin()+at,candidate.begin()+at+MatchStr.size()) == MatchStr) &&
|
||||
matchNext(brstack,candidate,at+MatchStr.size());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// regex::any_matcher ---------------------------------------------------------
|
||||
template<class T>
|
||||
ixion::regex<T>::matcher *ixion::regex<T>::any_matcher::duplicate() const {
|
||||
any_matcher *dupe = new any_matcher();
|
||||
dupe->copy(this);
|
||||
return dupe;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// regex::start_matcher ---------------------------------------------------------
|
||||
template<class T>
|
||||
ixion::regex<T>::matcher *ixion::regex<T>::start_matcher::duplicate() const {
|
||||
start_matcher *dupe = new start_matcher();
|
||||
dupe->copy(this);
|
||||
return dupe;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
bool ixion::regex<T>::start_matcher::match(backref_stack &brstack,T const &candidate,TIndex at) {
|
||||
return (at == 0) && matchNext(brstack,candidate,at);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// regex::end_matcher ---------------------------------------------------------
|
||||
template<class T>
|
||||
ixion::regex<T>::matcher *ixion::regex<T>::end_matcher::duplicate() const {
|
||||
end_matcher *dupe = new end_matcher();
|
||||
dupe->copy(this);
|
||||
return dupe;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
bool ixion::regex<T>::end_matcher::match(backref_stack &brstack,T const &candidate,TIndex at) {
|
||||
return (at == candidate.size()) && matchNext(brstack,candidate,at);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// regex::backref_open_matcher ------------------------------------------------
|
||||
template<class T>
|
||||
ixion::regex<T>::matcher *ixion::regex<T>::backref_open_matcher::duplicate() const {
|
||||
backref_open_matcher *dupe = new backref_open_matcher();
|
||||
dupe->copy(this);
|
||||
return dupe;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
bool ixion::regex<T>::backref_open_matcher::match(backref_stack &brstack,T const &candidate,TIndex at) {
|
||||
backref_stack::rewind_info ri = brstack.getRewindInfo();
|
||||
brstack.open(at);
|
||||
|
||||
bool result = matchNext(brstack,candidate,at);
|
||||
|
||||
if (!result)
|
||||
brstack.rewind(ri);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// regex::backref_close_matcher -----------------------------------------------
|
||||
template<class T>
|
||||
ixion::regex<T>::matcher *ixion::regex<T>::backref_close_matcher::duplicate() const {
|
||||
backref_close_matcher *dupe = new backref_close_matcher();
|
||||
dupe->copy(this);
|
||||
return dupe;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
bool ixion::regex<T>::backref_close_matcher::match(backref_stack &brstack,T const &candidate,TIndex at) {
|
||||
backref_stack::rewind_info ri = brstack.getRewindInfo();
|
||||
brstack.close(at);
|
||||
|
||||
bool result = matchNext(brstack,candidate,at);
|
||||
|
||||
if (!result)
|
||||
brstack.rewind(ri);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// regex::alternative_matcher::connector --------------------------------------
|
||||
template<class T>
|
||||
bool ixion::regex<T>::alternative_matcher::connector::match(backref_stack &brstack,T const &candidate,TIndex at) {
|
||||
return matchNext(brstack,candidate,at);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// regex::alternative_matcher -------------------------------------------------
|
||||
template<class T>
|
||||
ixion::regex<T>::alternative_matcher::~alternative_matcher() {
|
||||
while (AltList.size()) {
|
||||
delete AltList.back();
|
||||
AltList.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
ixion::regex<T>::matcher *ixion::regex<T>::alternative_matcher::duplicate() const {
|
||||
alternative_matcher *dupe = new alternative_matcher();
|
||||
dupe->copy(this);
|
||||
return dupe;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
ixion::TSize ixion::regex<T>::alternative_matcher::minimumMatchLength() const {
|
||||
TSize result = 0;
|
||||
bool is_first = true;
|
||||
|
||||
FOREACH_CONST(first,AltList,alt_list)
|
||||
if (is_first) {
|
||||
result = (*first)->minimumMatchLength();
|
||||
is_first = true;
|
||||
}
|
||||
else {
|
||||
TSize current = (*first)->minimumMatchLength();
|
||||
if (current < result) result = current;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
void ixion::regex<T>::alternative_matcher::setNext(matcher *next,bool ownnext = true) {
|
||||
matcher::setNext(next);
|
||||
Connector.setNext(next,false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
void ixion::regex<T>::alternative_matcher::addAlternative(matcher *alternative) {
|
||||
AltList.push_back(alternative);
|
||||
matcher *searchlast = alternative,*last = NULL;
|
||||
while (searchlast) {
|
||||
last = searchlast;
|
||||
searchlast = searchlast->getNext();
|
||||
}
|
||||
last->setNext(&Connector,false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
bool ixion::regex<T>::alternative_matcher::match(backref_stack &brstack,T const &candidate,TIndex at) {
|
||||
std::vector<matcher *>::iterator first = AltList.begin(),last = AltList.end();
|
||||
while (first != last) {
|
||||
if ((*first)->match(brstack,candidate,at)) {
|
||||
MatchLength = 0;
|
||||
matcher const *object = *first;
|
||||
while (object != &Connector) {
|
||||
MatchLength += object->getMatchLength();
|
||||
object = object->getNext();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
first++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
void ixion::regex<T>::alternative_matcher::copy(alternative_matcher const *src) {
|
||||
super::copy(src);
|
||||
Connector.setNext(Next,false);
|
||||
|
||||
FOREACH_CONST(first,src->AltList,alt_list)
|
||||
addAlternative((*first)->duplicate());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// regex::backref_matcher -----------------------------------------------------
|
||||
template<class T>
|
||||
ixion::regex<T>::backref_matcher::backref_matcher(TIndex backref)
|
||||
: Backref(backref) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
ixion::regex<T>::matcher *ixion::regex<T>::backref_matcher::duplicate() const {
|
||||
backref_matcher *dupe = new backref_matcher(Backref);
|
||||
dupe->copy(this);
|
||||
return dupe;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
bool ixion::regex<T>::backref_matcher::match(backref_stack &brstack,T const &candidate,TIndex at) {
|
||||
T matchstr = brstack.get(Backref,candidate);
|
||||
MatchLength = matchstr.size();
|
||||
|
||||
if (at+matchstr.size() > candidate.size()) return false;
|
||||
return (T(candidate.begin()+at,candidate.begin()+at+matchstr.size()) == matchstr) &&
|
||||
matchNext(brstack,candidate,at+matchstr.size());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// regex ----------------------------------------------------------------------
|
||||
template<class T>
|
||||
ixion::regex<T>::regex()
|
||||
: MatchIndex(0),MatchLength(0) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
ixion::regex<T>::regex(regex const &src)
|
||||
: ParsedRegex(src.ParsedRegex->duplicate()),
|
||||
MatchIndex(0),MatchLength(0) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
ixion::regex<T> &ixion::regex<T>::operator=(regex const &src) {
|
||||
std::auto_ptr<matcher> regex_copy(src.ParsedRegex->duplicate());
|
||||
ParsedRegex = regex_copy;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
bool ixion::regex<T>::match(T const &candidate,TIndex from) {
|
||||
LastCandidate = candidate;
|
||||
BackrefStack.clear();
|
||||
|
||||
if (ParsedRegex.get() == NULL)
|
||||
EX_THROW(regex,ECRE_NOPATTERN)
|
||||
|
||||
for (TIndex index = from;index < candidate.size();index++)
|
||||
if (ParsedRegex->match(BackrefStack,candidate,index)) {
|
||||
MatchIndex = index;
|
||||
MatchLength = ParsedRegex->subsequentMatchLength();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
bool ixion::regex<T>::matchAt(T const &candidate,TIndex at) {
|
||||
LastCandidate = candidate;
|
||||
BackrefStack.clear();
|
||||
|
||||
if (ParsedRegex.get() == NULL)
|
||||
EX_THROW(regex,ECRE_NOPATTERN)
|
||||
|
||||
if (ParsedRegex->match(BackrefStack,candidate,at)) {
|
||||
MatchIndex = at;
|
||||
MatchLength = ParsedRegex->subsequentMatchLength();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
24
simgear/interpreter/ixlib_scanjs.hh
Normal file
24
simgear/interpreter/ixlib_scanjs.hh
Normal file
@@ -0,0 +1,24 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Javascript scanner
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 2000 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef IXLIB_SCANJS
|
||||
#define IXLIB_SCANJS
|
||||
|
||||
|
||||
|
||||
|
||||
#undef yyFlexLexer
|
||||
#define yyFlexLexer jsFlexLexer
|
||||
#include <FlexLexer.h>
|
||||
#undef yyFlexLexer
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
75
simgear/interpreter/ixlib_scanner.hh
Normal file
75
simgear/interpreter/ixlib_scanner.hh
Normal file
@@ -0,0 +1,75 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : scanner wrapper for FlexLexer
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 1999 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef IXLIB_SCANNER
|
||||
#define IXLIB_SCANNER
|
||||
|
||||
|
||||
|
||||
|
||||
#include <ixlib_base.hh>
|
||||
#include <ixlib_exbase.hh>
|
||||
#include <vector>
|
||||
#include <ixlib_string.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
class FlexLexer;
|
||||
|
||||
|
||||
|
||||
|
||||
// possible errors during execution -------------------------------------------
|
||||
#define ECSCAN_UNKNOWN_TOKEN 0
|
||||
#define ECSCAN_EOF 1
|
||||
|
||||
|
||||
|
||||
|
||||
// scanner_exception ----------------------------------------------------------
|
||||
namespace ixion {
|
||||
struct scanner_exception : public base_exception {
|
||||
scanner_exception(TErrorCode const error,TIndex const line,std::string const &info);
|
||||
virtual char *getText() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// scanner --------------------------------------------------------------------
|
||||
class scanner {
|
||||
public:
|
||||
typedef unsigned token_type;
|
||||
|
||||
struct token {
|
||||
token_type Type;
|
||||
TIndex Line;
|
||||
std::string Text;
|
||||
};
|
||||
|
||||
typedef std::vector<token> token_list;
|
||||
typedef std::vector<token>::iterator token_iterator;
|
||||
|
||||
scanner(FlexLexer &lexer);
|
||||
token_list scan();
|
||||
|
||||
protected:
|
||||
FlexLexer &Lexer;
|
||||
token CurrentToken;
|
||||
|
||||
token getNextToken();
|
||||
bool reachedEOF() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
64
simgear/interpreter/ixlib_string.hh
Normal file
64
simgear/interpreter/ixlib_string.hh
Normal file
@@ -0,0 +1,64 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : String crunching tools
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 1999 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef IXLIB_STRING
|
||||
#define IXLIB_STRING
|
||||
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <ixlib_base.hh>
|
||||
#include <ixlib_exgen.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
namespace ixion {
|
||||
template<class InputIterator>
|
||||
inline std::string concat(InputIterator first,InputIterator last,std::string const &sep = " ") {
|
||||
std::string str;
|
||||
while (first != last) {
|
||||
if (str.size()) str += sep;
|
||||
str += *first++;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
std::string findReplace(std::string const &target,std::string const &src,std::string const &dest);
|
||||
std::string findReplace(std::string const &target,char* src,char *dest);
|
||||
std::string findReplace(std::string const &target,char src,char dest);
|
||||
std::string upper(std::string const &original);
|
||||
std::string lower(std::string const &original);
|
||||
std::string removeLeading(std::string const &original,char ch = ' ');
|
||||
std::string removeTrailing(std::string const &original,char ch = ' ');
|
||||
std::string removeLeadingTrailing(std::string const &original,char ch = ' ');
|
||||
std::string parseCEscapes(std::string const &original);
|
||||
|
||||
TSize getMaxBase64DecodedSize(TSize encoded);
|
||||
// data must provide enough space for the maximal size determined by the
|
||||
// above function
|
||||
TSize base64decode(TByte *data,std::string const &base64);
|
||||
void base64encode(std::string &base64,TByte const *data,TSize size);
|
||||
|
||||
|
||||
|
||||
|
||||
class string_hash {
|
||||
public:
|
||||
unsigned long operator()(std::string const &str) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
85
simgear/interpreter/ixlib_token_javascript.hh
Normal file
85
simgear/interpreter/ixlib_token_javascript.hh
Normal file
@@ -0,0 +1,85 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Token definitions for Javascript scanner
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 2000 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef IXLIB_TOKEN_JAVASCRIPT
|
||||
#define IXLIB_TOKEN_JAVASCRIPT
|
||||
|
||||
|
||||
|
||||
|
||||
#include <ixlib_token_lex.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
// keywords
|
||||
#define TT_JS_THIS (TT_USER + 0)
|
||||
#define TT_JS_FUNCTION (TT_USER + 1)
|
||||
#define TT_JS_VAR (TT_USER + 2)
|
||||
#define TT_JS_NULL (TT_USER + 3)
|
||||
#define TT_JS_IF (TT_USER + 4)
|
||||
#define TT_JS_WHILE (TT_USER + 5)
|
||||
#define TT_JS_DO (TT_USER + 6)
|
||||
#define TT_JS_ELSE (TT_USER + 7)
|
||||
#define TT_JS_FOR (TT_USER + 8)
|
||||
#define TT_JS_RETURN (TT_USER + 9)
|
||||
#define TT_JS_SWITCH (TT_USER + 10)
|
||||
#define TT_JS_CASE (TT_USER + 11)
|
||||
#define TT_JS_CONTINUE (TT_USER + 12)
|
||||
#define TT_JS_BREAK (TT_USER + 13)
|
||||
#define TT_JS_DEFAULT (TT_USER + 14)
|
||||
#define TT_JS_IN (TT_USER + 15)
|
||||
#define TT_JS_CONST (TT_USER + 16)
|
||||
#define TT_JS_CLASS (TT_USER + 17)
|
||||
#define TT_JS_EXTENDS (TT_USER + 18)
|
||||
#define TT_JS_NAMESPACE (TT_USER + 19)
|
||||
#define TT_JS_STATIC (TT_USER + 20)
|
||||
#define TT_JS_CONSTRUCTOR (TT_USER + 21)
|
||||
|
||||
// operators
|
||||
#define TT_JS_NEW (TT_USER + 1024)
|
||||
|
||||
#define TT_JS_PLUS_ASSIGN (TT_USER + 1025)
|
||||
#define TT_JS_MINUS_ASSIGN (TT_USER + 1026)
|
||||
#define TT_JS_MULTIPLY_ASSIGN (TT_USER + 1027)
|
||||
#define TT_JS_DIVIDE_ASSIGN (TT_USER + 1028)
|
||||
#define TT_JS_MODULO_ASSIGN (TT_USER + 1029)
|
||||
#define TT_JS_BIT_XOR_ASSIGN (TT_USER + 1030)
|
||||
#define TT_JS_BIT_AND_ASSIGN (TT_USER + 1031)
|
||||
#define TT_JS_BIT_OR_ASSIGN (TT_USER + 1032)
|
||||
#define TT_JS_LEFT_SHIFT (TT_USER + 1033)
|
||||
#define TT_JS_RIGHT_SHIFT (TT_USER + 1034)
|
||||
#define TT_JS_LEFT_SHIFT_ASSIGN (TT_USER + 1035)
|
||||
#define TT_JS_RIGHT_SHIFT_ASSIGN (TT_USER + 1036)
|
||||
#define TT_JS_EQUAL (TT_USER + 1037)
|
||||
#define TT_JS_NOT_EQUAL (TT_USER + 1038)
|
||||
#define TT_JS_LESS_EQUAL (TT_USER + 1039)
|
||||
#define TT_JS_GREATER_EQUAL (TT_USER + 1040)
|
||||
#define TT_JS_LOGICAL_AND (TT_USER + 1041)
|
||||
#define TT_JS_LOGICAL_OR (TT_USER + 1042)
|
||||
#define TT_JS_INCREMENT (TT_USER + 1043)
|
||||
#define TT_JS_DECREMENT (TT_USER + 1044)
|
||||
#define TT_JS_IDENTICAL (TT_USER + 1045)
|
||||
#define TT_JS_NOT_IDENTICAL (TT_USER + 1046)
|
||||
|
||||
// literals
|
||||
#define TT_JS_LIT_INT (TT_USER + 2048)
|
||||
#define TT_JS_LIT_FLOAT (TT_USER + 2049)
|
||||
#define TT_JS_LIT_STRING (TT_USER + 2050)
|
||||
#define TT_JS_LIT_TRUE (TT_USER + 2051)
|
||||
#define TT_JS_LIT_FALSE (TT_USER + 2052)
|
||||
#define TT_JS_LIT_UNDEFINED (TT_USER + 2053)
|
||||
|
||||
// identifier
|
||||
#define TT_JS_IDENTIFIER (TT_USER + 3072)
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
25
simgear/interpreter/ixlib_token_lex.hh
Normal file
25
simgear/interpreter/ixlib_token_lex.hh
Normal file
@@ -0,0 +1,25 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Basic definitions
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 2000 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef IXLIB_TOKENLEX
|
||||
#define IXLIB_TOKENLEX
|
||||
|
||||
|
||||
|
||||
|
||||
// Basic token types
|
||||
#define TT_EOF 1024
|
||||
#define TT_UNKNOWN 1025
|
||||
#define TT_WHITESPACE 1026
|
||||
#define TT_USER 2048
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
201
simgear/interpreter/js_array.cc
Normal file
201
simgear/interpreter/js_array.cc
Normal file
@@ -0,0 +1,201 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Javascript interpreter
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 2000 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#include <ixlib_js_internals.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
using namespace ixion;
|
||||
using namespace javascript;
|
||||
|
||||
|
||||
|
||||
|
||||
// js_array -------------------------------------------------------------------
|
||||
js_array::
|
||||
js_array(TSize size) {
|
||||
Array.resize(size);
|
||||
|
||||
ref<value> null = javascript::makeNull();
|
||||
for (TIndex i = 0;i < size;i++)
|
||||
Array[i] = makeLValue(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string js_array::stringify() const {
|
||||
value_array::const_iterator first = Array.begin(),last = Array.end();
|
||||
|
||||
string result = "{ ";
|
||||
bool at_first = true;
|
||||
while (first != last) {
|
||||
if (!at_first) result += ',';
|
||||
else at_first = false;
|
||||
result += (*first)->stringify();
|
||||
first++;
|
||||
}
|
||||
return result + " }";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<javascript::value>
|
||||
js_array::
|
||||
duplicate() {
|
||||
ref<value> result = new js_array(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<javascript::value>
|
||||
js_array::
|
||||
lookup(string const &identifier) {
|
||||
if (identifier == "length") return javascript::makeConstant(Array.size());
|
||||
return super::lookup(identifier);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<javascript::value>
|
||||
js_array::
|
||||
subscript(value const &index) {
|
||||
TIndex idx = index.toInt();
|
||||
return operator[](idx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<javascript::value>
|
||||
js_array::
|
||||
callMethod(string const &id,parameter_list const ¶meters) {
|
||||
if (id == "pop" && parameters.size() == 0) {
|
||||
if (Array.size() == 0) return javascript::makeNull();
|
||||
else {
|
||||
ref<value> back = Array.back();
|
||||
Array.pop_back();
|
||||
return back;
|
||||
}
|
||||
}
|
||||
else if (id == "push") {
|
||||
FOREACH_CONST(first,parameters,parameter_list) {
|
||||
Array.push_back((*first)->duplicate());
|
||||
}
|
||||
return javascript::makeConstant(Array.size());
|
||||
}
|
||||
else if (id == "reverse" && parameters.size() == 0) {
|
||||
reverse(Array.begin(),Array.end());
|
||||
return this;
|
||||
}
|
||||
else if (id == "shift" && parameters.size() == 0) {
|
||||
if (Array.size() == 0) return javascript::makeNull();
|
||||
else {
|
||||
ref<value> front = Array.front();
|
||||
Array.erase(Array.begin());
|
||||
return front;
|
||||
}
|
||||
}
|
||||
else if (id == "slice" && parameters.size() == 2) {
|
||||
value_array::const_iterator first = Array.begin() + parameters[0]->toInt();
|
||||
value_array::const_iterator last = Array.begin() + parameters[1]->toInt();
|
||||
|
||||
auto_ptr<js_array> array(new js_array(first,last));
|
||||
return array.release();
|
||||
}
|
||||
else if (id == "unshift") {
|
||||
TIndex i = 0;
|
||||
FOREACH_CONST(first,parameters,parameter_list) {
|
||||
Array.insert(Array.begin() + i++,(*first)->duplicate());
|
||||
}
|
||||
return javascript::makeConstant(Array.size());
|
||||
}
|
||||
else if (id == "join" && parameters.size() == 1) {
|
||||
string sep = parameters[0]->toString();
|
||||
string result;
|
||||
|
||||
for( TIndex i = 0; i < Array.size(); ++i ) {
|
||||
if (i != 0)
|
||||
result += sep;
|
||||
|
||||
result += Array[i]->toString();
|
||||
}
|
||||
|
||||
return javascript::makeValue(result);
|
||||
}
|
||||
// *** FIXME: implement splice and sort
|
||||
|
||||
EXJS_THROWINFO(ECJS_UNKNOWN_IDENTIFIER,("Array."+id).c_str())
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void js_array::resize(TSize size) {
|
||||
if (size >= Array.size()) {
|
||||
TSize prevsize = Array.size();
|
||||
|
||||
Array.resize(size);
|
||||
|
||||
ref<value> null = javascript::makeNull();
|
||||
for (TIndex i = prevsize;i < size;i++)
|
||||
Array[i] = makeLValue(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> &js_array::operator[](TIndex idx) {
|
||||
if (idx >= Array.size())
|
||||
resize((Array.size()+1)*2);
|
||||
|
||||
return Array[idx];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void js_array::push_back(ref<value> val) {
|
||||
Array.push_back(val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// js_array_constructor -------------------------------------------------------
|
||||
ref<javascript::value> js_array_constructor::duplicate() {
|
||||
// array_constructor is not mutable
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<javascript::value>
|
||||
js_array_constructor::
|
||||
construct(parameter_list const ¶meters) {
|
||||
if (parameters.size() == 0) return makeArray();
|
||||
else if (parameters.size() == 1) return makeArray(parameters[0]->toInt());
|
||||
else /* parameters.size() >= 2 */ {
|
||||
auto_ptr<js_array> result(new js_array(parameters.size()));
|
||||
|
||||
TIndex i = 0;
|
||||
FOREACH_CONST(first,parameters,parameter_list) {
|
||||
(*result)[i++] = (*first)->duplicate();
|
||||
}
|
||||
return result.release();
|
||||
}
|
||||
}
|
||||
216
simgear/interpreter/js_declaration.cc
Normal file
216
simgear/interpreter/js_declaration.cc
Normal file
@@ -0,0 +1,216 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Javascript interpreter
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 2000 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#include <ixlib_js_internals.hh>
|
||||
#include <ixlib_token_javascript.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
#define EXJS_ADD_CODE_LOCATION \
|
||||
catch (no_location_javascript_exception &half) { \
|
||||
throw javascript_exception(half,getCodeLocation()); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
using namespace ixion;
|
||||
using namespace javascript;
|
||||
|
||||
|
||||
|
||||
|
||||
// variable_declaration -------------------------------------------------------
|
||||
variable_declaration::variable_declaration(string const &id,ref<expression> def_value,code_location const &loc)
|
||||
: expression(loc),Identifier(id),DefaultValue(def_value) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> variable_declaration::evaluate(context const &ctx) const {
|
||||
try {
|
||||
ref<value> def;
|
||||
if (DefaultValue.get() != NULL) def = DefaultValue->evaluate(ctx)->eliminateWrappers()->duplicate();
|
||||
else def = makeNull();
|
||||
|
||||
ref<value> lv = makeLValue(def);
|
||||
ctx.DeclarationScope->addMember(Identifier,lv);
|
||||
return lv;
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// constant_declaration -------------------------------------------------------
|
||||
constant_declaration::constant_declaration(string const &id,ref<expression> def_value,code_location const &loc)
|
||||
: expression(loc),Identifier(id),DefaultValue(def_value) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> constant_declaration::evaluate(context const &ctx) const {
|
||||
try {
|
||||
ref<value> def;
|
||||
if (DefaultValue.get() != NULL) def = DefaultValue->evaluate(ctx)->eliminateWrappers()->duplicate();
|
||||
else def = makeNull();
|
||||
|
||||
ref<value> cns = wrapConstant(def);
|
||||
ctx.DeclarationScope->addMember(Identifier,cns);
|
||||
return cns;
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// function_declaration -------------------------------------------------------
|
||||
function_declaration::
|
||||
function_declaration(string const &id,parameter_name_list const &pnames,
|
||||
ref<expression> body,code_location const &loc)
|
||||
: expression(loc),Identifier(id),ParameterNameList(pnames),Body(body) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> function_declaration::evaluate(context const &ctx) const {
|
||||
try {
|
||||
ref<value> fun = new function(ParameterNameList,Body,ctx.LookupScope);
|
||||
ctx.DeclarationScope->addMember(Identifier,fun);
|
||||
return ref<value>(NULL);
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// method_declaration ---------------------------------------------------------
|
||||
method_declaration::
|
||||
method_declaration(string const &id,parameter_name_list const &pnames,
|
||||
ref<expression> body,code_location const &loc)
|
||||
: expression(loc),Identifier(id),ParameterNameList(pnames),Body(body) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> method_declaration::evaluate(context const &ctx) const {
|
||||
try {
|
||||
ref<value> fun = new method(ParameterNameList,Body,ctx.LookupScope);
|
||||
ctx.DeclarationScope->addMember(Identifier,fun);
|
||||
return ref<value>(NULL);
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// constructor_declaration ---------------------------------------------------------
|
||||
constructor_declaration::
|
||||
constructor_declaration(parameter_name_list const &pnames,
|
||||
ref<expression> body,code_location const &loc)
|
||||
: expression(loc),ParameterNameList(pnames),Body(body) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> constructor_declaration::evaluate(context const &ctx) const {
|
||||
try {
|
||||
ref<value> fun = new constructor(ParameterNameList,Body,ctx.LookupScope);
|
||||
return fun;
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// js_class_declaration -------------------------------------------------------
|
||||
js_class_declaration::js_class_declaration(string const &id,ref<expression> superclass,code_location const &loc)
|
||||
: expression(loc),Identifier(id),SuperClass(superclass) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> js_class_declaration::evaluate(context const &ctx) const {
|
||||
try {
|
||||
ref<list_scope,value> sml(new list_scope);
|
||||
ref<list_scope,value> ml(new list_scope);
|
||||
ref<list_scope,value> svl(new list_scope);
|
||||
|
||||
ref<value> sc;
|
||||
if (SuperClass.get())
|
||||
sc = SuperClass->evaluate(ctx);
|
||||
|
||||
ref<value> constructor;
|
||||
if (ConstructorDeclaration.get())
|
||||
constructor = ConstructorDeclaration->evaluate(ctx);
|
||||
ref<value> cls(new js_class(ctx.LookupScope,sc,constructor,sml,ml,svl,VariableList));
|
||||
|
||||
ref<list_scope,value> static_scope(new list_scope);
|
||||
static_scope->unite(ctx.LookupScope);
|
||||
static_scope->unite(cls);
|
||||
|
||||
FOREACH_CONST(first,StaticMethodList,declaration_list)
|
||||
(*first)->evaluate(context(sml,static_scope));
|
||||
FOREACH_CONST(first,MethodList,declaration_list)
|
||||
(*first)->evaluate(context(ml,ctx.LookupScope));
|
||||
FOREACH_CONST(first,StaticVariableList,declaration_list)
|
||||
(*first)->evaluate(context(svl,static_scope));
|
||||
|
||||
ctx.DeclarationScope->addMember(Identifier,cls);
|
||||
return cls;
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void js_class_declaration::setConstructor(ref<expression> decl) {
|
||||
ConstructorDeclaration = decl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void js_class_declaration::addStaticMethod(ref<expression> decl) {
|
||||
StaticMethodList.push_back(decl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void js_class_declaration::addMethod(ref<expression> decl) {
|
||||
MethodList.push_back(decl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void js_class_declaration::addStaticVariable(ref<expression> decl) {
|
||||
StaticVariableList.push_back(decl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void js_class_declaration::addVariable(ref<expression> decl) {
|
||||
VariableList.push_back(decl);
|
||||
}
|
||||
310
simgear/interpreter/js_expression.cc
Normal file
310
simgear/interpreter/js_expression.cc
Normal file
@@ -0,0 +1,310 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Javascript interpreter
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 2000 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#include <ixlib_js_internals.hh>
|
||||
#include <ixlib_token_javascript.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
#define EXJS_ADD_CODE_LOCATION \
|
||||
catch (no_location_javascript_exception &half) { \
|
||||
throw javascript_exception(half,getCodeLocation()); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
using namespace ixion;
|
||||
using namespace javascript;
|
||||
|
||||
|
||||
|
||||
|
||||
// expression -----------------------------------------------------------------
|
||||
expression::expression(code_location const &loc)
|
||||
: Location(loc) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
expression::~expression() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// constant -------------------------------------------------------------------
|
||||
constant::constant(ref<value> val,code_location const &loc)
|
||||
: expression(loc),Value(val) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value>
|
||||
constant::
|
||||
evaluate(context const &ctx) const {
|
||||
return Value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// unary_operator -------------------------------------------------
|
||||
unary_operator::unary_operator(value::operator_id opt,ref<expression> opn,code_location const &loc)
|
||||
: expression(loc),Operator(opt),Operand(opn) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value>
|
||||
unary_operator::
|
||||
evaluate(context const &ctx) const {
|
||||
try {
|
||||
return Operand->evaluate(ctx)->operatorUnary(Operator);
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// modifying_unary_operator ---------------------------------------------------
|
||||
modifying_unary_operator::
|
||||
modifying_unary_operator(value::operator_id opt,ref<expression> opn,code_location const &loc)
|
||||
: expression(loc),Operator(opt),Operand(opn) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value>
|
||||
modifying_unary_operator::
|
||||
evaluate(context const &ctx) const {
|
||||
try {
|
||||
return Operand->evaluate(ctx)->operatorUnaryModifying(Operator);
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// binary_operator ------------------------------------------------------------
|
||||
binary_operator::binary_operator(value::operator_id opt,ref<expression> opn1,ref<expression> opn2,code_location const &loc)
|
||||
: expression(loc),Operator(opt),Operand1(opn1),Operand2(opn2) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> binary_operator::evaluate(context const &ctx) const {
|
||||
try {
|
||||
return Operand1->evaluate(ctx)->operatorBinary(Operator,Operand2->evaluate(ctx));
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// binary_shortcut_operator ---------------------------------------------------
|
||||
binary_shortcut_operator::binary_shortcut_operator(value::operator_id opt,ref<expression> opn1,ref<expression> opn2,code_location const &loc)
|
||||
: expression(loc),Operator(opt),Operand1(opn1),Operand2(opn2) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> binary_shortcut_operator::evaluate(context const &ctx) const {
|
||||
try {
|
||||
return Operand1->evaluate(ctx)->operatorBinaryShortcut(Operator,*Operand2,ctx);
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// modifying_binary_operator --------------------------------------
|
||||
modifying_binary_operator::
|
||||
modifying_binary_operator(value::operator_id opt,ref<expression> opn1,ref<expression> opn2,code_location const &loc)
|
||||
: expression(loc),Operator(opt),Operand1(opn1),Operand2(opn2) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value>
|
||||
modifying_binary_operator::
|
||||
evaluate(context const &ctx) const {
|
||||
try {
|
||||
return Operand1->evaluate(ctx)->operatorBinaryModifying(Operator,Operand2->evaluate(ctx));
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ternary_operator -----------------------------------------------------------
|
||||
ternary_operator::
|
||||
ternary_operator(ref<expression> opn1,ref<expression> opn2,ref<expression> opn3,code_location const &loc)
|
||||
: expression(loc),Operand1(opn1),Operand2(opn2),Operand3(opn3) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value>
|
||||
ternary_operator::
|
||||
evaluate(context const &ctx) const {
|
||||
try {
|
||||
if (Operand1->evaluate(ctx)->toBoolean())
|
||||
return Operand2->evaluate(ctx);
|
||||
else
|
||||
return Operand3->evaluate(ctx);
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// subscript_operation --------------------------------------------------------
|
||||
subscript_operation::subscript_operation(ref<expression> opn1,ref<expression> opn2,code_location const &loc)
|
||||
: expression(loc),Operand1(opn1),Operand2(opn2) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> subscript_operation::evaluate(context const &ctx) const {
|
||||
try {
|
||||
ref<value> op2 = Operand2->evaluate(ctx);
|
||||
return Operand1->evaluate(ctx)->subscript(*op2);
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// lookup_operation -----------------------------------------------------------
|
||||
lookup_operation::lookup_operation(string const &id,code_location const &loc)
|
||||
: expression(loc),Identifier(id) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
lookup_operation::lookup_operation(ref<expression> opn,string const &id,code_location const &loc)
|
||||
: expression(loc),Operand(opn),Identifier(id) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> lookup_operation::evaluate(context const &ctx) const {
|
||||
try {
|
||||
ref<value> scope(ctx.LookupScope);
|
||||
if (Operand.get() != NULL)
|
||||
scope = Operand->evaluate(ctx);
|
||||
return scope->lookup(Identifier);
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// assignment -----------------------------------------------------------------
|
||||
assignment::
|
||||
assignment(ref<expression> opn1,ref<expression> opn2,code_location const &loc)
|
||||
: expression(loc),Operand1(opn1),Operand2(opn2) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value>
|
||||
assignment::evaluate(context const &ctx) const {
|
||||
try {
|
||||
return Operand1->evaluate(ctx)->assign(Operand2->evaluate(ctx)->eliminateWrappers()->duplicate());
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// basic_call -----------------------------------------------------------------
|
||||
basic_call::basic_call(parameter_expression_list const &pexps,code_location const &loc)
|
||||
: expression(loc),ParameterExpressionList(pexps) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void basic_call::makeParameterValueList(context const &ctx,parameter_value_list &pvalues) const {
|
||||
FOREACH_CONST(first,ParameterExpressionList,parameter_expression_list) {
|
||||
pvalues.push_back((*first)->evaluate(ctx));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// function_call --------------------------------------------------------------
|
||||
function_call::function_call(ref<expression> fun,parameter_expression_list const &pexps,code_location const &loc)
|
||||
: super(pexps,loc),Function(fun) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> function_call::evaluate(context const &ctx) const {
|
||||
try {
|
||||
ref<value> func_value = Function->evaluate(ctx);
|
||||
|
||||
value::parameter_list pvalues;
|
||||
makeParameterValueList(ctx,pvalues);
|
||||
ref<value> result = func_value->call(pvalues);
|
||||
|
||||
if (result.get() == NULL) return makeNull();
|
||||
else return result;
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// construction ---------------------------------------------------------------
|
||||
construction::construction(ref<expression> cls,parameter_expression_list const &pexps,code_location const &loc)
|
||||
: super(pexps,loc),Class(cls) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> construction::evaluate(context const &ctx) const {
|
||||
try {
|
||||
ref<value> class_value = Class->evaluate(ctx);
|
||||
|
||||
value::parameter_list pvalues;
|
||||
makeParameterValueList(ctx,pvalues);
|
||||
|
||||
return class_value->construct(pvalues);
|
||||
}
|
||||
EXJS_ADD_CODE_LOCATION
|
||||
}
|
||||
413
simgear/interpreter/js_instruction.cc
Normal file
413
simgear/interpreter/js_instruction.cc
Normal file
@@ -0,0 +1,413 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Javascript interpreter
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 2000 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#include <ixlib_js_internals.hh>
|
||||
#include <ixlib_token_javascript.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
using namespace ixion;
|
||||
using namespace javascript;
|
||||
|
||||
|
||||
|
||||
|
||||
// instruction_list -----------------------------------------------------------
|
||||
ref<value>
|
||||
instruction_list::evaluate(context const &ctx) const {
|
||||
ref<value> result;
|
||||
FOREACH_CONST(first,ExpressionList,expression_list)
|
||||
result = (*first)->evaluate(ctx);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void instruction_list::add(ref<expression> expr) {
|
||||
ExpressionList.push_back(expr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// scoped_instruction_list ----------------------------------------
|
||||
ref<value> scoped_instruction_list::evaluate(context const &ctx) const {
|
||||
ref<list_scope,value> scope = new list_scope;
|
||||
scope->unite(ctx.LookupScope);
|
||||
|
||||
ref<value> result = instruction_list::evaluate(context(scope));
|
||||
if (result.get()) return result->duplicate();
|
||||
return ref<value>(NULL);
|
||||
|
||||
// ATTENTION: this is a scope cancellation point.
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// js_if ----------------------------------------------------------------------
|
||||
js_if::js_if(ref<expression> cond,ref<expression> ifex,ref<expression> ifnotex,code_location const &loc)
|
||||
: expression(loc),Conditional(cond),IfExpression(ifex),IfNotExpression(ifnotex) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> js_if::evaluate(context const &ctx) const {
|
||||
if (Conditional->evaluate(ctx)->toBoolean())
|
||||
return IfExpression->evaluate(ctx);
|
||||
else
|
||||
if (IfNotExpression.get())
|
||||
return IfNotExpression->evaluate(ctx);
|
||||
else
|
||||
return ref<value>(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// js_while -------------------------------------------------------------------
|
||||
js_while::js_while(ref<expression> cond,ref<expression> loopex,code_location const &loc)
|
||||
: expression(loc),Conditional(cond),LoopExpression(loopex),HasLabel(false) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
js_while::js_while(ref<expression> cond,ref<expression> loopex,string const &label,code_location const &loc)
|
||||
: expression(loc),Conditional(cond),LoopExpression(loopex),HasLabel(true),Label(label) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> js_while::evaluate(context const &ctx) const {
|
||||
ref<value> result;
|
||||
while (Conditional->evaluate(ctx)->toBoolean()) {
|
||||
try {
|
||||
result = LoopExpression->evaluate(ctx);
|
||||
}
|
||||
catch (break_exception &be) {
|
||||
if (!be.HasLabel || (HasLabel && be.HasLabel && be.Label == Label))
|
||||
break;
|
||||
else throw;
|
||||
}
|
||||
catch (continue_exception &ce) {
|
||||
if (!ce.HasLabel || (HasLabel && ce.HasLabel && ce.Label == Label))
|
||||
continue;
|
||||
else throw;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// js_do_while ----------------------------------------------------------------
|
||||
js_do_while::js_do_while(ref<expression> cond,ref<expression> loopex,code_location const &loc)
|
||||
: expression(loc),Conditional(cond),LoopExpression(loopex),HasLabel(false) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
js_do_while::js_do_while(ref<expression> cond,ref<expression> loopex,string const &label,code_location const &loc)
|
||||
: expression(loc),Conditional(cond),LoopExpression(loopex),HasLabel(true),Label(label) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> js_do_while::evaluate(context const &ctx) const {
|
||||
ref<value> result;
|
||||
do {
|
||||
try {
|
||||
result = LoopExpression->evaluate(ctx);
|
||||
}
|
||||
catch (break_exception &be) {
|
||||
if (!be.HasLabel || (HasLabel && be.HasLabel && be.Label == Label))
|
||||
break;
|
||||
else throw;
|
||||
}
|
||||
catch (continue_exception &ce) {
|
||||
if (!ce.HasLabel || (HasLabel && ce.HasLabel && ce.Label == Label))
|
||||
continue;
|
||||
else throw;
|
||||
}
|
||||
} while (Conditional->evaluate(ctx)->toBoolean());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// js_for ---------------------------------------------------------------------
|
||||
js_for::js_for(ref<expression> init,ref<expression> cond,ref<expression> update,ref<expression> loop,code_location const &loc)
|
||||
: expression(loc),Initialization(init),Conditional(cond),Update(update),
|
||||
LoopExpression(loop),HasLabel(false) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
js_for::js_for(ref<expression> init,ref<expression> cond,ref<expression> update,ref<expression> loop,string const &label,code_location const &loc)
|
||||
: expression(loc),Initialization(init),Conditional(cond),Update(update),LoopExpression(loop),
|
||||
HasLabel(true),Label(label) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> js_for::evaluate(context const &ctx) const {
|
||||
ref<list_scope,value> scope = new list_scope;
|
||||
scope->unite(ctx.LookupScope);
|
||||
context inner_context(scope);
|
||||
|
||||
ref<value> result;
|
||||
for (Initialization->evaluate(inner_context);Conditional->evaluate(inner_context)->toBoolean();
|
||||
Update->evaluate(inner_context)) {
|
||||
try {
|
||||
result = LoopExpression->evaluate(inner_context);
|
||||
}
|
||||
catch (break_exception &be) {
|
||||
if (!be.HasLabel || (HasLabel && be.HasLabel && be.Label == Label))
|
||||
break;
|
||||
else throw;
|
||||
}
|
||||
catch (continue_exception &ce) {
|
||||
if (!ce.HasLabel || (HasLabel && ce.HasLabel && ce.Label == Label))
|
||||
continue;
|
||||
else throw;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// js_for_in ------------------------------------------------------------------
|
||||
js_for_in::js_for_in(ref<expression> iter,ref<expression> array,ref<expression> loop,code_location const &loc)
|
||||
: expression(loc),Iterator(iter),Array(array),LoopExpression(loop),HasLabel(false) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
js_for_in::js_for_in(ref<expression> iter,ref<expression> array,ref<expression> loop,string const &label,code_location const &loc)
|
||||
: expression(loc),Iterator(iter),Array(array),LoopExpression(loop),
|
||||
HasLabel(true),Label(label) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> js_for_in::evaluate(context const &ctx) const {
|
||||
ref<list_scope,value> scope = new list_scope;
|
||||
scope->unite(ctx.LookupScope);
|
||||
context inner_context(scope);
|
||||
|
||||
ref<value> result;
|
||||
ref<value> iterator = Iterator->evaluate(inner_context);
|
||||
ref<value> array = Array->evaluate(inner_context);
|
||||
|
||||
TSize size = array->lookup("length")->toInt();
|
||||
|
||||
for (TIndex i = 0;i < size;i++) {
|
||||
try {
|
||||
iterator->assign(array->subscript(*makeConstant(i)));
|
||||
result = LoopExpression->evaluate(inner_context);
|
||||
}
|
||||
catch (break_exception &be) {
|
||||
if (!be.HasLabel || (HasLabel && be.HasLabel && be.Label == Label))
|
||||
break;
|
||||
else throw;
|
||||
}
|
||||
catch (continue_exception &ce) {
|
||||
if (!ce.HasLabel || (HasLabel && ce.HasLabel && ce.Label == Label))
|
||||
continue;
|
||||
else throw;
|
||||
}
|
||||
}
|
||||
if (result.get()) return result->duplicate();
|
||||
return ref<value>(NULL);
|
||||
|
||||
// ATTENTION: this is a scope cancellation point.
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// js_return ------------------------------------------------------------------
|
||||
js_return::js_return(ref<expression> retval,code_location const &loc)
|
||||
: expression(loc),ReturnValue(retval) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> js_return::evaluate(context const &ctx) const {
|
||||
ref<value> retval;
|
||||
if (ReturnValue.get())
|
||||
retval = ReturnValue->evaluate(ctx);
|
||||
|
||||
throw return_exception(retval,getCodeLocation());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// js_break -------------------------------------------------------------------
|
||||
js_break::js_break(code_location const &loc)
|
||||
: expression(loc),HasLabel(false) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
js_break::js_break(string const &label,code_location const &loc)
|
||||
: expression(loc),HasLabel(true),Label(label) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> js_break::evaluate(context const &ctx) const {
|
||||
throw break_exception(HasLabel,Label,getCodeLocation());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// js_continue ----------------------------------------------------------------
|
||||
js_continue::js_continue(code_location const &loc)
|
||||
: expression(loc),HasLabel(false) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
js_continue::js_continue(string const &label,code_location const &loc)
|
||||
: expression(loc),HasLabel(true),Label(label) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> js_continue::evaluate(context const &ctx) const {
|
||||
throw continue_exception(HasLabel,Label,getCodeLocation());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// break_label ----------------------------------------------------------------
|
||||
break_label::break_label(string const &label,ref<expression> expr,code_location const &loc)
|
||||
: expression(loc),Label(label),Expression(expr) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value>
|
||||
break_label::evaluate(context const &ctx) const {
|
||||
try {
|
||||
return Expression->evaluate(ctx);
|
||||
}
|
||||
catch (break_exception &be) {
|
||||
if (be.HasLabel && be.Label == Label) return ref<value>(NULL);
|
||||
else throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// js_switch -----------------------------------------------------------------
|
||||
js_switch::js_switch(ref<expression> discriminant,code_location const &loc)
|
||||
: expression(loc),HasLabel(false),Discriminant(discriminant) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
js_switch::js_switch(ref<expression> discriminant,string const &label,code_location const &loc)
|
||||
: expression(loc),HasLabel(true),Label(label),Discriminant(discriminant) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value>
|
||||
js_switch::
|
||||
evaluate(context const &ctx) const {
|
||||
ref<list_scope,value> scope = new list_scope;
|
||||
scope->unite(ctx.LookupScope);
|
||||
context inner_context(scope);
|
||||
|
||||
ref<value> discr = Discriminant->evaluate(inner_context);
|
||||
|
||||
case_list::const_iterator expr,def;
|
||||
bool expr_found = false,def_found = false;
|
||||
FOREACH_CONST(first,CaseList,case_list) {
|
||||
if (first->DiscriminantValue.get()) {
|
||||
if (first->DiscriminantValue->evaluate(inner_context)->
|
||||
operatorBinary(value::OP_EQUAL,Discriminant->evaluate(inner_context))->toBoolean()) {
|
||||
expr = first;
|
||||
expr_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!def_found) {
|
||||
def = first;
|
||||
def_found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
case_list::const_iterator exec,last = CaseList.end();
|
||||
if (expr_found)
|
||||
exec = expr;
|
||||
else if (def_found)
|
||||
exec = def;
|
||||
else
|
||||
return ref<value>(NULL);
|
||||
|
||||
ref<value> result;
|
||||
while (exec != last) {
|
||||
result = exec->Expression->evaluate(inner_context);
|
||||
exec++;
|
||||
}
|
||||
if (result.get()) return result->duplicate();
|
||||
return ref<value>(NULL);
|
||||
}
|
||||
catch (break_exception &be) {
|
||||
if (!be.HasLabel || (HasLabel && be.HasLabel && be.Label == Label))
|
||||
return ref<value>(NULL);
|
||||
else
|
||||
throw;
|
||||
}
|
||||
|
||||
// ATTENTION: this is a scope cancellation point.
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void js_switch::addCase(ref<expression> dvalue,ref<expression> expr) {
|
||||
case_label cl;
|
||||
cl.DiscriminantValue = dvalue;
|
||||
cl.Expression = expr;
|
||||
CaseList.push_back(cl);
|
||||
}
|
||||
1133
simgear/interpreter/js_interpreter.cc
Normal file
1133
simgear/interpreter/js_interpreter.cc
Normal file
File diff suppressed because it is too large
Load Diff
259
simgear/interpreter/js_library.cc
Normal file
259
simgear/interpreter/js_library.cc
Normal file
@@ -0,0 +1,259 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Javascript interpreter library
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 2000 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <ixlib_js_internals.hh>
|
||||
#include <ixlib_numconv.hh>
|
||||
#include <ixlib_random.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
using namespace ixion;
|
||||
using namespace javascript;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace {
|
||||
class eval : public value {
|
||||
protected:
|
||||
interpreter &Interpreter;
|
||||
|
||||
public:
|
||||
value_type getType() const {
|
||||
return VT_FUNCTION;
|
||||
}
|
||||
eval(interpreter &interpreter)
|
||||
: Interpreter(interpreter) {
|
||||
}
|
||||
ref<value> call(parameter_list const ¶meters);
|
||||
};
|
||||
|
||||
class Math : public value_with_methods {
|
||||
private:
|
||||
typedef value_with_methods super;
|
||||
|
||||
protected:
|
||||
float_random RNG;
|
||||
|
||||
public:
|
||||
value_type getType() const {
|
||||
return VT_BUILTIN;
|
||||
}
|
||||
|
||||
ref<value> duplicate() const;
|
||||
|
||||
ref<value> lookup(string const &identifier);
|
||||
ref<value> callMethod(string const &identifier,parameter_list const ¶meters);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// eval -----------------------------------------------------------------------
|
||||
ref<value>
|
||||
eval::
|
||||
call(parameter_list const ¶meters) {
|
||||
if (parameters.size() != 1) {
|
||||
EXJS_THROWINFO(ECJS_INVALID_NUMBER_OF_ARGUMENTS,"eval")
|
||||
}
|
||||
if (parameters[0]->getType() != VT_STRING) return parameters[0];
|
||||
return Interpreter.execute(parameters[0]->toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// parseInt -------------------------------------------------------------------
|
||||
IXLIB_JS_DECLARE_FUNCTION(parseInt) {
|
||||
if (parameters.size() != 1 && parameters.size() != 2) {
|
||||
EXJS_THROWINFO(ECJS_INVALID_NUMBER_OF_ARGUMENTS,"parseInt")
|
||||
}
|
||||
unsigned radix = 10;
|
||||
if (parameters.size() == 2)
|
||||
radix = parameters[1]->toInt();
|
||||
return makeConstant(evalSigned(parameters[0]->toString(),radix));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// parseFloat -----------------------------------------------------------------
|
||||
IXLIB_JS_DECLARE_FUNCTION(parseFloat) {
|
||||
if (parameters.size() != 1) {
|
||||
EXJS_THROWINFO(ECJS_INVALID_NUMBER_OF_ARGUMENTS,"parseFloat")
|
||||
}
|
||||
return makeConstant(evalFloat(parameters[0]->toString()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// isNaN ----------------------------------------------------------------------
|
||||
#ifdef ADVANCED_MATH_AVAILABLE
|
||||
IXLIB_JS_DECLARE_FUNCTION(isNaN) {
|
||||
if (parameters.size() != 1) {
|
||||
EXJS_THROWINFO(ECJS_INVALID_NUMBER_OF_ARGUMENTS,"isNaN")
|
||||
}
|
||||
int classification = fpclassify(parameters[0]->toFloat());
|
||||
return makeConstant(classification == FP_NAN);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
// isFinite -------------------------------------------------------------------
|
||||
#ifdef ADVANCED_MATH_AVAILABLE
|
||||
IXLIB_JS_DECLARE_FUNCTION(isFinite) {
|
||||
if (parameters.size() != 1) {
|
||||
EXJS_THROWINFO(ECJS_INVALID_NUMBER_OF_ARGUMENTS,"isFinite")
|
||||
}
|
||||
int classification = fpclassify(parameters[0]->toFloat());
|
||||
return makeConstant(classification != FP_NAN && classification != FP_INFINITE);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
// Math -----------------------------------------------------------------------
|
||||
ref<value> Math::duplicate() const {
|
||||
// Math is not mutable
|
||||
return const_cast<Math *>(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> Math::lookup(string const &identifier) {
|
||||
#define MATH_CONSTANT(NAME,VALUE) \
|
||||
if (identifier == NAME) return makeConstant(VALUE);
|
||||
|
||||
MATH_CONSTANT("E",2.7182818284590452354)
|
||||
MATH_CONSTANT("LN10",2.30258509299404568402)
|
||||
MATH_CONSTANT("LN2",0.69314718055994530942)
|
||||
MATH_CONSTANT("LOG2E",1.4426950408889634074)
|
||||
MATH_CONSTANT("LOG10E,",0.43429448190325182765)
|
||||
MATH_CONSTANT("PI",3.14159265358979323846)
|
||||
MATH_CONSTANT("SQRT1_2",0.70710678118654752440)
|
||||
MATH_CONSTANT("SQRT2",1.41421356237309504880)
|
||||
|
||||
return super::lookup(identifier);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ref<value> Math::callMethod(string const &identifier,parameter_list const ¶meters) {
|
||||
#define MATH_FUNCTION(NAME,C_NAME) \
|
||||
if (identifier == NAME) { \
|
||||
if (parameters.size() != 1) { \
|
||||
EXJS_THROWINFO(ECJS_INVALID_NUMBER_OF_ARGUMENTS,"Math." NAME) \
|
||||
} \
|
||||
return makeConstant(C_NAME(parameters[0]->toFloat())); \
|
||||
}
|
||||
|
||||
MATH_FUNCTION("abs",NUM_ABS)
|
||||
MATH_FUNCTION("acos",acos)
|
||||
MATH_FUNCTION("asin",asin)
|
||||
MATH_FUNCTION("atan",atan)
|
||||
MATH_FUNCTION("ceil",ceil)
|
||||
MATH_FUNCTION("cos",cos)
|
||||
MATH_FUNCTION("exp",exp)
|
||||
MATH_FUNCTION("floor",floor)
|
||||
MATH_FUNCTION("log",log)
|
||||
#ifdef ADVANCED_MATH_AVAILABLE
|
||||
MATH_FUNCTION("round",round)
|
||||
#endif
|
||||
MATH_FUNCTION("sin",sin)
|
||||
MATH_FUNCTION("sqrt",sqrt)
|
||||
MATH_FUNCTION("tan",tan)
|
||||
if (identifier == "atan2") {
|
||||
if (parameters.size() != 2) {
|
||||
EXJS_THROWINFO(ECJS_INVALID_NUMBER_OF_ARGUMENTS,"Math.atan2")
|
||||
}
|
||||
return makeConstant(atan2(parameters[0]->toFloat(),parameters[1]->toFloat()));
|
||||
}
|
||||
if (identifier == "pow") {
|
||||
if (parameters.size() != 2) {
|
||||
EXJS_THROWINFO(ECJS_INVALID_NUMBER_OF_ARGUMENTS,"Math.pow")
|
||||
}
|
||||
return makeConstant(pow(parameters[0]->toFloat(),parameters[1]->toFloat()));
|
||||
}
|
||||
if (identifier == "random") {
|
||||
if (parameters.size() != 0) {
|
||||
EXJS_THROWINFO(ECJS_INVALID_NUMBER_OF_ARGUMENTS,"Math.random")
|
||||
}
|
||||
return makeConstant(RNG());
|
||||
}
|
||||
// *** FIXME this is non-compliant, but there is no equivalent standard function
|
||||
if (identifier == "initRandom") {
|
||||
if (parameters.size() >= 2) {
|
||||
EXJS_THROWINFO(ECJS_INVALID_NUMBER_OF_ARGUMENTS,"Math.initRandom")
|
||||
}
|
||||
if (parameters.size() == 0)
|
||||
RNG.init();
|
||||
else if (parameters.size() == 1)
|
||||
RNG.init(parameters[0]->toFloat());
|
||||
return makeNull();
|
||||
}
|
||||
|
||||
// *** FIXME: implement max, min
|
||||
EXJS_THROWINFO(ECJS_UNKNOWN_IDENTIFIER,("Math." + identifier).c_str())
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// external interface functions -----------------------------------------------
|
||||
#define ADD_GLOBAL_OBJECT(NAME,TYPE) \
|
||||
{ ref<value> x = new TYPE(); \
|
||||
ip.RootScope->addMember(NAME,x); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void javascript::addGlobal(interpreter &ip) {
|
||||
ref<value> ev = new eval(ip);
|
||||
ip.RootScope->addMember("eval",ev);
|
||||
|
||||
ADD_GLOBAL_OBJECT("parseInt",parseInt)
|
||||
ADD_GLOBAL_OBJECT("parseFloat",parseFloat)
|
||||
#ifdef ADVANCED_MATH_AVAILABLE
|
||||
ADD_GLOBAL_OBJECT("isNaN",isNaN)
|
||||
ADD_GLOBAL_OBJECT("isFinite",isFinite)
|
||||
#endif
|
||||
|
||||
// *** FIXME hope this is portable
|
||||
float zero = 0;
|
||||
ip.RootScope->addMember("NaN",makeConstant(0.0/zero));
|
||||
ip.RootScope->addMember("Infinity",makeConstant(1.0/zero));
|
||||
ip.RootScope->addMember("undefined",makeUndefined());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void javascript::addMath(interpreter &ip) {
|
||||
ADD_GLOBAL_OBJECT("Math",Math)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void javascript::addStandardLibrary(interpreter &ip) {
|
||||
addGlobal(ip);
|
||||
addMath(ip);
|
||||
}
|
||||
1967
simgear/interpreter/js_value.cc
Normal file
1967
simgear/interpreter/js_value.cc
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user