Beautify director.swg files

Also some comment corrections for Perl
This commit is contained in:
William S Fulton 2013-12-23 19:50:41 +00:00
commit 135a7cc558
9 changed files with 289 additions and 406 deletions

View file

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* director.swg * 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++. * methods can be called from C++.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
@ -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) {
} }
}; };
} }

View file

@ -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) {
} }
}; };
} }

View file

@ -126,7 +126,7 @@ namespace Swig {
#endif #endif
env_status = director_->swig_jvm_->GetEnv((void **)&jenv_, JNI_VERSION_1_2); env_status = director_->swig_jvm_->GetEnv((void **)&jenv_, JNI_VERSION_1_2);
#if defined(SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON) #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. // the thread to exit upon shutdown. Only for jdk-1.4 and later.
director_->swig_jvm_->AttachCurrentThreadAsDaemon(jenv, NULL); director_->swig_jvm_->AttachCurrentThreadAsDaemon(jenv, NULL);
#else #else
@ -358,7 +358,7 @@ namespace Swig {
if (throwable && jenv && classname) { if (throwable && jenv && classname) {
// Exceptions need to be cleared for correct behavior. // 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. // the caller already has the throwable.
jenv->ExceptionClear(); jenv->ExceptionClear();

View file

@ -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 {
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 */ /* 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) {
@ -57,7 +60,7 @@ namespace Swig {
#define MUTEX_INIT(var) CRITICAL_SECTION var #define MUTEX_INIT(var) CRITICAL_SECTION var
#else #else
#include <pthread.h> #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
#endif #endif
@ -78,23 +81,21 @@ namespace Swig {
/* discard our reference at destruction */ /* discard our reference at destruction */
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 */
CAML_VALUE swig_get_self() const { CAML_VALUE swig_get_self() const {
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;
callback(*caml_named_value("caml_obj_disown"),swig_self); callback(*caml_named_value("caml_obj_disown"),swig_self);
} }
} }
}; };
} }

View file

@ -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);

View file

@ -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;
} }
}; };
} }

View file

@ -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);
} }
@ -116,11 +104,11 @@ namespace Swig {
zend_class_entry **ce; zend_class_entry **ce;
zend_function *mptr; zend_function *mptr;
int name_len = strlen(lc_fname); int name_len = strlen(lc_fname);
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);
} }
}; };

View file

@ -58,7 +58,7 @@
could stop working when using this option. could stop working when using this option.
*/ */
#ifdef SWIG_DIRECTOR_NORTTI #ifdef SWIG_DIRECTOR_NORTTI
/* /*
When we don't use the native C++ RTTI, we implement a minimal one When we don't use the native C++ RTTI, we implement a minimal one
only for Directors. only for Directors.
*/ */
@ -99,94 +99,77 @@ extern "C" {
struct swig_type_info; struct swig_type_info;
} }
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;
} }
private: private:
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()
{
} }
int get_own() const virtual ~GCItem_Object() {
{ }
int get_own() const {
return _own; return _own;
} }
private: private:
int _own; int _own;
}; };
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;
} }
private: private:
Type *_ptr; Type *_ptr;
}; };
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;
} }
private: private:
Type *_ptr; Type *_ptr;
}; };
@ -196,10 +179,8 @@ 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 += " ";
swig_msg += msg; swig_msg += msg;
@ -207,30 +188,26 @@ namespace Swig {
if (!PyErr_Occurred()) { if (!PyErr_Occurred()) {
PyErr_SetString(error, getMessage()); PyErr_SetString(error, getMessage());
} }
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) {
@ -241,12 +218,12 @@ namespace Swig {
} catch (...) { } catch (...) {
std::cerr << "Unknown exception caught." << std::endl; std::cerr << "Unknown exception caught." << std::endl;
} }
std::cerr << std::endl std::cerr << std::endl
<< "Python interpreter traceback:" << std::endl; << "Python interpreter traceback:" << std::endl;
PyErr_Print(); PyErr_Print();
std::cerr << std::endl; std::cerr << std::endl;
std::cerr << "This exception was caught by the SWIG unexpected exception handler." << 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 << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl
<< std::endl << std::endl
@ -255,15 +232,13 @@ 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
@ -272,23 +247,19 @@ namespace Swig {
/* 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(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);
} }
}; };
@ -296,28 +267,23 @@ namespace Swig {
/* any python exception that occurs during a director method call */ /* any python exception that occurs during a director method call */
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,24 +298,21 @@ 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_);
} }
}; };
# define SWIG_GUARD(mutex) Guard _guard(mutex) # define SWIG_GUARD(mutex) Guard _guard(mutex)
#else #else
# define SWIG_GUARD(mutex) # define SWIG_GUARD(mutex)
#endif #endif
/* director base class */ /* director base class */
@ -361,11 +324,11 @@ namespace Swig {
mutable bool swig_disown_flag; mutable bool swig_disown_flag;
/* decrement the reference count of the wrapped python object */ /* decrement the reference count of the wrapped python object */
void swig_decref() const { void swig_decref() const {
if (swig_disown_flag) { if (swig_disown_flag) {
SWIG_PYTHON_THREAD_BEGIN_BLOCK; SWIG_PYTHON_THREAD_BEGIN_BLOCK;
Py_DECREF(swig_self); Py_DECREF(swig_self);
SWIG_PYTHON_THREAD_END_BLOCK; SWIG_PYTHON_THREAD_END_BLOCK;
} }
} }
@ -375,31 +338,28 @@ 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;
swig_incref(); swig_incref();
} }
} }
/* increase the reference count of the wrapped python object */ /* increase the reference count of the wrapped python object */
void swig_incref() const { void swig_incref() const {
if (swig_disown_flag) { 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 { virtual bool swig_get_inner(const char * /* swig_protected_method_name */) const {
return true; return true;
} }
virtual void swig_set_inner(const char * /* swig_protected_method_name */, bool /* swig_val */) const { virtual void swig_set_inner(const char * /* swig_protected_method_name */, bool /* swig_val */) const {
} }
@ -421,33 +381,29 @@ 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);
} }
} }
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__

