[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash server/asobj/SharedObject.cpp libamf/amf....
From: |
Rob Savoye |
Subject: |
[Gnash-commit] gnash server/asobj/SharedObject.cpp libamf/amf.... |
Date: |
Wed, 19 Dec 2007 19:40:22 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Rob Savoye <rsavoye> 07/12/19 19:40:22
Modified files:
server/asobj : SharedObject.cpp
libamf : amf.h amf.cpp sol.cpp
. : ChangeLog
Log message:
* server/asobj/SharedObject.cpp: Add handler for properties
visitor function. Handle "undefined" values when encoding into
AMF. Fixes #21848.
* libamf/amf.cpp: Comment out function traces.
* libamf/sol.cpp: Trap undefiend filespec.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/SharedObject.cpp?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amf.h?cvsroot=gnash&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amf.cpp?cvsroot=gnash&r1=1.45&r2=1.46
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/sol.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5220&r2=1.5221
Patches:
Index: server/asobj/SharedObject.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/SharedObject.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/asobj/SharedObject.cpp 19 Dec 2007 05:18:46 -0000 1.13
+++ server/asobj/SharedObject.cpp 19 Dec 2007 19:40:20 -0000 1.14
@@ -45,9 +45,46 @@
as_value sharedobject_getsize(const fn_call& fn);
as_value sharedobject_ctor(const fn_call& fn);
-void sharedobject_iter(string_table::key key, const as_value &reference);
+void sharedobject_iter(SOL &sol, string_table::key key, const as_value
&reference);
-static SOL sol;
+class PropsSerializer {
+ SOL& _sol; public: PropsSerializer(SOL& sol) : _sol(sol) {};
+ virtual as_value operator() (string_table::key key, const as_value& val)
+ {
+ GNASH_REPORT_FUNCTION;
+ AMF amf;
+ AMF::amf_element_t el;
+ string_table& st = VM::get().getStringTable();
+ string str = st.string_table::value(key);
+ cerr << "FIXME: yes!!!!! " << str << ": "<< val.to_string() <<
endl;
+
+ if (val.is_string()) {
+ string str;
+ if (val.is_undefined()) {
+ str = "";
+ } else {
+ str = val.to_string();
+ }
+ amf.createElement(&el, str, str);
+ }
+ if (val.is_bool()) {
+ bool b;
+ amf.createElement(&el, str, b);
+ }
+ if (val.is_number()) {
+ double dub;
+ if (val.is_undefined()) {
+ dub = 0.0;
+ } else {
+ dub = val.to_number();
+ }
+ amf.createElement(&el, str, dub);
+ }
+
+ _sol.addObj(el);
+ return as_value(true);
+ }
+};
static void
attachProperties(as_object& o)
@@ -100,11 +137,12 @@
}
};
+#if 0
// Turn each property into an AMF element
void
-sharedobject_iter(string_table::key key, const as_value &reference)
+sharedobject_iter(SOL &sol, string_table::key key, const as_value &reference)
{
-// GNASH_REPORT_FUNCTION;
+ GNASH_REPORT_FUNCTION;
AMF amf;
AMF::amf_element_t el;
@@ -127,6 +165,7 @@
sol.addObj(el);
}
+#endif
as_value
sharedobject_clear(const fn_call& fn)
@@ -148,15 +187,19 @@
{
GNASH_REPORT_FUNCTION;
+
boost::intrusive_ptr<SharedObject> obj =
ensureType<SharedObject>(fn.this_ptr);
- log_msg("Flushing to file %s", obj->getFilespec().c_str());
+// log_msg("Flushing to file %s", obj->getFilespec().c_str());
string_table::key dataKey = VM::get().getStringTable().find("data");
as_value as = obj->getMember(dataKey);
boost::intrusive_ptr<as_object> ptr = as.to_object();
- ptr->visitPropertyValues(sharedobject_iter);
- sol.writeFile(obj->getFilespec(), "settings");
+
+ auto_ptr<SOL> sol(new SOL);
+ PropsSerializer props(*sol);
+ ptr->visitPropertyValues(props);
+ sol->writeFile(obj->getFilespec(), obj->getObjectName().c_str());
return as_value(true);
}
Index: libamf/amf.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/amf.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- libamf/amf.h 18 Dec 2007 01:55:18 -0000 1.24
+++ libamf/amf.h 19 Dec 2007 19:40:21 -0000 1.25
@@ -251,6 +251,10 @@
boost::intrusive_ptr<gnash::as_object> &data);
amf_element_t *createElement(amf_element_t *el, const char *name,
boost::intrusive_ptr<gnash::as_object> &data);
+// amf_element_t *createElement(amf_element_t *el, std::string &name,
+// const gnash::as_value &data);
+// amf_element_t *createElement(amf_element_t *el, const char *name,
+// const gnash::as_value &data);
//
/// @return a newly allocated byte array,
/// to be deleted by caller using delete [] operator, or NULL
Index: libamf/amf.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/amf.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- libamf/amf.cpp 18 Dec 2007 01:55:18 -0000 1.45
+++ libamf/amf.cpp 19 Dec 2007 19:40:21 -0000 1.46
@@ -80,7 +80,7 @@
_seekptr(0),
_mystery_word(0)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
}
AMF::AMF(int size)
@@ -92,7 +92,7 @@
_amf_data(0),
_mystery_word(0)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
if (!_amf_data) {
_amf_data = new uint8_t(size+1);
memset(_amf_data, 0, size+1);
@@ -102,7 +102,7 @@
AMF::~AMF()
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
}
@@ -167,7 +167,7 @@
bool
AMF::parseAMF(uint8_t *in)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
uint8_t *x = in;
@@ -180,7 +180,7 @@
uint8_t *
AMF::readElement(void *in)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
uint8_t *x = static_cast<uint8_t *>(in);
astype_e type = (astype_e)*x;
@@ -523,7 +523,7 @@
amfhead_t *
AMF::encodeHeader(amfutf8_t *name, bool required, int nbytes, void *data)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
AMF_Int_t length = sizeof(amfhead_t) + nbytes + name->length + 1;
char *buf = new char[length];
@@ -567,7 +567,7 @@
amfbody_t *
AMF::encodeBody(amfutf8_t *target, amfutf8_t *response, int nbytes, void *data)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
char *buf = new char[sizeof(amfbody_t) + nbytes];
memset(buf, 0, sizeof(amfbody_t) + nbytes );
@@ -600,7 +600,7 @@
amfpacket_t *
AMF::encodePacket(std::vector<amfpacket_t *> messages)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
int total = 0;
amfpacket_t pkt;
@@ -637,7 +637,7 @@
AMF::astype_e
AMF::extractElementHeader(void *in)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
return (AMF::astype_e)*(char *)in;
}
@@ -645,7 +645,7 @@
int
AMF::extractElementLength(void *in)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
char *x = (char *)in;
astype_e type = (astype_e)*x;
@@ -719,7 +719,7 @@
int8_t *
AMF::extractString(const uint8_t *in)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
int8_t *buf = NULL;
uint8_t *x = const_cast<uint8_t *>(in);
@@ -742,7 +742,7 @@
amfnum_t *
AMF::extractNumber(const uint8_t *in)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
uint8_t *x = const_cast<uint8_t *>(in);
amfnum_t *num = new amfnum_t;
memset(num, 0, AMF_NUMBER_SIZE);
@@ -762,7 +762,7 @@
AMF::createElement(amf_element_t *el, astype_e type,
std::string &name, uint8_t *data, int nbytes)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
log_debug("Creating element %s", name.c_str());
el->type = type;
@@ -775,7 +775,7 @@
AMF::amf_element_t *
AMF::createElement(amf_element_t *el, const char *name, amfnum_t data)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
string str = name;
return createElement(el, str, data);
}
@@ -800,7 +800,7 @@
AMF::amf_element_t *
AMF::createElement(amf_element_t *el, const char *name, double data)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
string str = name;
return createElement(el, str, data);
}
@@ -853,7 +853,7 @@
AMF::amf_element_t *
AMF::createElement(amf_element_t *el, const char *name, bool data)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
string str = name;
return createElement(el, str, data);
}
@@ -874,38 +874,39 @@
}
-AMF::amf_element_t *
-createElement(AMF::amf_element_t *el, std::string &name,
- boost::intrusive_ptr<gnash::as_object> &data)
-{
- GNASH_REPORT_FUNCTION;
- log_debug("Creating element %s", name.c_str());
-
- el->type = AMF::OBJECT;
- el->name = name;
- el->length = sizeof(data);
- el->data = new uint8_t[sizeof(uint16_t)];
- memset(el->data, 0, sizeof(uint16_t));
- memcpy(el->data, (char *)&data, el->length);
- return el;
-}
+// AMF::amf_element_t *
+// createElement(AMF::amf_element_t *el, std::string &name,
+// boost::intrusive_ptr<gnash::as_object> &data)
+// {
+// GNASH_REPORT_FUNCTION;
+// log_debug("Creating element %s", name.c_str());
-AMF::amf_element_t *
-createElement(AMF::amf_element_t *el, const char *name,
- boost::intrusive_ptr<gnash::as_object> &data)
-{
- GNASH_REPORT_FUNCTION;
- string str = name;
- return createElement(el, str, data);
-}
+// el->type = AMF::OBJECT;
+// el->name = name;
+// el->length = sizeof(data);
+// el->data = new uint8_t[sizeof(uint16_t)];
+// memset(el->data, 0, sizeof(uint16_t));
+// memcpy(el->data, (char *)&data, el->length);
+// return el;
+// }
+
+// AMF::amf_element_t *
+// createElement(AMF::amf_element_t *el, const char *name,
+// boost::intrusive_ptr<gnash::as_object> &data)
+// {
+// GNASH_REPORT_FUNCTION;
+// string str = name;
+// return createElement(el, str, data);
+// }
uint8_t *
AMF::encodeVariable(amf_element_t *el)
{
GNASH_REPORT_FUNCTION;
int outsize = el->name.size() + el->length + 5;
- uint8_t *out = new uint8_t[outsize];
- memset(out, 0, outsize);
+ log_debug("FIXME: Outsize is: %d", outsize);
+ uint8_t *out = new uint8_t[outsize + 2];
+ memset(out, 0, outsize + 2);
uint8_t *tmpptr = out;
// Add the length of the string for the name of the variable
@@ -929,8 +930,10 @@
tmpptr += sizeof(uint16_t);
break;
case AMF::NUMBER:
+ if (el->data) {
swapBytes(el->data, AMF_NUMBER_SIZE);
memcpy(tmpptr, el->data, AMF_NUMBER_SIZE);
+ }
break;
default:
enclength = el->length;
@@ -947,7 +950,7 @@
uint8_t *
AMF::encodeVariable(amf_element_t &el)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
int outsize = el.name.size() + el.length + 5;
uint8_t *out = new uint8_t[outsize];
uint8_t *tmpptr = out;
@@ -974,7 +977,7 @@
uint8_t *
AMF::encodeVariable(const char *name, bool flag)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
int outsize = strlen(name) + AMF_NUMBER_SIZE + 5;
uint8_t *out = new uint8_t[outsize];
@@ -997,7 +1000,7 @@
uint8_t *
AMF::encodeVariable(const char *name)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
size_t outsize = strlen(name) + AMF_NUMBER_SIZE + 5;
uint8_t *out = new uint8_t[outsize];
uint8_t *tmpptr = out;
@@ -1018,7 +1021,7 @@
uint8_t *
AMF::encodeVariable(const char *name, amfnum_t bignum)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
int outsize = strlen(name) + AMF_NUMBER_SIZE + 5;
uint8_t *out = new uint8_t[outsize];
uint8_t *tmpptr = out;
@@ -1043,7 +1046,7 @@
uint8_t *
AMF::encodeVariable(const char *name, const char *val)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
int outsize = strlen(name) + strlen(val) + 5;
uint8_t *out = new uint8_t[outsize];
@@ -1071,7 +1074,7 @@
uint8_t *
AMF::encodeVariable(std::string &name, std::string &val)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
int outsize = name.size() + val.size() + 5;
uint8_t *out = new uint8_t[outsize];
@@ -1128,7 +1131,7 @@
int
AMF::parseHeader(uint8_t *in)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
uint8_t *tmpptr = in;
@@ -1206,7 +1209,7 @@
uint8_t *
AMF::addPacketData(uint8_t *data, int bytes)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
memcpy(_seekptr, data, bytes);
_seekptr+=bytes;
return _seekptr;
@@ -1215,7 +1218,7 @@
int
AMF::parseBody()
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
return parseBody(_amf_data, _total_size);
}
@@ -1223,7 +1226,7 @@
int
AMF::parseBody(uint8_t *in, int bytes)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
uint8_t *tmpptr;
@@ -1320,7 +1323,7 @@
uint8_t *
AMF::extractVariable(AMF::amf_element_t *el, uint8_t *in)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
uint8_t buffer[AMF_PACKET_SIZE];
uint8_t *tmpptr = in;
Index: libamf/sol.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/sol.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- libamf/sol.cpp 18 Dec 2007 01:55:18 -0000 1.2
+++ libamf/sol.cpp 19 Dec 2007 19:40:21 -0000 1.3
@@ -59,6 +59,7 @@
namespace amf
{
+
SOL::SOL()
: _filesize(0)
{
@@ -184,7 +185,7 @@
bool
SOL::writeFile(string &filespec, const char *name)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
string str = name;
return writeFile(filespec, str);
}
@@ -192,7 +193,7 @@
bool
SOL::writeFile(const char *filespec, const char *name)
{
- GNASH_REPORT_FUNCTION;
+// GNASH_REPORT_FUNCTION;
string str1 = filespec;
string str2 = name;
return writeFile(str1, str2);
@@ -208,6 +209,11 @@
AMF amf_obj;
char *ptr;
+
+ if (filespec.size() == 0) {
+ return false;
+ }
+
char *body = new char[_filesize]; // FIXME: bogus size!
memset(body, 0, _filesize);
ptr = body;
@@ -218,7 +224,6 @@
uint8_t *foo = amf_obj.encodeVariable(el);
switch (el->type) {
case AMF::BOOLEAN:
-// *ptr++ = el->data[0];
outsize = el->name.size() + 5;
memcpy(ptr, foo, outsize);
ptr += outsize;
@@ -251,8 +256,10 @@
memcpy(ptr, foo, outsize);
ptr += outsize;
}
+ if (foo) {
delete foo;
}
+ }
_filesize = ptr - body;
int len = name.size() + sizeof(uint16_t) + 16;
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5220
retrieving revision 1.5221
diff -u -b -r1.5220 -r1.5221
--- ChangeLog 19 Dec 2007 18:40:06 -0000 1.5220
+++ ChangeLog 19 Dec 2007 19:40:21 -0000 1.5221
@@ -1,3 +1,11 @@
+2007-12-19 Rob Savoye <address@hidden>
+
+ * server/asobj/SharedObject.cpp: Add handler for properties
+ visitor function. Handle "undefined" values when encoding into
+ AMF. Fixes #21848.
+ * libamf/amf.cpp: Comment out function traces.
+ * libamf/sol.cpp: Trap undefiend filespec.
+
2007-12-18 Sandro Santilli <address@hidden>
* server/edit_text_character.{cpp,h}:
- [Gnash-commit] gnash server/asobj/SharedObject.cpp libamf/amf....,
Rob Savoye <=