Oolite 1.91.0.7708-250910-30bbc4c
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)
OOEquipmentTypeJSValueToEquipmentType (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 45 of file OOJSEquipmentInfo.m.

46{
47 // Property IDs
65 kEquipmentInfo_isExternalStore, // is missile or mine
82 kEquipmentInfo_scriptInfo, // arbitrary data for scripts, dictionary, read-only
86};
@ 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 503 of file OOJSEquipmentInfo.m.

504{
505 OOJS_NATIVE_ENTER(context)
506
507 *value = OOJSValueFromNativeObject(context, [OOEquipmentType allEquipmentTypes]);
508 return YES;
509
511}
#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 249 of file OOJSEquipmentInfo.m.

250{
251 if (!JSID_IS_INT(propID)) return YES;
252
253 OOJS_NATIVE_ENTER(context)
254
255 OOEquipmentType *eqType = nil;
256 id result = nil;
257 NSUInteger inst_time;
258
259 if (EXPECT_NOT(!JSEquipmentInfoGetEquipmentType(context, this, &eqType))) return NO;
260
261 switch (JSID_TO_INT(propID))
262 {
264 result = [eqType identifier];
265 break;
266
268 result = [eqType name];
269 break;
270
272 if ([[eqType identifier] isEqual:@"EQ_FUEL"])
273 {
274 return JS_NewNumberValue(context, (PLAYER_MAX_FUEL - [OOPlayerForScripting() fuel]) * [eqType price] * [OOPlayerForScripting() fuelChargeRate], value);
275 }
276 else if ([[eqType identifier] isEqual:@"EQ_RENOVATION"])
277 {
278 return JS_NewNumberValue(context, [OOPlayerForScripting() renovationCosts], value);
279 }
280 else
281 {
282 return JS_NewNumberValue(context, [OOPlayerForScripting() adjustPriceByScriptForEqKey:[eqType identifier] withCurrent:[eqType price]], value);
283 }
285 *value = OOJSValueFromBOOL([eqType canCarryMultiple]);
286 return YES;
287
289 *value = OOJSValueFromBOOL([eqType canBeDamaged]);
290 return YES;
291
293 result = [eqType descriptiveText];
294 break;
295
297 return JS_NewNumberValue(context, [eqType damageProbability], value);
298
300 result = [[eqType displayColor] normalizedArray];
301 break;
302
304 *value = OOJSValueFromBOOL([eqType fastAffinityDefensive]);
305 return YES;
306
308 *value = OOJSValueFromBOOL([eqType fastAffinityOffensive]);
309 return YES;
310
312 result = [eqType defaultActivateKey];
313 break;
314
316 result = [eqType defaultModeKey];
317 break;
318
320 *value = INT_TO_JSVAL((int32_t)[eqType techLevel]);
321 return YES;
322
324 *value = INT_TO_JSVAL((int32_t)[eqType effectiveTechLevel]);
325 return YES;
326
328 return JS_NewNumberValue(context, [eqType price], value);
329
331 result = [eqType providesForScripting];
332 break;
333
335 inst_time = [eqType installTime];
336 if (inst_time == 0)
337 {
338 inst_time = [eqType price] + 600;
339 }
340 *value = INT_TO_JSVAL((int32_t)inst_time);
341 return YES;
342
344 *value = OOJSValueFromBOOL([eqType isAvailableToAll]);
345 return YES;
346
348 *value = OOJSValueFromBOOL([eqType isAvailableToNPCs]);
349 return YES;
350
352 *value = OOJSValueFromBOOL([eqType isAvailableToPlayer]);
353 return YES;
354
356 *value = INT_TO_JSVAL((int32_t)[eqType repairTime]);
357 return YES;
358
360 *value = OOJSValueFromBOOL([eqType requiresEmptyPylon]);
361 return YES;
362
364 *value = OOJSValueFromBOOL([eqType requiresMountedPylon]);
365 return YES;
366
368 *value = OOJSValueFromBOOL([eqType requiresCleanLegalRecord]);
369 return YES;
370
372 *value = OOJSValueFromBOOL([eqType requiresNonCleanLegalRecord]);
373 return YES;
374
376 *value = OOJSValueFromBOOL([eqType requiresFreePassengerBerth]);
377 return YES;
378
380 *value = OOJSValueFromBOOL([eqType requiresFullFuel]);
381 return YES;
382
384 *value = OOJSValueFromBOOL([eqType requiresNonFullFuel]);
385 return YES;
386
388 *value = OOJSValueFromBOOL([eqType isMissileOrMine]);
389 return YES;
390
392 *value = OOJSValueFromBOOL([eqType isPortableBetweenShips]);
393 return YES;
394
396 *value = OOJSValueFromBOOL([eqType isVisible]);
397 return YES;
398
400 *value = INT_TO_JSVAL((int32_t)[eqType requiredCargoSpace]);
401 return YES;
402
404 result = [[eqType requiresEquipment] allObjects];
405 break;
406
408 result = [[eqType requiresAnyEquipment] allObjects];
409 break;
410
412 result = [[eqType incompatibleEquipment] allObjects];
413 break;
414
416 result = [eqType scriptInfo];
417 if (result == nil) result = [NSDictionary dictionary]; // empty rather than null
418 break;
419
421 result = [eqType scriptName];
422 if (result == nil) result = @"";
423 break;
424
426 result = [eqType weaponInfo];
427 if (result == nil) result = [NSDictionary dictionary]; // empty rather than null
428 break;
429
430 default:
432 return NO;
433 }
434
435 *value = OOJSValueFromNativeObject(context, result);
436 return YES;
437
439}
#define EXPECT_NOT(x)
static JSPropertySpec sEquipmentInfoProperties[]
PlayerEntity * OOPlayerForScripting(void)
Definition OOJSPlayer.m:191
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:511
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 442 of file OOJSEquipmentInfo.m.

443{
444 if (!JSID_IS_INT(propID)) return YES;
445
446 OOJS_NATIVE_ENTER(context)
447
448 OOEquipmentType *eqType = nil;
449 int32 iValue;
450 OOColor *colorForScript = nil;
451
452 if (EXPECT_NOT(!JSEquipmentInfoGetEquipmentType(context, this, &eqType))) return NO;
453
454 switch (JSID_TO_INT(propID))
455 {
457 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
458 if (colorForScript != nil || JSVAL_IS_NULL(*value))
459 {
460 [eqType setDisplayColor:colorForScript];
461 return YES;
462 }
463 break;
465 OOStandardsDeprecated([NSString stringWithFormat:@"TL99 for variable tech level is deprecated for %@",[eqType identifier]]);
466 if (!OOEnforceStandards() && [eqType techLevel] == kOOVariableTechLevel)
467 {
468 if (JSVAL_IS_NULL(*value))
469 {
470 // reset mission variable
472 forKey:[@"mission_TL_FOR_" stringByAppendingString:[eqType identifier]]];
473 return YES;
474 }
475 if (JS_ValueToInt32(context, *value, &iValue))
476 {
477 if (iValue < 0) iValue = 0;
478 if (15 < iValue && iValue != kOOVariableTechLevel) iValue = 15;
479 [OOPlayerForScripting() setMissionVariable:[NSString stringWithFormat:@"%u", iValue]
480 forKey:[@"mission_TL_FOR_" stringByAppendingString:[eqType identifier]]];
481 return YES;
482 }
483 }
484 else
485 {
486 OOJSReportWarning(context, @"Cannot modify effective tech level for %@, because its base tech level is not 99.", [eqType identifier]);
487 return YES;
488 }
489 break;
490
491 default:
493 return NO;
494 }
495
496 OOJSReportBadPropertyValue(context, this, propID, sEquipmentInfoProperties, *value);
497 return NO;
498
500}
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:202
OOColor * colorWithDescription:(id description)
Definition OOColor.m:127
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 548 of file OOJSEquipmentInfo.m.

