Previous: , Up: The Groveller   [Contents][Index]


13.5 Wrapper for Inline/Static Functions and Macros

In a shared library, information in static/inlined functions and macros are already removed during the compilation. Wrapper file enables to write an uninlined function wrapping the call to them.

A wrapper file compilation/loading proceeds as follows: Unlike groveller which generates C code that emits lisp files containing cffi definitions, it generates C code, compiles it as a shared library, loads the library, generate the cffi definitions (as lisp code) and then loads the lisp code.

It has asdf integration similar to groveller.

  (defsystem "example-software"
    :defsystem-depends-on ("cffi-grovel")
    :depends-on ("cffi")
    :serial t
    :components
    ((:file "package")
     (:cffi-grovel-file "example-grovelling")
     (:cffi-wrapper-file "example-wrappers")  ;; <<--- this part
     (:file "example")))
Wrapper Form: defwrapper name-and-options return-type &rest args
static inline int foo(int i) {
  return 1+i;
};
#define bar(i) (1+(i))
  (in-package :mypackage)
  (defwrapper ("foo" foo) :int
    (i :int))
  (defwrapper ("bar" bar) :int
    (i :int))

Other forms are similar to grovel files.

Wrapper Form: progn &rest forms

Processes a list of forms. Useful for conditionalizing several forms. For example:

  #+freebsd
  (progn
    (constant (ev-enable "EV_ENABLE"))
    (constant (ev-disable "EV_DISABLE")))
Wrapper Form: include &rest files

Include the specified files (specified as strings) in the generated C source code.

Wrapper Form: in-package symbol

Set the package to be used for the final Lisp output.

Wrapper Form: flags &rest flags

Adds cc-flags to the command line arguments used for the C compiler invocation.

Wrapper Form: proclaim &rest proclaimations
Wrapper Form: declaim &rest declaimations

Previous: , Up: The Groveller   [Contents][Index]