SWIG chicken module now returns multiple values instead of returning a list.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7156 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
420ba48099
commit
cee86ee739
10 changed files with 91 additions and 28 deletions
|
|
@ -1,6 +1,12 @@
|
||||||
Version 1.3.25 (In progress)
|
Version 1.3.25 (In progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
04/15/2005: wuzzeb (John Lenz)
|
||||||
|
[Chicken]
|
||||||
|
For wrapped functions that return multiple values (using argout),
|
||||||
|
SWIG CHICKEN now returns them as multiple values instead of as
|
||||||
|
a list. They can then be accessed using (call-with-values).
|
||||||
|
|
||||||
04/14/2005: wuzzeb (John Lenz)
|
04/14/2005: wuzzeb (John Lenz)
|
||||||
[Chicken]
|
[Chicken]
|
||||||
+ Added a whole bunch of new _runme scripts into the chicken test
|
+ Added a whole bunch of new _runme scripts into the chicken test
|
||||||
|
|
|
||||||
|
|
@ -230,10 +230,10 @@
|
||||||
<p>
|
<p>
|
||||||
A function may return more than one value by using the
|
A function may return more than one value by using the
|
||||||
<code>OUTPUT</code> specifier (see Lib/chicken/typemaps.i).
|
<code>OUTPUT</code> specifier (see Lib/chicken/typemaps.i).
|
||||||
They will be returned as a Scheme list if there is more than one
|
They will be returned as multiple values using <code>(values)</code> if there is more than one
|
||||||
result (that is, a non-void return value and at least one argout
|
result (that is, a non-void return value and at least one argout
|
||||||
parameter, or a void return value and at least two argout
|
parameter, or a void return value and at least two argout
|
||||||
parameters).
|
parameters). The return values can then be accessed with <code>(call-with-values)</code>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Chicken_nn10"></a>17.2.5 Exceptions</H3>
|
<H3><a name="Chicken_nn10"></a>17.2.5 Exceptions</H3>
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,8 @@
|
||||||
(display "\n")
|
(display "\n")
|
||||||
|
|
||||||
(display "(squarecubed 3: ")
|
(display "(squarecubed 3: ")
|
||||||
(display (squareCubed 3))
|
(call-with-values (lambda() (squareCubed 3))
|
||||||
|
(lambda (a b) (printf "~A ~A" a b)))
|
||||||
(display "\n")
|
(display "\n")
|
||||||
|
|
||||||
(exit)
|
(exit)
|
||||||
|
|
|
||||||
|
|
@ -28,16 +28,14 @@
|
||||||
(printf "deflate error(~D): ~A ~%" ret (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
|
;; Use simple compress routine, and set max output size to 100
|
||||||
(define c (compress 100 in))
|
|
||||||
(newline)
|
(newline)
|
||||||
(let
|
(call-with-values (lambda () (compress 100 in))
|
||||||
((ret (car c))
|
(lambda (ret compressed)
|
||||||
(compressed (cadr c)))
|
(cond
|
||||||
(cond
|
((= ret (Z-OK))
|
||||||
((= ret (Z-OK))
|
(printf "compressed properly!~%compressed bytes: ~A~%compressed stream: ~A~%"
|
||||||
(printf "compressed properly!~%compressed bytes: ~A~%compressed stream: ~A~%"
|
(string-length compressed) compressed))
|
||||||
(string-length compressed) compressed))
|
(else
|
||||||
(else
|
(printf "compress error(~D): ~A ~%" ret (z-error ret))))))
|
||||||
(printf "compress error(~D): ~A ~%" ret (z-error ret)))))
|
|
||||||
|
|
||||||
(exit 0)
|
(exit 0)
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,12 @@
|
||||||
(require 'li_typemaps)
|
(require 'li_typemaps)
|
||||||
(load "../schemerunme/li_typemaps.scm")
|
(load "../schemerunme/li_typemaps.scm")
|
||||||
|
|
||||||
|
(call-with-values (lambda () (inoutr-int2 3 -2))
|
||||||
|
(lambda (a b)
|
||||||
|
(if (not (and (= a 3) (= b -2)))
|
||||||
|
(error "Error in inoutr-int2"))))
|
||||||
|
(call-with-values (lambda () (out-foo 4))
|
||||||
|
(lambda (a b)
|
||||||
|
(if (not (and (= (Foo-a-get a) 4) (= b 8)))
|
||||||
|
(error "Error in out-foo"))))
|
||||||
|
(exit 0)
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,13 @@
|
||||||
(require 'li_typemaps)
|
(require 'li_typemaps)
|
||||||
(load "../schemerunme/li_typemaps_proxy.scm")
|
(load "../schemerunme/li_typemaps_proxy.scm")
|
||||||
|
|
||||||
|
(call-with-values (lambda () (inoutr-int2 3 -2))
|
||||||
|
(lambda (a b)
|
||||||
|
(if (not (and (= a 3) (= b -2)))
|
||||||
|
(error "Error in inoutr-int2"))))
|
||||||
|
(call-with-values (lambda () (out-foo 4))
|
||||||
|
(lambda (a b)
|
||||||
|
(if (not (and (= (slot-ref a 'a) 4) (= b 8)))
|
||||||
|
(error "Error in out-foo"))))
|
||||||
|
|
||||||
|
(exit 0)
|
||||||
|
|
|
||||||
|
|
@ -6,3 +6,13 @@
|
||||||
;; current module. That's enough for such a simple test.
|
;; current module. That's enough for such a simple test.
|
||||||
(dynamic-call "scm_init_li_typemaps_module" (dynamic-link "./libli_typemaps.so"))
|
(dynamic-call "scm_init_li_typemaps_module" (dynamic-link "./libli_typemaps.so"))
|
||||||
(load "../schemerunme/li_typemaps.scm")
|
(load "../schemerunme/li_typemaps.scm")
|
||||||
|
|
||||||
|
(let ((lst (inoutr-int2 3 -2)))
|
||||||
|
(if (not (and (= (car lst) 3) (= (cadr lst) -2)))
|
||||||
|
(error "Error in inoutr-int2")))
|
||||||
|
|
||||||
|
(let ((lst (out-foo 4)))
|
||||||
|
(if (not (and (= (Foo-a-get (car lst)) 4) (= (cadr lst) 8)))
|
||||||
|
(error "Error in out-foo")))
|
||||||
|
|
||||||
|
(exit 0)
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,23 @@
|
||||||
;(check "longlong" 1634 =)
|
;(check "longlong" 1634 =)
|
||||||
;(check "ulonglong" 6432 =)
|
;(check "ulonglong" 6432 =)
|
||||||
|
|
||||||
(let ((lst (inoutr-int2 3 -2)))
|
;; The checking of inoutr-int2 and out-foo is done in the individual
|
||||||
(if (not (and (= (car lst) 3) (= (cadr lst) -2)))
|
;; language runme scripts, since chicken returns multiple values
|
||||||
(error "Error in inoutr-int2")))
|
;; and must be checked with call-with-values, while guile just returns a list
|
||||||
|
|
||||||
(let ((lst (out-foo 4)))
|
;(call-with-values (lambda () (inoutr-int2 3 -2))
|
||||||
(if (not (and (= (Foo-a-get (car lst)) 4) (= (cadr lst) 8)))
|
; (lambda (a b)
|
||||||
(error "Error in out-foo")))
|
; (if (not (and (= a 3) (= b -2)))
|
||||||
|
; (error "Error in inoutr-int2"))))
|
||||||
|
;(call-with-values (lambda () (out-foo 4))
|
||||||
|
; (lambda (a b)
|
||||||
|
; (if (not (and (= (Foo-a-get a) 4) (= b 8)))
|
||||||
|
; (error "Error in out-foo"))))
|
||||||
|
|
||||||
|
;(let ((lst (inoutr-int2 3 -2)))
|
||||||
|
; (if (not (and (= (car lst) 3) (= (cadr lst) -2)))
|
||||||
|
; (error "Error in inoutr-int2")))
|
||||||
|
|
||||||
(exit 0)
|
;(let ((lst (out-foo 4)))
|
||||||
|
; (if (not (and (= (Foo-a-get (car lst)) 4) (= (cadr lst) 8)))
|
||||||
|
; (error "Error in out-foo")))
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,23 @@
|
||||||
(check "longlong" 1634 =)
|
(check "longlong" 1634 =)
|
||||||
(check "ulonglong" 6432 =)
|
(check "ulonglong" 6432 =)
|
||||||
|
|
||||||
(let ((lst (inoutr-int2 3 -2)))
|
;; The checking of inoutr-int2 and out-foo is done in the individual
|
||||||
(if (not (and (= (car lst) 3) (= (cadr lst) -2)))
|
;; language runme scripts, since chicken returns multiple values
|
||||||
(error "Error in inoutr-int2")))
|
;; and must be checked with call-with-values, while guile just returns a list
|
||||||
|
|
||||||
(let ((lst (out-foo 4)))
|
;(call-with-values (lambda () (inoutr-int2 3 -2))
|
||||||
(if (not (and (= (slot-ref (car lst) 'a) 4) (= (cadr lst) 8)))
|
; (lambda (a b)
|
||||||
(error "Error in out-foo")))
|
; (if (not (and (= a 3) (= b -2)))
|
||||||
|
; (error "Error in inoutr-int2"))))
|
||||||
|
;(call-with-values (lambda () (out-foo 4))
|
||||||
|
; (lambda (a b)
|
||||||
|
; (if (not (and (= (slot-ref a 'a) 4) (= b 8)))
|
||||||
|
; (error "Error in out-foo"))))
|
||||||
|
|
||||||
(exit 0)
|
;(let ((lst (inoutr-int2 3 -2)))
|
||||||
|
; (if (not (and (= (car lst) 3) (= (cadr lst) -2)))
|
||||||
|
; (error "Error in inoutr-int2")))
|
||||||
|
|
||||||
|
;(let ((lst (out-foo 4)))
|
||||||
|
; (if (not (and (= (slot-ref (car lst) 'a) 4) (= (cadr lst) 8)))
|
||||||
|
; (error "Error in out-foo")))
|
||||||
|
|
|
||||||
|
|
@ -602,8 +602,13 @@ CHICKEN::functionWrapper(Node *n)
|
||||||
"else\n",
|
"else\n",
|
||||||
" C_kontinue(continuation, resultobj);\n",
|
" C_kontinue(continuation, resultobj);\n",
|
||||||
"}\n", NIL);
|
"}\n", NIL);
|
||||||
|
} else if (Wrapper_check_local(f, "gswig_list_p")) {
|
||||||
|
Printv(f->code,"if (gswig_list_p)\n",
|
||||||
|
" C_apply_values(3, C_SCHEME_UNDEFINED, continuation, resultobj);\n",
|
||||||
|
"else\n",
|
||||||
|
" C_kontinue(continuation, resultobj);\n", NIL);
|
||||||
} else {
|
} else {
|
||||||
Printf(f->code," C_kontinue (continuation, resultobj);\n");
|
Printf(f->code,"C_kontinue (continuation, resultobj);\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Error handling code */
|
/* Error handling code */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue