[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/rtmp r9941: add to_short() and to_integer(
From: |
rob |
Subject: |
[Gnash-commit] /srv/bzr/gnash/rtmp r9941: add to_short() and to_integer() accessors for the Element data. |
Date: |
Tue, 30 Dec 2008 21:01:32 -0700 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9941
committer: address@hidden
branch nick: rtmp
timestamp: Tue 2008-12-30 21:01:32 -0700
message:
add to_short() and to_integer() accessors for the Element data.
modified:
libamf/element.cpp
libamf/element.h
=== modified file 'libamf/element.cpp'
--- a/libamf/element.cpp 2008-12-28 22:34:58 +0000
+++ b/libamf/element.cpp 2008-12-31 04:01:32 +0000
@@ -171,7 +171,8 @@
Element::Element(bool /* flag */, double /* unknown1 */, double /* unknown2 */,
const string &/* methodname */)
: _name(0),
- _type(NOTYPE)
+ _type(NOTYPE),
+ _referenceid(0)
{
// GNASH_REPORT_FUNCTION;
log_unimpl("Can't create remote function calls yet");
@@ -249,6 +250,34 @@
return -1.0;
}
+/// \brief Cast the data in this Element to a short value.
+///
+/// @return short value.
+boost::uint16_t
+Element::to_short() const
+{
+// GNASH_REPORT_FUNCTION;
+ if (_buffer) {
+ return *(reinterpret_cast<boost::uint16_t *>(_buffer->reference()));
+ }
+// return ::nan("NaN");
+ return -1;
+}
+
+/// \brief Cast the data in this Element to a short value.
+///
+/// @return short value.
+boost::uint32_t
+Element::to_integer() const
+{
+// GNASH_REPORT_FUNCTION;
+ if (_buffer) {
+ return *(reinterpret_cast<boost::uint32_t *>(_buffer->reference()));
+ }
+// return ::nan("NaN");
+ return -1;
+}
+
/// \brief Cast the data in this Element to an ASCII string value.
///
/// @return A NULL terminated ASCII string.
@@ -258,14 +287,7 @@
// GNASH_REPORT_FUNCTION;
if (_buffer) {
if (_buffer->size() > 0) {
-#if 0
- char *foo = new char[_buffer->size() + 1];
- memset(foo, 0, _buffer->size() + 1);
- memcpy(foo, _buffer->reference(), _buffer->size());
- return foo;
-#else
return reinterpret_cast<const char *>(_buffer->reference());
-#endif
}
return "NULL";
}
@@ -945,7 +967,7 @@
return *this;
}
Element &
-Element::makeXMLObject(boost::uint8_t *data)
+Element::makeXMLObject(boost::uint8_t * /*data*/)
{
// GNASH_REPORT_FUNCTION;
_type = Element::XML_OBJECT_AMF0;
@@ -1028,7 +1050,7 @@
///
/// @return A reference to this Element.
Element &
-Element::makeTypedObject(boost::uint8_t *data)
+Element::makeTypedObject(boost::uint8_t */*data*/)
{
// GNASH_REPORT_FUNCTION;
_type = Element::TYPED_OBJECT_AMF0;
@@ -1045,6 +1067,16 @@
{
// GNASH_REPORT_FUNCTION;
_type = Element::REFERENCE_AMF0;
+}
+
+Element &
+Element::makeReference(boost::uint16_t index)
+{
+// GNASH_REPORT_FUNCTION;
+ _type = Element::REFERENCE_AMF0;
+ boost::uint8_t *ptr = reinterpret_cast<boost::uint8_t *>(&index);
+ return makeReference(ptr, sizeof(boost::uint16_t));
+
return *this;
}
@@ -1426,6 +1458,9 @@
if (_buffer->size() < size) {
throw ParserException("Buffer not big enough, try resizing!");
}
+ if (_buffer->size() == 0) {
+ throw ParserException("Buffer has zero size, not initialized!");
+ }
}
}
=== modified file 'libamf/element.h'
--- a/libamf/element.h 2008-12-23 02:56:29 +0000
+++ b/libamf/element.h 2008-12-31 04:01:32 +0000
@@ -472,6 +472,7 @@
///
/// @return A reference to this Element.
Element &makeReference();
+ Element &makeReference(boost::uint16_t index);
/// \brief Make this Element a Property with an Object Reference as the
value.
///
@@ -621,6 +622,16 @@
/// @return double value.
double to_number() const;
+ /// \brief Cast the data in this Element to a short (2 bytes) value.
+ ///
+ /// @return short (2 bytes) value.
+ boost::uint16_t to_short() const;
+
+ /// \brief Cast the data in this Element to an integer (4 bytes) value.
+ ///
+ /// @return integer (4 bytes) value.
+ boost::uint32_t to_integer() const;
+
/// \brief Cast the data in this Element to an ASCII string value.
///
/// @return A NULL terminated ASCII string.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/rtmp r9941: add to_short() and to_integer() accessors for the Element data.,
rob <=