[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog pythonmodule/pyGnash.cpp python...
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] gnash ChangeLog pythonmodule/pyGnash.cpp python... |
Date: |
Tue, 13 May 2008 15:07:44 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Benjamin Wolsey <bwy> 08/05/13 15:07:43
Modified files:
. : ChangeLog
pythonmodule : pyGnash.cpp gnashpython.cpp gnashpython.h
Log message:
* pythonmodule/pyGnash.cpp, pythonmodule/gnashpython.{cpp,h}:
make
it build again; allow fetching log messages; let Python
handle the
file object, not Gnash; clean up a bit. There's no option to
build
this code, so it's irrelevant for the release.
There's a lovely IRC bot waiting to emerge once Gnash can handle opening
SWFs consecutively.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6594&r2=1.6595
http://cvs.savannah.gnu.org/viewcvs/gnash/pythonmodule/pyGnash.cpp?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/pythonmodule/gnashpython.cpp?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/pythonmodule/gnashpython.h?cvsroot=gnash&r1=1.5&r2=1.6
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6594
retrieving revision 1.6595
diff -u -b -r1.6594 -r1.6595
--- ChangeLog 13 May 2008 07:54:59 -0000 1.6594
+++ ChangeLog 13 May 2008 15:07:41 -0000 1.6595
@@ -1,5 +1,12 @@
2008-05-13 Benjamin Wolsey <address@hidden>
+ * pythonmodule/pyGnash.cpp, pythonmodule/gnashpython.{cpp,h}: make
+ it build again; allow fetching log messages; let Python handle the
+ file object, not Gnash; clean up a bit. There's no option to build
+ this code, so it's irrelevant for the release.
+
+2008-05-13 Benjamin Wolsey <address@hidden>
+
* server/swf/tag_loaders.cpp: minor cleanups, typo corrections,
include used headers.
* server/parser/movie_def_impl.h: log malformed SWF and return
Index: pythonmodule/pyGnash.cpp
===================================================================
RCS file: /sources/gnash/gnash/pythonmodule/pyGnash.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- pythonmodule/pyGnash.cpp 22 Jan 2008 21:13:15 -0000 1.5
+++ pythonmodule/pyGnash.cpp 13 May 2008 15:07:42 -0000 1.6
@@ -18,24 +18,32 @@
//
//
-#ifdef HAVE_CONFIG_H
-# include "gnashconfig.h"
-#endif
-
#include <boost/python.hpp>
#include "gnashpython.h"
// Warning! These Python bindings are not mature. They are unlikely to
// stay as they are. Do not rely on this interface!
+class PyObjectFromPyFile
+{
+public:
+ static PyObject& execute(PyObject& o) {
+ return o;
+ }
+};
+
using namespace boost::python;
namespace gnash {
BOOST_PYTHON_MODULE(gnash) {
+
+ lvalue_from_pytype<PyObjectFromPyFile, &PyFile_Type> ();
+
class_<pythonwrapper::GnashPlayer>("Player", "Wrapper round Gnash player
functions.")
- .def("loadMovie", &pythonwrapper::GnashPlayer::loadMovie)
+ .def("loadMovie", &pythonwrapper::GnashPlayer::loadMovie,
+ "Load the file object passed")
.def("initVM", &pythonwrapper::GnashPlayer::initVM)
.def("setRenderer", &pythonwrapper::GnashPlayer::setRenderer,
@@ -54,8 +62,7 @@
"Restart the movie.")
.def("pressKey", &pythonwrapper::GnashPlayer::pressKey,
"Send a key press event to the player.")
- .def("allowRescale", &pythonwrapper::GnashPlayer::allowRescale)
- .def("setVerbose", &pythonwrapper::GnashPlayer::setVerbose)
+ .def("setVerbosity", &pythonwrapper::GnashPlayer::setVerbosity)
.def("render", &pythonwrapper::GnashPlayer::render,
"Instruct the renderer to draw the current frame. "
"Pass 'True' to enforce a full redraw, 'False' to
redraw "
@@ -81,6 +88,14 @@
.def("getTopmostMouseEntity",
&pythonwrapper::GnashPlayer::getTopmostMouseEntity,
return_value_policy<manage_new_object>(),
"The active gnash.Character() under the pointer.")
+
+ // Log messages
+ .def("logSize", &pythonwrapper::GnashPlayer::logSize,
+ "The number of messages in the log")
+ .staticmethod("logSize")
+ .def("getLogMessage", &pythonwrapper::GnashPlayer::getLogMessage,
+ "Retrieve the earliest message in the log")
+ .staticmethod("getLogMessage")
;
class_<pythonwrapper::GnashCharacter>("Character", "Wrapper round a Gnash
character.")
Index: pythonmodule/gnashpython.cpp
===================================================================
RCS file: /sources/gnash/gnash/pythonmodule/gnashpython.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- pythonmodule/gnashpython.cpp 28 Jan 2008 13:58:25 -0000 1.7
+++ pythonmodule/gnashpython.cpp 13 May 2008 15:07:43 -0000 1.8
@@ -17,10 +17,6 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-#ifdef HAVE_CONFIG_H
-# include "gnashconfig.h"
-#endif
-
#include "GnashException.h"
#include "URL.h"
#include "noseek_fd_adapter.h"
@@ -35,13 +31,15 @@
#include "render_handler_agg.h"
#include "SystemClock.h"
#include "log.h"
+#include "rc.h"
-#include <cstdio>
#include <string>
#include <memory>
#include "gnashpython.h"
+#define LOG_QUEUE_MAX 200
+
#define REQUIRE_MOVIE_LOADED if (!_movieDef) throw GnashException("No Movie
Loaded!")
#define REQUIRE_VM_STARTED if (!_movieRoot) throw GnashException("VM not
started!")
@@ -49,6 +47,7 @@
namespace pythonwrapper {
+std::deque<std::string> GnashPlayer::_logMessages;
GnashPlayer::GnashPlayer()
:
@@ -58,10 +57,8 @@
_logFile(gnash::LogFile::getDefaultInstance()),
_xpos(0),
_ypos(0),
- _url(""),
- _fp(NULL)
+ _url("")
{
- init();
}
GnashPlayer::~GnashPlayer()
@@ -80,6 +77,36 @@
GnashPlayer::init()
{
gnash::gnashInit();
+ _logFile.registerLogCallback(&receiveLogMessages);
+}
+
+void
+GnashPlayer::receiveLogMessages(const std::string& s)
+{
+ /// Make sure the _logMessage queue doesn't grow out of control.
+ if (_logMessages.size() > LOG_QUEUE_MAX)
+ {
+ _logMessages.pop_front();
+ }
+ _logMessages.push_back(s);
+}
+
+std::string
+GnashPlayer::getLogMessage()
+{
+ if (! _logMessages.empty() )
+ {
+ std::string ret = _logMessages.front();
+ _logMessages.pop_front();
+ return ret;
+ }
+ return "";
+}
+
+size_t
+GnashPlayer::logSize()
+{
+ return _logMessages.size();
}
void
@@ -104,42 +131,50 @@
gnash::set_base_url( (gnash::URL)_url );
}
-// TODO: Read in movies from a python file object.
+
bool
-GnashPlayer::loadMovie(std::string url)
+GnashPlayer::loadMovie(PyObject& pf)
{
if (_movieDef) return false;
- setBaseURL(url);
+ init();
- // Fail if base URL not set
- if (_url == "") return false;
+ FILE* file = PyFile_AsFile(&pf);
+
+ std::string filename(PyString_AsString(PyFile_Name(&pf)));
- _fp = fopen(_url.c_str(), "rb");
+ URL baseurl = URL(filename);
- if (!_fp) return false;
+ setBaseURL(baseurl.str());
+
+ // Add URL to sandbox
+ RcInitFile& rcfile = RcInitFile::getDefaultInstance();
+ const std::string& path = baseurl.path();
+ size_t lastSlash = path.find_last_of('/');
+ std::string dir = path.substr(0, lastSlash+1);
+ rcfile.addLocalSandboxPath(dir);
+
+ // Fail if base URL not set
+ if (_url == "") return false;
- std::auto_ptr<tu_file> in(noseek_fd_adapter::make_stream(fileno(_fp)));
+ std::auto_ptr<tu_file> in(noseek_fd_adapter::make_stream(fileno(file)));
_movieDef = gnash::create_movie(in, _url, false);
if (!_movieDef) {
- // Something didn't work
- fclose(_fp);
return false;
}
return true;
}
+
bool
GnashPlayer::initVM()
{
- // If movie definition hasn't already been created, try to create it,
- // fail if that doesn't work either.
- if (!_movieDef && !loadMovie(_url)) return false;
+ if (!_movieDef || _movieRoot ) return false;
// Initialize the VM with a manual clock
_movieRoot = &(gnash::VM::init(*_movieDef, _manualClock).getRoot());
@@ -152,10 +187,6 @@
_movieDef->completeLoad();
_movieDef->ensure_frame_loaded(getSWFFrameCount());
- if (_fp) {
- fclose (_fp);
- }
-
// I don't know why it's done like this.
std::auto_ptr<movie_instance> mi (_movieDef->create_movie_instance());
@@ -165,20 +196,12 @@
return true;
}
-// Whether the movie can be resized or not
-void
-GnashPlayer::allowRescale(bool allow)
-{
- REQUIRE_VM_STARTED;
- _movieRoot->allowRescaling(allow);
-}
// Whether debug messages are sent to stdout
void
-GnashPlayer::setVerbose(bool verbose)
+GnashPlayer::setVerbosity(unsigned verbosity)
{
- // Can't turn this off yet...
- if (verbose) _logFile.setVerbosity();
+ _logFile.setVerbosity(verbosity);
}
// Move Gnash's sense of time along manually
Index: pythonmodule/gnashpython.h
===================================================================
RCS file: /sources/gnash/gnash/pythonmodule/gnashpython.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- pythonmodule/gnashpython.h 28 Jan 2008 13:58:25 -0000 1.5
+++ pythonmodule/gnashpython.h 13 May 2008 15:07:43 -0000 1.6
@@ -34,6 +34,9 @@
#include "log.h"
#include <string>
+#include <memory>
+#include <deque>
+#include <boost/python.hpp>
// Because the Python bindings are there to allow flexible access
// to Gnash in an interpreted language, there need to be many
@@ -66,8 +69,10 @@
// For exiting
void close();
- // Movie creation
- bool loadMovie(std::string url);
+ /// Movie creation
+
+ /// Takes a python file object
+ bool loadMovie(PyObject& pf);
bool initVM();
// Renderer
@@ -93,10 +98,9 @@
// Interaction
void advanceClock(unsigned long ms);
void advance();
- void allowRescale(bool allow);
void render(bool forceRedraw);
void restart();
- void setVerbose(bool verbose);
+ void setVerbosity(unsigned verbosity);
geometry::SnappingRanges2d<int> getInvalidatedRanges() const;
@@ -114,6 +118,9 @@
// to decide whether to rerender.
bool pressKey(int code);
+ static std::string getLogMessage();
+ static size_t logSize();
+
private:
void init();
void setBaseURL(std::string url);
@@ -126,7 +133,7 @@
gnash::InvalidatedRanges _invalidatedBounds;
- gnash::LogFile& _logFile ;
+ gnash::LogFile& _logFile;
// The position of our pointer
int _xpos, _ypos;
@@ -134,8 +141,10 @@
// The base URL of the movie;
std::string _url;
- // File to open (a bit primitive...)
- FILE* _fp;
+ static std::deque<std::string> _logMessages;
+
+ static void receiveLogMessages(const std::string& s);
+
};
class GnashCharacter
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog pythonmodule/pyGnash.cpp python...,
Benjamin Wolsey <=