gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10396: Register ASnatives, get some


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10396: Register ASnatives, get some swfdec testsuite passes.
Date: Mon, 08 Dec 2008 09:42:36 +0100
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10396
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2008-12-08 09:42:36 +0100
message:
  Register ASnatives, get some swfdec testsuite passes.
modified:
  libcore/asobj/ClassHierarchy.cpp
  libcore/asobj/Global.cpp
  libcore/asobj/LoadVars_as.cpp
  libcore/asobj/LoadableObject.cpp
  libcore/asobj/LoadableObject.h
  libcore/asobj/XMLNode_as.cpp
  libcore/asobj/XMLNode_as.h
  libcore/asobj/XML_as.cpp
  libcore/asobj/XML_as.h
  testsuite/swfdec/PASSING
    ------------------------------------------------------------
    revno: 10395.1.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2008-12-08 08:23:38 +0100
    message:
      Register XML methods as ASnative, including XML.escape(), which is only
      available through the ASnative interface.
    modified:
      libcore/asobj/Global.cpp
      libcore/asobj/XML_as.cpp
      libcore/asobj/XML_as.h
    ------------------------------------------------------------
    revno: 10395.1.2
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2008-12-08 08:35:55 +0100
    message:
      Passes for swfdec xml-escape 6-8.
    modified:
      testsuite/swfdec/PASSING
    ------------------------------------------------------------
    revno: 10395.1.3
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2008-12-08 08:59:26 +0100
    message:
      Register Loadableobject natives separately, use for LoadVars and XML.
    modified:
      libcore/asobj/ClassHierarchy.cpp
      libcore/asobj/Global.cpp
      libcore/asobj/LoadVars_as.cpp
      libcore/asobj/LoadableObject.cpp
      libcore/asobj/LoadableObject.h
      libcore/asobj/XML_as.cpp
      libcore/asobj/XML_as.h
    ------------------------------------------------------------
    revno: 10395.1.4
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2008-12-08 09:30:13 +0100
    message:
      Register XMLNode natives.
    modified:
      libcore/asobj/ClassHierarchy.cpp
      libcore/asobj/Global.cpp
      libcore/asobj/XMLNode_as.cpp
      libcore/asobj/XMLNode_as.h
      libcore/asobj/XML_as.cpp
=== modified file 'libcore/asobj/ClassHierarchy.cpp'
--- a/libcore/asobj/ClassHierarchy.cpp  2008-12-05 07:35:49 +0000
+++ b/libcore/asobj/ClassHierarchy.cpp  2008-12-08 08:30:13 +0000
@@ -287,8 +287,9 @@
        { sound_class_init, NSV::CLASS_SOUND, NSV::CLASS_OBJECT, 
NSV::NS_FLASH_MEDIA, 5 },
        { xmlsocket_class_init, NSV::CLASS_X_M_L_SOCKET, NSV::CLASS_OBJECT, 
NSV::NS_FLASH_NET, 5 },
        { date_class_init, NSV::CLASS_DATE, NSV::CLASS_OBJECT, NS_GLOBAL, 5 },
-       { xml_class_init, NSV::CLASS_X_M_L, NSV::CLASS_OBJECT, NS_GLOBAL, 5 },
-       { xmlnode_class_init, NSV::CLASS_X_M_L_NODE, NSV::CLASS_OBJECT, 
NSV::NS_FLASH_XML, 5 },
+       { XML_as::init, NSV::CLASS_X_M_L, NSV::CLASS_OBJECT, NS_GLOBAL, 5 },
+       { XMLNode_as::init, NSV::CLASS_X_M_L_NODE, NSV::CLASS_OBJECT,
+        NSV::NS_FLASH_XML, 5 },
        { mouse_class_init, NSV::CLASS_MOUSE, NSV::CLASS_OBJECT, 
NSV::NS_FLASH_UI, 5 },
        { number_class_init, NSV::CLASS_NUMBER, NSV::CLASS_OBJECT, NS_GLOBAL, 5 
},
        { textformat_class_init, NSV::CLASS_TEXT_FORMAT, NSV::CLASS_OBJECT, 
NS_GLOBAL, 5 },

=== modified file 'libcore/asobj/Global.cpp'
--- a/libcore/asobj/Global.cpp  2008-12-05 07:35:49 +0000
+++ b/libcore/asobj/Global.cpp  2008-12-08 08:30:13 +0000
@@ -185,8 +185,15 @@
     object_class_init(*this); // flagged for sole SWF5+ visibility
     string_class_init(*this); // should be SWF5+ only
     array_class_init(*this); // should be only for SWF5+
-    //localconnection_class_init(*this); // only for SWF6+
-    registerDateNative(*this); // natives are always present
+
+    registerDateNative(*this);
+
+    XMLNode_as::registerNative(*this);
+
+    // LoadableObject has natives shared between LoadVars and XML, so 
+    // should be registered first.
+    LoadableObject::registerNative(*this);
+    XML_as::registerNative(*this);
 
     switch (version)
     {

=== modified file 'libcore/asobj/LoadVars_as.cpp'
--- a/libcore/asobj/LoadVars_as.cpp     2008-11-26 20:19:17 +0000
+++ b/libcore/asobj/LoadVars_as.cpp     2008-12-08 07:59:26 +0000
@@ -137,6 +137,8 @@
 void
 LoadVars_as::attachLoadVarsInterface(as_object& o)
 {
+    VM& vm = o.getVM();
+
        o.init_member("addRequestHeader", new builtin_function(
                    LoadableObject::loadableobject_addRequestHeader));
        o.init_member("decode", new 
builtin_function(LoadVars_as::decode_method));
@@ -144,12 +146,9 @@
                    LoadVars_as::getBytesLoaded_method));
        o.init_member("getBytesTotal", new builtin_function(
                    LoadVars_as::getBytesTotal_method));
-       o.init_member("load", new builtin_function(
-                   LoadableObject::loadableobject_load));
-       o.init_member("send", new builtin_function(
-                LoadableObject::loadableobject_send));
-       o.init_member("sendAndLoad", new builtin_function(
-                   LoadableObject::loadableobject_sendAndLoad));
+       o.init_member("load", vm.getNative(301, 0));
+       o.init_member("send", vm.getNative(301, 1));
+       o.init_member("sendAndLoad", vm.getNative(301, 2));
        o.init_member("toString", new builtin_function(loadvars_tostring));
        o.init_member("onData", new 
builtin_function(LoadVars_as::onData_method));
        o.init_member("onLoad", new 
builtin_function(LoadVars_as::onLoad_method));

=== modified file 'libcore/asobj/LoadableObject.cpp'
--- a/libcore/asobj/LoadableObject.cpp  2008-10-29 08:21:28 +0000
+++ b/libcore/asobj/LoadableObject.cpp  2008-12-08 07:59:26 +0000
@@ -35,6 +35,11 @@
 
 namespace gnash {
 
+namespace {
+    as_value loadableobject_send(const fn_call& fn);
+    as_value loadableobject_load(const fn_call& fn);
+    as_value loadableobject_sendAndLoad(const fn_call& fn);
+}
 
 LoadableObject::LoadableObject()
     :
@@ -310,6 +315,16 @@
     }
 }
 
+void
+LoadableObject::registerNative(as_object& o)
+{
+    VM& vm = o.getVM();
+
+    vm.registerNative(loadableobject_load, 301, 0);
+    vm.registerNative(loadableobject_send, 301, 1);
+    vm.registerNative(loadableobject_sendAndLoad, 301, 2);
+}
+
 
 /// Can take either a two strings as arguments or an array of strings,
 /// alternately header and value.
@@ -317,7 +332,8 @@
 LoadableObject::loadableobject_addRequestHeader(const fn_call& fn)
 {
     
-    boost::intrusive_ptr<LoadableObject> ptr = 
ensureType<LoadableObject>(fn.this_ptr);   
+    boost::intrusive_ptr<LoadableObject> ptr = 
+        ensureType<LoadableObject>(fn.this_ptr);   
 
     as_value customHeaders;
     as_object* array;
@@ -420,13 +436,17 @@
 }
 
 
+/// These methods are accessed through the ASnative interface, so they
+/// do not need to be public methods of the LoadableObject class.
+namespace {
+
 /// Returns true if the arguments are valid, otherwise false. The
 /// success of the connection is irrelevant.
 /// The second argument must be a loadable object (XML or LoadVars).
 /// An optional third argument specifies the method ("GET", or by default
 /// "POST"). The values are partly URL encoded if using GET.
 as_value
-LoadableObject::loadableobject_sendAndLoad(const fn_call& fn)
+loadableobject_sendAndLoad(const fn_call& fn)
 {
        boost::intrusive_ptr<LoadableObject> ptr =
                        ensureType<LoadableObject>(fn.this_ptr);
@@ -470,9 +490,10 @@
 
 
 as_value
-LoadableObject::loadableobject_load(const fn_call& fn)
+loadableobject_load(const fn_call& fn)
 {
-       boost::intrusive_ptr<LoadableObject> obj = 
ensureType<LoadableObject>(fn.this_ptr);
+       boost::intrusive_ptr<LoadableObject> obj = 
+        ensureType<LoadableObject>(fn.this_ptr);
 
        if ( fn.nargs < 1 )
        {
@@ -498,7 +519,7 @@
 
     
 as_value
-LoadableObject::loadableobject_send(const fn_call& fn)
+loadableobject_send(const fn_call& fn)
 {
     boost::intrusive_ptr<LoadableObject> ptr =
         ensureType<LoadableObject>(fn.this_ptr);
@@ -537,5 +558,5 @@
     return as_value(true);
 }
 
-
-}
+} // anonymous namespace
+} // namespace gnash

=== modified file 'libcore/asobj/LoadableObject.h'
--- a/libcore/asobj/LoadableObject.h    2008-10-23 18:27:11 +0000
+++ b/libcore/asobj/LoadableObject.h    2008-12-08 07:59:26 +0000
@@ -44,6 +44,9 @@
 
     virtual ~LoadableObject();
 
+    /// Register methods as native for use by XML_as and LoadVars_as
+    static void registerNative(as_object& global);
+
     /// Carry out the AS send() operation
     //
     /// @param urlstr   The URI to send the data to
@@ -87,9 +90,6 @@
     /// Shared AS methods for XML and LoadVars, which can be used
     /// interchangeably with each object in ActionScript.
     static as_value loadableobject_addRequestHeader(const fn_call& fn);
-    static as_value loadableobject_sendAndLoad(const fn_call& fn);
-    static as_value loadableobject_load(const fn_call& fn);
-    static as_value loadableobject_send(const fn_call& fn);
 
 protected:
 

=== modified file 'libcore/asobj/XMLNode_as.cpp'
--- a/libcore/asobj/XMLNode_as.cpp      2008-12-05 08:03:35 +0000
+++ b/libcore/asobj/XMLNode_as.cpp      2008-12-08 08:30:13 +0000
@@ -49,20 +49,20 @@
             const std::string& ns);
 
     as_value xmlnode_new(const fn_call& fn);
-    as_value xmlnode_nodename(const fn_call& fn);
-    as_value xmlnode_node_value(const fn_call& fn);
-    as_value xmlnode_nodetype(const fn_call& fn);
+    as_value xmlnode_nodeName(const fn_call& fn);
+    as_value xmlnode_nodeValue(const fn_call& fn);
+    as_value xmlnode_nodeType(const fn_call& fn);
     as_value xmlnode_attributes(const fn_call& fn);
