[D] Test C++ references in »d_nativepointers«; normalized indentation.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12407 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
160ee9c937
commit
b9d12afa7c
3 changed files with 49 additions and 20 deletions
|
|
@ -7,17 +7,30 @@ import d_nativepointers.SWIGTYPE_p_p_SomeClass;
|
||||||
import d_nativepointers.SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void;
|
import d_nativepointers.SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
check!(a, int*);
|
check!(a, int*);
|
||||||
check!(b, float**);
|
check!(b, float**);
|
||||||
check!(c, char***);
|
check!(c, char***);
|
||||||
check!(d, SomeClass);
|
check!(d, SomeClass);
|
||||||
check!(e, SWIGTYPE_p_p_SomeClass);
|
check!(e, SWIGTYPE_p_p_SomeClass);
|
||||||
check!(f, SWIGTYPE_p_OpaqueClass);
|
check!(f, SWIGTYPE_p_OpaqueClass);
|
||||||
check!(g, void function(int**, char***));
|
check!(g, void function(int**, char***));
|
||||||
check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
|
check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
|
||||||
|
|
||||||
|
{
|
||||||
|
static assert(is(int* function(int*) == typeof(&refA)));
|
||||||
|
int v = 2;
|
||||||
|
assert(*refA(&v) == 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
static assert(is(float** function(float**) == typeof(&refB)));
|
||||||
|
float v = 1.0;
|
||||||
|
float* p = &v;
|
||||||
|
assert(**refB(&p) == 1.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void check(alias F, T)() {
|
void check(alias F, T)() {
|
||||||
static assert(is(T function(T) == typeof(&F)));
|
static assert(is(T function(T) == typeof(&F)));
|
||||||
assert(F(null) is null);
|
assert(F(null) is null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,17 +7,30 @@ import d_nativepointers.SWIGTYPE_p_p_SomeClass;
|
||||||
import d_nativepointers.SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void;
|
import d_nativepointers.SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
check!(a, int*);
|
check!(a, int*);
|
||||||
check!(b, float**);
|
check!(b, float**);
|
||||||
check!(c, char***);
|
check!(c, char***);
|
||||||
check!(d, SomeClass);
|
check!(d, SomeClass);
|
||||||
check!(e, SWIGTYPE_p_p_SomeClass);
|
check!(e, SWIGTYPE_p_p_SomeClass);
|
||||||
check!(f, SWIGTYPE_p_OpaqueClass);
|
check!(f, SWIGTYPE_p_OpaqueClass);
|
||||||
check!(g, void function(int**, char***));
|
check!(g, void function(int**, char***));
|
||||||
check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
|
check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
|
||||||
|
|
||||||
|
{
|
||||||
|
static assert(is(int* function(int*) == typeof(&refA)));
|
||||||
|
int v = 2;
|
||||||
|
assert(*refA(&v) == 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
static assert(is(float** function(float**) == typeof(&refB)));
|
||||||
|
float v = 1.0;
|
||||||
|
float* p = &v;
|
||||||
|
assert(**refB(&p) == 1.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void check(alias F, T)() {
|
void check(alias F, T)() {
|
||||||
static assert(is(T function(T) == typeof(&F)));
|
static assert(is(T function(T) == typeof(&F)));
|
||||||
assert(F(null) is null);
|
assert(F(null) is null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,7 @@
|
||||||
OpaqueClass *f( OpaqueClass *value ){ return value; }
|
OpaqueClass *f( OpaqueClass *value ){ return value; }
|
||||||
FuncA g( FuncA value ){ return value; }
|
FuncA g( FuncA value ){ return value; }
|
||||||
FuncB* h( FuncB* value ){ return value; }
|
FuncB* h( FuncB* value ){ return value; }
|
||||||
|
|
||||||
|
int &refA( int &value ){ return value; }
|
||||||
|
float *&refB( float *&value ){ return value; }
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue