[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r9631: Some cleanups.
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r9631: Some cleanups. |
Date: |
Fri, 22 Aug 2008 15:02:43 +0200 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9631
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2008-08-22 15:02:43 +0200
message:
Some cleanups.
modified:
libcore/as_environment.cpp
libcore/as_object.h
libcore/as_value.cpp
libcore/asobj/xml.cpp
libcore/asobj/xml.h
libcore/asobj/xmlnode.h
------------------------------------------------------------
revno: 9629.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Thu 2008-08-21 14:05:09 +0200
message:
Don't use C methods on strings.
modified:
libcore/as_environment.cpp
------------------------------------------------------------
revno: 9629.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Thu 2008-08-21 16:30:29 +0200
message:
Various bits of tidying up, replacement of C code.
modified:
libcore/as_object.h
libcore/as_value.cpp
libcore/asobj/xml.cpp
libcore/asobj/xml.h
libcore/asobj/xmlnode.h
=== modified file 'libcore/as_environment.cpp'
--- a/libcore/as_environment.cpp 2008-07-19 08:16:30 +0000
+++ b/libcore/as_environment.cpp 2008-08-21 12:05:09 +0000
@@ -117,23 +117,7 @@
static bool validRawVariableName(const std::string& varname)
{
- // check raw variable name validity
- const char* ptr = varname.c_str();
- for (;;)
- {
- ptr = strchr(ptr, ':');
- if ( ! ptr ) break;
-
- int num=1;
- while (*(++ptr) == ':') ++num;
- if (num>2)
- {
- //log_debug("Invalid raw variable name...");
- return false;
- }
- }
-
- return true;
+ return (varname.find(":::") == std::string::npos);
}
as_value
=== modified file 'libcore/as_object.h'
--- a/libcore/as_object.h 2008-06-19 10:49:15 +0000
+++ b/libcore/as_object.h 2008-08-21 14:30:29 +0000
@@ -34,13 +34,10 @@
#include "GnashException.h"
#include "event_id.h" // for event_id
-#if defined(__GNUC__) && __GNUC__ > 2
-# include <cxxabi.h>
-#endif
-
#include <cmath>
#include <utility> // for std::pair
#include <set>
+#include <sstream>
// Forward declarations
namespace gnash {
@@ -222,10 +219,12 @@
/// The default implementation converts the text value
/// to a number, override for a more performant implementation
///
- virtual double get_numeric_value() const {
- std::string txt = get_text_value();
- if ( ! txt.empty() ) return atof(txt.c_str());
- else return 0;
+ virtual double get_numeric_value() const
+ {
+ double d = 0;
+ std::istringstream is(get_text_value());
+ is >> d;
+ return d;
}
/// Return the "primitive" value of this object
=== modified file 'libcore/as_value.cpp'
--- a/libcore/as_value.cpp 2008-08-18 23:53:04 +0000
+++ b/libcore/as_value.cpp 2008-08-21 14:30:29 +0000
@@ -319,15 +319,6 @@
// and many swfdec tests, with no new failures (though
// perhaps we aren't testing enough).
return as_value();
-
-// if ( (!obj->get_member(NSV::PROP_TO_STRING, &method))
|| (!method.is_object()) ) // ECMA says ! is_object()
-// {
-//#if GNASH_DEBUG_CONVERSION_TO_PRIMITIVE
-// log_debug(" toString not found");
-//#endif
-//
-// throw ActionTypeError();
-// }
}
}
else
@@ -525,9 +516,7 @@
{
// For SWF4, any valid number before non-numerical
// characters is returned, including exponent, positive
- // and negative signs and whitespace before. A stringstream
- // does the job. Locale differences (decimal separator) arise
- // with strtod.
+ // and negative signs and whitespace before.
double d = 0;
std::istringstream is (getStr());
is >> d;
@@ -634,11 +623,11 @@
if (d < 0)
{
- i = - static_cast<boost::uint32_t>(std::fmod (-d, 4294967296.0));
+ i = - static_cast<boost::uint32_t>(std::fmod(-d, 4294967296.0));
}
else
{
- i = static_cast<boost::uint32_t>(std::fmod (d, 4294967296.0));
+ i = static_cast<boost::uint32_t>(std::fmod(d, 4294967296.0));
}
return i;
@@ -817,11 +806,11 @@
as_value::to_as_function() const
{
if (m_type == AS_FUNCTION) {
- // OK.
- return getFun().get();
- } else {
- return NULL;
+ // OK.
+ return getFun().get();
}
+
+ return NULL;
}
// Force type to number.
@@ -1168,7 +1157,9 @@
default:
if (is_exception())
+ {
return "exception";
+ }
abort();
return NULL;
}
@@ -1215,7 +1206,9 @@
}
default:
if (is_exception())
+ {
return false; // Exceptions equal nothing.
+ }
}
abort();
@@ -1291,9 +1284,10 @@
}
default:
if (is_exception())
+ {
return "[exception]";
+ }
abort();
- return "[invalid type]";
}
}
@@ -1419,11 +1413,11 @@
if ( radix == 10 )
{
- // ActionScript always expects dot as decimal point?
- ostr.imbue(std::locale("C"));
+ // ActionScript always expects dot as decimal point.
+ ostr.imbue(std::locale::classic());
// force to decimal notation for this range (because the
reference player does)
- if (fabs(val) < 0.0001 && fabs(val) >= 0.00001)
+ if (std::abs(val) < 0.0001 && std::abs(val) >= 0.00001)
{
// All nineteen digits (4 zeros + up to 15 significant
digits)
ostr << std::fixed << std::setprecision(19) << val;
@@ -1458,14 +1452,13 @@
bool negative = (val < 0);
if ( negative ) val = -val;
- double left = floor(val);
+ double left = std::floor(val);
if ( left < 1 ) return "0";
while ( left != 0 )
{
double n = left;
- left = floor(left/radix);
- n -= (left*radix);
- //str = std::string(n < 10 ? ((int)n+'0') :
((int)n+('a'-10))) + str;
+ left = std::floor(left / radix);
+ n -= (left * radix);
str.insert(0, 1, (n < 10 ? ((int)n+'0') :
((int)n+('a'-10))));
}
if ( negative ) str.insert(0, 1, '-');
@@ -1739,7 +1732,7 @@
}
else
{
- ret.set_bool(op1<op2);
+ ret.set_bool(op1 < op2);
}
}
return ret;
=== modified file 'libcore/asobj/xml.cpp'
--- a/libcore/asobj/xml.cpp 2008-07-31 19:23:06 +0000
+++ b/libcore/asobj/xml.cpp 2008-08-21 14:30:29 +0000
@@ -45,9 +45,6 @@
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xmlreader.h>
-//#include <unistd.h>
-//#include <sys/types.h>
-//#include <sys/stat.h>
#include <string>
#include <sstream>
#include <vector>
@@ -354,15 +351,13 @@
return true;
}
-// This reads in an XML file from disk and parses into into a memory resident
+// This parses an XML string into a
// tree which can be walked through later.
bool
XML::parseXML(const std::string& xml_in)
{
//GNASH_REPORT_FUNCTION;
- //log_debug(_("Parse XML from memory: %s"), xml_in);
-
if (xml_in.empty()) {
log_error(_("XML data is empty"));
return false;
@@ -439,11 +434,13 @@
if ( startTimer )
{
- boost::intrusive_ptr<builtin_function> loadsChecker = \
+ boost::intrusive_ptr<builtin_function> loadsChecker =
new builtin_function(&XML::checkLoads_wrapper);
+
std::auto_ptr<Timer> timer(new Timer);
timer->setInterval(*loadsChecker, 50, this);
_loadCheckerTimer = getVM().getRoot().add_interval_timer(timer, true);
+
#ifdef DEBUG_XML_LOADS
log_debug("Registered XML loads interval %d", _loadCheckerTimer);
#endif
@@ -1009,23 +1006,6 @@
}
-#if 0 // not time for this (yet)
-static
-void _xmlErrorHandler(void* ctx, const char* fmt, ...)
-{
- va_list ap;
- static const unsigned long BUFFER_SIZE = 128;
- char tmp[BUFFER_SIZE];
-
- va_start (ap, fmt);
- vsnprintf (tmp, BUFFER_SIZE, fmt, ap);
- tmp[BUFFER_SIZE-1] = '\0';
-
- log_error(_("XML parser: %s"), tmp);
-
- va_end (ap);
-}
-#endif // disabled
void
XML::initParser()
=== modified file 'libcore/asobj/xml.h'
--- a/libcore/asobj/xml.h 2008-06-09 13:31:51 +0000
+++ b/libcore/asobj/xml.h 2008-08-21 14:30:29 +0000
@@ -15,8 +15,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#ifndef __XML_H__
-#define __XML_H__
+#ifndef GNASH_ASOBJ_XML_H
+#define GNASH_ASOBJ_XML_H
#include "action.h"
#include "LoadThread.h"
@@ -41,7 +41,7 @@
class LoaderThread;
/// XML class and ActionScript object
-class DSOLOCAL XML : public XMLNode
+class XML : public XMLNode
{
public:
=== modified file 'libcore/asobj/xmlnode.h'
--- a/libcore/asobj/xmlnode.h 2008-04-21 10:27:41 +0000
+++ b/libcore/asobj/xmlnode.h 2008-08-21 14:30:29 +0000
@@ -15,8 +15,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#ifndef __XML_NODE_H__
-#define __XML_NODE_H__
+#ifndef GNASH_ASOBJ_XML_NODE_H
+#define GNASH_ASOBJ_XML_NODE_H
//#define DEBUG_MEMORY_ALLOCATION 1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r9631: Some cleanups.,
Benjamin Wolsey <=