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/ibcarbon/_IBCarbon.c

    r2 r391  
    2424
    2525typedef struct IBNibRefObject {
    26         PyObject_HEAD
    27         IBNibRef ob_itself;
     26    PyObject_HEAD
     27    IBNibRef ob_itself;
    2828} IBNibRefObject;
    2929
    3030PyObject *IBNibRefObj_New(IBNibRef itself)
    3131{
    32         IBNibRefObject *it;
    33         it = PyObject_NEW(IBNibRefObject, &IBNibRef_Type);
    34         if (it == NULL) return NULL;
    35         it->ob_itself = itself;
    36         return (PyObject *)it;
     32    IBNibRefObject *it;
     33    it = PyObject_NEW(IBNibRefObject, &IBNibRef_Type);
     34    if (it == NULL) return NULL;
     35    it->ob_itself = itself;
     36    return (PyObject *)it;
    3737}
    3838
    3939int IBNibRefObj_Convert(PyObject *v, IBNibRef *p_itself)
    4040{
    41         if (!IBNibRefObj_Check(v))
    42         {
    43                 PyErr_SetString(PyExc_TypeError, "IBNibRef required");
    44                 return 0;
    45         }
    46         *p_itself = ((IBNibRefObject *)v)->ob_itself;
    47         return 1;
     41    if (!IBNibRefObj_Check(v))
     42    {
     43        PyErr_SetString(PyExc_TypeError, "IBNibRef required");
     44        return 0;
     45    }
     46    *p_itself = ((IBNibRefObject *)v)->ob_itself;
     47    return 1;
    4848}
    4949
    5050static void IBNibRefObj_dealloc(IBNibRefObject *self)
    5151{
    52         DisposeNibReference(self->ob_itself);
    53         self->ob_type->tp_free((PyObject *)self);
     52    DisposeNibReference(self->ob_itself);
     53    self->ob_type->tp_free((PyObject *)self);
    5454}
    5555
    5656static PyObject *IBNibRefObj_CreateWindowFromNib(IBNibRefObject *_self, PyObject *_args)
    5757{
    58         PyObject *_res = NULL;
    59         OSStatus _err;
    60         CFStringRef inName;
    61         WindowPtr outWindow;
    62         if (!PyArg_ParseTuple(_args, "O&",
    63                               CFStringRefObj_Convert, &inName))
    64                 return NULL;
    65         _err = CreateWindowFromNib(_self->ob_itself,
    66                                    inName,
    67                                    &outWindow);
    68         if (_err != noErr) return PyMac_Error(_err);
    69         _res = Py_BuildValue("O&",
    70                              WinObj_New, outWindow);
    71         return _res;
     58    PyObject *_res = NULL;
     59    OSStatus _err;
     60    CFStringRef inName;
     61    WindowPtr outWindow;
     62    if (!PyArg_ParseTuple(_args, "O&",
     63                          CFStringRefObj_Convert, &inName))
     64        return NULL;
     65    _err = CreateWindowFromNib(_self->ob_itself,
     66                               inName,
     67                               &outWindow);
     68    if (_err != noErr) return PyMac_Error(_err);
     69    _res = Py_BuildValue("O&",
     70                         WinObj_New, outWindow);
     71    return _res;
    7272}
    7373
    7474static PyObject *IBNibRefObj_CreateMenuFromNib(IBNibRefObject *_self, PyObject *_args)
    7575{
    76         PyObject *_res = NULL;
    77         OSStatus _err;
    78         CFStringRef inName;
    79         MenuHandle outMenuRef;
    80         if (!PyArg_ParseTuple(_args, "O&",
    81                               CFStringRefObj_Convert, &inName))
    82                 return NULL;
    83         _err = CreateMenuFromNib(_self->ob_itself,
    84                                  inName,
    85                                  &outMenuRef);
    86         if (_err != noErr) return PyMac_Error(_err);
    87         _res = Py_BuildValue("O&",
    88                              MenuObj_New, outMenuRef);
    89         return _res;
     76    PyObject *_res = NULL;
     77    OSStatus _err;
     78    CFStringRef inName;
     79    MenuHandle outMenuRef;
     80    if (!PyArg_ParseTuple(_args, "O&",
     81                          CFStringRefObj_Convert, &inName))
     82        return NULL;
     83    _err = CreateMenuFromNib(_self->ob_itself,
     84                             inName,
     85                             &outMenuRef);
     86    if (_err != noErr) return PyMac_Error(_err);
     87    _res = Py_BuildValue("O&",
     88                         MenuObj_New, outMenuRef);
     89    return _res;
    9090}
    9191
    9292static PyObject *IBNibRefObj_CreateMenuBarFromNib(IBNibRefObject *_self, PyObject *_args)
    9393{
    94         PyObject *_res = NULL;
    95         OSStatus _err;
    96         CFStringRef inName;
    97         Handle outMenuBar;
    98         if (!PyArg_ParseTuple(_args, "O&",
    99                               CFStringRefObj_Convert, &inName))
    100                 return NULL;
    101         _err = CreateMenuBarFromNib(_self->ob_itself,
    102                                     inName,
    103                                     &outMenuBar);
    104         if (_err != noErr) return PyMac_Error(_err);
    105         _res = Py_BuildValue("O&",
    106                              ResObj_New, outMenuBar);
    107         return _res;
     94    PyObject *_res = NULL;
     95    OSStatus _err;
     96    CFStringRef inName;
     97    Handle outMenuBar;
     98    if (!PyArg_ParseTuple(_args, "O&",
     99                          CFStringRefObj_Convert, &inName))
     100        return NULL;
     101    _err = CreateMenuBarFromNib(_self->ob_itself,
     102                                inName,
     103                                &outMenuBar);
     104    if (_err != noErr) return PyMac_Error(_err);
     105    _res = Py_BuildValue("O&",
     106                         ResObj_New, outMenuBar);
     107    return _res;
    108108}
    109109
    110110static PyObject *IBNibRefObj_SetMenuBarFromNib(IBNibRefObject *_self, PyObject *_args)
    111111{
    112         PyObject *_res = NULL;
    113         OSStatus _err;
    114         CFStringRef inName;
    115         if (!PyArg_ParseTuple(_args, "O&",
    116                               CFStringRefObj_Convert, &inName))
    117                 return NULL;
    118         _err = SetMenuBarFromNib(_self->ob_itself,
    119                                  inName);
    120         if (_err != noErr) return PyMac_Error(_err);
    121         Py_INCREF(Py_None);
    122         _res = Py_None;
    123         return _res;
     112    PyObject *_res = NULL;
     113    OSStatus _err;
     114    CFStringRef inName;
     115    if (!PyArg_ParseTuple(_args, "O&",
     116                          CFStringRefObj_Convert, &inName))
     117        return NULL;
     118    _err = SetMenuBarFromNib(_self->ob_itself,
     119                             inName);
     120    if (_err != noErr) return PyMac_Error(_err);
     121    Py_INCREF(Py_None);
     122    _res = Py_None;
     123    return _res;
    124124}
    125125
    126126static PyMethodDef IBNibRefObj_methods[] = {
    127         {"CreateWindowFromNib", (PyCFunction)IBNibRefObj_CreateWindowFromNib, 1,
    128         PyDoc_STR("(CFStringRef inName) -> (WindowPtr outWindow)")},
    129         {"CreateMenuFromNib", (PyCFunction)IBNibRefObj_CreateMenuFromNib, 1,
    130         PyDoc_STR("(CFStringRef inName) -> (MenuHandle outMenuRef)")},
    131         {"CreateMenuBarFromNib", (PyCFunction)IBNibRefObj_CreateMenuBarFromNib, 1,
    132         PyDoc_STR("(CFStringRef inName) -> (Handle outMenuBar)")},
    133         {"SetMenuBarFromNib", (PyCFunction)IBNibRefObj_SetMenuBarFromNib, 1,
    134         PyDoc_STR("(CFStringRef inName) -> None")},
    135         {NULL, NULL, 0}
     127    {"CreateWindowFromNib", (PyCFunction)IBNibRefObj_CreateWindowFromNib, 1,
     128    PyDoc_STR("(CFStringRef inName) -> (WindowPtr outWindow)")},
     129    {"CreateMenuFromNib", (PyCFunction)IBNibRefObj_CreateMenuFromNib, 1,
     130    PyDoc_STR("(CFStringRef inName) -> (MenuHandle outMenuRef)")},
     131    {"CreateMenuBarFromNib", (PyCFunction)IBNibRefObj_CreateMenuBarFromNib, 1,
     132    PyDoc_STR("(CFStringRef inName) -> (Handle outMenuBar)")},
     133    {"SetMenuBarFromNib", (PyCFunction)IBNibRefObj_SetMenuBarFromNib, 1,
     134    PyDoc_STR("(CFStringRef inName) -> None")},
     135    {NULL, NULL, 0}
    136136};
    137137
     
    150150static PyObject *IBNibRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
    151151{
    152         PyObject *_self;
    153         IBNibRef itself;
    154         char *kw[] = {"itself", 0};
    155 
    156         if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, IBNibRefObj_Convert, &itself)) return NULL;
    157         if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
    158         ((IBNibRefObject *)_self)->ob_itself = itself;
    159         return _self;
     152    PyObject *_self;
     153    IBNibRef itself;
     154    char *kw[] = {"itself", 0};
     155
     156    if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, IBNibRefObj_Convert, &itself)) return NULL;
     157    if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
     158    ((IBNibRefObject *)_self)->ob_itself = itself;
     159    return _self;
    160160}
    161161
     
    164164
    165165PyTypeObject IBNibRef_Type = {
    166         PyObject_HEAD_INIT(NULL)
    167         0, /*ob_size*/
    168         "_IBCarbon.IBNibRef", /*tp_name*/
    169         sizeof(IBNibRefObject), /*tp_basicsize*/
    170         0, /*tp_itemsize*/
    171         /* methods */
    172         (destructor) IBNibRefObj_dealloc, /*tp_dealloc*/
    173         0, /*tp_print*/
    174         (getattrfunc)0, /*tp_getattr*/
    175         (setattrfunc)0, /*tp_setattr*/
    176         (cmpfunc) IBNibRefObj_compare, /*tp_compare*/
    177         (reprfunc) IBNibRefObj_repr, /*tp_repr*/
    178         (PyNumberMethods *)0, /* tp_as_number */
    179         (PySequenceMethods *)0, /* tp_as_sequence */
    180         (PyMappingMethods *)0, /* tp_as_mapping */
    181         (hashfunc) IBNibRefObj_hash, /*tp_hash*/
    182         0, /*tp_call*/
    183         0, /*tp_str*/
    184         PyObject_GenericGetAttr, /*tp_getattro*/
    185         PyObject_GenericSetAttr, /*tp_setattro */
    186         0, /*tp_as_buffer*/
    187         Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
    188         0, /*tp_doc*/
    189         0, /*tp_traverse*/
    190         0, /*tp_clear*/
    191         0, /*tp_richcompare*/
    192         0, /*tp_weaklistoffset*/
    193         0, /*tp_iter*/
    194         0, /*tp_iternext*/
    195         IBNibRefObj_methods, /* tp_methods */
    196         0, /*tp_members*/
    197         IBNibRefObj_getsetlist, /*tp_getset*/
    198         0, /*tp_base*/
    199         0, /*tp_dict*/
    200         0, /*tp_descr_get*/
    201         0, /*tp_descr_set*/
    202         0, /*tp_dictoffset*/
    203         IBNibRefObj_tp_init, /* tp_init */
    204         IBNibRefObj_tp_alloc, /* tp_alloc */
    205         IBNibRefObj_tp_new, /* tp_new */
    206         IBNibRefObj_tp_free, /* tp_free */
     166    PyObject_HEAD_INIT(NULL)
     167    0, /*ob_size*/
     168    "_IBCarbon.IBNibRef", /*tp_name*/
     169    sizeof(IBNibRefObject), /*tp_basicsize*/
     170    0, /*tp_itemsize*/
     171    /* methods */
     172    (destructor) IBNibRefObj_dealloc, /*tp_dealloc*/
     173    0, /*tp_print*/
     174    (getattrfunc)0, /*tp_getattr*/
     175    (setattrfunc)0, /*tp_setattr*/
     176    (cmpfunc) IBNibRefObj_compare, /*tp_compare*/
     177    (reprfunc) IBNibRefObj_repr, /*tp_repr*/
     178    (PyNumberMethods *)0, /* tp_as_number */
     179    (PySequenceMethods *)0, /* tp_as_sequence */
     180    (PyMappingMethods *)0, /* tp_as_mapping */
     181    (hashfunc) IBNibRefObj_hash, /*tp_hash*/
     182    0, /*tp_call*/
     183    0, /*tp_str*/
     184    PyObject_GenericGetAttr, /*tp_getattro*/
     185    PyObject_GenericSetAttr, /*tp_setattro */
     186    0, /*tp_as_buffer*/
     187    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
     188    0, /*tp_doc*/
     189    0, /*tp_traverse*/
     190    0, /*tp_clear*/
     191    0, /*tp_richcompare*/
     192    0, /*tp_weaklistoffset*/
     193    0, /*tp_iter*/
     194    0, /*tp_iternext*/
     195    IBNibRefObj_methods, /* tp_methods */
     196    0, /*tp_members*/
     197    IBNibRefObj_getsetlist, /*tp_getset*/
     198    0, /*tp_base*/
     199    0, /*tp_dict*/
     200    0, /*tp_descr_get*/
     201    0, /*tp_descr_set*/
     202    0, /*tp_dictoffset*/
     203    IBNibRefObj_tp_init, /* tp_init */
     204    IBNibRefObj_tp_alloc, /* tp_alloc */
     205    IBNibRefObj_tp_new, /* tp_new */
     206    IBNibRefObj_tp_free, /* tp_free */
    207207};
    208208
     
    212212static PyObject *IBCarbon_CreateNibReference(PyObject *_self, PyObject *_args)
    213213{
    214         PyObject *_res = NULL;
    215         OSStatus _err;
    216         CFStringRef inNibName;
    217         IBNibRef outNibRef;
    218         if (!PyArg_ParseTuple(_args, "O&",
    219                               CFStringRefObj_Convert, &inNibName))
    220                 return NULL;
    221         _err = CreateNibReference(inNibName,
    222                                   &outNibRef);
    223         if (_err != noErr) return PyMac_Error(_err);
    224         _res = Py_BuildValue("O&",
    225                              IBNibRefObj_New, outNibRef);
    226         return _res;
     214    PyObject *_res = NULL;
     215    OSStatus _err;
     216    CFStringRef inNibName;
     217    IBNibRef outNibRef;
     218    if (!PyArg_ParseTuple(_args, "O&",
     219                          CFStringRefObj_Convert, &inNibName))
     220        return NULL;
     221    _err = CreateNibReference(inNibName,
     222                              &outNibRef);
     223    if (_err != noErr) return PyMac_Error(_err);
     224    _res = Py_BuildValue("O&",
     225                         IBNibRefObj_New, outNibRef);
     226    return _res;
    227227}
    228228#endif /* __LP64__ */
     
    230230static PyMethodDef IBCarbon_methods[] = {
    231231#ifndef __LP64__
    232         {"CreateNibReference", (PyCFunction)IBCarbon_CreateNibReference, 1,
    233         PyDoc_STR("(CFStringRef inNibName) -> (IBNibRef outNibRef)")},
    234 #endif /* __LP64__ */
    235         {NULL, NULL, 0}
     232    {"CreateNibReference", (PyCFunction)IBCarbon_CreateNibReference, 1,
     233    PyDoc_STR("(CFStringRef inNibName) -> (IBNibRef outNibRef)")},
     234#endif /* __LP64__ */
     235    {NULL, NULL, 0}
    236236};
    237237
     
    241241void init_IBCarbon(void)
    242242{
    243         PyObject *m;
    244 #ifndef __LP64__
    245         PyObject *d;
    246 #endif /* __LP64__ */
    247 
    248 
    249 
    250 
    251 
    252         m = Py_InitModule("_IBCarbon", IBCarbon_methods);
    253 #ifndef __LP64__
    254         d = PyModule_GetDict(m);
    255         IBCarbon_Error = PyMac_GetOSErrException();
    256         if (IBCarbon_Error == NULL ||
    257             PyDict_SetItemString(d, "Error", IBCarbon_Error) != 0)
    258                 return;
    259         IBNibRef_Type.ob_type = &PyType_Type;
    260         if (PyType_Ready(&IBNibRef_Type) < 0) return;
    261         Py_INCREF(&IBNibRef_Type);
    262         PyModule_AddObject(m, "IBNibRef", (PyObject *)&IBNibRef_Type);
    263         /* Backward-compatible name */
    264         Py_INCREF(&IBNibRef_Type);
    265         PyModule_AddObject(m, "IBNibRefType", (PyObject *)&IBNibRef_Type);
     243    PyObject *m;
     244#ifndef __LP64__
     245    PyObject *d;
     246#endif /* __LP64__ */
     247
     248
     249
     250
     251
     252    m = Py_InitModule("_IBCarbon", IBCarbon_methods);
     253#ifndef __LP64__
     254    d = PyModule_GetDict(m);
     255    IBCarbon_Error = PyMac_GetOSErrException();
     256    if (IBCarbon_Error == NULL ||
     257        PyDict_SetItemString(d, "Error", IBCarbon_Error) != 0)
     258        return;
     259    IBNibRef_Type.ob_type = &PyType_Type;
     260    if (PyType_Ready(&IBNibRef_Type) < 0) return;
     261    Py_INCREF(&IBNibRef_Type);
     262    PyModule_AddObject(m, "IBNibRef", (PyObject *)&IBNibRef_Type);
     263    /* Backward-compatible name */
     264    Py_INCREF(&IBNibRef_Type);
     265    PyModule_AddObject(m, "IBNibRefType", (PyObject *)&IBNibRef_Type);
    266266#endif /* __LP64__ */
    267267}
Note: See TracChangeset for help on using the changeset viewer.