Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Mac/Modules/fm/_Fmmodule.c

    r2 r391  
    33
    44#include "Python.h"
    5 
    6 #ifndef __LP64__
     5#include <Carbon/Carbon.h>
     6
     7#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7)
    78
    89
     
    1112/* Macro to test whether a weak-loaded CFM function exists */
    1213#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; \
    1617    }} while(0)
    1718
    1819
    19 #include <Carbon/Carbon.h>
    2020
    2121
     
    2727{
    2828
    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);
    3535}
    3636
     
    4040FMRec_Convert(PyObject *v, FMetricRec *p_itself)
    4141{
    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);
    4848}
    4949#endif
     
    5454static PyObject *Fm_GetFontName(PyObject *_self, PyObject *_args)
    5555{
    56         PyObject *_res = NULL;
    57         short familyID;
    58         Str255 name;
     56    PyObject *_res = NULL;
     57    short familyID;
     58    Str255 name;
    5959#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;
    7070}
    7171
    7272static PyObject *Fm_GetFNum(PyObject *_self, PyObject *_args)
    7373{
    74         PyObject *_res = NULL;
    75         Str255 name;
    76         short familyID;
     74    PyObject *_res = NULL;
     75    Str255 name;
     76    short familyID;
    7777#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;
    8888}
    8989
    9090static PyObject *Fm_RealFont(PyObject *_self, PyObject *_args)
    9191{
    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;
    9696#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;
    108108}
    109109
    110110static PyObject *Fm_SetFScaleDisable(PyObject *_self, PyObject *_args)
    111111{
    112         PyObject *_res = NULL;
    113         Boolean fscaleDisable;
     112    PyObject *_res = NULL;
     113    Boolean fscaleDisable;
    114114#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;
    124124}
    125125
    126126static PyObject *Fm_FontMetrics(PyObject *_self, PyObject *_args)
    127127{
    128         PyObject *_res = NULL;
    129         FMetricRec theMetrics;
     128    PyObject *_res = NULL;
     129    FMetricRec theMetrics;
    130130#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;
    139139}
    140140
    141141static PyObject *Fm_SetFractEnable(PyObject *_self, PyObject *_args)
    142142{
    143         PyObject *_res = NULL;
    144         Boolean fractEnable;
     143    PyObject *_res = NULL;
     144    Boolean fractEnable;
    145145#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;
    155155}
    156156
    157157static PyObject *Fm_GetDefFontSize(PyObject *_self, PyObject *_args)
    158158{
    159         PyObject *_res = NULL;
    160         short _rv;
     159    PyObject *_res = NULL;
     160    short _rv;
    161161#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;
    170170}
    171171
    172172static PyObject *Fm_IsOutline(PyObject *_self, PyObject *_args)
    173173{
    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;
    178178#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;
    190190}
    191191
    192192static PyObject *Fm_SetOutlinePreferred(PyObject *_self, PyObject *_args)
    193193{
    194         PyObject *_res = NULL;
    195         Boolean outlinePreferred;
     194    PyObject *_res = NULL;
     195    Boolean outlinePreferred;
    196196#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;
    206206}
    207207
    208208static PyObject *Fm_GetOutlinePreferred(PyObject *_self, PyObject *_args)
    209209{
    210         PyObject *_res = NULL;
    211         Boolean _rv;
     210    PyObject *_res = NULL;
     211    Boolean _rv;
    212212#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;
    221221}
    222222
    223223static PyObject *Fm_SetPreserveGlyph(PyObject *_self, PyObject *_args)
    224224{
    225         PyObject *_res = NULL;
    226         Boolean preserveGlyph;
     225    PyObject *_res = NULL;
     226    Boolean preserveGlyph;
    227227#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;
    237237}
    238238
    239239static PyObject *Fm_GetPreserveGlyph(PyObject *_self, PyObject *_args)
    240240{
    241         PyObject *_res = NULL;
    242         Boolean _rv;
     241    PyObject *_res = NULL;
     242    Boolean _rv;
    243243#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;
    252252}
    253253
    254254static PyObject *Fm_GetSysFont(PyObject *_self, PyObject *_args)
    255255{
    256         PyObject *_res = NULL;
    257         short _rv;
     256    PyObject *_res = NULL;
     257    short _rv;
    258258#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;
    267267}
    268268
    269269static PyObject *Fm_GetAppFont(PyObject *_self, PyObject *_args)
    270270{
    271         PyObject *_res = NULL;
    272         short _rv;
     271    PyObject *_res = NULL;
     272    short _rv;
    273273#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;
    282282}
    283283
    284284static PyObject *Fm_QDTextBounds(PyObject *_self, PyObject *_args)
    285285{
    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;
    291291#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;
    303303}
    304304
    305305static 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}
    337337};
    338338
     
    340340
    341341static PyMethodDef Fm_methods[] = {
    342         {NULL, NULL, 0}
     342    {NULL, NULL, 0}
    343343};
    344344
     
    347347void init_Fm(void)
    348348{
    349         PyObject *m;
    350 #ifndef __LP64__
    351         PyObject *d;
     349    PyObject *m;
     350#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7)
     351    PyObject *d;
    352352#endif  /* __LP64__ */
    353353
     
    355355
    356356
    357         m = Py_InitModule("_Fm", Fm_methods);
    358 #ifndef __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;
    364364#endif  /* __LP64__ */
    365365}
Note: See TracChangeset for help on using the changeset viewer.