[D] Use stdc.config.c_long/c_ulong to represent C long types.
Previously, C's long/ulong types would always be mapped to 32 bit integers in D, which is wrong on D_LP64, but was not really a problem in practice since DMD used to be 32 bit only. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12861 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
5e5d1e2775
commit
e2b2f26bf6
8 changed files with 51 additions and 33 deletions
|
|
@ -8,6 +8,7 @@ Version 2.0.5 (in progress)
|
|||
2011-12-03: klickvebrot
|
||||
[D] Fix exception glue code for newer DMD 2 versions.
|
||||
[D] Do not default to 32 bit glue code for DMD anymore.
|
||||
[D] Use stdc.config.c_long/c_ulong to represent C long types.
|
||||
|
||||
2011-12-01: szager
|
||||
[python] Fixed bug 3447426: memory leak in vector.__getitem__.
|
||||
|
|
|
|||
|
|
@ -583,7 +583,7 @@ private void verifyCount(int expected, Klass k) {
|
|||
// We deliberately call the use_count(Klass) overload also for objects which
|
||||
// are instances of a subclass of Klass (due to static dispatch); things still
|
||||
// have to work.
|
||||
int got = use_count(k);
|
||||
auto got = use_count(k);
|
||||
if (expected != got)
|
||||
throw new Exception("verify use_count failed. Expected: " ~ to!string(expected) ~ " Got: " ~ to!string(got));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
module preproc_constants_c_runme;
|
||||
|
||||
import tango.stdc.config;
|
||||
import preproc_constants_c.preproc_constants_c;
|
||||
|
||||
// Same as preproc_constants.i testcase, but bool types are int instead.
|
||||
|
|
@ -10,10 +11,10 @@ void main() {
|
|||
static assert(is(uint == typeof(CONST_UINT2())));
|
||||
static assert(is(uint == typeof(CONST_UINT3())));
|
||||
static assert(is(uint == typeof(CONST_UINT4())));
|
||||
static assert(is(int == typeof(CONST_LONG1())));
|
||||
static assert(is(int == typeof(CONST_LONG2())));
|
||||
static assert(is(int == typeof(CONST_LONG3())));
|
||||
static assert(is(int == typeof(CONST_LONG4())));
|
||||
static assert(is(c_long == typeof(CONST_LONG1())));
|
||||
static assert(is(c_long == typeof(CONST_LONG2())));
|
||||
static assert(is(c_long == typeof(CONST_LONG3())));
|
||||
static assert(is(c_long == typeof(CONST_LONG4())));
|
||||
static assert(is(long == typeof(CONST_LLONG1())));
|
||||
static assert(is(long == typeof(CONST_LLONG2())));
|
||||
static assert(is(long == typeof(CONST_LLONG3())));
|
||||
|
|
@ -38,8 +39,8 @@ void main() {
|
|||
// static assert(is(int == typeof(INT_AND_CHAR())));
|
||||
static assert(is(int == typeof(INT_AND_INT())));
|
||||
static assert(is(uint == typeof(INT_AND_UINT())));
|
||||
static assert(is(int == typeof(INT_AND_LONG())));
|
||||
static assert(is(uint == typeof(INT_AND_ULONG())));
|
||||
static assert(is(c_long == typeof(INT_AND_LONG())));
|
||||
static assert(is(c_ulong == typeof(INT_AND_ULONG())));
|
||||
static assert(is(long == typeof(INT_AND_LLONG())));
|
||||
static assert(is(ulong == typeof(INT_AND_ULLONG())));
|
||||
static assert(is(int == typeof(BOOL_AND_BOOL())));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
module preproc_constants_c_runme;
|
||||
|
||||
import core.stdc.config;
|
||||
import preproc_constants_c.preproc_constants_c;
|
||||
|
||||
// Same as preproc_constants.i testcase, but bool types are int instead.
|
||||
|
|
@ -10,10 +11,10 @@ void main() {
|
|||
static assert(is(uint == typeof(CONST_UINT2())));
|
||||
static assert(is(uint == typeof(CONST_UINT3())));
|
||||
static assert(is(uint == typeof(CONST_UINT4())));
|
||||
static assert(is(int == typeof(CONST_LONG1())));
|
||||
static assert(is(int == typeof(CONST_LONG2())));
|
||||
static assert(is(int == typeof(CONST_LONG3())));
|
||||
static assert(is(int == typeof(CONST_LONG4())));
|
||||
static assert(is(c_long == typeof(CONST_LONG1())));
|
||||
static assert(is(c_long == typeof(CONST_LONG2())));
|
||||
static assert(is(c_long == typeof(CONST_LONG3())));
|
||||
static assert(is(c_long == typeof(CONST_LONG4())));
|
||||
static assert(is(long == typeof(CONST_LLONG1())));
|
||||
static assert(is(long == typeof(CONST_LLONG2())));
|
||||
static assert(is(long == typeof(CONST_LLONG3())));
|
||||
|
|
@ -38,8 +39,8 @@ void main() {
|
|||
// static assert(is(int == typeof(INT_AND_CHAR())));
|
||||
static assert(is(int == typeof(INT_AND_INT())));
|
||||
static assert(is(uint == typeof(INT_AND_UINT())));
|
||||
static assert(is(int == typeof(INT_AND_LONG())));
|
||||
static assert(is(uint == typeof(INT_AND_ULONG())));
|
||||
static assert(is(c_long == typeof(INT_AND_LONG())));
|
||||
static assert(is(c_ulong == typeof(INT_AND_ULONG())));
|
||||
static assert(is(long == typeof(INT_AND_LLONG())));
|
||||
static assert(is(ulong == typeof(INT_AND_ULLONG())));
|
||||
static assert(is(int == typeof(BOOL_AND_BOOL())));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
module preproc_constants_runme;
|
||||
|
||||
import tango.stdc.config;
|
||||
import preproc_constants.preproc_constants;
|
||||
|
||||
void main() {
|
||||
|
|
@ -9,10 +10,10 @@ void main() {
|
|||
static assert(is(uint == typeof(CONST_UINT2())));
|
||||
static assert(is(uint == typeof(CONST_UINT3())));
|
||||
static assert(is(uint == typeof(CONST_UINT4())));
|
||||
static assert(is(int == typeof(CONST_LONG1())));
|
||||
static assert(is(int == typeof(CONST_LONG2())));
|
||||
static assert(is(int == typeof(CONST_LONG3())));
|
||||
static assert(is(int == typeof(CONST_LONG4())));
|
||||
static assert(is(c_long == typeof(CONST_LONG1())));
|
||||
static assert(is(c_long == typeof(CONST_LONG2())));
|
||||
static assert(is(c_long == typeof(CONST_LONG3())));
|
||||
static assert(is(c_long == typeof(CONST_LONG4())));
|
||||
static assert(is(long == typeof(CONST_LLONG1())));
|
||||
static assert(is(long == typeof(CONST_LLONG2())));
|
||||
static assert(is(long == typeof(CONST_LLONG3())));
|
||||
|
|
@ -37,8 +38,8 @@ void main() {
|
|||
// static assert(is(int == typeof(INT_AND_CHAR())));
|
||||
static assert(is(int == typeof(INT_AND_INT())));
|
||||
static assert(is(uint == typeof(INT_AND_UINT())));
|
||||
static assert(is(int == typeof(INT_AND_LONG())));
|
||||
static assert(is(uint == typeof(INT_AND_ULONG())));
|
||||
static assert(is(c_long == typeof(INT_AND_LONG())));
|
||||
static assert(is(c_ulong == typeof(INT_AND_ULONG())));
|
||||
static assert(is(long == typeof(INT_AND_LLONG())));
|
||||
static assert(is(ulong == typeof(INT_AND_ULLONG())));
|
||||
static assert(is(int == typeof(BOOL_AND_BOOL())));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
module preproc_constants_runme;
|
||||
|
||||
import core.stdc.config;
|
||||
import preproc_constants.preproc_constants;
|
||||
|
||||
void main() {
|
||||
|
|
@ -9,10 +10,10 @@ void main() {
|
|||
static assert(is(uint == typeof(CONST_UINT2())));
|
||||
static assert(is(uint == typeof(CONST_UINT3())));
|
||||
static assert(is(uint == typeof(CONST_UINT4())));
|
||||
static assert(is(int == typeof(CONST_LONG1())));
|
||||
static assert(is(int == typeof(CONST_LONG2())));
|
||||
static assert(is(int == typeof(CONST_LONG3())));
|
||||
static assert(is(int == typeof(CONST_LONG4())));
|
||||
static assert(is(c_long == typeof(CONST_LONG1())));
|
||||
static assert(is(c_long == typeof(CONST_LONG2())));
|
||||
static assert(is(c_long == typeof(CONST_LONG3())));
|
||||
static assert(is(c_long == typeof(CONST_LONG4())));
|
||||
static assert(is(long == typeof(CONST_LLONG1())));
|
||||
static assert(is(long == typeof(CONST_LLONG2())));
|
||||
static assert(is(long == typeof(CONST_LLONG3())));
|
||||
|
|
@ -37,8 +38,8 @@ void main() {
|
|||
// static assert(is(int == typeof(INT_AND_CHAR())));
|
||||
static assert(is(int == typeof(INT_AND_INT())));
|
||||
static assert(is(uint == typeof(INT_AND_UINT())));
|
||||
static assert(is(int == typeof(INT_AND_LONG())));
|
||||
static assert(is(uint == typeof(INT_AND_ULONG())));
|
||||
static assert(is(c_long == typeof(INT_AND_LONG())));
|
||||
static assert(is(c_ulong == typeof(INT_AND_ULONG())));
|
||||
static assert(is(long == typeof(INT_AND_LLONG())));
|
||||
static assert(is(ulong == typeof(INT_AND_ULLONG())));
|
||||
static assert(is(int == typeof(BOOL_AND_BOOL())));
|
||||
|
|
|
|||
|
|
@ -4,6 +4,19 @@
|
|||
* Typemaps for primitive types.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
// 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
|
||||
* types, because are more or less the same for all of them. The few special
|
||||
|
|
@ -49,8 +62,8 @@ SWIG_D_PRIMITIVE(short, short)
|
|||
SWIG_D_PRIMITIVE(unsigned short, ushort)
|
||||
SWIG_D_PRIMITIVE(int, int)
|
||||
SWIG_D_PRIMITIVE(unsigned int, uint)
|
||||
SWIG_D_PRIMITIVE(long, int)
|
||||
SWIG_D_PRIMITIVE(unsigned long, uint)
|
||||
SWIG_D_PRIMITIVE(long, SWIG_LONG_DTYPE)
|
||||
SWIG_D_PRIMITIVE(unsigned long, SWIG_ULONG_DTYPE)
|
||||
SWIG_D_PRIMITIVE(size_t, size_t)
|
||||
SWIG_D_PRIMITIVE(long long, long)
|
||||
SWIG_D_PRIMITIVE(unsigned long long, ulong)
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ INPUT_TYPEMAP(short, short, short)
|
|||
INPUT_TYPEMAP(unsigned short, unsigned short, ushort)
|
||||
INPUT_TYPEMAP(int, int, int)
|
||||
INPUT_TYPEMAP(unsigned int, unsigned int, uint)
|
||||
INPUT_TYPEMAP(long, long, int)
|
||||
INPUT_TYPEMAP(unsigned long, unsigned long, uint)
|
||||
INPUT_TYPEMAP(long, long, SWIG_LONG_DTYPE)
|
||||
INPUT_TYPEMAP(unsigned long, unsigned long, SWIG_ULONG_DTYPE)
|
||||
INPUT_TYPEMAP(long long, long long, long)
|
||||
INPUT_TYPEMAP(unsigned long long, unsigned long long, ulong)
|
||||
INPUT_TYPEMAP(float, float, float)
|
||||
|
|
@ -157,8 +157,8 @@ OUTPUT_TYPEMAP(short, short, short, INT16_PTR)
|
|||
OUTPUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR)
|
||||
OUTPUT_TYPEMAP(int, int, int, INT32_PTR)
|
||||
OUTPUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR)
|
||||
OUTPUT_TYPEMAP(long, long, int, INT32_PTR)
|
||||
OUTPUT_TYPEMAP(unsigned long, unsigned long, uint, UINT32_PTR)
|
||||
OUTPUT_TYPEMAP(long, long, SWIG_LONG_DTYPE,INT32_PTR)
|
||||
OUTPUT_TYPEMAP(unsigned long, unsigned long, SWIG_ULONG_DTYPE,UINT32_PTR)
|
||||
OUTPUT_TYPEMAP(long long, long long, long, INT64_PTR)
|
||||
OUTPUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR)
|
||||
OUTPUT_TYPEMAP(float, float, float, FLOAT_PTR)
|
||||
|
|
@ -248,8 +248,8 @@ INOUT_TYPEMAP(short, short, short, INT16_PTR)
|
|||
INOUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR)
|
||||
INOUT_TYPEMAP(int, int, int, INT32_PTR)
|
||||
INOUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR)
|
||||
INOUT_TYPEMAP(long, long, int, INT32_PTR)
|
||||
INOUT_TYPEMAP(unsigned long, unsigned long, uint, UINT32_PTR)
|
||||
INOUT_TYPEMAP(long, long, SWIG_LONG_DTYPE,INT32_PTR)
|
||||
INOUT_TYPEMAP(unsigned long, unsigned long, SWIG_ULONG_DTYPE,UINT32_PTR)
|
||||
INOUT_TYPEMAP(long long, long long, long, INT64_PTR)
|
||||
INOUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR)
|
||||
INOUT_TYPEMAP(float, float, float, FLOAT_PTR)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue