[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libbase/container.cpp libbase/c...
From: |
Bastiaan Jacques |
Subject: |
[Gnash-commit] gnash ChangeLog libbase/container.cpp libbase/c... |
Date: |
Sun, 15 Apr 2007 10:52:10 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Bastiaan Jacques <bjacques> 07/04/15 10:52:09
Modified files:
. : ChangeLog
libbase : container.cpp container.h membuf.cpp membuf.h
server : PropertyList.cpp array.cpp as_function.cpp
as_object.h as_value.cpp as_value.h
edit_text_character.cpp gnash.h
sprite_instance.cpp sprite_instance.h
textformat.cpp
server/asobj : Global.cpp LocalConnection.cpp
MovieClipLoader.cpp NetConnection.cpp
NetStream.cpp Object.cpp Sound.cpp xml.cpp
xmlnode.cpp
server/vm : ASHandlers.cpp action.cpp
Log message:
* libbase/container.{cpp,h}: Remove tu_string{,i}.
* server/as_value.{cpp,h}: Replace tu_string with std::string.
Remove wide string code that was both unused and inherently
broken.
* all over the place: Update to match changes in as_value.h.
Also, eliminate tu_string usage entirely.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2875&r2=1.2876
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/container.cpp?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/container.h?cvsroot=gnash&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/membuf.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/membuf.h?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/server/PropertyList.cpp?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/server/array.cpp?cvsroot=gnash&r1=1.58&r2=1.59
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_function.cpp?cvsroot=gnash&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.h?cvsroot=gnash&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.cpp?cvsroot=gnash&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.h?cvsroot=gnash&r1=1.42&r2=1.43
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.52&r2=1.53
http://cvs.savannah.gnu.org/viewcvs/gnash/server/gnash.h?cvsroot=gnash&r1=1.92&r2=1.93
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.240&r2=1.241
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.96&r2=1.97
http://cvs.savannah.gnu.org/viewcvs/gnash/server/textformat.cpp?cvsroot=gnash&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.cpp?cvsroot=gnash&r1=1.57&r2=1.58
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/LocalConnection.cpp?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/MovieClipLoader.cpp?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetConnection.cpp?cvsroot=gnash&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStream.cpp?cvsroot=gnash&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Object.cpp?cvsroot=gnash&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Sound.cpp?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xml.cpp?cvsroot=gnash&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlnode.cpp?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.88&r2=1.89
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/action.cpp?cvsroot=gnash&r1=1.13&r2=1.14
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2875
retrieving revision 1.2876
diff -u -b -r1.2875 -r1.2876
--- ChangeLog 14 Apr 2007 22:23:04 -0000 1.2875
+++ ChangeLog 15 Apr 2007 10:52:08 -0000 1.2876
@@ -1,3 +1,12 @@
+2007-04-15 Bastiaan Jacques <address@hidden>
+
+ * libbase/container.{cpp,h}: Remove tu_string{,i}.
+ * server/as_value.{cpp,h}: Replace tu_string with std::string.
+ Remove wide string code that was both unused and inherently
+ broken.
+ * all over the place: Update to match changes in as_value.h.
+ Also, eliminate tu_string usage entirely.
+
2007-04-15 Sandro Santilli <address@hidden>
* testsuite/actionscript.all/MovieClip.as,
Index: libbase/container.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/container.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- libbase/container.cpp 11 Apr 2007 17:54:21 -0000 1.13
+++ libbase/container.cpp 15 Apr 2007 10:52:09 -0000 1.14
@@ -17,319 +17,6 @@
#include "utf8.h"
#include "tu_random.h"
-void tu_string::append_wide_char(uint16_t c)
-{
- char buf[8];
- int index = 0;
- utf8::encode_unicode_character(buf, &index, (uint32_t) c);
- buf[index] = '\0';
-
- *this += buf;
-}
-
-
-void tu_string::append_wide_char(uint32_t c)
-{
- char buf[8];
- int index = 0;
- utf8::encode_unicode_character(buf, &index, c);
- buf[index] = '\0';
-
- *this += buf;
-}
-
-
-void tu_string::resize(int new_size)
-{
- assert(new_size >= 0);
-
- if (using_heap() == false)
- {
- if (new_size < 15)
- {
- // Stay with internal storage.
- m_local.m_size = (char) (new_size + 1);
- m_local.m_buffer[new_size] = '\0'; // terminate
- }
- else
- {
- // need to allocate heap buffer.
- int capacity = new_size + 1;
- // round up.
- capacity = (capacity + 15) & ~15;
- char* buf = (char*) tu_malloc(capacity);
- memset(buf, 0, capacity);
-
- // Copy existing data.
- strcpy(buf, m_local.m_buffer);
-
- // Set the heap state.
- m_heap.m_buffer = buf;
- m_heap.m_all_ones = char(~0);
- m_heap.m_size = new_size + 1;
- m_heap.m_capacity = capacity;
- }
- }
- else
- {
- // Currently using heap storage.
- if (new_size < 15)
- {
- // Switch to local storage.
-
- // Be sure to get stack copies of m_heap info, before
we overwrite it.
- char* old_buffer = m_heap.m_buffer;
- int old_capacity = m_heap.m_capacity;
- UNUSED(old_capacity);
-
- // Copy existing string info.
- m_local.m_size = (char) (new_size + 1);
- strncpy(m_local.m_buffer, old_buffer, 15);
- m_local.m_buffer[new_size] = '\0'; // ensure
termination.
-
- tu_free(old_buffer, old_capacity);
- }
- else
- {
- // Changing size of heap buffer.
- int capacity = new_size + 1;
- // Round up.
- capacity = (capacity + 15) & ~15;
- if (capacity != m_heap.m_capacity) // @@ TODO
should use hysteresis when resizing
- {
- m_heap.m_buffer = (char*)
tu_realloc(m_heap.m_buffer, capacity, m_heap.m_capacity);
- m_heap.m_capacity = capacity;
- }
- // else we're OK with existing buffer.
-
- m_heap.m_size = new_size + 1;
-
- // Ensure termination.
- m_heap.m_buffer[new_size] = '\0';
- }
- }
-}
-
-
-template<class char_type>
-/*static*/ void encode_utf8_from_wchar_generic(tu_string* result, const
char_type* wstr)
-{
- const char_type* in = wstr;
-
- // First pass: compute the necessary string length.
- int bytes_needed = 0;
- char dummy[10];
- int offset;
- for (;;)
- {
- uint32_t uc = *in++;
- offset = 0;
- utf8::encode_unicode_character(dummy, &offset, uc);
- bytes_needed += offset;
-
- assert(offset <= 6);
-
- if (uc == 0)
- {
- break;
- }
- }
-
- // Second pass: transfer the data.
- result->resize(bytes_needed - 1); // resize() adds 1 for the \0
terminator
- in = wstr;
- char* out = &((*result)[0]);
- offset = 0;
- for (;;)
- {
- assert(offset < bytes_needed);
-
- uint32_t uc = *in++;
- utf8::encode_unicode_character(out, &offset, uc);
-
- assert(offset <= bytes_needed);
-
- if (uc == 0)
- {
- break;
- }
- }
-
- assert(offset == bytes_needed);
- assert((*result)[offset - 1] == 0);
- assert(result->length() == (int) strlen(result->c_str()));
-}
-
-void tu_string::encode_utf8_from_wchar(tu_string* result, const uint32_t* wstr)
-{
- encode_utf8_from_wchar_generic<uint32_t>(result, wstr);
-}
-
-
-void tu_string::encode_utf8_from_wchar(tu_string* result, const uint16_t* wstr)
-{
- encode_utf8_from_wchar_generic<uint16_t>(result, wstr);
-}
-
-
-/*static*/ int tu_string::stricmp(const char* a, const char* b)
-{
- return STRCASECMP(a, b);
-}
-
-
-uint32_t tu_string::utf8_char_at(int index) const
-{
- const char* buf = get_buffer();
- uint32_t c;
-
- do
- {
- c = utf8::decode_next_unicode_character(&buf);
- index--;
-
- if (c == 0)
- {
- // We've hit the end of the string; don't go further.
- assert(index == 0);
- return c;
- }
- }
- while (index >= 0);
-
- return c;
-}
-
-
-tu_string tu_string::utf8_to_upper() const
-{
- const char* buf = get_buffer();
- tu_string str;
- for (;;)
- {
- uint32_t c = utf8::decode_next_unicode_character(&buf);
-
- if (c == 0)
- {
- // We've hit the end of the string; don't go further.
- return str;
- }
- str += toupper(c);
- }
-
- return str;
-}
-
-
-tu_string tu_string::utf8_to_lower() const
-{
- const char* buf = get_buffer();
- tu_string str;
- for (;;)
- {
- uint32_t c = utf8::decode_next_unicode_character(&buf);
-
- if (c == 0) {
- // We've hit the end of the string; don't go further.
- return str;
- }
- str += tolower(c);
- }
-
- return str;
-}
-
-
-/*static*/ int tu_string::utf8_char_count(const char* buf, int buflen)
-{
- const char* p = buf;
- int length = 0;
-
- while (p - buf < buflen)
- {
- uint32_t c = utf8::decode_next_unicode_character(&p);
- if (c == 0)
- {
- break;
- }
-
- length++;
- }
-
- return length;
-}
-
-
-tu_string tu_string::utf8_substring(int start, int end) const
-{
- assert(start <= end);
-
- if (start == end)
- {
- // Special case, always return empty string.
- return tu_string();
- }
-
- const char* p = get_buffer();
- int index = 0;
- const char* start_pointer = p;
- const char* end_pointer = p;
-
- for (;;)
- {
- if (index == start)
- {
- start_pointer = p;
- }
-
- uint32_t c = utf8::decode_next_unicode_character(&p);
- index++;
-
- if (index == end)
- {
- end_pointer = p;
- break;
- }
-
- if (c == 0)
- {
- if (index < end)
- {
- assert(0);
- end_pointer = p;
- }
- break;
- }
- }
-
- if (end_pointer < start_pointer)
- {
- end_pointer = start_pointer;
- }
-
- return tu_string(start_pointer, end_pointer - start_pointer);
-}
-
-
-// #ifndef HAVE_VSNPRINTF
-// #define vsnprintf _vsnprintf
-// #endif
-
-tu_string string_printf(const char* fmt, ...)
-// Handy sprintf wrapper.
-{
- static const int BUFFER_SIZE = 500;
- char s_buffer[BUFFER_SIZE];
-
- va_list ap;
- va_start(ap, fmt);
- vsnprintf(s_buffer, BUFFER_SIZE, fmt, ap);
- va_end(ap);
-
- return s_buffer;
-}
-
-
#ifdef CONTAINER_UNIT_TEST
@@ -473,222 +160,6 @@
printf("next_new_index = %d\n", next_new_index);
}
-
-void test_stringi()
-{
- tu_stringi a, b;
-
- // Equality.
- a = "this is a test";
- b = "This is a test";
- assert(a == b);
-
- b = "tHiS Is a tEsT";
- assert(a == b);
-
- a += "Hello";
- b += "hellO";
- assert(a == b);
-
- tu_string c(b);
- assert(a.to_tu_string() != c);
-
- // Ordering.
- a = "a";
- b = "B";
- assert(a < b);
-
- a = "b";
- b = "A";
- assert(a > b);
-}
-
-
-void test_stringi_hash()
-{
- stringi_hash<int> a;
-
- assert(a.is_empty());
-
- a.add("bobo", 1);
-
- assert(a.is_empty() == false);
-
- a.add("hello", 2);
- a.add("it's", 3);
- a.add("a", 4);
- a.add("beautiful day!", 5);
-
- int result = 0;
- a.get("boBO", &result);
- assert(result == 1);
-
- a.set("BObo", 2);
- a.get("bObO", &result);
- assert(result == 2);
-
- assert(a.is_empty() == false);
- a.clear();
- assert(a.is_empty() == true);
-
- // Hammer on one key that differs only by case.
- tu_stringi original_key("thisisatest");
- tu_stringi key(original_key);
- a.add(key, 1234567);
-
- int variations = 1 << key.length();
- for (int i = 0; i < variations; i++)
- {
- // Twiddle the case of the key.
- for (int c = 0; c < key.length(); c++)
- {
- if (i & (1 << c))
- {
- key[c] = toupper(key[c]);
- }
- else
- {
- key[c] = tolower(key[c]);
- }
- }
-
- a.set(key, 7654321);
-
- // Make sure original entry was modified.
- int value = 0;
- a.get(original_key, &value);
- assert(value == 7654321);
-
- // Make sure hash keys are preserving case.
- assert(a.find(key)->first.to_tu_string() ==
original_key.to_tu_string());
-
- // Make sure they're actually the same entry.
- assert(a.find(original_key) == a.find(key));
-
- a.set(original_key, 1234567);
- assert(a.find(key)->second == 1234567);
- }
-}
-
-
-void test_unicode()
-{
- tu_string a;
-
- tu_string::encode_utf8_from_wchar(&a, L"19 character string");
- assert(a.length() == 19);
-
- // TODO add some more tests; should test actual UTF-8 conversions.
-}
-
-
-
-int main()
-{
-#if 1
- printf("sizeof(tu_string) == %d\n", sizeof(tu_string));
-
- std::vector<tu_string> storage;
- storage.resize(2);
-
- tu_string& a = storage[0];
- tu_string& b = storage[1];
- a = "test1";
-
- printf("&a = 0x%X, &b = 0x%X\n", int(&a), int(&b));
-
- printf("%s\n", a.c_str());
-
- assert(a == "test1");
- assert(a.length() == 5);
-
- a += "2";
- assert(a == "test12");
-
- a += "this is some more text";
- assert(a.length() == 28);
-
- assert(a[2] == 's');
- assert(a[3] == 't');
- assert(a[4] == '1');
- assert(a[5] == '2');
- assert(a[7] == 'h');
- assert(a[28] == 0);
-
- assert(b.length() == 0);
- assert(b[0] == 0);
- assert(b.c_str()[0] == 0);
-
- tu_string c = a + b;
-
- assert(c.length() == a.length());
-
- c.resize(2);
- assert(c == "te");
- assert(c == tu_string("te"));
-
- assert(tu_string("fourscore and sevent") == "fourscore and sevent");
-
- b = "#sacrificial lamb";
-
- // Test growing & shrinking.
- a = "";
- for (int i = 0; i < 1000; i++)
- {
- assert(a.length() == i);
-
- if (i == 8)
- {
- assert(a == "01234567");
- }
- else if (i == 27)
- {
- assert(a == "012345678901234567890123456");
- }
-
- a.resize(a.length() + 1);
- a[a.length() - 1] = '0' + (i % 10);
- }
-
- {for (int i = 999; i >= 0; i--)
- {
- a.resize(a.length() - 1);
- assert(a.length() == i);
-
- if (i == 8)
- {
- assert(a == "01234567");
- }
- else if (i == 27)
- {
- assert(a == "012345678901234567890123456");
- }
- }}
-
- // Test larger shrinking across heap/local boundary.
- a = "this is a string longer than 16 characters";
- a = "short";
-
- // Test larger expand across heap/local boundary.
- a = "another longer string...";
-
- assert(b == "#sacrificial lamb");
-
- test_hash();
- test_stringi();
- test_stringi_hash();
-
- test_unicode();
-
- // TODO: unit tests for std::vector<>, string_hash<>
-#endif
-
- test_hash_speed();
-
- return 0;
-}
-
-
#endif // CONTAINER_UNIT_TEST
Index: libbase/container.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/container.h,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- libbase/container.h 13 Apr 2007 09:15:54 -0000 1.53
+++ libbase/container.h 15 Apr 2007 10:52:09 -0000 1.54
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: container.h,v 1.53 2007/04/13 09:15:54 bjacques Exp $ */
+/* $Id: container.h,v 1.54 2007/04/15 10:52:09 bjacques Exp $ */
#ifndef __CONTAINER_H__
#define __CONTAINER_H__
@@ -702,356 +702,6 @@
#pragma warning(disable : 4345) // in MSVC 7.1, warning about placement
new POD default initializer
#endif // _WIN32
-class tu_stringi;
-
-// String-like type. Attempt to be memory-efficient with small strings.
-class DSOEXPORT tu_string
-{
-public:
- tu_string() { m_local.m_size = 1; memset(m_local.m_buffer, 0, 15); }
- tu_string(const char* str)
- {
- m_local.m_size = 1;
- m_local.m_buffer[0] = '\0';
-
- int new_size = strlen(str);
- resize(new_size);
- strcpy(get_buffer(), str);
- }
- tu_string(const char* buf, int buflen)
- {
- m_local.m_size = 1;
- m_local.m_buffer[0] = '\0';
-
- int new_size = buflen;
- resize(new_size);
- memcpy(get_buffer(), buf, buflen);
- get_buffer()[buflen] = '\0'; // terminate.
- }
- tu_string(const tu_string& str)
- {
- m_local.m_size = 1;
- m_local.m_buffer[0] = '\0';
-
- resize(str.size());
- strcpy(get_buffer(), str.get_buffer());
- }
- tu_string(const uint32_t* wide_char_str)
- {
- m_local.m_size = 1;
- m_local.m_buffer[0] = '\0';
-
- *this = wide_char_str;
- }
- tu_string(const uint16_t* wide_char_str)
- {
- m_local.m_size = 1;
- m_local.m_buffer[0] = '\0';
-
- *this = wide_char_str;
- }
-
- ~tu_string()
- {
- if (using_heap())
- {
- tu_free(m_heap.m_buffer, m_heap.m_capacity);
- }
- }
-
- operator const char*() const
- {
- return get_buffer();
- }
-
- const char* c_str() const
- {
- return (const char*) (*this);
- }
-
- /// \brief
- /// If you need a const tu_stringi, don't create a new object;
- /// these things have the same internal representation.
- const tu_stringi& to_tu_stringi() const { return *(const
tu_stringi*) this; }
-
- /// \brief
- /// operator= returns void; if you want to know why, ask Charles Bloom
:)
- /// (executive summary: a = b = c is an invitation to bad code)
- void operator=(const char* str)
- {
- resize(strlen(str));
- strcpy(get_buffer(), str);
- }
-
- void operator=(const tu_string& str)
- {
- resize(str.size());
- strcpy(get_buffer(), str.get_buffer());
- }
-
- bool operator==(const char* str) const
- {
- return strcmp(*this, str) == 0;
- }
-
- bool operator!=(const char* str) const
- {
- return strcmp(*this, str) != 0;
- }
-
- bool operator==(const tu_string& str) const
- {
- return strcmp(*this, str) == 0;
- }
-
- bool operator!=(const tu_string& str) const
- {
- return strcmp(*this, str) != 0;
- }
-
- int length() const
- {
- if (using_heap() == false)
- {
- return m_local.m_size - 1;
- }
- else
- {
- return m_heap.m_size - 1;
- }
- }
- int size() const { return length(); }
-
- char& operator[](int index)
- {
- assert(index >= 0 && index <= size());
- return get_buffer()[index];
- }
- const char& operator[](int index) const
- {
- return (*(const_cast<tu_string*>(this)))[index];
- }
-
- void operator+=(const char* str)
- {
- int str_length = strlen(str);
- int old_length = length();
- assert(old_length >= 0);
- resize(old_length + str_length);
- strcpy(get_buffer() + old_length, str);
- }
-
- void operator+=(char ch)
- {
- int old_length = length();
- assert(old_length >= 0);
- resize(old_length + 1);
- strncpy(get_buffer() + old_length, (char *)&ch, 1);
- }
-
- // Append wide char. Both versions of wide char.
- void append_wide_char(uint16_t ch);
- void append_wide_char(uint32_t ch);
-
- void operator+=(const tu_string& str)
- {
- int str_length = str.length();
- int old_length = length();
- assert(old_length >= 0);
- resize(old_length + str_length);
- strcpy(get_buffer() + old_length, str.c_str());
- }
-
- tu_string operator+(const char* str) const
- // NOT EFFICIENT! But convenient.
- {
- tu_string new_string(*this);
- new_string += str;
- return new_string;
- }
-
- bool operator<(const char* str) const
- {
- return strcmp(c_str(), str) < 0;
- }
- bool operator<(const tu_string& str) const
- {
- return *this < str.c_str();
- }
- bool operator>(const char* str) const
- {
- return strcmp(c_str(), str) > 0;
- }
- bool operator>(const tu_string& str) const
- {
- return *this > str.c_str();
- }
-
- void clear()
- {
- resize(0);
- }
-
- // Sets buffer size to new_size+1 (i.e. enough room for
- // new_size chars, plus terminating 0).
- void resize(int new_size);
-
- // Set *result to the UTF-8 encoded version of wstr[].
- // Both version of wchar_t.
- //
- // Could add operator= overloads, but maybe it's better to
- // keep this very explicit.
- static void encode_utf8_from_wchar(tu_string* result, const
uint32_t* wstr);
- static void encode_utf8_from_wchar(tu_string* result, const
uint16_t* wstr);
-
- // Utility: case-insensitive string compare. stricmp() is not
- // ANSI or POSIX, doesn't seem to appear in Linux.
- static int stricmp(const char* a, const char* b);
-
- // Return the Unicode char at the specified character
- // position. index is in UTF-8 chars, NOT bytes.
- uint32_t utf8_char_at(int index) const;
-
- // Return the string in this container as all upper case letters
- tu_string utf8_to_upper() const;
-
- // Return the string in this container as all lower case letters
- tu_string utf8_to_lower() const;
-
- // Return the number of UTF-8 characters in the given
- // substring buffer. You must pass in a valid buffer length;
- // this routine does not look for a terminating \0.
- static int utf8_char_count(const char* buf, int buflen);
-
- int utf8_length() const { return utf8_char_count(get_buffer(),
length()); }
-
- // Returns a tu_string that's a substring of this. start and
- // end are in UTF-8 character positions (NOT bytes).
- //
- // start is the index of the first character you want to include.
- //
- // end is the index one past the last character you want to include.
- tu_string utf8_substring(int start, int end) const;
-
-private:
- char* get_buffer()
- {
- if (using_heap() == false)
- {
- return m_local.m_buffer;
- }
- else
- {
- return m_heap.m_buffer;
- }
- }
-
- const char* get_buffer() const
- {
- return const_cast<tu_string*>(this)->get_buffer();
- }
-
-
- bool using_heap() const
- {
- bool heap = (m_heap.m_all_ones == (char) ~0);
- return heap;
- }
-
- // The idea here is that tu_string is a 16-byte structure,
- // which uses internal storage for strings of 14 characters or
- // less. For longer strings, it allocates a heap buffer, and
- // keeps the buffer-tracking info in the same bytes that would
- // be used for internal string storage.
- //
- // A string that's implemented like vector<char> is typically
- // 12 bytes plus heap storage, so this seems like a decent
- // thing to try. Also, a zero-length string still needs a
- // terminator character, which with vector<char> means an
- // unfortunate heap alloc just to hold a single '0'.
- union
- {
- // Internal storage.
- struct
- {
- char m_size;
- char m_buffer[15];
- } m_local;
-
- // Heap storage.
- struct
- {
- char m_all_ones; // flag to indicate heap
storage is in effect.
- int m_size;
- int m_capacity;
- char* m_buffer;
- } m_heap;
- };
-};
-
-
-// String-like type; comparisons are CASE INSENSITIVE.
-// Uses tu_string for implementation.
-class tu_stringi
-{
-public:
- tu_stringi() {}
- tu_stringi(const char* str) : m_string(str) {}
- tu_stringi(const tu_string& str) : m_string(str) {}
- tu_stringi(const tu_stringi& stri) : m_string(stri.c_str()) {}
-
- ~tu_stringi() {}
-
- operator const char*() const { return (const char*) m_string; }
- const char* c_str() const { return m_string.c_str(); }
- void operator=(const char* str) { m_string = str; }
- void operator=(const tu_string& str) { m_string = str; }
- void operator=(const tu_stringi& str) { m_string = str.m_string; }
- int length() const { return m_string.length(); }
- int size() const { return length(); }
- char& operator[](int index) { return m_string[index]; }
- const char& operator[](int index) const { return m_string[index]; }
- void operator+=(const char* str) { m_string += str; }
- void operator+=(const tu_string& str) { m_string += str; }
- void operator+=(const tu_stringi& str) { m_string += str.m_string; }
- tu_stringi operator+(const char* str) const { return
tu_stringi(m_string + str); }
-
- // The special stuff.
- tu_string& to_tu_string() { return m_string; }
- const tu_string& to_tu_string() const { return m_string; }
-
- bool operator==(const char* str) const
- {
- return tu_string::stricmp(*this, str) == 0;
- }
- bool operator==(const tu_stringi& str) const
- {
- return tu_string::stricmp(*this, str) == 0;
- }
- bool operator<(const char* str) const
- {
- return tu_string::stricmp(c_str(), str) < 0;
- }
- bool operator<(const tu_stringi& str) const
- {
- return *this < str.c_str();
- }
- bool operator>(const char* str) const
- {
- return tu_string::stricmp(c_str(), str) > 0;
- }
- bool operator>(const tu_stringi& str) const
- {
- return *this > str.c_str();
- }
-
- void resize(int new_size) { m_string.resize(new_size); }
-
-private:
- tu_string m_string;
-};
-
-
template<class T>
class string_hash_functor
// Computes a hash of a string-like object (something that has
@@ -1066,13 +716,6 @@
}
};
-
-template<class U>
-class string_hash : public gnash::hash<tu_string, U,
string_hash_functor<tu_string> >
-{
-};
-
-
template<class T>
class stringi_hash_functor
// Computes a case-insensitive hash of a string-like object (something that has
@@ -1087,22 +730,6 @@
}
};
-
-// Case-insensitive string hash.
-template<class U>
-class stringi_hash : public gnash::hash<tu_stringi, U,
stringi_hash_functor<tu_stringi> >
-{
-};
-
-
-// Utility: handy sprintf wrapper.
-tu_string string_printf(const char* fmt, ...)
-#ifdef __GNUC__
- // use the following to catch errors: (only with gcc)
- __attribute__((format (printf, 1, 2)))
-#endif // not __GNUC__
-;
-
#endif // __CONTAINER_H__
// Local Variables:
Index: libbase/membuf.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/membuf.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- libbase/membuf.cpp 6 Aug 2006 02:00:54 -0000 1.4
+++ libbase/membuf.cpp 15 Apr 2007 10:52:09 -0000 1.5
@@ -65,7 +65,7 @@
}
-membuf::membuf(const tu_string& str)
+membuf::membuf(const std::string& str)
:
m_size(0),
m_capacity(0),
@@ -152,7 +152,7 @@
}
-bool membuf::append(const tu_string& str)
+bool membuf::append(const std::string& str)
{
return append(str.c_str(), str.length());
}
Index: libbase/membuf.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/membuf.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- libbase/membuf.h 25 Aug 2006 23:35:20 -0000 1.3
+++ libbase/membuf.h 15 Apr 2007 10:52:09 -0000 1.4
@@ -13,9 +13,7 @@
#include "tu_config.h"
#include "utility.h"
-
-class tu_string;
-
+#include <string>
class membuf
{
@@ -23,7 +21,7 @@
membuf();
membuf(const void* data, int size);
membuf(const membuf& buf);
- membuf(const tu_string& str);
+ membuf(const std::string& str);
~membuf();
// Construct a read-only membuf that points at the given data,
@@ -44,7 +42,7 @@
bool append(const void* data, int size);
bool append(const membuf& buf);
// We do not append the terminating '\0'.
- bool append(const tu_string& str);
+ bool append(const std::string& str);
private:
int m_size;
Index: server/PropertyList.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/PropertyList.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- server/PropertyList.cpp 22 Mar 2007 15:26:16 -0000 1.12
+++ server/PropertyList.cpp 15 Apr 2007 10:52:09 -0000 1.13
@@ -210,7 +210,7 @@
for ( const_iterator it=begin(), itEnd=end(); it != itEnd; ++it )
{
log_msg(" %s: %s", it->first.c_str(),
- it->second->getValue(this_ptr).to_string());
+ it->second->getValue(this_ptr).to_string().c_str());
}
}
Index: server/array.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/array.cpp,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -b -r1.58 -r1.59
--- server/array.cpp 13 Apr 2007 07:35:55 -0000 1.58
+++ server/array.cpp 15 Apr 2007 10:52:09 -0000 1.59
@@ -33,6 +33,7 @@
#include <string>
#include <algorithm>
#include <memory> // for auto_ptr
+#include <boost/algorithm/string/case_conv.hpp>
//#define GNASH_DEBUG
@@ -49,7 +50,7 @@
public:
bool operator() (const as_value& a, const as_value& b)
{
- return ( a.to_tu_string() < b.to_tu_string() );
+ return a.to_string().compare(b.to_string()) < 0;
}
};
@@ -59,7 +60,7 @@
public:
bool operator() (const as_value& a, const as_value& b)
{
- return ( a.to_string() > b.to_string() );
+ return a.to_string().compare(b.to_string()) > 0;
}
};
@@ -69,7 +70,12 @@
public:
bool operator() (const as_value& a, const as_value& b)
{
- return ( a.to_tu_stringi() < b.to_tu_stringi() );
+ using namespace boost::algorithm;
+
+ std::string strA = to_upper_copy(a.to_string());
+ std::string strB = to_upper_copy(b.to_string());
+
+ return strA.compare(strB) < 0;
}
};
@@ -79,7 +85,12 @@
public:
bool operator() (const as_value& a, const as_value& b)
{
- return ( a.to_tu_stringi() > b.to_tu_stringi() );
+ using namespace boost::algorithm;
+
+ std::string strA = to_upper_copy(a.to_string());
+ std::string strB = to_upper_copy(b.to_string());
+
+ return strA.compare(strB) > 0;
}
};
@@ -632,7 +643,7 @@
IF_VERBOSE_ACTION (
log_action("calling array pop, result:%s, new array size:%d",
- rv.to_string(), array->size());
+ rv.to_string().c_str(), array->size());
);
return rv;
}
@@ -648,7 +659,7 @@
IF_VERBOSE_ACTION (
log_action("calling array shift, result:%s, new array size:%d",
- rv.to_string(), array->size());
+ rv.to_string().c_str(), array->size());
);
return rv;
}
@@ -665,7 +676,7 @@
IF_VERBOSE_ACTION (
log_action("called array reverse, result:%s, new array size:%d",
- rv.to_string(), array->size());
+ rv.to_string().c_str(), array->size());
);
return rv;
}
@@ -846,7 +857,7 @@
for (int i = 0; i < int(fn.arg(0).to_number()); i++)
{
index_number.set_int(i);
- ao->set_member(index_number.to_string(), null_value);
+ ao->set_member(index_number.to_string().c_str(),
null_value);
}
}
else
Index: server/as_function.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_function.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- server/as_function.cpp 24 Mar 2007 11:35:02 -0000 1.28
+++ server/as_function.cpp 15 Apr 2007 10:52:09 -0000 1.29
@@ -246,7 +246,7 @@
" (expected array)"
" - considering as call with no
args",
fn.arg(1).typeOf(),
- fn.arg(1).to_string());
+ fn.arg(1).to_string().c_str());
);
goto call_it;
}
Index: server/as_object.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.h,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- server/as_object.h 29 Mar 2007 14:29:15 -0000 1.53
+++ server/as_object.h 15 Apr 2007 10:52:09 -0000 1.54
@@ -465,8 +465,6 @@
/// The derived class should not override this method,
/// but instead implement its own gettersetter properties.
///
- /// TODO: take a std::string rather then a tu_stringi
- ///
/// @parame name
/// Name of the property.
/// Case insensitive up to SWF6,
Index: server/as_value.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- server/as_value.cpp 14 Apr 2007 17:31:24 -0000 1.35
+++ server/as_value.cpp 15 Apr 2007 10:52:09 -0000 1.36
@@ -66,32 +66,15 @@
}
}
-
-// Conversion to string.
-const char
-*as_value::to_string(as_environment* env) const
-{
- return to_tu_string(env).c_str();
-}
-
-
std::string
as_value::to_std_string(as_environment* env) const
{
- const char* c = to_string(env);
- assert(c);
- return std::string(c);
+ return to_string(env);
}
-const tu_stringi
-&as_value::to_tu_stringi(as_environment* env) const
-{
- return reinterpret_cast<const tu_stringi&>(to_tu_string(env));
-}
-
-// Conversion to const tu_string&.
-const tu_string&
-as_value::to_tu_string(as_environment* env) const
+// Conversion to const std::string&.
+const std::string&
+as_value::to_string(as_environment* env) const
{
switch (m_type)
{
@@ -214,9 +197,9 @@
return m_string_value;
}
-// Conversion to const tu_string&.
-const tu_string
-&as_value::to_tu_string_versioned(int version, as_environment* env) const
+// Conversion to const std::string&.
+const std::string&
+as_value::to_string_versioned(int version, as_environment* env) const
{
if (m_type == UNDEFINED) {
// Version-dependent behavior.
@@ -228,14 +211,14 @@
return m_string_value;
}
- return to_tu_string(env);
+ return to_string(env);
}
// Version-based Conversion to std::string
std::string
as_value::to_std_string_versioned(int version, as_environment* env) const
{
- return std::string(to_tu_string_versioned(version, env).c_str());
+ return to_string_versioned(version, env);
}
// Conversion to primitive value.
@@ -554,7 +537,7 @@
void
as_value::convert_to_string()
{
- to_tu_string(); // init our string data.
+ to_string(); // init our string data.
m_type = STRING; // force type.
}
@@ -563,7 +546,7 @@
as_value::convert_to_string_versioned(int version, as_environment* env)
// Force type to string.
{
- to_tu_string_versioned(version, env); // init our string data.
+ to_string_versioned(version, env); // init our string data.
m_type = STRING; // force type.
}
@@ -633,7 +616,7 @@
}
else if (m_type == STRING)
{
- return m_string_value == v.to_tu_string();
+ return m_string_value == v.to_string();
}
else if (m_type == NUMBER)
{
@@ -677,7 +660,7 @@
}
else if (m_type == STRING)
{
- return m_string_value == v.to_tu_string(env);
+ return m_string_value == v.to_string(env);
}
else if (m_type == NUMBER)
{
@@ -718,9 +701,9 @@
// Sets *this to this string plus the given string.
void
-as_value::string_concat(const tu_string& str)
+as_value::string_concat(const std::string& str)
{
- to_tu_string(); // make sure our m_string_value is initialized
+ to_string(); // make sure our m_string_value is initialized
m_type = STRING;
m_string_value += str;
}
@@ -785,7 +768,6 @@
std::string
as_value::to_debug_string() const
{
- std::string ret;
char buf[512];
switch (m_type)
@@ -804,14 +786,15 @@
sprintf(buf, "[function:%p]", m_object_value);
return buf;
case STRING:
- ret = "[string:" + std::string(m_string_value.c_str())
+ std::string("]");
- return ret;
+ return "[string:" + m_string_value + "]";
case NUMBER:
- sprintf(buf, "[number:%g]", m_number_value);
- return buf;
+ {
+ std::stringstream stream;
+ stream << m_number_value;
+ return "[number:" + stream.str() + "]";
+ }
case MOVIECLIP:
- sprintf(buf, "[movieclip:%s]", m_string_value.c_str());
- return buf;
+ return "[movieclip:" + m_string_value + "]";
default:
assert(0);
}
@@ -823,7 +806,7 @@
if (v.m_type == UNDEFINED) set_undefined();
else if (v.m_type == NULLTYPE) set_null();
else if (v.m_type == BOOLEAN) set_bool(v.m_boolean_value);
- else if (v.m_type == STRING) set_tu_string(v.m_string_value);
+ else if (v.m_type == STRING) set_string(v.m_string_value);
else if (v.m_type == NUMBER) set_double(v.m_number_value);
else if (v.m_type == OBJECT) set_as_object(v.m_object_value);
Index: server/as_value.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- server/as_value.h 11 Apr 2007 17:54:21 -0000 1.42
+++ server/as_value.h 15 Apr 2007 10:52:09 -0000 1.43
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: as_value.h,v 1.42 2007/04/11 17:54:21 bjacques Exp $ */
+/* $Id: as_value.h,v 1.43 2007/04/15 10:52:09 bjacques Exp $ */
#ifndef GNASH_AS_VALUE_H
#define GNASH_AS_VALUE_H
@@ -141,42 +141,6 @@
{
}
- /// Construct a STRING value
- as_value(const wchar_t* wstr)
- :
- m_type(STRING),
- m_string_value(""),
- m_number_value(0.0)
- {
- // Encode the string value as UTF-8.
- //
- // Is this dumb? Alternatives:
- //
- // 1. store a tu_wstring instead of tu_string?
- // Bloats typical ASCII strings, needs a
- // tu_wstring type, and conversion back the
- // other way to interface with char[].
- //
- // 2. store a tu_wstring as a union with
- // tu_string? Extra complexity.
- //
- // 3. ??
- //
- // Storing UTF-8 seems like a pretty decent
- // way to do it. Everything else just
- // continues to work.
-
-#if (WCHAR_MAX != MAXINT)
- tu_string::encode_utf8_from_wchar(&m_string_value, (const
uint16_t *)wstr);
-#else
-# if (WCHAR_MAX != MAXSHORT)
-# error "Can't determine the size of wchar_t"
-# else
- tu_string::encode_utf8_from_wchar(&m_string_value, (const
uint32_t *)wstr);
-# endif
-#endif
- }
-
/// Construct a BOOLEAN value
as_value(bool val)
:
@@ -311,28 +275,13 @@
return m_type == OBJECT || m_type == AS_FUNCTION || m_type ==
MOVIECLIP;
}
- /// Get a C string representation of this value.
- //
- /// @param env
- /// The environment to use for running the toString() method
- /// for object values. If NULL, toString() won't be run.
- ///
- const char* to_string(as_environment* env=NULL) const;
-
- /// Get a tu_string representation for this value.
- //
- /// @param env
- /// The environment to use for running the toString() method
- /// for object values. If NULL, toString() won't be run.
- ///
- const tu_string& to_tu_string(as_environment* env=NULL) const;
-
/// Get a std::string representation for this value.
//
/// @param env
/// The environment to use for running the toString() method
/// for object values. If NULL, toString() won't be run.
///
+ const std::string& to_string(as_environment* env=NULL) const;
std::string to_std_string(as_environment* env=NULL) const;
std::string to_debug_string() const;
@@ -348,9 +297,9 @@
///
std::string to_std_string_versioned(int version, as_environment*
env=NULL) const;
- /// Get a tu_string representation for this value.
+ /// Get a string representation for this value.
//
- /// This differs from to_tu_string() in that returned
+ /// This differs from to_string() in that returned
/// representation will depend on version of the SWF
/// source.
/// @@ shouldn't this be the default ?
@@ -359,15 +308,7 @@
/// The environment to use for running the toString() method
/// for object values. If NULL, toString() won't be run.
///
- const tu_string& to_tu_string_versioned(int version,
as_environment* env=NULL) const;
-
- /// Calls to_tu_string() returning a cast to tu_stringi
- //
- /// @param env
- /// The environment to use for running the toString() method
- /// for object values. If NULL, toString() won't be run.
- ///
- const tu_stringi& to_tu_stringi(as_environment* env=NULL) const;
+ const std::string& to_string_versioned(int version,
as_environment* env=NULL) const;
/// Conversion to number
//
@@ -472,7 +413,7 @@
/// The environment to use for running the toString() method
/// for object values. If NULL, toString() won't be run.
///
- /// @see to_tu_string_versionioned
+ /// @see to_string_versionioned
///
void convert_to_string_versioned(int version, as_environment*
env=NULL);
@@ -480,7 +421,7 @@
// in preference to generic overloaded set(). You are
// more likely to get a warning/error if misused.
- void set_tu_string(const tu_string& str) {
+ void set_string(const std::string& str) {
drop_refs();
m_type = STRING;
m_string_value = str;
@@ -582,9 +523,7 @@
// void lsr(const as_value& v) { set_int((uint32_t(to_number()) >>
int(v.to_number()))); }
/// Sets this value to this string plus the given string.
- void string_concat(const tu_string& str);
-
- //tu_string* get_mutable_tu_string() { assert(m_type == STRING); return
&m_string_value; }
+ void string_concat(const std::string& str);
private:
@@ -598,8 +537,7 @@
type m_type;
- // TODO: switch to std::string
- mutable tu_string m_string_value;
+ mutable std::string m_string_value;
union
{
Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- server/edit_text_character.cpp 12 Apr 2007 11:35:30 -0000 1.52
+++ server/edit_text_character.cpp 15 Apr 2007 10:52:09 -0000 1.53
@@ -15,7 +15,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: edit_text_character.cpp,v 1.52 2007/04/12 11:35:30 strk Exp $ */
+/* $Id: edit_text_character.cpp,v 1.53 2007/04/15 10:52:09 bjacques Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -666,7 +666,7 @@
//if (name == "text")
{
int version =
get_parent()->get_movie_definition()->get_version();
- set_text_value(val.to_tu_string_versioned(version).c_str());
+ set_text_value(val.to_string_versioned(version).c_str());
return;
}
case M_X:
@@ -1276,7 +1276,7 @@
#ifdef DEBUG_DYNTEXT_VARIABLES
log_msg("target sprite (%p) does have a member named %s",
(void*)sprite, varname);
#endif
- set_text_value(val.to_string());
+ set_text_value(val.to_string().c_str());
}
#ifdef DEBUG_DYNTEXT_VARIABLES
else
Index: server/gnash.h
===================================================================
RCS file: /sources/gnash/gnash/server/gnash.h,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -b -r1.92 -r1.93
--- server/gnash.h 13 Apr 2007 09:15:54 -0000 1.92
+++ server/gnash.h 15 Apr 2007 10:52:09 -0000 1.93
@@ -17,7 +17,7 @@
//
//
-/* $Id: gnash.h,v 1.92 2007/04/13 09:15:54 bjacques Exp $ */
+/* $Id: gnash.h,v 1.93 2007/04/15 10:52:09 bjacques Exp $ */
/// \mainpage
///
@@ -61,8 +61,6 @@
// forward decl
namespace jpeg { class input; }
-class tu_string;
-class tu_stringi;
namespace gnash {
// Forward declarations.
Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.240
retrieving revision 1.241
diff -u -b -r1.240 -r1.241
--- server/sprite_instance.cpp 14 Apr 2007 16:27:22 -0000 1.240
+++ server/sprite_instance.cpp 15 Apr 2007 10:52:09 -0000 1.241
@@ -206,7 +206,7 @@
IF_VERBOSE_MALFORMED_SWF(
log_aserror("Fourth argument of attachMovie "
"doesn't cast to an object (%s)",
- fn.arg(3).to_string());
+ fn.arg(3).to_string().c_str());
);
}
}
@@ -258,7 +258,7 @@
}
}
- character* ch = sprite->add_empty_movieclip(fn.arg(0).to_string(),
int(fn.arg(1).to_number()));
+ character* ch =
sprite->add_empty_movieclip(fn.arg(0).to_string().c_str(),
int(fn.arg(1).to_number()));
return as_value(ch);
}
@@ -628,7 +628,7 @@
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror("Can't find hitTest target %s",
- tgt_val.to_string());
+ tgt_val.to_string().c_str());
);
return as_value();
}
@@ -1126,7 +1126,7 @@
}
else // setter
{
- ptr->set_name(fn.arg(0).to_string(&fn.env()));
+ ptr->set_name(fn.arg(0).to_string(&fn.env()).c_str());
//IF_VERBOSE_ASCODING_ERRORS(
//log_aserror("Attempt to set read-only property '_name'");
//);
@@ -1902,13 +1902,11 @@
}
}
-void sprite_instance::remove_display_object(const tu_string& name_tu)
+void sprite_instance::remove_display_object(const std::string& name)
{
// GNASH_REPORT_FUNCTION;
- std::string name(name_tu.c_str());
-
- character* ch = m_display_list.get_character_by_name(name);
+ character* ch = m_display_list.get_character_by_name(name.c_str());
if (ch)
{
// @@ TODO: should only remove movies that were created via
clone_display_object --
@@ -1995,7 +1993,7 @@
const as_value& val)
{
#ifdef DEBUG_DYNTEXT_VARIABLES
- log_msg("sprite[%p]::set_member(%s, %s)", (void*)this, name.c_str(),
val.to_string());
+log_msg("sprite[%p]::set_member(%s, %s)", (void*)this, name.c_str(),
val.to_string().c_str());
#endif
if ( val.is_function() )
@@ -2018,7 +2016,7 @@
#ifdef DEBUG_DYNTEXT_VARIABLES
log_msg(" it's a Text Variable!");
#endif
- etc->set_text_value(val.to_string());
+ etc->set_text_value(val.to_string().c_str());
}
#ifdef DEBUG_DYNTEXT_VARIABLES
else
@@ -2046,7 +2044,7 @@
val = m_as_environment.get_variable(path);
- return val.to_string(); // ack!
+ return val.to_string().c_str(); // ack!
}
void sprite_instance::set_variable(const char* path_to_var,
Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -b -r1.96 -r1.97
--- server/sprite_instance.h 12 Apr 2007 11:35:30 -0000 1.96
+++ server/sprite_instance.h 15 Apr 2007 10:52:09 -0000 1.97
@@ -17,7 +17,7 @@
//
//
-/* $Id: sprite_instance.h,v 1.96 2007/04/12 11:35:30 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.97 2007/04/15 10:52:09 bjacques Exp $ */
// Stateful live Sprite instance
@@ -551,7 +551,7 @@
//
/// @@ what happens if the we have multiple objects
/// with the same name ?
- void remove_display_object(const tu_string& name);
+ void remove_display_object(const std::string& name);
/// Dispatch event handler(s), if any.
virtual bool on_event(const event_id& id);
Index: server/textformat.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/textformat.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- server/textformat.cpp 11 Apr 2007 17:54:21 -0000 1.24
+++ server/textformat.cpp 15 Apr 2007 10:52:09 -0000 1.25
@@ -15,7 +15,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-// $Id: textformat.cpp,v 1.24 2007/04/11 17:54:21 bjacques Exp $
+// $Id: textformat.cpp,v 1.25 2007/04/15 10:52:09 bjacques Exp $
//
#include "log.h"
@@ -195,7 +195,7 @@
if (obj->get_member("align", &method)) {
//log_msg("Align exists and is set to %s\n", method.to_string());
- const char* align = method.to_string();
+ const char* align = method.to_string().c_str();
if ( align ) obj->obj.alignSet(align);
}
Index: server/asobj/Global.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Global.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- server/asobj/Global.cpp 30 Mar 2007 14:51:38 -0000 1.57
+++ server/asobj/Global.cpp 15 Apr 2007 10:52:09 -0000 1.58
@@ -18,7 +18,7 @@
// Implementation of the Global ActionScript Object
-/* $Id: Global.cpp,v 1.57 2007/03/30 14:51:38 strk Exp $ */
+/* $Id: Global.cpp,v 1.58 2007/04/15 10:52:09 bjacques Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -104,7 +104,7 @@
//
// @@ Nothing needs special treatment,
// as_value::to_string() will take care of everything
- const char* arg0 = fn.arg(0).to_string();
+ const char* arg0 = fn.arg(0).to_string().c_str();
log_trace("%s", arg0);
return as_value();
}
@@ -175,7 +175,7 @@
as_value rv;
// sscanf will handle the whitespace / unneeded characters etc.
automatically
- if (1 == sscanf(fn.arg(0).to_string(), "%f", &result))
+ if (1 == sscanf(fn.arg(0).to_string().c_str(), "%f", &result))
rv = double(result);
else
// if sscanf didn't find anything, return NaN
@@ -206,9 +206,9 @@
// Set up some variables
const string digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- char *input_buffer = new char[strlen(fn.arg(0).to_string())+1];
+ char *input_buffer = new char[fn.arg(0).to_string().size()+1];
char *input = input_buffer;
- strcpy(input,fn.arg(0).to_string());
+ strcpy(input,fn.arg(0).to_string().c_str());
int base;
bool bNegative;
@@ -328,7 +328,7 @@
{
log_warning("Invalid call to ASSetPropFlags: "
"object argument is not an object: %s",
- fn.arg(0).to_string());
+ fn.arg(0).to_string().c_str());
return as_value();
}
Index: server/asobj/LocalConnection.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/LocalConnection.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- server/asobj/LocalConnection.cpp 22 Mar 2007 22:37:45 -0000 1.12
+++ server/asobj/LocalConnection.cpp 15 Apr 2007 10:52:09 -0000 1.13
@@ -139,7 +139,7 @@
boost::intrusive_ptr<localconnection_as_object> ptr =
ensureType<localconnection_as_object>(fn.this_ptr);
if (fn.nargs != 0) {
- ret = ptr->obj.connect(fn.arg(0).to_string());
+ ret = ptr->obj.connect(fn.arg(0).to_string().c_str());
} else {
log_msg("ERROR: No connection name specified to
LocalConnection.connect()!\n");
ret = ptr->obj.connect("localhost"); // FIXME: This should probably
Index: server/asobj/MovieClipLoader.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/MovieClipLoader.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- server/asobj/MovieClipLoader.cpp 22 Mar 2007 22:37:45 -0000 1.23
+++ server/asobj/MovieClipLoader.cpp 15 Apr 2007 10:52:09 -0000 1.24
@@ -142,7 +142,7 @@
Listeners _listeners;
bool _started;
bool _completed;
- tu_string _filespec;
+ std::string _filespec;
int _progress;
bool _error;
struct mcl _mcl;
@@ -318,7 +318,7 @@
character* target = fn.env().find_target(fn.arg(1));
if ( ! target )
{
- log_error("Could not find target %s", fn.arg(1).to_string());
+ log_error("Could not find target %s",
fn.arg(1).to_string().c_str());
return as_value(false);
}
sprite_instance* sprite = dynamic_cast<sprite_instance*>(target);
Index: server/asobj/NetConnection.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetConnection.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- server/asobj/NetConnection.cpp 7 Apr 2007 11:55:50 -0000 1.36
+++ server/asobj/NetConnection.cpp 15 Apr 2007 10:52:09 -0000 1.37
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: NetConnection.cpp,v 1.36 2007/04/07 11:55:50 tgc Exp $ */
+/* $Id: NetConnection.cpp,v 1.37 2007/04/15 10:52:09 bjacques Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -212,7 +212,7 @@
boost::intrusive_ptr<NetConnection> ptr =
ensureType<NetConnection>(fn.this_ptr);
if (fn.nargs > 0) {
- ptr->addToURL(fn.arg(0).to_string());
+ ptr->addToURL(fn.arg(0).to_string().c_str());
}
return as_value();
}
Index: server/asobj/NetStream.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStream.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- server/asobj/NetStream.cpp 14 Apr 2007 15:53:17 -0000 1.35
+++ server/asobj/NetStream.cpp 15 Apr 2007 10:52:09 -0000 1.36
@@ -15,7 +15,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: NetStream.cpp,v 1.35 2007/04/14 15:53:17 bjacques Exp $ */
+/* $Id: NetStream.cpp,v 1.36 2007/04/15 10:52:09 bjacques Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -83,7 +83,7 @@
log_aserror("First argument "
"to NetStream constructor "
"doesn't cast to a NetConnection (%s)",
- fn.arg(0).to_string());
+ fn.arg(0).to_string().c_str());
);
}
}
@@ -124,7 +124,7 @@
return as_value();
}
- if (ns->play(fn.arg(0).to_string()) != 0)
+ if (ns->play(fn.arg(0).to_string().c_str()) != 0)
{
ns->close();
};
Index: server/asobj/Object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Object.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- server/asobj/Object.cpp 22 Mar 2007 22:37:46 -0000 1.21
+++ server/asobj/Object.cpp 15 Apr 2007 10:52:09 -0000 1.22
@@ -18,7 +18,7 @@
//
//
-/* $Id: Object.cpp,v 1.21 2007/03/22 22:37:46 bjacques Exp $ */
+/* $Id: Object.cpp,v 1.22 2007/04/15 10:52:09 bjacques Exp $ */
// Implementation of ActionScript Object class.
@@ -323,7 +323,7 @@
if ( arg.is_undefined() || propname.empty() )
{
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror("Invalid call to Object.hasOwnProperty('%s')",
arg.to_string());
+ log_aserror("Invalid call to Object.hasOwnProperty('%s')",
arg.to_string().c_str());
);
return as_value();
}
@@ -346,7 +346,7 @@
if ( arg.is_undefined() || propname.empty() )
{
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror("Invalid call to
Object.isPropertyEnumerable('%s')", arg.to_string());
+ log_aserror("Invalid call to
Object.isPropertyEnumerable('%s')", arg.to_string().c_str());
);
return as_value();
}
Index: server/asobj/Sound.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Sound.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- server/asobj/Sound.cpp 14 Apr 2007 15:53:17 -0000 1.12
+++ server/asobj/Sound.cpp 15 Apr 2007 10:52:09 -0000 1.13
@@ -281,7 +281,7 @@
int si = -1;
if (fn.nargs > 0) {
- const char* name = fn.arg(0).to_string();
+ const char* name = fn.arg(0).to_string().c_str();
// check the import.
movie_definition* def =
fn.env().get_target()->get_root_movie()->get_movie_definition();
@@ -327,7 +327,7 @@
boost::intrusive_ptr<Sound> so = ensureType<Sound>(fn.this_ptr);
- const char* name = fn.arg(0).to_string();
+ const char* name = fn.arg(0).to_string().c_str();
if (!name) {
IF_VERBOSE_ASCODING_ERRORS(
log_aserror("attachSound need a non-null argument");
Index: server/asobj/xml.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xml.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- server/asobj/xml.cpp 7 Apr 2007 15:27:16 -0000 1.36
+++ server/asobj/xml.cpp 15 Apr 2007 10:52:09 -0000 1.37
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: xml.cpp,v 1.36 2007/04/07 15:27:16 strk Exp $ */
+/* $Id: xml.cpp,v 1.37 2007/04/15 10:52:09 bjacques Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -610,7 +610,7 @@
// GNASH_REPORT_FUNCTION;
if (fn.nargs > 0) {
- const char *text = fn.arg(0).to_string();
+ const char *text = fn.arg(0).to_string().c_str();
XMLNode *xml_obj = new XMLNode();
// cerr << "create new child XMLNode is at " << (void *)xml_obj << endl;
xml_obj->nodeNameSet(text);
@@ -643,7 +643,7 @@
const char *text;
if (fn.nargs > 0) {
- text = fn.arg(0).to_string();
+ text = fn.arg(0).to_string().c_str();
xml_obj = new XMLNode;
xml_obj->nodeValueSet(text);
xml_obj->nodeTypeSet(XMLNode::tText);
Index: server/asobj/xmlnode.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlnode.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- server/asobj/xmlnode.cpp 14 Apr 2007 15:53:17 -0000 1.29
+++ server/asobj/xmlnode.cpp 15 Apr 2007 10:52:09 -0000 1.30
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: xmlnode.cpp,v 1.29 2007/04/14 15:53:17 bjacques Exp $ */
+/* $Id: xmlnode.cpp,v 1.30 2007/04/15 10:52:09 bjacques Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -596,7 +596,7 @@
}
else
{
- ptr->nodeNameSet(fn.arg(0).to_string());
+ ptr->nodeNameSet(fn.arg(0).to_string().c_str());
}
return rv;
}
Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -b -r1.88 -r1.89
--- server/vm/ASHandlers.cpp 14 Apr 2007 17:33:16 -0000 1.88
+++ server/vm/ASHandlers.cpp 15 Apr 2007 10:52:09 -0000 1.89
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: ASHandlers.cpp,v 1.88 2007/04/14 17:33:16 strk Exp $ */
+/* $Id: ASHandlers.cpp,v 1.89 2007/04/15 10:52:09 bjacques Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -826,7 +826,7 @@
// GNASH_REPORT_FUNCTION;
as_environment& env = thread.env;
thread.ensureStack(2);
- env.top(1).set_bool(env.top(1).to_tu_string() ==
env.top(0).to_tu_string());
+ env.top(1).set_bool(env.top(1).to_string() == env.top(0).to_string());
env.drop(1);
}
@@ -837,7 +837,7 @@
as_environment& env = thread.env;
thread.ensureStack(1);
int version = env.get_version();
-
env.top(0).set_int(env.top(0).to_tu_string_versioned(version).utf8_length());
+ env.top(0).set_int(env.top(0).to_string_versioned(version).size());
}
void
@@ -865,7 +865,7 @@
int base = int(base_val.to_number(&env));
int version = env.get_version();
- const tu_string& str = string_val.to_tu_string_versioned(version);
+ const std::string& str = string_val.to_string_versioned(version);
if ( size < 0 )
{
@@ -923,11 +923,11 @@
//size = imin(str.length() - base, size);
// TODO: unsafe: use string::substr instead !
- tu_string new_string = str.c_str() + base;
+ std::string new_string = str.c_str() + base; // XXX
new_string.resize(size);
env.drop(2);
- env.top(0).set_tu_string(new_string);
+ env.top(0).set_string(new_string);
}
void
@@ -958,7 +958,7 @@
thread.ensureStack(1); // variable name
as_value& top_value = env.top(0);
- const char* ptr = top_value.to_string();
+ const char* ptr = top_value.to_string().c_str();
if ( ! ptr )
{
top_value.set_undefined();
@@ -979,7 +979,7 @@
} else {
log_action("-- get var: %s=%s at %p",
var_string.c_str(),
- top_value.to_tu_string().c_str(),
+ top_value.to_string().c_str(),
(void*)obj.get());
}
);
@@ -998,7 +998,7 @@
// stack must be contain at least two items
thread.ensureStack(2);
- assert(env.top(1).to_string());
+ assert(env.top(1).to_string().c_str());
string name = env.top(1).to_std_string();
thread.setVariable(name, env.top(0));
@@ -1027,7 +1027,7 @@
//Vitaly: env.drop(1) remove object on which refers const char *
target_name
//strk: shouldn't we use env.pop() instead ? No (see above comment)
//const char * target_name = env.top(0).to_string();
- assert(env.top(0).to_string());
+ assert(env.top(0).to_string().c_str());
string target_name = env.top(0).to_string();
env.drop(1); // pop the target name off the stack
@@ -1044,7 +1044,7 @@
int version = env.get_version();
env.top(1).convert_to_string_versioned(version);
- env.top(1).string_concat(env.top(0).to_tu_string_versioned(version));
+ env.top(1).string_concat(env.top(0).to_string_versioned(version));
env.drop(1);
}
@@ -1305,7 +1305,7 @@
// GNASH_REPORT_FUNCTION;
as_environment& env = thread.env;
thread.ensureStack(2);
- env.top(1).set_bool(env.top(1).to_tu_string() < env.top(0).to_tu_string());
+ env.top(1).set_bool(env.top(1).to_string() < env.top(0).to_string());
}
void
@@ -1772,7 +1772,7 @@
const char* target_string = NULL;
if ( ! target.is_undefined() && ! target.is_null() )
{
- target_string = target.to_string(&env);
+ target_string = target.to_string(&env).c_str();
}
// If the url starts with "FSCommand:", then this is
@@ -1942,7 +1942,7 @@
}
else
{
- const char* url = url_val.to_string();
+ const char* url = url_val.to_string().c_str();
CommonGetUrl(env, env.top(0), url, method);
}
@@ -2109,7 +2109,7 @@
thread.setLocalVariable(varname.to_std_string(), value);
IF_VERBOSE_ACTION (
- log_action("-- set local var: %s = %s", varname.to_string(),
value.to_debug_string().c_str());
+ log_action("-- set local var: %s = %s", varname.to_string().c_str(),
value.to_debug_string().c_str());
);
}
@@ -2129,7 +2129,7 @@
as_value function = thread.getVariable(env.top(0).to_std_string(&env));
if ( ! function.is_object() )
{
- log_aserror("ActionCallFunction: %s is not an object",
env.top(0).to_string());
+ log_aserror("ActionCallFunction: %s is not an object",
env.top(0).to_string().c_str());
}
else if ( ! function.is_function() )
{
@@ -2473,7 +2473,7 @@
int version = env.get_version();
// modify env.top(1)
v2.convert_to_string_versioned(version, &env);
- v2.string_concat(v1.to_tu_string_versioned(version, &env));
+ v2.string_concat(v1.to_string_versioned(version, &env));
}
else
{
@@ -2606,8 +2606,8 @@
// Special case: String has a member "length"
// @@ FIXME: we shouldn't have all this "special" cases --strk;
- if (target.is_string() && member_name.to_tu_stringi() == "length") {
- int len = target.to_tu_string_versioned(version).utf8_length();
+ if (target.is_string() && member_name.to_string_versioned(version) ==
"length") {
+ int len = target.to_string_versioned(version).size();
env.top(1).set_int(len);
} else {
if ( ! thread.getObjectMember(*obj, member_name.to_std_string(),
env.top(1)) )
@@ -3124,7 +3124,7 @@
// GNASH_REPORT_FUNCTION;
as_environment& env = thread.env;
thread.ensureStack(2);
- env.top(1).set_bool(env.top(1).to_tu_string() > env.top(0).to_tu_string());
+ env.top(1).set_bool(env.top(1).to_string() > env.top(0).to_string());
env.drop(1);
}
Index: server/vm/action.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/action.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/vm/action.cpp 13 Apr 2007 07:35:56 -0000 1.13
+++ server/vm/action.cpp 15 Apr 2007 10:52:09 -0000 1.14
@@ -436,8 +436,8 @@
env->drop(nargs);
// Return pointer to static string for return value.
- static tu_string s_retval;
- s_retval = result.to_tu_string();
+ static std::string s_retval;
+ s_retval = result.to_string();
return s_retval.c_str();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog libbase/container.cpp libbase/c...,
Bastiaan Jacques <=