Lots more bug fixes for the chicken module: almost the entire test-sutie now runs

The only tests that are failing are ones that depend on std_vector.i and similar


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7079 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
John Lenz 2005-03-17 07:28:19 +00:00
commit 92df04c40b
17 changed files with 322 additions and 43 deletions

View file

@ -754,7 +754,8 @@ CHICKEN_COMPILED_MAIN_OBJECT = $(CHICKEN_COMPILED_MAIN:.c=.@OBJEXT@)
# Build a CHICKEN dynamically loadable module
# -----------------------------------------------------------------
chicken: $(SRCS)
# This is the old way to build chicken, but it does not work correctly with exceptions
chicken_direct: $(SRCS)
$(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE)
$(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
-dynamic -feature chicken-compile-shared \
@ -764,7 +765,7 @@ chicken: $(SRCS)
$(LDSHARED) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \
$(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO)
chicken_cpp: $(CXXSRCS) $(CHICKSRCS)
chicken_direct_cpp: $(CXXSRCS) $(CHICKSRCS)
$(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE)
$(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
-dynamic -feature chicken-compile-shared \
@ -807,13 +808,13 @@ chicken_static_cpp: $(CXXSRCS) $(CHICKSRCS)
# Build a shared library using csc
# ----------------------------------------------------------------
chicken_csc:
chicken:
$(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE)
$(CHICKEN_CSC) -sv $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ISRCS) -o $(TARGET)$(SO)
$(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ISRCS) -o $(TARGET)$(SO)
chicken_csc_cpp:
chicken_cpp:
$(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE)
$(CHICKEN_CSC) -sv $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ICXXSRCS) $(CXXSRCS) -o $(TARGET)$(SO)
$(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ICXXSRCS) $(CXXSRCS) -o $(TARGET)$(SO)
chicken_clean:
rm -f *.@OBJEXT@ *$(SO) *_wrap* *~ .~* core @EXTRA_CLEAN@ *_chicken*

View file

@ -0,0 +1,2 @@
(load-library 'cpp-enum "cpp_enum.so")
(include "../schemerunme/cpp_enum.scm")

View file

@ -0,0 +1,2 @@
(load-library 'li-std-string "li_std_string.so")
(include "../schemerunme/li_std_string.scm")

View file

@ -0,0 +1,28 @@
(load-library 'throw-exception "throw_exception.so")
(define-macro (check-throw expr check)
`(if (handle-exceptions exvar (if ,check #f (begin (print "Error executing: " ',expr " " exvar) (exit 1))) ,expr #t)
(print "Expression did not throw an error: " ',expr)))
(define f (new-Foo))
(check-throw (Foo-test-int f) (= exvar 37))
(check-throw (Foo-test-msg f) (string=? exvar "Dead"))
(check-throw (Foo-test-cls f) (test-is-Error exvar))
(check-throw (Foo-test-cls-ptr f) (test-is-Error exvar))
(check-throw (Foo-test-cls-ref f) (test-is-Error exvar))
(check-throw (Foo-test-cls-td f) (test-is-Error exvar))
(check-throw (Foo-test-cls-ptr-td f) (test-is-Error exvar))
(check-throw (Foo-test-cls-ref-td f) (test-is-Error exvar))
; don't know how to test this... it is returning a SWIG wrapped int *
;(check-throw (Foo-test-array f) (equal? exvar '(0 1 2 3 4 5 6 7 8 9)))
(check-throw (Foo-test-multi f 1) (= exvar 37))
(check-throw (Foo-test-multi f 2) (string=? exvar "Dead"))
(check-throw (Foo-test-multi f 3) (test-is-Error exvar))
(set! f #f)
(gc #t)
(exit 0)

View file

@ -0,0 +1,5 @@
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
;; Guile modules (namespaces) but simply put all the bindings into the
;; current module. That's enough for such a simple test.
(dynamic-call "scm_init_cpp_enum_module" (dynamic-link "./cpp_enum.so"))
(load "../schemerunme/cpp_enum.scm")

View file

@ -0,0 +1,5 @@
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
;; Guile modules (namespaces) but simply put all the bindings into the
;; current module. That's enough for such a simple test.
(dynamic-call "scm_init_li_std_string_module" (dynamic-link "./libli_std_string.so"))
(load "../schemerunme/li_std_string.scm")

View file

@ -277,6 +277,11 @@ inline const char* mangle ## #@__VA_ARGS__ () {
/* chiao */
#endif;
#ifdef SWIGCHICKEN
/* define is a scheme keyword (and thus an invalid variable name), so SWIG warns about it */
%warnfilter(314) define;
#endif
#ifdef SWIGRUBY
%rename(ddefined) defined;
#endif

View file

@ -0,0 +1,21 @@
(define f (new-Foo))
(if (not (= (Foo-hola-get f) (Foo-Hello)))
(error "Error 1"))
(Foo-hola-set f (Foo-Hi))
(if (not (= (Foo-hola-get f) (Foo-Hi)))
(error "Error 2"))
(Foo-hola-set f (Foo-Hello))
(if (not (= (Foo-hola-get f) (Foo-Hello)))
(error "Error 3"))
(hi (Hello))
(if (not (= (hi) (Hello)))
(error "Error 4"))
(exit 0)

View file

@ -0,0 +1,17 @@
(define x "hello")
(if (not (string=? (test-value x) x))
(begin (error "Error 1") (exit 1)))
(if (not (string=? (test-const-reference x) x))
(begin (error "Error 2") (exit 1)))
(define y (test-pointer-out))
(test-pointer y)
(define z (test-const-pointer-out))
(test-const-pointer z)
(define a (test-reference-out))
(test-reference a)
(exit 0)

View file

@ -13,12 +13,12 @@
(if (not (char=? (value-char (var-char)) #\w))
(begin (display "Runtime test 3 failed.\n") (exit 1)))
(var-unsigned-char (createref-unsigned-char #\nl))
(if (not (char=? (value-unsigned-char (var-unsigned-char)) #\nl))
(var-unsigned-char (createref-unsigned-char #\newline))
(if (not (char=? (value-unsigned-char (var-unsigned-char)) #\newline))
(begin (display "Runtime test 4 failed.\n") (exit 1)))
(var-signed-char (createref-signed-char #\nl))
(if (not (char=? (value-signed-char (var-signed-char)) #\nl))
(var-signed-char (createref-signed-char #\newline))
(if (not (char=? (value-signed-char (var-signed-char)) #\newline))
(begin (display "Runtime test 5 failed.\n") (exit 1)))
(var-unsigned-short (createref-unsigned-short 10))

View file

@ -10,6 +10,8 @@
class Error {
};
void test_is_Error(Error *r) {}
namespace Namespace {
typedef Error ErrorTypedef;
typedef const Error& ErrorRef;