gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r11434: More refactoring.


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11434: More refactoring.
Date: Fri, 21 Aug 2009 15:54:41 +0200
User-agent: Bazaar (1.16.1)

------------------------------------------------------------
revno: 11434 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2009-08-21 15:54:41 +0200
message:
  More refactoring.
modified:
  libcore/asMethod.cpp
  libcore/as_environment.cpp
  libcore/as_object.h
  libcore/asobj/LoadVars_as.cpp
  libcore/asobj/flash/net/XMLSocket_as.cpp
  libcore/asobj/flash/xml/XMLDocument_as.cpp
  testsuite/actionscript.all/XML.as
  testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp
  testsuite/misc-ming.all/SpriteButtonEventsTest-Runner.cpp
  testsuite/movies.all/gravity_embedded-TestRunner.cpp
  testsuite/samples/clip_as_button2-TestRunner.cpp
=== modified file 'libcore/asMethod.cpp'
--- a/libcore/asMethod.cpp      2009-07-16 08:53:33 +0000
+++ b/libcore/asMethod.cpp      2009-08-21 12:29:40 +0000
@@ -70,7 +70,6 @@
        if (!_prototype) {
                log_debug("ERROR _prototype is null.");
        }
-       log_debug("Prototype text value: %s",_prototype->get_text_value());
        _prototype->set_member(NSV::PROP_PROTOTYPE, pOwner->getPrototype());
 }
 

=== modified file 'libcore/as_environment.cpp'
--- a/libcore/as_environment.cpp        2009-07-14 15:33:46 +0000
+++ b/libcore/as_environment.cpp        2009-08-21 12:29:40 +0000
@@ -90,7 +90,7 @@
             IF_VERBOSE_ASCODING_ERRORS(
             log_aserror(_("find_object(\"%s\") [ varname = '%s' - "
                         "current target = '%s' ] failed"),
-                        path, varname, m_target ? m_target->get_text_value() : 
"<null>");
+                        path, varname, m_target);
             as_value tmp = get_variable_raw(path, scopeStack, retTarget);
             if ( ! tmp.is_undefined() )
             {
@@ -753,7 +753,7 @@
 
 #ifdef DEBUG_TARGET_FINDING 
             log_debug(_("Invoking get_path_element(%s) on object "
-                    "%p (%s)"), subpart, (void *)env, env->get_text_value());
+                    "%p"), subpart, (void *)env);
 #endif
 
             as_object* element = env->get_path_element(subpartKey);

=== modified file 'libcore/as_object.h'
--- a/libcore/as_object.h       2009-08-21 08:48:47 +0000
+++ b/libcore/as_object.h       2009-08-21 12:29:40 +0000
@@ -268,9 +268,6 @@
     ///
     void dump_members(std::map<std::string, as_value>& to);
 
-    /// Return a text representation for this object
-    virtual std::string get_text_value() const { return "[object Object]"; }
-
     /// Return true if instances of this ActionScript class should use 
     /// a custom toString method, when available, for converting the object
     /// to a string.

=== modified file 'libcore/asobj/LoadVars_as.cpp'
--- a/libcore/asobj/LoadVars_as.cpp     2009-08-21 07:07:11 +0000
+++ b/libcore/asobj/LoadVars_as.cpp     2009-08-21 11:42:13 +0000
@@ -81,6 +81,7 @@
        o.init_member("toString", gl->createFunction(loadvars_tostring));
        o.init_member("onData", gl->createFunction(loadvars_onData));
        o.init_member("onLoad", gl->createFunction(loadvars_onLoad));
+    o.init_member("contentType", "application/x-www-form-urlencoded");
 }
 
 as_value

=== modified file 'libcore/asobj/flash/net/XMLSocket_as.cpp'
--- a/libcore/asobj/flash/net/XMLSocket_as.cpp  2009-08-21 07:09:32 +0000
+++ b/libcore/asobj/flash/net/XMLSocket_as.cpp  2009-08-21 12:58:03 +0000
@@ -24,7 +24,6 @@
 #include "GnashSystemFDHeaders.h"
 #include "network.h"
 #include "utility.h"
-#include "xml/XMLDocument_as.h"
 #include "net/XMLSocket_as.h"
 #include "as_function.h"
 #include "movie_root.h"
@@ -55,7 +54,6 @@
     // These are the event handlers called for this object
     as_value xmlsocket_onData(const fn_call& fn);
 
-    as_object* getXMLSocketInterface();
     void attachXMLSocketInterface(as_object& o);
 }
 
@@ -507,7 +505,6 @@
 as_value
 xmlsocket_new(const fn_call& fn)
 {
-
     as_object* obj = fn.this_ptr;
     obj->setRelay(new XMLSocket_as(obj));
     return as_value();
@@ -537,25 +534,26 @@
         return as_value();
     }
 
