37@implementation Entity (OOJavaScriptExtensions)
49- (jsval)oo_jsValueInContext:(JSContext*)context
51 JSClass*
class = NULL;
52 JSObject* prototype = NULL;
53 jsval result = JSVAL_NULL;
59 _jsSelf = JS_NewObject(context,
class, prototype, NULL);
60 if (_jsSelf != NULL) {
65 if (_jsSelf != NULL) {
68 selector:@selector(deleteJSSelf)
69 name:kOOJavaScriptEngineWillResetNotification
75 result = OBJECT_TO_JSVAL(_jsSelf);
81- (void)getJSClass:(JSClass**)outClass andPrototype:(JSObject**)outPrototype
89 if (_jsSelf != NULL) {
92 JS_RemoveObjectRoot(context, &_jsSelf);
95 [[NSNotificationCenter defaultCenter] removeObserver:
self
96 name:kOOJavaScriptEngineWillResetNotification
103@implementation ShipEntity (OOJavaScriptExtensions)
110- (void)getJSClass:(JSClass**)outClass andPrototype:(JSObject**)outPrototype
121- (NSArray*)subEntitiesForScript
123 return [[
self shipSubEntityEnumerator] allObjects];
126- (void)setTargetForScript:(ShipEntity*)target
128 ShipEntity* me =
self;
131 while ([me isSubEntity]) {
132 if (me == [me owner] || [me owner] ==
nil)
134 me = (ShipEntity*)[me owner];
136 while ([target isSubEntity]) {
137 if (target == [target owner] || [target owner] ==
nil)
139 target = (ShipEntity*)[target owner];
141 if (![me isKindOfClass:[ShipEntity
class]])
id OOConsumeReference(id OO_NS_CONSUMED value)
OOINLINE JSClass * JSEntityClass(void)
OOINLINE JSObject * JSEntityPrototype(void)
JSObject * JSShipPrototype(void)
JSClass * JSShipClass(void)
OOINLINE JSContext * OOJSAcquireContext(void)
#define OOJSAddGCObjectRoot(context, root, name)
OOINLINE void OOJSRelinquishContext(JSContext *context)
BOOL isVisibleToScripts()
NSString * oo_jsClassName()
NSString * oo_jsClassName()
BOOL isVisibleToScripts()
void getJSClass:andPrototype:(JSClass **outClass,[andPrototype] JSObject **outPrototype)
OOJavaScriptEngine * sharedEngine()
void addTarget:(Entity *targetEntity)
void removeTarget:(Entity *targetEntity)