1967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch/*
2967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
3967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
4967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    This library is free software; you can redistribute it and/or
5967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    modify it under the terms of the GNU Library General Public
6967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    License as published by the Free Software Foundation; either
7967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    version 2 of the License, or (at your option) any later version.
8967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
9967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    This library is distributed in the hope that it will be useful,
10967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    but WITHOUT ANY WARRANTY; without even the implied warranty of
11967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    Library General Public License for more details.
13967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
14967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    You should have received a copy of the GNU Library General Public License
15967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    along with this library; see the file COPYING.LIB.  If not, write to
16967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    Boston, MA 02110-1301, USA.
18967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch*/
19967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
20967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch#ifndef qscriptoriginalglobalobject_p_h
21967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch#define qscriptoriginalglobalobject_p_h
22967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
23967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch#include <JavaScriptCore/JavaScript.h>
24967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch#include <JavaScriptCore/JSRetainPtr.h>
25967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch#include <QtCore/qvector.h>
26967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
27967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch/*!
28967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    \internal
29967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    This class is a workaround for missing JSC C API functionality. This class keeps all important
30967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    properties of an original (default) global object, so we can use it even if the global object was
31967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    changed.
32967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
33967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    FIXME this class is a container for workarounds :-) it should be replaced by proper JSC C API calls.
34967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
35967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    The class have to be created on the QScriptEnginePrivate creation time (before any change got applied to
36967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    global object).
37967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch*/
38967717af5423377c967781471ee106e2bb4e11c8Ben Murdochclass QScriptOriginalGlobalObject {
39967717af5423377c967781471ee106e2bb4e11c8Ben Murdochpublic:
40967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    inline QScriptOriginalGlobalObject(JSGlobalContextRef context);
41967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    inline ~QScriptOriginalGlobalObject();
42967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
43967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    inline bool objectHasOwnProperty(JSObjectRef object, JSStringRef property) const;
44967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    inline QVector<JSStringRef> objectGetOwnPropertyNames(JSObjectRef object) const;
45967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
46bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen    inline bool isDate(JSValueRef value) const;
47967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    inline bool isArray(JSValueRef value) const;
48967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    inline bool isError(JSValueRef value) const;
490617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen
500617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    inline JSValueRef functionPrototype() const;
51967717af5423377c967781471ee106e2bb4e11c8Ben Murdochprivate:
52967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    inline bool isType(JSValueRef value, JSObjectRef constructor, JSValueRef prototype) const;
53967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    inline void initializeMember(JSObjectRef globalObject, JSStringRef prototypeName, const char* type, JSObjectRef& constructor, JSValueRef& prototype);
54967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
55967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    // Copy of the global context reference (the same as in QScriptEnginePrivate).
56967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSGlobalContextRef m_context;
57967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
58967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    // Copy of constructors and prototypes used in isType functions.
59967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSObjectRef m_arrayConstructor;
60967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueRef m_arrayPrototype;
61967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSObjectRef m_errorConstructor;
62967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueRef m_errorPrototype;
630617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    JSObjectRef m_functionConstructor;
640617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    JSValueRef m_functionPrototype;
65bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen    JSObjectRef m_dateConstructor;
66bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen    JSValueRef m_datePrototype;
67967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
68967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    // Reference to standard JS functions that are not exposed by JSC C API.
69967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSObjectRef m_hasOwnPropertyFunction;
70967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSObjectRef m_getOwnPropertyNamesFunction;
71967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch};
72967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
73967717af5423377c967781471ee106e2bb4e11c8Ben MurdochQScriptOriginalGlobalObject::QScriptOriginalGlobalObject(JSGlobalContextRef context)
74967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    : m_context(JSGlobalContextRetain(context))
75967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch{
76967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSObjectRef globalObject = JSContextGetGlobalObject(m_context);
77967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueRef exception = 0;
78967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSRetainPtr<JSStringRef> propertyName;
79967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
80967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    propertyName.adopt(JSStringCreateWithUTF8CString("prototype"));
81967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    initializeMember(globalObject, propertyName.get(), "Array", m_arrayConstructor, m_arrayPrototype);
82967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    initializeMember(globalObject, propertyName.get(), "Error", m_errorConstructor, m_errorPrototype);
830617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    initializeMember(globalObject, propertyName.get(), "Function", m_functionConstructor, m_functionPrototype);
84bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen    initializeMember(globalObject, propertyName.get(), "Date", m_dateConstructor, m_datePrototype);
85967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
86967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    propertyName.adopt(JSStringCreateWithUTF8CString("hasOwnProperty"));
87967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    m_hasOwnPropertyFunction = const_cast<JSObjectRef>(JSObjectGetProperty(m_context, globalObject, propertyName.get(), &exception));
88967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueProtect(m_context, m_hasOwnPropertyFunction);
89967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    Q_ASSERT(JSValueIsObject(m_context, m_hasOwnPropertyFunction));
90967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    Q_ASSERT(JSObjectIsFunction(m_context, m_hasOwnPropertyFunction));
91967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    Q_ASSERT(!exception);
92967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
93967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    propertyName.adopt(JSStringCreateWithUTF8CString("Object"));
94967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSObjectRef objectConstructor
95967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch            = const_cast<JSObjectRef>(JSObjectGetProperty(m_context, globalObject, propertyName.get(), &exception));
96967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    propertyName.adopt(JSStringCreateWithUTF8CString("getOwnPropertyNames"));
97967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    m_getOwnPropertyNamesFunction
98967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch            = const_cast<JSObjectRef>(JSObjectGetProperty(m_context, objectConstructor, propertyName.get(), &exception));
99967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueProtect(m_context, m_getOwnPropertyNamesFunction);
100967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    Q_ASSERT(JSValueIsObject(m_context, m_getOwnPropertyNamesFunction));
101967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    Q_ASSERT(JSObjectIsFunction(m_context, m_getOwnPropertyNamesFunction));
102967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    Q_ASSERT(!exception);
103967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch}
104967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
105967717af5423377c967781471ee106e2bb4e11c8Ben Murdochinline void QScriptOriginalGlobalObject::initializeMember(JSObjectRef globalObject, JSStringRef prototypeName, const char* type, JSObjectRef& constructor, JSValueRef& prototype)
106967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch{
107967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSRetainPtr<JSStringRef> typeName(Adopt, JSStringCreateWithUTF8CString(type));
108967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueRef exception = 0;
109967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
110967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    // Save references to the Type constructor and prototype.
111967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueRef typeConstructor = JSObjectGetProperty(m_context, globalObject, typeName.get(), &exception);
112967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    Q_ASSERT(JSValueIsObject(m_context, typeConstructor));
113967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    constructor = JSValueToObject(m_context, typeConstructor, &exception);
114967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueProtect(m_context, constructor);
115967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
116967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    // Note that this is not the [[Prototype]] internal property (which we could
117967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    // get via JSObjectGetPrototype), but the Type.prototype, that will be set
118967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    // as [[Prototype]] of Type instances.
119967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    prototype = JSObjectGetProperty(m_context, constructor, prototypeName, &exception);
120967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    Q_ASSERT(JSValueIsObject(m_context, prototype));
121967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueProtect(m_context, prototype);
122967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    Q_ASSERT(!exception);
123967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch}
124967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
125967717af5423377c967781471ee106e2bb4e11c8Ben MurdochQScriptOriginalGlobalObject::~QScriptOriginalGlobalObject()
126967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch{
127967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueUnprotect(m_context, m_arrayConstructor);
128967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueUnprotect(m_context, m_arrayPrototype);
129967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueUnprotect(m_context, m_errorConstructor);
130967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueUnprotect(m_context, m_errorPrototype);
1310617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    JSValueUnprotect(m_context, m_functionConstructor);
1320617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    JSValueUnprotect(m_context, m_functionPrototype);
133bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen    JSValueUnprotect(m_context, m_dateConstructor);
134bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen    JSValueUnprotect(m_context, m_datePrototype);
135967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueUnprotect(m_context, m_hasOwnPropertyFunction);
136967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueUnprotect(m_context, m_getOwnPropertyNamesFunction);
137967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSGlobalContextRelease(m_context);
138967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch}
139967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
140967717af5423377c967781471ee106e2bb4e11c8Ben Murdochinline bool QScriptOriginalGlobalObject::objectHasOwnProperty(JSObjectRef object, JSStringRef property) const
141967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch{
142967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    // FIXME This function should be replaced by JSC C API.
143967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueRef exception = 0;
144967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueRef propertyName[] = { JSValueMakeString(m_context, property) };
145967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueRef result = JSObjectCallAsFunction(m_context, m_hasOwnPropertyFunction, object, 1, propertyName, &exception);
146967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    return exception ? false : JSValueToBoolean(m_context, result);
147967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch}
148967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
149967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch/*!
150967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    \internal
151967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    This method gives ownership of all JSStringRefs.
152967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch*/
153967717af5423377c967781471ee106e2bb4e11c8Ben Murdochinline QVector<JSStringRef> QScriptOriginalGlobalObject::objectGetOwnPropertyNames(JSObjectRef object) const
154967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch{
155967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueRef exception = 0;
156967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSObjectRef propertyNames
157967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch            = const_cast<JSObjectRef>(JSObjectCallAsFunction(m_context,
158967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch                                                            m_getOwnPropertyNamesFunction,
159967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch                                                            /* thisObject */ 0,
160967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch                                                            /* argumentCount */ 1,
161967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch                                                            &object,
162967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch                                                            &exception));
163967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    Q_ASSERT(JSValueIsObject(m_context, propertyNames));
164967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    Q_ASSERT(!exception);
165967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSStringRef lengthName = QScriptConverter::toString("length");
166967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    int count = JSValueToNumber(m_context, JSObjectGetProperty(m_context, propertyNames, lengthName, &exception), &exception);
167967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
168967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    Q_ASSERT(!exception);
169967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    QVector<JSStringRef> names;
170967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    names.reserve(count);
171967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    for (int i = 0; i < count; ++i) {
172967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch        JSValueRef tmp = JSObjectGetPropertyAtIndex(m_context, propertyNames, i, &exception);
173967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch        names.append(JSValueToStringCopy(m_context, tmp, &exception));
174967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch        Q_ASSERT(!exception);
175967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    }
176967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    return names;
177967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch}
178967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
179bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monseninline bool QScriptOriginalGlobalObject::isDate(JSValueRef value) const
180bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen{
181bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen    return isType(value, m_dateConstructor, m_datePrototype);
182bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen}
183bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen
184967717af5423377c967781471ee106e2bb4e11c8Ben Murdochinline bool QScriptOriginalGlobalObject::isArray(JSValueRef value) const
185967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch{
186967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    return isType(value, m_arrayConstructor, m_arrayPrototype);
187967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch}
188967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
189967717af5423377c967781471ee106e2bb4e11c8Ben Murdochinline bool QScriptOriginalGlobalObject::isError(JSValueRef value) const
190967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch{
191967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    return isType(value, m_errorConstructor, m_errorPrototype);
192967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch}
193967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
1940617145a89917ae7735fe1c9538688ab9a577df5Kristian Monseninline JSValueRef QScriptOriginalGlobalObject::functionPrototype() const
1950617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen{
1960617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    return m_functionPrototype;
1970617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen}
1980617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen
199967717af5423377c967781471ee106e2bb4e11c8Ben Murdochinline bool QScriptOriginalGlobalObject::isType(JSValueRef value, JSObjectRef constructor, JSValueRef prototype) const
200967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch{
201967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    // JSC API doesn't export the [[Class]] information for the builtins. But we know that a value
202967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    // is an object of the Type if it was created with the Type constructor or if it is the Type.prototype.
203967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    JSValueRef exception = 0;
204967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    bool result = JSValueIsInstanceOfConstructor(m_context, value, constructor, &exception) || JSValueIsStrictEqual(m_context, value, prototype);
205967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    Q_ASSERT(!exception);
206967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    return result;
207967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch}
208967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
209967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch#endif // qscriptoriginalglobalobject_p_h
210