summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/API
diff options
context:
space:
mode:
Diffstat (limited to 'JavaScriptCore/API')
-rw-r--r--JavaScriptCore/API/JSCallbackObject.h8
-rw-r--r--JavaScriptCore/API/JSCallbackObjectFunctions.h20
-rw-r--r--JavaScriptCore/API/JSClassRef.cpp16
-rw-r--r--JavaScriptCore/API/JSClassRef.h4
-rw-r--r--JavaScriptCore/API/JSRetainPtr.h89
-rw-r--r--JavaScriptCore/API/OpaqueJSString.cpp4
6 files changed, 88 insertions, 53 deletions
diff --git a/JavaScriptCore/API/JSCallbackObject.h b/JavaScriptCore/API/JSCallbackObject.h
index cf42818..83442b2 100644
--- a/JavaScriptCore/API/JSCallbackObject.h
+++ b/JavaScriptCore/API/JSCallbackObject.h
@@ -80,7 +80,7 @@ struct JSCallbackObjectData {
struct JSPrivatePropertyMap {
JSValue getPrivateProperty(const Identifier& propertyName) const
{
- PrivatePropertyMap::const_iterator location = m_propertyMap.find(propertyName.ustring().rep());
+ PrivatePropertyMap::const_iterator location = m_propertyMap.find(propertyName.impl());
if (location == m_propertyMap.end())
return JSValue();
return location->second;
@@ -88,12 +88,12 @@ struct JSCallbackObjectData {
void setPrivateProperty(const Identifier& propertyName, JSValue value)
{
- m_propertyMap.set(propertyName.ustring().rep(), value);
+ m_propertyMap.set(propertyName.impl(), value);
}
void deletePrivateProperty(const Identifier& propertyName)
{
- m_propertyMap.remove(propertyName.ustring().rep());
+ m_propertyMap.remove(propertyName.impl());
}
void markChildren(MarkStack& markStack)
@@ -105,7 +105,7 @@ struct JSCallbackObjectData {
}
private:
- typedef HashMap<RefPtr<UString::Rep>, JSValue, IdentifierRepHash> PrivatePropertyMap;
+ typedef HashMap<RefPtr<StringImpl>, JSValue, IdentifierRepHash> PrivatePropertyMap;
PrivatePropertyMap m_propertyMap;
};
OwnPtr<JSPrivatePropertyMap> m_privateProperties;
diff --git a/JavaScriptCore/API/JSCallbackObjectFunctions.h b/JavaScriptCore/API/JSCallbackObjectFunctions.h
index 9a3e448..de5d842 100644
--- a/JavaScriptCore/API/JSCallbackObjectFunctions.h
+++ b/JavaScriptCore/API/JSCallbackObjectFunctions.h
@@ -146,14 +146,14 @@ bool JSCallbackObject<Base>::getOwnPropertySlot(ExecState* exec, const Identifie
}
if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
- if (staticValues->contains(propertyName.ustring().rep())) {
+ if (staticValues->contains(propertyName.impl())) {
slot.setCustom(this, staticValueGetter);
return true;
}
}
if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
- if (staticFunctions->contains(propertyName.ustring().rep())) {
+ if (staticFunctions->contains(propertyName.impl())) {
slot.setCustom(this, staticFunctionGetter);
return true;
}
@@ -213,7 +213,7 @@ void JSCallbackObject<Base>::put(ExecState* exec, const Identifier& propertyName
}
if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
- if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) {
+ if (StaticValueEntry* entry = staticValues->get(propertyName.impl())) {
if (entry->attributes & kJSPropertyAttributeReadOnly)
return;
if (JSObjectSetPropertyCallback setProperty = entry->setProperty) {
@@ -235,7 +235,7 @@ void JSCallbackObject<Base>::put(ExecState* exec, const Identifier& propertyName
}
if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
- if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
+ if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.impl())) {
if (entry->attributes & kJSPropertyAttributeReadOnly)
return;
JSCallbackObject<Base>::putDirect(propertyName, value); // put as override property
@@ -271,7 +271,7 @@ bool JSCallbackObject<Base>::deleteProperty(ExecState* exec, const Identifier& p
}
if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
- if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) {
+ if (StaticValueEntry* entry = staticValues->get(propertyName.impl())) {
if (entry->attributes & kJSPropertyAttributeDontDelete)
return false;
return true;
@@ -279,7 +279,7 @@ bool JSCallbackObject<Base>::deleteProperty(ExecState* exec, const Identifier& p
}
if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
- if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
+ if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.impl())) {
if (entry->attributes & kJSPropertyAttributeDontDelete)
return false;
return true;
@@ -417,7 +417,7 @@ void JSCallbackObject<Base>::getOwnPropertyNames(ExecState* exec, PropertyNameAr
typedef OpaqueJSClassStaticValuesTable::const_iterator iterator;
iterator end = staticValues->end();
for (iterator it = staticValues->begin(); it != end; ++it) {
- UString::Rep* name = it->first.get();
+ StringImpl* name = it->first.get();
StaticValueEntry* entry = it->second;
if (entry->getProperty && (!(entry->attributes & kJSPropertyAttributeDontEnum) || (mode == IncludeDontEnumProperties)))
propertyNames.add(Identifier(exec, name));
@@ -428,7 +428,7 @@ void JSCallbackObject<Base>::getOwnPropertyNames(ExecState* exec, PropertyNameAr
typedef OpaqueJSClassStaticFunctionsTable::const_iterator iterator;
iterator end = staticFunctions->end();
for (iterator it = staticFunctions->begin(); it != end; ++it) {
- UString::Rep* name = it->first.get();
+ StringImpl* name = it->first.get();
StaticFunctionEntry* entry = it->second;
if (!(entry->attributes & kJSPropertyAttributeDontEnum) || (mode == IncludeDontEnumProperties))
propertyNames.add(Identifier(exec, name));
@@ -528,7 +528,7 @@ JSValue JSCallbackObject<Base>::staticValueGetter(ExecState* exec, JSValue slotB
for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass)
if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec))
- if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep()))
+ if (StaticValueEntry* entry = staticValues->get(propertyName.impl()))
if (JSObjectGetPropertyCallback getProperty = entry->getProperty) {
if (!propertyNameRef)
propertyNameRef = OpaqueJSString::create(propertyName.ustring());
@@ -561,7 +561,7 @@ JSValue JSCallbackObject<Base>::staticFunctionGetter(ExecState* exec, JSValue sl
for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
- if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
+ if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.impl())) {
if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) {
JSObject* o = new (exec) JSCallbackFunction(exec, asGlobalObject(thisObj->getAnonymousValue(0)), callAsFunction, propertyName);
diff --git a/JavaScriptCore/API/JSClassRef.cpp b/JavaScriptCore/API/JSClassRef.cpp
index d8393f1..decf493 100644
--- a/JavaScriptCore/API/JSClassRef.cpp
+++ b/JavaScriptCore/API/JSClassRef.cpp
@@ -45,13 +45,13 @@ const JSClassDefinition kJSClassDefinitionEmpty = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
static inline UString tryCreateStringFromUTF8(const char* string)
{
if (!string)
- return UString::null();
+ return UString();
size_t length = strlen(string);
Vector<UChar, 1024> buffer(length);
UChar* p = buffer.data();
if (conversionOK != convertUTF8ToUTF16(&string, string + length, &p, p + length))
- return UString::null();
+ return UString();
return UString(buffer.data(), p - buffer.data());
}
@@ -83,7 +83,7 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass*
if (!valueName.isNull()) {
// Use a local variable here to sidestep an RVCT compiler bug.
StaticValueEntry* entry = new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes);
- UStringImpl* impl = valueName.rep();
+ StringImpl* impl = valueName.impl();
impl->ref();
m_staticValues->add(impl, entry);
}
@@ -98,7 +98,7 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass*
if (!functionName.isNull()) {
// Use a local variable here to sidestep an RVCT compiler bug.
StaticFunctionEntry* entry = new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes);
- UStringImpl* impl = functionName.rep();
+ StringImpl* impl = functionName.impl();
impl->ref();
m_staticFunctions->add(impl, entry);
}
@@ -113,7 +113,7 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass*
OpaqueJSClass::~OpaqueJSClass()
{
// The empty string is shared across threads & is an identifier, in all other cases we should have done a deep copy in className(), below.
- ASSERT(!m_className.size() || !m_className.rep()->isIdentifier());
+ ASSERT(!m_className.length() || !m_className.impl()->isIdentifier());
if (m_staticValues) {
OpaqueJSClassStaticValuesTable::const_iterator end = m_staticValues->end();
@@ -173,7 +173,7 @@ OpaqueJSClassContextData::OpaqueJSClassContextData(OpaqueJSClass* jsClass)
ASSERT(!it->first->isIdentifier());
// Use a local variable here to sidestep an RVCT compiler bug.
StaticValueEntry* entry = new StaticValueEntry(it->second->getProperty, it->second->setProperty, it->second->attributes);
- staticValues->add(UString::Rep::create(it->first->characters(), it->first->length()), entry);
+ staticValues->add(StringImpl::create(it->first->characters(), it->first->length()), entry);
}
} else
staticValues = 0;
@@ -185,7 +185,7 @@ OpaqueJSClassContextData::OpaqueJSClassContextData(OpaqueJSClass* jsClass)
ASSERT(!it->first->isIdentifier());
// Use a local variable here to sidestep an RVCT compiler bug.
StaticFunctionEntry* entry = new StaticFunctionEntry(it->second->callAsFunction, it->second->attributes);
- staticFunctions->add(UString::Rep::create(it->first->characters(), it->first->length()), entry);
+ staticFunctions->add(StringImpl::create(it->first->characters(), it->first->length()), entry);
}
} else
@@ -216,7 +216,7 @@ OpaqueJSClassContextData& OpaqueJSClass::contextData(ExecState* exec)
UString OpaqueJSClass::className()
{
// Make a deep copy, so that the caller has no chance to put the original into IdentifierTable.
- return UString(m_className.data(), m_className.size());
+ return UString(m_className.characters(), m_className.length());
}
OpaqueJSClassStaticValuesTable* OpaqueJSClass::staticValues(JSC::ExecState* exec)
diff --git a/JavaScriptCore/API/JSClassRef.h b/JavaScriptCore/API/JSClassRef.h
index 5a3a17e..5062093 100644
--- a/JavaScriptCore/API/JSClassRef.h
+++ b/JavaScriptCore/API/JSClassRef.h
@@ -55,8 +55,8 @@ struct StaticFunctionEntry : FastAllocBase {
JSPropertyAttributes attributes;
};
-typedef HashMap<RefPtr<JSC::UString::Rep>, StaticValueEntry*> OpaqueJSClassStaticValuesTable;
-typedef HashMap<RefPtr<JSC::UString::Rep>, StaticFunctionEntry*> OpaqueJSClassStaticFunctionsTable;
+typedef HashMap<RefPtr<StringImpl>, StaticValueEntry*> OpaqueJSClassStaticValuesTable;
+typedef HashMap<RefPtr<StringImpl>, StaticFunctionEntry*> OpaqueJSClassStaticFunctionsTable;
struct OpaqueJSClass;
diff --git a/JavaScriptCore/API/JSRetainPtr.h b/JavaScriptCore/API/JSRetainPtr.h
index 69c6de1..a884f38 100644
--- a/JavaScriptCore/API/JSRetainPtr.h
+++ b/JavaScriptCore/API/JSRetainPtr.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -37,23 +37,20 @@ inline void JSRelease(JSStringRef string) { JSStringRelease(string); }
enum AdoptTag { Adopt };
-template <typename T> class JSRetainPtr {
+template<typename T> class JSRetainPtr {
public:
- JSRetainPtr() : m_ptr(0) {}
+ JSRetainPtr() : m_ptr(0) { }
JSRetainPtr(T ptr) : m_ptr(ptr) { if (ptr) JSRetain(ptr); }
-
JSRetainPtr(AdoptTag, T ptr) : m_ptr(ptr) { }
-
- JSRetainPtr(const JSRetainPtr& o) : m_ptr(o.m_ptr) { if (T ptr = m_ptr) JSRetain(ptr); }
-
- ~JSRetainPtr() { if (T ptr = m_ptr) JSRelease(ptr); }
-
- template <typename U> JSRetainPtr(const JSRetainPtr<U>& o) : m_ptr(o.get()) { if (T ptr = m_ptr) JSRetain(ptr); }
+ JSRetainPtr(const JSRetainPtr&);
+ template<typename U> JSRetainPtr(const JSRetainPtr<U>&);
+ ~JSRetainPtr();
T get() const { return m_ptr; }
- T releaseRef() { T tmp = m_ptr; m_ptr = 0; return tmp; }
-
+ void clear();
+ T leakRef();
+
T operator->() const { return m_ptr; }
bool operator!() const { return !m_ptr; }
@@ -63,19 +60,57 @@ public:
operator UnspecifiedBoolType() const { return m_ptr ? &JSRetainPtr::m_ptr : 0; }
JSRetainPtr& operator=(const JSRetainPtr&);
- template <typename U> JSRetainPtr& operator=(const JSRetainPtr<U>&);
+ template<typename U> JSRetainPtr& operator=(const JSRetainPtr<U>&);
JSRetainPtr& operator=(T);
- template <typename U> JSRetainPtr& operator=(U*);
+ template<typename U> JSRetainPtr& operator=(U*);
void adopt(T);
void swap(JSRetainPtr&);
+ // FIXME: Remove releaseRef once we change all callers to call leakRef instead.
+ T releaseRef() { return leakRef(); }
+
private:
T m_ptr;
};
-template <typename T> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(const JSRetainPtr<T>& o)
+template<typename T> inline JSRetainPtr<T>::JSRetainPtr(const JSRetainPtr& o)
+ : m_ptr(o.m_ptr)
+{
+ if (m_ptr)
+ JSRetain(m_ptr);
+}
+
+template<typename T> template<typename U> inline JSRetainPtr<T>::JSRetainPtr(const JSRetainPtr<U>& o)
+ : m_ptr(o.get())
+{
+ if (m_ptr)
+ JSRetain(m_ptr);
+}
+
+template<typename T> inline JSRetainPtr<T>::~JSRetainPtr()
+{
+ if (m_ptr)
+ JSRelease(m_ptr);
+}
+
+template<typename T> inline void JSRetainPtr<T>::clear()
+{
+ if (T ptr = m_ptr) {
+ m_ptr = 0;
+ JSRelease(ptr);
+ }
+}
+
+template<typename T> inline T JSRetainPtr<T>::leakRef()
+{
+ T ptr = m_ptr;
+ m_ptr = 0;
+ return ptr;
+}
+
+template<typename T> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(const JSRetainPtr<T>& o)
{
T optr = o.get();
if (optr)
@@ -87,7 +122,7 @@ template <typename T> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(const JSR
return *this;
}
-template <typename T> template <typename U> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(const JSRetainPtr<U>& o)
+template<typename T> template<typename U> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(const JSRetainPtr<U>& o)
{
T optr = o.get();
if (optr)
@@ -99,7 +134,7 @@ template <typename T> template <typename U> inline JSRetainPtr<T>& JSRetainPtr<T
return *this;
}
-template <typename T> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(T optr)
+template<typename T> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(T optr)
{
if (optr)
JSRetain(optr);
@@ -110,7 +145,7 @@ template <typename T> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(T optr)
return *this;
}
-template <typename T> inline void JSRetainPtr<T>::adopt(T optr)
+template<typename T> inline void JSRetainPtr<T>::adopt(T optr)
{
T ptr = m_ptr;
m_ptr = optr;
@@ -118,7 +153,7 @@ template <typename T> inline void JSRetainPtr<T>::adopt(T optr)
JSRelease(ptr);
}
-template <typename T> template <typename U> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(U* optr)
+template<typename T> template<typename U> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(U* optr)
{
if (optr)
JSRetain(optr);
@@ -129,42 +164,42 @@ template <typename T> template <typename U> inline JSRetainPtr<T>& JSRetainPtr<T
return *this;
}
-template <class T> inline void JSRetainPtr<T>::swap(JSRetainPtr<T>& o)
+template<typename T> inline void JSRetainPtr<T>::swap(JSRetainPtr<T>& o)
{
std::swap(m_ptr, o.m_ptr);
}
-template <class T> inline void swap(JSRetainPtr<T>& a, JSRetainPtr<T>& b)
+template<typename T> inline void swap(JSRetainPtr<T>& a, JSRetainPtr<T>& b)
{
a.swap(b);
}
-template <typename T, typename U> inline bool operator==(const JSRetainPtr<T>& a, const JSRetainPtr<U>& b)
+template<typename T, typename U> inline bool operator==(const JSRetainPtr<T>& a, const JSRetainPtr<U>& b)
{
return a.get() == b.get();
}
-template <typename T, typename U> inline bool operator==(const JSRetainPtr<T>& a, U* b)
+template<typename T, typename U> inline bool operator==(const JSRetainPtr<T>& a, U* b)
{
return a.get() == b;
}
-template <typename T, typename U> inline bool operator==(T* a, const JSRetainPtr<U>& b)
+template<typename T, typename U> inline bool operator==(T* a, const JSRetainPtr<U>& b)
{
return a == b.get();
}
-template <typename T, typename U> inline bool operator!=(const JSRetainPtr<T>& a, const JSRetainPtr<U>& b)
+template<typename T, typename U> inline bool operator!=(const JSRetainPtr<T>& a, const JSRetainPtr<U>& b)
{
return a.get() != b.get();
}
-template <typename T, typename U> inline bool operator!=(const JSRetainPtr<T>& a, U* b)
+template<typename T, typename U> inline bool operator!=(const JSRetainPtr<T>& a, U* b)
{
return a.get() != b;
}
-template <typename T, typename U> inline bool operator!=(T* a, const JSRetainPtr<U>& b)
+template<typename T, typename U> inline bool operator!=(T* a, const JSRetainPtr<U>& b)
{
return a != b.get();
}
diff --git a/JavaScriptCore/API/OpaqueJSString.cpp b/JavaScriptCore/API/OpaqueJSString.cpp
index f740abe..9a116e6 100644
--- a/JavaScriptCore/API/OpaqueJSString.cpp
+++ b/JavaScriptCore/API/OpaqueJSString.cpp
@@ -35,7 +35,7 @@ using namespace JSC;
PassRefPtr<OpaqueJSString> OpaqueJSString::create(const UString& ustring)
{
if (!ustring.isNull())
- return adoptRef(new OpaqueJSString(ustring.data(), ustring.size()));
+ return adoptRef(new OpaqueJSString(ustring.characters(), ustring.length()));
return 0;
}
@@ -43,7 +43,7 @@ UString OpaqueJSString::ustring() const
{
if (this && m_characters)
return UString(m_characters, m_length);
- return UString::null();
+ return UString();
}
Identifier OpaqueJSString::identifier(JSGlobalData* globalData) const