gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog libamf/amf.cpp libamf/amf.h lib...


From: Rob Savoye
Subject: [Gnash-commit] gnash ChangeLog libamf/amf.cpp libamf/amf.h lib...
Date: Wed, 30 Apr 2008 03:35:31 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Rob Savoye <rsavoye>    08/04/30 03:35:31

Modified files:
        .              : ChangeLog 
        libamf         : amf.cpp amf.h buffer.cpp buffer.h element.cpp 
                         element.h lcshm.cpp sol.cpp sol.h 
        testsuite/libamf.all: .cvsignore test_amf.cpp test_buffer.cpp 
                              test_el.cpp test_lc.cpp test_sol.cpp 

Log message:
                * libamf/amf.h: Use _AMF0* on Element types.
                * libamf/amf.cpp: Use AMF0_* instead of just AMF_*. Remove junk
                that's been commented out for awhile. Rename *Variable to
                *Property, which is the correct name. Adjust to keep valgrind
                happy.
                * libamf/element.h: Rename amf_* to amf0_*. Add new
                amf3_types. Rename *Child methods to *Property.
                * libamf/element.cpp: Add NOTYPE back in. 
                * libamf/lcshm.cpp: Use non static methods for extracting AMF
                objects.
                * libamf/sol.cpp: Use _AMF0* on Element types. 
                * testsuite/libamf.all/test_amf.cpp: Don't use Memory profiling
                if mallinfo() isn't found. Use _AMF0* on Element types.  Delete
                pointers so there are no memory leaks.
                * testsuite/libamf.all/test_buffer.cpp: Don't use Memory 
profiling
                if mallinfo() isn't found. Use _AMF0* on Element types. Delete
                pointers so there are no memory leaks.
                * testsuite/libamf.all/test_el.cpp: Use properties instead of
                children. Use _AMF0* on Element types. 
                * testsuite/libamf.all/test_lc.cpp: Don't try to send(), it's
                unimplemented still. Use _AMF0* on Element types. 
                * testsuite/libamf.all/test_sol.cpp: Use Memory profiling if
                mallinfo() exists. Use proper argument processing. Use _AMF0* on
                Element types.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6450&r2=1.6451
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amf.cpp?cvsroot=gnash&r1=1.72&r2=1.73
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amf.h?cvsroot=gnash&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/buffer.cpp?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/buffer.h?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/element.cpp?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/element.h?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/lcshm.cpp?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/sol.cpp?cvsroot=gnash&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/sol.h?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/.cvsignore?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/test_amf.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/test_buffer.cpp?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/test_el.cpp?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/test_lc.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/test_sol.cpp?cvsroot=gnash&r1=1.12&r2=1.13

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6450
retrieving revision 1.6451
diff -u -b -r1.6450 -r1.6451
--- ChangeLog   30 Apr 2008 02:33:05 -0000      1.6450
+++ ChangeLog   30 Apr 2008 03:35:30 -0000      1.6451
@@ -1,3 +1,30 @@
+2008-04-29  Rob Savoye  <address@hidden>
+
+       * libamf/amf.h: Use _AMF0* on Element types.
+       * libamf/amf.cpp: Use AMF0_* instead of just AMF_*. Remove junk
+       that's been commented out for awhile. Rename *Variable to
+       *Property, which is the correct name. Adjust to keep valgrind
+       happy.
+       * libamf/element.h: Rename amf_* to amf0_*. Add new
+       amf3_types. Rename *Child methods to *Property.
+       * libamf/element.cpp: Add NOTYPE back in. 
+       * libamf/lcshm.cpp: Use non static methods for extracting AMF
+       objects.
+       * libamf/sol.cpp: Use _AMF0* on Element types. 
+       * testsuite/libamf.all/test_amf.cpp: Don't use Memory profiling
+       if mallinfo() isn't found. Use _AMF0* on Element types.  Delete
+       pointers so there are no memory leaks.
+       * testsuite/libamf.all/test_buffer.cpp: Don't use Memory profiling
+       if mallinfo() isn't found. Use _AMF0* on Element types. Delete
+       pointers so there are no memory leaks.
+       * testsuite/libamf.all/test_el.cpp: Use properties instead of
+       children. Use _AMF0* on Element types. 
+       * testsuite/libamf.all/test_lc.cpp: Don't try to send(), it's
+       unimplemented still. Use _AMF0* on Element types. 
+       * testsuite/libamf.all/test_sol.cpp: Use Memory profiling if
+       mallinfo() exists. Use proper argument processing. Use _AMF0* on
+       Element types.
+
 2008-04-29 Zou Lunkai <address@hidden>
        
        * server/dlist.{h,cpp}: move_display_object() renamed to 
move_character(),

Index: libamf/amf.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/amf.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -b -r1.72 -r1.73
--- libamf/amf.cpp      14 Apr 2008 21:35:17 -0000      1.72
+++ libamf/amf.cpp      30 Apr 2008 03:35:30 -0000      1.73
@@ -155,125 +155,6 @@
     return word;
 }
 
-#if 0
-bool
-AMF::parseAMF(Network::byte_t * /* in */)
-{
-//    GNASH_REPORT_FUNCTION;
-
-#if 0
-    Network::byte_t *x = in;
-
-    while (*x != Element::OBJECT_END) {
-        x = readElements(x);
-    }
-    return true;
-#endif
-    return false;
-}
-
-vector<AMF::amf_element_t *> *
-AMF::readElements(Network::byte_t *in)
-{
-    GNASH_REPORT_FUNCTION;
-    Network::byte_t *x = in;
-    astype_e type = (astype_e)*x;
-    bool boolshift;
-    const char *mstr = NULL;
-    double *num;
-    double nanosecs;
-    short length;
-
-    vector<AMF::amf_element_t> list;
-    AMF::amf_element_t el;
-    
-    
-    log_debug(_("Type is %s"), astype_str[type]);
-
-//    x++;                        // skip the type byte
-    switch (type) {
-      case Element::NUMBER:
-         // AMF numbers are 64-bit big-endian integers.
-         num = extractNumber(x);
-//       log_debug(_("Number is " AMFNUM_F), num));
-          break;
-      case Element::BOOLEAN:
-          boolshift = *x;
-          log_debug(_("Boolean is %d"), boolshift);
-          break;
-      case Element::STRING:
-          string str = extractString(x);
-//        int length = *(short *)swapBytes(x, 2);
-//           length = *(short *)x;
-//           x+=2;                  // skip the length bytes
-//           mstr = new char[length+1];
-//           memset(mstr, 0, length+1);
-//           memcpy(mstr, x, length);
-          // The function converts the multibyte string beginning at
-          // *src to a sequence of wide characters as if by repeated
-          // calls of the form:
-//          mbsrtowcs
-                 log_debug(_("String is %s"), mstr);
-          break;
-      case Element::OBJECT:
-//          return reinterpret_cast<uint8_t *>(extractObject(x));
-//          readElement();
-          log_unimpl("Object AMF decoder");
-          break;
-      case Element::MOVIECLIP:
-        log_unimpl("MovieClip AMF decoder");
-          break;
-      case Element::UNSUPPORTED:
-        log_unimpl("Unsupported AMF decoder");
-          break;
-      case Element::NULL_VALUE: 
-          log_unimpl("Null AMF decoder");
-          break;
-      case Element::UNDEFINED:
-          log_debug(_("Undefined element"));
-          break;
-      case Element::REFERENCE:
-          log_unimpl("Reference AMF decoder");
-          break;
-      case Element::ECMA_ARRAY:
-          log_unimpl("ECMAArray AMF decoder");
-          break;
-      case Element::OBJECT_END:
-          log_unimpl("ObjectEnd AMF decoder");
-          break;
-      case Element::STRICT_ARRAY:
-          log_unimpl("StrictArray AMF decoder");
-          break;
-      case Element::DATE:
-          nanosecs = *(double *)swapBytes(x+1, 8);
-//          log_debug(_("Date is " AMFNUM_F " nanoseconds"), nanosecs);
-          break;
-      case Element::LONG_STRING:
-//          int length = *(short *)swapBytes(x, 4);
-          x+=4;                  // skip the length bytes
-//        mstr = new char[length+1];
-//          memcpy(mstr, x, length);
-//          log_debug(_("String is %s"), mstr);
-          break;
-      case Element::RECORD_SET:
-          log_unimpl("Recordset AMF decoder");
-          break;
-      case Element::XML_OBJECT:
-          log_unimpl("XMLObject AMF decoder");
-          break;
-      case Element::TYPED_OBJECT:
-          log_unimpl("TypedObject AMF decoder");
-          break;
-      default:
-          log_error("Warning: Unknown AMF element type %d\n", type);
-          break;
-    }
-    
-    return x;
-}
-#endif
-
-
 //
 // Methods for encoding data into big endian formatted raw AMF data.
 //
@@ -289,10 +170,10 @@
 //    GNASH_REPORT_FUNCTION;
     double num;
     // Encode the data as a 64 bit, big-endian, numeric value
-    Buffer *buf = new Buffer(AMF_NUMBER_SIZE + AMF_HEADER_SIZE);
-    buf->append(Element::NUMBER);
+    Buffer *buf = new Buffer(AMF0_NUMBER_SIZE + AMF_HEADER_SIZE);
+    buf->append(Element::NUMBER_AMF0);
     num = indata;
-    swapBytes(&num, AMF_NUMBER_SIZE);
+    swapBytes(&num, AMF0_NUMBER_SIZE);
     buf->append(num);
     
     return buf;
@@ -311,7 +192,7 @@
 //    GNASH_REPORT_FUNCTION;
     // Encode a boolean value. 0 for false, 1 for true
     Buffer *buf = new Buffer(AMF_HEADER_SIZE);
-    buf->append(Element::BOOLEAN);
+    buf->append(Element::BOOLEAN_AMF0);
     boost::uint16_t x = flag;
     swapBytes(&x, 2);
     buf->append(x);
@@ -327,7 +208,7 @@
 Buffer *
 AMF::encodeObjectEnd()
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     Buffer *buf = new Buffer(1);
     buf->append(TERMINATOR);
 
@@ -344,10 +225,10 @@
 AMF::encodeObject(Element *el)
 {
     GNASH_REPORT_FUNCTION;
-    AMF amf_obj;
+//    AMF amf_obj;
     
-    for (size_t i=0; i< el->childrenSize(); i++) {
-//     Buffer *var = amf_obj.encodeVariable();
+    for (size_t i=0; i< el->propertiesSize(); i++) {
+//     Buffer *var = amf_obj.encodeProperty();
 //     Element *child = el[i];
 #if 0
        Buffer *buf = new Buffer(AMF_HEADER_SIZE + size);
@@ -375,7 +256,7 @@
 {
 //    GNASH_REPORT_FUNCTION;
     Buffer *buf = new Buffer(AMF_HEADER_SIZE);
-    buf->append(Element::UNDEFINED);
+    buf->append(Element::UNDEFINED_AMF0);
     
     return buf;
 }
@@ -390,7 +271,7 @@
 {
 //    GNASH_REPORT_FUNCTION;
     Buffer *buf = new Buffer(AMF_HEADER_SIZE);
-    buf->append(Element::UNSUPPORTED);
+    buf->append(Element::UNSUPPORTED_AMF0);
     
     return buf;
 }
@@ -405,7 +286,7 @@
 {
 //    GNASH_REPORT_FUNCTION;
     Buffer *buf = new Buffer(AMF_HEADER_SIZE);
-    buf->append(Element::DATE);
+    buf->append(Element::DATE_AMF0);
     double num = *reinterpret_cast<const double*>(data);
     swapBytes(&num, 8);
     buf->append(num);
@@ -557,7 +438,7 @@
     boost::uint16_t length;
     
     Buffer *buf = new Buffer(size + AMF_HEADER_SIZE);
-    buf->append(Element::STRING);
+    buf->append(Element::STRING_AMF0);
     // when a string is stored in an element, we add a NULL terminator so
     // it can be printed by to_string() efficiently. The NULL terminator
     // doesn't get written when encoding a string as it has a byte count
@@ -583,7 +464,7 @@
     boost::uint16_t length;
     
     Buffer *buf = new Buffer(AMF_HEADER_SIZE);
-    buf->append(Element::STRING);
+    buf->append(Element::STRING_AMF0);
     // when a string is stored in an element, we add a NULL terminator so
     // it can be printed by to_string() efficiently. The NULL terminator
     // doesn't get written when encoding a string as it has a byte count
@@ -640,64 +521,64 @@
       case Element::NOTYPE:
          return 0;
          break;
-      case Element::NUMBER:
+      case Element::NUMBER_AMF0:
          tmp = encodeNumber(el->to_number());
           break;
-      case Element::BOOLEAN:
+      case Element::BOOLEAN_AMF0:
          tmp = encodeBoolean(el->to_bool());
           break;
-      case Element::STRING:
+      case Element::STRING_AMF0:
          tmp = encodeString(el->getData(), el->getLength()-1);
          break;
-      case Element::OBJECT:
+      case Element::OBJECT_AMF0:
          tmp = el->encode();
           break;
-      case Element::MOVIECLIP:
+      case Element::MOVIECLIP_AMF0:
          tmp = encodeMovieClip(el->getData(), el->getLength());
           break;
-      case Element::NULL_VALUE: 
+      case Element::NULL_AMF0:
          tmp = encodeNull();
           break;
-      case Element::UNDEFINED:
+      case Element::UNDEFINED_AMF0:
          tmp = encodeUndefined();
          break;
-      case Element::REFERENCE:
+      case Element::REFERENCE_AMF0:
          tmp = encodeReference(el->getData(), el->getLength());
           break;
-      case Element::ECMA_ARRAY:
+      case Element::ECMA_ARRAY_AMF0:
          tmp = encodeECMAArray(el->getData(), el->getLength());
           break;
          // The Object End gets added when creating the object, so we can jusy 
ignore it here.
-      case Element::OBJECT_END:
+      case Element::OBJECT_END_AMF0:
          tmp = encodeObjectEnd();
           break;
-      case Element::STRICT_ARRAY:
+      case Element::STRICT_ARRAY_AMF0:
          tmp = encodeStrictArray(el->getData(), el->getLength());
           break;
-      case Element::DATE:
+      case Element::DATE_AMF0:
          tmp = encodeDate(el->getData());
           break;
-      case Element::LONG_STRING:
+      case Element::LONG_STRING_AMF0:
          tmp = encodeLongString(el->getData(), el->getLength());
           break;
-      case Element::UNSUPPORTED:
+      case Element::UNSUPPORTED_AMF0:
          tmp = encodeUnsupported();
           break;
-      case Element::RECORD_SET:
+      case Element::RECORD_SET_AMF0:
          tmp = encodeRecordSet(el->getData(), el->getLength());
           break;
-      case Element::XML_OBJECT:
+      case Element::XML_OBJECT_AMF0:
          tmp = encodeXMLObject(el->getData(), el->getLength());
           // Encode an XML object. The data follows a 4 byte length
           // field. (which must be big-endian)
           break;
-      case Element::TYPED_OBJECT:
+      case Element::TYPED_OBJECT_AMF0:
 //       tmp = encodeTypedObject(el->getData(), el->getLength());
           break;
-         // This is a Gnash specific value
-      case Element::VARIABLE:
-      case Element::FUNCTION:
-          break;
+//       // This is a Gnash specific value
+//       case Element::VARIABLE:
+//       case Element::FUNCTION:
+//          break;
     };
 
     buf->append(tmp);
@@ -718,7 +599,7 @@
 vector<Buffer> *
 AMF::encodeElement(vector<amf::Element *> &data)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
 
     int size = 0;
     bool pad = false;
@@ -759,7 +640,7 @@
        // wider variety of sef movies that use LocalConnection to
        // really tell.
        if (el->getType() == Element::NUMBER) {
-           size = AMF_NUMBER_SIZE + 1;
+           size = AMF0_NUMBER_SIZE + 1;
            pad = true;
        }
        if (el->getType() == Element::STRING) {
@@ -769,9 +650,9 @@
            }
            size = el->getLength() + AMF_HEADER_SIZE;
        }
-       if (el->getType() == Element::FUNCTION) {
-           // _children
-       }
+//     if (el->getType() == Element::FUNCTION) {
+//         // _properties
+//     }
        if (el->getType() == Element::BOOLEAN) {
            size = 3;
        }
@@ -787,253 +668,10 @@
 }
 #endif
 
-// #if 0
-// AMF::astype_e
-// AMF::extractElementHeader(void *in)
-// {
-// //    GNASH_REPORT_FUNCTION;
-
-//     return (AMF::astype_e)*(char *)in;
-// }
-
-// int
-// AMF::extractElementLength(void *in)
-// {
-// //    GNASH_REPORT_FUNCTION;
-
-//     char *x = (char *)in;
-//     Element::astype_e type = (Element::astype_e)*x;
-//     x++;                        // skip the header byte
-    
-//     switch (type) {
-//       case Element::NUMBER:              // a 64 bit numeric value
-//           return AMF_NUMBER_SIZE;
-//           break;
-//       case Element::BOOLEAN:             // a single byte
-//           return sizeof(bool);
-//           break;
-//       case Element::STRING:              // the length is a 2 byte value
-//             //FIXME, there are all kinds of byte order problems in this 
code.
-//           return (short)*(short *)x;
-//           break;
-//       case Element::OBJECT:
-//           return x - strchr(x, TERMINATOR);
-//           break;
-//       case Element::MOVIECLIP:
-//           return -1;
-//           log_unimpl("MovieClip AMF extractor");
-//           break;
-//       case Element::NULL_VALUE: 
-//           return -1;
-//           log_unimpl("Null AMF extractor");
-//           break;
-//       case Element::UNDEFINED:
-//           return 0;
-//           break;
-//       case Element::REFERENCE:
-//           return -1;
-//           log_unimpl("Reference AMF extractor");
-//           break;
-//       case Element::ECMA_ARRAY:
-//           return x - strchr(x, TERMINATOR);
-//           break;
-//       case Element::OBJECT_END:
-//           return -1;
-//           log_unimpl("ObjectEnd AMF extractor");
-//           break;
-//       case Element::STRICT_ARRAY:         // the length is a 4 byte value
-// //          return (int *)x;
-//           break;
-//       case Element::DATE:              // a 64 bit numeric value
-//           return 8;
-//           break;
-//       case Element::LONG_STRING:
-//           return -1;
-//           log_unimpl("LongString AMF extractor");
-//           break;
-//       case Element::UNSUPPORTED:
-//           return -1;
-//           log_unimpl("Unsupported AMF extractor");
-//           break;
-//       case Element::RECORD_SET:
-//           return -1;
-//           log_unimpl("Recordset AMF extractor");
-//           break;
-//       case Element::XML_OBJECT:           // the length is a 4 byte value
-// //          return (int)*(int *)x;
-//           break;
-//       case Element::TYPED_OBJECT:
-//           return x - strchr(x, TERMINATOR);
-//           break;
-//     };
-    
-//     return 0;
-// }
-
-// char *
-// AMF::extractString(const Network::byte_t *in)
-// {
-// //    GNASH_REPORT_FUNCTION;
-//     boost::int8_t *buf = NULL;
-//     Network::byte_t *x = const_cast<Network::byte_t *>(in);
-    
-//     if (*x == Element::STRING) {
-//         x++;
-//         short length = *(reinterpret_cast<const short *>(x));
-//         swapBytes(&length, 2);
-//     log_debug("Encoded length of string: %hd", length);
-//         x += sizeof(short);
-//         buf = new int8_t[length+1];
-//         memset(buf, 0, length+1);
-//         memcpy(buf, x, length); /* x is not long enough */
-//     } else {
-//         log_error("Tried to extract AMF string from non String object!");
-//     }
-    
-//     return reinterpret_cast<char *>(buf);
-// }
-
-// double
-// AMF::extractNumber(const Network::byte_t *in)
-// {
-// //    GNASH_REPORT_FUNCTION;    
-//     Network::byte_t *x = const_cast<uint8_t *>(in);
-// //    double *num = new double;
-//     double num = 0.0;
-// //    memset(num, 0, AMF_NUMBER_SIZE);
-    
-//     if (*x == Element::NUMBER) {
-//         x++;
-//         memcpy(&num, x, AMF_NUMBER_SIZE);
-//         swapBytes(&num, AMF_NUMBER_SIZE);
-//     } else {
-//         log_error("Tried to extract AMF Number from non Number object!");
-//     }
-
-//     return num;
-// }
-
-// Element &
-// AMF::createElement(amf_element_t *el, astype_e type,
-//               const std::string &name, Network::byte_t *data, int nbytes)
-// {
-// //    GNASH_REPORT_FUNCTION;
-//     log_debug("Creating element %s", name.c_str());
-    
-//     el->type = type;
-//     el->name = name;
-//     el->length = nbytes;
-//     el->data = data;
-//     return el;
-// }
-
-// // AMF::amf_element_t *
-// // AMF::createElement(amf_element_t *el, const char *name, double data)
-// // {
-// // //    GNASH_REPORT_FUNCTION;
-// //     string str = name;
-// //     return createElement(el, str, data);
-// // }
-
-// // AMF::amf_element_t *
-// // AMF::createElement(amf_element_t *el, const std::string &name, double 
data)
-// // {
-// // //    GNASH_REPORT_FUNCTION;
-// //     log_debug("Creating element %s", name.c_str());
-
-// //     el->type = AMF::NUMBER;
-// //     el->name = name;
-// //     el->length = AMF_NUMBER_SIZE;
-// // //    char *numptr = (char *)&data;
-// //     el->data = new Network::byte_t[AMF_NUMBER_SIZE + 1];
-// //     memset(el->data, 0, AMF_NUMBER_SIZE + 1);
-// //     memcpy(el->data, &data, AMF_NUMBER_SIZE);
-
-// //     return el;
-// // }
-
-// AMF::amf_element_t *
-// AMF::createElement(amf_element_t *el, const char *name, double data)
-// {
-// //    GNASH_REPORT_FUNCTION;
-//     string str = name;
-//     return createElement(el, str, data);
-// }
-
-// AMF::amf_element_t *
-// AMF::createElement(amf_element_t *el, const std::string &name, double data)
-// {
-// //    GNASH_REPORT_FUNCTION;
-//     log_debug("Creating element %s", name.c_str());
-
-//     el->type = AMF::NUMBER;
-//     el->name = name;
-//     el->length = AMF_NUMBER_SIZE;
-// //    char *numptr = (char *)&data;
-//     el->data = new Network::byte_t[AMF_NUMBER_SIZE + 1];
-//     memset(el->data, 0, AMF_NUMBER_SIZE + 1);
-//     memcpy(el->data, &data, AMF_NUMBER_SIZE);
-
-//     return el;
-// }
-
-// AMF::amf_element_t *
-// AMF::createElement(amf_element_t *el, const char *name, const char *data)
-// {
-// //    GNASH_REPORT_FUNCTION;
-//     log_debug("Creating element %s", name);
-
-//     el->type = AMF::STRING;
-//     el->name = name;
-//     el->length = strlen(data);
-//     char *str = const_cast<char *>(data);
-//     el->data = reinterpret_cast<Network::byte_t *>(str);
-//     return el;
-// }
-
-// AMF::amf_element_t *
-// AMF::createElement(amf_element_t *el, const std::string &name, std::string 
&data)
-// {
-// //    GNASH_REPORT_FUNCTION;
-//     log_debug("Creating element %s", name.c_str());
-
-//     el->type = AMF::STRING;
-//     el->name = name;
-//     el->length = data.size();
-//     char *str = const_cast<char *>(data.c_str());
-//     el->data = reinterpret_cast<Network::byte_t *>(str);
-//     return el;
-// }
-
-// AMF::amf_element_t *
-// AMF::createElement(amf_element_t *el, const char *name, bool data)
-// {
-// //    GNASH_REPORT_FUNCTION;
-//     string str = name;
-//     return createElement(el, str, data);
-// }
-
-// AMF::amf_element_t *
-// AMF::createElement(AMF::amf_element_t *el, const std::string &name, bool 
data)
-// {
-// //    GNASH_REPORT_FUNCTION;
-//     log_debug("Creating element %s", name.c_str());
-
-//     el->type = AMF::BOOLEAN;
-//     el->name = name;
-//     el->length = 1;
-//     el->data = new Network::byte_t[sizeof(uint16_t)];
-//     memset(el->data, 0, sizeof(uint16_t));
-//     *el->data = data;
-//     return el;
-// }
-
-// #endif
-
 Buffer *
-AMF::encodeVariable(amf::Element *el)
+AMF::encodeProperty(amf::Element *el)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     
     size_t outsize = el->getNameSize() + el->getLength() + AMF_VAR_HEADER_SIZE;
 
@@ -1063,14 +701,14 @@
     // Booleans appear to be encoded weird. Just a short after
     // the type byte that's the value.
     switch (el->getType()) {
-      case Element::BOOLEAN:
+      case Element::BOOLEAN_AMF0:
          enclength = el->to_bool();
          buf->append(enclength);
          break;
-      case Element::NUMBER:
+      case Element::NUMBER_AMF0:
          if (el->getData()) {
-             swapBytes(el->getData(), AMF_NUMBER_SIZE);
-             buf->append(el->getData(), AMF_NUMBER_SIZE);
+             swapBytes(el->getData(), AMF0_NUMBER_SIZE);
+             buf->append(el->getData(), AMF0_NUMBER_SIZE);
          }
          break;
       default:
@@ -1084,137 +722,17 @@
     return buf;
 }
 
-// #if 0
-// Network::byte_t *
-// AMF::encodeVariable(const char *name, bool flag)
-// {
-// //    GNASH_REPORT_FUNCTION;
-    
-//     int outsize = strlen(name) + AMF_NUMBER_SIZE + 5;
-//     Network::byte_t *out = new uint8_t[outsize];
-//     Network::byte_t *tmpptr = out;
-
-//     size_t length = strlen(name);
-//     short enclength = length;
-//     swapBytes(&enclength, 2);
-//     memcpy(tmpptr, &enclength, 2);
-//     tmpptr += 2;
-//     memcpy(tmpptr, name, length);
-//     tmpptr += length;
-//     *tmpptr = Element::BOOLEAN;
-//     tmpptr++;
-//     *tmpptr = flag;
-
-//     return out;    
-// }
-
-// Network::byte_t *
-// AMF::encodeVariable(const char *name)
-// {
-// //    GNASH_REPORT_FUNCTION;
-//     size_t outsize = strlen(name) + AMF_NUMBER_SIZE + 5;
-//     Network::byte_t *out = new Network::byte_t[outsize];
-//     Network::byte_t *tmpptr = out;
-
-//     size_t length = strlen(name);
-//     short enclength = length;
-//     swapBytes(&enclength, 2);
-//     memcpy(tmpptr, &enclength, 2);
-//     tmpptr += 2;
-//     memcpy(tmpptr, name, length);
-//     tmpptr += length;
-//     *tmpptr = Element::UNDEFINED;
-//     tmpptr++;
-
-//     return out;    
-// }
-
-// Network::byte_t *
-// AMF::encodeVariable(const char *name, double bignum)
-// {
-// //    GNASH_REPORT_FUNCTION;
-//     int outsize = strlen(name) + AMF_NUMBER_SIZE + 5;
-//     Network::byte_t *out = new Network::byte_t[outsize];
-//     Network::byte_t *tmpptr = out;
-//     double newnum = bignum;
-//     char *numptr = (char *)&newnum;
-
-//     size_t length = strlen(name);
-//     short enclength = length;
-//     swapBytes(&enclength, 2);
-//     memcpy(tmpptr, &enclength, 2);
-//     tmpptr += 2;
-//     memcpy(tmpptr, name, length);
-//     tmpptr += length;
-//     *tmpptr = Element::NUMBER;
-//     tmpptr++;
-// //    swapBytes(numptr, AMF_NUMBER_SIZE);
-//     memcpy(tmpptr, numptr, AMF_NUMBER_SIZE);
-
-//     return out;    
-// }
-
-// uint8_t *
-// AMF::encodeVariable(const char *name, const char *val)
-// {
-// //    GNASH_REPORT_FUNCTION;
-
-//     int outsize = strlen(name) + strlen(val) + 5;
-//     Network::byte_t *out = new Network::byte_t[outsize];
-//     Network::byte_t *tmpptr = out;
-
-//     size_t length = strlen(name);
-//     short enclength = length;
-//     swapBytes(&enclength, 2);
-//     memcpy(tmpptr, &enclength, 2);
-//     tmpptr += 2;
-//     memcpy(tmpptr, name, length);
-//     tmpptr += length;
-//     *tmpptr = Element::STRING;
-//     tmpptr++;
-//     length = strlen(val);
-//     enclength = length;
-//     swapBytes(&enclength, 2);
-//     memcpy(tmpptr, &enclength, 2);
-//     tmpptr += 2;
-//     memcpy(tmpptr, val, length);
-
-//     return out;
-// }
-
-// Network::byte_t *
-// AMF::encodeVariable(std::string &name, std::string &val)
-// {
-// //    GNASH_REPORT_FUNCTION;
-
-//     int outsize = name.size() + val.size() + 5;
-//     Network::byte_t *out = new Network::byte_t[outsize];
-//     Network::byte_t *tmpptr = out;
-//     short length;
-
-//     length = name.size() && 0xffff;
-//     swapBytes(&length, 2);
-//     memcpy(tmpptr, &length, 2);
-//     tmpptr += 2;
-//     memcpy(tmpptr, name.c_str(), name.size());
-//     tmpptr += name.size();
-//     *tmpptr = Element::STRING;
-//     tmpptr++;
-//     length = val.size() && 0xffff;
-//     swapBytes(&length, 2);
-//     memcpy(tmpptr, &length, 2);
-//     tmpptr += 2;
-//     memcpy(tmpptr, val.c_str(), name.size());
-
-//     return out;
-// }
-
-// #endif
+Element *
+AMF::extractAMF(Buffer *buf)
+{
+//    GNASH_REPORT_FUNCTION;
+    return extractAMF(buf->reference());
+}
 
 Element *
 AMF::extractAMF(Network::byte_t *in)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
 
     Element *el = new Element;    
     Network::byte_t *tmpptr;
@@ -1234,21 +752,26 @@
     // 8 bytes are read If it's a String type, then there is a count of
     // characters, then the string value    
     
-    // Check the type of the element data
-    Element::amf_type_e type = *(reinterpret_cast<Element::amf_type_e 
*>(tmpptr));
+    // Get the type of the element, which is a single byte.
+    // This type casting looks like a stupid mistake, but it's
+    // mostly to make valgrind shut up, as it has a tendency to
+    // complain about legit code when it comes to all this byte
+    // manipulation stuff.
+    char c = *(reinterpret_cast<char *>(tmpptr));
+    Element::amf0_type_e type = static_cast<Element::amf0_type_e>(c);
     tmpptr++;                        // skip the header byte
 
     AMF amf_obj;
     switch (type) {
-      case Element::NUMBER:
+      case Element::NUMBER_AMF0:
          el->makeNumber(tmpptr);
-         tmpptr += AMF_NUMBER_SIZE; // all numbers are 8 bit big endian
+         tmpptr += AMF0_NUMBER_SIZE; // all numbers are 8 bit big endian
          break;
-      case Element::BOOLEAN:
+      case Element::BOOLEAN_AMF0:
          el->makeBoolean(tmpptr);
          tmpptr += sizeof(boost::uint16_t); // although a bool is one byte, 
it's stored as a short
          break;
-      case Element::STRING:
+      case Element::STRING_AMF0:
          // get the length of the name
          length = ntohs((*(boost::uint16_t *)tmpptr) & 0xffff);
          tmpptr += sizeof(boost::uint16_t);
@@ -1259,91 +782,107 @@
              log_debug(_("AMF String is: %s"), el->to_string());
              tmpptr += length;
          } else {
-             el->setType(Element::STRING);
+             el->setType(Element::STRING_AMF0);
          };
          break;
