Changeset 34 for trunk/init

Show
Ignore:
Timestamp:
03/11/08 01:34:13 (8 months ago)
Author:
lhealy
Message:

The classes/types in the different contexts are now gathered together
in one place, in *type-names* for the types and in *data-class-name*
for data classes, populated by #'add-data-class. Both defdata and
defmfun-all use the table and so mapping between various names is
consistent. The data class names are now different, *-double-float
and *-single-float replaces *-double and *-single. The regression
tests give the same results as before.

Location:
trunk/init
Files:
1 removed
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/init/init.lisp

    r26 r34  
    11;; Load GSL 
    22;; Liam Healy Sat Mar  4 2006 - 18:53 
    3 ;; Time-stamp: <2008-02-25 19:31:49EST init.lisp> 
     3;; Time-stamp: <2008-03-09 12:30:38EDT init.lisp> 
    44;; $Id$ 
    55 
     
    2121    
    2222(cffi:use-foreign-library libgsl) 
    23  
    24 ;;; The following define :size, from cffi-unix which became cffi-net, 
    25 ;;; which is apparently turning into something even bigger and more 
    26 ;;; irrelevant.  All we need is the definition of :size.  This is 
    27 ;;; not in the keyword package to suppress warnings from CFFI. 
    28  
    29 (cffi:defctype uint32 :unsigned-int) 
    30 (cffi:defctype uint64 :unsigned-long) 
    31 (cffi:defctype gsll::size 
    32    #-cffi-features:no-long-long uint64 
    33    #+cffi-features:no-long-long 
    34    #.(progn (cerror "Use uint32 instead." 
    35    "This platform does not support long long types.") 
    36    uint32)) 
  • trunk/init/number-conversion.lisp

    r26 r34  
    11;; Conversion of numbers C->CL 
    22;; Liam Healy, Sun May 28 2006 - 22:04 
    3 ;; Time-stamp: <2008-02-17 18:54:32EST number-conversion.lisp> 
     3;; Time-stamp: <2008-03-09 14:17:34EDT number-conversion.lisp> 
    44;; $Id$ 
    55 
     
    7171    (t `((,(cl-convert-function (st-type decl)) ,(st-symbol decl)))))) 
    7272 
     73;;;;**************************************************************************** 
     74;;;; Types 
     75;;;;**************************************************************************** 
     76 
     77;;; CL type definitions: 
     78(deftype unsigned-byte8 () '(unsigned-byte 8)) 
     79(deftype unsigned-byte16 () '(unsigned-byte 16)) 
     80(deftype unsigned-byte32 () '(unsigned-byte 32)) 
     81(deftype unsigned-byte64 () '(unsigned-byte 64)) 
     82 
     83;;; C type definitions from cffi-net/unixint.cffi.lisp: 
     84(cffi:defctype uint8 :unsigned-char) 
     85(cffi:defctype uint16 :unsigned-short) 
     86(cffi:defctype uint32 :unsigned-int) 
     87(cffi:defctype uint64 :unsigned-long) 
     88(cffi:defctype int8 :char) 
     89(cffi:defctype int16 :short) 
     90(cffi:defctype int32 :int) 
     91(cffi:defctype int64 :long) 
     92 
     93#-cffi-features:no-long-long 
     94(cffi:defctype size uint64) 
     95 
     96#+cffi-features:no-long-long 
     97(progn (cerror "Use :uint32 instead." "This platform does not support long long types.") 
     98       (cffi:defctype size uint32)) 
     99 
     100;;;(deftype unsigned-fixnum () `(integer 0 ,most-positive-fixnum)) 
     101 
     102(defparameter *type-names* 
     103  '( 
     104    (fixnum :int "_int") 
     105    (unsigned-fixnum :unsigned-int "_uint") 
     106    (single-float :float "_float") 
     107    (double-float :double "") 
     108    ;;(long-double :long "_long_double") 
     109    (complex gsl-complex "_complex") 
     110    (t nil "")) 
     111  "A list of type name mappings, each being a list 
     112   Lisp type, C type as CFFI understands it, and GSL 
     113   splice string.") 
     114 
     115(defun lookup-splice-name (cl-type) 
     116  (third (find cl-type *type-names* :key #'first))) 
     117 
     118(defun lookup-C-type (cl-type) 
     119  (second (find cl-type *type-names* :key #'first))) 
     120 
     121(defun splice-name (base-name keyword symbol) 
     122  "Make a new C name for a data function from a base name."  
     123  (let* ((insert (+ (search keyword base-name) (length keyword)))) 
     124    (concatenate 'string 
     125                 (subseq base-name 0 insert) 
     126                 (lookup-splice-name symbol) 
     127                 (subseq base-name insert))))