Package: cffi

Generic Function translate-name-from-foreign

Lambda List

translate-name-from-foreign (foreign-name package &optional varp)

Arguments

foreign-name -- A string denoting a foreign function.
package -- A Lisp package
varp -- A generalized boolean.

Return Value

The Lisp symbol to be used a function name.

Details

translate-name-from-foreign is used by defcfun to handle the conversion of foreign names to lisp 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.

Examples

  CFFI> (defcfun "someXmlFunction" ...)
  => SOMEXMLFUNCTION
  CFFI> (defmethod translate-name-from-foreign ((spec string)
                                                (package (eql *package*))
                                                &optional varp)
          (let ((name (translate-camelcase-name spec)))
            (if varp (intern (format nil "*~a*" name)) name)))
  => #<STANDARD-METHOD TRANSLATE-NAME-FROM-FOREIGN (STRING (EQL #<Package "SOME-PACKAGE">))>
  CFFI> (defcfun "someXmlFunction" ...)
  => SOME-XML-FUNCTION  
 

See also