Oolite 1.91.0.7708-250910-30bbc4c
Loading...
Searching...
No Matches
OOJSEquipmentInfo.h File Reference
#include <jsapi.h>
import "OOCocoa.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)
OOEquipmentTypeJSValueToEquipmentType (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 179 of file OOJSEquipmentInfo.m.

180{
182
184}
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.

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 208 of file OOJSEquipmentInfo.m.

209{
210 return [JSValueToEquipmentType(context, value) identifier];
211}
OOEquipmentType * JSValueToEquipmentType(JSContext *context, jsval value)

References OOEquipmentType::identifier.

Referenced by PlayerShipAwardEquipmentToCurrentPylon(), ShipEquipmentStatus(), 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 214 of file OOJSEquipmentInfo.m.

215{
217
218 NSString *result = nil;
219 BOOL exists = NO;
220 id objValue = OOJSNativeObjectFromJSValue(context, value);
221
222 if ([objValue isKindOfClass:[OOEquipmentType class]])
223 {
224 result = [objValue identifier];
225 exists = YES;
226 }
227 else if ([objValue isKindOfClass:[NSString class]])
228 {
229 /* To enforce deliberate backwards incompatibility, reject strings
230 ending with _DAMAGED unless someone actually named an equip that
231 way.
232 */
233 exists = [OOEquipmentType equipmentTypeWithIdentifier:objValue] != nil;
234 if (exists || ![objValue hasSuffix:@"_DAMAGED"])
235 {
236 result = objValue;
237 }
238 }
239
240 if (outExists != NULL) *outExists = exists;
241 return result;
242
244}
#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(), ShipCanAwardEquipment(), 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 187 of file OOJSEquipmentInfo.m.

188{
190
191 if (JSVAL_IS_OBJECT(value))
192 {
193 JSObject *object = JSVAL_TO_OBJECT(value);
194 if (JS_InstanceOf(context, JSVAL_TO_OBJECT(value), &sEquipmentInfoClass, NULL))
195 {
196 return (OOEquipmentType *)JS_GetPrivate(context, object);
197 }
198 }
199
200 NSString *string = OOStringFromJSValue(context, value);
201 if (string != nil) return [OOEquipmentType equipmentTypeWithIdentifier:string];
202 return nil;
203
205}
NSString * OOStringFromJSValue(JSContext *context, jsval value)

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

Referenced by ShipAwardEquipment(), and ShipSetEquipmentStatus().

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