summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorErez Geva <ErezGeva2@gmail.com>2023-05-03 12:09:15 +0200
committerOlly Betts <olly@survex.com>2023-05-04 13:18:10 +1200
commit63b1293e1a760e0ce1a27208a5231e705c8f0f3b (patch)
tree49ae567d51c5b72ace63a15b54612308274ee56a /Lib
parentdada37e1d1a860100c23f7971b0aac58154441fa (diff)
downloadswig-63b1293e1a760e0ce1a27208a5231e705c8f0f3b.tar.gz
Drop D version 1
See #2538
Diffstat (limited to 'Lib')
-rw-r--r--Lib/d/dhead.swg112
-rw-r--r--Lib/d/doperators.swg125
-rw-r--r--Lib/d/dprimitives.swg7
-rw-r--r--Lib/d/dstrings.swg7
-rw-r--r--Lib/d/std_string.i7
-rw-r--r--Lib/d/std_vector.i164
6 files changed, 0 insertions, 422 deletions
diff --git a/Lib/d/dhead.swg b/Lib/d/dhead.swg
index 1ef1e4164..3d502ffc7 100644
--- a/Lib/d/dhead.swg
+++ b/Lib/d/dhead.swg
@@ -71,87 +71,6 @@ SWIGEXPORT void SWIGRegisterExceptionCallbacks_$module(
}
%}
-#if (SWIG_D_VERSION == 1)
-%pragma(d) imdmoduleimports=%{
-// Exception throwing support currently requires Tango, but there is no reason
-// why it could not support Phobos.
-static import tango.core.Exception;
-static import tango.core.Thread;
-static import tango.stdc.stringz;
-%}
-
-%pragma(d) imdmodulecode=%{
-private class SwigExceptionHelper {
- static this() {
- swigRegisterExceptionCallbacks$module(
- &setException,
- &setIllegalArgumentException,
- &setIllegalElementException,
- &setIOException,
- &setNoSuchElementException);
- }
-
- static void setException(char* message) {
- auto exception = new object.Exception(tango.stdc.stringz.fromStringz(message).dup);
- SwigPendingException.set(exception);
- }
-
- static void setIllegalArgumentException(char* message) {
- auto exception = new tango.core.Exception.IllegalArgumentException(tango.stdc.stringz.fromStringz(message).dup);
- SwigPendingException.set(exception);
- }
-
- static void setIllegalElementException(char* message) {
- auto exception = new tango.core.Exception.IllegalElementException(tango.stdc.stringz.fromStringz(message).dup);
- SwigPendingException.set(exception);
- }
-
- static void setIOException(char* message) {
- auto exception = new tango.core.Exception.IOException(tango.stdc.stringz.fromStringz(message).dup);
- SwigPendingException.set(exception);
- }
-
- static void setNoSuchElementException(char* message) {
- auto exception = new tango.core.Exception.NoSuchElementException(tango.stdc.stringz.fromStringz(message).dup);
- SwigPendingException.set(exception);
- }
-}
-
-package class SwigPendingException {
-public:
- static this() {
- m_sPendingException = new ThreadLocalData(null);
- }
-
- static bool isPending() {
- return m_sPendingException.val !is null;
- }
-
- static void set(object.Exception 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;
- }
-
- static object.Exception retrieve() {
- auto e = m_sPendingException.val;
- m_sPendingException.val = null;
- return e;
- }
-
-private:
- // The reference to the pending exception (if any) is stored thread-local.
- alias tango.core.Thread.ThreadLocal!(object.Exception) ThreadLocalData;
- static ThreadLocalData m_sPendingException;
-}
-alias void function(char* message) SwigExceptionCallback;
-%}
-#else
%pragma(d) imdmoduleimports=%{
static import std.conv;
%}
@@ -208,7 +127,6 @@ private:
}
alias void function(const char* message) SwigExceptionCallback;
%}
-#endif
// Callback registering function in wrapperloader.swg.
#endif // SWIG_D_NO_EXCEPTION_HELPER
@@ -231,23 +149,6 @@ SWIGEXPORT void SWIGRegisterStringCallback_$module(SWIG_DStringHelperCallback ca
}
%}
-#if (SWIG_D_VERSION == 1)
-%pragma(d) imdmoduleimports = "static import tango.stdc.stringz;";
-
-%pragma(d) imdmodulecode = %{
-private class SwigStringHelper {
- static this() {
- swigRegisterStringCallback$module(&createString);
- }
-
- static char* createString(char* cString) {
- // We are effectively dup'ing the string here.
- return tango.stdc.stringz.toStringz(tango.stdc.stringz.fromStringz(cString));
- }
-}
-alias char* function(char* cString) SwigStringCallback;
-%}
-#else
%pragma(d) imdmoduleimports = %{
static import std.conv;
static import std.string;
@@ -267,7 +168,6 @@ private class SwigStringHelper {
}
alias const(char)* function(const(char*) cString) SwigStringCallback;
%}
-#endif
// Callback registering function in wrapperloader.swg.
#endif // SWIG_D_NO_STRING_HELPER
@@ -275,17 +175,6 @@ alias const(char)* function(const(char*) cString) SwigStringCallback;
/*
* Function pointer support code.
*/
-#if (SWIG_D_VERSION == 1)
-%pragma(d) imdmodulecode = %{
-template SwigExternC(T) {
- static if (is(typeof(*(T.init)) R == return)) {
- static if (is(typeof(*(T.init)) P == function)) {
- alias extern(C) R function(P) SwigExternC;
- }
- }
-}
-%}
-#else
%pragma(d) imdmodulecode = %{
template SwigExternC(T) if (is(typeof(*(T.init)) P == function)) {
static if (is(typeof(*(T.init)) R == return)) {
@@ -295,4 +184,3 @@ template SwigExternC(T) if (is(typeof(*(T.init)) P == function)) {
}
}
%}
-#endif
diff --git a/Lib/d/doperators.swg b/Lib/d/doperators.swg
index 0a82a6cb4..f651c3928 100644
--- a/Lib/d/doperators.swg
+++ b/Lib/d/doperators.swg
@@ -4,129 +4,6 @@
* Mapping of C++ operator overloading methods to D.
* ----------------------------------------------------------------------------- */
-#if (SWIG_D_VERSION == 1)
-
-%pragma(d) imdmodulecode=%{
-template SwigOperatorDefinitions() {
- public override int opEquals(Object o) {
- if (auto rhs = cast(typeof(this))o) {
- if (swigCPtr == rhs.swigCPtr) return 1;
- static if (is(typeof(swigOpEquals(rhs)))) {
- return swigOpEquals(rhs) ? 1 : 0;
- } else {
- return 0;
- }
- }
- return super.opEquals(o);
- }
-%}
-// opEquals is emitted in pure C mode as well to define two proxy classes
-// pointing to the same struct as equal.
-
-#ifdef __cplusplus
-%rename(opPos) *::operator+();
-%rename(opPos) *::operator+() const;
-%rename(opNeg) *::operator-();
-%rename(opNeg) *::operator-() const;
-%rename(opCom) *::operator~();
-%rename(opCom) *::operator~() const;
-
-%rename(opAdd) *::operator+;
-%rename(opAddAssign) *::operator+=;
-%rename(opSub) *::operator-;
-%rename(opSubAssign) *::operator-=;
-%rename(opMul) *::operator*;
-%rename(opMulAssign) *::operator*=;
-%rename(opDiv) *::operator/;
-%rename(opDivAssign) *::operator/=;
-%rename(opMod) *::operator%;
-%rename(opModAssign) *::operator%=;
-%rename(opAnd) *::operator&;
-%rename(opAndAssign) *::operator&=;
-%rename(opOr) *::operator|;
-%rename(opOrAssign) *::operator|=;
-%rename(opXor) *::operator^;
-%rename(opXorAssign) *::operator^=;
-%rename(opShl) *::operator<<;
-%rename(opShlAssign) *::operator<<=;
-%rename(opShr) *::operator>>;
-%rename(opShrAssign) *::operator>>=;
-
-%rename(opIndex) *::operator[](unsigned) const;
-// opIndexAssign is not currently generated, it needs more extensive support
-// mechanisms.
-
-%rename(opCall) *::operator();
-
-// !a is not overridable in D1.
-%ignoreoperator(LNOT) operator!;
-
-// opCmp is used in D.
-%rename(swigOpEquals) *::operator==;
-%rename(swigOpLt) *::operator<;
-%rename(swigOpLtEquals) *::operator<=;
-%rename(swigOpGt) *::operator>;
-%rename(swigOpGtEquals) *::operator>=;
-
-// a != b is rewritten as !a.opEquals(b) in D.
-%ignoreoperator(NOTEQUAL) operator!=;
-
-// The logic operators are not overridable in D.
-%ignoreoperator(LAND) operator&&;
-%ignoreoperator(LOR) operator||;
-
-// ++/--a is rewritten as a +/-= 1 in D1,so ignore the prefix operators.
-%ignoreoperator(PLUSPLUS) *::operator++();
-%ignoreoperator(MINUSMINUS) *::operator--();
-%rename(swigOpInc) *::operator++(int);
-%rename(swigOpDec) *::operator--(int);
-
-// The C++ assignment operator does not translate well to D where the proxy
-// classes have reference semantics.
-%ignoreoperator(EQ) operator=;
-
-%pragma(d) imdmodulecode=%{
- public override int opCmp(Object o) {
- static if (is(typeof(swigOpLt(typeof(this).init) &&
- swigOpEquals(typeof(this).init)))) {
- if (auto rhs = cast(typeof(this))o) {
- if (swigOpLt(rhs)) {
- return -1;
- } else if (swigOpEquals(rhs)) {
- return 0;
- } else {
- return 1;
- }
- }
- }
- return super.opCmp(o);
- }
-
- public typeof(this) opPostInc(T = int)(T unused = 0) {
- static assert(
- is(typeof(swigOpInc(int.init))),
- "opPostInc called on " ~ typeof(this).stringof ~ ", but no postfix " ~
- "increment operator exists in the corresponding C++ class."
- );
- return swigOpInc(int.init);
- }
-
- public typeof(this) opPostDec(T = int)(T unused = 0) {
- static assert(
- is(typeof(swigOpDec(int.init))),
- "opPostInc called on " ~ typeof(this).stringof ~ ", but no postfix " ~
- "decrement operator exists in the corresponding C++ class."
- );
- return swigOpDec(int.init);
- }
-%}
-#endif
-
-%pragma(d) imdmodulecode=%{
-}
-%}
-
-#else
%pragma(d) imdmodulecode=%{
mixin template SwigOperatorDefinitions() {
public override bool opEquals(Object o) {
@@ -255,5 +132,3 @@ mixin template SwigOperatorDefinitions() {
%pragma(d) imdmodulecode=%{
}
%}
-
-#endif
diff --git a/Lib/d/dprimitives.swg b/Lib/d/dprimitives.swg
index eaee816d3..a30231b90 100644
--- a/Lib/d/dprimitives.swg
+++ b/Lib/d/dprimitives.swg
@@ -5,17 +5,10 @@
* ----------------------------------------------------------------------------- */
// C long/ulong width depends on the target arch, use stdlib aliases for them.
-#if (SWIG_D_VERSION == 1)
-%pragma(d) imdmoduleimports = "static import tango.stdc.config;"
-%pragma(d) globalproxyimports = "static import tango.stdc.config;"
-#define SWIG_LONG_DTYPE tango.stdc.config.c_long
-#define SWIG_ULONG_DTYPE tango.stdc.config.c_ulong
-#else
%pragma(d) imdmoduleimports = "static import core.stdc.config;"
%pragma(d) globalproxyimports = "static import core.stdc.config;"
#define SWIG_LONG_DTYPE core.stdc.config.c_long
#define SWIG_ULONG_DTYPE core.stdc.config.c_ulong
-#endif
/*
* The SWIG_D_PRIMITIVE macro is used to define the typemaps for the primitive
diff --git a/Lib/d/dstrings.swg b/Lib/d/dstrings.swg
index 02895c153..0b875b58b 100644
--- a/Lib/d/dstrings.swg
+++ b/Lib/d/dstrings.swg
@@ -64,17 +64,10 @@
// We need to have the \0-terminated string conversion functions available in
// the D proxy modules.
-#if (SWIG_D_VERSION == 1)
-// Could be easily extended to support Phobos as well.
-SWIGD_STRING_TYPEMAPS(char*, char[], tango.stdc.stringz.fromStringz, tango.stdc.stringz.toStringz)
-
-%pragma(d) globalproxyimports = "static import tango.stdc.stringz;";
-#else
SWIGD_STRING_TYPEMAPS(const(char)*, string, std.conv.to!string, std.string.toStringz)
%pragma(d) globalproxyimports = %{
static import std.conv;
static import std.string;
%}
-#endif
#undef SWIGD_STRING_TYPEMAPS
diff --git a/Lib/d/std_string.i b/Lib/d/std_string.i
index 8d75d23e4..fbee0578c 100644
--- a/Lib/d/std_string.i
+++ b/Lib/d/std_string.i
@@ -79,19 +79,12 @@ class string;
// We need to have the \0-terminated string conversion functions available in
// the D proxy modules.
-#if (SWIG_D_VERSION == 1)
-// Could be easily extended to support Phobos as well.
-SWIGD_STD_STRING_TYPEMAPS(char*, char[], tango.stdc.stringz.fromStringz, tango.stdc.stringz.toStringz)
-
-%pragma(d) globalproxyimports = "static import tango.stdc.stringz;";
-#else
SWIGD_STD_STRING_TYPEMAPS(const(char)*, string, std.conv.to!string, std.string.toStringz)
%pragma(d) globalproxyimports = %{
static import std.conv;
static import std.string;
%}
-#endif
#undef SWIGD_STD_STRING_TYPEMAPS
diff --git a/Lib/d/std_vector.i b/Lib/d/std_vector.i
index fb8f7d2e0..8c67402e5 100644
--- a/Lib/d/std_vector.i
+++ b/Lib/d/std_vector.i
@@ -22,169 +22,6 @@
// MACRO for use within the std::vector class body
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CONST_REFERENCE, CTYPE...)
-#if (SWIG_D_VERSION == 1)
-%typemap(dimports) std::vector< CTYPE > "static import tango.core.Exception;"
-%proxycode %{
-public this($typemap(dtype, CTYPE)[] values) {
- this();
- append(values);
-}
-
-alias push_back add;
-alias push_back push;
-alias push_back opCatAssign;
-alias size length;
-alias opSlice slice;
-
-public $typemap(dtype, CTYPE) opIndexAssign($typemap(dtype, CTYPE) value, size_t index) {
- if (index >= size()) {
- throw new tango.core.Exception.NoSuchElementException("Tried to assign to element out of vector bounds.");
- }
- setElement(index, value);
- return value;
-}
-
-public $typemap(dtype, CTYPE) opIndex(size_t index) {
- if (index >= size()) {
- throw new tango.core.Exception.NoSuchElementException("Tried to read from element out of vector bounds.");
- }
- return getElement(index);
-}
-
-public void append($typemap(dtype, CTYPE)[] value...) {
- foreach (v; value) {
- add(v);
- }
-}
-
-public $typemap(dtype, CTYPE)[] opSlice() {
- $typemap(dtype, CTYPE)[] array = new $typemap(dtype, CTYPE)[size()];
- foreach (i, ref value; array) {
- value = getElement(i);
- }
- return array;
-}
-
-public int opApply(int delegate(ref $typemap(dtype, CTYPE) value) dg) {
- int result;
-
- size_t currentSize = size();
- for (size_t i = 0; i < currentSize; ++i) {
- auto value = getElement(i);
- result = dg(value);
- setElement(i, value);
- }
- return result;
-}
-
-public int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) {
- int result;
-
- size_t currentSize = size();
- for (size_t i = 0; i < currentSize; ++i) {
- auto value = getElement(i);
-
- // Workaround for http://d.puremagic.com/issues/show_bug.cgi?id=2443.
- auto index = i;
-
- result = dg(index, value);
- setElement(i, value);
- }
- return result;
-}
-
-public void capacity(size_t value) {
- if (value < size()) {
- throw new tango.core.Exception.IllegalArgumentException("Tried to make the capacity of a vector smaller than its size.");
- }
-
- reserve(value);
-}
-%}
-
- public:
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef CTYPE value_type;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
- typedef value_type& reference;
- typedef CONST_REFERENCE const_reference;
-
- void clear();
- void push_back(CTYPE const& x);
- size_type size() const;
- size_type capacity() const;
- void reserve(size_type n) throw (std::length_error);
-
- vector();
- vector(const vector &other);
-
- %extend {
- vector(size_type capacity) throw (std::length_error) {
- std::vector< CTYPE >* pv = 0;
- pv = new std::vector< CTYPE >();
-
- // Might throw std::length_error.
- pv->reserve(capacity);
-
- return pv;
- }
-
- size_type unused() const {
- return $self->capacity() - $self->size();
- }
-
- const_reference remove() throw (std::out_of_range) {
- if ($self->empty()) {
- throw std::out_of_range("Tried to remove last element from empty vector.");
- }
-
- std::vector< CTYPE >::const_reference value = $self->back();
- $self->pop_back();
- return value;
- }
-
- const_reference remove(size_type index) throw (std::out_of_range) {
- if (index >= $self->size()) {
- throw std::out_of_range("Tried to remove element with invalid index.");
- }
-
- std::vector< CTYPE >::iterator it = $self->begin() + index;
- std::vector< CTYPE >::const_reference value = *it;
- $self->erase(it);
- return value;
- }
- }
-
- // Wrappers for setting/getting items with the possibly thrown exception
- // specified (important for SWIG wrapper generation).
- %extend {
- const_reference getElement(size_type index) throw (std::out_of_range) {
- if ((index < 0) || ($self->size() <= index)) {
- throw std::out_of_range("Tried to get value of element with invalid index.");
- }
- return (*$self)[index];
- }
- }
-
- // Use CTYPE const& instead of const_reference to work around SWIG code
- // generation issue when using const pointers as vector elements (like
- // std::vector< const int* >).
- %extend {
- void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) {
- if ((index < 0) || ($self->size() <= index)) {
- throw std::out_of_range("Tried to set value of element with invalid index.");
- }
- (*$self)[index] = val;
- }
- }
-
-%dmethodmodifiers std::vector::getElement "private"
-%dmethodmodifiers std::vector::setElement "private"
-%dmethodmodifiers std::vector::reserve "private"
-
-#else
%typemap(dimports) std::vector< CTYPE > %{
static import std.algorithm;
@@ -541,7 +378,6 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
%dmethodmodifiers std::vector::getElement "private"
%dmethodmodifiers std::vector::setElement "private"
-#endif
%enddef
// Extra methods added to the collection class if operator== is defined for the class being wrapped