- Fix SF bug 1573892

- Minor change to chicken to make it work with version 2.5rc1
- add externaltest to chicken and guile modules


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9451 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
John Lenz 2006-10-14 08:19:27 +00:00
commit 56904f30d0
13 changed files with 175 additions and 2 deletions

View file

@ -3,8 +3,12 @@
# Makefile for guile test-suite (with SCM API)
#######################################################################
EXTRA_TEST_CASES += ext_test.externaltest
include ../guile/Makefile
INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guilescm
VARIANT =
# Refer to the guile directory for the run scripts
SCRIPTPREFIX = ../guile/
@ -31,3 +35,21 @@ swig_and_compile_multi_cpp = \
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \
$(LANGUAGE)$(VARIANT)_cpp; \
done
%.externaltest:
$(local_setup) \
($(swig_and_compile_external); ) && \
$(local_run_testcase)
# Same as setup and run_testcase, but without the SCRIPTPREFIX (so the runme comes from the guilescm directory)
local_setup = \
if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
echo "Checking testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \
else \
echo "Checking testcase $* under $(LANGUAGE) (with SCM API)" ; \
fi;
local_run_testcase = \
if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(GUILE) -l $(srcdir)/$*$(SCRIPTSUFFIX);) \
fi;

View file

@ -0,0 +1,19 @@
%module ext_test
/* just use the imports_a.h header... for this test we only need a class */
%{
#include "imports_a.h"
%}
%include "imports_a.h"
%{
SCM test_create();
SCM test_is_pointer(SCM val);
%}
%init %{
scm_c_define_gsubr("test-create", 0, 0, 0, (swig_guile_proc) test_create);
scm_c_define_gsubr("test-is-pointer", 1, 0, 0, (swig_guile_proc) test_is_pointer);
%}

View file

@ -0,0 +1,24 @@
#include <ext_test_wrap_hdr.h>
#include <imports_a.h>
SCM test_create()
{
#define FUNC_NAME "test-create"
SCM result;
A *newobj;
swig_type_info *type;
newobj = new A();
type = SWIG_TypeQuery("A *");
result = SWIG_NewPointerObj(result, type, 1);
return result;
#undef FUNC_NAME
}
SCM test_is_pointer(SCM val)
{
#define FUNC_NAME "test-is-pointer"
return SCM_BOOL(SWIG_IsPointer(val));
#undef FUNC_NAME
}

View file

@ -0,0 +1,19 @@
(dynamic-call "scm_init_ext_test_module" (dynamic-link "./libext_test.so"))
; This is a test for SF Bug 1573892
; If IsPointer is called before TypeQuery, the test-is-pointer will fail
; (i.e if the bottom two lines were moved to the top, the old code would succeed)
; only a problem when is-pointer is called first
(define a (new-A))
(if (not (test-is-pointer a))
(error "test-is-pointer failed!"))
(if (test-is-pointer 5)
(error "test-is-pointer thinks 5 is a pointer!"))
(define b (test-create))
(A-hello b)
(exit 0)