Racket - NULL pointer handling
SWIG now converts a C/C++ NULL pointer into a null value by calling scheme_make_null(), so that scheme's null? is true for a NULL C/C++ pointer value. Consistency with Guile and needed for a pending commit for handling NULL and std::unique_ptr.
This commit is contained in:
parent
3f622ea65e
commit
2cfd77b1c0
5 changed files with 31 additions and 9 deletions
|
|
@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
||||||
Version 4.1.0 (in progress)
|
Version 4.1.0 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2022-08-26: wsfulton
|
||||||
|
[Racket] SWIG now converts a C/C++ NULL pointer into a null value by calling
|
||||||
|
scheme_make_null(), so that scheme's null? is true for a NULL C/C++ pointer value.
|
||||||
|
|
||||||
2022-08-18: wsfulton
|
2022-08-18: wsfulton
|
||||||
[Racket] Add support for std::unique_ptr in std_unique_ptr.i.
|
[Racket] Add support for std::unique_ptr in std_unique_ptr.i.
|
||||||
Add support for std::auto_ptr in std_auto_ptr.i.
|
Add support for std::auto_ptr in std_auto_ptr.i.
|
||||||
|
|
|
||||||
3
Examples/test-suite/guile/null_pointer_runme.scm
Normal file
3
Examples/test-suite/guile/null_pointer_runme.scm
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
(dynamic-call "scm_init_null_pointer_module" (dynamic-link "./libnull_pointer"))
|
||||||
|
(load "testsuite.scm")
|
||||||
|
(load "../schemerunme/null_pointer.scm")
|
||||||
3
Examples/test-suite/mzscheme/null_pointer_runme.scm
Normal file
3
Examples/test-suite/mzscheme/null_pointer_runme.scm
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
(load-extension "null_pointer.so")
|
||||||
|
|
||||||
|
(load "../schemerunme/null_pointer.scm")
|
||||||
8
Examples/test-suite/schemerunme/null_pointer.scm
Normal file
8
Examples/test-suite/schemerunme/null_pointer.scm
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
(define null '())
|
||||||
|
(unless (funk null)
|
||||||
|
(error "funk(null) does not return true"))
|
||||||
|
|
||||||
|
(unless (null? (getnull))
|
||||||
|
(error "NULL pointer should be null"))
|
||||||
|
|
||||||
|
(exit 0)
|
||||||
|
|
@ -144,6 +144,7 @@ mz_free_swig(void *p, void *data) {
|
||||||
|
|
||||||
static Scheme_Object *
|
static Scheme_Object *
|
||||||
SWIG_MzScheme_NewPointerObj(void *ptr, swig_type_info *type, int owner) {
|
SWIG_MzScheme_NewPointerObj(void *ptr, swig_type_info *type, int owner) {
|
||||||
|
if (ptr) {
|
||||||
struct swig_mz_proxy *new_proxy;
|
struct swig_mz_proxy *new_proxy;
|
||||||
new_proxy = (struct swig_mz_proxy *) scheme_malloc(sizeof(struct swig_mz_proxy));
|
new_proxy = (struct swig_mz_proxy *) scheme_malloc(sizeof(struct swig_mz_proxy));
|
||||||
new_proxy->mztype = swig_type;
|
new_proxy->mztype = swig_type;
|
||||||
|
|
@ -154,6 +155,9 @@ SWIG_MzScheme_NewPointerObj(void *ptr, swig_type_info *type, int owner) {
|
||||||
scheme_add_finalizer(new_proxy, mz_free_swig, NULL);
|
scheme_add_finalizer(new_proxy, mz_free_swig, NULL);
|
||||||
}
|
}
|
||||||
return (Scheme_Object *) new_proxy;
|
return (Scheme_Object *) new_proxy;
|
||||||
|
} else {
|
||||||
|
return scheme_make_null();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue