aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2013-12-23 19:50:41 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2013-12-23 19:50:41 +0000
commit135a7cc558442062ce8d65de834870a71eb30aca (patch)
treec3c68ae61768f9ff18bf72ba6ccff630705f1c49
parent279ebdc0cf655feca4c80c23f115e90ce0470102 (diff)
downloadswig-135a7cc558442062ce8d65de834870a71eb30aca.tar.gz
Beautify director.swg files
Also some comment corrections for Perl
-rw-r--r--Lib/csharp/director.swg9
-rw-r--r--Lib/d/director.swg8
-rw-r--r--Lib/java/director.swg4
-rw-r--r--Lib/ocaml/director.swg33
-rw-r--r--Lib/octave/director.swg15
-rw-r--r--Lib/perl5/director.swg122
-rw-r--r--Lib/php/director.swg85
-rw-r--r--Lib/python/director.swg220
-rw-r--r--Lib/ruby/director.swg195
9 files changed, 287 insertions, 404 deletions
diff --git a/Lib/csharp/director.swg b/Lib/csharp/director.swg
index 7768d8c02..c68c2d98f 100644
--- a/Lib/csharp/director.swg
+++ b/Lib/csharp/director.swg
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
* director.swg
*
- * This file contains support for director classes so that C# proxy
+ * This file contains support for director classes so that C# proxy
* methods can be called from C++.
* ----------------------------------------------------------------------------- */
@@ -23,13 +23,16 @@ namespace Swig {
std::string swig_msg;
public:
- DirectorException(const char* msg) : swig_msg(msg) {
+ DirectorException(const char *msg) : swig_msg(msg) {
}
+
DirectorException(const std::string &msg) : swig_msg(msg) {
}
+
const std::string& what() const {
return swig_msg;
}
+
virtual ~DirectorException() {
}
};
@@ -37,7 +40,7 @@ namespace Swig {
/* Pure virtual method exception */
class DirectorPureVirtualException : public Swig::DirectorException {
public:
- DirectorPureVirtualException(const char* msg) : DirectorException(std::string("Attempt to invoke pure virtual method ") + msg) {
+ DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempt to invoke pure virtual method ") + msg) {
}
};
}
diff --git a/Lib/d/director.swg b/Lib/d/director.swg
index 9692e03c1..d0ef2372b 100644
--- a/Lib/d/director.swg
+++ b/Lib/d/director.swg
@@ -13,6 +13,7 @@
#include <string>
namespace Swig {
+
// Director base class – not used in D directors.
class Director {
};
@@ -23,13 +24,16 @@ namespace Swig {
std::string swig_msg;
public:
- DirectorException(const char* msg) : swig_msg(msg) {
+ DirectorException(const char *msg) : swig_msg(msg) {
}
+
DirectorException(const std::string &msg) : swig_msg(msg) {
}
+
const std::string& what() const {
return swig_msg;
}
+
virtual ~DirectorException() {
}
};
@@ -38,7 +42,7 @@ namespace Swig {
// from D code thorugh the director layer.
class DirectorPureVirtualException : public Swig::DirectorException {
public:
- DirectorPureVirtualException(const char* msg) : DirectorException(std::string("Attempted to invoke pure virtual method ") + msg) {
+ DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempted to invoke pure virtual method ") + msg) {
}
};
}
diff --git a/Lib/java/director.swg b/Lib/java/director.swg
index f9ddbeffe..86880a55e 100644
--- a/Lib/java/director.swg
+++ b/Lib/java/director.swg
@@ -126,7 +126,7 @@ namespace Swig {
#endif
env_status = director_->swig_jvm_->GetEnv((void **)&jenv_, JNI_VERSION_1_2);
#if defined(SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON)
- // Attach a daemon thread to the JVM. Useful when the JVM should not wait for
+ // Attach a daemon thread to the JVM. Useful when the JVM should not wait for
// the thread to exit upon shutdown. Only for jdk-1.4 and later.
director_->swig_jvm_->AttachCurrentThreadAsDaemon(jenv, NULL);
#else
@@ -358,7 +358,7 @@ namespace Swig {
if (throwable && jenv && classname) {
// Exceptions need to be cleared for correct behavior.
- // The caller of ExceptionMatches should restore pending exceptions if desired -
+ // The caller of ExceptionMatches should restore pending exceptions if desired -
// the caller already has the throwable.
jenv->ExceptionClear();
diff --git a/Lib/ocaml/director.swg b/Lib/ocaml/director.swg
index 77b2fd3c0..dc4c69b7d 100644
--- a/Lib/ocaml/director.swg
+++ b/Lib/ocaml/director.swg
@@ -18,18 +18,21 @@ namespace Swig {
protected:
std::string swig_msg;
public:
- DirectorException(const char* msg="") {
+ DirectorException(const char *msg="") {
}
- const char *getMessage() const {
- return swig_msg.c_str();
+
+ const char *getMessage() const {
+ return swig_msg.c_str();
+ }
+
+ virtual ~DirectorException() {
}
- virtual ~DirectorException() {}
};
/* type mismatch in the return value from a python method call */
class DirectorTypeMismatchException : public Swig::DirectorException {
public:
- DirectorTypeMismatchException(const char* msg="") {
+ DirectorTypeMismatchException(const char *msg="") {
}
};
@@ -39,7 +42,7 @@ namespace Swig {
/* attempt to call a pure virtual method via a director method */
class DirectorPureVirtualException : public Swig::DirectorException {
public:
- DirectorPureVirtualException(const char* msg="") {
+ DirectorPureVirtualException(const char *msg="") {
}
static void raise(const char *msg) {
@@ -57,7 +60,7 @@ namespace Swig {
#define MUTEX_INIT(var) CRITICAL_SECTION var
#else
#include <pthread.h>
-#define MUTEX_INIT(var) pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER
+#define MUTEX_INIT(var) pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER
#endif
#endif
@@ -78,23 +81,21 @@ namespace Swig {
/* discard our reference at destruction */
virtual ~Director() {
remove_global_root(&swig_self);
- swig_disown();
- // Disown is safe here because we're just divorcing a reference that
- // points to us.
+ swig_disown();
+ // Disown is safe here because we're just divorcing a reference that points to us.
}
/* return a pointer to the wrapped ocaml object */
- CAML_VALUE swig_get_self() const {
+ CAML_VALUE swig_get_self() const {
return swig_self;
}
- /* acquire ownership of the wrapped ocaml object (the sense of "disown"
- * is from ocaml) */
- void swig_disown() const {
- if (!swig_disown_flag) {
+ /* acquire ownership of the wrapped ocaml object (the sense of "disown" is from ocaml) */
+ void swig_disown() const {
+ if (!swig_disown_flag) {
swig_disown_flag=true;
callback(*caml_named_value("caml_obj_disown"),swig_self);
- }
+ }
}
};
}
diff --git a/Lib/octave/director.swg b/Lib/octave/director.swg
index 5e5d6f1f4..ce4377ef1 100644
--- a/Lib/octave/director.swg
+++ b/Lib/octave/director.swg
@@ -1,3 +1,10 @@
+/* -----------------------------------------------------------------------------
+ * director.swg
+ *
+ * This file contains support for director classes so that D proxy
+ * methods can be called from C++.
+ * ----------------------------------------------------------------------------- */
+
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
@@ -62,7 +69,7 @@ namespace Swig {
}
};
- SWIGINTERN rtdir_map* get_rtdir_map() {
+ SWIGINTERN rtdir_map *get_rtdir_map() {
static swig_module_info *module = 0;
if (!module)
module = SWIG_GetModule(0);
@@ -74,19 +81,19 @@ namespace Swig {
}
SWIGINTERNINLINE void set_rtdir(void *vptr, Director *d) {
- rtdir_map* rm = get_rtdir_map();
+ rtdir_map *rm = get_rtdir_map();
if (rm)
(*rm)[vptr] = d;
}
SWIGINTERNINLINE void erase_rtdir(void *vptr) {
- rtdir_map* rm = get_rtdir_map();
+ rtdir_map *rm = get_rtdir_map();
if (rm)
(*rm).erase(vptr);
}
SWIGINTERNINLINE Director *get_rtdir(void *vptr) {
- rtdir_map* rm = get_rtdir_map();
+ rtdir_map *rm = get_rtdir_map();
if (!rm)
return 0;
rtdir_map::const_iterator pos = rm->find(vptr);
diff --git a/Lib/perl5/director.swg b/Lib/perl5/director.swg
index 34514972a..0e7faee6c 100644
--- a/Lib/perl5/director.swg
+++ b/Lib/perl5/director.swg
@@ -2,7 +2,7 @@
* director.swg
*
* This file contains support for director classes that proxy
- * method calls from C++ to Python extensions.
+ * method calls from C++ to Perl extensions.
* ----------------------------------------------------------------------------- */
#ifndef SWIG_DIRECTOR_PERL_HEADER_
@@ -67,37 +67,30 @@ extern "C" {
namespace Swig {
/* memory handler */
- struct GCItem
- {
+ struct GCItem {
virtual ~GCItem() {}
- virtual int get_own() const
- {
+ virtual int get_own() const {
return 0;
}
};
- struct GCItem_var
- {
- GCItem_var(GCItem *item = 0) : _item(item)
- {
+ struct GCItem_var {
+ GCItem_var(GCItem *item = 0) : _item(item) {
}
- GCItem_var& operator=(GCItem *item)
- {
+ GCItem_var& operator=(GCItem *item) {
GCItem *tmp = _item;
_item = item;
delete tmp;
return *this;
}
- ~GCItem_var()
- {
+ ~GCItem_var() {
delete _item;
}
- GCItem * operator->() const
- {
+ GCItem *operator->() const {
return _item;
}
@@ -105,18 +98,14 @@ namespace Swig {
GCItem *_item;
};
- struct GCItem_Object : GCItem
- {
- GCItem_Object(int own) : _own(own)
- {
+ struct GCItem_Object : GCItem {
+ GCItem_Object(int own) : _own(own) {
}
- virtual ~GCItem_Object()
- {
+ virtual ~GCItem_Object() {
}
- int get_own() const
- {
+ int get_own() const {
return _own;
}
@@ -125,14 +114,11 @@ namespace Swig {
};
template <typename Type>
- struct GCItem_T : GCItem
- {
- GCItem_T(Type *ptr) : _ptr(ptr)
- {
+ struct GCItem_T : GCItem {
+ GCItem_T(Type *ptr) : _ptr(ptr) {
}
- virtual ~GCItem_T()
- {
+ virtual ~GCItem_T() {
delete _ptr;
}
@@ -141,14 +127,11 @@ namespace Swig {
};
template <typename Type>
- struct GCArray_T : GCItem
- {
- GCArray_T(Type *ptr) : _ptr(ptr)
- {
+ struct GCArray_T : GCItem {
+ GCArray_T(Type *ptr) : _ptr(ptr) {
}
- virtual ~GCArray_T()
- {
+ virtual ~GCArray_T() {
delete[] _ptr;
}
@@ -162,30 +145,29 @@ namespace Swig {
virtual const char *getMessage() const = 0;
virtual SV *getNative() const = 0;
};
+
/* exceptions emitted by Perl */
class DirectorMethodException : public Swig::DirectorException {
protected:
SV *err;
public:
- DirectorMethodException(SV *sv = sv_mortalcopy(ERRSV))
- : err(sv)
- {
+ DirectorMethodException(SV *sv = sv_mortalcopy(ERRSV)) : err(sv) {
SvREFCNT_inc(err);
}
- ~DirectorMethodException()
- {
+
+ ~DirectorMethodException() {
SvREFCNT_dec(err);
}
- const char *getMessage() const
- {
+
+ const char *getMessage() const {
return SvPV_nolen(err);
}
- SV *getNative() const
- {
+
+ SV *getNative() const {
return sv_2mortal(newSVsv(err));
}
- static void raise(SV *sv)
- {
+
+ static void raise(SV *sv) {
throw DirectorMethodException(sv);
}
};
@@ -193,42 +175,38 @@ namespace Swig {
class DirectorWrapException : public Swig::DirectorException {
protected:
std::string msg;
- DirectorWrapException(const char *str)
- : msg(str)
- {
+ DirectorWrapException(const char *str) : msg(str) {
}
+
public:
- virtual const char *getMessage() const
- {
+ virtual const char *getMessage() const {
return msg.c_str();
}
+
virtual SV *getNative() const {
return sv_2mortal(newSVpvn(msg.data(), msg.size()));
}
};
+
class DirectorTypeMismatchException : public Swig::DirectorWrapException {
public:
- DirectorTypeMismatchException(const char *str)
- : DirectorWrapException(str)
- {
+ DirectorTypeMismatchException(const char *str) : DirectorWrapException(str) {
}
- static void raise(const char *type, const char *msg)
- {
+ static void raise(const char *type, const char *msg) {
std::string err = std::string(type);
err += ": ";
err += msg;
throw DirectorTypeMismatchException(err.c_str());
}
};
+
class DirectorPureVirtualException : public Swig::DirectorWrapException {
public:
DirectorPureVirtualException(const char *name)
- : DirectorWrapException("SWIG director pure virtual method called: ")
- {
+ : DirectorWrapException("SWIG director pure virtual method called: ") {
msg += name;
}
- static void raise(const char *name)
- {
+ static void raise(const char *name) {
throw DirectorPureVirtualException(name);
}
};
@@ -251,7 +229,7 @@ namespace Swig {
}
public:
- /* wrap a python object, optionally taking ownership */
+ /* wrap a Perl object, optionally taking ownership */
Director(SV *pkg) : swig_disown_flag(false) {
STRLEN len;
char *str = SvPV(pkg, len);
@@ -260,14 +238,12 @@ namespace Swig {
swig_incref();
}
-
/* discard our reference at destruction */
virtual ~Director() {
swig_decref();
}
-
- /* return a pointer to the wrapped python object */
+ /* return a pointer to the wrapped Perl object */
SV *swig_get_self() const {
return swig_self;
}
@@ -276,8 +252,7 @@ namespace Swig {
return swig_class.c_str();
}
- /* acquire ownership of the wrapped python object (the sense of "disown"
- * is from python) */
+ /* acquire ownership of the wrapped Perl object (the sense of "disown" is from perl) */
void swig_disown() const {
if (!swig_disown_flag) {
swig_disown_flag=true;
@@ -285,7 +260,7 @@ namespace Swig {
}
}
- /* increase the reference count of the wrapped python object */
+ /* increase the reference count of the wrapped Perl object */
void swig_incref() const {
if (swig_disown_flag) {
SvREFCNT_inc(swig_self);
@@ -307,30 +282,26 @@ namespace Swig {
public:
template <typename Type>
- void swig_acquire_ownership_array(Type *vptr) const
- {
+ void swig_acquire_ownership_array(Type *vptr) const {
if (vptr) {
swig_owner[vptr] = new GCArray_T<Type>(vptr);
}
}
template <typename Type>
- void swig_acquire_ownership(Type *vptr) const
- {
+ void swig_acquire_ownership(Type *vptr) const {
if (vptr) {
swig_owner[vptr] = new GCItem_T<Type>(vptr);
}
}
- void swig_acquire_ownership_obj(void *vptr, int own) const
- {
+ void swig_acquire_ownership_obj(void *vptr, int own) const {
if (vptr && own) {
swig_owner[vptr] = new GCItem_Object(own);
}
}
- int swig_release_ownership(void *vptr) const
- {
+ int swig_release_ownership(void *vptr) const {
int own = 0;
if (vptr) {
swig_ownership_map::iterator iter = swig_owner.find(vptr);
@@ -341,7 +312,6 @@ namespace Swig {
}
return own;
}
-
};
}
diff --git a/Lib/php/director.swg b/Lib/php/director.swg
index 90f6a74a2..b864cff84 100644
--- a/Lib/php/director.swg
+++ b/Lib/php/director.swg
@@ -23,38 +23,33 @@
#endif
namespace Swig {
+
/* memory handler */
- struct GCItem
- {
- virtual ~GCItem() {}
+ struct GCItem {
+ virtual ~GCItem() {
+ }
- virtual int get_own() const
- {
+ virtual int get_own() const {
return 0;
}
};
- struct GCItem_var
- {
- GCItem_var(GCItem *item = 0) : _item(item)
- {
+ struct GCItem_var {
+ GCItem_var(GCItem *item = 0) : _item(item) {
}
- GCItem_var& operator=(GCItem *item)
- {
+ GCItem_var& operator=(GCItem *item) {
GCItem *tmp = _item;
_item = item;
delete tmp;
return *this;
}
- ~GCItem_var()
- {
+ ~GCItem_var() {
delete _item;
}
- GCItem * operator->() const
- {
+ GCItem * operator->() const {
return _item;
}
@@ -62,18 +57,14 @@ namespace Swig {
GCItem *_item;
};
- struct GCItem_Object : GCItem
- {
- GCItem_Object(int own) : _own(own)
- {
+ struct GCItem_Object : GCItem {
+ GCItem_Object(int own) : _own(own) {
}
- virtual ~GCItem_Object()
- {
+ virtual ~GCItem_Object() {
}
- int get_own() const
- {
+ int get_own() const {
return _own;
}
@@ -82,14 +73,11 @@ namespace Swig {
};
template <typename Type>
- struct GCItem_T : GCItem
- {
- GCItem_T(Type *ptr) : _ptr(ptr)
- {
+ struct GCItem_T : GCItem {
+ GCItem_T(Type *ptr) : _ptr(ptr) {
}
- virtual ~GCItem_T()
- {
+ virtual ~GCItem_T() {
delete _ptr;
}
@@ -100,14 +88,14 @@ namespace Swig {
class Director {
protected:
zval *swig_self;
- typedef std::map<void*, GCItem_var> swig_ownership_map;
+ typedef std::map<void *, GCItem_var> swig_ownership_map;
mutable swig_ownership_map swig_owner;
#ifdef ZTS
// Store the ZTS context so it's available when C++ calls back to PHP.
void *** swig_zts_ctx;
-#endif
+#endif
public:
- Director(zval* self TSRMLS_DC) : swig_self(self) {
+ Director(zval *self TSRMLS_DC) : swig_self(self) {
TSRMLS_SET_CTX(swig_zts_ctx);
}
@@ -116,11 +104,11 @@ namespace Swig {
zend_class_entry **ce;
zend_function *mptr;
int name_len = strlen(lc_fname);
-
+
if (zend_lookup_class(cname, strlen(cname), &ce TSRMLS_CC) != SUCCESS) {
return false;
}
- if (zend_hash_find(&(*ce)->function_table, lc_fname, name_len + 1, (void**) &mptr) != SUCCESS) {
+ if (zend_hash_find(&(*ce)->function_table, lc_fname, name_len + 1, (void **) &mptr) != SUCCESS) {
return false;
}
// common.scope points to the declaring class
@@ -128,8 +116,7 @@ namespace Swig {
}
template <typename Type>
- void swig_acquire_ownership(Type *vptr) const
- {
+ void swig_acquire_ownership(Type *vptr) const {
if (vptr) {
swig_owner[vptr] = new GCItem_T<Type>(vptr);
}
@@ -141,9 +128,7 @@ namespace Swig {
protected:
std::string swig_msg;
public:
- DirectorException(int code, const char *hdr, const char* msg TSRMLS_DC)
- : swig_msg(hdr)
- {
+ DirectorException(int code, const char *hdr, const char *msg TSRMLS_DC) : swig_msg(hdr) {
if (strlen(msg)) {
swig_msg += " ";
swig_msg += msg;
@@ -152,23 +137,19 @@ namespace Swig {
SWIG_ErrorMsg() = swig_msg.c_str();
}
- static void raise(int code, const char *hdr, const char* msg TSRMLS_DC)
- {
+ static void raise(int code, const char *hdr, const char *msg TSRMLS_DC) {
throw DirectorException(code, hdr, msg TSRMLS_CC);
}
};
/* attempt to call a pure virtual method via a director method */
- class DirectorPureVirtualException : public Swig::DirectorException
- {
+ class DirectorPureVirtualException : public Swig::DirectorException {
public:
- DirectorPureVirtualException(const char* msg TSRMLS_DC)
- : DirectorException(E_ERROR, "SWIG director pure virtual method called", msg TSRMLS_CC)
- {
+ DirectorPureVirtualException(const char *msg TSRMLS_DC)
+ : DirectorException(E_ERROR, "SWIG director pure virtual method called", msg TSRMLS_CC) {
}
- static void raise(const char *msg TSRMLS_DC)
- {
+ static void raise(const char *msg TSRMLS_DC) {
throw DirectorPureVirtualException(msg TSRMLS_CC);
}
};
@@ -176,13 +157,11 @@ namespace Swig {
class DirectorMethodException : public Swig::DirectorException
{
public:
- DirectorMethodException(const char* msg TSRMLS_DC)
- : DirectorException(E_ERROR, "SWIG director method error", msg TSRMLS_CC)
- {
+ DirectorMethodException(const char *msg TSRMLS_DC)
+ : DirectorException(E_ERROR, "SWIG director method error", msg TSRMLS_CC) {
}
- static void raise(const char *msg TSRMLS_DC)
- {
+ static void raise(const char *msg TSRMLS_DC) {
throw DirectorMethodException(msg TSRMLS_CC);
}
};
diff --git a/Lib/python/director.swg b/Lib/python/director.swg
index d6bfe51f0..baa72c664 100644
--- a/Lib/python/director.swg
+++ b/Lib/python/director.swg
@@ -58,7 +58,7 @@
could stop working when using this option.
*/
#ifdef SWIG_DIRECTOR_NORTTI
-/*
+/*
When we don't use the native C++ RTTI, we implement a minimal one
only for Directors.
*/
@@ -99,94 +99,77 @@ extern "C" {
struct swig_type_info;
}
-namespace Swig {
+namespace Swig {
/* memory handler */
- struct GCItem
- {
+ struct GCItem {
virtual ~GCItem() {}
- virtual int get_own() const
- {
+ virtual int get_own() const {
return 0;
}
};
- struct GCItem_var
- {
- GCItem_var(GCItem *item = 0) : _item(item)
- {
+ struct GCItem_var {
+ GCItem_var(GCItem *item = 0) : _item(item) {
}
- GCItem_var& operator=(GCItem *item)
- {
+ GCItem_var& operator=(GCItem *item) {
GCItem *tmp = _item;
_item = item;
delete tmp;
return *this;
}
- ~GCItem_var()
- {
+ ~GCItem_var() {
delete _item;
}
-
- GCItem * operator->() const
- {
+
+ GCItem * operator->() const {
return _item;
}
-
+
private:
GCItem *_item;
};
-
- struct GCItem_Object : GCItem
- {
- GCItem_Object(int own) : _own(own)
- {
+
+ struct GCItem_Object : GCItem {
+ GCItem_Object(int own) : _own(own) {
}
-
- virtual ~GCItem_Object()
- {
+
+ virtual ~GCItem_Object() {
}
- int get_own() const
- {
+ int get_own() const {
return _own;
}
-
+
private:
int _own;
};
template <typename Type>
- struct GCItem_T : GCItem
- {
- GCItem_T(Type *ptr) : _ptr(ptr)
- {
- }
-
- virtual ~GCItem_T()
- {
+ struct GCItem_T : GCItem {
+ GCItem_T(Type *ptr) : _ptr(ptr) {
+ }
+
+ virtual ~GCItem_T() {
delete _ptr;
}
-
+
private:
Type *_ptr;
};
template <typename Type>
- struct GCArray_T : GCItem
- {
- GCArray_T(Type *ptr) : _ptr(ptr)
- {
- }
-
- virtual ~GCArray_T()
- {
+ struct GCArray_T : GCItem {
+ GCArray_T(Type *ptr) : _ptr(ptr) {
+ }
+
+ virtual ~GCArray_T() {
delete[] _ptr;
}
-
+
private:
Type *_ptr;
};
@@ -196,10 +179,8 @@ namespace Swig {
protected:
std::string swig_msg;
public:
- DirectorException(PyObject *error, const char *hdr ="", const char *msg ="")
- : swig_msg(hdr)
- {
- SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ DirectorException(PyObject *error, const char *hdr ="", const char *msg ="") : swig_msg(hdr) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
if (strlen(msg)) {
swig_msg += " ";
swig_msg += msg;
@@ -207,30 +188,26 @@ namespace Swig {
if (!PyErr_Occurred()) {
PyErr_SetString(error, getMessage());
}
- SWIG_PYTHON_THREAD_END_BLOCK;
+ SWIG_PYTHON_THREAD_END_BLOCK;
}
- const char *getMessage() const
- {
- return swig_msg.c_str();
+ const char *getMessage() const {
+ return swig_msg.c_str();
}
- static void raise(PyObject *error, const char *msg)
- {
+ static void raise(PyObject *error, const char *msg) {
throw DirectorException(error, msg);
}
- static void raise(const char *msg)
- {
+ static void raise(const char *msg) {
raise(PyExc_RuntimeError, msg);
}
};
/* unknown exception handler */
- class UnknownExceptionHandler
- {
+ class UnknownExceptionHandler {
#ifdef SWIG_DIRECTOR_UEH
- static void handler() {
+ static void handler() {
try {
throw;
} catch (DirectorException& e) {
@@ -241,12 +218,12 @@ namespace Swig {
} catch (...) {
std::cerr << "Unknown exception caught." << std::endl;
}
-
+
std::cerr << std::endl
<< "Python interpreter traceback:" << std::endl;
PyErr_Print();
std::cerr << std::endl;
-
+
std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl
<< "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl
<< std::endl
@@ -255,15 +232,13 @@ namespace Swig {
}
public:
-
+
std::unexpected_handler old;
- UnknownExceptionHandler(std::unexpected_handler nh = handler)
- {
+ UnknownExceptionHandler(std::unexpected_handler nh = handler) {
old = std::set_unexpected(nh);
}
- ~UnknownExceptionHandler()
- {
+ ~UnknownExceptionHandler() {
std::set_unexpected(old);
}
#endif
@@ -272,23 +247,19 @@ namespace Swig {
/* type mismatch in the return value from a python method call */
class DirectorTypeMismatchException : public Swig::DirectorException {
public:
- DirectorTypeMismatchException(PyObject *error, const char *msg="")
- : Swig::DirectorException(error, "SWIG director type mismatch", msg)
- {
+ DirectorTypeMismatchException(PyObject *error, const char *msg="")
+ : Swig::DirectorException(error, "SWIG director type mismatch", msg) {
}
- DirectorTypeMismatchException(const char *msg="")
- : Swig::DirectorException(PyExc_TypeError, "SWIG director type mismatch", msg)
- {
+ DirectorTypeMismatchException(const char *msg="")
+ : Swig::DirectorException(PyExc_TypeError, "SWIG director type mismatch", msg) {
}
- static void raise(PyObject *error, const char *msg)
- {
+ static void raise(PyObject *error, const char *msg) {
throw DirectorTypeMismatchException(error, msg);
}
- static void raise(const char *msg)
- {
+ static void raise(const char *msg) {
throw DirectorTypeMismatchException(msg);
}
};
@@ -296,28 +267,23 @@ namespace Swig {
/* any python exception that occurs during a director method call */
class DirectorMethodException : public Swig::DirectorException {
public:
- DirectorMethodException(const char *msg = "")
- : DirectorException(PyExc_RuntimeError, "SWIG director method error.", msg)
- {
- }
+ DirectorMethodException(const char *msg = "")
+ : DirectorException(PyExc_RuntimeError, "SWIG director method error.", msg) {
+ }
- static void raise(const char *msg)
- {
+ static void raise(const char *msg) {
throw DirectorMethodException(msg);
}
};
/* attempt to call a pure virtual method via a director method */
- class DirectorPureVirtualException : public Swig::DirectorException
- {
+ class DirectorPureVirtualException : public Swig::DirectorException {
public:
- DirectorPureVirtualException(const char *msg = "")
- : DirectorException(PyExc_RuntimeError, "SWIG director pure virtual method called", msg)
- {
+ DirectorPureVirtualException(const char *msg = "")
+ : DirectorException(PyExc_RuntimeError, "SWIG director pure virtual method called", msg) {
}
- static void raise(const char *msg)
- {
+ static void raise(const char *msg) {
throw DirectorPureVirtualException(msg);
}
};
@@ -332,24 +298,21 @@ namespace Swig {
#ifdef __THREAD__
# include "pythread.h"
- class Guard
- {
- PyThread_type_lock & mutex_;
-
+ class Guard {
+ PyThread_type_lock &mutex_;
+
public:
- Guard(PyThread_type_lock & mutex) : mutex_(mutex)
- {
+ Guard(PyThread_type_lock & mutex) : mutex_(mutex) {
PyThread_acquire_lock(mutex_, WAIT_LOCK);
}
-
- ~Guard()
- {
+
+ ~Guard() {
PyThread_release_lock(mutex_);
}
};
# define SWIG_GUARD(mutex) Guard _guard(mutex)
#else
-# define SWIG_GUARD(mutex)
+# define SWIG_GUARD(mutex)
#endif
/* director base class */
@@ -361,11 +324,11 @@ namespace Swig {
mutable bool swig_disown_flag;
/* decrement the reference count of the wrapped python object */
- void swig_decref() const {
+ void swig_decref() const {
if (swig_disown_flag) {
- SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- Py_DECREF(swig_self);
- SWIG_PYTHON_THREAD_END_BLOCK;
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ Py_DECREF(swig_self);
+ SWIG_PYTHON_THREAD_END_BLOCK;
}
}
@@ -375,31 +338,28 @@ namespace Swig {
swig_incref();
}
-
/* discard our reference at destruction */
virtual ~Director() {
- swig_decref();
+ swig_decref();
}
-
/* return a pointer to the wrapped python object */
- PyObject *swig_get_self() const {
- return swig_self;
+ PyObject *swig_get_self() const {
+ return swig_self;
}
- /* acquire ownership of the wrapped python object (the sense of "disown"
- * is from python) */
- void swig_disown() const {
- if (!swig_disown_flag) {
+ /* 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();
- }
+ swig_incref();
+ }
}
/* increase the reference count of the wrapped python object */
- void swig_incref() const {
+ void swig_incref() const {
if (swig_disown_flag) {
- Py_INCREF(swig_self);
+ Py_INCREF(swig_self);
}
}
@@ -407,7 +367,7 @@ namespace Swig {
virtual bool swig_get_inner(const char * /* swig_protected_method_name */) const {
return true;
}
-
+
virtual void swig_set_inner(const char * /* swig_protected_method_name */, bool /* swig_val */) const {
}
@@ -421,33 +381,29 @@ namespace Swig {
public:
template <typename Type>
- void swig_acquire_ownership_array(Type *vptr) const
- {
+ void swig_acquire_ownership_array(Type *vptr) const {
if (vptr) {
SWIG_GUARD(swig_mutex_own);
swig_owner[vptr] = new GCArray_T<Type>(vptr);
}
}
-
+
template <typename Type>
- void swig_acquire_ownership(Type *vptr) const
- {
+ void swig_acquire_ownership(Type *vptr) const {
if (vptr) {
SWIG_GUARD(swig_mutex_own);
swig_owner[vptr] = new GCItem_T<Type>(vptr);
}
}
- void swig_acquire_ownership_obj(void *vptr, int own) const
- {
+ void swig_acquire_ownership_obj(void *vptr, int own) const {
if (vptr && own) {
SWIG_GUARD(swig_mutex_own);
swig_owner[vptr] = new GCItem_Object(own);
}
}
-
- int swig_release_ownership(void *vptr) const
- {
+
+ int swig_release_ownership(void *vptr) const {
int own = 0;
if (vptr) {
SWIG_GUARD(swig_mutex_own);
@@ -461,8 +417,7 @@ namespace Swig {
}
template <typename Type>
- static PyObject *swig_pyobj_disown(PyObject *pyobj, PyObject *SWIGUNUSEDPARM(args))
- {
+ static PyObject *swig_pyobj_disown(PyObject *pyobj, PyObject *SWIGUNUSEDPARM(args)) {
SwigPyObject *sobj = (SwigPyObject *)pyobj;
sobj->own = 0;
Director *d = SWIG_DIRECTOR_CAST(reinterpret_cast<Type *>(sobj->ptr));
@@ -470,7 +425,6 @@ namespace Swig {
d->swig_disown();
return PyWeakref_NewProxy(pyobj, NULL);
}
-
};
#ifdef __THREAD__
diff --git a/Lib/ruby/director.swg b/Lib/ruby/director.swg
index a5daf2176..360344f6c 100644
--- a/Lib/ruby/director.swg
+++ b/Lib/ruby/director.swg
@@ -24,96 +24,78 @@
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
namespace Swig {
+
/* memory handler */
- struct GCItem
- {
- virtual ~GCItem()
- {
+ struct GCItem {
+ virtual ~GCItem() {
}
- virtual ruby_owntype get_own() const
- {
+ virtual ruby_owntype get_own() const {
return 0;
}
};
-
- struct GCItem_var
- {
- GCItem_var(GCItem *item = 0) : _item(item)
- {
+
+ struct GCItem_var {
+ GCItem_var(GCItem *item = 0) : _item(item) {
}
- GCItem_var& operator=(GCItem *item)
- {
+ GCItem_var& operator=(GCItem *item) {
GCItem *tmp = _item;
_item = item;
delete tmp;
return *this;
}
-
- ~GCItem_var()
- {
+
+ ~GCItem_var() {
delete _item;
}
-
- GCItem * operator->() const
- {
+
+ GCItem *operator->() const {
return _item;
}
-
+
private:
GCItem *_item;
};
template <typename Type>
- struct GCItem_T : GCItem
- {
- GCItem_T(Type *ptr) : _ptr(ptr)
- {
+ struct GCItem_T : GCItem {
+ GCItem_T(Type *ptr) : _ptr(ptr) {
}
-
- virtual ~GCItem_T()
- {
+
+ virtual ~GCItem_T() {
delete _ptr;
}
-
+
private:
Type *_ptr;
};
- struct GCItem_Object : GCItem
- {
- GCItem_Object(ruby_owntype own) : _own(own)
- {
+ struct GCItem_Object : GCItem {
+ GCItem_Object(ruby_owntype own) : _own(own) {
}
-
- virtual ~GCItem_Object()
- {
+
+ virtual ~GCItem_Object() {
}
- ruby_owntype get_own() const
- {
+ ruby_owntype get_own() const {
return _own;
}
-
+
private:
ruby_owntype _own;
};
-
template <typename Type>
- struct GCArray_T : GCItem
- {
- GCArray_T(Type *ptr) : _ptr(ptr)
- {
+ struct GCArray_T : GCItem {
+ GCArray_T(Type *ptr) : _ptr(ptr) {
}
-
- virtual ~GCArray_T()
- {
+
+ virtual ~GCArray_T() {
delete[] _ptr;
}
-
+
private:
Type *_ptr;
};
@@ -126,20 +108,17 @@ namespace Swig {
int argc;
VALUE *argv;
};
-
+
/* Base class for director exceptions */
class DirectorException {
protected:
VALUE swig_error;
std::string swig_msg;
protected:
- DirectorException(VALUE error)
- : swig_error(error)
- {
+ DirectorException(VALUE error) : swig_error(error) {
}
-
- DirectorException(VALUE error, const char* hdr, const char* msg ="")
- : swig_error(error), swig_msg(hdr) {
+
+ DirectorException(VALUE error, const char *hdr, const char *msg ="") : swig_error(error), swig_msg(hdr) {
if (strlen(msg)) {
swig_msg += " ";
swig_msg += msg;
@@ -151,25 +130,26 @@ namespace Swig {
swig_error = error;
}
}
+
public:
- VALUE getType() const {
- return CLASS_OF(swig_error);
+ VALUE getType() const {
+ return CLASS_OF(swig_error);
}
+
VALUE getError() const {
return swig_error;
}
- const std::string& getMessage() const
- {
+
+ const std::string& getMessage() const {
return swig_msg;
}
-
- virtual ~DirectorException() {}
+
+ virtual ~DirectorException() {
+ }
};
-
- /* unknown exception handler */
- class UnknownExceptionHandler
- {
+ /* unknown exception handler */
+ class UnknownExceptionHandler {
#ifdef SWIG_DIRECTOR_UEH
static void handler() {
try {
@@ -181,26 +161,24 @@ namespace Swig {
std::cerr << "std::exception caught: "<< e.what() << std::endl;
} catch (...) {
std::cerr << "Unknown exception caught." << std::endl;
- }
+ }
std::cerr << std::endl
<< "Ruby interpreter traceback:" << std::endl;
- std::cerr << std::endl;
+ std::cerr << std::endl;
std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl
<< "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl
<< std::endl
<< "Exception is being re-thrown, program will like abort/terminate." << std::endl;
throw;
}
-
- public:
+
+ public:
std::unexpected_handler old;
- UnknownExceptionHandler(std::unexpected_handler nh = handler)
- {
+ UnknownExceptionHandler(std::unexpected_handler nh = handler) {
old = std::set_unexpected(nh);
}
- ~UnknownExceptionHandler()
- {
+ ~UnknownExceptionHandler() {
std::set_unexpected(old);
}
#endif
@@ -211,13 +189,11 @@ namespace Swig {
class DirectorTypeMismatchException : public Swig::DirectorException {
public:
DirectorTypeMismatchException(VALUE error, const char *msg="")
- : Swig::DirectorException(error, "SWIG director type mismatch", msg)
- {
+ : Swig::DirectorException(error, "SWIG director type mismatch", msg) {
}
DirectorTypeMismatchException(const char *msg="")
- : Swig::DirectorException(rb_eTypeError, "SWIG director type mismatch", msg)
- {
+ : Swig::DirectorException(rb_eTypeError, "SWIG director type mismatch", msg) {
}
static void raise(VALUE error, const char *msg) {
@@ -232,31 +208,28 @@ namespace Swig {
/* Any Ruby exception that occurs during a director method call */
class DirectorMethodException : public Swig::DirectorException {
public:
- DirectorMethodException(VALUE error)
+ DirectorMethodException(VALUE error)
: Swig::DirectorException(error) {
}
- DirectorMethodException(const char* msg = "")
+ DirectorMethodException(const char *msg = "")
: Swig::DirectorException(rb_eRuntimeError, "SWIG director method error.", msg) {
}
-
- static void raise(VALUE error)
- {
+
+ static void raise(VALUE error) {
throw DirectorMethodException(error);
- }
+ }
};
/* Attempted to call a pure virtual method via a director method */
class DirectorPureVirtualException : public Swig::DirectorException
{
public:
- DirectorPureVirtualException(const char* msg = "")
- : DirectorException(rb_eRuntimeError, "SWIG director pure virtual method called", msg)
- {
+ DirectorPureVirtualException(const char *msg = "")
+ : DirectorException(rb_eRuntimeError, "SWIG director pure virtual method called", msg) {
}
- static void raise(const char *msg)
- {
+ static void raise(const char *msg) {
throw DirectorPureVirtualException(msg);
}
};
@@ -271,28 +244,25 @@ namespace Swig {
# define SWIG_MUTEX_INIT(var) var
# else
# include <pthread.h>
-# define SWIG_MUTEX_INIT(var) var = PTHREAD_MUTEX_INITIALIZER
+# define SWIG_MUTEX_INIT(var) var = PTHREAD_MUTEX_INITIALIZER
# endif
#endif
#ifdef __PTHREAD__
- struct Guard
- {
+ struct Guard {
pthread_mutex_t *_mutex;
-
- Guard(pthread_mutex_t &mutex) : _mutex(&mutex)
- {
+
+ Guard(pthread_mutex_t &mutex) : _mutex(&mutex) {
pthread_mutex_lock(_mutex);
}
-
- ~Guard()
- {
+
+ ~Guard() {
pthread_mutex_unlock(_mutex);
}
};
# define SWIG_GUARD(mutex) Guard _guard(mutex)
#else
-# define SWIG_GUARD(mutex)
+# define SWIG_GUARD(mutex)
#endif
/* director base class */
@@ -313,21 +283,20 @@ namespace Swig {
}
/* return a pointer to the wrapped Ruby object */
- VALUE swig_get_self() const {
- return swig_self;
+ VALUE swig_get_self() const {
+ return swig_self;
}
- /* acquire ownership of the wrapped Ruby object (the sense of "disown"
- * is from Ruby) */
- void swig_disown() const {
- if (!swig_disown_flag) {
+ /* acquire ownership of the wrapped Ruby object (the sense of "disown" is from Ruby) */
+ void swig_disown() const {
+ if (!swig_disown_flag) {
swig_disown_flag = true;
- }
+ }
}
/* ownership management */
private:
- typedef std::map<void*, GCItem_var> swig_ownership_map;
+ typedef std::map<void *, GCItem_var> swig_ownership_map;
mutable swig_ownership_map swig_owner;
#ifdef __PTHREAD__
static pthread_mutex_t swig_mutex_own;
@@ -335,33 +304,29 @@ namespace Swig {
public:
template <typename Type>
- void swig_acquire_ownership_array(Type *vptr) const
- {
+ void swig_acquire_ownership_array(Type *vptr) const {
if (vptr) {
SWIG_GUARD(swig_mutex_own);
swig_owner[vptr] = new GCArray_T<Type>(vptr);
}
}
-
+
template <typename Type>
- void swig_acquire_ownership(Type *vptr) const
- {
+ void swig_acquire_ownership(Type *vptr) const {
if (vptr) {
SWIG_GUARD(swig_mutex_own);
swig_owner[vptr] = new GCItem_T<Type>(vptr);
}
}
- void swig_acquire_ownership_obj(void *vptr, ruby_owntype own) const
- {
+ void swig_acquire_ownership_obj(void *vptr, ruby_owntype own) const {
if (vptr && own) {
SWIG_GUARD(swig_mutex_own);
swig_owner[vptr] = new GCItem_Object(own);
}
}
-
- ruby_owntype swig_release_ownership(void *vptr) const
- {
+
+ ruby_owntype swig_release_ownership(void *vptr) const {
ruby_owntype own = 0;
if (vptr) {
SWIG_GUARD(swig_mutex_own);