annotate Python/modsupport.c @ 5476:062aed8a4ce2 legacy-trunk v1.5a1

This commit was manufactured by cvs2svn to create tag 'r15a1'.
author cvs2svn <tools@python.org>
date Fri, 09 May 1997 03:21:44 +0000
parents 5880384d7c71
children 93304b2e14cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
1 /***********************************************************
2062
d0d0a69b5ca3 Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents: 2052
diff changeset
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
d0d0a69b5ca3 Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents: 2052
diff changeset
3 The Netherlands.
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
4
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
5 All Rights Reserved
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
6
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
7 Permission to use, copy, modify, and distribute this software and its
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
8 documentation for any purpose and without fee is hereby granted,
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
9 provided that the above copyright notice appear in all copies and that
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
10 both that copyright notice and this permission notice appear in
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
11 supporting documentation, and that the names of Stichting Mathematisch
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
12 Centrum or CWI or Corporation for National Research Initiatives or
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
13 CNRI not be used in advertising or publicity pertaining to
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
14 distribution of the software without specific, written prior
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
15 permission.
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
16
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
17 While CWI is the initial source for this software, a modified version
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
18 is made available by the Corporation for National Research Initiatives
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
19 (CNRI) at the Internet address ftp://ftp.python.org.
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
20
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3347
diff changeset
28 PERFORMANCE OF THIS SOFTWARE.
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
29
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
30 ******************************************************************/
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
31
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 /* Module support implementation */
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
33
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
34 #include "Python.h"
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
35
1848
b724599401ff Merge back to main trunk
Guido van Rossum <guido@python.org>
parents: 1319
diff changeset
36 #ifdef MPW /* MPW pushes 'extended' for float and double types with varargs */
b724599401ff Merge back to main trunk
Guido van Rossum <guido@python.org>
parents: 1319
diff changeset
37 typedef extended va_double;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
38 #else
1848
b724599401ff Merge back to main trunk
Guido van Rossum <guido@python.org>
parents: 1319
diff changeset
39 typedef double va_double;
b724599401ff Merge back to main trunk
Guido van Rossum <guido@python.org>
parents: 1319
diff changeset
40 #endif
b724599401ff Merge back to main trunk
Guido van Rossum <guido@python.org>
parents: 1319
diff changeset
41
2095
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
42 /* initmodule4() parameters:
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
43 - name is the module name
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
44 - methods is the list of top-level functions
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
45 - doc is the documentation string
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
46 - passthrough is passed as self to functions defined in the module
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
47 - api_version is the value of PYTHON_API_VERSION at the time the
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
48 module was compiled
2090
f78b387b54e0 New newmethodobject() interface takes struct methodlist pointer
Guido van Rossum <guido@python.org>
parents: 2062
diff changeset
49 */
1848
b724599401ff Merge back to main trunk
Guido van Rossum <guido@python.org>
parents: 1319
diff changeset
50
2095
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
51 static char api_version_warning[] =
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
52 "WARNING: Python C API version mismatch for module %s:\n\
3347
faa21ce1ff01 Corrected format string in api_version_warning.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2501
diff changeset
53 This Python has API version %d, module %s has version %d.\n";
2095
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
54
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
55 PyObject *
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
56 Py_InitModule4(name, methods, doc, passthrough, module_api_version)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 char *name;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
58 PyMethodDef *methods;
2090
f78b387b54e0 New newmethodobject() interface takes struct methodlist pointer
Guido van Rossum <guido@python.org>
parents: 2062
diff changeset
59 char *doc;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
60 PyObject *passthrough;
2095
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
61 int module_api_version;
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
63 PyObject *m, *d, *v;
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
64 PyMethodDef *ml;
2095
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
65 if (module_api_version != PYTHON_API_VERSION)
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
66 fprintf(stderr, api_version_warning,
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
67 name, PYTHON_API_VERSION, name, module_api_version);
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
68 if ((m = PyImport_AddModule(name)) == NULL) {
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 fprintf(stderr, "initializing module: %s\n", name);
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
70 Py_FatalError("can't create a module");
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 }
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
72 d = PyModule_GetDict(m);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 for (ml = methods; ml->ml_name != NULL; ml++) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
74 v = PyCFunction_New(ml, passthrough);
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
75 if (v == NULL ||
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
76 PyDict_SetItemString(d, ml->ml_name, v) != 0)
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
77 {
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 fprintf(stderr, "initializing module: %s\n", name);
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
79 Py_FatalError("can't initialize module");
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 }
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
81 Py_DECREF(v);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
82 }
2090
f78b387b54e0 New newmethodobject() interface takes struct methodlist pointer
Guido van Rossum <guido@python.org>
parents: 2062
diff changeset
83 if (doc != NULL) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
84 v = PyString_FromString(doc);
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
85 if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0)
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
86 Py_FatalError("can't add doc string");
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
87 Py_DECREF(v);
2090
f78b387b54e0 New newmethodobject() interface takes struct methodlist pointer
Guido van Rossum <guido@python.org>
parents: 2062
diff changeset
88 }
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 12
diff changeset
89 return m;
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
90 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
91
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
92
1211
406860dfaac7 * stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents: 1198
diff changeset
93 /* Helper for mkvalue() to scan the length of a format */
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
94
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
95 static int countformat Py_PROTO((char *format, int endchar));
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
96 static int countformat(format, endchar)
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
97 char *format;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
98 int endchar;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
99 {
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
100 int count = 0;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
101 int level = 0;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
102 while (level > 0 || *format != endchar) {
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
103 switch (*format) {
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
104 case '\0':
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
105 /* Premature end */
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
106 PyErr_SetString(PyExc_SystemError,
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
107 "unmatched paren in format");
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
108 return -1;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
109 case '(':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
110 case '[':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
111 case '{':
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
112 if (level == 0)
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
113 count++;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
114 level++;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
115 break;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
116 case ')':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
117 case ']':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
118 case '}':
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
119 level--;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
120 break;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
121 case '#':
2202
9894e55468ec support "O&" taking an object constructor a void*
Guido van Rossum <guido@python.org>
parents: 2154
diff changeset
122 case '&':
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
123 case ',':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
124 case ':':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
125 case ' ':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
126 case '\t':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
127 break;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
128 default:
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
129 if (level == 0)
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
130 count++;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
131 }
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
132 format++;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
133 }
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
134 return count;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
135 }
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
136
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
137
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
138 /* Generic function to create a value -- the inverse of getargs() */
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
139 /* After an original idea and first implementation by Steven Miale */
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
140
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
141 static PyObject *do_mktuple Py_PROTO((char**, va_list *, int, int));
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
142 static PyObject *do_mklist Py_PROTO((char**, va_list *, int, int));
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
143 static PyObject *do_mkdict Py_PROTO((char**, va_list *, int, int));
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
144 static PyObject *do_mkvalue Py_PROTO((char**, va_list *));
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
145
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
146
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
147 static PyObject *
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
148 do_mkdict(p_format, p_va, endchar, n)
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
149 char **p_format;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
150 va_list *p_va;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
151 int endchar;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
152 int n;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
153 {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
154 PyObject *d;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
155 int i;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
156 if (n < 0)
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
157 return NULL;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
158 if ((d = PyDict_New()) == NULL)
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
159 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
160 for (i = 0; i < n; i+= 2) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
161 PyObject *k, *v;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
162 k = do_mkvalue(p_format, p_va);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
163 if (k == NULL) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
164 Py_DECREF(d);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
165 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
166 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
167 v = do_mkvalue(p_format, p_va);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
168 if (v == NULL) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
169 Py_DECREF(k);
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
170 Py_DECREF(d);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
171 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
172 }
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
173 if (PyDict_SetItem(d, k, v) < 0) {
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
174 Py_DECREF(k);
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
175 Py_DECREF(v);
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
176 Py_DECREF(d);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
177 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
178 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
179 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
180 if (d != NULL && **p_format != endchar) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
181 Py_DECREF(d);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
182 d = NULL;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
183 PyErr_SetString(PyExc_SystemError,
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
184 "Unmatched paren in format");
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
185 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
186 else if (endchar)
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
187 ++*p_format;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
188 return d;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
189 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
190
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
191 static PyObject *
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
192 do_mklist(p_format, p_va, endchar, n)
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
193 char **p_format;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
194 va_list *p_va;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
195 int endchar;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
196 int n;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
197 {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
198 PyObject *v;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
199 int i;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
200 if (n < 0)
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
201 return NULL;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
202 if ((v = PyList_New(n)) == NULL)
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
203 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
204 for (i = 0; i < n; i++) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
205 PyObject *w = do_mkvalue(p_format, p_va);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
206 if (w == NULL) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
207 Py_DECREF(v);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
208 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
209 }
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
210 PyList_SetItem(v, i, w);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
211 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
212 if (v != NULL && **p_format != endchar) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
213 Py_DECREF(v);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
214 v = NULL;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
215 PyErr_SetString(PyExc_SystemError,
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
216 "Unmatched paren in format");
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
217 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
218 else if (endchar)
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
219 ++*p_format;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
220 return v;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
221 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
222
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
223 static PyObject *
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
224 do_mktuple(p_format, p_va, endchar, n)
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
225 char **p_format;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
226 va_list *p_va;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
227 int endchar;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
228 int n;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
229 {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
230 PyObject *v;
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
231 int i;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
232 if (n < 0)
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
233 return NULL;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
234 if ((v = PyTuple_New(n)) == NULL)
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
235 return NULL;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
236 for (i = 0; i < n; i++) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
237 PyObject *w = do_mkvalue(p_format, p_va);
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
238 if (w == NULL) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
239 Py_DECREF(v);
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
240 return NULL;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
241 }
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
242 PyTuple_SetItem(v, i, w);
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
243 }
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
244 if (v != NULL && **p_format != endchar) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
245 Py_DECREF(v);
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
246 v = NULL;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
247 PyErr_SetString(PyExc_SystemError,
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
248 "Unmatched paren in format");
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
249 }
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
250 else if (endchar)
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
251 ++*p_format;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
252 return v;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
253 }
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
254
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
255 static PyObject *
860
39134c99c923 Added parameter decls to do_mkvalue for non-template machines
Guido van Rossum <guido@python.org>
parents: 817
diff changeset
256 do_mkvalue(p_format, p_va)
39134c99c923 Added parameter decls to do_mkvalue for non-template machines
Guido van Rossum <guido@python.org>
parents: 817
diff changeset
257 char **p_format;
39134c99c923 Added parameter decls to do_mkvalue for non-template machines
Guido van Rossum <guido@python.org>
parents: 817
diff changeset
258 va_list *p_va;
39134c99c923 Added parameter decls to do_mkvalue for non-template machines
Guido van Rossum <guido@python.org>
parents: 817
diff changeset
259 {
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
260 for (;;) {
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
261 switch (*(*p_format)++) {
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
262 case '(':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
263 return do_mktuple(p_format, p_va, ')',
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
264 countformat(*p_format, ')'));
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
265
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
266 case '[':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
267 return do_mklist(p_format, p_va, ']',
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
268 countformat(*p_format, ']'));
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
269
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
270 case '{':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
271 return do_mkdict(p_format, p_va, '}',
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
272 countformat(*p_format, '}'));
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
273
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
274 case 'b':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
275 case 'h':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
276 case 'i':
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
277 return PyInt_FromLong((long)va_arg(*p_va, int));
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
278
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
279 case 'l':
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
280 return PyInt_FromLong((long)va_arg(*p_va, long));
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
281
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
282 case 'f':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
283 case 'd':
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
284 return PyFloat_FromDouble(
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
285 (double)va_arg(*p_va, va_double));
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
286
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
287 case 'c':
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
288 {
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
289 char p[1];
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
290 p[0] = va_arg(*p_va, int);
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
291 return PyString_FromStringAndSize(p, 1);
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
292 }
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
293
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
294 case 's':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
295 case 'z':
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
296 {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
297 PyObject *v;
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
298 char *str = va_arg(*p_va, char *);
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
299 int n;
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
300 if (**p_format == '#') {
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
301 ++*p_format;
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
302 n = va_arg(*p_va, int);
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
303 }
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
304 else
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
305 n = -1;
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
306 if (str == NULL) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
307 v = Py_None;
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
308 Py_INCREF(v);
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
309 }
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
310 else {
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
311 if (n < 0)
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
312 n = strlen(str);
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
313 v = PyString_FromStringAndSize(str, n);
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
314 }
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
315 return v;
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
316 }
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
317
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
318 case 'S':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
319 case 'O':
2202
9894e55468ec support "O&" taking an object constructor a void*
Guido van Rossum <guido@python.org>
parents: 2154
diff changeset
320 if (**p_format == '&') {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
321 typedef PyObject *(*converter) Py_PROTO((void *));
2202
9894e55468ec support "O&" taking an object constructor a void*
Guido van Rossum <guido@python.org>
parents: 2154
diff changeset
322 converter func = va_arg(*p_va, converter);
9894e55468ec support "O&" taking an object constructor a void*
Guido van Rossum <guido@python.org>
parents: 2154
diff changeset
323 void *arg = va_arg(*p_va, void *);
9894e55468ec support "O&" taking an object constructor a void*
Guido van Rossum <guido@python.org>
parents: 2154
diff changeset
324 ++*p_format;
9894e55468ec support "O&" taking an object constructor a void*
Guido van Rossum <guido@python.org>
parents: 2154
diff changeset
325 return (*func)(arg);
9894e55468ec support "O&" taking an object constructor a void*
Guido van Rossum <guido@python.org>
parents: 2154
diff changeset
326 }
9894e55468ec support "O&" taking an object constructor a void*
Guido van Rossum <guido@python.org>
parents: 2154
diff changeset
327 else {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
328 PyObject *v;
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
329 v = va_arg(*p_va, PyObject *);
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
330 if (v != NULL)
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
331 Py_INCREF(v);
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
332 else if (!PyErr_Occurred())
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
333 /* If a NULL was passed
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
334 * because a call that should
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
335 * have constructed a value
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
336 * failed, that's OK, and we
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
337 * pass the error on; but if
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
338 * no error occurred it's not
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
339 * clear that the caller knew
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
340 * what she was doing. */
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
341 PyErr_SetString(PyExc_SystemError,
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
342 "NULL object passed to mkvalue");
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
343 return v;
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
344 }
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
345
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
346 case ':':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
347 case ',':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
348 case ' ':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
349 case '\t':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
350 break;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
351
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
352 default:
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
353 PyErr_SetString(PyExc_SystemError,
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
354 "bad format char passed to mkvalue");
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
355 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
356
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
357 }
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
358 }
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
359 }
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
360
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
361
1848
b724599401ff Merge back to main trunk
Guido van Rossum <guido@python.org>
parents: 1319
diff changeset
362 #ifdef HAVE_STDARG_PROTOTYPES
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
363 /* VARARGS 2 */
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
364 PyObject *Py_BuildValue(char *format, ...)
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
365 #else
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
366 /* VARARGS */
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
367 PyObject *Py_BuildValue(va_alist) va_dcl
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
368 #endif
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
369 {
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
370 va_list va;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
371 PyObject* retval;
1848
b724599401ff Merge back to main trunk
Guido van Rossum <guido@python.org>
parents: 1319
diff changeset
372 #ifdef HAVE_STDARG_PROTOTYPES
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
373 va_start(va, format);
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
374 #else
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
375 char *format;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
376 va_start(va);
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
377 format = va_arg(va, char *);
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
378 #endif
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
379 retval = Py_VaBuildValue(format, va);
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
380 va_end(va);
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
381 return retval;
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
382 }
1252
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
383
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
384 PyObject *
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
385 Py_VaBuildValue(format, va)
1252
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
386 char *format;
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
387 va_list va;
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
388 {
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
389 char *f = format;
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
390 int n = countformat(f, '\0');
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
391 va_list lva;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
392
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
393 #ifdef VA_LIST_IS_ARRAY
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
394 memcpy(lva, va, sizeof(va_list));
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
395 #else
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
396 lva = va;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
397 #endif
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
398
1252
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
399 if (n < 0)
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
400 return NULL;
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
401 if (n == 0) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
402 Py_INCREF(Py_None);
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
403 return Py_None;
1252
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
404 }
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
405 if (n == 1)
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
406 return do_mkvalue(&f, &lva);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
407 return do_mktuple(&f, &lva, '\0', n);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
408 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
409
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
410
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
411 #ifdef HAVE_STDARG_PROTOTYPES
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
412 PyObject *
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
413 PyEval_CallFunction(PyObject *obj, char *format, ...)
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
414 #else
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
415 PyObject *
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
416 PyEval_CallFunction(obj, format, va_alist)
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
417 PyObject *obj;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
418 char *format;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
419 va_dcl
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
420 #endif
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
421 {
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
422 va_list vargs;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
423 PyObject *args;
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
424 PyObject *res;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
425
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
426 #ifdef HAVE_STDARG_PROTOTYPES
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
427 va_start(vargs, format);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
428 #else
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
429 va_start(vargs);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
430 #endif
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
431
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
432 args = Py_VaBuildValue(format, vargs);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
433 va_end(vargs);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
434
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
435 if (args == NULL)
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
436 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
437
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
438 res = PyEval_CallObject(obj, args);
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
439 Py_DECREF(args);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
440
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
441 return res;
1252
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
442 }
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
443
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
444
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
445 #ifdef HAVE_STDARG_PROTOTYPES
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
446 PyObject *
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
447 PyEval_CallMethod(PyObject *obj, char *methonname, char *format, ...)
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
448 #else
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
449 PyObject *
2154
0728feb1d031 rename method arg because of typedef conflict
Guido van Rossum <guido@python.org>
parents: 2095
diff changeset
450 PyEval_CallMethod(obj, methonname, format, va_alist)
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
451 PyObject *obj;
2154
0728feb1d031 rename method arg because of typedef conflict
Guido van Rossum <guido@python.org>
parents: 2095
diff changeset
452 char *methonname;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
453 char *format;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
454 va_dcl
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
455 #endif
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
456 {
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
457 va_list vargs;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
458 PyObject *meth;
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
459 PyObject *args;
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
460 PyObject *res;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
461
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
462 meth = PyObject_GetAttrString(obj, methonname);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
463 if (meth == NULL)
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
464 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
465
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
466 #ifdef HAVE_STDARG_PROTOTYPES
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
467 va_start(vargs, format);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
468 #else
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
469 va_start(vargs);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
470 #endif
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
471
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
472 args = Py_VaBuildValue(format, vargs);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
473 va_end(vargs);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
474
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
475 if (args == NULL) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
476 Py_DECREF(meth);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
477 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
478 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
479
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
480 res = PyEval_CallObject(meth, args);
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
481 Py_DECREF(meth);
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
482 Py_DECREF(args);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
483
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
484 return res;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
485 }