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);
}
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)
/*! @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. */
#include "APICast.h"
#include "JSCallbackObject.h"
-#include "JSStringBufferRef.h"
+#include "JSInternalStringRef.h"
#include "JSClassRef.h"
#include "JSObjectRef.h"
#include "internal.h"
{
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
{
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) {
{
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) {
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;
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;
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);
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;
@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
}
*/
#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
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());
memcpy(outBuffer, data, numChars * sizeof(JSChar));
}
-size_t JSStringBufferGetMaxLengthUTF8(JSStringBufferRef buffer)
+size_t JSInternalStringGetMaxLengthUTF8(JSInternalStringRef buffer)
{
UString::Rep* rep = toJS(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);
return length;
}
-bool JSStringBufferIsEqual(JSStringBufferRef a, JSStringBufferRef b)
+bool JSInternalStringIsEqual(JSInternalStringRef a, JSInternalStringRef b)
{
UString::Rep* aRep = toJS(a);
UString::Rep* bRep = toJS(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);
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());
--- /dev/null
+// -*- 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
// 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]);
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);
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);
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);
{ 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);
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;
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);
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);
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);
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);
return false;
}
-bool JSObjectDeleteProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName)
+bool JSObjectDeleteProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName)
{
JSLock lock;
ExecState* exec = toJS(context);
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;
}
delete enumerator;
}
-void JSPropertyListAdd(JSPropertyListRef propertyList, JSObjectRef thisObject, JSStringBufferRef propertyName)
+void JSPropertyListAdd(JSPropertyListRef propertyList, JSObjectRef thisObject, JSInternalStringRef propertyName)
{
JSLock lock;
ReferenceList* jsPropertyList = toJS(propertyList);
@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
@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
@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
@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
@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
}
/*!
@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
/*!
@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
#include <stddef.h> // for size_t
#include "JSBase.h"
-#include "JSStringBufferRef.h"
+#include "JSInternalStringRef.h"
#include "JSContextRef.h"
#include "JSObjectRef.h"
#include "JSValueRef.h"
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
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);
}
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);
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,
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,
if (jsLength != (size_t)cfLength)
fprintf(stderr, "assertEqualsAsCharacters failed: jsLength(%ld) != cfLength(%ld)\n", jsLength, cfLength);
- JSStringBufferRelease(valueAsString);
+ JSInternalStringRelease(valueAsString);
}
#endif // __APPLE__
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;
}
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;
{
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[])
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();
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;
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__)
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);
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__
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);
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));
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);
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);
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
+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.
.objc_class_name_WebScriptObject
.objc_class_name_WebScriptObjectPrivate
.objc_class_name_WebUndefined
-_CFStringCreateWithJSStringBuffer
+_CFStringCreateWithJSInternalString
_JSBooleanMake
_JSCheckSyntax
_JSClassCreate
_JSGCCollect
_JSGCProtect
_JSGCUnprotect
+_JSInternalStringCreate
+_JSInternalStringCreateCF
+_JSInternalStringCreateUTF8
+_JSInternalStringGetCharacters
+_JSInternalStringGetCharactersPtr
+_JSInternalStringGetCharactersUTF8
+_JSInternalStringGetLength
+_JSInternalStringGetMaxLengthUTF8
+_JSInternalStringIsEqual
+_JSInternalStringIsEqualUTF8
+_JSInternalStringRelease
+_JSInternalStringRetain
_JSNullMake
_JSNumberMake
_JSObjectCallAsConstructor
_JSPropertyEnumeratorRelease
_JSPropertyEnumeratorRetain
_JSPropertyListAdd
-_JSStringBufferCreate
-_JSStringBufferCreateUTF8
-_JSStringBufferCreateCF
-_JSStringBufferGetCharacters
-_JSStringBufferGetCharactersPtr
-_JSStringBufferGetCharactersUTF8
-_JSStringBufferGetLength
-_JSStringBufferGetMaxLengthUTF8
-_JSStringBufferIsEqual
-_JSStringBufferIsEqualUTF8
-_JSStringBufferRelease
-_JSStringBufferRetain
_JSStringMake
_JSUndefinedMake
_JSValueCopyStringValue
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 */,