35static JSBool
ClockGetProperty(JSContext *context, JSObject *
this, jsid propID, jsval *value);
38static JSBool
JSClockToString(JSContext *context, uintN argc, jsval *vp);
40static JSBool
ClockAddSeconds(JSContext *context, uintN argc, jsval *vp);
51 JS_StrictPropertyStub,
56 JSCLASS_NO_OPTIONAL_MEMBERS
116static JSBool
ClockGetProperty(JSContext *context, JSObject *
this, jsid propID, jsval *value)
118 if (!JSID_IS_INT(propID))
return YES;
127 switch (JSID_TO_INT(propID))
130 return JS_NewNumberValue(context, [
UNIVERSE getTime], value);
133 return JS_NewNumberValue(context, clockTime, value);
136 return JS_NewNumberValue(context, floor(clockTime / 60.0), value);
139 return JS_NewNumberValue(context, floor(clockTime /3600.0), value);
143 *value = INT_TO_JSVAL(fmod(clockTime, 60.0));
147 *value = INT_TO_JSVAL(fmod(floor(clockTime / 60.0), 60.0));
151 *value = INT_TO_JSVAL(fmod(floor(clockTime / 3600.0), 24.0));
156 *value = INT_TO_JSVAL(floor(clockTime / 86400.0));
168 return JS_NewNumberValue(context, [player clockTimeAdjusted], value);
172 return JS_NewNumberValue(context, [player scriptTimer], value);
205 jsval arg = JSVAL_VOID;
223 const double kMaxTime = 30.0 * 24.0 * 3600.0;
227 jsval arg = JSVAL_VOID;
233 if (time > kMaxTime || time < 1.0 || !isfinite(time))
238 [OOPlayerForScripting() addToAdjustTime:time];
void OOStandardsDeprecated(NSString *message)
static JSBool ClockClockStringForTime(JSContext *context, uintN argc, jsval *vp)
@ kClock_secondsComponent
@ kClock_minutesComponent
@ kClock_legacy_scriptTimer
static JSBool ClockAddSeconds(JSContext *context, uintN argc, jsval *vp)
static JSClass sClockClass
static JSPropertySpec sClockProperties[]
void InitOOJSClock(JSContext *context, JSObject *global)
static JSBool ClockGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
static JSFunctionSpec sClockMethods[]
static JSBool JSClockToString(JSContext *context, uintN argc, jsval *vp)
#define OOJS_NATIVE_ENTER(cx)
PlayerEntity * OOPlayerForScripting(void)
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
#define OOJS_RETURN_OBJECT(o)
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
#define OOJS_RETURN_BOOL(v)
JSBool OOJSUnconstructableConstruct(JSContext *context, uintN argc, jsval *vp)
#define OOJS_PROP_READONLY
OOINLINE jsval OOJSValueFromBOOL(int b) INLINE_CONST_FUNC
void OOJSReportBadArguments(JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, NSString *message, NSString *expectedArgsDescription)
#define OOJS_PROP_READONLY_CB
NSString * ClockToString(double clock, BOOL adjusting)