From ba4943e63df6683992615163db46b99316bee8d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20K=C3=B6ppe?= Date: Mon, 24 Nov 2003 16:55:22 +0000 Subject: [PATCH] (SWIG_Guile_NewPointerObj): Return '() to represent null pointers. This is for compatibility with the -gh version. Also, GOOPS objects representing null pointers would behave very badly, like segfaulting when one DESCRIBEs them. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5383 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Lib/guile/guile_scm_run.swg | 41 +++++++++++++++++--------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/SWIG/Lib/guile/guile_scm_run.swg b/SWIG/Lib/guile/guile_scm_run.swg index 0464d497c..ffc6e9899 100644 --- a/SWIG/Lib/guile/guile_scm_run.swg +++ b/SWIG/Lib/guile/guile_scm_run.swg @@ -102,26 +102,29 @@ static SCM swig_symbol = SCM_EOL; SWIGRUNTIME(SCM) SWIG_Guile_NewPointerObj(void *ptr, swig_type_info *type, int owner) { - SCM smob; - swig_guile_clientdata *cdata = (swig_guile_clientdata *) type->clientdata; - if (owner) - SCM_NEWSMOB2(smob, swig_collectable_tag, ptr, (void *) type); - else - SCM_NEWSMOB2(smob, swig_tag, ptr, (void *) type); + if (ptr == NULL) + return SCM_EOL; + else { + SCM smob; + swig_guile_clientdata *cdata = (swig_guile_clientdata *) type->clientdata; + if (owner) + SCM_NEWSMOB2(smob, swig_collectable_tag, ptr, (void *) type); + else + SCM_NEWSMOB2(smob, swig_tag, ptr, (void *) type); - if (!cdata || SCM_NULLP(cdata->goops_class) || swig_make_func == SCM_EOL ) { - return smob; - } else { - /* the scm_make() C function only handles the creation of gf, methods and classes (no instances) - the (make ...) function is later redefined in goops.scm. So we need to lookup and - call that function */ - return scm_apply( - swig_make_func, - scm_list_3( - cdata->goops_class, - swig_keyword, - smob), - SCM_EOL); + if (!cdata || SCM_NULLP(cdata->goops_class) || swig_make_func == SCM_EOL ) { + return smob; + } else { + /* the scm_make() C function only handles the creation of gf, + methods and classes (no instances) the (make ...) function is + later redefined in goops.scm. So we need to call that + Scheme function. */ + return scm_apply(swig_make_func, + scm_list_3(cdata->goops_class, + swig_keyword, + smob), + SCM_EOL); + } } }