source: project/release/3/pyffi/trunk/pyffi-eggdoc.scm @ 10774

Last change on this file since 10774 was 10774, checked in by Ivan Raikov, 12 years ago

Added entry for version 2.6.

File size: 6.7 KB
Line 
1
2(use eggdoc)
3
4(define doc
5  `((eggdoc:begin
6     (name "pyffi")
7
8     (description "An interface to the Python programming language.")
9
10     (author (url "http://chicken.wiki.br/ivan raikov" "Ivan Raikov"))
11
12     (history 
13      (version "2.6" "define-pyslot updated to support modifying attributes")
14      (version "2.5" "Added definitions for Py_IncRef and Py_DecRef when using Python 2.3")
15      (version "2.4" "Fixed a bug in the wrapper of PyRun_String")
16      (version "2.3" "Added support for the boolean type")
17      (version "2.2" "Some fixes to ensure compatibility with Python 2.3 and 2.5")
18      (version "2.1" "Build script updated for better cross-platform compatibility")
19      (version "2.0" "Change to use utf8 extension")
20      (version "1.1" "Metafile fix")
21      (version "1.0" "Initial release"))
22
23     (requires (url "utf8.html"   "utf8")
24               (url "easyffi.html"  "easyffi"))
25
26     (usage "(require-extension pyffi)")
27
28     (download "pyffi.egg")
29
30     (documentation
31     
32      (p "The " (tt "pyffi") " extension uses the " 
33         (url "http://www.python.org" "Python") " C interface "
34         " to invoke Python procedures and methods from within Scheme "
35         " and to convert data objects between their Python and Scheme "
36         "representation. ")
37
38      (p "Currently, " (tt "pyffi") " supports the Python data "
39         "types listed in the table below. All other Python data types "
40         "are represented as pointers. ")
41
42      (symbol-table 
43       (describe "int, float" 
44                 ("numeric types, converted to and from the corresponding Scheme numeric values."))
45
46       (describe "list" 
47                 ("list type, converted to and from Scheme list value"))
48
49       (describe "str" 
50                 ("string type, converted to and from Scheme string value"))
51
52       (describe "unicode" 
53                 ("Unicode string type, converted to and from Scheme " (url "utf8.html"   "utf8") " string"))
54
55       (describe "dict" 
56                 ("dictionary type, converted to and from Scheme alist value"))
57
58       (describe "tuple" 
59                 ("tuple type, converted to and from Scheme vector value")))
60
61      (subsection "Procedures"
62                 
63          (procedure "(py-start)"
64                     (p "Initializes the Python interpreter, and creates an evaluation environment. "
65                        "This procedure must be called before all other procedures in the extension. "))
66                       
67          (procedure "(py-stop)"
68                     (p "Deallocates the memory reserved by the Python interpreter, and frees all "
69                        "internal structures of the extension. "))
70
71          (procedure "(py-import name)"
72                     (p "Imports Python module " (tt "NAME") ". If the import was unsuccessful, "
73                        "raises an exception of type " (tt "'pyerror") ". "))
74
75         
76          (procedure "(py-eval expr)"
77                     (p "Evaluates the Python expression contained in the string " (tt "EXPR") 
78                        " and returns the resulting value, either converted to Scheme "
79                        "representation, or as a pointer to a Python value. "))
80
81          (procedure "(py-apply func arg1 ...)"
82                     (p "Applies the given arguments to the Python object " (tt "FUNC") 
83                        " and returns the resulting value, either converted to Scheme "
84                        "representation, or as a pointer to a Python value. "
85                        "The arguments must be either Scheme values of types listed "
86                        "in the type conversion table above, or pointers to Python values.")))
87
88      (subsection "Macros"
89
90          (macro "(define-pyfun expr arg1 ...)"
91             (p "Defines a Scheme procedure named when called, "
92                "invokes the Python procedure of the same name. " 
93                (tt "EXPR") " is either a string that contains the procedure name, "
94                "or a pair of the form " (tt "(FORM . NAME)") " where " (tt "FORM")
95                " is a Python expression that when evaluated returns a Python procedure, "
96                "and " (tt "NAME") " is a string that contains the name of the Scheme procedure. "
97                "The arguments must be all symbols. "))
98
99          (macro "(define-pyslot NAME [SCHEME-NAME])"
100             (p "Defines an accessor/modifier for the Python object attribute " (tt "NAME") ". "
101                "The optional argument " (tt "SCHEME-NAME") " is an alternate name for the "
102                "Scheme procedure. The returned procedure takes in a Python object "
103                "and returns the value of attribute " (tt "NAME") " contained in that object. "
104                "If the object has no such attribute, #f is returned. "
105                "If a value is supplied after the name of the object, the procedure acts as a modifier for that slot. "
106                ))
107
108          (macro "(define-pymethod NAME [SCHEME-NAME])"
109             (p "Defines an accessor for the Python method " (tt "NAME") ". "
110                "The optional argument " (tt "SCHEME-NAME") " is an alternate name for the "
111                "Scheme procedure. The accessor is a procedure of the form " 
112                (tt "LAMBDA OBJ ARG1 ...") " that takes in a Python object " (tt "OBJ")
113                " and invokes the method " (tt "NAME") " contained in that object, "
114                "with the supplied arguments, which must be either Scheme values of types "
115                "listed in the type conversion table above, or pointers to Python values. "
116                "If the object has no such method, #f is returned. "))))
117
118
119
120     (examples (pre #<<EOF
121;;
122;; Python-UNO example from pyffi.lisp by Dmitri Hrapof.
123;;
124;; Before running the following code, you must make sure OpenOffice is
125;; running as a server:
126;;
127;;  soffice "-accept=socket,host=localhost,port=2002;urp;"
128;;
129(require-extension pyffi)
130
131(py-start)
132
133(py-import "uno")
134
135(define-pyfun "uno.getComponentContext")
136
137(define-pyslot "ServiceManager")
138(define-pyslot "Text")
139
140;; Can't yet find out appropriate class, the following is lame
141(define-pymethod "createInstanceWithContext")
142(define-pymethod "resolve")
143(define-pymethod "getCurrentComponent")
144(define-pymethod "createTextCursor")
145(define-pymethod "insertString")
146
147(define (message-uno str)
148  (let* ((lc (uno.getcomponentcontext))
149         (resolver (createInstanceWithContext 
150                    (ServiceManager lc)
151                    "com.sun.star.bridge.UnoUrlResolver" lc))
152         (ctx (resolve resolver "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext"))
153         (desktop (CreateInstanceWithContext 
154                   (ServiceManager ctx)
155                   "com.sun.star.frame.Desktop" ctx))
156         (model   (getCurrentComponent desktop))
157         (text    (text model))
158         (cursor  (createTextCursor text)))
159    (insertString text cursor str 0)))
160
161
162(message-uno "Hello, world!")
163
164EOF
165))
166     (license
167      "Copyright 2007 Ivan Raikov. Based on pyffi.lisp by Dmitri Hrapof.
168
169This program is free software: you can redistribute it and/or modify
170it under the terms of the GNU General Public License as published by
171the Free Software Foundation, either version 3 of the License, or (at
172your option) any later version.
173
174This program is distributed in the hope that it will be useful, but
175WITHOUT ANY WARRANTY; without even the implied warranty of
176MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
177General Public License for more details.
178
179A full copy of the GPL license can be found at
180<http://www.gnu.org/licenses/>."))))
181
182(if (eggdoc->html doc) (void))
Note: See TracBrowser for help on using the repository browser.