gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r9672: merge patch from rtmp branch.


From: rob
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r9672: merge patch from rtmp branch.
Date: Wed, 03 Sep 2008 17:52:46 -0600
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9672
committer: address@hidden
branch nick: trunk
timestamp: Wed 2008-09-03 17:52:46 -0600
message:
  merge patch from rtmp branch.
modified:
  libcore/as_value.cpp
  libcore/as_value.h
  testsuite/libcore.all/AsValueTest.cpp
    ------------------------------------------------------------
    revno: 9483.1.145
    committer: address@hidden
    branch nick: rtmp
    timestamp: Wed 2008-09-03 17:46:02 -0600
    message:
      use pointers to AMF elements instead of passing copies.
    modified:
      libcore/as_value.cpp
      libcore/as_value.h
      testsuite/libcore.all/AsValueTest.cpp
=== modified file 'libcore/as_value.cpp'
--- a/libcore/as_value.cpp      2008-09-03 22:27:27 +0000
+++ b/libcore/as_value.cpp      2008-09-03 23:46:02 +0000
@@ -95,6 +95,8 @@
 
 namespace gnash {
 
+// This class is used to iterate through all the properties of an AS object,
+// so we can change them to children of an AMF0 element.
 class PropsSerializer {
     Element& _obj;
     string_table& _st;
@@ -143,7 +145,6 @@
             }
         }
 };
-
     
 //
 // as_value -- ActionScript value type
@@ -676,7 +677,11 @@
 amf::Element *
 as_value::to_element() const
 {
+    VM& vm = VM::get();
+    int swfVersion = vm.getSWFVersion();
     Element *el = new Element;
+    boost::intrusive_ptr<as_object> ptr = to_object();
+
     switch (m_type) {
       case  STRING:
          el->makeString(getStr());
@@ -688,8 +693,12 @@
          el->makeBoolean(getBool());
          break;
       case OBJECT:
+      {
          el->makeObject();
+         PropsSerializer props(*el, vm);
+         ptr->visitPropertyValues(props);
          break;
+      }
       case AS_FUNCTION:
          break;
       case MOVIECLIP:
@@ -1737,13 +1746,13 @@
 }
 
 /// Instantiate this value from an AMF element 
-as_value::as_value(Element &el)
+as_value::as_value(Element *el)
 {
     VM& vm = VM::get();
     int swfVersion = vm.getSWFVersion();
     string_table& st = vm.getStringTable();
     
-    switch (el.getType()) {
+    switch (el->getType()) {
       case Element::NULL_AMF0:
       {
          m_type = NULLTYPE;
@@ -1757,41 +1766,40 @@
       case Element::MOVIECLIP_AMF0:
       {
          m_type = MOVIECLIP;
-         _value = el.getData();
+         _value = el->getData();
          break;
       }
       case Element::NUMBER_AMF0:
       {
          m_type = NUMBER;
-         _value = el.to_number();
+         _value = el->to_number();
          break;
       }
       case Element::BOOLEAN_AMF0:
       {
          m_type = BOOLEAN;
-         bool flag = el.to_bool();
+         bool flag = el->to_bool();
          _value = flag ;
          break;
       }
       case Element::STRING_AMF0:
       {
          m_type = STRING;
-         std::string str = el.to_string();
+         std::string str = el->to_string();
          _value = str;
          break;
       }
       case Element::OBJECT_AMF0:
       case Element::REFERENCE_AMF0:
-         log_unimpl("References don't work for AMF0 yet");
       case Element::ECMA_ARRAY_AMF0:
       case Element::OBJECT_END_AMF0:
       case Element::STRICT_ARRAY_AMF0:
       {
          m_type = OBJECT;
          boost::intrusive_ptr<as_object> obj(new as_object()); 
-         if (el.propertySize()) {
-             for (size_t i=0; i < el.propertySize(); i++) {
-                 Element *prop = el[i];
+         if (el->propertySize()) {
+             for (size_t i=0; i < el->propertySize(); i++) {
+                 Element *prop = el->getProperty(i);
                  if (prop == 0) {
                      break;
                  } else {
@@ -1801,6 +1809,7 @@
          }
          _value = obj;
       }
+      break;
       case Element::DATE_AMF0:
       {
          if (swfVersion > 5) {
@@ -1811,15 +1820,25 @@
       case Element::LONG_STRING_AMF0:
       {
          m_type = STRING;
-         std::string str = el.to_string();
+         std::string str = el->to_string();
          _value = str;
          break;
       }
       case Element::UNSUPPORTED_AMF0:
+         log_unimpl("Unsupported data type is not supported yet");
+         break;
       case Element::RECORD_SET_AMF0:
+         log_unimpl("Record Set data type is not supported yet");
+         break;
       case Element::XML_OBJECT_AMF0:
+         log_unimpl("XML data type is not supported yet");
+         break;
       case Element::TYPED_OBJECT_AMF0:
+         log_unimpl("Typed Object data type is not supported yet");
+         break;
       case Element::AMF3_DATA:
+         log_unimpl("AMF3 data type is not supported yet");
+         break;
       case Element::NOTYPE:
          throw ParserException("No type set for amf0 element");
          break;
@@ -1830,10 +1849,9 @@
 }
 
 as_value &
-as_value::operator=(amf::Element &)
+as_value::operator=(amf::Element *el)
 {
-
-    return *this;
+//    as_value(el);
 }
 
 as_value&

=== modified file 'libcore/as_value.h'
--- a/libcore/as_value.h        2008-09-03 21:46:17 +0000
+++ b/libcore/as_value.h        2008-09-03 23:46:02 +0000
@@ -163,8 +163,8 @@
        as_value(asNamespace &);
 
        /// Construct a value from an AMF element
-       as_value(amf::Element &);
-       as_value &operator=(amf::Element &);
+       as_value(amf::Element *el);
+       as_value &operator=(amf::Element *el);
        
        /// Construct a NULL, OBJECT, MOVIECLIP or AS_FUNCTION value
        //

=== modified file 'testsuite/libcore.all/AsValueTest.cpp'
--- a/testsuite/libcore.all/AsValueTest.cpp     2008-09-03 21:46:17 +0000
+++ b/testsuite/libcore.all/AsValueTest.cpp     2008-09-03 23:46:02 +0000
@@ -123,7 +123,7 @@
     
     Element el1;
     el1.makeNumber(1.234);
-    as_value as1(el1);
+    as_value as1(&el1);
     if (as1.to_number() == el1.to_number()) {
         runtest.pass("as_value(Element &number)");
     } else {
@@ -138,7 +138,7 @@
     
     Element el2;
     el2.makeString("Hello World");
-    as_value as2(el2);
+    as_value as2(&el2);
     if (as2.to_string() == el2.to_string()) {
         runtest.pass("as_value(Element &string)");
     } else {
@@ -147,7 +147,7 @@
     
     Element el3;
     el3.makeBoolean(true);
-    as_value as3(el3);    
+    as_value as3(&el3);    
     if ((as3.is_bool()) && (as3.to_bool() == true)) {
         runtest.pass("as_value(Element &bool)");
     } else {
@@ -156,7 +156,7 @@
 
     Element el4;
     el4.makeUndefined();
-    as_value as4(el4);
+    as_value as4(&el4);
     if (as4.is_undefined()) {
         runtest.pass("as_value(Element &undefined)");
     } else {
@@ -165,7 +165,7 @@
     
     Element el5;
     el5.makeMovieClip();
-    as_value as5(el5);
+    as_value as5(&el5);
     if (as5.is_sprite()) {
         runtest.pass("as_value(Element &movieclip)");
     } else {
@@ -198,7 +198,7 @@
     VM& vm = VM::get();
     string_table& st = vm.getStringTable();
 
-    as_value as1(top);
+    as_value as1(&top);
     
     if (as1.is_object()) {
         runtest.pass("as_value(Element &object)");


reply via email to

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