Oolite
Loading...
Searching...
No Matches
OOJSEquipmentInfo.h File Reference
import "OOEquipmentType.h"
import "OOFoundation.h"
#include <jsapi.h>
Include dependency graph for OOJSEquipmentInfo.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void InitOOJSEquipmentInfo (JSContext *context, JSObject *global)
OOEquipmentType * JSValueToEquipmentType (JSContext *context, jsval value)
NSString * JSValueToEquipmentKey (JSContext *context, jsval value)
NSString * JSValueToEquipmentKeyRelaxed (JSContext *context, jsval value, BOOL *outExists)

Function Documentation

◆ InitOOJSEquipmentInfo()

void InitOOJSEquipmentInfo ( JSContext * context,
JSObject * global )

Definition at line 162 of file OOJSEquipmentInfo.m.

163{
165
167}
static JSObject * sEquipmentInfoPrototype
static JSClass sEquipmentInfoClass
static JSFunctionSpec sEquipmentInfoMethods[]
static JSFunctionSpec sEquipmentInfoStaticMethods[]
static JSPropertySpec sEquipmentInfoProperties[]
static JSPropertySpec sEquipmentInfoStaticProperties[]
void OOJSRegisterObjectConverter(JSClass *theClass, OOJSClassConverterCallback converter)
JSBool OOJSUnconstructableConstruct(JSContext *context, uintN argc, jsval *vp)
id OOJSBasicPrivateObjectConverter(JSContext *context, JSObject *object)

References OOJSBasicPrivateObjectConverter(), OOJSRegisterObjectConverter(), OOJSUnconstructableConstruct(), sEquipmentInfoClass, sEquipmentInfoMethods, sEquipmentInfoProperties, sEquipmentInfoPrototype, sEquipmentInfoStaticMethods, and sEquipmentInfoStaticProperties.

Referenced by OOJavaScriptEngine(Private)::createMainThreadContext, and InitOOJSEquipmentInfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ JSValueToEquipmentKey()

NSString * JSValueToEquipmentKey ( JSContext * context,
jsval value )

Definition at line 188 of file OOJSEquipmentInfo.m.

189{
190 return [JSValueToEquipmentType(context, value) identifier];
191}
OOEquipmentType * JSValueToEquipmentType(JSContext *context, jsval value)

References OOEquipmentType::identifier.

Referenced by PlayerShipAwardEquipmentToCurrentPylon(), PlayerShipAwardEquipmentToCurrentPylon(), ShipEquipmentStatus(), ShipEquipmentStatus(), ShipRemoveEquipment(), and ShipRemoveEquipment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ JSValueToEquipmentKeyRelaxed()

NSString * JSValueToEquipmentKeyRelaxed ( JSContext * context,
jsval value,
BOOL * outExists )

Definition at line 193 of file OOJSEquipmentInfo.m.

194{
196
197 NSString* result = nil;
198 BOOL exists = NO;
199 id objValue = OOJSNativeObjectFromJSValue(context, value);
200
201 if ([objValue isKindOfClass:[OOEquipmentType class]]) {
202 result = [objValue identifier];
203 exists = YES;
204 } else if ([objValue isKindOfClass:[NSString class]]) {
205 /* To enforce deliberate backwards incompatibility, reject strings
206 ending with _DAMAGED unless someone actually named an equip that
207 way.
208 */
209 exists = [OOEquipmentType equipmentTypeWithIdentifier:objValue] != nil;
210 if (exists || ![objValue hasSuffix:@"_DAMAGED"]) {
211 result = objValue;
212 }
213 }
214
215 if (outExists != NULL)
216 *outExists = exists;
217 return result;
218
220}
#define OOJS_PROFILE_EXIT
#define OOJS_PROFILE_ENTER
id OOJSNativeObjectFromJSValue(JSContext *context, jsval value)
return nil

References OOEquipmentType::equipmentTypeWithIdentifier:, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJSNativeObjectFromJSValue().

Referenced by PlayerShipSetProperty(), PlayerShipSetProperty(), ShipCanAwardEquipment(), ShipCanAwardEquipment(), ShipSetProperty(), and ShipSetProperty().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ JSValueToEquipmentType()

OOEquipmentType * JSValueToEquipmentType ( JSContext * context,
jsval value )

Definition at line 169 of file OOJSEquipmentInfo.m.

170{
172
173 if (JSVAL_IS_OBJECT(value)) {
174 JSObject* object = JSVAL_TO_OBJECT(value);
175 if (JS_InstanceOf(context, JSVAL_TO_OBJECT(value), &sEquipmentInfoClass, NULL)) {
176 return (OOEquipmentType*)JS_GetPrivate(context, object);
177 }
178 }
179
180 NSString* string = OOStringFromJSValue(context, value);
181 if (string != nil)
182 return [OOEquipmentType equipmentTypeWithIdentifier:string];
183 return nil;
184
186}
NSString * OOStringFromJSValue(JSContext *context, jsval value)

References OOEquipmentType::equipmentTypeWithIdentifier:, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOStringFromJSValue(), and sEquipmentInfoClass.

Referenced by ShipAwardEquipment(), ShipAwardEquipment(), ShipSetEquipmentStatus(), and ShipSetEquipmentStatus().

Here is the call graph for this function:
Here is the caller graph for this function: