Package: cffi

Generic Function translate-name-to-foreign

Lambda List

translate-name-to-foreign (lisp-name package &optional varp)


lisp-name -- A symbol naming the Lisp function to be created.
package -- A Lisp package
varp -- A generalized boolean.

Return Value

The string representing the foreign function name.


translate-name-to-foreign is used by defcfun to handle the conversion of lisp names to foreign names. By default, it translates using translate-underscore-separated-name. However, you can create specialized methods on this function to make translating more closely match the foreign library's naming conventions.

Specialize package on some package. This allows other packages to load libraries with different naming conventions.


  CFFI> (defcfun some-xml-function ...)
  => "some_xml_function"
  CFFI> (defmethod translate-name-to-foreign ((spec symbol)
                                              (package (eql *package*))
                                              &optional varp)
          (let ((name (translate-camelcase-name spec)))
            (if varp (subseq name 1 (1- (length name))) name)))
  CFFI> (defcfun some-xml-function ...)
  => "someXmlFunction"  

See also