Oolite
Loading...
Searching...
No Matches
OOJSEquipmentInfo.m File Reference
Include dependency graph for OOJSEquipmentInfo.m:

Go to the source code of this file.

Enumerations

enum  {
  kEquipmentInfo_calculatedPrice , kEquipmentInfo_canBeDamaged , kEquipmentInfo_canCarryMultiple , kEquipmentInfo_damageProbability ,
  kEquipmentInfo_description , kEquipmentInfo_displayColor , kEquipmentInfo_effectiveTechLevel , kEquipmentInfo_equipmentKey ,
  kEquipmentInfo_fastAffinityDefensive , kEquipmentInfo_fastAffinityOffensive , kEquipmentInfo_defaultActivateKey , kEquipmentInfo_defaultModeKey ,
  kEquipmentInfo_incompatibleEquipment , kEquipmentInfo_installationTime , kEquipmentInfo_isAvailableToAll , kEquipmentInfo_isAvailableToNPCs ,
  kEquipmentInfo_isAvailableToPlayer , kEquipmentInfo_isExternalStore , kEquipmentInfo_isPortableBetweenShips , kEquipmentInfo_isVisible ,
  kEquipmentInfo_name , kEquipmentInfo_price , kEquipmentInfo_provides , kEquipmentInfo_repairTime ,
  kEquipmentInfo_requiredCargoSpace , kEquipmentInfo_requiresAnyEquipment , kEquipmentInfo_requiresCleanLegalRecord , kEquipmentInfo_requiresEmptyPylon ,
  kEquipmentInfo_requiresEquipment , kEquipmentInfo_requiresFreePassengerBerth , kEquipmentInfo_requiresFullFuel , kEquipmentInfo_requiresMountedPylon ,
  kEquipmentInfo_requiresNonCleanLegalRecord , kEquipmentInfo_requiresNonFullFuel , kEquipmentInfo_scriptInfo , kEquipmentInfo_scriptName ,
  kEquipmentInfo_techLevel , kEquipmentInfo_weaponInfo
}

Functions

static JSBool EquipmentInfoGetProperty (JSContext *context, JSObject *this, jsid propID, jsval *value)
static JSBool EquipmentInfoSetProperty (JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
static JSBool EquipmentInfoGetAllEqipment (JSContext *context, JSObject *this, jsid propID, jsval *value)
static JSBool EquipmentInfoStaticInfoForKey (JSContext *context, uintN argc, jsval *vp)
 DEFINE_JS_OBJECT_GETTER (JSEquipmentInfoGetEquipmentType, &sEquipmentInfoClass, sEquipmentInfoPrototype, OOEquipmentType)
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)

Variables

static JSObject * sEquipmentInfoPrototype
static JSPropertySpec sEquipmentInfoProperties []
static JSPropertySpec sEquipmentInfoStaticProperties []
static JSFunctionSpec sEquipmentInfoMethods []
static JSFunctionSpec sEquipmentInfoStaticMethods []
static JSClass sEquipmentInfoClass

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
kEquipmentInfo_calculatedPrice 
kEquipmentInfo_canBeDamaged 
kEquipmentInfo_canCarryMultiple 
kEquipmentInfo_damageProbability 
kEquipmentInfo_description 
kEquipmentInfo_displayColor 
kEquipmentInfo_effectiveTechLevel 
kEquipmentInfo_equipmentKey 
kEquipmentInfo_fastAffinityDefensive 
kEquipmentInfo_fastAffinityOffensive 
kEquipmentInfo_defaultActivateKey 
kEquipmentInfo_defaultModeKey 
kEquipmentInfo_incompatibleEquipment 
kEquipmentInfo_installationTime 
kEquipmentInfo_isAvailableToAll 
kEquipmentInfo_isAvailableToNPCs 
kEquipmentInfo_isAvailableToPlayer 
kEquipmentInfo_isExternalStore 
kEquipmentInfo_isPortableBetweenShips 
kEquipmentInfo_isVisible 
kEquipmentInfo_name 
kEquipmentInfo_price 
kEquipmentInfo_provides 
kEquipmentInfo_repairTime 
kEquipmentInfo_requiredCargoSpace 
kEquipmentInfo_requiresAnyEquipment 
kEquipmentInfo_requiresCleanLegalRecord 
kEquipmentInfo_requiresEmptyPylon 
kEquipmentInfo_requiresEquipment 
kEquipmentInfo_requiresFreePassengerBerth 
kEquipmentInfo_requiresFullFuel 
kEquipmentInfo_requiresMountedPylon 
kEquipmentInfo_requiresNonCleanLegalRecord 
kEquipmentInfo_requiresNonFullFuel 
kEquipmentInfo_scriptInfo 
kEquipmentInfo_scriptName 
kEquipmentInfo_techLevel 
kEquipmentInfo_weaponInfo 

Definition at line 41 of file OOJSEquipmentInfo.m.

41 {
42 // Property IDs
60 kEquipmentInfo_isExternalStore, // is missile or mine
77 kEquipmentInfo_scriptInfo, // arbitrary data for scripts, dictionary, read-only
81};
@ kEquipmentInfo_defaultActivateKey
@ kEquipmentInfo_installationTime
@ kEquipmentInfo_requiresAnyEquipment
@ kEquipmentInfo_canCarryMultiple
@ kEquipmentInfo_calculatedPrice
@ kEquipmentInfo_weaponInfo
@ kEquipmentInfo_effectiveTechLevel
@ kEquipmentInfo_requiresEquipment
@ kEquipmentInfo_equipmentKey
@ kEquipmentInfo_displayColor
@ kEquipmentInfo_isAvailableToAll
@ kEquipmentInfo_requiresFreePassengerBerth
@ kEquipmentInfo_damageProbability
@ kEquipmentInfo_requiresCleanLegalRecord
@ kEquipmentInfo_isVisible
@ kEquipmentInfo_isPortableBetweenShips
@ kEquipmentInfo_defaultModeKey
@ kEquipmentInfo_name
@ kEquipmentInfo_price
@ kEquipmentInfo_fastAffinityDefensive
@ kEquipmentInfo_isExternalStore
@ kEquipmentInfo_isAvailableToPlayer
@ kEquipmentInfo_canBeDamaged
@ kEquipmentInfo_description
@ kEquipmentInfo_techLevel
@ kEquipmentInfo_scriptName
@ kEquipmentInfo_scriptInfo
@ kEquipmentInfo_repairTime
@ kEquipmentInfo_provides
@ kEquipmentInfo_requiresFullFuel
@ kEquipmentInfo_requiresNonFullFuel
@ kEquipmentInfo_requiredCargoSpace
@ kEquipmentInfo_isAvailableToNPCs
@ kEquipmentInfo_incompatibleEquipment
@ kEquipmentInfo_requiresNonCleanLegalRecord
@ kEquipmentInfo_requiresMountedPylon
@ kEquipmentInfo_requiresEmptyPylon
@ kEquipmentInfo_fastAffinityOffensive

Function Documentation

◆ DEFINE_JS_OBJECT_GETTER()

DEFINE_JS_OBJECT_GETTER ( JSEquipmentInfoGetEquipmentType ,
& sEquipmentInfoClass,
sEquipmentInfoPrototype ,
OOEquipmentType  )

◆ EquipmentInfoGetAllEqipment()

JSBool EquipmentInfoGetAllEqipment ( JSContext * context,
JSObject * this,
jsid propID,
jsval * value )
static

Definition at line 471 of file OOJSEquipmentInfo.m.

472{
473 OOJS_NATIVE_ENTER(context)
474
475 *value = OOJSValueFromNativeObject(context, [OOEquipmentType allEquipmentTypes]);
476 return YES;
477
479}
#define OOJS_NATIVE_ENTER(cx)
#define OOJS_NATIVE_EXIT
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)

References OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, and OOJSValueFromNativeObject().

Here is the call graph for this function:

◆ EquipmentInfoGetProperty()

JSBool EquipmentInfoGetProperty ( JSContext * context,
JSObject * this,
jsid propID,
jsval * value )
static

Definition at line 224 of file OOJSEquipmentInfo.m.

