Add a whole bunch of chicken runme scripts, and fix the bugs exposed by those scripts
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7155 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c4dc892c23
commit
420ba48099
72 changed files with 1086 additions and 413 deletions
|
|
@ -1,6 +1,16 @@
|
|||
Version 1.3.25 (In progress)
|
||||
============================
|
||||
|
||||
04/14/2005: wuzzeb (John Lenz)
|
||||
[Chicken]
|
||||
+ Added a whole bunch of new _runme scripts into the chicken test
|
||||
suite. Also fix some bugs these new scripts turned up.
|
||||
|
||||
+ Added optimization when returning a wrapped proxy class. Before,
|
||||
a minor garbage collection was invoked every time a function returned.
|
||||
|
||||
+ All the chicken Examples should now run correctly
|
||||
|
||||
04/14/2005: wsfulton
|
||||
[C#] More fixes for typemap matching when wrapping variables, in particular
|
||||
std::string, so that std::string variables can be easily marshalled with
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@
|
|||
<li><a href="#Chicken_nn10">Exceptions</a>
|
||||
</ul>
|
||||
<li><a href="#Chicken_nn11">TinyCLOS</a>
|
||||
<li><a href="#Chicken_nn12">Compilation</a>
|
||||
<li><a href="#Chicken_nn13">Linkage</a>
|
||||
<li><a href="#Chicken_nn12">Linkage</a>
|
||||
<ul>
|
||||
<li><a href="#Chicken_nn14">Shared library</a>
|
||||
<li><a href="#Chicken_nn15">Static binary</a>
|
||||
<li><a href="#Chicken_nn13">Static binary or shared library linked at compile time</a>
|
||||
<li><a href="#Chicken_nn14">Building chicken extension libraries</a>
|
||||
<li><a href="#Chicken_nn15">Linking multiple SWIG modules with TinyCLOS</a>
|
||||
</ul>
|
||||
<li><a href="#Chicken_nn16">Typemaps</a>
|
||||
<li><a href="#Chicken_nn17">Pointers</a>
|
||||
|
|
@ -205,7 +205,7 @@
|
|||
</ol>
|
||||
|
||||
<p>
|
||||
In all cases, the constants may be accessed from with CHICKEN
|
||||
In all cases, the constants may be accessed from within CHICKEN
|
||||
using the form <tt>(MYCONSTANT1)</tt>; that is, the constants
|
||||
may be accessed using the read-only parameter form.
|
||||
</p>
|
||||
|
|
@ -247,7 +247,7 @@
|
|||
|
||||
<p>Chicken supports both the <code>SWIG_exception(int code, const char *msg)</code> interface
|
||||
as well as a <code>SWIG_ThrowException(C_word val)</code> function for throwing exceptions from
|
||||
inside the %exception blocks. <code>SWIG_exception</code> will throw a list consiting of the code
|
||||
inside the %exception blocks. <code>SWIG_exception</code> will throw a list consisting of the code
|
||||
(as an integer) and the message. Both of these will throw an exception using <code>(abort)</code>,
|
||||
which can be handled by <code>(handle-exceptions)</code>. See
|
||||
<a href="http://www.call-with-current-continuation.org/manual/Exceptions.html#Exceptions">Chicken manual on Exceptions</a>
|
||||
|
|
@ -378,7 +378,7 @@ $ csc -v test_script.scm -lexample
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<p>An alternative is the test_script.scm can have the code <code>(load-library 'example "example.so")</code>,
|
||||
<p>An alternative is that the test_script.scm can have the code <code>(load-library 'example "example.so")</code>,
|
||||
in which case the test script does not need to be linked with example.so. The test_script.scm file can then
|
||||
be run with <tt>csi</tt>.
|
||||
</p>
|
||||
|
|
@ -388,8 +388,8 @@ be run with <tt>csi</tt>.
|
|||
|
||||
<p>Building a shared library like in the above section only works if the library
|
||||
is linked at compile time with a script containing <code>(declare (uses ...))</code> or is
|
||||
loaded explictetly with <code>(load-library 'example "example.so")</code>. It is
|
||||
not the format that chicken expects for extension libraries and eggs. The problem is the
|
||||
loaded explicitly with <code>(load-library 'example "example.so")</code>. It is
|
||||
not the format that CHICKEN expects for extension libraries and eggs. The problem is the
|
||||
<code>(declare (unit <i>modname</i>))</code> inside the <tt>modname.scm</tt> file. There are
|
||||
two possible solutions to this.</p>
|
||||
|
||||
|
|
@ -405,7 +405,7 @@ $ csc -sv modname.scm modname_wrap.c modname_impl.c -o modname.so
|
|||
|
||||
<p>This library can then be loaded by scheme code with the <code>(require 'modname)</code> function.
|
||||
See <a href="http://www.call-with-current-continuation.org/manual/Loading-extension-libraries.html">
|
||||
Loading-extension-libraries</a> in the eval unit inside the Chicken manual for more information.</p>
|
||||
Loading-extension-libraries</a> in the eval unit inside the CHICKEN manual for more information.</p>
|
||||
|
||||
<p>Another alternative is to run SWIG normally and create a scheme file that contains <code>(declare (uses <i>modname</i>))</code>
|
||||
and then compile that file into the shared library as well. For example, inside the <tt>mod_load.scm</tt> file,</p>
|
||||
|
|
@ -443,6 +443,7 @@ two eggs, one using the first method and one using the second method.</p>
|
|||
|
||||
<H3><a name="Chicken_nn15"></a>17.4.3 Linking multiple SWIG modules with TinyCLOS</H3>
|
||||
|
||||
|
||||
<p>Linking together multiple modules that share type information using the <code>%import</code>
|
||||
directive while also using <tt>-proxy</tt> is more complicated. For example, if <tt>mod2.i</tt> imports <tt>mod1.i</tt>, then the
|
||||
<tt>mod2.scm</tt> file contains references to symbols declared in <tt>mod1.scm</tt>,
|
||||
|
|
|
|||
|
|
@ -10,5 +10,3 @@ zlib -- a wrapping of the zlib compression library
|
|||
|
||||
You should be able to run make in each of the examples. By default, a shared
|
||||
library will be built. Run make check to execute the test.
|
||||
|
||||
You can uncomment a few lines in the Makefile to build a static test exe.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ TARGET = class
|
|||
INCLUDE =
|
||||
SWIGOPT =
|
||||
CFLAGS =
|
||||
VARIANT = _csc
|
||||
VARIANT =
|
||||
|
||||
# uncomment the following lines to build a static exe (only pick one of the CHICKEN_MAIN lines)
|
||||
#CHICKEN_MAIN = test-lowlevel-class.scm
|
||||
|
|
|
|||
|
|
@ -64,8 +64,9 @@
|
|||
(display "\nGuess I'll clean up now\n")
|
||||
|
||||
;; Note: this invokes the virtual destructor
|
||||
(delete-Shape c)
|
||||
(delete-Shape s)
|
||||
(set! c #f)
|
||||
(set! s #f)
|
||||
(gc #t)
|
||||
|
||||
(set! s 3)
|
||||
(display (Shape-nshapes))
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
;; ----- Access a static member -----
|
||||
|
||||
(display "\nA total of ")
|
||||
(display (nshapes))
|
||||
(display (Shape-nshapes))
|
||||
(display " shapes were created\n")
|
||||
|
||||
;; ----- Member data access -----
|
||||
|
|
@ -67,9 +67,9 @@
|
|||
;; Note: Invoke the virtual destructors by forcing garbage collection
|
||||
(set! c 77)
|
||||
(set! s 88)
|
||||
;(gc #t)
|
||||
(gc #t)
|
||||
|
||||
(display (nshapes))
|
||||
(display (Shape-nshapes))
|
||||
(display " shapes remain\n")
|
||||
(display "Goodbye\n")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
;; run with './constants test-constants.scm'
|
||||
;; feel free to uncomment and comment sections
|
||||
|
||||
(load-library 'example "constants.so")
|
||||
(declare (uses example))
|
||||
(load-library 'example "./constants.so")
|
||||
|
||||
(display "starting test ... you will see 'finished' if successful.\n")
|
||||
(or (= (ICONST) 42) (exit 1))
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
;; feel free to uncomment and comment sections
|
||||
|
||||
(load-library 'example "multimap.so")
|
||||
(declare (uses example))
|
||||
|
||||
(display "(gcd 90 12): ")
|
||||
(display (gcd 90 12))
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
;; This file demonstrates the overloading capabilities of SWIG
|
||||
|
||||
(load-library 'example "overload.so")
|
||||
(declare (uses example))
|
||||
(declare (uses tinyclos))
|
||||
|
||||
;; Low level
|
||||
;; ---------
|
||||
|
|
@ -40,7 +38,7 @@ Trying TinyCLOS code ...
|
|||
(foo 1)
|
||||
(foo "some string")
|
||||
(define A-FOO (make <Foo>))
|
||||
(define ANOTHER-FOO (make <Foo> (slot-ref A-FOO 'swig-this))) ;; copy constructor
|
||||
(define ANOTHER-FOO (make <Foo> A-FOO)) ;; copy constructor
|
||||
(bar A-FOO 2)
|
||||
(bar ANOTHER-FOO "another string" 3)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@
|
|||
|
||||
extern double My_variable;
|
||||
extern int fact(int);
|
||||
%name(mod) extern int my_mod(int n, int m);
|
||||
%rename(mod) my_mod;
|
||||
extern int my_mod(int n, int m);
|
||||
extern char *get_time();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
;; feel free to uncomment and comment sections
|
||||
(load-library 'example "simple.so")
|
||||
(declare (uses example))
|
||||
|
||||
(display "(My-variable): ")
|
||||
(display (My-variable))
|
||||
|
|
@ -14,31 +13,14 @@
|
|||
(display (My-variable))
|
||||
(display "\n")
|
||||
|
||||
(display "(My-variable 'a): ")
|
||||
;;(display (My-variable 'a))
|
||||
(display "\n")
|
||||
|
||||
(display "(My-variable 1.5 'b): ")
|
||||
(display (My-variable 1.5 'b))
|
||||
(display "\n")
|
||||
|
||||
(display "(fact 5): ")
|
||||
(display (fact 5))
|
||||
(display "\n")
|
||||
|
||||
(display "(fact 'a): ")
|
||||
;;(display (fact 'a))
|
||||
(display "\n")
|
||||
|
||||
(display "(mod 75 7): ")
|
||||
(display (mod 75 7))
|
||||
(display "\n")
|
||||
|
||||
(display "(my-mod 75 7): ")
|
||||
(display (my-mod 75 7))
|
||||
(display "\n")
|
||||
|
||||
|
||||
(display "(get-time): ")
|
||||
(display (get-time))
|
||||
(display "\n")
|
||||
|
|
|
|||
|
|
@ -5,27 +5,24 @@ SRCS =
|
|||
CXXSRCS =
|
||||
TARGET = zlib
|
||||
INCLUDE =
|
||||
SWIGOPT = -I/usr/include -mixed -prefix zlib
|
||||
SWIGOPT = -I/usr/include
|
||||
CFLAGS =
|
||||
VARIANT =
|
||||
LIBS = -lz
|
||||
|
||||
# comment out the following two lines to build a dynamic exe
|
||||
CHICKEN_MAIN = test-zlib.scm
|
||||
VARIANT = _static
|
||||
VARIANT = _direct
|
||||
|
||||
all:: $(TARGET)
|
||||
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_clean
|
||||
rm -f example.scm example-generic.scm example-clos.scm
|
||||
rm -f example.scm
|
||||
rm -f $(TARGET)
|
||||
|
||||
check::
|
||||
csi -batch simple.so test-zlib.scm
|
||||
csi test-zlib.scm
|
||||
|
|
|
|||
|
|
@ -1,45 +1,43 @@
|
|||
;; run with './zlib test-zlib.scm'
|
||||
|
||||
(declare (uses example))
|
||||
(declare (uses format))
|
||||
(load-library 'example "./zlib.so")
|
||||
|
||||
;; Init zstream
|
||||
(define s (zlib:new-z-stream))
|
||||
(zlib:z-stream-zalloc-set s #f)
|
||||
(zlib:z-stream-zfree-set s #f)
|
||||
(zlib:z-stream-opaque-set s #f)
|
||||
(zlib:deflate-init s (zlib:z-default-compression))
|
||||
(define s (new-z-stream))
|
||||
(z-stream-zalloc-set s #f)
|
||||
(z-stream-zfree-set s #f)
|
||||
(z-stream-opaque-set s #f)
|
||||
(deflate-init s (Z-DEFAULT-COMPRESSION))
|
||||
|
||||
;; Deflate something small so we don't need to loop/stream data
|
||||
(define in "some pony et jumping et jack et flash et had a jack pony")
|
||||
(define out (make-string 1000))
|
||||
(format #t "to be compressed: ~A~%to be compressed bytes: ~D~%~%" in (string-length in))
|
||||
(zlib:z-stream-next-in-set s in)
|
||||
(zlib:z-stream-avail-in-set s (string-length in))
|
||||
(zlib:z-stream-next-out-set s out)
|
||||
(zlib:z-stream-avail-out-set s (string-length out))
|
||||
(printf "to be compressed: ~A~%to be compressed bytes: ~A~%~%" in (string-length in))
|
||||
(z-stream-next-in-set s in)
|
||||
(z-stream-avail-in-set s (string-length in))
|
||||
(z-stream-next-out-set s out)
|
||||
(z-stream-avail-out-set s (string-length out))
|
||||
(let*
|
||||
((saved-out (zlib:z-stream-save-next-out s))
|
||||
(ret (zlib:deflate s (zlib:z-finish))))
|
||||
((saved-out (z-stream-save-next-out s))
|
||||
(ret (deflate s (Z-FINISH))))
|
||||
(cond
|
||||
((= ret (zlib:z-stream-end))
|
||||
(format #t "deflated properly!~%compressed bytes: ~D~%compressed stream: ~S~%"
|
||||
(zlib:z-stream-total-out-get s) (zlib:z-stream-get-next-chunk s saved-out)))
|
||||
((= ret (zlib:z-ok))
|
||||
((= ret (Z-STREAM-END))
|
||||
(printf "deflated properly!~%compressed bytes: ~A~%compressed stream: ~A~%"
|
||||
(z-stream-total-out-get s) (z-stream-get-next-chunk s saved-out)))
|
||||
((= ret (Z-OK))
|
||||
(display "only partial deflation ... not enough output space\n"))
|
||||
(else
|
||||
(format #t "deflate error(~D): ~A ~%" ret (zlib:z-stream-msg-get s)))))
|
||||
(printf "deflate error(~D): ~A ~%" ret (z-stream-msg-get s)))))
|
||||
|
||||
;; Use simple compress routine, and set max output size to 100
|
||||
(define c (zlib:compress 100 in))
|
||||
(define c (compress 100 in))
|
||||
(newline)
|
||||
(let
|
||||
((ret (car c))
|
||||
(compressed (cadr c)))
|
||||
(cond
|
||||
((= ret (zlib:z-ok))
|
||||
(format #t "compressed properly!~%compressed bytes: ~D~%compressed stream: ~S~%"
|
||||
((= ret (Z-OK))
|
||||
(printf "compressed properly!~%compressed bytes: ~A~%compressed stream: ~A~%"
|
||||
(string-length compressed) compressed))
|
||||
(else
|
||||
(format #t "compress error(~D): ~A ~%" ret (zlib:z-error ret)))))
|
||||
(printf "compress error(~D): ~A ~%" ret (z-error ret)))))
|
||||
|
||||
(exit 0)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ SO = @SO@
|
|||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
SWIGOPT +=
|
||||
SWIGOPT += -nounit
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
|
|
@ -41,6 +41,9 @@ SWIGOPT +=
|
|||
$(setup) \
|
||||
($(swig_and_compile_multi_cpp); ) && \
|
||||
$(run_testcase)
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then ( \
|
||||
$(MAKE) $*.multiproxy; ) \
|
||||
fi;
|
||||
|
||||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.scm appended after the testcase name.
|
||||
|
|
@ -65,6 +68,13 @@ run_testcase = \
|
|||
($(swig_and_compile_c); ) && \
|
||||
$(run_testcase)
|
||||
|
||||
%.multiproxy: SWIGOPT += -proxy -noclosuses
|
||||
%.multiproxy: SCRIPTSUFFIX = $(PROXYSUFFIX)
|
||||
%.multiproxy:
|
||||
echo "Checking testcase $* (with run test) under chicken with -proxy"; \
|
||||
($(swig_and_compile_multi_cpp); ) && \
|
||||
$(run_testcase)
|
||||
|
||||
# Clean
|
||||
%.clean:
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(load-library 'casts "casts.so")
|
||||
(load "casts.so")
|
||||
(include "../schemerunme/casts.scm")
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(load-library 'char_constant "char_constant.so")
|
||||
(load "char_constant.so")
|
||||
(include "../schemerunme/char_constant.scm")
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(load-library 'class_ignore "class_ignore.so")
|
||||
(load "class_ignore.so")
|
||||
(include "../schemerunme/class_ignore.scm")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,95 @@
|
|||
(require 'clientdata_prop_a)
|
||||
(require 'clientdata_prop_b)
|
||||
|
||||
(define a (make <A>))
|
||||
(test-A a)
|
||||
(test-tA a)
|
||||
(test-t2A a)
|
||||
(test-t3A a)
|
||||
(fA a)
|
||||
|
||||
(define b (make <B>))
|
||||
(test-A b)
|
||||
(test-tA b)
|
||||
(test-t2A b)
|
||||
(test-t3A b)
|
||||
(test-B b)
|
||||
(fA b)
|
||||
(fB b)
|
||||
|
||||
(define c (make <C>))
|
||||
(test-A c)
|
||||
(test-tA c)
|
||||
(test-t2A c)
|
||||
(test-t3A c)
|
||||
(test-C c)
|
||||
(fA c)
|
||||
(fC c)
|
||||
|
||||
(define d (make <D>))
|
||||
(test-A d)
|
||||
(test-tA d)
|
||||
(test-t2A d)
|
||||
(test-t3A d)
|
||||
(test-D d)
|
||||
(test-tD d)
|
||||
(test-t2D d)
|
||||
(fA d)
|
||||
(fD d)
|
||||
|
||||
;; here are the real tests... if the clientdata is correctly
|
||||
;; propegated, new-tA, new-t2A, should all return wrapped proxy's
|
||||
;; of class <A>
|
||||
|
||||
(define a2 (new-tA))
|
||||
(if (not (eq? (class-of a2) <A>))
|
||||
(error "Error 1"))
|
||||
(test-A a2)
|
||||
(test-tA a2)
|
||||
(test-t2A a2)
|
||||
(test-t3A a2)
|
||||
(fA a2)
|
||||
|
||||
(define a3 (new-t2A))
|
||||
(if (not (eq? (class-of a3) <A>))
|
||||
(error "Error 2"))
|
||||
(test-A a3)
|
||||
(test-tA a3)
|
||||
(test-t2A a3)
|
||||
(test-t3A a3)
|
||||
(fA a3)
|
||||
|
||||
(define a4 (new-t3A))
|
||||
(if (not (eq? (class-of a4) <A>))
|
||||
(error "Error 3"))
|
||||
(test-A a4)
|
||||
(test-tA a4)
|
||||
(test-t2A a4)
|
||||
(test-t3A a4)
|
||||
(fA a4)
|
||||
|
||||
(define d2 (new-tD))
|
||||
(if (not (eq? (class-of d2) <D>))
|
||||
(error "Error 4"))
|
||||
(test-A d2)
|
||||
(test-tA d2)
|
||||
(test-t2A d2)
|
||||
(test-t3A d2)
|
||||
(test-D d2)
|
||||
(test-tD d2)
|
||||
(fA d2)
|
||||
(fD d2)
|
||||
|
||||
(define d3 (new-t2D))
|
||||
(if (not (eq? (class-of d3) <D>))
|
||||
(error "Error 5"))
|
||||
(test-A d3)
|
||||
(test-tA d3)
|
||||
(test-t2A d3)
|
||||
(test-t3A d3)
|
||||
(test-D d3)
|
||||
(test-tD d3)
|
||||
(fA d3)
|
||||
(fD d3)
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
(load-library 'constover "constover.so")
|
||||
(load "constover.so")
|
||||
(include "../schemerunme/constover.scm")
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
(load-library 'contract "contract.so")
|
||||
(load "contract.so")
|
||||
(include "testsuite.ss")
|
||||
(include "../schemerunme/contract.scm")
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue