Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
Entity(OOJavaScriptExtensions) Category Reference

#include <EntityOOJavaScriptExtensions.h>

Instance Methods

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

Detailed Description

Definition at line 32 of file EntityOOJavaScriptExtensions.h.

Method Documentation

◆ deleteJSSelf

- (void) deleteJSSelf

Extends class Entity.

Definition at line 1 of file EntityOOJavaScriptExtensions.m.

96{
97 if (_jsSelf != NULL)
98 {
99 _jsSelf = NULL;
100 JSContext *context = OOJSAcquireContext();
101 JS_RemoveObjectRoot(context, &_jsSelf);
102 OOJSRelinquishContext(context);
103
104 [[NSNotificationCenter defaultCenter] removeObserver:self
105 name:kOOJavaScriptEngineWillResetNotification
107 }
108}
OOINLINE JSContext * OOJSAcquireContext(void)
OOINLINE void OOJSRelinquishContext(JSContext *context)
OOJavaScriptEngine * sharedEngine()

◆ getJSClass:andPrototype:

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

Extends class Entity.

Definition at line 1 of file EntityOOJavaScriptExtensions.m.

88 :(JSClass **)outClass andPrototype:(JSObject **)outPrototype
89{
90 *outClass = JSEntityClass();
91 *outPrototype = JSEntityPrototype();
92}
OOINLINE JSClass * JSEntityClass(void)
Definition OOJSEntity.h:42
OOINLINE JSObject * JSEntityPrototype(void)
Definition OOJSEntity.h:43

◆ isVisibleToScripts

- (BOOL) isVisibleToScripts

Extends class Entity.

Definition at line 1 of file EntityOOJavaScriptExtensions.m.

43{
44 return NO;
45}

◆ oo_jsClassName

- (NSString *) oo_jsClassName

Extends class Entity.

Definition at line 1 of file EntityOOJavaScriptExtensions.m.

49{
50 return @"Entity";
51}

◆ oo_jsValueInContext:

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

Extends class Entity.

Definition at line 1 of file EntityOOJavaScriptExtensions.m.

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

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