Oolite
Loading...
Searching...
No Matches
OOConstToJSString.h
Go to the documentation of this file.
1/*
2
3OOConstToJSString.h
4
5Convert various sets of integer constants to JavaScript strings and back again.
6See also: OOConstToString.h.
7
8
9Oolite
10Copyright (C) 2004-2013 Giles C Williams and contributors
11
12This program is free software; you can redistribute it and/or
13modify it under the terms of the GNU General Public License
14as published by the Free Software Foundation; either version 2
15of the License, or (at your option) any later version.
16
17This program is distributed in the hope that it will be useful,
18but WITHOUT ANY WARRANTY; without even the implied warranty of
19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License
23along with this program; if not, write to the Free Software
24Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25MA 02110-1301, USA.
26
27*/
28
30
31void OOConstToJSStringInit(JSContext* context);
33
34struct ConstTable;
35
36/* QuickJS has no JSString type, so the SpiderMonkey OOJSStringFromFoo() and
37 OOFooFromJSString() variants are gone; OOJSValueFromFoo() returns an owned
38 string value and OOFooFromJSValue() accepts any value (non-strings give
39 the default).
40*/
41
42// Private functions, don't use directly.
43JSValue OOJSValueFromConstantPRIVATE(JSContext* context, NSInteger value, struct ConstTable* table);
44NSUInteger OOConstantFromJSValuePRIVATE(JSContext* context, JSValueConst value, struct ConstTable* table, NSInteger defaultValue);
45
46/* JSValue OOJSValueFromEntityStatus(JSContext *, OOEntityStatus)
47 OOEntityStatus OOEntityStatusFromJSValue(JSContext *, JSValueConst)
48
49 Convert between JavaScript strings and OOEntityStatus.
50*/
51OOINLINE JSValue OOJSValueFromEntityStatus(JSContext* context, OOEntityStatus value)
52{
55}
56
62
63/* JSValue OOJSValueFromScanClass(JSContext *, OOScanClass)
64 OOScanClass OOScanClassFromJSValue(JSContext *, JSValueConst)
65
66 Convert between JavaScript strings and OOScanClass.
67*/
68OOINLINE JSValue OOJSValueFromScanClass(JSContext* context, OOScanClass value)
69{
72}
73
74OOINLINE OOScanClass OOScanClassFromJSValue(JSContext* context, JSValueConst value)
75{
78}
79
80/* JSValue OOJSValueFromCompassMode(JSContext *, OOCompassMode)
81 OOCompassMode OOCompassModeFromJSValue(JSContext *, JSValueConst)
82
83 Convert between JavaScript strings and OOCompassMode.
84*/
85OOINLINE JSValue OOJSValueFromCompassMode(JSContext* context, OOCompassMode value)
86{
89}
90
96
97/* JSValue OOJSValueFromGUIScreenID(JSContext *, OOGUIScreenID)
98 OOGUIScreenID OOGUIScreenIDFromJSValue(JSContext *, JSValueConst)
99
100 Convert between JavaScript strings and OOGUIScreenID.
101*/
102OOINLINE JSValue OOJSValueFromGUIScreenID(JSContext* context, OOGUIScreenID value)
103{
106}
107
113
114/* JSValue OOJSValueFromGalacticHyperspaceBehaviour(JSContext *, OOGalacticHyperspaceBehaviour)
115 OOGalacticHyperspaceBehaviour OOGalacticHyperspaceBehaviourFromJSValue(JSContext *, JSValueConst)
116
117 Convert between JavaScript strings and OOGalacticHyperspaceBehaviour.
118*/
124
130
131/* JSValue OOJSValueFromViewID(JSContext *, OOViewID)
132 OOViewID OOViewIDFromJSValue(JSContext *, JSValueConst)
133
134 Convert between JavaScript strings and OOViewID.
135*/
136OOINLINE JSValue OOJSValueFromViewID(JSContext* context, OOViewID value)
137{
138 extern struct ConstTable gOOViewIDConstTable;
139 return OOJSValueFromConstantPRIVATE(context, value, &gOOViewIDConstTable);
140}
141
142OOINLINE OOViewID OOViewIDFromJSValue(JSContext* context, JSValueConst value)
143{
144 extern struct ConstTable gOOViewIDConstTable;
146}
147
148/* JSValue OOJSValueFromShipDamageType(JSContext *, OOShipDamageType)
149
150 Convert OOShipDamageType to JavaScript strings.
151*/
152OOINLINE JSValue OOJSValueFromShipDamageType(JSContext* context, OOShipDamageType value)
153{
156}
157
158/* JSValue OOJSValueFromLegalStatusReason(JSContext *, OOLegalStatusReason)
159
160 Convert OOLegalStatusReason to JavaScript strings.
161*/
@ kOOScanClassDefault
Definition Entity.h:327
@ kOOEntityStatusDefault
Definition Entity.h:326
OOEntityStatus
Definition Entity.h:60
OOScanClass
Definition Entity.h:69
OOINLINE jsval OOJSValueFromGalacticHyperspaceBehaviour(JSContext *context, OOGalacticHyperspaceBehaviour value)
OOINLINE OOViewID OOViewIDFromJSValue(JSContext *context, jsval value)
void OOConstToJSStringDestroy(void)
OOINLINE jsval OOJSValueFromViewID(JSContext *context, OOViewID value)
OOINLINE jsval OOJSValueFromScanClass(JSContext *context, OOScanClass value)
OOINLINE OOGUIScreenID OOGUIScreenIDFromJSValue(JSContext *context, jsval value)
OOINLINE OOGalacticHyperspaceBehaviour OOGalacticHyperspaceBehaviourFromJSValue(JSContext *context, jsval value)
void OOConstToJSStringInit(JSContext *context)
OOINLINE jsval OOJSValueFromEntityStatus(JSContext *context, OOEntityStatus value)
OOINLINE OOCompassMode OOCompassModeFromJSValue(JSContext *context, jsval value)
OOINLINE jsval OOJSValueFromLegalStatusReason(JSContext *context, OOLegalStatusReason value)
OOINLINE OOScanClass OOScanClassFromJSValue(JSContext *context, jsval value)
OOINLINE OOEntityStatus OOEntityStatusFromJSValue(JSContext *context, jsval value)
OOINLINE jsval OOJSValueFromShipDamageType(JSContext *context, OOShipDamageType value)
OOINLINE jsval OOJSValueFromCompassMode(JSContext *context, OOCompassMode value)
OOINLINE jsval OOJSValueFromGUIScreenID(JSContext *context, OOGUIScreenID value)
NSUInteger OOConstantFromJSValuePRIVATE(JSContext *context, jsval value, struct ConstTable *table, NSInteger defaultValue)
ConstTable gOOViewIDConstTable
ConstTable gOOEntityStatusConstTable
ConstTable gOOCompassModeConstTable
ConstTable gOOLegalStatusReasonConstTable
ConstTable gOOShipDamageTypeConstTable
ConstTable gOOScanClassConstTable
ConstTable gOOGUIScreenIDConstTable
ConstTable gOOGalacticHyperspaceBehaviourConstTable
#define OOINLINE
OOLegalStatusReason
Definition OOTypes.h:139
OOViewID
Definition OOTypes.h:39
@ kOOViewIDDefault
Definition OOTypes.h:42
OOCompassMode
Definition OOTypes.h:129
@ kOOCompassModeDefault
Definition OOTypes.h:134
OOGalacticHyperspaceBehaviour
@ kOOGUIScreenIDDefault
@ kOOGalacticHyperspaceBehaviourDefault
OOGUIScreenID
JSValue OOJSValueFromConstantPRIVATE(JSContext *context, NSInteger value, struct ConstTable *table)
OOShipDamageType
Definition ShipEntity.h:175