mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-09 23:40:29 +02:00
add a test for foreign functions taking struct args
* test-suite/standalone/test-ffi (f-sum-struct): * test-suite/standalone/test-ffi-lib.c (test_ffi_sum_struct): Add a struct test. Wheee....
This commit is contained in:
parent
75383ddbd7
commit
c612ed59ab
2 changed files with 24 additions and 0 deletions
|
@ -143,6 +143,16 @@ exec guile -q -s "$0" "$@"
|
|||
(test (f-sum -1 2000 -30000 40000000000)
|
||||
(+ -1 2000 -30000 40000000000))
|
||||
|
||||
;;
|
||||
;; Structs
|
||||
;;
|
||||
(define f-sum-struct
|
||||
(make-foreign-function int64 (dynamic-func "test_ffi_sum_struct" lib)
|
||||
(list (list int8 int16 int32 int64))))
|
||||
(test (f-sum-struct (make-c-struct (list int8 int16 int32 int64)
|
||||
(list -1 2000 -30000 40000000000)))
|
||||
(+ -1 2000 -30000 40000000000))
|
||||
|
||||
|
||||
;; Local Variables:
|
||||
;; mode: scheme
|
||||
|
|
|
@ -192,3 +192,17 @@ scm_t_int64 test_ffi_sum (scm_t_int8 a, scm_t_int16 b,
|
|||
{
|
||||
return d + c + b + a;
|
||||
}
|
||||
|
||||
|
||||
struct foo
|
||||
{
|
||||
scm_t_int8 a;
|
||||
scm_t_int16 b;
|
||||
scm_t_int32 c;
|
||||
scm_t_int64 d;
|
||||
};
|
||||
scm_t_int64 test_ffi_sum_struct (struct foo foo);
|
||||
scm_t_int64 test_ffi_sum_struct (struct foo foo)
|
||||
{
|
||||
return foo.d + foo.c + foo.b + foo.a;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue