Oolite 1.91.0.7646-241128-10e222e
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 175 of file OOJSEquipmentInfo.m.

176{
178
180}
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.

+ Here is the call graph for this function:

◆ JSValueToEquipmentKey()

NSString * JSValueToEquipmentKey ( JSContext * context,
jsval value )

Definition at line 204 of file OOJSEquipmentInfo.m.

205{
206 return [JSValueToEquipmentType(context, value) identifier];
207}
OOEquipmentType * JSValueToEquipmentType(JSContext *context, jsval value)

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

+ Here is the caller graph for this function:

◆ JSValueToEquipmentKeyRelaxed()

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

Definition at line 210 of file OOJSEquipmentInfo.m.

211{
213
214 NSString *result = nil;
215 BOOL exists = NO;
216 id objValue = OOJSNativeObjectFromJSValue(context, value);
217
218 if ([objValue isKindOfClass:[OOEquipmentType class]])
219 {
220 result = [objValue identifier];
221 exists = YES;
222 }
223 else if ([objValue isKindOfClass:[NSString class]])
224 {
225 /* To enforce deliberate backwards incompatibility, reject strings
226 ending with _DAMAGED unless someone actually named an equip that
227 way.
228 */
229 exists = [OOEquipmentType equipmentTypeWithIdentifier:objValue] != nil;
230 if (exists || ![objValue hasSuffix:@"_DAMAGED"])
231 {
232 result = objValue;
233 }
234 }
235
236 if (outExists != NULL) *outExists = exists;
237 return result;
238
240}
#define OOJS_PROFILE_EXIT
#define OOJS_PROFILE_ENTER
id OOJSNativeObjectFromJSValue(JSContext *context, jsval value)
return nil

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

184{
186
187 if (JSVAL_IS_OBJECT(value))
188 {
189 JSObject *object = JSVAL_TO_OBJECT(value);
190 if (JS_InstanceOf(context, JSVAL_TO_OBJECT(value), &sEquipmentInfoClass, NULL))
191 {
192 return (OOEquipmentType *)JS_GetPrivate(context, object);
193 }
194 }
195
196 NSString *string = OOStringFromJSValue(context, value);
197 if (string != nil) return [OOEquipmentType equipmentTypeWithIdentifier:string];
198 return nil;
199
201}
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: