Modified: trunk/Source/_javascript_Core/API/JSValue.mm (144667 => 144668)
--- trunk/Source/_javascript_Core/API/JSValue.mm 2013-03-04 21:44:07 UTC (rev 144667)
+++ trunk/Source/_javascript_Core/API/JSValue.mm 2013-03-04 21:47:29 UTC (rev 144668)
@@ -69,62 +69,62 @@
+ (JSValue *)valueWithBool:(BOOL)value inContext:(JSContext *)context
{
- return [JSValue valueWithValue:JSValueMakeBoolean(contextInternalContext(context), value) inContext:context];
+ return [JSValue valueWithValue:JSValueMakeBoolean([context globalContextRef], value) inContext:context];
}
+ (JSValue *)valueWithDouble:(double)value inContext:(JSContext *)context
{
- return [JSValue valueWithValue:JSValueMakeNumber(contextInternalContext(context), value) inContext:context];
+ return [JSValue valueWithValue:JSValueMakeNumber([context globalContextRef], value) inContext:context];
}
+ (JSValue *)valueWithInt32:(int32_t)value inContext:(JSContext *)context
{
- return [JSValue valueWithValue:JSValueMakeNumber(contextInternalContext(context), value) inContext:context];
+ return [JSValue valueWithValue:JSValueMakeNumber([context globalContextRef], value) inContext:context];
}
+ (JSValue *)valueWithUInt32:(uint32_t)value inContext:(JSContext *)context
{
- return [JSValue valueWithValue:JSValueMakeNumber(contextInternalContext(context), value) inContext:context];
+ return [JSValue valueWithValue:JSValueMakeNumber([context globalContextRef], value) inContext:context];
}
+ (JSValue *)valueWithNewObjectInContext:(JSContext *)context
{
- return [JSValue valueWithValue:JSObjectMake(contextInternalContext(context), 0, 0) inContext:context];
+ return [JSValue valueWithValue:JSObjectMake([context globalContextRef], 0, 0) inContext:context];
}
+ (JSValue *)valueWithNewArrayInContext:(JSContext *)context
{
- return [JSValue valueWithValue:JSObjectMakeArray(contextInternalContext(context), 0, NULL, 0) inContext:context];
+ return [JSValue valueWithValue:JSObjectMakeArray([context globalContextRef], 0, NULL, 0) inContext:context];
}
+ (JSValue *)valueWithNewRegularExpressionFromPattern:(NSString *)pattern flags:(NSString *)flags inContext:(JSContext *)context
{
JSStringRef patternString = JSStringCreateWithCFString((CFStringRef)pattern);
JSStringRef flagsString = JSStringCreateWithCFString((CFStringRef)flags);
- JSValueRef arguments[2] = { JSValueMakeString(contextInternalContext(context), patternString), JSValueMakeString(contextInternalContext(context), flagsString) };
+ JSValueRef arguments[2] = { JSValueMakeString([context globalContextRef], patternString), JSValueMakeString([context globalContextRef], flagsString) };
JSStringRelease(patternString);
JSStringRelease(flagsString);
- return [JSValue valueWithValue:JSObjectMakeRegExp(contextInternalContext(context), 2, arguments, 0) inContext:context];
+ return [JSValue valueWithValue:JSObjectMakeRegExp([context globalContextRef], 2, arguments, 0) inContext:context];
}
+ (JSValue *)valueWithNewErrorFromMessage:(NSString *)message inContext:(JSContext *)context
{
JSStringRef string = JSStringCreateWithCFString((CFStringRef)message);
- JSValueRef argument = JSValueMakeString(contextInternalContext(context), string);
+ JSValueRef argument = JSValueMakeString([context globalContextRef], string);
JSStringRelease(string);
- return [JSValue valueWithValue:JSObjectMakeError(contextInternalContext(context), 1, &argument, 0) inContext:context];
+ return [JSValue valueWithValue:JSObjectMakeError([context globalContextRef], 1, &argument, 0) inContext:context];
}
+ (JSValue *)valueWithNullInContext:(JSContext *)context
{
- return [JSValue valueWithValue:JSValueMakeNull(contextInternalContext(context)) inContext:context];
+ return [JSValue valueWithValue:JSValueMakeNull([context globalContextRef]) inContext:context];
}
+ (JSValue *)valueWithUndefinedInContext:(JSContext *)context
{
- return [JSValue valueWithValue:JSValueMakeUndefined(contextInternalContext(context)) inContext:context];
+ return [JSValue valueWithValue:JSValueMakeUndefined([context globalContextRef]) inContext:context];
}
- (id)toObject
@@ -140,13 +140,13 @@
- (BOOL)toBool
{
- return JSValueToBoolean(contextInternalContext(_context), m_value);
+ return JSValueToBoolean([_context globalContextRef], m_value);
}
- (double)toDouble
{
JSValueRef exception = 0;
- double result = JSValueToNumber(contextInternalContext(_context), m_value, &exception);
+ double result = JSValueToNumber([_context globalContextRef], m_value, &exception);
if (exception) {
[_context notifyException:exception];
return std::numeric_limits<double>::quiet_NaN();
@@ -168,7 +168,7 @@
- (NSNumber *)toNumber
{
JSValueRef exception = 0;
- id result = valueToNumber(contextInternalContext(_context), m_value, &exception);
+ id result = valueToNumber([_context globalContextRef], m_value, &exception);
if (exception)
[_context notifyException:exception];
return result;
@@ -177,7 +177,7 @@
- (NSString *)toString
{
JSValueRef exception = 0;
- id result = valueToString(contextInternalContext(_context), m_value, &exception);
+ id result = valueToString([_context globalContextRef], m_value, &exception);
if (exception)
[_context notifyException:exception];
return result;
@@ -186,7 +186,7 @@
- (NSDate *)toDate
{
JSValueRef exception = 0;
- id result = valueToDate(contextInternalContext(_context), m_value, &exception);
+ id result = valueToDate([_context globalContextRef], m_value, &exception);
if (exception)
[_context notifyException:exception];
return result;
@@ -195,7 +195,7 @@
- (NSArray *)toArray
{
JSValueRef exception = 0;
- id result = valueToArray(contextInternalContext(_context), m_value, &exception);
+ id result = valueToArray([_context globalContextRef], m_value, &exception);
if (exception)
[_context notifyException:exception];
return result;
@@ -204,7 +204,7 @@
- (NSDictionary *)toDictionary
{
JSValueRef exception = 0;
- id result = valueToDictionary(contextInternalContext(_context), m_value, &exception);
+ id result = valueToDictionary([_context globalContextRef], m_value, &exception);
if (exception)
[_context notifyException:exception];
return result;
@@ -213,12 +213,12 @@
- (JSValue *)valueForProperty:(NSString *)propertyName
{
JSValueRef exception = 0;
- JSObjectRef object = JSValueToObject(contextInternalContext(_context), m_value, &exception);
+ JSObjectRef object = JSValueToObject([_context globalContextRef], m_value, &exception);
if (exception)
return [_context valueFromNotifyException:exception];
JSStringRef name = JSStringCreateWithCFString((CFStringRef)propertyName);
- JSValueRef result = JSObjectGetProperty(contextInternalContext(_context), object, name, &exception);
+ JSValueRef result = JSObjectGetProperty([_context globalContextRef], object, name, &exception);
JSStringRelease(name);
if (exception)
return [_context valueFromNotifyException:exception];
@@ -229,14 +229,14 @@
- (void)setValue:(id)value forProperty:(NSString *)propertyName
{
JSValueRef exception = 0;
- JSObjectRef object = JSValueToObject(contextInternalContext(_context), m_value, &exception);
+ JSObjectRef object = JSValueToObject([_context globalContextRef], m_value, &exception);
if (exception) {
[_context notifyException:exception];
return;
}
JSStringRef name = JSStringCreateWithCFString((CFStringRef)propertyName);
- JSObjectSetProperty(contextInternalContext(_context), object, name, objectToValue(_context, value), 0, &exception);
+ JSObjectSetProperty([_context globalContextRef], object, name, objectToValue(_context, value), 0, &exception);
JSStringRelease(name);
if (exception) {
[_context notifyException:exception];
@@ -247,12 +247,12 @@
- (BOOL)deleteProperty:(NSString *)propertyName
{
JSValueRef exception = 0;
- JSObjectRef object = JSValueToObject(contextInternalContext(_context), m_value, &exception);
+ JSObjectRef object = JSValueToObject([_context globalContextRef], m_value, &exception);
if (exception)
return [_context boolFromNotifyException:exception];
JSStringRef name = JSStringCreateWithCFString((CFStringRef)propertyName);
- BOOL result = JSObjectDeleteProperty(contextInternalContext(_context), object, name, &exception);
+ BOOL result = JSObjectDeleteProperty([_context globalContextRef], object, name, &exception);
JSStringRelease(name);
if (exception)
return [_context boolFromNotifyException:exception];
@@ -263,12 +263,12 @@
- (BOOL)hasProperty:(NSString *)propertyName
{
JSValueRef exception = 0;
- JSObjectRef object = JSValueToObject(contextInternalContext(_context), m_value, &exception);
+ JSObjectRef object = JSValueToObject([_context globalContextRef], m_value, &exception);
if (exception)
return [_context boolFromNotifyException:exception];
JSStringRef name = JSStringCreateWithCFString((CFStringRef)propertyName);
- BOOL result = JSObjectHasProperty(contextInternalContext(_context), object, name);
+ BOOL result = JSObjectHasProperty([_context globalContextRef], object, name);
JSStringRelease(name);
return result;
}
@@ -286,11 +286,11 @@
return [self valueForProperty:[[JSValue valueWithDouble:index inContext:_context] toString]];
JSValueRef exception = 0;
- JSObjectRef object = JSValueToObject(contextInternalContext(_context), m_value, &exception);
+ JSObjectRef object = JSValueToObject([_context globalContextRef], m_value, &exception);
if (exception)
return [_context valueFromNotifyException:exception];
- JSValueRef result = JSObjectGetPropertyAtIndex(contextInternalContext(_context), object, (unsigned)index, &exception);
+ JSValueRef result = JSObjectGetPropertyAtIndex([_context globalContextRef], object, (unsigned)index, &exception);
if (exception)
return [_context valueFromNotifyException:exception];
@@ -305,13 +305,13 @@
return [self setValue:value forProperty:[[JSValue valueWithDouble:index inContext:_context] toString]];
JSValueRef exception = 0;
- JSObjectRef object = JSValueToObject(contextInternalContext(_context), m_value, &exception);
+ JSObjectRef object = JSValueToObject([_context globalContextRef], m_value, &exception);
if (exception) {
[_context notifyException:exception];
return;
}
- JSObjectSetPropertyAtIndex(contextInternalContext(_context), object, (unsigned)index, objectToValue(_context, value), &exception);
+ JSObjectSetPropertyAtIndex([_context globalContextRef], object, (unsigned)index, objectToValue(_context, value), &exception);
if (exception) {
[_context notifyException:exception];
return;
@@ -320,43 +320,43 @@
- (BOOL)isUndefined
{
- return JSValueIsUndefined(contextInternalContext(_context), m_value);
+ return JSValueIsUndefined([_context globalContextRef], m_value);
}
- (BOOL)isNull
{
- return JSValueIsNull(contextInternalContext(_context), m_value);
+ return JSValueIsNull([_context globalContextRef], m_value);
}
- (BOOL)isBoolean
{
- return JSValueIsBoolean(contextInternalContext(_context), m_value);
+ return JSValueIsBoolean([_context globalContextRef], m_value);
}
- (BOOL)isNumber
{
- return JSValueIsNumber(contextInternalContext(_context), m_value);
+ return JSValueIsNumber([_context globalContextRef], m_value);
}
- (BOOL)isString
{
- return JSValueIsString(contextInternalContext(_context), m_value);
+ return JSValueIsString([_context globalContextRef], m_value);
}
- (BOOL)isObject
{
- return JSValueIsObject(contextInternalContext(_context), m_value);
+ return JSValueIsObject([_context globalContextRef], m_value);
}
- (BOOL)isEqualToObject:(id)value
{
- return JSValueIsStrictEqual(contextInternalContext(_context), m_value, objectToValue(_context, value));
+ return JSValueIsStrictEqual([_context globalContextRef], m_value, objectToValue(_context, value));
}
- (BOOL)isEqualWithTypeCoercionToObject:(id)value
{
JSValueRef exception = 0;
- BOOL result = JSValueIsEqual(contextInternalContext(_context), m_value, objectToValue(_context, value), &exception);
+ BOOL result = JSValueIsEqual([_context globalContextRef], m_value, objectToValue(_context, value), &exception);
if (exception)
return [_context boolFromNotifyException:exception];
@@ -366,11 +366,11 @@
- (BOOL)isInstanceOf:(id)value
{
JSValueRef exception = 0;
- JSObjectRef constructor = JSValueToObject(contextInternalContext(_context), objectToValue(_context, value), &exception);
+ JSObjectRef constructor = JSValueToObject([_context globalContextRef], objectToValue(_context, value), &exception);
if (exception)
return [_context boolFromNotifyException:exception];
- BOOL result = JSValueIsInstanceOfConstructor(contextInternalContext(_context), m_value, constructor, &exception);
+ BOOL result = JSValueIsInstanceOfConstructor([_context globalContextRef], m_value, constructor, &exception);
if (exception)
return [_context boolFromNotifyException:exception];
@@ -385,11 +385,11 @@
arguments[i] = objectToValue(_context, [argumentArray objectAtIndex:i]);
JSValueRef exception = 0;
- JSObjectRef object = JSValueToObject(contextInternalContext(_context), m_value, &exception);
+ JSObjectRef object = JSValueToObject([_context globalContextRef], m_value, &exception);
if (exception)
return [_context valueFromNotifyException:exception];
- JSValueRef result = JSObjectCallAsFunction(contextInternalContext(_context), object, 0, argumentCount, arguments, &exception);
+ JSValueRef result = JSObjectCallAsFunction([_context globalContextRef], object, 0, argumentCount, arguments, &exception);
if (exception)
return [_context valueFromNotifyException:exception];
@@ -404,11 +404,11 @@
arguments[i] = objectToValue(_context, [argumentArray objectAtIndex:i]);
JSValueRef exception = 0;
- JSObjectRef object = JSValueToObject(contextInternalContext(_context), m_value, &exception);
+ JSObjectRef object = JSValueToObject([_context globalContextRef], m_value, &exception);
if (exception)
return [_context valueFromNotifyException:exception];
- JSObjectRef result = JSObjectCallAsConstructor(contextInternalContext(_context), object, argumentCount, arguments, &exception);
+ JSObjectRef result = JSObjectCallAsConstructor([_context globalContextRef], object, argumentCount, arguments, &exception);
if (exception)
return [_context valueFromNotifyException:exception];
@@ -423,21 +423,21 @@
argumentArray[i] = objectToValue(_context, [arguments objectAtIndex:i]);
JSValueRef exception = 0;
- JSObjectRef thisObject = JSValueToObject(contextInternalContext(_context), m_value, &exception);
+ JSObjectRef thisObject = JSValueToObject([_context globalContextRef], m_value, &exception);
if (exception)
return [_context valueFromNotifyException:exception];
JSStringRef name = JSStringCreateWithCFString((CFStringRef)method);
- JSValueRef function = JSObjectGetProperty(contextInternalContext(_context), thisObject, name, &exception);
+ JSValueRef function = JSObjectGetProperty([_context globalContextRef], thisObject, name, &exception);
JSStringRelease(name);
if (exception)
return [_context valueFromNotifyException:exception];
- JSObjectRef object = JSValueToObject(contextInternalContext(_context), function, &exception);
+ JSObjectRef object = JSValueToObject([_context globalContextRef], function, &exception);
if (exception)
return [_context valueFromNotifyException:exception];
- JSValueRef result = JSObjectCallAsFunction(contextInternalContext(_context), object, thisObject, argumentCount, argumentArray, &exception);
+ JSValueRef result = JSObjectCallAsFunction([_context globalContextRef], object, thisObject, argumentCount, argumentArray, &exception);
if (exception)
return [_context valueFromNotifyException:exception];
@@ -710,10 +710,10 @@
id valueToObject(JSContext *context, JSValueRef value)
{
- JSContainerConvertor::Task result = valueToObjectWithoutCopy(contextInternalContext(context), value);
+ JSContainerConvertor::Task result = valueToObjectWithoutCopy([context globalContextRef], value);
if (result.type == ContainerNone)
return result.objc;
- return containerValueToObject(contextInternalContext(context), result);
+ return containerValueToObject([context globalContextRef], result);
}
id valueToNumber(JSGlobalContextRef context, JSValueRef value, JSValueRef* exception)
@@ -856,7 +856,7 @@
static ObjcContainerConvertor::Task objectToValueWithoutCopy(JSContext *context, id object)
{
- JSGlobalContextRef contextRef = contextInternalContext(context);
+ JSGlobalContextRef contextRef = [context globalContextRef];
if (!object)
return (ObjcContainerConvertor::Task){ object, JSValueMakeUndefined(contextRef), ContainerNone };
@@ -899,7 +899,7 @@
JSValueRef objectToValue(JSContext *context, id object)
{
- JSGlobalContextRef contextRef = contextInternalContext(context);
+ JSGlobalContextRef contextRef = [context globalContextRef];
ObjcContainerConvertor::Task task = objectToValueWithoutCopy(context, object);
if (task.type == ContainerNone)
@@ -957,7 +957,7 @@
ASSERT(value);
_context = [context retain];
m_value = value;
- JSValueProtect(contextInternalContext(_context), m_value);
+ JSValueProtect([_context globalContextRef], m_value);
return self;
}
@@ -1075,7 +1075,7 @@
- (void)dealloc
{
- JSValueUnprotect(contextInternalContext(_context), m_value);
+ JSValueUnprotect([_context globalContextRef], m_value);
[_context release];
_context = nil;
[super dealloc];
@@ -1083,7 +1083,7 @@
- (NSString *)description
{
- if (id wrapped = tryUnwrapObjcObject(contextInternalContext(_context), m_value))
+ if (id wrapped = tryUnwrapObjcObject([_context globalContextRef], m_value))
return [wrapped description];
return [self toString];
}
Modified: trunk/Source/_javascript_Core/API/ObjCCallbackFunction.mm (144667 => 144668)
--- trunk/Source/_javascript_Core/API/ObjCCallbackFunction.mm 2013-03-04 21:44:07 UTC (rev 144667)
+++ trunk/Source/_javascript_Core/API/ObjCCallbackFunction.mm 2013-03-04 21:47:29 UTC (rev 144668)
@@ -57,7 +57,7 @@
class CallbackArgumentBoolean : public CallbackArgument {
virtual void set(NSInvocation *invocation, NSInteger argumentNumber, JSContext *context, JSValueRef argument, JSValueRef*) override
{
- bool value = JSValueToBoolean(contextInternalContext(context), argument);
+ bool value = JSValueToBoolean([context globalContextRef], argument);
[invocation setArgument:&value atIndex:argumentNumber];
}
};
@@ -66,7 +66,7 @@
class CallbackArgumentInteger : public CallbackArgument {
virtual void set(NSInvocation *invocation, NSInteger argumentNumber, JSContext *context, JSValueRef argument, JSValueRef* exception) override
{
- T value = (T)JSC::toInt32(JSValueToNumber(contextInternalContext(context), argument, exception));
+ T value = (T)JSC::toInt32(JSValueToNumber([context globalContextRef], argument, exception));
[invocation setArgument:&value atIndex:argumentNumber];
}
};
@@ -75,7 +75,7 @@
class CallbackArgumentDouble : public CallbackArgument {
virtual void set(NSInvocation *invocation, NSInteger argumentNumber, JSContext *context, JSValueRef argument, JSValueRef* exception) override
{
- T value = (T)JSValueToNumber(contextInternalContext(context), argument, exception);
+ T value = (T)JSValueToNumber([context globalContextRef], argument, exception);
[invocation setArgument:&value atIndex:argumentNumber];
}
};
@@ -113,7 +113,7 @@
virtual void set(NSInvocation *invocation, NSInteger argumentNumber, JSContext *context, JSValueRef argument, JSValueRef* exception) override
{
- JSGlobalContextRef contextRef = contextInternalContext(context);
+ JSGlobalContextRef contextRef = [context globalContextRef];
id object = tryUnwrapObjcObject(contextRef, argument);
if (object && [object isKindOfClass:m_class]) {
@@ -136,7 +136,7 @@
class CallbackArgumentNSNumber : public CallbackArgument {
virtual void set(NSInvocation *invocation, NSInteger argumentNumber, JSContext *context, JSValueRef argument, JSValueRef* exception) override
{
- id value = valueToNumber(contextInternalContext(context), argument, exception);
+ id value = valueToNumber([context globalContextRef], argument, exception);
[invocation setArgument:&value atIndex:argumentNumber];
}
};
@@ -144,7 +144,7 @@
class CallbackArgumentNSString : public CallbackArgument {
virtual void set(NSInvocation *invocation, NSInteger argumentNumber, JSContext *context, JSValueRef argument, JSValueRef* exception) override
{
- id value = valueToString(contextInternalContext(context), argument, exception);
+ id value = valueToString([context globalContextRef], argument, exception);
[invocation setArgument:&value atIndex:argumentNumber];
}
};
@@ -152,7 +152,7 @@
class CallbackArgumentNSDate : public CallbackArgument {
virtual void set(NSInvocation *invocation, NSInteger argumentNumber, JSContext *context, JSValueRef argument, JSValueRef* exception) override
{
- id value = valueToDate(contextInternalContext(context), argument, exception);
+ id value = valueToDate([context globalContextRef], argument, exception);
[invocation setArgument:&value atIndex:argumentNumber];
}
};
@@ -160,7 +160,7 @@
class CallbackArgumentNSArray : public CallbackArgument {
virtual void set(NSInvocation *invocation, NSInteger argumentNumber, JSContext *context, JSValueRef argument, JSValueRef* exception) override
{
- id value = valueToArray(contextInternalContext(context), argument, exception);
+ id value = valueToArray([context globalContextRef], argument, exception);
[invocation setArgument:&value atIndex:argumentNumber];
}
};
@@ -168,7 +168,7 @@
class CallbackArgumentNSDictionary : public CallbackArgument {
virtual void set(NSInvocation *invocation, NSInteger argumentNumber, JSContext *context, JSValueRef argument, JSValueRef* exception) override
{
- id value = valueToDictionary(contextInternalContext(context), argument, exception);
+ id value = valueToDictionary([context globalContextRef], argument, exception);
[invocation setArgument:&value atIndex:argumentNumber];
}
};
@@ -275,7 +275,7 @@
class CallbackResultVoid : public CallbackResult {
virtual JSValueRef get(NSInvocation *, JSContext *context, JSValueRef*) override
{
- return JSValueMakeUndefined(contextInternalContext(context));
+ return JSValueMakeUndefined([context globalContextRef]);
}
};
@@ -294,7 +294,7 @@
{
T value;
[invocation getReturnValue:&value];
- return JSValueMakeNumber(contextInternalContext(context), value);
+ return JSValueMakeNumber([context globalContextRef], value);
}
};
@@ -303,7 +303,7 @@
{
bool value;
[invocation getReturnValue:&value];
- return JSValueMakeBoolean(contextInternalContext(context), value);
+ return JSValueMakeBoolean([context globalContextRef], value);
}
};
@@ -489,7 +489,7 @@
JSValueRef ObjCCallbackFunction::call(JSContext *context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
- JSGlobalContextRef contextRef = contextInternalContext(context);
+ JSGlobalContextRef contextRef = [context globalContextRef];
size_t firstArgument;
switch (m_type) {
@@ -582,10 +582,10 @@
// The result should be a regular host function, rather than a callable C API object.
// Patch in the right length & [Prototype] values for now, but should fix this.
// Function.prototype.toString currently fails, since this is not yet a subclass of functon, but call & apply do work.
- JSObjectRef functionObject = JSObjectMake(contextInternalContext(context), objCCallbackFunctionClass(), new ObjCCallbackFunction(context, invocation, type, instanceClass, arguments.release(), result.release()));
+ JSObjectRef functionObject = JSObjectMake([context globalContextRef], objCCallbackFunctionClass(), new ObjCCallbackFunction(context, invocation, type, instanceClass, arguments.release(), result.release()));
JSValue *value = [JSValue valueWithValue:functionObject inContext:context];
value[@"length"] = @(argumentCount);
- JSObjectSetPrototype(contextInternalContext(context), functionObject, valueInternalValue(context[@"Function"][@"prototype"]));
+ JSObjectSetPrototype([context globalContextRef], functionObject, valueInternalValue(context[@"Function"][@"prototype"]));
value[@"toString"] = [context evaluateScript:@"(function(){ return '"
"function <Objective-C>() {" "\\n"
" [native code]" "\\n"