Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOJSPopulatorDefinition Class Reference

#include <OOJSPopulatorDefinition.h>

+ Inheritance diagram for OOJSPopulatorDefinition:
+ Collaboration diagram for OOJSPopulatorDefinition:

Instance Methods

(jsval) - callback
 
(void) - setCallback:
 
(JSObject *) - callbackThis
 
(void) - setCallbackThis:
 
(void) - runCallback:
 
(id) - init [implementation]
 
(void) - deleteJSPointers [implementation]
 
(void) - dealloc [implementation]
 
- Instance Methods inherited from OOWeakRefObject
(id) - weakSelf
 
(id) - weakRetain [implementation]
 
(void) - weakRefDied: [implementation]
 
- Instance Methods inherited from <OOWeakReferenceSupport>
(id) - OO_RETURNS_RETAINED
 

Private Attributes

jsval _callback
 
JSObject * _callbackThis
 
OOJSScript_owningScript
 

Additional Inherited Members

- Protected Attributes inherited from OOWeakRefObject
OOWeakReferenceweakSelf
 

Detailed Description

Definition at line 30 of file OOJSPopulatorDefinition.h.

Method Documentation

◆ callback

- (jsval) callback

Definition at line 1 of file OOJSPopulatorDefinition.m.

75{
76 return _callback;
77}

References _callback, _callbackThis, _owningScript, OOJSScript::currentlyRunningScript, OOJavaScriptEngine::sharedEngine, and OOJSScript::weakRetain.

+ Here is the call graph for this function:

◆ callbackThis

- (JSObject *) callbackThis

Definition at line 1 of file OOJSPopulatorDefinition.m.

91{
92 return _callbackThis;
93}

◆ dealloc

- (void) dealloc
implementation

Reimplemented from OOWeakRefObject.

Definition at line 1 of file OOJSPopulatorDefinition.m.

66{
67 [_owningScript release];
68
69 [self deleteJSPointers];
70
71 [super dealloc];
72}

◆ deleteJSPointers

- (void) deleteJSPointers
implementation

Definition at line 1 of file OOJSPopulatorDefinition.m.

49{
50
51 JSContext *context = OOJSAcquireContext();
52 _callback = JSVAL_VOID;
53 _callbackThis = NULL;
54 JS_RemoveValueRoot(context, &_callback);
55 JS_RemoveObjectRoot(context, &_callbackThis);
56
57 OOJSRelinquishContext(context);
58
59 [[NSNotificationCenter defaultCenter] removeObserver:self
60 name:kOOJavaScriptEngineWillResetNotification
62
63}
OOINLINE JSContext * OOJSAcquireContext(void)
OOINLINE void OOJSRelinquishContext(JSContext *context)
OOJavaScriptEngine * sharedEngine()

◆ init

- (id) init
implementation

Definition at line 1 of file OOJSPopulatorDefinition.m.

33 {
34 self = [super init];
35 _callback = JSVAL_VOID;
36 _callbackThis = NULL;
37
39
40 [[NSNotificationCenter defaultCenter] addObserver:self
41 selector:@selector(deleteJSPointers)
42 name:kOOJavaScriptEngineWillResetNotification
44
45 return self;
46}
OOJSScript * currentlyRunningScript()
Definition OOJSScript.m:339

◆ runCallback:

- (void) runCallback: (HPVector) location

Definition at line 1 of file OOJSPopulatorDefinition.m.

106 :(HPVector)location
107{
109 JSContext *context = OOJSAcquireContext();
110 jsval loc, rval = JSVAL_VOID;
111
112 VectorToJSValue(context, HPVectorToVector(location), &loc);
113
114 OOJSScript *owner = [_owningScript retain]; // local copy needed
115 [OOJSScript pushScript:owner];
116
117 [engine callJSFunction:_callback
118 forObject:_callbackThis
119 argc:1
120 argv:&loc
121 result:&rval];
122
123 [OOJSScript popScript:owner];
124 [owner release];
125
126 OOJSRelinquishContext(context);
127}
BOOL VectorToJSValue(JSContext *context, Vector vector, jsval *outValue) NONNULL_FUNC
Definition OOJSVector.m:185
void pushScript:(OOJSScript *script)
Definition OOJSScript.m:537
void popScript:(OOJSScript *script)
Definition OOJSScript.m:550
BOOL callJSFunction:forObject:argc:argv:result:(jsval function,[forObject] JSObject *jsThis,[argc] uintN argc,[argv] jsval *argv,[result] jsval *outResult)

◆ setCallback:

- (void) setCallback: (jsval) callback

Definition at line 1 of file OOJSPopulatorDefinition.m.

80 :(jsval)callback
81{
82 JSContext *context = OOJSAcquireContext();
83 JS_RemoveValueRoot(context, &_callback);
85 OOJSAddGCValueRoot(context, &_callback, "OOJSPopulatorDefinition callback function");
86 OOJSRelinquishContext(context);
87}
#define OOJSAddGCValueRoot(context, root, name)

Referenced by SystemSetPopulator().

+ Here is the caller graph for this function:

◆ setCallbackThis:

- (void) setCallbackThis: (JSObject *) callbackthis

Definition at line 1 of file OOJSPopulatorDefinition.m.

96 :(JSObject *)callbackThis
97{
98 JSContext *context = OOJSAcquireContext();
99 JS_RemoveObjectRoot(context, &_callbackThis);
101 OOJSAddGCObjectRoot(context, &_callbackThis, "OOJSPopulatorDefinition callback this");
102 OOJSRelinquishContext(context);
103}
#define OOJSAddGCObjectRoot(context, root, name)

Member Data Documentation

◆ _callback

- (jsval) _callback
private

Definition at line 33 of file OOJSPopulatorDefinition.h.

Referenced by callback.

◆ _callbackThis

- (JSObject*) _callbackThis
private

Definition at line 34 of file OOJSPopulatorDefinition.h.

Referenced by callback.

◆ _owningScript

- (OOJSScript*) _owningScript
private

Definition at line 35 of file OOJSPopulatorDefinition.h.

Referenced by callback.


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