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

Side by Side Diff: include/v8.h

Issue 2658008: Remove the SetExternalStringDiposeCallback API... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 6 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.cc » ('j') | no next file with comments »
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 class ObjectTemplate; 127 class ObjectTemplate;
128 class Data; 128 class Data;
129 class AccessorInfo; 129 class AccessorInfo;
130 class StackTrace; 130 class StackTrace;
131 class StackFrame; 131 class StackFrame;
132 132
133 namespace internal { 133 namespace internal {
134 134
135 class Arguments; 135 class Arguments;
136 class Object; 136 class Object;
137 class Heap;
137 class Top; 138 class Top;
138 139
139 } 140 }
140 141
141 142
142 // --- W e a k H a n d l e s 143 // --- W e a k H a n d l e s
143 144
144 145
145 /** 146 /**
146 * A weak reference callback function. 147 * A weak reference callback function.
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 bool IsExternal() const; 1020 bool IsExternal() const;
1020 1021
1021 /** 1022 /**
1022 * Returns true if the string is both external and ascii 1023 * Returns true if the string is both external and ascii
1023 */ 1024 */
1024 bool IsExternalAscii() const; 1025 bool IsExternalAscii() const;
1025 1026
1026 class V8EXPORT ExternalStringResourceBase { 1027 class V8EXPORT ExternalStringResourceBase {
1027 public: 1028 public:
1028 virtual ~ExternalStringResourceBase() {} 1029 virtual ~ExternalStringResourceBase() {}
1030
1029 protected: 1031 protected:
1030 ExternalStringResourceBase() {} 1032 ExternalStringResourceBase() {}
1033
1034 /**
1035 * Internally V8 will call this Dispose method when the external string
1036 * resource is no longer needed. The default implementation will use the
1037 * delete operator. This method can be overridden in subclasses to
1038 * control how allocated external string resources are disposed.
1039 */
1040 virtual void Dispose() { delete this; }
1041
1031 private: 1042 private:
1032 // Disallow copying and assigning. 1043 // Disallow copying and assigning.
1033 ExternalStringResourceBase(const ExternalStringResourceBase&); 1044 ExternalStringResourceBase(const ExternalStringResourceBase&);
1034 void operator=(const ExternalStringResourceBase&); 1045 void operator=(const ExternalStringResourceBase&);
1046
1047 friend class v8::internal::Heap;
1035 }; 1048 };
1036 1049
1037 /** 1050 /**
1038 * An ExternalStringResource is a wrapper around a two-byte string 1051 * An ExternalStringResource is a wrapper around a two-byte string
1039 * buffer that resides outside V8's heap. Implement an 1052 * buffer that resides outside V8's heap. Implement an
1040 * ExternalStringResource to manage the life cycle of the underlying 1053 * ExternalStringResource to manage the life cycle of the underlying
1041 * buffer. Note that the string data must be immutable. 1054 * buffer. Note that the string data must be immutable.
1042 */ 1055 */
1043 class V8EXPORT ExternalStringResource 1056 class V8EXPORT ExternalStringResource
1044 : public ExternalStringResourceBase { 1057 : public ExternalStringResourceBase {
1045 public: 1058 public:
1046 /** 1059 /**
1047 * Override the destructor to manage the life cycle of the underlying 1060 * Override the destructor to manage the life cycle of the underlying
1048 * buffer. 1061 * buffer.
1049 */ 1062 */
1050 virtual ~ExternalStringResource() {} 1063 virtual ~ExternalStringResource() {}
1051 /** The string data from the underlying buffer.*/ 1064
1065 /**
1066 * The string data from the underlying buffer.
1067 */
1052 virtual const uint16_t* data() const = 0; 1068 virtual const uint16_t* data() const = 0;
1053 /** The length of the string. That is, the number of two-byte characters.*/ 1069
1070 /**
1071 * The length of the string. That is, the number of two-byte characters.
1072 */
1054 virtual size_t length() const = 0; 1073 virtual size_t length() const = 0;
1074
1055 protected: 1075 protected:
1056 ExternalStringResource() {} 1076 ExternalStringResource() {}
1057 }; 1077 };
1058 1078
1059 /** 1079 /**
1060 * An ExternalAsciiStringResource is a wrapper around an ascii 1080 * An ExternalAsciiStringResource is a wrapper around an ascii
1061 * string buffer that resides outside V8's heap. Implement an 1081 * string buffer that resides outside V8's heap. Implement an
1062 * ExternalAsciiStringResource to manage the life cycle of the 1082 * ExternalAsciiStringResource to manage the life cycle of the
1063 * underlying buffer. Note that the string data must be immutable 1083 * underlying buffer. Note that the string data must be immutable
1064 * and that the data must be strict 7-bit ASCII, not Latin1 or 1084 * and that the data must be strict 7-bit ASCII, not Latin1 or
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 1136
1117 /** 1137 /**
1118 * Creates a new string by concatenating the left and the right strings 1138 * Creates a new string by concatenating the left and the right strings
1119 * passed in as parameters. 1139 * passed in as parameters.
1120 */ 1140 */
1121 static Local<String> Concat(Handle<String> left, Handle<String>right); 1141 static Local<String> Concat(Handle<String> left, Handle<String>right);
1122 1142
1123 /** 1143 /**
1124 * Creates a new external string using the data defined in the given 1144 * Creates a new external string using the data defined in the given
1125 * resource. When the external string is no longer live on V8's heap the 1145 * resource. When the external string is no longer live on V8's heap the
1126 * resource will be disposed. If a disposal callback has been set using 1146 * resource will be disposed by calling its Dispose method. The caller of
1127 * SetExternalStringDiposeCallback this callback will be called to dispose 1147 * this function should not otherwise delete or modify the resource. Neither
1128 * the resource. Otherwise, V8 will dispose the resource using the C++ delete 1148 * should the underlying buffer be deallocated or modified except through the
1129 * operator. The caller of this function should not otherwise delete or 1149 * destructor of the external string resource.
1130 * modify the resource. Neither should the underlying buffer be deallocated
1131 * or modified except through the destructor of the external string resource.
1132 */ 1150 */
1133 static Local<String> NewExternal(ExternalStringResource* resource); 1151 static Local<String> NewExternal(ExternalStringResource* resource);
1134 1152
1135 /** 1153 /**
1136 * Associate an external string resource with this string by transforming it 1154 * Associate an external string resource with this string by transforming it
1137 * in place so that existing references to this string in the JavaScript heap 1155 * in place so that existing references to this string in the JavaScript heap
1138 * will use the external string resource. The external string resource's 1156 * will use the external string resource. The external string resource's
1139 * character contents needs to be equivalent to this string. 1157 * character contents needs to be equivalent to this string.
1140 * Returns true if the string has been changed to be an external string. 1158 * Returns true if the string has been changed to be an external string.
1141 * The string is not modified if the operation fails. See NewExternal for 1159 * The string is not modified if the operation fails. See NewExternal for
1142 * information on the lifetime of the resource. 1160 * information on the lifetime of the resource.
1143 */ 1161 */
1144 bool MakeExternal(ExternalStringResource* resource); 1162 bool MakeExternal(ExternalStringResource* resource);
1145 1163
1146 /** 1164 /**
1147 * Creates a new external string using the ascii data defined in the given 1165 * Creates a new external string using the ascii data defined in the given
1148 * resource. When the external string is no longer live on V8's heap the 1166 * resource. When the external string is no longer live on V8's heap the
1149 * resource will be disposed. If a disposal callback has been set using 1167 * resource will be disposed by calling its Dispose method. The caller of
1150 * SetExternalStringDiposeCallback this callback will be called to dispose 1168 * this function should not otherwise delete or modify the resource. Neither
1151 * the resource. Otherwise, V8 will dispose the resource using the C++ delete 1169 * should the underlying buffer be deallocated or modified except through the
1152 * operator. The caller of this function should not otherwise delete or 1170 * destructor of the external string resource.
1153 * modify the resource. Neither should the underlying buffer be deallocated
1154 * or modified except through the destructor of the external string resource.
1155 */ 1171 */
1156 static Local<String> NewExternal(ExternalAsciiStringResource* resource); 1172 static Local<String> NewExternal(ExternalAsciiStringResource* resource);
1157 1173
1158 /** 1174 /**
1159 * Associate an external string resource with this string by transforming it 1175 * Associate an external string resource with this string by transforming it
1160 * in place so that existing references to this string in the JavaScript heap 1176 * in place so that existing references to this string in the JavaScript heap
1161 * will use the external string resource. The external string resource's 1177 * will use the external string resource. The external string resource's
1162 * character contents needs to be equivalent to this string. 1178 * character contents needs to be equivalent to this string.
1163 * Returns true if the string has been changed to be an external string. 1179 * Returns true if the string has been changed to be an external string.
1164 * The string is not modified if the operation fails. See NewExternal for 1180 * The string is not modified if the operation fails. See NewExternal for
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 Value(const Value&); 1260 Value(const Value&);
1245 void operator=(const Value&); 1261 void operator=(const Value&);
1246 }; 1262 };
1247 1263
1248 private: 1264 private:
1249 void VerifyExternalStringResource(ExternalStringResource* val) const; 1265 void VerifyExternalStringResource(ExternalStringResource* val) const;
1250 static void CheckCast(v8::Value* obj); 1266 static void CheckCast(v8::Value* obj);
1251 }; 1267 };
1252 1268
1253 1269
1254 typedef void (*ExternalStringDiposeCallback)
1255 (String::ExternalStringResourceBase* resource);
1256
1257
1258 /** 1270 /**
1259 * A JavaScript number value (ECMA-262, 4.3.20) 1271 * A JavaScript number value (ECMA-262, 4.3.20)
1260 */ 1272 */
1261 class V8EXPORT Number : public Primitive { 1273 class V8EXPORT Number : public Primitive {
1262 public: 1274 public:
1263 double Value() const; 1275 double Value() const;
1264 static Local<Number> New(double value); 1276 static Local<Number> New(double value);
1265 static inline Number* Cast(v8::Value* obj); 1277 static inline Number* Cast(v8::Value* obj);
1266 private: 1278 private:
1267 Number(); 1279 Number();
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2465 */ 2477 */
2466 static bool AddMessageListener(MessageCallback that, 2478 static bool AddMessageListener(MessageCallback that,
2467 Handle<Value> data = Handle<Value>()); 2479 Handle<Value> data = Handle<Value>());
2468 2480
2469 /** 2481 /**
2470 * Remove all message listeners from the specified callback function. 2482 * Remove all message listeners from the specified callback function.
2471 */ 2483 */
2472 static void RemoveMessageListeners(MessageCallback that); 2484 static void RemoveMessageListeners(MessageCallback that);
2473 2485
2474 /** 2486 /**
2475 * Set a callback to be called when an external string is no longer live on
2476 * V8's heap. The resource will no longer be needed by V8 and the embedder
2477 * can dispose of if. If this callback is not set V8 will free the resource
2478 * using the C++ delete operator.
2479 */
2480 static void SetExternalStringDiposeCallback(
2481 ExternalStringDiposeCallback that);
2482
2483 /**
2484 * Sets V8 flags from a string. 2487 * Sets V8 flags from a string.
2485 */ 2488 */
2486 static void SetFlagsFromString(const char* str, int length); 2489 static void SetFlagsFromString(const char* str, int length);
2487 2490
2488 /** 2491 /**
2489 * Sets V8 flags from the command line. 2492 * Sets V8 flags from the command line.
2490 */ 2493 */
2491 static void SetFlagsFromCommandLine(int* argc, 2494 static void SetFlagsFromCommandLine(int* argc,
2492 char** argv, 2495 char** argv,
2493 bool remove_flags); 2496 bool remove_flags);
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
3602 3605
3603 } // namespace v8 3606 } // namespace v8
3604 3607
3605 3608
3606 #undef V8EXPORT 3609 #undef V8EXPORT
3607 #undef V8EXPORT_INLINE 3610 #undef V8EXPORT_INLINE
3608 #undef TYPE_CHECK 3611 #undef TYPE_CHECK
3609 3612
3610 3613
3611 #endif // V8_H_ 3614 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698