[Python-checkins] python/dist/src/Modules datetimemodule.c, 1.73,
1.74
tim_one at users.sourceforge.net
tim_one at users.sourceforge.net
Sun Jun 20 18:41:36 EDT 2004
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18815/Modules
Modified Files:
datetimemodule.c
Log Message:
SF patch 876130: add C API to datetime module, from Anthony Tuininga.
The LaTeX is untested (well, so is the new API, for that matter).
Note that I also changed NULL to get spelled consistently in concrete.tex.
If that was a wrong thing to do, Fred should yell at me.
Index: datetimemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/datetimemodule.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -C2 -d -r1.73 -r1.74
*** datetimemodule.c 20 Jun 2004 02:50:16 -0000 1.73
--- datetimemodule.c 20 Jun 2004 22:41:32 -0000 1.74
***************
*** 10,14 ****
--- 10,20 ----
#include "timefuncs.h"
+
+ /* Differentiate between building the core module and building extension
+ * modules.
+ */
+ #define Py_BUILD_CORE
#include "datetime.h"
+ #undef Py_BUILD_CORE
/* We require that C int be at least 32 bits, and use int virtually
***************
*** 4521,4524 ****
--- 4527,4548 ----
};
+ /* C API. Clients get at this via PyDateTime_IMPORT, defined in
+ * datetime.h.
+ */
+ static PyDateTime_CAPI CAPI = {
+ &PyDateTime_DateType,
+ &PyDateTime_DateTimeType,
+ &PyDateTime_TimeType,
+ &PyDateTime_DeltaType,
+ &PyDateTime_TZInfoType,
+ new_date_ex,
+ new_datetime_ex,
+ new_time_ex,
+ new_delta_ex,
+ datetime_fromtimestamp,
+ date_fromtimestamp
+ };
+
+
PyMODINIT_FUNC
initdatetime(void)
***************
*** 4634,4637 ****
--- 4658,4667 ----
PyModule_AddObject(m, "tzinfo", (PyObject *) &PyDateTime_TZInfoType);
+ x = PyCObject_FromVoidPtrAndDesc(&CAPI, (void*) DATETIME_API_MAGIC,
+ NULL);
+ if (x == NULL)
+ return;
+ PyModule_AddObject(m, "datetime_CAPI", x);
+
/* A 4-year cycle has an extra leap day over what we'd get from
* pasting together 4 single years.
More information about the Python-checkins
mailing list