sdilts / cl-bindgen Goto Github PK
View Code? Open in Web Editor NEWA command line tool and library for generating FFI wrappers for Common Lisp
License: MIT License
A command line tool and library for generating FFI wrappers for Common Lisp
License: MIT License
For the struct
struct s {
char[4] array;
};
The following is being generated;
(cffi:destruct s
(array (:pointer :char :count 4)))
It should be generating:
(cffi:destruct s
(array :char :count 4))
cl-bindgen/cl_bindgen/__main__.py
Line 8 in dc19add
Is there any reason why this is named managler
and not mangler
?
cl-bindgen always expands pointer types to the the type's full definition, i.e.
struct foo {
struct other_thing *foo
};
always gets expanded to:
(defcstruct foo
(foo (:pointer (:struct other-thing))))
However, this can be problematic if the other_thing
type doesn't yet have (or won't ever) bindings generated for it. There should be a way to define a regex or some other matching function to tell cl-bindgen that some pointer types should not be expanded. The desired output would then be something like:
(defcstruct foo
(foo :pointer #| (:struct other-thing) |#))
Structs like
struct foo {
enum type flag;
union {
int a;
double b;
};
};
Cause an assertion error originating here:
cl-bindgen/cl_bindgen/processfile.py
Lines 210 to 213 in 920df4c
Here's what the C spec says on nested unions:
https://en.cppreference.com/w/c/language/union
Thanks for this awesome library.
I discovered a minor inconvenience: when parsing a file like cuda.h
quotes are not escaped in docstrings. So forms like the following are produced:
(cffi:defcfun "custreamgetcaptureinfo" CUresult
"\brief Query capture status of a stream
Query the capture status of a stream and and get an id for
the capture sequence, which is unique over the lifetime of the process.
If called on ::CU_STREAM_LEGACY (the "null stream") while a stream not created
with ::CU_STREAM_NON_BLOCKING is capturing, returns ::CUDA_ERROR_STREAM_CAPTURE_IMPLICIT.
A valid id is returned only if both of the following are true:
- the call returns CUDA_SUCCESS
- captureStatus is set to ::CU_STREAM_CAPTURE_STATUS_ACTIVE
\return
::CUDA_SUCCESS,
::CUDA_ERROR_STREAM_CAPTURE_IMPLICIT
\notefnerr
\sa
::cuStreamBeginCapture,
::cuStreamIsCapturing"
(hstream CUstream)
(capturestatus (:pointer CUstreamCaptureStatus))
(id (:pointer cuuint64-t)))
The problem is "null stream"
where the quotes around it are not escaped.
Hi there, I'm just trying out your library, I wonder if this is expected behaviour with respect to the include guard at the top of the file? Many thanks!
(venv) anticrisis@Au14-1:/tmp/test$ cat cpp.h
#ifndef CPP_H
#define CPP_H
#ifdef __cplusplus
extern "C" {
#endif
int hello();
#ifdef __cplusplus
}
#endif
#endif
(venv) anticrisis@Au14-1:/tmp/test$ cl-bindgen f cpp.h
Found macro +cpp-h+ definition in: cpp.h:2:9
;; next section imported from file cpp.h
#| MACRO_DEFINITION
(defconstant +cpp-h+ ACTUAL_VALUE_HERE)
|#
(cffi:defcfun "hello" :int)
(venv) anticrisis@Au14-1:/tmp/test$
clang -print-resource-dir
prints out the resource directory of clang, which contains the include
directory needed to find standard header files. Use this command to derive this at run-time instead of making the user do it themselves.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.