OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 class V8ArrayBuffer { | 48 class V8ArrayBuffer { |
49 public: | 49 public: |
50 static bool HasInstance(v8::Handle<v8::Value>, v8::Isolate*, WrapperWorldTyp
e); | 50 static bool HasInstance(v8::Handle<v8::Value>, v8::Isolate*, WrapperWorldTyp
e); |
51 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); | 51 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); |
52 static ArrayBuffer* toNative(v8::Handle<v8::Object>); | 52 static ArrayBuffer* toNative(v8::Handle<v8::Object>); |
53 static void derefObject(void*); | 53 static void derefObject(void*); |
54 static WrapperTypeInfo info; | 54 static WrapperTypeInfo info; |
55 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount; | 55 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount; |
56 static void installPerContextProperties(v8::Handle<v8::Object>, ArrayBuffer*
, v8::Isolate*) { } | 56 static void installPerContextProperties(v8::Handle<v8::Object>, ArrayBuffer*
, v8::Isolate*) { } |
57 static void installPerContextPrototypeProperties(v8::Handle<v8::Object>, v8:
:Isolate*) { } | 57 static void installPerContextPrototypeProperties(v8::Handle<v8::Object>, v8:
:Isolate*) { } |
| 58 |
| 59 static inline void* toInternalPointer(ArrayBuffer* impl) |
| 60 { |
| 61 return impl; |
| 62 } |
| 63 |
| 64 static inline ArrayBuffer* fromInternalPointer(void* impl) |
| 65 { |
| 66 return static_cast<ArrayBuffer*>(impl); |
| 67 } |
| 68 |
58 private: | 69 private: |
59 friend v8::Handle<v8::Object> wrap(ArrayBuffer*, v8::Handle<v8::Object> crea
tionContext, v8::Isolate*); | 70 friend v8::Handle<v8::Object> wrap(ArrayBuffer*, v8::Handle<v8::Object> crea
tionContext, v8::Isolate*); |
60 static v8::Handle<v8::Object> createWrapper(PassRefPtr<ArrayBuffer>, v8::Han
dle<v8::Object> creationContext, v8::Isolate*); | 71 static v8::Handle<v8::Object> createWrapper(PassRefPtr<ArrayBuffer>, v8::Han
dle<v8::Object> creationContext, v8::Isolate*); |
61 }; | 72 }; |
62 | 73 |
63 template<> | 74 template<> |
64 class WrapperTypeTraits<ArrayBuffer > { | 75 class WrapperTypeTraits<ArrayBuffer > { |
65 public: | 76 public: |
66 static WrapperTypeInfo* info() { return &V8ArrayBuffer::info; } | 77 static WrapperTypeInfo* info() { return &V8ArrayBuffer::info; } |
67 }; | 78 }; |
68 | 79 |
69 | 80 |
70 inline v8::Handle<v8::Object> wrap(ArrayBuffer* impl, v8::Handle<v8::Object> cre
ationContext, v8::Isolate* isolate) | 81 inline v8::Handle<v8::Object> wrap(ArrayBuffer* impl, v8::Handle<v8::Object> cre
ationContext, v8::Isolate* isolate) |
71 { | 82 { |
72 ASSERT(impl); | 83 ASSERT(impl); |
73 ASSERT(DOMDataStore::getWrapper(impl, isolate).IsEmpty()); | 84 ASSERT(DOMDataStore::getWrapper<V8ArrayBuffer>(impl, isolate).IsEmpty()); |
74 return V8ArrayBuffer::createWrapper(impl, creationContext, isolate); | 85 return V8ArrayBuffer::createWrapper(impl, creationContext, isolate); |
75 } | 86 } |
76 | 87 |
77 inline v8::Handle<v8::Value> toV8(ArrayBuffer* impl, v8::Handle<v8::Object> crea
tionContext, v8::Isolate* isolate) | 88 inline v8::Handle<v8::Value> toV8(ArrayBuffer* impl, v8::Handle<v8::Object> crea
tionContext, v8::Isolate* isolate) |
78 { | 89 { |
79 if (UNLIKELY(!impl)) | 90 if (UNLIKELY(!impl)) |
80 return v8NullWithCheck(isolate); | 91 return v8NullWithCheck(isolate); |
81 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); | 92 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper<V8ArrayBuffer>(impl
, isolate); |
82 if (!wrapper.IsEmpty()) | 93 if (!wrapper.IsEmpty()) |
83 return wrapper; | 94 return wrapper; |
84 return wrap(impl, creationContext, isolate); | 95 return wrap(impl, creationContext, isolate); |
85 } | 96 } |
86 | 97 |
87 inline v8::Handle<v8::Value> toV8ForMainWorld(ArrayBuffer* impl, v8::Handle<v8::
Object> creationContext, v8::Isolate* isolate) | 98 inline v8::Handle<v8::Value> toV8ForMainWorld(ArrayBuffer* impl, v8::Handle<v8::
Object> creationContext, v8::Isolate* isolate) |
88 { | 99 { |
89 ASSERT(worldType(isolate) == MainWorld); | 100 ASSERT(worldType(isolate) == MainWorld); |
90 if (UNLIKELY(!impl)) | 101 if (UNLIKELY(!impl)) |
91 return v8NullWithCheck(isolate); | 102 return v8NullWithCheck(isolate); |
92 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapperForMainWorld(impl); | 103 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapperForMainWorld<V8Array
Buffer>(impl); |
93 if (!wrapper.IsEmpty()) | 104 if (!wrapper.IsEmpty()) |
94 return wrapper; | 105 return wrapper; |
95 return wrap(impl, creationContext, isolate); | 106 return wrap(impl, creationContext, isolate); |
96 } | 107 } |
97 | 108 |
98 template<class HolderContainer, class Wrappable> | 109 template<class HolderContainer, class Wrappable> |
99 inline v8::Handle<v8::Value> toV8Fast(ArrayBuffer* impl, const HolderContainer&
container, Wrappable* wrappable) | 110 inline v8::Handle<v8::Value> toV8Fast(ArrayBuffer* impl, const HolderContainer&
container, Wrappable* wrappable) |
100 { | 111 { |
101 if (UNLIKELY(!impl)) | 112 if (UNLIKELY(!impl)) |
102 return v8::Null(container.GetIsolate()); | 113 return v8::Null(container.GetIsolate()); |
103 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperFast(impl, containe
r, wrappable); | 114 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperFast<V8ArrayBuffer>
(impl, container, wrappable); |
104 if (!wrapper.IsEmpty()) | 115 if (!wrapper.IsEmpty()) |
105 return wrapper; | 116 return wrapper; |
106 return wrap(impl, container.Holder(), container.GetIsolate()); | 117 return wrap(impl, container.Holder(), container.GetIsolate()); |
107 } | 118 } |
108 | 119 |
109 template<class HolderContainer, class Wrappable> | 120 template<class HolderContainer, class Wrappable> |
110 inline v8::Handle<v8::Value> toV8FastForMainWorld(ArrayBuffer* impl, const Holde
rContainer& container, Wrappable* wrappable) | 121 inline v8::Handle<v8::Value> toV8FastForMainWorld(ArrayBuffer* impl, const Holde
rContainer& container, Wrappable* wrappable) |
111 { | 122 { |
112 ASSERT(worldType(container.GetIsolate()) == MainWorld); | 123 ASSERT(worldType(container.GetIsolate()) == MainWorld); |
113 if (UNLIKELY(!impl)) | 124 if (UNLIKELY(!impl)) |
114 return v8Null(container.GetIsolate()); | 125 return v8Null(container.GetIsolate()); |
115 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperForMainWorld(impl); | 126 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperForMainWorld<V8Arra
yBuffer>(impl); |
116 if (!wrapper.IsEmpty()) | 127 if (!wrapper.IsEmpty()) |
117 return wrapper; | 128 return wrapper; |
118 return wrap(impl, container.Holder(), container.GetIsolate()); | 129 return wrap(impl, container.Holder(), container.GetIsolate()); |
119 } | 130 } |
120 | 131 |
121 template<class HolderContainer, class Wrappable> | 132 template<class HolderContainer, class Wrappable> |
122 inline v8::Handle<v8::Value> toV8FastForMainWorld(PassRefPtr< ArrayBuffer > impl
, const HolderContainer& container, Wrappable* wrappable) | 133 inline v8::Handle<v8::Value> toV8FastForMainWorld(PassRefPtr< ArrayBuffer > impl
, const HolderContainer& container, Wrappable* wrappable) |
123 { | 134 { |
124 return toV8FastForMainWorld(impl.get(), container, wrappable); | 135 return toV8FastForMainWorld(impl.get(), container, wrappable); |
125 } | 136 } |
126 | 137 |
127 | 138 |
128 template<class HolderContainer, class Wrappable> | 139 template<class HolderContainer, class Wrappable> |
129 inline v8::Handle<v8::Value> toV8Fast(PassRefPtr< ArrayBuffer > impl, const Hold
erContainer& container, Wrappable* wrappable) | 140 inline v8::Handle<v8::Value> toV8Fast(PassRefPtr< ArrayBuffer > impl, const Hold
erContainer& container, Wrappable* wrappable) |
130 { | 141 { |
131 return toV8Fast(impl.get(), container, wrappable); | 142 return toV8Fast(impl.get(), container, wrappable); |
132 } | 143 } |
133 | 144 |
134 inline v8::Handle<v8::Value> toV8(PassRefPtr< ArrayBuffer > impl, v8::Handle<v8:
:Object> creationContext, v8::Isolate* isolate) | 145 inline v8::Handle<v8::Value> toV8(PassRefPtr< ArrayBuffer > impl, v8::Handle<v8:
:Object> creationContext, v8::Isolate* isolate) |
135 { | 146 { |
136 return toV8(impl.get(), creationContext, isolate); | 147 return toV8(impl.get(), creationContext, isolate); |
137 } | 148 } |
138 | 149 |
139 } // namespace WebCore | 150 } // namespace WebCore |
140 | 151 |
141 #endif // V8ArrayBufferCustom_h | 152 #endif // V8ArrayBufferCustom_h |
OLD | NEW |