From f3c0481a74e3289b222c26051fc817cc69e133a6 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Sun, 10 Mar 2002 22:29:47 +0000 Subject: [PATCH] r1544: *** empty log message *** --- doc/notes.sgml | 27 +++++++++++++++++++-------- doc/ref.sgml | 4 +++- examples/gettime.cl | 26 ++++++++++++++------------ src/aggregates.cl | 8 ++++---- src/primitives.cl | 6 +++--- tests/gettime.cl | 26 ++++++++++++++------------ 6 files changed, 57 insertions(+), 40 deletions(-) diff --git a/doc/notes.sgml b/doc/notes.sgml index 8dfb3e5..cdb5f6d 100644 --- a/doc/notes.sgml +++ b/doc/notes.sgml @@ -64,14 +64,25 @@ Cross-Implementation Optimization -To fully optimize across platforms, both explicit type information -must be passed to dereferencing of pointers and arrays. Though this -optimization only helps with &acl;, &uffi; is designed to require this -type information be passed the dereference functions. Second, declarations -of type should be made in functions, structures, and classes where -foreign objects will be help. This will optimize access for &lw; - - + + To fully optimize across platforms, both explicit type + information must be passed to dereferencing of pointers and + arrays. Though this optimization only helps with &acl;, &uffi; + is designed to require this type information be passed the + dereference functions. Second, declarations of type should be + made in functions, structures, and classes where foreign + objects will be help. This will optimize access for &lw; + + + Here is an example that should both methods being used for + maximum cross-implementation optimization: + +(let ((a-foreign-struct (allocate-foreign-object 'the-struct-type))) + (uffi-declare 'the-struct-type a-foreign-struct) + (get-slot-value a-foreign-struct 'the-struct-type 'field-name)) + + + diff --git a/doc/ref.sgml b/doc/ref.sgml index 2935dcf..33f8a56 100644 --- a/doc/ref.sgml +++ b/doc/ref.sgml @@ -471,7 +471,9 @@ a session. Examples - (load-foreign-library #p"/usr/lib/libmysqlclient.so" "mysql" '("c")) + (load-foreign-library #p"/usr/lib/libmysqlclient.so" + :module "mysql" + :supporting-libraries '("c")) => T diff --git a/examples/gettime.cl b/examples/gettime.cl index be0bdee..a093306 100644 --- a/examples/gettime.cl +++ b/examples/gettime.cl @@ -9,7 +9,7 @@ ;;;; ;;;; Copyright (c) 2002 Kevin M. Rosenberg ;;;; -;;;; $Id: gettime.cl,v 1.3 2002/03/10 04:15:33 kevin Exp $ +;;;; $Id: gettime.cl,v 1.4 2002/03/10 22:29:47 kevin Exp $ ;;;; ;;;; This file is part of UFFI. ;;;; @@ -53,18 +53,20 @@ (defun gettime () "Returns the local time" (let* ((time (uffi:allocate-foreign-object time-t))) +;; (uffi:uffi-declare time-t time) (c-time time) - (let* ((tm-ptr (c-localtime time)) - (time-string (format nil "~2d/~2,'0d/~d ~2d:~2,'0d:~2,'0d" - (1+ (uffi:get-slot-value tm-ptr 'mon 'tm)) - (uffi:get-slot-value tm-ptr 'mday 'tm) - (+ 1900 (uffi:get-slot-value tm-ptr 'year 'tm)) - (uffi:get-slot-value tm-ptr 'hour 'tm) - (uffi:get-slot-value tm-ptr 'min 'tm) - (uffi:get-slot-value tm-ptr 'sec 'tm) - ))) - (uffi:free-foreign-object time) - time-string) + (let ((tm-ptr (c-localtime time))) +;; (uffi:uffi-declare (* tm) tm-ptr) + (let ((time-string (format nil "~2d/~2,'0d/~d ~2d:~2,'0d:~2,'0d" + (1+ (uffi:get-slot-value tm-ptr 'tm 'mon)) + (uffi:get-slot-value tm-ptr 'tm 'mday) + (+ 1900 (uffi:get-slot-value tm-ptr 'tm 'year)) + (uffi:get-slot-value tm-ptr 'tm 'hour) + (uffi:get-slot-value tm-ptr 'tm 'min) + (uffi:get-slot-value tm-ptr 'tm 'sec) + ))) + (uffi:free-foreign-object time) + time-string)) )) #+test-uffi diff --git a/src/aggregates.cl b/src/aggregates.cl index bf163c8..64a0e28 100644 --- a/src/aggregates.cl +++ b/src/aggregates.cl @@ -9,7 +9,7 @@ ;;;; ;;;; Copyright (c) 2002 Kevin M. Rosenberg ;;;; -;;;; $Id: aggregates.cl,v 1.2 2002/03/10 11:13:07 kevin Exp $ +;;;; $Id: aggregates.cl,v 1.3 2002/03/10 22:29:47 kevin Exp $ ;;;; ;;;; This file is part of the UFFI. ;;;; @@ -95,7 +95,7 @@ of the enum-name name, separator-string, and field-name" ) -(defmacro get-slot-value (obj slot type) +(defmacro get-slot-value (obj type slot) #+(or lispworks cmu) (declare (ignore type)) #+allegro `(ff:fslot-value-typed ,type :c ,obj ,slot) @@ -105,7 +105,7 @@ of the enum-name name, separator-string, and field-name" `(alien:slot ,obj ,slot) ) -(defmacro get-slot-pointer (obj slot type) +(defmacro get-slot-pointer (obj type slot) #+(or lispworks cmu) (declare (ignore type)) #+allegro `(ff:fslot-value-typed ,type :c ,obj ,slot) @@ -115,7 +115,7 @@ of the enum-name name, separator-string, and field-name" `(alien:slot ,obj ,slot) ) -(defmacro deref-array (obj i type) +(defmacro deref-array (obj type i) "Returns a field from a row" #+(or lispworks cmu) (declare (ignore type)) #+cmu `(alien:deref ,obj ,i) diff --git a/src/primitives.cl b/src/primitives.cl index c5c6450..a0bcae7 100644 --- a/src/primitives.cl +++ b/src/primitives.cl @@ -9,7 +9,7 @@ ;;;; ;;;; Copyright (c) 2002 Kevin M. Rosenberg ;;;; -;;;; $Id: primitives.cl,v 1.1 2002/03/10 21:48:50 kevin Exp $ +;;;; $Id: primitives.cl,v 1.2 2002/03/10 22:29:47 kevin Exp $ ;;;; ;;;; This file is part of the UFFI. ;;;; @@ -42,7 +42,7 @@ supports this." #+(or lispworks allegro) (declare (ignore type name)) #+cmu - `(declare (type (alien ,type) ,name)) + `(declare (type (alien:alien ,type)) ,name) ) (defmacro slot-type (type) @@ -90,7 +90,7 @@ supports this." '((* . *) (:void . c-call:void) (:short . c-call:short) (:pointer-void . (* t)) - (:cstring . c-call:cstring) + (:cstring . c-call:c-string) (:char . c-call:char) (:unsigned-char . (alien:unsigned 8)) (:byte . (alien:unsigned 8)) diff --git a/tests/gettime.cl b/tests/gettime.cl index be0bdee..a093306 100644 --- a/tests/gettime.cl +++ b/tests/gettime.cl @@ -9,7 +9,7 @@ ;;;; ;;;; Copyright (c) 2002 Kevin M. Rosenberg ;;;; -;;;; $Id: gettime.cl,v 1.3 2002/03/10 04:15:33 kevin Exp $ +;;;; $Id: gettime.cl,v 1.4 2002/03/10 22:29:47 kevin Exp $ ;;;; ;;;; This file is part of UFFI. ;;;; @@ -53,18 +53,20 @@ (defun gettime () "Returns the local time" (let* ((time (uffi:allocate-foreign-object time-t))) +;; (uffi:uffi-declare time-t time) (c-time time) - (let* ((tm-ptr (c-localtime time)) - (time-string (format nil "~2d/~2,'0d/~d ~2d:~2,'0d:~2,'0d" - (1+ (uffi:get-slot-value tm-ptr 'mon 'tm)) - (uffi:get-slot-value tm-ptr 'mday 'tm) - (+ 1900 (uffi:get-slot-value tm-ptr 'year 'tm)) - (uffi:get-slot-value tm-ptr 'hour 'tm) - (uffi:get-slot-value tm-ptr 'min 'tm) - (uffi:get-slot-value tm-ptr 'sec 'tm) - ))) - (uffi:free-foreign-object time) - time-string) + (let ((tm-ptr (c-localtime time))) +;; (uffi:uffi-declare (* tm) tm-ptr) + (let ((time-string (format nil "~2d/~2,'0d/~d ~2d:~2,'0d:~2,'0d" + (1+ (uffi:get-slot-value tm-ptr 'tm 'mon)) + (uffi:get-slot-value tm-ptr 'tm 'mday) + (+ 1900 (uffi:get-slot-value tm-ptr 'tm 'year)) + (uffi:get-slot-value tm-ptr 'tm 'hour) + (uffi:get-slot-value tm-ptr 'tm 'min) + (uffi:get-slot-value tm-ptr 'tm 'sec) + ))) + (uffi:free-foreign-object time) + time-string)) )) #+test-uffi -- 2.34.1