View file

@ -24,96 +24,78 @@
# 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;
} }
private: private:
GCItem *_item; GCItem *_item;
}; };
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;
} }
private: private:
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()
{
} }
ruby_owntype get_own() const virtual ~GCItem_Object() {
{ }
ruby_owntype get_own() const {
return _own; return _own;
} }
private: private:
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;
} }
private: private:
Type *_ptr; Type *_ptr;
}; };
@ -126,20 +108,17 @@ namespace Swig {
int argc; int argc;
VALUE *argv; VALUE *argv;
}; };
/* Base class for director exceptions */ /* Base class for director exceptions */
class DirectorException { class DirectorException {
protected: protected:
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() {}
};
/* unknown exception handler */
class UnknownExceptionHandler virtual ~DirectorException() {
{ }
};
/* unknown exception handler */
class UnknownExceptionHandler {
#ifdef SWIG_DIRECTOR_UEH #ifdef SWIG_DIRECTOR_UEH
static void handler() { static void handler() {
try { try {
@ -181,26 +161,24 @@ namespace Swig {
std::cerr << "std::exception caught: "<< e.what() << std::endl; std::cerr << "std::exception caught: "<< e.what() << std::endl;
} catch (...) { } catch (...) {
std::cerr << "Unknown exception caught." << std::endl; std::cerr << "Unknown exception caught." << std::endl;
} }
std::cerr << std::endl std::cerr << std::endl
<< "Ruby interpreter traceback:" << 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 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 << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl
<< std::endl << std::endl
<< "Exception is being re-thrown, program will like abort/terminate." << std::endl; << "Exception is being re-thrown, program will like abort/terminate." << std::endl;
throw; throw;
} }
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) {
@ -232,31 +208,28 @@ namespace Swig {
/* Any Ruby exception that occurs during a director method call */ /* Any Ruby exception that occurs during a director method call */
class DirectorMethodException : public Swig::DirectorException { class DirectorMethodException : public Swig::DirectorException {
public: public:
DirectorMethodException(VALUE error) DirectorMethodException(VALUE error)
: 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);
} }
}; };
/* Attempted to call a pure virtual method via a director method */ /* Attempted 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(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);
} }
}; };
@ -271,28 +244,25 @@ namespace Swig {
# define SWIG_MUTEX_INIT(var) var # define SWIG_MUTEX_INIT(var) var
# else # else
# include <pthread.h> # include <pthread.h>
# define SWIG_MUTEX_INIT(var) var = PTHREAD_MUTEX_INITIALIZER # define SWIG_MUTEX_INIT(var) var = PTHREAD_MUTEX_INITIALIZER
# endif # endif
#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);
} }
}; };
# define SWIG_GUARD(mutex) Guard _guard(mutex) # define SWIG_GUARD(mutex) Guard _guard(mutex)
#else #else
# define SWIG_GUARD(mutex) # define SWIG_GUARD(mutex)
#endif #endif
/* director base class */ /* director base class */
@ -313,21 +283,20 @@ namespace Swig {
} }
/* return a pointer to the wrapped Ruby object */ /* return a pointer to the wrapped Ruby object */
VALUE swig_get_self() const { VALUE swig_get_self() const {
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;
} }
} }
/* 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,33 +304,29 @@ 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);
} }
} }
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);