gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/avm2 r9702: Merge from trunk. Use log leve


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/avm2 r9702: Merge from trunk. Use log level of 3 for log_abc. Fix an AVM2 crash and
Date: Wed, 01 Apr 2009 17:25:07 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9702
committer: Benjamin Wolsey <address@hidden>
branch nick: avm2
timestamp: Wed 2009-04-01 17:25:07 +0200
message:
  Merge from trunk. Use log level of 3 for log_abc. Fix an AVM2 crash and
  log error.
modified:
  gui/gnash.cpp
  libbase/log.cpp
  libbase/log.h
  libcore/MovieClip.cpp
  libcore/Timers.cpp
  libcore/Timers.h
  libcore/as_environment.h
  libcore/as_function.cpp
  libcore/as_function.h
  libcore/as_object.cpp
  libcore/as_value.cpp
  libcore/asobj/Array_as.cpp
  libcore/asobj/Array_as.h
  libcore/asobj/NetStream_as.cpp
  libcore/asobj/NetStream_as.h
  libcore/asobj/TextSnapshot_as.cpp
  libcore/asobj/XMLNode_as.cpp
  libcore/asobj/XMLNode_as.h
  libcore/asobj/flash/display/BitmapData_as.cpp
  libcore/asobj/flash/geom/Rectangle_as.cpp
  libcore/parser/abc_block.cpp
  libcore/swf_function.cpp
  libcore/vm/ASHandlers.cpp
  libcore/vm/Machine.cpp
  libcore/vm/action.cpp
  libcore/vm/action.h
  libcore/vm/fn_call.h
  macros/pthreads.m4
  utilities/processor.cpp
    ------------------------------------------------------------
    revno: 9701.1.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: avm2-work
    timestamp: Wed 2009-04-01 10:07:28 +0200
    message:
      Log error when top of stack is not an object as expected.
    modified:
      libcore/vm/Machine.cpp
    ------------------------------------------------------------
    revno: 9701.1.2
    committer: Benjamin Wolsey <address@hidden>
    branch nick: avm2-work
    timestamp: Wed 2009-04-01 10:08:07 +0200
    message:
      Indentation.
    modified:
      libcore/parser/abc_block.cpp
    ------------------------------------------------------------
    revno: 9701.1.3
    committer: Benjamin Wolsey <address@hidden>
    branch nick: avm2-work
    timestamp: Wed 2009-04-01 10:52:19 +0200
    message:
      Add a new log level for abc logging (-vvv necessary). Don't enforce buffer
      flushing with endl when logging.
    modified:
      libbase/log.cpp
      libbase/log.h
    ------------------------------------------------------------
    revno: 9701.1.4
    committer: Benjamin Wolsey <address@hidden>
    branch nick: avm2-work
    timestamp: Wed 2009-04-01 16:22:00 +0200
    message:
      Merge from trunk.
    modified:
      gui/gnash.cpp
      libbase/log.cpp
      libbase/log.h
      libcore/MovieClip.cpp
      libcore/Timers.cpp
      libcore/Timers.h
      libcore/as_environment.h
      libcore/as_function.cpp
      libcore/as_function.h
      libcore/as_object.cpp
      libcore/as_value.cpp
      libcore/asobj/Array_as.cpp
      libcore/asobj/Array_as.h
      libcore/asobj/NetStream_as.cpp
      libcore/asobj/NetStream_as.h
      libcore/asobj/TextSnapshot_as.cpp
      libcore/asobj/XMLNode_as.cpp
      libcore/asobj/XMLNode_as.h
      libcore/asobj/flash/display/BitmapData_as.cpp
      libcore/asobj/flash/geom/Rectangle_as.cpp
      libcore/swf_function.cpp
      libcore/vm/ASHandlers.cpp
      libcore/vm/Machine.cpp
      libcore/vm/action.cpp
      libcore/vm/action.h
      libcore/vm/fn_call.h
      macros/pthreads.m4
      utilities/processor.cpp
        ------------------------------------------------------------
        revno: 9439.1.1318
        committer: Benjamin Wolsey <address@hidden>
        branch nick: trunk
        timestamp: Tue 2009-03-31 11:26:54 +0200
        message:
          Fix some missing GC registrations, use std::max's template argument 
because
          it's more concise.
        modified:
          libcore/asobj/NetStream_as.cpp
          libcore/asobj/NetStream_as.h
          libcore/asobj/TextSnapshot_as.cpp
          libcore/asobj/XMLNode_as.cpp
          libcore/asobj/XMLNode_as.h
          libcore/asobj/flash/display/BitmapData_as.cpp
        ------------------------------------------------------------
        revno: 9439.1.1319
        committer: Markus Gothe <address@hidden>
        branch nick: trunk
        timestamp: Tue 2009-03-31 21:26:23 +0200
        message:
          re-added -{K,k}thread
        modified:
          macros/pthreads.m4
        ------------------------------------------------------------
        revno: 9439.1.1320
        committer: Benjamin Wolsey <address@hidden>
        branch nick: trunk
        timestamp: Wed 2009-04-01 16:01:00 +0200
        message:
          Speed up logging, add extra logging levels (for AVM2).
          Const correct and reduce pointer usage.
        modified:
          gui/gnash.cpp
          libbase/log.cpp
          libbase/log.h
          libcore/MovieClip.cpp
          libcore/Timers.cpp
          libcore/Timers.h
          libcore/as_environment.h
          libcore/as_function.cpp
          libcore/as_function.h
          libcore/as_object.cpp
          libcore/as_value.cpp
          libcore/asobj/Array_as.cpp
          libcore/asobj/Array_as.h
          libcore/asobj/flash/geom/Rectangle_as.cpp
          libcore/swf_function.cpp
          libcore/vm/ASHandlers.cpp
          libcore/vm/action.cpp
          libcore/vm/action.h
          libcore/vm/fn_call.h
          utilities/processor.cpp
            ------------------------------------------------------------
            revno: 9439.300.1
            committer: Benjamin Wolsey <address@hidden>
            branch nick: work
            timestamp: Wed 2009-04-01 07:59:00 +0200
            message:
              Minor cleanups.
            modified:
              libcore/Timers.cpp
              libcore/Timers.h
            ------------------------------------------------------------
            revno: 9439.300.2
            committer: Benjamin Wolsey <address@hidden>
            branch nick: work
            timestamp: Wed 2009-04-01 09:00:32 +0200
            message:
              Const correct some as_environment member functions. Use const 
as_environment
              reference instead of pointer to non-const in various functions.
            modified:
              libcore/MovieClip.cpp
              libcore/Timers.cpp
              libcore/as_environment.h
              libcore/as_function.cpp
              libcore/as_function.h
              libcore/as_object.cpp
              libcore/as_value.cpp
              libcore/asobj/Array_as.cpp
              libcore/asobj/Array_as.h
              libcore/asobj/flash/geom/Rectangle_as.cpp
              libcore/swf_function.cpp
              libcore/vm/ASHandlers.cpp
              libcore/vm/action.cpp
              libcore/vm/action.h
              libcore/vm/fn_call.h
            ------------------------------------------------------------
            revno: 9439.300.3
            committer: Benjamin Wolsey <address@hidden>
            branch nick: work
            timestamp: Wed 2009-04-01 13:29:07 +0200
            message:
              Add some minor changes to logging (more logging levels) for use 
with AVM2.
              Also optimize logging class to improve speed by about 10 percent.
            modified:
              gui/gnash.cpp
              libbase/log.cpp
              libbase/log.h
            ------------------------------------------------------------
            revno: 9439.300.4
            committer: Benjamin Wolsey <address@hidden>
            branch nick: work
            timestamp: Wed 2009-04-01 14:26:49 +0200
            message:
              Drop stdio sync for gprocessor too.
            modified:
              gui/gnash.cpp
              utilities/processor.cpp
=== modified file 'gui/gnash.cpp'
--- a/gui/gnash.cpp     2009-03-17 11:39:48 +0000
+++ b/gui/gnash.cpp     2009-04-01 12:26:49 +0000
@@ -47,6 +47,7 @@
 
 #include <string>
 #include <iostream>
+#include <ios>
 
 #ifdef ENABLE_NLS
 # include <locale>
