Mercurial > pymonkey
annotate src/undefined.cpp @ 173:5cfb47c9e916 default tip
Minor line wrap and spacing fixes.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Tue, 01 Sep 2009 03:22:33 -0700 |
parents | dd32a92f6b4f |
children |
rev | line source |
---|---|
48
bc4263c6ae82
Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents:
10
diff
changeset
|
1 /* ***** BEGIN LICENSE BLOCK ***** |
bc4263c6ae82
Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents:
10
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:
10
diff
changeset
|
3 * |
bc4263c6ae82
Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents:
10
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:
10
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:
10
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:
10
diff
changeset
|
7 * http://www.mozilla.org/MPL/ |
bc4263c6ae82
Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents:
10
diff
changeset
|
8 * |
bc4263c6ae82
Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents:
10
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:
10
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:
10
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:
10
diff
changeset
|
12 * License. |
bc4263c6ae82
Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents:
10
diff
changeset
|
13 * |
170
dd32a92f6b4f
Initial attempt at renaming pymonkey to pydermonkey.
Atul Varma <varmaa@toolness.com>
parents:
131
diff
changeset
|
14 * The Original Code is Pydermonkey. |
48
bc4263c6ae82
Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents:
10
diff
changeset
|
15 * |
bc4263c6ae82
Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents:
10
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:
10
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:
10
diff
changeset
|
18 * the Initial Developer. All Rights Reserved. |
bc4263c6ae82
Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents:
10
diff
changeset
|
19 * |
bc4263c6ae82
Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents:
10
diff
changeset
|
20 * Contributor(s): |
bc4263c6ae82
Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents:
10
diff
changeset
|
21 * Atul Varma <atul@mozilla.com> |
bc4263c6ae82
Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents:
10
diff
changeset
|
22 * |
bc4263c6ae82
Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents:
10
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:
10
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:
10
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:
10
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:
10
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:
10
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:
10
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:
10
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:
10
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:
10
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:
10
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:
10
diff
changeset
|
34 * |
bc4263c6ae82
Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents:
10
diff
changeset
|
35 * ***** END LICENSE BLOCK ***** */ |
bc4263c6ae82
Added license blocks to all .c/.h files.
Atul Varma <varmaa@toolness.com>
parents:
10
diff
changeset
|
36 |
10
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
37 #include "undefined.h" |
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
38 |
57
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
39 static Py_ssize_t PYM_undefinedLength(PyObject *o) { |
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
40 return 0; |
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
41 }; |
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
42 |
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
43 static PyMappingMethods PYM_undefinedAsMapping = { |
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
44 PYM_undefinedLength, /*mp_length*/ |
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
45 0, /*mp_subscript*/ |
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
46 0 /*mp_ass_subscript*/ |
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
47 }; |
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
48 |
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
49 static PyObject *PYM_undefinedRepr(PyObject *o) { |
170
dd32a92f6b4f
Initial attempt at renaming pymonkey to pydermonkey.
Atul Varma <varmaa@toolness.com>
parents:
131
diff
changeset
|
50 return PyString_FromString("pydermonkey.undefined"); |
57
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
51 } |
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
52 |
10
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
53 PyTypeObject PYM_undefinedType = { |
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
54 PyObject_HEAD_INIT(NULL) |
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
55 0, /*ob_size*/ |
173
5cfb47c9e916
Minor line wrap and spacing fixes.
Atul Varma <varmaa@toolness.com>
parents:
170
diff
changeset
|
56 "pydermonkey.undefined", /*tp_name*/ |
10
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
57 sizeof(PYM_undefinedObject), /*tp_basicsize*/ |
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
58 0, /*tp_itemsize*/ |
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
59 0, /*tp_dealloc*/ |
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
60 0, /*tp_print*/ |
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
61 0, /*tp_getattr*/ |
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
62 0, /*tp_setattr*/ |
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
63 0, /*tp_compare*/ |
57
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
64 PYM_undefinedRepr, /*tp_repr*/ |
10
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
65 0, /*tp_as_number*/ |
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
66 0, /*tp_as_sequence*/ |
57
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
67 &PYM_undefinedAsMapping, /*tp_as_mapping*/ |
10
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
68 0, /*tp_hash */ |
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
69 0, /*tp_call*/ |
57
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
70 PYM_undefinedRepr, /*tp_str*/ |
10
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
71 0, /*tp_getattro*/ |
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
72 0, /*tp_setattro*/ |
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
73 0, /*tp_as_buffer*/ |
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
74 Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
131
f956a6dea16c
Minor housekeeping: replaced tabs w/ spaces, got rid of outdated TODOs, etc.
Atul Varma <varmaa@toolness.com>
parents:
117
diff
changeset
|
75 /* tp_doc */ |
10
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
76 "Pythonic equivalent of JavaScript's 'undefined' value", |
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
77 }; |
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
78 |
57
a2b617731398
pymonkey.undefined now has a 'falsy' value.
Atul Varma <varmaa@toolness.com>
parents:
48
diff
changeset
|
79 PYM_undefinedObject *PYM_undefined; |