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

Side by Side Diff: src/api.h

Issue 14195034: First cut at API for native Typed Arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Self-review Created 7 years, 7 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
« no previous file with comments | « include/v8.h ('k') | src/api.cc » ('j') | src/api.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 V(FunctionTemplate, FunctionTemplateInfo) \ 164 V(FunctionTemplate, FunctionTemplateInfo) \
165 V(ObjectTemplate, ObjectTemplateInfo) \ 165 V(ObjectTemplate, ObjectTemplateInfo) \
166 V(Signature, SignatureInfo) \ 166 V(Signature, SignatureInfo) \
167 V(AccessorSignature, FunctionTemplateInfo) \ 167 V(AccessorSignature, FunctionTemplateInfo) \
168 V(TypeSwitch, TypeSwitchInfo) \ 168 V(TypeSwitch, TypeSwitchInfo) \
169 V(Data, Object) \ 169 V(Data, Object) \
170 V(RegExp, JSRegExp) \ 170 V(RegExp, JSRegExp) \
171 V(Object, JSObject) \ 171 V(Object, JSObject) \
172 V(Array, JSArray) \ 172 V(Array, JSArray) \
173 V(ArrayBuffer, JSArrayBuffer) \ 173 V(ArrayBuffer, JSArrayBuffer) \
174 V(TypedArray, JSTypedArray) \
175 V(Uint8Array, JSTypedArray) \
176 V(Int8Array, JSTypedArray) \
177 V(Uint16Array, JSTypedArray) \
178 V(Int16Array, JSTypedArray) \
179 V(Uint32Array, JSTypedArray) \
180 V(Int32Array, JSTypedArray) \
181 V(Float32Array, JSTypedArray) \
182 V(Float64Array, JSTypedArray) \
174 V(String, String) \ 183 V(String, String) \
175 V(Symbol, Symbol) \ 184 V(Symbol, Symbol) \
176 V(Script, Object) \ 185 V(Script, Object) \
177 V(Function, JSFunction) \ 186 V(Function, JSFunction) \
178 V(Message, JSObject) \ 187 V(Message, JSObject) \
179 V(Context, Context) \ 188 V(Context, Context) \
180 V(External, Foreign) \ 189 V(External, Foreign) \
181 V(StackTrace, JSArray) \ 190 V(StackTrace, JSArray) \
182 V(StackFrame, JSObject) \ 191 V(StackFrame, JSObject) \
183 V(DeclaredAccessorDescriptor, DeclaredAccessorDescriptor) 192 V(DeclaredAccessorDescriptor, DeclaredAccessorDescriptor)
(...skipping 17 matching lines...) Expand all
201 static inline Local<Symbol> ToLocal( 210 static inline Local<Symbol> ToLocal(
202 v8::internal::Handle<v8::internal::Symbol> obj); 211 v8::internal::Handle<v8::internal::Symbol> obj);
203 static inline Local<RegExp> ToLocal( 212 static inline Local<RegExp> ToLocal(
204 v8::internal::Handle<v8::internal::JSRegExp> obj); 213 v8::internal::Handle<v8::internal::JSRegExp> obj);
205 static inline Local<Object> ToLocal( 214 static inline Local<Object> ToLocal(
206 v8::internal::Handle<v8::internal::JSObject> obj); 215 v8::internal::Handle<v8::internal::JSObject> obj);
207 static inline Local<Array> ToLocal( 216 static inline Local<Array> ToLocal(
208 v8::internal::Handle<v8::internal::JSArray> obj); 217 v8::internal::Handle<v8::internal::JSArray> obj);
209 static inline Local<ArrayBuffer> ToLocal( 218 static inline Local<ArrayBuffer> ToLocal(
210 v8::internal::Handle<v8::internal::JSArrayBuffer> obj); 219 v8::internal::Handle<v8::internal::JSArrayBuffer> obj);
220
221 static inline Local<TypedArray> ToLocal(
222 v8::internal::Handle<v8::internal::JSTypedArray> obj);
223 static inline Local<Uint8Array> ToLocalUint8Array(
224 v8::internal::Handle<v8::internal::JSTypedArray> obj);
225 static inline Local<Int8Array> ToLocalInt8Array(
226 v8::internal::Handle<v8::internal::JSTypedArray> obj);
227 static inline Local<Uint16Array> ToLocalUint16Array(
228 v8::internal::Handle<v8::internal::JSTypedArray> obj);
229 static inline Local<Int16Array> ToLocalInt16Array(
230 v8::internal::Handle<v8::internal::JSTypedArray> obj);
231 static inline Local<Uint32Array> ToLocalUint32Array(
232 v8::internal::Handle<v8::internal::JSTypedArray> obj);
233 static inline Local<Int32Array> ToLocalInt32Array(
234 v8::internal::Handle<v8::internal::JSTypedArray> obj);
235 static inline Local<Float32Array> ToLocalFloat32Array(
236 v8::internal::Handle<v8::internal::JSTypedArray> obj);
237 static inline Local<Float64Array> ToLocalFloat64Array(
238 v8::internal::Handle<v8::internal::JSTypedArray> obj);
239
211 static inline Local<Message> MessageToLocal( 240 static inline Local<Message> MessageToLocal(
212 v8::internal::Handle<v8::internal::Object> obj); 241 v8::internal::Handle<v8::internal::Object> obj);
213 static inline Local<StackTrace> StackTraceToLocal( 242 static inline Local<StackTrace> StackTraceToLocal(
214 v8::internal::Handle<v8::internal::JSArray> obj); 243 v8::internal::Handle<v8::internal::JSArray> obj);
215 static inline Local<StackFrame> StackFrameToLocal( 244 static inline Local<StackFrame> StackFrameToLocal(
216 v8::internal::Handle<v8::internal::JSObject> obj); 245 v8::internal::Handle<v8::internal::JSObject> obj);
217 static inline Local<Number> NumberToLocal( 246 static inline Local<Number> NumberToLocal(
218 v8::internal::Handle<v8::internal::Object> obj); 247 v8::internal::Handle<v8::internal::Object> obj);
219 static inline Local<Integer> IntegerToLocal( 248 static inline Local<Integer> IntegerToLocal(
220 v8::internal::Handle<v8::internal::Object> obj); 249 v8::internal::Handle<v8::internal::Object> obj);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 292
264 293
265 // Implementations of ToLocal 294 // Implementations of ToLocal
266 295
267 #define MAKE_TO_LOCAL(Name, From, To) \ 296 #define MAKE_TO_LOCAL(Name, From, To) \
268 Local<v8::To> Utils::Name(v8::internal::Handle<v8::internal::From> obj) { \ 297 Local<v8::To> Utils::Name(v8::internal::Handle<v8::internal::From> obj) { \
269 ASSERT(obj.is_null() || !obj->IsTheHole()); \ 298 ASSERT(obj.is_null() || !obj->IsTheHole()); \
270 return Local<To>(reinterpret_cast<To*>(obj.location())); \ 299 return Local<To>(reinterpret_cast<To*>(obj.location())); \
271 } 300 }
272 301
302
303 #define MAKE_TO_LOCAL_TYPED_ARRAY(TypedArray, typeConst) \
304 Local<v8::TypedArray> Utils::ToLocal##TypedArray( \
305 v8::internal::Handle<v8::internal::JSTypedArray> obj) { \
306 ASSERT(obj.is_null() || !obj->IsTheHole()); \
307 ASSERT(obj->type() == typeConst); \
308 return Local<v8::TypedArray>( \
309 reinterpret_cast<v8::TypedArray*>(obj.location())); \
310 }
311
312
273 MAKE_TO_LOCAL(ToLocal, Context, Context) 313 MAKE_TO_LOCAL(ToLocal, Context, Context)
274 MAKE_TO_LOCAL(ToLocal, Object, Value) 314 MAKE_TO_LOCAL(ToLocal, Object, Value)
275 MAKE_TO_LOCAL(ToLocal, JSFunction, Function) 315 MAKE_TO_LOCAL(ToLocal, JSFunction, Function)
276 MAKE_TO_LOCAL(ToLocal, String, String) 316 MAKE_TO_LOCAL(ToLocal, String, String)
277 MAKE_TO_LOCAL(ToLocal, Symbol, Symbol) 317 MAKE_TO_LOCAL(ToLocal, Symbol, Symbol)
278 MAKE_TO_LOCAL(ToLocal, JSRegExp, RegExp) 318 MAKE_TO_LOCAL(ToLocal, JSRegExp, RegExp)
279 MAKE_TO_LOCAL(ToLocal, JSObject, Object) 319 MAKE_TO_LOCAL(ToLocal, JSObject, Object)
280 MAKE_TO_LOCAL(ToLocal, JSArray, Array) 320 MAKE_TO_LOCAL(ToLocal, JSArray, Array)
281 MAKE_TO_LOCAL(ToLocal, JSArrayBuffer, ArrayBuffer) 321 MAKE_TO_LOCAL(ToLocal, JSArrayBuffer, ArrayBuffer)
322 MAKE_TO_LOCAL(ToLocal, JSTypedArray, TypedArray)
323
324 MAKE_TO_LOCAL_TYPED_ARRAY(Uint8Array, kExternalUnsignedByteArray)
325 MAKE_TO_LOCAL_TYPED_ARRAY(Int8Array, kExternalByteArray)
326 MAKE_TO_LOCAL_TYPED_ARRAY(Uint16Array, kExternalUnsignedShortArray)
327 MAKE_TO_LOCAL_TYPED_ARRAY(Int16Array, kExternalShortArray)
328 MAKE_TO_LOCAL_TYPED_ARRAY(Uint32Array, kExternalUnsignedIntArray)
329 MAKE_TO_LOCAL_TYPED_ARRAY(Int32Array, kExternalIntArray)
330 MAKE_TO_LOCAL_TYPED_ARRAY(Float32Array, kExternalFloatArray)
331 MAKE_TO_LOCAL_TYPED_ARRAY(Float64Array, kExternalDoubleArray)
332
282 MAKE_TO_LOCAL(ToLocal, FunctionTemplateInfo, FunctionTemplate) 333 MAKE_TO_LOCAL(ToLocal, FunctionTemplateInfo, FunctionTemplate)
283 MAKE_TO_LOCAL(ToLocal, ObjectTemplateInfo, ObjectTemplate) 334 MAKE_TO_LOCAL(ToLocal, ObjectTemplateInfo, ObjectTemplate)
284 MAKE_TO_LOCAL(ToLocal, SignatureInfo, Signature) 335 MAKE_TO_LOCAL(ToLocal, SignatureInfo, Signature)
285 MAKE_TO_LOCAL(AccessorSignatureToLocal, FunctionTemplateInfo, AccessorSignature) 336 MAKE_TO_LOCAL(AccessorSignatureToLocal, FunctionTemplateInfo, AccessorSignature)
286 MAKE_TO_LOCAL(ToLocal, TypeSwitchInfo, TypeSwitch) 337 MAKE_TO_LOCAL(ToLocal, TypeSwitchInfo, TypeSwitch)
287 MAKE_TO_LOCAL(MessageToLocal, Object, Message) 338 MAKE_TO_LOCAL(MessageToLocal, Object, Message)
288 MAKE_TO_LOCAL(StackTraceToLocal, JSArray, StackTrace) 339 MAKE_TO_LOCAL(StackTraceToLocal, JSArray, StackTrace)
289 MAKE_TO_LOCAL(StackFrameToLocal, JSObject, StackFrame) 340 MAKE_TO_LOCAL(StackFrameToLocal, JSObject, StackFrame)
290 MAKE_TO_LOCAL(NumberToLocal, Object, Number) 341 MAKE_TO_LOCAL(NumberToLocal, Object, Number)
291 MAKE_TO_LOCAL(IntegerToLocal, Object, Integer) 342 MAKE_TO_LOCAL(IntegerToLocal, Object, Integer)
292 MAKE_TO_LOCAL(Uint32ToLocal, Object, Uint32) 343 MAKE_TO_LOCAL(Uint32ToLocal, Object, Uint32)
293 MAKE_TO_LOCAL(ExternalToLocal, JSObject, External) 344 MAKE_TO_LOCAL(ExternalToLocal, JSObject, External)
294 MAKE_TO_LOCAL(ToLocal, DeclaredAccessorDescriptor, DeclaredAccessorDescriptor) 345 MAKE_TO_LOCAL(ToLocal, DeclaredAccessorDescriptor, DeclaredAccessorDescriptor)
295 346
347 #undef MAKE_TO_LOCAL_TYPED_ARRAY
296 #undef MAKE_TO_LOCAL 348 #undef MAKE_TO_LOCAL
297 349
298 350
299 // Implementations of OpenHandle 351 // Implementations of OpenHandle
300 352
301 #define MAKE_OPEN_HANDLE(From, To) \ 353 #define MAKE_OPEN_HANDLE(From, To) \
302 v8::internal::Handle<v8::internal::To> Utils::OpenHandle( \ 354 v8::internal::Handle<v8::internal::To> Utils::OpenHandle( \
303 const v8::From* that, bool allow_empty_handle) { \ 355 const v8::From* that, bool allow_empty_handle) { \
304 EXTRA_CHECK(allow_empty_handle || that != NULL); \ 356 EXTRA_CHECK(allow_empty_handle || that != NULL); \
305 EXTRA_CHECK(that == NULL || \ 357 EXTRA_CHECK(that == NULL || \
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 stress_type_ = stress_type; 652 stress_type_ = stress_type;
601 } 653 }
602 654
603 private: 655 private:
604 static v8::Testing::StressType stress_type_; 656 static v8::Testing::StressType stress_type_;
605 }; 657 };
606 658
607 } } // namespace v8::internal 659 } } // namespace v8::internal
608 660
609 #endif // V8_API_H_ 661 #endif // V8_API_H_
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/api.cc » ('j') | src/api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698