Support for querying foreign type designators
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| CFFI |
Wishlist
|
Unassigned |
Bug Description
I am writing an API that uses CFFI underneath and have had the need to check if a designator for a foreign type (such as :uint8, or another user-defined type) actually designates a foreign type.
The most sane way I've found to do this is the following:
(defun foreign-type-p (foreign-type)
(handler-case (and (cffi::parse-type foreign-type) t)
(error () nil)))
I feel that there should be a better way to go about this
Changed in cffi: | |
importance: | Undecided → Wishlist |
status: | New → Triaged |
Luís Oliveira (luismbo) wrote : | #1 |
I'm building a Type Library (TLB) importer to auto-generate COM wrappers, but part of the yak-shaving is a small helper lib on top of CFFI to avoid repetitive & error-prone code and that's where I'm using this function right now
You can find the main code here:
https:/
The TLDR is that it uses a custom declaration (via CLTL2) to define a variable's 'cffi-type' and I'm using
`(check-type type foreign-type)`
in order to sanity check and provide useful errors at macro-expansion
Stelian Ionescu (sionescu) wrote : Re: [Bug 1881118] Re: Support for querying foreign type designators | #3 |
> Sounds reasonable. Can you tell me a bit more about your API and why you
> need this feature?
I use cffi::parse-type in the IOlib syscall wrappers: I need a generic way to determine the type size and signedness.
--
Stelian Ionescu
Note I also make use of cffi::parse-type (as well as specializing on internal cffi classes) for my marshalling code - though I haven't ironed out all the kinks to it quite yet, and there's possibly a way I could accomplish it via CFFI's type translators.
Sounds reasonable. Can you tell me a bit more about your API and why you need this feature?