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

Side by Side Diff: include/v8.h

Issue 2645004: Add an API to control the disposal of external string resources... (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 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 static Local<String> NewSymbol(const char* data, int length = -1); 1115 static Local<String> NewSymbol(const char* data, int length = -1);
1116 1116
1117 /** 1117 /**
1118 * Creates a new string by concatenating the left and the right strings 1118 * Creates a new string by concatenating the left and the right strings
1119 * passed in as parameters. 1119 * passed in as parameters.
1120 */ 1120 */
1121 static Local<String> Concat(Handle<String> left, Handle<String>right); 1121 static Local<String> Concat(Handle<String> left, Handle<String>right);
1122 1122
1123 /** 1123 /**
1124 * Creates a new external string using the data defined in the given 1124 * Creates a new external string using the data defined in the given
1125 * resource. The resource is deleted when the external string is no 1125 * resource. When the external string is no longer live on V8's heap the
1126 * longer live on V8's heap. The caller of this function should not 1126 * resource will be disposed. If a disposal callback has been set using
1127 * delete or modify the resource. Neither should the underlying buffer be 1127 * SetExternalStringDiposeCallback this callback will be called to dispose
1128 * deallocated or modified except through the destructor of the 1128 * the resource. Otherwise, V8 will dispose the resource using the C++ delete
1129 * external string resource. 1129 * operator. The caller of this function should not otherwise delete or
1130 * modify the resource. Neither should the underlying buffer be deallocated
1131 * or modified except through the destructor of the external string resource.
1130 */ 1132 */
1131 static Local<String> NewExternal(ExternalStringResource* resource); 1133 static Local<String> NewExternal(ExternalStringResource* resource);
1132 1134
1133 /** 1135 /**
1134 * Associate an external string resource with this string by transforming it 1136 * Associate an external string resource with this string by transforming it
1135 * in place so that existing references to this string in the JavaScript heap 1137 * in place so that existing references to this string in the JavaScript heap
1136 * will use the external string resource. The external string resource's 1138 * will use the external string resource. The external string resource's
1137 * character contents needs to be equivalent to this string. 1139 * character contents needs to be equivalent to this string.
1138 * Returns true if the string has been changed to be an external string. 1140 * Returns true if the string has been changed to be an external string.
1139 * The string is not modified if the operation fails. 1141 * The string is not modified if the operation fails. See NewExternal for
1142 * information on the lifetime of the resource.
1140 */ 1143 */
1141 bool MakeExternal(ExternalStringResource* resource); 1144 bool MakeExternal(ExternalStringResource* resource);
1142 1145
1143 /** 1146 /**
1144 * Creates a new external string using the ascii data defined in the given 1147 * Creates a new external string using the ascii data defined in the given
1145 * resource. The resource is deleted when the external string is no 1148 * resource. When the external string is no longer live on V8's heap the
1146 * longer live on V8's heap. The caller of this function should not 1149 * resource will be disposed. If a disposal callback has been set using
1147 * delete or modify the resource. Neither should the underlying buffer be 1150 * SetExternalStringDiposeCallback this callback will be called to dispose
1148 * deallocated or modified except through the destructor of the 1151 * the resource. Otherwise, V8 will dispose the resource using the C++ delete
1149 * external string resource. 1152 * operator. The caller of this function should not otherwise delete or
1153 * modify the resource. Neither should the underlying buffer be deallocated
1154 * or modified except through the destructor of the external string resource.
1150 */ 1155 */
1151 static Local<String> NewExternal(ExternalAsciiStringResource* resource); 1156 static Local<String> NewExternal(ExternalAsciiStringResource* resource);
1152 1157
1153 /** 1158 /**
1154 * Associate an external string resource with this string by transforming it 1159 * Associate an external string resource with this string by transforming it
1155 * in place so that existing references to this string in the JavaScript heap 1160 * in place so that existing references to this string in the JavaScript heap
1156 * will use the external string resource. The external string resource's 1161 * will use the external string resource. The external string resource's
1157 * character contents needs to be equivalent to this string. 1162 * character contents needs to be equivalent to this string.
1158 * Returns true if the string has been changed to be an external string. 1163 * Returns true if the string has been changed to be an external string.
1159 * The string is not modified if the operation fails. 1164 * The string is not modified if the operation fails. See NewExternal for
1165 * information on the lifetime of the resource.
1160 */ 1166 */
1161 bool MakeExternal(ExternalAsciiStringResource* resource); 1167 bool MakeExternal(ExternalAsciiStringResource* resource);
1162 1168
1163 /** 1169 /**
1164 * Returns true if this string can be made external. 1170 * Returns true if this string can be made external.
1165 */ 1171 */
1166 bool CanMakeExternal(); 1172 bool CanMakeExternal();
1167 1173
1168 /** Creates an undetectable string from the supplied ascii or utf-8 data.*/ 1174 /** Creates an undetectable string from the supplied ascii or utf-8 data.*/
1169 static Local<String> NewUndetectable(const char* data, int length = -1); 1175 static Local<String> NewUndetectable(const char* data, int length = -1);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 Value(const Value&); 1244 Value(const Value&);
1239 void operator=(const Value&); 1245 void operator=(const Value&);
1240 }; 1246 };
1241 1247
1242 private: 1248 private:
1243 void VerifyExternalStringResource(ExternalStringResource* val) const; 1249 void VerifyExternalStringResource(ExternalStringResource* val) const;
1244 static void CheckCast(v8::Value* obj); 1250 static void CheckCast(v8::Value* obj);
1245 }; 1251 };
1246 1252
1247 1253
1254 typedef void (*ExternalStringDiposeCallback)
1255 (String::ExternalStringResourceBase* resource);
1256
1257
1248 /** 1258 /**
1249 * A JavaScript number value (ECMA-262, 4.3.20) 1259 * A JavaScript number value (ECMA-262, 4.3.20)
1250 */ 1260 */
1251 class V8EXPORT Number : public Primitive { 1261 class V8EXPORT Number : public Primitive {
1252 public: 1262 public:
1253 double Value() const; 1263 double Value() const;
1254 static Local<Number> New(double value); 1264 static Local<Number> New(double value);
1255 static inline Number* Cast(v8::Value* obj); 1265 static inline Number* Cast(v8::Value* obj);
1256 private: 1266 private:
1257 Number(); 1267 Number();
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2455 */ 2465 */
2456 static bool AddMessageListener(MessageCallback that, 2466 static bool AddMessageListener(MessageCallback that,
2457 Handle<Value> data = Handle<Value>()); 2467 Handle<Value> data = Handle<Value>());
2458 2468
2459 /** 2469 /**
2460 * Remove all message listeners from the specified callback function. 2470 * Remove all message listeners from the specified callback function.
2461 */ 2471 */
2462 static void RemoveMessageListeners(MessageCallback that); 2472 static void RemoveMessageListeners(MessageCallback that);
2463 2473
2464 /** 2474 /**
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 /**
2465 * Sets V8 flags from a string. 2484 * Sets V8 flags from a string.
2466 */ 2485 */
2467 static void SetFlagsFromString(const char* str, int length); 2486 static void SetFlagsFromString(const char* str, int length);
2468 2487
2469 /** 2488 /**
2470 * Sets V8 flags from the command line. 2489 * Sets V8 flags from the command line.
2471 */ 2490 */
2472 static void SetFlagsFromCommandLine(int* argc, 2491 static void SetFlagsFromCommandLine(int* argc,
2473 char** argv, 2492 char** argv,
2474 bool remove_flags); 2493 bool remove_flags);
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
3583 3602
3584 } // namespace v8 3603 } // namespace v8
3585 3604
3586 3605
3587 #undef V8EXPORT 3606 #undef V8EXPORT
3588 #undef V8EXPORT_INLINE 3607 #undef V8EXPORT_INLINE
3589 #undef TYPE_CHECK 3608 #undef TYPE_CHECK
3590 3609
3591 3610
3592 #endif // V8_H_ 3611 #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