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

Last change on this file since 11623 was 11623, checked in by Ivan Raikov, 11 years ago

Some fixed in utf8 support; version set to 2.10

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