uffi/tests casts.lisp,NONE,1.1 pointers.lisp,NONE,1.1 structs.lisp,1.1,1.2 uffi-c-test-lib.c,1.1,1.2
"Kevin M. Rosenberg" <[email protected]> Thu, 14 Aug 2003 19:35:07 +0000
| Newsgroups | gmane.lisp.uffi.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /pubcvs/uffi/tests
In directory boa.b9.com:/tmp/cvs-serv14284/tests
Modified Files:
structs.lisp uffi-c-test-lib.c
Added Files:
casts.lisp pointers.lisp
Log Message:
--- NEW FILE: casts.lisp ---
;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
;;;; Name: casts
;;;; Purpose: Tests of with-cast-pointer
;;;; Programmer: Kevin M. Rosenberg / Edi Weitz
;;;; Date Started: Aug 2003
;;;;
;;;; $Id: casts.lisp,v 1.1 2003/08/14 19:35:05 kevin Exp $
;;;;
;;;; *************************************************************************
(in-package #:uffi-tests)
(uffi:def-function ("cast_test_int" cast-test-int)
()
:returning :pointer-void)
(uffi:def-function ("cast_test_float" cast-test-float)
()
:returning :pointer-void)
(deftest cast.1
(progn
(uffi:with-cast-pointer (temp (cast-test-int) :int)
(assert (= (uffi:deref-pointer temp :int) 23)))
(let ((result (cast-test-int)))
(uffi:with-cast-pointer (result2 result :int)
(assert (= (uffi:deref-pointer result2 :int) 23)))
(uffi:with-cast-pointer (temp result :int)
(assert (= (uffi:deref-pointer temp :int) 23))))
t)
t)
(deftest cast.2
(progn
(uffi:with-cast-pointer (temp (cast-test-float) :double)
(assert (= (uffi:deref-pointer temp :double) 3.21d0)))
(let ((result (cast-test-float)))
(uffi:with-cast-pointer (result2 result :double)
(assert (= (uffi:deref-pointer result2 :double) 3.21d0)))
(uffi:with-cast-pointer (temp result :double)
(assert (= (uffi:deref-pointer temp :double) 3.21d0))))
t)
t)
--- NEW FILE: pointers.lisp ---
;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
;;;; Name: pointers.lisp
;;;; Purpose: Test file for UFFI pointers
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Aug 2003
;;;;
;;;; $Id: pointers.lisp,v 1.1 2003/08/14 19:35:05 kevin Exp $
;;;;
;;;; This file, part of UFFI, is Copyright (c) 2003 by Kevin M. Rosenberg
;;;;
;;;; *************************************************************************
(in-package #:uffi-tests)
(deftest chptr.1
(let ((native-string "test string"))
(uffi:with-foreign-string (fs native-string)
(characterp
(ensure-char-character
(deref-pointer fs :char)))))
t)
(deftest chptr.2
(let ((native-string "test string"))
(uffi:with-foreign-string (fs native-string)
(characterp
(ensure-char-character
(deref-pointer fs :unsigned-char)))))
t)
(deftest chptr.3
(let ((native-string "test string"))
(uffi:with-foreign-string (fs native-string)
(numberp
(deref-pointer fs :byte))))
t)
Index: uffi-c-test-lib.c
===================================================================
RCS file: /pubcvs/uffi/tests/uffi-c-test-lib.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** uffi-c-test-lib.c 29 Apr 2003 14:08:02 -0000 1.1
--- uffi-c-test-lib.c 14 Aug 2003 19:35:05 -0000 1.2
***************
*** 94,95 ****
--- 94,111 ----
+ DLLEXPORT
+ void *
+ cast_test_int () {
+ int *x = (int *) malloc(sizeof(int));
+ *x = 23;
+ return x;
+ }
+
+ DLLEXPORT
+ void *
+ cast_test_float ()
+ {
+ double *y = (double *) malloc(sizeof(double));
+ *y = 3.21;
+ return y;
+ }
Index: structs.lisp
===================================================================
RCS file: /pubcvs/uffi/tests/structs.lisp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** structs.lisp 13 Aug 2003 18:53:42 -0000 1.1
--- structs.lisp 14 Aug 2003 19:35:05 -0000 1.2
***************
*** 4,8 ****
;;;;
;;;; Name: structs.lisp
! ;;;; Purpose: UFFI Example file to strtol, uses pointer arithmetic
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
--- 4,8 ----
;;;;
;;;; Name: structs.lisp
! ;;;; Purpose: Test file for UFFI structures
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
***************
*** 10,14 ****
;;;; $Id$
;;;;
! ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
;;;; *************************************************************************
--- 10,14 ----
;;;; $Id$
;;;;
! ;;;; This file, part of UFFI, is Copyright (c) 2002-2003 by Kevin M. Rosenberg
;;;;
;;;; *************************************************************************
***************
*** 24,34 ****
(uffi:def-foreign-type foo-ptr (* foo))
! (uffi:def-function "baz"
! ((x :int))
! :returning foo-ptr
! :module "frob")
!
! (defun test ()
(with-foreign-object (p 'foo)
! (baz p)))
--- 24,31 ----
(uffi:def-foreign-type foo-ptr (* foo))
! ;; tests that compilation worked
! (deftest structs.1
(with-foreign-object (p 'foo)
! t)
! t)