gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/asobj/Key.cpp server/aso...


From: Ann Barcomb
Subject: [Gnash-commit] gnash ChangeLog server/asobj/Key.cpp server/aso...
Date: Tue, 20 Mar 2007 11:36:48 +0000

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

Modified files:
        .              : ChangeLog 
        server/asobj   : Key.cpp LocalConnection.cpp MovieClipLoader.cpp 
                         xml.cpp xmlnode.cpp xmlsocket.cpp 

Log message:
        Change casts and asserts to ensureType; Sandro advised this when
        reviewing the ActionScript manual which contained examples from xml.cpp:
        
            > -                     fn.result->set_as_object_interface(xml_obj);
            > +                        assert(dynamic_cast&lt;XML*&gt;(obj));
            Don't assert, or new XML(new Date) will abort Gnash.
            Rather, check as you did after .to_object() above.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2637&r2=1.2638
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Key.cpp?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/LocalConnection.cpp?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/MovieClipLoader.cpp?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xml.cpp?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlnode.cpp?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlsocket.cpp?cvsroot=gnash&r1=1.10&r2=1.11

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2637
retrieving revision 1.2638
diff -u -b -r1.2637 -r1.2638
--- ChangeLog   20 Mar 2007 10:36:44 -0000      1.2637
+++ ChangeLog   20 Mar 2007 11:36:48 -0000      1.2638
@@ -1,5 +1,10 @@
 2007-03-20 Ann Barcomb <address@hidden>
 
+       * server/asobj/Key.cpp, MovieClipLoader.cpp, xml.cpp, xmlnode.cpp,
+         xmlsocket.cpp: Change casts and asserts to ensureType.
+
+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.

Index: server/asobj/Key.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Key.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- server/asobj/Key.cpp        19 Mar 2007 17:11:14 -0000      1.17
+++ server/asobj/Key.cpp        20 Mar 2007 11:36:48 -0000      1.18
@@ -238,8 +238,7 @@
            return as_value();
        }
 
-    key_as_object*     ko = static_cast<key_as_object*>( fn.this_ptr );
-    assert(ko);
+    key_as_object* ko = ensureType<key_as_object>( fn.this_ptr );
 
     ko->add_listener(listener);
     return as_value();
@@ -248,8 +247,7 @@
 as_value       key_get_ascii(const fn_call& fn)
     // Return the ascii value of the last key pressed.
 {
-    key_as_object*     ko = static_cast<key_as_object*>( fn.this_ptr );
-    assert(ko);
+    key_as_object* ko = ensureType<key_as_object>( fn.this_ptr );
 
     int        code = ko->get_last_key_pressed();
     if (code < 0)
@@ -267,8 +265,7 @@
 as_value       key_get_code(const fn_call& fn)
     // Returns the keycode of the last key pressed.
 {
-    key_as_object*     ko = static_cast<key_as_object*>( fn.this_ptr );
-    assert(ko);
+    key_as_object* ko = ensureType<key_as_object>( fn.this_ptr );
 
     return as_value(ko->get_last_key_pressed());
 }
@@ -284,8 +281,7 @@
 
     int        code = (int) fn.arg(0).to_number();
 
-    key_as_object*     ko = static_cast<key_as_object*>( fn.this_ptr );
-    assert(ko);
+    key_as_object* ko = ensureType<key_as_object>( fn.this_ptr );
 
     return as_value(ko->is_key_down(code));
 }
@@ -314,8 +310,7 @@
            return as_value();
        }
 
-    key_as_object*     ko = static_cast<key_as_object*>( fn.this_ptr );
-    assert(ko);
+    key_as_object* ko = ensureType<key_as_object>( fn.this_ptr );
 
     ko->remove_listener(listener);
     return as_value();

