Tmux etc
This commit is contained in:
parent
276853ba84
commit
1cb167b597
361 changed files with 77302 additions and 4 deletions
|
|
@ -0,0 +1,46 @@
|
|||
# -*- Mode: Makefile; tab-width: 3; indent-tabs-mode: t -*-
|
||||
#
|
||||
# Makefile --- Make targets for generating the documentation.
|
||||
#
|
||||
# Copyright (C) 2005-2007, Luis Oliveira <loliveira@common-lisp.net>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person
|
||||
# obtaining a copy of this software and associated documentation
|
||||
# files (the "Software"), to deal in the Software without
|
||||
# restriction, including without limitation the rights to use, copy,
|
||||
# modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
# of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
export LC_ALL=C
|
||||
|
||||
all: manual spec
|
||||
|
||||
manual: cffi-manual.texinfo style.css
|
||||
sh gendocs.sh -o manual --html "--css-include=style.css" cffi-manual "CFFI User Manual"
|
||||
|
||||
spec: cffi-sys-spec.texinfo style.css
|
||||
sh gendocs.sh -o spec --html "--css-include=style.css" cffi-sys-spec "CFFI-SYS Interface Specification"
|
||||
|
||||
clean:
|
||||
find . \( -name "*.info" -o -name "*.aux" -o -name "*.cp" -o -name "*.fn" -o -name "*.fns" -o -name "*.ky" -o -name "*.log" -o -name "*.pg" -o -name "*.toc" -o -name "*.tp" -o -name "*.vr" -o -name "*.dvi" -o -name "*.cps" -o -name "*.vrs" \) -exec rm {} \;
|
||||
rm -rf manual spec dir
|
||||
|
||||
upload-docs: manual spec
|
||||
rsync -av --delete -e ssh manual spec common-lisp.net:/project/cffi/public_html/
|
||||
# scp -r manual spec common-lisp.net:/project/cffi/public_html/
|
||||
|
||||
# vim: ft=make ts=3 noet
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
July 2005
|
||||
These details were kindly provided by Duane Rettig of Franz.
|
||||
|
||||
Regarding the following snippet of the macro expansion of
|
||||
FF:DEF-FOREIGN-CALL:
|
||||
|
||||
(SYSTEM::FF-FUNCALL
|
||||
(LOAD-TIME-VALUE (EXCL::DETERMINE-FOREIGN-ADDRESS
|
||||
'("foo" :LANGUAGE :C) 2 NIL))
|
||||
'(:INT (INTEGER * *)) ARG1
|
||||
'(:DOUBLE (DOUBLE-FLOAT * *)) ARG2
|
||||
'(:INT (INTEGER * *)))
|
||||
|
||||
"
|
||||
... in Allegro CL, if you define a foreign call FOO with C entry point
|
||||
"foo" and with :call-direct t in the arguments, and if other things are
|
||||
satisfied, then if a lisp function BAR is compiled which has a call to
|
||||
FOO, that call will not go through ff-funcall (and thus a large amount
|
||||
of argument manipulation and processing) but will instead set up its
|
||||
arguments directly on the stack, and will then perform the "call" more
|
||||
or less directly, through the "entry vec" (a small structure which
|
||||
keeps track of a foreign entry's address and status)."
|
||||
|
||||
This is the code that generates what the compiler expects to see:
|
||||
|
||||
(setq call-direct-form
|
||||
(if* call-direct
|
||||
then `(setf (get ',lispname 'sys::direct-ff-call)
|
||||
(list ',external-name
|
||||
,callback
|
||||
,convention
|
||||
',returning
|
||||
',arg-types
|
||||
,arg-checking
|
||||
,entry-vec-flags))
|
||||
else `(remprop ',lispname 'sys::direct-ff-call)))
|
||||
|
||||
Thus generating something like:
|
||||
|
||||
(EVAL-WHEN (COMPILE LOAD EVAL)
|
||||
(SETF (GET 'FOO 'SYSTEM::DIRECT-FF-CALL)
|
||||
(LIST '("foo" :LANGUAGE :C) T :C
|
||||
'(:INT (INTEGER * *))
|
||||
'((:INT (INTEGER * *))
|
||||
(:FLOAT (SINGLE-FLOAT * *)))
|
||||
T
|
||||
2 ; this magic value is explained later
|
||||
)))
|
||||
|
||||
"
|
||||
(defun determine-foreign-address (name &optional (flags 0) method-index)
|
||||
;; return an entry-vec struct suitable for the foreign-call of name.
|
||||
;;
|
||||
;; name is either a string, which is taken without conversion, or
|
||||
;; a list consisting of a string to convert or a conversion function
|
||||
;; call.
|
||||
;; flags is an integer representing the flags to place into the entry-vec.
|
||||
;; method-index, if non-nil, is a word-index into a vtbl (virtual table).
|
||||
;; If method-index is true, then the name must be a string uniquely
|
||||
;; represented by the index and by the flags field.
|
||||
|
||||
Note that not all architectures implement the :method-index argument
|
||||
to def-foreign-call, but your interface likely won't support it
|
||||
anyway, so just leave it nil. As for the flags, they are constants
|
||||
stored into the entry-vec returned by d-f-a and are given here:
|
||||
|
||||
(defconstant ep-flag-call-semidirect 1) ; Real address stored in alt-address slot
|
||||
(defconstant ep-flag-never-release 2) ; Never release the heap
|
||||
(defconstant ep-flag-always-release 4) ; Always release the heap
|
||||
(defconstant ep-flag-release-when-ok 8) ; Release the heap unless without-interrupts
|
||||
|
||||
(defconstant ep-flag-tramp-calls #x70) ; Make calls through special trampolines
|
||||
(defconstant ep-flag-tramp-shift 4)
|
||||
|
||||
(defconstant ep-flag-variable-address #x100) ; Entry-point contains address of C var
|
||||
(defconstant ep-flag-strings-convert #x200) ; Convert strings automatically
|
||||
|
||||
(defconstant ep-flag-get-errno #x1000) ;; [rfe5060]: Get errno value after call
|
||||
(defconstant ep-flag-get-last-error #x2000) ;; [rfe5060]: call GetLastError after call
|
||||
;; Leave #x4000 and #x8000 open for expansion
|
||||
|
||||
Mostly, you'll give the value 2 (never release the heap), but if you
|
||||
give 4 or 8, then d-f-a will automatically set the 1 bit as well,
|
||||
which takes the call through a heap-release/reacquire process.
|
||||
|
||||
Some docs for entry-vec are:
|
||||
|
||||
;; -- entry vec --
|
||||
;; An entry-vec is an entry-point descriptor, usually a pointer into
|
||||
;; a shared-library. It is represented as a 5-element struct of type
|
||||
;; foreign-vector. The reason for this represntation is
|
||||
;; that it allows the entry point to be stored in a table, called
|
||||
;; the .saved-entry-points. table, and to be used by a foreign
|
||||
;; function. When the location of the foreign function to which the entry
|
||||
;; point refers changes, it is simply a matter of changing the value in entry
|
||||
;; point vector and the foreign call code sees it immediately. There is
|
||||
;; even an address that can be put in the entry point vector that denotes
|
||||
;; a missing foreign function, thus lookup can happen dynamically.
|
||||
|
||||
(defstruct (entry-vec
|
||||
(:type (vector excl::foreign (*)))
|
||||
(:constructor make-entry-vec-boa ()))
|
||||
name ; entry point name
|
||||
(address 0) ; jump address for foreign code
|
||||
(handle 0) ; shared-lib handle
|
||||
(flags 0) ; ep-* flags
|
||||
(alt-address 0) ; sometimes holds the real func addr
|
||||
)
|
||||
|
||||
[...]
|
||||
"
|
||||
|
||||
Regarding the arguments to SYSTEM::FF-FUNCALL:
|
||||
'(:int (integer * *)) argN
|
||||
|
||||
"The type-spec is as it is given in the def-foreign-call
|
||||
syntax, with a C type optionally followed by a lisp type,
|
||||
followed optionally by a user-conversion function name[...]"
|
||||
|
||||
|
||||
Getting the alignment:
|
||||
|
||||
CL-USER(2): (ff:get-foreign-type :int)
|
||||
#S(FOREIGN-FUNCTIONS::IFOREIGN-TYPE
|
||||
:ATTRIBUTES NIL
|
||||
:SFTYPE
|
||||
#S(FOREIGN-FUNCTIONS::SIZED-FTYPE-PRIM
|
||||
:KIND :INT
|
||||
:WIDTH 4
|
||||
:OFFSET 0
|
||||
:ALIGN 4)
|
||||
...)
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,334 @@
|
|||
\input texinfo @c -*-texinfo-*-
|
||||
@c %**start of header
|
||||
@setfilename cffi-sys.info
|
||||
@settitle CFFI-SYS Interface Specification
|
||||
|
||||
@c Show types in the same index as the functions.
|
||||
@synindex tp fn
|
||||
|
||||
@copying
|
||||
Copyright @copyright{} 2005-2006, James Bielman <jamesjb at jamesjb.com>
|
||||
|
||||
@quotation
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the ``Software''), to deal in the Software without
|
||||
restriction, including without limitation the rights to use, copy,
|
||||
modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
@sc{The software is provided ``as is'', without warranty of any kind,
|
||||
express or implied, including but not limited to the warranties of
|
||||
merchantability, fitness for a particular purpose and
|
||||
noninfringement. In no event shall the authors or copyright
|
||||
holders be liable for any claim, damages or other liability,
|
||||
whether in an action of contract, tort or otherwise, arising from,
|
||||
out of or in connection with the software or the use or other
|
||||
dealings in the software.}
|
||||
@end quotation
|
||||
@end copying
|
||||
|
||||
@macro impnote {text}
|
||||
@emph{Implementor's note: \text\}
|
||||
@end macro
|
||||
@c %**end of header
|
||||
|
||||
@dircategory Software development
|
||||
@direntry
|
||||
* CFFI Sys spec: (cffi-sys-spec). CFFI Sys spec.
|
||||
@end direntry
|
||||
|
||||
@titlepage
|
||||
@title CFFI-SYS Interface Specification
|
||||
@c @subtitle Version X.X
|
||||
@c @author James Bielman
|
||||
|
||||
@page
|
||||
@vskip 0pt plus 1filll
|
||||
@insertcopying
|
||||
@end titlepage
|
||||
|
||||
@contents
|
||||
|
||||
@ifnottex
|
||||
@node Top
|
||||
@top cffi-sys
|
||||
@insertcopying
|
||||
@end ifnottex
|
||||
|
||||
@menu
|
||||
* Introduction::
|
||||
* Built-In Foreign Types::
|
||||
* Operations on Foreign Types::
|
||||
* Basic Pointer Operations::
|
||||
* Foreign Memory Allocation::
|
||||
* Memory Access::
|
||||
* Foreign Function Calling::
|
||||
* Loading Foreign Libraries::
|
||||
* Foreign Globals::
|
||||
* Symbol Index::
|
||||
@end menu
|
||||
|
||||
@node Introduction
|
||||
@chapter Introduction
|
||||
|
||||
@acronym{CFFI}, the Common Foreign Function Interface, purports to be
|
||||
a portable foreign function interface for Common Lisp.
|
||||
|
||||
This specification defines a set of low-level primitives that must be
|
||||
defined for each Lisp implementation supported by @acronym{CFFI}.
|
||||
These operators are defined in the @code{CFFI-SYS} package.
|
||||
|
||||
The @code{CFFI} package uses the @code{CFFI-SYS} interface
|
||||
to implement an extensible foreign type system with support for
|
||||
typedefs, structures, and unions, a declarative interface for
|
||||
defining foreign function calls, and automatic conversion of
|
||||
foreign function arguments to/from Lisp types.
|
||||
|
||||
Please note the following conventions that apply to everything in
|
||||
@code{CFFI-SYS}:
|
||||
|
||||
@itemize @bullet
|
||||
@item
|
||||
Functions in @code{CFFI-SYS} that are low-level versions of functions
|
||||
exported from the @code{CFFI} package begin with a leading
|
||||
percent-sign (eg. @code{%mem-ref}).
|
||||
|
||||
@item
|
||||
Where ``foreign type'' is mentioned as the kind of an argument, the
|
||||
meaning is restricted to that subset of all foreign types defined in
|
||||
@ref{Built-In Foreign Types}. Support for higher-level types is
|
||||
always defined in terms of those lower-level types in @code{CFFI}
|
||||
proper.
|
||||
@end itemize
|
||||
|
||||
|
||||
@node Built-In Foreign Types
|
||||
@chapter Built-In Foreign Types
|
||||
|
||||
@deftp {Foreign Type} :char
|
||||
@deftpx {Foreign Type} :unsigned-char
|
||||
@deftpx {Foreign Type} :short
|
||||
@deftpx {Foreign Type} :unsigned-short
|
||||
@deftpx {Foreign Type} :int
|
||||
@deftpx {Foreign Type} :unsigned-int
|
||||
@deftpx {Foreign Type} :long
|
||||
@deftpx {Foreign Type} :unsigned-long
|
||||
@deftpx {Foreign Type} :long-long
|
||||
@deftpx {Foreign Type} :unsigned-long-long
|
||||
These types correspond to the native C integer types according to the
|
||||
ABI of the system the Lisp implementation is compiled against.
|
||||
@end deftp
|
||||
|
||||
@deftp {Foreign Type} :int8
|
||||
@deftpx {Foreign Type} :uint8
|
||||
@deftpx {Foreign Type} :int16
|
||||
@deftpx {Foreign Type} :uint16
|
||||
@deftpx {Foreign Type} :int32
|
||||
@deftpx {Foreign Type} :uint32
|
||||
@deftpx {Foreign Type} :int64
|
||||
@deftpx {Foreign Type} :uint64
|
||||
Foreign integer types of specific sizes, corresponding to the C types
|
||||
defined in @code{stdint.h}.
|
||||
@end deftp
|
||||
|
||||
@deftp {Foreign Type} :size
|
||||
@deftpx {Foreign Type} :ssize
|
||||
@deftpx {Foreign Type} :ptrdiff
|
||||
@deftpx {Foreign Type} :time
|
||||
Foreign integer types corresponding to the standard C types (without
|
||||
the @code{_t} suffix).
|
||||
@end deftp
|
||||
|
||||
@impnote{I'm sure there are more of these that could be useful, let's
|
||||
add any types that can't be defined portably to this list as
|
||||
necessary.}
|
||||
|
||||
@deftp {Foreign Type} :float
|
||||
@deftpx {Foreign Type} :double
|
||||
The @code{:float} type represents a C @code{float} and a Lisp
|
||||
@code{single-float}. @code{:double} represents a C @code{double} and a
|
||||
Lisp @code{double-float}.
|
||||
@end deftp
|
||||
|
||||
@deftp {Foreign Type} :pointer
|
||||
A foreign pointer to an object of any type, corresponding to
|
||||
@code{void *}.
|
||||
@end deftp
|
||||
|
||||
@deftp {Foreign Type} :void
|
||||
No type at all. Only valid as the return type of a function.
|
||||
@end deftp
|
||||
|
||||
|
||||
@node Operations on Foreign Types
|
||||
@chapter Operations on Built-in Foreign Types
|
||||
|
||||
@defun %foreign-type-size type @result{} size
|
||||
Return the @var{size}, in bytes, of objects having foreign type
|
||||
@var{type}. An error is signalled if @var{type} is not a known
|
||||
built-in foreign type.
|
||||
@end defun
|
||||
|
||||
@defun %foreign-type-alignment type @result{} alignment
|
||||
Return the default alignment in bytes for structure members of foreign
|
||||
type @var{type}. An error is signalled if @var{type} is not a known
|
||||
built-in foreign type.
|
||||
|
||||
@impnote{Maybe this should take an optional keyword argument specifying an
|
||||
alternate alignment system, eg. :mac68k for 68000-compatible alignment
|
||||
on Darwin.}
|
||||
@end defun
|
||||
|
||||
|
||||
@node Basic Pointer Operations
|
||||
@chapter Basic Pointer Operations
|
||||
|
||||
@defun pointerp ptr @result{} boolean
|
||||
Return true if @var{ptr} is a foreign pointer.
|
||||
@end defun
|
||||
|
||||
@defun null-pointer @result{} pointer
|
||||
Return a null foreign pointer.
|
||||
@end defun
|
||||
|
||||
@defun null-pointer-p ptr @result{} boolean
|
||||
Return true if @var{ptr} is a null foreign pointer.
|
||||
@end defun
|
||||
|
||||
@defun make-pointer address @result{} pointer
|
||||
Return a pointer corresponding to the numeric integer @var{address}.
|
||||
@end defun
|
||||
|
||||
@defun inc-pointer ptr offset @result{} pointer
|
||||
Return the result of numerically incrementing @var{ptr} by @var{offset}.
|
||||
@end defun
|
||||
|
||||
|
||||
@node Foreign Memory Allocation
|
||||
@chapter Foreign Memory Allocation
|
||||
|
||||
@defun foreign-alloc size @result{} pointer
|
||||
Allocate @var{size} bytes of foreign-addressable memory and return
|
||||
a @var{pointer} to the allocated block. An implementation-specific
|
||||
error is signalled if the memory cannot be allocated.
|
||||
@end defun
|
||||
|
||||
@defun foreign-free ptr @result{} unspecified
|
||||
Free a pointer @var{ptr} allocated by @code{foreign-alloc}. The
|
||||
results are undefined if @var{ptr} is used after being freed.
|
||||
@end defun
|
||||
|
||||
@defmac with-foreign-pointer (var size &optional size-var) &body body
|
||||
Bind @var{var} to a pointer to @var{size} bytes of
|
||||
foreign-accessible memory during @var{body}. Both @var{ptr} and the
|
||||
memory block it points to have dynamic extent and may be stack
|
||||
allocated if supported by the implementation. If @var{size-var} is
|
||||
supplied, it will be bound to @var{size} during @var{body}.
|
||||
@end defmac
|
||||
|
||||
|
||||
@node Memory Access
|
||||
@chapter Memory Access
|
||||
|
||||
@deffn {Accessor} %mem-ref ptr type &optional offset
|
||||
Dereference a pointer @var{offset} bytes from @var{ptr} to an object
|
||||
for reading (or writing when used with @code{setf}) of built-in type
|
||||
@var{type}.
|
||||
@end deffn
|
||||
|
||||
@heading Example
|
||||
|
||||
@lisp
|
||||
;; An impractical example, since time returns the time as well,
|
||||
;; but it demonstrates %MEM-REF. Better (simple) examples wanted!
|
||||
(with-foreign-pointer (p (foreign-type-size :time))
|
||||
(foreign-funcall "time" :pointer p :time)
|
||||
(%mem-ref p :time))
|
||||
@end lisp
|
||||
|
||||
|
||||
@node Foreign Function Calling
|
||||
@chapter Foreign Function Calling
|
||||
|
||||
@defmac %foreign-funcall name @{arg-type arg@}* &optional result-type @result{} object
|
||||
@defmacx %foreign-funcall-pointer ptr @{arg-type arg@}* &optional result-type @result{} object
|
||||
Invoke a foreign function called @var{name} in the foreign source code.
|
||||
|
||||
Each @var{arg-type} is a foreign type specifier, followed by
|
||||
@var{arg}, Lisp data to be converted to foreign data of type
|
||||
@var{arg-type}. @var{result-type} is the foreign type of the
|
||||
function's return value, and is assumed to be @code{:void} if not
|
||||
supplied.
|
||||
|
||||
@code{%foreign-funcall-pointer} takes a pointer @var{ptr} to the
|
||||
function, as returned by @code{foreign-symbol-pointer}, rather than a
|
||||
string @var{name}.
|
||||
@end defmac
|
||||
|
||||
@defmac %foreign-funcall-varargs name (@{fixed-type arg@}*) @{vararg-type arg@}* &optional result-type @result{} object
|
||||
@defmacx %foreign-funcall-varargs-pointer ptr (@{fixed-type arg@}*) @{vararg-type arg@}* &optional result-type @result{} object
|
||||
Invoke a foreign variadic function called @var{name} in the foreign
|
||||
source code.
|
||||
|
||||
Each @var{fixed-type} and @var{vararg-type} is a foreign type
|
||||
specifier, followed by @var{arg}, Lisp data to be converted to foreign
|
||||
data of type @var{arg-type}. @var{result-type} is the foreign type of
|
||||
the function's return value, and is assumed to be @code{:void} if not
|
||||
supplied.
|
||||
|
||||
@code{%foreign-funcall-pointer-varargs} takes a pointer @var{ptr} to
|
||||
the variadic function, as returned by @code{foreign-symbol-pointer},
|
||||
rather than a string @var{name}.
|
||||
|
||||
Both functions have default implementation which call
|
||||
@code{%foreign-funcall} and @code{%foreign-funcall-pointer}
|
||||
approprietly.
|
||||
@end defmac
|
||||
|
||||
@heading Examples
|
||||
|
||||
@lisp
|
||||
;; Calling a standard C library function:
|
||||
(%foreign-funcall "sqrtf" :float 16.0 :float) @result{} 4.0
|
||||
@end lisp
|
||||
|
||||
@lisp
|
||||
;; Dynamic allocation of a buffer and passing to a function:
|
||||
(with-foreign-ptr (buf 255 buf-size)
|
||||
(%foreign-funcall "gethostname" :pointer buf :size buf-size :int)
|
||||
;; Convert buf to a Lisp string using MAKE-STRING and %MEM-REF or
|
||||
;; a portable CFFI function such as CFFI:FOREIGN-STRING-TO-LISP.
|
||||
)
|
||||
@end lisp
|
||||
|
||||
|
||||
@node Loading Foreign Libraries
|
||||
@chapter Loading Foreign Libraries
|
||||
|
||||
@defun %load-foreign-library name @result{} unspecified
|
||||
Load the foreign shared library @var{name}.
|
||||
|
||||
@impnote{There is a lot of behavior to decide here. Currently I lean
|
||||
toward not requiring NAME to be a full path to the library so
|
||||
we can search the system library directories (maybe even get
|
||||
LD_LIBRARY_PATH from the environment) as necessary.}
|
||||
@end defun
|
||||
|
||||
|
||||
@node Foreign Globals
|
||||
@chapter Foreign Globals
|
||||
|
||||
@defun foreign-symbol-pointer name @result{} pointer
|
||||
Return a pointer to a foreign symbol @var{name}.
|
||||
@end defun
|
||||
|
||||
@node Symbol Index
|
||||
@unnumbered Symbol Index
|
||||
@printindex fn
|
||||
|
||||
@bye
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,313 @@
|
|||
#!/bin/sh
|
||||
# gendocs.sh -- generate a GNU manual in many formats. This script is
|
||||
# mentioned in maintain.texi. See the help message below for usage details.
|
||||
# $Id: gendocs.sh,v 1.16 2005/05/15 00:00:08 karl Exp $
|
||||
#
|
||||
# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, you can either send email to this
|
||||
# program's maintainer or write to: The Free Software Foundation,
|
||||
# Inc.; 51 Franklin Street, Fifth Floor; Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# Original author: Mohit Agarwal.
|
||||
# Send bug reports and any other correspondence to bug-texinfo@gnu.org.
|
||||
|
||||
#set -e
|
||||
|
||||
prog="`basename \"$0\"`"
|
||||
srcdir=`pwd`
|
||||
|
||||
scripturl="https://github.com/cffi/cffi/blob/master/doc/gendocs.sh"
|
||||
templateurl="http://savannah.gnu.org/cgi-bin/viewcvs/texinfo/texinfo/util/gendocs_template"
|
||||
|
||||
: ${MAKEINFO="makeinfo"}
|
||||
: ${TEXI2DVI="texi2dvi -t @finalout"}
|
||||
: ${DVIPS="dvips"}
|
||||
: ${DOCBOOK2TXT="docbook2txt"}
|
||||
: ${DOCBOOK2HTML="docbook2html"}
|
||||
: ${DOCBOOK2PDF="docbook2pdf"}
|
||||
: ${DOCBOOK2PS="docbook2ps"}
|
||||
: ${GENDOCS_TEMPLATE_DIR="."}
|
||||
unset CDPATH
|
||||
|
||||
rcs_revision='$Revision: 1.16 $'
|
||||
rcs_version=`set - $rcs_revision; echo $2`
|
||||
program=`echo $0 | sed -e 's!.*/!!'`
|
||||
version="gendocs.sh $rcs_version
|
||||
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
There is NO warranty. You may redistribute this software
|
||||
under the terms of the GNU General Public License.
|
||||
For more information about these matters, see the files named COPYING."
|
||||
|
||||
usage="Usage: $prog [OPTION]... PACKAGE MANUAL-TITLE
|
||||
|
||||
Generate various output formats from PACKAGE.texinfo (or .texi or .txi) source.
|
||||
See the GNU Maintainers document for a more extensive discussion:
|
||||
http://www.gnu.org/prep/maintain_toc.html
|
||||
|
||||
Options:
|
||||
-o OUTDIR write files into OUTDIR, instead of manual/.
|
||||
--docbook convert to DocBook too (xml, txt, html, pdf and ps).
|
||||
--html ARG pass indicated ARG to makeinfo for HTML targets.
|
||||
--help display this help and exit successfully.
|
||||
--version display version information and exit successfully.
|
||||
|
||||
Simple example: $prog emacs \"GNU Emacs Manual\"
|
||||
|
||||
Typical sequence:
|
||||
cd YOURPACKAGESOURCE/doc
|
||||
wget \"$scripturl\"
|
||||
wget \"$templateurl\"
|
||||
$prog YOURMANUAL \"GNU YOURMANUAL - One-line description\"
|
||||
|
||||
Output will be in a new subdirectory \"manual\" (by default, use -o OUTDIR
|
||||
to override). Move all the new files into your web CVS tree, as
|
||||
explained in the Web Pages node of maintain.texi.
|
||||
|
||||
MANUAL-TITLE is included as part of the HTML <title> of the overall
|
||||
manual/index.html file. It should include the name of the package being
|
||||
documented. manual/index.html is created by substitution from the file
|
||||
$GENDOCS_TEMPLATE_DIR/gendocs_template. (Feel free to modify the
|
||||
generic template for your own purposes.)
|
||||
|
||||
If you have several manuals, you'll need to run this script several
|
||||
times with different YOURMANUAL values, specifying a different output
|
||||
directory with -o each time. Then write (by hand) an overall index.html
|
||||
with links to them all.
|
||||
|
||||
You can set the environment variables MAKEINFO, TEXI2DVI, and DVIPS to
|
||||
control the programs that get executed, and GENDOCS_TEMPLATE_DIR to
|
||||
control where the gendocs_template file is looked for.
|
||||
|
||||
Email bug reports or enhancement requests to bug-texinfo@gnu.org.
|
||||
"
|
||||
|
||||
calcsize()
|
||||
{
|
||||
size="`ls -ksl $1 | awk '{print $1}'`"
|
||||
echo $size
|
||||
}
|
||||
|
||||
outdir=manual
|
||||
html=
|
||||
PACKAGE=
|
||||
MANUAL_TITLE=
|
||||
|
||||
while test $# -gt 0; do
|
||||
case $1 in
|
||||
--help) echo "$usage"; exit 0;;
|
||||
--version) echo "$version"; exit 0;;
|
||||
-o) shift; outdir=$1;;
|
||||
--docbook) docbook=yes;;
|
||||
--html) shift; html=$1;;
|
||||
-*)
|
||||
echo "$0: Unknown or ambiguous option \`$1'." >&2
|
||||
echo "$0: Try \`--help' for more information." >&2
|
||||
exit 1;;
|
||||
*)
|
||||
if test -z "$PACKAGE"; then
|
||||
PACKAGE=$1
|
||||
elif test -z "$MANUAL_TITLE"; then
|
||||
MANUAL_TITLE=$1
|
||||
else
|
||||
echo "$0: extra non-option argument \`$1'." >&2
|
||||
exit 1
|
||||
fi;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if test -s $srcdir/$PACKAGE.texinfo; then
|
||||
srcfile=$srcdir/$PACKAGE.texinfo
|
||||
elif test -s $srcdir/$PACKAGE.texi; then
|
||||
srcfile=$srcdir/$PACKAGE.texi
|
||||
elif test -s $srcdir/$PACKAGE.txi; then
|
||||
srcfile=$srcdir/$PACKAGE.txi
|
||||
else
|
||||
echo "$0: cannot find .texinfo or .texi or .txi for $PACKAGE in $srcdir." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test ! -r $GENDOCS_TEMPLATE_DIR/gendocs_template; then
|
||||
echo "$0: cannot read $GENDOCS_TEMPLATE_DIR/gendocs_template." >&2
|
||||
echo "$0: it is available from $templateurl." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo Generating output formats for $srcfile
|
||||
|
||||
cmd="${MAKEINFO} -o $PACKAGE.info $srcfile"
|
||||
echo "Generating info files... ($cmd)"
|
||||
eval $cmd
|
||||
install-info $PACKAGE.info dir
|
||||
mkdir -p $outdir/
|
||||
tar czf $outdir/$PACKAGE.info.tar.gz $PACKAGE.info*
|
||||
info_tgz_size="`calcsize $outdir/$PACKAGE.info.tar.gz`"
|
||||
# do not mv the info files, there's no point in having them available
|
||||
# separately on the web.
|
||||
|
||||
cmd="${TEXI2DVI} $srcfile"
|
||||
echo "Generating dvi ... ($cmd)"
|
||||
eval $cmd
|
||||
|
||||
# now, before we compress dvi:
|
||||
echo Generating postscript...
|
||||
${DVIPS} $PACKAGE -o
|
||||
gzip -f -9 $PACKAGE.ps
|
||||
ps_gz_size="`calcsize $PACKAGE.ps.gz`"
|
||||
mv $PACKAGE.ps.gz $outdir/
|
||||
|
||||
# compress/finish dvi:
|
||||
gzip -f -9 $PACKAGE.dvi
|
||||
dvi_gz_size="`calcsize $PACKAGE.dvi.gz`"
|
||||
mv $PACKAGE.dvi.gz $outdir/
|
||||
|
||||
cmd="${TEXI2DVI} --pdf $srcfile"
|
||||
echo "Generating pdf ... ($cmd)"
|
||||
eval $cmd
|
||||
pdf_size="`calcsize $PACKAGE.pdf`"
|
||||
mv $PACKAGE.pdf $outdir/
|
||||
|
||||
cmd="${MAKEINFO} -o $PACKAGE.txt --no-split --no-headers $srcfile"
|
||||
echo "Generating ASCII... ($cmd)"
|
||||
eval $cmd
|
||||
ascii_size="`calcsize $PACKAGE.txt`"
|
||||
gzip -f -9 -c $PACKAGE.txt >$outdir/$PACKAGE.txt.gz
|
||||
ascii_gz_size="`calcsize $outdir/$PACKAGE.txt.gz`"
|
||||
mv $PACKAGE.txt $outdir/
|
||||
|
||||
# Print a SED expression that will translate references to MANUAL to
|
||||
# the proper page on gnu.org. This is a horrible shell hack done
|
||||
# because \| in sed regexps is a GNU extension.
|
||||
monognuorg () {
|
||||
case "$1" in
|
||||
libtool) echo "s!$1.html!http://www.gnu.org/software/$1/manual.html!" ;;
|
||||
*) echo "s!$1.html!http://www.gnu.org/software/$1/manual/html_mono/$1.html!" ;;
|
||||
esac
|
||||
}
|
||||
polygnuorg () {
|
||||
case "$1" in
|
||||
libtool) echo 's!\.\./'"$1/.*\.html!http://www.gnu.org/software/$1/manual.html!" ;;
|
||||
*) echo 's!\.\./'"$1!http://www.gnu.org/software/$1/manual/html_node!" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
cmd="${MAKEINFO} --no-split --html -o $PACKAGE.html $html $srcfile"
|
||||
echo "Generating monolithic html... ($cmd)"
|
||||
rm -rf $PACKAGE.html # in case a directory is left over
|
||||
eval $cmd
|
||||
sbcl --no-sysinit --no-userinit --load colorize-lisp-examples.lisp $PACKAGE.html
|
||||
#fix libc/libtool xrefs
|
||||
sed -e `monognuorg libc` -e `monognuorg libtool` $PACKAGE.html >$outdir/$PACKAGE.html
|
||||
rm $PACKAGE.html
|
||||
html_mono_size="`calcsize $outdir/$PACKAGE.html`"
|
||||
gzip -f -9 -c $outdir/$PACKAGE.html >$outdir/$PACKAGE.html.gz
|
||||
html_mono_gz_size="`calcsize $outdir/$PACKAGE.html.gz`"
|
||||
|
||||
cmd="${MAKEINFO} --html -o $PACKAGE.html $html $srcfile"
|
||||
echo "Generating html by node... ($cmd)"
|
||||
eval $cmd
|
||||
split_html_dir=$PACKAGE.html
|
||||
sbcl --no-userinit --no-sysinit --load colorize-lisp-examples.lisp "${split_html_dir}"/\*.html
|
||||
(
|
||||
cd ${split_html_dir} || exit 1
|
||||
#fix libc xrefs
|
||||
for broken_file in *.html; do
|
||||
sed -e `polygnuorg libc` -e `polygnuorg libtool` "$broken_file" > "$broken_file".temp
|
||||
mv -f "$broken_file".temp "$broken_file"
|
||||
done
|
||||
tar -czf ../$outdir/${PACKAGE}.html_node.tar.gz -- *.html
|
||||
)
|
||||
html_node_tgz_size="`calcsize $outdir/${PACKAGE}.html_node.tar.gz`"
|
||||
rm -f $outdir/html_node/*.html
|
||||
mkdir -p $outdir/html_node/
|
||||
mv ${split_html_dir}/*.html $outdir/html_node/
|
||||
rmdir ${split_html_dir}
|
||||
|
||||
echo Making .tar.gz for sources...
|
||||
srcfiles=`ls *.texinfo *.texi *.txi *.eps 2>/dev/null`
|
||||
tar cvzfh $outdir/$PACKAGE.texi.tar.gz $srcfiles
|
||||
texi_tgz_size="`calcsize $outdir/$PACKAGE.texi.tar.gz`"
|
||||
|
||||
if test -n "$docbook"; then
|
||||
cmd="${MAKEINFO} -o - --docbook $srcfile > ${srcdir}/$PACKAGE-db.xml"
|
||||
echo "Generating docbook XML... $(cmd)"
|
||||
eval $cmd
|
||||
docbook_xml_size="`calcsize $PACKAGE-db.xml`"
|
||||
gzip -f -9 -c $PACKAGE-db.xml >$outdir/$PACKAGE-db.xml.gz
|
||||
docbook_xml_gz_size="`calcsize $outdir/$PACKAGE-db.xml.gz`"
|
||||
mv $PACKAGE-db.xml $outdir/
|
||||
|
||||
cmd="${DOCBOOK2HTML} -o $split_html_db_dir ${outdir}/$PACKAGE-db.xml"
|
||||
echo "Generating docbook HTML... ($cmd)"
|
||||
eval $cmd
|
||||
split_html_db_dir=html_node_db
|
||||
(
|
||||
cd ${split_html_db_dir} || exit 1
|
||||
tar -czf ../$outdir/${PACKAGE}.html_node_db.tar.gz -- *.html
|
||||
)
|
||||
html_node_db_tgz_size="`calcsize $outdir/${PACKAGE}.html_node_db.tar.gz`"
|
||||
rm -f $outdir/html_node_db/*.html
|
||||
mkdir -p $outdir/html_node_db
|
||||
mv ${split_html_db_dir}/*.html $outdir/html_node_db/
|
||||
rmdir ${split_html_db_dir}
|
||||
|
||||
cmd="${DOCBOOK2TXT} ${outdir}/$PACKAGE-db.xml"
|
||||
echo "Generating docbook ASCII... ($cmd)"
|
||||
eval $cmd
|
||||
docbook_ascii_size="`calcsize $PACKAGE-db.txt`"
|
||||
mv $PACKAGE-db.txt $outdir/
|
||||
|
||||
cmd="${DOCBOOK2PS} ${outdir}/$PACKAGE-db.xml"
|
||||
echo "Generating docbook PS... $(cmd)"
|
||||
eval $cmd
|
||||
gzip -f -9 -c $PACKAGE-db.ps >$outdir/$PACKAGE-db.ps.gz
|
||||
docbook_ps_gz_size="`calcsize $outdir/$PACKAGE-db.ps.gz`"
|
||||
mv $PACKAGE-db.ps $outdir/
|
||||
|
||||
cmd="${DOCBOOK2PDF} ${outdir}/$PACKAGE-db.xml"
|
||||
echo "Generating docbook PDF... ($cmd)"
|
||||
eval $cmd
|
||||
docbook_pdf_size="`calcsize $PACKAGE-db.pdf`"
|
||||
mv $PACKAGE-db.pdf $outdir/
|
||||
fi
|
||||
|
||||
echo Writing index file...
|
||||
curdate="`date '+%B %d, %Y'`"
|
||||
sed \
|
||||
-e "s!%%TITLE%%!$MANUAL_TITLE!g" \
|
||||
-e "s!%%DATE%%!$curdate!g" \
|
||||
-e "s!%%PACKAGE%%!$PACKAGE!g" \
|
||||
-e "s!%%HTML_MONO_SIZE%%!$html_mono_size!g" \
|
||||
-e "s!%%HTML_MONO_GZ_SIZE%%!$html_mono_gz_size!g" \
|
||||
-e "s!%%HTML_NODE_TGZ_SIZE%%!$html_node_tgz_size!g" \
|
||||
-e "s!%%INFO_TGZ_SIZE%%!$info_tgz_size!g" \
|
||||
-e "s!%%DVI_GZ_SIZE%%!$dvi_gz_size!g" \
|
||||
-e "s!%%PDF_SIZE%%!$pdf_size!g" \
|
||||
-e "s!%%PS_GZ_SIZE%%!$ps_gz_size!g" \
|
||||
-e "s!%%ASCII_SIZE%%!$ascii_size!g" \
|
||||
-e "s!%%ASCII_GZ_SIZE%%!$ascii_gz_size!g" \
|
||||
-e "s!%%TEXI_TGZ_SIZE%%!$texi_tgz_size!g" \
|
||||
-e "s!%%DOCBOOK_HTML_NODE_TGZ_SIZE%%!$html_node_db_tgz_size!g" \
|
||||
-e "s!%%DOCBOOK_ASCII_SIZE%%!$docbook_ascii_size!g" \
|
||||
-e "s!%%DOCBOOK_PS_GZ_SIZE%%!$docbook_ps_gz_size!g" \
|
||||
-e "s!%%DOCBOOK_PDF_SIZE%%!$docbook_pdf_size!g" \
|
||||
-e "s!%%DOCBOOK_XML_SIZE%%!$docbook_xml_size!g" \
|
||||
-e "s!%%DOCBOOK_XML_GZ_SIZE%%!$docbook_xml_gz_size!g" \
|
||||
-e "s,%%SCRIPTURL%%,$scripturl,g" \
|
||||
-e "s!%%SCRIPTNAME%%!$prog!g" \
|
||||
$GENDOCS_TEMPLATE_DIR/gendocs_template >$outdir/index.html
|
||||
|
||||
echo "Done! See $outdir/ subdirectory for new files."
|
||||
|
|
@ -0,0 +1,259 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<!-- $Id: gendocs_template,v 1.7 2005/05/15 00:00:08 karl Exp $ -->
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
|
||||
<!--
|
||||
|
||||
This template was adapted from Texinfo:
|
||||
http://savannah.gnu.org/cgi-bin/viewcvs/texinfo/texinfo/util/gendocs_template
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<head>
|
||||
<title>%%TITLE%%</title>
|
||||
<meta http-equiv="content-type" content='text/html; charset=utf-8' />
|
||||
<!-- <link rel="stylesheet" type="text/css" href="/gnu.css" /> -->
|
||||
<!-- <link rev="made" href="webmasters@gnu.org" /> -->
|
||||
<style>
|
||||
/* CSS style taken from http://gnu.org/gnu.css */
|
||||
|
||||
html, body {
|
||||
background-color: #FFFFFF;
|
||||
color: #000000;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
a:link {
|
||||
color: #1f00ff;
|
||||
background-color: transparent;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #9900dd;
|
||||
background-color: transparent;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #9900dd;
|
||||
background-color: transparent;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.quote {
|
||||
margin-left: 40px;
|
||||
margin-right: 40px;
|
||||
}
|
||||
|
||||
.hrsmall {
|
||||
width: 80px;
|
||||
height: 1px;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.td_title {
|
||||
border-color: #3366cc;
|
||||
border-style: solid;
|
||||
border-width: thin;
|
||||
color: #3366cc;
|
||||
background-color : #f2f2f9;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.td_con {
|
||||
padding-top: 3px;
|
||||
padding-left: 8px;
|
||||
padding-bottom: 3px;
|
||||
color : #303030;
|
||||
background-color : #fefefe;
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
.translations {
|
||||
background-color: transparent;
|
||||
color: black;
|
||||
font-family: serif;
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
.fsflink {
|
||||
font-size: smaller;
|
||||
font-family: monospace;
|
||||
color : #000000;
|
||||
border-left: #3366cc thin solid;
|
||||
border-bottom: #3366cc thin solid;
|
||||
padding-left: 5px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
/*
|
||||
* rtl stands for right-to-left layout, as in farsi/persian,
|
||||
* arabic, etc. See also trans_rtl.
|
||||
*/
|
||||
.fsflink_rtl {
|
||||
font-size: smaller;
|
||||
font-family: monospace;
|
||||
color : #000000;
|
||||
border-right: #3366cc thin solid;
|
||||
border-bottom: #3366cc thin solid;
|
||||
padding-right: 5px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
.trans {
|
||||
font-size: smaller;
|
||||
color : #000000;
|
||||
border-left: #3366cc thin solid;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.trans_rtl {
|
||||
font-size: smaller;
|
||||
color : #000000;
|
||||
border-right: #3366cc thin solid;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
img {
|
||||
border: none 0;
|
||||
}
|
||||
|
||||
td.side {
|
||||
color: #3366cc;
|
||||
/* background: #f2f2f9;
|
||||
border-color: #3366cc;
|
||||
border-style: solid;
|
||||
border-width: thin; */
|
||||
border-color: white;
|
||||
border-style: none;
|
||||
vertical-align: top;
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
div.copyright {
|
||||
font-size: 80%;
|
||||
border: 2px solid #3366cc;
|
||||
padding: 4px;
|
||||
background: #f2f2f9;
|
||||
border-style: solid;
|
||||
border-width: thin;
|
||||
}
|
||||
|
||||
.footnoteref {
|
||||
font-size: smaller;
|
||||
vertical-align: text-top;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<!-- This document is in XML, and xhtml 1.0 -->
|
||||
<!-- Please make sure to properly nest your tags -->
|
||||
<!-- and ensure that your final document validates -->
|
||||
<!-- consistent with W3C xhtml 1.0 and CSS standards -->
|
||||
<!-- See validator.w3.org -->
|
||||
|
||||
<body>
|
||||
|
||||
<h3>%%TITLE%%</h3>
|
||||
|
||||
<!-- <address>Free Software Foundation</address> -->
|
||||
<address>last updated %%DATE%%</address>
|
||||
|
||||
<!--
|
||||
<p>
|
||||
<a href="/graphics/gnu-head.jpg">
|
||||
<img src="/graphics/gnu-head-sm.jpg"
|
||||
alt=" [image of the head of a GNU] "
|
||||
width="129" height="122" />
|
||||
</a>
|
||||
<a href="/philosophy/gif.html">(no gifs due to patent problems)</a>
|
||||
</p>
|
||||
-->
|
||||
|
||||
<hr />
|
||||
|
||||
<p>This document <!--(%%PACKAGE%%)--> is available in the following formats:</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="%%PACKAGE%%.html">HTML
|
||||
(%%HTML_MONO_SIZE%%K characters)</a> - entirely on one web page.</li>
|
||||
<li><a href="html_node/index.html">HTML</a> - with one web page per
|
||||
node.</li>
|
||||
<li><a href="%%PACKAGE%%.html.gz">HTML compressed
|
||||
(%%HTML_MONO_GZ_SIZE%%K gzipped characters)</a> - entirely on
|
||||
one web page.</li>
|
||||
<li><a href="%%PACKAGE%%.html_node.tar.gz">HTML compressed
|
||||
(%%HTML_NODE_TGZ_SIZE%%K gzipped tar file)</a> -
|
||||
with one web page per node.</li>
|
||||
<li><a href="%%PACKAGE%%.info.tar.gz">Info document
|
||||
(%%INFO_TGZ_SIZE%%K characters gzipped tar file)</a>.</li>
|
||||
<li><a href="%%PACKAGE%%.txt">ASCII text
|
||||
(%%ASCII_SIZE%%K characters)</a>.</li>
|
||||
<li><a href="%%PACKAGE%%.txt.gz">ASCII text compressed
|
||||
(%%ASCII_GZ_SIZE%%K gzipped characters)</a>.</li>
|
||||
<li><a href="%%PACKAGE%%.dvi.gz">TeX dvi file
|
||||
(%%DVI_GZ_SIZE%%K characters gzipped)</a>.</li>
|
||||
<li><a href="%%PACKAGE%%.ps.gz">PostScript file
|
||||
(%%PS_GZ_SIZE%%K characters gzipped)</a>.</li>
|
||||
<li><a href="%%PACKAGE%%.pdf">PDF file
|
||||
(%%PDF_SIZE%%K characters)</a>.</li>
|
||||
<li><a href="%%PACKAGE%%.texi.tar.gz">Texinfo source
|
||||
(%%TEXI_TGZ_SIZE%%K characters gzipped tar file)</a></li>
|
||||
</ul>
|
||||
|
||||
<p>(This page was generated by the <a href="%%SCRIPTURL%%">%%SCRIPTNAME%%
|
||||
script</a>.)</p>
|
||||
|
||||
<div class="copyright">
|
||||
<p>
|
||||
Return to <a href="/project/cffi/">CFFI's home page</a>.
|
||||
</p>
|
||||
|
||||
<!--
|
||||
<p>
|
||||
Please send FSF & GNU inquiries to
|
||||
<a href="mailto:gnu@gnu.org"><em>gnu@gnu.org</em></a>.
|
||||
There are also <a href="/home.html#ContactInfo">other ways to contact</a>
|
||||
the FSF.
|
||||
<br />
|
||||
Please send broken links and other corrections (or suggestions) to
|
||||
<a href="mailto:webmasters@gnu.org"><em>webmasters@gnu.org</em></a>.
|
||||
</p>
|
||||
-->
|
||||
|
||||
<p>
|
||||
Copyright (C) 2005 James Bielman <jamesjb at jamesjb.com><br />
|
||||
Copyright (C) 2005 Luís Oliveira <loliveira at common-lisp.net>
|
||||
<!--
|
||||
<br />
|
||||
Verbatim copying and distribution of this entire article is
|
||||
permitted in any medium, provided this notice is preserved.
|
||||
-->
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Updated: %%DATE%%
|
||||
<!-- timestamp start -->
|
||||
<!-- $Date: 2005/05/15 00:00:08 $ $Author: karl $ -->
|
||||
<!-- timestamp end -->
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
|
||||
# Block Memory Operations
|
||||
|
||||
Function: mem-fill ptr type count value &optional (offset 0)
|
||||
|
||||
Fill COUNT objects of TYPE, starting at PTR plus offset, with VALUE.
|
||||
|
||||
;; Equivalent to (but possibly more efficient than):
|
||||
(loop for i below count
|
||||
for off from offset by (%foreign-type-size type)
|
||||
do (setf (%mem-ref ptr type off) value))
|
||||
|
||||
Function: mem-read-vector vector ptr type count &optional (offset 0)
|
||||
|
||||
Copy COUNT objects of TYPE from foreign memory at PTR plus OFFSET into
|
||||
VECTOR. If VECTOR is not large enough to contain COUNT objects, it
|
||||
will copy as many objects as necessary to fill the vector. The
|
||||
results are undefined if the foreign memory block is not large enough
|
||||
to supply the data to copy.
|
||||
|
||||
TYPE must be a built-in foreign type (integer, float, double, or
|
||||
pointer).
|
||||
|
||||
Returns the number of objects copied.
|
||||
|
||||
;; Equivalent to (but possibly more efficient than):
|
||||
(loop for i below (min count (length vector))
|
||||
for off from offset by (%foreign-type-size type)
|
||||
do (setf (aref vector i) (%mem-ref ptr type off))
|
||||
finally (return i))
|
||||
|
||||
|
||||
Function: mem-read-c-string string ptr &optional (offset 0)
|
||||
|
||||
Copy a null-terminated C string from PTR plus OFFSET into STRING, a
|
||||
Lisp string. If STRING is not large enough to contain the data at PTR
|
||||
it will be truncated.
|
||||
|
||||
Returns the number of characters copied into STRING.
|
||||
|
||||
;; Equivalent to (but possibly more efficient than):
|
||||
(loop for i below (length string)
|
||||
for off from offset
|
||||
for char = (%mem-ref ptr :char off)
|
||||
until (zerop char)
|
||||
do (setf (char string i) char)
|
||||
finally (return i))
|
||||
|
||||
Function: mem-write-vector vector ptr type &optional
|
||||
(count (length vector)) (offset 0)
|
||||
|
||||
Copy COUNT objects from VECTOR into objects of TYPE in foreign memory,
|
||||
starting at PTR plus OFFSET. The results are undefined if PTR does
|
||||
not point to a memory block large enough to hold the data copied.
|
||||
|
||||
TYPE must be a built-in type (integer, float, double, or pointer).
|
||||
|
||||
Returns the number of objects copied from VECTOR to PTR.
|
||||
|
||||
;; Equivalent to (but possibly more efficient than):
|
||||
(loop for i below count
|
||||
for off from offset by (%foreign-type-size type)
|
||||
do (setf (%mem-ref ptr type off) (aref vector i))
|
||||
finally (return i))
|
||||
|
||||
|
||||
Function: mem-write-c-string string ptr &optional (offset 0)
|
||||
|
||||
Copy the characters from a Lisp STRING to PTR plus OFFSET, adding a
|
||||
final null terminator at the end. The results are undefined if the
|
||||
memory at PTR is not large enough to accomodate the data.
|
||||
|
||||
This interface is currently equivalent to MEM-WRITE-VECTOR with a TYPE
|
||||
of :CHAR, but will be useful when proper support for Unicode strings
|
||||
is implemented.
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
# Shareable Byte Vectors
|
||||
|
||||
Function: make-shareable-byte-vector size
|
||||
|
||||
Create a vector of element type (UNSIGNED-BYTE 8) suitable for passing
|
||||
to WITH-POINTER-TO-VECTOR-DATA.
|
||||
|
||||
;; Minimal implementation:
|
||||
(defun make-shareable-byte-vector (size)
|
||||
(make-array size :element-type '(unsigned-byte 8)))
|
||||
|
||||
|
||||
Macro: with-pointer-to-vector-data (ptr-var vector) &body body
|
||||
|
||||
Bind PTR-VAR to a pointer to the data contained in a shareable byte
|
||||
vector.
|
||||
|
||||
VECTOR must be a shareable vector created by MAKE-SHAREABLE-BYTE-VECTOR.
|
||||
|
||||
PTR-VAR may point directly into the Lisp vector data, or it may point
|
||||
to a temporary block of foreign memory which will be copied to and
|
||||
from VECTOR.
|
||||
|
||||
Both the pointer object in PTR-VAR and the memory it points to have
|
||||
dynamic extent. The results are undefined if foreign code attempts to
|
||||
access this memory outside this dynamic contour.
|
||||
|
||||
The implementation must guarantee the memory pointed to by PTR-VAR
|
||||
will not be moved during the dynamic contour of this operator, either
|
||||
by creating the vector in a static area or temporarily disabling the
|
||||
garbage collector.
|
||||
|
||||
;; Minimal (copying) implementation:
|
||||
(defmacro with-pointer-to-vector-data ((ptr-var vector) &body body)
|
||||
(let ((vector-var (gensym))
|
||||
(size-var (gensym)))
|
||||
`(let* ((,vector-var ,vector)
|
||||
(,size-var (length ,vector-var)))
|
||||
(with-foreign-ptr (,ptr-var ,size-var)
|
||||
(mem-write-vector ,vector-var ,ptr :uint8)
|
||||
(prog1
|
||||
(progn ,@body)
|
||||
(mem-read-vector ,vector-var ,ptr-var :uint8 ,size-var))))))
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
body {font-family: Georgia, serif;
|
||||
line-height: 1.3;
|
||||
padding-left: 5em; padding-right: 1em;
|
||||
padding-bottom: 1em; max-width: 60em;}
|
||||
table {border-collapse: collapse}
|
||||
span.roman { font-family: century schoolbook, serif; font-weight: normal; }
|
||||
h1, h2, h3, h4, h5, h6 {font-family: Helvetica, sans-serif}
|
||||
h4 { margin-top: 2.5em; }
|
||||
dfn {font-family: inherit; font-variant: italic; font-weight: bolder }
|
||||
kbd {font-family: monospace; text-decoration: underline}
|
||||
/*var {font-family: Helvetica, sans-serif; font-variant: slanted}*/
|
||||
var {font-variant: slanted;}
|
||||
td {padding-right: 1em; padding-left: 1em}
|
||||
sub {font-size: smaller}
|
||||
.node {padding: 0; margin: 0}
|
||||
|
||||
pre.lisp { font-family: monospace;
|
||||
background-color: #F4F4F4; border: 1px solid #AAA;
|
||||
padding-top: 0.5em; padding-bottom: 0.5em; }
|
||||
|
||||
/* coloring */
|
||||
|
||||
.lisp-bg { background-color: #F4F4F4 ; color: black; }
|
||||
.lisp-bg:hover { background-color: #F4F4F4 ; color: black; }
|
||||
|
||||
.symbol { font-weight: bold; color: #770055; background-color : transparent; border: 0px; margin: 0px;}
|
||||
a.symbol:link { font-weight: bold; color : #229955; background-color : transparent; text-decoration: none; border: 0px; margin: 0px; }
|
||||
a.symbol:active { font-weight: bold; color : #229955; background-color : transparent; text-decoration: none; border: 0px; margin: 0px; }
|
||||
a.symbol:visited { font-weight: bold; color : #229955; background-color : transparent; text-decoration: none; border: 0px; margin: 0px; }
|
||||
a.symbol:hover { font-weight: bold; color : #229955; background-color : transparent; text-decoration: none; border: 0px; margin: 0px; }
|
||||
.special { font-weight: bold; color: #FF5000; background-color: inherit; }
|
||||
.keyword { font-weight: bold; color: #770000; background-color: inherit; }
|
||||
.comment { font-weight: normal; color: #007777; background-color: inherit; }
|
||||
.string { font-weight: bold; color: #777777; background-color: inherit; }
|
||||
.character { font-weight: bold; color: #0055AA; background-color: inherit; }
|
||||
.syntaxerror { font-weight: bold; color: #FF0000; background-color: inherit; }
|
||||
span.paren1 { font-weight: bold; color: #777777; }
|
||||
span.paren1:hover { color: #777777; background-color: #BAFFFF; }
|
||||
span.paren2 { color: #777777; }
|
||||
span.paren2:hover { color: #777777; background-color: #FFCACA; }
|
||||
span.paren3 { color: #777777; }
|
||||
span.paren3:hover { color: #777777; background-color: #FFFFBA; }
|
||||
span.paren4 { color: #777777; }
|
||||
span.paren4:hover { color: #777777; background-color: #CACAFF; }
|
||||
span.paren5 { color: #777777; }
|
||||
span.paren5:hover { color: #777777; background-color: #CAFFCA; }
|
||||
span.paren6 { color: #777777; }
|
||||
span.paren6:hover { color: #777777; background-color: #FFBAFF; }
|
||||
Loading…
Add table
Add a link
Reference in a new issue