Oolite
Loading...
Searching...
No Matches
OOJSTimer(Private) Category Reference

Instance Methods

(id) - initWithDelay:interval:context:function:this:
(id) - initWithDelay:interval:context:function:this:
(void) - clearJSSelf
(BOOL) - willNotFireAgain
(JSValue) - transferJSSelf
(void) - releaseJSValues

Detailed Description

Definition at line 36 of file OOJSTimer.m.

Method Documentation

◆ clearJSSelf

- (void) clearJSSelf

Extends class OOJSTimer.

Definition at line 246 of file OOJSTimer.m.

247{
248 _jsSelf = JS_UNDEFINED;
249}

References clearJSSelf.

Referenced by clearJSSelf, and initWithDelay:interval:context:function:this:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initWithDelay:interval:context:function:this: [1/2]

- (id) initWithDelay: (OOTimeAbsolute) delay
interval: (OOTimeDelta) interval
context: (JSContext *) context
function: (jsval) function
this: (JSObject *) jsThis 

Extends class OOJSTimer.

Definition at line 48 of file OOJSTimer.m.

48 :(OOTimeAbsolute)delay
49 interval:(OOTimeDelta)interval
50 context:(JSContext*)context
51 function:(jsval)function
52 this:(JSObject*)jsThis
53{
54 self = [super initWithNextTime:[UNIVERSE getTime] + delay interval:interval];
55 if (self != nil) {
56 NSAssert(OOJSValueIsFunction(context, function), @"Attempt to init OOJSTimer with a function that isn't.");
57
58 _jsThis = jsThis;
59 OOJSAddGCObjectRoot(context, &_jsThis, "OOJSTimer this");
60
61 _function = function;
62 OOJSAddGCValueRoot(context, &_function, "OOJSTimer function");
63
64 _jsSelf = JS_NewObject(context, &sTimerClass, sTimerPrototype, NULL);
65 if (_jsSelf != NULL) {
66 if (!JS_SetPrivate(context, _jsSelf, [self retain]))
67 _jsSelf = NULL;
68 }
69 if (_jsSelf == NULL) {
70 [self release];
71 return nil;
72 }
73
75
76 [[NSNotificationCenter defaultCenter] addObserver:self
77 selector:@selector(deleteJSPointers)
78 name:kOOJavaScriptEngineWillResetNotification
80 }
81
82 return self;
83}
static JSObject * sTimerPrototype
Definition OOJSTimer.m:33
OOINLINE BOOL OOJSValueIsFunction(JSContext *context, jsval value)
#define OOJSAddGCObjectRoot(context, root, name)
#define OOJSAddGCValueRoot(context, root, name)
return nil
double OOTimeDelta
Definition OOTypes.h:193
double OOTimeAbsolute
Definition OOTypes.h:192
static JSClassDef sTimerClass
Definition OOJSTimer.m:34
OOJSScript * currentlyRunningScript()
Definition OOJSScript.m:101
OOJavaScriptEngine * sharedEngine()

References OOJSScript::currentlyRunningScript, OOScriptTimer::initWithNextTime:interval:, nil, OOJSAddGCObjectRoot, OOJSAddGCValueRoot, OOJSValueIsFunction(), OOJavaScriptEngine::sharedEngine, sTimerClass, sTimerPrototype, and OOJSScript::weakRetain.

Here is the call graph for this function:

◆ initWithDelay:interval:context:function:this: [2/2]

- (id) initWithDelay: (OOTimeAbsolute) delay
interval: (OOTimeDelta) interval
context: (JSContext *) context
function: (JSValueConst) function
this: (JSValueConst) jsThis 

References clearJSSelf, releaseJSValues, transferJSSelf, and willNotFireAgain.

Here is the call graph for this function:

◆ releaseJSValues

- (void) releaseJSValues

Extends class OOJSTimer.

Definition at line 133 of file OOJSTimer.m.

134{
135 [self unscheduleTimer];
136
137 // Ivars are zero-filled (not objects) before they are set.
138 if (JS_IsObject(_function)) {
139 // Don't touch the ivars after freeing (see -deleteJSPointers).
140 JSValue function = _function;
141 JSValue jsThis = _jsThis;
142 _function = JS_UNDEFINED;
143 _jsThis = JS_UNDEFINED;
144
145 [[NSNotificationCenter defaultCenter] removeObserver:self
146 name:kOOJavaScriptEngineWillResetNotification
148
149 JSContext* context = OOJSAcquireContext();
150 JS_FreeValue(context, function);
151 JS_FreeValue(context, jsThis);
152 OOJSRelinquishContext(context);
153 }
154}
OOINLINE JSContext * OOJSAcquireContext(void)
OOINLINE void OOJSRelinquishContext(JSContext *context)

References OOJSAcquireContext(), OOJSRelinquishContext(), releaseJSValues, OOJavaScriptEngine::sharedEngine, and OOScriptTimer::unscheduleTimer.

Referenced by OOJSTimer::initWithDelay:interval:context:function:this:, initWithDelay:interval:context:function:this:, and releaseJSValues.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transferJSSelf

- (JSValue) transferJSSelf

Extends class OOJSTimer.

Definition at line 266 of file OOJSTimer.m.

267{
268 return _jsSelf;
269}

References transferJSSelf.

Referenced by initWithDelay:interval:context:function:this:, TimerConstruct(), and transferJSSelf.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ willNotFireAgain

- (BOOL) willNotFireAgain

Extends class OOJSTimer.

Definition at line 256 of file OOJSTimer.m.

257{
258 return _firing && [self interval] <= 0.0;
259}

References OOScriptTimer::interval, and willNotFireAgain.

Referenced by initWithDelay:interval:context:function:this:, TimerFinalize(), and willNotFireAgain.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this category was generated from the following files: