some things that were changed/removed from my patch I submitted to them.) Since it is now possible easily and simply share the SWIG type tables across modules I reverted to always using the stock SWIG runtime instead of my slightly hacked up version of it exported via the wxPython C API. The %name directive is now deprecated so replaced most uses of it with a custom %Rename macro that uses %rename internally. These will evetually need to be replaced with a DocDecl macro when docstrings are added. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31128 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
155 lines
3.7 KiB
OpenEdge ABL
155 lines
3.7 KiB
OpenEdge ABL
/////////////////////////////////////////////////////////////////////////////
|
|
// Name: _streams.i
|
|
// Purpose: SWIG typemaps and wrappers for wxInputStream
|
|
//
|
|
// Author: Robin Dunn
|
|
//
|
|
// Created: 25-Sept-2000
|
|
// RCS-ID: $Id$
|
|
// Copyright: (c) 2003 by Total Control Software
|
|
// Licence: wxWindows license
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Not a %module
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
%{
|
|
#include "wx/wxPython/pyistream.h"
|
|
%}
|
|
|
|
//---------------------------------------------------------------------------
|
|
%newgroup
|
|
|
|
|
|
// typemaps for wxInputStream
|
|
%typemap(in) wxInputStream* (wxPyInputStream* temp, bool created) {
|
|
if (wxPyConvertSwigPtr($input, (void **)&temp, wxT("wxPyInputStream"))) {
|
|
$1 = temp->m_wxis;
|
|
created = false;
|
|
} else {
|
|
PyErr_Clear(); // clear the failure of the wxPyConvert above
|
|
$1 = wxPyCBInputStream_create($input, false);
|
|
if ($1 == NULL) {
|
|
PyErr_SetString(PyExc_TypeError, "Expected wxInputStream or Python file-like object.");
|
|
SWIG_fail;
|
|
}
|
|
created = true;
|
|
}
|
|
}
|
|
%typemap(freearg) wxInputStream* {
|
|
if (created$argnum)
|
|
delete $1;
|
|
}
|
|
|
|
|
|
%typemap(in) wxInputStream& = wxInputStream*;
|
|
%typemap(freearg) wxInputStream& = wxInputStream*;
|
|
|
|
|
|
%typemap(out) wxInputStream* {
|
|
wxPyInputStream * _ptr = NULL;
|
|
|
|
if ($1) {
|
|
_ptr = new wxPyInputStream($1);
|
|
}
|
|
$result = wxPyConstructObject(_ptr, wxT("wxPyInputStream"), $owner);
|
|
}
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
enum wxSeekMode
|
|
{
|
|
wxFromStart,
|
|
wxFromCurrent,
|
|
wxFromEnd
|
|
};
|
|
|
|
|
|
%rename(InputStream) wxPyInputStream;
|
|
class wxPyInputStream
|
|
{
|
|
public:
|
|
%extend {
|
|
wxPyInputStream(PyObject* p) {
|
|
wxInputStream* wxis = wxPyCBInputStream::create(p);
|
|
if (wxis)
|
|
return new wxPyInputStream(wxis);
|
|
else
|
|
return NULL;
|
|
}
|
|
}
|
|
~wxPyInputStream();
|
|
|
|
void close();
|
|
void flush();
|
|
bool eof();
|
|
PyObject* read(int size=-1);
|
|
PyObject* readline(int size=-1);
|
|
PyObject* readlines(int sizehint=-1);
|
|
void seek(int offset, int whence=0);
|
|
int tell();
|
|
|
|
/*
|
|
bool isatty();
|
|
int fileno();
|
|
void truncate(int size=-1);
|
|
void write(wxString data);
|
|
void writelines(wxStringPtrList);
|
|
*/
|
|
|
|
char Peek();
|
|
char GetC();
|
|
size_t LastRead();
|
|
bool CanRead();
|
|
bool Eof();
|
|
bool Ungetch(char c);
|
|
|
|
long SeekI(long pos, wxSeekMode mode = wxFromStart);
|
|
long TellI();
|
|
};
|
|
|
|
|
|
|
|
// TODO: make a more fully implemented file interface...
|
|
class wxOutputStream {
|
|
public:
|
|
/*
|
|
void close();
|
|
void flush();
|
|
wxString* read(int size=-1);
|
|
wxString* readline(int size=-1);
|
|
wxStringPtrList* readlines(int sizehint=-1);
|
|
void seek(int offset, int whence=0);
|
|
int tell();
|
|
bool isatty();
|
|
int fileno();
|
|
void truncate(int size=-1);
|
|
void write(wxString data);
|
|
void writelines(wxStringPtrList);
|
|
*/
|
|
|
|
%extend {
|
|
void write(PyObject* obj) {
|
|
// We use only strings for the streams, not unicode
|
|
PyObject* str = PyObject_Str(obj);
|
|
if (! str) {
|
|
PyErr_SetString(PyExc_TypeError, "Unable to convert to string");
|
|
return;
|
|
}
|
|
self->Write(PyString_AS_STRING(str),
|
|
PyString_GET_SIZE(str));
|
|
Py_DECREF(str);
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
%init %{
|
|
wxPyPtrTypeMap_Add("wxInputStream", "wxPyInputStream");
|
|
%}
|
|
//---------------------------------------------------------------------------
|