Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: Source/bindings/tests/results/V8TestInterfacePython2.cpp

Issue 196343032: Implement ImageData constructors. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Generate code that custom wrap()s constructor instances Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 18 matching lines...) Expand all
29 */ 29 */
30 30
31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY! 31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY!
32 32
33 #include "config.h" 33 #include "config.h"
34 #include "V8TestInterfacePython2.h" 34 #include "V8TestInterfacePython2.h"
35 35
36 #include "RuntimeEnabledFeatures.h" 36 #include "RuntimeEnabledFeatures.h"
37 #include "V8Interface1.h" 37 #include "V8Interface1.h"
38 #include "V8Interface2.h" 38 #include "V8Interface2.h"
39 #include "V8int.h"
39 #include "bindings/v8/ExceptionState.h" 40 #include "bindings/v8/ExceptionState.h"
40 #include "bindings/v8/V8DOMConfiguration.h" 41 #include "bindings/v8/V8DOMConfiguration.h"
41 #include "bindings/v8/V8GCController.h" 42 #include "bindings/v8/V8GCController.h"
42 #include "bindings/v8/V8HiddenValue.h" 43 #include "bindings/v8/V8HiddenValue.h"
43 #include "bindings/v8/V8ObjectConstructor.h" 44 #include "bindings/v8/V8ObjectConstructor.h"
44 #include "core/dom/ContextFeatures.h" 45 #include "core/dom/ContextFeatures.h"
45 #include "core/dom/Document.h" 46 #include "core/dom/Document.h"
46 #include "core/dom/Element.h" 47 #include "core/dom/Element.h"
48 #include "core/frame/DOMWindow.h"
47 #include "platform/TraceEvent.h" 49 #include "platform/TraceEvent.h"
48 #include "wtf/GetPtr.h" 50 #include "wtf/GetPtr.h"
49 #include "wtf/RefPtr.h" 51 #include "wtf/RefPtr.h"
50 52
51 namespace WebCore { 53 namespace WebCore {
52 54
53 static void initializeScriptWrappableForInterface(TestInterfacePython2* object) 55 static void initializeScriptWrappableForInterface(TestInterfacePython2* object)
54 { 56 {
55 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 57 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
56 ScriptWrappable::setTypeInfoInObject(object, &V8TestInterfacePython2::wr apperTypeInfo); 58 ScriptWrappable::setTypeInfoInObject(object, &V8TestInterfacePython2::wr apperTypeInfo);
(...skipping 12 matching lines...) Expand all
69 WebCore::initializeScriptWrappableForInterface(object); 71 WebCore::initializeScriptWrappableForInterface(object);
70 } 72 }
71 73
72 namespace WebCore { 74 namespace WebCore {
73 const WrapperTypeInfo V8TestInterfacePython2::wrapperTypeInfo = { gin::kEmbedder Blink, V8TestInterfacePython2::domTemplate, V8TestInterfacePython2::derefObject, 0, 0, V8TestInterfacePython2::visitDOMWrapper, V8TestInterfacePython2::installP erContextEnabledMethods, 0, WrapperTypeObjectPrototype, false }; 75 const WrapperTypeInfo V8TestInterfacePython2::wrapperTypeInfo = { gin::kEmbedder Blink, V8TestInterfacePython2::domTemplate, V8TestInterfacePython2::derefObject, 0, 0, V8TestInterfacePython2::visitDOMWrapper, V8TestInterfacePython2::installP erContextEnabledMethods, 0, WrapperTypeObjectPrototype, false };
74 76
75 namespace TestInterfacePython2V8Internal { 77 namespace TestInterfacePython2V8Internal {
76 78
77 template <typename T> void V8_USE(T) { } 79 template <typename T> void V8_USE(T) { }
78 80
81 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
82 {
83 if (UNLIKELY(info.Length() < 1)) {
84 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfacePython 2", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate()) ;
85 return;
86 }
87 V8TRYCATCH_VOID(int*, width, V8int::toNativeWithTypeCheck(info.GetIsolate(), info[0]));
88 RefPtr<TestInterfacePython2> impl = TestInterfacePython2::create(width);
89
90 v8SetReturnValue(info, wrap(impl.get(), info.Holder(), info.GetIsolate()));
91 }
92
79 } // namespace TestInterfacePython2V8Internal 93 } // namespace TestInterfacePython2V8Internal
80 94
81 void V8TestInterfacePython2::visitDOMWrapper(void* object, const v8::Persistent< v8::Object>& wrapper, v8::Isolate* isolate) 95 void V8TestInterfacePython2::visitDOMWrapper(void* object, const v8::Persistent< v8::Object>& wrapper, v8::Isolate* isolate)
82 { 96 {
83 TestInterfacePython2* impl = fromInternalPointer(object); 97 TestInterfacePython2* impl = fromInternalPointer(object);
84 // The ownerNode() method may return a reference or a pointer. 98 // The ownerNode() method may return a reference or a pointer.
85 if (Node* owner = WTF::getPtr(impl->ownerNode())) { 99 if (Node* owner = WTF::getPtr(impl->ownerNode())) {
86 Node* root = V8GCController::opaqueRootForGC(owner, isolate); 100 Node* root = V8GCController::opaqueRootForGC(owner, isolate);
87 isolate->SetReferenceFromGroup(v8::UniqueId(reinterpret_cast<intptr_t>(r oot)), wrapper); 101 isolate->SetReferenceFromGroup(v8::UniqueId(reinterpret_cast<intptr_t>(r oot)), wrapper);
88 return; 102 return;
89 } 103 }
90 setObjectGroup(object, wrapper, isolate); 104 setObjectGroup(object, wrapper, isolate);
91 } 105 }
92 106
107 void V8TestInterfacePython2::constructorCallback(const v8::FunctionCallbackInfo< v8::Value>& info)
108 {
109 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor");
110 if (!info.IsConstructCall()) {
111 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfacePython 2", "Please use the 'new' operator, this DOM object constructor cannot be called as a function."), info.GetIsolate());
112 return;
113 }
114
115 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) {
116 v8SetReturnValue(info, info.Holder());
117 return;
118 }
119
120 TestInterfacePython2V8Internal::constructor(info);
121 }
122
93 static void configureV8TestInterfacePython2Template(v8::Handle<v8::FunctionTempl ate> functionTemplate, v8::Isolate* isolate) 123 static void configureV8TestInterfacePython2Template(v8::Handle<v8::FunctionTempl ate> functionTemplate, v8::Isolate* isolate)
94 { 124 {
95 functionTemplate->ReadOnlyPrototype(); 125 functionTemplate->ReadOnlyPrototype();
96 126
97 v8::Local<v8::Signature> defaultSignature; 127 v8::Local<v8::Signature> defaultSignature;
98 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "TestInterfacePython2", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceP ython2::internalFieldCount, 128 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "TestInterfacePython2", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceP ython2::internalFieldCount,
99 0, 0, 129 0, 0,
100 0, 0, 130 0, 0,
101 0, 0, 131 0, 0,
102 isolate); 132 isolate);
133 functionTemplate->SetCallHandler(V8TestInterfacePython2::constructorCallback );
134 functionTemplate->SetLength(1);
103 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla te->InstanceTemplate(); 135 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla te->InstanceTemplate();
104 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl ate->PrototypeTemplate(); 136 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl ate->PrototypeTemplate();
105 137
106 // Custom toString template 138 // Custom toString template
107 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData: :current()->toStringTemplate()); 139 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData: :current()->toStringTemplate());
108 } 140 }
109 141
110 v8::Handle<v8::FunctionTemplate> V8TestInterfacePython2::domTemplate(v8::Isolate * isolate) 142 v8::Handle<v8::FunctionTemplate> V8TestInterfacePython2::domTemplate(v8::Isolate * isolate)
111 { 143 {
112 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 144 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 fromInternalPointer(object)->deref(); 204 fromInternalPointer(object)->deref();
173 } 205 }
174 206
175 template<> 207 template<>
176 v8::Handle<v8::Value> toV8NoInline(TestInterfacePython2* impl, v8::Handle<v8::Ob ject> creationContext, v8::Isolate* isolate) 208 v8::Handle<v8::Value> toV8NoInline(TestInterfacePython2* impl, v8::Handle<v8::Ob ject> creationContext, v8::Isolate* isolate)
177 { 209 {
178 return toV8(impl, creationContext, isolate); 210 return toV8(impl, creationContext, isolate);
179 } 211 }
180 212
181 } // namespace WebCore 213 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698