comparison Python/modsupport.c @ 13658:f79434ee41fa legacy-trunk

Mass ANSIfication of function definitions. Doesn't cover all 'extern' declarations yet, those come later.
author Thomas Wouters <thomas@python.org>
date Sat, 22 Jul 2000 18:47:25 +0000
parents a89f7f268de4
children 94f6ec87930a
comparison
equal deleted inserted replaced
13657:6a5314a6c2c2 13658:f79434ee41fa
40 static char api_version_warning[] = 40 static char api_version_warning[] =
41 "WARNING: Python C API version mismatch for module %s:\n\ 41 "WARNING: Python C API version mismatch for module %s:\n\
42 This Python has API version %d, module %s has version %d.\n"; 42 This Python has API version %d, module %s has version %d.\n";
43 43
44 PyObject * 44 PyObject *
45 Py_InitModule4(name, methods, doc, passthrough, module_api_version) 45 Py_InitModule4(char *name, PyMethodDef *methods, char *doc,
46 char *name; 46 PyObject *passthrough, int module_api_version)
47 PyMethodDef *methods;
48 char *doc;
49 PyObject *passthrough;
50 int module_api_version;
51 { 47 {
52 PyObject *m, *d, *v; 48 PyObject *m, *d, *v;
53 PyMethodDef *ml; 49 PyMethodDef *ml;
54 if (module_api_version != PYTHON_API_VERSION) 50 if (module_api_version != PYTHON_API_VERSION)
55 fprintf(stderr, api_version_warning, 51 fprintf(stderr, api_version_warning,
82 } 78 }
83 79
84 80
85 /* Helper for mkvalue() to scan the length of a format */ 81 /* Helper for mkvalue() to scan the length of a format */
86 82
87 static int countformat(char *format, int endchar); 83 static int countformat(char *format, int endchar)
88 static int countformat(format, endchar)
89 char *format;
90 int endchar;
91 { 84 {
92 int count = 0; 85 int count = 0;
93 int level = 0; 86 int level = 0;
94 while (level > 0 || *format != endchar) { 87 while (level > 0 || *format != endchar) {
95 switch (*format) { 88 switch (*format) {
135 static PyObject *do_mkdict(char**, va_list *, int, int); 128 static PyObject *do_mkdict(char**, va_list *, int, int);
136 static PyObject *do_mkvalue(char**, va_list *); 129 static PyObject *do_mkvalue(char**, va_list *);
137 130
138 131
139 static PyObject * 132 static PyObject *
140 do_mkdict(p_format, p_va, endchar, n) 133 do_mkdict(char **p_format, va_list *p_va, int endchar, int n)
141 char **p_format;
142 va_list *p_va;
143 int endchar;
144 int n;
145 { 134 {
146 PyObject *d; 135 PyObject *d;
147 int i; 136 int i;
148 if (n < 0) 137 if (n < 0)
149 return NULL; 138 return NULL;
181 ++*p_format; 170 ++*p_format;
182 return d; 171 return d;
183 } 172 }
184 173
185 static PyObject * 174 static PyObject *
186 do_mklist(p_format, p_va, endchar, n) 175 do_mklist(char **p_format, va_list *p_va, int endchar, int n)
187 char **p_format;
188 va_list *p_va;
189 int endchar;
190 int n;
191 { 176 {
192 PyObject *v; 177 PyObject *v;
193 int i; 178 int i;
194 if (n < 0) 179 if (n < 0)
195 return NULL; 180 return NULL;
222 while (*v != 0) { i++; v++; } 207 while (*v != 0) { i++; v++; }
223 return i; 208 return i;
224 } 209 }
225 210
226 static PyObject * 211 static PyObject *
227 do_mktuple(p_format, p_va, endchar, n) 212 do_mktuple(char **p_format, va_list *p_va, int endchar, int n)
228 char **p_format;
229 va_list *p_va;
230 int endchar;
231 int n;
232 { 213 {
233 PyObject *v; 214 PyObject *v;
234 int i; 215 int i;
235 if (n < 0) 216 if (n < 0)
236 return NULL; 217 return NULL;
254 ++*p_format; 235 ++*p_format;
255 return v; 236 return v;
256 } 237 }
257 238
258 static PyObject * 239 static PyObject *
259 do_mkvalue(p_format, p_va) 240 do_mkvalue(char **p_format, va_list *p_va)
260 char **p_format;
261 va_list *p_va;
262 { 241 {
263 for (;;) { 242 for (;;) {
264 switch (*(*p_format)++) { 243 switch (*(*p_format)++) {
265 case '(': 244 case '(':
266 return do_mktuple(p_format, p_va, ')', 245 return do_mktuple(p_format, p_va, ')',
399 } 378 }
400 } 379 }
401 } 380 }
402 381
403 382
404 #ifdef HAVE_STDARG_PROTOTYPES
405 /* VARARGS 2 */
406 PyObject *Py_BuildValue(char *format, ...) 383 PyObject *Py_BuildValue(char *format, ...)
407 #else
408 /* VARARGS */
409 PyObject *Py_BuildValue(va_alist) va_dcl
410 #endif
411 { 384 {
412 va_list va; 385 va_list va;
413 PyObject* retval; 386 PyObject* retval;
414 #ifdef HAVE_STDARG_PROTOTYPES
415 va_start(va, format); 387 va_start(va, format);
416 #else
417 char *format;
418 va_start(va);
419 format = va_arg(va, char *);
420 #endif
421 retval = Py_VaBuildValue(format, va); 388 retval = Py_VaBuildValue(format, va);
422 va_end(va); 389 va_end(va);
423 return retval; 390 return retval;
424 } 391 }
425 392
426 PyObject * 393 PyObject *
427 Py_VaBuildValue(format, va) 394 Py_VaBuildValue(char *format, va_list va)
428 char *format;
429 va_list va;
430 { 395 {
431 char *f = format; 396 char *f = format;
432 int n = countformat(f, '\0'); 397 int n = countformat(f, '\0');
433 va_list lva; 398 va_list lva;
434 399
448 return do_mkvalue(&f, &lva); 413 return do_mkvalue(&f, &lva);
449 return do_mktuple(&f, &lva, '\0', n); 414 return do_mktuple(&f, &lva, '\0', n);
450 } 415 }
451 416
452 417
453 #ifdef HAVE_STDARG_PROTOTYPES
454 PyObject * 418 PyObject *
455 PyEval_CallFunction(PyObject *obj, char *format, ...) 419 PyEval_CallFunction(PyObject *obj, char *format, ...)
456 #else
457 PyObject *
458 PyEval_CallFunction(obj, format, va_alist)
459 PyObject *obj;
460 char *format;
461 va_dcl
462 #endif
463 { 420 {
464 va_list vargs; 421 va_list vargs;
465 PyObject *args; 422 PyObject *args;
466 PyObject *res; 423 PyObject *res;
467 424
468 #ifdef HAVE_STDARG_PROTOTYPES
469 va_start(vargs, format); 425 va_start(vargs, format);
470 #else
471 va_start(vargs);
472 #endif
473 426
474 args = Py_VaBuildValue(format, vargs); 427 args = Py_VaBuildValue(format, vargs);
475 va_end(vargs); 428 va_end(vargs);
476 429
477 if (args == NULL) 430 if (args == NULL)
482 435
483 return res; 436 return res;
484 } 437 }
485 438
486 439
487 #ifdef HAVE_STDARG_PROTOTYPES
488 PyObject * 440 PyObject *
489 PyEval_CallMethod(PyObject *obj, char *methodname, char *format, ...) 441 PyEval_CallMethod(PyObject *obj, char *methodname, char *format, ...)
490 #else
491 PyObject *
492 PyEval_CallMethod(obj, methodname, format, va_alist)
493 PyObject *obj;
494 char *methodname;
495 char *format;
496 va_dcl
497 #endif
498 { 442 {
499 va_list vargs; 443 va_list vargs;
500 PyObject *meth; 444 PyObject *meth;
501 PyObject *args; 445 PyObject *args;
502 PyObject *res; 446 PyObject *res;
503 447
504 meth = PyObject_GetAttrString(obj, methodname); 448 meth = PyObject_GetAttrString(obj, methodname);
505 if (meth == NULL) 449 if (meth == NULL)
506 return NULL; 450 return NULL;
507 451
508 #ifdef HAVE_STDARG_PROTOTYPES
509 va_start(vargs, format); 452 va_start(vargs, format);
510 #else
511 va_start(vargs);
512 #endif
513 453
514 args = Py_VaBuildValue(format, vargs); 454 args = Py_VaBuildValue(format, vargs);
515 va_end(vargs); 455 va_end(vargs);
516 456
517 if (args == NULL) { 457 if (args == NULL) {