Re: Coercing pointers

Edi Weitz <[email protected]> 13 Aug 2003 23:14:01 +0200
Newsgroups gmane.lisp.uffi.general
Message-ID <[email protected]>
[Sorry, some emails inbetween have been lost because we
 unintentionally removed the list from Cc.]

On Wed, 13 Aug 2003 09:22:00 -0600, Kevin Rosenberg <kevin-HJRc7zDS/[email protected]> wrote:

> > Maybe it would make sense to map :UNSIGNED-CHAR to :CHAR for LW?
> 
> I'd like to "do the right thing". It's quite easy for different UFFI
> types to represent different types in the native FFI's. If there is
> no way for the all of the supported platforms to represent both
> unsigned and signed characters, then I'll admit defeat and have only
> one character type in UFFI. But, if the trouble with supporting
> :unsigned-char represents a bug in UFFI, then I'd prefer to fix
> that.
> 
> Do LW not have an :unsigned-char type?

They have but it behaves like a number, don't know why:

  CL-USER 6 > (defparameter *a* (fli:allocate-foreign-object :type :char))
  *A*

  CL-USER 7 > (fli:dereference *a*)
  #\:

  CL-USER 8 > (setf (fli:dereference *a*) #\a)
  #\a

  CL-USER 9 > (fli:dereference *a*)
  #\a

  CL-USER 10 > (defparameter *a* (fli:allocate-foreign-object :type '(:unsigned :char)))
  *A*

  CL-USER 11 > (fli:dereference *a*)
  117

  CL-USER 12 > (setf (fli:dereference *a*) #\a)
  #\a

  CL-USER 13 > (fli:dereference *a*)
  97

  CL-USER 14 > (fli:dereference *a* :type :char)
  #\a

If you'd modify ENSURE-CHAR-CHARACTER for this case it had to make a
runtime decision which probably wouldn't be a good idea.

Cheers,
Edi.