[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/as_environment.cpp serve...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/as_environment.cpp serve... |
Date: |
Thu, 26 Apr 2007 17:06:11 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/04/26 17:06:11
Modified files:
. : ChangeLog
server : as_environment.cpp as_environment.h
as_value.cpp
server/vm : ASHandlers.cpp ActionExec.cpp ActionExec.h
testsuite/actionscript.all: Function.as
Log message:
* server/as_value.cpp (equals): compare m_object_value when both
operatns are either functions or objects.
* server/as_environment.{cpp,h} (get_variable, get_variable_raw,
findLocal): accept an additional argument to return the target
object the variable was found in.
* server/vm/ActionExec.{cpp,h}: provide an additional
getVariable
method accepting an as_object pointer to return the target
object
a variable was found in.
* server/vm/ASHandlers.cpp (ActionCallFunction): set the 'this'
pointer to the object found to contain the function.
* testsuite/actionscript.all/Function.as: more successes.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3010&r2=1.3011
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.cpp?cvsroot=gnash&r1=1.73&r2=1.74
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.h?cvsroot=gnash&r1=1.47&r2=1.48
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.cpp?cvsroot=gnash&r1=1.48&r2=1.49
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.100&r2=1.101
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ActionExec.cpp?cvsroot=gnash&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ActionExec.h?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Function.as?cvsroot=gnash&r1=1.44&r2=1.45
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3010
retrieving revision 1.3011
diff -u -b -r1.3010 -r1.3011
--- ChangeLog 26 Apr 2007 16:26:01 -0000 1.3010
+++ ChangeLog 26 Apr 2007 17:06:10 -0000 1.3011
@@ -1,5 +1,19 @@
2007-04-26 Sandro Santilli <address@hidden>
+ * server/as_value.cpp (equals): compare m_object_value when both
+ operatns are either functions or objects.
+ * server/as_environment.{cpp,h} (get_variable, get_variable_raw,
+ findLocal): accept an additional argument to return the target
+ object the variable was found in.
+ * server/vm/ActionExec.{cpp,h}: provide an additional getVariable
+ method accepting an as_object pointer to return the target object
+ a variable was found in.
+ * server/vm/ASHandlers.cpp (ActionCallFunction): set the 'this'
+ pointer to the object found to contain the function.
+ * testsuite/actionscript.all/Function.as: more successes.
+
+2007-04-26 Sandro Santilli <address@hidden>
+
* server/as_environment.cpp (get_variable_raw): elements of
the 'with' stack take precedence over locals.
See test in Function.as.
Index: server/as_environment.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.cpp,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -b -r1.73 -r1.74
--- server/as_environment.cpp 26 Apr 2007 16:26:01 -0000 1.73
+++ server/as_environment.cpp 26 Apr 2007 17:06:10 -0000 1.74
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: as_environment.cpp,v 1.73 2007/04/26 16:26:01 strk Exp $ */
+/* $Id: as_environment.cpp,v 1.74 2007/04/26 17:06:10 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -45,7 +45,7 @@
// Return the value of the given var, if it's defined.
as_value
as_environment::get_variable(const std::string& varname,
- const ScopeStack& with_stack) const
+ const ScopeStack& with_stack, as_object** retTarget) const
{
// Path lookup rigamarole.
std::string path;
@@ -63,6 +63,7 @@
if (target) {
as_value val;
target->get_member(var.c_str(), &val);
+ if ( retTarget ) *retTarget = target;
return val;
} else {
@@ -75,7 +76,7 @@
);
);
- as_value tmp = get_variable_raw(path, with_stack);
+ as_value tmp = get_variable_raw(path, with_stack, retTarget);
if ( ! tmp.is_undefined() )
{
IF_VERBOSE_ASCODING_ERRORS(
@@ -85,7 +86,7 @@
return as_value();
}
} else {
- return get_variable_raw(varname, with_stack);
+ return get_variable_raw(varname, with_stack, retTarget);
}
}
@@ -99,7 +100,7 @@
as_value
as_environment::get_variable_raw(
const std::string& varname,
- const ScopeStack& with_stack) const
+ const ScopeStack& with_stack, as_object** retTarget) const
// varname must be a plain variable name; no path parsing.
{
assert(strchr(varname.c_str(), ':') == NULL);
@@ -112,13 +113,14 @@
as_object* obj = const_cast<as_object*>(with_stack[i-1].object());
if (obj && obj->get_member(varname.c_str(), &val)) {
// Found the var in this context.
+ if ( retTarget ) *retTarget = obj;
return val;
}
}
// Check locals for getting them
//as_environment::frame_slot slot;
- if ( findLocal(varname, val, true) ) // do we really want to descend here
??
+ if ( findLocal(varname, val, true, retTarget) ) // do we really want to
descend here ??
{
return val;
}
@@ -126,17 +128,20 @@
// Check target members.
if (m_target->get_member(varname.c_str(), &val)) {
+ if ( retTarget ) *retTarget = m_target;
return val;
}
// Looking for "this"?
if (varname == "this") {
val.set_as_object(m_target);
+ if ( retTarget ) *retTarget = NULL; // correct ??
return val;
}
// Check built-in constants.
if (varname == "_root" || varname == "_level0") {
+ if ( retTarget ) *retTarget = NULL; // correct ??
return as_value(m_target->get_root_movie());
}
@@ -146,11 +151,13 @@
if ( vm.getSWFVersion() > 5 && varname == "_global" )
{
// The "_global" ref was added in SWF6
+ if ( retTarget ) *retTarget = NULL; // correct ??
return as_value(global);
}
if (global->get_member(varname.c_str(), &val))
{
+ if ( retTarget ) *retTarget = global;
return val;
}
@@ -922,10 +929,18 @@
/*private*/
bool
-as_environment::findLocal(const std::string& varname, as_value& ret, bool
descend)
+as_environment::findLocal(const std::string& varname, as_value& ret, bool
descend, as_object** retTarget)
{
if ( _localFrames.empty() ) return false;
- if ( ! descend ) return findLocal(_localFrames.back().locals, varname,
ret);
+ if ( ! descend )
+ {
+ if ( findLocal(_localFrames.back().locals, varname, ret) )
+ {
+ if ( retTarget ) *retTarget =
_localFrames.back().locals.get();
+ return true;
+ }
+ return false;
+ }
for (CallStack::reverse_iterator it=_localFrames.rbegin(),
itEnd=_localFrames.rend();
@@ -935,6 +950,7 @@
LocalVars& locals = it->locals;
if ( findLocal(locals, varname, ret) )
{
+ if ( retTarget ) *retTarget = locals.get();
return true;
}
}
Index: server/as_environment.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- server/as_environment.h 26 Apr 2007 13:34:00 -0000 1.47
+++ server/as_environment.h 26 Apr 2007 17:06:10 -0000 1.48
@@ -175,8 +175,12 @@
/// @param with_stack
/// The Scope stack to use for lookups.
///
+ /// @param retTarget
+ /// If not NULL, the pointer will be set to the actual object
containing the
+ /// found variable (if found).
+ ///
as_value get_variable(const std::string& varname,
- const ScopeStack& with_stack) const;
+ const ScopeStack& with_stack, as_object** retTarget=NULL) const;
/// \brief
/// Given a path to variable, set its value.
@@ -512,8 +516,13 @@
const ScopeStack& with_stack);
/// Same of the above, but no support for path.
+ ///
+ /// @param retTarget
+ /// If not NULL, the pointer will be set to the actual object
containing the
+ /// found variable (if found).
+ ///
as_value get_variable_raw(const std::string& varname,
- const ScopeStack& with_stack) const;
+ const ScopeStack& with_stack, as_object** retTarget=NULL) const;
/// \brief
@@ -530,13 +539,17 @@
/// If true the seek don't stop at current call frame, but
/// descends in upper frames. By default it is false.
///
+ /// @param retTarget
+ /// If not NULL, the pointer will be set to the actual object
containing the
+ /// found variable (if found).
+ ///
/// @return true if the variable was found, false otherwise
///
- bool findLocal(const std::string& varname, as_value& ret, bool
descend=false);
+ bool findLocal(const std::string& varname, as_value& ret, bool descend,
as_object** retTarget=NULL);
- bool findLocal(const std::string& varname, as_value& ret, bool
descend=false) const
+ bool findLocal(const std::string& varname, as_value& ret, bool descend,
as_object** retTarget=NULL) const
{
- return const_cast<as_environment*>(this)->findLocal(varname,
ret, descend);
+ return const_cast<as_environment*>(this)->findLocal(varname,
ret, descend, retTarget);
}
/// Find a variable in the given LocalVars
Index: server/as_value.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- server/as_value.cpp 26 Apr 2007 12:06:39 -0000 1.48
+++ server/as_value.cpp 26 Apr 2007 17:06:10 -0000 1.49
@@ -641,7 +641,7 @@
bool v_obj_or_func = (v.m_type == OBJECT || v.m_type == AS_FUNCTION);
/// Compare to same type
- if ( obj_or_func && v_obj_or_func ) return equalsSameType(v);
+ if ( obj_or_func && v_obj_or_func ) return m_object_value ==
v.m_object_value;
if ( m_type == v.m_type ) return equalsSameType(v);
else if (m_type == STRING)
Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -b -r1.100 -r1.101
--- server/vm/ASHandlers.cpp 24 Apr 2007 20:38:26 -0000 1.100
+++ server/vm/ASHandlers.cpp 26 Apr 2007 17:06:10 -0000 1.101
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: ASHandlers.cpp,v 1.100 2007/04/24 20:38:26 strk Exp $ */
+/* $Id: ASHandlers.cpp,v 1.101 2007/04/26 17:06:10 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -2194,7 +2194,8 @@
as_object* this_ptr = thread.getThisPointer();
if ( ! env.parse_path(funcname, &this_ptr, function) )
{
- function = thread.getVariable(funcname);
+ //function = thread.getVariable(funcname);
+ function = thread.getVariable(funcname, &this_ptr);
}
if ( ! function.is_object() )
@@ -2205,7 +2206,9 @@
}
else if ( ! function.is_function() )
{
+ // Calling super ?
boost::intrusive_ptr<as_object> obj = function.to_object();
+ this_ptr = thread.getThisPointer();
if ( ! obj->get_member("constructor", &function) )
{
IF_VERBOSE_ASCODING_ERRORS (
Index: server/vm/ActionExec.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ActionExec.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- server/vm/ActionExec.cpp 25 Apr 2007 06:58:57 -0000 1.30
+++ server/vm/ActionExec.cpp 26 Apr 2007 17:06:10 -0000 1.31
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: ActionExec.cpp,v 1.30 2007/04/25 06:58:57 martinwguy Exp $ */
+/* $Id: ActionExec.cpp,v 1.31 2007/04/26 17:06:10 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -382,6 +382,19 @@
return env.get_variable(namei, getWithStack());
}
+as_value
+ActionExec::getVariable(const std::string& name, as_object** target)
+{
+ VM& vm = VM::get();
+
+ std::string namei = name;
+ if ( vm.getSWFVersion() < 7 ) {
+ boost::to_lower(namei, vm.getLocale());
+ }
+
+ return env.get_variable(namei, getWithStack(), target);
+}
+
void
ActionExec::setLocalVariable(const std::string& name_, const as_value& val)
{
Index: server/vm/ActionExec.h
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ActionExec.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- server/vm/ActionExec.h 24 Apr 2007 20:38:26 -0000 1.15
+++ server/vm/ActionExec.h 26 Apr 2007 17:06:10 -0000 1.16
@@ -267,6 +267,20 @@
///
as_value getVariable(const std::string& name);
+ /// Get a named variable, seeking for it in the with stack if any.
+ //
+ /// @param name
+ /// Name of the variable. Supports slash and dot syntax.
+ /// Name is converted to lowercase if SWF version is < 7.
+ ///
+ /// @param target
+ /// An output parameter, will be set to point to the object
+ /// containing any found variable.
+ /// The pointer may be set to NULL if the variable was not
+ /// found or it belongs to no object (absolute references, for
instance).
+ ///
+ as_value getVariable(const std::string& name, as_object** target);
+
/// Set an object's member.
//
/// @param obj
Index: testsuite/actionscript.all/Function.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Function.as,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- testsuite/actionscript.all/Function.as 26 Apr 2007 16:26:02 -0000
1.44
+++ testsuite/actionscript.all/Function.as 26 Apr 2007 17:06:11 -0000
1.45
@@ -20,7 +20,7 @@
// compile this test case with Ming makeswf, and then
// execute it like this gnash -1 -r 0 -v out.swf
-rcsid="$Id: Function.as,v 1.44 2007/04/26 16:26:02 strk Exp $";
+rcsid="$Id: Function.as,v 1.45 2007/04/26 17:06:11 strk Exp $";
#include "check.as"
@@ -624,7 +624,7 @@
with (sub) {
ret = getThis();
check_equals(typeof(ret), 'object');
- xcheck_equals(getThis(), o);
+ check_equals(getThis(), o);
}
}
@@ -632,20 +632,20 @@
{
var localGetThis = function() { return this; };
ret = localGetThis();
- xcheck_equals(typeof(ret), 'object');
+ check_equals(typeof(ret), 'object');
#if OUTPUT_VERSION < 6
xcheck(ret == testInFunctionContext);
#else
check(ret != testInFunctionContext);
#endif
- xcheck(ret != this);
+ check(ret != this);
var num = 4;
with(o) {
// see bug #19704
ret = getThis();
- xcheck_equals(typeof(ret), 'object');
- xcheck_equals(ret, o);
+ check_equals(typeof(ret), 'object');
+ check_equals(ret, o);
// 'with' stack takes precedence over locals
check_equals(num, 5);
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2007/04/10
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2007/04/16
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2007/04/16
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2007/04/26
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve...,
Sandro Santilli <=
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2007/04/27
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2007/04/28