annotate runtime.h @ 87:345d4c0e3dd3

Thread safety exceptions are now properly raised by all relevant pymonkey functions.
author Atul Varma <varmaa@toolness.com>
date Sun, 09 Aug 2009 16:17:25 -0700
parents 2b5696b91b01
children e77bc7c799e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
48
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
1 /* ***** BEGIN LICENSE BLOCK *****
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
3 *
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
4 * The contents of this file are subject to the Mozilla Public License Version
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
5 * 1.1 (the "License"); you may not use this file except in compliance with
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
6 * the License. You may obtain a copy of the License at
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
7 * http://www.mozilla.org/MPL/
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
8 *
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
9 * Software distributed under the License is distributed on an "AS IS" basis,
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
11 * for the specific language governing rights and limitations under the
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
12 * License.
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
13 *
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
14 * The Original Code is Pymonkey.
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
15 *
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
16 * The Initial Developer of the Original Code is Mozilla.
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
17 * Portions created by the Initial Developer are Copyright (C) 2007
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
18 * the Initial Developer. All Rights Reserved.
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
19 *
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
20 * Contributor(s):
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
21 * Atul Varma <atul@mozilla.com>
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
22 *
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
23 * Alternatively, the contents of this file may be used under the terms of
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
26 * in which case the provisions of the GPL or the LGPL are applicable instead
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
27 * of those above. If you wish to allow use of your version of this file only
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
28 * under the terms of either the GPL or the LGPL, and not to allow others to
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
29 * use your version of this file under the terms of the MPL, indicate your
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
30 * decision by deleting the provisions above and replace them with the notice
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
31 * and other provisions required by the GPL or the LGPL. If you do not delete
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
32 * the provisions above, a recipient may use your version of this file under
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
33 * the terms of any one of the MPL, the GPL or the LGPL.
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
34 *
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
35 * ***** END LICENSE BLOCK ***** */
bc4263c6ae82 Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents: 23
diff changeset
36
11
551ba05fe6ad factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
37 #ifndef PYM_RUNTIME_H
551ba05fe6ad factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
38 #define PYM_RUNTIME_H
551ba05fe6ad factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
39
551ba05fe6ad factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
40 #include <jsapi.h>
23
951ad1b15587 The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents: 22
diff changeset
41 #include <jsdhash.h>
11
551ba05fe6ad factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
42 #include <Python/Python.h>
87
345d4c0e3dd3 Thread safety exceptions are now properly raised by all relevant pymonkey functions.
Atul Varma <varmaa@toolness.com>
parents: 62
diff changeset
43 #include <Python/pythread.h>
345d4c0e3dd3 Thread safety exceptions are now properly raised by all relevant pymonkey functions.
Atul Varma <varmaa@toolness.com>
parents: 62
diff changeset
44
345d4c0e3dd3 Thread safety exceptions are now properly raised by all relevant pymonkey functions.
Atul Varma <varmaa@toolness.com>
parents: 62
diff changeset
45 #define PYM_SANITY_CHECK(runtime) \
345d4c0e3dd3 Thread safety exceptions are now properly raised by all relevant pymonkey functions.
Atul Varma <varmaa@toolness.com>
parents: 62
diff changeset
46 if (PyThread_get_thread_ident() != runtime->thread) { \
345d4c0e3dd3 Thread safety exceptions are now properly raised by all relevant pymonkey functions.
Atul Varma <varmaa@toolness.com>
parents: 62
diff changeset
47 PyErr_SetString(PYM_error, "Function called from wrong thread"); \
345d4c0e3dd3 Thread safety exceptions are now properly raised by all relevant pymonkey functions.
Atul Varma <varmaa@toolness.com>
parents: 62
diff changeset
48 return NULL; \
345d4c0e3dd3 Thread safety exceptions are now properly raised by all relevant pymonkey functions.
Atul Varma <varmaa@toolness.com>
parents: 62
diff changeset
49 }
11
551ba05fe6ad factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
50
551ba05fe6ad factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
51 typedef struct {
551ba05fe6ad factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
52 PyObject_HEAD
551ba05fe6ad factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
53 JSRuntime *rt;
62
2b5696b91b01 Fixed a bug whereby some objects wouldn't be finalized when a runtime was destroyed.
Atul Varma <varmaa@toolness.com>
parents: 48
diff changeset
54 JSContext *cx;
23
951ad1b15587 The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents: 22
diff changeset
55 JSDHashTable objects;
87
345d4c0e3dd3 Thread safety exceptions are now properly raised by all relevant pymonkey functions.
Atul Varma <varmaa@toolness.com>
parents: 62
diff changeset
56 long thread;
11
551ba05fe6ad factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
57 } PYM_JSRuntimeObject;
551ba05fe6ad factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
58
551ba05fe6ad factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
59 extern PyTypeObject PYM_JSRuntimeType;
551ba05fe6ad factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
60
551ba05fe6ad factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
61 #endif