diff options
Diffstat (limited to 'Lib/d')
-rw-r--r-- | Lib/d/boost_shared_ptr.i | 4 | ||||
-rw-r--r-- | Lib/d/dclassgen.swg | 8 | ||||
-rw-r--r-- | Lib/d/denums.swg | 8 | ||||
-rw-r--r-- | Lib/d/dhead.swg | 74 |
4 files changed, 24 insertions, 70 deletions
diff --git a/Lib/d/boost_shared_ptr.i b/Lib/d/boost_shared_ptr.i index bfa2aa646..5c171555e 100644 --- a/Lib/d/boost_shared_ptr.i +++ b/Lib/d/boost_shared_ptr.i @@ -152,7 +152,7 @@ public this(void* cObject, bool ownCObject) { swigCMemOwn = ownCObject; } -public static void* swigGetCPtr($dclassname obj) { +public static void* swigGetCPtr(typeof(this) obj) { return (obj is null) ? null : obj.swigCPtr; } %} @@ -167,7 +167,7 @@ public this(void* cObject, bool ownCObject) { swigCMemOwn = ownCObject; } -public static void* swigGetCPtr($dclassname obj) { +public static void* swigGetCPtr(typeof(this) obj) { return (obj is null) ? null : obj.swigCPtr; } %} diff --git a/Lib/d/dclassgen.swg b/Lib/d/dclassgen.swg index ceaf50727..68910b412 100644 --- a/Lib/d/dclassgen.swg +++ b/Lib/d/dclassgen.swg @@ -72,7 +72,7 @@ public this(void* cObject, bool ownCObject) { swigCMemOwn = ownCObject; } -public static void* swigGetCPtr($dclassname obj) { +public static void* swigGetCPtr(typeof(this) obj) { return (obj is null) ? null : obj.swigCPtr; } @@ -88,7 +88,7 @@ public this(void* cObject, bool ownCObject) { swigCPtr = cObject; } -public static void* swigGetCPtr($dclassname obj) { +public static void* swigGetCPtr(typeof(this) obj) { return (obj is null) ? null : obj.swigCPtr; } @@ -111,7 +111,7 @@ protected this() { swigCPtr = null; } -public static void* swigGetCPtr($dclassname obj) { +public static void* swigGetCPtr(typeof(this) obj) { return (obj is null) ? null : obj.swigCPtr; } @@ -134,7 +134,7 @@ protected this() { swigCPtr = null; } -package static char* swigGetCMemberPtr($dclassname obj) { +package static char* swigGetCMemberPtr(typeof(this) obj) { return (obj is null) ? null : obj.swigCPtr; } diff --git a/Lib/d/denums.swg b/Lib/d/denums.swg index 5917da90d..3f8124662 100644 --- a/Lib/d/denums.swg +++ b/Lib/d/denums.swg @@ -16,10 +16,10 @@ %typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} -%typemap(out) enum SWIGTYPE %{ $result = $1; %} +%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} -%typemap(directorin) enum SWIGTYPE "$input = $1;" +%typemap(directorin) enum SWIGTYPE "$input = (int)$1;" %typemap(ddirectorin) enum SWIGTYPE "cast($dclassname)$winput" %typemap(ddirectorout) enum SWIGTYPE "cast(int)$dcall" @@ -43,9 +43,9 @@ %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} -%typemap(out) const enum SWIGTYPE & %{ $result = *$1; %} +%typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %} -%typemap(directorin) const enum SWIGTYPE & "$input = $1;" +%typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;" %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} diff --git a/Lib/d/dhead.swg b/Lib/d/dhead.swg index 7a2f4fddc..786ca6e66 100644 --- a/Lib/d/dhead.swg +++ b/Lib/d/dhead.swg @@ -93,31 +93,26 @@ private class SwigExceptionHelper { static void setException(char* message) { auto exception = new object.Exception(tango.stdc.stringz.fromStringz(message).dup); - exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); } static void setIllegalArgumentException(char* message) { auto exception = new tango.core.Exception.IllegalArgumentException(tango.stdc.stringz.fromStringz(message).dup); - exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); } static void setIllegalElementException(char* message) { auto exception = new tango.core.Exception.IllegalElementException(tango.stdc.stringz.fromStringz(message).dup); - exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); } static void setIOException(char* message) { auto exception = new tango.core.Exception.IOException(tango.stdc.stringz.fromStringz(message).dup); - exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); } static void setNoSuchElementException(char* message) { auto exception = new tango.core.Exception.NoSuchElementException(tango.stdc.stringz.fromStringz(message).dup); - exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); } } @@ -125,51 +120,31 @@ private class SwigExceptionHelper { package class SwigPendingException { public: static this() { - m_sPendingCount = 0; m_sPendingException = new ThreadLocalData(null); } static bool isPending() { - bool pending = false; - if (m_sPendingCount > 0) { - if (m_sPendingException.val !is null) { - pending = true; - } - } - return pending; + return m_sPendingException.val !is null; } static void set(object.Exception e) { - if (m_sPendingException.val !is null) { - throw new object.Exception("FATAL: An earlier pending exception from C/C++ code " ~ - "was missed and thus not thrown (" ~ m_sPendingException.val.classinfo.name ~ - ": " ~ m_sPendingException.val.msg ~ ")!", e); + auto pending = m_sPendingException.val; + if (pending !is null) { + e.next = pending; + throw new object.Exception("FATAL: An earlier pending exception from C/C++ " ~ + "code was missed and thus not thrown (" ~ pending.classinfo.name ~ ": " ~ + pending.msg ~ ")!", e); } - m_sPendingException.val = e; - synchronized { - ++m_sPendingCount; - } } static object.Exception retrieve() { - object.Exception e = null; - if (m_sPendingCount > 0) { - if (m_sPendingException.val !is null) { - e = m_sPendingException.val; - m_sPendingException.val = null; - synchronized { - --m_sPendingCount; - } - } - } + auto e = m_sPendingException.val; + m_sPendingException.val = null; return e; } private: - // The pending exception counter is stored thread-global. - static int m_sPendingCount; - // The reference to the pending exception (if any) is stored thread-local. alias tango.core.Thread.ThreadLocal!(object.Exception) ThreadLocalData; static ThreadLocalData m_sPendingException; @@ -195,8 +170,7 @@ private class SwigExceptionHelper { } static void setException(const char* message) { - auto exception = new object.Exception(std.conv.to!string(message).idup); - exception.next = SwigPendingException.retrieve(); + auto exception = new object.Exception(std.conv.to!string(message)); SwigPendingException.set(exception); } } @@ -204,51 +178,31 @@ private class SwigExceptionHelper { package struct SwigPendingException { public: static this() { - m_sPendingCount = 0; m_sPendingException = null; } static bool isPending() { - bool pending = false; - if (m_sPendingCount > 0) { - if (m_sPendingException !is null) { - pending = true; - } - } - return pending; + return m_sPendingException !is null; } static void set(object.Exception e) { if (m_sPendingException !is null) { + e.next = m_sPendingException; throw new object.Exception("FATAL: An earlier pending exception from C/C++ code " ~ "was missed and thus not thrown (" ~ m_sPendingException.classinfo.name ~ ": " ~ m_sPendingException.msg ~ ")!", e); } m_sPendingException = e; - synchronized { - ++m_sPendingCount; - } } static object.Exception retrieve() { - object.Exception e = null; - if (m_sPendingCount > 0) { - if (m_sPendingException !is null) { - e = m_sPendingException; - m_sPendingException = null; - synchronized { - --m_sPendingCount; - } - } - } + auto e = m_sPendingException; + m_sPendingException = null; return e; } private: - // The pending exception counter is stored thread-global. - static shared int m_sPendingCount; - // The reference to the pending exception (if any) is stored thread-local. static object.Exception m_sPendingException; } |