comparison docs/src/pymonkey.txt @ 51:fabd3f2271fa

Added some basic, incomplete docs on the pymonkey module, which include a doctest that's run when pymonkey is built.
author Atul Varma <varmaa@toolness.com>
date Wed, 08 Jul 2009 09:32:31 -0700
parents
children 2055d853b995
comparison
equal deleted inserted replaced
50:405f03166009 51:fabd3f2271fa
1 :mod:`pymonkey` --- Access SpiderMonkey from Python
2 ===================================================
3
4 .. module:: pymonkey
5 :synopsis: Access SpiderMonkey from Python
6
7 .. testsetup:: *
8
9 import pymonkey
10
11 This module offers a low-level interface to the `Mozilla SpiderMonkey
12 <https://developer.mozilla.org/en/SpiderMonkey>`_ JavaScript engine.
13
14 .. exception:: error
15
16 This is the type of any SpiderMonkey-related errors thrown by this
17 module.
18
19 .. class:: Context
20
21 This is the type of JavaScript context objects. Contexts can only
22 be created via a call to :meth:`Runtime.new_context()`, but this
23 type object can be used with Python's built-in :func:`isinstance()`
24 to verify that an object is a context, like so:
25
26 >>> cx = pymonkey.Runtime().new_context()
27 >>> isinstance(cx, pymonkey.Context)
28 True
29
30 .. class:: Runtime()
31
32 Creates a new JavaScript runtime. JS objects created by the
33 runtime may interact with other JS objects of the runtime, but
34 they can't interact with objects from other runtimes.
35
36 .. method:: new_context()
37
38 Creates a new Context object and returns it. Contexts are best
39 conceptualized as threads of execution in a JS runtme; each one
40 has a program counter, a current exception state, and so
41 forth. JS objects may be freely accessed and changed by contexts
42 that are associated with the same JS runtime as the objects.