source: project/pyffi/trunk/pyffi-eggdoc.scm @ 7358

Last change on this file since 7358 was 7358, checked in by Ivan Raikov, 13 years ago

Updated author address.

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