-      case Element::OBJECT:
+      case Element::OBJECT_AMF0:
+         el->makeObject();
+         Element *child;
          do {
-             el = amf_obj.extractVariable(tmpptr);
-             tmpptr += amf_obj.totalsize();
-         } while (el->getType() != Element::OBJECT_END);
-         break;
-      case Element::MOVIECLIP:
-      case Element::NULL_VALUE: 
-      case Element::UNDEFINED:
-      case Element::REFERENCE:
-      case Element::ECMA_ARRAY:
-      case Element::OBJECT_END:
-      case Element::STRICT_ARRAY:
-      case Element::DATE:
-      case Element::LONG_STRING:
-      case Element::UNSUPPORTED:
-      case Element::RECORD_SET:
-      case Element::XML_OBJECT:
-      case Element::TYPED_OBJECT:
+             child = amf_obj.extractProperty(tmpptr);
+             tmpptr += amf_obj.totalsize() - 1;
+             el->addProperty(child);
+         } while (*tmpptr != Element::OBJECT_END_AMF0);
+         break;
+      case Element::MOVIECLIP_AMF0:
+      case Element::NULL_AMF0:
+      case Element::UNDEFINED_AMF0:
+      case Element::REFERENCE_AMF0:
+      case Element::ECMA_ARRAY_AMF0:
+      case Element::OBJECT_END_AMF0:
+      case Element::STRICT_ARRAY_AMF0:
+      case Element::DATE_AMF0:
+      case Element::LONG_STRING_AMF0:
+      case Element::UNSUPPORTED_AMF0:
+      case Element::RECORD_SET_AMF0:
+      case Element::XML_OBJECT_AMF0:
+      case Element::TYPED_OBJECT_AMF0:
       default:
 //       log_unimpl("%s: type %d", __PRETTY_FUNCTION__, (int)type);
          return 0;
     }
     
+    // Calculate the offset for the next read
+    _totalsize = (tmpptr - in) + 1;
+
     return el;
 }
 
 Element *
-AMF::extractVariable(Network::byte_t *in)
+AMF::extractProperty(Buffer *buf)
 {
 //    GNASH_REPORT_FUNCTION;
-    Element *el = new Element;
-    boost::uint16_t length;
+    return extractProperty(buf->reference());
+}
 
+Element *
+AMF::extractProperty(Network::byte_t *in)
+{
+//    GNASH_REPORT_FUNCTION;
     Network::byte_t *tmpptr = in;
-//    std::copy(in, in + sizeof(boost::uint16_t), &length);
-    length = *reinterpret_cast<boost::uint16_t *>(in);
-    swapBytes(&length, sizeof(boost::uint16_t));
+    boost::uint16_t length = 0;
+    Network::byte_t len = 0;
+
+//    length = *(reinterpret_cast<boost::uint16_t *>(tmpptr));
+    length = tmpptr[1];
+//    swapBytes(&length, sizeof(boost::uint16_t));
     tmpptr += sizeof(boost::uint16_t);    
+    
     if (length <= 0) {
-       if (*(in+2) == Element::OBJECT_END) {
+//     if (*(in+2) == Element::OBJECT_END) {
            log_debug(_("End of Object definition"));
-            el->setType(Element::OBJECT_END);
-            return el;
-        }
-       delete el;
+//            el->setType(Element::OBJECT_END);
+//             return el;
+//         }
+//     delete el;
        return 0;
     }    
+    
+    Element *el = new Element;
     // get the name of the element, the length of which we just decoded
     if (length > 0) {
-        log_debug(_("AMF element length is: %d"), length);
+//        log_debug(_("AMF element length is: %d"), length);
         el->setName(tmpptr, length);
-       log_debug(_("AMF element name is: %s"), el->getName());
+//     log_debug(_("AMF element name is: %s"), el->getName());
        tmpptr += length;
     }
     
     // get the type of the element, which is a single byte.
     char c = *(reinterpret_cast<char *>(tmpptr));
-    Element::amf_type_e type = static_cast<Element::amf_type_e>(c);
+    Element::amf0_type_e type = static_cast<Element::amf0_type_e>(c);
     tmpptr++;
-    if (type != Element::TYPED_OBJECT) {
-//        log_debug(_("AMF type is: %s"), amftype_str[(int)type]);
+    if (type != Element::TYPED_OBJECT_AMF0) {
+        log_debug(_("AMF type is: %s"), amftype_str[(int)type]);
        el->setType(type);
     }
 
     switch (type) {
-      case Element::NUMBER: 
+      case Element::NUMBER_AMF0:
       {
          double num = *reinterpret_cast<const double*>(tmpptr);
-          swapBytes(&num, AMF_NUMBER_SIZE);
+          swapBytes(&num, AMF0_NUMBER_SIZE);
          el->makeNumber(num);
-          tmpptr += AMF_NUMBER_SIZE;
+          tmpptr += AMF0_NUMBER_SIZE;
          break;
       }
-      case Element::BOOLEAN:
+      case Element::BOOLEAN_AMF0:
       {
          bool sheet = *(reinterpret_cast<bool *>(tmpptr));
           el->makeBoolean(sheet);
          tmpptr += 1;
          break;
       }
-      case Element::STRING:
+      case Element::STRING_AMF0:
          // extractString returns a printable char *. First 2 bytes for the 
length,
          // and then read the string, which is NOT NULL terminated.
          length = *reinterpret_cast<boost::uint16_t *>(tmpptr);
@@ -1354,44 +893,43 @@
              tmpptr += length;
          }
          if (length == 0) {
+//           log_debug("NullString");
              el->makeNullString();
-//           tmpptr++;
          }
-//       string v(reinterpret_cast<const char *>(tmpptr) + 3, (int)length);
-         log_debug(_("Variable \"%s\" is: %s"), el->getName(), 
el->to_string());
+//       log_debug(_("Property \"%s\" is: %s"), el->getName(), 
el->to_string());
           break;
-      case Element::OBJECT:
-         while (*(tmpptr++) != Element::OBJECT_END) {
-             log_debug("Look for end of object...");
+      case Element::OBJECT_AMF0:
+         while (*(tmpptr++) != Element::OBJECT_END_AMF0) {
+//           log_debug("Looking for end of object...");
          }
          break;
-      case Element::MOVIECLIP:
-      case Element::NULL_VALUE:
+      case Element::MOVIECLIP_AMF0:
+      case Element::NULL_AMF0:
          el->makeUndefined();
          break;
-      case Element::UNDEFINED:
+      case Element::UNDEFINED_AMF0:
          el->makeUndefined();
           break;
-      case Element::REFERENCE:
-      case Element::ECMA_ARRAY:
+      case Element::REFERENCE_AMF0:
+      case Element::ECMA_ARRAY_AMF0:
                        // FIXME this shouldn't fall thru
-      case Element::OBJECT_END:
+      case Element::OBJECT_END_AMF0:
 //          log_debug(_("End of Object definition"));
          el->makeObjectEnd();
           break;
-      case Element::TYPED_OBJECT:
+      case Element::TYPED_OBJECT_AMF0:
          el->makeTypedObject(tmpptr, 0);
           break;
-      case Element::STRICT_ARRAY:
-      case Element::DATE:
+      case Element::STRICT_ARRAY_AMF0:
+      case Element::DATE_AMF0:
          el->makeDate(tmpptr);
           break;
-      case Element::LONG_STRING:
-      case Element::UNSUPPORTED:
-      case Element::RECORD_SET:
-      case Element::XML_OBJECT:
+      case Element::LONG_STRING_AMF0:
+      case Element::UNSUPPORTED_AMF0:
+      case Element::RECORD_SET_AMF0:
+      case Element::XML_OBJECT_AMF0:
       default:
-          log_unimpl(_("amf_type_e of value: %x"), (int)type);
+          log_unimpl(_("amf0_type_e of value: %x"), (int)type);
          delete el;
          return 0;
     }

Index: libamf/amf.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/amf.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- libamf/amf.h        14 Apr 2008 21:35:17 -0000      1.40
+++ libamf/amf.h        30 Apr 2008 03:35:30 -0000      1.41
@@ -47,7 +47,7 @@
 class Buffer;
 
 // All numbers in AMF format are 8 byte doubles.
-const size_t AMF_NUMBER_SIZE = 0x08;
+const size_t AMF0_NUMBER_SIZE = 0x08;
 
 // The header of an AMF object is a type filed (1 byte), followed by a
 // length field. (short)
@@ -59,9 +59,6 @@
 // then only 5 bytes instead of the 6 that one assumes would be used.
 const gnash::Network::byte_t AMF_VAR_HEADER_SIZE = 5;
 
-// FIXME: this should go away
-const int  AMF_PACKET_SIZE = 128;
-
 // Use a zero version till now till we know what this should be.
 const gnash::Network::byte_t AMF_VERSION = 0;
 
@@ -73,15 +70,6 @@
 // LocalConnection segment, or over an RTMP connection for streaming.
 class DSOEXPORT AMF {
 public:
-//     typedef enum {
-//         Byte,
-//         Int,
-//         MediumInt,
-//         Long,
-//         Double,
-//         UTF8,
-//         LongUTF8
-//     } amftype_e;
     typedef enum {
         CONNECT = 0x01,
         DISCONNECT = 0x02,
@@ -109,7 +97,6 @@
     AMF();
     AMF(size_t size);
     ~AMF();
-//    size_t size() { return _total_size; };
 
     //
     // Methods for encoding data into big endian formatted raw AMF data.
@@ -244,7 +231,7 @@
     ///         in form of a newly allocated byte array.
     ///         to be deleted by caller using delete [] operator, or NULL
     ///
-    Buffer *encodeVariable(amf::Element *el);
+    Buffer *encodeProperty(amf::Element *el);
     static Buffer *encodeVariableHeader(const std::string &name);
     
     //
@@ -252,14 +239,21 @@
     //
     
     // Extract the object type from the first byte of the header.
-    static amf::Element::amf_type_e 
extractElementHeader(gnash::Network::byte_t *in)
-                         { return *(reinterpret_cast<amf::Element::amf_type_e 
*>(in)); };
+    static amf::Element::amf0_type_e 
extractElementHeader(gnash::Network::byte_t *in)
+                         { return *(reinterpret_cast<amf::Element::amf0_type_e 
*>(in)); };
+
+    // Unlike when we are encoding, for extracting objects we need
+    // to keep track where we are in the memory buffer so these can't
+    // be static.
 
     // Extract an AMF object. These have no name like the variables do.
-    static amf::Element *extractAMF(gnash::Network::byte_t *in);
+    amf::Element *extractAMF(gnash::Network::byte_t *in);
+    amf::Element *extractAMF(Buffer *buf);
+    
     // Extract an AMF "variable", which is a standard AMF object preceeded by
     // just a length and a name field.
-    amf::Element *extractVariable(gnash::Network::byte_t *in);
+    amf::Element *extractProperty(gnash::Network::byte_t *in);
+    amf::Element *extractProperty(Buffer *buf);
 
     size_t totalsize() { return _totalsize; }
     

Index: libamf/buffer.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/buffer.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- libamf/buffer.cpp   14 Apr 2008 21:35:17 -0000      1.8
+++ libamf/buffer.cpp   30 Apr 2008 03:35:30 -0000      1.9
@@ -17,6 +17,7 @@
 //
 
 #include <boost/cstdint.hpp>
+#include <iostream>
 #include "buffer.h"
 #include "amf.h"
 #include "log.h"
@@ -114,8 +115,8 @@
 {
 //    GNASH_REPORT_FUNCTION;
     Network::byte_t *ptr = reinterpret_cast<Network::byte_t *>(&num);
-    std::copy(ptr, ptr + amf::AMF_NUMBER_SIZE, _ptr);    
-    _seekptr = _ptr + amf::AMF_NUMBER_SIZE;
+    std::copy(ptr, ptr + amf::AMF0_NUMBER_SIZE, _ptr);    
+    _seekptr = _ptr + amf::AMF0_NUMBER_SIZE;
 }
 
 void
@@ -167,8 +168,8 @@
 //    GNASH_REPORT_FUNCTION;
     if ((_seekptr + sizeof(double)) <= (_ptr + _nbytes)) {
        Network::byte_t *ptr = reinterpret_cast<Network::byte_t *>(&num);
-       std::copy(ptr, ptr + amf::AMF_NUMBER_SIZE, _seekptr);    
-       _seekptr += amf::AMF_NUMBER_SIZE;
+       std::copy(ptr, ptr + amf::AMF0_NUMBER_SIZE, _seekptr);    
+       _seekptr += amf::AMF0_NUMBER_SIZE;
        return _seekptr;
     }
     return 0;
@@ -223,7 +224,7 @@
 }
 
 Network::byte_t *
-Buffer::append(amf::Element::amf_type_e type)
+Buffer::append(amf::Element::amf0_type_e type)
 {
     return append(static_cast<Network::byte_t>(type));
 }

Index: libamf/buffer.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/buffer.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- libamf/buffer.h     12 Apr 2008 03:59:32 -0000      1.5
+++ libamf/buffer.h     30 Apr 2008 03:35:30 -0000      1.6
@@ -65,7 +65,7 @@
     gnash::Network::byte_t *append(boost::uint32_t val);
     gnash::Network::byte_t *append(bool);
     gnash::Network::byte_t *append(double num);
-    gnash::Network::byte_t *append(Element::amf_type_e type);
+    gnash::Network::byte_t *append(Element::amf0_type_e type);
     gnash::Network::byte_t *append(boost::uint16_t length);
     gnash::Network::byte_t *append(gnash::Network::byte_t *data, size_t 
nbytes);
     gnash::Network::byte_t *append(gnash::Network::byte_t byte);

Index: libamf/element.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/element.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- libamf/element.cpp  14 Apr 2008 21:35:17 -0000      1.22
+++ libamf/element.cpp  30 Apr 2008 03:35:30 -0000      1.23
@@ -65,7 +65,7 @@
 Element::Element()
     : _name(),
       _buffer(0),
-      _type(Element::NOTYPE)
+      _type(NOTYPE)
 {
 //    GNASH_REPORT_FUNCTION;
 }
@@ -77,8 +77,8 @@
     if (_buffer) {
        delete _buffer;
     }
-    for (size_t i=0; i< _children.size(); i++) {
-       delete _children[i];
+    for (size_t i=0; i< _properties.size(); i++) {
+       delete _properties[i];
     }
     if (_name) {
        delete[] _name;
@@ -88,18 +88,18 @@
 Element::Element(Network::byte_t *indata) 
     : _name(),
       _buffer(0),
-      _type(Element::NOTYPE)
+      _type(NOTYPE)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     init(indata);
 }
 
 Element::Element(double indata)
     : _name(),
       _buffer(0),
-      _type(Element::NOTYPE)
+      _type(NOTYPE)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     init(indata);
 }
 
@@ -112,36 +112,36 @@
 Element::Element(const string &indata)
     : _name(),
       _buffer(0),
-    _type(Element::NOTYPE)
+      _type(NOTYPE)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     init(indata);
 }
 
 Element::Element(const string &name, const string &indata)
     : _name(),
       _buffer(0),
-      _type(Element::NOTYPE)
+      _type(NOTYPE)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     init(name, indata);
 }
 
 Element::Element(const string &name, bool indata)
     : _name(),
       _buffer(0),