@@ -444,6 +445,8 @@
 gnash_main(int argc, char *argv[])
 {
 
+    std::ios::sync_with_stdio(false);
+
     gnash::Player player;
 
     // Enable native language support, i.e. internationalization

=== modified file 'libbase/log.cpp'
--- a/libbase/log.cpp   2009-03-25 11:23:39 +0000
+++ b/libbase/log.cpp   2009-04-01 15:25:07 +0000
@@ -49,18 +49,18 @@
 
 // Convert each byte into its hex representation
 std::string
-hexify (const unsigned char *p, size_t length, bool ascii)
+hexify(const unsigned char *p, size_t length, bool ascii)
 {
 
-       const std::vector<unsigned char> bytes (p, p + length);
+       const std::vector<unsigned char> bytes(p, p + length);
 
        std::ostringstream ss;
        
        // For hex output, fill single-digit numbers with a leading 0.
        if (!ascii) ss << std::hex << std::setfill('0');
        
-       for (std::vector<unsigned char>::const_iterator i = bytes.begin(), e = 
bytes.end();
-            i != e; ++i)
+       for (std::vector<unsigned char>::const_iterator i = bytes.begin(),
+            e = bytes.end(); i != e; ++i)
            {
                if (ascii) {
                    if (std::isprint(*i) || *i == 0xd) {
@@ -78,29 +78,23 @@
 
 }
 
-std::string
-timestamp()
+std::ostream&
+timestamp(std::ostream& o)
 {
 
+    const char fmt[] = "%H:%M:%S";
+
        time_t t;
-       char buf[10];
-
-       std::memset (buf, '0', 10); // this terminates the string
-       std::time (&t); // get the current time
-       std::strftime (buf, sizeof(buf), "%H:%M:%S", std::localtime (&t));
-
-       std::stringstream ss;
-       ss << getpid() << ":" << get_thread_id() << "] " << buf;
-       return ss.str();
+       char buf[sizeof(fmt)];
+
+       std::time(&t);
+       std::strftime(buf, sizeof(buf), fmt, std::localtime(&t));
+
+       o << getpid() << ":" << get_thread_id() << "] " << buf;
+       return o;
 
 }
 
-// This is a bit of a hack. We implement wrappers for the old
-// functions so we don't have to change files everywhere, but get the
-// new behaviours, like logging to disk.
-// THIS IS DANGEROUS AS TIME OF INITIALIZATION IS UNPREDICTABLE,
-// THUS WE NOW HAVE A LogFile::getDefaultInstance() TO MAKE SURE
-// INITIALIZATION OF THE GLOBAL data HAPPENS BEFORE USE
 LogFile&
 LogFile::getDefaultInstance()
 {
@@ -124,14 +118,14 @@
 void
 processLog_debug(const boost::format& fmt)
 {
-       if (dbglogfile.getVerbosity() < GNASH_DEBUG_LEVEL) return;
+       if (dbglogfile.getVerbosity() < LogFile::LOG_DEBUG) return;
        dbglogfile.log(N_("DEBUG"), fmt.str());
 }
 
 void
 processLog_abc(const boost::format& fmt)
 {
-       if (dbglogfile.getVerbosity() < GNASH_DEBUG_LEVEL) return;
+       if (dbglogfile.getVerbosity() < LogFile::LOG_EXTRA) return;
        dbglogfile.log(N_("ABC"), fmt.str());
 }
 
@@ -197,17 +191,15 @@
        if (openLogIfNeeded())
        {
                if (_stamp) {
-                       std::string ts = timestamp();
-                       _outstream << ts << ": " << msg << endl;
+                       _outstream << timestamp << ": " << msg << "\n";
                } else {
-                       _outstream << msg << endl;
+                       _outstream << msg << "\n";
                }
        }
        else // log to stdout
        {
                if (_stamp) {
-                       std::string ts = timestamp();
-                       cout << ts << " " << msg << endl;
+                       cout << timestamp << " " << msg << endl;
                } else {
                        cout << msg << endl;
                }
@@ -219,10 +211,10 @@
        }
 }
 
-void
+inline void
 LogFile::log(const std::string& label, const std::string& msg)
 {
-       log(label+std::string(": ")+msg);
+       log(label + ": " + msg);
 }
 
 void
@@ -235,12 +227,12 @@
 void
 LogFile::setWriteDisk(bool use)
 {
-       if ( ! use ) closeLog();
+       if (!use) closeLog();
        _write = use;
 }
 
 // Default constructor
-LogFile::LogFile ()
+LogFile::LogFile()
        :
        _verbose(0),
        _actiondump(false),
@@ -258,7 +250,7 @@
 }
 
 bool
-LogFile::openLogIfNeeded ()
+LogFile::openLogIfNeeded()
 {
     if (_state != CLOSED) return true;
     if (!_write) return false;
@@ -271,7 +263,7 @@
 }
 
 bool
-LogFile::openLog (const std::string& filespec)
+LogFile::openLog(const std::string& filespec)
 {
 
     // NOTE:
@@ -282,28 +274,27 @@
 
     if (_state != CLOSED) {
        cout << "Closing previously opened stream" << endl;
-        _outstream.close ();
+        _outstream.close();
         _state = CLOSED;
     }
 
     // Append, don't truncate, the log file
-    _outstream.open (filespec.c_str(), std::ios::app|std::ios::out); // 
ios::out
+    _outstream.open(filespec.c_str(), std::ios::app|std::ios::out); // ios::out
     if( _outstream.fail() ) {
        // Can't use log_error here...
-        cout << "ERROR: can't open debug log file " << filespec << " for 
appending." << endl;
+        cout << "ERROR: can't open debug log file " << filespec << 
+            " for appending." << endl;
         return false;
     }       
 
        _filespec = filespec;
        _state = OPEN;
 
-  // LogFile::outstream << "Opened " << filespec << endl;
-
     return true;
 }
 
 bool
-LogFile::closeLog (void)
+LogFile::closeLog()
 {
        boost::mutex::scoped_lock lock(_ioMutex);
        if (_state == OPEN) {
@@ -316,10 +307,10 @@
 }
 
 bool
-LogFile::removeLog (void)
+LogFile::removeLog()
 {
        if (_state == OPEN) {
-               _outstream.close ();
+               _outstream.close();
        }
 
     // Ignore the error, we don't care
@@ -329,28 +320,6 @@
        return true;
 }
 
-boost::format
-logFormat (const std::string &str)
-{
-
-       using namespace boost::io;
-
-       boost::format fmt(str);
-       
-       // Don't throw exception if the wrong number of 
-       // arguments is passed or the format string is 
-       // bad. This might lead to strings being mangled,
-       // but the alternative is that a careless format
-       // string would cause Gnash to abort; and some
-       // strings don't appear very often. The same holds
-       // for translations.
-       fmt.exceptions(all_error_bits ^ (
-                                                       too_many_args_bit |
-                                                       too_few_args_bit |
-                                                       bad_format_string_bit));
-       return fmt;
-}
-
 } // end of gnash namespace
 
 

=== modified file 'libbase/log.h'
--- a/libbase/log.h     2009-03-24 11:07:39 +0000
+++ b/libbase/log.h     2009-04-01 14:22:00 +0000
@@ -40,10 +40,11 @@
 
 // Macro to prevent repeated logging calls for the same
 // event
-#define LOG_ONCE(x) { static bool warned = false; if (!warned) { warned = 
true; x; } }
+#define LOG_ONCE(x) { \
+    static bool warned = false; \
+    if (!warned) { warned = true; x; } \
+}
 
-// Define to switch between printf-style log formatting
-// and boost::format
 # include <boost/preprocessor/arithmetic/inc.hpp>
 # include <boost/preprocessor/repetition/enum_params.hpp>
 # include <boost/preprocessor/repetition/repeat.hpp>
