2 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include "JSInjectedScriptHostPrototype.h"
30 #include "GetterSetter.h"
31 #include "Identifier.h"
32 #include "InjectedScriptHost.h"
33 #include "JSCInlines.h"
34 #include "JSFunction.h"
35 #include "JSInjectedScriptHost.h"
41 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionSubtype(ExecState*);
42 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionFunctionDetails(ExecState*);
43 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionGetInternalProperties(ExecState*);
44 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionInternalConstructorName(ExecState*);
45 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionIsHTMLAllCollection(ExecState*);
46 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapSize(ExecState*);
47 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapEntries(ExecState*);
49 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeAttributeEvaluate(ExecState*);
51 const ClassInfo JSInjectedScriptHostPrototype::s_info = { "InjectedScriptHost", &Base::s_info, 0, CREATE_METHOD_TABLE(JSInjectedScriptHostPrototype) };
53 void JSInjectedScriptHostPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject)
55 Base::finishCreation(vm);
56 ASSERT(inherits(info()));
57 vm.prototypeMap.addPrototype(this);
59 JSC_NATIVE_FUNCTION("subtype", jsInjectedScriptHostPrototypeFunctionSubtype, DontEnum, 1);
60 JSC_NATIVE_FUNCTION("functionDetails", jsInjectedScriptHostPrototypeFunctionFunctionDetails, DontEnum, 1);
61 JSC_NATIVE_FUNCTION("getInternalProperties", jsInjectedScriptHostPrototypeFunctionGetInternalProperties, DontEnum, 1);
62 JSC_NATIVE_FUNCTION("internalConstructorName", jsInjectedScriptHostPrototypeFunctionInternalConstructorName, DontEnum, 1);
63 JSC_NATIVE_FUNCTION("isHTMLAllCollection", jsInjectedScriptHostPrototypeFunctionIsHTMLAllCollection, DontEnum, 1);
64 JSC_NATIVE_FUNCTION("weakMapSize", jsInjectedScriptHostPrototypeFunctionWeakMapSize, DontEnum, 1);
65 JSC_NATIVE_FUNCTION("weakMapEntries", jsInjectedScriptHostPrototypeFunctionWeakMapEntries, DontEnum, 1);
67 Identifier evaluateIdentifier(&vm, "evaluate");
68 GetterSetter* accessor = GetterSetter::create(vm, globalObject);
69 JSFunction* function = JSFunction::create(vm, globalObject, 0, evaluateIdentifier.string(), jsInjectedScriptHostPrototypeAttributeEvaluate);
70 accessor->setGetter(vm, globalObject, function);
71 putDirectNonIndexAccessor(vm, evaluateIdentifier, accessor, DontEnum | Accessor);
74 EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeAttributeEvaluate(ExecState* exec)
76 JSValue thisValue = exec->thisValue();
77 JSInjectedScriptHost* castedThis = jsDynamicCast<JSInjectedScriptHost*>(thisValue);
79 return throwVMTypeError(exec);
81 ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
82 return JSValue::encode(castedThis->evaluate(exec));
85 EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionInternalConstructorName(ExecState* exec)
87 JSValue thisValue = exec->thisValue();
88 JSInjectedScriptHost* castedThis = jsDynamicCast<JSInjectedScriptHost*>(thisValue);
90 return throwVMTypeError(exec);
92 ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
93 return JSValue::encode(castedThis->internalConstructorName(exec));
96 EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionIsHTMLAllCollection(ExecState* exec)
98 JSValue thisValue = exec->thisValue();
99 JSInjectedScriptHost* castedThis = jsDynamicCast<JSInjectedScriptHost*>(thisValue);
101 return throwVMTypeError(exec);
103 ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
104 return JSValue::encode(castedThis->isHTMLAllCollection(exec));
107 EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapSize(ExecState* exec)
109 JSValue thisValue = exec->thisValue();
110 JSInjectedScriptHost* castedThis = jsDynamicCast<JSInjectedScriptHost*>(thisValue);
112 return throwVMTypeError(exec);
114 ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
115 return JSValue::encode(castedThis->weakMapSize(exec));
118 EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapEntries(ExecState* exec)
120 JSValue thisValue = exec->thisValue();
121 JSInjectedScriptHost* castedThis = jsDynamicCast<JSInjectedScriptHost*>(thisValue);
123 return throwVMTypeError(exec);
125 ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
126 return JSValue::encode(castedThis->weakMapEntries(exec));
129 EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionSubtype(ExecState* exec)
131 JSValue thisValue = exec->thisValue();
132 JSInjectedScriptHost* castedThis = jsDynamicCast<JSInjectedScriptHost*>(thisValue);
134 return throwVMTypeError(exec);
136 ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
137 return JSValue::encode(castedThis->subtype(exec));
140 EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionFunctionDetails(ExecState* exec)
142 JSValue thisValue = exec->thisValue();
143 JSInjectedScriptHost* castedThis = jsDynamicCast<JSInjectedScriptHost*>(thisValue);
145 return throwVMTypeError(exec);
147 ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
148 return JSValue::encode(castedThis->functionDetails(exec));
151 EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionGetInternalProperties(ExecState* exec)
153 JSValue thisValue = exec->thisValue();
154 JSInjectedScriptHost* castedThis = jsDynamicCast<JSInjectedScriptHost*>(thisValue);
156 return throwVMTypeError(exec);
158 ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
159 return JSValue::encode(castedThis->getInternalProperties(exec));
162 } // namespace Inspector