| 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 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1289   V8_INLINE(ExternalStringResource* GetExternalStringResource() const); | 1289   V8_INLINE(ExternalStringResource* GetExternalStringResource() const); | 
| 1290 | 1290 | 
| 1291   /** | 1291   /** | 
| 1292    * Get the ExternalAsciiStringResource for an external ASCII string. | 1292    * Get the ExternalAsciiStringResource for an external ASCII string. | 
| 1293    * Returns NULL if IsExternalAscii() doesn't return true. | 1293    * Returns NULL if IsExternalAscii() doesn't return true. | 
| 1294    */ | 1294    */ | 
| 1295   const ExternalAsciiStringResource* GetExternalAsciiStringResource() const; | 1295   const ExternalAsciiStringResource* GetExternalAsciiStringResource() const; | 
| 1296 | 1296 | 
| 1297   V8_INLINE(static String* Cast(v8::Value* obj)); | 1297   V8_INLINE(static String* Cast(v8::Value* obj)); | 
| 1298 | 1298 | 
|  | 1299   // TODO(dcarney): deprecate | 
| 1299   /** | 1300   /** | 
| 1300    * Allocates a new string from either UTF-8 encoded or ASCII data. | 1301    * Allocates a new string from either UTF-8 encoded or ASCII data. | 
| 1301    * The second parameter 'length' gives the buffer length. If omitted, | 1302    * The second parameter 'length' gives the buffer length. If omitted, | 
| 1302    * the function calls 'strlen' to determine the buffer length. | 1303    * the function calls 'strlen' to determine the buffer length. | 
| 1303    */ | 1304    */ | 
| 1304   static Local<String> New(const char* data, int length = -1); | 1305   V8_INLINE(static Local<String> New(const char* data, int length = -1)); | 
| 1305 | 1306 | 
|  | 1307   // TODO(dcarney): deprecate | 
| 1306   /** Allocates a new string from 16-bit character codes.*/ | 1308   /** Allocates a new string from 16-bit character codes.*/ | 
| 1307   static Local<String> New(const uint16_t* data, int length = -1); | 1309   V8_INLINE(static Local<String> New(const uint16_t* data, int length = -1)); | 
| 1308 | 1310 | 
|  | 1311   // TODO(dcarney): deprecate | 
| 1309   /** Creates a symbol. Returns one if it exists already.*/ | 1312   /** Creates a symbol. Returns one if it exists already.*/ | 
| 1310   static Local<String> NewSymbol(const char* data, int length = -1); | 1313   V8_INLINE(static Local<String> NewSymbol(const char* data, int length = -1)); | 
|  | 1314 | 
|  | 1315   enum NewStringType { | 
|  | 1316     kNormalString, kInternalizedString, kUndetectableString | 
|  | 1317   }; | 
|  | 1318 | 
|  | 1319   /** Allocates a new string from UTF-8 data.*/ | 
|  | 1320   static Local<String> NewFromUtf8(Isolate* isolate, | 
|  | 1321                                   const char* data, | 
|  | 1322                                   NewStringType type = kNormalString, | 
|  | 1323                                   int length = -1); | 
|  | 1324 | 
|  | 1325   /** Allocates a new string from Latin-1 data.*/ | 
|  | 1326   static Local<String> NewFromOneByte( | 
|  | 1327       Isolate* isolate, | 
|  | 1328       const uint8_t* data, | 
|  | 1329       NewStringType type = kNormalString, | 
|  | 1330       int length = -1); | 
|  | 1331 | 
|  | 1332   /** Allocates a new string from UTF-16 data.*/ | 
|  | 1333   static Local<String> NewFromTwoByte( | 
|  | 1334       Isolate* isolate, | 
|  | 1335       const uint16_t* data, | 
|  | 1336       NewStringType type = kNormalString, | 
|  | 1337       int length = -1); | 
| 1311 | 1338 | 
| 1312   /** | 1339   /** | 
| 1313    * Creates a new string by concatenating the left and the right strings | 1340    * Creates a new string by concatenating the left and the right strings | 
| 1314    * passed in as parameters. | 1341    * passed in as parameters. | 
| 1315    */ | 1342    */ | 
| 1316   static Local<String> Concat(Handle<String> left, Handle<String> right); | 1343   static Local<String> Concat(Handle<String> left, Handle<String> right); | 
| 1317 | 1344 | 
| 1318   /** | 1345   /** | 
| 1319    * Creates a new external string using the data defined in the given | 1346    * Creates a new external string using the data defined in the given | 
| 1320    * resource. When the external string is no longer live on V8's heap the | 1347    * resource. When the external string is no longer live on V8's heap the | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1355    * The string is not modified if the operation fails. See NewExternal for | 1382    * The string is not modified if the operation fails. See NewExternal for | 
| 1356    * information on the lifetime of the resource. | 1383    * information on the lifetime of the resource. | 
| 1357    */ | 1384    */ | 
| 1358   bool MakeExternal(ExternalAsciiStringResource* resource); | 1385   bool MakeExternal(ExternalAsciiStringResource* resource); | 
| 1359 | 1386 | 
| 1360   /** | 1387   /** | 
| 1361    * Returns true if this string can be made external. | 1388    * Returns true if this string can be made external. | 
| 1362    */ | 1389    */ | 
| 1363   bool CanMakeExternal(); | 1390   bool CanMakeExternal(); | 
| 1364 | 1391 | 
|  | 1392   // TODO(dcarney): deprecate | 
| 1365   /** Creates an undetectable string from the supplied ASCII or UTF-8 data.*/ | 1393   /** Creates an undetectable string from the supplied ASCII or UTF-8 data.*/ | 
| 1366   static Local<String> NewUndetectable(const char* data, int length = -1); | 1394   V8_INLINE( | 
|  | 1395       static Local<String> NewUndetectable(const char* data, int length = -1)); | 
| 1367 | 1396 | 
|  | 1397   // TODO(dcarney): deprecate | 
| 1368   /** Creates an undetectable string from the supplied 16-bit character codes.*/ | 1398   /** Creates an undetectable string from the supplied 16-bit character codes.*/ | 
| 1369   static Local<String> NewUndetectable(const uint16_t* data, int length = -1); | 1399   V8_INLINE(static Local<String> NewUndetectable( | 
|  | 1400       const uint16_t* data, int length = -1)); | 
| 1370 | 1401 | 
| 1371   /** | 1402   /** | 
| 1372    * Converts an object to a UTF-8-encoded character array.  Useful if | 1403    * Converts an object to a UTF-8-encoded character array.  Useful if | 
| 1373    * you want to print the object.  If conversion to a string fails | 1404    * you want to print the object.  If conversion to a string fails | 
| 1374    * (e.g. due to an exception in the toString() method of the object) | 1405    * (e.g. due to an exception in the toString() method of the object) | 
| 1375    * then the length() method returns 0 and the * operator returns | 1406    * then the length() method returns 0 and the * operator returns | 
| 1376    * NULL. | 1407    * NULL. | 
| 1377    */ | 1408    */ | 
| 1378   class V8EXPORT Utf8Value { | 1409   class V8EXPORT Utf8Value { | 
| 1379    public: | 1410    public: | 
| (...skipping 3352 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4732 | 4763 | 
| 4733 Local<String> String::Empty(Isolate* isolate) { | 4764 Local<String> String::Empty(Isolate* isolate) { | 
| 4734   typedef internal::Object* S; | 4765   typedef internal::Object* S; | 
| 4735   typedef internal::Internals I; | 4766   typedef internal::Internals I; | 
| 4736   if (!I::IsInitialized(isolate)) return Empty(); | 4767   if (!I::IsInitialized(isolate)) return Empty(); | 
| 4737   S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); | 4768   S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); | 
| 4738   return Local<String>(reinterpret_cast<String*>(slot)); | 4769   return Local<String>(reinterpret_cast<String*>(slot)); | 
| 4739 } | 4770 } | 
| 4740 | 4771 | 
| 4741 | 4772 | 
|  | 4773 Local<String> String::New(const char* data, int length) { | 
|  | 4774   return NewFromUtf8(Isolate::GetCurrent(), data, kNormalString, length); | 
|  | 4775 } | 
|  | 4776 | 
|  | 4777 | 
|  | 4778 Local<String> String::New(const uint16_t* data, int length) { | 
|  | 4779   return NewFromTwoByte(Isolate::GetCurrent(), data, kNormalString, length); | 
|  | 4780 } | 
|  | 4781 | 
|  | 4782 | 
|  | 4783 Local<String> String::NewSymbol(const char* data, int length) { | 
|  | 4784   return NewFromUtf8(Isolate::GetCurrent(), data, kInternalizedString, length); | 
|  | 4785 } | 
|  | 4786 | 
|  | 4787 | 
|  | 4788 Local<String> String::NewUndetectable(const char* data, int length) { | 
|  | 4789   return NewFromUtf8(Isolate::GetCurrent(), data, kUndetectableString, length); | 
|  | 4790 } | 
|  | 4791 | 
|  | 4792 | 
|  | 4793 Local<String> String::NewUndetectable(const uint16_t* data, int length) { | 
|  | 4794   return NewFromTwoByte( | 
|  | 4795       Isolate::GetCurrent(), data, kUndetectableString, length); | 
|  | 4796 } | 
|  | 4797 | 
|  | 4798 | 
| 4742 String::ExternalStringResource* String::GetExternalStringResource() const { | 4799 String::ExternalStringResource* String::GetExternalStringResource() const { | 
| 4743   typedef internal::Object O; | 4800   typedef internal::Object O; | 
| 4744   typedef internal::Internals I; | 4801   typedef internal::Internals I; | 
| 4745   O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); | 4802   O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); | 
| 4746   String::ExternalStringResource* result; | 4803   String::ExternalStringResource* result; | 
| 4747   if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) { | 4804   if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) { | 
| 4748     void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); | 4805     void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); | 
| 4749     result = reinterpret_cast<String::ExternalStringResource*>(value); | 4806     result = reinterpret_cast<String::ExternalStringResource*>(value); | 
| 4750   } else { | 4807   } else { | 
| 4751     result = NULL; | 4808     result = NULL; | 
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5021 | 5078 | 
| 5022 | 5079 | 
| 5023 }  // namespace v8 | 5080 }  // namespace v8 | 
| 5024 | 5081 | 
| 5025 | 5082 | 
| 5026 #undef V8EXPORT | 5083 #undef V8EXPORT | 
| 5027 #undef TYPE_CHECK | 5084 #undef TYPE_CHECK | 
| 5028 | 5085 | 
| 5029 | 5086 | 
| 5030 #endif  // V8_H_ | 5087 #endif  // V8_H_ | 
| OLD | NEW | 
|---|