* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#import "APICast.h"
-#import "APIShims.h"
#import "DateInstance.h"
#import "Error.h"
+#import "Exception.h"
#import "JavaScriptCore.h"
#import "JSContextInternal.h"
#import "JSVirtualMachineInternal.h"
#import "JSValueInternal.h"
#import "JSWrapperMap.h"
#import "ObjcRuntimeExtras.h"
-#import "Operations.h"
+#import "JSCInlines.h"
#import "JSCJSValue.h"
+#import "Strong.h"
#import "StrongInlines.h"
#import <wtf/HashMap.h>
#import <wtf/HashSet.h>
#import <wtf/ObjcRuntimeExtras.h>
+#import <wtf/SpinLock.h>
#import <wtf/Vector.h>
-#import <wtf/TCSpinLock.h>
#import <wtf/text/WTFString.h>
#import <wtf/text/StringHash.h>
+#if ENABLE(REMOTE_INSPECTOR)
+#import "CallFrame.h"
+#import "JSGlobalObject.h"
+#import "JSGlobalObjectInspectorController.h"
+#endif
+
#if JSC_OBJC_API_ENABLED
NSString * const JSPropertyDescriptorWritableKey = @"writable";
return JSValueIsObject([_context JSGlobalContextRef], m_value);
}
+- (BOOL)isArray
+{
+ return JSValueIsArray([_context JSGlobalContextRef], m_value);
+}
+
+- (BOOL)isDate
+{
+ return JSValueIsDate([_context JSGlobalContextRef], m_value);
+}
+
- (BOOL)isEqualToObject:(id)value
{
return JSValueIsStrictEqual([_context JSGlobalContextRef], m_value, objectToValue(_context, value));
inline bool isDate(JSObjectRef object, JSGlobalContextRef context)
{
- JSC::APIEntryShim entryShim(toJS(context));
- return toJS(object)->inherits(&JSC::DateInstance::s_info);
+ JSC::JSLockHolder locker(toJS(context));
+ return toJS(object)->inherits(JSC::DateInstance::info());
}
inline bool isArray(JSObjectRef object, JSGlobalContextRef context)
{
- JSC::APIEntryShim entryShim(toJS(context));
- return toJS(object)->inherits(&JSC::JSArray::s_info);
+ JSC::JSLockHolder locker(toJS(context));
+ return toJS(object)->inherits(JSC::JSArray::info());
}
@implementation JSValue(Internal)
return last;
}
+#if ENABLE(REMOTE_INSPECTOR)
+static void reportExceptionToInspector(JSGlobalContextRef context, JSC::JSValue exceptionValue)
+{
+ JSC::ExecState* exec = toJS(context);
+ JSC::Exception* exception = JSC::Exception::create(exec->vm(), exceptionValue);
+ exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exception);
+}
+#endif
+
static JSContainerConvertor::Task valueToObjectWithoutCopy(JSGlobalContextRef context, JSValueRef value)
{
if (!JSValueIsObject(context, value)) {
return (JSContainerConvertor::Task){ object, wrapped, ContainerNone };
if (isDate(object, context))
- return (JSContainerConvertor::Task){ object, [NSDate dateWithTimeIntervalSince1970:JSValueToNumber(context, object, 0)], ContainerNone };
+ return (JSContainerConvertor::Task){ object, [NSDate dateWithTimeIntervalSince1970:JSValueToNumber(context, object, 0) / 1000.0], ContainerNone };
if (isArray(object, context))
return (JSContainerConvertor::Task){ object, [NSMutableArray array], ContainerArray };
static id containerValueToObject(JSGlobalContextRef context, JSContainerConvertor::Task task)
{
ASSERT(task.type != ContainerNone);
- JSC::APIEntryShim entryShim(toJS(context));
+ JSC::JSLockHolder locker(toJS(context));
JSContainerConvertor convertor(context);
convertor.add(task);
ASSERT(!convertor.isWorkListEmpty());
ASSERT([current.objc isKindOfClass:[NSMutableDictionary class]]);
NSMutableDictionary *dictionary = (NSMutableDictionary *)current.objc;
+ JSC::JSLockHolder locker(toJS(context));
+
JSPropertyNameArrayRef propertyNameArray = JSObjectCopyPropertyNames(context, js);
size_t length = JSPropertyNameArrayGetCount(propertyNameArray);
return nil;
}
- NSString *stringNS = HardAutorelease(JSStringCopyCFString(kCFAllocatorDefault, jsstring));
+ RetainPtr<CFStringRef> stringCF = adoptCF(JSStringCopyCFString(kCFAllocatorDefault, jsstring));
JSStringRelease(jsstring);
- return stringNS;
+ return (NSString *)stringCF.autorelease();
}
id valueToDate(JSGlobalContextRef context, JSValueRef value, JSValueRef* exception)
return wrapped;
}
- double result = JSValueToNumber(context, value, exception);
+ double result = JSValueToNumber(context, value, exception) / 1000.0;
return *exception ? nil : [NSDate dateWithTimeIntervalSince1970:result];
}
if (JSValueIsObject(context, value))
return containerValueToObject(context, (JSContainerConvertor::Task){ value, [NSMutableArray array], ContainerArray});
- if (!(JSValueIsNull(context, value) || JSValueIsUndefined(context, value)))
- *exception = toRef(JSC::createTypeError(toJS(context), "Cannot convert primitive to NSArray"));
+ JSC::JSLockHolder locker(toJS(context));
+ if (!(JSValueIsNull(context, value) || JSValueIsUndefined(context, value))) {
+ JSC::JSObject* exceptionObject = JSC::createTypeError(toJS(context), ASCIILiteral("Cannot convert primitive to NSArray"));
+ *exception = toRef(exceptionObject);
+#if ENABLE(REMOTE_INSPECTOR)
+ reportExceptionToInspector(context, exceptionObject);
+#endif
+ }
return nil;
}
if (JSValueIsObject(context, value))
return containerValueToObject(context, (JSContainerConvertor::Task){ value, [NSMutableDictionary dictionary], ContainerDictionary});
- if (!(JSValueIsNull(context, value) || JSValueIsUndefined(context, value)))
- *exception = toRef(JSC::createTypeError(toJS(context), "Cannot convert primitive to NSDictionary"));
+ JSC::JSLockHolder locker(toJS(context));
+ if (!(JSValueIsNull(context, value) || JSValueIsUndefined(context, value))) {
+ JSC::JSObject* exceptionObject = JSC::createTypeError(toJS(context), ASCIILiteral("Cannot convert primitive to NSDictionary"));
+ *exception = toRef(exceptionObject);
+#if ENABLE(REMOTE_INSPECTOR)
+ reportExceptionToInspector(context, exceptionObject);
+#endif
+ }
return nil;
}
}
if ([object isKindOfClass:[NSDate class]]) {
- JSValueRef argument = JSValueMakeNumber(contextRef, [object timeIntervalSince1970]);
+ JSValueRef argument = JSValueMakeNumber(contextRef, [object timeIntervalSince1970] * 1000.0);
JSObjectRef result = JSObjectMakeDate(contextRef, 1, &argument, 0);
return (ObjcContainerConvertor::Task){ object, result, ContainerNone };
}
if (task.type == ContainerNone)
return task.js;
- JSC::APIEntryShim entryShim(toJS(contextRef));
+ JSC::JSLockHolder locker(toJS(contextRef));
ObjcContainerConvertor convertor(context);
convertor.add(task);
ASSERT(!convertor.isWorkListEmpty());
static StructTagHandler* handerForStructTag(const char* encodedType)
{
- static SpinLock handerForStructTagLock = SPINLOCK_INITIALIZER;
+ static StaticSpinLock handerForStructTagLock;
SpinLockHolder lockHolder(&handerForStructTagLock);
static StructHandlers* structHandlers = createStructHandlerMap();