Mercurial > cpython-lru_cache-weakref
annotate Modules/fmmodule.c @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | fd25030223b0 |
| children |
| rev | line source |
|---|---|
| 164 | 1 |
| 2 /* Font Manager module */ | |
| 3 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
4 #include "Python.h" |
| 164 | 5 |
| 6 #include <gl.h> | |
| 7 #include <device.h> | |
| 8 #include <fmclient.h> | |
| 9 | |
| 10 | |
| 11 /* Font Handle object implementation */ | |
| 12 | |
| 13 typedef struct { | |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
14 PyObject_HEAD |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
15 fmfonthandle fh_fh; |
| 164 | 16 } fhobject; |
| 17 | |
|
24280
1598a1e473e2
staticforward bites the dust.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
22708
diff
changeset
|
18 static PyTypeObject Fhtype; |
| 164 | 19 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
20 #define is_fhobject(v) ((v)->ob_type == &Fhtype) |
| 164 | 21 |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
22 static PyObject * |
|
13514
5304b88fe3cc
ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
23 newfhobject(fmfonthandle fh) |
| 164 | 24 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
25 fhobject *fhp; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
26 if (fh == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
27 PyErr_SetString(PyExc_RuntimeError, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
28 "error creating new font handle"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
29 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
30 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
31 fhp = PyObject_New(fhobject, &Fhtype); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
32 if (fhp == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
33 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
34 fhp->fh_fh = fh; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
35 return (PyObject *)fhp; |
| 164 | 36 } |
| 37 | |
| 38 /* Font Handle methods */ | |
| 39 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
40 static PyObject * |
|
13514
5304b88fe3cc
ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
41 fh_scalefont(fhobject *self, PyObject *args) |
| 164 | 42 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
43 double size; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
44 if (!PyArg_ParseTuple(args, "d", &size)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
45 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
46 return newfhobject(fmscalefont(self->fh_fh, size)); |
| 164 | 47 } |
| 48 | |
| 49 /* XXX fmmakefont */ | |
| 50 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
51 static PyObject * |
|
22708
aea6dfeaaab8
Convert from using METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
52 fh_setfont(fhobject *self) |
| 164 | 53 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
54 fmsetfont(self->fh_fh); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
55 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
56 return Py_None; |
| 164 | 57 } |
| 58 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
59 static PyObject * |
|
22708
aea6dfeaaab8
Convert from using METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
60 fh_getfontname(fhobject *self) |
| 164 | 61 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
62 char fontname[256]; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
63 int len; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
64 len = fmgetfontname(self->fh_fh, sizeof fontname, fontname); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
65 if (len < 0) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
66 PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontname"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
67 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
68 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
69 return PyString_FromStringAndSize(fontname, len); |
| 164 | 70 } |
| 71 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
72 static PyObject * |
|
22708
aea6dfeaaab8
Convert from using METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
73 fh_getcomment(fhobject *self) |
| 164 | 74 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
75 char comment[256]; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
76 int len; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
77 len = fmgetcomment(self->fh_fh, sizeof comment, comment); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
78 if (len < 0) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
79 PyErr_SetString(PyExc_RuntimeError, "error in fmgetcomment"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
80 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
81 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
82 return PyString_FromStringAndSize(comment, len); |
| 164 | 83 } |
| 84 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
85 static PyObject * |
|
22708
aea6dfeaaab8
Convert from using METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
86 fh_getfontinfo(fhobject *self) |
| 164 | 87 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
88 fmfontinfo info; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
89 if (fmgetfontinfo(self->fh_fh, &info) < 0) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
90 PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontinfo"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
91 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
92 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
93 return Py_BuildValue("(llllllll)", |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
94 info.printermatched, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
95 info.fixed_width, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
96 info.xorig, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
97 info.yorig, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
98 info.xsize, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
99 info.ysize, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
100 info.height, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
101 info.nglyphs); |
| 164 | 102 } |
| 103 | |
| 104 #if 0 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
105 static PyObject * |
|
13514
5304b88fe3cc
ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
106 fh_getwholemetrics(fhobject *self, PyObject *args) |
| 164 | 107 { |
| 108 } | |
| 109 #endif | |
| 110 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
111 static PyObject * |
|
13514
5304b88fe3cc
ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
112 fh_getstrwidth(fhobject *self, PyObject *args) |
| 164 | 113 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
114 char *str; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
115 if (!PyArg_ParseTuple(args, "s", &str)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
116 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
117 return PyInt_FromLong(fmgetstrwidth(self->fh_fh, str)); |
| 164 | 118 } |
| 119 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
120 static PyMethodDef fh_methods[] = { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
121 {"scalefont", (PyCFunction)fh_scalefont, METH_VARARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
122 {"setfont", (PyCFunction)fh_setfont, METH_NOARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
123 {"getfontname", (PyCFunction)fh_getfontname, METH_NOARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
124 {"getcomment", (PyCFunction)fh_getcomment, METH_NOARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
125 {"getfontinfo", (PyCFunction)fh_getfontinfo, METH_NOARGS}, |
| 164 | 126 #if 0 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
127 {"getwholemetrics", (PyCFunction)fh_getwholemetrics, METH_VARARGS}, |
| 164 | 128 #endif |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
129 {"getstrwidth", (PyCFunction)fh_getstrwidth, METH_VARARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
130 {NULL, NULL} /* sentinel */ |
| 164 | 131 }; |
| 132 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
133 static PyObject * |
|
13514
5304b88fe3cc
ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
134 fh_getattr(fhobject *fhp, char *name) |
| 164 | 135 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
136 return Py_FindMethod(fh_methods, (PyObject *)fhp, name); |
| 164 | 137 } |
| 138 | |
| 139 static void | |
|
13514
5304b88fe3cc
ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
140 fh_dealloc(fhobject *fhp) |
| 164 | 141 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
142 fmfreefont(fhp->fh_fh); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
143 PyObject_Del(fhp); |
| 164 | 144 } |
| 145 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
146 static PyTypeObject Fhtype = { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
147 PyObject_HEAD_INIT(&PyType_Type) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
148 0, /*ob_size*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
149 "fm.font handle", /*tp_name*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
150 sizeof(fhobject), /*tp_size*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
151 0, /*tp_itemsize*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
152 /* methods */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
153 (destructor)fh_dealloc, /*tp_dealloc*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
154 0, /*tp_print*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
155 (getattrfunc)fh_getattr, /*tp_getattr*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
156 0, /*tp_setattr*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
157 0, /*tp_compare*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
158 0, /*tp_repr*/ |
| 164 | 159 }; |
| 160 | |
| 161 | |
| 162 /* Font Manager functions */ | |
| 163 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
164 static PyObject * |
|
22708
aea6dfeaaab8
Convert from using METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
165 fm_init(PyObject *self) |
| 164 | 166 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
167 fminit(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
168 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
169 return Py_None; |
| 164 | 170 } |
| 171 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
172 static PyObject * |
|
13572
e417d9528fd6
Fixed up some ANSIfications.
Sjoerd Mullender <sjoerd@acm.org>
parents:
13514
diff
changeset
|
173 fm_findfont(PyObject *self, PyObject *args) |
| 164 | 174 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
175 char *str; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
176 if (!PyArg_ParseTuple(args, "s", &str)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
177 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
178 return newfhobject(fmfindfont(str)); |
| 164 | 179 } |
| 180 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
181 static PyObject * |
|
13572
e417d9528fd6
Fixed up some ANSIfications.
Sjoerd Mullender <sjoerd@acm.org>
parents:
13514
diff
changeset
|
182 fm_prstr(PyObject *self, PyObject *args) |
| 164 | 183 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
184 char *str; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
185 if (!PyArg_ParseTuple(args, "s", &str)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
186 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
187 fmprstr(str); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
188 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
189 return Py_None; |
| 164 | 190 } |
| 191 | |
| 192 /* XXX This uses a global variable as temporary! Not re-entrant! */ | |
| 193 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
194 static PyObject *fontlist; |
| 164 | 195 |
| 196 static void | |
|
13514
5304b88fe3cc
ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
197 clientproc(char *fontname) |
| 164 | 198 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
199 int err; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
200 PyObject *v; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
201 if (fontlist == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
202 return; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
203 v = PyString_FromString(fontname); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
204 if (v == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
205 err = -1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
206 else { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
207 err = PyList_Append(fontlist, v); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
208 Py_DECREF(v); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
209 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
210 if (err != 0) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
211 Py_DECREF(fontlist); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
212 fontlist = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
213 } |
| 164 | 214 } |
| 215 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
216 static PyObject * |
|
22708
aea6dfeaaab8
Convert from using METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
217 fm_enumerate(PyObject *self) |
| 164 | 218 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
219 PyObject *res; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
220 fontlist = PyList_New(0); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
221 if (fontlist == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
222 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
223 fmenumerate(clientproc); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
224 res = fontlist; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
225 fontlist = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
226 return res; |
| 164 | 227 } |
| 228 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
229 static PyObject * |
|
13514
5304b88fe3cc
ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
230 fm_setpath(PyObject *self, PyObject *args) |
| 164 | 231 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
232 char *str; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
233 if (!PyArg_ParseTuple(args, "s", &str)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
234 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
235 fmsetpath(str); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
236 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
237 return Py_None; |
| 164 | 238 } |
| 239 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
240 static PyObject * |
|
22708
aea6dfeaaab8
Convert from using METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
241 fm_fontpath(PyObject *self) |
| 164 | 242 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
243 return PyString_FromString(fmfontpath()); |
| 164 | 244 } |
| 245 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
246 static PyMethodDef fm_methods[] = { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
247 {"init", fm_init, METH_NOARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
248 {"findfont", fm_findfont, METH_VARARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
249 {"enumerate", fm_enumerate, METH_NOARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
250 {"prstr", fm_prstr, METH_VARARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
251 {"setpath", fm_setpath, METH_VARARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
252 {"fontpath", fm_fontpath, METH_NOARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
253 {NULL, NULL} /* sentinel */ |
| 164 | 254 }; |
| 255 | |
| 256 | |
| 257 void | |
|
13651
8a063423e0b7
Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents:
13572
diff
changeset
|
258 initfm(void) |
| 164 | 259 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
260 |
|
47025
62d9ec9c9efd
Deprecated 'fm' for removal in 3.0.
Brett Cannon <bcannon@gmail.com>
parents:
38478
diff
changeset
|
261 if (PyErr_WarnPy3k("the fm module has been removed in " |
|
62d9ec9c9efd
Deprecated 'fm' for removal in 3.0.
Brett Cannon <bcannon@gmail.com>
parents:
38478
diff
changeset
|
262 "Python 3.0", 2) < 0) |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
263 return; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
264 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
265 Py_InitModule("fm", fm_methods); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
266 if (m == NULL) |
|
47025
62d9ec9c9efd
Deprecated 'fm' for removal in 3.0.
Brett Cannon <bcannon@gmail.com>
parents:
38478
diff
changeset
|
267 return; |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
268 fminit(); |
| 164 | 269 } |
