Finished wrapping and providing typemaps for wxInputStream and also

added the stream ctor and other methods for wxImage so images can now
be loaded from any Python "file-like" object.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14365 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-02-23 19:50:01 +00:00
parent e531b73f89
commit f74ff5efa5
12 changed files with 714 additions and 688 deletions

View File

@@ -77,7 +77,7 @@ void wxPyBeginBlockThreads();
void wxPyEndBlockThreads();
//----------------------------------------------------------------------
// Handle wxInputStreams by Joerg Baumann
// Handling of wxInputStreams by Joerg Baumann
// See stream.i for implementations
// list class for return list of strings, e.g. readlines()
@@ -85,14 +85,14 @@ WX_DECLARE_LIST(wxString, wxStringPtrList);
// C++ class wxPyInputStream to act as base for python class wxInputStream
// Use it in python like a python file object
// You can use it in python like a python file object.
class wxPyInputStream {
public:
// underlying wxInputStream
wxInputStream* wxi;
wxInputStream* m_wxis;
public:
wxPyInputStream(wxInputStream* wxi_) : wxi(wxi_) {}
wxPyInputStream(wxInputStream* wxis) : m_wxis(wxis) {}
~wxPyInputStream();
// python file object interface for input files (most of it)
@@ -104,7 +104,8 @@ public:
wxStringPtrList* readlines(int sizehint=-1);
void seek(int offset, int whence=0);
int tell();
/*
/* do these later?
bool isatty();
int fileno();
void truncate(int size=-1);
@@ -114,6 +115,36 @@ public:
};
// This is a wxInputStream that wraps a Python file-like
// object and calls the Python methods as needed.
class wxPyCBInputStream : public wxInputStream {
public:
~wxPyCBInputStream();
virtual size_t GetSize() const;
// factory function
static wxPyCBInputStream* create(PyObject *py, bool block=TRUE);
protected:
// can only be created via the factory
wxPyCBInputStream(PyObject *r, PyObject *s, PyObject *t, bool block);
// wxStreamBase methods
virtual size_t OnSysRead(void *buffer, size_t bufsize);
virtual size_t OnSysWrite(const void *buffer, size_t bufsize);
virtual off_t OnSysSeek(off_t off, wxSeekMode mode);
virtual off_t OnSysTell() const;
// helper
static PyObject* getMethod(PyObject* py, char* name);
PyObject* m_read;
PyObject* m_seek;
PyObject* m_tell;
bool m_block;
};
//----------------------------------------------------------------------
// These are helpers used by the typemaps