-      _type(Element::NOTYPE)
+      _type(NOTYPE)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     init(name, indata);
 }
 
 Element::Element(bool indata)
     : _name(),
       _buffer(0),
-      _type(Element::NOTYPE)
+      _type(NOTYPE)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     init(indata);
 }
 
@@ -150,9 +150,9 @@
                 const string &methodname)
     : _name(),
       _buffer(0),
-      _type(Element::NOTYPE)
+      _type(NOTYPE)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     init(flag, unknown1, unknown2, methodname);
 }
 
@@ -160,27 +160,27 @@
 Element::init(bool flag, double unknown1, double unknown2,
              const string &methodname)
 {
-    GNASH_REPORT_FUNCTION;
-    _type = Element::FUNCTION;
+//    GNASH_REPORT_FUNCTION;
+//    _type = Element::FUNCTION_AMF0;
     if (methodname.size()) {
        setName(methodname);
     }
 
-    // Build up the children for the function block
+    // Build up the properties for the function block
     Element *el = new Element(flag);
-    _children.push_back(el);
+    _properties.push_back(el);
     
     el = new Element(unknown1);
-    _children.push_back(el);
+    _properties.push_back(el);
     
     el = new Element(unknown2);
-    _children.push_back(el);
+    _properties.push_back(el);
     
     el = new Element(methodname);
-    _children.push_back(el);
+    _properties.push_back(el);
     
     _buffer = new Buffer(3
-       + ((AMF_HEADER_SIZE + AMF_NUMBER_SIZE) * 2)
+       + ((AMF_HEADER_SIZE + AMF0_NUMBER_SIZE) * 2)
               + methodname.size() + AMF_HEADER_SIZE);
 //     memcpy(_data, &indata, _length);
     return *this;
@@ -197,14 +197,14 @@
 Element::init(const string &name, double num)
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::NUMBER;
+    _type = Element::NUMBER_AMF0;
     if (name.size()) {
         setName(name);
     }
     if (_buffer == 0) {
-       _buffer = new Buffer(AMF_NUMBER_SIZE);
+       _buffer = new Buffer(AMF0_NUMBER_SIZE);
     } else {
-       _buffer->resize(AMF_NUMBER_SIZE);
+       _buffer->resize(AMF0_NUMBER_SIZE);
     }
     _buffer->copy(num);
     
@@ -221,8 +221,8 @@
 Element &
 Element::init(const string &name, const string &str)
 {
-    GNASH_REPORT_FUNCTION;
-    _type = Element::STRING;
+//    GNASH_REPORT_FUNCTION;
+    _type = Element::STRING_AMF0;
     if (name.size()) {
         setName(name);
     }
@@ -247,7 +247,7 @@
 Element::init(const string &name, bool flag)
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::BOOLEAN;
+    _type = Element::BOOLEAN_AMF0;
     if (name.size()) {
         setName(name);
     }
@@ -374,7 +374,7 @@
     }
 
     // FIXME: make this test more exhaustive
-    if (_children.size() == el->childrenSize()) {
+    if (_properties.size() == el->propertySize()) {
        count++;
     }
 
@@ -397,14 +397,14 @@
 Buffer *
 Element::encode()
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     Buffer *buf = 0;
-    if (_type == Element::OBJECT) {
+    if (_type == Element::OBJECT_AMF0) {
        // FIXME: we probably want a better size, to avoid the other
        // appends from having to resize and copy the data all the time.
        buf = new Buffer(128);
        buf->clear();           // FIXME: temporary, makes buffers cleaner in 
gdb.
-       buf->append(Element::OBJECT);
+       buf->append(Element::OBJECT_AMF0);
 //     string name = _name;
        if (_name > 0) {
 //         Buffer *top = AMF::encodeElement(this);
@@ -416,8 +416,8 @@
            buf->append(enclength);
        }
 
-       for (size_t i=0; i<_children.size(); i++) {
-           Buffer *partial = AMF::encodeElement(_children[i]);
+       for (size_t i=0; i<_properties.size(); i++) {
+           Buffer *partial = AMF::encodeElement(_properties[i]);
 //         log_debug("Encoded partial size is %d", partial->size());
            if (partial) {
                buf->append(partial);
@@ -437,11 +437,11 @@
 }
 
 Element *
-Element::operator[](int index)
+Element::operator[](size_t index)
 {
-    GNASH_REPORT_FUNCTION;
-    if (index <= _children.size()) {
-       return _children[index];
+//    GNASH_REPORT_FUNCTION;
+    if (index <= _properties.size()) {
+       return _properties[index];
     }
     
     return 0;
@@ -479,7 +479,7 @@
 Element::makeString(Network::byte_t *data, size_t size)
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::STRING;
+    _type = Element::STRING_AMF0;
     // Make room for an additional NULL terminator
     check_buffer(size+1);
     _buffer->copy(data, size);
@@ -499,7 +499,7 @@
 Element::makeNullString()
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::STRING;
+    _type = Element::STRING_AMF0;
     check_buffer(sizeof(Network::byte_t));
     *(_buffer->reference()) = 0;
     return *this;
@@ -509,7 +509,7 @@
 Element::makeString(const char *str, size_t size)
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::STRING;
+    _type = Element::STRING_AMF0;
     Network::byte_t *ptr = reinterpret_cast<Network::byte_t *>(const_cast<char 
*>(str));
     return makeString(ptr, size);
 }
@@ -536,8 +536,8 @@
 {
 //    GNASH_REPORT_FUNCTION;
     double num = *reinterpret_cast<const double*>(data);
-    _type = Element::NUMBER;
-    check_buffer(AMF_NUMBER_SIZE);
+    _type = Element::NUMBER_AMF0;
+    check_buffer(AMF0_NUMBER_SIZE);
     _buffer->copy(num);
     
     return *this;
@@ -547,8 +547,8 @@
 Element::makeNumber(double num)
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::NUMBER;
-    check_buffer(AMF_NUMBER_SIZE);
+    _type = Element::NUMBER_AMF0;
+    check_buffer(AMF0_NUMBER_SIZE);
     _buffer->copy(num);
 
     return *this;
@@ -568,7 +568,7 @@
 Element::makeBoolean(bool flag)
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::BOOLEAN;
+    _type = Element::BOOLEAN_AMF0;
     check_buffer(sizeof(bool));
     _buffer->append(flag);
     return *this;
@@ -597,7 +597,7 @@
 Element::makeUndefined()
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::UNDEFINED;
+    _type = Element::UNDEFINED_AMF0;
     return *this;
 }
 
@@ -615,7 +615,7 @@
 Element::makeNull()
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::NULL_VALUE;
+    _type = Element::NULL_AMF0;
     check_buffer(sizeof(Network::byte_t));
     *(_buffer->reference()) = 0;
     return *this;
@@ -635,7 +635,7 @@
 Element::makeObject()
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = OBJECT;
+    _type = OBJECT_AMF0;
     return *this;
 }
 
@@ -646,7 +646,7 @@
     if (name.size()) {
         setName(name);
     }
-    _type = OBJECT;
+    _type = OBJECT_AMF0;
     return *this;
 }
 
@@ -654,7 +654,7 @@
 Element::makeObject(Network::byte_t *indata, size_t size)
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::OBJECT;
+    _type = Element::OBJECT_AMF0;
     check_buffer(size);
     _buffer->copy(indata, size);
     return *this;
@@ -664,7 +664,7 @@
 Element::makeObjectEnd()
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::OBJECT_END;
+    _type = Element::OBJECT_END_AMF0;
     return *this;
 }
 
@@ -672,7 +672,7 @@
 Element::makeXMLObject(const std::string &name)
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::XML_OBJECT;    
+    _type = Element::XML_OBJECT_AMF0;
     if (name.size()) {
         setName(name);
     }
@@ -683,7 +683,7 @@
 Element::makeXMLObject(Network::byte_t *indata, size_t size)
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::XML_OBJECT;
+    _type = Element::XML_OBJECT_AMF0;
     check_buffer(size);
     _buffer->copy(indata, size);
     
@@ -694,7 +694,7 @@
 Element::makeTypedObject(const std::string &name)
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::TYPED_OBJECT;    
+    _type = Element::TYPED_OBJECT_AMF0;  
     if (name.size()) {
         setName(name);
     }
@@ -705,7 +705,7 @@
 Element::makeTypedObject(Network::byte_t *indata, size_t size)
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::TYPED_OBJECT;
+    _type = Element::TYPED_OBJECT_AMF0;
     check_buffer(size);
     _buffer->copy(indata, size);
     return *this;
@@ -715,7 +715,7 @@
 Element::makeReference()
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::REFERENCE;
+    _type = Element::REFERENCE_AMF0;
     return *this;
 }
 
@@ -723,7 +723,7 @@
 Element::makeReference(Network::byte_t *indata, size_t size)
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::REFERENCE;
+    _type = Element::REFERENCE_AMF0;
     check_buffer(size);
     _buffer->copy(indata, size);
     return *this;
@@ -733,15 +733,15 @@
 Element::makeMovieClip()
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::MOVIECLIP;
+    _type = Element::MOVIECLIP_AMF0;
     return *this;
 }
 
 Element &
 Element::makeMovieClip(Network::byte_t *indata, size_t size)
 {
-    GNASH_REPORT_FUNCTION;
-    _type = Element::MOVIECLIP;
+//    GNASH_REPORT_FUNCTION;
+    _type = Element::MOVIECLIP_AMF0;
     check_buffer(size);
     _buffer->copy(indata, size);
     return *this;    
@@ -751,7 +751,7 @@
 Element::makeECMAArray()
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::ECMA_ARRAY;
+    _type = Element::ECMA_ARRAY_AMF0;
     return *this;
 }
 
@@ -759,7 +759,7 @@
 Element::makeECMAArray(Network::byte_t *indata, size_t size)
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::ECMA_ARRAY;
+    _type = Element::ECMA_ARRAY_AMF0;
     check_buffer(size);
     _buffer->copy(indata, size);
     return *this;    
@@ -769,7 +769,7 @@
 Element::makeUnsupported()
 {
 //    GNASH_REPORT_FUNCTION;    
-    _type = Element::UNSUPPORTED;
+    _type = Element::UNSUPPORTED_AMF0;
     return *this;
 }
 
@@ -777,7 +777,7 @@
 Element::makeUnsupported(Network::byte_t *indata, size_t size)
 {
 //    GNASH_REPORT_FUNCTION;    
-    _type = Element::UNSUPPORTED;
+    _type = Element::UNSUPPORTED_AMF0;
     check_buffer(size);
     _buffer->copy(indata, size);
     return *this;
@@ -787,7 +787,7 @@
 Element::makeLongString()
 {
 //    GNASH_REPORT_FUNCTION;    
-    _type = Element::LONG_STRING;
+    _type = Element::LONG_STRING_AMF0;
     return *this;
 }
 
@@ -795,7 +795,7 @@
 Element::makeLongString(Network::byte_t *indata, size_t size)
 {
 //    GNASH_REPORT_FUNCTION;    
-    _type = Element::LONG_STRING;
+    _type = Element::LONG_STRING_AMF0;
     check_buffer(size);
     _buffer->copy(indata, size);
     return *this;
@@ -805,7 +805,7 @@
 Element::makeRecordSet()
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::RECORD_SET;
+    _type = Element::RECORD_SET_AMF0;
     return *this;
 }
 
@@ -813,7 +813,7 @@
 Element::makeDate(Network::byte_t *date)
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::DATE;
+    _type = Element::DATE_AMF0;
     size_t size = sizeof(long);
     check_buffer(size);
     _buffer->copy(date, sizeof(long));
@@ -824,7 +824,7 @@
 Element::makeStrictArray()
 {
 //    GNASH_REPORT_FUNCTION;
-    _type = Element::STRICT_ARRAY;
+    _type = Element::STRICT_ARRAY_AMF0;
     return *this;
 }
 
@@ -832,7 +832,7 @@
 Element::makeStrictArray(Network::byte_t *indata, size_t size)
 {
 //    GNASH_REPORT_FUNCTION;    
-    _type = Element::STRICT_ARRAY;
+    _type = Element::STRICT_ARRAY_AMF0;
     check_buffer(size);
     _buffer->copy(indata, size);
     return *this;
@@ -898,15 +898,13 @@
     cerr << astype_str[_type] << ": ";
 
     switch (_type) {
-      case Element::NOTYPE:
-         break;
-      case Element::NUMBER:
+      case Element::NUMBER_AMF0:
          cerr << to_number() << endl;
          break;
-      case Element::BOOLEAN:
+      case Element::BOOLEAN_AMF0:
          cerr << (to_bool() ? "true" : "false") << endl;
          break;
-      case Element::STRING:
+      case Element::STRING_AMF0:
          cerr << "(" << getLength() << " bytes): ";
          if (getLength() > 0) {
              cerr << "\t\"" << to_string() << "\"" << endl;
@@ -914,31 +912,31 @@
              cerr << endl;
          }
          break;
-      case Element::OBJECT:
+      case Element::OBJECT_AMF0:
          break;
-      case Element::MOVIECLIP:
-      case Element::NULL_VALUE: 
-      case Element::UNDEFINED:
-      case Element::REFERENCE:
-      case Element::ECMA_ARRAY:
-      case Element::OBJECT_END:
-      case Element::STRICT_ARRAY:
-      case Element::DATE:
-      case Element::LONG_STRING:
-      case Element::UNSUPPORTED:
-      case Element::RECORD_SET:
-      case Element::XML_OBJECT:
-      case Element::TYPED_OBJECT:
+      case Element::MOVIECLIP_AMF0:
+      case Element::NULL_AMF0: 
+      case Element::UNDEFINED_AMF0:
+      case Element::REFERENCE_AMF0:
+      case Element::ECMA_ARRAY_AMF0:
+      case Element::OBJECT_END_AMF0:
+      case Element::STRICT_ARRAY_AMF0:
+      case Element::DATE_AMF0:
+      case Element::LONG_STRING_AMF0:
+      case Element::UNSUPPORTED_AMF0:
+      case Element::RECORD_SET_AMF0:
+      case Element::XML_OBJECT_AMF0:
+      case Element::TYPED_OBJECT_AMF0:
 //       cerr << "AMF data is: 0x" << hexify(_data, _length, false) << endl;
          log_debug("FIXME: got a typed object!");
          break;
-      case Element::VARIABLE:
-      case Element::FUNCTION:
-         cerr << "# of children in object: " << _children.size() << endl;
-         for (size_t i=0; i< _children.size(); i++) {
-             _children[i]->dump();
-         }
-         break;
+//       case Element::VARIABLE:
+//       case Element::FUNCTION:
+//       cerr << "# of properties in object: " << properties.size() << endl;
+//       for (size_t i=0; i< properties.size(); i++) {
+//           properties[i]->dump();
+//       }
+//       break;
       default:
 //       log_unimpl("%s: type %d", __PRETTY_FUNCTION__, (int)_type);
          break;

Index: libamf/element.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/element.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- libamf/element.h    14 Apr 2008 21:35:17 -0000      1.19
+++ libamf/element.h    30 Apr 2008 03:35:31 -0000      1.20
@@ -34,30 +34,49 @@
 
 class DSOEXPORT Element {
 public:
-    // The following elements are defined within AMF:
+    // The following elements are defined within AMF0, and are used
+    // up through SWF version 8.
     typedef enum {
        NOTYPE=-1,
-        NUMBER=0x00,
-        BOOLEAN=0x01,
-        STRING=0x02,
-        OBJECT=0x03,
-        MOVIECLIP=0x04,
-        NULL_VALUE=0x05,
-        UNDEFINED=0x06,
-        REFERENCE=0x07,
-        ECMA_ARRAY=0x08,
-        OBJECT_END=0x09,
-        STRICT_ARRAY=0x0a,
-        DATE=0x0b,
-        LONG_STRING=0x0c,
-        UNSUPPORTED=0x0d,
-        RECORD_SET=0x0e,
-        XML_OBJECT=0x0f,
-        TYPED_OBJECT=0x10,
-       // these aren't part of the AMF spec, they're used internally
-       VARIABLE=0x11,
-       FUNCTION=0x12
-    } amf_type_e;
+        NUMBER_AMF0=0x00,
+        BOOLEAN_AMF0=0x01,
+        STRING_AMF0=0x02,
+        OBJECT_AMF0=0x03,
+        MOVIECLIP_AMF0=0x04,
+        NULL_AMF0=0x05,
+        UNDEFINED_AMF0=0x06,
+        REFERENCE_AMF0=0x07,
+        ECMA_ARRAY_AMF0=0x08,
+        OBJECT_END_AMF0=0x09,
+        STRICT_ARRAY_AMF0=0x0a,
+        DATE_AMF0=0x0b,
+        LONG_STRING_AMF0=0x0c,
+        UNSUPPORTED_AMF0=0x0d,
+        RECORD_SET_AMF0=0x0e,
+        XML_OBJECT_AMF0=0x0f,
+        TYPED_OBJECT_AMF0=0x10,
+//     // these aren't part of the AMF spec, they're used internally
+//     VARIABLE=0x11,
+//     FUNCTION=0x12
+    } amf0_type_e;
+    // AMF3, was introduced with ActionScript 3 in SWF version 9
+    // to reduce duplicate, and allow for a more compact layout of
+    // data to save bandwidth and improve performance.
+    typedef enum {
+        UNDEFINED_AMF3=0x00,
+        NULL_AMF3=0x01,
+        FALSE_AMF3=0x02,
+        TRUE_AMF3=0x03,
+        INTEGER_AMF3=0x04,
+        DOUBLE_AMF3=0x05,
+        STRING_AMF3=0x06,
+        XMLDOC_AMF3=0x07,
+        DATE_AMF3=0x08,
+        ARRAY_AMF3=0x09,
+        OBJECT_AMF3=0x0a,
+        XML_AMF3=0x0b,
+        BYTES_AMF3=0x0c,
+    } amf3_type_e;
     Element();
     Element(gnash::Network::byte_t *data);
     Element(double data);
@@ -147,15 +166,15 @@
     Element &operator=(Element &);
     Element &operator=(Element *);
     
-    Element *operator[](int x);
+    Element *operator[](size_t x);
 
     gnash::Network::byte_t *getData();
     size_t getLength();
     Buffer *getBuffer() { return _buffer; };
     
     // These are all accessors for the various output formats
-    amf_type_e getType() { return _type; };
-    void setType(amf_type_e x) { _type = x; };
+    amf0_type_e getType() { return _type; };
+    void setType(amf0_type_e x) { _type = x; };
 //    void setData(Buffer *buf) { _buffer = buf; };
 
     // These accessors convert the raw data to a standard data type we can use.
@@ -170,12 +189,12 @@
     void setName(gnash::Network::byte_t *name, size_t x);
 
     // Manipulate the children Elements of an object
-    void addChild(Element &el) { _children.push_back(&el); };
-    void addChild(Element *el) { _children.push_back(el); };
-    Element *popChild() { return _children.front(); };
-    size_t childrenSize() { return _children.size(); };
-//    std::vector<Element      *> &getChildren() { return _children; };
+    Element *getProperty(size_t x) { return _properties[x]; };
 
+    void addProperty(Element &el) { _properties.push_back(&el); };
+    void addProperty(Element *el) { _properties.push_back(el); };
+    Element *popProperty()        { return _properties.front(); };
+    size_t propertySize()         { return _properties.size(); };
     amf::Buffer *encode();
     
     void dump();
@@ -183,8 +202,8 @@
     void check_buffer(size_t size);
     char               *_name;
     Buffer             *_buffer;
-    amf_type_e         _type;
-    std::vector<Element        *> _children;
+    amf0_type_e                _type;
+    std::vector<Element        *> _properties;
 };                              // end of class definition
 
 

Index: libamf/lcshm.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/lcshm.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- libamf/lcshm.cpp    11 Apr 2008 19:36:02 -0000      1.13
+++ libamf/lcshm.cpp    30 Apr 2008 03:35:31 -0000      1.14
@@ -246,7 +246,6 @@
           break;
     };
 }
-#endif
 
 vector<amf::Element *> 
 LcShm::parseBody(Network::byte_t *data)
@@ -257,6 +256,7 @@
 
     while (ptr) {
         amf::Element *el = amf.extractAMF(ptr);
+        if (el) {
         if (el->getType() == Element::NUMBER) {
             if (el->to_number() == 0.0) {
                 break;
@@ -268,10 +268,14 @@
         } else {
             break;
         }
+        } else {
+
+        }
     };
     
     return _amfobjs;
 }
+#endif
 
 // From what I can tell by exaimining the memory segment, after the
 // raw 16 bytes is a LocalConnection object. This appears to have the
@@ -310,7 +314,7 @@
 
     
     AMF amf;
-    Element *el = AMF::extractAMF(ptr);
+    Element *el = amf.extractAMF(ptr);
     if (el == 0) {
         log_debug("Didn't extract an element from the byte stream!");
         return 0;
@@ -319,7 +323,7 @@
     _object.connection_name = el->to_string();
     delete el;
     
-    el = AMF::extractAMF(ptr);
+    el = amf.extractAMF(ptr);
     if (ptr != 0) {
         _object.hostname = el->to_string();
     }

Index: libamf/sol.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/sol.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- libamf/sol.cpp      11 Apr 2008 19:36:03 -0000      1.33
+++ libamf/sol.cpp      30 Apr 2008 03:35:31 -0000      1.34
@@ -79,8 +79,6 @@
 SOL::~SOL()
 {
 //    GNASH_REPORT_FUNCTION;
-
-#if 0
     vector<amf::Element *>::iterator it;
     for (it = _amfobjs.begin(); it != _amfobjs.end(); it++) {
        amf::Element *el = (*(it));
@@ -88,7 +86,6 @@
            delete el;
        }
     }
-#endif
 }
 
 bool
@@ -240,36 +237,36 @@
 
     for (ita = _amfobjs.begin(); ita != _amfobjs.end(); ita++) {
         amf::Element *el = (*(ita));
-        Buffer *var = amf_obj.encodeVariable(el); 
-        //  Network::byte_t *var = amf_obj.encodeVariable(el, outsize); 
+        Buffer *var = amf_obj.encodeProperty(el); 
+        //  Network::byte_t *var = amf_obj.encodeProperty(el, outsize); 
         if (!var) {
             continue;
         }
         size_t outsize = 0;
         switch (el->getType()) {
-         case Element::BOOLEAN:
+         case Element::BOOLEAN_AMF0:
              outsize = el->getNameSize() + AMF_VAR_HEADER_SIZE;
              memcpy(ptr, var->reference(), outsize); 
              ptr += outsize;
              break;
-         case Element::OBJECT:
+         case Element::OBJECT_AMF0:
              outsize = el->getNameSize() + 5;
               assert(ptr+outsize < endPtr);
              outsize = el->getNameSize() + 5;
              memcpy(ptr, var->reference(), outsize);
              ptr += outsize;
-             *ptr++ = Element::OBJECT_END;
+             *ptr++ = Element::OBJECT_END_AMF0;
              *ptr++ = 0;       // objects are terminated too!
              break;
-         case Element::NUMBER:
-             outsize = el->getNameSize() + AMF_NUMBER_SIZE + 2;
+         case Element::NUMBER_AMF0:
+             outsize = el->getNameSize() + AMF0_NUMBER_SIZE + 2;
               assert(ptr+outsize < endPtr);
              memcpy(ptr, var->reference(), outsize);
              ptr += outsize;
              *ptr++ = 0;       // doubles are terminated too!
              *ptr++ = 0;       // doubles are terminated too!
              break;
-         case Element::STRING:
+         case Element::STRING_AMF0:
              if (el->getLength() == 0) {
                  assert(ptr+outsize+1 < endPtr);
                  memcpy(ptr, var, outsize+1);
@@ -323,19 +320,19 @@
 //    GNASH_REPORT_FUNCTION;
     struct stat st;
     boost::uint16_t size;
-    Network::byte_t *buf;
-    Network::byte_t *ptr;
+    Network::byte_t *buf = 0;
+    Network::byte_t *ptr = 0;
     size_t bodysize;
 
     // Make sure it's an SOL file
     if (stat(filespec.c_str(), &st) == 0) {
         ifstream ifs(filespec.c_str(), ios::binary);
         _filesize = st.st_size;
+       buf = new Network::byte_t[_filesize + sizeof(int)];
+       ptr = buf;
        bodysize = st.st_size - 6;
         _filespec = filespec;
-       buf = new Network::byte_t[_filesize+1];
-       ptr = buf;
-        ifs.read(reinterpret_cast<char *>(buf), _filesize);
+        ifs.read(reinterpret_cast<char *>(ptr), _filesize);
 
         // skip the magic number (will check later)
         ptr += 2;
@@ -373,8 +370,10 @@
 
         AMF amf_obj;
        int size = 0;
-        while (size <= static_cast<boost::uint16_t>(bodysize)) {
-           amf::Element *el =  amf_obj.extractVariable(ptr);
+       amf::Element *el;
+        while (size < static_cast<boost::uint16_t>(bodysize) - 24) {
+           if (ptr) {
+               el = amf_obj.extractProperty(ptr);
             if (el != 0) {
                size += amf_obj.totalsize();
                ptr += amf_obj.totalsize();
@@ -382,7 +381,12 @@
            } else {
                break;
            }
+//             log_debug("Bodysize is: %d size is: %d for %s", bodysize, size, 
el->getName());
+           } else {
+               break;
+           }
         }
+       delete[] buf;
         
         ifs.close();
         return true;
@@ -404,20 +408,20 @@
     for (it = _amfobjs.begin(); it != _amfobjs.end(); it++) {
        amf::Element *el = (*(it));
         cerr << el->getName() << ": ";
-        if (el->getType() == Element::STRING) {
+        if (el->getType() == Element::STRING_AMF0) {
             if (el->getLength() != 0) {
                 cerr << el->getData();
             } else {
                 cerr << "null";
             }
         }
-        if (el->getType() == Element::NUMBER) {
+        if (el->getType() == Element::NUMBER_AMF0) {
             double ddd = *((double *)el->getData());
              cerr << ddd << " ";
 
             cerr << "( " << hexify(el->getData(), 8, false) << ")";
         }
-        if ((*(it))->getType() == Element::BOOLEAN) {
+        if ((*(it))->getType() == Element::BOOLEAN_AMF0) {
             if (el[0] == true) {
                 cerr << "true";
             }
@@ -425,7 +429,7 @@
                 cerr << "false";
             }
         }
-        if (el->getType() == Element::OBJECT) {
+        if (el->getType() == Element::OBJECT_AMF0) {
             cerr << "is an object";
         }
         cerr << endl;

Index: libamf/sol.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/sol.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- libamf/sol.h        30 Mar 2008 22:08:54 -0000      1.12
+++ libamf/sol.h        30 Apr 2008 03:35:31 -0000      1.13
@@ -1,5 +1,5 @@
 // 
-//   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+//   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
 // 
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by

Index: testsuite/libamf.all/.cvsignore
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libamf.all/.cvsignore,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- testsuite/libamf.all/.cvsignore     6 Apr 2008 18:11:33 -0000       1.3
+++ testsuite/libamf.all/.cvsignore     30 Apr 2008 03:35:31 -0000      1.4
@@ -11,4 +11,17 @@
 testrun.log
 testrun.sum
 gmon.out
-xmlfiles
+testsuite/libamf.all/xmlfiles/array.sol
+testsuite/libamf.all/xmlfiles/array2.sol
+testsuite/libamf.all/xmlfiles/boolean.sol
+testsuite/libamf.all/xmlfiles/date.sol
+testsuite/libamf.all/xmlfiles/null.sol
+testsuite/libamf.all/xmlfiles/object.sol
+testsuite/libamf.all/xmlfiles/object2.sol
+testsuite/libamf.all/xmlfiles/string.sol
+testsuite/libamf.all/xmlfiles/test.sol
+testsuite/libamf.all/xmlfiles/undefined.sol
+testsuite/libamf.all/xmlfiles/x.sol
+testsuite/libamf.all/xmlfiles/x.xml
+testsuite/libamf.all/xmlfiles/xml.sol
+

Index: testsuite/libamf.all/test_amf.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libamf.all/test_amf.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- testsuite/libamf.all/test_amf.cpp   14 Apr 2008 21:35:16 -0000      1.2
+++ testsuite/libamf.all/test_amf.cpp   30 Apr 2008 03:35:31 -0000      1.3
@@ -39,6 +39,7 @@
 #include "buffer.h"
 #include "network.h"
 #include "element.h"
+#include "gmemory.h"
 
 using namespace amf;
 using namespace gnash;
@@ -55,6 +56,13 @@
 // Enable the display of memory allocation and timing data
 static bool memdebug = false;
 
+// We use the Memory profiling class to check the malloc buffers
+// in the kernel to make sure the allocations and frees happen
+// the way we expect them too. There is no real other way to tell.
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+Memory *mem = 0;
+#endif
+
 TestState runtest;
 LogFile& dbglogfile = LogFile::getDefaultInstance();
 RcInitFile& rcfile = RcInitFile::getDefaultInstance();
@@ -106,11 +114,17 @@
 
 int
 main(int argc, char *argv[])
-{    const Arg_parser::Option opts[] =
+{
+    const Arg_parser::Option opts[] =
         {
             { 'h', "help",          Arg_parser::no  },
             { 'v', "verbose",       Arg_parser::no  },
             { 'w', "write",         Arg_parser::no  },
+// Unless you have support for memory debugging turned on, and
+// you have support for the Linux mallinfo() system call,
+// this option is totally useless. This doesn't really matter
+// as the memory testing is primarily used only during
+// debugging or development.
             { 'm', "memstats",      Arg_parser::no  },
             { 'd', "dump",          Arg_parser::no  },
         };
@@ -152,9 +166,33 @@
         }
     }
 
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+    if (memdebug) {
+        mem = new Memory;
+        mem->startStats();
+    }
+#endif
+    
     // run the tests
     test_encoding();
     test_object();
+
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+   if (memdebug) {
+        if (mem->analyze()) {
+            runtest.pass("AMF doesn't leak memory");
+        } else {
+            runtest.fail("AMF leaks memory!");
+        }
+    }
+#endif
+
+   // cleanup
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+    if (mem) {
+        delete mem;
+    }
+#endif
 }
 
 void
@@ -164,11 +202,22 @@
     const char *x = "40 83 38 00 00 00 00 00";
     Buffer *buf1 = hex2mem(x);
     double num = *(double *)buf1->reference();
-    swapBytes(&num, amf::AMF_NUMBER_SIZE); // we alwasy encode in big endian 
format
+    swapBytes(&num, amf::AMF0_NUMBER_SIZE); // we alwasy encode in big endian 
format
+
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+    if (memdebug) {
+        mem->addStats(__LINE__);             // take a sample
+    }
+#endif    
     Buffer *encnum = AMF::encodeNumber(num);
     // A number AMF object has only one header byte, which is the type field.
-    if ((*encnum->reference() == Element::NUMBER) &&
-        (memcmp(buf1->reference(), encnum->reference()+1, 
amf::AMF_NUMBER_SIZE) == 0)) {
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+    if (memdebug) {
+        mem->addStats(__LINE__);             // take a sample
+    }
+#endif
+    if ((*encnum->reference() == Element::NUMBER_AMF0) &&
+        (memcmp(buf1->reference(), encnum->reference()+1, 
amf::AMF0_NUMBER_SIZE) == 0)) {
         runtest.pass("Encoded AMF Number");
     } else {
         runtest.fail("Encoded AMF Number");
@@ -183,12 +232,25 @@
     Buffer *buf2 = hex2mem(x2);
     boost::uint16_t sht = *(boost::uint16_t *)buf2->reference();
     swapBytes(&sht, sizeof(boost::uint16_t)); // we always encode in big 
endian format
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+    if (memdebug) {
+        mem->addStats(__LINE__);             // take a sample
+    }
+#endif
     Buffer *encbool = AMF::encodeBoolean(flag);
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+    if (memdebug) {
+        mem->addStats(__LINE__);             // take a sample
+    }
+#endif
+    
     // A boolean AMF object has only one header byte, which is the type field.
     // The data is always encoded as a two byte value, even though *we* know a 
bool is just
     // one. Obviously AMF goes back to the days of 16 bit ints, and bool was 
the same size.
     // Ya gotta love old K&R C code for binary formats.
-    if ((*encbool->reference() == Element::BOOLEAN) &&
+    // AMF changes this to being two different type, FALSE & TRUE
+    // which are finally only one byte apiece.
+    if ((*encbool->reference() == Element::BOOLEAN_AMF0) &&
         (encbool->size() == 3) &&
         (memcmp(buf2->reference(), encbool->reference()+1, 
sizeof(boost::uint16_t)) == 0)) {
         runtest.pass("Encoded AMF Boolean");
@@ -200,9 +262,20 @@
     
     // Encode a String.
     string str = "Jerry Garcia rules";
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+    if (memdebug) {
+        mem->addStats(__LINE__);             // take a sample
+    }
+#endif
     Buffer *encstr = AMF::encodeString(str);
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+    if (memdebug) {
+        mem->addStats(__LINE__);             // take a sample
+    }
+#endif
+    
     // A String AMF object has a 3 bytes head, the type, and a two byte length.
-    if ((*encstr->reference() == Element::STRING) &&
+    if ((*encstr->reference() == Element::STRING_AMF0) &&
         (encstr->size() == str.size() + AMF_HEADER_SIZE) &&
         (memcmp(encstr->reference() + 3, str.c_str(), str.size()) == 0)) {
         runtest.pass("Encoded AMF String");
@@ -212,10 +285,20 @@
     delete encstr;
     
     // Encode a NULL String.
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+    if (memdebug) {
+        mem->addStats(__LINE__);             // take a sample
+    }
+#endif
     Buffer *encnull = AMF::encodeNullString();
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+    if (memdebug) {
+        mem->addStats(__LINE__);             // take a sample
+    }
+#endif
     boost::uint16_t len = *(boost::uint16_t *)(encnull->reference() + 1);
     // A NULL String AMF object has just 3 bytes, the type, and a two byte 
length, which is zero.
-    if ((*encnull->reference() == Element::STRING) &&
+    if ((*encnull->reference() == Element::STRING_AMF0) &&
         (encnull->size() == AMF_HEADER_SIZE) && 
         (len == 0)) {
         runtest.pass("Encoded AMF NULL String");
@@ -223,7 +306,21 @@
         runtest.fail("Encoded AMF NULL String");
     }
     delete encnull;
+    
 }
+// amf::encodeDate(unsigned char*)
+// amf::AMF::encodeLongString(unsigned char*, int)
+// amf::AMF::encodeStrictArray(unsigned char*, int)
+// amf::AMF::encodeTypedObject(unsigned char*, int)
+// amf::AMF::encodeUnsupported()
+// amf::AMF::encodeNull()
+// amf::AMF::encodeElement(amf::Element*)
+// amf::AMF::encodeECMAArray(unsigned char*, int)
+// amf::AMF::encodeMovieClip(unsigned char*, int)
+// amf::AMF::encodeRecordSet(unsigned char*, int)
+// amf::AMF::encodeReference(unsigned char*, int)
+// amf::AMF::encodeUndefined()
+// amf::AMF::encodeXMLObject(unsigned char*, int)
 
 void
 test_object()
@@ -231,27 +328,36 @@
     Element top;
     top.makeObject();
 
-    Element *child1 = new Element;
-    child1->makeString("app", "oflaDemo");
-    top.addChild(child1);
-    
-    Element *child2 = new Element;
-    child2->makeString("flashVer", "LNX 9,0,31,0");
-    top.addChild(child2);
-
-    Element *child3 = new Element;
-    child3->makeString("swfUrl", 
"http://www.red5.nl/tools/publisher/publisher.swf";);
-    top.addChild(child3);
+    Element *prop1 = new Element;
+    prop1->makeString("app", "oflaDemo");
+    top.addProperty(prop1);
+    
+    Element *prop2 = new Element;
+    prop2->makeString("flashVer", "LNX 9,0,31,0");
+    top.addProperty(prop2);
+
+    Element *prop3 = new Element;
+    prop3->makeString("swfUrl", 
"http://www.red5.nl/tools/publisher/publisher.swf";);
+    top.addProperty(prop3);
 
-    if (top.childrenSize() == 3) {
-        runtest.pass("Adding children");
+    if (top.propertySize() == 3) {
+        runtest.pass("Adding property");
     } else {
-        runtest.fail("Adding children");
+        runtest.fail("Adding property");
     }
 
     // Encode an object
-//    string str = "appl";
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+    if (memdebug) {
+        mem->addStats(__LINE__);             // take a sample
+    }
+#endif
     Buffer *encobj = top.encode();
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+    if (memdebug) {
+        mem->addStats(__LINE__);             // take a sample
+    }
+#endif
     if (encobj == 0) {
         runtest.unresolved("Encoded Object");
         return;
@@ -259,32 +365,48 @@
 
     const char *x = "03 00 03 61 70 70 02 00 08 6f 66 6c 61 44 65 6d 6f 00 08 
66 6c 61 73 68 56 65 72 02 00 0c 4c 4e 58 20 39 2c 30 2c 33 31 2c 30 00 06 73 
77 66 55 72 6c 02 00 30 68 74 74 70 3a 2f 2f 77 77 77 2e 72 65 64 35 2e 6e 6c 
2f 74 6f 6f 6c 73 2f 70 75 62 6c 69 73 68 65 72 2f 70 75 62 6c 69 73 68 65 72 
2e 73 77 66 09";
     Buffer *buf1 = hex2mem(x);
-    if ((*encobj->reference() == Element::OBJECT) &&
+    if ((*encobj->reference() == Element::OBJECT_AMF0) &&
         (memcmp(buf1->reference(), encobj->reference(), 102) == 0)) {
         runtest.pass("Encoded Object");
     } else {
         runtest.fail("Encoded Object");
     }
+
+    AMF amf_obj;
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+    if (memdebug) {
+        mem->addStats(__LINE__);             // take a sample
+    }
+#endif
+    Element *newtop = amf_obj.extractAMF(buf1);
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+    if (memdebug) {
+        mem->addStats(__LINE__);             // take a sample
+    }
+#endif
+    
+    // FIXME: this test is a bit overly simple. We can tell from
+    // the debugging messages plus this has been examined with GDB,
+    // but this should have a more accurate test to make sure all
+    // the child elements are correct all the time.
+    if ((newtop->getType() == Element::OBJECT_AMF0)
+        && (newtop->propertySize() == 3)) {
+        runtest.pass("Extracted Object");
+    } else {
+        runtest.fail("Extracted Object");
+    }
+
+#if 0
+    newtop->getProperty(0)->dump();
+    newtop->getProperty(1)->dump();
+    newtop->getProperty(2)->dump();
+#endif
+    
+    // cleanup
+    delete newtop;
     delete buf1;
 }
 
-// amf::encodeDate(unsigned char*)
-// amf::AMF::encodeLongString(unsigned char*, int)
-// amf::AMF::encodeStrictArray(unsigned char*, int)
-// amf::AMF::encodeTypedObject(unsigned char*, int)
-// amf::AMF::encodeUnsupported()
-// amf::AMF::encodeNull()
-// amf::AMF::encodeObject(unsigned char*, int)
-// amf::AMF::encodeString(std::string const&)
-// amf::AMF::encodeElement(amf::Element*)
-// amf::AMF::encodeVariable(amf::Element*)
-// amf::AMF::encodeECMAArray(unsigned char*, int)
-// amf::AMF::encodeMovieClip(unsigned char*, int)
-// amf::AMF::encodeRecordSet(unsigned char*, int)
-// amf::AMF::encodeReference(unsigned char*, int)
-// amf::AMF::encodeUndefined()
-// amf::AMF::encodeXMLObject(unsigned char*, int)
-
 // amf::AMF::extractAMF(unsigned char*)
 // amf::AMF::extractVariable(unsigned char*)
 

Index: testsuite/libamf.all/test_buffer.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libamf.all/test_buffer.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- testsuite/libamf.all/test_buffer.cpp        13 Apr 2008 23:46:33 -0000      
1.6
+++ testsuite/libamf.all/test_buffer.cpp        30 Apr 2008 03:35:31 -0000      
1.7
@@ -22,25 +22,22 @@
 
 #ifdef HAVE_DEJAGNU_H
 
+#include <iostream>
 #include <regex.h>
 #include <cstdio>
 #include <cerrno>
-#include <iostream>
 #include <fstream>
 #include <cstring>
 #include <vector>
 #include <boost/cstdint.hpp>
 
-#ifdef HAVE_DEJAGNU_H
 #include "dejagnu.h"
-#else
-#include "check.h"
-#endif
-
 #include "log.h"
 #include "rc.h"
 #include "network.h"
+#ifdef HAVE_MALLINFO
 #include "gmemory.h"
+#endif
 #include "buffer.h"
 #include "arg_parser.h"
 
@@ -63,6 +60,13 @@
 // Enable the display of memory allocation and timing data
 static bool memdebug = false;
 
+// We use the Memory profiling class to check the malloc buffers
+// in the kernel to make sure the allocations and frees happen
+// the way we expect them too. There is no real other way to tell.
+#ifdef HAVE_MALLINFO
+Memory *mem = 0;
+#endif
+
 TestState runtest;
 LogFile& dbglogfile = LogFile::getDefaultInstance();
 RcInitFile& rcfile = RcInitFile::getDefaultInstance();
@@ -75,6 +79,11 @@
             { 'h', "help",          Arg_parser::no  },
             { 'v', "verbose",       Arg_parser::no  },
             { 'w', "write",         Arg_parser::no  },
+// Unless you have support for memory debugging turned on, and
+// you have support for the Linux mallinfo() system call,
+// this option is totally useless. This doesn't really matter
+// as the memory testing is primarily used only during
+// debugging or development.
             { 'm', "memstats",      Arg_parser::no  },
             { 'd', "dump",          Arg_parser::no  },
         };
@@ -94,16 +103,14 @@
                   exit(EXIT_SUCCESS);
               case 'v':
                     dbglogfile.setVerbosity();
-                    // This happens once per 'v' flag 
                     log_debug(_("Verbose output turned on"));
                     break;
               case 'm':
-                    // This happens once per 'v' flag 
                     log_debug(_("Enabling memory statistics"));
                     memdebug = true;
                     break;
               case 'w':
-                  rcfile.useWriteLog(true); // dbglogfile.setWriteDisk(true);
+                  rcfile.useWriteLog(true);
                   log_debug(_("Logging to disk enabled"));
                   break;
                   
@@ -116,47 +123,54 @@
         }
     }
     
-    // We use the Memory profiling class to check the malloc buffers
-    // in the kernel to make sure the allocations and frees happen
-    // the way we expect them too. There is no real other way to tell.
-    Memory *mem = 0;
+#ifdef HAVE_MALLINFO
     if (memdebug) {
         mem = new Memory;
         mem->startStats();
     }
+#endif
     
     Buffer buf;
+#ifdef HAVE_MALLINFO
     if (memdebug) {
         mem->addStats(__LINE__);             // take a sample
     }
-    
+#endif    
     if (buf.size() == gnash::NETBUFSIZE) {
          runtest.pass ("Buffer::size()");
      } else {
          runtest.fail ("Buffer::size()");
     }
 
+#ifdef HAVE_MALLINFO
     if (memdebug) {
         mem->addStats(__LINE__);             // take a sample
     }
+#endif
     buf.resize(112);
+#ifdef HAVE_MALLINFO
     if (memdebug) {
         mem->addStats(__LINE__);             // take a sample
     }
-
+#endif
     if (buf.size() == 112) {
          runtest.pass ("Buffer::resize()");
      } else {
          runtest.fail ("Buffer::resize()");
     }
+#ifdef HAVE_MALLINFO
     if (memdebug) {
         mem->addStats(__LINE__);             // take a sample
     }
-
+#endif
+// these tests are bogus unless you have both mallinfo()
+// and also have memory statistics gathering turned on.
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
     // test creating Buffers
     test_construct();
     // test destroying Buffers
     test_destruct();
+#endif
 
     test_copy();
     test_find();
@@ -166,14 +180,22 @@
 
 // amf::Buffer::resize(unsigned int)
     
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
     if (memdebug) {
-        mem->analyze();
+        if (mem->analyze()) {
+            runtest.pass("Buffer doesn't leak memory");
+        } else {
+            runtest.fail("Buffer leaks memory!");
+        }
     }
+#endif
 
     // cleanup
+#ifdef HAVE_MALLINFO
     if (mem) {
         delete mem;
     }
+#endif
 }
 
 void
@@ -232,14 +254,15 @@
     Buffer buf4;
     buf4.clear();
     buf4.copy(num);
-    memcpy(data, &num, amf::AMF_NUMBER_SIZE);
+    memcpy(data, &num, amf::AMF0_NUMBER_SIZE);
 
-    if (memcmp(data, buf4.reference(), amf::AMF_NUMBER_SIZE) == 0) {
+    if (memcmp(data, buf4.reference(), amf::AMF0_NUMBER_SIZE) == 0) {
          runtest.pass ("Buffer::copy(double)");
     } else {
          runtest.fail ("Buffer::copy(double)");
     }   
 #endif
+    delete[] data;
 }
 
 void
@@ -256,6 +279,7 @@
 
     // populate the buffer
     buf1.copy(data, 10);
+    delete[] data;
 
     // See if we can find a character
     Network::byte_t *fptr = buf1.find('c');
@@ -338,6 +362,10 @@
          runtest.fail ("Buffer::append(double)");
     }
     
+    delete[] data1;
+    delete[] data2;
+    delete[] data3;
+    
 // amf::Buffer::append(amf::Element::amf_type_e)
 // amf::Buffer::append(amf::Buffer*)
 // amf::Buffer::append(std::string const&)
@@ -401,13 +429,22 @@
     } else {
          runtest.fail ("Buffer::remove(int, int)");
     }    
+
+    delete[] data1;
+    delete[] data2;
+    delete[] data3;
 }
 
 void
 test_construct()
 {
+// these tests are bogus unless you have both mallinfo()
+// and also have memory statistics gathering turned on.
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
     bool valgrind = false;
     
+    size_t fudge = sizeof(long *)*5;
+    
     Memory mem(5);
     mem.addStats(__LINE__);             // take a sample
     Buffer buf1;
@@ -417,10 +454,9 @@
         valgrind = true;
         log_debug("Running this test case under valgrind screws up mallinfo(), 
so the results get skewed");
     }
-
     // Different systems allocate memory slightly differently, so about all we 
can do to see
     // if it worked is check to make sure it's within a tight range of 
possible values.
-    if ((buf1.size() == NETBUFSIZE) && (diff >= (NETBUFSIZE - (sizeof(long *) 
* 4)) && diff <= (NETBUFSIZE + sizeof(long *)*4))) {
+     if ((buf1.size() == NETBUFSIZE) && (diff >= (NETBUFSIZE - fudge)) && diff 
<= (NETBUFSIZE + fudge)) {
         runtest.pass ("Buffer::Buffer()");
     } else {
         if (valgrind) {
@@ -434,7 +470,7 @@
     Buffer buf2(124);
     mem.addStats(__LINE__);             // take a sample
     diff = mem.diffStats() - sizeof(long *);
-    if ((buf2.size() == 124) && (124 - (sizeof(long *) * 4)) && diff <= (124 + 
sizeof(long *)*4)) {
+    if ((buf2.size() == 124) && (124 - fudge) && diff <= (124 + fudge)) {
         runtest.pass ("Buffer::Buffer(size_t)");
     } else {
         if (valgrind) {
@@ -443,6 +479,7 @@
             runtest.fail("Buffer::Buffer(size_t)");
         }
     }
+#endif
 }
 
 // make sure when we delete a Buffer, *all* the allocated
@@ -452,6 +489,9 @@
 void
 test_destruct()
 {
+// these tests are bogus unless you have both mallinfo()
+// and also have memory statistics gathering turned on.
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
     Memory mem(5);
     mem.addStats(__LINE__);             // take a sample
     Buffer *buf1, *buf2;
@@ -475,7 +515,7 @@
     } else {
         runtest.fail ("Buffer::~Buffer(size_t)");
     }
-    
+#endif
 }
 
 void
@@ -514,16 +554,17 @@
 
     Buffer *buf3, *buf4;
     buf3 = new Buffer;
-    buf4 = new Buffer;
     boost::uint8_t *ptr2 = buf3->reference();
     for (size_t i=1; i< buf3->size(); i++) {
         ptr2[i] = i + 'a';
     }
+    buf4 = new Buffer;
     if (buf3 == buf4) {
          runtest.fail ("Buffer::operator==(Buffer *)");
      } else {
          runtest.pass ("Buffer::operator==(Buffer *)");
     }
+    delete buf4;
 
     // This makes the new buffer be identical to the
     // the source buffer, including copying all the data.
@@ -533,6 +574,7 @@
     } else {
          runtest.fail ("Buffer::operator=(Buffer *)");
     }
+    delete buf3;
 
     Buffer buf5(10);
     buf5.clear();

Index: testsuite/libamf.all/test_el.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libamf.all/test_el.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- testsuite/libamf.all/test_el.cpp    13 Apr 2008 23:46:33 -0000      1.8
+++ testsuite/libamf.all/test_el.cpp    30 Apr 2008 03:35:31 -0000      1.9
@@ -51,7 +51,7 @@
 static void test_destruct();
 static void test_make();
 static void test_operators();
-static void test_children();
+static void test_properties();
 
 // Enable the display of memory allocation and timing data
 static bool memdebug = false;
@@ -113,27 +113,27 @@
     test_make();
     test_operators();
     test_destruct();
-    test_children();
+    test_properties();
 }
 
 void
-test_children()
+test_properties()
 {
     Element top;
     top.makeObject("app");
 
-    Element *child1 = new Element;
-    child1->makeString("child one");
-    top.addChild(child1);
-    
-    Element *child2 = new Element;
-    child2->makeString("child two");
-    top.addChild(child2);
+    Element *prop1 = new Element;
+    prop1->makeString("property one");
+    top.addProperty(prop1);
+    
+    Element *prop2 = new Element;
+    prop2->makeString("property two");
+    top.addProperty(prop2);
 
-    if (top.childrenSize() == 2) {
-        runtest.pass("Adding children");
+    if (top.propertySize() == 2) {
+        runtest.pass("Adding property");
     } else {
-        runtest.fail("Adding children");
+        runtest.fail("Adding property");
     }
     
 //    top.dump();
@@ -145,17 +145,17 @@
     // First test the init method, which is all the constructor does anyway.. 
First
     // we test just making regular elements instead of named elements, ie...
     // AMF "variables".
-    Element el1;
-    if (el1.getType() == Element::NOTYPE) {
-        runtest.pass("Created empty element");
-    } else {
-        runtest.fail("Created empty element");
-    }
+//     Element el1;
+//     if (el1.getType() == Element::NOTYPE) {
+//         runtest.pass("Created empty element");
+//     } else {
+//         runtest.fail("Created empty element");
+//     }
 
     Element el2;
     double dub = 54.3;
     el2.init(dub);
-    if ((el2.getType() == Element::NUMBER) &&
+    if ((el2.getType() == Element::NUMBER_AMF0) &&
         (el2.to_number() == dub)) {
         runtest.pass("Initialized as double element");
     } else {
@@ -165,7 +165,7 @@
     Element el3;
     bool flag = true;
     el3.init(flag);
-    if ((el3.getType() == Element::BOOLEAN) &&
+    if ((el3.getType() == Element::BOOLEAN_AMF0) &&
         (el3.to_bool() == true)) {
         runtest.pass("Initialized as bool element");
     } else {
@@ -175,7 +175,7 @@
     Element el4;
     string str = "Hello World";
     el4.init(str);
-    if ((el4.getType() == Element::STRING) &&
+    if ((el4.getType() == Element::STRING_AMF0) &&
         (el4.getLength() == str.size())) {
         runtest.pass("Initialized as string element");
     } else {
@@ -186,7 +186,7 @@
     Element el5;
     dub = 2.456;
     el5.init("test1", dub);
-    if ((el5.getType() == Element::NUMBER) &&
+    if ((el5.getType() == Element::NUMBER_AMF0) &&
         (strcmp(el5.getName(), "test1") == 0) &&
         (el5.to_number() == dub)) {
         runtest.pass("Initialized as double element with name");
@@ -197,7 +197,7 @@
     Element el6;
     flag = true;
     el6.init("test2", flag);
-    if ((el6.getType() == Element::BOOLEAN) &&
+    if ((el6.getType() == Element::BOOLEAN_AMF0) &&
         (strcmp(el6.getName(), "test2") == 0) &&
         (el6.to_bool() == true)) {
         runtest.pass("Initialized as bool element with name");
@@ -208,7 +208,7 @@
     Element el7;
     str = "Hello World";
     el7.init("test3", str);
-    if ((el7.getType() == Element::STRING) &&
+    if ((el7.getType() == Element::STRING_AMF0) &&
         (strcmp(el7.getName(), "test3") == 0) &&
         (el7.getLength() == str.size())) {
         runtest.pass("Initialized as string element with name");
@@ -219,7 +219,7 @@
     // Now test the actual constructor
     dub = 23.45;
     Element elnum1(dub);
-    if ((elnum1.getType() == Element::NUMBER) &&
+    if ((elnum1.getType() == Element::NUMBER_AMF0) &&
         (elnum1.to_number() == dub)) {
         runtest.pass("Constructed as double element");
     } else {
@@ -228,7 +228,7 @@
 
     flag = true;
     Element elbool1(flag);
-    if ((elbool1.getType() == Element::BOOLEAN) &&
+    if ((elbool1.getType() == Element::BOOLEAN_AMF0) &&
         (elbool1.to_bool() == true)) {
         runtest.pass("Constructed as bool element");
     } else {
@@ -237,7 +237,7 @@
 
     str = "Guten Tag";
     Element elstr1(str);
-    if ((elstr1.getType() == Element::STRING) &&
+    if ((elstr1.getType() == Element::STRING_AMF0) &&
         (elstr1.getLength() == str.size())) {
         runtest.pass("Constructed as string element");
     } else {
@@ -246,7 +246,7 @@
     // And now test constrcutors with variable names
     dub = 23.45;
     Element elnum2(dub);
-    if ((elnum2.getType() == Element::NUMBER) &&
+    if ((elnum2.getType() == Element::NUMBER_AMF0) &&
         (elnum2.to_number() == dub)) {
         runtest.pass("Constructed as double element with name");
     } else {
@@ -255,7 +255,7 @@
 
     flag = true;
     Element elbool2(flag);
-    if ((elbool2.getType() == Element::BOOLEAN) &&
+    if ((elbool2.getType() == Element::BOOLEAN_AMF0) &&
         (elbool2.to_bool() == true)) {
         runtest.pass("Constructed as bool element with name");
     } else {
@@ -264,7 +264,7 @@
 
     str = "Aloha";
     Element elstr2(str);
-    if ((elstr2.getType() == Element::STRING) &&
+    if ((elstr2.getType() == Element::STRING_AMF0) &&
         (elstr2.getLength() == str.size())) {
         runtest.pass("Constructed as string element with name");
     } else {
@@ -283,7 +283,7 @@
     Element el1;
     string str = "Hello World!";
     el1.makeString("Hello World!");
-    if ((el1.getType() == Element::STRING) &&
+    if ((el1.getType() == Element::STRING_AMF0) &&
         (el1.to_string() == str)) {
         runtest.pass("Made string element");
     } else {
@@ -293,7 +293,7 @@
     Element el2;
     bool sheet = true;
     el2.makeBoolean(sheet);
-    if ((el2.getType() == Element::BOOLEAN) &&
+    if ((el2.getType() == Element::BOOLEAN_AMF0) &&
         (el2.to_bool() == sheet)) {
         runtest.pass("Made bool element");
     } else {
@@ -303,7 +303,7 @@
     Element el3;
     el3.clear();
     el3.makeNull();
-    if (el3.getType() == Element::NULL_VALUE) {
+    if (el3.getType() == Element::NULL_AMF0) {
         runtest.pass("Made NULL Value element");
     } else {
         runtest.fail("Made NULL Value element");
@@ -311,7 +311,7 @@
 
     Element el4;
     el4.makeUndefined();
-    if (el4.getType() == Element::UNDEFINED) {
+    if (el4.getType() == Element::UNDEFINED_AMF0) {
         runtest.pass("Made Undefined element");
     } else {
         runtest.fail("Made Undefined element");
@@ -320,7 +320,7 @@
     Element el5;
     el5.clear();
     el5.makeObjectEnd();
-    if (el5.getType() == Element::OBJECT_END) {
+    if (el5.getType() == Element::OBJECT_END_AMF0) {
         runtest.pass("Made Object End element");
     } else {
         runtest.fail("Made Object End element");
@@ -329,7 +329,7 @@
     Element el6;
     el6.clear();
     el6.makeNullString();
-    if ((el6.getType() == Element::STRING) &&
+    if ((el6.getType() == Element::STRING_AMF0) &&
         (el6.getLength() == 1)) {
         runtest.pass("Made NULL String element");
     } else {
@@ -340,7 +340,7 @@
     Element el7;
     el7.clear();
     el7.makeNumber(num);
-    if ((el7.getType() == Element::NUMBER) &&
+    if ((el7.getType() == Element::NUMBER_AMF0) &&
         (el7.to_number() == num)) {
         runtest.pass("Made double element");
     } else {
@@ -350,7 +350,7 @@
     Element el8;
     el8.clear();
     el8.makeObject("app");
-    if (el8.getType() == Element::OBJECT) {
+    if (el8.getType() == Element::OBJECT_AMF0) {
         runtest.pass("Made Object element");
     } else {
         runtest.fail("Made Object element");
@@ -359,7 +359,7 @@
     Element el9;
     el9.clear();
     el9.makeTypedObject("foobar");
-    if (el9.getType() == Element::TYPED_OBJECT) {
+    if (el9.getType() == Element::TYPED_OBJECT_AMF0) {
         runtest.pass("Made Object element");
     } else {
         runtest.fail("Made Object element");
@@ -368,7 +368,7 @@
     Element el10;
     el10.clear();
     el10.makeECMAArray();
-    if (el10.getType() == Element::ECMA_ARRAY) {
+    if (el10.getType() == Element::ECMA_ARRAY_AMF0) {
         runtest.pass("Made ECMA Array Object element");
     } else {
         runtest.fail("Made ECMA Array Object element");
@@ -377,7 +377,7 @@
     Element el11;
     el11.clear();
     el11.makeMovieClip();
-    if (el11.getType() == Element::MOVIECLIP) {
+    if (el11.getType() == Element::MOVIECLIP_AMF0) {
         runtest.pass("Made MovieClip Object element");
     } else {
         runtest.fail("Made MovieClip Object element");
@@ -386,7 +386,7 @@
     Element el12;
     el12.clear();
     el12.makeRecordSet();
-    if (el12.getType() == Element::RECORD_SET) {
+    if (el12.getType() == Element::RECORD_SET_AMF0) {
         runtest.pass("Made MovieClip Object element");
     } else {
         runtest.fail("Made MovieClip Object element");
@@ -395,7 +395,7 @@
     Element el13;
     el13.clear();
     el13.makeReference();
-    if (el13.getType() == Element::REFERENCE) {
+    if (el13.getType() == Element::REFERENCE_AMF0) {
         runtest.pass("Made Reference Object element");
     } else {
         runtest.fail("Made Reference Object element");
@@ -404,7 +404,7 @@
     Element el14;
     el14.clear();
     el14.makeLongString();
-    if (el14.getType() == Element::LONG_STRING) {
+    if (el14.getType() == Element::LONG_STRING_AMF0) {
         runtest.pass("Made Long String Object element");
     } else {
         runtest.fail("Made Long String Object element");
@@ -413,7 +413,7 @@
     Element el15;
     el15.clear();
     el15.makeUnsupported();
-    if (el15.getType() == Element::UNSUPPORTED) {
+    if (el15.getType() == Element::UNSUPPORTED_AMF0) {
         runtest.pass("Made Unsupported Object element");
     } else {
         runtest.fail("Made Unsupported Object element");
@@ -424,8 +424,8 @@
     rel1.clear();
     rel1.makeBoolean(true);
     rel1.makeNumber(num);
-    if ((rel1.getType() == Element::NUMBER) &&
-        (rel1.getLength() == amf::AMF_NUMBER_SIZE) &&
+    if ((rel1.getType() == Element::NUMBER_AMF0) &&
+        (rel1.getLength() == amf::AMF0_NUMBER_SIZE) &&
         (rel1.to_number() == num)) {
         runtest.pass("Remade boolean as a double element");
     } else {

Index: testsuite/libamf.all/test_lc.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libamf.all/test_lc.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- testsuite/libamf.all/test_lc.cpp    11 Apr 2008 19:02:36 -0000      1.9
+++ testsuite/libamf.all/test_lc.cpp    30 Apr 2008 03:35:31 -0000      1.10
@@ -219,6 +219,7 @@
     el = new Element(true, 123.456, 987.654, "IAmReplyingNow");
 //    el->dump();
     els.push_back(el);
+    delete el;    
 
 #if 0
     // 
@@ -241,7 +242,9 @@
     els.push_back(el);
 
     // Send the AMF objects
-    lc.send(con1, "localhost", els);
+//    lc.send(con1, "localhost", els);
+
+    delete el;
 }
 
 void
@@ -350,11 +353,14 @@
         }
     }
 
-    boost::uint8_t *ptr = lc.parseHeader(reinterpret_cast<boost::uint8_t 
*>(shmaddr));
-    vector<amf::Element *> ellist = lc.parseBody(ptr);
+//    boost::uint8_t *ptr = lc.parseHeader(reinterpret_cast<boost::uint8_t 
*>(shmaddr));
+//    vector<amf::Element *> ellist = lc.parseBody(ptr);
 //    cout << "# of AMF Elements in file: " << ellist.size() << endl;
 //    lc.dump();
     lc.close();
+
+    // cleanup
+//    delete ptr;
 }
 
 void
@@ -373,9 +379,9 @@
     sol.addObj(el);
     if ((el.name == "gain") &&
         (el.type == AMF::NUMBER) &&
-        (memcmp(el.data, &dub, AMF_NUMBER_SIZE) == 0) &&
+        (memcmp(el.data, &dub, AMF0_NUMBER_SIZE) == 0) &&
         (*((double *)el.data) == dub) &&
-        (el.length == AMF_NUMBER_SIZE)) {
+        (el.length == AMF0_NUMBER_SIZE)) {
         runtest.pass("gain set");
     } else {
         runtest.fail("gain set");
@@ -445,9 +451,9 @@
     sol.addObj(el);
     if ((el.name == "defaultklimit") &&
         (el.type == AMF::NUMBER) &&
-        (memcmp(el.data, &dub, AMF_NUMBER_SIZE) == 0) &&
+        (memcmp(el.data, &dub, AMF0_NUMBER_SIZE) == 0) &&
         (*((double *)el.data) == dub) &&
-        (el.length == AMF_NUMBER_SIZE)) {
+        (el.length == AMF0_NUMBER_SIZE)) {
         runtest.pass("defaultklimit set");
     } else {
         runtest.fail("defaultklimit set");
@@ -534,9 +540,9 @@
     sol.addObj(el);
     if ((el.name == "localSecPathTime") &&
         (el.type == AMF::NUMBER) &&
-        (memcmp(el.data, &dub, AMF_NUMBER_SIZE) == 0) &&
+        (memcmp(el.data, &dub, AMF0_NUMBER_SIZE) == 0) &&
         (*((double *)el.data) == dub) &&
-        (el.length == AMF_NUMBER_SIZE)) {
+        (el.length == AMF0_NUMBER_SIZE)) {
         runtest.pass("localSecPathTime set");
     } else {
         runtest.fail("localSecPathTime set");

Index: testsuite/libamf.all/test_sol.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libamf.all/test_sol.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- testsuite/libamf.all/test_sol.cpp   11 Apr 2008 19:02:36 -0000      1.12
+++ testsuite/libamf.all/test_sol.cpp   30 Apr 2008 03:35:31 -0000      1.13
@@ -1,5 +1,5 @@
 // 
-//   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+//   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
 // 
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -26,23 +26,13 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#include "as_object.h"
-
-extern "C"{
-#include <unistd.h>
-#ifdef HAVE_GETOPT_H
-        #include <getopt.h>
-#endif
-#ifndef __GNUC__
-extern int optind, getopt(int, char *const *, const char *);
-#endif
-}
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <iostream>
 #include <string>
 
+#include "as_object.h"
 #include "dejagnu.h"
 #include "log.h"
 #include "amf.h"
@@ -50,6 +40,8 @@
 #include "network.h"
 #include "element.h"
 #include "sol.h"
+#include "arg_parser.h"
+#include "gmemory.h"
 
 using namespace amf;
 using namespace gnash;
@@ -57,6 +49,16 @@
 
 static void usage (void);
 
+// Enable the display of memory allocation and timing data
+static bool memdebug = false;
+
+// We use the Memory profiling class to check the malloc buffers
+// in the kernel to make sure the allocations and frees happen
+// the way we expect them too. There is no real other way to tell.
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+Memory *mem = 0;
+#endif
+
 static TestState runtest;
 
 static void test_read(std::string &filespec);
@@ -65,36 +67,114 @@
 
 LogFile& dbglogfile = LogFile::getDefaultInstance();
 
-int
-main(int argc, char *argv[])
+// These next two functions are borrowed from Libgloss, part of the GNU 
binutils,
+// of which I am the primary author and copyright holder.
+// convert an ascii hex digit to a number.
+//      param is hex digit.
+//      returns a decimal digit.
+Network::byte_t
+hex2digit (Network::byte_t digit)
 {
-    int c;
+    if (digit == 0)
+        return 0;
+    
+    if (digit >= '0' && digit <= '9')
+        return digit - '0';
+    if (digit >= 'a' && digit <= 'f')
+        return digit - 'a' + 10;
+    if (digit >= 'A' && digit <= 'F')
+        return digit - 'A' + 10;
 
-    RcInitFile& rc = RcInitFile::getDefaultInstance();
+    // shouldn't ever get this far
+    return -1;
+}
 
-    while ((c = getopt (argc, argv, "hdvsm:")) != -1) {
-        switch (c) {
+// Convert the hex array pointed to by buf into binary to be placed in mem
+Buffer *
+hex2mem(const char *str)
+{
+    size_t count = strlen(str);
+    Network::byte_t ch = 0;
+    Buffer *buf = new Buffer(count + 12);
+    buf->clear();
+
+    Network::byte_t *ptr = const_cast<Network::byte_t 
*>(reinterpret_cast<const Network::byte_t *>(str));
+    
+    for (size_t i=0; i<count; i++) {
+        if (*ptr == ' ') {      // skip spaces.
+            ptr++;
+            continue;
+        }
+        ch = hex2digit(*ptr++) << 4;
+        ch |= hex2digit(*ptr++);
+        buf->append(ch);
+    }
+    return buf;
+}
+
+int
+main(int argc, char *argv[])
+{
+    const Arg_parser::Option opts[] =
+        {
+            { 'h', "help",          Arg_parser::no  },
+            { 'v', "verbose",       Arg_parser::no  },
+            { 'w', "write",         Arg_parser::no  },
+// Unless you have support for memory debugging turned on, and
+// you have support for the Linux mallinfo() system call,
+// this option is totally useless. This doesn't really matter
+// as the memory testing is primarily used only during
+// debugging or development.
+            { 'm', "memstats",      Arg_parser::no  },
+            { 'd', "dump",          Arg_parser::no  },
+        };
+    
+    Arg_parser parser(argc, argv, opts);
+    if( ! parser.error().empty() ) {
+        cout << parser.error() << endl;
+        exit(EXIT_FAILURE);
+    }
+    
+    for( int i = 0; i < parser.arguments(); ++i ) {
+        const int code = parser.code(i);
+        try {
+            switch( code ) {
           case 'h':
             usage ();
-            break;
-            
+                  exit(EXIT_SUCCESS);
           case 'v':
               dbglogfile.setVerbosity();
+                    log_debug(_("Verbose output turned on"));
             break;
-            
-          default:
-            usage ();
+              case 'm':
+                    log_debug(_("Enabling memory statistics"));
+                    memdebug = true;
             break;
         }
     }
 
+        catch (Arg_parser::ArgParserException &e) {
+            cerr << _("Error parsing command line options: ") << e.what() << 
endl;
+            cerr << _("This is a Gnash bug.") << endl;
+        }
+    }
+
+#if defined(HAVE_MALLINFO) && defined(USE_STATS_MEMORY)
+    if (memdebug) {
+        mem = new Memory;
+        mem->startStats();
+    }
+#endif
+    
     // Read a premade .sol file
     string filespec = SRCDIR;
     filespec += "/settings.sol";    
     test_read(filespec);
 
+    filespec = SRCDIR;
+    filespec += "/testout.sol";    
     // Write a .sol file
-    filespec = rc.getSOLSafeDir() + std::string("/test.sol");
+    
     test_write(filespec);
 //    test_read(filespec);
     
@@ -153,10 +233,10 @@
 //    amf_obj.createElement(&el, "gain", dub);
     sol.addObj(el);
     if ((strcmp(el->getName(), "gain") == 0) &&
-        (el->getType() == Element::NUMBER) &&
-        (memcmp(el->getData(), &dub, AMF_NUMBER_SIZE) == 0) &&
+        (el->getType() == Element::NUMBER_AMF0) &&
+        (memcmp(el->getData(), &dub, AMF0_NUMBER_SIZE) == 0) &&
         (*((double *)el->getData()) == dub) &&
-        (el->getLength() == AMF_NUMBER_SIZE)) {
+        (el->getLength() == AMF0_NUMBER_SIZE)) {
         runtest.pass("gain set");
     } else {
         runtest.fail("gain set");
@@ -169,7 +249,7 @@
     ptr = (char *)amf_obj.extractVariable(&newel, foo);
     if ((el.getName() == newel.getName()) &&
         (el.getLength() == newel.getLength()) &&
-        (newel.getType() == Element::NUMBER) &&
+        (newel.getType() == Element::NUMBER_AMF0) &&
         (*((double *)newel.getData()) == dub)) {
         runtest.pass("gain number encoded/extracted");
     } else {
@@ -179,7 +259,7 @@
     el = new amf::Element("echosuppression", false);
     sol.addObj(el);
     if ((strcmp(el->getName(), "echosuppression") == 0) &&
-        (el->getType() == Element::BOOLEAN) &&
+        (el->getType() == Element::BOOLEAN_AMF0) &&
         (*el->getData() == 0) &&
         (el->getLength() == 1)) {
         runtest.pass("echosupression set");
@@ -203,7 +283,7 @@
     el = new amf::Element("defaultmicrophone", data);
     sol.addObj(el);
     if ((el->getName() == name) &&
-        (el->getType() == Element::STRING) &&
+        (el->getType() == Element::STRING_AMF0) &&
         (memcmp(el->getData(), data.c_str(), el->getLength()) == 0) &&
         (el->getLength() == data.size())) {
         runtest.pass("defaultmicrophone set");
@@ -216,7 +296,7 @@
     el->init("defaultcamera", data);
     sol.addObj(el);
     if ((strcmp(el->getName(), "defaultcamera") == 0) &&
-        (el->getType() == Element::STRING) &&
+        (el->getType() == Element::STRING_AMF0) &&
         (el->getLength() == 0)) {
         runtest.pass("defaultcamera set");
     } else {
@@ -229,10 +309,10 @@
     el->init("defaultklimit", dub);
     sol.addObj(el);
     if ((strcmp(el->getName(), "defaultklimit") == 0) &&
-        (el->getType() == Element::NUMBER) &&
-        (memcmp(el->getData(), &dub, AMF_NUMBER_SIZE) == 0) &&
+        (el->getType() == Element::NUMBER_AMF0) &&
+        (memcmp(el->getData(), &dub, AMF0_NUMBER_SIZE) == 0) &&
         (*((double *)el->getData()) == dub) &&
-        (el->getLength() == AMF_NUMBER_SIZE)) {
+        (el->getLength() == AMF0_NUMBER_SIZE)) {
         runtest.pass("defaultklimit set");
     } else {
         runtest.fail("defaultklimit set");
@@ -241,7 +321,7 @@
     el = new amf::Element("defaultalways", false);
     sol.addObj(el);
     if ((strcmp(el->getName(), "defaultalways") == 0) &&
-        (el->getType() == Element::BOOLEAN) &&
+        (el->getType() == Element::BOOLEAN_AMF0) &&
         (*el->getData() == 0) &&
         (el->getLength() == 1)) {
         runtest.pass("defaultalways set");
@@ -252,7 +332,7 @@
     el = new amf::Element("crossdomainAllow", true);
     sol.addObj(el);
     if ((strcmp(el->getName(), "crossdomainAllow") == 0) &&
-        (el->getType() == Element::BOOLEAN) &&
+        (el->getType() == Element::BOOLEAN_AMF0) &&
         (*el->getData() == 1) &&
         (el->getLength() == 1)) {
         runtest.pass("crossdomainAllow set");
@@ -263,7 +343,7 @@
     el = new amf::Element("crossdomainAlways", true);
     sol.addObj(el);
     if ((strcmp(el->getName(), "crossdomainAlways") == 0) &&
-        (el->getType() == Element::BOOLEAN) &&
+        (el->getType() == Element::BOOLEAN_AMF0) &&
         (*el->getData() == 1) &&
         (el->getLength() == 1)) {
         runtest.pass("crossdomainAlways set");
@@ -274,7 +354,7 @@
     el = new amf::Element("allowThirdPartyLSOAccess", true);
     sol.addObj(el);
     if ((strcmp(el->getName(), "allowThirdPartyLSOAccess") ==0) &&
-        (el->getType() == Element::BOOLEAN) &&
+        (el->getType() == Element::BOOLEAN_AMF0) &&
         (*el->getData() == 1) &&
         (el->getLength() == 1)) {
         runtest.pass("allowThirdPartyLSOAccess set");
@@ -288,7 +368,7 @@
     boost::intrusive_ptr<gnash::as_object> as;
     amf_obj.createElement(&el, "trustedPaths", &as);
     if ((el->getName() == "trustedPaths") &&
-        (el->getType() == Element::OBJECT)) {
+        (el->getType() == Element::OBJECT_AMF0)) {
         runtest.xpass("trustedPaths set");
     } else {
         runtest.xfail("trustedPaths set");
@@ -296,7 +376,7 @@
         // As this builds a null object, we get away with it,
         // and it helps debugging to have the hexdumps of the
         // .sol files match the originals.
-        el->getType() = Element::OBJECT;        
+        el->getType() = Element::OBJECT_AMF0;  
         el->getLength() = 0;
     }
     sol.addObj(el);
@@ -306,7 +386,7 @@
     el->init("localSecPath", data);
     sol.addObj(el);
     if ((strcmp(el->getName(), "localSecPath") == 0) &&
-        (el->getType() == Element::STRING) &&
+        (el->getType() == Element::STRING_AMF0) &&
         (el->getLength() == 0)) {
         runtest.pass("localSecPath set");
     } else {
@@ -321,64 +401,20 @@
     el->init("localSecPathTime", dub);
     sol.addObj(el);
     if ((strcmp(el->getName(), "localSecPathTime") ==0) &&
-        (el->getType() == Element::NUMBER) &&
-        (memcmp(el->getData(), &dub, AMF_NUMBER_SIZE) == 0) &&
+        (el->getType() == Element::NUMBER_AMF0) &&
+        (memcmp(el->getData(), &dub, AMF0_NUMBER_SIZE) == 0) &&
         (*((double *)el->getData()) == dub) &&
-        (el->getLength() == AMF_NUMBER_SIZE)) {
+        (el->getLength() == AMF0_NUMBER_SIZE)) {
         runtest.pass("localSecPathTime set");
     } else {
         runtest.fail("localSecPathTime set");
     }
+
 //    sol.dump();
     // now write the data to disk
     sol.writeFile(filespec, "settings");
 }
 
-#if 0
-// Test SOL files. These are shared Objects which are basically an AMF object 
with
-// a header. These .sol files are used for transferring data, so we want to 
make
-// sure they actually work. All numeric data is stored in big endian format.
-bool
-test_sol(std::string &filespec)
-{
-    struct stat st;
-
-    if (stat(filespec.c_str(), &st) == 0) {
-        AMF amf_obj;
-        int fd, ret;
-        uint8_t *buf;
-        
-        buf = new uint8_t[st.st_size + 1];
-        
-        memset(buf, 0, st.st_size+1);
-        fd = open(filespec.c_str(), O_RDONLY);
-        ret = read(fd, buf, st.st_size);
-        close(fd);
-        
-        Element *el = amf_obj.extractElement(buf);
-        boost::uint8_t *num = &reinterpret_cast<boost::uint8_t *>(el);
-        
-        if ((num[6] == -16) && (num[7] == 0x3f)) {
-            runtest.pass("Extracted Number SOL object");
-        } else {
-            runtest.fail("Extracted Number SOL object");
-        }
-        
-        void *out = el->encodeNumber(num);
-        
-        if (memcmp(out, buf, 9) == 0) {
-            runtest.pass("Encoded SOL Number");
-        } else {
-            runtest.fail("Encoded SOL Number");
-        }
-        return true;
-    }
- 
-    runtest.untested("testfile not found");
-    return false;
-}
-#endif
-
 static void
 usage (void)
 {




reply via email to

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