[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
rjw
rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:23:12 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit c8b0fe847e62f1088c01800494784e74fa031dc5
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Jan 23 00:42:34 2004 +0000
Simplified JavaString by using UString as backing store. This
revealed a bug in CString's assignment operator which I fixed.
Removed some dead code.
Reviewed by John.
* bindings/jni/jni_runtime.h:
(KJS::Bindings::JavaString::JavaString):
(KJS::Bindings::JavaString::_commonInit):
(KJS::Bindings::JavaString::UTF8String):
(KJS::Bindings::JavaString::uchars):
(KJS::Bindings::JavaString::length):
(KJS::Bindings::JavaString::ustring):
* bindings/runtime_object.cpp:
(RuntimeObjectImp::RuntimeObjectImp):
* bindings/runtime_object.h:
* kjs/ustring.cpp:
(KJS::CString::CString):
(KJS::CString::operator=):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5964 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index d115250..982c82d 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,26 @@
+2004-01-22 Richard Williamson <rjw at apple.com>
+
+ Simplified JavaString by using UString as backing store. This
+ revealed a bug in CString's assignment operator which I fixed.
+
+ Removed some dead code.
+
+ Reviewed by John.
+
+ * bindings/jni/jni_runtime.h:
+ (KJS::Bindings::JavaString::JavaString):
+ (KJS::Bindings::JavaString::_commonInit):
+ (KJS::Bindings::JavaString::UTF8String):
+ (KJS::Bindings::JavaString::uchars):
+ (KJS::Bindings::JavaString::length):
+ (KJS::Bindings::JavaString::ustring):
+ * bindings/runtime_object.cpp:
+ (RuntimeObjectImp::RuntimeObjectImp):
+ * bindings/runtime_object.h:
+ * kjs/ustring.cpp:
+ (KJS::CString::CString):
+ (KJS::CString::operator=):
+
=== Safari-125 ===
=== Safari-124 ===
diff --git a/JavaScriptCore/bindings/jni/jni_runtime.h b/JavaScriptCore/bindings/jni/jni_runtime.h
index c283458..c78ab7f 100644
--- a/JavaScriptCore/bindings/jni/jni_runtime.h
+++ b/JavaScriptCore/bindings/jni/jni_runtime.h
@@ -42,37 +42,16 @@ namespace Bindings
class JavaString
{
public:
- JavaString () : _characters(0), _uchars(0), _size(0) {};
+ JavaString () {};
void _commonInit (JNIEnv *e, jstring s)
{
- // We could be more efficient: only create
- // _characters from _uchars on demand. Maybe just
- // use a UString?
- _size = e->GetStringLength (s);
- const char *c = getCharactersFromJStringInEnv (e, s);
- _characters = strdup(c);
- releaseCharactersForJStringInEnv (e, s, c);
+ int _size = e->GetStringLength (s);
const jchar *uc = getUCharactersFromJStringInEnv (e, s);
- _uchars = (jchar *)malloc (sizeof(jchar)*_size);
- memcpy (_uchars,uc,_size*sizeof(jchar));
+ _ustring = UString((UChar *)uc,_size);
releaseUCharactersForJStringInEnv (e, s, uc);
}
- void _commonCopy(const JavaString &other)
- {
- _size = other._size;
- _characters = strdup (other._characters);
- _uchars = (jchar *)malloc (sizeof(jchar)*_size);
- memcpy (_uchars,other._uchars,_size*sizeof(jchar));
- }
-
- void _commonDelete()
- {
- free ((void *)_characters);
- free ((void *)_uchars);
- }
-
JavaString (JNIEnv *e, jstring s) {
_commonInit (e, s);
}
@@ -81,38 +60,20 @@ public:
_commonInit (getJNIEnv(), s);
}
- ~JavaString () {
- _commonDelete();
- }
-
- JavaString(const JavaString &other)
- {
- _commonCopy(other);
+ const char *UTF8String() const {
+ if (_utf8String.c_str() == 0)
+ _utf8String = _ustring.UTF8String();
+ return _utf8String.c_str();
}
-
- JavaString &operator=(const JavaString &other)
- {
- if (this == &other)
- return *this;
-
- _commonDelete();
- _commonCopy(other);
-
- return *this;
- }
-
- const char *UTF8String() const { return _characters; }
- const jchar *uchars() const { return _uchars; }
- int length() const { return _size; }
- KJS::UString ustring() const { return KJS::UString ((const KJS::UChar *)uchars(),length()); }
+ const jchar *uchars() const { return (const jchar *)_ustring.data(); }
+ int length() const { return _ustring.size(); }
+ KJS::UString ustring() const { return _ustring; }
private:
- const char *_characters;
- jchar *_uchars;
- int _size;
+ UString _ustring;
+ mutable CString _utf8String;
};
-
class JavaParameter : public Parameter
{
public:
diff --git a/JavaScriptCore/bindings/runtime_object.cpp b/JavaScriptCore/bindings/runtime_object.cpp
index 1b3771d..6cd5395 100644
--- a/JavaScriptCore/bindings/runtime_object.cpp
+++ b/JavaScriptCore/bindings/runtime_object.cpp
@@ -57,7 +57,6 @@ RuntimeObjectImp::RuntimeObjectImp(Bindings::Instance *i, bool oi) : ObjectImp (
{
ownsInstance = oi;
instance = i;
- _initializeClassInfoFromInstance();
}
Value RuntimeObjectImp::get(ExecState *exec, const Identifier &propertyName) const
@@ -147,8 +146,3 @@ Value RuntimeObjectImp::defaultValue(ExecState *exec, Type hint) const
return aValue;
}
-void RuntimeObjectImp::_initializeClassInfoFromInstance()
-{
- if (!instance)
- return;
-}
diff --git a/JavaScriptCore/bindings/runtime_object.h b/JavaScriptCore/bindings/runtime_object.h
index 51b392f..503c247 100644
--- a/JavaScriptCore/bindings/runtime_object.h
+++ b/JavaScriptCore/bindings/runtime_object.h
@@ -62,7 +62,6 @@ public:
Bindings::Instance *getInternalInstance() const { return instance; }
private:
- void _initializeClassInfoFromInstance();
static const ClassInfo info;
Bindings::Instance *instance;
diff --git a/JavaScriptCore/kjs/ustring.cpp b/JavaScriptCore/kjs/ustring.cpp
index c6ee008..2cdef0e 100644
--- a/JavaScriptCore/kjs/ustring.cpp
+++ b/JavaScriptCore/kjs/ustring.cpp
@@ -64,8 +64,13 @@ CString::CString(const char *c, int len)
CString::CString(const CString &b)
{
length = b.length;
- data = new char[length+1];
- memcpy(data, b.data, length + 1);
+ if (length > 0 && b.data) {
+ data = new char[length+1];
+ memcpy(data, b.data, length + 1);
+ }
+ else {
+ data = 0;
+ }
}
CString::~CString()
@@ -109,8 +114,13 @@ CString &CString::operator=(const CString &str)
if (data)
delete [] data;
length = str.length;
- data = new char[length + 1];
- memcpy(data, str.data, length + 1);
+ if (length > 0 && str.data) {
+ data = new char[length + 1];
+ memcpy(data, str.data, length + 1);
+ }
+ else {
+ data = 0;
+ }
return *this;
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list