- 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:
parent
5149b7b4f3
commit
56904f30d0
13 changed files with 175 additions and 2 deletions
|
|
@ -296,6 +296,9 @@ guile_cpp: $(SRCS)
|
|||
$(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
|
||||
|
||||
guile_externalhdr:
|
||||
$(SWIG) -guile -external-runtime $(TARGET)
|
||||
|
||||
#------------------------------------------------------------------
|
||||
# Build a dynamically loaded module with passive linkage and the gh interface
|
||||
#------------------------------------------------------------------
|
||||
|
|
@ -839,6 +842,9 @@ chicken_cpp:
|
|||
$(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE)
|
||||
$(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ICXXSRCS) $(CXXSRCS) -o $(TARGET)$(SO)
|
||||
|
||||
chicken_externalhdr:
|
||||
$(SWIG) -chicken -external-runtime $(TARGET)
|
||||
|
||||
chicken_clean:
|
||||
rm -f *_wrap* *~ .~* *_chicken*
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ SKIP_CPP_STD_CASES = Yes
|
|||
|
||||
CPP_TEST_CASES += li_std_string
|
||||
|
||||
EXTRA_TEST_CASES += ext_test.externaltest
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
|
||||
|
|
@ -51,6 +53,11 @@ SWIGOPT += -nounit
|
|||
$(MAKE) $*.multiproxy; ) \
|
||||
fi;
|
||||
|
||||
%.externaltest:
|
||||
$(setup) \
|
||||
($(swig_and_compile_external); ) && \
|
||||
$(run_testcase)
|
||||
|
||||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.scm appended after the testcase name.
|
||||
run_testcase = \
|
||||
|
|
|
|||
21
Examples/test-suite/chicken/ext_test.i
Normal file
21
Examples/test-suite/chicken/ext_test.i
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
%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"
|
||||
|
||||
%{
|
||||
void test_create(C_word,C_word,C_word) C_noret;
|
||||
%}
|
||||
|
||||
%init %{
|
||||
{
|
||||
C_word *space = C_alloc(2 + C_SIZEOF_INTERNED_SYMBOL(11));
|
||||
sym = C_intern (&space, 11, "test-create");
|
||||
C_mutate ((C_word*)sym+1, (*space=C_CLOSURE_TYPE|1, space[1]=(C_word)test_create, tmp=(C_word)space, space+=2, tmp));
|
||||
}
|
||||
%}
|
||||
|
||||
22
Examples/test-suite/chicken/ext_test_external.cxx
Normal file
22
Examples/test-suite/chicken/ext_test_external.cxx
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include <ext_test_wrap_hdr.h>
|
||||
#include <imports_a.h>
|
||||
|
||||
void test_create(C_word,C_word,C_word) C_noret;
|
||||
void test_create(C_word argc, C_word closure, C_word continuation) {
|
||||
C_word resultobj;
|
||||
swig_type_info *type;
|
||||
A *newobj;
|
||||
C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
|
||||
|
||||
C_trace("test-create");
|
||||
if (argc!=2) C_bad_argc(argc,2);
|
||||
|
||||
|
||||
newobj = new A();
|
||||
|
||||
type = SWIG_TypeQuery("A *");
|
||||
resultobj = SWIG_NewPointerObj(newobj, type, 1);
|
||||
|
||||
C_kontinue(continuation, resultobj);
|
||||
}
|
||||
|
||||
5
Examples/test-suite/chicken/ext_test_runme.ss
Normal file
5
Examples/test-suite/chicken/ext_test_runme.ss
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(load "ext_test.so")
|
||||
|
||||
(define a (test-create))
|
||||
|
||||
(A-hello a)
|
||||
|
|
@ -404,7 +404,8 @@ MULTI_CPP_TEST_CASES += \
|
|||
NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \
|
||||
$(C_TEST_CASES:=.ctest) \
|
||||
$(MULTI_CPP_TEST_CASES:=.multicpptest) \
|
||||
$(CUSTOM_TEST_CASES:=.customtest)
|
||||
$(CUSTOM_TEST_CASES:=.customtest) \
|
||||
$(EXTRA_TEST_CASES)
|
||||
|
||||
BROKEN_TEST_CASES = $(CPP_TEST_BROKEN:=.cpptest) \
|
||||
$(C_TEST_BROKEN:=.ctest)
|
||||
|
|
@ -448,6 +449,17 @@ swig_and_compile_multi_cpp = \
|
|||
$(LANGUAGE)$(VARIANT)_cpp; \
|
||||
done
|
||||
|
||||
swig_and_compile_external = \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
|
||||
TARGET="$*_wrap_hdr.h" \
|
||||
$(LANGUAGE)$(VARIANT)_externalhdr; \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS) $*_external.cxx" \
|
||||
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
|
||||
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
|
||||
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \
|
||||
$(LANGUAGE)$(VARIANT)_cpp
|
||||
|
||||
swig_and_compile_runtime = \
|
||||
|
||||
setup = \
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
19
Examples/test-suite/guilescm/ext_test.i
Normal file
19
Examples/test-suite/guilescm/ext_test.i
Normal 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);
|
||||
%}
|
||||
|
||||
24
Examples/test-suite/guilescm/ext_test_external.cxx
Normal file
24
Examples/test-suite/guilescm/ext_test_external.cxx
Normal 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
|
||||
}
|
||||
19
Examples/test-suite/guilescm/ext_test_runme.scm
Normal file
19
Examples/test-suite/guilescm/ext_test_runme.scm
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue