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

Side by Side Diff: include/v8.h

Issue 391068: Add Blob API
Patch Set: Created 11 years, 1 month 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
« 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 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 class Context; 106 class Context;
107 class String; 107 class String;
108 class Value; 108 class Value;
109 class Utils; 109 class Utils;
110 class Number; 110 class Number;
111 class Object; 111 class Object;
112 class Array; 112 class Array;
113 class Int32; 113 class Int32;
114 class Uint32; 114 class Uint32;
115 class External; 115 class External;
116 class Blob;
116 class Primitive; 117 class Primitive;
117 class Boolean; 118 class Boolean;
118 class Integer; 119 class Integer;
119 class Function; 120 class Function;
120 class Date; 121 class Date;
121 class ImplementationUtilities; 122 class ImplementationUtilities;
122 class Signature; 123 class Signature;
123 template <class T> class Handle; 124 template <class T> class Handle;
124 template <class T> class Local; 125 template <class T> class Local;
125 template <class T> class Persistent; 126 template <class T> class Persistent;
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 * Returns true if this value is a number. 718 * Returns true if this value is a number.
718 */ 719 */
719 bool IsNumber() const; 720 bool IsNumber() const;
720 721
721 /** 722 /**
722 * Returns true if this value is external. 723 * Returns true if this value is external.
723 */ 724 */
724 bool IsExternal() const; 725 bool IsExternal() const;
725 726
726 /** 727 /**
728 * Returns true if this value is blob.
729 */
730 bool IsBlob() const;
731
732 /**
727 * Returns true if this value is a 32-bit signed integer. 733 * Returns true if this value is a 32-bit signed integer.
728 */ 734 */
729 bool IsInt32() const; 735 bool IsInt32() const;
730 736
731 /** 737 /**
732 * Returns true if this value is a Date. 738 * Returns true if this value is a Date.
733 */ 739 */
734 bool IsDate() const; 740 bool IsDate() const;
735 741
736 Local<Boolean> ToBoolean() const; 742 Local<Boolean> ToBoolean() const;
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 static inline External* Cast(Value* obj); 1380 static inline External* Cast(Value* obj);
1375 void* Value() const; 1381 void* Value() const;
1376 private: 1382 private:
1377 External(); 1383 External();
1378 static void CheckCast(v8::Value* obj); 1384 static void CheckCast(v8::Value* obj);
1379 static inline void* QuickUnwrap(Handle<v8::Value> obj); 1385 static inline void* QuickUnwrap(Handle<v8::Value> obj);
1380 static void* FullUnwrap(Handle<v8::Value> obj); 1386 static void* FullUnwrap(Handle<v8::Value> obj);
1381 }; 1387 };
1382 1388
1383 1389
1390 /**
1391 * A JavaScript value that wraps a ByteArray.
1392 */
1393 class V8EXPORT Blob : public Value {
1394 public:
1395 // Create a Blob with room for 'length' bytes.
1396 static Local<Blob> New(int length);
1397 static inline Blob* Cast(Value* obj);
1398
1399 // Read the index'th byte integer
1400 uint8_t GetByte(int index);
1401 // Write the index'th byte
1402 void SetByte(int index, uint8_t value);
1403 // Get access to the raw memory
1404 uint8_t* GetAddress();
1405 int ByteCount();
1406 private:
1407 Blob();
1408 static void CheckCast(v8::Value* obj);
1409 };
1410
1411
1384 // --- T e m p l a t e s --- 1412 // --- T e m p l a t e s ---
1385 1413
1386 1414
1387 /** 1415 /**
1388 * The superclass of object and function templates. 1416 * The superclass of object and function templates.
1389 */ 1417 */
1390 class V8EXPORT Template : public Data { 1418 class V8EXPORT Template : public Data {
1391 public: 1419 public:
1392 /** Adds a property to each instance created by this template.*/ 1420 /** Adds a property to each instance created by this template.*/
1393 void Set(Handle<String> name, Handle<Data> value, 1421 void Set(Handle<String> name, Handle<Data> value,
(...skipping 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after
3170 3198
3171 3199
3172 External* External::Cast(v8::Value* value) { 3200 External* External::Cast(v8::Value* value) {
3173 #ifdef V8_ENABLE_CHECKS 3201 #ifdef V8_ENABLE_CHECKS
3174 CheckCast(value); 3202 CheckCast(value);
3175 #endif 3203 #endif
3176 return static_cast<External*>(value); 3204 return static_cast<External*>(value);
3177 } 3205 }
3178 3206
3179 3207
3208 Blob* Blob::Cast(v8::Value* value) {
3209 #ifdef V8_ENABLE_CHECKS
3210 CheckCast(value);
3211 #endif
3212 return static_cast<Blob*>(value);
3213 }
3214
3215
3180 Local<Value> AccessorInfo::Data() const { 3216 Local<Value> AccessorInfo::Data() const {
3181 return Local<Value>(reinterpret_cast<Value*>(&args_[-3])); 3217 return Local<Value>(reinterpret_cast<Value*>(&args_[-3]));
3182 } 3218 }
3183 3219
3184 3220
3185 Local<Object> AccessorInfo::This() const { 3221 Local<Object> AccessorInfo::This() const {
3186 return Local<Object>(reinterpret_cast<Object*>(&args_[0])); 3222 return Local<Object>(reinterpret_cast<Object*>(&args_[0]));
3187 } 3223 }
3188 3224
3189 3225
(...skipping 16 matching lines...) Expand all
3206 3242
3207 } // namespace v8 3243 } // namespace v8
3208 3244
3209 3245
3210 #undef V8EXPORT 3246 #undef V8EXPORT
3211 #undef V8EXPORT_INLINE 3247 #undef V8EXPORT_INLINE
3212 #undef TYPE_CHECK 3248 #undef TYPE_CHECK
3213 3249
3214 3250
3215 #endif // V8_H_ 3251 #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