From: Hoehle, Joerg-C. <Joe...@t-...> - 2005-03-14 10:17:21
|
Sam asked: >is this correct, i.e., should we just say that ":OUT requires >ALLOCATION :ALLOCA"? Fine with me. Then perhaps add some clarification on pointers. "Note that when the parameter type is either c-pointer or (c-pointer type), the programmer/user/developer is responsible for the correct allocation of the things being pointed to." "The pointer itself is stack-allocated by CLISP (:alloca is the default) and using either :out or :in-out makes no sense with such a parameter type even though conceptually, that would be the proper mode" -- unclear, please rephrase Or ":out or :in-out, although correctly describing a possible mode from a conceptual point of view, do not make sense to the FFI when the parameter type is [anything else than c-ptr and in particular] either c-pointer or (c-pointer <type>), because "... Hmm perhaps "the FFI can only allocate the pointer ... or "only that pointer is passed on the stack..." The thing to keep in mind is, :out or :in-out require (c-ptr xyz), don't work with anything else -- unless one can propose another concept. If somebody wants an API that would be :[in-]out, but with user-supplied pointer, possibly NULL (common in some places of the OS), then impnotes could mention that what's to do is either use (c-pointer <type) or c-pointer with the default :in and do allocation oneself, or use two prototypes, one with :out (c-ptr ...) and one with NULL. But that's possibly a different issue than explaining that user supplied foreign pointer parameters are/must be :in from the FFI POV, perhaps by analogy that C only knows about pointers and has no concept of such modes (but the rule still applies when interfacing to other languages) Sorry that this is not clear, Jorg Hohle. |