; -*- scheme -*- ; ; Suggestions for policy mechanisms in the FFIGEN back-end for Chez Scheme. ; These are currently *not* implemented, and are only intended as examples. ; ; Mechanism falls into three categories: exclusion, overriding, and ; adaptation. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Exclusion: ; At the outset, everything in the .ffi file is marked as referenced. ; The mechanisms for excluding stuff are based on an item's name. ; exclude-file takes a file name or list of file names and excludes every ; item defined in that file and files included by it. (exclude-file '()) ; exclude-structure takes a structure name (i.e. either "struct FOO" ; or "union FOO" or "FOO") or list of names and inhibits generation of ; constructors, destructors, accessors, and mutators for it and all ; typedefs derived from it. If the name is a typedef name and the ; structure named has a compiler-generated tag, then the structure ; named by this typedef is also excluded. (exclude-structure "FILE") ; exclude-function excludes the named function(s). (exclude-function "select") ; exclude-global excludes the named global variable. (exclude-global "__iob") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Overriding ; Override-prototype gives the named function a new prototype. (override-prototype "fgets" `(function (,(primitive-type 'string) ,(primitive-type 'int) ,(pointer-type (struct-type "FILE"))) ,(pointer-type (primitive-type 'char)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Adaptation ; Short-policy says something about how to handle shorts. Three values are ; possible: warning, use-integer, and use-proxy. If use-integer is the ; value, then an integer-32 FFI argument will be used on the assumption that ; this is meaningful in the native API. If use-proxy is the value then a ; proxy function is generated which takes an integer argument and calls ; the real function with the argument cast to short. (short-policy 'use-integer) ; Struct-param-policy says something about how to handle structure parameters. ; Values are: warning and use-proxy. If use-proxy is the value, then ; an FF will be generated which takes structure pointers and which names a ; proxy function (this is transparent to Scheme code), and the real function ; will be called by the proxy. (struct-param-policy 'warning) ; Struct-return-policy says something about how to handle structure return ; values. Values are: warning, alloc-new, and pass-placeholder. If alloc-new ; is the value, then a proxy function will be generated which receives ; the return value, allocates an object on the heap for it, copies the value ; into the allocated memory, and returns a pointer to the memory. ; If pass-placeholder is the value, then a FF and proxy will be generated ; that take an extra argument (the first); that argument must be a pointer ; to a structure in which to place the value. (struct-return-policy 'warning) ; Variadic-policy says something about how to handle variadic procedures. ; Values are: warning and exclude. If the value is exclude, a warning will ; be given and no FFI code will be generated; if the value is warning, then ; invalid FFI code will be generated. (variadic-policy 'warning) ; eof