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

Side by Side Diff: include/v8.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, 8 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 | « no previous file | src/api.h » ('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 2029 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 2040
2041 V8_INLINE(static ArrayBuffer* Cast(Value* obj)); 2041 V8_INLINE(static ArrayBuffer* Cast(Value* obj));
2042 2042
2043 private: 2043 private:
2044 ArrayBuffer(); 2044 ArrayBuffer();
2045 static void CheckCast(Value* obj); 2045 static void CheckCast(Value* obj);
2046 }; 2046 };
2047 2047
2048 2048
2049 /** 2049 /**
2050 * A base class for an instance of TypedArray series of constructors
2051 * (ES6 draft 15.13.6).
2052 * This API is experimental and may change significantly.
2053 */
2054 class V8EXPORT TypedArray : public Object {
2055 public:
2056 /**
2057 * Returns underlying ArrayBuffer.
2058 */
2059 Local<ArrayBuffer> Buffer();
2060 /**
2061 * Byte offset in |Buffer|
2062 */
2063 size_t ByteOffset();
2064 /**
2065 * Numbe of elements in this typed array.
2066 */
2067 size_t Length();
2068 /**
2069 * Size of typed array in bytes (e.g. for Int16Array, 2*|Length|).
2070 */
2071 size_t ByteLength();
2072 /**
2073 * Base address of typed array.
2074 */
2075 void* BaseAddress();
2076
2077 V8_INLINE(static TypedArray* Cast(Value* obj));
2078
2079 private:
2080 TypedArray();
2081 static void CheckCast(Value* obj);
2082 };
2083
2084
2085 /**
2086 * An instance of Uint8Array constructor (ES6 draft 15.13.6).
2087 * This API is experimental and may change significantly.
2088 */
2089 class V8EXPORT Uint8Array : public TypedArray {
2090 public:
2091 static Local<Uint8Array> New(Handle<ArrayBuffer> array_buffer,
2092 size_t byte_offset, size_t length);
2093 V8_INLINE(static Uint8Array* Cast(Value* obj));
2094
2095 private:
2096 Uint8Array();
2097 static void CheckCast(Value* obj);
2098 };
2099
2100
2101 /**
2102 * An instance of Int8Array constructor (ES6 draft 15.13.6).
2103 * This API is experimental and may change significantly.
2104 */
2105 class V8EXPORT Int8Array : public TypedArray {
2106 public:
2107 static Local<Int8Array> New(Handle<ArrayBuffer> array_buffer,
2108 size_t byte_offset, size_t length);
2109 V8_INLINE(static Int8Array* Cast(Value* obj));
2110
2111 private:
2112 Int8Array();
2113 static void CheckCast(Value* obj);
2114 };
2115
2116
2117 /**
2118 * An instance of Uint16Array constructor (ES6 draft 15.13.6).
2119 * This API is experimental and may change significantly.
2120 */
2121 class V8EXPORT Uint16Array : public TypedArray {
2122 public:
2123 static Local<Uint16Array> New(Handle<ArrayBuffer> array_buffer,
2124 size_t byte_offset, size_t length);
2125 V8_INLINE(static Uint16Array* Cast(Value* obj));
2126
2127 private:
2128 Uint16Array();
2129 static void CheckCast(Value* obj);
2130 };
2131
2132
2133 /**
2134 * An instance of Int16Array constructor (ES6 draft 15.13.6).
2135 * This API is experimental and may change significantly.
2136 */
2137 class V8EXPORT Int16Array : public TypedArray {
2138 public:
2139 static Local<Int16Array> New(Handle<ArrayBuffer> array_buffer,
2140 size_t byte_offset, size_t length);
2141 V8_INLINE(static Int16Array* Cast(Value* obj));
2142
2143 private:
2144 Int16Array();
2145 static void CheckCast(Value* obj);
2146 };
2147
2148
2149 /**
2150 * An instance of Uint32Array constructor (ES6 draft 15.13.6).
2151 * This API is experimental and may change significantly.
2152 */
2153 class V8EXPORT Uint32Array : public TypedArray {
2154 public:
2155 static Local<Uint32Array> New(Handle<ArrayBuffer> array_buffer,
2156 size_t byte_offset, size_t length);
2157 V8_INLINE(static Uint32Array* Cast(Value* obj));
2158
2159 private:
2160 Uint32Array();
2161 static void CheckCast(Value* obj);
2162 };
2163
2164
2165 /**
2166 * An instance of Int32Array constructor (ES6 draft 15.13.6).
2167 * This API is experimental and may change significantly.
2168 */
2169 class V8EXPORT Int32Array : public TypedArray {
2170 public:
2171 static Local<Int32Array> New(Handle<ArrayBuffer> array_buffer,
2172 size_t byte_offset, size_t length);
2173 V8_INLINE(static Int32Array* Cast(Value* obj));
2174
2175 private:
2176 Int32Array();
2177 static void CheckCast(Value* obj);
2178 };
2179
2180
2181 /**
2182 * An instance of Float32Array constructor (ES6 draft 15.13.6).
2183 * This API is experimental and may change significantly.
2184 */
2185 class V8EXPORT Float32Array : public TypedArray {
2186 public:
2187 static Local<Float32Array> New(Handle<ArrayBuffer> array_buffer,
2188 size_t byte_offset, size_t length);
2189 V8_INLINE(static Float32Array* Cast(Value* obj));
2190
2191 private:
2192 Float32Array();
2193 static void CheckCast(Value* obj);
2194 };
2195
2196
2197 /**
2198 * An instance of Float64Array constructor (ES6 draft 15.13.6).
2199 * This API is experimental and may change significantly.
2200 */
2201 class V8EXPORT Float64Array : public TypedArray {
2202 public:
2203 static Local<Float64Array> New(Handle<ArrayBuffer> array_buffer,
2204 size_t byte_offset, size_t length);
2205 V8_INLINE(static Float64Array* Cast(Value* obj));
2206
2207 private:
2208 Float64Array();
2209 static void CheckCast(Value* obj);
2210 };
2211
2212
2213 /**
2050 * An instance of the built-in Date constructor (ECMA-262, 15.9). 2214 * An instance of the built-in Date constructor (ECMA-262, 15.9).
2051 */ 2215 */
2052 class V8EXPORT Date : public Object { 2216 class V8EXPORT Date : public Object {
2053 public: 2217 public:
2054 static Local<Value> New(double time); 2218 static Local<Value> New(double time);
2055 2219
2056 /** 2220 /**
2057 * A specialization of Value::NumberValue that is more efficient 2221 * A specialization of Value::NumberValue that is more efficient
2058 * because we know the structure of this object. 2222 * because we know the structure of this object.
2059 */ 2223 */
(...skipping 2476 matching lines...) Expand 10 before | Expand all | Expand 10 after
4536 // the implementation of v8. 4700 // the implementation of v8.
4537 static const int kHeapObjectMapOffset = 0; 4701 static const int kHeapObjectMapOffset = 0;
4538 static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize; 4702 static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize;
4539 static const int kStringResourceOffset = 3 * kApiPointerSize; 4703 static const int kStringResourceOffset = 3 * kApiPointerSize;
4540 4704
4541 static const int kOddballKindOffset = 3 * kApiPointerSize; 4705 static const int kOddballKindOffset = 3 * kApiPointerSize;
4542 static const int kForeignAddressOffset = kApiPointerSize; 4706 static const int kForeignAddressOffset = kApiPointerSize;
4543 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; 4707 static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
4544 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; 4708 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
4545 static const int kContextHeaderSize = 2 * kApiPointerSize; 4709 static const int kContextHeaderSize = 2 * kApiPointerSize;
4546 static const int kContextEmbedderDataIndex = 56; 4710 static const int kContextEmbedderDataIndex = 64;
4547 static const int kFullStringRepresentationMask = 0x07; 4711 static const int kFullStringRepresentationMask = 0x07;
4548 static const int kStringEncodingMask = 0x4; 4712 static const int kStringEncodingMask = 0x4;
4549 static const int kExternalTwoByteRepresentationTag = 0x02; 4713 static const int kExternalTwoByteRepresentationTag = 0x02;
4550 static const int kExternalAsciiRepresentationTag = 0x06; 4714 static const int kExternalAsciiRepresentationTag = 0x06;
4551 4715
4552 static const int kIsolateStateOffset = 0; 4716 static const int kIsolateStateOffset = 0;
4553 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; 4717 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize;
4554 static const int kIsolateRootsOffset = 3 * kApiPointerSize; 4718 static const int kIsolateRootsOffset = 3 * kApiPointerSize;
4555 static const int kUndefinedValueRootIndex = 5; 4719 static const int kUndefinedValueRootIndex = 5;
4556 static const int kNullValueRootIndex = 7; 4720 static const int kNullValueRootIndex = 7;
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
5217 5381
5218 5382
5219 ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) { 5383 ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) {
5220 #ifdef V8_ENABLE_CHECKS 5384 #ifdef V8_ENABLE_CHECKS
5221 CheckCast(value); 5385 CheckCast(value);
5222 #endif 5386 #endif
5223 return static_cast<ArrayBuffer*>(value); 5387 return static_cast<ArrayBuffer*>(value);
5224 } 5388 }
5225 5389
5226 5390
5391 TypedArray* TypedArray::Cast(v8::Value* value) {
5392 #ifdef V8_ENABLE_CHECKS
5393 CheckCast(value);
5394 #endif
5395 return static_cast<TypedArray*>(value);
5396 }
5397
5398
5399 Uint8Array* Uint8Array::Cast(v8::Value* value) {
5400 #ifdef V8_ENABLE_CHECKS
5401 CheckCast(value);
5402 #endif
5403 return static_cast<Uint8Array*>(value);
5404 }
5405
5406
5407 Int8Array* Int8Array::Cast(v8::Value* value) {
5408 #ifdef V8_ENABLE_CHECKS
5409 CheckCast(value);
5410 #endif
5411 return static_cast<Int8Array*>(value);
5412 }
5413
5414
5415 Uint16Array* Uint16Array::Cast(v8::Value* value) {
5416 #ifdef V8_ENABLE_CHECKS
5417 CheckCast(value);
5418 #endif
5419 return static_cast<Uint16Array*>(value);
5420 }
5421
5422
5423 Int16Array* Int16Array::Cast(v8::Value* value) {
5424 #ifdef V8_ENABLE_CHECKS
5425 CheckCast(value);
5426 #endif
5427 return static_cast<Int16Array*>(value);
5428 }
5429
5430
5431 Uint32Array* Uint32Array::Cast(v8::Value* value) {
5432 #ifdef V8_ENABLE_CHECKS
5433 CheckCast(value);
5434 #endif
5435 return static_cast<Uint32Array*>(value);
5436 }
5437
5438
5439 Int32Array* Int32Array::Cast(v8::Value* value) {
5440 #ifdef V8_ENABLE_CHECKS
5441 CheckCast(value);
5442 #endif
5443 return static_cast<Int32Array*>(value);
5444 }
5445
5446
5447 Float32Array* Float32Array::Cast(v8::Value* value) {
5448 #ifdef V8_ENABLE_CHECKS
5449 CheckCast(value);
5450 #endif
5451 return static_cast<Float32Array*>(value);
5452 }
5453
5454
5455 Float64Array* Float64Array::Cast(v8::Value* value) {
5456 #ifdef V8_ENABLE_CHECKS
5457 CheckCast(value);
5458 #endif
5459 return static_cast<Float64Array*>(value);
5460 }
5461
5462
5227 Function* Function::Cast(v8::Value* value) { 5463 Function* Function::Cast(v8::Value* value) {
5228 #ifdef V8_ENABLE_CHECKS 5464 #ifdef V8_ENABLE_CHECKS
5229 CheckCast(value); 5465 CheckCast(value);
5230 #endif 5466 #endif
5231 return static_cast<Function*>(value); 5467 return static_cast<Function*>(value);
5232 } 5468 }
5233 5469
5234 5470
5235 External* External::Cast(v8::Value* value) { 5471 External* External::Cast(v8::Value* value) {
5236 #ifdef V8_ENABLE_CHECKS 5472 #ifdef V8_ENABLE_CHECKS
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
5343 5579
5344 5580
5345 } // namespace v8 5581 } // namespace v8
5346 5582
5347 5583
5348 #undef V8EXPORT 5584 #undef V8EXPORT
5349 #undef TYPE_CHECK 5585 #undef TYPE_CHECK
5350 5586
5351 5587
5352 #endif // V8_H_ 5588 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.h » ('j') | src/api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698