Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
OOJSGuiScreenKeyDefinition Class Reference

#include <OOJSGuiScreenKeyDefinition.h>

+ Inheritance diagram for OOJSGuiScreenKeyDefinition:
+ Collaboration diagram for OOJSGuiScreenKeyDefinition:

Instance Methods

(NSString *) - name
 
(void) - setName:
 
(NSDictionary *) - registerKeys
 
(void) - setRegisterKeys:
 
(jsval) - callback
 
(void) - setCallback:
 
(JSObject *) - callbackThis
 
(void) - setCallbackThis:
 
(void) - runCallback:
 
(NSComparisonResult) - interfaceCompare:
 
(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
 
NSString * _name
 
NSDictionary * _registerKeys
 

Additional Inherited Members

- Protected Attributes inherited from OOWeakRefObject
OOWeakReferenceweakSelf
 

Detailed Description

Definition at line 29 of file OOJSGuiScreenKeyDefinition.h.

Method Documentation

◆ callback

- (jsval) callback

Definition at line 1 of file OOJSGuiScreenKeyDefinition.m.

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 OOJSGuiScreenKeyDefinition.m.

116{
117 return _callbackThis;
118}

◆ dealloc

- (void) dealloc
implementation

Reimplemented from OOWeakRefObject.

Definition at line 1 of file OOJSGuiScreenKeyDefinition.m.

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

◆ deleteJSPointers

- (void) deleteJSPointers
implementation

Definition at line 1 of file OOJSGuiScreenKeyDefinition.m.

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

◆ init

- (id) init
implementation

Definition at line 1 of file OOJSGuiScreenKeyDefinition.m.

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

◆ interfaceCompare:

- (NSComparisonResult) interfaceCompare: (OOJSGuiScreenKeyDefinition *) other

Definition at line 1 of file OOJSGuiScreenKeyDefinition.m.

156{
157 return [_name caseInsensitiveCompare:[other name]];
158}

◆ name

- (NSString *) name

Definition at line 1 of file OOJSGuiScreenKeyDefinition.m.

74{
75 return _name;
76}

◆ registerKeys

- (NSDictionary *) registerKeys

Definition at line 1 of file OOJSGuiScreenKeyDefinition.m.

87{
88 return _registerKeys;
89}

◆ runCallback:

- (void) runCallback: (NSString *) key

Definition at line 1 of file OOJSGuiScreenKeyDefinition.m.

131 :(NSString *)key
132{
134 JSContext *context = OOJSAcquireContext();
135 jsval rval = JSVAL_VOID;
136
137 jsval cKey = OOJSValueFromNativeObject(context, key);
138
139 OOJSScript *owner = [_owningScript retain]; // local copy needed
140 [OOJSScript pushScript:owner];
141
142 [engine callJSFunction:_callback
143 forObject:_callbackThis
144 argc:1
145 argv:&cKey
146 result:&rval];
147
148 [OOJSScript popScript:owner];
149 [owner release];
150
151 OOJSRelinquishContext(context);
152}
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
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 OOJSGuiScreenKeyDefinition.m.

105 :(jsval)callback
106{
107 JSContext *context = OOJSAcquireContext();
108 JS_RemoveValueRoot(context, &_callback);
110 OOJSAddGCValueRoot(context, &_callback, "OOJSGuiScreenKeyDefinition callback function");
111 OOJSRelinquishContext(context);
112}
#define OOJSAddGCValueRoot(context, root, name)

Referenced by GlobalSetExtraGuiScreenKeys().

+ Here is the caller graph for this function:

◆ setCallbackThis:

- (void) setCallbackThis: (JSObject *) callbackthis

Definition at line 1 of file OOJSGuiScreenKeyDefinition.m.

121 :(JSObject *)callbackThis
122{
123 JSContext *context = OOJSAcquireContext();
124 JS_RemoveObjectRoot(context, &_callbackThis);
126 OOJSAddGCObjectRoot(context, &_callbackThis, "OOJSGuiScreenKeyDefinition callback this");
127 OOJSRelinquishContext(context);
128}
#define OOJSAddGCObjectRoot(context, root, name)

Referenced by GlobalSetExtraGuiScreenKeys().

+ Here is the caller graph for this function:

◆ setName:

- (void) setName: (NSString *) name

Definition at line 1 of file OOJSGuiScreenKeyDefinition.m.

79 :(NSString *)name
80{
81 [_name autorelease];
82 _name = [name retain];
83}

Referenced by GlobalSetExtraGuiScreenKeys().

+ Here is the caller graph for this function:

◆ setRegisterKeys:

- (void) setRegisterKeys: (NSDictionary *) registerKeys

Definition at line 1 of file OOJSGuiScreenKeyDefinition.m.

92 :(NSDictionary *)registerKeys
93{
94 [_registerKeys release];
95 _registerKeys = [registerKeys copy];
96}

Referenced by GlobalSetExtraGuiScreenKeys().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _callback

- (jsval) _callback
private

Definition at line 32 of file OOJSGuiScreenKeyDefinition.h.

Referenced by callback.

◆ _callbackThis

- (JSObject*) _callbackThis
private

Definition at line 33 of file OOJSGuiScreenKeyDefinition.h.

Referenced by callback.

◆ _name

- (NSString*) _name
private

Definition at line 36 of file OOJSGuiScreenKeyDefinition.h.

◆ _owningScript

- (OOJSScript*) _owningScript
private

Definition at line 34 of file OOJSGuiScreenKeyDefinition.h.

Referenced by callback.

◆ _registerKeys

- (NSDictionary*) _registerKeys
private

Definition at line 37 of file OOJSGuiScreenKeyDefinition.h.


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