39static JSBool
ManifestComment(JSContext *context, uintN argc, jsval *vp);
46static JSBool
ManifestGetProperty(JSContext *context, JSObject *
this, jsid propID, jsval *value);
47static JSBool
ManifestSetProperty(JSContext *context, JSObject *
this, jsid propID, JSBool strict, jsval *value);
63 JSCLASS_NO_OPTIONAL_MEMBERS
111- (jsval) oo_jsValueInContext:(JSContext *)context
113 JSObject *jsSelf = NULL;
114 jsval result = JSVAL_NULL;
119 if (!JS_SetPrivate(context, jsSelf, [
self retain])) jsSelf = NULL;
121 if (jsSelf != NULL) result = OBJECT_TO_JSVAL(jsSelf);
147 jsval v = JSVAL_VOID;
159 if (JSID_IS_INT(propID))
161 switch (JSID_TO_INT(propID))
172 else if (JSID_IS_STRING(propID))
179 if ([[
UNIVERSE commodities] goodDefined:key])
181 *value = INT_TO_JSVAL([entity cargoQuantityForType:key]);
197static JSBool
ManifestSetProperty(JSContext *context, JSObject *
this, jsid propID, JSBool strict, jsval *value)
204 if (JSID_IS_STRING(propID))
208 OOMassUnit unit = [[UNIVERSE commodityMarket] massUnitForGood:key];
210 if (unit ==
UNITS_TONS && [entity specialCargo])
212 OOJSReportWarning(context,
@"PlayerShip.manifest['foo'] - cannot modify cargo tonnage when Special Cargo is in use.");
216 if (JS_ValueToInt32(context, *value, &iValue))
218 if (iValue < 0) iValue = 0;
237 NSString * information =
nil;
249 information = [[PLAYER shipCommodityData] commentForGood:good];
263 NSString * information =
nil;
270 if (good ==
nil || information ==
nil)
276 OK = [[PLAYER shipCommodityData] setComment:information forGood:good];
289 NSString * information =
nil;
301 information = [[PLAYER shipCommodityData] shortCommentForGood:good];
315 NSString * information =
nil;
322 if (good ==
nil || information ==
nil)
328 OK = [[PLAYER shipCommodityData] setShortComment:information forGood:good];
#define OOJS_NATIVE_ENTER(cx)
static JSBool ManifestShortComment(JSContext *context, uintN argc, jsval *vp)
static JSObject * sManifestPrototype
void InitOOJSManifest(JSContext *context, JSObject *global)
static JSBool ManifestDeleteProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
static JSFunctionSpec sManifestMethods[]
static JSBool ManifestGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
static JSBool ManifestSetProperty(JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
static JSObject * sManifestObject
static JSBool ManifestSetShortComment(JSContext *context, uintN argc, jsval *vp)
static JSClass sManifestClass
static JSBool ManifestComment(JSContext *context, uintN argc, jsval *vp)
static JSPropertySpec sManifestProperties[]
static JSBool ManifestSetComment(JSContext *context, uintN argc, jsval *vp)
JSObject * JSPlayerShipObject(void)
PlayerEntity * OOPlayerForScripting(void)
void OOJSReportWarning(JSContext *context, NSString *format,...)
void OOJSRegisterObjectConverter(JSClass *theClass, OOJSClassConverterCallback converter)
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
void OOJSObjectWrapperFinalize(JSContext *context, JSObject *this)
#define OOJS_RETURN_OBJECT(o)
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
#define OOJS_RETURN_BOOL(v)
NSString * OOStringFromJSValue(JSContext *context, jsval value)
JSBool OOJSUnconstructableConstruct(JSContext *context, uintN argc, jsval *vp)
#define OOJS_PROP_READONLY
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 * OOStringFromJSString(JSContext *context, JSString *string)
NSString * OOCommodityType
NSString * oo_jsClassName()
OOCargoQuantity setCargoQuantityForType:amount:(OOCommodityType type,[amount] OOCargoQuantity amount)
NSArray * cargoListForScripting()