OLD | NEW |
---|---|
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 2307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2318 Handle<Value> GetScriptId() const; | 2318 Handle<Value> GetScriptId() const; |
2319 ScriptOrigin GetScriptOrigin() const; | 2319 ScriptOrigin GetScriptOrigin() const; |
2320 V8_INLINE(static Function* Cast(Value* obj)); | 2320 V8_INLINE(static Function* Cast(Value* obj)); |
2321 static const int kLineOffsetNotFound; | 2321 static const int kLineOffsetNotFound; |
2322 | 2322 |
2323 private: | 2323 private: |
2324 Function(); | 2324 Function(); |
2325 static void CheckCast(Value* obj); | 2325 static void CheckCast(Value* obj); |
2326 }; | 2326 }; |
2327 | 2327 |
2328 /** | |
2329 * The contents of an |ArrayBuffer|. Externalization of |ArrayBuffer| | |
2330 * populates an instance of this class with a pointer to data and byte length. | |
2331 * | |
2332 * |ArrayBufferContents| is the owner of its data. When an instance of | |
2333 * this class is destructed, the |Data| is freed. | |
2334 * | |
2335 * This API is experimental and may change significantly. | |
2336 */ | |
2337 class V8EXPORT ArrayBufferContents { | |
2338 public: | |
2339 void* Data() const { return data_; } | |
2340 size_t ByteLength() const { return byte_length_; } | |
2341 | |
2342 ArrayBufferContents() : data_(NULL), byte_length_(0) {} | |
Sven Panne
2013/05/23 07:57:01
Nit: We usually put the constructor/destructor at
Dmitry Lomov (no reviews)
2013/05/23 08:42:15
Done.
| |
2343 ~ArrayBufferContents(); | |
2344 | |
2345 private: | |
2346 ArrayBufferContents(void* data, size_t byte_length) | |
2347 : data_(data), byte_length_(byte_length) | |
2348 { } | |
Sven Panne
2013/05/23 07:57:01
Nit: Put this at the end of the initializer list.
Dmitry Lomov (no reviews)
2013/05/23 08:42:15
Done.
| |
2349 | |
2350 void* data_; | |
2351 size_t byte_length_; | |
2352 | |
2353 friend class ArrayBuffer; | |
2354 }; | |
2355 | |
2356 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT | |
2357 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 | |
2358 #endif | |
2328 | 2359 |
2329 /** | 2360 /** |
2330 * An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5). | 2361 * An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5). |
2331 * This API is experimental and may change significantly. | 2362 * This API is experimental and may change significantly. |
2332 */ | 2363 */ |
2333 class V8EXPORT ArrayBuffer : public Object { | 2364 class V8EXPORT ArrayBuffer : public Object { |
2334 public: | 2365 public: |
2335 /** | 2366 /** |
2336 * Data length in bytes. | 2367 * Data length in bytes. |
2337 */ | 2368 */ |
2338 size_t ByteLength() const; | 2369 size_t ByteLength() const; |
2339 /** | |
2340 * Raw pointer to the array buffer data | |
2341 */ | |
2342 void* Data() const; | |
2343 | 2370 |
2344 /** | 2371 /** |
2345 * Create a new ArrayBuffer. Allocate |byte_length| bytes. | 2372 * Create a new ArrayBuffer. Allocate |byte_length| bytes. |
2346 * Allocated memory will be owned by a created ArrayBuffer and | 2373 * Allocated memory will be owned by a created ArrayBuffer and |
2347 * will be deallocated when it is garbage-collected. | 2374 * will be deallocated when it is garbage-collected, |
2375 * unless the object is externalized. | |
2348 */ | 2376 */ |
2349 static Local<ArrayBuffer> New(size_t byte_length); | 2377 static Local<ArrayBuffer> New(size_t byte_length); |
2350 | 2378 |
2351 /** | 2379 /** |
2352 * Create a new ArrayBuffer over an existing memory block. | 2380 * Create a new ArrayBuffer over an existing memory block. |
2381 * The created array buffer is immediately in externalized state. | |
2353 * The memory block will not be reclaimed when a created ArrayBuffer | 2382 * The memory block will not be reclaimed when a created ArrayBuffer |
2354 * is garbage-collected. | 2383 * is garbage-collected. |
2355 */ | 2384 */ |
2356 static Local<ArrayBuffer> New(void* data, size_t byte_length); | 2385 static Local<ArrayBuffer> New(void* data, size_t byte_length); |
2357 | 2386 |
2387 /** | |
2388 * Returns true if ArrayBuffer is extrenalized, that is, does not | |
2389 * own its memory block. | |
2390 */ | |
2391 bool IsExternal() const; | |
2392 | |
2393 /** | |
2394 * Pass the ownership of this ArrayBuffer's backing store to | |
2395 * a given ArrayBufferContents. | |
2396 */ | |
2397 void Externalize(ArrayBufferContents* contents); | |
2398 | |
2358 V8_INLINE(static ArrayBuffer* Cast(Value* obj)); | 2399 V8_INLINE(static ArrayBuffer* Cast(Value* obj)); |
2359 | 2400 |
2401 | |
2402 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; | |
2403 | |
2360 private: | 2404 private: |
2361 ArrayBuffer(); | 2405 ArrayBuffer(); |
2362 static void CheckCast(Value* obj); | 2406 static void CheckCast(Value* obj); |
2363 }; | 2407 }; |
2364 | 2408 |
2365 | 2409 |
2366 /** | 2410 /** |
2367 * A base class for an instance of TypedArray series of constructors | 2411 * A base class for an instance of TypedArray series of constructors |
2368 * (ES6 draft 15.13.6). | 2412 * (ES6 draft 15.13.6). |
2369 * This API is experimental and may change significantly. | 2413 * This API is experimental and may change significantly. |
(...skipping 3916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6286 | 6330 |
6287 | 6331 |
6288 } // namespace v8 | 6332 } // namespace v8 |
6289 | 6333 |
6290 | 6334 |
6291 #undef V8EXPORT | 6335 #undef V8EXPORT |
6292 #undef TYPE_CHECK | 6336 #undef TYPE_CHECK |
6293 | 6337 |
6294 | 6338 |
6295 #endif // V8_H_ | 6339 #endif // V8_H_ |
OLD | NEW |