Approved by Maciej, Darin.
authorggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Jul 2006 17:41:32 +0000 (17:41 +0000)
committerggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Jul 2006 17:41:32 +0000 (17:41 +0000)
        Renamed JSStringBufferRef to JSInternalStringRef. "Internal string" means the
        JavaScript engine's internal string representation, which is the most
        low-level and efficient representation to use when interfacing with JavaScript.

        * API/APICast.h:
        (toJS):
        (toRef):
        * API/JSBase.h:
        * API/JSCallbackObject.cpp:
        (KJS::JSCallbackObject::getOwnPropertySlot):
        (KJS::JSCallbackObject::put):
        (KJS::JSCallbackObject::deleteProperty):
        (KJS::JSCallbackObject::staticValueGetter):
        (KJS::JSCallbackObject::callbackGetter):
        * API/JSContextRef.cpp:
        (JSEvaluate):
        (JSCheckSyntax):
        * API/JSContextRef.h:
        * API/JSInternalStringRef.cpp: Added.
        (JSStringMake):
        (JSInternalStringCreate):
        (JSInternalStringCreateUTF8):
        (JSInternalStringRetain):
        (JSInternalStringRelease):
        (JSValueCopyStringValue):
        (JSInternalStringGetLength):
        (JSInternalStringGetCharactersPtr):
        (JSInternalStringGetCharacters):
        (JSInternalStringGetMaxLengthUTF8):
        (JSInternalStringGetCharactersUTF8):
        (JSInternalStringIsEqual):
        (JSInternalStringIsEqualUTF8):
        (JSInternalStringCreateCF):
        (CFStringCreateWithJSInternalString):
        * API/JSInternalStringRef.h: Added.
        * API/JSNode.c:
        (JSNodePrototype_appendChild):
        (JSNode_getNodeType):
        (JSNode_getChildNodes):
        (JSNode_getFirstChild):
        * API/JSNodeList.c:
        (JSNodeList_length):
        (JSNodeList_getProperty):
        * API/JSObjectRef.cpp:
        (JSFunctionMakeWithBody):
        (JSObjectGetDescription):
        (JSObjectHasProperty):
        (JSObjectGetProperty):
        (JSObjectSetProperty):
        (JSObjectDeleteProperty):
        (JSPropertyEnumeratorGetNext):
        (JSPropertyListAdd):
        * API/JSObjectRef.h:
        * API/JSStringBufferRef.cpp: Removed.
        * API/JSStringBufferRef.h: Removed.
        * API/JSValueRef.h:
        * API/JavaScriptCore.h:
        * API/minidom.c:
        (main):
        (print):
        * API/testapi.c:
        (assertEqualsAsUTF8String):
        (assertEqualsAsCharactersPtr):
        (assertEqualsAsCharacters):
        (MyObject_hasProperty):
        (MyObject_getProperty):
        (MyObject_setProperty):
        (MyObject_deleteProperty):
        (MyObject_getPropertyList):
        (print_callAsFunction):
        (myConstructor_callAsConstructor):
        (main):
        * JavaScriptCore.exp:
        * JavaScriptCore.xcodeproj/project.pbxproj:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15307 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
JavaScriptCore/API/APICast.h
JavaScriptCore/API/JSBase.h
JavaScriptCore/API/JSCallbackObject.cpp
JavaScriptCore/API/JSContextRef.cpp
JavaScriptCore/API/JSContextRef.h
JavaScriptCore/API/JSInternalSringRef.h [moved from JavaScriptCore/API/JSStringBufferRef.h with 100% similarity]
JavaScriptCore/API/JSInternalStringRef.cpp [moved from JavaScriptCore/API/JSStringBufferRef.cpp with 74% similarity]
JavaScriptCore/API/JSInternalStringRef.h [new file with mode: 0644]
JavaScriptCore/API/JSNode.c
JavaScriptCore/API/JSNodeList.c
JavaScriptCore/API/JSObjectRef.cpp
JavaScriptCore/API/JSObjectRef.h
JavaScriptCore/API/JSValueRef.h
JavaScriptCore/API/JavaScriptCore.h
JavaScriptCore/API/minidom.c
JavaScriptCore/API/testapi.c
JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.exp
JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

index 378861c9c9b1288a57da4009862b97b8f876527d..40e2672e94bef12a4810455f2a7bc709bb773d29 100644 (file)
@@ -49,7 +49,7 @@ inline KJS::JSValue* toJS(JSValueRef v)
     return reinterpret_cast<KJS::JSValue*>(v);
 }
 
-inline KJS::UString::Rep* toJS(JSStringBufferRef b)
+inline KJS::UString::Rep* toJS(JSInternalStringRef b)
 {
     return reinterpret_cast<KJS::UString::Rep*>(b);
 }
@@ -69,9 +69,9 @@ inline JSValueRef toRef(KJS::JSValue* v)
     return reinterpret_cast<JSValueRef>(v);
 }
 
-inline JSStringBufferRef toRef(KJS::UString::Rep* s)
+inline JSInternalStringRef toRef(KJS::UString::Rep* s)
 {
-    return reinterpret_cast<JSStringBufferRef>(s);
+    return reinterpret_cast<JSInternalStringRef>(s);
 }
 
 inline JSObjectRef toRef(KJS::JSObject* o)
index 1280525242ccddd5110f0caa32d17696939325eb..ee6773d732880eee89fdde7b7efa53f87ad46fea 100644 (file)
@@ -31,8 +31,8 @@
 
 /*! @typedef JSContextRef A JavaScript execution context. Holds the global object and other execution state. */
 typedef struct __JSContext* JSContextRef;
-/*! @typedef JSStringBuffer A UTF16 character buffer. The fundamental string representation in JavaScript. */
-typedef struct __JSStringBuffer* JSStringBufferRef;
+/*! @typedef JSInternalString A UTF16 character buffer. The fundamental string representation in JavaScript. */
+typedef struct __JSInternalString* JSInternalStringRef;
 /*! @typedef JSClassRef A JavaScript class. Used with JSObjectMake to construct objects with custom behavior. */
 typedef struct __JSClass* JSClassRef;
 /*! @typedef JSPropertyListRef A JavaScript property list. Used for listing the properties in an object so they can be enumerated. */
index 07bb2557282b22e8ba3fc0c37ce300cf1a238d6e..2213bcf4f0fabb192d80786dce854dc80a3c2d1b 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "APICast.h"
 #include "JSCallbackObject.h"
-#include "JSStringBufferRef.h"
+#include "JSInternalStringRef.h"
 #include "JSClassRef.h"
 #include "JSObjectRef.h"
 #include "internal.h"
@@ -82,7 +82,7 @@ bool JSCallbackObject::getOwnPropertySlot(ExecState* exec, const Identifier& pro
 {
     JSContextRef context = toRef(exec);
     JSObjectRef thisRef = toRef(this);
-    JSStringBufferRef propertyNameRef = toRef(propertyName.ustring().rep());
+    JSInternalStringRef propertyNameRef = toRef(propertyName.ustring().rep());
     
     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) {
         // optional optimization to bypass getProperty in cases when we only need to know if the property exists
@@ -131,7 +131,7 @@ void JSCallbackObject::put(ExecState* exec, const Identifier& propertyName, JSVa
 {
     JSContextRef context = toRef(exec);
     JSObjectRef thisRef = toRef(this);
-    JSStringBufferRef propertyNameRef = toRef(propertyName.ustring().rep());
+    JSInternalStringRef propertyNameRef = toRef(propertyName.ustring().rep());
 
     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) {
         if (JSSetPropertyCallback setPropertyCallback = jsClass->callbacks.setProperty) {
@@ -171,7 +171,7 @@ bool JSCallbackObject::deleteProperty(ExecState* exec, const Identifier& propert
 {
     JSContextRef context = toRef(exec);
     JSObjectRef thisRef = toRef(this);
-    JSStringBufferRef propertyNameRef = toRef(propertyName.ustring().rep());
+    JSInternalStringRef propertyNameRef = toRef(propertyName.ustring().rep());
     
     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) {
         if (JSDeletePropertyCallback deletePropertyCallback = jsClass->callbacks.deleteProperty) {
@@ -371,7 +371,7 @@ JSValue* JSCallbackObject::staticValueGetter(ExecState* exec, JSObject*, const I
     JSCallbackObject* thisObj = static_cast<JSCallbackObject*>(slot.slotBase());
 
     JSObjectRef thisRef = toRef(thisObj);
-    JSStringBufferRef propertyNameRef = toRef(propertyName.ustring().rep());
+    JSInternalStringRef propertyNameRef = toRef(propertyName.ustring().rep());
 
     for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parent) {
         JSValueRef returnValue;
@@ -413,7 +413,7 @@ JSValue* JSCallbackObject::callbackGetter(ExecState* exec, JSObject*, const Iden
     JSCallbackObject* thisObj = static_cast<JSCallbackObject*>(slot.slotBase());
 
     JSObjectRef thisRef = toRef(thisObj);
-    JSStringBufferRef propertyNameRef = toRef(propertyName.ustring().rep());
+    JSInternalStringRef propertyNameRef = toRef(propertyName.ustring().rep());
 
     for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parent) {
         JSValueRef returnValue;
index 29a18787c530d1375b2bbe26d23a7d7758b0ad07..58d01c73b2966235b61a653825e387f99f972189 100644 (file)
@@ -62,7 +62,7 @@ JSObjectRef JSContextGetGlobalObject(JSContextRef context)
     return toRef(exec->dynamicInterpreter()->globalObject());
 }
 
-JSValueRef JSEvaluate(JSContextRef context, JSStringBufferRef script, JSObjectRef thisObject, JSStringBufferRef sourceURL, int startingLineNumber, JSValueRef* exception)
+JSValueRef JSEvaluate(JSContextRef context, JSInternalStringRef script, JSObjectRef thisObject, JSInternalStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
 {
     JSLock lock;
     ExecState* exec = toJS(context);
@@ -85,7 +85,7 @@ JSValueRef JSEvaluate(JSContextRef context, JSStringBufferRef script, JSObjectRe
     return toRef(jsUndefined());
 }
 
-bool JSCheckSyntax(JSContextRef context, JSStringBufferRef script, JSStringBufferRef sourceURL, int startingLineNumber, JSValueRef* exception)
+bool JSCheckSyntax(JSContextRef context, JSInternalStringRef script, JSInternalStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
 {
     JSLock lock;
 
index 82a3b234c11d93dbb140c4d4856abea46b04c44a..2da2519b4590c3ae34fef1ee4131a1c7b5a307c7 100644 (file)
@@ -86,26 +86,26 @@ void JSContextClearException(JSContextRef context);
 @function
 @abstract                 Evaluates a string of JavaScript.
 @param context            The execution context to use.
-@param script             A JSStringBuffer containing the script to evaluate.
+@param script             A JSInternalString containing the script to evaluate.
 @param thisObject         The object to use as "this," or NULL to use the global object as "this."
-@param sourceURL          A JSStringBuffer containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
+@param sourceURL          A JSInternalString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
 @param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions.
 @param exception          A pointer to a JSValueRef in which to store an uncaught exception, if any. Pass NULL if you do not care to store an uncaught exception.
 @result                   The JSValue that results from evaluating script, or NULL if an uncaught exception is thrown.
 */
-JSValueRef JSEvaluate(JSContextRef context, JSStringBufferRef script, JSObjectRef thisObject, JSStringBufferRef sourceURL, int startingLineNumber, JSValueRef* exception);
+JSValueRef JSEvaluate(JSContextRef context, JSInternalStringRef script, JSObjectRef thisObject, JSInternalStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
 
 /*!
 @function JSCheckSyntax
 @abstract                 Checks for syntax errors in a string of JavaScript.
 @param context            The execution context to use.
-@param script             A JSStringBuffer containing the JavaScript to check for syntax errors.
-@param sourceURL          A JSStringBuffer containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
+@param script             A JSInternalString containing the JavaScript to check for syntax errors.
+@param sourceURL          A JSInternalString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
 @param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions.
 @param exception          A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception.
 @result                   true if the script is syntactically correct, otherwise false.
 */
-bool JSCheckSyntax(JSContextRef context, JSStringBufferRef script, JSStringBufferRef sourceURL, int startingLineNumber, JSValueRef* exception);
+bool JSCheckSyntax(JSContextRef context, JSInternalStringRef script, JSInternalStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
 
 #ifdef __cplusplus
 }
similarity index 74%
rename from JavaScriptCore/API/JSStringBufferRef.cpp
rename to JavaScriptCore/API/JSInternalStringRef.cpp
index 7594b9060e1115ef46ef68cf6e3a7b9309669b6d..ec5de02426edefb747eed80a5513eb56bc4392cd 100644 (file)
@@ -25,7 +25,7 @@
  */
 
 #include "APICast.h"
-#include "JSStringBufferRef.h"
+#include "JSInternalStringRef.h"
 
 #include <kjs/JSLock.h>
 #include <kjs/JSType.h>
 
 using namespace KJS;
 
-JSValueRef JSStringMake(JSStringBufferRef buffer)
+JSValueRef JSStringMake(JSInternalStringRef buffer)
 {
     JSLock lock;
     UString::Rep* rep = toJS(buffer);
     return toRef(jsString(UString(rep)));
 }
 
-JSStringBufferRef JSStringBufferCreate(const JSChar* chars, size_t numChars)
+JSInternalStringRef JSInternalStringCreate(const JSChar* chars, size_t numChars)
 {
     JSLock lock;
     return toRef(UString(reinterpret_cast<const UChar*>(chars), numChars).rep()->ref());
 }
 
-JSStringBufferRef JSStringBufferCreateUTF8(const char* string)
+JSInternalStringRef JSInternalStringCreateUTF8(const char* string)
 {
     JSLock lock;
     // FIXME: Only works with ASCII
@@ -57,44 +57,44 @@ JSStringBufferRef JSStringBufferCreateUTF8(const char* string)
     return toRef(UString(string).rep()->ref());
 }
 
-JSStringBufferRef JSStringBufferRetain(JSStringBufferRef buffer)
+JSInternalStringRef JSInternalStringRetain(JSInternalStringRef buffer)
 {
     UString::Rep* rep = toJS(buffer);
     return toRef(rep->ref());
 }
 
-void JSStringBufferRelease(JSStringBufferRef buffer)
+void JSInternalStringRelease(JSInternalStringRef buffer)
 {
     JSLock lock;
     UString::Rep* rep = toJS(buffer);
     rep->deref();
 }
 
-JSStringBufferRef JSValueCopyStringValue(JSContextRef context, JSValueRef value)
+JSInternalStringRef JSValueCopyStringValue(JSContextRef context, JSValueRef value)
 {
     JSLock lock;
     JSValue* jsValue = toJS(value);
     ExecState* exec = toJS(context);
 
-    JSStringBufferRef charBufferRef = toRef(jsValue->toString(exec).rep()->ref());
+    JSInternalStringRef charBufferRef = toRef(jsValue->toString(exec).rep()->ref());
     if (exec->hadException())
         exec->clearException();
     return charBufferRef;
 }
 
-size_t JSStringBufferGetLength(JSStringBufferRef buffer)
+size_t JSInternalStringGetLength(JSInternalStringRef buffer)
 {
     UString::Rep* rep = toJS(buffer);
     return rep->size();
 }
 
-const JSChar* JSStringBufferGetCharactersPtr(JSStringBufferRef buffer)
+const JSChar* JSInternalStringGetCharactersPtr(JSInternalStringRef buffer)
 {
     UString::Rep* rep = toJS(buffer);
     return reinterpret_cast<const JSChar*>(rep->data());
 }
 
-void JSStringBufferGetCharacters(JSStringBufferRef inBuffer, JSChar* outBuffer, size_t numChars)
+void JSInternalStringGetCharacters(JSInternalStringRef inBuffer, JSChar* outBuffer, size_t numChars)
 {
     UString::Rep* rep = toJS(inBuffer);
     const JSChar* data = reinterpret_cast<const JSChar*>(rep->data());
@@ -102,7 +102,7 @@ void JSStringBufferGetCharacters(JSStringBufferRef inBuffer, JSChar* outBuffer,
     memcpy(outBuffer, data, numChars * sizeof(JSChar));
 }
 
-size_t JSStringBufferGetMaxLengthUTF8(JSStringBufferRef buffer)
+size_t JSInternalStringGetMaxLengthUTF8(JSInternalStringRef buffer)
 {
     UString::Rep* rep = toJS(buffer);
     
@@ -110,7 +110,7 @@ size_t JSStringBufferGetMaxLengthUTF8(JSStringBufferRef buffer)
     return rep->size() * 3 + 1; // + 1 for terminating '\0'
 }
 
-size_t JSStringBufferGetCharactersUTF8(JSStringBufferRef inBuffer, char* outBuffer, size_t bufferSize)
+size_t JSInternalStringGetCharactersUTF8(JSInternalStringRef inBuffer, char* outBuffer, size_t bufferSize)
 {
     JSLock lock;
     UString::Rep* rep = toJS(inBuffer);
@@ -121,7 +121,7 @@ size_t JSStringBufferGetCharactersUTF8(JSStringBufferRef inBuffer, char* outBuff
     return length;
 }
 
-bool JSStringBufferIsEqual(JSStringBufferRef a, JSStringBufferRef b)
+bool JSInternalStringIsEqual(JSInternalStringRef a, JSInternalStringRef b)
 {
     UString::Rep* aRep = toJS(a);
     UString::Rep* bRep = toJS(b);
@@ -129,17 +129,17 @@ bool JSStringBufferIsEqual(JSStringBufferRef a, JSStringBufferRef b)
     return UString(aRep) == UString(bRep);
 }
 
-bool JSStringBufferIsEqualUTF8(JSStringBufferRef a, const char* b)
+bool JSInternalStringIsEqualUTF8(JSInternalStringRef a, const char* b)
 {
-    JSStringBufferRef bBuf = JSStringBufferCreateUTF8(b);
-    bool result = JSStringBufferIsEqual(a, bBuf);
-    JSStringBufferRelease(bBuf);
+    JSInternalStringRef bBuf = JSInternalStringCreateUTF8(b);
+    bool result = JSInternalStringIsEqual(a, bBuf);
+    JSInternalStringRelease(bBuf);
     
     return result;
 }
 
 #if defined(__APPLE__)
-JSStringBufferRef JSStringBufferCreateCF(CFStringRef string)
+JSInternalStringRef JSInternalStringCreateCF(CFStringRef string)
 {
     JSLock lock;
     CFIndex length = CFStringGetLength(string);
@@ -156,7 +156,7 @@ JSStringBufferRef JSStringBufferCreateCF(CFStringRef string)
     return toRef(rep);
 }
 
-CFStringRef CFStringCreateWithJSStringBuffer(CFAllocatorRef alloc, JSStringBufferRef buffer)
+CFStringRef CFStringCreateWithJSInternalString(CFAllocatorRef alloc, JSInternalStringRef buffer)
 {
     UString::Rep* rep = toJS(buffer);
     return CFStringCreateWithCharacters(alloc, reinterpret_cast<const JSChar*>(rep->data()), rep->size());
diff --git a/JavaScriptCore/API/JSInternalStringRef.h b/JavaScriptCore/API/JSInternalStringRef.h
new file mode 100644 (file)
index 0000000..824b77b
--- /dev/null
@@ -0,0 +1,171 @@
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef JSInternalStringRef_h
+#define JSInternalStringRef_h
+
+#include "JSValueRef.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*!
+@typedef JSChar
+@abstract A Unicode character.
+*/
+#if !defined(WIN32) && !defined(_WIN32)
+    typedef unsigned short JSChar;
+#else
+    typedef wchar_t JSChar;
+#endif
+
+/*!
+@function
+@abstract         Creates a JavaScript string from a buffer of Unicode characters.
+@param chars      The buffer of Unicode characters to copy into the new JSInternalString.
+@param numChars   The number of characters to copy from the buffer pointed to by chars.
+@result           A JSInternalString containing chars. Ownership follows the create rule.
+*/
+JSInternalStringRef JSInternalStringCreate(const JSChar* chars, size_t numChars);
+/*!
+@function
+@abstract         Creates a JavaScript string from a null-terminated UTF8 string.
+@param string     The null-terminated UTF8 string to copy into the new JSInternalString.
+@result           A JSInternalString containing string. Ownership follows the create rule.
+*/
+JSInternalStringRef JSInternalStringCreateUTF8(const char* string);
+
+/*!
+@function
+@abstract         Retains a JavaScript string.
+@param buffer     The JSInternalString to retain.
+@result           A JSInternalString that is the same as buffer.
+*/
+JSInternalStringRef JSInternalStringRetain(JSInternalStringRef buffer);
+/*!
+@function
+@abstract         Releases a JavaScript string.
+@param buffer     The JSInternalString to release.
+*/
+void JSInternalStringRelease(JSInternalStringRef buffer);
+
+/*!
+@function
+@abstract         Returns the number of Unicode characters in a JavaScript string.
+@param buffer     The JSInternalString whose length (in Unicode characters) you want to know.
+@result           The number of Unicode characters stored in buffer.
+*/
+size_t JSInternalStringGetLength(JSInternalStringRef buffer);
+/*!
+@function
+@abstract         Quickly obtains a pointer to the Unicode character buffer that 
+ serves as the backing store for a JavaScript string.
+@param buffer     The JSInternalString whose backing store you want to access.
+@result           A pointer to the Unicode character buffer that serves as buffer's 
+ backing store, which will be deallocated when buffer is deallocated.
+*/
+const JSChar* JSInternalStringGetCharactersPtr(JSInternalStringRef buffer);
+/*!
+@function
+@abstract         Copies a JavaScript string's Unicode characters into an 
+ external character buffer.
+@param inBuffer   The source JSInternalString.
+@param outBuffer  The destination JSChar buffer into which to copy inBuffer's 
+ characters. On return, outBuffer contains the requested Unicode characters.
+@param numChars   The number of Unicode characters to copy. This number must not 
+ exceed the length of the string.
+*/
+void JSInternalStringGetCharacters(JSInternalStringRef inBuffer, JSChar* outBuffer, size_t numChars);
+
+/*!
+@function
+@abstract         Returns the maximum number of bytes required to encode the 
+ contents of a JavaScript string as a null-terminated UTF8 string.
+@param buffer     The JSInternalString whose maximum encoded length (in bytes) you 
+ want to know.
+@result           The maximum number of bytes required to encode buffer's contents 
+ as a null-terminated UTF8 string.
+*/
+size_t JSInternalStringGetMaxLengthUTF8(JSInternalStringRef buffer);
+/*!
+@function
+@abstract         Converts a JavaScript string's contents into a 
+ null-terminated UTF8 string, and copies the result into an external byte buffer.
+@param inBuffer   The source JSInternalString.
+@param outBuffer  The destination byte buffer into which to copy a UTF8 string 
+ representation of inBuffer. The buffer must be at least bufferSize bytes in length. 
+ On return, outBuffer contains a UTF8 string representation of inBuffer. 
+ If bufferSize is too small, outBuffer will contain only partial results.
+@param bufferSize The length of the external buffer in bytes.
+@result           The number of bytes written into outBuffer (including the null-terminator byte).
+*/
+size_t JSInternalStringGetCharactersUTF8(JSInternalStringRef inBuffer, char* outBuffer, size_t bufferSize);
+
+/*!
+@function
+@abstract     Tests whether the characters in two JavaScript strings match.
+@param a      The first JSInternalString to test.
+@param b      The second JSInternalString to test.
+@result       true if the characters in the two buffers match, otherwise false.
+*/
+bool JSInternalStringIsEqual(JSInternalStringRef a, JSInternalStringRef b);
+/*!
+@function
+@abstract     Tests whether the characters in a JavaScript string match 
+ the characters in a null-terminated UTF8 string.
+@param a      The JSInternalString to test.
+@param b      The null-terminated UTF8 string to test.
+@result       true if the characters in the two buffers match, otherwise false.
+*/
+bool JSInternalStringIsEqualUTF8(JSInternalStringRef a, const char* b);
+
+#if defined(__APPLE__)
+#include <CoreFoundation/CoreFoundation.h>
+// CFString convenience methods
+/*!
+@function
+@abstract         Creates a JavaScript string from a CFString.
+@discussion       This function is optimized to take advantage of cases when 
+ CFStringGetCharactersPtr returns a valid pointer.
+@param string     The CFString to copy into the new JSInternalString.
+@result           A JSInternalString containing string. Ownership follows the create rule.
+*/
+JSInternalStringRef JSInternalStringCreateCF(CFStringRef string);
+/*!
+@function
+@abstract         Creates a CFString form a JavaScript string.
+@param alloc      The alloc parameter to pass to CFStringCreate.
+@param buffer     The JSInternalString to copy into the new CFString.
+@result           A CFString containing buffer. Ownership follows the create rule.
+*/
+CFStringRef CFStringCreateWithJSInternalString(CFAllocatorRef alloc, JSInternalStringRef buffer);
+#endif // __APPLE__
+    
+#ifdef __cplusplus
+}
+#endif
+
+#endif // JSInternalStringRef_h
index 335cda41eba36379bad692330ac1ff087d0f2f2a..e78317b9f2c86ed53972587ab59bfb702c1dffab 100644 (file)
@@ -39,13 +39,13 @@ static JSValueRef JSNodePrototype_appendChild(JSContextRef context, JSObjectRef
 
     // Example of throwing a type error for invalid values
     if (!JSValueIsObjectOfClass(thisObject, JSNode_class(context))) {
-        JSStringBufferRef messageBuf = JSStringBufferCreateUTF8("TypeError: appendChild can only be called on nodes");
+        JSInternalStringRef messageBuf = JSInternalStringCreateUTF8("TypeError: appendChild can only be called on nodes");
         JSContextSetException(context, JSStringMake(messageBuf));
-        JSStringBufferRelease(messageBuf);
+        JSInternalStringRelease(messageBuf);
     } else if (argc < 1 || !JSValueIsObjectOfClass(argv[0], JSNode_class(context))) {
-        JSStringBufferRef messageBuf = JSStringBufferCreateUTF8("TypeError: first argument to appendChild must be a node");
+        JSInternalStringRef messageBuf = JSInternalStringCreateUTF8("TypeError: first argument to appendChild must be a node");
         JSContextSetException(context, JSStringMake(messageBuf));
-        JSStringBufferRelease(messageBuf);
+        JSInternalStringRelease(messageBuf);
     } else {
         Node* node = JSObjectGetPrivate(thisObject);
         Node* child = JSObjectGetPrivate(argv[0]);
@@ -113,22 +113,22 @@ static JSClassRef JSNodePrototype_class(JSContextRef context)
     return nodePrototypeClass;
 }
 
-static bool JSNode_getNodeType(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName, JSValueRef* returnValue)
+static bool JSNode_getNodeType(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef* returnValue)
 {
     UNUSED_PARAM(context);
     UNUSED_PARAM(propertyName);
 
     Node* node = JSObjectGetPrivate(object);
     if (node) {
-        JSStringBufferRef nodeBuf = JSStringBufferCreateUTF8(node->nodeType);
+        JSInternalStringRef nodeBuf = JSInternalStringCreateUTF8(node->nodeType);
         *returnValue = JSStringMake(nodeBuf);
-        JSStringBufferRelease(nodeBuf);
+        JSInternalStringRelease(nodeBuf);
         return true;
     }
     return false;
 }
 
-static bool JSNode_getChildNodes(JSContextRef context, JSObjectRef thisObject, JSStringBufferRef propertyName, JSValueRef* returnValue)
+static bool JSNode_getChildNodes(JSContextRef context, JSObjectRef thisObject, JSInternalStringRef propertyName, JSValueRef* returnValue)
 {
     UNUSED_PARAM(propertyName);
     Node* node = JSObjectGetPrivate(thisObject);
@@ -137,7 +137,7 @@ static bool JSNode_getChildNodes(JSContextRef context, JSObjectRef thisObject, J
     return true;
 }
 
-static bool JSNode_getFirstChild(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName, JSValueRef* returnValue)
+static bool JSNode_getFirstChild(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef* returnValue)
 {
     UNUSED_PARAM(context);
     UNUSED_PARAM(propertyName);
index 29a181398d0d72ccbd0aad8b4f3b6050507b6b95..9c3dac6376115264d2148c1b032adae830eb8554 100644 (file)
@@ -56,7 +56,7 @@ static JSClassRef JSNodeListPrototype_class(JSContextRef context)
     return jsClass;
 }
 
-static bool JSNodeList_length(JSContextRef context, JSObjectRef thisObject, JSStringBufferRef propertyName, JSValueRef* returnValue)
+static bool JSNodeList_length(JSContextRef context, JSObjectRef thisObject, JSInternalStringRef propertyName, JSValueRef* returnValue)
 {
     UNUSED_PARAM(context);
     
@@ -71,7 +71,7 @@ static JSStaticValue JSNodeList_staticValues[] = {
     { 0, 0, 0, 0 }
 };
 
-static bool JSNodeList_getProperty(JSContextRef context, JSObjectRef thisObject, JSStringBufferRef propertyName, JSValueRef* returnValue)
+static bool JSNodeList_getProperty(JSContextRef context, JSObjectRef thisObject, JSInternalStringRef propertyName, JSValueRef* returnValue)
 {
     NodeList* nodeList = JSObjectGetPrivate(thisObject);
     assert(nodeList);
index d0b8758f6689330610af27d718850dc4068f154e..967d42a90b807a3523621724417886c9028c5b81 100644 (file)
@@ -70,7 +70,7 @@ JSObjectRef JSConstructorMake(JSContextRef context, JSCallAsConstructorCallback
     return toRef(new JSCallbackConstructor(exec, callAsConstructor));
 }
 
-JSObjectRef JSFunctionMakeWithBody(JSContextRef context, JSStringBufferRef body, JSStringBufferRef sourceURL, int startingLineNumber, JSValueRef* exception)
+JSObjectRef JSFunctionMakeWithBody(JSContextRef context, JSInternalStringRef body, JSInternalStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
 {
     JSLock lock;
     
@@ -96,7 +96,7 @@ JSObjectRef JSFunctionMakeWithBody(JSContextRef context, JSStringBufferRef body,
     return toRef(static_cast<JSObject*>(new DeclaredFunctionImp(exec, "anonymous", bodyNode.get(), scopeChain)));
 }
 
-JSStringBufferRef JSObjectGetDescription(JSObjectRef object)
+JSInternalStringRef JSObjectGetDescription(JSObjectRef object)
 {
     JSLock lock;
     JSObject* jsObject = toJS(object);
@@ -117,7 +117,7 @@ void JSObjectSetPrototype(JSObjectRef object, JSValueRef value)
     jsObject->setPrototype(jsValue);
 }
 
-bool JSObjectHasProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName)
+bool JSObjectHasProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName)
 {
     JSLock lock;
     ExecState* exec = toJS(context);
@@ -127,7 +127,7 @@ bool JSObjectHasProperty(JSContextRef context, JSObjectRef object, JSStringBuffe
     return jsObject->hasProperty(exec, Identifier(nameRep));
 }
 
-JSValueRef JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName)
+JSValueRef JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName)
 {
     JSLock lock;
     ExecState* exec = toJS(context);
@@ -140,7 +140,7 @@ JSValueRef JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSStrin
     return jsValue;
 }
 
-bool JSObjectSetProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName, JSValueRef value, JSPropertyAttributes attributes)
+bool JSObjectSetProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes)
 {
     JSLock lock;
     ExecState* exec = toJS(context);
@@ -156,7 +156,7 @@ bool JSObjectSetProperty(JSContextRef context, JSObjectRef object, JSStringBuffe
         return false;
 }
 
-bool JSObjectDeleteProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName)
+bool JSObjectDeleteProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName)
 {
     JSLock lock;
     ExecState* exec = toJS(context);
@@ -284,11 +284,11 @@ JSPropertyEnumeratorRef JSObjectCreatePropertyEnumerator(JSContextRef context, J
     return JSPropertyEnumeratorRetain(enumerator);
 }
 
-JSStringBufferRef JSPropertyEnumeratorGetNext(JSPropertyEnumeratorRef enumerator)
+JSInternalStringRef JSPropertyEnumeratorGetNext(JSPropertyEnumeratorRef enumerator)
 {
     ReferenceListIterator& iterator = enumerator->iterator;
     if (iterator != enumerator->list.end()) {
-        JSStringBufferRef result = toRef(iterator->getPropertyName().ustring().rep());
+        JSInternalStringRef result = toRef(iterator->getPropertyName().ustring().rep());
         iterator++;
         return result;
     }
@@ -307,7 +307,7 @@ void JSPropertyEnumeratorRelease(JSPropertyEnumeratorRef enumerator)
         delete enumerator;
 }
 
-void JSPropertyListAdd(JSPropertyListRef propertyList, JSObjectRef thisObject, JSStringBufferRef propertyName)
+void JSPropertyListAdd(JSPropertyListRef propertyList, JSObjectRef thisObject, JSInternalStringRef propertyName)
 {
     JSLock lock;
     ReferenceList* jsPropertyList = toJS(propertyList);
index bd7302a147b24f3ddc3edc52b6743951e8f61533..67a0b01db3073f795301644827be4e66c7095b6c 100644 (file)
@@ -82,66 +82,66 @@ typedef void
 @abstract The callback invoked when determining whether an object has a given property.
 @param context The current execution context.
 @param object The JSObject to search for the property.
-@param propertyName A JSStringBuffer containing the name of the property look up.
+@param propertyName A JSInternalString containing the name of the property look up.
 @result true if object has the property, otherwise false.
 @discussion If you named your function HasProperty, you would declare it like this:
 
-bool HasProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName);
+bool HasProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName);
 
 This callback enables optimization in cases where only a property's existence needs to be known, not its value, and computing its value would be expensive. If this callback is NULL, the getProperty callback will be used to service hasProperty calls.
 */
 typedef bool
-(*JSHasPropertyCallback)        (JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName);
+(*JSHasPropertyCallback)        (JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName);
 
 /*! 
 @typedef JSGetPropertyCallback
 @abstract The callback invoked when getting a property from an object.
 @param context The current execution context.
 @param object The JSObject to search for the property.
-@param propertyName A JSStringBuffer containing the name of the property to get.
+@param propertyName A JSInternalString containing the name of the property to get.
 @param returnValue A pointer to a JSValue in which to store the property's value.
 @result true if object has the property in question, otherwise false. If this function returns true, returnValue is assumed to contain a valid JSValue.
 @discussion If you named your function GetProperty, you would declare it like this:
 
-bool GetProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName, JSValueRef* returnValue);
+bool GetProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef* returnValue);
 
 If this function returns false, the get request forwards to object's static property table, then its parent class chain (which includes the default object class), then its prototype chain.
 */
 typedef bool
-(*JSGetPropertyCallback)        (JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName, JSValueRef* returnValue);
+(*JSGetPropertyCallback)        (JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef* returnValue);
 
 /*! 
 @typedef JSSetPropertyCallback
 @abstract The callback invoked when setting the value of a given property.
 @param context The current execution context.
 @param object The JSObject on which to set the property's value.
-@param propertyName A JSStringBuffer containing the name of the property to set.
+@param propertyName A JSInternalString containing the name of the property to set.
 @param value A JSValue to use as the property's value.
 @result true if the property was successfully set, otherwise false.
 @discussion If you named your function SetProperty, you would declare it like this:
 
-bool SetProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName, JSValueRef value);
+bool SetProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef value);
 
 If this function returns false, the set request forwards to object's static property table, then its parent class chain (which includes the default object class).
 */
 typedef bool
-(*JSSetPropertyCallback)        (JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName, JSValueRef value);
+(*JSSetPropertyCallback)        (JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef value);
 
 /*! 
 @typedef JSDeletePropertyCallback
 @abstract The callback invoked when deleting a given property.
 @param context The current execution context.
 @param object The JSObject in which to delete the property.
-@param propertyName A JSStringBuffer containing the name of the property to delete.
+@param propertyName A JSInternalString containing the name of the property to delete.
 @result true if propertyName was successfully deleted, otherwise false.
 @discussion If you named your function DeleteProperty, you would declare it like this:
 
-bool DeleteProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName);
+bool DeleteProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName);
 
 If this function returns false, the delete request forwards to object's static property table, then its parent class chain (which includes the default object class).
 */
 typedef bool
-(*JSDeletePropertyCallback)     (JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName);
+(*JSDeletePropertyCallback)     (JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName);
 
 /*! 
 @typedef JSGetPropertyListCallback
@@ -339,23 +339,23 @@ JSObjectRef JSConstructorMake(JSContextRef context, JSCallAsConstructorCallback
 @function
 @abstract Creates a function with a given script as its body.
 @param context The execution context to use.
-@param body A JSStringBuffer containing the script to use as the function's body.
-@param sourceURL A JSStringBuffer containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
+@param body A JSInternalString containing the script to use as the function's body.
+@param sourceURL A JSInternalString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
 @param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions.
 @param exception A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception.
 @result A JSObject that is an anonymous function, or NULL if body contains a syntax error. The returned object's prototype will be the default function prototype.
 @discussion Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution.
 */
-JSObjectRef JSFunctionMakeWithBody(JSContextRef context, JSStringBufferRef body, JSStringBufferRef sourceURL, int startingLineNumber, JSValueRef* exception);
+JSObjectRef JSFunctionMakeWithBody(JSContextRef context, JSInternalStringRef body, JSInternalStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
 
 /*!
 @function
 @abstract Gets a short description of a JavaScript object.
 @param context The execution context to use.
 @param object The object whose description you want to get.
-@result A JSStringBuffer containing the object's description. This is usually the object's class name.
+@result A JSInternalString containing the object's description. This is usually the object's class name.
 */
-JSStringBufferRef JSObjectGetDescription(JSObjectRef object);
+JSInternalStringRef JSObjectGetDescription(JSObjectRef object);
 
 /*!
 @function
@@ -376,39 +376,39 @@ void JSObjectSetPrototype(JSObjectRef object, JSValueRef value);
 @function
 @abstract Tests whether an object has a certain property.
 @param object The JSObject to test.
-@param propertyName A JSStringBuffer containing the property's name.
+@param propertyName A JSInternalString containing the property's name.
 @result true if the object has a property whose name matches propertyName, otherwise false.
 */
-bool JSObjectHasProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName);
+bool JSObjectHasProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName);
 /*!
 @function
 @abstract Gets a property from an object.
 @param context The execution context to use.
 @param object The JSObject whose property you want to get.
-@param propertyName A JSStringBuffer containing the property's name.
+@param propertyName A JSInternalString containing the property's name.
 @result The property's value, or NULL if the object does not have a property whose name matches propertyName.
 */
-JSValueRef JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName);
+JSValueRef JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName);
 /*!
 @function
 @abstract Sets a property on an object.
 @param context The execution context to use.
 @param object The JSObject whose property you want to set.
-@param propertyName A JSStringBuffer containing the property's name.
+@param propertyName A JSInternalString containing the property's name.
 @param value A JSValue to use as the property's value.
 @param attributes A logically ORed set of JSPropertyAttributes to give to the property.
 @result true if the set operation succeeds, otherwise false (for example, if the object already has a property of the given name with the kJSPropertyAttributeReadOnly attribute set).
 */
-bool JSObjectSetProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName, JSValueRef value, JSPropertyAttributes attributes);
+bool JSObjectSetProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes);
 /*!
 @function
 @abstract Deletes a property from an object.
 @param context The execution context to use.
 @param object The JSObject whose property you want to delete.
-@param propertyName A JSStringBuffer containing the property's name.
+@param propertyName A JSInternalString containing the property's name.
 @result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).
 */
-bool JSObjectDeleteProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName);
+bool JSObjectDeleteProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName);
 
 /*!
 @function
@@ -491,9 +491,9 @@ void JSPropertyEnumeratorRelease(JSPropertyEnumeratorRef enumerator);
 @function
 @abstract Gets a property enumerator's next property.
 @param enumerator The JSPropertyEnumerator whose next property you want to get.
-@result A JSStringBuffer containing the property's name, or NULL if all properties have been enumerated.
+@result A JSInternalString containing the property's name, or NULL if all properties have been enumerated.
 */
-JSStringBufferRef JSPropertyEnumeratorGetNext(JSPropertyEnumeratorRef enumerator);
+JSInternalStringRef JSPropertyEnumeratorGetNext(JSPropertyEnumeratorRef enumerator);
 
 /*!
 @function
@@ -501,9 +501,9 @@ JSStringBufferRef JSPropertyEnumeratorGetNext(JSPropertyEnumeratorRef enumerator
 @discussion Use this method inside a JSGetPropertyListCallback to add a custom property to an object's property list.
 @param propertyList The JSPropertyList to which you want to add a property.
 @param thisObject The JSObject to which the property belongs.
-@param propertyName A JSStringBuffer specifying the property's name.
+@param propertyName A JSInternalString specifying the property's name.
 */
-void JSPropertyListAdd(JSPropertyListRef propertyList, JSObjectRef thisObject, JSStringBufferRef propertyName);
+void JSPropertyListAdd(JSPropertyListRef propertyList, JSObjectRef thisObject, JSInternalStringRef propertyName);
 
 #ifdef __cplusplus
 }
index 8347b0dc67a5b9ecd6a8c473b2addfec4deedb9a..7234aaed85378988c5a2f6b77544a2b0f6740d54 100644 (file)
@@ -188,11 +188,11 @@ JSValueRef JSNumberMake(double value);
 /*!
 @function
 @abstract       Creates a JavaScript value of the string type.
-@param buffer   The JSStringBuffer to assign to the newly created JSValue. The
+@param buffer   The JSInternalString to assign to the newly created JSValue. The
  newly created JSValue retains buffer, and releases it upon garbage collection.
 @result         A JSValue of the string type, representing the string value of buffer.
 */
-JSValueRef JSStringMake(JSStringBufferRef buffer);
+JSValueRef JSStringMake(JSInternalStringRef buffer);
 
 // Converting to primitive values
 
@@ -217,13 +217,13 @@ double JSValueToNumber(JSContextRef context, JSValueRef value);
 /*!
 @function
 @abstract       Converts a JavaScript value to string and copies the resulting
- string into a newly allocated JavaScript string buffer.
+ string into a newly allocated JavaScript string.
 @param context  The execution context to use.
 @param value    The JSValue to convert.
-@result         A JSStringBuffer containing the result of conversion, or an empty
- string buffer if conversion fails. Ownership follows the copy rule.
+@result         A JSInternalString containing the result of conversion, or an empty
+ string if conversion fails. Ownership follows the copy rule.
 */
-JSStringBufferRef JSValueCopyStringValue(JSContextRef context, JSValueRef value);
+JSInternalStringRef JSValueCopyStringValue(JSContextRef context, JSValueRef value);
 
 /*!
 @function
index c81d2b3fa0bd039c5a0cf591f7b2b0773132a2ac..0e0b1304167883fe55a0c829d60b613858741b8f 100644 (file)
@@ -31,7 +31,7 @@
 #include <stddef.h> // for size_t
 
 #include "JSBase.h"
-#include "JSStringBufferRef.h"
+#include "JSInternalStringRef.h"
 #include "JSContextRef.h"
 #include "JSObjectRef.h"
 #include "JSValueRef.h"
index 2771fc0a982b4e4c573fed782e112a326f95eba8..e1521aca5bd6e1ffd5642626a369ab0967ace57d 100644 (file)
@@ -39,29 +39,29 @@ int main(int argc, char* argv[])
     JSContextRef context = JSContextCreate(NULL);
     JSObjectRef globalObject = JSContextGetGlobalObject(context);
     
-    JSStringBufferRef printBuf = JSStringBufferCreateUTF8("print");
+    JSInternalStringRef printBuf = JSInternalStringCreateUTF8("print");
     JSObjectSetProperty(context, globalObject, printBuf, JSFunctionMake(context, print), kJSPropertyAttributeNone);
-    JSStringBufferRelease(printBuf);
+    JSInternalStringRelease(printBuf);
     
-    JSStringBufferRef nodeBuf = JSStringBufferCreateUTF8("Node");
+    JSInternalStringRef nodeBuf = JSInternalStringCreateUTF8("Node");
     JSObjectSetProperty(context, globalObject, nodeBuf, JSConstructorMake(context, JSNode_construct), kJSPropertyAttributeNone);
-    JSStringBufferRelease(nodeBuf);
+    JSInternalStringRelease(nodeBuf);
     
     char* script = createStringWithContentsOfFile("minidom.js");
-    JSStringBufferRef scriptBuf = JSStringBufferCreateUTF8(script);
+    JSInternalStringRef scriptBuf = JSInternalStringCreateUTF8(script);
     JSValueRef exception;
     JSValueRef result = JSEvaluate(context, scriptBuf, NULL, NULL, 0, &exception);
     if (result)
         printf("PASS: Test script executed successfully.\n");
     else {
         printf("FAIL: Test script threw exception:\n");
-        JSStringBufferRef exceptionBuf = JSValueCopyStringValue(context, exception);
-        CFStringRef exceptionCF = CFStringCreateWithJSStringBuffer(kCFAllocatorDefault, exceptionBuf);
+        JSInternalStringRef exceptionBuf = JSValueCopyStringValue(context, exception);
+        CFStringRef exceptionCF = CFStringCreateWithJSInternalString(kCFAllocatorDefault, exceptionBuf);
         CFShow(exceptionCF);
         CFRelease(exceptionCF);
-        JSStringBufferRelease(exceptionBuf);
+        JSInternalStringRelease(exceptionBuf);
     }
-    JSStringBufferRelease(scriptBuf);
+    JSInternalStringRelease(scriptBuf);
     free(script);
 
 #if 0 // used for leak/finalize debugging    
@@ -81,10 +81,10 @@ int main(int argc, char* argv[])
 static JSValueRef print(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argc, JSValueRef argv[])
 {
     if (argc > 0) {
-        JSStringBufferRef stringBuf = JSValueCopyStringValue(context, argv[0]);
-        size_t numChars = JSStringBufferGetMaxLengthUTF8(stringBuf);
+        JSInternalStringRef stringBuf = JSValueCopyStringValue(context, argv[0]);
+        size_t numChars = JSInternalStringGetMaxLengthUTF8(stringBuf);
         char string[numChars];
-        JSStringBufferGetCharactersUTF8(stringBuf, string, numChars);
+        JSInternalStringGetCharactersUTF8(stringBuf, string, numChars);
         printf("%s\n", string);
     }
     
index dd9ac64b3d8101c64eecf11cb6ff07b3a3f09c50..879a4ae217f25c4f7bbfd2a35adfe6c243b67b46 100644 (file)
@@ -51,11 +51,11 @@ static void assertEqualsAsNumber(JSValueRef value, double expectedValue)
 
 static void assertEqualsAsUTF8String(JSValueRef value, const char* expectedValue)
 {
-    JSStringBufferRef valueAsString = JSValueCopyStringValue(context, value);
+    JSInternalStringRef valueAsString = JSValueCopyStringValue(context, value);
 
-    size_t jsSize = JSStringBufferGetMaxLengthUTF8(valueAsString);
+    size_t jsSize = JSInternalStringGetMaxLengthUTF8(valueAsString);
     char jsBuffer[jsSize];
-    JSStringBufferGetCharactersUTF8(valueAsString, jsBuffer, jsSize);
+    JSInternalStringGetCharactersUTF8(valueAsString, jsBuffer, jsSize);
     
     if (strcmp(jsBuffer, expectedValue) != 0)
         fprintf(stderr, "assertEqualsAsUTF8String strcmp failed: %s != %s\n", jsBuffer, expectedValue);
@@ -63,16 +63,16 @@ static void assertEqualsAsUTF8String(JSValueRef value, const char* expectedValue
     if (jsSize < strlen(jsBuffer) + 1)
         fprintf(stderr, "assertEqualsAsUTF8String failed: jsSize was too small\n");
 
-    JSStringBufferRelease(valueAsString);
+    JSInternalStringRelease(valueAsString);
 }
 
 #if defined(__APPLE__)
 static void assertEqualsAsCharactersPtr(JSValueRef value, const char* expectedValue)
 {
-    JSStringBufferRef valueAsString = JSValueCopyStringValue(context, value);
+    JSInternalStringRef valueAsString = JSValueCopyStringValue(context, value);
 
-    size_t jsLength = JSStringBufferGetLength(valueAsString);
-    const JSChar* jsBuffer = JSStringBufferGetCharactersPtr(valueAsString);
+    size_t jsLength = JSInternalStringGetLength(valueAsString);
+    const JSChar* jsBuffer = JSInternalStringGetCharactersPtr(valueAsString);
 
     CFStringRef expectedValueAsCFString = CFStringCreateWithCString(kCFAllocatorDefault, 
                                                                     expectedValue,
@@ -88,16 +88,16 @@ static void assertEqualsAsCharactersPtr(JSValueRef value, const char* expectedVa
     if (jsLength != (size_t)cfLength)
         fprintf(stderr, "assertEqualsAsCharactersPtr failed: jsLength(%ld) != cfLength(%ld)\n", jsLength, cfLength);
     
-    JSStringBufferRelease(valueAsString);
+    JSInternalStringRelease(valueAsString);
 }
 
 static void assertEqualsAsCharacters(JSValueRef value, const char* expectedValue)
 {
-    JSStringBufferRef valueAsString = JSValueCopyStringValue(context, value);
+    JSInternalStringRef valueAsString = JSValueCopyStringValue(context, value);
     
-    size_t jsLength = JSStringBufferGetLength(valueAsString);
+    size_t jsLength = JSInternalStringGetLength(valueAsString);
     JSChar jsBuffer[jsLength];
-    JSStringBufferGetCharacters(valueAsString, jsBuffer, jsLength);
+    JSInternalStringGetCharacters(valueAsString, jsBuffer, jsLength);
     
     CFStringRef expectedValueAsCFString = CFStringCreateWithCString(kCFAllocatorDefault, 
                                                                     expectedValue,
@@ -113,7 +113,7 @@ static void assertEqualsAsCharacters(JSValueRef value, const char* expectedValue
     if (jsLength != (size_t)cfLength)
         fprintf(stderr, "assertEqualsAsCharacters failed: jsLength(%ld) != cfLength(%ld)\n", jsLength, cfLength);
     
-    JSStringBufferRelease(valueAsString);
+    JSInternalStringRelease(valueAsString);
 }
 #endif // __APPLE__
 
@@ -129,36 +129,36 @@ static void MyObject_initialize(JSContextRef context, JSObjectRef object)
     didInitialize = true;
 }
 
-static bool MyObject_hasProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName)
+static bool MyObject_hasProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName)
 {
     UNUSED_PARAM(context);
     UNUSED_PARAM(object);
 
-    if (JSStringBufferIsEqualUTF8(propertyName, "alwaysOne")
-        || JSStringBufferIsEqualUTF8(propertyName, "cantFind")
-        || JSStringBufferIsEqualUTF8(propertyName, "myPropertyName")) {
+    if (JSInternalStringIsEqualUTF8(propertyName, "alwaysOne")
+        || JSInternalStringIsEqualUTF8(propertyName, "cantFind")
+        || JSInternalStringIsEqualUTF8(propertyName, "myPropertyName")) {
         return true;
     }
     
     return false;
 }
 
-static bool MyObject_getProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName, JSValueRef* returnValue)
+static bool MyObject_getProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef* returnValue)
 {
     UNUSED_PARAM(context);
     UNUSED_PARAM(object);
     
-    if (JSStringBufferIsEqualUTF8(propertyName, "alwaysOne")) {
+    if (JSInternalStringIsEqualUTF8(propertyName, "alwaysOne")) {
         *returnValue = JSNumberMake(1);
         return true;
     }
     
-    if (JSStringBufferIsEqualUTF8(propertyName, "myPropertyName")) {
+    if (JSInternalStringIsEqualUTF8(propertyName, "myPropertyName")) {
         *returnValue = JSNumberMake(1);
         return true;
     }
 
-    if (JSStringBufferIsEqualUTF8(propertyName, "cantFind")) {
+    if (JSInternalStringIsEqualUTF8(propertyName, "cantFind")) {
         *returnValue = JSUndefinedMake();
         return true;
     }
@@ -166,24 +166,24 @@ static bool MyObject_getProperty(JSContextRef context, JSObjectRef object, JSStr
     return false;
 }
 
-static bool MyObject_setProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName, JSValueRef value)
+static bool MyObject_setProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef value)
 {
     UNUSED_PARAM(context);
     UNUSED_PARAM(object);
     UNUSED_PARAM(value);
 
-    if (JSStringBufferIsEqualUTF8(propertyName, "cantSet"))
+    if (JSInternalStringIsEqualUTF8(propertyName, "cantSet"))
         return true; // pretend we set the property in order to swallow it
     
     return false;
 }
 
-static bool MyObject_deleteProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName)
+static bool MyObject_deleteProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName)
 {
     UNUSED_PARAM(context);
     UNUSED_PARAM(object);
     
-    if (JSStringBufferIsEqualUTF8(propertyName, "cantDelete"))
+    if (JSInternalStringIsEqualUTF8(propertyName, "cantDelete"))
         return true;
     
     return false;
@@ -193,15 +193,15 @@ static void MyObject_getPropertyList(JSContextRef context, JSObjectRef object, J
 {
     UNUSED_PARAM(context);
     
-    JSStringBufferRef propertyNameBuf;
+    JSInternalStringRef propertyNameBuf;
     
-    propertyNameBuf = JSStringBufferCreateUTF8("alwaysOne");
+    propertyNameBuf = JSInternalStringCreateUTF8("alwaysOne");
     JSPropertyListAdd(propertyList, object, propertyNameBuf);
-    JSStringBufferRelease(propertyNameBuf);
+    JSInternalStringRelease(propertyNameBuf);
     
-    propertyNameBuf = JSStringBufferCreateUTF8("myPropertyName");
+    propertyNameBuf = JSInternalStringCreateUTF8("myPropertyName");
     JSPropertyListAdd(propertyList, object, propertyNameBuf);
-    JSStringBufferRelease(propertyNameBuf);
+    JSInternalStringRelease(propertyNameBuf);
 }
 
 static JSValueRef MyObject_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argc, JSValueRef argv[])
@@ -285,12 +285,12 @@ static JSValueRef print_callAsFunction(JSContextRef context, JSObjectRef functio
     UNUSED_PARAM(thisObject);
     
     if (argc > 0) {
-        JSStringBufferRef string = JSValueCopyStringValue(context, argv[0]);
-        size_t sizeUTF8 = JSStringBufferGetMaxLengthUTF8(string);
+        JSInternalStringRef string = JSValueCopyStringValue(context, argv[0]);
+        size_t sizeUTF8 = JSInternalStringGetMaxLengthUTF8(string);
         char stringUTF8[sizeUTF8];
-        JSStringBufferGetCharactersUTF8(string, stringUTF8, sizeUTF8);
+        JSInternalStringGetCharactersUTF8(string, stringUTF8, sizeUTF8);
         printf("%s\n", stringUTF8);
-        JSStringBufferRelease(string);
+        JSInternalStringRelease(string);
     }
     
     return JSUndefinedMake();
@@ -302,9 +302,9 @@ static JSObjectRef myConstructor_callAsConstructor(JSContextRef context, JSObjec
     
     JSObjectRef result = JSObjectMake(context, NULL, 0);
     if (argc > 0) {
-        JSStringBufferRef valueBuffer = JSStringBufferCreateUTF8("value");
+        JSInternalStringRef valueBuffer = JSInternalStringCreateUTF8("value");
         JSObjectSetProperty(context, result, valueBuffer, argv[0], kJSPropertyAttributeNone);
-        JSStringBufferRelease(valueBuffer);
+        JSInternalStringRelease(valueBuffer);
     }
     
     return result;
@@ -329,10 +329,10 @@ int main(int argc, char* argv[])
     JSObjectRef jsObjectNoProto = JSObjectMake(context, NULL, JSNullMake());
 
     // FIXME: test funny utf8 characters
-    JSStringBufferRef jsEmptyStringBuf = JSStringBufferCreateUTF8("");
+    JSInternalStringRef jsEmptyStringBuf = JSInternalStringCreateUTF8("");
     JSValueRef jsEmptyString = JSStringMake(jsEmptyStringBuf);
     
-    JSStringBufferRef jsOneStringBuf = JSStringBufferCreateUTF8("1");
+    JSInternalStringRef jsOneStringBuf = JSInternalStringCreateUTF8("1");
     JSValueRef jsOneString = JSStringMake(jsOneStringBuf);
 
 #if defined(__APPLE__)
@@ -344,12 +344,12 @@ int main(int argc, char* argv[])
                                                           1,
                                                           kCFAllocatorNull);
 
-    JSStringBufferRef jsCFStringBuf = JSStringBufferCreateCF(cfString);
+    JSInternalStringRef jsCFStringBuf = JSInternalStringCreateCF(cfString);
     JSValueRef jsCFString = JSStringMake(jsCFStringBuf);
     
     CFStringRef cfEmptyString = CFStringCreateWithCString(kCFAllocatorDefault, "", kCFStringEncodingUTF8);
     
-    JSStringBufferRef jsCFEmptyStringBuf = JSStringBufferCreateCF(cfEmptyString);
+    JSInternalStringRef jsCFEmptyStringBuf = JSInternalStringCreateCF(cfEmptyString);
     JSValueRef jsCFEmptyString = JSStringMake(jsCFEmptyStringBuf);
 
     CFIndex cfStringLength = CFStringGetLength(cfString);
@@ -357,10 +357,10 @@ int main(int argc, char* argv[])
     CFStringGetCharacters(cfString, 
                           CFRangeMake(0, cfStringLength), 
                           buffer);
-    JSStringBufferRef jsCFStringWithCharactersBuf = JSStringBufferCreate(buffer, cfStringLength);
+    JSInternalStringRef jsCFStringWithCharactersBuf = JSInternalStringCreate(buffer, cfStringLength);
     JSValueRef jsCFStringWithCharacters = JSStringMake(jsCFStringWithCharactersBuf);
     
-    JSStringBufferRef jsCFEmptyStringWithCharactersBuf = JSStringBufferCreate(buffer, CFStringGetLength(cfEmptyString));
+    JSInternalStringRef jsCFEmptyStringWithCharactersBuf = JSInternalStringCreate(buffer, CFStringGetLength(cfEmptyString));
     JSValueRef jsCFEmptyStringWithCharacters = JSStringMake(jsCFEmptyStringWithCharactersBuf);
 #endif // __APPLE__
 
@@ -476,8 +476,8 @@ int main(int argc, char* argv[])
     assert(!JSValueIsEqual(context, jsTrue, jsFalse));
     
 #if defined(__APPLE__)
-    CFStringRef cfJSString = CFStringCreateWithJSStringBuffer(kCFAllocatorDefault, jsCFStringBuf);
-    CFStringRef cfJSEmptyString = CFStringCreateWithJSStringBuffer(kCFAllocatorDefault, jsCFEmptyStringBuf);
+    CFStringRef cfJSString = CFStringCreateWithJSInternalString(kCFAllocatorDefault, jsCFStringBuf);
+    CFStringRef cfJSEmptyString = CFStringCreateWithJSInternalString(kCFAllocatorDefault, jsCFEmptyStringBuf);
     assert(CFEqual(cfJSString, cfString));
     assert(CFEqual(cfJSEmptyString, cfEmptyString));
     CFRelease(cfJSString);
@@ -498,8 +498,8 @@ int main(int argc, char* argv[])
     JSObjectRef globalObject = JSContextGetGlobalObject(context);
     assert(JSValueIsObject(globalObject));
 
-    JSStringBufferRef goodSyntaxBuf = JSStringBufferCreateUTF8("x = 1;");
-    JSStringBufferRef badSyntaxBuf = JSStringBufferCreateUTF8("x := 1;");
+    JSInternalStringRef goodSyntaxBuf = JSInternalStringCreateUTF8("x = 1;");
+    JSInternalStringRef badSyntaxBuf = JSInternalStringCreateUTF8("x := 1;");
     assert(JSCheckSyntax(context, goodSyntaxBuf, NULL, 0, NULL));
     assert(!JSCheckSyntax(context, badSyntaxBuf, NULL, 0, NULL));
 
@@ -524,43 +524,43 @@ int main(int argc, char* argv[])
     JSContextClearException(context);
     assert(!JSContextGetException(context));
 
-    JSStringBufferRelease(jsEmptyStringBuf);
-    JSStringBufferRelease(jsOneStringBuf);
+    JSInternalStringRelease(jsEmptyStringBuf);
+    JSInternalStringRelease(jsOneStringBuf);
 #if defined(__APPLE__)
-    JSStringBufferRelease(jsCFStringBuf);
-    JSStringBufferRelease(jsCFEmptyStringBuf);
-    JSStringBufferRelease(jsCFStringWithCharactersBuf);
-    JSStringBufferRelease(jsCFEmptyStringWithCharactersBuf);
+    JSInternalStringRelease(jsCFStringBuf);
+    JSInternalStringRelease(jsCFEmptyStringBuf);
+    JSInternalStringRelease(jsCFStringWithCharactersBuf);
+    JSInternalStringRelease(jsCFEmptyStringWithCharactersBuf);
 #endif // __APPLE__
-    JSStringBufferRelease(goodSyntaxBuf);
-    JSStringBufferRelease(badSyntaxBuf);
+    JSInternalStringRelease(goodSyntaxBuf);
+    JSInternalStringRelease(badSyntaxBuf);
 
-    JSStringBufferRef arrayBuf = JSStringBufferCreateUTF8("Array");
+    JSInternalStringRef arrayBuf = JSInternalStringCreateUTF8("Array");
     v = JSObjectGetProperty(context, globalObject, arrayBuf);
     assert(v);
     JSObjectRef arrayConstructor = JSValueToObject(context, v);
-    JSStringBufferRelease(arrayBuf);
+    JSInternalStringRelease(arrayBuf);
     result = JSObjectCallAsConstructor(context, arrayConstructor, 0, NULL, NULL);
     assert(result);
     assert(JSValueIsInstanceOf(context, result, arrayConstructor));
     assert(!JSValueIsInstanceOf(context, JSNullMake(), arrayConstructor));
     
-    JSStringBufferRef functionBuf;
+    JSInternalStringRef functionBuf;
     
     exception = NULL;
-    functionBuf = JSStringBufferCreateUTF8("rreturn Array;");
-    JSStringBufferRef lineBuf = JSStringBufferCreateUTF8("line");
+    functionBuf = JSInternalStringCreateUTF8("rreturn Array;");
+    JSInternalStringRef lineBuf = JSInternalStringCreateUTF8("line");
     assert(!JSFunctionMakeWithBody(context, functionBuf, NULL, 1, &exception));
     assert(JSValueIsObject(exception));
     v = JSObjectGetProperty(context, exception, lineBuf);
     assert(v);
     assertEqualsAsNumber(v, 2); // FIXME: Lexer::setCode bumps startingLineNumber by 1 -- we need to change internal callers so that it doesn't have to (saying '0' to mean '1' in the API would be really confusing -- it's really confusing internally, in fact)
-    JSStringBufferRelease(functionBuf);
-    JSStringBufferRelease(lineBuf);
+    JSInternalStringRelease(functionBuf);
+    JSInternalStringRelease(lineBuf);
 
-    functionBuf = JSStringBufferCreateUTF8("return Array;");
+    functionBuf = JSInternalStringCreateUTF8("return Array;");
     JSObjectRef function = JSFunctionMakeWithBody(context, functionBuf, NULL, 1, NULL);
-    JSStringBufferRelease(functionBuf);
+    JSInternalStringRelease(functionBuf);
 
     assert(JSObjectIsFunction(function));
     v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL);
@@ -568,22 +568,22 @@ int main(int argc, char* argv[])
                                                   
     JSObjectRef myObject = JSObjectMake(context, MyObject_class(context), NULL);
     assert(didInitialize);
-    JSStringBufferRef myObjectBuf = JSStringBufferCreateUTF8("MyObject");
+    JSInternalStringRef myObjectBuf = JSInternalStringCreateUTF8("MyObject");
     JSObjectSetProperty(context, globalObject, myObjectBuf, myObject, kJSPropertyAttributeNone);
-    JSStringBufferRelease(myObjectBuf);
+    JSInternalStringRelease(myObjectBuf);
 
-    JSStringBufferRef printBuf = JSStringBufferCreateUTF8("print");
+    JSInternalStringRef printBuf = JSInternalStringCreateUTF8("print");
     JSValueRef printFunction = JSFunctionMake(context, print_callAsFunction);
     JSObjectSetProperty(context, globalObject, printBuf, printFunction, kJSPropertyAttributeNone); 
-    JSStringBufferRelease(printBuf);
+    JSInternalStringRelease(printBuf);
     
     assert(JSObjectSetPrivate(printFunction, (void*)1));
     assert(JSObjectGetPrivate(printFunction) == (void*)1);
 
-    JSStringBufferRef myConstructorBuf = JSStringBufferCreateUTF8("MyConstructor");
+    JSInternalStringRef myConstructorBuf = JSInternalStringCreateUTF8("MyConstructor");
     JSValueRef myConstructor = JSConstructorMake(context, myConstructor_callAsConstructor);
     JSObjectSetProperty(context, globalObject, myConstructorBuf, myConstructor, kJSPropertyAttributeNone);
-    JSStringBufferRelease(myConstructorBuf);
+    JSInternalStringRelease(myConstructorBuf);
     
     assert(JSObjectSetPrivate(myConstructor, (void*)1));
     assert(JSObjectGetPrivate(myConstructor) == (void*)1);
@@ -601,28 +601,28 @@ int main(int argc, char* argv[])
     JSClassRef nullCallbacksClass = JSClassCreate(NULL, NULL, NULL, NULL);
     JSClassRelease(nullCallbacksClass);
     
-    functionBuf = JSStringBufferCreateUTF8("return this;");
+    functionBuf = JSInternalStringCreateUTF8("return this;");
     function = JSFunctionMakeWithBody(context, functionBuf, NULL, 1, NULL);
-    JSStringBufferRelease(functionBuf);
+    JSInternalStringRelease(functionBuf);
     v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL);
     assert(JSValueIsEqual(context, v, globalObject));
     v = JSObjectCallAsFunction(context, function, o, 0, NULL, NULL);
     assert(JSValueIsEqual(context, v, o));
     
     char* script = createStringWithContentsOfFile("testapi.js");
-    JSStringBufferRef scriptBuf = JSStringBufferCreateUTF8(script);
+    JSInternalStringRef scriptBuf = JSInternalStringCreateUTF8(script);
     result = JSEvaluate(context, scriptBuf, NULL, NULL, 1, &exception);
     if (JSValueIsUndefined(result))
         printf("PASS: Test script executed successfully.\n");
     else {
         printf("FAIL: Test script returned unexcpected value:\n");
-        JSStringBufferRef exceptionBuf = JSValueCopyStringValue(context, exception);
-        CFStringRef exceptionCF = CFStringCreateWithJSStringBuffer(kCFAllocatorDefault, exceptionBuf);
+        JSInternalStringRef exceptionBuf = JSValueCopyStringValue(context, exception);
+        CFStringRef exceptionCF = CFStringCreateWithJSInternalString(kCFAllocatorDefault, exceptionBuf);
         CFShow(exceptionCF);
         CFRelease(exceptionCF);
-        JSStringBufferRelease(exceptionBuf);
+        JSInternalStringRelease(exceptionBuf);
     }
-    JSStringBufferRelease(scriptBuf);
+    JSInternalStringRelease(scriptBuf);
     free(script);
 
     // Allocate a few dummies so that at least one will be collected
index d7bd8d3879d53fc15f1edd5e0497e3e7341cf4c9..a200aebe78110723eca468cb83ca3f9c4f3aab63 100644 (file)
@@ -1,3 +1,82 @@
+2006-07-10  Geoffrey Garen  <ggaren@apple.com>
+
+        Approved by Maciej, Darin.
+        
+        Renamed JSStringBufferRef to JSInternalStringRef. "Internal string" means the 
+        JavaScript engine's internal string representation, which is the most 
+        low-level and efficient representation to use when interfacing with JavaScript.
+
+        * API/APICast.h:
+        (toJS):
+        (toRef):
+        * API/JSBase.h:
+        * API/JSCallbackObject.cpp:
+        (KJS::JSCallbackObject::getOwnPropertySlot):
+        (KJS::JSCallbackObject::put):
+        (KJS::JSCallbackObject::deleteProperty):
+        (KJS::JSCallbackObject::staticValueGetter):
+        (KJS::JSCallbackObject::callbackGetter):
+        * API/JSContextRef.cpp:
+        (JSEvaluate):
+        (JSCheckSyntax):
+        * API/JSContextRef.h:
+        * API/JSInternalStringRef.cpp: Added.
+        (JSStringMake):
+        (JSInternalStringCreate):
+        (JSInternalStringCreateUTF8):
+        (JSInternalStringRetain):
+        (JSInternalStringRelease):
+        (JSValueCopyStringValue):
+        (JSInternalStringGetLength):
+        (JSInternalStringGetCharactersPtr):
+        (JSInternalStringGetCharacters):
+        (JSInternalStringGetMaxLengthUTF8):
+        (JSInternalStringGetCharactersUTF8):
+        (JSInternalStringIsEqual):
+        (JSInternalStringIsEqualUTF8):
+        (JSInternalStringCreateCF):
+        (CFStringCreateWithJSInternalString):
+        * API/JSInternalStringRef.h: Added.
+        * API/JSNode.c:
+        (JSNodePrototype_appendChild):
+        (JSNode_getNodeType):
+        (JSNode_getChildNodes):
+        (JSNode_getFirstChild):
+        * API/JSNodeList.c:
+        (JSNodeList_length):
+        (JSNodeList_getProperty):
+        * API/JSObjectRef.cpp:
+        (JSFunctionMakeWithBody):
+        (JSObjectGetDescription):
+        (JSObjectHasProperty):
+        (JSObjectGetProperty):
+        (JSObjectSetProperty):
+        (JSObjectDeleteProperty):
+        (JSPropertyEnumeratorGetNext):
+        (JSPropertyListAdd):
+        * API/JSObjectRef.h:
+        * API/JSStringBufferRef.cpp: Removed.
+        * API/JSStringBufferRef.h: Removed.
+        * API/JSValueRef.h:
+        * API/JavaScriptCore.h:
+        * API/minidom.c:
+        (main):
+        (print):
+        * API/testapi.c:
+        (assertEqualsAsUTF8String):
+        (assertEqualsAsCharactersPtr):
+        (assertEqualsAsCharacters):
+        (MyObject_hasProperty):
+        (MyObject_getProperty):
+        (MyObject_setProperty):
+        (MyObject_deleteProperty):
+        (MyObject_getPropertyList):
+        (print_callAsFunction):
+        (myConstructor_callAsConstructor):
+        (main):
+        * JavaScriptCore.exp:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+
 2006-07-08  Tim Omernick  <timo@apple.com>
 
         Reviewed by Maciej.
index e673680932f3152733aabd27ae151d922d71b0c8..d54ab4c7e64a8b5aa263734ff5894d0b67093d16 100644 (file)
@@ -1,7 +1,7 @@
 .objc_class_name_WebScriptObject
 .objc_class_name_WebScriptObjectPrivate
 .objc_class_name_WebUndefined
-_CFStringCreateWithJSStringBuffer
+_CFStringCreateWithJSInternalString
 _JSBooleanMake
 _JSCheckSyntax
 _JSClassCreate
@@ -20,6 +20,18 @@ _JSFunctionMakeWithBody
 _JSGCCollect
 _JSGCProtect
 _JSGCUnprotect
+_JSInternalStringCreate
+_JSInternalStringCreateCF
+_JSInternalStringCreateUTF8
+_JSInternalStringGetCharacters
+_JSInternalStringGetCharactersPtr
+_JSInternalStringGetCharactersUTF8
+_JSInternalStringGetLength
+_JSInternalStringGetMaxLengthUTF8
+_JSInternalStringIsEqual
+_JSInternalStringIsEqualUTF8
+_JSInternalStringRelease
+_JSInternalStringRetain
 _JSNullMake
 _JSNumberMake
 _JSObjectCallAsConstructor
@@ -41,18 +53,6 @@ _JSPropertyEnumeratorGetNext
 _JSPropertyEnumeratorRelease
 _JSPropertyEnumeratorRetain
 _JSPropertyListAdd
-_JSStringBufferCreate
-_JSStringBufferCreateUTF8
-_JSStringBufferCreateCF
-_JSStringBufferGetCharacters
-_JSStringBufferGetCharactersPtr
-_JSStringBufferGetCharactersUTF8
-_JSStringBufferGetLength
-_JSStringBufferGetMaxLengthUTF8
-_JSStringBufferIsEqual
-_JSStringBufferIsEqualUTF8
-_JSStringBufferRelease
-_JSStringBufferRetain
 _JSStringMake
 _JSUndefinedMake
 _JSValueCopyStringValue
index d76bad368efae24ecbf930bfb59114739d0293a7..906358f8d1a24c8bf1faa3f7283f71e07fc46ea4 100644 (file)
@@ -54,8 +54,8 @@
                1440FCE40A51E46B0005F061 /* JSClassRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1440FCE20A51E46B0005F061 /* JSClassRef.cpp */; };
                14760864099C633800437128 /* JSImmediate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14760863099C633800437128 /* JSImmediate.cpp */; };
                1482B6EB0A4300B300517CFC /* JSValueRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 1482B6EA0A4300B300517CFC /* JSValueRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               1482B74D0A43032800517CFC /* JSStringBufferRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 1482B74B0A43032800517CFC /* JSStringBufferRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               1482B74E0A43032800517CFC /* JSStringBufferRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1482B74C0A43032800517CFC /* JSStringBufferRef.cpp */; };
+               1482B74D0A43032800517CFC /* JSInternalStringRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 1482B74B0A43032800517CFC /* JSInternalStringRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               1482B74E0A43032800517CFC /* JSInternalStringRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1482B74C0A43032800517CFC /* JSInternalStringRef.cpp */; };
                1482B78B0A4305AB00517CFC /* APICast.h in Headers */ = {isa = PBXBuildFile; fileRef = 1482B78A0A4305AB00517CFC /* APICast.h */; };
                1482B7E30A43076000517CFC /* JSObjectRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 1482B7E10A43076000517CFC /* JSObjectRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1482B7E40A43076000517CFC /* JSObjectRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1482B7E20A43076000517CFC /* JSObjectRef.cpp */; };
                1440FCE20A51E46B0005F061 /* JSClassRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSClassRef.cpp; sourceTree = "<group>"; };
                14760863099C633800437128 /* JSImmediate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSImmediate.cpp; sourceTree = "<group>"; };
                1482B6EA0A4300B300517CFC /* JSValueRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSValueRef.h; sourceTree = "<group>"; };
-               1482B74B0A43032800517CFC /* JSStringBufferRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStringBufferRef.h; sourceTree = "<group>"; };
-               1482B74C0A43032800517CFC /* JSStringBufferRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSStringBufferRef.cpp; sourceTree = "<group>"; };
+               1482B74B0A43032800517CFC /* JSInternalStringRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInternalStringRef.h; sourceTree = "<group>"; };
+               1482B74C0A43032800517CFC /* JSInternalStringRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInternalStringRef.cpp; sourceTree = "<group>"; };
                1482B78A0A4305AB00517CFC /* APICast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APICast.h; sourceTree = "<group>"; };
                1482B7E10A43076000517CFC /* JSObjectRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSObjectRef.h; sourceTree = "<group>"; };
                1482B7E20A43076000517CFC /* JSObjectRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSObjectRef.cpp; sourceTree = "<group>"; };
                                1440FCE10A51E46B0005F061 /* JSClassRef.h */,
                                14BD5A290A3E91F600BAF59C /* JSContextRef.cpp */,
                                14BD5A2A0A3E91F600BAF59C /* JSContextRef.h */,
+                               1482B74C0A43032800517CFC /* JSInternalStringRef.cpp */,
+                               1482B74B0A43032800517CFC /* JSInternalStringRef.h */,
                                1482B7E20A43076000517CFC /* JSObjectRef.cpp */,
                                1482B7E10A43076000517CFC /* JSObjectRef.h */,
-                               1482B74C0A43032800517CFC /* JSStringBufferRef.cpp */,
-                               1482B74B0A43032800517CFC /* JSStringBufferRef.h */,
                                14BD5A2B0A3E91F600BAF59C /* JSValueRef.cpp */,
                                1482B6EA0A4300B300517CFC /* JSValueRef.h */,
                        );
                                14BD534C0A3E0AEA00BAF59C /* SavedBuiltins.h in Headers */,
                                14BD53F50A3E12D800BAF59C /* ExecState.h in Headers */,
                                1482B6EB0A4300B300517CFC /* JSValueRef.h in Headers */,
-                               1482B74D0A43032800517CFC /* JSStringBufferRef.h in Headers */,
+                               1482B74D0A43032800517CFC /* JSInternalStringRef.h in Headers */,
                                1482B78B0A4305AB00517CFC /* APICast.h in Headers */,
                                1482B7E30A43076000517CFC /* JSObjectRef.h in Headers */,
                                14ABDF5F0A437FEF00ECCA01 /* JSCallbackObject.h in Headers */,
                                14BD5A300A3E91F600BAF59C /* JSContextRef.cpp in Sources */,
                                14BD5A320A3E91F600BAF59C /* JSValueRef.cpp in Sources */,
                                14BD53F60A3E12D800BAF59C /* ExecState.cpp in Sources */,
-                               1482B74E0A43032800517CFC /* JSStringBufferRef.cpp in Sources */,
+                               1482B74E0A43032800517CFC /* JSInternalStringRef.cpp in Sources */,
                                1482B7E40A43076000517CFC /* JSObjectRef.cpp in Sources */,
                                14ABDF600A437FEF00ECCA01 /* JSCallbackObject.cpp in Sources */,
                                1440F8920A508B100005F061 /* JSCallbackFunction.cpp in Sources */,