225{
226 if (!JSID_IS_INT(propID))
227 return YES;
228
229 OOJS_NATIVE_ENTER(context)
230
231 OOEquipmentType* eqType = nil;
232 id result = nil;
233 NSUInteger inst_time;
234
235 if (EXPECT_NOT(!JSEquipmentInfoGetEquipmentType(context, this, &eqType)))
236 return NO;
237
238 switch (JSID_TO_INT(propID)) {
240 result = [eqType identifier];
241 break;
242
244 result = [eqType name];
245 break;
246
248 if ([[eqType identifier] isEqual:@"EQ_FUEL"]) {
249 return JS_NewNumberValue(context, (PLAYER_MAX_FUEL - [OOPlayerForScripting() fuel]) * [eqType price] * [OOPlayerForScripting() fuelChargeRate], value);
250 } else if ([[eqType identifier] isEqual:@"EQ_RENOVATION"]) {
251 return JS_NewNumberValue(context, [OOPlayerForScripting() renovationCosts], value);
252 } else {
253 return JS_NewNumberValue(context, [OOPlayerForScripting() adjustPriceByScriptForEqKey:[eqType identifier] withCurrent:[eqType price]], value);
254 }
256 *value = OOJSValueFromBOOL([eqType canCarryMultiple]);
257 return YES;
258
260 *value = OOJSValueFromBOOL([eqType canBeDamaged]);
261 return YES;
262
264 result = [eqType descriptiveText];
265 break;
266
268 return JS_NewNumberValue(context, [eqType damageProbability], value);
269
271 result = [[eqType displayColor] normalizedArray];
272 break;
273
275 *value = OOJSValueFromBOOL([eqType fastAffinityDefensive]);
276 return YES;
277
279 *value = OOJSValueFromBOOL([eqType fastAffinityOffensive]);
280 return YES;
281
283 result = [eqType defaultActivateKey];
284 break;
285
287 result = [eqType defaultModeKey];
288 break;
289
291 *value = INT_TO_JSVAL((int32_t)[eqType techLevel]);
292 return YES;
293
295 *value = INT_TO_JSVAL((int32_t)[eqType effectiveTechLevel]);
296 return YES;
297
299 return JS_NewNumberValue(context, [eqType price], value);
300
302 result = [eqType providesForScripting];
303 break;
304
306 inst_time = [eqType installTime];
307 if (inst_time == 0) {
308 inst_time = [eqType price] + 600;
309 }
310 *value = INT_TO_JSVAL((int32_t)inst_time);
311 return YES;
312
314 *value = OOJSValueFromBOOL([eqType isAvailableToAll]);
315 return YES;
316
318 *value = OOJSValueFromBOOL([eqType isAvailableToNPCs]);
319 return YES;
320
322 *value = OOJSValueFromBOOL([eqType isAvailableToPlayer]);
323 return YES;
324
326 *value = INT_TO_JSVAL((int32_t)[eqType repairTime]);
327 return YES;
328
330 *value = OOJSValueFromBOOL([eqType requiresEmptyPylon]);
331 return YES;
332
334 *value = OOJSValueFromBOOL([eqType requiresMountedPylon]);
335 return YES;
336
338 *value = OOJSValueFromBOOL([eqType requiresCleanLegalRecord]);
339 return YES;
340
342 *value = OOJSValueFromBOOL([eqType requiresNonCleanLegalRecord]);
343 return YES;
344
346 *value = OOJSValueFromBOOL([eqType requiresFreePassengerBerth]);
347 return YES;
348
350 *value = OOJSValueFromBOOL([eqType requiresFullFuel]);
351 return YES;
352
354 *value = OOJSValueFromBOOL([eqType requiresNonFullFuel]);
355 return YES;
356
358 *value = OOJSValueFromBOOL([eqType isMissileOrMine]);
359 return YES;
360
362 *value = OOJSValueFromBOOL([eqType isPortableBetweenShips]);
363 return YES;
364
366 *value = OOJSValueFromBOOL([eqType isVisible]);
367 return YES;
368
370 *value = INT_TO_JSVAL((int32_t)[eqType requiredCargoSpace]);
371 return YES;
372
374 result = [[eqType requiresEquipment] allObjects];
375 break;
376
378 result = [[eqType requiresAnyEquipment] allObjects];
379 break;
380
382 result = [[eqType incompatibleEquipment] allObjects];
383 break;
384
386 result = [eqType scriptInfo];
387 if (result == nil)
388 result = [NSDictionary dictionary]; // empty rather than null
389 break;
390
392 result = [eqType scriptName];
393 if (result == nil)
394 result = @"";
395 break;
396
398 result = [eqType weaponInfo];
399 if (result == nil)
400 result = [NSDictionary dictionary]; // empty rather than null
401 break;
402
403 default:
405 return NO;
406 }
407
408 *value = OOJSValueFromNativeObject(context, result);
409 return YES;
410
412}
#define EXPECT_NOT(x)
static JSPropertySpec sEquipmentInfoProperties[]
PlayerEntity * OOPlayerForScripting(void)
Definition OOJSPlayer.m:175
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
OOINLINE jsval OOJSValueFromBOOL(int b) INLINE_CONST_FUNC
return nil
#define PLAYER_MAX_FUEL
NSArray * normalizedArray()
Definition OOColor.m:465
NSDictionary * weaponInfo()
NSString * scriptName()
NSSet * incompatibleEquipment()
NSDictionary * scriptInfo()
OOColor * displayColor()
NSArray * defaultActivateKey()
NSArray * defaultModeKey()
NSSet * requiresEquipment()
NSSet * requiresAnyEquipment()
OOCreditsQuantity price()
NSUInteger installTime()
NSArray * providesForScripting()
NSString * identifier()
NSString * descriptiveText()

