Changeset 391 for python/trunk/Mac/Modules/fm
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (12 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
Mac/Modules/fm/_Fmmodule.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Mac/Modules/fm/_Fmmodule.c
r2 r391 3 3 4 4 #include "Python.h" 5 6 #ifndef __LP64__ 5 #include <Carbon/Carbon.h> 6 7 #if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7) 7 8 8 9 … … 11 12 /* Macro to test whether a weak-loaded CFM function exists */ 12 13 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ 13 PyErr_SetString(PyExc_NotImplementedError, \14 "Not available in this shared library/OS version"); \15 return NULL; \14 PyErr_SetString(PyExc_NotImplementedError, \ 15 "Not available in this shared library/OS version"); \ 16 return NULL; \ 16 17 }} while(0) 17 18 18 19 19 #include <Carbon/Carbon.h>20 20 21 21 … … 27 27 { 28 28 29 return Py_BuildValue("O&O&O&O&O&",30 PyMac_BuildFixed, itself->ascent,31 PyMac_BuildFixed, itself->descent,32 PyMac_BuildFixed, itself->leading,33 PyMac_BuildFixed, itself->widMax,34 ResObj_New, itself->wTabHandle);29 return Py_BuildValue("O&O&O&O&O&", 30 PyMac_BuildFixed, itself->ascent, 31 PyMac_BuildFixed, itself->descent, 32 PyMac_BuildFixed, itself->leading, 33 PyMac_BuildFixed, itself->widMax, 34 ResObj_New, itself->wTabHandle); 35 35 } 36 36 … … 40 40 FMRec_Convert(PyObject *v, FMetricRec *p_itself) 41 41 { 42 return PyArg_ParseTuple(v, "O&O&O&O&O&",43 PyMac_GetFixed, &itself->ascent,44 PyMac_GetFixed, &itself->descent,45 PyMac_GetFixed, &itself->leading,46 PyMac_GetFixed, &itself->widMax,47 ResObj_Convert, &itself->wTabHandle);42 return PyArg_ParseTuple(v, "O&O&O&O&O&", 43 PyMac_GetFixed, &itself->ascent, 44 PyMac_GetFixed, &itself->descent, 45 PyMac_GetFixed, &itself->leading, 46 PyMac_GetFixed, &itself->widMax, 47 ResObj_Convert, &itself->wTabHandle); 48 48 } 49 49 #endif … … 54 54 static PyObject *Fm_GetFontName(PyObject *_self, PyObject *_args) 55 55 { 56 PyObject *_res = NULL;57 short familyID;58 Str255 name;56 PyObject *_res = NULL; 57 short familyID; 58 Str255 name; 59 59 #ifndef GetFontName 60 PyMac_PRECHECK(GetFontName);61 #endif 62 if (!PyArg_ParseTuple(_args, "h",63 &familyID))64 return NULL;65 GetFontName(familyID,66 name);67 _res = Py_BuildValue("O&",68 PyMac_BuildStr255, name);69 return _res;60 PyMac_PRECHECK(GetFontName); 61 #endif 62 if (!PyArg_ParseTuple(_args, "h", 63 &familyID)) 64 return NULL; 65 GetFontName(familyID, 66 name); 67 _res = Py_BuildValue("O&", 68 PyMac_BuildStr255, name); 69 return _res; 70 70 } 71 71 72 72 static PyObject *Fm_GetFNum(PyObject *_self, PyObject *_args) 73 73 { 74 PyObject *_res = NULL;75 Str255 name;76 short familyID;74 PyObject *_res = NULL; 75 Str255 name; 76 short familyID; 77 77 #ifndef GetFNum 78 PyMac_PRECHECK(GetFNum);79 #endif 80 if (!PyArg_ParseTuple(_args, "O&",81 PyMac_GetStr255, name))82 return NULL;83 GetFNum(name,84 &familyID);85 _res = Py_BuildValue("h",86 familyID);87 return _res;78 PyMac_PRECHECK(GetFNum); 79 #endif 80 if (!PyArg_ParseTuple(_args, "O&", 81 PyMac_GetStr255, name)) 82 return NULL; 83 GetFNum(name, 84 &familyID); 85 _res = Py_BuildValue("h", 86 familyID); 87 return _res; 88 88 } 89 89 90 90 static PyObject *Fm_RealFont(PyObject *_self, PyObject *_args) 91 91 { 92 PyObject *_res = NULL;93 Boolean _rv;94 short fontNum;95 short size;92 PyObject *_res = NULL; 93 Boolean _rv; 94 short fontNum; 95 short size; 96 96 #ifndef RealFont 97 PyMac_PRECHECK(RealFont);98 #endif 99 if (!PyArg_ParseTuple(_args, "hh",100 &fontNum,101 &size))102 return NULL;103 _rv = RealFont(fontNum,104 size);105 _res = Py_BuildValue("b",106 _rv);107 return _res;97 PyMac_PRECHECK(RealFont); 98 #endif 99 if (!PyArg_ParseTuple(_args, "hh", 100 &fontNum, 101 &size)) 102 return NULL; 103 _rv = RealFont(fontNum, 104 size); 105 _res = Py_BuildValue("b", 106 _rv); 107 return _res; 108 108 } 109 109 110 110 static PyObject *Fm_SetFScaleDisable(PyObject *_self, PyObject *_args) 111 111 { 112 PyObject *_res = NULL;113 Boolean fscaleDisable;112 PyObject *_res = NULL; 113 Boolean fscaleDisable; 114 114 #ifndef SetFScaleDisable 115 PyMac_PRECHECK(SetFScaleDisable);116 #endif 117 if (!PyArg_ParseTuple(_args, "b",118 &fscaleDisable))119 return NULL;120 SetFScaleDisable(fscaleDisable);121 Py_INCREF(Py_None);122 _res = Py_None;123 return _res;115 PyMac_PRECHECK(SetFScaleDisable); 116 #endif 117 if (!PyArg_ParseTuple(_args, "b", 118 &fscaleDisable)) 119 return NULL; 120 SetFScaleDisable(fscaleDisable); 121 Py_INCREF(Py_None); 122 _res = Py_None; 123 return _res; 124 124 } 125 125 126 126 static PyObject *Fm_FontMetrics(PyObject *_self, PyObject *_args) 127 127 { 128 PyObject *_res = NULL;129 FMetricRec theMetrics;128 PyObject *_res = NULL; 129 FMetricRec theMetrics; 130 130 #ifndef FontMetrics 131 PyMac_PRECHECK(FontMetrics);132 #endif 133 if (!PyArg_ParseTuple(_args, ""))134 return NULL;135 FontMetrics(&theMetrics);136 _res = Py_BuildValue("O&",137 FMRec_New, &theMetrics);138 return _res;131 PyMac_PRECHECK(FontMetrics); 132 #endif 133 if (!PyArg_ParseTuple(_args, "")) 134 return NULL; 135 FontMetrics(&theMetrics); 136 _res = Py_BuildValue("O&", 137 FMRec_New, &theMetrics); 138 return _res; 139 139 } 140 140 141 141 static PyObject *Fm_SetFractEnable(PyObject *_self, PyObject *_args) 142 142 { 143 PyObject *_res = NULL;144 Boolean fractEnable;143 PyObject *_res = NULL; 144 Boolean fractEnable; 145 145 #ifndef SetFractEnable 146 PyMac_PRECHECK(SetFractEnable);147 #endif 148 if (!PyArg_ParseTuple(_args, "b",149 &fractEnable))150 return NULL;151 SetFractEnable(fractEnable);152 Py_INCREF(Py_None);153 _res = Py_None;154 return _res;146 PyMac_PRECHECK(SetFractEnable); 147 #endif 148 if (!PyArg_ParseTuple(_args, "b", 149 &fractEnable)) 150 return NULL; 151 SetFractEnable(fractEnable); 152 Py_INCREF(Py_None); 153 _res = Py_None; 154 return _res; 155 155 } 156 156 157 157 static PyObject *Fm_GetDefFontSize(PyObject *_self, PyObject *_args) 158 158 { 159 PyObject *_res = NULL;160 short _rv;159 PyObject *_res = NULL; 160 short _rv; 161 161 #ifndef GetDefFontSize 162 PyMac_PRECHECK(GetDefFontSize);163 #endif 164 if (!PyArg_ParseTuple(_args, ""))165 return NULL;166 _rv = GetDefFontSize();167 _res = Py_BuildValue("h",168 _rv);169 return _res;162 PyMac_PRECHECK(GetDefFontSize); 163 #endif 164 if (!PyArg_ParseTuple(_args, "")) 165 return NULL; 166 _rv = GetDefFontSize(); 167 _res = Py_BuildValue("h", 168 _rv); 169 return _res; 170 170 } 171 171 172 172 static PyObject *Fm_IsOutline(PyObject *_self, PyObject *_args) 173 173 { 174 PyObject *_res = NULL;175 Boolean _rv;176 Point numer;177 Point denom;174 PyObject *_res = NULL; 175 Boolean _rv; 176 Point numer; 177 Point denom; 178 178 #ifndef IsOutline 179 PyMac_PRECHECK(IsOutline);180 #endif 181 if (!PyArg_ParseTuple(_args, "O&O&",182 PyMac_GetPoint, &numer,183 PyMac_GetPoint, &denom))184 return NULL;185 _rv = IsOutline(numer,186 denom);187 _res = Py_BuildValue("b",188 _rv);189 return _res;179 PyMac_PRECHECK(IsOutline); 180 #endif 181 if (!PyArg_ParseTuple(_args, "O&O&", 182 PyMac_GetPoint, &numer, 183 PyMac_GetPoint, &denom)) 184 return NULL; 185 _rv = IsOutline(numer, 186 denom); 187 _res = Py_BuildValue("b", 188 _rv); 189 return _res; 190 190 } 191 191 192 192 static PyObject *Fm_SetOutlinePreferred(PyObject *_self, PyObject *_args) 193 193 { 194 PyObject *_res = NULL;195 Boolean outlinePreferred;194 PyObject *_res = NULL; 195 Boolean outlinePreferred; 196 196 #ifndef SetOutlinePreferred 197 PyMac_PRECHECK(SetOutlinePreferred);198 #endif 199 if (!PyArg_ParseTuple(_args, "b",200 &outlinePreferred))201 return NULL;202 SetOutlinePreferred(outlinePreferred);203 Py_INCREF(Py_None);204 _res = Py_None;205 return _res;197 PyMac_PRECHECK(SetOutlinePreferred); 198 #endif 199 if (!PyArg_ParseTuple(_args, "b", 200 &outlinePreferred)) 201 return NULL; 202 SetOutlinePreferred(outlinePreferred); 203 Py_INCREF(Py_None); 204 _res = Py_None; 205 return _res; 206 206 } 207 207 208 208 static PyObject *Fm_GetOutlinePreferred(PyObject *_self, PyObject *_args) 209 209 { 210 PyObject *_res = NULL;211 Boolean _rv;210 PyObject *_res = NULL; 211 Boolean _rv; 212 212 #ifndef GetOutlinePreferred 213 PyMac_PRECHECK(GetOutlinePreferred);214 #endif 215 if (!PyArg_ParseTuple(_args, ""))216 return NULL;217 _rv = GetOutlinePreferred();218 _res = Py_BuildValue("b",219 _rv);220 return _res;213 PyMac_PRECHECK(GetOutlinePreferred); 214 #endif 215 if (!PyArg_ParseTuple(_args, "")) 216 return NULL; 217 _rv = GetOutlinePreferred(); 218 _res = Py_BuildValue("b", 219 _rv); 220 return _res; 221 221 } 222 222 223 223 static PyObject *Fm_SetPreserveGlyph(PyObject *_self, PyObject *_args) 224 224 { 225 PyObject *_res = NULL;226 Boolean preserveGlyph;225 PyObject *_res = NULL; 226 Boolean preserveGlyph; 227 227 #ifndef SetPreserveGlyph 228 PyMac_PRECHECK(SetPreserveGlyph);229 #endif 230 if (!PyArg_ParseTuple(_args, "b",231 &preserveGlyph))232 return NULL;233 SetPreserveGlyph(preserveGlyph);234 Py_INCREF(Py_None);235 _res = Py_None;236 return _res;228 PyMac_PRECHECK(SetPreserveGlyph); 229 #endif 230 if (!PyArg_ParseTuple(_args, "b", 231 &preserveGlyph)) 232 return NULL; 233 SetPreserveGlyph(preserveGlyph); 234 Py_INCREF(Py_None); 235 _res = Py_None; 236 return _res; 237 237 } 238 238 239 239 static PyObject *Fm_GetPreserveGlyph(PyObject *_self, PyObject *_args) 240 240 { 241 PyObject *_res = NULL;242 Boolean _rv;241 PyObject *_res = NULL; 242 Boolean _rv; 243 243 #ifndef GetPreserveGlyph 244 PyMac_PRECHECK(GetPreserveGlyph);245 #endif 246 if (!PyArg_ParseTuple(_args, ""))247 return NULL;248 _rv = GetPreserveGlyph();249 _res = Py_BuildValue("b",250 _rv);251 return _res;244 PyMac_PRECHECK(GetPreserveGlyph); 245 #endif 246 if (!PyArg_ParseTuple(_args, "")) 247 return NULL; 248 _rv = GetPreserveGlyph(); 249 _res = Py_BuildValue("b", 250 _rv); 251 return _res; 252 252 } 253 253 254 254 static PyObject *Fm_GetSysFont(PyObject *_self, PyObject *_args) 255 255 { 256 PyObject *_res = NULL;257 short _rv;256 PyObject *_res = NULL; 257 short _rv; 258 258 #ifndef GetSysFont 259 PyMac_PRECHECK(GetSysFont);260 #endif 261 if (!PyArg_ParseTuple(_args, ""))262 return NULL;263 _rv = GetSysFont();264 _res = Py_BuildValue("h",265 _rv);266 return _res;259 PyMac_PRECHECK(GetSysFont); 260 #endif 261 if (!PyArg_ParseTuple(_args, "")) 262 return NULL; 263 _rv = GetSysFont(); 264 _res = Py_BuildValue("h", 265 _rv); 266 return _res; 267 267 } 268 268 269 269 static PyObject *Fm_GetAppFont(PyObject *_self, PyObject *_args) 270 270 { 271 PyObject *_res = NULL;272 short _rv;271 PyObject *_res = NULL; 272 short _rv; 273 273 #ifndef GetAppFont 274 PyMac_PRECHECK(GetAppFont);275 #endif 276 if (!PyArg_ParseTuple(_args, ""))277 return NULL;278 _rv = GetAppFont();279 _res = Py_BuildValue("h",280 _rv);281 return _res;274 PyMac_PRECHECK(GetAppFont); 275 #endif 276 if (!PyArg_ParseTuple(_args, "")) 277 return NULL; 278 _rv = GetAppFont(); 279 _res = Py_BuildValue("h", 280 _rv); 281 return _res; 282 282 } 283 283 284 284 static PyObject *Fm_QDTextBounds(PyObject *_self, PyObject *_args) 285 285 { 286 PyObject *_res = NULL;287 char *inText__in__;288 int inText__len__;289 int inText__in_len__;290 Rect bounds;286 PyObject *_res = NULL; 287 char *inText__in__; 288 int inText__len__; 289 int inText__in_len__; 290 Rect bounds; 291 291 #ifndef QDTextBounds 292 PyMac_PRECHECK(QDTextBounds);293 #endif 294 if (!PyArg_ParseTuple(_args, "s#",295 &inText__in__, &inText__in_len__))296 return NULL;297 inText__len__ = inText__in_len__;298 QDTextBounds(inText__len__, inText__in__,299 &bounds);300 _res = Py_BuildValue("O&",301 PyMac_BuildRect, &bounds);302 return _res;292 PyMac_PRECHECK(QDTextBounds); 293 #endif 294 if (!PyArg_ParseTuple(_args, "s#", 295 &inText__in__, &inText__in_len__)) 296 return NULL; 297 inText__len__ = inText__in_len__; 298 QDTextBounds(inText__len__, inText__in__, 299 &bounds); 300 _res = Py_BuildValue("O&", 301 PyMac_BuildRect, &bounds); 302 return _res; 303 303 } 304 304 305 305 static PyMethodDef Fm_methods[] = { 306 {"GetFontName", (PyCFunction)Fm_GetFontName, 1,307 PyDoc_STR("(short familyID) -> (Str255 name)")},308 {"GetFNum", (PyCFunction)Fm_GetFNum, 1,309 PyDoc_STR("(Str255 name) -> (short familyID)")},310 {"RealFont", (PyCFunction)Fm_RealFont, 1,311 PyDoc_STR("(short fontNum, short size) -> (Boolean _rv)")},312 {"SetFScaleDisable", (PyCFunction)Fm_SetFScaleDisable, 1,313 PyDoc_STR("(Boolean fscaleDisable) -> None")},314 {"FontMetrics", (PyCFunction)Fm_FontMetrics, 1,315 PyDoc_STR("() -> (FMetricRec theMetrics)")},316 {"SetFractEnable", (PyCFunction)Fm_SetFractEnable, 1,317 PyDoc_STR("(Boolean fractEnable) -> None")},318 {"GetDefFontSize", (PyCFunction)Fm_GetDefFontSize, 1,319 PyDoc_STR("() -> (short _rv)")},320 {"IsOutline", (PyCFunction)Fm_IsOutline, 1,321 PyDoc_STR("(Point numer, Point denom) -> (Boolean _rv)")},322 {"SetOutlinePreferred", (PyCFunction)Fm_SetOutlinePreferred, 1,323 PyDoc_STR("(Boolean outlinePreferred) -> None")},324 {"GetOutlinePreferred", (PyCFunction)Fm_GetOutlinePreferred, 1,325 PyDoc_STR("() -> (Boolean _rv)")},326 {"SetPreserveGlyph", (PyCFunction)Fm_SetPreserveGlyph, 1,327 PyDoc_STR("(Boolean preserveGlyph) -> None")},328 {"GetPreserveGlyph", (PyCFunction)Fm_GetPreserveGlyph, 1,329 PyDoc_STR("() -> (Boolean _rv)")},330 {"GetSysFont", (PyCFunction)Fm_GetSysFont, 1,331 PyDoc_STR("() -> (short _rv)")},332 {"GetAppFont", (PyCFunction)Fm_GetAppFont, 1,333 PyDoc_STR("() -> (short _rv)")},334 {"QDTextBounds", (PyCFunction)Fm_QDTextBounds, 1,335 PyDoc_STR("(Buffer inText) -> (Rect bounds)")},336 {NULL, NULL, 0}306 {"GetFontName", (PyCFunction)Fm_GetFontName, 1, 307 PyDoc_STR("(short familyID) -> (Str255 name)")}, 308 {"GetFNum", (PyCFunction)Fm_GetFNum, 1, 309 PyDoc_STR("(Str255 name) -> (short familyID)")}, 310 {"RealFont", (PyCFunction)Fm_RealFont, 1, 311 PyDoc_STR("(short fontNum, short size) -> (Boolean _rv)")}, 312 {"SetFScaleDisable", (PyCFunction)Fm_SetFScaleDisable, 1, 313 PyDoc_STR("(Boolean fscaleDisable) -> None")}, 314 {"FontMetrics", (PyCFunction)Fm_FontMetrics, 1, 315 PyDoc_STR("() -> (FMetricRec theMetrics)")}, 316 {"SetFractEnable", (PyCFunction)Fm_SetFractEnable, 1, 317 PyDoc_STR("(Boolean fractEnable) -> None")}, 318 {"GetDefFontSize", (PyCFunction)Fm_GetDefFontSize, 1, 319 PyDoc_STR("() -> (short _rv)")}, 320 {"IsOutline", (PyCFunction)Fm_IsOutline, 1, 321 PyDoc_STR("(Point numer, Point denom) -> (Boolean _rv)")}, 322 {"SetOutlinePreferred", (PyCFunction)Fm_SetOutlinePreferred, 1, 323 PyDoc_STR("(Boolean outlinePreferred) -> None")}, 324 {"GetOutlinePreferred", (PyCFunction)Fm_GetOutlinePreferred, 1, 325 PyDoc_STR("() -> (Boolean _rv)")}, 326 {"SetPreserveGlyph", (PyCFunction)Fm_SetPreserveGlyph, 1, 327 PyDoc_STR("(Boolean preserveGlyph) -> None")}, 328 {"GetPreserveGlyph", (PyCFunction)Fm_GetPreserveGlyph, 1, 329 PyDoc_STR("() -> (Boolean _rv)")}, 330 {"GetSysFont", (PyCFunction)Fm_GetSysFont, 1, 331 PyDoc_STR("() -> (short _rv)")}, 332 {"GetAppFont", (PyCFunction)Fm_GetAppFont, 1, 333 PyDoc_STR("() -> (short _rv)")}, 334 {"QDTextBounds", (PyCFunction)Fm_QDTextBounds, 1, 335 PyDoc_STR("(Buffer inText) -> (Rect bounds)")}, 336 {NULL, NULL, 0} 337 337 }; 338 338 … … 340 340 341 341 static PyMethodDef Fm_methods[] = { 342 {NULL, NULL, 0}342 {NULL, NULL, 0} 343 343 }; 344 344 … … 347 347 void init_Fm(void) 348 348 { 349 PyObject *m;350 #if ndef __LP64__351 PyObject *d;349 PyObject *m; 350 #if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7) 351 PyObject *d; 352 352 #endif /* __LP64__ */ 353 353 … … 355 355 356 356 357 m = Py_InitModule("_Fm", Fm_methods);358 #if ndef __LP64__359 d = PyModule_GetDict(m);360 Fm_Error = PyMac_GetOSErrException();361 if (Fm_Error == NULL ||362 PyDict_SetItemString(d, "Error", Fm_Error) != 0)363 return;357 m = Py_InitModule("_Fm", Fm_methods); 358 #if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7) 359 d = PyModule_GetDict(m); 360 Fm_Error = PyMac_GetOSErrException(); 361 if (Fm_Error == NULL || 362 PyDict_SetItemString(d, "Error", Fm_Error) != 0) 363 return; 364 364 #endif /* __LP64__ */ 365 365 }
Note:
See TracChangeset
for help on using the changeset viewer.
