Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OOJSValue Class Reference

#include <OOJavaScriptEngine.h>

+ Inheritance diagram for OOJSValue:
+ Collaboration diagram for OOJSValue:

Instance Methods

(id) - initWithJSValue:inContext:
 
(id) - initWithJSObject:inContext:
 
(void) - deleteJSValue [implementation]
 
(void) - dealloc [implementation]
 
(jsval) - oo_jsValueInContext: [implementation]
 

Class Methods

(id) + valueWithJSValue:inContext:
 
(id) + valueWithJSObject:inContext:
 

Protected Attributes

jsval _val
 

Detailed Description

Definition at line 262 of file OOJavaScriptEngine.h.

Method Documentation

◆ dealloc

- (void) dealloc
implementation

Definition at line 622 of file OOJavaScriptEngine.m.

1529{
1530 [self deleteJSValue];
1531 [super dealloc];
1532}

◆ deleteJSValue

- (void) deleteJSValue
implementation

Definition at line 622 of file OOJavaScriptEngine.m.

1513{
1514 if (!JSVAL_IS_VOID(_val))
1515 {
1516 JSContext *context = OOJSAcquireContext();
1517 JS_RemoveValueRoot(context, &_val);
1518 OOJSRelinquishContext(context);
1519
1520 _val = JSVAL_VOID;
1521 [[NSNotificationCenter defaultCenter] removeObserver:self
1522 name:kOOJavaScriptEngineWillResetNotification
1524 }
1525}
OOINLINE JSContext * OOJSAcquireContext(void)
OOINLINE void OOJSRelinquishContext(JSContext *context)
OOJavaScriptEngine * sharedEngine()

◆ initWithJSObject:inContext:

- (id) initWithJSObject: (JSObject *) object
inContext: (JSContext *) context 

Definition at line 622 of file OOJavaScriptEngine.m.

1506 :(JSObject *)object inContext:(JSContext *)context
1507{
1508 return [self initWithJSValue:OBJECT_TO_JSVAL(object) inContext:context];
1509}

◆ initWithJSValue:inContext:

- (id) initWithJSValue: (jsval) value
inContext: (JSContext *) context 

Definition at line 622 of file OOJavaScriptEngine.m.

1473 :(jsval)value inContext:(JSContext *)context
1474{
1476
1477 self = [super init];
1478 if (self != nil)
1479 {
1480 BOOL tempCtxt = NO;
1481 if (context == NULL)
1482 {
1483 context = OOJSAcquireContext();
1484 tempCtxt = YES;
1485 }
1486
1487 _val = value;
1488 if (!JSVAL_IS_VOID(_val))
1489 {
1490 JS_AddNamedValueRoot(context, &_val, "OOJSValue");
1491
1492 [[NSNotificationCenter defaultCenter] addObserver:self
1493 selector:@selector(deleteJSValue)
1494 name:kOOJavaScriptEngineWillResetNotification
1496 }
1497
1498 if (tempCtxt) OOJSRelinquishContext(context);
1499 }
1500 return self;
1501
1503}
#define OOJS_PROFILE_EXIT
#define OOJS_PROFILE_ENTER
return nil

◆ oo_jsValueInContext:

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

Definition at line 622 of file OOJavaScriptEngine.m.

1535 :(JSContext *)context
1536{
1537 return _val;
1538}

◆ valueWithJSObject:inContext:

+ (id) valueWithJSObject: (JSObject *) object
inContext: (JSContext *) context 

Definition at line 622 of file OOJavaScriptEngine.m.

1463 :(JSObject *)object inContext:(JSContext *)context
1464{
1466
1467 return [[[self alloc] initWithJSObject:object inContext:context] autorelease];
1468
1470}

Referenced by JSSpecialFunctionsObjectWrapper().

+ Here is the caller graph for this function:

◆ valueWithJSValue:inContext:

+ (id) valueWithJSValue: (jsval) value
inContext: (JSContext *) context 

Definition at line 622 of file OOJavaScriptEngine.m.

1453 :(jsval)value inContext:(JSContext *)context
1454{
1456
1457 return [[[self alloc] initWithJSValue:value inContext:context] autorelease];
1458
1460}

Member Data Documentation

◆ _val

- (jsval) _val
protected

Definition at line 264 of file OOJavaScriptEngine.h.


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