Index: server/asobj/LocalConnection.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/LocalConnection.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- server/asobj/LocalConnection.cpp    19 Mar 2007 17:11:14 -0000      1.8
+++ server/asobj/LocalConnection.cpp    20 Mar 2007 11:36:48 -0000      1.9
@@ -124,8 +124,7 @@
 {
 //    log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
     
-    localconnection_as_object *ptr = (localconnection_as_object*)fn.this_ptr;
-    assert(ptr);
+    localconnection_as_object *ptr = 
ensureType<localconnection_as_object>(fn.this_ptr);
     
     ptr->obj.close();
     return as_value();
@@ -136,9 +135,8 @@
 {
 //    log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
     bool ret;
-    localconnection_as_object *ptr = (localconnection_as_object*)fn.this_ptr;
+    localconnection_as_object *ptr = 
ensureType<localconnection_as_object>(fn.this_ptr);
     
-    assert(ptr);
     if (fn.nargs != 0) {
         ret = 
ptr->obj.connect(fn.env->bottom(fn.first_arg_bottom_index).to_string());
     } else {
@@ -153,8 +151,7 @@
 as_value localconnection_domain(const fn_call& fn)
 {
 //    log_msg("%s:\n", __PRETTY_FUNCTION__);
-    localconnection_as_object *ptr = (localconnection_as_object*)fn.this_ptr;
-    assert(ptr);
+    localconnection_as_object *ptr = 
ensureType<localconnection_as_object>(fn.this_ptr);
     return as_value(ptr->obj.domain().c_str());
 }
 

Index: server/asobj/MovieClipLoader.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/MovieClipLoader.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- server/asobj/MovieClipLoader.cpp    19 Mar 2007 17:11:14 -0000      1.20
+++ server/asobj/MovieClipLoader.cpp    20 Mar 2007 11:36:48 -0000      1.21
@@ -308,10 +308,7 @@
 
        //log_msg("%s: nargs = %d\n", __FUNCTION__, fn.nargs);
 
-       MovieClipLoader* ptr = \
-               dynamic_cast<MovieClipLoader*>(fn.this_ptr);
-
-       assert(ptr);
+       MovieClipLoader* ptr = ensureType<MovieClipLoader>(fn.this_ptr);
   
        as_value& url_arg = fn.arg(0);
 #if 0 // whatever it is, we'll need a string, the check below would only be 
worth
@@ -377,8 +374,7 @@
 {
   //log_msg("%s: nargs = %d\n", __FUNCTION__, nargs);
   
-  MovieClipLoader* ptr = dynamic_cast<MovieClipLoader*>(fn.this_ptr);
-  assert(ptr); // or warn if bogus call ?
+  MovieClipLoader* ptr = ensureType<MovieClipLoader>(fn.this_ptr);
   
   as_object *target = fn.arg(0).to_object();
   
@@ -395,8 +391,7 @@
 static as_value
 moviecliploader_addlistener(const fn_call& fn)
 {
-       assert(dynamic_cast<MovieClipLoader*>(fn.this_ptr));
-       MovieClipLoader* mcl = static_cast<MovieClipLoader*>(fn.this_ptr);
+       MovieClipLoader* mcl = ensureType<MovieClipLoader>(fn.this_ptr);
   
        as_object *listener = fn.arg(0).to_object();
        if ( ! listener )
@@ -412,8 +407,7 @@
 static as_value
 moviecliploader_removelistener(const fn_call& fn)
 {
-       assert(dynamic_cast<MovieClipLoader*>(fn.this_ptr));
-       MovieClipLoader* mcl = static_cast<MovieClipLoader*>(fn.this_ptr);
+       MovieClipLoader* mcl = ensureType<MovieClipLoader>(fn.this_ptr);
   
        as_object *listener = fn.arg(0).to_object();
        if ( ! listener )

Index: server/asobj/xml.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xml.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- server/asobj/xml.cpp        19 Mar 2007 17:11:14 -0000      1.20
+++ server/asobj/xml.cpp        20 Mar 2007 11:36:48 -0000      1.21
@@ -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: xml.cpp,v 1.20 2007/03/19 17:11:14 bjacques Exp $ */
+/* $Id: xml.cpp,v 1.21 2007/03/20 11:36:48 ann Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -768,7 +768,7 @@
 
     //GNASH_REPORT_FUNCTION;
   
-    XML *xml_obj = (XML*)fn.this_ptr;
+    XML *xml_obj = ensureType<XML>(fn.this_ptr);
   
     std::string filespec = fn.arg(0).to_string(); 
 
@@ -842,8 +842,7 @@
     as_value   method;
     as_value      val;
     static bool first = true;     // This event handler should only be 
executed once.
-    XML*       ptr = (XML*) (as_object*) fn.this_ptr;
-    assert(ptr);
+    XML*       ptr = ensureType<XML>(fn.this_ptr);
   
     if ((ptr->loaded()) && (first)) {
         // env->set_variable("success", true, 0);
@@ -877,8 +876,7 @@
     as_value   val;
     static bool first = true;     // FIXME: ugly hack!
   
-    XML*       ptr = (XML*)fn.this_ptr;
-    assert(ptr);
+    XML*       ptr = ensureType<XML>(fn.this_ptr);
   
     if ((ptr->loaded()) && (first)) {
         if (fn.this_ptr->get_member("onData", &method)) {
@@ -967,8 +965,7 @@
             //xml_obj->clear();
             //delete xml_obj->firstChild();
         } else {
-           assert(dynamic_cast<XML*>(obj));
-            XML*       xml_obj = (XML*)obj;
+            XML*       xml_obj = ensureType<XML>(obj);
             //log_msg("\tCloned the XML object at %p\n", xml_obj);
             //result->set(xml_obj);
             return as_value(xml_obj);
@@ -998,8 +995,7 @@
 
     log_msg("%s:\n", __FUNCTION__);
     
-    XML*       ptr = (XML*) (as_object*) fn.this_ptr;
-    assert(ptr);
+    XML*       ptr = ensureType<XML>(fn.this_ptr);
     std::string filespec = fn.arg(0).to_string();
     //fn.result->set(ptr->loaded());
     return as_value(ptr->loaded());
@@ -1010,8 +1006,6 @@
 {
     GNASH_REPORT_FUNCTION;
     log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
-    XML *ptr = (XML*)fn.this_ptr;
-    assert(ptr);
     
 //    return as_value(ptr->getAllocated());
 //    ptr->addRequestHeader();
@@ -1023,8 +1017,7 @@
     GNASH_REPORT_FUNCTION;
     //    log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
     if (fn.nargs > 0) {
-       XML *ptr = (XML*)fn.this_ptr;
-       assert(ptr);
+       XML *ptr = ensureType<XML>(fn.this_ptr);
        XMLNode *xml_obj = dynamic_cast<XMLNode*>(fn.arg(0).to_object());
        if (xml_obj->nodeType() == XML_ELEMENT_NODE) {
            ptr->appendChild(xml_obj);
@@ -1041,9 +1034,8 @@
 {
     GNASH_REPORT_FUNCTION;
 //    log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
-    XML        *ptr = (XML*)fn.this_ptr;
+    XML *ptr = ensureType<XML>(fn.this_ptr);
     XMLNode   *xml_obj;
-    assert(ptr);
 
     if (fn.nargs > 0) {
        bool deep = fn.arg(0).to_bool(); 
@@ -1070,9 +1062,6 @@
 {
 //    GNASH_REPORT_FUNCTION;
     
-    XML *ptr = (XML*)fn.this_ptr;
-    assert(ptr);
-
     if (fn.nargs > 0) {
         const char *text = fn.arg(0).to_string();
        XMLNode *xml_obj = new XMLNode();
@@ -1102,8 +1091,7 @@
 {
 //    GNASH_REPORT_FUNCTION;
 
-    //assert(dynamic_cast<XML*>(fn.this_ptr));
-    //XML *ptr = static_cast<XML*>(fn.this_ptr);
+    //XML *ptr = ensureType<XML>(fn.this_ptr);
 
     XMLNode *xml_obj;
     const char *text;
@@ -1123,23 +1111,20 @@
 
 as_value xml_getbytesloaded(const fn_call& fn)
 {
-    XML *ptr = (XML*)fn.this_ptr;
-    assert(ptr);
+    XML *ptr = ensureType<XML>(fn.this_ptr);
     return as_value(ptr->getBytesLoaded());
 }
 
 as_value xml_getbytestotal(const fn_call& fn)
 {
-    XML *ptr = (XML*)fn.this_ptr;
-    assert(ptr);
+    XML *ptr = ensureType<XML>(fn.this_ptr);
     return as_value(ptr->getBytesTotal());
 }
 
 as_value xml_haschildnodes(const fn_call& fn)
 {
     GNASH_REPORT_FUNCTION;
-    XML *ptr = (XML*)fn.this_ptr;
-    assert(ptr);
+    XML *ptr = ensureType<XML>(fn.this_ptr);
     return as_value(ptr->hasChildNodes());
 }
 
@@ -1154,8 +1139,6 @@
 as_value xml_insertbefore(const fn_call& fn)
 {
     GNASH_REPORT_FUNCTION;
-    XML *ptr = (XML*)fn.this_ptr;
-    assert(ptr);
     
 //    return as_value(ptr->getAllocated());
 //    ptr->insertBefore();
@@ -1169,8 +1152,7 @@
     const char *text;
     as_value   method;
     as_value   val;    
-    XML *ptr = (XML*)fn.this_ptr;
-    assert(ptr);
+    XML *ptr = ensureType<XML>(fn.this_ptr);
 
     if (fn.nargs > 0) {
         text = fn.arg(0).to_string(); 
@@ -1202,8 +1184,7 @@
 as_value xml_removenode(const fn_call& fn)
 {
     GNASH_REPORT_FUNCTION;
-    XML *ptr = (XML*)fn.this_ptr;
-    assert(ptr);
+    XML *ptr = ensureType<XML>(fn.this_ptr);
     
 //    return as_value(ptr->getAllocated());
     ptr->removeNode();
@@ -1212,8 +1193,7 @@
 as_value xml_send(const fn_call& fn)
 {
     GNASH_REPORT_FUNCTION;
-    XML *ptr = (XML*)fn.this_ptr;
-    assert(ptr);
+    XML *ptr = ensureType<XML>(fn.this_ptr);
     
 //    return as_value(ptr->getAllocated());
     ptr->send();
@@ -1222,8 +1202,7 @@
 as_value xml_sendandload(const fn_call& fn)
 {
     GNASH_REPORT_FUNCTION;
-    XML *ptr = (XML*)fn.this_ptr;
-    assert(ptr);
+    XML *ptr = ensureType<XML>(fn.this_ptr);
     
 //    return as_value(ptr->getAllocated());
     ptr->sendAndLoad();
@@ -1232,8 +1211,7 @@
 as_value xml_tostring(const fn_call& fn)
 {
 //    GNASH_REPORT_FUNCTION;
-    XML *ptr = (XML*)fn.this_ptr;
-    assert(ptr);
+    XML *ptr = ensureType<XML>(fn.this_ptr);
 
     // TODO: There is also the "stringify" function to be used here.
     // See above. Wot does FlashPlayer return for this call?
@@ -1248,8 +1226,7 @@
 xml_nodename(const fn_call& fn)
 {
 //    GNASH_REPORT_FUNCTION;
-    assert(dynamic_cast<XML*>(fn.this_ptr));
-    XML *ptr = static_cast<XML*>(fn.this_ptr);
+    XML *ptr = ensureType<XML>(fn.this_ptr);
 
     if ( fn.nargs == 0 ) {
        const char* val = ptr->nodeName();
@@ -1270,8 +1247,7 @@
 {
 //    GNASH_REPORT_FUNCTION;
 
-    assert(dynamic_cast<XML*>(fn.this_ptr));
-    XML *ptr = static_cast<XML*>(fn.this_ptr);
+    XML *ptr = ensureType<XML>(fn.this_ptr);
     
     //log_msg("xml_nodevalue called with %d args against 'this' = %p", 
fn.nargs, ptr);
     if ( fn.nargs == 0 ) {
@@ -1294,8 +1270,7 @@
 xml_firstchild(const fn_call& fn)
 {
     GNASH_REPORT_FUNCTION;
-    assert(dynamic_cast<XML*>(fn.this_ptr));
-    XML *ptr = static_cast<XML*>(fn.this_ptr);
+    XML *ptr = ensureType<XML>(fn.this_ptr);
 
     if ( fn.nargs == 0 ) {
        //return as_value(ptr->firstChild());
@@ -1313,8 +1288,7 @@
 xml_childnodes(const fn_call& fn)
 {
     GNASH_REPORT_FUNCTION;
-    assert(dynamic_cast<XML*>(fn.this_ptr));
-    XML *ptr = static_cast<XML*>(fn.this_ptr);
+    XML *ptr = ensureType<XML>(fn.this_ptr);
 
     if ( fn.nargs == 0 ) {
        //return as_value(ptr->childNodes());

Index: server/asobj/xmlnode.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlnode.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- server/asobj/xmlnode.cpp    19 Mar 2007 17:11:14 -0000      1.17
+++ server/asobj/xmlnode.cpp    20 Mar 2007 11:36:48 -0000      1.18
@@ -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: xmlnode.cpp,v 1.17 2007/03/19 17:11:14 bjacques Exp $ */
+/* $Id: xmlnode.cpp,v 1.18 2007/03/20 11:36:48 ann Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -493,8 +493,7 @@
 {
 //    GNASH_REPORT_FUNCTION;
     if (fn.nargs > 0) {
-       XMLNode *ptr = (XMLNode*)fn.this_ptr;
-       assert(ptr);
+       XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
 //    log_msg("%s: %p, %d args\n", __PRETTY_FUNCTION__, ptr, fn.nargs);
        
        XMLNode *xml_obj = dynamic_cast<XMLNode*>(fn.arg(0).to_object());       
@@ -527,9 +526,8 @@
 {
     GNASH_REPORT_FUNCTION;
 //    log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
-    XMLNode    *ptr = (XMLNode*)fn.this_ptr;
+    XMLNode    *ptr = ensureType<XMLNode>(fn.this_ptr);
     XMLNode   *xmlnode_obj;
-    assert(ptr);
 
     if (fn.nargs > 0) {
        bool deep = fn.arg(0).to_bool();
@@ -547,8 +545,7 @@
 xmlnode_insertbefore(const fn_call& fn)
 {
     GNASH_REPORT_FUNCTION;
-    XMLNode *ptr = (XMLNode*)fn.this_ptr;
-    assert(ptr);
+    XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
     
 //    return as_value(ptr->obj.getAllocated());
 //    ptr->obj.insertBefore();
@@ -560,8 +557,7 @@
 xmlnode_removenode(const fn_call& fn)
 {
     GNASH_REPORT_FUNCTION;
-    XMLNode *ptr = (XMLNode*)fn.this_ptr;
-    assert(ptr);
+    XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
     
 //    return as_value(ptr->obj.getAllocated());
     ptr->removeNode();
@@ -574,8 +570,7 @@
 {
 //    GNASH_REPORT_FUNCTION;
     
-    XMLNode *ptr = (XMLNode*)fn.this_ptr;
-    assert(ptr);
+    XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
     
     return as_value(ptr->toString());
 }
@@ -584,8 +579,7 @@
 xmlnode_haschildnodes(const fn_call& fn)
 {
 //    GNASH_REPORT_FUNCTION;
-    XMLNode *ptr = (XMLNode*)fn.this_ptr;
-    assert(ptr);
+    XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
     return as_value(ptr->hasChildNodes());
 }
 
@@ -595,8 +589,7 @@
 {
     //GNASH_REPORT_FUNCTION;
 
-    assert(dynamic_cast<XMLNode*>(fn.this_ptr));
-    XMLNode *ptr = static_cast<XMLNode*>(fn.this_ptr);
+    XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
     as_value rv;
     rv.set_null();
     
@@ -619,8 +612,7 @@
 xmlnode_nodename(const fn_call& fn)
 {
 //    GNASH_REPORT_FUNCTION;
-    assert(dynamic_cast<XMLNode*>(fn.this_ptr));
-    XMLNode *ptr = static_cast<XMLNode*>(fn.this_ptr);
+    XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
     as_value rv;
     rv.set_null();
 
@@ -641,8 +633,7 @@
 {
 //    GNASH_REPORT_FUNCTION;
     
-    assert(dynamic_cast<XMLNode*>(fn.this_ptr));
-    XMLNode *ptr = static_cast<XMLNode*>(fn.this_ptr);
+    XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
 
     if ( fn.nargs == 0 ) {
        return as_value(ptr->nodeType());
@@ -659,8 +650,7 @@
 xmlnode_firstchild(const fn_call& fn)
 {
 //    GNASH_REPORT_FUNCTION;
-    assert(dynamic_cast<XMLNode*>(fn.this_ptr));
-    XMLNode *ptr = static_cast<XMLNode*>(fn.this_ptr);
+    XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
     as_value rv;
     rv.set_null();
 
@@ -686,8 +676,7 @@
 xmlnode_lastchild(const fn_call& fn)
 {
 //    GNASH_REPORT_FUNCTION;
-    assert(dynamic_cast<XMLNode*>(fn.this_ptr));
-    XMLNode *ptr = static_cast<XMLNode*>(fn.this_ptr);
+    XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
     as_value rv;
     rv.set_null();
 
@@ -722,8 +711,7 @@
        return rv;
     }
     
-    assert(dynamic_cast<XMLNode*>(fn.this_ptr));
-    XMLNode *ptr = static_cast<XMLNode*>(fn.this_ptr);
+    XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
     XMLNode *node = ptr->nextSibling();
     if (node) {
        rv = node;
@@ -747,8 +735,7 @@
        return rv;
     }
 
-    assert(dynamic_cast<XMLNode*>(fn.this_ptr));
-    XMLNode *ptr = static_cast<XMLNode*>(fn.this_ptr);
+    XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
     XMLNode *node = ptr->previousSibling();
     if (node) {
        rv = node;

Index: server/asobj/xmlsocket.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlsocket.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/asobj/xmlsocket.cpp  19 Mar 2007 17:11:14 -0000      1.10
+++ server/asobj/xmlsocket.cpp  20 Mar 2007 11:36:48 -0000      1.11
@@ -378,8 +378,7 @@
     }
     
     log_msg("%s: nargs=%d\n", __FUNCTION__, fn.nargs);
-    xmlsocket_as_object*       ptr = (xmlsocket_as_object*) (as_object*) 
fn.this_ptr;
-    assert(ptr);
+    xmlsocket_as_object* ptr = ensureType<xmlsocket_as_object>(fn.this_ptr);
     const std::string host = 
fn.env->bottom(fn.first_arg_bottom_index).to_string();
     std::string port_str = 
fn.env->bottom(fn.first_arg_bottom_index-1).to_string();
     double port = atof(port_str.c_str());
@@ -426,8 +425,7 @@
     as_value   method;
     as_value   val;
     
-    xmlsocket_as_object*       ptr = (xmlsocket_as_object*) (as_object*) 
fn.this_ptr;
-    assert(ptr);
+    xmlsocket_as_object* ptr = ensureType<xmlsocket_as_object>(fn.this_ptr);
     const std::string object = fn.env->bottom( 
fn.first_arg_bottom_index).to_string();
     //  log_msg("%s: host=%s, port=%g\n", __FUNCTION__, host, port);
     return as_value(ptr->obj.send(object));
@@ -440,8 +438,7 @@
     as_value   method;
     as_value   val;
     
-    xmlsocket_as_object*       ptr = (xmlsocket_as_object*) (as_object*) 
fn.this_ptr;
-    assert(ptr);
+    xmlsocket_as_object* ptr = ensureType<xmlsocket_as_object>(fn.this_ptr);
     // Since the return code from close() doesn't get used by Shockwave,
     // we don't care either.
     ptr->obj.close();
@@ -532,8 +529,7 @@
     char          *messages[200];
     int           i;
     
-    xmlsocket_as_object*       ptr = (xmlsocket_as_object*)fn.this_ptr;
-    assert(ptr);
+    xmlsocket_as_object* ptr = ensureType<xmlsocket_as_object>(fn.this_ptr);
     if (ptr->obj.processingData()) {
         log_msg("Still processing data!\n");
         return as_value(false);
@@ -613,8 +609,7 @@
         return as_value(true);
     }
     
-    xmlsocket_as_object*       ptr = (xmlsocket_as_object*) (as_object*) 
fn.this_ptr;
-    assert(ptr);
+    xmlsocket_as_object* ptr = ensureType<xmlsocket_as_object>(fn.this_ptr);
     
     log_msg("%s: connected = %d\n", __FUNCTION__, ptr->obj.connected());
     if ((ptr->obj.connected()) && (first)) {




reply via email to

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