gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/as_object.cpp server/typ...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/as_object.cpp server/typ...
Date: Wed, 07 Feb 2007 13:31:27 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/02/07 13:31:26

Modified files:
        .              : ChangeLog 
        server         : as_object.cpp types.cpp 
        server/asobj   : Object.cpp 
        server/vm      : fn_call.h 

Log message:
                * server/types.cpp (rgba::read): made more readable.
                * server/vm/fn_call.h: add dump_args() method.
                * server/asobj/Object.cpp: use log_aserror() where appropriate,
                  dump function args when invalid. Don't giveup when number of
                  args is greater then required.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2261&r2=1.2262
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.cpp?cvsroot=gnash&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/gnash/server/types.cpp?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Object.cpp?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/fn_call.h?cvsroot=gnash&r1=1.1&r2=1.2

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2261
retrieving revision 1.2262
diff -u -b -r1.2261 -r1.2262
--- ChangeLog   7 Feb 2007 11:09:07 -0000       1.2261
+++ ChangeLog   7 Feb 2007 13:31:26 -0000       1.2262
@@ -1,3 +1,17 @@
+M ChangeLog
+M server/as_object.cpp
+M server/types.cpp
+M server/asobj/Object.cpp
+M server/vm/fn_call.h
+
+2007-02-07 Sandro Santilli <address@hidden>
+
+       * server/types.cpp (rgba::read): made more readable.
+       * server/vm/fn_call.h: add dump_args() method.
+       * server/asobj/Object.cpp: use log_aserror() where appropriate,
+         dump function args when invalid. Don't giveup when number of 
+         args is greater then required.
+
 2007-02-07 Sandro Santilli <address@hidden>
 
        * testsuite/actionscript.all/Object.as: add tests for invalid calls

Index: server/as_object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- server/as_object.cpp        7 Feb 2007 10:28:40 -0000       1.34
+++ server/as_object.cpp        7 Feb 2007 13:31:26 -0000       1.35
@@ -437,7 +437,9 @@
                obj = obj->get_prototype();
        }
 
-       if ( obj ) log_warning("prototype loop during Enumeration");
+       // This happens always since top object in hierarchy
+       // is always Object, which in turn derives from itself
+       //if ( obj ) log_warning("prototype loop during Enumeration");
 }
 
 as_object::as_object()

Index: server/types.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/types.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- server/types.cpp    7 Feb 2007 08:43:33 -0000       1.18
+++ server/types.cpp    7 Feb 2007 13:31:26 -0000       1.19
@@ -192,13 +192,16 @@
 
        void    rgba::read(stream* in, int tag_type)
        {
-               if (tag_type <= 22)
+               switch (tag_type)
                {
+                       case SWF::DEFINESHAPE:
+                       case SWF::DEFINESHAPE2:
                        read_rgb(in);
-               }
-               else
-               {
+                               break;
+                       default:
+                       case SWF::DEFINESHAPE3:
                        read_rgba(in);
+                               break;
                }
        }
 

Index: server/asobj/Object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Object.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/asobj/Object.cpp     7 Feb 2007 10:28:40 -0000       1.13
+++ server/asobj/Object.cpp     7 Feb 2007 13:31:26 -0000       1.14
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: Object.cpp,v 1.13 2007/02/07 10:28:40 strk Exp $ */
+/* $Id: Object.cpp,v 1.14 2007/02/07 13:31:26 strk Exp $ */
 
 // Implementation of ActionScript Object class.
 
@@ -157,19 +157,30 @@
 
        if ( fn.nargs != 3 )
        {
-               log_warning("Invalid call to Object.addProperty() - "
-                       "wrong number of args: %d, expected 3 "
-                       "(property name, getter function, setter function)",
-                       fn.nargs);
+               IF_VERBOSE_ASCODING_ERRORS(
+               std::stringstream ss;
+               fn.dump_args(ss);
+               log_aserror("Invalid call to Object.addProperty(%s) - "
+                       "expected 3 arguments (<name>, <getter>, <setter>).",
+                       ss.str().c_str());
+               );
+
+               // if we've been given more args then needed there's
+               // no need to abort here
+               if ( fn.nargs < 3 )
+               {
                fn.result->set_bool(false);
                return;
        }
+       }
 
        std::string propname = fn.arg(0).to_string();
        if ( propname.empty() )
        {
-               log_warning("Invalid call to Object.addProperty() - "
+               IF_VERBOSE_ASCODING_ERRORS(
+               log_aserror("Invalid call to Object.addProperty() - "
                        "empty property name");
+               );
                fn.result->set_bool(false);
                return;
        }
@@ -177,8 +188,10 @@
        as_function* getter = fn.arg(1).to_as_function();
        if ( ! getter )
        {
-               log_warning("Invalid call to Object.addProperty() - "
+               IF_VERBOSE_ASCODING_ERRORS(
+               log_aserror("Invalid call to Object.addProperty() - "
                        "getter is not an AS function");
+               );
                fn.result->set_bool(false);
                return;
        }
@@ -186,8 +199,10 @@
        as_function* setter = fn.arg(2).to_as_function();
        if ( ! setter )
        {
-               log_warning("Invalid call to Object.addProperty() - "
+               IF_VERBOSE_ASCODING_ERRORS(
+               log_aserror("Invalid call to Object.addProperty() - "
                        "setter is not an AS function");
+               );
                fn.result->set_bool(false);
                return;
        }
@@ -206,24 +221,32 @@
 object_registerClass(const fn_call& fn)
 {
        assert(fn.this_ptr);
-       as_object* obj = fn.this_ptr;
+       //as_object* obj = fn.this_ptr;
 
        if ( fn.nargs != 2 )
        {
                IF_VERBOSE_ASCODING_ERRORS(
-                       log_warning("Invalid call to Object.registerClass() - "
-                               "wrong number of args: %d, expected 2.",
-                               fn.nargs);
+               std::stringstream ss;
+               fn.dump_args(ss);
+               log_aserror("Invalid call to Object.registerClass(%s) - "
+                       "expected 2 arguments (<symbol>, <constructor>).",
+                       ss.str().c_str());
                );
+
+               // if we've been given more args then needed there's
+               // no need to abort here
+               if ( fn.nargs < 2 )
+               {
                fn.result->set_bool(false);
                return;
        }
+       }
 
        std::string symbolid = fn.arg(0).to_std_string();
        if ( symbolid.empty() )
        {
                IF_VERBOSE_ASCODING_ERRORS(
-                       log_warning("Invalid call to Object.registerClass() - "
+               log_aserror("Invalid call to Object.registerClass() - "
                                "empty symbol id");
                );
                fn.result->set_bool(false);
@@ -234,7 +257,7 @@
        if ( ! theclass )
        {
                IF_VERBOSE_ASCODING_ERRORS(
-                       log_warning("Invalid call to Object.registerClass() - "
+               log_aserror("Invalid call to Object.registerClass() - "
                                "class is not a function");
                );
                fn.result->set_bool(false);
@@ -249,11 +272,14 @@
        boost::intrusive_ptr<resource> exp_res = 
def->get_exported_resource(symbolid.c_str());
        if ( ! exp_res )
        {
-               log_warning("Object.registerClass(%s, %s): "
+               IF_VERBOSE_ASCODING_ERRORS(
+               log_aserror("Object.registerClass(%s, %s): "
                        "can't find exported symbol",
                        symbolid.c_str(), 
                        typeid(theclass).name());
+               );
                fn.result->set_bool(false);
+               return;
        }
 
        // Check that the exported resource is a sprite_definition
@@ -265,13 +291,16 @@
 
        if ( ! exp_clipdef )
        {
-               log_warning("Object.registerClass(%s, %s): "
+               IF_VERBOSE_ASCODING_ERRORS(
+               log_aserror("Object.registerClass(%s, %s): "
                        "exported symbol is not a MovieClip symbol "
                        "(sprite_definition), but a %s",
                        symbolid.c_str(), 
                        typeid(theclass).name(),
                        typeid(*exp_res).name());
+               );
                fn.result->set_bool(false);
+               return;
        }
 
        exp_clipdef->registerClass(theclass);

Index: server/vm/fn_call.h
===================================================================
RCS file: /sources/gnash/gnash/server/vm/fn_call.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/vm/fn_call.h 24 Nov 2006 09:04:25 -0000      1.1
+++ server/vm/fn_call.h 7 Feb 2007 13:31:26 -0000       1.2
@@ -28,6 +28,7 @@
 #include "as_environment.h" // for inlines (arg)
 
 #include <cassert> // for inlines (arg)
+#include <ostream> // for inlines (dump_args)
 
 namespace gnash {
 
@@ -67,6 +68,16 @@
                return env->bottom(first_arg_bottom_index - n);
        }
 
+       /// Dump arguments to given output stream
+       void dump_args(std::ostream& os) const
+       {
+               for (int i=0; i<nargs; ++i)
+               {
+                       if ( i ) os << ", ";
+                       os << arg(i).to_string();
+               }
+       }
+
 };
 
 /// Signature of a builtin function callable from ActionScript




reply via email to

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