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

#include <OOJSInterfaceDefinition.h>

+ Inheritance diagram for OOJSInterfaceDefinition:
+ Collaboration diagram for OOJSInterfaceDefinition:

Instance Methods

(NSString *) - title
 
(void) - setTitle:
 
(NSString *) - category
 
(void) - setCategory:
 
(NSString *) - summary
 
(void) - setSummary:
 
(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 * _title
 
NSString * _summary
 
NSString * _category
 

Additional Inherited Members

- Protected Attributes inherited from OOWeakRefObject
OOWeakReferenceweakSelf
 

Detailed Description

Definition at line 29 of file OOJSInterfaceDefinition.h.

Method Documentation

◆ callback

- (jsval) callback

Definition at line 1 of file OOJSInterfaceDefinition.m.

113{
114 return _callback;
115}

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

129{
130 return _callbackThis;
131}

◆ category

- (NSString *) category

Definition at line 1 of file OOJSInterfaceDefinition.m.

87{
88 return _category;
89}

◆ dealloc

- (void) dealloc
implementation

Reimplemented from OOWeakRefObject.

Definition at line 1 of file OOJSInterfaceDefinition.m.

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

◆ deleteJSPointers

- (void) deleteJSPointers
implementation

Definition at line 1 of file OOJSInterfaceDefinition.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 OOJSInterfaceDefinition.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: (OOJSInterfaceDefinition *) other

Definition at line 1 of file OOJSInterfaceDefinition.m.

169{
170 NSComparisonResult byCategory = [_category caseInsensitiveCompare:[other category]];
171 if (byCategory == NSOrderedSame)
172 {
173 return [_title caseInsensitiveCompare:[other title]];
174 }
175 else
176 {
177 return byCategory;
178 }
179}

◆ runCallback:

- (void) runCallback: (NSString *) key

Definition at line 1 of file OOJSInterfaceDefinition.m.

144 :(NSString *)key
145{
147 JSContext *context = OOJSAcquireContext();
148 jsval rval = JSVAL_VOID;
149
150 jsval cKey = OOJSValueFromNativeObject(context, key);
151
152 OOJSScript *owner = [_owningScript retain]; // local copy needed
153 [OOJSScript pushScript:owner];
154
155 [engine callJSFunction:_callback
156 forObject:_callbackThis
157 argc:1
158 argv:&cKey
159 result:&rval];
160
161 [OOJSScript popScript:owner];
162 [owner release];
163
164 OOJSRelinquishContext(context);
165}
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 OOJSInterfaceDefinition.m.

118 :(jsval)callback
119{
120 JSContext *context = OOJSAcquireContext();
121 JS_RemoveValueRoot(context, &_callback);
123 OOJSAddGCValueRoot(context, &_callback, "OOJSInterfaceDefinition callback function");
124 OOJSRelinquishContext(context);
125}
#define OOJSAddGCValueRoot(context, root, name)

Referenced by StationSetInterface().

+ Here is the caller graph for this function:

◆ setCallbackThis:

- (void) setCallbackThis: (JSObject *) callbackthis

Definition at line 1 of file OOJSInterfaceDefinition.m.

134 :(JSObject *)callbackThis
135{
136 JSContext *context = OOJSAcquireContext();
137 JS_RemoveObjectRoot(context, &_callbackThis);
139 OOJSAddGCObjectRoot(context, &_callbackThis, "OOJSInterfaceDefinition callback this");
140 OOJSRelinquishContext(context);
141}
#define OOJSAddGCObjectRoot(context, root, name)

Referenced by StationSetInterface().

+ Here is the caller graph for this function:

◆ setCategory:

- (void) setCategory: (NSString *) category

Definition at line 1 of file OOJSInterfaceDefinition.m.

92 :(NSString *)category
93{
94 [_category autorelease];
95 _category = [category retain];
96}

Referenced by StationSetInterface().

+ Here is the caller graph for this function:

◆ setSummary:

- (void) setSummary: (NSString *) summary

Definition at line 1 of file OOJSInterfaceDefinition.m.

105 :(NSString *)summary
106{
107 [_summary autorelease];
108 _summary = [summary retain];
109}

Referenced by StationSetInterface().

+ Here is the caller graph for this function:

◆ setTitle:

- (void) setTitle: (NSString *) title

Definition at line 1 of file OOJSInterfaceDefinition.m.

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

Referenced by StationSetInterface().

+ Here is the caller graph for this function:

◆ summary

- (NSString *) summary

Definition at line 1 of file OOJSInterfaceDefinition.m.

100{
101 return _summary;
102}

◆ title

- (NSString *) title

Definition at line 1 of file OOJSInterfaceDefinition.m.

74{
75 return _title;
76}

Member Data Documentation

◆ _callback

- (jsval) _callback
private

Definition at line 32 of file OOJSInterfaceDefinition.h.

Referenced by callback.

◆ _callbackThis

- (JSObject*) _callbackThis
private

Definition at line 33 of file OOJSInterfaceDefinition.h.

Referenced by callback.

◆ _category

- (NSString*) _category
private

Definition at line 38 of file OOJSInterfaceDefinition.h.

◆ _owningScript

- (OOJSScript*) _owningScript
private

Definition at line 34 of file OOJSInterfaceDefinition.h.

Referenced by callback.

◆ _summary

- (NSString*) _summary
private

Definition at line 37 of file OOJSInterfaceDefinition.h.

◆ _title

- (NSString*) _title
private

Definition at line 36 of file OOJSInterfaceDefinition.h.


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