uffi/tests foreign-var.lisp,1.2,1.3 uffi-c-test-lib.c,1.3,1.4
"Kevin M. Rosenberg" <[email protected]> Fri, 15 Aug 2003 02:34:37 +0000
| Newsgroups | gmane.lisp.uffi.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /pubcvs/uffi/tests
In directory boa.b9.com:/tmp/cvs-serv27219/tests
Modified Files:
foreign-var.lisp uffi-c-test-lib.c
Log Message:
Index: foreign-var.lisp
===================================================================
RCS file: /pubcvs/uffi/tests/foreign-var.lisp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** foreign-var.lisp 14 Aug 2003 21:58:44 -0000 1.2
--- foreign-var.lisp 15 Aug 2003 02:34:34 -0000 1.3
***************
*** 33,34 ****
--- 33,82 ----
+ (uffi:def-foreign-var ("fvar_addend" *fvar-addend*) :int "uffi_tests")
+
+ (uffi:def-struct fvar-struct
+ (i :int)
+ (d :double))
+
+ (uffi:def-foreign-var ("fvar_struct" *fvar-struct*) fvar-struct
+ "uffi_tests")
+
+ (uffi:def-function ("fvar_struct_int" fvar-struct-int)
+ ()
+ :returning :int
+ :module "uffi_tests")
+
+ (uffi:def-function ("fvar_struct_double" fvar-struct-double)
+ ()
+ :returning :double
+ :module "uffi_tests")
+
+ (deftest fvarst.1 *fvar-addend* 3)
+ (deftest fvarst.2 (uffi:get-slot-value *fvar-struct* 'fvar-struct 'i) 42)
+ (deftest fvarst.3 (= (+ *fvar-addend*
+ (uffi:get-slot-value *fvar-struct* 'fvar-struct 'i))
+ (fvar-struct-int))
+ t)
+ (deftest fvarst.4 (uffi:get-slot-value *fvar-struct* 'fvar-struct 'd) 3.2d0)
+ (deftest fvarst.5 (= (uffi:get-slot-value *fvar-struct* 'fvar-struct 'd)
+ (fvar-struct-double))
+ t)
+
+ (deftest fvarst.6
+ (let ((orig *fvar-addend*))
+ (incf *fvar-addend* 3)
+ (prog1
+ *fvar-addend*
+ (setf *fvar-addend* orig)))
+ 6)
+
+ (deftest fvarst.7
+ (let ((orig *fvar-addend*))
+ (incf *fvar-addend* 3)
+ (prog1
+ (fvar-struct-int)
+ (setf *fvar-addend* orig)))
+ 48)
+
+ ;;(decf (uffi:get-slot-value *fvar-struct* 'fvar-struct 'i) 10)
+ ;;(deftest fvarst.8 (fvar-struct-int) 38)
Index: uffi-c-test-lib.c
===================================================================
RCS file: /pubcvs/uffi/tests/uffi-c-test-lib.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** uffi-c-test-lib.c 14 Aug 2003 21:40:13 -0000 1.3
--- uffi-c-test-lib.c 15 Aug 2003 02:34:34 -0000 1.4
***************
*** 119,120 ****
--- 119,141 ----
return y;
}
+
+ DLLEXPORT int fvar_addend = 3;
+
+ typedef struct {
+ int i;
+ double d;
+ } fvar_struct_type;
+
+ fvar_struct_type fvar_struct = {42, 3.2};
+
+ DLLEXPORT
+ int fvar_struct_int () {
+ return (fvar_addend + fvar_struct.i);
+ }
+
+ DLLEXPORT
+ double fvar_struct_double () {
+ return fvar_struct.d;
+ }
+
+