[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r9728: - Improve Element to as_value
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r9728: - Improve Element to as_value converter. |
Date: |
Fri, 12 Sep 2008 18:22:06 +0200 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9728
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Fri 2008-09-12 18:22:06 +0200
message:
- Improve Element to as_value converter.
- Add log_amferror and related gnashrc directive.
modified:
libbase/log.cpp
libbase/log.h
libbase/rc.cpp
libbase/rc.h
libcore/as_value.cpp
------------------------------------------------------------
revno: 9727.1.1
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Fri 2008-09-12 17:04:27 +0200
message:
Fix Element to as_value converter and add debugging lines
modified:
libcore/as_value.cpp
------------------------------------------------------------
revno: 9727.1.2
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Fri 2008-09-12 18:20:20 +0200
message:
Add log_amferror for malformed amf reporting
modified:
libbase/log.cpp
libbase/log.h
libbase/rc.cpp
libbase/rc.h
=== modified file 'libbase/log.cpp'
--- a/libbase/log.cpp 2008-06-02 12:40:49 +0000
+++ b/libbase/log.cpp 2008-09-12 16:20:20 +0000
@@ -159,6 +159,12 @@
}
void
+processLog_amferror(const boost::format& fmt)
+{
+ dbglogfile.log(N_("MALFORMED AMF"), fmt.str());
+}
+
+void
processLog_aserror(const boost::format& fmt)
{
dbglogfile.log(N_("ACTIONSCRIPT ERROR"), fmt.str());
=== modified file 'libbase/log.h'
--- a/libbase/log.h 2008-08-18 23:53:04 +0000
+++ b/libbase/log.h 2008-09-12 16:20:20 +0000
@@ -225,7 +225,7 @@
/// This is a sequence of different log message types to be used in
/// the code. Append the name to log_ to call the function, e.g.
/// log_error, log_unimpl.
-#define LOG_TYPES (error) (debug) (unimpl) (aserror) (swferror) (security)
(action) (parse) (trace)
+#define LOG_TYPES (error) (debug) (unimpl) (aserror) (swferror) (smferror)
(security) (action) (parse) (trace)
/// This actually creates the template functions using the TOKENIZE
/// functions above. The templates look like this:
@@ -287,6 +287,7 @@
DSOEXPORT void processLog_parse(const boost::format& fmt);
DSOEXPORT void processLog_security(const boost::format& fmt);
DSOEXPORT void processLog_swferror(const boost::format& fmt);
+DSOEXPORT void processLog_amferror(const boost::format& fmt);
DSOEXPORT void processLog_aserror(const boost::format& fmt);
/// A fault-tolerant boost::format object for logging
@@ -325,6 +326,11 @@
#define VERBOSE_MALFORMED_SWF 1
#endif
+// Define to 0 this to remove invalid AMF verbosity at compile-time
+#ifndef VERBOSE_MALFORMED_AMF
+#define VERBOSE_MALFORMED_AMF 1
+#endif
+
#if VERBOSE_PARSE
#define IF_VERBOSE_PARSE(x) do { if (
LogFile::getDefaultInstance().getParserDump() ) { x; } } while (0);
@@ -352,6 +358,13 @@
#define IF_VERBOSE_MALFORMED_SWF(x)
#endif
+#if VERBOSE_MALFORMED_AMF
+// TODO: check if it's worth to check verbosity level too...
+#define IF_VERBOSE_MALFORMED_AMF(x) { if (
gnash::RcInitFile::getDefaultInstance().showMalformedAMFErrors() ) { x; } }
+#else
+#define IF_VERBOSE_MALFORMED_AMF(x)
+#endif
+
class DSOEXPORT __Host_Function_Report__ {
public:
const char *func;
=== modified file 'libbase/rc.cpp'
--- a/libbase/rc.cpp 2008-07-02 16:16:00 +0000
+++ b/libbase/rc.cpp 2008-09-12 16:20:20 +0000
@@ -81,6 +81,7 @@
_parserDump(false),
_verboseASCodingErrors(false),
_verboseMalformedSWF(false),
+ _verboseMalformedAMF(false),
_splashScreen(true),
_localdomainOnly(false),
_localhostOnly(false),
@@ -491,6 +492,9 @@
extractSetting(_verboseMalformedSWF, "MalformedSWFVerbosity",
variable, value)
||
+ extractSetting(_verboseMalformedAMF, "MalformedAMFVerbosity",
+ variable, value)
+ ||
extractSetting(_extensionsEnabled, "EnableExtensions",
variable, value)
||
@@ -648,6 +652,7 @@
cmd << "pluginSound " << _pluginSound << endl <<
cmd << "ASCodingErrorsVerbosity " << _verboseASCodingErrors << endl <<
cmd << "malformedSWFVerbosity " << _verboseMalformedSWF << endl <<
+ cmd << "malformedAMFVerbosity " << _verboseMalformedAMF << endl <<
cmd << "enableExtensions " << _extensionsEnabled << endl <<
cmd << "startStopped " << _startStopped << endl <<
cmd << "streamsTimeout " << _streamsTimeout << endl <<
@@ -655,6 +660,7 @@
cmd << "delay " << _delay << endl <<
cmd << "verbosity " << _verbosity << endl <<
cmd << "solReadOnly " << _solreadonly << endl <<
+ cmd << "SOLSafeDir " << _solsandbox << endl <<
cmd << "localConnection " << _lcdisabled << endl <<
cmd << "LCTrace " << _lctrace << endl <<
cmd << "LCShmkey " << std::hex << (boost::uint32_t) _lcshmkey << endl <<
@@ -675,7 +681,6 @@
cmd << "flashVersionString " << _flashVersionString << endl <<
cmd << "urlOpenerFormat " << _urlOpenerFormat << endl <<
cmd << "GSTAudioSink " << _gstaudiosink << endl <<
- cmd << "SOLSafeDir " << _solsandbox << endl;
// Lists. These can't be handled very well at the moment. The main
// inconvenience would be that disabling a list makes it an empty
=== modified file 'libbase/rc.h'
--- a/libbase/rc.h 2008-07-30 17:02:39 +0000
+++ b/libbase/rc.h 2008-09-12 16:20:20 +0000
@@ -88,6 +88,9 @@
bool showMalformedSWFErrors() const { return _verboseMalformedSWF; }
void showMalformedSWFErrors(bool value);
+ bool showMalformedAMFErrors() const { return _verboseMalformedAMF; }
+ void showMalformedAMFErrors(bool value);
+
int getMovieLibraryLimit() const { return _movieLibraryLimit; }
void setMovieLibraryLimit(int value) { _movieLibraryLimit = value; }
@@ -291,6 +294,9 @@
/// Enable Malformed SWF verbosity
bool _verboseMalformedSWF;
+ /// Enable Malformed AMF verbosity
+ bool _verboseMalformedAMF;
+
/// Display a splash screen when loading a movie
bool _splashScreen;
=== modified file 'libcore/as_value.cpp'
--- a/libcore/as_value.cpp 2008-09-12 12:53:50 +0000
+++ b/libcore/as_value.cpp 2008-09-12 15:04:27 +0000
@@ -1813,6 +1813,8 @@
/// Instantiate this value from an AMF element
as_value::as_value(const amf::Element& el)
+ :
+ m_type(UNDEFINED)
{
VM& vm = VM::get();
int swfVersion = vm.getSWFVersion();
@@ -1821,96 +1823,161 @@
switch (el.getType()) {
case amf::Element::NULL_AMF0:
{
- m_type = NULLTYPE;
- break;
+#ifdef GNASH_DEBUG_AMF_DESERIALIZE
+ log_debug("as_value(Element&) : AMF type NULL");
+#endif
+ set_null();
+ break;
}
case amf::Element::UNDEFINED_AMF0:
{
- m_type = UNDEFINED;
- break;
+#ifdef GNASH_DEBUG_AMF_DESERIALIZE
+ log_debug("as_value(Element&) : AMF type UNDEFINED");
+#endif
+ set_undefined();
+ break;
}
case amf::Element::MOVIECLIP_AMF0:
{
- m_type = MOVIECLIP;
- _value = el.getData();
- break;
+#ifdef GNASH_DEBUG_AMF_DESERIALIZE
+ log_debug("as_value(Element&) : AMF type MOVIECLIP");
+#endif
+ log_unimpl("MOVIECLIP AMF0 type");
+ set_undefined();
+ //m_type = MOVIECLIP;
+ //_value = el.getData();
+
+ break;
}
case amf::Element::NUMBER_AMF0:
{
- m_type = NUMBER;
- _value = el.to_number();
- break;
+#ifdef GNASH_DEBUG_AMF_DESERIALIZE
+ log_debug("as_value(Element&) : AMF type NUMBER");
+#endif
+ double num = el.to_number();
+ set_double(num);
+ break;
}
case amf::Element::BOOLEAN_AMF0:
{
- m_type = BOOLEAN;
- bool flag = el.to_bool();
- _value = flag ;
- break;
+#ifdef GNASH_DEBUG_AMF_DESERIALIZE
+ log_debug("as_value(Element&) : AMF type BOOLEAN");
+#endif
+ bool flag = el.to_bool();
+ set_bool(flag);
+ break;
}
+
case amf::Element::STRING_AMF0:
+ case amf::Element::LONG_STRING_AMF0:
{
- m_type = STRING;
- std::string str = el.to_string();
- _value = str;
- break;
+#ifdef GNASH_DEBUG_AMF_DESERIALIZE
+ log_debug("as_value(Element&) : AMF type STRING");
+#endif
+ std::string str = el.to_string();
+ set_string(str);
+ break;
}
+
case amf::Element::OBJECT_AMF0:
- case amf::Element::REFERENCE_AMF0:
+ {
+
+#ifdef GNASH_DEBUG_AMF_DESERIALIZE
+ log_debug("as_value(Element&) : AMF type OBJECT");
+#endif
+ as_object* obj = new as_object(getObjectInterface());
+ if (el.propertySize()) {
+ for (size_t i=0; i < el.propertySize(); i++) {
+ const amf::Element *prop = el.getProperty(i);
+ if (prop == 0) {
+ break;
+ } else {
+ obj->set_member(st.find(prop->getName()), as_value(*prop));
+ }
+ }
+ }
+ set_as_object(obj);
+ break;
+ }
+
case amf::Element::ECMA_ARRAY_AMF0:
- case amf::Element::OBJECT_END_AMF0:
+ {
+ // TODO: fixme: ECMA_ARRAY has an additional fiedl, dunno
+ // if accessible trought Element class
+ // (the theoretic number of elements in it)
+
+#ifdef GNASH_DEBUG_AMF_DESERIALIZE
+ log_debug("as_value(Element&) : AMF type ECMA_ARRAY");
+#endif
+ as_array_object* obj = new as_array_object();
+ if (el.propertySize()) {
+ for (size_t i=0; i < el.propertySize(); i++) {
+ const amf::Element *prop = el.getProperty(i);
+ if (prop == 0) {
+ break;
+ } else {
+ obj->set_member(st.find(prop->getName()), as_value(*prop));
+ }
+ }
+ }
+ set_as_object(obj);
+ break;
+ }
+
+
case amf::Element::STRICT_ARRAY_AMF0:
{
- m_type = OBJECT;
- boost::intrusive_ptr<as_object> obj(new as_object());
- if (el.propertySize()) {
- for (size_t i=0; i < el.propertySize(); i++) {
- const amf::Element *prop = el.getProperty(i);
- if (prop == 0) {
- break;
- } else {
- obj->set_member(st.string_table::find(prop->getName()),
as_value(*prop));
- }
- }
- }
- _value = obj;
- }
- break;
+#ifdef GNASH_DEBUG_AMF_DESERIALIZE
+ log_debug("as_value(Element&) : AMF type STRICT_ARRAY");
+#endif
+ as_array_object* obj = new as_array_object();
+ size_t len = el.propertySize();
+ obj->resize(len);
+
+ for (size_t i=0; i < el.propertySize(); i++) {
+ const amf::Element *prop = el.getProperty(i);
+ if (prop == 0) {
+ break;
+ } else {
+ obj->set_member(st.find(prop->getName()), as_value(*prop));
+ }
+ }
+
+ set_as_object(obj);
+ break;
+ }
+
+ case amf::Element::REFERENCE_AMF0:
+ {
+ log_unimpl("REFERENCE Element to as_value");
+ break;
+ }
+
case amf::Element::DATE_AMF0:
{
- if (swfVersion > 5) {
- m_type = STRING;
- }
- break;
- }
- case amf::Element::LONG_STRING_AMF0:
- {
- m_type = STRING;
- std::string str = el.to_string();
- _value = str;
- break;
- }
+ log_unimpl("DATE Element to as_value");
+ //if (swfVersion > 5) m_type = STRING;
+ break;
+ }
+
case amf::Element::UNSUPPORTED_AMF0:
- log_unimpl("Unsupported data type is not supported yet");
- break;
+ log_unimpl("Unsupported data type is not supported yet");
+ break;
case amf::Element::RECORD_SET_AMF0:
- log_unimpl("Record Set data type is not supported yet");
- break;
+ log_unimpl("Record Set data type is not supported yet");
+ break;
case amf::Element::XML_OBJECT_AMF0:
- log_unimpl("XML data type is not supported yet");
- break;
+ log_unimpl("XML data type is not supported yet");
+ break;
case amf::Element::TYPED_OBJECT_AMF0:
- log_unimpl("Typed Object data type is not supported yet");
- break;
+ log_unimpl("Typed Object data type is not supported yet");
+ break;
case amf::Element::AMF3_DATA:
- log_unimpl("AMF3 data type is not supported yet");
- break;
- case amf::Element::NOTYPE:
- throw ParserException("No type set for amf0 element");
- break;
+ log_unimpl("AMF3 data type is not supported yet");
+ break;
default:
- throw ParserException("Unsupported value type");
- break;
+ log_unimpl("Element to as_value - unsupported Element type %d",
el.getType());
+ break;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r9728: - Improve Element to as_value converter.,
Sandro Santilli <=