[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11046: Drop some singleton usage.
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11046: Drop some singleton usage. |
Date: |
Tue, 09 Jun 2009 14:22:18 +0200 |
User-agent: |
Bazaar (1.13.1) |
------------------------------------------------------------
revno: 11046
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Tue 2009-06-09 14:22:18 +0200
message:
Drop some singleton usage.
modified:
libcore/parser/SWFMovieDefinition.cpp
libcore/parser/SWFParser.h
libcore/swf/ScriptLimitsTag.h
libnet/network.cpp
------------------------------------------------------------
revno: 11034.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: test
timestamp: Mon 2009-06-08 12:52:42 +0200
message:
Indentation.
modified:
libnet/network.cpp
------------------------------------------------------------
revno: 11034.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: test
timestamp: Mon 2009-06-08 16:50:28 +0200
message:
Correct typo.
modified:
libcore/parser/SWFParser.h
------------------------------------------------------------
revno: 11034.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: test
timestamp: Mon 2009-06-08 17:43:21 +0200
message:
Don't use singleton in ScriptLimitsTag.
modified:
libcore/swf/ScriptLimitsTag.h
------------------------------------------------------------
revno: 11034.1.4
committer: Benjamin Wolsey <address@hidden>
branch nick: test
timestamp: Mon 2009-06-08 17:43:34 +0200
message:
Drop max FPS magic number, as Gnash does very well without it.
modified:
libcore/parser/SWFMovieDefinition.cpp
=== modified file 'libcore/parser/SWFMovieDefinition.cpp'
--- a/libcore/parser/SWFMovieDefinition.cpp 2009-06-05 10:25:43 +0000
+++ b/libcore/parser/SWFMovieDefinition.cpp 2009-06-08 15:43:34 +0000
@@ -340,28 +340,11 @@
);
}
- // It seems frame rate is limited to a max
- // 84 was found by testing the pp, might be turned into a
- // compile-time define
- static const int maxfps = 84;
-
_str->ensureBytes(2 + 2); // frame rate, frame count.
- m_frame_rate = _str->read_u16();
- if ( ! m_frame_rate )
- {
- log_debug("Frame rate of 0 taken as %d (upper bound)", maxfps);
- m_frame_rate = maxfps;
- }
- else
- {
- m_frame_rate /= 256.0f;
- if ( m_frame_rate > maxfps )
- {
- log_debug("Frame rate of %d too high, we'll use %d
(upper bound)",
- m_frame_rate, maxfps);
- m_frame_rate = maxfps;
- }
- }
+ m_frame_rate = _str->read_u16() / 256.0f;
+ if (!m_frame_rate) {
+ m_frame_rate = std::numeric_limits<boost::uint16_t>::max();
+ }
m_frame_count = _str->read_u16();
=== modified file 'libcore/parser/SWFParser.h'
--- a/libcore/parser/SWFParser.h 2009-06-05 11:19:22 +0000
+++ b/libcore/parser/SWFParser.h 2009-06-08 14:50:28 +0000
@@ -67,7 +67,7 @@
/// Parse a specified number of bytes from the stream.
//
- /// This function will as many complete tags as it can in the specified
+ /// This function will read as many complete tags as are in the specified
/// number of bytes. Any incomplete tags will be left open and unparsed
/// until the next call to read().
//
=== modified file 'libcore/swf/ScriptLimitsTag.h'
--- a/libcore/swf/ScriptLimitsTag.h 2009-06-03 16:05:40 +0000
+++ b/libcore/swf/ScriptLimitsTag.h 2009-06-08 15:43:21 +0000
@@ -22,6 +22,7 @@
#include "SWFStream.h" // for inlines
#include "movie_root.h"
#include "movie_definition.h"
+#include "ControlTag.h"
namespace gnash {
namespace SWF {
@@ -30,34 +31,48 @@
//
/// A loaded movie containing a ScriptLimits tag should change the *global*
/// scriptlimits setting, so this is kept in movie_root rather than the
-/// immutable movie_definition. Whenever this tag is parsed, the value in
-/// movie_root is overridden.
-class ScriptLimitsTag
+/// immutable movie_definition.
+class ScriptLimitsTag : public ControlTag
{
public:
- static void loader(SWFStream& in, TagType tag, movie_definition& /*m*/,
+ virtual ~ScriptLimitsTag() {}
+
+ virtual void execute(MovieClip* m, DisplayList& /*dl*/) const
+ {
+ log_debug("Setting script limits: recursion %s, timeout %s",
+ _recursionLimit, _timeoutLimit);
+ m->getVM().getRoot().setScriptLimits(_recursionLimit, _timeoutLimit);
+ }
+
+ static void loader(SWFStream& in, TagType tag, movie_definition& m,
const RunInfo& /*r*/)
{
-
- assert(VM::isInitialized());
-
- in.ensureBytes(4); // recursion and timeout.
-
- // We need to get the root movie or the VM from somewhere
- // in order to make the VM not a singleton.
- movie_root& r = VM::get().getRoot();
-
- const boost::uint16_t recursionLimit = in.read_u16();
- const boost::uint16_t timeoutLimit = in.read_u16();
+ assert(tag = SWF::SCRIPTLIMITS);
+ std::auto_ptr<ScriptLimitsTag> s(new ScriptLimitsTag(in));
+ m.addControlTag(s.release());
+ }
+
+private:
+
+ ScriptLimitsTag(SWFStream& in)
+ :
+ _recursionLimit(0),
+ _timeoutLimit(0)
+ {
+ in.ensureBytes(4);
+ _recursionLimit = in.read_u16();
+ _timeoutLimit = in.read_u16();
IF_VERBOSE_PARSE (
- log_parse(_(" ScriptLimits tag(%d): recursion: %d, timeout: %d"),
- tag, recursionLimit, timeoutLimit);
+ log_parse(_(" ScriptLimits tag: recursion: %d, timeout: %d"),
+ _recursionLimit, _timeoutLimit);
);
- r.setScriptLimits(recursionLimit, timeoutLimit);
}
+
+ boost::uint16_t _recursionLimit;
+ boost::uint16_t _timeoutLimit;
};
} // namespace gnash::SWF
=== modified file 'libnet/network.cpp'
--- a/libnet/network.cpp 2009-06-07 21:14:22 +0000
+++ b/libnet/network.cpp 2009-06-08 10:52:42 +0000
@@ -516,7 +516,7 @@
// assert( ! connected() );
if (connected()) {
- return true;
+ return true;
}
_port = port;
@@ -532,6 +532,7 @@
return false;
}
}
+
const struct hostent *hent = ::gethostbyname(hostname.c_str());
if (hent > 0) {
::memcpy(&sock_in.sin_addr, hent->h_addr, hent->h_length);
@@ -548,12 +549,11 @@
proto = ::getprotobyname("TCP");
_sockfd = ::socket(PF_INET, SOCK_STREAM, proto->p_proto);
- if (_sockfd < 0)
- {
- log_error(_("unable to create socket: %s"), strerror(errno));
- _sockfd = -1;
- return false;
- }
+ if (_sockfd < 0) {
+ log_error(_("unable to create socket: %s"), strerror(errno));
+ _sockfd = -1;
+ return false;
+ }
retries = 2;
while (retries-- > 0) {
@@ -570,37 +570,39 @@
ret = ::select(_sockfd+1, &fdset, NULL, NULL, &tval);
// If interupted by a system call, try again
- if (ret == -1 && errno == EINTR)
- {
- log_debug(_("The connect() socket for fd %d was interupted by
a system call"),
- _sockfd);
- continue;
- }
+ if (ret == -1 && errno == EINTR) {
+ log_debug(_("The connect() socket for fd %d was interrupted "
+ "by a system call"), _sockfd);
+ continue;
+ }
- if (ret == -1)
- {
- log_debug(_("The connect() socket for fd %d never was
available for writing"),
- _sockfd);
+ if (ret == -1) {
+ log_debug(_("The connect() socket for fd %d never was "
+ "available for writing"), _sockfd);
#ifdef HAVE_WINSOCK_H
- ::shutdown(_sockfd, 0); // FIXME: was SHUT_BOTH
+ ::shutdown(_sockfd, 0); // FIXME: was SHUT_BOTH
#else
- ::shutdown(_sockfd, SHUT_RDWR);
+ ::shutdown(_sockfd, SHUT_RDWR);
#endif
- _sockfd = -1;
- return false;
- }
+ _sockfd = -1;
+ return false;
+ }
+
if (ret == 0) {
- log_error(_("The connect() socket for fd %d timed out waiting to
write"),
- _sockfd);
+ log_error(_("The connect() socket for fd %d timed out waiting "
+ "to write"), _sockfd);
continue;
}
if (ret > 0) {
- ret = ::connect(_sockfd, reinterpret_cast<struct sockaddr
*>(&sock_in), sizeof(sock_in));
+ ret = ::connect(_sockfd,
+ reinterpret_cast<struct sockaddr *>(&sock_in),
+ sizeof(sock_in));
+
if (ret == 0) {
- char *ascip = ::inet_ntoa(sock_in.sin_addr);
-// char ascip[INET_ADDRSTRLEN];
-// inet_ntop(sock_in.sin_family, &sock_in.sin_addr.s_addr, ascip,
INET_ADDRSTRLEN);
+ char *ascip = ::inet_ntoa(sock_in.sin_addr);
+ // char ascip[INET_ADDRSTRLEN];
+ // inet_ntop(sock_in.sin_family, &sock_in.sin_addr.s_addr,
ascip, INET_ADDRSTRLEN);
log_debug(_("\tport %d at IP %s for fd %d"), port,
ascip, _sockfd);
_connected = true;
@@ -608,8 +610,8 @@
return true;
}
if (ret == -1) {
- log_error(_("The connect() socket for fd %d never was
available for writing"),
- _sockfd);
+ log_error(_("The connect() socket for fd %d never was "
+ "available for writing"), _sockfd);
_sockfd = -1;
assert(!_connected);
return false;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11046: Drop some singleton usage.,
Benjamin Wolsey <=