Oolite
Loading...
Searching...
No Matches
Entity(OOJavaScriptExtensions) Category Reference

#include <EntityOOJavaScriptExtensions.h>

Instance Methods

(BOOL) - isVisibleToScripts
(NSString *) - oo_jsClassName
(void) - getJSClass:andPrototype:
(void) - deleteJSSelf
(BOOL) - isVisibleToScripts
(NSString *) - oo_jsClassName
(JSClassID) - oo_jsClassID
(void) - deleteJSSelf
(jsval) - oo_jsValueInContext: [implementation]

Detailed Description

Definition at line 32 of file EntityOOJavaScriptExtensions.h.

Method Documentation

◆ deleteJSSelf [1/2]

- (void) deleteJSSelf

Extends class Entity.

Definition at line 78 of file EntityOOJavaScriptExtensions.m.

79{
80 if (JS_IsObject(_jsSelf)) {
81 /* Scripts may still hold the JS object. Its private data is a weak
82 reference, so it becomes stale (isValid false) when the entity is
83 deallocated.
84 */
85 JS_FreeValue(OOJSAcquireContext(), _jsSelf);
86 _jsSelf = JS_UNDEFINED;
87
88 [[NSNotificationCenter defaultCenter] removeObserver:self
89 name:kOOJavaScriptEngineWillResetNotification
91 }
92}
OOINLINE JSContext * OOJSAcquireContext(void)
OOJavaScriptEngine * sharedEngine()

References deleteJSSelf, OOJSAcquireContext(), and OOJavaScriptEngine::sharedEngine.

Referenced by deleteJSSelf.

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

◆ deleteJSSelf [2/2]

- (void) deleteJSSelf

Extends class Entity.

References deleteJSSelf.

Here is the call graph for this function:

◆ getJSClass:andPrototype:

- (void) getJSClass: (JSClass**) outClass
andPrototype: (JSObject**) outPrototype 

Extends class Entity.

Definition at line 81 of file EntityOOJavaScriptExtensions.m.

81 :(JSClass**)outClass andPrototype:(JSObject**)outPrototype
82{
83 *outClass = JSEntityClass();
84 *outPrototype = JSEntityPrototype();
85}
OOINLINE JSClass * JSEntityClass(void)
Definition OOJSEntity.h:42
OOINLINE JSObject * JSEntityPrototype(void)
Definition OOJSEntity.h:43

References JSEntityClass(), and JSEntityPrototype().

Here is the call graph for this function:

◆ isVisibleToScripts [1/2]

- (BOOL) isVisibleToScripts

Extends class Entity.

Definition at line 38 of file EntityOOJavaScriptExtensions.m.

39{
40 return NO;
41}

References isVisibleToScripts.

Referenced by isVisibleToScripts, and oo_jsValueInContext:.

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

◆ isVisibleToScripts [2/2]

- (BOOL) isVisibleToScripts

Extends class Entity.

References isVisibleToScripts.

Here is the call graph for this function:

◆ oo_jsClassID

- (JSClassID) oo_jsClassID

Extends class Entity.

Definition at line 73 of file EntityOOJavaScriptExtensions.m.

74{
75 return JSEntityClassID();
76}
JSClassID JSEntityClassID(void)
Definition OOJSEntity.m:115

References JSEntityClassID(), and oo_jsClassID.

Referenced by oo_jsClassID, and oo_jsClassName.

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

◆ oo_jsClassName [1/2]

- (NSString *) oo_jsClassName

Extends class Entity.

Definition at line 43 of file EntityOOJavaScriptExtensions.m.

44{
45 return @"Entity";
46}

References oo_jsClassName.

Referenced by oo_jsClassName.

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

◆ oo_jsClassName [2/2]

- (NSString *) oo_jsClassName

Extends class Entity.

References oo_jsClassID, and oo_jsClassName.

Here is the call graph for this function:

◆ oo_jsValueInContext:

- (JSValue) oo_jsValueInContext: (JSContext*) context
implementation

Extends class Entity.

Definition at line 49 of file EntityOOJavaScriptExtensions.m.

49 :(JSContext*)context
50{
51 JSClass* class = NULL;
52 JSObject* prototype = NULL;
53 jsval result = JSVAL_NULL;
54
55 if (_jsSelf == NULL && [self isVisibleToScripts]) {
56 // Create JS object
57 [self getJSClass:&class andPrototype:&prototype];
58
59 _jsSelf = JS_NewObject(context, class, prototype, NULL);
60 if (_jsSelf != NULL) {
61 if (!JS_SetPrivate(context, _jsSelf, OOConsumeReference([self weakRetain])))
62 _jsSelf = NULL;
63 }
64
65 if (_jsSelf != NULL) {
66 OOJSAddGCObjectRoot(context, &_jsSelf, "Entity jsSelf");
67 [[NSNotificationCenter defaultCenter] addObserver:self
68 selector:@selector(deleteJSSelf)
69 name:kOOJavaScriptEngineWillResetNotification
71 }
72 }
73
74 if (_jsSelf != NULL)
75 result = OBJECT_TO_JSVAL(_jsSelf);
76
77 return result;
78 // Analyzer: object leaked. [Expected, object is retained by JS object.]
79}
id OOConsumeReference(id OO_NS_CONSUMED value)
#define OOJSAddGCObjectRoot(context, root, name)

References Entity::getJSClass:andPrototype:, isVisibleToScripts, OOConsumeReference(), OOJSAddGCObjectRoot, and OOJavaScriptEngine::sharedEngine.

Here is the call graph for this function:

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