References OOEquipmentType::defaultActivateKey, OOEquipmentType::defaultModeKey, OOEquipmentType::descriptiveText, OOEquipmentType::displayColor, EXPECT_NOT, OOEquipmentType::identifier, OOEquipmentType::incompatibleEquipment, OOEquipmentType::installTime, kEquipmentInfo_calculatedPrice, kEquipmentInfo_canBeDamaged, kEquipmentInfo_canCarryMultiple, kEquipmentInfo_damageProbability, kEquipmentInfo_defaultActivateKey, kEquipmentInfo_defaultModeKey, kEquipmentInfo_description, kEquipmentInfo_displayColor, kEquipmentInfo_effectiveTechLevel, kEquipmentInfo_equipmentKey, kEquipmentInfo_fastAffinityDefensive, kEquipmentInfo_fastAffinityOffensive, kEquipmentInfo_incompatibleEquipment, kEquipmentInfo_installationTime, kEquipmentInfo_isAvailableToAll, kEquipmentInfo_isAvailableToNPCs, kEquipmentInfo_isAvailableToPlayer, kEquipmentInfo_isExternalStore, kEquipmentInfo_isPortableBetweenShips, kEquipmentInfo_isVisible, kEquipmentInfo_name, kEquipmentInfo_price, kEquipmentInfo_provides, kEquipmentInfo_repairTime, kEquipmentInfo_requiredCargoSpace, kEquipmentInfo_requiresAnyEquipment, kEquipmentInfo_requiresCleanLegalRecord, kEquipmentInfo_requiresEmptyPylon, kEquipmentInfo_requiresEquipment, kEquipmentInfo_requiresFreePassengerBerth, kEquipmentInfo_requiresFullFuel, kEquipmentInfo_requiresMountedPylon, kEquipmentInfo_requiresNonCleanLegalRecord, kEquipmentInfo_requiresNonFullFuel, kEquipmentInfo_scriptInfo, kEquipmentInfo_scriptName, kEquipmentInfo_techLevel, kEquipmentInfo_weaponInfo, OOEquipmentType::name, nil, OOColor::normalizedArray, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadPropertySelector(), OOJSValueFromBOOL(), OOJSValueFromNativeObject(), OOPlayerForScripting(), PLAYER_MAX_FUEL, OOEquipmentType::price, OOEquipmentType::providesForScripting, OOEquipmentType::requiresAnyEquipment, OOEquipmentType::requiresEquipment, OOEquipmentType::scriptInfo, OOEquipmentType::scriptName, sEquipmentInfoProperties, and OOEquipmentType::weaponInfo.

Here is the call graph for this function:

◆ EquipmentInfoSetProperty()

JSBool EquipmentInfoSetProperty ( JSContext * context,
JSObject * this,
jsid propID,
JSBool strict,
jsval * value )
static

Definition at line 414 of file OOJSEquipmentInfo.m.

415{
416 if (!JSID_IS_INT(propID))
417 return YES;
418
419 OOJS_NATIVE_ENTER(context)
420
421 OOEquipmentType* eqType = nil;
422 int32 iValue;
423 OOColor* colorForScript = nil;
424
425 if (EXPECT_NOT(!JSEquipmentInfoGetEquipmentType(context, this, &eqType)))
426 return NO;
427
428 switch (JSID_TO_INT(propID)) {
430 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
431 if (colorForScript != nil || JSVAL_IS_NULL(*value)) {
432 [eqType setDisplayColor:colorForScript];
433 return YES;
434 }
435 break;
437 OOStandardsDeprecated([NSString stringWithFormat:@"TL99 for variable tech level is deprecated for %@", [eqType identifier]]);
438 if (!OOEnforceStandards() && [eqType techLevel] == kOOVariableTechLevel) {
439 if (JSVAL_IS_NULL(*value)) {
440 // reset mission variable
442 forKey:[@"mission_TL_FOR_" stringByAppendingString:[eqType identifier]]];
443 return YES;
444 }
445 if (JS_ValueToInt32(context, *value, &iValue)) {
446 if (iValue < 0)
447 iValue = 0;
448 if (15 < iValue && iValue != kOOVariableTechLevel)
449 iValue = 15;
450 [OOPlayerForScripting() setMissionVariable:[NSString stringWithFormat:@"%u", iValue]
451 forKey:[@"mission_TL_FOR_" stringByAppendingString:[eqType identifier]]];
452 return YES;
453 }
454 } else {
455 OOJSReportWarning(context, @"Cannot modify effective tech level for %@, because its base tech level is not 99.", [eqType identifier]);
456 return YES;
457 }
458 break;
459
460 default:
462 return NO;
463 }
464
465 OOJSReportBadPropertyValue(context, this, propID, sEquipmentInfoProperties, *value);
466 return NO;
467
469}
void OOStandardsDeprecated(NSString *message)
BOOL OOEnforceStandards(void)
void OOJSReportWarning(JSContext *context, NSString *format,...)
void OOJSReportBadPropertyValue(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec, jsval value)
@ kOOVariableTechLevel
Definition OOTypes.h:175
OOColor * colorWithDescription:(id description)
Definition OOColor.m:135
void setDisplayColor:(OOColor *newColor)
void setMissionVariable:forKey:(NSString *value,[forKey] NSString *key)

References OOColor::colorWithDescription:, EXPECT_NOT, OOEquipmentType::identifier, kEquipmentInfo_displayColor, kEquipmentInfo_effectiveTechLevel, kOOVariableTechLevel, nil, OOEnforceStandards(), OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadPropertySelector(), OOJSReportBadPropertyValue(), OOJSReportWarning(), OOStandardsDeprecated(), sEquipmentInfoProperties, OOEquipmentType::setDisplayColor:, and PlayerEntity::setMissionVariable:forKey:.

Here is the call graph for this function:

◆ EquipmentInfoStaticInfoForKey()

JSBool EquipmentInfoStaticInfoForKey ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 512 of file OOJSEquipmentInfo.m.

513{
514 OOJS_NATIVE_ENTER(context)
515
516 NSString* key = nil;
517
518 if (argc > 0)
519 key = OOStringFromJSValue(context, OOJS_ARGV[0]);
520 if (key == nil) {
521 OOJSReportBadArguments(context, @"EquipmentInfo", @"infoForKey", MIN(argc, 1U), OOJS_ARGV, nil, @"string");
522 return NO;
523 }
524
525 OOJS_RETURN_OBJECT([OOEquipmentType equipmentTypeWithIdentifier:key]);
526
528}
#define OOJS_RETURN_OBJECT(o)
NSString * OOStringFromJSValue(JSContext *context, jsval value)
#define OOJS_ARGV
void OOJSReportBadArguments(JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, NSString *message, NSString *expectedArgsDescription)
#define MIN(A, B)
Definition OOMaths.h:91

References MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, OOJSReportBadArguments(), and OOStringFromJSValue().

Here is the call graph for this function:

◆ 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 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}

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)
OOEquipmentType * equipmentTypeWithIdentifier:(NSString *identifier)

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)
183 return nil;
184
186}

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:

