[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/vm/ASHandlers.cpp
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] gnash ChangeLog server/vm/ASHandlers.cpp |
Date: |
Thu, 22 May 2008 15:32:53 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Benjamin Wolsey <bwy> 08/05/22 15:32:53
Modified files:
. : ChangeLog
server/vm : ASHandlers.cpp
Log message:
* server/vm/ASHandlers.cpp: partial revert of last commit,
restricted
to dropping using namespace std, const correcting some
variables,
and as an extra using boost::lexical_cast not as_value for
converting ints to strings. The changes to take some variables
by reference and to logging have been reverted for now.
There were a couple of errors in the reverted commit that
would have led to undefined behaviour, but correcting them
still failed the swfdec testsuite. I'll have to look at
the logging changes as well as a possible cause, so will
deal with it incrementally. This commit passes the testsuite
for me.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6677&r2=1.6678
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.238&r2=1.239
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6677
retrieving revision 1.6678
diff -u -b -r1.6677 -r1.6678
--- ChangeLog 22 May 2008 11:36:00 -0000 1.6677
+++ ChangeLog 22 May 2008 15:32:52 -0000 1.6678
@@ -1,3 +1,11 @@
+2008-05-22 Benjamin Wolsey <address@hidden>
+
+ * server/vm/ASHandlers.cpp: partial revert of last commit, restricted
+ to dropping using namespace std, const correcting some variables,
+ and as an extra using boost::lexical_cast not as_value for
+ converting ints to strings. The changes to take some variables
+ by reference and to logging have been reverted for now.
+
2008-05-22 Sandro Santilli <address@hidden>
* testsuite/swfdec/PASSING: color-setTransform-full.swf passes
Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.238
retrieving revision 1.239
diff -u -b -r1.238 -r1.239
--- server/vm/ASHandlers.cpp 21 May 2008 21:41:27 -0000 1.238
+++ server/vm/ASHandlers.cpp 22 May 2008 15:32:53 -0000 1.239
@@ -53,13 +53,16 @@
#include <unistd.h> // For write() on BSD
#include <string>
+#include <map>
+#include <set>
#include <vector>
+#include <utility> // for std::pair
#include <locale>
#include <cerrno>
#include <boost/scoped_array.hpp>
#include <boost/random.hpp>
#include <boost/algorithm/string/replace.hpp>
-
+#include <boost/lexical_cast.hpp>
namespace {
#ifdef USE_DEBUGGER
@@ -166,6 +169,7 @@
SWFHandlers::SWFHandlers()
{
+// GNASH_REPORT_FUNCTION;
using std::string;
@@ -606,7 +610,7 @@
// and use tag length as maxlen
//size_t tag_length = code.read_int16(pc+1);
const char* url = code.read_string(pc+3);
- const size_t url_len = strlen(url)+1;
+ size_t url_len = strlen(url)+1;
const char* target = code.read_string(pc+3+url_len);
IF_VERBOSE_ACTION (
@@ -627,7 +631,7 @@
assert( code[thread.pc] == SWF::ACTION_WAITFORFRAME );
// SWF integrity check
- const size_t tag_len = code.read_int16(thread.pc+1);
+ size_t tag_len = code.read_int16(thread.pc+1);
if ( tag_len != 3 )
{
IF_VERBOSE_MALFORMED_SWF (
@@ -639,8 +643,8 @@
// If we haven't loaded a specified frame yet, then
// skip the specified number of actions.
//
- const unsigned int framenum = code.read_int16(thread.pc+3);
- const boost::uint8_t skip = code[thread.pc+5];
+ unsigned int framenum = code.read_int16(thread.pc+3);
+ boost::uint8_t skip = code[thread.pc+5];
character* target = env.get_target();
sprite_instance* target_sprite = target->to_movie();
@@ -657,7 +661,7 @@
assert(target_sprite->get_loaded_frames() >= framenum);
#endif
- const size_t lastloaded = target_sprite->get_loaded_frames();
+ size_t lastloaded = target_sprite->get_loaded_frames();
if ( lastloaded < framenum )
{
//log_debug(_("%s: frame %u not reached yet (loaded %u),
skipping next %u actions"), __FUNCTION__, framenum, lastloaded, skip);
@@ -676,12 +680,12 @@
//as_environment& env = thread.env;
const action_buffer& code = thread.code;
- const size_t pc = thread.pc;
+ size_t pc = thread.pc;
assert(code[pc] == SWF::ACTION_SETTARGET); // 0x8B
// Change the movie we're working on.
- const std::string target_name ( code.read_string(pc+3) );
+ std::string target_name ( code.read_string(pc+3) );
CommonSetTarget(thread, target_name);
}
@@ -785,8 +789,8 @@
thread.ensureStack(2);
- const as_value& op1 = env.top(0);
- const as_value& op2 = env.top(1);
+ as_value& op1 = env.top(0);
+ as_value& op2 = env.top(1);
env.top(1).set_bool(op1.to_number() == op2.to_number());
@@ -991,7 +995,7 @@
thread.ensureStack(1); // variable name
as_value& top_value = env.top(0);
- const std::string var_string = top_value.to_string();
+ std::string var_string = top_value.to_string();
if ( var_string.empty() )
{
top_value.set_undefined();
@@ -1003,7 +1007,8 @@
IF_VERBOSE_ACTION
(
log_action(_("-- get var: %s=%s"),
- var_string, top_value);
+ var_string.c_str(),
+ top_value.to_debug_string().c_str());
);
#ifdef USE_DEBUGGER
debugger.matchWatchPoint(var_string, Debugger::READS);
@@ -1024,7 +1029,7 @@
thread.setVariable(name, env.top(0));
IF_VERBOSE_ACTION (
- log_action(_("-- set var: %s = %s"), name, env.top(0));
+ log_action(_("-- set var: %s = %s"), name.c_str(),
env.top(0).to_debug_string().c_str());
);
// TODO: move this to ActionExec::setVariable !
@@ -1077,8 +1082,8 @@
thread.ensureStack(2); // prop num, target
- const as_value& tgt_val = env.top(1);
- const std::string tgt_str = tgt_val.to_string();
+ as_value& tgt_val = env.top(1);
+ std::string tgt_str = tgt_val.to_string();
character *target = NULL;
if ( tgt_str.empty() )
{
@@ -1096,7 +1101,7 @@
{
target = env.find_target(tgt_str);
}
- unsigned int prop_number = static_cast<unsigned
int>(env.top(0).to_number());
+ unsigned int prop_number = (unsigned int)env.top(0).to_number();
if (target)
{
if ( prop_number < get_property_names().size() )
@@ -1105,7 +1110,7 @@
// TODO: check if get_propery_names() can return a
string
// directly.
assert( get_property_names().size() );
- const std::string propname =
get_property_names()[prop_number].c_str();
+ std::string propname =
get_property_names()[prop_number].c_str();
//target->get_member(propname &val);
thread.getObjectMember(*target, propname, val);
env.top(1) = val;
@@ -1122,7 +1127,7 @@
// ASCODING error ? (well, last time it was a gnash error ;)
IF_VERBOSE_ASCODING_ERRORS (
log_aserror(_("Could not find GetProperty target (%s)"),
- tgt_val);
+ tgt_val.to_debug_string().c_str());
);
env.top(1) = as_value();
}
@@ -1138,15 +1143,15 @@
thread.ensureStack(3); // prop val, prop num, target
character *target = env.find_target(env.top(2).to_string());
- const unsigned int prop_number = static_cast<unsigned
int>(env.top(1).to_number());
- const as_value& prop_val = env.top(0);
+ unsigned int prop_number = (unsigned int)env.top(1).to_number();
+ as_value prop_val = env.top(0);
if (target) {
// set_property(target, prop_number, env.top(0));
if ( prop_number < get_property_names().size() )
{
// TODO: check if get_property_names() return a string&
- const std::string member_name = get_property_names()[prop_number];
+ std::string member_name = get_property_names()[prop_number].c_str();
thread.setObjectMember(*target, member_name, prop_val);
}
else
@@ -1162,7 +1167,7 @@
{
IF_VERBOSE_ASCODING_ERRORS (
log_aserror(_("ActionSetProperty: can't find target %s for setting
property %s"),
- env.top(2), get_property_names()[prop_number]);
+ env.top(2).to_debug_string().c_str(),
get_property_names()[prop_number].c_str());
)
}
@@ -1177,7 +1182,7 @@
thread.ensureStack(3);
- const int depth =
int(env.top(0).to_number())+character::staticDepthOffset; // TODO: use to_int ?
+ int depth = int(env.top(0).to_number())+character::staticDepthOffset;
// TODO: use to_int ?
const std::string& newname = env.top(1).to_string();
const std::string& path = env.top(2).to_string();
@@ -1186,7 +1191,7 @@
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Path given to duplicateMovieClip(%s) doesn't
point to a character"),
- path);
+ path.c_str());
);
env.drop(3);
return;
@@ -1197,7 +1202,7 @@
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Path given to duplicateMovieClip(%s) is not a
sprite"),
- path);
+ path.c_str());
);
env.drop(3);
return;
@@ -1215,14 +1220,14 @@
thread.ensureStack(1);
- const std::string path = env.pop().to_string();
+ std::string path = env.pop().to_string();
character* ch = env.find_target(path);
if ( ! ch )
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Path given to removeMovieClip(%s) doesn't point
to a character"),
- path);
+ path.c_str());
);
return;
}
@@ -1232,7 +1237,7 @@
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Path given to removeMovieClip(%s) is not a
sprite"),
- path);
+ path.c_str());
);
return;
}
@@ -1250,8 +1255,8 @@
thread.ensureStack(1);
//std::string val =
env.pop().to_string_versioned(VM::get().getSWFVersion(), &env);
- const std::string val = env.pop().to_string();
- log_trace("%s", val);
+ std::string val = env.pop().to_string();
+ log_trace("%s", val.c_str());
}
void
@@ -1277,7 +1282,7 @@
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("startDrag: unknown target '%s'"),
- env.top(0));
+ env.top(0).to_debug_string().c_str());
);
}
@@ -1383,8 +1388,8 @@
{
IF_VERBOSE_ASCODING_ERRORS (
log_aserror(_("-- %s cast_to %s (invalid args?)"),
- env.top(1),
- env.top(0));
+ env.top(1).to_debug_string().c_str(),
+ env.top(0).to_debug_string().c_str());
);
env.drop(1);
@@ -1402,7 +1407,11 @@
env.top(0).set_null(); // null, not undefined.
}
- LOG_ONCE(log_debug(_("ActionCastOp TESTING")));
+ static bool warned=false;
+ if ( ! warned ) {
+ log_debug(_("ActionCastOp TESTING"));
+ warned=true;
+ }
}
void
@@ -1414,7 +1423,7 @@
thread.ensureStack(2);
- const as_value objval = env.pop();
+ as_value objval = env.pop();
as_object *obj = objval.to_object().get();
int count = static_cast<int>(env.pop().to_number());
as_value a(1);
@@ -1423,7 +1432,7 @@
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Stack value on IMPLEMENTSOP is not an object:
%s."),
- objval);
+ objval.to_debug_string().c_str());
);
return;
}
@@ -1486,7 +1495,8 @@
IF_VERBOSE_ACTION(
log_action("%s (with .prototype %p) implements %s (with
.prototype %p)",
- objval, static_cast<void*>(obj), ctorval,
static_cast<void*>(inter));
+ objval.to_debug_string(), (void*)obj,
ctorval.to_debug_string(),
+ (void*)inter);
);
obj->add_interface(inter);
}
@@ -1501,13 +1511,13 @@
as_environment& env = thread.env;
- unsigned int off = 0;
+ unsigned int off=0;
thread.ensureStack(1); // nargs
- const unsigned int nargs = env.top(off++).to_int();
+ unsigned int nargs = env.top(off++).to_int();
thread.ensureStack(off+nargs+1); // nargs, cmdname, actual args
- const std::string cmd = env.top(off++).to_string();
+ std::string cmd = env.top(off++).to_string();
std::stringstream ss;
ss << cmd << "(";
@@ -1657,7 +1667,7 @@
as_environment& env = thread.env;
thread.ensureStack(1);
- const std::string& str = env.top(0).to_string();
+ std::string str = env.top(0).to_string();
if (str.empty())
{
@@ -1684,7 +1694,7 @@
const int version = env.get_version();
- const std::string& str = env.top(0).to_string();
+ std::string str = env.top(0).to_string();
if (str.empty())
{
@@ -1692,7 +1702,7 @@
return;
}
- const std::wstring& wstr = utf8::decodeCanonicalString(str, version);
+ std::wstring wstr = utf8::decodeCanonicalString(str, version);
// decodeCanonicalString should correctly work out what the first character
// is according to version.
@@ -1707,7 +1717,7 @@
thread.ensureStack(1);
// Only handles values up to 65535
- const boost::uint16_t c =
static_cast<boost::uint16_t>(env.top(0).to_int());
+ boost::uint16_t c = static_cast<boost::uint16_t>(env.top(0).to_int());
// If the argument to chr() is '0', we return
// nothing, not NULL
@@ -1761,7 +1771,7 @@
as_value& string_val = env.top(2);
IF_VERBOSE_ACTION(
- log_action(" ActionMbSubString(%s, %d, %d)", string_val, start, size);
+ log_action(" ActionMbSubString(%s, %d, %d)",
string_val.to_debug_string().c_str(), start, size);
);
env.drop(2);
@@ -1885,7 +1895,7 @@
// Cut to uint16, as characters above 65535 'wrap around'
const boost::uint16_t i = static_cast<boost::uint16_t>
(env.top(0).to_int());
- const std::string out = utf8::encodeUnicodeCharacter(i);
+ std::string out = utf8::encodeUnicodeCharacter(i);
/// Always valid, or can it be undefined?
env.top(0).set_string(out);
@@ -1903,7 +1913,7 @@
thread.ensureStack(1); // expression
// how many actions to skip if frame has not been loaded
- const boost::uint8_t skip = code[thread.pc+3];
+ boost::uint8_t skip = code[thread.pc+3];
// env.top(0) contains frame specification,
// evaluated as for ActionGotoExpression
@@ -1925,7 +1935,7 @@
log_aserror(_("Frame spec found on stack "
"at ActionWaitForFrame doesn't evaluate "
"to a valid frame: %s"),
- framespec);
+ framespec.to_debug_string().c_str());
);
return;
}
@@ -1935,7 +1945,7 @@
assert(target_sprite->get_loaded_frames() >= framenum);
#endif
- const size_t lastloaded = target_sprite->get_loaded_frames();
+ size_t lastloaded = target_sprite->get_loaded_frames();
if ( lastloaded < framenum )
{
//log_debug(_("ActionWaitForFrameExpression: frame %u not
reached yet (loaded %u), skipping next %u actions"), framenum, lastloaded,
skip);
@@ -1981,8 +1991,8 @@
const action_buffer& code = thread.code;
- const size_t pc = thread.pc;
- const boost::int16_t length = code.read_int16(pc+1);
+ size_t pc = thread.pc;
+ boost::int16_t length = code.read_int16(pc+1);
assert( length >= 0 );
#if 0 // is this really useful ?
@@ -2088,7 +2098,7 @@
case pushDouble: // 6
{
- const double d = code.read_double_wacky(i+3);
+ double d = code.read_double_wacky(i+3);
i += 8;
env.push(d);
break;
@@ -2096,7 +2106,7 @@
case pushInt32: // 7
{
- const boost::int32_t val = code.read_int32(i+3);
+ boost::int32_t val = code.read_int32(i+3);
i += 4;
env.push(val);
break;
@@ -2106,7 +2116,7 @@
{
id = code[3 + i];
i++;
- if ( id <
static_cast<int>(code.dictionary_size()) )
+ if ( id < (int) code.dictionary_size() )
{
env.push( code.dictionary_get(id) );
}
@@ -2125,7 +2135,7 @@
{
id = code.read_int16(i+3);
i += 2;
- if ( id <
static_cast<int>(code.dictionary_size()) )
+ if ( id < (int) code.dictionary_size() )
{
env.push( code.dictionary_get(id) );
}
@@ -2144,11 +2154,11 @@
IF_VERBOSE_ACTION (
if ( type == pushDict8 || type == pushDict16 )
{
- log_action(_("\t%d) type=%s (%d), value=%s"), count,
pushType[type], id, env.top(0));
+ log_action(_("\t%d) type=%s (%d), value=%s"), count,
pushType[type], id, env.top(0).to_debug_string().c_str());
}
else
{
- log_action(_("\t%d) type=%s, value=%s"), count,
pushType[type], env.top(0));
+ log_action(_("\t%d) type=%s, value=%s"), count,
pushType[type], env.top(0).to_debug_string().c_str());
}
++count;
);
@@ -2160,7 +2170,7 @@
{
// GNASH_REPORT_FUNCTION;
- const boost::int16_t offset = thread.code.read_int16(thread.pc+3);
+ boost::int16_t offset = thread.code.read_int16(thread.pc+3);
thread.next_pc += offset;
// @@ TODO range checks
}
@@ -2267,15 +2277,13 @@
// The base url must be set with the set_base_url() command.
//
- const std::string url_s(url_c);
+ std::string url_s(url_c);
const URL& baseurl = get_base_url();
URL url(url_s, baseurl);
- log_debug(_("get url: target=%s, url=%s (%s), method=%x (sendVars:%X,
loadTarget:%d, loadVariable:%d)"),
- target_string, url.str(),
- url_c, static_cast<int>(method), sendVarsMethod,
- loadTargetFlag, loadVariableFlag);
+ log_debug(_("get url: target=%s, url=%s (%s), method=%x (sendVars:%X,
loadTarget:%d, loadVariable:%d)"), target_string.c_str(),
+ url.str().c_str(), url_c, (int)method, sendVarsMethod,
loadTargetFlag, loadVariableFlag);
if ( ! URLAccessManager::allow(url) )
{
@@ -2318,14 +2326,16 @@
if ( ! target_ch )
{
- log_error(_("get url: target %s not found"),
target_string);
+ log_error(_("get url: target %s not found"),
+ target_string.c_str());
// might want to invoke the external url opener here...
return;
}
if ( ! target_movie )
{
- log_error(_("get url: target %s is not a sprite"),
target_string);
+ log_error(_("get url: target %s is not a sprite"),
+ target_string.c_str());
// might want to invoke the external url opener here...
return;
}
@@ -2364,7 +2374,8 @@
}
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("Unknown loadMovie target: %s"),
target_string);
+ log_aserror(_("Unknown loadMovie target: %s"),
+ target_string.c_str());
);
// TESTED: Even if the target is created right-after
@@ -2378,7 +2389,8 @@
if ( ! target_movie )
{
- log_error(_("get url: target %s is not a sprite"),
target_string);
+ log_error(_("get url: target %s is not a sprite"),
+ target_string.c_str());
return;
}
@@ -2421,7 +2433,7 @@
log_unimpl (_("POST with host-provided uri grabber"));
}
- const int hostfd = VM::get().getRoot().getHostFD();
+ int hostfd = VM::get().getRoot().getHostFD();
if ( hostfd == -1 )
{
gnash::RcInitFile& rcfile =
gnash::RcInitFile::getDefaultInstance();
@@ -2463,13 +2475,13 @@
boost::replace_all(command, "%u", safeurl);
- log_debug (_("Launching URL... %s"), command);
+ log_debug (_("Launching URL... %s"), command.c_str());
system(command.c_str());
}
else
{
//log_debug("user-provided host requests fd is %d", hostfd);
- std::ostringstream request;
+ std::stringstream request;
// use the original url, non parsed (the browser will know
better how to resolve relative urls and handle hactionscript)
//request << "GET " << url << endl;
@@ -2477,7 +2489,7 @@
std::string requestString = request.str();
const char* cmd = requestString.c_str();
- const size_t len = requestString.length();
+ size_t len = requestString.length();
// TODO: should mutex-protect this ?
// NOTE: we assuming the hostfd is set in blocking mode here..
log_debug("Attempt to write geturl requests fd %d", hostfd);
@@ -2486,7 +2498,7 @@
{
log_error("Could not write to user-provided host
requests fd %d: %s", hostfd, std::strerror(errno));
}
- if ( static_cast<size_t>(ret) < len )
+ if ( (size_t)ret < len )
{
log_error("Could only write %d bytes over %d required
to user-provided host requests fd %d",
ret, len, hostfd);
@@ -2520,7 +2532,8 @@
IF_VERBOSE_ASCODING_ERRORS (
log_aserror(
_("Couldn't find movie \"%s\" to set target to!"
- " Resetting to original target..."), target_name);
+ " Resetting to original target..."),
+ target_name.c_str());
);
return;
}
@@ -2542,9 +2555,9 @@
assert( code[thread.pc] == SWF::ACTION_GETURL2 );
- const boost::uint8_t method = code[thread.pc + 3];
+ boost::uint8_t method = code[thread.pc + 3];
- const as_value& url_val = env.top(1);
+ as_value url_val = env.top(1);
if ( url_val.is_undefined() )
{
log_error(_("Undefined GetUrl2 url on stack, skipping"));
@@ -2566,15 +2579,15 @@
// Alias these
as_environment& env = thread.env;
const action_buffer& code = thread.code;
- const size_t& pc = thread.pc;
+ size_t& pc = thread.pc;
size_t& next_pc = thread.next_pc;
- const size_t& stop_pc = thread.stop_pc;
+ size_t& stop_pc = thread.stop_pc;
assert( code[pc] == SWF::ACTION_BRANCHIFTRUE );
thread.ensureStack(1); // bool
- const boost::int16_t offset = code.read_int16(pc+3);
+ boost::int16_t offset = code.read_int16(pc+3);
bool test = env.pop().to_bool();
if (test)
@@ -2625,7 +2638,8 @@
IF_VERBOSE_ASCODING_ERRORS (
log_aserror(_(
"Couldn't find target_sprite \"%s\" in ActionCallFrame!"
- " target frame actions will not be called..."),
target_path);
+ " target frame actions will not be called..."),
+ target_path.c_str());
)
}
@@ -2642,7 +2656,7 @@
thread.ensureStack(1); // expression
const action_buffer& code = thread.code;
- const size_t pc = thread.pc;
+ size_t pc = thread.pc;
// From Alexi's SWF ref:
@@ -2657,10 +2671,10 @@
// that frame is reached. Otherwise, the
// frame is shown in stop mode.
- const unsigned char play_flag = code[pc + 3];
+ unsigned char play_flag = code[pc + 3];
sprite_instance::play_state state = play_flag ? sprite_instance::PLAY :
sprite_instance::STOP;
- const std::string& target_frame = env.pop().to_string();
+ std::string target_frame = env.pop().to_string();
std::string target_path;
std::string frame_var;
@@ -2687,7 +2701,8 @@
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Frame spec found on stack "
"at ActionGotoExpression doesn't evaluate "
- "to a valid frame: %s"), target_frame);
+ "to a valid frame: %s"),
+ target_frame.c_str());
);
return;
}
@@ -2699,7 +2714,8 @@
IF_VERBOSE_ASCODING_ERRORS (
log_aserror(_(
"Couldn't find target sprite \"%s\" in
ActionGotoExpression. "
- " Will not go to target frame..."), target_frame);
+ " Will not go to target frame..."),
+ target_frame.c_str());
)
}
}
@@ -2723,8 +2739,8 @@
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror("delete %s.%s : first element is not an object",
- env.top(1),
- env.top(0));
+ env.top(1).to_debug_string().c_str(),
+ env.top(0).to_debug_string().c_str());
);
env.top(1).set_bool(false);
env.drop(1);
@@ -2759,12 +2775,12 @@
as_environment& env = thread.env;
thread.ensureStack(2); // value, var
- const as_value& value = env.top(0);
- const as_value& varname = env.top(1);
+ as_value& value = env.top(0);
+ as_value& varname = env.top(1);
thread.setLocalVariable(varname.to_string(), value);
IF_VERBOSE_ACTION (
- log_action(_("-- set local var: %s = %s"), varname.to_string(), value);
+ log_action(_("-- set local var: %s = %s"), varname.to_string().c_str(),
value.to_debug_string().c_str());
);
env.drop(2);
@@ -2779,7 +2795,7 @@
thread.ensureStack(2); // func name, nargs
- //log_debug("ActionCallFunction: %s", env.top(0));
+ //log_debug("ActionCallFunction: %s",
env.top(0).to_debug_string().c_str());
//cerr << "At ActionCallFunction enter:"<<endl;
//env.dump_stack();
@@ -2900,8 +2916,8 @@
thread.ensureStack(2); // x, ,y
as_value result;
- double y = env.pop().to_number();
- double x = env.pop().to_number();
+ const double y = env.pop().to_number();
+ const double x = env.pop().to_number();
// Don't need to check for y being 0 here - if it's zero, fmod returns NaN
// which is what flash would do too
result = fmod(x, y);
@@ -2924,7 +2940,7 @@
IF_VERBOSE_ACTION (
log_action(_("---new object: %s"),
- classname);
+ classname.c_str());
);
unsigned nargs = unsigned(env.pop().to_number());
@@ -2992,28 +3008,21 @@
thread.ensureStack(1); // array size name
- int array_size = env.pop().to_int();
+ const int array_size = env.pop().to_int();
assert(array_size >= 0);
- thread.ensureStack((unsigned int)array_size); // array elements
-
- //log_debug(_("xxx init array: size = %d, top of stack = %d"), array_size,
env.get_top_index());//xxxxx
+ thread.ensureStack(static_cast<unsigned int>(array_size)); // array
elements
// Call the array constructor, to create an empty array.
- as_value result;
- result = array_new(fn_call(NULL, &env, 0, env.get_top_index()));
+ as_value result = array_new(fn_call(NULL, &env, 0, env.get_top_index()));
boost::intrusive_ptr<as_object> ao = result.to_object();
assert(ao);
// Fill the elements with the initial values from the stack.
- as_value index_number;
for (int i = 0; i < array_size; i++) {
// @@ TODO a set_member that takes an int or as_value?
- // @@ TODO: don'e use as_value for converting a number to a string !!
- index_number.set_int(i);
- //ao->set_member(index_number.to_string(), env.pop());
- thread.setObjectMember(*ao, index_number.to_string(), env.pop());
+ thread.setObjectMember(*ao, boost::lexical_cast<std::string>(i),
env.pop());
}
env.push(result);
@@ -3095,7 +3104,7 @@
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Argument to TargetPath(%s) doesn't cast to a
MovieClip"),
- env.top(0));
+ env.top(0).to_debug_string().c_str());
);
env.top(0).set_undefined();
}
@@ -3133,7 +3142,8 @@
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Top of stack doesn't evaluate to an object (%s)
at "
- "ActionEnumerate execution"), var_name);
+ "ActionEnumerate execution"),
+ var_name.to_debug_string().c_str());
);
return;
}
@@ -3162,26 +3172,27 @@
catch (ActionTypeError& e)
{
log_debug("%s.to_primitive() threw an error during
ActionNewAdd",
- env.top(0));
+ env.top(0).to_debug_string().c_str());
}
try { v2 = v2.to_primitive(); }
catch (ActionTypeError& e)
{
log_debug("%s.to_primitive() threw an error during
ActionNewAdd",
- env.top(1));
+ env.top(1).to_debug_string().c_str());
}
assert( stackSize == env.stack_size() );
#if GNASH_DEBUG
log_debug(_("ActionNewAdd(%s, %s) [primitive conversion done]"),
- v1, v2);
+ v1.to_debug_string().c_str(),
+ v2.to_debug_string().c_str());
#endif
if (v1.is_string() || v2.is_string() )
{
- int version = env.get_version();
+ const int version = env.get_version();
v2.convert_to_string_versioned(version);
v2.string_concat(v1.to_string_versioned(version));
env.top(1) = v2;
@@ -3189,9 +3200,9 @@
else
{
// use numeric semantic
- double v2num = v2.to_number();
+ const double v2num = v2.to_number();
//log_debug(_("v2 num = %g"), v2num);
- double v1num = v1.to_number();
+ const double v1num = v1.to_number();
//log_debug(_("v1 num = %g"), v1num);
v2.set_double(v2num + v1num);
@@ -3220,14 +3231,14 @@
catch (ActionTypeError& e)
{
log_debug("%s.to_primitive() threw an error during
ActionNewLessThen",
- op1_in);
+ op1_in.to_debug_string().c_str());
}
try { operand2 = op2_in.to_primitive(); }
catch (ActionTypeError& e)
{
log_debug("%s.to_primitive() threw an error during
ActionNewLessThen",
- op2_in);
+ op2_in.to_debug_string().c_str());
}
if ( operand1.is_string() && operand2.is_string() )
@@ -3236,8 +3247,8 @@
}
else
{
- double op1 = operand1.to_number();
- double op2 = operand2.to_number();
+ const double op1 = operand1.to_number();
+ const double op2 = operand2.to_number();
if ( isnan(op1) || isnan(op2) )
{
@@ -3269,7 +3280,7 @@
catch (ActionTypeError& e)
{
log_debug(_("to_primitive(%s) threw an ActionTypeError %s"),
- op1, e.what());
+ op1.to_debug_string().c_str(), e.what());
}
as_value op2 = env.top(1);
@@ -3277,7 +3288,7 @@
catch (ActionTypeError& e)
{
log_debug(_("to_primitive(%s) threw an ActionTypeError %s"),
- op2, e.what());
+ op2.to_debug_string().c_str(), e.what());
}
env.top(1).set_bool(op1.equals(op2));
@@ -3305,7 +3316,7 @@
// GNASH_REPORT_FUNCTION;
as_environment& env = thread.env;
thread.ensureStack(1);
- int version = env.get_version();
+ const int version = env.get_version();
env.top(0).convert_to_string_versioned(version);
}
@@ -3338,7 +3349,7 @@
thread.ensureStack(2); // member name, target
// Some corner case behaviors depend on the SWF file version.
- //int version = env.get_version();
+ //const int version = env.get_version();
as_value member_name = env.top(0);
as_value target = env.top(1);
@@ -3350,7 +3361,7 @@
log_aserror(_("getMember called against "
"a value that does not cast "
"to an as_object: %s"),
- target));
+ target.to_debug_string().c_str()));
env.top(1).set_undefined();
env.drop(1);
return;
@@ -3358,21 +3369,24 @@
IF_VERBOSE_ACTION (
log_action(_(" ActionGetMember: target: %s (object %p)"),
- target, static_cast<void*>(obj.get()));
+ target.to_debug_string().c_str(), (void*)obj.get());
);
if ( ! thread.getObjectMember(*obj, member_name.to_string(),
env.top(1)) )
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror("Reference to undefined member %s of object %s",
- member_name, target);
+ member_name.to_debug_string().c_str(),
+ target.to_debug_string().c_str());
);
env.top(1).set_undefined();
}
IF_VERBOSE_ACTION (
log_action(_("-- get_member %s.%s=%s"),
- target, member_name, env.top(1));
+ target.to_debug_string().c_str(),
+ member_name.to_debug_string().c_str(),
+ env.top(1).to_debug_string().c_str());
);
env.drop(1);
@@ -3397,7 +3411,9 @@
IF_VERBOSE_ACTION (
log_action(_("-- set_member %s.%s=%s"),
- env.top(2), member_name, member_value);
+ env.top(2).to_debug_string().c_str(),
+ member_name.c_str(),
+ member_value.to_debug_string().c_str());
);
}
else
@@ -3407,7 +3423,9 @@
IF_VERBOSE_ASCODING_ERRORS (
// Invalid object, can't set.
log_aserror(_("-- set_member %s.%s=%s on invalid
object!"),
- env.top(2), member_name, member_value);
+ env.top(2).to_debug_string().c_str(),
+ member_name.c_str(),
+ member_value.to_debug_string().c_str());
);
}
@@ -3445,7 +3463,7 @@
thread.ensureStack(3); // method_name, obj, nargs
// Some corner case behaviors depend on the SWF file version.
- //int version = env.get_version();
+ //const int version = env.get_version();
// Get name function of the method
as_value& method_name = env.top(0);
@@ -3468,8 +3486,8 @@
IF_VERBOSE_ACTION (
- log_action(_(" method name: %s"), method_name);
- log_action(_(" method object/func: %s"), obj_value);
+ log_action(_(" method name: %s"),
method_name.to_debug_string().c_str());
+ log_action(_(" method object/func: %s"),
obj_value.to_debug_string().c_str());
log_action(_(" method nargs: %d"), nargs);
);
@@ -3559,7 +3577,7 @@
log_debug(_("Function object given to ActionCallMethod"
" is not a function (%s), will try to
use"
" its 'constructor' member (but should
instead invoke it's [[Call]] method"),
- obj_value);
+ obj_value.to_debug_string().c_str());
//#endif
// TODO: all this crap should go into an
as_object::getConstructor instead
@@ -3593,7 +3611,7 @@
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("ActionCallMethod: "
"Tried to invoke method '%s' on non-object
value %s."),
- method_name,
+ method_name.to_debug_string().c_str(),
obj_value.typeOf());
);
env.drop(nargs+2);
@@ -3606,8 +3624,8 @@
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("ActionCallMethod: "
"Can't find method %s of object %s"),
- method_name,
- obj_value);
+ method_name.to_debug_string().c_str(),
+ obj_value.to_debug_string().c_str());
);
env.drop(nargs+2);
env.top(0).set_undefined(); // should we push an object
anyway ?
@@ -3701,7 +3719,7 @@
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("ActionNewMethod: "
"can't find method %s of object %s"),
- method_string, obj_val);
+ method_string.c_str(),
obj_val.to_debug_string().c_str());
);
env.drop(nargs);
env.push(as_value()); // should we push an object
anyway ?
@@ -3753,8 +3771,8 @@
if (!super || ! instance) {
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("-- %s instanceof %s (invalid args?)"),
- env.top(1),
- env.top(0));
+ env.top(1).to_debug_string().c_str(),
+ env.top(0).to_debug_string().c_str());
);
env.drop(1);
@@ -3788,7 +3806,7 @@
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Top of stack not an object %s at ActionEnum2 "
" execution"),
- obj_val);
+ obj_val.to_debug_string().c_str());
);
return;
}
@@ -3921,8 +3939,8 @@
}
else
{
- double op1 = operand1.to_number();
- double op2 = operand2.to_number();
+ const double op1 = operand1.to_number();
+ const double op2 = operand2.to_number();
if ( isnan(op1) || isnan(op2) )
{
@@ -3965,12 +3983,12 @@
if ( ! super )
{
log_aserror(_("ActionExtends: Super is not an
as_function (%s)"),
- env.top(0));
+ env.top(0).to_debug_string().c_str());
}
if ( ! sub )
{
log_aserror(_("ActionExtends: Sub is not an
as_function (%s)"),
- env.top(1));
+ env.top(1).to_debug_string().c_str());
}
);
env.drop(2);
@@ -4198,7 +4216,7 @@
}
pc += 2; // skip tag len
- const unsigned int block_length = code.read_int16(pc); // read 'with'
body size
+ unsigned block_length = code.read_int16(pc); // read 'with' body size
if ( block_length == 0 )
{
IF_VERBOSE_ASCODING_ERRORS(
@@ -4215,7 +4233,7 @@
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("with(%s) : first argument doesn't cast to an
object!"),
- with_obj_val);
+ with_obj_val.to_debug_string().c_str());
);
// skip the full block
thread.next_pc += block_length;
@@ -4223,7 +4241,7 @@
}
// where does the 'with' block ends ?
- const unsigned int block_end = thread.next_pc + block_length;
+ unsigned block_end = thread.next_pc + block_length;
if ( ! thread.pushWithEntry(with_stack_entry(with_obj, block_end)) )
{
@@ -4264,7 +4282,7 @@
//cerr << " name:" << name << endl;
// Get number of arguments.
- const unsigned int nargs = code.read_int16(i);
+ unsigned nargs = code.read_int16(i);
i += 2;
//cerr << " nargs:" << nargs << endl;
@@ -4282,7 +4300,7 @@
}
// Get the length of the actual function code.
- const boost::int16_t code_size = code.read_int16(i);
+ boost::int16_t code_size = code.read_int16(i);
//cerr << " code size:" << code_size << endl;
@@ -4345,7 +4363,7 @@
const action_buffer& code = thread.code;
- const unsigned int reg = code[thread.pc + 3];
+ unsigned int reg = code[thread.pc + 3];
// Save top of stack in specified register.
if ( thread.isFunction2() && env.num_local_registers() )
@@ -4356,7 +4374,7 @@
IF_VERBOSE_ACTION (
log_action(_("-------------- local register[%d] =
'%s'"),
- reg, env.top(0));
+ reg, env.top(0).to_debug_string().c_str());
);
}
else
@@ -4372,7 +4390,7 @@
IF_VERBOSE_ACTION (
log_action(_("-------------- global register[%d] = '%s'"),
- static_cast<unsigned int>(reg), env.top(0) );
+ (unsigned)reg, env.top(0).to_debug_string().c_str() );
);
}