Mercurial > cpython-lru_cache-weakref
annotate Modules/fmmodule.c @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | 52294af4b663 |
| children | fd25030223b0 |
| 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 { | |
|
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
|
14 PyObject_HEAD |
| 164 | 15 fmfonthandle fh_fh; |
| 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 |
| 20 #define is_fhobject(v) ((v)->ob_type == &Fhtype) | |
| 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 { |
| 25 fhobject *fhp; | |
| 26 if (fh == NULL) { | |
|
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
|
27 PyErr_SetString(PyExc_RuntimeError, |
|
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
|
28 "error creating new font handle"); |
| 164 | 29 return NULL; |
| 30 } | |
|
12576
1c7c2dd1beb1
Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents:
4985
diff
changeset
|
31 fhp = PyObject_New(fhobject, &Fhtype); |
| 164 | 32 if (fhp == NULL) |
| 33 return NULL; | |
| 34 fhp->fh_fh = fh; | |
|
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
|
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 { |
| 43 double size; | |
|
38478
58e99f2a64ec
Convert fmmodule to METH_VARARGS.
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
44 if (!PyArg_ParseTuple(args, "d", &size)) |
| 164 | 45 return NULL; |
| 46 return newfhobject(fmscalefont(self->fh_fh, size)); | |
| 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 { |
| 54 fmsetfont(self->fh_fh); | |
|
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
|
55 Py_INCREF(Py_None); |
|
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
|
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 { |
| 62 char fontname[256]; | |
| 63 int len; | |
| 64 len = fmgetfontname(self->fh_fh, sizeof fontname, fontname); | |
| 65 if (len < 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
|
66 PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontname"); |
| 164 | 67 return NULL; |
| 68 } | |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
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 { |
| 75 char comment[256]; | |
| 76 int len; | |
| 77 len = fmgetcomment(self->fh_fh, sizeof comment, comment); | |
| 78 if (len < 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
|
79 PyErr_SetString(PyExc_RuntimeError, "error in fmgetcomment"); |
| 164 | 80 return NULL; |
| 81 } | |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
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 { |
| 88 fmfontinfo info; | |
| 89 if (fmgetfontinfo(self->fh_fh, &info) < 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
|
90 PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontinfo"); |
| 164 | 91 return NULL; |
| 92 } | |
|
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
|
93 return Py_BuildValue("(llllllll)", |
|
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
|
94 info.printermatched, |
|
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
|
95 info.fixed_width, |
|
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
|
96 info.xorig, |
|
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
|
97 info.yorig, |
|
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
|
98 info.xsize, |
|
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
|
99 info.ysize, |
|
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
|
100 info.height, |
|
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
|
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 { |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
164
diff
changeset
|
114 char *str; |
|
38478
58e99f2a64ec
Convert fmmodule to METH_VARARGS.
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
115 if (!PyArg_ParseTuple(args, "s", &str)) |
| 164 | 116 return NULL; |
|
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
|
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[] = { |
|
38478
58e99f2a64ec
Convert fmmodule to METH_VARARGS.
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
121 {"scalefont", (PyCFunction)fh_scalefont, METH_VARARGS}, |
|
22708
aea6dfeaaab8
Convert from using METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
122 {"setfont", (PyCFunction)fh_setfont, METH_NOARGS}, |
|
aea6dfeaaab8
Convert from using METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
123 {"getfontname", (PyCFunction)fh_getfontname, METH_NOARGS}, |
|
aea6dfeaaab8
Convert from using METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
124 {"getcomment", (PyCFunction)fh_getcomment, METH_NOARGS}, |
|
aea6dfeaaab8
Convert from using METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
125 {"getfontinfo", (PyCFunction)fh_getfontinfo, METH_NOARGS}, |
| 164 | 126 #if 0 |
|
38478
58e99f2a64ec
Convert fmmodule to METH_VARARGS.
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
127 {"getwholemetrics", (PyCFunction)fh_getwholemetrics, METH_VARARGS}, |
| 164 | 128 #endif |
|
38478
58e99f2a64ec
Convert fmmodule to METH_VARARGS.
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
129 {"getstrwidth", (PyCFunction)fh_getstrwidth, METH_VARARGS}, |
| 164 | 130 {NULL, NULL} /* sentinel */ |
| 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 { |
|
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
|
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 { |
| 142 fmfreefont(fhp->fh_fh); | |
|
12576
1c7c2dd1beb1
Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents:
4985
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 = { |
|
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
|
147 PyObject_HEAD_INIT(&PyType_Type) |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
148 0, /*ob_size*/ |
|
21313
91dd223829c6
Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
149 "fm.font handle", /*tp_name*/ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
150 sizeof(fhobject), /*tp_size*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
151 0, /*tp_itemsize*/ |
| 164 | 152 /* methods */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
153 (destructor)fh_dealloc, /*tp_dealloc*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
154 0, /*tp_print*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
155 (getattrfunc)fh_getattr, /*tp_getattr*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
156 0, /*tp_setattr*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
157 0, /*tp_compare*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
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 { |
| 167 fminit(); | |
|
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
|
168 Py_INCREF(Py_None); |
|
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
|
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 { |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
164
diff
changeset
|
175 char *str; |
|
38478
58e99f2a64ec
Convert fmmodule to METH_VARARGS.
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
176 if (!PyArg_ParseTuple(args, "s", &str)) |
| 164 | 177 return NULL; |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
164
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 { |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
164
diff
changeset
|
184 char *str; |
|
38478
58e99f2a64ec
Convert fmmodule to METH_VARARGS.
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
185 if (!PyArg_ParseTuple(args, "s", &str)) |
| 164 | 186 return NULL; |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
164
diff
changeset
|
187 fmprstr(str); |
|
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
|
188 Py_INCREF(Py_None); |
|
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
|
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 { |
| 199 int err; | |
|
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
|
200 PyObject *v; |
| 164 | 201 if (fontlist == NULL) |
| 202 return; | |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
203 v = PyString_FromString(fontname); |
| 164 | 204 if (v == NULL) |
| 205 err = -1; | |
| 206 else { | |
|
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
|
207 err = PyList_Append(fontlist, v); |
|
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
|
208 Py_DECREF(v); |
| 164 | 209 } |
| 210 if (err != 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
|
211 Py_DECREF(fontlist); |
| 164 | 212 fontlist = NULL; |
| 213 } | |
| 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 { |
|
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
|
219 PyObject *res; |
|
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
|
220 fontlist = PyList_New(0); |
| 164 | 221 if (fontlist == NULL) |
| 222 return NULL; | |
| 223 fmenumerate(clientproc); | |
| 224 res = fontlist; | |
| 225 fontlist = NULL; | |
| 226 return res; | |
| 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 { |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
164
diff
changeset
|
232 char *str; |
|
38478
58e99f2a64ec
Convert fmmodule to METH_VARARGS.
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
233 if (!PyArg_ParseTuple(args, "s", &str)) |
| 164 | 234 return NULL; |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
164
diff
changeset
|
235 fmsetpath(str); |
|
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
|
236 Py_INCREF(Py_None); |
|
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
|
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 { |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
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[] = { |
|
22708
aea6dfeaaab8
Convert from using METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
247 {"init", fm_init, METH_NOARGS}, |
|
38478
58e99f2a64ec
Convert fmmodule to METH_VARARGS.
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
248 {"findfont", fm_findfont, METH_VARARGS}, |
|
22708
aea6dfeaaab8
Convert from using METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
249 {"enumerate", fm_enumerate, METH_NOARGS}, |
|
38478
58e99f2a64ec
Convert fmmodule to METH_VARARGS.
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
250 {"prstr", fm_prstr, METH_VARARGS}, |
|
58e99f2a64ec
Convert fmmodule to METH_VARARGS.
Georg Brandl <georg@python.org>
parents:
36324
diff
changeset
|
251 {"setpath", fm_setpath, METH_VARARGS}, |
|
22708
aea6dfeaaab8
Convert from using METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
252 {"fontpath", fm_fontpath, METH_NOARGS}, |
| 164 | 253 {NULL, NULL} /* sentinel */ |
| 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 { |
|
47025
62d9ec9c9efd
Deprecated 'fm' for removal in 3.0.
Brett Cannon <bcannon@gmail.com>
parents:
38478
diff
changeset
|
260 |
|
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) |
|
62d9ec9c9efd
Deprecated 'fm' for removal in 3.0.
Brett Cannon <bcannon@gmail.com>
parents:
38478
diff
changeset
|
263 return; |
|
62d9ec9c9efd
Deprecated 'fm' for removal in 3.0.
Brett Cannon <bcannon@gmail.com>
parents:
38478
diff
changeset
|
264 |
|
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
|
265 Py_InitModule("fm", fm_methods); |
|
36324
1af7f719ed28
Check return result from Py_InitModule*(). This API can fail.
Neal Norwitz <nnorwitz@gmail.com>
parents:
24280
diff
changeset
|
266 if (m == NULL) |
|
1af7f719ed28
Check return result from Py_InitModule*(). This API can fail.
Neal Norwitz <nnorwitz@gmail.com>
parents:
24280
diff
changeset
|
267 return; |
| 164 | 268 fminit(); |
| 269 } |
