comparison src/utils.h @ 118:00e874d9a6a7

Added some documentation to utils.h.
author Atul Varma <varmaa@toolness.com>
date Mon, 17 Aug 2009 22:22:41 -0700
parents ac8ca0ee7760
children 537cf7deadc9
comparison
equal deleted inserted replaced
117:ac8ca0ee7760 118:00e874d9a6a7
41 41
42 #include <jsapi.h> 42 #include <jsapi.h>
43 #include <jsdhash.h> 43 #include <jsdhash.h>
44 #include <Python.h> 44 #include <Python.h>
45 45
46 // Simple class that holds the Python global interpreter lock (GIL)
47 // for as long as it's in scope.
46 class PYM_PyAutoEnsureGIL { 48 class PYM_PyAutoEnsureGIL {
47 public: 49 public:
48 PYM_PyAutoEnsureGIL() { 50 PYM_PyAutoEnsureGIL() {
49 state = PyGILState_Ensure(); 51 state = PyGILState_Ensure();
50 } 52 }
62 void *value; 64 void *value;
63 } PYM_HashEntry; 65 } PYM_HashEntry;
64 66
65 extern PyObject *PYM_error; 67 extern PyObject *PYM_error;
66 68
69 // Convert a PyObject to a jsval. Returns 0 on success,
70 // -1 on error. If an error occurs, a Python exception is
71 // set.
72 //
73 // The jsval is placed in rval.
67 extern int 74 extern int
68 PYM_pyObjectToJsval(PYM_JSContextObject *context, 75 PYM_pyObjectToJsval(PYM_JSContextObject *context,
69 PyObject *object, 76 PyObject *object,
70 jsval *rval); 77 jsval *rval);
71 78
79 // Convert a jsval to a PyObject, returning a new reference.
80 // If this function fails, it sets a Python exception and
81 // returns NULL.
72 extern PyObject * 82 extern PyObject *
73 PYM_jsvalToPyObject(PYM_JSContextObject *context, jsval value); 83 PYM_jsvalToPyObject(PYM_JSContextObject *context, jsval value);
74 84
85 // Converts the currently-pending Python exception to a
86 // pending JS exception on the given JS context.
75 extern void 87 extern void
76 PYM_pythonExceptionToJs(PYM_JSContextObject *context); 88 PYM_pythonExceptionToJs(PYM_JSContextObject *context);
77 89
90 // Converts the currently-pending exception on the given
91 // JS context into a pending Python exception.
78 void 92 void
79 PYM_jsExceptionToPython(PYM_JSContextObject *context); 93 PYM_jsExceptionToPython(PYM_JSContextObject *context);
80 94
81 #endif 95 #endif