[PyKDE] Static (why?) PyDateTimeAPI and SIP

Denis S. Otkidach ods at strana.ru
Sat Jun 18 16:52:20 BST 2005


I use datetime C API in extension module generated with SIP.  But SIP
break the code into several .cpp files compiled separately and
PyDateTimeAPI used by all macros constituting public interface is
declared static.

The current solution is to define my own functions in main module as
workaround:

%ModuleHeaderCode
PyObject * mxo_PyDateTime_FromDateAndTime(int year, int month, int day,
                                          int hour, int minute, int seconds,
                                          int usecs);
%End

%ModuleCode
PyObject * mxo_PyDateTime_FromDateAndTime(int year, int month, int day,
                                          int hour, int minute, int seconds,
                                          int usecs) {
    return PyDateTime_FromDateAndTime(year, month, day, hour, minute, seconds,
                                      usecs);
}
// and so on for each macro used
%End

%PostInitialisationCode
    PyDateTime_IMPORT;
%End

But I wonder why PyDateTimeAPI is declared static, and is the a better
solution?

-- 
Denis S. Otkidach
http://www.python.ru/      [ru]




More information about the PyQt mailing list