Revision: 2664
Author: [email protected]
Date: Wed Aug 12 03:27:35 2009
Log: Add api call to determine whether a string can be externalized.

Review URL: http://codereview.chromium.org/164393
http://code.google.com/p/v8/source/detail?r=2664

Modified:
  /branches/bleeding_edge/include/v8.h
  /branches/bleeding_edge/src/api.cc

=======================================
--- /branches/bleeding_edge/include/v8.h        Thu Aug  6 06:35:21 2009
+++ /branches/bleeding_edge/include/v8.h        Wed Aug 12 03:27:35 2009
@@ -901,6 +901,11 @@
     */
    bool MakeExternal(ExternalAsciiStringResource* resource);

+  /**
+   * Returns true if this string can be made external.
+   */
+  bool CanMakeExternal();
+
    /** Creates an undetectable string from the supplied ascii or utf-8  
data.*/
    static Local<String> NewUndetectable(const char* data, int length = -1);

=======================================
--- /branches/bleeding_edge/src/api.cc  Fri Aug  7 11:17:01 2009
+++ /branches/bleeding_edge/src/api.cc  Wed Aug 12 03:27:35 2009
@@ -2986,7 +2986,7 @@
    if (IsDeadCheck("v8::String::MakeExternal()")) return false;
    if (this->IsExternal()) return false;  // Already an external string.
    ENTER_V8;
-  i::Handle <i::String> obj = Utils::OpenHandle(this);
+  i::Handle<i::String> obj = Utils::OpenHandle(this);
    bool result = obj->MakeExternal(resource);
    if (result && !obj->IsSymbol()) {
      // Operation was successful and the string is not a symbol. In this  
case
@@ -3022,7 +3022,7 @@
    if (IsDeadCheck("v8::String::MakeExternal()")) return false;
    if (this->IsExternal()) return false;  // Already an external string.
    ENTER_V8;
-  i::Handle <i::String> obj = Utils::OpenHandle(this);
+  i::Handle<i::String> obj = Utils::OpenHandle(this);
    bool result = obj->MakeExternal(resource);
    if (result && !obj->IsSymbol()) {
      // Operation was successful and the string is not a symbol. In this  
case
@@ -3035,6 +3035,14 @@
    }
    return result;
  }
+
+
+bool v8::String::CanMakeExternal() {
+  if (IsDeadCheck("v8::String::CanMakeExternal()")) return false;
+  i::Handle<i::String> obj = Utils::OpenHandle(this);
+  int size = obj->Size();  // Byte size of the original string.
+  return (size >= i::ExternalString::kSize) && !obj->IsExternalString();
+}


  Local<v8::Object> v8::Object::New() {

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to