155 JSCLASS_NO_OPTIONAL_MEMBERS
173 if (JSVAL_IS_OBJECT(value)) {
174 JSObject*
object = JSVAL_TO_OBJECT(value);
197 NSString* result =
nil;
202 result = [objValue identifier];
204 }
else if ([objValue isKindOfClass:[NSString
class]]) {
210 if (exists || ![objValue hasSuffix:
@"_DAMAGED"]) {
215 if (outExists != NULL)
226 if (!JSID_IS_INT(propID))
233 NSUInteger inst_time;
235 if (
EXPECT_NOT(!JSEquipmentInfoGetEquipmentType(context,
this, &eqType)))
238 switch (JSID_TO_INT(propID)) {
244 result = [eqType
name];
248 if ([[eqType identifier] isEqual:
@"EQ_FUEL"]) {
250 }
else if ([[eqType identifier] isEqual:
@"EQ_RENOVATION"]) {
253 return JS_NewNumberValue(context, [
OOPlayerForScripting() adjustPriceByScriptForEqKey:[eqType identifier] withCurrent:[eqType price]], value);
268 return JS_NewNumberValue(context, [eqType damageProbability], value);
291 *value = INT_TO_JSVAL((int32_t)[eqType techLevel]);
295 *value = INT_TO_JSVAL((int32_t)[eqType effectiveTechLevel]);
299 return JS_NewNumberValue(context, [eqType price], value);
307 if (inst_time == 0) {
308 inst_time = [eqType
price] + 600;
310 *value = INT_TO_JSVAL((int32_t)inst_time);
326 *value = INT_TO_JSVAL((int32_t)[eqType repairTime]);
370 *value = INT_TO_JSVAL((int32_t)[eqType requiredCargoSpace]);
388 result = [NSDictionary dictionary];
400 result = [NSDictionary dictionary];
416 if (!JSID_IS_INT(propID))
425 if (
EXPECT_NOT(!JSEquipmentInfoGetEquipmentType(context,
this, &eqType)))
428 switch (JSID_TO_INT(propID)) {
431 if (colorForScript !=
nil || JSVAL_IS_NULL(*value)) {
437 OOStandardsDeprecated([NSString stringWithFormat:
@"TL99 for variable tech level is deprecated for %@", [eqType identifier]]);
439 if (JSVAL_IS_NULL(*value)) {
445 if (JS_ValueToInt32(context, *value, &iValue)) {
455 OOJSReportWarning(context,
@"Cannot modify effective tech level for %@, because its base tech level is not 99.", [eqType identifier]);
481@implementation OOEquipmentType (OOJavaScriptExtensions)
483- (jsval)oo_jsValueInContext:(JSContext*)context
485 if (_jsSelf == NULL) {
487 if (_jsSelf != NULL) {
488 if (!JS_SetPrivate(context, _jsSelf, [
self retain]))
493 return OBJECT_TO_JSVAL(_jsSelf);
498 return @"EquipmentInfo";
501- (void)oo_clearJSSelf:(JSObject*)selfVal
503 if (_jsSelf == selfVal)
void OOStandardsDeprecated(NSString *message)
BOOL OOEnforceStandards(void)
#define OOJS_PROFILE_EXIT
#define OOJS_NATIVE_ENTER(cx)
#define OOJS_PROFILE_ENTER
static JSBool EquipmentInfoGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
OOEquipmentType * JSValueToEquipmentType(JSContext *context, jsval value)
static JSObject * sEquipmentInfoPrototype
static JSClass sEquipmentInfoClass
static JSFunctionSpec sEquipmentInfoMethods[]
@ 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_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
static JSBool EquipmentInfoSetProperty(JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
void InitOOJSEquipmentInfo(JSContext *context, JSObject *global)
static JSFunctionSpec sEquipmentInfoStaticMethods[]
static JSPropertySpec sEquipmentInfoProperties[]
static JSBool EquipmentInfoStaticInfoForKey(JSContext *context, uintN argc, jsval *vp)
static JSBool EquipmentInfoGetAllEqipment(JSContext *context, JSObject *this, jsid propID, jsval *value)
NSString * JSValueToEquipmentKeyRelaxed(JSContext *context, jsval value, BOOL *outExists)
NSString * JSValueToEquipmentKey(JSContext *context, jsval value)
static JSPropertySpec sEquipmentInfoStaticProperties[]
PlayerEntity * OOPlayerForScripting(void)
id OOJSNativeObjectFromJSValue(JSContext *context, jsval value)
void OOJSReportWarning(JSContext *context, NSString *format,...)
JSBool OOJSObjectWrapperToString(JSContext *context, uintN argc, jsval *vp)
#define OOJS_PROP_READWRITE_CB
void OOJSRegisterObjectConverter(JSClass *theClass, OOJSClassConverterCallback converter)
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
#define DEFINE_JS_OBJECT_GETTER(NAME, JSCLASS, JSPROTO, OBJCCLASSNAME)
void OOJSObjectWrapperFinalize(JSContext *context, JSObject *this)
#define OOJS_RETURN_OBJECT(o)
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
NSString * OOStringFromJSValue(JSContext *context, jsval value)
JSBool OOJSUnconstructableConstruct(JSContext *context, uintN argc, jsval *vp)
OOINLINE jsval OOJSValueFromBOOL(int b) INLINE_CONST_FUNC
void OOJSReportBadPropertyValue(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec, jsval value)
id OOJSBasicPrivateObjectConverter(JSContext *context, JSObject *object)
void OOJSReportBadArguments(JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, NSString *message, NSString *expectedArgsDescription)
#define OOJS_PROP_READONLY_CB
NSString * oo_jsClassName()
OOColor * colorWithDescription:(id description)
NSArray * normalizedArray()
void setDisplayColor:(OOColor *newColor)
NSDictionary * weaponInfo()
NSSet * incompatibleEquipment()
NSDictionary * scriptInfo()
NSArray * defaultActivateKey()
NSArray * defaultModeKey()
NSSet * requiresEquipment()
NSSet * requiresAnyEquipment()
OOEquipmentType * equipmentTypeWithIdentifier:(NSString *identifier)
OOCreditsQuantity price()
NSArray * providesForScripting()
NSString * descriptiveText()
void setMissionVariable:forKey:(NSString *value,[forKey] NSString *key)