Beautify director.swg files
Also some comment corrections for Perl
This commit is contained in:
parent
279ebdc0cf
commit
135a7cc558
9 changed files with 289 additions and 406 deletions
|
|
@ -23,13 +23,16 @@ namespace Swig {
|
||||||
std::string swig_msg;
|
std::string swig_msg;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DirectorException(const char* msg) : swig_msg(msg) {
|
DirectorException(const char *msg) : swig_msg(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectorException(const std::string &msg) : swig_msg(msg) {
|
DirectorException(const std::string &msg) : swig_msg(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& what() const {
|
const std::string& what() const {
|
||||||
return swig_msg;
|
return swig_msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~DirectorException() {
|
virtual ~DirectorException() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -37,7 +40,7 @@ namespace Swig {
|
||||||
/* Pure virtual method exception */
|
/* Pure virtual method exception */
|
||||||
class DirectorPureVirtualException : public Swig::DirectorException {
|
class DirectorPureVirtualException : public Swig::DirectorException {
|
||||||
public:
|
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) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Swig {
|
namespace Swig {
|
||||||
|
|
||||||
// Director base class – not used in D directors.
|
// Director base class – not used in D directors.
|
||||||
class Director {
|
class Director {
|
||||||
};
|
};
|
||||||
|
|
@ -23,13 +24,16 @@ namespace Swig {
|
||||||
std::string swig_msg;
|
std::string swig_msg;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DirectorException(const char* msg) : swig_msg(msg) {
|
DirectorException(const char *msg) : swig_msg(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectorException(const std::string &msg) : swig_msg(msg) {
|
DirectorException(const std::string &msg) : swig_msg(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& what() const {
|
const std::string& what() const {
|
||||||
return swig_msg;
|
return swig_msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~DirectorException() {
|
virtual ~DirectorException() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -38,7 +42,7 @@ namespace Swig {
|
||||||
// from D code thorugh the director layer.
|
// from D code thorugh the director layer.
|
||||||
class DirectorPureVirtualException : public Swig::DirectorException {
|
class DirectorPureVirtualException : public Swig::DirectorException {
|
||||||
public:
|
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) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,18 +18,21 @@ namespace Swig {
|
||||||
protected:
|
protected:
|
||||||
std::string swig_msg;
|
std::string swig_msg;
|
||||||
public:
|
public:
|
||||||
DirectorException(const char* msg="") {
|
DirectorException(const char *msg="") {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getMessage() const {
|
const char *getMessage() const {
|
||||||
return swig_msg.c_str();
|
return swig_msg.c_str();
|
||||||
}
|
}
|
||||||
virtual ~DirectorException() {}
|
|
||||||
|
virtual ~DirectorException() {
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* type mismatch in the return value from a python method call */
|
/* type mismatch in the return value from a python method call */
|
||||||
class DirectorTypeMismatchException : public Swig::DirectorException {
|
class DirectorTypeMismatchException : public Swig::DirectorException {
|
||||||
public:
|
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 */
|
/* attempt to call a pure virtual method via a director method */
|
||||||
class DirectorPureVirtualException : public Swig::DirectorException {
|
class DirectorPureVirtualException : public Swig::DirectorException {
|
||||||
public:
|
public:
|
||||||
DirectorPureVirtualException(const char* msg="") {
|
DirectorPureVirtualException(const char *msg="") {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void raise(const char *msg) {
|
static void raise(const char *msg) {
|
||||||
|
|
@ -79,8 +82,7 @@ namespace Swig {
|
||||||
virtual ~Director() {
|
virtual ~Director() {
|
||||||
remove_global_root(&swig_self);
|
remove_global_root(&swig_self);
|
||||||
swig_disown();
|
swig_disown();
|
||||||
// Disown is safe here because we're just divorcing a reference that
|
// Disown is safe here because we're just divorcing a reference that points to us.
|
||||||
// points to us.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return a pointer to the wrapped ocaml object */
|
/* return a pointer to the wrapped ocaml object */
|
||||||
|
|
@ -88,8 +90,7 @@ namespace Swig {
|
||||||
return swig_self;
|
return swig_self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* acquire ownership of the wrapped ocaml object (the sense of "disown"
|
/* acquire ownership of the wrapped ocaml object (the sense of "disown" is from ocaml) */
|
||||||
* is from ocaml) */
|
|
||||||
void swig_disown() const {
|
void swig_disown() const {
|
||||||
if (!swig_disown_flag) {
|
if (!swig_disown_flag) {
|
||||||
swig_disown_flag=true;
|
swig_disown_flag=true;
|
||||||
|
|
|
||||||
|
|
@ -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)
|
# 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;
|
static swig_module_info *module = 0;
|
||||||
if (!module)
|
if (!module)
|
||||||
module = SWIG_GetModule(0);
|
module = SWIG_GetModule(0);
|
||||||
|
|
@ -74,19 +81,19 @@ namespace Swig {
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIGINTERNINLINE void set_rtdir(void *vptr, Director *d) {
|
SWIGINTERNINLINE void set_rtdir(void *vptr, Director *d) {
|
||||||
rtdir_map* rm = get_rtdir_map();
|
rtdir_map *rm = get_rtdir_map();
|
||||||
if (rm)
|
if (rm)
|
||||||
(*rm)[vptr] = d;
|
(*rm)[vptr] = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIGINTERNINLINE void erase_rtdir(void *vptr) {
|
SWIGINTERNINLINE void erase_rtdir(void *vptr) {
|
||||||
rtdir_map* rm = get_rtdir_map();
|
rtdir_map *rm = get_rtdir_map();
|
||||||
if (rm)
|
if (rm)
|
||||||
(*rm).erase(vptr);
|
(*rm).erase(vptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIGINTERNINLINE Director *get_rtdir(void *vptr) {
|
SWIGINTERNINLINE Director *get_rtdir(void *vptr) {
|
||||||
rtdir_map* rm = get_rtdir_map();
|
rtdir_map *rm = get_rtdir_map();
|
||||||
if (!rm)
|
if (!rm)
|
||||||
return 0;
|
return 0;
|
||||||
rtdir_map::const_iterator pos = rm->find(vptr);
|
rtdir_map::const_iterator pos = rm->find(vptr);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
* director.swg
|
* director.swg
|
||||||
*
|
*
|
||||||
* This file contains support for director classes that proxy
|
* 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_
|
#ifndef SWIG_DIRECTOR_PERL_HEADER_
|
||||||
|
|
@ -67,37 +67,30 @@ extern "C" {
|
||||||
namespace Swig {
|
namespace Swig {
|
||||||
|
|
||||||
/* memory handler */
|
/* memory handler */
|
||||||
struct GCItem
|
struct GCItem {
|
||||||
{
|
|
||||||
virtual ~GCItem() {}
|
virtual ~GCItem() {}
|
||||||
|
|
||||||
virtual int get_own() const
|
virtual int get_own() const {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GCItem_var
|
struct GCItem_var {
|
||||||
{
|
GCItem_var(GCItem *item = 0) : _item(item) {
|
||||||
GCItem_var(GCItem *item = 0) : _item(item)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GCItem_var& operator=(GCItem *item)
|
GCItem_var& operator=(GCItem *item) {
|
||||||
{
|
|
||||||
GCItem *tmp = _item;
|
GCItem *tmp = _item;
|
||||||
_item = item;
|
_item = item;
|
||||||
delete tmp;
|
delete tmp;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
~GCItem_var()
|
~GCItem_var() {
|
||||||
{
|
|
||||||
delete _item;
|
delete _item;
|
||||||
}
|
}
|
||||||
|
|
||||||
GCItem * operator->() const
|
GCItem *operator->() const {
|
||||||
{
|
|
||||||
return _item;
|
return _item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,18 +98,14 @@ namespace Swig {
|
||||||
GCItem *_item;
|
GCItem *_item;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GCItem_Object : GCItem
|
struct GCItem_Object : GCItem {
|
||||||
{
|
GCItem_Object(int own) : _own(own) {
|
||||||
GCItem_Object(int own) : _own(own)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~GCItem_Object()
|
virtual ~GCItem_Object() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_own() const
|
int get_own() const {
|
||||||
{
|
|
||||||
return _own;
|
return _own;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,14 +114,11 @@ namespace Swig {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
struct GCItem_T : GCItem
|
struct GCItem_T : GCItem {
|
||||||
{
|
GCItem_T(Type *ptr) : _ptr(ptr) {
|
||||||
GCItem_T(Type *ptr) : _ptr(ptr)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~GCItem_T()
|
virtual ~GCItem_T() {
|
||||||
{
|
|
||||||
delete _ptr;
|
delete _ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,14 +127,11 @@ namespace Swig {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
struct GCArray_T : GCItem
|
struct GCArray_T : GCItem {
|
||||||
{
|
GCArray_T(Type *ptr) : _ptr(ptr) {
|
||||||
GCArray_T(Type *ptr) : _ptr(ptr)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~GCArray_T()
|
virtual ~GCArray_T() {
|
||||||
{
|
|
||||||
delete[] _ptr;
|
delete[] _ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,30 +145,29 @@ namespace Swig {
|
||||||
virtual const char *getMessage() const = 0;
|
virtual const char *getMessage() const = 0;
|
||||||
virtual SV *getNative() const = 0;
|
virtual SV *getNative() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* exceptions emitted by Perl */
|
/* exceptions emitted by Perl */
|
||||||
class DirectorMethodException : public Swig::DirectorException {
|
class DirectorMethodException : public Swig::DirectorException {
|
||||||
protected:
|
protected:
|
||||||
SV *err;
|
SV *err;
|
||||||
public:
|
public:
|
||||||
DirectorMethodException(SV *sv = sv_mortalcopy(ERRSV))
|
DirectorMethodException(SV *sv = sv_mortalcopy(ERRSV)) : err(sv) {
|
||||||
: err(sv)
|
|
||||||
{
|
|
||||||
SvREFCNT_inc(err);
|
SvREFCNT_inc(err);
|
||||||
}
|
}
|
||||||
~DirectorMethodException()
|
|
||||||
{
|
~DirectorMethodException() {
|
||||||
SvREFCNT_dec(err);
|
SvREFCNT_dec(err);
|
||||||
}
|
}
|
||||||
const char *getMessage() const
|
|
||||||
{
|
const char *getMessage() const {
|
||||||
return SvPV_nolen(err);
|
return SvPV_nolen(err);
|
||||||
}
|
}
|
||||||
SV *getNative() const
|
|
||||||
{
|
SV *getNative() const {
|
||||||
return sv_2mortal(newSVsv(err));
|
return sv_2mortal(newSVsv(err));
|
||||||
}
|
}
|
||||||
static void raise(SV *sv)
|
|
||||||
{
|
static void raise(SV *sv) {
|
||||||
throw DirectorMethodException(sv);
|
throw DirectorMethodException(sv);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -193,42 +175,38 @@ namespace Swig {
|
||||||
class DirectorWrapException : public Swig::DirectorException {
|
class DirectorWrapException : public Swig::DirectorException {
|
||||||
protected:
|
protected:
|
||||||
std::string msg;
|
std::string msg;
|
||||||
DirectorWrapException(const char *str)
|
DirectorWrapException(const char *str) : msg(str) {
|
||||||
: msg(str)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual const char *getMessage() const
|
virtual const char *getMessage() const {
|
||||||
{
|
|
||||||
return msg.c_str();
|
return msg.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual SV *getNative() const {
|
virtual SV *getNative() const {
|
||||||
return sv_2mortal(newSVpvn(msg.data(), msg.size()));
|
return sv_2mortal(newSVpvn(msg.data(), msg.size()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DirectorTypeMismatchException : public Swig::DirectorWrapException {
|
class DirectorTypeMismatchException : public Swig::DirectorWrapException {
|
||||||
public:
|
public:
|
||||||
DirectorTypeMismatchException(const char *str)
|
DirectorTypeMismatchException(const char *str) : DirectorWrapException(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);
|
std::string err = std::string(type);
|
||||||
err += ": ";
|
err += ": ";
|
||||||
err += msg;
|
err += msg;
|
||||||
throw DirectorTypeMismatchException(err.c_str());
|
throw DirectorTypeMismatchException(err.c_str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DirectorPureVirtualException : public Swig::DirectorWrapException {
|
class DirectorPureVirtualException : public Swig::DirectorWrapException {
|
||||||
public:
|
public:
|
||||||
DirectorPureVirtualException(const char *name)
|
DirectorPureVirtualException(const char *name)
|
||||||
: DirectorWrapException("SWIG director pure virtual method called: ")
|
: DirectorWrapException("SWIG director pure virtual method called: ") {
|
||||||
{
|
|
||||||
msg += name;
|
msg += name;
|
||||||
}
|
}
|
||||||
static void raise(const char *name)
|
static void raise(const char *name) {
|
||||||
{
|
|
||||||
throw DirectorPureVirtualException(name);
|
throw DirectorPureVirtualException(name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -251,7 +229,7 @@ namespace Swig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* wrap a python object, optionally taking ownership */
|
/* wrap a Perl object, optionally taking ownership */
|
||||||
Director(SV *pkg) : swig_disown_flag(false) {
|
Director(SV *pkg) : swig_disown_flag(false) {
|
||||||
STRLEN len;
|
STRLEN len;
|
||||||
char *str = SvPV(pkg, len);
|
char *str = SvPV(pkg, len);
|
||||||
|
|
@ -260,14 +238,12 @@ namespace Swig {
|
||||||
swig_incref();
|
swig_incref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* discard our reference at destruction */
|
/* discard our reference at destruction */
|
||||||
virtual ~Director() {
|
virtual ~Director() {
|
||||||
swig_decref();
|
swig_decref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* return a pointer to the wrapped Perl object */
|
||||||
/* return a pointer to the wrapped python object */
|
|
||||||
SV *swig_get_self() const {
|
SV *swig_get_self() const {
|
||||||
return swig_self;
|
return swig_self;
|
||||||
}
|
}
|
||||||
|
|
@ -276,8 +252,7 @@ namespace Swig {
|
||||||
return swig_class.c_str();
|
return swig_class.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* acquire ownership of the wrapped python object (the sense of "disown"
|
/* acquire ownership of the wrapped Perl object (the sense of "disown" is from perl) */
|
||||||
* is from python) */
|
|
||||||
void swig_disown() const {
|
void swig_disown() const {
|
||||||
if (!swig_disown_flag) {
|
if (!swig_disown_flag) {
|
||||||
swig_disown_flag=true;
|
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 {
|
void swig_incref() const {
|
||||||
if (swig_disown_flag) {
|
if (swig_disown_flag) {
|
||||||
SvREFCNT_inc(swig_self);
|
SvREFCNT_inc(swig_self);
|
||||||
|
|
@ -307,30 +282,26 @@ namespace Swig {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void swig_acquire_ownership_array(Type *vptr) const
|
void swig_acquire_ownership_array(Type *vptr) const {
|
||||||
{
|
|
||||||
if (vptr) {
|
if (vptr) {
|
||||||
swig_owner[vptr] = new GCArray_T<Type>(vptr);
|
swig_owner[vptr] = new GCArray_T<Type>(vptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void swig_acquire_ownership(Type *vptr) const
|
void swig_acquire_ownership(Type *vptr) const {
|
||||||
{
|
|
||||||
if (vptr) {
|
if (vptr) {
|
||||||
swig_owner[vptr] = new GCItem_T<Type>(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) {
|
if (vptr && own) {
|
||||||
swig_owner[vptr] = new GCItem_Object(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;
|
int own = 0;
|
||||||
if (vptr) {
|
if (vptr) {
|
||||||
swig_ownership_map::iterator iter = swig_owner.find(vptr);
|
swig_ownership_map::iterator iter = swig_owner.find(vptr);
|
||||||
|
|
@ -341,7 +312,6 @@ namespace Swig {
|
||||||
}
|
}
|
||||||
return own;
|
return own;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,38 +23,33 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Swig {
|
namespace Swig {
|
||||||
/* memory handler */
|
|
||||||
struct GCItem
|
|
||||||
{
|
|
||||||
virtual ~GCItem() {}
|
|
||||||
|
|
||||||
virtual int get_own() const
|
/* memory handler */
|
||||||
{
|
struct GCItem {
|
||||||
|
virtual ~GCItem() {
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int get_own() const {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GCItem_var
|
struct GCItem_var {
|
||||||
{
|
GCItem_var(GCItem *item = 0) : _item(item) {
|
||||||
GCItem_var(GCItem *item = 0) : _item(item)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GCItem_var& operator=(GCItem *item)
|
GCItem_var& operator=(GCItem *item) {
|
||||||
{
|
|
||||||
GCItem *tmp = _item;
|
GCItem *tmp = _item;
|
||||||
_item = item;
|
_item = item;
|
||||||
delete tmp;
|
delete tmp;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
~GCItem_var()
|
~GCItem_var() {
|
||||||
{
|
|
||||||
delete _item;
|
delete _item;
|
||||||
}
|
}
|
||||||
|
|
||||||
GCItem * operator->() const
|
GCItem * operator->() const {
|
||||||
{
|
|
||||||
return _item;
|
return _item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,18 +57,14 @@ namespace Swig {
|
||||||
GCItem *_item;
|
GCItem *_item;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GCItem_Object : GCItem
|
struct GCItem_Object : GCItem {
|
||||||
{
|
GCItem_Object(int own) : _own(own) {
|
||||||
GCItem_Object(int own) : _own(own)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~GCItem_Object()
|
virtual ~GCItem_Object() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_own() const
|
int get_own() const {
|
||||||
{
|
|
||||||
return _own;
|
return _own;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,14 +73,11 @@ namespace Swig {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
struct GCItem_T : GCItem
|
struct GCItem_T : GCItem {
|
||||||
{
|
GCItem_T(Type *ptr) : _ptr(ptr) {
|
||||||
GCItem_T(Type *ptr) : _ptr(ptr)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~GCItem_T()
|
virtual ~GCItem_T() {
|
||||||
{
|
|
||||||
delete _ptr;
|
delete _ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,14 +88,14 @@ namespace Swig {
|
||||||
class Director {
|
class Director {
|
||||||
protected:
|
protected:
|
||||||
zval *swig_self;
|
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;
|
mutable swig_ownership_map swig_owner;
|
||||||
#ifdef ZTS
|
#ifdef ZTS
|
||||||
// Store the ZTS context so it's available when C++ calls back to PHP.
|
// Store the ZTS context so it's available when C++ calls back to PHP.
|
||||||
void *** swig_zts_ctx;
|
void *** swig_zts_ctx;
|
||||||
#endif
|
#endif
|
||||||
public:
|
public:
|
||||||
Director(zval* self TSRMLS_DC) : swig_self(self) {
|
Director(zval *self TSRMLS_DC) : swig_self(self) {
|
||||||
TSRMLS_SET_CTX(swig_zts_ctx);
|
TSRMLS_SET_CTX(swig_zts_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,7 +108,7 @@ namespace Swig {
|
||||||
if (zend_lookup_class(cname, strlen(cname), &ce TSRMLS_CC) != SUCCESS) {
|
if (zend_lookup_class(cname, strlen(cname), &ce TSRMLS_CC) != SUCCESS) {
|
||||||
return false;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
// common.scope points to the declaring class
|
// common.scope points to the declaring class
|
||||||
|
|
@ -128,8 +116,7 @@ namespace Swig {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void swig_acquire_ownership(Type *vptr) const
|
void swig_acquire_ownership(Type *vptr) const {
|
||||||
{
|
|
||||||
if (vptr) {
|
if (vptr) {
|
||||||
swig_owner[vptr] = new GCItem_T<Type>(vptr);
|
swig_owner[vptr] = new GCItem_T<Type>(vptr);
|
||||||
}
|
}
|
||||||
|
|
@ -141,9 +128,7 @@ namespace Swig {
|
||||||
protected:
|
protected:
|
||||||
std::string swig_msg;
|
std::string swig_msg;
|
||||||
public:
|
public:
|
||||||
DirectorException(int code, const char *hdr, const char* msg TSRMLS_DC)
|
DirectorException(int code, const char *hdr, const char *msg TSRMLS_DC) : swig_msg(hdr) {
|
||||||
: swig_msg(hdr)
|
|
||||||
{
|
|
||||||
if (strlen(msg)) {
|
if (strlen(msg)) {
|
||||||
swig_msg += " ";
|
swig_msg += " ";
|
||||||
swig_msg += msg;
|
swig_msg += msg;
|
||||||
|
|
@ -152,23 +137,19 @@ namespace Swig {
|
||||||
SWIG_ErrorMsg() = swig_msg.c_str();
|
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);
|
throw DirectorException(code, hdr, msg TSRMLS_CC);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* attempt to call a pure virtual method via a director method */
|
/* attempt to call a pure virtual method via a director method */
|
||||||
class DirectorPureVirtualException : public Swig::DirectorException
|
class DirectorPureVirtualException : public Swig::DirectorException {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
DirectorPureVirtualException(const char* msg TSRMLS_DC)
|
DirectorPureVirtualException(const char *msg TSRMLS_DC)
|
||||||
: DirectorException(E_ERROR, "SWIG director pure virtual method called", msg TSRMLS_CC)
|
: 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);
|
throw DirectorPureVirtualException(msg TSRMLS_CC);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -176,13 +157,11 @@ namespace Swig {
|
||||||
class DirectorMethodException : public Swig::DirectorException
|
class DirectorMethodException : public Swig::DirectorException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DirectorMethodException(const char* msg TSRMLS_DC)
|
DirectorMethodException(const char *msg TSRMLS_DC)
|
||||||
: DirectorException(E_ERROR, "SWIG director method error", msg TSRMLS_CC)
|
: 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);
|
throw DirectorMethodException(msg TSRMLS_CC);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -102,37 +102,30 @@ extern "C" {
|
||||||
namespace Swig {
|
namespace Swig {
|
||||||
|
|
||||||
/* memory handler */
|
/* memory handler */
|
||||||
struct GCItem
|
struct GCItem {
|
||||||
{
|
|
||||||
virtual ~GCItem() {}
|
virtual ~GCItem() {}
|
||||||
|
|
||||||
virtual int get_own() const
|
virtual int get_own() const {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GCItem_var
|
struct GCItem_var {
|
||||||
{
|
GCItem_var(GCItem *item = 0) : _item(item) {
|
||||||
GCItem_var(GCItem *item = 0) : _item(item)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GCItem_var& operator=(GCItem *item)
|
GCItem_var& operator=(GCItem *item) {
|
||||||
{
|
|
||||||
GCItem *tmp = _item;
|
GCItem *tmp = _item;
|
||||||
_item = item;
|
_item = item;
|
||||||
delete tmp;
|
delete tmp;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
~GCItem_var()
|
~GCItem_var() {
|
||||||
{
|
|
||||||
delete _item;
|
delete _item;
|
||||||
}
|
}
|
||||||
|
|
||||||
GCItem * operator->() const
|
GCItem * operator->() const {
|
||||||
{
|
|
||||||
return _item;
|
return _item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,18 +133,14 @@ namespace Swig {
|
||||||
GCItem *_item;
|
GCItem *_item;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GCItem_Object : GCItem
|
struct GCItem_Object : GCItem {
|
||||||
{
|
GCItem_Object(int own) : _own(own) {
|
||||||
GCItem_Object(int own) : _own(own)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~GCItem_Object()
|
virtual ~GCItem_Object() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_own() const
|
int get_own() const {
|
||||||
{
|
|
||||||
return _own;
|
return _own;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -160,14 +149,11 @@ namespace Swig {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
struct GCItem_T : GCItem
|
struct GCItem_T : GCItem {
|
||||||
{
|
GCItem_T(Type *ptr) : _ptr(ptr) {
|
||||||
GCItem_T(Type *ptr) : _ptr(ptr)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~GCItem_T()
|
virtual ~GCItem_T() {
|
||||||
{
|
|
||||||
delete _ptr;
|
delete _ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,14 +162,11 @@ namespace Swig {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
struct GCArray_T : GCItem
|
struct GCArray_T : GCItem {
|
||||||
{
|
GCArray_T(Type *ptr) : _ptr(ptr) {
|
||||||
GCArray_T(Type *ptr) : _ptr(ptr)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~GCArray_T()
|
virtual ~GCArray_T() {
|
||||||
{
|
|
||||||
delete[] _ptr;
|
delete[] _ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,9 +179,7 @@ namespace Swig {
|
||||||
protected:
|
protected:
|
||||||
std::string swig_msg;
|
std::string swig_msg;
|
||||||
public:
|
public:
|
||||||
DirectorException(PyObject *error, const char *hdr ="", const char *msg ="")
|
DirectorException(PyObject *error, const char *hdr ="", const char *msg ="") : swig_msg(hdr) {
|
||||||
: swig_msg(hdr)
|
|
||||||
{
|
|
||||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||||
if (strlen(msg)) {
|
if (strlen(msg)) {
|
||||||
swig_msg += " ";
|
swig_msg += " ";
|
||||||
|
|
@ -210,27 +191,23 @@ namespace Swig {
|
||||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getMessage() const
|
const char *getMessage() const {
|
||||||
{
|
|
||||||
return swig_msg.c_str();
|
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);
|
throw DirectorException(error, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void raise(const char *msg)
|
static void raise(const char *msg) {
|
||||||
{
|
|
||||||
raise(PyExc_RuntimeError, msg);
|
raise(PyExc_RuntimeError, msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* unknown exception handler */
|
/* unknown exception handler */
|
||||||
class UnknownExceptionHandler
|
class UnknownExceptionHandler {
|
||||||
{
|
|
||||||
#ifdef SWIG_DIRECTOR_UEH
|
#ifdef SWIG_DIRECTOR_UEH
|
||||||
static void handler() {
|
static void handler() {
|
||||||
try {
|
try {
|
||||||
throw;
|
throw;
|
||||||
} catch (DirectorException& e) {
|
} catch (DirectorException& e) {
|
||||||
|
|
@ -257,13 +234,11 @@ namespace Swig {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
std::unexpected_handler old;
|
std::unexpected_handler old;
|
||||||
UnknownExceptionHandler(std::unexpected_handler nh = handler)
|
UnknownExceptionHandler(std::unexpected_handler nh = handler) {
|
||||||
{
|
|
||||||
old = std::set_unexpected(nh);
|
old = std::set_unexpected(nh);
|
||||||
}
|
}
|
||||||
|
|
||||||
~UnknownExceptionHandler()
|
~UnknownExceptionHandler() {
|
||||||
{
|
|
||||||
std::set_unexpected(old);
|
std::set_unexpected(old);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -273,22 +248,18 @@ namespace Swig {
|
||||||
class DirectorTypeMismatchException : public Swig::DirectorException {
|
class DirectorTypeMismatchException : public Swig::DirectorException {
|
||||||
public:
|
public:
|
||||||
DirectorTypeMismatchException(PyObject *error, const char *msg="")
|
DirectorTypeMismatchException(PyObject *error, const char *msg="")
|
||||||
: Swig::DirectorException(error, "SWIG director type mismatch", msg)
|
: Swig::DirectorException(error, "SWIG director type mismatch", msg) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectorTypeMismatchException(const char *msg="")
|
DirectorTypeMismatchException(const char *msg="")
|
||||||
: Swig::DirectorException(PyExc_TypeError, "SWIG director type mismatch", 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);
|
throw DirectorTypeMismatchException(error, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void raise(const char *msg)
|
static void raise(const char *msg) {
|
||||||
{
|
|
||||||
throw DirectorTypeMismatchException(msg);
|
throw DirectorTypeMismatchException(msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -297,27 +268,22 @@ namespace Swig {
|
||||||
class DirectorMethodException : public Swig::DirectorException {
|
class DirectorMethodException : public Swig::DirectorException {
|
||||||
public:
|
public:
|
||||||
DirectorMethodException(const char *msg = "")
|
DirectorMethodException(const char *msg = "")
|
||||||
: DirectorException(PyExc_RuntimeError, "SWIG director method error.", msg)
|
: DirectorException(PyExc_RuntimeError, "SWIG director method error.", msg) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void raise(const char *msg)
|
static void raise(const char *msg) {
|
||||||
{
|
|
||||||
throw DirectorMethodException(msg);
|
throw DirectorMethodException(msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* attempt to call a pure virtual method via a director method */
|
/* attempt to call a pure virtual method via a director method */
|
||||||
class DirectorPureVirtualException : public Swig::DirectorException
|
class DirectorPureVirtualException : public Swig::DirectorException {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
DirectorPureVirtualException(const char *msg = "")
|
DirectorPureVirtualException(const char *msg = "")
|
||||||
: DirectorException(PyExc_RuntimeError, "SWIG director pure virtual method called", 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);
|
throw DirectorPureVirtualException(msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -332,18 +298,15 @@ namespace Swig {
|
||||||
|
|
||||||
#ifdef __THREAD__
|
#ifdef __THREAD__
|
||||||
# include "pythread.h"
|
# include "pythread.h"
|
||||||
class Guard
|
class Guard {
|
||||||
{
|
PyThread_type_lock &mutex_;
|
||||||
PyThread_type_lock & mutex_;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Guard(PyThread_type_lock & mutex) : mutex_(mutex)
|
Guard(PyThread_type_lock & mutex) : mutex_(mutex) {
|
||||||
{
|
|
||||||
PyThread_acquire_lock(mutex_, WAIT_LOCK);
|
PyThread_acquire_lock(mutex_, WAIT_LOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Guard()
|
~Guard() {
|
||||||
{
|
|
||||||
PyThread_release_lock(mutex_);
|
PyThread_release_lock(mutex_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -375,20 +338,17 @@ namespace Swig {
|
||||||
swig_incref();
|
swig_incref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* discard our reference at destruction */
|
/* discard our reference at destruction */
|
||||||
virtual ~Director() {
|
virtual ~Director() {
|
||||||
swig_decref();
|
swig_decref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* return a pointer to the wrapped python object */
|
/* return a pointer to the wrapped python object */
|
||||||
PyObject *swig_get_self() const {
|
PyObject *swig_get_self() const {
|
||||||
return swig_self;
|
return swig_self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* acquire ownership of the wrapped python object (the sense of "disown"
|
/* acquire ownership of the wrapped python object (the sense of "disown" is from python) */
|
||||||
* is from python) */
|
|
||||||
void swig_disown() const {
|
void swig_disown() const {
|
||||||
if (!swig_disown_flag) {
|
if (!swig_disown_flag) {
|
||||||
swig_disown_flag=true;
|
swig_disown_flag=true;
|
||||||
|
|
@ -421,8 +381,7 @@ namespace Swig {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void swig_acquire_ownership_array(Type *vptr) const
|
void swig_acquire_ownership_array(Type *vptr) const {
|
||||||
{
|
|
||||||
if (vptr) {
|
if (vptr) {
|
||||||
SWIG_GUARD(swig_mutex_own);
|
SWIG_GUARD(swig_mutex_own);
|
||||||
swig_owner[vptr] = new GCArray_T<Type>(vptr);
|
swig_owner[vptr] = new GCArray_T<Type>(vptr);
|
||||||
|
|
@ -430,24 +389,21 @@ namespace Swig {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void swig_acquire_ownership(Type *vptr) const
|
void swig_acquire_ownership(Type *vptr) const {
|
||||||
{
|
|
||||||
if (vptr) {
|
if (vptr) {
|
||||||
SWIG_GUARD(swig_mutex_own);
|
SWIG_GUARD(swig_mutex_own);
|
||||||
swig_owner[vptr] = new GCItem_T<Type>(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) {
|
if (vptr && own) {
|
||||||
SWIG_GUARD(swig_mutex_own);
|
SWIG_GUARD(swig_mutex_own);
|
||||||
swig_owner[vptr] = new GCItem_Object(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;
|
int own = 0;
|
||||||
if (vptr) {
|
if (vptr) {
|
||||||
SWIG_GUARD(swig_mutex_own);
|
SWIG_GUARD(swig_mutex_own);
|
||||||
|
|
@ -461,8 +417,7 @@ namespace Swig {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
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;
|
SwigPyObject *sobj = (SwigPyObject *)pyobj;
|
||||||
sobj->own = 0;
|
sobj->own = 0;
|
||||||
Director *d = SWIG_DIRECTOR_CAST(reinterpret_cast<Type *>(sobj->ptr));
|
Director *d = SWIG_DIRECTOR_CAST(reinterpret_cast<Type *>(sobj->ptr));
|
||||||
|
|
@ -470,7 +425,6 @@ namespace Swig {
|
||||||
d->swig_disown();
|
d->swig_disown();
|
||||||
return PyWeakref_NewProxy(pyobj, NULL);
|
return PyWeakref_NewProxy(pyobj, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __THREAD__
|
#ifdef __THREAD__
|
||||||
|
|
|
||||||
|
|
@ -24,40 +24,33 @@
|
||||||
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
|
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
|
||||||
|
|
||||||
namespace Swig {
|
namespace Swig {
|
||||||
|
|
||||||
/* memory handler */
|
/* memory handler */
|
||||||
struct GCItem
|
struct GCItem {
|
||||||
{
|
virtual ~GCItem() {
|
||||||
virtual ~GCItem()
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ruby_owntype get_own() const
|
virtual ruby_owntype get_own() const {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GCItem_var
|
struct GCItem_var {
|
||||||
{
|
GCItem_var(GCItem *item = 0) : _item(item) {
|
||||||
GCItem_var(GCItem *item = 0) : _item(item)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GCItem_var& operator=(GCItem *item)
|
GCItem_var& operator=(GCItem *item) {
|
||||||
{
|
|
||||||
GCItem *tmp = _item;
|
GCItem *tmp = _item;
|
||||||
_item = item;
|
_item = item;
|
||||||
delete tmp;
|
delete tmp;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
~GCItem_var()
|
~GCItem_var() {
|
||||||
{
|
|
||||||
delete _item;
|
delete _item;
|
||||||
}
|
}
|
||||||
|
|
||||||
GCItem * operator->() const
|
GCItem *operator->() const {
|
||||||
{
|
|
||||||
return _item;
|
return _item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,14 +60,11 @@ namespace Swig {
|
||||||
|
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
struct GCItem_T : GCItem
|
struct GCItem_T : GCItem {
|
||||||
{
|
GCItem_T(Type *ptr) : _ptr(ptr) {
|
||||||
GCItem_T(Type *ptr) : _ptr(ptr)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~GCItem_T()
|
virtual ~GCItem_T() {
|
||||||
{
|
|
||||||
delete _ptr;
|
delete _ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,18 +72,14 @@ namespace Swig {
|
||||||
Type *_ptr;
|
Type *_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GCItem_Object : GCItem
|
struct GCItem_Object : GCItem {
|
||||||
{
|
GCItem_Object(ruby_owntype own) : _own(own) {
|
||||||
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;
|
return _own;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,16 +87,12 @@ namespace Swig {
|
||||||
ruby_owntype _own;
|
ruby_owntype _own;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
struct GCArray_T : GCItem
|
struct GCArray_T : GCItem {
|
||||||
{
|
GCArray_T(Type *ptr) : _ptr(ptr) {
|
||||||
GCArray_T(Type *ptr) : _ptr(ptr)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~GCArray_T()
|
virtual ~GCArray_T() {
|
||||||
{
|
|
||||||
delete[] _ptr;
|
delete[] _ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,13 +115,10 @@ namespace Swig {
|
||||||
VALUE swig_error;
|
VALUE swig_error;
|
||||||
std::string swig_msg;
|
std::string swig_msg;
|
||||||
protected:
|
protected:
|
||||||
DirectorException(VALUE error)
|
DirectorException(VALUE error) : swig_error(error) {
|
||||||
: swig_error(error)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectorException(VALUE error, const char* hdr, const char* msg ="")
|
DirectorException(VALUE error, const char *hdr, const char *msg ="") : swig_error(error), swig_msg(hdr) {
|
||||||
: swig_error(error), swig_msg(hdr) {
|
|
||||||
if (strlen(msg)) {
|
if (strlen(msg)) {
|
||||||
swig_msg += " ";
|
swig_msg += " ";
|
||||||
swig_msg += msg;
|
swig_msg += msg;
|
||||||
|
|
@ -151,25 +130,26 @@ namespace Swig {
|
||||||
swig_error = error;
|
swig_error = error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VALUE getType() const {
|
VALUE getType() const {
|
||||||
return CLASS_OF(swig_error);
|
return CLASS_OF(swig_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE getError() const {
|
VALUE getError() const {
|
||||||
return swig_error;
|
return swig_error;
|
||||||
}
|
}
|
||||||
const std::string& getMessage() const
|
|
||||||
{
|
const std::string& getMessage() const {
|
||||||
return swig_msg;
|
return swig_msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~DirectorException() {}
|
virtual ~DirectorException() {
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* unknown exception handler */
|
/* unknown exception handler */
|
||||||
|
class UnknownExceptionHandler {
|
||||||
class UnknownExceptionHandler
|
|
||||||
{
|
|
||||||
#ifdef SWIG_DIRECTOR_UEH
|
#ifdef SWIG_DIRECTOR_UEH
|
||||||
static void handler() {
|
static void handler() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -194,13 +174,11 @@ namespace Swig {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::unexpected_handler old;
|
std::unexpected_handler old;
|
||||||
UnknownExceptionHandler(std::unexpected_handler nh = handler)
|
UnknownExceptionHandler(std::unexpected_handler nh = handler) {
|
||||||
{
|
|
||||||
old = std::set_unexpected(nh);
|
old = std::set_unexpected(nh);
|
||||||
}
|
}
|
||||||
|
|
||||||
~UnknownExceptionHandler()
|
~UnknownExceptionHandler() {
|
||||||
{
|
|
||||||
std::set_unexpected(old);
|
std::set_unexpected(old);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -211,13 +189,11 @@ namespace Swig {
|
||||||
class DirectorTypeMismatchException : public Swig::DirectorException {
|
class DirectorTypeMismatchException : public Swig::DirectorException {
|
||||||
public:
|
public:
|
||||||
DirectorTypeMismatchException(VALUE error, const char *msg="")
|
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="")
|
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) {
|
static void raise(VALUE error, const char *msg) {
|
||||||
|
|
@ -236,12 +212,11 @@ namespace Swig {
|
||||||
: Swig::DirectorException(error) {
|
: Swig::DirectorException(error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectorMethodException(const char* msg = "")
|
DirectorMethodException(const char *msg = "")
|
||||||
: Swig::DirectorException(rb_eRuntimeError, "SWIG director method error.", msg) {
|
: Swig::DirectorException(rb_eRuntimeError, "SWIG director method error.", msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void raise(VALUE error)
|
static void raise(VALUE error) {
|
||||||
{
|
|
||||||
throw DirectorMethodException(error);
|
throw DirectorMethodException(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -250,13 +225,11 @@ namespace Swig {
|
||||||
class DirectorPureVirtualException : public Swig::DirectorException
|
class DirectorPureVirtualException : public Swig::DirectorException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DirectorPureVirtualException(const char* msg = "")
|
DirectorPureVirtualException(const char *msg = "")
|
||||||
: DirectorException(rb_eRuntimeError, "SWIG director pure virtual method called", 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);
|
throw DirectorPureVirtualException(msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -276,17 +249,14 @@ namespace Swig {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
struct Guard
|
struct Guard {
|
||||||
{
|
|
||||||
pthread_mutex_t *_mutex;
|
pthread_mutex_t *_mutex;
|
||||||
|
|
||||||
Guard(pthread_mutex_t &mutex) : _mutex(&mutex)
|
Guard(pthread_mutex_t &mutex) : _mutex(&mutex) {
|
||||||
{
|
|
||||||
pthread_mutex_lock(_mutex);
|
pthread_mutex_lock(_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Guard()
|
~Guard() {
|
||||||
{
|
|
||||||
pthread_mutex_unlock(_mutex);
|
pthread_mutex_unlock(_mutex);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -317,8 +287,7 @@ namespace Swig {
|
||||||
return swig_self;
|
return swig_self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* acquire ownership of the wrapped Ruby object (the sense of "disown"
|
/* acquire ownership of the wrapped Ruby object (the sense of "disown" is from Ruby) */
|
||||||
* is from Ruby) */
|
|
||||||
void swig_disown() const {
|
void swig_disown() const {
|
||||||
if (!swig_disown_flag) {
|
if (!swig_disown_flag) {
|
||||||
swig_disown_flag = true;
|
swig_disown_flag = true;
|
||||||
|
|
@ -327,7 +296,7 @@ namespace Swig {
|
||||||
|
|
||||||
/* ownership management */
|
/* ownership management */
|
||||||
private:
|
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;
|
mutable swig_ownership_map swig_owner;
|
||||||
#ifdef __PTHREAD__
|
#ifdef __PTHREAD__
|
||||||
static pthread_mutex_t swig_mutex_own;
|
static pthread_mutex_t swig_mutex_own;
|
||||||
|
|
@ -335,8 +304,7 @@ namespace Swig {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void swig_acquire_ownership_array(Type *vptr) const
|
void swig_acquire_ownership_array(Type *vptr) const {
|
||||||
{
|
|
||||||
if (vptr) {
|
if (vptr) {
|
||||||
SWIG_GUARD(swig_mutex_own);
|
SWIG_GUARD(swig_mutex_own);
|
||||||
swig_owner[vptr] = new GCArray_T<Type>(vptr);
|
swig_owner[vptr] = new GCArray_T<Type>(vptr);
|
||||||
|
|
@ -344,24 +312,21 @@ namespace Swig {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void swig_acquire_ownership(Type *vptr) const
|
void swig_acquire_ownership(Type *vptr) const {
|
||||||
{
|
|
||||||
if (vptr) {
|
if (vptr) {
|
||||||
SWIG_GUARD(swig_mutex_own);
|
SWIG_GUARD(swig_mutex_own);
|
||||||
swig_owner[vptr] = new GCItem_T<Type>(vptr);
|
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) {
|
if (vptr && own) {
|
||||||
SWIG_GUARD(swig_mutex_own);
|
SWIG_GUARD(swig_mutex_own);
|
||||||
swig_owner[vptr] = new GCItem_Object(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;
|
ruby_owntype own = 0;
|
||||||
if (vptr) {
|
if (vptr) {
|
||||||
SWIG_GUARD(swig_mutex_own);
|
SWIG_GUARD(swig_mutex_own);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue