[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10759: Speed up logging, add extra
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10759: Speed up logging, add extra logging levels (for AVM2). |
Date: |
Wed, 01 Apr 2009 16:01:00 +0200 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10759
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: 10758.1.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: 10758.1.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: 10758.1.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: 10758.1.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-02-25 22:33:03 +0000
+++ b/libbase/log.cpp 2009-04-01 11:29: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,7 +118,7 @@
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());
}
@@ -190,19 +184,17 @@
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 << "\n";
} else {
- cout << msg << endl;
+ cout << msg << "\n";
}
}
@@ -212,10 +204,10 @@
}
}
-void
+inline void
LogFile::log(const std::string& label, const std::string& msg)
{
- log(label+std::string(": ")+msg);
+ log(label + ": " + msg);
}
void
@@ -228,12 +220,12 @@
void
LogFile::setWriteDisk(bool use)
{
- if ( ! use ) closeLog();
+ if (!use) closeLog();
_write = use;
}
// Default constructor
-LogFile::LogFile ()
+LogFile::LogFile()
:
_verbose(0),
_actiondump(false),
@@ -251,7 +243,7 @@
}
bool
-LogFile::openLogIfNeeded ()
+LogFile::openLogIfNeeded()
{
if (_state != CLOSED) return true;
if (!_write) return false;
@@ -264,7 +256,7 @@
}
bool
-LogFile::openLog (const std::string& filespec)
+LogFile::openLog(const std::string& filespec)
{
// NOTE:
@@ -275,28 +267,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) {
@@ -309,10 +300,10 @@
}
bool
-LogFile::removeLog (void)
+LogFile::removeLog()
{
if (_state == OPEN) {
- _outstream.close ();
+ _outstream.close();
}
// Ignore the error, we don't care
@@ -322,28 +313,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-02-25 22:33:03 +0000
+++ b/libbase/log.h 2009-04-01 11:29:07 +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,17 @@
};
+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);
+
/// This heap of steaming preprocessor code magically converts
/// printf-style statements into boost::format messages using templates.
//
@@ -225,44 +243,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)
+#define LOG_TYPES (error) (debug) (unimpl) (aserror) (swferror) \
+ (amferror) (security) (action) (parse) (trace)
/// 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,24 +300,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);
-
-/// 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
@@ -304,7 +307,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
@@ -386,7 +390,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-23 07:40:22 +0000
+++ b/libcore/MovieClip.cpp 2009-04-01 07:00:32 +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-10 15:38:43 +0000
+++ b/libcore/as_object.cpp 2009-04-01 07:00:32 +0000
@@ -1154,7 +1154,7 @@
if (get_member(id.functionKey(), &event_handler) )
{
- call_method0(event_handler, NULL, this);
+ call_method0(event_handler, as_environment(_vm), this);
return true;
}
@@ -1181,7 +1181,7 @@
as_environment env(_vm);
- return call_method0(method, &env, this);
+ return call_method0(method, env, this);
}
as_value
@@ -1199,7 +1199,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
@@ -1219,7 +1219,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
@@ -1241,7 +1241,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;
}
@@ -1265,7 +1265,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-17 11:39:48 +0000
+++ b/libcore/as_value.cpp 2009-04-01 07:00:32 +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/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/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/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 '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();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10759: Speed up logging, add extra logging levels (for AVM2).,
Benjamin Wolsey <=