Compare commits
355 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 |
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
|
||||
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 =
|
||||
102
Makefile.am
102
Makefile.am
@@ -1,99 +1,21 @@
|
||||
EXTRA_DIST = mksymlinks.sh acsite.m4 acconfig.h
|
||||
EXTRA_DIST = \
|
||||
acinclude.m4 \
|
||||
autogen.sh \
|
||||
mksymlinks.sh \
|
||||
README.MSVC \
|
||||
README.metakit \
|
||||
README.zlib \
|
||||
SimGear.dsp \
|
||||
SimGear.dsw
|
||||
|
||||
SUBDIRS = simgear
|
||||
|
||||
#
|
||||
# Additional all, clean, and distclean rules for additional packages.
|
||||
# We can't just include the additional package dirs in SUBDIRS (which
|
||||
# would be nice because there are then problems with make dist
|
||||
#
|
||||
|
||||
all:
|
||||
@list='@subdirs@'; \
|
||||
target=`echo $@`; \
|
||||
for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done
|
||||
|
||||
install:
|
||||
@list='@subdirs@'; \
|
||||
target=`echo $@`; \
|
||||
for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done
|
||||
|
||||
clean:
|
||||
@list='@subdirs@'; \
|
||||
target=`echo $@`; \
|
||||
for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done
|
||||
|
||||
distclean:
|
||||
@list='@subdirs@'; \
|
||||
target=`echo $@`; \
|
||||
for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done
|
||||
|
||||
#
|
||||
# distclean the associated packages and include them in the dist
|
||||
#
|
||||
SUBDIRS = src-libs simgear
|
||||
|
||||
dist-hook:
|
||||
tar cf - simgear/metar | (cd $(distdir); tar xvf -)
|
||||
@list='@subdirs@'; \
|
||||
target=distclean; \
|
||||
for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) echo "distclean error ignored...";; *k*) fail=yes;; *) echo "distclean error ignored...";; esac; \
|
||||
done
|
||||
tar cf - simgear/metakit | (cd $(distdir); tar xvf -)
|
||||
|
||||
(cd $(top_srcdir); $(HOME)/projects/FlightGear-0.7/admin/am2dsp.pl)
|
||||
|
||||
#
|
||||
# Rule to build RPM distribution package
|
||||
#
|
||||
rpm: dist
|
||||
cp $(PACKAGE)-$(VERSION).tar.gz /usr/src/packages/SOURCES
|
||||
rpm -ba @PACKAGE@.spec
|
||||
rpm -ta $(PACKAGE)-$(VERSION).tar.gz
|
||||
|
||||
|
||||
169
NEWS
169
NEWS
@@ -1,3 +1,165 @@
|
||||
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)
|
||||
@@ -8,6 +170,7 @@ New in 0.0.13
|
||||
* MacOS tweaks.
|
||||
* MSVC tweaks.
|
||||
|
||||
|
||||
New in 0.0.12
|
||||
* July 19, 2000
|
||||
* Converted project license from GPL to LGPL.
|
||||
@@ -17,6 +180,7 @@ New in 0.0.12
|
||||
* Added a property manager (registry)
|
||||
* Some documentation added.
|
||||
|
||||
|
||||
New in 0.0.11
|
||||
* July 3, 2000
|
||||
* Replaced gdbm with metakit
|
||||
@@ -25,6 +189,7 @@ New in 0.0.11
|
||||
* 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
|
||||
@@ -37,18 +202,22 @@ New in 0.0.7
|
||||
* 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
|
||||
|
||||
4
README
4
README
@@ -1,3 +1 @@
|
||||
MSVC5 users:
|
||||
|
||||
Copy simgear/config.h.vc5 to simgear/config.h before building.
|
||||
[ Nothing here at this time. ]
|
||||
|
||||
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.
|
||||
@@ -1,5 +1,47 @@
|
||||
With the author's permission, SimGear now bundles MetaKit. MetaKit is
|
||||
explained
|
||||
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
|
||||
==============================================================================
|
||||
|
||||
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>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
330
acconfig.h
330
acconfig.h
@@ -1,330 +0,0 @@
|
||||
/* acconfig.h
|
||||
This file is in the public domain.
|
||||
|
||||
Descriptive text for the C preprocessor macros that
|
||||
the distributed Autoconf macros can define.
|
||||
No software package will use all of them; autoheader copies the ones
|
||||
your configure.in uses into your configuration header file templates.
|
||||
|
||||
The entries are in sort -df order: alphabetical, case insensitive,
|
||||
ignoring punctuation (such as underscores). Although this order
|
||||
can split up related entries, it makes it easier to check whether
|
||||
a given entry is in the file.
|
||||
|
||||
Leave the following blank line there!! Autoheader needs it. */
|
||||
|
||||
|
||||
/* Define if on AIX 3.
|
||||
System headers sometimes define this.
|
||||
We just want to avoid a redefinition error message. */
|
||||
#ifndef _ALL_SOURCE
|
||||
#undef _ALL_SOURCE
|
||||
#endif
|
||||
|
||||
/* Define if using alloca.c. */
|
||||
#undef C_ALLOCA
|
||||
|
||||
/* Define if type char is unsigned and you are not using gcc. */
|
||||
#ifndef __CHAR_UNSIGNED__
|
||||
#undef __CHAR_UNSIGNED__
|
||||
#endif
|
||||
|
||||
/* Define if the closedir function returns void instead of int. */
|
||||
#undef CLOSEDIR_VOID
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
#undef const
|
||||
|
||||
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
|
||||
This function is required for alloca.c support on those systems. */
|
||||
#undef CRAY_STACKSEG_END
|
||||
|
||||
/* Define for DGUX with <sys/dg_sys_info.h>. */
|
||||
#undef DGUX
|
||||
|
||||
/* Define if you have <dirent.h>. */
|
||||
#undef DIRENT
|
||||
|
||||
/* Define to enable audio support */
|
||||
#undef ENABLE_AUDIO_SUPPORT
|
||||
|
||||
/* Define to enable GLUT joystick support (limited to 3 axes) */
|
||||
#undef ENABLE_GLUT_JOYSTICK
|
||||
|
||||
/* Define to enable plib joystick support (recommended) */
|
||||
#undef ENABLE_PLIB_JOYSTICK
|
||||
|
||||
/* Define to eliminate all trace of debugging messages such as for a
|
||||
release build */
|
||||
#undef FG_NDEBUG
|
||||
|
||||
/* Define to include Oliver's networking support */
|
||||
#undef FG_NETWORK_OLK
|
||||
|
||||
/* Define to avoid Christian's new weather code */
|
||||
#undef FG_OLD_WEATHER
|
||||
|
||||
/* Define if we are building FGFS (should always be defined) */
|
||||
#undef FGFS
|
||||
|
||||
/* Define to enable 3dfx/glide render in a window hack under unix.
|
||||
This probably won't work under windows. */
|
||||
#undef XMESA
|
||||
#undef FX
|
||||
|
||||
/* Define to the type of elements in the array set by `getgroups'.
|
||||
Usually this is either `int' or `gid_t'. */
|
||||
#undef GETGROUPS_T
|
||||
|
||||
/* Define if the `getloadavg' function needs to be run setuid or setgid. */
|
||||
#undef GETLOADAVG_PRIVILEGED
|
||||
|
||||
/* Define if the `getpgrp' function takes no argument. */
|
||||
#undef GETPGRP_VOID
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef gid_t
|
||||
|
||||
/* Define if you have alloca, as a function or macro. */
|
||||
#undef HAVE_ALLOCA
|
||||
|
||||
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
|
||||
#undef HAVE_ALLOCA_H
|
||||
|
||||
/* Define if you external variables daylight. */
|
||||
#undef HAVE_DAYLIGHT
|
||||
|
||||
/* Define if you don't have vprintf but do have _doprnt. */
|
||||
#undef HAVE_DOPRNT
|
||||
|
||||
/* Define if your system has a working fnmatch function. */
|
||||
#undef HAVE_FNMATCH
|
||||
|
||||
/* Define if your system has its own `getloadavg' function. */
|
||||
#undef HAVE_GETLOADAVG
|
||||
|
||||
/* Define if you have getrusage() */
|
||||
#undef HAVE_GETRUSAGE
|
||||
|
||||
/* Define if you have the getmntent function. */
|
||||
#undef HAVE_GETMNTENT
|
||||
|
||||
/* Define if you have the gpc library and headers installed. */
|
||||
#undef HAVE_GPC_H
|
||||
|
||||
/* Define if the `long double' type works. */
|
||||
#undef HAVE_LONG_DOUBLE
|
||||
|
||||
/* Define if you support file names longer than 14 characters. */
|
||||
#undef HAVE_LONG_FILE_NAMES
|
||||
|
||||
/* Define if you have a working `mmap' system call. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
/* Define if system calls automatically restart after interruption
|
||||
by a signal. */
|
||||
#undef HAVE_RESTARTABLE_SYSCALLS
|
||||
|
||||
/* Define if you have rint() which rounds to closest int but returns
|
||||
result as a double data type. */
|
||||
#undef HAVE_RINT
|
||||
|
||||
/* Define if your struct stat has st_blksize. */
|
||||
#undef HAVE_ST_BLKSIZE
|
||||
|
||||
/* Define if your struct stat has st_blocks. */
|
||||
#undef HAVE_ST_BLOCKS
|
||||
|
||||
/* Define if you have the strcoll function and it is properly defined. */
|
||||
#undef HAVE_STRCOLL
|
||||
|
||||
/* Define if your struct stat has st_rdev. */
|
||||
#undef HAVE_ST_RDEV
|
||||
|
||||
/* Define if you have the strftime function. */
|
||||
#undef HAVE_STRFTIME
|
||||
|
||||
/* Define if you have <sys/param.h> */
|
||||
#undef HAVE_SYS_PARAM_H
|
||||
|
||||
/* Define if you have <sys/stat.h> that is POSIX.1 compatible. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
#undef HAVE_SYS_WAIT_H
|
||||
|
||||
/* Define if you have timegm() */
|
||||
#undef HAVE_TIMEGM
|
||||
|
||||
/* Define if you external variables timezone. */
|
||||
#undef HAVE_TIMEZONE
|
||||
|
||||
/* Define if your struct tm has tm_zone. */
|
||||
#undef HAVE_TM_ZONE
|
||||
|
||||
/* Define if you don't have tm_zone but do have the external array
|
||||
tzname. */
|
||||
#undef HAVE_TZNAME
|
||||
|
||||
/* Define if you have <unistd.h>. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define if utime(file, NULL) sets file's timestamp to the present. */
|
||||
#undef HAVE_UTIME_NULL
|
||||
|
||||
/* Define if you have <vfork.h>. */
|
||||
#undef HAVE_VFORK_H
|
||||
|
||||
/* Define if you have the vprintf function. */
|
||||
#undef HAVE_VPRINTF
|
||||
|
||||
/* Define if you have the wait3 system call. */
|
||||
#undef HAVE_WAIT3
|
||||
|
||||
/* Define if you have gdbm installed system wide. */
|
||||
/* #undef HAVE_GDBM */
|
||||
|
||||
/* Define if you have zlib installed system wide. */
|
||||
#undef HAVE_ZLIB
|
||||
|
||||
/* Define as __inline if that's what the C compiler calls it. */
|
||||
#undef inline
|
||||
|
||||
/* Define if int is 16 bits instead of 32. */
|
||||
#undef INT_16_BITS
|
||||
|
||||
/* Define if long int is 64 bits. */
|
||||
#undef LONG_64_BITS
|
||||
|
||||
/* Define if major, minor, and makedev are declared in <mkdev.h>. */
|
||||
#undef MAJOR_IN_MKDEV
|
||||
|
||||
/* Define if major, minor, and makedev are declared in <sysmacros.h>. */
|
||||
#undef MAJOR_IN_SYSMACROS
|
||||
|
||||
/* Define if on MINIX. */
|
||||
#undef _MINIX
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef mode_t
|
||||
|
||||
/* Define if you don't have <dirent.h>, but have <ndir.h>. */
|
||||
#undef NDIR
|
||||
|
||||
/* Define if you have <memory.h>, and <string.h> doesn't declare the
|
||||
mem* functions. */
|
||||
#undef NEED_MEMORY_H
|
||||
|
||||
/* Define if your struct nlist has an n_un member. */
|
||||
#undef NLIST_NAME_UNION
|
||||
|
||||
/* Define if you have <nlist.h>. */
|
||||
#undef NLIST_STRUCT
|
||||
|
||||
/* Define if your C compiler doesn't accept -c and -o together. */
|
||||
#undef NO_MINUS_C_MINUS_O
|
||||
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
#undef off_t
|
||||
|
||||
/* Define to package name */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef pid_t
|
||||
|
||||
/* Define if the system does not provide POSIX.1 features except
|
||||
with this defined. */
|
||||
#undef _POSIX_1_SOURCE
|
||||
|
||||
/* Define if you need to in order for stat and other things to work. */
|
||||
#undef _POSIX_SOURCE
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* Define if the `setpgrp' function takes no argument. */
|
||||
#undef SETPGRP_VOID
|
||||
|
||||
/* Define if the setvbuf function takes the buffering type as its second
|
||||
argument and the buffer pointer as the third, as on System V
|
||||
before release 3. */
|
||||
#undef SETVBUF_REVERSED
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> doesn't define. */
|
||||
#undef size_t
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at run-time.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown
|
||||
*/
|
||||
#undef STACK_DIRECTION
|
||||
|
||||
/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
|
||||
#undef STAT_MACROS_BROKEN
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define on System V Release 4. */
|
||||
#undef SVR4
|
||||
|
||||
/* Define if you don't have <dirent.h>, but have <sys/dir.h>. */
|
||||
#undef SYSDIR
|
||||
|
||||
/* Define if you don't have <dirent.h>, but have <sys/ndir.h>. */
|
||||
#undef SYSNDIR
|
||||
|
||||
/* Define if `sys_siglist' is declared by <signal.h>. */
|
||||
#undef SYS_SIGLIST_DECLARED
|
||||
|
||||
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define if your <sys/time.h> declares struct tm. */
|
||||
#undef TM_IN_SYS_TIME
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef uid_t
|
||||
|
||||
/* Define for Encore UMAX. */
|
||||
#undef UMAX
|
||||
|
||||
/* Define for Encore UMAX 4.3 that has <inq_status/cpustats.h>
|
||||
instead of <sys/cpustats.h>. */
|
||||
#undef UMAX4_3
|
||||
|
||||
/* Define if you do not have <strings.h>, index, bzero, etc.. */
|
||||
#undef USG
|
||||
|
||||
/* Define to version number */
|
||||
#undef VERSION
|
||||
|
||||
/* Define vfork as fork if vfork does not work. */
|
||||
#undef vfork
|
||||
|
||||
/* Define if the closedir function returns void instead of int. */
|
||||
#undef VOID_CLOSEDIR
|
||||
|
||||
/* Define if compiling on a Winbloze (95, NT, etc.) platform */
|
||||
#undef WIN32
|
||||
|
||||
/* Define if your processor stores words with the most significant
|
||||
byte first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||
#undef WORDS_BIGENDIAN
|
||||
|
||||
/* Define if the X Window System is missing or not being used. */
|
||||
#undef X_DISPLAY_MISSING
|
||||
|
||||
/* Define if lex declares yytext as a char * by default, not a char[]. */
|
||||
#undef YYTEXT_POINTER
|
||||
|
||||
|
||||
/* Leave that blank line there!! Autoheader needs it.
|
||||
If you're adding to this file, keep in mind:
|
||||
The entries are in sort -df order: alphabetical, case insensitive,
|
||||
ignoring punctuation (such as underscores). */
|
||||
|
||||
@@ -102,7 +102,7 @@ for exdir in $exdirs ; do
|
||||
mylibdir="${exdir}/lib${subexdir}"
|
||||
wi_EXTRA_LDIR($mylibdir)
|
||||
|
||||
progdir="${exdir}/bin${subexdirr}"
|
||||
progdir="${exdir}/bin${subexdir}"
|
||||
wi_EXTRA_PDIR($progdir)
|
||||
fi
|
||||
done
|
||||
@@ -392,3 +392,24 @@ if test "$have_timezone" = no; then
|
||||
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])
|
||||
140
aclocal.m4
vendored
140
aclocal.m4
vendored
@@ -1,140 +0,0 @@
|
||||
dnl aclocal.m4 generated automatically by aclocal 1.4
|
||||
|
||||
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl This program is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
dnl PARTICULAR PURPOSE.
|
||||
|
||||
# Do all the work for Automake. This macro actually does too much --
|
||||
# some checks are only needed if your package does certain things.
|
||||
# But this isn't really a big deal.
|
||||
|
||||
# serial 1
|
||||
|
||||
dnl Usage:
|
||||
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
|
||||
|
||||
AC_DEFUN(AM_INIT_AUTOMAKE,
|
||||
[AC_REQUIRE([AC_PROG_INSTALL])
|
||||
PACKAGE=[$1]
|
||||
AC_SUBST(PACKAGE)
|
||||
VERSION=[$2]
|
||||
AC_SUBST(VERSION)
|
||||
dnl test to see if srcdir already configured
|
||||
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
|
||||
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
|
||||
fi
|
||||
ifelse([$3],,
|
||||
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
|
||||
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
|
||||
AC_REQUIRE([AM_SANITY_CHECK])
|
||||
AC_REQUIRE([AC_ARG_PROGRAM])
|
||||
dnl FIXME This is truly gross.
|
||||
missing_dir=`cd $ac_aux_dir && pwd`
|
||||
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
|
||||
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
|
||||
AC_REQUIRE([AC_PROG_MAKE_SET])])
|
||||
|
||||
#
|
||||
# Check to make sure that the build environment is sane.
|
||||
#
|
||||
|
||||
AC_DEFUN(AM_SANITY_CHECK,
|
||||
[AC_MSG_CHECKING([whether build environment is sane])
|
||||
# Just in case
|
||||
sleep 1
|
||||
echo timestamp > conftestfile
|
||||
# Do `set' in a subshell so we don't clobber the current shell's
|
||||
# arguments. Must try -L first in case configure is actually a
|
||||
# symlink; some systems play weird games with the mod time of symlinks
|
||||
# (eg FreeBSD returns the mod time of the symlink's containing
|
||||
# directory).
|
||||
if (
|
||||
set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
|
||||
if test "[$]*" = "X"; then
|
||||
# -L didn't work.
|
||||
set X `ls -t $srcdir/configure conftestfile`
|
||||
fi
|
||||
if test "[$]*" != "X $srcdir/configure conftestfile" \
|
||||
&& test "[$]*" != "X conftestfile $srcdir/configure"; then
|
||||
|
||||
# If neither matched, then we have a broken ls. This can happen
|
||||
# if, for instance, CONFIG_SHELL is bash and it inherits a
|
||||
# broken ls alias from the environment. This has actually
|
||||
# happened. Such a system could not be considered "sane".
|
||||
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
|
||||
alias in your environment])
|
||||
fi
|
||||
|
||||
test "[$]2" = conftestfile
|
||||
)
|
||||
then
|
||||
# Ok.
|
||||
:
|
||||
else
|
||||
AC_MSG_ERROR([newly created file is older than distributed files!
|
||||
Check your system clock])
|
||||
fi
|
||||
rm -f conftest*
|
||||
AC_MSG_RESULT(yes)])
|
||||
|
||||
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
|
||||
dnl The program must properly implement --version.
|
||||
AC_DEFUN(AM_MISSING_PROG,
|
||||
[AC_MSG_CHECKING(for working $2)
|
||||
# Run test in a subshell; some versions of sh will print an error if
|
||||
# an executable is not found, even if stderr is redirected.
|
||||
# Redirect stdin to placate older versions of autoconf. Sigh.
|
||||
if ($2 --version) < /dev/null > /dev/null 2>&1; then
|
||||
$1=$2
|
||||
AC_MSG_RESULT(found)
|
||||
else
|
||||
$1="$3/missing $2"
|
||||
AC_MSG_RESULT(missing)
|
||||
fi
|
||||
AC_SUBST($1)])
|
||||
|
||||
# Define a conditional.
|
||||
|
||||
AC_DEFUN(AM_CONDITIONAL,
|
||||
[AC_SUBST($1_TRUE)
|
||||
AC_SUBST($1_FALSE)
|
||||
if $2; then
|
||||
$1_TRUE=
|
||||
$1_FALSE='#'
|
||||
else
|
||||
$1_TRUE='#'
|
||||
$1_FALSE=
|
||||
fi])
|
||||
|
||||
# Like AC_CONFIG_HEADER, but automatically create stamp file.
|
||||
|
||||
AC_DEFUN(AM_CONFIG_HEADER,
|
||||
[AC_PREREQ([2.12])
|
||||
AC_CONFIG_HEADER([$1])
|
||||
dnl When config.status generates a header, we must update the stamp-h file.
|
||||
dnl This file resides in the same directory as the config header
|
||||
dnl that is generated. We must strip everything past the first ":",
|
||||
dnl and everything past the last "/".
|
||||
AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
|
||||
ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
|
||||
<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
|
||||
<<am_indx=1
|
||||
for am_file in <<$1>>; do
|
||||
case " <<$>>CONFIG_HEADERS " in
|
||||
*" <<$>>am_file "*<<)>>
|
||||
echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
|
||||
;;
|
||||
esac
|
||||
am_indx=`expr "<<$>>am_indx" + 1`
|
||||
done<<>>dnl>>)
|
||||
changequote([,]))])
|
||||
|
||||
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
|
||||
303
configure.in
303
configure.in
@@ -1,303 +0,0 @@
|
||||
dnl Process this file with aclocal ; automake -a ; autoconf to produce a
|
||||
dnl working configure script.
|
||||
dnl
|
||||
dnl $Id$
|
||||
|
||||
AC_INIT(simgear/bucket/newbucket.cxx)
|
||||
|
||||
dnl Initialize the automake stuff
|
||||
AM_INIT_AUTOMAKE(SimGear, 0.0.13)
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
|
||||
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)
|
||||
fi
|
||||
|
||||
dnl specify if we are building with "checker"
|
||||
AC_ARG_WITH(efence, [ --with-efence Specify if we are building with "electric-fence"])
|
||||
|
||||
if test "x$with_efence" = "xyes" ; then
|
||||
echo "Building with efence"
|
||||
LIBS= "$LIBS -lefence"
|
||||
fi
|
||||
|
||||
dnl Check for MS Windows environment
|
||||
AC_CHECK_HEADER(windows.h)
|
||||
|
||||
dnl extra library and include directories
|
||||
EXTRA_DIRS="/usr/local /usr/local/plib /usr/X11R6"
|
||||
|
||||
if test -d /opt/X11R6 ; then
|
||||
EXTRA_DIRS="$EXTRA_DIRS /opt/X11R6"
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_header_windows_h" = "xyes" ; then
|
||||
EXTRA_DIRS="${EXTRA_DIRS} `pwd`/Win32"
|
||||
# elif test `uname -s` = "SunOS" ; then
|
||||
# EXTRA_DIRS="${EXTRA_DIRS} `pwd`/SunOS"
|
||||
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 Enable serial support on Unix type systems
|
||||
AM_CONDITIONAL(ENABLE_UNIX_SERIAL, true)
|
||||
|
||||
dnl Check for X11 (fancy)
|
||||
AC_PATH_XTRA
|
||||
|
||||
dnl Checks for libraries.
|
||||
|
||||
null_LIBS="$LIBS"
|
||||
|
||||
AC_CHECK_LIB(m, cos)
|
||||
|
||||
base_LIBS="$LIBS"
|
||||
|
||||
AC_CHECK_LIB(socket, socket)
|
||||
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)
|
||||
|
||||
dnl check for OpenGL related libraries
|
||||
|
||||
if test "x$ac_cv_header_windows_h" != "xyes" ; then
|
||||
dnl Reasonable stuff for non-windoze variants ... :-)
|
||||
|
||||
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/xmesa.h)
|
||||
if test "x$ac_cv_header_GL_xmesa_h" = "xyes"; then
|
||||
AC_DEFINE( XMESA )
|
||||
AC_DEFINE( FX )
|
||||
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 is a little wierd because it has to try to handle the various
|
||||
dnl winbloze-isms. We'll just do this manually for now.
|
||||
|
||||
echo Win32 specific hacks...
|
||||
AC_DEFINE(WIN32)
|
||||
|
||||
dnl force a failed check since we will be building under windoze
|
||||
AM_CONDITIONAL(ENABLE_XMESA_FX, test "no" = "yes")
|
||||
|
||||
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"
|
||||
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 fetch and install the latest version of glut 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" )
|
||||
|
||||
dnl Check for "plib" without which we cannot go on
|
||||
AC_CHECK_HEADER(plib/pu.h)
|
||||
if test "x$ac_cv_header_plib_pu_h" != "xyes"; then
|
||||
echo
|
||||
echo "You *must* have the plib library installed on your system to build"
|
||||
echo "the FGFS simulator!"
|
||||
echo
|
||||
echo "Please see README.plib for more details."
|
||||
echo
|
||||
echo "configure aborted."
|
||||
exit
|
||||
fi
|
||||
|
||||
# dnl Check for system installed gdbm
|
||||
# AC_CHECK_HEADER(gdbm.h)
|
||||
# if test "x$ac_cv_header_gdbm_h" = "xyes"; then
|
||||
# AC_DEFINE( HAVE_GDBM )
|
||||
# else
|
||||
# echo "no gdbm found, configuring and building."
|
||||
# fi
|
||||
# AM_CONDITIONAL(HAVE_GDBM, test "x$ac_cv_header_gdbm_h" = "xyes" )
|
||||
|
||||
dnl Check for system installed metakit
|
||||
AC_CHECK_HEADER(mk4.h)
|
||||
if test "x$ac_cv_header_mk4_h" != "xyes"; then
|
||||
echo "no metakit found, configuring and building."
|
||||
# Run configure in the metakit subdir
|
||||
AC_CONFIG_SUBDIRS( simgear/metakit/unix )
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_METAKIT, test "x$ac_cv_header_mk4_h" = "xyes" )
|
||||
|
||||
|
||||
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
|
||||
AC_DEFINE( HAVE_ZLIB )
|
||||
else
|
||||
echo "no zlib found, building."
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_ZLIB, test "x$ac_cv_header_zlib_h" = "xyes" )
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS( \
|
||||
fcntl.h getopt.h malloc.h memory.h stdlib.h sys/param.h sys/stat.h \
|
||||
sys/time.h sys/timeb.h unistd.h windows.h winbase.h values.h )
|
||||
|
||||
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 setitimer getitimer signal GetLocalTime rint getrusage )
|
||||
|
||||
AM_CONFIG_HEADER(simgear/config.h)
|
||||
|
||||
AC_OUTPUT( \
|
||||
Makefile \
|
||||
SimGear.spec \
|
||||
simgear/Makefile \
|
||||
simgear/version.h \
|
||||
simgear/bucket/Makefile \
|
||||
simgear/debug/Makefile \
|
||||
simgear/ephemeris/Makefile \
|
||||
simgear/io/Makefile \
|
||||
simgear/magvar/Makefile \
|
||||
simgear/math/Makefile \
|
||||
simgear/misc/Makefile \
|
||||
simgear/screen/Makefile \
|
||||
simgear/serial/Makefile \
|
||||
simgear/sky/Makefile \
|
||||
simgear/timing/Makefile \
|
||||
simgear/xgl/Makefile \
|
||||
simgear/xml/Makefile \
|
||||
simgear/zlib/Makefile \
|
||||
)
|
||||
|
||||
AC_OUTPUT_COMMANDS([
|
||||
# if test "x$ac_cv_header_windows_h" = "xyes" ; then
|
||||
# cp simgear/gdbm/autoconf.h.cygwin32 simgear/gdbm/autoconf.h
|
||||
# fi
|
||||
])
|
||||
|
||||
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
|
||||
|
||||
if test "x$with_efence" != "x"; then
|
||||
echo "Electric fence: $with_efence"
|
||||
else
|
||||
echo "Electric fence: no"
|
||||
fi
|
||||
|
||||
# if test "x$ac_cv_header_gdbm_h" != "xyes"; then
|
||||
# echo "Building gdbm"
|
||||
# fi
|
||||
|
||||
if test "x$ac_cv_header_mk4_h" != "xyes"; then
|
||||
echo "Building metakit"
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_header_zlib_h" != "xyes"; then
|
||||
echo "Building zlib"
|
||||
fi
|
||||
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
|
||||
@@ -1,43 +1,33 @@
|
||||
if ENABLE_UNIX_SERIAL
|
||||
SERIAL_DIRS = serial
|
||||
if HAVE_THREADS
|
||||
SGTHREAD_DIR = threads
|
||||
else
|
||||
SERIAL_DIRS =
|
||||
SGTHREAD_DIR =
|
||||
endif
|
||||
|
||||
# if HAVE_GDBM
|
||||
# GDBM_DIRS =
|
||||
# else
|
||||
# GDBM_DIRS = gdbm
|
||||
# endif
|
||||
# METAR_DIRS =
|
||||
METAR_DIRS = metar
|
||||
|
||||
if HAVE_ZLIB
|
||||
ZLIB_DIRS =
|
||||
else
|
||||
ZLIB_DIRS = zlib
|
||||
endif
|
||||
|
||||
METAR_DIRS =
|
||||
# METAR_DIRS = metar
|
||||
|
||||
EXTRA_DIST = version.h.in
|
||||
EXTRA_DIST = simgear_config.h.vc5 version.h.in
|
||||
|
||||
include_HEADERS = \
|
||||
compiler.h constants.h fg_traits.hxx fg_zlib.h inlines.h version.h
|
||||
compiler.h constants.h sg_inlines.h sg_traits.hxx sg_zlib.h version.h
|
||||
|
||||
SUBDIRS = \
|
||||
bucket \
|
||||
xml \
|
||||
debug \
|
||||
misc \
|
||||
bucket \
|
||||
ephemeris \
|
||||
io \
|
||||
magvar \
|
||||
math \
|
||||
$(METAR_DIRS) \
|
||||
misc \
|
||||
route \
|
||||
screen \
|
||||
$(SERIAL_DIRS) \
|
||||
serial \
|
||||
sky \
|
||||
$(SGTHREAD_DIR) \
|
||||
timing \
|
||||
xgl \
|
||||
xml \
|
||||
$(ZLIB_DIRS)
|
||||
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
|
||||
@@ -14,4 +14,4 @@ libsgbucket_a_SOURCES = newbucket.cxx
|
||||
# $(top_builddir)/bucket/libsgbucket.a \
|
||||
# $(top_builddir)/misc/libsgmisc.a
|
||||
|
||||
INCLUDES += -I$(top_builddir)
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
|
||||
@@ -24,20 +24,116 @@
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <simgear/misc/fgpath.hxx>
|
||||
#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 FGBucket::gen_base_path() const {
|
||||
string SGBucket::gen_base_path() const {
|
||||
// long int index;
|
||||
int top_lon, top_lat, main_lon, main_lat;
|
||||
char hem, pole;
|
||||
@@ -79,25 +175,64 @@ string FGBucket::gen_base_path() const {
|
||||
hem, top_lon, pole, top_lat,
|
||||
hem, main_lon, pole, main_lat);
|
||||
|
||||
FGPath path( raw_path );
|
||||
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
|
||||
FGBucket fgBucketOffset( double dlon, double dlat, int dx, int dy ) {
|
||||
FGBucket result( dlon, dlat );
|
||||
double clat = result.get_center_lat() + dy * FG_BUCKET_SPAN;
|
||||
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 = bucket_span( clat );
|
||||
double span = sg_bucket_span( clat );
|
||||
|
||||
// walk dx units in the lon direction
|
||||
double tmp = dlon + dx * span;
|
||||
@@ -114,7 +249,7 @@ FGBucket fgBucketOffset( double dlon, double dlat, int dx, int dy ) {
|
||||
|
||||
|
||||
// calculate the offset between two buckets
|
||||
void fgBucketDiff( const FGBucket& b1, const FGBucket& b2, int *dx, int *dy ) {
|
||||
void sgBucketDiff( const SGBucket& b1, const SGBucket& b2, int *dx, int *dy ) {
|
||||
|
||||
// Latitude difference
|
||||
double c1_lat = b1.get_center_lat();
|
||||
@@ -122,12 +257,12 @@ void fgBucketDiff( const FGBucket& b1, const FGBucket& b2, int *dx, int *dy ) {
|
||||
double diff_lat = c2_lat - c1_lat;
|
||||
|
||||
#ifdef HAVE_RINT
|
||||
*dy = (int)rint( diff_lat / FG_BUCKET_SPAN );
|
||||
*dy = (int)rint( diff_lat / SG_BUCKET_SPAN );
|
||||
#else
|
||||
if ( diff_lat > 0 ) {
|
||||
*dy = (int)( diff_lat / FG_BUCKET_SPAN + 0.5 );
|
||||
*dy = (int)( diff_lat / SG_BUCKET_SPAN + 0.5 );
|
||||
} else {
|
||||
*dy = (int)( diff_lat / FG_BUCKET_SPAN - 0.5 );
|
||||
*dy = (int)( diff_lat / SG_BUCKET_SPAN - 0.5 );
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -136,10 +271,10 @@ void fgBucketDiff( const FGBucket& b1, const FGBucket& b2, int *dx, int *dy ) {
|
||||
double c2_lon = b2.get_center_lon();
|
||||
double diff_lon = c2_lon - c1_lon;
|
||||
double span;
|
||||
if ( bucket_span(c1_lat) <= bucket_span(c2_lat) ) {
|
||||
span = bucket_span(c1_lat);
|
||||
if ( sg_bucket_span(c1_lat) <= sg_bucket_span(c2_lat) ) {
|
||||
span = sg_bucket_span(c1_lat);
|
||||
} else {
|
||||
span = bucket_span(c2_lat);
|
||||
span = sg_bucket_span(c2_lat);
|
||||
}
|
||||
|
||||
#ifdef HAVE_RINT
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
|
||||
/** \file newbucket.hxx
|
||||
* A class and associated utiltity functions to manage world scenery tiling.
|
||||
*/
|
||||
|
||||
#ifndef _NEWBUCKET_HXX
|
||||
#define _NEWBUCKET_HXX
|
||||
@@ -30,106 +33,46 @@
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/constants.h>
|
||||
|
||||
#ifdef FG_HAVE_STD_INCLUDES
|
||||
#ifdef SG_HAVE_STD_INCLUDES
|
||||
# include <cmath>
|
||||
# include <cstdio> // sprintf()
|
||||
# include <iostream>
|
||||
#else
|
||||
# include <math.h>
|
||||
# include <stdio.h> // sprintf()
|
||||
# include <iostream.h>
|
||||
#endif
|
||||
|
||||
#include STL_IOSTREAM
|
||||
|
||||
// I don't understand ... <math.h> or <cmath> should be included
|
||||
// already depending on how you defined FG_HAVE_STD_INCLUDES, but I
|
||||
// already depending on how you defined SG_HAVE_STD_INCLUDES, but I
|
||||
// can go ahead and add this -- CLO
|
||||
#ifdef __MWERKS__
|
||||
# include <math.h> // needed fabs()
|
||||
SG_USING_STD(sprintf);
|
||||
SG_USING_STD(fabs);
|
||||
#endif
|
||||
|
||||
#include STL_STRING
|
||||
|
||||
FG_USING_STD(string);
|
||||
SG_USING_STD(string);
|
||||
|
||||
#if ! defined( FG_HAVE_NATIVE_SGI_COMPILERS )
|
||||
FG_USING_STD(ostream);
|
||||
#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
|
||||
|
||||
#define FG_BUCKET_SPAN 0.125 // 1/8 of a degree
|
||||
#define FG_HALF_BUCKET_SPAN 0.0625 // 1/2 of 1/8 of a degree = 1/16 = 0.0625
|
||||
|
||||
class FGBucket;
|
||||
ostream& operator<< ( ostream&, const FGBucket& );
|
||||
bool operator== ( const FGBucket&, const FGBucket& );
|
||||
|
||||
class FGBucket {
|
||||
|
||||
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
|
||||
FGBucket();
|
||||
|
||||
// create a bucket which would contain the specified lon/lat
|
||||
FGBucket(const double lon, const double lat);
|
||||
|
||||
// create a bucket based on "long int" index
|
||||
FGBucket(const long int bindex);
|
||||
|
||||
// create an impossible bucket if false
|
||||
FGBucket(const bool is_good);
|
||||
|
||||
~FGBucket();
|
||||
|
||||
// Set the bucket params for the specified lat and lon
|
||||
void set_bucket( double dlon, double dlat );
|
||||
void set_bucket( double *lonlat ) {
|
||||
set_bucket( lonlat[0], lonlat[1] );
|
||||
}
|
||||
|
||||
void make_bad ( void );
|
||||
|
||||
// Generate the unique scenery tile index for this bucket
|
||||
long int gen_index();
|
||||
string gen_index_str() const;
|
||||
|
||||
// Build the path name for this bucket
|
||||
string gen_base_path() const;
|
||||
|
||||
// return the center lon of a tile
|
||||
double get_center_lon() const;
|
||||
|
||||
// return width of the tile
|
||||
double get_width() const;
|
||||
|
||||
// return the center lat of a tile
|
||||
double get_center_lat() const;
|
||||
|
||||
// return height of the tile
|
||||
double get_height() const;
|
||||
|
||||
// Informational methods
|
||||
inline int get_lon() const { return lon; }
|
||||
inline int get_lat() const { return lat; }
|
||||
inline int get_x() const { return x; }
|
||||
inline int get_y() const { return y; }
|
||||
|
||||
// friends
|
||||
friend ostream& operator<< ( ostream&, const FGBucket& );
|
||||
friend bool operator== ( const FGBucket&, const FGBucket& );
|
||||
};
|
||||
/**
|
||||
* 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
|
||||
inline double bucket_span( double l ) {
|
||||
static double sg_bucket_span( double l ) {
|
||||
if ( l >= 89.0 ) {
|
||||
return 360.0;
|
||||
} else if ( l >= 88.0 ) {
|
||||
@@ -164,179 +107,229 @@ inline double bucket_span( double l ) {
|
||||
}
|
||||
|
||||
|
||||
// Set the bucket params for the specified lat and lon
|
||||
inline void FGBucket::set_bucket( double dlon, double dlat ) {
|
||||
//
|
||||
// latitude first
|
||||
//
|
||||
double span = bucket_span( dlat );
|
||||
double diff = dlon - (double)(int)dlon;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// cout << "diff = " << diff << " span = " << span << endl;
|
||||
class SGBucket {
|
||||
|
||||
if ( (dlon >= 0) || (fabs(diff) < FG_EPSILON) ) {
|
||||
lon = (int)dlon;
|
||||
} else {
|
||||
lon = (int)dlon - 1;
|
||||
}
|
||||
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)
|
||||
|
||||
// find subdivision or super lon if needed
|
||||
if ( span < FG_EPSILON ) {
|
||||
// polar cap
|
||||
lon = 0;
|
||||
x = 0;
|
||||
} else if ( span <= 1.0 ) {
|
||||
x = (int)((dlon - lon) / span);
|
||||
} else {
|
||||
if ( (dlon >= 0) || (fabs(diff) < FG_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;
|
||||
}
|
||||
public:
|
||||
|
||||
//
|
||||
// then latitude
|
||||
//
|
||||
diff = dlat - (double)(int)dlat;
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
SGBucket();
|
||||
|
||||
if ( (dlat >= 0) || (fabs(diff) < FG_EPSILON) ) {
|
||||
lat = (int)dlat;
|
||||
} else {
|
||||
lat = (int)dlat - 1;
|
||||
}
|
||||
y = (int)((dlat - lat) * 8);
|
||||
}
|
||||
/**
|
||||
* 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);
|
||||
|
||||
// default constructor
|
||||
inline FGBucket::FGBucket() {}
|
||||
/** Construct a bucket given a unique bucket index number.
|
||||
* @param bindex unique bucket index
|
||||
*/
|
||||
SGBucket(const long int bindex);
|
||||
|
||||
/**
|
||||
* Default destructor.
|
||||
*/
|
||||
~SGBucket();
|
||||
|
||||
// constructor for specified location
|
||||
inline FGBucket::FGBucket(const double dlon, const double dlat) {
|
||||
set_bucket(dlon, dlat);
|
||||
}
|
||||
/**
|
||||
* 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 if false
|
||||
inline FGBucket::FGBucket(const bool is_good) {
|
||||
set_bucket(0.0, 0.0);
|
||||
if ( !is_good ) {
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Parse a unique scenery tile index and find the lon, lat, x, and y
|
||||
inline FGBucket::FGBucket(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
|
||||
inline FGBucket::~FGBucket() {}
|
||||
|
||||
|
||||
// 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)
|
||||
|
||||
inline long int FGBucket::gen_index() {
|
||||
return ((lon + 180) << 14) + ((lat + 90) << 6) + (y << 3) + x;
|
||||
}
|
||||
|
||||
inline string FGBucket::gen_index_str() const {
|
||||
char tmp[20];
|
||||
sprintf(tmp, "%ld",
|
||||
(((long)lon + 180) << 14) + ((lat + 90) << 6) + (y << 3) + x);
|
||||
return (string)tmp;
|
||||
}
|
||||
|
||||
|
||||
// return the center lon of a tile
|
||||
inline double FGBucket::get_center_lon() const {
|
||||
double span = bucket_span( lat + y / 8.0 + FG_HALF_BUCKET_SPAN );
|
||||
|
||||
if ( span >= 1.0 ) {
|
||||
return lon + span / 2.0;
|
||||
} else {
|
||||
return lon + x * span + span / 2.0;
|
||||
/**
|
||||
* 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& );
|
||||
};
|
||||
|
||||
|
||||
// return the center lat of a tile
|
||||
inline double FGBucket::get_center_lat() const {
|
||||
return lat + y / 8.0 + FG_HALF_BUCKET_SPAN;
|
||||
}
|
||||
/**
|
||||
* \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 );
|
||||
|
||||
|
||||
// return width of the tile
|
||||
inline double FGBucket::get_width() const {
|
||||
return bucket_span( get_center_lat() );
|
||||
}
|
||||
|
||||
|
||||
// return height of the tile
|
||||
inline double FGBucket::get_height() const {
|
||||
return FG_BUCKET_SPAN;
|
||||
}
|
||||
|
||||
|
||||
// create an impossible bucket
|
||||
inline void FGBucket::make_bad( void ) {
|
||||
set_bucket(0.0, 0.0);
|
||||
lon = -1000;
|
||||
}
|
||||
|
||||
|
||||
// offset a bucket struct by the specified tile units in the X & Y
|
||||
// direction
|
||||
FGBucket fgBucketOffset( double dlon, double dlat, int x, int y );
|
||||
|
||||
|
||||
// calculate the offset between two buckets
|
||||
void fgBucketDiff( const FGBucket& b1, const FGBucket& b2, int *dx, int *dy );
|
||||
/**
|
||||
* \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 FGBucket& b )
|
||||
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 FGBucket& b1, const FGBucket& b2 )
|
||||
operator== ( const SGBucket& b1, const SGBucket& b2 )
|
||||
{
|
||||
return ( b1.lon == b2.lon &&
|
||||
b1.lat == b2.lat &&
|
||||
|
||||
@@ -17,37 +17,67 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef _COMPILER_H
|
||||
#define _COMPILER_H
|
||||
/** \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>.
|
||||
*/
|
||||
|
||||
// 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 FG_EXPLICIT_FUNCTION_TMPL_ARGS if the compiler
|
||||
// supports calling a function template by providing its template
|
||||
// arguments explicitly.
|
||||
// (7) Defines FG_NEED_AUTO_PTR if STL doesn't provide auto_ptr<>.
|
||||
// (8) Defines FG_NO_ARROW_OPERATOR if the compiler is unable
|
||||
// to support operator->() for iterators.
|
||||
// (9) Defines FG_USE_EXCEPTIONS if the compiler supports exceptions.
|
||||
// Note: no FlightGear code uses exceptions.
|
||||
// (10) Define FG_NAMESPACES if the compiler supports namespaces.
|
||||
// (11) FG_MATH_FN_IN_NAMESPACE_STD -- not used??
|
||||
// (12) Define FG_HAVE_STD if std namespace is supported.
|
||||
// (13) Defines FG_CLASS_PARTIAL_SPECIALIZATION if the compiler
|
||||
// supports partial specialization of class templates.
|
||||
// (14) Defines FG_HAVE_STD_INCLUDES to use ISO C++ Standard headers.
|
||||
// (15) Defines FG_HAVE_STREAMBUF if <streambuf> of <streambuf.h> are present.
|
||||
// (16) Define FG_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
|
||||
@@ -58,42 +88,97 @@
|
||||
# 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 FG_NEED_AUTO_PTR
|
||||
# define FG_NO_DEFAULT_TEMPLATE_ARGS
|
||||
# define FG_INCOMPLETE_FUNCTIONAL
|
||||
# define FG_NO_ARROW_OPERATOR
|
||||
# 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 FG_EXPLICIT_FUNCTION_TMPL_ARGS
|
||||
# define FG_NEED_AUTO_PTR
|
||||
# define FG_MEMBER_TEMPLATES
|
||||
# define FG_NAMESPACES
|
||||
# define FG_HAVE_STD
|
||||
# define FG_HAVE_STREAMBUF
|
||||
# define FG_CLASS_PARTIAL_SPECIALIZATION
|
||||
# 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
|
||||
//
|
||||
@@ -101,15 +186,16 @@
|
||||
/*
|
||||
CodeWarrior compiler from Metrowerks, Inc.
|
||||
*/
|
||||
# define FG_HAVE_TRAITS
|
||||
# define FG_HAVE_STD_INCLUDES
|
||||
# define FG_HAVE_STD
|
||||
# define FG_NAMESPACES
|
||||
# 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>
|
||||
@@ -122,7 +208,10 @@
|
||||
|
||||
// -dw- currently used glut has no game mode stuff
|
||||
# define GLUT_WRONG_VERSION
|
||||
#endif
|
||||
|
||||
# define SG_COMPILER_STR "Metrowerks CodeWarrior C++ version " SG_STRINGIZE(__MWERKS__)
|
||||
|
||||
#endif // __MWERKS__
|
||||
|
||||
//
|
||||
// Microsoft compilers.
|
||||
@@ -132,39 +221,22 @@
|
||||
# define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
|
||||
|
||||
# if _MSC_VER == 1200 // msvc++ 6.0
|
||||
# define FG_NAMESPACES
|
||||
# define FG_HAVE_STD
|
||||
# define FG_HAVE_STD_INCLUDES
|
||||
# define FG_HAVE_STREAMBUF
|
||||
# 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>
|
||||
|
||||
# pragma warning(disable: 4786) // identifier was truncated to '255' characters
|
||||
# pragma warning(disable: 4244) // conversion from double to float
|
||||
# pragma warning(disable: 4305) //
|
||||
|
||||
# elif _MSC_VER == 1100 // msvc++ 5.0
|
||||
# define NEEDNAMESPACESTD
|
||||
# define FG_NAMESPACES
|
||||
# define FG_HAVE_STD
|
||||
# define FG_HAVE_STD_INCLUDES
|
||||
# define FG_HAVE_STREAMBUF
|
||||
|
||||
# define STL_ALGORITHM <algorithm>
|
||||
# define STL_FUNCTIONAL <functional>
|
||||
# define STL_IOMANIP <iomanip>
|
||||
# define STL_IOSTREAM <iostream>
|
||||
# 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
|
||||
@@ -173,7 +245,10 @@
|
||||
# else
|
||||
# error What version of MSVC++ is this?
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# define SG_COMPILER_STR "Microsoft Visual C++ version " SG_STRINGIZE(_MSC_VER)
|
||||
|
||||
#endif // _MSC_VER
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# if defined(HAVE_SGI_STL_PORT)
|
||||
@@ -183,7 +258,7 @@
|
||||
# define STL_ALGORITHM "algorithm"
|
||||
# define STL_FUNCTIONAL "functional"
|
||||
|
||||
# define FG_MATH_EXCEPTION_CLASH
|
||||
# define SG_MATH_EXCEPTION_CLASH
|
||||
|
||||
# else
|
||||
|
||||
@@ -193,16 +268,19 @@
|
||||
# define STL_STDEXCEPT <stdexcept>
|
||||
# define STL_STRSTREAM <strstream>
|
||||
|
||||
# define FG_INCOMPLETE_FUNCTIONAL
|
||||
# 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 FG_NO_DEFAULT_TEMPLATE_ARGS
|
||||
# define FG_NAMESPACES
|
||||
// # define FG_HAVE_STD
|
||||
# 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__
|
||||
|
||||
@@ -211,23 +289,40 @@
|
||||
//
|
||||
|
||||
#if defined ( sgi ) && !defined( __GNUC__ )
|
||||
# define FG_HAVE_NATIVE_SGI_COMPILERS
|
||||
# define SG_HAVE_NATIVE_SGI_COMPILERS
|
||||
|
||||
# define FG_EXPLICIT_FUNCTION_TMPL_ARGS
|
||||
# define FG_NEED_AUTO_PTR
|
||||
# define FG_MEMBER_TEMPLATES
|
||||
# define FG_NAMESPACES
|
||||
# define FG_HAVE_STD
|
||||
# define FG_CLASS_PARTIAL_SPECIALIZATION
|
||||
# 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>
|
||||
# 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
|
||||
|
||||
@@ -243,65 +338,95 @@
|
||||
# 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 FG_NEED_EXPLICIT
|
||||
#ifdef SG_NEED_EXPLICIT
|
||||
# define explicit
|
||||
#endif
|
||||
|
||||
#ifdef FG_NEED_TYPENAME
|
||||
#ifdef SG_NEED_TYPENAME
|
||||
# define typename
|
||||
#endif
|
||||
|
||||
#ifdef FG_NEED_MUTABLE
|
||||
#ifdef SG_NEED_MUTABLE
|
||||
# define mutable
|
||||
#endif
|
||||
|
||||
#ifdef FG_NEED_BOOL
|
||||
#ifdef SG_NEED_BOOL
|
||||
typedef int bool;
|
||||
# define true 1
|
||||
# define false 0
|
||||
#endif
|
||||
|
||||
#ifdef FG_EXPLICIT_FUNCTION_TMPL_ARGS
|
||||
# define FG_NULL_TMPL_ARGS <>
|
||||
#ifdef SG_EXPLICIT_FUNCTION_TMPL_ARGS
|
||||
# define SG_NULL_TMPL_ARGS <>
|
||||
#else
|
||||
# define FG_NULL_TMPL_ARGS
|
||||
# define SG_NULL_TMPL_ARGS
|
||||
#endif
|
||||
|
||||
#ifdef FG_CLASS_PARTIAL_SPECIALIZATION
|
||||
# define FG_TEMPLATE_NULL template<>
|
||||
#ifdef SG_CLASS_PARTIAL_SPECIALIZATION
|
||||
# define SG_TEMPLATE_NULL template<>
|
||||
#else
|
||||
# define FG_TEMPLATE_NULL
|
||||
# define SG_TEMPLATE_NULL
|
||||
#endif
|
||||
|
||||
// FG_NO_NAMESPACES is a hook so that users can disable namespaces
|
||||
// SG_NO_NAMESPACES is a hook so that users can disable namespaces
|
||||
// without having to edit library headers.
|
||||
#if defined(FG_NAMESPACES) && !defined(FG_NO_NAMESPACES)
|
||||
# define FG_NAMESPACE(X) namespace X {
|
||||
# define FG_NAMESPACE_END }
|
||||
# define FG_USING_NAMESPACE(X) using namespace X
|
||||
#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 FG_NAMESPACE(X)
|
||||
# define FG_NAMESPACE_END
|
||||
# define FG_USING_NAMESPACE(X)
|
||||
# define SG_NAMESPACE(X)
|
||||
# define SG_NAMESPACE_END
|
||||
# define SG_USING_NAMESPACE(X)
|
||||
#endif
|
||||
|
||||
# ifdef FG_HAVE_STD
|
||||
# define FG_USING_STD(X) using std::X
|
||||
/** \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 FG_USING_STD(X)
|
||||
# define SG_USING_STD(X)
|
||||
# define STD
|
||||
# endif
|
||||
|
||||
// Additional <functional> implementation from SGI STL 3.11
|
||||
// Adapter function objects: pointers to member functions
|
||||
#ifdef FG_INCOMPLETE_FUNCTIONAL
|
||||
#ifdef SG_INCOMPLETE_FUNCTIONAL
|
||||
|
||||
template <class _Ret, class _Tp>
|
||||
class const_mem_fun_ref_t
|
||||
@@ -320,6 +445,6 @@ 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 // FG_INCOMPLETE_FUNCTIONAL
|
||||
#endif // SG_INCOMPLETE_FUNCTIONAL
|
||||
|
||||
#endif // _COMPILER_H
|
||||
#endif // _SG_COMPILER_H
|
||||
|
||||
@@ -1,208 +0,0 @@
|
||||
/* simgear/config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
#undef const
|
||||
|
||||
/* Define if you don't have vprintf but do have _doprnt. */
|
||||
#undef HAVE_DOPRNT
|
||||
|
||||
/* Define if you have the vprintf function. */
|
||||
#undef HAVE_VPRINTF
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> doesn't define. */
|
||||
#undef size_t
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define if your <sys/time.h> declares struct tm. */
|
||||
#undef TM_IN_SYS_TIME
|
||||
|
||||
/* Define if the X Window System is missing or not being used. */
|
||||
#undef X_DISPLAY_MISSING
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
#undef const
|
||||
|
||||
|
||||
/* Define to eliminate all trace of debugging messages such as for a
|
||||
release build */
|
||||
#undef FG_NDEBUG
|
||||
|
||||
|
||||
/* Define to enable 3dfx/glide render in a window hack under unix.
|
||||
This probably won't work under windows. */
|
||||
#undef XMESA
|
||||
#undef FX
|
||||
|
||||
/* Define if you don't have vprintf but do have _doprnt. */
|
||||
#undef HAVE_DOPRNT
|
||||
|
||||
/* Define if you have the vprintf function. */
|
||||
#undef HAVE_VPRINTF
|
||||
|
||||
/* Define if you have zlib installed system wide. */
|
||||
#undef HAVE_ZLIB
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> doesn't define. */
|
||||
#undef size_t
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define if your <sys/time.h> declares struct tm. */
|
||||
#undef TM_IN_SYS_TIME
|
||||
|
||||
/* Define if compiling on a Winbloze (95, NT, etc.) platform */
|
||||
#undef WIN32
|
||||
|
||||
/* Define if the X Window System is missing or not being used. */
|
||||
#undef X_DISPLAY_MISSING
|
||||
|
||||
/* Define if you have the GetLocalTime function. */
|
||||
#undef HAVE_GETLOCALTIME
|
||||
|
||||
/* Define if you have the bcopy function. */
|
||||
#undef HAVE_BCOPY
|
||||
|
||||
/* Define if you have the ftime function. */
|
||||
#undef HAVE_FTIME
|
||||
|
||||
/* Define if you have the getitimer function. */
|
||||
#undef HAVE_GETITIMER
|
||||
|
||||
/* Define if you have the getrusage function. */
|
||||
#undef HAVE_GETRUSAGE
|
||||
|
||||
/* Define if you have the gettimeofday function. */
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
|
||||
/* Define if you have the memcpy function. */
|
||||
#undef HAVE_MEMCPY
|
||||
|
||||
/* Define if you have the mktime function. */
|
||||
#undef HAVE_MKTIME
|
||||
|
||||
/* Define if you have the rand function. */
|
||||
#undef HAVE_RAND
|
||||
|
||||
/* Define if you have the random function. */
|
||||
#undef HAVE_RANDOM
|
||||
|
||||
/* Define if you have the rint function. */
|
||||
#undef HAVE_RINT
|
||||
|
||||
/* Define if you have the setitimer function. */
|
||||
#undef HAVE_SETITIMER
|
||||
|
||||
/* Define if you have the signal function. */
|
||||
#undef HAVE_SIGNAL
|
||||
|
||||
/* Define if you have the strstr function. */
|
||||
#undef HAVE_STRSTR
|
||||
|
||||
/* Define if you have the timegm function. */
|
||||
#undef HAVE_TIMEGM
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define if you have the <getopt.h> header file. */
|
||||
#undef HAVE_GETOPT_H
|
||||
|
||||
/* Define if you have the <malloc.h> header file. */
|
||||
#undef HAVE_MALLOC_H
|
||||
|
||||
/* Define if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define if you have the <sys/param.h> header file. */
|
||||
#undef HAVE_SYS_PARAM_H
|
||||
|
||||
/* Define if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
/* Define if you have the <sys/timeb.h> header file. */
|
||||
#undef HAVE_SYS_TIMEB_H
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define if you have the <values.h> header file. */
|
||||
#undef HAVE_VALUES_H
|
||||
|
||||
/* Define if you have the <winbase.h> header file. */
|
||||
#undef HAVE_WINBASE_H
|
||||
|
||||
/* Define if you have the <windows.h> header file. */
|
||||
#undef HAVE_WINDOWS_H
|
||||
|
||||
/* Define if you have the GL library (-lGL). */
|
||||
#undef HAVE_LIBGL
|
||||
|
||||
/* Define if you have the GLU library (-lGLU). */
|
||||
#undef HAVE_LIBGLU
|
||||
|
||||
/* Define if you have the GLcore library (-lGLcore). */
|
||||
#undef HAVE_LIBGLCORE
|
||||
|
||||
/* Define if you have the ICE library (-lICE). */
|
||||
#undef HAVE_LIBICE
|
||||
|
||||
/* Define if you have the MesaGL library (-lMesaGL). */
|
||||
#undef HAVE_LIBMESAGL
|
||||
|
||||
/* Define if you have the MesaGLU library (-lMesaGLU). */
|
||||
#undef HAVE_LIBMESAGLU
|
||||
|
||||
/* Define if you have the SM library (-lSM). */
|
||||
#undef HAVE_LIBSM
|
||||
|
||||
/* Define if you have the X11 library (-lX11). */
|
||||
#undef HAVE_LIBX11
|
||||
|
||||
/* Define if you have the Xext library (-lXext). */
|
||||
#undef HAVE_LIBXEXT
|
||||
|
||||
/* Define if you have the Xi library (-lXi). */
|
||||
#undef HAVE_LIBXI
|
||||
|
||||
/* Define if you have the Xmu library (-lXmu). */
|
||||
#undef HAVE_LIBXMU
|
||||
|
||||
/* Define if you have the Xt library (-lXt). */
|
||||
#undef HAVE_LIBXT
|
||||
|
||||
/* Define if you have the glut library (-lglut). */
|
||||
#undef HAVE_LIBGLUT
|
||||
|
||||
/* Define if you have the m library (-lm). */
|
||||
#undef HAVE_LIBM
|
||||
|
||||
/* Define if you have the socket library (-lsocket). */
|
||||
#undef HAVE_LIBSOCKET
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
@@ -21,124 +21,112 @@
|
||||
//
|
||||
// $Id$
|
||||
|
||||
/** \file constants.h
|
||||
* Various constant definitions.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SG_CONSTANTS_H
|
||||
#define _SG_CONSTANTS_H
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#ifdef FG_HAVE_STD_INCLUDES
|
||||
#ifdef SG_HAVE_STD_INCLUDES
|
||||
# include <cmath>
|
||||
#else
|
||||
# ifdef FG_MATH_EXCEPTION_CLASH
|
||||
# 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
|
||||
|
||||
// PI, only PI, and nothing but PI
|
||||
#ifdef M_PI
|
||||
# define FG_PI M_PI
|
||||
#else
|
||||
# define FG_PI 3.14159265358979323846
|
||||
#endif
|
||||
// SG_PI and SGD_PI (float and double) come from plib/sg.h
|
||||
|
||||
// 2 * PI
|
||||
#define FG_2PI 6.28318530717958647692
|
||||
/** 2 * PI */
|
||||
#define SGD_2PI 6.28318530717958647692
|
||||
|
||||
// PI / 2
|
||||
/** PI / 2 */
|
||||
#ifdef M_PI_2
|
||||
# define FG_PI_2 M_PI_2
|
||||
# define SGD_PI_2 M_PI_2
|
||||
#else
|
||||
# define FG_PI_2 1.57079632679489661923
|
||||
# define SGD_PI_2 1.57079632679489661923
|
||||
#endif
|
||||
|
||||
// PI / 4
|
||||
#define FG_PI_4 0.78539816339744830961
|
||||
/** PI / 4 */
|
||||
#define SGD_PI_4 0.78539816339744830961
|
||||
|
||||
#ifndef M_E
|
||||
# define M_E 2.7182818284590452354
|
||||
/** \def SG_E "e" */
|
||||
#ifdef M_E
|
||||
# define SG_E M_E
|
||||
#else
|
||||
# define SG_E 2.7182818284590452354
|
||||
#endif
|
||||
|
||||
// ONE_SECOND is pi/180/60/60, or about 100 feet at earths' equator
|
||||
#define ONE_SECOND 4.848136811E-6
|
||||
/** 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 EARTH_RAD 6378.155
|
||||
/** 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 [8]
|
||||
#define EQUATORIAL_RADIUS_FT 20925650. // ft
|
||||
#define EQUATORIAL_RADIUS_M 6378138.12 // meter
|
||||
// Radius squared
|
||||
#define RESQ_FT 437882827922500. // ft
|
||||
#define RESQ_M 40680645877797.1344 // meter
|
||||
/** Value of earth radius from LaRCsim (ft) */
|
||||
#define SG_EQUATORIAL_RADIUS_FT 20925650.
|
||||
|
||||
// Value of earth flattening parameter from ref [8]
|
||||
//
|
||||
// Note: FP = f
|
||||
// E = 1-f
|
||||
// EPS = sqrt(1-(1-f)^2)
|
||||
//
|
||||
|
||||
#define FP 0.003352813178
|
||||
#define E 0.996647186
|
||||
#define EPS 0.081819221
|
||||
#define INVG 0.031080997
|
||||
/** Value of earth radius from LaRCsim (meter) */
|
||||
#define SG_EQUATORIAL_RADIUS_M 6378138.12
|
||||
|
||||
// Time Related Parameters
|
||||
|
||||
#define MJD0 2415020.0
|
||||
#define J2000 (2451545.0 - MJD0)
|
||||
#define SIDRATE .9972695677
|
||||
/** Radius squared (ft) */
|
||||
#define SG_EQ_RAD_SQUARE_FT 437882827922500.
|
||||
|
||||
/** Radius squared (meter) */
|
||||
#define SG_EQ_RAD_SQUARE_M 40680645877797.1344
|
||||
|
||||
// Conversions
|
||||
|
||||
// Degrees to Radians
|
||||
#define DEG_TO_RAD 0.017453292 // deg*pi/180 = rad
|
||||
/** Arc seconds to radians. (arcsec*pi)/(3600*180) = rad */
|
||||
#define SG_ARCSEC_TO_RAD 4.84813681109535993589e-06
|
||||
|
||||
// Radians to Degrees
|
||||
#define RAD_TO_DEG 57.29577951 // rad*180/pi = deg
|
||||
/** Radians to arc seconds. (rad*3600*180)/pi = arcsec */
|
||||
#define SG_RAD_TO_ARCSEC 206264.806247096355156
|
||||
|
||||
// Arc seconds to radians // (arcsec*pi)/(3600*180) = rad
|
||||
#define ARCSEC_TO_RAD 4.84813681109535993589e-06
|
||||
/** Feet to Meters */
|
||||
#define SG_FEET_TO_METER 0.3048
|
||||
|
||||
// Radians to arc seconds // (rad*3600*180)/pi = arcsec
|
||||
#define RAD_TO_ARCSEC 206264.806247096355156
|
||||
/** Meters to Feet */
|
||||
#define SG_METER_TO_FEET 3.28083989501312335958
|
||||
|
||||
// Feet to Meters
|
||||
#define FEET_TO_METER 0.3048
|
||||
/** Meters to Nautical Miles. 1 nm = 6076.11549 feet */
|
||||
#define SG_METER_TO_NM 0.00053995680
|
||||
|
||||
// Meters to Feet
|
||||
#define METER_TO_FEET 3.28083989501312335958
|
||||
/** Nautical Miles to Meters */
|
||||
#define SG_NM_TO_METER 1852.0000
|
||||
|
||||
// Meters to Nautical Miles, 1 nm = 6076.11549 feet
|
||||
#define METER_TO_NM 0.00053995680
|
||||
/** Radians to Nautical Miles. 1 nm = 1/60 of a degree */
|
||||
#define SG_NM_TO_RAD 0.00029088820866572159
|
||||
|
||||
// Nautical Miles to Meters
|
||||
#define NM_TO_METER 1852.0000
|
||||
/** Nautical Miles to Radians */
|
||||
#define SG_RAD_TO_NM 3437.7467707849392526
|
||||
|
||||
// Radians to Nautical Miles, 1 nm = 1/60 of a degree
|
||||
#define NM_TO_RAD 0.00029088820866572159
|
||||
/** For divide by zero avoidance, this will be close enough to zero */
|
||||
#define SG_EPSILON 0.0000001
|
||||
|
||||
// Nautical Miles to Radians
|
||||
#define RAD_TO_NM 3437.7467707849392526
|
||||
|
||||
// For divide by zero avoidance, this will be close enough to zero
|
||||
#define FG_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
|
||||
@@ -8,4 +8,4 @@ include_HEADERS = debug_types.h logstream.hxx
|
||||
|
||||
libsgdebug_a_SOURCES = logstream.cxx
|
||||
|
||||
INCLUDES += -I$(top_builddir)
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
|
||||
@@ -1,38 +1,43 @@
|
||||
// NB: To add a dbg_class, add it here, and add it to the structure in
|
||||
// fg_debug.c
|
||||
/** \file debug_types.h
|
||||
* Define the various logging classes and prioritiess
|
||||
*/
|
||||
|
||||
/**
|
||||
* Define the possible classes/categories of logging messages
|
||||
*/
|
||||
typedef enum {
|
||||
FG_NONE = 0x00000000,
|
||||
SG_NONE = 0x00000000,
|
||||
|
||||
FG_TERRAIN = 0x00000001,
|
||||
FG_ASTRO = 0x00000002,
|
||||
FG_FLIGHT = 0x00000004,
|
||||
FG_INPUT = 0x00000008,
|
||||
FG_GL = 0x00000010,
|
||||
FG_VIEW = 0x00000020,
|
||||
FG_COCKPIT = 0x00000040,
|
||||
FG_GENERAL = 0x00000080,
|
||||
FG_MATH = 0x00000100,
|
||||
FG_EVENT = 0x00000200,
|
||||
FG_AIRCRAFT = 0x00000400,
|
||||
FG_AUTOPILOT = 0x00000800,
|
||||
FG_IO = 0x00001000,
|
||||
FG_CLIPPER = 0x00002000,
|
||||
FG_NETWORK = 0x00004000,
|
||||
FG_UNDEFD = 0x00008000, // For range checking
|
||||
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
|
||||
|
||||
FG_ALL = 0xFFFFFFFF
|
||||
} fgDebugClass;
|
||||
SG_ALL = 0xFFFFFFFF
|
||||
} sgDebugClass;
|
||||
|
||||
|
||||
// NB: To add a priority, add it here.
|
||||
/**
|
||||
* Define the possible logging priorities (and their order).
|
||||
*/
|
||||
typedef enum {
|
||||
FG_BULK, // For frequent messages
|
||||
FG_DEBUG, // Less frequent debug type messages
|
||||
FG_INFO, // Informatory messages
|
||||
FG_WARN, // Possible impending problem
|
||||
FG_ALERT // Very possible impending problem
|
||||
// FG_EXIT, // Problem (no core)
|
||||
// FG_ABORT // Abandon ship (core)
|
||||
} fgDebugPriority;
|
||||
|
||||
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;
|
||||
|
||||
@@ -23,9 +23,11 @@
|
||||
|
||||
#include "logstream.hxx"
|
||||
|
||||
logstream *global_logstream = NULL;
|
||||
|
||||
bool logbuf::logging_enabled = true;
|
||||
fgDebugClass logbuf::logClass = FG_NONE;
|
||||
fgDebugPriority logbuf::logPriority = FG_INFO;
|
||||
sgDebugClass logbuf::logClass = SG_NONE;
|
||||
sgDebugPriority logbuf::logPriority = SG_INFO;
|
||||
streambuf* logbuf::sbuf = NULL;
|
||||
|
||||
logbuf::logbuf()
|
||||
@@ -50,14 +52,38 @@ logbuf::set_sb( streambuf* sb )
|
||||
}
|
||||
|
||||
void
|
||||
logbuf::set_log_level( fgDebugClass c, fgDebugPriority p )
|
||||
logbuf::set_log_level( sgDebugClass c, sgDebugPriority p )
|
||||
{
|
||||
logClass = c;
|
||||
logPriority = p;
|
||||
}
|
||||
|
||||
void
|
||||
logstream::setLogLevels( fgDebugClass c, fgDebugPriority p )
|
||||
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 );
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// Stream based logging mechanism.
|
||||
//
|
||||
/** \file logstream.hxx
|
||||
* Stream based logging mechanism.
|
||||
*/
|
||||
|
||||
// Written by Bernie Bright, 1998
|
||||
//
|
||||
// Copyright (C) 1998 Bernie Bright - bbright@c031.aone.net.au
|
||||
@@ -24,34 +26,34 @@
|
||||
#ifndef _LOGSTREAM_H
|
||||
#define _LOGSTREAM_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#ifdef FG_HAVE_STD_INCLUDES
|
||||
// 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/fg_traits.hxx>
|
||||
# include <simgear/sg_traits.hxx>
|
||||
#endif
|
||||
|
||||
#include <simgear/debug/debug_types.h>
|
||||
|
||||
#ifndef FG_HAVE_NATIVE_SGI_COMPILERS
|
||||
FG_USING_STD(streambuf);
|
||||
FG_USING_STD(ostream);
|
||||
FG_USING_STD(cerr);
|
||||
FG_USING_STD(endl);
|
||||
#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__
|
||||
# define cerr std::cerr
|
||||
# define endl std::endl
|
||||
FG_USING_STD(iostream);
|
||||
SG_USING_STD(iostream);
|
||||
#endif
|
||||
|
||||
//
|
||||
@@ -62,43 +64,90 @@ FG_USING_STD(iostream);
|
||||
// 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.
|
||||
//
|
||||
/**
|
||||
* 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 FG_HAVE_STD_INCLUDES
|
||||
#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;
|
||||
// typedef char_traits<char>::pos_type pos_type;
|
||||
// typedef char_traits<char>::off_type off_type;
|
||||
#endif
|
||||
// logbuf( streambuf* sb ) : sbuf(sb) {}
|
||||
// logbuf( streambuf* sb ) : sbuf(sb) {}
|
||||
/** Constructor */
|
||||
logbuf();
|
||||
|
||||
/** Destructor */
|
||||
~logbuf();
|
||||
|
||||
// Is logging enabled?
|
||||
/**
|
||||
* Is logging enabled?
|
||||
* @return true or false*/
|
||||
bool enabled() { return logging_enabled; }
|
||||
|
||||
// Set the logging level of subsequent messages.
|
||||
void set_log_state( fgDebugClass c, fgDebugPriority p );
|
||||
/**
|
||||
* 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.
|
||||
static void set_log_level( fgDebugClass c, fgDebugPriority 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 );
|
||||
// int xsputn( const char* s, istreamsize n );
|
||||
|
||||
private:
|
||||
|
||||
@@ -106,8 +155,8 @@ private:
|
||||
static streambuf* sbuf;
|
||||
|
||||
static bool logging_enabled;
|
||||
static fgDebugClass logClass;
|
||||
static fgDebugPriority logPriority;
|
||||
static sgDebugClass logClass;
|
||||
static sgDebugPriority logPriority;
|
||||
|
||||
private:
|
||||
|
||||
@@ -119,7 +168,7 @@ private:
|
||||
inline int
|
||||
logbuf::sync()
|
||||
{
|
||||
#ifdef FG_HAVE_STD_INCLUDES
|
||||
#ifdef SG_HAVE_STD_INCLUDES
|
||||
return sbuf->pubsync();
|
||||
#else
|
||||
return sbuf->sync();
|
||||
@@ -127,7 +176,7 @@ logbuf::sync()
|
||||
}
|
||||
|
||||
inline void
|
||||
logbuf::set_log_state( fgDebugClass c, fgDebugPriority p )
|
||||
logbuf::set_log_state( sgDebugClass c, sgDebugPriority p )
|
||||
{
|
||||
logging_enabled = ((c & logClass) != 0 && p >= logPriority);
|
||||
}
|
||||
@@ -138,54 +187,65 @@ logbuf::overflow( int c )
|
||||
return logging_enabled ? sbuf->sputc(c) : (EOF == 0 ? 1: 0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// logstream manipulator for setting the log level of a message.
|
||||
//
|
||||
/**
|
||||
* logstream manipulator for setting the log level of a message.
|
||||
*/
|
||||
struct loglevel
|
||||
{
|
||||
loglevel( fgDebugClass c, fgDebugPriority p )
|
||||
loglevel( sgDebugClass c, sgDebugPriority p )
|
||||
: logClass(c), logPriority(p) {}
|
||||
|
||||
fgDebugClass logClass;
|
||||
fgDebugPriority logPriority;
|
||||
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.
|
||||
//
|
||||
/**
|
||||
* 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( 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.
|
||||
/**
|
||||
* The default is to send messages to cerr.
|
||||
* @param out output stream
|
||||
*/
|
||||
logstream( ostream& out )
|
||||
// : logstream_base(out.rdbuf()),
|
||||
// : 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.
|
||||
void setLogLevels( fgDebugClass c, fgDebugPriority p );
|
||||
/**
|
||||
* 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.
|
||||
/**
|
||||
* Output operator to capture the debug level and priority of a message.
|
||||
* @param l log level
|
||||
*/
|
||||
inline ostream& operator<< ( const loglevel& l );
|
||||
};
|
||||
|
||||
@@ -196,26 +256,51 @@ logstream::operator<< ( const loglevel& l )
|
||||
return *this;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
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&
|
||||
fglog()
|
||||
sglog()
|
||||
{
|
||||
static logstream logstrm( cerr );
|
||||
return logstrm;
|
||||
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 FG_LOG(C,P,M)
|
||||
# define SG_LOG(C,P,M)
|
||||
#elif defined( __MWERKS__ )
|
||||
# define FG_LOG(C,P,M) ::fglog() << ::loglevel(C,P) << M << std::endl
|
||||
# define SG_LOG(C,P,M) ::sglog() << ::loglevel(C,P) << M << std::endl
|
||||
#else
|
||||
# define FG_LOG(C,P,M) fglog() << loglevel(C,P) << M << endl
|
||||
# define SG_LOG(C,P,M) sglog() << loglevel(C,P) << M << endl
|
||||
#endif
|
||||
|
||||
|
||||
#endif // _LOGSTREAM_H
|
||||
|
||||
|
||||
@@ -1,23 +1,39 @@
|
||||
#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[] )
|
||||
{
|
||||
fglog().setLogLevels( FG_ALL, FG_INFO );
|
||||
sglog().setLogLevels( SG_ALL, SG_INFO );
|
||||
|
||||
FG_LOG( FG_TERRAIN, FG_BULK, "terrain::bulk" ); // shouldnt appear
|
||||
FG_LOG( FG_TERRAIN, FG_DEBUG, "terrain::debug" ); // shouldnt appear
|
||||
FG_LOG( FG_TERRAIN, FG_INFO, "terrain::info" );
|
||||
FG_LOG( FG_TERRAIN, FG_WARN, "terrain::warn" );
|
||||
FG_LOG( FG_TERRAIN, FG_ALERT, "terrain::alert" );
|
||||
//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!";
|
||||
|
||||
FG_LOG( FG_EVENT, FG_INFO, "event::info "
|
||||
SG_LOG( SG_EVENT, SG_INFO, "event::info "
|
||||
<< "i=" << i
|
||||
<< ", l=" << l
|
||||
<< ", d=" << d
|
||||
@@ -25,7 +41,7 @@ main( int argc, char* argv[] )
|
||||
<< ", s=\"" << s << "\"" );
|
||||
|
||||
// This shouldn't appear in log output:
|
||||
FG_LOG( FG_EVENT, FG_DEBUG, "event::debug "
|
||||
SG_LOG( SG_EVENT, SG_DEBUG, "event::debug "
|
||||
<< "- this should be seen - "
|
||||
<< "d=" << d
|
||||
<< ", s=\"" << s << "\"" );
|
||||
|
||||
3
simgear/ephemeris/.cvsignore
Normal file
3
simgear/ephemeris/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -8,11 +8,11 @@ include_HEADERS = \
|
||||
jupiter.hxx \
|
||||
mars.hxx \
|
||||
mercury.hxx \
|
||||
moon.hxx \
|
||||
moonpos.hxx \
|
||||
neptune.hxx \
|
||||
saturn.hxx \
|
||||
star.hxx \
|
||||
stars.hxx \
|
||||
stardata.hxx \
|
||||
uranus.hxx \
|
||||
venus.hxx
|
||||
|
||||
@@ -22,13 +22,13 @@ libsgephem_a_SOURCES = \
|
||||
jupiter.cxx \
|
||||
mars.cxx \
|
||||
mercury.cxx \
|
||||
moon.cxx \
|
||||
moonpos.cxx \
|
||||
neptune.cxx \
|
||||
pluto.hxx \
|
||||
saturn.cxx \
|
||||
star.cxx \
|
||||
stars.cxx \
|
||||
stardata.cxx \
|
||||
uranus.cxx \
|
||||
venus.cxx
|
||||
|
||||
INCLUDES += -I$(top_builddir)
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#ifdef FG_MATH_EXCEPTION_CLASH
|
||||
#ifdef SG_MATH_EXCEPTION_CLASH
|
||||
# define exception c_exception
|
||||
#endif
|
||||
#include <math.h>
|
||||
@@ -62,7 +62,7 @@ void CelestialBody::updatePosition(double mjd, Star *ourSun)
|
||||
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 = sgCalcEccAnom(M, e); //calculate the eccentric anomaly
|
||||
xv = a * (cos(eccAnom) - e);
|
||||
@@ -88,7 +88,7 @@ void CelestialBody::updatePosition(double mjd, 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 : "
|
||||
/* SG_LOG(SG_GENERAL, SG_INFO, "Planet found at : "
|
||||
<< rightAscension << " (ra), " << declination << " (dec)" ); */
|
||||
|
||||
//calculate some variables specific to calculating the magnitude
|
||||
@@ -107,8 +107,8 @@ void CelestialBody::updatePosition(double mjd, Star *ourSun)
|
||||
tmp = -1.0;
|
||||
}
|
||||
|
||||
FV = RAD_TO_DEG * acos( tmp );
|
||||
};
|
||||
FV = SGD_RADIANS_TO_DEGREES * acos( tmp );
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* double CelestialBody::sgCalcEccAnom(double M, double e)
|
||||
@@ -152,28 +152,118 @@ double CelestialBody::sgCalcEccAnom(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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -87,113 +87,6 @@ public:
|
||||
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, 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);
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
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
|
||||
***************************************************************************/
|
||||
inline void CelestialBody::updateOrbElements(double mjd)
|
||||
{
|
||||
double actTime = sgCalcActTime(mjd);
|
||||
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::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.
|
||||
****************************************************************************/
|
||||
inline 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
|
||||
*
|
||||
****************************************************************************/
|
||||
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; }
|
||||
@@ -210,14 +103,3 @@ inline double CelestialBody::getLat()
|
||||
|
||||
#endif // _CELESTIALBODY_H_
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
// Constructor
|
||||
SGEphemeris::SGEphemeris( const string &path ) {
|
||||
our_sun = new Star;
|
||||
moon = new Moon;
|
||||
moon = new MoonPos;
|
||||
mercury = new Mercury;
|
||||
venus = new Venus;
|
||||
mars = new Mars;
|
||||
@@ -37,7 +37,7 @@ SGEphemeris::SGEphemeris( const string &path ) {
|
||||
saturn = new Saturn;
|
||||
uranus = new Uranus;
|
||||
neptune = new Neptune;
|
||||
stars = new SGStarData( FGPath(path) );
|
||||
stars = new SGStarData( SGPath(path) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ephemeris.hxx -- Top level class for calculating current positions of
|
||||
// astronomical objects
|
||||
//
|
||||
/** \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
|
||||
@@ -30,14 +31,10 @@
|
||||
#define _EPHEMERIS_HXX
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
#include <simgear/ephemeris/moon.hxx>
|
||||
#include <simgear/ephemeris/moonpos.hxx>
|
||||
#include <simgear/ephemeris/mercury.hxx>
|
||||
#include <simgear/ephemeris/venus.hxx>
|
||||
#include <simgear/ephemeris/mars.hxx>
|
||||
@@ -45,13 +42,35 @@
|
||||
#include <simgear/ephemeris/saturn.hxx>
|
||||
#include <simgear/ephemeris/uranus.hxx>
|
||||
#include <simgear/ephemeris/neptune.hxx>
|
||||
#include <simgear/ephemeris/stars.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;
|
||||
Moon *moon;
|
||||
MoonPos *moon;
|
||||
Mercury *mercury;
|
||||
Venus *venus;
|
||||
Mars *mars;
|
||||
@@ -71,40 +90,84 @@ class SGEphemeris {
|
||||
|
||||
public:
|
||||
|
||||
// Constructor
|
||||
/**
|
||||
* 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
|
||||
/** Destructor */
|
||||
~SGEphemeris( void );
|
||||
|
||||
// Update (recalculate) the positions of all objects for the
|
||||
// specified time
|
||||
/**
|
||||
* 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);
|
||||
|
||||
// sun
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
|
||||
// moon
|
||||
inline Moon *get_moon() const { return moon; }
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
|
||||
// planets
|
||||
/** @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; }
|
||||
|
||||
// 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(); }
|
||||
};
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
#ifndef _JUPITER_HXX_
|
||||
#define _JUPITER_HXX_
|
||||
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
#include <simgear/ephemeris/celestialBody.hxx>
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
|
||||
class Jupiter : public CelestialBody
|
||||
{
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
#ifndef _MARS_HXX_
|
||||
#define _MARS_HXX_
|
||||
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
#include <simgear/ephemeris/celestialBody.hxx>
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
|
||||
class Mars : public CelestialBody
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**************************************************************************
|
||||
* moon.cxx
|
||||
* 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
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/fgpath.hxx>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
# define exception c_exception
|
||||
@@ -36,18 +35,18 @@
|
||||
|
||||
// #include <FDM/flight.hxx>
|
||||
|
||||
#include "moon.hxx"
|
||||
#include "moonpos.hxx"
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Moon::Moon(double mjd)
|
||||
* Public constructor for class Moon. Initializes the orbital elements and
|
||||
* 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 Moon are passed to
|
||||
* the hard coded orbital elements for MoonPos are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Moon::Moon(double mjd) :
|
||||
MoonPos::MoonPos(double mjd) :
|
||||
CelestialBody(125.1228, -0.0529538083,
|
||||
5.1454, 0.00000,
|
||||
318.0634, 0.1643573223,
|
||||
@@ -57,7 +56,7 @@ Moon::Moon(double mjd) :
|
||||
{
|
||||
}
|
||||
|
||||
Moon::Moon() :
|
||||
MoonPos::MoonPos() :
|
||||
CelestialBody(125.1228, -0.0529538083,
|
||||
5.1454, 0.00000,
|
||||
318.0634, 0.1643573223,
|
||||
@@ -68,18 +67,18 @@ Moon::Moon() :
|
||||
}
|
||||
|
||||
|
||||
Moon::~Moon()
|
||||
MoonPos::~MoonPos()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* void Moon::updatePosition(double mjd, Star *ourSun)
|
||||
* 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 Moon::updatePosition(double mjd, double lst, double lat, Star *ourSun)
|
||||
void MoonPos::updatePosition(double mjd, double lst, double lat, Star *ourSun)
|
||||
{
|
||||
double
|
||||
eccAnom, ecl, actTime,
|
||||
@@ -92,7 +91,7 @@ void Moon::updatePosition(double mjd, double lst, double lat, Star *ourSun)
|
||||
|
||||
// calculate the angle between ecliptic and equatorial coordinate system
|
||||
// in Radians
|
||||
ecl = ((DEG_TO_RAD * 23.4393) - (DEG_TO_RAD * 3.563E-7) * actTime);
|
||||
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));
|
||||
@@ -116,7 +115,7 @@ void Moon::updatePosition(double mjd, double lst, double lat, Star *ourSun)
|
||||
D = Lm - Ls;
|
||||
F = Lm - N;
|
||||
|
||||
lonEcl += DEG_TO_RAD * (-1.274 * sin (M - 2*D)
|
||||
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)
|
||||
@@ -129,7 +128,7 @@ void Moon::updatePosition(double mjd, double lst, double lat, Star *ourSun)
|
||||
-0.015 * sin(2*F - 2*D)
|
||||
+0.011 * sin(M - 4*D)
|
||||
);
|
||||
latEcl += DEG_TO_RAD * (-0.173 * sin(F-2*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)
|
||||
@@ -138,7 +137,7 @@ void Moon::updatePosition(double mjd, double lst, double lat, Star *ourSun)
|
||||
r += (-0.58 * cos(M - 2*D)
|
||||
-0.46 * cos(2*D)
|
||||
);
|
||||
// FG_LOG(FG_GENERAL, FG_INFO, "Running moon update");
|
||||
// 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);
|
||||
@@ -150,9 +149,9 @@ void Moon::updatePosition(double mjd, double lst, double lat, Star *ourSun)
|
||||
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) << ")" ); */
|
||||
/* 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
|
||||
@@ -162,30 +161,40 @@ void Moon::updatePosition(double mjd, double lst, double lat, Star *ourSun)
|
||||
// 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() );
|
||||
// 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 * DEG_TO_RAD * lat );
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "gclat = " << gclat );
|
||||
sin (2 * SGD_DEGREES_TO_RADIANS * lat );
|
||||
// SG_LOG( SG_GENERAL, SG_INFO, "gclat = " << gclat );
|
||||
|
||||
rho = 0.99883 + 0.00167 * cos(2 * DEG_TO_RAD * lat);
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "rho = " << rho );
|
||||
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*FG_PI);
|
||||
geoRa += (2*SGD_PI);
|
||||
|
||||
HA = lst - (3.8197186 * geoRa);
|
||||
/* FG_LOG( FG_GENERAL, FG_INFO, "t->getLst() = " << t->getLst()
|
||||
/* SG_LOG( SG_GENERAL, SG_INFO, "t->getLst() = " << t->getLst()
|
||||
<< " HA = " << HA ); */
|
||||
|
||||
g = atan (tan(gclat) / cos ((HA / 3.8197186)));
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "g = " << g );
|
||||
// SG_LOG( SG_GENERAL, SG_INFO, "g = " << g );
|
||||
|
||||
rightAscension = geoRa - mpar * rho * cos(gclat) * sin(HA) / cos (geoDec);
|
||||
declination = geoDec - mpar * rho * sin (gclat) * sin (g - geoDec) / sin(g);
|
||||
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;
|
||||
}
|
||||
|
||||
/* FG_LOG( FG_GENERAL, FG_INFO,
|
||||
"Ra = (" << (RAD_TO_DEG *rightAscension)
|
||||
<< "), Dec= (" << (RAD_TO_DEG *declination) << ")" ); */
|
||||
/* SG_LOG( SG_GENERAL, SG_INFO,
|
||||
"Ra = (" << (SGD_RADIANS_TO_DEGREES *rightAscension)
|
||||
<< "), Dec= (" << (SGD_RADIANS_TO_DEGREES *declination) << ")" ); */
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**************************************************************************
|
||||
* moon.hxx
|
||||
* 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
|
||||
@@ -22,8 +22,8 @@
|
||||
*
|
||||
* $Id$
|
||||
**************************************************************************/
|
||||
#ifndef _MOON_HXX_
|
||||
#define _MOON_HXX_
|
||||
#ifndef _MOONPOS_HXX_
|
||||
#define _MOONPOS_HXX_
|
||||
|
||||
|
||||
#include <simgear/constants.h>
|
||||
@@ -31,7 +31,8 @@
|
||||
#include <simgear/ephemeris/celestialBody.hxx>
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
|
||||
class Moon : public CelestialBody
|
||||
|
||||
class MoonPos : public CelestialBody
|
||||
{
|
||||
|
||||
private:
|
||||
@@ -49,12 +50,12 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
Moon(double mjd);
|
||||
Moon();
|
||||
~Moon();
|
||||
MoonPos(double mjd);
|
||||
MoonPos();
|
||||
~MoonPos();
|
||||
void updatePosition(double mjd, double lst, double lat, Star *ourSun);
|
||||
// void newImage();
|
||||
};
|
||||
|
||||
|
||||
#endif // _MOON_HXX_
|
||||
#endif // _MOONPOS_HXX_
|
||||
@@ -25,8 +25,8 @@
|
||||
#ifndef _NEPTUNE_HXX_
|
||||
#define _NEPTUNE_HXX_
|
||||
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
#include <simgear/ephemeris/celestialBody.hxx>
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
|
||||
class Neptune : public CelestialBody
|
||||
{
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
#ifndef _SATURN_HXX_
|
||||
#define _SATURN_HXX_
|
||||
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
#include <simgear/ephemeris/celestialBody.hxx>
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
|
||||
class Saturn : public CelestialBody
|
||||
{
|
||||
|
||||
@@ -85,7 +85,7 @@ void Star::updatePosition(double mjd)
|
||||
updateOrbElements(mjd);
|
||||
|
||||
actTime = sgCalcActTime(mjd);
|
||||
ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime); // Angle in Radians
|
||||
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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// stars.cxx -- manage star data
|
||||
// stardata.cxx -- manage star data
|
||||
//
|
||||
// Written by Curtis Olson, started March 2000.
|
||||
//
|
||||
@@ -23,20 +23,24 @@
|
||||
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/fgstream.hxx>
|
||||
#include <simgear/misc/sgstream.hxx>
|
||||
|
||||
#include "stars.hxx"
|
||||
#include "stardata.hxx"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
FG_USING_STD(getline);
|
||||
#if defined (_MSC_VER) || defined (SG_HAVE_NATIVE_SGI_COMPILERS)
|
||||
SG_USING_STD(getline);
|
||||
#endif
|
||||
|
||||
// Constructor
|
||||
SGStarData::SGStarData() {
|
||||
SGStarData::SGStarData() :
|
||||
nstars(0)
|
||||
{
|
||||
}
|
||||
|
||||
SGStarData::SGStarData( FGPath path ) {
|
||||
data_path = FGPath( path );
|
||||
SGStarData::SGStarData( SGPath path ) :
|
||||
nstars(0)
|
||||
{
|
||||
data_path = SGPath( path );
|
||||
load();
|
||||
}
|
||||
|
||||
@@ -54,11 +58,11 @@ bool SGStarData::load() {
|
||||
|
||||
// build the full path name to the stars data base file
|
||||
data_path.append( "stars" );
|
||||
FG_LOG( FG_ASTRO, FG_INFO, " Loading stars from " << data_path.str() );
|
||||
SG_LOG( SG_ASTRO, SG_INFO, " Loading stars from " << data_path.str() );
|
||||
|
||||
fg_gzifstream in( data_path.str() );
|
||||
sg_gzifstream in( data_path.str() );
|
||||
if ( ! in.is_open() ) {
|
||||
FG_LOG( FG_ASTRO, FG_ALERT, "Cannot open star file: "
|
||||
SG_LOG( SG_ASTRO, SG_ALERT, "Cannot open star file: "
|
||||
<< data_path.str() );
|
||||
exit(-1);
|
||||
}
|
||||
@@ -116,7 +120,7 @@ bool SGStarData::load() {
|
||||
++nstars;
|
||||
}
|
||||
|
||||
FG_LOG( FG_ASTRO, FG_INFO, " Loaded " << nstars << " stars" );
|
||||
SG_LOG( SG_ASTRO, SG_INFO, " Loaded " << nstars << " stars" );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// stars.hxx -- manage star data
|
||||
// stardata.hxx -- manage star data
|
||||
//
|
||||
// Written by Curtis Olson, started March 2000.
|
||||
//
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
#include <simgear/misc/fgpath.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
||||
|
||||
#define SG_MAX_STARS 850
|
||||
@@ -39,13 +39,13 @@ class SGStarData {
|
||||
int nstars;
|
||||
sgdVec3 *stars;
|
||||
|
||||
FGPath data_path;
|
||||
SGPath data_path;
|
||||
|
||||
public:
|
||||
|
||||
// Constructor
|
||||
SGStarData();
|
||||
SGStarData( FGPath path );
|
||||
SGStarData( SGPath path );
|
||||
|
||||
// Destructor
|
||||
~SGStarData();
|
||||
@@ -25,8 +25,8 @@
|
||||
#ifndef _URANUS_HXX_
|
||||
#define _URANUS_HXX_
|
||||
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
#include <simgear/ephemeris/celestialBody.hxx>
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
|
||||
class Uranus : public CelestialBody
|
||||
{
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
#ifndef _VENUS_HXX_
|
||||
#define _VENUS_HXX_
|
||||
|
||||
#include "celestialBody.hxx"
|
||||
#include "star.hxx"
|
||||
#include <simgear/ephemeris/celestialBody.hxx>
|
||||
#include <simgear/ephemeris/star.hxx>
|
||||
|
||||
class Venus : public CelestialBody
|
||||
{
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
/**************************************************************************
|
||||
* fg_zlib.h -- a zlib wrapper to replace zlib calls with normal uncompressed
|
||||
* calls for systems that have problems building zlib.
|
||||
*
|
||||
* Written by Curtis Olson, started April 1998.
|
||||
*
|
||||
* Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
|
||||
*
|
||||
* 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 _FG_ZLIB_H
|
||||
#define _FG_ZLIB_H
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef AVOID_USING_ZLIB
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define fgFile FILE *
|
||||
|
||||
/* fgFile fgopen(char *filename, const char *flags) */
|
||||
#define fgopen(P, F) (fopen((P), (F)))
|
||||
|
||||
/* int fgseek(fgFile *file, long offset, int whence) */
|
||||
#define fgseek(F, O, W) (fseek((F), (O), (W)))
|
||||
|
||||
/* fgread(fgFile file, void *buf, int size); */
|
||||
#define fgread(F, B, S) (fread((B), (S), 1, (F)))
|
||||
|
||||
/* int fggets(fgFile fd, char *buffer, int len) */
|
||||
#define fggets(F, B, L) (fgets((B), (L), (F)))
|
||||
|
||||
/* int fgclose(fgFile fd) */
|
||||
#define fgclose(F) (fclose((F)))
|
||||
#else
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
#include <zlib.h>
|
||||
#else
|
||||
#include <simgear/zlib/zlib.h>
|
||||
#endif
|
||||
|
||||
#define fgFile gzFile
|
||||
|
||||
/* fgFile fgopen(char *filename, const char *flags) */
|
||||
#define fgopen(P, F) (gzopen((P), (F)))
|
||||
|
||||
/* int fgseek(fgFile *file, long offset, int whence) */
|
||||
#define fgseek(F, O, W) (gzseek((F), (O), (W)))
|
||||
|
||||
/* fgread(fgFile file, void *buf, int size); */
|
||||
#define fgread(F, B, S) (gzread((F), (B), (S)))
|
||||
|
||||
/* int fggets(fgFile fd, char *buffer, int len) */
|
||||
#define fggets(F, B, L) (gzgets((F), (B), (L)))
|
||||
|
||||
/* int fgclose(fgFile fd) */
|
||||
#define fgclose(F) (gzclose((F)))
|
||||
|
||||
#endif /* #ifdef AVOID_USING_ZLIB #else #endif */
|
||||
|
||||
|
||||
#endif /* _FG_ZLIB_H */
|
||||
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
// inlines.h -- various inline template definitions
|
||||
//
|
||||
// Written by Norman Vine, started June 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Norman Vine - nhv@cape.com
|
||||
//
|
||||
// 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_INLINES_H
|
||||
#define _SG_INLINES_H
|
||||
|
||||
|
||||
template <class T>
|
||||
inline const int SG_SIGN(const T x) {
|
||||
return x < T(0) ? -1 : 1;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const T SG_MIN(const T a, const T b) {
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
// return the minimum of three values
|
||||
template <class T>
|
||||
inline const T SG_MIN3( const T a, const T b, const T c) {
|
||||
return (a < b ? SG_MIN (a, c) : SG_MIN (b, c));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const T SG_MAX(const T a, const T b) {
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
// return the maximum of three values
|
||||
template <class T>
|
||||
inline const T SG_MAX3 (const T a, const T b, const T c) {
|
||||
return (a > b ? SG_MAX (a, c) : SG_MAX (b, c));
|
||||
}
|
||||
|
||||
//
|
||||
template <class T>
|
||||
inline void SG_SWAP( T &a, T &b) {
|
||||
T c = a; a = b; b = c;
|
||||
}
|
||||
|
||||
#endif // _SG_INLINES_H
|
||||
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
2031
simgear/interpreter/lex.javascript.cc
Normal file
2031
simgear/interpreter/lex.javascript.cc
Normal file
File diff suppressed because it is too large
Load Diff
168
simgear/interpreter/lex.javascript.yy
Normal file
168
simgear/interpreter/lex.javascript.yy
Normal file
@@ -0,0 +1,168 @@
|
||||
/* -------- definitions ------- */
|
||||
|
||||
%option c++ yylineno noyywrap prefix="js" outfile="lex.javascript.cc" batch
|
||||
|
||||
%{
|
||||
#include <ixlib_js_internals.hh>
|
||||
#include <ixlib_token_javascript.hh>
|
||||
|
||||
using namespace ixion;
|
||||
using namespace javascript;
|
||||
%}
|
||||
|
||||
WHITESPACE [ \t\n\r]
|
||||
|
||||
DIGIT [0-9]
|
||||
DIGIT_NZ [1-9]
|
||||
DIGIT_OCT [0-7]
|
||||
DIGIT_HEX [0-9a-fA-F]
|
||||
DIGIT_SEQ {DIGIT}+
|
||||
|
||||
NONDIGIT [_a-zA-Z]
|
||||
ID_COMPONENT [_a-zA-Z0-9]
|
||||
|
||||
ESCAPE_SIMPLE \\['"?\\abfnrtv]
|
||||
ESCAPE_OCTAL \\{DIGIT_OCT}{1,3}
|
||||
ESCAPE_HEX \\x{DIGIT_HEX}{1,2}
|
||||
ESCAPE {ESCAPE_SIMPLE}|{ESCAPE_OCTAL}|{ESCAPE_HEX}
|
||||
S_CHAR [^"\\\n]|{ESCAPE}
|
||||
|
||||
SIGN \+|\-
|
||||
SIGNopt {SIGN}?
|
||||
|
||||
|
||||
|
||||
|
||||
/* higher-level entities ------------------------------------------------------
|
||||
*/
|
||||
IDENTIFIER {NONDIGIT}{ID_COMPONENT}*
|
||||
|
||||
|
||||
|
||||
|
||||
/* literals -------------------------------------------------------------------
|
||||
*/
|
||||
LIT_DECIMAL {DIGIT_NZ}{DIGIT}*
|
||||
LIT_OCTAL 0{DIGIT_OCT}*
|
||||
LIT_HEX 0[xX]{DIGIT_HEX}+
|
||||
LIT_INT ({LIT_DECIMAL}|{LIT_OCTAL}|{LIT_HEX})
|
||||
|
||||
LIT_STRING \"{S_CHAR}*\"|\'{S_CHAR}*\'
|
||||
|
||||
LIT_FRACTION {DIGIT_SEQ}?\.{DIGIT_SEQ}|{DIGIT_SEQ}\.
|
||||
LIT_EXPONENT [eE]{SIGNopt}{DIGIT_SEQ}
|
||||
LIT_FLOAT {LIT_FRACTION}{LIT_EXPONENT}?|{DIGIT_SEQ}{LIT_EXPONENT}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Contexts -------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
%x Comment
|
||||
%x LineComment
|
||||
|
||||
|
||||
|
||||
|
||||
/* Rules ----------------------------------------------------------------------
|
||||
*/
|
||||
%%
|
||||
|
||||
\/\* BEGIN(Comment);
|
||||
<Comment>\*\/ BEGIN(INITIAL);
|
||||
<Comment><<EOF>> EXJS_THROW(ECJS_UNTERMINATED_COMMENT)
|
||||
<Comment>. /* nothing */
|
||||
<Comment>\n /* nothing */
|
||||
\/\/ BEGIN(LineComment);
|
||||
<LineComment>[\n\r]+ BEGIN(INITIAL);
|
||||
<LineComment>. /* nothing */
|
||||
|
||||
<<EOF>> return TT_EOF;
|
||||
|
||||
\{ return '{';
|
||||
\} return '}';
|
||||
\; return ';';
|
||||
|
||||
\[ return '[';
|
||||
\] return ']';
|
||||
\( return '(';
|
||||
\) return ')';
|
||||
\? return '?';
|
||||
\: return ':';
|
||||
\+ return '+';
|
||||
\- return '-';
|
||||
\* return '*';
|
||||
\/ return '/';
|
||||
\% return '%';
|
||||
\^ return '^';
|
||||
\& return '&';
|
||||
\| return '|';
|
||||
\~ return '~';
|
||||
\! return '!';
|
||||
\= return '=';
|
||||
\< return '<';
|
||||
\> return '>';
|
||||
\, return ',';
|
||||
\. return '.';
|
||||
\+\= return TT_JS_PLUS_ASSIGN;
|
||||
\-\= return TT_JS_MINUS_ASSIGN;
|
||||
\*\= return TT_JS_MULTIPLY_ASSIGN;
|
||||
\/\= return TT_JS_DIVIDE_ASSIGN;
|
||||
\%\= return TT_JS_MODULO_ASSIGN;
|
||||
\^\= return TT_JS_BIT_XOR_ASSIGN;
|
||||
\&\= return TT_JS_BIT_AND_ASSIGN;
|
||||
\|\= return TT_JS_BIT_OR_ASSIGN;
|
||||
\<\< return TT_JS_LEFT_SHIFT;
|
||||
\>\> return TT_JS_RIGHT_SHIFT;
|
||||
\<\<\= return TT_JS_LEFT_SHIFT_ASSIGN;
|
||||
\>\>\= return TT_JS_RIGHT_SHIFT_ASSIGN;
|
||||
\=\=\= return TT_JS_IDENTICAL;
|
||||
\!\=\= return TT_JS_NOT_IDENTICAL;
|
||||
\=\= return TT_JS_EQUAL;
|
||||
\!\= return TT_JS_NOT_EQUAL;
|
||||
\<\= return TT_JS_LESS_EQUAL;
|
||||
\>\= return TT_JS_GREATER_EQUAL;
|
||||
\&\& return TT_JS_LOGICAL_AND;
|
||||
\|\| return TT_JS_LOGICAL_OR;
|
||||
\+\+ return TT_JS_INCREMENT;
|
||||
\-\- return TT_JS_DECREMENT;
|
||||
|
||||
new return TT_JS_NEW;
|
||||
|
||||
this return TT_JS_THIS;
|
||||
function return TT_JS_FUNCTION;
|
||||
var return TT_JS_VAR;
|
||||
null return TT_JS_NULL;
|
||||
if return TT_JS_IF;
|
||||
while return TT_JS_WHILE;
|
||||
do return TT_JS_DO;
|
||||
else return TT_JS_ELSE;
|
||||
for return TT_JS_FOR;
|
||||
return return TT_JS_RETURN;
|
||||
switch return TT_JS_SWITCH;
|
||||
case return TT_JS_CASE;
|
||||
continue return TT_JS_CONTINUE;
|
||||
break return TT_JS_BREAK;
|
||||
default return TT_JS_DEFAULT;
|
||||
true return TT_JS_LIT_TRUE;
|
||||
false return TT_JS_LIT_FALSE;
|
||||
undefined return TT_JS_LIT_UNDEFINED;
|
||||
in return TT_JS_IN;
|
||||
const return TT_JS_CONST;
|
||||
class return TT_JS_CLASS;
|
||||
extends return TT_JS_EXTENDS;
|
||||
namespace return TT_JS_NAMESPACE;
|
||||
static return TT_JS_STATIC;
|
||||
constructor return TT_JS_CONSTRUCTOR;
|
||||
|
||||
{LIT_INT} return TT_JS_LIT_INT;
|
||||
{LIT_FLOAT} return TT_JS_LIT_FLOAT;
|
||||
{LIT_STRING} return TT_JS_LIT_STRING;
|
||||
|
||||
{IDENTIFIER} return TT_JS_IDENTIFIER;
|
||||
|
||||
{WHITESPACE}+ /* nothing */
|
||||
. EXJS_THROWINFOLOCATION(ECJS_INVALID_TOKEN,YYText(),code_location(lineno()))
|
||||
41
simgear/interpreter/main.cc
Normal file
41
simgear/interpreter/main.cc
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <ixlib_js_internals.hh>
|
||||
#include <ixlib_exbase.hh>
|
||||
#include <ixlib_javascript.hh>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
using namespace ixion;
|
||||
using namespace ixion::javascript;
|
||||
|
||||
IXLIB_JS_DECLARE_FUNCTION(write)
|
||||
{
|
||||
if (parameters.size() != 1) {
|
||||
EXJS_THROWINFO(ECJS_INVALID_NUMBER_OF_ARGUMENTS, "write");
|
||||
}
|
||||
std::cout << parameters[0]->toString();
|
||||
return makeConstant(parameters[0]->toString());
|
||||
}
|
||||
|
||||
int main (int ac, char ** av) {
|
||||
interpreter *jsint = new interpreter();
|
||||
addStandardLibrary(*jsint);
|
||||
ref<value> x = new write();
|
||||
jsint->RootScope->addMember("write", x);
|
||||
|
||||
if (ac == 1) {
|
||||
std::cerr << "Usage: " << av[0] << "<file+>" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
for (int i = 1; i < ac; i++) {
|
||||
std::ifstream input(av[i]);
|
||||
try {
|
||||
ref<value> result = jsint->execute(input);
|
||||
std::cout << av[i] << " returned " << result->stringify() << std::endl;
|
||||
} catch (base_exception &ex) {
|
||||
std::cerr << ex.getText() << ex.what() << std::endl;
|
||||
}
|
||||
input.close();
|
||||
}
|
||||
delete jsint;
|
||||
}
|
||||
|
||||
144
simgear/interpreter/numconv.cc
Normal file
144
simgear/interpreter/numconv.cc
Normal file
@@ -0,0 +1,144 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Numeric conversions
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 1999 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#include <ixlib_exgen.hh>
|
||||
#include <ixlib_numconv.hh>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace ixion;
|
||||
|
||||
|
||||
|
||||
|
||||
// data objects --------------------------------------------------------------
|
||||
static string numChars = IXLIB_NUMCHARS;
|
||||
|
||||
|
||||
|
||||
|
||||
// exported subroutines -------------------------------------------------------
|
||||
string ixion::float2dec(double value) {
|
||||
char buf[255];
|
||||
sprintf((char *)&buf,"%f",value);
|
||||
return string(buf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string ixion::float2dec(double value, unsigned int precision) {
|
||||
char buf[255];
|
||||
string cmd("%.");
|
||||
|
||||
cmd += unsigned2dec(precision) + "f";
|
||||
sprintf((char *)&buf,cmd.c_str(),value);
|
||||
return string(buf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string ixion::unsigned2base(unsigned long value,char digits,char radix) {
|
||||
string temp;
|
||||
do {
|
||||
temp = numChars[value % radix]+temp;
|
||||
value /= radix;
|
||||
if (digits) digits--;
|
||||
} while (value || digits);
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string ixion::signed2base(signed long value,char digits,char radix) {
|
||||
if (value < 0) return "-"+unsigned2base(-value,digits,radix);
|
||||
else return unsigned2base(value,digits,radix);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string ixion::bytes2dec(TSize bytes) {
|
||||
if (bytes>(TSize) 10*1024*1024)
|
||||
return unsigned2dec(bytes / ((TSize) 1024*1024))+" MB";
|
||||
if (bytes>(TSize) 10*1024)
|
||||
return unsigned2dec(bytes / ((TSize) 1024))+" KB";
|
||||
return unsigned2dec(bytes)+" Byte";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned long ixion::evalNumeral(string const &numeral,unsigned radix) {
|
||||
string numstr = upper(numeral);
|
||||
|
||||
if (numstr.size() == 0) return 0;
|
||||
unsigned long value = 0, mulvalue = 1;
|
||||
TIndex index = numstr.size()-1;
|
||||
|
||||
do {
|
||||
string::size_type digvalue = numChars.find(numstr[index]);
|
||||
if (digvalue == string::npos)
|
||||
EXGEN_THROWINFO(EC_CANNOTEVALUATE,numstr.c_str())
|
||||
value += mulvalue * digvalue;
|
||||
mulvalue *= radix;
|
||||
} while (index--);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
double ixion::evalFloat(string const &numeral) {
|
||||
double result;
|
||||
int count = sscanf(numeral.c_str(), "%le", &result);
|
||||
if (count == 0) EXGEN_THROWINFO(EC_CANNOTEVALUATE,numeral.c_str())
|
||||
else return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned long ixion::evalUnsigned(string const &numeral,unsigned default_base) {
|
||||
if (numeral.size() == 0) return 0;
|
||||
|
||||
if (numeral.substr(0,2) == "0X" || numeral.substr(0,2) == "0x")
|
||||
return evalNumeral(numeral.substr(2),0x10);
|
||||
if (numeral.substr(0,1) == "$")
|
||||
return evalNumeral(numeral.substr(1),0x10);
|
||||
|
||||
char lastchar = numeral[numeral.size()-1];
|
||||
if (lastchar == 'H' || lastchar == 'h') return evalNumeral(numeral.substr(0,numeral.size()-1),0x10);
|
||||
if (lastchar == 'B' || lastchar == 'b') return evalNumeral(numeral.substr(0,numeral.size()-1),2);
|
||||
if (lastchar == 'D' || lastchar == 'd') return evalNumeral(numeral.substr(0,numeral.size()-1),10);
|
||||
if (lastchar == 'O' || lastchar == 'o') return evalNumeral(numeral.substr(0,numeral.size()-1),8);
|
||||
|
||||
return evalNumeral(numeral,default_base);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
signed long ixion::evalSigned(string const &numeral,unsigned default_base) {
|
||||
if (numeral.size() == 0) return 0;
|
||||
if (numeral[0] == '-')
|
||||
return - (signed long) evalUnsigned(numeral.substr(1),default_base);
|
||||
else {
|
||||
if (numeral[0] == '+')
|
||||
return evalUnsigned(numeral.substr(1),default_base);
|
||||
else
|
||||
return evalUnsigned(numeral,default_base);
|
||||
}
|
||||
}
|
||||
38
simgear/interpreter/numeric.cc
Normal file
38
simgear/interpreter/numeric.cc
Normal file
@@ -0,0 +1,38 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Numeric / order processing
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 1998 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#include <ixlib_numeric.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
// BCD encoding ---------------------------------------------------------------
|
||||
unsigned long ixion::unsigned2BCD(unsigned long value)
|
||||
{
|
||||
unsigned long bcdvalue = 0,bcdshift = 0;
|
||||
while (value) {
|
||||
bcdvalue += (value % 10) << bcdshift;
|
||||
bcdshift += 4;
|
||||
value /= 10;
|
||||
}
|
||||
return bcdvalue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned long ixion::BCD2unsigned(unsigned long value)
|
||||
{
|
||||
unsigned long decvalue = 0;
|
||||
for (unsigned long i = 1;value;i *= 10) {
|
||||
decvalue += (value & 0xf) * i;
|
||||
value >>= 4;
|
||||
}
|
||||
return decvalue;
|
||||
}
|
||||
427
simgear/interpreter/re.cc
Normal file
427
simgear/interpreter/re.cc
Normal file
@@ -0,0 +1,427 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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>
|
||||
#include <ixlib_re_impl.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace ixion;
|
||||
|
||||
|
||||
|
||||
|
||||
// Template instantiations ----------------------------------------------------
|
||||
template regex<string>;
|
||||
|
||||
|
||||
|
||||
|
||||
// Error texts ----------------------------------------------------------------
|
||||
static char *RegexPlainText[] = {
|
||||
N_("Invalid quantifier"),
|
||||
N_("Unbalanced backreference"),
|
||||
N_("Invalid escape sequence"),
|
||||
N_("Invalid backreference"),
|
||||
N_("Unterminated character class"),
|
||||
N_("Unable to match without expression"),
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// regex_exception ------------------------------------------------------------
|
||||
regex_exception::regex_exception(TErrorCode error,
|
||||
char const *info,char *module,TIndex line)
|
||||
: base_exception(error,info,module,line,"RE") {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
char *regex_exception::getText() const {
|
||||
return _(RegexPlainText[Error]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// regex_string::class_matcher ------------------------------------------------
|
||||
regex_string::class_matcher::class_matcher()
|
||||
: Negated(false) {
|
||||
MatchLength = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
regex_string::class_matcher::class_matcher(string const &cls)
|
||||
: Negated(false) {
|
||||
MatchLength = 1;
|
||||
|
||||
if (cls.size() && cls[0] == XSTRRE_CLASSNEG) {
|
||||
expandClass(cls.substr(1));
|
||||
Negated = true;
|
||||
}
|
||||
else
|
||||
expandClass(cls);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ixion::regex<string>::matcher *ixion::regex_string::class_matcher::duplicate() const {
|
||||
class_matcher *dupe = new class_matcher();
|
||||
dupe->copy(this);
|
||||
return dupe;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool regex_string::class_matcher::match(backref_stack &brstack,string const &candidate,TIndex at) {
|
||||
if (at >= candidate.size()) return false;
|
||||
|
||||
bool result = Set[candidate[at]];
|
||||
if (Negated) result = !result;
|
||||
|
||||
return result && matchNext(brstack,candidate,at+1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void regex_string::class_matcher::expandClass(string const &cls) {
|
||||
memset(&Set,0,sizeof(Set));
|
||||
|
||||
if (cls.size() == 0) return;
|
||||
Set[cls[0]] = true;
|
||||
char lastchar = cls[0];
|
||||
|
||||
for (TIndex index = 1;index < cls.size();index++) {
|
||||
if ((cls[index] == XSTRRE_CLASSRANGE) && (index < cls.size()-1)) {
|
||||
for (char ch = lastchar+1;ch < cls[index+1];ch++)
|
||||
Set[ch] = true;
|
||||
}
|
||||
else Set[cls[index]] = true;
|
||||
lastchar = cls[index];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ixion::regex_string::class_matcher::copy(class_matcher const *src) {
|
||||
super::copy(src);
|
||||
for (TIndex i = 0;i < CharValues;i++)
|
||||
Set[i] = src->Set[i];
|
||||
Negated = src->Negated;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// regex_string::special_class_matcher ----------------------------------------
|
||||
regex_string::special_class_matcher::special_class_matcher(type tp)
|
||||
: Type(tp) {
|
||||
MatchLength = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ixion::regex<string>::matcher *ixion::regex_string::special_class_matcher::duplicate() const {
|
||||
special_class_matcher *dupe = new special_class_matcher(Type);
|
||||
dupe->copy(this);
|
||||
return dupe;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool regex_string::special_class_matcher::match(backref_stack &brstack,string const &candidate,TIndex at) {
|
||||
if (at >= candidate.size()) return false;
|
||||
enum type { DIGIT,NONDIGIT,ALNUM,NONALNUM,SPACE,NONSPACE };
|
||||
|
||||
bool result;
|
||||
switch (Type) {
|
||||
case DIGIT: result = isdigit(candidate[at]);
|
||||
break;
|
||||
case NONDIGIT: result = !isdigit(candidate[at]);
|
||||
break;
|
||||
case ALNUM: result = isalnum(candidate[at]);
|
||||
break;
|
||||
case NONALNUM: result = !isalnum(candidate[at]);
|
||||
break;
|
||||
case SPACE: result = isspace(candidate[at]);
|
||||
break;
|
||||
case NONSPACE: result = !isspace(candidate[at]);
|
||||
break;
|
||||
default:
|
||||
EX_THROW(regex,ECRE_INVESCAPE)
|
||||
}
|
||||
|
||||
return result && matchNext(brstack,candidate,at+1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// regex_string ---------------------------------------------------------------
|
||||
void regex_string::parse(string const &expr) {
|
||||
auto_ptr<matcher> new_re(parseRegex(expr));
|
||||
ParsedRegex = new_re;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string regex_string::replaceAll(string const &candidate,string const &replacement,TIndex from) {
|
||||
string result;
|
||||
string tempreplacement;
|
||||
|
||||
LastCandidate = candidate;
|
||||
if (ParsedRegex.get() == NULL)
|
||||
EX_THROW(regex,ECRE_NOPATTERN)
|
||||
|
||||
for (TIndex index = from;index < candidate.size();) {
|
||||
BackrefStack.clear();
|
||||
if (ParsedRegex->match(BackrefStack,candidate,index)) {
|
||||
TIndex matchlength = ParsedRegex->subsequentMatchLength();
|
||||
tempreplacement = replacement;
|
||||
|
||||
TSize backrefs = BackrefStack.size();
|
||||
for (TIndex i = 0;i < backrefs;i++)
|
||||
tempreplacement = findReplace(tempreplacement,XSTRRE_BACKREF+unsigned2dec(i),
|
||||
BackrefStack.get(i,LastCandidate));
|
||||
|
||||
result += tempreplacement;
|
||||
index += matchlength;
|
||||
}
|
||||
else result += candidate[index++];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
regex_string::matcher *regex_string::parseRegex(string const &expr) {
|
||||
if (!expr.size()) return NULL;
|
||||
TIndex index = 0;
|
||||
matcher *firstobject,*lastobject = NULL;
|
||||
alternative_matcher *alternative = NULL;
|
||||
|
||||
while (index < expr.size()) {
|
||||
matcher *object = NULL;
|
||||
quantifier *quantifier = NULL;
|
||||
bool quantified = true;
|
||||
char ch;
|
||||
|
||||
// several objects may be inserted in one loop run
|
||||
switch (expr[index++]) {
|
||||
// case XSTRRE_BACKREF: (dupe)
|
||||
// case XSTRRE_ESCAPESEQ: (dupe)
|
||||
case XSTRRE_LITERAL: {
|
||||
if (index >= expr.size()) EX_THROW(regex,ECRE_INVESCAPE)
|
||||
|
||||
ch = expr[index++];
|
||||
if (isdigit(ch))
|
||||
object = new backref_matcher(ch-'0');
|
||||
else {
|
||||
switch (ch) {
|
||||
case 'd': object = new special_class_matcher(special_class_matcher::DIGIT);
|
||||
break;
|
||||
case 'D': object = new special_class_matcher(special_class_matcher::NONDIGIT);
|
||||
break;
|
||||
case 'w': object = new special_class_matcher(special_class_matcher::ALNUM);
|
||||
break;
|
||||
case 'W': object = new special_class_matcher(special_class_matcher::NONALNUM);
|
||||
break;
|
||||
case 's': object = new special_class_matcher(special_class_matcher::SPACE);
|
||||
break;
|
||||
case 'S': object = new special_class_matcher(special_class_matcher::NONSPACE);
|
||||
break;
|
||||
default: object = new sequence_matcher(string(1,ch));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XSTRRE_ANYCHAR:
|
||||
object = new any_matcher;
|
||||
break;
|
||||
case XSTRRE_START:
|
||||
quantified = false;
|
||||
object = new start_matcher;
|
||||
break;
|
||||
case XSTRRE_END:
|
||||
quantified = false;
|
||||
object = new end_matcher;
|
||||
break;
|
||||
case XSTRRE_ALTERNATIVE: {
|
||||
if (!alternative)
|
||||
alternative = new alternative_matcher;
|
||||
alternative->addAlternative(firstobject);
|
||||
firstobject = NULL;
|
||||
lastobject = NULL;
|
||||
break;
|
||||
}
|
||||
case XSTRRE_CLASSSTART: {
|
||||
TIndex classend = expr.find(XSTRRE_CLASSSTOP,index);
|
||||
if (classend == string::npos)
|
||||
EX_THROW(regex,ECRE_UNTERMCLASS)
|
||||
object = new class_matcher(expr.substr(index,classend-index));
|
||||
|
||||
index = classend+1;
|
||||
break;
|
||||
}
|
||||
case XSTRRE_BACKREFSTART: {
|
||||
matcher *parsed;
|
||||
|
||||
TSize brlevel = 1;
|
||||
for (TIndex searchstop = index;searchstop < expr.size();searchstop++) {
|
||||
if ((expr[searchstop] == XSTRRE_BACKREFSTART) &&
|
||||
(expr[searchstop-1] != XSTRRE_LITERAL))
|
||||
brlevel++;
|
||||
if ((expr[searchstop] == XSTRRE_BACKREFSTOP) &&
|
||||
(expr[searchstop-1] != XSTRRE_LITERAL)) {
|
||||
brlevel--;
|
||||
if (brlevel == 0) {
|
||||
parsed = parseRegex(expr.substr(index,searchstop-index));
|
||||
if (!parsed) EX_THROW(regex,ECRE_INVBACKREF)
|
||||
|
||||
index = searchstop+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!parsed) EX_THROW(regex,ECRE_UNBALBACKREF)
|
||||
|
||||
object = new backref_open_matcher;
|
||||
object->setNext(parsed);
|
||||
|
||||
matcher *closer = new backref_close_matcher;
|
||||
|
||||
matcher *searchlast = parsed,*foundlast;
|
||||
while (searchlast) {
|
||||
foundlast = searchlast;
|
||||
searchlast = searchlast->getNext();
|
||||
}
|
||||
foundlast->setNext(closer);
|
||||
|
||||
break;
|
||||
}
|
||||
case XSTRRE_BACKREFSTOP:
|
||||
EX_THROW(regex,ECRE_UNBALBACKREF)
|
||||
default:
|
||||
object = new sequence_matcher(expr.substr(index-1,1));
|
||||
break;
|
||||
}
|
||||
|
||||
if (object) {
|
||||
if (quantified) quantifier = parseQuantifier(expr,index);
|
||||
if (quantifier) {
|
||||
quantifier->setQuantified(object);
|
||||
if (lastobject) lastobject->setNext(quantifier);
|
||||
else firstobject = quantifier;
|
||||
}
|
||||
else {
|
||||
if (lastobject) lastobject->setNext(object);
|
||||
else firstobject = object;
|
||||
}
|
||||
}
|
||||
|
||||
// we need this for the alternative matcher, which also inserts
|
||||
// its connector
|
||||
matcher *searchlast = quantifier ? quantifier : object;
|
||||
while (searchlast) {
|
||||
lastobject = searchlast;
|
||||
searchlast = searchlast->getNext();
|
||||
}
|
||||
}
|
||||
if (alternative) {
|
||||
alternative->addAlternative(firstobject);
|
||||
return alternative;
|
||||
}
|
||||
else return firstobject;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
regex_string::quantifier *regex_string::parseQuantifier(string const &expr,TIndex &at) {
|
||||
quantifier *quant = NULL;
|
||||
if (at == expr.size()) return NULL;
|
||||
if (expr[at] == XSTRREQ_0PLUS) {
|
||||
quant = new quantifier(isGreedy(expr,++at),0);
|
||||
return quant;
|
||||
}
|
||||
if (expr[at] == XSTRREQ_1PLUS) {
|
||||
quant = new quantifier(isGreedy(expr,++at),1);
|
||||
return quant;
|
||||
}
|
||||
if (expr[at] == XSTRREQ_01) {
|
||||
quant = new quantifier(isGreedy(expr,++at),0,1);
|
||||
return quant;
|
||||
}
|
||||
if (expr[at] == XSTRREQ_START) {
|
||||
TSize min,max;
|
||||
|
||||
at++;
|
||||
TIndex endindex;
|
||||
endindex = expr.find(XSTRREQ_STOP,at);
|
||||
if (endindex == string::npos)
|
||||
EXGEN_THROW(ECRE_INVQUANTIFIER)
|
||||
|
||||
string quantspec = expr.substr(at,endindex-at);
|
||||
at = endindex+1;
|
||||
|
||||
try {
|
||||
string::size_type rangeindex = quantspec.find(XSTRREQ_RANGE);
|
||||
if (rangeindex == string::npos) {
|
||||
min = evalUnsigned(quantspec);
|
||||
quant = new quantifier(isGreedy(expr,at),min,min);
|
||||
}
|
||||
else if (rangeindex == quantspec.size()-1) {
|
||||
min = evalUnsigned(quantspec.substr(0,rangeindex));
|
||||
quant = new quantifier(isGreedy(expr,at),min);
|
||||
}
|
||||
else {
|
||||
min = evalUnsigned(quantspec.substr(0,rangeindex));
|
||||
max = evalUnsigned(quantspec.substr(rangeindex+1));
|
||||
quant = new quantifier(isGreedy(expr,at),min,max);
|
||||
}
|
||||
return quant;
|
||||
}
|
||||
EX_CONVERT(generic,EC_CANNOTEVALUATE,regex,ECRE_INVQUANTIFIER)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool regex_string::isGreedy(string const &expr,TIndex &at)
|
||||
{
|
||||
if (at == expr.size()) return true;
|
||||
if (expr[at] == XSTRREQ_NONGREEDY) {
|
||||
at++;
|
||||
return false;
|
||||
}
|
||||
else return true;
|
||||
}
|
||||
108
simgear/interpreter/scanner.cc
Normal file
108
simgear/interpreter/scanner.cc
Normal file
@@ -0,0 +1,108 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Scanner for xTextFile
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 1999 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#include <FlexLexer.h>
|
||||
#include "ixlib_i18n.hh"
|
||||
#include <ixlib_numconv.hh>
|
||||
#include <ixlib_token_lex.hh>
|
||||
#include <ixlib_scanner.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace ixion;
|
||||
|
||||
|
||||
|
||||
|
||||
// Plain text rendering table -------------------------------------------------
|
||||
static char *(PlainText[]) = {
|
||||
N_("Unknown token"),
|
||||
N_("End of input")
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// scanner_exception ----------------------------------------------------------
|
||||
scanner_exception::scanner_exception(TErrorCode error, TIndex line,
|
||||
string const &info)
|
||||
: base_exception(error, NULL, NULL, 0, "SCAN") {
|
||||
HasInfo = true;
|
||||
try {
|
||||
string temp = "line ";
|
||||
temp += unsigned2dec(line);
|
||||
if (info != "") {
|
||||
temp += " : ";
|
||||
temp += info;
|
||||
}
|
||||
strcpy(Info, temp.c_str());
|
||||
}
|
||||
catch (...) { }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
char *scanner_exception::getText() const {
|
||||
return PlainText[Error];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// scanner --------------------------------------------------------------------
|
||||
scanner::scanner(FlexLexer &lexer)
|
||||
: Lexer(lexer) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
scanner::token_list scanner::scan() {
|
||||
CurrentToken.Type = Lexer.yylex();
|
||||
CurrentToken.Line = Lexer.lineno();
|
||||
CurrentToken.Text = Lexer.YYText();
|
||||
|
||||
token_list tokenlist;
|
||||
while (!reachedEOF()) {
|
||||
tokenlist.push_back(getNextToken());
|
||||
}
|
||||
return tokenlist;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
scanner::token scanner::getNextToken() {
|
||||
if (!reachedEOF()) {
|
||||
token lasttoken = CurrentToken;
|
||||
|
||||
CurrentToken.Type = Lexer.yylex();
|
||||
CurrentToken.Line = Lexer.lineno();
|
||||
CurrentToken.Text = Lexer.YYText();
|
||||
|
||||
if (CurrentToken.Type == TT_UNKNOWN)
|
||||
throw scanner_exception(ECSCAN_UNKNOWN_TOKEN,CurrentToken.Line,CurrentToken.Text);
|
||||
else return lasttoken;
|
||||
}
|
||||
throw scanner_exception(ECSCAN_UNKNOWN_TOKEN, CurrentToken.Line, "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool scanner::reachedEOF() const {
|
||||
return (CurrentToken.Type == TT_EOF);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
317
simgear/interpreter/string.cc
Normal file
317
simgear/interpreter/string.cc
Normal file
@@ -0,0 +1,317 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : String object
|
||||
// ----------------------------------------------------------------------------
|
||||
// (c) Copyright 1999 by iXiONmedia, all rights reserved.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#include <cstring>
|
||||
#include <cctype>
|
||||
#include <ixlib_numconv.hh>
|
||||
#include <ixlib_string.hh>
|
||||
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace ixion;
|
||||
|
||||
|
||||
|
||||
|
||||
// String utility functions ---------------------------------------------------
|
||||
string ixion::findReplace(string const &target,string const &src,string const &dest) {
|
||||
string result = target;
|
||||
TIndex foundpos = string::npos;
|
||||
TIndex n = src.size();
|
||||
while ((foundpos = result.find(src)) != string::npos)
|
||||
result.replace(foundpos,n,dest);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string ixion::findReplace(string const &target,char* src,char *dest) {
|
||||
string result = target;
|
||||
TSize foundpos = string::npos;
|
||||
TSize n = strlen(src);
|
||||
while ((foundpos = result.find(src)) != string::npos)
|
||||
result.replace(foundpos,n,dest);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string ixion::findReplace(string const &target,char src,char dest) {
|
||||
string result = target;
|
||||
string::iterator first = result.begin(),last = result.end();
|
||||
|
||||
while (first != last) {
|
||||
if (*first == src) *first = dest;
|
||||
first++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string ixion::upper(string const &original) {
|
||||
string temp(original);
|
||||
string::iterator first = temp.begin(),last = temp.end();
|
||||
|
||||
while (first != last) {
|
||||
*first = toupper(*first);
|
||||
first++;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string ixion::lower(string const &original) {
|
||||
string temp(original);
|
||||
string::iterator first = temp.begin(),last = temp.end();
|
||||
|
||||
while (first != last) {
|
||||
*first = tolower(*first);
|
||||
first++;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string ixion::removeLeading(string const &original,char ch) {
|
||||
string copy(original);
|
||||
string::iterator first = copy.begin(), last = copy.end();
|
||||
|
||||
while (first != last && *first == ch) first++;
|
||||
if (first != copy.begin()) copy.erase(copy.begin(),first);
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string ixion::removeTrailing(string const &original,char ch) {
|
||||
string copy(original);
|
||||
string::iterator first = copy.begin(), last = copy.end();
|
||||
|
||||
if (first != last) {
|
||||
last--;
|
||||
while (first != last && *last == ch) last--;
|
||||
if (*last != ch) last++;
|
||||
}
|
||||
|
||||
if (last != copy.end()) copy.erase(last,copy.end());
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string ixion::removeLeadingTrailing(string const &original,char ch) {
|
||||
string copy(original);
|
||||
string::iterator first = copy.begin(), last = copy.end();
|
||||
|
||||
while (first != last && *first == ch) first++;
|
||||
if (first != copy.begin()) copy.erase(copy.begin(),first);
|
||||
|
||||
first = copy.begin();
|
||||
last = copy.end();
|
||||
|
||||
if (first != last) {
|
||||
last--;
|
||||
while (first != last && *last == ch) last--;
|
||||
if (*last != ch) last++;
|
||||
}
|
||||
|
||||
if (last != copy.end()) copy.erase(last,copy.end());
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
string ixion::parseCEscapes(string const &original) {
|
||||
string result = "";
|
||||
string::const_iterator first = original.begin(),last = original.end();
|
||||
while (first != last) {
|
||||
if (*first == '\\') {
|
||||
first++;
|
||||
if (first == last) {
|
||||
result += '\\';
|
||||
break;
|
||||
}
|
||||
|
||||
#define GET_TEMP_STRING(LENGTH) \
|
||||
if (original.end()-first < LENGTH) \
|
||||
EXGEN_THROWINFO(EC_INVALIDPAR,"invalid escape sequence") \
|
||||
tempstring = string(first,first+LENGTH); \
|
||||
first += LENGTH;
|
||||
|
||||
char value;
|
||||
string tempstring;
|
||||
switch (*first) {
|
||||
case 'b': result += '\b'; first++; break;
|
||||
case 'f': result += '\f'; first++; break;
|
||||
case 'n': result += '\n'; first++; break;
|
||||
case 't': result += '\t'; first++; break;
|
||||
case 'v': result += '\v'; first++; break;
|
||||
case 'X':
|
||||
case 'x': first++;
|
||||
GET_TEMP_STRING(2)
|
||||
value = evalNumeral(tempstring,16);
|
||||
result += value;
|
||||
break;
|
||||
case 'u': first++;
|
||||
GET_TEMP_STRING(4)
|
||||
value = evalNumeral(tempstring,16);
|
||||
result += value;
|
||||
break;
|
||||
case '0':
|
||||
GET_TEMP_STRING(3)
|
||||
value = evalNumeral(tempstring,8);
|
||||
result += value;
|
||||
break;
|
||||
default: result += *first++;
|
||||
}
|
||||
}
|
||||
else result += *first++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
namespace {
|
||||
TByte const B64_INVALID = 0xff;
|
||||
TByte const B64_PAD = 0xfe;
|
||||
char const B64_PAD_CHAR = '=';
|
||||
char Base64EncodeTable[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
TByte Base64DecodeTable[] = { // based at 0
|
||||
// see test/invertmap.js on how to generate this table
|
||||
B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,
|
||||
B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,
|
||||
B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,
|
||||
B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,
|
||||
B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,
|
||||
B64_INVALID,B64_INVALID,B64_INVALID,62,B64_INVALID,B64_INVALID,B64_INVALID,63,52,53,54,
|
||||
55,56,57,58,59,60,61,B64_INVALID,B64_INVALID,B64_INVALID,B64_PAD,B64_INVALID,
|
||||
B64_INVALID,B64_INVALID,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,
|
||||
19,20,21,22,23,24,25,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,
|
||||
B64_INVALID,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,
|
||||
44,45,46,47,48,49,50,51,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,B64_INVALID,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TSize ixion::getMaxBase64DecodedSize(TSize encoded) {
|
||||
return ((encoded+3)/4)*3;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TSize ixion::base64decode(TByte *data,string const &base64) {
|
||||
string::const_iterator first = base64.begin(),last = base64.end();
|
||||
|
||||
TByte *data_start = data;
|
||||
|
||||
TUnsigned32 block;
|
||||
TByte a,b,c,d;
|
||||
|
||||
while (first != last) {
|
||||
a = Base64DecodeTable[*(first++)];
|
||||
b = Base64DecodeTable[*(first++)];
|
||||
c = Base64DecodeTable[*(first++)];
|
||||
d = Base64DecodeTable[*(first++)];
|
||||
if (c == B64_PAD) {
|
||||
block = a << 3*6 | b << 2*6;
|
||||
*data++ = (block >> 16) & 0xff;
|
||||
}
|
||||
else if (d == B64_PAD) {
|
||||
block = a << 3*6 | b << 2*6 | c << 1*6;
|
||||
*data++ = (block >> 16) & 0xff;
|
||||
*data++ = (block >> 8) & 0xff;
|
||||
}
|
||||
else {
|
||||
block = a << 3*6 | b << 2*6 | c << 1*6 | d << 0*6;
|
||||
*data++ = (block >> 16) & 0xff;
|
||||
*data++ = (block >> 8) & 0xff;
|
||||
*data++ = (block >> 0) & 0xff;
|
||||
}
|
||||
}
|
||||
return data-data_start;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ixion::base64encode(string &base64,TByte const *data,TSize size) {
|
||||
base64.resize((size+2)/3*4);
|
||||
|
||||
TUnsigned32 block;
|
||||
TByte a,b,c,d;
|
||||
|
||||
TByte const *end = data+size;
|
||||
string::iterator first = base64.begin();
|
||||
while (data < end)
|
||||
if (data+1 == end) {
|
||||
block = data[0] << 16;
|
||||
a = (block >> 3*6) & 0x3f;
|
||||
b = (block >> 2*6) & 0x3f;
|
||||
*first++ = Base64EncodeTable[a];
|
||||
*first++ = Base64EncodeTable[b];
|
||||
*first++ = B64_PAD_CHAR;
|
||||
*first++ = B64_PAD_CHAR;
|
||||
data++;
|
||||
}
|
||||
else if (data+2 == end) {
|
||||
block = data[0] << 16 | data[1] << 8;
|
||||
a = (block >> 3*6) & 0x3f;
|
||||
b = (block >> 2*6) & 0x3f;
|
||||
c = (block >> 1*6) & 0x3f;
|
||||
*first++ = Base64EncodeTable[a];
|
||||
*first++ = Base64EncodeTable[b];
|
||||
*first++ = Base64EncodeTable[c];
|
||||
*first++ = B64_PAD_CHAR;
|
||||
data += 2;
|
||||
}
|
||||
else {
|
||||
block = data[0] << 16 | data[1] << 8 | data[2];
|
||||
a = (block >> 3*6) & 0x3f;
|
||||
b = (block >> 2*6) & 0x3f;
|
||||
c = (block >> 1*6) & 0x3f;
|
||||
d = (block >> 0*6) & 0x3f;
|
||||
*first++ = Base64EncodeTable[a];
|
||||
*first++ = Base64EncodeTable[b];
|
||||
*first++ = Base64EncodeTable[c];
|
||||
*first++ = Base64EncodeTable[d];
|
||||
data += 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// string_hash ----------------------------------------------------------------
|
||||
unsigned long ixion::string_hash::operator()(string const &str) const {
|
||||
// the sgi stl uses the same hash algorithm
|
||||
unsigned long h = 0;
|
||||
FOREACH_CONST(first,str,string)
|
||||
h = 5*h + *first;
|
||||
return h;
|
||||
}
|
||||
8
simgear/io/.cvsignore
Normal file
8
simgear/io/.cvsignore
Normal file
@@ -0,0 +1,8 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
decode_binobj
|
||||
lowtest
|
||||
socktest
|
||||
tcp_client
|
||||
tcp_server
|
||||
@@ -4,14 +4,73 @@ lib_LIBRARIES = libsgio.a
|
||||
|
||||
include_HEADERS = \
|
||||
iochannel.hxx \
|
||||
lowlevel.hxx \
|
||||
sg_binobj.hxx \
|
||||
sg_file.hxx \
|
||||
sg_serial.hxx \
|
||||
sg_socket.hxx
|
||||
sg_socket.hxx \
|
||||
sg_socket_udp.hxx
|
||||
|
||||
libsgio_a_SOURCES = \
|
||||
iochannel.cxx \
|
||||
lowlevel.cxx \
|
||||
sg_binobj.cxx \
|
||||
sg_file.cxx \
|
||||
sg_serial.cxx \
|
||||
sg_socket.cxx
|
||||
sg_socket.cxx \
|
||||
sg_socket_udp.cxx
|
||||
|
||||
INCLUDES += -I$(top_builddir)
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
|
||||
if IS_MINGW
|
||||
NETWORK_LIB = -lwsock32
|
||||
else
|
||||
NETWORK_LIB =
|
||||
endif
|
||||
|
||||
noinst_PROGRAMS = decode_binobj socktest lowtest tcp_server tcp_client
|
||||
|
||||
tcp_server_SOURCES = tcp_server.cxx
|
||||
|
||||
tcp_server_LDADD = \
|
||||
$(top_builddir)/simgear/io/libsgio.a \
|
||||
$(top_builddir)/simgear/debug/libsgdebug.a \
|
||||
$(top_builddir)/simgear/bucket/libsgbucket.a \
|
||||
$(top_builddir)/simgear/misc/libsgmisc.a \
|
||||
$(top_builddir)/simgear/xml/libsgxml.a \
|
||||
-lplibnet -lplibul -lz $(NETWORK_LIB)
|
||||
|
||||
tcp_client_SOURCES = tcp_client.cxx
|
||||
|
||||
tcp_client_LDADD = \
|
||||
$(top_builddir)/simgear/io/libsgio.a \
|
||||
$(top_builddir)/simgear/debug/libsgdebug.a \
|
||||
$(top_builddir)/simgear/bucket/libsgbucket.a \
|
||||
$(top_builddir)/simgear/misc/libsgmisc.a \
|
||||
$(top_builddir)/simgear/xml/libsgxml.a \
|
||||
-lplibnet -lplibul -lz $(NETWORK_LIB)
|
||||
|
||||
socktest_SOURCES = socktest.cxx
|
||||
|
||||
socktest_LDADD = \
|
||||
$(top_builddir)/simgear/bucket/libsgbucket.a \
|
||||
$(top_builddir)/simgear/io/libsgio.a \
|
||||
$(top_builddir)/simgear/debug/libsgdebug.a \
|
||||
$(top_builddir)/simgear/misc/libsgmisc.a \
|
||||
$(top_builddir)/simgear/xml/libsgxml.a \
|
||||
-lplibnet -lplibul -lz $(NETWORK_LIB)
|
||||
|
||||
lowtest_SOURCES = lowtest.cxx
|
||||
|
||||
lowtest_LDADD = \
|
||||
$(top_builddir)/simgear/io/libsgio.a
|
||||
|
||||
decode_binobj_SOURCES = decode_binobj.cxx
|
||||
|
||||
decode_binobj_LDADD = \
|
||||
$(top_builddir)/simgear/io/libsgio.a \
|
||||
$(top_builddir)/simgear/bucket/libsgbucket.a \
|
||||
$(top_builddir)/simgear/misc/libsgmisc.a \
|
||||
$(top_builddir)/simgear/debug/libsgdebug.a \
|
||||
$(top_builddir)/simgear/xml/libsgxml.a \
|
||||
-lz
|
||||
|
||||
151
simgear/io/decode_binobj.cxx
Normal file
151
simgear/io/decode_binobj.cxx
Normal file
@@ -0,0 +1,151 @@
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include STL_IOSTREAM
|
||||
|
||||
#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
|
||||
SG_USING_STD(cout);
|
||||
SG_USING_STD(endl);
|
||||
#endif
|
||||
|
||||
#include "sg_binobj.hxx"
|
||||
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
int i, j;
|
||||
|
||||
// check usage
|
||||
if ( argc != 2 ) {
|
||||
cout << "Usage: " << argv[0] << " binary_obj_file" << endl;
|
||||
}
|
||||
|
||||
SGBinObject obj;
|
||||
bool result = obj.read_bin( argv[1] );
|
||||
if ( !result ) {
|
||||
cout << "error loading: " << argv[1] << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
cout << "# FGFS Scenery" << endl;
|
||||
cout << "# Version " << obj.get_version() << endl;
|
||||
cout << endl;
|
||||
|
||||
printf("# gbs %.5f %.5f %.5f %.2f\n", obj.get_gbs_center().x(),
|
||||
obj.get_gbs_center().y(), obj.get_gbs_center().z(),
|
||||
obj.get_gbs_radius());
|
||||
cout << endl;
|
||||
|
||||
point_list nodes = obj.get_wgs84_nodes();
|
||||
cout << "# vertex list" << endl;
|
||||
for ( i = 0; i < (int)nodes.size(); ++i ) {
|
||||
printf("v %.5f %.5f %.5f\n", nodes[i].x(), nodes[i].y(), nodes[i].z() );
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
point_list normals = obj.get_normals();
|
||||
cout << "# vertex normal list" << endl;
|
||||
for ( i = 0; i < (int)normals.size(); ++i ) {
|
||||
printf("vn %.5f %.5f %.5f\n",
|
||||
normals[i].x(), normals[i].y(), normals[i].z() );
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
point_list texcoords = obj.get_texcoords();
|
||||
cout << "# texture coordinate list" << endl;
|
||||
for ( i = 0; i < (int)texcoords.size(); ++i ) {
|
||||
printf("vt %.5f %.5f\n",
|
||||
texcoords[i].x(), texcoords[i].y() );
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
cout << "# geometry groups" << endl;
|
||||
cout << endl;
|
||||
|
||||
string material;
|
||||
int_list vertex_index;
|
||||
int_list normal_index;
|
||||
int_list tex_index;
|
||||
|
||||
// generate points
|
||||
string_list pt_materials = obj.get_pt_materials();
|
||||
group_list pts_v = obj.get_pts_v();
|
||||
group_list pts_n = obj.get_pts_n();
|
||||
for ( i = 0; i < (int)pts_v.size(); ++i ) {
|
||||
material = pt_materials[i];
|
||||
vertex_index = pts_v[i];
|
||||
normal_index = pts_n[i];
|
||||
cout << "# usemtl " << material << endl;
|
||||
cout << "pt ";
|
||||
for ( j = 0; j < (int)vertex_index.size(); ++j ) {
|
||||
cout << vertex_index[j] << "/" << normal_index[j] << " ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
// generate triangles
|
||||
string_list tri_materials = obj.get_tri_materials();
|
||||
group_list tris_v = obj.get_tris_v();
|
||||
group_list tris_n = obj.get_tris_n();
|
||||
group_list tris_tc = obj.get_tris_tc();
|
||||
for ( i = 0; i < (int)tris_v.size(); ++i ) {
|
||||
material = tri_materials[i];
|
||||
vertex_index = tris_v[i];
|
||||
normal_index = tris_n[i];
|
||||
tex_index = tris_tc[i];
|
||||
cout << "# usemtl " << material << endl;
|
||||
cout << "f ";
|
||||
for ( j = 0; j < (int)vertex_index.size(); ++j ) {
|
||||
cout << vertex_index[j];
|
||||
if ( normal_index.size() ) {
|
||||
cout << "/" << normal_index[j];
|
||||
}
|
||||
cout << "/" << tex_index[j];
|
||||
cout << " ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
// generate strips
|
||||
string_list strip_materials = obj.get_strip_materials();
|
||||
group_list strips_v = obj.get_strips_v();
|
||||
group_list strips_n = obj.get_strips_n();
|
||||
group_list strips_tc = obj.get_strips_tc();
|
||||
for ( i = 0; i < (int)strips_v.size(); ++i ) {
|
||||
material = strip_materials[i];
|
||||
vertex_index = strips_v[i];
|
||||
normal_index = strips_n[i];
|
||||
tex_index = strips_tc[i];
|
||||
cout << "# usemtl " << material << endl;
|
||||
cout << "ts ";
|
||||
for ( j = 0; j < (int)vertex_index.size(); ++j ) {
|
||||
cout << vertex_index[j];
|
||||
if ( normal_index.size() ) {
|
||||
cout << "/" << normal_index[j];
|
||||
}
|
||||
cout << "/" << tex_index[j] << " ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
// generate fans
|
||||
string_list fan_materials = obj.get_fan_materials();
|
||||
group_list fans_v = obj.get_fans_v();
|
||||
group_list fans_n = obj.get_fans_n();
|
||||
group_list fans_tc = obj.get_fans_tc();
|
||||
for ( i = 0; i < (int)fans_v.size(); ++i ) {
|
||||
material = fan_materials[i];
|
||||
vertex_index = fans_v[i];
|
||||
normal_index = fans_n[i];
|
||||
tex_index = fans_tc[i];
|
||||
cout << "# usemtl " << material << endl;
|
||||
cout << "tf ";
|
||||
for ( j = 0; j < (int)vertex_index.size(); ++j ) {
|
||||
cout << vertex_index[j];
|
||||
if ( normal_index.size() ) {
|
||||
cout << "/" << normal_index[j];
|
||||
}
|
||||
cout << "/" << tex_index[j] << " ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
|
||||
#include "iochannel.hxx"
|
||||
// #include "garmin.hxx"
|
||||
// #include "nmea.hxx"
|
||||
|
||||
|
||||
// constructor
|
||||
@@ -39,7 +37,7 @@ SGIOChannel::~SGIOChannel()
|
||||
|
||||
|
||||
// dummy configure routine
|
||||
bool SGIOChannel::open( SGProtocolDir dir ) {
|
||||
bool SGIOChannel::open( const SGProtocolDir d ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -57,13 +55,13 @@ int SGIOChannel::readline( char *buf, int length ) {
|
||||
|
||||
|
||||
// dummy process routine
|
||||
int SGIOChannel::write( char *buf, int length ) {
|
||||
int SGIOChannel::write( const char *buf, const int length ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// dummy process routine
|
||||
int SGIOChannel::writestring( char *str ) {
|
||||
int SGIOChannel::writestring( const char *str ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
// iochannel.hxx -- High level IO channel class
|
||||
//
|
||||
/**
|
||||
* \file iochannel.hxx
|
||||
* High level IO channel base class.
|
||||
*/
|
||||
|
||||
// Written by Curtis Olson, started November 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
@@ -32,12 +35,16 @@
|
||||
#include STL_STRING
|
||||
#include <vector>
|
||||
|
||||
FG_USING_STD(vector);
|
||||
FG_USING_STD(string);
|
||||
SG_USING_STD(vector);
|
||||
SG_USING_STD(string);
|
||||
|
||||
|
||||
#define SG_IO_MAX_MSG_SIZE 16384
|
||||
|
||||
/**
|
||||
* Specify if this is a read (IN), write (OUT), or r/w (BI) directional
|
||||
* channel
|
||||
*/
|
||||
enum SGProtocolDir {
|
||||
SG_IO_NONE = 0,
|
||||
SG_IO_IN = 1,
|
||||
@@ -45,31 +52,113 @@ enum SGProtocolDir {
|
||||
SG_IO_BI = 3
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Specify the channel type
|
||||
*/
|
||||
enum SGChannelType {
|
||||
sgFileType = 0,
|
||||
sgSerialType = 1,
|
||||
sgSocketType = 2
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The SGIOChannel base class provides a consistent method for
|
||||
* applications to communication through various mediums. By providing
|
||||
* a base class with multiple derived classes, and application such as
|
||||
* FlightGear can implement a way to speak any protocol via any kind
|
||||
* of I/O channel.
|
||||
*
|
||||
* All of the SGIOChannel derived classes have exactly the same usage
|
||||
* interface once an instance has been created.
|
||||
*
|
||||
*/
|
||||
class SGIOChannel {
|
||||
|
||||
SGChannelType type;
|
||||
SGProtocolDir dir;
|
||||
bool valid;
|
||||
|
||||
public:
|
||||
|
||||
/** Constructor */
|
||||
SGIOChannel();
|
||||
|
||||
/** Destructor */
|
||||
virtual ~SGIOChannel();
|
||||
|
||||
virtual bool open( SGProtocolDir dir );
|
||||
/** Open a channel.
|
||||
* @param d channel communication "direction"
|
||||
* Direction can be one of:
|
||||
* - SG_IO_IN - data will be flowing into this object to the application.
|
||||
* - SG_IO_OUT - data will be flowing out of this object from the
|
||||
* application.
|
||||
* - SG_IO_BI - data will be flowing in both directions.
|
||||
* - SG_IO_NONE - data will not be flowing in either direction.
|
||||
* This is here for the sake of completeness.
|
||||
* @return result of open
|
||||
*/
|
||||
virtual bool open( const SGProtocolDir d );
|
||||
|
||||
/**
|
||||
* The read() method is modeled after the read() Unix system
|
||||
* call. You must provide a pointer to a character buffer that has
|
||||
* enough allocated space for your potential read. You can also
|
||||
* specify the maximum number of bytes allowed for this particular
|
||||
* read. The actual number of bytes read is returned. You are
|
||||
* responsible to ensure that the size of buf is large enough to
|
||||
* accomodate your input message
|
||||
* @param buf a char pointer to your input buffer
|
||||
* @param length max number of bytes to read
|
||||
* @return number of bytes read
|
||||
*/
|
||||
virtual int read( char *buf, int length );
|
||||
|
||||
/**
|
||||
* The readline() method is similar to read() except that it will
|
||||
* stop at the first end of line encountered in the input buffer.
|
||||
* @param buf a char pointer to your input buffer
|
||||
* @param length max number of bytes to read
|
||||
* @return number of bytes read
|
||||
*/
|
||||
virtual int readline( char *buf, int length );
|
||||
virtual int write( char *buf, int length );
|
||||
virtual int writestring( char *str );
|
||||
|
||||
|
||||
/**
|
||||
* The write() method is modeled after the write() Unix system
|
||||
* call and is analogous to the read() method. You provide a
|
||||
* pointer to a buffer of data, and then length of that data to be
|
||||
* written out. The number of bytes written is returned.
|
||||
* @param buf a char pointer to your output buffer
|
||||
* @param length number of bytes to write
|
||||
* @return number of bytes written
|
||||
*/
|
||||
virtual int write( const char *buf, const int length );
|
||||
|
||||
/**
|
||||
* The writestring() method is a simple wrapper that will
|
||||
* calculate the length of a null terminated character array and
|
||||
* write it to the output channel.
|
||||
* @param buf a char pointer to your output buffer
|
||||
* @return number of bytes written
|
||||
*/
|
||||
virtual int writestring( const char *str );
|
||||
|
||||
/**
|
||||
* The close() method is modeled after the close() Unix system
|
||||
* call and will close an open device. You should call this method
|
||||
* when you are done using your IO class, before it is destructed.
|
||||
* @return result of close
|
||||
*/
|
||||
virtual bool close();
|
||||
|
||||
virtual void set_type( SGChannelType t ) { type = t; }
|
||||
virtual SGChannelType get_type() const { return type; }
|
||||
inline void set_type( SGChannelType t ) { type = t; }
|
||||
inline SGChannelType get_type() const { return type; }
|
||||
|
||||
inline void set_dir( const SGProtocolDir d ) { dir = d; }
|
||||
inline SGProtocolDir get_dir() const { return dir; }
|
||||
inline bool isvalid() const { return valid; }
|
||||
inline void set_valid( const bool v ) { valid = v; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
497
simgear/io/lowlevel.cxx
Normal file
497
simgear/io/lowlevel.cxx
Normal file
@@ -0,0 +1,497 @@
|
||||
// lowlevel.cxx -- routines to handle lowlevel compressed binary IO of
|
||||
// various datatypes
|
||||
//
|
||||
// Shamelessly adapted from plib (plib.sourceforge.net) January 2001
|
||||
//
|
||||
// Original version Copyright (C) 2000 the plib team
|
||||
// Local changes Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// 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 <string.h> // for memcpy()
|
||||
|
||||
#include "lowlevel.hxx"
|
||||
|
||||
|
||||
static int read_error = false ;
|
||||
static int write_error = false ;
|
||||
|
||||
void sgClearReadError() { read_error = false; }
|
||||
void sgClearWriteError() { write_error = false; }
|
||||
int sgReadError() { return read_error ; }
|
||||
int sgWriteError() { return write_error ; }
|
||||
|
||||
|
||||
void sgReadChar ( gzFile fd, char *var )
|
||||
{
|
||||
if ( gzread ( fd, var, sizeof(char) ) != sizeof(char) ) {
|
||||
read_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgWriteChar ( gzFile fd, const char var )
|
||||
{
|
||||
if ( gzwrite ( fd, (void *)(&var), sizeof(char) ) != sizeof(char) ) {
|
||||
write_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgReadFloat ( gzFile fd, float *var )
|
||||
{
|
||||
if ( gzread ( fd, var, sizeof(float) ) != sizeof(float) ) {
|
||||
read_error = true ;
|
||||
}
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (unsigned int*)var);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgWriteFloat ( gzFile fd, const float var )
|
||||
{
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (unsigned int*)&var);
|
||||
}
|
||||
if ( gzwrite ( fd, (void *)(&var), sizeof(float) ) != sizeof(float) ) {
|
||||
write_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgReadDouble ( gzFile fd, double *var )
|
||||
{
|
||||
if ( gzread ( fd, var, sizeof(double) ) != sizeof(double) ) {
|
||||
read_error = true ;
|
||||
}
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (uint64*)var);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgWriteDouble ( gzFile fd, const double var )
|
||||
{
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (uint64*)&var);
|
||||
}
|
||||
if ( gzwrite ( fd, (void *)(&var), sizeof(double) ) != sizeof(double) ) {
|
||||
write_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgReadUInt ( gzFile fd, unsigned int *var )
|
||||
{
|
||||
if ( gzread ( fd, var, sizeof(unsigned int) ) != sizeof(unsigned int) ) {
|
||||
read_error = true ;
|
||||
}
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (unsigned int*)var);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgWriteUInt ( gzFile fd, const unsigned int var )
|
||||
{
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (unsigned int*)&var);
|
||||
}
|
||||
if ( gzwrite ( fd, (void *)(&var), sizeof(unsigned int) )
|
||||
!= sizeof(unsigned int) )
|
||||
{
|
||||
write_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgReadInt ( gzFile fd, int *var )
|
||||
{
|
||||
if ( gzread ( fd, var, sizeof(int) ) != sizeof(int) ) {
|
||||
read_error = true ;
|
||||
}
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (unsigned int*)var);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgWriteInt ( gzFile fd, const int var )
|
||||
{
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (unsigned int*)&var);
|
||||
}
|
||||
if ( gzwrite ( fd, (void *)(&var), sizeof(int) ) != sizeof(int) ) {
|
||||
write_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgReadLong ( gzFile fd, long int *var )
|
||||
{
|
||||
if ( gzread ( fd, var, sizeof(long int) ) != sizeof(long int) ) {
|
||||
read_error = true ;
|
||||
}
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (unsigned int*)var);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgWriteLong ( gzFile fd, const long int var )
|
||||
{
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (unsigned int*)&var);
|
||||
}
|
||||
if ( gzwrite ( fd, (void *)(&var), sizeof(long int) )
|
||||
!= sizeof(long int) )
|
||||
{
|
||||
write_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgReadLongLong ( gzFile fd, int64 *var )
|
||||
{
|
||||
if ( gzread ( fd, var, sizeof(int64) ) != sizeof(int64) ) {
|
||||
read_error = true ;
|
||||
}
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (uint64*)var);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgWriteLongLong ( gzFile fd, const int64 var )
|
||||
{
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (uint64*)&var);
|
||||
}
|
||||
if ( gzwrite ( fd, (void *)(&var), sizeof(int64) )
|
||||
!= sizeof(int64) )
|
||||
{
|
||||
write_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgReadUShort ( gzFile fd, unsigned short *var )
|
||||
{
|
||||
if ( gzread ( fd, var, sizeof(unsigned short) ) != sizeof(unsigned short) ){
|
||||
read_error = true ;
|
||||
}
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (unsigned short int*)var);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgWriteUShort ( gzFile fd, const unsigned short var )
|
||||
{
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (unsigned short*)&var);
|
||||
}
|
||||
if ( gzwrite ( fd, (void *)(&var), sizeof(unsigned short) )
|
||||
!= sizeof(unsigned short) )
|
||||
{
|
||||
write_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgReadShort ( gzFile fd, short *var )
|
||||
{
|
||||
if ( gzread ( fd, var, sizeof(short) ) != sizeof(short) ) {
|
||||
read_error = true ;
|
||||
}
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (unsigned short int*)var);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgWriteShort ( gzFile fd, const short var )
|
||||
{
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (unsigned short*)&var);
|
||||
}
|
||||
if ( gzwrite ( fd, (void *)(&var), sizeof(short) ) != sizeof(short) ) {
|
||||
write_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgReadFloat ( gzFile fd, const unsigned int n, float *var )
|
||||
{
|
||||
if ( gzread ( fd, var, sizeof(float) * n ) != (int)(sizeof(float) * n) ) {
|
||||
read_error = true ;
|
||||
}
|
||||
if ( sgIsBigEndian() ) {
|
||||
for ( unsigned int i = 0; i < n; ++i ) {
|
||||
sgEndianSwap( (unsigned int*)var++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgWriteFloat ( gzFile fd, const unsigned int n, const float *var )
|
||||
{
|
||||
if ( sgIsBigEndian() ) {
|
||||
float *swab = new float[n];
|
||||
float *ptr = swab;
|
||||
memcpy( swab, var, sizeof(float) * n );
|
||||
for ( unsigned int i = 0; i < n; ++i ) {
|
||||
sgEndianSwap( (unsigned int*)ptr++);
|
||||
}
|
||||
var = swab;
|
||||
}
|
||||
if ( gzwrite ( fd, (void *)var, sizeof(float) * n )
|
||||
!= (int)(sizeof(float) * n) )
|
||||
{
|
||||
write_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
void sgReadDouble ( gzFile fd, const unsigned int n, double *var )
|
||||
{
|
||||
if ( gzread ( fd, var, sizeof(double) * n ) != (int)(sizeof(double) * n) ) {
|
||||
read_error = true ;
|
||||
}
|
||||
if ( sgIsBigEndian() ) {
|
||||
for ( unsigned int i = 0; i < n; ++i ) {
|
||||
sgEndianSwap( (uint64*)var++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgWriteDouble ( gzFile fd, const unsigned int n, const double *var )
|
||||
{
|
||||
if ( sgIsBigEndian() ) {
|
||||
double *swab = new double[n];
|
||||
double *ptr = swab;
|
||||
memcpy( swab, var, sizeof(double) * n );
|
||||
for ( unsigned int i = 0; i < n; ++i ) {
|
||||
sgEndianSwap( (uint64*)ptr++);
|
||||
}
|
||||
var = swab;
|
||||
}
|
||||
if ( gzwrite ( fd, (void *)var, sizeof(double) * n )
|
||||
!= (int)(sizeof(double) * n) )
|
||||
{
|
||||
write_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
void sgReadBytes ( gzFile fd, const unsigned int n, void *var )
|
||||
{
|
||||
if ( n == 0) return;
|
||||
if ( gzread ( fd, var, n ) != (int)n ) {
|
||||
read_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
void sgWriteBytes ( gzFile fd, const unsigned int n, const void *var )
|
||||
{
|
||||
if ( n == 0) return;
|
||||
if ( gzwrite ( fd, (void *)var, n ) != (int)n ) {
|
||||
write_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgReadUShort ( gzFile fd, const unsigned int n, unsigned short *var )
|
||||
{
|
||||
if ( gzread ( fd, var, sizeof(unsigned short) * n )
|
||||
!= (int)(sizeof(unsigned short) * n) )
|
||||
{
|
||||
read_error = true ;
|
||||
}
|
||||
if ( sgIsBigEndian() ) {
|
||||
for ( unsigned int i = 0; i < n; ++i ) {
|
||||
sgEndianSwap( (unsigned short int*)var++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgWriteUShort ( gzFile fd, const unsigned int n, const unsigned short *var )
|
||||
{
|
||||
if ( sgIsBigEndian() ) {
|
||||
unsigned short *swab = new unsigned short[n];
|
||||
unsigned short *ptr = swab;
|
||||
memcpy( swab, var, sizeof(unsigned short) * n );
|
||||
for ( unsigned int i = 0; i < n; ++i ) {
|
||||
sgEndianSwap( (unsigned short*)ptr++);
|
||||
}
|
||||
var = swab;
|
||||
}
|
||||
if ( gzwrite ( fd, (void *)var, sizeof(unsigned short) * n )
|
||||
!= (int)(sizeof(unsigned short) * n) )
|
||||
{
|
||||
write_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void sgReadShort ( gzFile fd, const unsigned int n, short *var )
|
||||
{
|
||||
if ( gzread ( fd, var, sizeof(short) * n )
|
||||
!= (int)(sizeof(short) * n) )
|
||||
{
|
||||
read_error = true ;
|
||||
}
|
||||
if ( sgIsBigEndian() ) {
|
||||
for ( unsigned int i = 0; i < n; ++i ) {
|
||||
sgEndianSwap( (unsigned short int*)var++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgWriteShort ( gzFile fd, const unsigned int n, const short *var )
|
||||
{
|
||||
if ( sgIsBigEndian() ) {
|
||||
short *swab = new short[n];
|
||||
short *ptr = swab;
|
||||
memcpy( swab, var, sizeof(short) * n );
|
||||
for ( unsigned int i = 0; i < n; ++i ) {
|
||||
sgEndianSwap( (unsigned short*)ptr++);
|
||||
}
|
||||
var = swab;
|
||||
}
|
||||
if ( gzwrite ( fd, (void *)var, sizeof(short) * n )
|
||||
!= (int)(sizeof(short) * n) )
|
||||
{
|
||||
write_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgReadUInt ( gzFile fd, const unsigned int n, unsigned int *var )
|
||||
{
|
||||
if ( gzread ( fd, var, sizeof(unsigned int) * n )
|
||||
!= (int)(sizeof(unsigned int) * n) )
|
||||
{
|
||||
read_error = true ;
|
||||
}
|
||||
if ( sgIsBigEndian() ) {
|
||||
for ( unsigned int i = 0; i < n; ++i ) {
|
||||
sgEndianSwap( (unsigned int*)var++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgWriteUInt ( gzFile fd, const unsigned int n, const unsigned int *var )
|
||||
{
|
||||
if ( sgIsBigEndian() ) {
|
||||
unsigned int *swab = new unsigned int[n];
|
||||
unsigned int *ptr = swab;
|
||||
memcpy( swab, var, sizeof(unsigned int) * n );
|
||||
for ( unsigned int i = 0; i < n; ++i ) {
|
||||
sgEndianSwap( (unsigned int*)ptr++);
|
||||
}
|
||||
var = swab;
|
||||
}
|
||||
if ( gzwrite ( fd, (void *)var, sizeof(unsigned int) * n )
|
||||
!= (int)(sizeof(unsigned int) * n) )
|
||||
{
|
||||
write_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void sgReadInt ( gzFile fd, const unsigned int n, int *var )
|
||||
{
|
||||
if ( gzread ( fd, var, sizeof(int) * n )
|
||||
!= (int)(sizeof(int) * n) )
|
||||
{
|
||||
read_error = true ;
|
||||
}
|
||||
if ( sgIsBigEndian() ) {
|
||||
for ( unsigned int i = 0; i < n; ++i ) {
|
||||
sgEndianSwap( (unsigned int*)var++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgWriteInt ( gzFile fd, const unsigned int n, const int *var )
|
||||
{
|
||||
if ( sgIsBigEndian() ) {
|
||||
int *swab = new int[n];
|
||||
int *ptr = swab;
|
||||
memcpy( swab, var, sizeof(int) * n );
|
||||
for ( unsigned int i = 0; i < n; ++i ) {
|
||||
sgEndianSwap( (unsigned int*)ptr++);
|
||||
}
|
||||
var = swab;
|
||||
}
|
||||
if ( gzwrite ( fd, (void *)var, sizeof(int) * n )
|
||||
!= (int)(sizeof(int) * n) )
|
||||
{
|
||||
write_error = true ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define MAX_ENTITY_NAME_LENGTH 1024
|
||||
|
||||
void sgReadString ( gzFile fd, char **var )
|
||||
{
|
||||
int i ;
|
||||
char s [ MAX_ENTITY_NAME_LENGTH ] ;
|
||||
|
||||
for ( i = 0 ; i < MAX_ENTITY_NAME_LENGTH ; i++ ) {
|
||||
int c = gzgetc ( fd ) ;
|
||||
s [ i ] = c ;
|
||||
|
||||
if ( c == '\0' )
|
||||
break ;
|
||||
}
|
||||
|
||||
if ( i >= MAX_ENTITY_NAME_LENGTH-1 )
|
||||
s [ MAX_ENTITY_NAME_LENGTH-1 ] = '\0' ;
|
||||
|
||||
|
||||
if ( s[0] == '\0' )
|
||||
*var = NULL ;
|
||||
else {
|
||||
*var = new char [ strlen(s)+1 ] ;
|
||||
strcpy ( *var, s ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sgWriteString ( gzFile fd, const char *var )
|
||||
{
|
||||
if ( var != NULL ) {
|
||||
if ( gzwrite ( fd, (void *)var, strlen(var) + 1 ) ==
|
||||
(int)(strlen(var) + 1) )
|
||||
return ;
|
||||
} else {
|
||||
gzputc( fd, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
172
simgear/io/lowlevel.hxx
Normal file
172
simgear/io/lowlevel.hxx
Normal file
@@ -0,0 +1,172 @@
|
||||
// lowlevel.hxx -- routines to handle lowlevel compressed binary IO of
|
||||
// various datatypes
|
||||
//
|
||||
// Shamelessly adapted from plib January 2001
|
||||
//
|
||||
// Original version Copyright (C) 2000 the plib team
|
||||
// Local changes Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// 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 _SG_LOWLEVEL_HXX
|
||||
#define _SG_LOWLEVEL_HXX
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef __int64 int64;
|
||||
typedef __int64 uint64;
|
||||
#else
|
||||
typedef long long int64;
|
||||
typedef unsigned long long uint64;
|
||||
#endif
|
||||
|
||||
// Note that output is written in little endian form (and converted as
|
||||
// necessary for big endian machines)
|
||||
|
||||
void sgReadChar ( gzFile fd, char *var ) ;
|
||||
void sgWriteChar ( gzFile fd, const char var ) ;
|
||||
void sgReadFloat ( gzFile fd, float *var ) ;
|
||||
void sgWriteFloat ( gzFile fd, const float var ) ;
|
||||
void sgReadDouble ( gzFile fd, double *var ) ;
|
||||
void sgWriteDouble ( gzFile fd, const double var ) ;
|
||||
void sgReadUInt ( gzFile fd, unsigned int *var ) ;
|
||||
void sgWriteUInt ( gzFile fd, const unsigned int var ) ;
|
||||
void sgReadInt ( gzFile fd, int *var ) ;
|
||||
void sgWriteInt ( gzFile fd, const int var ) ;
|
||||
void sgReadLong ( gzFile fd, long int *var ) ;
|
||||
void sgWriteLong ( gzFile fd, const long int var ) ;
|
||||
void sgReadLongLong ( gzFile fd, int64 *var ) ;
|
||||
void sgWriteLongLong ( gzFile fd, const int64 var ) ;
|
||||
void sgReadUShort ( gzFile fd, unsigned short *var ) ;
|
||||
void sgWriteUShort ( gzFile fd, const unsigned short var ) ;
|
||||
void sgReadShort ( gzFile fd, short *var ) ;
|
||||
void sgWriteShort ( gzFile fd, const short var ) ;
|
||||
|
||||
void sgReadFloat ( gzFile fd, const unsigned int n, float *var ) ;
|
||||
void sgWriteFloat ( gzFile fd, const unsigned int n, const float *var ) ;
|
||||
void sgReadDouble ( gzFile fd, const unsigned int n, double *var ) ;
|
||||
void sgWriteDouble ( gzFile fd, const unsigned int n, const double *var ) ;
|
||||
void sgReadUInt ( gzFile fd, const unsigned int n, unsigned int *var ) ;
|
||||
void sgWriteUInt ( gzFile fd, const unsigned int n, const unsigned int *var ) ;
|
||||
void sgReadInt ( gzFile fd, const unsigned int n, int *var ) ;
|
||||
void sgWriteInt ( gzFile fd, const unsigned int n, const int *var ) ;
|
||||
void sgReadUShort ( gzFile fd, const unsigned int n, unsigned short *var ) ;
|
||||
void sgWriteUShort ( gzFile fd, const unsigned int n, const unsigned short *var ) ;
|
||||
void sgReadShort ( gzFile fd, const unsigned int n, short *var ) ;
|
||||
void sgWriteShort ( gzFile fd, const unsigned int n, const short *var ) ;
|
||||
void sgReadBytes ( gzFile fd, const unsigned int n, void *var ) ;
|
||||
void sgWriteBytes ( gzFile fd, const unsigned int n, const void *var ) ;
|
||||
|
||||
void sgReadString ( gzFile fd, char **var ) ;
|
||||
void sgWriteString ( gzFile fd, const char *var ) ;
|
||||
|
||||
inline void sgReadVec2 ( gzFile fd, sgVec2 var ) {
|
||||
sgReadFloat ( fd, 2, var ) ;
|
||||
}
|
||||
inline void sgWriteVec2 ( gzFile fd, const sgVec2 var ) {
|
||||
sgWriteFloat ( fd, 2, var ) ;
|
||||
}
|
||||
|
||||
inline void sgReadVec3 ( gzFile fd, sgVec3 var ) {
|
||||
sgReadFloat ( fd, 3, var ) ;
|
||||
}
|
||||
inline void sgWriteVec3 ( gzFile fd, const sgVec3 var ) {
|
||||
sgWriteFloat ( fd, 3, var ) ;
|
||||
}
|
||||
|
||||
inline void sgReaddVec3 ( gzFile fd, sgdVec3 var ) {
|
||||
sgReadDouble ( fd, 3, var ) ;
|
||||
}
|
||||
inline void sgWritedVec3 ( gzFile fd, const sgdVec3 var ) {
|
||||
sgWriteDouble ( fd, 3, var ) ;
|
||||
}
|
||||
|
||||
inline void sgReadVec4 ( gzFile fd, sgVec4 var ) {
|
||||
sgReadFloat ( fd, 4, var ) ;
|
||||
}
|
||||
inline void sgWriteVec4 ( gzFile fd, const sgVec4 var ) {
|
||||
sgWriteFloat ( fd, 4, var ) ;
|
||||
}
|
||||
|
||||
inline void sgReadMat4 ( gzFile fd, sgMat4 var ) {
|
||||
sgReadFloat ( fd, 16, (float *)var ) ;
|
||||
}
|
||||
inline void sgWriteMat4 ( gzFile fd, const sgMat4 var ) {
|
||||
sgWriteFloat ( fd, 16, (float *)var ) ;
|
||||
}
|
||||
|
||||
void sgClearReadError();
|
||||
void sgClearWriteError();
|
||||
int sgReadError();
|
||||
int sgWriteError();
|
||||
|
||||
inline bool sgIsLittleEndian() {
|
||||
static const int sgEndianTest = 1;
|
||||
return (*((char *) &sgEndianTest ) != 0);
|
||||
}
|
||||
|
||||
inline bool sgIsBigEndian() {
|
||||
static const int sgEndianTest = 1;
|
||||
return (*((char *) &sgEndianTest ) == 0);
|
||||
}
|
||||
|
||||
inline void sgEndianSwap(unsigned short *x) {
|
||||
*x =
|
||||
(( *x >> 8 ) & 0x00FF ) |
|
||||
(( *x << 8 ) & 0xFF00 ) ;
|
||||
}
|
||||
|
||||
inline void sgEndianSwap(unsigned int *x) {
|
||||
*x =
|
||||
(( *x >> 24 ) & 0x000000FF ) |
|
||||
(( *x >> 8 ) & 0x0000FF00 ) |
|
||||
(( *x << 8 ) & 0x00FF0000 ) |
|
||||
(( *x << 24 ) & 0xFF000000 ) ;
|
||||
}
|
||||
|
||||
inline void sgEndianSwap(uint64 *x) {
|
||||
#ifndef _MSC_VER
|
||||
*x =
|
||||
(( *x >> 56 ) & 0x00000000000000FFULL ) |
|
||||
(( *x >> 40 ) & 0x000000000000FF00ULL ) |
|
||||
(( *x >> 24 ) & 0x0000000000FF0000ULL ) |
|
||||
(( *x >> 8 ) & 0x00000000FF000000ULL ) |
|
||||
(( *x << 8 ) & 0x000000FF00000000ULL ) |
|
||||
(( *x << 24 ) & 0x0000FF0000000000ULL ) |
|
||||
(( *x << 40 ) & 0x00FF000000000000ULL ) |
|
||||
(( *x << 56 ) & 0xFF00000000000000ULL ) ;
|
||||
#else
|
||||
*x =
|
||||
(( *x >> 56 ) & 0x00000000000000FF ) |
|
||||
(( *x >> 40 ) & 0x000000000000FF00 ) |
|
||||
(( *x >> 24 ) & 0x0000000000FF0000 ) |
|
||||
(( *x >> 8 ) & 0x00000000FF000000 ) |
|
||||
(( *x << 8 ) & 0x000000FF00000000 ) |
|
||||
(( *x << 24 ) & 0x0000FF0000000000 ) |
|
||||
(( *x << 40 ) & 0x00FF000000000000 ) |
|
||||
(( *x << 56 ) & 0xFF00000000000000 ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // _SG_LOWLEVEL_HXX
|
||||
48
simgear/io/lowtest.cxx
Normal file
48
simgear/io/lowtest.cxx
Normal file
@@ -0,0 +1,48 @@
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include STL_IOSTREAM
|
||||
#include "lowlevel.hxx"
|
||||
|
||||
#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
|
||||
SG_USING_STD(cout);
|
||||
SG_USING_STD(endl);
|
||||
#endif
|
||||
|
||||
|
||||
static const int sgEndianTest = 1;
|
||||
#define sgIsLittleEndian (*((char *) &sgEndianTest ) != 0)
|
||||
#define sgIsBigEndian (*((char *) &sgEndianTest ) == 0)
|
||||
|
||||
|
||||
int main() {
|
||||
cout << "This machine is ";
|
||||
if ( sgIsLittleEndian ) {
|
||||
cout << "little ";
|
||||
} else {
|
||||
cout << "big ";
|
||||
}
|
||||
cout << "endian" << endl;
|
||||
|
||||
cout << "sizeof(short) = " << sizeof(short) << endl;
|
||||
|
||||
short s = 1111;
|
||||
cout << "short s = " << s << endl;
|
||||
sgEndianSwap((unsigned short *)&s);
|
||||
cout << "short s = " << s << endl;
|
||||
sgEndianSwap((unsigned short *)&s);
|
||||
cout << "short s = " << s << endl;
|
||||
|
||||
int i = 1111111;
|
||||
cout << "int i = " << i << endl;
|
||||
sgEndianSwap((unsigned int *)&i);
|
||||
cout << "int i = " << i << endl;
|
||||
sgEndianSwap((unsigned int *)&i);
|
||||
cout << "int i = " << i << endl;
|
||||
|
||||
double x = 1111111111;
|
||||
cout << "double x = " << x << endl;
|
||||
sgEndianSwap((unsigned long long *)&x);
|
||||
cout << "double x = " << x << endl;
|
||||
sgEndianSwap((unsigned long long *)&x);
|
||||
cout << "double x = " << x << endl;
|
||||
}
|
||||
1231
simgear/io/sg_binobj.cxx
Normal file
1231
simgear/io/sg_binobj.cxx
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