@@ -52,16 +53,22 @@
 
 namespace gnash {
 
-#define GNASH_DEBUG_LEVEL 2
-
 // This is a basic file logging class
-class DSOEXPORT LogFile {
+class DSOEXPORT LogFile
+{
 public:
 
     static LogFile& getDefaultInstance();
 
     ~LogFile();
 
+    enum LogLevel {
+        LOG_SILENT,
+        LOG_NORMAL,
+        LOG_DEBUG,
+        LOG_EXTRA
+    };
+
     enum FileState {
         CLOSED,
         OPEN,
@@ -107,23 +114,23 @@
     void setLogFilename(const std::string& fname);
 
     // accessors for the verbose level
-    void setVerbosity () {
-        _verbose++;
+    void setVerbosity() {
+        ++_verbose;
     }
 
-    void setVerbosity (int x) {
+    void setVerbosity(int x) {
         _verbose = x;
     }
 
-    int getVerbosity () {
+    int getVerbosity() const {
         return _verbose;
     }
     
-    void setActionDump (int x) {
+    void setActionDump(int x) {
         _actiondump = x;
     }
 
-    int getActionDump () {
+    int getActionDump() const {
         return _actiondump;
     }
     
@@ -131,7 +138,7 @@
         _parserdump = x;
     }
 
-    int getParserDump () {
+    int getParserDump() const {
         return _parserdump;
     }
     
@@ -139,14 +146,14 @@
         _stamp = b;
     }
 
-    bool getStamp () {
+    bool getStamp() const {
         return _stamp;
     }
 
     /// Set whether to write logs to file
-    void setWriteDisk (bool b);
+    void setWriteDisk(bool b);
 
-    bool getWriteDisk () {
+    bool getWriteDisk() const {
         return _write;
     }
     
@@ -183,24 +190,24 @@
     boost::mutex _ioMutex;
 
     /// Stream to write to stdout.
-    std::ofstream       _outstream;
+    std::ofstream _outstream;
 
     /// How much output is required: 2 or more gives debug output.
-    int                 _verbose;
+    int _verbose;
 
     /// Whether to dump all SWF actions
-    bool                _actiondump;
+    bool _actiondump;
 
     /// Whether to dump parser output
-    bool                _parserdump;
+    bool _parserdump;
 
     /// The state of the log file.
     FileState _state;
 
-    bool                _stamp;
+    bool _stamp;
 
     /// Whether to write the log file to disk.
-    bool                _write;
+    bool _write;
 
     std::string _filespec;
 
@@ -210,6 +217,18 @@
 
 };
 
+DSOEXPORT void processLog_error(const boost::format& fmt);
+DSOEXPORT void processLog_unimpl(const boost::format& fmt);
+DSOEXPORT void processLog_trace(const boost::format& fmt);
+DSOEXPORT void processLog_debug(const boost::format& fmt);
+DSOEXPORT void processLog_action(const boost::format& fmt);
+DSOEXPORT void processLog_parse(const boost::format& fmt);
+DSOEXPORT void processLog_security(const boost::format& fmt);
+DSOEXPORT void processLog_swferror(const boost::format& fmt);
+DSOEXPORT void processLog_amferror(const boost::format& fmt);
+DSOEXPORT void processLog_aserror(const boost::format& fmt);
+DSOEXPORT void processLog_abc(const boost::format& fmt);
+
 /// This heap of steaming preprocessor code magically converts
 /// printf-style statements into boost::format messages using templates.
 //
@@ -225,44 +244,47 @@
 /// This is a sequence of different log message types to be used in
 /// the code. Append the name to log_ to call the function, e.g. 
 /// log_error, log_unimpl.
-#define LOG_TYPES (error) (debug) (unimpl) (aserror) (swferror) (amferror) 
(security) (action) (parse) (trace) (abc)
+#define LOG_TYPES (error) (debug) (unimpl) (aserror) (swferror) \
+    (amferror) (security) (action) (parse) (trace) (abc)
 
 /// This actually creates the template functions using the TOKENIZE
 /// functions above. The templates look like this:
 //
-/// template< typename T0 , typename T1 , typename T2 , typename T3 > 
-/// void
-/// log_security (const T0& t0, const T1& t1, const T2& t2, const T3& t3)
+/// template<typename T0 , typename T1 , typename T2>
+/// void log_error(const T0& t0 , const T1& t1 , const T2& t2)
 /// {
-///     if (_verbosity == 0) return;
-///     processLog_security(myFormat(t0) % t1 % t2 % t3);
+///     if (LogFile::getDefaultInstance().getVerbosity() == 0) return;
+///     boost::format f(t0);
+///     using namespace boost::io;
+///     f.exceptions(all_error_bits ^ (too_many_args_bit |
+///                                    too_few_args_bit |
+///                                    bad_format_string_bit));
+///     processLog_error(f % t1 % t2);
 /// }
-//
+///
 /// Only not as nicely indented.
 ///
-/// Use "g++ -E log.h" or "gcc log.h" to check.
+/// Use "g++ -E log.h" or "cpp log.h" to check.
 #define LOG_TEMPLATES(z, n, data)\
-    template< \
-         BOOST_PP_ENUM_PARAMS(\
-         BOOST_PP_INC(n), typename T)\
-     >\
-    void log_##data (\
-        BOOST_PP_REPEAT(\
-        BOOST_PP_INC(n), \
-        TOKENIZE_ARGS, t)\
-    ) { \
+template<BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n), typename T)>\
+void log_##data(BOOST_PP_REPEAT(BOOST_PP_INC(n), TOKENIZE_ARGS, t)) \
+{\
     if (LogFile::getDefaultInstance().getVerbosity() == 0) return; \
-    processLog_##data(logFormat(t0) \
-    BOOST_PP_REPEAT_FROM_TO(1, \
-        BOOST_PP_INC(n), \
-        TOKENIZE_FORMAT, t));\
-    }\
+    boost::format f(t0); \
+    using namespace boost::io; \
+    f.exceptions(all_error_bits ^ (too_many_args_bit | \
+                                   too_few_args_bit | \
+                                   bad_format_string_bit)); \
+    processLog_##data(f BOOST_PP_REPEAT_FROM_TO(1, \
+            BOOST_PP_INC(n), \
+            TOKENIZE_FORMAT, t));\
+}
 
 /// Defines the maximum number of template arguments
 //
 /// The preprocessor generates templates with 1..ARG_NUMBER
 /// arguments.
-#define ARG_NUMBER 16
+#define ARG_NUMBER 10
 
 /// Calls the macro LOG_TEMPLATES an ARG_NUMBER number
 /// of times, each time adding an extra typename argument to the
@@ -279,25 +301,6 @@
 #undef LOG_TEMPLATES
 #undef ARG_NUMBER
 
-DSOEXPORT void processLog_error(const boost::format& fmt);
-DSOEXPORT void processLog_unimpl(const boost::format& fmt);
-DSOEXPORT void processLog_trace(const boost::format& fmt);
-DSOEXPORT void processLog_debug(const boost::format& fmt);
-DSOEXPORT void processLog_action(const boost::format& fmt);
-DSOEXPORT void processLog_parse(const boost::format& fmt);
-DSOEXPORT void processLog_security(const boost::format& fmt);
-DSOEXPORT void processLog_swferror(const boost::format& fmt);
-DSOEXPORT void processLog_amferror(const boost::format& fmt);
-DSOEXPORT void processLog_aserror(const boost::format& fmt);
-DSOEXPORT void processLog_abc(const boost::format& fmt);
-
-/// A fault-tolerant boost::format object for logging
-//
-/// Generally to be used in the LogFile macro BF(), which will also
-/// be recognized by gettext for internationalization and is less
-/// effort to type.
-DSOEXPORT boost::format logFormat(const std::string &str);
-
 /// Convert a sequence of bytes to hex or ascii format.
 //
 /// @param bytes    the array of bytes to process
@@ -305,7 +308,8 @@
 ///                 for checking that length does not exceed the array size.
 /// @param ascii    whether to return in ascii or space-separated hex format.
 /// @return         a string representation of the byte sequence.
-DSOEXPORT std::string hexify(const unsigned char *bytes, size_t length, bool 
ascii);
+DSOEXPORT std::string hexify(const unsigned char *bytes, size_t length,
+        bool ascii);
 
 // Define to 0 to completely remove parse debugging at compile-time
 #ifndef VERBOSE_PARSE
@@ -387,7 +391,7 @@
     }
 
     ~__Host_Function_Report__(void) {
-       if (LogFile::getDefaultInstance().getVerbosity() >= GNASH_DEBUG_LEVEL + 
1) {
+       if (LogFile::getDefaultInstance().getVerbosity() > LogFile::LOG_DEBUG) {
            log_debug("%s returning", func);
        }
     }

=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp     2009-03-24 10:56:52 +0000
+++ b/libcore/MovieClip.cpp     2009-04-01 14:22:00 +0000
@@ -972,7 +972,7 @@
 
         if ( method )
         {
-            call_method0(as_value(method.get()), &m_as_environment, this);
+            call_method0(as_value(method.get()), m_as_environment, this);
             called = true;
         }
     }

=== modified file 'libcore/Timers.cpp'
--- a/libcore/Timers.cpp        2009-03-17 09:44:00 +0000
+++ b/libcore/Timers.cpp        2009-04-01 07:00:32 +0000
@@ -46,11 +46,11 @@
 
 void
 Timer::setInterval(as_function& method, unsigned long ms,
-                boost::intrusive_ptr<as_object> this_ptr, 
+        boost::intrusive_ptr<as_object> this_ptr, 
         ArgsContainer& args, bool runOnce)
 {
     _function = &method;
-    _interval = ms; // keep as milliseconds
+    _interval = ms; 
     _object = this_ptr;
     _args = args;
     _runOnce = runOnce;
@@ -62,7 +62,7 @@
         boost::intrusive_ptr<as_object> this_ptr, bool runOnce)
 {
     _function = &method;
-    _interval = ms; // keep as milliseconds
+    _interval = ms; 
     _object = this_ptr;
     _runOnce = runOnce;
     start();
@@ -75,7 +75,7 @@
 {
     _object = this_ptr;
     _methodName = methodName;
-    _interval = ms; // keep as milliseconds
+    _interval = ms; 
     _args = args;
     _runOnce = runOnce;
     start();
@@ -98,9 +98,9 @@
 bool
 Timer::expired(unsigned long now, unsigned long& elapsed)
 {
-    if ( cleared() ) return false;
+    if (cleared()) return false;
     long unsigned expTime = _start + _interval;
-    if ( now < expTime ) return false;
+    if (now < expTime) return false;
     elapsed = expTime-now;
     return true;
 }
@@ -108,9 +108,9 @@
 void
 Timer::executeAndReset()
 {
-    if ( cleared() ) return;
+    if (cleared()) return;
     execute();
-    if ( _runOnce ) clearInterval();
+    if (_runOnce) clearInterval();
     else _start += _interval; // reset the timer
 }
 
@@ -129,17 +129,18 @@
     else {
         string_table::key k = vm.getStringTable().find(_methodName);
         as_value tmp;
-        if ( ! _object->get_member(k, &tmp) )
-        {
+
+        if ( ! _object->get_member(k, &tmp) ) {
             IF_VERBOSE_ASCODING_ERRORS(
             log_aserror("object %p has no member named %s (interval method)",
                      _object, _methodName);
             );
             return;
         }
+
         as_function* f = tmp.to_as_function();
-        if ( ! f )
-        {
+
+        if (!f) {
             IF_VERBOSE_ASCODING_ERRORS(
             log_aserror("member %s of object %p (interval method) is not "
                 "a function (%s)", _methodName, (void*)_object.get(), tmp);
@@ -151,16 +152,11 @@
 
     as_environment env(vm); 
 
-    // Prepare args 
-    std::auto_ptr<std::vector<as_value> > args ( new std::vector<as_value> );
-    for ( ArgsContainer::iterator it=_args.begin(), itEnd=_args.end();
-            it != itEnd; ++it )
-    {
-        //log_debug("Env-pushing %s", *it);
-        args->push_back(*it);
-    }
+    // Copy args 
+    std::auto_ptr<std::vector<as_value> > args(
+            new std::vector<as_value>(_args));
 
-    call_method(timer_method, &env, _object.get(), args, super);
+    call_method(timer_method, env, _object.get(), args, super);
 
 }
 

=== modified file 'libcore/Timers.h'
--- a/libcore/Timers.h  2009-03-17 09:44:00 +0000
+++ b/libcore/Timers.h  2009-04-01 05:59:00 +0000
@@ -29,7 +29,7 @@
 
 // Forward declarations
 namespace gnash {
-       class as_function;
+    class as_function;
 }
 
 namespace gnash {
@@ -64,43 +64,43 @@
     /// Setup the Timer, enabling it.
     //
     /// @param method
-    ///        The function to call from execution operator.
-    ///        Will be stored in an intrusive_ptr.
+    ///    The function to call from execution operator.
+    ///    Will be stored in an intrusive_ptr.
     ///
     /// @param ms
-    ///        The number of milliseconds between expires.
+    ///    The number of milliseconds between expires.
     ///
     /// @param this_ptr
-    ///        The object to be used as 'this' pointer when calling the
-    ///        associated function. Will be stored in an intrusive_ptr.
-    ///        It is allowed to be NULL as long as fn_call is allowed
-    ///        a NULL as 'this_ptr' (we might want to change this).
+    ///    The object to be used as 'this' pointer when calling the
+    ///    associated function. Will be stored in an intrusive_ptr.
+    ///    It is allowed to be NULL as long as fn_call is allowed
+    ///    a NULL as 'this_ptr' (we might want to change this).
     ///
     /// @param runOnce
-    ///        If true the interval will run only once. False if omitted.
+    ///     If true the interval will run only once. False if omitted.
     void setInterval(as_function& method, unsigned long ms,
             boost::intrusive_ptr<as_object> this_ptr, bool runOnce = false);
 
     /// Setup the Timer, enabling it.
     //
     /// @param method
-    ///        The function to call from execution operator.
-    ///        Will be stored in an intrusive_ptr.
+    ///    The function to call from execution operator.
+    ///    Will be stored in an intrusive_ptr.
     ///
     /// @param ms
-    ///        The number of milliseconds between expires.
+    ///    The number of milliseconds between expires.
     ///
     /// @param this_ptr
-    ///        The object to be used as 'this' pointer when calling the
-    ///        associated function. Will be stored in an intrusive_ptr.
-    ///        It is allowed to be NULL as long as fn_call is allowed
-    ///        a NULL as 'this_ptr' (we might want to change this).
+    ///    The object to be used as 'this' pointer when calling the
+    ///    associated function. Will be stored in an intrusive_ptr.
+    ///    It is allowed to be NULL as long as fn_call is allowed
+    ///    a NULL as 'this_ptr' (we might want to change this).
     ///
     /// @param args
-    ///        The list of arguments to pass to the function being invoked.
+    ///     The list of arguments to pass to the function being invoked.
     ///
     /// @param runOnce
-    ///        If true the interval will run only once. False if omitted.
+    ///     If true the interval will run only once. False if omitted.
     void setInterval(as_function& method, unsigned long ms,
             boost::intrusive_ptr<as_object> this_ptr,
             std::vector<as_value>& args, bool runOnce = false);
@@ -108,22 +108,22 @@
     /// Setup the Timer to call a late-evaluated object method, enabling it.
     //
     /// @param this_ptr
-    ///        The object to be used as 'this' pointer when calling the
-    ///        associated function. Will be stored in an intrusive_ptr.
-    ///        It is allowed to be NULL as long as fn_call is allowed
-    ///        a NULL as 'this_ptr' (we might want to change this).
+    ///    The object to be used as 'this' pointer when calling the
+    ///    associated function. Will be stored in an intrusive_ptr.
+    ///    It is allowed to be NULL as long as fn_call is allowed
+    ///    a NULL as 'this_ptr' (we might want to change this).
     ///
     /// @param methodName
-    ///        The method name to call from execution operator.
+    ///    The method name to call from execution operator.
     ///
     /// @param ms
-    ///        The number of milliseconds between expires.
+    ///    The number of milliseconds between expires.
     ///
     /// @param args
-    ///        The list of arguments to pass to the function being invoked.
+    ///     The list of arguments to pass to the function being invoked.
     ///
     /// @param runOnce
-    ///        If true the interval will run only once. False if omitted.
+    ///     If true the interval will run only once. False if omitted.
     void setInterval(boost::intrusive_ptr<as_object> obj,
             const std::string& methodName, unsigned long ms,
             std::vector<as_value>& args, bool runOnce = false);
@@ -169,15 +169,15 @@
     void executeAndReset();
 
 #ifdef GNASH_USE_GC
-  /// Mark all reachable resources (for GC)
-  //
-  /// Resources reachable from Timer are:
-  ///
-  ///  - Arguments list (_args)
-  ///  - Associated function (_function)
-  ///  - Target object (_object)
-  ///
-  void markReachableResources() const;
+    /// Mark all reachable resources (for GC)
+    //
+    /// Resources reachable from Timer are:
+    ///
+    ///    - Arguments list (_args)
+    ///    - Associated function (_function)
+    ///    - Target object (_object)
+    ///
+    void markReachableResources() const;
 #endif // GNASH_USE_GC
 
 private:

=== modified file 'libcore/as_environment.h'
--- a/libcore/as_environment.h  2009-02-25 22:33:03 +0000
+++ b/libcore/as_environment.h  2009-04-01 07:00:32 +0000
@@ -52,9 +52,9 @@
 
     as_environment(VM& vm);
 
-    VM& getVM() { return _vm; }
+    VM& getVM() const { return _vm; }
 
-    character* get_target() { return m_target; }
+    character* get_target() const { return m_target; }
 
     /// Set default target for timeline opcodes
     //
@@ -120,7 +120,7 @@
     ///
     /// Throw StackException if index is out of range
     ///
-    as_value& bottom(size_t index)
+    as_value& bottom(size_t index) const
     {
         try {
             return _stack.value(index);

=== modified file 'libcore/as_function.cpp'
--- a/libcore/as_function.cpp   2009-03-02 11:52:46 +0000
+++ b/libcore/as_function.cpp   2009-04-01 07:00:32 +0000
@@ -341,7 +341,7 @@
 }
 
 boost::intrusive_ptr<as_object>
-as_function::constructInstance(as_environment& env,
+as_function::constructInstance(const as_environment& env,
        std::auto_ptr<std::vector<as_value> > args)
 {
 

=== modified file 'libcore/as_function.h'
--- a/libcore/as_function.h     2009-02-25 22:33:03 +0000
+++ b/libcore/as_function.h     2009-04-01 07:00:32 +0000
@@ -88,7 +88,7 @@
        /// @param args
        ///     Arguments for the constructor invocation
        ///
-       boost::intrusive_ptr<as_object> constructInstance( as_environment& env,
+       boost::intrusive_ptr<as_object> constructInstance(const as_environment& 
env,
                        std::auto_ptr< std::vector<as_value> > args);
 
        /// Get this function's "prototype" member (exported interface).

=== modified file 'libcore/as_object.cpp'
--- a/libcore/as_object.cpp     2009-02-20 12:24:00 +0000
+++ b/libcore/as_object.cpp     2009-04-01 14:22:00 +0000
@@ -1180,7 +1180,7 @@
 
        if (get_member(id.functionKey(), &event_handler) )
        {
-               call_method0(event_handler, NULL, this);
+               call_method0(event_handler, as_environment(_vm), this);
                return true;
        }
 
@@ -1207,7 +1207,7 @@
 
        as_environment env(_vm);
 
-       return call_method0(method, &env, this);
+       return call_method0(method, env, this);
 }
 
 as_value
@@ -1225,7 +1225,7 @@
        std::auto_ptr< std::vector<as_value> > args ( new std::vector<as_value> 
);
        args->push_back(arg0);
 
-       return call_method(method, &env, this, args);
+       return call_method(method, env, this, args);
 }
 
 as_value
@@ -1245,7 +1245,7 @@
        args->push_back(arg0);
        args->push_back(arg1);
 
-       return call_method(method, &env, this, args);
+       return call_method(method, env, this, args);
 }
 
 as_value
@@ -1267,7 +1267,7 @@
        args->push_back(arg1);
        args->push_back(arg2);
 
-       ret = call_method(method, &env, this, args);
+       ret = call_method(method, env, this, args);
 
        return ret;
 }
@@ -1291,7 +1291,7 @@
        args->push_back(arg2);
        args->push_back(arg3);
 
-       return call_method(method, &env, this, args);
+       return call_method(method, env, this, args);
 
 }
 

=== modified file 'libcore/as_value.cpp'
--- a/libcore/as_value.cpp      2009-03-24 10:56:52 +0000
+++ b/libcore/as_value.cpp      2009-04-01 14:22:00 +0000
@@ -572,7 +572,7 @@
        assert(obj);
 
        as_environment env(obj->getVM());
-       as_value ret = call_method0(method, &env, obj);
+       as_value ret = call_method0(method, env, obj);
 #if GNASH_DEBUG_CONVERSION_TO_PRIMITIVE
        log_debug("to_primitive: method call returned %s", ret);
 #endif
@@ -677,7 +677,7 @@
        assert(obj);
 
        as_environment env(obj->getVM());
-       as_value ret = call_method0(method, &env, obj);
+       as_value ret = call_method0(method, env, obj);
 #if GNASH_DEBUG_CONVERSION_TO_PRIMITIVE
        log_debug("to_primitive: method call returned %s", ret);
 #endif

=== modified file 'libcore/asobj/Array_as.cpp'
--- a/libcore/asobj/Array_as.cpp        2009-03-17 11:39:48 +0000
+++ b/libcore/asobj/Array_as.cpp        2009-04-01 07:00:32 +0000
@@ -349,10 +349,10 @@
     as_function& _comp;
     as_object* _object;
     bool (*_zeroCmp)(const int);
-    as_environment& _env;
+    const as_environment& _env;
 
     as_value_custom(as_function& comparator, bool (*zc)(const int), 
-        boost::intrusive_ptr<as_object> this_ptr, as_environment& env)
+        boost::intrusive_ptr<as_object> this_ptr, const as_environment& env)
         :
         _comp(comparator),
         _zeroCmp(zc),
@@ -369,7 +369,7 @@
            std::auto_ptr<std::vector<as_value> > args (new 
std::vector<as_value>);
            args->push_back(b);
            args->push_back(a);
-        ret = call_method(cmp_method, &_env, _object, args);
+        ret = call_method(cmp_method, _env, _object, args);
 
         return (*_zeroCmp)(ret.to_int());
     }
@@ -672,7 +672,7 @@
 }
 
 std::string
-Array_as::join(const std::string& separator, as_environment*) const
+Array_as::join(const std::string& separator) const
 {
     // TODO - confirm this is the right format!
     // Reportedly, flash version 7 on linux, and Flash 8 on IE look like
@@ -710,9 +710,9 @@
 }
 
 std::string
-Array_as::toString(as_environment* env) const
+Array_as::toString() const
 {
-    return join(",", env);
+    return join(",");
 }
 
 unsigned int
@@ -993,7 +993,7 @@
         if (flags & Array_as::fDescending) icmp = &int_lt_or_eq;
         else icmp = &int_gt;
 
-        as_environment& env = fn.env();
+        const as_environment& env = fn.env();
 
         as_value_custom avc = 
             as_value_custom(*as_func, icmp, fn.this_ptr, env);
@@ -1259,15 +1259,14 @@
     boost::intrusive_ptr<Array_as> array = ensureType<Array_as>(fn.this_ptr);
 
     std::string separator = ",";
-    int version = array->getVM().getSWFVersion();
-    as_environment* env = &(fn.env());
+    int version = fn.getVM().getSWFVersion();
 
     if (fn.nargs > 0)
     {
         separator = fn.arg(0).to_string_versioned(version);
     }
 
-    std::string ret = array->join(separator, env);
+    std::string ret = array->join(separator);
 
     return as_value(ret);
 }

=== modified file 'libcore/asobj/Array_as.h'
--- a/libcore/asobj/Array_as.h  2009-02-25 22:33:03 +0000
+++ b/libcore/asobj/Array_as.h  2009-04-01 07:00:32 +0000
@@ -160,18 +160,10 @@
 
        /// @param separator
     ///     String to use as separator between elements
-    ///
-       /// @param env
-       ///     If not-null will be used to properl invoke the toString()
-       ///     method against member values.
-       ///
-       std::string join(const std::string& separator, as_environment* env) 
const;
+       std::string join(const std::string& separator) const;
 
-       /// @param env
-       ///     If not-null will be used to properly invoke the toString()
-       ///     method against member values.
-       ///
-       std::string toString(as_environment* env=NULL) const;
+    /// Convert array to string.
+       std::string toString() const;
 
        // override from as_object
        std::string get_text_value() const

=== modified file 'libcore/asobj/NetStream_as.cpp'
--- a/libcore/asobj/NetStream_as.cpp    2009-03-28 09:54:42 +0000
+++ b/libcore/asobj/NetStream_as.cpp    2009-03-31 09:26:54 +0000
@@ -298,7 +298,7 @@
 
     if (_netCon) _netCon->setReachable();
 
-    if (m_statusHandler) m_statusHandler->setReachable();
+    if (_statusHandler) _statusHandler->setReachable();
 
     if (_audioController) _audioController->setReachable();
 

=== modified file 'libcore/asobj/NetStream_as.h'
--- a/libcore/asobj/NetStream_as.h      2009-03-19 19:16:28 +0000
+++ b/libcore/asobj/NetStream_as.h      2009-03-31 09:26:54 +0000
@@ -411,7 +411,7 @@
 
     // Are we playing a FLV?
     // The handler which is invoked on status change
-    boost::intrusive_ptr<as_function> m_statusHandler;
+    boost::intrusive_ptr<as_function> _statusHandler;
 
     // The position in the inputfile, only used when not playing a FLV
     long inputPos;

=== modified file 'libcore/asobj/TextSnapshot_as.cpp'
--- a/libcore/asobj/TextSnapshot_as.cpp 2009-03-30 23:47:37 +0000
+++ b/libcore/asobj/TextSnapshot_as.cpp 2009-03-31 09:26:54 +0000
@@ -186,6 +186,7 @@
 TextSnapshot_as::markReachableResources() const
 {
     std::for_each(_textFields.begin(), _textFields.end(), setTextReachable);
+    markAsObjectReachable();
 }
 
 void
@@ -439,8 +440,8 @@
         return as_value();
     }
 
-    size_t start = std::max(0, static_cast<int>(fn.arg(0).to_int()));
-    size_t end = std::max<int>(start + 1, fn.arg(1).to_int());
+    size_t start = std::max<boost::int32_t>(0, fn.arg(0).to_int());
+    size_t end = std::max<boost::int32_t>(start + 1, fn.arg(1).to_int());
 
     Array_as* ri = new Array_as;
 
@@ -505,8 +506,8 @@
         return as_value();
     }
 
-    size_t start = std::max(0, static_cast<int>(fn.arg(0).to_int()));
-    size_t end = std::max<int>(start + 1, fn.arg(1).to_int());
+    size_t start = std::max<boost::int32_t>(0, fn.arg(0).to_int());
+    size_t end = std::max<boost::int32_t>(start + 1, fn.arg(1).to_int());
 
     return as_value(ts->getSelected(start, end));
 }
@@ -592,8 +593,8 @@
         return as_value();
     }
 
