Oolite 1.91.0.7668-250429-8542c40
All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
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 112 of file OOJSInterfaceDefinition.m.

113{
114 return _callback;
115}

References _callback, and callback.

Referenced by callback, and setCallback:.

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

◆ callbackThis

- (JSObject *) callbackThis

Definition at line 128 of file OOJSInterfaceDefinition.m.

129{
130 return _callbackThis;
131}

References _callbackThis, and callbackThis.

Referenced by callbackThis, and setCallbackThis:.

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

◆ category

- (NSString *) category

Definition at line 86 of file OOJSInterfaceDefinition.m.

87{
88 return _category;
89}

References _category, and category.

Referenced by category, interfaceCompare:, and PlayerEntity::setGuiToInterfacesScreen:.

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

◆ dealloc

- (void) dealloc
implementation

Reimplemented from OOWeakRefObject.

Definition at line 64 of file OOJSInterfaceDefinition.m.

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

References dealloc, OOWeakRefObject::dealloc, and deleteJSPointers.

Referenced by dealloc.

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

◆ deleteJSPointers

- (void) deleteJSPointers
implementation

Definition at line 47 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()

References _callback, _callbackThis, deleteJSPointers, OOJSAcquireContext(), OOJSRelinquishContext(), and OOJavaScriptEngine::sharedEngine.

Referenced by dealloc, and deleteJSPointers.

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

◆ init

- (id) init
implementation

Definition at line 32 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

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

Referenced by init.

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

◆ interfaceCompare:

- (NSComparisonResult) interfaceCompare: (OOJSInterfaceDefinition *) other

Definition at line 168 of file OOJSInterfaceDefinition.m.

168 :(OOJSInterfaceDefinition *)other
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}

References category, and title.

+ Here is the call graph for this function:

◆ runCallback:

- (void) runCallback: (NSString *) key

Definition at line 144 of file OOJSInterfaceDefinition.m.

144 :(NSString *)key
145{
146 OOJavaScriptEngine *engine = [OOJavaScriptEngine sharedEngine];
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)

References OOJavaScriptEngine::callJSFunction:forObject:argc:argv:result:, OOJSAcquireContext(), OOJSRelinquishContext(), OOJSValueFromNativeObject(), OOJSScript::popScript:, OOJSScript::pushScript:, and OOJavaScriptEngine::sharedEngine.

Referenced by PlayerEntity::activateSelectedInterface.

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

◆ setCallback:

- (void) setCallback: (jsval) callback

Definition at line 118 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)

References _callback, callback, OOJSAcquireContext(), OOJSAddGCValueRoot, and OOJSRelinquishContext().

Referenced by StationSetInterface().

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

◆ setCallbackThis:

- (void) setCallbackThis: (JSObject *) callbackthis

Definition at line 134 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)

References _callbackThis, callbackThis, OOJSAcquireContext(), OOJSAddGCObjectRoot, and OOJSRelinquishContext().

Referenced by StationSetInterface().

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

◆ setCategory:

- (void) setCategory: (NSString *) category

Definition at line 92 of file OOJSInterfaceDefinition.m.

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

References _category.

Referenced by StationSetInterface().

+ Here is the caller graph for this function:

◆ setSummary:

- (void) setSummary: (NSString *) summary

Definition at line 105 of file OOJSInterfaceDefinition.m.

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

References _summary.

Referenced by StationSetInterface().

+ Here is the caller graph for this function:

◆ setTitle:

- (void) setTitle: (NSString *) title

Definition at line 79 of file OOJSInterfaceDefinition.m.

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

References _title.

Referenced by StationSetInterface().

+ Here is the caller graph for this function:

◆ summary

- (NSString *) summary

Definition at line 99 of file OOJSInterfaceDefinition.m.

100{
101 return _summary;
102}

References _summary, and summary.

Referenced by PlayerEntity::showInformationForSelectedInterface, and summary.

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

◆ title

- (NSString *) title

Definition at line 73 of file OOJSInterfaceDefinition.m.

74{
75 return _title;
76}

References _title, and title.

Referenced by interfaceCompare:, PlayerEntity::setGuiToInterfacesScreen:, and title.

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

Member Data Documentation

◆ _callback

- (jsval) _callback
private

Definition at line 32 of file OOJSInterfaceDefinition.h.

Referenced by callback, deleteJSPointers, init, and setCallback:.

◆ _callbackThis

- (JSObject*) _callbackThis
private

Definition at line 33 of file OOJSInterfaceDefinition.h.

Referenced by callbackThis, deleteJSPointers, init, and setCallbackThis:.

◆ _category

- (NSString*) _category
private

Definition at line 38 of file OOJSInterfaceDefinition.h.

Referenced by category, and setCategory:.

◆ _owningScript

- (OOJSScript*) _owningScript
private

Definition at line 34 of file OOJSInterfaceDefinition.h.

Referenced by init.

◆ _summary

- (NSString*) _summary
private

Definition at line 37 of file OOJSInterfaceDefinition.h.

Referenced by setSummary:, and summary.

◆ _title

- (NSString*) _title
private

Definition at line 36 of file OOJSInterfaceDefinition.h.

Referenced by setTitle:, and title.


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