More fix for warnings, and add some of the ideas of the Bill's 'labels' patch

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6998 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-02-24 23:48:20 +00:00
commit 192e00615d
18 changed files with 177 additions and 141 deletions

View file

@ -25,28 +25,29 @@ extern "C" {
namespace Swig {
/* base class for director exceptions */
class DirectorException {
protected:
std::string swig_msg;
public:
DirectorException(const char* msg="") {
}
const char *getMessage() const {
return swig_msg.c_str();
}
virtual ~DirectorException();
protected:
std::string swig_msg;
public:
DirectorException(const char* /* msg */ ="") {
}
const char *getMessage() const {
return swig_msg.c_str();
}
virtual ~DirectorException();
};
/* type mismatch in the return value from a python method call */
class DirectorTypeMismatchException : public Swig::DirectorException {
public:
DirectorTypeMismatchException(const char* msg="") {
if (!PyErr_Occurred()) {
swig_msg = "Swig director type mismatch: ";
swig_msg += msg;
PyErr_SetString(PyExc_TypeError, getMessage());
}
public:
DirectorTypeMismatchException(const char* msg="") {
if (!PyErr_Occurred()) {
swig_msg = "Swig director type mismatch: ";
swig_msg += msg;
PyErr_SetString(PyExc_TypeError, getMessage());
}
}
};
/* any python exception that occurs during a director method call */
@ -73,116 +74,116 @@ namespace Swig {
/* director base class */
class Director {
private:
/* pointer to the wrapped python object */
PyObject* swig_self;
/* flag indicating whether the object is owned by python or c++ */
mutable bool swig_disown_flag;
/* shared flag for breaking recursive director calls */
static bool swig_up;
private:
/* pointer to the wrapped python object */
PyObject* swig_self;
/* flag indicating whether the object is owned by python or c++ */
mutable bool swig_disown_flag;
/* shared flag for breaking recursive director calls */
static bool swig_up;
#ifdef __PTHREAD__
/* locks for sharing the swig_up flag in a threaded environment */
static pthread_mutex_t swig_mutex_up;
static bool swig_mutex_active;
static pthread_t swig_mutex_thread;
/* locks for sharing the swig_up flag in a threaded environment */
static pthread_mutex_t swig_mutex_up;
static bool swig_mutex_active;
static pthread_t swig_mutex_thread;
#endif
/* decrement the reference count of the wrapped python object */
void swig_decref() const {
if (swig_disown_flag) {
Py_DECREF(swig_self);
}
/* decrement the reference count of the wrapped python object */
void swig_decref() const {
if (swig_disown_flag) {
Py_DECREF(swig_self);
}
}
/* reset the swig_up flag once the routing direction has been determined */
/* reset the swig_up flag once the routing direction has been determined */
#ifdef __PTHREAD__
void swig_clear_up() const {
Swig::Director::swig_up = false;
Swig::Director::swig_mutex_active = false;
pthread_mutex_unlock(&swig_mutex_up);
}
void swig_clear_up() const {
Swig::Director::swig_up = false;
Swig::Director::swig_mutex_active = false;
pthread_mutex_unlock(&swig_mutex_up);
}
#else
void swig_clear_up() const {
Swig::Director::swig_up = false;
}
void swig_clear_up() const {
Swig::Director::swig_up = false;
}
#endif
public:
/* wrap a python object, optionally taking ownership */
Director(PyObject* self) : swig_self(self), swig_disown_flag(false) {
swig_incref();
}
public:
/* wrap a python object, optionally taking ownership */
Director(PyObject* self) : swig_self(self), swig_disown_flag(false) {
swig_incref();
}
/* discard our reference at destruction */
virtual ~Director();
/* discard our reference at destruction */
virtual ~Director();
/* return a pointer to the wrapped python object */
PyObject *swig_get_self() const {
return swig_self;
}
/* return a pointer to the wrapped python object */
PyObject *swig_get_self() const {
return swig_self;
}
/* get the swig_up flag to determine if the method call should be routed
* to the c++ base class or through the wrapped python object
*/
/* get the swig_up flag to determine if the method call should be routed
* to the c++ base class or through the wrapped python object
*/
#ifdef __PTHREAD__
bool swig_get_up() const {
if (Swig::Director::swig_mutex_active) {
if (pthread_equal(Swig::Director::swig_mutex_thread, pthread_self())) {
bool up = swig_up;
swig_clear_up();
return up;
}
}
return 0;
bool swig_get_up() const {
if (Swig::Director::swig_mutex_active) {
if (pthread_equal(Swig::Director::swig_mutex_thread, pthread_self())) {
bool up = swig_up;
swig_clear_up();
return up;
}
}
return 0;
}
#else
bool swig_get_up() const {
bool up = swig_up;
swig_up = false;
return up;
}
bool swig_get_up() const {
bool up = swig_up;
swig_up = false;
return up;
}
#endif
/* set the swig_up flag if the next method call should be directed to
* the c++ base class rather than the wrapped python object
*/
/* set the swig_up flag if the next method call should be directed to
* the c++ base class rather than the wrapped python object
*/
#ifdef __PTHREAD__
void swig_set_up() const {
pthread_mutex_lock(&Swig::Director::swig_mutex_up);
Swig::Director::swig_mutex_thread = pthread_self();
Swig::Director::swig_mutex_active = true;
Swig::Director::swig_up = true;
}
void swig_set_up() const {
pthread_mutex_lock(&Swig::Director::swig_mutex_up);
Swig::Director::swig_mutex_thread = pthread_self();
Swig::Director::swig_mutex_active = true;
Swig::Director::swig_up = true;
}
#else
void swig_set_up() const {
Swig::Director::swig_up = true;
}
void swig_set_up() const {
Swig::Director::swig_up = true;
}
#endif
/* acquire ownership of the wrapped python object (the sense of "disown"
* is from python) */
void swig_disown() const {
if (!swig_disown_flag) {
swig_disown_flag=true;
swig_incref();
}
}
/* acquire ownership of the wrapped python object (the sense of "disown"
* is from python) */
void swig_disown() const {
if (!swig_disown_flag) {
swig_disown_flag=true;
swig_incref();
}
}
/* increase the reference count of the wrapped python object */
void swig_incref() const {
if (swig_disown_flag) {
Py_INCREF(swig_self);
}
/* increase the reference count of the wrapped python object */
void swig_incref() const {
if (swig_disown_flag) {
Py_INCREF(swig_self);
}
}
/* methods to implement pseudo protected director members */
virtual bool swig_get_inner(const char* name) const {
return true;
}
virtual void swig_set_inner(const char* name, bool val) const {
}
/* methods to implement pseudo protected director members */
virtual bool swig_get_inner(const char* /* name */) const {
return true;
}
virtual void swig_set_inner(const char* /* name */, bool /* val */) const {
}
};
}

View file

@ -28,7 +28,7 @@ SWIG_AsValFilePtr(PyObject *obj, FILE **val) {
}
%fragment("SWIG_AsFilePtr","header",fragment="SWIG_AsValFilePtr") {
SWIGINTERNSHORT FILE*
SWIGINTERNINLINE FILE*
SWIG_AsFilePtr(PyObject *obj) {
FILE *val = 0;
SWIG_AsValFilePtr(obj, &val);
@ -37,7 +37,7 @@ SWIG_AsFilePtr(PyObject *obj) {
}
%fragment("SWIG_CheckFilePtr","header",fragment="SWIG_AsValFilePtr") {
SWIGINTERNSHORT int
SWIGINTERNINLINE int
SWIG_CheckFilePtr(PyObject *obj) {
return SWIG_AsValFilePtr(obj, (FILE **)(0));
}

View file

@ -14,8 +14,8 @@ extern "C" {
# define SWIGINTERN static SWIGUNUSED
#endif
#ifndef SWIGINTERNSHORT
# define SWIGINTERNSHORT SWIGINTERN SWIGINLINE
#ifndef SWIGINTERNINLINE
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
#endif
/*

View file

@ -11,7 +11,7 @@
%define %swig_fromcplx_conv(Type, Real, Imag)
%fragment(SWIG_From_frag(Type),"header")
%{
SWIGINTERNSHORT PyObject*
SWIGINTERNINLINE PyObject*
SWIG_From(Type)(SWIG_cplusplus(const Type&, Type) c)
{
return PyComplex_FromDoubles(Real(c), Imag(c));

View file

@ -140,11 +140,12 @@ namespace swig
return swig::as<T>(item, true);
} catch (std::exception& e) {
char msg[1024];
sprintf(msg,"in sequence element %d", _index);
sprintf(msg,"in sequence element %d ", _index);
if (!PyErr_Occurred()) {
SWIG_type_error(swig::type_name<T>(), item);
}
SWIG_append_errmsg(msg);
SWIG_append_errmsg(e.what());
throw;
}
}

View file

@ -7,7 +7,7 @@
For example, if you add:
%fragment(SWIG_AsVal_frag(int),"header") {
SWIGINTERNSHORT int
SWIGINTERNINLINE int
SWIG_AsVal(int)(PyObject *obj, int *val)
{
<your code here>;

View file

@ -131,7 +131,7 @@ SWIG_Python_newvarlink(void) {
return ((PyObject*) result);
}
static void
static SWIGUNUSED void
SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
swig_varlinkobject *v;
swig_globalvar *gv;

View file

@ -103,7 +103,7 @@ SWIGINTERN int
%fragment("SWIG_CheckUnsignedLongInRange","header",
fragment="<limits.h>") {
SWIGINTERNSHORT int
SWIGINTERNINLINE int
SWIG_CheckUnsignedLongInRange(unsigned long value,
unsigned long max_value,
const char *errmsg)
@ -178,7 +178,7 @@ SWIGINTERN int
%fragment(SWIG_From_frag(long long),"header",
fragment="<limits.h>") {
SWIGINTERNSHORT PyObject*
SWIGINTERNINLINE PyObject*
SWIG_From(long long)(long long value)
{
return ((value < LONG_MIN) || (value > LONG_MAX)) ?
@ -190,7 +190,7 @@ SWIGINTERNSHORT PyObject*
%fragment(SWIG_From_frag(unsigned long long),"header",
fragment="<limits.h>") {
SWIGINTERNSHORT PyObject*
SWIGINTERNINLINE PyObject*
SWIG_From(unsigned long long)(unsigned long long value)
{
return (value > LONG_MAX) ?
@ -254,7 +254,7 @@ SWIGINTERN int
}
%fragment(SWIG_From_frag(unsigned long),"header") {
SWIGINTERNSHORT PyObject*
SWIGINTERNINLINE PyObject*
SWIG_From(unsigned long)(unsigned long value)
{
return (value > LONG_MAX) ?
@ -340,7 +340,7 @@ SWIGINTERN int
return 0;
}
%#else
SWIGINTERNSHORT int
SWIGINTERNINLINE int
SWIG_AsVal(int)(PyObject *obj, int *val)
{
return SWIG_AsVal(long)(obj,(long*)val);
@ -371,7 +371,7 @@ SWIGINTERN int
return 0;
}
%#else
SWIGINTERNSHORT unsigned int
SWIGINTERNINLINE unsigned int
SWIG_AsVal(unsigned int)(PyObject *obj, unsigned int *val)
{
return SWIG_AsVal(unsigned long)(obj,(unsigned long *)val);
@ -491,7 +491,7 @@ SWIGINTERN int
}
%fragment(SWIG_From_frag(char),"header") {
SWIGINTERNSHORT PyObject*
SWIGINTERNINLINE PyObject*
SWIG_From(char)(char c)
{
return PyString_FromStringAndSize(&c,1);
@ -522,7 +522,7 @@ SWIGINTERN int
}
%fragment(SWIG_From_frag(wchar_t),"header") {
SWIGINTERNSHORT PyObject*
SWIGINTERNINLINE PyObject*
SWIG_From(wchar_t)(wchar_t c)
{
return PyUnicode_FromWideChar(&c, 1);
@ -554,7 +554,7 @@ SWIGINTERN int
}
%fragment(SWIG_From_frag(bool),"header") {
SWIGINTERNSHORT PyObject*
SWIGINTERNINLINE PyObject*
SWIG_From(bool)(bool value)
{
PyObject *obj = value ? Py_True : Py_False;

View file

@ -115,7 +115,7 @@
%define %typemap_asptrfrom(CheckCode, AsPtrMeth, FromMeth, AsPtrFrag, FromFrag, Type...)
%fragment(SWIG_AsVal_frag(Type),"header",
fragment=SWIG_AsPtr_frag(Type)) %{
SWIGINTERNSHORT int
SWIGINTERNINLINE int
SWIG_AsVal(Type)(PyObject* obj, Type *val)
{
Type *v = (Type *)0;
@ -130,7 +130,7 @@
%}
%fragment(SWIG_As_frag(Type),"header",
fragment=SWIG_AsVal_frag(Type)) %{
SWIGINTERNSHORT Type
SWIGINTERNINLINE Type
SWIG_As(Type)(PyObject* obj)
{
Type v;

View file

@ -78,7 +78,7 @@ namespace swig {
if (val) {
Type *p = 0;
int res = traits_asptr<Type>::asptr(obj, &p);
if (res && p) {
if ((res != 0) && p) {
typedef typename noconst_traits<Type>::noconst_type noconst_type;
*(const_cast<noconst_type*>(val)) = *p;
if (res == SWIG_NEWOBJ) delete p;

View file

@ -37,7 +37,7 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize)
%fragment("SWIG_AsCharPtr","header",
fragment="SWIG_AsCharPtrAndSize") {
SWIGINTERNSHORT int
SWIGINTERNINLINE int
SWIG_AsCharPtr(PyObject *obj, char **val)
{
if (SWIG_AsCharPtrAndSize(obj, val, (size_t*)(0))) {
@ -134,7 +134,7 @@ SWIG_AsCharArray(PyObject *obj, char *val, size_t size)
}
%fragment("SWIG_FromCharArray","header") {
SWIGINTERNSHORT PyObject *
SWIGINTERNINLINE PyObject *
SWIG_FromCharArray(const char* carray, size_t size)
{
if (size > INT_MAX) {

View file

@ -127,7 +127,7 @@
%define %typemap_asvaln(CheckCode, Type...)
%fragment(SWIG_As_frag(Type),"header",
fragment=SWIG_AsVal_frag(Type)) %{
SWIGINTERNSHORT Type
SWIGINTERNINLINE Type
SWIG_As(Type)(PyObject* obj)
{
Type v;
@ -142,7 +142,7 @@ SWIG_As(Type)(PyObject* obj)
%}
%fragment(SWIG_Check_frag(Type),"header",
fragment=SWIG_AsVal_frag(Type)) %{
SWIGINTERNSHORT int
SWIGINTERNINLINE int
SWIG_Check(Type)(PyObject* obj)
{
return SWIG_AsVal(Type)(obj, (Type*)0);

View file

@ -128,7 +128,7 @@ SWIG_AsWCharArray(PyObject *obj, wchar_t *val, size_t size)
}
%fragment("SWIG_FromWCharArray","header") {
SWIGINTERNSHORT PyObject *
SWIGINTERNINLINE PyObject *
SWIG_FromWCharArray(const wchar_t * carray, size_t size)
{
if (size > INT_MAX) {

View file

@ -38,7 +38,7 @@
%fragment(SWIG_From_frag(std::basic_string<char>),"header",
fragment="SWIG_FromCharArray") {
SWIGINTERNSHORT PyObject*
SWIGINTERNINLINE PyObject*
SWIG_From(std::basic_string<char>)(const std::string& s)
{
return SWIG_FromCharArray(s.data(), s.size());
@ -80,7 +80,7 @@ SWIGINTERN int
%fragment(SWIG_From_frag(std::basic_string<wchar_t>),"header",
fragment="SWIG_FromWCharArray") {
SWIGINTERNSHORT PyObject*
SWIGINTERNINLINE PyObject*
SWIG_From(std::basic_string<wchar_t>)(const std::wstring& s)
{
return SWIG_FromWCharArray(s.data(), s.size());

View file

@ -51,7 +51,7 @@ namespace std
%fragment(SWIG_From_frag(std::string),"header",
fragment="SWIG_FromCharArray") {
SWIGINTERNSHORT PyObject*
SWIGINTERNINLINE PyObject*
SWIG_From(std::string)(const std::string& s)
{
return SWIG_FromCharArray(s.data(), s.size());
@ -65,7 +65,7 @@ SWIGINTERN int
{
std::string* s;
int res = SWIG_AsPtr(std::string)(obj, &s);
if (res && s) {
if ((res != 0) && s) {
if (val) *val = *s;
if (res == SWIG_NEWOBJ) delete s;
return res;

View file

@ -53,7 +53,7 @@ SWIGINTERN int
%fragment(SWIG_From_frag(std::wstring),"header",
fragment="SWIG_FromWCharArray") {
SWIGINTERNSHORT PyObject*
SWIGINTERNINLINE PyObject*
SWIG_From(std::wstring)(const std::wstring& s)
{
return SWIG_FromWCharArray(s.data(), s.size());
@ -68,7 +68,7 @@ SWIGINTERN int
{
std::wstring *s;
int res = SWIG_AsPtr(std::wstring)(obj, &s);
if (res && s) {
if ((res != 0) && s) {
if (val) *val = *s;
if (res == SWIG_NEWOBJ) delete s;
return res;