-    as_value xmlnode_appendchild(const fn_call& fn);
-    as_value xmlnode_clonenode(const fn_call& fn);
-    as_value xmlnode_haschildnodes(const fn_call& fn);
-    as_value xmlnode_insertbefore(const fn_call& fn);
-    as_value xmlnode_removenode(const fn_call& fn);
-    as_value xmlnode_tostring(const fn_call& fn);
-    as_value xmlnode_firstchild(const fn_call& fn);
-    as_value xmlnode_lastchild(const fn_call& fn);
-    as_value xmlnode_nextsibling(const fn_call& fn);
-    as_value xmlnode_previoussibling(const fn_call& fn);
+    as_value xmlnode_appendChild(const fn_call& fn);
+    as_value xmlnode_cloneNode(const fn_call& fn);
+    as_value xmlnode_hasChildNodes(const fn_call& fn);
+    as_value xmlnode_insertBefore(const fn_call& fn);
+    as_value xmlnode_removeNode(const fn_call& fn);
+    as_value xmlnode_toString(const fn_call& fn);
+    as_value xmlnode_firstChild(const fn_call& fn);
+    as_value xmlnode_lastChild(const fn_call& fn);
+    as_value xmlnode_nextSibling(const fn_call& fn);
+    as_value xmlnode_previousSibling(const fn_call& fn);
     as_value xmlnode_childNodes(const fn_call& fn);
     as_value xmlnode_parentNode(const fn_call& fn);
     as_value xmlnode_getPrefixForNamespace(const fn_call& fn);
@@ -368,20 +368,20 @@
 XMLNode_as::stringify(const XMLNode_as& xml, std::ostream& xmlout, bool 
encode) 
 {
 
-    const std::string& node_value = xml.nodeValue();
-    const std::string& nodename = xml.nodeName();
+    const std::string& nodeValue = xml.nodeValue();
+    const std::string& nodeName = xml.nodeName();
     NodeType type = xml.nodeType();
 
 #ifdef GNASH_DEBUG
     log_debug(_("Stringifying node %p with name %s, as_value %s, %u "
-                "attributes and %u children"), (void*)&xml, nodename,
-            node_value, xml._attributes.size(), xml._children.size());
+                "attributes and %u children"), (void*)&xml, nodeName,
+            nodeValue, xml._attributes.size(), xml._children.size());
 #endif
 
     // Create the beginning of the tag
-    if (!nodename.empty())
+    if (!nodeName.empty())
     {
-        xmlout << "<" << nodename;
+        xmlout << "<" << nodeName;
     
         // Process the attributes, if any
         PropertyList::SortedPropertyList attrs;
@@ -396,7 +396,7 @@
         }
 
        // If the node has no content, just close the tag now
-       if ( node_value.empty() && xml._children.empty() )
+       if ( nodeValue.empty() && xml._children.empty() )
        {
                xmlout << " />";
                return;
@@ -413,7 +413,7 @@
     if ( type == Text )
     {
         // Insert entities.
-        std::string escaped(node_value);
+        std::string escaped(nodeValue);
         XML_as::escape(escaped);
         if (encode) URL::encode(escaped);
 
@@ -427,9 +427,9 @@
         (*itx)->toString(xmlout, encode);
     }
 
-    if (!nodename.empty())
+    if (!nodeName.empty())
     {
-           xmlout << "</" << nodename << ">";
+           xmlout << "</" << nodeName << ">";
     }
 }
 
@@ -455,9 +455,20 @@
 }
 #endif // GNASH_USE_GC
 
-// External, used by getXMLInterface() !
+void
+XMLNode_as::registerNative(as_object& global)
+{
+    VM& vm = global.getVM();
+    vm.registerNative(xmlnode_cloneNode, 253, 1);
+    vm.registerNative(xmlnode_removeNode, 253, 2);
+    vm.registerNative(xmlnode_insertBefore, 253, 3);
+    vm.registerNative(xmlnode_appendChild, 253, 4);
+    vm.registerNative(xmlnode_hasChildNodes, 253, 5);
+    vm.registerNative(xmlnode_toString, 253, 6);
+}
+
 as_object*
