OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 2454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2465 | 2465 |
2466 Local<External> v8::External::New(void* data) { | 2466 Local<External> v8::External::New(void* data) { |
2467 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); | 2467 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); |
2468 LOG_API("External::New"); | 2468 LOG_API("External::New"); |
2469 EnsureInitialized("v8::External::New()"); | 2469 EnsureInitialized("v8::External::New()"); |
2470 i::Handle<i::Proxy> obj = i::Factory::NewProxy(static_cast<i::Address>(data)); | 2470 i::Handle<i::Proxy> obj = i::Factory::NewProxy(static_cast<i::Address>(data)); |
2471 return Utils::ToLocal(obj); | 2471 return Utils::ToLocal(obj); |
2472 } | 2472 } |
2473 | 2473 |
2474 | 2474 |
| 2475 Local<String> v8::String::Empty() { |
| 2476 EnsureInitialized("v8::String::Empty()"); |
| 2477 LOG_API("String::Empty()"); |
| 2478 return Utils::ToLocal(i::Factory::empty_symbol()); |
| 2479 } |
| 2480 |
| 2481 |
2475 Local<String> v8::String::New(const char* data, int length) { | 2482 Local<String> v8::String::New(const char* data, int length) { |
2476 EnsureInitialized("v8::String::New()"); | 2483 EnsureInitialized("v8::String::New()"); |
2477 LOG_API("String::New(char)"); | 2484 LOG_API("String::New(char)"); |
| 2485 if (length == 0) return Empty(); |
2478 if (length == -1) length = strlen(data); | 2486 if (length == -1) length = strlen(data); |
2479 i::Handle<i::String> result = | 2487 i::Handle<i::String> result = |
2480 i::Factory::NewStringFromUtf8(i::Vector<const char>(data, length)); | 2488 i::Factory::NewStringFromUtf8(i::Vector<const char>(data, length)); |
2481 return Utils::ToLocal(result); | 2489 return Utils::ToLocal(result); |
2482 } | 2490 } |
2483 | 2491 |
2484 | 2492 |
2485 Local<String> v8::String::NewUndetectable(const char* data, int length) { | 2493 Local<String> v8::String::NewUndetectable(const char* data, int length) { |
2486 EnsureInitialized("v8::String::NewUndetectable()"); | 2494 EnsureInitialized("v8::String::NewUndetectable()"); |
2487 LOG_API("String::NewUndetectable(char)"); | 2495 LOG_API("String::NewUndetectable(char)"); |
2488 if (length == -1) length = strlen(data); | 2496 if (length == -1) length = strlen(data); |
2489 i::Handle<i::String> result = | 2497 i::Handle<i::String> result = |
2490 i::Factory::NewStringFromUtf8(i::Vector<const char>(data, length)); | 2498 i::Factory::NewStringFromUtf8(i::Vector<const char>(data, length)); |
2491 result->MarkAsUndetectable(); | 2499 result->MarkAsUndetectable(); |
2492 return Utils::ToLocal(result); | 2500 return Utils::ToLocal(result); |
2493 } | 2501 } |
2494 | 2502 |
2495 | 2503 |
2496 static int TwoByteStringLength(const uint16_t* data) { | 2504 static int TwoByteStringLength(const uint16_t* data) { |
2497 int length = 0; | 2505 int length = 0; |
2498 while (data[length] != '\0') length++; | 2506 while (data[length] != '\0') length++; |
2499 return length; | 2507 return length; |
2500 } | 2508 } |
2501 | 2509 |
2502 | 2510 |
2503 Local<String> v8::String::New(const uint16_t* data, int length) { | 2511 Local<String> v8::String::New(const uint16_t* data, int length) { |
2504 EnsureInitialized("v8::String::New()"); | 2512 EnsureInitialized("v8::String::New()"); |
2505 LOG_API("String::New(uint16_)"); | 2513 LOG_API("String::New(uint16_)"); |
| 2514 if (length == 0) return Empty(); |
2506 if (length == -1) length = TwoByteStringLength(data); | 2515 if (length == -1) length = TwoByteStringLength(data); |
2507 i::Handle<i::String> result = | 2516 i::Handle<i::String> result = |
2508 i::Factory::NewStringFromTwoByte(i::Vector<const uint16_t>(data, length)); | 2517 i::Factory::NewStringFromTwoByte(i::Vector<const uint16_t>(data, length)); |
2509 return Utils::ToLocal(result); | 2518 return Utils::ToLocal(result); |
2510 } | 2519 } |
2511 | 2520 |
2512 | 2521 |
2513 Local<String> v8::String::NewUndetectable(const uint16_t* data, int length) { | 2522 Local<String> v8::String::NewUndetectable(const uint16_t* data, int length) { |
2514 EnsureInitialized("v8::String::NewUndetectable()"); | 2523 EnsureInitialized("v8::String::NewUndetectable()"); |
2515 LOG_API("String::NewUndetectable(uint16_)"); | 2524 LOG_API("String::NewUndetectable(uint16_)"); |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3144 reinterpret_cast<HandleScopeImplementer*>(storage); | 3153 reinterpret_cast<HandleScopeImplementer*>(storage); |
3145 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); | 3154 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); |
3146 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = | 3155 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = |
3147 &thread_local->handle_scope_data_; | 3156 &thread_local->handle_scope_data_; |
3148 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); | 3157 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); |
3149 | 3158 |
3150 return storage + ArchiveSpacePerThread(); | 3159 return storage + ArchiveSpacePerThread(); |
3151 } | 3160 } |
3152 | 3161 |
3153 } } // namespace v8::internal | 3162 } } // namespace v8::internal |
OLD | NEW |