Giter Club home page Giter Club logo

cl-bindgen's People

Contributors

sdilts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

adamkruszewski

cl-bindgen's Issues

Arrays in structs are not converted properly

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))

Add ability to not fully expand pointer types in structure and function declarations

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) |#))

Nested anonymous records cause cl-bindgen to crash

Structs like

struct foo {
    enum type flag;
    union {
        int a;
        double b;
    };
};

Cause an assertion error originating here:

if field.is_anonymous():
assert(field.type.kind == clang.TypeKind.ELABORATED)
inner_name = name + '-' + field_name
actual_elaborated_type = _determine_elaborated_type(field.type)

Here's what the C spec says on nested unions:
https://en.cppreference.com/w/c/language/union

Quotes in docstrings are not escapted

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.

header guards?

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$

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.