549{
550 OOJS_NATIVE_ENTER(context)
551
552 NSString *key = nil;
553
554 if (argc > 0) key = OOStringFromJSValue(context, OOJS_ARGV[0]);
555 if (key == nil)
556 {
557 OOJSReportBadArguments(context, @"EquipmentInfo", @"infoForKey", MIN(argc, 1U), OOJS_ARGV, nil, @"string");
558 return NO;
559 }
560
561 OOJS_RETURN_OBJECT([OOEquipmentType equipmentTypeWithIdentifier:key]);
562
564}
#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:111

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

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

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}

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

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}

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:

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

158{
159 "EquipmentInfo",
160 JSCLASS_HAS_PRIVATE,
161
162 JS_PropertyStub, // addProperty
163 JS_PropertyStub, // delProperty
164 EquipmentInfoGetProperty, // getProperty
165 EquipmentInfoSetProperty, // setProperty
166 JS_EnumerateStub, // enumerate
167 JS_ResolveStub, // resolve
168 JS_ConvertStub, // convert
169 OOJSObjectWrapperFinalize, // finalize
170 JSCLASS_NO_OPTIONAL_MEMBERS
171};

Referenced by DEFINE_JS_OBJECT_GETTER(), 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 141 of file OOJSEquipmentInfo.m.

142{
143 // JS name Function min args
144 { "toString", OOJSObjectWrapperToString, 0 },
145 { 0 }
146};

Referenced by InitOOJSEquipmentInfo().

◆ sEquipmentInfoProperties

JSPropertySpec sEquipmentInfoProperties[]
static

Definition at line 89 of file OOJSEquipmentInfo.m.

90{
91 // JS name ID flags
118 { "requiresCleanLegalRecord", kEquipmentInfo_requiresCleanLegalRecord, OOJS_PROP_READONLY_CB },
121 { "requiresFreePassengerBerth", kEquipmentInfo_requiresFreePassengerBerth, OOJS_PROP_READONLY_CB },
124 { "requiresNonCleanLegalRecord", kEquipmentInfo_requiresNonCleanLegalRecord, OOJS_PROP_READONLY_CB },
130 { 0 }
131};
#define OOJS_PROP_READWRITE_CB
#define OOJS_PROP_READONLY_CB

Referenced by EquipmentInfoGetProperty(), EquipmentInfoSetProperty(), 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 149 of file OOJSEquipmentInfo.m.

150{
151 // JS name Function min args
152 { "infoForKey", EquipmentInfoStaticInfoForKey, 0 },
153 { 0 }
154};

Referenced by InitOOJSEquipmentInfo().

◆ sEquipmentInfoStaticProperties

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

Definition at line 134 of file OOJSEquipmentInfo.m.

135{
137 { 0 }
138};

Referenced by InitOOJSEquipmentInfo().