1 # Copyright (C) 2013-2020 Roland Lutz
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 ## \file xorn/guile.py
18 ## Placeholder file for xorn.guile documentation.
20 # This file DOES NOT contain the actual source code of the xorn.guile
21 # module. It contains documented stubs of the code from which the
22 # Doxygen documentation is generated. For the actual definition of
23 # the module, see the Python extension in \c src/cpython/guile/.
25 ## \namespace xorn.guile
26 ## Embedding a Guile interpreter.
28 # This module allows embedding a Guile interpreter into a Python
29 # application. It translates Python objects transparently into Guile
30 # objects and vice versa. In order to make a Python function
31 # available to Guile code, just bind it to a variable name:
33 # \snippet guile.py guile
35 ## Raised on Guile-related errors.
37 class GuileError(Exception):
42 # This type can't be directly instantiated.
44 class Procedure(object):
45 ## x.__call__(...) <==> x(...)
49 ## x.__repr__() <==> repr(x)
53 ## Return the variable bound to a symbol.
55 # Signals an error if there is no such binding or the symbol is not
56 # bound to a variable.
61 ## Create a top level variable.
63 # If the named variable already exists, just changes its value.
65 # \throws GuileError if \a value can't be represented as a Guile
68 def define(name
, value
):
71 ## Load a file and evaluate its contents in the top-level environment.
73 # \a name must either be a full pathname or be a pathname relative to
74 # the current directory. If the Guile variable \c %%load-hook is
75 # defined, the procedure to which it is bound will be called before
78 # \sa [Guile documentation for %%load-hook](https://www.gnu.org/
79 #software/guile/manual/html_node/Loading.html#index-_0025load_002dhook)
84 ## Parse a string as Scheme and evaluate the expressions it contains,
85 ## in order, returning the last expression.
87 def eval_string(string
):