[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: |
Wed, 14 Nov 2007 22:16:06 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/11/14 22:16:05
Modified files:
. : ChangeLog
server : as_environment.cpp as_environment.h
testsuite/actionscript.all: with.as
testsuite/misc-ming.all: callFunction_test.c
testsuite/swfdec: PASSING
Log message:
Unify object finding and target finding in as_environment
(the code is pretty dirty but is more correct then before).
Successes in swfdec, actionscript.all and misc-ming.all testsuites.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4861&r2=1.4862
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.cpp?cvsroot=gnash&r1=1.107&r2=1.108
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.h?cvsroot=gnash&r1=1.62&r2=1.63
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/with.as?cvsroot=gnash&r1=1.37&r2=1.38
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/callFunction_test.c?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/swfdec/PASSING?cvsroot=gnash&r1=1.55&r2=1.56
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4861
retrieving revision 1.4862
diff -u -b -r1.4861 -r1.4862
--- ChangeLog 14 Nov 2007 21:17:31 -0000 1.4861
+++ ChangeLog 14 Nov 2007 22:16:04 -0000 1.4862
@@ -1,5 +1,15 @@
2007-11-14 Sandro Santilli <address@hidden>
+ * server/as_environment.{cpp,h}: unify object finding and target
+ finding. The code is pretty dirty but is more correct then
+ before.
+ * testsuite/swfdec/PASSING: getsetproperty-target-{6,7,8}.swf succeed
+ * testsuite/actionscript.all/with.as: no more failures (we need more)
+ * testsuite/misc-ming.all/callFunction_test.c: two more successes, one
+ test still fails.
+
+2007-11-14 Sandro Santilli <address@hidden>
+
* server/asobj/Object.cpp (object_registerClass): more informative
aserror messages.
* testsuite/actionscript.all/TextField.as: more tests.
Index: server/as_environment.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.cpp,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -b -r1.107 -r1.108
--- server/as_environment.cpp 13 Nov 2007 19:11:20 -0000 1.107
+++ server/as_environment.cpp 14 Nov 2007 22:16:05 -0000 1.108
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: as_environment.cpp,v 1.107 2007/11/13 19:11:20 strk Exp $ */
+/* $Id: as_environment.cpp,v 1.108 2007/11/14 22:16:05 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -62,12 +62,10 @@
bool is_slash_based;
if (parse_path(varname, path, var, &is_slash_based))
{
- //as_value target_val = get_variable_raw(path, scopeStack);
- //as_object* target = target_val.to_object();
// TODO: let find_target return generic as_objects, or use 'with'
stack,
// see player2.swf or bug #18758 (strip.swf)
// @@ TODO: should we use scopeStack here too ?
- as_object* target = is_slash_based ? find_object_slashsyntax(path,
&scopeStack) : find_object_dotsyntax(path, &scopeStack);
+ as_object* target = find_object(path, &scopeStack);
if (target)
{
@@ -80,8 +78,7 @@
{
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("find_object%s(\"%s\") [ varname = '%s' - current
target = '%s' ] failed"),
- is_slash_based ? "_slashsyntax" : "_dotsyntax",
+ log_aserror(_("find_object(\"%s\") [ varname = '%s' - current
target = '%s' ] failed"),
path.c_str(), varname.c_str(),
m_target->get_text_value().c_str()
);
@@ -263,7 +260,7 @@
if (parse_path(varname, path, var, &is_slash_based)) {
//log_msg(_("Variable '%s' parsed into path='%s', var='%s'"),
varname.c_str(), path.c_str(), var.c_str());
//target = find_target(path);
- target = is_slash_based ? find_object_slashsyntax(path, &scopeStack) :
find_object_dotsyntax(path, &scopeStack);
+ target = find_object(path, &scopeStack); //is_slash_based ?
find_object_slashsyntax(path, &scopeStack) : find_object_dotsyntax(path,
&scopeStack);
if (target)
{
target->set_member(VM::get().getStringTable().find(var), val);
@@ -465,7 +462,7 @@
string var;
bool is_slash_based;
if( ! parse_path(var_path, path, var, &is_slash_based) ) return false;
- as_object* target_ptr = is_slash_based ? find_object_slashsyntax(path)
: find_object_dotsyntax(path);
+ as_object* target_ptr = find_object(path); // is_slash_based ?
find_object_slashsyntax(path) : find_object_dotsyntax(path);
if ( ! target_ptr ) return false;
target_ptr->get_member(VM::get().getStringTable().find(var), &val);
@@ -481,31 +478,7 @@
for (const char* p = word; *p; p++) {
if (*p == '.' && p[1] == '.') {
p++;
- } else if (*p == '.' || *p == '/') {
- return p;
- }
- }
-
- return NULL;
-}
-
-static const char*
-find_next_slash(const char* word)
-{
- for (const char* p = word; *p; p++) {
- if (*p == '/') {
- return p;
- }
- }
-
- return NULL;
-}
-
-static const char*
-find_next_dot(const char* word)
-{
- for (const char* p = word; *p; p++) {
- if (*p == '.' ) {
+ } else if (*p == '.' || *p == '/' || *p == ':') {
return p;
}
}
@@ -520,8 +493,16 @@
character*
as_environment::find_target(const std::string& path_in) const
{
+ as_object* o = find_object(path_in);
+ if ( o ) return o->to_movie(); // can be NULL (not a movie)...
+ else return NULL;
+}
+
+as_object*
+as_environment::find_object(const std::string& path_in, const ScopeStack*
scopeStack) const
+{
#ifdef DEBUG_TARGET_FINDING
- log_msg(_("find_target(%s) called"), path_in.c_str());
+ log_msg(_("find_object(%s) called"), path_in.c_str());
#endif
if (path_in.empty())
@@ -543,8 +524,12 @@
as_object* env = m_target;
assert(env);
+ bool firstElementParsed = false;
+ bool dot_allowed=true;
+
const char* p = path.c_str();
- if (*p == '/') {
+ if (*p == '/')
+ {
// Absolute path. Start at the root.
sprite_instance* root = m_target->get_root_movie();
if ( ! *(++p) )
@@ -556,6 +541,8 @@
}
env = root;
+ firstElementParsed = true;
+ dot_allowed = false;
#ifdef DEBUG_TARGET_FINDING
log_msg(_("Absolute path, start at the root (%p)"), (void*)env);
@@ -574,334 +561,112 @@
std::string subpart;
while (env)
{
- const char* next_slash = next_slash_or_dot(p);
- subpart = p;
- if (next_slash == p)
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("invalid path '%s'"), path.c_str());
- );
- return NULL;
- //break;
- }
- else if (next_slash)
- {
- // Cut off the slash and everything after it.
- subpart.resize(next_slash - p);
- // Remove any column in the subpart
- }
-
- while ( ! subpart.empty() && subpart[0] == ':' ) subpart =
subpart.substr(1);
+ while ( *p == ':' ) ++p;
// No more components to scan
- if ( subpart.empty() )
+ if ( ! *p )
{
#ifdef DEBUG_TARGET_FINDING
- log_msg(_("No more subparts, env is %p"), (void*)env);
+ log_msg(_("Path is %s, returning the root"), path.c_str());
#endif
- break;
- }
-
-#ifdef DEBUG_TARGET_FINDING
- log_msg(_("Invoking get_path_element(%s) on object %p (%s)"),
subpart.c_str(), (void *)env, env->get_text_value().c_str());
-#endif
-
- as_object* element = env->get_path_element(st.find(subpart));
- if ( ! element )
- {
-#ifdef DEBUG_TARGET_FINDING
- log_msg(_("Path element %s not found in object %p"),
subpart.c_str(), (void *)env);
-#endif
- return NULL;
- }
- env = element;
-
- //@@ _level0 --> root, .. --> parent, . --> this, other == character
-
- if (next_slash == NULL)
- {
- break;
- }
-
- p = next_slash + 1;
- }
- return env->to_movie(); // can be NULL (not a movie)...
-}
-
-as_object*
-as_environment::find_object_dotsyntax(const std::string& path, const
ScopeStack* scopeStack) const
-{
-#ifdef DEBUG_TARGET_FINDING
- log_msg(_("find_object_dotsyntax(%s) called"), path.c_str());
-#endif
-
- VM& vm = VM::get();
-
- if ( path.empty() )
- {
-#ifdef DEBUG_TARGET_FINDING
- log_msg(_("Returning m_target (empty path)"));
-#endif
- return m_target;
+ return env;
}
- // we'd have returned m_target in this case
- //assert(path.length() > 0);
- as_object* env = m_target;
- if ( scopeStack && ! scopeStack->empty() ) env = scopeStack->back().get();
- assert(env);
-
- const char* p = path.c_str();
- unsigned int depth=0; // number of iterations
- while (env)
- {
- const char* next_dot = find_next_dot(p); // TODO: use std::string::find
- std::string subpart = p;
- if (next_dot == p)
+ const char* next_slash = next_slash_or_dot(p);
+ subpart = p;
+ if (next_slash == p)
{
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("invalid path '%s'"), path.c_str());
+ log_aserror(_("invalid path '%s' (p=next_slash=%s)"), path.c_str(),
next_slash);
);
- return NULL; // TODO: check me
+ return NULL;
}
- else if (next_dot)
+ else if (next_slash)
{
// Cut off the slash and everything after it.
- subpart.resize(next_dot - p);
+ subpart.resize(next_slash - p);
}
-#ifdef DEBUG_TARGET_FINDING
- log_msg(_("Subpart == %s"), subpart.c_str());
-#endif
+ assert(subpart[0] != ':');
// No more components to scan
if ( subpart.empty() )
{
#ifdef DEBUG_TARGET_FINDING
- log_debug(_("No more subparts, env is %p"), (void*)env);
+ log_msg(_("No more subparts, env is %p"), (void*)env);
#endif
break;
}
-#ifdef DEBUG_TARGET_FINDING
- log_debug(_("Invoking get_path_element(%s) on object %p"),
subpart.c_str(), (void *)env);
-#endif
-
- //as_value tmp;
- string_table::key subpartkey = vm.getStringTable().find(subpart);
+ string_table::key subpartKey = st.find(subpart);
- // TODO: make sure sprite_instances know about ".."
- as_object* nextElement = env->get_path_element(subpartkey);
- if ( ! nextElement )
- //if (!env->get_member(subpartkey, &tmp) )
+ if ( ! firstElementParsed )
{
- // Try this and _global, but only at first iteration...
+ as_object* element = NULL;
- if ( depth > 0 )
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("Member %s for object %p not found (dotsyntax).
Path was %s"),
- subpart.c_str(), (void *)env, path.c_str());
- );
- return NULL;
- }
+ do {
- if ( subpart == "this" )
- {
- //tmp.set_as_object(m_target);
- nextElement = m_target;
- }
- else
+ // Try scope stack
+ if ( scopeStack )
{
- nextElement = vm.getGlobal()->get_path_element(subpartkey);
- if ( ! nextElement )
+ for (size_t i = scopeStack->size(); i > 0; --i)
{
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("Path element '%s' of variable '%s' not found
in object %p nor in _global (dotsyntax)"),
- subpart.c_str(), path.c_str(), (void *)env);
- );
- return NULL;
- }
+ // const_cast needed due to non-const
as_object::get_member
+ as_object* obj =
const_cast<as_object*>((*scopeStack)[i-1].get());
+ element =
obj->get_path_element(subpartKey);
+ if ( element ) break;
}
+ if ( element ) break;
}
- assert(nextElement);
-
- env = nextElement; // tmp.to_object().get();
-#ifndef GNASH_USE_GC
- assert(env->get_ref_count() > 0); // still alive...
-#endif // ndef GNASH_USE_GC
+ // Try current target
+ assert(env == m_target);
+ element = env->get_path_element(subpartKey);
+ if ( element ) break;
- //@@ _level0 --> root, .. --> parent, . --> this, other == character
-
- if (next_dot == NULL)
+ // Looking for _global ?
+ as_object* global = VM::get().getGlobal();
+ if ( swfVersion > 5 && subpart == "_global" )
{
+ element = global;
break;
}
- p = next_dot + 1;
- ++depth;
- }
-
- return env;
-}
-
-as_object*
-as_environment::find_object_slashsyntax(const std::string& path, const
ScopeStack* scopeStack) const
-{
-#ifdef DEBUG_TARGET_FINDING
- log_msg(_("find_object_slashsyntax(%s) called"), path.c_str());
-#endif
-
- if ( path.empty() )
- {
-#ifdef DEBUG_TARGET_FINDING
- log_debug(_("Returning m_target (empty path)"));
-#endif
- return m_target;
- }
-
- as_object* env = m_target;
- if ( scopeStack && ! scopeStack->empty() ) env = scopeStack->back().get();
- assert(env);
-
- const char* p = path.c_str();
-
- if (*p == '/')
- {
- // Absolute path. Start at the *absolute* root.
- // TODO: should this be VM::get().getRoot().get_root_movie() ?
- env = m_target->get_root_movie();
-#ifdef DEBUG_TARGET_FINDING
- log_debug(_("Absolute path, start at the root (%p)"), (void*)env);
-#endif
- p++;
- }
-
- if (*p == '\0')
- {
-#ifdef DEBUG_TARGET_FINDING
- log_msg(_("Slash-only path, returning root movie"));
-#endif
- assert(path=="/");
- assert(env == m_target->get_root_movie());
- return env;
- }
-
- VM& vm = VM::get();
-
- unsigned int depth=0; // number of iterations
- while (env)
- {
- std::string subpart;
- const char* next_slash = find_next_slash(p); // TODO: use
std::string::find
- subpart = p;
- if (next_slash == p)
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("invalid path '%s'"), path.c_str());
- );
- return NULL; // TODO: check me
- }
- else if (next_slash)
- {
- // Cut off the slash and everything after it.
- // TODO: optimize by using offsets in the original string
- subpart.resize(next_slash - p);
- }
+ // Try globals
+ element = global->get_path_element(subpartKey);
+ //if ( element ) break;
-#ifdef DEBUG_TARGET_FINDING
- log_debug(_("Subpart == %s"), subpart.c_str());
-#endif
+ } while (0);
- // No more components to scan
- if ( subpart.empty() )
+ if ( ! element )
{
#ifdef DEBUG_TARGET_FINDING
- log_debug(_("No more subparts, env is %p"), (void*)env);
+ log_debug("subpart %s of path %s not found in any scope
stack element", subpart.c_str(), path.c_str());
#endif
- break;
- }
-
- if ( subpart == ".." )
- {
- character* ch = dynamic_cast<character*>(env);
- if ( ! ch )
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("'..' element in path '%s' follows a
non-character object %p"),
- path.c_str(), (void *)env);
- );
return NULL;
}
- env = ch->get_parent();
- if ( ! env ) // root movie doesn't have a parent
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("'..' in path '%s' follows a character "
- "with no parent (%s : %p) (root is %p)"),
- path.c_str(), ch->get_text_value().c_str(), (void *)ch,
- (void *)vm.getRoot().get_root_movie());
- );
- // if we override env, getvariable.as fails [line
57]
- //env = ch;
- }
+ env = element;
+ firstElementParsed = true;
}
else
{
#ifdef DEBUG_TARGET_FINDING
- log_debug(_("Invoking get_path_element(%s) on object %p"),
subpart.c_str(), (void *)env);
+ log_msg(_("Invoking get_path_element(%s) on object %p (%s)"),
subpart.c_str(), (void *)env, env->get_text_value().c_str());
#endif
- //as_value tmp;
- string_table::key subpartkey =
vm.getStringTable().find(subpart);
- // TODO: make sure sprite_instances know about ".."
- as_object* nextElement = env->get_path_element(subpartkey);
- if ( ! nextElement )
- //if (!env->get_member(subpartkey, &tmp) )
- {
- // Try this and _global, but only at first iteration...
- if ( depth > 0 )
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("Member %s for object %p not
found (slashsyntax). Path was %s"),
- subpart.c_str(), (void *)env,
path.c_str());
- );
- return NULL;
- }
-
- if ( subpart == "this" )
- {
- //tmp.set_as_object(m_target);
- nextElement = m_target;
- }
-
- else
- {
- nextElement =
vm.getGlobal()->get_path_element(subpartkey);
- if ( ! nextElement )
+ as_object* element = env->get_path_element(subpartKey);
+ if ( ! element )
{
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("Element '%s' of variable
'%s' not found in object %p nor in _global (slashsyntax)"),
- subpart.c_str(), path.c_str(),
(void *)env);
- );
+#ifdef DEBUG_TARGET_FINDING
+ log_msg(_("Path element %s not found in object %p"),
subpart.c_str(), (void *)env);
+#endif
return NULL;
}
+ env = element;
}
- }
-
- assert(nextElement);
-
- env = nextElement;
-#ifndef GNASH_USE_GC
- assert(env->get_ref_count() > 0);
-#endif // ndef GNASH_USE_GC
- }
-
- //@@ _level0 --> root, .. --> parent, . --> this, other ==
character
if (next_slash == NULL)
{
@@ -909,7 +674,6 @@
}
p = next_slash + 1;
- ++depth;
}
return env;
}
Index: server/as_environment.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.h,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- server/as_environment.h 25 Oct 2007 10:47:50 -0000 1.62
+++ server/as_environment.h 14 Nov 2007 22:16:05 -0000 1.63
@@ -335,6 +335,13 @@
///
character* find_target(const std::string& path) const;
+ /// Find the object referenced by the given path.
+ //
+ /// Supports both /slash/syntax and dot.syntax
+ /// Case insensitive for SWF up to 6, sensitive from 7 up
+ ///
+ as_object* find_object(const std::string& path, const ScopeStack*
scopeStack=NULL) const;
+
/// Dump content of the stack to a std::ostream
void dump_stack(std::ostream& out=std::cerr)
{
Index: testsuite/actionscript.all/with.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/with.as,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- testsuite/actionscript.all/with.as 26 Oct 2007 13:03:56 -0000 1.37
+++ testsuite/actionscript.all/with.as 14 Nov 2007 22:16:05 -0000 1.38
@@ -21,7 +21,7 @@
// compile this test case with Ming makeswf, and then
// execute it like this gnash -1 -r 0 -v out.swf
-rcsid="$Id: with.as,v 1.37 2007/10/26 13:03:56 strk Exp $";
+rcsid="$Id: with.as,v 1.38 2007/11/14 22:16:05 strk Exp $";
#include "check.as"
@@ -354,7 +354,7 @@
setTarget("");
setTarget('o:t');
-xcheck_equals(_target, "/clip1");
+check_equals(_target, "/clip1");
setTarget("");
setTarget('../o:t'); // invalid ?
@@ -384,7 +384,7 @@
with (o2)
{
setTarget('o:t');
- xcheck_equals(_target, "/clip1");
+ check_equals(_target, "/clip1");
setTarget("");
}
Index: testsuite/misc-ming.all/callFunction_test.c
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/callFunction_test.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- testsuite/misc-ming.all/callFunction_test.c 12 Sep 2007 05:04:16 -0000
1.4
+++ testsuite/misc-ming.all/callFunction_test.c 14 Nov 2007 22:16:05 -0000
1.5
@@ -148,8 +148,8 @@
check_equals(mo, "_root.x2", "_root.mc1.mc11");
check_equals(mo, "_root.x3", "1");
check_equals(mo, "_root.x4", "0");
- xcheck_equals(mo, "_root.x5", "1");
- xcheck_equals(mo, "_root.x6", "_root.mc1");
+ check_equals(mo, "_root.x5", "1");
+ check_equals(mo, "_root.x6", "_root.mc1");
check_equals(mo, "_root.x7", "1");
xcheck_equals(mo, "_root.x8", "1");
Index: testsuite/swfdec/PASSING
===================================================================
RCS file: /sources/gnash/gnash/testsuite/swfdec/PASSING,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -b -r1.55 -r1.56
--- testsuite/swfdec/PASSING 2 Nov 2007 17:50:50 -0000 1.55
+++ testsuite/swfdec/PASSING 14 Nov 2007 22:16:05 -0000 1.56
@@ -145,6 +145,9 @@
function2.swf:021842f44ba2c3e5c7c13786c7cc88ea
get-depth-5.swf:3bcb54d583b5b4bfb8b332ccb821d064
getsetproperty-target-5.swf:03e0f34befd1de66083128dd7810d211
+getsetproperty-target-6.swf:cd70c0eac0ac31400859178f7d877fe1
+getsetproperty-target-7.swf:d7d730794e6318c1b69a7e946cb2fedd
+getsetproperty-target-8.swf:b558d97e246e9ed2b90969d96f3e0fcc
getvariable-dotdot-5.swf:68529abcc9f149593f50dfacb3f8656e
getvariable-dotdot-6.swf:becc7079e65bcf47fe2ab0293bbc2c29
getvariable-dotdot-7.swf:efa5597fe3e61764b6ee937f87d8cf1b
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve...,
Sandro Santilli <=