-    size_t start = std::max(0, static_cast<int>(fn.arg(0).to_int()));
-    size_t end = std::max<int>(start, fn.arg(1).to_int());
+    size_t start = std::max<boost::int32_t>(0, fn.arg(0).to_int());
+    size_t end = std::max<boost::int32_t>(start, fn.arg(1).to_int());
 
     bool selected = (fn.nargs > 2) ? fn.arg(2).to_bool() : true;
 

=== modified file 'libcore/asobj/XMLNode_as.cpp'
--- a/libcore/asobj/XMLNode_as.cpp      2009-01-22 20:10:39 +0000
+++ b/libcore/asobj/XMLNode_as.cpp      2009-03-31 09:26:54 +0000
@@ -98,20 +98,18 @@
     _type(tpl._type)
 {
     // only clone children if in deep mode
-    if ( deep ) 
-    {
+    if (deep) {
         const Children& from=tpl._children;
         for (Children::const_iterator it=from.begin(), itEnd=from.end();
-                        it != itEnd; ++it)
-        {
-                _children.push_back(new XMLNode_as(*(*it), deep));
+                        it != itEnd; ++it) {
+
+            _children.push_back(new XMLNode_as(*(*it), deep));
         }
     }
 }
 
 XMLNode_as::~XMLNode_as()
 {
-    //log_debug("%s: %p", __PRETTY_FUNCTION__, this);
 #ifdef DEBUG_MEMORY_ALLOCATION
     log_debug(_("\tDeleting XMLNode data %s with as_value %s at %p"),
             this->_name, this->as_value, this);
@@ -121,17 +119,13 @@
 bool
 XMLNode_as::hasChildNodes()
 {
-    //GNASH_REPORT_FUNCTION;
-    if (_children.size()) {
-        return true;
-    }
+    if (_children.size()) return true;
     return false;
 }
 
 boost::intrusive_ptr<XMLNode_as>
 XMLNode_as::firstChild()
 {
-    //GNASH_REPORT_FUNCTION;
     if ( _children.empty() ) return NULL;
     return _children.front();
 }
@@ -139,11 +133,9 @@
 boost::intrusive_ptr<XMLNode_as>
 XMLNode_as::lastChild()
 {
-       //GNASH_REPORT_FUNCTION;
-       if ( _children.empty() )
-       {
+       if (_children.empty()) {
                        log_debug(_("XMLNode_as %p has no children"), 
(void*)this);
-                       return NULL;
+                       return 0;
        }
        return _children.back();
 }
@@ -176,10 +168,10 @@
 {
     // find iterator for positional parameter
     Children::iterator it = std::find(_children.begin(), _children.end(), pos);
-    if ( it == _children.end() )
-    {
+    if (it == _children.end()) {
         IF_VERBOSE_ASCODING_ERRORS(
-        log_aserror(_("XMLNode.insertBefore(): positional parameter is not a 
child of this node"));
+        log_aserror(_("XMLNode.insertBefore(): positional parameter "
+                "is not a child of this node"));
         );
         return;
     }
@@ -187,8 +179,7 @@
     _children.insert(it, newnode);
     boost::intrusive_ptr<XMLNode_as> oldparent = newnode->getParent();
     newnode->setParent(this);
-    if ( oldparent )
-    {
+    if (oldparent) {
         oldparent->_children.remove(newnode);
     }
 }
@@ -198,72 +189,48 @@
 void
 XMLNode_as::removeNode()
 {
-#ifndef GNASH_USE_GC
-    assert(get_ref_count() > 1);
-#endif
     boost::intrusive_ptr<XMLNode_as> oldparent = getParent();
-    if ( oldparent )
-    {
+    if (oldparent) {
         oldparent->_children.remove(this);
     }
-    _parent = NULL;
-#ifndef GNASH_USE_GC
-    assert(get_ref_count() > 0);
-#endif
+    _parent = 0;
 }
 
 XMLNode_as *
 XMLNode_as::previousSibling()
 {
-    //GNASH_REPORT_FUNCTION;
-
-    if ( ! _parent) return NULL;
-       if (_parent->_children.size() <= 1) return NULL;
-
-    XMLNode_as *previous_node = NULL;
-    Children::iterator itx;
-    for (itx = _parent->_children.begin(); itx != _parent->_children.end(); 
itx++)
-    {
-        if (itx->get() == this)
-        {
-            // log_debug("Found the previous XMLNode_as child !!!! %s <%p>", 
(*itx)->nodeName(), (void*)*itx);
-                   return previous_node;
-               }
-               previous_node = itx->get();
+    if (!_parent) return 0;
+       if (_parent->_children.size() <= 1) return 0;
+
+    XMLNode_as *previous_node = 0;
+    for (Children::iterator itx = _parent->_children.begin();
+            itx != _parent->_children.end(); itx++) {
+
+        if (itx->get() == this) return previous_node;
+               
+        previous_node = itx->get();
     }
 
-    return NULL;
+    return 0;
 }
 
 XMLNode_as *
 XMLNode_as::nextSibling()
 {
-    //GNASH_REPORT_FUNCTION;
-
-    if ( ! _parent)
-    {
-            //log_debug("Node %p has no parent, returning NULL", this);
-            return NULL;
-    }
-    if (_parent->_children.size() <= 1)
-    {
-            //log_debug("Node %p parent has only this node, returning NULL", 
this);
-            return NULL;
-    }
-
-    XMLNode_as *previous_node = NULL;
-    Children::reverse_iterator itx;
-    for (itx = _parent->_children.rbegin(); itx != _parent->_children.rend();
-            itx++)
-    {
-        if (itx->get() == this)
-        {
-                   return previous_node;
-               }
+
+    if (!_parent) return 0;
+
+    if (_parent->_children.size() <= 1) return 0;
+
+    XMLNode_as *previous_node = 0;
+    for (Children::reverse_iterator itx = _parent->_children.rbegin();
+            itx != _parent->_children.rend(); ++itx) {
+
+        if (itx->get() == this) return previous_node;
                previous_node = itx->get();
     }
 
-    return NULL;
+    return 0;
 }
 
 void
@@ -288,8 +255,7 @@
     PropertyList::SortedPropertyList::const_iterator it; 
     PropertyList::SortedPropertyList attrs;
     
-    while (node)
-    {
+    while (node) {
         enumerateAttributes(*node, attrs);
         if (!attrs.empty())
         {
@@ -327,11 +293,12 @@
     PropertyList::SortedPropertyList::const_iterator it; 
     PropertyList::SortedPropertyList attrs;
     
-    while (node)
-    {
+    while (node) {
+
         enumerateAttributes(*node, attrs);
-        if (!attrs.empty())
-        {
+
+        if (!attrs.empty()) {
+
             it = std::find_if(attrs.begin(), attrs.end(), 
                         boost::bind(prefixMatches, _1, prefix));
             if (it != attrs.end()) break;
@@ -379,8 +346,8 @@
 #endif
 
     // Create the beginning of the tag
-    if (!nodeName.empty())
-    {
+    if (!nodeName.empty()) {
+
         xmlout << "<" << nodeName;
     
         // Process the attributes, if any
@@ -408,7 +375,7 @@
     }
 
     // Node as_value first, then children
-    if ( type == Text )
+    if (type == Text)
     {
         // Insert entities.
         std::string escaped(nodeValue);
@@ -419,14 +386,13 @@
     }
 
     // Childs, after node as_value.
-    Children::const_iterator itx;
-    for (itx = xml._children.begin(); itx != xml._children.end(); itx++)
-    {
+    for (Children::const_iterator itx = xml._children.begin(); 
+            itx != xml._children.end(); ++itx) {
+
         (*itx)->toString(xmlout, encode);
     }
 
-    if (!nodeName.empty())
-    {
+    if (!nodeName.empty()) {
            xmlout << "</" << nodeName << ">";
     }
 }
@@ -436,15 +402,12 @@
 void
 XMLNode_as::markReachableResources() const
 {
-       // Mark childs
-       for (Children::const_iterator i=_children.begin(),
-            e=_children.end(); i!=e; ++i)
-       {
-               (*i)->setReachable();
-       }
+       // Mark children
+    std::for_each(_children.begin(), _children.end(),
+            boost::mem_fn(&as_object::setReachable));
 
        // Mark parent
-       if ( _parent ) _parent->setReachable();
+       if (_parent) _parent->setReachable();
 
        // Mark attributes object
        if (_attributes) _attributes->setReachable();
@@ -625,8 +588,8 @@
 
        boost::intrusive_ptr<XMLNode_as> newnode = 
         boost::dynamic_pointer_cast<XMLNode_as>(fn.arg(0).to_object());
-       if ( ! newnode )
-       {
+
+       if (!newnode) {
                IF_VERBOSE_ASCODING_ERRORS(
                std::stringstream ss; fn.dump_args(ss);
                log_aserror(_("First argument to XMLNode.insertBefore(%s) is 
not "
@@ -637,8 +600,8 @@
 
        boost::intrusive_ptr<XMLNode_as> pos = 
         boost::dynamic_pointer_cast<XMLNode_as>(fn.arg(1).to_object());
-       if ( ! pos )
-       {
+
+       if (!pos) {
                IF_VERBOSE_ASCODING_ERRORS(
         std::stringstream ss; fn.dump_args(ss);
                log_aserror(_("Second argument to XMLNode.insertBefore(%s) is 
not "

=== modified file 'libcore/asobj/XMLNode_as.h'
--- a/libcore/asobj/XMLNode_as.h        2009-01-22 20:10:39 +0000
+++ b/libcore/asobj/XMLNode_as.h        2009-03-31 09:26:54 +0000
@@ -120,7 +120,7 @@
     boost::intrusive_ptr<XMLNode_as> lastChild();
     
     // Use a list for quick erasing
-    typedef std::list< boost::intrusive_ptr<XMLNode_as> > Children;
+    typedef std::list<boost::intrusive_ptr<XMLNode_as> > Children;
 
     Children& childNodes() { return _children; }
 

=== modified file 'libcore/asobj/flash/display/BitmapData_as.cpp'
--- a/libcore/asobj/flash/display/BitmapData_as.cpp     2009-02-27 11:55:27 
+0000
+++ b/libcore/asobj/flash/display/BitmapData_as.cpp     2009-03-31 09:26:54 
+0000
@@ -98,6 +98,7 @@
 {
     std::for_each(_attachedBitmaps.begin(), _attachedBitmaps.end(),
             std::mem_fun(&character::setReachable));
+    markAsObjectReachable();
 }
 
 

=== modified file 'libcore/asobj/flash/geom/Rectangle_as.cpp'
--- a/libcore/asobj/flash/geom/Rectangle_as.cpp 2009-03-17 11:39:48 +0000
+++ b/libcore/asobj/flash/geom/Rectangle_as.cpp 2009-04-01 07:00:32 +0000
@@ -434,13 +434,11 @@
 
                as_function* pointCtor = getFlashGeomPointConstructor();
 
-               as_environment& env = fn.env();
-
                std::auto_ptr<std::vector<as_value> > args(new 
std::vector<as_value>);
                args->push_back(right);
                args->push_back(bottom);
 
-               ret = pointCtor->constructInstance(env, args);
+               ret = pointCtor->constructInstance(fn.env(), args);
        }
        else // setter
        {
@@ -524,13 +522,11 @@
 
                as_function* pointCtor = getFlashGeomPointConstructor();
 
-               as_environment& env = fn.env();
-
                std::auto_ptr<std::vector<as_value> > args(new 
std::vector<as_value>);
                args->push_back(w);
                args->push_back(h);
 
-               ret = pointCtor->constructInstance(env, args);
+               ret = pointCtor->constructInstance(fn.env(), args);
        }
        else // setter
        {
@@ -586,13 +582,11 @@
 
                as_function* pointCtor = getFlashGeomPointConstructor();
 
-               as_environment& env = fn.env();
-
-               std::auto_ptr< std::vector<as_value> > args ( new 
std::vector<as_value> );
+               std::auto_ptr<std::vector<as_value> > args(new 
std::vector<as_value>);
                args->push_back(x);
                args->push_back(y);
 
-               ret = pointCtor->constructInstance(env, args);
+               ret = pointCtor->constructInstance(fn.env(), args);
 
        }
        else // setter

=== modified file 'libcore/parser/abc_block.cpp'
--- a/libcore/parser/abc_block.cpp      2009-03-25 11:02:48 +0000
+++ b/libcore/parser/abc_block.cpp      2009-04-01 08:08:07 +0000
@@ -602,52 +602,46 @@
                // Read, but don't upper validate until after the switch.
                switch (kind)
                {
-        case asName::KIND_Qname:
-        case asName::KIND_QnameA:
-        {
-           ns = mS->read_V32();
-           check_multiname_namespace(ns);
-            name = mS->read_V32();
-               check_multiname_name(name);
-               log_abc("\tnamespace_index=%u name_index=%u name=%s", ns, name, 
_stringPool[name]);
-            break;
-        }
-        case asName::KIND_RTQname:
-        case asName::KIND_RTQnameA:
-        {
-            name = mS->read_V32();
-            check_multiname_name(name);
-            break;
-        }
-        case asName::KIND_RTQnameL:
-        case asName::KIND_RTQnameLA:
-        {
-
-            break;
-        }
-        case asName::KIND_Multiname:
-        case asName::KIND_MultinameA:
-        {
-            name = mS->read_V32();
-            check_multiname_name(name);
-            nsset = mS->read_V32();
-            check_multiname_namespaceset(nsset);
-            break;
-        }
-        case asName::KIND_MultinameL:
-        case asName::KIND_MultinameLA:
-        {
-            nsset = mS->read_V32();
-            check_multiname_namespaceset(nsset);
-            break;
-        }
-        default:
-        {
-            // Unknown type.
-            log_error(_("Action Block: Unknown multiname type (%d)."), kind);
-            return false;
-        } // End of cases.
-        } // End of switch.
+            case asName::KIND_Qname:
+            case asName::KIND_QnameA:
+                ns = mS->read_V32();
+                check_multiname_namespace(ns);
+                name = mS->read_V32();
+                check_multiname_name(name);
+                log_abc("\tnamespace_index=%u name_index=%u name=%s",
+                        ns, name, _stringPool[name]);
+                break;
+            
+            case asName::KIND_RTQname:
+            case asName::KIND_RTQnameA:
+                name = mS->read_V32();
+                check_multiname_name(name);
+                break;
+            
+            case asName::KIND_RTQnameL:
+            case asName::KIND_RTQnameLA:
+                break;
+            
+            case asName::KIND_Multiname:
+            case asName::KIND_MultinameA:
+                name = mS->read_V32();
+                check_multiname_name(name);
+                nsset = mS->read_V32();
+                check_multiname_namespaceset(nsset);
+                break;
+            
+            case asName::KIND_MultinameL:
+            case asName::KIND_MultinameLA:
+                nsset = mS->read_V32();
+                check_multiname_namespaceset(nsset);
+                break;
+            
+            default:
+                // Unknown type.
+                log_error(_("Action Block: Unknown multiname type (%d)."),
+                        kind);
+                return false;
+        } 
 
                _multinamePool[i].setFlags(kind);
                setMultinameNames(&_multinamePool[i], name);

=== modified file 'libcore/swf_function.cpp'
--- a/libcore/swf_function.cpp  2009-02-25 22:33:03 +0000
+++ b/libcore/swf_function.cpp  2009-04-01 07:00:32 +0000
@@ -129,26 +129,16 @@
     CallStack& cs = vm.getCallStack();
     if ( ! cs.empty() ) caller = cs.back().func;
 
+       assert(m_env);
+
        // Set up local stack frame, for parameters and locals.
-       as_environment::FrameGuard guard(fn.env(), this);
+       as_environment::FrameGuard guard(*m_env, this);
 
        as_environment* our_env = m_env;
-       assert(our_env);
-
-       // if(our_env->get_original_target()->isDestroyed())
-        if (our_env == NULL)
-       {
-               log_error("swf_function own environment is null (possible?)");
-               our_env = &fn.env();
-       }
 
        character* target = our_env->get_target();
        character* orig_target = our_env->get_original_target();
 
-#if 0
-       log_debug("swf_function() stack:\n"); fn.env().dump_stack();
-       log_debug("  first_arg_bottom_index: %d\n", fn.first_arg_bottom_index);
-#endif
        // Some features are version-dependant.
        unsigned swfversion = vm.getSWFVersion();
        as_object *super = NULL;

=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2009-03-17 12:01:42 +0000
+++ b/libcore/vm/ASHandlers.cpp 2009-04-01 07:00:32 +0000
@@ -2801,8 +2801,7 @@
     args->reserve(nargs);
     for (size_t i=0; i<nargs; ++i) args->push_back(env.pop()); 
 
-    //log_debug("ActionCallFunction calling call_method with %p as this_ptr", 
this_ptr);
-    as_value result = call_method(function, &env, this_ptr,
+    as_value result = call_method(function, env, this_ptr,
                   args, super, &(thread.code.getMovieDefinition()));
 
     env.push(result);
@@ -3477,7 +3476,7 @@
     args->reserve(nargs);
     for (size_t i=0; i<nargs; ++i) args->push_back(env.pop()); 
 
-    as_value result = call_method(method_val, &env, this_ptr, 
+    as_value result = call_method(method_val, env, this_ptr, 
             args, super, &(thread.code.getMovieDefinition()));
 
     env.push(result);

=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp    2009-03-31 09:06:17 +0000
+++ b/libcore/vm/Machine.cpp    2009-04-01 14:22:00 +0000
@@ -1196,7 +1196,7 @@
                                LOG_DEBUG_AVM("Calling method %s on object %s",
                         property.toDebugString(),object_val.toDebugString());
                                as_environment env = as_environment(_vm);
-                               result = call_method(property,&env,object,args);
+                               result = call_method(property,env,object,args);
 
                        }
                        else{
@@ -1353,7 +1353,7 @@
                        }
                        else{
                                as_value val = 
constructor_val.to_object().get()->getMember(NSV::PROP_CONSTRUCTOR,0);
-                               as_value result = 
call_method(val,&env,constructor_val.to_object().get(),args);
+                               as_value result = 
call_method(val,env,constructor_val.to_object().get(),args);
                                push_stack(result);
                        }
                }
@@ -1450,7 +1450,7 @@
                //Call the class's static constructor.
                as_environment env = as_environment(_vm);
                as_value property = 
new_class->getMember(NSV::PROP_uuCONSTRUCTORuu,0);
-               as_value value = 
call_method(property,&env,new_class,get_args(0));
+               as_value value = 
call_method(property,env,new_class,get_args(0));
 
                break;
        }
@@ -1576,9 +1576,17 @@
                else{
                        name = a.getGlobalName();
                }
-               as_object *object = pop_stack().to_object().get();
-               object->set_member(name,value,ns,false);
-
+
+        as_value val = pop_stack();
+               as_object *object = val.to_object().get();
+
+        if (!object) {
+            log_error("Expected object on stack, but none found (%s)!",
+                    val);
+            break;
+        }
+
+               object->set_member(name, value, ns, false);
                break;
        }
 /// 0x62 ABC_ACTION_GETLOCAL

=== modified file 'libcore/vm/action.cpp'
--- a/libcore/vm/action.cpp     2009-02-25 22:33:03 +0000
+++ b/libcore/vm/action.cpp     2009-04-01 07:00:32 +0000
@@ -48,12 +48,12 @@
 
 /// @param this_ptr     this is ourself.
 as_value
-call_method(const as_value& method, as_environment* env, as_object* this_ptr,
+call_method(const as_value& method, const as_environment& env, as_object* 
this_ptr,
         std::auto_ptr< std::vector<as_value> > args, as_object* super,
         const movie_definition* callerDef)
 {
        as_value val;
-       fn_call call(this_ptr, *env, args);
+       fn_call call(this_ptr, env, args);
        call.super = super;
     call.callerDef = callerDef;
 
@@ -83,7 +83,8 @@
        return val;
 }
 
-as_value call_method0( const as_value& method, as_environment* env,
+as_value
+call_method0(const as_value& method, const as_environment& env,
         as_object* this_ptr)
 {
     // TODO: avoid allocating a vector here

=== modified file 'libcore/vm/action.h'
--- a/libcore/vm/action.h       2009-02-25 22:33:03 +0000
+++ b/libcore/vm/action.h       2009-04-01 07:00:32 +0000
@@ -40,14 +40,16 @@
        //
 
        // Dispatching methods from C++.
-       as_value        call_method0(const as_value& method, as_environment* 
env, as_object* this_ptr);
+       as_value call_method0(const as_value& method,
+            const as_environment& env, as_object* this_ptr);
 
        /// Call a method, be it an as_function or a c_function. 
        //
        /// This is a thin wrapper around operator() and fn_call,
        /// probably worth dropping.
        ///
-       DSOEXPORT as_value call_method(const as_value& method, as_environment* 
env,
+       DSOEXPORT as_value call_method(const as_value& method,
+            const as_environment& env,
         // this is ourself
                as_object* this_ptr,
                std::auto_ptr<std::vector<as_value> > args,

=== modified file 'libcore/vm/fn_call.h'
--- a/libcore/vm/fn_call.h      2009-03-05 16:00:37 +0000
+++ b/libcore/vm/fn_call.h      2009-04-01 07:00:32 +0000
@@ -83,7 +83,7 @@
        {
        }
 
-       fn_call(as_object* this_in, as_environment& env_in,
+       fn_call(as_object* this_in, const as_environment& env_in,
                        int nargs_in, size_t first_in, as_object* sup = 0)
                :
                this_ptr(this_in),
@@ -96,7 +96,7 @@
                readArgs(env_in, first_in, nargs);
        }
 
-       fn_call(as_object* this_in, as_environment& env_in,
+       fn_call(as_object* this_in, const as_environment& env_in,
                        std::auto_ptr<std::vector<as_value> > args, as_object* 
sup = 0)
                :
                this_ptr(this_in),
@@ -108,7 +108,7 @@
        {
        }
 
-       fn_call(as_object* this_in, as_environment& env_in)
+       fn_call(as_object* this_in, const as_environment& env_in)
                :
                this_ptr(this_in),
                super(0),
@@ -154,7 +154,7 @@
                --nargs;
        }
 
-       as_environment& env() const
+       const as_environment& env() const
        {
                return _env;
        }
@@ -193,12 +193,12 @@
 
        /// The ActionScript environment in which the function call is taking
        /// place. This contains, among other things, the function arguments.
-       as_environment& _env;
+       const as_environment& _env;
 
        /// The actual arguments
        std::auto_ptr< std::vector<as_value> > _args;
 
-       void readArgs(as_environment& env, int first_in, int nargs)
+       void readArgs(const as_environment& env, int first_in, int nargs)
        {
                _args.reset(new std::vector<as_value>);
                for (int i=0; i<nargs; ++i)

=== modified file 'macros/pthreads.m4'
--- a/macros/pthreads.m4        2009-03-30 23:35:25 +0000
+++ b/macros/pthreads.m4        2009-03-31 19:26:23 +0000
@@ -57,7 +57,7 @@
 dnl which indicates that we try without any flags at all, and "pthread-config"
 dnl which is a program returning the flags for the Pth emulation library.
 
-pthread_flags="pthreads none lthread -pthread -pthreads -mthreads pthread 
--thread-safe -mt pthread-config pth-config"
+pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads 
-mthreads pthread --thread-safe -mt pthread-config pth-config"
 
 dnl When cross configuring, we're always using GCC, and we always have a 
platform
 dnl with pthreads in that case, but it's often sonewhere non-standard, so

=== modified file 'utilities/processor.cpp'
--- a/utilities/processor.cpp   2009-02-25 22:33:03 +0000
+++ b/utilities/processor.cpp   2009-04-01 12:26:49 +0000
@@ -28,6 +28,7 @@
 # include "gst/MediaHandlerGst.h"
 #endif
 
+#include <ios>
 #include <iostream>
 #include <cstdio>
 #include <cstdlib>
@@ -211,6 +212,8 @@
 int
 main(int argc, char *argv[])
 {
+    std::ios::sync_with_stdio(false);
+
     /// Initialize gnash core library
     gnashInit();
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]