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

Side by Side Diff: Source/bindings/v8/custom/V8TypedArrayCustom.h

Issue 39393004: IDL compiler: rename WrapperTypeInfo info => wrapperTypeInfo (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return TypedArrayTraits<TypedArray>::IsInstance(value); 52 return TypedArrayTraits<TypedArray>::IsInstance(value);
53 } 53 }
54 54
55 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::Isolate*) 55 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::Isolate*)
56 { 56 {
57 return TypedArrayTraits<TypedArray>::IsInstance(value); 57 return TypedArrayTraits<TypedArray>::IsInstance(value);
58 } 58 }
59 59
60 static TypedArray* toNative(v8::Handle<v8::Object>); 60 static TypedArray* toNative(v8::Handle<v8::Object>);
61 static void derefObject(void*); 61 static void derefObject(void*);
62 static WrapperTypeInfo info; 62 static WrapperTypeInfo wrapperTypeInfo;
63 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount; 63 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount;
64 64
65 static v8::Handle<v8::Object> wrap(TypedArray* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 65 static v8::Handle<v8::Object> wrap(TypedArray* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
66 { 66 {
67 ASSERT(impl); 67 ASSERT(impl);
68 ASSERT(!DOMDataStore::containsWrapper<Binding>(impl, isolate)); 68 ASSERT(!DOMDataStore::containsWrapper<Binding>(impl, isolate));
69 return V8TypedArray<TypedArray>::createWrapper(impl, creationContext, is olate); 69 return V8TypedArray<TypedArray>::createWrapper(impl, creationContext, is olate);
70 } 70 }
71 71
72 static v8::Handle<v8::Value> toV8(TypedArray* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 72 static v8::Handle<v8::Value> toV8(TypedArray* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 typedef TypedArrayTraits<TypedArray> Traits; 127 typedef TypedArrayTraits<TypedArray> Traits;
128 typedef typename Traits::V8Type V8Type; 128 typedef typename Traits::V8Type V8Type;
129 typedef V8TypedArray<TypedArray> Binding; 129 typedef V8TypedArray<TypedArray> Binding;
130 130
131 static v8::Handle<v8::Object> createWrapper(PassRefPtr<TypedArray>, v8::Hand le<v8::Object> creationContext, v8::Isolate*); 131 static v8::Handle<v8::Object> createWrapper(PassRefPtr<TypedArray>, v8::Hand le<v8::Object> creationContext, v8::Isolate*);
132 }; 132 };
133 133
134 template<typename TypedArray> 134 template<typename TypedArray>
135 class TypedArrayWrapperTraits { 135 class TypedArrayWrapperTraits {
136 public: 136 public:
137 static WrapperTypeInfo* info() { return &V8TypedArray<TypedArray>::info; } 137 static WrapperTypeInfo* info() { return &V8TypedArray<TypedArray>::wrapperTy peInfo; }
138 }; 138 };
139 139
140 140
141 template <typename TypedArray> 141 template <typename TypedArray>
142 v8::Handle<v8::Object> V8TypedArray<TypedArray>::createWrapper(PassRefPtr<TypedA rray> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 142 v8::Handle<v8::Object> V8TypedArray<TypedArray>::createWrapper(PassRefPtr<TypedA rray> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
143 { 143 {
144 ASSERT(impl.get()); 144 ASSERT(impl.get());
145 ASSERT(!DOMDataStore::containsWrapper<Binding>(impl.get(), isolate)); 145 ASSERT(!DOMDataStore::containsWrapper<Binding>(impl.get(), isolate));
146 146
147 RefPtr<ArrayBuffer> buffer = impl->buffer(); 147 RefPtr<ArrayBuffer> buffer = impl->buffer();
148 v8::Local<v8::Value> v8Buffer = WebCore::toV8(buffer.get(), creationContext, isolate); 148 v8::Local<v8::Value> v8Buffer = WebCore::toV8(buffer.get(), creationContext, isolate);
149 149
150 ASSERT(v8Buffer->IsArrayBuffer()); 150 ASSERT(v8Buffer->IsArrayBuffer());
151 151
152 v8::Local<v8::Object> wrapper = V8Type::New(v8Buffer.As<v8::ArrayBuffer>(), impl->byteOffset(), Traits::length(impl.get())); 152 v8::Local<v8::Object> wrapper = V8Type::New(v8Buffer.As<v8::ArrayBuffer>(), impl->byteOffset(), Traits::length(impl.get()));
153 153
154 V8DOMWrapper::associateObjectWithWrapper<Binding>(impl, &info, wrapper, isol ate, WrapperConfiguration::Independent); 154 V8DOMWrapper::associateObjectWithWrapper<Binding>(impl, &wrapperTypeInfo, wr apper, isolate, WrapperConfiguration::Independent);
155 return wrapper; 155 return wrapper;
156 } 156 }
157 157
158 template <typename TypedArray> 158 template <typename TypedArray>
159 TypedArray* V8TypedArray<TypedArray>::toNative(v8::Handle<v8::Object> object) 159 TypedArray* V8TypedArray<TypedArray>::toNative(v8::Handle<v8::Object> object)
160 { 160 {
161 ASSERT(Traits::IsInstance(object)); 161 ASSERT(Traits::IsInstance(object));
162 void* typedarrayPtr = object->GetAlignedPointerFromInternalField(v8DOMWrappe rObjectIndex); 162 void* typedarrayPtr = object->GetAlignedPointerFromInternalField(v8DOMWrappe rObjectIndex);
163 if (typedarrayPtr) 163 if (typedarrayPtr)
164 return reinterpret_cast<TypedArray*>(typedarrayPtr); 164 return reinterpret_cast<TypedArray*>(typedarrayPtr);
165 165
166 v8::Handle<V8Type> view = object.As<V8Type>(); 166 v8::Handle<V8Type> view = object.As<V8Type>();
167 RefPtr<ArrayBuffer> arrayBuffer = V8ArrayBuffer::toNative(view->Buffer()); 167 RefPtr<ArrayBuffer> arrayBuffer = V8ArrayBuffer::toNative(view->Buffer());
168 RefPtr<TypedArray> typedArray = TypedArray::create(arrayBuffer, view->ByteOf fset(), Traits::length(view)); 168 RefPtr<TypedArray> typedArray = TypedArray::create(arrayBuffer, view->ByteOf fset(), Traits::length(view));
169 ASSERT(typedArray.get()); 169 ASSERT(typedArray.get());
170 V8DOMWrapper::associateObjectWithWrapper<Binding>(typedArray.release(), &inf o, object, v8::Isolate::GetCurrent(), WrapperConfiguration::Independent); 170 V8DOMWrapper::associateObjectWithWrapper<Binding>(typedArray.release(), &wra pperTypeInfo, object, v8::Isolate::GetCurrent(), WrapperConfiguration::Independe nt);
171 171
172 typedarrayPtr = object->GetAlignedPointerFromInternalField(v8DOMWrapperObjec tIndex); 172 typedarrayPtr = object->GetAlignedPointerFromInternalField(v8DOMWrapperObjec tIndex);
173 ASSERT(typedarrayPtr); 173 ASSERT(typedarrayPtr);
174 return reinterpret_cast<TypedArray*>(typedarrayPtr); 174 return reinterpret_cast<TypedArray*>(typedarrayPtr);
175 } 175 }
176 176
177 177
178 template <typename TypedArray> 178 template <typename TypedArray>
179 WrapperTypeInfo V8TypedArray<TypedArray>::info = { 179 WrapperTypeInfo V8TypedArray<TypedArray>::wrapperTypeInfo = {
180 0, V8TypedArray<TypedArray>::derefObject, 180 0, V8TypedArray<TypedArray>::derefObject,
181 0, 0, 0, 0, 0, WrapperTypeObjectPrototype 181 0, 0, 0, 0, 0, WrapperTypeObjectPrototype
182 }; 182 };
183 183
184 template <typename TypedArray> 184 template <typename TypedArray>
185 void V8TypedArray<TypedArray>::derefObject(void* object) 185 void V8TypedArray<TypedArray>::derefObject(void* object)
186 { 186 {
187 static_cast<TypedArray*>(object)->deref(); 187 static_cast<TypedArray*>(object)->deref();
188 } 188 }
189 189
190 190
191 } // namespace WebCode 191 } // namespace WebCode
192 192
193 #endif // V8TypedArrayCustom_h 193 #endif // V8TypedArrayCustom_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/custom/V8PromiseCustom.cpp ('k') | Source/bindings/v8/custom/V8WebKitPointCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698