Changeset 391 for python/trunk/Mac/Modules/fm
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
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 14 15 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 30 31 32 33 34 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 43 44 45 46 47 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 57 58 56 PyObject *_res = NULL; 57 short familyID; 58 Str255 name; 59 59 #ifndef GetFontName 60 61 #endif 62 63 64 65 66 67 68 69 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 75 76 74 PyObject *_res = NULL; 75 Str255 name; 76 short familyID; 77 77 #ifndef GetFNum 78 79 #endif 80 81 82 83 84 85 86 87 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 93 94 95 92 PyObject *_res = NULL; 93 Boolean _rv; 94 short fontNum; 95 short size; 96 96 #ifndef RealFont 97 98 #endif 99 100 101 102 103 104 105 106 107 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 113 112 PyObject *_res = NULL; 113 Boolean fscaleDisable; 114 114 #ifndef SetFScaleDisable 115 116 #endif 117 118 119 120 121 122 123 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 129 128 PyObject *_res = NULL; 129 FMetricRec theMetrics; 130 130 #ifndef FontMetrics 131 132 #endif 133 134 135 136 137 138 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 144 143 PyObject *_res = NULL; 144 Boolean fractEnable; 145 145 #ifndef SetFractEnable 146 147 #endif 148 149 150 151 152 153 154 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 160 159 PyObject *_res = NULL; 160 short _rv; 161 161 #ifndef GetDefFontSize 162 163 #endif 164 165 166 167 168 169 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 175 176 177 174 PyObject *_res = NULL; 175 Boolean _rv; 176 Point numer; 177 Point denom; 178 178 #ifndef IsOutline 179 180 #endif 181 182 183 184 185 186 187 188 189 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 195 194 PyObject *_res = NULL; 195 Boolean outlinePreferred; 196 196 #ifndef SetOutlinePreferred 197 198 #endif 199 200 201 202 203 204 205 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 211 210 PyObject *_res = NULL; 211 Boolean _rv; 212 212 #ifndef GetOutlinePreferred 213 214 #endif 215 216 217 218 219 220 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 226 225 PyObject *_res = NULL; 226 Boolean preserveGlyph; 227 227 #ifndef SetPreserveGlyph 228 229 #endif 230 231 232 233 234 235 236 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 242 241 PyObject *_res = NULL; 242 Boolean _rv; 243 243 #ifndef GetPreserveGlyph 244 245 #endif 246 247 248 249 250 251 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 257 256 PyObject *_res = NULL; 257 short _rv; 258 258 #ifndef GetSysFont 259 260 #endif 261 262 263 264 265 266 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 272 271 PyObject *_res = NULL; 272 short _rv; 273 273 #ifndef GetAppFont 274 275 #endif 276 277 278 279 280 281 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 287 288 289 290 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 293 #endif 294 295 296 297 298 299 300 301 302 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 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 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 342 {NULL, NULL, 0} 343 343 }; 344 344 … … 347 347 void init_Fm(void) 348 348 { 349 350 #if ndef __LP64__351 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 358 #if ndef __LP64__359 360 361 362 363 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.