annotate PC/example_nt/example.c @ 9383:2b34461ba4a3 legacy-trunk

PyMapping_SetItemString() returns int, not an object.
author Guido van Rossum <guido@python.org>
date Fri, 16 Oct 1998 17:43:53 +0000
parents 180c1d3dac41
children a1ce07218781
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4223
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 #include "Python.h"
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 static PyObject *
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 ex_foo(self, args)
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 PyObject *self, *args;
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 {
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 printf("Hello, world\n");
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 Py_INCREF(Py_None);
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 return Py_None;
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 }
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 static PyMethodDef example_methods[] = {
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 {"foo", ex_foo, 1, "foo() doc string"},
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 {NULL, NULL}
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 };
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
16
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 void
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 initexample()
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 {
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 Py_InitModule("example", example_methods);
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 }