gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/asobj/ContextMenu.cpp se...


From: Ann Barcomb
Subject: [Gnash-commit] gnash ChangeLog server/asobj/ContextMenu.cpp se...
Date: Tue, 20 Mar 2007 10:36:45 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Ann Barcomb <ann>       07/03/20 10:36:45

Modified files:
        .              : ChangeLog 
        server/asobj   : ContextMenu.cpp Date.cpp LoadVars.cpp 
                         NetConnection.cpp NetStream.cpp Sound.cpp 
                         gen-asclass.sh string.cpp 

Log message:
        Changed instances of ensureClass to use inherited ensureType.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2636&r2=1.2637
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/ContextMenu.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Date.cpp?cvsroot=gnash&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/LoadVars.cpp?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetConnection.cpp?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStream.cpp?cvsroot=gnash&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Sound.cpp?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/gen-asclass.sh?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/string.cpp?cvsroot=gnash&r1=1.19&r2=1.20

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2636
retrieving revision 1.2637
diff -u -b -r1.2636 -r1.2637
--- ChangeLog   20 Mar 2007 09:55:09 -0000      1.2636
+++ ChangeLog   20 Mar 2007 10:36:44 -0000      1.2637
@@ -1,5 +1,11 @@
 2007-03-20 Ann Barcomb <address@hidden>
 
+       * server/asobj/ContextMenu.cpp, Date.cpp, LoadVars.cpp, string.cpp,
+         NetConnection.cpp, NetStream.cpp, Sound.cpp, gen-asclass.sh:
+         Changed instances of ensureClass to use inherited ensureType.
+
+2007-03-20 Ann Barcomb <address@hidden>
+
        * doc/C/actionscript/new_as_class.xml: syntax of 'ensure'
          changed to correspond with Bastiaan's last commit.
 

Index: server/asobj/ContextMenu.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/ContextMenu.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/asobj/ContextMenu.cpp        19 Mar 2007 17:11:14 -0000      1.9
+++ server/asobj/ContextMenu.cpp        20 Mar 2007 10:36:45 -0000      1.10
@@ -87,16 +87,6 @@
                set_member("onSelect", callback);
        }
 
-       static ContextMenu* ensureContextMenu(as_object* obj)
-       {
-               ContextMenu* ret = dynamic_cast<ContextMenu*>(obj);
-               if ( ! ret )
-               {
-                       throw ActionException("builtin method or gettersetter 
for ContextMenu objects called against non-ContextMenu instance");
-               }
-               return ret;
-       }
-
        /// Attach the exported interface of this ActionScript class
        /// to the given object.
        static void attachExportedInterface(as_object& o);
@@ -137,7 +127,7 @@
 as_value
 ContextMenu::copy_method(const fn_call& fn)
 {
-       ContextMenu* ptr = ensureContextMenu(fn.this_ptr);
+       ContextMenu* ptr = ensureType<ContextMenu>(fn.this_ptr);
        UNUSED(ptr);
        log_warning("%s: unimplemented", __FUNCTION__);
        return as_value();
@@ -147,7 +137,7 @@
 as_value
 ContextMenu::hideBuiltInItems_method(const fn_call& fn)
 {
-       ContextMenu* ptr = ensureContextMenu(fn.this_ptr);
+       ContextMenu* ptr = ensureType<ContextMenu>(fn.this_ptr);
        UNUSED(ptr);
        log_warning("%s: unimplemented", __FUNCTION__);
        return as_value();

Index: server/asobj/Date.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Date.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- server/asobj/Date.cpp       19 Mar 2007 17:11:14 -0000      1.35
+++ server/asobj/Date.cpp       20 Mar 2007 10:36:45 -0000      1.36
@@ -437,19 +437,6 @@
        return as_value(date);
 }
 
-// Wrapper around dynamic_cast to implement user warning.
-// To be used by builtin properties and methods.
-static date_as_object*
-ensure_date_object(as_object* obj)
-{
-       date_as_object* ret = dynamic_cast<date_as_object*>(obj);
-       if ( ! ret )
-       {
-               throw ActionException("builtin method or gettersetter for date 
objects called against non-date instance");
-       }
-       return ret;
-}
-
 //
 //    =========    Functions to get dates in various ways    ========
 //
@@ -466,7 +453,7 @@
 
 #define date_get_proto(function, timefn, element) \
        static as_value function(const fn_call& fn) { \
-               date_as_object* date = ensure_date_object(fn.this_ptr); \
+               date_as_object* date = ensureType<date_as_object>(fn.this_ptr); 
\
                time_t t = (time_t)(date->value / 1000.0); \
                struct tm tm; \
                return as_value(_##timefn##_r(&t, &tm)->element); \
@@ -523,7 +510,7 @@
 // Also implements Date.getUTCMilliseconds
 
 static as_value date_getmilliseconds(const fn_call& fn) {
-       date_as_object* date = ensure_date_object(fn.this_ptr);
+       date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
        return as_value((int) std::fmod(date->value, 1000.0));
 }
 
@@ -592,7 +579,7 @@
 /// sets a Date in milliseconds after January 1, 1970 00:00 UTC.
 /// Returns value is the same aqs the paramemeter.
 static as_value date_settime(const fn_call& fn) {
-       date_as_object* date = ensure_date_object(fn.this_ptr);
+       date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
 
        // assert(fn.nargs == 1);
        if (fn.nargs < 1) {
@@ -761,7 +748,7 @@
 // to the day the clocks go forward.
 
 static as_value _date_setfullyear(const fn_call& fn, bool utc) {
-       date_as_object* date = ensure_date_object(fn.this_ptr);
+       date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
 
        // assert(fn.nargs >= 1 && fn.nargs <= 3);
        if (fn.nargs < 1) {
@@ -803,7 +790,7 @@
 // There is no setUTCYear() function.
 
 static as_value date_setyear(const fn_call& fn) {
-       date_as_object* date = ensure_date_object(fn.this_ptr);
+       date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
 
        // assert(fn.nargs == 1);
        if (fn.nargs < 1) {
@@ -839,7 +826,7 @@
 /// This implementation currently wraps it into the next month, which is wrong.
 
 static as_value _date_setmonth(const fn_call& fn, bool utc) {
-       date_as_object* date = ensure_date_object(fn.this_ptr);
+       date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
 
        // assert(fn.nargs >= 1 && fn.nargs <= 2);
        if (fn.nargs < 1) {
@@ -870,7 +857,7 @@
 /// day > 31. Example: setting the 35th in January results in Feb 4th.
 
 static as_value _date_setdate(const fn_call& fn, bool utc) {
-       date_as_object* date = ensure_date_object(fn.this_ptr);
+       date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
 
        if (fn.nargs < 1) {
            IF_VERBOSE_ASCODING_ERRORS(
@@ -904,7 +891,7 @@
 /// setTime(n) or call the constructor with one argument.
 
 static as_value _date_sethours(const fn_call& fn, bool utc) {
-       date_as_object* date = ensure_date_object(fn.this_ptr);
+       date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
 
        // assert(fn.nargs >= 1 && fn.nargs <= 4);
        if (fn.nargs < 1) {
@@ -941,7 +928,7 @@
 /// Similarly, negative values carry you back into the previous 
minute/hour/day.
 
 static as_value _date_setminutes(const fn_call& fn, bool utc) {
-       date_as_object* date = ensure_date_object(fn.this_ptr);
+       date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
 
        //assert(fn.nargs >= 1 && fn.nargs <= 3);
        if (fn.nargs < 1) {
@@ -974,7 +961,7 @@
 /// previous minute (or hour or calendar day) or on to the following ones.
 
 static as_value _date_setseconds(const fn_call& fn, bool utc) {
-       date_as_object* date = ensure_date_object(fn.this_ptr);
+       date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
 
        // assert(fn.nargs >= 1 && fn.nargs <= 2);
        if (fn.nargs < 1) {
@@ -1003,7 +990,7 @@
 }
 
 static as_value date_setmilliseconds(const fn_call& fn) {
-       date_as_object* date = ensure_date_object(fn.this_ptr);
+       date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
 
        // assert(fn.nargs == 1);
        if (fn.nargs < 1) {
@@ -1062,7 +1049,7 @@
                
{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
        char* dayweekname[7] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
 
-       date_as_object* date = ensure_date_object(fn.this_ptr);
+       date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
        
        time_t t = (time_t) (date->value / 1000.0);
        struct tm tm;
@@ -1234,7 +1221,7 @@
 // Also used to implement Date.getTime()
 
 static as_value date_valueof(const fn_call& fn) {
-       date_as_object* date = ensure_date_object(fn.this_ptr);
+       date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
        return as_value(date->value);
 }
 

Index: server/asobj/LoadVars.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/LoadVars.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- server/asobj/LoadVars.cpp   19 Mar 2007 17:11:14 -0000      1.15
+++ server/asobj/LoadVars.cpp   20 Mar 2007 10:36:45 -0000      1.16
@@ -26,7 +26,6 @@
 #include "fn_call.h"
 #include "smart_ptr.h" // for boost intrusive_ptr
 #include "builtin_function.h" // need builtin_function
-#include "GnashException.h" // for ActionException in ensureLoadVars
 #include "as_function.h" // for calling event handlers
 #include "as_environment.h" // for setting up a fn_call
 #include "as_value.h" // for setting up a fn_call
@@ -425,27 +424,11 @@
        }
 }
 
-static LoadVars*
-ensureLoadVars(as_object* obj)
-{
-       LoadVars* ret = dynamic_cast<LoadVars*>(obj);
-       if ( ! ret )
-       {
-               std::stringstream ss;
-               ss << "builtin method or gettersetter for LoadVars objects "
-                       << "called against non-LoadVars instance ("
-                       << typeid(*obj).name() << ")";
-               throw ActionException(ss.str());
-               //throw ActionException("builtin method or gettersetter for 
LoadVars objects called against non-LoadVars instance (%s)", 
typeid(*obj).name());
-       }
-       return ret;
-}
-
 /* private static */
 as_value
 LoadVars::onLoad_getset(const fn_call& fn)
 {
-       LoadVars* ptr = ensureLoadVars(fn.this_ptr);
+       LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
 
        if ( fn.nargs == 0 ) // getter
        {
@@ -465,7 +448,7 @@
 as_value
 LoadVars::checkLoads_wrapper(const fn_call& fn)
 {
-       LoadVars* ptr = ensureLoadVars(fn.this_ptr);
+       LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
        ptr->checkLoads();
        return as_value();
 }
@@ -475,7 +458,7 @@
 LoadVars::onData_getset(const fn_call& fn)
 {
 
-       LoadVars* ptr = ensureLoadVars(fn.this_ptr);
+       LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
 
        if ( fn.nargs == 0 ) // getter
        {
@@ -496,7 +479,7 @@
 LoadVars::loaded_getset(const fn_call& fn)
 {
 
-       LoadVars* ptr = ensureLoadVars(fn.this_ptr);
+       LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
 
        if ( fn.nargs == 0 ) // getter
        {
@@ -515,7 +498,7 @@
 static as_value
 loadvars_addrequestheader(const fn_call& fn)
 {
-       LoadVars* ptr = ensureLoadVars(fn.this_ptr);
+       LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
        UNUSED(ptr);
        log_error("%s: unimplemented", __FUNCTION__);
        return as_value(); 
@@ -524,7 +507,7 @@
 static as_value
 loadvars_decode(const fn_call& fn)
 {
-       LoadVars* ptr = ensureLoadVars(fn.this_ptr);
+       LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
        UNUSED(ptr);
        log_error("%s: unimplemented", __FUNCTION__);
        return as_value(); 
@@ -533,21 +516,21 @@
 as_value
 LoadVars::getBytesLoaded_method(const fn_call& fn)
 {
-       LoadVars* ptr = ensureLoadVars(fn.this_ptr);
+       LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
        return as_value(ptr->getBytesLoaded());
 }
 
 as_value
 LoadVars::getBytesTotal_method(const fn_call& fn)
 {
-       LoadVars* ptr = ensureLoadVars(fn.this_ptr);
+       LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
        return as_value(ptr->getBytesTotal());
 }
 
 static as_value
 loadvars_load(const fn_call& fn)
 {
-       LoadVars* obj = ensureLoadVars(fn.this_ptr);
+       LoadVars* obj = ensureType<LoadVars>(fn.this_ptr);
 
        if ( fn.nargs < 1 )
        {
@@ -574,7 +557,7 @@
 static as_value
 loadvars_send(const fn_call& fn)
 {
-       LoadVars* ptr = ensureLoadVars(fn.this_ptr);
+       LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
        UNUSED(ptr);
        log_error("%s: unimplemented", __FUNCTION__);
        return as_value(); 
@@ -583,7 +566,7 @@
 static as_value
 loadvars_sendandload(const fn_call& fn)
 {
-       LoadVars* ptr = ensureLoadVars(fn.this_ptr);
+       LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
 
        if ( fn.nargs < 2 )
        {
@@ -624,7 +607,7 @@
 static as_value
 loadvars_tostring(const fn_call& fn)
 {
-       LoadVars* ptr = ensureLoadVars(fn.this_ptr);
+       LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
        UNUSED(ptr);
        log_error("%s: unimplemented", __FUNCTION__);
        return as_value(); 

Index: server/asobj/NetConnection.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetConnection.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- server/asobj/NetConnection.cpp      19 Mar 2007 17:11:14 -0000      1.29
+++ server/asobj/NetConnection.cpp      20 Mar 2007 10:36:45 -0000      1.30
@@ -14,7 +14,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: NetConnection.cpp,v 1.29 2007/03/19 17:11:14 bjacques Exp $ */
+/* $Id: NetConnection.cpp,v 1.30 2007/03/20 10:36:45 ann Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -156,20 +156,6 @@
 }
 
 
-// Wrapper around dynamic_cast to implement user warning.
-// To be used by builtin properties and methods.
-static NetConnection*
-ensure_netconnection(as_object* obj)
-{
-       NetConnection* ret = dynamic_cast<NetConnection*>(obj);
-       if ( ! ret )
-       {
-               throw ActionException("builtin method or gettersetter for 
NetConnection objects called against non-NetConnection instance");
-       }
-       return ret;
-}
-
-
 /// \brief callback to instantiate a new NetConnection object.
 /// \param fn the parameters from the Flash movie
 /// \return nothing from the function call.
@@ -189,7 +175,7 @@
 {
        GNASH_REPORT_FUNCTION;
 
-       NetConnection *ptr = ensure_netconnection(fn.this_ptr); 
+       NetConnection *ptr = ensureType<NetConnection>(fn.this_ptr); 
     
        if (fn.nargs > 0) {
                ptr->addToURL(fn.arg(0).to_string());

Index: server/asobj/NetStream.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStream.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- server/asobj/NetStream.cpp  19 Mar 2007 17:11:14 -0000      1.30
+++ server/asobj/NetStream.cpp  20 Mar 2007 10:36:45 -0000      1.31
@@ -15,7 +15,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: NetStream.cpp,v 1.30 2007/03/19 17:11:14 bjacques Exp $ */
+/* $Id: NetStream.cpp,v 1.31 2007/03/20 10:36:45 ann Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -90,30 +90,16 @@
 
 }
 
-// Wrapper around dynamic_cast to implement user warning.
-// To be used by builtin properties and methods.
-static NetStream*
-ensure_netstream(as_object* obj)
-{
-       NetStream* ret = dynamic_cast<NetStream*>(obj);
-       if ( ! ret )
-       {
-               throw ActionException("builtin method or gettersetter for 
NetStream objects called against non-NetStream instance");
-       }
-       return ret;
-}
-
-
 static as_value netstream_close(const fn_call& fn)
 {
-       NetStream* ns = ensure_netstream(fn.this_ptr);
+       NetStream* ns = ensureType<NetStream>(fn.this_ptr);
        ns->close();
        return as_value();
 }
 
 static as_value netstream_pause(const fn_call& fn)
 {
-       NetStream* ns = ensure_netstream(fn.this_ptr);
+       NetStream* ns = ensureType<NetStream>(fn.this_ptr);
        
        // mode: -1 ==> toogle, 0==> pause, 1==> play
        int mode = -1;
@@ -127,7 +113,7 @@
 
 static as_value netstream_play(const fn_call& fn)
 {
-       NetStream* ns = ensure_netstream(fn.this_ptr);
+       NetStream* ns = ensureType<NetStream>(fn.this_ptr);
 
        if (fn.nargs < 1)
        {
@@ -145,7 +131,7 @@
 }
 
 static as_value netstream_seek(const fn_call& fn) {
-       NetStream* ns = ensure_netstream(fn.this_ptr);
+       NetStream* ns = ensureType<NetStream>(fn.this_ptr);
 
        double time = 0;
        if (fn.nargs > 0)
@@ -157,7 +143,7 @@
        return as_value();
 }
 static as_value netstream_setbuffertime(const fn_call& fn) {
-       NetStream* ns = ensure_netstream(fn.this_ptr);
+       NetStream* ns = ensureType<NetStream>(fn.this_ptr);
        UNUSED(ns);
     log_msg("%s:unimplemented \n", __FUNCTION__);
        return as_value();
@@ -168,7 +154,7 @@
 netstream_time(const fn_call& fn)
 {
 
-       NetStream* ns = ensure_netstream(fn.this_ptr);
+       NetStream* ns = ensureType<NetStream>(fn.this_ptr);
 
        if ( fn.nargs == 0 )
        {
@@ -188,7 +174,7 @@
 netstream_bytesloaded(const fn_call& fn)
 {
 
-       NetStream* ns = ensure_netstream(fn.this_ptr);
+       NetStream* ns = ensureType<NetStream>(fn.this_ptr);
 
        if ( fn.nargs == 0 )
        {
@@ -208,7 +194,7 @@
 netstream_bytestotal(const fn_call& fn)
 {
 
-       NetStream* ns = ensure_netstream(fn.this_ptr);
+       NetStream* ns = ensureType<NetStream>(fn.this_ptr);
 
        if ( fn.nargs == 0 )
        {

Index: server/asobj/Sound.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Sound.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- server/asobj/Sound.cpp      19 Mar 2007 17:11:14 -0000      1.8
+++ server/asobj/Sound.cpp      20 Mar 2007 10:36:45 -0000      1.9
@@ -249,24 +249,11 @@
        return as_value(sound_obj);
 }
 
-// Wrapper around dynamic_cast to implement user warning.
-// To be used by builtin properties and methods.
-static Sound*
-ensure_sound(as_object* obj)
-{
-       Sound* ret = dynamic_cast<Sound*>(obj);
-       if ( ! ret )
-       {
-               throw ActionException("builtin method or gettersetter for Sound 
objects called against non-Sound instance");
-       }
-       return ret;
-}
-
 as_value
 sound_start(const fn_call& fn)
 {
        log_action("-- start sound");
-       Sound* so = ensure_sound(fn.this_ptr);
+       Sound* so = ensureType<Sound>(fn.this_ptr);
        int loop = 0;
        int secondOffset = 0;
 
@@ -289,7 +276,7 @@
 sound_stop(const fn_call& fn)
 {
        log_action("-- stop sound ");
-       Sound* so = ensure_sound(fn.this_ptr);
+       Sound* so = ensureType<Sound>(fn.this_ptr);
 
        int si = -1;
 
@@ -338,7 +325,7 @@
            return as_value();
        }
 
-       Sound* so = ensure_sound(fn.this_ptr);
+       Sound* so = ensureType<Sound>(fn.this_ptr);
 
     const char* name = fn.arg(0).to_string();
     if (!name) {
@@ -431,7 +418,7 @@
 sound_getvolume(const fn_call& fn)
 {
 
-       Sound* so = ensure_sound(fn.this_ptr);
+       Sound* so = ensureType<Sound>(fn.this_ptr);
 
        int volume = so->getVolume();
 
@@ -449,7 +436,7 @@
            return as_value();          
        }
 
-       Sound* so = ensure_sound(fn.this_ptr);
+       Sound* so = ensureType<Sound>(fn.this_ptr);
        so->loadSound(fn.arg(0).to_std_string(), fn.arg(1).to_bool());
 
        return as_value();
@@ -490,7 +477,7 @@
                return as_value();
        }
 
-       Sound* so = ensure_sound(fn.this_ptr);  
+       Sound* so = ensureType<Sound>(fn.this_ptr);     
        int volume = (int) fn.arg(0).to_number();
 
        so->setVolume(volume);
@@ -500,7 +487,7 @@
 as_value
 sound_duration(const fn_call& fn)
 {
-       Sound* so = ensure_sound(fn.this_ptr);
+       Sound* so = ensureType<Sound>(fn.this_ptr);
        if ( fn.nargs == 0 ) {
                return as_value(so->getDuration());
     } else {
@@ -526,7 +513,7 @@
 as_value
 sound_position(const fn_call& fn)
 {
-       Sound* so = ensure_sound(fn.this_ptr);
+       Sound* so = ensureType<Sound>(fn.this_ptr);
        if ( fn.nargs == 0 ) {
                return as_value(so->getPosition());
     } else {

Index: server/asobj/gen-asclass.sh
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/gen-asclass.sh,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/asobj/gen-asclass.sh 19 Mar 2007 17:11:14 -0000      1.10
+++ server/asobj/gen-asclass.sh 20 Mar 2007 10:36:45 -0000      1.11
@@ -203,19 +203,6 @@
 };
 
 EOF
-
-cat <<EOF>>${srcname}
-static ${lowname}_as_object* 
-ensure_${lowname}(as_object* obj)
-{
-       ${lowname}_as_object* ret = dynamic_cast<${lowname}_as_object*>(obj);
-       if ( ! ret )
-       {
-               throw ActionException("builtin method or gettersetter for 
${asname} objects called against non-${asname} instance");
-       }
-       return ret;
-}
-EOF
 for i in $methods; do
 # DO NOT CONVERT CASE, SWF7+ is case-sensitive 
 newi=`echo $i | sed -e 's/)//g'` # | tr '[A-Z]' '[a-z]'
@@ -223,7 +210,7 @@
 static as_value
 ${lowname}_${newi}const fn_call& fn)
 {
-       ${lowname}_as_object* ptr = ensure_${lowname}(fn.this_ptr);
+       ${lowname}_as_object* ptr = 
ensureType<${lowname}_as_object>(fn.this_ptr);
        UNUSED(ptr);
        log_warning("%s: unimplemented", __FUNCTION__);
        return as_value();

Index: server/asobj/string.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/string.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- server/asobj/string.cpp     19 Mar 2007 17:11:14 -0000      1.19
+++ server/asobj/string.cpp     20 Mar 2007 10:36:45 -0000      1.20
@@ -14,7 +14,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: string.cpp,v 1.19 2007/03/19 17:11:14 bjacques Exp $ */
+/* $Id: string.cpp,v 1.20 2007/03/20 10:36:45 ann Exp $ */
 
 // Implementation of ActionScript String class.
 
@@ -113,21 +113,10 @@
 
 };
 
-static tu_string_as_object *
-ensureString(as_object* obj)
-{
-       tu_string_as_object* ret = dynamic_cast<tu_string_as_object*>(obj);
-       if ( ! ret )
-       {
-               throw ActionException("builtin method or gettersetter for 
String objects called against non-String instance");
-       }
-       return ret;
-}
-
 static as_value
 string_get_length(const fn_call& fn)
 {
-       tu_string_as_object* str = ensureString(fn.this_ptr);
+       tu_string_as_object* str = ensureType<tu_string_as_object>(fn.this_ptr);
 
        return as_value(str->m_string.utf8_length());
 
@@ -146,7 +135,7 @@
 static as_value
 string_concat(const fn_call& fn)
 {
-       tu_string_as_object* str = ensureString(fn.this_ptr);
+       tu_string_as_object* str = ensureType<tu_string_as_object>(fn.this_ptr);
        tu_string this_string = str->m_string;
        
        int len = strlen(this_string.c_str());
@@ -172,7 +161,7 @@
 static as_value
 string_slice(const fn_call& fn)
 {
-       tu_string_as_object* str = ensureString(fn.this_ptr);
+       tu_string_as_object* str = ensureType<tu_string_as_object>(fn.this_ptr);
        tu_string this_string = str->m_string;
        // Pull a slice out of this_string.
        int     start = 0;
@@ -205,7 +194,7 @@
 static as_value
 string_split(const fn_call& fn)
 {
-       tu_string_as_object* str = ensureString(fn.this_ptr);
+       tu_string_as_object* str = ensureType<tu_string_as_object>(fn.this_ptr);
 
        boost::intrusive_ptr<tu_string_as_object> this_string_ptr(str); // why 
??
        
@@ -277,7 +266,7 @@
 static as_value
 string_last_index_of(const fn_call& fn)
 {
-       tu_string_as_object* this_string_ptr = ensureString(fn.this_ptr);
+       tu_string_as_object* this_string_ptr = 
ensureType<tu_string_as_object>(fn.this_ptr);
 
        if (fn.nargs < 1)
        {
@@ -315,7 +304,7 @@
 static as_value
 string_sub_str(const fn_call& fn)
 {
-       tu_string_as_object* this_string_ptr = ensureString(fn.this_ptr);
+       tu_string_as_object* this_string_ptr = 
ensureType<tu_string_as_object>(fn.this_ptr);
        tu_string this_string = this_string_ptr->m_string;
 
        // Pull a slice out of this_string.
@@ -341,7 +330,7 @@
 static as_value
 string_sub_string(const fn_call& fn)
 {
-       tu_string_as_object* this_string_ptr = ensureString(fn.this_ptr);
+       tu_string_as_object* this_string_ptr = 
ensureType<tu_string_as_object>(fn.this_ptr);
        tu_string this_string = this_string_ptr->m_string;
        // Pull a slice out of this_string.
        int     start = 0;
@@ -366,7 +355,7 @@
 static as_value
 string_index_of(const fn_call& fn)
 {
-       tu_string_as_object* this_string_ptr = ensureString(fn.this_ptr);
+       tu_string_as_object* this_string_ptr = 
ensureType<tu_string_as_object>(fn.this_ptr);
 
        if (fn.nargs < 1)
        {
@@ -395,7 +384,7 @@
 static as_value
 string_from_char_code(const fn_call& fn)
 {
-       //tu_string_as_object* this_string_ptr = ensureString(fn.this_ptr);
+       //tu_string_as_object* this_string_ptr = 
ensureType<tu_string_as_object>(fn.this_ptr);
 
        tu_string result;
 
@@ -411,7 +400,7 @@
 static as_value
 string_char_code_at(const fn_call& fn)
 {
-       tu_string_as_object* this_string_ptr = ensureString(fn.this_ptr);
+       tu_string_as_object* this_string_ptr = 
ensureType<tu_string_as_object>(fn.this_ptr);
 
        // assert(fn.nargs == 1);
        if (fn.nargs < 1) {
@@ -440,7 +429,7 @@
 static as_value
 string_char_at(const fn_call& fn)
 {
-       tu_string_as_object* this_string_ptr = ensureString(fn.this_ptr);
+       tu_string_as_object* this_string_ptr = 
ensureType<tu_string_as_object>(fn.this_ptr);
 
        // assert(fn.nargs == 1);
        if (fn.nargs < 1) {
@@ -469,7 +458,7 @@
 static as_value
 string_to_upper_case(const fn_call& fn)
 {
-       tu_string_as_object* this_string_ptr = ensureString(fn.this_ptr);
+       tu_string_as_object* this_string_ptr = 
ensureType<tu_string_as_object>(fn.this_ptr);
 
        return as_value(this_string_ptr->m_string.utf8_to_upper());
 }
@@ -477,7 +466,7 @@
 static as_value
 string_to_lower_case(const fn_call& fn)
 {
-       tu_string_as_object* this_string_ptr = ensureString(fn.this_ptr);
+       tu_string_as_object* this_string_ptr = 
ensureType<tu_string_as_object>(fn.this_ptr);
 
        return as_value(this_string_ptr->m_string.utf8_to_lower());
 }
@@ -485,7 +474,7 @@
 static as_value
 string_to_string(const fn_call& fn)
 {
-       tu_string_as_object* this_string_ptr = ensureString(fn.this_ptr);
+       tu_string_as_object* this_string_ptr = 
ensureType<tu_string_as_object>(fn.this_ptr);
        return as_value(this_string_ptr->m_string);
 }
 




reply via email to

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