-    boost::intrusive_ptr<as_object> xml = new XMLDocument_as(xmlin);
-    as_value arg(xml.get());
-
-    fn.this_ptr->callMethod(NSV::PROP_ON_XML, arg);
+
+    Global_as* gl = getGlobal(fn);
+    as_function* ctor = gl->getMember(NSV::CLASS_XML).to_as_function();
+
+    fn_call::Args args;
+    args += xmlin;
+
+    as_value xml;
+    if (ctor) {
+        xml = ctor->constructInstance(fn.env(), args);
+    }
+
+    // The built-in function calls:
+    //
+    //      this.onXML(new XML(src));
+    fn.this_ptr->callMethod(NSV::PROP_ON_XML, xml);
 
     return as_value();
 }
 
-as_object*
-getXMLSocketInterface()
-{
-    static boost::intrusive_ptr<as_object> o;
-    if (!o) {
-        o = new as_object(getObjectInterface());
-        attachXMLSocketInterface(*o);
-    }
-    return o.get();
-}
-
 void
 attachXMLSocketInterface(as_object& o)
 {

=== modified file 'libcore/asobj/flash/xml/XMLDocument_as.cpp'
--- a/libcore/asobj/flash/xml/XMLDocument_as.cpp        2009-08-21 09:08:01 
+0000
+++ b/libcore/asobj/flash/xml/XMLDocument_as.cpp        2009-08-21 12:29:40 
+0000
@@ -72,7 +72,7 @@
        
        
     as_value xmldocument_ctor(const fn_call& fn);
-    void attachXMLProperties(as_object& /*o*/);
+    void attachXMLProperties(as_object& o);
        void attachXMLInterface(as_object& o);
     as_object* getXMLInterface();
 
@@ -84,11 +84,6 @@
     _loaded(-1), 
     _status(XML_OK)
 {
-#ifdef DEBUG_MEMORY_ALLOCATION
-    log_debug(_("Creating XML data at %p"), this);
-#endif
-
-    attachXMLProperties(*this);
 }
 
 // Parse the ASCII XML string into an XMLNode tree
@@ -98,10 +93,6 @@
     _loaded(-1), 
     _status(XML_OK)
 {
-#ifdef DEBUG_MEMORY_ALLOCATION
-    log_debug(_("Creating XML data at %p"), this);
-#endif
-
     parseXML(xml);
 }
 
@@ -635,11 +626,11 @@
 
 namespace {
 void
-attachXMLProperties(as_object& /*o*/)
+attachXMLProperties(as_object& o)
 {
-    // if we use a proper member here hasOwnProperty() would return true
-    // but we want it to return false instead. See XML.as
-    //o.init_member("status", as_value(XML::sOK));
+    const int flags = 0;
+    o.init_property("xmlDecl", &xml_xmlDecl, &xml_xmlDecl, flags);
+    o.init_property("docTypeDecl", &xml_docTypeDecl, &xml_docTypeDecl, flags);
 }
 
 
@@ -667,8 +658,6 @@
     o.init_member("sendAndLoad", vm.getNative(301, 2), flags);
     o.init_member("onData", gl->createFunction(xml_ondata), flags);
 
-    o.init_property("xmlDecl", &xml_xmlDecl, &xml_xmlDecl, flags);
-    o.init_property("docTypeDecl", &xml_docTypeDecl, &xml_docTypeDecl, flags);
 }
 
 as_object*
@@ -695,24 +684,25 @@
 as_value
 xml_new(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLDocument_as> xml_obj;
-
-    if ( fn.nargs > 0 )
-    {
-        if ( fn.arg(0).is_object() )
-        {
-            boost::intrusive_ptr<as_object> obj = 
fn.arg(0).to_object(*getGlobal(fn));
-            xml_obj = dynamic_cast<XMLDocument_as*>(obj.get());
-            if ( xml_obj )
-            {
-                log_debug(_("Cloned the XML object at %p"),
-                       (void *)xml_obj.get());
-                return as_value(xml_obj->cloneNode(true).get());
+
+    XMLDocument_as* xml_obj;
+
+    if (fn.nargs > 0) {
+
+        // Copy constructor clones nodes.
+        if (fn.arg(0).is_object()) {
+            as_object* obj = fn.arg(0).to_object(*getGlobal(fn)).get();
+            xml_obj = dynamic_cast<XMLDocument_as*>(obj);
+
+            if (xml_obj) {
+                as_object* clone = xml_obj->cloneNode(true).get();
+                attachXMLProperties(*clone);
+                return as_value(clone);
             }
         }
 
         const std::string& xml_in = fn.arg(0).to_string();
-        if ( xml_in.empty() )
+        if (xml_in.empty())
         {
             IF_VERBOSE_ASCODING_ERRORS(
             log_aserror(_("First arg given to XML constructor (%s) "
@@ -722,15 +712,17 @@
         else
         {
             xml_obj = new XMLDocument_as(xml_in);
-            xml_obj->setRelay(new LoadableObject(xml_obj.get()));
-            return as_value(xml_obj.get());
+            xml_obj->setRelay(new LoadableObject(xml_obj));
+            attachXMLProperties(*xml_obj);
+            return as_value(xml_obj);
         }
     }
 
     xml_obj = new XMLDocument_as;
-    xml_obj->setRelay(new LoadableObject(xml_obj.get()));
+    xml_obj->setRelay(new LoadableObject(xml_obj));
+    attachXMLProperties(*xml_obj);
 
-    return as_value(xml_obj.get());
+    return as_value(xml_obj);
 }
 
 /// Only available as ASnative.
@@ -822,7 +814,8 @@
 as_value
 xml_xmlDecl(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLDocument_as> ptr = 
ensureType<XMLDocument_as>(fn.this_ptr);
+    boost::intrusive_ptr<XMLDocument_as> ptr =
+        ensureType<XMLDocument_as>(fn.this_ptr);
 
     if (!fn.nargs)
     {
@@ -835,7 +828,7 @@
     // Setter
 
     const std::string& xml = fn.arg(0).to_string();
-    ptr->setDocTypeDecl(xml);
+    ptr->setXMLDecl(xml);
     
     return as_value();
 

=== modified file 'testsuite/actionscript.all/XML.as'
--- a/testsuite/actionscript.all/XML.as 2009-07-01 07:12:16 +0000
+++ b/testsuite/actionscript.all/XML.as 2009-08-21 11:42:13 +0000
@@ -867,12 +867,12 @@
 #endif
        {
 #if OUTPUT_VERSION < 6
-               check_totals(400);
+               check_totals(406);
 #else
 # if OUTPUT_VERSION < 8
-               check_totals(435);
+               check_totals(441);
 # else
-               check_totals(416);
+               check_totals(422);
 # endif
 #endif
                play();
@@ -1032,5 +1032,14 @@
 check_equals(h.toString(), "<?xMl decl?><?XMl new?><!dOcType new><tag />");
 check_equals(h.xmlDecl, "<?xMl decl?><?XMl new?>");
 
+h.xmlDecl = 7;
+check_equals(typeof(h.xmlDecl), "string");
+check_equals(h.xmlDecl, "7");
+check_equals(h.toString(), "7<!dOcType new><tag />");
+
+h.docTypeDecl = 98;
+check_equals(typeof(h.docTypeDecl), "string");
+check_equals(h.docTypeDecl, "98");
+check_equals(h.toString(), "798<tag />");
 stop();
 

=== modified file 'testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp'
--- a/testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp       2009-04-09 
11:41:59 +0000
+++ b/testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp       2009-08-21 
12:54:14 +0000
@@ -23,6 +23,7 @@
 #include "MovieTester.h"
 #include "MovieClip.h"
 #include "DisplayObject.h"
+#include "TextField.h"
 #include "DisplayList.h"
 #include "log.h"
 
@@ -34,7 +35,7 @@
 using namespace std;
 
 void
-test_mouse_activity(MovieTester& tester, const DisplayObject* text, const 
DisplayObject* text2, bool covered, bool enabled)
+test_mouse_activity(MovieTester& tester, const TextField* text, const 
TextField* text2, bool covered, bool enabled)
 {
        rgba red(255,0,0,255);
        rgba dark_red(128,0,0,255);
@@ -237,13 +238,16 @@
 
        check_equals(root->get_current_frame(), 0);
 
-       const DisplayObject* text = tester.findDisplayItemByName(*root, 
"textfield");
+       const TextField* text = dynamic_cast<const TextField*>(
+               tester.findDisplayItemByName(*root, "textfield"));
        check(text);
 
-       const DisplayObject* text2 = tester.findDisplayItemByName(*root, 
"textfield2");
+       const TextField* text2 = dynamic_cast<const TextField*>(
+               tester.findDisplayItemByName(*root, "textfield2"));
        check(text2);
 
-       const DisplayObject* text3 = tester.findDisplayItemByName(*root, 
"textfield3");
+       const TextField* text3 = dynamic_cast<const TextField*>(
+               tester.findDisplayItemByName(*root, "textfield3"));
        check(text3);
 
        check_equals(string(text->get_text_value()), idleString);

=== modified file 'testsuite/misc-ming.all/SpriteButtonEventsTest-Runner.cpp'
--- a/testsuite/misc-ming.all/SpriteButtonEventsTest-Runner.cpp 2009-04-09 
11:41:59 +0000
+++ b/testsuite/misc-ming.all/SpriteButtonEventsTest-Runner.cpp 2009-08-21 
12:54:14 +0000
@@ -24,6 +24,7 @@
 #include "MovieClip.h"
 #include "DisplayObject.h"
 #include "DisplayList.h"
+#include "TextField.h"
 #include "log.h"
 
 #include "check.h"
@@ -34,7 +35,7 @@
 using namespace std;
 
 void
-test_mouse_activity(MovieTester& tester, const DisplayObject* text, const 
DisplayObject* text2, bool covered, bool enabled)
+test_mouse_activity(MovieTester& tester, const TextField* text, const 
TextField* text2, bool covered, bool enabled)
 {
        rgba red(255,0,0,255);
        rgba covered_red(127,126,0,255); // red, covered by 50% black
@@ -210,13 +211,16 @@
        check_equals(root->get_frame_count(), 5);
        check_equals(root->get_current_frame(), 0);
 
-       const DisplayObject* text = tester.findDisplayItemByName(*root, 
"textfield");
+       const TextField* text = dynamic_cast<const TextField*>(
+               tester.findDisplayItemByName(*root, "textfield"));
        check(text);
 
-       const DisplayObject* text2 = tester.findDisplayItemByName(*root, 
"textfield2");
+       const TextField* text2 = dynamic_cast<const TextField*>(
+               tester.findDisplayItemByName(*root, "textfield2"));
        check(text2);
 
-       const DisplayObject* text3 = tester.findDisplayItemByName(*root, 
"textfield3");
+       const TextField* text3 = dynamic_cast<const TextField*>(
+               tester.findDisplayItemByName(*root, "textfield3"));
        check(text3);
 
        tester.advance();
@@ -259,7 +263,8 @@
                check_equals(root->get_current_frame(), fno);
 
                info (("testing mouse activity in frame %d", 
root->get_current_frame()));
-               test_mouse_activity(tester, text, text2, square_front!=NULL, 
fno != root->get_frame_count()-1);
+               test_mouse_activity(tester, text, text2,
+                               square_front!=NULL, fno != 
root->get_frame_count()-1);
 
                // TODO: test key presses !
                //       They seem NOT to trigger immediate redraw

=== modified file 'testsuite/movies.all/gravity_embedded-TestRunner.cpp'
--- a/testsuite/movies.all/gravity_embedded-TestRunner.cpp      2009-04-03 
10:27:08 +0000
+++ b/testsuite/movies.all/gravity_embedded-TestRunner.cpp      2009-08-21 
12:29:40 +0000
@@ -26,6 +26,7 @@
 #include "DisplayList.h"
 #include "log.h"
 #include "VM.h"
+#include "TextField.h"
 
 #include "check.h"
 #include <string>
@@ -76,7 +77,10 @@
        check_equals(loaded->get_height(), 2056);
        check_equals(loaded->get_width(), 2056);
 
-       const DisplayObject* text = tester.findDisplayItemByDepth(*root, 
7+DisplayObject::staticDepthOffset);
+       const TextField* text = 
+            dynamic_cast<const TextField*>(
+                tester.findDisplayItemByDepth(
+                    *root, 7 +DisplayObject::staticDepthOffset));
        check(text);
        
        check_equals(string(text->get_text_value()), "50");

=== modified file 'testsuite/samples/clip_as_button2-TestRunner.cpp'
--- a/testsuite/samples/clip_as_button2-TestRunner.cpp  2009-04-03 10:23:04 
+0000
+++ b/testsuite/samples/clip_as_button2-TestRunner.cpp  2009-08-21 12:40:49 
+0000
@@ -24,6 +24,7 @@
 #include "GnashException.h"
 #include "MovieClip.h"
 #include "DisplayObject.h"
+#include "TextField.h"
 #include "DisplayList.h"
 #include "log.h"
 
@@ -78,7 +79,9 @@
        rgba cyan(0, 255, 204, 255);
        rgba green(0,255,102,255);
 
-       const DisplayObject* text = tester.findDisplayItemByDepth(*root, 
3+DisplayObject::staticDepthOffset);
+       const TextField* text =
+               dynamic_cast<const TextField*>(
+                       tester.findDisplayItemByDepth(*root, 
3+DisplayObject::staticDepthOffset));
        check(text);
        check_equals(string(text->get_text_value()), msg_empty);
        check(!tester.isMouseOverMouseEntity());


reply via email to

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