Ignore:
Timestamp:
Mar 19, 2014, 11:11:30 AM (11 years ago)
Author:
dmik
Message:

python: Update vendor to 2.7.6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/vendor/current/Include/datetime.h

    r2 r388  
    1212 *
    1313 * byte offset
    14  *  0           year     2 bytes, 1-9999
    15  *  2           month    1 byte, 1-12
    16  *  3           day      1 byte, 1-31
    17  *  4           hour     1 byte, 0-23
    18  *  5           minute   1 byte, 0-59
    19  *  6           second   1 byte, 0-59
    20  *  7           usecond  3 bytes, 0-999999
     14 *  0           year     2 bytes, 1-9999
     15 *  2           month    1 byte, 1-12
     16 *  3           day      1 byte, 1-31
     17 *  4           hour     1 byte, 0-23
     18 *  5           minute   1 byte, 0-59
     19 *  6           second   1 byte, 0-59
     20 *  7           usecond  3 bytes, 0-999999
    2121 * 10
    2222 */
     
    3434typedef struct
    3535{
    36         PyObject_HEAD
    37         long hashcode;          /* -1 when unknown */
    38         int days;               /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */
    39         int seconds;            /* 0 <= seconds < 24*3600 is invariant */
    40         int microseconds;       /* 0 <= microseconds < 1000000 is invariant */
     36    PyObject_HEAD
     37    long hashcode;              /* -1 when unknown */
     38    int days;                   /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */
     39    int seconds;                /* 0 <= seconds < 24*3600 is invariant */
     40    int microseconds;           /* 0 <= microseconds < 1000000 is invariant */
    4141} PyDateTime_Delta;
    4242
    4343typedef struct
    4444{
    45         PyObject_HEAD           /* a pure abstract base clase */
     45    PyObject_HEAD               /* a pure abstract base class */
    4646} PyDateTime_TZInfo;
    4747
     
    5050 * present if and only if hastzinfo is true.
    5151 */
    52 #define _PyTZINFO_HEAD          \
    53         PyObject_HEAD           \
    54         long hashcode;          \
    55         char hastzinfo;         /* boolean flag */
     52#define _PyTZINFO_HEAD          \
     53    PyObject_HEAD               \
     54    long hashcode;              \
     55    char hastzinfo;             /* boolean flag */
    5656
    5757/* No _PyDateTime_BaseTZInfo is allocated; it's just to have something
     
    6161typedef struct
    6262{
    63         _PyTZINFO_HEAD
     63    _PyTZINFO_HEAD
    6464} _PyDateTime_BaseTZInfo;
    6565
     
    7070 * "without" case.
    7171 */
    72 #define _PyDateTime_TIMEHEAD    \
    73         _PyTZINFO_HEAD          \
    74         unsigned char data[_PyDateTime_TIME_DATASIZE];
    75 
    76 typedef struct
    77 {
    78         _PyDateTime_TIMEHEAD
    79 } _PyDateTime_BaseTime;         /* hastzinfo false */
    80 
    81 typedef struct
    82 {
    83         _PyDateTime_TIMEHEAD
    84         PyObject *tzinfo;
    85 } PyDateTime_Time;              /* hastzinfo true */
     72#define _PyDateTime_TIMEHEAD    \
     73    _PyTZINFO_HEAD              \
     74    unsigned char data[_PyDateTime_TIME_DATASIZE];
     75
     76typedef struct
     77{
     78    _PyDateTime_TIMEHEAD
     79} _PyDateTime_BaseTime;         /* hastzinfo false */
     80
     81typedef struct
     82{
     83    _PyDateTime_TIMEHEAD
     84    PyObject *tzinfo;
     85} PyDateTime_Time;              /* hastzinfo true */
    8686
    8787
     
    9393typedef struct
    9494{
    95         _PyTZINFO_HEAD
    96         unsigned char data[_PyDateTime_DATE_DATASIZE];
     95    _PyTZINFO_HEAD
     96    unsigned char data[_PyDateTime_DATE_DATASIZE];
    9797} PyDateTime_Date;
    9898
    99 #define _PyDateTime_DATETIMEHEAD        \
    100         _PyTZINFO_HEAD                  \
    101         unsigned char data[_PyDateTime_DATETIME_DATASIZE];
    102 
    103 typedef struct
    104 {
    105         _PyDateTime_DATETIMEHEAD
    106 } _PyDateTime_BaseDateTime;     /* hastzinfo false */
    107 
    108 typedef struct
    109 {
    110         _PyDateTime_DATETIMEHEAD
    111         PyObject *tzinfo;
    112 } PyDateTime_DateTime;          /* hastzinfo true */
     99#define _PyDateTime_DATETIMEHEAD        \
     100    _PyTZINFO_HEAD                      \
     101    unsigned char data[_PyDateTime_DATETIME_DATASIZE];
     102
     103typedef struct
     104{
     105    _PyDateTime_DATETIMEHEAD
     106} _PyDateTime_BaseDateTime;     /* hastzinfo false */
     107
     108typedef struct
     109{
     110    _PyDateTime_DATETIMEHEAD
     111    PyObject *tzinfo;
     112} PyDateTime_DateTime;          /* hastzinfo true */
    113113
    114114
    115115/* Apply for date and datetime instances. */
    116116#define PyDateTime_GET_YEAR(o)     ((((PyDateTime_Date*)o)->data[0] << 8) | \
    117                                      ((PyDateTime_Date*)o)->data[1])
     117                     ((PyDateTime_Date*)o)->data[1])
    118118#define PyDateTime_GET_MONTH(o)    (((PyDateTime_Date*)o)->data[2])
    119119#define PyDateTime_GET_DAY(o)      (((PyDateTime_Date*)o)->data[3])
     
    122122#define PyDateTime_DATE_GET_MINUTE(o)      (((PyDateTime_DateTime*)o)->data[5])
    123123#define PyDateTime_DATE_GET_SECOND(o)      (((PyDateTime_DateTime*)o)->data[6])
    124 #define PyDateTime_DATE_GET_MICROSECOND(o)              \
    125         ((((PyDateTime_DateTime*)o)->data[7] << 16) |   \
    126          (((PyDateTime_DateTime*)o)->data[8] << 8)  |   \
    127           ((PyDateTime_DateTime*)o)->data[9])
     124#define PyDateTime_DATE_GET_MICROSECOND(o)              \
     125    ((((PyDateTime_DateTime*)o)->data[7] << 16) |       \
     126     (((PyDateTime_DateTime*)o)->data[8] << 8)  |       \
     127      ((PyDateTime_DateTime*)o)->data[9])
    128128
    129129/* Apply for time instances. */
     
    131131#define PyDateTime_TIME_GET_MINUTE(o)      (((PyDateTime_Time*)o)->data[1])
    132132#define PyDateTime_TIME_GET_SECOND(o)      (((PyDateTime_Time*)o)->data[2])
    133 #define PyDateTime_TIME_GET_MICROSECOND(o)              \
    134         ((((PyDateTime_Time*)o)->data[3] << 16) |       \
    135          (((PyDateTime_Time*)o)->data[4] << 8)  |       \
    136           ((PyDateTime_Time*)o)->data[5])
     133#define PyDateTime_TIME_GET_MICROSECOND(o)              \
     134    ((((PyDateTime_Time*)o)->data[3] << 16) |           \
     135     (((PyDateTime_Time*)o)->data[4] << 8)  |           \
     136      ((PyDateTime_Time*)o)->data[5])
    137137
    138138
     
    149149    PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*);
    150150    PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int,
    151             PyObject*, PyTypeObject*);
     151        PyObject*, PyTypeObject*);
    152152    PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*);
    153153    PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*);
     
    159159} PyDateTime_CAPI;
    160160
     161#define PyDateTime_CAPSULE_NAME "datetime.datetime_CAPI"
     162
    161163
    162164/* "magic" constant used to partially protect against developer mistakes. */
     
    184186
    185187/* Define global variable for the C API and a macro for setting it. */
    186 static PyDateTime_CAPI *PyDateTimeAPI;
     188static PyDateTime_CAPI *PyDateTimeAPI = NULL;
    187189
    188190#define PyDateTime_IMPORT \
    189         PyDateTimeAPI = (PyDateTime_CAPI*) PyCObject_Import("datetime", \
    190                                                             "datetime_CAPI")
    191 
    192 /* This macro would be used if PyCObject_ImportEx() was created.
    193 #define PyDateTime_IMPORT \
    194         PyDateTimeAPI = (PyDateTime_CAPI*) PyCObject_ImportEx("datetime", \
    195                                                             "datetime_CAPI", \
    196                                                             DATETIME_API_MAGIC)
    197 */
     191    PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0)
    198192
    199193/* Macros for type checking when not building the Python core. */
     
    215209/* Macros for accessing constructors in a simplified fashion. */
    216210#define PyDate_FromDate(year, month, day) \
    217         PyDateTimeAPI->Date_FromDate(year, month, day, PyDateTimeAPI->DateType)
     211    PyDateTimeAPI->Date_FromDate(year, month, day, PyDateTimeAPI->DateType)
    218212
    219213#define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) \
    220         PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, \
    221                 min, sec, usec, Py_None, PyDateTimeAPI->DateTimeType)
     214    PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, \
     215        min, sec, usec, Py_None, PyDateTimeAPI->DateTimeType)
    222216
    223217#define PyTime_FromTime(hour, minute, second, usecond) \
    224         PyDateTimeAPI->Time_FromTime(hour, minute, second, usecond, \
    225                 Py_None, PyDateTimeAPI->TimeType)
     218    PyDateTimeAPI->Time_FromTime(hour, minute, second, usecond, \
     219        Py_None, PyDateTimeAPI->TimeType)
    226220
    227221#define PyDelta_FromDSU(days, seconds, useconds) \
    228         PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, \
    229                 PyDateTimeAPI->DeltaType)
     222    PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, \
     223        PyDateTimeAPI->DeltaType)
    230224
    231225/* Macros supporting the DB API. */
    232226#define PyDateTime_FromTimestamp(args) \
    233         PyDateTimeAPI->DateTime_FromTimestamp( \
    234                 (PyObject*) (PyDateTimeAPI->DateTimeType), args, NULL)
     227    PyDateTimeAPI->DateTime_FromTimestamp( \
     228        (PyObject*) (PyDateTimeAPI->DateTimeType), args, NULL)
    235229
    236230#define PyDate_FromTimestamp(args) \
    237         PyDateTimeAPI->Date_FromTimestamp( \
    238                 (PyObject*) (PyDateTimeAPI->DateType), args)
    239 
    240 #endif  /* Py_BUILD_CORE */
     231    PyDateTimeAPI->Date_FromTimestamp( \
     232        (PyObject*) (PyDateTimeAPI->DateType), args)
     233
     234#endif  /* Py_BUILD_CORE */
    241235
    242236#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.