[D] Correctly annotate function pointers with C linkage.
Minor cleanups as well. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12899 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
1b47ddf8f0
commit
8fa4d20ec3
5 changed files with 50 additions and 8 deletions
|
|
@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 2.0.5 (in progress)
|
Version 2.0.5 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2012-01-23: klickverbot
|
||||||
|
[D] Correctly annotate function pointers with C linkage.
|
||||||
|
|
||||||
2012-01-20: wsfulton
|
2012-01-20: wsfulton
|
||||||
[Python] Add Python stepped slicing support to the STL wrappers (std::vector, std::list).
|
[Python] Add Python stepped slicing support to the STL wrappers (std::vector, std::list).
|
||||||
Assigning to a slice, reading a slice and deleting a slice with steps now work.
|
Assigning to a slice, reading a slice and deleting a slice with steps now work.
|
||||||
|
|
@ -87,7 +90,7 @@ Version 2.0.5 (in progress)
|
||||||
Bug fix: Handle methods renamed or ignored in the base class correctly in the derived classes
|
Bug fix: Handle methods renamed or ignored in the base class correctly in the derived classes
|
||||||
(they could be sometimes mysteriously not renamed or ignored there before).
|
(they could be sometimes mysteriously not renamed or ignored there before).
|
||||||
|
|
||||||
2011-12-03: klickvebrot
|
2011-12-03: klickverbot
|
||||||
[D] Fix exception glue code for newer DMD 2 versions.
|
[D] Fix exception glue code for newer DMD 2 versions.
|
||||||
[D] Do not default to 32 bit glue code for DMD anymore.
|
[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.
|
[D] Use stdc.config.c_long/c_ulong to represent C long types.
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import d_nativepointers.SWIGTYPE_p_OpaqueClass;
|
||||||
import d_nativepointers.SWIGTYPE_p_p_SomeClass;
|
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;
|
||||||
|
|
||||||
|
extern(C) alias void function(int**, char***) GType;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
check!(a, int*);
|
check!(a, int*);
|
||||||
check!(b, float**);
|
check!(b, float**);
|
||||||
|
|
@ -13,7 +15,7 @@ void main() {
|
||||||
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, GType);
|
||||||
check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
|
check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import d_nativepointers.SWIGTYPE_p_OpaqueClass;
|
||||||
import d_nativepointers.SWIGTYPE_p_p_SomeClass;
|
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;
|
||||||
|
|
||||||
|
extern(C) alias void function(int**, char***) GType;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
check!(a, int*);
|
check!(a, int*);
|
||||||
check!(b, float**);
|
check!(b, float**);
|
||||||
|
|
@ -13,7 +15,7 @@ void main() {
|
||||||
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, GType);
|
||||||
check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
|
check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,23 @@
|
||||||
*
|
*
|
||||||
* Support code for exceptions if the SWIG_D_NO_EXCEPTION_HELPER is not defined
|
* Support code for exceptions if the SWIG_D_NO_EXCEPTION_HELPER is not defined
|
||||||
* Support code for strings if the SWIG_D_NO_STRING_HELPER is not defined
|
* Support code for strings if the SWIG_D_NO_STRING_HELPER is not defined
|
||||||
* ----------------------------------------------------------------------------- */
|
*
|
||||||
|
* Support code for function pointers. ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
%insert(runtime) %{
|
%insert(runtime) %{
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* Contract support. */
|
||||||
|
#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_DSetPendingException(SWIG_DException, msg); return nullreturn; } else
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Exception support code.
|
||||||
|
*/
|
||||||
|
|
||||||
#if !defined(SWIG_D_NO_EXCEPTION_HELPER)
|
#if !defined(SWIG_D_NO_EXCEPTION_HELPER)
|
||||||
%insert(runtime) %{
|
%insert(runtime) %{
|
||||||
// Support for throwing D exceptions from C/C++.
|
// Support for throwing D exceptions from C/C++.
|
||||||
|
|
@ -250,6 +258,11 @@ alias void function(const char* message) SwigExceptionCallback;
|
||||||
// Callback registering function in wrapperloader.swg.
|
// Callback registering function in wrapperloader.swg.
|
||||||
#endif // SWIG_D_NO_EXCEPTION_HELPER
|
#endif // SWIG_D_NO_EXCEPTION_HELPER
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* String support code.
|
||||||
|
*/
|
||||||
|
|
||||||
#if !defined(SWIG_D_NO_STRING_HELPER)
|
#if !defined(SWIG_D_NO_STRING_HELPER)
|
||||||
%insert(runtime) %{
|
%insert(runtime) %{
|
||||||
// Callback for returning strings to D without leaking memory.
|
// Callback for returning strings to D without leaking memory.
|
||||||
|
|
@ -304,7 +317,28 @@ alias const(char)* function(const(char*) cString) SwigStringCallback;
|
||||||
// Callback registering function in wrapperloader.swg.
|
// Callback registering function in wrapperloader.swg.
|
||||||
#endif // SWIG_D_NO_STRING_HELPER
|
#endif // SWIG_D_NO_STRING_HELPER
|
||||||
|
|
||||||
%insert(runtime) %{
|
|
||||||
/* Contract support. */
|
/*
|
||||||
#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_DSetPendingException(SWIG_DException, msg); return nullreturn; } else
|
* 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)) {
|
||||||
|
static if (is(typeof(*(T.init)) P == function)) {
|
||||||
|
alias extern(C) R function(P) SwigExternC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -3877,7 +3877,8 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dtype = NewStringf("%s function(%s)", return_dtype, param_list);
|
dtype = NewStringf("%s.SwigExternC!(%s function(%s))", im_dmodule_fq_name,
|
||||||
|
return_dtype, param_list);
|
||||||
Delete(param_list);
|
Delete(param_list);
|
||||||
Delete(param_dtypes);
|
Delete(param_dtypes);
|
||||||
Delete(return_dtype);
|
Delete(return_dtype);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue