Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 This file is part of the Blink open source project. | |
| 3 This file has been auto-generated by CodeGeneratorV8.pm. 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., 59 Temple Place - Suite 330, | |
| 18 Boston, MA 02111-1307, USA. | |
| 19 */ | |
| 20 | |
| 21 #include "config.h" | |
| 22 #include "V8TestConstants.h" | |
| 23 | |
| 24 #include "RuntimeEnabledFeatures.h" | |
| 25 #include "bindings/v8/ScriptController.h" | |
| 26 #include "bindings/v8/V8Binding.h" | |
| 27 #include "bindings/v8/V8DOMConfiguration.h" | |
| 28 #include "bindings/v8/V8DOMWrapper.h" | |
| 29 #include "core/dom/ContextFeatures.h" | |
| 30 #include "core/dom/Document.h" | |
| 31 #include "core/page/Frame.h" | |
| 32 #include "core/platform/chromium/TraceEvent.h" | |
| 33 #include "wtf/UnusedParam.h" | |
| 34 | |
| 35 namespace WebCore { | |
| 36 | |
| 37 static void initializeScriptWrappableForInterface(TestConstants* object) | |
| 38 { | |
| 39 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) | |
| 40 ScriptWrappable::setTypeInfoInObject(object, &V8TestConstants::info); | |
| 41 else | |
| 42 ASSERT_NOT_REACHED(); | |
| 43 } | |
| 44 | |
| 45 } // namespace WebCore | |
| 46 | |
| 47 // In ScriptWrappable::init, the use of a local function declaration has an issu e on Windows: | |
| 48 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function | |
| 49 // in the global namespace. | |
| 50 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe edback/details/664619/the-namespace-of-local-function-declarations-in-c) | |
| 51 void webCoreInitializeScriptWrappableForInterface(WebCore::TestConstants* object ) | |
| 52 { | |
| 53 WebCore::initializeScriptWrappableForInterface(object); | |
| 54 } | |
| 55 | |
| 56 namespace WebCore { | |
| 57 WrapperTypeInfo V8TestConstants::info = { V8TestConstants::GetTemplate, V8TestCo nstants::derefObject, 0, 0, 0, V8TestConstants::installPerContextPrototypeProper ties, 0, WrapperTypeObjectPrototype }; | |
| 58 | |
| 59 namespace TestConstantsV8Internal { | |
| 60 | |
| 61 template <typename T> void V8_USE(T) { } | |
| 62 | |
| 63 } // namespace TestConstantsV8Internal | |
| 64 | |
| 65 static const V8DOMConfiguration::ConstantConfiguration V8TestConstantsConstants[ ] = { | |
| 66 {"CONST_VALUE_0", 0}, | |
| 67 {"CONST_VALUE_1", 1}, | |
| 68 {"CONST_VALUE_2", 2}, | |
| 69 {"CONST_VALUE_4", 4}, | |
| 70 {"CONST_VALUE_8", 8}, | |
| 71 {"CONST_VALUE_9", -1}, | |
| 72 {"CONST_VALUE_10", "my constant string"}, | |
| 73 {"CONST_VALUE_11", 0xffffffff}, | |
| 74 {"CONST_VALUE_12", 0x01}, | |
| 75 {"CONST_VALUE_13", 0X20}, | |
| 76 {"CONST_VALUE_14", 0x1abc}, | |
| 77 {"CONST_VALUE_15", 010}, | |
| 78 {"CONST_VALUE_16", -010}, | |
| 79 {"CONST_VALUE_16", -0x1A}, | |
| 80 {"CONST_VALUE_17", -0X1a}, | |
| 81 #if ENABLE(Condition) | |
| 82 {"CONDITIONAL_CONST", 0}, | |
| 83 #endif // ENABLE(Condition) | |
| 84 {"DEPRECATED_CONSTANT", 1}, | |
| 85 {"CONST_JAVASCRIPT", 1}, | |
| 86 }; | |
| 87 | |
| 88 COMPILE_ASSERT(0 == TestConstants::CONST_VALUE_0, TestConstantsEnumCONST_VALUE_0 IsWrongUseDoNotCheckConstants); | |
| 89 COMPILE_ASSERT(1 == TestConstants::CONST_VALUE_1, TestConstantsEnumCONST_VALUE_1 IsWrongUseDoNotCheckConstants); | |
| 90 COMPILE_ASSERT(2 == TestConstants::CONST_VALUE_2, TestConstantsEnumCONST_VALUE_2 IsWrongUseDoNotCheckConstants); | |
| 91 COMPILE_ASSERT(4 == TestConstants::CONST_VALUE_4, TestConstantsEnumCONST_VALUE_4 IsWrongUseDoNotCheckConstants); | |
| 92 COMPILE_ASSERT(8 == TestConstants::CONST_VALUE_8, TestConstantsEnumCONST_VALUE_8 IsWrongUseDoNotCheckConstants); | |
| 93 COMPILE_ASSERT(-1 == TestConstants::CONST_VALUE_9, TestConstantsEnumCONST_VALUE_ 9IsWrongUseDoNotCheckConstants); | |
| 94 COMPILE_ASSERT("my constant string" == TestConstants::CONST_VALUE_10, TestConsta ntsEnumCONST_VALUE_10IsWrongUseDoNotCheckConstants); | |
| 95 COMPILE_ASSERT(0xffffffff == TestConstants::CONST_VALUE_11, TestConstantsEnumCON ST_VALUE_11IsWrongUseDoNotCheckConstants); | |
| 96 COMPILE_ASSERT(0x01 == TestConstants::CONST_VALUE_12, TestConstantsEnumCONST_VAL UE_12IsWrongUseDoNotCheckConstants); | |
| 97 COMPILE_ASSERT(0X20 == TestConstants::CONST_VALUE_13, TestConstantsEnumCONST_VAL UE_13IsWrongUseDoNotCheckConstants); | |
| 98 COMPILE_ASSERT(0x1abc == TestConstants::CONST_VALUE_14, TestConstantsEnumCONST_V ALUE_14IsWrongUseDoNotCheckConstants); | |
| 99 COMPILE_ASSERT(010 == TestConstants::CONST_VALUE_15, TestConstantsEnumCONST_VALU E_15IsWrongUseDoNotCheckConstants); | |
| 100 COMPILE_ASSERT(-010 == TestConstants::CONST_VALUE_16, TestConstantsEnumCONST_VAL UE_16IsWrongUseDoNotCheckConstants); | |
| 101 COMPILE_ASSERT(-0x1A == TestConstants::CONST_VALUE_16, TestConstantsEnumCONST_VA LUE_16IsWrongUseDoNotCheckConstants); | |
| 102 COMPILE_ASSERT(-0X1a == TestConstants::CONST_VALUE_17, TestConstantsEnumCONST_VA LUE_17IsWrongUseDoNotCheckConstants); | |
| 103 #if ENABLE(Condition) | |
| 104 COMPILE_ASSERT(0 == TestConstants::CONDITIONAL_CONST, TestConstantsEnumCONDITION AL_CONSTIsWrongUseDoNotCheckConstants); | |
| 105 #endif // ENABLE(Condition) | |
| 106 COMPILE_ASSERT(1 == TestConstants::DEPRECATED_CONSTANT, TestConstantsEnumDEPRECA TED_CONSTANTIsWrongUseDoNotCheckConstants); | |
| 107 COMPILE_ASSERT(1 == TestConstants::RUNTIME_ENABLED_CONST, TestConstantsEnumRUNTI ME_ENABLED_CONSTIsWrongUseDoNotCheckConstants); | |
| 108 COMPILE_ASSERT(1 == TestConstants::FEATURE_ENABLED_CONST, TestConstantsEnumFEATU RE_ENABLED_CONSTIsWrongUseDoNotCheckConstants); | |
| 109 COMPILE_ASSERT(1 == TestConstants::CONST_IMPL, TestConstantsEnumCONST_IMPLIsWron gUseDoNotCheckConstants); | |
| 110 | |
| 111 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestConstantsTemplate(v8::Han dle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWo rldType) | |
|
haraken
2013/08/26 09:33:40
ConfigureV8TestConstantsTemplate => InstallDOMClas
Nils Barth (inactive)
2013/08/27 02:59:27
This function actually returns a template; most of
| |
| 112 { | |
| 113 desc->ReadOnlyPrototype(); | |
| 114 | |
| 115 v8::Local<v8::Signature> defaultSignature; | |
| 116 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(desc, "TestCo nstants", v8::Local<v8::FunctionTemplate>(), V8TestConstants::internalFieldCount , | |
| 117 0, 0, | |
| 118 0, 0, isolate, currentWorldType); | |
| 119 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. | |
| 120 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); | |
| 121 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); | |
| 122 UNUSED_PARAM(instance); // In some cases, it will not be used. | |
| 123 UNUSED_PARAM(proto); // In some cases, it will not be used. | |
| 124 if (RuntimeEnabledFeatures::rUNTIME_ENABLED_CONSTEnabled()) { | |
|
haraken
2013/08/26 09:33:40
"rUNTIME" looks wrong.
Nils Barth (inactive)
2013/08/27 02:59:27
It's pretty ugly, because the CG assumes CamelCase
| |
| 125 static const V8DOMConfiguration::ConstantConfiguration constantConfigura tion = {"RUNTIME_ENABLED_CONST", static_cast<signed int>(1)}; | |
| 126 V8DOMConfiguration::installConstants(desc, proto, &constantConfiguration , 1, isolate); | |
| 127 } | |
| 128 if (RuntimeEnabledFeatures::featureNameEnabled()) { | |
| 129 static const V8DOMConfiguration::ConstantConfiguration constantConfigura tion = {"FEATURE_ENABLED_CONST", static_cast<signed int>(1)}; | |
| 130 V8DOMConfiguration::installConstants(desc, proto, &constantConfiguration , 1, isolate); | |
| 131 } | |
| 132 V8DOMConfiguration::installConstants(desc, proto, V8TestConstantsConstants, WTF_ARRAY_LENGTH(V8TestConstantsConstants), isolate); | |
| 133 | |
| 134 // Custom toString template | |
| 135 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to StringTemplate()); | |
| 136 return desc; | |
| 137 } | |
| 138 | |
| 139 v8::Handle<v8::FunctionTemplate> V8TestConstants::GetTemplate(v8::Isolate* isola te, WrapperWorldType currentWorldType) | |
| 140 { | |
| 141 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | |
| 142 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&info); | |
| 143 if (result != data->templateMap(currentWorldType).end()) | |
| 144 return result->value.newLocal(isolate); | |
| 145 | |
| 146 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | |
| 147 v8::HandleScope handleScope(isolate); | |
| 148 v8::Handle<v8::FunctionTemplate> templ = | |
| 149 ConfigureV8TestConstantsTemplate(data->rawTemplate(&info, currentWorldTy pe), isolate, currentWorldType); | |
| 150 data->templateMap(currentWorldType).add(&info, UnsafePersistent<v8::Function Template>(isolate, templ)); | |
| 151 return handleScope.Close(templ); | |
| 152 } | |
| 153 | |
| 154 bool V8TestConstants::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* isol ate, WrapperWorldType currentWorldType) | |
| 155 { | |
| 156 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor ldType); | |
| 157 } | |
| 158 | |
| 159 bool V8TestConstants::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::Iso late* isolate) | |
| 160 { | |
| 161 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) | |
| 162 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo rld) | |
| 163 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl d); | |
| 164 } | |
| 165 | |
| 166 v8::Handle<v8::Object> V8TestConstants::createWrapper(PassRefPtr<TestConstants> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | |
| 167 { | |
| 168 ASSERT(impl.get()); | |
| 169 ASSERT(!DOMDataStore::containsWrapper<V8TestConstants>(impl.get(), isolate)) ; | |
| 170 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | |
| 171 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get()); | |
| 172 // Might be a XXXConstructor::info instead of an XXX::info. These will b oth have | |
| 173 // the same object de-ref functions, though, so use that as the basis of the check. | |
| 174 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == info.derefObjectFunction); | |
| 175 } | |
| 176 | |
| 177 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &info, toInternalPointer(impl.get()), isolate); | |
| 178 if (UNLIKELY(wrapper.IsEmpty())) | |
| 179 return wrapper; | |
| 180 | |
| 181 installPerContextProperties(wrapper, impl.get(), isolate); | |
| 182 V8DOMWrapper::associateObjectWithWrapper<V8TestConstants>(impl, &info, wrapp er, isolate, WrapperConfiguration::Independent); | |
| 183 return wrapper; | |
| 184 } | |
| 185 | |
| 186 void V8TestConstants::derefObject(void* object) | |
| 187 { | |
| 188 fromInternalPointer(object)->deref(); | |
| 189 } | |
| 190 | |
| 191 } // namespace WebCore | |
| OLD | NEW |