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/ah/_AHmodule.c

    r2 r391  
    1010/* Macro to test whether a weak-loaded CFM function exists */
    1111#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL )  {\
    12         PyErr_SetString(PyExc_NotImplementedError, \
    13         "Not available in this shared library/OS version"); \
    14         return NULL; \
     12    PyErr_SetString(PyExc_NotImplementedError, \
     13    "Not available in this shared library/OS version"); \
     14    return NULL; \
    1515    }} while(0)
    1616
     
    2323static PyObject *Ah_AHSearch(PyObject *_self, PyObject *_args)
    2424{
    25         PyObject *_res = NULL;
    26         OSStatus _err;
    27         CFStringRef bookname;
    28         CFStringRef query;
    29         if (!PyArg_ParseTuple(_args, "O&O&",
    30                               CFStringRefObj_Convert, &bookname,
    31                               CFStringRefObj_Convert, &query))
    32                 return NULL;
    33         _err = AHSearch(bookname,
    34                         query);
    35         if (_err != noErr) return PyMac_Error(_err);
    36         Py_INCREF(Py_None);
    37         _res = Py_None;
    38         return _res;
     25    PyObject *_res = NULL;
     26    OSStatus _err;
     27    CFStringRef bookname;
     28    CFStringRef query;
     29    if (!PyArg_ParseTuple(_args, "O&O&",
     30                          CFStringRefObj_Convert, &bookname,
     31                          CFStringRefObj_Convert, &query))
     32        return NULL;
     33    _err = AHSearch(bookname,
     34                    query);
     35    if (_err != noErr) return PyMac_Error(_err);
     36    Py_INCREF(Py_None);
     37    _res = Py_None;
     38    return _res;
    3939}
    4040
    4141static PyObject *Ah_AHGotoMainTOC(PyObject *_self, PyObject *_args)
    4242{
    43         PyObject *_res = NULL;
    44         OSStatus _err;
    45         AHTOCType toctype;
    46         if (!PyArg_ParseTuple(_args, "h",
    47                               &toctype))
    48                 return NULL;
    49         _err = AHGotoMainTOC(toctype);
    50         if (_err != noErr) return PyMac_Error(_err);
    51         Py_INCREF(Py_None);
    52         _res = Py_None;
    53         return _res;
     43    PyObject *_res = NULL;
     44    OSStatus _err;
     45    AHTOCType toctype;
     46    if (!PyArg_ParseTuple(_args, "h",
     47                          &toctype))
     48        return NULL;
     49    _err = AHGotoMainTOC(toctype);
     50    if (_err != noErr) return PyMac_Error(_err);
     51    Py_INCREF(Py_None);
     52    _res = Py_None;
     53    return _res;
    5454}
    5555
    5656static PyObject *Ah_AHGotoPage(PyObject *_self, PyObject *_args)
    5757{
    58         PyObject *_res = NULL;
    59         OSStatus _err;
    60         CFStringRef bookname;
    61         CFStringRef path;
    62         CFStringRef anchor;
    63         if (!PyArg_ParseTuple(_args, "O&O&O&",
    64                               CFStringRefObj_Convert, &bookname,
    65                               CFStringRefObj_Convert, &path,
    66                               CFStringRefObj_Convert, &anchor))
    67                 return NULL;
    68         _err = AHGotoPage(bookname,
    69                           path,
    70                           anchor);
    71         if (_err != noErr) return PyMac_Error(_err);
    72         Py_INCREF(Py_None);
    73         _res = Py_None;
    74         return _res;
     58    PyObject *_res = NULL;
     59    OSStatus _err;
     60    CFStringRef bookname;
     61    CFStringRef path;
     62    CFStringRef anchor;
     63    if (!PyArg_ParseTuple(_args, "O&O&O&",
     64                          CFStringRefObj_Convert, &bookname,
     65                          CFStringRefObj_Convert, &path,
     66                          CFStringRefObj_Convert, &anchor))
     67        return NULL;
     68    _err = AHGotoPage(bookname,
     69                      path,
     70                      anchor);
     71    if (_err != noErr) return PyMac_Error(_err);
     72    Py_INCREF(Py_None);
     73    _res = Py_None;
     74    return _res;
    7575}
    7676
    7777static PyObject *Ah_AHLookupAnchor(PyObject *_self, PyObject *_args)
    7878{
    79         PyObject *_res = NULL;
    80         OSStatus _err;
    81         CFStringRef bookname;
    82         CFStringRef anchor;
    83         if (!PyArg_ParseTuple(_args, "O&O&",
    84                               CFStringRefObj_Convert, &bookname,
    85                               CFStringRefObj_Convert, &anchor))
    86                 return NULL;
    87         _err = AHLookupAnchor(bookname,
    88                               anchor);
    89         if (_err != noErr) return PyMac_Error(_err);
    90         Py_INCREF(Py_None);
    91         _res = Py_None;
    92         return _res;
     79    PyObject *_res = NULL;
     80    OSStatus _err;
     81    CFStringRef bookname;
     82    CFStringRef anchor;
     83    if (!PyArg_ParseTuple(_args, "O&O&",
     84                          CFStringRefObj_Convert, &bookname,
     85                          CFStringRefObj_Convert, &anchor))
     86        return NULL;
     87    _err = AHLookupAnchor(bookname,
     88                          anchor);
     89    if (_err != noErr) return PyMac_Error(_err);
     90    Py_INCREF(Py_None);
     91    _res = Py_None;
     92    return _res;
    9393}
    9494
    9595static PyObject *Ah_AHRegisterHelpBook(PyObject *_self, PyObject *_args)
    9696{
    97         PyObject *_res = NULL;
    98         OSStatus _err;
    99         FSRef appBundleRef;
    100         if (!PyArg_ParseTuple(_args, "O&",
    101                               PyMac_GetFSRef, &appBundleRef))
    102                 return NULL;
    103         _err = AHRegisterHelpBook(&appBundleRef);
    104         if (_err != noErr) return PyMac_Error(_err);
    105         Py_INCREF(Py_None);
    106         _res = Py_None;
    107         return _res;
     97    PyObject *_res = NULL;
     98    OSStatus _err;
     99    FSRef appBundleRef;
     100    if (!PyArg_ParseTuple(_args, "O&",
     101                          PyMac_GetFSRef, &appBundleRef))
     102        return NULL;
     103    _err = AHRegisterHelpBook(&appBundleRef);
     104    if (_err != noErr) return PyMac_Error(_err);
     105    Py_INCREF(Py_None);
     106    _res = Py_None;
     107    return _res;
    108108}
    109109
    110110static PyMethodDef Ah_methods[] = {
    111         {"AHSearch", (PyCFunction)Ah_AHSearch, 1,
    112         PyDoc_STR("(CFStringRef bookname, CFStringRef query) -> None")},
    113         {"AHGotoMainTOC", (PyCFunction)Ah_AHGotoMainTOC, 1,
    114         PyDoc_STR("(AHTOCType toctype) -> None")},
    115         {"AHGotoPage", (PyCFunction)Ah_AHGotoPage, 1,
    116         PyDoc_STR("(CFStringRef bookname, CFStringRef path, CFStringRef anchor) -> None")},
    117         {"AHLookupAnchor", (PyCFunction)Ah_AHLookupAnchor, 1,
    118         PyDoc_STR("(CFStringRef bookname, CFStringRef anchor) -> None")},
    119         {"AHRegisterHelpBook", (PyCFunction)Ah_AHRegisterHelpBook, 1,
    120         PyDoc_STR("(FSRef appBundleRef) -> None")},
    121         {NULL, NULL, 0}
     111    {"AHSearch", (PyCFunction)Ah_AHSearch, 1,
     112    PyDoc_STR("(CFStringRef bookname, CFStringRef query) -> None")},
     113    {"AHGotoMainTOC", (PyCFunction)Ah_AHGotoMainTOC, 1,
     114    PyDoc_STR("(AHTOCType toctype) -> None")},
     115    {"AHGotoPage", (PyCFunction)Ah_AHGotoPage, 1,
     116    PyDoc_STR("(CFStringRef bookname, CFStringRef path, CFStringRef anchor) -> None")},
     117    {"AHLookupAnchor", (PyCFunction)Ah_AHLookupAnchor, 1,
     118    PyDoc_STR("(CFStringRef bookname, CFStringRef anchor) -> None")},
     119    {"AHRegisterHelpBook", (PyCFunction)Ah_AHRegisterHelpBook, 1,
     120    PyDoc_STR("(FSRef appBundleRef) -> None")},
     121    {NULL, NULL, 0}
    122122};
    123123
     
    127127void init_AH(void)
    128128{
    129         PyObject *m;
    130         PyObject *d;
     129    PyObject *m;
     130    PyObject *d;
    131131
    132132
    133133
    134134
    135         m = Py_InitModule("_AH", Ah_methods);
    136         d = PyModule_GetDict(m);
    137         Ah_Error = PyMac_GetOSErrException();
    138         if (Ah_Error == NULL ||
    139             PyDict_SetItemString(d, "Error", Ah_Error) != 0)
    140                 return;
     135    m = Py_InitModule("_AH", Ah_methods);
     136    d = PyModule_GetDict(m);
     137    Ah_Error = PyMac_GetOSErrException();
     138    if (Ah_Error == NULL ||
     139        PyDict_SetItemString(d, "Error", Ah_Error) != 0)
     140        return;
    141141}
    142142
Note: See TracChangeset for help on using the changeset viewer.