Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ScriptTypes.h
Go to the documentation of this file.
1 /* Copyright (C) 2012 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_SCRIPTTYPES
19 #define INCLUDED_SCRIPTTYPES
20 
21 #ifdef _WIN32
22 # define XP_WIN
23 # ifndef WIN32
24 # define WIN32 // SpiderMonkey expects this
25 # endif
26 
27 // The jsval struct type causes crashes due to weird miscompilation
28 // issues in (at least) VC2008, so force it to be the less-type-safe
29 // non-struct type instead
30 # define JS_NO_JSVAL_JSID_STRUCT_TYPES
31 
32 // Make JS think the int8_t etc types are defined, since wposix_types.h emulates
33 // the ones that are needed and this avoids conflicting definitions
34 # define JS_SYS_TYPES_H_DEFINES_EXACT_SIZE_TYPES
35 
36 #else // If not Windows, then Unix:
37 
38 # define XP_UNIX
39 
40 // In DEBUG mode, jsval defaults to struct types. Normally we build separate
41 // debug/release mode versions of the library, but when using --with-system-mozjs185
42 // it's always a release mode library, so we have to disable struct types for
43 // ABI compatibility
44 # if defined(DEBUG) && defined(WITH_SYSTEM_MOZJS185)
45 # define JS_NO_JSVAL_JSID_STRUCT_TYPES
46 # endif
47 
48 #endif
49 // (we don't support XP_OS2 or XP_BEOS)
50 
51 
52 // Guess whether the library was compiled with the release-mode or debug-mode ABI
53 // (for JS_DumpHeap etc)
54 #if defined(DEBUG) && !defined(WITH_SYSTEM_MOZJS185)
55 # define MOZJS_DEBUG_ABI 1
56 #else
57 # define MOZJS_DEBUG_ABI 0
58 #endif
59 
60 
61 #include <cstring> // required by jsutil.h
62 
63 // SpiderMonkey wants the DEBUG flag
64 #ifndef NDEBUG
65 # ifndef DEBUG
66 # define DEBUG
67 # endif
68 #endif
69 
70 // Ignore some harmless warnings triggered by jsapi.h
71 #if GCC_VERSION >= 402 // (older GCCs don't support this pragma)
72 # pragma GCC diagnostic ignored "-Wunused-parameter"
73 # pragma GCC diagnostic ignored "-Wredundant-decls"
74 #endif
75 #if MSC_VERSION
76 # pragma warning(push)
77 # pragma warning(disable:4480) // "nonstandard extension used: specifying underlying type for enum"
78 # pragma warning(disable:4100) // "unreferenced formal parameter"
79 #endif
80 
81 #include "js/jsapi.h"
82 
83 #if MSC_VERSION
84 # pragma warning(pop)
85 #endif
86 #if GCC_VERSION >= 402
87 # pragma GCC diagnostic warning "-Wunused-parameter"
88 # pragma GCC diagnostic warning "-Wredundant-decls"
89 #endif
90 
91 #if JS_VERSION != 185
92 #error Your compiler is trying to use an incorrect version of the SpiderMonkey library.
93 #error The only version that works is the one in the libraries/spidermonkey/ directory,
94 #error and it will not work with a typical system-installed version.
95 #error Make sure you have got all the right files and include paths.
96 #endif
97 
98 class ScriptInterface;
99 class CScriptVal;
100 class CScriptValRooted;
101 
102 #endif // INCLUDED_SCRIPTTYPES
A trivial wrapper around a jsval.
Definition: ScriptVal.h:29
Abstraction around a SpiderMonkey JSContext.