1 /*
2     This file is part of the WebKit open source project.
3     This file has been generated by generate-bindings.pl. DO NOT MODIFY!
4 
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Library General Public
7     License as published by the Free Software Foundation; either
8     version 2 of the License, or (at your option) any later version.
9 
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13     Library General Public License for more details.
14 
15     You should have received a copy of the GNU Library General Public License
16     along with this library; see the file COPYING.LIB.  If not, write to
17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18     Boston, MA 02110-1301, USA.
19 */
20 
21 #include "config.h"
22 
23 #if ENABLE(BLOB)
24 
25 #include "JSDOMURL.h"
26 
27 #include "DOMURL.h"
28 #include "ExceptionCode.h"
29 #include "JSBlob.h"
30 #include "JSDOMBinding.h"
31 #include "KURL.h"
32 #include <runtime/Error.h>
33 #include <wtf/GetPtr.h>
34 
35 using namespace JSC;
36 
37 namespace WebCore {
38 
39 ASSERT_CLASS_FITS_IN_CELL(JSDOMURL);
40 
41 /* Hash table for prototype */
42 #if ENABLE(JIT)
43 #define THUNK_GENERATOR(generator) , generator
44 #else
45 #define THUNK_GENERATOR(generator)
46 #endif
47 
48 static const HashTableValue JSDOMURLPrototypeTableValues[3] =
49 {
50     { "createObjectURL", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMURLPrototypeFunctionCreateObjectURL), (intptr_t)1 THUNK_GENERATOR(0) },
51     { "revokeObjectURL", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMURLPrototypeFunctionRevokeObjectURL), (intptr_t)1 THUNK_GENERATOR(0) },
52     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
53 };
54 
55 #undef THUNK_GENERATOR
56 static JSC_CONST_HASHTABLE HashTable JSDOMURLPrototypeTable = { 4, 3, JSDOMURLPrototypeTableValues, 0 };
getJSDOMURLPrototypeTable(ExecState * exec)57 static const HashTable* getJSDOMURLPrototypeTable(ExecState* exec)
58 {
59     return getHashTableForGlobalData(exec->globalData(), &JSDOMURLPrototypeTable);
60 }
61 
62 const ClassInfo JSDOMURLPrototype::s_info = { "DOMURLPrototype", &JSC::JSObjectWithGlobalObject::s_info, 0, getJSDOMURLPrototypeTable };
63 
self(ExecState * exec,JSGlobalObject * globalObject)64 JSObject* JSDOMURLPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
65 {
66     return getDOMPrototype<JSDOMURL>(exec, globalObject);
67 }
68 
getOwnPropertySlot(ExecState * exec,const Identifier & propertyName,PropertySlot & slot)69 bool JSDOMURLPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
70 {
71     return getStaticFunctionSlot<JSObject>(exec, getJSDOMURLPrototypeTable(exec), this, propertyName, slot);
72 }
73 
getOwnPropertyDescriptor(ExecState * exec,const Identifier & propertyName,PropertyDescriptor & descriptor)74 bool JSDOMURLPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
75 {
76     return getStaticFunctionDescriptor<JSObject>(exec, getJSDOMURLPrototypeTable(exec), this, propertyName, descriptor);
77 }
78 
79 const ClassInfo JSDOMURL::s_info = { "DOMURL", &JSDOMWrapper::s_info, 0, 0 };
80 
JSDOMURL(Structure * structure,JSDOMGlobalObject * globalObject,PassRefPtr<DOMURL> impl)81 JSDOMURL::JSDOMURL(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<DOMURL> impl)
82     : JSDOMWrapper(structure, globalObject)
83     , m_impl(impl)
84 {
85     ASSERT(inherits(&s_info));
86 }
87 
createPrototype(ExecState * exec,JSGlobalObject * globalObject)88 JSObject* JSDOMURL::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
89 {
90     return new (exec) JSDOMURLPrototype(exec->globalData(), globalObject, JSDOMURLPrototype::createStructure(globalObject->globalData(), globalObject->objectPrototype()));
91 }
92 
jsDOMURLPrototypeFunctionCreateObjectURL(ExecState * exec)93 EncodedJSValue JSC_HOST_CALL jsDOMURLPrototypeFunctionCreateObjectURL(ExecState* exec)
94 {
95     JSValue thisValue = exec->hostThisValue();
96     if (!thisValue.inherits(&JSDOMURL::s_info))
97         return throwVMTypeError(exec);
98     JSDOMURL* castedThis = static_cast<JSDOMURL*>(asObject(thisValue));
99     DOMURL* imp = static_cast<DOMURL*>(castedThis->impl());
100     Blob* blob(toBlob(exec->argument(0)));
101     if (exec->hadException())
102         return JSValue::encode(jsUndefined());
103 
104 
105     JSC::JSValue result = jsStringOrUndefined(exec, imp->createObjectURL(blob));
106     return JSValue::encode(result);
107 }
108 
jsDOMURLPrototypeFunctionRevokeObjectURL(ExecState * exec)109 EncodedJSValue JSC_HOST_CALL jsDOMURLPrototypeFunctionRevokeObjectURL(ExecState* exec)
110 {
111     JSValue thisValue = exec->hostThisValue();
112     if (!thisValue.inherits(&JSDOMURL::s_info))
113         return throwVMTypeError(exec);
114     JSDOMURL* castedThis = static_cast<JSDOMURL*>(asObject(thisValue));
115     DOMURL* imp = static_cast<DOMURL*>(castedThis->impl());
116     const String& url(ustringToString(exec->argument(0).toString(exec)));
117     if (exec->hadException())
118         return JSValue::encode(jsUndefined());
119 
120     imp->revokeObjectURL(url);
121     return JSValue::encode(jsUndefined());
122 }
123 
toJS(JSC::ExecState * exec,JSDOMGlobalObject * globalObject,DOMURL * impl)124 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMURL* impl)
125 {
126     return wrap<JSDOMURL>(exec, globalObject, impl);
127 }
128 
toDOMURL(JSC::JSValue value)129 DOMURL* toDOMURL(JSC::JSValue value)
130 {
131     return value.inherits(&JSDOMURL::s_info) ? static_cast<JSDOMURL*>(asObject(value))->impl() : 0;
132 }
133 
134 }
135 
136 #endif // ENABLE(BLOB)
137