Variable Documentation

◆ sEquipmentInfoClass

JSClass sEquipmentInfoClass
static
Initial value:
= {
"EquipmentInfo",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub,
JSCLASS_NO_OPTIONAL_MEMBERS
}
static JSBool EquipmentInfoGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
static JSBool EquipmentInfoSetProperty(JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
void OOJSObjectWrapperFinalize(JSContext *context, JSObject *this)

Definition at line 143 of file OOJSEquipmentInfo.m.

143 {
144 "EquipmentInfo",
145 JSCLASS_HAS_PRIVATE,
146
147 JS_PropertyStub, // addProperty
148 JS_PropertyStub, // delProperty
149 EquipmentInfoGetProperty, // getProperty
150 EquipmentInfoSetProperty, // setProperty
151 JS_EnumerateStub, // enumerate
152 JS_ResolveStub, // resolve
153 JS_ConvertStub, // convert
154 OOJSObjectWrapperFinalize, // finalize
155 JSCLASS_NO_OPTIONAL_MEMBERS
156};

Referenced by DEFINE_JS_OBJECT_GETTER(), InitOOJSEquipmentInfo(), InitOOJSEquipmentInfo(), JSValueToEquipmentType(), and OOEquipmentType(OOJavaScriptExtensions)::oo_jsValueInContext:.

◆ sEquipmentInfoMethods

JSFunctionSpec sEquipmentInfoMethods[]
static
Initial value:
= {
{ "toString", OOJSObjectWrapperToString, 0 },
{ 0 }
}
JSBool OOJSObjectWrapperToString(JSContext *context, uintN argc, jsval *vp)

Definition at line 131 of file OOJSEquipmentInfo.m.

131 {
132 // JS name Function min args
133 { "toString", OOJSObjectWrapperToString, 0 },
134 { 0 }
135};

Referenced by InitOOJSEquipmentInfo(), and InitOOJSEquipmentInfo().

◆ sEquipmentInfoProperties

JSPropertySpec sEquipmentInfoProperties[]
static

Definition at line 83 of file OOJSEquipmentInfo.m.

83 {
84 // JS name ID flags
111 { "requiresCleanLegalRecord", kEquipmentInfo_requiresCleanLegalRecord, OOJS_PROP_READONLY_CB },
114 { "requiresFreePassengerBerth", kEquipmentInfo_requiresFreePassengerBerth, OOJS_PROP_READONLY_CB },
117 { "requiresNonCleanLegalRecord", kEquipmentInfo_requiresNonCleanLegalRecord, OOJS_PROP_READONLY_CB },
123 { 0 }
124};
#define OOJS_PROP_READWRITE_CB
#define OOJS_PROP_READONLY_CB

Referenced by EquipmentInfoGetProperty(), EquipmentInfoGetProperty(), EquipmentInfoSetProperty(), EquipmentInfoSetProperty(), InitOOJSEquipmentInfo(), and InitOOJSEquipmentInfo().

◆ sEquipmentInfoPrototype

JSObject* sEquipmentInfoPrototype
static

◆ sEquipmentInfoStaticMethods

JSFunctionSpec sEquipmentInfoStaticMethods[]
static
Initial value:
= {
{ "infoForKey", EquipmentInfoStaticInfoForKey, 0 },
{ 0 }
}
static JSBool EquipmentInfoStaticInfoForKey(JSContext *context, uintN argc, jsval *vp)

Definition at line 137 of file OOJSEquipmentInfo.m.

137 {
138 // JS name Function min args
139 { "infoForKey", EquipmentInfoStaticInfoForKey, 0 },
140 { 0 }
141};

Referenced by InitOOJSEquipmentInfo(), and InitOOJSEquipmentInfo().

◆ sEquipmentInfoStaticProperties

JSPropertySpec sEquipmentInfoStaticProperties[]
static
Initial value:
= {
{ 0 }
}
static JSBool EquipmentInfoGetAllEqipment(JSContext *context, JSObject *this, jsid propID, jsval *value)

Definition at line 126 of file OOJSEquipmentInfo.m.

126 {
128 { 0 }
129};

Referenced by InitOOJSEquipmentInfo().