-getXMLNodeInterface()
+XMLNode_as::getXMLNodeInterface()
 {
     static boost::intrusive_ptr<as_object> o;
     if ( o == NULL ) {
@@ -468,7 +479,8 @@
 }
 
 
-void xmlnode_class_init(as_object& global)
+void
+XMLNode_as::init(as_object& global)
 {
     // This is the global XMLNode_as "class"
     static boost::intrusive_ptr<builtin_function> cl;
@@ -492,20 +504,17 @@
 {
     // These need to be full-featured AS functions (builtin_function)
     
+    VM& vm = o.getVM();
+
     const int noFlags = 0;
     
     // No prop flags:
-    o.init_member("appendChild", new builtin_function(
-                xmlnode_appendchild), noFlags);
-    o.init_member("cloneNode", new builtin_function(
-                xmlnode_clonenode), noFlags);
-    o.init_member("hasChildNodes", new builtin_function(
-                xmlnode_haschildnodes), noFlags);
-    o.init_member("insertBefore", new builtin_function(
-                xmlnode_insertbefore), noFlags);
-    o.init_member("removeNode", new builtin_function(
-                xmlnode_removenode), noFlags);
-    o.init_member("toString", new builtin_function(xmlnode_tostring), noFlags);
+    o.init_member("cloneNode", vm.getNative(253, 1), noFlags);
+    o.init_member("removeNode", vm.getNative(253, 2), noFlags);
+    o.init_member("insertBefore", vm.getNative(253, 3), noFlags);
+    o.init_member("appendChild", vm.getNative(253, 4), noFlags);
+    o.init_member("hasChildNodes", vm.getNative(253, 5), noFlags);
+    o.init_member("toString", vm.getNative(253, 6), noFlags);
     o.init_member("getPrefixForNamespace", new builtin_function(
                 xmlnode_getPrefixForNamespace), noFlags);
     o.init_member("getNamespaceForPrefix", new builtin_function(
@@ -515,22 +524,22 @@
     const int protectedFlags = as_prop_flags::isProtected;
 
     // Just the protected flag:
-    o.init_property("nodeValue", &xmlnode_node_value, 
-            &xmlnode_node_value, protectedFlags);
-    o.init_property("nodeName", &xmlnode_nodename, 
-            &xmlnode_nodename, protectedFlags);
+    o.init_property("nodeValue", &xmlnode_nodeValue, 
+            &xmlnode_nodeValue, protectedFlags);
+    o.init_property("nodeName", &xmlnode_nodeName, 
+            &xmlnode_nodeName, protectedFlags);
 
-    o.init_readonly_property("firstChild", &xmlnode_firstchild, 
protectedFlags);
-    o.init_readonly_property("lastChild", &xmlnode_lastchild, protectedFlags);
+    o.init_readonly_property("firstChild", &xmlnode_firstChild, 
protectedFlags);
+    o.init_readonly_property("lastChild", &xmlnode_lastChild, protectedFlags);
     o.init_readonly_property("localName", &xmlnode_localName, protectedFlags);
     o.init_readonly_property("namespaceURI", 
             &xmlnode_namespaceURI, protectedFlags);
     o.init_readonly_property("nextSibling", 
-            &xmlnode_nextsibling, protectedFlags);
+            &xmlnode_nextSibling, protectedFlags);
     o.init_readonly_property("prefix", &xmlnode_prefix, protectedFlags);
     o.init_readonly_property("previousSibling", 
-            &xmlnode_previoussibling, protectedFlags);
-    o.init_readonly_property("nodeType", &xmlnode_nodetype, protectedFlags);
+            &xmlnode_previousSibling, protectedFlags);
+    o.init_readonly_property("nodeType", &xmlnode_nodeType, protectedFlags);
     o.init_readonly_property("attributes", &xmlnode_attributes, 
protectedFlags);
     o.init_readonly_property("childNodes", &xmlnode_childNodes, 
protectedFlags);
     o.init_readonly_property("parentNode", &xmlnode_parentNode, 
protectedFlags);
@@ -557,7 +566,7 @@
 
 
 as_value
-xmlnode_appendchild(const fn_call& fn)
+xmlnode_appendChild(const fn_call& fn)
 {
 //    GNASH_REPORT_FUNCTION;
 
@@ -589,7 +598,7 @@
 
 
 as_value
-xmlnode_clonenode(const fn_call& fn)
+xmlnode_cloneNode(const fn_call& fn)
 {
     boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
 
@@ -602,7 +611,7 @@
 
 
 as_value
-xmlnode_insertbefore(const fn_call& fn)
+xmlnode_insertBefore(const fn_call& fn)
 {
        boost::intrusive_ptr<XMLNode_as> ptr = 
ensureType<XMLNode_as>(fn.this_ptr);
 
@@ -774,7 +783,7 @@
 
 
 as_value
-xmlnode_removenode(const fn_call& fn)
+xmlnode_removeNode(const fn_call& fn)
 {
     boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     
@@ -785,7 +794,7 @@
 
 // TODO: shouldn't overriding get_text_value() be fine ?
 as_value
-xmlnode_tostring(const fn_call& fn)
+xmlnode_toString(const fn_call& fn)
 {
     //GNASH_REPORT_FUNCTION;
     
@@ -799,7 +808,7 @@
 
 
 as_value
-xmlnode_haschildnodes(const fn_call& fn)
+xmlnode_hasChildNodes(const fn_call& fn)
 {
     boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     return as_value(ptr->hasChildNodes());
@@ -807,7 +816,7 @@
 
 
 as_value
-xmlnode_node_value(const fn_call& fn)
+xmlnode_nodeValue(const fn_call& fn)
 {
     boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     as_value rv;
@@ -827,7 +836,7 @@
 
 
 as_value
-xmlnode_nodename(const fn_call& fn)
+xmlnode_nodeName(const fn_call& fn)
 {
     boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     as_value rv;
@@ -846,7 +855,7 @@
 
 
 as_value
-xmlnode_nodetype(const fn_call& fn)
+xmlnode_nodeType(const fn_call& fn)
 {
     boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     return as_value(ptr->nodeType());
@@ -873,7 +882,7 @@
 /// and removeNode() methods to manipulate child nodes. 
 ///
 as_value
-xmlnode_firstchild(const fn_call& fn)
+xmlnode_firstChild(const fn_call& fn)
 {
     boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     as_value rv;
@@ -895,7 +904,7 @@
 /// insertBefore(), and removeNode() methods to manipulate child
 /// nodes.
 as_value
-xmlnode_lastchild(const fn_call& fn)
+xmlnode_lastChild(const fn_call& fn)
 {
     boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     as_value rv;
@@ -909,7 +918,7 @@
 
 
 as_value
-xmlnode_nextsibling(const fn_call& fn)
+xmlnode_nextSibling(const fn_call& fn)
 {
     as_value rv;
     rv.set_null();
@@ -924,7 +933,7 @@
 
 
 as_value
-xmlnode_previoussibling(const fn_call& fn)
+xmlnode_previousSibling(const fn_call& fn)
 {
     as_value rv;
     rv.set_null();

=== modified file 'libcore/asobj/XMLNode_as.h'
--- a/libcore/asobj/XMLNode_as.h        2008-12-04 08:23:23 +0000
+++ b/libcore/asobj/XMLNode_as.h        2008-12-08 08:30:13 +0000
@@ -86,6 +86,15 @@
     XMLNode_as(const XMLNode_as &node, bool deep);
     virtual ~XMLNode_as();
 
+    // Initialize the global XMLNode class
+    static void init(as_object& global);
+
+    // Used by XML_as
+    static as_object* getXMLNodeInterface();
+
+    /// Register ASnative methods
+    static void registerNative(as_object& global);
+
     size_t length() const { return _children.size(); }
 
     const std::string& nodeName() const { return _name; }
@@ -261,12 +270,6 @@
 
 };
 
-// Initialize the global XMLNode class
-void xmlnode_class_init(as_object& global);
-
-// Used by XML_as
-as_object* getXMLNodeInterface();
-
 } // gnash namespace
 
 

=== modified file 'libcore/asobj/XML_as.cpp'
--- a/libcore/asobj/XML_as.cpp  2008-12-03 15:25:56 +0000
+++ b/libcore/asobj/XML_as.cpp  2008-12-08 08:30:13 +0000
@@ -61,14 +61,15 @@
     void attachXMLProperties(as_object& o);
 
     as_value xml_new(const fn_call& fn);
-    as_value xml_createelement(const fn_call& fn);
-    as_value xml_createtextnode(const fn_call& fn);
-    as_value xml_getbytesloaded(const fn_call& fn);
-    as_value xml_getbytestotal(const fn_call& fn);
-    as_value xml_parsexml(const fn_call& fn);
+    as_value xml_createElement(const fn_call& fn);
+    as_value xml_createTextNode(const fn_call& fn);
+    as_value xml_getBytesLoaded(const fn_call& fn);
+    as_value xml_getBytesTotal(const fn_call& fn);
+    as_value xml_parseXML(const fn_call& fn);
     as_value xml_ondata(const fn_call& fn);
     as_value xml_xmlDecl(const fn_call& fn);
     as_value xml_docTypeDecl(const fn_call& fn);
+    as_value xml_escape(const fn_call& fn);
 
     bool textAfterWhitespace(const std::string& xml,
             std::string::const_iterator& it);
@@ -598,7 +599,7 @@
 
 // extern (used by Global.cpp)
 void
-xml_class_init(as_object& global)
+XML_as::init(as_object& global)
 {
 
     static boost::intrusive_ptr<builtin_function> cl;
@@ -612,6 +613,16 @@
 
 }
 
+void
+XML_as::registerNative(as_object& global)
+{
+    VM& vm = global.getVM();
+    vm.registerNative(xml_escape, 100, 5);
+    vm.registerNative(xml_createElement, 253, 8);
+    vm.registerNative(xml_createTextNode, 253, 9);
+    vm.registerNative(xml_parseXML, 253, 10);
+}
+
 ///
 /// XML object AS interface.
 ///
@@ -626,29 +637,28 @@
     //o.init_member("status", as_value(XML::sOK));
 }
 
+
 void
 attachXMLInterface(as_object& o)
 {
+
+    VM& vm = o.getVM();
+
     const int flags = 0;
 
     // No flags:
     o.init_member("addRequestHeader", new builtin_function(
                 LoadableObject::loadableobject_addRequestHeader), flags);
-    o.init_member("createElement", 
-            new builtin_function(xml_createelement), flags);
-    o.init_member("createTextNode", 
-            new builtin_function(xml_createtextnode), flags);
+    o.init_member("createElement", vm.getNative(253, 8), flags);
+    o.init_member("createTextNode", vm.getNative(253, 9), flags);
     o.init_member("getBytesLoaded", 
-            new builtin_function(xml_getbytesloaded), flags);
+            new builtin_function(xml_getBytesLoaded), flags);
     o.init_member("getBytesTotal", 
-            new builtin_function(xml_getbytestotal), flags);
-    o.init_member("load", new builtin_function(
-                LoadableObject::loadableobject_load), flags);
-    o.init_member("parseXML", new builtin_function(xml_parsexml), flags);
-    o.init_member("send", new builtin_function(
-                LoadableObject::loadableobject_send), flags);
-    o.init_member("sendAndLoad", new builtin_function(
-                LoadableObject::loadableobject_sendAndLoad), flags);
+            new builtin_function(xml_getBytesTotal), flags);
+    o.init_member("load", vm.getNative(301, 0), flags);
+    o.init_member("parseXML", vm.getNative(253, 10), flags); 
+    o.init_member("send", vm.getNative(301, 1), flags);
+    o.init_member("sendAndLoad", vm.getNative(301, 2), flags);
     o.init_member("onData", new builtin_function(xml_ondata), flags);
 
     o.init_property("xmlDecl", &xml_xmlDecl, &xml_xmlDecl, flags);
@@ -661,7 +671,7 @@
     static boost::intrusive_ptr<as_object> o;
     if ( o == NULL )
     {
-        o = new as_object(getXMLNodeInterface());
+        o = new as_object(XMLNode_as::getXMLNodeInterface());
         attachXMLInterface(*o);
     }
     return o.get();
@@ -707,6 +717,17 @@
 }
 
 
+/// Only available as ASnative.
+as_value
+xml_escape(const fn_call& fn)
+{
+    if (!fn.nargs) return as_value();
+
+    std::string escaped = fn.arg(0).to_string();
+    XML_as::escape(escaped);
+    return as_value(escaped);
+}
+
 /// \brief create a new XML element
 ///
 /// Method; creates a new XML element with the name specified in the
@@ -716,7 +737,7 @@
 /// the XML.createTextNode() method are the constructor methods for
 /// creating nodes for an XML object. 
 as_value
-xml_createelement(const fn_call& fn)
+xml_createElement(const fn_call& fn)
 {
     
     if (fn.nargs > 0)
@@ -745,7 +766,7 @@
 /// XML.createElement() method are the constructor methods for
 /// creating nodes for an XML object.
 as_value
-xml_createtextnode(const fn_call& fn)
+xml_createTextNode(const fn_call& fn)
 {
 
     if (fn.nargs > 0) {
@@ -763,7 +784,7 @@
 
 
 as_value
-xml_getbytesloaded(const fn_call& fn)
+xml_getBytesLoaded(const fn_call& fn)
 {
     boost::intrusive_ptr<XML_as> ptr = ensureType<XML_as>(fn.this_ptr);
     long int ret = ptr->getBytesLoaded();
@@ -773,7 +794,7 @@
 
 
 as_value
-xml_getbytestotal(const fn_call& fn)
+xml_getBytesTotal(const fn_call& fn)
 {
     boost::intrusive_ptr<XML_as> ptr = ensureType<XML_as>(fn.this_ptr);
     long int ret = ptr->getBytesTotal();
@@ -783,7 +804,7 @@
 
 
 as_value
-xml_parsexml(const fn_call& fn)
+xml_parseXML(const fn_call& fn)
 {
 
     boost::intrusive_ptr<XML_as> ptr = ensureType<XML_as>(fn.this_ptr);

=== modified file 'libcore/asobj/XML_as.h'
--- a/libcore/asobj/XML_as.h    2008-11-21 09:51:27 +0000
+++ b/libcore/asobj/XML_as.h    2008-12-08 07:59:26 +0000
@@ -59,6 +59,9 @@
     XML_as(const std::string& xml);
 
     ~XML_as() {};
+    
+    static void init(as_object& global);
+    static void registerNative(as_object& global);
 
     /// Convert the XML object to a string
     //
@@ -177,10 +180,7 @@
 
 };
 
-
-DSOEXPORT void xml_class_init(as_object& global);
-
-}      // end namespace gnash
+}      // namespace gnash
 
 #endif
 

=== modified file 'testsuite/swfdec/PASSING'
--- a/testsuite/swfdec/PASSING  2008-12-05 12:52:48 +0000
+++ b/testsuite/swfdec/PASSING  2008-12-08 07:35:55 +0000
@@ -1195,6 +1195,9 @@
 xml-cdata-6.swf:d7559375e07591033d7739671a8c4d42
 xml-cdata-7.swf:5e51dafbe7f6af8206041ecabf0016f8
 xml-cdata-8.swf:d5537f4fb83eaf49d615eecb89b2ae95
+xml-escape-6.swf:302349505514bd60239c7019355f6ab8
+xml-escape-7.swf:31cca7515723685cf0384bf7e059e8ac
+xml-escape-8.swf:cbd1f724a3dc3e73697535468443171d
 xml-init-5.swf:2ba1da174f2b1958749fede5667a60c4
 xml-init-5.swf:bb54cac64e38396084a147266f7d9711
 xml-node-init-5.swf:12fd3762a2bfa787b01fc0b8abfaa492


reply via email to

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