diff options
Diffstat (limited to 'python/sip')
100 files changed, 0 insertions, 67752 deletions
diff --git a/python/sip/ChangeLog b/python/sip/ChangeLog deleted file mode 100644 index 1ec4760c..00000000 --- a/python/sip/ChangeLog +++ /dev/null @@ -1,3814 +0,0 @@ -2007/04/10 15:27:04 phil -Released as v4.6. - - -2007/04/07 17:37:56 phil -Changed the API file generation to generate the __init__ form of a ctor as well -as the callable type form. - - -2007/04/02 22:45:04 phil -Updated the NEWS file. - - -2007/04/02 22:44:16 phil -Added the -n flag to configure.py to build universal binaries on MacOS/X. - - -2007/04/02 19:07:30 phil -Fixed a MinGW warning message. - - -2007/04/02 16:03:32 phil -Backed out the save and restore of the exception state in sipWrapper_dealloc() -as it can get called when there is no current thread state (which results in a -segfault). - - -2007/04/02 15:23:53 phil -Updated the NEWS file. - - -2007/04/02 14:06:29 phil -Fixed a bug handling sub-class convertor code with multiple inheritance. - - -2007/04/02 12:10:54 phil -Virtuals that return a wchar_t * now keep then free the previous result to -limit the possible memory leaks. - - -2007/04/01 16:28:23 phil -Fixed a bug in the wchar_t support with const wchar_t * arguments. -Fixed a bug in the wchar_t support with char and wchar_t being considered -equivalent. - - -2007/03/26 19:28:28 phil -Fixed problem where lambda slots connected to QObject.destroyed() were cleared -before the signal was emitted. - - -2007/03/25 13:45:56 phil -Completed the wchar_t support. - - -2007/03/25 0:00:12 phil -Added support for wchar_t - undocumented and certainly untested. - - -2007/03/10 15:23:46 phil -No longer generate the forward declaration of an opaque class. It shouldn't be -necessary and means that the class could be a C structure. - - -2007/03/02 22:48:39 phil -SIP should now handle DOS format files on UNIX systems. - - -2007/02/27 13:25:26 phil -Undeprecated the -g command line option. -Added the /HoldGIL/ annotation. - - -2007/02/25 14:28:22 phil -Fixed the previous fix related to signatures for the cases where the Python and -C++ signatures have different numbers of arguments. - - -2007/02/25 0:19:29 phil -Included Matt Newell's fix for making sure that a sub-class convertor returns -the most specific type available. - - -2007/02/24 16:38:26 phil -Fixed some documentation references to Py_ssize_t. -sip now takes C++ as well as Python signatures into account when deciding what -interface files a class need to include. - - -2007/02/24 13:45:24 phil -Leave it to the Qt support code to release the GIL when connecting signals. - - -2007/02/20 18:22:48 phil -An instance dictionary is not longer created automatically. Python will create -it if and when it is needed. -lambda slots are now cleaned up in the clear function rather than being left -to the slot proxy dtor. - - -2007/02/20 1:14:16 phil -Fixed a bug in the implementation of /Transfer/ when the object was aleady -owned by C++ but the owning object had been garbage collected. - - -2007/02/18 16:00:12 phil -Fixed a bug in the clearing of reference cycles with lambda slots. Although -the slot is visited, it is no longer cleared - that is left to the proxy dtor. - - -2007/02/16 18:47:13 phil -Fixed a bug in the build system for QtDesigner on Windows. -The Q_OBJECT support code now uses metaObject() rather than staticMetaObject -because the latter is private in the ActiveQt classes. - - -2007/02/10 23:20:33 phil -Added support for /TypeFlags/. -Added sipFindClass() and sipFindNamedEnum() to the public API. - - -2007/02/06 22:20:59 phil -More changes to the Q_OBJECT support. - - -2007/02/04 17:33:33 phil -Renamed "Qt4MetaObject" to "Qt4Q_OBJECT". - - -2007/02/01 15:06:34 phil -Changed the metaObject() hook so that it won't crash if the C++ instance has -gone. - - -2007/01/30 13:22:16 phil -Changed the metaObject() hook again. - - -2007/01/30 13:08:35 phil -Changed the metaObject() hooks. - - -2007/01/27 16:00:54 phil -Changed the way the Qt support API is created so that new SIPs can build old -PyQts. - - -2007/01/27 15:29:54 phil -Added the hooks to allow PyQt to build a proper meta-object when a new Python -class is defined. - - -2007/01/25 13:22:06 phil -Fixed a build system bug that affected non-MinGW Windows compilers when -building static modules. -Taught the build system about the QtDesigner module. - - -2007/01/23 12:41:52 phil -Reimplemented the support for qt_metacall() so that it is a bit cleaner and -can't be called from Python. - - -2007/01/22 22:02:07 phil -Added support for the QtMetaClass option. -Added sipParseSignature() to the private Qt API. -(Both of the above are needed for David Boddie's support for Python widgets in -Qt Designer.) - - -2007/01/21 16:32:45 phil -Extended the cyclic garbage collector support for lambda slots so it works with -SIGNALs as well as PYSIGNALs. -Incremented the SIP API version number to 3.4. - - -2007/01/21 14:55:47 phil -Fixed garbage collection support for lambda slots (at the moment only when the -slot is connected to a PYSIGNAL). - - -2007/01/16 22:32:06 phil -Added #undef slots to sip.h for when embedding Python 2.3 in Qt applications. - - -2007/01/16 13:54:14 phil -qRegisterMetaType() is now called for every candidate class at module -initialisation rather than when the first instance is created from Python. - - -2007/01/15 23:47:45 phil -Allowed /TransferThis/ to be specified more than once. - - -2007/01/15 13:43:51 phil -Updated the copyright notices. -Fixed a reentrancy problem in wrapping objects obtained from C/C++ (thanks to -Giovanni Bajo for the fix). - - -2007/01/10 16:24:13 phil -Added support for __truediv__ and __itruediv__ by making them synonyms for -__div__ and __idiv__. - - -2007/01/07 17:33:58 phil -Hopefully fixed a bug in the generation of the typedefs table that wasn't using -the full name of foreign modules. - - -2006/12/28 16:58:57 phil -Fixed a bug in the sipResetCppHasRef() macro that breaks the /TransferBack/ -annotation. - - -2006/12/20 17:22:28 phil -Fixed a MacOS specific bug in create_wrapper() in the build system. - - -2006/12/20 15:13:08 phil -Applied a patch to sipdistutils.py from Giovanni Bajo to allow .sip files to be -used in the "depends" argument to setup(). - - -2006/12/16 16:25:30 phil -Fixed a bug in the build system that meant that lines in the top level mkspec -file were being ignored after the last include. - - -2006/12/09 23:44:19 phil -Released as v4.5.2. - - -2006/12/09 23:42:27 phil -Fixed a MacOS build problem caused by another change to Qt installs. - - -2006/12/09 18:33:42 phil -Released as v4.5.1. - - -2006/12/09 18:30:52 phil -Updated the NEWS file. -Fixed the internal build system for later versions of docutils. - - -2006/12/06 18:09:27 phil -"PyQt_PyObject" is now used instead of "PyObject *". -lamda functions can now be used as slots. - - -2006/11/26 18:19:36 phil -Fixed an incorrect assumption that if a Python wrapper of a C++ owned object -was being garbage collected then its Python children (ie. things it owns) -should also be garbage collected. It may be that the parent is a "temporary" -object (eg. the argument of a reimplementation of a virtual) but the children -are "permanent". The case in PyQt is the parent argument of -QAbstractItemDelegate.createEditor(). - - -2006/11/25 17:09:54 phil -PEP 353 fixes from Ulli. - - -2006/11/25 10:48:15 phil -Some "char *" to "const char *" fixes from Ulli. - - -2006/11/18 13:25:28 phil -Fixed a broken pointer bug in the API file generation. - - -2006/11/17 18:21:30 phil -Fixed a misleading error message when instantiating templates. -Fixed a bug generating global functions in API files. - - -2006/11/11 23:16:12 phil -Fixed a bug with virtual handlers when a module %Imports from two other -(independent) modules. - - -2006/11/04 22:07:32 phil -Released as v4.5. - - -2006/10/28 17:58:28 phil -The build system now handles .prl files on MacOS. - - -2006/10/27 17:15:09 phil -Changed NoDefaultCopyCtor to NoDefaultCtors. -Updated the NEWS file. - - -2006/10/22 16:38:19 phil -A fix for configuring QtAssistant in PyQt for Qt v4.2 on MacOS. -Added the NoDefaultCopyCtor class annotation. - - -2006/10/21 17:48:15 phil -Fixed a Python 2.4/2.5 change that was missed. -Added sip.setdeleted(). - - -2006/10/20 16:40:42 phil -Platform portability fixes from Ulli. -Fix for conditional includes in spec files from Ulli. -Qt4 module include directories are now searched before the main Qt4 include -directory. -Handle the change in debug libraries in Qt v4.2. - - -2006/10/15 18:54:40 phil -Allow virtual signals if the NoEmitters option is set. - - -2006/10/15 12:41:12 phil -Fixed a bug where the first argument to a global comparison operator was -mishandled if it was a pointer rather than a reference. - - -2006/10/13 16:28:11 phil -Improved the previous fix for the incorrect ctor exception. - - -2006/10/08 17:04:46 phil -Fixed bug where handwritten traverse and clear code wasn't being called for -derived classes. -Fixed an incorrect Python exception raised when a C++ exception is thrown by a -ctor. -The build system now displayed an error if a non-framework build of Python is -used on MacOS. -Untested fix for building a static module with MinGW. - - -2006/10/07 12:21:23 phil -Build system fixes for Qt v4.2.0 based on a patch from Matt Newell. - - -2006/09/30 19:20:12 phil -Fixes for building QtTest on Windows. - - -2006/09/24 0:09:37 phil -Taught the build system about QtTest. -Fixed a bug in the handling of namespaces split across multiple header files. - - -2006/09/23 18:40:03 phil -Added support for hooking into the C++ dtor from Python by implementing -__dtor__() from a patch by Jean Jacques Lecler. - - -2006/09/23 17:59:58 phil -Added sip.delete() (based on a patch from Jean Jacques Lecler) and -sip.isdeleted(). - - -2006/09/23 14:29:46 phil -Removed the -n flag to sip now I think I've decided how to change code -completion in QScintilla. - - -2006/09/22 18:17:25 phil -Backed out the check that abstract methods are virtual - because they don't -have to be. - - -2006/09/17 13:04:05 phil -Added support for pure virtual dtors. -Fixed a bug where abstract operators weren't flagging the class as being -abstract. - - -2006/09/03 13:05:16 phil -Defeated a GCC v4 warning message on generated code. - - -2006/08/17 17:06:30 phil -Minor code generation formatting tidyups. - - -2006/08/17 16:04:59 phil -Added argument type checking to sipRegisterIntTypes(). - - -2006/08/17 0:12:00 phil -Added sipRegisterIntTypes() to the private Qt support API so that PyQt4 can -implement Q_ENUMS and Q_FLAGS. - - -2006/08/05 17:48:43 phil -Added support for QAxContainer in the build system. - - -2006/07/19 19:52:25 phil -Updated the spec files from Qt v4.1.4. -Added (completely untested) support for embedding manifests for MSVC v8. - - -2006/07/16 12:38:09 phil -More Python v2.5 changes. - - -2006/07/15 22:27:26 phil -The sip module will now build against Python v2.5. (The 64 bit changes still -need to be done.) - - -2006/07/08 19:27:08 phil -Fixed the use of sys.lib in configure.py. - - -2006/07/06 22:17:58 phil -configure.py uses sys.lib if it is defined (for some 64 bit Linux distros). - - -2006/07/04 17:15:45 phil -Always call a dtor if there is one, even if we can't see how the instance could -have been created. - - -2006/07/01 11:20:03 phil -Fixed default arguments and C++ scoped names in the new API file handling. - - -2006/06/30 23:26:45 phil -Added the -n command line option (possibly only temporarily). -Changed the API generation so that it is more complete and uses Python types -rather than C/C++ types. - - -2006/06/29 22:54:54 phil -Added sip_config_args to sipconfig.py. -Added __hex__() to sip.voidptr. - - -2006/06/19 15:57:08 phil -More warning fixes from Ulli. - - -2006/06/17 10:48:34 phil -Changed the explicit C linkage to retain the benefit of using static. - - -2006/06/13 12:00:29 phil -Signals and slots are now const char * rather than char *. - - -2006/06/10 12:33:46 phil -Fixed the implementation of /TransferBack/ for virtuals. -Changed all API arguments that take a format string from char * to const char * -for Solaris. -Used explicit C linkage for all generated function calls when generating C++. -(May need more work in this area.) - - -2006/06/06 23:08:25 phil -Changed the XML handling of opaque classes. - - -2006/06/05 23:30:09 phil -Added support for opaque classes to the XML. - - -2006/06/03 23:19:33 phil -More XML generation changes. - - -2006/05/31 21:18:34 phil -More XML generation changes. - - -2006/05/30 10:39:52 phil -More XML generation changes. - - -2006/05/28 22:29:04 phil -More XML generation changes. - - -2006/05/25 20:44:55 phil -Fixed bug disconnecting Python signals. - - -2006/05/20 21:02:30 phil -More XML generation changes. - - -2006/05/20 10:50:32 phil -Backed out the change that treated "char" and "char *" as equivalent when -comparing Python signatures. (The former is different to the latter if it -appears first.) - - -2006/05/18 23:28:21 phil -More XML generation changes. - - -2006/05/16 23:27:00 phil -Tightened up on detecting clashing Python signatures involving strings and -longs. -Changes to the XML file generation. - - -2006/05/13 23:17:28 phil -Removed some Python API calls made after the interpreter is known to have gone. - - -2006/05/13 23:10:47 phil -Fixed a sip module bug that meant that the Python API might be called after the -interpreter had gone. - - -2006/05/13 17:18:43 phil -Fixed code generation bug with abstract operators. - - -2006/05/13 15:10:42 phil -Added %UnitCode. - - -2006/05/11 19:02:42 phil -Added sipExportSymbol() and sipImportSymbol(). -Bumped the API version number to 3.2. - - -2006/05/08 13:29:42 phil -Removed (hopefully) two new warning messages. - - -2006/05/07 19:28:35 phil -Added support for %ExportedHeaderCode. - - -2006/05/07 18:27:34 phil -Fixed bug in handling of virtuals with different Python and C++ signatures. - - -2006/05/05 13:54:51 phil -Fixes for compiler warnings and a couple of minor bugs from Ulli. -Deprecated %SIPNoEmitters and replaced it with %SIPOptions. -Added the RegisterTypes option so that appropriate classes are registered with -Qt automatically when needed - so PyQt4 doesn't need to implement -qRegisterMetaType(). - - -2006/05/05 12:23:00 phil -Fixed some compiler warnings. - - -2006/05/01 14:41:18 phil -More work on the XML generation. - - -2006/04/30 19:14:19 phil -Added the -m flag to generate the XML representation of the Pythonic API. - - -2006/04/28 20:49:53 phil -Replaced long long with PY_LONG_LONG for MSVC 6. - - -2006/04/27 8:01:56 phil -Fixed bug in handling multiple instances of the same namespace. -The build system allows Apple's Python to be used if there is also a later -python.org installation. -MacOS modules are now bundles rather than dynamic libraries and can now be -loaded by Pythons from python.org. -Released as v4.4.3. - - -2006/04/21 12:27:20 phil -Fixed the previous const mapped type fix. - - -2006/04/20 23:14:34 phil -Fixed the GUI enabled interpreter in sipconfig.create_wrapper() for MacOS. -Fixed static const mapped types. - - -2006/04/18 23:49:07 phil -Fixed the build system for when sys.prefix != sys.exec_prefix. - - -2006/04/16 11:17:30 phil -Added the export_all argument to the ModuleMakefile constructor of the build -system so that exports can be handled on a per module basis. This is needed to -get around a (not properly understood) problem with modules that wrap C++ -exceptions. - - -2006/04/15 19:21:04 phil -The build system now complains if a property is used in a spec file when no -properties have been defined. -Removed Qt specific properties from the solaris-cc and hurd-g++ spec files. -Fixed the disconnecting of short-circuited signals. - - -2006/04/08 19:54:38 phil -Fixed the build system to better support frameworks on MacOS. - - -2006/04/07 8:37:29 phil -Made sure that all uses of sipMappedType * in the API are const. - - -2006/04/06 10:40:18 phil -The sipconfig module now uses qt_data_dir (if set) to find the qmake spec files. - - -2006/04/05 12:27:06 phil -Merged v4.4.1 into the trunk. -SIP now properly detects duplicate Python signatures. - - -2006/04/03 19:27:34 phil -Released as v4.4.1. - - -2006/04/03 0:08:03 phil -Fixed a regression in the handling of __dict__. - - -2006/04/01 10:34:10 phil -Make the sip module's support for long long and unsigned long long conditional -on HAVE_LONG_LONG so that it will build with older compilers. - - -2006/03/29 10:17:22 phil -Removed extraneous brackets in generated code. - - -2006/03/28 13:35:38 phil -Fixed some C++ code wrongly appearing in C modules. - - -2006/03/25 16:58:15 phil -Fixed a regression in the handling of namespaces. - - -2006/03/24 22:24:29 phil -Documented sipModule and sipModuleDict as being available to -%PostInitialisationCode. -Released as v4.4. - - -2006/03/21 23:39:27 phil -Applied patch for sipdistuils.py from Giovanni. -Documented sipConvertFromNamedEnum(). -Wrapped types now define __reduce_ex__ and __reduce__ attributes set to None so -that pickle knows they can't be pickled. - - -2006/03/20 23:13:23 phil -Fixed the special handling of the __dict__ attribute so that it doesn't apply -to Python sub-classes of wrapped classes. - - -2006/03/19 14:21:56 phil -Documentation tweaks. -Generate sipSelf for ctor %MethodCode now that it's existence is documented. -Fixed a second place where slots with no underlying C++ instance might be -invoked. - - -2006/03/17 1:17:00 phil -Removed __unicode__ from the documentation. -Fixed a bug with virtual methods that returned a reference to a type that had -%ConvertToTypeCode. - - -2006/03/15 23:44:16 phil -Removal of a now redundant error message. -Fixed a leaking weak reference object. -Another attempt at fixing calling slots where the underlying C++ instance has -disappeared. - - -2006/03/14 22:46:48 phil -More const void * fixes. -Fixed bug with building debug modules using MinGW. -Fixed feature where too many names were being generated from imported modules. -SIP now handles nested imports properly and doesn't require all modules to be -explcitly imported. - - -2006/03/13 11:33:28 phil -Build system changes to support MacOS properly. -Fixed crash when %TypeHeaderCode was used outside of a scope. - - -2006/03/12 14:47:22 phil -Fixed calls to sipConvertFromVoidPtr() with a const argument. - - -2006/03/11 19:15:31 phil -Minor changes to sipconfig.py for PyQt4's pyqtconfig.py. - - -2006/03/11 15:14:31 phil -Fixed handling of generating code for the version before the first %Timeline -version. - - -2006/03/08 9:34:46 phil -Fixed a bug in the handling of QVariant * and PyObject * signal arguments. - - -2006/03/06 18:59:26 phil -Fixed a regression in handling of enums defined in an imported module. - - -2006/03/06 12:35:05 phil -Fixed bug in handling the typedef void hack. - - -2006/03/05 17:41:44 phil -Fixed bug with abstract classes with %ConvertToSubClassCode. -Reimplemented namspaces split across modules so that there is a single -namespace implemented in the original module. - - -2006/03/05 12:55:13 phil -Fixed missing #include for classes that aren't an immediate parent. - - -2006/03/04 17:55:49 phil -Fixed a regression in the wrappers around protected methods. - - -2006/03/04 10:48:35 phil -Suppressed the exception about the underlying object disappearing when calling -a Python slot. This is because we don't automatically disconnect Python slots. - - -2006/03/02 20:36:56 phil -Added sipLong_AsUnsignedLong() to work around a bug in PyLong_AsUnsignedLong(). - - -2006/02/26 23:19:31 phil -Fixed bug in handling class arguments with /Out/ specified. - - -2006/02/26 17:08:35 phil -Recognise NULL as a synonym for 0. -Some build system changes for Cygwin. -Fixed the deletion of temporary instances in catch clauses. - - -2006/02/26 13:56:56 phil -SIP now treats signed char as a type distinct from char. - - -2006/02/26 0:41:23 phil -Tore up the recent changes for handling cross module namespaces. A namespace -is now defined in each module it is used. That makes things easier to -implement and should be less confusing for the user. The API and data -structures should now be stable. - - -2006/02/25 21:08:24 phil -Fixed bug in handling of variables introduced in the previous commit. - - -2006/02/25 20:54:19 phil -Added support for variables defined in namespaces defined in other modules. - - -2006/02/25 19:59:46 phil -Completed the support for enums in namespaces originating in other modules. - - -2006/02/21 15:22:52 phil -Added the 't' and 'u' format characters to sipParseArgs(), sipParseResult(), -sipCallMethod() and sipBuildResult(). -unsigned and unsigned short are now implemented as Python long objects instead -of integer objects. - - -2006/02/19 16:43:02 phil -Implemented disconnects for universal signals. - - -2006/02/18 21:04:05 phil -Implemented support for signal arguments of type PyObject *. -Implemented support for shortcircuited Python signals (ie. just the name -without arguments) that will only work with other shortcircuited Python signals -and Python slots - bit don't need to do any conversions between Python and C++. - - -2006/02/17 10:59:46 phil -Fixed bug in the implementation of /TransferBack/ in virtual handlers. -Fixed bug in methods with a void result and a single /Out/ argument that was a -mapped type or class. - - -2006/02/16 18:24:46 phil -Fixed bug in generating code that called sipCallMethod(). -Updated the documentation where it was still referring to the legacy type -convertors. - - -2006/02/16 16:30:10 phil -Fixed bug in generated legacy mapped type convertor names. - - -2006/02/15 16:45:33 phil -Fixed bug that could easily result in deleting non-heap instances. - - -2006/02/13 20:04:02 phil -Fixes to PythonModuleMakefile. - - -2006/02/13 0:23:04 phil -Renamed the new sipCheckConvert functions to sipForceConvert functions. -Added the 'B', 'C' and 'D' format character to sipBuildResult() and -sipCallMethod(). -Removed the 'L' format character from sipBuildResult() and sipCallMethod(). -Added sipConvertFromInstance(), sipConvertFromNewInstance() and -sipConvertFromMappedType(). - - -2006/02/12 1:13:28 phil -Overhauled how %ConvertToTypeCode should be written - detail below. (Still need -to overhaul %ConvertFromTypeCode.) -Added sipCanConvertToInstance(), sipConvertToInstance(), -sipCheckConvertToInstance() and sipReleaseInstance(). -Added sipCanConvertToMappedType(), sipConvertToMappedType(), -sipCheckConvertToMappedType(), sipReleaseMappedType() and sipFindMappedType(). -Changed the order of the arguments to sipConvertToCppTransfer(). -Added the 'C' and 'D' format characters to sipParseResult(). -Changed the meaning of the 'J' and 'M' format characters in sipParseArgs(). -Removed the sipConvertTo_*() functions. -Removed sipConvertToCppTransfer(). -Took all of the None handling out of %ConvertToTypeCode. - - -2006/01/28 20:11:45 phil -Fixed the support for __hash__. - - -2006/01/26 16:39:44 phil -Added %SIPNoEmitters to stop SIP generating signal emitters for a module and -any module that imports it. -Changed the signal/slot support so that Python signals can be implemented with -proxies. - - -2006/01/20 22:36:17 phil -Fixed a bug in sipTransferTo() that caused some objects to be garbage collected -while ownership was being transferred. -Check that abstract methods are only ever called as bound methods. - - -2006/01/19 17:57:01 phil -Updated the documentation for sipConnectRx(). -The __dict__ attribute of a wrapper type now returns a regular dictionary -rather than a proxy (because PyDict_Next() doesn't iterate over proxies). - - -2006/01/14 16:40:04 phil -Fixed the searching of signal types. - - -2006/01/11 8:45:06 phil -The previous fix wasn't quite so trivial. - - -2006/01/11 8:17:58 phil -Added missing function prototype. - - -2006/01/10 20:12:59 phil -Fixed code generation bugs in new virtual handling code that was triggered by -PyKDE. -Build system changes for MinGW. -Added support for constrained bools. -Generate code to wrap static enum instances with inline code rather than -through tables (as is done with class instances) for Windows. - - -2006/01/09 19:42:45 phil -Changed the signatures of sipForceConvertTo_*() and sipConvertFrom_*() back to -their SIP 4.3 versions, deprecated them, and introduced the Transfer variants. - - -2006/01/09 17:49:19 phil -More build system changes for Windows. -Added the platform macro to sipconfig.py. -The default Windows platform Python 2.4 and later is now win32-msvc.net rather -than win32-msvc. - - -2006/01/08 15:59:48 phil -Various build system changes needed by PyQt4 on Windows. - - -2006/01/07 15:57:31 phil -Updated the spec files from Qt v4.1. -Added support for the $$() method of accessing environment variables in qmake -spec files. -sipdistutils.py fix from Giovanni. -Changes to the build system for the slightly different macro names on Windows. - - -2006/01/04 13:10:29 phil -Added support for the /NoDerived/ annotation. - - -2006/01/03 21:08:54 phil -Fixed bug in handling of delayed dtors. - - -2006/01/02 12:43:51 phil -Fixed another bug with the new handling of virtual function calls (where -re-implementations from another module weren't picked up). - - -2005/12/30 14:35:11 phil -Fixed bugs with the new handling of virtuals that caused recursions. - - -2005/12/29 19:02:18 phil -Taught the build system about the QtAssistantClient library. - - -2005/12/29 15:14:14 phil -Fixed bugs related to global operators with an enum as the first argument. - - -2005/12/28 19:34:37 phil -Added sipConvertToCppTransfer(). -Changed the signatures for the type convertor functions. -Added the 'L' format character to sipBuildResult() and sipCallMethod(). - - -2005/12/27 10:53:26 phil -Added support for the /DelayDtor/ class annotation to control the order of dtor -calls when the interpreter exits. -Fixed bugs with cast operators. - - -2005/12/26 10:59:30 phil -Fixed a documentation bug. -Slightly changed the declaration of the sipProtectVirt wrappers. - - -2005/12/24 17:33:39 phil -Class methods called as class.method(self, ...) is now equivalent to -this->class::method(...). Class methods called as self.method(...) is now -equivalent to this->method(...). -Introduced sipSelfWasArg and the sipProtectVirt wrappers in order to support -the above. - - -2005/12/22 19:13:05 phil -SIP no longer complains if a slot to be disconnected isn't actually connected -(and hopes Qt will then behave appropriately). - - -2005/12/19 17:43:03 phil -Backed out the recent change that ignored abstract specifications if the -methods wasn't virtual. - - -2005/12/19 14:52:41 phil -Various changes to the build system to better support Qt v4. - - -2005/12/18 15:24:36 phil -Added the PythonModuleMakefile class and create_wrapper() function to the build -system. - - -2005/12/15 15:11:02 phil -Internally renamed qtlib.cpp to qtlib.c. -Small changes to the internal build system caused by the move to SVN. -Removed SIP_BUILD from sip.h. - - -2005/12/12 19:47:19 phil -Ignore abstract specifications for non-virtual methods as GCC seems to do. - - -2005/12/11 22:51:51 phil -Fixed bug in the implementation of slot extenders. - - -2005/12/07 18:19:48 phil -Fixed the misleading exception raised when attempting to call a private -re-implementation. - - -2005/12/07 00:52:24 phil -Fixed the fundamentally broken #include dependency handling. - - -2005/12/05 09:57:22 phil -The sip module now leaves to the Qt support API to determine if a signal is a -Qt signal or a Python signal (so that PYSIGNAL can be dropped in PyQt4). - - -2005/12/04 16:35:05 phil -Fixed a bug with the expansion of class templates. - - -2005/11/30 19:00:57 phil -Made the parsing of default arguments able to handle template instantiations. -Fixed a bug in the handling of renamed enums. -Started the support for namespaces defined across modules. - - -2005/11/29 13:06:06 phil -Implemented the last pieces of cross-module type convertor support. - - -2005/11/26 22:10:57 phil -Fixed the internal build system for the latest release of docutils. -Fixed a bug in the parser that caused classes to sometimes appear to be -external when they weren't. - - -2005/11/25 17:43:01 phil -Exposed sipConvertRx() as part of the hidden Qt support API. -Added SIP_ANYSLOT to support the hidden Qt support API. - - -2005/11/24 17:23:25 phil -Finished the modified mapped type template handling. -Allowed SIP_SLOT and SIP_SIGNAL to have a default argument. - - -2005/11/23 21:51:04 phil -Made type expansions in template code aware of SIP generated names. -Started to modify the handling of mapped type templates (not yet finished). - - -2005/11/20 18:40:37 phil -Further refined the Python type comparisons. - - -2005/11/19 18:10:05 phil -Fixed the parsing of ellipsis arguments. - - -2005/11/18 23:23:39 phil -Made the selection of a suitable ctor when generating error values more likely -to find one without being explicitly told. - - -2005/11/18 18:02:04 phil -Fixed class numbering bug with external classes. -Fixed bug with protected enums used as arguments to virtuals. -Improved the comparison of Python signatures. - - -2005/11/17 18:04:33 phil -Completed the support for cross-module operators. -Started the support for cross-module operator casts. - - -2005/11/16 20:11:14 phil -Added support for operator casts of basic types. -Added support for the __long__ and __float__ Python slots. -Started to add support for operator casts of classes. - - -2005/11/16 17:16:18 phil -Added support for cross-module number operators. - - -2005/11/15 17:19:33 phil -Fixed a long standing bug related to default arguments. - - -2005/11/14 17:19:34 phil -Changed the Qt support API to pass the Python object when creating a new -universal slot. -More fixes for external classes. - - -2005/11/13 17:47:38 phil -Fixed bug in handling external classes (not yet right). - - -2005/11/12 10:21:24 phil -Updated the documentation regarding module names. - - -2005/11/12 10:15:09 phil -Added support for hierachies in module names. - - -2005/11/09 18:22:38 phil -Fixed the documentation error. - - -2005/11/09 17:58:26 phil -Passing None when an argument will be dereferenced now causes a type error -(allowing subsequent signatures to possibly succeed) rather than a conversion -error. This means QFileDialog(None) works. - - -2005/11/06 17:43:48 phil -Added support for external class declarations. -Template signatures can now include base types. -The arguments to function calls that are default values can now be expressions. - - -2005/11/03 22:25:39 phil -Removed the restriction that static methods cannot be Qt slots. -Argument names can now be given for the Qt signal/slot types. - - -2005/11/02 19:16:45 phil -Added support for SIP_PYTYPE. -Added support for signatures with variable numbers of arguments. -__getitem__() no longer requires %MethodCode. -Global unary + and - operators are now handled properly. -Fixed bug with nested templates. - - -2005/11/01 22:09:07 phil -Changed the Qt API to deal with the extra argument in connect() and -disconnect() in Qt4 and the way in which signal arguments are passed. - - -2005/10/30 18:04:19 phil -Added the sipdistutils.py script from Giovanni Bajo. - - -2005/10/30 11:23:23 phil -Fixed bug in error reporting when doing template instantiation. -Allow template types to be pointers (and the indirection is dropped). -/TransferThis/ can now be used in non-factory methods. -Removed the 't' format flag from sipParseArgs(). A pointer to sipSelf is now -passed which is updated. -Fixed clash of format characters in sipParseArgs(). -Fixed a couple of bugs with char * output arguments. - - -2005/10/24 16:58:17 phil -Applied fix from Giovanni Bajo to the build system where a macro was defined in -terms of another macro *and* additional values. - - -2005/10/23 16:02:18 phil -Changed the buffer interface support so that sipSelf is always passed in. -Changed the Qt interface to allow QObject.sender() to support Python signals. - - -2005/10/23 12:44:47 phil -Added the "user" member to the sipWrapper structure. -Added support for Python's buffer interface. - - -2005/10/16 16:07:19 phil -Debugged the support for mapped type templates. - - -2005/10/16 10:47:31 phil -Documented the use of mapped type templates. -Completed the implementation of mapped type templates. - - -2005/10/13 21:43:57 phil -Added parser support for mapped type templates. (Automatic instantiation not -yet implemented.) - - -2005/10/13 16:59:01 phil -Fixed an assumption that a type created by sip.wrappertype would always be -derived from sip.wrapper causing a segfault. (__metaclass__ might have been -used to invalidate the assumption.) - - -2005/10/12 21:10:17 phil -Fixed legacy C++ism from the Qt support hooks. - - -2005/10/11 21:12:02 phil -Moved the export module function to the start of the API table. (Not having -there from day one was a really, really stupid thing to do.) - - -2005/10/09 17:01:39 phil -Changed the handling of number slots to support the reverse operators. - - -2005/10/06 21:41:32 phil -Fixed bugs related to function arguments that were classes and had default -arguments that weren't function calls. - - -2005/10/06 20:24:43 phil -Removed longs, unsigned longs etc. from the tests for types that Python can -automatically convert. I think this needs looking at again as the current -tests are too simple minded. -Fixed some missing checks for constrained floats and doubles. - - -2005/10/05 15:39:40 phil -Added support for the int() cast in classes. -Debugged the support for template classes and global operators. - - -2005/10/01 11:24:21 phil -The C/C++ long long and unsigned long long types are now supported. - - -2005/09/30 23:48:16 phil -longs are now implemented using the Python long object. -unsigned longs are now handled separately. - - -2005/09/30 18:10:18 phil -Completed support for global operators with wrapped enums as the first -argument. - - -2005/09/29 17:56:05 phil -Template class definitions now have to use typename. -Started to add support for global operators that have wrapped enums as the -first argument. - - -2005/09/28 21:10:50 phil -A couple of fixes to the template support. - - -2005/09/28 16:05:16 phil -Added support for global operators (so long as the first argument is a class -wrapped in the same module). -Fixed a bug that prevented global functions with the same name being defined in -different modules. - - -2005/09/28 13:50:04 phil -Completed the support for template classes. - - -2005/09/27 21:16:14 phil -Started to add support for template classes. Not yet complete, but shouldn't -have broken anything. - - -2005/09/25 15:10:20 phil -Function arguments can now have names (although they are ignored). -The "explicit" keyword is parsed (but not yet used). - - -2005/09/22 20:21:36 phil -The generated sipconfig.py no longer contains any Qt version specific -configuration data and so can be shared between Qt configurations. -Added Configuration.build_macros(), Configuration.set_build_macros() and -parse_build_macros() to the build system API. -Added the macros argument to create_content() and create_config_module() in the -build system API. -Removed the dictname argument from create_content() in the build system API. -Removed the -l, -q, -x and -c command line flags to configure.py. - - -2005/09/19 21:14:35 phil -Started to refactor the build system so that sipconfig.py doesn't know about -Qt. - - -2005/09/17 15:19:17 phil -The build system now detects the open source edition of Qt v4. - - -2005/09/17 13:42:19 phil -The build system no longer passes QT_THREAD_SUPPORT to Qt v4. - - -2005/09/09 22:06:20 phil -Reverted to the v4.3 behaviour of the /Factory/ annotation in virtual methods. - - -2005/09/08 20:15:09 phil -Updated the documentation where it covers what Qt support is. -Universal slots no longer take part in cyclic garbage collection as they are -associated with C++ instances and not Python objects. - - -2005/09/07 20:53:06 phil -The Qt support framework is now C rather than C++. - - -2005/09/06 20:32:33 phil -Refactored the Qt support so that the sip module no longer makes any Qt calls -and so it can support PyQt v3 and v4 without needing to be re-compiled. - - -2005/09/04 20:47:42 phil -More build system changes for Qt4. - - -2005/09/04 17:57:02 phil -Small fix so it still builds in the internal development systems. - - -2005/09/04 17:49:32 phil -Started to update the build system to deal with Qt4. - - -2005/08/31 18:39:27 phil -Fixed slot handling bug caused when a slot was defined in a C++ super-class and -called from a wrapped sub-class. - - -2005/08/30 16:32:20 phil -Released as v4.3. - - -2005/08/28 11:42:13 phil -Clarifed the documentation regarding object ownership with the some of the -flags to sipBuildObject(). - - -2005/08/28 07:50:59 phil -Fixed bug in exception handling that caused a seg fault when generating code. - - -2005/08/22 20:39:42 phil -Backed out part of the last commit - the bit I wasn't sure about (seems I was -right). - - -2005/08/22 16:46:30 phil -Applied some HP-UX and AIX portability fixes from Ulli. - - -2005/08/21 11:54:53 phil -Fixed bug with new ownership code related to objects with no owning object. -(It breaks PyQt's semaphore.py example.) - - -2005/08/19 16:01:47 phil -Fixed a regression that caused the leak of universal slots. - - -2005/08/17 22:32:13 phil -Reimplemented the code that handles object ownership. -Deprecated sipTransfer() and sip.transfer(). -Added sipTransferTo(), sipTransferBack(), sip.transferto() and -sip.transferback(). - - -2005/08/16 16:35:21 phil -Backed out the garbage collector fix yet again. I now know what the real -problem & solution is. - - -2005/08/10 16:40:47 phil -Hopefully fixed the remaining problem with the cyclic garbage collector -support. - - -2005/07/27 17:17:29 phil -Put back in the possible fix for weak references and cyclic garbage collection -so that it can be selectively tested. - - -2005/07/27 12:08:18 phil -Fix for very subtle bug where an object being garbage collected was passed as -an argument to a Python method and its referenced count increased again. - - -2005/07/26 19:45:59 phil -Fixed a bug in the handling of __dict__ for wrapped instances. - - -2005/07/10 09:45:43 phil -Added support for sipCppRet in %ConvertSubClassCode. - - -2005/07/09 15:37:04 phil -Redid some of the handwritten code handling now I properly understand what -flex is doing. - - -2005/07/09 10:25:58 phil -Hopefully, finally, nailed the lexing of handwritten code. - - -2005/07/03 15:54:41 phil -Backed out some of the "fix" for Windows path separators. - - -2005/07/03 13:56:25 phil -Fixed segv trigged by a reference to __dict__ in an __init__ function before -the instance dictionary has been created. - - -2005/07/02 11:06:14 phil -Fixed handling of variables based on the pseudo PyObject based types. -Allowed all of the pseudo PyObject types to be variables (not just -SIP_PYOBJECT). - - -2005/07/01 17:06:50 phil -Updated the NEWS file. -Possibly fixed the problem with directory separators on Windows not being -escaped in generated #lines. (Actually in the last commit but I forgot to -mention it.) - - -2005/07/01 16:41:12 phil -Fixed a silly bug in the handling of sipExceptionRef. - - -2005/06/30 18:04:35 phil -Fixed a couple of bugs related to global anonymous enums. - - -2005/06/30 16:56:10 phil -Classes are properly marked as abstract if they have an abstract method visible -in their super class hierarchy. - - -2005/06/30 16:15:12 phil -Don't generate sipExceptionRef if it isn't used. - - -2005/06/30 15:53:27 phil -Fixed a bug in the handling of slots with implied connections caused by a -recent GC related fix. - - -2005/06/29 20:44:11 phil -Backed out the last fix for the cyclic garbage collector - it's wrong. Still -leaves the problem with weak references. - - -2005/06/29 15:00:30 phil -Fixed segv with the new exception support when class or undefined exceptions -where used in throw specifier. -The build file now doesn't include non-existant C++ files for exceptions. - - -2005/06/26 22:03:27 phil -Implemented the support for %Exception. -The parsing of handwritten code still seems to have problems in that blank -lines seem to be ignored. This seems to be a problem with flex (the rule -doesn't seem to be recognised for this condition). Ignore until somebody -complains. - - -2005/06/25 17:28:17 phil -Fixed a bug with In,Out arguments that had type convertors. - - -2005/06/25 15:47:51 phil -Fixed the cyclic garbage collector support for objects owned by C++. - - -2005/06/25 13:19:50 phil -Fixed the extra linefeed appearing in handwritten code. - - -2005/06/25 11:42:49 phil -Connections from emitters not owned by Python are now maintained if the Python -wrapper is garbage collected. - - -2005/06/23 16:46:33 phil -Allow comments on the same line after %End and (as a side effect) fix compile -problem on Windows (thanks to Ulli Berning). - - -2005/06/22 17:45:57 phil -Hopefully fixed blank lines in handwritten code. - - -2005/06/19 13:47:59 phil -Code blocks can now contain %. -Added parser support for the new %Exception directive. The implementation -hasn't yet been done - but it shouldn't break anything. - - -2005/06/05 08:28:05 phil -Fixed code generation bug in the new variable handling code. - - -2005/06/01 17:38:26 phil -Updated the documentation regarding %GetCode and %SetCode for static class -variables. - - -2005/05/31 20:34:53 phil -Added support for %GetCode and %SetCode. - - -2005/05/29 10:10:24 phil -Fixed silly bug in new -c flag to configure.py. - - -2005/05/28 15:55:11 phil -Added the -c flag to configure.py to allow the directory containing qconfig.h -to be explicitly specified. -Fixed a bug with assigning None to a class variable that was itself a class or -mapped type. -Fixed a bug when the (non-existent) cast function was being called for a C -structure. - - -2005/05/27 19:51:30 phil -sip.voidptr can now be instansiated from Python. -Added the ascobject() method to sip.voidptr. - - -2005/05/24 16:12:54 phil -Updated the documentation regarding the simple C example. - - -2005/05/24 14:55:09 phil -C structures can now have constructors and a destructor. -Updated the NEWS file. - - -2005/05/13 16:31:08 phil -Fixed simple code generation bug that didn't get triggered with PyQt. - - -2005/05/05 20:19:00 phil -%TypeHeaderCode can now be used in namespaces. -%TypeHeaderCode defined in an enclosing scope (class or namespace) now gets -automatically included for each sub-scope. - - -2005/05/04 18:32:09 phil -Added SIP_VERSION_STR to the sip module. - - -2005/04/30 09:51:27 phil -Fixed bug with protected const method (thanks to James Emerton). -Fixed the text of the exception raised by sipConvertFromSequenceIndex(). - - -2005/04/23 23:17:56 phil -Fixed the previous fix. - - -2005/04/23 18:11:37 phil -Fixed bug with shadow classes if explicit C++ signatures were duplicates. - - -2005/04/23 11:46:33 phil -Fixed a leak where virtual handlers return a mapped type or a class with -handwritten conversion code. (Thanks to James Emerton.) - - -2005/04/23 09:20:53 phil -Removed the caching of enum values in type dictionaries - it's the wrong thing -to do. - - -2005/04/17 10:49:17 phil -Fixed a bug preventing a class that couldn't be instantiated explicitly -(because of private ctors) being wrapped. - - -2005/04/14 19:04:14 phil -Further tweaked the text of the operator type exception. - - -2005/04/14 18:15:54 phil -Improved the text of the exception raised when some operators get bad argument -types. - - -2005/04/03 10:02:00 phil -Fixed a problem with the recent fix for leaking weak reference objects. - - -2005/04/02 23:22:10 phil -Wrapped types now support Python's cyclic garbage collector. -Added %GCTraverseCode and %GCClearCode to allow types to cooperate with the -garbage collector. - - -2005/04/02 18:54:31 phil -Abstract C++ classes can no longer be instantiated from Python - they can only -be sub-classed. -The above change needed the SIP API major version bumping. The minor version -number has been added to the main module data structure to (hopefully) reduce -the need for this in future. - - -2005/04/02 10:12:46 phil -Replaced the new /NoConvertor/ annotation with an extended implementation of -/Constrained/. - - -2005/03/25 20:17:44 phil -Dealloc functions are now generated whenever it might be possible to call the -C++ dtor, even if it is not possible to create a class instance from Python. -Fixed a bug where universal slots were never destroyed. - - -2005/03/25 14:26:46 phil -Fixed bug in sip.cast() when casting to a more specific type. - - -2005/03/17 17:56:18 phil -Updated the documentation regarding sip.transfer(), sipTransfer() and -/TransferBack/. - - -2005/03/10 17:52:22 phil -The C++ unary '+' and '-' operators are now handled correctly. - - -2005/03/10 17:34:09 phil -Added support for __pos__ and __abs__ (which meant bumping the API to 1.1). - - -2005/03/06 10:03:25 phil -Released as v4.2.1. - - -2005/03/04 17:37:36 phil -Fixed problem with sipWrapQVariant(). -Added support for multiple %Timelines in a single module. - - -2005/02/26 11:22:02 phil -Fixed problem with relative path arguments to configure.py. - - -2005/02/25 22:57:28 phil -Backed out the changes that attempted to detect exceptions in Python -re-implementations if virtual C++ methods. The restoration of PyErr_Print() -means that sys.excepthook is usefull again. - - -2005/02/20 08:45:42 phil -Fixed missing cast in generated code. - - -2005/02/19 15:22:53 phil -Fixed a bug with the new enum support when returning one as a tuple element. -Released as v4.2. - - -2005/02/18 19:00:37 phil -Backed out a supposed improvement in the handling of char * method results. -Added SIP_VERSION to the sip module. - - -2005/02/13 20:01:23 phil -Hopefully removed a couple of compiler warnings from the sip module. - - -2005/02/11 18:43:40 phil -Updated the NEWS file. -Released as v4.2rc2. - - -2005/02/11 17:20:15 phil -Updated the copyright notice in the documentation. -The recent fix in the object map code was broken. It should now be fixed -properly. - - -2005/02/06 14:39:02 phil -Thanks to Ulli Berning, by default the build system now only exports a module's -initialisation function. Added the -a flag to configure.py to restore the old -behaviour. - - -2005/02/04 18:29:16 phil -All modules are now stripped by default on installation. -Fixed a bug where namespaces' generated names were wrong so that they appeared -to go AWOL. - - -2005/01/29 10:15:15 phil -Synced build system with Qt v3.3.4. - - -2005/01/22 18:35:10 phil -Updated the NEWS file. -Released as v4.2rc1. - - -2005/01/16 13:07:00 phil -Minor fix to the documentation. - - -2005/01/16 00:12:33 phil -Fixed bug in new signal handling introduced when __module__/__name__ handling -was fixed. - - -2005/01/14 17:35:33 phil -Backed out the changes that relaxed the interpretation of enums. -Updated the copyright notices. -Fixed the __module__ and __name__ attributes for wrapped classes and enums. -sip.cast() will now cast to both sub and super-types of an instance. -Added support for debug builds to the internal build system. - - -2005/01/09 14:03:48 phil -Relaxed the new enum type checking so that an integer can also be used where a -named enum is expected. The previous rigorous type checking was likely to -break too much code. - - -2004/12/31 15:29:22 phil -Fixed problems handling signals that were emitted by a QSignal instance. - - -2004/12/30 21:51:11 phil -Fixed bug in the object map code where unused slots weren't being reclaimed -properly. - - -2004/12/30 14:18:27 phil -Fixed invalid format characters in calls to PyErr_Format(). - - -2004/12/26 18:51:39 phil -The sip module now complains about an argument with a bad type in preference to -having too many arguments - which is a more meaningful error message in that -context. - - -2004/12/26 12:26:30 phil -Fixed a typo in the mkcustom.py script. - - -2004/12/24 17:53:37 phil -Restored the support for moc in the build system for SIP v3. -Deprecated the -g flag to sip. -Fixed a code generation bug related to virtual operators. - - -2004/12/23 22:43:16 phil -Added the custom directory. -Added the section on custom interpreters to the documentation. - - -2004/12/19 19:27:35 phil -Make %PreInitialisationCode and %PostInitialisationCode subject to version -control. -Removed the calls to PyErr_Print() now that we detect exceptions in Python -re-implementations. -Changed the building of static modules so that they are used as libraries -(still need to document this). - - -2004/12/10 18:07:24 phil -Fixed bug where members of global enums weren't being added to the module -dictionary. -Fixed debug builds on Windows. -Fixed bug where invalid C code was being generated in the module init function. -Fixed bug where enums defined in a super-class from another module would -segfault when referenced. -Fixed bug that meant that the C++/Python object map would continually grow. - - -2004/12/05 11:27:27 phil -Fixed silly bug in the new typedef handling. - - -2004/12/04 23:51:39 phil -Virtual and abstract operators are now supported. -The __call__ slot no longer requires %MethodCode. -Python exceptions raised in virtual re-implementations of C++ methods are now -detected when they occur. - - -2004/12/03 18:59:33 phil -The /PyName/ annotation can now be applied to classes, variables and enums. - - -2004/11/28 10:57:58 phil -Added support for %PreInitialisationCode from Ulli Berning. -Added a check for name clashes with named enums. - - -2004/11/26 18:54:04 phil -Completed the support for named enums having distinct types. -The new signal support now handles typedefs (untested). - - -2004/11/21 10:38:30 phil -Build system fixes and README.HP-UX from Ulli Berning. - - -2004/11/19 19:05:02 phil -Initial support for named enums having distinct types. This should work as -before. The new types are not yet exploited. - - -2004/11/13 19:07:52 phil -Generalise the build system treatment of INCDIR and LIBDIR to INCDIR* and -LIBDIR*. - - -2004/11/13 18:59:33 phil -Fixed a feature where a factory function with a /TransferThis/ would always -keep a C++ pointer, never finding out it was invalid, and mistakenly recognise -the address when it was re-used. - - -2004/10/30 13:44:50 phil -Fixed bad bugs in new slot proxy handling. -Exposed the voidptr, wrapper and wrappertype types in the sip module. -Updated the documentation. - - -2004/10/06 22:36:38 phil -The new signal handling now supports mapped types. - - -2004/10/05 07:56:53 phil -Revert to a C-style cast for protected enums for some older compilers. - - -2004/10/02 16:23:00 phil -Fixed some warning messages. -SIP v4.x no longer supports Qt v2.x and earlier (use SIP v3.x). -Unrecognised signal argument types are now converted to NotImplemented rather -than causing connections to fail. -Fixed the new signal handling for Qt v3.0.x. -The new signal handling has now been tested on Windows. - - -2004/10/01 16:59:42 phil -Initial support for the new dynamic signal handling that allows previously -unknown signals to be connected to Python callables (needed for ActiveX -support). At the moment mapped types and enums aren't (yet) supported. Qt -versions 1 and 2 aren't (yet) supported. Untested on Windows. - - -2004/09/29 18:31:22 phil -Fixed significant bugs in the way the metatype was working. Operators are now -properly inherited in sub-classes of wrapped classes. - - -2004/09/24 16:56:23 phil -Released as v4.1.1. - - -2004/09/23 20:46:59 phil -Really fixed the previous problem this time. The return type is ignored, but -the re-implementation must be in a sub-class and not a different branch of the -class hierarchy. - - -2004/09/23 19:04:52 phil -Fixed a problem with classes with a virtual and a non-virtual with the same -signature but different return types in the hierarchy. - - -2004/09/23 17:27:51 phil -Fixed an incompatibility accidentally introduced with v4.1. - - -2004/09/21 12:21:20 phil -Minor build system fix for tmake. - - -2004/09/21 11:00:39 phil -Improved the test for the + and * operators context again - the previous change -seems to have got lost. -Added the /Numeric/ annotation to give more control over the above test. - - -2004/09/20 18:18:16 phil -Fixed a problem with deleting const instances. -Released as v4.1. - - -2004/09/15 08:46:45 phil -Fixed bug with arguments that are const simple types. - - -2004/09/14 07:31:13 phil -Updated the NEWS file. -Released as v4.1rc1. - - -2004/09/11 17:25:12 phil -Improved the test to see if the + and * operators should mean concat and repeat -rather than add and multiply. - - -2004/09/10 22:33:28 phil -Re-implemented some of the virtual method handling so that the return type is -ignored when comparing signatures. Not sure it is completely correct yet, but -PyQt seems to be fine. - - -2004/08/25 19:17:59 phil -Fixed const bug - only MSVC complains. - - -2004/08/24 17:32:39 phil -Fixed a bug in the support for protected classes. - - -2004/08/23 22:25:51 phil -Added limited support for protected classes (sufficient for immediate -requirements). - - -2004/08/22 10:16:38 phil -Fixed a bug with access controls in nested classes. - - -2004/08/21 14:12:40 phil -Added the cast() function to the sip module. - - -2004/08/19 22:31:48 phil -Added the /Abstract/ class annotation. -Updated the documentation. - - -2004/08/17 17:56:55 phil -Added support for typedefs that define pointers to functions. - - -2004/08/17 13:58:53 phil -A method that starts a new thread will now make sure that a single thread state -is created - rather than forcing PyGILState_Ensure() to create a new one each -time. - - -2004/08/17 09:24:07 phil -Fixed bug in the internal build system. - - -2004/08/15 23:35:20 phil -Updated the build system from Qt 3.3.3. -Added README.Fink. - - -2004/08/04 14:05:57 phil -Fixed the previous fix. - - -2004/08/04 12:53:29 phil -Fixed a bug where arguments passed to sipParseArgs() may have been const. - - -2004/08/03 16:23:10 phil -The SIP_PYCALLABLE type now supports the /AllowNone/ annotation. -Fixed a documentation bug. - - -2004/08/02 15:28:30 phil -Mostly fixed a problem where a virtual handler without code was being used in -preference to one with code. -More type information is supplied when calling the default constructor. -Fixed a bug with protected enums as arguments to protected methods. -Handle protected abstract methods properly. - - -2004/08/01 18:08:36 phil -Fixed another typo in the documentation example code for %VirtualCatcherCode. - - -2004/08/01 17:55:34 phil -Fixed a typo in the documentation example code for %VirtualCatcherCode. - - -2004/08/01 08:55:03 phil -Added support for the threaded version of Qt/Embedded to the build system. - - -2004/07/27 22:00:24 phil -Added support for MSVC.NET to the build system. - - -2004/07/19 18:42:48 phil -Fixed a bug in sipconfig.read_version() so that version strings with embedded -spaces are handled properly. - - -2004/07/16 21:50:12 phil -Change to the internal build system as Gentoo has prefixed the names of the -docutils binaries. -A few trivial changes to the documentation. - - -2004/07/06 08:12:25 phil -Released as v4.0.1. - - -2004/07/05 16:12:02 phil -Fixed a bug where dtors could be calling Python functions after the interpreter -had been finalised. - - -2004/07/05 10:48:04 phil -Backed out the previous fix for functions that used /TransferThis/ and -/Factory/ and fixed it properly in the sip module. - - -2004/07/05 09:18:44 phil -Fixed bug for methods that used /Factory/ and /TransferThis/. - - -2004/07/02 07:27:56 phil -Fixed problem with internal build system. - - -2004/07/01 12:38:43 phil -Attempts to wrap a NULL pointer now return None rather than raise an exception. -Minor documentation fix. - - -2004/06/30 22:36:17 phil -Fixed a bug in the build system related to libraries. - - -2004/06/23 14:01:38 phil -Released as v4.0. - - -2004/06/21 22:42:42 phil -Switched the SIP4 branch to the trunk. (SIP v3 is now on its own SIP3 branch.) - - -2004/06/20 21:45:18 phil -Completed the documentation. - - -2004/06/15 18:22:26 phil -Added more documentation. SIP pseudo-types and annotations are now complete. - - -2004/06/11 17:32:42 phil -Deprecated the 'L' and 'K' format characters to sipParseResult(). -Added more documentation. The API for handwritten code is now complete. - - -2004/06/09 16:28:20 phil -Added more documentation. The directives section is now complete. - - -2004/06/07 19:44:22 phil -Added more documentation. -Added the transfer() function to the sip module. - - -2004/06/06 17:47:39 phil -A few changes to the new wrapinstance() and unwrapinstance() functions. - - -2004/06/05 17:30:45 phil -Added some more documentation. -Added the wrapinstance() and unwrapinstance() functions to the sip module. - - -2004/06/04 21:32:52 phil -Added some more documentation. - - -2004/05/30 19:05:14 phil -Fixed another benign bug in the build system. - - -2004/05/30 18:06:00 phil -Fix minor bug in the build system. - - -2004/05/27 22:00:37 phil -Updated the TODO list. -Added support for Qt v2 non-commercial to the build system. -Tidied up unused parameters, variables etc. -Added support for the Borland compiler to the build system. - - -2004/05/22 17:41:41 phil -Released as v4.0rc4. - - -2004/05/15 22:33:35 phil -Operators will now recognise return values that have already been wrapped. - - -2004/05/14 06:26:35 phil -Fixed a bug where the wrong virtual handlers were being used from imported -modules. - - -2004/05/10 20:10:27 phil -Fixed bugs related to generating calls to sipBuildResult(). - - -2004/05/04 16:00:17 phil -Fixed the handling of .prl files. - - -2004/05/01 17:10:27 phil -Fixed a bug with virtual methods returning a class reference. -Fixed a bug with hasattr() of a sip.wrapper type. - - -2004/04/30 21:51:10 phil -Fixed missing const_cast in variable handlers. -Fixed missing #includes for classes used in global functions but defined in -other modules. - - -2004/04/24 22:46:22 phil -Suppress the const and & when on the error return path for abstract functions. - - -2004/04/24 09:07:33 phil -Sync (again) to SIP v3 build system. - - -2004/04/24 08:42:38 phil -Sync the build system with SIP v3. - - -2004/04/21 19:06:09 phil -SIP now builds using MinGW. - - -2004/04/19 21:57:51 phil -Changes to the build system to support MinGW - not yet complete. - - -2004/04/18 15:45:41 phil -Added support for the evaluation version of Qt. - - -2004/04/11 11:41:09 phil -Reverted the recent change to sub-class convertors - the original code was -correct. - - -2004/04/10 18:17:30 phil -Fixed a bug with legacy GIL management when the -g and -e flags were given. - - -2004/03/30 22:48:17 phil -Fixed a bad bug that meant that sub-class converters weren't working properly. - - -2004/03/29 17:47:56 phil -Fixed crash when an argument was a non-const mapped type with a non-zero -default value. - - -2004/03/17 23:56:40 phil -Fixed a bug where /ArraySize/ was broken for long (or short) types. - - -2004/03/16 18:14:48 phil -Released as v4.0rc3. - - -2004/03/15 23:53:21 phil -Added some more documentation. - - -2004/03/13 10:20:34 phil -Fixed a problem with const struct pointers and MSVC .NET. - - -2004/03/12 23:15:25 phil -Fixed bugs where opaque classes were assumed to have a default ctor. - - -2004/03/10 18:30:17 phil -Fixed incompatibility with non-standard MSVC. -#defines are now generated for enabled features. - - -2004/03/06 15:39:24 phil -Fixed problem with slot arguments being ignored for anything other than complex classes. - - -2004/03/06 01:07:38 phil -Fixed problem with static methods with a SLOT argument. - - -2004/03/05 18:25:13 phil -Improved the support for resolving multiple non-virtual base classes by -removing the need for the hack for PyKDE. - - -2004/03/04 23:02:57 phil -Added support for resolving multiple non-virtual base classes. - - -2004/03/03 21:35:54 phil -Fixed a build system problem when DEFINES had more than one value. - - -2004/03/02 21:02:53 phil -Fixed a bug where private copy ctors in super-classes might not be detected -properly. -Fixed __str__() after breaking it when trying to fix inherited operators. - - -2004/03/01 23:50:14 phil -Fixed problems with classes containing private dtors. - - -2004/02/29 19:57:04 phil -Fixed a build system problem caused by copying a file from SIP v3 to the wrong -place. - - -2004/02/29 19:51:52 phil -Updated build spec files from Qt v3.3.1. -Updated the internal build system to exploit distcc. -Fixed small bug in configure.py. -Fixed a bug where operators were not inherited by wrapped C++ sub-classes. - - -2004/02/16 23:36:08 phil -Fixed problems in the new build system with spaces in directory names. -Updated the documentation to reflect the (small) change in the build system -API. - - -2004/02/15 22:33:16 phil -Added some more documentation. -Updated the build system from SIP v3. - - -2004/02/11 19:25:24 phil -Added some more documentation. -The new build system now supplies a sensible context specific default if -install_dir is None. -Fixed a bug when sipSelf was used in handwritten code. - - -2004/02/08 12:17:13 phil -Backed out the last change relating to ctor argument types - it was a feature, -not a bug. - - -2004/02/07 23:58:51 phil -Fixed bug in validating ctor argument types. - - -2004/02/07 17:37:36 phil -Added Ulli Berning's patch to the build system to read Qt's .prl files. This -should mean that PyQt should build against a static Qt library. - - -2004/02/05 23:41:04 phil -Change to the internal build system so that sip compiles under Windows without -a hacked version of flex. -Static C++ class instances are now wrapped with inline code rather that through -a table. Hopefully this works round a problem reported by Ulli Berning with -static linking under Windows due to C++ not defining the order in which static -instances are instantiated. - - -2004/01/31 23:08:41 phil -Virtual handlers now respect the /Factory/ and /TransferBack/ flags. -Updated the spec files from Qt v3.3.0. - - -2004/01/29 19:20:49 phil -Windows build system changes from Ulli Berning. - - -2004/01/27 23:50:29 phil -Fixed bugs with handling class references as /Out/ arguments. - - -2004/01/18 15:14:49 phil -The build system configuration files are now part of the CVS tree rather than -being copied in from the local machine when building. - - -2004/01/18 14:24:44 phil -Fixed a compiler warning message in the SIP module. -Fixed a bug where #includes weren't being generated when only needed by -operators. - - -2004/01/12 22:13:14 phil -Fixed the corrupt #line directives when joining files. -Released as v4.0rc2. - - -2004/01/11 11:58:50 phil -Fixed bug where the header files needed by static namespace methods weren't -being #included. - - -2004/01/10 17:41:34 phil -Fixed a bug with static methods that connect to slots. - - -2004/01/05 23:19:33 phil -Fixed a bug handling some /In/ argument types. -Fixed a bug that prevented a namespace's methods from being generated. - - -2004/01/04 18:53:08 phil -Minor updates to the build system. -Completed the build system documentation. - - -2004/01/02 18:41:28 phil -Minor changes to the build system. -Added some more documentation. - - -2003/12/31 16:42:50 phil -Fixed problem with virtual methods that return references. - - -2003/12/29 10:26:38 phil -Fixed namespace related bug when typing sipCpp in ctors. - - -2003/12/28 19:30:55 phil -Change to the build system to only use -soname for SIP v3.x (so MacOS/X should -work again). - - -2003/12/28 13:30:36 phil -Fixed problems with thread handling. The semaphore.py example now works -properly again. - - -2003/12/27 15:42:05 phil -Build system changes based on patches from Ulrich Berning. - - -2003/12/26 19:30:25 phil -Fixed bug where the not all .h files were being #included for signal -signatures. - - -2003/12/23 08:14:37 phil -Added support for LITERAL_WHITESPACE in build system spec files. -Added support for macros in braces in build system spec files. -Made sure that trailing spaces in macros don't get lost. - - -2003/12/21 17:29:10 phil -Implemented sip.voidptr.asstring(). - - -2003/12/21 12:57:43 phil -We now distinguish (automatically) between add and mul when applied to numbers -and sequences because they have slightly different APIs. -The sequence repeat and in-place repeat slots now don't convert their integer -argument to a Python object. -Number slots now support new-style numbers. - - -2003/12/16 20:00:33 phil -Changed the documentation so as not to suggest using -fno-rtti as it's bad -advice if you are using KDE. - - -2003/12/14 20:53:23 phil -Make sure we don't lie to Python by saying we support new-style numbers when we -don't (yet). -Number methods return Py_NotImplemented rather than raise an exception. -Fixed a reference count bug in sipParseArgs(). - - -2003/12/11 22:29:33 phil -configure.py now doesn't complain if environment variables in the spec. files -aren't defined (ie. $QTDIR). -Properly defined setSetBool(). -Added the help about the -e flag to configure.py. - - -2003/12/11 20:03:32 phil -Changed the new build system to use LFLAGS_SONAME instead of RPATH for modules. - - -2003/12/10 18:21:10 phil -Fixed bug in configure.py that prevented empty build macros from being -overridden on the command line. - - -2003/12/09 23:02:51 phil -Fixed bug with operators in classes in namespaces. -Fixed bug with sub-class convertors and namespaces. -Fixed problems with multi-dimensional __getitem__, __setitem__ and __delitem__. - - -2003/12/06 21:04:17 phil -Released as v4.0rc1. - - -2003/12/06 21:00:25 phil -Fixed problem with new build system when Qt support is disabled. - - -2003/12/06 20:21:02 phil -Fixed a bug in building a static module with the new build system. - - -2003/12/05 19:42:58 phil -Fixed a problem with methods that had an abstract version in the super-class -hierarchy. - - -2003/12/04 19:36:13 phil -Changed the new build system to handle Borland a bit better. - - -2003/12/04 00:16:19 phil -Fixed a bug when connecting to a Python callable that is actually a wrapped C++ -method. - - -2003/12/03 19:00:41 phil -Make sure that the instance dictionary of a type exists. - - -2003/12/02 21:28:11 phil -Fixed a bug in the modified object map code. This fixes the last outstanding -problem with user's test cases. - - -2003/12/02 18:56:03 phil -Fixed build problem on MacOS/X where it thought multiple -framework flags were -unnecessary duplicates. - - -2003/12/02 00:02:17 phil -Changed the naming of names so they don't change when other names are added or -removed. -Added the start of the documentation. -Several tidy ups to the object map code of the sip module. -Changed the implementation of virtual handlers as it was keeping results alive. -sipParseArgs() no longer garbage collects the result object being parsed. -Add $(DESTDIR) to generated Makefiles. - - -2003/11/25 23:09:12 phil -Fixed silly typo in configure.py. - - -2003/11/25 18:45:30 phil -Fixed build system bug in handling line continuations in spec files. - - -2003/11/24 23:21:19 phil -Minor code tidy up in the sip module. - - -2003/11/24 21:55:20 phil -Cleared any exception before returning Py_NotImplemented. - - -2003/11/23 17:02:53 phil -More build system changes. PyQt now builds under the commercial and educational -versions on Windows. -Released as v4.0pre4. - - -2003/11/22 20:54:44 phil -Windows related changes to the new build system. -Removed some of the old licensing stuff. - - -2003/11/22 10:18:02 phil -Fixed bug with the build file when not concatenating sources. -Make sure the proxy header file #includes qobject.h. -Successfully builds PyQt for the Zaurus. - - -2003/11/22 00:52:15 phil -Fix code that generates warning message when building PyQt for Qt v2. - - -2003/11/22 00:06:43 phil -More changes to the new build system related to building Qt v2. - - -2003/11/21 23:06:56 phil -More changes to the new build system. Tested with Qt Professional on Linux. - - -2003/11/21 07:34:16 phil -Renamed %Build back to %Makefile and deprecated it for SIP v4. -Added the -b flag and removed the -m flag. -Fixed the new build system so that it will build PyQt under Linux. - - -2003/11/16 21:03:12 phil -Changed the build system to generate Makefiles (and dumped SCons). DO NOT USE -TO TRY AND BUILD PyQt UNTIL FURTHER NOTICE. - - -2003/11/15 11:20:50 phil -More changes to the new build system. - - -2003/11/13 19:42:15 phil -More changes to the new build system. - - -2003/11/13 13:12:10 phil -New build system changes. PyQt now builds correctly on Linux. - - -2003/11/12 22:24:23 phil -Updated the new build system. -Filenames given to %Build no longer need to have an extension. -Added the -j flag to generate concatanated source files. -Changed the name of the header file containing the proxy class to conform to -SCons way of doing things. -Fixed the handling of __call__, __cmp__, __neg__ and __invert__. - - -2003/11/05 20:31:25 phil -Changes to the new build system for PyQt. - - -2003/11/04 17:50:20 phil -Tidying up of the new build system. The sipconfig.py module has better support -for non-SCons build scripts. - - -2003/11/03 22:56:38 phil -Removed the old build system. -Added the $L macro to generate the list of source files as a Python list. - - -2003/11/03 19:44:27 phil -More changes to the new build system. It now seems to work Ok for SIP, but not -yet tested under Windows. - - -2003/10/30 19:18:02 phil -Added the start of the new SCons based build system. - - -2003/10/29 13:50:47 phil -Added "x11" to the default configuration for non-Windows, non-Mac. -Make sure active virtual handlers don't look for Python methods after the -interpreter has gone. -Don't create a overwrite an instance dictionary when a wrapped object's -__init__ method is called. - - -2003/10/28 11:08:25 phil -Released as v4.0pre3. - - -2003/10/27 23:24:07 phil -Completed the support for pointers and references to base types. - - -2003/10/26 22:52:29 phil -Added support for handling functions that return values via pointers and -references. (Virtual functions not yet handled.) - - -2003/10/24 08:35:18 phil -Added the -g flag and the /ReleaseGIL/ option to allow fine control over the -release of the GIL. - - -2003/10/23 18:28:27 phil -Removed deprecated macros from handwritten code. -Renamed %Makefile to %Build. -Renamed %PostInitialisationC++Code to %PostInitialisationCode. -Renamed %HeaderCode to %TypeHeaderCode or %ModuleHeaderCode depending on the -context. -Renamed %C++Code to %TypeCode or %ModuleCode depending on the context. -Allow structs within classes. -Added %CModule - SIP can now wrap C libraries as well as C++ libraries. - - -2003/10/22 18:42:08 phil -The object mapper now checks for super-classes and sub-classes when determining -if an C++ pointer has already been wrapped. -%Import, %Include and %OptionalInclude can now take a relative (UNIX style) -pathname. The directory containing the file will also be searched for files -that it itself includes or imports. - - -2003/10/21 16:41:32 phil -Fixed a bug in the mapping of C++ addresses to Python objects that was probably -causing the occaisional "random" "underlying C++ object has been deleted" -exception to be raised. -Fixed a bug in sipconfig.py which meant that PyQt modules for MacOS were -misnamed. - - -2003/10/21 13:38:47 phil -Added support for namespaces - SIP v4 should now be as functional as SIP v3. - - -2003/10/20 18:51:21 phil -More MacOS/X related changes. -More Windows porting changes. -Revert to SIP v3 behaviour that allows wrapped methods and enums to be -overwritten in an instance. -Removed many warning messages when compiling the sip module with -Wall. -Generated code now compiles without warning messages. - - -2003/10/19 19:46:35 phil -Initial changes the build system to handle the Mac. -Portability fixes for Windows. - - -2003/10/19 10:21:37 phil -Now uses the new GIL functions (see PEP 311). This means it is no longer -necessary to manage the GIL exactly right in handwritten code and makes it more -likely that code will work with non-SIP generated extension modules that don't -handle the GIL properly (ie. Boost). - - -2003/10/18 16:42:40 phil -Completed support for class variables. - - -2003/10/17 16:45:47 phil -Fixed a bug with ctors that had a Qt slot in their argument list (QToolButton -is the only example in Qt). -Tidied up the public sip.h file a little bit. -Fixed the handling of common strings so that there are no name clashes between -modules. This means that modules can be builtins of the interpreter. -Renamed %VariableCode to %AccessCode. -Started on support for variables. - - -2003/10/16 15:52:11 phil -Added support for dir() of a wrapped type. -Changed the API to sipEmitToSlot() so that it takes the arguments on the stack. -Virtual catchers now use sipCallMethod(). -Released as 4.0pre1. - - -2003/10/15 18:21:19 phil -Slot handlers are now only installed for slots that have actually been defined. -This fixes the problem with QPopupMenu. The problem with quickly moving the -cannon in the tutorials also seems to have gone away. -All examples now appear to work. -All unit tests work except for QString and QStringList. - - -2003/10/14 22:37:30 phil -Added sipTrace() to the module API. -More debugging - all tutorials mostly work (except for an odd problem when -dragging the cannon) and some of the examples (except for a problem with -QPopupMenu). - - -2003/10/11 21:58:49 phil -More debugging - tut7.py now works. - - -2003/10/09 19:12:47 phil -Various changes so that PyQt now compiles. - - -2003/10/07 18:55:10 phil -Fix for protected enums as arguments to protected methods. -Removed the 'O' and 't' format characters from sipParseArgs(). -Removed sipBadVirtualResultType() from the module API. -Added sipBadCatcherResult(), sipCallMethod() and sipParseResult() to the module -API. -Added support for /TransferBack/ for function results. -Added support for %VirtualCatcherCode. -Removed support for %VirtualCode. - - -2003/10/04 14:54:16 phil -Added SIP_VERSION and SIP_BUILD to sip.h. -Removed the 'K' format character from sipParseArgs(). -Added the 'b' format character to sipParseArgs(). -Added support for the /GetWrapper/ option flag. -Added support for /GetWrapper/ to the 'J' format character to sipParseArgs(). -Added sipBuildResult() and sipClassName() to the module API. -Renamed sipTransferSelf() to sipTransfer(). -Added support for SIP_SLOT, SIP_PYCALLABLE and SIP_QOBJECT. - - -2003/10/01 14:01:21 phil -sipParseArgs() now handles a single argument as well as a tuple. -Removed the last vestiges of %MemberCode support. -Added support for explicit C++ signatures. - - -2003/09/28 12:06:00 phil -Fully implemented Python special methods in the sip module. -Added the SIP_PYTUPLE type. - - -2003/09/26 23:38:35 phil -Added support for the SIP v3 slots. -Added /AllowNone/ to arguments. -These changes were in the previous commit but I forgot to add them to the log. - - -2003/09/26 23:36:18 phil -Added support for %MethodCode. -Added -w flag to enable warnings. -Added the SIP_PYLIST and SIP_PYDICT types. -Added PreHook and PostHook support to ctors. - - -2003/09/21 12:08:00 phil -Ported all outstanding fixes from SIP v3. - - -2003/09/20 21:32:08 phil -Ported the exception support from SIP v3. - - -2003/09/19 15:31:16 phil -The build system is now a copy of the one from SIP v3. -Fixed bugs related to sub-classing wrapped types. -Implemented the __str__slot. -Added the SIP_PYSLICE pseudo-type. -Added support for empty enum definitions. -Added SIP_VERSION_STR to sip.h -Added support for the 'L' format character. -Added support for virtual dtors. -Added dupport for %VirtualCode in dtors. -Added operator support in the parser only. - - -2003/04/15 17:56:27 phil -Name strings are no longer shared between modules. -PyQt now imports - non-lazy methods and handwritten code still to do. -Python v2.3 is now required. - - -2003/04/14 23:39:00 phil -All of PyQt should now compile. -Attribute handling is working (except for variables and non-lazy methods). -Adding static class instances fails because we are currently relying on static -ctors. - - -2003/04/13 12:37:49 phil -PyQt now compiles (except for the qtnetwork module because it includes nested -classes.) - - -2003/04/10 18:49:45 phil -Lots of changes moving towards implementing new-style classes. sip compiles -but, other than that, everything is broken. - - -2003/04/05 17:32:11 phil -Fixed a bug where templates weren't being parsed properly. -Make sure classes only appear once in a hierarchy. - - -2003/04/04 10:36:49 phil -Added the %e format charcter to sipParseArgs() to handle enums. -Removed all remaining inter-module dependencies. PyQt now builds and loads. - - -2003/04/01 20:44:04 phil -Added support for the educational version. -Added the -r and -t flags to build.py based on patches from Hans-Peter Jansen. -Changed the format of symbolic names from sipName_module_name to sipName_name. - - -2003/03/31 22:29:31 phil -Many more changes to eliminate inter-module dependencies. - - -2003/03/26 22:23:43 phil -Fixed all the remaining dependencies on the old-style SIP API. -Many other bug fixes. -sipQt.h is no longer needed. - - -2003/03/25 17:51:28 phil -Fixes so that PyQt now compiles - but modules do not yet load because of -remaining symbol dependencies. - - -2003/03/25 12:33:33 phil -Converted the remaining old-style API calls to the new style. - - -2003/03/24 19:49:01 phil -Moved another load of functions from the old-style API to the new-style API. - - -2003/03/23 13:34:27 phil -Forward ported the fixes for private and protected dtors. -Forward ported the -a flag for generating Scintilla API files. - - -2003/03/16 16:21:01 phil -Forward port the latest handling of the Python version number in build.py. -Forward port the cast fixes for PyString_FromString(). - - -2003/03/01 14:42:24 phil -Forward ported all the recent changes to SIP v3. - - -2003/01/25 11:09:39 phil -The names and sub-class convertors are now part of the new API. -The sub-class convertors are now generated in the main module code instead of -in the class file. - - -2003/01/20 08:10:53 phil -Added SIP_MAJOR_NR. -The values of sipClass_* are no generated for the new API. - - -2003/01/17 19:40:52 phil -Removed the external API header file. -The Python stub file is no longer generated. -The instance variable hierachy tables are no longer needed. - - -2003/01/14 09:41:59 phil -The module APIs now have an optional version number so that imports of -incompatible modules can be detected. - - -2003/01/12 22:17:40 phil -Added the table of modules to import to the main module definition. -The list of classes is now ordered so that no class appears before any of its -super classes. - - -2003/01/05 15:54:32 phil -Make sure that sipPyThis is always initialised in case a C++ ctor calls one of -its own methods that has been re-implemented in Python. - - -2003/01/04 17:16:41 phil -Removed %ExposedFunction and %PythonCode. -%PrePythonCode is now a no-op. -Removed the -p command line flag. -SLOT(), SIGNAL() and PYSIGNAL() are no longer generated by SIP. -Removed the SIP_EXTERN/EXPORT/IMPORT nonsense in the module. -Added the generation of the .h file that defines a module's external API. - - -2002/12/28 17:37:00 phil -The start of development of SIP v4. -Dropped support for Python earlier than v2.2 and Qt earlier than v3.0. -Start of the changes needed to make the SIP module a pure Python module rather -than a hybrid module and shared library. - - -2002/12/11 13:51:00 phil -Ensure that generated Makefiles have a later timestamp than the project file. -Released as v3.5. - - -2002/12/10 23:12:03 phil -Build change where FORCE wasn't being handled properly now that it is version -dependent. - - -2002/12/05 18:26:47 phil -Finalisation fixes (thanks to Kristine Sato). - - -2002/12/05 17:27:33 phil -Build system change for Qt v3.0.x and FORCE in Makefiles. - - -2002/11/28 09:03:40 phil -Fixed bug in handling of char * class variables introduced in the previous fix. - - -2002/11/26 12:46:01 phil -Make sure that flex and bison generated files have later timestamps than their -sources. -Removed the automatic test for -fno-exceptions and added the -f flag to the -build system so that it can be explicitly set. - - -2002/11/25 16:51:50 phil -Fixed generated code for char and unsigned char class variables - thanks to -Toby Sargeant. - - -2002/11/14 22:31:28 phil -Minor build changes for Windows. - - -2002/11/06 23:56:10 phil -The weak reference protection now works if the slot is a wrapped method as well -as a user written Python method. -The type name of the sipThis object is now "sip.wrapper" rather than being the -name of the wrapped class. -Deprecated the 'C' format character for sipParseArgs(). -Added the 'X' format character for sipParseArgs(). -Added /Constrained/ support for float and double types. - - -2002/11/05 15:08:18 phil -Addition of new licenses to the internal build system. -The TODO files is now added to the distribution. - - -2002/10/18 17:29:36 phil -More build system changes to fix directory names containing spaces. - - -2002/10/12 23:47:08 phil -Added the 'x' format character to sipParseArgs() to convert sequence indices. -Added sipConvertFromSequenceIndex(). - - -2002/10/11 14:12:52 phil -Fixed the build system where the Python directory path contained spaces. - - -2002/10/05 13:35:06 phil -Changed the internal build system so that internal development versions are -marked as such. -The user build system now handles conflicting licenses. - - -2002/09/21 17:58:53 phil -Added the NC version to allow others to build modules that conform to the Qt -non-commercial license. - - -2002/09/18 18:48:17 phil -Fixed a phantom exception raised when connecting a signal to a wrapped method -(rather than using SLOT() on the method). - - -2002/09/18 00:30:09 phil -"unsigned int" is now supported. - - -2002/09/10 12:38:35 phil -Minor documentation changes. -Released as v3.4. - - -2002/09/08 21:36:16 phil -Fixed a couple of code generation bugs related to structs. - - -2002/09/08 12:20:14 phil -The user now has to explicitly accept any non-GPL license. - - -2002/09/07 20:49:31 phil -Added support for defining structs. - - -2002/09/06 17:48:08 phil -Added the new licenses and changed the internal build process to support them. -Changed %License so that the timestamp is now a string. -Updated the NEWS file. - - -2002/09/02 12:03:37 phil -Added sipAddLicense() to the SIP module. -Added the %License keyword. - - -2002/08/27 19:06:05 phil -Added the %OptionalInclude directive that does the same as %Include but doesn't -complain if the file doesn't exist. -Added a delay to the build system before running make to avoid potential -timestamp problems. - - -2002/08/17 00:44:57 phil -Brought the NEWS file up to date. -Added Fredrik Juhlin's patch to the build system to support debug builds. - - -2002/08/06 18:35:53 phil -Fixes to the build system for Python 1.5. - - -2002/08/06 17:49:12 phil -Fixed a bug where const wasn't being taken into account when comparing argument -types. - - -2002/07/14 16:09:40 phil -Added the -e flag to the build system to allow the destination directory of the -SIP header files to be explicitly specified. - - -2002/07/12 13:03:59 phil -Fixed a problem with detecting the Qt version in the build system. -Released as 3.3.2. - - -2002/07/11 22:53:30 phil -More minor changes to the internal build system. - - -2002/07/11 20:57:32 phil -Internal build system changes. - - -2002/07/09 22:06:42 phil -Added support for Qt 3.0.5. -Released as 3.3.1. - - -2002/07/07 19:20:11 phil -Windows fixes for the build system. -Released as 3.3. - - -2002/07/05 08:55:37 phil -The build system now ignores qmake if present when building for Qt 1.x and 2.x. - - -2002/07/03 17:41:37 phil -Build system changes for Windows. -Fixed a thread problem for Python 2.0.x and earlier. (Untested.) -Released as 3.3rc3. - - -2002/07/02 18:33:59 phil -Fixed a probably false exception in sipTransferSelf(). -Fixed a bug in the -z flag handling. - - -2002/07/02 15:00:16 phil -Added the -x flag to specify a disabled feature. -Removed all of the version handling as it is now all dealt with in the parser. -Removed the -f flag and all support for the helper program as it is no longer -needed. -Removed %FeatureCode and %ExportedFeaturesCode. -Added the -z flag to specify a file from which subsequent arguments are read -from. - - -2002/06/30 16:20:48 phil -Minor changes to the build system messages. -Removed support for the -r flag in the build system as tmake handles -fno-rtti. - - -2002/06/29 18:53:49 phil -The build system now determines the Qt version by parsing qglobal.h rather than -compiling and running a program (which is no good when cross compiling). -Added the 'K' format character to sipParseArgs(). - - -2002/06/28 22:46:20 phil -More build.py fixes. -Changed the build system so that project files are restored to their original -contents. - - -2002/06/28 12:41:10 phil -Fixed a bug in the build system where the path to tmake was explicitly -specified. -Added the -r flag to the build system to explicitly enable -rno-rtti. -Released as 3.3rc2. - - -2002/06/23 19:45:33 phil -Added support for the evaluation version of Qt to the build system. - - -2002/06/22 14:25:14 phil -Reverted the change that stopped abstract classes from being created (because -it also stopped them from being sub-classed). -Released as 3.3rc1. - - -2002/06/22 00:56:29 phil -Fixed typo in build.py. - - -2002/06/22 00:49:59 phil -Updated the TODO list. -Fixed a bug where abstract classes weren't being detected properly. -An exception is now raised when attempting to explicitly instanciate an -abstract class. -Methods are now generated for pure virtual methods. -The default installation directory for sip under UNIX/Linux is now -/usr/local/bin rather than where the Python executable is installed. -Added the -i flag to build.py to allow the directory containing the Qt header -files to be explicitly specified. - - -2002/06/20 18:50:49 phil -Changes to the build system to support Qt/Embedded. -Changes to the build system to handle the lack of site-packages under Windows -before Python v2.2. - - -2002/06/19 07:51:59 phil -Fixed a bug that prevented SIP being built with support for Qt v2.x. - - -2002/06/17 08:35:34 phil -Fix for the build process for when Qt support is disabled. - - -2002/06/16 23:14:29 phil -Implemented the new build system based on tmake/qmake. -Removed all vestiges of the old build system. - - -2002/06/16 15:18:37 phil -Changed the build-common target to dist. -Fixed the build script to cope with an apparent feature of tmake v1.8. - - -2002/06/14 16:34:53 phil -The SIP module now works with Python versions earlier than 1.6 again. - - -2002/06/13 21:26:06 phil -Fixed a bug in the generation of the proxy header file. - - -2002/06/13 16:22:40 phil -Forgot to add the new versions.c source file. - - -2002/06/13 16:21:52 phil -Slightly changed the version number format in generated code so that it looks -better with snapshots. -The helper program now takes an optional argument which is the output file to -use instead of stdout. -Changed the internal implementation of versions so that it is more flexible. -The proxy header file is now moc-ed and linked separately. - - -2002/05/25 16:45:12 phil -Updated the (private) TODO list. - - -2002/05/25 16:23:27 phil -Further minor tweaks for the new build system. -Set the version number to v3.2.4 - but this is actually slightly later than -that version. - - -2002/05/25 11:02:57 phil -More work on the new build system. Untested on Windows. - - -2002/05/25 09:49:43 phil -Initial import of SIP into the Riverbank CVS repositiory. - - -2002/05/21 16:09:57 phil -Whoops - left a debug statement in. - - -2002/05/21 14:38:36 phil -Fixed a bug in sipParseArgs() using stdarg functions badly. It only seemed to -cause a problem on some platforms (eg. Linux PPC). - - -2002/05/17 19:02:28 phil -Minor documentation changes. -Released as v3.2.4. - - -2002/05/16 15:19:42 phil -Removed MacOS X support. - - -2002/05/15 17:17:36 phil -A final (I think) fix for the problem with maintaining the extra reference for -instances where C++ owns the wrapped object and also when objects are -re-wrapped while their dtor chain is being executed. -The .spec file now works out the Python directories rather than them being -hardcoded. - - -2002/05/13 08:48:56 phil -Fixed a bug where /TransferThis/ wasn't increasing the reference count of the -Python instance being transferred. -Released as v3.2.3. - - -2002/05/11 17:30:22 phil -Final documentation changes. -Released as v3.2.2. - - -2002/05/09 00:18:32 phil -Fixed a bug where threads weren't being handled properly when calling Qt -emitters. - - -2002/05/07 21:14:57 phil -Added information about "--without-x" to the MacOS installation notes. -Fixed a bug in the object map code that was trying to free non-malloc'ed -memory. -Keep a separate flag as to whether C++ has an extra reference to the Python -instance rather than assume is does if the C++ object is not owned by Python. -This should fix a very obscure memory leak that happends when C++ objects get -re-wrapped while they are being destroyed. - - -2002/05/05 13:45:13 phil -Fixed a bug where the sizes of attribute tables were wrong when optional -features were disabled. -Released as v3.2.1. - - -2002/05/04 14:17:39 phil -Minor tweak to fix a build problem with Windows. -Released as v3.2. - - -2002/05/03 22:34:37 phil -Added INSTALL.MacX. - - -2002/05/03 09:23:11 phil -Fixed NULL pointer bug in sub-class conversions. - - -2002/05/01 22:51:46 phil -Fixed sip.pro to revert to generating libsip.dll rather than sip.dll. -Replaced the use of PyCObject with the new sip.voidptr type. - - -2002/04/30 07:54:59 phil -configure will now search for Qt v3.0.4. - - -2002/04/29 18:09:16 phil -Fixed a bug where sub-class convertors were being generated for imported -classes. - - -2002/04/29 10:16:29 phil -configure doesn't search for X11 for Qt/E. -Fixed the bug where the class object for namespaces was being incorrectly -exported. - - -2002/04/27 14:16:25 phil -Fixed a bug in the SIP library Makefile.am. -Fixed the bug in the thread support that was causing the problem with the PyQt -semaphore.py example. -Changed the way %ConvertToSubClassCode worked so it is closer to the old -implementation and won't break if it comes across internal classes that it -doesn't recognise. - - -2002/04/23 09:09:07 phil -Fix to SIP_[UN]BLOCK_THREADS for when thread support is disabled. - - -2002/04/22 21:31:05 phil -Explicitly include pythread.h. -Changed the Windows installation instructions to put things in site-packages. -Added -module to the libtool flags. -Added sipMapStringToClass() and sipMapIntToClass() for %ConvertToSubClassCode. - - -2002/04/21 19:08:02 phil -Added support for the pseudo-type SIP_PYOBJECT. -Added the 'P' format character to sipParseArgs(). - - -2002/04/18 23:16:29 phil -Allow '!' to be applied to platforms. - - -2002/04/18 12:09:27 phil -configure no longer fails if X11 couldn't be found (for MacOS X). -Fixed a bug in the parsing of namespaces. - - -2002/04/16 18:56:33 phil -Fixed a problem building under Windows. - - -2002/04/16 18:16:55 phil -Minor build portability change for MacOS/X. - - -2002/04/16 14:23:21 phil -Replaced all the old thread support with explicit support for classes that can -create new threads. -Removed /ReleaseLock/ - the Python lock is released for any call to C++, not -just selected ones. -Added /CreatesThread/ and /NewThread/. -SIP_USE_DLL is no longer needed, but SIP_MAKE_MODULE_DLL is now needed when -compiling a SIP generated module under Windows. - - -2002/03/30 00:48:46 phil -Sub-class convertors are now called for any sub-class of the base class - even -if they don't provide their own convertor. - - -2002/03/24 22:19:28 phil -Added support for modules registering sub-class convertors. - - -2002/03/22 10:39:23 phil -Released as v3.1. -configure will now use qt-mt in preference to qt if it finds both. - - -2002/03/20 15:57:54 phil -configure now handles Qt v3.0.3. - - -2002/03/19 00:19:10 phil -Fixed typo in INSTALL.win32. -Documentation changes prior to the release of v3.1. - - -2002/03/17 17:36:30 phil -Fixed bug where functions defined in a namespace weren't being generated. - - -2002/03/12 19:29:19 phil -Upgraded to autoconf-2.53 and automake-1.6. - - -2002/03/09 18:17:55 phil -Various build changes for Windows. -The variables that hold the values parsed by sipParseArgs() are no longer -declared as const if there is no default value. -The %PrePythonCode is now generated before the import of a maodule's C++ code. - - -2002/03/04 21:06:37 phil -Made sure all the autoconf/automake/libtool generated files are updated. - - -2002/03/04 20:57:46 phil -SIP now compiles again. -Fixed the bug where exceptions sometimes appeared to be raised by Python -re-implementations of C++ virtual methods. - - -2002/03/04 17:17:12 phil -Using /TransferThis/ in a non-ctor is now detected as an error. - - -2002/02/25 16:24:35 phil -Method and enum tables are now sorted and searched with a binary search instead -of a linear search. -Individual values of enums are now under version control. - - -2002/02/24 14:59:04 phil -Ctors now support /ReleaseLock/. - - -2002/02/24 01:30:02 phil -configure now searches for Qt v3.0.2. -SIP now handles protected static methods. -Added the /NonLazy/ option. -Added the 'n' format character to sipParseArgs() to support non-lazy methods. -Removed the __sipDtor__ and __sipStr__ builtins. -The __del__ method is created by the SIP module at run-time when needed. -Removed all of the special method handling. - - -2002/02/08 15:52:55 phil -The AutoGen option now takes an optional feature name (needed for PyKDE2). - - -2002/01/28 11:07:47 phil -The sip library is now a Python module. - - -2002/01/09 00:37:16 phil -Class enums are now lazy. - - -2002/01/08 20:15:47 phil -The SIP library now uses PyObject_Del() rather than PyMem_DEL() for Python v1.6 -and later. -Fixed a code generator bug related to nested features. - - -2002/01/03 01:02:02 phil -Fixed a bug where feature tests were being generated when thay should have been -unconditional. -Added the -f flag to specifically generate the helper program. -Added %ExportedFeaturesCode. -Added the $B and $H macros. -The %Makefile object file extension is now optional and defaults to ".o". - - -2001/12/27 12:15:44 phil -Replaced %SecondaryVersion with %Platforms and %Feature. -Removed %ImportWithTimeline. -Added support for Qt/Embedded. -Replaced %VersionCode with %FeatureCode. -%If now supports logical ors or platforms and/or features. - - -2001/12/09 11:39:57 phil -configure now looks for Qt v3.0.1. - - -2001/12/01 18:35:59 phil -Used AC_HELP_STRING throughout configure.ac. - - -2001/11/25 18:24:55 phil -Upgraded libtool to v1.4.2. -Fix for attribute lookup for classes with no attributes (eg. namespaces). - - -2001/11/17 17:11:37 phil -Fixed bugs in operators for "setitem" and "getslice" for sequence methods. - - -2001/11/17 14:41:38 phil -%ConvertToTypeCode must now handle None objects. -sipConvertToCpp() now handles None objects. -Fixes to configure.ac. -The module name is now passed in at runtime rather than being hardcoded (thanks -to Andreas Gerstlauer). -Ownership is only transferred if it really has changed. - - -2001/11/11 19:05:36 phil -configure will search for Qt v2.3.2. -Fixed the memory leak when calling Python slots (thanks to Andreas Gerstlauer). -Another attempt at fixing the problem with generating the right Python super -classes for PyKDE2. -Generate an error message if handwritten code is provided for signals. - - -2001/10/28 10:32:47 phil -Backed out the change to use __sipThis rather than sipThis. - - -2001/10/26 23:37:26 phil -ALtered the lexer/parser so that C++ methods can have names starting with "__", -which means that .sip files that define special methods must also be changed. -The library now uses the C API for weak references for Python v2.2 and later. -Added the %PostInitialisationC++Code directive. -Replaced "sipThis" with "__sipThis". -Added __sipStr__ to replace str() in __str__() methods so that unicode() on a -QString works properly. - - -2001/10/21 13:54:14 phil -Fixed bug where all the fields of a mapped argument type weren't being -initialised. -Fixed bug where the sipCpp pointer has the wrong type for a protected method of -a class in a namespace. - - -2001/10/19 23:29:46 phil -Added the 'N' format character to sipParseArgs(). - - -2001/10/12 22:49:23 phil -Literal strings are no longer cached because their contents are used in the -cache name but they might not be valid characters for an identifier. -Fixed a bug where %ImportWithTimeLine on a module that has already been -imported didn't inherit the time line. -Fixed a bad bug where the "object is on the heap" flag wasn't being -initialised. - - -2001/10/07 18:48:39 phil -Fixed generation of proxy object for modules without signals. -Fix possible bug with handling protected enums (my version of gcc doesn't -complain). - - -2001/10/06 18:17:23 phil -configure now handles multi-threaded Qt. -Correct header files now generated for mapped types based on the same template -being defined in different modules. - - -2001/10/04 21:30:10 phil -By default, a class inherits its header code from the enclosing scope. -Mapped types based on templates now automatically include the header files for -the types of the template parameters. - - -2001/09/30 10:44:26 phil -Bug fixing of the new sipParseArgs() code. - - -2001/09/28 23:11:43 phil -Many changes to sipParseArgs(): it now returns the number of successfully -parsed arguments; the '-' and 'I' formatting characters are no longer -supported; the 'm', 'p', 't', 'q', 'Q', 'y', 'Y', 'J' and 'M' formtting -characters have been added; it now does all argument conversions. -Static and non-static methods can now be mixed. -Removed the %CanConvertToType directive. - - -2001/09/23 19:55:51 phil -Fixed bug in adding a scope to enum values. - - -2001/09/23 14:21:53 phil -Fixed code generation bug with const signal arguments. -Fixed generation of calls to sipForceConvertTo_*() functions. -Header code is now generated before used includes in interface files. -Protected enums are now handled properly again. - - -2001/09/16 18:08:19 phil -Changed the method of preventing moc generated files being included with the -distribution - needed by the latest automake. - - -2001/09/14 15:18:05 phil -Added the /AutoGen/ options and removed the hardcoded handling of moc generated -methods. -Fixed the #include of a non-existent interface file in the main module. -Fixed a bug where a cached name was being associated with the wrong module. -Fixed an indentation bug when generating Python code for namespaces. -Fixed a bug where global enums after a class definition were incorrectly -generating errors. - - -2001/09/07 16:04:49 phil -Fixed a bug where a bad number methods table was being generated. -Upgraded to libtool-1.4.1. - - -2001/09/02 16:39:48 phil -Fixed bug where the header file for a class's super classes wheren't being -included if the class was in an imported module. - - -2001/09/01 02:37:46 phil -The first parameter of sipConvertFrom_*() for mapped types is no longer const. -Upgraded to autoconf-2.52 and automake-1.5. - - -2001/08/10 17:52:30 phil -Fixed missing popVersion() in gencode.c. - - -2001/08/10 14:59:17 phil -Python classes that have to be imported are done so at the start of the module, -not immediately before they are first needed. - - -2001/08/06 20:08:19 phil -Fixed a problem registering a class that doesn't exist in a particular -secondary version. - - -2001/08/01 22:17:47 phil -More build changes for Qt-NC. -tr() is now properly handled for Qt v2.3.0 and earlier. - - -2001/07/30 22:48:21 phil -The contents of namespaces are now effectively public. -Changed AMTAR to TAR. -Generated Windows Makefiles that support Qt-NC (untested). - - -2001/07/28 22:40:44 phil -Fixed bug in sipRegisterClass()'s handling of nested scopes. - - -2001/07/28 06:45:41 phil -Changed sipRegisterClasses() to handle nested classes and namespaces. -The sipClassDef structure now has an extra field to identify the enclosing -scope. - - -2001/07/27 22:28:19 phil -sipConvertFrom_*() for mapped types now leaves the handling of a NULL pointer -to the handwritten code rather than converting it to None. -The same namespace can be defined many times, so long as they are in the same -module. -Fixed a problem testing for -fno-exceptions. -Fixed problem building with Qt support disabled. -Fixed small code generation bug for virtual handlers and nested classes. -Fixed an extraneous const that Windows MSVC doesn't like. - - -2001/07/21 15:57:20 phil -Replaced %PrimaryVersion and %PrimaryOrder with %Timeline. -Added %ImportWithTimeline. -The -t switch can now be given any number of times. -These changes now means that version control works properly across modules so -that (for example) SIP doesn't try to generate bindings that support invalid -combinations like Qt v1.x and KDE v2.x. - - -2001/07/20 23:35:04 phil -Completed the support for namespaces and nested classes. -sipCallCtor() now handles namespaces. -Added the SIP_SIGNAL pseudo-type. -Replaced %Version and %PrimaryVersions with %PrimaryVersion, %SecondaryVersion -and %PrimaryOrder. - - -2001/07/17 07:39:58 phil -Added the %MappedType directive - particularly for templates. -Added support for namespaces and nested classes - not yet finished. -Removed the Version keyword so that it can be used for class names. - - -2001/07/01 14:31:35 phil -configure now looks for Qt v2.3.1. - - -2001/06/05 21:41:39 phil -Added the relevant files to build sip.exe under Windows (not tested yet). -The Windows Makefiles (now Borland as well as MSVC) are created automatically -as part of the "make dist" process. - - -2001/06/04 21:38:18 phil -Some Windows portability changes. - - -2001/06/02 17:00:21 phil -C-style comments can now be used in .sip files. -Methods automatically generated by moc (particularly tr()) are now handled -properly. - - -2001/05/30 21:20:07 phil -Added the /Constraint/ option and support for it to sipParseArgs(). - - -2001/05/23 22:25:54 phil -QObject.blockSignals() now blocks Python signals as well as Qt signals. - - -2001/05/23 21:13:18 phil -Fixed problems when default arguments are function calls. -Added support for QObject.sender() to be able to be implemented properly. -Fixed the problem when a slot disconnects itself. - - -2001/04/29 16:23:09 phil -Minor configuration changes. - - -2001/04/22 15:22:52 phil -Upgraded to automake v1.4d. - - -2001/04/19 22:09:32 phil -Final changes for the release of v2.4. - - -2001/04/08 13:39:02 phil -Upgraded to libtool v1.3d. - - -2001/03/10 00:43:37 phil -Fixed compile problems with Python earlier then v2.1. - - -2001/03/07 20:17:47 phil -The library now tidies itself up when Py_Finalize() is called. - - -2001/03/06 09:29:05 phil -Fixed minor code generation bugs with Python special methods. - - -2001/03/05 23:16:12 phil -Added support for Python v2.1 rich comparison operators. - - -2001/03/05 16:42:18 phil -Added support for the in-place operators introduced in Python v2.0. -Python slots are now wrapped in weak references which means that when the -programmer forgets to keep a slot alive it won't core dump. - - -2001/03/01 19:21:58 phil -configure now uses the Python executable to determine where Python is -installed. - - -2001/02/10 12:09:11 phil -Fixed bug in sipCommonDtor() so that it acquires the Python lock before calling -Python library functions. - - -2001/02/04 14:37:10 phil -Configure now checks for Qt v2.2.4 and Python v2.1. -Released as v2.3. - - -2001/01/23 23:36:51 phil -Added the -p switch and the $m macro. - - -2001/01/09 16:07:55 phil -The library will raise an exception if a program tries to inherit from more -than one wrapped class. - - -2000/12/24 18:30:09 phil -Fixed a bug that meant some signal proxies were not being generated properly -(only affected QMovie). -When a C++ instance takes ownership, it also takes a reference to the Python -object as well. -Updated the documentation for v2.3. - - -2000/12/19 14:48:31 phil -Added the ability to add pre- and post-call hooks. Added the sipCallHook() -function to implement them. - - -2000/12/15 11:18:00 phil -Added a couple of missing Python exceptions. - - -2000/12/13 10:41:12 phil -Updated the configuration to look for Qt v2.2.3. - - -2000/12/12 17:48:53 phil -Changed sipParseArgs() to take an extra parameter to enable better error -messages to be reported. -Changed the sipNo*() functions to report the better messages. -Changed the code generator to use the changed sipParseArgs(). - - -2000/11/05 20:56:28 phil -Added the $P macro. -Backed out the change making the wrapper class dtors virtual (causes problems -under Windows). -Released v2.2. - - -2000/11/04 11:06:11 phil -Made the wrapper class dtor virtual to avoid compiler warning messages. -Fixed proxy class generation for modules that don't define any new signals. - - -2000/11/02 15:03:13 phil -Minor compile fixes (why is it always RedHat?). -Added the %Copying directive. -Clarified the license regarding generated code. - - -2000/10/18 16:20:53 phil -Final tidying up for the release of v2.1. - - -2000/10/15 20:41:24 phil -Finally fixed the problem with signal signatures defined with SIP_CON_SLOT. -Updated the documentation for v2.1pre1. - - -2000/10/13 19:00:17 phil -Fixed really nasty segv with complex Python expressions where the wrapped -object was (legitimately) outliving the class instance. - - -2000/10/11 17:23:05 phil -Slot types that are only specified by SIP_CON_SLOT (and not as a signal) are -now handled properly. - - -2000/10/11 13:34:03 phil -Added the ability to provide handwritten code for dtors. -Added the sipGetThisWrapper() function to the SIP library. - - -2000/10/02 21:46:56 phil -Fixed the bad code generated for Python special methods (ie. operators). - - -2000/10/01 12:32:19 phil -Slots that take fewer arguments than the number supplied by a signal will not -cause an exception - just like Qt. - - -2000/10/01 00:44:57 phil -Fixed the signal handling bug introduced a couple of days ago while trying to -fix another signal handling bug. - - -2000/09/29 22:28:26 phil -When a wrapped class instance is deleted it is now guaranteed that the -underlying object will be deleted after all of the instances variables. This -avoids some potentially very subtle bugs. - - -2000/09/23 18:07:05 phil -Connecting Python signals to Qt slots (expressed using SLOT()) now works. -Increased the library version number to 3.0.1. - - -2000/09/20 10:57:10 phil -Tidy up after moving the CVS tree to theKompany.com CVS repository. diff --git a/python/sip/LICENSE b/python/sip/LICENSE deleted file mode 100644 index 70b9d04b..00000000 --- a/python/sip/LICENSE +++ /dev/null @@ -1,45 +0,0 @@ -RIVERBANK COMPUTING LIMITED LICENSE AGREEMENT FOR SIP 4.6 - -1. This LICENSE AGREEMENT is between Riverbank Computing Limited -("Riverbank"), and the Individual or Organization ("Licensee") accessing -and otherwise using SIP 4.6 software in source or binary form and its -associated documentation. - -2. Subject to the terms and conditions of this License Agreement, Riverbank -hereby grants Licensee a nonexclusive, royalty-free, world-wide license -to reproduce, analyze, test, perform and/or display publicly, prepare -derivative works, distribute, and otherwise use SIP 4.6 alone or in -any derivative version, provided, however, that Riverbank's License -Agreement and Riverbank's notice of copyright, i.e., "Copyright (c) 2004 -Riverbank Computing Limited; All Rights Reserved" are retained in -SIP 4.6 alone or in any derivative version prepared by Licensee. - -3. In the event Licensee prepares a derivative work that is based on -or incorporates SIP 4.6 or any part thereof, and wants to make -the derivative work available to others as provided herein, then -Licensee hereby agrees to include in any such work a brief summary of -the changes made to SIP 4.6. - -4. Riverbank is making SIP 4.6 available to Licensee on an "AS IS" -basis. RIVERBANK MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR -IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, RIVERBANK MAKES NO AND -DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS -FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF SIP 4.6 WILL NOT -INFRINGE ANY THIRD PARTY RIGHTS. - -5. RIVERBANK SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF -SIP 4.6 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS -AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING SIP 4.6, -OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - -6. This License Agreement will automatically terminate upon a material -breach of its terms and conditions. - -7. Nothing in this License Agreement shall be deemed to create any -relationship of agency, partnership, or joint venture between Riverbank -and Licensee. This License Agreement does not grant permission to use -Riverbank trademarks or trade name in a trademark sense to endorse or -promote products or services of Licensee, or any third party. - -8. By copying, installing or otherwise using SIP 4.6, Licensee -agrees to be bound by the terms and conditions of this License Agreement. diff --git a/python/sip/NEWS b/python/sip/NEWS deleted file mode 100644 index 919527ad..00000000 --- a/python/sip/NEWS +++ /dev/null @@ -1,198 +0,0 @@ -v4.6 10th April 2007 - - Added support for wchar_t. - - The -g command line option releases the GIL whenever a call is made to the - wrapped library. - - Added the /HoldGIL/ annotation to explicitly retain the GIL when calling a - particular function in the wrapped library. - - Added sipFindClass() and sipFindNamedEnum() to the public API. - - /TransferThis/ may be specified more than once. - - Added support for __truediv__ and __itruediv__. - - The SIP code generator and module may be built as universal binaries under - MacOS/X using the -n command line option to configure.py. - -v4.5.2 9th December 2006 - - A bug fix release. - -v4.5.1 9th December 2006 - - Added the SIP_SSIZE_T type to help write PEP 353 compliant handwritten - code. - -v4.5 4th November 2006 - - Added support for Python v2.5. - - Added sip_config_args to sipconfig.py. - - sip.voidptr now implements __hex__(). - - Added sip.delete() to call a C++ instance's destructor, or return a C - structure to the heap. - - Added sip.isdeleted() to check if a C++ instance or C structure has been - destroyed or returned to the heap. - - Added sip.setdeleted() to mark that a C++ instance or C structure has been - destroyed or returned to the heap. - - Added support for pure virtual destructors. - - Added the __dtor__() method to allow Python code to be called from a C++ - destructor. - - Added the /NoDefaultCtors/ class annotation. - - The generated API files are now more complete and use Python types rather - than C/C++ types. - - Added support for embedding manifests for MSVC 2005. - -v4.4.5 10th June 2006 - - A bug fix release. - -v4.4.4 8th June 2006 - - Added %ExportedHeaderCode and %UnitCode. - - Added sipExportSymbol() and sipImportSymbol() to the public API. - -v4.4.3 27th April 2006 - - A bug fix release. - -v4.4.2 23rd April 2006 - - A bug fix release. - -v4.4.1 3rd April 2006 - - A bug fix release. - -v4.4 24th March 2006 - - The major number of the internal API has changed so it will be necessary - to regenerate all modules. - - This release introduces small incompatibilities that may affect handwritten - code. See the documentation for the details. - - Module names specified with %Module and %CModule can now include periods to - denote a Python package structure. - - Namespaces can be split across multiple Python modules. - - Class templates are now supported and instantiated using "typedef". - - Mapped type templates are now supported and instantiated automatically. - - Global operators are now supported. - - Operator casts in classes are now supported. - - C/C++ signed char type is now treated as a separate type to char. - - C/C++ long and unsigned long types are now wrapped as Python long objects - rather than Python integer objects. - - C/C++ long long and unsigned long long types are now supported. - - unsigned short and unsigned int are now implemented as long objects instead - of integer objects. - - Classes can now be declared using the /External/ annotation and be defined - in another, unspecified, module. - - /TransferThis/ can now be used in non-factory methods to change the - ownership to a different C++ instance or to change it to Python. - - /Constrained/ can now be used with booleans. - - Added support for Python's buffer interface, %BIGetCharBufferCode, - %BIGetReadBufferCode, %BIGetSegCountCode and %BIGetWriteBufferCode. - - The "user" member has been added to the sipWrapper structure and can be - used for any purpose by handwritten code. - - Function argument names are now parsed, but otherwise ignored. - - The "explicit" keyword is now parsed, but otherwise ignored. - - Added the /DelayDtor/ class annotation which given more control over the - order in which instances are deleted when an application terminates. - - Added support for the SIP_PYTYPE pseudo-type that represents a Python - type object. - - Added support for ellipsis (ie. "...") in function arguments. Any - remaining arguments will be gathered as a Python tuple. - - Add support for the /NoDerived/ annotation for Python class constructors - that have no C/C++ equivalent. - - The sipSelfWasArg boolean is now available to the %MethodCode of - non-abstract, virtual methods to indicate whether the class implementation - of the method rather than the virtual implementation should be called. - %MethodCode for non-abstract, virtual, protected methods must now call the - sipProtectVirt wrapper (rather than sipProtect). - - sipCanConvertToInstance(), sipConvertToInstance(), - sipForceConvertToInstance(), sipReleaseInstance(), - sipConvertFromInstance(), sipConvertFromNewInstance(), - sipCanConvertToMappedType(), sipConvertToMappedType(), - sipForceConvertToMappedType(), sipReleaseMappedType(), - sipConvertFromMappedType() and sipFindMappedType() have been added to the - SIP API. - - sipLong_AsUnsignedLong() has been added, primarily as a workaround for a - bug in Python v2.3.x and earlier. - - Added the 't', 'u', 'C' and 'D' format characters to sipParseResult(). - - Added the 't', 'u', 'B', 'C' and 'D' format characters to sipBuildResult(). - - Responsibility for interpreting and implementing the /Transfer/ and - /TransferBack/ annotations has been pushed down to %ConvertToTypeCode and - %ConvertFromTypeCode. The generated type convertors sipForceConvertTo_*() - and sipConvertFrom_*() have been deprecated. - - Added the %SIPNoEmitters directive for PyQt4. - - Added support for the __hash__ Python special method. - - The __getitem__ Python special method no longer requires %MethodCode. - - All of the calls to Qt have been moved out of the sip module and into PyQt. - The generated sipconfig.py file no longer contains any Qt specific - information. These changes mean that SIP can support PyQt v3 and v4 at the - same time. - - Static methods can now be defined as Qt slots. - - Removed SIP_BUILD from sip.h. - - The -c, -l, -q and -x flags to configure.py have been removed. - - Added the PythonModuleMakefile class to the build system for installing - pure Python modules. - - Added the create_wrapper() function to the build system for creating - platform dependent executable wrappers for Python scripts. - - Added Configuration.platform to the build system. - -v4.3.2 14th November 2005 - - The sipdistutils.py script has contributed by Giovanni Bajo that enables - SIP extension modules to be built with distutils. - -v4.3.1 10th September 2005 - - A bug fix release. - -v4.3 30th August 2005 - - The major number of the internal API has changed so it will be necessary - to regenerate all modules. - - C structures can now have constructors and a destructor defined so that - they can be made to behave more Pythonically. - - %TypeHeaderCode can now be used in namespaces. - - Added sip.SIP_VERSION_STR. - - Added support for Python's cyclic garbage collector, %GCTraverseCode and - %GCClearCode. - - Deprecated sipTransfer() and sip.transfer(). - - Added sipTransferTo, sipTransferBack(), sip.transferto() and - sip.transferback(). - - Added support for sipCppRet in %ConvertSubClassCode. - - Added support for %GetCode and %SetCode for instance variables and - structure members. - - Added support for %Exception and %RaiseCode. - - Added support for __pos__ and __abs__. - - sip.voidptr instances can now be created from Python. - - The ascobject() method has been added to sip.voidptr. - - Added the -c flag to configure.py to explicitly specify the location of - the qconfig.h file. - -v4.2.1 6th March 2005 - - Restored the pre-4.2 behaviour of Python exceptions raised in virtual - re-implementations. - - %Timeline can now be used more than once in a module. - -v4.2 19th February 2005 - - The /PyName/ annotation can now be applied to classes, namespaces, - enums, enum members and variables. - - Added the %PreInitialisationCode directive and is subject to version - control. %PostInitialisationCode is now subject to version control. - - Named enums now have distinct types and so can be differentiated from - integers in function signatures. - - The handling of Qt signals has changed so that "foreign" signals (ie. - those raised by ActiveX controls) can be handled. - - The voidptr, wrapper and wrappertype types are now exposed in the sip - module. - - Virtual and abstract operators are now supported. - - The __call__ slot no longer requires %MethodCode. - - Any Python exceptions raised in virtual re-implementations are now - detected when they occur. - - sip.cast() can now cast downwards as well as upwards. - - Added sip.SIP_VERSION. - - The -k flag to configure.py can now be used to build modules as builtins - to custom interpreters. - - The build system now strips modules and only exports the module - initialisation function by default (when supported by the platform). - -v4.1.1 24th September 2004 - - A bug fix release. - -v4.1 20th September 2004 - - Added the cast() method to the sip module. - - Added limited support for protected classes. - - Added the /Abstract/ class annotation. - - Added support for typedefs that define pointers to functions. - - The SIP_PYCALLABLE type now supports the /AllowNone/ annotation. - - Added support for MSVC.NET to the build system. - -v4.0.1 6th July 2004 - - A bug fix release. - -v4.0 23rd June 2004 - - The release of SIP v4. diff --git a/python/sip/README b/python/sip/README deleted file mode 100644 index debbe22b..00000000 --- a/python/sip/README +++ /dev/null @@ -1,5 +0,0 @@ - SIP - Python C/C++ Bindings Generator - - -The SIP documentation (including installation instructions) can be found in the -"doc" directory. diff --git a/python/sip/README.HP-UX b/python/sip/README.HP-UX deleted file mode 100644 index f628f31d..00000000 --- a/python/sip/README.HP-UX +++ /dev/null @@ -1,32 +0,0 @@ -This file describes some things to be aware of when building SIP (and PyQt) -under HP-UX. - -I had success building SIP V4 and PyQt on HP-UX 11.0 with the -HP aC++ compiler. - -My configuration was: - -HP-UX B.11.00 -HP aC++ Compiler C.03.50 (B3911DB) -Qt-3.3.3 -Python-2.3.4 -sip-snapshot-20041113 -PyQt-commercial-snapshot-20041031 - -Additionally, I installed the patches PHSS_29483 and PHSS_30967. -PHSS_29483 brings the aC++ Compiler to level A.03.52. -PHSS_30967 is a cumulative linker patch. - -Because HP-UX can load C++ shared libraries and C++ shared objects only, when -the main program is a C++ program, I had to configure Python with the option ---with-cxx=aCC - -I also had to change the definition of _POSIX_C_SOURCE in the configure script -of Python from 200112L to 199506L because it conflicts with the definition -from Qt. - -If you have any problems or questions on building SIP or PyQt on HP-UX, either -send an email to ulrich.berning@desys.de or use the PyKDE mailing list. - -Ulrich Berning -DESYS GmbH diff --git a/python/sip/THANKS b/python/sip/THANKS deleted file mode 100644 index 5b2614a3..00000000 --- a/python/sip/THANKS +++ /dev/null @@ -1,16 +0,0 @@ -Ulli Berning - For lots of work resolving many multi-platform build issues. - -Simon Cusack - For the Borland stuff. - -Wilken Boie - For porting the SIP code generator to Windows. - -Toby J Sargeant - For the hash table code (and finding out why it's needed). - For deep bug hunting and fixing. - For the Python interpeter lock stuff. - -Matthias H"olzer-Kl"upfel - For the original automake/autoconf magic. diff --git a/python/sip/TODO b/python/sip/TODO deleted file mode 100644 index bf1227c1..00000000 --- a/python/sip/TODO +++ /dev/null @@ -1,55 +0,0 @@ -1. Make the parser aware of Python keywords so they can't be used as -member function names. - -5. Allow handwritten code for static class variables (like -KTMainWindow.memberList). The problem is intercepting references to it -(__getattr__ and __setattr__ aren't good enough) - probably extending the -lazy function mechanism. - -11. Consider changing the way default arguments that are function calls are -handled. At the moment the function is always called and the result discarded -if it is not needed. It should really only be called if the result is really -needed. - -18. Implement the C++ feature of automatically calling simple ctors to -transparently convert between types for function parameters. For example, a -function takes a parameter of type QKeySequence, but is passed an int, but -there is a QKeySequence ctor that takes a single int - so call it -automatically. This just needs extra code generated for the CanConvertTo and -ConvertTo functions. This will only work where the destination type is a -class. Note that we will end up doing lots of checks in the CanConvertTo -function and repeating them in the ConvertToFunction. It would be better if -the CanConvertTo function could return some information (even the results of -the conversion of simple types like ints) to be re-used by ConvertTo - but make -sure default arguments are handled correctly. We could implement it for base -types as well (if the source type implemented an appropriate cast operator) but -the way of doing argument parsing would have to change completely - if -sipParseArgs was trying to convert an argument to an int it would have to have -a table of all types that could be converted to an int (messy and slow?). - -19. Consider changing sipConvertToCpp() etc. to take a PyObject* (rather -than a sipWrapperType*) and do a check and cast internally. - -22. Consider adding support for methods that take keyword arguments. Do it -by allowing a function parameter to have a name (this becomes the keyword) and -extend sipParseArgs() to take an options dictionary and list of keywords. - -24. Need some way of implementing new Qt properties, or at least fiddle the -implementation of QSqlPropertyMap to allow new customer editor widgets to be -implemented in Python. - -25. Add support for specifying docstrings for generated methods. - -26. Fully implement QObject.disconnect(). - -27. Look at adding QObject.Q_OBJECT() that will create the moc generated -methods dynamically (maybe just the tr() functions). - -28. Consider creating a copy of a const reference when wrapping it in order -to enforce const in Python. Or add a flag to the wrapper which says it is a -const instance. I think the only to way to implement it is to have a "const" -Python type - an instance of which will point to the underlying Python object. -This will enable const_cast to be implemented. - -30. Add support for specifying the reverse arithmetic operators. (Or just -document that you should use the normal ones as global operators?) diff --git a/python/sip/configure.py b/python/sip/configure.py deleted file mode 100644 index e5c55295..00000000 --- a/python/sip/configure.py +++ /dev/null @@ -1,417 +0,0 @@ -# This script handles the SIP configuration and generates the Makefiles. -# -# Copyright (c) 2007 -# Riverbank Computing Limited <info@riverbankcomputing.co.uk> -# -# This file is part of SIP. -# -# This copy of SIP is licensed for use under the terms of the SIP License -# Agreement. See the file LICENSE for more details. -# -# SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - -import sys -import os -import string -import glob -import getopt - -import siputils - - -# Initialise the globals. -sip_version = 0x040600 -sip_version_str = "4.6" -py_version = sys.hexversion >> 8 -plat_py_site_dir = None -plat_py_inc_dir = None -plat_py_conf_inc_dir = None -plat_py_lib_dir = None -plat_sip_dir = None -plat_bin_dir = None -platform_specs = [] -default_platform = None - -# Command line options. -opt_platform = None -opt_sipbindir = None -opt_sipmoddir = None -opt_sipincdir = None -opt_sipsipdir = None -opt_static = 0 -opt_debug = 0 -opt_export_all = 0 -opt_universal = '' - -# The names of build macros extracted from the platform specific configuration -# files. -build_macro_names = [ - "DEFINES", "CONFIG", - "CC", - "CFLAGS", - "CFLAGS_RELEASE", "CFLAGS_DEBUG", - "CFLAGS_CONSOLE", "CFLAGS_SHLIB", "CFLAGS_THREAD", - "CFLAGS_MT", "CFLAGS_MT_DBG", "CFLAGS_MT_DLL", "CFLAGS_MT_DLLDBG", - "CFLAGS_EXCEPTIONS_ON", "CFLAGS_EXCEPTIONS_OFF", - "CFLAGS_RTTI_ON", "CFLAGS_RTTI_OFF", - "CFLAGS_STL_ON", "CFLAGS_STL_OFF", - "CFLAGS_WARN_ON", "CFLAGS_WARN_OFF", - "CHK_DIR_EXISTS", "COPY", - "CXX", - "CXXFLAGS", - "CXXFLAGS_RELEASE", "CXXFLAGS_DEBUG", - "CXXFLAGS_CONSOLE", "CXXFLAGS_SHLIB", "CXXFLAGS_THREAD", - "CXXFLAGS_MT", "CXXFLAGS_MT_DBG", "CXXFLAGS_MT_DLL", "CXXFLAGS_MT_DLLDBG", - "CXXFLAGS_EXCEPTIONS_ON", "CXXFLAGS_EXCEPTIONS_OFF", - "CXXFLAGS_RTTI_ON", "CXXFLAGS_RTTI_OFF", - "CXXFLAGS_STL_ON", "CXXFLAGS_STL_OFF", - "CXXFLAGS_WARN_ON", "CXXFLAGS_WARN_OFF", - "DEL_FILE", - "EXTENSION_SHLIB", "EXTENSION_PLUGIN", - "INCDIR", "INCDIR_X11", "INCDIR_OPENGL", - "LIBS_CORE", "LIBS_GUI", "LIBS_NETWORK", "LIBS_OPENGL", - "LINK", "LINK_SHLIB", "AIX_SHLIB", "LINK_SHLIB_CMD", - "LFLAGS", "LFLAGS_CONSOLE", "LFLAGS_CONSOLE_DLL", "LFLAGS_DEBUG", - "LFLAGS_DLL", - "LFLAGS_PLUGIN", "LFLAGS_RELEASE", "LFLAGS_SHLIB", "LFLAGS_SONAME", - "LFLAGS_THREAD", "LFLAGS_WINDOWS", "LFLAGS_WINDOWS_DLL", "LFLAGS_OPENGL", - "LIBDIR", "LIBDIR_X11", "LIBDIR_OPENGL", - "LIBS", "LIBS_CONSOLE", "LIBS_OPENGL", "LIBS_OPENGL", "LIBS_RT", - "LIBS_RTMT", "LIBS_THREAD", "LIBS_WINDOWS", "LIBS_X11", - "MAKEFILE_GENERATOR", - "MKDIR", - "RPATH", - "AR", "RANLIB", "LIB", "STRIP" -] - - -def usage(rcode = 2): - """Display a usage message and exit. - - rcode is the return code passed back to the calling process. - """ - print "Usage:" - print " python configure.py [-h] [-b dir] [-d dir] [-e dir] [-k] [-n] [-p plat] [-u] [-v dir] option=value option+=value ..." - print "where:" - print " -h display this help message" - print " -b dir where the SIP code generator will be installed [default %s]" % opt_sipbindir - print " -d dir where the SIP module will be installed [default %s]" % opt_sipmoddir - print " -e dir where the SIP header file will be installed [default %s]" % opt_sipincdir - print " -k build the SIP module as a static library" - print " -n build the SIP code generator and module as universal binaries on MacOS/X" - print " -p plat the platform/compiler configuration [default %s]" % default_platform - print " -u build with debugging symbols" - print " -v dir where .sip files are normally installed [default %s]" % opt_sipsipdir - - # Display the different platform/compilers. - print - print "The following platform/compiler configurations are supported:" - print - - platform_specs.sort() - - ss = "" - sep = "" - for s in platform_specs: - ss = ss + sep + s - sep = ", " - - print siputils.format(ss, 2) - - # Display the different build macros. - print - print "The following options may be used to adjust the compiler configuration:" - print - - build_macro_names.sort() - - ss = "" - sep = "" - for s in build_macro_names: - ss = ss + sep + s - sep = " " - - print siputils.format(ss, 2) - - sys.exit(rcode) - - -def set_defaults(): - """Set up the defaults for values that can be set on the command line. - """ - global default_platform - global opt_sipbindir, opt_sipmoddir, opt_sipincdir, opt_sipsipdir - - # Set the platform specific default specification. - platdefaults = { - "aix": "aix-xlc", - "bsd": "bsdi-g++", - "cygwin": "cygwin-g++", - "darwin": "macx-g++", - "dgux": "dgux-g++", - "freebsd": "freebsd-g++", - "gnu": "hurd-g++", - "hp-ux": "hpux-acc", - "irix": "irix-cc", - "linux": "linux-g++", - "lynxos": "lynxos-g++", - "netbsd": "netbsd-g++", - "openbsd": "openbsd-g++", - "openunix": "unixware-cc", - "osf1": "tru64-cxx", - "qnx": "qnx-g++", - "reliantunix": "reliant-cds", - "sco_sv": "sco-cc", - "sinix": "reliant-cds", - "sunos5": "solaris-cc", - "ultrix": "ultrix-g++", - "unix_sv": "unixware-g++", - "unixware": "unixware-cc" - } - - default_platform = "none" - - if sys.platform == "win32": - if py_version >= 0x020400: - default_platform = "win32-msvc.net" - else: - default_platform = "win32-msvc" - else: - for pd in platdefaults.keys(): - if sys.platform[:len(pd)] == pd: - default_platform = platdefaults[pd] - break - - opt_sipbindir = plat_bin_dir - opt_sipmoddir = plat_py_site_dir - opt_sipincdir = plat_py_inc_dir - opt_sipsipdir = plat_sip_dir - - -def inform_user(): - """Tell the user the option values that are going to be used. - """ - siputils.inform("The SIP code generator will be installed in %s." % opt_sipbindir) - siputils.inform("The SIP module will be installed in %s." % opt_sipmoddir) - siputils.inform("The SIP header file will be installed in %s." % opt_sipincdir) - siputils.inform("The default directory to install .sip files in is %s." % opt_sipsipdir) - siputils.inform("The platform/compiler configuration is %s." % opt_platform) - - if opt_universal: - siputils.inform("MacOS/X universal binaries will be created.") - - -def set_platform_directories(): - """Initialise the global variables relating to platform specific - directories. - """ - global plat_py_site_dir, plat_py_inc_dir, plat_py_conf_inc_dir - global plat_bin_dir, plat_py_lib_dir, plat_sip_dir - - if sys.platform == "win32": - plat_py_site_dir = sys.prefix + "\\Lib" - if py_version >= 0x020200: - plat_py_site_dir = plat_py_site_dir + "\\site-packages" - - plat_py_inc_dir = sys.prefix + "\\include" - plat_py_conf_inc_dir = sys.exec_prefix + "\\include" - plat_py_lib_dir = sys.prefix + "\\libs" - plat_bin_dir = sys.exec_prefix - plat_sip_dir = sys.prefix + "\\sip" - else: - vers = "%d.%d" % ((py_version >> 16) & 0xff, (py_version >> 8) & 0xff) - - # Some 64 bit Linux distros (Mandriva, SuSE) seem to add sys.lib as a - # non-standard extension presumably to allow 32 and 64 bit versions to - # be installed side by side. Use it if it seems to be available. - try: - lib_dir = sys.lib - except AttributeError: - lib_dir = "lib" - - lib_dir = sys.prefix + "/" + lib_dir + "/python" + vers - - plat_py_site_dir = lib_dir - if py_version >= 0x020000: - plat_py_site_dir = plat_py_site_dir + "/site-packages" - - plat_py_inc_dir = sys.prefix + "/include/python" + vers - plat_py_conf_inc_dir = sys.exec_prefix + "/include/python" + vers - plat_py_lib_dir = lib_dir + "/config" - plat_bin_dir = sys.exec_prefix + "/bin" - plat_sip_dir = sys.prefix + "/share/sip" - - -def create_config(module, template, macros): - """Create the SIP configuration module so that it can be imported by build - scripts. - - module is the module file name. - template is the template file name. - macros is the dictionary of build macros. - """ - siputils.inform("Creating %s..." % module) - - content = { - "sip_config_args": sys.argv[1:], - "sip_version": sip_version, - "sip_version_str": sip_version_str, - "platform": opt_platform, - "sip_bin": os.path.join(opt_sipbindir, "sip"), - "sip_inc_dir": opt_sipincdir, - "sip_mod_dir": opt_sipmoddir, - "default_bin_dir": plat_bin_dir, - "default_mod_dir": plat_py_site_dir, - "default_sip_dir": opt_sipsipdir, - "export_all": opt_export_all, - "py_version": py_version, - "py_inc_dir": plat_py_inc_dir, - "py_conf_inc_dir": plat_py_conf_inc_dir, - "py_lib_dir": plat_py_lib_dir, - "universal": opt_universal - } - - siputils.create_config_module(module, template, content, macros) - - -def create_makefiles(macros): - """Create the Makefiles. - - macros is the dictionary of platform specific build macros. - """ - # Bootstrap. - import sipconfig - - cfg = sipconfig.Configuration() - - cfg.set_build_macros(macros) - - sipconfig.inform("Creating top level Makefile...") - - sipconfig.ParentMakefile( - configuration=cfg, - subdirs=["sipgen", "siplib"], - installs=(["sipconfig.py", "sipdistutils.py"], cfg.sip_mod_dir) - ).generate() - - sipconfig.inform("Creating sip code generator Makefile...") - - sipconfig.ProgramMakefile( - configuration=cfg, - build_file="sipgen.sbf", - dir="sipgen", - install_dir=os.path.dirname(cfg.sip_bin), - console=1, - warnings=0, - universal=opt_universal - ).generate() - - sipconfig.inform("Creating sip module Makefile...") - - makefile = sipconfig.ModuleMakefile( - configuration=cfg, - build_file="siplib.sbf", - dir="siplib", - install_dir=cfg.sip_mod_dir, - installs=(["sip.h"], cfg.sip_inc_dir), - console=1, - warnings=0, - static=opt_static, - debug=opt_debug, - universal=opt_universal - ) - - makefile.generate() - - -def main(argv): - """Create the configuration module module. - - argv is the list of command line arguments. - """ - siputils.inform("This is SIP %s for Python %s on %s." % (sip_version_str, string.split(sys.version)[0], sys.platform)) - - if py_version < 0x020300: - siputils.error("This version of SIP requires Python v2.3 or later.") - - # Basic initialisation. - set_platform_directories() - - # Build up the list of valid specs. - for s in os.listdir("specs"): - platform_specs.append(s) - - # Handle the command line. - set_defaults() - - try: - optlist, args = getopt.getopt(argv[1:], "hab:d:e:knp:uv:") - except getopt.GetoptError: - usage() - - global opt_sipbindir, opt_sipmoddir, opt_sipincdir, opt_sipsipdir - global opt_platform, opt_static, opt_debug, opt_export_all, opt_universal - - for opt, arg in optlist: - if opt == "-h": - usage(0) - elif opt == "-a": - opt_export_all = 1 - elif opt == "-b": - opt_sipbindir = os.path.abspath(arg) - elif opt == "-d": - opt_sipmoddir = os.path.abspath(arg) - elif opt == "-e": - opt_sipincdir = os.path.abspath(arg) - elif opt == "-k": - opt_static = 1 - elif opt == "-n": - # This should probably be determined dynamically or passed as an - # argument. - opt_universal = '/Developer/SDKs/MacOSX10.4u.sdk' - elif opt == "-p": - if arg not in platform_specs: - usage() - - opt_platform = arg - elif opt == "-u": - opt_debug = 1 - elif opt == "-v": - opt_sipsipdir = os.path.abspath(arg) - - if opt_platform is None: - opt_platform = default_platform - - # Get the platform specific macros for building. - macros = siputils.parse_build_macros(os.path.join("specs", opt_platform), build_macro_names, args) - - if macros is None: - usage() - - # Tell the user what's been found. - inform_user() - - # Install the configuration module. - create_config("sipconfig.py", "siputils.py", macros) - - # Create the Makefiles. - create_makefiles(macros) - - -############################################################################### -# The script starts here. -############################################################################### - -if __name__ == "__main__": - try: - main(sys.argv) - except SystemExit: - raise - except: - print \ -"""An internal error occured. Please report all the output from the program, -including the following traceback, to support@riverbankcomputing.co.uk. -""" - raise diff --git a/python/sip/custom/custom.c b/python/sip/custom/custom.c deleted file mode 100644 index e5ec2d25..00000000 --- a/python/sip/custom/custom.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is the basis of a custom Python interpreter. Use it for Linux, - * UNIX and Windows (console). You will also need to edit mkcustom.py. - */ - - -#include <Python.h> - - -int main(int argc, char **argv) -{ - /* - * Declare the module initialisation function for each module you want - * to be a builtin in the custom interpreter. The name of the function - * will be the name of the module with "init" prepended. The modules - * must be built as static libraries (using the -k flag to configure.py - * for SIP and PyQt). - */ - - /* The sip module will be builtin. */ - extern void initsip(void); - - /* - * Uncomment these (and in the structure below) to include the PyQt - * modules as builtins. - */ -/* extern void initqt(void);*/ -/* extern void initqtaxcontainer(void);*/ -/* extern void initqtcanvas(void);*/ -/* extern void initqtext(void);*/ -/* extern void initqtgl(void);*/ -/* extern void initqtnetwork(void);*/ -/* extern void initqtsql(void);*/ -/* extern void initqttable(void);*/ -/* extern void initqtui(void);*/ -/* extern void initqtxml(void);*/ - - /* - * This structure specifies the names and initialisation functions of - * the builtin modules. - */ - struct _inittab builtin_modules[] = { - {"sip", initsip}, -/* {"qt", initqt},*/ -/* {"qtaxcontainer", initqtaxcontainer},*/ -/* {"qtcanvas", initqtcanvas},*/ -/* {"qtext", initqtext},*/ -/* {"qtgl", initqtgl},*/ -/* {"qtnetwork", initqtnetwork},*/ -/* {"qtsql", initqtsql},*/ -/* {"qttable", initqttable},*/ -/* {"qtui", initqtui},*/ -/* {"qtxml", initqtxml},*/ - {NULL, NULL} - }; - - PyImport_ExtendInittab(builtin_modules); - - return Py_Main(argc, argv); -} diff --git a/python/sip/custom/customw.c b/python/sip/custom/customw.c deleted file mode 100644 index 58770766..00000000 --- a/python/sip/custom/customw.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is the basis of a custom Python interpreter. Use it for Windows - * (non-console). You will also need to edit mkcustom.py. - */ - - -#define WIN32_LEAN_AND_MEAN -#include <windows.h> - -#include <Python.h> - - -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPSTR lpCmdLine, int nCmdShow) -{ - /* - * Declare the module initialisation function for each module you want - * to be a builtin in the custom interpreter. The name of the function - * will be the name of the module with "init" prepended. The modules - * must be built as static libraries (using the -k flag to configure.py - * for SIP and PyQt). - */ - - /* The sip module will be builtin. */ - extern void initsip(void); - - /* - * Uncomment these (and in the structure below) to include the PyQt - * modules as builtins. - */ -/* extern void initqt(void);*/ -/* extern void initqtaxcontainer(void);*/ -/* extern void initqtcanvas(void);*/ -/* extern void initqtext(void);*/ -/* extern void initqtgl(void);*/ -/* extern void initqtnetwork(void);*/ -/* extern void initqtsql(void);*/ -/* extern void initqttable(void);*/ -/* extern void initqtui(void);*/ -/* extern void initqtxml(void);*/ - - /* - * This structure specifies the names and initialisation functions of - * the builtin modules. - */ - struct _inittab builtin_modules[] = { - {"sip", initsip}, -/* {"qt", initqt},*/ -/* {"qtaxcontainer", initqtaxcontainer},*/ -/* {"qtcanvas", initqtcanvas},*/ -/* {"qtext", initqtext},*/ -/* {"qtgl", initqtgl},*/ -/* {"qtnetwork", initqtnetwork},*/ -/* {"qtsql", initqtsql},*/ -/* {"qttable", initqttable},*/ -/* {"qtui", initqtui},*/ -/* {"qtxml", initqtxml},*/ - {NULL, NULL} - }; - - PyImport_ExtendInittab(builtin_modules); - - return Py_Main(__argc, __argv); -} diff --git a/python/sip/custom/mkcustom.py b/python/sip/custom/mkcustom.py deleted file mode 100644 index 0e8deabb..00000000 --- a/python/sip/custom/mkcustom.py +++ /dev/null @@ -1,87 +0,0 @@ -"""This Python script uses the SIP build system to create a Makefile for -building a custom Python interpreter. The script doesn't take any command line -flags - just edit it to suit your needs. You will also need to edit custom.c -or customw.c. -""" - - -import sys -import sipconfig - - -# Get the SIP configuration. -cfg = sipconfig.Configuration() - - -# This is the name of the interpreter executable (excluding any platform -# specific extension. -InterpreterName = "custom" - -# Set this to True to create a non-console interpreter on Windows (ie. a custom -# version of pythonw). Make sure you make changes to customw.c rather than -# custom.c. It is ignored on other platforms. -WindowsInterpreter = False - -# Set this to the list of the name of modules to be builtin to the custom -# interpreter. The modules must also be added to custom.c and/or customw.c. -Modules = ["sip"] -#Modules = ["sip", "qt", "qtaxcontainer", "qtcanvas", "qtext", "qtgl", -# "qtnetwork", "qtsql", "qttable", "qtui", "qtxml"] - -# Set this to the name of the directory containing the static modules. -ModuleDirectory = cfg.default_mod_dir - -# Set this to the list of additional libraries to link with the custom -# interpreter. -ExtraLibraries = [] -#ExtraLibraries = ["qassistantclient"] - -# Set this to the list of additional directory names to search for any -# additional libraries. -ExtraLibraryDirectories = [] - -# Set this to the name of the directory containing the Python library. -PythonLibraryDirectory = cfg.py_lib_dir - - -# Make platform specific modifications. -if sys.platform == "linux2": - ExtraLibraries.append("util") - - -# Create a dictionary describing the target and source files to be passed to -# the SIP build system. -build = {} - -if sys.platform == "win32" and WindowsInterpreter: - build["target"] = InterpreterName + "w" - build["sources"] = "customw.c" - console = False -else: - build["target"] = InterpreterName - build["sources"] = "custom.c" - console = True - -# Assume Qt support is required if Qt support was enabled in the sip module. -qt = (cfg.qt_version > 0) - -# Create the Makefile instance. -mf = sipconfig.ProgramMakefile(cfg, build, python=True, console=console, qt=qt) - -# Modify the Makefile according to the values set above. -mf.extra_lib_dirs.extend(ExtraLibraryDirectories) -mf.extra_lib_dirs.append(ModuleDirectory) -mf.extra_lib_dirs.append(PythonLibraryDirectory) - -mf.extra_libs.extend(Modules) - -if sys.platform == "win32": - pylib = "python%u%u" -else: - pylib = "python%u.%u" - -mf.extra_libs.append(pylib % ((cfg.py_version >> 16), ((cfg.py_version >> 8) & 0xff))) -mf.extra_libs.extend(ExtraLibraries) - -# Generate the Makefile itself. -mf.generate() diff --git a/python/sip/doc/default.css b/python/sip/doc/default.css deleted file mode 100644 index 5e077213..00000000 --- a/python/sip/doc/default.css +++ /dev/null @@ -1,229 +0,0 @@ -/* -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:date: $Date$ -:version: $Revision$ -:copyright: This stylesheet has been placed in the public domain. - -Default cascading style sheet for the HTML output of Docutils. -*/ - -.first { - margin-top: 0 } - -.last { - margin-bottom: 0 } - -a.toc-backref { - text-decoration: none ; - color: black } - -dt { - font-weight: bold } - -dd { - margin-bottom: 1.5em } - -div.abstract { - margin: 2em 5em } - -div.abstract p.topic-title { - font-weight: bold ; - text-align: center } - -div.attention, div.caution, div.danger, div.error, div.hint, -div.important, div.note, div.tip, div.warning, div.admonition { - margin: 2em ; - border: medium outset ; - padding: 1em } - -div.attention p.admonition-title, div.caution p.admonition-title, -div.danger p.admonition-title, div.error p.admonition-title, -div.warning p.admonition-title { - color: red ; - font-weight: bold ; - font-family: sans-serif } - -div.hint p.admonition-title, div.important p.admonition-title, -div.note p.admonition-title, div.tip p.admonition-title, -div.admonition p.admonition-title { - font-weight: bold ; - font-family: sans-serif } - -div.dedication { - margin: 2em 5em ; - text-align: center ; - font-style: italic } - -div.dedication p.topic-title { - font-weight: bold ; - font-style: normal } - -div.figure { - margin-left: 2em } - -div.footer, div.header { - font-size: smaller } - -div.sidebar { - margin-left: 1em ; - border: medium outset ; - padding: 0em 1em ; - background-color: #ffffee ; - width: 40% ; - float: right ; - clear: right } - -div.sidebar p.rubric { - font-family: sans-serif ; - font-size: medium } - -div.system-messages { - margin: 5em } - -div.system-messages h1 { - color: red } - -div.system-message { - border: medium outset ; - padding: 1em } - -div.system-message p.system-message-title { - color: red ; - font-weight: bold } - -div.topic { - margin: 2em } - -h1.title { - text-align: center } - -h2.subtitle { - text-align: center } - -hr { - width: 75% } - -ol.simple, ul.simple { - margin-bottom: 1em } - -ol.arabic { - list-style: decimal } - -ol.loweralpha { - list-style: lower-alpha } - -ol.upperalpha { - list-style: upper-alpha } - -ol.lowerroman { - list-style: lower-roman } - -ol.upperroman { - list-style: upper-roman } - -p.attribution { - text-align: right ; - margin-left: 50% } - -p.caption { - font-style: italic } - -p.credits { - font-style: italic ; - font-size: smaller } - -p.label { - white-space: nowrap } - -p.rubric { - font-weight: bold ; - font-size: larger ; - color: maroon ; - text-align: center } - -p.sidebar-title { - font-family: sans-serif ; - font-weight: bold ; - font-size: larger } - -p.sidebar-subtitle { - font-family: sans-serif ; - font-weight: bold } - -p.topic-title { - font-weight: bold } - -pre.address { - margin-bottom: 0 ; - margin-top: 0 ; - font-family: serif ; - font-size: 100% } - -pre.line-block { - font-family: serif ; - font-size: 100% } - -pre.literal-block, pre.doctest-block { - margin-left: 2em ; - margin-right: 2em ; - background-color: #eeeeee } - -span.classifier { - font-family: sans-serif ; - font-style: oblique } - -span.classifier-delimiter { - font-family: sans-serif ; - font-weight: bold } - -span.interpreted { - font-family: sans-serif } - -span.option { - white-space: nowrap } - -span.option-argument { - font-style: italic } - -span.pre { - white-space: pre } - -span.problematic { - color: red } - -table { - margin-top: 0.5em ; - margin-bottom: 0.5em } - -table.citation { - border-left: solid thin gray ; - padding-left: 0.5ex } - -table.docinfo { - margin: 2em 4em } - -table.footnote { - border-left: solid thin black ; - padding-left: 0.5ex } - -td, th { - padding-left: 0.5em ; - padding-right: 0.5em ; - vertical-align: top } - -th.docinfo-name, th.field-name { - font-weight: bold ; - text-align: left ; - white-space: nowrap } - -h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt { - font-size: 100% } - -/* -tt { - background-color: #eeeeee } -*/ - -ul.auto-toc { - list-style-type: none } diff --git a/python/sip/doc/sipref.html b/python/sip/doc/sipref.html deleted file mode 100644 index 71fcbdb4..00000000 --- a/python/sip/doc/sipref.html +++ /dev/null @@ -1,5281 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" /> -<title>SIP - A Tool for Generating Python Bindings for C and C++ Libraries</title> -<meta name="copyright" content="Copyright (c) 2007 Riverbank Computing Limited" /> -<style type="text/css"> - -/* -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Date: $Date$ -:Revision: $Revision$ -:Copyright: This stylesheet has been placed in the public domain. - -Default cascading style sheet for the HTML output of Docutils. - -See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to -customize this style sheet. -*/ - -/* used to remove borders from tables and images */ -.borderless, table.borderless td, table.borderless th { - border: 0 } - -table.borderless td, table.borderless th { - /* Override padding for "table.docutils td" with "! important". - The right padding separates the table cells. */ - padding: 0 0.5em 0 0 ! important } - -.first { - /* Override more specific margin styles with "! important". */ - margin-top: 0 ! important } - -.last, .with-subtitle { - margin-bottom: 0 ! important } - -.hidden { - display: none } - -a.toc-backref { - text-decoration: none ; - color: black } - -blockquote.epigraph { - margin: 2em 5em ; } - -dl.docutils dd { - margin-bottom: 0.5em } - -/* Uncomment (and remove this text!) to get bold-faced definition list terms -dl.docutils dt { - font-weight: bold } -*/ - -div.abstract { - margin: 2em 5em } - -div.abstract p.topic-title { - font-weight: bold ; - text-align: center } - -div.admonition, div.attention, div.caution, div.danger, div.error, -div.hint, div.important, div.note, div.tip, div.warning { - margin: 2em ; - border: medium outset ; - padding: 1em } - -div.admonition p.admonition-title, div.hint p.admonition-title, -div.important p.admonition-title, div.note p.admonition-title, -div.tip p.admonition-title { - font-weight: bold ; - font-family: sans-serif } - -div.attention p.admonition-title, div.caution p.admonition-title, -div.danger p.admonition-title, div.error p.admonition-title, -div.warning p.admonition-title { - color: red ; - font-weight: bold ; - font-family: sans-serif } - -/* Uncomment (and remove this text!) to get reduced vertical space in - compound paragraphs. -div.compound .compound-first, div.compound .compound-middle { - margin-bottom: 0.5em } - -div.compound .compound-last, div.compound .compound-middle { - margin-top: 0.5em } -*/ - -div.dedication { - margin: 2em 5em ; - text-align: center ; - font-style: italic } - -div.dedication p.topic-title { - font-weight: bold ; - font-style: normal } - -div.figure { - margin-left: 2em ; - margin-right: 2em } - -div.footer, div.header { - clear: both; - font-size: smaller } - -div.line-block { - display: block ; - margin-top: 1em ; - margin-bottom: 1em } - -div.line-block div.line-block { - margin-top: 0 ; - margin-bottom: 0 ; - margin-left: 1.5em } - -div.sidebar { - margin-left: 1em ; - border: medium outset ; - padding: 1em ; - background-color: #ffffee ; - width: 40% ; - float: right ; - clear: right } - -div.sidebar p.rubric { - font-family: sans-serif ; - font-size: medium } - -div.system-messages { - margin: 5em } - -div.system-messages h1 { - color: red } - -div.system-message { - border: medium outset ; - padding: 1em } - -div.system-message p.system-message-title { - color: red ; - font-weight: bold } - -div.topic { - margin: 2em } - -h1.section-subtitle, h2.section-subtitle, h3.section-subtitle, -h4.section-subtitle, h5.section-subtitle, h6.section-subtitle { - margin-top: 0.4em } - -h1.title { - text-align: center } - -h2.subtitle { - text-align: center } - -hr.docutils { - width: 75% } - -img.align-left { - clear: left } - -img.align-right { - clear: right } - -ol.simple, ul.simple { - margin-bottom: 1em } - -ol.arabic { - list-style: decimal } - -ol.loweralpha { - list-style: lower-alpha } - -ol.upperalpha { - list-style: upper-alpha } - -ol.lowerroman { - list-style: lower-roman } - -ol.upperroman { - list-style: upper-roman } - -p.attribution { - text-align: right ; - margin-left: 50% } - -p.caption { - font-style: italic } - -p.credits { - font-style: italic ; - font-size: smaller } - -p.label { - white-space: nowrap } - -p.rubric { - font-weight: bold ; - font-size: larger ; - color: maroon ; - text-align: center } - -p.sidebar-title { - font-family: sans-serif ; - font-weight: bold ; - font-size: larger } - -p.sidebar-subtitle { - font-family: sans-serif ; - font-weight: bold } - -p.topic-title { - font-weight: bold } - -pre.address { - margin-bottom: 0 ; - margin-top: 0 ; - font-family: serif ; - font-size: 100% } - -pre.literal-block, pre.doctest-block { - margin-left: 2em ; - margin-right: 2em ; - background-color: #eeeeee } - -span.classifier { - font-family: sans-serif ; - font-style: oblique } - -span.classifier-delimiter { - font-family: sans-serif ; - font-weight: bold } - -span.interpreted { - font-family: sans-serif } - -span.option { - white-space: nowrap } - -span.pre { - white-space: pre } - -span.problematic { - color: red } - -span.section-subtitle { - /* font-size relative to parent (h1..h6 element) */ - font-size: 80% } - -table.citation { - border-left: solid 1px gray; - margin-left: 1px } - -table.docinfo { - margin: 2em 4em } - -table.docutils { - margin-top: 0.5em ; - margin-bottom: 0.5em } - -table.footnote { - border-left: solid 1px black; - margin-left: 1px } - -table.docutils td, table.docutils th, -table.docinfo td, table.docinfo th { - padding-left: 0.5em ; - padding-right: 0.5em ; - vertical-align: top } - -table.docutils th.field-name, table.docinfo th.docinfo-name { - font-weight: bold ; - text-align: left ; - white-space: nowrap ; - padding-left: 0 } - -h1 tt.docutils, h2 tt.docutils, h3 tt.docutils, -h4 tt.docutils, h5 tt.docutils, h6 tt.docutils { - font-size: 100% } - -tt.docutils { - background-color: #eeeeee } - -ul.auto-toc { - list-style-type: none } - -</style> -</head> -<body> -<div class="document" id="sip-a-tool-for-generating-python-bindings-for-c-and-c-libraries"> -<h1 class="title">SIP - A Tool for Generating Python Bindings for C and C++ Libraries</h1> -<h2 class="subtitle" id="reference-guide">Reference Guide</h2> -<table class="docinfo" frame="void" rules="none"> -<col class="docinfo-name" /> -<col class="docinfo-content" /> -<tbody valign="top"> -<tr><th class="docinfo-name">Contact:</th> -<td><a class="first last reference" href="mailto:info@riverbankcomputing.co.uk">info@riverbankcomputing.co.uk</a></td></tr> -<tr><th class="docinfo-name">Version:</th> -<td>4.6</td></tr> -<tr><th class="docinfo-name">Copyright:</th> -<td>Copyright (c) 2007 Riverbank Computing Limited</td></tr> -</tbody> -</table> -<div class="contents topic"> -<p class="topic-title first"><a id="contents" name="contents">Contents</a></p> -<ul class="auto-toc simple"> -<li><a class="reference" href="#introduction" id="id22" name="id22">1 Introduction</a><ul class="auto-toc"> -<li><a class="reference" href="#license" id="id23" name="id23">1.1 License</a></li> -<li><a class="reference" href="#features" id="id24" name="id24">1.2 Features</a></li> -<li><a class="reference" href="#sip-components" id="id25" name="id25">1.3 SIP Components</a></li> -<li><a class="reference" href="#qt-support" id="id26" name="id26">1.4 Qt Support</a></li> -</ul> -</li> -<li><a class="reference" href="#potential-incompatibilities-with-earlier-versions" id="id27" name="id27">2 Potential Incompatibilities with Earlier Versions</a><ul class="auto-toc"> -<li><a class="reference" href="#sip-v4-4" id="id28" name="id28">2.1 SIP v4.4</a></li> -</ul> -</li> -<li><a class="reference" href="#installing-sip" id="id29" name="id29">3 Installing SIP</a><ul class="auto-toc"> -<li><a class="reference" href="#downloading-sip" id="id30" name="id30">3.1 Downloading SIP</a></li> -<li><a class="reference" href="#configuring-sip" id="id31" name="id31">3.2 Configuring SIP</a><ul class="auto-toc"> -<li><a class="reference" href="#configuring-sip-using-mingw" id="id32" name="id32">3.2.1 Configuring SIP Using MinGW</a></li> -<li><a class="reference" href="#configuring-sip-using-the-borland-c-compiler" id="id33" name="id33">3.2.2 Configuring SIP Using the Borland C++ Compiler</a></li> -</ul> -</li> -<li><a class="reference" href="#building-sip" id="id34" name="id34">3.3 Building SIP</a></li> -</ul> -</li> -<li><a class="reference" href="#using-sip" id="id35" name="id35">4 Using SIP</a><ul class="auto-toc"> -<li><a class="reference" href="#a-simple-c-example" id="id36" name="id36">4.1 A Simple C++ Example</a></li> -<li><a class="reference" href="#id7" id="id37" name="id37">4.2 A Simple C Example</a></li> -<li><a class="reference" href="#a-more-complex-c-example" id="id38" name="id38">4.3 A More Complex C++ Example</a></li> -<li><a class="reference" href="#ownership-of-objects" id="id39" name="id39">4.4 Ownership of Objects</a></li> -<li><a class="reference" href="#support-for-wide-characters" id="id40" name="id40">4.5 Support for Wide Characters</a></li> -<li><a class="reference" href="#the-python-global-interpreter-lock" id="id41" name="id41">4.6 The Python Global Interpreter Lock</a></li> -</ul> -</li> -<li><a class="reference" href="#the-sip-command-line" id="id42" name="id42">5 The SIP Command Line</a></li> -<li><a class="reference" href="#sip-specification-files" id="id43" name="id43">6 SIP Specification Files</a><ul class="auto-toc"> -<li><a class="reference" href="#syntax-definition" id="id44" name="id44">6.1 Syntax Definition</a></li> -<li><a class="reference" href="#variable-numbers-of-arguments" id="id45" name="id45">6.2 Variable Numbers of Arguments</a></li> -<li><a class="reference" href="#additional-sip-types" id="id46" name="id46">6.3 Additional SIP Types</a><ul class="auto-toc"> -<li><a class="reference" href="#sip-anyslot" id="id47" name="id47">6.3.1 SIP_ANYSLOT</a></li> -<li><a class="reference" href="#sip-pycallable" id="id48" name="id48">6.3.2 SIP_PYCALLABLE</a></li> -<li><a class="reference" href="#sip-pydict" id="id49" name="id49">6.3.3 SIP_PYDICT</a></li> -<li><a class="reference" href="#sip-pylist" id="id50" name="id50">6.3.4 SIP_PYLIST</a></li> -<li><a class="reference" href="#sip-pyobject" id="id51" name="id51">6.3.5 SIP_PYOBJECT</a></li> -<li><a class="reference" href="#sip-pyslice" id="id52" name="id52">6.3.6 SIP_PYSLICE</a></li> -<li><a class="reference" href="#sip-pytuple" id="id53" name="id53">6.3.7 SIP_PYTUPLE</a></li> -<li><a class="reference" href="#sip-pytype" id="id54" name="id54">6.3.8 SIP_PYTYPE</a></li> -<li><a class="reference" href="#sip-qobject" id="id55" name="id55">6.3.9 SIP_QOBJECT</a></li> -<li><a class="reference" href="#sip-rxobj-con" id="id56" name="id56">6.3.10 SIP_RXOBJ_CON</a></li> -<li><a class="reference" href="#sip-rxobj-dis" id="id57" name="id57">6.3.11 SIP_RXOBJ_DIS</a></li> -<li><a class="reference" href="#sip-signal" id="id58" name="id58">6.3.12 SIP_SIGNAL</a></li> -<li><a class="reference" href="#sip-slot" id="id59" name="id59">6.3.13 SIP_SLOT</a></li> -<li><a class="reference" href="#sip-slot-con" id="id60" name="id60">6.3.14 SIP_SLOT_CON</a></li> -<li><a class="reference" href="#sip-slot-dis" id="id61" name="id61">6.3.15 SIP_SLOT_DIS</a></li> -</ul> -</li> -</ul> -</li> -<li><a class="reference" href="#sip-directives" id="id62" name="id62">7 SIP Directives</a><ul class="auto-toc"> -<li><a class="reference" href="#accesscode" id="id63" name="id63">7.1 %AccessCode</a></li> -<li><a class="reference" href="#bigetcharbuffercode" id="id64" name="id64">7.2 %BIGetCharBufferCode</a></li> -<li><a class="reference" href="#bigetreadbuffercode" id="id65" name="id65">7.3 %BIGetReadBufferCode</a></li> -<li><a class="reference" href="#bigetsegcountcode" id="id66" name="id66">7.4 %BIGetSegCountCode</a></li> -<li><a class="reference" href="#bigetwritebuffercode" id="id67" name="id67">7.5 %BIGetWriteBufferCode</a></li> -<li><a class="reference" href="#cmodule" id="id68" name="id68">7.6 %CModule</a></li> -<li><a class="reference" href="#convertfromtypecode" id="id69" name="id69">7.7 %ConvertFromTypeCode</a></li> -<li><a class="reference" href="#converttosubclasscode" id="id70" name="id70">7.8 %ConvertToSubClassCode</a></li> -<li><a class="reference" href="#converttotypecode" id="id71" name="id71">7.9 %ConvertToTypeCode</a></li> -<li><a class="reference" href="#copying" id="id72" name="id72">7.10 %Copying</a></li> -<li><a class="reference" href="#doc" id="id73" name="id73">7.11 %Doc</a></li> -<li><a class="reference" href="#end" id="id74" name="id74">7.12 %End</a></li> -<li><a class="reference" href="#exception" id="id75" name="id75">7.13 %Exception</a></li> -<li><a class="reference" href="#exporteddoc" id="id76" name="id76">7.14 %ExportedDoc</a></li> -<li><a class="reference" href="#exportedheadercode" id="id77" name="id77">7.15 %ExportedHeaderCode</a></li> -<li><a class="reference" href="#feature" id="id78" name="id78">7.16 %Feature</a></li> -<li><a class="reference" href="#gcclearcode" id="id79" name="id79">7.17 %GCClearCode</a></li> -<li><a class="reference" href="#gctraversecode" id="id80" name="id80">7.18 %GCTraverseCode</a></li> -<li><a class="reference" href="#getcode" id="id81" name="id81">7.19 %GetCode</a></li> -<li><a class="reference" href="#if" id="id82" name="id82">7.20 %If</a></li> -<li><a class="reference" href="#import" id="id83" name="id83">7.21 %Import</a></li> -<li><a class="reference" href="#include" id="id84" name="id84">7.22 %Include</a></li> -<li><a class="reference" href="#id14" id="id85" name="id85">7.23 %License</a></li> -<li><a class="reference" href="#mappedtype" id="id86" name="id86">7.24 %MappedType</a></li> -<li><a class="reference" href="#methodcode" id="id87" name="id87">7.25 %MethodCode</a></li> -<li><a class="reference" href="#module" id="id88" name="id88">7.26 %Module</a></li> -<li><a class="reference" href="#modulecode" id="id89" name="id89">7.27 %ModuleCode</a></li> -<li><a class="reference" href="#moduleheadercode" id="id90" name="id90">7.28 %ModuleHeaderCode</a></li> -<li><a class="reference" href="#optionalinclude" id="id91" name="id91">7.29 %OptionalInclude</a></li> -<li><a class="reference" href="#platforms" id="id92" name="id92">7.30 %Platforms</a></li> -<li><a class="reference" href="#postinitialisationcode" id="id93" name="id93">7.31 %PostInitialisationCode</a></li> -<li><a class="reference" href="#preinitialisationcode" id="id94" name="id94">7.32 %PreInitialisationCode</a></li> -<li><a class="reference" href="#raisecode" id="id95" name="id95">7.33 %RaiseCode</a></li> -<li><a class="reference" href="#setcode" id="id96" name="id96">7.34 %SetCode</a></li> -<li><a class="reference" href="#sipoptions" id="id97" name="id97">7.35 %SIPOptions</a></li> -<li><a class="reference" href="#timeline" id="id98" name="id98">7.36 %Timeline</a></li> -<li><a class="reference" href="#typecode" id="id99" name="id99">7.37 %TypeCode</a></li> -<li><a class="reference" href="#typeheadercode" id="id100" name="id100">7.38 %TypeHeaderCode</a></li> -<li><a class="reference" href="#unitcode" id="id101" name="id101">7.39 %UnitCode</a></li> -<li><a class="reference" href="#virtualcatchercode" id="id102" name="id102">7.40 %VirtualCatcherCode</a></li> -</ul> -</li> -<li><a class="reference" href="#sip-annotations" id="id103" name="id103">8 SIP Annotations</a><ul class="auto-toc"> -<li><a class="reference" href="#argument-annotations" id="id104" name="id104">8.1 Argument Annotations</a><ul class="auto-toc"> -<li><a class="reference" href="#allownone" id="id105" name="id105">8.1.1 AllowNone</a></li> -<li><a class="reference" href="#array" id="id106" name="id106">8.1.2 Array</a></li> -<li><a class="reference" href="#arraysize" id="id107" name="id107">8.1.3 ArraySize</a></li> -<li><a class="reference" href="#constrained" id="id108" name="id108">8.1.4 Constrained</a></li> -<li><a class="reference" href="#getwrapper" id="id109" name="id109">8.1.5 GetWrapper</a></li> -<li><a class="reference" href="#in" id="id110" name="id110">8.1.6 In</a></li> -<li><a class="reference" href="#out" id="id111" name="id111">8.1.7 Out</a></li> -<li><a class="reference" href="#transfer" id="id112" name="id112">8.1.8 Transfer</a></li> -<li><a class="reference" href="#transferback" id="id113" name="id113">8.1.9 TransferBack</a></li> -<li><a class="reference" href="#transferthis" id="id114" name="id114">8.1.10 TransferThis</a></li> -</ul> -</li> -<li><a class="reference" href="#class-annotations" id="id115" name="id115">8.2 Class Annotations</a><ul class="auto-toc"> -<li><a class="reference" href="#abstract" id="id116" name="id116">8.2.1 Abstract</a></li> -<li><a class="reference" href="#delaydtor" id="id117" name="id117">8.2.2 DelayDtor</a></li> -<li><a class="reference" href="#external" id="id118" name="id118">8.2.3 External</a></li> -<li><a class="reference" href="#nodefaultctors" id="id119" name="id119">8.2.4 NoDefaultCtors</a></li> -<li><a class="reference" href="#pyname" id="id120" name="id120">8.2.5 PyName</a></li> -</ul> -</li> -<li><a class="reference" href="#enum-annotations" id="id121" name="id121">8.3 Enum Annotations</a><ul class="auto-toc"> -<li><a class="reference" href="#id17" id="id122" name="id122">8.3.1 PyName</a></li> -</ul> -</li> -<li><a class="reference" href="#exception-annotations" id="id123" name="id123">8.4 Exception Annotations</a><ul class="auto-toc"> -<li><a class="reference" href="#id18" id="id124" name="id124">8.4.1 PyName</a></li> -</ul> -</li> -<li><a class="reference" href="#function-annotations" id="id125" name="id125">8.5 Function Annotations</a><ul class="auto-toc"> -<li><a class="reference" href="#autogen" id="id126" name="id126">8.5.1 AutoGen</a></li> -<li><a class="reference" href="#default" id="id127" name="id127">8.5.2 Default</a></li> -<li><a class="reference" href="#factory" id="id128" name="id128">8.5.3 Factory</a></li> -<li><a class="reference" href="#holdgil" id="id129" name="id129">8.5.4 HoldGIL</a></li> -<li><a class="reference" href="#newthread" id="id130" name="id130">8.5.5 NewThread</a></li> -<li><a class="reference" href="#noderived" id="id131" name="id131">8.5.6 NoDerived</a></li> -<li><a class="reference" href="#numeric" id="id132" name="id132">8.5.7 Numeric</a></li> -<li><a class="reference" href="#posthook" id="id133" name="id133">8.5.8 PostHook</a></li> -<li><a class="reference" href="#prehook" id="id134" name="id134">8.5.9 PreHook</a></li> -<li><a class="reference" href="#id19" id="id135" name="id135">8.5.10 PyName</a></li> -<li><a class="reference" href="#releasegil" id="id136" name="id136">8.5.11 ReleaseGIL</a></li> -<li><a class="reference" href="#id20" id="id137" name="id137">8.5.12 TransferBack</a></li> -</ul> -</li> -<li><a class="reference" href="#license-annotations" id="id138" name="id138">8.6 License Annotations</a><ul class="auto-toc"> -<li><a class="reference" href="#licensee" id="id139" name="id139">8.6.1 Licensee</a></li> -<li><a class="reference" href="#signature" id="id140" name="id140">8.6.2 Signature</a></li> -<li><a class="reference" href="#timestamp" id="id141" name="id141">8.6.3 Timestamp</a></li> -<li><a class="reference" href="#type" id="id142" name="id142">8.6.4 Type</a></li> -</ul> -</li> -<li><a class="reference" href="#variable-annotations" id="id143" name="id143">8.7 Variable Annotations</a><ul class="auto-toc"> -<li><a class="reference" href="#id21" id="id144" name="id144">8.7.1 PyName</a></li> -</ul> -</li> -</ul> -</li> -<li><a class="reference" href="#sip-api-for-handwritten-code" id="id145" name="id145">9 SIP API for Handwritten Code</a><ul class="auto-toc"> -<li><a class="reference" href="#sip-api-major-nr" id="id146" name="id146">9.1 SIP_API_MAJOR_NR</a></li> -<li><a class="reference" href="#sip-api-minor-nr" id="id147" name="id147">9.2 SIP_API_MINOR_NR</a></li> -<li><a class="reference" href="#sip-block-threads" id="id148" name="id148">9.3 SIP_BLOCK_THREADS</a></li> -<li><a class="reference" href="#sip-ssize-t" id="id149" name="id149">9.4 SIP_SSIZE_T</a></li> -<li><a class="reference" href="#sip-unblock-threads" id="id150" name="id150">9.5 SIP_UNBLOCK_THREADS</a></li> -<li><a class="reference" href="#sip-version" id="id151" name="id151">9.6 SIP_VERSION</a></li> -<li><a class="reference" href="#sip-version-str" id="id152" name="id152">9.7 SIP_VERSION_STR</a></li> -<li><a class="reference" href="#sipbadcatcherresult" id="id153" name="id153">9.8 sipBadCatcherResult()</a></li> -<li><a class="reference" href="#sipbadlengthforslice" id="id154" name="id154">9.9 sipBadLengthForSlice()</a></li> -<li><a class="reference" href="#sipbuildresult" id="id155" name="id155">9.10 sipBuildResult()</a></li> -<li><a class="reference" href="#sipcallmethod" id="id156" name="id156">9.11 sipCallMethod()</a></li> -<li><a class="reference" href="#sipcanconverttoinstance" id="id157" name="id157">9.12 sipCanConvertToInstance()</a></li> -<li><a class="reference" href="#sipcanconverttomappedtype" id="id158" name="id158">9.13 sipCanConvertToMappedType()</a></li> -<li><a class="reference" href="#sipclassname" id="id159" name="id159">9.14 sipClassName()</a></li> -<li><a class="reference" href="#sipconnectrx" id="id160" name="id160">9.15 sipConnectRx()</a></li> -<li><a class="reference" href="#sipconvertfrominstance" id="id161" name="id161">9.16 sipConvertFromInstance()</a></li> -<li><a class="reference" href="#sipconvertfrommappedtype" id="id162" name="id162">9.17 sipConvertFromMappedType()</a></li> -<li><a class="reference" href="#sipconvertfromnamedenum" id="id163" name="id163">9.18 sipConvertFromNamedEnum()</a></li> -<li><a class="reference" href="#sipconvertfromnewinstance" id="id164" name="id164">9.19 sipConvertFromNewInstance()</a></li> -<li><a class="reference" href="#sipconvertfromsequenceindex" id="id165" name="id165">9.20 sipConvertFromSequenceIndex()</a></li> -<li><a class="reference" href="#sipconvertfromsliceobject" id="id166" name="id166">9.21 sipConvertFromSliceObject()</a></li> -<li><a class="reference" href="#sipconverttocpp" id="id167" name="id167">9.22 sipConvertToCpp()</a></li> -<li><a class="reference" href="#sipconverttoinstance" id="id168" name="id168">9.23 sipConvertToInstance()</a></li> -<li><a class="reference" href="#sipconverttomappedtype" id="id169" name="id169">9.24 sipConvertToMappedType()</a></li> -<li><a class="reference" href="#sipdisconnectrx" id="id170" name="id170">9.25 sipDisconnectRx()</a></li> -<li><a class="reference" href="#sipemitsignal" id="id171" name="id171">9.26 sipEmitSignal()</a></li> -<li><a class="reference" href="#sipexportsymbol" id="id172" name="id172">9.27 sipExportSymbol()</a></li> -<li><a class="reference" href="#sipfindclass" id="id173" name="id173">9.28 sipFindClass()</a></li> -<li><a class="reference" href="#sipfindmappedtype" id="id174" name="id174">9.29 sipFindMappedType()</a></li> -<li><a class="reference" href="#sipfindnamedenum" id="id175" name="id175">9.30 sipFindNamedEnum()</a></li> -<li><a class="reference" href="#sipforceconverttoinstance" id="id176" name="id176">9.31 sipForceConvertToInstance()</a></li> -<li><a class="reference" href="#sipforceconverttomappedtype" id="id177" name="id177">9.32 sipForceConvertToMappedType()</a></li> -<li><a class="reference" href="#sipfree" id="id178" name="id178">9.33 sipFree()</a></li> -<li><a class="reference" href="#sipgetsender" id="id179" name="id179">9.34 sipGetSender()</a></li> -<li><a class="reference" href="#sipgetwrapper" id="id180" name="id180">9.35 sipGetWrapper()</a></li> -<li><a class="reference" href="#sipimportsymbol" id="id181" name="id181">9.36 sipImportSymbol()</a></li> -<li><a class="reference" href="#sipinttypeclassmap" id="id182" name="id182">9.37 sipIntTypeClassMap</a></li> -<li><a class="reference" href="#sipissubclassinstance" id="id183" name="id183">9.38 sipIsSubClassInstance()</a></li> -<li><a class="reference" href="#siplong-asunsignedlong" id="id184" name="id184">9.39 sipLong_AsUnsignedLong()</a></li> -<li><a class="reference" href="#sipmalloc" id="id185" name="id185">9.40 sipMalloc()</a></li> -<li><a class="reference" href="#sipmapinttoclass" id="id186" name="id186">9.41 sipMapIntToClass()</a></li> -<li><a class="reference" href="#sipmapstringtoclass" id="id187" name="id187">9.42 sipMapStringToClass()</a></li> -<li><a class="reference" href="#sipparseresult" id="id188" name="id188">9.43 sipParseResult()</a></li> -<li><a class="reference" href="#sipreleaseinstance" id="id189" name="id189">9.44 sipReleaseInstance()</a></li> -<li><a class="reference" href="#sipreleasemappedtype" id="id190" name="id190">9.45 sipReleaseMappedType()</a></li> -<li><a class="reference" href="#sipstringtypeclassmap" id="id191" name="id191">9.46 sipStringTypeClassMap</a></li> -<li><a class="reference" href="#siptransfer" id="id192" name="id192">9.47 sipTransfer()</a></li> -<li><a class="reference" href="#siptransferback" id="id193" name="id193">9.48 sipTransferBack()</a></li> -<li><a class="reference" href="#siptransferto" id="id194" name="id194">9.49 sipTransferTo()</a></li> -<li><a class="reference" href="#sipwrapper" id="id195" name="id195">9.50 sipWrapper</a></li> -<li><a class="reference" href="#sipwrapper-check" id="id196" name="id196">9.51 sipWrapper_Check()</a></li> -<li><a class="reference" href="#sipwrappertype" id="id197" name="id197">9.52 sipWrapperType</a></li> -<li><a class="reference" href="#generated-type-convertors" id="id198" name="id198">9.53 Generated Type Convertors</a></li> -<li><a class="reference" href="#generated-type-objects" id="id199" name="id199">9.54 Generated Type Objects</a></li> -<li><a class="reference" href="#generated-named-enum-type-objects" id="id200" name="id200">9.55 Generated Named Enum Type Objects</a></li> -<li><a class="reference" href="#generated-derived-classes" id="id201" name="id201">9.56 Generated Derived Classes</a></li> -<li><a class="reference" href="#generated-exception-objects" id="id202" name="id202">9.57 Generated Exception Objects</a></li> -</ul> -</li> -<li><a class="reference" href="#using-the-sip-module-in-applications" id="id203" name="id203">10 Using the SIP Module in Applications</a></li> -<li><a class="reference" href="#the-sip-build-system" id="id204" name="id204">11 The SIP Build System</a><ul class="auto-toc"> -<li><a class="reference" href="#sipconfig-functions" id="id205" name="id205">11.1 <tt class="docutils literal"><span class="pre">sipconfig</span></tt> Functions</a></li> -<li><a class="reference" href="#sipconfig-classes" id="id206" name="id206">11.2 <tt class="docutils literal"><span class="pre">sipconfig</span></tt> Classes</a></li> -</ul> -</li> -<li><a class="reference" href="#building-your-extension-with-distutils" id="id207" name="id207">12 Building Your Extension with distutils</a></li> -<li><a class="reference" href="#builtin-modules-and-custom-interpreters" id="id208" name="id208">13 Builtin Modules and Custom Interpreters</a></li> -</ul> -</div> -<div class="section"> -<h1><a class="toc-backref" href="#id22" id="introduction" name="introduction">1 Introduction</a></h1> -<p>This is the reference guide for SIP 4.6. SIP is a tool for -automatically generating <a class="reference" href="http://www.python.org">Python</a> bindings for C and -C++ libraries. SIP was originally developed in 1998 for -<a class="reference" href="http://www.riverbankcomputing.co.uk/pyqt/">PyQt</a> - the Python bindings for -the Qt GUI toolkit - but is suitable for generating bindings for any C or C++ -library.</p> -<p>This version of SIP generates bindings for Python v2.3 or later.</p> -<p>There are many other similar tools available. One of the original such tools -is <a class="reference" href="http://www.swig.org">SWIG</a> and, in fact, SIP is so called because it -started out as a small SWIG. Unlike SWIG, SIP is specifically designed for -bringing together Python and C/C++ and goes to great lengths to make the -integration as tight as possible.</p> -<p>The homepage for SIP is <a class="reference" href="http://www.riverbankcomputing.co.uk/sip/">http://www.riverbankcomputing.co.uk/sip/</a>. Here you -will always find the latest stable version, current development snapshots, and -the latest version of this documentation.</p> -<div class="section"> -<h2><a class="toc-backref" href="#id23" id="license" name="license">1.1 License</a></h2> -<p>SIP is licensed under the same terms as Python itself. SIP places no -restrictions on the license you may apply to the bindings you create.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id24" id="features" name="features">1.2 Features</a></h2> -<p>SIP, and the bindings it produces, have the following features.</p> -<blockquote> -<ul class="simple"> -<li>bindings are fast to load and minimise memory consumption especially when -only a small sub-set of a large library is being used</li> -<li>automatic conversion between standard Python and C/C++ data types</li> -<li>overloading of functions and methods with different argument signatures</li> -<li>access to a C++ class's protected methods</li> -<li>the ability to define a Python class that is a sub-class of a C++ class, -including abstract C++ classes</li> -<li>Python sub-classes can implement the <tt class="docutils literal"><span class="pre">__dtor__(self)</span></tt> method which -will be called from the C++ class's virtual destructor</li> -<li>support for ordinary C++ functions, class methods, static class methods, -virtual class methods and abstract class methods</li> -<li>the ability to re-implement C++ virtual and abstract methods in Python</li> -<li>support for global and class variables</li> -<li>support for global and class operators</li> -<li>support for C++ namespaces</li> -<li>support for C++ templates</li> -<li>support for C++ exceptions and wrapping them as Python exceptions</li> -<li>the ability to define mappings between C++ classes and similar Python -data types that are automatically invoked</li> -<li>the ability to automatically exploit any available run time type -information to ensure that the class of a Python instance object matches -the class of the corresponding C++ instance</li> -<li>full support of the Python global interpreter lock, including the ability -to specify that a C++ function of method may block, therefore allowing -the lock to be released and other Python threads to run</li> -<li>support for the concept of ownership of a C++ instance (i.e. what part of -the code is responsible for calling the instance's destructor) and how -the ownership may change during the execution of an application</li> -<li>the ability to generate bindings for a C++ class library that itself is -built on another C++ class library which also has had bindings generated -so that the different bindings integrate and share code properly</li> -<li>a sophisticated versioning system that allows the full lifetime of a C++ -class library, including any platform specific or optional features, to -be described in a single set of specification files</li> -<li>the ability to include documentation in the specification files which can -be extracted and subsequently processed by external tools</li> -<li>the ability to include copyright notices and licensing information in the -specification files that is automatically included in all generated -source code</li> -<li>a build system, written in Python, that you can extend to configure, -compile and install your own bindings without worrying about platform -specific issues</li> -<li>support for building your extensions using distutils</li> -<li>SIP, and the bindings it produces, runs under UNIX, Linux, Windows and -MacOS/X</li> -</ul> -</blockquote> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id25" id="sip-components" name="sip-components">1.3 SIP Components</a></h2> -<p>SIP comprises a number of different components.</p> -<blockquote> -<ul class="simple"> -<li>The SIP code generator (<tt class="docutils literal"><span class="pre">sip</span></tt> or <tt class="docutils literal"><span class="pre">sip.exe</span></tt>). This processes <tt class="docutils literal"><span class="pre">.sip</span></tt> -specification files and generates C or C++ bindings. It is covered in -detail in <a class="reference" href="#using-sip">Using SIP</a>.</li> -<li>The SIP header file (<tt class="docutils literal"><span class="pre">sip.h</span></tt>). This contains definitions and data -structures needed by the generated C and C++ code.</li> -<li>The SIP module (<tt class="docutils literal"><span class="pre">sip.so</span></tt> or <tt class="docutils literal"><span class="pre">sip.pyd</span></tt>). This is a Python extension -module that is imported automatically by SIP generated bindings and -provides them with some common utility functions. See also <a class="reference" href="#using-the-sip-module-in-applications">Using the -SIP Module in Applications</a>.</li> -<li>The SIP build system (<tt class="docutils literal"><span class="pre">sipconfig.py</span></tt>). This is a pure Python module -that is created when SIP is configured and encapsulates all the necessary -information about your system including relevant directory names, -compiler and linker flags, and version numbers. It also includes several -Python classes and functions which help you write configuration scripts -for your own bindings. It is covered in detail in <a class="reference" href="#the-sip-build-system">The SIP Build -System</a>.</li> -<li>The SIP distutils extension (<tt class="docutils literal"><span class="pre">sipdistutils.py</span></tt>). This is a distutils -extension that can be used to build your extension modules using -distutils and is an alternative to writing configuration scripts with the -SIP build system. This can be as simple as adding your .sip files to the -list of files needed to build the extension module. It is covered in -detail in <a class="reference" href="#building-your-extension-with-distutils">Building Your Extension with distutils</a>.</li> -</ul> -</blockquote> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id26" id="qt-support" name="qt-support">1.4 Qt Support</a></h2> -<p>SIP has specific support for the creation of bindings based on Trolltech's Qt -toolkit.</p> -<p>The SIP code generator understands the signal/slot type safe callback mechanism -that Qt uses to connect objects together. This allows applications to define -new Python signals, and allows any Python callable object to be used as a slot.</p> -<p>SIP itself does not require Qt to be installed.</p> -</div> -</div> -<div class="section"> -<h1><a class="toc-backref" href="#id27" id="potential-incompatibilities-with-earlier-versions" name="potential-incompatibilities-with-earlier-versions">2 Potential Incompatibilities with Earlier Versions</a></h1> -<div class="section"> -<h2><a class="toc-backref" href="#id28" id="sip-v4-4" name="sip-v4-4">2.1 SIP v4.4</a></h2> -<blockquote> -<ul class="simple"> -<li>The <tt class="docutils literal"><span class="pre">SIP_BUILD</span></tt> C preprocessor symbol has been removed.</li> -<li><a class="reference" href="#sipconverttocpp">sipConvertToCpp()</a>, <a class="reference" href="#sipissubclassinstance">sipIsSubClassInstance()</a> and the old <a class="reference" href="#generated-type-convertors">Generated -Type Convertors</a> have been deprecated. The functions -<a class="reference" href="#sipcanconverttoinstance">sipCanConvertToInstance()</a>, <a class="reference" href="#sipconverttoinstance">sipConvertToInstance()</a>, -<a class="reference" href="#sipforceconverttoinstance">sipForceConvertToInstance()</a>, <a class="reference" href="#sipconvertfrominstance">sipConvertFromInstance()</a>, -<a class="reference" href="#sipconvertfromnewinstance">sipConvertFromNewInstance()</a>, <a class="reference" href="#sipcanconverttomappedtype">sipCanConvertToMappedType()</a>, -<a class="reference" href="#sipconverttomappedtype">sipConvertToMappedType()</a>, <a class="reference" href="#sipforceconverttomappedtype">sipForceConvertToMappedType()</a> and -<a class="reference" href="#sipconvertfrommappedtype">sipConvertFromMappedType()</a> should be used instead. Handwritten -<a class="reference" href="#convertfromtypecode">%ConvertFromTypeCode</a> and <a class="reference" href="#converttotypecode">%ConvertToTypeCode</a> now has the -responsibility for using these to implement the <tt class="docutils literal"><span class="pre">Transfer</span></tt> and -<tt class="docutils literal"><span class="pre">TransferBack</span></tt> annotations.</li> -</ul> -</blockquote> -</div> -</div> -<div class="section"> -<h1><a class="toc-backref" href="#id29" id="installing-sip" name="installing-sip">3 Installing SIP</a></h1> -<div class="section"> -<h2><a class="toc-backref" href="#id30" id="downloading-sip" name="downloading-sip">3.1 Downloading SIP</a></h2> -<p>You can get the latest release of the SIP source code from -<a class="reference" href="http://www.riverbankcomputing.co.uk/sip/download.php">http://www.riverbankcomputing.co.uk/sip/download.php</a>.</p> -<p>SIP is also included with all of the major Linux distributions. However, it -may be a version or two out of date.</p> -<p>You may also find more up to date pre-compiled binaries on -<a class="reference" href="http://sourceforge.net/project/showfiles.php?group_id=61057">SourceForge</a>.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id31" id="configuring-sip" name="configuring-sip">3.2 Configuring SIP</a></h2> -<p>After unpacking the source package (either a <tt class="docutils literal"><span class="pre">.tar.gz</span></tt> or a <tt class="docutils literal"><span class="pre">.zip</span></tt> file -depending on your platform) you should then check for any <tt class="docutils literal"><span class="pre">README</span></tt> files -that relate to your platform.</p> -<p>Next you need to configure SIP by executing the <tt class="docutils literal"><span class="pre">configure.py</span></tt> script. For -example:</p> -<pre class="literal-block"> -python configure.py -</pre> -<p>This assumes that the Python interpreter is on your path. Something like the -following may be appropriate on Windows:</p> -<pre class="literal-block"> -c:\python25\python configure.py -</pre> -<p>If you have multiple versions of Python installed then make sure you use the -interpreter for which you wish SIP to generate bindings for.</p> -<p>The full set of command line options is:</p> -<table class="docutils option-list" frame="void" rules="none"> -<col class="option" /> -<col class="description" /> -<tbody valign="top"> -<tr><td class="option-group"> -<kbd><span class="option">-h</span></kbd></td> -<td>Display a help message.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-a</span></kbd></td> -<td>Export all symbols in any SIP generated module and the SIP module -itself. This was the default behaviour of SIP prior to v4.2. -Normally only a module's inititialisation function is exported. This -option is deprecated as the <tt class="docutils literal"><span class="pre">ModuleMakefile</span></tt> class of <a class="reference" href="#the-sip-build-system">The SIP Build -System</a> allows this to be specified on a per module basis.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-b <var>dir</var></span></kbd></td> -<td>The SIP code generator will be installed in the directory <tt class="docutils literal"><span class="pre">dir</span></tt>.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-d <var>dir</var></span></kbd></td> -<td>The SIP module will be installed in the directory <tt class="docutils literal"><span class="pre">dir</span></tt>.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-e <var>dir</var></span></kbd></td> -<td>The SIP header file will be installed in the directory <tt class="docutils literal"><span class="pre">dir</span></tt>.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-k</span></kbd></td> -<td>The SIP module will be built as a static library. This is useful when -building the SIP module as a Python builtin (see -<a class="reference" href="#builtin-modules-and-custom-interpreters">Builtin Modules and Custom Interpreters</a>).</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-n</span></kbd></td> -<td>The SIP code generator and module will be built as universal binaries -under MacOS/X.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-p <var>plat</var></span></kbd></td> -<td>Explicitly specify the platform/compiler to be used by the build -system, otherwise a platform specific default will be used. The -<tt class="docutils literal"><span class="pre">-h</span></tt> option will display all the supported platform/compilers and -the default.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-u</span></kbd></td> -<td>The SIP module will be built with debugging symbols.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-v <var>dir</var></span></kbd></td> -<td>By default <tt class="docutils literal"><span class="pre">.sip</span></tt> files will be installed in the directory <tt class="docutils literal"><span class="pre">dir</span></tt>.</td></tr> -</tbody> -</table> -<p>The configure.py script takes many other options that allows the build system -to be finely tuned. These are of the form <tt class="docutils literal"><span class="pre">name=value</span></tt> or <tt class="docutils literal"><span class="pre">name+=value</span></tt>. -The <tt class="docutils literal"><span class="pre">-h</span></tt> option will display each supported <tt class="docutils literal"><span class="pre">name</span></tt>, although not all are -applicable to all platforms.</p> -<p>The <tt class="docutils literal"><span class="pre">name=value</span></tt> form means that <tt class="docutils literal"><span class="pre">value</span></tt> will replace the existing value of -<tt class="docutils literal"><span class="pre">name</span></tt>.</p> -<p>The <tt class="docutils literal"><span class="pre">name+=value</span></tt> form means that <tt class="docutils literal"><span class="pre">value</span></tt> will be appended to the existing -value of <tt class="docutils literal"><span class="pre">name</span></tt>.</p> -<p>For example, the following will disable support for C++ exceptions (and so -reduce the size of module binaries) when used with GCC:</p> -<pre class="literal-block"> -python configure.py CXXFLAGS+=-fno-exceptions -</pre> -<p>A pure Python module called <tt class="docutils literal"><span class="pre">sipconfig.py</span></tt> is generated by <tt class="docutils literal"><span class="pre">configure.py</span></tt>. -This defines each <tt class="docutils literal"><span class="pre">name</span></tt> and its corresponding <tt class="docutils literal"><span class="pre">value</span></tt>. Looking at it will -give you a good idea of how the build system uses the different options. It is -covered in detail in <a class="reference" href="#the-sip-build-system">The SIP Build System</a>.</p> -<div class="section"> -<h3><a class="toc-backref" href="#id32" id="configuring-sip-using-mingw" name="configuring-sip-using-mingw">3.2.1 Configuring SIP Using MinGW</a></h3> -<p>SIP, and the modules it generates, can be built with MinGW, the Windows port of -GCC. You must use the <tt class="docutils literal"><span class="pre">-p</span></tt> command line option to specify the correct -platform. For example:</p> -<pre class="literal-block"> -c:\python25\python configure.py -p win32-g++ -</pre> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id33" id="configuring-sip-using-the-borland-c-compiler" name="configuring-sip-using-the-borland-c-compiler">3.2.2 Configuring SIP Using the Borland C++ Compiler</a></h3> -<p>SIP, and the modules it generates, can be built with the free Borland C++ -compiler. You must use the <tt class="docutils literal"><span class="pre">-p</span></tt> command line option to specify the correct -platform. For example:</p> -<pre class="literal-block"> -c:\python25\python configure.py -p win32-borland -</pre> -<p>You must also make sure you have a Borland-compatible version of the Python -library. If you are using the standard Python distribution (built using the -Microsoft compiler) then you must convert the format of the Python library. -For example:</p> -<pre class="literal-block"> -coff2omf python25.lib python25_bcpp.lib -</pre> -</div> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id34" id="building-sip" name="building-sip">3.3 Building SIP</a></h2> -<p>The next step is to build SIP by running your platform's <tt class="docutils literal"><span class="pre">make</span></tt> command. For -example:</p> -<pre class="literal-block"> -make -</pre> -<p>The final step is to install SIP by running the following command:</p> -<pre class="literal-block"> -make install -</pre> -<p>(Depending on your system you may require root or administrator privileges.)</p> -<p>This will install the various SIP components.</p> -</div> -</div> -<div class="section"> -<h1><a class="toc-backref" href="#id35" id="using-sip" name="using-sip">4 Using SIP</a></h1> -<p>Bindings are generated by the SIP code generator from a number of specification -files, typically with a <tt class="docutils literal"><span class="pre">.sip</span></tt> extension. Specification files look very -similar to C and C++ header files, but often with additional information (in -the form of a <em>directive</em> or an <em>annotation</em>) and code so that the bindings -generated can be finely tuned.</p> -<div class="section"> -<h2><a class="toc-backref" href="#id36" id="a-simple-c-example" name="a-simple-c-example">4.1 A Simple C++ Example</a></h2> -<p>We start with a simple example. Let's say you have a (fictional) C++ library -that implements a single class called <tt class="docutils literal"><span class="pre">Word</span></tt>. The class has one constructor -that takes a <tt class="docutils literal"><span class="pre">\0</span></tt> terminated character string as its single argument. The -class has one method called <tt class="docutils literal"><span class="pre">reverse()</span></tt> which takes no arguments and returns -a <tt class="docutils literal"><span class="pre">\0</span></tt> terminated character string. The interface to the class is defined in -a header file called <tt class="docutils literal"><span class="pre">word.h</span></tt> which might look something like this:</p> -<pre class="literal-block"> -// Define the interface to the word library. - -class Word { - const char *the_word; - -public: - Word(const char *w); - - char *reverse() const; -}; -</pre> -<p>The corresponding SIP specification file would then look something like this:</p> -<pre class="literal-block"> -// Define the SIP wrapper to the word library. - -%Module word 0 - -class Word { - -%TypeHeaderCode -#include <word.h> -%End - -public: - Word(const char *w); - - char *reverse() const; -}; -</pre> -<p>Obviously a SIP specification file looks very much like a C++ (or C) header -file, but SIP does not include a full C++ parser. Let's look at the -differences between the two files.</p> -<blockquote> -<ul class="simple"> -<li>The <a class="reference" href="#module">%Module</a> directive has been added <a class="footnote-reference" href="#id4" id="id1" name="id1">[1]</a>. This is used to name the -Python module that is being created and to give it a <em>generation</em> number. -In this example these are <tt class="docutils literal"><span class="pre">word</span></tt> and <tt class="docutils literal"><span class="pre">0</span></tt> respectively. The -generation number is effectively the version number of the module.</li> -<li>The <a class="reference" href="#typeheadercode">%TypeHeaderCode</a> directive has been added. The text between this -and the following <a class="reference" href="#end">%End</a> directive is included literally in the code -that SIP generates. Normally it is used, as in this case, to -<tt class="docutils literal"><span class="pre">#include</span></tt> the corresponding C++ (or C) header file <a class="footnote-reference" href="#id5" id="id2" name="id2">[2]</a>.</li> -<li>The declaration of the private variable <tt class="docutils literal"><span class="pre">this_word</span></tt> has been removed. -SIP does not support access to either private or protected instance -variables.</li> -</ul> -</blockquote> -<p>If we want to we can now generate the C++ code in the current directory by -running the following command:</p> -<pre class="literal-block"> -sip -c . word.sip -</pre> -<p>However, that still leaves us with the task of compiling the generated code and -linking it against all the necessary libraries. It's much easier to use the -SIP build system to do the whole thing.</p> -<p>Using the SIP build system is simply a matter of writing a small Python script. -In this simple example we will assume that the <tt class="docutils literal"><span class="pre">word</span></tt> library we are wrapping -and it's header file are installed in standard system locations and will be -found by the compiler and linker without having to specify any additional -flags. In a more realistic example your Python script may take command line -options, or search a set of directories to deal with different configurations -and installations.</p> -<p>This is the simplest script (conventionally called <tt class="docutils literal"><span class="pre">configure.py</span></tt>):</p> -<pre class="literal-block"> -import os -import sipconfig - -# The name of the SIP build file generated by SIP and used by the build -# system. -build_file = "word.sbf" - -# Get the SIP configuration information. -config = sipconfig.Configuration() - -# Run SIP to generate the code. -os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file, "word.sip"])) - -# Create the Makefile. -makefile = sipconfig.SIPModuleMakefile(config, build_file) - -# Add the library we are wrapping. The name doesn't include any platform -# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the -# ".dll" extension on Windows). -makefile.extra_libs = ["word"] - -# Generate the Makefile itself. -makefile.generate() -</pre> -<p>Hopefully this script is self-documenting. The key parts are the -<tt class="docutils literal"><span class="pre">Configuration</span></tt> and <tt class="docutils literal"><span class="pre">SIPModuleMakefile</span></tt> classes. The build system contains -other Makefile classes, for example to build programs or to call other -Makefiles in sub-directories.</p> -<p>After running the script (using the Python interpreter the extension module is -being created for) the generated C++ code and <tt class="docutils literal"><span class="pre">Makefile</span></tt> will be in the -current directory.</p> -<p>To compile and install the extension module, just run the following -commands <a class="footnote-reference" href="#id6" id="id3" name="id3">[3]</a>:</p> -<pre class="literal-block"> -make -make install -</pre> -<p>That's all there is to it.</p> -<p>See <a class="reference" href="#building-your-extension-with-distutils">Building Your Extension with distutils</a> for an example of how to build -this example using distutils.</p> -<table class="docutils footnote" frame="void" id="id4" rules="none"> -<colgroup><col class="label" /><col /></colgroup> -<tbody valign="top"> -<tr><td class="label"><a class="fn-backref" href="#id1" name="id4">[1]</a></td><td>All SIP directives start with a <tt class="docutils literal"><span class="pre">%</span></tt> as the first non-whitespace -character of a line.</td></tr> -</tbody> -</table> -<table class="docutils footnote" frame="void" id="id5" rules="none"> -<colgroup><col class="label" /><col /></colgroup> -<tbody valign="top"> -<tr><td class="label"><a class="fn-backref" href="#id2" name="id5">[2]</a></td><td>SIP includes many code directives like this. They differ in where the -supplied code is placed by SIP in the generated code.</td></tr> -</tbody> -</table> -<table class="docutils footnote" frame="void" id="id6" rules="none"> -<colgroup><col class="label" /><col /></colgroup> -<tbody valign="top"> -<tr><td class="label"><a class="fn-backref" href="#id3" name="id6">[3]</a></td><td>On Windows you might run <tt class="docutils literal"><span class="pre">nmake</span></tt> or <tt class="docutils literal"><span class="pre">mingw32-make</span></tt> instead.</td></tr> -</tbody> -</table> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id37" id="id7" name="id7">4.2 A Simple C Example</a></h2> -<p>Let's now look at a very similar example of wrapping a fictional C library:</p> -<pre class="literal-block"> -/* Define the interface to the word library. */ - -struct Word { - const char *the_word; -}; - -struct Word *create_word(const char *w); -char *reverse(struct Word *word); -</pre> -<p>The corresponding SIP specification file would then look something like this:</p> -<pre class="literal-block"> -/* Define the SIP wrapper to the word library. */ - -%CModule word 0 - -struct Word { - -%TypeHeaderCode -#include <word.h> -%End - - const char *the_word; -}; - -struct Word *create_word(const char *w) /Factory/; -char *reverse(struct Word *word); -</pre> -<p>Again, let's look at the differences between the two files.</p> -<blockquote> -<ul class="simple"> -<li>The <a class="reference" href="#cmodule">%CModule</a> directive has been added. This has the same syntax as -the <a class="reference" href="#module">%Module</a> directive used in the previous example but tells SIP that -the library being wrapped is implemented in C rather than C++.</li> -<li>The <a class="reference" href="#typeheadercode">%TypeHeaderCode</a> directive has been added.</li> -<li>The <a class="reference" href="#factory">Factory</a> annotation has been added to the <tt class="docutils literal"><span class="pre">create_word()</span></tt> function. -This tells SIP that a newly created structure is being returned and it is -owned by Python.</li> -</ul> -</blockquote> -<p>The <tt class="docutils literal"><span class="pre">configure.py</span></tt> build system script described in the previous example can -be used for this example without change.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id38" id="a-more-complex-c-example" name="a-more-complex-c-example">4.3 A More Complex C++ Example</a></h2> -<p>In this last example we will wrap a fictional C++ library that contains a class -that is derived from a Qt class. This will demonstrate how SIP allows a class -hierarchy to be split across multiple Python extension modules, and will -introduce SIP's versioning system.</p> -<p>The library contains a single C++ class called <tt class="docutils literal"><span class="pre">Hello</span></tt> which is derived from -Qt's <tt class="docutils literal"><span class="pre">TQLabel</span></tt> class. It behaves just like <tt class="docutils literal"><span class="pre">TQLabel</span></tt> except that the text -in the label is hard coded to be <tt class="docutils literal"><span class="pre">Hello</span> <span class="pre">World</span></tt>. To make the example more -interesting we'll also say that the library only supports Qt v3.0 and later, -and also includes a function called <tt class="docutils literal"><span class="pre">setDefault()</span></tt> that is not implemented -in the Windows version of the library.</p> -<p>The <tt class="docutils literal"><span class="pre">hello.h</span></tt> header file looks something like this:</p> -<pre class="literal-block"> -// Define the interface to the hello library. - -#include <tqlabel.h> -#include <tqwidget.h> -#include <tqstring.h> - -class Hello : public TQLabel { - // This is needed by the Qt Meta-Object Compiler. - Q_OBJECT - -public: - Hello(TQWidget *parent, const char *name = 0, WFlags f = 0); - -private: - // Prevent instances from being copied. - Hello(const Hello &); - Hello &operator=(const Hello &); -}; - -#if !defined(Q_OS_WIN) -void setDefault(const TQString &def); -#endif -</pre> -<p>The corresponding SIP specification file would then look something like this:</p> -<pre class="literal-block"> -// Define the SIP wrapper to the hello library. - -%Module hello 0 - -%Import qt/qtmod.sip - -%If (Qt_3_0_0 -) - -class Hello : TQLabel { - -%TypeHeaderCode -#include <hello.h> -%End - -public: - Hello(TQWidget *parent /TransferThis/, const char *name = 0, WFlags f = 0); - -private: - Hello(const Hello &); -}; - -%If (!WS_WIN) -void setDefault(const TQString &def); -%End - -%End -</pre> -<p>Again we look at the differences, but we'll skip those that we've looked at in -previous examples.</p> -<blockquote> -<ul class="simple"> -<li>The <a class="reference" href="#import">%Import</a> directive has been added to specify that we are extending -the class hierarchy defined in the file <tt class="docutils literal"><span class="pre">qt/qtmod.sip</span></tt>. This file is -part of PyQt. The build system will take care of finding the file's -exact location.</li> -<li>The <a class="reference" href="#if">%If</a> directive has been added to specify that -everything <a class="footnote-reference" href="#id11" id="id8" name="id8">[4]</a> up to the matching <a class="reference" href="#end">%End</a> directive only applies to Qt -v3.0 and later. <tt class="docutils literal"><span class="pre">Qt_3_0_0</span></tt> is a <em>tag</em> defined in <tt class="docutils literal"><span class="pre">qtmod.sip</span></tt> <a class="footnote-reference" href="#id12" id="id9" name="id9">[5]</a> -using the <a class="reference" href="#timeline">%Timeline</a> directive. <a class="reference" href="#timeline">%Timeline</a> is used to define a tag -for each version of a library's API you are wrapping allowing you to -maintain all the different versions in a single SIP specification. The -build system provides support to <tt class="docutils literal"><span class="pre">configure.py</span></tt> scripts for working out -the correct tags to use according to which version of the library is -actually installed.</li> -<li>The <tt class="docutils literal"><span class="pre">public</span></tt> keyword used in defining the super-classes has been -removed. This is not supported by SIP.</li> -<li>The <a class="reference" href="#transferthis">TransferThis</a> annotation has been added to the first argument -of the constructor. It specifies that if the argument is not 0 (i.e. the -<tt class="docutils literal"><span class="pre">Hello</span></tt> instance being constructed has a parent) then ownership of the -instance is transferred from Python to C++. It is needed because Qt -maintains objects (i.e. instances derived from the <tt class="docutils literal"><span class="pre">TQObject</span></tt> class) in -a hierachy. When an object is destroyed all of its children are also -automatically destroyed. It is important, therefore, that the Python -garbage collector doesn't also try and destroy them. This is covered in -more detail in <a class="reference" href="#ownership-of-objects">Ownership of Objects</a>. SIP provides many other -annotations that can be applied to arguments, functions and classes. -Multiple annotations are separated by commas. Annotations may have -values.</li> -<li>The <tt class="docutils literal"><span class="pre">=</span></tt> operator has been removed. This operator is not supported by -SIP.</li> -<li>The <a class="reference" href="#if">%If</a> directive has been added to specify that everything up to the -matching <a class="reference" href="#end">%End</a> directive does not apply to Windows. <tt class="docutils literal"><span class="pre">WS_WIN</span></tt> is -another tag defined by PyQt, this time using the <a class="reference" href="#platforms">%Platforms</a> directive. -Tags defined by the <a class="reference" href="#platforms">%Platforms</a> directive are mutually exclusive, i.e. -only one may be valid at a time <a class="footnote-reference" href="#id13" id="id10" name="id10">[6]</a>.</li> -</ul> -</blockquote> -<p>One question you might have at this point is why bother to define the private -copy constructor when it can never be called from Python? The answer is to -prevent the automatic generation of a public copy constructor.</p> -<p>We now look at the <tt class="docutils literal"><span class="pre">configure.py</span></tt> script. This is a little different to the -script in the previous examples for two related reasons.</p> -<p>Firstly, PyQt includes a pure Python module called <tt class="docutils literal"><span class="pre">pyqtconfig</span></tt> that extends -the SIP build system for modules, like our example, that build on top of PyQt. -It deals with the details of which version of Qt is being used (i.e. it -determines what the correct tags are) and where it is installed. This is -called a module's configuration module.</p> -<p>Secondly, we generate a configuration module (called <tt class="docutils literal"><span class="pre">helloconfig</span></tt>) for our -own <tt class="docutils literal"><span class="pre">hello</span></tt> module. There is no need to do this, but if there is a chance -that somebody else might want to extend your C++ library then it would make -life easier for them.</p> -<p>Now we have two scripts. First the <tt class="docutils literal"><span class="pre">configure.py</span></tt> script:</p> -<pre class="literal-block"> -import os -import sipconfig -import pyqtconfig - -# The name of the SIP build file generated by SIP and used by the build -# system. -build_file = "hello.sbf" - -# Get the PyQt configuration information. -config = pyqtconfig.Configuration() - -# Get the extra SIP flags needed by the imported qt module. Note that -# this normally only includes those flags (-x and -t) that relate to SIP's -# versioning system. -qt_sip_flags = config.pyqt_qt_sip_flags - -# Run SIP to generate the code. Note that we tell SIP where to find the qt -# module's specification files using the -I flag. -os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file, "-I", config.pyqt_sip_dir, qt_sip_flags, "hello.sip"])) - -# We are going to install the SIP specification file for this module and -# its configuration module. -installs = [] - -installs.append(["hello.sip", os.path.join(config.default_sip_dir, "hello")]) - -installs.append(["helloconfig.py", config.default_mod_dir]) - -# Create the Makefile. The QtModuleMakefile class provided by the -# pyqtconfig module takes care of all the extra preprocessor, compiler and -# linker flags needed by the Qt library. -makefile = pyqtconfig.QtModuleMakefile( - configuration=config, - build_file=build_file, - installs=installs -) - -# Add the library we are wrapping. The name doesn't include any platform -# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the -# ".dll" extension on Windows). -makefile.extra_libs = ["hello"] - -# Generate the Makefile itself. -makefile.generate() - -# Now we create the configuration module. This is done by merging a Python -# dictionary (whose values are normally determined dynamically) with a -# (static) template. -content = { - # Publish where the SIP specifications for this module will be - # installed. - "hello_sip_dir": config.default_sip_dir, - - # Publish the set of SIP flags needed by this module. As these are the - # same flags needed by the qt module we could leave it out, but this - # allows us to change the flags at a later date without breaking - # scripts that import the configuration module. - "hello_sip_flags": qt_sip_flags -} - -# This creates the helloconfig.py module from the helloconfig.py.in -# template and the dictionary. -sipconfig.create_config_module("helloconfig.py", "helloconfig.py.in", content) -</pre> -<p>Next we have the <tt class="docutils literal"><span class="pre">helloconfig.py.in</span></tt> template script:</p> -<pre class="literal-block"> -import pyqtconfig - -# These are installation specific values created when Hello was configured. -# The following line will be replaced when this template is used to create -# the final configuration module. -# @SIP_CONFIGURATION@ - -class Configuration(pyqtconfig.Configuration): - """The class that represents Hello configuration values. - """ - def __init__(self, sub_cfg=None): - """Initialise an instance of the class. - - sub_cfg is the list of sub-class configurations. It should be None - when called normally. - """ - # This is all standard code to be copied verbatim except for the - # name of the module containing the super-class. - if sub_cfg: - cfg = sub_cfg - else: - cfg = [] - - cfg.append(_pkg_config) - - pyqtconfig.Configuration.__init__(self, cfg) - -class HelloModuleMakefile(pyqtconfig.QtModuleMakefile): - """The Makefile class for modules that %Import hello. - """ - def finalise(self): - """Finalise the macros. - """ - # Make sure our C++ library is linked. - self.extra_libs.append("hello") - - # Let the super-class do what it needs to. - pyqtconfig.QtModuleMakefile.finalise(self) -</pre> -<p>Again, we hope that the scripts are self documenting.</p> -<table class="docutils footnote" frame="void" id="id11" rules="none"> -<colgroup><col class="label" /><col /></colgroup> -<tbody valign="top"> -<tr><td class="label"><a class="fn-backref" href="#id8" name="id11">[4]</a></td><td>Some parts of a SIP specification aren't subject to version control.</td></tr> -</tbody> -</table> -<table class="docutils footnote" frame="void" id="id12" rules="none"> -<colgroup><col class="label" /><col /></colgroup> -<tbody valign="top"> -<tr><td class="label"><a class="fn-backref" href="#id9" name="id12">[5]</a></td><td>Actually in <tt class="docutils literal"><span class="pre">versions.sip</span></tt>. PyQt uses the <a class="reference" href="#include">%Include</a> directive to -split the SIP specification for Qt across a large number of separate -<tt class="docutils literal"><span class="pre">.sip</span></tt> files.</td></tr> -</tbody> -</table> -<table class="docutils footnote" frame="void" id="id13" rules="none"> -<colgroup><col class="label" /><col /></colgroup> -<tbody valign="top"> -<tr><td class="label"><a class="fn-backref" href="#id10" name="id13">[6]</a></td><td>Tags can also be defined by the <a class="reference" href="#feature">%Feature</a> directive. These tags are -not mutually exclusive, i.e. any number may be valid at a time.</td></tr> -</tbody> -</table> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id39" id="ownership-of-objects" name="ownership-of-objects">4.4 Ownership of Objects</a></h2> -<p>When a C++ instance is wrapped a corresponding Python object is created. The -Python object behaves as you would expect in regard to garbage collection - it -is garbage collected when its reference count reaches zero. What then happens -to the corresponding C++ instance? The obvious answer might be that the -instance's destructor is called. However the library API may say that when the -instance is passed to a particular function, the library takes ownership of the -instance, i.e. responsibility for calling the instance's destructor is -transferred from the SIP generated module to the library.</p> -<p>Ownership of an instance may also be associated with another instance. The -implication being that the owned instance will automatically be destroyed if -the owning instance is destroyed. SIP keeps track of these relationships to -ensure that Python's cyclic garbage collector can detect and break any -reference cycles between the owning and owned instances. The association is -implemented as the owning instance taking a reference to the owned instance.</p> -<p>The <a class="reference" href="#transferthis">TransferThis</a>, <a class="reference" href="#transfer">Transfer</a> and TransferBack annotations are used to specify -where, and it what direction, transfers of ownership happen. It is very -important that these are specified correctly to avoid crashes (where both -Python and C++ call the destructor) and memory leaks (where neither Python and -C++ call the destructor).</p> -<p>This applies equally to C structures where the structure is returned to the -heap using the <tt class="docutils literal"><span class="pre">free()</span></tt> function.</p> -<p>See also <a class="reference" href="#siptransferto">sipTransferTo()</a> and <a class="reference" href="#siptransferback">sipTransferBack()</a>.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id40" id="support-for-wide-characters" name="support-for-wide-characters">4.5 Support for Wide Characters</a></h2> -<p>SIP v4.6 introduced support for wide characters (i.e. the <tt class="docutils literal"><span class="pre">wchar_t</span></tt> type). -Python's C API includes support for converting between unicode objects and wide -character strings and arrays. When converting from a unicode object to wide -characters SIP creates the string or array on the heap (using memory allocated -using <a class="reference" href="#sipmalloc">sipMalloc()</a>). This then raises the problem of how this memory is -subsequently freed.</p> -<p>The following describes how SIP handles this memory in the different situations -where this is an issue.</p> -<blockquote> -<ul class="simple"> -<li>When a wide string or array is passed to a function or method then the -memory is freed (using <a class="reference" href="#sipfree">sipFree()</a>) after than function or method -returns.</li> -<li>When a wide string or array is returned from a virtual method then SIP -does not free the memory until the next time the method is called.</li> -<li>When an assignment is made to a wide string or array instance variable -then SIP does not first free the instance's current string or array.</li> -</ul> -</blockquote> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id41" id="the-python-global-interpreter-lock" name="the-python-global-interpreter-lock">4.6 The Python Global Interpreter Lock</a></h2> -<p>Python's Global Interpretor Lock (GIL) must be acquired before calls can be -made to the Python API. It should also be released when a potentially -blocking call to C/C++ library is made in order to allow other Python threads -to be executed. In addition, some C/C++ libraries may implement their own -locking strategies that conflict with the GIL causing application deadlocks. -SIP provides ways of specifying when the GIL is released and acquired to -ensure that locking problems can be avoided.</p> -<p>SIP always ensures that the GIL is acquired before making calls to the Python -API. By default SIP does not release the GIL when making calls to the C/C++ -library being wrapped. The <a class="reference" href="#releasegil">ReleaseGIL</a> annotation can be used to override -this behaviour when required.</p> -<p>If SIP is given the <tt class="docutils literal"><span class="pre">-g</span></tt> command line option then the default behaviour is -changed and SIP releases the GIL every time is makes calls to the C/C++ -library being wrapped. The <a class="reference" href="#holdgil">HoldGIL</a> annotation can be used to override this -behaviour when required.</p> -</div> -</div> -<div class="section"> -<h1><a class="toc-backref" href="#id42" id="the-sip-command-line" name="the-sip-command-line">5 The SIP Command Line</a></h1> -<p>The syntax of the SIP command line is:</p> -<pre class="literal-block"> -sip [options] [specification] -</pre> -<p><tt class="docutils literal"><span class="pre">specification</span></tt> is the name of the specification file for the module. If it -is omitted then <tt class="docutils literal"><span class="pre">stdin</span></tt> is used.</p> -<p>The full set of command line options is:</p> -<table class="docutils option-list" frame="void" rules="none"> -<col class="option" /> -<col class="description" /> -<tbody valign="top"> -<tr><td class="option-group"> -<kbd><span class="option">-h</span></kbd></td> -<td>Display a help message.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-V</span></kbd></td> -<td>Display the SIP version number.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-a <var>file</var></span></kbd></td> -<td>The name of the QScintilla API file to generate. This file contains a -description of the module API in a form that the QScintilla editor -component can use for auto-completion and call tips. (The file may -also be used by the SciTE editor but must be sorted first.) By default -the file is not generated.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-b <var>file</var></span></kbd></td> -<td>The name of the build file to generate. This file contains the -information about the module needed by the SIP build system to generate -a platform and compiler specific Makefile for the module. By default -the file is not generated.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-c <var>dir</var></span></kbd></td> -<td>The name of the directory (which must exist) into which all of the -generated C or C++ code is placed. By default no code is generated.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-d <var>file</var></span></kbd></td> -<td>The name of the documentation file to generate. Documentation is -included in specification files using the <a class="reference" href="#doc">%Doc</a> and <a class="reference" href="#exporteddoc">%ExportedDoc</a> -directives. By default the file is not generated.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-e</span></kbd></td> -<td>Support for C++ exceptions is enabled. This causes all calls to C++ -code to be enclosed in <tt class="docutils literal"><span class="pre">try</span></tt>/<tt class="docutils literal"><span class="pre">catch</span></tt> blocks and C++ exceptions to -be converted to Python exceptions. By default exception support is -disabled.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-g</span></kbd></td> -<td>The Python GIL is released before making any calls to the C/C++ library -being wrapped and reacquired afterwards. See <a class="reference" href="#the-python-global-interpreter-lock">The Python Global -Interpreter Lock</a> and the <a class="reference" href="#releasegil">ReleaseGIL</a> and <a class="reference" href="#holdgil">HoldGIL</a> annotations.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-I <var>dir</var></span></kbd></td> -<td>The directory is added to the list of directories searched when looking -for a specification file given in an <a class="reference" href="#include">%Include</a> or <a class="reference" href="#import">%Import</a> -directive. This option may be given any number of times.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-j <var>number</var></span></kbd></td> -<td>The generated code is split into the given number of files. This make -it easier to use the parallel build facility of most modern -implementations of <tt class="docutils literal"><span class="pre">make</span></tt>. By default 1 file is generated for each C -structure or C++ class.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-r</span></kbd></td> -<td>Debugging statements that trace the execution of the bindings are -automatically generated. By default the statements are not generated.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-s <var>suffix</var></span></kbd></td> -<td>The suffix to use for generated C or C++ source files. By default -<tt class="docutils literal"><span class="pre">.c</span></tt> is used for C and <tt class="docutils literal"><span class="pre">.cpp</span></tt> for C++.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-t <var>tag</var></span></kbd></td> -<td>The SIP version tag (declared using a <a class="reference" href="#timeline">%Timeline</a> directive) or the -SIP platform tag (declared using the <a class="reference" href="#platforms">%Platforms</a> directive) to -generate code for. This option may be given any number of times so -long as the tags do not conflict.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-w</span></kbd></td> -<td>The display of warning messages is enabled. By default warning -messages are disabled.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-x <var>feature</var></span></kbd></td> -<td>The feature (declared using the <a class="reference" href="#feature">%Feature</a> directive) is disabled.</td></tr> -<tr><td class="option-group"> -<kbd><span class="option">-z <var>file</var></span></kbd></td> -<td>The name of a file containing more command line options.</td></tr> -</tbody> -</table> -</div> -<div class="section"> -<h1><a class="toc-backref" href="#id43" id="sip-specification-files" name="sip-specification-files">6 SIP Specification Files</a></h1> -<p>A SIP specification consists of some C/C++ type and function declarations and -some directives. The declarations may contain annotations which provide SIP -with additional information that cannot be expressed in C/C++. SIP does not -include a full C/C++ parser.</p> -<p>It is important to understand that a SIP specification describes the Python -API, i.e. the API available to the Python programmer when they <tt class="docutils literal"><span class="pre">import</span></tt> the -generated module. It does not have to accurately represent the underlying -C/C++ library. There is nothing wrong with omitting functions that make -little sense in a Python context, or adding functions implemented with -handwritten code that have no C/C++ equivalent. It is even possible (and -sometimes necessary) to specify a different super-class hierarchy for a C++ -class. All that matters is that the generated code compiles properly.</p> -<p>In most cases the Python API matches the C/C++ API. In some cases handwritten -code (see <a class="reference" href="#methodcode">%MethodCode</a>) is used to map from one to the other without SIP -having to know the details itself. However, there are a few cases where SIP -generates a thin wrapper around a C++ method or constructor (see <a class="reference" href="#generated-derived-classes">Generated -Derived Classes</a>) and needs to know the exact C++ signature. To deal with -these cases SIP allows two signatures to be specified. For example:</p> -<pre class="literal-block"> -class Klass -{ -public: - // The Python signature is a tuple, but the underlying C++ signature - // is a 2 element array. - Klass(SIP_PYTUPLE) [(int *)]; -%MethodCode - int iarr[2]; - - if (PyArg_ParseTuple(a0, "ii", &iarr[0], &iarr[1])) - { - // Note that we use the SIP generated derived class - // constructor. - Py_BEGIN_ALLOW_THREADS - sipCpp = new sipKlass(iarr); - Py_END_ALLOW_THREADS - } -%End -}; -</pre> -<div class="section"> -<h2><a class="toc-backref" href="#id44" id="syntax-definition" name="syntax-definition">6.1 Syntax Definition</a></h2> -<p>The following is a semi-formal description of the syntax of a specification -file.</p> -<pre class="literal-block"> -<em>specification</em> ::= {<em>module-statement</em>} - -<em>module-statement</em> ::= [<em>module-directive</em> | <em>statement</em>] - -<em>module-directive</em> ::= [<a class="reference" href="#cmodule">%CModule</a> | <a class="reference" href="#copying">%Copying</a> | <a class="reference" href="#doc">%Doc</a> | - <a class="reference" href="#exporteddoc">%ExportedDoc</a> | <a class="reference" href="#exportedheadercode">%ExportedHeaderCode</a> | <a class="reference" href="#feature">%Feature</a> | - <a class="reference" href="#import">%Import</a> | <a class="reference" href="#include">%Include</a> | <a class="reference" href="#id14">%License</a> | <a class="reference" href="#mappedtype">%MappedType</a> | - <em>mapped-type-template</em> | <a class="reference" href="#module">%Module</a> | <a class="reference" href="#modulecode">%ModuleCode</a> | - <a class="reference" href="#moduleheadercode">%ModuleHeaderCode</a> | <a class="reference" href="#optionalinclude">%OptionalInclude</a> | <a class="reference" href="#platforms">%Platforms</a> | - <a class="reference" href="#preinitialisationcode">%PreInitialisationCode</a> | <a class="reference" href="#postinitialisationcode">%PostInitialisationCode</a> | - <em>sip-option-list</em> | <a class="reference" href="#timeline">%Timeline</a> | <a class="reference" href="#unitcode">%UnitCode</a>] - -<em>sip-option-list</em> :: <a class="reference" href="#sipoptions">%SIPOptions</a> <tt class="docutils literal"><span class="pre">(</span></tt> <em>option-list</em> <tt class="docutils literal"><span class="pre">)</span></tt> - -<em>option-list</em> ::= <em>option</em> [<tt class="docutils literal"><span class="pre">,</span></tt> <em>option-list</em>] - -<em>statement</em> :: [<em>class-statement</em> | <em>function</em> | <em>variable</em>] - -<em>class-statement</em> :: [<a class="reference" href="#if">%If</a> | <em>class</em> | <em>class-template</em> | <em>enum</em> | - <em>namespace</em> | <em>opaque-class</em> | <em>operator</em> | <em>struct</em> | <em>typedef</em> | - <em>exception</em>] - -<em>class</em> ::= <tt class="docutils literal"><span class="pre">class</span></tt> <em>name</em> [<tt class="docutils literal"><span class="pre">:</span></tt> <em>super-classes</em>] [<em>class-annotations</em>] - <tt class="docutils literal"><span class="pre">{</span></tt> {<em>class-line</em>} <tt class="docutils literal"><span class="pre">};</span></tt> - -<em>super-classes</em> ::= <em>name</em> [<tt class="docutils literal"><span class="pre">,</span></tt> <em>super-classes</em>] - -<em>class-line</em> ::= [<em>class-statement</em> | <a class="reference" href="#bigetreadbuffercode">%BIGetReadBufferCode</a> | - <a class="reference" href="#bigetwritebuffercode">%BIGetWriteBufferCode</a> | <a class="reference" href="#bigetsegcountcode">%BIGetSegCountCode</a> | - <a class="reference" href="#bigetcharbuffercode">%BIGetCharBufferCode</a> | <a class="reference" href="#converttosubclasscode">%ConvertToSubClassCode</a> | - <a class="reference" href="#converttotypecode">%ConvertToTypeCode</a> | <a class="reference" href="#gcclearcode">%GCClearCode</a> | <a class="reference" href="#gctraversecode">%GCTraverseCode</a> | - <a class="reference" href="#typecode">%TypeCode</a> | <a class="reference" href="#typeheadercode">%TypeHeaderCode</a> | <em>constructor</em> | <em>destructor</em> | - <em>method</em> | <em>static-method</em> | <em>virtual-method</em> | <em>special-method</em> | - <em>operator</em> | <em>virtual-operator</em> | <em>class-variable</em> | <tt class="docutils literal"><span class="pre">public:</span></tt> | - <tt class="docutils literal"><span class="pre">public</span> <span class="pre">slots:</span></tt> | <tt class="docutils literal"><span class="pre">protected:</span></tt> | <tt class="docutils literal"><span class="pre">protected</span> <span class="pre">slots:</span></tt> | - <tt class="docutils literal"><span class="pre">private:</span></tt> | <tt class="docutils literal"><span class="pre">private</span> <span class="pre">slots:</span></tt> | <tt class="docutils literal"><span class="pre">signals:</span></tt>] - -<em>constructor</em> ::= [<tt class="docutils literal"><span class="pre">explicit</span></tt>] <em>name</em> <tt class="docutils literal"><span class="pre">(</span></tt> [<em>argument-list</em>] <tt class="docutils literal"><span class="pre">)</span></tt> - [<em>exceptions</em>] [<em>function-annotations</em>] - [<em>c++-constructor-signature</em>] <tt class="docutils literal"><span class="pre">;</span></tt> [<a class="reference" href="#methodcode">%MethodCode</a>] - -<em>c++-constructor-signature</em> ::= <tt class="docutils literal"><span class="pre">[(</span></tt> [<em>argument-list</em>] <tt class="docutils literal"><span class="pre">)]</span></tt> - -<em>destructor</em> ::= [<tt class="docutils literal"><span class="pre">virtual</span></tt>] <tt class="docutils literal"><span class="pre">~</span></tt> <em>name</em> <tt class="docutils literal"><span class="pre">()</span></tt> [<em>exceptions</em>] [<tt class="docutils literal"><span class="pre">=</span> <span class="pre">0</span></tt>] - [<em>function-annotations</em>] <tt class="docutils literal"><span class="pre">;</span></tt> [<a class="reference" href="#methodcode">%MethodCode</a>] - [<a class="reference" href="#virtualcatchercode">%VirtualCatcherCode</a>] - -<em>method</em> ::= <em>type</em> <em>name</em> <tt class="docutils literal"><span class="pre">(</span></tt> [<em>argument-list</em>] <tt class="docutils literal"><span class="pre">)</span></tt> [<tt class="docutils literal"><span class="pre">const</span></tt>] - [<em>exceptions</em>] [<tt class="docutils literal"><span class="pre">=</span> <span class="pre">0</span></tt>] [<em>function-annotations</em>] [<em>c++-signature</em>] - <tt class="docutils literal"><span class="pre">;</span></tt> [<a class="reference" href="#methodcode">%MethodCode</a>] - -<em>c++-signature</em> ::= <tt class="docutils literal"><span class="pre">[</span></tt> <em>type</em> <tt class="docutils literal"><span class="pre">(</span></tt> [<em>argument-list</em>] <tt class="docutils literal"><span class="pre">)]</span></tt> - -<em>static-method</em> ::= <tt class="docutils literal"><span class="pre">static</span></tt> <em>function</em> - -<em>virtual-method</em> ::= <tt class="docutils literal"><span class="pre">virtual</span></tt> <em>type</em> <em>name</em> <tt class="docutils literal"><span class="pre">(</span></tt> [<em>argument-list</em>] <tt class="docutils literal"><span class="pre">)</span></tt> - [<tt class="docutils literal"><span class="pre">const</span></tt>] [<em>exceptions</em>] [<tt class="docutils literal"><span class="pre">=</span> <span class="pre">0</span></tt>] [<em>function-annotations</em>] - [<em>c++-signature</em>] <tt class="docutils literal"><span class="pre">;</span></tt> [<a class="reference" href="#methodcode">%MethodCode</a>] [<a class="reference" href="#virtualcatchercode">%VirtualCatcherCode</a>] - -<em>special-method</em> ::= <em>type</em> <em>special-method-name</em> - <tt class="docutils literal"><span class="pre">(</span></tt> [<em>argument-list</em>] <tt class="docutils literal"><span class="pre">)</span></tt> [<em>function-annotations</em>] <tt class="docutils literal"><span class="pre">;</span></tt> - [<a class="reference" href="#methodcode">%MethodCode</a>] - -<em>special-method-name</em> ::= [ <tt class="docutils literal"><span class="pre">__abs__</span></tt> | <tt class="docutils literal"><span class="pre">__add__</span></tt> | <tt class="docutils literal"><span class="pre">__and__</span></tt> | - <tt class="docutils literal"><span class="pre">__call__</span></tt> | <tt class="docutils literal"><span class="pre">__cmp__</span></tt> | <tt class="docutils literal"><span class="pre">__contains__</span></tt> | <tt class="docutils literal"><span class="pre">__delitem__</span></tt> | - <tt class="docutils literal"><span class="pre">__div__</span></tt> | <tt class="docutils literal"><span class="pre">__eq__</span></tt> | <tt class="docutils literal"><span class="pre">__float__</span></tt> | <tt class="docutils literal"><span class="pre">__ge__</span></tt> | - <tt class="docutils literal"><span class="pre">__getitem__</span></tt> | <tt class="docutils literal"><span class="pre">__gt__</span></tt> | <tt class="docutils literal"><span class="pre">__hash__</span></tt> | <tt class="docutils literal"><span class="pre">__iadd__</span></tt> | - <tt class="docutils literal"><span class="pre">__iand__</span></tt> | <tt class="docutils literal"><span class="pre">__idiv__</span></tt> | <tt class="docutils literal"><span class="pre">__ilshift__</span></tt> | <tt class="docutils literal"><span class="pre">__imod__</span></tt> | - <tt class="docutils literal"><span class="pre">__imul__</span></tt> | <tt class="docutils literal"><span class="pre">__int__</span></tt> | <tt class="docutils literal"><span class="pre">__invert__</span></tt> | <tt class="docutils literal"><span class="pre">__ior__</span></tt> | - <tt class="docutils literal"><span class="pre">__irshift__</span></tt> | <tt class="docutils literal"><span class="pre">__isub__</span></tt> | <tt class="docutils literal"><span class="pre">__ixor__</span></tt> | <tt class="docutils literal"><span class="pre">__le__</span></tt> | - <tt class="docutils literal"><span class="pre">__len__</span></tt> | <tt class="docutils literal"><span class="pre">__long__</span></tt> | <tt class="docutils literal"><span class="pre">__lshift__</span></tt> | <tt class="docutils literal"><span class="pre">__lt__</span></tt> | - <tt class="docutils literal"><span class="pre">__mod__</span></tt> | <tt class="docutils literal"><span class="pre">__mul__</span></tt> | <tt class="docutils literal"><span class="pre">__ne__</span></tt> | <tt class="docutils literal"><span class="pre">__neg__</span></tt> | - <tt class="docutils literal"><span class="pre">__nonzero__</span></tt> | <tt class="docutils literal"><span class="pre">__or__</span></tt> | <tt class="docutils literal"><span class="pre">__pos__</span></tt> | <tt class="docutils literal"><span class="pre">__repr__</span></tt> | - <tt class="docutils literal"><span class="pre">__rshift__</span></tt> | <tt class="docutils literal"><span class="pre">__setitem__</span></tt> | <tt class="docutils literal"><span class="pre">__str__</span></tt> | <tt class="docutils literal"><span class="pre">__sub__</span></tt> | - <tt class="docutils literal"><span class="pre">__xor__</span></tt>] - -<em>operator</em> ::= <em>operator-type</em> - <tt class="docutils literal"><span class="pre">(</span></tt> [<em>argument-list</em>] <tt class="docutils literal"><span class="pre">)</span></tt> [<tt class="docutils literal"><span class="pre">const</span></tt>] [<em>exceptions</em>] - [<em>function-annotations</em>] <tt class="docutils literal"><span class="pre">;</span></tt> [<a class="reference" href="#methodcode">%MethodCode</a>] - -<em>virtual-operator</em> ::= <tt class="docutils literal"><span class="pre">virtual</span></tt> <em>operator-type</em> - <tt class="docutils literal"><span class="pre">(</span></tt> [<em>argument-list</em>] <tt class="docutils literal"><span class="pre">)</span></tt> [<tt class="docutils literal"><span class="pre">const</span></tt>] [<em>exceptions</em>] [<tt class="docutils literal"><span class="pre">=</span> <span class="pre">0</span></tt>] - [<em>function-annotations</em>] <tt class="docutils literal"><span class="pre">;</span></tt> [<a class="reference" href="#methodcode">%MethodCode</a>] - [<a class="reference" href="#virtualcatchercode">%VirtualCatcherCode</a>] - -<em>operatator-type</em> ::= [ <em>operator-function</em> | <em>operator-cast</em> ] - -<em>operator-function</em> ::= <em>type</em> <tt class="docutils literal"><span class="pre">operator</span></tt> <em>operator-name</em> - -<em>operator-cast</em> ::= <tt class="docutils literal"><span class="pre">operator</span></tt> <em>type</em> - -<em>operator-name</em> ::= [<tt class="docutils literal"><span class="pre">+</span></tt> | <tt class="docutils literal"><span class="pre">-</span></tt> | <tt class="docutils literal"><span class="pre">*</span></tt> | <tt class="docutils literal"><span class="pre">/</span></tt> | <tt class="docutils literal"><span class="pre">%</span></tt> | <tt class="docutils literal"><span class="pre">&</span></tt> | - <tt class="docutils literal"><span class="pre">|</span></tt> | <tt class="docutils literal"><span class="pre">^</span></tt> | <tt class="docutils literal"><span class="pre"><<</span></tt> | <tt class="docutils literal"><span class="pre">>></span></tt> | <tt class="docutils literal"><span class="pre">+=</span></tt> | <tt class="docutils literal"><span class="pre">-=</span></tt> | <tt class="docutils literal"><span class="pre">*=</span></tt> | - <tt class="docutils literal"><span class="pre">/=</span></tt> | <tt class="docutils literal"><span class="pre">%=</span></tt> | <tt class="docutils literal"><span class="pre">&=</span></tt> | <tt class="docutils literal"><span class="pre">|=</span></tt> | <tt class="docutils literal"><span class="pre">^=</span></tt> | <tt class="docutils literal"><span class="pre"><<=</span></tt> | <tt class="docutils literal"><span class="pre">>>=</span></tt> | - <tt class="docutils literal"><span class="pre">~</span></tt> | <tt class="docutils literal"><span class="pre">()</span></tt> | <tt class="docutils literal"><span class="pre">[]</span></tt> | <tt class="docutils literal"><span class="pre"><</span></tt> | <tt class="docutils literal"><span class="pre"><=</span></tt> | <tt class="docutils literal"><span class="pre">==</span></tt> | <tt class="docutils literal"><span class="pre">!=</span></tt> | - <tt class="docutils literal"><span class="pre">></span></tt> | <tt class="docutils literal"><span class="pre">>>=</span></tt>] - -<em>class-variable</em> ::= [<tt class="docutils literal"><span class="pre">static</span></tt>] <em>variable</em> - -<em>class-template</em> :: = <tt class="docutils literal"><span class="pre">template</span></tt> <tt class="docutils literal"><span class="pre"><</span></tt> <em>type-list</em> <tt class="docutils literal"><span class="pre">></span></tt> <em>class</em> - -<em>mapped-type-template</em> :: = <tt class="docutils literal"><span class="pre">template</span></tt> <tt class="docutils literal"><span class="pre"><</span></tt> <em>type-list</em> <tt class="docutils literal"><span class="pre">></span></tt> - <a class="reference" href="#mappedtype">%MappedType</a> - -<em>enum</em> ::= <tt class="docutils literal"><span class="pre">enum</span></tt> [<em>name</em>] [<em>enum-annotations</em>] <tt class="docutils literal"><span class="pre">{</span></tt> {<em>enum-line</em>} <tt class="docutils literal"><span class="pre">};</span></tt> - -<em>enum-line</em> ::= [<a class="reference" href="#if">%If</a> | <em>name</em> [<em>enum-annotations</em>] <tt class="docutils literal"><span class="pre">,</span></tt> - -<em>function</em> ::= <em>type</em> <em>name</em> <tt class="docutils literal"><span class="pre">(</span></tt> [<em>argument-list</em>] <tt class="docutils literal"><span class="pre">)</span></tt> [<em>exceptions</em>] - [<em>function-annotations</em>] <tt class="docutils literal"><span class="pre">;</span></tt> [<a class="reference" href="#methodcode">%MethodCode</a>] - -<em>namespace</em> ::= <tt class="docutils literal"><span class="pre">namespace</span></tt> <em>name</em> <tt class="docutils literal"><span class="pre">{</span></tt> {<em>namespace-line</em>} <tt class="docutils literal"><span class="pre">};</span></tt> - -<em>namespace-line</em> ::= [<a class="reference" href="#typeheadercode">%TypeHeaderCode</a> | <em>statement</em>] - -<em>opaque-class</em> ::= <tt class="docutils literal"><span class="pre">class</span></tt> <em>scoped-name</em> <tt class="docutils literal"><span class="pre">;</span></tt> - -<em>struct</em> ::= <tt class="docutils literal"><span class="pre">struct</span></tt> <em>name</em> <tt class="docutils literal"><span class="pre">{</span></tt> {<em>class-line</em>} <tt class="docutils literal"><span class="pre">};</span></tt> - -<em>typedef</em> ::= <tt class="docutils literal"><span class="pre">typedef</span></tt> [<em>typed-name</em> | <em>function-pointer</em>] <tt class="docutils literal"><span class="pre">;</span></tt> - -<em>variable</em>::= <em>typed-name</em> [<em>variable-annotations</em>] <tt class="docutils literal"><span class="pre">;</span></tt> [<a class="reference" href="#accesscode">%AccessCode</a>] - [<a class="reference" href="#getcode">%GetCode</a>] [<a class="reference" href="#setcode">%SetCode</a>] - -<em>exception</em> ::= <a class="reference" href="#exception">%Exception</a> <em>exception-name</em> [<em>exception-base</em>] <tt class="docutils literal"><span class="pre">{</span></tt> - [<a class="reference" href="#typeheadercode">%TypeHeaderCode</a>] <a class="reference" href="#raisecode">%RaiseCode</a> <cite>};`</cite> - -<em>exception-name</em> ::= <em>scoped-name</em> - -<em>exception-base</em> ::= <tt class="docutils literal"><span class="pre">(</span></tt> [<em>exception-name</em> | <em>python-exception</em>] <tt class="docutils literal"><span class="pre">)</span></tt> - -<em>python-exception</em> ::= [<tt class="docutils literal"><span class="pre">SIP_Exception</span></tt> | <tt class="docutils literal"><span class="pre">SIP_StopIteration</span></tt> | - <tt class="docutils literal"><span class="pre">SIP_StandardError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_ArithmeticError</span></tt> | - <tt class="docutils literal"><span class="pre">SIP_LookupError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_AssertionError</span></tt> | - <tt class="docutils literal"><span class="pre">SIP_AttributeError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_EOFError</span></tt> | - <tt class="docutils literal"><span class="pre">SIP_FloatingPointError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_EnvironmentError</span></tt> | - <tt class="docutils literal"><span class="pre">SIP_IOError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_OSError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_ImportError</span></tt> | - <tt class="docutils literal"><span class="pre">SIP_IndexError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_KeyError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_KeyboardInterrupt</span></tt> | - <tt class="docutils literal"><span class="pre">SIP_MemoryError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_NameError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_OverflowError</span></tt> | - <tt class="docutils literal"><span class="pre">SIP_RuntimeError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_NotImplementedError</span></tt> | - <tt class="docutils literal"><span class="pre">SIP_SyntaxError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_IndentationError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_TabError</span></tt> | - <tt class="docutils literal"><span class="pre">SIP_ReferenceError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_SystemError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_SystemExit</span></tt> | - <tt class="docutils literal"><span class="pre">SIP_TypeError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_UnboundLocalError</span></tt> | - <tt class="docutils literal"><span class="pre">SIP_UnicodeError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_UnicodeEncodeError</span></tt> | - <tt class="docutils literal"><span class="pre">SIP_UnicodeDecodeError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_UnicodeTranslateError</span></tt> | - <tt class="docutils literal"><span class="pre">SIP_ValueError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_ZeroDivisionError</span></tt> | - <tt class="docutils literal"><span class="pre">SIP_WindowsError</span></tt> | <tt class="docutils literal"><span class="pre">SIP_VMSError</span></tt>] - -<em>exceptions</em> ::= <tt class="docutils literal"><span class="pre">throw</span> <span class="pre">(</span></tt> [<em>exception-list</em>] <tt class="docutils literal"><span class="pre">)</span></tt> - -<em>exception-list</em> ::= <em>scoped-name</em> [<tt class="docutils literal"><span class="pre">,</span></tt> <em>exception-list</em>] - -<em>argument-list</em> ::= <em>argument</em> [<tt class="docutils literal"><span class="pre">,</span></tt> <em>argument-list</em>] [<tt class="docutils literal"><span class="pre">,</span></tt> <tt class="docutils literal"><span class="pre">...</span></tt>] - -<em>argument</em> ::= [<em>type</em> [<em>name</em>] [<em>argument-annotations</em>] - [<em>default-value</em>] | <a class="reference" href="#sip-anyslot">SIP_ANYSLOT</a> [<em>default-value</em>] | <a class="reference" href="#sip-qobject">SIP_QOBJECT</a> | - <a class="reference" href="#sip-rxobj-con">SIP_RXOBJ_CON</a> | <a class="reference" href="#sip-rxobj-dis">SIP_RXOBJ_DIS</a> | <a class="reference" href="#sip-signal">SIP_SIGNAL</a> [<em>default-value</em>] | - <a class="reference" href="#sip-slot">SIP_SLOT</a> [<em>default-value</em>] | <a class="reference" href="#sip-slot-con">SIP_SLOT_CON</a> | <a class="reference" href="#sip-slot-dis">SIP_SLOT_DIS</a>] - -<em>default-value</em> ::= <tt class="docutils literal"><span class="pre">=</span></tt> <em>expression</em> - -<em>expression</em> ::= [<em>value</em> | <em>value</em> <em>binary-operator</em> <em>expression</em>] - -<em>value</em> ::= [<em>unary-operator</em>] <em>simple-value</em> - -<em>simple-value</em> ::= [<em>scoped-name</em> | <em>function-call</em> | <em>real-value</em> | - <em>integer-value</em> | <em>boolean-value</em> | <em>string-value</em> | - <em>character-value</em>] - -<em>typed-name</em>::= <em>type</em> <em>name</em> - -<em>function-pointer</em>::= <em>type</em> <tt class="docutils literal"><span class="pre">(*</span></tt> <em>name</em> <tt class="docutils literal"><span class="pre">)(</span></tt> [<em>type-list</em>] <tt class="docutils literal"><span class="pre">)</span></tt> - -<em>type-list</em> ::= <em>type</em> [<tt class="docutils literal"><span class="pre">,</span></tt> <em>type-list</em>] - -<em>function-call</em> ::= <em>scoped-name</em> <tt class="docutils literal"><span class="pre">(</span></tt> [<em>value-list</em>] <tt class="docutils literal"><span class="pre">)</span></tt> - -<em>value-list</em> ::= <em>value</em> [<tt class="docutils literal"><span class="pre">,</span></tt> <em>value-list</em>] - -<em>real-value</em> ::= a floating point number - -<em>integer-value</em> ::= a number - -<em>boolean-value</em> ::= [<tt class="docutils literal"><span class="pre">true</span></tt> | <tt class="docutils literal"><span class="pre">false</span></tt>] - -<em>string-value</em> ::= <tt class="docutils literal"><span class="pre">"</span></tt> {<em>character</em>} <tt class="docutils literal"><span class="pre">"</span></tt> - -<em>character-value</em> ::= <tt class="docutils literal"><span class="pre">`</span></tt> <em>character</em> <tt class="docutils literal"><span class="pre">`</span></tt> - -<em>unary-operator</em> ::= [<tt class="docutils literal"><span class="pre">!</span></tt> | <tt class="docutils literal"><span class="pre">~</span></tt> | <tt class="docutils literal"><span class="pre">-</span></tt> | <tt class="docutils literal"><span class="pre">+</span></tt>] - -<em>binary-operator</em> ::= [<tt class="docutils literal"><span class="pre">-</span></tt> | <tt class="docutils literal"><span class="pre">+</span></tt> | <tt class="docutils literal"><span class="pre">*</span></tt> | <tt class="docutils literal"><span class="pre">/</span></tt> | <tt class="docutils literal"><span class="pre">&</span></tt> | <tt class="docutils literal"><span class="pre">|</span></tt>] - -<em>argument-annotations</em> ::= see <a class="reference" href="#argument-annotations">Argument Annotations</a> - -<em>class-annotations</em> ::= see <a class="reference" href="#class-annotations">Class Annotations</a> - -<em>enum-annotations</em> ::= see <a class="reference" href="#enum-annotations">Enum Annotations</a> - -<em>function-annotations</em> ::= see <a class="reference" href="#function-annotations">Function Annotations</a> - -<em>variable-annotations</em> ::= see <a class="reference" href="#variable-annotations">Variable Annotations</a> - -<em>type</em> ::= [<tt class="docutils literal"><span class="pre">const</span></tt>] <em>base-type</em> {<tt class="docutils literal"><span class="pre">*</span></tt>} [<tt class="docutils literal"><span class="pre">&</span></tt>] - -<em>type-list</em> ::= <em>type</em> [<tt class="docutils literal"><span class="pre">,</span></tt> <em>type-list</em>] - -<em>base-type</em> ::= [<em>scoped-name</em> | <em>template</em> | <tt class="docutils literal"><span class="pre">struct</span></tt> <em>scoped-name</em> | - <tt class="docutils literal"><span class="pre">short</span></tt> | <tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">short</span></tt> | <tt class="docutils literal"><span class="pre">int</span></tt> | <tt class="docutils literal"><span class="pre">unsigned</span></tt> | - <tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">int</span></tt> | <tt class="docutils literal"><span class="pre">long</span></tt> | <tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">long</span></tt> | <tt class="docutils literal"><span class="pre">float</span></tt> | - <tt class="docutils literal"><span class="pre">double</span></tt> | <tt class="docutils literal"><span class="pre">bool</span></tt> | <tt class="docutils literal"><span class="pre">char</span></tt> | <tt class="docutils literal"><span class="pre">signed</span> <span class="pre">char</span></tt> | - <tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">char</span></tt> | <tt class="docutils literal"><span class="pre">void</span></tt> | <tt class="docutils literal"><span class="pre">wchar_t</span></tt> | <a class="reference" href="#sip-pycallable">SIP_PYCALLABLE</a> | - <a class="reference" href="#sip-pydict">SIP_PYDICT</a> | <a class="reference" href="#sip-pylist">SIP_PYLIST</a> | <a class="reference" href="#sip-pyobject">SIP_PYOBJECT</a> | <a class="reference" href="#sip-pyslice">SIP_PYSLICE</a> | - <a class="reference" href="#sip-pytuple">SIP_PYTUPLE</a> | <a class="reference" href="#sip-pytype">SIP_PYTYPE</a>] - -<em>scoped-name</em> ::= <em>name</em> [<tt class="docutils literal"><span class="pre">::</span></tt> <em>scoped-name</em>] - -<em>template</em> ::= <em>scoped-name</em> <tt class="docutils literal"><span class="pre"><</span></tt> <em>type-list</em> <tt class="docutils literal"><span class="pre">></span></tt> - -<em>name</em> ::= _A-Za-z {_A-Za-z0-9} -</pre> -<p>Here is a short list of differences between C++ and the subset supported by -SIP that might trip you up.</p> -<blockquote> -<ul class="simple"> -<li>SIP does not support the use of <tt class="docutils literal"><span class="pre">[]</span></tt> in types. Use pointers instead.</li> -<li>A global <tt class="docutils literal"><span class="pre">operator</span></tt> can only be defined if its first argument is a -class or a named enum that has been wrapped in the same module.</li> -<li>Variables declared outside of a class are effectively read-only.</li> -<li>A class's list of super-classes doesn't not include any access specifier -(e.g. <tt class="docutils literal"><span class="pre">public</span></tt>).</li> -</ul> -</blockquote> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id45" id="variable-numbers-of-arguments" name="variable-numbers-of-arguments">6.2 Variable Numbers of Arguments</a></h2> -<p>SIP supports the use of <tt class="docutils literal"><span class="pre">...</span></tt> as the last part of a function signature. Any -remaining arguments are collected as a Python tuple.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id46" id="additional-sip-types" name="additional-sip-types">6.3 Additional SIP Types</a></h2> -<p>SIP supports a number of additional data types that can be used in Python -signatures.</p> -<div class="section"> -<h3><a class="toc-backref" href="#id47" id="sip-anyslot" name="sip-anyslot">6.3.1 SIP_ANYSLOT</a></h3> -<p>This is both a <tt class="docutils literal"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*</span></tt> and a <tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt> that is used as the type -of the member instead of <tt class="docutils literal"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*</span></tt> in functions that implement the -connection or disconnection of an explicitly generated signal to a slot. -Handwritten code must be provided to interpret the conversion correctly.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id48" id="sip-pycallable" name="sip-pycallable">6.3.2 SIP_PYCALLABLE</a></h3> -<p>This is a <tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt> that is a Python callable object.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id49" id="sip-pydict" name="sip-pydict">6.3.3 SIP_PYDICT</a></h3> -<p>This is a <tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt> that is a Python dictionary object.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id50" id="sip-pylist" name="sip-pylist">6.3.4 SIP_PYLIST</a></h3> -<p>This is a <tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt> that is a Python list object.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id51" id="sip-pyobject" name="sip-pyobject">6.3.5 SIP_PYOBJECT</a></h3> -<p>This is a <tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt> of any Python type.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id52" id="sip-pyslice" name="sip-pyslice">6.3.6 SIP_PYSLICE</a></h3> -<p>This is a <tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt> that is a Python slice object.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id53" id="sip-pytuple" name="sip-pytuple">6.3.7 SIP_PYTUPLE</a></h3> -<p>This is a <tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt> that is a Python tuple object.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id54" id="sip-pytype" name="sip-pytype">6.3.8 SIP_PYTYPE</a></h3> -<p>This is a <tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt> that is a Python type object.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id55" id="sip-qobject" name="sip-qobject">6.3.9 SIP_QOBJECT</a></h3> -<p>This is a <tt class="docutils literal"><span class="pre">TQObject</span> <span class="pre">*</span></tt> that is a C++ instance of a class derived from Qt's -<tt class="docutils literal"><span class="pre">TQObject</span></tt> class.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id56" id="sip-rxobj-con" name="sip-rxobj-con">6.3.10 SIP_RXOBJ_CON</a></h3> -<p>This is a <tt class="docutils literal"><span class="pre">TQObject</span> <span class="pre">*</span></tt> that is a C++ instance of a class derived from Qt's -<tt class="docutils literal"><span class="pre">TQObject</span></tt> class. It is used as the type of the receiver instead of <tt class="docutils literal"><span class="pre">const</span> -<span class="pre">TQObject</span> <span class="pre">*</span></tt> in functions that implement a connection to a slot.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id57" id="sip-rxobj-dis" name="sip-rxobj-dis">6.3.11 SIP_RXOBJ_DIS</a></h3> -<p>This is a <tt class="docutils literal"><span class="pre">TQObject</span> <span class="pre">*</span></tt> that is a C++ instance of a class derived from Qt's -<tt class="docutils literal"><span class="pre">TQObject</span></tt> class. It is used as the type of the receiver instead of <tt class="docutils literal"><span class="pre">const</span> -<span class="pre">TQObject</span> <span class="pre">*</span></tt> in functions that implement a disconnection from a slot.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id58" id="sip-signal" name="sip-signal">6.3.12 SIP_SIGNAL</a></h3> -<p>This is a <tt class="docutils literal"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*</span></tt> that is used as the type of the signal instead of -<tt class="docutils literal"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*</span></tt> in functions that implement the connection or disconnection -of an explicitly generated signal to a slot.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id59" id="sip-slot" name="sip-slot">6.3.13 SIP_SLOT</a></h3> -<p>This is a <tt class="docutils literal"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*</span></tt> that is used as the type of the member instead of -<tt class="docutils literal"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*</span></tt> in functions that implement the connection or disconnection -of an explicitly generated signal to a slot.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id60" id="sip-slot-con" name="sip-slot-con">6.3.14 SIP_SLOT_CON</a></h3> -<p>This is a <tt class="docutils literal"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*</span></tt> that is used as the type of the member instead of -<tt class="docutils literal"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*</span></tt> in functions that implement the connection of an internally -generated signal to a slot. The type includes a comma separated list of types -that is the C++ signature of of the signal.</p> -<p>To take an example, <tt class="docutils literal"><span class="pre">TQAccel::connectItem()</span></tt> connects an internally generated -signal to a slot. The signal is emitted when the keyboard accelerator is -activated and it has a single integer argument that is the ID of the -accelerator. The C++ signature is:</p> -<pre class="literal-block"> -bool connectItem(int id, const TQObject *receiver, const char *member); -</pre> -<p>The corresponding SIP specification is:</p> -<pre class="literal-block"> -bool connectItem(int, SIP_RXOBJ_CON, SIP_SLOT_CON(int)); -</pre> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id61" id="sip-slot-dis" name="sip-slot-dis">6.3.15 SIP_SLOT_DIS</a></h3> -<p>This is a <tt class="docutils literal"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*</span></tt> that is used as the type of the member instead of -<tt class="docutils literal"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*</span></tt> in functions that implement the disconnection of an -internally generated signal to a slot. The type includes a comma separated -list of types that is the C++ signature of of the signal.</p> -</div> -</div> -</div> -<div class="section"> -<h1><a class="toc-backref" href="#id62" id="sip-directives" name="sip-directives">7 SIP Directives</a></h1> -<p>In this section we describe each of the directives that can be used in -specification files. All directives begin with <tt class="docutils literal"><span class="pre">%</span></tt> as the first -non-whitespace character in a line.</p> -<p>Some directives have arguments or contain blocks of code or documentation. In -the following descriptions these are shown in <em>italics</em>. Optional arguments -are enclosed in [<em>brackets</em>].</p> -<p>Some directives are used to specify handwritten code. Handwritten code must -not define names that start with the prefix <tt class="docutils literal"><span class="pre">sip</span></tt>.</p> -<div class="section"> -<h2><a class="toc-backref" href="#id63" id="accesscode" name="accesscode">7.1 %AccessCode</a></h2> -<pre class="literal-block"> -%AccessCode - <em>code</em> -%End -</pre> -<p>This directive is used immediately after the declaration of an instance of a -wrapped class or structure, or a pointer to such an instance. You use it to -provide handwritten code that overrides the default behaviour.</p> -<p>For example:</p> -<pre class="literal-block"> -class Klass; - -Klass *klassInstance; -%AccessCode - // In this contrived example the C++ library we are wrapping defines - // klassInstance as Klass ** (which SIP doesn't support) so we - // explicitly dereference it. - if (klassInstance && *klassInstance) - return *klassInstance; - - // This will get converted to None. - return 0; -%End -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id64" id="bigetcharbuffercode" name="bigetcharbuffercode">7.2 %BIGetCharBufferCode</a></h2> -<pre class="literal-block"> -%BIGetCharBufferCode - <em>code</em> -%End -</pre> -<p>This directive (along with <a class="reference" href="#bigetreadbuffercode">%BIGetReadBufferCode</a>, <a class="reference" href="#bigetsegcountcode">%BIGetSegCountCode</a> and -<a class="reference" href="#bigetwritebuffercode">%BIGetWriteBufferCode</a>) is used to specify code that implements Python's -buffer interface. See the section <a class="reference" href="http://www.python.org/dev/doc/devel/api/buffer-structs.html">Buffer Object Structures</a> for the -details.</p> -<p>The following variables are made available to the handwritten code:</p> -<dl class="docutils"> -<dt><em>type</em> *sipCpp</dt> -<dd>This is a pointer to the structure or class instance. Its <em>type</em> is a -pointer to the structure or class.</dd> -<dt>void **sipPtrPtr</dt> -<dd>This is the pointer used to return the address of the character buffer.</dd> -<dt>SIP_SSIZE_T sipRes</dt> -<dd>The handwritten code should set this to the length of the character buffer -or -1 if there was an error.</dd> -<dt>SIP_SSIZE_T sipSegment</dt> -<dd>This is the number of the segment of the character buffer.</dd> -<dt>PyObject *sipSelf</dt> -<dd>This is the Python object that wraps the the structure or class instance, -i.e. <tt class="docutils literal"><span class="pre">self</span></tt>.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id65" id="bigetreadbuffercode" name="bigetreadbuffercode">7.3 %BIGetReadBufferCode</a></h2> -<pre class="literal-block"> -%BIGetReadBufferCode - <em>code</em> -%End -</pre> -<p>This directive (along with <a class="reference" href="#bigetcharbuffercode">%BIGetCharBufferCode</a>, <a class="reference" href="#bigetsegcountcode">%BIGetSegCountCode</a> and -<a class="reference" href="#bigetwritebuffercode">%BIGetWriteBufferCode</a>) is used to specify code that implements Python's -buffer interface.</p> -<p>The following variables are made available to the handwritten code:</p> -<dl class="docutils"> -<dt><em>type</em> *sipCpp</dt> -<dd>This is a pointer to the structure or class instance. Its <em>type</em> is a -pointer to the structure or class.</dd> -<dt>void **sipPtrPtr</dt> -<dd>This is the pointer used to return the address of the read buffer.</dd> -<dt>SIP_SSIZE_T sipRes</dt> -<dd>The handwritten code should set this to the length of the read buffer or --1 if there was an error.</dd> -<dt>SIP_SSIZE_T sipSegment</dt> -<dd>This is the number of the segment of the read buffer.</dd> -<dt>PyObject *sipSelf</dt> -<dd>This is the Python object that wraps the the structure or class instance, -i.e. <tt class="docutils literal"><span class="pre">self</span></tt>.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id66" id="bigetsegcountcode" name="bigetsegcountcode">7.4 %BIGetSegCountCode</a></h2> -<pre class="literal-block"> -%BIGetSegCountCode - <em>code</em> -%End -</pre> -<p>This directive (along with <a class="reference" href="#bigetcharbuffercode">%BIGetCharBufferCode</a>, <a class="reference" href="#bigetreadbuffercode">%BIGetReadBufferCode</a> and -<a class="reference" href="#bigetwritebuffercode">%BIGetWriteBufferCode</a>) is used to specify code that implements Python's -buffer interface.</p> -<p>The following variables are made available to the handwritten code:</p> -<dl class="docutils"> -<dt><em>type</em> *sipCpp</dt> -<dd>This is a pointer to the structure or class instance. Its <em>type</em> is a -pointer to the structure or class.</dd> -<dt>SIP_SSIZE_T *sipLenPtr</dt> -<dd>This is the pointer used to return the total length in bytes of all -segments of the buffer.</dd> -<dt>SIP_SSIZE_T sipRes</dt> -<dd>The handwritten code should set this to the number of segments that make -up the buffer.</dd> -<dt>PyObject *sipSelf</dt> -<dd>This is the Python object that wraps the the structure or class instance, -i.e. <tt class="docutils literal"><span class="pre">self</span></tt>.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id67" id="bigetwritebuffercode" name="bigetwritebuffercode">7.5 %BIGetWriteBufferCode</a></h2> -<pre class="literal-block"> -%BIGetWriteBufferCode - <em>code</em> -%End -</pre> -<p>This directive (along with <a class="reference" href="#bigetcharbuffercode">%BIGetCharBufferCode</a>, <a class="reference" href="#bigetreadbuffercode">%BIGetReadBufferCode</a> -and <a class="reference" href="#bigetsegcountcode">%BIGetSegCountCode</a> is used to specify code that implements Python's -buffer interface.</p> -<p>The following variables are made available to the handwritten code:</p> -<dl class="docutils"> -<dt><em>type</em> *sipCpp</dt> -<dd>This is a pointer to the structure or class instance. Its <em>type</em> is a -pointer to the structure or class.</dd> -<dt>void **sipPtrPtr</dt> -<dd>This is the pointer used to return the address of the write buffer.</dd> -<dt>SIP_SSIZE_T sipRes</dt> -<dd>The handwritten code should set this to the length of the write buffer or --1 if there was an error.</dd> -<dt>SIP_SSIZE_T sipSegment</dt> -<dd>This is the number of the segment of the write buffer.</dd> -<dt>PyObject *sipSelf</dt> -<dd>This is the Python object that wraps the the structure or class instance, -i.e. <tt class="docutils literal"><span class="pre">self</span></tt>.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id68" id="cmodule" name="cmodule">7.6 %CModule</a></h2> -<pre class="literal-block"> -%CModule <em>name</em> [<em>version</em>] -</pre> -<p>This directive is used to identify that the library being wrapped is a C -library and to define the name of the module and it's optional version number.</p> -<p>See the <a class="reference" href="#module">%Module</a> directive for an explanation of the version number.</p> -<p>For example:</p> -<pre class="literal-block"> -%CModule dbus 1 -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id69" id="convertfromtypecode" name="convertfromtypecode">7.7 %ConvertFromTypeCode</a></h2> -<pre class="literal-block"> -%ConvertFromTypeCode - <em>code</em> -%End -</pre> -<p>This directive is used as part of the <a class="reference" href="#mappedtype">%MappedType</a> directive to specify the -handwritten code that converts an instance of a mapped type to a Python -object.</p> -<p>The following variables are made available to the handwritten code:</p> -<dl class="docutils"> -<dt><em>type</em> *sipCpp</dt> -<dd>This is a pointer to the instance of the mapped type to be converted. It -will never be zero as the conversion from zero to <tt class="docutils literal"><span class="pre">Py_None</span></tt> is handled -before the handwritten code is called.</dd> -<dt>PyObject *sipTransferObj</dt> -<dd>This specifies any desired ownership changes to the returned object. If it -is <tt class="docutils literal"><span class="pre">NULL</span></tt> then the ownership should be left unchanged. If it is -<tt class="docutils literal"><span class="pre">Py_None</span></tt> then ownership should be transferred to Python. Otherwise -ownership should be transferred to C/C++ and the returned object associated -with <em>sipTransferObj</em>. The code can choose to interpret these changes in -any way. For example, if the code is converting a C++ container of wrapped -classes to a Python list it is likely that the ownership changes should be -made to each element of the list.</dd> -</dl> -<p>The handwritten code must explicitly return a <tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt>. If there was an -error then a Python exception must be raised and <tt class="docutils literal"><span class="pre">NULL</span></tt> returned.</p> -<p>The following example converts a <tt class="docutils literal"><span class="pre">QList<TQWidget</span> <span class="pre">*></span></tt> instance to a Python -list of <tt class="docutils literal"><span class="pre">TQWidget</span></tt> instances:</p> -<pre class="literal-block"> -%ConvertFromTypeCode - PyObject *l; - - // Create the Python list of the correct length. - if ((l = PyList_New(sipCpp -> size())) == NULL) - return NULL; - - // Go through each element in the C++ instance and convert it to a - // wrapped TQWidget. - for (int i = 0; i < sipCpp -> size(); ++i) - { - TQWidget *w = sipCpp -> at(i); - PyObject *wobj; - - // Get the Python wrapper for the TQWidget instance, creating a new - // one if necessary, and handle any ownership transfer. - if ((wobj = sipConvertFromInstance(w, sipClass_QWidget, sipTransferObj)) == NULL) - { - // There was an error so garbage collect the Python list. - Py_DECREF(l); - return NULL; - } - - // Add the wrapper to the list. - PyList_SET_ITEM(l, i, wobj); - } - - // Return the Python list. - return l; -%End -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id70" id="converttosubclasscode" name="converttosubclasscode">7.8 %ConvertToSubClassCode</a></h2> -<pre class="literal-block"> -%ConvertToSubClassCode - <em>code</em> -%End -</pre> -<p>When SIP needs to wrap a C++ class instance it first checks to make sure it -hasn't already done so. If it has then it just returns a new reference to the -corresponding Python object. Otherwise it creates a new Python object of the -appropriate type. In C++ a function may be defined to return an instance of a -certain class, but can often return a sub-class instead.</p> -<p>This directive is used to specify handwritten code that exploits any available -real-time type information (RTTI) to see if there is a more specific Python -type that can be used when wrapping the C++ instance. The RTTI may be -provided by the compiler or by the C++ instance itself.</p> -<p>The directive is included in the specification of one of the classes that the -handwritten code handles the type conversion for. It doesn't matter which -one, but a sensible choice would be the one at the root of that class -hierarchy in the module.</p> -<p>Note that if a class hierarchy extends over a number of modules then this -directive should be used in each of those modules to handle the part of the -hierarchy defined in that module. SIP will ensure that the different pieces -of code are called in the right order to determine the most specific Python -type to use.</p> -<p>The following variables are made available to the handwritten code:</p> -<dl class="docutils"> -<dt><em>type</em> *sipCpp</dt> -<dd>This is a pointer to the C++ class instance.</dd> -<dt>void **sipCppRet</dt> -<dd>When the sub-class is derived from more than one super-class then it is -possible that the C++ address of the instance as the sub-class is -different to that of the super-class. If so, then this must be set to the -C++ address of the instance when cast (usually using <tt class="docutils literal"><span class="pre">static_cast</span></tt>) -from the super-class to the sub-class.</dd> -<dt>sipWrapperType *sipClass</dt> -<dd>The handwritten code must set this to the SIP generated Python type object -that corresponds to the class instance. (The type object for class -<tt class="docutils literal"><span class="pre">Klass</span></tt> is <tt class="docutils literal"><span class="pre">sipClass_Klass</span></tt>.) If the RTTI of the class instance isn't -recognised then <tt class="docutils literal"><span class="pre">sipClass</span></tt> must be set to <tt class="docutils literal"><span class="pre">NULL</span></tt>. The code doesn't -have to recognise the exact class, only the most specific sub-class that -it can.</dd> -</dl> -<p>The handwritten code must not explicitly return.</p> -<p>The following example shows the sub-class conversion code for <tt class="docutils literal"><span class="pre">TQEvent</span></tt> based -class hierarchy in PyQt:</p> -<pre class="literal-block"> -class QEvent -{ -%ConvertToSubClassCode - // TQEvent sub-classes provide a unique type ID. - switch (sipCpp -> type()) - { - case TQEvent::Timer: - sipClass = sipClass_QTimerEvent; - break; - - case TQEvent::KeyPress: - case TQEvent::KeyRelease: - sipClass = sipClass_QKeyEvent; - break; - - // Skip the remaining event types to keep the example short. - - default: - // We don't recognise the type. - sipClass = NULL; - } -%End - - // The rest of the class specification. - -}; -</pre> -<p>The SIP API includes the <a class="reference" href="#sipmapinttoclass">sipMapIntToClass()</a> and <a class="reference" href="#sipmapstringtoclass">sipMapStringToClass()</a> -functions that convert integer and string based RTTI to Python type objects -based on ordered lookup tables.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id71" id="converttotypecode" name="converttotypecode">7.9 %ConvertToTypeCode</a></h2> -<pre class="literal-block"> -%ConvertToTypeCode - <em>code</em> -%End -</pre> -<p>This directive is used to specify the handwritten code that converts a Python -object to a mapped type instance and to handle any ownership transfers. It is -used as part of the <a class="reference" href="#mappedtype">%MappedType</a> directive and as part of a class -specification. The code is also called to determine if the Python object is of -the correct type prior to conversion.</p> -<p>When used as part of a class specification it can automatically convert -additional types of Python object. For example, PyQt uses it in the -specification of the <tt class="docutils literal"><span class="pre">TQString</span></tt> class to allow Python string objects and -unicode objects to be used wherever <tt class="docutils literal"><span class="pre">TQString</span></tt> instances are expected.</p> -<p>The following variables are made available to the handwritten code:</p> -<dl class="docutils"> -<dt>int *sipIsErr</dt> -<dd>If this is <tt class="docutils literal"><span class="pre">NULL</span></tt> then the code is being asked to check the type of the -Python object. The check must not have any side effects. Otherwise the -code is being asked to convert the Python object and a non-zero value -should be returned through this pointer if an error occurred during the -conversion.</dd> -<dt>PyObject *sipPy</dt> -<dd>This is the Python object to be converted.</dd> -<dt><em>type</em> **sipCppPtr</dt> -<dd>This is a pointer through which the address of the mapped type instance (or -zero if appropriate) is returned. Its value is undefined if <tt class="docutils literal"><span class="pre">sipIsErr</span></tt> -is <tt class="docutils literal"><span class="pre">NULL</span></tt>.</dd> -<dt>PyObject *sipTransferObj</dt> -<dd>This specifies any desired ownership changes to <em>sipPy</em>. If it is <tt class="docutils literal"><span class="pre">NULL</span></tt> -then the ownership should be left unchanged. If it is <tt class="docutils literal"><span class="pre">Py_None</span></tt> then -ownership should be transferred to Python. Otherwise ownership should be -transferred to C/C++ and <em>sipPy</em> associated with <em>sipTransferObj</em>. The -code can choose to interpret these changes in any way.</dd> -</dl> -<p>The handwritten code must explicitly return an <tt class="docutils literal"><span class="pre">int</span></tt> the meaning of which -depends on the value of <tt class="docutils literal"><span class="pre">sipIsErr</span></tt>.</p> -<p>If <tt class="docutils literal"><span class="pre">sipIsErr</span></tt> is <tt class="docutils literal"><span class="pre">NULL</span></tt> then a non-zero value is returned if the Python -object has a type that can be converted to the mapped type. Otherwise zero is -returned.</p> -<p>If <tt class="docutils literal"><span class="pre">sipIsErr</span></tt> is not <tt class="docutils literal"><span class="pre">NULL</span></tt> then a combination of the following flags is -returned.</p> -<blockquote> -<ul class="simple"> -<li><tt class="docutils literal"><span class="pre">SIP_TEMPORARY</span></tt> is set to indicate that the returned instance is a -temporary and should be released to avoid a memory leak.</li> -<li><tt class="docutils literal"><span class="pre">SIP_DERIVED_CLASS</span></tt> is set to indicate that the type of the -returned instance is a derived class. See <a class="reference" href="#generated-derived-classes">Generated Derived -Classes</a>.</li> -</ul> -</blockquote> -<p>The following example converts a Python list of <tt class="docutils literal"><span class="pre">TQPoint</span></tt> instances to a -<tt class="docutils literal"><span class="pre">QList<TQPoint></span></tt> instance:</p> -<pre class="literal-block"> -%ConvertToTypeCode - // See if we are just being asked to check the type of the Python - // object. - if (!sipIsErr) - { - // Checking whether or not None has been passed instead of a list - // has already been done. - if (!PyList_Check(sipPy)) - return 0; - - // Check the type of each element. We specify SIP_NOT_NONE to - // disallow None because it is a list of TQPoint, not of a pointer - // to a TQPoint, so None isn't appropriate. - for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) - if (!sipCanConvertToInstance(PyList_GET_ITEM(sipPy, i), - sipClass_QPoint, SIP_NOT_NONE)) - return 0; - - // The type is valid. - return 1; - } - - // Create the instance on the heap. - QList<TQPoint> *ql = new QList<TQPoint>; - - for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) - { - TQPoint *qp; - int state; - - // Get the address of the element's C++ instance. Note that, in - // this case, we don't apply any ownership changes to the list - // elements, only to the list itself. - qp = reinterpret_cast<TQPoint *>(sipConvertToInstance( - PyList_GET_ITEM(sipPy, i), - sipClass_QPoint, 0, - SIP_NOT_NONE, - &state, sipIsErr)); - - // Deal with any errors. - if (*sipIsErr) - { - sipReleaseInstance(qp, sipClass_QPoint, state); - - // Tidy up. - delete ql; - - // There is no temporary instance. - return 0; - } - - ql -> append(*qp); - - // A copy of the TQPoint was appended to the list so we no longer - // need it. It may be a temporary instance that should be - // destroyed, or a wrapped instance that should not be destroyed. - // sipReleaseInstance() will do the right thing. - sipReleaseInstance(qp, sipClass_QPoint, state); - } - - // Return the instance. - *sipCppPtr = ql; - - // The instance should be regarded as temporary (and be destroyed as - // soon as it has been used) unless it has been transferred from - // Python. sipGetState() is a convenience function that implements - // this common transfer behaviour. - return sipGetState(sipTransferObj); -%End -</pre> -<p>When used in a class specification the handwritten code replaces the code that -would normally be automatically generated. This means that the handwritten -code must also handle instances of the class itself and not just the additional -types that are being supported. This should be done by making calls to -<a class="reference" href="#sipcanconverttoinstance">sipCanConvertToInstance()</a> to check the object type and -<a class="reference" href="#sipconverttoinstance">sipConvertToInstance()</a> to convert the object. The <tt class="docutils literal"><span class="pre">SIP_NO_CONVERTORS</span></tt> -flag <em>must</em> be passed to both these functions to prevent recursive calls to the -handwritten code.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id72" id="copying" name="copying">7.10 %Copying</a></h2> -<pre class="literal-block"> -%Copying - <em>text</em> -%End -</pre> -<p>This directive is used to specify some arbitrary text that will be included at -the start of all source files generated by SIP. It is normally used to -include copyright and licensing terms.</p> -<p>For example:</p> -<pre class="literal-block"> -%Copying -Copyright (c) 2007 Riverbank Computing Limited -%End -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id73" id="doc" name="doc">7.11 %Doc</a></h2> -<pre class="literal-block"> -%Doc - <em>text</em> -%End -</pre> -<p>This directive is used to specify some arbitrary text that will be extracted -by SIP when the <tt class="docutils literal"><span class="pre">-d</span></tt> command line option is used. The directive can be -specified any number of times and SIP will concatenate all the separate pieces -of text in the order that it sees them.</p> -<p>Documentation that is specified using this directive is local to the module in -which it appears. It is ignored by modules that <a class="reference" href="#import">%Import</a> it. Use the -<a class="reference" href="#exporteddoc">%ExportedDoc</a> directive for documentation that should be included by all -modules that <a class="reference" href="#import">%Import</a> this one.</p> -<p>For example:</p> -<pre class="literal-block"> -%Doc -<h1>An Example</h1> -<p> -This fragment of documentation is HTML and is local to the module in -which it is defined. -</p> -%End -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id74" id="end" name="end">7.12 %End</a></h2> -<p>This isn't a directive in itself, but is used to terminate a number of -directives that allow a block of handwritten code or text to be specified.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id75" id="exception" name="exception">7.13 %Exception</a></h2> -<pre class="literal-block"> -%Exception <em>name</em> [(<em>base-exception)] -{ - [*header-code</em>] - <em>raise-code</em> -}; -</pre> -<p>This directive is used to define new Python exceptions, or to provide a stub -for existing Python exceptions. It allows handwritten code to be provided -that implements the translation between C++ exceptions and Python exceptions. -The arguments to <tt class="docutils literal"><span class="pre">throw</span> <span class="pre">()</span></tt> specifiers must either be names of classes or the -names of Python exceptions defined by this directive.</p> -<p><em>name</em> is the name of the exception.</p> -<p><em>base-exception</em> is the optional base exception. This may be either one of -the standard Python exceptions or one defined with a previous <a class="reference" href="#exception">%Exception</a> -directive.</p> -<p><em>header-code</em> is the optional <a class="reference" href="#typeheadercode">%TypeHeaderCode</a> used to specify any external -interface to the exception being defined.</p> -<p><em>raise-code</em> is the <a class="reference" href="#raisecode">%RaiseCode</a> used to specify the handwritten code that -converts a reference to the C++ exception to the Python exception.</p> -<p>For example:</p> -<pre class="literal-block"> -%Exception std::exception(SIP_Exception) /PyName=StdException/ -{ -%TypeHeaderCode -#include <exception> -%End -%RaiseCode - const char *detail = sipExceptionReference.what(); - - SIP_BLOCK_THREADS - PyErr_SetString(sipException_StdException, detail); - SIP_UNBLOCK_THREADS -%End -}; -</pre> -<p>In this example we map the standard C++ exception to a new Python exception. -The new exception is called <tt class="docutils literal"><span class="pre">StdException</span></tt> and is derived from the standard -Python exception <tt class="docutils literal"><span class="pre">Exception</span></tt>.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id76" id="exporteddoc" name="exporteddoc">7.14 %ExportedDoc</a></h2> -<pre class="literal-block"> -%ExportedDoc - <em>text</em> -%End -</pre> -<p>This directive is used to specify some arbitrary text that will be extracted -by SIP when the <tt class="docutils literal"><span class="pre">-d</span></tt> command line option is used. The directive can be -specified any number of times and SIP will concatenate all the separate pieces -of text in the order that it sees them.</p> -<p>Documentation that is specified using this directive will also be included by -modules that <a class="reference" href="#import">%Import</a> it.</p> -<p>For example:</p> -<pre class="literal-block"> -%ExportedDoc -========== -An Example -========== - -This fragment of documentation is reStructuredText and will appear in the -module in which it is defined and all modules that %Import it. -%End -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id77" id="exportedheadercode" name="exportedheadercode">7.15 %ExportedHeaderCode</a></h2> -<pre class="literal-block"> -%ExportedHeaderCode - <em>code</em> -%End -</pre> -<p>This directive is used to specify handwritten code, typically the declarations -of types, that is placed in a header file that is included by all generated -code for all modules. It should not include function declarations because -Python modules should not explicitly call functions in another Python module.</p> -<p>See also <a class="reference" href="#modulecode">%ModuleCode</a> and <a class="reference" href="#moduleheadercode">%ModuleHeaderCode</a>.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id78" id="feature" name="feature">7.16 %Feature</a></h2> -<pre class="literal-block"> -%Feature <em>name</em> -</pre> -<p>This directive is used to declare a feature. Features (along with -<a class="reference" href="#platforms">%Platforms</a> and <a class="reference" href="#timeline">%Timeline</a>) are used by the <a class="reference" href="#if">%If</a> directive to control -whether or not parts of a specification are processed or ignored.</p> -<p>Features are mutually independent of each other - any combination of features -may be enabled or disable. By default all features are enabled. The SIP -<tt class="docutils literal"><span class="pre">-x</span></tt> command line option is used to disable a feature.</p> -<p>If a feature is enabled then SIP will automatically generate a corresponding C -preprocessor symbol for use by handwritten code. The symbol is the name of -the feature prefixed by <tt class="docutils literal"><span class="pre">SIP_FEATURE_</span></tt>.</p> -<p>For example:</p> -<pre class="literal-block"> -%Feature FOO_SUPPORT - -%If (FOO_SUPPORT) -void foo(); -%End -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id79" id="gcclearcode" name="gcclearcode">7.17 %GCClearCode</a></h2> -<pre class="literal-block"> -%GCClearCode - <em>code</em> -%End -</pre> -<p>Python has a cyclic garbage collector which can identify and release unneeded -objects even when their reference counts are not zero. If a wrapped C -structure or C++ class keeps its own reference to a Python object then, if the -garbage collector is to do its job, it needs to provide some handwritten code -to traverse and potentially clear those embedded references.</p> -<p>See the section <em>Supporting cyclic garbage collection</em> in <a class="reference" href="http://www.python.org/dev/doc/devel/ext/">Embedding and -Extending the Python Interpreter</a> -for the details.</p> -<p>This directive is used to specify the code that clears any embedded references. -(See <a class="reference" href="#gctraversecode">%GCTraverseCode</a> for specifying the code that traverses any embedded -references.)</p> -<p>The following variables are made available to the handwritten code:</p> -<dl class="docutils"> -<dt><em>type</em> *sipCpp</dt> -<dd>This is a pointer to the structure or class instance. Its <em>type</em> is a -pointer to the structure or class.</dd> -<dt>int sipRes</dt> -<dd>The handwritten code should set this to the result to be returned.</dd> -</dl> -<p>The following simplified example is taken from PyQt. The <tt class="docutils literal"><span class="pre">TQCustomEvent</span></tt> -class allows arbitary data to be attached to the event. In PyQt this data is -always a Python object and so should be handled by the garbage collector:</p> -<pre class="literal-block"> -%GCClearCode - PyObject *obj; - - // Get the object. - obj = reinterpret_cast<PyObject *>(sipCpp -> data()); - - // Clear the pointer. - sipCpp -> setData(0); - - // Clear the reference. - Py_XDECREF(obj); - - // Report no error. - sipRes = 0; -%End -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id80" id="gctraversecode" name="gctraversecode">7.18 %GCTraverseCode</a></h2> -<pre class="literal-block"> -%GCTraverseCode - <em>code</em> -%End -</pre> -<p>This directive is used to specify the code that traverses any embedded -references for Python's cyclic garbage collector. (See <a class="reference" href="#gcclearcode">%GCClearCode</a> for a -full explanation.)</p> -<p>The following variables are made available to the handwritten code:</p> -<dl class="docutils"> -<dt><em>type</em> *sipCpp</dt> -<dd>This is a pointer to the structure or class instance. Its <em>type</em> is a -pointer to the structure or class.</dd> -<dt>visitproc sipVisit</dt> -<dd>This is the visit function provided by the garbage collector.</dd> -<dt>void *sipArg</dt> -<dd>This is the argument to the visit function provided by the garbage -collector.</dd> -<dt>int sipRes</dt> -<dd>The handwritten code should set this to the result to be returned.</dd> -</dl> -<p>The following simplified example is taken from PyQt's <tt class="docutils literal"><span class="pre">TQCustomEvent</span></tt> class:</p> -<pre class="literal-block"> -%GCTraverseCode - PyObject *obj; - - // Get the object. - obj = reinterpret_cast<PyObject *>(sipCpp -> data()); - - // Call the visit function if there was an object. - if (obj) - sipRes = sipVisit(obj, sipArg); - else - sipRes = 0; -%End -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id81" id="getcode" name="getcode">7.19 %GetCode</a></h2> -<pre class="literal-block"> -%GetCode - <em>code</em> -%End -</pre> -<p>This directive is used after the declaration of a C++ class variable or C -structure member to specify handwritten code to convert it to a Python object. -It is usually used to handle types that SIP cannot deal with automatically.</p> -<p>The following variables are made available to the handwritten code:</p> -<dl class="docutils"> -<dt><em>type</em> *sipCpp</dt> -<dd>This is a pointer to the structure or class instance. Its <em>type</em> is a -pointer to the structure or class. It is not made available if the -variable being wrapped is a static class variable.</dd> -<dt>PyObject *sipPy</dt> -<dd>The handwritten code must set this to the Python representation of the -class variable or structure member. If there is an error then the code -must raise an exception and set this to <tt class="docutils literal"><span class="pre">NULL</span></tt>.</dd> -</dl> -<p>For example:</p> -<pre class="literal-block"> -struct Entity -{ - /* - * In this contrived example the C library we are wrapping actually - * defines this as char buffer[100] which SIP cannot handle - * automatically. - */ - char *buffer; -%GetCode - sipPy = PyString_FromStringAndSize(sipCpp -> buffer, 100); -%End -%SetCode - char *ptr; - int length; - - if (PyString_AsStringAndSize(sipPy, &ptr, &length) == -1) - sipErr = 1; - else if (length != 100) - { - /* - * Raise an exception because the length isn't exactly right. - */ - - PyErr_SetString(PyExc_ValueError, "an Entity.buffer must be exactly 100 bytes"); - sipErr = 1; - } - else - memcpy(sipCpp -> buffer, ptr, 100); -%End -} -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id82" id="if" name="if">7.20 %If</a></h2> -<pre class="literal-block"> -%If (<em>expression</em>) - <em>specification</em> -%End -</pre> -<p>where</p> -<pre class="literal-block"> -<em>expression</em> ::= [<em>ored-qualifiers</em> | <em>range</em>] - -<em>ored-qualifiers</em> ::= [<em>qualifier</em> | <em>qualifier</em> <tt class="docutils literal"><span class="pre">||</span></tt> <em>ored-qualifiers</em>] - -<em>qualifier</em> ::= [<tt class="docutils literal"><span class="pre">!</span></tt>] [<em>feature</em> | <em>platform</em>] - -<em>range</em> ::= [<em>version</em>] <tt class="docutils literal"><span class="pre">-</span></tt> [<em>version</em>] -</pre> -<p>This directive is used in conjunction with features (see <a class="reference" href="#feature">%Feature</a>), -platforms (see <a class="reference" href="#platforms">%Platforms</a>) and versions (see <a class="reference" href="#timeline">%Timeline</a>) to control -whether or not parts of a specification are processed or not.</p> -<p>A <em>range</em> of versions means all versions starting with the lower bound up to -but excluding the upper bound. If the lower bound is omitted then it is -interpreted as being before the earliest version. If the upper bound is -omitted then it is interpreted as being after the latest version.</p> -<p>For example:</p> -<pre class="literal-block"> -%Feature SUPPORT_FOO -%Platforms {WIN32_PLATFORM POSIX_PLATFORM MACOS_PLATFORM} -%Timeline {V1_0 V1_1 V2_0 V3_0} - -%If (!SUPPORT_FOO) - // Process this if the SUPPORT_FOO feature is disabled. -%End - -%If (POSIX_PLATFORM || MACOS_PLATFORM) - // Process this if either the POSIX_PLATFORM or MACOS_PLATFORM - // platforms are enabled. -%End - -%If (V1_0 - V2_0) - // Process this if either V1_0 or V1_1 is enabled. -%End - -%If (V2_0 - ) - // Process this if either V2_0 or V3_0 is enabled. -%End - -%If ( - ) - // Always process this. -%End -</pre> -<p>Note that this directive is not implemented as a preprocessor. Only the -following parts of a specification are affected by it:</p> -<blockquote> -<ul class="simple"> -<li><tt class="docutils literal"><span class="pre">class</span></tt></li> -<li><a class="reference" href="#convertfromtypecode">%ConvertFromTypeCode</a></li> -<li><a class="reference" href="#converttosubclasscode">%ConvertToSubClassCode</a></li> -<li><a class="reference" href="#converttotypecode">%ConvertToTypeCode</a></li> -<li><tt class="docutils literal"><span class="pre">enum</span></tt></li> -<li><a class="reference" href="#exportedheadercode">%ExportedHeaderCode</a></li> -<li>functions</li> -<li><a class="reference" href="#gcclearcode">%GCClearCode</a></li> -<li><a class="reference" href="#gctraversecode">%GCTraverseCode</a></li> -<li><a class="reference" href="#if">%If</a></li> -<li><a class="reference" href="#mappedtype">%MappedType</a></li> -<li><a class="reference" href="#methodcode">%MethodCode</a></li> -<li><a class="reference" href="#modulecode">%ModuleCode</a></li> -<li><a class="reference" href="#moduleheadercode">%ModuleHeaderCode</a></li> -<li><tt class="docutils literal"><span class="pre">namespace</span></tt></li> -<li><a class="reference" href="#postinitialisationcode">%PostInitialisationCode</a></li> -<li><a class="reference" href="#preinitialisationcode">%PreInitialisationCode</a></li> -<li><tt class="docutils literal"><span class="pre">struct</span></tt></li> -<li><tt class="docutils literal"><span class="pre">typedef</span></tt></li> -<li><a class="reference" href="#typecode">%TypeCode</a></li> -<li><a class="reference" href="#typeheadercode">%TypeHeaderCode</a></li> -<li><a class="reference" href="#unitcode">%UnitCode</a></li> -<li>variables</li> -<li><a class="reference" href="#virtualcatchercode">%VirtualCatcherCode</a></li> -</ul> -</blockquote> -<p>Also note that the only way to specify the logical and of qualifiers is to use -nested <a class="reference" href="#if">%If</a> directives.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id83" id="import" name="import">7.21 %Import</a></h2> -<pre class="literal-block"> -%Import <em>filename</em> -</pre> -<p>This directive is used to import the specification of another module. This is -needed if the current module makes use of any types defined in the imported -module, e.g. as an argument to a function, or to sub-class.</p> -<p>If <em>filename</em> cannot be opened then SIP prepends <em>filename</em> with the name of -the directory containing the current specification file (i.e. the one -containing the <a class="reference" href="#import">%Import</a> directive) and tries again. If this also fails then -SIP prepends <em>filename</em> with each of the directories, in turn, specified by -the <tt class="docutils literal"><span class="pre">-I</span></tt> command line option.</p> -<p>For example:</p> -<pre class="literal-block"> -%Import qt/qtmod.sip -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id84" id="include" name="include">7.22 %Include</a></h2> -<pre class="literal-block"> -%Include <em>filename</em> -</pre> -<p>This directive is used to include contents of another file as part of the -specification of the current module. It is the equivalent of the C -preprocessor's <tt class="docutils literal"><span class="pre">#include</span></tt> directive and is used to structure a large module -specification into manageable pieces.</p> -<p><a class="reference" href="#include">%Include</a> follows the same search process as <a class="reference" href="#import">%Import</a> when trying to open -<em>filename</em>.</p> -<p>For example:</p> -<pre class="literal-block"> -%Include qwidget.sip -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id85" id="id14" name="id14">7.23 %License</a></h2> -<pre class="literal-block"> -%License /<em>license-annotations</em>/ -</pre> -<p>This directive is used to specify the contents of an optional license -dictionary. The license dictionary is called <tt class="docutils literal"><span class="pre">__license__</span></tt> and is stored in -the module dictionary. The elements of the dictionary are specified using the -<a class="reference" href="#licensee">Licensee</a>, <a class="reference" href="#signature">Signature</a>, <a class="reference" href="#timestamp">Timestamp</a> and <a class="reference" href="#type">Type</a> annotations. Only the <a class="reference" href="#type">Type</a> -annotation is compulsory.</p> -<p>Note that this directive isn't an attempt to impose any licensing restrictions -on a module. It is simply a method for easily embedding licensing information -in a module so that it is accessible to Python scripts.</p> -<p>For example:</p> -<pre class="literal-block"> -%License /Type="GPL"/ -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id86" id="mappedtype" name="mappedtype">7.24 %MappedType</a></h2> -<pre class="literal-block"> -template<<em>type-list</em>> -%MappedType <em>type</em> -{ - [<em>header-code</em>] - [<em>convert-to-code</em>] - [<em>convert-from-code</em>] -}; - -%MappedType <em>type</em> -{ - [<em>header-code</em>] - [<em>convert-to-code</em>] - [<em>convert-from-code</em>] -}; -</pre> -<p>This directive is used to define an automatic mapping between a C or C++ type -and a Python type. It can be used as part of a template, or to map a specific -type.</p> -<p>When used as part of a template <em>type</em> cannot itself refer to a template. Any -occurrences of any of the type names (but not any <tt class="docutils literal"><span class="pre">*</span></tt> or <tt class="docutils literal"><span class="pre">&</span></tt>) in -<em>type-list</em> will be replaced by the actual type names used when the template is -instantiated. Template mapped types are instantiated automatically as required -(unlike template classes which are only instantiated using <tt class="docutils literal"><span class="pre">typedef</span></tt>).</p> -<p>Any explicit mapped type will be used in preference to any template that maps -the same type, ie. a template will not be automatically instantiated if there -is an explicit mapped type.</p> -<p><em>header-code</em> is the <a class="reference" href="#typeheadercode">%TypeHeaderCode</a> used to specify the library interface -to the type being mapped.</p> -<p><em>convert-to-code</em> is the <a class="reference" href="#converttotypecode">%ConvertToTypeCode</a> used to specify the handwritten -code that converts a Python object to an instance of the mapped type.</p> -<p><em>convert-from-code</em> is the <a class="reference" href="#convertfromtypecode">%ConvertFromTypeCode</a> used to specify the -handwritten code that converts an instance of the mapped type to a Python -object.</p> -<p>For example:</p> -<pre class="literal-block"> -template<Type *> -%MappedType QList -{ -%TypeHeaderCode -// Include the library interface to the type being mapped. -#include <tqlist.h> -%End - -%ConvertToTypeCode - // See if we are just being asked to check the type of the Python - // object. - if (sipIsErr == NULL) - { - // Check it is a list. - if (!PyList_Check(sipPy)) - return 0; - - // Now check each element of the list is of the type we expect. - // The template is for a pointer type so we don't disallow None. - for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) - if (!sipCanConvertToInstance(PyList_GET_ITEM(sipPy, i), - sipClass_Type, 0)) - return 0; - - return 1; - } - - // Create the instance on the heap. - QList<Type *> *ql = new QList<Type *>; - - for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) - { - // Use the SIP API to convert the Python object to the - // corresponding C++ instance. Note that we apply any ownership - // transfer to the list itself, not the individual elements. - Type *t = reinterpret_cast<Type *>(sipConvertToInstance( - PyList_GET_ITEM(sipPy, i), - sipClass_Type, 0, 0, 0, - sipIsErr)); - - if (*sipIsErr) - { - // Tidy up. - delete ql; - - // There is nothing on the heap. - return 0; - } - - // Add the pointer to the C++ instance. - ql -> append(t); - } - - // Return the instance on the heap. - *sipCppPtr = ql; - - // Apply the normal transfer. - return sipGetState(sipTransferObj); -%End - -%ConvertFromTypeCode - PyObject *l; - - // Create the Python list of the correct length. - if ((l = PyList_New(sipCpp -> size())) == NULL) - return NULL; - - // Go through each element in the C++ instance and convert it to the - // corresponding Python object. - for (int i = 0; i < sipCpp -> size(); ++i) - { - Type *t = sipCpp -> at(i); - PyObject *tobj; - - if ((tobj = sipConvertFromInstance(t, sipClass_Type, sipTransferObj)) == NULL) - { - // There was an error so garbage collect the Python list. - Py_DECREF(l); - return NULL; - } - - PyList_SET_ITEM(l, i, tobj); - } - - // Return the Python list. - return l; -%End -} -</pre> -<p>Using this we can use, for example, <tt class="docutils literal"><span class="pre">QList<TQObject</span> <span class="pre">*></span></tt> throughout the -module's specification files (and in any module that imports this one). The -generated code will automatically map this to and from a Python list of QObject -instances when appropriate.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id87" id="methodcode" name="methodcode">7.25 %MethodCode</a></h2> -<pre class="literal-block"> -%MethodCode - <em>code</em> -%End -</pre> -<p>This directive is used as part of the specification of a global function, class -method, operator, constructor or destructor to specify handwritten code that -replaces the normally generated call to the function being wrapped. It is -usually used to handle argument types and results that SIP cannot deal with -automatically.</p> -<p>The specified code is embedded in-line after the function's arguments have -been successfully converted from Python objects to their C or C++ equivalents. -The specified code must not include any <tt class="docutils literal"><span class="pre">return</span></tt> statements.</p> -<p>In the context of a destructor the specified code is embedded in-line in the -Python type's deallocation function. Unlike other contexts it supplements -rather than replaces the normally generated code, so it must not include code -to return the C structure or C++ class instance to the heap. The code is only -called if ownership of the structure or class is with Python.</p> -<p>The specified code must also handle the Python Global Interpreter Lock (GIL). -If compatibility with SIP v3.x is required then the GIL must be released -immediately before the C++ call and reacquired immediately afterwards as shown -in this example fragment:</p> -<pre class="literal-block"> -Py_BEGIN_ALLOW_THREADS -sipCpp -> foo(); -Py_END_ALLOW_THREADS -</pre> -<p>If compatibility with SIP v3.x is not required then this is optional but -should be done if the C++ function might block the current thread or take a -significant amount of time to execute. (See <a class="reference" href="#the-python-global-interpreter-lock">The Python Global Interpreter -Lock</a> and the <a class="reference" href="#releasegil">ReleaseGIL</a> and <a class="reference" href="#holdgil">HoldGIL</a> annotations.)</p> -<p>The following variables are made available to the handwritten code:</p> -<dl class="docutils"> -<dt><em>type</em> a0</dt> -<dd><p class="first">There is a variable for each argument of the Python signature (excluding -any <tt class="docutils literal"><span class="pre">self</span></tt> argument) named <tt class="docutils literal"><span class="pre">a0</span></tt>, <tt class="docutils literal"><span class="pre">a1</span></tt>, etc. The <em>type</em> of the -variable is the same as the type defined in the specification with the -following exceptions:</p> -<ul class="simple"> -<li>if the argument is only used to return a value (e.g. it is an <tt class="docutils literal"><span class="pre">int</span> <span class="pre">*</span></tt> -without an <a class="reference" href="#in">In</a> annotation) then the type has one less level of -indirection (e.g. it will be an <tt class="docutils literal"><span class="pre">int</span></tt>)</li> -<li>if the argument is a structure or class (or a reference or a pointer to a -structure or class) then <em>type</em> will always be a pointer to the structure -or class.</li> -</ul> -<p class="last">Note that handwritten code for destructors never has any arguments.</p> -</dd> -<dt>PyObject *a0Wrapper</dt> -<dd>This variable is made available only if the corresponding argument wraps a -C structure or C++ class instance and the <a class="reference" href="#getwrapper">GetWrapper</a> annotation is -specified. The variable is a pointer to the Python object that wraps the -argument.</dd> -<dt><em>type</em> *sipCpp</dt> -<dd>If the directive is used in the context of a class constructor then this -must be set by the handwritten code to the constructed instance. In any -other context then this is a pointer to the C structure or C++ class -instance. Its <em>type</em> is a pointer to the structure or class.</dd> -<dt>int sipIsErr</dt> -<dd><p class="first">The handwritten code should set this to a non-zero value, and raise an -appropriate Python exception, if an error is detected.</p> -<p class="last"><tt class="docutils literal"><span class="pre">sipIsErr</span></tt> is not provided for destructors.</p> -</dd> -<dt><em>type</em> sipRes</dt> -<dd><p class="first">The handwritten code should set this to the result to be returned. The -<em>type</em> of the variable is the same as the type defined in the Python -signature in the specification with the following exception:</p> -<ul class="simple"> -<li>if the argument is a structure or class (or a reference or a pointer to a -structure or class) then <em>type</em> will always be a pointer to the structure -or class.</li> -</ul> -<p class="last"><tt class="docutils literal"><span class="pre">sipRes</span></tt> is not provided for inplace operators (e.g. <tt class="docutils literal"><span class="pre">+=</span></tt> or -<tt class="docutils literal"><span class="pre">__imul__</span></tt>) as their results are handled automatically, nor for class -constructors.</p> -</dd> -<dt>PyObject *sipSelf</dt> -<dd>If the directive is used in the context of a class constructor or method -then this is the Python object that wraps the the structure or class -instance, i.e. <tt class="docutils literal"><span class="pre">self</span></tt>.</dd> -<dt>bool sipSelfWasArg</dt> -<dd><p class="first">This is only made available for non-abstract, virtual methods. It is set -if <tt class="docutils literal"><span class="pre">self</span></tt> was explicitly passed as the first argument of the method -rather than being bound to the method. In other words, the call was:</p> -<pre class="literal-block"> -Klass.foo(self, ...) -</pre> -<p>rather than:</p> -<pre class="last literal-block"> -self.foo(...) -</pre> -</dd> -</dl> -<p>The following is a complete example:</p> -<pre class="literal-block"> -class Klass -{ -public: - virtual int foo(SIP_PYTUPLE); -%MethodCode - // The C++ API takes a 2 element array of integers but passing a - // two element tuple is more Pythonic. - - int iarr[2]; - - if (PyArg_ParseTuple(a0, "ii", &iarr[0], &iarr[1])) - { - Py_BEGIN_ALLOW_THREADS - sipRes = sipSelfWasArg ? sipCpp -> Klass::foo(iarr) - : sipCpp -> foo(iarr); - Py_END_ALLOW_THREADS - } - else - { - // PyArg_ParseTuple() will have raised the exception. - sipIsErr = 1; - } -%End -}; -</pre> -<p>As the example is a virtual method <a class="footnote-reference" href="#id16" id="id15" name="id15">[7]</a>, note the use of <tt class="docutils literal"><span class="pre">sipSelfWasArg</span></tt> to -determine exactly which implementation of <tt class="docutils literal"><span class="pre">foo()</span></tt> to call.</p> -<p>If a method is in the <tt class="docutils literal"><span class="pre">protected</span></tt> section of a C++ class then the call -should instead be:</p> -<pre class="literal-block"> -sipRes = sipCpp -> sipProtectVirt_foo(sipSelfWasArg, iarr); -</pre> -<p>If a method is in the <tt class="docutils literal"><span class="pre">protected</span></tt> section of a C++ class but is not virtual -then the call should instead be:</p> -<pre class="literal-block"> -sipRes = sipCpp -> sipProtect_foo(iarr); -</pre> -<table class="docutils footnote" frame="void" id="id16" rules="none"> -<colgroup><col class="label" /><col /></colgroup> -<tbody valign="top"> -<tr><td class="label"><a class="fn-backref" href="#id15" name="id16">[7]</a></td><td>See <a class="reference" href="#virtualcatchercode">%VirtualCatcherCode</a> for a description of how SIP generated code -handles the reimplementation of C++ virtual methods in Python.</td></tr> -</tbody> -</table> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id88" id="module" name="module">7.26 %Module</a></h2> -<pre class="literal-block"> -%Module <em>name</em> [<em>version</em>] -</pre> -<p>This directive is used to identify that the library being wrapped is a C++ -library and to define the name of the module and it's optional version number.</p> -<p>The name may contain periods to specify that the module is part of a Python -package.</p> -<p>The optional version number is useful if you (or others) might create other -modules that build on this module, i.e. if another module might <a class="reference" href="#import">%Import</a> -this module. Under the covers, a module exports an API that is used by modules -that <a class="reference" href="#import">%Import</a> it and the API is given a version number. A module built on -that module knows the version number of the API that it is expecting. If, -when the modules are imported at run-time, the version numbers do not match -then a Python exception is raised. The dependent module must then be re-built -using the correct specification files for the base module.</p> -<p>The version number should be incremented whenever a module is changed. Some -changes don't affect the exported API, but it is good practice to change the -version number anyway.</p> -<p>For example:</p> -<pre class="literal-block"> -%Module qt 5 -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id89" id="modulecode" name="modulecode">7.27 %ModuleCode</a></h2> -<pre class="literal-block"> -%ModuleCode - <em>code</em> -%End -</pre> -<p>This directive is used to specify handwritten code, typically the -implementations of utility functions, that can be called by other handwritten -code in the module.</p> -<p>For example:</p> -<pre class="literal-block"> -%ModuleCode -// Print an object on stderr for debugging purposes. -void dump_object(PyObject *o) -{ - PyObject_Print(o, stderr, 0); - fprintf(stderr, "\n"); -} -%End -</pre> -<p>See also <a class="reference" href="#exportedheadercode">%ExportedHeaderCode</a> and <a class="reference" href="#moduleheadercode">%ModuleHeaderCode</a>.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id90" id="moduleheadercode" name="moduleheadercode">7.28 %ModuleHeaderCode</a></h2> -<pre class="literal-block"> -%ModuleHeaderCode - <em>code</em> -%End -</pre> -<p>This directive is used to specify handwritten code, typically the declarations -of utility functions, that is placed in a header file that is included by all -generated code for the same module.</p> -<p>For example:</p> -<pre class="literal-block"> -%ModuleHeaderCode -void dump_object(PyObject *o); -%End -</pre> -<p>See also <a class="reference" href="#exportedheadercode">%ExportedHeaderCode</a> and <a class="reference" href="#modulecode">%ModuleCode</a>.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id91" id="optionalinclude" name="optionalinclude">7.29 %OptionalInclude</a></h2> -<pre class="literal-block"> -%OptionalInclude <em>filename</em> -</pre> -<p>This directive is identical to the <a class="reference" href="#include">%Include</a> directive except that SIP -silently continues processing if <em>filename</em> could not be opened.</p> -<p>For example:</p> -<pre class="literal-block"> -%OptionalInclude license.sip -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id92" id="platforms" name="platforms">7.30 %Platforms</a></h2> -<pre class="literal-block"> -%Platforms {<em>name</em> <em>name</em> ...} -</pre> -<p>This directive is used to declare a set of platforms. Platforms (along with -<a class="reference" href="#feature">%Feature</a> and <a class="reference" href="#timeline">%Timeline</a>) are used by the <a class="reference" href="#if">%If</a> directive to control -whether or not parts of a specification are processed or ignored.</p> -<p>Platforms are mutually exclusive - only one platform can be enabled at a time. -By default all platforms are disabled. The SIP <tt class="docutils literal"><span class="pre">-t</span></tt> command line option is -used to enable a platform.</p> -<p>For example:</p> -<pre class="literal-block"> -%Platforms {WIN32_PLATFORM POSIX_PLATFORM MACOS_PLATFORM} - -%If (WIN32_PLATFORM) -void undocumented(); -%End - -%If (POSIX_PLATFORM) -void documented(); -%End -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id93" id="postinitialisationcode" name="postinitialisationcode">7.31 %PostInitialisationCode</a></h2> -<pre class="literal-block"> -%PostInitialisationCode - <em>code</em> -%End -</pre> -<p>This directive is used to specify handwritten code that is embedded in-line -at the very end of the generated module initialisation code.</p> -<p>The following variables are made available to the handwritten code:</p> -<dl class="docutils"> -<dt>PyObject *sipModule</dt> -<dd>This is the module object returned by <tt class="docutils literal"><span class="pre">Py_InitModule()</span></tt>.</dd> -<dt>PyObject *sipModuleDict</dt> -<dd>This is the module's dictionary object returned by <tt class="docutils literal"><span class="pre">Py_ModuleGetDict()</span></tt>.</dd> -</dl> -<p>For example:</p> -<pre class="literal-block"> -%PostInitialisationCode - // The code will be executed when the module is first imported and - // after all other initialisation has been completed. -%End -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id94" id="preinitialisationcode" name="preinitialisationcode">7.32 %PreInitialisationCode</a></h2> -<pre class="literal-block"> -%PreInitialisationCode - <em>code</em> -%End -</pre> -<p>This directive is used to specify handwritten code that is embedded in-line -at the very start of the generated module initialisation code.</p> -<p>For example:</p> -<pre class="literal-block"> -%PreInitialisationCode - // The code will be executed when the module is first imported and - // before other initialisation has been completed. -%End -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id95" id="raisecode" name="raisecode">7.33 %RaiseCode</a></h2> -<pre class="literal-block"> -%RaiseCode - <em>code</em> -%End -</pre> -<p>This directive is used as part of the definition of an exception using the -<a class="reference" href="#exception">%Exception</a> directive to specify handwritten code that raises a Python -exception when a C++ exception has been caught. The code is embedded in-line -as the body of a C++ <tt class="docutils literal"><span class="pre">catch</span> <span class="pre">()</span></tt> clause.</p> -<p>The specified code must handle the Python Global Interpreter Lock (GIL) if -necessary. The GIL must be acquired before any calls to the Python API and -released after the last call as shown in this example fragment:</p> -<pre class="literal-block"> -SIP_BLOCK_THREADS -PyErr_SetNone(PyErr_Exception); -SIP_UNBLOCK_THREADS -</pre> -<p>Finally, the specified code must not include any <tt class="docutils literal"><span class="pre">return</span></tt> statements.</p> -<p>The following variable is made available to the handwritten code:</p> -<dl class="docutils"> -<dt><em>type</em> &sipExceptionRef</dt> -<dd>This is a reference to the caught C++ exception. The <em>type</em> of the -reference is the same as the type defined in the <tt class="docutils literal"><span class="pre">throw</span> <span class="pre">()</span></tt> specifier.</dd> -</dl> -<p>See the <a class="reference" href="#exception">%Exception</a> directive for an example.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id96" id="setcode" name="setcode">7.34 %SetCode</a></h2> -<pre class="literal-block"> -%SetCode - <em>code</em> -%End -</pre> -<p>This directive is used after the declaration of a C++ class variable or C -structure member to specify handwritten code to convert it from a Python -object. It is usually used to handle types that SIP cannot deal with -automatically.</p> -<p>The following variables are made available to the handwritten code:</p> -<dl class="docutils"> -<dt><em>type</em> *sipCpp</dt> -<dd>This is a pointer to the structure or class instance. Its <em>type</em> is a -pointer to the structure or class. It is not made available if the -variable being wrapped is a static class variable.</dd> -<dt>int sipErr</dt> -<dd>If the conversion failed then the handwritten code should raise a Python -exception and set this to a non-zero value. Its initial value will be -automatically set to zero.</dd> -<dt>PyObject *sipPy</dt> -<dd>This is the Python object that the handwritten code should convert.</dd> -</dl> -<p>See the <a class="reference" href="#getcode">%GetCode</a> directive for an example.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id97" id="sipoptions" name="sipoptions">7.35 %SIPOptions</a></h2> -<p>This directive sets one or more options that controls different aspects of -SIP's behaviour. In this version all the available options are provided -specifically to support PyQt and so are not documented.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id98" id="timeline" name="timeline">7.36 %Timeline</a></h2> -<pre class="literal-block"> -%Timeline {<em>name</em> <em>name</em> ...} -</pre> -<p>This directive is used to declare a set of versions released over a period of -time. Versions (along with <a class="reference" href="#feature">%Feature</a> and <a class="reference" href="#platforms">%Platforms</a>) are used by the -<a class="reference" href="#if">%If</a> directive to control whether or not parts of a specification are -processed or ignored.</p> -<p>Versions are mutually exclusive - only one version can be enabled at a time. -By default all versions are disabled. The SIP <tt class="docutils literal"><span class="pre">-t</span></tt> command line option is -used to enable a version.</p> -<p>For example:</p> -<pre class="literal-block"> -%Timeline {V1_0 V1_1 V2_0 V3_0} - -%If (V1_0 - V2_0) -void foo(); -%End - -%If (V2_0 -) -void foo(int = 0); -%End -</pre> -<p><a class="reference" href="#timeline">%Timeline</a> can be used any number of times in a module to allow multiple -libraries to be wrapped in the same module.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id99" id="typecode" name="typecode">7.37 %TypeCode</a></h2> -<pre class="literal-block"> -%TypeCode - <em>code</em> -%End -</pre> -<p>This directive is used as part of the specification of a C structure or a C++ -class to specify handwritten code, typically the implementations of utility -functions, that can be called by other handwritten code in the structure or -class.</p> -<p>For example:</p> -<pre class="literal-block"> -class Klass -{ -%TypeCode -// Print an instance on stderr for debugging purposes. -static void dump_klass(const Klass *k) -{ - fprintf(stderr,"Klass %s at %p\n", k -> name(), k); -} -%End - - // The rest of the class specification. - -}; -</pre> -<p>Because the scope of the code is normally within the generated file that -implements the type, any utility functions would normally be declared -<tt class="docutils literal"><span class="pre">static</span></tt>. However a naming convention should still be adopted to prevent -clashes of function names within a module in case the SIP <tt class="docutils literal"><span class="pre">-j</span></tt> command line -option is used.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id100" id="typeheadercode" name="typeheadercode">7.38 %TypeHeaderCode</a></h2> -<pre class="literal-block"> -%TypeHeaderCode - <em>code</em> -%End -</pre> -<p>This directive is used to specify handwritten code that defines the interface -to a C or C++ type being wrapped, either a structure, a class, or a template. -It is used within a class definition or a <a class="reference" href="#mappedtype">%MappedType</a> directive.</p> -<p>Normally <em>code</em> will be a pre-processor <tt class="docutils literal"><span class="pre">#include</span></tt> statement.</p> -<p>For example:</p> -<pre class="literal-block"> -// Wrap the Klass class. -class Klass -{ -%TypeHeaderCode -#include <klass.h> -%End - - // The rest of the class specification. -}; -</pre> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id101" id="unitcode" name="unitcode">7.39 %UnitCode</a></h2> -<pre class="literal-block"> -%UnitCode - <em>code</em> -%End -</pre> -<p>This directive is used to specify handwritten code that it included at the very -start of a generated compilation unit (ie. C or C++ source file). It is -typically used to <tt class="docutils literal"><span class="pre">#include</span></tt> a C++ precompiled header file.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id102" id="virtualcatchercode" name="virtualcatchercode">7.40 %VirtualCatcherCode</a></h2> -<pre class="literal-block"> -%VirtualCatcherCode - <em>code</em> -%End -</pre> -<p>For most classes there are corresponding <a class="reference" href="#generated-derived-classes">generated derived classes</a> that -contain reimplementations of the class's virtual methods. These methods (which -SIP calls catchers) determine if there is a corresponding Python -reimplementation and call it if so. If there is no Python reimplementation -then the method in the original class is called instead.</p> -<p>This directive is used to specify handwritten code that replaces the normally -generated call to the Python reimplementation and the handling of any returned -results. It is usually used to handle argument types and results that SIP -cannot deal with automatically.</p> -<p>This directive can also be used in the context of a class destructor to -specify handwritten code that is embedded in-line in the internal derived -class's destructor.</p> -<p>In the context of a method the Python Global Interpreter Lock (GIL) is -automatically acquired before the specified code is executed and automatically -released afterwards.</p> -<p>In the context of a destructor the specified code must handle the GIL. The -GIL must be acquired before any calls to the Python API and released after the -last call as shown in this example fragment:</p> -<pre class="literal-block"> -SIP_BLOCK_THREADS -Py_DECREF(obj); -SIP_UNBLOCK_THREADS -</pre> -<p>The following variables are made available to the handwritten code in the -context of a method:</p> -<dl class="docutils"> -<dt><em>type</em> a0</dt> -<dd>There is a variable for each argument of the C++ signature named <tt class="docutils literal"><span class="pre">a0</span></tt>, -<tt class="docutils literal"><span class="pre">a1</span></tt>, etc. The <em>type</em> of the variable is the same as the type defined in -the specification.</dd> -<dt>int sipIsErr</dt> -<dd>The handwritten code should set this to a non-zero value, and raise an -appropriate Python exception, if an error is detected.</dd> -<dt>PyObject *sipMethod</dt> -<dd>This object is the Python reimplementation of the virtual C++ method. It -is normally passed to <a class="reference" href="#sipcallmethod">sipCallMethod()</a>.</dd> -<dt><em>type</em> sipRes</dt> -<dd>The handwritten code should set this to the result to be returned. The -<em>type</em> of the variable is the same as the type defined in the C++ signature -in the specification.</dd> -</dl> -<p>No variables are made available in the context of a destructor.</p> -<p>For example:</p> -<pre class="literal-block"> -class Klass -{ -public: - virtual int foo(SIP_PYTUPLE) [int (int *)]; -%MethodCode - // The C++ API takes a 2 element array of integers but passing a - // two element tuple is more Pythonic. - - int iarr[2]; - - if (PyArg_ParseTuple(a0, "ii", &iarr[0], &iarr[1])) - { - Py_BEGIN_ALLOW_THREADS - sipRes = sipCpp -> Klass::foo(iarr); - Py_END_ALLOW_THREADS - } - else - { - // PyArg_ParseTuple() will have raised the exception. - sipIsErr = 1; - } -%End -%VirtualCatcherCode - // Convert the 2 element array of integers to the two element - // tuple. - - PyObject *result; - - result = sipCallMethod(&sipIsErr, sipMethod, "ii", a0[0], a0[1]); - - if (result != NULL) - { - // Convert the result to the C++ type. - sipParseResult(&sipIsErr, sipMethod, result, "i", &sipRes); - - Py_DECREF(result); - } -%End -}; -</pre> -</div> -</div> -<div class="section"> -<h1><a class="toc-backref" href="#id103" id="sip-annotations" name="sip-annotations">8 SIP Annotations</a></h1> -<p>In this section we describe each of the annotations that can be used in -specification files.</p> -<p>Annotations can either be argument annotations, class annotations, enum -annotations, exception annotations, function annotations, license annotations, -or variable annotations depending on the context in which they can be used.</p> -<p>Annotations are placed between forward slashes (<tt class="docutils literal"><span class="pre">/</span></tt>). Multiple annotations -are comma separated within the slashes.</p> -<p>Annotations have a type and, possibly, a value. The type determines the -format of the value. The name of an annotation and its value are separated by -<tt class="docutils literal"><span class="pre">=</span></tt>.</p> -<p>Annotations can have one of the following types:</p> -<dl class="docutils"> -<dt>boolean</dt> -<dd>This type of annotation has no value and is implicitly true.</dd> -<dt>name</dt> -<dd>The value is a name that is compatible with a C/C++ identifier. In some -cases the value is optional.</dd> -<dt>string</dt> -<dd>The value is a double quoted string.</dd> -</dl> -<p>The following example shows argument and function annotations:</p> -<pre class="literal-block"> -void exec(TQWidget * /Transfer/) /ReleaseGIL, PyName=call_exec/; -</pre> -<p>Note that the current version of SIP does not complain about unknown -annotations, or annotations used out of their correct context.</p> -<div class="section"> -<h2><a class="toc-backref" href="#id104" id="argument-annotations" name="argument-annotations">8.1 Argument Annotations</a></h2> -<div class="section"> -<h3><a class="toc-backref" href="#id105" id="allownone" name="allownone">8.1.1 AllowNone</a></h3> -<p>This boolean annotation specifies that the value of the corresponding argument -(which should be either <a class="reference" href="#sip-pycallable">SIP_PYCALLABLE</a>, <a class="reference" href="#sip-pydict">SIP_PYDICT</a>, <a class="reference" href="#sip-pylist">SIP_PYLIST</a>, -<a class="reference" href="#sip-pyslice">SIP_PYSLICE</a>, <a class="reference" href="#sip-pytuple">SIP_PYTUPLE</a> or <a class="reference" href="#sip-pytype">SIP_PYTYPE</a>) may be <tt class="docutils literal"><span class="pre">None</span></tt>.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id106" id="array" name="array">8.1.2 Array</a></h3> -<p>This boolean annotation specifies that the corresponding argument (which -should be either <tt class="docutils literal"><span class="pre">char</span> <span class="pre">*</span></tt> or <tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">char</span> <span class="pre">*</span></tt>) refers to an array -rather than a <tt class="docutils literal"><span class="pre">'\0'</span></tt> terminated string. There must be a corresponding -argument with the <a class="reference" href="#arraysize">ArraySize</a> annotation specified. The annotation may only be -specified once in a list of arguments.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id107" id="arraysize" name="arraysize">8.1.3 ArraySize</a></h3> -<p>This boolean annotation specifies that the corresponding argument (which -should be either <tt class="docutils literal"><span class="pre">short</span></tt>, <tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">short</span></tt>, <tt class="docutils literal"><span class="pre">int</span></tt>, <tt class="docutils literal"><span class="pre">unsigned</span></tt>, -<tt class="docutils literal"><span class="pre">long</span></tt> or <tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">long</span></tt>) refers to the size of an array. There must be -a corresponding argument with the <a class="reference" href="#array">Array</a> annotation specified. The annotation -may only be specified once in a list of arguments.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id108" id="constrained" name="constrained">8.1.4 Constrained</a></h3> -<p>Python will automatically convert between certain compatible types. For -example, if a floating pointer number is expected and an integer supplied, -then the integer will be converted appropriately. This can cause problems -when wrapping C or C++ functions with similar signatures. For example:</p> -<pre class="literal-block"> -// The wrapper for this function will also accept an integer argument -// which Python will automatically convert to a floating point number. -void foo(double); - -// The wrapper for this function will never get used. -void foo(int); -</pre> -<p>This boolean annotation specifies that the corresponding argument (which -should be either <tt class="docutils literal"><span class="pre">bool</span></tt>, <tt class="docutils literal"><span class="pre">int</span></tt>, <tt class="docutils literal"><span class="pre">float</span></tt>, <tt class="docutils literal"><span class="pre">double</span></tt> or a wrapped class) -must match the type without any automatic conversions. In the context of a -wrapped class the invocation of any <a class="reference" href="#converttotypecode">%ConvertToTypeCode</a> is suppressed.</p> -<p>The following example gets around the above problem:</p> -<pre class="literal-block"> -// The wrapper for this function will only accept floating point numbers. -void foo(double /Constrained/); - -// The wrapper for this function will be used for anything that Python can -// convert to an integer, except for floating point numbers. -void foo(int); -</pre> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id109" id="getwrapper" name="getwrapper">8.1.5 GetWrapper</a></h3> -<p>This boolean annotation is only ever used in conjunction with handwritten code -specified with the <a class="reference" href="#methodcode">%MethodCode</a> directive. It causes an extra variable to -be generated for the corresponding argument (which should be a wrapped C -structure or C++ class instance) which is a pointer to the Python object that -wraps the argument.</p> -<p>See the <a class="reference" href="#methodcode">%MethodCode</a> directive for more detail.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id110" id="in" name="in">8.1.6 In</a></h3> -<p>This boolean annotation is used to specify that the corresponding argument -(which should be a pointer type) is used to pass a value to the function.</p> -<p>For pointers to wrapped C structures or C++ class instances, <tt class="docutils literal"><span class="pre">char</span> <span class="pre">*</span></tt> and -<tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">char</span> <span class="pre">*</span></tt> then this annotation is assumed unless the <a class="reference" href="#out">Out</a> annotation -is specified.</p> -<p>For pointers to other types then this annotation must be explicitly specified -if required. The argument will be dereferenced to obtain the actual value.</p> -<p>Both <a class="reference" href="#in">In</a> and <a class="reference" href="#out">Out</a> may be specified for the same argument.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id111" id="out" name="out">8.1.7 Out</a></h3> -<p>This boolean annotation is used to specify that the corresponding argument -(which should be a pointer type) is used by the function to return a value as -an element of a tuple.</p> -<p>For pointers to wrapped C structures or C++ class instances, <tt class="docutils literal"><span class="pre">char</span> <span class="pre">*</span></tt> and -<tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">char</span> <span class="pre">*</span></tt> then this annotation must be explicitly specified if -required.</p> -<p>For pointers to other types then this annotation is assumed unless the <a class="reference" href="#in">In</a> -annotation is specified.</p> -<p>Both <a class="reference" href="#in">In</a> and <a class="reference" href="#out">Out</a> may be specified for the same argument.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id112" id="transfer" name="transfer">8.1.8 Transfer</a></h3> -<p>This boolean annotation is used to specify that ownership of the corresponding -argument (which should be a wrapped C structure or C++ class instance) is -transferred from Python to C++. In addition, if the argument is of a class -method, then it is associated with the class instance with regard to the -cyclic garbage collector.</p> -<p>See <a class="reference" href="#ownership-of-objects">Ownership of Objects</a> for more detail.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id113" id="transferback" name="transferback">8.1.9 TransferBack</a></h3> -<p>This boolean annotation is used to specify that ownership of the corresponding -argument (which should be a wrapped C structure or C++ class instance) is -transferred back to Python from C++. In addition, any association of the -argument with regard to the cyclic garbage collector with another instance is -removed.</p> -<p>Note that this can also be used as a function annotation.</p> -<p>See <a class="reference" href="#ownership-of-objects">Ownership of Objects</a> for more detail.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id114" id="transferthis" name="transferthis">8.1.10 TransferThis</a></h3> -<p>This boolean annotation is only used in C++ constructors or methods. In the -context of a constructor or factory method it specifies that ownership of the -instance being created is transferred from Python to C++ if the corresponding -argument (which should be a wrapped C structure or C++ class instance) is not -<tt class="docutils literal"><span class="pre">None</span></tt>. In addition, the newly created instance is associated with the -argument with regard to the cyclic garbage collector.</p> -<p>In the context of a non-factory method it specifies that ownership of <tt class="docutils literal"><span class="pre">this</span></tt> -is transferred from Python to C++ if the corresponding argument is not -<tt class="docutils literal"><span class="pre">None</span></tt>. If it is <tt class="docutils literal"><span class="pre">None</span></tt> then ownership is transferred to Python.</p> -<p>The annotation may be used more that once, in which case ownership is -transferred to last instance that is not <tt class="docutils literal"><span class="pre">None</span></tt>.</p> -<p>See <a class="reference" href="#ownership-of-objects">Ownership of Objects</a> for more detail.</p> -</div> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id115" id="class-annotations" name="class-annotations">8.2 Class Annotations</a></h2> -<div class="section"> -<h3><a class="toc-backref" href="#id116" id="abstract" name="abstract">8.2.1 Abstract</a></h3> -<p>This boolean annotation is used to specify that the class has additional pure -virtual methods that have not been specified and so it cannot be instantiated -or sub-classed from Python.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id117" id="delaydtor" name="delaydtor">8.2.2 DelayDtor</a></h3> -<p>This boolean annotation is used to specify that the class's destructor should -not be called until the Python interpreter exits. It would normally only be -applied to singleton classes.</p> -<p>When the Python interpreter exits the order in which any wrapped instances are -garbage collected is unpredictable. However, the underlying C or C++ instances -may need to be destroyed in a certain order. If this annotation is specified -then when the wrapped instance is garbage collected the C or C++ instance is -not destroyed but instead added to a list of delayed instances. When the -interpreter exits then the function <tt class="docutils literal"><span class="pre">sipDelayedDtors</span></tt> is called with the -list of delayed instances. <tt class="docutils literal"><span class="pre">sipDelayedDtors</span></tt> can then choose to call (or -ignore) the destructors in any desired order.</p> -<p>The <tt class="docutils literal"><span class="pre">sipDelayedDtors</span></tt> function must be specified using the <a class="reference" href="#modulecode">%ModuleCode</a> -directive. It's signature is as follows:</p> -<pre class="literal-block"> -static void sipDelayedDtors(const sipDelayedDtor *dd_list); -</pre> -<p><tt class="docutils literal"><span class="pre">dd_list</span></tt> is the linked list of delayed instances. The following fields are -defined.</p> -<dl class="docutils"> -<dt>const char *dd_name</dt> -<dd>This is the name of the class excluding any package or module name.</dd> -<dt>void *dd_ptr</dt> -<dd>This is the address of the C or C++ instance to be destroyed. It's exact -type depends on the value of <tt class="docutils literal"><span class="pre">dd_isderived</span></tt>.</dd> -<dt>int dd_isderived</dt> -<dd>This is non-zero if the type of <tt class="docutils literal"><span class="pre">dd_ptr</span></tt> is actually the generated -derived class. This allows the correct destructor to be called. See -<a class="reference" href="#generated-derived-classes">Generated Derived Classes</a>.</dd> -<dt>sipDelayedDtor *dd_next</dt> -<dd>This is the address of the next entry in the list or zero if this is the -last one.</dd> -</dl> -<p>Note that the above applies only to C and C++ instances that are owned by -Python.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id118" id="external" name="external">8.2.3 External</a></h3> -<p>This boolean annotation is used to specify that the class is defined in another -module. Declarations of external classes are private to the module in which -they appear.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id119" id="nodefaultctors" name="nodefaultctors">8.2.4 NoDefaultCtors</a></h3> -<p>This boolean annotation is used to suppress the automatic generation of default -constructors for the class.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id120" id="pyname" name="pyname">8.2.5 PyName</a></h3> -<p>This name annotation specifies an alternative name for the class being wrapped -which is used when it is referred to from Python. It is required when a class -name is the same as a Python keyword. It may also be used to avoid name -clashes with other objects (e.g. enums, exceptions, functions) that have the -same name in the same C++ scope.</p> -</div> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id121" id="enum-annotations" name="enum-annotations">8.3 Enum Annotations</a></h2> -<div class="section"> -<h3><a class="toc-backref" href="#id122" id="id17" name="id17">8.3.1 PyName</a></h3> -<p>This name annotation specifies an alternative name for the enum or enum member -being wrapped which is used when it is referred to from Python. It is required -when an enum or enum member name is the same as a Python keyword. It may also -be used to avoid name clashes with other objects (e.g. classes, exceptions, -functions) that have the same name in the same C++ scope.</p> -</div> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id123" id="exception-annotations" name="exception-annotations">8.4 Exception Annotations</a></h2> -<div class="section"> -<h3><a class="toc-backref" href="#id124" id="id18" name="id18">8.4.1 PyName</a></h3> -<p>This name annotation specifies an alternative name for the exception being -defined which is used when it is referred to from Python. It is required when -an exception name is the same as a Python keyword. It may also be used to -avoid name clashes with other objects (e.g. classes, enums, functions) that -have the same name.</p> -</div> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id125" id="function-annotations" name="function-annotations">8.5 Function Annotations</a></h2> -<div class="section"> -<h3><a class="toc-backref" href="#id126" id="autogen" name="autogen">8.5.1 AutoGen</a></h3> -<p>This optional name annotation is used with class methods to specify that the -method be automatically included in all sub-classes. The value is the name of -a feature (specified using the <a class="reference" href="#feature">%Feature</a> directive) which must be enabled -for the method to be generated.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id127" id="default" name="default">8.5.2 Default</a></h3> -<p>This boolean annotation is only used with C++ constructors. Sometimes SIP -needs to create a class instance. By default it uses a constructor with no -compulsory arguments if one is specified. (SIP will automatically generate a -constructor with no arguments if no constructors are specified.) This -annotation is used to explicitly specify which constructor to use. Zero is -passed as the value of any arguments to the constructor.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id128" id="factory" name="factory">8.5.3 Factory</a></h3> -<p>This boolean annotation specifies that the value returned by the function -(which should be a wrapped C structure or C++ class instance) is a newly -created instance and is owned by Python.</p> -<p>See <a class="reference" href="#ownership-of-objects">Ownership of Objects</a> for more detail.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id129" id="holdgil" name="holdgil">8.5.4 HoldGIL</a></h3> -<p>This boolean annotation specifies that the Python Global Interpreter Lock (GIL) -is not released before the call to the underlying C or C++ function. See -<a class="reference" href="#the-python-global-interpreter-lock">The Python Global Interpreter Lock</a> and the <a class="reference" href="#releasegil">ReleaseGIL</a> annotation.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id130" id="newthread" name="newthread">8.5.5 NewThread</a></h3> -<p>This boolean annotation specifies that the function will create a new thread.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id131" id="noderived" name="noderived">8.5.6 NoDerived</a></h3> -<p>This boolean annotation is only used with C++ constructors. In many cases SIP -generates a derived class for each class being wrapped (see <a class="reference" href="#generated-derived-classes">Generated Derived -Classes</a>). This derived class contains constructors with the same C++ -signatures as the class being wrapped. Sometimes you may want to define a -Python constructor that has no corresponding C++ constructor. This annotation -is used to suppress the generation of the constructor in the derived class.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id132" id="numeric" name="numeric">8.5.7 Numeric</a></h3> -<p>This boolean annotation specifies that the operator should be interpreted as a -numeric operator rather than a sequence operator. Python uses the <tt class="docutils literal"><span class="pre">+</span></tt> -operator for adding numbers and concatanating sequences, and the <tt class="docutils literal"><span class="pre">*</span></tt> operator -for multiplying numbers and repeating sequences. SIP tries to work out which -is meant by looking at other operators that have been defined for the type. -If it finds either <tt class="docutils literal"><span class="pre">-</span></tt>, <tt class="docutils literal"><span class="pre">-=</span></tt>, <tt class="docutils literal"><span class="pre">/</span></tt>, <tt class="docutils literal"><span class="pre">/=</span></tt>, <tt class="docutils literal"><span class="pre">%</span></tt> or <tt class="docutils literal"><span class="pre">%=</span></tt> defined then -it assumes that <tt class="docutils literal"><span class="pre">+</span></tt>, <tt class="docutils literal"><span class="pre">+=</span></tt>, <tt class="docutils literal"><span class="pre">*</span></tt> and <tt class="docutils literal"><span class="pre">*=</span></tt> should be numeric operators. -Otherwise, if it finds either <tt class="docutils literal"><span class="pre">[]</span></tt>, <tt class="docutils literal"><span class="pre">__getitem__()</span></tt>, <tt class="docutils literal"><span class="pre">__setitem__()</span></tt> or -<tt class="docutils literal"><span class="pre">__delitem__()</span></tt> defined then it assumes that they should be sequence -operators. This annotation is used to force SIP to treat the operator as -numeric.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id133" id="posthook" name="posthook">8.5.8 PostHook</a></h3> -<p>This name annotation is used to specify the name of a Python builtin that is -called immediately after the call to the underlying C or C++ function or any -handwritten code. The builtin is not called if an error occurred. It is -primarily used to integrate with debuggers.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id134" id="prehook" name="prehook">8.5.9 PreHook</a></h3> -<p>This name annotation is used to specify the name of a Python builtin that is -called immediately after the function's arguments have been successfully -parsed and before the call to the underlying C or C++ function or any -handwritten code. It is primarily used to integrate with debuggers.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id135" id="id19" name="id19">8.5.10 PyName</a></h3> -<p>This name annotation specifies an alternative name for the function being -wrapped which is used when it is referred to from Python. It is required when -a function or method name is the same as a Python keyword. It may also be used -to avoid name clashes with other objects (e.g. classes, enums, exceptions) that -have the same name in the same C++ scope.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id136" id="releasegil" name="releasegil">8.5.11 ReleaseGIL</a></h3> -<p>This boolean annotation specifies that the Python Global Interpreter Lock (GIL) -is released before the call to the underlying C or C++ function and reacquired -afterwards. It should be used for functions that might block or take a -significant amount of time to execute. See <a class="reference" href="#the-python-global-interpreter-lock">The Python Global Interpreter -Lock</a> and the <a class="reference" href="#holdgil">HoldGIL</a> annotation.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id137" id="id20" name="id20">8.5.12 TransferBack</a></h3> -<p>This boolean annotation specifies that ownership of the value returned by the -function (which should be a wrapped C structure or C++ class instance) is -transferred back to Python from C++. Normally returned values (unless they are -new references to already wrapped values) are owned by C++. In addition, any -association of the returned value with regard to the cyclic garbage collector -with another instance is removed.</p> -<p>Note that this can also be used as an argument annotation.</p> -<p>See <a class="reference" href="#ownership-of-objects">Ownership of Objects</a> for more detail.</p> -</div> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id138" id="license-annotations" name="license-annotations">8.6 License Annotations</a></h2> -<div class="section"> -<h3><a class="toc-backref" href="#id139" id="licensee" name="licensee">8.6.1 Licensee</a></h3> -<p>This optional string annotation specifies the license's licensee. No -restrictions are placed on the contents of the string.</p> -<p>See the <a class="reference" href="#id14">%License</a> directive.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id140" id="signature" name="signature">8.6.2 Signature</a></h3> -<p>This optional string annotation specifies the license's signature. No -restrictions are placed on the contents of the string.</p> -<p>See the <a class="reference" href="#id14">%License</a> directive.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id141" id="timestamp" name="timestamp">8.6.3 Timestamp</a></h3> -<p>This optional string annotation specifies the license's timestamp. No -restrictions are placed on the contents of the string.</p> -<p>See the <a class="reference" href="#id14">%License</a> directive.</p> -</div> -<div class="section"> -<h3><a class="toc-backref" href="#id142" id="type" name="type">8.6.4 Type</a></h3> -<p>This string annotation specifies the license's type. No restrictions are -placed on the contents of the string.</p> -<p>See the <a class="reference" href="#id14">%License</a> directive.</p> -</div> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id143" id="variable-annotations" name="variable-annotations">8.7 Variable Annotations</a></h2> -<div class="section"> -<h3><a class="toc-backref" href="#id144" id="id21" name="id21">8.7.1 PyName</a></h3> -<p>This name annotation specifies an alternative name for the variable being -wrapped which is used when it is referred to from Python. It is required when -a variable name is the same as a Python keyword. It may also be used to avoid -name clashes with other objects (e.g. classes, functions) that have the same -name in the same C++ scope.</p> -</div> -</div> -</div> -<div class="section"> -<h1><a class="toc-backref" href="#id145" id="sip-api-for-handwritten-code" name="sip-api-for-handwritten-code">9 SIP API for Handwritten Code</a></h1> -<p>In this section we describe the API that can be used by handwritten code in -specification files.</p> -<div class="section"> -<h2><a class="toc-backref" href="#id146" id="sip-api-major-nr" name="sip-api-major-nr">9.1 SIP_API_MAJOR_NR</a></h2> -<p>This is a C preprocessor symbol that defines the major number of the SIP API. -Its value is a number. There is no direct relationship between this and the -SIP version number.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id147" id="sip-api-minor-nr" name="sip-api-minor-nr">9.2 SIP_API_MINOR_NR</a></h2> -<p>This is a C preprocessor symbol that defines the minor number of the SIP API. -Its value is a number. There is no direct relationship between this and the -SIP version number.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id148" id="sip-block-threads" name="sip-block-threads">9.3 SIP_BLOCK_THREADS</a></h2> -<p>This is a C preprocessor macro that will make sure the Python Global -Interpreter Lock (GIL) is acquired. Python API calls must only be made when -the GIL has been acquired. There must be a corresponding -<a class="reference" href="#sip-unblock-threads">SIP_UNBLOCK_THREADS</a> at the same lexical scope.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id149" id="sip-ssize-t" name="sip-ssize-t">9.4 SIP_SSIZE_T</a></h2> -<p>This is a C preprocessor macro that is defined as <tt class="docutils literal"><span class="pre">Py_ssize_t</span></tt> for Python -v2.5 and later, and as <tt class="docutils literal"><span class="pre">int</span></tt> for earlier versions of Python. It makes it -easier to write PEP 353 compliant handwritten code.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id150" id="sip-unblock-threads" name="sip-unblock-threads">9.5 SIP_UNBLOCK_THREADS</a></h2> -<p>This is a C preprocessor macro that will restore the Python Global Interpreter -Lock (GIL) to the state it was prior to the corresponding <a class="reference" href="#sip-block-threads">SIP_BLOCK_THREADS</a>.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id151" id="sip-version" name="sip-version">9.6 SIP_VERSION</a></h2> -<p>This is a C preprocessor symbol that defines the SIP version number -represented as a 3 part hexadecimal number (e.g. v4.0.0 is represented as -<tt class="docutils literal"><span class="pre">0x040000</span></tt>).</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id152" id="sip-version-str" name="sip-version-str">9.7 SIP_VERSION_STR</a></h2> -<p>This is a C preprocessor symbol that defines the SIP version number -represented as a string. For development snapshots it will start with -<tt class="docutils literal"><span class="pre">snapshot-</span></tt>.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id153" id="sipbadcatcherresult" name="sipbadcatcherresult">9.8 sipBadCatcherResult()</a></h2> -<dl class="docutils"> -<dt>void sipBadCatcherResult(PyObject *method)</dt> -<dd>This raises a Python exception when the result of a Python reimplementation -of a C++ method doesn't have the expected type. It is normally called by -handwritten code specified with the <a class="reference" href="#virtualcatchercode">%VirtualCatcherCode</a> directive. -<em>method</em> is the Python method and would normally be the supplied -<tt class="docutils literal"><span class="pre">sipMethod</span></tt>.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id154" id="sipbadlengthforslice" name="sipbadlengthforslice">9.9 sipBadLengthForSlice()</a></h2> -<dl class="docutils"> -<dt>void sipBadLengthForSlice(SIP_SSIZE_T seqlen, SIP_SSIZE_T slicelen)</dt> -<dd>This raises a Python exception when the length of a slice object is -inappropriate for a sequence-like object. It is normally called by -handwritten code specified for <tt class="docutils literal"><span class="pre">__setitem__()</span></tt> methods. <em>seqlen</em> is the -length of the sequence. <em>slicelen</em> is the length of the slice. With -versions of Python prior to v2.5 the arguments have type <tt class="docutils literal"><span class="pre">int</span></tt>.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id155" id="sipbuildresult" name="sipbuildresult">9.10 sipBuildResult()</a></h2> -<dl class="docutils"> -<dt>PyObject *sipBuildResult(int *iserr, const char *format, ...)</dt> -<dd><p class="first">This creates a Python object based on a format string and associated -values in a similar way to the Python <tt class="docutils literal"><span class="pre">Py_BuildValue()</span></tt> function. If -there was an error then <tt class="docutils literal"><span class="pre">NULL</span></tt> is returned and a Python exception is -raised. If <em>iserr</em> is not <tt class="docutils literal"><span class="pre">NULL</span></tt> then the location it points to is set -to a non-zero value. <em>format</em> is the string of format characters.</p> -<p>If <em>format</em> begins and ends with parentheses then a tuple of objects is -created. If <em>format</em> contains more than one format character then -parentheses must be specified.</p> -<p>In the following description the first letter is the format character, the -entry in parentheses is the Python object type that the format character -will create, and the entry in brackets are the types of the C/C++ values -to be passed.</p> -<dl class="last docutils"> -<dt><tt class="docutils literal"><span class="pre">a</span></tt> (string) [char *, int]</dt> -<dd>Convert a C/C++ character array and its length to a Python string. If -the array is <tt class="docutils literal"><span class="pre">NULL</span></tt> then the length is ignored and the result is -<tt class="docutils literal"><span class="pre">Py_None</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">b</span></tt> (boolean) [int]</dt> -<dd>Convert a C/C++ <tt class="docutils literal"><span class="pre">int</span></tt> to a Python boolean.</dd> -<dt><tt class="docutils literal"><span class="pre">c</span></tt> (string) [char]</dt> -<dd>Convert a C/C++ <tt class="docutils literal"><span class="pre">char</span></tt> to a Python string.</dd> -<dt><tt class="docutils literal"><span class="pre">d</span></tt> (float) [double]</dt> -<dd>Convert a C/C++ <tt class="docutils literal"><span class="pre">double</span></tt> to a Python floating point number.</dd> -<dt><tt class="docutils literal"><span class="pre">e</span></tt> (integer) [enum]</dt> -<dd>Convert an anonymous C/C++ <tt class="docutils literal"><span class="pre">enum</span></tt> to a Python integer.</dd> -<dt><tt class="docutils literal"><span class="pre">f</span></tt> (float) [float]</dt> -<dd>Convert a C/C++ <tt class="docutils literal"><span class="pre">float</span></tt> to a Python floating point number.</dd> -<dt><tt class="docutils literal"><span class="pre">h</span></tt> (integer) [short]</dt> -<dd>Convert a C/C++ <tt class="docutils literal"><span class="pre">short</span></tt> to a Python integer.</dd> -<dt><tt class="docutils literal"><span class="pre">i</span></tt> (integer) [int]</dt> -<dd>Convert a C/C++ <tt class="docutils literal"><span class="pre">int</span></tt> to a Python integer.</dd> -<dt><tt class="docutils literal"><span class="pre">l</span></tt> (long) [long]</dt> -<dd>Convert a C/C++ <tt class="docutils literal"><span class="pre">long</span></tt> to a Python integer.</dd> -<dt><tt class="docutils literal"><span class="pre">m</span></tt> (long) [unsigned long]</dt> -<dd>Convert a C/C++ <tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">long</span></tt> to a Python long.</dd> -<dt><tt class="docutils literal"><span class="pre">n</span></tt> (long) [long long]</dt> -<dd>Convert a C/C++ <tt class="docutils literal"><span class="pre">long</span> <span class="pre">long</span></tt> to a Python long.</dd> -<dt><tt class="docutils literal"><span class="pre">o</span></tt> (long) [unsigned long long]</dt> -<dd>Convert a C/C++ <tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">long</span> <span class="pre">long</span></tt> to a Python long.</dd> -<dt><tt class="docutils literal"><span class="pre">s</span></tt> (string) [char *]</dt> -<dd>Convert a C/C++ <tt class="docutils literal"><span class="pre">'\0'</span></tt> terminated string to a Python string. If the -string pointer is <tt class="docutils literal"><span class="pre">NULL</span></tt> then the result is <tt class="docutils literal"><span class="pre">Py_None</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">t</span></tt> (long) [unsigned short]</dt> -<dd>Convert a C/C++ <tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">short</span></tt> to a Python long.</dd> -<dt><tt class="docutils literal"><span class="pre">u</span></tt> (long) [unsigned int]</dt> -<dd>Convert a C/C++ <tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">int</span></tt> to a Python long.</dd> -<dt><tt class="docutils literal"><span class="pre">w</span></tt> (unicode) [wchar_t]</dt> -<dd>Convert a C/C++ wide character to a Python unicode object.</dd> -<dt><tt class="docutils literal"><span class="pre">x</span></tt> (unicode) [wchar_t *]</dt> -<dd>Convert a C/C++ <tt class="docutils literal"><span class="pre">L'\0'</span></tt> terminated wide character string to a Python -unicode object. If the string pointer is <tt class="docutils literal"><span class="pre">NULL</span></tt> then the result is -<tt class="docutils literal"><span class="pre">Py_None</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">A</span></tt> (unicode) [wchar_t *, int]</dt> -<dd>Convert a C/C++ wide character array and its length to a Python unicode -object. If the array is <tt class="docutils literal"><span class="pre">NULL</span></tt> then the length is ignored and the -result is <tt class="docutils literal"><span class="pre">Py_None</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">B</span></tt> (wrapped instance) [<em>type</em> *, sipWrapperType *, PyObject *]</dt> -<dd>Convert a new C structure or a new C++ class instance to a Python class -instance object. Ownership of the structure or instance is determined -by the <tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt> argument. If it is <tt class="docutils literal"><span class="pre">NULL</span></tt> and the instance has -already been wrapped then the ownership is unchanged. If it is -<tt class="docutils literal"><span class="pre">NULL</span></tt> or <tt class="docutils literal"><span class="pre">Py_None</span></tt> then ownership will be with Python. Otherwise -ownership will be with C/C++ and the instance associated with the -<tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt> argument. The Python class is influenced by any -applicable <a class="reference" href="#converttosubclasscode">%ConvertToSubClassCode</a> code.</dd> -<dt><tt class="docutils literal"><span class="pre">C</span></tt> (wrapped instance) [<em>type</em> *, sipWrapperType *, PyObject *]</dt> -<dd>Convert a C structure or a C++ class instance to a Python class -instance object. If the structure or class instance has already been -wrapped then the result is a new reference to the existing class -instance object. Ownership of the structure or instance is determined -by the <tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt> argument. If it is <tt class="docutils literal"><span class="pre">NULL</span></tt> and the instance has -already been wrapped then the ownership is unchanged. If it is -<tt class="docutils literal"><span class="pre">NULL</span></tt> and the instance is newly wrapped then ownership will be with -C/C++. If it is <tt class="docutils literal"><span class="pre">Py_None</span></tt> then ownership is transferred to Python -via a call to <a class="reference" href="#siptransferback">sipTransferBack()</a>. Otherwise ownership is transferred -to C/C++ and the instance associated with the <tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt> argument -via a call to <a class="reference" href="#siptransferto">sipTransferTo()</a>. The Python class is influenced by -any applicable <a class="reference" href="#converttosubclasscode">%ConvertToSubClassCode</a> code.</dd> -<dt><tt class="docutils literal"><span class="pre">D</span></tt> (object) [<em>type</em> *, const sipMappedType *, PyObject *]</dt> -<dd>Convert a C structure or a C++ class instance wrapped as a mapped type -to a Python object. Ownership of the structure or instance is -determined by the <tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt> argument. If it is <tt class="docutils literal"><span class="pre">NULL</span></tt> then the -ownership is unchanged. If it is <tt class="docutils literal"><span class="pre">Py_None</span></tt> then ownership is -transferred to Python via a call to <a class="reference" href="#siptransferback">sipTransferBack()</a>. Otherwise -ownership is transferred to C/C++ and the instance associated with the -<tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt> argument via a call to <a class="reference" href="#siptransferto">sipTransferTo()</a>.</dd> -<dt><tt class="docutils literal"><span class="pre">E</span></tt> (wrapped enum) [enum, PyTypeObject *]</dt> -<dd>Convert a named C/C++ <tt class="docutils literal"><span class="pre">enum</span></tt> to an instance of the corresponding -Python named enum type.</dd> -<dt><tt class="docutils literal"><span class="pre">M</span></tt> (wrapped instance) [<em>type</em> *, sipWrapperType *]</dt> -<dd>Convert a C structure or a C++ class instance to a Python class -instance object. If the structure or class instance has already been -wrapped then the result is a new reference to the existing class -instance object. If the instance has already been wrapped then the -ownership is unchanged. If the instance is newly wrapped then -ownership will be with C/C++. The Python class is influenced by any -applicable <a class="reference" href="#converttosubclasscode">%ConvertToSubClassCode</a> code. This is deprecated from -SIP v4.4.</dd> -<dt><tt class="docutils literal"><span class="pre">N</span></tt> (wrapped instance) [<em>type</em> *, sipWrapperType *]</dt> -<dd>Convert a C structure or a C++ class instance to a Python class -instance object. This should not be used if the structure or class -instance might already have been wrapped. Ownership of the structure -or instance will be with Python. The Python class is influenced by -any applicable <a class="reference" href="#converttosubclasscode">%ConvertToSubClassCode</a> code. This is deprecated -from SIP v4.4.</dd> -<dt><tt class="docutils literal"><span class="pre">O</span></tt> (wrapped instance) [<em>type</em> *, sipWrapperType *]</dt> -<dd>Convert a C structure or a C++ class instance to a Python class -instance object. If the structure or class instance has already been -wrapped then the result is a new reference to the existing class -instance object. Ownership of the structure or instance will be with -C/C++. This is deprecated from SIP v4.4.</dd> -<dt><tt class="docutils literal"><span class="pre">P</span></tt> (wrapped instance) [<em>type</em> *, sipWrapperType *]</dt> -<dd>Convert a C structure or a C++ class instance to a Python class -instance object. This should not be used if the structure or class -instance might already have been wrapped. Ownership of the structure -or instance will be with Python. This is deprecated from SIP v4.4.</dd> -<dt><tt class="docutils literal"><span class="pre">R</span></tt> (object) [PyObject *]</dt> -<dd>The result is value passed without any conversions. The reference -count is unaffected, i.e. a reference is taken.</dd> -<dt><tt class="docutils literal"><span class="pre">S</span></tt> (object) [PyObject *]</dt> -<dd>The result is value passed without any conversions. The reference -count is incremented.</dd> -<dt><tt class="docutils literal"><span class="pre">T</span></tt> (object) [void *, PyObject *(*)(void *cppptr)]</dt> -<dd>Convert a C structure or a C++ class instance to a Python object using -a convertor function. See <a class="reference" href="#generated-type-convertors">Generated Type Convertors</a>. This is -deprecated from SIP v4.4.</dd> -<dt><tt class="docutils literal"><span class="pre">V</span></tt> (sip.voidptr) [void *]</dt> -<dd>Convert a C/C++ <tt class="docutils literal"><span class="pre">void</span> <span class="pre">*</span></tt> Python <tt class="docutils literal"><span class="pre">sip.voidptr</span></tt> object.</dd> -</dl> -</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id156" id="sipcallmethod" name="sipcallmethod">9.11 sipCallMethod()</a></h2> -<dl class="docutils"> -<dt>PyObject *sipCallMethod(int *iserr, PyObject *method, const char *format, ...)</dt> -<dd><p class="first">This calls a Python method passing a tuple of arguments based on a format -string and associated values in a similar way to the Python -<tt class="docutils literal"><span class="pre">PyObject_CallObject()</span></tt> function. If there was an error then <tt class="docutils literal"><span class="pre">NULL</span></tt> is -returned and a Python exception is raised. If <em>iserr</em> is not <tt class="docutils literal"><span class="pre">NULL</span></tt> -then the location it points to is set to a non-zero value. <em>method</em> is the -Python bound method to call. <em>format</em> is the string of format characters -(see <a class="reference" href="#sipbuildresult">sipBuildResult()</a>).</p> -<p class="last">This is normally called by handwritten code specified with the -<a class="reference" href="#virtualcatchercode">%VirtualCatcherCode</a> directive with <em>method</em> being the supplied -<tt class="docutils literal"><span class="pre">sipMethod</span></tt>.</p> -</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id157" id="sipcanconverttoinstance" name="sipcanconverttoinstance">9.12 sipCanConvertToInstance()</a></h2> -<dl class="docutils"> -<dt>int sipCanConvertToInstance(PyObject *obj, sipWrapperType *type, int flags)</dt> -<dd><p class="first">This returns a non-zero value if a Python object can be converted to an -instance of a C structure or C++ class. <em>obj</em> is the Python object. -<em>type</em> is the generated type corresponding to the C/C++ type being checked. -<em>flags</em> is any combination of the following values used to fine tune the -check.</p> -<blockquote class="last"> -<ul class="simple"> -<li><tt class="docutils literal"><span class="pre">SIP_NOT_NONE</span></tt> causes the check to fail if <em>obj</em> is <tt class="docutils literal"><span class="pre">None</span></tt>.</li> -<li><tt class="docutils literal"><span class="pre">SIP_NO_CONVERTORS</span></tt> suppresses the use of of any -<a class="reference" href="#converttotypecode">%ConvertToTypeCode</a> for <em>type</em>.</li> -</ul> -</blockquote> -</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id158" id="sipcanconverttomappedtype" name="sipcanconverttomappedtype">9.13 sipCanConvertToMappedType()</a></h2> -<dl class="docutils"> -<dt>int sipCanConvertToMappedType(PyObject *obj, const sipMappedType *mt, int flags)</dt> -<dd><p class="first">This returns a non-zero value if a Python object can be converted to an -instance of a C structure or C++ class which has been implemented as a -mapped type. <em>obj</em> is the Python object. <em>mt</em> is an opaque structure -returned by <a class="reference" href="#sipfindmappedtype">sipFindMappedType()</a>. <em>flags</em> is any combination of the -following values used to fine tune the check.</p> -<blockquote class="last"> -<ul class="simple"> -<li><tt class="docutils literal"><span class="pre">SIP_NOT_NONE</span></tt> causes the check to fail if <em>obj</em> is <tt class="docutils literal"><span class="pre">None</span></tt>.</li> -</ul> -</blockquote> -</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id159" id="sipclassname" name="sipclassname">9.14 sipClassName()</a></h2> -<dl class="docutils"> -<dt>PyObject *sipClassName(PyObject *obj)</dt> -<dd>This returns the class name of a wrapped instance as a Python string. It -comes with a reference.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id160" id="sipconnectrx" name="sipconnectrx">9.15 sipConnectRx()</a></h2> -<dl class="docutils"> -<dt>PyObject *sipConnectRx(PyObject *sender, const char *signal, PyObject *receiver, const char *slot, int type)</dt> -<dd>This connects a signal to a signal or slot and returns <tt class="docutils literal"><span class="pre">Py_True</span></tt> if the -signal was connected or <tt class="docutils literal"><span class="pre">Py_False</span></tt> if not. If there was some other -error then a Python exception is raised and <tt class="docutils literal"><span class="pre">NULL</span></tt> is returned. <em>sender</em> -is the wrapped <tt class="docutils literal"><span class="pre">TQObject</span></tt> derived instance that emits the signal. -<em>signal</em> is the typed name of the signal. <em>receiver</em> is the wrapped -<tt class="docutils literal"><span class="pre">TQObject</span></tt> derived instance or Python callable that the signal is -connected to. <em>slot</em> is the typed name of the slot, or <tt class="docutils literal"><span class="pre">NULL</span></tt> if -<em>receiver</em> is a Python callable. <em>type</em> is the type of connection and is -cast from Qt::ConnectionType. It is normally only used by PyQt to -implement <tt class="docutils literal"><span class="pre">TQObject.connect()</span></tt>.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id161" id="sipconvertfrominstance" name="sipconvertfrominstance">9.16 sipConvertFromInstance()</a></h2> -<dl class="docutils"> -<dt>PyObject *sipConvertFromInstance(void *cpp, sipWrapperType *type, PyObject *transferObj)</dt> -<dd>Convert a C structure or a C++ class instance to a Python class instance -object. <em>cpp</em> is the C/C++ instance. If the instance has already been -wrapped then the result is a new reference to the existing instance object. -<em>type</em> is the generated type corresponding to the C/C++ type. -<em>transferObj</em> controls the ownership of the returned value. If the -structure or class instance has already been wrapped then the result is a -new reference to the existing class instance object. If it is <tt class="docutils literal"><span class="pre">NULL</span></tt> and -the instance has already been wrapped then the ownership is unchanged. If -it is <tt class="docutils literal"><span class="pre">NULL</span></tt> and the instance is newly wrapped then ownership will be -with C/C++. If it is <tt class="docutils literal"><span class="pre">Py_None</span></tt> then ownership is transferred to Python -via a call to <a class="reference" href="#siptransferback">sipTransferBack()</a>. Otherwise ownership is transferred to -C/C++ and the instance associated with <em>transferObj</em> via a call to -<a class="reference" href="#siptransferto">sipTransferTo()</a>. The Python class is influenced by any applicable -<a class="reference" href="#converttosubclasscode">%ConvertToSubClassCode</a> code.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id162" id="sipconvertfrommappedtype" name="sipconvertfrommappedtype">9.17 sipConvertFromMappedType()</a></h2> -<dl class="docutils"> -<dt>PyObject *sipConvertFromMappedType(void *cpp, const sipMappedType *mt, PyObject *transferObj)</dt> -<dd>Convert a C structure or a C++ class instance wrapped as a mapped type to a -Python object. <em>cpp</em> is the C/C++ instance. <em>mt</em> is the opaque structure -returned by <a class="reference" href="#sipfindmappedtype">sipFindMappedType()</a>. <em>transferObj</em> controls any ownership -changes to <em>obj</em>. If it is <tt class="docutils literal"><span class="pre">NULL</span></tt> then the ownership is unchanged. If -it is <tt class="docutils literal"><span class="pre">Py_None</span></tt> then ownership is transferred to Python via a call to -<a class="reference" href="#siptransferback">sipTransferBack()</a>. Otherwise ownership is transferred to C/C++ and the -instance associated with the <tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt> argument via a call to -<a class="reference" href="#siptransferto">sipTransferTo()</a>.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id163" id="sipconvertfromnamedenum" name="sipconvertfromnamedenum">9.18 sipConvertFromNamedEnum()</a></h2> -<dl class="docutils"> -<dt>PyObject *sipConvertFromNamedEnum(int eval, PyTypeObject *type)</dt> -<dd>Convert a named C/C++ <tt class="docutils literal"><span class="pre">enum</span></tt> to an instance of the corresponding Python -named enum type. <em>eval</em> is the enumerated value to convert. <em>type</em> is the -generated Python type object (see <a class="reference" href="#generated-named-enum-type-objects">Generated Named Enum Type Objects</a>).</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id164" id="sipconvertfromnewinstance" name="sipconvertfromnewinstance">9.19 sipConvertFromNewInstance()</a></h2> -<dl class="docutils"> -<dt>PyObject *sipConvertFromNewInstance(void *cpp, sipWrapperType *type, PyObject *transferObj)</dt> -<dd>Convert a new C structure or a new C++ class instance to a Python class -instance object. <em>cpp</em> is the C/C++ instance. <em>type</em> is the generated -type corresponding to the C/C++ type. <em>transferObj</em> controls the ownership -of the returned value. If it is <tt class="docutils literal"><span class="pre">NULL</span></tt> or <tt class="docutils literal"><span class="pre">Py_None</span></tt> then ownership -will be with Python. Otherwise ownership will be with C/C++ and the -instance associated with <em>transferObj</em>. The Python class is influenced by -any applicable <a class="reference" href="#converttosubclasscode">%ConvertToSubClassCode</a> code.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id165" id="sipconvertfromsequenceindex" name="sipconvertfromsequenceindex">9.20 sipConvertFromSequenceIndex()</a></h2> -<dl class="docutils"> -<dt>SIP_SSIZE_T sipConvertFromSequenceIndex(SIP_SSIZE_T idx, SIP_SSIZE_T len)</dt> -<dd>This converts a Python sequence index (i.e. where a negative value refers -to the offset from the end of the sequence) to a C/C++ array index. If the -index was out of range then a negative value is returned and a Python -exception raised. With versions of Python prior to v2.5 the result and the -arguments have type <tt class="docutils literal"><span class="pre">int</span></tt>.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id166" id="sipconvertfromsliceobject" name="sipconvertfromsliceobject">9.21 sipConvertFromSliceObject()</a></h2> -<dl class="docutils"> -<dt>int sipConvertFromSliceObject(PyObject *slice, SIP_SSIZE_T length, SIP_SSIZE_T *start, SIP_SSIZE_T *stop, SIP_SSIZE_T *step, SIP_SSIZE_T *slicelength)</dt> -<dd>This is a thin wrapper around the Python <tt class="docutils literal"><span class="pre">PySlice_GetIndicesEx()</span></tt> -function provided to make it easier to write handwritten code that is -compatible with SIP v3.x and versions of Python earlier that v2.3.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id167" id="sipconverttocpp" name="sipconverttocpp">9.22 sipConvertToCpp()</a></h2> -<dl class="docutils"> -<dt>void *sipConvertToCpp(PyObject *obj, sipWrapperType *type, int *iserr)</dt> -<dd><p class="first">This function is deprecated from SIP v4.4. It is equivalent to:</p> -<pre class="last literal-block"> -sipConvertToInstance(obj, type, NULL, SIP_NO_CONVERTORS, NULL, iserr); -</pre> -</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id168" id="sipconverttoinstance" name="sipconverttoinstance">9.23 sipConvertToInstance()</a></h2> -<dl class="docutils"> -<dt>void *sipConvertToInstance(PyObject *obj, sipWrapperType *type, PyObject *transferObj, int flags, int *state, int *iserr)</dt> -<dd><p class="first">This converts a Python object to an instance of a C structure or C++ class -assuming that a previous call to <a class="reference" href="#sipcanconverttoinstance">sipCanConvertToInstance()</a> has been -successful. <em>obj</em> is the Python object. <em>type</em> is the generated type -corresponding to the C/C++ type returned. It may be any class in the -object's class hierarchy. <em>transferObj</em> controls any ownership changes to -<em>obj</em>. If it is <tt class="docutils literal"><span class="pre">NULL</span></tt> then the ownership is unchanged. If it is -<tt class="docutils literal"><span class="pre">Py_None</span></tt> then ownership is transferred to Python via a call to -<a class="reference" href="#siptransferback">sipTransferBack()</a>. Otherwise ownership is transferred to C/C++ and -<em>obj</em> associated with <em>transferObj</em> via a call to <a class="reference" href="#siptransferto">sipTransferTo()</a>. -<em>flags</em> is any combination of the following values used to fine tune the -check.</p> -<blockquote> -<ul class="simple"> -<li><tt class="docutils literal"><span class="pre">SIP_NOT_NONE</span></tt> causes the check to fail if <em>obj</em> is <tt class="docutils literal"><span class="pre">None</span></tt>.</li> -<li><tt class="docutils literal"><span class="pre">SIP_NO_CONVERTORS</span></tt> suppresses the use of of any -<a class="reference" href="#converttotypecode">%ConvertToTypeCode</a> for <em>type</em>.</li> -</ul> -</blockquote> -<p class="last">If <em>state</em> is not <tt class="docutils literal"><span class="pre">NULL</span></tt> then the location it points to is set to -describe the state of the returned C/C++ instance and is the value returned -by any <a class="reference" href="#converttotypecode">%ConvertToTypeCode</a>. The calling code must then release the value -at some point to prevent a memory leak by calling <a class="reference" href="#sipreleaseinstance">sipReleaseInstance()</a>. -If there is an error then the location <em>iserr</em> points to is set to a -non-zero value. If it was initially a non-zero value then the conversion -isn't attempted in the first place. (This allows several calls to be made -that share the same error flag so that it only needs to be tested once -rather than after each call.)</p> -</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id169" id="sipconverttomappedtype" name="sipconverttomappedtype">9.24 sipConvertToMappedType()</a></h2> -<dl class="docutils"> -<dt>void *sipConvertToMappedType(PyObject *obj, const sipMappedType *mt, PyObject *transferObj, int flags, int *state, int *iserr)</dt> -<dd><p class="first">This converts a Python object to an instance of a C structure or C++ -class that is implemented as a mapped type assuming that a previous call to -<a class="reference" href="#sipcanconverttomappedtype">sipCanConvertToMappedType()</a> has been successful. <em>obj</em> is the Python -object. <em>mt</em> is the opaque structure returned by <a class="reference" href="#sipfindmappedtype">sipFindMappedType()</a>. -<em>transferObj</em> controls any ownership changes to <em>obj</em>. If it is <tt class="docutils literal"><span class="pre">NULL</span></tt> -then the ownership is unchanged. If it is <tt class="docutils literal"><span class="pre">Py_None</span></tt> then ownership is -transferred to Python via a call to <a class="reference" href="#siptransferback">sipTransferBack()</a>. Otherwise -ownership is transferred to C/C++ and <em>obj</em> associated with <em>transferObj</em> -via a call to <a class="reference" href="#siptransferto">sipTransferTo()</a>. <em>flags</em> is any combination of the -following values used to fine tune the check.</p> -<blockquote> -<ul class="simple"> -<li><tt class="docutils literal"><span class="pre">SIP_NOT_NONE</span></tt> causes the check to fail if <em>obj</em> is <tt class="docutils literal"><span class="pre">None</span></tt>.</li> -</ul> -</blockquote> -<p class="last">If <em>state</em> is not <tt class="docutils literal"><span class="pre">NULL</span></tt> then the location it points to is set to -describe the state of the returned C/C++ instance and is the value returned -by any <a class="reference" href="#converttotypecode">%ConvertToTypeCode</a>. The calling code must then release the value -at some point to prevent a memory leak by calling -<a class="reference" href="#sipreleasemappedtype">sipReleaseMappedType()</a>. If there is an error then the location <em>iserr</em> -points to is set to a non-zero value. If it was initially a non-zero value -then the conversion isn't attempted in the first place. (This allows -several calls to be made that share the same error flag so that it only -needs to be tested once rather than after each call.)</p> -</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id170" id="sipdisconnectrx" name="sipdisconnectrx">9.25 sipDisconnectRx()</a></h2> -<dl class="docutils"> -<dt>PyObject *sipDisconnectRx(PyObject *sender, const char *signal, PyObject *receiver, const char *slot)</dt> -<dd>This disconnects a signal from a signal or slot and returns <tt class="docutils literal"><span class="pre">Py_True</span></tt> if -the signal was disconnected or <tt class="docutils literal"><span class="pre">Py_False</span></tt> if not. If there was some -other error then a Python exception is raised and <tt class="docutils literal"><span class="pre">NULL</span></tt> is returned. -<em>sender</em> is the wrapped <tt class="docutils literal"><span class="pre">TQObject</span></tt> derived instance that emits the signal. -<em>signal</em> is the typed name of the signal. <em>receiver</em> is the wrapped -<tt class="docutils literal"><span class="pre">TQObject</span></tt> derived instance or Python callable that the signal is -connected to. <em>slot</em> is the typed name of the slot, or <tt class="docutils literal"><span class="pre">NULL</span></tt> if -<em>receiver</em> is a Python callable. It is normally only used by PyQt to -implement <tt class="docutils literal"><span class="pre">TQObject.disconnect()</span></tt>.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id171" id="sipemitsignal" name="sipemitsignal">9.26 sipEmitSignal()</a></h2> -<dl class="docutils"> -<dt>int sipEmitSignal(PyObject *txobj, const char *signal, PyObject *args)</dt> -<dd>This emits a signal and returns zero if there was no error. If there was -an error then a Python exception is raised and a negative value is -returned. <em>txobj</em> is the wrapped <tt class="docutils literal"><span class="pre">TQObject</span></tt> derived instance that emits -the signal. <em>signal</em> is the typed name of the signal. <em>args</em> is a Python -tuple of the signal arguments. It is normally only used by PyQt to -implement <tt class="docutils literal"><span class="pre">TQObject.emit()</span></tt>.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id172" id="sipexportsymbol" name="sipexportsymbol">9.27 sipExportSymbol()</a></h2> -<dl class="docutils"> -<dt>int sipExportSymbol(const char *name, void *sym)</dt> -<dd>Python does not allow extension modules to directly access symbols in -another extension module. This exports a symbol, referenced by a name, -that can subsequently be imported, using <a class="reference" href="#sipimportsymbol">sipImportSymbol()</a>, by another -module. <em>name</em> is the name of the symbol and <em>sym</em> is its value. Zero is -returned if there was no error. A negative value is returned if <em>name</em> is -already associated with a symbol or there was some other error.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id173" id="sipfindclass" name="sipfindclass">9.28 sipFindClass()</a></h2> -<dl class="docutils"> -<dt>sipWrapperType *sipFindClass(const char *type)</dt> -<dd>This returns a pointer to the generated type corresponding to a C/C++ type. -<em>type</em> is the C/C++ declaration of the type. <tt class="docutils literal"><span class="pre">NULL</span></tt> is returned if the -C/C++ type doesn't exist. The value of the pointer will not change and -may be saved in a static cache.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id174" id="sipfindmappedtype" name="sipfindmappedtype">9.29 sipFindMappedType()</a></h2> -<dl class="docutils"> -<dt>const sipMappedType *sipFindMappedType(const char *type)</dt> -<dd>This returns a pointer to an opaque structure describing a mapped type. -<em>type</em> is the C/C++ declaration of the type. <tt class="docutils literal"><span class="pre">NULL</span></tt> is returned if the -mapped type doesn't exist. The value of the pointer will not change and -may be saved in a static cache.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id175" id="sipfindnamedenum" name="sipfindnamedenum">9.30 sipFindNamedEnum()</a></h2> -<dl class="docutils"> -<dt>PyTypeObject *sipFindNamedEnum(const char *type)</dt> -<dd>This returns a pointer to the generated type corresponding to a named C/C++ -enum. <em>type</em> is the C/C++ declaration of the enum. <tt class="docutils literal"><span class="pre">NULL</span></tt> is returned -if the named C/C++ enum doesn't exist. The value of the pointer will not -change and may be saved in a static cache.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id176" id="sipforceconverttoinstance" name="sipforceconverttoinstance">9.31 sipForceConvertToInstance()</a></h2> -<dl class="docutils"> -<dt>void *sipForceConvertToInstance(PyObject *obj, sipWrapperType *type, PyObject *transferObj, int flags, int *state, int *iserr)</dt> -<dd>This converts a Python object to an instance of a C structure or C++ class -by calling <a class="reference" href="#sipcanconverttoinstance">sipCanConvertToInstance()</a> and, if it is successfull, calling -<a class="reference" href="#sipconverttoinstance">sipConvertToInstance()</a>. See <a class="reference" href="#sipconverttoinstance">sipConvertToInstance()</a> for a full -description of the arguments.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id177" id="sipforceconverttomappedtype" name="sipforceconverttomappedtype">9.32 sipForceConvertToMappedType()</a></h2> -<dl class="docutils"> -<dt>void *sipForceConvertToMappedType(PyObject *obj, const sipMappedType *mt, PyObject *transferObj, int flags, int *state, int *iserr)</dt> -<dd>This converts a Python object to an instance of a C structure or C++ class -which has been implemented as a mapped type by calling -<a class="reference" href="#sipcanconverttomappedtype">sipCanConvertToMappedType()</a> and, if it is successfull, calling -<a class="reference" href="#sipconverttomappedtype">sipConvertToMappedType()</a>. See <a class="reference" href="#sipconverttomappedtype">sipConvertToMappedType()</a> for a full -description of the arguments.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id178" id="sipfree" name="sipfree">9.33 sipFree()</a></h2> -<dl class="docutils"> -<dt>void sipFree(void *mem)</dt> -<dd>This returns an area of memory allocated by <a class="reference" href="#sipmalloc">sipMalloc()</a> to the heap. -<em>mem</em> is a pointer to the area of memory.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id179" id="sipgetsender" name="sipgetsender">9.34 sipGetSender()</a></h2> -<dl class="docutils"> -<dt>const void *sipGetSender()</dt> -<dd>This returns a pointer to the last <tt class="docutils literal"><span class="pre">TQObject</span></tt> instance that emitted a Qt -signal. It is normally only used by PyQt to implement -<tt class="docutils literal"><span class="pre">TQObject.sender()</span></tt>.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id180" id="sipgetwrapper" name="sipgetwrapper">9.35 sipGetWrapper()</a></h2> -<dl class="docutils"> -<dt>PyObject *sipGetWrapper(void *cppptr, sipWrapperType *type)</dt> -<dd>This returns a borrowed reference to the wrapped instance object for a C -structure or C++ class instance. If the structure or class instance -hasn't been wrapped then <tt class="docutils literal"><span class="pre">NULL</span></tt> is returned (and no Python exception is -raised). <em>cppptr</em> is the pointer to the structure or class instance. -<em>type</em> is the generated type corresponding to the C/C++ type.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id181" id="sipimportsymbol" name="sipimportsymbol">9.36 sipImportSymbol()</a></h2> -<dl class="docutils"> -<dt>void *sipImportSymbol(const char *name)</dt> -<dd>Python does not allow extension modules to directly access symbols in -another extension module. This imports a symbol, referenced by a name, -that has previously been exported, using <a class="reference" href="#sipexportsymbol">sipExportSymbol()</a>, by another -module. <em>name</em> is the name of the symbol. The value of the symbol is -returned if there was no error. <tt class="docutils literal"><span class="pre">NULL</span></tt> is returned if there is no such -symbol.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id182" id="sipinttypeclassmap" name="sipinttypeclassmap">9.37 sipIntTypeClassMap</a></h2> -<p>This C structure is used with <a class="reference" href="#sipmapinttoclass">sipMapIntToClass()</a> to define a mapping -between integer based RTTI and <a class="reference" href="#generated-type-objects">generated type objects</a>. The structure -elements are as follows.</p> -<dl class="docutils"> -<dt>int typeInt</dt> -<dd>The integer RTTI.</dd> -<dt>sipWrapperType **pyType.</dt> -<dd>A pointer to the corresponding Python type object.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id183" id="sipissubclassinstance" name="sipissubclassinstance">9.38 sipIsSubClassInstance()</a></h2> -<dl class="docutils"> -<dt>int sipIsSubClassInstance(PyObject *obj, sipWrapperType *type)</dt> -<dd><p class="first">This function is deprecated from SIP v4.4. It is equivalent to:</p> -<pre class="last literal-block"> -sipCanConvertToInstance(obj, type, SIP_NOT_NONE | SIP_NO_CONVERTORS); -</pre> -</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id184" id="siplong-asunsignedlong" name="siplong-asunsignedlong">9.39 sipLong_AsUnsignedLong()</a></h2> -<dl class="docutils"> -<dt>unsigned long sipLong_AsUnsignedLong(PyObject *obj)</dt> -<dd>This function is a thin wrapper around PyLong_AsUnsignedLong() that works -around a bug in Python v2.3.x and earlier when converting integer objects.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id185" id="sipmalloc" name="sipmalloc">9.40 sipMalloc()</a></h2> -<dl class="docutils"> -<dt>void *sipMalloc(size_t nbytes)</dt> -<dd>This allocates an area of memory of size <em>nytes</em> on the heap using the -Python <tt class="docutils literal"><span class="pre">PyMem_Malloc()</span></tt> function. If there was an error then <tt class="docutils literal"><span class="pre">NULL</span></tt> is -returned and a Python exception raised. See <a class="reference" href="#sipfree">sipFree()</a>.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id186" id="sipmapinttoclass" name="sipmapinttoclass">9.41 sipMapIntToClass()</a></h2> -<dl class="docutils"> -<dt>sipWrapperType *sipMapIntToClass(int type, const sipIntTypeClassMap *map, int maplen)</dt> -<dd>This is used in <a class="reference" href="#converttosubclasscode">%ConvertToSubClassCode</a> code as a convenient way of -converting integer based RTTI to the corresponding Python type object. -<em>type</em> is the RTTI. <em>map</em> is the table of known RTTI and the corresponding -type objects (see <a class="reference" href="#sipinttypeclassmap">sipIntTypeClassMap</a>). The entries in the table must be -sorted in ascending order of RTTI. <em>maplen</em> is the number of entries in -the table. The corresponding Python type object is returned, or <tt class="docutils literal"><span class="pre">NULL</span></tt> -if <em>type</em> wasn't in <em>map</em>.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id187" id="sipmapstringtoclass" name="sipmapstringtoclass">9.42 sipMapStringToClass()</a></h2> -<dl class="docutils"> -<dt>sipWrapperType *sipMapStringToClass(char *type, const sipStringTypeClassMap *map, int maplen)</dt> -<dd>This is used in <a class="reference" href="#converttosubclasscode">%ConvertToSubClassCode</a> code as a convenient way of -converting <tt class="docutils literal"><span class="pre">'\0'</span></tt> terminated string based RTTI to the corresponding -Python type object. <em>type</em> is the RTTI. <em>map</em> is the table of known RTTI -and the corresponding type objects (see <a class="reference" href="#sipstringtypeclassmap">sipStringTypeClassMap</a>). The -entries in the table must be sorted in ascending order of RTTI. <em>maplen</em> -is the number of entries in the table. The corresponding Python type -object is returned, or <tt class="docutils literal"><span class="pre">NULL</span></tt> if <em>type</em> wasn't in <em>map</em>.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id188" id="sipparseresult" name="sipparseresult">9.43 sipParseResult()</a></h2> -<dl class="docutils"> -<dt>int sipParseResult(int *iserr, PyObject *method, PyObject *result, const char *format, ...)</dt> -<dd><p class="first">This converts a Python object (usually returned by a method) to C/C++ based -on a format string and associated values in a similar way to the Python -<tt class="docutils literal"><span class="pre">PyArg_ParseTuple()</span></tt> function. If there was an error then a negative -value is returned and a Python exception is raised. If <em>iserr</em> is not -<tt class="docutils literal"><span class="pre">NULL</span></tt> then the location it points to is set to a non-zero value. -<em>method</em> is the Python bound method that returned the <em>result</em> object. -<em>format</em> is the string of format characters.</p> -<p>This is normally called by handwritten code specified with the -<a class="reference" href="#virtualcatchercode">%VirtualCatcherCode</a> directive with <em>method</em> being the supplied -<tt class="docutils literal"><span class="pre">sipMethod</span></tt> and <tt class="docutils literal"><span class="pre">result</span></tt> being the value returned by -<a class="reference" href="#sipcallmethod">sipCallMethod()</a>.</p> -<p>If <em>format</em> begins and ends with parentheses then <em>result</em> must be a Python -tuple and the rest of <em>format</em> is applied to the tuple contents.</p> -<p>In the following description the first letter is the format character, the -entry in parentheses is the Python object type that the format character -will convert, and the entry in brackets are the types of the C/C++ values -to be passed.</p> -<dl class="last docutils"> -<dt><tt class="docutils literal"><span class="pre">a</span></tt> (string) [char **, int *]</dt> -<dd>Convert a Python string to a C/C++ character array and its length. If -the Python object is <tt class="docutils literal"><span class="pre">Py_None</span></tt> then the array and length are <tt class="docutils literal"><span class="pre">NULL</span></tt> -and zero respectively.</dd> -<dt><tt class="docutils literal"><span class="pre">b</span></tt> (integer) [bool *]</dt> -<dd>Convert a Python integer to a C/C++ <tt class="docutils literal"><span class="pre">bool</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">c</span></tt> (string) [char *]</dt> -<dd>Convert a Python string of length 1 to a C/C++ <tt class="docutils literal"><span class="pre">char</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">d</span></tt> (float) [double *]</dt> -<dd>Convert a Python floating point number to a C/C++ <tt class="docutils literal"><span class="pre">double</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">e</span></tt> (integer) [enum *]</dt> -<dd>Convert a Python integer to an anonymous C/C++ <tt class="docutils literal"><span class="pre">enum</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">f</span></tt> (float) [float *]</dt> -<dd>Convert a Python floating point number to a C/C++ <tt class="docutils literal"><span class="pre">float</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">h</span></tt> (integer) [short *]</dt> -<dd>Convert a Python integer to a C/C++ <tt class="docutils literal"><span class="pre">short</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">i</span></tt> (integer) [int *]</dt> -<dd>Convert a Python integer to a C/C++ <tt class="docutils literal"><span class="pre">int</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">l</span></tt> (long) [long *]</dt> -<dd>Convert a Python long to a C/C++ <tt class="docutils literal"><span class="pre">long</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">m</span></tt> (long) [unsigned long *]</dt> -<dd>Convert a Python long to a C/C++ <tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">long</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">n</span></tt> (long) [long long *]</dt> -<dd>Convert a Python long to a C/C++ <tt class="docutils literal"><span class="pre">long</span> <span class="pre">long</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">o</span></tt> (long) [unsigned long long *]</dt> -<dd>Convert a Python long to a C/C++ <tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">long</span> <span class="pre">long</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">s</span></tt> (string) [char **]</dt> -<dd>Convert a Python string to a C/C++ <tt class="docutils literal"><span class="pre">'\0'</span></tt> terminated string. If the -Python object is <tt class="docutils literal"><span class="pre">Py_None</span></tt> then the string is <tt class="docutils literal"><span class="pre">NULL</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">t</span></tt> (long) [unsigned short *]</dt> -<dd>Convert a Python long to a C/C++ <tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">short</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">u</span></tt> (long) [unsigned int *]</dt> -<dd>Convert a Python long to a C/C++ <tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">int</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">w</span></tt> (unicode) [wchar_t *]</dt> -<dd>Convert a Python unicode object of length 1 to a C/C++ wide character.</dd> -<dt><tt class="docutils literal"><span class="pre">x</span></tt> (unicode) [wchar_t **]</dt> -<dd>Convert a Python unicode object to a C/C++ <tt class="docutils literal"><span class="pre">L'\0'</span></tt> terminated wide -character string. If the Python object is <tt class="docutils literal"><span class="pre">Py_None</span></tt> then the string -is <tt class="docutils literal"><span class="pre">NULL</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">A</span></tt> (unicode) [wchar_t **, int *]</dt> -<dd>Convert a Python unicode object to a C/C++ wide character array and its -length. If the Python object is <tt class="docutils literal"><span class="pre">Py_None</span></tt> then the array and length -are <tt class="docutils literal"><span class="pre">NULL</span></tt> and zero respectively.</dd> -<dt><tt class="docutils literal"><span class="pre">Cf</span></tt> (wrapped class) [sipWrapperType *, int *, void **]</dt> -<dd><p class="first">Convert a Python object to a C structure or a C++ class instance and -return its state as described in <a class="reference" href="#sipconverttoinstance">sipConvertToInstance()</a>. <tt class="docutils literal"><span class="pre">f</span></tt> is a -combination of the following flags encoded as an ASCII character by -adding <tt class="docutils literal"><span class="pre">0</span></tt> to the combined value:</p> -<blockquote class="last"> -<p>0x01 disallows the conversion of <tt class="docutils literal"><span class="pre">Py_None</span></tt> to <tt class="docutils literal"><span class="pre">NULL</span></tt></p> -<p>0x02 implements the <a class="reference" href="#factory">Factory</a> annotation</p> -<dl class="docutils"> -<dt>0x04 suppresses the return of the state of the returned C/C++</dt> -<dd>instance. Note that the <tt class="docutils literal"><span class="pre">int</span> <span class="pre">*</span></tt> used to return the state is -not passed if this flag is specified.</dd> -</dl> -</blockquote> -</dd> -<dt><tt class="docutils literal"><span class="pre">Df</span></tt> (mapped type) [const sipMappedType *, int *, void **]</dt> -<dd><p class="first">Convert a Python object to a C structure or a C++ class instance -implemented as a mapped type and return its state as described in -<a class="reference" href="#sipconverttomappedtype">sipConvertToMappedType()</a>. <tt class="docutils literal"><span class="pre">f</span></tt> is a combination of the following -flags encoded as an ASCII character by adding <tt class="docutils literal"><span class="pre">0</span></tt> to the combined -value:</p> -<blockquote class="last"> -<p>0x01 disallows the conversion of <tt class="docutils literal"><span class="pre">Py_None</span></tt> to <tt class="docutils literal"><span class="pre">NULL</span></tt></p> -<p>0x02 implements the <a class="reference" href="#factory">Factory</a> annotation</p> -<dl class="docutils"> -<dt>0x04 suppresses the return of the state of the returned C/C++</dt> -<dd>instance. Note that the <tt class="docutils literal"><span class="pre">int</span> <span class="pre">*</span></tt> used to return the state is -not passed if this flag is specified.</dd> -</dl> -</blockquote> -</dd> -<dt><tt class="docutils literal"><span class="pre">E</span></tt> (wrapped enum) [PyTypeObject *, enum *]</dt> -<dd>Convert a Python named enum type to the corresponding C/C++ <tt class="docutils literal"><span class="pre">enum</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">L</span></tt> (object) [<em>type</em> *(*)(PyObject *obj, int *iserr), void **]</dt> -<dd>Convert a Python object to a C structure or a C++ class instance using -a convertor function. See <a class="reference" href="#generated-type-convertors">Generated Type Convertors</a>. This is -deprecated from SIP v4.4.</dd> -<dt><tt class="docutils literal"><span class="pre">M</span></tt> (object) [<em>type</em> *(*)(PyObject *obj, int *iserr), void **]</dt> -<dd>Convert a Python object to a C structure or a C++ class instance using -a convertor function. If the structure or class instance pointer is -<tt class="docutils literal"><span class="pre">NULL</span></tt> then return an error. See <a class="reference" href="#generated-type-convertors">Generated Type Convertors</a>. This -is deprecated from SIP v4.4.</dd> -<dt><tt class="docutils literal"><span class="pre">N</span></tt> (object) [PyTypeObject *, PyObject **]</dt> -<dd>A Python object is checked to see if it is a certain type and then -returned without any conversions. The reference count is incremented. -The Python object may be <tt class="docutils literal"><span class="pre">Py_None</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">O</span></tt> (object) [PyObject **]</dt> -<dd>A Python object is returned without any conversions. The reference -count is incremented.</dd> -<dt><tt class="docutils literal"><span class="pre">T</span></tt> (object) [PyTypeObject *, PyObject **]</dt> -<dd>A Python object is checked to see if it is a certain type and then -returned without any conversions. The reference count is incremented. -The Python object may not be <tt class="docutils literal"><span class="pre">Py_None</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">V</span></tt> (sip.voidptr) [void *]</dt> -<dd>Convert a Python <tt class="docutils literal"><span class="pre">sip.voidptr</span></tt> object to a C/C++ <tt class="docutils literal"><span class="pre">void</span> <span class="pre">*</span></tt>.</dd> -<dt><tt class="docutils literal"><span class="pre">Z</span></tt> (object) []</dt> -<dd>Check that a Python object is <tt class="docutils literal"><span class="pre">Py_None</span></tt>. No value is returned.</dd> -</dl> -</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id189" id="sipreleaseinstance" name="sipreleaseinstance">9.44 sipReleaseInstance()</a></h2> -<dl class="docutils"> -<dt>void sipReleaseInstance(void *cpp, sipWrapperType *type, int state)</dt> -<dd>This destroys a wrapped C/C++ instance if it was a temporary instance. It -is called after a call to either <a class="reference" href="#sipconverttoinstance">sipConvertToInstance()</a> or -<a class="reference" href="#sipforceconverttoinstance">sipForceConvertToInstance()</a>. <em>cpp</em> is the wrapped C/C++ instance. -<em>type</em> is the generated type corresponding to <em>cpp</em>. <em>state</em> describes the -state of the instance.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id190" id="sipreleasemappedtype" name="sipreleasemappedtype">9.45 sipReleaseMappedType()</a></h2> -<dl class="docutils"> -<dt>void sipReleaseMappedType(void *cpp, const sipMappedType *mt, int state)</dt> -<dd>This destroys a wrapped C/C++ mapped type if it was a temporary instance. -It is called after a call to either <a class="reference" href="#sipconverttomappedtype">sipConvertToMappedType()</a> or -<a class="reference" href="#sipforceconverttomappedtype">sipForceConvertToMappedType()</a>. <em>cpp</em> is the wrapped C/C++ instance. -<em>mt</em> is the opaque structure returned by <a class="reference" href="#sipfindmappedtype">sipFindMappedType()</a>. <em>state</em> -describes the state of the instance.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id191" id="sipstringtypeclassmap" name="sipstringtypeclassmap">9.46 sipStringTypeClassMap</a></h2> -<p>This C structure is used with <a class="reference" href="#sipmapstringtoclass">sipMapStringToClass()</a> to define a mapping -between <tt class="docutils literal"><span class="pre">'\0'</span></tt> terminated string based RTTI and <a class="reference" href="#generated-type-objects">generated type objects</a>. -The structure elements are as follows.</p> -<dl class="docutils"> -<dt>char *typeString</dt> -<dd>The <tt class="docutils literal"><span class="pre">'\0'</span></tt> terminated string RTTI.</dd> -<dt>sipWrapperType **pyType.</dt> -<dd>A pointer to the corresponding Python type object.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id192" id="siptransfer" name="siptransfer">9.47 sipTransfer()</a></h2> -<dl class="docutils"> -<dt>void sipTransfer(PyObject *obj, int tocpp)</dt> -<dd><p class="first">This function is deprecated from SIP v4.3. If <em>tocpp</em> is non-zero then the -equivalent call is:</p> -<pre class="literal-block"> -sipTransferTo(obj, obj); -</pre> -<p>If <em>tocpp</em> is zero then the equivalent call is:</p> -<pre class="last literal-block"> -sipTransferBack(obj); -</pre> -</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id193" id="siptransferback" name="siptransferback">9.48 sipTransferBack()</a></h2> -<dl class="docutils"> -<dt>void sipTransferBack(PyObject *obj)</dt> -<dd>This transfers ownership of a Python wrapped instance to Python (see -<a class="reference" href="#ownership-of-objects">Ownership of Objects</a>). <em>obj</em> is the wrapped instance. In addition, -any association of the instance with regard to the cyclic garbage -collector with another instance is removed.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id194" id="siptransferto" name="siptransferto">9.49 sipTransferTo()</a></h2> -<dl class="docutils"> -<dt>void sipTransferTo(PyObject *obj, PyObject *owner)</dt> -<dd>This transfers ownership of a Python wrapped instance to C++ (see -<a class="reference" href="#ownership-of-objects">Ownership of Objects</a>). <em>obj</em> is the wrapped instance. <em>owner</em> is an -optional wrapped instance that <em>obj</em> becomes associated with with regard -to the cyclic garbage collector. If <em>owner</em> is <tt class="docutils literal"><span class="pre">NULL</span></tt> then no such -association is made. If <em>owner</em> is the same value as <em>obj</em> then any -reference cycles involving <em>obj</em> can never be detected or broken by the -cyclic garbage collector. Responsibility for calling the C++ instance's -destructor is always transfered to C++.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id195" id="sipwrapper" name="sipwrapper">9.50 sipWrapper</a></h2> -<p>This is a C structure that represents a Python wrapped instance. It is an -extension of the Python <tt class="docutils literal"><span class="pre">PyObject</span></tt> structure and so may be safely cast to -<tt class="docutils literal"><span class="pre">PyObject</span></tt>. It includes a member called <tt class="docutils literal"><span class="pre">user</span></tt> which is of type -<tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt>. This can be used for any purpose by handwritten code and will -automatically be garbage collected at the appropriate time.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id196" id="sipwrapper-check" name="sipwrapper-check">9.51 sipWrapper_Check()</a></h2> -<dl class="docutils"> -<dt>int sipWrapper_Check(PyObject *obj)</dt> -<dd>This returns a non-zero value if a Python object is a wrapped instance. -<em>obj</em> is the Python object.</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id197" id="sipwrappertype" name="sipwrappertype">9.52 sipWrapperType</a></h2> -<p>This is a C structure that represents a SIP generated type object. It is an -extension of the Python <tt class="docutils literal"><span class="pre">PyTypeObject</span></tt> structure (which is itself an -extension of the Python <tt class="docutils literal"><span class="pre">PyObject</span></tt> structure) and so may be safely cast to -<tt class="docutils literal"><span class="pre">PyTypeObject</span></tt> (and <tt class="docutils literal"><span class="pre">PyObject</span></tt>).</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id198" id="generated-type-convertors" name="generated-type-convertors">9.53 Generated Type Convertors</a></h2> -<p>These functions are deprecated from SIP v4.4.</p> -<p>SIP generates functions for all types being wrapped (including mapped types -defined with the <a class="reference" href="#mappedtype">%MappedType</a> directive) that convert a Python object to the -C structure or C++ class instance. The name of this convertor is the name of -the structure or class prefixed by <tt class="docutils literal"><span class="pre">sipForceConvertTo_</span></tt>.</p> -<dl class="docutils"> -<dt>void *sipForceConvertTo_*class*(PyObject *obj, int *iserr)</dt> -<dd><em>obj</em> is the Python object to convert. If <em>obj</em> is <tt class="docutils literal"><span class="pre">NULL</span></tt> or the -location pointed to by <em>iserr</em> is non-zero then the conversion is not -attempted and <tt class="docutils literal"><span class="pre">NULL</span></tt> is returned. If there was an error then the -location pointed to by <em>iserr</em> is set to a non-zero value, a Python -exception is raised, and <tt class="docutils literal"><span class="pre">NULL</span></tt> is returned.</dd> -</dl> -<p>SIP also generates functions for mapped types that convert a C structure or -C++ class instance to a Python object. The name of this convertor is the name -of the structure or class prefixed by <tt class="docutils literal"><span class="pre">sipConvertFrom_</span></tt>.</p> -<dl class="docutils"> -<dt>PyObject *sipConvertFrom_*class*(void *cppptr)</dt> -<dd><em>cppptr</em> is a pointer to the C structure or C++ class instance to convert. -If there was an error then <tt class="docutils literal"><span class="pre">NULL</span></tt> is returned and a Python exception -raised.</dd> -</dl> -<p>The convertor functions of all imported types are available to handwritten -code.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id199" id="generated-type-objects" name="generated-type-objects">9.54 Generated Type Objects</a></h2> -<p>SIP generates a type object for each C structure or C++ class being wrapped. -These are <a class="reference" href="#sipwrappertype">sipWrapperType</a> structures and are used extensively by the SIP API.</p> -<p>These objects are named with the structure or class name prefixed by -<tt class="docutils literal"><span class="pre">sipClass_</span></tt>. For example, the type object for class <tt class="docutils literal"><span class="pre">Klass</span></tt> is -<tt class="docutils literal"><span class="pre">sipClass_Klass</span></tt>.</p> -<p>The type objects of all imported classes are available to handwritten code.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id200" id="generated-named-enum-type-objects" name="generated-named-enum-type-objects">9.55 Generated Named Enum Type Objects</a></h2> -<p>SIP generates a type object for each named enum being wrapped. These are -PyTypeObject structures. (Anonymous enums are wrapped as Python integers.)</p> -<p>These objects are named with the fully qualified enum name (i.e. including any -enclosing scope) prefixed by <tt class="docutils literal"><span class="pre">sipEnum_</span></tt>. For example, the type object for -enum <tt class="docutils literal"><span class="pre">Enum</span></tt> defined in class <tt class="docutils literal"><span class="pre">Klass</span></tt> is <tt class="docutils literal"><span class="pre">sipEnum_Klass_Enum</span></tt>.</p> -<p>The type objects of all imported named enums are available to handwritten code.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id201" id="generated-derived-classes" name="generated-derived-classes">9.56 Generated Derived Classes</a></h2> -<p>For most C++ classes being wrapped SIP generates a derived class with the same -name prefixed by <tt class="docutils literal"><span class="pre">sip</span></tt>. For example, the derived class for class <tt class="docutils literal"><span class="pre">Klass</span></tt> -is <tt class="docutils literal"><span class="pre">sipKlass</span></tt>.</p> -<p>If a C++ class doesn't have any virtual or protected methods in it or any of -it's super-class hierarchy, or does not emit any Qt signals, then a derived -class is not generated.</p> -<p>Most of the time handwritten code should ignore the derived classes. The only -exception is that handwritten constructor code specified using the -<a class="reference" href="#methodcode">%MethodCode</a> directive should call the derived class's constructor (which -has the same C++ signature) rather then the wrapped class's constructor.</p> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id202" id="generated-exception-objects" name="generated-exception-objects">9.57 Generated Exception Objects</a></h2> -<p>SIP generates a Python object for each exception defined with the <cite>%Exception_</cite> -directive.</p> -<p>These objects are named with the fully qualified exception name (i.e. including -any enclosing scope) prefixed by <tt class="docutils literal"><span class="pre">sipException_</span></tt>. For example, the type -object for enum <tt class="docutils literal"><span class="pre">Except</span></tt> defined in class <tt class="docutils literal"><span class="pre">Klass</span></tt> is -<tt class="docutils literal"><span class="pre">sipException_Klass_Except</span></tt>.</p> -<p>The objects of all imported exceptions are available to handwritten code.</p> -</div> -</div> -<div class="section"> -<h1><a class="toc-backref" href="#id203" id="using-the-sip-module-in-applications" name="using-the-sip-module-in-applications">10 Using the SIP Module in Applications</a></h1> -<p>The main purpose of the SIP module is to provide functionality common to all -SIP generated bindings. It is loaded automatically and most of the time you -will completely ignore it. However, it does expose some functionality that can -be used by applications.</p> -<dl class="docutils"> -<dt>cast(obj, type)</dt> -<dd>This does the Python equivalent of casting a C++ instance to one of its -sub or super-class types. <em>obj</em> is the Python object and <em>type</em> is the -type. A new Python object is returned that wraps the same C++ instance as -<em>obj</em>, but has the type <em>type</em>.</dd> -<dt>delete(obj)</dt> -<dd>For C++ instances this calls the C++ destructor. For C structures it -returns the structure's memory to the heap. <em>obj</em> is the Python object.</dd> -<dt>isdeleted(obj)</dt> -<dd>This returns True if the C++ instance or C structure has been destroyed or -returned to the heap. <em>obj</em> is the Python object.</dd> -<dt>setdeleted(obj)</dt> -<dd>This marks the C++ instance or C structure as having been destroyed or -returned to the heap so that future references to it raise an exception -rather than cause a program crash. Normally SIP handles such things -automatically, but there are circumstances where this isn't possible. -<em>obj</em> is the Python object.</dd> -<dt>settracemask(mask)</dt> -<dd><p class="first">If the bindings have been created with SIP's <tt class="docutils literal"><span class="pre">-r</span></tt> command line option -then the generated code will produce debugging statements that trace the -execution of the code. (It is particularly useful when trying to -understand the operation of a C++ library's virtual function calls.)</p> -<p>Debugging statements are generated at the following points:</p> -<ul class="simple"> -<li>in a C++ virtual function (<em>mask</em> is <tt class="docutils literal"><span class="pre">0x0001</span></tt>)</li> -<li>in a C++ constructor (<em>mask</em> is <tt class="docutils literal"><span class="pre">0x0002</span></tt>)</li> -<li>in a C++ destructor (<em>mask</em> is <tt class="docutils literal"><span class="pre">0x0004</span></tt>)</li> -<li>in a Python type's __init__ method (<em>mask</em> is <tt class="docutils literal"><span class="pre">0x0008</span></tt>)</li> -<li>in a Python type's __del__ method (<em>mask</em> is <tt class="docutils literal"><span class="pre">0x0010</span></tt>)</li> -<li>in a Python type's ordinary method (<em>mask</em> is <tt class="docutils literal"><span class="pre">0x0020</span></tt>).</li> -</ul> -<p class="last">By default the trace mask is zero and all debugging statements are -disabled.</p> -</dd> -<dt>SIP_VERSION</dt> -<dd>This is a Python integer object that represents the SIP version number as -a 3 part hexadecimal number (e.g. v4.0.0 is represented as <tt class="docutils literal"><span class="pre">0x040000</span></tt>). -It was first implemented in SIP v4.2.</dd> -<dt>SIP_VERSION_STR</dt> -<dd>This is a Python string object that defines the SIP version number as -represented as a string. For development snapshots it will start with -<tt class="docutils literal"><span class="pre">snapshot-</span></tt>. It was first implemented in SIP v4.3.</dd> -<dt>transfer(obj, direction)</dt> -<dd><p class="first">This function is deprecated from SIP v4.3. If <em>direction</em> is non-zero then -the equivalent call is:</p> -<pre class="literal-block"> -sip.transferto(obj, None) -</pre> -<p>If <em>direction</em> is zero then the equivalent call is:</p> -<pre class="last literal-block"> -sip.transferback(obj) -</pre> -</dd> -<dt>transferback(obj)</dt> -<dd>This function is a wrapper around <a class="reference" href="#siptransferback">sipTransferBack()</a>.</dd> -<dt>transferto(obj, owner)</dt> -<dd>This function is a wrapper around <a class="reference" href="#siptransferto">sipTransferTo()</a>.</dd> -<dt>unwrapinstance(obj)</dt> -<dd>Return the address, as a number, of the wrapped C/C++ structure or class -instance <em>obj</em>.</dd> -<dt>voidptr</dt> -<dd><p class="first">This is the type object for the type SIP uses to represent a C/C++ -<tt class="docutils literal"><span class="pre">void</span> <span class="pre">*</span></tt>. The type constructor takes a single argument that must either -be another <tt class="docutils literal"><span class="pre">voidptr</span></tt>, <tt class="docutils literal"><span class="pre">None</span></tt>, a Python CObject, or an integer. The -type has the following methods:</p> -<dl class="last docutils"> -<dt>__int__()</dt> -<dd>This returns the pointer as an integer.</dd> -<dt>__hex__()</dt> -<dd>This returns the pointer as a hexadecimal string.</dd> -<dt>ascobject()</dt> -<dd>This returns the pointer as a Python CObject.</dd> -<dt>asstring(nbytes)</dt> -<dd>This returns a copy of the first <em>nbytes</em> of memory at the pointer as a -Python string.</dd> -</dl> -</dd> -<dt>wrapinstance(addr, type)</dt> -<dd>A C/C++ structure or class instance is wrapped and the Python object -created is returned. If the instance has already been wrapped then a new -reference to the existing object is returned. <em>addr</em> is the address of -the instance represented as a number. <em>type</em> is the type of the object -(e.g. <tt class="docutils literal"><span class="pre">qt.TQWidget</span></tt>).</dd> -<dt>wrapper</dt> -<dd>This is the type object of the base type of all instances wrapped by SIP.</dd> -<dt>wrappertype</dt> -<dd>This is the type object of the metatype of the <tt class="docutils literal"><span class="pre">wrapper</span></tt> type.</dd> -</dl> -</div> -<div class="section"> -<h1><a class="toc-backref" href="#id204" id="the-sip-build-system" name="the-sip-build-system">11 The SIP Build System</a></h1> -<p>The purpose of the build system is to make it easy for you to write -configuration scripts in Python for your own bindings. The build system takes -care of the details of particular combinations of platform and compiler. It -supports over 50 different platform/compiler combinations.</p> -<p>The build system is implemented as a pure Python module called <tt class="docutils literal"><span class="pre">sipconfig</span></tt> -that contains a number of classes and functions. Using this module you can -write bespoke configuration scripts (e.g. PyQt's <tt class="docutils literal"><span class="pre">configure.py</span></tt>) or use it -with other Python based build systems (e.g. -<a class="reference" href="http://www.python.org/sigs/distutils-sig/distutils.html">Distutils</a> and -<a class="reference" href="http://www.scons.org">SCons</a>).</p> -<p>An important feature of SIP is the ability to generate bindings that are built -on top of existing bindings. For example, both -<a class="reference" href="http://www.riverbankcomputing.co.uk/pykde/">PyKDE</a> and -<a class="reference" href="http://pyqwt.sourceforge.net/">PyQwt</a> are built on top of PyQt but all three -packages are maintained by different developers. To make this easier PyQt -includes its own configuration module, <tt class="docutils literal"><span class="pre">pyqtconfig</span></tt>, that contains additional -classes intended to be used by the configuration scripts of bindings built on -top of PyQt. The SIP build system includes facilities that do a lot of the -work of creating these additional configuration modules.</p> -<div class="section"> -<h2><a class="toc-backref" href="#id205" id="sipconfig-functions" name="sipconfig-functions">11.1 <tt class="docutils literal"><span class="pre">sipconfig</span></tt> Functions</a></h2> -<dl class="docutils"> -<dt>create_config_module(module, template, content, macros=None)</dt> -<dd><p class="first">This creates a configuration module (e.g. <tt class="docutils literal"><span class="pre">pyqtconfig</span></tt>) from a template -file and a string.</p> -<p><tt class="docutils literal"><span class="pre">module</span></tt> is the name of the configuration module file to create.</p> -<p><tt class="docutils literal"><span class="pre">template</span></tt> is the name of the template file.</p> -<p><tt class="docutils literal"><span class="pre">content</span></tt> is a string which replaces every occurence of the pattern -<tt class="docutils literal"><span class="pre">@SIP_CONFIGURATION@</span></tt> in the template file. The content string is -usually created from a Python dictionary using -<tt class="docutils literal"><span class="pre">sipconfig.create_content()</span></tt>. <tt class="docutils literal"><span class="pre">content</span></tt> may also be a dictionary, in -which case <tt class="docutils literal"><span class="pre">sipconfig.create_content()</span></tt> is automatically called to -convert it to a string.</p> -<p class="last"><tt class="docutils literal"><span class="pre">macros</span></tt> is an optional dictionary of platform specific build macros. It -is only used if <tt class="docutils literal"><span class="pre">sipconfig.create_content()</span></tt> is called automatically to -convert a <tt class="docutils literal"><span class="pre">content</span></tt> dictionary to a string.</p> -</dd> -<dt>create_content(dict, macros=None)</dt> -<dd><p class="first">This converts a Python dictionary to a string that can be parsed by the -Python interpreter and converted back to an equivalent dictionary. It is -typically used to generate the content string for -<tt class="docutils literal"><span class="pre">sipconfig.create_config_module()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">dict</span></tt> is the Python dictionary to convert.</p> -<p><tt class="docutils literal"><span class="pre">macros</span></tt> is the optional dictionary of platform specific build macros.</p> -<p class="last">Returns the dictionary as a string.</p> -</dd> -<dt>create_wrapper(script, wrapper, gui=0)</dt> -<dd><p class="first">This creates a platform dependent executable wrapper around a Python -script.</p> -<p><tt class="docutils literal"><span class="pre">script</span></tt> is the full pathname of the script.</p> -<p><tt class="docutils literal"><span class="pre">wrapper</span></tt> is the pathname of the wrapper to create.</p> -<p><tt class="docutils literal"><span class="pre">gui</span></tt> is non-zero if a GUI enabled version of the interpreter should be -used on platforms that require it.</p> -<p class="last">Returns the platform specific name of the wrapper.</p> -</dd> -<dt>error(msg)</dt> -<dd><p class="first">This displays an error message on <tt class="docutils literal"><span class="pre">stderr</span></tt> and calls <tt class="docutils literal"><span class="pre">sys.exit()</span></tt> with -a value of 1.</p> -<p class="last"><tt class="docutils literal"><span class="pre">msg</span></tt> is the text of the message and should not include any newline -characters.</p> -</dd> -<dt>format(msg, leftmargin=0, rightmargin=78)</dt> -<dd><p class="first">This formats a message by inserting newline characters at appropriate -places.</p> -<p><tt class="docutils literal"><span class="pre">msg</span></tt> is the text of the message and should not include any newline -characters.</p> -<p><tt class="docutils literal"><span class="pre">leftmargin</span></tt> is the optional position of the left margin.</p> -<p class="last"><tt class="docutils literal"><span class="pre">rightmargin</span></tt> is the optional position of the right margin.</p> -</dd> -<dt>inform(msg)</dt> -<dd><p class="first">This displays an information message on <tt class="docutils literal"><span class="pre">stdout</span></tt>.</p> -<p class="last"><tt class="docutils literal"><span class="pre">msg</span></tt> is the text of the message and should not include any newline -characters.</p> -</dd> -<dt>parse_build_macros(filename, names, overrides=None, properties=None)</dt> -<dd><p class="first">This parses a qmake compatible file of build system macros and converts it -to a dictionary. A macro is a name/value pair. The dictionary is returned -or None if any of the overrides was invalid.</p> -<p><tt class="docutils literal"><span class="pre">filename</span></tt> is the name of the file to parse.</p> -<p><tt class="docutils literal"><span class="pre">names</span></tt> is a list of the macro names to extract from the file.</p> -<p><tt class="docutils literal"><span class="pre">overrides</span></tt> is an optional list of macro names and values that modify -those found in the file. They are of the form <em>name=value</em> (in which case -the value replaces the value found in the file) or <em>name+=value</em> (in which -case the value is appended to the value found in the file).</p> -<p class="last"><tt class="docutils literal"><span class="pre">properties</span></tt> is an optional dictionary of property name and values that -are used to resolve any expressions of the form <tt class="docutils literal"><span class="pre">$[name]</span></tt> in the file.</p> -</dd> -<dt>read_version(filename, description, numdefine=None, strdefine=None)</dt> -<dd><p class="first">This extracts version information for a package from a file, usually a C or -C++ header file. The version information must each be specified as a -<tt class="docutils literal"><span class="pre">#define</span></tt> of a numeric (hexadecimal or decimal) value and/or a string -value.</p> -<p><tt class="docutils literal"><span class="pre">filename</span></tt> is the name of the file to read.</p> -<p><tt class="docutils literal"><span class="pre">description</span></tt> is a descriptive name of the package used in error -messages.</p> -<p><tt class="docutils literal"><span class="pre">numdefine</span></tt> is the optional name of the <tt class="docutils literal"><span class="pre">#define</span></tt> of the version as a -number. If it is <tt class="docutils literal"><span class="pre">None</span></tt> then the numeric version is ignored.</p> -<p><tt class="docutils literal"><span class="pre">strdefine</span></tt> is the optional name of the <tt class="docutils literal"><span class="pre">#define</span></tt> of the version as a -string. If it is <tt class="docutils literal"><span class="pre">None</span></tt> then the string version is ignored.</p> -<p class="last">Returns a tuple of the numeric and string versions. <tt class="docutils literal"><span class="pre">sipconfig.error()</span></tt> -is called if either were required but could not be found.</p> -</dd> -<dt>version_to_sip_tag(version, tags, description)</dt> -<dd><p class="first">This converts a version number to a SIP version tag. SIP uses the -<a class="reference" href="#timeline">%Timeline</a> directive to define the chronology of the different versions -of the C/C++ library being wrapped. Typically it is not necessary to -define a version tag for every version of the library, but only for those -versions that affect the library's API as SIP sees it.</p> -<p><tt class="docutils literal"><span class="pre">version</span></tt> is the numeric version number of the C/C++ library being -wrapped. If it is negative then the latest version is assumed. (This is -typically useful if a snapshot is indicated by a negative version number.)</p> -<p><tt class="docutils literal"><span class="pre">tags</span></tt> is the dictionary of SIP version tags keyed by the corresponding -C/C++ library version number. The tag used is the one with the smallest -key (i.e. earliest version) that is greater than <tt class="docutils literal"><span class="pre">version</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">description</span></tt> is a descriptive name of the C/C++ library used in error -messages.</p> -<p class="last">Returns the SIP version tag. <tt class="docutils literal"><span class="pre">sipconfig.error()</span></tt> is called if the C/C++ -library version number did not correspond to a SIP version tag.</p> -</dd> -<dt>version_to_string(v)</dt> -<dd><p class="first">This converts a 3 part version number encoded as a hexadecimal value to a -string.</p> -<p><tt class="docutils literal"><span class="pre">v</span></tt> is the version number.</p> -<p class="last">Returns a string.</p> -</dd> -</dl> -</div> -<div class="section"> -<h2><a class="toc-backref" href="#id206" id="sipconfig-classes" name="sipconfig-classes">11.2 <tt class="docutils literal"><span class="pre">sipconfig</span></tt> Classes</a></h2> -<dl class="docutils"> -<dt>Configuration</dt> -<dd><p class="first">This class encapsulates configuration values that can be accessed as -instance objects. A sub-class may provide a dictionary of additional -configuration values in its constructor the elements of which will have -precedence over the super-class's values.</p> -<p>The following configuration values are provided:</p> -<blockquote> -<dl class="docutils"> -<dt>default_bin_dir</dt> -<dd>The name of the directory where executables should be installed by -default.</dd> -<dt>default_mod_dir</dt> -<dd>The name of the directory where SIP generated modules should be -installed by default.</dd> -<dt>default_sip_dir</dt> -<dd>The name of the base directory where the <tt class="docutils literal"><span class="pre">.sip</span></tt> files for SIP -generated modules should be installed by default. A sub-directory -with the same name as the module should be created and its <tt class="docutils literal"><span class="pre">.sip</span></tt> -files should be installed in the sub-directory. The <tt class="docutils literal"><span class="pre">.sip</span></tt> -files only need to be installed if you might want to build other -bindings based on them.</dd> -<dt>platform</dt> -<dd>The name of the platform/compiler for which the build system has -been configured for.</dd> -<dt>py_conf_inc_dir</dt> -<dd>The name of the directory containing the <tt class="docutils literal"><span class="pre">pyconfig.h</span></tt> header -file.</dd> -<dt>py_inc_dir</dt> -<dd>The name of the directory containing the <tt class="docutils literal"><span class="pre">Python.h</span></tt> header file.</dd> -<dt>py_lib_dir</dt> -<dd>The name of the directory containing the Python interpreter -library.</dd> -<dt>py_version</dt> -<dd>The Python version as a 3 part hexadecimal number (e.g. v2.3.3 is -represented as <tt class="docutils literal"><span class="pre">0x020303</span></tt>).</dd> -<dt>sip_bin</dt> -<dd>The full pathname of the SIP executable.</dd> -<dt>sip_config_args</dt> -<dd>The command line passed to <tt class="docutils literal"><span class="pre">configure.py</span></tt> when SIP was -configured.</dd> -<dt>sip_inc_dir</dt> -<dd>The name of the directory containing the <tt class="docutils literal"><span class="pre">sip.h</span></tt> header file.</dd> -<dt>sip_mod_dir</dt> -<dd>The name of the directory containing the SIP module.</dd> -<dt>sip_version</dt> -<dd>The SIP version as a 3 part hexadecimal number (e.g. v4.0.0 is -represented as <tt class="docutils literal"><span class="pre">0x040000</span></tt>).</dd> -<dt>sip_version_str</dt> -<dd>The SIP version as a string. For development snapshots it will -start with <tt class="docutils literal"><span class="pre">snapshot-</span></tt>.</dd> -<dt>universal</dt> -<dd>The name of the MacOS/X SDK used when creating universal binaries.</dd> -</dl> -</blockquote> -<dl class="last docutils"> -<dt>__init__(self, sub_cfg=None)</dt> -<dd><p class="first">Initialise the instance.</p> -<p class="last"><tt class="docutils literal"><span class="pre">sub_cfg</span></tt> is an optional list of sub-class configurations. It should -only be used by the <tt class="docutils literal"><span class="pre">__init__()</span></tt> method of a sub-class to append its -own dictionary of configuration values before passing the list to its -super-class.</p> -</dd> -<dt>build_macros(self)</dt> -<dd>Return the dictionary of platform specific build macros.</dd> -<dt>set_build_macros(self, macros)</dt> -<dd>Set the dictionary of platform specific build macros to be use when -generating Makefiles. Normally there is no need to change the default -macros.</dd> -</dl> -</dd> -<dt>Makefile</dt> -<dd><p class="first">This class encapsulates a Makefile. It is intended to be sub-classed to -generate Makefiles for particular purposes. It handles all platform and -compiler specific flags, but allows them to be adjusted to suit the -requirements of a particular module or program. These are defined using a -number of macros which can be accessed as instance objects.</p> -<p>The following instance objects are provided to help in fine tuning the -generated Makefile:</p> -<blockquote> -<dl class="docutils"> -<dt>chkdir</dt> -<dd>A string that will check for the existence of a directory.</dd> -<dt>config</dt> -<dd>A reference to the <tt class="docutils literal"><span class="pre">configuration</span></tt> argument that was passed to -the constructor.</dd> -<dt>console</dt> -<dd>A reference to the <tt class="docutils literal"><span class="pre">console</span></tt> argument that was passed to the -constructor.</dd> -<dt>copy</dt> -<dd>A string that will copy a file.</dd> -<dt>extra_cflags</dt> -<dd>A list of additional flags passed to the C compiler.</dd> -<dt>extra_cxxflags</dt> -<dd>A list of additional flags passed to the C++ compiler.</dd> -<dt>extra_defines</dt> -<dd>A list of additional macro names passed to the C/C++ preprocessor.</dd> -<dt>extra_include_dirs</dt> -<dd>A list of additional include directories passed to the C/C++ -preprocessor.</dd> -<dt>extra_lflags</dt> -<dd>A list of additional flags passed to the linker.</dd> -<dt>extra_lib_dirs</dt> -<dd>A list of additional library directories passed to the linker.</dd> -<dt>extra_libs</dt> -<dd>A list of additional libraries passed to the linker. The names of -the libraries must be in platform neutral form (i.e. without any -platform specific prefixes, version numbers or extensions).</dd> -<dt>generator</dt> -<dd>A string that defines the platform specific style of Makefile. The -only supported values are <tt class="docutils literal"><span class="pre">UNIX</span></tt> and something else that is not -<tt class="docutils literal"><span class="pre">UNIX</span></tt>.</dd> -<dt>mkdir</dt> -<dd>A string that will create a directory.</dd> -<dt>rm</dt> -<dd>A string that will remove a file.</dd> -</dl> -</blockquote> -<dl class="last docutils"> -<dt>__init__(self, configuration, console=0, qt=0, opengl=0, python=0, threaded=0, warnings=None, debug=0, dir=None, makefile="Makefile", installs=None, universal='')</dt> -<dd><p class="first">Initialise the instance.</p> -<p><tt class="docutils literal"><span class="pre">configuration</span></tt> is the current configuration and is an instance of -the <tt class="docutils literal"><span class="pre">Configuration</span></tt> class or a sub-class.</p> -<p><tt class="docutils literal"><span class="pre">console</span></tt> is set if the target is a console (rather than GUI) target. -This only affects Windows and is ignored on other platforms.</p> -<p><tt class="docutils literal"><span class="pre">qt</span></tt> is set if the target uses Qt. For Qt v4 a list of Qt libraries -may be specified and a simple non-zero value implies QtCore and QtGui.</p> -<p><tt class="docutils literal"><span class="pre">opengl</span></tt> is set if the target uses OpenGL.</p> -<p><tt class="docutils literal"><span class="pre">python</span></tt> is set if the target uses Python.h.</p> -<p><tt class="docutils literal"><span class="pre">threaded</span></tt> is set if the target requires thread support. It is set -automatically if the target uses Qt and Qt has thread support enabled.</p> -<p><tt class="docutils literal"><span class="pre">warnings</span></tt> is set if compiler warning messages should be enabled. -The default of <tt class="docutils literal"><span class="pre">None</span></tt> means that warnings are enabled for SIP v4.x -and disabled for SIP v3.x.</p> -<p><tt class="docutils literal"><span class="pre">debug</span></tt> is set if debugging symbols should be generated.</p> -<p><tt class="docutils literal"><span class="pre">dir</span></tt> is the name of the directory where build files are read from -and Makefiles are written to. The default of <tt class="docutils literal"><span class="pre">None</span></tt> means the -current directory is used.</p> -<p><tt class="docutils literal"><span class="pre">makefile</span></tt> is the name of the generated Makefile.</p> -<p><tt class="docutils literal"><span class="pre">installs</span></tt> is a list of extra install targets. Each element is a two -part list, the first of which is the source and the second is the -destination. If the source is another list then it is a list of source -files and the destination is a directory.</p> -<p class="last"><tt class="docutils literal"><span class="pre">universal</span></tt> is the name of the SDK if universal binaries are to be -created under MacOS/X.</p> -</dd> -<dt>clean_build_file_objects(self, mfile, build)</dt> -<dd><p class="first">This generates the Makefile commands that will remove any files -generated during the build of the default target.</p> -<p><tt class="docutils literal"><span class="pre">mfile</span></tt> is the Python file object of the Makefile.</p> -<p class="last"><tt class="docutils literal"><span class="pre">build</span></tt> is the dictionary created from parsing the build file.</p> -</dd> -<dt>finalise(self)</dt> -<dd>This is called just before the Makefile is generated to ensure that it -is fully configured. It must be reimplemented by a sub-class.</dd> -<dt>generate(self)</dt> -<dd>This generates the Makefile.</dd> -<dt>generate_macros_and_rules(self, mfile)</dt> -<dd><p class="first">This is the default implementation of the Makefile macros and rules -generation.</p> -<p class="last"><tt class="docutils literal"><span class="pre">mfile</span></tt> is the Python file object of the Makefile.</p> -</dd> -<dt>generate_target_clean(self, mfile)</dt> -<dd><p class="first">This is the default implementation of the Makefile clean target -generation.</p> -<p class="last"><tt class="docutils literal"><span class="pre">mfile</span></tt> is the Python file object of the Makefile.</p> -</dd> -<dt>generate_target_default(self, mfile)</dt> -<dd><p class="first">This is the default implementation of the Makefile default target -generation.</p> -<p class="last"><tt class="docutils literal"><span class="pre">mfile</span></tt> is the Python file object of the Makefile.</p> -</dd> -<dt>generate_target_install(self, mfile)</dt> -<dd><p class="first">This is the default implementation of the Makefile install target -generation.</p> -<p class="last"><tt class="docutils literal"><span class="pre">mfile</span></tt> is the Python file object of the Makefile.</p> -</dd> -<dt>install_file(self, mfile, src, dst, strip=0)</dt> -<dd><p class="first">This generates the Makefile commands to install one or more files to a -directory.</p> -<p><tt class="docutils literal"><span class="pre">mfile</span></tt> is the Python file object of the Makefile.</p> -<p><tt class="docutils literal"><span class="pre">src</span></tt> is the name of a single file to install or a list of a number -of files to install.</p> -<p><tt class="docutils literal"><span class="pre">dst</span></tt> is the name of the destination directory.</p> -<p class="last"><tt class="docutils literal"><span class="pre">strip</span></tt> is set if the files should be stripped of unneeded symbols -after having been installed.</p> -</dd> -<dt>optional_list(self, name)</dt> -<dd><p class="first">This returns an optional Makefile macro as a list.</p> -<p><tt class="docutils literal"><span class="pre">name</span></tt> is the name of the macro.</p> -<p class="last">Returns the macro as a list.</p> -</dd> -<dt>optional_string(self, name, default="")</dt> -<dd><p class="first">This returns an optional Makefile macro as a string.</p> -<p><tt class="docutils literal"><span class="pre">name</span></tt> is the name of the macro.</p> -<p><tt class="docutils literal"><span class="pre">default</span></tt> is the optional default value of the macro.</p> -<p class="last">Returns the macro as a string.</p> -</dd> -<dt>parse_build_file(self, filename)</dt> -<dd><p class="first">This parses a build file (created with the <tt class="docutils literal"><span class="pre">-b</span></tt> SIP command line -option) and converts it to a dictionary. It can also validate an -existing dictionary created through other means.</p> -<p><tt class="docutils literal"><span class="pre">filename</span></tt> is the name of the build file, or is a dictionary to be -validated. A valid dictionary will contain the name of the target to -build (excluding any platform specific extension) keyed by <tt class="docutils literal"><span class="pre">target</span></tt>; -the names of all source files keyed by <tt class="docutils literal"><span class="pre">sources</span></tt>; and, optionally, -the names of all header files keyed by <tt class="docutils literal"><span class="pre">headers</span></tt>.</p> -<p class="last">Returns a dictionary corresponding to the parsed build file.</p> -</dd> -<dt>platform_lib(self, clib, framework=0)</dt> -<dd><p class="first">This converts a library name to a platform specific form.</p> -<p><tt class="docutils literal"><span class="pre">clib</span></tt> is the name of the library in cannonical form.</p> -<p><tt class="docutils literal"><span class="pre">framework</span></tt> is set if the library is implemented as a MacOS -framework.</p> -<p class="last">Return the platform specific name.</p> -</dd> -<dt>ready(self)</dt> -<dd>This is called to ensure that the Makefile is fully configured. It is -normally called automatically when needed.</dd> -<dt>required_string(self, name)</dt> -<dd><p class="first">This returns a required Makefile macro as a string.</p> -<p><tt class="docutils literal"><span class="pre">name</span></tt> is the name of the macro.</p> -<p class="last">Returns the macro as a string. An exception is raised if the macro -does not exist or has an empty value.</p> -</dd> -</dl> -</dd> -<dt>ModuleMakefile(Makefile)</dt> -<dd><p class="first">This class encapsulates a Makefile to build a generic Python extension -module.</p> -<dl class="last docutils"> -<dt>__init__(self, configuration, build_file, install_dir=None, static=0, console=0, opengl=0, threaded=0, warnings=None, debug=0, dir=None, makefile="Makefile", installs=None, strip=1, export_all=0, universal='')</dt> -<dd><p class="first">Initialise the instance.</p> -<p><tt class="docutils literal"><span class="pre">configuration</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">build_file</span></tt> is the name of the build file. Build files are -generated using the <tt class="docutils literal"><span class="pre">-b</span></tt> SIP command line option.</p> -<p><tt class="docutils literal"><span class="pre">install_dir</span></tt> is the name of the directory where the module will be -optionally installed.</p> -<p><tt class="docutils literal"><span class="pre">static</span></tt> is set if the module should be built as a static library -(see <a class="reference" href="#builtin-modules-and-custom-interpreters">Builtin Modules and Custom Interpreters</a>).</p> -<p><tt class="docutils literal"><span class="pre">console</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">qt</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">opengl</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">threaded</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">warnings</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">debug</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">dir</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">makefile</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">installs</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">strip</span></tt> is set if the module should be stripped of unneeded symbols -after installation. It is ignored if either <tt class="docutils literal"><span class="pre">debug</span></tt> or <tt class="docutils literal"><span class="pre">static</span></tt> is -set, or if the platform doesn't support it.</p> -<p class="last"><tt class="docutils literal"><span class="pre">export_all</span></tt> is set if all of the module's symbols should be exported -rather than just the module's initialisation function. Exporting all -symbols increases the size of the module and slows down module load -times but may avoid problems with modules that use C++ exceptions. All -symbols are exported if either <tt class="docutils literal"><span class="pre">debug</span></tt> or <tt class="docutils literal"><span class="pre">static</span></tt> is set, or if -the platform doesn't support it.</p> -</dd> -<dt>finalise(self)</dt> -<dd>This is a reimplementation of <tt class="docutils literal"><span class="pre">sipconfig.Makefile.finalise()</span></tt>.</dd> -<dt>generate_macros_and_rules(self, mfile)</dt> -<dd>This is a reimplementation of -<tt class="docutils literal"><span class="pre">sipconfig.Makefile.generate_macros_and_rules()</span></tt>.</dd> -<dt>generate_target_clean(self, mfile)</dt> -<dd>This is a reimplementation of -<tt class="docutils literal"><span class="pre">sipconfig.Makefile.generate_target_clean()</span></tt>.</dd> -<dt>generate_target_default(self, mfile)</dt> -<dd>This is a reimplementation of -<tt class="docutils literal"><span class="pre">sipconfig.Makefile.generate_target_default()</span></tt>.</dd> -<dt>generate_target_install(self, mfile)</dt> -<dd>This is a reimplementation of -<tt class="docutils literal"><span class="pre">sipconfig.Makefile.generate_target_install()</span></tt>.</dd> -<dt>module_as_lib(self, mname)</dt> -<dd><p class="first">This returns the name of a SIP v3.x module for when it is used as a -library to be linked against. An exception will be raised if it is -used with SIP v4.x modules.</p> -<p><tt class="docutils literal"><span class="pre">mname</span></tt> is the name of the module.</p> -<p class="last">Returns the corresponding library name.</p> -</dd> -</dl> -</dd> -<dt>ParentMakefile(Makefile)</dt> -<dd><p class="first">This class encapsulates a Makefile that sits above a number of other -Makefiles in sub-directories.</p> -<dl class="last docutils"> -<dt>__init__(self, configuration, subdirs, dir=None, makefile="Makefile", installs=None)</dt> -<dd><p class="first">Initialise the instance.</p> -<p><tt class="docutils literal"><span class="pre">configuration</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">subdirs</span></tt> is the sequence of sub-directories.</p> -<p><tt class="docutils literal"><span class="pre">dir</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">makefile</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p class="last"><tt class="docutils literal"><span class="pre">installs</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -</dd> -<dt>generate_macros_and_rules(self, mfile)</dt> -<dd>This is a reimplementation of -<tt class="docutils literal"><span class="pre">sipconfig.Makefile.generate_macros_and_rules()</span></tt>.</dd> -<dt>generate_target_clean(self, mfile)</dt> -<dd>This is a reimplementation of -<tt class="docutils literal"><span class="pre">sipconfig.Makefile.generate_target_clean()</span></tt>.</dd> -<dt>generate_target_default(self, mfile)</dt> -<dd>This is a reimplementation of -<tt class="docutils literal"><span class="pre">sipconfig.Makefile.generate_target_default()</span></tt>.</dd> -<dt>generate_target_install(self, mfile)</dt> -<dd>This is a reimplementation of -<tt class="docutils literal"><span class="pre">sipconfig.Makefile.generate_target_install()</span></tt>.</dd> -</dl> -</dd> -<dt>ProgramMakefile(Makefile)</dt> -<dd><p class="first">This class encapsulates a Makefile to build an executable program.</p> -<dl class="last docutils"> -<dt>__init__(self, configuration, build_file=None, install_dir=None, console=0, qt=0, opengl=0, python=0, threaded=0, warnings=None, debug=0, dir=None, makefile="Makefile", installs=None, universal='')</dt> -<dd><p class="first">Initialise the instance.</p> -<p><tt class="docutils literal"><span class="pre">configuration</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">build_file</span></tt> is the name of the optional build file. Build files are -generated using the <tt class="docutils literal"><span class="pre">-b</span></tt> SIP command line option.</p> -<p><tt class="docutils literal"><span class="pre">install_dir</span></tt> is the name of the directory where the executable -program will be optionally installed.</p> -<p><tt class="docutils literal"><span class="pre">console</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">qt</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">opengl</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">python</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">threaded</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">warnings</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">debug</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">dir</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">makefile</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p class="last"><tt class="docutils literal"><span class="pre">installs</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -</dd> -<dt>build_command(self, source)</dt> -<dd><p class="first">This creates a single command line that will create an executable -program from a single source file.</p> -<p><tt class="docutils literal"><span class="pre">source</span></tt> is the name of the source file.</p> -<p class="last">Returns a tuple of the name of the executable that will be created and -the command line.</p> -</dd> -<dt>finalise(self)</dt> -<dd>This is a reimplementation of <tt class="docutils literal"><span class="pre">sipconfig.Makefile.finalise()</span></tt>.</dd> -<dt>generate_macros_and_rules(self, mfile)</dt> -<dd>This is a reimplementation of -<tt class="docutils literal"><span class="pre">sipconfig.Makefile.generate_macros_and_rules()</span></tt>.</dd> -<dt>generate_target_clean(self, mfile)</dt> -<dd>This is a reimplementation of -<tt class="docutils literal"><span class="pre">sipconfig.Makefile.generate_target_clean()</span></tt>.</dd> -<dt>generate_target_default(self, mfile)</dt> -<dd>This is a reimplementation of -<tt class="docutils literal"><span class="pre">sipconfig.Makefile.generate_target_default()</span></tt>.</dd> -<dt>generate_target_install(self, mfile)</dt> -<dd>This is a reimplementation of -<tt class="docutils literal"><span class="pre">sipconfig.Makefile.generate_target_install()</span></tt>.</dd> -</dl> -</dd> -<dt>PythonModuleMakefile(Makefile)</dt> -<dd><p class="first">This class encapsulates a Makefile that installs a pure Python module.</p> -<dl class="last docutils"> -<dt>__init__(self, configuration, dstdir, srcdir=None, dir=None, makefile="Makefile", installs=None)</dt> -<dd><p class="first">Initialise the instance.</p> -<p><tt class="docutils literal"><span class="pre">configuration</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">dstdir</span></tt> is the name of the directory in which the module's Python -code will be installed.</p> -<p><tt class="docutils literal"><span class="pre">srcdir</span></tt> is the name of the directory (relative to <tt class="docutils literal"><span class="pre">dir</span></tt>) -containing the module's Python code. It defaults to the same -directory.</p> -<p><tt class="docutils literal"><span class="pre">dir</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p><tt class="docutils literal"><span class="pre">makefile</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -<p class="last"><tt class="docutils literal"><span class="pre">installs</span></tt> - see <tt class="docutils literal"><span class="pre">sipconfig.Makefile.__init__()</span></tt>.</p> -</dd> -<dt>generate_macros_and_rules(self, mfile)</dt> -<dd>This is a reimplementation of -<tt class="docutils literal"><span class="pre">sipconfig.Makefile.generate_macros_and_rules()</span></tt>.</dd> -<dt>generate_target_install(self, mfile)</dt> -<dd>This is a reimplementation of -<tt class="docutils literal"><span class="pre">sipconfig.Makefile.generate_target_install()</span></tt>.</dd> -</dl> -</dd> -<dt>SIPModuleMakefile(ModuleMakefile)</dt> -<dd><p class="first">This class encapsulates a Makefile to build a SIP generated Python -extension module.</p> -<dl class="last docutils"> -<dt>finalise(self)</dt> -<dd>This is a reimplementation of <tt class="docutils literal"><span class="pre">sipconfig.Makefile.finalise()</span></tt>.</dd> -</dl> -</dd> -</dl> -</div> -</div> -<div class="section"> -<h1><a class="toc-backref" href="#id207" id="building-your-extension-with-distutils" name="building-your-extension-with-distutils">12 Building Your Extension with distutils</a></h1> -<p>To build the example in <a class="reference" href="#a-simple-c-example">A Simple C++ Example</a> using distutils, it is -sufficient to create a standard <tt class="docutils literal"><span class="pre">setup.py</span></tt>, listing <tt class="docutils literal"><span class="pre">word.sip</span></tt> among the -files to build, and hook-up SIP into distutils:</p> -<pre class="literal-block"> -from distutils.core import setup, Extension -import sipdistutils - -setup( - name = 'word', - versione = '1.0', - ext_modules=[ - Extension("word", ["word.sip", "word.cpp"]), - ], - - cmdclass = {'build_ext': sipdistutils.build_ext} -) -</pre> -<p>As we can see, the above is a normal distutils setup script, with just a -special line which is needed so that SIP can see and process <tt class="docutils literal"><span class="pre">word.sip</span></tt>. -Then, running <tt class="docutils literal"><span class="pre">setup.py</span> <span class="pre">build</span></tt> will build our extension module.</p> -</div> -<div class="section"> -<h1><a class="toc-backref" href="#id208" id="builtin-modules-and-custom-interpreters" name="builtin-modules-and-custom-interpreters">13 Builtin Modules and Custom Interpreters</a></h1> -<p>Sometimes you want to create a custom Python interpreter with some modules -built in to the interpreter itself rather than being dynamically loaded. To -do this the module must be created as a static library and linked with a -custom stub and the normal Python library.</p> -<p>To build the SIP module as a static library you must pass the <tt class="docutils literal"><span class="pre">-k</span></tt> command -line option to <tt class="docutils literal"><span class="pre">configure.py</span></tt>. You should then build and install SIP as -normal. (Note that, because the module is now a static library, you will not -be able to import it.)</p> -<p>To build a module you have created for your own library you must modify your -own configuration script to pass a non-zero value as the <tt class="docutils literal"><span class="pre">static</span></tt> argument -of the <tt class="docutils literal"><span class="pre">__init__()</span></tt> method of the <tt class="docutils literal"><span class="pre">ModuleMakefile</span></tt> class (or any derived -class you have created). Normally you would make this configurable using a -command line option in the same way that SIP's <tt class="docutils literal"><span class="pre">configure.py</span></tt> handles it.</p> -<p>The next stage is to create a custom stub and a Makefile. The SIP distribution -contains a directory called <tt class="docutils literal"><span class="pre">custom</span></tt> which contains example stubs and a -Python script that will create a correct Makefile. Note that, if your copy of -SIP was part of a standard Linux distribution, the <tt class="docutils literal"><span class="pre">custom</span></tt> directory may -not be installed on your system.</p> -<p>The <tt class="docutils literal"><span class="pre">custom</span></tt> directory contains the following files. They are provided as -examples - each needs to be modified according to your particular -requirements.</p> -<blockquote> -<ul class="simple"> -<li><tt class="docutils literal"><span class="pre">mkcustom.py</span></tt> is a Python script that will create a Makefile which is -then used to build the custom interpreter. Comments in the file describe -how it should be modified.</li> -<li><tt class="docutils literal"><span class="pre">custom.c</span></tt> is a stub for a custom interpreter on Linux/UNIX. It -should also be used for a custom console interpreter on Windows (i.e. -like <tt class="docutils literal"><span class="pre">python.exe</span></tt>). Comments in the file describe how it should be -modified.</li> -<li><tt class="docutils literal"><span class="pre">customw.c</span></tt> is a stub for a custom GUI interpreter on Windows (i.e. -like <tt class="docutils literal"><span class="pre">pythonw.exe</span></tt>). Comments in the file describe how it should be -modified.</li> -</ul> -</blockquote> -<p>Note that this technique does not restrict how the interpreter can be used. -For example, it still allows users to write their own applications that can -import your builtin modules. If you want to prevent users from doing that, -perhaps to protect a proprietary API, then take a look at the -<a class="reference" href="http://www.riverbankcomputing.co.uk/vendorid/">VendorID</a> package.</p> -</div> -</div> -</body> -</html> diff --git a/python/sip/doc/sipref.txt b/python/sip/doc/sipref.txt deleted file mode 100644 index 4e14f79e..00000000 --- a/python/sip/doc/sipref.txt +++ /dev/null @@ -1,5353 +0,0 @@ -===================================================================== - SIP - A Tool for Generating Python Bindings for C and C++ Libraries -===================================================================== - ------------------ - Reference Guide ------------------ - -:Contact: info@riverbankcomputing.co.uk -:Version: 4.6 -:Copyright: Copyright (c) 2007 Riverbank Computing Limited - -.. contents:: -.. section-numbering:: - - -Introduction -============ - -This is the reference guide for SIP 4.6. SIP is a tool for -automatically generating `Python <http://www.python.org>`__ bindings for C and -C++ libraries. SIP was originally developed in 1998 for -`PyQt <http://www.riverbankcomputing.co.uk/pyqt/>`__ - the Python bindings for -the Qt GUI toolkit - but is suitable for generating bindings for any C or C++ -library. - -This version of SIP generates bindings for Python v2.3 or later. - -There are many other similar tools available. One of the original such tools -is `SWIG <http://www.swig.org>`__ and, in fact, SIP is so called because it -started out as a small SWIG. Unlike SWIG, SIP is specifically designed for -bringing together Python and C/C++ and goes to great lengths to make the -integration as tight as possible. - -The homepage for SIP is http://www.riverbankcomputing.co.uk/sip/. Here you -will always find the latest stable version, current development snapshots, and -the latest version of this documentation. - - -License -------- - -SIP is licensed under the same terms as Python itself. SIP places no -restrictions on the license you may apply to the bindings you create. - - -Features --------- - -SIP, and the bindings it produces, have the following features. - - - bindings are fast to load and minimise memory consumption especially when - only a small sub-set of a large library is being used - - - automatic conversion between standard Python and C/C++ data types - - - overloading of functions and methods with different argument signatures - - - access to a C++ class's protected methods - - - the ability to define a Python class that is a sub-class of a C++ class, - including abstract C++ classes - - - Python sub-classes can implement the ``__dtor__(self)`` method which - will be called from the C++ class's virtual destructor - - - support for ordinary C++ functions, class methods, static class methods, - virtual class methods and abstract class methods - - - the ability to re-implement C++ virtual and abstract methods in Python - - - support for global and class variables - - - support for global and class operators - - - support for C++ namespaces - - - support for C++ templates - - - support for C++ exceptions and wrapping them as Python exceptions - - - the ability to define mappings between C++ classes and similar Python - data types that are automatically invoked - - - the ability to automatically exploit any available run time type - information to ensure that the class of a Python instance object matches - the class of the corresponding C++ instance - - - full support of the Python global interpreter lock, including the ability - to specify that a C++ function of method may block, therefore allowing - the lock to be released and other Python threads to run - - - support for the concept of ownership of a C++ instance (i.e. what part of - the code is responsible for calling the instance's destructor) and how - the ownership may change during the execution of an application - - - the ability to generate bindings for a C++ class library that itself is - built on another C++ class library which also has had bindings generated - so that the different bindings integrate and share code properly - - - a sophisticated versioning system that allows the full lifetime of a C++ - class library, including any platform specific or optional features, to - be described in a single set of specification files - - - the ability to include documentation in the specification files which can - be extracted and subsequently processed by external tools - - - the ability to include copyright notices and licensing information in the - specification files that is automatically included in all generated - source code - - - a build system, written in Python, that you can extend to configure, - compile and install your own bindings without worrying about platform - specific issues - - - support for building your extensions using distutils - - - SIP, and the bindings it produces, runs under UNIX, Linux, Windows and - MacOS/X - - -SIP Components --------------- - -SIP comprises a number of different components. - - - The SIP code generator (``sip`` or ``sip.exe``). This processes ``.sip`` - specification files and generates C or C++ bindings. It is covered in - detail in `Using SIP`_. - - - The SIP header file (``sip.h``). This contains definitions and data - structures needed by the generated C and C++ code. - - - The SIP module (``sip.so`` or ``sip.pyd``). This is a Python extension - module that is imported automatically by SIP generated bindings and - provides them with some common utility functions. See also `Using the - SIP Module in Applications`_. - - - The SIP build system (``sipconfig.py``). This is a pure Python module - that is created when SIP is configured and encapsulates all the necessary - information about your system including relevant directory names, - compiler and linker flags, and version numbers. It also includes several - Python classes and functions which help you write configuration scripts - for your own bindings. It is covered in detail in `The SIP Build - System`_. - - - The SIP distutils extension (``sipdistutils.py``). This is a distutils - extension that can be used to build your extension modules using - distutils and is an alternative to writing configuration scripts with the - SIP build system. This can be as simple as adding your .sip files to the - list of files needed to build the extension module. It is covered in - detail in `Building Your Extension with distutils`_. - - -Qt Support ----------- - -SIP has specific support for the creation of bindings based on Trolltech's Qt -toolkit. - -The SIP code generator understands the signal/slot type safe callback mechanism -that Qt uses to connect objects together. This allows applications to define -new Python signals, and allows any Python callable object to be used as a slot. - -SIP itself does not require Qt to be installed. - - -Potential Incompatibilities with Earlier Versions -================================================= - -SIP v4.4 --------- - - - The ``SIP_BUILD`` C preprocessor symbol has been removed. - - - `sipConvertToCpp()`_, `sipIsSubClassInstance()`_ and the old `Generated - Type Convertors`_ have been deprecated. The functions - `sipCanConvertToInstance()`_, `sipConvertToInstance()`_, - `sipForceConvertToInstance()`_, `sipConvertFromInstance()`_, - `sipConvertFromNewInstance()`_, `sipCanConvertToMappedType()`_, - `sipConvertToMappedType()`_, `sipForceConvertToMappedType()`_ and - `sipConvertFromMappedType()`_ should be used instead. Handwritten - `%ConvertFromTypeCode`_ and `%ConvertToTypeCode`_ now has the - responsibility for using these to implement the ``Transfer`` and - ``TransferBack`` annotations. - - -Installing SIP -============== - -Downloading SIP ---------------- - -You can get the latest release of the SIP source code from -http://www.riverbankcomputing.co.uk/sip/download.php. - -SIP is also included with all of the major Linux distributions. However, it -may be a version or two out of date. - -You may also find more up to date pre-compiled binaries on -`SourceForge <http://sourceforge.net/project/showfiles.php?group_id=61057>`_. - - -Configuring SIP ---------------- - -After unpacking the source package (either a ``.tar.gz`` or a ``.zip`` file -depending on your platform) you should then check for any ``README`` files -that relate to your platform. - -Next you need to configure SIP by executing the ``configure.py`` script. For -example:: - - python configure.py - -This assumes that the Python interpreter is on your path. Something like the -following may be appropriate on Windows:: - - c:\python25\python configure.py - -If you have multiple versions of Python installed then make sure you use the -interpreter for which you wish SIP to generate bindings for. - -The full set of command line options is: - --h Display a help message. --a Export all symbols in any SIP generated module and the SIP module - itself. This was the default behaviour of SIP prior to v4.2. - Normally only a module's inititialisation function is exported. This - option is deprecated as the ``ModuleMakefile`` class of `The SIP Build - System`_ allows this to be specified on a per module basis. --b dir The SIP code generator will be installed in the directory ``dir``. --d dir The SIP module will be installed in the directory ``dir``. --e dir The SIP header file will be installed in the directory ``dir``. --k The SIP module will be built as a static library. This is useful when - building the SIP module as a Python builtin (see - `Builtin Modules and Custom Interpreters`_). --n The SIP code generator and module will be built as universal binaries - under MacOS/X. --p plat Explicitly specify the platform/compiler to be used by the build - system, otherwise a platform specific default will be used. The - ``-h`` option will display all the supported platform/compilers and - the default. --u The SIP module will be built with debugging symbols. --v dir By default ``.sip`` files will be installed in the directory ``dir``. - -The configure.py script takes many other options that allows the build system -to be finely tuned. These are of the form ``name=value`` or ``name+=value``. -The ``-h`` option will display each supported ``name``, although not all are -applicable to all platforms. - -The ``name=value`` form means that ``value`` will replace the existing value of -``name``. - -The ``name+=value`` form means that ``value`` will be appended to the existing -value of ``name``. - -For example, the following will disable support for C++ exceptions (and so -reduce the size of module binaries) when used with GCC:: - - python configure.py CXXFLAGS+=-fno-exceptions - -A pure Python module called ``sipconfig.py`` is generated by ``configure.py``. -This defines each ``name`` and its corresponding ``value``. Looking at it will -give you a good idea of how the build system uses the different options. It is -covered in detail in `The SIP Build System`_. - - -Configuring SIP Using MinGW -*************************** - -SIP, and the modules it generates, can be built with MinGW, the Windows port of -GCC. You must use the ``-p`` command line option to specify the correct -platform. For example:: - - c:\python25\python configure.py -p win32-g++ - - -Configuring SIP Using the Borland C++ Compiler -********************************************** - -SIP, and the modules it generates, can be built with the free Borland C++ -compiler. You must use the ``-p`` command line option to specify the correct -platform. For example:: - - c:\python25\python configure.py -p win32-borland - -You must also make sure you have a Borland-compatible version of the Python -library. If you are using the standard Python distribution (built using the -Microsoft compiler) then you must convert the format of the Python library. -For example:: - - coff2omf python25.lib python25_bcpp.lib - - -Building SIP ------------- - -The next step is to build SIP by running your platform's ``make`` command. For -example:: - - make - -The final step is to install SIP by running the following command:: - - make install - -(Depending on your system you may require root or administrator privileges.) - -This will install the various SIP components. - - -Using SIP -========= - -Bindings are generated by the SIP code generator from a number of specification -files, typically with a ``.sip`` extension. Specification files look very -similar to C and C++ header files, but often with additional information (in -the form of a *directive* or an *annotation*) and code so that the bindings -generated can be finely tuned. - - -A Simple C++ Example --------------------- - -We start with a simple example. Let's say you have a (fictional) C++ library -that implements a single class called ``Word``. The class has one constructor -that takes a ``\0`` terminated character string as its single argument. The -class has one method called ``reverse()`` which takes no arguments and returns -a ``\0`` terminated character string. The interface to the class is defined in -a header file called ``word.h`` which might look something like this:: - - // Define the interface to the word library. - - class Word { - const char *the_word; - - public: - Word(const char *w); - - char *reverse() const; - }; - -The corresponding SIP specification file would then look something like this:: - - // Define the SIP wrapper to the word library. - - %Module word 0 - - class Word { - - %TypeHeaderCode - #include <word.h> - %End - - public: - Word(const char *w); - - char *reverse() const; - }; - -Obviously a SIP specification file looks very much like a C++ (or C) header -file, but SIP does not include a full C++ parser. Let's look at the -differences between the two files. - - - The `%Module`_ directive has been added [#]_. This is used to name the - Python module that is being created and to give it a *generation* number. - In this example these are ``word`` and ``0`` respectively. The - generation number is effectively the version number of the module. - - - The `%TypeHeaderCode`_ directive has been added. The text between this - and the following `%End`_ directive is included literally in the code - that SIP generates. Normally it is used, as in this case, to - ``#include`` the corresponding C++ (or C) header file [#]_. - - - The declaration of the private variable ``this_word`` has been removed. - SIP does not support access to either private or protected instance - variables. - -If we want to we can now generate the C++ code in the current directory by -running the following command:: - - sip -c . word.sip - -However, that still leaves us with the task of compiling the generated code and -linking it against all the necessary libraries. It's much easier to use the -SIP build system to do the whole thing. - -Using the SIP build system is simply a matter of writing a small Python script. -In this simple example we will assume that the ``word`` library we are wrapping -and it's header file are installed in standard system locations and will be -found by the compiler and linker without having to specify any additional -flags. In a more realistic example your Python script may take command line -options, or search a set of directories to deal with different configurations -and installations. - -This is the simplest script (conventionally called ``configure.py``):: - - import os - import sipconfig - - # The name of the SIP build file generated by SIP and used by the build - # system. - build_file = "word.sbf" - - # Get the SIP configuration information. - config = sipconfig.Configuration() - - # Run SIP to generate the code. - os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file, "word.sip"])) - - # Create the Makefile. - makefile = sipconfig.SIPModuleMakefile(config, build_file) - - # Add the library we are wrapping. The name doesn't include any platform - # specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the - # ".dll" extension on Windows). - makefile.extra_libs = ["word"] - - # Generate the Makefile itself. - makefile.generate() - -Hopefully this script is self-documenting. The key parts are the -``Configuration`` and ``SIPModuleMakefile`` classes. The build system contains -other Makefile classes, for example to build programs or to call other -Makefiles in sub-directories. - -After running the script (using the Python interpreter the extension module is -being created for) the generated C++ code and ``Makefile`` will be in the -current directory. - -To compile and install the extension module, just run the following -commands [#]_:: - - make - make install - -That's all there is to it. - -See `Building Your Extension with distutils`_ for an example of how to build -this example using distutils. - -.. [#] All SIP directives start with a ``%`` as the first non-whitespace - character of a line. -.. [#] SIP includes many code directives like this. They differ in where the - supplied code is placed by SIP in the generated code. -.. [#] On Windows you might run ``nmake`` or ``mingw32-make`` instead. - - -A Simple C Example ------------------- - -Let's now look at a very similar example of wrapping a fictional C library:: - - /* Define the interface to the word library. */ - - struct Word { - const char *the_word; - }; - - struct Word *create_word(const char *w); - char *reverse(struct Word *word); - -The corresponding SIP specification file would then look something like this:: - - /* Define the SIP wrapper to the word library. */ - - %CModule word 0 - - struct Word { - - %TypeHeaderCode - #include <word.h> - %End - - const char *the_word; - }; - - struct Word *create_word(const char *w) /Factory/; - char *reverse(struct Word *word); - -Again, let's look at the differences between the two files. - - - The `%CModule`_ directive has been added. This has the same syntax as - the `%Module`_ directive used in the previous example but tells SIP that - the library being wrapped is implemented in C rather than C++. - - - The `%TypeHeaderCode`_ directive has been added. - - - The Factory_ annotation has been added to the ``create_word()`` function. - This tells SIP that a newly created structure is being returned and it is - owned by Python. - -The ``configure.py`` build system script described in the previous example can -be used for this example without change. - - -A More Complex C++ Example --------------------------- - -In this last example we will wrap a fictional C++ library that contains a class -that is derived from a Qt class. This will demonstrate how SIP allows a class -hierarchy to be split across multiple Python extension modules, and will -introduce SIP's versioning system. - -The library contains a single C++ class called ``Hello`` which is derived from -Qt's ``QLabel`` class. It behaves just like ``QLabel`` except that the text -in the label is hard coded to be ``Hello World``. To make the example more -interesting we'll also say that the library only supports Qt v3.0 and later, -and also includes a function called ``setDefault()`` that is not implemented -in the Windows version of the library. - -The ``hello.h`` header file looks something like this:: - - // Define the interface to the hello library. - - #include <qlabel.h> - #include <qwidget.h> - #include <qstring.h> - - class Hello : public QLabel { - // This is needed by the Qt Meta-Object Compiler. - Q_OBJECT - - public: - Hello(QWidget *parent, const char *name = 0, WFlags f = 0); - - private: - // Prevent instances from being copied. - Hello(const Hello &); - Hello &operator=(const Hello &); - }; - - #if !defined(Q_OS_WIN) - void setDefault(const QString &def); - #endif - -The corresponding SIP specification file would then look something like this:: - - // Define the SIP wrapper to the hello library. - - %Module hello 0 - - %Import qt/qtmod.sip - - %If (Qt_3_0_0 -) - - class Hello : QLabel { - - %TypeHeaderCode - #include <hello.h> - %End - - public: - Hello(QWidget *parent /TransferThis/, const char *name = 0, WFlags f = 0); - - private: - Hello(const Hello &); - }; - - %If (!WS_WIN) - void setDefault(const QString &def); - %End - - %End - -Again we look at the differences, but we'll skip those that we've looked at in -previous examples. - - - The `%Import`_ directive has been added to specify that we are extending - the class hierarchy defined in the file ``qt/qtmod.sip``. This file is - part of PyQt. The build system will take care of finding the file's - exact location. - - - The `%If`_ directive has been added to specify that - everything [#]_ up to the matching `%End`_ directive only applies to Qt - v3.0 and later. ``Qt_3_0_0`` is a *tag* defined in ``qtmod.sip`` [#]_ - using the `%Timeline`_ directive. `%Timeline`_ is used to define a tag - for each version of a library's API you are wrapping allowing you to - maintain all the different versions in a single SIP specification. The - build system provides support to ``configure.py`` scripts for working out - the correct tags to use according to which version of the library is - actually installed. - - - The ``public`` keyword used in defining the super-classes has been - removed. This is not supported by SIP. - - - The TransferThis_ annotation has been added to the first argument - of the constructor. It specifies that if the argument is not 0 (i.e. the - ``Hello`` instance being constructed has a parent) then ownership of the - instance is transferred from Python to C++. It is needed because Qt - maintains objects (i.e. instances derived from the ``QObject`` class) in - a hierachy. When an object is destroyed all of its children are also - automatically destroyed. It is important, therefore, that the Python - garbage collector doesn't also try and destroy them. This is covered in - more detail in `Ownership of Objects`_. SIP provides many other - annotations that can be applied to arguments, functions and classes. - Multiple annotations are separated by commas. Annotations may have - values. - - - The ``=`` operator has been removed. This operator is not supported by - SIP. - - - The `%If`_ directive has been added to specify that everything up to the - matching `%End`_ directive does not apply to Windows. ``WS_WIN`` is - another tag defined by PyQt, this time using the `%Platforms`_ directive. - Tags defined by the `%Platforms`_ directive are mutually exclusive, i.e. - only one may be valid at a time [#]_. - -One question you might have at this point is why bother to define the private -copy constructor when it can never be called from Python? The answer is to -prevent the automatic generation of a public copy constructor. - -We now look at the ``configure.py`` script. This is a little different to the -script in the previous examples for two related reasons. - -Firstly, PyQt includes a pure Python module called ``pyqtconfig`` that extends -the SIP build system for modules, like our example, that build on top of PyQt. -It deals with the details of which version of Qt is being used (i.e. it -determines what the correct tags are) and where it is installed. This is -called a module's configuration module. - -Secondly, we generate a configuration module (called ``helloconfig``) for our -own ``hello`` module. There is no need to do this, but if there is a chance -that somebody else might want to extend your C++ library then it would make -life easier for them. - -Now we have two scripts. First the ``configure.py`` script:: - - import os - import sipconfig - import pyqtconfig - - # The name of the SIP build file generated by SIP and used by the build - # system. - build_file = "hello.sbf" - - # Get the PyQt configuration information. - config = pyqtconfig.Configuration() - - # Get the extra SIP flags needed by the imported qt module. Note that - # this normally only includes those flags (-x and -t) that relate to SIP's - # versioning system. - qt_sip_flags = config.pyqt_qt_sip_flags - - # Run SIP to generate the code. Note that we tell SIP where to find the qt - # module's specification files using the -I flag. - os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file, "-I", config.pyqt_sip_dir, qt_sip_flags, "hello.sip"])) - - # We are going to install the SIP specification file for this module and - # its configuration module. - installs = [] - - installs.append(["hello.sip", os.path.join(config.default_sip_dir, "hello")]) - - installs.append(["helloconfig.py", config.default_mod_dir]) - - # Create the Makefile. The QtModuleMakefile class provided by the - # pyqtconfig module takes care of all the extra preprocessor, compiler and - # linker flags needed by the Qt library. - makefile = pyqtconfig.QtModuleMakefile( - configuration=config, - build_file=build_file, - installs=installs - ) - - # Add the library we are wrapping. The name doesn't include any platform - # specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the - # ".dll" extension on Windows). - makefile.extra_libs = ["hello"] - - # Generate the Makefile itself. - makefile.generate() - - # Now we create the configuration module. This is done by merging a Python - # dictionary (whose values are normally determined dynamically) with a - # (static) template. - content = { - # Publish where the SIP specifications for this module will be - # installed. - "hello_sip_dir": config.default_sip_dir, - - # Publish the set of SIP flags needed by this module. As these are the - # same flags needed by the qt module we could leave it out, but this - # allows us to change the flags at a later date without breaking - # scripts that import the configuration module. - "hello_sip_flags": qt_sip_flags - } - - # This creates the helloconfig.py module from the helloconfig.py.in - # template and the dictionary. - sipconfig.create_config_module("helloconfig.py", "helloconfig.py.in", content) - -Next we have the ``helloconfig.py.in`` template script:: - - import pyqtconfig - - # These are installation specific values created when Hello was configured. - # The following line will be replaced when this template is used to create - # the final configuration module. - # @SIP_CONFIGURATION@ - - class Configuration(pyqtconfig.Configuration): - """The class that represents Hello configuration values. - """ - def __init__(self, sub_cfg=None): - """Initialise an instance of the class. - - sub_cfg is the list of sub-class configurations. It should be None - when called normally. - """ - # This is all standard code to be copied verbatim except for the - # name of the module containing the super-class. - if sub_cfg: - cfg = sub_cfg - else: - cfg = [] - - cfg.append(_pkg_config) - - pyqtconfig.Configuration.__init__(self, cfg) - - class HelloModuleMakefile(pyqtconfig.QtModuleMakefile): - """The Makefile class for modules that %Import hello. - """ - def finalise(self): - """Finalise the macros. - """ - # Make sure our C++ library is linked. - self.extra_libs.append("hello") - - # Let the super-class do what it needs to. - pyqtconfig.QtModuleMakefile.finalise(self) - -Again, we hope that the scripts are self documenting. - -.. [#] Some parts of a SIP specification aren't subject to version control. -.. [#] Actually in ``versions.sip``. PyQt uses the `%Include`_ directive to - split the SIP specification for Qt across a large number of separate - ``.sip`` files. -.. [#] Tags can also be defined by the `%Feature`_ directive. These tags are - not mutually exclusive, i.e. any number may be valid at a time. - - -Ownership of Objects --------------------- - -When a C++ instance is wrapped a corresponding Python object is created. The -Python object behaves as you would expect in regard to garbage collection - it -is garbage collected when its reference count reaches zero. What then happens -to the corresponding C++ instance? The obvious answer might be that the -instance's destructor is called. However the library API may say that when the -instance is passed to a particular function, the library takes ownership of the -instance, i.e. responsibility for calling the instance's destructor is -transferred from the SIP generated module to the library. - -Ownership of an instance may also be associated with another instance. The -implication being that the owned instance will automatically be destroyed if -the owning instance is destroyed. SIP keeps track of these relationships to -ensure that Python's cyclic garbage collector can detect and break any -reference cycles between the owning and owned instances. The association is -implemented as the owning instance taking a reference to the owned instance. - -The TransferThis_, Transfer_ and TransferBack annotations are used to specify -where, and it what direction, transfers of ownership happen. It is very -important that these are specified correctly to avoid crashes (where both -Python and C++ call the destructor) and memory leaks (where neither Python and -C++ call the destructor). - -This applies equally to C structures where the structure is returned to the -heap using the ``free()`` function. - -See also `sipTransferTo()`_ and `sipTransferBack()`_. - - -Support for Wide Characters ---------------------------- - -SIP v4.6 introduced support for wide characters (i.e. the ``wchar_t`` type). -Python's C API includes support for converting between unicode objects and wide -character strings and arrays. When converting from a unicode object to wide -characters SIP creates the string or array on the heap (using memory allocated -using `sipMalloc()`_). This then raises the problem of how this memory is -subsequently freed. - -The following describes how SIP handles this memory in the different situations -where this is an issue. - - - When a wide string or array is passed to a function or method then the - memory is freed (using `sipFree()`_) after than function or method - returns. - - - When a wide string or array is returned from a virtual method then SIP - does not free the memory until the next time the method is called. - - - When an assignment is made to a wide string or array instance variable - then SIP does not first free the instance's current string or array. - - -The Python Global Interpreter Lock ----------------------------------- - -Python's Global Interpretor Lock (GIL) must be acquired before calls can be -made to the Python API. It should also be released when a potentially -blocking call to C/C++ library is made in order to allow other Python threads -to be executed. In addition, some C/C++ libraries may implement their own -locking strategies that conflict with the GIL causing application deadlocks. -SIP provides ways of specifying when the GIL is released and acquired to -ensure that locking problems can be avoided. - -SIP always ensures that the GIL is acquired before making calls to the Python -API. By default SIP does not release the GIL when making calls to the C/C++ -library being wrapped. The ReleaseGIL_ annotation can be used to override -this behaviour when required. - -If SIP is given the ``-g`` command line option then the default behaviour is -changed and SIP releases the GIL every time is makes calls to the C/C++ -library being wrapped. The HoldGIL_ annotation can be used to override this -behaviour when required. - - -The SIP Command Line -==================== - -The syntax of the SIP command line is:: - - sip [options] [specification] - -``specification`` is the name of the specification file for the module. If it -is omitted then ``stdin`` is used. - -The full set of command line options is: - --h Display a help message. --V Display the SIP version number. --a file - The name of the QScintilla API file to generate. This file contains a - description of the module API in a form that the QScintilla editor - component can use for auto-completion and call tips. (The file may - also be used by the SciTE editor but must be sorted first.) By default - the file is not generated. --b file - The name of the build file to generate. This file contains the - information about the module needed by the SIP build system to generate - a platform and compiler specific Makefile for the module. By default - the file is not generated. --c dir The name of the directory (which must exist) into which all of the - generated C or C++ code is placed. By default no code is generated. --d file - The name of the documentation file to generate. Documentation is - included in specification files using the `%Doc`_ and `%ExportedDoc`_ - directives. By default the file is not generated. --e Support for C++ exceptions is enabled. This causes all calls to C++ - code to be enclosed in ``try``/``catch`` blocks and C++ exceptions to - be converted to Python exceptions. By default exception support is - disabled. --g The Python GIL is released before making any calls to the C/C++ library - being wrapped and reacquired afterwards. See `The Python Global - Interpreter Lock`_ and the ReleaseGIL_ and HoldGIL_ annotations. --I dir The directory is added to the list of directories searched when looking - for a specification file given in an `%Include`_ or `%Import`_ - directive. This option may be given any number of times. --j number - The generated code is split into the given number of files. This make - it easier to use the parallel build facility of most modern - implementations of ``make``. By default 1 file is generated for each C - structure or C++ class. --r Debugging statements that trace the execution of the bindings are - automatically generated. By default the statements are not generated. --s suffix - The suffix to use for generated C or C++ source files. By default - ``.c`` is used for C and ``.cpp`` for C++. --t tag The SIP version tag (declared using a `%Timeline`_ directive) or the - SIP platform tag (declared using the `%Platforms`_ directive) to - generate code for. This option may be given any number of times so - long as the tags do not conflict. --w The display of warning messages is enabled. By default warning - messages are disabled. --x feature - The feature (declared using the `%Feature`_ directive) is disabled. --z file - The name of a file containing more command line options. - - -SIP Specification Files -======================= - -A SIP specification consists of some C/C++ type and function declarations and -some directives. The declarations may contain annotations which provide SIP -with additional information that cannot be expressed in C/C++. SIP does not -include a full C/C++ parser. - -It is important to understand that a SIP specification describes the Python -API, i.e. the API available to the Python programmer when they ``import`` the -generated module. It does not have to accurately represent the underlying -C/C++ library. There is nothing wrong with omitting functions that make -little sense in a Python context, or adding functions implemented with -handwritten code that have no C/C++ equivalent. It is even possible (and -sometimes necessary) to specify a different super-class hierarchy for a C++ -class. All that matters is that the generated code compiles properly. - -In most cases the Python API matches the C/C++ API. In some cases handwritten -code (see `%MethodCode`_) is used to map from one to the other without SIP -having to know the details itself. However, there are a few cases where SIP -generates a thin wrapper around a C++ method or constructor (see `Generated -Derived Classes`_) and needs to know the exact C++ signature. To deal with -these cases SIP allows two signatures to be specified. For example:: - - class Klass - { - public: - // The Python signature is a tuple, but the underlying C++ signature - // is a 2 element array. - Klass(SIP_PYTUPLE) [(int *)]; - %MethodCode - int iarr[2]; - - if (PyArg_ParseTuple(a0, "ii", &iarr[0], &iarr[1])) - { - // Note that we use the SIP generated derived class - // constructor. - Py_BEGIN_ALLOW_THREADS - sipCpp = new sipKlass(iarr); - Py_END_ALLOW_THREADS - } - %End - }; - - -Syntax Definition ------------------ - -The following is a semi-formal description of the syntax of a specification -file. - -.. parsed-literal:: - - *specification* ::= {*module-statement*} - - *module-statement* ::= [*module-directive* | *statement*] - - *module-directive* ::= [`%CModule`_ | `%Copying`_ | `%Doc`_ | - `%ExportedDoc`_ | `%ExportedHeaderCode`_ | `%Feature`_ | - `%Import`_ | `%Include`_ | `%License`_ | `%MappedType`_ | - *mapped-type-template* | `%Module`_ | `%ModuleCode`_ | - `%ModuleHeaderCode`_ | `%OptionalInclude`_ | `%Platforms`_ | - `%PreInitialisationCode`_ | `%PostInitialisationCode`_ | - *sip-option-list* | `%Timeline`_ | `%UnitCode`_] - - *sip-option-list* :: `%SIPOptions`_ ``(`` *option-list* ``)`` - - *option-list* ::= *option* [``,`` *option-list*] - - *statement* :: [*class-statement* | *function* | *variable*] - - *class-statement* :: [`%If`_ | *class* | *class-template* | *enum* | - *namespace* | *opaque-class* | *operator* | *struct* | *typedef* | - *exception*] - - *class* ::= ``class`` *name* [``:`` *super-classes*] [*class-annotations*] - ``{`` {*class-line*} ``};`` - - *super-classes* ::= *name* [``,`` *super-classes*] - - *class-line* ::= [*class-statement* | `%BIGetReadBufferCode`_ | - `%BIGetWriteBufferCode`_ | `%BIGetSegCountCode`_ | - `%BIGetCharBufferCode`_ | `%ConvertToSubClassCode`_ | - `%ConvertToTypeCode`_ | `%GCClearCode`_ | `%GCTraverseCode`_ | - `%TypeCode`_ | `%TypeHeaderCode`_ | *constructor* | *destructor* | - *method* | *static-method* | *virtual-method* | *special-method* | - *operator* | *virtual-operator* | *class-variable* | ``public:`` | - ``public slots:`` | ``protected:`` | ``protected slots:`` | - ``private:`` | ``private slots:`` | ``signals:``] - - *constructor* ::= [``explicit``] *name* ``(`` [*argument-list*] ``)`` - [*exceptions*] [*function-annotations*] - [*c++-constructor-signature*] ``;`` [`%MethodCode`_] - - *c++-constructor-signature* ::= ``[(`` [*argument-list*] ``)]`` - - *destructor* ::= [``virtual``] ``~`` *name* ``()`` [*exceptions*] [``= 0``] - [*function-annotations*] ``;`` [`%MethodCode`_] - [`%VirtualCatcherCode`_] - - *method* ::= *type* *name* ``(`` [*argument-list*] ``)`` [``const``] - [*exceptions*] [``= 0``] [*function-annotations*] [*c++-signature*] - ``;`` [`%MethodCode`_] - - *c++-signature* ::= ``[`` *type* ``(`` [*argument-list*] ``)]`` - - *static-method* ::= ``static`` *function* - - *virtual-method* ::= ``virtual`` *type* *name* ``(`` [*argument-list*] ``)`` - [``const``] [*exceptions*] [``= 0``] [*function-annotations*] - [*c++-signature*] ``;`` [`%MethodCode`_] [`%VirtualCatcherCode`_] - - *special-method* ::= *type* *special-method-name* - ``(`` [*argument-list*] ``)`` [*function-annotations*] ``;`` - [`%MethodCode`_] - - *special-method-name* ::= [ ``__abs__`` | ``__add__`` | ``__and__`` | - ``__call__`` | ``__cmp__`` | ``__contains__`` | ``__delitem__`` | - ``__div__`` | ``__eq__`` | ``__float__`` | ``__ge__`` | - ``__getitem__`` | ``__gt__`` | ``__hash__`` | ``__iadd__`` | - ``__iand__`` | ``__idiv__`` | ``__ilshift__`` | ``__imod__`` | - ``__imul__`` | ``__int__`` | ``__invert__`` | ``__ior__`` | - ``__irshift__`` | ``__isub__`` | ``__ixor__`` | ``__le__`` | - ``__len__`` | ``__long__`` | ``__lshift__`` | ``__lt__`` | - ``__mod__`` | ``__mul__`` | ``__ne__`` | ``__neg__`` | - ``__nonzero__`` | ``__or__`` | ``__pos__`` | ``__repr__`` | - ``__rshift__`` | ``__setitem__`` | ``__str__`` | ``__sub__`` | - ``__xor__``] - - *operator* ::= *operator-type* - ``(`` [*argument-list*] ``)`` [``const``] [*exceptions*] - [*function-annotations*] ``;`` [`%MethodCode`_] - - *virtual-operator* ::= ``virtual`` *operator-type* - ``(`` [*argument-list*] ``)`` [``const``] [*exceptions*] [``= 0``] - [*function-annotations*] ``;`` [`%MethodCode`_] - [`%VirtualCatcherCode`_] - - *operatator-type* ::= [ *operator-function* | *operator-cast* ] - - *operator-function* ::= *type* ``operator`` *operator-name* - - *operator-cast* ::= ``operator`` *type* - - *operator-name* ::= [``+`` | ``-`` | ``*`` | ``/`` | ``%`` | ``&`` | - ``|`` | ``^`` | ``<<`` | ``>>`` | ``+=`` | ``-=`` | ``*=`` | - ``/=`` | ``%=`` | ``&=`` | ``|=`` | ``^=`` | ``<<=`` | ``>>=`` | - ``~`` | ``()`` | ``[]`` | ``<`` | ``<=`` | ``==`` | ``!=`` | - ``>`` | ``>>=``] - - *class-variable* ::= [``static``] *variable* - - *class-template* :: = ``template`` ``<`` *type-list* ``>`` *class* - - *mapped-type-template* :: = ``template`` ``<`` *type-list* ``>`` - `%MappedType`_ - - *enum* ::= ``enum`` [*name*] [*enum-annotations*] ``{`` {*enum-line*} ``};`` - - *enum-line* ::= [`%If`_ | *name* [*enum-annotations*] ``,`` - - *function* ::= *type* *name* ``(`` [*argument-list*] ``)`` [*exceptions*] - [*function-annotations*] ``;`` [`%MethodCode`_] - - *namespace* ::= ``namespace`` *name* ``{`` {*namespace-line*} ``};`` - - *namespace-line* ::= [`%TypeHeaderCode`_ | *statement*] - - *opaque-class* ::= ``class`` *scoped-name* ``;`` - - *struct* ::= ``struct`` *name* ``{`` {*class-line*} ``};`` - - *typedef* ::= ``typedef`` [*typed-name* | *function-pointer*] ``;`` - - *variable*::= *typed-name* [*variable-annotations*] ``;`` [`%AccessCode`_] - [`%GetCode`_] [`%SetCode`_] - - *exception* ::= `%Exception`_ *exception-name* [*exception-base*] ``{`` - [`%TypeHeaderCode`_] `%RaiseCode`_ `};`` - - *exception-name* ::= *scoped-name* - - *exception-base* ::= ``(`` [*exception-name* | *python-exception*] ``)`` - - *python-exception* ::= [``SIP_Exception`` | ``SIP_StopIteration`` | - ``SIP_StandardError`` | ``SIP_ArithmeticError`` | - ``SIP_LookupError`` | ``SIP_AssertionError`` | - ``SIP_AttributeError`` | ``SIP_EOFError`` | - ``SIP_FloatingPointError`` | ``SIP_EnvironmentError`` | - ``SIP_IOError`` | ``SIP_OSError`` | ``SIP_ImportError`` | - ``SIP_IndexError`` | ``SIP_KeyError`` | ``SIP_KeyboardInterrupt`` | - ``SIP_MemoryError`` | ``SIP_NameError`` | ``SIP_OverflowError`` | - ``SIP_RuntimeError`` | ``SIP_NotImplementedError`` | - ``SIP_SyntaxError`` | ``SIP_IndentationError`` | ``SIP_TabError`` | - ``SIP_ReferenceError`` | ``SIP_SystemError`` | ``SIP_SystemExit`` | - ``SIP_TypeError`` | ``SIP_UnboundLocalError`` | - ``SIP_UnicodeError`` | ``SIP_UnicodeEncodeError`` | - ``SIP_UnicodeDecodeError`` | ``SIP_UnicodeTranslateError`` | - ``SIP_ValueError`` | ``SIP_ZeroDivisionError`` | - ``SIP_WindowsError`` | ``SIP_VMSError``] - - *exceptions* ::= ``throw (`` [*exception-list*] ``)`` - - *exception-list* ::= *scoped-name* [``,`` *exception-list*] - - *argument-list* ::= *argument* [``,`` *argument-list*] [``,`` ``...``] - - *argument* ::= [*type* [*name*] [*argument-annotations*] - [*default-value*] | SIP_ANYSLOT_ [*default-value*] | SIP_QOBJECT_ | - SIP_RXOBJ_CON_ | SIP_RXOBJ_DIS_ | SIP_SIGNAL_ [*default-value*] | - SIP_SLOT_ [*default-value*] | SIP_SLOT_CON_ | SIP_SLOT_DIS_] - - *default-value* ::= ``=`` *expression* - - *expression* ::= [*value* | *value* *binary-operator* *expression*] - - *value* ::= [*unary-operator*] *simple-value* - - *simple-value* ::= [*scoped-name* | *function-call* | *real-value* | - *integer-value* | *boolean-value* | *string-value* | - *character-value*] - - *typed-name*::= *type* *name* - - *function-pointer*::= *type* ``(*`` *name* ``)(`` [*type-list*] ``)`` - - *type-list* ::= *type* [``,`` *type-list*] - - *function-call* ::= *scoped-name* ``(`` [*value-list*] ``)`` - - *value-list* ::= *value* [``,`` *value-list*] - - *real-value* ::= a floating point number - - *integer-value* ::= a number - - *boolean-value* ::= [``true`` | ``false``] - - *string-value* ::= ``"`` {*character*} ``"`` - - *character-value* ::= ````` *character* ````` - - *unary-operator* ::= [``!`` | ``~`` | ``-`` | ``+``] - - *binary-operator* ::= [``-`` | ``+`` | ``*`` | ``/`` | ``&`` | ``|``] - - *argument-annotations* ::= see `Argument Annotations`_ - - *class-annotations* ::= see `Class Annotations`_ - - *enum-annotations* ::= see `Enum Annotations`_ - - *function-annotations* ::= see `Function Annotations`_ - - *variable-annotations* ::= see `Variable Annotations`_ - - *type* ::= [``const``] *base-type* {``*``} [``&``] - - *type-list* ::= *type* [``,`` *type-list*] - - *base-type* ::= [*scoped-name* | *template* | ``struct`` *scoped-name* | - ``short`` | ``unsigned short`` | ``int`` | ``unsigned`` | - ``unsigned int`` | ``long`` | ``unsigned long`` | ``float`` | - ``double`` | ``bool`` | ``char`` | ``signed char`` | - ``unsigned char`` | ``void`` | ``wchar_t`` | SIP_PYCALLABLE_ | - SIP_PYDICT_ | SIP_PYLIST_ | SIP_PYOBJECT_ | SIP_PYSLICE_ | - SIP_PYTUPLE_ | SIP_PYTYPE_] - - *scoped-name* ::= *name* [``::`` *scoped-name*] - - *template* ::= *scoped-name* ``<`` *type-list* ``>`` - - *name* ::= _A-Za-z {_A-Za-z0-9} - -Here is a short list of differences between C++ and the subset supported by -SIP that might trip you up. - - - SIP does not support the use of ``[]`` in types. Use pointers instead. - - - A global ``operator`` can only be defined if its first argument is a - class or a named enum that has been wrapped in the same module. - - - Variables declared outside of a class are effectively read-only. - - - A class's list of super-classes doesn't not include any access specifier - (e.g. ``public``). - - -Variable Numbers of Arguments ------------------------------ - -SIP supports the use of ``...`` as the last part of a function signature. Any -remaining arguments are collected as a Python tuple. - - -Additional SIP Types --------------------- - -SIP supports a number of additional data types that can be used in Python -signatures. - - -SIP_ANYSLOT -*********** - -This is both a ``const char *`` and a ``PyObject *`` that is used as the type -of the member instead of ``const char *`` in functions that implement the -connection or disconnection of an explicitly generated signal to a slot. -Handwritten code must be provided to interpret the conversion correctly. - - -SIP_PYCALLABLE -************** - -This is a ``PyObject *`` that is a Python callable object. - - -SIP_PYDICT -********** - -This is a ``PyObject *`` that is a Python dictionary object. - - -SIP_PYLIST -********** - -This is a ``PyObject *`` that is a Python list object. - - -SIP_PYOBJECT -************ - -This is a ``PyObject *`` of any Python type. - - -SIP_PYSLICE -*********** - -This is a ``PyObject *`` that is a Python slice object. - - -SIP_PYTUPLE -*********** - -This is a ``PyObject *`` that is a Python tuple object. - - -SIP_PYTYPE -********** - -This is a ``PyObject *`` that is a Python type object. - - -SIP_QOBJECT -*********** - -This is a ``QObject *`` that is a C++ instance of a class derived from Qt's -``QObject`` class. - - -SIP_RXOBJ_CON -************* - -This is a ``QObject *`` that is a C++ instance of a class derived from Qt's -``QObject`` class. It is used as the type of the receiver instead of ``const -QObject *`` in functions that implement a connection to a slot. - - -SIP_RXOBJ_DIS -************* - -This is a ``QObject *`` that is a C++ instance of a class derived from Qt's -``QObject`` class. It is used as the type of the receiver instead of ``const -QObject *`` in functions that implement a disconnection from a slot. - - -SIP_SIGNAL -********** - -This is a ``const char *`` that is used as the type of the signal instead of -``const char *`` in functions that implement the connection or disconnection -of an explicitly generated signal to a slot. - - -SIP_SLOT -******** - -This is a ``const char *`` that is used as the type of the member instead of -``const char *`` in functions that implement the connection or disconnection -of an explicitly generated signal to a slot. - - -SIP_SLOT_CON -************ - -This is a ``const char *`` that is used as the type of the member instead of -``const char *`` in functions that implement the connection of an internally -generated signal to a slot. The type includes a comma separated list of types -that is the C++ signature of of the signal. - -To take an example, ``QAccel::connectItem()`` connects an internally generated -signal to a slot. The signal is emitted when the keyboard accelerator is -activated and it has a single integer argument that is the ID of the -accelerator. The C++ signature is:: - - bool connectItem(int id, const QObject *receiver, const char *member); - -The corresponding SIP specification is:: - - bool connectItem(int, SIP_RXOBJ_CON, SIP_SLOT_CON(int)); - - -SIP_SLOT_DIS -************ - -This is a ``const char *`` that is used as the type of the member instead of -``const char *`` in functions that implement the disconnection of an -internally generated signal to a slot. The type includes a comma separated -list of types that is the C++ signature of of the signal. - - -SIP Directives -============== - -In this section we describe each of the directives that can be used in -specification files. All directives begin with ``%`` as the first -non-whitespace character in a line. - -Some directives have arguments or contain blocks of code or documentation. In -the following descriptions these are shown in *italics*. Optional arguments -are enclosed in [*brackets*]. - -Some directives are used to specify handwritten code. Handwritten code must -not define names that start with the prefix ``sip``. - - -%AccessCode ------------ - -.. parsed-literal:: - - %AccessCode - *code* - %End - -This directive is used immediately after the declaration of an instance of a -wrapped class or structure, or a pointer to such an instance. You use it to -provide handwritten code that overrides the default behaviour. - -For example:: - - class Klass; - - Klass *klassInstance; - %AccessCode - // In this contrived example the C++ library we are wrapping defines - // klassInstance as Klass ** (which SIP doesn't support) so we - // explicitly dereference it. - if (klassInstance && *klassInstance) - return *klassInstance; - - // This will get converted to None. - return 0; - %End - - -%BIGetCharBufferCode --------------------- - -.. parsed-literal:: - - %BIGetCharBufferCode - *code* - %End - -This directive (along with `%BIGetReadBufferCode`_, `%BIGetSegCountCode`_ and -`%BIGetWriteBufferCode`_) is used to specify code that implements Python's -buffer interface. See the section `Buffer Object Structures -<http://www.python.org/dev/doc/devel/api/buffer-structs.html>`__ for the -details. - -The following variables are made available to the handwritten code: - -*type* \*sipCpp - This is a pointer to the structure or class instance. Its *type* is a - pointer to the structure or class. - -void \*\*sipPtrPtr - This is the pointer used to return the address of the character buffer. - -SIP_SSIZE_T sipRes - The handwritten code should set this to the length of the character buffer - or -1 if there was an error. - -SIP_SSIZE_T sipSegment - This is the number of the segment of the character buffer. - -PyObject \*sipSelf - This is the Python object that wraps the the structure or class instance, - i.e. ``self``. - - -%BIGetReadBufferCode --------------------- - -.. parsed-literal:: - - %BIGetReadBufferCode - *code* - %End - -This directive (along with `%BIGetCharBufferCode`_, `%BIGetSegCountCode`_ and -`%BIGetWriteBufferCode`_) is used to specify code that implements Python's -buffer interface. - -The following variables are made available to the handwritten code: - -*type* \*sipCpp - This is a pointer to the structure or class instance. Its *type* is a - pointer to the structure or class. - -void \*\*sipPtrPtr - This is the pointer used to return the address of the read buffer. - -SIP_SSIZE_T sipRes - The handwritten code should set this to the length of the read buffer or - -1 if there was an error. - -SIP_SSIZE_T sipSegment - This is the number of the segment of the read buffer. - -PyObject \*sipSelf - This is the Python object that wraps the the structure or class instance, - i.e. ``self``. - - -%BIGetSegCountCode ------------------- - -.. parsed-literal:: - - %BIGetSegCountCode - *code* - %End - -This directive (along with `%BIGetCharBufferCode`_, `%BIGetReadBufferCode`_ and -`%BIGetWriteBufferCode`_) is used to specify code that implements Python's -buffer interface. - -The following variables are made available to the handwritten code: - -*type* \*sipCpp - This is a pointer to the structure or class instance. Its *type* is a - pointer to the structure or class. - -SIP_SSIZE_T \*sipLenPtr - This is the pointer used to return the total length in bytes of all - segments of the buffer. - -SIP_SSIZE_T sipRes - The handwritten code should set this to the number of segments that make - up the buffer. - -PyObject \*sipSelf - This is the Python object that wraps the the structure or class instance, - i.e. ``self``. - - -%BIGetWriteBufferCode ---------------------- - -.. parsed-literal:: - - %BIGetWriteBufferCode - *code* - %End - -This directive (along with `%BIGetCharBufferCode`_, `%BIGetReadBufferCode`_ -and `%BIGetSegCountCode`_ is used to specify code that implements Python's -buffer interface. - -The following variables are made available to the handwritten code: - -*type* \*sipCpp - This is a pointer to the structure or class instance. Its *type* is a - pointer to the structure or class. - -void \*\*sipPtrPtr - This is the pointer used to return the address of the write buffer. - -SIP_SSIZE_T sipRes - The handwritten code should set this to the length of the write buffer or - -1 if there was an error. - -SIP_SSIZE_T sipSegment - This is the number of the segment of the write buffer. - -PyObject \*sipSelf - This is the Python object that wraps the the structure or class instance, - i.e. ``self``. - - -%CModule --------- - -.. parsed-literal:: - - %CModule *name* [*version*] - -This directive is used to identify that the library being wrapped is a C -library and to define the name of the module and it's optional version number. - -See the `%Module`_ directive for an explanation of the version number. - -For example:: - - %CModule dbus 1 - - -%ConvertFromTypeCode --------------------- - -.. parsed-literal:: - - %ConvertFromTypeCode - *code* - %End - -This directive is used as part of the `%MappedType`_ directive to specify the -handwritten code that converts an instance of a mapped type to a Python -object. - -The following variables are made available to the handwritten code: - -*type* \*sipCpp - This is a pointer to the instance of the mapped type to be converted. It - will never be zero as the conversion from zero to ``Py_None`` is handled - before the handwritten code is called. - -PyObject \*sipTransferObj - This specifies any desired ownership changes to the returned object. If it - is ``NULL`` then the ownership should be left unchanged. If it is - ``Py_None`` then ownership should be transferred to Python. Otherwise - ownership should be transferred to C/C++ and the returned object associated - with *sipTransferObj*. The code can choose to interpret these changes in - any way. For example, if the code is converting a C++ container of wrapped - classes to a Python list it is likely that the ownership changes should be - made to each element of the list. - -The handwritten code must explicitly return a ``PyObject *``. If there was an -error then a Python exception must be raised and ``NULL`` returned. - -The following example converts a ``QList<QWidget *>`` instance to a Python -list of ``QWidget`` instances:: - - %ConvertFromTypeCode - PyObject *l; - - // Create the Python list of the correct length. - if ((l = PyList_New(sipCpp -> size())) == NULL) - return NULL; - - // Go through each element in the C++ instance and convert it to a - // wrapped QWidget. - for (int i = 0; i < sipCpp -> size(); ++i) - { - QWidget *w = sipCpp -> at(i); - PyObject *wobj; - - // Get the Python wrapper for the QWidget instance, creating a new - // one if necessary, and handle any ownership transfer. - if ((wobj = sipConvertFromInstance(w, sipClass_QWidget, sipTransferObj)) == NULL) - { - // There was an error so garbage collect the Python list. - Py_DECREF(l); - return NULL; - } - - // Add the wrapper to the list. - PyList_SET_ITEM(l, i, wobj); - } - - // Return the Python list. - return l; - %End - - -%ConvertToSubClassCode ----------------------- - -.. parsed-literal:: - - %ConvertToSubClassCode - *code* - %End - -When SIP needs to wrap a C++ class instance it first checks to make sure it -hasn't already done so. If it has then it just returns a new reference to the -corresponding Python object. Otherwise it creates a new Python object of the -appropriate type. In C++ a function may be defined to return an instance of a -certain class, but can often return a sub-class instead. - -This directive is used to specify handwritten code that exploits any available -real-time type information (RTTI) to see if there is a more specific Python -type that can be used when wrapping the C++ instance. The RTTI may be -provided by the compiler or by the C++ instance itself. - -The directive is included in the specification of one of the classes that the -handwritten code handles the type conversion for. It doesn't matter which -one, but a sensible choice would be the one at the root of that class -hierarchy in the module. - -Note that if a class hierarchy extends over a number of modules then this -directive should be used in each of those modules to handle the part of the -hierarchy defined in that module. SIP will ensure that the different pieces -of code are called in the right order to determine the most specific Python -type to use. - -The following variables are made available to the handwritten code: - -*type* \*sipCpp - This is a pointer to the C++ class instance. - -void \*\*sipCppRet - When the sub-class is derived from more than one super-class then it is - possible that the C++ address of the instance as the sub-class is - different to that of the super-class. If so, then this must be set to the - C++ address of the instance when cast (usually using ``static_cast``) - from the super-class to the sub-class. - -sipWrapperType \*sipClass - The handwritten code must set this to the SIP generated Python type object - that corresponds to the class instance. (The type object for class - ``Klass`` is ``sipClass_Klass``.) If the RTTI of the class instance isn't - recognised then ``sipClass`` must be set to ``NULL``. The code doesn't - have to recognise the exact class, only the most specific sub-class that - it can. - -The handwritten code must not explicitly return. - -The following example shows the sub-class conversion code for ``QEvent`` based -class hierarchy in PyQt:: - - class QEvent - { - %ConvertToSubClassCode - // QEvent sub-classes provide a unique type ID. - switch (sipCpp -> type()) - { - case QEvent::Timer: - sipClass = sipClass_QTimerEvent; - break; - - case QEvent::KeyPress: - case QEvent::KeyRelease: - sipClass = sipClass_QKeyEvent; - break; - - // Skip the remaining event types to keep the example short. - - default: - // We don't recognise the type. - sipClass = NULL; - } - %End - - // The rest of the class specification. - - }; - -The SIP API includes the `sipMapIntToClass()`_ and `sipMapStringToClass()`_ -functions that convert integer and string based RTTI to Python type objects -based on ordered lookup tables. - - -%ConvertToTypeCode ------------------- - -.. parsed-literal:: - - %ConvertToTypeCode - *code* - %End - -This directive is used to specify the handwritten code that converts a Python -object to a mapped type instance and to handle any ownership transfers. It is -used as part of the `%MappedType`_ directive and as part of a class -specification. The code is also called to determine if the Python object is of -the correct type prior to conversion. - -When used as part of a class specification it can automatically convert -additional types of Python object. For example, PyQt uses it in the -specification of the ``QString`` class to allow Python string objects and -unicode objects to be used wherever ``QString`` instances are expected. - -The following variables are made available to the handwritten code: - -int \*sipIsErr - If this is ``NULL`` then the code is being asked to check the type of the - Python object. The check must not have any side effects. Otherwise the - code is being asked to convert the Python object and a non-zero value - should be returned through this pointer if an error occurred during the - conversion. - -PyObject \*sipPy - This is the Python object to be converted. - -*type* \*\*sipCppPtr - This is a pointer through which the address of the mapped type instance (or - zero if appropriate) is returned. Its value is undefined if ``sipIsErr`` - is ``NULL``. - -PyObject \*sipTransferObj - This specifies any desired ownership changes to *sipPy*. If it is ``NULL`` - then the ownership should be left unchanged. If it is ``Py_None`` then - ownership should be transferred to Python. Otherwise ownership should be - transferred to C/C++ and *sipPy* associated with *sipTransferObj*. The - code can choose to interpret these changes in any way. - -The handwritten code must explicitly return an ``int`` the meaning of which -depends on the value of ``sipIsErr``. - -If ``sipIsErr`` is ``NULL`` then a non-zero value is returned if the Python -object has a type that can be converted to the mapped type. Otherwise zero is -returned. - -If ``sipIsErr`` is not ``NULL`` then a combination of the following flags is -returned. - - - ``SIP_TEMPORARY`` is set to indicate that the returned instance is a - temporary and should be released to avoid a memory leak. - - - ``SIP_DERIVED_CLASS`` is set to indicate that the type of the - returned instance is a derived class. See `Generated Derived - Classes`_. - -The following example converts a Python list of ``QPoint`` instances to a -``QList<QPoint>`` instance:: - - %ConvertToTypeCode - // See if we are just being asked to check the type of the Python - // object. - if (!sipIsErr) - { - // Checking whether or not None has been passed instead of a list - // has already been done. - if (!PyList_Check(sipPy)) - return 0; - - // Check the type of each element. We specify SIP_NOT_NONE to - // disallow None because it is a list of QPoint, not of a pointer - // to a QPoint, so None isn't appropriate. - for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) - if (!sipCanConvertToInstance(PyList_GET_ITEM(sipPy, i), - sipClass_QPoint, SIP_NOT_NONE)) - return 0; - - // The type is valid. - return 1; - } - - // Create the instance on the heap. - QList<QPoint> *ql = new QList<QPoint>; - - for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) - { - QPoint *qp; - int state; - - // Get the address of the element's C++ instance. Note that, in - // this case, we don't apply any ownership changes to the list - // elements, only to the list itself. - qp = reinterpret_cast<QPoint *>(sipConvertToInstance( - PyList_GET_ITEM(sipPy, i), - sipClass_QPoint, 0, - SIP_NOT_NONE, - &state, sipIsErr)); - - // Deal with any errors. - if (*sipIsErr) - { - sipReleaseInstance(qp, sipClass_QPoint, state); - - // Tidy up. - delete ql; - - // There is no temporary instance. - return 0; - } - - ql -> append(*qp); - - // A copy of the QPoint was appended to the list so we no longer - // need it. It may be a temporary instance that should be - // destroyed, or a wrapped instance that should not be destroyed. - // sipReleaseInstance() will do the right thing. - sipReleaseInstance(qp, sipClass_QPoint, state); - } - - // Return the instance. - *sipCppPtr = ql; - - // The instance should be regarded as temporary (and be destroyed as - // soon as it has been used) unless it has been transferred from - // Python. sipGetState() is a convenience function that implements - // this common transfer behaviour. - return sipGetState(sipTransferObj); - %End - -When used in a class specification the handwritten code replaces the code that -would normally be automatically generated. This means that the handwritten -code must also handle instances of the class itself and not just the additional -types that are being supported. This should be done by making calls to -`sipCanConvertToInstance()`_ to check the object type and -`sipConvertToInstance()`_ to convert the object. The ``SIP_NO_CONVERTORS`` -flag *must* be passed to both these functions to prevent recursive calls to the -handwritten code. - - -%Copying --------- - -.. parsed-literal:: - - %Copying - *text* - %End - -This directive is used to specify some arbitrary text that will be included at -the start of all source files generated by SIP. It is normally used to -include copyright and licensing terms. - -For example:: - - %Copying - Copyright (c) 2007 Riverbank Computing Limited - %End - - -%Doc ----- - -.. parsed-literal:: - - %Doc - *text* - %End - -This directive is used to specify some arbitrary text that will be extracted -by SIP when the ``-d`` command line option is used. The directive can be -specified any number of times and SIP will concatenate all the separate pieces -of text in the order that it sees them. - -Documentation that is specified using this directive is local to the module in -which it appears. It is ignored by modules that `%Import`_ it. Use the -`%ExportedDoc`_ directive for documentation that should be included by all -modules that `%Import`_ this one. - -For example:: - - %Doc - <h1>An Example</h1> - <p> - This fragment of documentation is HTML and is local to the module in - which it is defined. - </p> - %End - - -%End ----- - -This isn't a directive in itself, but is used to terminate a number of -directives that allow a block of handwritten code or text to be specified. - - -%Exception ----------- - -.. parsed-literal:: - - %Exception *name* [(*base-exception)] - { - [*header-code*] - *raise-code* - }; - -This directive is used to define new Python exceptions, or to provide a stub -for existing Python exceptions. It allows handwritten code to be provided -that implements the translation between C++ exceptions and Python exceptions. -The arguments to ``throw ()`` specifiers must either be names of classes or the -names of Python exceptions defined by this directive. - -*name* is the name of the exception. - -*base-exception* is the optional base exception. This may be either one of -the standard Python exceptions or one defined with a previous `%Exception`_ -directive. - -*header-code* is the optional `%TypeHeaderCode`_ used to specify any external -interface to the exception being defined. - -*raise-code* is the `%RaiseCode`_ used to specify the handwritten code that -converts a reference to the C++ exception to the Python exception. - -For example:: - - %Exception std::exception(SIP_Exception) /PyName=StdException/ - { - %TypeHeaderCode - #include <exception> - %End - %RaiseCode - const char *detail = sipExceptionReference.what(); - - SIP_BLOCK_THREADS - PyErr_SetString(sipException_StdException, detail); - SIP_UNBLOCK_THREADS - %End - }; - -In this example we map the standard C++ exception to a new Python exception. -The new exception is called ``StdException`` and is derived from the standard -Python exception ``Exception``. - - -%ExportedDoc ------------- - -.. parsed-literal:: - - %ExportedDoc - *text* - %End - -This directive is used to specify some arbitrary text that will be extracted -by SIP when the ``-d`` command line option is used. The directive can be -specified any number of times and SIP will concatenate all the separate pieces -of text in the order that it sees them. - -Documentation that is specified using this directive will also be included by -modules that `%Import`_ it. - -For example:: - - %ExportedDoc - ========== - An Example - ========== - - This fragment of documentation is reStructuredText and will appear in the - module in which it is defined and all modules that %Import it. - %End - - -%ExportedHeaderCode -------------------- - -.. parsed-literal:: - - %ExportedHeaderCode - *code* - %End - -This directive is used to specify handwritten code, typically the declarations -of types, that is placed in a header file that is included by all generated -code for all modules. It should not include function declarations because -Python modules should not explicitly call functions in another Python module. - -See also `%ModuleCode`_ and `%ModuleHeaderCode`_. - - -%Feature --------- - -.. parsed-literal:: - - %Feature *name* - -This directive is used to declare a feature. Features (along with -`%Platforms`_ and `%Timeline`_) are used by the `%If`_ directive to control -whether or not parts of a specification are processed or ignored. - -Features are mutually independent of each other - any combination of features -may be enabled or disable. By default all features are enabled. The SIP -``-x`` command line option is used to disable a feature. - -If a feature is enabled then SIP will automatically generate a corresponding C -preprocessor symbol for use by handwritten code. The symbol is the name of -the feature prefixed by ``SIP_FEATURE_``. - -For example:: - - %Feature FOO_SUPPORT - - %If (FOO_SUPPORT) - void foo(); - %End - - -%GCClearCode ------------- - -.. parsed-literal:: - - %GCClearCode - *code* - %End - -Python has a cyclic garbage collector which can identify and release unneeded -objects even when their reference counts are not zero. If a wrapped C -structure or C++ class keeps its own reference to a Python object then, if the -garbage collector is to do its job, it needs to provide some handwritten code -to traverse and potentially clear those embedded references. - -See the section *Supporting cyclic garbage collection* in `Embedding and -Extending the Python Interpreter <http://www.python.org/dev/doc/devel/ext/>`__ -for the details. - -This directive is used to specify the code that clears any embedded references. -(See `%GCTraverseCode`_ for specifying the code that traverses any embedded -references.) - -The following variables are made available to the handwritten code: - -*type* \*sipCpp - This is a pointer to the structure or class instance. Its *type* is a - pointer to the structure or class. - -int sipRes - The handwritten code should set this to the result to be returned. - -The following simplified example is taken from PyQt. The ``QCustomEvent`` -class allows arbitary data to be attached to the event. In PyQt this data is -always a Python object and so should be handled by the garbage collector:: - - %GCClearCode - PyObject *obj; - - // Get the object. - obj = reinterpret_cast<PyObject *>(sipCpp -> data()); - - // Clear the pointer. - sipCpp -> setData(0); - - // Clear the reference. - Py_XDECREF(obj); - - // Report no error. - sipRes = 0; - %End - - -%GCTraverseCode ---------------- - -.. parsed-literal:: - - %GCTraverseCode - *code* - %End - -This directive is used to specify the code that traverses any embedded -references for Python's cyclic garbage collector. (See `%GCClearCode`_ for a -full explanation.) - -The following variables are made available to the handwritten code: - -*type* \*sipCpp - This is a pointer to the structure or class instance. Its *type* is a - pointer to the structure or class. - -visitproc sipVisit - This is the visit function provided by the garbage collector. - -void \*sipArg - This is the argument to the visit function provided by the garbage - collector. - -int sipRes - The handwritten code should set this to the result to be returned. - -The following simplified example is taken from PyQt's ``QCustomEvent`` class:: - - %GCTraverseCode - PyObject *obj; - - // Get the object. - obj = reinterpret_cast<PyObject *>(sipCpp -> data()); - - // Call the visit function if there was an object. - if (obj) - sipRes = sipVisit(obj, sipArg); - else - sipRes = 0; - %End - - -%GetCode --------- - -.. parsed-literal:: - - %GetCode - *code* - %End - -This directive is used after the declaration of a C++ class variable or C -structure member to specify handwritten code to convert it to a Python object. -It is usually used to handle types that SIP cannot deal with automatically. - -The following variables are made available to the handwritten code: - -*type* \*sipCpp - This is a pointer to the structure or class instance. Its *type* is a - pointer to the structure or class. It is not made available if the - variable being wrapped is a static class variable. - -PyObject \*sipPy - The handwritten code must set this to the Python representation of the - class variable or structure member. If there is an error then the code - must raise an exception and set this to ``NULL``. - -For example:: - - struct Entity - { - /* - * In this contrived example the C library we are wrapping actually - * defines this as char buffer[100] which SIP cannot handle - * automatically. - */ - char *buffer; - %GetCode - sipPy = PyString_FromStringAndSize(sipCpp -> buffer, 100); - %End - %SetCode - char *ptr; - int length; - - if (PyString_AsStringAndSize(sipPy, &ptr, &length) == -1) - sipErr = 1; - else if (length != 100) - { - /* - * Raise an exception because the length isn't exactly right. - */ - - PyErr_SetString(PyExc_ValueError, "an Entity.buffer must be exactly 100 bytes"); - sipErr = 1; - } - else - memcpy(sipCpp -> buffer, ptr, 100); - %End - } - - -%If ---- - -.. parsed-literal:: - - %If (*expression*) - *specification* - %End - -where - -.. parsed-literal:: - - *expression* ::= [*ored-qualifiers* | *range*] - - *ored-qualifiers* ::= [*qualifier* | *qualifier* ``||`` *ored-qualifiers*] - - *qualifier* ::= [``!``] [*feature* | *platform*] - - *range* ::= [*version*] ``-`` [*version*] - -This directive is used in conjunction with features (see `%Feature`_), -platforms (see `%Platforms`_) and versions (see `%Timeline`_) to control -whether or not parts of a specification are processed or not. - -A *range* of versions means all versions starting with the lower bound up to -but excluding the upper bound. If the lower bound is omitted then it is -interpreted as being before the earliest version. If the upper bound is -omitted then it is interpreted as being after the latest version. - -For example:: - - %Feature SUPPORT_FOO - %Platforms {WIN32_PLATFORM POSIX_PLATFORM MACOS_PLATFORM} - %Timeline {V1_0 V1_1 V2_0 V3_0} - - %If (!SUPPORT_FOO) - // Process this if the SUPPORT_FOO feature is disabled. - %End - - %If (POSIX_PLATFORM || MACOS_PLATFORM) - // Process this if either the POSIX_PLATFORM or MACOS_PLATFORM - // platforms are enabled. - %End - - %If (V1_0 - V2_0) - // Process this if either V1_0 or V1_1 is enabled. - %End - - %If (V2_0 - ) - // Process this if either V2_0 or V3_0 is enabled. - %End - - %If ( - ) - // Always process this. - %End - -Note that this directive is not implemented as a preprocessor. Only the -following parts of a specification are affected by it: - - - ``class`` - - `%ConvertFromTypeCode`_ - - `%ConvertToSubClassCode`_ - - `%ConvertToTypeCode`_ - - ``enum`` - - `%ExportedHeaderCode`_ - - functions - - `%GCClearCode`_ - - `%GCTraverseCode`_ - - `%If`_ - - `%MappedType`_ - - `%MethodCode`_ - - `%ModuleCode`_ - - `%ModuleHeaderCode`_ - - ``namespace`` - - `%PostInitialisationCode`_ - - `%PreInitialisationCode`_ - - ``struct`` - - ``typedef`` - - `%TypeCode`_ - - `%TypeHeaderCode`_ - - `%UnitCode`_ - - variables - - `%VirtualCatcherCode`_ - -Also note that the only way to specify the logical and of qualifiers is to use -nested `%If`_ directives. - - -%Import -------- - -.. parsed-literal:: - - %Import *filename* - -This directive is used to import the specification of another module. This is -needed if the current module makes use of any types defined in the imported -module, e.g. as an argument to a function, or to sub-class. - -If *filename* cannot be opened then SIP prepends *filename* with the name of -the directory containing the current specification file (i.e. the one -containing the `%Import`_ directive) and tries again. If this also fails then -SIP prepends *filename* with each of the directories, in turn, specified by -the ``-I`` command line option. - -For example:: - - %Import qt/qtmod.sip - - -%Include --------- - -.. parsed-literal:: - - %Include *filename* - -This directive is used to include contents of another file as part of the -specification of the current module. It is the equivalent of the C -preprocessor's ``#include`` directive and is used to structure a large module -specification into manageable pieces. - -`%Include`_ follows the same search process as `%Import`_ when trying to open -*filename*. - -For example:: - - %Include qwidget.sip - - -%License --------- - -.. parsed-literal:: - - %License /*license-annotations*/ - -This directive is used to specify the contents of an optional license -dictionary. The license dictionary is called ``__license__`` and is stored in -the module dictionary. The elements of the dictionary are specified using the -Licensee_, Signature_, Timestamp_ and Type_ annotations. Only the Type_ -annotation is compulsory. - -Note that this directive isn't an attempt to impose any licensing restrictions -on a module. It is simply a method for easily embedding licensing information -in a module so that it is accessible to Python scripts. - -For example:: - - %License /Type="GPL"/ - - -%MappedType ------------ - -.. parsed-literal:: - - template<*type-list*> - %MappedType *type* - { - [*header-code*] - [*convert-to-code*] - [*convert-from-code*] - }; - - %MappedType *type* - { - [*header-code*] - [*convert-to-code*] - [*convert-from-code*] - }; - -This directive is used to define an automatic mapping between a C or C++ type -and a Python type. It can be used as part of a template, or to map a specific -type. - -When used as part of a template *type* cannot itself refer to a template. Any -occurrences of any of the type names (but not any ``*`` or ``&``) in -*type-list* will be replaced by the actual type names used when the template is -instantiated. Template mapped types are instantiated automatically as required -(unlike template classes which are only instantiated using ``typedef``). - -Any explicit mapped type will be used in preference to any template that maps -the same type, ie. a template will not be automatically instantiated if there -is an explicit mapped type. - -*header-code* is the `%TypeHeaderCode`_ used to specify the library interface -to the type being mapped. - -*convert-to-code* is the `%ConvertToTypeCode`_ used to specify the handwritten -code that converts a Python object to an instance of the mapped type. - -*convert-from-code* is the `%ConvertFromTypeCode`_ used to specify the -handwritten code that converts an instance of the mapped type to a Python -object. - -For example:: - - template<Type *> - %MappedType QList - { - %TypeHeaderCode - // Include the library interface to the type being mapped. - #include <qlist.h> - %End - - %ConvertToTypeCode - // See if we are just being asked to check the type of the Python - // object. - if (sipIsErr == NULL) - { - // Check it is a list. - if (!PyList_Check(sipPy)) - return 0; - - // Now check each element of the list is of the type we expect. - // The template is for a pointer type so we don't disallow None. - for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) - if (!sipCanConvertToInstance(PyList_GET_ITEM(sipPy, i), - sipClass_Type, 0)) - return 0; - - return 1; - } - - // Create the instance on the heap. - QList<Type *> *ql = new QList<Type *>; - - for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) - { - // Use the SIP API to convert the Python object to the - // corresponding C++ instance. Note that we apply any ownership - // transfer to the list itself, not the individual elements. - Type *t = reinterpret_cast<Type *>(sipConvertToInstance( - PyList_GET_ITEM(sipPy, i), - sipClass_Type, 0, 0, 0, - sipIsErr)); - - if (*sipIsErr) - { - // Tidy up. - delete ql; - - // There is nothing on the heap. - return 0; - } - - // Add the pointer to the C++ instance. - ql -> append(t); - } - - // Return the instance on the heap. - *sipCppPtr = ql; - - // Apply the normal transfer. - return sipGetState(sipTransferObj); - %End - - %ConvertFromTypeCode - PyObject *l; - - // Create the Python list of the correct length. - if ((l = PyList_New(sipCpp -> size())) == NULL) - return NULL; - - // Go through each element in the C++ instance and convert it to the - // corresponding Python object. - for (int i = 0; i < sipCpp -> size(); ++i) - { - Type *t = sipCpp -> at(i); - PyObject *tobj; - - if ((tobj = sipConvertFromInstance(t, sipClass_Type, sipTransferObj)) == NULL) - { - // There was an error so garbage collect the Python list. - Py_DECREF(l); - return NULL; - } - - PyList_SET_ITEM(l, i, tobj); - } - - // Return the Python list. - return l; - %End - } - -Using this we can use, for example, ``QList<QObject *>`` throughout the -module's specification files (and in any module that imports this one). The -generated code will automatically map this to and from a Python list of QObject -instances when appropriate. - - -%MethodCode ------------ - -.. parsed-literal:: - - %MethodCode - *code* - %End - -This directive is used as part of the specification of a global function, class -method, operator, constructor or destructor to specify handwritten code that -replaces the normally generated call to the function being wrapped. It is -usually used to handle argument types and results that SIP cannot deal with -automatically. - -The specified code is embedded in-line after the function's arguments have -been successfully converted from Python objects to their C or C++ equivalents. -The specified code must not include any ``return`` statements. - -In the context of a destructor the specified code is embedded in-line in the -Python type's deallocation function. Unlike other contexts it supplements -rather than replaces the normally generated code, so it must not include code -to return the C structure or C++ class instance to the heap. The code is only -called if ownership of the structure or class is with Python. - -The specified code must also handle the Python Global Interpreter Lock (GIL). -If compatibility with SIP v3.x is required then the GIL must be released -immediately before the C++ call and reacquired immediately afterwards as shown -in this example fragment:: - - Py_BEGIN_ALLOW_THREADS - sipCpp -> foo(); - Py_END_ALLOW_THREADS - -If compatibility with SIP v3.x is not required then this is optional but -should be done if the C++ function might block the current thread or take a -significant amount of time to execute. (See `The Python Global Interpreter -Lock`_ and the ReleaseGIL_ and HoldGIL_ annotations.) - -The following variables are made available to the handwritten code: - -*type* a0 - There is a variable for each argument of the Python signature (excluding - any ``self`` argument) named ``a0``, ``a1``, etc. The *type* of the - variable is the same as the type defined in the specification with the - following exceptions: - - - if the argument is only used to return a value (e.g. it is an ``int *`` - without an In_ annotation) then the type has one less level of - indirection (e.g. it will be an ``int``) - - if the argument is a structure or class (or a reference or a pointer to a - structure or class) then *type* will always be a pointer to the structure - or class. - - Note that handwritten code for destructors never has any arguments. - -PyObject \*a0Wrapper - This variable is made available only if the corresponding argument wraps a - C structure or C++ class instance and the GetWrapper_ annotation is - specified. The variable is a pointer to the Python object that wraps the - argument. - -*type* \*sipCpp - If the directive is used in the context of a class constructor then this - must be set by the handwritten code to the constructed instance. In any - other context then this is a pointer to the C structure or C++ class - instance. Its *type* is a pointer to the structure or class. - -int sipIsErr - The handwritten code should set this to a non-zero value, and raise an - appropriate Python exception, if an error is detected. - - ``sipIsErr`` is not provided for destructors. - -*type* sipRes - The handwritten code should set this to the result to be returned. The - *type* of the variable is the same as the type defined in the Python - signature in the specification with the following exception: - - - if the argument is a structure or class (or a reference or a pointer to a - structure or class) then *type* will always be a pointer to the structure - or class. - - ``sipRes`` is not provided for inplace operators (e.g. ``+=`` or - ``__imul__``) as their results are handled automatically, nor for class - constructors. - -PyObject \*sipSelf - If the directive is used in the context of a class constructor or method - then this is the Python object that wraps the the structure or class - instance, i.e. ``self``. - -bool sipSelfWasArg - This is only made available for non-abstract, virtual methods. It is set - if ``self`` was explicitly passed as the first argument of the method - rather than being bound to the method. In other words, the call was:: - - Klass.foo(self, ...) - - rather than:: - - self.foo(...) - -The following is a complete example:: - - class Klass - { - public: - virtual int foo(SIP_PYTUPLE); - %MethodCode - // The C++ API takes a 2 element array of integers but passing a - // two element tuple is more Pythonic. - - int iarr[2]; - - if (PyArg_ParseTuple(a0, "ii", &iarr[0], &iarr[1])) - { - Py_BEGIN_ALLOW_THREADS - sipRes = sipSelfWasArg ? sipCpp -> Klass::foo(iarr) - : sipCpp -> foo(iarr); - Py_END_ALLOW_THREADS - } - else - { - // PyArg_ParseTuple() will have raised the exception. - sipIsErr = 1; - } - %End - }; - -As the example is a virtual method [#]_, note the use of ``sipSelfWasArg`` to -determine exactly which implementation of ``foo()`` to call. - -If a method is in the ``protected`` section of a C++ class then the call -should instead be:: - - sipRes = sipCpp -> sipProtectVirt_foo(sipSelfWasArg, iarr); - -If a method is in the ``protected`` section of a C++ class but is not virtual -then the call should instead be:: - - sipRes = sipCpp -> sipProtect_foo(iarr); - -.. [#] See `%VirtualCatcherCode`_ for a description of how SIP generated code - handles the reimplementation of C++ virtual methods in Python. - - -%Module -------- - -.. parsed-literal:: - - %Module *name* [*version*] - -This directive is used to identify that the library being wrapped is a C++ -library and to define the name of the module and it's optional version number. - -The name may contain periods to specify that the module is part of a Python -package. - -The optional version number is useful if you (or others) might create other -modules that build on this module, i.e. if another module might `%Import`_ -this module. Under the covers, a module exports an API that is used by modules -that `%Import`_ it and the API is given a version number. A module built on -that module knows the version number of the API that it is expecting. If, -when the modules are imported at run-time, the version numbers do not match -then a Python exception is raised. The dependent module must then be re-built -using the correct specification files for the base module. - -The version number should be incremented whenever a module is changed. Some -changes don't affect the exported API, but it is good practice to change the -version number anyway. - -For example:: - - %Module qt 5 - - -%ModuleCode ------------ - -.. parsed-literal:: - - %ModuleCode - *code* - %End - -This directive is used to specify handwritten code, typically the -implementations of utility functions, that can be called by other handwritten -code in the module. - -For example:: - - %ModuleCode - // Print an object on stderr for debugging purposes. - void dump_object(PyObject *o) - { - PyObject_Print(o, stderr, 0); - fprintf(stderr, "\n"); - } - %End - -See also `%ExportedHeaderCode`_ and `%ModuleHeaderCode`_. - - -%ModuleHeaderCode ------------------ - -.. parsed-literal:: - - %ModuleHeaderCode - *code* - %End - -This directive is used to specify handwritten code, typically the declarations -of utility functions, that is placed in a header file that is included by all -generated code for the same module. - -For example:: - - %ModuleHeaderCode - void dump_object(PyObject *o); - %End - -See also `%ExportedHeaderCode`_ and `%ModuleCode`_. - - -%OptionalInclude ----------------- - -.. parsed-literal:: - - %OptionalInclude *filename* - -This directive is identical to the `%Include`_ directive except that SIP -silently continues processing if *filename* could not be opened. - -For example:: - - %OptionalInclude license.sip - - -%Platforms ----------- - -.. parsed-literal:: - - %Platforms {*name* *name* ...} - -This directive is used to declare a set of platforms. Platforms (along with -`%Feature`_ and `%Timeline`_) are used by the `%If`_ directive to control -whether or not parts of a specification are processed or ignored. - -Platforms are mutually exclusive - only one platform can be enabled at a time. -By default all platforms are disabled. The SIP ``-t`` command line option is -used to enable a platform. - -For example:: - - %Platforms {WIN32_PLATFORM POSIX_PLATFORM MACOS_PLATFORM} - - %If (WIN32_PLATFORM) - void undocumented(); - %End - - %If (POSIX_PLATFORM) - void documented(); - %End - - -%PostInitialisationCode ------------------------ - -.. parsed-literal:: - - %PostInitialisationCode - *code* - %End - -This directive is used to specify handwritten code that is embedded in-line -at the very end of the generated module initialisation code. - -The following variables are made available to the handwritten code: - -PyObject \*sipModule - This is the module object returned by ``Py_InitModule()``. - -PyObject \*sipModuleDict - This is the module's dictionary object returned by ``Py_ModuleGetDict()``. - -For example:: - - %PostInitialisationCode - // The code will be executed when the module is first imported and - // after all other initialisation has been completed. - %End - - -%PreInitialisationCode ----------------------- - -.. parsed-literal:: - - %PreInitialisationCode - *code* - %End - -This directive is used to specify handwritten code that is embedded in-line -at the very start of the generated module initialisation code. - -For example:: - - %PreInitialisationCode - // The code will be executed when the module is first imported and - // before other initialisation has been completed. - %End - - -%RaiseCode ----------- - -.. parsed-literal:: - - %RaiseCode - *code* - %End - -This directive is used as part of the definition of an exception using the -`%Exception`_ directive to specify handwritten code that raises a Python -exception when a C++ exception has been caught. The code is embedded in-line -as the body of a C++ ``catch ()`` clause. - -The specified code must handle the Python Global Interpreter Lock (GIL) if -necessary. The GIL must be acquired before any calls to the Python API and -released after the last call as shown in this example fragment:: - - SIP_BLOCK_THREADS - PyErr_SetNone(PyErr_Exception); - SIP_UNBLOCK_THREADS - -Finally, the specified code must not include any ``return`` statements. - -The following variable is made available to the handwritten code: - -*type* &sipExceptionRef - This is a reference to the caught C++ exception. The *type* of the - reference is the same as the type defined in the ``throw ()`` specifier. - -See the `%Exception`_ directive for an example. - - -%SetCode --------- - -.. parsed-literal:: - - %SetCode - *code* - %End - -This directive is used after the declaration of a C++ class variable or C -structure member to specify handwritten code to convert it from a Python -object. It is usually used to handle types that SIP cannot deal with -automatically. - -The following variables are made available to the handwritten code: - -*type* \*sipCpp - This is a pointer to the structure or class instance. Its *type* is a - pointer to the structure or class. It is not made available if the - variable being wrapped is a static class variable. - -int sipErr - If the conversion failed then the handwritten code should raise a Python - exception and set this to a non-zero value. Its initial value will be - automatically set to zero. - -PyObject \*sipPy - This is the Python object that the handwritten code should convert. - -See the `%GetCode`_ directive for an example. - - -%SIPOptions ------------ - -This directive sets one or more options that controls different aspects of -SIP's behaviour. In this version all the available options are provided -specifically to support PyQt and so are not documented. - - -%Timeline ---------- - -.. parsed-literal:: - - %Timeline {*name* *name* ...} - -This directive is used to declare a set of versions released over a period of -time. Versions (along with `%Feature`_ and `%Platforms`_) are used by the -`%If`_ directive to control whether or not parts of a specification are -processed or ignored. - -Versions are mutually exclusive - only one version can be enabled at a time. -By default all versions are disabled. The SIP ``-t`` command line option is -used to enable a version. - -For example:: - - %Timeline {V1_0 V1_1 V2_0 V3_0} - - %If (V1_0 - V2_0) - void foo(); - %End - - %If (V2_0 -) - void foo(int = 0); - %End - -`%Timeline`_ can be used any number of times in a module to allow multiple -libraries to be wrapped in the same module. - - -%TypeCode ---------- - -.. parsed-literal:: - - %TypeCode - *code* - %End - -This directive is used as part of the specification of a C structure or a C++ -class to specify handwritten code, typically the implementations of utility -functions, that can be called by other handwritten code in the structure or -class. - -For example:: - - class Klass - { - %TypeCode - // Print an instance on stderr for debugging purposes. - static void dump_klass(const Klass *k) - { - fprintf(stderr,"Klass %s at %p\n", k -> name(), k); - } - %End - - // The rest of the class specification. - - }; - -Because the scope of the code is normally within the generated file that -implements the type, any utility functions would normally be declared -``static``. However a naming convention should still be adopted to prevent -clashes of function names within a module in case the SIP ``-j`` command line -option is used. - - -%TypeHeaderCode ---------------- - -.. parsed-literal:: - - %TypeHeaderCode - *code* - %End - -This directive is used to specify handwritten code that defines the interface -to a C or C++ type being wrapped, either a structure, a class, or a template. -It is used within a class definition or a `%MappedType`_ directive. - -Normally *code* will be a pre-processor ``#include`` statement. - -For example:: - - // Wrap the Klass class. - class Klass - { - %TypeHeaderCode - #include <klass.h> - %End - - // The rest of the class specification. - }; - - -%UnitCode ---------- - -.. parsed-literal:: - - %UnitCode - *code* - %End - -This directive is used to specify handwritten code that it included at the very -start of a generated compilation unit (ie. C or C++ source file). It is -typically used to ``#include`` a C++ precompiled header file. - - -%VirtualCatcherCode -------------------- - -.. parsed-literal:: - - %VirtualCatcherCode - *code* - %End - -For most classes there are corresponding `generated derived classes`_ that -contain reimplementations of the class's virtual methods. These methods (which -SIP calls catchers) determine if there is a corresponding Python -reimplementation and call it if so. If there is no Python reimplementation -then the method in the original class is called instead. - -This directive is used to specify handwritten code that replaces the normally -generated call to the Python reimplementation and the handling of any returned -results. It is usually used to handle argument types and results that SIP -cannot deal with automatically. - -This directive can also be used in the context of a class destructor to -specify handwritten code that is embedded in-line in the internal derived -class's destructor. - -In the context of a method the Python Global Interpreter Lock (GIL) is -automatically acquired before the specified code is executed and automatically -released afterwards. - -In the context of a destructor the specified code must handle the GIL. The -GIL must be acquired before any calls to the Python API and released after the -last call as shown in this example fragment:: - - SIP_BLOCK_THREADS - Py_DECREF(obj); - SIP_UNBLOCK_THREADS - -The following variables are made available to the handwritten code in the -context of a method: - -*type* a0 - There is a variable for each argument of the C++ signature named ``a0``, - ``a1``, etc. The *type* of the variable is the same as the type defined in - the specification. - -int sipIsErr - The handwritten code should set this to a non-zero value, and raise an - appropriate Python exception, if an error is detected. - -PyObject \*sipMethod - This object is the Python reimplementation of the virtual C++ method. It - is normally passed to `sipCallMethod()`_. - -*type* sipRes - The handwritten code should set this to the result to be returned. The - *type* of the variable is the same as the type defined in the C++ signature - in the specification. - -No variables are made available in the context of a destructor. - -For example:: - - class Klass - { - public: - virtual int foo(SIP_PYTUPLE) [int (int *)]; - %MethodCode - // The C++ API takes a 2 element array of integers but passing a - // two element tuple is more Pythonic. - - int iarr[2]; - - if (PyArg_ParseTuple(a0, "ii", &iarr[0], &iarr[1])) - { - Py_BEGIN_ALLOW_THREADS - sipRes = sipCpp -> Klass::foo(iarr); - Py_END_ALLOW_THREADS - } - else - { - // PyArg_ParseTuple() will have raised the exception. - sipIsErr = 1; - } - %End - %VirtualCatcherCode - // Convert the 2 element array of integers to the two element - // tuple. - - PyObject *result; - - result = sipCallMethod(&sipIsErr, sipMethod, "ii", a0[0], a0[1]); - - if (result != NULL) - { - // Convert the result to the C++ type. - sipParseResult(&sipIsErr, sipMethod, result, "i", &sipRes); - - Py_DECREF(result); - } - %End - }; - - -SIP Annotations -=============== - -In this section we describe each of the annotations that can be used in -specification files. - -Annotations can either be argument annotations, class annotations, enum -annotations, exception annotations, function annotations, license annotations, -or variable annotations depending on the context in which they can be used. - -Annotations are placed between forward slashes (``/``). Multiple annotations -are comma separated within the slashes. - -Annotations have a type and, possibly, a value. The type determines the -format of the value. The name of an annotation and its value are separated by -``=``. - -Annotations can have one of the following types: - -boolean - This type of annotation has no value and is implicitly true. - -name - The value is a name that is compatible with a C/C++ identifier. In some - cases the value is optional. - -string - The value is a double quoted string. - -The following example shows argument and function annotations:: - - void exec(QWidget * /Transfer/) /ReleaseGIL, PyName=call_exec/; - -Note that the current version of SIP does not complain about unknown -annotations, or annotations used out of their correct context. - - -Argument Annotations --------------------- - -AllowNone -********* - -This boolean annotation specifies that the value of the corresponding argument -(which should be either SIP_PYCALLABLE_, SIP_PYDICT_, SIP_PYLIST_, -SIP_PYSLICE_, SIP_PYTUPLE_ or SIP_PYTYPE_) may be ``None``. - - -Array -***** - -This boolean annotation specifies that the corresponding argument (which -should be either ``char *`` or ``unsigned char *``) refers to an array -rather than a ``'\0'`` terminated string. There must be a corresponding -argument with the ArraySize_ annotation specified. The annotation may only be -specified once in a list of arguments. - - -ArraySize -********* - -This boolean annotation specifies that the corresponding argument (which -should be either ``short``, ``unsigned short``, ``int``, ``unsigned``, -``long`` or ``unsigned long``) refers to the size of an array. There must be -a corresponding argument with the Array_ annotation specified. The annotation -may only be specified once in a list of arguments. - - -Constrained -*********** - -Python will automatically convert between certain compatible types. For -example, if a floating pointer number is expected and an integer supplied, -then the integer will be converted appropriately. This can cause problems -when wrapping C or C++ functions with similar signatures. For example:: - - // The wrapper for this function will also accept an integer argument - // which Python will automatically convert to a floating point number. - void foo(double); - - // The wrapper for this function will never get used. - void foo(int); - -This boolean annotation specifies that the corresponding argument (which -should be either ``bool``, ``int``, ``float``, ``double`` or a wrapped class) -must match the type without any automatic conversions. In the context of a -wrapped class the invocation of any `%ConvertToTypeCode`_ is suppressed. - -The following example gets around the above problem:: - - // The wrapper for this function will only accept floating point numbers. - void foo(double /Constrained/); - - // The wrapper for this function will be used for anything that Python can - // convert to an integer, except for floating point numbers. - void foo(int); - - -GetWrapper -********** - -This boolean annotation is only ever used in conjunction with handwritten code -specified with the `%MethodCode`_ directive. It causes an extra variable to -be generated for the corresponding argument (which should be a wrapped C -structure or C++ class instance) which is a pointer to the Python object that -wraps the argument. - -See the `%MethodCode`_ directive for more detail. - - -In -** - -This boolean annotation is used to specify that the corresponding argument -(which should be a pointer type) is used to pass a value to the function. - -For pointers to wrapped C structures or C++ class instances, ``char *`` and -``unsigned char *`` then this annotation is assumed unless the Out_ annotation -is specified. - -For pointers to other types then this annotation must be explicitly specified -if required. The argument will be dereferenced to obtain the actual value. - -Both In_ and Out_ may be specified for the same argument. - - -Out -*** - -This boolean annotation is used to specify that the corresponding argument -(which should be a pointer type) is used by the function to return a value as -an element of a tuple. - -For pointers to wrapped C structures or C++ class instances, ``char *`` and -``unsigned char *`` then this annotation must be explicitly specified if -required. - -For pointers to other types then this annotation is assumed unless the In_ -annotation is specified. - -Both In_ and Out_ may be specified for the same argument. - - -Transfer -******** - -This boolean annotation is used to specify that ownership of the corresponding -argument (which should be a wrapped C structure or C++ class instance) is -transferred from Python to C++. In addition, if the argument is of a class -method, then it is associated with the class instance with regard to the -cyclic garbage collector. - -See `Ownership of Objects`_ for more detail. - - -TransferBack -************ - -This boolean annotation is used to specify that ownership of the corresponding -argument (which should be a wrapped C structure or C++ class instance) is -transferred back to Python from C++. In addition, any association of the -argument with regard to the cyclic garbage collector with another instance is -removed. - -Note that this can also be used as a function annotation. - -See `Ownership of Objects`_ for more detail. - - -TransferThis -************ - -This boolean annotation is only used in C++ constructors or methods. In the -context of a constructor or factory method it specifies that ownership of the -instance being created is transferred from Python to C++ if the corresponding -argument (which should be a wrapped C structure or C++ class instance) is not -``None``. In addition, the newly created instance is associated with the -argument with regard to the cyclic garbage collector. - -In the context of a non-factory method it specifies that ownership of ``this`` -is transferred from Python to C++ if the corresponding argument is not -``None``. If it is ``None`` then ownership is transferred to Python. - -The annotation may be used more that once, in which case ownership is -transferred to last instance that is not ``None``. - -See `Ownership of Objects`_ for more detail. - - -Class Annotations ------------------ - -Abstract -******** - -This boolean annotation is used to specify that the class has additional pure -virtual methods that have not been specified and so it cannot be instantiated -or sub-classed from Python. - - -DelayDtor -********* - -This boolean annotation is used to specify that the class's destructor should -not be called until the Python interpreter exits. It would normally only be -applied to singleton classes. - -When the Python interpreter exits the order in which any wrapped instances are -garbage collected is unpredictable. However, the underlying C or C++ instances -may need to be destroyed in a certain order. If this annotation is specified -then when the wrapped instance is garbage collected the C or C++ instance is -not destroyed but instead added to a list of delayed instances. When the -interpreter exits then the function ``sipDelayedDtors`` is called with the -list of delayed instances. ``sipDelayedDtors`` can then choose to call (or -ignore) the destructors in any desired order. - -The ``sipDelayedDtors`` function must be specified using the `%ModuleCode`_ -directive. It's signature is as follows:: - - static void sipDelayedDtors(const sipDelayedDtor *dd_list); - -``dd_list`` is the linked list of delayed instances. The following fields are -defined. - -const char \*dd_name - This is the name of the class excluding any package or module name. - -void \*dd_ptr - This is the address of the C or C++ instance to be destroyed. It's exact - type depends on the value of ``dd_isderived``. - -int dd_isderived - This is non-zero if the type of ``dd_ptr`` is actually the generated - derived class. This allows the correct destructor to be called. See - `Generated Derived Classes`_. - -sipDelayedDtor \*dd_next - This is the address of the next entry in the list or zero if this is the - last one. - -Note that the above applies only to C and C++ instances that are owned by -Python. - - -External -******** - -This boolean annotation is used to specify that the class is defined in another -module. Declarations of external classes are private to the module in which -they appear. - - -NoDefaultCtors -************** - -This boolean annotation is used to suppress the automatic generation of default -constructors for the class. - - -PyName -****** - -This name annotation specifies an alternative name for the class being wrapped -which is used when it is referred to from Python. It is required when a class -name is the same as a Python keyword. It may also be used to avoid name -clashes with other objects (e.g. enums, exceptions, functions) that have the -same name in the same C++ scope. - - -Enum Annotations ----------------- - -PyName -****** - -This name annotation specifies an alternative name for the enum or enum member -being wrapped which is used when it is referred to from Python. It is required -when an enum or enum member name is the same as a Python keyword. It may also -be used to avoid name clashes with other objects (e.g. classes, exceptions, -functions) that have the same name in the same C++ scope. - - -Exception Annotations ---------------------- - -PyName -****** - -This name annotation specifies an alternative name for the exception being -defined which is used when it is referred to from Python. It is required when -an exception name is the same as a Python keyword. It may also be used to -avoid name clashes with other objects (e.g. classes, enums, functions) that -have the same name. - - -Function Annotations --------------------- - -AutoGen -******* - -This optional name annotation is used with class methods to specify that the -method be automatically included in all sub-classes. The value is the name of -a feature (specified using the `%Feature`_ directive) which must be enabled -for the method to be generated. - - -Default -******* - -This boolean annotation is only used with C++ constructors. Sometimes SIP -needs to create a class instance. By default it uses a constructor with no -compulsory arguments if one is specified. (SIP will automatically generate a -constructor with no arguments if no constructors are specified.) This -annotation is used to explicitly specify which constructor to use. Zero is -passed as the value of any arguments to the constructor. - - -Factory -******* - -This boolean annotation specifies that the value returned by the function -(which should be a wrapped C structure or C++ class instance) is a newly -created instance and is owned by Python. - -See `Ownership of Objects`_ for more detail. - - -HoldGIL -******* - -This boolean annotation specifies that the Python Global Interpreter Lock (GIL) -is not released before the call to the underlying C or C++ function. See -`The Python Global Interpreter Lock`_ and the ReleaseGIL_ annotation. - - -NewThread -********* - -This boolean annotation specifies that the function will create a new thread. - - -NoDerived -********* - -This boolean annotation is only used with C++ constructors. In many cases SIP -generates a derived class for each class being wrapped (see `Generated Derived -Classes`_). This derived class contains constructors with the same C++ -signatures as the class being wrapped. Sometimes you may want to define a -Python constructor that has no corresponding C++ constructor. This annotation -is used to suppress the generation of the constructor in the derived class. - - -Numeric -******* - -This boolean annotation specifies that the operator should be interpreted as a -numeric operator rather than a sequence operator. Python uses the ``+`` -operator for adding numbers and concatanating sequences, and the ``*`` operator -for multiplying numbers and repeating sequences. SIP tries to work out which -is meant by looking at other operators that have been defined for the type. -If it finds either ``-``, ``-=``, ``/``, ``/=``, ``%`` or ``%=`` defined then -it assumes that ``+``, ``+=``, ``*`` and ``*=`` should be numeric operators. -Otherwise, if it finds either ``[]``, ``__getitem__()``, ``__setitem__()`` or -``__delitem__()`` defined then it assumes that they should be sequence -operators. This annotation is used to force SIP to treat the operator as -numeric. - - -PostHook -******** - -This name annotation is used to specify the name of a Python builtin that is -called immediately after the call to the underlying C or C++ function or any -handwritten code. The builtin is not called if an error occurred. It is -primarily used to integrate with debuggers. - - -PreHook -******* - -This name annotation is used to specify the name of a Python builtin that is -called immediately after the function's arguments have been successfully -parsed and before the call to the underlying C or C++ function or any -handwritten code. It is primarily used to integrate with debuggers. - - -PyName -****** - -This name annotation specifies an alternative name for the function being -wrapped which is used when it is referred to from Python. It is required when -a function or method name is the same as a Python keyword. It may also be used -to avoid name clashes with other objects (e.g. classes, enums, exceptions) that -have the same name in the same C++ scope. - - -ReleaseGIL -********** - -This boolean annotation specifies that the Python Global Interpreter Lock (GIL) -is released before the call to the underlying C or C++ function and reacquired -afterwards. It should be used for functions that might block or take a -significant amount of time to execute. See `The Python Global Interpreter -Lock`_ and the HoldGIL_ annotation. - - -TransferBack -************ - -This boolean annotation specifies that ownership of the value returned by the -function (which should be a wrapped C structure or C++ class instance) is -transferred back to Python from C++. Normally returned values (unless they are -new references to already wrapped values) are owned by C++. In addition, any -association of the returned value with regard to the cyclic garbage collector -with another instance is removed. - -Note that this can also be used as an argument annotation. - -See `Ownership of Objects`_ for more detail. - - -License Annotations -------------------- - -Licensee -******** - -This optional string annotation specifies the license's licensee. No -restrictions are placed on the contents of the string. - -See the `%License`_ directive. - - -Signature -********* - -This optional string annotation specifies the license's signature. No -restrictions are placed on the contents of the string. - -See the `%License`_ directive. - - -Timestamp -********* - -This optional string annotation specifies the license's timestamp. No -restrictions are placed on the contents of the string. - -See the `%License`_ directive. - - -Type -**** - -This string annotation specifies the license's type. No restrictions are -placed on the contents of the string. - -See the `%License`_ directive. - - -Variable Annotations --------------------- - -PyName -****** - -This name annotation specifies an alternative name for the variable being -wrapped which is used when it is referred to from Python. It is required when -a variable name is the same as a Python keyword. It may also be used to avoid -name clashes with other objects (e.g. classes, functions) that have the same -name in the same C++ scope. - - -SIP API for Handwritten Code -============================ - -In this section we describe the API that can be used by handwritten code in -specification files. - - -SIP_API_MAJOR_NR ----------------- - -This is a C preprocessor symbol that defines the major number of the SIP API. -Its value is a number. There is no direct relationship between this and the -SIP version number. - - -SIP_API_MINOR_NR ----------------- - -This is a C preprocessor symbol that defines the minor number of the SIP API. -Its value is a number. There is no direct relationship between this and the -SIP version number. - - -SIP_BLOCK_THREADS ------------------ - -This is a C preprocessor macro that will make sure the Python Global -Interpreter Lock (GIL) is acquired. Python API calls must only be made when -the GIL has been acquired. There must be a corresponding -`SIP_UNBLOCK_THREADS`_ at the same lexical scope. - - -SIP_SSIZE_T ------------ - -This is a C preprocessor macro that is defined as ``Py_ssize_t`` for Python -v2.5 and later, and as ``int`` for earlier versions of Python. It makes it -easier to write PEP 353 compliant handwritten code. - - -SIP_UNBLOCK_THREADS -------------------- - -This is a C preprocessor macro that will restore the Python Global Interpreter -Lock (GIL) to the state it was prior to the corresponding `SIP_BLOCK_THREADS`_. - - -SIP_VERSION ------------ - -This is a C preprocessor symbol that defines the SIP version number -represented as a 3 part hexadecimal number (e.g. v4.0.0 is represented as -``0x040000``). - - -SIP_VERSION_STR ---------------- - -This is a C preprocessor symbol that defines the SIP version number -represented as a string. For development snapshots it will start with -``snapshot-``. - - -sipBadCatcherResult() ---------------------- - -void sipBadCatcherResult(PyObject \*method) - This raises a Python exception when the result of a Python reimplementation - of a C++ method doesn't have the expected type. It is normally called by - handwritten code specified with the `%VirtualCatcherCode`_ directive. - *method* is the Python method and would normally be the supplied - ``sipMethod``. - - -sipBadLengthForSlice() ----------------------- - -void sipBadLengthForSlice(SIP_SSIZE_T seqlen, SIP_SSIZE_T slicelen) - This raises a Python exception when the length of a slice object is - inappropriate for a sequence-like object. It is normally called by - handwritten code specified for ``__setitem__()`` methods. *seqlen* is the - length of the sequence. *slicelen* is the length of the slice. With - versions of Python prior to v2.5 the arguments have type ``int``. - - -sipBuildResult() ----------------- - -PyObject \*sipBuildResult(int \*iserr, const char \*format, ...) - This creates a Python object based on a format string and associated - values in a similar way to the Python ``Py_BuildValue()`` function. If - there was an error then ``NULL`` is returned and a Python exception is - raised. If *iserr* is not ``NULL`` then the location it points to is set - to a non-zero value. *format* is the string of format characters. - - If *format* begins and ends with parentheses then a tuple of objects is - created. If *format* contains more than one format character then - parentheses must be specified. - - In the following description the first letter is the format character, the - entry in parentheses is the Python object type that the format character - will create, and the entry in brackets are the types of the C/C++ values - to be passed. - - ``a`` (string) [char \*, int] - Convert a C/C++ character array and its length to a Python string. If - the array is ``NULL`` then the length is ignored and the result is - ``Py_None``. - - ``b`` (boolean) [int] - Convert a C/C++ ``int`` to a Python boolean. - - ``c`` (string) [char] - Convert a C/C++ ``char`` to a Python string. - - ``d`` (float) [double] - Convert a C/C++ ``double`` to a Python floating point number. - - ``e`` (integer) [enum] - Convert an anonymous C/C++ ``enum`` to a Python integer. - - ``f`` (float) [float] - Convert a C/C++ ``float`` to a Python floating point number. - - ``h`` (integer) [short] - Convert a C/C++ ``short`` to a Python integer. - - ``i`` (integer) [int] - Convert a C/C++ ``int`` to a Python integer. - - ``l`` (long) [long] - Convert a C/C++ ``long`` to a Python integer. - - ``m`` (long) [unsigned long] - Convert a C/C++ ``unsigned long`` to a Python long. - - ``n`` (long) [long long] - Convert a C/C++ ``long long`` to a Python long. - - ``o`` (long) [unsigned long long] - Convert a C/C++ ``unsigned long long`` to a Python long. - - ``s`` (string) [char \*] - Convert a C/C++ ``'\0'`` terminated string to a Python string. If the - string pointer is ``NULL`` then the result is ``Py_None``. - - ``t`` (long) [unsigned short] - Convert a C/C++ ``unsigned short`` to a Python long. - - ``u`` (long) [unsigned int] - Convert a C/C++ ``unsigned int`` to a Python long. - - ``w`` (unicode) [wchar_t] - Convert a C/C++ wide character to a Python unicode object. - - ``x`` (unicode) [wchar_t \*] - Convert a C/C++ ``L'\0'`` terminated wide character string to a Python - unicode object. If the string pointer is ``NULL`` then the result is - ``Py_None``. - - ``A`` (unicode) [wchar_t \*, int] - Convert a C/C++ wide character array and its length to a Python unicode - object. If the array is ``NULL`` then the length is ignored and the - result is ``Py_None``. - - ``B`` (wrapped instance) [*type* \*, sipWrapperType \*, PyObject \*] - Convert a new C structure or a new C++ class instance to a Python class - instance object. Ownership of the structure or instance is determined - by the ``PyObject *`` argument. If it is ``NULL`` and the instance has - already been wrapped then the ownership is unchanged. If it is - ``NULL`` or ``Py_None`` then ownership will be with Python. Otherwise - ownership will be with C/C++ and the instance associated with the - ``PyObject *`` argument. The Python class is influenced by any - applicable `%ConvertToSubClassCode`_ code. - - ``C`` (wrapped instance) [*type* \*, sipWrapperType \*, PyObject \*] - Convert a C structure or a C++ class instance to a Python class - instance object. If the structure or class instance has already been - wrapped then the result is a new reference to the existing class - instance object. Ownership of the structure or instance is determined - by the ``PyObject *`` argument. If it is ``NULL`` and the instance has - already been wrapped then the ownership is unchanged. If it is - ``NULL`` and the instance is newly wrapped then ownership will be with - C/C++. If it is ``Py_None`` then ownership is transferred to Python - via a call to `sipTransferBack()`_. Otherwise ownership is transferred - to C/C++ and the instance associated with the ``PyObject *`` argument - via a call to `sipTransferTo()`_. The Python class is influenced by - any applicable `%ConvertToSubClassCode`_ code. - - ``D`` (object) [*type* \*, const sipMappedType \*, PyObject \*] - Convert a C structure or a C++ class instance wrapped as a mapped type - to a Python object. Ownership of the structure or instance is - determined by the ``PyObject *`` argument. If it is ``NULL`` then the - ownership is unchanged. If it is ``Py_None`` then ownership is - transferred to Python via a call to `sipTransferBack()`_. Otherwise - ownership is transferred to C/C++ and the instance associated with the - ``PyObject *`` argument via a call to `sipTransferTo()`_. - - ``E`` (wrapped enum) [enum, PyTypeObject \*] - Convert a named C/C++ ``enum`` to an instance of the corresponding - Python named enum type. - - ``M`` (wrapped instance) [*type* \*, sipWrapperType \*] - Convert a C structure or a C++ class instance to a Python class - instance object. If the structure or class instance has already been - wrapped then the result is a new reference to the existing class - instance object. If the instance has already been wrapped then the - ownership is unchanged. If the instance is newly wrapped then - ownership will be with C/C++. The Python class is influenced by any - applicable `%ConvertToSubClassCode`_ code. This is deprecated from - SIP v4.4. - - ``N`` (wrapped instance) [*type* \*, sipWrapperType \*] - Convert a C structure or a C++ class instance to a Python class - instance object. This should not be used if the structure or class - instance might already have been wrapped. Ownership of the structure - or instance will be with Python. The Python class is influenced by - any applicable `%ConvertToSubClassCode`_ code. This is deprecated - from SIP v4.4. - - ``O`` (wrapped instance) [*type* \*, sipWrapperType \*] - Convert a C structure or a C++ class instance to a Python class - instance object. If the structure or class instance has already been - wrapped then the result is a new reference to the existing class - instance object. Ownership of the structure or instance will be with - C/C++. This is deprecated from SIP v4.4. - - ``P`` (wrapped instance) [*type* \*, sipWrapperType \*] - Convert a C structure or a C++ class instance to a Python class - instance object. This should not be used if the structure or class - instance might already have been wrapped. Ownership of the structure - or instance will be with Python. This is deprecated from SIP v4.4. - - ``R`` (object) [PyObject \*] - The result is value passed without any conversions. The reference - count is unaffected, i.e. a reference is taken. - - ``S`` (object) [PyObject \*] - The result is value passed without any conversions. The reference - count is incremented. - - ``T`` (object) [void \*, PyObject \*(\*)(void \*cppptr)] - Convert a C structure or a C++ class instance to a Python object using - a convertor function. See `Generated Type Convertors`_. This is - deprecated from SIP v4.4. - - ``V`` (sip.voidptr) [void \*] - Convert a C/C++ ``void *`` Python ``sip.voidptr`` object. - - -sipCallMethod() ---------------- - -PyObject \*sipCallMethod(int \*iserr, PyObject \*method, const char \*format, ...) - This calls a Python method passing a tuple of arguments based on a format - string and associated values in a similar way to the Python - ``PyObject_CallObject()`` function. If there was an error then ``NULL`` is - returned and a Python exception is raised. If *iserr* is not ``NULL`` - then the location it points to is set to a non-zero value. *method* is the - Python bound method to call. *format* is the string of format characters - (see `sipBuildResult()`_). - - This is normally called by handwritten code specified with the - `%VirtualCatcherCode`_ directive with *method* being the supplied - ``sipMethod``. - - -sipCanConvertToInstance() -------------------------- - -int sipCanConvertToInstance(PyObject \*obj, sipWrapperType \*type, int flags) - This returns a non-zero value if a Python object can be converted to an - instance of a C structure or C++ class. *obj* is the Python object. - *type* is the generated type corresponding to the C/C++ type being checked. - *flags* is any combination of the following values used to fine tune the - check. - - - ``SIP_NOT_NONE`` causes the check to fail if *obj* is ``None``. - - - ``SIP_NO_CONVERTORS`` suppresses the use of of any - `%ConvertToTypeCode`_ for *type*. - - -sipCanConvertToMappedType() ---------------------------- - -int sipCanConvertToMappedType(PyObject \*obj, const sipMappedType \*mt, int flags) - This returns a non-zero value if a Python object can be converted to an - instance of a C structure or C++ class which has been implemented as a - mapped type. *obj* is the Python object. *mt* is an opaque structure - returned by `sipFindMappedType()`_. *flags* is any combination of the - following values used to fine tune the check. - - - ``SIP_NOT_NONE`` causes the check to fail if *obj* is ``None``. - - -sipClassName() --------------- - -PyObject \*sipClassName(PyObject \*obj) - This returns the class name of a wrapped instance as a Python string. It - comes with a reference. - - -sipConnectRx() --------------- - -PyObject \*sipConnectRx(PyObject \*sender, const char \*signal, PyObject \*receiver, const char \*slot, int type) - This connects a signal to a signal or slot and returns ``Py_True`` if the - signal was connected or ``Py_False`` if not. If there was some other - error then a Python exception is raised and ``NULL`` is returned. *sender* - is the wrapped ``QObject`` derived instance that emits the signal. - *signal* is the typed name of the signal. *receiver* is the wrapped - ``QObject`` derived instance or Python callable that the signal is - connected to. *slot* is the typed name of the slot, or ``NULL`` if - *receiver* is a Python callable. *type* is the type of connection and is - cast from Qt::ConnectionType. It is normally only used by PyQt to - implement ``QObject.connect()``. - - -sipConvertFromInstance() ------------------------- - -PyObject \*sipConvertFromInstance(void \*cpp, sipWrapperType \*type, PyObject \*transferObj) - Convert a C structure or a C++ class instance to a Python class instance - object. *cpp* is the C/C++ instance. If the instance has already been - wrapped then the result is a new reference to the existing instance object. - *type* is the generated type corresponding to the C/C++ type. - *transferObj* controls the ownership of the returned value. If the - structure or class instance has already been wrapped then the result is a - new reference to the existing class instance object. If it is ``NULL`` and - the instance has already been wrapped then the ownership is unchanged. If - it is ``NULL`` and the instance is newly wrapped then ownership will be - with C/C++. If it is ``Py_None`` then ownership is transferred to Python - via a call to `sipTransferBack()`_. Otherwise ownership is transferred to - C/C++ and the instance associated with *transferObj* via a call to - `sipTransferTo()`_. The Python class is influenced by any applicable - `%ConvertToSubClassCode`_ code. - - -sipConvertFromMappedType() --------------------------- - -PyObject \*sipConvertFromMappedType(void \*cpp, const sipMappedType \*mt, PyObject \*transferObj) - Convert a C structure or a C++ class instance wrapped as a mapped type to a - Python object. *cpp* is the C/C++ instance. *mt* is the opaque structure - returned by `sipFindMappedType()`_. *transferObj* controls any ownership - changes to *obj*. If it is ``NULL`` then the ownership is unchanged. If - it is ``Py_None`` then ownership is transferred to Python via a call to - `sipTransferBack()`_. Otherwise ownership is transferred to C/C++ and the - instance associated with the ``PyObject *`` argument via a call to - `sipTransferTo()`_. - - -sipConvertFromNamedEnum() -------------------------- - -PyObject \*sipConvertFromNamedEnum(int eval, PyTypeObject \*type) - Convert a named C/C++ ``enum`` to an instance of the corresponding Python - named enum type. *eval* is the enumerated value to convert. *type* is the - generated Python type object (see `Generated Named Enum Type Objects`_). - - -sipConvertFromNewInstance() ---------------------------- - -PyObject \*sipConvertFromNewInstance(void \*cpp, sipWrapperType \*type, PyObject \*transferObj) - Convert a new C structure or a new C++ class instance to a Python class - instance object. *cpp* is the C/C++ instance. *type* is the generated - type corresponding to the C/C++ type. *transferObj* controls the ownership - of the returned value. If it is ``NULL`` or ``Py_None`` then ownership - will be with Python. Otherwise ownership will be with C/C++ and the - instance associated with *transferObj*. The Python class is influenced by - any applicable `%ConvertToSubClassCode`_ code. - - -sipConvertFromSequenceIndex() ------------------------------ - -SIP_SSIZE_T sipConvertFromSequenceIndex(SIP_SSIZE_T idx, SIP_SSIZE_T len) - This converts a Python sequence index (i.e. where a negative value refers - to the offset from the end of the sequence) to a C/C++ array index. If the - index was out of range then a negative value is returned and a Python - exception raised. With versions of Python prior to v2.5 the result and the - arguments have type ``int``. - - -sipConvertFromSliceObject() ---------------------------- - -int sipConvertFromSliceObject(PyObject \*slice, SIP_SSIZE_T length, SIP_SSIZE_T \*start, SIP_SSIZE_T \*stop, SIP_SSIZE_T \*step, SIP_SSIZE_T \*slicelength) - This is a thin wrapper around the Python ``PySlice_GetIndicesEx()`` - function provided to make it easier to write handwritten code that is - compatible with SIP v3.x and versions of Python earlier that v2.3. - - -sipConvertToCpp() ------------------ - -void \*sipConvertToCpp(PyObject \*obj, sipWrapperType \*type, int \*iserr) - This function is deprecated from SIP v4.4. It is equivalent to:: - - sipConvertToInstance(obj, type, NULL, SIP_NO_CONVERTORS, NULL, iserr); - - -sipConvertToInstance() ----------------------- - -void \*sipConvertToInstance(PyObject \*obj, sipWrapperType \*type, PyObject \*transferObj, int flags, int \*state, int \*iserr) - This converts a Python object to an instance of a C structure or C++ class - assuming that a previous call to `sipCanConvertToInstance()`_ has been - successful. *obj* is the Python object. *type* is the generated type - corresponding to the C/C++ type returned. It may be any class in the - object's class hierarchy. *transferObj* controls any ownership changes to - *obj*. If it is ``NULL`` then the ownership is unchanged. If it is - ``Py_None`` then ownership is transferred to Python via a call to - `sipTransferBack()`_. Otherwise ownership is transferred to C/C++ and - *obj* associated with *transferObj* via a call to `sipTransferTo()`_. - *flags* is any combination of the following values used to fine tune the - check. - - - ``SIP_NOT_NONE`` causes the check to fail if *obj* is ``None``. - - - ``SIP_NO_CONVERTORS`` suppresses the use of of any - `%ConvertToTypeCode`_ for *type*. - - If *state* is not ``NULL`` then the location it points to is set to - describe the state of the returned C/C++ instance and is the value returned - by any `%ConvertToTypeCode`_. The calling code must then release the value - at some point to prevent a memory leak by calling `sipReleaseInstance()`_. - If there is an error then the location *iserr* points to is set to a - non-zero value. If it was initially a non-zero value then the conversion - isn't attempted in the first place. (This allows several calls to be made - that share the same error flag so that it only needs to be tested once - rather than after each call.) - - -sipConvertToMappedType() ------------------------- - -void \*sipConvertToMappedType(PyObject \*obj, const sipMappedType \*mt, PyObject \*transferObj, int flags, int \*state, int \*iserr) - This converts a Python object to an instance of a C structure or C++ - class that is implemented as a mapped type assuming that a previous call to - `sipCanConvertToMappedType()`_ has been successful. *obj* is the Python - object. *mt* is the opaque structure returned by `sipFindMappedType()`_. - *transferObj* controls any ownership changes to *obj*. If it is ``NULL`` - then the ownership is unchanged. If it is ``Py_None`` then ownership is - transferred to Python via a call to `sipTransferBack()`_. Otherwise - ownership is transferred to C/C++ and *obj* associated with *transferObj* - via a call to `sipTransferTo()`_. *flags* is any combination of the - following values used to fine tune the check. - - - ``SIP_NOT_NONE`` causes the check to fail if *obj* is ``None``. - - If *state* is not ``NULL`` then the location it points to is set to - describe the state of the returned C/C++ instance and is the value returned - by any `%ConvertToTypeCode`_. The calling code must then release the value - at some point to prevent a memory leak by calling - `sipReleaseMappedType()`_. If there is an error then the location *iserr* - points to is set to a non-zero value. If it was initially a non-zero value - then the conversion isn't attempted in the first place. (This allows - several calls to be made that share the same error flag so that it only - needs to be tested once rather than after each call.) - - -sipDisconnectRx() ------------------ - -PyObject \*sipDisconnectRx(PyObject \*sender, const char \*signal, PyObject \*receiver, const char \*slot) - This disconnects a signal from a signal or slot and returns ``Py_True`` if - the signal was disconnected or ``Py_False`` if not. If there was some - other error then a Python exception is raised and ``NULL`` is returned. - *sender* is the wrapped ``QObject`` derived instance that emits the signal. - *signal* is the typed name of the signal. *receiver* is the wrapped - ``QObject`` derived instance or Python callable that the signal is - connected to. *slot* is the typed name of the slot, or ``NULL`` if - *receiver* is a Python callable. It is normally only used by PyQt to - implement ``QObject.disconnect()``. - - -sipEmitSignal() ---------------- - -int sipEmitSignal(PyObject \*txobj, const char \*signal, PyObject \*args) - This emits a signal and returns zero if there was no error. If there was - an error then a Python exception is raised and a negative value is - returned. *txobj* is the wrapped ``QObject`` derived instance that emits - the signal. *signal* is the typed name of the signal. *args* is a Python - tuple of the signal arguments. It is normally only used by PyQt to - implement ``QObject.emit()``. - - -sipExportSymbol() ------------------ - -int sipExportSymbol(const char \*name, void \*sym) - Python does not allow extension modules to directly access symbols in - another extension module. This exports a symbol, referenced by a name, - that can subsequently be imported, using `sipImportSymbol()`_, by another - module. *name* is the name of the symbol and *sym* is its value. Zero is - returned if there was no error. A negative value is returned if *name* is - already associated with a symbol or there was some other error. - - -sipFindClass() --------------- - -sipWrapperType \*sipFindClass(const char \*type) - This returns a pointer to the generated type corresponding to a C/C++ type. - *type* is the C/C++ declaration of the type. ``NULL`` is returned if the - C/C++ type doesn't exist. The value of the pointer will not change and - may be saved in a static cache. - - -sipFindMappedType() -------------------- - -const sipMappedType \*sipFindMappedType(const char \*type) - This returns a pointer to an opaque structure describing a mapped type. - *type* is the C/C++ declaration of the type. ``NULL`` is returned if the - mapped type doesn't exist. The value of the pointer will not change and - may be saved in a static cache. - - -sipFindNamedEnum() ------------------- - -PyTypeObject \*sipFindNamedEnum(const char \*type) - This returns a pointer to the generated type corresponding to a named C/C++ - enum. *type* is the C/C++ declaration of the enum. ``NULL`` is returned - if the named C/C++ enum doesn't exist. The value of the pointer will not - change and may be saved in a static cache. - - -sipForceConvertToInstance() ---------------------------- - -void \*sipForceConvertToInstance(PyObject \*obj, sipWrapperType \*type, PyObject \*transferObj, int flags, int \*state, int \*iserr) - This converts a Python object to an instance of a C structure or C++ class - by calling `sipCanConvertToInstance()`_ and, if it is successfull, calling - `sipConvertToInstance()`_. See `sipConvertToInstance()`_ for a full - description of the arguments. - - -sipForceConvertToMappedType() ------------------------------ - -void \*sipForceConvertToMappedType(PyObject \*obj, const sipMappedType \*mt, PyObject \*transferObj, int flags, int \*state, int \*iserr) - This converts a Python object to an instance of a C structure or C++ class - which has been implemented as a mapped type by calling - `sipCanConvertToMappedType()`_ and, if it is successfull, calling - `sipConvertToMappedType()`_. See `sipConvertToMappedType()`_ for a full - description of the arguments. - - -sipFree() ---------- - -void sipFree(void \*mem) - This returns an area of memory allocated by `sipMalloc()`_ to the heap. - *mem* is a pointer to the area of memory. - - -sipGetSender() --------------- - -const void \*sipGetSender() - This returns a pointer to the last ``QObject`` instance that emitted a Qt - signal. It is normally only used by PyQt to implement - ``QObject.sender()``. - - -sipGetWrapper() ---------------- - -PyObject \*sipGetWrapper(void \*cppptr, sipWrapperType \*type) - This returns a borrowed reference to the wrapped instance object for a C - structure or C++ class instance. If the structure or class instance - hasn't been wrapped then ``NULL`` is returned (and no Python exception is - raised). *cppptr* is the pointer to the structure or class instance. - *type* is the generated type corresponding to the C/C++ type. - - -sipImportSymbol() ------------------ - -void \*sipImportSymbol(const char \*name) - Python does not allow extension modules to directly access symbols in - another extension module. This imports a symbol, referenced by a name, - that has previously been exported, using `sipExportSymbol()`_, by another - module. *name* is the name of the symbol. The value of the symbol is - returned if there was no error. ``NULL`` is returned if there is no such - symbol. - - -sipIntTypeClassMap ------------------- - -This C structure is used with `sipMapIntToClass()`_ to define a mapping -between integer based RTTI and `generated type objects`_. The structure -elements are as follows. - -int typeInt - The integer RTTI. - -sipWrapperType \*\*pyType. - A pointer to the corresponding Python type object. - - -sipIsSubClassInstance() ------------------------ - -int sipIsSubClassInstance(PyObject \*obj, sipWrapperType \*type) - This function is deprecated from SIP v4.4. It is equivalent to:: - - sipCanConvertToInstance(obj, type, SIP_NOT_NONE | SIP_NO_CONVERTORS); - - -sipLong_AsUnsignedLong() ------------------------- - -unsigned long sipLong_AsUnsignedLong(PyObject \*obj) - This function is a thin wrapper around PyLong_AsUnsignedLong() that works - around a bug in Python v2.3.x and earlier when converting integer objects. - - -sipMalloc() ------------ - -void \*sipMalloc(size_t nbytes) - This allocates an area of memory of size *nytes* on the heap using the - Python ``PyMem_Malloc()`` function. If there was an error then ``NULL`` is - returned and a Python exception raised. See `sipFree()`_. - - -sipMapIntToClass() ------------------- - -sipWrapperType \*sipMapIntToClass(int type, const sipIntTypeClassMap \*map, int maplen) - This is used in `%ConvertToSubClassCode`_ code as a convenient way of - converting integer based RTTI to the corresponding Python type object. - *type* is the RTTI. *map* is the table of known RTTI and the corresponding - type objects (see sipIntTypeClassMap_). The entries in the table must be - sorted in ascending order of RTTI. *maplen* is the number of entries in - the table. The corresponding Python type object is returned, or ``NULL`` - if *type* wasn't in *map*. - - -sipMapStringToClass() ---------------------- - -sipWrapperType \*sipMapStringToClass(char \*type, const sipStringTypeClassMap \*map, int maplen) - This is used in `%ConvertToSubClassCode`_ code as a convenient way of - converting ``'\0'`` terminated string based RTTI to the corresponding - Python type object. *type* is the RTTI. *map* is the table of known RTTI - and the corresponding type objects (see sipStringTypeClassMap_). The - entries in the table must be sorted in ascending order of RTTI. *maplen* - is the number of entries in the table. The corresponding Python type - object is returned, or ``NULL`` if *type* wasn't in *map*. - - -sipParseResult() ----------------- - -int sipParseResult(int \*iserr, PyObject \*method, PyObject \*result, const char \*format, ...) - This converts a Python object (usually returned by a method) to C/C++ based - on a format string and associated values in a similar way to the Python - ``PyArg_ParseTuple()`` function. If there was an error then a negative - value is returned and a Python exception is raised. If *iserr* is not - ``NULL`` then the location it points to is set to a non-zero value. - *method* is the Python bound method that returned the *result* object. - *format* is the string of format characters. - - This is normally called by handwritten code specified with the - `%VirtualCatcherCode`_ directive with *method* being the supplied - ``sipMethod`` and ``result`` being the value returned by - `sipCallMethod()`_. - - If *format* begins and ends with parentheses then *result* must be a Python - tuple and the rest of *format* is applied to the tuple contents. - - In the following description the first letter is the format character, the - entry in parentheses is the Python object type that the format character - will convert, and the entry in brackets are the types of the C/C++ values - to be passed. - - ``a`` (string) [char \*\*, int \*] - Convert a Python string to a C/C++ character array and its length. If - the Python object is ``Py_None`` then the array and length are ``NULL`` - and zero respectively. - - ``b`` (integer) [bool \*] - Convert a Python integer to a C/C++ ``bool``. - - ``c`` (string) [char \*] - Convert a Python string of length 1 to a C/C++ ``char``. - - ``d`` (float) [double \*] - Convert a Python floating point number to a C/C++ ``double``. - - ``e`` (integer) [enum \*] - Convert a Python integer to an anonymous C/C++ ``enum``. - - ``f`` (float) [float \*] - Convert a Python floating point number to a C/C++ ``float``. - - ``h`` (integer) [short \*] - Convert a Python integer to a C/C++ ``short``. - - ``i`` (integer) [int \*] - Convert a Python integer to a C/C++ ``int``. - - ``l`` (long) [long \*] - Convert a Python long to a C/C++ ``long``. - - ``m`` (long) [unsigned long \*] - Convert a Python long to a C/C++ ``unsigned long``. - - ``n`` (long) [long long \*] - Convert a Python long to a C/C++ ``long long``. - - ``o`` (long) [unsigned long long \*] - Convert a Python long to a C/C++ ``unsigned long long``. - - ``s`` (string) [char \*\*] - Convert a Python string to a C/C++ ``'\0'`` terminated string. If the - Python object is ``Py_None`` then the string is ``NULL``. - - ``t`` (long) [unsigned short \*] - Convert a Python long to a C/C++ ``unsigned short``. - - ``u`` (long) [unsigned int \*] - Convert a Python long to a C/C++ ``unsigned int``. - - ``w`` (unicode) [wchar_t \*] - Convert a Python unicode object of length 1 to a C/C++ wide character. - - ``x`` (unicode) [wchar_t \*\*] - Convert a Python unicode object to a C/C++ ``L'\0'`` terminated wide - character string. If the Python object is ``Py_None`` then the string - is ``NULL``. - - ``A`` (unicode) [wchar_t \*\*, int \*] - Convert a Python unicode object to a C/C++ wide character array and its - length. If the Python object is ``Py_None`` then the array and length - are ``NULL`` and zero respectively. - - ``Cf`` (wrapped class) [sipWrapperType \*, int \*, void \*\*] - Convert a Python object to a C structure or a C++ class instance and - return its state as described in `sipConvertToInstance()`_. ``f`` is a - combination of the following flags encoded as an ASCII character by - adding ``0`` to the combined value: - - 0x01 disallows the conversion of ``Py_None`` to ``NULL`` - - 0x02 implements the `Factory`_ annotation - - 0x04 suppresses the return of the state of the returned C/C++ - instance. Note that the ``int *`` used to return the state is - not passed if this flag is specified. - - ``Df`` (mapped type) [const sipMappedType \*, int \*, void \*\*] - Convert a Python object to a C structure or a C++ class instance - implemented as a mapped type and return its state as described in - `sipConvertToMappedType()`_. ``f`` is a combination of the following - flags encoded as an ASCII character by adding ``0`` to the combined - value: - - 0x01 disallows the conversion of ``Py_None`` to ``NULL`` - - 0x02 implements the `Factory`_ annotation - - 0x04 suppresses the return of the state of the returned C/C++ - instance. Note that the ``int *`` used to return the state is - not passed if this flag is specified. - - ``E`` (wrapped enum) [PyTypeObject \*, enum \*] - Convert a Python named enum type to the corresponding C/C++ ``enum``. - - ``L`` (object) [*type* \*(\*)(PyObject \*obj, int \*iserr), void \*\*] - Convert a Python object to a C structure or a C++ class instance using - a convertor function. See `Generated Type Convertors`_. This is - deprecated from SIP v4.4. - - ``M`` (object) [*type* \*(\*)(PyObject \*obj, int \*iserr), void \*\*] - Convert a Python object to a C structure or a C++ class instance using - a convertor function. If the structure or class instance pointer is - ``NULL`` then return an error. See `Generated Type Convertors`_. This - is deprecated from SIP v4.4. - - ``N`` (object) [PyTypeObject \*, PyObject \*\*] - A Python object is checked to see if it is a certain type and then - returned without any conversions. The reference count is incremented. - The Python object may be ``Py_None``. - - ``O`` (object) [PyObject \*\*] - A Python object is returned without any conversions. The reference - count is incremented. - - ``T`` (object) [PyTypeObject \*, PyObject \*\*] - A Python object is checked to see if it is a certain type and then - returned without any conversions. The reference count is incremented. - The Python object may not be ``Py_None``. - - ``V`` (sip.voidptr) [void \*] - Convert a Python ``sip.voidptr`` object to a C/C++ ``void *``. - - ``Z`` (object) [] - Check that a Python object is ``Py_None``. No value is returned. - - -sipReleaseInstance() --------------------- - -void sipReleaseInstance(void \*cpp, sipWrapperType \*type, int state) - This destroys a wrapped C/C++ instance if it was a temporary instance. It - is called after a call to either `sipConvertToInstance()`_ or - `sipForceConvertToInstance()`_. *cpp* is the wrapped C/C++ instance. - *type* is the generated type corresponding to *cpp*. *state* describes the - state of the instance. - - -sipReleaseMappedType() ----------------------- - -void sipReleaseMappedType(void \*cpp, const sipMappedType \*mt, int state) - This destroys a wrapped C/C++ mapped type if it was a temporary instance. - It is called after a call to either `sipConvertToMappedType()`_ or - `sipForceConvertToMappedType()`_. *cpp* is the wrapped C/C++ instance. - *mt* is the opaque structure returned by `sipFindMappedType()`_. *state* - describes the state of the instance. - - -sipStringTypeClassMap ---------------------- - -This C structure is used with `sipMapStringToClass()`_ to define a mapping -between ``'\0'`` terminated string based RTTI and `generated type objects`_. -The structure elements are as follows. - -char \*typeString - The ``'\0'`` terminated string RTTI. - -sipWrapperType \*\*pyType. - A pointer to the corresponding Python type object. - - -sipTransfer() -------------- - -void sipTransfer(PyObject \*obj, int tocpp) - This function is deprecated from SIP v4.3. If *tocpp* is non-zero then the - equivalent call is:: - - sipTransferTo(obj, obj); - - If *tocpp* is zero then the equivalent call is:: - - sipTransferBack(obj); - - -sipTransferBack() ------------------ - -void sipTransferBack(PyObject \*obj) - This transfers ownership of a Python wrapped instance to Python (see - `Ownership of Objects`_). *obj* is the wrapped instance. In addition, - any association of the instance with regard to the cyclic garbage - collector with another instance is removed. - - -sipTransferTo() ---------------- - -void sipTransferTo(PyObject \*obj, PyObject \*owner) - This transfers ownership of a Python wrapped instance to C++ (see - `Ownership of Objects`_). *obj* is the wrapped instance. *owner* is an - optional wrapped instance that *obj* becomes associated with with regard - to the cyclic garbage collector. If *owner* is ``NULL`` then no such - association is made. If *owner* is the same value as *obj* then any - reference cycles involving *obj* can never be detected or broken by the - cyclic garbage collector. Responsibility for calling the C++ instance's - destructor is always transfered to C++. - - -sipWrapper ----------- - -This is a C structure that represents a Python wrapped instance. It is an -extension of the Python ``PyObject`` structure and so may be safely cast to -``PyObject``. It includes a member called ``user`` which is of type -``PyObject *``. This can be used for any purpose by handwritten code and will -automatically be garbage collected at the appropriate time. - - -sipWrapper_Check() ------------------- - -int sipWrapper_Check(PyObject \*obj) - This returns a non-zero value if a Python object is a wrapped instance. - *obj* is the Python object. - - -sipWrapperType --------------- - -This is a C structure that represents a SIP generated type object. It is an -extension of the Python ``PyTypeObject`` structure (which is itself an -extension of the Python ``PyObject`` structure) and so may be safely cast to -``PyTypeObject`` (and ``PyObject``). - - -Generated Type Convertors -------------------------- - -These functions are deprecated from SIP v4.4. - -SIP generates functions for all types being wrapped (including mapped types -defined with the `%MappedType`_ directive) that convert a Python object to the -C structure or C++ class instance. The name of this convertor is the name of -the structure or class prefixed by ``sipForceConvertTo_``. - -void \*sipForceConvertTo_*class*(PyObject \*obj, int \*iserr) - *obj* is the Python object to convert. If *obj* is ``NULL`` or the - location pointed to by *iserr* is non-zero then the conversion is not - attempted and ``NULL`` is returned. If there was an error then the - location pointed to by *iserr* is set to a non-zero value, a Python - exception is raised, and ``NULL`` is returned. - -SIP also generates functions for mapped types that convert a C structure or -C++ class instance to a Python object. The name of this convertor is the name -of the structure or class prefixed by ``sipConvertFrom_``. - -PyObject \*sipConvertFrom_*class*(void \*cppptr) - *cppptr* is a pointer to the C structure or C++ class instance to convert. - If there was an error then ``NULL`` is returned and a Python exception - raised. - -The convertor functions of all imported types are available to handwritten -code. - - -Generated Type Objects ----------------------- - -SIP generates a type object for each C structure or C++ class being wrapped. -These are sipWrapperType_ structures and are used extensively by the SIP API. - -These objects are named with the structure or class name prefixed by -``sipClass_``. For example, the type object for class ``Klass`` is -``sipClass_Klass``. - -The type objects of all imported classes are available to handwritten code. - - -Generated Named Enum Type Objects ---------------------------------- - -SIP generates a type object for each named enum being wrapped. These are -PyTypeObject structures. (Anonymous enums are wrapped as Python integers.) - -These objects are named with the fully qualified enum name (i.e. including any -enclosing scope) prefixed by ``sipEnum_``. For example, the type object for -enum ``Enum`` defined in class ``Klass`` is ``sipEnum_Klass_Enum``. - -The type objects of all imported named enums are available to handwritten code. - - -Generated Derived Classes -------------------------- - -For most C++ classes being wrapped SIP generates a derived class with the same -name prefixed by ``sip``. For example, the derived class for class ``Klass`` -is ``sipKlass``. - -If a C++ class doesn't have any virtual or protected methods in it or any of -it's super-class hierarchy, or does not emit any Qt signals, then a derived -class is not generated. - -Most of the time handwritten code should ignore the derived classes. The only -exception is that handwritten constructor code specified using the -`%MethodCode`_ directive should call the derived class's constructor (which -has the same C++ signature) rather then the wrapped class's constructor. - - -Generated Exception Objects ---------------------------- - -SIP generates a Python object for each exception defined with the `%Exception_` -directive. - -These objects are named with the fully qualified exception name (i.e. including -any enclosing scope) prefixed by ``sipException_``. For example, the type -object for enum ``Except`` defined in class ``Klass`` is -``sipException_Klass_Except``. - -The objects of all imported exceptions are available to handwritten code. - - -Using the SIP Module in Applications -==================================== - -The main purpose of the SIP module is to provide functionality common to all -SIP generated bindings. It is loaded automatically and most of the time you -will completely ignore it. However, it does expose some functionality that can -be used by applications. - -cast(obj, type) - This does the Python equivalent of casting a C++ instance to one of its - sub or super-class types. *obj* is the Python object and *type* is the - type. A new Python object is returned that wraps the same C++ instance as - *obj*, but has the type *type*. - -delete(obj) - For C++ instances this calls the C++ destructor. For C structures it - returns the structure's memory to the heap. *obj* is the Python object. - -isdeleted(obj) - This returns True if the C++ instance or C structure has been destroyed or - returned to the heap. *obj* is the Python object. - -setdeleted(obj) - This marks the C++ instance or C structure as having been destroyed or - returned to the heap so that future references to it raise an exception - rather than cause a program crash. Normally SIP handles such things - automatically, but there are circumstances where this isn't possible. - *obj* is the Python object. - -settracemask(mask) - If the bindings have been created with SIP's ``-r`` command line option - then the generated code will produce debugging statements that trace the - execution of the code. (It is particularly useful when trying to - understand the operation of a C++ library's virtual function calls.) - - Debugging statements are generated at the following points: - - - in a C++ virtual function (*mask* is ``0x0001``) - - in a C++ constructor (*mask* is ``0x0002``) - - in a C++ destructor (*mask* is ``0x0004``) - - in a Python type's __init__ method (*mask* is ``0x0008``) - - in a Python type's __del__ method (*mask* is ``0x0010``) - - in a Python type's ordinary method (*mask* is ``0x0020``). - - By default the trace mask is zero and all debugging statements are - disabled. - -SIP_VERSION - This is a Python integer object that represents the SIP version number as - a 3 part hexadecimal number (e.g. v4.0.0 is represented as ``0x040000``). - It was first implemented in SIP v4.2. - -SIP_VERSION_STR - This is a Python string object that defines the SIP version number as - represented as a string. For development snapshots it will start with - ``snapshot-``. It was first implemented in SIP v4.3. - -transfer(obj, direction) - This function is deprecated from SIP v4.3. If *direction* is non-zero then - the equivalent call is:: - - sip.transferto(obj, None) - - If *direction* is zero then the equivalent call is:: - - sip.transferback(obj) - -transferback(obj) - This function is a wrapper around `sipTransferBack()`_. - -transferto(obj, owner) - This function is a wrapper around `sipTransferTo()`_. - -unwrapinstance(obj) - Return the address, as a number, of the wrapped C/C++ structure or class - instance *obj*. - -voidptr - This is the type object for the type SIP uses to represent a C/C++ - ``void *``. The type constructor takes a single argument that must either - be another ``voidptr``, ``None``, a Python CObject, or an integer. The - type has the following methods: - - __int__() - This returns the pointer as an integer. - - __hex__() - This returns the pointer as a hexadecimal string. - - ascobject() - This returns the pointer as a Python CObject. - - asstring(nbytes) - This returns a copy of the first *nbytes* of memory at the pointer as a - Python string. - -wrapinstance(addr, type) - A C/C++ structure or class instance is wrapped and the Python object - created is returned. If the instance has already been wrapped then a new - reference to the existing object is returned. *addr* is the address of - the instance represented as a number. *type* is the type of the object - (e.g. ``qt.QWidget``). - -wrapper - This is the type object of the base type of all instances wrapped by SIP. - -wrappertype - This is the type object of the metatype of the ``wrapper`` type. - - -The SIP Build System -==================== - -The purpose of the build system is to make it easy for you to write -configuration scripts in Python for your own bindings. The build system takes -care of the details of particular combinations of platform and compiler. It -supports over 50 different platform/compiler combinations. - -The build system is implemented as a pure Python module called ``sipconfig`` -that contains a number of classes and functions. Using this module you can -write bespoke configuration scripts (e.g. PyQt's ``configure.py``) or use it -with other Python based build systems (e.g. -`Distutils <http://www.python.org/sigs/distutils-sig/distutils.html>`_ and -`SCons <http://www.scons.org>`_). - -An important feature of SIP is the ability to generate bindings that are built -on top of existing bindings. For example, both -`PyKDE <http://www.riverbankcomputing.co.uk/pykde/>`_ and -`PyQwt <http://pyqwt.sourceforge.net/>`_ are built on top of PyQt but all three -packages are maintained by different developers. To make this easier PyQt -includes its own configuration module, ``pyqtconfig``, that contains additional -classes intended to be used by the configuration scripts of bindings built on -top of PyQt. The SIP build system includes facilities that do a lot of the -work of creating these additional configuration modules. - - -``sipconfig`` Functions ------------------------ - -create_config_module(module, template, content, macros=None) - This creates a configuration module (e.g. ``pyqtconfig``) from a template - file and a string. - - ``module`` is the name of the configuration module file to create. - - ``template`` is the name of the template file. - - ``content`` is a string which replaces every occurence of the pattern - ``@SIP_CONFIGURATION@`` in the template file. The content string is - usually created from a Python dictionary using - ``sipconfig.create_content()``. ``content`` may also be a dictionary, in - which case ``sipconfig.create_content()`` is automatically called to - convert it to a string. - - ``macros`` is an optional dictionary of platform specific build macros. It - is only used if ``sipconfig.create_content()`` is called automatically to - convert a ``content`` dictionary to a string. - -create_content(dict, macros=None) - This converts a Python dictionary to a string that can be parsed by the - Python interpreter and converted back to an equivalent dictionary. It is - typically used to generate the content string for - ``sipconfig.create_config_module()``. - - ``dict`` is the Python dictionary to convert. - - ``macros`` is the optional dictionary of platform specific build macros. - - Returns the dictionary as a string. - -create_wrapper(script, wrapper, gui=0) - This creates a platform dependent executable wrapper around a Python - script. - - ``script`` is the full pathname of the script. - - ``wrapper`` is the pathname of the wrapper to create. - - ``gui`` is non-zero if a GUI enabled version of the interpreter should be - used on platforms that require it. - - Returns the platform specific name of the wrapper. - -error(msg) - This displays an error message on ``stderr`` and calls ``sys.exit()`` with - a value of 1. - - ``msg`` is the text of the message and should not include any newline - characters. - -format(msg, leftmargin=0, rightmargin=78) - This formats a message by inserting newline characters at appropriate - places. - - ``msg`` is the text of the message and should not include any newline - characters. - - ``leftmargin`` is the optional position of the left margin. - - ``rightmargin`` is the optional position of the right margin. - -inform(msg) - This displays an information message on ``stdout``. - - ``msg`` is the text of the message and should not include any newline - characters. - -parse_build_macros(filename, names, overrides=None, properties=None) - This parses a qmake compatible file of build system macros and converts it - to a dictionary. A macro is a name/value pair. The dictionary is returned - or None if any of the overrides was invalid. - - ``filename`` is the name of the file to parse. - - ``names`` is a list of the macro names to extract from the file. - - ``overrides`` is an optional list of macro names and values that modify - those found in the file. They are of the form *name=value* (in which case - the value replaces the value found in the file) or *name+=value* (in which - case the value is appended to the value found in the file). - - ``properties`` is an optional dictionary of property name and values that - are used to resolve any expressions of the form ``$[name]`` in the file. - -read_version(filename, description, numdefine=None, strdefine=None) - This extracts version information for a package from a file, usually a C or - C++ header file. The version information must each be specified as a - ``#define`` of a numeric (hexadecimal or decimal) value and/or a string - value. - - ``filename`` is the name of the file to read. - - ``description`` is a descriptive name of the package used in error - messages. - - ``numdefine`` is the optional name of the ``#define`` of the version as a - number. If it is ``None`` then the numeric version is ignored. - - ``strdefine`` is the optional name of the ``#define`` of the version as a - string. If it is ``None`` then the string version is ignored. - - Returns a tuple of the numeric and string versions. ``sipconfig.error()`` - is called if either were required but could not be found. - -version_to_sip_tag(version, tags, description) - This converts a version number to a SIP version tag. SIP uses the - `%Timeline`_ directive to define the chronology of the different versions - of the C/C++ library being wrapped. Typically it is not necessary to - define a version tag for every version of the library, but only for those - versions that affect the library's API as SIP sees it. - - ``version`` is the numeric version number of the C/C++ library being - wrapped. If it is negative then the latest version is assumed. (This is - typically useful if a snapshot is indicated by a negative version number.) - - ``tags`` is the dictionary of SIP version tags keyed by the corresponding - C/C++ library version number. The tag used is the one with the smallest - key (i.e. earliest version) that is greater than ``version``. - - ``description`` is a descriptive name of the C/C++ library used in error - messages. - - Returns the SIP version tag. ``sipconfig.error()`` is called if the C/C++ - library version number did not correspond to a SIP version tag. - -version_to_string(v) - This converts a 3 part version number encoded as a hexadecimal value to a - string. - - ``v`` is the version number. - - Returns a string. - - -``sipconfig`` Classes ---------------------- - -Configuration - This class encapsulates configuration values that can be accessed as - instance objects. A sub-class may provide a dictionary of additional - configuration values in its constructor the elements of which will have - precedence over the super-class's values. - - The following configuration values are provided: - - default_bin_dir - The name of the directory where executables should be installed by - default. - - default_mod_dir - The name of the directory where SIP generated modules should be - installed by default. - - default_sip_dir - The name of the base directory where the ``.sip`` files for SIP - generated modules should be installed by default. A sub-directory - with the same name as the module should be created and its ``.sip`` - files should be installed in the sub-directory. The ``.sip`` - files only need to be installed if you might want to build other - bindings based on them. - - platform - The name of the platform/compiler for which the build system has - been configured for. - - py_conf_inc_dir - The name of the directory containing the ``pyconfig.h`` header - file. - - py_inc_dir - The name of the directory containing the ``Python.h`` header file. - - py_lib_dir - The name of the directory containing the Python interpreter - library. - - py_version - The Python version as a 3 part hexadecimal number (e.g. v2.3.3 is - represented as ``0x020303``). - - sip_bin - The full pathname of the SIP executable. - - sip_config_args - The command line passed to ``configure.py`` when SIP was - configured. - - sip_inc_dir - The name of the directory containing the ``sip.h`` header file. - - sip_mod_dir - The name of the directory containing the SIP module. - - sip_version - The SIP version as a 3 part hexadecimal number (e.g. v4.0.0 is - represented as ``0x040000``). - - sip_version_str - The SIP version as a string. For development snapshots it will - start with ``snapshot-``. - - universal - The name of the MacOS/X SDK used when creating universal binaries. - - __init__(self, sub_cfg=None) - Initialise the instance. - - ``sub_cfg`` is an optional list of sub-class configurations. It should - only be used by the ``__init__()`` method of a sub-class to append its - own dictionary of configuration values before passing the list to its - super-class. - - build_macros(self) - Return the dictionary of platform specific build macros. - - set_build_macros(self, macros) - Set the dictionary of platform specific build macros to be use when - generating Makefiles. Normally there is no need to change the default - macros. - -Makefile - This class encapsulates a Makefile. It is intended to be sub-classed to - generate Makefiles for particular purposes. It handles all platform and - compiler specific flags, but allows them to be adjusted to suit the - requirements of a particular module or program. These are defined using a - number of macros which can be accessed as instance objects. - - The following instance objects are provided to help in fine tuning the - generated Makefile: - - chkdir - A string that will check for the existence of a directory. - - config - A reference to the ``configuration`` argument that was passed to - the constructor. - - console - A reference to the ``console`` argument that was passed to the - constructor. - - copy - A string that will copy a file. - - extra_cflags - A list of additional flags passed to the C compiler. - - extra_cxxflags - A list of additional flags passed to the C++ compiler. - - extra_defines - A list of additional macro names passed to the C/C++ preprocessor. - - extra_include_dirs - A list of additional include directories passed to the C/C++ - preprocessor. - - extra_lflags - A list of additional flags passed to the linker. - - extra_lib_dirs - A list of additional library directories passed to the linker. - - extra_libs - A list of additional libraries passed to the linker. The names of - the libraries must be in platform neutral form (i.e. without any - platform specific prefixes, version numbers or extensions). - - generator - A string that defines the platform specific style of Makefile. The - only supported values are ``UNIX`` and something else that is not - ``UNIX``. - - mkdir - A string that will create a directory. - - rm - A string that will remove a file. - - __init__(self, configuration, console=0, qt=0, opengl=0, python=0, threaded=0, warnings=None, debug=0, dir=None, makefile="Makefile", installs=None, universal='') - Initialise the instance. - - ``configuration`` is the current configuration and is an instance of - the ``Configuration`` class or a sub-class. - - ``console`` is set if the target is a console (rather than GUI) target. - This only affects Windows and is ignored on other platforms. - - ``qt`` is set if the target uses Qt. For Qt v4 a list of Qt libraries - may be specified and a simple non-zero value implies QtCore and QtGui. - - ``opengl`` is set if the target uses OpenGL. - - ``python`` is set if the target uses Python.h. - - ``threaded`` is set if the target requires thread support. It is set - automatically if the target uses Qt and Qt has thread support enabled. - - ``warnings`` is set if compiler warning messages should be enabled. - The default of ``None`` means that warnings are enabled for SIP v4.x - and disabled for SIP v3.x. - - ``debug`` is set if debugging symbols should be generated. - - ``dir`` is the name of the directory where build files are read from - and Makefiles are written to. The default of ``None`` means the - current directory is used. - - ``makefile`` is the name of the generated Makefile. - - ``installs`` is a list of extra install targets. Each element is a two - part list, the first of which is the source and the second is the - destination. If the source is another list then it is a list of source - files and the destination is a directory. - - ``universal`` is the name of the SDK if universal binaries are to be - created under MacOS/X. - - clean_build_file_objects(self, mfile, build) - This generates the Makefile commands that will remove any files - generated during the build of the default target. - - ``mfile`` is the Python file object of the Makefile. - - ``build`` is the dictionary created from parsing the build file. - - finalise(self) - This is called just before the Makefile is generated to ensure that it - is fully configured. It must be reimplemented by a sub-class. - - generate(self) - This generates the Makefile. - - generate_macros_and_rules(self, mfile) - This is the default implementation of the Makefile macros and rules - generation. - - ``mfile`` is the Python file object of the Makefile. - - generate_target_clean(self, mfile) - This is the default implementation of the Makefile clean target - generation. - - ``mfile`` is the Python file object of the Makefile. - - generate_target_default(self, mfile) - This is the default implementation of the Makefile default target - generation. - - ``mfile`` is the Python file object of the Makefile. - - generate_target_install(self, mfile) - This is the default implementation of the Makefile install target - generation. - - ``mfile`` is the Python file object of the Makefile. - - install_file(self, mfile, src, dst, strip=0) - This generates the Makefile commands to install one or more files to a - directory. - - ``mfile`` is the Python file object of the Makefile. - - ``src`` is the name of a single file to install or a list of a number - of files to install. - - ``dst`` is the name of the destination directory. - - ``strip`` is set if the files should be stripped of unneeded symbols - after having been installed. - - optional_list(self, name) - This returns an optional Makefile macro as a list. - - ``name`` is the name of the macro. - - Returns the macro as a list. - - optional_string(self, name, default="") - This returns an optional Makefile macro as a string. - - ``name`` is the name of the macro. - - ``default`` is the optional default value of the macro. - - Returns the macro as a string. - - parse_build_file(self, filename) - This parses a build file (created with the ``-b`` SIP command line - option) and converts it to a dictionary. It can also validate an - existing dictionary created through other means. - - ``filename`` is the name of the build file, or is a dictionary to be - validated. A valid dictionary will contain the name of the target to - build (excluding any platform specific extension) keyed by ``target``; - the names of all source files keyed by ``sources``; and, optionally, - the names of all header files keyed by ``headers``. - - Returns a dictionary corresponding to the parsed build file. - - platform_lib(self, clib, framework=0) - This converts a library name to a platform specific form. - - ``clib`` is the name of the library in cannonical form. - - ``framework`` is set if the library is implemented as a MacOS - framework. - - Return the platform specific name. - - ready(self) - This is called to ensure that the Makefile is fully configured. It is - normally called automatically when needed. - - required_string(self, name) - This returns a required Makefile macro as a string. - - ``name`` is the name of the macro. - - Returns the macro as a string. An exception is raised if the macro - does not exist or has an empty value. - -ModuleMakefile(Makefile) - This class encapsulates a Makefile to build a generic Python extension - module. - - __init__(self, configuration, build_file, install_dir=None, static=0, console=0, opengl=0, threaded=0, warnings=None, debug=0, dir=None, makefile="Makefile", installs=None, strip=1, export_all=0, universal='') - Initialise the instance. - - ``configuration`` - see ``sipconfig.Makefile.__init__()``. - - ``build_file`` is the name of the build file. Build files are - generated using the ``-b`` SIP command line option. - - ``install_dir`` is the name of the directory where the module will be - optionally installed. - - ``static`` is set if the module should be built as a static library - (see `Builtin Modules and Custom Interpreters`_). - - ``console`` - see ``sipconfig.Makefile.__init__()``. - - ``qt`` - see ``sipconfig.Makefile.__init__()``. - - ``opengl`` - see ``sipconfig.Makefile.__init__()``. - - ``threaded`` - see ``sipconfig.Makefile.__init__()``. - - ``warnings`` - see ``sipconfig.Makefile.__init__()``. - - ``debug`` - see ``sipconfig.Makefile.__init__()``. - - ``dir`` - see ``sipconfig.Makefile.__init__()``. - - ``makefile`` - see ``sipconfig.Makefile.__init__()``. - - ``installs`` - see ``sipconfig.Makefile.__init__()``. - - ``strip`` is set if the module should be stripped of unneeded symbols - after installation. It is ignored if either ``debug`` or ``static`` is - set, or if the platform doesn't support it. - - ``export_all`` is set if all of the module's symbols should be exported - rather than just the module's initialisation function. Exporting all - symbols increases the size of the module and slows down module load - times but may avoid problems with modules that use C++ exceptions. All - symbols are exported if either ``debug`` or ``static`` is set, or if - the platform doesn't support it. - - finalise(self) - This is a reimplementation of ``sipconfig.Makefile.finalise()``. - - generate_macros_and_rules(self, mfile) - This is a reimplementation of - ``sipconfig.Makefile.generate_macros_and_rules()``. - - generate_target_clean(self, mfile) - This is a reimplementation of - ``sipconfig.Makefile.generate_target_clean()``. - - generate_target_default(self, mfile) - This is a reimplementation of - ``sipconfig.Makefile.generate_target_default()``. - - generate_target_install(self, mfile) - This is a reimplementation of - ``sipconfig.Makefile.generate_target_install()``. - - module_as_lib(self, mname) - This returns the name of a SIP v3.x module for when it is used as a - library to be linked against. An exception will be raised if it is - used with SIP v4.x modules. - - ``mname`` is the name of the module. - - Returns the corresponding library name. - -ParentMakefile(Makefile) - This class encapsulates a Makefile that sits above a number of other - Makefiles in sub-directories. - - __init__(self, configuration, subdirs, dir=None, makefile="Makefile", installs=None) - Initialise the instance. - - ``configuration`` - see ``sipconfig.Makefile.__init__()``. - - ``subdirs`` is the sequence of sub-directories. - - ``dir`` - see ``sipconfig.Makefile.__init__()``. - - ``makefile`` - see ``sipconfig.Makefile.__init__()``. - - ``installs`` - see ``sipconfig.Makefile.__init__()``. - - generate_macros_and_rules(self, mfile) - This is a reimplementation of - ``sipconfig.Makefile.generate_macros_and_rules()``. - - generate_target_clean(self, mfile) - This is a reimplementation of - ``sipconfig.Makefile.generate_target_clean()``. - - generate_target_default(self, mfile) - This is a reimplementation of - ``sipconfig.Makefile.generate_target_default()``. - - generate_target_install(self, mfile) - This is a reimplementation of - ``sipconfig.Makefile.generate_target_install()``. - -ProgramMakefile(Makefile) - This class encapsulates a Makefile to build an executable program. - - __init__(self, configuration, build_file=None, install_dir=None, console=0, qt=0, opengl=0, python=0, threaded=0, warnings=None, debug=0, dir=None, makefile="Makefile", installs=None, universal='') - Initialise the instance. - - ``configuration`` - see ``sipconfig.Makefile.__init__()``. - - ``build_file`` is the name of the optional build file. Build files are - generated using the ``-b`` SIP command line option. - - ``install_dir`` is the name of the directory where the executable - program will be optionally installed. - - ``console`` - see ``sipconfig.Makefile.__init__()``. - - ``qt`` - see ``sipconfig.Makefile.__init__()``. - - ``opengl`` - see ``sipconfig.Makefile.__init__()``. - - ``python`` - see ``sipconfig.Makefile.__init__()``. - - ``threaded`` - see ``sipconfig.Makefile.__init__()``. - - ``warnings`` - see ``sipconfig.Makefile.__init__()``. - - ``debug`` - see ``sipconfig.Makefile.__init__()``. - - ``dir`` - see ``sipconfig.Makefile.__init__()``. - - ``makefile`` - see ``sipconfig.Makefile.__init__()``. - - ``installs`` - see ``sipconfig.Makefile.__init__()``. - - build_command(self, source) - This creates a single command line that will create an executable - program from a single source file. - - ``source`` is the name of the source file. - - Returns a tuple of the name of the executable that will be created and - the command line. - - finalise(self) - This is a reimplementation of ``sipconfig.Makefile.finalise()``. - - generate_macros_and_rules(self, mfile) - This is a reimplementation of - ``sipconfig.Makefile.generate_macros_and_rules()``. - - generate_target_clean(self, mfile) - This is a reimplementation of - ``sipconfig.Makefile.generate_target_clean()``. - - generate_target_default(self, mfile) - This is a reimplementation of - ``sipconfig.Makefile.generate_target_default()``. - - generate_target_install(self, mfile) - This is a reimplementation of - ``sipconfig.Makefile.generate_target_install()``. - -PythonModuleMakefile(Makefile) - This class encapsulates a Makefile that installs a pure Python module. - - __init__(self, configuration, dstdir, srcdir=None, dir=None, makefile="Makefile", installs=None) - Initialise the instance. - - ``configuration`` - see ``sipconfig.Makefile.__init__()``. - - ``dstdir`` is the name of the directory in which the module's Python - code will be installed. - - ``srcdir`` is the name of the directory (relative to ``dir``) - containing the module's Python code. It defaults to the same - directory. - - ``dir`` - see ``sipconfig.Makefile.__init__()``. - - ``makefile`` - see ``sipconfig.Makefile.__init__()``. - - ``installs`` - see ``sipconfig.Makefile.__init__()``. - - generate_macros_and_rules(self, mfile) - This is a reimplementation of - ``sipconfig.Makefile.generate_macros_and_rules()``. - - generate_target_install(self, mfile) - This is a reimplementation of - ``sipconfig.Makefile.generate_target_install()``. - -SIPModuleMakefile(ModuleMakefile) - This class encapsulates a Makefile to build a SIP generated Python - extension module. - - finalise(self) - This is a reimplementation of ``sipconfig.Makefile.finalise()``. - - -Building Your Extension with distutils -====================================== - -To build the example in `A Simple C++ Example`_ using distutils, it is -sufficient to create a standard ``setup.py``, listing ``word.sip`` among the -files to build, and hook-up SIP into distutils:: - - from distutils.core import setup, Extension - import sipdistutils - - setup( - name = 'word', - versione = '1.0', - ext_modules=[ - Extension("word", ["word.sip", "word.cpp"]), - ], - - cmdclass = {'build_ext': sipdistutils.build_ext} - ) - -As we can see, the above is a normal distutils setup script, with just a -special line which is needed so that SIP can see and process ``word.sip``. -Then, running ``setup.py build`` will build our extension module. - - -Builtin Modules and Custom Interpreters -======================================= - -Sometimes you want to create a custom Python interpreter with some modules -built in to the interpreter itself rather than being dynamically loaded. To -do this the module must be created as a static library and linked with a -custom stub and the normal Python library. - -To build the SIP module as a static library you must pass the ``-k`` command -line option to ``configure.py``. You should then build and install SIP as -normal. (Note that, because the module is now a static library, you will not -be able to import it.) - -To build a module you have created for your own library you must modify your -own configuration script to pass a non-zero value as the ``static`` argument -of the ``__init__()`` method of the ``ModuleMakefile`` class (or any derived -class you have created). Normally you would make this configurable using a -command line option in the same way that SIP's ``configure.py`` handles it. - -The next stage is to create a custom stub and a Makefile. The SIP distribution -contains a directory called ``custom`` which contains example stubs and a -Python script that will create a correct Makefile. Note that, if your copy of -SIP was part of a standard Linux distribution, the ``custom`` directory may -not be installed on your system. - -The ``custom`` directory contains the following files. They are provided as -examples - each needs to be modified according to your particular -requirements. - - - ``mkcustom.py`` is a Python script that will create a Makefile which is - then used to build the custom interpreter. Comments in the file describe - how it should be modified. - - - ``custom.c`` is a stub for a custom interpreter on Linux/UNIX. It - should also be used for a custom console interpreter on Windows (i.e. - like ``python.exe``). Comments in the file describe how it should be - modified. - - - ``customw.c`` is a stub for a custom GUI interpreter on Windows (i.e. - like ``pythonw.exe``). Comments in the file describe how it should be - modified. - -Note that this technique does not restrict how the interpreter can be used. -For example, it still allows users to write their own applications that can -import your builtin modules. If you want to prevent users from doing that, -perhaps to protect a proprietary API, then take a look at the -`VendorID <http://www.riverbankcomputing.co.uk/vendorid/>`__ package. diff --git a/python/sip/sipdistutils.py b/python/sip/sipdistutils.py deleted file mode 100644 index 1c2ab7ed..00000000 --- a/python/sip/sipdistutils.py +++ /dev/null @@ -1,90 +0,0 @@ -# Subclasses disutils.command.build_ext, -# replacing it with a SIP version that compiles .sip -> .cpp -# before calling the original build_ext command. -# Written by Giovanni Bajo <rasky at develer dot com> -# Based on Pyrex.Distutils, written by Graham Fawcett and Darrel Gallion. - -import distutils.command.build_ext -from distutils.dep_util import newer, newer_group -import os -import sys - -def replace_suffix(path, new_suffix): - return os.path.splitext(path)[0] + new_suffix - -class build_ext (distutils.command.build_ext.build_ext): - - description = "Compiler SIP descriptions, then build C/C++ extensions (compile/link to build directory)" - - def _get_sip_output_list(self, sbf): - """ - Parse the sbf file specified to extract the name of the generated source - files. Make them absolute assuming they reside in the temp directory. - """ - for L in file(sbf): - key, value = L.split("=", 1) - if key.strip() == "sources": - out = [] - for o in value.split(): - out.append(os.path.join(self.build_temp, o)) - return out - - raise RuntimeError, "cannot parse SIP-generated '%s'" % sbf - - def _find_sip(self): - import sipconfig - cfg = sipconfig.Configuration() - return cfg.sip_bin - - def _sip_inc_dir(self): - import sipconfig - cfg = sipconfig.Configuration() - return cfg.sip_inc_dir - - def swig_sources (self, sources, extension=None): - if not self.extensions: - return - - # Add the SIP include directory to the include path - if extension is not None: - extension.include_dirs.append(self._sip_inc_dir()) - depends = extension.depends - else: - # pre-2.4 compatibility - self.include_dirs.append(self._sip_inc_dir()) - depends = [] # ? - - # Filter dependencies list: we are interested only in .sip files, - # since the main .sip files can only depend on additional .sip - # files. For instance, if a .h changes, there is no need to - # run sip again. - depends = [f for f in depends if os.path.splitext(f)[1] == ".sip"] - - # Create the temporary directory if it does not exist already - if not os.path.isdir(self.build_temp): - os.makedirs(self.build_temp) - - # Collect the names of the source (.sip) files - sip_sources = [] - sip_sources = [source for source in sources if source.endswith('.sip')] - other_sources = [source for source in sources if not source.endswith('.sip')] - generated_sources = [] - - sip_bin = self._find_sip() - - for sip in sip_sources: - # Use the sbf file as dependency check - sipbasename = os.path.basename(sip) - sbf = os.path.join(self.build_temp, replace_suffix(sipbasename, ".sbf")) - if newer_group([sip]+depends, sbf) or self.force: - self._sip_compile(sip_bin, sip, sbf) - out = self._get_sip_output_list(sbf) - generated_sources.extend(out) - - return generated_sources + other_sources - - def _sip_compile(self, sip_bin, source, sbf): - self.spawn([sip_bin, - "-c", self.build_temp, - "-b", sbf, - source]) diff --git a/python/sip/sipgen/export.c b/python/sip/sipgen/export.c deleted file mode 100644 index 5200b2cf..00000000 --- a/python/sip/sipgen/export.c +++ /dev/null @@ -1,998 +0,0 @@ -/* - * The XML and API file generator module for SIP. - * - * Copyright (c) 2007 - * Riverbank Computing Limited <info@riverbankcomputing.co.uk> - * - * This file is part of SIP. - * - * This copy of SIP is licensed for use under the terms of the SIP License - * Agreement. See the file LICENSE for more details. - * - * SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - - -#include <stdio.h> - -#include "sip.h" - - -#define XML_VERSION_NR 0 /* The schema version number. */ - - -static void apiEnums(sipSpec *pt, classDef *scope, FILE *fp); -static void apiVars(sipSpec *pt, classDef *scope, FILE *fp); -static int apiCtor(sipSpec *pt, classDef *scope, ctorDef *ct, int sec, - FILE *fp); -static int apiOverload(sipSpec *pt, classDef *scope, overDef *od, int sec, - FILE *fp); -static int apiArgument(argDef *ad, int out, int need_comma, int sec, FILE *fp); -static void xmlClass(sipSpec *pt, classDef *cd, FILE *fp); -static void xmlEnums(sipSpec *pt, classDef *scope, int indent, FILE *fp); -static void xmlVars(sipSpec *pt, classDef *scope, int indent, FILE *fp); -static void xmlFunction(classDef *scope, memberDef *md, overDef *oloads, - int indent, FILE *fp); -static int xmlCtor(classDef *scope, ctorDef *ct, int sec, int indent, FILE *fp); -static int xmlOverload(classDef *scope, memberDef *md, overDef *od, - classDef *xtnds, int stat, int sec, int indent, FILE *fp); -static void xmlCppSignature(FILE *fp, overDef *od); -static void xmlArgument(argDef *ad, const char *dir, int res_xfer, int sec, - int indent, FILE *fp); -static void xmlType(argDef *ad, int sec, FILE *fp); -static void xmlIndent(int indent, FILE *fp); -static const char *dirAttribute(argDef *ad); -static void exportDefaultValue(argDef *ad, FILE *fp); -static const char *pyType(argDef *ad, int sec, classDef **scope); - - -/* - * Generate the API file. - */ -void generateAPI(sipSpec *pt, const char *apiFile) -{ - overDef *od; - classDef *cd; - FILE *fp; - - /* Generate the file. */ - if ((fp = fopen(apiFile, "w")) == NULL) - fatal("Unable to create file \"%s\"\n", apiFile); - - apiEnums(pt, NULL, fp); - apiVars(pt, NULL, fp); - - for (od = pt->overs; od != NULL; od = od->next) - { - if (od->common->module != pt->module) - continue; - - if (od->common->slot != no_slot) - continue; - - if (apiOverload(pt, NULL, od, FALSE, fp)) - apiOverload(pt, NULL, od, TRUE, fp); - } - - for (cd = pt->classes; cd != NULL; cd = cd->next) - { - ctorDef *ct; - - if (cd->iff->module != pt->module) - continue; - - if (isExternal(cd)) - continue; - - apiEnums(pt, cd, fp); - apiVars(pt, cd, fp); - - for (ct = cd->ctors; ct != NULL; ct = ct->next) - { - if (isPrivateCtor(ct)) - continue; - - if (apiCtor(pt, cd, ct, FALSE, fp)) - apiCtor(pt, cd, ct, TRUE, fp); - } - - for (od = cd->overs; od != NULL; od = od->next) - { - if (isPrivate(od)) - continue; - - if (od->common->slot != no_slot) - continue; - - if (apiOverload(pt, cd, od, FALSE, fp)) - apiOverload(pt, cd, od, TRUE, fp); - } - } - - fclose(fp); -} - - -/* - * Generate an API ctor. - */ -static int apiCtor(sipSpec *pt, classDef *scope, ctorDef *ct, int sec, - FILE *fp) -{ - int need_sec = FALSE, need_comma, a; - - /* Do the callable type form. */ - fprintf(fp, "%s.", pt->module->name); - prScopedPythonName(fp, scope->ecd, scope->pyname); - fprintf(fp, "("); - - need_comma = FALSE; - - for (a = 0; a < ct->pysig.nrArgs; ++a) - { - argDef *ad = &ct->pysig.args[a]; - - need_comma = apiArgument(ad, FALSE, need_comma, sec, fp); - - if (ad->atype == rxcon_type || ad->atype == rxdis_type) - need_sec = TRUE; - } - - fprintf(fp, ")\n"); - - /* Do the call __init__ form. */ - fprintf(fp, "%s.", pt->module->name); - prScopedPythonName(fp, scope->ecd, scope->pyname); - fprintf(fp, ".__init__(self"); - - for (a = 0; a < ct->pysig.nrArgs; ++a) - apiArgument(&ct->pysig.args[a], FALSE, TRUE, sec, fp); - - fprintf(fp, ")\n"); - - return need_sec; -} - - -/* - * Generate the APIs for all the enums in a scope. - */ -static void apiEnums(sipSpec *pt, classDef *scope, FILE *fp) -{ - enumDef *ed; - - for (ed = pt->enums; ed != NULL; ed = ed->next) - { - enumMemberDef *emd; - - if (ed->module != pt->module) - continue; - - if (ed->ecd != scope) - continue; - - if (ed->pyname != NULL) - { - fprintf(fp, "%s.", pt->module->name); - prScopedPythonName(fp, ed->ecd, ed->pyname->text); - fprintf(fp, "\n"); - } - - for (emd = ed->members; emd != NULL; emd = emd->next) - { - fprintf(fp, "%s.", pt->module->name); - prScopedPythonName(fp, ed->ecd, emd->pyname->text); - fprintf(fp, "\n"); - } - } -} - - -/* - * Generate the APIs for all the variables in a scope. - */ -static void apiVars(sipSpec *pt, classDef *scope, FILE *fp) -{ - varDef *vd; - - for (vd = pt->vars; vd != NULL; vd = vd->next) - { - if (vd->module != pt->module) - continue; - - if (vd->ecd != scope) - continue; - - fprintf(fp, "%s.", pt->module->name); - prScopedPythonName(fp, vd->ecd, vd->pyname->text); - fprintf(fp, "\n"); - } -} - - -/* - * Generate a single API overload. - */ -static int apiOverload(sipSpec *pt, classDef *scope, overDef *od, int sec, - FILE *fp) -{ - int need_sec = FALSE, need_comma = FALSE, is_res, nr_out, a; - - fprintf(fp, "%s.", pt->module->name); - prScopedPythonName(fp, scope, od->common->pyname->text); - fprintf(fp, "("); - - if (scope != NULL && scope->iff->type != namespace_iface && !isStatic(od)) - { - fprintf(fp, "self"); - need_comma = TRUE; - } - - nr_out = 0; - - for (a = 0; a < od->pysig.nrArgs; ++a) - { - argDef *ad = &od->pysig.args[a]; - - if (isOutArg(ad)) - ++nr_out; - - if (!isInArg(ad)) - continue; - - need_comma = apiArgument(ad, FALSE, need_comma, sec, fp); - - if (ad->atype == rxcon_type || ad->atype == rxdis_type) - need_sec = TRUE; - } - - fprintf(fp, ")"); - - is_res = (od->pysig.result.atype != void_type || od->pysig.result.nrderefs != 0); - - if (is_res || nr_out > 0) - { - fprintf(fp, " -> "); - - if ((is_res && nr_out > 0) || nr_out > 1) - fprintf(fp, "("); - - if (is_res) - need_comma = apiArgument(&od->pysig.result, TRUE, FALSE, sec, fp); - else - need_comma = FALSE; - - for (a = 0; a < od->pysig.nrArgs; ++a) - { - argDef *ad = &od->pysig.args[a]; - - if (!isOutArg(ad)) - continue; - - need_comma = apiArgument(ad, TRUE, need_comma, sec, fp); - } - - if ((is_res && nr_out > 0) || nr_out > 1) - fprintf(fp, ")"); - } - - fprintf(fp, "\n"); - - return need_sec; -} - - -/* - * Generate the API for an argument. - */ -static int apiArgument(argDef *ad, int out, int need_comma, int sec, FILE *fp) -{ - const char *tname; - classDef *tscope; - - if (isArraySize(ad)) - return need_comma; - - if (sec && (ad->atype == slotcon_type || ad->atype == slotdis_type)) - return need_comma; - - if ((tname = pyType(ad, sec, &tscope)) == NULL) - return need_comma; - - if (need_comma) - fprintf(fp, ", "); - - prScopedPythonName(fp, tscope, tname); - - if (ad->name != NULL) - fprintf(fp, " %s", ad->name); - - /* - * Handle the default value, but ignore it if it is an output only - * argument. - */ - if (ad->defval && !out) - { - fprintf(fp, "="); - prcode(fp, "%M"); - exportDefaultValue(ad, fp); - prcode(fp, "%M"); - } - - return TRUE; -} - - -/* - * Generate the XML export file. - */ -void generateXML(sipSpec *pt, const char *xmlFile) -{ - FILE *fp; - classDef *cd; - memberDef *md; - - if ((fp = fopen(xmlFile, "w")) == NULL) - fatal("Unable to create file \"%s\"\n", xmlFile); - - fprintf(fp, "<?xml version=\"1.0\"?>\n"); - fprintf(fp, "<Module version=\"%u\" name=\"%s\">\n", - XML_VERSION_NR, pt->module->name); - - /* - * Note that we don't yet handle mapped types, templates or exceptions. - */ - - for (cd = pt->classes; cd != NULL; cd = cd->next) - { - if (cd->iff->module != pt->module) - continue; - - if (isExternal(cd)) - continue; - - xmlClass(pt, cd, fp); - } - - for (cd = pt->proxies; cd != NULL; cd = cd->next) - xmlClass(pt, cd, fp); - - xmlEnums(pt, NULL, 1, fp); - xmlVars(pt, NULL, 1, fp); - - for (md = pt->othfuncs; md != NULL; md = md->next) - { - if (md->module != pt->module) - continue; - - xmlFunction(NULL, md, pt->overs, 1, fp); - } - - fprintf(fp, "</Module>\n"); - - fclose(fp); -} - - -/* - * Generate the XML for a class. - */ -static void xmlClass(sipSpec *pt, classDef *cd, FILE *fp) -{ - int indent = 1; - ctorDef *ct; - memberDef *md; - - if (isOpaque(cd)) - { - xmlIndent(indent, fp); - fprintf(fp, "<OpaqueClass name=\"", cd->pyname); - prScopedPythonName(fp, cd->ecd, cd->pyname); - fprintf(fp, "\"/>\n"); - - return; - } - - xmlIndent(indent++, fp); - fprintf(fp, "<Class name=\"", cd->pyname); - prScopedPythonName(fp, cd->ecd, cd->pyname); - fprintf(fp, "\""); - - if (cd->convtocode != NULL) - fprintf(fp, " convert=\"1\""); - - if (cd->real != NULL) - fprintf(fp, " extends=\"%s\"", cd->real->iff->module->name); - - if (cd->supers != NULL) - { - classList *cl; - - fprintf(fp, " inherits=\""); - - for (cl = cd->supers; cl != NULL; cl = cl->next) - { - if (cl != cd->supers) - fprintf(fp, " "); - - prScopedPythonName(fp, cl->cd->ecd, cl->cd->pyname); - } - - fprintf(fp, "\""); - } - - fprintf(fp, ">\n"); - - xmlEnums(pt, cd, indent, fp); - xmlVars(pt, cd, indent, fp); - - for (ct = cd->ctors; ct != NULL; ct = ct->next) - { - if (isPrivateCtor(ct)) - continue; - - if (xmlCtor(cd, ct, FALSE, indent, fp)) - xmlCtor(cd, ct, TRUE, indent, fp); - } - - for (md = cd->members; md != NULL; md = md->next) - xmlFunction(cd, md, cd->overs, indent, fp); - - xmlIndent(--indent, fp); - fprintf(fp, "</Class>\n"); -} - - -/* - * Generate the XML for all the enums in a scope. - */ -static void xmlEnums(sipSpec *pt, classDef *scope, int indent, FILE *fp) -{ - enumDef *ed; - - for (ed = pt->enums; ed != NULL; ed = ed->next) - { - if (ed->module != pt->module) - continue; - - if (ed->ecd != scope) - continue; - - if (ed->pyname != NULL) - { - enumMemberDef *emd; - - xmlIndent(indent++, fp); - fprintf(fp, "<Enum name=\""); - prScopedPythonName(fp, ed->ecd, ed->pyname->text); - fprintf(fp, "\">\n"); - - for (emd = ed->members; emd != NULL; emd = emd->next) - { - xmlIndent(indent, fp); - fprintf(fp, "<EnumMember name=\""); - prScopedPythonName(fp, ed->ecd, emd->pyname->text); - fprintf(fp, "\"/>\n"); - } - - xmlIndent(--indent, fp); - fprintf(fp, "</Enum>\n"); - } - else - { - enumMemberDef *emd; - - for (emd = ed->members; emd != NULL; emd = emd->next) - { - xmlIndent(indent, fp); - fprintf(fp, "<Member name=\""); - prScopedPythonName(fp, ed->ecd, emd->pyname->text); - fprintf(fp, "\" const=\"1\" typename=\"int\"/>\n"); - } - } - } -} - - -/* - * Generate the XML for all the variables in a scope. - */ -static void xmlVars(sipSpec *pt, classDef *scope, int indent, FILE *fp) -{ - varDef *vd; - - for (vd = pt->vars; vd != NULL; vd = vd->next) - { - if (vd->module != pt->module) - continue; - - if (vd->ecd != scope) - continue; - - xmlIndent(indent, fp); - fprintf(fp, "<Member name=\""); - prScopedPythonName(fp, vd->ecd, vd->pyname->text); - fprintf(fp, "\""); - - if (isConstArg(&vd->type) || scope == NULL) - fprintf(fp, " const=\"1\""); - - if (isStaticVar(vd)) - fprintf(fp, " static=\"1\""); - - xmlType(&vd->type, FALSE, fp); - fprintf(fp, "/>\n"); - } -} - - -/* - * Generate the XML for a ctor. - */ -static int xmlCtor(classDef *scope, ctorDef *ct, int sec, int indent, FILE *fp) -{ - int a, need_sec; - - xmlIndent(indent++, fp); - fprintf(fp, "<Function name=\""); - prScopedPythonName(fp, scope, "__init__"); - fprintf(fp, "\""); - - /* Handle the trivial case. */ - if (ct->pysig.nrArgs == 0) - { - fprintf(fp, "/>\n"); - return FALSE; - } - - fprintf(fp, ">\n"); - - need_sec = FALSE; - - for (a = 0; a < ct->pysig.nrArgs; ++a) - { - argDef *ad = &ct->pysig.args[a]; - - xmlArgument(ad, dirAttribute(ad), FALSE, sec, indent, fp); - - if (ad->atype == rxcon_type || ad->atype == rxdis_type) - need_sec = TRUE; - } - - xmlIndent(--indent, fp); - fprintf(fp, "</Function>\n"); - - return need_sec; -} - - -/* - * Generate the XML for a function. - */ -static void xmlFunction(classDef *scope, memberDef *md, overDef *oloads, - int indent, FILE *fp) -{ - overDef *od; - - for (od = oloads; od != NULL; od = od->next) - { - int isstat; - classDef *xtnds; - - if (od->common != md) - continue; - - if (isPrivate(od)) - continue; - - if (isSignal(od)) - { - xmlIndent(indent, fp); - fprintf(fp, "<Signal name=\""); - prScopedPythonName(fp, scope, md->pyname->text); - fprintf(fp, "\" sig=\""); - xmlCppSignature(fp, od); - fprintf(fp, "\"/>\n", md->pyname->text); - - continue; - } - - xtnds = NULL; - isstat = (scope == NULL || scope->iff->type == namespace_iface || isStatic(od)); - - if (scope == NULL && md->slot != no_slot && od->pysig.args[0].atype == class_type) - { - xtnds = od->pysig.args[0].u.cd; - isstat = FALSE; - } - - if (xmlOverload(scope, md, od, xtnds, isstat, FALSE, indent, fp)) - xmlOverload(scope, md, od, xtnds, isstat, TRUE, indent, fp); - } -} - - -/* - * Generate the XML for an overload. - */ -static int xmlOverload(classDef *scope, memberDef *md, overDef *od, - classDef *xtnds, int stat, int sec, int indent, FILE *fp) -{ - int a, need_sec, no_res; - - xmlIndent(indent++, fp); - fprintf(fp, "<Function name=\""); - prScopedPythonName(fp, scope, md->pyname->text); - fprintf(fp, "\""); - - if (isAbstract(od)) - fprintf(fp, " abstract=\"1\""); - - if (stat) - fprintf(fp, " static=\"1\""); - - if (isSlot(od)) - { - fprintf(fp, " slot=\""); - xmlCppSignature(fp, od); - fprintf(fp, "\""); - } - - if (xtnds != NULL) - { - fprintf(fp, " extends=\""); - prScopedPythonName(fp, xtnds->ecd, xtnds->pyname); - fprintf(fp, "\""); - } - - no_res = (od->pysig.result.atype == void_type && od->pysig.result.nrderefs == 0); - - /* Handle the trivial case. */ - if (no_res && od->pysig.nrArgs == 0) - { - fprintf(fp, "/>\n"); - return FALSE; - } - - fprintf(fp, ">\n"); - - if (!no_res) - xmlArgument(&od->pysig.result, "out", isResultTransferredBack(od), FALSE, indent, fp); - - need_sec = FALSE; - - for (a = 0; a < od->pysig.nrArgs; ++a) - { - argDef *ad = &od->pysig.args[a]; - - /* Ignore the first argument of number slots. */ - if (isNumberSlot(md) && a == 0 && od->pysig.nrArgs == 2) - continue; - - xmlArgument(ad, dirAttribute(ad), FALSE, sec, indent, fp); - - if (ad->atype == rxcon_type || ad->atype == rxdis_type) - need_sec = TRUE; - } - - xmlIndent(--indent, fp); - fprintf(fp, "</Function>\n"); - - return need_sec; -} - - -/* - * Generate the XML for a C++ signature. - */ -static void xmlCppSignature(FILE *fp, overDef *od) -{ - prcode(fp, "%M"); - prOverloadDecl(fp, od, TRUE); - prcode(fp, "%M"); -} - - -/* - * Convert an arguments direction to an XML attribute value. - */ -static const char *dirAttribute(argDef *ad) -{ - if (isInArg(ad)) - { - if (isOutArg(ad)) - return "inout"; - - return NULL; - } - - return "out"; -} - - -/* - * Generate the XML for an argument. - */ -static void xmlArgument(argDef *ad, const char *dir, int res_xfer, int sec, - int indent, FILE *fp) -{ - if (isArraySize(ad)) - return; - - if (sec && (ad->atype == slotcon_type || ad->atype == slotdis_type)) - return; - - xmlIndent(indent, fp); - fprintf(fp, "<Argument"); - xmlType(ad, sec, fp); - - if (dir != NULL) - fprintf(fp, " dir=\"%s\"", dir); - - if (isAllowNone(ad)) - fprintf(fp, " allownone=\"1\""); - - if (isTransferred(ad)) - fprintf(fp, " transfer=\"to\""); - else if (isThisTransferred(ad)) - fprintf(fp, " transfer=\"this\""); - else if (res_xfer || isTransferredBack(ad)) - fprintf(fp, " transfer=\"back\""); - - /* - * Handle the default value, but ignore it if it is an output only - * argument. - */ - if (ad->defval && (dir == NULL || strcmp(dir, "out") != 0)) - { - prcode(fp, " default=\"%M"); - exportDefaultValue(ad, fp); - prcode(fp, "%M\""); - } - - fprintf(fp, "/>\n"); -} - - -/* - * Generate the XML for a type. - */ -static void xmlType(argDef *ad, int sec, FILE *fp) -{ - const char *type_type = NULL, *type_name; - classDef *type_scope; - - fprintf(fp, " typename=\""); - - switch (ad->atype) - { - case class_type: - type_type = (isOpaque(ad->u.cd) ? "opaque" : "class"); - break; - - case enum_type: - if (ad->u.ed->pyname != NULL) - type_type = "enum"; - break; - - case rxcon_type: - case rxdis_type: - if (!sec) - type_type = "class"; - break; - - case qobject_type: - type_type = "class"; - break; - - case slotcon_type: - case slotdis_type: - { - int a; - - prcode(fp, "TQT_SLOT("); - - for (a = 0; a < ad->u.sa->nrArgs; ++a) - { - if (a > 0) - prcode(fp, ", "); - - prcode(fp, "%M%B%M", &ad->u.sa->args[a]); - } - - prcode(fp, ")"); - } - - break; - - case mapped_type: - prcode(fp, "%M%B%M", &ad->u.mtd->type); - type_type = "mappedtype"; - break; - } - - if ((type_name = pyType(ad, sec, &type_scope)) != NULL) - prScopedPythonName(fp, type_scope, type_name); - - fprintf(fp, "\""); - - if (type_type != NULL) - fprintf(fp, " typetype=\"%s\"", type_type); - - if (ad->name != NULL) - fprintf(fp, " name=\"%s\"", ad->name); -} - - -/* - * Generate the indentation for a line. - */ -static void xmlIndent(int indent, FILE *fp) -{ - while (indent-- > 0) - fprintf(fp, " "); -} - - -/* - * Export the default value of an argument. - */ -static void exportDefaultValue(argDef *ad, FILE *fp) -{ - /* Translate some special cases. */ - if (ad->defval->next == NULL && ad->defval->vtype == numeric_value) - { - if (ad->nrderefs > 0 && ad->defval->u.vnum == 0) - { - prcode(fp, "None"); - return; - } - - if (ad->atype == bool_type || ad->atype == cbool_type) - { - prcode(fp, ad->defval->u.vnum ? "True" : "False"); - return; - } - } - - generateExpression(ad->defval, fp); -} - - -/* - * Get the Python representation of a type. - */ -static const char *pyType(argDef *ad, int sec, classDef **scope) -{ - const char *type_name; - - *scope = NULL; - - switch (ad->atype) - { - case class_type: - type_name = ad->u.cd->pyname; - *scope = ad->u.cd->ecd; - break; - - case struct_type: - case void_type: - type_name = "sip.voidptr"; - break; - - case enum_type: - if (ad->u.ed->pyname != NULL) - { - type_name = ad->u.ed->pyname->text; - *scope = ad->u.ed->ecd; - } - else - type_name = "int"; - break; - - case signal_type: - type_name = "TQT_SIGNAL()"; - break; - - case slot_type: - type_name = "TQT_SLOT()"; - break; - - case rxcon_type: - case rxdis_type: - if (sec) - type_name = "callable"; - else - type_name = "TQObject"; - - break; - - case qobject_type: - type_name = "TQObject"; - break; - - case ustring_type: - case string_type: - case sstring_type: - case wstring_type: - if (ad->nrderefs > 0) - type_name = "str"; - else - type_name = "char"; - - break; - - case short_type: - case int_type: - case cint_type: - type_name = "int"; - break; - - case ushort_type: - case uint_type: - case ulong_type: - case ulonglong_type: - type_name = "unsigned long"; - break; - - case long_type: - case longlong_type: - type_name = "long"; - break; - - case float_type: - case cfloat_type: - case double_type: - case cdouble_type: - type_name = "float"; - break; - - case bool_type: - case cbool_type: - type_name = "bool"; - break; - - case pyobject_type: - type_name = "object"; - break; - - case pytuple_type: - type_name = "tuple"; - break; - - case pylist_type: - type_name = "list"; - break; - - case pydict_type: - type_name = "dict"; - break; - - case pycallable_type: - type_name = "callable"; - break; - - case pyslice_type: - type_name = "slice"; - break; - - case pytype_type: - type_name = "type"; - break; - - case ellipsis_type: - type_name = "..."; - break; - - case anyslot_type: - /* Need to check if this is enough. */ - type_name = "TQT_SLOT()"; - break; - - default: - type_name = NULL; - } - - return type_name; -} diff --git a/python/sip/sipgen/gencode.c b/python/sip/sipgen/gencode.c deleted file mode 100644 index ff1b93b9..00000000 --- a/python/sip/sipgen/gencode.c +++ /dev/null @@ -1,10820 +0,0 @@ -/* - * The code generator module for SIP. - * - * Copyright (c) 2007 - * Riverbank Computing Limited <info@riverbankcomputing.co.uk> - * - * This file is part of SIP. - * - * This copy of SIP is licensed for use under the terms of the SIP License - * Agreement. See the file LICENSE for more details. - * - * SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - - -#include <stdio.h> -#include <time.h> -#include <errno.h> -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> - -#include "sip.h" - - -/* - * These must match the values of SIP_TYPE_FLAGS_SHIFT and SIP_TYPE_FLAGS_MASK - * in siplib/sip.h. - */ -#define TYPE_FLAGS_SHIFT 8 -#define TYPE_FLAGS_MASK 0x0f00 - - -/* Control what generateSingleArg() actually generates. */ -typedef enum { - Call, - Declaration, - Definition -} funcArgType; - - -/* An entry in the sorted array of methods. */ -typedef struct { - memberDef *md; /* The method. */ - int is_static; /* Set if all overloads are static. */ -} sortedMethTab; - - -static int currentLineNr; /* Current output line number. */ -static char *currentFileName; /* Current output file name. */ -static int previousLineNr; /* Previous output line number. */ -static char *previousFileName; /* Previous output file name. */ -static int exceptions; /* Set if exceptions are enabled. */ -static int tracing; /* Set if tracing is enabled. */ -static int generating_c; /* Set if generating C. */ -static int release_gil; /* Set if always releasing the GIL. */ -static const char *prcode_last = NULL; /* The last prcode format string. */ -static int prcode_xml = FALSE; /* Set if prcode is XML aware. */ - - -static void generateDocumentation(sipSpec *, char *); -static void generateBuildFile(sipSpec *, char *, char *, int); -static void generateInternalAPIHeader(sipSpec *, char *, stringList *); -static void generateCpp(sipSpec *, char *, char *, int *); -static void generateIfaceCpp(sipSpec *, ifaceFileDef *, char *, char *, - FILE *); -static void generateMappedTypeCpp(mappedTypeDef *, FILE *); -static void generateImportedMappedTypeHeader(mappedTypeDef *mtd, sipSpec *pt, - FILE *fp); -static void generateMappedTypeHeader(mappedTypeDef *, int, FILE *); -static void generateClassCpp(classDef *cd, sipSpec *pt, FILE *fp); -static void generateImportedClassHeader(classDef *cd, sipSpec *pt, FILE *fp); -static void generateClassTableEntries(sipSpec *pt, nodeDef *nd, FILE *fp); -static void generateClassHeader(classDef *, int, sipSpec *, FILE *); -static void generateClassFunctions(sipSpec *, classDef *, FILE *); -static void generateShadowCode(sipSpec *, classDef *, FILE *); -static void generateFunction(sipSpec *, memberDef *, overDef *, classDef *, - classDef *, FILE *); -static void generateFunctionBody(sipSpec *, overDef *, classDef *, classDef *, - int deref, FILE *); -static void generateTypeDefinition(sipSpec *pt, classDef *cd, FILE *fp); -static void generateTypeInit(sipSpec *, classDef *, FILE *); -static void generateCppCodeBlock(codeBlock *, FILE *); -static void generateUsedIncludes(ifaceFileList *, int, FILE *); -static void generateIfaceHeader(sipSpec *, ifaceFileDef *, char *); -static void generateShadowClassDeclaration(sipSpec *, classDef *, FILE *); -static int hasConvertToCode(argDef *ad); -static void deleteTemps(signatureDef *sd, FILE *fp); -static void gc_ellipsis(signatureDef *sd, FILE *fp); -static void generateArgs(signatureDef *, funcArgType, FILE *); -static void generateVariable(argDef *, int, FILE *); -static void generateNamedValueType(argDef *, char *, FILE *); -static void generateSingleArg(argDef *, int, funcArgType, FILE *); -static void generateBaseType(argDef *, FILE *); -static void generateNamedBaseType(argDef *, char *, FILE *); -static void generateTupleBuilder(signatureDef *, FILE *); -static void generateEmitters(sipSpec *pt, classDef *cd, FILE *fp); -static void generateEmitter(sipSpec *, classDef *, visibleList *, FILE *); -static void generateVirtualHandler(sipSpec *, virtHandlerDef *, FILE *); -static void generateVirtHandlerErrorReturn(argDef *res, FILE *fp); -static void generateVirtualCatcher(sipSpec *, classDef *, int, virtOverDef *, - FILE *); -static void generateUnambiguousClass(classDef *cd, classDef *scope, FILE *fp); -static void generateProtectedEnums(sipSpec *, classDef *, FILE *); -static void generateProtectedDeclarations(classDef *, FILE *); -static void generateProtectedDefinitions(classDef *, FILE *); -static void generateProtectedCallArgs(overDef *od, FILE *fp); -static void generateConstructorCall(classDef *, ctorDef *, int, FILE *); -static void generateHandleResult(overDef *, int, char *, FILE *); -static void generateOrdinaryFunction(sipSpec *, classDef *, memberDef *, - FILE *); -static void generateSimpleFunctionCall(fcallDef *, FILE *); -static void generateFunctionCall(classDef *cd, classDef *ocd, overDef *od, - int deref, FILE *fp); -static void generateCppFunctionCall(classDef *cd, classDef *ocd, overDef *od, - FILE *fp); -static void generateSlotArg(signatureDef *sd, int argnr, FILE *fp); -static void generateBinarySlotCall(overDef *od, char *op, int deref, FILE *fp); -static void generateNumberSlotCall(overDef *od, char *op, FILE *fp); -static void generateVariableHandler(varDef *, FILE *); -static int generateObjToCppConversion(argDef *, FILE *); -static void generateVarClassConversion(varDef *, FILE *); -static void generateVarMember(varDef *vd, FILE *fp); -static int generateVoidPointers(sipSpec *, classDef *, FILE *); -static int generateChars(sipSpec *, classDef *, FILE *); -static int generateStrings(sipSpec *, classDef *, FILE *); -static sortedMethTab *createFunctionTable(classDef *, int *); -static sortedMethTab *createMethodTable(classDef *, int *); -static int generateMethodTable(classDef *, FILE *); -static void generateEnumMacros(sipSpec *pt, classDef *cd, FILE *fp); -static int generateEnumMemberTable(sipSpec *, classDef *, FILE *); -static int generateInts(sipSpec *, classDef *, FILE *); -static int generateLongs(sipSpec *, classDef *, FILE *); -static int generateUnsignedLongs(sipSpec *, classDef *, FILE *); -static int generateLongLongs(sipSpec *, classDef *, FILE *); -static int generateUnsignedLongLongs(sipSpec *, classDef *, FILE *); -static int generateVariableType(sipSpec *pt, classDef *cd, argType atype, - const char *eng, const char *s1, const char *s2, FILE *fp); -static int generateDoubles(sipSpec *, classDef *, FILE *); -static int generateEnums(sipSpec *, classDef *, FILE *); -static int generateClasses(sipSpec *, classDef *, FILE *); -static void generateEnumsInline(sipSpec *, FILE *); -static void generateClassesInline(sipSpec *, FILE *); -static void generateAccessFunctions(sipSpec *, classDef *, FILE *); -static void generateConvertToDefinitions(mappedTypeDef *, classDef *, FILE *); -static void generateEncodedClass(sipSpec *, classDef *, int, FILE *); -static int generateArgParser(sipSpec *, signatureDef *, classDef *, ctorDef *, - overDef *, int, FILE *); -static void generateTry(throwArgs *, FILE *); -static void generateCatch(throwArgs *ta, signatureDef *sd, FILE *fp); -static void generateThrowSpecifier(throwArgs *, FILE *); -static void generateSlot(sipSpec *pt, classDef *cd, enumDef *ed, memberDef *md, - FILE *fp); -static void generateCastZero(argDef *ad, FILE *fp); -static void generateCallDefaultCtor(ctorDef *ct, FILE *fp); -static int countVirtuals(classDef *); -static int skipOverload(overDef *, memberDef *, classDef *, classDef *, int); -static int compareMethTab(const void *, const void *); -static int compareEnumMembers(const void *, const void *); -static char *getSubFormatChar(char, argDef *); -static char *createIfaceFileName(char *, ifaceFileDef *, char *); -static FILE *createCompilationUnit(sipSpec *pt, char *fname, - char *description); -static FILE *createFile(sipSpec *, char *, char *); -static void closeFile(FILE *); -static void prScopedName(FILE *fp, scopedNameDef *snd, char *sep); -static void prTypeName(FILE *, argDef *, int); -static void prScopedClassName(FILE *, classDef *, char *); -static int isZeroArgSlot(memberDef *md); -static int isMultiArgSlot(memberDef *md); -static int isIntArgSlot(memberDef *md); -static int isInplaceNumberSlot(memberDef *md); -static int isInplaceSequenceSlot(memberDef *md); -static int needErrorFlag(codeBlock *cb); -static int needNewInstance(argDef *ad); -static int needDealloc(classDef *cd); -static char getBuildResultFormat(argDef *ad); -static const char *getParseResultFormat(argDef *ad, int isres, int xfervh); -static void generateParseResultExtraArgs(argDef *ad, int isres, FILE *fp); -static char *makePartName(char *codeDir, char *mname, int part, - char *srcSuffix); -static void normaliseArgs(signatureDef *); -static void restoreArgs(signatureDef *); -static const char *slotName(slotType st); -static void ints_intro(classDef *cd, FILE *fp); -static const char *argName(const char *name, codeBlock *cb); -static int usedInCode(codeBlock *code, const char *str); -static void generateDefaultValue(argDef *ad, int argnr, FILE *fp); -static void generateClassFromVoid(classDef *cd, const char *cname, - const char *vname, FILE *fp); -static void generateMappedTypeFromVoid(mappedTypeDef *mtd, const char *cname, - const char *vname, FILE *fp); -static int generateSubClassConvertors(sipSpec *pt, FILE *fp); -static void generateRegisterMetaType(classDef *cd, FILE *fp); - - -/* - * Generate the code from a specification. - */ -void generateCode(sipSpec *pt, char *codeDir, char *buildfile, char *docFile, - char *srcSuffix, int except, int trace, int releaseGIL, int parts, - stringList *xsl) -{ - exceptions = except; - tracing = trace; - release_gil = releaseGIL; - generating_c = pt->genc; - - if (srcSuffix == NULL) - srcSuffix = (generating_c ? ".c" : ".cpp"); - - /* Generate the documentation. */ - if (docFile != NULL) - generateDocumentation(pt,docFile); - - /* Generate the code. */ - if (codeDir != NULL) - { - generateCpp(pt,codeDir,srcSuffix,&parts); - generateInternalAPIHeader(pt,codeDir,xsl); - } - - /* Generate the build file. */ - if (buildfile != NULL) - generateBuildFile(pt,buildfile,srcSuffix,parts); -} - - -/* - * Generate the documentation. - */ -static void generateDocumentation(sipSpec *pt, char *docFile) -{ - FILE *fp; - codeBlock *cb; - - fp = createFile(pt, docFile, NULL); - - for (cb = pt->docs; cb != NULL; cb = cb->next) - fputs(cb->frag, fp); - - closeFile(fp); -} - - -/* - * Generate the build file. - */ -static void generateBuildFile(sipSpec *pt, char *buildFile, char *srcSuffix, - int parts) -{ - char *mname = pt->module->name; - ifaceFileDef *iff; - FILE *fp; - - fp = createFile(pt, buildFile, NULL); - - prcode(fp, "target = %s\nsources = ", mname); - - if (parts) - { - int p; - - for (p = 0; p < parts; ++p) - { - if (p > 0) - prcode(fp, " "); - - prcode(fp, "sip%spart%d%s", mname, p, srcSuffix); - } - } - else - { - prcode(fp, "sip%scmodule%s", mname, srcSuffix); - - for (iff = pt->ifacefiles; iff != NULL; iff = iff->next) - { - if (iff->module != pt->module) - continue; - - if (iff->type == exception_iface) - continue; - - prcode(fp, " sip%s%F%s", mname, iff->fqcname, srcSuffix); - } - } - - prcode(fp, "\nheaders = sipAPI%s.h", mname); - - for (iff = pt->ifacefiles; iff != NULL; iff = iff->next) - { - char *imname; - - imname = (iff->module == pt->module ? mname : iff->module->name); - - prcode(fp, " sip%s%F.h", imname, iff->fqcname); - } - - prcode(fp, "\n"); - - closeFile(fp); -} - - -/* - * Generate an expression in C++. - */ -void generateExpression(valueDef *vd, FILE *fp) -{ - while (vd != NULL) - { - if (vd->vunop != '\0') - prcode(fp,"%c",vd->vunop); - - switch (vd->vtype) - { - case qchar_value: - prcode(fp,"'%c'",vd->u.vqchar); - break; - - case string_value: - prcode(fp,"\"%s\"",vd->u.vstr); - break; - - case numeric_value: - prcode(fp,"%l",vd->u.vnum); - break; - - case real_value: - prcode(fp,"%g",vd->u.vreal); - break; - - case scoped_value: - if (prcode_xml) - prScopedName(fp, vd->u.vscp, "."); - else - prcode(fp, "%S", vd->u.vscp); - - break; - - case fcall_value: - generateSimpleFunctionCall(vd->u.fcd,fp); - break; - } - - if (vd->vbinop != '\0') - prcode(fp," %c ",vd->vbinop); - - vd = vd->next; - } -} - - -/* - * Generate the C++ internal module API header file. - */ -static void generateInternalAPIHeader(sipSpec *pt,char *codeDir,stringList *xsl) -{ - char *hfile, *mname = pt->module->name; - int noIntro; - FILE *fp; - nameDef *nd; - moduleDef *mod; - moduleListDef *mld; - - hfile = concat(codeDir,"/sipAPI",mname,".h",NULL); - fp = createFile(pt,hfile,"Internal module API header file."); - - /* Include files. */ - - prcode(fp, -"\n" -"#ifndef _%sAPI_H\n" -"#define _%sAPI_H\n" -"\n" -"\n" -"#include <sip.h>\n" - ,mname - ,mname); - - if (optRegisterTypes(pt)) - prcode(fp, -"\n" -"#include <QMetaType>\n" - ); - - /* Define the enabled features. */ - noIntro = TRUE; - - for (mod = pt->modules; mod != NULL; mod = mod->next) - { - qualDef *qd; - - for (qd = mod->qualifiers; qd != NULL; qd = qd->next) - if (qd->qtype == feature_qualifier && !excludedFeature(xsl,qd)) - { - if (noIntro) - { - prcode(fp, -"\n" -"\n" -"/* These are the features that are enabled. */\n" - ); - - noIntro = FALSE; - } - - prcode(fp, -"#define SIP_FEATURE_%s\n" - ,qd->name); - } - } - - generateCppCodeBlock(pt->exphdrcode,fp); - generateCppCodeBlock(pt->hdrcode,fp); - - /* Shortcuts that hide the messy detail of the APIs. */ - noIntro = TRUE; - - for (nd = pt->namecache; nd != NULL; nd = nd->next) - { - if (!isClassName(nd)) - continue; - - if (noIntro) - { - prcode(fp, -"\n" -"\n" -"/*\n" -" * Convenient names to refer to the names of classes defined in this module.\n" -" * These are part of the public API.\n" -" */\n" -"\n" - ); - - noIntro = FALSE; - } - - prcode(fp, -"#define sipName_%s %N\n" - ,nd->text,nd); - } - - prcode(fp, -"\n" -"\n" -"/* Convenient names to call the SIP API. */\n" -"#define sipConvertFromSliceObject(o,len,start,stop,step,slen) PySlice_GetIndicesEx((PySliceObject *)(o),(len),(start),(stop),(step),(slen))\n" -"#define sipIsSubClassInstance(o,wt) PyObject_TypeCheck((o),(PyTypeObject *)(wt))\n" -"\n" -"#define sipMapStringToClass sipAPI_%s->api_map_string_to_class\n" -"#define sipMapIntToClass sipAPI_%s->api_map_int_to_class\n" -"#define sipMalloc sipAPI_%s->api_malloc\n" -"#define sipFree sipAPI_%s->api_free\n" -"#define sipBuildResult sipAPI_%s->api_build_result\n" -"#define sipCallMethod sipAPI_%s->api_call_method\n" -"#define sipParseResult sipAPI_%s->api_parse_result\n" -"#define sipParseArgs sipAPI_%s->api_parse_args\n" -"#define sipParsePair sipAPI_%s->api_parse_pair\n" -"#define sipCommonCtor sipAPI_%s->api_common_ctor\n" -"#define sipCommonDtor sipAPI_%s->api_common_dtor\n" -"#define sipConvertFromSequenceIndex sipAPI_%s->api_convert_from_sequence_index\n" -"#define sipConvertFromVoidPtr sipAPI_%s->api_convert_from_void_ptr\n" -"#define sipConvertToCpp sipAPI_%s->api_convert_to_cpp\n" -"#define sipConvertToVoidPtr sipAPI_%s->api_convert_to_void_ptr\n" -"#define sipNoFunction sipAPI_%s->api_no_function\n" -"#define sipNoMethod sipAPI_%s->api_no_method\n" -"#define sipAbstractMethod sipAPI_%s->api_abstract_method\n" -"#define sipBadClass sipAPI_%s->api_bad_class\n" -"#define sipBadSetType sipAPI_%s->api_bad_set_type\n" -"#define sipBadCatcherResult sipAPI_%s->api_bad_catcher_result\n" -"#define sipBadOperatorArg sipAPI_%s->api_bad_operator_arg\n" -"#define sipTrace sipAPI_%s->api_trace\n" -"#define sipTransfer sipAPI_%s->api_transfer\n" -"#define sipTransferBack sipAPI_%s->api_transfer_back\n" -"#define sipTransferTo sipAPI_%s->api_transfer_to\n" -"#define sipWrapper_Check sipAPI_%s->api_wrapper_check\n" -"#define sipGetWrapper sipAPI_%s->api_get_wrapper\n" -"#define sipGetCppPtr sipAPI_%s->api_get_cpp_ptr\n" -"#define sipGetComplexCppPtr sipAPI_%s->api_get_complex_cpp_ptr\n" -"#define sipIsPyMethod sipAPI_%s->api_is_py_method\n" -"#define sipCallHook sipAPI_%s->api_call_hook\n" -"#define sipStartThread sipAPI_%s->api_start_thread\n" -"#define sipEndThread sipAPI_%s->api_end_thread\n" -"#define sipEmitSignal sipAPI_%s->api_emit_signal\n" -"#define sipConnectRx sipAPI_%s->api_connect_rx\n" -"#define sipDisconnectRx sipAPI_%s->api_disconnect_rx\n" -"#define sipGetSender sipAPI_%s->api_get_sender\n" -"#define sipRaiseUnknownException sipAPI_%s->api_raise_unknown_exception\n" -"#define sipRaiseClassException sipAPI_%s->api_raise_class_exception\n" -"#define sipRaiseSubClassException sipAPI_%s->api_raise_sub_class_exception\n" -"#define sipBadLengthForSlice sipAPI_%s->api_bad_length_for_slice\n" -"#define sipClassName sipAPI_%s->api_class_name\n" -"#define sipAddClassInstance sipAPI_%s->api_add_class_instance\n" -"#define sipAddMappedTypeInstance sipAPI_%s->api_add_mapped_type_instance\n" -"#define sipAddEnumInstance sipAPI_%s->api_add_enum_instance\n" -"#define sipConvertFromNamedEnum sipAPI_%s->api_convert_from_named_enum\n" -"#define sipGetAddress sipAPI_%s->api_get_address\n" -"#define sipFreeConnection sipAPI_%s->api_free_connection\n" -"#define sipEmitToSlot sipAPI_%s->api_emit_to_slot\n" -"#define sipSameConnection sipAPI_%s->api_same_connection\n" -"#define sipPySlotExtend sipAPI_%s->api_pyslot_extend\n" -"#define sipConvertRx sipAPI_%s->api_convert_rx\n" -"#define sipAddDelayedDtor sipAPI_%s->api_add_delayed_dtor\n" -"#define sipCanConvertToInstance sipAPI_%s->api_can_convert_to_instance\n" -"#define sipCanConvertToMappedType sipAPI_%s->api_can_convert_to_mapped_type\n" -"#define sipConvertToInstance sipAPI_%s->api_convert_to_instance\n" -"#define sipConvertToMappedType sipAPI_%s->api_convert_to_mapped_type\n" -"#define sipForceConvertToInstance sipAPI_%s->api_force_convert_to_instance\n" -"#define sipForceConvertToMappedType sipAPI_%s->api_force_convert_to_mapped_type\n" -"#define sipReleaseInstance sipAPI_%s->api_release_instance\n" -"#define sipReleaseMappedType sipAPI_%s->api_release_mapped_type\n" -"#define sipConvertFromInstance sipAPI_%s->api_convert_from_instance\n" -"#define sipConvertFromNewInstance sipAPI_%s->api_convert_from_new_instance\n" -"#define sipConvertFromMappedType sipAPI_%s->api_convert_from_mapped_type\n" -"#define sipGetState sipAPI_%s->api_get_state\n" -"#define sipFindMappedType sipAPI_%s->api_find_mapped_type\n" -"#define sipLong_AsUnsignedLong sipAPI_%s->api_long_as_unsigned_long\n" -"#define sipExportSymbol sipAPI_%s->api_export_symbol\n" -"#define sipImportSymbol sipAPI_%s->api_import_symbol\n" -"#define sipRegisterIntTypes sipAPI_%s->api_register_int_types\n" -"#define sipParseSignature sipAPI_%s->api_parse_signature\n" -"#define sipFindClass sipAPI_%s->api_find_class\n" -"#define sipFindNamedEnum sipAPI_%s->api_find_named_enum\n" -"#define sipString_AsChar sipAPI_%s->api_string_as_char\n" -"#define sipUnicode_AsWChar sipAPI_%s->api_unicode_as_wchar\n" -"#define sipUnicode_AsWString sipAPI_%s->api_unicode_as_wstring\n" - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname - ,mname); - - /* The name strings. */ - noIntro = TRUE; - - for (nd = pt->namecache; nd != NULL; nd = nd->next) - { - if (!isUsedName(nd)) - continue; - - if (noIntro) - { - prcode(fp, -"\n" -"\n" -"/* The strings used by this module. */\n" - ); - - noIntro = FALSE; - } - - prcode(fp, -"extern char %N[];\n" - ,nd); - } - - /* The unscoped enum macros. */ - generateEnumMacros(pt, NULL, fp); - - prcode(fp, -"\n" -"\n" -"/* The SIP API, this module's API and the APIs of any imported modules. */\n" -"extern const sipAPIDef *sipAPI_%s;\n" -"extern sipExportedModuleDef sipModuleAPI_%s;\n" - ,mname - ,mname,mname); - - for (mld = pt->module->allimports; mld != NULL; mld = mld->next) - prcode(fp, -"extern const sipExportedModuleDef *sipModuleAPI_%s_%s;\n" - ,mname,mld->module->name); - - if (optQ_OBJECT4(pt)) - prcode(fp, -"\n" -"typedef const TQMetaObject *(*sip_qt_metaobject_func)(sipWrapper *,sipWrapperType *,const TQMetaObject *);\n" -"extern sip_qt_metaobject_func sip_%s_qt_metaobject;\n" -"\n" -"typedef int (*sip_qt_metacall_func)(sipWrapper *,sipWrapperType *,TQMetaObject::Call,int,void **);\n" -"extern sip_qt_metacall_func sip_%s_qt_metacall;\n" - , mname - , mname); - - /* - * Note that we don't forward declare the virtual handlers. This is - * because we would need to #include everything needed for their - * argument types. - */ - - prcode(fp, -"\n" -"#endif\n" - ); - - closeFile(fp); - free(hfile); -} - - -/* - * Return the filename of a source code part on the heap. - */ -static char *makePartName(char *codeDir,char *mname,int part,char *srcSuffix) -{ - char buf[20]; - - sprintf(buf,"part%d",part); - - return concat(codeDir,"/sip",mname,buf,srcSuffix,NULL); -} - - -/* - * Generate the C/C++ code. - */ -static void generateCpp(sipSpec *pt, char *codeDir, char *srcSuffix, int *parts) -{ - char *cppfile, *mname = pt->module->name; - int noIntro, nrSccs = 0, files_in_part, max_per_part, this_part; - int is_inst_class, is_inst_voidp, is_inst_char, is_inst_string; - int is_inst_int, is_inst_long, is_inst_ulong, is_inst_longlong; - int is_inst_ulonglong, is_inst_double, is_inst_enum, nr_enummembers; - int hasexternal = FALSE, slot_extenders = FALSE, ctor_extenders = FALSE; - FILE *fp; - moduleListDef *mld; - classDef *cd; - memberDef *md; - ifaceFileDef *iff; - virtHandlerDef *vhd; - nameDef *nd; - exceptionDef *xd; - - /* Calculate the number of files in each part. */ - if (*parts) - { - int nr_files = 1; - - for (iff = pt->ifacefiles; iff != NULL; iff = iff->next) - if (iff->module == pt->module) - ++nr_files; - - max_per_part = (nr_files + *parts - 1) / *parts; - files_in_part = 1; - this_part = 0; - - cppfile = makePartName(codeDir,mname,0,srcSuffix); - } - else - cppfile = concat(codeDir,"/sip",mname,"cmodule",srcSuffix,NULL); - - fp = createCompilationUnit(pt, cppfile, "Module code."); - - prcode(fp, -"\n" -"#include \"sipAPI%s.h\"\n" -"\n" - ,mname); - - for (iff = pt->ifacefiles; iff != NULL; iff = iff->next) - if (iff->module == pt->module && iff->type != exception_iface) - prcode(fp, -"#include \"sip%s%F.h\"\n" - ,iff->module->name,iff->fqcname); - - generateUsedIncludes(pt->used, FALSE, fp); - - /* - * If there should be a Qt support API then generate stubs values for the - * optional parts. These should be undefined in %ModuleCode if a C++ - * implementation is provided. - */ - if (pt->qobjclass >= 0) - prcode(fp, -"\n" -"#define sipQtIsQtSignal 0\n" -"#define sipQtCreateUniversalSignalShortcut 0\n" -"#define sipQtCreateUniversalSignal 0\n" -"#define sipQtFindUniversalSignalShortcut 0\n" -"#define sipQtFindUniversalSignal 0\n" -"#define sipQtEmitSignalShortcut 0\n" -"#define sipQtEmitSignal 0\n" - ); - - /* Define the names. */ - noIntro = TRUE; - - for (nd = pt->namecache; nd != NULL; nd = nd->next) - { - if (!isUsedName(nd)) - continue; - - if (noIntro) - { - prcode(fp, -"\n" -"\n" -"/* Define the strings used by this module. */\n" - ); - - noIntro = FALSE; - } - - prcode(fp, -"char %N[] = \"%s\";\n" - ,nd,nd->text); - } - - /* Generate the C++ code blocks. */ - generateCppCodeBlock(pt->cppcode,fp); - - /* Generate any virtual handler declarations. */ - for (vhd = pt->module->virthandlers; vhd != NULL; vhd = vhd->next) - if (!isDuplicateVH(vhd)) - generateVirtualHandler(pt,vhd,fp); - - /* Generate the global functions. */ - for (md = pt->othfuncs; md != NULL; md = md->next) - { - if (md->module != pt->module) - continue; - - if (md->slot == no_slot) - generateOrdinaryFunction(pt,NULL,md,fp); - else - { - overDef *od; - - /* - * Make sure that there is still an overload and we - * haven't moved them all to classes. - */ - for (od = pt->overs; od != NULL; od = od->next) - if (od->common == md) - { - generateSlot(pt, NULL, NULL, md, fp); - slot_extenders = TRUE; - break; - } - } - } - - /* Generate any class specific ctor or slot extenders. */ - for (cd = pt->proxies; cd != NULL; cd = cd->next) - { - if (cd->ctors != NULL) - { - generateTypeInit(pt, cd, fp); - ctor_extenders = TRUE; - } - - for (md = cd->members; md != NULL; md = md->next) - { - generateSlot(pt, cd, NULL, md, fp); - slot_extenders = TRUE; - } - } - - /* Generate any ctor extender table. */ - if (ctor_extenders) - { - prcode(fp, -"\n" -"static sipInitExtenderDef initExtenders[] = {\n" - ); - - for (cd = pt->proxies; cd != NULL; cd = cd->next) - if (cd->ctors != NULL) - { - prcode(fp, -" {init_%C, ", classFQCName(cd)); - - generateEncodedClass(pt, cd, 0, fp); - - prcode(fp, ", NULL},\n" - ); - } - - prcode(fp, -" {NULL, {0, 0, 0}, NULL}\n" -"};\n" - ); - } - - /* Generate any slot extender table. */ - if (slot_extenders) - { - prcode(fp, -"\n" -"static sipPySlotExtenderDef slotExtenders[] = {\n" - ); - - for (md = pt->othfuncs; md != NULL; md = md->next) - { - overDef *od; - - if (md->module != pt->module) - continue; - - if (md->slot == no_slot) - continue; - - for (od = pt->overs; od != NULL; od = od->next) - if (od->common == md) - { - prcode(fp, -" {(void *)slot_%s, %s, {0, 0, 0}},\n" - , md->pyname->text, slotName(md->slot)); - - break; - } - } - - for (cd = pt->proxies; cd != NULL; cd = cd->next) - for (md = cd->members; md != NULL; md = md->next) - { - prcode(fp, -" {(void *)slot_%C_%s, %s, ", classFQCName(cd), md->pyname->text, slotName(md->slot)); - - generateEncodedClass(pt, cd, 0, fp); - - prcode(fp, "},\n" - ); - } - - prcode(fp, -" {NULL, (sipPySlotType)0, {0, 0, 0}}\n" -"};\n" - ); - } - - /* Generate the global access functions. */ - generateAccessFunctions(pt,NULL,fp); - - /* Generate the module data structures. */ - if (pt->module->nrclasses > 0) - { - nrSccs = generateSubClassConvertors(pt, fp); - - prcode(fp, -"\n" -"\n" -"/*\n" -" * This defines each class in this module. The values are replaced by the\n" -" * proper Python types during the export process.\n" -" */\n" -"static sipWrapperType *typesTable[] = {\n" - ); - - generateClassTableEntries(pt, &pt->module->root, fp); - - prcode(fp, -"};\n" - ); - - /* Generate the external classes table if needed. */ - for (cd = pt->classes; cd != NULL; cd = cd->next) - { - if (!isExternal(cd)) - continue; - - if (cd->iff->module != pt->module) - continue; - - if (!hasexternal) - { - prcode(fp, -"\n" -"\n" -"/* This defines each external type declared in this module, */\n" -"static sipExternalTypeDef externalTypesTable[] = {\n" - ); - - hasexternal = TRUE; - } - - prcode(fp, -" {%d, \"", cd->classnr); - prScopedName(fp, classFQCName(cd), "."); - prcode(fp,"\"},\n" - ); - } - - if (hasexternal) - prcode(fp, -" {-1, NULL}\n" -"};\n" - ); - } - - if (pt->module->nrmappedtypes > 0) - { - mappedTypeDef *mtd; - argDef type; - - type.argflags = 0; - type.name = NULL; - type.nrderefs = 0; - type.defval = NULL; - - prcode(fp, -"\n" -"\n" -"/* This defines each mapped type in this module. */\n" -"static sipMappedType *mappedTypesTable[] = {\n" - ); - - for (mtd = pt->mappedtypes; mtd != NULL; mtd = mtd->next) - { - if (mtd->iff->module != pt->module) - continue; - - type.atype = mapped_type; - type.u.mtd = mtd; - - prcode(fp, -" &sipMappedTypeDef_%T,\n" - ,&type); - } - - prcode(fp, -" 0\n" -"};\n" - ); - } - - if (pt->module->nrenums > 0) - { - enumDef *ed; - - prcode(fp, -"\n" -"\n" -"/* Define each named enum in this module. */\n" - ); - - /* Generate any slot tables. */ - for (ed = pt->enums; ed != NULL; ed = ed->next) - { - memberDef *slot; - - if (ed->module != pt->module || ed->fqcname == NULL) - continue; - - if (ed->slots == NULL) - continue; - - for (slot = ed->slots; slot != NULL; slot = slot->next) - generateSlot(pt, NULL, ed, slot, fp); - - prcode(fp, -"\n" -"static sipPySlotDef slots_%C[] = {\n" - , ed->fqcname); - - for (slot = ed->slots; slot != NULL; slot = slot->next) - { - const char *stype; - - if ((stype = slotName(slot->slot)) != NULL) - prcode(fp, -" {(void *)slot_%C_%s, %s},\n" - , ed->fqcname, slot->pyname->text, stype); - } - - prcode(fp, -" {0, (sipPySlotType)0}\n" -"};\n" -"\n" - ); - } - - prcode(fp, -"static sipEnumDef enumTypesTable[] = {\n" - ); - - for (ed = pt->enums; ed != NULL; ed = ed->next) - { - char *emname; - - if (ed->module != pt->module || ed->fqcname == NULL) - continue; - - if (ed->ecd == NULL) - emname = mname; - else if (ed->ecd->real == NULL) - emname = ed->module->name; - else - emname = ed->ecd->real->iff->module->name; - - prcode(fp, -" {\"%s.%P\", ", emname, ed->ecd, ed->pyname->text); - - if (isRenamedEnum(ed) || (ed->ecd != NULL && isRenamedClass(ed->ecd))) - prcode(fp, "\"%S\", ", ed->fqcname); - else - prcode(fp, "NULL, "); - - if (ed->ecd == NULL) - prcode(fp, "-1"); - else - prcode(fp, "%d", ed->ecd->classnr); - - if (ed->slots != NULL) - prcode(fp, ", slots_%C", ed->fqcname); - else - prcode(fp, ", NULL"); - - prcode(fp, "},\n" - ); - } - - prcode(fp, -"};\n" - ); - - nr_enummembers = generateEnumMemberTable(pt,NULL,fp); - } - else - nr_enummembers = 0; - - if (pt->module->nrtypedefs > 0) - { - typedefDef *td; - - prcode(fp, -"\n" -"\n" -"/*\n" -" * These define each typedef in this module. They are only needed in case\n" -" * they are used as arguments to Qt signals.\n" -" */\n" -"\n" -"static sipTypedefDef typedefsTable[] = {\n" - ); - - for (td = pt->typedefs; td != NULL; td = td->next) - { - char *tdmname, *sat; - scopedNameDef *fqname; - - if (td->module != pt->module) - continue; - - fqname = NULL; - tdmname = NULL; - sat = "unknown"; - - switch (td->type.atype) - { - case string_type: - sat = (td->type.nrderefs == 0 ? "char" : "string"); - break; - - case sstring_type: - sat = (td->type.nrderefs == 0 ? "schar" : "sstring"); - break; - - case ustring_type: - sat = (td->type.nrderefs == 0 ? "uchar" : "ustring"); - break; - - case wstring_type: - sat = (td->type.nrderefs == 0 ? "wchar" : "wstring"); - break; - - case short_type: - sat = "short"; - break; - - case ushort_type: - sat = "ushort"; - break; - - case cint_type: - case int_type: - sat = "int"; - break; - - case uint_type: - sat = "uint"; - break; - - case long_type: - sat = "long"; - break; - - case ulong_type: - sat = "ulong"; - break; - - case longlong_type: - sat = "longlong"; - break; - - case ulonglong_type: - sat = "ulonglong"; - break; - - case cfloat_type: - case float_type: - sat = "float"; - break; - - case cdouble_type: - case double_type: - sat = "double"; - break; - - case bool_type: - case cbool_type: - sat = "bool"; - break; - - case void_type: - if (td->type.nrderefs != 0) - sat = "void"; - break; - - case enum_type: - if ((fqname = td->type.u.ed->fqcname) != NULL) - { - sat = "enum"; - - if (td->type.u.ed->module != pt->module) - tdmname = td->type.u.ed->module->fullname; - } - break; - - case class_type: - sat = "class"; - fqname = classFQCName(td->type.u.cd); - - if (td->type.u.cd->iff->module != pt->module) - tdmname = td->type.u.cd->iff->module->fullname; - break; - - case mapped_type: - sat = "mtype"; - fqname = td->type.u.mtd->iff->fqcname; - - if (td->type.u.mtd->iff->module != pt->module) - tdmname = td->type.u.mtd->iff->module->fullname; - break; - } - - prcode(fp, -" {\"%S\", %s_sat", td->fqname, sat); - - if (fqname != NULL) - prcode(fp, ", \"%S\"", fqname); - else - prcode(fp, ", NULL"); - - if (tdmname != NULL) - prcode(fp, ", \"%s\"", tdmname); - else - prcode(fp, ", NULL"); - - prcode(fp, "},\n" - ); - } - - prcode(fp, -" {NULL, unknown_sat, NULL, NULL}\n" -"};\n" - ); - } - - if (pt->module->nrvirthandlers > 0) - { - prcode(fp, -"\n" -"\n" -"/*\n" -" * This defines the virtual handlers that this module implements and can be\n" -" * used by other modules.\n" -" */\n" -"static sipVirtHandlerFunc virtHandlersTable[] = {\n" - ); - - for (vhd = pt->module->virthandlers; vhd != NULL; vhd = vhd->next) - if (!isDuplicateVH(vhd)) - prcode(fp, -" (sipVirtHandlerFunc)sipVH_%s_%d,\n" - ,mname,vhd->virthandlernr); - - prcode(fp, -"};\n" - ); - } - - if (pt->module->allimports != NULL) - { - prcode(fp, -"\n" -"\n" -"/* This defines the modules that this module needs to import. */\n" -"static sipImportedModuleDef importsTable[] = {\n" - ); - - for (mld = pt->module->allimports; mld != NULL; mld = mld->next) - prcode(fp, -" {\"%s\", %d, NULL},\n" - , mld->module->fullname, mld->module->version); - - prcode(fp, -" {NULL, -1, NULL}\n" -"};\n" - ); - } - - if (nrSccs > 0) - { - prcode(fp, -"\n" -"\n" -"/* This defines the class sub-convertors that this module defines. */\n" -"static sipSubClassConvertorDef convertorsTable[] = {\n" - ); - - for (cd = pt->classes; cd != NULL; cd = cd->next) - { - if (cd->iff->module != pt->module) - continue; - - if (cd->convtosubcode == NULL) - continue; - - prcode(fp, -" {sipSubClass_%C, ",classFQCName(cd)); - - generateEncodedClass(pt,cd->subbase,0,fp); - - prcode(fp,", NULL},\n"); - } - - prcode(fp, -" {NULL, {0, 0, 0}, NULL}\n" -"};\n" - ); - } - - /* Generate any license information. */ - if (pt->module->license != NULL) - { - licenseDef *ld = pt->module->license; - - prcode(fp, -"\n" -"\n" -"/* Define the module's license. */\n" -"static sipLicenseDef module_license = {\n" - ); - - prcode(fp, -" \"%s\",\n" - ,ld->type); - - if (ld->licensee != NULL) - prcode(fp, -" \"%s\",\n" - ,ld->licensee); - else - prcode(fp, -" NULL,\n" - ); - - if (ld->timestamp != NULL) - prcode(fp, -" \"%s\",\n" - ,ld->timestamp); - else - prcode(fp, -" NULL,\n" - ); - - if (ld->sig != NULL) - prcode(fp, -" \"%s\"\n" - ,ld->sig); - else - prcode(fp, -" NULL\n" - ); - - prcode(fp, -"};\n" - ); - } - - /* Generate each instance table. */ - is_inst_class = generateClasses(pt,NULL,fp); - is_inst_voidp = generateVoidPointers(pt,NULL,fp); - is_inst_char = generateChars(pt,NULL,fp); - is_inst_string = generateStrings(pt,NULL,fp); - is_inst_int = generateInts(pt,NULL,fp); - is_inst_long = generateLongs(pt,NULL,fp); - is_inst_ulong = generateUnsignedLongs(pt,NULL,fp); - is_inst_longlong = generateLongLongs(pt,NULL,fp); - is_inst_ulonglong = generateUnsignedLongLongs(pt,NULL,fp); - is_inst_double = generateDoubles(pt,NULL,fp); - is_inst_enum = generateEnums(pt,NULL,fp); - - /* Generate any exceptions table. */ - if (pt->module->nrexceptions > 0) - prcode(fp, -"\n" -"\n" -"static PyObject *exceptionsTable[%d];\n" - ,pt->module->nrexceptions); - - /* Generate any Qt support API. */ - if (pt->qobjclass >= 0) - prcode(fp, -"\n" -"\n" -"/* This defines the Qt support API. */\n" -"\n" -"static sipQtAPI qtAPI = {\n" -" &typesTable[%d],\n" -" sipQtIsQtSignal,\n" -" sipQtCreateUniversalSignalShortcut,\n" -" sipQtCreateUniversalSignal,\n" -" sipQtFindUniversalSignalShortcut,\n" -" sipQtFindUniversalSignal,\n" -" sipQtEmitSignalShortcut,\n" -" sipQtEmitSignal,\n" -" sipQtCreateUniversalSlot,\n" -" sipQtDestroyUniversalSlot,\n" -" sipQtFindSlot,\n" -" sipQtConnect,\n" -" sipQtDisconnect,\n" -" sipQtSignalsBlocked,\n" -" sipQtGetSender,\n" -" sipQtForgetSender,\n" -" sipQtSameSignalSlotName,\n" -" sipQtFindConnection\n" -"};\n" - ,pt->qobjclass); - - prcode(fp, -"\n" -"\n" -"/* This defines this module. */\n" -"sipExportedModuleDef sipModuleAPI_%s = {\n" -" NULL,\n" -" SIP_API_MINOR_NR,\n" -" \"%s\",\n" -" NULL,\n" -" %d,\n" -" %s,\n" -" %s,\n" -" %d,\n" -" %s,\n" -" %s,\n" -" %s,\n" -" %d,\n" -" NULL,\n" -" %s,\n" -" %d,\n" -" %s,\n" -" %s,\n" -" %s,\n" -" %s,\n" -" {%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s},\n" -" %s,\n" -" %s,\n" -" %s,\n" -" %s,\n" -" %s,\n" -" NULL\n" -"};\n" - , mname - , pt->module->fullname - , pt->module->version - , pt->module->allimports != NULL ? "importsTable" : "NULL" - , pt->qobjclass >= 0 ? "&qtAPI" : "NULL" - , pt->module->nrclasses - , pt->module->nrclasses > 0 ? "typesTable" : "NULL" - , hasexternal ? "externalTypesTable" : "NULL" - , pt->module->nrmappedtypes > 0 ? "mappedTypesTable" : "NULL" - , pt->module->nrenums - , pt->module->nrenums > 0 ? "enumTypesTable" : "NULL" - , nr_enummembers - , nr_enummembers > 0 ? "enummembers" : "NULL" - , pt->module->nrtypedefs > 0 ? "typedefsTable" : "NULL" - , pt->module->nrvirthandlers > 0 ? "virtHandlersTable" : "NULL" - , nrSccs > 0 ? "convertorsTable" : "NULL" - , is_inst_class ? "classInstances" : "NULL" - , is_inst_voidp ? "voidPtrInstances" : "NULL" - , is_inst_char ? "charInstances" : "NULL" - , is_inst_string ? "stringInstances" : "NULL" - , is_inst_int ? "intInstances" : "NULL" - , is_inst_long ? "longInstances" : "NULL" - , is_inst_ulong ? "unsignedLongInstances" : "NULL" - , is_inst_longlong ? "longLongInstances" : "NULL" - , is_inst_ulonglong ? "unsignedLongLongInstances" : "NULL" - , is_inst_double ? "doubleInstances" : "NULL" - , is_inst_enum ? "enumInstances" : "NULL" - , pt->module->license != NULL ? "&module_license" : "NULL" - , pt->module->nrexceptions > 0 ? "exceptionsTable" : "NULL" - , slot_extenders ? "slotExtenders" : "NULL" - , ctor_extenders ? "initExtenders" : "NULL" - , hasDelayedDtors(pt->module) ? "sipDelayedDtors" : "NULL"); - - /* Generate the storage for the external API pointers. */ - prcode(fp, -"\n" -"\n" -"/* The SIP API and the APIs of any imported modules. */\n" -"const sipAPIDef *sipAPI_%s;\n" - ,mname); - - for (mld = pt->module->allimports; mld != NULL; mld = mld->next) - prcode(fp, -"const sipExportedModuleDef *sipModuleAPI_%s_%s;\n" - ,mname,mld->module->name); - - if (optQ_OBJECT4(pt)) - prcode(fp, -"\n" -"sip_qt_metaobject_func sip_%s_qt_metaobject;\n" -"sip_qt_metacall_func sip_%s_qt_metacall;\n" - , mname - , mname); - - /* Generate the Python module initialisation function. */ - prcode(fp, -"\n" -"\n" -"/* The Python module initialisation function. */\n" -"#if defined(SIP_STATIC_MODULE)\n" -"%svoid init%s()\n" -"#else\n" -"PyMODINIT_FUNC init%s()\n" -"#endif\n" -"{\n" -" static PyMethodDef sip_methods[] = {\n" - ,(generating_c ? "" : "extern \"C\" "), mname - ,mname); - - /* Generate the global functions. */ - - for (md = pt->othfuncs; md != NULL; md = md->next) - if (md->module == pt->module && md->slot == no_slot) - prcode(fp, -" {%N, func_%s, METH_VARARGS, NULL},\n" - ,md->pyname,md->pyname->text); - - prcode(fp, -" {0, 0, 0, 0}\n" -" };\n" -"\n" -" PyObject *sipModule, *sipModuleDict, *sip_sipmod, *sip_capiobj;\n" -"\n" - ); - - /* Generate the pre-initialisation code. */ - generateCppCodeBlock(pt->preinitcode,fp); - - prcode(fp, -" /* Initialise the module and get it's dictionary. */\n" -" sipModule = Py_InitModule((char *)sipModuleAPI_%s.em_name,sip_methods);\n" -" sipModuleDict = PyModule_GetDict(sipModule);\n" -"\n" -" /* Import the SIP module and get it's API. */\n" -" sip_sipmod = PyImport_ImportModule((char *)\"sip\");\n" -"\n" -" if (sip_sipmod == NULL)\n" -" return;\n" -"\n" -" sip_capiobj = PyDict_GetItemString(PyModule_GetDict(sip_sipmod),\"_C_API\");\n" -"\n" -" if (sip_capiobj == NULL || !PyCObject_Check(sip_capiobj))\n" -" return;\n" -"\n" - ,mname); - - if (generating_c) - prcode(fp, -" sipAPI_%s = (const sipAPIDef *)PyCObject_AsVoidPtr(sip_capiobj);\n" - ,mname); - else - prcode(fp, -" sipAPI_%s = reinterpret_cast<const sipAPIDef *>(PyCObject_AsVoidPtr(sip_capiobj));\n" - ,mname); - - prcode(fp, -"\n" -" /* Export the module and publish it's API. */\n" -" if (sipAPI_%s->api_export_module(&sipModuleAPI_%s,SIP_API_MAJOR_NR,SIP_API_MINOR_NR,sipModuleDict) < 0)\n" -" return;\n" - ,mname - ,mname); - - noIntro = TRUE; - - for (mld = pt->module->allimports; mld != NULL; mld = mld->next) - { - if (noIntro) - { - prcode(fp, -"\n" -" /* Get the APIs of the modules that this one is dependent on. */\n" - ); - - noIntro = FALSE; - } - - prcode(fp, -" sipModuleAPI_%s_%s = sipModuleAPI_%s.em_imports[%d].im_module;\n" - ,mname,mld->module->name,mname,mld->module->modulenr); - } - - generateClassesInline(pt,fp); - generateEnumsInline(pt, fp); - - /* Create any exceptions. */ - for (xd = pt->exceptions; xd != NULL; xd = xd->next) - { - if (xd->iff->module != pt->module) - continue; - - if (xd->iff->type != exception_iface) - continue; - - if (xd->exceptionnr < 0) - continue; - - prcode(fp, -"\n" -" if ((exceptionsTable[%d] = PyErr_NewException((char *)\"%s.%s\",", xd->exceptionnr, xd->iff->module->name, xd->pyname); - - if (xd->bibase != NULL) - prcode(fp, "PyExc_%s", xd->bibase); - else if (xd->base->iff->module == pt->module) - prcode(fp, "exceptionsTable[%d]", xd->base->exceptionnr); - else - prcode(fp, "sipException_%C", xd->base->iff->fqcname); - - prcode(fp, ",NULL)) == NULL || PyDict_SetItemString(sipModuleDict,\"%s\",exceptionsTable[%d]) < 0)\n" -" return;\n" - , xd->pyname, xd->exceptionnr); - } - - /* Generate any Qt metatype registration calls. */ - if (optRegisterTypes(pt)) - for (cd = pt->classes; cd != NULL; cd = cd->next) - { - if (cd->iff->module != pt->module) - continue; - - generateRegisterMetaType(cd, fp); - } - - /* Generate the post-initialisation code. */ - generateCppCodeBlock(pt->postinitcode,fp); - - /* - * This has to be done after the post-initialisation code in case this - * module is exporting the symbol. - */ - if (optQ_OBJECT4(pt)) - prcode(fp, -"\n" -" sip_%s_qt_metaobject = (sip_qt_metaobject_func)sipImportSymbol(\"qtcore_qt_metaobject\");\n" -" sip_%s_qt_metacall = (sip_qt_metacall_func)sipImportSymbol(\"qtcore_qt_metacall\");\n" - , mname - , mname); - - prcode(fp, -"}\n" - ); - - /* Generate the interface source and header files. */ - for (iff = pt->ifacefiles; iff != NULL; iff = iff->next) - { - if (iff->module == pt->module && iff->type != exception_iface) - { - if (*parts && files_in_part++ == max_per_part) - { - /* Close the old part. */ - closeFile(fp); - free(cppfile); - - /* Create a new one. */ - files_in_part = 1; - ++this_part; - - cppfile = makePartName(codeDir,mname,this_part,srcSuffix); - fp = createCompilationUnit(pt, cppfile, "Module code."); - } - - generateIfaceCpp(pt,iff,codeDir,srcSuffix,(*parts ? fp : NULL)); - } - - generateIfaceHeader(pt,iff,codeDir); - } - - closeFile(fp); - free(cppfile); - - /* How many parts we actually generated. */ - if (*parts) - *parts = this_part + 1; -} - - -/* - * Generate all the sub-class convertors for a module. - */ -static int generateSubClassConvertors(sipSpec *pt, FILE *fp) -{ - int nrSccs = 0; - classDef *cd; - - for (cd = pt->classes; cd != NULL; cd = cd->next) - { - if (cd->iff->module != pt->module) - continue; - - if (cd->convtosubcode == NULL) - continue; - - prcode(fp, -"\n" -"\n" -"/* Convert to a sub-class if possible. */\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static sipWrapperType *sipSubClass_%C(void **);}\n" - , classFQCName(cd)); - - prcode(fp, -"static sipWrapperType *sipSubClass_%C(void **sipCppRet)\n" -"{\n" -" %S *sipCpp = reinterpret_cast<%S *>(*sipCppRet);\n" -" sipWrapperType *sipClass;\n" -"\n" - , classFQCName(cd) - , classFQCName(cd->subbase), classFQCName(cd->subbase)); - - generateCppCodeBlock(cd->convtosubcode, fp); - - prcode(fp, -"\n" -" return sipClass;\n" -"}\n" - ); - - ++nrSccs; - } - - return nrSccs; -} - - -/* - * Generate an entry for a class in the classes table and all its children. - */ -static void generateClassTableEntries(sipSpec *pt, nodeDef *nd, FILE *fp) -{ - nodeDef *cnd; - - /* Generate the entry if it's not the root. */ - if (nd->cd != NULL) - if (isExternal(nd->cd)) - prcode(fp, -" 0,\n" - ); - else - prcode(fp, -" (sipWrapperType *)(void *)&sipType_%s_%C,\n" - , pt->module->name, classFQCName(nd->cd)); - - /* Generate all it's children. */ - for (cnd = nd->child; cnd != NULL; cnd = cnd->next) - generateClassTableEntries(pt, cnd, fp); -} - - -/* - * Generate the structure representing an encoded class. - */ -static void generateEncodedClass(sipSpec *pt,classDef *cd,int last,FILE *fp) -{ - moduleDef *mod = cd->iff->module; - - prcode(fp,"{%u, ",cd->classnr); - - if (mod == pt->module) - prcode(fp,"255"); - else - prcode(fp,"%u",mod->modulenr); - - prcode(fp,", %u}",last); -} - - -/* - * Generate an ordinary function (ie. not a class method). - */ -static void generateOrdinaryFunction(sipSpec *pt,classDef *cd,memberDef *md, - FILE *fp) -{ - overDef *od; - - prcode(fp, -"\n" -"\n" - ); - - if (cd != NULL) - { - if (!generating_c) - prcode(fp, -"extern \"C\" {static PyObject *meth_%C_%s(PyObject *,PyObject *);}\n" - , classFQCName(cd), md->pyname->text); - - prcode(fp, -"static PyObject *meth_%C_%s(PyObject *,PyObject *sipArgs)\n" - ,classFQCName(cd),md->pyname->text); - - od = cd->overs; - } - else - { - if (!generating_c) - prcode(fp, -"extern \"C\" {static PyObject *func_%s(PyObject *,PyObject *);}\n" - , md->pyname->text); - - prcode(fp, -"static PyObject *func_%s(PyObject *%s,PyObject *sipArgs)\n" - ,md->pyname->text,(generating_c ? "sipSelf" : "")); - - od = pt->overs; - } - - prcode(fp, -"{\n" -" int sipArgsParsed = 0;\n" - ); - - while (od != NULL) - { - if (od->common == md) - generateFunctionBody(pt,od,cd,cd,TRUE,fp); - - od = od->next; - } - - prcode(fp, -"\n" -" /* Raise an exception if the arguments couldn't be parsed. */\n" -" sipNoFunction(sipArgsParsed,%N);\n" -"\n" -" return NULL;\n" -"}\n" - ,md->pyname); -} - - -/* - * Generate the table of enum members for a scope. Return the number of them. - */ -static int generateEnumMemberTable(sipSpec *pt,classDef *cd,FILE *fp) -{ - int i, nr_members; - enumDef *ed; - enumMemberDef **etab, **et; - - /* First we count how many. */ - - nr_members = 0; - - for (ed = pt->enums; ed != NULL; ed = ed->next) - { - enumMemberDef *emd; - - if (ed->ecd != cd || ed->module != pt->module) - continue; - - if (cd == NULL && ed->fqcname == NULL) - continue; - - for (emd = ed->members; emd != NULL; emd = emd->next) - ++nr_members; - } - - if (nr_members == 0) - return 0; - - /* Create a table so they can be sorted. */ - - etab = sipMalloc(sizeof (enumMemberDef *) * nr_members); - - et = etab; - - for (ed = pt->enums; ed != NULL; ed = ed->next) - { - enumMemberDef *emd; - - if (ed->ecd != cd || ed->module != pt->module) - continue; - - if (cd == NULL && ed->fqcname == NULL) - continue; - - for (emd = ed->members; emd != NULL; emd = emd->next) - *et++ = emd; - } - - qsort(etab,nr_members,sizeof (enumMemberDef *),compareEnumMembers); - - /* Now generate the table. */ - - if (cd != NULL) - prcode(fp, -"\n" -"static sipEnumMemberDef enummembers_%C[] = {\n" - ,classFQCName(cd)); - else - prcode(fp, -"\n" -"/* These are the enum members of all global enums. */\n" -"static sipEnumMemberDef enummembers[] = {\n" - ); - - for (i = 0; i < nr_members; ++i) - { - enumMemberDef *emd; - - emd = etab[i]; - - prcode(fp, -" {%N, ",emd->pyname); - - if (cd != NULL) - { - if (isProtectedEnum(emd->ed)) - prcode(fp,"sip"); - - prcode(fp,"%S::%s",classFQCName(cd),emd->cname); - } - else - prcode(fp,"%s" - ,emd->cname); - - prcode(fp, ", %d},\n", emd->ed->enumnr); - } - - prcode(fp, -"};\n" - ); - - return nr_members; -} - - -/* - * The qsort helper to compare two enumMemberDef structures based on the name - * of the enum member. - */ - -static int compareEnumMembers(const void *m1,const void *m2) -{ - return strcmp((*(enumMemberDef **)m1)->pyname->text, - (*(enumMemberDef **)m2)->pyname->text); -} - - -/* - * Generate the access functions for the variables. - */ -static void generateAccessFunctions(sipSpec *pt,classDef *cd,FILE *fp) -{ - varDef *vd; - - for (vd = pt->vars; vd != NULL; vd = vd->next) - { - if (vd->accessfunc == NULL) - continue; - - if (vd->ecd != cd || vd->module != pt->module) - continue; - - prcode(fp, -"\n" -"\n" -"/* Access function. */\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static void *access_%C();}\n" - , vd->fqcname); - - prcode(fp, -"static void *access_%C()\n" -"{\n" - ,vd->fqcname); - - generateCppCodeBlock(vd->accessfunc,fp); - - prcode(fp, -"}\n" - ); - } -} - - -/* - * Generate the inline code to add a set of enum instances to a dictionary. - */ -static void generateEnumsInline(sipSpec *pt, FILE *fp) -{ - int noIntro; - varDef *vd; - - noIntro = TRUE; - - for (vd = pt->vars; vd != NULL; vd = vd->next) - { - if (vd->module != pt->module) - continue; - - if (vd->type.atype != enum_type) - continue; - - if (needsHandler(vd)) - continue; - - /* Skip enums that don't need inline code. */ - if (generating_c || vd->accessfunc != NULL || vd->type.nrderefs != 0) - continue; - - if (noIntro) - { - prcode(fp, -"\n" -" /* Define the enum instances that have to be added inline. */\n" - ); - - noIntro = FALSE; - } - - prcode(fp, -" sipAddEnumInstance("); - - if (vd->ecd == NULL) - prcode(fp,"sipModuleDict"); - else - prcode(fp,"(PyObject *)sipClass_%C",classFQCName(vd->ecd)); - - prcode(fp,",%N,(int)%S,sipEnum_%C);\n" - , vd->pyname, vd->fqcname, vd->type.u.ed->fqcname); - } -} - - -/* - * Generate the inline code to add a set of class instances to a dictionary. - */ -static void generateClassesInline(sipSpec *pt,FILE *fp) -{ - int noIntro; - varDef *vd; - - noIntro = TRUE; - - for (vd = pt->vars; vd != NULL; vd = vd->next) - { - if (vd->module != pt->module) - continue; - - if (vd->type.atype != class_type && vd->type.atype != mapped_type) - continue; - - if (needsHandler(vd)) - continue; - - /* Skip classes that don't need inline code. */ - if (generating_c || vd->accessfunc != NULL || vd->type.nrderefs != 0) - continue; - - if (noIntro) - { - prcode(fp, -"\n" -" /*\n" -" * Define the class and mapped type instances that have to be added\n" -" * inline.\n" -" */\n" - ); - - noIntro = FALSE; - } - - if (vd->type.atype == class_type) - prcode(fp, -" sipAddClassInstance("); - else - prcode(fp, -" sipAddMappedTypeInstance("); - - if (vd->ecd == NULL) - prcode(fp,"sipModuleDict"); - else - prcode(fp,"(PyObject *)sipClass_%C",classFQCName(vd->ecd)); - - prcode(fp,",%N,",vd->pyname); - - if (isConstArg(&vd->type)) - prcode(fp,"const_cast<%b *>(&%S)",&vd->type,vd->fqcname); - else - prcode(fp,"&%S",vd->fqcname); - - if (vd->type.atype == class_type) - prcode(fp, ",sipClass_%C);\n" - , classFQCName(vd->type.u.cd)); - else - prcode(fp, ",sipMappedType_%T);\n" - , &vd->type); - } -} - - -/* - * Generate the code to add a set of class instances to a dictionary. Return - * TRUE if there was at least one. - */ -static int generateClasses(sipSpec *pt,classDef *cd,FILE *fp) -{ - int noIntro; - varDef *vd; - - noIntro = TRUE; - - for (vd = pt->vars; vd != NULL; vd = vd->next) - { - scopedNameDef *vcname; - - if (vd->ecd != cd || vd->module != pt->module) - continue; - - if (vd->type.atype != class_type) - continue; - - if (needsHandler(vd)) - continue; - - /* - * Skip ordinary C++ class instances which need to be done with - * inline code rather than through a static table. This is - * because C++ does not guarantee the order in which the table - * and the instance will be created. So far this has only been - * seen to be a problem when statically linking SIP generated - * modules on Windows. - */ - if (!generating_c && vd->accessfunc == NULL && vd->type.nrderefs == 0) - continue; - - if (noIntro) - { - if (cd != NULL) - prcode(fp, -"\n" -"\n" -"/* Define the class instances to be added to this type dictionary. */\n" -"static sipClassInstanceDef classInstances_%C[] = {\n" - ,classFQCName(cd)); - else - prcode(fp, -"\n" -"\n" -"/* Define the class instances to be added to this module dictionary. */\n" -"static sipClassInstanceDef classInstances[] = {\n" - ); - - noIntro = FALSE; - } - - vcname = classFQCName(vd->type.u.cd); - - if (vd->accessfunc != NULL) - { - prcode(fp, -" {%N, (void *)access_%C, &sipClass_%C, SIP_ACCFUNC},\n" - ,vd->pyname,vd->fqcname,vcname); - } - else if (vd->type.nrderefs != 0) - { - prcode(fp, -" {%N, &%S, &sipClass_%C, SIP_INDIRECT},\n" - ,vd->pyname,vd->fqcname,vcname); - } - else if (isConstArg(&vd->type)) - { - prcode(fp, -" {%N, const_cast<%b *>(&%S), &sipClass_%C, 0},\n" - ,vd->pyname,&vd->type,vd->fqcname,vcname); - } - else - { - prcode(fp, -" {%N, &%S, &sipClass_%C, 0},\n" - ,vd->pyname,vd->fqcname,vcname); - } - } - - if (!noIntro) - prcode(fp, -" {0, 0, 0, 0}\n" -"};\n" - ); - - return !noIntro; -} - - -/* - * Generate the code to add a set of void pointers to a dictionary. Return - * TRUE if there was at least one. - */ -static int generateVoidPointers(sipSpec *pt,classDef *cd,FILE *fp) -{ - int noIntro; - varDef *vd; - - noIntro = TRUE; - - for (vd = pt->vars; vd != NULL; vd = vd->next) - { - if (vd->ecd != cd || vd->module != pt->module) - continue; - - if (vd->type.atype != void_type && vd->type.atype != struct_type) - continue; - - if (needsHandler(vd)) - continue; - - if (noIntro) - { - if (cd != NULL) - prcode(fp, -"\n" -"\n" -"/* Define the void pointers to be added to this type dictionary. */\n" -"static sipVoidPtrInstanceDef voidPtrInstances_%C[] = {\n" - ,classFQCName(cd)); - else - prcode(fp, -"\n" -"\n" -"/* Define the void pointers to be added to this module dictionary. */\n" -"static sipVoidPtrInstanceDef voidPtrInstances[] = {\n" - ); - - noIntro = FALSE; - } - - if (isConstArg(&vd->type)) - prcode(fp, -" {%N, const_cast<%b *>(%S)},\n" - , vd->pyname, &vd->type, vd->fqcname); - else - prcode(fp, -" {%N, %S},\n" - , vd->pyname, vd->fqcname); - } - - if (!noIntro) - prcode(fp, -" {0, 0}\n" -"};\n" - ); - - return !noIntro; -} - - -/* - * Generate the code to add a set of characters to a dictionary. Return TRUE - * if there was at least one. - */ -static int generateChars(sipSpec *pt,classDef *cd,FILE *fp) -{ - int noIntro; - varDef *vd; - - noIntro = TRUE; - - for (vd = pt->vars; vd != NULL; vd = vd->next) - { - argType vtype = vd->type.atype; - - if (vd->ecd != cd || vd->module != pt->module) - continue; - - if (!((vtype == sstring_type || vtype == ustring_type || vtype == string_type || vtype == wstring_type) && vd->type.nrderefs == 0)) - continue; - - if (needsHandler(vd)) - continue; - - if (noIntro) - { - if (cd != NULL) - prcode(fp, -"\n" -"\n" -"/* Define the chars to be added to this type dictionary. */\n" -"static sipCharInstanceDef charInstances_%C[] = {\n" - ,classFQCName(cd)); - else - prcode(fp, -"\n" -"\n" -"/* Define the chars to be added to this module dictionary. */\n" -"static sipCharInstanceDef charInstances[] = {\n" - ); - - noIntro = FALSE; - } - - prcode(fp, -" {%N, %S},\n" - ,vd->pyname,vd->fqcname); - } - - if (!noIntro) - prcode(fp, -" {0, 0}\n" -"};\n" - ); - - return !noIntro; -} - - -/* - * Generate the code to add a set of strings to a dictionary. Return TRUE if - * there is at least one. - */ -static int generateStrings(sipSpec *pt,classDef *cd,FILE *fp) -{ - int noIntro; - varDef *vd; - - noIntro = TRUE; - - for (vd = pt->vars; vd != NULL; vd = vd->next) - { - argType vtype = vd->type.atype; - - if (vd->ecd != cd || vd->module != pt->module) - continue; - - if (!((vtype == sstring_type || vtype == ustring_type || vtype == string_type || vtype == wstring_type) && vd->type.nrderefs != 0)) - continue; - - if (needsHandler(vd)) - continue; - - if (noIntro) - { - if (cd != NULL) - prcode(fp, -"\n" -"\n" -"/* Define the strings to be added to this type dictionary. */\n" -"static sipStringInstanceDef stringInstances_%C[] = {\n" - ,classFQCName(cd)); - else - prcode(fp, -"\n" -"\n" -"/* Define the strings to be added to this module dictionary. */\n" -"static sipStringInstanceDef stringInstances[] = {\n" - ); - - noIntro = FALSE; - } - - prcode(fp, -" {%N, %S},\n" - ,vd->pyname,vd->fqcname); - } - - if (!noIntro) - prcode(fp, -" {0, 0}\n" -"};\n" - ); - - return !noIntro; -} - - -/* - * Generate the code to add a set of enum instances to a dictionary. Return - * TRUE if there was at least one. - */ -static int generateEnums(sipSpec *pt, classDef *cd, FILE *fp) -{ - int noIntro; - varDef *vd; - - noIntro = TRUE; - - for (vd = pt->vars; vd != NULL; vd = vd->next) - { - if (vd->ecd != cd || vd->module != pt->module) - continue; - - if (vd->type.atype != enum_type || vd->type.u.ed->fqcname == NULL) - continue; - - if (needsHandler(vd)) - continue; - - /* Skip enums that need inline code. */ - if (!generating_c && vd->accessfunc == NULL && vd->type.nrderefs == 0) - continue; - - if (noIntro) - { - if (cd != NULL) - prcode(fp, -"\n" -"\n" -"/* Define the enum instances to be added to this type dictionary. */\n" -"static sipEnumInstanceDef enumInstances_%C[] = {\n" - ,classFQCName(cd)); - else - prcode(fp, -"\n" -"\n" -"/* Define the enum instances to be added to this module dictionary. */\n" -"static sipEnumInstanceDef enumInstances[] = {\n" - ); - - noIntro = FALSE; - } - - prcode(fp, -" {%N, (int)%S, &sipEnum_%C},\n" - ,vd->pyname,vd->fqcname,vd->type.u.ed->fqcname); - } - - if (!noIntro) - prcode(fp, -" {0, 0, 0}\n" -"};\n" - ); - - return !noIntro; -} - - -/* - * Generate the code to add a set of ints to a dictionary. Return TRUE if - * there was at least one. - */ -static int generateInts(sipSpec *pt, classDef *cd, FILE *fp) -{ - int noIntro; - varDef *vd; - enumDef *ed; - - noIntro = TRUE; - - for (vd = pt->vars; vd != NULL; vd = vd->next) - { - argType vtype = vd->type.atype; - - if (vd->ecd != cd || vd->module != pt->module) - continue; - - if (!(vtype == enum_type || vtype == ushort_type || - vtype == short_type || vtype == uint_type || - vtype == cint_type || vtype == int_type || - vtype == bool_type || vtype == cbool_type)) - continue; - - if (needsHandler(vd)) - continue; - - /* Named enums are handled elsewhere. */ - if (vtype == enum_type && vd->type.u.ed->fqcname != NULL) - continue; - - if (noIntro) - { - ints_intro(cd, fp); - noIntro = FALSE; - } - - prcode(fp, -" {%N, %S},\n" - ,vd->pyname,vd->fqcname); - } - - /* Now do global anonymous enums. */ - if (cd == NULL) - for (ed = pt->enums; ed != NULL; ed = ed->next) - { - enumMemberDef *em; - - if (ed->ecd != cd || ed->module != pt->module) - continue; - - if (ed->fqcname != NULL) - continue; - - for (em = ed->members; em != NULL; em = em->next) - { - if (noIntro) - { - ints_intro(cd, fp); - noIntro = FALSE; - } - - prcode(fp, -" {%N, %s},\n" - , em->pyname, em->cname); - } - } - - if (!noIntro) - prcode(fp, -" {0, 0}\n" -"};\n" - ); - - return !noIntro; -} - - -/* - * Generate the intro for a table of int instances. - */ -static void ints_intro(classDef *cd, FILE *fp) -{ - if (cd != NULL) - prcode(fp, -"\n" -"\n" -"/* Define the ints to be added to this type dictionary. */\n" -"static sipIntInstanceDef intInstances_%C[] = {\n" - ,classFQCName(cd)); - else - prcode(fp, -"\n" -"\n" -"/* Define the ints to be added to this module dictionary. */\n" -"static sipIntInstanceDef intInstances[] = {\n" - ); -} - - -/* - * Generate the code to add a set of longs to a dictionary. Return TRUE if - * there was at least one. - */ -static int generateLongs(sipSpec *pt, classDef *cd, FILE *fp) -{ - return generateVariableType(pt, cd, long_type, "long", "Long", "long", fp); -} - - -/* - * Generate the code to add a set of unsigned longs to a dictionary. Return - * TRUE if there was at least one. - */ -static int generateUnsignedLongs(sipSpec *pt, classDef *cd, FILE *fp) -{ - return generateVariableType(pt, cd, ulong_type, "unsigned long", "UnsignedLong", "unsignedLong", fp); -} - - -/* - * Generate the code to add a set of long longs to a dictionary. Return TRUE - * if there was at least one. - */ -static int generateLongLongs(sipSpec *pt, classDef *cd, FILE *fp) -{ - return generateVariableType(pt, cd, longlong_type, "long long", "LongLong", "longLong", fp); -} - - -/* - * Generate the code to add a set of unsigned long longs to a dictionary. - * Return TRUE if there was at least one. - */ -static int generateUnsignedLongLongs(sipSpec *pt, classDef *cd, FILE *fp) -{ - return generateVariableType(pt, cd, ulonglong_type, "unsigned long long", "UnsignedLongLong", "unsignedLongLong", fp); -} - - -/* - * Generate the code to add a set of a particular type to a dictionary. Return - * TRUE if there was at least one. - */ -static int generateVariableType(sipSpec *pt, classDef *cd, argType atype, const char *eng, const char *s1, const char *s2, FILE *fp) -{ - int noIntro; - varDef *vd; - - noIntro = TRUE; - - for (vd = pt->vars; vd != NULL; vd = vd->next) - { - argType vtype = vd->type.atype; - - if (vd->ecd != cd || vd->module != pt->module) - continue; - - if (vtype != atype) - continue; - - if (needsHandler(vd)) - continue; - - if (noIntro) - { - if (cd != NULL) - prcode(fp, -"\n" -"\n" -"/* Define the %ss to be added to this type dictionary. */\n" -"static sip%sInstanceDef %sInstances_%C[] = {\n" - , eng - , s1, s2, classFQCName(cd)); - else - prcode(fp, -"\n" -"\n" -"/* Define the %ss to be added to this module dictionary. */\n" -"static sip%sInstanceDef %sInstances[] = {\n" - , eng - , s1, s2); - - noIntro = FALSE; - } - - prcode(fp, -" {%N, %S},\n" - ,vd->pyname,vd->fqcname); - } - - if (!noIntro) - prcode(fp, -" {0, 0}\n" -"};\n" - ); - - return !noIntro; -} - - -/* - * Generate the code to add a set of doubles to a dictionary. Return TRUE if - * there was at least one. - */ -static int generateDoubles(sipSpec *pt,classDef *cd,FILE *fp) -{ - int noIntro; - varDef *vd; - - noIntro = TRUE; - - for (vd = pt->vars; vd != NULL; vd = vd->next) - { - argType vtype = vd->type.atype; - - if (vd->ecd != cd || vd->module != pt->module) - continue; - - if (!(vtype == float_type || vtype == cfloat_type || vtype == double_type || vtype == cdouble_type)) - continue; - - if (needsHandler(vd)) - continue; - - if (noIntro) - { - if (cd != NULL) - prcode(fp, -"\n" -"\n" -"/* Define the doubles to be added to this type dictionary. */\n" -"static sipDoubleInstanceDef doubleInstances_%C[] = {\n" - ,classFQCName(cd)); - else - prcode(fp, -"\n" -"\n" -"/* Define the doubles to be added to this module dictionary. */\n" -"static sipDoubleInstanceDef doubleInstances[] = {\n" - ); - - noIntro = FALSE; - } - - prcode(fp, -" {%N, %S},\n" - ,vd->pyname,vd->fqcname); - } - - if (!noIntro) - prcode(fp, -" {0, 0}\n" -"};\n" - ); - - return !noIntro; -} - - -/* - * Generate the C/C++ code for an interface. - */ -static void generateIfaceCpp(sipSpec *pt,ifaceFileDef *iff,char *codeDir, - char *srcSuffix,FILE *master) -{ - char *cppfile, *cmname = iff->module->name; - classDef *cd; - mappedTypeDef *mtd; - FILE *fp; - - if (master == NULL) - { - cppfile = createIfaceFileName(codeDir,iff,srcSuffix); - fp = createCompilationUnit(pt, cppfile, "Interface wrapper code."); - } - else - fp = master; - - prcode(fp, -"\n" -"#include \"sipAPI%s.h\"\n" -"#include \"sip%s%F.h\"\n" - ,cmname - ,cmname,iff->fqcname); - - generateUsedIncludes(iff->used, FALSE, fp); - - for (cd = pt->classes; cd != NULL; cd = cd->next) - if (cd->iff == iff) - { - if (isProtectedClass(cd)) - prcode(fp, -"\n" -"#include \"sip%s%F.h\"\n" - ,cmname,cd->ecd->iff->fqcname); - - if (!isExternal(cd)) - generateClassCpp(cd, pt, fp); - } - - for (mtd = pt->mappedtypes; mtd != NULL; mtd = mtd->next) - if (mtd->iff == iff) - generateMappedTypeCpp(mtd,fp); - - if (master == NULL) - { - closeFile(fp); - free(cppfile); - } -} - - -/* - * Return a filename for an interface C++ or header file on the heap. - */ -static char *createIfaceFileName(char *codeDir,ifaceFileDef *iff,char *suffix) -{ - char *fn; - scopedNameDef *snd; - - fn = concat(codeDir,"/sip",iff->module->name,NULL); - - for (snd = iff->fqcname; snd != NULL; snd = snd->next) - append(&fn,snd->name); - - append(&fn,suffix); - - return fn; -} - - -/* - * Generate the C++ code for a mapped type version. - */ -static void generateMappedTypeCpp(mappedTypeDef *mtd,FILE *fp) -{ - int need_xfer; - - prcode(fp, -"\n" -"\n" -"/* Call the mapped type's destructor. */\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static void release_%T(void *, int);}\n" - , &mtd->type); - - prcode(fp, -"static void release_%T(void *ptr, int%s)\n" -"{\n" - , &mtd->type, (generating_c ? " status" : "")); - - if (release_gil) - prcode(fp, -" Py_BEGIN_ALLOW_THREADS\n" - ); - - if (generating_c) - prcode(fp, -" sipFree(ptr);\n" - ); - else - prcode(fp, -" delete reinterpret_cast<%b *>(ptr);\n" - , &mtd->type); - - if (release_gil) - prcode(fp, -" Py_END_ALLOW_THREADS\n" - ); - - prcode(fp, -"}\n" -"\n" - ); - - generateConvertToDefinitions(mtd,NULL,fp); - - /* Generate the from type convertor. */ - - need_xfer = (generating_c || usedInCode(mtd->convfromcode, "sipTransferObj")); - - prcode(fp, -"\n" -"\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static PyObject *convertFrom_%T(void *, PyObject *);}\n" - , &mtd->type); - - prcode(fp, -"static PyObject *convertFrom_%T(void *sipCppV,PyObject *%s)\n" -"{\n" -" ", &mtd->type, (need_xfer ? "sipTransferObj" : "")); - - generateMappedTypeFromVoid(mtd, "sipCpp", "sipCppV", fp); - - prcode(fp, ";\n" -"\n" - ); - - generateCppCodeBlock(mtd->convfromcode,fp); - - prcode(fp, -"}\n" -"\n" -"\n" -"sipMappedType sipMappedTypeDef_%T = {\n" -" \"%B\",\n" -" release_%T,\n" -" forceConvertTo_%T,\n" -" convertTo_%T,\n" -" convertFrom_%T\n" -"};\n" - , &mtd->type - , &mtd->type - , &mtd->type - , &mtd->type - , &mtd->type - , &mtd->type - , &mtd->type); -} - - -/* - * Generate the C++ code for a class. - */ -static void generateClassCpp(classDef *cd,sipSpec *pt,FILE *fp) -{ - varDef *vd; - - /* Generate any local class code. */ - - generateCppCodeBlock(cd->cppcode,fp); - - generateClassFunctions(pt,cd,fp); - - generateAccessFunctions(pt,cd,fp); - - /* Generate the variable handlers. */ - if (hasVarHandlers(cd)) - { - for (vd = pt->vars; vd != NULL; vd = vd->next) - if (vd->ecd == cd && needsHandler(vd)) - generateVariableHandler(vd,fp); - - /* Generate the variable table. */ - prcode(fp, -"\n" -"PyMethodDef variables_%C[] = {\n" - ,classFQCName(cd)); - - for (vd = pt->vars; vd != NULL; vd = vd->next) - if (vd->ecd == cd && needsHandler(vd)) - prcode(fp, -" {%N, var_%C, %s, NULL},\n" - ,vd->pyname,vd->fqcname,(isStaticVar(vd) ? "METH_STATIC" : "0")); - - prcode(fp, -" {0, 0, 0, 0}\n" -"};\n" - ); - } - - if (cd->iff->type != namespace_iface) - generateConvertToDefinitions(NULL,cd,fp); - - /* The type definition structure. */ - generateTypeDefinition(pt, cd, fp); -} - - -/* - * Return a sorted array of relevant functions for a namespace. - */ - -static sortedMethTab *createFunctionTable(classDef *cd,int *nrp) -{ - int nr; - sortedMethTab *mtab, *mt; - memberDef *md; - - /* First we need to count the number of applicable functions. */ - - nr = 0; - - for (md = cd->members; md != NULL; md = md->next) - ++nr; - - if ((*nrp = nr) == 0) - return NULL; - - /* Create the table of methods. */ - - mtab = sipMalloc(sizeof (sortedMethTab) * nr); - - /* Initialise the table. */ - - mt = mtab; - - for (md = cd->members; md != NULL; md = md->next) - { - mt->md = md; - mt->is_static = TRUE; - - ++mt; - } - - /* Finally sort the table. */ - - qsort(mtab,nr,sizeof (sortedMethTab),compareMethTab); - - return mtab; -} - - -/* - * Return a sorted array of relevant methods (either lazy or non-lazy) for a - * class. - */ -static sortedMethTab *createMethodTable(classDef *cd, int *nrp) -{ - int nr; - visibleList *vl; - sortedMethTab *mtab, *mt; - - /* - * First we need to count the number of applicable methods. Only provide - * an entry point if there is at least one overload that is defined in this - * class and is a non-abstract function or slot. We allow private (even - * though we don't actually generate code) because we need to intercept the - * name before it reaches a more public version further up the class - * hierarchy. We add the ctor and any variable handlers as special - * entries. - */ - nr = 0; - - for (vl = cd->visible; vl != NULL; vl = vl->next) - { - overDef *od; - - if (vl->m->slot != no_slot) - continue; - - for (od = vl->cd->overs; od != NULL; od = od->next) - { - /* - * Skip protected methods if we don't have the means to - * handle them. - */ - if (isProtected(od) && !hasShadow(cd)) - continue; - - if (skipOverload(od,vl->m,cd,vl->cd,TRUE)) - continue; - - ++nr; - - break; - } - } - - if ((*nrp = nr) == 0) - return NULL; - - /* Create the table of methods. */ - - mtab = sipMalloc(sizeof (sortedMethTab) * nr); - - /* Initialise the table. */ - - mt = mtab; - - for (vl = cd->visible; vl != NULL; vl = vl->next) - { - int need_method, is_static; - overDef *od; - - if (vl->m->slot != no_slot) - continue; - - need_method = FALSE; - is_static = TRUE; - - for (od = vl->cd->overs; od != NULL; od = od->next) - { - /* - * Skip protected methods if we don't have the means to - * handle them. - */ - if (isProtected(od) && !hasShadow(cd)) - continue; - - if (!skipOverload(od,vl->m,cd,vl->cd,TRUE)) - { - need_method = TRUE; - - if (!isPrivate(od) && !isStatic(od)) - is_static = FALSE; - } - } - - if (need_method) - { - mt->md = vl->m; - mt->is_static = is_static; - - ++mt; - } - } - - /* Finally sort the table. */ - - qsort(mtab,nr,sizeof (sortedMethTab),compareMethTab); - - return mtab; -} - - -/* - * The qsort helper to compare two sortedMethTab structures based on the Python - * name of the method. - */ - -static int compareMethTab(const void *m1,const void *m2) -{ - return strcmp(((sortedMethTab *)m1)->md->pyname->text, - ((sortedMethTab *)m2)->md->pyname->text); -} - - -/* - * Generate the sorted table of methods and return the number of entries. - */ -static int generateMethodTable(classDef *cd,FILE *fp) -{ - int nr; - sortedMethTab *mtab; - - mtab = (cd->iff->type == namespace_iface) ? - createFunctionTable(cd,&nr) : - createMethodTable(cd,&nr); - - if (mtab != NULL) - { - int i; - - prcode(fp, -"\n" -"\n" -"static PyMethodDef methods_%C[] = {\n" - ,classFQCName(cd)); - - for (i = 0; i < nr; ++i) - { - memberDef *md = mtab[i].md; - - /* - * For the moment we are suppressing the generation of - * METH_STATIC until we understand descriptors better. - * It could be that they will simplify the handling of - * lazy attributes and allow things to be cached in the - * type dictionary. - */ - mtab[i].is_static = FALSE; - - prcode(fp, -" {%N, meth_%C_%s, METH_VARARGS%s, NULL}%s\n" - ,md->pyname,classFQCName(cd),md->pyname->text,(mtab[i].is_static ? "|METH_STATIC" : ""),((i + 1) < nr) ? "," : ""); - } - - free(mtab); - - prcode(fp, -"};\n" - ); - } - - return nr; -} - - -/* - * Generate the "to type" convertor definitions. - */ - -static void generateConvertToDefinitions(mappedTypeDef *mtd,classDef *cd, - FILE *fp) -{ - codeBlock *convtocode; - ifaceFileDef *iff; - argDef type; - - if (cd != NULL) - { - convtocode = cd->convtocode; - - iff = cd->iff; - - type.atype = class_type; - type.u.cd = cd; - } - else - { - convtocode = mtd->convtocode; - - iff = mtd->iff; - - type.atype = mapped_type; - type.u.mtd = mtd; - } - - type.argflags = 0; - type.name = NULL; - type.nrderefs = 0; - type.defval = NULL; - - /* Generate the type convertors. */ - - if (convtocode != NULL) - { - int need_ptr, need_xfer; - - /* - * Sometimes type convertors are just stubs that set the error - * flag, so check if we actually need everything so that we - * can avoid compiler warnings. - */ - need_ptr = (generating_c || usedInCode(convtocode, "sipCppPtr")); - need_xfer = (generating_c || usedInCode(convtocode, "sipTransferObj")); - - prcode(fp, -"\n" -"\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static int convertTo_%T(PyObject *, void **, int *, PyObject *);}\n" - , &type); - - prcode(fp, -"static int convertTo_%T(PyObject *sipPy,void **%s,int *sipIsErr,PyObject *%s)\n" -"{\n" - , &type, (need_ptr ? "sipCppPtrV" : ""), (need_xfer ? "sipTransferObj" : "")); - - if (need_ptr) - if (generating_c) - prcode(fp, -" %b **sipCppPtr = (%b **)sipCppPtrV;\n" -"\n" - , &type, &type); - else - prcode(fp, -" %b **sipCppPtr = reinterpret_cast<%b **>(sipCppPtrV);\n" -"\n" - , &type, &type); - - generateCppCodeBlock(convtocode,fp); - - prcode(fp, -"}\n" - ); - } - - prcode(fp, -"\n" -"\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static void *forceConvertTo_%T(PyObject *, int *);}\n" - , &type); - - prcode(fp, -"static void *forceConvertTo_%T(PyObject *valobj,int *iserrp)\n" -"{\n" -" if (*iserrp || valobj == NULL)\n" -" return NULL;\n" -"\n" - ,&type); - - if (convtocode != NULL) - prcode(fp, -" if (convertTo_%T(valobj,NULL,NULL,NULL))\n" -" {\n" -" void *val;\n" -"\n" -" /*\n" -" * Note that we throw away the flag that says if the value\n" -" * has just been created on the heap or not.\n" -" */\n" -" convertTo_%T(valobj,&val,iserrp,NULL);\n" -"\n" -" return val;\n" -" }\n" - ,&type - ,&type); - else - prcode(fp, -" if (valobj == Py_None || sipIsSubClassInstance(valobj,sipClass_%T))\n" -" return sipConvertToCpp(valobj,sipClass_%T,iserrp);\n" - ,&type - ,&type); - - if (cd != NULL) - prcode(fp, -"\n" -" sipBadClass(%N);\n" - , iff->name); - else - prcode(fp, -"\n" -" sipBadClass(\"%B\");\n" - , &mtd->type); - - prcode(fp, -"\n" -" *iserrp = 1;\n" -"\n" -" return NULL;\n" -"}\n" - ); -} - - -/* - * Generate a variable handler. - */ -static void generateVariableHandler(varDef *vd,FILE *fp) -{ - argType atype = vd->type.atype; - - prcode(fp, -"\n" -"\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static PyObject *var_%C(PyObject *, PyObject *);}\n" - , vd->fqcname); - - prcode(fp, -"static PyObject *var_%C(PyObject *%s,PyObject *sipPy)\n" -"{\n" - ,vd->fqcname,(isStaticVar(vd) ? "" : "sipSelf")); - - if (atype == class_type || atype == mapped_type) - prcode(fp, -" int sipIsErr = 0;\n" - ); - - if (vd->type.nrderefs == 0 && (atype == mapped_type || (atype == class_type && vd->type.u.cd->convtocode != NULL))) - prcode(fp, -" int sipValState;\n" - ); - - if (vd->getcode == NULL || vd->setcode == NULL) - { - prcode(fp, -" "); - - generateNamedValueType(&vd->type, "sipVal", fp); - - prcode(fp, ";\n" - ); - } - - if (!isStaticVar(vd)) - { - if (generating_c) - prcode(fp, -" %S *sipCpp = (%S *)sipGetCppPtr((sipWrapper *)sipSelf,sipClass_%C);\n" - ,classFQCName(vd->ecd),classFQCName(vd->ecd),classFQCName(vd->ecd)); - else - prcode(fp, -" %S *sipCpp = reinterpret_cast<%S *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_%C));\n" - ,classFQCName(vd->ecd),classFQCName(vd->ecd),classFQCName(vd->ecd)); - - prcode(fp, -"\n" -" if (!sipCpp)\n" -" return NULL;\n" - ); - } - - prcode(fp, -"\n" -" if (sipPy == NULL)\n" -" {\n" - ); - - /* Generate the get handler part. */ - - if (vd->getcode != NULL) - { - generateCppCodeBlock(vd->getcode, fp); - - prcode(fp, -"\n" -" return sipPy;\n" - ); - } - else - { - int pyobj = FALSE; - - prcode(fp, -" sipVal = %s", (((atype == class_type || atype == mapped_type) && vd->type.nrderefs == 0) ? "&" : "")); - - generateVarMember(vd, fp); - - prcode(fp, ";\n" -"\n" - ); - - switch (atype) - { - case mapped_type: - prcode(fp, -" sipPy = sipConvertFromMappedType(sipVal,sipMappedType_%T,NULL);\n" - ,&vd->type); - - break; - - case class_type: - generateVarClassConversion(vd,fp); - break; - - case bool_type: - case cbool_type: - prcode(fp, -" sipPy = PyBool_FromLong(sipVal);\n" - ); - - break; - - case sstring_type: - case ustring_type: - case string_type: - if (vd->type.nrderefs == 0) - prcode(fp, -" sipPy = PyString_FromStringAndSize(%s&sipVal,1);\n" - ,(atype != string_type) ? "(char *)" : ""); - else - prcode(fp, -" sipPy = PyString_FromString(%ssipVal);\n" - ,(atype != string_type) ? "(char *)" : ""); - - break; - - case wstring_type: - if (vd->type.nrderefs == 0) - prcode(fp, -" sipPy = PyUnicode_FromWideChar(&sipVal,1);\n" - ); - else - prcode(fp, -" sipPy = PyUnicode_FromWideChar(sipVal,(SIP_SSIZE_T)wcslen(sipVal));\n" - ); - - break; - - case float_type: - case cfloat_type: - prcode(fp, -" sipPy = PyFloat_FromDouble((double)sipVal);\n" - ); - break; - - case double_type: - case cdouble_type: - prcode(fp, -" sipPy = PyFloat_FromDouble(sipVal);\n" - ); - break; - - case enum_type: - if (vd->type.u.ed->fqcname != NULL) - { - prcode(fp, -" sipPy = sipConvertFromNamedEnum(sipVal,sipEnum_%C);\n" - ,vd->type.u.ed->fqcname); - - break; - } - - /* Drop through. */ - - case short_type: - case cint_type: - case int_type: - prcode(fp, -" sipPy = PyInt_FromLong(sipVal);\n" - ); - break; - - case long_type: - prcode(fp, -" sipPy = PyLong_FromLong(sipVal);\n" - ); - break; - - case ushort_type: - case uint_type: - case ulong_type: - prcode(fp, -" sipPy = PyLong_FromUnsignedLong(sipVal);\n" - ); - break; - - case longlong_type: - prcode(fp, -" sipPy = PyLong_FromLongLong(sipVal);\n" - ); - break; - - case ulonglong_type: - prcode(fp, -" sipPy = PyLong_FromUnsignedLongLong(sipVal);\n" - ); - break; - - case struct_type: - prcode(fp, -" sipPy = sipConvertFromVoidPtr("); - - if (isConstArg(&vd->type)) - prcode(fp, "const_cast<%b *>(sipVal)", &vd->type); - else - prcode(fp, "sipVal"); - - prcode(fp, ");\n" - ); - - break; - - case void_type: - prcode(fp, -" sipPy = sipConvertFromVoidPtr("); - - if (isConstArg(&vd->type)) - prcode(fp, "const_cast<void *>(sipVal)"); - else - prcode(fp, "sipVal"); - - prcode(fp, ");\n" - ); - - break; - - case pyobject_type: - case pytuple_type: - case pylist_type: - case pydict_type: - case pycallable_type: - case pyslice_type: - case pytype_type: - prcode(fp, -" Py_XINCREF(sipVal);\n" - ); - pyobj = TRUE; - break; - } - - prcode(fp, -"\n" -" return %s;\n" - ,(pyobj ? "sipVal" : "sipPy")); - } - - prcode(fp, -" }\n" -"\n" - ); - - /* Generate the set handler part. */ - - if (vd->setcode != NULL) - { - prcode(fp, -" {\n" -" int sipErr = 0;\n" -"\n" - ); - - generateCppCodeBlock(vd->setcode, fp); - - prcode(fp, -"\n" -" if (sipErr)\n" -" return NULL;\n" -" }\n" - ); - } - else - { - char *deref; - int might_be_temp; - - might_be_temp = generateObjToCppConversion(&vd->type,fp); - - deref = ""; - - if (atype == class_type || atype == mapped_type) - { - if (vd->type.nrderefs == 0) - deref = "*"; - - prcode(fp, -"\n" -" if (sipIsErr)\n" -" return NULL;\n" -"\n" - ); - } - else - { - if ((atype == sstring_type || atype == ustring_type || atype == string_type || atype == wstring_type) && vd->type.nrderefs != 0) - { - prcode(fp, -"\n" -" if (sipVal == NULL)\n" - ); - } - else - prcode(fp, -"\n" -" if (PyErr_Occurred() != NULL)\n" - ); - - prcode(fp, -" {\n" -" sipBadSetType(%N,%N);\n" -" return NULL;\n" -" }\n" -"\n" - ,vd->ecd->iff->name,vd->pyname); - } - - if (atype == pyobject_type || atype == pytuple_type || - atype == pylist_type || atype == pydict_type || - atype == pycallable_type || atype == pyslice_type || - atype == pytype_type) - { - prcode(fp, -" Py_XDECREF("); - - generateVarMember(vd, fp); - - prcode(fp, ");\n" -" Py_INCREF(sipVal);\n" -"\n" - ); - } - - prcode(fp, -" "); - - generateVarMember(vd, fp); - - prcode(fp, " = %ssipVal;\n" - , deref); - - /* Note that wchar_t * leaks here. */ - - if (might_be_temp) - prcode(fp, -"\n" -" sipReleaseInstance(sipVal,sipClass_%C,sipValState);\n" - , classFQCName(vd->type.u.cd)); - else if (vd->type.atype == mapped_type && vd->type.nrderefs == 0) - prcode(fp, -"\n" -" sipReleaseMappedType(sipVal,sipMappedType_%T,sipValState);\n" - , &vd->type); - } - - prcode(fp, -"\n" -" Py_INCREF(Py_None);\n" -" return Py_None;\n" -"}\n" - ); -} - - -/* - * Generate the member variable of a class. - */ -static void generateVarMember(varDef *vd, FILE *fp) -{ - if (isStaticVar(vd)) - prcode(fp,"%S::",classFQCName(vd->ecd)); - else - prcode(fp,"sipCpp->"); - - prcode(fp, "%s", scopedNameTail(vd->fqcname)); -} - - -/* - * Generate an variable class conversion fragment. - */ -static void generateVarClassConversion(varDef *vd,FILE *fp) -{ - classDef *cd = vd->type.u.cd; - - prcode(fp, -" sipPy = sipConvertFromInstance("); - - if (isConstArg(&vd->type)) - prcode(fp,"const_cast<%b *>(sipVal)",&vd->type); - else - prcode(fp,"sipVal"); - - prcode(fp,",sipClass_%C,NULL);\n" - ,classFQCName(cd)); -} - - -/* - * Generate the declaration of a variable that is initialised from a Python - * object. Return TRUE if the value might be a temporary on the heap. - */ -static int generateObjToCppConversion(argDef *ad,FILE *fp) -{ - int might_be_temp = FALSE; - char *rhs = NULL; - - prcode(fp, -" sipVal = "); - - switch (ad->atype) - { - case mapped_type: - { - const char *tail; - - if (generating_c) - { - prcode(fp, "(%b *)", ad); - tail = ""; - } - else - { - prcode(fp, "reinterpret_cast<%b *>(", ad); - tail = ")"; - } - - /* - * Note that we don't support /Transfer/ but could do. - */ - - prcode(fp, "sipForceConvertToMappedType(sipPy,sipMappedType_%T,NULL,%s,%s,&sipIsErr)", ad, (ad->nrderefs ? "0" : "SIP_NOT_NONE"), (ad->nrderefs ? "NULL" : "&sipValState")); - - prcode(fp, "%s;\n" - , tail); - } - break; - - case class_type: - { - const char *tail; - - if (ad->nrderefs == 0 && ad->u.cd->convtocode != NULL) - might_be_temp = TRUE; - - if (generating_c) - { - prcode(fp, "(%b *)", ad); - tail = ""; - } - else - { - prcode(fp, "reinterpret_cast<%b *>(", ad); - tail = ")"; - } - - /* - * Note that we don't support /Transfer/ but could do. - * We could also support /Constrained/ (so long as we - * also supported it for all types). - */ - - prcode(fp, "sipForceConvertToInstance(sipPy,sipClass_%C,NULL,%s,%s,&sipIsErr)", classFQCName(ad->u.cd), (ad->nrderefs ? "0" : "SIP_NOT_NONE"), (might_be_temp ? "&sipValState" : "NULL")); - - prcode(fp, "%s;\n" - , tail); - } - break; - - case enum_type: - prcode(fp, "(%E)PyInt_AsLong(sipPy);\n" - , ad->u.ed); - break; - - case sstring_type: - if (ad->nrderefs == 0) - rhs = "(signed char)sipString_AsChar(sipPy)"; - else - rhs = "(signed char *)PyString_AsString(sipPy)"; - break; - - case ustring_type: - if (ad->nrderefs == 0) - rhs = "(unsigned char)sipString_AsChar(sipPy)"; - else - rhs = "(unsigned char *)PyString_AsString(sipPy)"; - break; - - case string_type: - if (ad->nrderefs == 0) - rhs = "sipString_AsChar(sipPy)"; - else - rhs = "PyString_AsString(sipPy)"; - break; - - case wstring_type: - if (ad->nrderefs == 0) - rhs = "sipUnicode_AsWChar(sipPy)"; - else - rhs = "sipUnicode_AsWString(sipPy)"; - break; - - case float_type: - case cfloat_type: - rhs = "(float)PyFloat_AsDouble(sipPy)"; - break; - - case double_type: - case cdouble_type: - rhs = "PyFloat_AsDouble(sipPy)"; - break; - - case bool_type: - case cbool_type: - rhs = "(bool)PyInt_AsLong(sipPy)"; - break; - - case ushort_type: - rhs = "(unsigned short)sipLong_AsUnsignedLong(sipPy)"; - break; - - case short_type: - rhs = "(short)PyInt_AsLong(sipPy)"; - break; - - case uint_type: - rhs = "(unsigned)sipLong_AsUnsignedLong(sipPy)"; - break; - - case int_type: - case cint_type: - rhs = "(int)PyInt_AsLong(sipPy)"; - break; - - case ulong_type: - rhs = "sipLong_AsUnsignedLong(sipPy)"; - break; - - case long_type: - rhs = "PyLong_AsLong(sipPy)"; - break; - - case ulonglong_type: - rhs = "PyLong_AsUnsignedLongLong(sipPy)"; - break; - - case longlong_type: - rhs = "PyLong_AsLongLong(sipPy)"; - break; - - case struct_type: - prcode(fp, "(struct %S *)sipConvertToVoidPtr(sipPy);\n" - , ad->u.sname); - break; - - case void_type: - rhs = "sipConvertToVoidPtr(sipPy)"; - break; - - case pyobject_type: - case pytuple_type: - case pylist_type: - case pydict_type: - case pycallable_type: - case pyslice_type: - case pytype_type: - rhs = "sipPy"; - break; - } - - if (rhs != NULL) - prcode(fp, "%s;\n" - , rhs); - - return might_be_temp; -} - - -/* - * Returns TRUE if the given method is a slot that takes zero arguments. - */ -static int isZeroArgSlot(memberDef *md) -{ - slotType st = md->slot; - - return (st == str_slot || st == int_slot || st == long_slot || - st == float_slot || st == invert_slot || st == neg_slot || - st == len_slot || st == nonzero_slot || st == pos_slot || - st == abs_slot || st == repr_slot || st == hash_slot); -} - - -/* - * Returns TRUE if the given method is a slot that takes more than one - * argument. - */ -static int isMultiArgSlot(memberDef *md) -{ - slotType st = md->slot; - - return (st == setitem_slot || st == call_slot); -} - - -/* - * Returns TRUE if the given method is a slot that returns void (ie. nothing - * other than an error indicator). - */ -int isVoidReturnSlot(memberDef *md) -{ - slotType st = md->slot; - - return (st == setitem_slot || st == delitem_slot); -} - - -/* - * Returns TRUE if the given method is a slot that returns int. - */ -int isIntReturnSlot(memberDef *md) -{ - slotType st = md->slot; - - return (st == len_slot || st == nonzero_slot || st == contains_slot || - st == cmp_slot); -} - - -/* - * Returns TRUE if the given method is a slot that returns long. - */ -int isLongReturnSlot(memberDef *md) -{ - slotType st = md->slot; - - return (st == hash_slot); -} - - -/* - * Returns TRUE if the given method is a slot that takes an int argument. - */ -static int isIntArgSlot(memberDef *md) -{ - slotType st = md->slot; - - return (st == repeat_slot || st == irepeat_slot); -} - - -/* - * Returns TRUE if the given method is an inplace number slot. - */ -static int isInplaceNumberSlot(memberDef *md) -{ - slotType st = md->slot; - - return (st == iadd_slot || st == isub_slot || st == imul_slot || - st == idiv_slot || st == imod_slot || - st == ior_slot || st == ixor_slot || st == iand_slot || - st == ilshift_slot || st == irshift_slot); -} - - -/* - * Returns TRUE if the given method is an inplace sequence slot. - */ -static int isInplaceSequenceSlot(memberDef *md) -{ - slotType st = md->slot; - - return (st == iconcat_slot || st == irepeat_slot); -} - - -/* - * Returns TRUE if the given method is a number slot slot. - */ -int isNumberSlot(memberDef *md) -{ - slotType st = md->slot; - - return (st == add_slot || st == sub_slot || st == mul_slot || - st == div_slot || st == mod_slot || - st == and_slot || st == or_slot || st == xor_slot || - st == lshift_slot || st == rshift_slot); -} - - -/* - * Returns TRUE if the given method is a rich compare slot. - */ -int isRichCompareSlot(memberDef *md) -{ - slotType st = md->slot; - - return (st == lt_slot || st == le_slot || st == eq_slot || - st == ne_slot || st == gt_slot || st == ge_slot); -} - - -/* - * Generate a Python slot handler for either a class, an enum or an extender. - */ -static void generateSlot(sipSpec *pt, classDef *cd, enumDef *ed, memberDef *md, FILE *fp) -{ - char *arg_str, *prefix, *ret_type; - int ret_int, nr_args; - overDef *od, *overs; - scopedNameDef *fqcname; - nameDef *pyname; - - if (ed != NULL) - { - prefix = "Enum"; - pyname = ed->pyname; - fqcname = ed->fqcname; - overs = ed->overs; - } - else if (cd != NULL) - { - prefix = "Class"; - pyname = cd->iff->name; - fqcname = classFQCName(cd); - overs = cd->overs; - } - else - { - prefix = NULL; - pyname = NULL; - fqcname = NULL; - overs = pt->overs; - } - - if (isVoidReturnSlot(md) || isIntReturnSlot(md)) - { - ret_int = TRUE; - ret_type = "int "; - } - else - { - ret_int = FALSE; - - if (isLongReturnSlot(md)) - ret_type = "long "; - else - ret_type = "PyObject *"; - } - - if (isIntArgSlot(md)) - { - nr_args = 0; - arg_str = "PyObject *sipSelf,int a0"; - } - else if (isMultiArgSlot(md)) - { - nr_args = 2; - arg_str = "PyObject *sipSelf,PyObject *sipArgs"; - } - else if (isZeroArgSlot(md)) - { - nr_args = 0; - arg_str = "PyObject *sipSelf"; - } - else if (isNumberSlot(md)) - { - nr_args = 2; - arg_str = "PyObject *sipArg0,PyObject *sipArg1"; - } - else - { - nr_args = 1; - arg_str = "PyObject *sipSelf,PyObject *sipArg"; - } - - prcode(fp, -"\n" -"\n" - ); - - if (!generating_c) - { - prcode(fp, -"extern \"C\" {static %sslot_", ret_type); - - if (fqcname != NULL) - prcode(fp, "%C_", fqcname); - - prcode(fp, "%s(%s);}\n" - , md->pyname->text, arg_str); - } - - prcode(fp, -"static %sslot_", ret_type); - - if (fqcname != NULL) - prcode(fp, "%C_", fqcname); - - prcode(fp, "%s(%s)\n" -"{\n" - , md->pyname->text, arg_str); - - if (isInplaceNumberSlot(md)) - prcode(fp, -" if (!PyObject_TypeCheck(sipSelf,(PyTypeObject *)sip%s_%C))\n" -" {\n" -" Py_INCREF(Py_NotImplemented);\n" -" return Py_NotImplemented;\n" -" }\n" -"\n" - , prefix, fqcname); - - if (!isNumberSlot(md)) - if (cd != NULL) - prcode(fp, -" %S *sipCpp = reinterpret_cast<%S *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_%C));\n" -"\n" -" if (!sipCpp)\n" -" return %s;\n" -"\n" - , fqcname, fqcname, fqcname - , (md->slot == cmp_slot ? "-2" : (ret_int ? "-1" : "0"))); - else - prcode(fp, -" %S sipCpp = static_cast<%S>(PyInt_AsLong(sipSelf));\n" -"\n" - , fqcname, fqcname); - - if (nr_args > 0) - prcode(fp, -" int sipArgsParsed = 0;\n" - ); - - for (od = overs; od != NULL; od = od->next) - if (od->common == md && isAbstract(od)) - { - prcode(fp, -" bool sipSelfWasArg = !sipSelf;\n" - ); - - break; - } - - for (od = overs; od != NULL; od = od->next) - if (od->common == md) - generateFunctionBody(pt, od, cd, cd, (ed == NULL && !dontDerefSelf(od)), fp); - - if (nr_args > 0) - switch (md->slot) - { - case cmp_slot: - prcode(fp, -"\n" -" return 2;\n" - ); - break; - - case concat_slot: - case iconcat_slot: - case repeat_slot: - case irepeat_slot: - prcode(fp, -"\n" -" /* Raise an exception if the argument couldn't be parsed. */\n" -" sipBadOperatorArg(sipSelf,sipArg,%s);\n" -"\n" -" return NULL;\n" - ,slotName(md->slot)); - break; - - default: - if (isNumberSlot(md) || isRichCompareSlot(md)) - { - /* We can't extend enum slots. */ - if (cd == NULL) - prcode(fp, -"\n" -" Py_INCREF(Py_NotImplemented);\n" -" return Py_NotImplemented;\n" - ); - else if (isNumberSlot(md)) - prcode(fp, -"\n" -" return sipPySlotExtend(&sipModuleAPI_%s,%s,NULL,sipArg0,sipArg1);\n" - , pt->module->name, slotName(md->slot)); - else - prcode(fp, -"\n" -" return sipPySlotExtend(&sipModuleAPI_%s,%s,sip%s_%C,sipSelf,sipArg);\n" - , pt->module->name, slotName(md->slot), prefix, fqcname); - } - else if (isInplaceNumberSlot(md)) - prcode(fp, -"\n" -" PyErr_Clear();\n" -"\n" -" Py_INCREF(Py_NotImplemented);\n" -" return Py_NotImplemented;\n" - ); - else - prcode(fp, -"\n" -" /* Raise an exception if the arguments couldn't be parsed. */\n" -" sipNoMethod(sipArgsParsed,%N,%N);\n" -"\n" -" return %s;\n" - , pyname, md->pyname - ,ret_int ? "-1" : "0"); - } - - prcode(fp, -"}\n" - ); -} - - -/* - * Generate the member functions for a class. - */ -static void generateClassFunctions(sipSpec *pt,classDef *cd,FILE *fp) -{ - visibleList *vl; - memberDef *md; - - /* Any shadow code. */ - if (hasShadow(cd)) - generateShadowCode(pt,cd,fp); - - /* The member functions. */ - for (vl = cd->visible; vl != NULL; vl = vl->next) - if (vl->m->slot == no_slot) - generateFunction(pt, vl->m, vl->cd->overs, cd, vl->cd, fp); - - /* The slot functions. */ - for (md = cd->members; md != NULL; md = md->next) - if (cd->iff->type == namespace_iface) - generateOrdinaryFunction(pt,cd,md,fp); - else if (md->slot != no_slot && md->slot != unicode_slot) - generateSlot(pt, cd, NULL, md, fp); - - if (cd->iff->type != namespace_iface && !generating_c) - { - classList *cl; - int need_ptr, need_state; - - /* The cast function. */ - prcode(fp, -"\n" -"\n" -"/* Cast a pointer to a type somewhere in its superclass hierarchy. */\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static void *cast_%C(void *, sipWrapperType *);}\n" - , classFQCName(cd)); - - prcode(fp, -"static void *cast_%C(void *ptr,sipWrapperType *targetClass)\n" -"{\n" - ,classFQCName(cd)); - - if (cd->supers != NULL) - prcode(fp, -" void *res;\n" -"\n" - ); - - prcode(fp, -" if (targetClass == sipClass_%C)\n" -" return ptr;\n" - ,classFQCName(cd)); - - for (cl = cd->supers; cl != NULL; cl = cl->next) - { - scopedNameDef *sname = cl->cd->iff->fqcname; - - prcode(fp, -"\n" -" if ((res = sipCast_%C((%S *)(%S *)ptr,targetClass)) != NULL)\n" -" return res;\n" - ,sname,sname,classFQCName(cd)); - } - - prcode(fp, -"\n" -" return NULL;\n" -"}\n" - ); - - /* Generate the release function without compiler warnings. */ - need_ptr = need_state = FALSE; - - if (canCreate(cd) || isPublicDtor(cd)) - { - if (hasShadow(cd)) - need_ptr = need_state = TRUE; - else if (isPublicDtor(cd)) - need_ptr = TRUE; - } - - prcode(fp, -"\n" -"\n" -"/* Call the instance's destructor. */\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static void release_%C(void *, int);}\n" - , classFQCName(cd)); - - prcode(fp, -"static void release_%C(void *%s,int%s)\n" -"{\n" - , classFQCName(cd), (need_ptr ? "ptr" : ""), (need_state ? " state" : "")); - - /* - * If there is an explicit public dtor then assume there is - * some way to call it which we haven't worked out (because we - * don't fully understand C++). - */ - if (canCreate(cd) || isPublicDtor(cd)) - { - int rgil = ((release_gil || isReleaseGILDtor(cd)) && !isHoldGILDtor(cd)); - - if (rgil) - prcode(fp, -" Py_BEGIN_ALLOW_THREADS\n" -"\n" - ); - - if (hasShadow(cd)) - { - prcode(fp, -" if (state & SIP_DERIVED_CLASS)\n" -" delete reinterpret_cast<sip%C *>(ptr);\n" - , classFQCName(cd)); - - if (isPublicDtor(cd)) - prcode(fp, -" else\n" -" delete reinterpret_cast<%U *>(ptr);\n" - , cd); - } - else if (isPublicDtor(cd)) - prcode(fp, -" delete reinterpret_cast<%U *>(ptr);\n" - , cd); - - if (rgil) - prcode(fp, -"\n" -" Py_END_ALLOW_THREADS\n" - ); - } - - prcode(fp, -"}\n" - ); - } - - /* The traverse function. */ - if (cd->travcode != NULL) - { - prcode(fp, -"\n" -"\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static int traverse_%C(void *, visitproc, void *);}\n" - , classFQCName(cd)); - - prcode(fp, -"static int traverse_%C(void *sipCppV,visitproc sipVisit,void *sipArg)\n" -"{\n" -" ", classFQCName(cd)); - - generateClassFromVoid(cd, "sipCpp", "sipCppV", fp); - - prcode(fp, ";\n" -" int sipRes;\n" -"\n" - ); - - generateCppCodeBlock(cd->travcode, fp); - - prcode(fp, -"\n" -" return sipRes;\n" -"}\n" - ); - } - - /* The clear function. */ - if (cd->clearcode != NULL) - { - prcode(fp, -"\n" -"\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static int clear_%C(void *);}\n" - , classFQCName(cd)); - - prcode(fp, -"static int clear_%C(void *sipCppV)\n" -"{\n" -" ", classFQCName(cd)); - - generateClassFromVoid(cd, "sipCpp", "sipCppV", fp); - - prcode(fp, ";\n" -" int sipRes;\n" -"\n" - ); - - generateCppCodeBlock(cd->clearcode, fp); - - prcode(fp, -"\n" -" return sipRes;\n" -"}\n" - ); - } - - /* The buffer interface functions. */ - if (cd->readbufcode != NULL) - { - prcode(fp, -"\n" -"\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static SIP_SSIZE_T getreadbuffer_%C(PyObject *, void *, SIP_SSIZE_T, void **);}\n" - , classFQCName(cd)); - - prcode(fp, -"static SIP_SSIZE_T getreadbuffer_%C(PyObject *%s, void *sipCppV, SIP_SSIZE_T %s, void **%s)\n" -"{\n" -" ", classFQCName(cd) - , argName("sipSelf", cd->readbufcode) - , argName("sipSegment", cd->readbufcode) - , argName("sipPtrPtr", cd->readbufcode)); - - generateClassFromVoid(cd, "sipCpp", "sipCppV", fp); - - prcode(fp, ";\n" -" SIP_SSIZE_T sipRes;\n" -"\n" - ); - - generateCppCodeBlock(cd->readbufcode, fp); - - prcode(fp, -"\n" -" return sipRes;\n" -"}\n" - ); - } - - if (cd->writebufcode != NULL) - { - prcode(fp, -"\n" -"\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static SIP_SSIZE_T getwritebuffer_%C(PyObject *, void *, SIP_SSIZE_T, void **);}\n" - , classFQCName(cd)); - - prcode(fp, -"static SIP_SSIZE_T getwritebuffer_%C(PyObject *%s, void *sipCppV, SIP_SSIZE_T %s, void **%s)\n" -"{\n" -" ", classFQCName(cd) - , argName("sipSelf", cd->writebufcode) - , argName("sipSegment", cd->writebufcode) - , argName("sipPtrPtr", cd->writebufcode)); - - generateClassFromVoid(cd, "sipCpp", "sipCppV", fp); - - prcode(fp, ";\n" -" SIP_SSIZE_T sipRes;\n" -"\n" - ); - - generateCppCodeBlock(cd->writebufcode, fp); - - prcode(fp, -"\n" -" return sipRes;\n" -"}\n" - ); - } - - if (cd->segcountcode != NULL) - { - prcode(fp, -"\n" -"\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static SIP_SSIZE_T getsegcount_%C(PyObject *, void *, SIP_SSIZE_T *);}\n" - , classFQCName(cd)); - - prcode(fp, -"static SIP_SSIZE_T getsegcount_%C(PyObject *%s, void *sipCppV, SIP_SSIZE_T *%s)\n" -"{\n" -" ", classFQCName(cd) - , argName("sipSelf", cd->segcountcode) - , argName("sipLenPtr", cd->segcountcode)); - - generateClassFromVoid(cd, "sipCpp", "sipCppV", fp); - - prcode(fp, ";\n" -" SIP_SSIZE_T sipRes;\n" -"\n" - ); - - generateCppCodeBlock(cd->segcountcode, fp); - - prcode(fp, -"\n" -" return sipRes;\n" -"}\n" - ); - } - - if (cd->charbufcode != NULL) - { - prcode(fp, -"\n" -"\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static SIP_SSIZE_T getcharbuffer_%C(PyObject *, void *, SIP_SSIZE_T, void **);}\n" - , classFQCName(cd)); - - prcode(fp, -"static SIP_SSIZE_T getcharbuffer_%C(PyObject *%s, void *sipCppV, SIP_SSIZE_T %s, void **%s)\n" -"{\n" -" ", classFQCName(cd) - , argName("sipSelf", cd->charbufcode) - , argName("sipSegment", cd->charbufcode) - , argName("sipPtrPtr", cd->charbufcode)); - - generateClassFromVoid(cd, "sipCpp", "sipCppV", fp); - - prcode(fp, ";\n" -" SIP_SSIZE_T sipRes;\n" -"\n" - ); - - generateCppCodeBlock(cd->charbufcode, fp); - - prcode(fp, -"\n" -" return sipRes;\n" -"}\n" - ); - } - - /* The dealloc function. */ - if (needDealloc(cd)) - { - prcode(fp, -"\n" -"\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static void dealloc_%C(sipWrapper *);}\n" - , classFQCName(cd)); - - prcode(fp, -"static void dealloc_%C(sipWrapper *sipSelf)\n" -"{\n" - ,classFQCName(cd)); - - if (tracing) - prcode(fp, -" sipTrace(SIP_TRACE_DEALLOCS,\"dealloc_%C()\\n\");\n" -"\n" - ,classFQCName(cd)); - - /* Disable the virtual handlers. */ - if (hasShadow(cd)) - prcode(fp, -" if (sipIsDerived(sipSelf))\n" -" reinterpret_cast<sip%C *>(sipSelf->u.cppPtr)->sipPySelf = NULL;\n" -"\n" - ,classFQCName(cd)); - - if (generating_c || isPublicDtor(cd) || (hasShadow(cd) && isProtectedDtor(cd))) - { - prcode(fp, -" if (sipIsPyOwned(sipSelf))\n" -" {\n" - ); - - if (cd->dealloccode != NULL) - { - if (usedInCode(cd->dealloccode, "sipCpp")) - { - prcode(fp, -" "); - - generateClassFromVoid(cd, "sipCpp", "sipSelf->u.cppPtr", fp); - - prcode(fp, ";\n" - ); - } - - generateCppCodeBlock(cd->dealloccode,fp); - - prcode(fp, -"\n" - ); - } - - if (isDelayedDtor(cd)) - prcode(fp, -" sipAddDelayedDtor(sipSelf);\n" - ); - else if (generating_c) - prcode(fp, -" sipFree(sipSelf->u.cppPtr);\n" - ); - else - prcode(fp, -" release_%C(sipSelf->u.cppPtr,%s);\n" - , classFQCName(cd), (hasShadow(cd) ? "sipSelf->flags" : "0")); - - prcode(fp, -" }\n" - ); - } - - prcode(fp, -"}\n" - ); - } - - /* The type initialisation function. */ - if (canCreate(cd)) - generateTypeInit(pt, cd, fp); -} - - -/* - * Generate the shadow (derived) class code. - */ -static void generateShadowCode(sipSpec *pt,classDef *cd,FILE *fp) -{ - int nrVirts, virtNr; - virtOverDef *vod; - ctorDef *ct; - - nrVirts = countVirtuals(cd); - - /* Generate the wrapper class constructors. */ - - for (ct = cd->ctors; ct != NULL; ct = ct->next) - { - char *prefix; - int a; - ctorDef *dct; - - if (isPrivateCtor(ct)) - continue; - - if (ct->cppsig == NULL) - continue; - - /* Check we haven't already handled this C++ signature. */ - for (dct = cd->ctors; dct != ct; dct = dct->next) - if (dct->cppsig != NULL && sameSignature(dct->cppsig, ct->cppsig, TRUE)) - break; - - if (dct != ct) - continue; - - prcode(fp, -"\n" -"sip%C::sip%C(",classFQCName(cd),classFQCName(cd)); - - generateArgs(ct->cppsig,Definition,fp); - - prcode(fp,")%X: %S(",ct->exceptions,classFQCName(cd)); - - prefix = ""; - - for (a = 0; a < ct->cppsig->nrArgs; ++a) - { - prcode(fp,"%sa%d",prefix,a); - prefix = ","; - } - - prcode(fp,"), sipPySelf(0)\n" -"{\n" - ); - - if (tracing) - { - prcode(fp, -" sipTrace(SIP_TRACE_CTORS,\"sip%C::sip%C(",classFQCName(cd),classFQCName(cd)); - generateArgs(ct->cppsig,Declaration,fp); - prcode(fp,")%X (this=0x%%08x)\\n\",this);\n" -"\n" - ,ct->exceptions); - } - - prcode(fp, -" sipCommonCtor(%s,%d);\n" -"}\n" - ,(nrVirts > 0 ? "sipPyMethods" : "NULL"),nrVirts); - } - - /* The destructor. */ - - if (!isPrivateDtor(cd)) - { - prcode(fp, -"\n" -"sip%C::~sip%C()%X\n" -"{\n" - ,classFQCName(cd),classFQCName(cd),cd->dtorexceptions); - - if (tracing) - prcode(fp, -" sipTrace(SIP_TRACE_DTORS,\"sip%C::~sip%C()%X (this=0x%%08x)\\n\",this);\n" -"\n" - ,classFQCName(cd),classFQCName(cd),cd->dtorexceptions); - - if (cd->dtorcode != NULL) - generateCppCodeBlock(cd->dtorcode,fp); - - prcode(fp, -" sipCommonDtor(sipPySelf);\n" -"}\n" - ); - } - - /* The metacall method if required. */ - if (isQObjectSubClass(cd) && optQ_OBJECT4(pt)) - { - prcode(fp, -"\n" -"const TQMetaObject *sip%C::metaObject() const\n" -"{\n" -" return sip_%s_qt_metaobject(sipPySelf,sipClass_%C,%S::metaObject());\n" -"}\n" -"\n" -"int sip%C::qt_metacall(TQMetaObject::Call _c,int _id,void **_a)\n" -"{\n" -" sip%C::metaObject();\n" -"\n" -" _id = %S::qt_metacall(_c,_id,_a);\n" -"\n" -" if (_id >= 0)\n" -" {\n" -" SIP_BLOCK_THREADS\n" -" _id = sip_%s_qt_metacall(sipPySelf,sipClass_%C,_c,_id,_a);\n" -" SIP_UNBLOCK_THREADS\n" -" }\n" -"\n" -" return _id;\n" -"}\n" - , classFQCName(cd) - , pt->module->name, classFQCName(cd), classFQCName(cd) - , classFQCName(cd) - , classFQCName(cd) - , classFQCName(cd) - , pt->module->name, classFQCName(cd)); - } - - /* Generate the virtual catchers. */ - - virtNr = 0; - - for (vod = cd->vmembers; vod != NULL; vod = vod->next) - { - overDef *od = &vod->o; - virtOverDef *dvod; - - if (isPrivate(od)) - continue; - - /* Check we haven't already handled this C++ signature. */ - for (dvod = cd->vmembers; dvod != vod; dvod = dvod->next) - if (strcmp(dvod->o.cppname,od->cppname) == 0 && sameSignature(dvod->o.cppsig,od->cppsig,TRUE)) - break; - - if (dvod != vod) - continue; - - generateVirtualCatcher(pt,cd,virtNr++,vod,fp); - } - - /* Generate the wrapper around each protected member function. */ - - generateProtectedDefinitions(cd,fp); - - /* Generate the emitters if needed. */ - if (!optNoEmitters(pt)) - generateEmitters(pt, cd, fp); -} - - -/* - * Generate the emitter functions. - */ -static void generateEmitters(sipSpec *pt, classDef *cd, FILE *fp) -{ - int noIntro; - visibleList *vl; - - for (vl = cd->visible; vl != NULL; vl = vl->next) - { - overDef *od; - - for (od = vl->cd->overs; od != NULL; od = od->next) - if (od->common == vl->m && isSignal(od)) - { - generateEmitter(pt,cd,vl,fp); - break; - } - } - - /* Generate the table of signals to support fan-outs. */ - - noIntro = TRUE; - - for (vl = cd->visible; vl != NULL; vl = vl->next) - { - overDef *od; - - for (od = vl->cd->overs; od != NULL; od = od->next) - if (od->common == vl->m && isSignal(od)) - { - if (noIntro) - { - setHasSigSlots(cd); - - prcode(fp, -"\n" -"static sipQtSignal signals_%C[] = {\n" - ,classFQCName(cd)); - - noIntro = FALSE; - } - - prcode(fp, -" {%N, %C_emit_%s},\n" - ,vl->m->pyname,classFQCName(cd),vl->m->pyname->text); - - break; - } - } - - if (!noIntro) - prcode(fp, -" {NULL, NULL}\n" -"};\n" - ); -} - - -/* - * Generate the protected enums for a class. - */ -static void generateProtectedEnums(sipSpec *pt,classDef *cd,FILE *fp) -{ - enumDef *ed; - - for (ed = pt->enums; ed != NULL; ed = ed->next) - { - char *eol; - enumMemberDef *emd; - - /* Ignore unless this class is the publisher. */ - if (cd != ed->pcd) - continue; - - prcode(fp, -"\n" -" /* Expose this protected enum. */\n" -" enum"); - - if (ed->fqcname != NULL) - prcode(fp," sip%s",scopedNameTail(ed->fqcname)); - - prcode(fp," {"); - - eol = "\n"; - - for (emd = ed->members; emd != NULL; emd = emd->next) - { - prcode(fp,"%s" -" %s = %S::%s",eol,emd->cname,classFQCName(ed->ecd),emd->cname); - - eol = ",\n"; - } - - prcode(fp,"\n" -" };\n" - ); - } -} - - -/* - * Generate the catcher for a virtual function. - */ -static void generateVirtualCatcher(sipSpec *pt, classDef *cd, int virtNr, - virtOverDef *vod, FILE *fp) -{ - overDef *od = &vod->o; - virtHandlerDef *vhd = od->virthandler; - argDef *res, *ad; - int a; - - normaliseArgs(od->cppsig); - - res = &od->cppsig->result; - - if (res->atype == void_type && res->nrderefs == 0) - res = NULL; - - prcode(fp, -"\n"); - - generateBaseType(&od->cppsig->result,fp); - - prcode(fp," sip%C::%O(",classFQCName(cd),od); - generateArgs(od->cppsig,Definition,fp); - prcode(fp,")%s%X\n" -"{\n" - ,(isConst(od) ? " const" : ""),od->exceptions); - - if (tracing) - { - prcode(fp, -" sipTrace(SIP_TRACE_CATCHERS,\""); - - generateBaseType(&od->cppsig->result,fp); - prcode(fp," sip%C::%O(",classFQCName(cd),od); - generateArgs(od->cppsig,Declaration,fp); - prcode(fp,")%s%X (this=0x%%08x)\\n\",this);\n" -"\n" - ,(isConst(od) ? " const" : ""),od->exceptions); - } - - restoreArgs(od->cppsig); - - if (vhd->module == pt->module) - { - prcode(fp, -" extern "); - - generateBaseType(&od->cppsig->result,fp); - - prcode(fp," sipVH_%s_%d(sip_gilstate_t,PyObject *",vhd->module->name,vhd->virthandlernr); - } - else - { - prcode(fp, -" typedef "); - - generateBaseType(&od->cppsig->result,fp); - - prcode(fp," (*sipVH_%s_%d)(sip_gilstate_t,PyObject *",vhd->module->name,vhd->virthandlernr); - } - - if (vhd->cppsig->nrArgs > 0) - { - prcode(fp,","); - generateArgs(vhd->cppsig,Declaration,fp); - } - - prcode(fp,");\n" - ); - - if (isNewThread(od)) - prcode(fp, -"\n" -" SIP_BLOCK_THREADS\n" - ); - - prcode(fp, -"\n" -" sip_gilstate_t sipGILState;\n" -" PyObject *meth;\n" -"\n" -" meth = sipIsPyMethod(&sipGILState,"); - - if (isConst(od)) - prcode(fp,"const_cast<sipMethodCache *>("); - - prcode(fp,"&sipPyMethods[%d]",virtNr); - - if (isConst(od)) - prcode(fp,")"); - - prcode(fp,",sipPySelf,"); - - if (isAbstract(od)) - prcode(fp,"%N",cd->iff->name); - else - prcode(fp,"NULL"); - - prcode(fp,",%N);\n" -"\n" - ,od->common->pyname); - - if (isNewThread(od)) - prcode(fp, -" if (meth)\n" -" {\n" -" sipStartThread();\n" -" "); - else - { - prcode(fp, -" if (!meth)\n" - ); - - if (isAbstract(od)) - generateVirtHandlerErrorReturn(res,fp); - else - { - if (res == NULL) - prcode(fp, -" {\n" -" "); - else - prcode(fp, -" return "); - - generateUnambiguousClass(cd,vod->scope,fp); - - prcode(fp,"::%O(",od); - - for (a = 0; a < od->cppsig->nrArgs; ++a) - prcode(fp,"%sa%d",(a == 0 ? "" : ","),a); - - prcode(fp,");\n" - ); - - if (res == NULL) - prcode(fp, -" return;\n" -" }\n" - ); - } - - prcode(fp, -"\n" -" "); - - if (res != NULL) - prcode(fp,"return "); - } - - if (vhd->module == pt->module) - prcode(fp,"sipVH_%s_%d",vhd->module->name,vhd->virthandlernr); - else - prcode(fp,"((sipVH_%s_%d)(sipModuleAPI_%s_%s->em_virthandlers[%d]))",vhd->module->name,vhd->virthandlernr,pt->module->name,vhd->module->name,vhd->virthandlernr); - - prcode(fp,"(sipGILState,meth"); - - ad = od->cppsig->args; - - for (a = 0; a < od->cppsig->nrArgs; ++a) - { - if (ad->atype == class_type && isProtectedClass(ad->u.cd)) - prcode(fp,",static_cast<%U *>(a%d)",ad->u.cd,a); - else if (ad->atype == enum_type && isProtectedEnum(ad->u.ed)) - prcode(fp, ",(%E)a%d", ad->u.ed, a); - else - prcode(fp,",a%d",a); - - ++ad; - } - - prcode(fp,");\n" - ); - - if (isNewThread(od)) - prcode(fp, -" sipEndThread();\n" -" }\n" -"\n" -" SIP_UNBLOCK_THREADS\n" - ); - - prcode(fp, -"}\n" - ); -} - - -/* - * Generate the scope of the near class of a virtual taking duplicate - * super-classes into account. - */ -static void generateUnambiguousClass(classDef *cd,classDef *scope,FILE *fp) -{ - mroDef *mro; - - /* See if the near class has a duplicate. */ - for (mro = cd->mro; mro != NULL; mro = mro->next) - if (mro->cd == scope) - { - if (hasDuplicateSuper(mro)) - { - mroDef *guardc; - - /* - * Backtrack to find the class that directly - * sub-classes the duplicated one. This will - * be the one that disambiguates the duplicated - * one. - */ - guardc = mro; - - while (guardc != cd->mro) - { - mroDef *sub; - classList *cl; - - for (sub = cd->mro; sub->next != guardc; sub = sub->next) - ; - - for (cl = sub->cd->supers; cl != NULL; cl = cl->next) - if (cl->cd == mro->cd) - { - prcode(fp,"%S",classFQCName(sub->cd)); - - return; - } - - /* Try the previous one. */ - guardc = sub; - } - } - - break; - } - - /* If we got here there is nothing to worry about. */ - prcode(fp,"%S",classFQCName(scope)); -} - - -/* - * Generate a cast to zero. - */ -static void generateCastZero(argDef *ad,FILE *fp) -{ - if (ad->atype == enum_type) - prcode(fp,"(%E)",ad->u.ed); - - prcode(fp,"0"); -} - - -/* - * Generate the return statement for a virtual handler when there has been an - * error (ie. there is nothing sensible to return). - */ -static void generateVirtHandlerErrorReturn(argDef *res,FILE *fp) -{ - prcode(fp, -" return"); - - if (res == NULL) - { - prcode(fp,";\n" - ); - - return; - } - - prcode(fp," "); - - if (res->atype == mapped_type && res->nrderefs == 0) - { - argDef res_noconstref; - - /* - * We don't know anything about the mapped type so we just hope - * is has a default ctor. - */ - - if (isReference(res)) - prcode(fp,"*new "); - - res_noconstref = *res; - resetIsConstArg(&res_noconstref); - resetIsReference(&res_noconstref); - prcode(fp,"%B()",&res_noconstref); - } - else if (res->atype == class_type && res->nrderefs == 0) - { - ctorDef *ct = res->u.cd->defctor; - - /* - * If we don't have a suitable ctor then the generated code - * will issue an error message. - */ - if (ct != NULL && isPublicCtor(ct) && ct->cppsig != NULL) - { - argDef res_noconstref; - - /* - * If this is a badly designed class. We can only - * generate correct code by leaking memory. - */ - if (isReference(res)) - prcode(fp,"*new "); - - res_noconstref = *res; - resetIsConstArg(&res_noconstref); - resetIsReference(&res_noconstref); - prcode(fp,"%B",&res_noconstref); - - generateCallDefaultCtor(ct,fp); - } - else - { - fatalScopedName(classFQCName(res->u.cd)); - fatal(" must have a default constructor\n"); - } - } - else - generateCastZero(res,fp); - - prcode(fp,";\n" - ); -} - - -/* - * Generate the call to a default ctor. - */ -static void generateCallDefaultCtor(ctorDef *ct, FILE *fp) -{ - int a; - - prcode(fp, "("); - - for (a = 0; a < ct->cppsig->nrArgs; ++a) - { - argDef *ad = &ct->cppsig->args[a]; - - if (ad->defval != NULL) - break; - - if (a > 0) - prcode(fp, ","); - - /* - * Do what we can to provide type information to the compiler. - */ - if (ad->atype == class_type && ad->nrderefs > 0 && !isReference(ad)) - prcode(fp, "static_cast<%B>(0)", ad); - else if (ad->atype == enum_type) - prcode(fp, "static_cast<%E>(0)", ad->u.ed); - else if (ad->atype == float_type || ad->atype == cfloat_type) - prcode(fp, "0.0F"); - else if (ad->atype == double_type || ad->atype == cdouble_type) - prcode(fp, "0.0"); - else if (ad->atype == uint_type) - prcode(fp, "0U"); - else if (ad->atype == long_type || ad->atype == longlong_type) - prcode(fp, "0L"); - else if (ad->atype == ulong_type || ad->atype == ulonglong_type) - prcode(fp, "0UL"); - else if ((ad->atype == ustring_type || ad->atype == sstring_type || ad->atype == string_type) && ad->nrderefs == 0) - prcode(fp, "'\\0'"); - else if (ad->atype == wstring_type && ad->nrderefs == 0) - prcode(fp, "L'\\0'"); - else - prcode(fp, "0"); - } - - prcode(fp, ")"); -} - - -/* - * Generate the emitter function for a signal. - */ -static void generateEmitter(sipSpec *pt,classDef *cd,visibleList *vl,FILE *fp) -{ - char *pname = vl->m->pyname->text; - overDef *od; - - prcode(fp, -"\n" -"int sip%C::sipEmit_%s(PyObject *sipArgs)\n" -"{\n" -" int sipArgsParsed = 0;\n" - ,classFQCName(cd),pname); - - for (od = vl->cd->overs; od != NULL; od = od->next) - { - int rgil = ((release_gil || isReleaseGIL(od)) && !isHoldGIL(od)); - - if (od->common != vl->m || !isSignal(od)) - continue; - - /* - * Generate the code that parses the args and emits the - * appropriate overloaded signal. - */ - prcode(fp, -"\n" -" {\n" - ); - - generateArgParser(pt, &od->pysig, cd, NULL, NULL, FALSE, fp); - - prcode(fp, -" {\n" - ); - - if (rgil) - prcode(fp, -" Py_BEGIN_ALLOW_THREADS\n" - ); - - prcode(fp, -" emit %s(" - ,od->cppname); - - generateArgs(od->cppsig,Call,fp); - - prcode(fp,");\n" - ); - - if (rgil) - prcode(fp, -" Py_END_ALLOW_THREADS\n" - ); - - deleteTemps(&od->pysig, fp); - - prcode(fp, -"\n" -" return 0;\n" -" }\n" -" }\n" - ); - } - - prcode(fp, -"\n" -" sipNoMethod(sipArgsParsed,%N,%N);\n" -"\n" -" return -1;\n" -"}\n" -"\n" - , cd->iff->name, vl->m->pyname); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static int %C_emit_%s(sipWrapper *, PyObject *);}\n" - , classFQCName(cd), pname); - - prcode(fp, -"static int %C_emit_%s(sipWrapper *w,PyObject *sipArgs)\n" -"{\n" -" sip%C *ptr = reinterpret_cast<sip%C *>(sipGetComplexCppPtr(w));\n" -"\n" -" return (ptr ? ptr->sipEmit_%s(sipArgs) : -1);\n" -"}\n" - ,classFQCName(cd),pname - ,classFQCName(cd),classFQCName(cd) - ,pname); -} - - -/* - * Generate the declarations of the protected wrapper functions for a class. - */ - -static void generateProtectedDeclarations(classDef *cd,FILE *fp) -{ - int noIntro; - visibleList *vl; - - noIntro = TRUE; - - for (vl = cd->visible; vl != NULL; vl = vl->next) - { - overDef *od; - - if (vl->m->slot != no_slot) - continue; - - for (od = vl->cd->overs; od != NULL; od = od->next) - { - if (od->common != vl->m || !isProtected(od)) - continue; - - if (noIntro) - { - prcode(fp, -"\n" -" /*\n" -" * There is a public method for every protected method visible from\n" -" * this class.\n" -" */\n" - ); - - noIntro = FALSE; - } - - prcode(fp, -" "); - - if (isStatic(od)) - prcode(fp,"static "); - - generateBaseType(&od->cppsig->result,fp); - - if (!isStatic(od) && !isAbstract(od) && (isVirtual(od) || isVirtualReimp(od))) - { - prcode(fp, " sipProtectVirt_%s(bool", od->cppname); - - if (od->cppsig->nrArgs > 0) - prcode(fp, ","); - } - else - prcode(fp, " sipProtect_%s(", od->cppname); - - generateArgs(od->cppsig,Declaration,fp); - prcode(fp,")%s;\n" - ,(isConst(od) ? " const" : "")); - } - } -} - - -/* - * Generate the definitions of the protected wrapper functions for a class. - */ -static void generateProtectedDefinitions(classDef *cd,FILE *fp) -{ - visibleList *vl; - - for (vl = cd->visible; vl != NULL; vl = vl->next) - { - overDef *od; - - if (vl->m->slot != no_slot) - continue; - - for (od = vl->cd->overs; od != NULL; od = od->next) - { - char *mname = od->cppname; - int parens; - argDef *res; - - if (od->common != vl->m || !isProtected(od)) - continue; - - prcode(fp, -"\n" - ); - - generateBaseType(&od->cppsig->result,fp); - - if (!isStatic(od) && !isAbstract(od) && (isVirtual(od) || isVirtualReimp(od))) - { - prcode(fp, " sip%C::sipProtectVirt_%s(bool sipSelfWasArg", classFQCName(cd), mname); - - if (od->cppsig->nrArgs > 0) - prcode(fp, ","); - } - else - prcode(fp, " sip%C::sipProtect_%s(", classFQCName(cd), mname); - - generateArgs(od->cppsig,Definition,fp); - prcode(fp,")%s\n" -"{\n" - ,(isConst(od) ? " const" : "")); - - parens = 1; - - res = &od->cppsig->result; - - if (res->atype == void_type && res->nrderefs == 0) - prcode(fp, -" "); - else - { - prcode(fp, -" return "); - - if (res->atype == class_type && isProtectedClass(res->u.cd)) - { - prcode(fp,"static_cast<%U *>(",res->u.cd); - ++parens; - } - else if (res->atype == enum_type && isProtectedEnum(res->u.ed)) - /* - * One or two older compilers can't - * handle a static_cast here so we - * revert to a C-style cast. - */ - prcode(fp,"(%E)",res->u.ed); - } - - if (!isAbstract(od)) - if (isVirtual(od) || isVirtualReimp(od)) - { - prcode(fp, "(sipSelfWasArg ? %S::%s(", classFQCName(vl->cd), mname); - - generateProtectedCallArgs(od, fp); - - prcode(fp, ") : "); - ++parens; - } - else - prcode(fp, "%S::", classFQCName(vl->cd)); - - prcode(fp,"%s(",mname); - - generateProtectedCallArgs(od, fp); - - while (parens--) - prcode(fp,")"); - - prcode(fp,";\n" -"}\n" - ); - } - } -} - - -/* - * Generate the arguments for a call to a protected method. - */ -static void generateProtectedCallArgs(overDef *od, FILE *fp) -{ - int a; - - for (a = 0; a < od->cppsig->nrArgs; ++a) - { - argDef *ad = &od->cppsig->args[a]; - - if (a > 0) - prcode(fp, ","); - - if (ad->atype == enum_type && isProtectedEnum(ad->u.ed)) - prcode(fp, "(%S)", ad->u.ed->fqcname); - - prcode(fp, "a%d", a); - } -} - - -/* - * Generate the function that does most of the work to handle a particular - * virtual function. - */ -static void generateVirtualHandler(sipSpec *pt,virtHandlerDef *vhd,FILE *fp) -{ - int a, nrvals, copy, isref; - argDef *res, res_noconstref; - - res = &vhd->cppsig->result; - - copy = isref = FALSE; - - if (res->atype == void_type && res->nrderefs == 0) - res = NULL; - else - { - /* - * If we are returning a reference to an instance then we take care to - * handle Python errors but still return a valid C++ instance. If we - * are returning an instance then we take care to make a local copy of - * the instance returned from Python before the Python object is - * garbage collected and the C++ instance (possibly) destroyed. - */ - if ((res->atype == class_type || res->atype == mapped_type) && res->nrderefs == 0) - if (isReference(res)) - isref = TRUE; - else - copy = TRUE; - - res_noconstref = *res; - resetIsConstArg(&res_noconstref); - resetIsReference(&res_noconstref); - } - - prcode(fp, -"\n" - ); - - generateBaseType(&vhd->cppsig->result, fp); - - prcode(fp," sipVH_%s_%d(sip_gilstate_t sipGILState,PyObject *sipMethod" - ,pt->module->name,vhd->virthandlernr); - - if (vhd->cppsig->nrArgs > 0) - { - prcode(fp,","); - - generateArgs(vhd->cppsig, Definition, fp); - } - - prcode(fp,")\n" -"{\n" - ); - - if (res != NULL) - { - prcode(fp, " "); - - /* - * wchar_t * return values are always on the heap. To reduce memory - * leaks we keep the last result around until we have a new one. This - * means that ownership of the return value stays with the function - * returning it - which is consistent with how other types work, even - * thought it may not be what's required in all cases. - */ - if (res->atype == wstring_type && res->nrderefs == 1) - prcode(fp, "static "); - - generateBaseType(&res_noconstref,fp); - - prcode(fp," %ssipRes",(isref ? "*" : "")); - - if (copy && res->atype == class_type && res->nrderefs == 0) - { - ctorDef *ct = res->u.cd->defctor; - - if (ct != NULL && isPublicCtor(ct) && ct->cppsig != NULL && ct->cppsig->nrArgs > 0 && ct->cppsig->args[0].defval == NULL) - generateCallDefaultCtor(ct,fp); - } - else if (!copy) - { - /* - * We initialise the result to try and suppress a - * compiler warning. - */ - prcode(fp," = "); - generateCastZero(res,fp); - } - - prcode(fp,";\n" - ); - - if (res->atype == wstring_type && res->nrderefs == 1) - prcode(fp, -"\n" -" if (sipRes)\n" -" {\n" -" // Return any previous result to the heap.\n" -" sipFree(%s);\n" -" sipRes = 0;\n" -" }\n" -"\n" - , (isConstArg(res) ? "const_cast<wchar_t *>(sipRes)" : "sipRes")); - } - - if (vhd->virtcode != NULL) - { - int error_flag = needErrorFlag(vhd->virtcode); - - if (error_flag) - prcode(fp, -" int sipIsErr = 0;\n" - ); - - prcode(fp, -"\n" - ); - - generateCppCodeBlock(vhd->virtcode,fp); - - if (error_flag) - prcode(fp, -"\n" -" if (sipIsErr)\n" -" PyErr_Print();\n" - ); - - prcode(fp, -"\n" -" Py_DECREF(sipMethod);\n" -"\n" -" SIP_RELEASE_GIL(sipGILState)\n" - ); - - if (res != NULL) - prcode(fp, -"\n" -" return sipRes;\n" - ); - - prcode(fp, -"}\n" - ); - - return; - } - - /* See how many values we expect. */ - nrvals = (res != NULL ? 1 : 0); - - for (a = 0; a < vhd->pysig->nrArgs; ++a) - if (isOutArg(&vhd->pysig->args[a])) - ++nrvals; - - if (copy) - { - prcode(fp, -" "); - - generateBaseType(&res_noconstref,fp); - - prcode(fp," *sipResOrig;\n"); - - if (res->atype == class_type && res->u.cd->convtocode != NULL) - prcode(fp, -" int sipResState;\n" - ); - } - - /* Call the method. */ - prcode(fp, -" PyObject *sipResObj = sipCallMethod(0,sipMethod,"); - - generateTupleBuilder(vhd->pysig, fp); - - prcode(fp,");\n" -"\n" -" %s (!sipResObj || sipParseResult(0,sipMethod,sipResObj,\"",(isref ? "int sipIsErr =" : "if")); - - /* Build the format string. */ - if (nrvals == 0) - prcode(fp,"Z"); - else - { - if (nrvals > 1) - prcode(fp,"("); - - if (res != NULL) - prcode(fp, "%s", getParseResultFormat(res, TRUE, isTransferVH(vhd))); - - for (a = 0; a < vhd->pysig->nrArgs; ++a) - { - argDef *ad = &vhd->pysig->args[a]; - - if (isOutArg(ad)) - prcode(fp, "%s", getParseResultFormat(ad, FALSE, FALSE)); - } - - if (nrvals > 1) - prcode(fp,")"); - } - - prcode(fp,"\""); - - /* Pass the destination pointers. */ - if (res != NULL) - { - generateParseResultExtraArgs(res, TRUE, fp); - prcode(fp,",&sipRes%s",(copy ? "Orig" : "")); - } - - for (a = 0; a < vhd->pysig->nrArgs; ++a) - { - argDef *ad = &vhd->pysig->args[a]; - - if (isOutArg(ad)) - { - generateParseResultExtraArgs(ad, FALSE, fp); - prcode(fp,",%sa%d",(isReference(ad) ? "&" : ""),a); - } - } - - if (isref) - prcode(fp,") < 0);\n" -"\n" -" if (sipIsErr)\n" - ); - else - prcode(fp,") < 0)\n" - ); - - prcode(fp, -" PyErr_Print();\n" - ); - - /* Make a copy if needed. */ - if (copy) - { - prcode(fp, -" else\n" -" {\n" -" sipRes = *sipResOrig;\n" - ); - - if (res->atype == mapped_type) - prcode(fp, -" delete sipResOrig;\n" - ); - else if (res->atype == class_type && res->u.cd->convtocode != NULL) - prcode(fp, -" sipReleaseInstance(sipResOrig,sipClass_%C,sipResState);\n" - , classFQCName(res->u.cd)); - - prcode(fp, -" }\n" - ); - } - - prcode(fp, -"\n" -" Py_XDECREF(sipResObj);\n" -" Py_DECREF(sipMethod);\n" -"\n" -" SIP_RELEASE_GIL(sipGILState)\n" - ); - - if (res != NULL) - { - if (isref) - { - prcode(fp, -"\n" -" if (sipIsErr)\n" - ); - - generateVirtHandlerErrorReturn(res,fp); - } - - prcode(fp, -"\n" -" return %ssipRes;\n" - ,(isref ? "*" : "")); - } - - prcode(fp, -"}\n" - ); -} - - -/* - * Generate the extra arguments needed by sipParseResult() for a particular - * type. - */ -static void generateParseResultExtraArgs(argDef *ad, int isres, FILE *fp) -{ - switch (ad->atype) - { - case mapped_type: - prcode(fp, ",sipMappedType_%T", ad); - break; - - case class_type: - prcode(fp, ",sipClass_%C", classFQCName(ad->u.cd)); - - if (isres && ad->nrderefs == 0 && ad->u.cd->convtocode != NULL && !isReference(ad)) - prcode(fp, ",&sipResState"); - - break; - - case pytuple_type: - prcode(fp,",&PyTuple_Type"); - break; - - case pylist_type: - prcode(fp,",&PyList_Type"); - break; - - case pydict_type: - prcode(fp,",&PyDict_Type"); - break; - - case pyslice_type: - prcode(fp,",&PySlice_Type"); - break; - - case pytype_type: - prcode(fp,",&PyType_Type"); - break; - - case enum_type: - if (ad->u.ed->fqcname != NULL) - prcode(fp,",sipEnum_%C",ad->u.ed->fqcname); - break; - } -} - - -/* - * Return the format characters used by sipParseResult() for a particular type. - */ -static const char *getParseResultFormat(argDef *ad, int isres, int xfervh) -{ - switch (ad->atype) - { - case mapped_type: - { - static const char *s[] = { - "D0", "D1", "D2", "D3", - "D4", "D5", "D6", "D7" - }; - - int f = 0x04; - - if (isres && ad->nrderefs == 0) - f |= 0x01; - - if (isres && xfervh) - f |= 0x02; - - return s[f]; - } - - case class_type: - { - static char s[] = "C?"; - - int f = 0x04; - - if (isres && ad->nrderefs == 0) - { - f |= 0x01; - - if (ad->u.cd->convtocode != NULL) - { - f &= ~0x04; - - /* - * If it is a reference then we are - * going to return the dereference. To - * make sure it remains valid we can - * either leak the temporary from the - * %ConvertToCode or we can suppress - * the %ConvertToCode. We choose the - * latter. - */ - if (isReference(ad)) - f |= 0x10; - } - } - - if (isres && xfervh) - f |= 0x02; - - s[1] = '0' + f; - - return s; - } - - case bool_type: - case cbool_type: - return "b"; - - case sstring_type: - case ustring_type: - case string_type: - return ((ad->nrderefs == 0) ? "c" : "s"); - - case wstring_type: - return ((ad->nrderefs == 0) ? "w" : "x"); - - case enum_type: - return ((ad->u.ed->fqcname != NULL) ? "E" : "e"); - - case ushort_type: - return "t"; - - case short_type: - return "h"; - - case int_type: - case cint_type: - return "i"; - - case uint_type: - return "u"; - - case long_type: - return "l"; - - case ulong_type: - return "m"; - - case longlong_type: - return "n"; - - case ulonglong_type: - return "o"; - - case void_type: - case struct_type: - return "V"; - - case float_type: - case cfloat_type: - return "f"; - - case double_type: - case cdouble_type: - return "d"; - - case pyobject_type: - return "O"; - - case pytuple_type: - case pylist_type: - case pydict_type: - case pyslice_type: - case pytype_type: - return (isAllowNone(ad) ? "N" : "T"); - } - - /* We should never get here. */ - return " "; -} - - -/* - * Generate the code to build a tuple of Python arguments. - */ -static void generateTupleBuilder(signatureDef *sd,FILE *fp) -{ - int a, arraylenarg; - - prcode(fp,"\""); - - for (a = 0; a < sd->nrArgs; ++a) - { - char *fmt = ""; - argDef *ad = &sd->args[a]; - - if (!isInArg(ad)) - continue; - - switch (ad->atype) - { - case sstring_type: - case ustring_type: - case string_type: - if (ad->nrderefs == 0 || (ad->nrderefs == 1 && isOutArg(ad))) - fmt = "c"; - else if (isArray(ad)) - fmt = "a"; - else - fmt = "s"; - - break; - - case wstring_type: - if (ad->nrderefs == 0 || (ad->nrderefs == 1 && isOutArg(ad))) - fmt = "w"; - else if (isArray(ad)) - fmt = "A"; - else - fmt = "x"; - - break; - - case bool_type: - case cbool_type: - fmt = "b"; - break; - - case enum_type: - fmt = (ad->u.ed->fqcname != NULL) ? "E" : "e"; - break; - - case cint_type: - fmt = "i"; - break; - - case uint_type: - if (isArraySize(ad)) - arraylenarg = a; - else - fmt = "u"; - - break; - - case int_type: - if (isArraySize(ad)) - arraylenarg = a; - else - fmt = "i"; - - break; - - case ushort_type: - if (isArraySize(ad)) - arraylenarg = a; - else - fmt = "t"; - - break; - - case short_type: - if (isArraySize(ad)) - arraylenarg = a; - else - fmt = "h"; - - break; - - case long_type: - if (isArraySize(ad)) - arraylenarg = a; - else - fmt = "l"; - - break; - - case ulong_type: - if (isArraySize(ad)) - arraylenarg = a; - else - fmt = "m"; - - break; - - case longlong_type: - if (isArraySize(ad)) - arraylenarg = a; - else - fmt = "n"; - - break; - - case ulonglong_type: - if (isArraySize(ad)) - arraylenarg = a; - else - fmt = "o"; - - break; - - case struct_type: - case void_type: - fmt = "V"; - break; - - case float_type: - case cfloat_type: - fmt = "f"; - break; - - case double_type: - case cdouble_type: - fmt = "d"; - break; - - case signal_type: - case slot_type: - case slotcon_type: - case slotdis_type: - fmt = "s"; - break; - - case mapped_type: - fmt = "D"; - break; - - case class_type: - fmt = "C"; - break; - - case rxcon_type: - case rxdis_type: - case qobject_type: - fmt = "O"; - break; - - case pyobject_type: - case pytuple_type: - case pylist_type: - case pydict_type: - case pycallable_type: - case pyslice_type: - case pytype_type: - fmt = "S"; - break; - } - - prcode(fp,fmt); - } - - prcode(fp,"\""); - - for (a = 0; a < sd->nrArgs; ++a) - { - int derefs; - argDef *ad = &sd->args[a]; - - if (!isInArg(ad)) - continue; - - derefs = ad->nrderefs; - - switch (ad->atype) - { - case sstring_type: - case ustring_type: - case string_type: - case wstring_type: - if (!(ad->nrderefs == 0 || (ad->nrderefs == 1 && isOutArg(ad)))) - --derefs; - - break; - - case mapped_type: - case class_type: - if (ad->nrderefs > 0) - --derefs; - - break; - - case struct_type: - case void_type: - --derefs; - break; - } - - if (ad->atype == mapped_type || ad->atype == class_type || - ad->atype == rxcon_type || ad->atype == rxdis_type || - ad->atype == qobject_type) - { - prcode(fp,","); - - if (isConstArg(ad)) - prcode(fp,"const_cast<%b *>(",ad); - - if (ad->nrderefs == 0) - prcode(fp,"&"); - else - while (derefs-- != 0) - prcode(fp,"*"); - - prcode(fp,"a%d",a); - - if (isConstArg(ad)) - prcode(fp,")"); - - if (ad->atype == mapped_type) - prcode(fp, ",sipMappedType_%T,NULL", ad); - else if (ad->atype == class_type) - prcode(fp, ",sipClass_%C,NULL", classFQCName(ad->u.cd)); - else - prcode(fp,",sipClass_QObject"); - } - else - { - if (!isArraySize(ad)) - { - prcode(fp,","); - - while (derefs-- != 0) - prcode(fp,"*"); - - prcode(fp,"a%d",a); - } - - if (isArray(ad)) - { - argType astype = sd->args[arraylenarg].atype; - - prcode(fp,",%sa%d",(astype == int_type ? "" : "(int)"),arraylenarg); - } - else if (ad->atype == enum_type && ad->u.ed->fqcname != NULL) - prcode(fp,",sipEnum_%C",ad->u.ed->fqcname); - } - } -} - - -/* - * Generate the class interface #include directives required by either a class - * or a module. - */ -static void generateUsedIncludes(ifaceFileList *iffl, int header, FILE *fp) -{ - int newl = TRUE; - - while (iffl != NULL) - { - if (header == iffl->header) - { - if (newl) - { - prcode(fp, -"\n" - ); - - newl = FALSE; - } - - prcode(fp, -"#include \"sip%s%F.h\"\n" - , iffl->iff->module->name, iffl->iff->fqcname); - } - - iffl = iffl->next; - } - - if (!newl) - prcode(fp, -"\n" - ); -} - - -/* - * Generate the header file for the C++ interface. - */ -static void generateIfaceHeader(sipSpec *pt,ifaceFileDef *iff,char *codeDir) -{ - char *wfile; - char *cmname = iff->module->name; - classDef *cd; - mappedTypeDef *mtd; - exceptionDef *xd; - int genused; - FILE *fp; - - /* Create the header file. */ - - wfile = createIfaceFileName(codeDir,iff,".h"); - fp = createFile(pt,wfile,"Interface header file."); - - prcode(fp, -"\n" -"#ifndef _%s%F_h\n" -"#define _%s%F_h\n" -"\n" - ,cmname,iff->fqcname,cmname,iff->fqcname); - - genused = TRUE; - - for (cd = pt->classes; cd != NULL; cd = cd->next) - if (cd->iff == iff) - { - if (iff->module == pt->module) - generateClassHeader(cd,genused,pt,fp); - else if (!isExternal(cd)) - generateImportedClassHeader(cd,pt,fp); - - genused = FALSE; - } - - genused = TRUE; - - for (mtd = pt->mappedtypes; mtd != NULL; mtd = mtd->next) - if (mtd->iff == iff) - { - if (iff->module == pt->module) - generateMappedTypeHeader(mtd,genused,fp); - else - generateImportedMappedTypeHeader(mtd,pt,fp); - - genused = FALSE; - } - - for (xd = pt->exceptions; xd != NULL; xd = xd->next) - if (xd->iff == iff) - { - generateCppCodeBlock(xd->hdrcode,fp); - - if (xd->exceptionnr >= 0) - { - prcode(fp, -"\n" -"#define sipException_%C sipModuleAPI_%s" - ,iff->fqcname,pt->module->name); - - if (iff->module == pt->module) - prcode(fp,"."); - else - prcode(fp,"_%s->",iff->module->name); - - prcode(fp,"em_exceptions[%d]\n" - ,xd->exceptionnr); - } - } - - prcode(fp, -"\n" -"#endif\n" - ); - - closeFile(fp); - free(wfile); -} - - -/* - * Generate the C++ header code for an imported mapped type. - */ -static void generateImportedMappedTypeHeader(mappedTypeDef *mtd,sipSpec *pt, - FILE *fp) -{ - char *mname = pt->module->name; - char *imname = mtd->iff->module->name; - argDef type; - - generateCppCodeBlock(mtd->hdrcode,fp); - - type.atype = mapped_type; - type.u.mtd = mtd; - type.argflags = 0; - type.name = NULL; - type.nrderefs = 0; - type.defval = NULL; - - prcode(fp, -"\n" -"#define sipMappedType_%T sipModuleAPI_%s_%s->em_mappedtypes[%d]\n" -"#define sipForceConvertTo_%T sipModuleAPI_%s_%s->em_mappedtypes[%d]->mt_fcto\n" -"#define sipConvertFrom_%T sipModuleAPI_%s_%s->em_mappedtypes[%d]->mt_cfrom\n" - ,&type,mname,imname,mtd->mappednr - ,&type,mname,imname,mtd->mappednr - ,&type,mname,imname,mtd->mappednr); -} - - -/* - * Generate the C++ header code for a generated mapped type. - */ -static void generateMappedTypeHeader(mappedTypeDef *mtd,int genused,FILE *fp) -{ - prcode(fp, -"\n" -"\n" - ); - - generateCppCodeBlock(mtd->hdrcode,fp); - - if (genused) - generateUsedIncludes(mtd->iff->used, TRUE, fp); - - prcode(fp, -"\n" -"#define sipMappedType_%T &sipMappedTypeDef_%T\n" -"#define sipForceConvertTo_%T sipMappedTypeDef_%T.mt_fcto\n" -"#define sipConvertFrom_%T sipMappedTypeDef_%T.mt_cfrom\n" -"\n" -"extern sipMappedType sipMappedTypeDef_%T;\n" - ,&mtd->type,&mtd->type - ,&mtd->type,&mtd->type - ,&mtd->type,&mtd->type - ,&mtd->type); -} - - -/* - * Generate the C++ header code for an imported class. - */ -static void generateImportedClassHeader(classDef *cd,sipSpec *pt,FILE *fp) -{ - char *mname = pt->module->name; - char *imname = cd->iff->module->name; - classDef *hcd; - - for (hcd = cd; hcd != NULL; hcd = hcd->ecd) - generateCppCodeBlock(hcd->hdrcode,fp); - - prcode(fp, -"\n" -"#define sipClass_%C sipModuleAPI_%s_%s->em_types[%d]\n" -"#define sipCast_%C sipModuleAPI_%s_%s->em_types[%d]->type->td_cast\n" -"#define sipForceConvertTo_%C sipModuleAPI_%s_%s->em_types[%d]->type->td_fcto\n" - ,classFQCName(cd),mname,imname,cd->classnr - ,classFQCName(cd),mname,imname,cd->classnr - ,classFQCName(cd),mname,imname,cd->classnr); - - generateEnumMacros(pt, cd, fp); -} - - -/* - * Generate the C++ header code for a generated class. - */ -static void generateClassHeader(classDef *cd,int genused,sipSpec *pt,FILE *fp) -{ - char *mname = pt->module->name; - classDef *hcd; - - for (hcd = cd; hcd != NULL; hcd = hcd->ecd) - generateCppCodeBlock(hcd->hdrcode,fp); - - if (genused) - generateUsedIncludes(cd->iff->used, TRUE, fp); - - if (cd->iff->type != namespace_iface) - { - prcode(fp, -"\n" -"#define sipClass_%C sipModuleAPI_%s.em_types[%d]\n" - ,classFQCName(cd),mname,cd->classnr); - - if (!isExternal(cd)) - prcode(fp, -"#define sipCast_%C sipType_%s_%C.td_cast\n" -"#define sipForceConvertTo_%C sipType_%s_%C.td_fcto\n" - , classFQCName(cd), mname, classFQCName(cd) - , classFQCName(cd), mname, classFQCName(cd)); - } - - generateEnumMacros(pt, cd, fp); - - if (!isExternal(cd)) - prcode(fp, -"\n" -"extern sipTypeDef sipType_%s_%C;\n" - , mname, classFQCName(cd)); - - if (hasShadow(cd)) - generateShadowClassDeclaration(pt,cd,fp); -} - - -/* - * Generate the sipEnum_* macros. - */ -static void generateEnumMacros(sipSpec *pt, classDef *cd, FILE *fp) -{ - enumDef *ed; - int noIntro = TRUE; - - for (ed = pt->enums; ed != NULL; ed = ed->next) - { - if (ed->fqcname == NULL || ed->ecd != cd) - continue; - - if (noIntro) - { - prcode(fp, -"\n" - ); - - noIntro = FALSE; - } - - prcode(fp, -"#define sipEnum_%C sipModuleAPI_%s", ed->fqcname, pt->module->name); - - if (pt->module == ed->module) - prcode(fp, "."); - else - prcode(fp, "_%s->", ed->module->name); - - prcode(fp, "em_enums[%d]\n" - , ed->enumnr); - } -} - - -/* - * Generate the shadow class declaration. - */ -static void generateShadowClassDeclaration(sipSpec *pt,classDef *cd,FILE *fp) -{ - int noIntro, nrVirts; - ctorDef *ct; - virtOverDef *vod; - classDef *pcd; - - prcode(fp, -"\n" -"\n" -"class sip%C : public %S\n" -"{\n" -"public:\n" - ,classFQCName(cd),classFQCName(cd)); - - /* Define a shadow class for any protected classes we have. */ - - for (pcd = pt->classes; pcd != NULL; pcd = pcd->next) - { - if (pcd->ecd != cd || !isProtectedClass(pcd)) - continue; - - prcode(fp, -" class sip%s : public %s {};\n" - ,classBaseName(pcd),classBaseName(pcd)); - } - - /* The constructor declarations. */ - - for (ct = cd->ctors; ct != NULL; ct = ct->next) - { - ctorDef *dct; - - if (isPrivateCtor(ct)) - continue; - - if (ct->cppsig == NULL) - continue; - - /* Check we haven't already handled this C++ signature. */ - for (dct = cd->ctors; dct != ct; dct = dct->next) - if (dct->cppsig != NULL && sameSignature(dct->cppsig, ct->cppsig, TRUE)) - break; - - if (dct != ct) - continue; - - prcode(fp, -" sip%C(",classFQCName(cd)); - - generateArgs(ct->cppsig,Declaration,fp); - - prcode(fp,")%X;\n" - ,ct->exceptions); - } - - /* The destructor. */ - - if (!isPrivateDtor(cd)) - prcode(fp, -" %s~sip%C()%X;\n" - ,(cd->vmembers != NULL ? "virtual " : ""),classFQCName(cd),cd->dtorexceptions); - - /* The metacall methods if required. */ - if (isQObjectSubClass(cd) && optQ_OBJECT4(pt)) - prcode(fp, -"\n" -" const TQMetaObject *metaObject() const;\n" -" int qt_metacall(TQMetaObject::Call,int,void **);\n" - ); - - /* The exposure of protected enums. */ - - generateProtectedEnums(pt,cd,fp); - - /* The wrapper around each protected member function. */ - - generateProtectedDeclarations(cd,fp); - - /* The public wrapper around each signal emitter. */ - if (!optNoEmitters(pt)) - { - visibleList *vl; - - noIntro = TRUE; - - for (vl = cd->visible; vl != NULL; vl = vl->next) - { - overDef *od; - - if (vl->m->slot != no_slot) - continue; - - for (od = vl->cd->overs; od != NULL; od = od->next) - { - if (od->common != vl->m || !isSignal(od)) - continue; - - if (noIntro) - { - prcode(fp, -"\n" -" /*\n" -" * There is a public method for every Qt signal that can be emitted\n" -" * by this object. This function is called by Python to emit the\n" -" * signal.\n" -" */\n" - ); - - noIntro = FALSE; - } - - prcode(fp, -" int sipEmit_%s(PyObject *);\n" - ,vl->m->pyname->text); - - break; - } - } - } - - /* The catcher around each virtual function in the hierarchy. */ - noIntro = TRUE; - - for (vod = cd->vmembers; vod != NULL; vod = vod->next) - { - overDef *od = &vod->o; - virtOverDef *dvod; - - if (isPrivate(od)) - continue; - - /* Check we haven't already handled this C++ signature. */ - for (dvod = cd->vmembers; dvod != vod; dvod = dvod->next) - if (strcmp(dvod->o.cppname,od->cppname) == 0 && sameSignature(dvod->o.cppsig,od->cppsig,TRUE)) - break; - - if (dvod != vod) - continue; - - if (noIntro) - { - prcode(fp, -"\n" -" /*\n" -" * There is a protected method for every virtual method visible from\n" -" * this class.\n" -" */\n" -"protected:\n" - ); - - noIntro = FALSE; - } - - prcode(fp, -" "); - - prOverloadDecl(fp, od, FALSE); - prcode(fp, ";\n"); - } - - prcode(fp, -"\n" -"public:\n" -" sipWrapper *sipPySelf;\n" - ); - - /* The private declarations. */ - - prcode(fp, -"\n" -"private:\n" -" sip%C(const sip%C &);\n" -" sip%C &operator = (const sip%C &);\n" - ,classFQCName(cd),classFQCName(cd) - ,classFQCName(cd),classFQCName(cd)); - - if ((nrVirts = countVirtuals(cd)) > 0) - prcode(fp, -"\n" -" sipMethodCache sipPyMethods[%d];\n" - ,nrVirts); - - prcode(fp, -"};\n" - ); -} - - -/* - * Generate the C++ declaration for an overload. - */ -void prOverloadDecl(FILE *fp, overDef *od, int defval) -{ - int a; - - normaliseArgs(od->cppsig); - - generateBaseType(&od->cppsig->result, fp); - - prcode(fp, " %O(", od); - - for (a = 0; a < od->cppsig->nrArgs; ++a) - { - argDef *ad = &od->cppsig->args[a]; - - if (a > 0) - prcode(fp, ","); - - generateBaseType(ad, fp); - - if (defval && ad->defval != NULL) - { - prcode(fp, " = "); - generateExpression(ad->defval, fp); - } - } - - prcode(fp, ")%s%X", (isConst(od) ? " const" : ""), od->exceptions); - - restoreArgs(od->cppsig); -} - - -/* - * Generate typed arguments. - */ -static void generateArgs(signatureDef *sd,funcArgType ftype,FILE *fp) -{ - int a; - - for (a = 0; a < sd->nrArgs; ++a) - { - if (a > 0) - prcode(fp,","); - - generateSingleArg(&sd->args[a],a,ftype,fp); - } -} - - -/* - * Generate the declaration of a named variable to hold a result from a C++ - * function call. - */ -static void generateNamedValueType(argDef *ad,char *name,FILE *fp) -{ - argDef mod = *ad; - - if (ad->nrderefs == 0) - if (ad->atype == class_type || ad->atype == mapped_type) - mod.nrderefs = 1; - else - resetIsConstArg(&mod); - - resetIsReference(&mod); - generateNamedBaseType(&mod,name,fp); -} - - -/* - * Generate a single argument. - */ -static void generateSingleArg(argDef *ad,int argnr,funcArgType ftype,FILE *fp) -{ - char name[50]; - int genType, genName, derefPtr; - - /* Break the type down to individual modifications. */ - - genType = FALSE; - genName = FALSE; - derefPtr = FALSE; - - switch (ftype) - { - case Call: - genName = TRUE; - derefPtr = TRUE; - break; - - case Declaration: - genType = TRUE; - break; - - case Definition: - genType = TRUE; - genName = TRUE; - break; - } - - if (genName) - { - char *ind = ""; - - if (derefPtr) - switch (ad->atype) - { - case sstring_type: - case ustring_type: - case string_type: - case wstring_type: - if (ad->nrderefs > (isOutArg(ad) ? 0 : 1)) - ind = "&"; - - break; - - case mapped_type: - case class_type: - if (ad->nrderefs == 2) - ind = "&"; - else if (ad->nrderefs == 0) - ind = "*"; - - break; - - case struct_type: - case void_type: - if (ad->nrderefs == 2) - ind = "&"; - - break; - - default: - if (ad->nrderefs == 1) - ind = "&"; - } - - sprintf(name,"%sa%d",ind,argnr); - } - else - name[0] = '\0'; - - if (genType) - generateNamedBaseType(ad,name,fp); - else if (genName) - prcode(fp,name); -} - - -/* - * Generate a C++ type. - */ -static void generateBaseType(argDef *ad,FILE *fp) -{ - generateNamedBaseType(ad,"",fp); -} - - -/* - * Generate a C++ type and name. - */ -static void generateNamedBaseType(argDef *ad,char *name,FILE *fp) -{ - int nr_derefs = ad->nrderefs; - - /* - * A function type is handled differently because of the position of - * the name. - */ - if (ad->atype == function_type) - { - int i; - signatureDef *sig = ad->u.sa; - - generateBaseType(&sig->result,fp); - - prcode(fp," ("); - - for (i = 0; i < nr_derefs; ++i) - prcode(fp,"*"); - - prcode(fp,"%s)(",name); - generateArgs(sig,Declaration,fp); - prcode(fp,")"); - - return; - } - - if (isConstArg(ad)) - prcode(fp,"const "); - - switch (ad->atype) - { - case sstring_type: - prcode(fp,"signed char"); - break; - - case ustring_type: - prcode(fp,"unsigned char"); - break; - - case wstring_type: - prcode(fp,"wchar_t"); - break; - - case signal_type: - case slot_type: - case anyslot_type: - case slotcon_type: - case slotdis_type: - nr_derefs = 1; - - /* Drop through. */ - - case string_type: - prcode(fp,"char"); - break; - - case ushort_type: - prcode(fp,"unsigned short"); - break; - - case short_type: - prcode(fp,"short"); - break; - - case uint_type: - prcode(fp,"unsigned"); - break; - - case int_type: - case cint_type: - prcode(fp,"int"); - break; - - case ulong_type: - prcode(fp,"unsigned long"); - break; - - case long_type: - prcode(fp,"long"); - break; - - case ulonglong_type: - prcode(fp,"unsigned PY_LONG_LONG"); - break; - - case longlong_type: - prcode(fp,"PY_LONG_LONG"); - break; - - case struct_type: - prcode(fp,"struct %S",ad->u.sname); - break; - - case void_type: - prcode(fp,"void"); - break; - - case bool_type: - case cbool_type: - prcode(fp,"bool"); - break; - - case float_type: - case cfloat_type: - prcode(fp,"float"); - break; - - case double_type: - case cdouble_type: - prcode(fp,"double"); - break; - - case defined_type: - /* - * The only defined types still remaining are arguments to - * templates. - */ - - prcode(fp,"%S",ad->u.snd); - break; - - case rxcon_type: - case rxdis_type: - nr_derefs = 1; - prcode(fp,"TQObject"); - break; - - case mapped_type: - generateBaseType(&ad->u.mtd->type,fp); - break; - - case class_type: - prcode(fp,"%U",ad->u.cd); - break; - - case template_type: - { - static const char tail[] = ">"; - int a; - templateDef *td = ad->u.td; - - prcode(fp, "%S%s", td->fqname, (prcode_xml ? "<" : "<")); - - for (a = 0; a < td->types.nrArgs; ++a) - { - if (a > 0) - prcode(fp,","); - - generateBaseType(&td->types.args[a],fp); - } - - if (prcode_last == tail) - prcode(fp, " "); - - prcode(fp, (prcode_xml ? ">" : tail)); - break; - } - - case enum_type: - prcode(fp,"%E",ad->u.ed); - break; - - case pyobject_type: - case pytuple_type: - case pylist_type: - case pydict_type: - case pycallable_type: - case pyslice_type: - case pytype_type: - case qobject_type: - case ellipsis_type: - prcode(fp, "PyObject *"); - break; - } - - if (nr_derefs > 0) - { - int i; - - prcode(fp," "); - - for (i = 0; i < nr_derefs; ++i) - prcode(fp,"*"); - } - - if (isReference(ad)) - prcode(fp, (prcode_xml ? "&" : "&")); - - if (*name != '\0') - { - if (nr_derefs == 0) - prcode(fp," "); - - prcode(fp,name); - } -} - - -/* - * Generate the definition of an argument variable and any supporting - * variables. - */ -static void generateVariable(argDef *ad,int argnr,FILE *fp) -{ - argType atype = ad->atype; - argDef orig; - - if (isInArg(ad) && ad->defval != NULL && - (atype == class_type || atype == mapped_type) && - (ad->nrderefs == 0 || isReference(ad))) - { - /* - * Generate something to hold the default value as it cannot be - * assigned straight away. - */ - prcode(fp, -" %B a%ddef = ",ad,argnr); - - generateExpression(ad->defval,fp); - - prcode(fp,";\n" - ); - } - - /* Adjust the type so we have the type that will really handle it. */ - - orig = *ad; - - switch (atype) - { - case sstring_type: - case ustring_type: - case string_type: - case wstring_type: - if (!isReference(ad)) - if (ad->nrderefs == 2) - ad->nrderefs = 1; - else if (ad->nrderefs == 1 && isOutArg(ad)) - ad->nrderefs = 0; - - break; - - case mapped_type: - case class_type: - case void_type: - case struct_type: - ad->nrderefs = 1; - break; - - default: - ad->nrderefs = 0; - } - - /* Array sizes are always integers. */ - if (isArraySize(ad)) - ad->atype = int_type; - - resetIsReference(ad); - - if (ad->nrderefs == 0) - resetIsConstArg(ad); - - prcode(fp, -" %B a%d",ad,argnr); - - if (atype == anyslot_type) - prcode(fp, "Name"); - - *ad = orig; - - generateDefaultValue(ad, argnr, fp); - - prcode(fp,";\n" - ); - - /* Some types have supporting variables. */ - if (isInArg(ad)) - switch (atype) - { - case class_type: - if (ad->u.cd->convtocode != NULL && !isConstrained(ad)) - prcode(fp, -" int a%dState = 0;\n" - ,argnr); - - if (isGetWrapper(ad)) - prcode(fp, -" PyObject *a%dWrapper;\n" - ,argnr); - - break; - - case mapped_type: - prcode(fp, -" int a%dState = 0;\n" - ,argnr); - break; - - case anyslot_type: - prcode(fp, -" PyObject *a%dCallable", argnr); - generateDefaultValue(ad, argnr, fp); - prcode(fp, ";\n" - ); - break; - } -} - - -/* - * Generate a default value. - */ -static void generateDefaultValue(argDef *ad, int argnr, FILE *fp) -{ - if (isInArg(ad) && ad->defval != NULL) - { - prcode(fp," = "); - - if ((ad->atype == class_type || ad->atype == mapped_type) && - (ad->nrderefs == 0 || isReference(ad))) - prcode(fp, "&a%ddef", argnr); - else - generateExpression(ad->defval,fp); - } -} - - -/* - * Generate a simple function call. - */ -static void generateSimpleFunctionCall(fcallDef *fcd,FILE *fp) -{ - int i; - - prcode(fp, "%B(", &fcd->type); - - for (i = 0; i < fcd->nrArgs; ++i) - { - if (i > 0) - prcode(fp,","); - - generateExpression(fcd->args[i],fp); - } - - prcode(fp,")"); -} - - -/* - * Generate the type structure that contains all the information needed by the - * metatype. A sub-set of this is used to extend namespaces. - */ -static void generateTypeDefinition(sipSpec *pt, classDef *cd, FILE *fp) -{ - char *mname = pt->module->name; - const char *sep; - int is_slots, nr_methods, nr_enums; - int is_inst_class, is_inst_voidp, is_inst_char, is_inst_string; - int is_inst_int, is_inst_long, is_inst_ulong, is_inst_longlong; - int is_inst_ulonglong, is_inst_double, is_inst_enum; - memberDef *md; - - if (cd->supers != NULL) - { - classList *cl; - - prcode(fp, -"\n" -"\n" -"/* Define this type's super-types. */\n" -"static sipEncodedClassDef supers_%C[] = {",classFQCName(cd)); - - for (cl = cd->supers; cl != NULL; cl = cl->next) - { - if (cl != cd->supers) - prcode(fp,", "); - - generateEncodedClass(pt,cl->cd,(cl->next == NULL),fp); - } - - prcode(fp,"};\n" - ); - } - - /* Generate the slots table. */ - is_slots = FALSE; - - for (md = cd->members; md != NULL; md = md->next) - { - const char *stype; - - if (md->slot == no_slot) - continue; - - if (!is_slots) - { - prcode(fp, -"\n" -"\n" -"/* Define this type's Python slots. */\n" -"static sipPySlotDef slots_%C[] = {\n" - ,classFQCName(cd)); - - is_slots = TRUE; - } - - if ((stype = slotName(md->slot)) != NULL) - prcode(fp, -" {(void *)slot_%C_%s, %s},\n" - ,classFQCName(cd),md->pyname->text,stype); - } - - if (is_slots) - prcode(fp, -" {0, (sipPySlotType)0}\n" -"};\n" - ); - - /* Generate the attributes tables. */ - nr_methods = generateMethodTable(cd,fp); - nr_enums = generateEnumMemberTable(pt,cd,fp); - - /* Generate each instance table. */ - is_inst_class = generateClasses(pt,cd,fp); - is_inst_voidp = generateVoidPointers(pt,cd,fp); - is_inst_char = generateChars(pt,cd,fp); - is_inst_string = generateStrings(pt,cd,fp); - is_inst_int = generateInts(pt,cd,fp); - is_inst_long = generateLongs(pt,cd,fp); - is_inst_ulong = generateUnsignedLongs(pt,cd,fp); - is_inst_longlong = generateLongLongs(pt,cd,fp); - is_inst_ulonglong = generateUnsignedLongLongs(pt,cd,fp); - is_inst_double = generateDoubles(pt,cd,fp); - is_inst_enum = generateEnums(pt,cd,fp); - - prcode(fp, -"\n" -"\n" -"sipTypeDef sipType_%s_%C = {\n" -" 0,\n" -" ", mname, classFQCName(cd)); - - sep = ""; - - if (cd->userflags) - { - prcode(fp, "%s%x", sep, ((cd->userflags << TYPE_FLAGS_SHIFT) & TYPE_FLAGS_MASK)); - sep = "|"; - } - - if (isAbstractClass(cd)) - { - prcode(fp, "%sSIP_TYPE_ABSTRACT", sep); - sep = "|"; - } - - if (cd->subbase != NULL) - { - prcode(fp, "%sSIP_TYPE_SCC", sep); - sep = "|"; - } - - if (*sep == '\0') - prcode(fp, "0"); - - prcode(fp, ",\n"); - - if (cd->real != NULL) - prcode(fp, -" 0,\n" - ); - else if (cd->ecd != NULL && cd->ecd->real != NULL) - prcode(fp, -" \"%s.%P\",\n" - , cd->ecd->real->iff->module->name, cd->ecd, cd->pyname); - else - prcode(fp, -" \"%s.%P\",\n" - , mname, cd->ecd, cd->pyname); - - if (isRenamedClass(cd)) - prcode(fp, -" \"%S\",\n" - , classFQCName(cd)); - else - prcode(fp, -" 0,\n" - ); - - prcode(fp, -" "); - - if (cd->real != NULL) - generateEncodedClass(pt, cd->real, 0, fp); - else if (cd->ecd != NULL) - generateEncodedClass(pt, cd->ecd, 0, fp); - else - prcode(fp, "{0, 0, 1}"); - - prcode(fp, ",\n" - ); - - if (cd->supers != NULL) - prcode(fp, -" supers_%C,\n" - ,classFQCName(cd)); - else - prcode(fp, -" 0,\n" - ); - - if (is_slots) - prcode(fp, -" slots_%C,\n" - ,classFQCName(cd)); - else - prcode(fp, -" 0,\n" - ); - - if (nr_methods == 0) - prcode(fp, -" 0, 0,\n" - ); - else - prcode(fp, -" %d, methods_%C,\n" - ,nr_methods,classFQCName(cd)); - - if (nr_enums == 0) - prcode(fp, -" 0, 0,\n" - ); - else - prcode(fp, -" %d, enummembers_%C,\n" - ,nr_enums,classFQCName(cd)); - - if (hasVarHandlers(cd)) - prcode(fp, -" variables_%C,\n" - ,classFQCName(cd)); - else - prcode(fp, -" 0,\n" - ); - - if (canCreate(cd)) - prcode(fp, -" init_%C,\n" - ,classFQCName(cd)); - else - prcode(fp, -" 0,\n" - ); - - if (cd->travcode != NULL) - prcode(fp, -" traverse_%C,\n" - ,classFQCName(cd)); - else - prcode(fp, -" 0,\n" - ); - - if (cd->clearcode != NULL) - prcode(fp, -" clear_%C,\n" - ,classFQCName(cd)); - else - prcode(fp, -" 0,\n" - ); - - if (cd->readbufcode != NULL) - prcode(fp, -" getreadbuffer_%C,\n" - ,classFQCName(cd)); - else - prcode(fp, -" 0,\n" - ); - - if (cd->writebufcode != NULL) - prcode(fp, -" getwritebuffer_%C,\n" - ,classFQCName(cd)); - else - prcode(fp, -" 0,\n" - ); - - if (cd->segcountcode != NULL) - prcode(fp, -" getsegcount_%C,\n" - ,classFQCName(cd)); - else - prcode(fp, -" 0,\n" - ); - - if (cd->charbufcode != NULL) - prcode(fp, -" getcharbuffer_%C,\n" - ,classFQCName(cd)); - else - prcode(fp, -" 0,\n" - ); - - if (needDealloc(cd)) - prcode(fp, -" dealloc_%C,\n" - ,classFQCName(cd)); - else - prcode(fp, -" 0,\n" - ); - - if (cd->iff->type == namespace_iface || generating_c) - prcode(fp, -" 0,\n" -" 0,\n" - ); - else - prcode(fp, -" cast_%C,\n" -" release_%C,\n" - , classFQCName(cd) - , classFQCName(cd)); - - if (cd->iff->type == namespace_iface) - prcode(fp, -" 0,\n" -" 0,\n" - ); - else - { - prcode(fp, -" forceConvertTo_%C,\n" - ,classFQCName(cd)); - - if (cd->convtocode != NULL) - prcode(fp, -" convertTo_%C,\n" - ,classFQCName(cd)); - else - prcode(fp, -" 0,\n" - ); - } - - if (!optNoEmitters(pt) && hasSigSlots(cd)) - prcode(fp, -" signals_%C,\n" - ,classFQCName(cd)); - else - prcode(fp, -" 0,\n" - ); - - prcode(fp, -" {"); - - if (is_inst_class) - prcode(fp,"classInstances_%C, ",classFQCName(cd)); - else - prcode(fp,"0, "); - - if (is_inst_voidp) - prcode(fp,"voidPtrInstances_%C, ",classFQCName(cd)); - else - prcode(fp,"0, "); - - if (is_inst_char) - prcode(fp,"charInstances_%C, ",classFQCName(cd)); - else - prcode(fp,"0, "); - - if (is_inst_string) - prcode(fp,"stringInstances_%C, ",classFQCName(cd)); - else - prcode(fp,"0, "); - - if (is_inst_int) - prcode(fp,"intInstances_%C, ",classFQCName(cd)); - else - prcode(fp,"0, "); - - if (is_inst_long) - prcode(fp,"longInstances_%C, ",classFQCName(cd)); - else - prcode(fp,"0, "); - - if (is_inst_ulong) - prcode(fp,"unsignedLongInstances_%C, ",classFQCName(cd)); - else - prcode(fp,"0, "); - - if (is_inst_longlong) - prcode(fp,"longLongInstances_%C, ",classFQCName(cd)); - else - prcode(fp,"0, "); - - if (is_inst_ulonglong) - prcode(fp,"unsignedLongLongInstances_%C, ",classFQCName(cd)); - else - prcode(fp,"0, "); - - if (is_inst_double) - prcode(fp,"doubleInstances_%C, ",classFQCName(cd)); - else - prcode(fp,"0, "); - - if (is_inst_enum) - prcode(fp,"enumInstances_%C",classFQCName(cd)); - else - prcode(fp,"0"); - - prcode(fp,"},\n" -" 0\n" -"};\n" - ); -} - - -/* - * Return the sip module's string equivalent of a slot. - */ -static const char *slotName(slotType st) -{ - const char *sn; - - switch (st) - { - case str_slot: - sn = "str_slot"; - break; - - case int_slot: - sn = "int_slot"; - break; - - case long_slot: - sn = "long_slot"; - break; - - case float_slot: - sn = "float_slot"; - break; - - case len_slot: - sn = "len_slot"; - break; - - case contains_slot: - sn = "contains_slot"; - break; - - case add_slot: - sn = "add_slot"; - break; - - case concat_slot: - sn = "concat_slot"; - break; - - case sub_slot: - sn = "sub_slot"; - break; - - case mul_slot: - sn = "mul_slot"; - break; - - case repeat_slot: - sn = "repeat_slot"; - break; - - case div_slot: - sn = "div_slot"; - break; - - case mod_slot: - sn = "mod_slot"; - break; - - case and_slot: - sn = "and_slot"; - break; - - case or_slot: - sn = "or_slot"; - break; - - case xor_slot: - sn = "xor_slot"; - break; - - case lshift_slot: - sn = "lshift_slot"; - break; - - case rshift_slot: - sn = "rshift_slot"; - break; - - case iadd_slot: - sn = "iadd_slot"; - break; - - case iconcat_slot: - sn = "iconcat_slot"; - break; - - case isub_slot: - sn = "isub_slot"; - break; - - case imul_slot: - sn = "imul_slot"; - break; - - case irepeat_slot: - sn = "irepeat_slot"; - break; - - case idiv_slot: - sn = "idiv_slot"; - break; - - case imod_slot: - sn = "imod_slot"; - break; - - case iand_slot: - sn = "iand_slot"; - break; - - case ior_slot: - sn = "ior_slot"; - break; - - case ixor_slot: - sn = "ixor_slot"; - break; - - case ilshift_slot: - sn = "ilshift_slot"; - break; - - case irshift_slot: - sn = "irshift_slot"; - break; - - case invert_slot: - sn = "invert_slot"; - break; - - case call_slot: - sn = "call_slot"; - break; - - case getitem_slot: - sn = "getitem_slot"; - break; - - case setitem_slot: - sn = "setitem_slot"; - break; - - case delitem_slot: - sn = "delitem_slot"; - break; - - case lt_slot: - sn = "lt_slot"; - break; - - case le_slot: - sn = "le_slot"; - break; - - case eq_slot: - sn = "eq_slot"; - break; - - case ne_slot: - sn = "ne_slot"; - break; - - case gt_slot: - sn = "gt_slot"; - break; - - case ge_slot: - sn = "ge_slot"; - break; - - case cmp_slot: - sn = "cmp_slot"; - break; - - case nonzero_slot: - sn = "nonzero_slot"; - break; - - case neg_slot: - sn = "neg_slot"; - break; - - case pos_slot: - sn = "pos_slot"; - break; - - case abs_slot: - sn = "abs_slot"; - break; - - case repr_slot: - sn = "repr_slot"; - break; - - case hash_slot: - sn = "hash_slot"; - break; - - default: - sn = NULL; - } - - return sn; -} - - -/* - * Generate the code to register a class as a Qt metatype. - */ -static void generateRegisterMetaType(classDef *cd, FILE *fp) -{ - int pub_def_ctor, pub_copy_ctor; - ctorDef *ct; - - /* - * We register types with Qt if the class is not abstract, has a public - * default ctor, a public copy ctor, a public dtor and isn't one of the - * internally supported types. - */ - if (isAbstractClass(cd)) - return; - - if (!isPublicDtor(cd)) - return; - - if (classFQCName(cd)->next == NULL) - { - if (strcmp(classBaseName(cd), "TQChar") == 0) - return; - - if (strcmp(classBaseName(cd), "TQString") == 0) - return; - - if (strcmp(classBaseName(cd), "TQByteArray") == 0) - return; - } - - pub_def_ctor = pub_copy_ctor = FALSE; - - for (ct = cd->ctors; ct != NULL; ct = ct->next) - { - if (ct->cppsig == NULL || !isPublicCtor(ct)) - continue; - - if (ct->cppsig->nrArgs == 0) - pub_def_ctor = TRUE; - else if (ct->cppsig->nrArgs == 1) - { - argDef *ad = &ct->cppsig->args[0]; - - if (ad->atype == class_type && ad->u.cd == cd && isReference(ad) && - isConstArg(ad) && ad->nrderefs == 0 && ad->defval == NULL) - pub_copy_ctor = TRUE; - } - } - - if (pub_def_ctor && pub_copy_ctor) - prcode(fp, -" qRegisterMetaType<%S>(\"%S\");\n" - , classFQCName(cd), classFQCName(cd)); -} - - -/* - * Generate the initialisation function or cast operators for the type. - */ -static void generateTypeInit(sipSpec *pt, classDef *cd, FILE *fp) -{ - ctorDef *ct; - int need_self, need_owner; - - /* - * See if we need to name the self and owner arguments so that we can - * avoid a compiler warning about an unused argument. - */ - need_self = (generating_c || hasShadow(cd)); - need_owner = generating_c; - - for (ct = cd->ctors; ct != NULL; ct = ct->next) - { - int a; - - if (usedInCode(ct->methodcode, "sipSelf")) - need_self = TRUE; - - for (a = 0; a < ct->pysig.nrArgs; ++a) - if (isThisTransferred(&ct->pysig.args[a])) - { - need_owner = TRUE; - break; - } - } - - prcode(fp, -"\n" -"\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static void *init_%C(sipWrapper *, PyObject *, sipWrapper **, int *);}\n" - , classFQCName(cd)); - - prcode(fp, -"static void *init_%C(sipWrapper *%s,PyObject *sipArgs,sipWrapper **%s,int *sipArgsParsed)\n" -"{\n" - ,classFQCName(cd),(need_self ? "sipSelf" : ""),(need_owner ? "sipOwner" : "")); - - if (hasShadow(cd)) - prcode(fp, -" sip%C *sipCpp = 0;\n" - ,classFQCName(cd)); - else - prcode(fp, -" %U *sipCpp = 0;\n" - ,cd); - - if (tracing) - prcode(fp, -"\n" -" sipTrace(SIP_TRACE_INITS,\"init_%C()\\n\");\n" - ,classFQCName(cd)); - - /* - * Generate the code that parses the Python arguments and calls the - * correct constructor. - */ - for (ct = cd->ctors; ct != NULL; ct = ct->next) - { - int needSecCall, error_flag = FALSE; - - if (isPrivateCtor(ct)) - continue; - - prcode(fp, -"\n" -" if (!sipCpp)\n" -" {\n" - ); - - if (ct->methodcode != NULL && needErrorFlag(ct->methodcode)) - { - prcode(fp, -" int sipIsErr = 0;\n" - ); - - error_flag = TRUE; - } - - needSecCall = generateArgParser(pt, &ct->pysig, cd, ct, NULL, FALSE, fp); - generateConstructorCall(cd,ct,error_flag,fp); - - if (needSecCall) - { - prcode(fp, -" }\n" -"\n" -" if (!sipCpp)\n" -" {\n" - ); - - if (error_flag) - prcode(fp, -" int sipIsErr = 0;\n" - ); - - generateArgParser(pt, &ct->pysig, cd, ct, NULL, TRUE, fp); - generateConstructorCall(cd,ct,error_flag,fp); - } - - prcode(fp, -" }\n" - ); - } - - if (hasShadow(cd)) - prcode(fp, -"\n" -" if (sipCpp)\n" -" sipCpp->sipPySelf = sipSelf;\n" - ); - - prcode(fp, -"\n" -" return sipCpp;\n" -"}\n" - ); -} - - -/* - * Count the number of virtual members in a class. - */ -static int countVirtuals(classDef *cd) -{ - int nrvirts; - virtOverDef *vod; - - nrvirts = 0; - - for (vod = cd->vmembers; vod != NULL; vod = vod->next) - if (!isPrivate(&vod->o)) - ++nrvirts; - - return nrvirts; -} - - -/* - * Generate the try block for a call. - */ -static void generateTry(throwArgs *ta,FILE *fp) -{ - /* - * Generate the block if there was no throw specifier, or a non-empty - * throw specifier. - */ - if (exceptions && (ta == NULL || ta->nrArgs > 0)) - prcode(fp, -" try\n" -" {\n" - ); -} - - -/* - * Generate the catch block for a call. - */ -static void generateCatch(throwArgs *ta, signatureDef *sd, FILE *fp) -{ - /* - * Generate the block if there was no throw specifier, or a non-empty - * throw specifier. - */ - if (exceptions && (ta == NULL || ta->nrArgs > 0)) - { - prcode(fp, -" }\n" - ); - - if (ta == NULL) - { - prcode(fp, -" catch (...)\n" -" {\n" - ); - - deleteTemps(sd, fp); - - if (release_gil) - prcode(fp, -" Py_BLOCK_THREADS\n" -"\n" - ); - - prcode(fp, -" sipRaiseUnknownException();\n" -" return NULL;\n" -" }\n" - ); - } - else - { - int a; - - for (a = 0; a < ta->nrArgs; ++a) - { - exceptionDef *xd = ta->args[a]; - scopedNameDef *ename = xd->iff->fqcname; - - prcode(fp, -" catch (%S &%s)\n" -" {\n" - ,ename,(xd->cd != NULL || usedInCode(xd->raisecode, "sipExceptionRef")) ? "sipExceptionRef" : ""); - - deleteTemps(sd, fp); - - if (xd->cd != NULL) - { - /* The exception is a wrapped class. */ - - prcode(fp, -" /* Hope that there is a valid copy ctor. */\n" -" %S *sipExceptionCopy = new %S(sipExceptionRef);\n" -"\n" - ,ename,ename); - - if (release_gil) - prcode(fp, -" Py_BLOCK_THREADS\n" -"\n" - ); - - prcode(fp, -" sipRaise%sClassException(sipClass_%C,sipExceptionCopy);\n" - ,(xd->cd->subbase != NULL ? "Sub" : ""),ename); - } - else - generateCppCodeBlock(xd->raisecode,fp); - - prcode(fp, -"\n" -" return NULL;\n" -" }\n" - ); - } - } - } -} - - -/* - * Generate a throw specifier. - */ -static void generateThrowSpecifier(throwArgs *ta,FILE *fp) -{ - if (exceptions && ta != NULL) - { - int a; - - prcode(fp," throw("); - - for (a = 0; a < ta->nrArgs; ++a) - { - if (a > 0) - prcode(fp,","); - - prcode(fp,"%S",ta->args[a]->iff->fqcname); - } - - prcode(fp,")"); - } -} - - -/* - * Generate a single constructor call. - */ -static void generateConstructorCall(classDef *cd,ctorDef *ct,int error_flag, - FILE *fp) -{ - prcode(fp, -" {\n" - ); - - /* Call any pre-hook. */ - if (ct->prehook != NULL) - prcode(fp, -" sipCallHook(\"%s\");\n" -"\n" - ,ct->prehook); - - if (ct->methodcode != NULL) - generateCppCodeBlock(ct->methodcode,fp); - else if (generating_c) - prcode(fp, -" sipCpp = sipMalloc(sizeof (%S));\n" - ,classFQCName(cd)); - else - { - int rgil = ((release_gil || isReleaseGILCtor(ct)) && !isHoldGILCtor(ct)); - - if (rgil) - prcode(fp, -" Py_BEGIN_ALLOW_THREADS\n" - ); - - generateTry(ct->exceptions,fp); - - if (hasShadow(cd)) - prcode(fp, -" sipCpp = new sip%C(",classFQCName(cd)); - else - prcode(fp, -" sipCpp = new %U(",cd); - - if (isCastCtor(ct)) - { - classDef *ocd; - - /* We have to fiddle the type to generate the correct code. */ - ocd = ct->pysig.args[0].u.cd; - ct->pysig.args[0].u.cd = cd; - prcode(fp, "a0->operator %B()", &ct->pysig.args[0]); - ct->pysig.args[0].u.cd = ocd; - } - else - generateArgs(ct->cppsig, Call, fp); - - prcode(fp,");\n" - ); - - generateCatch(ct->exceptions, &ct->pysig, fp); - - if (rgil) - prcode(fp, -" Py_END_ALLOW_THREADS\n" - ); - } - - gc_ellipsis(&ct->pysig, fp); - - deleteTemps(&ct->pysig, fp); - - if (error_flag) - prcode(fp, -"\n" -" if (sipIsErr)\n" -" return 0;\n" - ); - - /* Call any post-hook. */ - if (ct->posthook != NULL) - prcode(fp, -"\n" -" sipCallHook(\"%s\");\n" - ,ct->posthook); - - prcode(fp, -" }\n" - ); -} - - -/* - * See if a member overload should be skipped. - */ -static int skipOverload(overDef *od,memberDef *md,classDef *cd,classDef *ccd, - int want_local) -{ - /* Skip if it's not the right name. */ - if (od->common != md) - return TRUE; - - /* Skip if it's a signal. */ - if (isSignal(od)) - return TRUE; - - /* Skip if it's a private abstract. */ - if (isAbstract(od) && isPrivate(od)) - return TRUE; - - /* - * If we are disallowing them, skip if it's not in the current class - * unless it is protected. - */ - if (want_local && !isProtected(od) && ccd != cd) - return TRUE; - - return FALSE; -} - - -/* - * Generate a class member function. - */ -static void generateFunction(sipSpec *pt,memberDef *md,overDef *overs, - classDef *cd,classDef *ocd,FILE *fp) -{ - overDef *od; - int need_method, need_self, need_args, need_selfarg; - - /* - * Check that there is at least one overload that needs to be handled. - * See if we can avoid naming the "self" argument (and suppress a - * compiler warning). Finally see if we need to remember if "self" was - * explicitly passed as an argument. - */ - need_method = need_self = need_args = need_selfarg = FALSE; - - for (od = overs; od != NULL; od = od->next) - { - /* - * Skip protected methods if we don't have the means to handle - * them. - */ - if (isProtected(od) && !hasShadow(cd)) - continue; - - if (!skipOverload(od,md,cd,ocd,TRUE)) - { - need_method = TRUE; - - if (!isPrivate(od)) - { - need_args = TRUE; - - if (!isStatic(od)) - { - need_self = TRUE; - - if (isAbstract(od) || isVirtual(od) || isVirtualReimp(od) || usedInCode(od->methodcode, "sipSelfWasArg")) - need_selfarg = TRUE; - } - } - } - } - - if (need_method) - { - char *pname = md->pyname->text; - - prcode(fp, -"\n" -"\n" - ); - - if (!generating_c) - prcode(fp, -"extern \"C\" {static PyObject *meth_%C_%s(PyObject *, PyObject *);}\n" - , classFQCName(cd), pname); - - prcode(fp, -"static PyObject *meth_%C_%s(PyObject *%s,PyObject *%s)\n" -"{\n" - ,classFQCName(cd),pname,(need_self ? "sipSelf" : ""),(need_args ? "sipArgs" : "")); - - if (tracing) - prcode(fp, -" sipTrace(SIP_TRACE_METHODS,\"meth_%C_%s()\\n\");\n" -"\n" - ,classFQCName(cd),pname); - - if (need_args) - prcode(fp, -" int sipArgsParsed = 0;\n" - ); - - if (need_selfarg) - prcode(fp, -" bool sipSelfWasArg = !sipSelf;\n" - ); - - for (od = overs; od != NULL; od = od->next) - { - /* - * If we are handling one variant then we must handle - * them all. - */ - if (skipOverload(od,md,cd,ocd,FALSE)) - continue; - - if (isPrivate(od)) - continue; - - generateFunctionBody(pt,od,cd,ocd,TRUE,fp); - } - - prcode(fp, -"\n" -" /* Raise an exception if the arguments couldn't be parsed. */\n" -" sipNoMethod(%s,%N,%N);\n" -"\n" -" return NULL;\n" -"}\n" - ,(need_args ? "sipArgsParsed" : "0"),cd->iff->name,md->pyname); - } -} - - -/* - * Generate the function calls for a particular overload. - */ -static void generateFunctionBody(sipSpec *pt,overDef *od,classDef *cd, - classDef *ocd,int deref,FILE *fp) -{ - int needSecCall; - signatureDef saved; - - prcode(fp, -"\n" -" {\n" - ); - - /* In case we have to fiddle with it. */ - saved = od->pysig; - - if (isNumberSlot(od->common)) - { - /* - * Number slots must have two arguments because we parse them - * slightly differently. - */ - if (od->pysig.nrArgs == 1) - { - od->pysig.nrArgs = 2; - od->pysig.args[1] = od->pysig.args[0]; - - /* Insert self as the first argument. */ - od->pysig.args[0].atype = class_type; - od->pysig.args[0].name = NULL; - od->pysig.args[0].argflags = ARG_IS_REF|ARG_IN; - od->pysig.args[0].nrderefs = 0; - od->pysig.args[0].defval = NULL; - od->pysig.args[0].u.cd = ocd; - } - - generateArgParser(pt, &od->pysig, cd, NULL, od, FALSE, fp); - needSecCall = FALSE; - } - else if (isIntArgSlot(od->common) || isZeroArgSlot(od->common)) - needSecCall = FALSE; - else - needSecCall = generateArgParser(pt, &od->pysig, cd, NULL, od, FALSE, fp); - - generateFunctionCall(cd,ocd,od,deref,fp); - - if (needSecCall) - { - prcode(fp, -" }\n" -"\n" -" {\n" - ); - - generateArgParser(pt, &od->pysig, cd, NULL, od, TRUE, fp); - generateFunctionCall(cd,ocd,od,deref,fp); - } - - prcode(fp, -" }\n" - ); - - od->pysig = saved; -} - - -/* - * Generate the code to handle the result of a call to a member function. - */ -static void generateHandleResult(overDef *od,int isNew,char *prefix,FILE *fp) -{ - char *vname, vnamebuf[50]; - int a, nrvals, only, has_owner; - argDef *res, *ad; - - res = &od->pysig.result; - - if (res->atype == void_type && res->nrderefs == 0) - res = NULL; - - /* See if we are returning 0, 1 or more values. */ - nrvals = 0; - - if (res != NULL) - { - only = -1; - ++nrvals; - } - - has_owner = FALSE; - - for (a = 0; a < od->pysig.nrArgs; ++a) - { - if (isOutArg(&od->pysig.args[a])) - { - only = a; - ++nrvals; - } - - if (isThisTransferred(&od->pysig.args[a])) - has_owner = TRUE; - } - - /* Handle the trivial case. */ - if (nrvals == 0) - { - prcode(fp, -" Py_INCREF(Py_None);\n" -" %s Py_None;\n" - ,prefix); - - return; - } - - /* Handle results that are classes or mapped types separately. */ - if (res != NULL) - if (res->atype == mapped_type) - { - prcode(fp, -" PyObject *sipResObj = sipConvertFromMappedType("); - - if (isConstArg(res)) - prcode(fp,"const_cast<%b *>(sipRes)",res); - else - prcode(fp,"sipRes"); - - prcode(fp,",sipMappedType_%T,%s);\n" - , res, isResultTransferredBack(od) ? "Py_None" : "NULL"); - - if (isNew) - prcode(fp, -" delete sipRes;\n" - ); - - /* Shortcut if this is the only value returned. */ - if (nrvals == 1) - { - prcode(fp, -"\n" -" %s sipResObj;\n" - ,prefix); - - return; - } - } - else if (res->atype == class_type) - { - classDef *cd = res->u.cd; - - if (isNew || isFactory(od)) - { - prcode(fp, -" %s sipConvertFromNewInstance(",(nrvals == 1 ? prefix : "PyObject *sipResObj =")); - - if (isConstArg(res)) - prcode(fp,"const_cast<%b *>(sipRes)",res); - else - prcode(fp,"sipRes"); - - prcode(fp,",sipClass_%C,%s);\n" - ,classFQCName(cd),((has_owner && isFactory(od)) ? "(PyObject *)sipOwner" : "NULL")); - - /* - * Shortcut if this is the only value returned. - */ - if (nrvals == 1) - return; - } - else - { - prcode(fp, -" %s sipConvertFromInstance(",(nrvals == 1 ? prefix : "PyObject *sipResObj =")); - - if (isConstArg(res)) - prcode(fp,"const_cast<%b *>(sipRes)",res); - else - prcode(fp,"sipRes"); - - prcode(fp, ",sipClass_%C,%s);\n" - , classFQCName(cd), (isResultTransferredBack(od) ? "Py_None" : "NULL")); - - /* - * Shortcut if this is the only value returned. - */ - if (nrvals == 1) - return; - } - } - - /* If there are multiple values then build a tuple. */ - if (nrvals > 1) - { - prcode(fp, -" %s sipBuildResult(0,\"(",prefix); - - /* Build the format string. */ - if (res != NULL) - prcode(fp,"%c",((res->atype == mapped_type || res->atype == class_type) ? 'R' : getBuildResultFormat(res))); - - for (a = 0; a < od->pysig.nrArgs; ++a) - { - argDef *ad = &od->pysig.args[a]; - - if (isOutArg(ad)) - prcode(fp,"%c",getBuildResultFormat(ad)); - } - - prcode(fp,")\""); - - /* Pass the values for conversion. */ - if (res != NULL) - { - prcode(fp,",sipRes"); - - if (res->atype == mapped_type || res->atype == class_type) - prcode(fp,"Obj"); - else if (res->atype == enum_type && res->u.ed->fqcname != NULL) - prcode(fp,",sipEnum_%C",res->u.ed->fqcname); - } - - for (a = 0; a < od->pysig.nrArgs; ++a) - { - argDef *ad = &od->pysig.args[a]; - - if (isOutArg(ad)) - { - prcode(fp,",a%d",a); - - if (ad->atype == mapped_type) - prcode(fp, ",sipMappedType_%T,%s", ad, (isTransferredBack(ad) ? "Py_None" : "NULL")); - else if (ad->atype == class_type) - prcode(fp, ",sipClass_%C,%s", classFQCName(ad->u.cd), (isTransferredBack(ad) ? "Py_None" : "NULL")); - else if (ad->atype == enum_type && ad->u.ed->fqcname != NULL) - prcode(fp,",sipEnum_%C",ad->u.ed->fqcname); - } - } - - prcode(fp,");\n" - ); - - /* All done for multiple values. */ - return; - } - - /* Deal with the only returned value. */ - if (only < 0) - { - ad = res; - vname = "sipRes"; - } - else - { - ad = &od->pysig.args[only]; - - sprintf(vnamebuf,"a%d",only); - vname = vnamebuf; - } - - switch (ad->atype) - { - case mapped_type: - prcode(fp, -" %s sipConvertFromMappedType(", prefix); - - if (isConstArg(ad)) - prcode(fp,"const_cast<%b *>(%s)",ad,vname); - else - prcode(fp,"%s",vname); - - prcode(fp,",sipMappedType_%T,%s);\n" - , ad, (isTransferredBack(ad) ? "Py_None" : "NULL")); - - break; - - case class_type: - { - classDef *cd = ad->u.cd; - int needNew = needNewInstance(ad); - - if (needNew) - prcode(fp, -" %s sipConvertFromNewInstance(", prefix); - else - prcode(fp, -" %s sipConvertFromInstance(", prefix); - - if (isConstArg(ad)) - prcode(fp,"const_cast<%b *>(%s)",ad,vname); - else - prcode(fp,"%s",vname); - - prcode(fp,",sipClass_%C,",classFQCName(cd)); - - if (needNew) - prcode(fp,"NULL"); - else - prcode(fp,"%s\n" - , (isTransferredBack(ad) ? "Py_None" : "NULL")); - - prcode(fp,");\n" - ); - } - - break; - - case bool_type: - case cbool_type: - prcode(fp, -" %s PyBool_FromLong(%s);\n" - ,prefix,vname); - - break; - - case sstring_type: - case ustring_type: - case string_type: - if (ad->nrderefs == 0) - prcode(fp, -" %s PyString_FromStringAndSize(%s&%s,1);\n" - ,prefix,(ad->atype != string_type) ? "(char *)" : "",vname); - else - prcode(fp, -" if (%s == NULL)\n" -" {\n" -" Py_INCREF(Py_None);\n" -" return Py_None;\n" -" }\n" -"\n" -" %s PyString_FromString(%s%s);\n" - ,vname - ,prefix,(ad->atype != string_type) ? "(char *)" : "",vname); - - break; - - case wstring_type: - if (ad->nrderefs == 0) - prcode(fp, -" %s PyUnicode_FromWideChar(&%s,1);\n" - , prefix, vname); - else - prcode(fp, -" if (%s == NULL)\n" -" {\n" -" Py_INCREF(Py_None);\n" -" return Py_None;\n" -" }\n" -"\n" -" %s PyUnicode_FromWideChar(%s,(SIP_SSIZE_T)wcslen(%s));\n" - , vname - , prefix, vname, vname); - - break; - - case enum_type: - if (ad->u.ed->fqcname != NULL) - { - prcode(fp, -" %s sipConvertFromNamedEnum(%s,sipEnum_%C);\n" - ,prefix,vname,ad->u.ed->fqcname); - - break; - } - - /* Drop through. */ - - case short_type: - case int_type: - case cint_type: - prcode(fp, -" %s PyInt_FromLong(%s);\n" - ,prefix,vname); - - break; - - case long_type: - prcode(fp, -" %s PyLong_FromLong(%s);\n" - ,prefix,vname); - - break; - - case ushort_type: - case uint_type: - case ulong_type: - prcode(fp, -" %s PyLong_FromUnsignedLong(%s);\n" - ,prefix,vname); - - break; - - case longlong_type: - prcode(fp, -" %s PyLong_FromLongLong(%s);\n" - ,prefix,vname); - - break; - - case ulonglong_type: - prcode(fp, -" %s PyLong_FromUnsignedLongLong(%s);\n" - ,prefix,vname); - - break; - - case void_type: - prcode(fp, -" %s sipConvertFromVoidPtr(", prefix); - - if (isConstArg(ad)) - prcode(fp, "const_cast<void *>(%s)", vname); - else - prcode(fp, "%s", vname); - - prcode(fp, ");\n" - ); - - break; - - case struct_type: - prcode(fp, -" %s sipConvertFromVoidPtr(",prefix); - - if (isConstArg(ad)) - prcode(fp,"const_cast<%b *>(%s)",ad,vname); - else - prcode(fp,"%s",vname); - - prcode(fp,");\n" - ); - - break; - - case float_type: - case cfloat_type: - prcode(fp, -" %s PyFloat_FromDouble((double)%s);\n" - ,prefix,vname); - - break; - - case double_type: - case cdouble_type: - prcode(fp, -" %s PyFloat_FromDouble(%s);\n" - ,prefix,vname); - - break; - - case pyobject_type: - case pytuple_type: - case pylist_type: - case pydict_type: - case pycallable_type: - case pyslice_type: - case pytype_type: - prcode(fp, -" %s %s;\n" - ,prefix,vname); - - break; - } -} - - -/* - * Return the format character used by sipBuildResult() for a particular type. - */ -static char getBuildResultFormat(argDef *ad) -{ - switch (ad->atype) - { - case mapped_type: - return 'D'; - - case class_type: - if (needNewInstance(ad)) - return 'B'; - - return 'C'; - - case bool_type: - case cbool_type: - return 'b'; - - case sstring_type: - case ustring_type: - case string_type: - return (ad->nrderefs > (isOutArg(ad) ? 1 : 0)) ? 's' : 'c'; - - case wstring_type: - return (ad->nrderefs > (isOutArg(ad) ? 1 : 0)) ? 'x' : 'w'; - - case enum_type: - return (ad->u.ed->fqcname != NULL) ? 'E' : 'e'; - - case short_type: - return 'h'; - - case ushort_type: - return 't'; - - case int_type: - case cint_type: - return 'i'; - - case uint_type: - return 'u'; - - case long_type: - return 'l'; - - case ulong_type: - return 'm'; - - case longlong_type: - return 'n'; - - case ulonglong_type: - return 'o'; - - case void_type: - case struct_type: - return 'V'; - - case float_type: - case cfloat_type: - return 'f'; - - case double_type: - case cdouble_type: - return 'd'; - - case pyobject_type: - case pytuple_type: - case pylist_type: - case pydict_type: - case pycallable_type: - case pyslice_type: - case pytype_type: - return 'R'; - } - - /* We should never get here. */ - return ' '; -} - - -/* - * Generate a function call. - */ -static void generateFunctionCall(classDef *cd,classDef *ocd,overDef *od, - int deref, FILE *fp) -{ - int needsNew, error_flag = FALSE, newline, is_result, a, deltemps; - argDef *res = &od->pysig.result, orig_res; - - prcode(fp, -" {\n" - ); - - /* - * If there is no shadow class then protected methods can never be - * called. - */ - if (isProtected(od) && !hasShadow(cd)) - { - prcode(fp, -" /* Never reached. */\n" -" }\n" - ); - - return; - } - - /* Save the full result type as we may want to fiddle with it. */ - orig_res = *res; - - /* See if we need to make a copy of the result on the heap. */ - if ((res->atype == class_type || res->atype == mapped_type) && - !isReference(res) && - res->nrderefs == 0) - { - needsNew = TRUE; - resetIsConstArg(res); - } - else - needsNew = FALSE; - - /* See if sipRes is needed. */ - is_result = (!isInplaceNumberSlot(od->common) && - !isInplaceSequenceSlot(od->common) && - (res->atype != void_type || res->nrderefs != 0)); - - newline = FALSE; - - if (is_result) - { - prcode(fp, -" "); - - generateNamedValueType(res,"sipRes",fp); - - /* - * The typical %MethodCode usually causes a compiler warning, - * so we initialise the result in that case to try and suppress - * it. - */ - if (od->methodcode != NULL) - { - prcode(fp," = "); - - generateCastZero(res,fp); - } - - prcode(fp,";\n" - ); - - newline = TRUE; - } - - deltemps = TRUE; - - for (a = 0; a < od->pysig.nrArgs; ++a) - { - argDef *ad = &od->pysig.args[a]; - - /* - * If we have an In,Out argument that has conversion code then we delay - * the destruction of any temporary variables until after we have - * converted the outputs. - */ - if (isInArg(ad) && isOutArg(ad) && hasConvertToCode(ad) && deltemps) - { - deltemps = FALSE; - - prcode(fp, -" PyObject *sipResult;\n" - ); - - newline = TRUE; - } - - /* - * If we are returning a class via an output only reference or pointer - * then we need an instance on the heap. - */ - if (needNewInstance(ad)) - { - prcode(fp, -" a%d = new %b();\n" - ,a,ad); - - newline = TRUE; - } - } - - if (od->methodcode != NULL) - { - /* See if the handwritten code seems to be using the error flag. */ - if (needErrorFlag(od->methodcode)) - { - prcode(fp, -" int sipIsErr = 0;\n" - ); - - newline = TRUE; - error_flag = TRUE; - } - } - - if (newline) - prcode(fp, -"\n" - ); - - /* If it is abstract make sure that self was bound. */ - if (isAbstract(od)) - prcode(fp, -" if (sipSelfWasArg)\n" -" {\n" -" sipAbstractMethod(%N,%N);\n" -" return NULL;\n" -" }\n" -"\n" - , cd->iff->name, od->common->pyname); - - /* Call any pre-hook. */ - if (od->prehook != NULL) - prcode(fp, -" sipCallHook(\"%s\");\n" -"\n" - ,od->prehook); - - if (od->methodcode != NULL) - generateCppCodeBlock(od->methodcode,fp); - else - { - int rgil = ((release_gil || isReleaseGIL(od)) && !isHoldGIL(od)); - - if (needsNew && generating_c) - { - prcode(fp, -" if ((sipRes = (%b *)sipMalloc(sizeof (%b))) == NULL)\n" -" {\n" - ,res,res); - - gc_ellipsis(&od->pysig, fp); - - prcode(fp, -" return NULL;\n" -" }\n" -"\n" - ); - } - - if (rgil) - prcode(fp, -" Py_BEGIN_ALLOW_THREADS\n" - ); - - generateTry(od->exceptions,fp); - - prcode(fp, -" "); - - if (od->common->slot != cmp_slot && is_result) - { - /* Construct a copy on the heap if needed. */ - if (needsNew) - { - if (generating_c) - prcode(fp,"*sipRes = "); - else - prcode(fp,"sipRes = new %b(",res); - } - else - prcode(fp,"sipRes = "); - - /* See if we need the address of the result. */ - if ((res->atype == class_type || res->atype == mapped_type) && isReference(res)) - prcode(fp,"&"); - } - - switch (od->common->slot) - { - case no_slot: - generateCppFunctionCall(cd,ocd,od,fp); - break; - - case getitem_slot: - prcode(fp, "(*sipCpp)["); - generateSlotArg(&od->pysig, 0, fp); - prcode(fp,"]"); - break; - - case call_slot: - prcode(fp, "(*sipCpp)("); - generateArgs(od->cppsig,Call,fp); - prcode(fp,")"); - break; - - case int_slot: - case long_slot: - case float_slot: - prcode(fp, "*sipCpp"); - break; - - case add_slot: - generateNumberSlotCall(od,"+",fp); - break; - - case concat_slot: - generateBinarySlotCall(od,"+",deref,fp); - break; - - case sub_slot: - generateNumberSlotCall(od,"-",fp); - break; - - case mul_slot: - generateNumberSlotCall(od,"*",fp); - break; - - case repeat_slot: - generateBinarySlotCall(od,"*",deref,fp); - break; - - case div_slot: - generateNumberSlotCall(od,"/",fp); - break; - - case mod_slot: - generateNumberSlotCall(od,"%",fp); - break; - - case and_slot: - generateNumberSlotCall(od,"&",fp); - break; - - case or_slot: - generateNumberSlotCall(od,"|",fp); - break; - - case xor_slot: - generateNumberSlotCall(od,"^",fp); - break; - - case lshift_slot: - generateNumberSlotCall(od,"<<",fp); - break; - - case rshift_slot: - generateNumberSlotCall(od,">>",fp); - break; - - case iadd_slot: - case iconcat_slot: - generateBinarySlotCall(od,"+=",deref,fp); - break; - - case isub_slot: - generateBinarySlotCall(od,"-=",deref,fp); - break; - - case imul_slot: - case irepeat_slot: - generateBinarySlotCall(od,"*=",deref,fp); - break; - - case idiv_slot: - generateBinarySlotCall(od,"/=",deref,fp); - break; - - case imod_slot: - generateBinarySlotCall(od,"%=",deref,fp); - break; - - case iand_slot: - generateBinarySlotCall(od,"&=",deref,fp); - break; - - case ior_slot: - generateBinarySlotCall(od,"|=",deref,fp); - break; - - case ixor_slot: - generateBinarySlotCall(od,"^=",deref,fp); - break; - - case ilshift_slot: - generateBinarySlotCall(od,"<<=",deref,fp); - break; - - case irshift_slot: - generateBinarySlotCall(od,">>=",deref,fp); - break; - - case invert_slot: - prcode(fp, "~(*sipCpp)"); - break; - - case lt_slot: - generateBinarySlotCall(od,"<",deref,fp); - break; - - case le_slot: - generateBinarySlotCall(od,"<=",deref,fp); - break; - - case eq_slot: - generateBinarySlotCall(od,"==",deref,fp); - break; - - case ne_slot: - generateBinarySlotCall(od,"!=",deref,fp); - break; - - case gt_slot: - generateBinarySlotCall(od,">",deref,fp); - break; - - case ge_slot: - generateBinarySlotCall(od,">=",deref,fp); - break; - - case neg_slot: - prcode(fp, "-(*sipCpp)"); - break; - - case pos_slot: - prcode(fp, "+(*sipCpp)"); - break; - - case cmp_slot: - prcode(fp,"if "); - generateBinarySlotCall(od,"<",deref,fp); - prcode(fp,"\n" -" sipRes = -1;\n" -" else if "); - generateBinarySlotCall(od,">",deref,fp); - prcode(fp,"\n" -" sipRes = 1;\n" -" else\n" -" sipRes = 0"); - - break; - } - - if (needsNew && !generating_c) - prcode(fp,")"); - - prcode(fp,";\n" - ); - - generateCatch(od->exceptions, &od->pysig, fp); - - if (rgil) - prcode(fp, -" Py_END_ALLOW_THREADS\n" - ); - } - - /* Handle /TransferThis/ for non-factory methods. */ - if (!isFactory(od)) - for (a = 0; a < od->pysig.nrArgs; ++a) - { - argDef *ad = &od->pysig.args[a]; - - if (!isInArg(ad)) - continue; - - if (isThisTransferred(ad)) - { - prcode(fp, -"\n" -" if (sipOwner)\n" -" sipTransferTo(sipSelf, (PyObject *)sipOwner);\n" -" else\n" -" sipTransferBack(sipSelf);\n" - ); - - break; - } - } - - gc_ellipsis(&od->pysig, fp); - - if (deltemps) - deleteTemps(&od->pysig, fp); - - prcode(fp, -"\n" - ); - - /* Handle sipIsErr if it was used. */ - if (error_flag) - prcode(fp, -" if (sipIsErr)\n" -" return %s;\n" -"\n" - ,((isVoidReturnSlot(od->common) || isIntReturnSlot(od->common) || isLongReturnSlot(od->common)) ? "-1" : "0")); - - /* Call any post-hook. */ - if (od->posthook != NULL) - prcode(fp, -"\n" -" sipCallHook(\"%s\");\n" - ,od->posthook); - - if (isVoidReturnSlot(od->common)) - prcode(fp, -" return 0;\n" - ); - else if (isInplaceNumberSlot(od->common) || isInplaceSequenceSlot(od->common)) - prcode(fp, -" Py_INCREF(sipSelf);\n" -" return sipSelf;\n" - ); - else if (isIntReturnSlot(od->common) || isLongReturnSlot(od->common)) - prcode(fp, -" return sipRes;\n" - ); - else - { - generateHandleResult(od,needsNew,(deltemps ? "return" : "sipResult ="),fp); - - /* Delete the temporaries now if we haven't already done so. */ - if (!deltemps) - { - deleteTemps(&od->pysig, fp); - - prcode(fp, -"\n" -" return sipResult;\n" - ); - } - } - - prcode(fp, -" }\n" - ); - - /* Restore the full type of the result. */ - *res = orig_res; -} - - -/* - * Generate a call to a C++ function. - */ -static void generateCppFunctionCall(classDef *cd,classDef *ocd,overDef *od, - FILE *fp) -{ - char *mname = od->cppname; - int parens = 1; - - /* - * If the function is protected then call the public wrapper. If it is - * virtual then call explicit scoped function if "self" was passed as - * the first argument. - */ - - if (cd == NULL) - prcode(fp,"%s(",mname); - else if (cd->iff->type == namespace_iface) - prcode(fp,"%S::%s(",classFQCName(cd),mname); - else if (isStatic(od)) - { - if (isProtected(od)) - prcode(fp,"sip%C::sipProtect_%s(",classFQCName(cd),mname); - else - prcode(fp,"%S::%s(",classFQCName(ocd),mname); - } - else if (isProtected(od)) - { - if (!isAbstract(od) && (isVirtual(od) || isVirtualReimp(od))) - { - prcode(fp, "sipCpp->sipProtectVirt_%s(sipSelfWasArg", mname); - - if (od->cppsig->nrArgs > 0) - prcode(fp, ","); - } - else - prcode(fp, "sipCpp->sipProtect_%s(", mname); - } - else if (!isAbstract(od) && (isVirtual(od) || isVirtualReimp(od))) - { - prcode(fp, "(sipSelfWasArg ? sipCpp->%U::%s(", ocd, mname); - generateArgs(od->cppsig, Call, fp); - prcode(fp, ") : sipCpp->%s(", mname); - ++parens; - } - else - prcode(fp, "sipCpp->%s(", mname); - - generateArgs(od->cppsig, Call, fp); - - while (parens--) - prcode(fp, ")"); -} - - -/* - * Generate argument to a slot. - */ -static void generateSlotArg(signatureDef *sd, int argnr, FILE *fp) -{ - argDef *ad; - int deref; - - ad = &sd->args[argnr]; - deref = ((ad->atype == class_type || ad->atype == mapped_type) && ad->nrderefs == 0); - - prcode(fp, "%sa%d", (deref ? "*" : ""), argnr); -} - - -/* - * Generate the call to a binary (non-number) slot method. - */ -static void generateBinarySlotCall(overDef *od, char *op, int deref, FILE *fp) -{ - if (deref) - prcode(fp, "((*sipCpp) %s ", op); - else - prcode(fp, "(sipCpp %s ", op); - - generateSlotArg(&od->pysig, 0, fp); - prcode(fp, ")"); -} - - -/* - * Generate the call to a binary number slot method. - */ -static void generateNumberSlotCall(overDef *od, char *op, FILE *fp) -{ - prcode(fp, "("); - generateSlotArg(&od->pysig, 0, fp); - prcode(fp, " %s ", op); - generateSlotArg(&od->pysig, 1, fp); - prcode(fp, ")"); -} - - -/* - * Generate the argument variables for a member function/constructor/operator. - */ -static int generateArgParser(sipSpec *pt, signatureDef *sd, classDef *cd, - ctorDef *ct, overDef *od, int secCall, FILE *fp) -{ - int a, isQtSlot, optargs, arraylenarg, sigarg, handle_self; - int slotconarg, slotdisarg, need_owner; - - /* If the class is just a namespace, then ignore it. */ - - if (cd != NULL && cd->iff->type == namespace_iface) - cd = NULL; - - handle_self = (od != NULL && od->common->slot == no_slot && !isStatic(od) && cd != NULL); - - /* Assume there isn't a Qt slot. */ - - isQtSlot = FALSE; - - /* - * Generate the local variables that will hold the parsed arguments and - * values returned via arguments. - */ - - sigarg = -1; - need_owner = FALSE; - - for (a = 0; a < sd->nrArgs; ++a) - { - argDef *ad = &sd->args[a]; - - switch (ad->atype) - { - case signal_type: - sigarg = a; - break; - - case rxcon_type: - case rxdis_type: - isQtSlot = TRUE; - break; - - case slotcon_type: - slotconarg = a; - break; - - case slotdis_type: - slotdisarg = a; - break; - } - - if (isArraySize(ad)) - arraylenarg = a; - - generateVariable(ad,a,fp); - - if (isThisTransferred(ad)) - need_owner = TRUE; - } - - if (od != NULL && need_owner) - prcode(fp, -" sipWrapper *sipOwner = 0;\n" - ); - - if (handle_self) - { - if (isProtected(od) && hasShadow(cd)) - prcode(fp, -" sip%C *sipCpp;\n" - ,classFQCName(cd)); - else - prcode(fp, -" %U *sipCpp;\n" - ,cd); - - prcode(fp, -"\n" - ); - } - else if (sd->nrArgs != 0) - prcode(fp, -"\n" - ); - - /* Generate the call to the parser function. */ - if (od != NULL && isNumberSlot(od->common)) - prcode(fp, -" if (sipParsePair(%ssipArgsParsed,sipArg0,sipArg1,\"", (ct != NULL ? "" : "&")); - else - prcode(fp, -" if (sipParseArgs(%ssipArgsParsed,sipArg%s,\"", (ct != NULL ? "" : "&"), (od == NULL || od->common->slot == no_slot || isMultiArgSlot(od->common)) ? "s" : ""); - - /* Generate the format string. */ - optargs = FALSE; - - if (handle_self) - prcode(fp,"%c",(isProtected(od) ? 'p' : 'B')); - else if (isQtSlot && od == NULL) - prcode(fp,"C"); - - for (a = 0; a < sd->nrArgs; ++a) - { - char *fmt = ""; - argDef *ad = &sd->args[a]; - - if (!isInArg(ad)) - continue; - - if (ad->defval != NULL && !optargs) - { - prcode(fp,"|"); - optargs = TRUE; - } - - switch (ad->atype) - { - case sstring_type: - case ustring_type: - case string_type: - if (ad->nrderefs == 0 || (isOutArg(ad) && ad->nrderefs == 1)) - fmt = "c"; - else if (isArray(ad)) - fmt = "a"; - else - fmt = "s"; - - break; - - case wstring_type: - if (ad->nrderefs == 0 || (isOutArg(ad) && ad->nrderefs == 1)) - fmt = "w"; - else if (isArray(ad)) - fmt = "A"; - else - fmt = "x"; - - break; - - case enum_type: - fmt = (ad->u.ed->fqcname != NULL) ? "E" : "e"; - break; - - case bool_type: - fmt = "b"; - break; - - case cbool_type: - fmt = "Xb"; - break; - - case int_type: - if (!isArraySize(ad)) - fmt = "i"; - - break; - - case uint_type: - if (!isArraySize(ad)) - fmt = "u"; - - break; - - case cint_type: - fmt = "Xi"; - break; - - case short_type: - if (!isArraySize(ad)) - fmt = "h"; - - break; - - case ushort_type: - if (!isArraySize(ad)) - fmt = "t"; - - break; - - case long_type: - if (!isArraySize(ad)) - fmt = "l"; - - break; - - case ulong_type: - if (!isArraySize(ad)) - fmt = "m"; - - break; - - case longlong_type: - if (!isArraySize(ad)) - fmt = "n"; - - break; - - case ulonglong_type: - if (!isArraySize(ad)) - fmt = "o"; - - break; - - case struct_type: - case void_type: - fmt = "v"; - break; - - case float_type: - fmt = "f"; - break; - - case cfloat_type: - fmt = "Xf"; - break; - - case double_type: - fmt = "d"; - break; - - case cdouble_type: - fmt = "Xd"; - break; - - case signal_type: - fmt = "G"; - break; - - case slot_type: - fmt = "S"; - break; - - case anyslot_type: - fmt = "U"; - break; - - case slotcon_type: - case slotdis_type: - fmt = (secCall ? "" : "S"); - break; - - case rxcon_type: - fmt = (secCall ? "y" : "q"); - break; - - case rxdis_type: - fmt = (secCall ? "Y" : "Q"); - break; - - case mapped_type: - fmt = getSubFormatChar('M',ad); - break; - - case class_type: - fmt = getSubFormatChar('J', ad); - break; - - case pyobject_type: - fmt = getSubFormatChar('P',ad); - break; - - case pytuple_type: - case pylist_type: - case pydict_type: - case pyslice_type: - case pytype_type: - fmt = (isAllowNone(ad) ? "N" : "T"); - break; - - case pycallable_type: - fmt = (isAllowNone(ad) ? "H" : "F"); - break; - - case qobject_type: - fmt = "R"; - break; - - case ellipsis_type: - fmt = "W"; - break; - } - - prcode(fp,fmt); - } - - prcode(fp,"\""); - - /* Generate the parameters corresponding to the format string. */ - - if (handle_self) - prcode(fp,",&sipSelf,sipClass_%C,&sipCpp",classFQCName(cd)); - else if (isQtSlot && od == NULL) - prcode(fp,",sipSelf"); - - for (a = 0; a < sd->nrArgs; ++a) - { - argDef *ad = &sd->args[a]; - - if (!isInArg(ad)) - continue; - - switch (ad->atype) - { - case mapped_type: - prcode(fp,",sipMappedType_%T,&a%d,&a%dState",ad,a,a); - break; - - case class_type: - prcode(fp, ",sipClass_%T,&a%d", ad, a); - - if (isThisTransferred(ad)) - prcode(fp, ",%ssipOwner", (ct != NULL ? "" : "&")); - else if (isGetWrapper(ad)) - prcode(fp, ",&a%dWrapper", a); - - if (ad->u.cd->convtocode != NULL && !isConstrained(ad)) - prcode(fp, ",&a%dState", a); - - break; - - case rxcon_type: - { - if (sigarg > 0) - prcode(fp,",a%d",sigarg); - else - { - prcode(fp,",\"("); - - generateArgs(sd->args[slotconarg].u.sa,Declaration,fp); - - prcode(fp,")\""); - } - - prcode(fp,",&a%d,&a%d",a,slotconarg); - - break; - } - - case rxdis_type: - { - prcode(fp,",\"("); - - generateArgs(sd->args[slotdisarg].u.sa,Declaration,fp); - - prcode(fp,")\",&a%d,&a%d",a,slotdisarg); - - break; - } - - case slotcon_type: - case slotdis_type: - if (!secCall) - prcode(fp,",&a%d",a); - - break; - - case anyslot_type: - prcode(fp, ",&a%dName,&a%dCallable", a, a); - break; - - case pytuple_type: - prcode(fp,",&PyTuple_Type,&a%d",a); - break; - - case pylist_type: - prcode(fp,",&PyList_Type,&a%d",a); - break; - - case pydict_type: - prcode(fp,",&PyDict_Type,&a%d",a); - break; - - case pyslice_type: - prcode(fp,",&PySlice_Type,&a%d",a); - break; - - case pytype_type: - prcode(fp,",&PyType_Type,&a%d",a); - break; - - case enum_type: - if (ad->u.ed->fqcname != NULL) - prcode(fp,",sipEnum_%C",ad->u.ed->fqcname); - - prcode(fp,",&a%d",a); - break; - - default: - if (!isArraySize(ad)) - prcode(fp,",&a%d",a); - - if (isArray(ad)) - prcode(fp,",&a%d",arraylenarg); - } - } - - prcode(fp,"))\n"); - - return isQtSlot; -} - - -/* - * Get the format character string for something that has sub-formats. - */ - -static char *getSubFormatChar(char fc,argDef *ad) -{ - static char fmt[3]; - char flags; - - fmt[0] = fc; - - flags = 0; - - if (fc != 'P' && ad->nrderefs == 0) - flags |= 0x01; - - if (isTransferred(ad)) - flags |= 0x02; - - if (isTransferredBack(ad)) - flags |= 0x04; - - if (fc == 'J') - { - if (isThisTransferred(ad)) - flags |= 0x20; - - if (isGetWrapper(ad)) - flags |= 0x08; - - if (ad->u.cd->convtocode == NULL || isConstrained(ad)) - flags |= 0x10; - } - - fmt[1] = '0' + flags; - - fmt[2] = '\0'; - - return fmt; -} - - -/* - * Return TRUE if a type has %ConvertToTypeCode. - */ -static int hasConvertToCode(argDef *ad) -{ - codeBlock *convtocode; - - if (ad->atype == class_type && !isConstrained(ad)) - convtocode = ad->u.cd->convtocode; - else if (ad->atype == mapped_type) - convtocode = ad->u.mtd->convtocode; - else - convtocode = NULL; - - return (convtocode != NULL); -} - - -/* - * Garbage collect any ellipsis argument. - */ -static void gc_ellipsis(signatureDef *sd, FILE *fp) -{ - if (sd->nrArgs > 0 && sd->args[sd->nrArgs - 1].atype == ellipsis_type) - prcode(fp, -"\n" -" Py_DECREF(a%d);\n" - , sd->nrArgs - 1); -} - - -/* - * Delete any temporary variables on the heap created by type convertors. - */ -static void deleteTemps(signatureDef *sd, FILE *fp) -{ - int a, first = TRUE; - - for (a = 0; a < sd->nrArgs; ++a) - { - argDef *ad = &sd->args[a]; - - if (!isInArg(ad)) - continue; - - if (ad->atype == wstring_type && ad->nrderefs == 1) - { - if (generating_c || !isConstArg(ad)) - prcode(fp, -" sipFree(a%d);\n" - , a); - else - prcode(fp, -" sipFree(const_cast<wchar_t *>(a%d));\n" - , a); - } - else if (hasConvertToCode(ad)) - { - const char *fstr, *sstr; - - if (ad->atype == mapped_type) - fstr = sstr = "MappedType"; - else - { - fstr = "Instance"; - sstr = "Class"; - } - - if (first) - { - prcode(fp, -"\n" - ); - - first = FALSE; - } - - if (generating_c || !isConstArg(ad)) - prcode(fp, -" sipRelease%s(a%d,sip%s_%T,a%dState);\n" - , fstr, a, sstr, ad, a); - else - prcode(fp, -" sipRelease%s(const_cast<%b *>(a%d),sip%s_%T,a%dState);\n" - , fstr, ad, a, sstr, ad, a); - } - } -} - - -/* - * Generate a C++ code block. - */ -static void generateCppCodeBlock(codeBlock *code,FILE *fp) -{ - int reset_line = FALSE; - codeBlock *cb; - - for (cb = code; cb != NULL; cb = cb->next) - { - char *cp; - - /* - * Fragmented fragments (possibly created when applying - * template types) don't have a filename. - */ - if ((cp = cb->filename) != NULL) - { - reset_line = TRUE; - - prcode(fp, -"#line %d \"", cb->linenr); - - while (*cp != '\0') - { - prcode(fp, "%c", *cp); - - if (*cp == '\\') - prcode(fp, "\\"); - - ++cp; - } - - prcode(fp, "\"\n" - ); - } - - prcode(fp, "%s", cb->frag); - } - - if (reset_line) - { - char *bn; - - /* Just use the base name. */ - - if ((bn = strrchr(currentFileName,'/')) != NULL) - ++bn; - else - bn = currentFileName; - - prcode(fp, -"#line %d \"%s\"\n" - ,currentLineNr + 1,bn); - } -} - - -/* - * Create a source file. - */ -static FILE *createCompilationUnit(sipSpec *pt, char *fname, char *description) -{ - FILE *fp = createFile(pt, fname, description); - - if (fp != NULL) - generateCppCodeBlock(pt->unitcode, fp); - - return fp; -} - - -/* - * Create a file with an optional standard header. - */ -static FILE *createFile(sipSpec *pt,char *fname,char *description) -{ - FILE *fp; - - /* Create the file. */ - - if ((fp = fopen(fname,"w")) == NULL) - fatal("Unable to create file \"%s\"\n",fname); - - /* The "stack" doesn't have to be very deep. */ - previousLineNr = currentLineNr; - currentLineNr = 1; - previousFileName = currentFileName; - currentFileName = fname; - - if (description != NULL) - { - int needComment; - codeBlock *cb; - time_t now; - - /* Write the header. */ - now = time(NULL); - - prcode(fp, -"/*\n" -" * %s\n" -" *\n" -" * Generated by SIP %s on %s" - ,description - ,sipVersion,ctime(&now)); - - if (pt->copying != NULL) - prcode(fp, -" *\n" - ); - - needComment = TRUE; - - for (cb = pt->copying; cb != NULL; cb = cb->next) - { - char *cp; - - for (cp = cb->frag; *cp != '\0'; ++cp) - { - if (needComment) - { - needComment = FALSE; - prcode(fp," * "); - } - - prcode(fp,"%c",*cp); - - if (*cp == '\n') - needComment = TRUE; - } - } - - prcode(fp, -" */\n" - ); - } - - return fp; -} - - -/* - * Close a file and report any errors. - */ -static void closeFile(FILE *fp) -{ - if (ferror(fp)) - fatal("Error writing to \"%s\"\n",currentFileName); - - if (fclose(fp)) - fatal("Error closing \"%s\"\n",currentFileName); - - currentLineNr = previousLineNr; - currentFileName = previousFileName; -} - - -/* - * Print formatted code. - */ -void prcode(FILE *fp, const char *fmt, ...) -{ - char ch; - va_list ap; - - prcode_last = fmt; - - va_start(ap,fmt); - - while ((ch = *fmt++) != '\0') - if (ch == '%') - { - ch = *fmt++; - - switch (ch) - { - case 'c': - { - char c = (char)va_arg(ap,int); - - if (c == '\n') - ++currentLineNr; - - fputc(c,fp); - break; - } - - case 's': - { - const char *cp = va_arg(ap,const char *); - - while (*cp != '\0') - { - if (*cp == '\n') - ++currentLineNr; - - fputc(*cp,fp); - ++cp; - } - - break; - } - - case 'l': - fprintf(fp,"%ld",va_arg(ap,long)); - break; - - case 'u': - fprintf(fp,"%u",va_arg(ap,unsigned)); - break; - - case 'd': - fprintf(fp,"%d",va_arg(ap,int)); - break; - - case 'g': - fprintf(fp,"%g",va_arg(ap,double)); - break; - - case 'x': - fprintf(fp,"0x%08x",va_arg(ap,unsigned)); - break; - - case '\0': - fputc('%',fp); - --fmt; - break; - - case '\n': - fputc('\n',fp); - ++currentLineNr; - break; - - case 'b': - { - argDef *ad, orig; - - ad = va_arg(ap,argDef *); - orig = *ad; - - resetIsConstArg(ad); - resetIsReference(ad); - ad->nrderefs = 0; - - generateBaseType(ad,fp); - - *ad = orig; - - break; - } - - case 'M': - prcode_xml = !prcode_xml; - break; - - case 'B': - generateBaseType(va_arg(ap,argDef *),fp); - break; - - case 'T': - prTypeName(fp,va_arg(ap,argDef *),FALSE); - break; - - case 'I': - { - int indent = va_arg(ap,int); - - while (indent-- > 0) - fputc('\t',fp); - - break; - } - - case 'N': - { - nameDef *nd = va_arg(ap,nameDef *); - - fprintf(fp,"sipNm_%s_%s",nd->module->name,nd->text); - break; - } - - case 'E': - { - enumDef *ed = va_arg(ap,enumDef *); - - if (ed->fqcname == NULL) - fprintf(fp,"int"); - else if (isProtectedEnum(ed)) - { - fprintf(fp,"sip"); - prScopedName(fp,classFQCName(ed->pcd),"_"); - - fprintf(fp,"::sip%s",scopedNameTail(ed->fqcname)); - } - else - prScopedName(fp,ed->fqcname,"::"); - - break; - } - - case 'F': - prScopedName(fp,va_arg(ap,scopedNameDef *),""); - break; - - case 'C': - prScopedName(fp,va_arg(ap,scopedNameDef *),"_"); - break; - - case 'S': - if (generating_c) - fprintf(fp,"struct "); - - prScopedName(fp,va_arg(ap,scopedNameDef *),"::"); - break; - - case 'U': - if (generating_c) - fprintf(fp,"struct "); - - prScopedClassName(fp,va_arg(ap,classDef *),"::"); - break; - - case 'O': - prOverloadName(fp, va_arg(ap, overDef *)); - break; - - case 'P': - { - classDef *ecd = va_arg(ap, classDef *); - const char *pyname = va_arg(ap, const char *); - - prScopedPythonName(fp, ecd, pyname); - break; - } - - case 'X': - generateThrowSpecifier(va_arg(ap,throwArgs *),fp); - break; - - default: - fputc(ch,fp); - } - } - else if (ch == '\n') - { - fputc('\n',fp); - ++currentLineNr; - } - else - fputc(ch,fp); - - va_end(ap); -} - - -/* - * Generate the C++ name of an overloaded function. - */ -void prOverloadName(FILE *fp, overDef *od) -{ - char *pt1, *pt2; - - pt1 = "operator"; - - switch (od->common->slot) - { - case add_slot: - pt2 = "+"; - break; - - case sub_slot: - pt2 = "-"; - break; - - case mul_slot: - pt2 = "*"; - break; - - case div_slot: - pt2 = "/"; - break; - - case mod_slot: - pt2 = "%"; - break; - - case and_slot: - pt2 = "&"; - break; - - case or_slot: - pt2 = "|"; - break; - - case xor_slot: - pt2 = "^"; - break; - - case lshift_slot: - pt2 = "<<"; - break; - - case rshift_slot: - pt2 = ">>"; - break; - - case iadd_slot: - pt2 = "+="; - break; - - case isub_slot: - pt2 = "-="; - break; - - case imul_slot: - pt2 = "*="; - break; - - case idiv_slot: - pt2 = "/="; - break; - - case imod_slot: - pt2 = "%="; - break; - - case iand_slot: - pt2 = "&="; - break; - - case ior_slot: - pt2 = "|="; - break; - - case ixor_slot: - pt2 = "^="; - break; - - case ilshift_slot: - pt2 = "<<="; - break; - - case irshift_slot: - pt2 = ">>="; - break; - - case invert_slot: - pt2 = "~"; - break; - - case call_slot: - pt2 = "()"; - break; - - case getitem_slot: - pt2 = "[]"; - break; - - case lt_slot: - pt2 = "<"; - break; - - case le_slot: - pt2 = "<="; - break; - - case eq_slot: - pt2 = "=="; - break; - - case ne_slot: - pt2 = "!="; - break; - - case gt_slot: - pt2 = ">"; - break; - - case ge_slot: - pt2 = ">="; - break; - - default: - pt1 = ""; - pt2 = od->cppname; - } - - fprintf(fp, "%s%s", pt1, pt2); -} - - -/* - * Generate a scoped name with the given separator string. - */ -static void prScopedName(FILE *fp,scopedNameDef *snd,char *sep) -{ - while (snd != NULL) - { - fprintf(fp,"%s",snd->name); - - if ((snd = snd->next) != NULL) - fprintf(fp,"%s",sep); - } -} - - -/* - * Generate a scoped class name with the given separator string. At the moment - * this provides (probably) broken support for protected classes. - */ -static void prScopedClassName(FILE *fp,classDef *cd,char *sep) -{ - scopedNameDef *snd = classFQCName(cd); - - while (snd != NULL) - { - if (isProtectedClass(cd)) - fprintf(fp,"sip"); - - fprintf(fp,"%s",snd->name); - - if ((snd = snd->next) != NULL) - fprintf(fp,"%s",sep); - } -} - - -/* - * Generate a scoped Python name. - */ -void prScopedPythonName(FILE *fp, classDef *scope, const char *pyname) -{ - if (scope != NULL) - { - prScopedPythonName(fp, scope->ecd, NULL); - fprintf(fp, "%s.", scope->pyname); - } - - if (pyname != NULL) - fprintf(fp, "%s", pyname); -} - - -/* - * Generate a type name to be used as part of an identifier name. - */ -static void prTypeName(FILE *fp,argDef *ad,int intmpl) -{ - if (intmpl) - { - char buf[10]; - int flgs; - - /* We use numbers so they don't conflict with names. */ - - sprintf(buf,"%02d",ad->atype); - - flgs = 0; - - if (isConstArg(ad)) - flgs += 1; - - if (isReference(ad)) - flgs += 2; - - prcode(fp,"%s%d%d",buf,flgs,ad->nrderefs); - } - - /* Now add a name if there is one associated with the type. */ - - switch (ad->atype) - { - case struct_type: - prcode(fp,"%C",ad->u.sname); - break; - - case defined_type: - prcode(fp,"%C",ad->u.snd); - break; - - case enum_type: - prcode(fp,"%C",ad->u.ed->fqcname); - break; - - case mapped_type: - prTypeName(fp,&ad->u.mtd->type,intmpl); - break; - - case class_type: - prcode(fp,"%C",classFQCName(ad->u.cd)); - break; - - case template_type: - { - int a; - templateDef *td = ad->u.td; - - prcode(fp,"%C",td->fqname); - - for (a = 0; a < td->types.nrArgs; ++a) - { - prcode(fp,"_"); - prTypeName(fp,&td->types.args[a],TRUE); - } - - break; - } - } -} - - -/* - * Return TRUE if handwritten code uses the error flag. - */ -static int needErrorFlag(codeBlock *cb) -{ - return usedInCode(cb, "sipIsErr"); -} - - -/* - * Return TRUE if the argument type means an instance needs to be created on - * the heap to pass back to Python. - */ -static int needNewInstance(argDef *ad) -{ - return ((ad->atype == mapped_type || ad->atype == class_type) && - ((isReference(ad) && ad->nrderefs == 0) || (!isReference(ad) && ad->nrderefs == 1)) && - !isInArg(ad) && isOutArg(ad)); -} - - -/* - * Reset and save any argument flags so that the signature will be rendered - * exactly as defined in C++. - */ -static void normaliseArgs(signatureDef *sd) -{ - int a; - argDef *ad = sd->args; - - for (a = 0; a < sd->nrArgs; ++a) - { - if (ad->atype == class_type && isProtectedClass(ad->u.cd)) - { - resetIsProtectedClass(ad->u.cd); - setWasProtectedClass(ad->u.cd); - } - else if (ad->atype == enum_type && isProtectedEnum(ad->u.ed)) - { - resetIsProtectedEnum(ad->u.ed); - setWasProtectedEnum(ad->u.ed); - } - - ++ad; - } -} - - -/* - * Restore any argument flags modified by normaliseArgs(). - */ -static void restoreArgs(signatureDef *sd) -{ - int a; - argDef *ad = sd->args; - - for (a = 0; a < sd->nrArgs; ++a) - { - if (ad->atype == class_type && wasProtectedClass(ad->u.cd)) - { - resetWasProtectedClass(ad->u.cd); - setIsProtectedClass(ad->u.cd); - } - else if (ad->atype == enum_type && wasProtectedEnum(ad->u.ed)) - { - resetWasProtectedEnum(ad->u.ed); - setIsProtectedEnum(ad->u.ed); - } - - ++ad; - } -} - - -/* - * Return TRUE if a dealloc function is needed for a class. - */ -static int needDealloc(classDef *cd) -{ - if (cd->iff->type == namespace_iface) - return FALSE; - - /* All of these conditions cause some code to be generated. */ - - if (tracing) - return TRUE; - - if (generating_c) - return TRUE; - - if (cd->dealloccode != NULL) - return TRUE; - - if (isPublicDtor(cd)) - return TRUE; - - if (hasShadow(cd)) - return TRUE; - - return FALSE; -} - - -/* - * Return the argument name to use in a function definition for handwritten - * code. - */ -static const char *argName(const char *name, codeBlock *cb) -{ - static const char noname[] = ""; - - /* Always use the name in C code. */ - if (generating_c) - return name; - - /* Use the name if it is used in the handwritten code. */ - if (usedInCode(cb, name)) - return name; - - /* Don't use the name and avoid a compiler warning. */ - return noname; -} - - -/* - * Returns TRUE if a string is used in a code block. - */ -static int usedInCode(codeBlock *code, const char *str) -{ - while (code != NULL) - { - if (strstr(code->frag, str) != NULL) - return TRUE; - - code = code->next; - } - - return FALSE; -} - - -/* - * Generate an assignment statement from a void * variable to a class instance - * variable. - */ -static void generateClassFromVoid(classDef *cd, const char *cname, - const char *vname, FILE *fp) -{ - if (generating_c) - prcode(fp, "%S *%s = (%S *)%s", classFQCName(cd), cname, classFQCName(cd), vname); - else - prcode(fp, "%S *%s = reinterpret_cast<%S *>(%s)", classFQCName(cd), cname, classFQCName(cd), vname); -} - - -/* - * Generate an assignment statement from a void * variable to a mapped type - * variable. - */ -static void generateMappedTypeFromVoid(mappedTypeDef *mtd, const char *cname, - const char *vname, FILE *fp) -{ - if (generating_c) - prcode(fp, "%b *%s = (%b *)%s", &mtd->type, cname, &mtd->type, vname); - else - prcode(fp, "%b *%s = reinterpret_cast<%b *>(%s)", &mtd->type, cname, &mtd->type, vname); -} diff --git a/python/sip/sipgen/heap.c b/python/sip/sipgen/heap.c deleted file mode 100644 index d6e94ccc..00000000 --- a/python/sip/sipgen/heap.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Wrappers around standard functions that use the heap. - * - * Copyright (c) 2007 - * Riverbank Computing Limited <info@riverbankcomputing.co.uk> - * - * This file is part of SIP. - * - * This copy of SIP is licensed for use under the terms of the SIP License - * Agreement. See the file LICENSE for more details. - * - * SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - - -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <sys/types.h> - -#include "sip.h" - - -static void nomem(void); - - -/* - * Wrap malloc() and handle any errors. - */ - -void *sipMalloc(size_t n) -{ - void *h; - - if ((h = malloc(n)) == NULL) - nomem(); - - return h; -} - - -/* - * Wrap strdup() and handle any errors. - */ - -char *sipStrdup(char *s) -{ - char *h; - - if ((h = strdup(s)) == NULL) - nomem(); - - return h; -} - - -/* - * Return a string on the heap which is the concatonation of all the arguments. - */ - -char *concat(const char *s, ...) -{ - const char *sp; - char *new; - size_t len; - va_list ap; - - /* Find the length of the final string. */ - - len = 1; - va_start(ap,s); - - for (sp = s; sp != NULL; sp = va_arg(ap, const char *)) - len += strlen(sp); - - va_end(ap); - - /* Create the new string. */ - - new = sipMalloc(len); - *new = '\0'; - - va_start(ap,s); - - for (sp = s; sp != NULL; sp = va_arg(ap, const char *)) - strcat(new,sp); - - va_end(ap); - - return new; -} - - -/* - * Append a string to another that is on the heap. - */ - -void append(char **s,char *new) -{ - if ((*s = realloc(*s,strlen(*s) + strlen(new) + 1)) == NULL) - nomem(); - - strcat(*s,new); -} - - -/* - * Display a standard error message when the heap is exhausted. - */ - -static void nomem(void) -{ - fatal("Unable to allocate memory on the heap\n"); -} diff --git a/python/sip/sipgen/lexer.c b/python/sip/sipgen/lexer.c deleted file mode 100644 index 138acfeb..00000000 --- a/python/sip/sipgen/lexer.c +++ /dev/null @@ -1,3266 +0,0 @@ -#line 2 "lexer.c.tmp" - -#line 4 "lexer.c.tmp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 33 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include <stdlib.h> - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ - -#if __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include <inttypes.h> -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN (yy_start) = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START (((yy_start) - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -extern int yyleng; - -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, (yytext_ptr) ) - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef unsigned int yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; -static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart (FILE *input_file ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); -void yy_delete_buffer (YY_BUFFER_STATE b ); -void yy_flush_buffer (YY_BUFFER_STATE b ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state (void ); - -static void yyensure_buffer_stack (void ); -static void yy_load_buffer_state (void ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); - -#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); - -void *yyalloc (yy_size_t ); -void *yyrealloc (void *,yy_size_t ); -void yyfree (void * ); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -typedef unsigned char YY_CHAR; - -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; - -typedef int yy_state_type; - -extern int yylineno; - -int yylineno = 1; - -extern char *yytext; -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 111 -#define YY_END_OF_BUFFER 112 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_accept[735] = - { 0, - 0, 0, 0, 0, 0, 0, 112, 110, 65, 66, - 110, 110, 110, 110, 110, 68, 68, 110, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 110, 65, 110, 109, - 108, 109, 78, 76, 78, 0, 73, 0, 74, 0, - 68, 0, 72, 69, 72, 75, 67, 0, 47, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 48, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 77, 69, 64, 72, 67, 70, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 27, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 69, 40, 71, 25, 23, - 71, 71, 71, 33, 71, 71, 71, 28, 71, 71, - - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 38, 71, 71, 71, 31, 71, 0, 0, 0, 0, - 0, 0, 0, 0, 101, 15, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 107, 69, 71, 71, 71, 71, 71, 16, 36, 71, - 71, 39, 29, 71, 71, 71, 71, 71, 26, 71, - 71, 22, 71, 71, 71, 44, 71, 71, 71, 71, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 71, 71, 71, 71, 71, 71, 30, 71, - 71, 71, 71, 71, 18, 71, 34, 37, 17, 71, - 71, 71, 71, 71, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 20, 71, 21, 71, 41, 71, 32, 24, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, - 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 57, 45, 71, 43, - 71, 46, 35, 6, 0, 0, 0, 0, 0, 7, - 0, 79, 0, 0, 10, 0, 0, 105, 3, 11, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 106, 0, 0, 0, 0, 0, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 42, 19, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 103, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 8, 90, 0, - 88, 0, 71, 71, 52, 51, 71, 71, 71, 55, - 71, 71, 56, 71, 71, 0, 0, 0, 0, 0, - 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 0, 0, 0, 100, 0, 0, 0, - 0, 58, 71, 71, 54, 50, 63, 71, 71, 71, - 71, 104, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 12, 91, 89, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 71, 49, 71, 71, 61, - - 62, 0, 0, 0, 0, 0, 0, 0, 102, 0, - 94, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 71, 59, 60, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 99, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 93, 0, 0, 0, - 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 84, 0, 0, 0, 0, 0, - - 97, 0, 0, 0, 81, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 83, 0, 0, 92, 98, 95, - 0, 80, 0, 0, 0, 96, 0, 0, 0, 82, - 0, 86, 87, 0 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 5, 1, 1, 6, 1, 7, 1, - 1, 8, 9, 1, 10, 11, 12, 13, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 15, 1, 1, - 1, 1, 1, 1, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 26, - 1, 1, 1, 1, 41, 1, 42, 43, 44, 45, - - 46, 47, 48, 49, 50, 26, 51, 52, 53, 54, - 55, 56, 26, 57, 58, 59, 60, 61, 62, 63, - 64, 26, 1, 65, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst flex_int32_t yy_meta[66] = - { 0, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, - 3, 3, 4, 4, 1, 4, 4, 4, 4, 4, - 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 4, 4, 4, 4, 4, 4, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 1 - } ; - -static yyconst flex_int16_t yy_base[743] = - { 0, - 0, 64, 1581, 65, 64, 66, 1583, 1585, 1585, 1585, - 70, 73, 68, 73, 80, 80, 84, 1567, 89, 92, - 95, 98, 102, 105, 110, 113, 120, 123, 126, 129, - 134, 137, 151, 159, 169, 165, 1516, 150, 209, 1585, - 1585, 1560, 1585, 1585, 1567, 124, 1585, 181, 1585, 64, - 179, 189, 192, 237, 195, 1585, 0, 0, 1585, 200, - 211, 242, 206, 248, 252, 255, 258, 264, 267, 270, - 274, 277, 281, 285, 288, 291, 294, 300, 303, 309, - 315, 320, 332, 337, 342, 348, 351, 355, 358, 1585, - 369, 391, 1534, 1553, 186, 1521, 96, 1529, 72, 286, - - 1524, 332, 1517, 324, 1530, 65, 108, 1517, 1520, 1515, - 1585, 370, 222, 382, 0, 0, 390, 417, 420, 423, - 426, 429, 432, 435, 438, 441, 444, 449, 452, 455, - 458, 466, 471, 481, 484, 492, 495, 498, 501, 506, - 509, 512, 524, 527, 532, 537, 541, 1540, 253, 140, - 1515, 1542, 1515, 1520, 1541, 1507, 326, 1517, 1515, 429, - 1517, 148, 1499, 1585, 1501, 1512, 1511, 294, 1495, 1508, - 1493, 1509, 1492, 1503, 1498, 1516, 1487, 1492, 1488, 1493, - 1485, 1496, 546, 242, 553, 559, 564, 568, 575, 578, - 582, 585, 593, 596, 599, 602, 605, 608, 611, 614, - - 617, 620, 623, 626, 640, 631, 643, 650, 660, 664, - 667, 680, 685, 688, 691, 694, 1496, 1483, 1493, 1491, - 1490, 1490, 1473, 1469, 1585, 1585, 1486, 1476, 1471, 1477, - 1471, 1509, 1471, 1473, 1478, 1477, 1466, 1472, 1460, 1469, - 1459, 1458, 362, 1458, 242, 1497, 1468, 1467, 1453, 1452, - 1585, 390, 698, 703, 706, 710, 718, 727, 742, 745, - 748, 751, 754, 757, 760, 763, 766, 770, 773, 776, - 784, 787, 790, 793, 796, 805, 813, 820, 825, 829, - 1450, 1451, 1449, 1447, 1460, 1455, 1448, 1446, 1442, 1455, - 1458, 1444, 1441, 1437, 1442, 1448, 1448, 1438, 1440, 1436, - - 1443, 1465, 1434, 1423, 1440, 1430, 1428, 1428, 1430, 456, - 1463, 1420, 832, 846, 836, 839, 867, 872, 850, 875, - 880, 883, 886, 889, 893, 896, 899, 902, 905, 908, - 916, 919, 923, 929, 1427, 1420, 650, 1425, 1419, 1421, - 1415, 1414, 1415, 1429, 1409, 1424, 1409, 1422, 1408, 1415, - 1419, 1418, 1416, 1407, 1405, 1405, 1408, 1398, 1438, 1435, - 1395, 1408, 1402, 1396, 1404, 1394, 1406, 932, 935, 945, - 948, 966, 969, 974, 979, 982, 990, 995, 1001, 1005, - 1010, 1013, 1016, 1021, 1024, 1027, 1030, 1033, 1036, 1401, - 1428, 1396, 1398, 1397, 1385, 1395, 1381, 1391, 1388, 1391, - - 1390, 1378, 1388, 1387, 1585, 1386, 1385, 1378, 1394, 1410, - 508, 1385, 1369, 1375, 1365, 1374, 1367, 1368, 1370, 1373, - 1364, 1372, 1374, 1370, 1362, 1041, 1044, 1047, 1062, 1066, - 1069, 1072, 1075, 1078, 1089, 1097, 1100, 1105, 1108, 1111, - 1114, 1117, 1120, 1585, 1358, 1370, 1369, 1362, 1359, 1585, - 185, 1585, 1353, 1362, 1585, 1388, 1348, 1585, 1585, 1585, - 1358, 1339, 1347, 1346, 1354, 1347, 1345, 1338, 1346, 1340, - 1349, 1343, 1337, 1585, 1345, 1344, 1344, 1342, 1369, 1123, - 1128, 1132, 1135, 1138, 1150, 1153, 1161, 1164, 1167, 1173, - 1176, 1179, 1186, 1341, 1328, 1339, 1365, 1323, 1324, 1325, - - 1325, 391, 1323, 1319, 1585, 1320, 1330, 1329, 1331, 1348, - 1313, 1320, 1327, 1314, 1321, 1305, 1284, 1585, 1585, 1290, - 1585, 1283, 1191, 1194, 1201, 1204, 1207, 1210, 1217, 1221, - 1224, 1228, 1231, 1238, 1241, 1278, 1296, 1294, 1255, 1259, - 1245, 389, 1585, 1244, 1247, 1221, 1218, 1217, 1212, 1211, - 1200, 1190, 1585, 1182, 1171, 1191, 1585, 1148, 1141, 1136, - 1133, 1244, 1250, 1259, 1262, 1265, 1268, 1271, 1274, 1277, - 1280, 1585, 1109, 1106, 1097, 1139, 1099, 1091, 1073, 1092, - 1063, 1058, 1084, 1585, 1585, 1585, 1051, 1051, 1042, 1042, - 1014, 1020, 1585, 1046, 1019, 1285, 1292, 1297, 1305, 1308, - - 1311, 1014, 1003, 975, 958, 974, 965, 947, 1585, 953, - 1585, 942, 938, 935, 932, 916, 928, 914, 915, 919, - 1317, 1320, 1323, 917, 915, 902, 906, 888, 932, 903, - 891, 891, 906, 863, 863, 846, 829, 813, 823, 820, - 1330, 817, 809, 836, 798, 777, 775, 808, 764, 774, - 763, 767, 769, 750, 1585, 1585, 747, 733, 732, 722, - 695, 701, 700, 702, 686, 722, 1585, 690, 688, 673, - 681, 1585, 706, 705, 701, 666, 650, 669, 623, 635, - 612, 619, 1585, 613, 603, 602, 592, 591, 593, 580, - 526, 510, 504, 500, 1585, 485, 478, 484, 483, 480, - - 1585, 459, 453, 479, 1585, 443, 417, 439, 374, 367, - 353, 343, 339, 322, 1585, 338, 273, 1585, 1585, 1585, - 271, 1585, 263, 193, 190, 1585, 152, 122, 96, 1585, - 80, 1585, 1585, 1585, 1342, 1346, 1350, 1354, 1356, 1358, - 1362, 92 - } ; - -static yyconst flex_int16_t yy_def[743] = - { 0, - 734, 1, 735, 735, 736, 736, 734, 734, 734, 734, - 737, 738, 734, 739, 734, 734, 734, 734, 740, 740, - 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 740, 740, 740, 740, 740, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 737, 734, 738, 734, 734, - 734, 739, 739, 739, 739, 734, 741, 742, 734, 740, - 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 740, 740, 740, 740, 740, 740, 740, 740, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 739, 739, 741, 742, 740, 740, 740, 740, - 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 740, 740, 740, 740, 740, 740, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 739, 739, 740, 740, 740, 740, - 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, - - 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 740, 740, 740, 740, 740, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 740, 740, 740, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 740, 740, 740, - 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 740, 740, 740, 740, 740, 740, 740, 740, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 740, 740, 740, 740, 740, - 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 740, 740, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 740, - 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 740, 740, 734, 734, 734, 734, 734, 734, 734, - - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 740, 740, 740, 740, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 740, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 740, 740, 740, 740, 740, - - 740, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 740, 740, 740, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 740, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 0, 734, 734, 734, 734, 734, 734, - 734, 734 - } ; - -static yyconst flex_int16_t yy_nxt[1651] = - { 0, - 8, 9, 10, 9, 11, 8, 12, 8, 8, 13, - 14, 15, 16, 17, 18, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 20, 19, - 19, 19, 19, 21, 19, 19, 19, 19, 19, 19, - 19, 19, 22, 23, 24, 25, 26, 19, 19, 27, - 19, 28, 19, 29, 30, 31, 19, 32, 33, 34, - 35, 36, 19, 19, 37, 38, 44, 41, 44, 39, - 42, 45, 47, 45, 47, 49, 112, 112, 50, 49, - 51, 51, 52, 53, 52, 54, 54, 56, 176, 162, - 50, 57, 51, 51, 50, 116, 51, 51, 52, 55, - - 52, 52, 55, 52, 52, 55, 52, 52, 55, 52, - 177, 52, 55, 52, 52, 55, 52, 163, 62, 52, - 55, 52, 52, 55, 52, 733, 47, 61, 47, 52, - 55, 52, 52, 55, 52, 52, 55, 52, 52, 55, - 52, 732, 58, 52, 55, 52, 52, 55, 52, 159, - 64, 91, 63, 65, 70, 92, 66, 178, 160, 67, - 52, 55, 52, 68, 71, 230, 731, 74, 52, 55, - 52, 179, 69, 72, 52, 55, 52, 73, 52, 55, - 52, 218, 231, 49, 75, 78, 79, 49, 80, 50, - 76, 51, 51, 77, 219, 81, 82, 730, 52, 83, - - 52, 52, 113, 52, 52, 499, 52, 84, 89, 52, - 55, 52, 86, 156, 85, 52, 55, 52, 87, 500, - 52, 55, 52, 88, 93, 94, 95, 96, 97, 98, - 99, 52, 100, 52, 729, 101, 102, 117, 103, 104, - 157, 105, 106, 107, 108, 109, 52, 728, 52, 54, - 54, 52, 55, 52, 252, 252, 114, 52, 55, 52, - 119, 52, 55, 52, 52, 55, 52, 52, 55, 52, - 306, 307, 118, 52, 55, 52, 52, 55, 52, 52, - 55, 52, 114, 52, 55, 52, 52, 55, 52, 120, - 52, 55, 52, 121, 52, 55, 52, 52, 55, 52, - - 52, 55, 52, 52, 55, 52, 159, 727, 122, 52, - 55, 52, 52, 55, 52, 217, 726, 123, 52, 55, - 52, 126, 125, 124, 52, 55, 52, 725, 127, 52, - 55, 52, 164, 131, 129, 128, 134, 130, 165, 166, - 132, 52, 55, 52, 236, 133, 52, 55, 52, 237, - 136, 52, 55, 52, 135, 724, 138, 52, 55, 52, - 52, 55, 52, 137, 52, 55, 52, 52, 55, 52, - 91, 139, 140, 168, 92, 172, 723, 169, 173, 223, - 174, 224, 112, 112, 722, 303, 170, 721, 141, 183, - 184, 185, 304, 52, 186, 186, 142, 143, 720, 52, - - 55, 52, 252, 252, 146, 144, 147, 145, 148, 544, - 149, 98, 719, 545, 100, 183, 187, 101, 150, 718, - 103, 151, 578, 579, 152, 153, 52, 55, 52, 52, - 55, 52, 52, 55, 52, 52, 55, 52, 52, 55, - 52, 52, 55, 52, 52, 55, 52, 52, 55, 52, - 52, 55, 52, 52, 55, 52, 717, 188, 52, 55, - 52, 52, 55, 52, 52, 55, 52, 52, 55, 52, - 716, 189, 227, 364, 193, 52, 55, 52, 365, 190, - 52, 55, 52, 191, 228, 197, 192, 194, 715, 195, - 52, 55, 52, 52, 55, 52, 714, 713, 196, 198, - - 199, 52, 55, 52, 52, 55, 52, 52, 55, 52, - 52, 55, 52, 712, 200, 52, 55, 52, 52, 55, - 52, 52, 55, 52, 711, 464, 201, 710, 709, 202, - 465, 708, 203, 52, 55, 52, 52, 55, 52, 707, - 204, 52, 55, 52, 706, 205, 52, 55, 52, 705, - 52, 55, 52, 206, 184, 184, 207, 211, 252, 252, - 208, 209, 52, 210, 52, 186, 186, 704, 52, 212, - 52, 186, 186, 52, 55, 52, 213, 52, 55, 52, - 703, 215, 216, 253, 52, 55, 52, 52, 55, 52, - 214, 52, 55, 52, 52, 55, 52, 702, 254, 255, - - 256, 257, 52, 55, 52, 52, 55, 52, 52, 55, - 52, 52, 55, 52, 52, 55, 52, 52, 55, 52, - 52, 55, 52, 52, 55, 52, 52, 55, 52, 52, - 55, 52, 52, 55, 52, 52, 55, 52, 701, 258, - 52, 55, 52, 259, 260, 700, 699, 262, 261, 52, - 55, 52, 52, 55, 52, 265, 698, 697, 266, 52, - 55, 52, 696, 263, 695, 267, 694, 392, 264, 52, - 55, 52, 268, 52, 55, 52, 52, 55, 52, 693, - 692, 270, 393, 394, 269, 271, 691, 395, 272, 52, - 55, 52, 273, 274, 52, 55, 52, 52, 55, 52, - - 52, 55, 52, 52, 55, 52, 690, 52, 55, 52, - 689, 275, 52, 55, 52, 52, 55, 52, 688, 52, - 55, 52, 687, 686, 277, 276, 313, 52, 55, 52, - 685, 684, 278, 683, 682, 315, 52, 55, 52, 681, - 680, 317, 314, 679, 318, 678, 677, 279, 316, 676, - 280, 52, 55, 52, 52, 55, 52, 52, 55, 52, - 52, 55, 52, 52, 55, 52, 52, 55, 52, 52, - 55, 52, 52, 55, 52, 52, 55, 52, 675, 52, - 55, 52, 52, 55, 52, 52, 55, 52, 674, 673, - 319, 320, 672, 52, 55, 52, 52, 55, 52, 52, - - 55, 52, 52, 55, 52, 52, 55, 52, 671, 324, - 670, 669, 321, 325, 52, 55, 52, 668, 322, 667, - 666, 323, 52, 55, 52, 665, 664, 326, 327, 52, - 55, 52, 663, 328, 52, 55, 52, 330, 52, 55, - 52, 52, 55, 52, 662, 52, 55, 52, 52, 55, - 52, 329, 375, 661, 660, 52, 55, 52, 331, 52, - 55, 52, 659, 369, 370, 658, 333, 657, 376, 334, - 656, 368, 371, 332, 655, 372, 52, 55, 52, 373, - 374, 52, 55, 52, 52, 55, 52, 654, 377, 52, - 55, 52, 52, 55, 52, 52, 55, 52, 52, 55, - - 52, 378, 52, 55, 52, 52, 55, 52, 52, 55, - 52, 52, 55, 52, 52, 55, 52, 52, 55, 52, - 653, 380, 652, 651, 379, 52, 55, 52, 52, 55, - 52, 382, 52, 55, 52, 650, 649, 381, 52, 55, - 52, 52, 55, 52, 52, 55, 52, 383, 648, 647, - 427, 646, 645, 384, 52, 55, 52, 52, 55, 52, - 644, 643, 386, 642, 387, 426, 385, 640, 428, 639, - 638, 429, 637, 636, 388, 52, 55, 52, 52, 55, - 52, 635, 430, 52, 55, 52, 634, 389, 52, 55, - 52, 52, 55, 52, 633, 431, 632, 631, 435, 52, - - 55, 52, 630, 434, 52, 55, 52, 629, 628, 432, - 52, 55, 52, 433, 52, 55, 52, 627, 436, 52, - 55, 52, 52, 55, 52, 52, 55, 52, 626, 437, - 52, 55, 52, 52, 55, 52, 52, 55, 52, 52, - 55, 52, 52, 55, 52, 52, 55, 52, 439, 625, - 52, 55, 52, 52, 55, 52, 52, 55, 52, 438, - 624, 441, 620, 619, 482, 618, 440, 480, 617, 442, - 481, 52, 55, 52, 443, 52, 55, 52, 52, 55, - 52, 52, 55, 52, 52, 55, 52, 52, 55, 52, - 484, 616, 485, 615, 614, 483, 613, 488, 52, 55, - - 52, 612, 486, 611, 610, 487, 52, 55, 52, 52, - 55, 52, 490, 489, 52, 55, 52, 52, 55, 52, - 52, 55, 52, 52, 55, 52, 52, 55, 52, 52, - 55, 52, 52, 55, 52, 609, 608, 52, 55, 52, - 491, 52, 55, 52, 52, 55, 52, 52, 55, 52, - 607, 606, 523, 492, 524, 605, 604, 527, 493, 52, - 55, 52, 52, 55, 52, 603, 525, 528, 602, 526, - 52, 55, 52, 52, 55, 52, 52, 55, 52, 529, - 530, 531, 52, 55, 52, 52, 55, 52, 52, 55, - 52, 595, 594, 534, 535, 52, 55, 52, 593, 533, - - 52, 55, 52, 52, 55, 52, 592, 532, 591, 563, - 52, 55, 52, 52, 55, 52, 52, 55, 52, 52, - 55, 52, 590, 589, 564, 562, 52, 55, 52, 565, - 52, 55, 52, 52, 55, 52, 566, 52, 55, 52, - 52, 55, 52, 588, 587, 568, 569, 52, 55, 52, - 52, 55, 52, 52, 55, 52, 586, 585, 567, 52, - 55, 52, 584, 583, 571, 582, 596, 570, 52, 55, - 52, 52, 55, 52, 52, 55, 52, 52, 55, 52, - 52, 55, 52, 52, 55, 52, 52, 55, 52, 52, - 55, 52, 581, 597, 52, 55, 52, 599, 580, 577, - - 598, 52, 55, 52, 576, 600, 52, 55, 52, 575, - 574, 621, 573, 601, 52, 55, 52, 52, 55, 52, - 52, 55, 52, 572, 561, 622, 52, 55, 52, 52, - 55, 52, 52, 55, 52, 560, 641, 559, 623, 52, - 55, 52, 40, 40, 40, 40, 43, 43, 43, 43, - 46, 46, 46, 46, 48, 48, 48, 48, 55, 55, - 60, 60, 115, 558, 115, 115, 557, 556, 555, 554, - 553, 552, 551, 550, 549, 548, 547, 546, 543, 542, - 541, 540, 539, 538, 537, 536, 522, 521, 520, 519, - 518, 517, 516, 515, 514, 513, 512, 511, 510, 509, - - 508, 507, 506, 505, 504, 503, 502, 501, 498, 497, - 496, 495, 494, 479, 478, 477, 476, 475, 474, 473, - 472, 471, 470, 469, 468, 467, 466, 463, 462, 461, - 460, 459, 458, 457, 456, 455, 454, 453, 452, 451, - 450, 449, 448, 447, 446, 445, 444, 425, 424, 423, - 422, 421, 420, 419, 418, 417, 416, 415, 414, 413, - 412, 411, 410, 409, 408, 407, 406, 405, 404, 403, - 402, 401, 400, 399, 398, 397, 396, 391, 390, 367, - 366, 363, 362, 361, 360, 359, 358, 357, 356, 355, - 354, 353, 352, 351, 350, 349, 348, 347, 346, 345, - - 344, 343, 342, 341, 340, 339, 338, 337, 336, 335, - 312, 311, 310, 309, 308, 305, 302, 301, 300, 299, - 298, 297, 296, 295, 294, 293, 292, 291, 290, 289, - 288, 287, 286, 285, 284, 283, 282, 281, 237, 227, - 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, - 241, 240, 239, 238, 235, 234, 233, 232, 229, 226, - 225, 222, 221, 220, 178, 176, 172, 156, 182, 181, - 180, 175, 171, 167, 161, 158, 155, 154, 111, 110, - 90, 59, 734, 41, 7, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734 - } ; - -static yyconst flex_int16_t yy_chk[1651] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 2, 5, 4, 6, 2, - 4, 5, 11, 6, 11, 12, 50, 50, 13, 12, - 13, 13, 14, 14, 14, 14, 14, 15, 106, 99, - 16, 15, 16, 16, 17, 742, 17, 17, 19, 19, - - 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, - 106, 23, 23, 23, 24, 24, 24, 99, 21, 25, - 25, 25, 26, 26, 26, 731, 46, 20, 46, 27, - 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, - 30, 729, 16, 31, 31, 31, 32, 32, 32, 97, - 23, 38, 22, 23, 26, 38, 23, 107, 97, 24, - 33, 33, 33, 25, 26, 162, 728, 29, 34, 34, - 34, 107, 25, 27, 36, 36, 36, 28, 35, 35, - 35, 150, 162, 48, 30, 32, 32, 48, 32, 51, - 31, 51, 51, 31, 150, 32, 33, 727, 52, 33, - - 52, 53, 53, 53, 55, 451, 55, 33, 36, 60, - 60, 60, 34, 95, 33, 63, 63, 63, 35, 451, - 61, 61, 61, 35, 39, 39, 39, 39, 39, 39, - 39, 113, 39, 113, 725, 39, 39, 61, 39, 39, - 95, 39, 39, 39, 39, 39, 54, 724, 54, 54, - 54, 62, 62, 62, 184, 184, 54, 64, 64, 64, - 63, 65, 65, 65, 66, 66, 66, 67, 67, 67, - 245, 245, 62, 68, 68, 68, 69, 69, 69, 70, - 70, 70, 54, 71, 71, 71, 72, 72, 72, 64, - 73, 73, 73, 65, 74, 74, 74, 75, 75, 75, - - 76, 76, 76, 77, 77, 77, 149, 723, 66, 78, - 78, 78, 79, 79, 79, 149, 721, 67, 80, 80, - 80, 70, 69, 68, 81, 81, 81, 717, 71, 82, - 82, 82, 100, 75, 73, 72, 77, 74, 100, 100, - 76, 83, 83, 83, 168, 76, 84, 84, 84, 168, - 79, 85, 85, 85, 78, 716, 81, 86, 86, 86, - 87, 87, 87, 80, 88, 88, 88, 89, 89, 89, - 91, 81, 82, 102, 91, 104, 714, 102, 104, 157, - 104, 157, 112, 112, 713, 243, 102, 712, 83, 112, - 114, 114, 243, 114, 114, 114, 84, 85, 711, 117, - - 117, 117, 252, 252, 88, 86, 89, 87, 92, 502, - 92, 92, 710, 502, 92, 112, 117, 92, 92, 709, - 92, 92, 542, 542, 92, 92, 118, 118, 118, 119, - 119, 119, 120, 120, 120, 121, 121, 121, 122, 122, - 122, 123, 123, 123, 124, 124, 124, 125, 125, 125, - 126, 126, 126, 127, 127, 127, 708, 118, 128, 128, - 128, 129, 129, 129, 130, 130, 130, 131, 131, 131, - 707, 119, 160, 310, 123, 132, 132, 132, 310, 120, - 133, 133, 133, 121, 160, 127, 122, 124, 706, 125, - 134, 134, 134, 135, 135, 135, 704, 703, 126, 129, - - 130, 136, 136, 136, 137, 137, 137, 138, 138, 138, - 139, 139, 139, 702, 131, 140, 140, 140, 141, 141, - 141, 142, 142, 142, 700, 411, 132, 699, 698, 133, - 411, 697, 134, 143, 143, 143, 144, 144, 144, 696, - 135, 145, 145, 145, 694, 136, 146, 146, 146, 693, - 147, 147, 147, 137, 183, 183, 138, 142, 183, 183, - 139, 140, 185, 141, 185, 185, 185, 692, 186, 143, - 186, 186, 186, 187, 187, 187, 144, 188, 188, 188, - 691, 146, 147, 188, 189, 189, 189, 190, 190, 190, - 145, 191, 191, 191, 192, 192, 192, 690, 188, 188, - - 188, 188, 193, 193, 193, 194, 194, 194, 195, 195, - 195, 196, 196, 196, 197, 197, 197, 198, 198, 198, - 199, 199, 199, 200, 200, 200, 201, 201, 201, 202, - 202, 202, 203, 203, 203, 204, 204, 204, 689, 191, - 206, 206, 206, 192, 193, 688, 687, 196, 195, 205, - 205, 205, 207, 207, 207, 200, 686, 685, 201, 208, - 208, 208, 684, 197, 682, 202, 681, 337, 199, 209, - 209, 209, 203, 210, 210, 210, 211, 211, 211, 680, - 679, 205, 337, 337, 204, 205, 678, 337, 206, 212, - 212, 212, 207, 208, 213, 213, 213, 214, 214, 214, - - 215, 215, 215, 216, 216, 216, 677, 253, 253, 253, - 676, 209, 254, 254, 254, 255, 255, 255, 675, 256, - 256, 256, 674, 673, 212, 210, 253, 257, 257, 257, - 671, 670, 213, 669, 668, 255, 258, 258, 258, 666, - 665, 257, 254, 664, 257, 663, 662, 214, 256, 661, - 216, 259, 259, 259, 260, 260, 260, 261, 261, 261, - 262, 262, 262, 263, 263, 263, 264, 264, 264, 265, - 265, 265, 266, 266, 266, 267, 267, 267, 660, 268, - 268, 268, 269, 269, 269, 270, 270, 270, 659, 658, - 260, 261, 657, 271, 271, 271, 272, 272, 272, 273, - - 273, 273, 274, 274, 274, 275, 275, 275, 654, 267, - 653, 652, 264, 268, 276, 276, 276, 651, 265, 650, - 649, 266, 277, 277, 277, 648, 647, 270, 271, 278, - 278, 278, 646, 273, 279, 279, 279, 275, 280, 280, - 280, 313, 313, 313, 645, 315, 315, 315, 316, 316, - 316, 274, 315, 644, 643, 314, 314, 314, 277, 319, - 319, 319, 642, 314, 314, 640, 279, 639, 316, 280, - 638, 313, 314, 278, 637, 314, 317, 317, 317, 314, - 314, 318, 318, 318, 320, 320, 320, 636, 317, 321, - 321, 321, 322, 322, 322, 323, 323, 323, 324, 324, - - 324, 318, 325, 325, 325, 326, 326, 326, 327, 327, - 327, 328, 328, 328, 329, 329, 329, 330, 330, 330, - 635, 321, 634, 633, 320, 331, 331, 331, 332, 332, - 332, 323, 333, 333, 333, 632, 631, 322, 334, 334, - 334, 368, 368, 368, 369, 369, 369, 324, 630, 629, - 369, 628, 627, 326, 370, 370, 370, 371, 371, 371, - 626, 625, 331, 624, 332, 368, 330, 620, 370, 619, - 618, 371, 617, 616, 333, 372, 372, 372, 373, 373, - 373, 615, 372, 374, 374, 374, 614, 334, 375, 375, - 375, 376, 376, 376, 613, 373, 612, 610, 376, 377, - - 377, 377, 608, 375, 378, 378, 378, 607, 606, 374, - 379, 379, 379, 374, 380, 380, 380, 605, 377, 381, - 381, 381, 382, 382, 382, 383, 383, 383, 604, 378, - 384, 384, 384, 385, 385, 385, 386, 386, 386, 387, - 387, 387, 388, 388, 388, 389, 389, 389, 380, 603, - 426, 426, 426, 427, 427, 427, 428, 428, 428, 379, - 602, 383, 595, 594, 428, 592, 381, 426, 591, 385, - 427, 429, 429, 429, 387, 430, 430, 430, 431, 431, - 431, 432, 432, 432, 433, 433, 433, 434, 434, 434, - 430, 590, 431, 589, 588, 429, 587, 434, 435, 435, - - 435, 583, 432, 582, 581, 433, 436, 436, 436, 437, - 437, 437, 436, 435, 438, 438, 438, 439, 439, 439, - 440, 440, 440, 441, 441, 441, 442, 442, 442, 443, - 443, 443, 480, 480, 480, 580, 579, 481, 481, 481, - 437, 482, 482, 482, 483, 483, 483, 484, 484, 484, - 578, 577, 480, 439, 481, 576, 575, 484, 441, 485, - 485, 485, 486, 486, 486, 574, 482, 485, 573, 483, - 487, 487, 487, 488, 488, 488, 489, 489, 489, 486, - 487, 488, 490, 490, 490, 491, 491, 491, 492, 492, - 492, 561, 560, 491, 491, 493, 493, 493, 559, 490, - - 523, 523, 523, 524, 524, 524, 558, 489, 556, 524, - 525, 525, 525, 526, 526, 526, 527, 527, 527, 528, - 528, 528, 555, 554, 527, 523, 529, 529, 529, 528, - 530, 530, 530, 531, 531, 531, 529, 532, 532, 532, - 533, 533, 533, 552, 551, 532, 532, 534, 534, 534, - 535, 535, 535, 562, 562, 562, 550, 549, 531, 563, - 563, 563, 548, 547, 535, 546, 563, 534, 564, 564, - 564, 565, 565, 565, 566, 566, 566, 567, 567, 567, - 568, 568, 568, 569, 569, 569, 570, 570, 570, 571, - 571, 571, 545, 564, 596, 596, 596, 569, 544, 541, - - 568, 597, 597, 597, 540, 570, 598, 598, 598, 539, - 538, 596, 537, 571, 599, 599, 599, 600, 600, 600, - 601, 601, 601, 536, 522, 598, 621, 621, 621, 622, - 622, 622, 623, 623, 623, 520, 621, 517, 599, 641, - 641, 641, 735, 735, 735, 735, 736, 736, 736, 736, - 737, 737, 737, 737, 738, 738, 738, 738, 739, 739, - 740, 740, 741, 516, 741, 741, 515, 514, 513, 512, - 511, 510, 509, 508, 507, 506, 504, 503, 501, 500, - 499, 498, 497, 496, 495, 494, 479, 478, 477, 476, - 475, 473, 472, 471, 470, 469, 468, 467, 466, 465, - - 464, 463, 462, 461, 457, 456, 454, 453, 449, 448, - 447, 446, 445, 425, 424, 423, 422, 421, 420, 419, - 418, 417, 416, 415, 414, 413, 412, 410, 409, 408, - 407, 406, 404, 403, 402, 401, 400, 399, 398, 397, - 396, 395, 394, 393, 392, 391, 390, 367, 366, 365, - 364, 363, 362, 361, 360, 359, 358, 357, 356, 355, - 354, 353, 352, 351, 350, 349, 348, 347, 346, 345, - 344, 343, 342, 341, 340, 339, 338, 336, 335, 312, - 311, 309, 308, 307, 306, 305, 304, 303, 302, 301, - 300, 299, 298, 297, 296, 295, 294, 293, 292, 291, - - 290, 289, 288, 287, 286, 285, 284, 283, 282, 281, - 250, 249, 248, 247, 246, 244, 242, 241, 240, 239, - 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, - 228, 227, 224, 223, 222, 221, 220, 219, 218, 217, - 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, - 172, 171, 170, 169, 167, 166, 165, 163, 161, 159, - 158, 156, 155, 154, 153, 152, 151, 148, 110, 109, - 108, 105, 103, 101, 98, 96, 94, 93, 45, 42, - 37, 18, 7, 3, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 734, 734, 734, 734, 734 - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -extern int yy_flex_debug; -int yy_flex_debug = 0; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *yytext; -#line 1 "lexer.l" -/* - * The SIP lexer. - * - * Copyright (c) 2007 - * Riverbank Computing Limited <info@riverbankcomputing.co.uk> - * - * This file is part of SIP. - * - * This copy of SIP is licensed for use under the terms of the SIP License - * Agreement. See the file LICENSE for more details. - * - * SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ -#line 17 "lexer.l" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> - -#include "sip.h" -#include "parser.h" - - -#ifndef FLEX_SCANNER -#error "Only flex is supported at the moment" -#endif - - -#define YY_FATAL_ERROR(s) fatallex(s) - -#define MAX_INCLUDE_DEPTH 10 -#define MAX_CODE_LINE_LENGTH 1000 - - -static struct inputFile { - int lineno; /* The line number. */ - YY_BUFFER_STATE bs; /* The flex buffer state handle. */ - char *name; /* The file name. */ - char *cwd; /* The path part of the file name. */ - parserContext pc; /* The parser context. */ -} inputFileStack[MAX_INCLUDE_DEPTH]; - -static int currentFile = -1; /* Index of the current input file. */ -static char codeLine[MAX_CODE_LINE_LENGTH + 2]; /* The current code line. */ -static int codeIdx = -1; /* Index of next code character. */ - -static FILE *openFile(char *); -static void fatallex(char *); - - -#line 1113 "lexer.c.tmp" - -#define INITIAL 0 -#define code 1 -#define ccomment 2 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ - -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -static int yy_init_globals (void ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap (void ); -#else -extern int yywrap (void ); -#endif -#endif - - static void yyunput (int c,char *buf_ptr ); - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (void ); -#else -static int input (void ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - size_t n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (void); - -#define YY_DECL int yylex (void) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - if ( yyleng > 0 ) \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ - (yytext[yyleng - 1] == '\n'); \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 56 "lexer.l" - - -#line 1274 "lexer.c.tmp" - - if ( !(yy_init) ) - { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); - } - - yy_load_buffer_state( ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = (yy_c_buf_p); - - /* Support of yytext. */ - *yy_cp = (yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = (yy_start); - yy_current_state += YY_AT_BOL(); -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 735 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 1585 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = (yy_hold_char); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 58 "lexer.l" -{return TK_OPTIONS;} - YY_BREAK -case 2: -YY_RULE_SETUP -#line 59 "lexer.l" -{return TK_NOEMITTERS;} - YY_BREAK -case 3: -YY_RULE_SETUP -#line 60 "lexer.l" -{return TK_INCLUDE;} - YY_BREAK -case 4: -YY_RULE_SETUP -#line 61 "lexer.l" -{return TK_OPTINCLUDE;} - YY_BREAK -case 5: -YY_RULE_SETUP -#line 62 "lexer.l" -{return TK_IMPORT;} - YY_BREAK -case 6: -YY_RULE_SETUP -#line 63 "lexer.l" -{return TK_MODULE;} - YY_BREAK -case 7: -YY_RULE_SETUP -#line 64 "lexer.l" -{return TK_CMODULE;} - YY_BREAK -case 8: -YY_RULE_SETUP -#line 65 "lexer.l" -{return TK_TIMELINE;} - YY_BREAK -case 9: -YY_RULE_SETUP -#line 66 "lexer.l" -{return TK_PLATFORMS;} - YY_BREAK -case 10: -YY_RULE_SETUP -#line 67 "lexer.l" -{return TK_FEATURE;} - YY_BREAK -case 11: -YY_RULE_SETUP -#line 68 "lexer.l" -{return TK_LICENSE;} - YY_BREAK -case 12: -YY_RULE_SETUP -#line 69 "lexer.l" -{return TK_MAPPEDTYPE;} - YY_BREAK -case 13: -YY_RULE_SETUP -#line 70 "lexer.l" -{return TK_EXCEPTION;} - YY_BREAK -case 14: -YY_RULE_SETUP -#line 71 "lexer.l" -{return TK_IF;} - YY_BREAK -case 15: -YY_RULE_SETUP -#line 72 "lexer.l" -{return TK_END;} - YY_BREAK -case 16: -YY_RULE_SETUP -#line 73 "lexer.l" -{return TK_CLASS;} - YY_BREAK -case 17: -YY_RULE_SETUP -#line 74 "lexer.l" -{return TK_STRUCT;} - YY_BREAK -case 18: -YY_RULE_SETUP -#line 75 "lexer.l" -{return TK_PUBLIC;} - YY_BREAK -case 19: -YY_RULE_SETUP -#line 76 "lexer.l" -{return TK_PROTECTED;} - YY_BREAK -case 20: -YY_RULE_SETUP -#line 77 "lexer.l" -{return TK_PRIVATE;} - YY_BREAK -case 21: -YY_RULE_SETUP -#line 78 "lexer.l" -{return TK_SIGNALS;} - YY_BREAK -case 22: -YY_RULE_SETUP -#line 79 "lexer.l" -{return TK_SLOTS;} - YY_BREAK -case 23: -YY_RULE_SETUP -#line 80 "lexer.l" -{return TK_CHAR;} - YY_BREAK -case 24: -YY_RULE_SETUP -#line 81 "lexer.l" -{return TK_WCHAR_T;} - YY_BREAK -case 25: -YY_RULE_SETUP -#line 82 "lexer.l" -{return TK_BOOL;} - YY_BREAK -case 26: -YY_RULE_SETUP -#line 83 "lexer.l" -{return TK_SHORT;} - YY_BREAK -case 27: -YY_RULE_SETUP -#line 84 "lexer.l" -{return TK_INT;} - YY_BREAK -case 28: -YY_RULE_SETUP -#line 85 "lexer.l" -{return TK_LONG;} - YY_BREAK -case 29: -YY_RULE_SETUP -#line 86 "lexer.l" -{return TK_FLOAT;} - YY_BREAK -case 30: -YY_RULE_SETUP -#line 87 "lexer.l" -{return TK_DOUBLE;} - YY_BREAK -case 31: -YY_RULE_SETUP -#line 88 "lexer.l" -{return TK_VOID;} - YY_BREAK -case 32: -YY_RULE_SETUP -#line 89 "lexer.l" -{return TK_VIRTUAL;} - YY_BREAK -case 33: -YY_RULE_SETUP -#line 90 "lexer.l" -{return TK_ENUM;} - YY_BREAK -case 34: -YY_RULE_SETUP -#line 91 "lexer.l" -{return TK_SIGNED;} - YY_BREAK -case 35: -YY_RULE_SETUP -#line 92 "lexer.l" -{return TK_UNSIGNED;} - YY_BREAK -case 36: -YY_RULE_SETUP -#line 93 "lexer.l" -{return TK_CONST;} - YY_BREAK -case 37: -YY_RULE_SETUP -#line 94 "lexer.l" -{return TK_STATIC;} - YY_BREAK -case 38: -YY_RULE_SETUP -#line 95 "lexer.l" -{return TK_TRUE;} - YY_BREAK -case 39: -YY_RULE_SETUP -#line 96 "lexer.l" -{return TK_FALSE;} - YY_BREAK -case 40: -YY_RULE_SETUP -#line 97 "lexer.l" -{return TK_NULL;} - YY_BREAK -case 41: -YY_RULE_SETUP -#line 98 "lexer.l" -{return TK_TYPEDEF;} - YY_BREAK -case 42: -YY_RULE_SETUP -#line 99 "lexer.l" -{return TK_NAMESPACE;} - YY_BREAK -case 43: -YY_RULE_SETUP -#line 100 "lexer.l" -{return TK_OPERATOR;} - YY_BREAK -case 44: -YY_RULE_SETUP -#line 101 "lexer.l" -{return TK_THROW;} - YY_BREAK -case 45: -YY_RULE_SETUP -#line 102 "lexer.l" -{return TK_EXPLICIT;} - YY_BREAK -case 46: -YY_RULE_SETUP -#line 103 "lexer.l" -{return TK_TEMPLATE;} - YY_BREAK -case 47: -YY_RULE_SETUP -#line 104 "lexer.l" -{return TK_SCOPE;} - YY_BREAK -case 48: -YY_RULE_SETUP -#line 105 "lexer.l" -{return TK_LOGICAL_OR;} - YY_BREAK -case 49: -YY_RULE_SETUP -#line 106 "lexer.l" -{return TK_PYOBJECT;} - YY_BREAK -case 50: -YY_RULE_SETUP -#line 107 "lexer.l" -{return TK_PYTUPLE;} - YY_BREAK -case 51: -YY_RULE_SETUP -#line 108 "lexer.l" -{return TK_PYLIST;} - YY_BREAK -case 52: -YY_RULE_SETUP -#line 109 "lexer.l" -{return TK_PYDICT;} - YY_BREAK -case 53: -YY_RULE_SETUP -#line 110 "lexer.l" -{return TK_PYCALLABLE;} - YY_BREAK -case 54: -YY_RULE_SETUP -#line 111 "lexer.l" -{return TK_PYSLICE;} - YY_BREAK -case 55: -YY_RULE_SETUP -#line 112 "lexer.l" -{return TK_PYTYPE;} - YY_BREAK -case 56: -YY_RULE_SETUP -#line 113 "lexer.l" -{return TK_SIPSIGNAL;} - YY_BREAK -case 57: -YY_RULE_SETUP -#line 114 "lexer.l" -{return TK_SIPSLOT;} - YY_BREAK -case 58: -YY_RULE_SETUP -#line 115 "lexer.l" -{return TK_SIPANYSLOT;} - YY_BREAK -case 59: -YY_RULE_SETUP -#line 116 "lexer.l" -{return TK_SIPRXCON;} - YY_BREAK -case 60: -YY_RULE_SETUP -#line 117 "lexer.l" -{return TK_SIPRXDIS;} - YY_BREAK -case 61: -YY_RULE_SETUP -#line 118 "lexer.l" -{return TK_SIPSLOTCON;} - YY_BREAK -case 62: -YY_RULE_SETUP -#line 119 "lexer.l" -{return TK_SIPSLOTDIS;} - YY_BREAK -case 63: -YY_RULE_SETUP -#line 120 "lexer.l" -{return TK_QOBJECT;} - YY_BREAK -case 64: -YY_RULE_SETUP -#line 121 "lexer.l" -{return TK_ELLIPSIS;} - YY_BREAK -case 65: -YY_RULE_SETUP -#line 124 "lexer.l" -{ /* Ignore whitespace. */ - ; -} - YY_BREAK -case 66: -/* rule 66 can match eol */ -YY_RULE_SETUP -#line 128 "lexer.l" -{ /* Maintain the line number. */ - ++inputFileStack[currentFile].lineno; - - if (codeIdx == 0) - { - BEGIN code; - } -} - YY_BREAK -case 67: -YY_RULE_SETUP -#line 137 "lexer.l" -{ /* Ignore C++ style comments. */ - ; -} - YY_BREAK -case 68: -YY_RULE_SETUP -#line 142 "lexer.l" -{ /* A signed decimal number. */ - yylval.number = strtol(yytext,NULL,0); - return TK_NUMBER; -} - YY_BREAK -case 69: -YY_RULE_SETUP -#line 148 "lexer.l" -{/* A floating point number. */ - yylval.real = strtod(yytext,NULL); - return TK_REAL; -} - YY_BREAK -case 70: -YY_RULE_SETUP -#line 154 "lexer.l" -{ /* An unsigned hexadecimal number. */ - yylval.number = strtol(yytext,NULL,16); - return TK_NUMBER; -} - YY_BREAK -case 71: -YY_RULE_SETUP -#line 160 "lexer.l" -{ /* An identifier name. */ - yylval.text = sipStrdup(yytext); - return TK_NAME; -} - YY_BREAK -case 72: -YY_RULE_SETUP -#line 166 "lexer.l" -{ /* A relative pathname. */ - yylval.text = sipStrdup(yytext); - return TK_PATHNAME; -} - YY_BREAK -case 73: -/* rule 73 can match eol */ -YY_RULE_SETUP -#line 172 "lexer.l" -{ /* A double-quoted string. */ - char *dp, *sp; - - /* Copy the string without the quotes. */ - - yylval.text = sipMalloc(strlen(yytext) + 1); - - dp = yylval.text; - sp = yytext; - - while (*sp != '\0') - { - if (*sp != '"') - *dp++ = *sp; - - ++sp; - } - - *dp = '\0'; - - return TK_STRING; -} - YY_BREAK -case 74: -/* rule 74 can match eol */ -YY_RULE_SETUP -#line 196 "lexer.l" -{ /* A single-quoted character. */ - if (strlen(yytext) != 3) - fatallex("Exactly one character expected between single quotes"); - - yylval.qchar = yytext[1]; - - return TK_QCHAR; -} - YY_BREAK -case 75: -YY_RULE_SETUP -#line 206 "lexer.l" -{ /* Ignore C-style comments. */ - BEGIN ccomment; -} - YY_BREAK -case 76: -/* rule 76 can match eol */ -YY_RULE_SETUP -#line 209 "lexer.l" -{ - ++inputFileStack[currentFile].lineno; -} - YY_BREAK -case 77: -YY_RULE_SETUP -#line 212 "lexer.l" -{ - BEGIN INITIAL; -} - YY_BREAK -case 78: -YY_RULE_SETUP -#line 215 "lexer.l" -{ - ; -} - YY_BREAK -case 79: -YY_RULE_SETUP -#line 220 "lexer.l" -{ /* The software license. */ - codeIdx = 0; - return TK_COPYING; -} - YY_BREAK -case 80: -YY_RULE_SETUP -#line 225 "lexer.l" -{ /* The start of a from-type code block. */ - codeIdx = 0; - return TK_FROMTYPE; -} - YY_BREAK -case 81: -YY_RULE_SETUP -#line 230 "lexer.l" -{ /* The start of a to-type code block. */ - codeIdx = 0; - return TK_TOTYPE; -} - YY_BREAK -case 82: -YY_RULE_SETUP -#line 235 "lexer.l" -{ /* The start of a to-sub-class code block. */ - codeIdx = 0; - return TK_TOSUBCLASS; -} - YY_BREAK -case 83: -YY_RULE_SETUP -#line 240 "lexer.l" -{ /* The start of an exported header code block. */ - codeIdx = 0; - return TK_EXPHEADERCODE; -} - YY_BREAK -case 84: -YY_RULE_SETUP -#line 245 "lexer.l" -{ /* The start of a module header code block. */ - codeIdx = 0; - return TK_MODHEADERCODE; -} - YY_BREAK -case 85: -YY_RULE_SETUP -#line 250 "lexer.l" -{ /* The start of a type header code block. */ - codeIdx = 0; - return TK_TYPEHEADERCODE; -} - YY_BREAK -case 86: -YY_RULE_SETUP -#line 255 "lexer.l" -{ /* The start of a pre-initialisation code block. */ - codeIdx = 0; - return TK_PREINITCODE; -} - YY_BREAK -case 87: -YY_RULE_SETUP -#line 260 "lexer.l" -{ /* The start of a post-initialisation code block. */ - codeIdx = 0; - return TK_POSTINITCODE; -} - YY_BREAK -case 88: -YY_RULE_SETUP -#line 265 "lexer.l" -{ /* The start of a unit code block. */ - codeIdx = 0; - return TK_UNITCODE; -} - YY_BREAK -case 89: -YY_RULE_SETUP -#line 270 "lexer.l" -{ /* The start of a module code block. */ - codeIdx = 0; - return TK_MODCODE; -} - YY_BREAK -case 90: -YY_RULE_SETUP -#line 275 "lexer.l" -{ /* The start of a type code block. */ - codeIdx = 0; - return TK_TYPECODE; -} - YY_BREAK -case 91: -YY_RULE_SETUP -#line 280 "lexer.l" -{ /* The start of a C++ method code block. */ - codeIdx = 0; - return TK_METHODCODE; -} - YY_BREAK -case 92: -YY_RULE_SETUP -#line 285 "lexer.l" -{ /* The start of a C++ virtual code block. */ - codeIdx = 0; - return TK_VIRTUALCATCHERCODE; -} - YY_BREAK -case 93: -YY_RULE_SETUP -#line 290 "lexer.l" -{ /* The start of a traverse code block. */ - codeIdx = 0; - return TK_TRAVERSECODE; -} - YY_BREAK -case 94: -YY_RULE_SETUP -#line 295 "lexer.l" -{ /* The start of a clear code block. */ - codeIdx = 0; - return TK_CLEARCODE; -} - YY_BREAK -case 95: -YY_RULE_SETUP -#line 300 "lexer.l" -{ /* The start of a read buffer code block. */ - codeIdx = 0; - return TK_READBUFFERCODE; -} - YY_BREAK -case 96: -YY_RULE_SETUP -#line 305 "lexer.l" -{ /* The start of a write buffer code block. */ - codeIdx = 0; - return TK_WRITEBUFFERCODE; -} - YY_BREAK -case 97: -YY_RULE_SETUP -#line 310 "lexer.l" -{ /* The start of a segment count code block. */ - codeIdx = 0; - return TK_SEGCOUNTCODE; -} - YY_BREAK -case 98: -YY_RULE_SETUP -#line 315 "lexer.l" -{ /* The start of a char buffer code block. */ - codeIdx = 0; - return TK_CHARBUFFERCODE; -} - YY_BREAK -case 99: -YY_RULE_SETUP -#line 320 "lexer.l" -{ /* The start of a pre-Python code block. */ - codeIdx = 0; - return TK_PREPYCODE; -} - YY_BREAK -case 100: -YY_RULE_SETUP -#line 325 "lexer.l" -{ /* The start of a raise exception code block. */ - codeIdx = 0; - return TK_RAISECODE; -} - YY_BREAK -case 101: -YY_RULE_SETUP -#line 330 "lexer.l" -{ /* The start of a documentation block. */ - codeIdx = 0; - return TK_DOC; -} - YY_BREAK -case 102: -YY_RULE_SETUP -#line 335 "lexer.l" -{ /* The start of an exported documentation block. */ - codeIdx = 0; - return TK_EXPORTEDDOC; -} - YY_BREAK -case 103: -YY_RULE_SETUP -#line 340 "lexer.l" -{ /* The start of a Makefile code block. */ - codeIdx = 0; - return TK_MAKEFILE; -} - YY_BREAK -case 104: -YY_RULE_SETUP -#line 345 "lexer.l" -{ /* The start of an access code block. */ - codeIdx = 0; - return TK_ACCESSCODE; -} - YY_BREAK -case 105: -YY_RULE_SETUP -#line 350 "lexer.l" -{ /* The start of a get code block. */ - codeIdx = 0; - return TK_GETCODE; -} - YY_BREAK -case 106: -YY_RULE_SETUP -#line 355 "lexer.l" -{ /* The start of a set code block. */ - codeIdx = 0; - return TK_SETCODE; -} - YY_BREAK -case 107: -YY_RULE_SETUP -#line 360 "lexer.l" -{ /* The end of a code block. */ - BEGIN INITIAL; - codeIdx = -1; - return TK_END; -} - YY_BREAK -case 108: -/* rule 108 can match eol */ -YY_RULE_SETUP -#line 366 "lexer.l" -{ /* The end of a code line . */ - struct inputFile *ifp; - - codeLine[codeIdx] = '\n'; - codeLine[codeIdx + 1] = '\0'; - codeIdx = 0; - - ifp = &inputFileStack[currentFile]; - - yylval.codeb = sipMalloc(sizeof (codeBlock)); - - yylval.codeb -> frag = sipStrdup(codeLine); - yylval.codeb -> linenr = ifp -> lineno++; - yylval.codeb -> filename = sipStrdup(ifp -> name); - yylval.codeb -> next = NULL; - - return TK_CODELINE; -} - YY_BREAK -case 109: -YY_RULE_SETUP -#line 385 "lexer.l" -{ /* The contents of a code line. */ - if (codeIdx == MAX_CODE_LINE_LENGTH) - fatallex("Line is too long"); - - codeLine[codeIdx++] = yytext[0]; -} - YY_BREAK -case 110: -YY_RULE_SETUP -#line 392 "lexer.l" -{ /* Anything else is returned as is. */ - return yytext[0]; -} - YY_BREAK -case 111: -YY_RULE_SETUP -#line 396 "lexer.l" -ECHO; - YY_BREAK -#line 2092 "lexer.c.tmp" -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(code): -case YY_STATE_EOF(ccomment): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = (yy_c_buf_p); - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_END_OF_FILE: - { - (yy_did_buffer_switch_on_eof) = 0; - - if ( yywrap( ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (void) -{ - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; - int ret_val; - - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; - - int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ( (yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (void) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = (yy_start); - yy_current_state += YY_AT_BOL(); - - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 735 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) -{ - register int yy_is_jam; - register char *yy_cp = (yy_c_buf_p); - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 735 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 734); - - return yy_is_jam ? 0 : yy_current_state; -} - - static void yyunput (int c, register char * yy_bp ) -{ - register char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up yytext */ - *yy_cp = (yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (void) -#else - static int input (void) -#endif - -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - int offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); - - switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart(yyin ); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( ) ) - return EOF; - - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve yytext */ - (yy_hold_char) = *++(yy_c_buf_p); - - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file ) -{ - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); - } - - yy_init_buffer(YY_CURRENT_BUFFER,input_file ); - yy_load_buffer_state( ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) -{ - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - -static void yy_load_buffer_state (void) -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer(b,file ); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * - */ - void yy_delete_buffer (YY_BUFFER_STATE b ) -{ - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ); - - yyfree((void *) b ); -} - -#ifndef _UNISTD_H /* assume unistd.h has isatty() for us */ -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __THROW /* this is a gnuism */ -extern int isatty (int ) __THROW; -#else -extern int isatty (int ); -#endif -#ifdef __cplusplus -} -#endif -#endif - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) - -{ - int oerrno = errno; - - yy_flush_buffer(b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ - void yy_flush_buffer (YY_BUFFER_STATE b ) -{ - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) -{ - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void yypop_buffer_state (void) -{ - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (void) -{ - int num_to_alloc; - - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer(b ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param str a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) -{ - - return yy_scan_bytes(yystr,strlen(yystr) ); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) yyalloc(n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer(buf,n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg ) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = (yy_hold_char); \ - (yy_c_buf_p) = yytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the current line number. - * - */ -int yyget_lineno (void) -{ - - return yylineno; -} - -/** Get the input stream. - * - */ -FILE *yyget_in (void) -{ - return yyin; -} - -/** Get the output stream. - * - */ -FILE *yyget_out (void) -{ - return yyout; -} - -/** Get the length of the current token. - * - */ -int yyget_leng (void) -{ - return yyleng; -} - -/** Get the current token. - * - */ - -char *yyget_text (void) -{ - return yytext; -} - -/** Set the current line number. - * @param line_number - * - */ -void yyset_lineno (int line_number ) -{ - - yylineno = line_number; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * in_str ) -{ - yyin = in_str ; -} - -void yyset_out (FILE * out_str ) -{ - yyout = out_str ; -} - -int yyget_debug (void) -{ - return yy_flex_debug; -} - -void yyset_debug (int bdebug ) -{ - yy_flex_debug = bdebug ; -} - -static int yy_init_globals (void) -{ - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - (yy_buffer_stack) = 0; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; - (yy_init) = 0; - (yy_start) = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = (FILE *) 0; - yyout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (void) -{ - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(); - } - - /* Destroy the stack itself. */ - yyfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( ); - - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size ) -{ - return (void *) malloc( size ); -} - -void *yyrealloc (void * ptr, yy_size_t size ) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void yyfree (void * ptr ) -{ - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 396 "lexer.l" - - - -/* - * Hook into EOF handling. Return 0 if there is more to process. - */ - -int yywrap() -{ - char *cwd; - struct inputFile *ifp; - - if ((cwd = inputFileStack[currentFile].cwd) != NULL) - free(cwd); - - ifp = &inputFileStack[currentFile--]; - - /* Tell the parser if this is the end of a file. */ - - parserEOF(ifp -> name,&ifp -> pc); - - /* Tidy up this file. */ - - fclose(yyin); - free(ifp -> name); - - /* See if this was the original file. */ - - if (currentFile < 0) - return 1; - - yy_delete_buffer(YY_CURRENT_BUFFER); - yy_switch_to_buffer(ifp -> bs); - - return 0; -} - - -/* - * Set up an input file to be read by the lexer, opening it if necessary. - */ -void setInputFile(FILE *fp,char *name,parserContext *pc,int optional) -{ - char *fullname = NULL; - - if (currentFile >= MAX_INCLUDE_DEPTH - 1) - fatal("Too many nested %%Include, %%OptionalInclude or %%Import statements\n"); - - if (fp != NULL || (fp = openFile(name)) != NULL) - fullname = sipStrdup(name); - else - { - char *cwd; - - /* Try the directory that contains the current file. */ - if (currentFile >= 0 && (cwd = inputFileStack[currentFile].cwd) != NULL) - { - fullname = concat(cwd,"/",name,NULL); - - if ((fp = openFile(fullname)) == NULL) - { - free(fullname); - fullname = NULL; - } - } - } - - /* Try the include path if we haven't found anything yet. */ - if (fullname == NULL) - { - stringList *sl; - - fullname = NULL; - - for (sl = includeDirList; sl != NULL; sl = sl -> next) - { - if (fullname != NULL) - free(fullname); - - fullname = concat(sl -> s,"/",name,NULL); - - if ((fp = openFile(fullname)) != NULL) - break; - } - - if (fp == NULL && !optional) - fatal("Unable to find file \"%s\"\n",name); - } - - if (fp != NULL) - { - char *cwd; - - yyin = fp; - - ++currentFile; - - /* - * Remember the directory containing the new file and make it - * "current". - */ - if ((cwd = strchr(fullname,'/')) != NULL) - { - cwd = sipStrdup(fullname); - *strrchr(cwd,'/') = '\0'; - } - - inputFileStack[currentFile].lineno = 1; - inputFileStack[currentFile].name = fullname; - inputFileStack[currentFile].pc = *pc; - inputFileStack[currentFile].cwd = cwd; - - if (currentFile > 0) - { - inputFileStack[currentFile].bs = YY_CURRENT_BUFFER; - yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE)); - } - } -} - - -/* - * Open a file for reading or return NULL if it doesn't exist. Any other error - * is fatal. - */ -static FILE *openFile(char *name) -{ - FILE *fp; - - if ((fp = fopen(name,"r")) == NULL && errno != ENOENT) - fatal("Error in opening file %s\n",name); - - return fp; -} - - -/* - * Handle fatal yacc errors. - */ -void yyerror(char *s) -{ - if (currentFile < 0) - fatal("%s\n", s); - - fatal("%s:%d: %s\n", - inputFileStack[currentFile].name, - inputFileStack[currentFile].lineno, - s); -} - - -/* - * Handle warnings while parsing. - */ -void yywarning(char *s) -{ - warning("%s:%d: %s\n", - inputFileStack[currentFile].name, - inputFileStack[currentFile].lineno, - s); -} - - -/* - * Handle fatal lex errors. - */ -static void fatallex(char *s) -{ - fatal("%s:%d: Lexical analyser error: %s\n", - inputFileStack[currentFile].name, - inputFileStack[currentFile].lineno, - s); -} - diff --git a/python/sip/sipgen/lexer.l b/python/sip/sipgen/lexer.l deleted file mode 100644 index ef234193..00000000 --- a/python/sip/sipgen/lexer.l +++ /dev/null @@ -1,567 +0,0 @@ -/* - * The SIP lexer. - * - * Copyright (c) 2007 - * Riverbank Computing Limited <info@riverbankcomputing.co.uk> - * - * This file is part of SIP. - * - * This copy of SIP is licensed for use under the terms of the SIP License - * Agreement. See the file LICENSE for more details. - * - * SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - -%{ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> - -#include "sip.h" -#include "parser.h" - - -#ifndef FLEX_SCANNER -#error "Only flex is supported at the moment" -#endif - - -#define YY_FATAL_ERROR(s) fatallex(s) - -#define MAX_INCLUDE_DEPTH 10 -#define MAX_CODE_LINE_LENGTH 1000 - - -static struct inputFile { - int lineno; /* The line number. */ - YY_BUFFER_STATE bs; /* The flex buffer state handle. */ - char *name; /* The file name. */ - char *cwd; /* The path part of the file name. */ - parserContext pc; /* The parser context. */ -} inputFileStack[MAX_INCLUDE_DEPTH]; - -static int currentFile = -1; /* Index of the current input file. */ -static char codeLine[MAX_CODE_LINE_LENGTH + 2]; /* The current code line. */ -static int codeIdx = -1; /* Index of next code character. */ - -static FILE *openFile(char *); -static void fatallex(char *); -%} - -%x code -%x ccomment - -%% - -^[ \t]*%SIPOptions {return TK_OPTIONS;} -^[ \t]*%SIPNoEmitters {return TK_NOEMITTERS;} -^[ \t]*%Include {return TK_INCLUDE;} -^[ \t]*%OptionalInclude {return TK_OPTINCLUDE;} -^[ \t]*%Import {return TK_IMPORT;} -^[ \t]*%Module {return TK_MODULE;} -^[ \t]*%CModule {return TK_CMODULE;} -^[ \t]*%Timeline {return TK_TIMELINE;} -^[ \t]*%Platforms {return TK_PLATFORMS;} -^[ \t]*%Feature {return TK_FEATURE;} -^[ \t]*%License {return TK_LICENSE;} -^[ \t]*%MappedType {return TK_MAPPEDTYPE;} -^[ \t]*%Exception {return TK_EXCEPTION;} -^[ \t]*%If {return TK_IF;} -<INITIAL>^[ \t]*%End {return TK_END;} -class {return TK_CLASS;} -struct {return TK_STRUCT;} -public {return TK_PUBLIC;} -protected {return TK_PROTECTED;} -private {return TK_PRIVATE;} -signals {return TK_SIGNALS;} -slots {return TK_SLOTS;} -char {return TK_CHAR;} -wchar_t {return TK_WCHAR_T;} -bool {return TK_BOOL;} -short {return TK_SHORT;} -int {return TK_INT;} -long {return TK_LONG;} -float {return TK_FLOAT;} -double {return TK_DOUBLE;} -void {return TK_VOID;} -virtual {return TK_VIRTUAL;} -enum {return TK_ENUM;} -signed {return TK_SIGNED;} -unsigned {return TK_UNSIGNED;} -const {return TK_CONST;} -static {return TK_STATIC;} -true {return TK_TRUE;} -false {return TK_FALSE;} -NULL {return TK_NULL;} -typedef {return TK_TYPEDEF;} -namespace {return TK_NAMESPACE;} -operator {return TK_OPERATOR;} -throw {return TK_THROW;} -explicit {return TK_EXPLICIT;} -template {return TK_TEMPLATE;} -:: {return TK_SCOPE;} -\|\| {return TK_LOGICAL_OR;} -SIP_PYOBJECT {return TK_PYOBJECT;} -SIP_PYTUPLE {return TK_PYTUPLE;} -SIP_PYLIST {return TK_PYLIST;} -SIP_PYDICT {return TK_PYDICT;} -SIP_PYCALLABLE {return TK_PYCALLABLE;} -SIP_PYSLICE {return TK_PYSLICE;} -SIP_PYTYPE {return TK_PYTYPE;} -SIP_SIGNAL {return TK_SIPSIGNAL;} -SIP_SLOT {return TK_SIPSLOT;} -SIP_ANYSLOT {return TK_SIPANYSLOT;} -SIP_RXOBJ_CON {return TK_SIPRXCON;} -SIP_RXOBJ_DIS {return TK_SIPRXDIS;} -SIP_SLOT_CON {return TK_SIPSLOTCON;} -SIP_SLOT_DIS {return TK_SIPSLOTDIS;} -SIP_QOBJECT {return TK_QOBJECT;} -\.\.\. {return TK_ELLIPSIS;} - - -[ \t\r] { /* Ignore whitespace. */ - ; -} - -\n { /* Maintain the line number. */ - ++inputFileStack[currentFile].lineno; - - if (codeIdx == 0) - { - BEGIN code; - } -} - -\/\/.* { /* Ignore C++ style comments. */ - ; -} - - --?[0-9]+ { /* A signed decimal number. */ - yylval.number = strtol(yytext,NULL,0); - return TK_NUMBER; -} - - --?(([0-9]+)|([0-9]*\.[0-9]+)([eE][-+]?[0-9]+)?) {/* A floating point number. */ - yylval.real = strtod(yytext,NULL); - return TK_REAL; -} - - -0x[0-9a-fA-F]+ { /* An unsigned hexadecimal number. */ - yylval.number = strtol(yytext,NULL,16); - return TK_NUMBER; -} - - -[_A-Za-z][_A-Za-z0-9]* { /* An identifier name. */ - yylval.text = sipStrdup(yytext); - return TK_NAME; -} - - -[._A-Za-z][._/A-Za-z0-9\-]*[._A-Za-z0-9] { /* A relative pathname. */ - yylval.text = sipStrdup(yytext); - return TK_PATHNAME; -} - - -\"[^"\n]*["\n] { /* A double-quoted string. */ - char *dp, *sp; - - /* Copy the string without the quotes. */ - - yylval.text = sipMalloc(strlen(yytext) + 1); - - dp = yylval.text; - sp = yytext; - - while (*sp != '\0') - { - if (*sp != '"') - *dp++ = *sp; - - ++sp; - } - - *dp = '\0'; - - return TK_STRING; -} - - -\'[^'\n]*['\n] { /* A single-quoted character. */ - if (strlen(yytext) != 3) - fatallex("Exactly one character expected between single quotes"); - - yylval.qchar = yytext[1]; - - return TK_QCHAR; -} - - -\/\* { /* Ignore C-style comments. */ - BEGIN ccomment; -} -<ccomment>\n { - ++inputFileStack[currentFile].lineno; -} -<ccomment>\*\/ { - BEGIN INITIAL; -} -<ccomment>. { - ; -} - - -^%Copying { /* The software license. */ - codeIdx = 0; - return TK_COPYING; -} - -^%ConvertFromTypeCode { /* The start of a from-type code block. */ - codeIdx = 0; - return TK_FROMTYPE; -} - -^%ConvertToTypeCode { /* The start of a to-type code block. */ - codeIdx = 0; - return TK_TOTYPE; -} - -^%ConvertToSubClassCode { /* The start of a to-sub-class code block. */ - codeIdx = 0; - return TK_TOSUBCLASS; -} - -^%ExportedHeaderCode { /* The start of an exported header code block. */ - codeIdx = 0; - return TK_EXPHEADERCODE; -} - -^%ModuleHeaderCode { /* The start of a module header code block. */ - codeIdx = 0; - return TK_MODHEADERCODE; -} - -^%TypeHeaderCode { /* The start of a type header code block. */ - codeIdx = 0; - return TK_TYPEHEADERCODE; -} - -^%PreInitialisationCode { /* The start of a pre-initialisation code block. */ - codeIdx = 0; - return TK_PREINITCODE; -} - -^%PostInitialisationCode { /* The start of a post-initialisation code block. */ - codeIdx = 0; - return TK_POSTINITCODE; -} - -^%UnitCode { /* The start of a unit code block. */ - codeIdx = 0; - return TK_UNITCODE; -} - -^%ModuleCode { /* The start of a module code block. */ - codeIdx = 0; - return TK_MODCODE; -} - -^%TypeCode { /* The start of a type code block. */ - codeIdx = 0; - return TK_TYPECODE; -} - -^%MethodCode { /* The start of a C++ method code block. */ - codeIdx = 0; - return TK_METHODCODE; -} - -^%VirtualCatcherCode { /* The start of a C++ virtual code block. */ - codeIdx = 0; - return TK_VIRTUALCATCHERCODE; -} - -^%GCTraverseCode { /* The start of a traverse code block. */ - codeIdx = 0; - return TK_TRAVERSECODE; -} - -^%GCClearCode { /* The start of a clear code block. */ - codeIdx = 0; - return TK_CLEARCODE; -} - -^%BIGetReadBufferCode { /* The start of a read buffer code block. */ - codeIdx = 0; - return TK_READBUFFERCODE; -} - -^%BIGetWriteBufferCode { /* The start of a write buffer code block. */ - codeIdx = 0; - return TK_WRITEBUFFERCODE; -} - -^%BIGetSegCountCode { /* The start of a segment count code block. */ - codeIdx = 0; - return TK_SEGCOUNTCODE; -} - -^%BIGetCharBufferCode { /* The start of a char buffer code block. */ - codeIdx = 0; - return TK_CHARBUFFERCODE; -} - -^%PrePythonCode { /* The start of a pre-Python code block. */ - codeIdx = 0; - return TK_PREPYCODE; -} - -^%RaiseCode { /* The start of a raise exception code block. */ - codeIdx = 0; - return TK_RAISECODE; -} - -^%Doc { /* The start of a documentation block. */ - codeIdx = 0; - return TK_DOC; -} - -^%ExportedDoc { /* The start of an exported documentation block. */ - codeIdx = 0; - return TK_EXPORTEDDOC; -} - -^%Makefile { /* The start of a Makefile code block. */ - codeIdx = 0; - return TK_MAKEFILE; -} - -^%AccessCode { /* The start of an access code block. */ - codeIdx = 0; - return TK_ACCESSCODE; -} - -^%GetCode { /* The start of a get code block. */ - codeIdx = 0; - return TK_GETCODE; -} - -^%SetCode { /* The start of a set code block. */ - codeIdx = 0; - return TK_SETCODE; -} - -<code>^%End { /* The end of a code block. */ - BEGIN INITIAL; - codeIdx = -1; - return TK_END; -} - -<code>\n { /* The end of a code line . */ - struct inputFile *ifp; - - codeLine[codeIdx] = '\n'; - codeLine[codeIdx + 1] = '\0'; - codeIdx = 0; - - ifp = &inputFileStack[currentFile]; - - yylval.codeb = sipMalloc(sizeof (codeBlock)); - - yylval.codeb -> frag = sipStrdup(codeLine); - yylval.codeb -> linenr = ifp -> lineno++; - yylval.codeb -> filename = sipStrdup(ifp -> name); - yylval.codeb -> next = NULL; - - return TK_CODELINE; -} - -<code>. { /* The contents of a code line. */ - if (codeIdx == MAX_CODE_LINE_LENGTH) - fatallex("Line is too long"); - - codeLine[codeIdx++] = yytext[0]; -} - -. { /* Anything else is returned as is. */ - return yytext[0]; -} - -%% - -/* - * Hook into EOF handling. Return 0 if there is more to process. - */ - -int yywrap() -{ - char *cwd; - struct inputFile *ifp; - - if ((cwd = inputFileStack[currentFile].cwd) != NULL) - free(cwd); - - ifp = &inputFileStack[currentFile--]; - - /* Tell the parser if this is the end of a file. */ - - parserEOF(ifp -> name,&ifp -> pc); - - /* Tidy up this file. */ - - fclose(yyin); - free(ifp -> name); - - /* See if this was the original file. */ - - if (currentFile < 0) - return 1; - - yy_delete_buffer(YY_CURRENT_BUFFER); - yy_switch_to_buffer(ifp -> bs); - - return 0; -} - - -/* - * Set up an input file to be read by the lexer, opening it if necessary. - */ -void setInputFile(FILE *fp,char *name,parserContext *pc,int optional) -{ - char *fullname = NULL; - - if (currentFile >= MAX_INCLUDE_DEPTH - 1) - fatal("Too many nested %%Include, %%OptionalInclude or %%Import statements\n"); - - if (fp != NULL || (fp = openFile(name)) != NULL) - fullname = sipStrdup(name); - else - { - char *cwd; - - /* Try the directory that contains the current file. */ - if (currentFile >= 0 && (cwd = inputFileStack[currentFile].cwd) != NULL) - { - fullname = concat(cwd,"/",name,NULL); - - if ((fp = openFile(fullname)) == NULL) - { - free(fullname); - fullname = NULL; - } - } - } - - /* Try the include path if we haven't found anything yet. */ - if (fullname == NULL) - { - stringList *sl; - - fullname = NULL; - - for (sl = includeDirList; sl != NULL; sl = sl -> next) - { - if (fullname != NULL) - free(fullname); - - fullname = concat(sl -> s,"/",name,NULL); - - if ((fp = openFile(fullname)) != NULL) - break; - } - - if (fp == NULL && !optional) - fatal("Unable to find file \"%s\"\n",name); - } - - if (fp != NULL) - { - char *cwd; - - yyin = fp; - - ++currentFile; - - /* - * Remember the directory containing the new file and make it - * "current". - */ - if ((cwd = strchr(fullname,'/')) != NULL) - { - cwd = sipStrdup(fullname); - *strrchr(cwd,'/') = '\0'; - } - - inputFileStack[currentFile].lineno = 1; - inputFileStack[currentFile].name = fullname; - inputFileStack[currentFile].pc = *pc; - inputFileStack[currentFile].cwd = cwd; - - if (currentFile > 0) - { - inputFileStack[currentFile].bs = YY_CURRENT_BUFFER; - yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE)); - } - } -} - - -/* - * Open a file for reading or return NULL if it doesn't exist. Any other error - * is fatal. - */ -static FILE *openFile(char *name) -{ - FILE *fp; - - if ((fp = fopen(name,"r")) == NULL && errno != ENOENT) - fatal("Error in opening file %s\n",name); - - return fp; -} - - -/* - * Handle fatal yacc errors. - */ -void yyerror(char *s) -{ - if (currentFile < 0) - fatal("%s\n", s); - - fatal("%s:%d: %s\n", - inputFileStack[currentFile].name, - inputFileStack[currentFile].lineno, - s); -} - - -/* - * Handle warnings while parsing. - */ -void yywarning(char *s) -{ - warning("%s:%d: %s\n", - inputFileStack[currentFile].name, - inputFileStack[currentFile].lineno, - s); -} - - -/* - * Handle fatal lex errors. - */ -static void fatallex(char *s) -{ - fatal("%s:%d: Lexical analyser error: %s\n", - inputFileStack[currentFile].name, - inputFileStack[currentFile].lineno, - s); -} diff --git a/python/sip/sipgen/main.c b/python/sip/sipgen/main.c deleted file mode 100644 index ce1e859b..00000000 --- a/python/sip/sipgen/main.c +++ /dev/null @@ -1,484 +0,0 @@ -/* - * The main module for SIP. - * - * Copyright (c) 2007 - * Riverbank Computing Limited <info@riverbankcomputing.co.uk> - * - * This file is part of SIP. - * - * This copy of SIP is licensed for use under the terms of the SIP License - * Agreement. See the file LICENSE for more details. - * - * SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - - -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <ctype.h> - -#include "sip.h" - - -#ifndef PACKAGE -#define PACKAGE "sip" -#endif - -#define VERSION "4.6 (4.6)" - - -/* Global variables - see sip.h for their meaning. */ -char *sipVersion; -stringList *includeDirList; - -static char *sipPackage = PACKAGE; -static int warnings = FALSE; - - -static void help(void); -static void version(void); -static void usage(void); -static char parseopt(int,char **,char *,char **,int *,char **); -static int parseInt(char *,char); - - -int main(int argc,char **argv) -{ - char *filename, *docFile, *codeDir, *srcSuffix, *flagFile; - char arg, *optarg, *buildFile, *apiFile, *xmlFile; - int optnr, exceptions, tracing, releaseGIL, parts; - FILE *file; - sipSpec spec; - stringList *versions, *xfeatures; - - /* Initialise. */ - sipVersion = VERSION; - includeDirList = NULL; - versions = NULL; - xfeatures = NULL; - buildFile = NULL; - codeDir = NULL; - docFile = NULL; - srcSuffix = NULL; - flagFile = NULL; - apiFile = NULL; - xmlFile = NULL; - exceptions = FALSE; - tracing = FALSE; - releaseGIL = FALSE; - parts = 0; - - /* Parse the command line. */ - optnr = 1; - - while ((arg = parseopt(argc, argv, "hVa:b:ec:d:gI:j:m:rs:t:wx:z:", &flagFile, &optnr, &optarg)) != '\0') - switch (arg) - { - case 'a': - /* Where to generate the API file. */ - apiFile = optarg; - break; - - case 'm': - /* Where to generate the XML file. */ - xmlFile = optarg; - break; - - case 'b': - /* Generate a build file. */ - buildFile = optarg; - break; - - case 'e': - /* Enable exceptions. */ - exceptions = TRUE; - break; - - case 'g': - /* Always release the GIL. */ - releaseGIL = TRUE; - break; - - case 'j': - /* Generate the code in this number of parts. */ - parts = parseInt(optarg,'j'); - break; - - case 'z': - /* Read a file for the next flags. */ - if (flagFile != NULL) - fatal("The -z flag cannot be specified in an argument file\n"); - - flagFile = optarg; - break; - - case 'c': - /* Where to generate the code. */ - codeDir = optarg; - break; - - case 'd': - /* Where to generate the documentation. */ - docFile = optarg; - break; - - case 't': - /* Which platform or version to generate code for. */ - appendString(&versions,optarg); - break; - - case 'x': - /* Which features are disabled. */ - appendString(&xfeatures,optarg); - break; - - case 'I': - /* Where to get included files from. */ - appendString(&includeDirList,optarg); - break; - - case 'r': - /* Enable tracing. */ - tracing = TRUE; - break; - - case 's': - /* The suffix to use for source files. */ - srcSuffix = optarg; - break; - - case 'w': - /* Enable warning messages. */ - warnings = TRUE; - break; - - case 'h': - /* Help message. */ - help(); - break; - - case 'V': - /* Display the version number. */ - version(); - break; - - default: - usage(); - } - - if (optnr < argc) - { - file = NULL; - filename = argv[optnr++]; - - if (optnr < argc) - usage(); - } - else - { - file = stdin; - filename = "stdin"; - } - - /* Parse the input file. */ - parse(&spec,file,filename,versions,xfeatures); - - /* Verify and transform the parse tree. */ - transform(&spec); - - /* Generate code. */ - generateCode(&spec, codeDir, buildFile, docFile, srcSuffix, exceptions, - tracing, releaseGIL, parts, xfeatures); - - /* Generate the API file. */ - if (apiFile != NULL) - generateAPI(&spec, apiFile); - - /* Generate the XML export. */ - if (xmlFile != NULL) - generateXML(&spec, xmlFile); - - /* All done. */ - return 0; -} - - -/* - * Parse the next command line argument - similar to UNIX getopts(). Allow a - * flag to specify that a file contains further arguments. - */ -static char parseopt(int argc,char **argv,char *opts,char **flags,int *optnrp, - char **optargp) -{ - char arg, *op, *fname; - int optnr; - static FILE *fp = NULL; - - /* Deal with any file first. */ - - fname = *flags; - - if (fname != NULL && fp == NULL && (fp = fopen(fname,"r")) == NULL) - fatal("Unable to open %s\n",fname); - - if (fp != NULL) - { - char buf[200], *cp, *fname; - int ch; - - fname = *flags; - cp = buf; - - while ((ch = fgetc(fp)) != EOF) - { - /* Skip leading whitespace. */ - - if (cp == buf && isspace(ch)) - continue; - - if (ch == '\n') - break; - - if (cp == &buf[sizeof (buf) - 1]) - fatal("A flag in %s is too long\n",fname); - - *cp++ = (char)ch; - } - - *cp = '\0'; - - if (ch == EOF) - { - fclose(fp); - fp = NULL; - *flags = NULL; - } - - /* - * Get the option character and any optional argument from the - * line. - */ - - if (buf[0] != '\0') - { - if (buf[0] != '-' || buf[1] == '\0') - fatal("An non-flag was given in %s\n",fname); - - arg = buf[1]; - - /* Find any optional argument. */ - - for (cp = &buf[2]; *cp != '\0'; ++cp) - if (!isspace(*cp)) - break; - - if (*cp == '\0') - cp = NULL; - else - cp = sipStrdup(cp); - - *optargp = cp; - - if ((op = strchr(opts,arg)) == NULL) - fatal("An invalid flag was given in %s\n",fname); - - if (op[1] == ':' && cp == NULL) - fatal("Missing flag argument in %s\n",fname); - - if (op[1] != ':' && cp != NULL) - fatal("Unexpected flag argument in %s\n",fname); - - return arg; - } - } - - /* Check there is an argument and it is a switch. */ - - optnr = *optnrp; - - if (optnr >= argc || argv[optnr] == NULL || argv[optnr][0] != '-') - return '\0'; - - /* Check it is a valid switch. */ - - arg = argv[optnr][1]; - - if (arg == '\0' || (op = strchr(opts,arg)) == NULL) - usage(); - - /* Check for the switch parameter, if any. */ - - if (op[1] == ':') - { - if (argv[optnr][2] != '\0') - { - *optargp = &argv[optnr][2]; - ++optnr; - } - else if (optnr + 1 >= argc || argv[optnr + 1] == NULL) - usage(); - else - { - *optargp = argv[optnr + 1]; - optnr += 2; - } - } - else if (argv[optnr][2] != '\0') - usage(); - else - { - *optargp = NULL; - ++optnr; - } - - *optnrp = optnr; - - return arg; -} - - -/* - * Parse an integer option. - */ -static int parseInt(char *arg, char opt) -{ - char *endptr; - int val; - - val = strtol(arg, &endptr, 10); - - if (*arg == '\0' || *endptr != '\0') - fatal("Invalid integer argument for -%c flag\n", opt); - - return val; -} - - -/* - * Append a string to a list of them. - */ -void appendString(stringList **headp, const char *s) -{ - stringList *sl; - - /* Create the new entry. */ - - sl = sipMalloc(sizeof (stringList)); - - sl -> s = s; - sl -> next = NULL; - - /* Append it to the list. */ - - while (*headp != NULL) - headp = &(*headp) -> next; - - *headp = sl; -} - - -/* - * Display a warning message. - */ -void warning(char *fmt,...) -{ - static int start = TRUE; - - va_list ap; - - if (!warnings) - return; - - if (start) - { - fprintf(stderr,"%s: Warning: ",sipPackage); - start = FALSE; - } - - va_start(ap,fmt); - vfprintf(stderr,fmt,ap); - va_end(ap); - - if (strchr(fmt,'\n') != NULL) - start = TRUE; -} - - -/* - * Display all or part of a one line error message describing a fatal error. - * If the message is complete (it has a newline) then the program exits. - */ -void fatal(char *fmt,...) -{ - static int start = TRUE; - - va_list ap; - - if (start) - { - fprintf(stderr,"%s: ",sipPackage); - start = FALSE; - } - - va_start(ap,fmt); - vfprintf(stderr,fmt,ap); - va_end(ap); - - if (strchr(fmt,'\n') != NULL) - exit(1); -} - - -/* - * Display the SIP version number on stdout and exit with zero exit status. - */ -static void version(void) -{ - printf("%s\n",sipVersion); - exit(0); -} - - -/* - * Display the help message on stdout and exit with zero exit status. - */ -static void help(void) -{ - printf( -"Usage:\n" -" %s [-h] [-V] [-a file] [-c dir] [-d file] [-e] [-g] [-I dir] [-j #] [-m file] [-r] [-s suffix] [-t version] [-w] [-x feature] [-z file] [file]\n" -"where:\n" -" -h display this help message\n" -" -V display the %s version number\n" -" -a file the name of the QScintilla API file [default not generated]\n" -" -b file the name of the build file [default none generated]\n" -" -c dir the name of the code directory [default not generated]\n" -" -d file the name of the documentation file [default not generated]\n" -" -e enable support for exceptions [default disabled]\n" -" -g always release and reacquire the GIL [default only when specified]\n" -" -I dir look in this directory when including files\n" -" -j # split the generated code into # files [default 1 per class]\n" -" -m file the name of the XML export file [default not generated]\n" -" -r generate code with tracing enabled [default disabled]\n" -" -s suffix the suffix to use for C or C++ source files [default \".c\" or \".cpp\"]\n" -" -t tag the version/platform to generate code for\n" -" -w enable warning messages\n" -" -x feature this feature is disabled\n" -" -z file the name of a file containing more command line flags\n" -" file the name of the specification file [default stdin]\n" - ,sipPackage,sipPackage); - - exit(0); -} - - -/* - * Display the usage message. - */ -static void usage(void) -{ - fatal("Usage: %s [-h] [-V] [-a file] [-b file] [-c dir] [-d file] [-e] [-g] [-I dir] [-j #] [-m file] [-r] [-s suffix] [-t tag] [-w] [-x feature] [-z file] [file]\n",sipPackage); -} diff --git a/python/sip/sipgen/parser.c b/python/sip/sipgen/parser.c deleted file mode 100644 index 04a72f68..00000000 --- a/python/sip/sipgen/parser.c +++ /dev/null @@ -1,7526 +0,0 @@ -/* A Bison parser, made by GNU Bison 1.875d. */ - -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 0 - -/* Using locations. */ -#define YYLSP_NEEDED 0 - - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TK_OPTIONS = 258, - TK_NOEMITTERS = 259, - TK_DOC = 260, - TK_EXPORTEDDOC = 261, - TK_MAKEFILE = 262, - TK_ACCESSCODE = 263, - TK_GETCODE = 264, - TK_SETCODE = 265, - TK_PREINITCODE = 266, - TK_POSTINITCODE = 267, - TK_UNITCODE = 268, - TK_MODCODE = 269, - TK_TYPECODE = 270, - TK_PREPYCODE = 271, - TK_COPYING = 272, - TK_MAPPEDTYPE = 273, - TK_CODELINE = 274, - TK_IF = 275, - TK_END = 276, - TK_NAME = 277, - TK_PATHNAME = 278, - TK_STRING = 279, - TK_VIRTUALCATCHERCODE = 280, - TK_TRAVERSECODE = 281, - TK_CLEARCODE = 282, - TK_READBUFFERCODE = 283, - TK_WRITEBUFFERCODE = 284, - TK_SEGCOUNTCODE = 285, - TK_CHARBUFFERCODE = 286, - TK_METHODCODE = 287, - TK_FROMTYPE = 288, - TK_TOTYPE = 289, - TK_TOSUBCLASS = 290, - TK_INCLUDE = 291, - TK_OPTINCLUDE = 292, - TK_IMPORT = 293, - TK_EXPHEADERCODE = 294, - TK_MODHEADERCODE = 295, - TK_TYPEHEADERCODE = 296, - TK_MODULE = 297, - TK_CMODULE = 298, - TK_CLASS = 299, - TK_STRUCT = 300, - TK_PUBLIC = 301, - TK_PROTECTED = 302, - TK_PRIVATE = 303, - TK_SIGNALS = 304, - TK_SLOTS = 305, - TK_BOOL = 306, - TK_SHORT = 307, - TK_INT = 308, - TK_LONG = 309, - TK_FLOAT = 310, - TK_DOUBLE = 311, - TK_CHAR = 312, - TK_WCHAR_T = 313, - TK_VOID = 314, - TK_PYOBJECT = 315, - TK_PYTUPLE = 316, - TK_PYLIST = 317, - TK_PYDICT = 318, - TK_PYCALLABLE = 319, - TK_PYSLICE = 320, - TK_PYTYPE = 321, - TK_VIRTUAL = 322, - TK_ENUM = 323, - TK_SIGNED = 324, - TK_UNSIGNED = 325, - TK_SCOPE = 326, - TK_LOGICAL_OR = 327, - TK_CONST = 328, - TK_STATIC = 329, - TK_SIPQT_SIGNAL = 330, - TK_SIPQT_SLOT = 331, - TK_SIPANYQT_SLOT = 332, - TK_SIPRXCON = 333, - TK_SIPRXDIS = 334, - TK_SIPSLOTCON = 335, - TK_SIPSLOTDIS = 336, - TK_NUMBER = 337, - TK_REAL = 338, - TK_TYPEDEF = 339, - TK_NAMESPACE = 340, - TK_TIMELINE = 341, - TK_PLATFORMS = 342, - TK_FEATURE = 343, - TK_LICENSE = 344, - TK_QCHAR = 345, - TK_TRUE = 346, - TK_FALSE = 347, - TK_NULL = 348, - TK_OPERATOR = 349, - TK_THROW = 350, - TK_QOBJECT = 351, - TK_EXCEPTION = 352, - TK_RAISECODE = 353, - TK_EXPLICIT = 354, - TK_TEMPLATE = 355, - TK_ELLIPSIS = 356 - }; -#endif -#define TK_OPTIONS 258 -#define TK_NOEMITTERS 259 -#define TK_DOC 260 -#define TK_EXPORTEDDOC 261 -#define TK_MAKEFILE 262 -#define TK_ACCESSCODE 263 -#define TK_GETCODE 264 -#define TK_SETCODE 265 -#define TK_PREINITCODE 266 -#define TK_POSTINITCODE 267 -#define TK_UNITCODE 268 -#define TK_MODCODE 269 -#define TK_TYPECODE 270 -#define TK_PREPYCODE 271 -#define TK_COPYING 272 -#define TK_MAPPEDTYPE 273 -#define TK_CODELINE 274 -#define TK_IF 275 -#define TK_END 276 -#define TK_NAME 277 -#define TK_PATHNAME 278 -#define TK_STRING 279 -#define TK_VIRTUALCATCHERCODE 280 -#define TK_TRAVERSECODE 281 -#define TK_CLEARCODE 282 -#define TK_READBUFFERCODE 283 -#define TK_WRITEBUFFERCODE 284 -#define TK_SEGCOUNTCODE 285 -#define TK_CHARBUFFERCODE 286 -#define TK_METHODCODE 287 -#define TK_FROMTYPE 288 -#define TK_TOTYPE 289 -#define TK_TOSUBCLASS 290 -#define TK_INCLUDE 291 -#define TK_OPTINCLUDE 292 -#define TK_IMPORT 293 -#define TK_EXPHEADERCODE 294 -#define TK_MODHEADERCODE 295 -#define TK_TYPEHEADERCODE 296 -#define TK_MODULE 297 -#define TK_CMODULE 298 -#define TK_CLASS 299 -#define TK_STRUCT 300 -#define TK_PUBLIC 301 -#define TK_PROTECTED 302 -#define TK_PRIVATE 303 -#define TK_SIGNALS 304 -#define TK_SLOTS 305 -#define TK_BOOL 306 -#define TK_SHORT 307 -#define TK_INT 308 -#define TK_LONG 309 -#define TK_FLOAT 310 -#define TK_DOUBLE 311 -#define TK_CHAR 312 -#define TK_WCHAR_T 313 -#define TK_VOID 314 -#define TK_PYOBJECT 315 -#define TK_PYTUPLE 316 -#define TK_PYLIST 317 -#define TK_PYDICT 318 -#define TK_PYCALLABLE 319 -#define TK_PYSLICE 320 -#define TK_PYTYPE 321 -#define TK_VIRTUAL 322 -#define TK_ENUM 323 -#define TK_SIGNED 324 -#define TK_UNSIGNED 325 -#define TK_SCOPE 326 -#define TK_LOGICAL_OR 327 -#define TK_CONST 328 -#define TK_STATIC 329 -#define TK_SIPQT_SIGNAL 330 -#define TK_SIPQT_SLOT 331 -#define TK_SIPANYQT_SLOT 332 -#define TK_SIPRXCON 333 -#define TK_SIPRXDIS 334 -#define TK_SIPSLOTCON 335 -#define TK_SIPSLOTDIS 336 -#define TK_NUMBER 337 -#define TK_REAL 338 -#define TK_TYPEDEF 339 -#define TK_NAMESPACE 340 -#define TK_TIMELINE 341 -#define TK_PLATFORMS 342 -#define TK_FEATURE 343 -#define TK_LICENSE 344 -#define TK_QCHAR 345 -#define TK_TRUE 346 -#define TK_FALSE 347 -#define TK_NULL 348 -#define TK_OPERATOR 349 -#define TK_THROW 350 -#define TK_QOBJECT 351 -#define TK_EXCEPTION 352 -#define TK_RAISECODE 353 -#define TK_EXPLICIT 354 -#define TK_TEMPLATE 355 -#define TK_ELLIPSIS 356 - - - - -/* Copy the first part of user declarations. */ -#line 16 "parser.y" - -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - -#include "sip.h" - - -#define MAX_NESTED_IF 10 -#define MAX_NESTED_SCOPE 10 - -#define inMainModule() (currentSpec -> module == currentModule) - - -static sipSpec *currentSpec; /* The current spec being parsed. */ -static stringList *neededQualifiers; /* The list of required qualifiers. */ -static stringList *excludedQualifiers; /* The list of excluded qualifiers. */ -static moduleDef *currentModule; /* The current module being parsed. */ -static mappedTypeDef *currentMappedType; /* The current mapped type. */ -static enumDef *currentEnum; /* The current enum being parsed. */ -static int sectionFlags; /* The current section flags. */ -static int currentOverIsVirt; /* Set if the overload is virtual. */ -static int currentCtorIsExplicit; /* Set if the ctor is explicit. */ -static int currentIsStatic; /* Set if the current is static. */ -static char *previousFile; /* The file just parsed. */ -static parserContext newContext; /* The new pending context. */ -static int skipStackPtr; /* The skip stack pointer. */ -static int skipStack[MAX_NESTED_IF]; /* Stack of skip flags. */ -static classDef *scopeStack[MAX_NESTED_SCOPE]; /* The scope stack. */ -static int sectFlagsStack[MAX_NESTED_SCOPE]; /* The section flags stack. */ -static int currentScopeIdx; /* The scope stack index. */ -static int currentTimelineOrder; /* The current timeline order. */ - - -static char *getPythonName(optFlags *optflgs, char *cname); -static nameDef *cacheName(sipSpec *,char *); -static classDef *findClass(sipSpec *,ifaceFileType,scopedNameDef *); -static classDef *findClassWithInterface(sipSpec *pt, ifaceFileDef *iff); -static classDef *newClass(sipSpec *,ifaceFileType,scopedNameDef *); -static void finishClass(sipSpec *,moduleDef *,classDef *,optFlags *); -static exceptionDef *findException(sipSpec *pt, scopedNameDef *fqname, int new); -static mappedTypeDef *newMappedType(sipSpec *,argDef *); -static enumDef *newEnum(sipSpec *,moduleDef *,char *,optFlags *,int); -static void instantiateClassTemplate(sipSpec *pt, moduleDef *mod, classDef *scope, scopedNameDef *fqname, classTmplDef *tcd, templateDef *td); -static void newTypedef(sipSpec *,moduleDef *,char *,argDef *); -static void newVar(sipSpec *,moduleDef *,char *,int,argDef *,optFlags *, - codeBlock *,codeBlock *,codeBlock *); -static void newCtor(char *,int,signatureDef *,optFlags *,codeBlock *, - throwArgs *,signatureDef *,int); -static void newFunction(sipSpec *,moduleDef *,int,int,int,char *, - signatureDef *,int,int,optFlags *,codeBlock *, - codeBlock *,throwArgs *,signatureDef *); -static optFlag *findOptFlag(optFlags *,char *,flagType); -static memberDef *findFunction(sipSpec *,moduleDef *,classDef *,nameDef *,int, - int); -static void checkAttributes(sipSpec *,classDef *,char *,int); -static void newModule(FILE *,char *); -static void appendCodeBlock(codeBlock **,codeBlock *); -static void parseFile(FILE *,char *,moduleDef *,int); -static void handleEOF(void); -static void handleEOM(void); -static qualDef *findQualifier(char *); -static scopedNameDef *text2scopedName(char *); -static scopedNameDef *scopeScopedName(scopedNameDef *name); -static void pushScope(classDef *); -static void popScope(void); -static classDef *currentScope(void); -static void newQualifier(moduleDef *,int,int,char *,qualType); -static void newImport(char *); -static void usedInMainModule(sipSpec *,ifaceFileDef *); -static int timePeriod(char *,char *); -static int platOrFeature(char *,int); -static int isNeeded(qualDef *); -static int notSkipping(void); -static void getHooks(optFlags *,char **,char **); -static int getReleaseGIL(optFlags *); -static int getHoldGIL(optFlags *); -static void templateSignature(signatureDef *sd, int result, classTmplDef *tcd, templateDef *td, classDef *ncd); -static void templateType(argDef *ad, classTmplDef *tcd, templateDef *td, classDef *ncd); -static int search_back(const char *end, const char *start, const char *target); -static char *getType(scopedNameDef *ename, argDef *ad); -static char *scopedNameToString(scopedNameDef *name); -static void addUsedFromCode(sipSpec *pt, ifaceFileList **used, const char *sname); -static int sameName(scopedNameDef *snd, const char *sname); -static int optFind(sipSpec *pt, const char *opt); - - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 103 "parser.y" -typedef union YYSTYPE { - char qchar; - char *text; - long number; - double real; - argDef memArg; - signatureDef signature; - signatureDef *optsignature; - throwArgs *throwlist; - codeBlock *codeb; - valueDef value; - valueDef *valp; - optFlags optflags; - optFlag flag; - scopedNameDef *scpvalp; - fcallDef fcall; - int boolean; - exceptionDef exceptionbase; - classDef *klass; -} YYSTYPE; -/* Line 191 of yacc.c. */ -#line 386 "parser.c" -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - -/* Copy the second part of user declarations. */ - - -/* Line 214 of yacc.c. */ -#line 398 "parser.c" - -#if ! defined (yyoverflow) || YYERROR_VERBOSE - -# ifndef YYFREE -# define YYFREE free -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# endif - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# endif -# else -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# else -# if defined (__STDC__) || defined (__cplusplus) -# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ - - -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - short int yyss; - YYSTYPE yyvs; - }; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined (__GNUC__) && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - register YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (0) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) - -#endif - -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short int yysigned_char; -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 4 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 1105 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 124 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 134 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 339 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 562 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 356 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 108, 2, 2, 2, 122, 114, 2, - 102, 103, 112, 111, 104, 109, 2, 113, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 119, 107, - 117, 110, 118, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 120, 2, 121, 123, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 105, 115, 106, 116, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, - 95, 96, 97, 98, 99, 100, 101 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const unsigned short int yyprhs[] = -{ - 0, 0, 3, 5, 8, 9, 12, 14, 16, 18, - 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, - 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, - 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, - 80, 82, 84, 89, 91, 95, 97, 107, 108, 112, - 115, 116, 121, 122, 128, 133, 135, 138, 140, 143, - 146, 147, 155, 157, 160, 161, 167, 169, 172, 174, - 177, 178, 184, 186, 189, 191, 196, 198, 201, 205, - 210, 212, 216, 218, 221, 225, 227, 229, 231, 233, - 234, 236, 239, 242, 245, 246, 249, 250, 253, 254, - 257, 260, 263, 266, 269, 270, 272, 275, 278, 281, - 284, 287, 290, 293, 296, 299, 302, 305, 308, 311, - 314, 319, 322, 324, 327, 328, 337, 338, 340, 341, - 343, 344, 346, 348, 351, 353, 355, 360, 361, 363, - 364, 367, 368, 371, 373, 377, 379, 381, 383, 385, - 387, 389, 390, 392, 394, 396, 398, 401, 403, 407, - 409, 411, 416, 418, 420, 422, 424, 426, 428, 430, - 431, 433, 437, 442, 453, 454, 463, 466, 471, 472, - 480, 481, 484, 486, 490, 492, 493, 497, 499, 502, - 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, - 524, 526, 528, 530, 532, 534, 536, 538, 540, 543, - 546, 550, 554, 558, 561, 562, 564, 576, 577, 581, - 583, 593, 594, 600, 601, 608, 609, 611, 625, 640, - 654, 656, 658, 660, 662, 664, 666, 668, 670, 673, - 676, 679, 682, 685, 688, 691, 694, 697, 700, 704, - 708, 710, 713, 716, 718, 721, 724, 727, 729, 732, - 733, 735, 736, 739, 740, 744, 746, 750, 752, 756, - 758, 760, 762, 763, 766, 767, 770, 772, 773, 775, - 779, 783, 787, 791, 794, 797, 803, 809, 812, 815, - 816, 820, 822, 824, 826, 827, 831, 833, 841, 846, - 850, 854, 855, 857, 858, 861, 863, 868, 871, 874, - 876, 878, 881, 883, 885, 888, 891, 895, 897, 899, - 901, 904, 907, 909, 911, 913, 915, 917, 919, 921, - 923, 925, 927, 929, 931, 935, 936, 941, 942, 944 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const short int yyrhs[] = -{ - 125, 0, -1, 126, -1, 125, 126, -1, -1, 127, - 128, -1, 160, -1, 130, -1, 132, -1, 170, -1, - 164, -1, 165, -1, 166, -1, 151, -1, 146, -1, - 150, -1, 159, -1, 171, -1, 172, -1, 181, -1, - 183, -1, 184, -1, 185, -1, 186, -1, 187, -1, - 188, -1, 189, -1, 136, -1, 138, -1, 129, -1, - 155, -1, 158, -1, 143, -1, 211, -1, 215, -1, - 213, -1, 133, -1, 210, -1, 192, -1, 231, -1, - 249, -1, 173, -1, 3, 102, 131, 103, -1, 22, - -1, 131, 104, 22, -1, 4, -1, 97, 206, 134, - 235, 105, 174, 135, 106, 107, -1, -1, 102, 206, - 103, -1, 98, 190, -1, -1, 18, 254, 137, 140, - -1, -1, 214, 18, 254, 139, 140, -1, 105, 141, - 106, 107, -1, 142, -1, 141, 142, -1, 173, -1, - 33, 190, -1, 34, 190, -1, -1, 85, 22, 144, - 105, 145, 106, 107, -1, 129, -1, 145, 129, -1, - -1, 87, 147, 105, 148, 106, -1, 149, -1, 148, - 149, -1, 22, -1, 88, 22, -1, -1, 86, 152, - 105, 153, 106, -1, 154, -1, 153, 154, -1, 22, - -1, 20, 102, 157, 103, -1, 22, -1, 108, 22, - -1, 156, 72, 22, -1, 156, 72, 108, 22, -1, - 156, -1, 195, 109, 195, -1, 21, -1, 89, 235, - -1, 161, 162, 163, -1, 42, -1, 43, -1, 22, - -1, 23, -1, -1, 82, -1, 36, 23, -1, 37, - 23, -1, 38, 23, -1, -1, 8, 190, -1, -1, - 9, 190, -1, -1, 10, 190, -1, 17, 190, -1, - 39, 190, -1, 40, 190, -1, 41, 190, -1, -1, - 173, -1, 26, 190, -1, 27, 190, -1, 28, 190, - -1, 29, 190, -1, 30, 190, -1, 31, 190, -1, - 14, 190, -1, 15, 190, -1, 11, 190, -1, 12, - 190, -1, 13, 190, -1, 16, 190, -1, 5, 190, - -1, 6, 190, -1, 7, 23, 194, 190, -1, 191, - 21, -1, 19, -1, 191, 19, -1, -1, 68, 195, - 235, 193, 105, 196, 106, 107, -1, -1, 23, -1, - -1, 22, -1, -1, 197, -1, 198, -1, 197, 198, - -1, 155, -1, 158, -1, 22, 200, 235, 199, -1, - -1, 104, -1, -1, 110, 205, -1, -1, 110, 202, - -1, 205, -1, 202, 203, 205, -1, 109, -1, 111, - -1, 112, -1, 113, -1, 114, -1, 115, -1, -1, - 108, -1, 116, -1, 109, -1, 111, -1, 204, 208, - -1, 207, -1, 206, 71, 207, -1, 22, -1, 206, - -1, 254, 102, 209, 103, -1, 83, -1, 82, -1, - 91, -1, 92, -1, 93, -1, 24, -1, 90, -1, - -1, 202, -1, 209, 104, 202, -1, 84, 250, 22, - 107, -1, 84, 250, 102, 253, 22, 103, 102, 255, - 103, 107, -1, -1, 45, 22, 212, 235, 105, 221, - 106, 107, -1, 214, 215, -1, 100, 117, 255, 118, - -1, -1, 44, 206, 216, 217, 235, 220, 107, -1, - -1, 119, 218, -1, 219, -1, 218, 104, 219, -1, - 206, -1, -1, 105, 221, 106, -1, 222, -1, 221, - 222, -1, 155, -1, 158, -1, 143, -1, 211, -1, - 215, -1, 133, -1, 210, -1, 192, -1, 182, -1, - 173, -1, 175, -1, 176, -1, 177, -1, 178, -1, - 179, -1, 180, -1, 225, -1, 224, -1, 244, -1, - 35, 190, -1, 34, 190, -1, 46, 223, 119, -1, - 47, 223, 119, -1, 48, 223, 119, -1, 49, 119, - -1, -1, 50, -1, 230, 116, 22, 102, 103, 256, - 234, 235, 107, 239, 240, -1, -1, 99, 226, 227, - -1, 227, -1, 22, 102, 241, 103, 256, 235, 228, - 107, 239, -1, -1, 120, 102, 241, 103, 121, -1, - -1, 120, 250, 102, 241, 103, 121, -1, -1, 67, - -1, 250, 22, 102, 241, 103, 233, 256, 234, 235, - 229, 107, 239, 240, -1, 250, 94, 232, 102, 241, - 103, 233, 256, 234, 235, 229, 107, 239, 240, -1, - 94, 250, 102, 241, 103, 233, 256, 234, 235, 229, - 107, 239, 240, -1, 111, -1, 109, -1, 112, -1, - 113, -1, 122, -1, 114, -1, 115, -1, 123, -1, - 117, 117, -1, 118, 118, -1, 111, 110, -1, 109, - 110, -1, 112, 110, -1, 113, 110, -1, 122, 110, - -1, 114, 110, -1, 115, 110, -1, 123, 110, -1, - 117, 117, 110, -1, 118, 118, 110, -1, 116, -1, - 102, 103, -1, 120, 121, -1, 117, -1, 117, 110, - -1, 110, 110, -1, 108, 110, -1, 118, -1, 118, - 110, -1, -1, 73, -1, -1, 110, 82, -1, -1, - 113, 236, 113, -1, 237, -1, 236, 104, 237, -1, - 22, -1, 22, 110, 238, -1, 22, -1, 24, -1, - 82, -1, -1, 32, 190, -1, -1, 25, 190, -1, - 242, -1, -1, 243, -1, 242, 104, 243, -1, 75, - 195, 201, -1, 76, 195, 201, -1, 77, 195, 201, - -1, 78, 195, -1, 79, 195, -1, 80, 102, 241, - 103, 195, -1, 81, 102, 241, 103, 195, -1, 96, - 195, -1, 251, 201, -1, -1, 74, 245, 246, -1, - 246, -1, 247, -1, 249, -1, -1, 67, 248, 231, - -1, 231, -1, 250, 22, 235, 107, 167, 168, 169, - -1, 73, 254, 253, 252, -1, 254, 253, 252, -1, - 250, 195, 235, -1, -1, 114, -1, -1, 253, 112, - -1, 206, -1, 206, 117, 255, 118, -1, 45, 206, - -1, 70, 52, -1, 52, -1, 70, -1, 70, 53, - -1, 53, -1, 54, -1, 70, 54, -1, 54, 54, - -1, 70, 54, 54, -1, 55, -1, 56, -1, 51, - -1, 69, 57, -1, 70, 57, -1, 57, -1, 58, - -1, 59, -1, 60, -1, 61, -1, 62, -1, 63, - -1, 64, -1, 65, -1, 66, -1, 101, -1, 250, - -1, 255, 104, 250, -1, -1, 95, 102, 257, 103, - -1, -1, 206, -1, 257, 104, 206, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned short int yyrline[] = -{ - 0, 289, 289, 290, 293, 293, 312, 313, 314, 315, - 316, 317, 318, 319, 320, 321, 322, 323, 327, 331, - 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, - 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, - 357, 358, 371, 374, 377, 382, 391, 430, 434, 508, - 513, 513, 519, 519, 558, 572, 573, 576, 580, 589, - 600, 600, 637, 638, 641, 641, 668, 669, 672, 677, - 682, 682, 707, 708, 711, 716, 729, 732, 735, 738, - 743, 744, 749, 755, 782, 807, 810, 815, 816, 832, - 835, 838, 843, 848, 853, 856, 861, 864, 869, 872, - 877, 883, 888, 893, 898, 901, 904, 909, 914, 919, - 924, 929, 934, 939, 944, 950, 956, 962, 971, 977, - 982, 988, 991, 992, 1003, 1003, 1014, 1017, 1022, 1025, - 1030, 1031, 1034, 1035, 1038, 1039, 1040, 1073, 1074, 1077, - 1078, 1081, 1084, 1089, 1090, 1108, 1111, 1114, 1117, 1120, - 1123, 1128, 1131, 1134, 1137, 1140, 1145, 1163, 1164, 1172, - 1177, 1187, 1197, 1201, 1205, 1209, 1213, 1217, 1221, 1227, - 1232, 1238, 1256, 1260, 1283, 1283, 1303, 1328, 1333, 1333, - 1382, 1383, 1386, 1387, 1390, 1405, 1408, 1413, 1414, 1417, - 1418, 1419, 1420, 1421, 1422, 1423, 1424, 1425, 1429, 1433, - 1440, 1447, 1454, 1461, 1468, 1475, 1476, 1477, 1478, 1489, - 1500, 1507, 1514, 1521, 1530, 1533, 1538, 1587, 1587, 1588, - 1591, 1617, 1620, 1627, 1630, 1638, 1641, 1646, 1663, 1688, - 1766, 1767, 1768, 1769, 1770, 1771, 1772, 1773, 1774, 1775, - 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, - 1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1797, - 1800, 1805, 1808, 1816, 1819, 1825, 1829, 1841, 1845, 1851, - 1855, 1859, 1865, 1868, 1873, 1876, 1881, 1929, 1934, 1940, - 1967, 1976, 1985, 1994, 2002, 2010, 2025, 2040, 2046, 2052, - 2052, 2053, 2056, 2057, 2060, 2060, 2061, 2064, 2097, 2103, - 2111, 2168, 2171, 2179, 2182, 2187, 2191, 2201, 2214, 2217, - 2220, 2223, 2226, 2229, 2232, 2235, 2238, 2241, 2244, 2247, - 2250, 2253, 2256, 2259, 2262, 2265, 2268, 2271, 2274, 2277, - 2280, 2283, 2286, 2291, 2297, 2313, 2316, 2343, 2349, 2356 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE -/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "TK_OPTIONS", "TK_NOEMITTERS", "TK_DOC", - "TK_EXPORTEDDOC", "TK_MAKEFILE", "TK_ACCESSCODE", "TK_GETCODE", - "TK_SETCODE", "TK_PREINITCODE", "TK_POSTINITCODE", "TK_UNITCODE", - "TK_MODCODE", "TK_TYPECODE", "TK_PREPYCODE", "TK_COPYING", - "TK_MAPPEDTYPE", "TK_CODELINE", "TK_IF", "TK_END", "TK_NAME", - "TK_PATHNAME", "TK_STRING", "TK_VIRTUALCATCHERCODE", "TK_TRAVERSECODE", - "TK_CLEARCODE", "TK_READBUFFERCODE", "TK_WRITEBUFFERCODE", - "TK_SEGCOUNTCODE", "TK_CHARBUFFERCODE", "TK_METHODCODE", "TK_FROMTYPE", - "TK_TOTYPE", "TK_TOSUBCLASS", "TK_INCLUDE", "TK_OPTINCLUDE", "TK_IMPORT", - "TK_EXPHEADERCODE", "TK_MODHEADERCODE", "TK_TYPEHEADERCODE", "TK_MODULE", - "TK_CMODULE", "TK_CLASS", "TK_STRUCT", "TK_PUBLIC", "TK_PROTECTED", - "TK_PRIVATE", "TK_SIGNALS", "TK_SLOTS", "TK_BOOL", "TK_SHORT", "TK_INT", - "TK_LONG", "TK_FLOAT", "TK_DOUBLE", "TK_CHAR", "TK_WCHAR_T", "TK_VOID", - "TK_PYOBJECT", "TK_PYTUPLE", "TK_PYLIST", "TK_PYDICT", "TK_PYCALLABLE", - "TK_PYSLICE", "TK_PYTYPE", "TK_VIRTUAL", "TK_ENUM", "TK_SIGNED", - "TK_UNSIGNED", "TK_SCOPE", "TK_LOGICAL_OR", "TK_CONST", "TK_STATIC", - "TK_SIPSIGNAL", "TK_SIPSLOT", "TK_SIPANYSLOT", "TK_SIPRXCON", - "TK_SIPRXDIS", "TK_SIPSLOTCON", "TK_SIPSLOTDIS", "TK_NUMBER", "TK_REAL", - "TK_TYPEDEF", "TK_NAMESPACE", "TK_TIMELINE", "TK_PLATFORMS", - "TK_FEATURE", "TK_LICENSE", "TK_QCHAR", "TK_TRUE", "TK_FALSE", "TK_NULL", - "TK_OPERATOR", "TK_THROW", "TK_QOBJECT", "TK_EXCEPTION", "TK_RAISECODE", - "TK_EXPLICIT", "TK_TEMPLATE", "TK_ELLIPSIS", "'('", "')'", "','", "'{'", - "'}'", "';'", "'!'", "'-'", "'='", "'+'", "'*'", "'/'", "'&'", "'|'", - "'~'", "'<'", "'>'", "':'", "'['", "']'", "'%'", "'^'", "$accept", - "specification", "statement", "@1", "modstatement", "nsstatement", - "options", "optionlist", "noemitters", "exception", "baseexception", - "raisecode", "mappedtype", "@2", "mappedtypetmpl", "@3", "mtdefinition", - "mtbody", "mtline", "namespace", "@4", "nsbody", "platforms", "@5", - "platformlist", "platform", "feature", "timeline", "@6", "qualifierlist", - "qualifiername", "ifstart", "oredqualifiers", "qualifiers", "ifend", - "license", "module", "modlang", "modname", "optnumber", "include", - "optinclude", "import", "optaccesscode", "optgetcode", "optsetcode", - "copying", "exphdrcode", "modhdrcode", "typehdrcode", "opttypehdrcode", - "travcode", "clearcode", "readbufcode", "writebufcode", "segcountcode", - "charbufcode", "modcode", "typecode", "preinitcode", "postinitcode", - "unitcode", "prepycode", "doc", "exporteddoc", "makefile", "codeblock", - "codelines", "enum", "@7", "optfilename", "optname", "optenumbody", - "enumbody", "enumline", "optcomma", "optenumassign", "optassign", "expr", - "binop", "optunop", "value", "scopedname", "scopepart", "simplevalue", - "exprlist", "typedef", "struct", "@8", "classtmpl", "template", "class", - "@9", "superclasses", "superlist", "superclass", "optclassbody", - "classbody", "classline", "optslot", "dtor", "ctor", "@10", "simplector", - "optctorsig", "optsig", "optvirtual", "function", "operatorname", - "optconst", "optabstract", "optflags", "flaglist", "flag", "flagvalue", - "methodcode", "virtualcatchercode", "arglist", "rawarglist", "argvalue", - "varmember", "@11", "varmem", "member", "@12", "variable", "cpptype", - "argtype", "optref", "deref", "basetype", "cpptypelist", "optexceptions", - "exceptionlist", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const unsigned short int yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, - 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, - 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, 40, 41, 44, 123, 125, 59, 33, 45, - 61, 43, 42, 47, 38, 124, 126, 60, 62, 58, - 91, 93, 37, 94 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned short int yyr1[] = -{ - 0, 124, 125, 125, 127, 126, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, - 129, 129, 130, 131, 131, 132, 133, 134, 134, 135, - 137, 136, 139, 138, 140, 141, 141, 142, 142, 142, - 144, 143, 145, 145, 147, 146, 148, 148, 149, 150, - 152, 151, 153, 153, 154, 155, 156, 156, 156, 156, - 157, 157, 158, 159, 160, 161, 161, 162, 162, 163, - 163, 164, 165, 166, 167, 167, 168, 168, 169, 169, - 170, 171, 172, 173, 174, 174, 175, 176, 177, 178, - 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, - 189, 190, 191, 191, 193, 192, 194, 194, 195, 195, - 196, 196, 197, 197, 198, 198, 198, 199, 199, 200, - 200, 201, 201, 202, 202, 203, 203, 203, 203, 203, - 203, 204, 204, 204, 204, 204, 205, 206, 206, 207, - 208, 208, 208, 208, 208, 208, 208, 208, 208, 209, - 209, 209, 210, 210, 212, 211, 213, 214, 216, 215, - 217, 217, 218, 218, 219, 220, 220, 221, 221, 222, - 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, - 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, - 222, 222, 222, 222, 223, 223, 224, 226, 225, 225, - 227, 228, 228, 229, 229, 230, 230, 231, 231, 231, - 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, 232, 233, - 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, - 238, 238, 239, 239, 240, 240, 241, 242, 242, 242, - 243, 243, 243, 243, 243, 243, 243, 243, 243, 245, - 244, 244, 246, 246, 248, 247, 247, 249, 250, 250, - 251, 252, 252, 253, 253, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 255, 255, 256, 256, 257, 257, 257 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = -{ - 0, 2, 1, 2, 0, 2, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 4, 1, 3, 1, 9, 0, 3, 2, - 0, 4, 0, 5, 4, 1, 2, 1, 2, 2, - 0, 7, 1, 2, 0, 5, 1, 2, 1, 2, - 0, 5, 1, 2, 1, 4, 1, 2, 3, 4, - 1, 3, 1, 2, 3, 1, 1, 1, 1, 0, - 1, 2, 2, 2, 0, 2, 0, 2, 0, 2, - 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 4, 2, 1, 2, 0, 8, 0, 1, 0, 1, - 0, 1, 1, 2, 1, 1, 4, 0, 1, 0, - 2, 0, 2, 1, 3, 1, 1, 1, 1, 1, - 1, 0, 1, 1, 1, 1, 2, 1, 3, 1, - 1, 4, 1, 1, 1, 1, 1, 1, 1, 0, - 1, 3, 4, 10, 0, 8, 2, 4, 0, 7, - 0, 2, 1, 3, 1, 0, 3, 1, 2, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, - 3, 3, 3, 2, 0, 1, 11, 0, 3, 1, - 9, 0, 5, 0, 6, 0, 1, 13, 14, 13, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, - 1, 2, 2, 1, 2, 2, 2, 1, 2, 0, - 1, 0, 2, 0, 3, 1, 3, 1, 3, 1, - 1, 1, 0, 2, 0, 2, 1, 0, 1, 3, - 3, 3, 3, 2, 2, 5, 5, 2, 2, 0, - 3, 1, 1, 1, 0, 3, 1, 7, 4, 3, - 3, 0, 1, 0, 2, 1, 4, 2, 2, 1, - 1, 2, 1, 1, 2, 2, 3, 1, 1, 1, - 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 3, 0, 4, 0, 1, 3 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const unsigned short int yydefact[] = -{ - 4, 4, 2, 0, 1, 3, 0, 45, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, - 159, 0, 0, 0, 0, 0, 0, 85, 86, 0, - 0, 319, 309, 312, 313, 317, 318, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, 128, 0, 310, - 0, 0, 0, 70, 64, 0, 263, 0, 0, 0, - 332, 5, 29, 7, 8, 36, 27, 28, 32, 14, - 15, 13, 30, 31, 16, 6, 0, 10, 11, 12, - 9, 17, 18, 41, 19, 20, 21, 22, 23, 24, - 25, 26, 38, 305, 157, 37, 33, 35, 0, 34, - 39, 40, 0, 303, 0, 122, 118, 0, 119, 126, - 114, 115, 116, 112, 117, 100, 0, 50, 128, 91, - 92, 93, 101, 102, 103, 178, 159, 307, 315, 129, - 263, 320, 308, 311, 314, 321, 303, 0, 60, 0, - 0, 69, 0, 83, 0, 47, 0, 87, 88, 89, - 0, 0, 0, 176, 263, 0, 301, 43, 0, 123, - 121, 127, 0, 0, 76, 0, 80, 0, 0, 180, - 263, 124, 316, 301, 0, 303, 0, 0, 0, 267, - 0, 265, 277, 0, 263, 333, 0, 90, 84, 158, - 0, 52, 277, 0, 0, 0, 231, 0, 230, 232, - 233, 235, 236, 250, 253, 257, 0, 234, 237, 0, - 304, 302, 299, 42, 0, 120, 0, 51, 77, 0, - 75, 128, 0, 263, 0, 0, 298, 172, 0, 0, - 74, 0, 72, 68, 0, 66, 0, 0, 264, 128, - 128, 128, 128, 128, 0, 0, 128, 0, 276, 278, - 128, 141, 0, 0, 0, 177, 306, 0, 0, 94, - 251, 256, 241, 255, 240, 242, 243, 245, 246, 254, - 238, 258, 239, 252, 244, 247, 277, 44, 0, 0, - 0, 55, 57, 78, 0, 81, 184, 181, 182, 185, - 225, 130, 0, 62, 0, 0, 71, 73, 65, 67, - 269, 270, 271, 268, 266, 141, 141, 141, 283, 284, - 277, 277, 287, 259, 0, 263, 151, 288, 48, 104, - 334, 53, 259, 0, 96, 248, 249, 0, 58, 59, - 0, 56, 79, 0, 225, 0, 0, 159, 0, 0, - 0, 0, 0, 0, 0, 0, 214, 214, 214, 0, - 294, 289, 217, 194, 191, 189, 190, 198, 199, 200, - 201, 202, 203, 204, 197, 196, 195, 192, 193, 225, - 187, 206, 205, 219, 0, 296, 207, 291, 292, 293, - 139, 134, 135, 0, 131, 132, 0, 0, 63, 280, - 281, 282, 0, 0, 260, 335, 279, 300, 152, 154, - 155, 153, 142, 0, 143, 105, 0, 335, 95, 0, - 98, 259, 54, 183, 225, 179, 113, 277, 106, 107, - 108, 109, 110, 111, 209, 208, 215, 0, 0, 0, - 213, 0, 0, 0, 0, 188, 0, 151, 263, 0, - 133, 0, 61, 128, 128, 0, 261, 145, 146, 147, - 148, 149, 150, 151, 167, 163, 162, 168, 164, 165, - 166, 160, 156, 0, 0, 0, 261, 97, 0, 297, - 335, 186, 0, 210, 211, 212, 295, 0, 294, 290, - 0, 218, 175, 0, 140, 137, 125, 0, 285, 286, - 337, 0, 263, 144, 151, 49, 0, 263, 99, 261, - 335, 0, 0, 138, 136, 0, 338, 0, 262, 223, - 170, 0, 46, 223, 263, 263, 335, 173, 336, 0, - 0, 0, 161, 151, 0, 223, 221, 261, 339, 0, - 272, 171, 272, 0, 0, 0, 263, 277, 0, 274, - 274, 272, 277, 272, 0, 0, 273, 0, 229, 227, - 274, 0, 220, 272, 0, 275, 228, 0, 274, 224, - 222, 216 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const short int yydefgoto[] = -{ - -1, 1, 2, 3, 61, 62, 63, 158, 64, 353, - 184, 465, 66, 163, 67, 257, 217, 280, 281, 354, - 176, 294, 69, 140, 234, 235, 70, 71, 139, 231, - 232, 355, 166, 167, 356, 74, 75, 76, 149, 188, - 77, 78, 79, 324, 410, 469, 80, 81, 82, 357, - 406, 358, 359, 360, 361, 362, 363, 84, 364, 85, - 86, 87, 88, 89, 90, 91, 106, 107, 365, 225, - 162, 130, 383, 384, 385, 504, 438, 317, 402, 453, - 403, 404, 93, 94, 462, 511, 366, 367, 170, 97, - 295, 368, 169, 223, 287, 288, 335, 369, 370, 427, - 371, 372, 433, 373, 535, 521, 374, 375, 209, 395, - 492, 143, 180, 181, 303, 539, 548, 247, 248, 249, - 376, 432, 377, 378, 431, 379, 250, 251, 212, 156, - 103, 186, 446, 507 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -484 -static const short int yypact[] = -{ - -484, 79, -484, 506, -484, -484, 29, -484, 127, 127, - 132, 127, 127, 127, 127, 127, 127, 1004, 58, -484, - -484, 139, 157, 176, 127, 127, 127, -484, -484, 179, - 189, -484, -484, -484, 158, -484, -484, -484, -484, -484, - -484, -484, -484, -484, -484, -484, -484, 193, 159, 137, - 1004, 221, 195, -484, -484, 203, 115, 221, 179, 112, - -484, -484, -484, -484, -484, -484, -484, -484, -484, -484, - -484, -484, -484, -484, -484, -484, 69, -484, -484, -484, - -484, -484, -484, -484, -484, -484, -484, -484, -484, -484, - -484, -484, -484, -28, -484, -484, -484, -484, 41, -484, - -484, -484, 12, -484, 204, -484, -484, 92, -484, 207, - -484, -484, -484, -484, -484, -484, 179, -484, 14, -484, - -484, -484, -484, -484, -484, 160, 2, 160, -484, -484, - 115, -484, -484, -484, 178, -484, -484, 19, -484, 128, - 130, -484, 214, -484, 135, -18, 221, -484, -484, 165, - 179, 221, 1004, -484, -39, 240, 47, -484, 46, -484, - -484, -484, 127, 136, 133, 226, 177, 151, 148, 141, - 115, -484, -484, 47, 154, -484, 153, 241, 242, 152, - -14, -484, 867, 179, 115, -484, -40, -484, -484, -484, - -6, -484, 867, 161, 162, 183, 186, 187, 188, 190, - 197, 198, 213, -484, -15, -1, 146, 215, 216, 169, - -484, -484, -484, -484, 266, -484, 39, -484, -484, 17, - -484, 193, 179, 115, 184, 219, -484, -484, 6, 814, - -484, 18, -484, -484, 20, -484, 28, 214, -484, 193, - 193, 193, 193, 193, 201, 235, 193, 225, 234, -484, - 193, 230, -27, 238, 221, -484, -484, 136, 244, 336, - -484, -484, -484, -484, -484, -484, -484, -484, -484, -484, - 249, -484, 251, -484, -484, -484, 867, -484, 127, 127, - 13, -484, -484, -484, 342, -484, 160, 261, -484, 262, - 755, 108, 265, -484, 113, 325, -484, -484, -484, -484, - -484, -484, -484, -484, -484, 230, 230, 230, -484, -484, - 867, 867, -484, 297, 867, 115, -8, -484, -484, 331, - -484, -484, 297, 127, 366, -484, -484, 273, -484, -484, - 270, -484, -484, 179, 755, 272, 127, 278, 127, 127, - 127, 127, 127, 127, 127, 127, 332, 332, 332, 267, - 268, -484, -484, -484, -484, -484, -484, -484, -484, -484, - -484, -484, -484, -484, -484, -484, -484, -484, -484, 589, - -484, -484, -484, -484, 269, -484, -484, -484, -484, -484, - 271, -484, -484, 281, 108, -484, 286, 282, -484, -484, - -484, -484, 287, 288, -484, 298, -484, -484, -484, -484, - -484, -484, 109, 927, -484, -484, 294, 298, -484, 127, - 387, 297, -484, -484, 672, -484, -484, 867, -484, -484, - -484, -484, -484, -484, -484, -484, -484, 283, 284, 285, - -484, 978, 420, 379, 299, -484, 383, -8, 115, 300, - -484, 221, -484, 193, 193, 306, 301, -484, -484, -484, - -484, -484, -484, -8, -484, -484, -484, -484, -484, -484, - -484, -34, -484, 307, 127, 304, 301, -484, 127, -484, - 298, -484, 309, -484, -484, -484, -484, 33, -484, -484, - 278, -484, -484, 311, -484, 310, -484, 81, -484, -484, - 179, 333, 115, -484, 84, -484, 313, 115, -484, 301, - 298, 314, 315, -484, -484, 316, 160, 100, -484, 302, - 109, 102, -484, 302, 115, 115, 298, -484, -484, 179, - 221, 317, -484, -8, 318, 302, 308, 301, 160, 319, - 394, 109, 394, 320, 328, 324, 115, 867, 127, 407, - 407, 394, 867, 394, 326, 335, -484, 127, -484, -484, - 407, 337, -484, 394, 322, -484, -484, 323, 407, -484, - -484, -484 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const short int yypgoto[] = -{ - -484, -484, 433, -484, -484, -197, -484, -484, -484, 11, - -484, -484, -484, -484, -484, -484, 182, -484, 155, 21, - -484, -484, -484, -484, -484, 211, -484, -484, -484, -484, - 210, 10, -484, -484, 15, -484, -484, -484, -484, -484, - -484, -484, -484, -484, -484, -484, -484, -484, -484, 22, - -484, -484, -484, -484, -484, -484, -484, -484, -484, -484, - -484, -484, -484, -484, -484, -484, -9, -484, 23, -484, - -484, -98, -484, -484, 63, -484, -484, -169, -436, -484, - -484, -376, -20, 303, -484, -484, 24, 26, -484, -484, - 445, 16, -484, -484, -484, 116, -484, 117, -321, -139, - -484, -484, -484, 25, -484, -443, -484, -2, -484, -291, - -433, -119, -484, 217, -484, -472, -483, -171, -484, 138, - -484, -484, 30, -484, -484, 27, 5, -484, 277, -87, - -5, -129, -384, -484 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -306 -static const short int yytable[] = -{ - 108, 100, 110, 111, 112, 113, 114, 115, 102, 125, - 127, 171, 117, 72, 65, 122, 123, 124, 73, 99, - 168, 258, 190, 466, 68, 83, 92, 95, 292, 96, - 101, 407, 293, 497, 154, 193, 164, 150, 145, 283, - 230, 174, 233, 150, 150, 136, 278, 279, 435, 173, - 300, 224, 301, 150, 26, 501, 137, 549, 510, 152, - 540, 484, 144, 192, 254, 253, 514, 556, -305, 550, - 524, 552, 278, 279, 142, 561, 318, 493, 255, 4, - 26, 558, 533, 151, 183, 29, 499, 531, 228, 151, - 237, 147, 148, 435, 536, 269, 127, 388, 254, 238, - 398, 399, 270, 400, 289, 327, 155, -174, 401, 271, - 302, 159, 256, 160, 153, -174, 515, 272, 210, 330, - 470, 175, 165, 285, 296, 284, 298, 155, 18, 19, - 380, 104, 527, 18, 19, 20, 389, 390, 391, 392, - 393, 305, 306, 307, 308, 309, 105, 191, 312, 213, - 214, 185, 315, 215, 26, 109, 185, 29, 30, 210, - 118, 211, 119, 252, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, - 120, 47, 48, 49, 505, 254, 50, -169, -169, 132, - 133, 134, 398, 399, 135, 400, 397, 51, 52, 121, - 401, 20, 286, 518, 519, 522, 523, 57, 428, 429, - 58, 126, 128, 59, 60, 129, 131, 138, 447, 387, - 448, 449, 450, 451, 452, 141, 157, 100, 142, 146, - 161, 150, 172, 177, 102, 178, 179, 182, 282, 72, - 65, 216, -129, 20, 73, 99, 472, 187, 218, 219, - 68, 83, 92, 95, 220, 96, 101, 221, 229, 320, - 222, 227, 236, 230, 233, 260, 116, 273, 259, 328, - 329, 276, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 277, 290, - 48, 49, 100, 261, 50, 102, 262, 263, 264, 102, - 265, 381, 282, 310, 72, 65, 382, 266, 267, 73, - 99, 153, 487, 286, 408, 68, 83, 92, 95, 485, - 96, 101, 60, 268, 291, 274, 275, 416, 313, 418, - 419, 420, 421, 422, 423, 424, 425, 311, 314, 102, - 316, 405, 194, 319, 323, 488, 489, 322, 195, 196, - 197, 198, 199, 200, 201, 202, 203, 204, 205, 325, - 206, 326, 207, 208, 332, 333, 545, 334, 386, 29, - 394, 551, 26, 509, 102, 409, 411, 412, 513, 415, - 417, 437, 426, 461, -226, 436, 430, 439, 441, 442, - 443, 444, 464, 445, 381, 525, 526, 468, 463, 382, - 467, 480, 473, 474, 475, 483, 482, 486, 490, 494, - 496, 491, 500, 502, 503, 508, 192, 544, 516, 102, - 512, 537, 520, 517, 530, 532, 538, 541, 534, 476, - 542, 543, 547, 553, 5, 331, 477, 102, 554, 321, - 557, 297, 20, 559, 560, 299, 185, 440, 98, 413, - 226, 414, 396, 189, 304, 495, 0, 0, 481, 498, - 0, 0, 479, 0, 0, 116, 0, 0, 0, 0, - 506, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 478, 0, 48, - 49, 0, 0, 50, 0, 0, 0, 0, 0, 528, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, - 7, 8, 9, 10, 57, 0, 0, 11, 12, 13, - 14, 60, 15, 16, 17, 529, 18, 19, 20, 546, - 0, 0, 0, 0, 0, 0, 0, 0, 555, 0, - 0, 0, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 0, 0, 0, 0, 0, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 0, 47, 48, 49, 0, 0, 50, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 51, 52, 53, 54, 55, 56, 0, 0, 0, 0, - 57, 0, 0, 58, 336, 0, 59, 60, 0, 18, - 19, 337, 0, 0, 0, 338, 339, 340, 341, 342, - 343, 0, 0, 344, 345, 0, 0, 0, 0, 0, - 26, 0, 0, 29, 30, 346, 347, 348, 349, 0, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 350, 47, 48, 49, - 0, 0, 50, 351, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 51, 52, 0, 0, 0, 0, 0, - 0, 0, 0, 57, 0, 0, 58, 336, 352, 0, - 60, 0, 18, 19, 337, 434, 0, 0, 338, 339, - 340, 341, 342, 343, 0, 0, 344, 345, 0, 0, - 0, 0, 0, 26, 0, 0, 29, 30, 346, 347, - 348, 349, 0, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 350, - 47, 48, 49, 0, 0, 50, 351, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 51, 52, 0, 0, - 0, 0, 0, 0, 0, 0, 57, 0, 0, 58, - 336, 352, 0, 60, 0, 18, 19, 337, 471, 0, - 0, 338, 339, 340, 341, 342, 343, 0, 0, 344, - 345, 0, 0, 0, 0, 0, 26, 0, 0, 29, - 30, 346, 347, 348, 349, 0, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 350, 47, 48, 49, 0, 0, 50, 351, - 0, 0, 0, 0, 18, 19, 20, 0, 0, 51, - 52, 0, 0, 0, 0, 0, 0, 0, 0, 57, - 0, 0, 58, 0, 352, 26, 60, 0, 29, 30, - 0, 0, 0, 0, 0, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 0, 47, 48, 49, 0, 0, 50, 0, 20, - 0, 0, 0, 0, 0, 0, 0, 0, 51, 52, - 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, - 0, 58, 116, 0, 59, 60, 0, 0, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 0, 0, 48, 49, 0, 0, - 50, 0, 239, 240, 241, 242, 243, 244, 245, 20, - 0, 454, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 246, 0, 0, 0, 0, 60, 0, - 0, 0, 116, 0, 0, 0, 0, 0, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 0, 0, 48, 49, 0, 0, - 20, 0, 0, 0, 0, 0, 0, 0, 0, 455, - 456, 0, 0, 0, 0, 0, 0, 457, 458, 459, - 460, 0, 0, 116, 0, 0, 20, 0, 60, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 0, 0, 48, 49, 116, - 0, 50, 0, 0, 0, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 0, 57, 48, 49, 0, 0, 0, 0, 60, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 60 -}; - -static const short int yycheck[] = -{ - 9, 3, 11, 12, 13, 14, 15, 16, 3, 29, - 30, 130, 17, 3, 3, 24, 25, 26, 3, 3, - 118, 192, 151, 407, 3, 3, 3, 3, 22, 3, - 3, 322, 229, 466, 22, 154, 22, 71, 58, 22, - 22, 22, 22, 71, 71, 50, 33, 34, 369, 136, - 22, 170, 24, 71, 41, 22, 51, 540, 494, 18, - 532, 437, 57, 102, 104, 184, 499, 550, 102, 541, - 513, 543, 33, 34, 113, 558, 103, 453, 118, 0, - 41, 553, 525, 117, 102, 44, 470, 523, 175, 117, - 104, 22, 23, 414, 527, 110, 116, 294, 104, 113, - 108, 109, 117, 111, 223, 276, 94, 105, 116, 110, - 82, 19, 118, 21, 98, 113, 500, 118, 112, 106, - 411, 102, 108, 221, 106, 108, 106, 94, 20, 21, - 22, 102, 516, 20, 21, 22, 305, 306, 307, 310, - 311, 239, 240, 241, 242, 243, 19, 152, 246, 103, - 104, 146, 250, 162, 41, 23, 151, 44, 45, 112, - 102, 114, 23, 183, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 23, 68, 69, 70, 103, 104, 73, 103, 104, 52, - 53, 54, 108, 109, 57, 111, 315, 84, 85, 23, - 116, 22, 222, 103, 104, 103, 104, 94, 347, 348, - 97, 22, 54, 100, 101, 22, 57, 22, 109, 106, - 111, 112, 113, 114, 115, 22, 22, 229, 113, 117, - 23, 71, 54, 105, 229, 105, 22, 102, 216, 229, - 229, 105, 109, 22, 229, 229, 417, 82, 22, 72, - 229, 229, 229, 229, 103, 229, 229, 109, 105, 254, - 119, 107, 110, 22, 22, 103, 45, 121, 107, 278, - 279, 102, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 22, 105, - 69, 70, 294, 110, 73, 290, 110, 110, 110, 294, - 110, 291, 280, 102, 294, 294, 291, 110, 110, 294, - 294, 295, 441, 333, 323, 294, 294, 294, 294, 438, - 294, 294, 101, 110, 105, 110, 110, 336, 103, 338, - 339, 340, 341, 342, 343, 344, 345, 102, 104, 334, - 110, 319, 102, 105, 8, 443, 444, 103, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 110, - 120, 110, 122, 123, 22, 104, 537, 105, 103, 44, - 73, 542, 41, 492, 369, 9, 103, 107, 497, 107, - 102, 110, 50, 403, 116, 116, 119, 106, 102, 107, - 103, 103, 98, 95, 384, 514, 515, 10, 403, 384, - 409, 22, 119, 119, 119, 22, 107, 107, 102, 102, - 106, 110, 103, 102, 104, 82, 102, 536, 103, 414, - 107, 102, 120, 107, 107, 107, 32, 107, 120, 431, - 102, 107, 25, 107, 1, 280, 431, 432, 103, 257, - 103, 231, 22, 121, 121, 234, 441, 384, 3, 333, - 173, 334, 314, 150, 237, 464, -1, -1, 433, 468, - -1, -1, 432, -1, -1, 45, -1, -1, -1, -1, - 490, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, -1, 69, - 70, -1, -1, 73, -1, -1, -1, -1, -1, 519, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, - 4, 5, 6, 7, 94, -1, -1, 11, 12, 13, - 14, 101, 16, 17, 18, 520, 20, 21, 22, 538, - -1, -1, -1, -1, -1, -1, -1, -1, 547, -1, - -1, -1, 36, 37, 38, 39, 40, 41, 42, 43, - 44, 45, -1, -1, -1, -1, -1, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, -1, 68, 69, 70, -1, -1, 73, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 84, 85, 86, 87, 88, 89, -1, -1, -1, -1, - 94, -1, -1, 97, 15, -1, 100, 101, -1, 20, - 21, 22, -1, -1, -1, 26, 27, 28, 29, 30, - 31, -1, -1, 34, 35, -1, -1, -1, -1, -1, - 41, -1, -1, 44, 45, 46, 47, 48, 49, -1, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - -1, -1, 73, 74, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 84, 85, -1, -1, -1, -1, -1, - -1, -1, -1, 94, -1, -1, 97, 15, 99, -1, - 101, -1, 20, 21, 22, 106, -1, -1, 26, 27, - 28, 29, 30, 31, -1, -1, 34, 35, -1, -1, - -1, -1, -1, 41, -1, -1, 44, 45, 46, 47, - 48, 49, -1, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, -1, -1, 73, 74, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 84, 85, -1, -1, - -1, -1, -1, -1, -1, -1, 94, -1, -1, 97, - 15, 99, -1, 101, -1, 20, 21, 22, 106, -1, - -1, 26, 27, 28, 29, 30, 31, -1, -1, 34, - 35, -1, -1, -1, -1, -1, 41, -1, -1, 44, - 45, 46, 47, 48, 49, -1, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, -1, -1, 73, 74, - -1, -1, -1, -1, 20, 21, 22, -1, -1, 84, - 85, -1, -1, -1, -1, -1, -1, -1, -1, 94, - -1, -1, 97, -1, 99, 41, 101, -1, 44, 45, - -1, -1, -1, -1, -1, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, -1, 68, 69, 70, -1, -1, 73, -1, 22, - -1, -1, -1, -1, -1, -1, -1, -1, 84, 85, - -1, -1, -1, -1, -1, -1, -1, -1, 94, -1, - -1, 97, 45, -1, 100, 101, -1, -1, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, -1, -1, 69, 70, -1, -1, - 73, -1, 75, 76, 77, 78, 79, 80, 81, 22, - -1, 24, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 96, -1, -1, -1, -1, 101, -1, - -1, -1, 45, -1, -1, -1, -1, -1, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, -1, -1, 69, 70, -1, -1, - 22, -1, -1, -1, -1, -1, -1, -1, -1, 82, - 83, -1, -1, -1, -1, -1, -1, 90, 91, 92, - 93, -1, -1, 45, -1, -1, 22, -1, 101, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, -1, -1, 69, 70, 45, - -1, 73, -1, -1, -1, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, -1, 94, 69, 70, -1, -1, -1, -1, 101, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 101 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const unsigned short int yystos[] = -{ - 0, 125, 126, 127, 0, 126, 3, 4, 5, 6, - 7, 11, 12, 13, 14, 16, 17, 18, 20, 21, - 22, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 68, 69, 70, - 73, 84, 85, 86, 87, 88, 89, 94, 97, 100, - 101, 128, 129, 130, 132, 133, 136, 138, 143, 146, - 150, 151, 155, 158, 159, 160, 161, 164, 165, 166, - 170, 171, 172, 173, 181, 183, 184, 185, 186, 187, - 188, 189, 192, 206, 207, 210, 211, 213, 214, 215, - 231, 249, 250, 254, 102, 19, 190, 191, 190, 23, - 190, 190, 190, 190, 190, 190, 45, 254, 102, 23, - 23, 23, 190, 190, 190, 206, 22, 206, 54, 22, - 195, 57, 52, 53, 54, 57, 254, 250, 22, 152, - 147, 22, 113, 235, 250, 206, 117, 22, 23, 162, - 71, 117, 18, 215, 22, 94, 253, 22, 131, 19, - 21, 23, 194, 137, 22, 108, 156, 157, 195, 216, - 212, 235, 54, 253, 22, 102, 144, 105, 105, 22, - 236, 237, 102, 102, 134, 250, 255, 82, 163, 207, - 255, 254, 102, 235, 102, 108, 109, 110, 111, 112, - 113, 114, 115, 116, 117, 118, 120, 122, 123, 232, - 112, 114, 252, 103, 104, 190, 105, 140, 22, 72, - 103, 109, 119, 217, 235, 193, 252, 107, 253, 105, - 22, 153, 154, 22, 148, 149, 110, 104, 113, 75, - 76, 77, 78, 79, 80, 81, 96, 241, 242, 243, - 250, 251, 206, 235, 104, 118, 118, 139, 241, 107, - 103, 110, 110, 110, 110, 110, 110, 110, 110, 110, - 117, 110, 118, 121, 110, 110, 102, 22, 33, 34, - 141, 142, 173, 22, 108, 195, 206, 218, 219, 235, - 105, 105, 22, 129, 145, 214, 106, 154, 106, 149, - 22, 24, 82, 238, 237, 195, 195, 195, 195, 195, - 102, 102, 195, 103, 104, 195, 110, 201, 103, 105, - 250, 140, 103, 8, 167, 110, 110, 241, 190, 190, - 106, 142, 22, 104, 105, 220, 15, 22, 26, 27, - 28, 29, 30, 31, 34, 35, 46, 47, 48, 49, - 67, 74, 99, 133, 143, 155, 158, 173, 175, 176, - 177, 178, 179, 180, 182, 192, 210, 211, 215, 221, - 222, 224, 225, 227, 230, 231, 244, 246, 247, 249, - 22, 155, 158, 196, 197, 198, 103, 106, 129, 201, - 201, 201, 241, 241, 73, 233, 243, 235, 108, 109, - 111, 116, 202, 204, 205, 173, 174, 233, 190, 9, - 168, 103, 107, 219, 221, 107, 190, 102, 190, 190, - 190, 190, 190, 190, 190, 190, 50, 223, 223, 223, - 119, 248, 245, 226, 106, 222, 116, 110, 200, 106, - 198, 102, 107, 103, 103, 95, 256, 109, 111, 112, - 113, 114, 115, 203, 24, 82, 83, 90, 91, 92, - 93, 206, 208, 254, 98, 135, 256, 190, 10, 169, - 233, 106, 241, 119, 119, 119, 231, 250, 67, 246, - 22, 227, 107, 22, 205, 235, 107, 255, 195, 195, - 102, 110, 234, 205, 102, 190, 106, 234, 190, 256, - 103, 22, 102, 104, 199, 103, 206, 257, 82, 235, - 202, 209, 107, 235, 234, 256, 103, 107, 103, 104, - 120, 229, 103, 104, 229, 235, 235, 256, 206, 250, - 107, 202, 107, 229, 120, 228, 234, 102, 32, 239, - 239, 107, 102, 107, 235, 241, 190, 25, 240, 240, - 239, 241, 239, 107, 103, 190, 240, 103, 239, 121, - 121, 240 -}; - -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# if defined (__STDC__) || defined (__cplusplus) -# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ - -#define YYFAIL goto yyerrlab - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror ("syntax error: cannot back up");\ - YYERROR; \ - } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -/* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). */ - -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - ((Current).first_line = (Rhs)[1].first_line, \ - (Current).first_column = (Rhs)[1].first_column, \ - (Current).last_line = (Rhs)[N].last_line, \ - (Current).last_column = (Rhs)[N].last_column) -#endif - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (YYLEX_PARAM) -#else -# define YYLEX yylex () -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) - -# define YYDSYMPRINT(Args) \ -do { \ - if (yydebug) \ - yysymprint Args; \ -} while (0) - -# define YYDSYMPRINTF(Title, Token, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Token, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_stack_print (short int *bottom, short int *top) -#else -static void -yy_stack_print (bottom, top) - short int *bottom; - short int *top; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_reduce_print (int yyrule) -#else -static void -yy_reduce_print (yyrule) - int yyrule; -#endif -{ - int yyi; - unsigned int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", - yyrule - 1, yylno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (Rule); \ -} while (0) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YYDSYMPRINT(Args) -# define YYDSYMPRINTF(Title, Token, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) -yystrlen (const char *yystr) -# else -yystrlen (yystr) - const char *yystr; -# endif -{ - register const char *yys = yystr; - - while (*yys++ != '\0') - continue; - - return yys - yystr - 1; -} -# endif -# endif - -# ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -# if defined (__STDC__) || defined (__cplusplus) -yystpcpy (char *yydest, const char *yysrc) -# else -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif -{ - register char *yyd = yydest; - register const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -#endif /* !YYERROR_VERBOSE */ - - - -#if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) -#else -static void -yysymprint (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - if (yytype < YYNTOKENS) - { - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); -# ifdef YYPRINT - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - } - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - switch (yytype) - { - default: - break; - } - YYFPRINTF (yyoutput, ")"); -} - -#endif /* ! YYDEBUG */ -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yydestruct (int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yytype, yyvaluep) - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - switch (yytype) - { - - default: - break; - } -} - - -/* Prevent warnings from -Wmissing-prototypes. */ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM); -# else -int yyparse (); -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - - -/* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; - - - -/*----------. -| yyparse. | -`----------*/ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int -yyparse (void) -#else -int -yyparse () - -#endif -#endif -{ - - register int yystate; - register int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - short int yyssa[YYINITDEPTH]; - short int *yyss = yyssa; - register short int *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - register YYSTYPE *yyvsp; - - - -#define YYPOPSTACK (yyvsp--, yyssp--) - - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; - - - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - short int *yyss1 = yyss; - - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow ("parser stack overflow", - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyoverflowlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyoverflowlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - short int *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyoverflowlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; - - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - yystate = yyn; - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 4: -#line 293 "parser.y" - { - /* - * We don't do these in parserEOF() because the parser - * is reading ahead and that would be too early. - */ - - if (previousFile != NULL) - { - handleEOF(); - - if (newContext.prevmod != NULL) - handleEOM(); - - free(previousFile); - previousFile = NULL; - } - } - break; - - case 17: -#line 323 "parser.y" - { - if (notSkipping()) - appendCodeBlock(¤tSpec->exphdrcode, yyvsp[0].codeb); - } - break; - - case 18: -#line 327 "parser.y" - { - if (notSkipping() && inMainModule()) - appendCodeBlock(¤tSpec -> hdrcode,yyvsp[0].codeb); - } - break; - - case 19: -#line 331 "parser.y" - { - if (notSkipping() && inMainModule()) - appendCodeBlock(¤tSpec -> cppcode,yyvsp[0].codeb); - } - break; - - case 41: -#line 358 "parser.y" - { - if (notSkipping()) - { - classDef *scope = currentScope(); - - if (scope == NULL) - yyerror("%TypeHeaderCode can only be used in a namespace, class or mapped type"); - - appendCodeBlock(&scope->hdrcode, yyvsp[0].codeb); - } - } - break; - - case 43: -#line 374 "parser.y" - { - appendString(¤tSpec->options, yyvsp[0].text); - } - break; - - case 44: -#line 377 "parser.y" - { - appendString(¤tSpec->options, yyvsp[0].text); - } - break; - - case 45: -#line 382 "parser.y" - { - if (notSkipping()) - { - yywarning("%SIPNoEmitters is deprecated, please use %SIPOptions instead"); - appendString(¤tSpec->options, "QtNoEmitters"); - } - } - break; - - case 46: -#line 391 "parser.y" - { - if (notSkipping()) - { - exceptionDef *xd; - char *pyname; - - if (currentSpec->genc) - yyerror("%Exception not allowed in a C module"); - - pyname = getPythonName(&yyvsp[-5].optflags, scopedNameTail(yyvsp[-7].scpvalp)); - - checkAttributes(currentSpec, NULL, pyname, FALSE); - - xd = findException(currentSpec, yyvsp[-7].scpvalp, TRUE); - - if (xd->cd != NULL) - yyerror("%Exception name has already been seen as a class name - it must be defined before being used"); - - if (xd->iff->module != NULL) - yyerror("The %Exception has already been defined"); - - /* Complete the definition. */ - - xd->iff->module = currentModule; - xd->pyname = pyname; - xd->bibase = yyvsp[-6].exceptionbase.bibase; - xd->base = yyvsp[-6].exceptionbase.base; - xd->hdrcode = yyvsp[-3].codeb; - xd->raisecode = yyvsp[-2].codeb; - - if (xd->bibase != NULL || xd->base != NULL) - xd->exceptionnr = currentModule->nrexceptions++; - - if (inMainModule() && xd->base != NULL && xd->base->iff->module != currentModule) - addToUsedList(¤tSpec->used, xd->base->iff); - } - } - break; - - case 47: -#line 430 "parser.y" - { - yyval.exceptionbase.bibase = NULL; - yyval.exceptionbase.base = NULL; - } - break; - - case 48: -#line 434 "parser.y" - { - exceptionDef *xd; - - yyval.exceptionbase.bibase = NULL; - yyval.exceptionbase.base = NULL; - - /* See if it is a defined exception. */ - for (xd = currentSpec->exceptions; xd != NULL; xd = xd->next) - if (sameScopedName(xd->iff->fqcname, yyvsp[-1].scpvalp)) - { - yyval.exceptionbase.base = xd; - break; - } - - if (xd == NULL && yyvsp[-1].scpvalp->next == NULL && strncmp(yyvsp[-1].scpvalp->name, "SIP_", 4) == 0) - { - /* See if it is a builtin exception. */ - - static char *builtins[] = { - "Exception", - "StopIteration", - "StandardError", - "ArithmeticError", - "LookupError", - "AssertionError", - "AttributeError", - "EOFError", - "FloatingPointError", - "EnvironmentError", - "IOError", - "OSError", - "ImportError", - "IndexError", - "KeyError", - "KeyboardInterrupt", - "MemoryError", - "NameError", - "OverflowError", - "RuntimeError", - "NotImplementedError", - "SyntaxError", - "IndentationError", - "TabError", - "ReferenceError", - "SystemError", - "SystemExit", - "TypeError", - "UnboundLocalError", - "UnicodeError", - "UnicodeEncodeError", - "UnicodeDecodeError", - "UnicodeTranslateError", - "ValueError", - "ZeroDivisionError", - "WindowsError", - "VMSError", - NULL - }; - - char **cp; - - for (cp = builtins; *cp != NULL; ++cp) - if (strcmp(yyvsp[-1].scpvalp->name + 4, *cp) == 0) - { - yyval.exceptionbase.bibase = *cp; - break; - } - } - - if (yyval.exceptionbase.bibase == NULL && yyval.exceptionbase.base == NULL) - yyerror("Unknown exception base type"); - } - break; - - case 49: -#line 508 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 50: -#line 513 "parser.y" - { - if (notSkipping()) - currentMappedType = newMappedType(currentSpec,&yyvsp[0].memArg); - } - break; - - case 52: -#line 519 "parser.y" - { - int a; - - if (currentSpec->genc) - yyerror("%MappedType templates not allowed in a C module"); - - /* Check the template arguments are all just simple names. */ - for (a = 0; a < yyvsp[-2].signature.nrArgs; ++a) - if (yyvsp[-2].signature.args[a].atype != defined_type || yyvsp[-2].signature.args[a].u.snd->next != NULL) - yyerror("%MappedType template arguments must be simple names"); - - if (yyvsp[0].memArg.atype != template_type) - yyerror("%MappedType template must map a template type"); - - if (notSkipping()) - { - mappedTypeTmplDef *mtt; - - /* Check a template hasn't already been provided. */ - for (mtt = currentSpec->mappedtypetemplates; mtt != NULL; mtt = mtt->next) - if (sameScopedName(mtt->mt->type.u.td->fqname, yyvsp[0].memArg.u.td->fqname) && sameTemplateSignature(&mtt->mt->type.u.td->types, &yyvsp[0].memArg.u.td->types, TRUE)) - yyerror("%MappedType template for this type has already been defined"); - - yyvsp[0].memArg.nrderefs = 0; - yyvsp[0].memArg.argflags = 0; - - mtt = sipMalloc(sizeof (mappedTypeTmplDef)); - - mtt->sig = yyvsp[-2].signature; - mtt->mt = allocMappedType(&yyvsp[0].memArg); - mtt->next = currentSpec->mappedtypetemplates; - - currentSpec->mappedtypetemplates = mtt; - - currentMappedType = mtt->mt; - } - } - break; - - case 54: -#line 558 "parser.y" - { - if (notSkipping()) - { - if (currentMappedType->convfromcode == NULL) - yyerror("%MappedType must have a %ConvertFromTypeCode directive"); - - if (currentMappedType->convtocode == NULL) - yyerror("%MappedType must have a %ConvertToTypeCode directive"); - - currentMappedType = NULL; - } - } - break; - - case 57: -#line 576 "parser.y" - { - if (notSkipping()) - appendCodeBlock(¤tMappedType -> hdrcode,yyvsp[0].codeb); - } - break; - - case 58: -#line 580 "parser.y" - { - if (notSkipping()) - { - if (currentMappedType -> convfromcode != NULL) - yyerror("%MappedType has more than one %ConvertFromTypeCode directive"); - - currentMappedType -> convfromcode = yyvsp[0].codeb; - } - } - break; - - case 59: -#line 589 "parser.y" - { - if (notSkipping()) - { - if (currentMappedType -> convtocode != NULL) - yyerror("%MappedType has more than one %ConvertToTypeCode directive"); - - currentMappedType -> convtocode = yyvsp[0].codeb; - } - } - break; - - case 60: -#line 600 "parser.y" - { - if (currentSpec -> genc) - yyerror("namespace definition not allowed in a C module"); - - if (notSkipping()) - { - classDef *ns; - - ns = newClass(currentSpec,namespace_iface,text2scopedName(yyvsp[0].text)); - - pushScope(ns); - - sectionFlags = 0; - } - } - break; - - case 61: -#line 614 "parser.y" - { - if (inMainModule()) - { - classDef *ns = currentScope(); - - if (!isUsedName(ns->iff->name)) - { - varDef *vd; - - for (vd = currentSpec->vars; vd != NULL; vd = vd->next) - if (vd->ecd == ns) - { - setIsUsedName(ns->iff->name); - break; - } - } - } - - if (notSkipping()) - popScope(); - } - break; - - case 64: -#line 641 "parser.y" - { - qualDef *qd; - - for (qd = currentModule -> qualifiers; qd != NULL; qd = qd -> next) - if (qd -> qtype == platform_qualifier) - yyerror("%Platforms has already been defined for this module"); - } - break; - - case 65: -#line 648 "parser.y" - { - qualDef *qd; - int nrneeded; - - /* - * Check that exactly one platform in the set was - * requested. - */ - - nrneeded = 0; - - for (qd = currentModule -> qualifiers; qd != NULL; qd = qd -> next) - if (qd -> qtype == platform_qualifier && isNeeded(qd)) - ++nrneeded; - - if (nrneeded > 1) - yyerror("No more than one of these %Platforms must be specified with the -t flag"); - } - break; - - case 68: -#line 672 "parser.y" - { - newQualifier(currentModule,-1,-1,yyvsp[0].text,platform_qualifier); - } - break; - - case 69: -#line 677 "parser.y" - { - newQualifier(currentModule,-1,-1,yyvsp[0].text,feature_qualifier); - } - break; - - case 70: -#line 682 "parser.y" - { - currentTimelineOrder = 0; - } - break; - - case 71: -#line 685 "parser.y" - { - qualDef *qd; - int nrneeded; - - /* - * Check that exactly one time slot in the set was - * requested. - */ - - nrneeded = 0; - - for (qd = currentModule -> qualifiers; qd != NULL; qd = qd -> next) - if (qd -> qtype == time_qualifier && isNeeded(qd)) - ++nrneeded; - - if (nrneeded > 1) - yyerror("At most one of this %Timeline must be specified with the -t flag"); - - currentModule -> nrtimelines++; - } - break; - - case 74: -#line 711 "parser.y" - { - newQualifier(currentModule,currentModule -> nrtimelines,currentTimelineOrder++,yyvsp[0].text,time_qualifier); - } - break; - - case 75: -#line 716 "parser.y" - { - if (skipStackPtr >= MAX_NESTED_IF) - yyerror("Internal error: increase the value of MAX_NESTED_IF"); - - /* Nested %Ifs are implicit logical ands. */ - - if (skipStackPtr > 0) - yyvsp[-1].boolean = (yyvsp[-1].boolean && skipStack[skipStackPtr - 1]); - - skipStack[skipStackPtr++] = yyvsp[-1].boolean; - } - break; - - case 76: -#line 729 "parser.y" - { - yyval.boolean = platOrFeature(yyvsp[0].text,FALSE); - } - break; - - case 77: -#line 732 "parser.y" - { - yyval.boolean = platOrFeature(yyvsp[0].text,TRUE); - } - break; - - case 78: -#line 735 "parser.y" - { - yyval.boolean = (platOrFeature(yyvsp[0].text,FALSE) || yyvsp[-2].boolean); - } - break; - - case 79: -#line 738 "parser.y" - { - yyval.boolean = (platOrFeature(yyvsp[0].text,TRUE) || yyvsp[-3].boolean); - } - break; - - case 81: -#line 744 "parser.y" - { - yyval.boolean = timePeriod(yyvsp[-2].text,yyvsp[0].text); - } - break; - - case 82: -#line 749 "parser.y" - { - if (skipStackPtr-- <= 0) - yyerror("Too many %End directives"); - } - break; - - case 83: -#line 755 "parser.y" - { - optFlag *of; - - if (yyvsp[0].optflags.nrFlags == 0) - yyerror("%License details not specified"); - - if ((of = findOptFlag(&yyvsp[0].optflags,"Type",string_flag)) == NULL) - yyerror("%License type not specified"); - - currentModule -> license = sipMalloc(sizeof (licenseDef)); - - currentModule -> license -> type = of -> fvalue.sval; - - currentModule -> license -> licensee = - ((of = findOptFlag(&yyvsp[0].optflags,"Licensee",string_flag)) != NULL) - ? of -> fvalue.sval : NULL; - - currentModule -> license -> timestamp = - ((of = findOptFlag(&yyvsp[0].optflags,"Timestamp",string_flag)) != NULL) - ? of -> fvalue.sval : NULL; - - currentModule -> license -> sig = - ((of = findOptFlag(&yyvsp[0].optflags,"Signature",string_flag)) != NULL) - ? of -> fvalue.sval : NULL; - } - break; - - case 84: -#line 782 "parser.y" - { - /* Check the module hasn't already been defined. */ - - moduleDef *mod; - - for (mod = currentSpec -> modules; mod != NULL; mod = mod -> next) - if (mod->fullname != NULL && strcmp(mod->fullname, yyvsp[-1].text) == 0) - yyerror("Module is already defined"); - - currentModule->fullname = yyvsp[-1].text; - - if ((currentModule->name = strrchr(yyvsp[-1].text, '.')) != NULL) - currentModule->name++; - else - currentModule->name = yyvsp[-1].text; - - currentModule -> version = yyvsp[0].number; - - if (currentSpec -> genc < 0) - currentSpec -> genc = yyvsp[-2].boolean; - else if (currentSpec -> genc != yyvsp[-2].boolean) - yyerror("Cannot mix C and C++ modules"); - } - break; - - case 85: -#line 807 "parser.y" - { - yyval.boolean = FALSE; - } - break; - - case 86: -#line 810 "parser.y" - { - yyval.boolean = TRUE; - } - break; - - case 88: -#line 816 "parser.y" - { - /* - * The grammar design is a bit broken and this is the - * easiest way to allow periods in module names. - */ - - char *cp; - - for (cp = yyvsp[0].text; *cp != '\0'; ++cp) - if (*cp != '.' && *cp != '_' && !isalnum(*cp)) - yyerror("Invalid character in module name"); - - yyval.text = yyvsp[0].text; - } - break; - - case 89: -#line 832 "parser.y" - { - yyval.number = -1; - } - break; - - case 91: -#line 838 "parser.y" - { - parseFile(NULL,yyvsp[0].text,NULL,FALSE); - } - break; - - case 92: -#line 843 "parser.y" - { - parseFile(NULL,yyvsp[0].text,NULL,TRUE); - } - break; - - case 93: -#line 848 "parser.y" - { - newImport(yyvsp[0].text); - } - break; - - case 94: -#line 853 "parser.y" - { - yyval.codeb = NULL; - } - break; - - case 95: -#line 856 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 96: -#line 861 "parser.y" - { - yyval.codeb = NULL; - } - break; - - case 97: -#line 864 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 98: -#line 869 "parser.y" - { - yyval.codeb = NULL; - } - break; - - case 99: -#line 872 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 100: -#line 877 "parser.y" - { - if (inMainModule()) - appendCodeBlock(¤tSpec -> copying,yyvsp[0].codeb); - } - break; - - case 101: -#line 883 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 102: -#line 888 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 103: -#line 893 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 104: -#line 898 "parser.y" - { - yyval.codeb = NULL; - } - break; - - case 106: -#line 904 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 107: -#line 909 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 108: -#line 914 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 109: -#line 919 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 110: -#line 924 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 111: -#line 929 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 112: -#line 934 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 113: -#line 939 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 114: -#line 944 "parser.y" - { - if (notSkipping() && inMainModule()) - appendCodeBlock(¤tSpec -> preinitcode,yyvsp[0].codeb); - } - break; - - case 115: -#line 950 "parser.y" - { - if (notSkipping() && inMainModule()) - appendCodeBlock(¤tSpec -> postinitcode,yyvsp[0].codeb); - } - break; - - case 116: -#line 956 "parser.y" - { - if (notSkipping() && inMainModule()) - appendCodeBlock(¤tSpec->unitcode, yyvsp[0].codeb); - } - break; - - case 117: -#line 962 "parser.y" - { - /* - * This is a no-op and is retained for compatibility - * until the last use of it (by SIP v3) can be removed - * from PyQt. - */ - } - break; - - case 118: -#line 971 "parser.y" - { - if (inMainModule()) - appendCodeBlock(¤tSpec -> docs,yyvsp[0].codeb); - } - break; - - case 119: -#line 977 "parser.y" - { - appendCodeBlock(¤tSpec -> docs,yyvsp[0].codeb); - } - break; - - case 120: -#line 982 "parser.y" - { - if (inMainModule()) - yywarning("%Makefile is ignored, please use the -b flag instead"); - } - break; - - case 123: -#line 992 "parser.y" - { - yyval.codeb = yyvsp[-1].codeb; - - append(&yyval.codeb->frag, yyvsp[0].codeb->frag); - - free(yyvsp[0].codeb->frag); - free(yyvsp[0].codeb->filename); - free(yyvsp[0].codeb); - } - break; - - case 124: -#line 1003 "parser.y" - { - if (notSkipping()) - { - if (sectionFlags != 0 && (sectionFlags & ~(SECT_IS_PUBLIC | SECT_IS_PROT)) != 0) - yyerror("Class enums must be in the public or protected sections"); - - currentEnum = newEnum(currentSpec,currentModule,yyvsp[-1].text,&yyvsp[0].optflags,sectionFlags); - } - } - break; - - case 126: -#line 1014 "parser.y" - { - yyval.text = NULL; - } - break; - - case 127: -#line 1017 "parser.y" - { - yyval.text = yyvsp[0].text; - } - break; - - case 128: -#line 1022 "parser.y" - { - yyval.text = NULL; - } - break; - - case 129: -#line 1025 "parser.y" - { - yyval.text = yyvsp[0].text; - } - break; - - case 136: -#line 1040 "parser.y" - { - if (notSkipping()) - { - /* - * Note that we don't use the assigned value. - * This is a hangover from when enums where - * generated in Python. We can remove it when - * we have got around to updating all the .sip - * files. - */ - enumMemberDef *emd, **tail; - - emd = sipMalloc(sizeof (enumMemberDef)); - - emd -> pyname = cacheName(currentSpec, getPythonName(&yyvsp[-1].optflags, yyvsp[-3].text)); - emd -> cname = yyvsp[-3].text; - emd -> ed = currentEnum; - emd -> next = NULL; - - checkAttributes(currentSpec,emd -> ed -> ecd,emd -> pyname -> text,FALSE); - - /* Append to preserve the order. */ - for (tail = ¤tEnum->members; *tail != NULL; tail = &(*tail)->next) - ; - - *tail = emd; - - if (inMainModule()) - setIsUsedName(emd -> pyname); - } - } - break; - - case 141: -#line 1081 "parser.y" - { - yyval.valp = NULL; - } - break; - - case 142: -#line 1084 "parser.y" - { - yyval.valp = yyvsp[0].valp; - } - break; - - case 144: -#line 1090 "parser.y" - { - valueDef *vd; - - if (yyvsp[-2].valp -> vtype == string_value || yyvsp[0].valp -> vtype == string_value) - yyerror("Invalid binary operator for string"); - - /* Find the last value in the existing expression. */ - - for (vd = yyvsp[-2].valp; vd -> next != NULL; vd = vd -> next) - ; - - vd -> vbinop = yyvsp[-1].qchar; - vd -> next = yyvsp[0].valp; - - yyval.valp = yyvsp[-2].valp; - } - break; - - case 145: -#line 1108 "parser.y" - { - yyval.qchar = '-'; - } - break; - - case 146: -#line 1111 "parser.y" - { - yyval.qchar = '+'; - } - break; - - case 147: -#line 1114 "parser.y" - { - yyval.qchar = '*'; - } - break; - - case 148: -#line 1117 "parser.y" - { - yyval.qchar = '/'; - } - break; - - case 149: -#line 1120 "parser.y" - { - yyval.qchar = '&'; - } - break; - - case 150: -#line 1123 "parser.y" - { - yyval.qchar = '|'; - } - break; - - case 151: -#line 1128 "parser.y" - { - yyval.qchar = '\0'; - } - break; - - case 152: -#line 1131 "parser.y" - { - yyval.qchar = '!'; - } - break; - - case 153: -#line 1134 "parser.y" - { - yyval.qchar = '~'; - } - break; - - case 154: -#line 1137 "parser.y" - { - yyval.qchar = '-'; - } - break; - - case 155: -#line 1140 "parser.y" - { - yyval.qchar = '+'; - } - break; - - case 156: -#line 1145 "parser.y" - { - if (yyvsp[-1].qchar != '\0' && yyvsp[0].value.vtype == string_value) - yyerror("Invalid unary operator for string"); - - /* - * Convert the value to a simple expression on the - * heap. - */ - - yyval.valp = sipMalloc(sizeof (valueDef)); - - *yyval.valp = yyvsp[0].value; - yyval.valp -> vunop = yyvsp[-1].qchar; - yyval.valp -> vbinop = '\0'; - yyval.valp -> next = NULL; - } - break; - - case 158: -#line 1164 "parser.y" - { - if (currentSpec -> genc) - yyerror("Scoped names are not allowed in a C module"); - - appendScopedName(&yyvsp[-2].scpvalp,yyvsp[0].scpvalp); - } - break; - - case 159: -#line 1172 "parser.y" - { - yyval.scpvalp = text2scopePart(yyvsp[0].text); - } - break; - - case 160: -#line 1177 "parser.y" - { - /* - * We let the C++ compiler decide if the value is a - * valid one - no point in building a full C++ parser - * here. - */ - - yyval.value.vtype = scoped_value; - yyval.value.u.vscp = yyvsp[0].scpvalp; - } - break; - - case 161: -#line 1187 "parser.y" - { - fcallDef *fcd; - - fcd = sipMalloc(sizeof (fcallDef)); - *fcd = yyvsp[-1].fcall; - fcd -> type = yyvsp[-3].memArg; - - yyval.value.vtype = fcall_value; - yyval.value.u.fcd = fcd; - } - break; - - case 162: -#line 1197 "parser.y" - { - yyval.value.vtype = real_value; - yyval.value.u.vreal = yyvsp[0].real; - } - break; - - case 163: -#line 1201 "parser.y" - { - yyval.value.vtype = numeric_value; - yyval.value.u.vnum = yyvsp[0].number; - } - break; - - case 164: -#line 1205 "parser.y" - { - yyval.value.vtype = numeric_value; - yyval.value.u.vnum = 1; - } - break; - - case 165: -#line 1209 "parser.y" - { - yyval.value.vtype = numeric_value; - yyval.value.u.vnum = 0; - } - break; - - case 166: -#line 1213 "parser.y" - { - yyval.value.vtype = numeric_value; - yyval.value.u.vnum = 0; - } - break; - - case 167: -#line 1217 "parser.y" - { - yyval.value.vtype = string_value; - yyval.value.u.vstr = yyvsp[0].text; - } - break; - - case 168: -#line 1221 "parser.y" - { - yyval.value.vtype = qchar_value; - yyval.value.u.vqchar = yyvsp[0].qchar; - } - break; - - case 169: -#line 1227 "parser.y" - { - /* No values. */ - - yyval.fcall.nrArgs = 0; - } - break; - - case 170: -#line 1232 "parser.y" - { - /* The single or first expression. */ - - yyval.fcall.args[0] = yyvsp[0].valp; - yyval.fcall.nrArgs = 1; - } - break; - - case 171: -#line 1238 "parser.y" - { - /* Check that it wasn't ...(,expression...). */ - - if (yyval.fcall.nrArgs == 0) - yyerror("First argument to function call is missing"); - - /* Check there is room. */ - - if (yyvsp[-2].fcall.nrArgs == MAX_NR_ARGS) - yyerror("Too many arguments to function call"); - - yyval.fcall = yyvsp[-2].fcall; - - yyval.fcall.args[yyval.fcall.nrArgs] = yyvsp[0].valp; - yyval.fcall.nrArgs++; - } - break; - - case 172: -#line 1256 "parser.y" - { - if (notSkipping()) - newTypedef(currentSpec,currentModule,yyvsp[-1].text,&yyvsp[-2].memArg); - } - break; - - case 173: -#line 1260 "parser.y" - { - if (notSkipping()) - { - argDef ftype; - signatureDef *sig; - - /* Create the full signature on the heap. */ - sig = sipMalloc(sizeof (signatureDef)); - *sig = yyvsp[-2].signature; - sig -> result = yyvsp[-8].memArg; - - /* Create the full type. */ - ftype.atype = function_type; - ftype.argflags = 0; - ftype.nrderefs = yyvsp[-6].number; - ftype.defval = NULL; - ftype.u.sa = sig; - - newTypedef(currentSpec,currentModule,yyvsp[-5].text,&ftype); - } - } - break; - - case 174: -#line 1283 "parser.y" - { - if (notSkipping()) - { - classDef *cd; - - cd = newClass(currentSpec,class_iface,text2scopedName(yyvsp[0].text)); - - pushScope(cd); - - sectionFlags = SECT_IS_PUBLIC; - } - } - break; - - case 175: -#line 1294 "parser.y" - { - if (notSkipping()) - { - finishClass(currentSpec, currentModule, currentScope(), &yyvsp[-4].optflags); - popScope(); - } - } - break; - - case 176: -#line 1303 "parser.y" - { - if (currentSpec->genc) - yyerror("Class templates not allowed in a C module"); - - if (notSkipping()) - { - classTmplDef *tcd; - - /* - * Make sure there is room for the extra class - * name argument. - */ - if (yyvsp[-1].signature.nrArgs == MAX_NR_ARGS) - yyerror("Internal error - increase the value of MAX_NR_ARGS"); - - tcd = sipMalloc(sizeof (classTmplDef)); - tcd->sig = yyvsp[-1].signature; - tcd->cd = yyvsp[0].klass; - tcd->next = currentSpec->classtemplates; - - currentSpec->classtemplates = tcd; - } - } - break; - - case 177: -#line 1328 "parser.y" - { - yyval.signature = yyvsp[-1].signature; - } - break; - - case 178: -#line 1333 "parser.y" - { - if (currentSpec -> genc) - yyerror("Class definition not allowed in a C module"); - - if (notSkipping()) - { - classDef *cd; - - cd = newClass(currentSpec, class_iface, scopeScopedName(yyvsp[0].scpvalp)); - - pushScope(cd); - - sectionFlags = SECT_IS_PRIVATE; - } - } - break; - - case 179: -#line 1347 "parser.y" - { - if (notSkipping()) - { - classDef *cd = currentScope(); - - /* - * See if the class was defined or just - * declared. - */ - if (yyvsp[-1].boolean) - { - if (yyvsp[-5].scpvalp->next != NULL) - yyerror("A scoped name cannot be given in a class definition"); - - } - else if (cd->supers != NULL) - yyerror("Class has super-classes but no definition"); - else - setIsOpaque(cd); - - finishClass(currentSpec, currentModule, cd, &yyvsp[-2].optflags); - popScope(); - - /* - * Check that external classes have only been - * declared at the global scope. - */ - if (isExternal(cd) && currentScope() != NULL) - yyerror("External classes can only be declared in the global scope"); - - yyval.klass = cd; - } - } - break; - - case 184: -#line 1390 "parser.y" - { - if (notSkipping()) - { - classDef *cd, *super; - - cd = currentScope(); - - super = findClass(currentSpec,class_iface,yyvsp[0].scpvalp); - - appendToClassList(&cd -> supers,super); - addToUsedList(&cd->iff->used, super->iff); - } - } - break; - - case 185: -#line 1405 "parser.y" - { - yyval.boolean = FALSE; - } - break; - - case 186: -#line 1408 "parser.y" - { - yyval.boolean = TRUE; - } - break; - - case 197: -#line 1425 "parser.y" - { - if (notSkipping()) - appendCodeBlock(¤tScope() -> cppcode,yyvsp[0].codeb); - } - break; - - case 198: -#line 1429 "parser.y" - { - if (notSkipping()) - appendCodeBlock(¤tScope() -> hdrcode,yyvsp[0].codeb); - } - break; - - case 199: -#line 1433 "parser.y" - { - if (currentScope()->travcode != NULL) - yyerror("%GCTraverseCode already given for class"); - - if (notSkipping()) - currentScope()->travcode = yyvsp[0].codeb; - } - break; - - case 200: -#line 1440 "parser.y" - { - if (currentScope()->clearcode != NULL) - yyerror("%GCClearCode already given for class"); - - if (notSkipping()) - currentScope()->clearcode = yyvsp[0].codeb; - } - break; - - case 201: -#line 1447 "parser.y" - { - if (currentScope()->readbufcode != NULL) - yyerror("%BIGetReadBufferCode already given for class"); - - if (notSkipping()) - currentScope()->readbufcode = yyvsp[0].codeb; - } - break; - - case 202: -#line 1454 "parser.y" - { - if (currentScope()->writebufcode != NULL) - yyerror("%BIGetWriteBufferCode already given for class"); - - if (notSkipping()) - currentScope()->writebufcode = yyvsp[0].codeb; - } - break; - - case 203: -#line 1461 "parser.y" - { - if (currentScope()->segcountcode != NULL) - yyerror("%BIGetSegCountCode already given for class"); - - if (notSkipping()) - currentScope()->segcountcode = yyvsp[0].codeb; - } - break; - - case 204: -#line 1468 "parser.y" - { - if (currentScope()->charbufcode != NULL) - yyerror("%BIGetCharBufferCode already given for class"); - - if (notSkipping()) - currentScope()->charbufcode = yyvsp[0].codeb; - } - break; - - case 208: -#line 1478 "parser.y" - { - if (notSkipping()) - { - classDef *cd = currentScope(); - - if (cd -> convtosubcode != NULL) - yyerror("Class has more than one %ConvertToSubClassCode directive"); - - cd -> convtosubcode = yyvsp[0].codeb; - } - } - break; - - case 209: -#line 1489 "parser.y" - { - if (notSkipping()) - { - classDef *cd = currentScope(); - - if (cd -> convtocode != NULL) - yyerror("Class has more than one %ConvertToTypeCode directive"); - - cd -> convtocode = yyvsp[0].codeb; - } - } - break; - - case 210: -#line 1500 "parser.y" - { - if (currentSpec -> genc) - yyerror("public section not allowed in a C module"); - - if (notSkipping()) - sectionFlags = SECT_IS_PUBLIC | yyvsp[-1].number; - } - break; - - case 211: -#line 1507 "parser.y" - { - if (currentSpec -> genc) - yyerror("protected section not allowed in a C module"); - - if (notSkipping()) - sectionFlags = SECT_IS_PROT | yyvsp[-1].number; - } - break; - - case 212: -#line 1514 "parser.y" - { - if (currentSpec -> genc) - yyerror("private section not allowed in a C module"); - - if (notSkipping()) - sectionFlags = SECT_IS_PRIVATE | yyvsp[-1].number; - } - break; - - case 213: -#line 1521 "parser.y" - { - if (currentSpec -> genc) - yyerror("signals section not allowed in a C module"); - - if (notSkipping()) - sectionFlags = SECT_IS_SIGNAL; - } - break; - - case 214: -#line 1530 "parser.y" - { - yyval.number = 0; - } - break; - - case 215: -#line 1533 "parser.y" - { - yyval.number = SECT_IS_SLOT; - } - break; - - case 216: -#line 1538 "parser.y" - { - /* Note that we allow non-virtual dtors in C modules. */ - - if (notSkipping()) - { - classDef *cd = currentScope(); - - if (strcmp(classBaseName(cd),yyvsp[-8].text) != 0) - yyerror("Destructor doesn't have the same name as its class"); - - if (isDtor(cd)) - yyerror("Destructor has already been defined"); - - if (currentSpec -> genc && yyvsp[-1].codeb == NULL) - yyerror("Destructor in C modules must include %MethodCode"); - - cd -> dealloccode = yyvsp[-1].codeb; - cd -> dtorcode = yyvsp[0].codeb; - cd -> dtorexceptions = yyvsp[-5].throwlist; - cd -> classflags |= sectionFlags; - - if (yyvsp[-4].number) - { - if (!yyvsp[-10].number) - yyerror("Abstract destructor must be virtual"); - - setIsAbstractClass(cd); - } - - /* - * The class has a shadow if we have a virtual dtor or some - * dtor code. - */ - if (yyvsp[-10].number || yyvsp[0].codeb != NULL) - { - if (currentSpec -> genc) - yyerror("Virtual destructor or %VirtualCatcherCode not allowed in a C module"); - - setHasShadow(cd); - } - - if (getReleaseGIL(&yyvsp[-3].optflags)) - setIsReleaseGILDtor(cd); - else if (getHoldGIL(&yyvsp[-3].optflags)) - setIsHoldGILDtor(cd); - } - } - break; - - case 217: -#line 1587 "parser.y" - {currentCtorIsExplicit = TRUE;} - break; - - case 220: -#line 1591 "parser.y" - { - /* Note that we allow ctors in C modules. */ - - if (notSkipping()) - { - if (currentSpec -> genc) - { - if (yyvsp[0].codeb == NULL && yyvsp[-6].signature.nrArgs != 0) - yyerror("Constructors with arguments in C modules must include %MethodCode"); - - if (currentCtorIsExplicit) - yyerror("Explicit constructors not allowed in a C module"); - } - - if ((sectionFlags & (SECT_IS_PUBLIC | SECT_IS_PROT | SECT_IS_PRIVATE)) == 0) - yyerror("Constructor must be in the public, private or protected sections"); - - newCtor(yyvsp[-8].text,sectionFlags,&yyvsp[-6].signature,&yyvsp[-3].optflags,yyvsp[0].codeb,yyvsp[-4].throwlist,yyvsp[-2].optsignature,currentCtorIsExplicit); - } - - free(yyvsp[-8].text); - - currentCtorIsExplicit = FALSE; - } - break; - - case 221: -#line 1617 "parser.y" - { - yyval.optsignature = NULL; - } - break; - - case 222: -#line 1620 "parser.y" - { - yyval.optsignature = sipMalloc(sizeof (signatureDef)); - - *yyval.optsignature = yyvsp[-2].signature; - } - break; - - case 223: -#line 1627 "parser.y" - { - yyval.optsignature = NULL; - } - break; - - case 224: -#line 1630 "parser.y" - { - yyval.optsignature = sipMalloc(sizeof (signatureDef)); - - *yyval.optsignature = yyvsp[-2].signature; - yyval.optsignature -> result = yyvsp[-4].memArg; - } - break; - - case 225: -#line 1638 "parser.y" - { - yyval.number = FALSE; - } - break; - - case 226: -#line 1641 "parser.y" - { - yyval.number = TRUE; - } - break; - - case 227: -#line 1646 "parser.y" - { - if (notSkipping()) - { - if (sectionFlags != 0 && (sectionFlags & (SECT_IS_PUBLIC | SECT_IS_PROT | SECT_IS_PRIVATE | SECT_IS_SLOT | SECT_IS_SIGNAL)) == 0) - yyerror("Class function must be in the public, private, protected, slot or signal sections"); - - yyvsp[-9].signature.result = yyvsp[-12].memArg; - - newFunction(currentSpec,currentModule, - sectionFlags,currentIsStatic, - currentOverIsVirt, - yyvsp[-11].text,&yyvsp[-9].signature,yyvsp[-7].number,yyvsp[-5].number,&yyvsp[-4].optflags,yyvsp[-1].codeb,yyvsp[0].codeb,yyvsp[-6].throwlist,yyvsp[-3].optsignature); - } - - currentIsStatic = FALSE; - currentOverIsVirt = FALSE; - } - break; - - case 228: -#line 1663 "parser.y" - { - if (notSkipping()) - { - classDef *cd = currentScope(); - - /* Handle the unary '+' and '-' operators. */ - if ((cd != NULL && yyvsp[-9].signature.nrArgs == 0) || (cd == NULL && yyvsp[-9].signature.nrArgs == 1)) - { - if (strcmp(yyvsp[-11].text, "__add__") == 0) - yyvsp[-11].text = "__pos__"; - else if (strcmp(yyvsp[-11].text, "__sub__") == 0) - yyvsp[-11].text = "__neg__"; - } - - yyvsp[-9].signature.result = yyvsp[-13].memArg; - - newFunction(currentSpec,currentModule, - sectionFlags,currentIsStatic, - currentOverIsVirt, - yyvsp[-11].text,&yyvsp[-9].signature,yyvsp[-7].number,yyvsp[-5].number,&yyvsp[-4].optflags,yyvsp[-1].codeb,yyvsp[0].codeb,yyvsp[-6].throwlist,yyvsp[-3].optsignature); - } - - currentIsStatic = FALSE; - currentOverIsVirt = FALSE; - } - break; - - case 229: -#line 1688 "parser.y" - { - classDef *scope = currentScope(); - - if (scope == NULL || yyvsp[-9].signature.nrArgs != 0) - yyerror("Operator casts must be specified in a class and have no arguments"); - - - if (notSkipping()) - { - char *sname; - - switch (yyvsp[-11].memArg.atype) - { - case defined_type: - sname = NULL; - break; - - case bool_type: - case cbool_type: - case short_type: - case ushort_type: - case int_type: - case cint_type: - case uint_type: - sname = "__int__"; - break; - - case long_type: - case ulong_type: - case longlong_type: - case ulonglong_type: - sname = "__long__"; - break; - - case float_type: - case cfloat_type: - case double_type: - case cdouble_type: - sname = "__float__"; - break; - - default: - yyerror("Unsupported operator cast"); - } - - if (sname != NULL) - { - yyvsp[-9].signature.result = yyvsp[-11].memArg; - - newFunction(currentSpec, currentModule, - sectionFlags, - currentIsStatic, - currentOverIsVirt, sname, - &yyvsp[-9].signature, yyvsp[-7].number, yyvsp[-5].number, &yyvsp[-4].optflags, yyvsp[-1].codeb, yyvsp[0].codeb, - yyvsp[-6].throwlist, yyvsp[-3].optsignature); - } - else - { - argList *al; - - /* Check it doesn't already exist. */ - for (al = scope->casts; al != NULL; al = al->next) - if (sameScopedName(yyvsp[-11].memArg.u.snd, al->arg.u.snd)) - yyerror("This operator cast has already been specified in this class"); - - al = sipMalloc(sizeof (argList)); - al->arg = yyvsp[-11].memArg; - al->next = scope->casts; - - scope->casts = al; - } - } - - currentIsStatic = FALSE; - currentOverIsVirt = FALSE; - } - break; - - case 230: -#line 1766 "parser.y" - {yyval.text = "__add__";} - break; - - case 231: -#line 1767 "parser.y" - {yyval.text = "__sub__";} - break; - - case 232: -#line 1768 "parser.y" - {yyval.text = "__mul__";} - break; - - case 233: -#line 1769 "parser.y" - {yyval.text = "__div__";} - break; - - case 234: -#line 1770 "parser.y" - {yyval.text = "__mod__";} - break; - - case 235: -#line 1771 "parser.y" - {yyval.text = "__and__";} - break; - - case 236: -#line 1772 "parser.y" - {yyval.text = "__or__";} - break; - - case 237: -#line 1773 "parser.y" - {yyval.text = "__xor__";} - break; - - case 238: -#line 1774 "parser.y" - {yyval.text = "__lshift__";} - break; - - case 239: -#line 1775 "parser.y" - {yyval.text = "__rshift__";} - break; - - case 240: -#line 1776 "parser.y" - {yyval.text = "__iadd__";} - break; - - case 241: -#line 1777 "parser.y" - {yyval.text = "__isub__";} - break; - - case 242: -#line 1778 "parser.y" - {yyval.text = "__imul__";} - break; - - case 243: -#line 1779 "parser.y" - {yyval.text = "__idiv__";} - break; - - case 244: -#line 1780 "parser.y" - {yyval.text = "__imod__";} - break; - - case 245: -#line 1781 "parser.y" - {yyval.text = "__iand__";} - break; - - case 246: -#line 1782 "parser.y" - {yyval.text = "__ior__";} - break; - - case 247: -#line 1783 "parser.y" - {yyval.text = "__ixor__";} - break; - - case 248: -#line 1784 "parser.y" - {yyval.text = "__ilshift__";} - break; - - case 249: -#line 1785 "parser.y" - {yyval.text = "__irshift__";} - break; - - case 250: -#line 1786 "parser.y" - {yyval.text = "__invert__";} - break; - - case 251: -#line 1787 "parser.y" - {yyval.text = "__call__";} - break; - - case 252: -#line 1788 "parser.y" - {yyval.text = "__getitem__";} - break; - - case 253: -#line 1789 "parser.y" - {yyval.text = "__lt__";} - break; - - case 254: -#line 1790 "parser.y" - {yyval.text = "__le__";} - break; - - case 255: -#line 1791 "parser.y" - {yyval.text = "__eq__";} - break; - - case 256: -#line 1792 "parser.y" - {yyval.text = "__ne__";} - break; - - case 257: -#line 1793 "parser.y" - {yyval.text = "__gt__";} - break; - - case 258: -#line 1794 "parser.y" - {yyval.text = "__ge__";} - break; - - case 259: -#line 1797 "parser.y" - { - yyval.number = FALSE; - } - break; - - case 260: -#line 1800 "parser.y" - { - yyval.number = TRUE; - } - break; - - case 261: -#line 1805 "parser.y" - { - yyval.number = 0; - } - break; - - case 262: -#line 1808 "parser.y" - { - if (yyvsp[0].number != 0) - yyerror("Abstract virtual function '= 0' expected"); - - yyval.number = TRUE; - } - break; - - case 263: -#line 1816 "parser.y" - { - yyval.optflags.nrFlags = 0; - } - break; - - case 264: -#line 1819 "parser.y" - { - yyval.optflags = yyvsp[-1].optflags; - } - break; - - case 265: -#line 1825 "parser.y" - { - yyval.optflags.flags[0] = yyvsp[0].flag; - yyval.optflags.nrFlags = 1; - } - break; - - case 266: -#line 1829 "parser.y" - { - /* Check there is room. */ - - if (yyvsp[-2].optflags.nrFlags == MAX_NR_FLAGS) - yyerror("Too many optional flags"); - - yyval.optflags = yyvsp[-2].optflags; - - yyval.optflags.flags[yyval.optflags.nrFlags++] = yyvsp[0].flag; - } - break; - - case 267: -#line 1841 "parser.y" - { - yyval.flag.ftype = bool_flag; - yyval.flag.fname = yyvsp[0].text; - } - break; - - case 268: -#line 1845 "parser.y" - { - yyval.flag = yyvsp[0].flag; - yyval.flag.fname = yyvsp[-2].text; - } - break; - - case 269: -#line 1851 "parser.y" - { - yyval.flag.ftype = name_flag; - yyval.flag.fvalue.sval = yyvsp[0].text; - } - break; - - case 270: -#line 1855 "parser.y" - { - yyval.flag.ftype = string_flag; - yyval.flag.fvalue.sval = yyvsp[0].text; - } - break; - - case 271: -#line 1859 "parser.y" - { - yyval.flag.ftype = integer_flag; - yyval.flag.fvalue.ival = yyvsp[0].number; - } - break; - - case 272: -#line 1865 "parser.y" - { - yyval.codeb = NULL; - } - break; - - case 273: -#line 1868 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 274: -#line 1873 "parser.y" - { - yyval.codeb = NULL; - } - break; - - case 275: -#line 1876 "parser.y" - { - yyval.codeb = yyvsp[0].codeb; - } - break; - - case 276: -#line 1881 "parser.y" - { - int a, nrrxcon, nrrxdis, nrslotcon, nrslotdis, nrarray, nrarraysize; - - nrrxcon = nrrxdis = nrslotcon = nrslotdis = nrarray = nrarraysize = 0; - - for (a = 0; a < yyvsp[0].signature.nrArgs; ++a) - { - argDef *ad = &yyvsp[0].signature.args[a]; - - switch (ad -> atype) - { - case rxcon_type: - ++nrrxcon; - break; - - case rxdis_type: - ++nrrxdis; - break; - - case slotcon_type: - ++nrslotcon; - break; - - case slotdis_type: - ++nrslotdis; - break; - } - - if (isArray(ad)) - ++nrarray; - - if (isArraySize(ad)) - ++nrarraysize; - } - - if (nrrxcon != nrslotcon || nrrxcon > 1) - yyerror("SIP_RXOBJ_CON and SIP_SLOT_CON must both be given and at most once"); - - if (nrrxdis != nrslotdis || nrrxdis > 1) - yyerror("SIP_RXOBJ_DIS and SIP_SLOT_DIS must both be given and at most once"); - - if (nrarray != nrarraysize || nrarray > 1) - yyerror("/Array/ and /ArraySize/ must both be given and at most once"); - - yyval.signature = yyvsp[0].signature; - } - break; - - case 277: -#line 1929 "parser.y" - { - /* No arguments. */ - - yyval.signature.nrArgs = 0; - } - break; - - case 278: -#line 1934 "parser.y" - { - /* The single or first argument. */ - - yyval.signature.args[0] = yyvsp[0].memArg; - yyval.signature.nrArgs = 1; - } - break; - - case 279: -#line 1940 "parser.y" - { - /* Check that it wasn't ...(,arg...). */ - if (yyvsp[-2].signature.nrArgs == 0) - yyerror("First argument of the list is missing"); - - /* Check there is nothing after an ellipsis. */ - if (yyvsp[-2].signature.args[yyvsp[-2].signature.nrArgs - 1].atype == ellipsis_type) - yyerror("An ellipsis must be at the end of the argument list"); - - /* - * If this argument has no default value, then the - * previous one mustn't either. - */ - if (yyvsp[0].memArg.defval == NULL && yyvsp[-2].signature.args[yyvsp[-2].signature.nrArgs - 1].defval != NULL) - yyerror("Compulsory argument given after optional argument"); - - /* Check there is room. */ - if (yyvsp[-2].signature.nrArgs == MAX_NR_ARGS) - yyerror("Internal error - increase the value of MAX_NR_ARGS"); - - yyval.signature = yyvsp[-2].signature; - - yyval.signature.args[yyval.signature.nrArgs] = yyvsp[0].memArg; - yyval.signature.nrArgs++; - } - break; - - case 280: -#line 1967 "parser.y" - { - yyval.memArg.atype = signal_type; - yyval.memArg.argflags = ARG_IS_CONST; - yyval.memArg.nrderefs = 0; - yyval.memArg.name = yyvsp[-1].text; - yyval.memArg.defval = yyvsp[0].valp; - - currentSpec -> sigslots = TRUE; - } - break; - - case 281: -#line 1976 "parser.y" - { - yyval.memArg.atype = slot_type; - yyval.memArg.argflags = ARG_IS_CONST; - yyval.memArg.nrderefs = 0; - yyval.memArg.name = yyvsp[-1].text; - yyval.memArg.defval = yyvsp[0].valp; - - currentSpec -> sigslots = TRUE; - } - break; - - case 282: -#line 1985 "parser.y" - { - yyval.memArg.atype = anyslot_type; - yyval.memArg.argflags = ARG_IS_CONST; - yyval.memArg.nrderefs = 0; - yyval.memArg.name = yyvsp[-1].text; - yyval.memArg.defval = yyvsp[0].valp; - - currentSpec -> sigslots = TRUE; - } - break; - - case 283: -#line 1994 "parser.y" - { - yyval.memArg.atype = rxcon_type; - yyval.memArg.argflags = 0; - yyval.memArg.nrderefs = 0; - yyval.memArg.name = yyvsp[0].text; - - currentSpec -> sigslots = TRUE; - } - break; - - case 284: -#line 2002 "parser.y" - { - yyval.memArg.atype = rxdis_type; - yyval.memArg.argflags = 0; - yyval.memArg.nrderefs = 0; - yyval.memArg.name = yyvsp[0].text; - - currentSpec -> sigslots = TRUE; - } - break; - - case 285: -#line 2010 "parser.y" - { - yyval.memArg.atype = slotcon_type; - yyval.memArg.argflags = ARG_IS_CONST; - yyval.memArg.nrderefs = 0; - yyval.memArg.name = yyvsp[0].text; - - yyvsp[-2].signature.result.atype = void_type; - yyvsp[-2].signature.result.argflags = 0; - yyvsp[-2].signature.result.nrderefs = 0; - - yyval.memArg.u.sa = sipMalloc(sizeof (signatureDef)); - *yyval.memArg.u.sa = yyvsp[-2].signature; - - currentSpec -> sigslots = TRUE; - } - break; - - case 286: -#line 2025 "parser.y" - { - yyval.memArg.atype = slotdis_type; - yyval.memArg.argflags = ARG_IS_CONST; - yyval.memArg.nrderefs = 0; - yyval.memArg.name = yyvsp[0].text; - - yyvsp[-2].signature.result.atype = void_type; - yyvsp[-2].signature.result.argflags = 0; - yyvsp[-2].signature.result.nrderefs = 0; - - yyval.memArg.u.sa = sipMalloc(sizeof (signatureDef)); - *yyval.memArg.u.sa = yyvsp[-2].signature; - - currentSpec -> sigslots = TRUE; - } - break; - - case 287: -#line 2040 "parser.y" - { - yyval.memArg.atype = qobject_type; - yyval.memArg.argflags = 0; - yyval.memArg.nrderefs = 0; - yyval.memArg.name = yyvsp[0].text; - } - break; - - case 288: -#line 2046 "parser.y" - { - yyval.memArg = yyvsp[-1].memArg; - yyval.memArg.defval = yyvsp[0].valp; - } - break; - - case 289: -#line 2052 "parser.y" - {currentIsStatic = TRUE;} - break; - - case 294: -#line 2060 "parser.y" - {currentOverIsVirt = TRUE;} - break; - - case 297: -#line 2064 "parser.y" - { - if (notSkipping()) - { - /* Check the section. */ - - if (sectionFlags != 0) - { - if ((sectionFlags & SECT_IS_PUBLIC) == 0) - yyerror("Class variables must be in the public section"); - - if (!currentIsStatic && yyvsp[-2].codeb != NULL) - yyerror("%AccessCode cannot be specified for non-static class variables"); - } - - if (currentIsStatic && currentSpec -> genc) - yyerror("Cannot have static members in a C structure"); - - if (yyvsp[-1].codeb != NULL || yyvsp[0].codeb != NULL) - { - if (yyvsp[-2].codeb != NULL) - yyerror("Cannot mix %AccessCode and %GetCode or %SetCode"); - - if (currentScope() == NULL) - yyerror("Cannot specify %GetCode or %SetCode for global variables"); - } - - newVar(currentSpec,currentModule,yyvsp[-5].text,currentIsStatic,&yyvsp[-6].memArg,&yyvsp[-4].optflags,yyvsp[-2].codeb,yyvsp[-1].codeb,yyvsp[0].codeb); - } - - currentIsStatic = FALSE; - } - break; - - case 298: -#line 2097 "parser.y" - { - yyval.memArg = yyvsp[-2].memArg; - yyval.memArg.nrderefs = yyvsp[-1].number; - yyval.memArg.argflags = ARG_IS_CONST | yyvsp[0].number; - yyval.memArg.name = NULL; - } - break; - - case 299: -#line 2103 "parser.y" - { - yyval.memArg = yyvsp[-2].memArg; - yyval.memArg.nrderefs = yyvsp[-1].number; - yyval.memArg.argflags = yyvsp[0].number; - yyval.memArg.name = NULL; - } - break; - - case 300: -#line 2111 "parser.y" - { - yyval.memArg = yyvsp[-2].memArg; - yyval.memArg.name = yyvsp[-1].text; - - if (findOptFlag(&yyvsp[0].optflags,"AllowNone",bool_flag) != NULL) - yyval.memArg.argflags |= ARG_ALLOW_NONE; - - if (findOptFlag(&yyvsp[0].optflags,"GetWrapper",bool_flag) != NULL) - yyval.memArg.argflags |= ARG_GET_WRAPPER; - - if (findOptFlag(&yyvsp[0].optflags,"Array",bool_flag) != NULL) - yyval.memArg.argflags |= ARG_ARRAY; - - if (findOptFlag(&yyvsp[0].optflags,"ArraySize",bool_flag) != NULL) - yyval.memArg.argflags |= ARG_ARRAY_SIZE; - - if (findOptFlag(&yyvsp[0].optflags,"Transfer",bool_flag) != NULL) - yyval.memArg.argflags |= ARG_XFERRED; - - if (findOptFlag(&yyvsp[0].optflags,"TransferThis",bool_flag) != NULL) - yyval.memArg.argflags |= ARG_THIS_XFERRED; - - if (findOptFlag(&yyvsp[0].optflags,"TransferBack",bool_flag) != NULL) - yyval.memArg.argflags |= ARG_XFERRED_BACK; - - if (findOptFlag(&yyvsp[0].optflags,"In",bool_flag) != NULL) - yyval.memArg.argflags |= ARG_IN; - - if (findOptFlag(&yyvsp[0].optflags,"Out",bool_flag) != NULL) - yyval.memArg.argflags |= ARG_OUT; - - if (findOptFlag(&yyvsp[0].optflags,"Constrained",bool_flag) != NULL) - { - yyval.memArg.argflags |= ARG_CONSTRAINED; - - switch (yyval.memArg.atype) - { - case bool_type: - yyval.memArg.atype = cbool_type; - break; - - case int_type: - yyval.memArg.atype = cint_type; - break; - - case float_type: - yyval.memArg.atype = cfloat_type; - break; - - case double_type: - yyval.memArg.atype = cdouble_type; - break; - } - } - } - break; - - case 301: -#line 2168 "parser.y" - { - yyval.number = 0; - } - break; - - case 302: -#line 2171 "parser.y" - { - if (currentSpec -> genc) - yyerror("References not allowed in a C module"); - - yyval.number = ARG_IS_REF; - } - break; - - case 303: -#line 2179 "parser.y" - { - yyval.number = 0; - } - break; - - case 304: -#line 2182 "parser.y" - { - yyval.number = yyvsp[-1].number + 1; - } - break; - - case 305: -#line 2187 "parser.y" - { - yyval.memArg.atype = defined_type; - yyval.memArg.u.snd = yyvsp[0].scpvalp; - } - break; - - case 306: -#line 2191 "parser.y" - { - templateDef *td; - - td = sipMalloc(sizeof(templateDef)); - td -> fqname = yyvsp[-3].scpvalp; - td -> types = yyvsp[-1].signature; - - yyval.memArg.atype = template_type; - yyval.memArg.u.td = td; - } - break; - - case 307: -#line 2201 "parser.y" - { - /* In a C module all structures must be defined. */ - if (currentSpec -> genc) - { - yyval.memArg.atype = defined_type; - yyval.memArg.u.snd = yyvsp[0].scpvalp; - } - else - { - yyval.memArg.atype = struct_type; - yyval.memArg.u.sname = yyvsp[0].scpvalp; - } - } - break; - - case 308: -#line 2214 "parser.y" - { - yyval.memArg.atype = ushort_type; - } - break; - - case 309: -#line 2217 "parser.y" - { - yyval.memArg.atype = short_type; - } - break; - - case 310: -#line 2220 "parser.y" - { - yyval.memArg.atype = uint_type; - } - break; - - case 311: -#line 2223 "parser.y" - { - yyval.memArg.atype = uint_type; - } - break; - - case 312: -#line 2226 "parser.y" - { - yyval.memArg.atype = int_type; - } - break; - - case 313: -#line 2229 "parser.y" - { - yyval.memArg.atype = long_type; - } - break; - - case 314: -#line 2232 "parser.y" - { - yyval.memArg.atype = ulong_type; - } - break; - - case 315: -#line 2235 "parser.y" - { - yyval.memArg.atype = longlong_type; - } - break; - - case 316: -#line 2238 "parser.y" - { - yyval.memArg.atype = ulonglong_type; - } - break; - - case 317: -#line 2241 "parser.y" - { - yyval.memArg.atype = float_type; - } - break; - - case 318: -#line 2244 "parser.y" - { - yyval.memArg.atype = double_type; - } - break; - - case 319: -#line 2247 "parser.y" - { - yyval.memArg.atype = bool_type; - } - break; - - case 320: -#line 2250 "parser.y" - { - yyval.memArg.atype = sstring_type; - } - break; - - case 321: -#line 2253 "parser.y" - { - yyval.memArg.atype = ustring_type; - } - break; - - case 322: -#line 2256 "parser.y" - { - yyval.memArg.atype = string_type; - } - break; - - case 323: -#line 2259 "parser.y" - { - yyval.memArg.atype = wstring_type; - } - break; - - case 324: -#line 2262 "parser.y" - { - yyval.memArg.atype = void_type; - } - break; - - case 325: -#line 2265 "parser.y" - { - yyval.memArg.atype = pyobject_type; - } - break; - - case 326: -#line 2268 "parser.y" - { - yyval.memArg.atype = pytuple_type; - } - break; - - case 327: -#line 2271 "parser.y" - { - yyval.memArg.atype = pylist_type; - } - break; - - case 328: -#line 2274 "parser.y" - { - yyval.memArg.atype = pydict_type; - } - break; - - case 329: -#line 2277 "parser.y" - { - yyval.memArg.atype = pycallable_type; - } - break; - - case 330: -#line 2280 "parser.y" - { - yyval.memArg.atype = pyslice_type; - } - break; - - case 331: -#line 2283 "parser.y" - { - yyval.memArg.atype = pytype_type; - } - break; - - case 332: -#line 2286 "parser.y" - { - yyval.memArg.atype = ellipsis_type; - } - break; - - case 333: -#line 2291 "parser.y" - { - /* The single or first type. */ - - yyval.signature.args[0] = yyvsp[0].memArg; - yyval.signature.nrArgs = 1; - } - break; - - case 334: -#line 2297 "parser.y" - { - /* Check there is nothing after an ellipsis. */ - if (yyvsp[-2].signature.args[yyvsp[-2].signature.nrArgs - 1].atype == ellipsis_type) - yyerror("An ellipsis must be at the end of the argument list"); - - /* Check there is room. */ - if (yyvsp[-2].signature.nrArgs == MAX_NR_ARGS) - yyerror("Internal error - increase the value of MAX_NR_ARGS"); - - yyval.signature = yyvsp[-2].signature; - - yyval.signature.args[yyval.signature.nrArgs] = yyvsp[0].memArg; - yyval.signature.nrArgs++; - } - break; - - case 335: -#line 2313 "parser.y" - { - yyval.throwlist = NULL; - } - break; - - case 336: -#line 2316 "parser.y" - { - if (currentSpec->genc) - yyerror("Exceptions not allowed in a C module"); - - if (notSkipping() && inMainModule()) - { - int e; - ifaceFileList **ifl; - - /* - * Make sure the exceptions' header files are - * included. We unconditionally mark them to - * be included in the current scope's header - * file to save us the effort of checking if - * they are being used with a protected method, - * a virtual or a signal. - */ - ifl = (currentScope() != NULL) ? ¤tScope()->iff->used : ¤tSpec->used; - - for (e = 0; e < yyvsp[-1].throwlist->nrArgs; ++e) - addToUsedList(ifl, yyvsp[-1].throwlist->args[e]->iff); - } - - yyval.throwlist = yyvsp[-1].throwlist; - } - break; - - case 337: -#line 2343 "parser.y" - { - /* Empty list so use a blank. */ - - yyval.throwlist = sipMalloc(sizeof (throwArgs)); - yyval.throwlist -> nrArgs = 0; - } - break; - - case 338: -#line 2349 "parser.y" - { - /* The only or first exception. */ - - yyval.throwlist = sipMalloc(sizeof (throwArgs)); - yyval.throwlist -> nrArgs = 1; - yyval.throwlist -> args[0] = findException(currentSpec, yyvsp[0].scpvalp, FALSE); - } - break; - - case 339: -#line 2356 "parser.y" - { - /* Check that it wasn't ...(,arg...). */ - - if (yyvsp[-2].throwlist -> nrArgs == 0) - yyerror("First exception of throw specifier is missing"); - - /* Check there is room. */ - - if (yyvsp[-2].throwlist -> nrArgs == MAX_NR_ARGS) - yyerror("Internal error - increase the value of MAX_NR_ARGS"); - - yyval.throwlist = yyvsp[-2].throwlist; - yyval.throwlist -> args[yyval.throwlist -> nrArgs++] = findException(currentSpec, yyvsp[0].scpvalp, FALSE); - } - break; - - - } - -/* Line 1010 of yacc.c. */ -#line 4727 "parser.c" - - yyvsp -= yylen; - yyssp -= yylen; - - - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (YYPACT_NINF < yyn && yyn < YYLAST) - { - YYSIZE_T yysize = 0; - int yytype = YYTRANSLATE (yychar); - const char* yyprefix; - char *yymsg; - int yyx; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 0; - - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); - yycount += 1; - if (yycount == 5) - { - yysize = 0; - break; - } - } - yysize += (sizeof ("syntax error, unexpected ") - + yystrlen (yytname[yytype])); - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg != 0) - { - char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); - yyp = yystpcpy (yyp, yytname[yytype]); - - if (yycount < 5) - { - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - yyp = yystpcpy (yyp, yyprefix); - yyp = yystpcpy (yyp, yytname[yyx]); - yyprefix = " or "; - } - } - yyerror (yymsg); - YYSTACK_FREE (yymsg); - } - else - yyerror ("syntax error; also virtual memory exhausted"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror ("syntax error"); - } - - - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - if (yychar <= YYEOF) - { - /* If at end of input, pop the error token, - then the rest of the stack, then return failure. */ - if (yychar == YYEOF) - for (;;) - { - YYPOPSTACK; - if (yyssp == yyss) - YYABORT; - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[*yyssp], yyvsp); - } - } - else - { - YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); - yydestruct (yytoken, &yylval); - yychar = YYEMPTY; - - } - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - -#ifdef __GNUC__ - /* Pacify GCC when the user code never invokes YYERROR and the label - yyerrorlab therefore never appears in user code. */ - if (0) - goto yyerrorlab; -#endif - - yyvsp -= yylen; - yyssp -= yylen; - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[yystate], yyvsp); - YYPOPSTACK; - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - if (yyn == YYFINAL) - YYACCEPT; - - YYDPRINTF ((stderr, "Shifting error token, ")); - - *++yyvsp = yylval; - - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#ifndef yyoverflow -/*----------------------------------------------. -| yyoverflowlab -- parser overflow comes here. | -`----------------------------------------------*/ -yyoverflowlab: - yyerror ("parser stack overflow"); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif - return yyresult; -} - - -#line 2372 "parser.y" - - - -/* - * Parse the specification. - */ -void parse(sipSpec *spec,FILE *fp,char *filename,stringList *tsl, - stringList *xfl) -{ - classTmplDef *tcd; - - /* Initialise the spec. */ - - spec -> modules = NULL; - spec -> namecache = NULL; - spec -> ifacefiles = NULL; - spec -> classes = NULL; - spec -> classtemplates = NULL; - spec -> proxies = NULL; - spec -> exceptions = NULL; - spec -> mappedtypes = NULL; - spec -> mappedtypetemplates = NULL; - spec -> qobjclass = -1; - spec -> enums = NULL; - spec -> vars = NULL; - spec -> othfuncs = NULL; - spec -> overs = NULL; - spec -> typedefs = NULL; - spec -> copying = NULL; - spec -> exphdrcode = NULL; - spec -> hdrcode = NULL; - spec -> cppcode = NULL; - spec -> docs = NULL; - spec -> preinitcode = NULL; - spec -> postinitcode = NULL; - spec -> unitcode = NULL; - spec -> used = NULL; - spec -> sigslots = FALSE; - spec -> genc = -1; - spec -> options = NULL; - - currentSpec = spec; - neededQualifiers = tsl; - excludedQualifiers = xfl; - currentModule = NULL; - currentMappedType = NULL; - currentOverIsVirt = FALSE; - currentCtorIsExplicit = FALSE; - currentIsStatic = FALSE; - previousFile = NULL; - skipStackPtr = 0; - currentScopeIdx = 0; - sectionFlags = 0; - - newModule(fp,filename); - spec -> module = currentModule; - - yyparse(); - - handleEOF(); - handleEOM(); - - /* - * Go through each template class and remove it from the list of - * classes. - */ - for (tcd = spec->classtemplates; tcd != NULL; tcd = tcd->next) - { - classDef **cdp; - - for (cdp = &spec->classes; *cdp != NULL; cdp = &(*cdp)->next) - if (*cdp == tcd->cd) - { - ifaceFileDef **ifdp; - - /* Remove the interface file as well. */ - for (ifdp = &spec->ifacefiles; *ifdp != NULL; ifdp = &(*ifdp)->next) - if (*ifdp == tcd->cd->iff) - { - *ifdp = (*ifdp)->next; - break; - } - - *cdp = (*cdp)->next; - break; - } - } -} - - -/* - * Tell the parser that a complete file has now been read. - */ -void parserEOF(char *name,parserContext *pc) -{ - previousFile = sipStrdup(name); - newContext = *pc; -} - - -/* - * Append a class definition to a class list if it doesn't already appear. - * Append is needed specifically for the list of super-classes because the - * order is important to Python. - */ -void appendToClassList(classList **clp,classDef *cd) -{ - classList *new; - - /* Find the end of the list. */ - - while (*clp != NULL) - { - if ((*clp) -> cd == cd) - return; - - clp = &(*clp) -> next; - } - - new = sipMalloc(sizeof (classList)); - - new -> cd = cd; - new -> next = NULL; - - *clp = new; -} - - -/* - * Create a new module for the current specification and make it current. - */ -static void newModule(FILE *fp,char *filename) -{ - moduleDef *newmod; - - parseFile(fp,filename,currentModule,FALSE); - - newmod = sipMalloc(sizeof (moduleDef)); - newmod -> fullname = NULL; - newmod -> name = NULL; - newmod -> version = -1; - newmod -> modflags = 0; - newmod -> modulenr = -1; - newmod -> file = filename; - newmod -> qualifiers = NULL; - newmod -> root.cd = NULL; - newmod -> root.child = NULL; - newmod -> nrtimelines = 0; - newmod -> nrclasses = 0; - newmod -> nrexceptions = 0; - newmod -> nrmappedtypes = 0; - newmod -> nrenums = 0; - newmod -> nrtypedefs = 0; - newmod -> nrvirthandlers = 0; - newmod -> virthandlers = NULL; - newmod -> license = NULL; - newmod -> allimports = NULL; - newmod -> imports = NULL; - newmod -> next = currentSpec -> modules; - - currentModule = currentSpec->modules = newmod; -} - - -/* - * Switch to parsing a new file. - */ -static void parseFile(FILE *fp,char *name,moduleDef *prevmod,int optional) -{ - parserContext pc; - - pc.ifdepth = skipStackPtr; - pc.prevmod = prevmod; - - setInputFile(fp,name,&pc,optional); -} - - -/* - * Find an interface file, or create a new one. - */ -ifaceFileDef *findIfaceFile(sipSpec *pt, moduleDef *mod, scopedNameDef *fqname, - ifaceFileType iftype, argDef *ad) -{ - ifaceFileDef *iff; - - /* See if the name is already used. */ - - for (iff = pt -> ifacefiles; iff != NULL; iff = iff -> next) - { - if (!sameScopedName(iff -> fqcname,fqname)) - continue; - - /* - * They must be the same type except that we allow a class if - * if we want an exception. This is because we allow classes - * to be used before they are defined. - */ - if (iff -> type != iftype) - if (iftype != exception_iface || iff -> type != class_iface) - yyerror("A class, exception, namespace or mapped type has already been defined with the same name"); - - /* Ignore an external class declared in another module. */ - if (iftype == class_iface && iff->module != mod) - { - classDef *cd; - - for (cd = pt->classes; cd != NULL; cd = cd->next) - if (cd->iff == iff) - break; - - if (cd != NULL && iff->module != NULL && isExternal(cd)) - continue; - } - - /* - * If this is a mapped type with the same name defined in a - * different module, then check that this type isn't the same - * as any of the mapped types defined in that module. - */ - if (iftype == mappedtype_iface && iff -> module != mod) - { - mappedTypeDef *mtd; - - for (mtd = pt -> mappedtypes; mtd != NULL; mtd = mtd -> next) - { - if (mtd -> iff != iff) - continue; - - if (ad -> atype != template_type || - mtd -> type.atype != template_type || - sameBaseType(ad,&mtd -> type)) - yyerror("Mapped type has already been defined in another module"); - } - - /* - * If we got here then we have a mapped type based on - * an existing template, but with unique parameters. - * We don't want to use interface files from other - * modules, so skip this one. - */ - - continue; - } - - /* Ignore a namespace defined in another module. */ - if (iftype == namespace_iface && iff->module != mod) - continue; - - return iff; - } - - iff = sipMalloc(sizeof (ifaceFileDef)); - - iff -> name = cacheName(pt,scopedNameTail(fqname)); - iff -> type = iftype; - iff -> fqcname = fqname; - iff -> module = NULL; - iff -> used = NULL; - iff -> next = pt -> ifacefiles; - - pt -> ifacefiles = iff; - - return iff; -} - - -/* - * Find a class definition in a parse tree. - */ -static classDef *findClass(sipSpec *pt,ifaceFileType iftype, - scopedNameDef *fqname) -{ - return findClassWithInterface(pt, findIfaceFile(pt, currentModule, fqname, iftype, NULL)); -} - - -/* - * Find a class definition given an existing interface file. - */ -static classDef *findClassWithInterface(sipSpec *pt, ifaceFileDef *iff) -{ - classDef *cd; - - for (cd = pt -> classes; cd != NULL; cd = cd -> next) - if (cd -> iff == iff) - return cd; - - /* Create a new one. */ - cd = sipMalloc(sizeof (classDef)); - - cd -> iff = iff; - cd -> pyname = classBaseName(cd); - cd -> classnr = -1; - cd -> classflags = 0; - cd -> userflags = 0; - cd -> ecd = NULL; - cd -> dtorexceptions = NULL; - cd -> real = NULL; - cd -> node = NULL; - cd -> supers = NULL; - cd -> mro = NULL; - cd -> td = NULL; - cd -> ctors = NULL; - cd -> defctor = NULL; - cd -> dealloccode = NULL; - cd -> dtorcode = NULL; - cd -> members = NULL; - cd -> overs = NULL; - cd -> casts = NULL; - cd -> vmembers = NULL; - cd -> visible = NULL; - cd -> cppcode = NULL; - cd -> hdrcode = NULL; - cd -> convtosubcode = NULL; - cd -> subbase = NULL; - cd -> convtocode = NULL; - cd -> travcode = NULL; - cd -> clearcode = NULL; - cd -> readbufcode = NULL; - cd -> writebufcode = NULL; - cd -> segcountcode = NULL; - cd -> charbufcode = NULL; - cd -> next = pt -> classes; - - pt -> classes = cd; - - return cd; -} - - -/* - * Add an interface file to an interface file list if it isn't already there. - */ -ifaceFileList *addToUsedList(ifaceFileList **ifflp, ifaceFileDef *iff) -{ - ifaceFileList *iffl; - - while ((iffl = *ifflp) != NULL) - { - /* Don't bother if it is already there. */ - if (iffl -> iff == iff) - return iffl; - - ifflp = &iffl -> next; - } - - iffl = sipMalloc(sizeof (ifaceFileList)); - - iffl->iff = iff; - iffl->header = FALSE; - iffl->next = NULL; - - *ifflp = iffl; - - return iffl; -} - - -/* - * Find an undefined (or create a new) exception definition in a parse tree. - */ -static exceptionDef *findException(sipSpec *pt, scopedNameDef *fqname, int new) -{ - exceptionDef *xd, **tail; - ifaceFileDef *iff; - classDef *cd; - - iff = findIfaceFile(pt, currentModule, fqname, exception_iface, NULL); - - /* See if it is an existing one. */ - for (xd = pt->exceptions; xd != NULL; xd = xd->next) - if (xd->iff == iff) - return xd; - - /* - * If it is an exception interface file then we have never seen this - * name before. We require that exceptions are defined before being - * used, but don't make the same requirement of classes (for reasons of - * backwards compatibility). Therefore the name must be reinterpreted - * as a (as yet undefined) class. - */ - if (new) - if (iff->type == exception_iface) - cd = NULL; - else - yyerror("There is already a class with the same name or the exception has been used before being defined"); - else - { - if (iff->type == exception_iface) - iff->type = class_iface; - - cd = findClassWithInterface(pt, iff); - } - - /* Create a new one. */ - xd = sipMalloc(sizeof (exceptionDef)); - - xd->exceptionnr = -1; - xd->iff = iff; - xd->pyname = NULL; - xd->cd = cd; - xd->bibase = NULL; - xd->base = NULL; - xd->hdrcode = NULL; - xd->raisecode = NULL; - xd->next = NULL; - - /* Append it to the list. */ - for (tail = &pt->exceptions; *tail != NULL; tail = &(*tail)->next) - ; - - *tail = xd; - - return xd; -} - - -/* - * Find an undefined (or create a new) class definition in a parse tree. - */ -static classDef *newClass(sipSpec *pt,ifaceFileType iftype, - scopedNameDef *fqname) -{ - int flags; - classDef *cd, *scope; - codeBlock *hdrcode; - - if (sectionFlags & SECT_IS_PRIVATE) - yyerror("Classes, structs and namespaces must be in the public or or protected sections"); - - flags = 0; - - if ((scope = currentScope()) != NULL) - { - if (sectionFlags & SECT_IS_PROT) - flags = CLASS_IS_PROTECTED; - - hdrcode = scope -> hdrcode; - } - else - hdrcode = NULL; - - if (pt -> genc) - { - /* C structs are always global types. */ - while (fqname -> next != NULL) - fqname = fqname -> next; - - scope = NULL; - } - - cd = findClass(pt,iftype,fqname); - - /* Check it hasn't already been defined. */ - if (iftype != namespace_iface && cd->iff->module != NULL) - yyerror("The struct/class has already been defined"); - - /* Complete the initialisation. */ - cd->classflags |= flags; - cd->ecd = scope; - cd->iff->module = currentModule; - - appendCodeBlock(&cd->hdrcode, hdrcode); - - /* See if it is a namespace extender. */ - if (iftype == namespace_iface) - { - classDef *ns; - - for (ns = pt->classes; ns != NULL; ns = ns->next) - { - if (ns == cd) - continue; - - if (ns->iff->type != namespace_iface) - continue; - - if (!sameScopedName(ns->iff->fqcname, fqname)) - continue; - - cd->real = ns; - break; - } - } - - return cd; -} - - -/* - * Tidy up after finishing a class definition. - */ -static void finishClass(sipSpec *pt, moduleDef *mod, classDef *cd, optFlags *of) -{ - char *pyname; - optFlag *flg; - - /* Get the Python name and see if it is different to the C++ name. */ - pyname = getPythonName(of, classBaseName(cd)); - - cd -> pyname = NULL; - checkAttributes(pt, cd->ecd, pyname, FALSE); - cd->pyname = pyname; - - if (cd->pyname != classBaseName(cd)) - setIsRenamedClass(cd); - - if ((flg = findOptFlag(of, "TypeFlags", integer_flag)) != NULL) - cd->userflags = flg->fvalue.ival; - - if (isOpaque(cd)) - { - if (findOptFlag(of, "External", bool_flag) != NULL) - setIsExternal(cd); - } - else - { - int seq_might, seq_not; - memberDef *md; - - if (findOptFlag(of, "NoDefaultCtors", bool_flag) != NULL) - setNoDefaultCtors(cd); - - if (cd -> ctors == NULL) - { - if (!noDefaultCtors(cd)) - { - /* Provide a default ctor. */ - - cd->ctors = sipMalloc(sizeof (ctorDef)); - - cd->ctors->ctorflags = SECT_IS_PUBLIC; - cd->ctors->pysig.nrArgs = 0; - cd->ctors->cppsig = &cd -> ctors -> pysig; - cd->ctors->exceptions = NULL; - cd->ctors->methodcode = NULL; - cd->ctors->prehook = NULL; - cd->ctors->posthook = NULL; - cd->ctors->next = NULL; - - cd->defctor = cd->ctors; - - setCanCreate(cd); - } - } - else if (cd -> defctor == NULL) - { - ctorDef *ct, *last = NULL; - - for (ct = cd -> ctors; ct != NULL; ct = ct -> next) - { - if (!isPublicCtor(ct)) - continue; - - if (ct -> pysig.nrArgs == 0 || ct -> pysig.args[0].defval != NULL) - { - cd -> defctor = ct; - break; - } - - if (last == NULL) - last = ct; - } - - /* The last resort is the first public ctor. */ - if (cd->defctor == NULL) - cd->defctor = last; - } - - if (findOptFlag(of,"Abstract",bool_flag) != NULL) - { - setIsAbstractClass(cd); - setIsIncomplete(cd); - resetCanCreate(cd); - } - - /* We assume a public dtor if nothing specific was provided. */ - if (!isDtor(cd)) - setIsPublicDtor(cd); - - if (findOptFlag(of, "DelayDtor", bool_flag) != NULL) - { - setIsDelayedDtor(cd); - setHasDelayedDtors(mod); - } - - /* - * There are subtle differences between the add and concat methods and - * the multiply and repeat methods. The number versions can have their - * operands swapped and may return NotImplemented. If the user has - * used the /Numeric/ annotation or there are other numeric operators - * then we use add/multiply. Otherwise, if there are indexing - * operators then we use concat/repeat. - */ - seq_might = seq_not = FALSE; - - for (md = cd -> members; md != NULL; md = md -> next) - switch (md -> slot) - { - case getitem_slot: - case setitem_slot: - case delitem_slot: - /* This might be a sequence. */ - seq_might = TRUE; - break; - - case sub_slot: - case isub_slot: - case div_slot: - case idiv_slot: - case mod_slot: - case imod_slot: - case pos_slot: - case neg_slot: - /* This is definately not a sequence. */ - seq_not = TRUE; - break; - } - - if (!seq_not && seq_might) - for (md = cd -> members; md != NULL; md = md -> next) - { - /* Ignore if the user has been explicit. */ - if (isNumeric(md)) - continue; - - switch (md -> slot) - { - case add_slot: - md -> slot = concat_slot; - break; - - case iadd_slot: - md -> slot = iconcat_slot; - break; - - case mul_slot: - md -> slot = repeat_slot; - break; - - case imul_slot: - md -> slot = irepeat_slot; - break; - } - } - } - - if (inMainModule()) - { - setIsUsedName(cd->iff->name); - setIsClassName(cd->iff->name); - } -} - - -/* - * Create a new mapped type. - */ -static mappedTypeDef *newMappedType(sipSpec *pt,argDef *ad) -{ - mappedTypeDef *mtd; - scopedNameDef *snd; - ifaceFileDef *iff; - - /* Check that the type is one we want to map. */ - switch (ad -> atype) - { - case defined_type: - snd = ad -> u.snd; - break; - - case template_type: - snd = ad -> u.td -> fqname; - break; - - case struct_type: - snd = ad -> u.sname; - break; - - default: - yyerror("Invalid type for %MappedType"); - } - - iff = findIfaceFile(pt, currentModule, snd, mappedtype_iface, ad); - - if (inMainModule()) - setIsUsedName(iff -> name); - - /* Check it hasn't already been defined. */ - for (mtd = pt -> mappedtypes; mtd != NULL; mtd = mtd -> next) - if (mtd -> iff == iff) - { - /* - * We allow types based on the same template but with - * different arguments. - */ - - if (ad -> atype != template_type || - sameBaseType(ad,&mtd -> type)) - yyerror("Mapped type has already been defined in this module"); - } - - /* The module may not have been set yet. */ - iff -> module = currentModule; - - /* Create a new mapped type. */ - mtd = allocMappedType(ad); - - mtd -> iff = iff; - mtd -> next = pt -> mappedtypes; - - pt -> mappedtypes = mtd; - - return mtd; -} - - -/* - * Allocate, intialise and return a mapped type structure. - */ -mappedTypeDef *allocMappedType(argDef *type) -{ - mappedTypeDef *mtd; - - mtd = sipMalloc(sizeof (mappedTypeDef)); - - mtd->type = *type; - mtd->type.argflags = 0; - mtd->type.nrderefs = 0; - - mtd->mappednr = -1; - mtd->iff = NULL; - mtd->hdrcode = NULL; - mtd->convfromcode = NULL; - mtd->convtocode = NULL; - mtd->next = NULL; - - return mtd; -} - - -/* - * Create a new enum. - */ -static enumDef *newEnum(sipSpec *pt,moduleDef *mod,char *name,optFlags *of, - int flags) -{ - enumDef *ed; - classDef *escope = currentScope(); - - ed = sipMalloc(sizeof (enumDef)); - - if (name != NULL) - { - ed -> fqcname = text2scopedName(name); - ed -> pyname = cacheName(pt, getPythonName(of, name)); - - checkAttributes(pt, escope, ed->pyname->text, FALSE); - } - else - { - ed -> fqcname = NULL; - ed -> pyname = NULL; - } - - ed -> enumflags = flags; - ed -> enumnr = -1; - ed -> ecd = escope; - ed -> pcd = (flags & SECT_IS_PROT) ? escope : NULL; - ed -> module = mod; - ed -> members = NULL; - ed -> slots = NULL; - ed -> overs = NULL; - ed -> next = pt -> enums; - - if (name != NULL && strcmp(ed->pyname->text, name) != 0) - setIsRenamedEnum(ed); - - pt -> enums = ed; - - if (escope != NULL) - setHasEnums(escope); - - return ed; -} - - -/* - * Get the type values and (optionally) the type names for substitution in - * handwritten code. - */ -void appendTypeStrings(scopedNameDef *ename, signatureDef *patt, signatureDef *src, signatureDef *known, scopedNameDef **names, scopedNameDef **values) -{ - int a; - - for (a = 0; a < patt->nrArgs; ++a) - { - argDef *pad = &patt->args[a]; - - if (pad->atype == defined_type) - { - char *nam = NULL; - - /* - * If the type names are already known then check that - * this is one of them. - */ - if (known == NULL) - nam = scopedNameTail(pad->u.snd); - else if (pad->u.snd->next == NULL) - { - int k; - - for (k = 0; k < known->nrArgs; ++k) - if (strcmp(pad->u.snd->name, known->args[k].u.snd->name) == 0) - { - nam = pad->u.snd->name; - break; - } - } - - if (nam == NULL) - continue; - - /* Add the name. */ - appendScopedName(names, text2scopePart(nam)); - - /* Add the corresponding value. */ - appendScopedName(values, text2scopePart(getType(ename, &src->args[a]))); - } - else if (pad->atype == template_type) - { - argDef *sad = &src->args[a]; - - /* These checks shouldn't be necessary, but... */ - if (sad->atype == template_type && pad->u.td->types.nrArgs == sad->u.td->types.nrArgs) - appendTypeStrings(ename, &pad->u.td->types, &sad->u.td->types, known, names, values); - } - } -} - - -/* - * Convert a type to a string. We impose some limitations because I'm too lazy - * to handle everything that might be needed one day. - */ -static char *getType(scopedNameDef *ename, argDef *ad) -{ - if (ad->atype == defined_type) - return scopedNameToString(ad->u.snd); - - fatalScopedName(ename); - fatal(": unsupported type argument to template class instantiation\n"); - - return NULL; -} - - -/* - * Convert a scoped name to a string on the heap. - */ -static char *scopedNameToString(scopedNameDef *name) -{ - static const char scope_string[] = "::"; - size_t len; - scopedNameDef *snd; - char *s, *dp; - - /* Work out the length of buffer needed. */ - len = 0; - - for (snd = name; snd != NULL; snd = snd->next) - { - len += strlen(snd->name); - - if (snd->next != NULL) - len += strlen(scope_string); - } - - /* Allocate and populate the buffer. */ - dp = s = sipMalloc(len + 1); - - for (snd = name; snd != NULL; snd = snd->next) - { - strcpy(dp, snd->name); - dp += strlen(snd->name); - - if (snd->next != NULL) - { - strcpy(dp, scope_string); - dp += strlen(scope_string); - } - } - - return s; -} - - -/* - * Instantiate a class template. - */ -static void instantiateClassTemplate(sipSpec *pt, moduleDef *mod, classDef *scope, scopedNameDef *fqname, classTmplDef *tcd, templateDef *td) -{ - scopedNameDef *type_names, *type_values; - classDef *cd; - ctorDef *oct, **cttail; - memberDef *omd, **mdtail; - overDef *ood, **odtail; - argDef *ad; - ifaceFileList *iffl, **used; - - type_names = type_values = NULL; - appendTypeStrings(classFQCName(tcd->cd), &tcd->sig, &td->types, NULL, &type_names, &type_values); - - /* - * Add a mapping from the template name to the instantiated name. If - * we have got this far we know there is room for it. - */ - ad = &tcd->sig.args[tcd->sig.nrArgs++]; - ad->atype = defined_type; - ad->name = NULL; - ad->argflags = 0; - ad->nrderefs = 0; - ad->defval = NULL; - ad->u.snd = classFQCName(tcd->cd); - - appendScopedName(&type_names, text2scopePart(scopedNameTail(classFQCName(tcd->cd)))); - appendScopedName(&type_values, text2scopePart(scopedNameToString(fqname))); - - /* Create the new class. */ - cd = sipMalloc(sizeof (classDef)); - - /* Start with a shallow copy. */ - *cd = *tcd->cd; - - cd->pyname = scopedNameTail(fqname); - cd->td = td; - - /* Handle the interface file. */ - cd->iff = findIfaceFile(pt, mod, fqname, class_iface, NULL); - cd->iff->module = mod; - - /* Make a copy of the used list and add the enclosing scope. */ - used = &cd->iff->used; - - for (iffl = tcd->cd->iff->used; iffl != NULL; iffl = iffl->next) - addToUsedList(used, iffl->iff); - - if (scope != NULL) - addToUsedList(&cd->iff->used, scope->iff); - - if (inMainModule()) - { - setIsUsedName(cd->iff->name); - setIsClassName(cd->iff->name); - } - - cd->ecd = currentScope(); - - /* Handle the ctors. */ - cd->ctors = NULL; - cttail = &cd->ctors; - - for (oct = tcd->cd->ctors; oct != NULL; oct = oct->next) - { - ctorDef *nct = sipMalloc(sizeof (ctorDef)); - - /* Start with a shallow copy. */ - *nct = *oct; - - templateSignature(&nct->pysig, FALSE, tcd, td, cd); - - if (oct->cppsig == NULL) - nct->cppsig = NULL; - else if (oct->cppsig == &oct->pysig) - nct->cppsig = &nct->pysig; - else - { - nct->cppsig = sipMalloc(sizeof (signatureDef)); - - *nct->cppsig = *oct->cppsig; - - templateSignature(nct->cppsig, FALSE, tcd, td, cd); - } - - nct->methodcode = templateCode(pt, used, nct->methodcode, type_names, type_values); - - nct->next = NULL; - *cttail = nct; - cttail = &nct->next; - - /* Handle the default ctor. */ - if (tcd->cd->defctor == oct) - cd->defctor = nct; - } - - cd->dealloccode = templateCode(pt, used, cd->dealloccode, type_names, type_values); - cd->dtorcode = templateCode(pt, used, cd->dtorcode, type_names, type_values); - - /* Handle the members, ie. the common parts of overloads. */ - cd->members = NULL; - mdtail = &cd->members; - - for (omd = tcd->cd->members; omd != NULL; omd = omd->next) - { - memberDef *nmd = sipMalloc(sizeof (memberDef)); - - /* Start with a shallow copy. */ - *nmd = *omd; - - nmd->module = mod; - - nmd->next = NULL; - *mdtail = nmd; - mdtail = &nmd->next; - } - - /* Handle the overloads. */ - cd->overs = NULL; - odtail = &cd->overs; - - for (ood = tcd->cd->overs; ood != NULL; ood = ood->next) - { - overDef *nod = sipMalloc(sizeof (overDef)); - memberDef *nmd; - - /* Start with a shallow copy. */ - *nod = *ood; - - for (nmd = cd->members, omd = tcd->cd->members; omd != NULL; omd = omd->next, nmd = nmd->next) - if (omd == ood->common) - { - nod->common = nmd; - break; - } - - templateSignature(&nod->pysig, TRUE, tcd, td, cd); - - if (ood->cppsig == &ood->pysig) - nod->cppsig = &nod->pysig; - else - { - nod->cppsig = sipMalloc(sizeof (signatureDef)); - - *nod->cppsig = *ood->cppsig; - - templateSignature(nod->cppsig, TRUE, tcd, td, cd); - } - - nod->methodcode = templateCode(pt, used, nod->methodcode, type_names, type_values); - - /* Handle any virtual handler. */ - if (ood->virthandler != NULL) - { - nod->virthandler = sipMalloc(sizeof (virtHandlerDef)); - - /* Start with a shallow copy. */ - *nod->virthandler = *ood->virthandler; - - if (ood->virthandler->cppsig == &ood->pysig) - nod->virthandler->cppsig = &nod->pysig; - else - { - nod->virthandler->cppsig = sipMalloc(sizeof (signatureDef)); - - *nod->virthandler->cppsig = *ood->virthandler->cppsig; - - templateSignature(nod->virthandler->cppsig, TRUE, tcd, td, cd); - } - - nod->virthandler->module = mod; - nod->virthandler->virtcode = templateCode(pt, used, nod->virthandler->virtcode, type_names, type_values); - nod->virthandler->next = mod->virthandlers; - - mod->virthandlers = nod->virthandler; - } - - nod->next = NULL; - *odtail = nod; - odtail = &nod->next; - } - - cd->cppcode = templateCode(pt, used, cd->cppcode, type_names, type_values); - cd->hdrcode = templateCode(pt, used, cd->hdrcode, type_names, type_values); - cd->convtosubcode = templateCode(pt, used, cd->convtosubcode, type_names, type_values); - cd->convtocode = templateCode(pt, used, cd->convtocode, type_names, type_values); - cd->travcode = templateCode(pt, used, cd->travcode, type_names, type_values); - cd->clearcode = templateCode(pt, used, cd->clearcode, type_names, type_values); - cd->readbufcode = templateCode(pt, used, cd->readbufcode, type_names, type_values); - cd->writebufcode = templateCode(pt, used, cd->writebufcode, type_names, type_values); - cd->segcountcode = templateCode(pt, used, cd->segcountcode, type_names, type_values); - cd->charbufcode = templateCode(pt, used, cd->charbufcode, type_names, type_values); - cd->next = pt->classes; - - pt->classes = cd; - - tcd->sig.nrArgs--; - - freeScopedName(type_names); - freeScopedName(type_values); -} - - -/* - * Replace any template arguments in a signature. - */ -static void templateSignature(signatureDef *sd, int result, classTmplDef *tcd, templateDef *td, classDef *ncd) -{ - int a; - - if (result) - templateType(&sd->result, tcd, td, ncd); - - for (a = 0; a < sd->nrArgs; ++a) - templateType(&sd->args[a], tcd, td, ncd); -} - - -/* - * Replace any template arguments in a type. - */ -static void templateType(argDef *ad, classTmplDef *tcd, templateDef *td, classDef *ncd) -{ - int a; - char *name; - - /* Ignore if it isn't an unscoped name. */ - if (ad->atype != defined_type || ad->u.snd->next != NULL) - return; - - name = ad->u.snd->name; - - for (a = 0; a < tcd->sig.nrArgs - 1; ++a) - if (strcmp(name, scopedNameTail(tcd->sig.args[a].u.snd)) == 0) - { - ad->atype = td->types.args[a].atype; - - /* We take the constrained flag from the real type. */ - resetIsConstrained(ad); - - if (isConstrained(&td->types.args[a])) - setIsConstrained(ad); - - ad->u = td->types.args[a].u; - - return; - } - - /* Handle the class name itself. */ - if (strcmp(name, scopedNameTail(classFQCName(tcd->cd))) == 0) - { - ad->atype = class_type; - ad->u.cd = ncd; - } -} - - -/* - * Replace any template arguments in a literal code block. - */ -codeBlock *templateCode(sipSpec *pt, ifaceFileList **used, codeBlock *ocb, scopedNameDef *names, scopedNameDef *values) -{ - codeBlock *ncb = NULL, **tail = &ncb; - - while (ocb != NULL) - { - char *at = ocb->frag; - - do - { - char *first = NULL; - codeBlock *cb; - scopedNameDef *nam, *val, *nam_first, *val_first; - - /* - * Go through the rest of this fragment looking for - * each of the types and the name of the class itself. - */ - nam = names; - val = values; - - while (nam != NULL && val != NULL) - { - char *cp; - - if ((cp = strstr(at, nam->name)) != NULL) - if (first == NULL || first > cp) - { - nam_first = nam; - val_first = val; - first = cp; - } - - nam = nam->next; - val = val->next; - } - - /* Create the new fragment. */ - cb = sipMalloc(sizeof (codeBlock)); - - if (at == ocb->frag) - { - cb->filename = ocb->filename; - cb->linenr = ocb->linenr; - } - else - cb->filename = NULL; - - cb->next = NULL; - *tail = cb; - tail = &cb->next; - - /* See if anything was found. */ - if (first == NULL) - { - /* We can just point to this. */ - cb->frag = at; - - /* All done with this one. */ - at = NULL; - } - else - { - static char *gen_names[] = { - "sipForceConvertToTransfer_", - "sipForceConvertTo_", - "sipConvertFromTransfer_", - "sipConvertFrom_", - "sipClass_", - "sipEnum_", - "sipException_", - NULL - }; - - char *dp, *sp, **gn; - int genname = FALSE; - - /* - * If the context in which the text is used is - * in the name of a SIP generated object then - * translate any "::" scoping to "_". - */ - for (gn = gen_names; *gn != NULL; ++gn) - if (search_back(first, at, *gn)) - { - addUsedFromCode(pt, used, val_first->name); - genname = TRUE; - break; - } - - /* Fragment the fragment. */ - cb->frag = sipMalloc(first - at + strlen(val_first->name) + 1); - - strncpy(cb->frag, at, first - at); - - dp = &cb->frag[first - at]; - sp = val_first->name; - - if (genname) - { - char gch; - - while ((gch = *sp++) != '\0') - if (gch == ':' && *sp == ':') - { - *dp++ = '_'; - ++sp; - } - else - *dp++ = gch; - - *dp = '\0'; - } - else - strcpy(dp, sp); - - /* Move past the replaced text. */ - at = first + strlen(nam_first->name); - } - } - while (at != NULL && *at != '\0'); - - ocb = ocb->next; - } - - return ncb; -} - - -/* - * Return TRUE if the text at the end of a string matches the target string. - */ -static int search_back(const char *end, const char *start, const char *target) -{ - size_t tlen = strlen(target); - - if (start + tlen >= end) - return FALSE; - - return (strncmp(end - tlen, target, tlen) == 0); -} - - -/* - * Add any needed interface files based on handwritten code. - */ -static void addUsedFromCode(sipSpec *pt, ifaceFileList **used, const char *sname) -{ - ifaceFileDef *iff; - enumDef *ed; - - for (iff = pt->ifacefiles; iff != NULL; iff = iff->next) - { - if (iff->type != class_iface && iff->type != exception_iface) - continue; - - if (sameName(iff->fqcname, sname)) - { - addToUsedList(used, iff); - - return; - } - } - - for (ed = pt->enums; ed != NULL; ed = ed->next) - { - if (ed->ecd == NULL) - continue; - - if (sameName(ed->fqcname, sname)) - { - addToUsedList(used, ed->ecd->iff); - - return; - } - } -} - - -/* - * Compare a scoped name with its string equivalent. - */ -static int sameName(scopedNameDef *snd, const char *sname) -{ - while (snd != NULL && *sname != '\0') - { - const char *sp = snd->name; - - while (*sp != '\0' && *sname != ':' && *sname != '\0') - if (*sp++ != *sname++) - return FALSE; - - if (*sp != '\0' || (*sname != ':' && *sname != '\0')) - return FALSE; - - snd = snd->next; - - if (*sname == ':') - sname += 2; - } - - return (snd == NULL && *sname == '\0'); -} - - -/* - * Create a new typedef. - */ -static void newTypedef(sipSpec *pt,moduleDef *mod,char *name,argDef *type) -{ - typedefDef *td; - scopedNameDef *fqname = text2scopedName(name); - classDef *scope = currentScope(); - - /* See if we are instantiating a template class. */ - if (type->atype == template_type) - { - classTmplDef *tcd; - templateDef *td = type->u.td; - - for (tcd = pt->classtemplates; tcd != NULL; tcd = tcd->next) - if (sameScopedName(tcd->cd->iff->fqcname, td->fqname)) - { - if (!sameTemplateSignature(&tcd->sig, &td->types, FALSE)) - continue; - - instantiateClassTemplate(pt, mod, scope, fqname, tcd, td); - - /* All done. */ - return; - } - } - - /* Check it doesn't already exist. */ - for (td = pt -> typedefs; td != NULL; td = td -> next) - if (sameScopedName(td -> fqname,fqname)) - { - fatalScopedName(fqname); - fatal(" already defined\n"); - } - - td = sipMalloc(sizeof (typedefDef)); - - td -> fqname = fqname; - td -> ecd = scope; - td -> module = mod; - td -> type = *type; - td -> next = pt -> typedefs; - - mod -> nrtypedefs++; - - pt -> typedefs = td; -} - - -/* - * Return TRUE if the template signatures are the same. A deep comparison is - * used for mapped type templates where we want to recurse into any nested - * templates. - */ -int sameTemplateSignature(signatureDef *sd1, signatureDef *sd2, int deep) -{ - int a; - - if (sd1->nrArgs != sd2->nrArgs) - return FALSE; - - for (a = 0; a < sd1->nrArgs; ++a) - { - argDef *ad1 = &sd1->args[a]; - argDef *ad2 = &sd2->args[a]; - - /* - * If we are doing a shallow comparision (ie. for class - * templates) then a type name on the left hand side matches - * anything on the right hand side. - */ - if (ad1->atype == defined_type && !deep) - continue; - - /* - * For type names only compare the references and pointers, and - * do the same for any nested templates. - */ - if (ad1->atype == defined_type && ad2->atype == defined_type) - { - if (isReference(ad1) != isReference(ad2) || ad1->nrderefs != ad2->nrderefs) - return FALSE; - } - else if (ad1->atype == template_type && ad2->atype == template_type) - { - if (!sameTemplateSignature(&ad1->u.td->types, &ad2->u.td->types, deep)) - return FALSE; - } - else if (!sameBaseType(ad1, ad2)) - return FALSE; - } - - return TRUE; -} - - -/* - * Create a new variable. - */ -static void newVar(sipSpec *pt,moduleDef *mod,char *name,int isstatic, - argDef *type,optFlags *of,codeBlock *acode,codeBlock *gcode, - codeBlock *scode) -{ - varDef *var; - classDef *escope = currentScope(); - nameDef *nd = cacheName(pt,getPythonName(of,name)); - - if (inMainModule()) - setIsUsedName(nd); - - checkAttributes(pt,escope,nd -> text,FALSE); - - var = sipMalloc(sizeof (varDef)); - - var -> pyname = nd; - var -> fqcname = text2scopedName(name); - var -> ecd = escope; - var -> module = mod; - var -> varflags = 0; - var -> type = *type; - var -> accessfunc = acode; - var -> getcode = gcode; - var -> setcode = scode; - var -> next = pt -> vars; - - if (isstatic || (escope != NULL && escope->iff->type == namespace_iface)) - setIsStaticVar(var); - - pt -> vars = var; -} - - -/* - * Create a new ctor. - */ -static void newCtor(char *name,int sectFlags,signatureDef *args, - optFlags *optflgs,codeBlock *methodcode, - throwArgs *exceptions,signatureDef *cppsig,int explicit) -{ - ctorDef *ct, **ctp; - classDef *cd = currentScope(); - - /* Check the name of the constructor. */ - if (strcmp(classBaseName(cd),name) != 0) - yyerror("Constructor doesn't have the same name as its class"); - - /* Add to the list of constructors. */ - ct = sipMalloc(sizeof (ctorDef)); - - ct -> ctorflags = sectFlags; - ct -> pysig = *args; - ct -> cppsig = (cppsig != NULL ? cppsig : &ct -> pysig); - ct -> exceptions = exceptions; - ct -> methodcode = methodcode; - ct -> next = NULL; - - if (!isPrivateCtor(ct)) - setCanCreate(cd); - - if (isProtectedCtor(ct)) - setHasShadow(cd); - - if (explicit) - setIsExplicitCtor(ct); - - getHooks(optflgs,&ct -> prehook,&ct -> posthook); - - if (getReleaseGIL(optflgs)) - setIsReleaseGILCtor(ct); - else if (getHoldGIL(optflgs)) - setIsHoldGILCtor(ct); - - if (findOptFlag(optflgs,"NoDerived",bool_flag) != NULL) - { - if (cppsig != NULL) - yyerror("The /NoDerived/ annotation cannot be used with a C++ signature"); - - if (methodcode == NULL) - yyerror("The /NoDerived/ annotation must be used with %MethodCode"); - - ct->cppsig = NULL; - } - - if (findOptFlag(optflgs,"Default",bool_flag) != NULL) - { - if (cd -> defctor != NULL) - yyerror("A constructor with the /Default/ annotation has already been defined"); - - cd -> defctor = ct; - } - - /* Append to the list. */ - for (ctp = &cd->ctors; *ctp != NULL; ctp = &(*ctp)->next) - ; - - *ctp = ct; -} - - -/* - * Create a new function. - */ -static void newFunction(sipSpec *pt,moduleDef *mod,int sflags,int isstatic, - int isvirt,char *name,signatureDef *sig,int isconst, - int isabstract,optFlags *optflgs,codeBlock *methodcode, - codeBlock *vcode,throwArgs *exceptions, - signatureDef *cppsig) -{ - classDef *cd = currentScope(); - nameDef *pname; - int factory, xferback; - overDef *od, **odp, **headp; - optFlag *of; - virtHandlerDef *vhd; - - /* Extra checks for a C module. */ - if (pt -> genc) - { - if (cd != NULL) - yyerror("Function declaration not allowed in a struct in a C module"); - - if (isstatic) - yyerror("Static functions not allowed in a C module"); - - if (exceptions != NULL) - yyerror("Exceptions not allowed in a C module"); - } - - headp = (cd != NULL ? &cd -> overs : &pt -> overs); - - /* See if it is a factory method. */ - if (findOptFlag(optflgs,"Factory",bool_flag) != NULL) - factory = TRUE; - else - { - int a; - - factory = FALSE; - - /* Check /TransferThis/ wasn't specified. */ - if (cd == NULL || isstatic) - for (a = 0; a < sig -> nrArgs; ++a) - if (isThisTransferred(&sig -> args[a])) - yyerror("/TransferThis/ may only be specified in constructors and class methods"); - } - - /* See if the result is to be returned to Python ownership. */ - xferback = (findOptFlag(optflgs,"TransferBack",bool_flag) != NULL); - - if (factory && xferback) - yyerror("/TransferBack/ and /Factory/ cannot both be specified"); - - /* Use the C++ name if a Python name wasn't given. */ - pname = cacheName(pt, getPythonName(optflgs, name)); - - /* Create a new overload definition. */ - - od = sipMalloc(sizeof (overDef)); - - /* Set the overload flags. */ - - od -> overflags = sflags; - - if (factory) - setIsFactory(od); - - if (xferback) - setIsResultTransferredBack(od); - - if (isProtected(od)) - setHasShadow(cd); - - if ((isSlot(od) || isSignal(od)) && !isPrivate(od)) - { - if (isSignal(od)) - setHasShadow(cd); - - pt -> sigslots = TRUE; - } - - if (isSignal(od) && (methodcode != NULL || vcode != NULL)) - yyerror("Cannot provide code for signals"); - - if (isstatic) - { - if (isSignal(od)) - yyerror("Static functions cannot be signals"); - - if (isvirt) - yyerror("Static functions cannot be virtual"); - - setIsStatic(od); - } - - if (isconst) - setIsConst(od); - - if (isabstract) - { - if (sflags == 0) - yyerror("Non-class function specified as abstract"); - - setIsAbstract(od); - } - - if ((of = findOptFlag(optflgs,"AutoGen",opt_name_flag)) != NULL) - { - setIsAutoGen(od); - - if (of -> fvalue.sval != NULL) - { - qualDef *qd; - - if ((qd = findQualifier(of -> fvalue.sval)) == NULL || qd -> qtype != feature_qualifier) - yyerror("No such feature"); - - if (excludedFeature(excludedQualifiers,qd)) - resetIsAutoGen(od); - } - } - - if (isvirt) - { - if (isSignal(od) && !optNoEmitters(pt)) - yyerror("Virtual signals aren't supported"); - - setIsVirtual(od); - setHasShadow(cd); - - vhd = sipMalloc(sizeof (virtHandlerDef)); - - vhd -> virthandlernr = -1; - vhd -> vhflags = 0; - vhd -> pysig = &od -> pysig; - vhd -> cppsig = (cppsig != NULL ? cppsig : &od -> pysig); - vhd -> module = currentModule; - vhd -> virtcode = vcode; - vhd -> next = currentModule -> virthandlers; - - if (factory || xferback) - setIsTransferVH(vhd); - - currentModule -> virthandlers = vhd; - } - else - { - if (vcode != NULL) - yyerror("%VirtualCatcherCode provided for non-virtual function"); - - vhd = NULL; - } - - od -> cppname = name; - od -> pysig = *sig; - od -> cppsig = (cppsig != NULL ? cppsig : &od -> pysig); - od -> exceptions = exceptions; - od -> methodcode = methodcode; - od -> virthandler = vhd; - od -> common = findFunction(pt,mod,cd,pname,(methodcode != NULL),sig -> nrArgs); - - if (findOptFlag(optflgs,"Numeric",bool_flag) != NULL) - setIsNumeric(od -> common); - - /* Methods that run in new threads must be virtual. */ - if (findOptFlag(optflgs,"NewThread",bool_flag) != NULL) - { - argDef *res; - - if (!isvirt) - yyerror("/NewThread/ may only be specified for virtual functions"); - - /* - * This is an arbitary limitation to make the code generator - * slightly easier - laziness on my part. - */ - res = &od -> cppsig -> result; - - if (res -> atype != void_type || res -> nrderefs != 0) - yyerror("/NewThread/ may only be specified for void functions"); - - setIsNewThread(od); - } - - getHooks(optflgs,&od -> prehook,&od -> posthook); - - if (getReleaseGIL(optflgs)) - setIsReleaseGIL(od); - else if (getHoldGIL(optflgs)) - setIsHoldGIL(od); - - od -> next = NULL; - - /* Append to the list. */ - for (odp = headp; *odp != NULL; odp = &(*odp)->next) - ; - - *odp = od; -} - - -/* - * Return the Python name based on the C/C++ name and any /PyName/ annotation. - */ -static char *getPythonName(optFlags *optflgs, char *cname) -{ - char *pname; - optFlag *of; - - if ((of = findOptFlag(optflgs, "PyName", name_flag)) != NULL) - pname = of -> fvalue.sval; - else - pname = cname; - - return pname; -} - - -/* - * Cache a name in a module. - */ -static nameDef *cacheName(sipSpec *pt,char *name) -{ - nameDef *nd; - - /* See if it already exists. */ - for (nd = pt -> namecache; nd != NULL; nd = nd -> next) - if (strcmp(nd -> text,name) == 0) - return nd; - - /* Create a new one. */ - nd = sipMalloc(sizeof (nameDef)); - - nd -> nameflags = 0; - nd -> module = currentSpec -> module; - nd -> text = name; - nd -> next = pt -> namecache; - - pt -> namecache = nd; - - return nd; -} - - -/* - * Find (or create) an overloaded function name. - */ -static memberDef *findFunction(sipSpec *pt,moduleDef *mod,classDef *cd, - nameDef *pname,int hwcode,int nrargs) -{ - static struct slot_map { - char *name; /* The slot name. */ - slotType type; /* The corresponding type. */ - int needs_hwcode; /* If handwritten code is required. */ - int nrargs; /* Nr. of arguments. */ - } slot_table[] = { - {"__str__", str_slot, TRUE, 0}, - {"__unicode__", unicode_slot, TRUE, 0}, - {"__int__", int_slot, FALSE, 0}, - {"__long__", long_slot, FALSE, 0}, - {"__float__", float_slot, FALSE, 0}, - {"__len__", len_slot, TRUE, 0}, - {"__contains__", contains_slot, TRUE, 1}, - {"__add__", add_slot, FALSE, 1}, - {"__sub__", sub_slot, FALSE, 1}, - {"__mul__", mul_slot, FALSE, 1}, - {"__div__", div_slot, FALSE, 1}, - {"__mod__", mod_slot, FALSE, 1}, - {"__and__", and_slot, FALSE, 1}, - {"__or__", or_slot, FALSE, 1}, - {"__xor__", xor_slot, FALSE, 1}, - {"__lshift__", lshift_slot, FALSE, 1}, - {"__rshift__", rshift_slot, FALSE, 1}, - {"__iadd__", iadd_slot, FALSE, 1}, - {"__isub__", isub_slot, FALSE, 1}, - {"__imul__", imul_slot, FALSE, 1}, - {"__idiv__", idiv_slot, FALSE, 1}, - {"__imod__", imod_slot, FALSE, 1}, - {"__iand__", iand_slot, FALSE, 1}, - {"__ior__", ior_slot, FALSE, 1}, - {"__ixor__", ixor_slot, FALSE, 1}, - {"__ilshift__", ilshift_slot, FALSE, 1}, - {"__irshift__", irshift_slot, FALSE, 1}, - {"__invert__", invert_slot, FALSE, 0}, - {"__call__", call_slot, FALSE, -1}, - {"__getitem__", getitem_slot, FALSE, -1}, - {"__setitem__", setitem_slot, TRUE, -1}, - {"__delitem__", delitem_slot, TRUE, -1}, - {"__lt__", lt_slot, FALSE, 1}, - {"__le__", le_slot, FALSE, 1}, - {"__eq__", eq_slot, FALSE, 1}, - {"__ne__", ne_slot, FALSE, 1}, - {"__gt__", gt_slot, FALSE, 1}, - {"__ge__", ge_slot, FALSE, 1}, - {"__cmp__", cmp_slot, FALSE, 1}, - {"__nonzero__", nonzero_slot, TRUE, 0}, - {"__neg__", neg_slot, FALSE, 0}, - {"__pos__", pos_slot, FALSE, 0}, - {"__abs__", abs_slot, TRUE, 0}, - {"__repr__", repr_slot, TRUE, 0}, - {"__hash__", hash_slot, TRUE, 0}, - {NULL} - }; - - memberDef *md, **flist; - struct slot_map *sm; - slotType st; - - /* Get the slot type. */ - st = no_slot; - - for (sm = slot_table; sm -> name != NULL; ++sm) - if (strcmp(sm -> name,pname -> text) == 0) - { - if (sm -> needs_hwcode && !hwcode) - yyerror("This Python slot requires %MethodCode"); - - if (sm -> nrargs < 0) - { - int min_nr; - - /* These require a minimum number. */ - switch (sm -> type) - { - case getitem_slot: - case delitem_slot: - min_nr = 1; - break; - - case setitem_slot: - min_nr = 2; - break; - - default: - min_nr = 0; - } - - if (nrargs < min_nr) - yyerror("Insufficient number of arguments to Python slot"); - } - else if (cd == NULL) - { - /* Global operators need one extra argument. */ - if (sm -> nrargs + 1 != nrargs) - yyerror("Incorrect number of arguments to global operator"); - } - else if (sm -> nrargs != nrargs) - yyerror("Incorrect number of arguments to Python slot"); - - st = sm -> type; - - break; - } - - if (inMainModule()) - setIsUsedName(pname); - - /* Check there is no name clash. */ - checkAttributes(pt,cd,pname -> text,TRUE); - - /* See if it already exists. */ - flist = (cd != NULL ? &cd -> members : &pt -> othfuncs); - - for (md = *flist; md != NULL; md = md -> next) - if (md -> pyname == pname && md -> module == mod) - return md; - - /* Create a new one. */ - md = sipMalloc(sizeof (memberDef)); - - md -> pyname = pname; - md -> memberflags = 0; - md -> slot = st; - md -> module = mod; - md -> next = *flist; - - *flist = md; - - /* Global operators are a subset. */ - if (cd == NULL && st != no_slot && st != neg_slot && st != pos_slot && !isNumberSlot(md) && !isRichCompareSlot(md)) - yyerror("Global operators must be either numeric or comparison operators"); - - return md; -} - - -/* - * Search a set of flags for a particular one and check its type. - */ -static optFlag *findOptFlag(optFlags *flgs,char *name,flagType ft) -{ - int f; - - for (f = 0; f < flgs -> nrFlags; ++f) - { - optFlag *of = &flgs -> flags[f]; - - if (strcmp(of -> fname,name) == 0) - { - /* - * An optional name can look like a boolean or a name. - */ - - if (ft == opt_name_flag) - { - if (of -> ftype == bool_flag) - { - of -> ftype = opt_name_flag; - of -> fvalue.sval = NULL; - } - else if (of -> ftype == name_flag) - of -> ftype = opt_name_flag; - } - - if (ft != of -> ftype) - yyerror("Optional flag has a value of the wrong type"); - - return of; - } - } - - return NULL; -} - - -/* - * A name is going to be used as a Python attribute name within a Python scope - * (ie. a Python dictionary), so check against what we already know is going in - * the same scope in case there is a clash. - */ -static void checkAttributes(sipSpec *pt,classDef *pyscope,char *attr,int isfunc) -{ - enumDef *ed; - varDef *vd; - classDef *cd; - - /* Check the enums. */ - - for (ed = pt -> enums; ed != NULL; ed = ed -> next) - { - enumMemberDef *emd; - - if (ed -> ecd != pyscope || ed -> pyname == NULL) - continue; - - if (strcmp(ed->pyname->text, attr) == 0) - yyerror("There is already an enum in scope with the same Python name"); - - for (emd = ed -> members; emd != NULL; emd = emd -> next) - if (strcmp(emd -> pyname -> text, attr) == 0) - yyerror("There is already an enum member in scope with the same Python name"); - } - - /* Check the variables. */ - - for (vd = pt -> vars; vd != NULL; vd = vd -> next) - { - if (vd -> ecd != pyscope) - continue; - - if (strcmp(vd -> pyname -> text, attr) == 0) - yyerror("There is already a variable in scope with the same Python name"); - } - - /* - * Only check the members if this attribute isn't a member because we - * can handle members with the same name in the same scope. - */ - if (!isfunc) - { - memberDef *md, *membs; - - membs = (pyscope != NULL ? pyscope -> members : pt -> othfuncs); - - for (md = membs; md != NULL; md = md -> next) - { - overDef *od, *overs; - - if (strcmp(md -> pyname -> text, attr) != 0) - continue; - - /* Check for a conflict with all overloads. */ - - overs = (pyscope != NULL ? pyscope -> overs : pt -> overs); - - for (od = overs; od != NULL; od = od -> next) - { - if (od -> common != md) - continue; - - yyerror("There is already a function in scope with the same Python name"); - } - } - } - - /* Check the classes. */ - - for (cd = pt -> classes; cd != NULL; cd = cd -> next) - { - if (cd -> ecd != pyscope || cd -> pyname == NULL) - continue; - - if (strcmp(cd->pyname, attr) == 0 && !isExternal(cd)) - yyerror("There is already a class or namespace in scope with the same Python name"); - } - - /* Check the exceptions. */ - - if (pyscope == NULL) - { - exceptionDef *xd; - - for (xd = pt->exceptions; xd != NULL; xd = xd->next) - if (xd->pyname != NULL && strcmp(xd->pyname, attr) == 0) - yyerror("There is already an exception with the same Python name"); - } -} - - -/* - * Append a code block to a list of them. Append is needed to give the - * specifier easy control over the order of the documentation. - */ -static void appendCodeBlock(codeBlock **headp,codeBlock *new) -{ - while (*headp != NULL) - headp = &(*headp) -> next; - - *headp = new; -} - - -/* - * Handle the end of a fully parsed a file. - */ -static void handleEOF() -{ - /* - * Check that the number of nested if's is the same as when we started - * the file. - */ - - if (skipStackPtr > newContext.ifdepth) - fatal("Too many %%If statements in %s\n",previousFile); - - if (skipStackPtr < newContext.ifdepth) - fatal("Too many %%End statements in %s\n",previousFile); -} - - -/* - * Handle the end of a fully parsed a module. - */ -static void handleEOM() -{ - /* Check it has been named. */ - - if (currentModule -> name == NULL) - fatal("No %%Module has been specified for module defined in %s\n",previousFile); - - /* The previous module is now current. */ - - currentModule = newContext.prevmod; -} - - -/* - * Find an existing qualifier. - */ -static qualDef *findQualifier(char *name) -{ - moduleDef *mod; - - for (mod = currentSpec -> modules; mod != NULL; mod = mod -> next) - { - qualDef *qd; - - for (qd = mod -> qualifiers; qd != NULL; qd = qd -> next) - if (strcmp(qd -> name,name) == 0) - return qd; - } - - return NULL; -} - - -/* - * Return a copy of a scoped name. - */ -scopedNameDef *copyScopedName(scopedNameDef *snd) -{ - scopedNameDef *head; - - head = NULL; - - while (snd != NULL) - { - appendScopedName(&head,text2scopePart(snd -> name)); - snd = snd -> next; - } - - return head; -} - - -/* - * Append a name to a list of scopes. - */ -void appendScopedName(scopedNameDef **headp,scopedNameDef *newsnd) -{ - while (*headp != NULL) - headp = &(*headp) -> next; - - *headp = newsnd; -} - - -/* - * Free a scoped name - but not the text itself. - */ -void freeScopedName(scopedNameDef *snd) -{ - while (snd != NULL) - { - scopedNameDef *next = snd -> next; - - free(snd); - - snd = next; - } -} - - -/* - * Convert a text string to a scope part structure. - */ -scopedNameDef *text2scopePart(char *text) -{ - scopedNameDef *snd; - - snd = sipMalloc(sizeof (scopedNameDef)); - - snd -> name = text; - snd -> next = NULL; - - return snd; -} - - -/* - * Convert a text string to a fully scoped name. - */ -static scopedNameDef *text2scopedName(char *text) -{ - return scopeScopedName(text2scopePart(text)); -} - - -/* - * Prepend any current scope to a scoped name. - */ -static scopedNameDef *scopeScopedName(scopedNameDef *name) -{ - classDef *cd = currentScope(); - scopedNameDef *snd; - - snd = (cd != NULL ? copyScopedName(cd->iff->fqcname) : NULL); - - appendScopedName(&snd, name); - - return snd; -} - - -/* - * Return a pointer to the tail part of a scoped name. - */ -char *scopedNameTail(scopedNameDef *snd) -{ - if (snd == NULL) - return NULL; - - while (snd -> next != NULL) - snd = snd -> next; - - return snd -> name; -} - - -/* - * Push the given scope onto the scope stack. - */ -static void pushScope(classDef *scope) -{ - if (currentScopeIdx >= MAX_NESTED_SCOPE) - fatal("Internal error: increase the value of MAX_NESTED_SCOPE\n"); - - scopeStack[currentScopeIdx] = scope; - sectFlagsStack[currentScopeIdx] = sectionFlags; - - ++currentScopeIdx; -} - - -/* - * Pop the scope stack. - */ -static void popScope(void) -{ - if (currentScopeIdx > 0) - sectionFlags = sectFlagsStack[--currentScopeIdx]; -} - - -/* - * Return non-zero if the current input should be parsed rather than be - * skipped. - */ -static int notSkipping() -{ - return (skipStackPtr == 0 ? TRUE : skipStack[skipStackPtr - 1]); -} - - -/* - * Return the value of an expression involving a time period. - */ -static int timePeriod(char *lname,char *uname) -{ - int this, line; - qualDef *qd, *lower, *upper; - moduleDef *mod; - - if (lname == NULL) - lower = NULL; - else if ((lower = findQualifier(lname)) == NULL || lower -> qtype != time_qualifier) - yyerror("Lower bound is not a time version"); - - if (uname == NULL) - upper = NULL; - else if ((upper = findQualifier(uname)) == NULL || upper -> qtype != time_qualifier) - yyerror("Upper bound is not a time version"); - - /* Sanity checks on the bounds. */ - - if (lower == NULL && upper == NULL) - yyerror("Lower and upper bounds cannot both be omitted"); - - if (lower != NULL && upper != NULL) - { - if (lower -> module != upper -> module || lower -> line != upper -> line) - yyerror("Lower and upper bounds are from different timelines"); - - if (lower == upper) - yyerror("Lower and upper bounds must be different"); - - if (lower -> order > upper -> order) - yyerror("Later version specified as lower bound"); - } - - /* Go through each slot in the relevant timeline. */ - - if (lower != NULL) - { - mod = lower -> module; - line = lower -> line; - } - else - { - mod = upper -> module; - line = upper -> line; - } - - this = FALSE; - - for (qd = mod -> qualifiers; qd != NULL; qd = qd -> next) - { - if (qd -> qtype != time_qualifier || qd -> line != line) - continue; - - if (lower != NULL && qd -> order < lower -> order) - continue; - - if (upper != NULL && qd -> order >= upper -> order) - continue; - - /* - * This is within the required range so if it is also needed - * then the expression is true. - */ - - if (isNeeded(qd)) - { - this = TRUE; - break; - } - } - - return this; -} - - -/* - * Return the value of an expression involving a single platform or feature. - */ -static int platOrFeature(char *name,int optnot) -{ - int this; - qualDef *qd; - - if ((qd = findQualifier(name)) == NULL || qd -> qtype == time_qualifier) - yyerror("No such platform or feature"); - - /* Assume this sub-expression is false. */ - - this = FALSE; - - if (qd -> qtype == feature_qualifier) - { - if (!excludedFeature(excludedQualifiers,qd)) - this = TRUE; - } - else if (isNeeded(qd)) - this = TRUE; - - if (optnot) - this = !this; - - return this; -} - - -/* - * Return TRUE if the given qualifier is excluded. - */ -int excludedFeature(stringList *xsl,qualDef *qd) -{ - while (xsl != NULL) - { - if (strcmp(qd -> name,xsl -> s) == 0) - return TRUE; - - xsl = xsl -> next; - } - - return FALSE; -} - - -/* - * Return TRUE if the given qualifier is needed. - */ -static int isNeeded(qualDef *qd) -{ - stringList *sl; - - for (sl = neededQualifiers; sl != NULL; sl = sl -> next) - if (strcmp(qd -> name,sl -> s) == 0) - return TRUE; - - return FALSE; -} - - -/* - * Return the current scope. currentScope() is only valid if notSkipping() - * returns non-zero. - */ -static classDef *currentScope(void) -{ - return (currentScopeIdx > 0 ? scopeStack[currentScopeIdx - 1] : NULL); -} - - -/* - * Create a new qualifier. - */ -static void newQualifier(moduleDef *mod,int line,int order,char *name,qualType qt) -{ - qualDef *qd; - - /* Check it doesn't already exist. */ - - if (findQualifier(name) != NULL) - yyerror("Version is already defined"); - - qd = sipMalloc(sizeof (qualDef)); - qd -> name = name; - qd -> qtype = qt; - qd -> module = mod; - qd -> line = line; - qd -> order = order; - qd -> next = mod -> qualifiers; - mod -> qualifiers = qd; -} - - -/* - * Create a new imported module. - */ -static void newImport(char *name) -{ - moduleDef *from, *mod; - moduleListDef *mld; - - /* Create a new module if it has already been imported. */ - for (mod = currentSpec -> modules; mod != NULL; mod = mod -> next) - if (strcmp(mod -> file,name) == 0) - break; - - from = currentModule; - - if (mod == NULL) - { - newModule(NULL,name); - mod = currentModule; - } - - /* Add the new import unless it has already been imported. */ - for (mld = from->imports; mld != NULL; mld = mld->next) - if (mld->module == mod) - return; - - mld = sipMalloc(sizeof (moduleListDef)); - mld -> module = mod; - mld -> next = from->imports; - - from->imports = mld; -} - - -/* - * Set up pointers to hook names. - */ -static void getHooks(optFlags *optflgs,char **pre,char **post) -{ - optFlag *of; - - if ((of = findOptFlag(optflgs,"PreHook",name_flag)) != NULL) - *pre = of -> fvalue.sval; - else - *pre = NULL; - - if ((of = findOptFlag(optflgs,"PostHook",name_flag)) != NULL) - *post = of -> fvalue.sval; - else - *post = NULL; -} - - -/* - * Get the /ReleaseGIL/ option flag. - */ -static int getReleaseGIL(optFlags *optflgs) -{ - return (findOptFlag(optflgs, "ReleaseGIL", bool_flag) != NULL); -} - - -/* - * Get the /HoldGIL/ option flag. - */ -static int getHoldGIL(optFlags *optflgs) -{ - return (findOptFlag(optflgs, "HoldGIL", bool_flag) != NULL); -} - - -/* - * Return TRUE if the QtNoEmitters option was specified. - */ -int optNoEmitters(sipSpec *pt) -{ - return optFind(pt, "QtNoEmitters"); -} - - -/* - * Return TRUE if the QtRegisterTypes option was specified. - */ -int optRegisterTypes(sipSpec *pt) -{ - return optFind(pt, "QtRegisterTypes"); -} - - -/* - * Return TRUE if the Qt4Q_OBJECT option was specified. - */ -int optQ_OBJECT4(sipSpec *pt) -{ - return optFind(pt, "Qt4Q_OBJECT"); -} - - -/* - * Return TRUE if a particular option was specified with %SIPOptions. - */ -static int optFind(sipSpec *pt, const char *opt) -{ - stringList *sl; - - for (sl = pt->options; sl != NULL; sl = sl->next) - if (strcmp(sl->s, opt) == 0) - return TRUE; - - return FALSE; -} - diff --git a/python/sip/sipgen/parser.h b/python/sip/sipgen/parser.h deleted file mode 100644 index 7a75072d..00000000 --- a/python/sip/sipgen/parser.h +++ /dev/null @@ -1,268 +0,0 @@ -/* A Bison parser, made by GNU Bison 1.875d. */ - -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TK_OPTIONS = 258, - TK_NOEMITTERS = 259, - TK_DOC = 260, - TK_EXPORTEDDOC = 261, - TK_MAKEFILE = 262, - TK_ACCESSCODE = 263, - TK_GETCODE = 264, - TK_SETCODE = 265, - TK_PREINITCODE = 266, - TK_POSTINITCODE = 267, - TK_UNITCODE = 268, - TK_MODCODE = 269, - TK_TYPECODE = 270, - TK_PREPYCODE = 271, - TK_COPYING = 272, - TK_MAPPEDTYPE = 273, - TK_CODELINE = 274, - TK_IF = 275, - TK_END = 276, - TK_NAME = 277, - TK_PATHNAME = 278, - TK_STRING = 279, - TK_VIRTUALCATCHERCODE = 280, - TK_TRAVERSECODE = 281, - TK_CLEARCODE = 282, - TK_READBUFFERCODE = 283, - TK_WRITEBUFFERCODE = 284, - TK_SEGCOUNTCODE = 285, - TK_CHARBUFFERCODE = 286, - TK_METHODCODE = 287, - TK_FROMTYPE = 288, - TK_TOTYPE = 289, - TK_TOSUBCLASS = 290, - TK_INCLUDE = 291, - TK_OPTINCLUDE = 292, - TK_IMPORT = 293, - TK_EXPHEADERCODE = 294, - TK_MODHEADERCODE = 295, - TK_TYPEHEADERCODE = 296, - TK_MODULE = 297, - TK_CMODULE = 298, - TK_CLASS = 299, - TK_STRUCT = 300, - TK_PUBLIC = 301, - TK_PROTECTED = 302, - TK_PRIVATE = 303, - TK_SIGNALS = 304, - TK_SLOTS = 305, - TK_BOOL = 306, - TK_SHORT = 307, - TK_INT = 308, - TK_LONG = 309, - TK_FLOAT = 310, - TK_DOUBLE = 311, - TK_CHAR = 312, - TK_WCHAR_T = 313, - TK_VOID = 314, - TK_PYOBJECT = 315, - TK_PYTUPLE = 316, - TK_PYLIST = 317, - TK_PYDICT = 318, - TK_PYCALLABLE = 319, - TK_PYSLICE = 320, - TK_PYTYPE = 321, - TK_VIRTUAL = 322, - TK_ENUM = 323, - TK_SIGNED = 324, - TK_UNSIGNED = 325, - TK_SCOPE = 326, - TK_LOGICAL_OR = 327, - TK_CONST = 328, - TK_STATIC = 329, - TK_SIPQT_SIGNAL = 330, - TK_SIPQT_SLOT = 331, - TK_SIPANYQT_SLOT = 332, - TK_SIPRXCON = 333, - TK_SIPRXDIS = 334, - TK_SIPSLOTCON = 335, - TK_SIPSLOTDIS = 336, - TK_NUMBER = 337, - TK_REAL = 338, - TK_TYPEDEF = 339, - TK_NAMESPACE = 340, - TK_TIMELINE = 341, - TK_PLATFORMS = 342, - TK_FEATURE = 343, - TK_LICENSE = 344, - TK_QCHAR = 345, - TK_TRUE = 346, - TK_FALSE = 347, - TK_NULL = 348, - TK_OPERATOR = 349, - TK_THROW = 350, - TK_QOBJECT = 351, - TK_EXCEPTION = 352, - TK_RAISECODE = 353, - TK_EXPLICIT = 354, - TK_TEMPLATE = 355, - TK_ELLIPSIS = 356 - }; -#endif -#define TK_OPTIONS 258 -#define TK_NOEMITTERS 259 -#define TK_DOC 260 -#define TK_EXPORTEDDOC 261 -#define TK_MAKEFILE 262 -#define TK_ACCESSCODE 263 -#define TK_GETCODE 264 -#define TK_SETCODE 265 -#define TK_PREINITCODE 266 -#define TK_POSTINITCODE 267 -#define TK_UNITCODE 268 -#define TK_MODCODE 269 -#define TK_TYPECODE 270 -#define TK_PREPYCODE 271 -#define TK_COPYING 272 -#define TK_MAPPEDTYPE 273 -#define TK_CODELINE 274 -#define TK_IF 275 -#define TK_END 276 -#define TK_NAME 277 -#define TK_PATHNAME 278 -#define TK_STRING 279 -#define TK_VIRTUALCATCHERCODE 280 -#define TK_TRAVERSECODE 281 -#define TK_CLEARCODE 282 -#define TK_READBUFFERCODE 283 -#define TK_WRITEBUFFERCODE 284 -#define TK_SEGCOUNTCODE 285 -#define TK_CHARBUFFERCODE 286 -#define TK_METHODCODE 287 -#define TK_FROMTYPE 288 -#define TK_TOTYPE 289 -#define TK_TOSUBCLASS 290 -#define TK_INCLUDE 291 -#define TK_OPTINCLUDE 292 -#define TK_IMPORT 293 -#define TK_EXPHEADERCODE 294 -#define TK_MODHEADERCODE 295 -#define TK_TYPEHEADERCODE 296 -#define TK_MODULE 297 -#define TK_CMODULE 298 -#define TK_CLASS 299 -#define TK_STRUCT 300 -#define TK_PUBLIC 301 -#define TK_PROTECTED 302 -#define TK_PRIVATE 303 -#define TK_SIGNALS 304 -#define TK_SLOTS 305 -#define TK_BOOL 306 -#define TK_SHORT 307 -#define TK_INT 308 -#define TK_LONG 309 -#define TK_FLOAT 310 -#define TK_DOUBLE 311 -#define TK_CHAR 312 -#define TK_WCHAR_T 313 -#define TK_VOID 314 -#define TK_PYOBJECT 315 -#define TK_PYTUPLE 316 -#define TK_PYLIST 317 -#define TK_PYDICT 318 -#define TK_PYCALLABLE 319 -#define TK_PYSLICE 320 -#define TK_PYTYPE 321 -#define TK_VIRTUAL 322 -#define TK_ENUM 323 -#define TK_SIGNED 324 -#define TK_UNSIGNED 325 -#define TK_SCOPE 326 -#define TK_LOGICAL_OR 327 -#define TK_CONST 328 -#define TK_STATIC 329 -#define TK_SIPQT_SIGNAL 330 -#define TK_SIPQT_SLOT 331 -#define TK_SIPANYQT_SLOT 332 -#define TK_SIPRXCON 333 -#define TK_SIPRXDIS 334 -#define TK_SIPSLOTCON 335 -#define TK_SIPSLOTDIS 336 -#define TK_NUMBER 337 -#define TK_REAL 338 -#define TK_TYPEDEF 339 -#define TK_NAMESPACE 340 -#define TK_TIMELINE 341 -#define TK_PLATFORMS 342 -#define TK_FEATURE 343 -#define TK_LICENSE 344 -#define TK_QCHAR 345 -#define TK_TRUE 346 -#define TK_FALSE 347 -#define TK_NULL 348 -#define TK_OPERATOR 349 -#define TK_THROW 350 -#define TK_QOBJECT 351 -#define TK_EXCEPTION 352 -#define TK_RAISECODE 353 -#define TK_EXPLICIT 354 -#define TK_TEMPLATE 355 -#define TK_ELLIPSIS 356 - - - - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 103 "parser.y" -typedef union YYSTYPE { - char qchar; - char *text; - long number; - double real; - argDef memArg; - signatureDef signature; - signatureDef *optsignature; - throwArgs *throwlist; - codeBlock *codeb; - valueDef value; - valueDef *valp; - optFlags optflags; - optFlag flag; - scopedNameDef *scpvalp; - fcallDef fcall; - int boolean; - exceptionDef exceptionbase; - classDef *klass; -} YYSTYPE; -/* Line 1285 of yacc.c. */ -#line 260 "parser.h" -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - -extern YYSTYPE yylval; - - - diff --git a/python/sip/sipgen/parser.y b/python/sip/sipgen/parser.y deleted file mode 100644 index bba7d0c1..00000000 --- a/python/sip/sipgen/parser.y +++ /dev/null @@ -1,4945 +0,0 @@ -/* - * The SIP parser. - * - * Copyright (c) 2007 - * Riverbank Computing Limited <info@riverbankcomputing.co.uk> - * - * This file is part of SIP. - * - * This copy of SIP is licensed for use under the terms of the SIP License - * Agreement. See the file LICENSE for more details. - * - * SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - -%{ -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - -#include "sip.h" - - -#define MAX_NESTED_IF 10 -#define MAX_NESTED_SCOPE 10 - -#define inMainModule() (currentSpec -> module == currentModule) - - -static sipSpec *currentSpec; /* The current spec being parsed. */ -static stringList *neededQualifiers; /* The list of required qualifiers. */ -static stringList *excludedQualifiers; /* The list of excluded qualifiers. */ -static moduleDef *currentModule; /* The current module being parsed. */ -static mappedTypeDef *currentMappedType; /* The current mapped type. */ -static enumDef *currentEnum; /* The current enum being parsed. */ -static int sectionFlags; /* The current section flags. */ -static int currentOverIsVirt; /* Set if the overload is virtual. */ -static int currentCtorIsExplicit; /* Set if the ctor is explicit. */ -static int currentIsStatic; /* Set if the current is static. */ -static char *previousFile; /* The file just parsed. */ -static parserContext newContext; /* The new pending context. */ -static int skipStackPtr; /* The skip stack pointer. */ -static int skipStack[MAX_NESTED_IF]; /* Stack of skip flags. */ -static classDef *scopeStack[MAX_NESTED_SCOPE]; /* The scope stack. */ -static int sectFlagsStack[MAX_NESTED_SCOPE]; /* The section flags stack. */ -static int currentScopeIdx; /* The scope stack index. */ -static int currentTimelineOrder; /* The current timeline order. */ - - -static char *getPythonName(optFlags *optflgs, char *cname); -static nameDef *cacheName(sipSpec *,char *); -static classDef *findClass(sipSpec *,ifaceFileType,scopedNameDef *); -static classDef *findClassWithInterface(sipSpec *pt, ifaceFileDef *iff); -static classDef *newClass(sipSpec *,ifaceFileType,scopedNameDef *); -static void finishClass(sipSpec *,moduleDef *,classDef *,optFlags *); -static exceptionDef *findException(sipSpec *pt, scopedNameDef *fqname, int new); -static mappedTypeDef *newMappedType(sipSpec *,argDef *); -static enumDef *newEnum(sipSpec *,moduleDef *,char *,optFlags *,int); -static void instantiateClassTemplate(sipSpec *pt, moduleDef *mod, classDef *scope, scopedNameDef *fqname, classTmplDef *tcd, templateDef *td); -static void newTypedef(sipSpec *,moduleDef *,char *,argDef *); -static void newVar(sipSpec *,moduleDef *,char *,int,argDef *,optFlags *, - codeBlock *,codeBlock *,codeBlock *); -static void newCtor(char *,int,signatureDef *,optFlags *,codeBlock *, - throwArgs *,signatureDef *,int); -static void newFunction(sipSpec *,moduleDef *,int,int,int,char *, - signatureDef *,int,int,optFlags *,codeBlock *, - codeBlock *,throwArgs *,signatureDef *); -static optFlag *findOptFlag(optFlags *,char *,flagType); -static memberDef *findFunction(sipSpec *,moduleDef *,classDef *,nameDef *,int, - int); -static void checkAttributes(sipSpec *,classDef *,char *,int); -static void newModule(FILE *,char *); -static void appendCodeBlock(codeBlock **,codeBlock *); -static void parseFile(FILE *,char *,moduleDef *,int); -static void handleEOF(void); -static void handleEOM(void); -static qualDef *findQualifier(char *); -static scopedNameDef *text2scopedName(char *); -static scopedNameDef *scopeScopedName(scopedNameDef *name); -static void pushScope(classDef *); -static void popScope(void); -static classDef *currentScope(void); -static void newQualifier(moduleDef *,int,int,char *,qualType); -static void newImport(char *); -static void usedInMainModule(sipSpec *,ifaceFileDef *); -static int timePeriod(char *,char *); -static int platOrFeature(char *,int); -static int isNeeded(qualDef *); -static int notSkipping(void); -static void getHooks(optFlags *,char **,char **); -static int getReleaseGIL(optFlags *); -static int getHoldGIL(optFlags *); -static void templateSignature(signatureDef *sd, int result, classTmplDef *tcd, templateDef *td, classDef *ncd); -static void templateType(argDef *ad, classTmplDef *tcd, templateDef *td, classDef *ncd); -static int search_back(const char *end, const char *start, const char *target); -static char *getType(scopedNameDef *ename, argDef *ad); -static char *scopedNameToString(scopedNameDef *name); -static void addUsedFromCode(sipSpec *pt, ifaceFileList **used, const char *sname); -static int sameName(scopedNameDef *snd, const char *sname); -static int optFind(sipSpec *pt, const char *opt); -%} - -%union { - char qchar; - char *text; - long number; - double real; - argDef memArg; - signatureDef signature; - signatureDef *optsignature; - throwArgs *throwlist; - codeBlock *codeb; - valueDef value; - valueDef *valp; - optFlags optflags; - optFlag flag; - scopedNameDef *scpvalp; - fcallDef fcall; - int boolean; - exceptionDef exceptionbase; - classDef *klass; -} - -%token TK_OPTIONS -%token TK_NOEMITTERS -%token TK_DOC -%token TK_EXPORTEDDOC -%token TK_MAKEFILE -%token TK_ACCESSCODE -%token TK_GETCODE -%token TK_SETCODE -%token TK_PREINITCODE -%token TK_POSTINITCODE -%token TK_UNITCODE -%token TK_MODCODE -%token TK_TYPECODE -%token TK_PREPYCODE -%token TK_COPYING -%token TK_MAPPEDTYPE -%token <codeb> TK_CODELINE -%token TK_IF -%token TK_END -%token <text> TK_NAME -%token <text> TK_PATHNAME -%token <text> TK_STRING -%token TK_VIRTUALCATCHERCODE -%token TK_TRAVERSECODE -%token TK_CLEARCODE -%token TK_READBUFFERCODE -%token TK_WRITEBUFFERCODE -%token TK_SEGCOUNTCODE -%token TK_CHARBUFFERCODE -%token TK_METHODCODE -%token TK_FROMTYPE -%token TK_TOTYPE -%token TK_TOSUBCLASS -%token TK_INCLUDE -%token TK_OPTINCLUDE -%token TK_IMPORT -%token TK_EXPHEADERCODE -%token TK_MODHEADERCODE -%token TK_TYPEHEADERCODE -%token TK_MODULE -%token TK_CMODULE -%token TK_CLASS -%token TK_STRUCT -%token TK_PUBLIC -%token TK_PROTECTED -%token TK_PRIVATE -%token TK_SIGNALS -%token TK_SLOTS -%token TK_BOOL -%token TK_SHORT -%token TK_INT -%token TK_LONG -%token TK_FLOAT -%token TK_DOUBLE -%token TK_CHAR -%token TK_WCHAR_T -%token TK_VOID -%token TK_PYOBJECT -%token TK_PYTUPLE -%token TK_PYLIST -%token TK_PYDICT -%token TK_PYCALLABLE -%token TK_PYSLICE -%token TK_PYTYPE -%token TK_VIRTUAL -%token TK_ENUM -%token TK_SIGNED -%token TK_UNSIGNED -%token TK_SCOPE -%token TK_LOGICAL_OR -%token TK_CONST -%token TK_STATIC -%token TK_SIPSIGNAL -%token TK_SIPSLOT -%token TK_SIPANYSLOT -%token TK_SIPRXCON -%token TK_SIPRXDIS -%token TK_SIPSLOTCON -%token TK_SIPSLOTDIS -%token <number> TK_NUMBER -%token <real> TK_REAL -%token TK_TYPEDEF -%token TK_NAMESPACE -%token TK_TIMELINE -%token TK_PLATFORMS -%token TK_FEATURE -%token TK_LICENSE -%token <qchar> TK_QCHAR -%token TK_TRUE -%token TK_FALSE -%token TK_NULL -%token TK_OPERATOR -%token TK_THROW -%token TK_QOBJECT -%token TK_EXCEPTION -%token TK_RAISECODE -%token TK_EXPLICIT -%token TK_TEMPLATE -%token TK_ELLIPSIS - -%type <memArg> argvalue -%type <memArg> argtype -%type <memArg> cpptype -%type <memArg> basetype -%type <signature> template -%type <signature> arglist -%type <signature> rawarglist -%type <signature> cpptypelist -%type <optsignature> optsig -%type <optsignature> optctorsig -%type <throwlist> optexceptions -%type <throwlist> exceptionlist -%type <number> optslot -%type <number> optref -%type <number> optconst -%type <number> optvirtual -%type <number> optabstract -%type <number> deref -%type <number> optnumber -%type <value> simplevalue -%type <valp> value -%type <valp> expr -%type <valp> optassign -%type <codeb> optaccesscode -%type <codeb> optgetcode -%type <codeb> optsetcode -%type <codeb> exphdrcode -%type <codeb> modhdrcode -%type <codeb> typehdrcode -%type <codeb> opttypehdrcode -%type <codeb> travcode -%type <codeb> clearcode -%type <codeb> readbufcode -%type <codeb> writebufcode -%type <codeb> segcountcode -%type <codeb> charbufcode -%type <codeb> modcode -%type <codeb> typecode -%type <codeb> codeblock -%type <codeb> codelines -%type <codeb> virtualcatchercode -%type <codeb> methodcode -%type <codeb> raisecode -%type <text> operatorname -%type <text> optfilename -%type <text> optname -%type <text> modname -%type <optflags> optflags -%type <optflags> flaglist -%type <flag> flag -%type <flag> flagvalue -%type <qchar> optunop -%type <qchar> binop -%type <scpvalp> scopepart -%type <scpvalp> scopedname -%type <fcall> exprlist -%type <boolean> qualifiers -%type <boolean> oredqualifiers -%type <boolean> modlang -%type <boolean> optclassbody -%type <exceptionbase> baseexception -%type <klass> class - -%% - -specification: statement - | specification statement - ; - -statement: { - /* - * We don't do these in parserEOF() because the parser - * is reading ahead and that would be too early. - */ - - if (previousFile != NULL) - { - handleEOF(); - - if (newContext.prevmod != NULL) - handleEOM(); - - free(previousFile); - previousFile = NULL; - } - } modstatement - ; - -modstatement: module - | options - | noemitters - | copying - | include - | optinclude - | import - | timeline - | platforms - | feature - | license - | exphdrcode { - if (notSkipping()) - appendCodeBlock(¤tSpec->exphdrcode, $1); - } - | modhdrcode { - if (notSkipping() && inMainModule()) - appendCodeBlock(¤tSpec -> hdrcode,$1); - } - | modcode { - if (notSkipping() && inMainModule()) - appendCodeBlock(¤tSpec -> cppcode,$1); - } - | preinitcode - | postinitcode - | unitcode - | prepycode - | doc - | exporteddoc - | makefile - | mappedtype - | mappedtypetmpl - | nsstatement - ; - -nsstatement: ifstart - | ifend - | namespace - | struct - | class - | classtmpl - | exception - | typedef - | enum - | function - | variable - | typehdrcode { - if (notSkipping()) - { - classDef *scope = currentScope(); - - if (scope == NULL) - yyerror("%TypeHeaderCode can only be used in a namespace, class or mapped type"); - - appendCodeBlock(&scope->hdrcode, $1); - } - } - ; - -options: TK_OPTIONS '(' optionlist ')' - ; - -optionlist: TK_NAME { - appendString(¤tSpec->options, $1); - } - | optionlist ',' TK_NAME { - appendString(¤tSpec->options, $3); - } - ; - -noemitters: TK_NOEMITTERS { - if (notSkipping()) - { - yywarning("%SIPNoEmitters is deprecated, please use %SIPOptions instead"); - appendString(¤tSpec->options, "QtNoEmitters"); - } - } - ; - -exception: TK_EXCEPTION scopedname baseexception optflags '{' opttypehdrcode raisecode '}' ';' { - if (notSkipping()) - { - exceptionDef *xd; - char *pyname; - - if (currentSpec->genc) - yyerror("%Exception not allowed in a C module"); - - pyname = getPythonName(&$4, scopedNameTail($2)); - - checkAttributes(currentSpec, NULL, pyname, FALSE); - - xd = findException(currentSpec, $2, TRUE); - - if (xd->cd != NULL) - yyerror("%Exception name has already been seen as a class name - it must be defined before being used"); - - if (xd->iff->module != NULL) - yyerror("The %Exception has already been defined"); - - /* Complete the definition. */ - - xd->iff->module = currentModule; - xd->pyname = pyname; - xd->bibase = $3.bibase; - xd->base = $3.base; - xd->hdrcode = $6; - xd->raisecode = $7; - - if (xd->bibase != NULL || xd->base != NULL) - xd->exceptionnr = currentModule->nrexceptions++; - - if (inMainModule() && xd->base != NULL && xd->base->iff->module != currentModule) - addToUsedList(¤tSpec->used, xd->base->iff); - } - } - ; - -baseexception: { - $$.bibase = NULL; - $$.base = NULL; - } - | '(' scopedname ')' { - exceptionDef *xd; - - $$.bibase = NULL; - $$.base = NULL; - - /* See if it is a defined exception. */ - for (xd = currentSpec->exceptions; xd != NULL; xd = xd->next) - if (sameScopedName(xd->iff->fqcname, $2)) - { - $$.base = xd; - break; - } - - if (xd == NULL && $2->next == NULL && strncmp($2->name, "SIP_", 4) == 0) - { - /* See if it is a builtin exception. */ - - static char *builtins[] = { - "Exception", - "StopIteration", - "StandardError", - "ArithmeticError", - "LookupError", - "AssertionError", - "AttributeError", - "EOFError", - "FloatingPointError", - "EnvironmentError", - "IOError", - "OSError", - "ImportError", - "IndexError", - "KeyError", - "KeyboardInterrupt", - "MemoryError", - "NameError", - "OverflowError", - "RuntimeError", - "NotImplementedError", - "SyntaxError", - "IndentationError", - "TabError", - "ReferenceError", - "SystemError", - "SystemExit", - "TypeError", - "UnboundLocalError", - "UnicodeError", - "UnicodeEncodeError", - "UnicodeDecodeError", - "UnicodeTranslateError", - "ValueError", - "ZeroDivisionError", - "WindowsError", - "VMSError", - NULL - }; - - char **cp; - - for (cp = builtins; *cp != NULL; ++cp) - if (strcmp($2->name + 4, *cp) == 0) - { - $$.bibase = *cp; - break; - } - } - - if ($$.bibase == NULL && $$.base == NULL) - yyerror("Unknown exception base type"); - } - ; - -raisecode: TK_RAISECODE codeblock { - $$ = $2; - } - ; - -mappedtype: TK_MAPPEDTYPE basetype { - if (notSkipping()) - currentMappedType = newMappedType(currentSpec,&$2); - } mtdefinition - ; - -mappedtypetmpl: template TK_MAPPEDTYPE basetype { - int a; - - if (currentSpec->genc) - yyerror("%MappedType templates not allowed in a C module"); - - /* Check the template arguments are all just simple names. */ - for (a = 0; a < $1.nrArgs; ++a) - if ($1.args[a].atype != defined_type || $1.args[a].u.snd->next != NULL) - yyerror("%MappedType template arguments must be simple names"); - - if ($3.atype != template_type) - yyerror("%MappedType template must map a template type"); - - if (notSkipping()) - { - mappedTypeTmplDef *mtt; - - /* Check a template hasn't already been provided. */ - for (mtt = currentSpec->mappedtypetemplates; mtt != NULL; mtt = mtt->next) - if (sameScopedName(mtt->mt->type.u.td->fqname, $3.u.td->fqname) && sameTemplateSignature(&mtt->mt->type.u.td->types, &$3.u.td->types, TRUE)) - yyerror("%MappedType template for this type has already been defined"); - - $3.nrderefs = 0; - $3.argflags = 0; - - mtt = sipMalloc(sizeof (mappedTypeTmplDef)); - - mtt->sig = $1; - mtt->mt = allocMappedType(&$3); - mtt->next = currentSpec->mappedtypetemplates; - - currentSpec->mappedtypetemplates = mtt; - - currentMappedType = mtt->mt; - } - } mtdefinition - ; - -mtdefinition: '{' mtbody '}' ';' { - if (notSkipping()) - { - if (currentMappedType->convfromcode == NULL) - yyerror("%MappedType must have a %ConvertFromTypeCode directive"); - - if (currentMappedType->convtocode == NULL) - yyerror("%MappedType must have a %ConvertToTypeCode directive"); - - currentMappedType = NULL; - } - } - ; - -mtbody: mtline - | mtbody mtline - ; - -mtline: typehdrcode { - if (notSkipping()) - appendCodeBlock(¤tMappedType -> hdrcode,$1); - } - | TK_FROMTYPE codeblock { - if (notSkipping()) - { - if (currentMappedType -> convfromcode != NULL) - yyerror("%MappedType has more than one %ConvertFromTypeCode directive"); - - currentMappedType -> convfromcode = $2; - } - } - | TK_TOTYPE codeblock { - if (notSkipping()) - { - if (currentMappedType -> convtocode != NULL) - yyerror("%MappedType has more than one %ConvertToTypeCode directive"); - - currentMappedType -> convtocode = $2; - } - } - ; - -namespace: TK_NAMESPACE TK_NAME { - if (currentSpec -> genc) - yyerror("namespace definition not allowed in a C module"); - - if (notSkipping()) - { - classDef *ns; - - ns = newClass(currentSpec,namespace_iface,text2scopedName($2)); - - pushScope(ns); - - sectionFlags = 0; - } - } '{' nsbody '}' ';' { - if (inMainModule()) - { - classDef *ns = currentScope(); - - if (!isUsedName(ns->iff->name)) - { - varDef *vd; - - for (vd = currentSpec->vars; vd != NULL; vd = vd->next) - if (vd->ecd == ns) - { - setIsUsedName(ns->iff->name); - break; - } - } - } - - if (notSkipping()) - popScope(); - } - ; - -nsbody: nsstatement - | nsbody nsstatement - ; - -platforms: TK_PLATFORMS { - qualDef *qd; - - for (qd = currentModule -> qualifiers; qd != NULL; qd = qd -> next) - if (qd -> qtype == platform_qualifier) - yyerror("%Platforms has already been defined for this module"); - } - '{' platformlist '}' { - qualDef *qd; - int nrneeded; - - /* - * Check that exactly one platform in the set was - * requested. - */ - - nrneeded = 0; - - for (qd = currentModule -> qualifiers; qd != NULL; qd = qd -> next) - if (qd -> qtype == platform_qualifier && isNeeded(qd)) - ++nrneeded; - - if (nrneeded > 1) - yyerror("No more than one of these %Platforms must be specified with the -t flag"); - } - ; - -platformlist: platform - | platformlist platform - ; - -platform: TK_NAME { - newQualifier(currentModule,-1,-1,$1,platform_qualifier); - } - ; - -feature: TK_FEATURE TK_NAME { - newQualifier(currentModule,-1,-1,$2,feature_qualifier); - } - ; - -timeline: TK_TIMELINE { - currentTimelineOrder = 0; - } - '{' qualifierlist '}' { - qualDef *qd; - int nrneeded; - - /* - * Check that exactly one time slot in the set was - * requested. - */ - - nrneeded = 0; - - for (qd = currentModule -> qualifiers; qd != NULL; qd = qd -> next) - if (qd -> qtype == time_qualifier && isNeeded(qd)) - ++nrneeded; - - if (nrneeded > 1) - yyerror("At most one of this %Timeline must be specified with the -t flag"); - - currentModule -> nrtimelines++; - } - ; - -qualifierlist: qualifiername - | qualifierlist qualifiername - ; - -qualifiername: TK_NAME { - newQualifier(currentModule,currentModule -> nrtimelines,currentTimelineOrder++,$1,time_qualifier); - } - ; - -ifstart: TK_IF '(' qualifiers ')' { - if (skipStackPtr >= MAX_NESTED_IF) - yyerror("Internal error: increase the value of MAX_NESTED_IF"); - - /* Nested %Ifs are implicit logical ands. */ - - if (skipStackPtr > 0) - $3 = ($3 && skipStack[skipStackPtr - 1]); - - skipStack[skipStackPtr++] = $3; - } - ; - -oredqualifiers: TK_NAME { - $$ = platOrFeature($1,FALSE); - } - | '!' TK_NAME { - $$ = platOrFeature($2,TRUE); - } - | oredqualifiers TK_LOGICAL_OR TK_NAME { - $$ = (platOrFeature($3,FALSE) || $1); - } - | oredqualifiers TK_LOGICAL_OR '!' TK_NAME { - $$ = (platOrFeature($4,TRUE) || $1); - } - ; - -qualifiers: oredqualifiers - | optname '-' optname { - $$ = timePeriod($1,$3); - } - ; - -ifend: TK_END { - if (skipStackPtr-- <= 0) - yyerror("Too many %End directives"); - } - ; - -license: TK_LICENSE optflags { - optFlag *of; - - if ($2.nrFlags == 0) - yyerror("%License details not specified"); - - if ((of = findOptFlag(&$2,"Type",string_flag)) == NULL) - yyerror("%License type not specified"); - - currentModule -> license = sipMalloc(sizeof (licenseDef)); - - currentModule -> license -> type = of -> fvalue.sval; - - currentModule -> license -> licensee = - ((of = findOptFlag(&$2,"Licensee",string_flag)) != NULL) - ? of -> fvalue.sval : NULL; - - currentModule -> license -> timestamp = - ((of = findOptFlag(&$2,"Timestamp",string_flag)) != NULL) - ? of -> fvalue.sval : NULL; - - currentModule -> license -> sig = - ((of = findOptFlag(&$2,"Signature",string_flag)) != NULL) - ? of -> fvalue.sval : NULL; - } - ; - -module: modlang modname optnumber { - /* Check the module hasn't already been defined. */ - - moduleDef *mod; - - for (mod = currentSpec -> modules; mod != NULL; mod = mod -> next) - if (mod->fullname != NULL && strcmp(mod->fullname, $2) == 0) - yyerror("Module is already defined"); - - currentModule->fullname = $2; - - if ((currentModule->name = strrchr($2, '.')) != NULL) - currentModule->name++; - else - currentModule->name = $2; - - currentModule -> version = $3; - - if (currentSpec -> genc < 0) - currentSpec -> genc = $1; - else if (currentSpec -> genc != $1) - yyerror("Cannot mix C and C++ modules"); - } - ; - -modlang: TK_MODULE { - $$ = FALSE; - } - | TK_CMODULE { - $$ = TRUE; - } - ; - -modname: TK_NAME - | TK_PATHNAME { - /* - * The grammar design is a bit broken and this is the - * easiest way to allow periods in module names. - */ - - char *cp; - - for (cp = $1; *cp != '\0'; ++cp) - if (*cp != '.' && *cp != '_' && !isalnum(*cp)) - yyerror("Invalid character in module name"); - - $$ = $1; - } - ; - -optnumber: { - $$ = -1; - } - | TK_NUMBER - ; - -include: TK_INCLUDE TK_PATHNAME { - parseFile(NULL,$2,NULL,FALSE); - } - ; - -optinclude: TK_OPTINCLUDE TK_PATHNAME { - parseFile(NULL,$2,NULL,TRUE); - } - ; - -import: TK_IMPORT TK_PATHNAME { - newImport($2); - } - ; - -optaccesscode: { - $$ = NULL; - } - | TK_ACCESSCODE codeblock { - $$ = $2; - } - ; - -optgetcode: { - $$ = NULL; - } - | TK_GETCODE codeblock { - $$ = $2; - } - ; - -optsetcode: { - $$ = NULL; - } - | TK_SETCODE codeblock { - $$ = $2; - } - ; - -copying: TK_COPYING codeblock { - if (inMainModule()) - appendCodeBlock(¤tSpec -> copying,$2); - } - ; - -exphdrcode: TK_EXPHEADERCODE codeblock { - $$ = $2; - } - ; - -modhdrcode: TK_MODHEADERCODE codeblock { - $$ = $2; - } - ; - -typehdrcode: TK_TYPEHEADERCODE codeblock { - $$ = $2; - } - ; - -opttypehdrcode: { - $$ = NULL; - } - | typehdrcode - ; - -travcode: TK_TRAVERSECODE codeblock { - $$ = $2; - } - ; - -clearcode: TK_CLEARCODE codeblock { - $$ = $2; - } - ; - -readbufcode: TK_READBUFFERCODE codeblock { - $$ = $2; - } - ; - -writebufcode: TK_WRITEBUFFERCODE codeblock { - $$ = $2; - } - ; - -segcountcode: TK_SEGCOUNTCODE codeblock { - $$ = $2; - } - ; - -charbufcode: TK_CHARBUFFERCODE codeblock { - $$ = $2; - } - ; - -modcode: TK_MODCODE codeblock { - $$ = $2; - } - ; - -typecode: TK_TYPECODE codeblock { - $$ = $2; - } - ; - -preinitcode: TK_PREINITCODE codeblock { - if (notSkipping() && inMainModule()) - appendCodeBlock(¤tSpec -> preinitcode,$2); - } - ; - -postinitcode: TK_POSTINITCODE codeblock { - if (notSkipping() && inMainModule()) - appendCodeBlock(¤tSpec -> postinitcode,$2); - } - ; - -unitcode: TK_UNITCODE codeblock { - if (notSkipping() && inMainModule()) - appendCodeBlock(¤tSpec->unitcode, $2); - } - ; - -prepycode: TK_PREPYCODE codeblock { - /* - * This is a no-op and is retained for compatibility - * until the last use of it (by SIP v3) can be removed - * from PyQt. - */ - } - ; - -doc: TK_DOC codeblock { - if (inMainModule()) - appendCodeBlock(¤tSpec -> docs,$2); - } - ; - -exporteddoc: TK_EXPORTEDDOC codeblock { - appendCodeBlock(¤tSpec -> docs,$2); - } - ; - -makefile: TK_MAKEFILE TK_PATHNAME optfilename codeblock { - if (inMainModule()) - yywarning("%Makefile is ignored, please use the -b flag instead"); - } - ; - -codeblock: codelines TK_END - ; - -codelines: TK_CODELINE - | codelines TK_CODELINE { - $$ = $1; - - append(&$$->frag, $2->frag); - - free($2->frag); - free($2->filename); - free($2); - } - ; - -enum: TK_ENUM optname optflags { - if (notSkipping()) - { - if (sectionFlags != 0 && (sectionFlags & ~(SECT_IS_PUBLIC | SECT_IS_PROT)) != 0) - yyerror("Class enums must be in the public or protected sections"); - - currentEnum = newEnum(currentSpec,currentModule,$2,&$3,sectionFlags); - } - } '{' optenumbody '}' ';' - ; - -optfilename: { - $$ = NULL; - } - | TK_PATHNAME { - $$ = $1; - } - ; - -optname: { - $$ = NULL; - } - | TK_NAME { - $$ = $1; - } - ; - -optenumbody: - | enumbody - ; - -enumbody: enumline - | enumbody enumline - ; - -enumline: ifstart - | ifend - | TK_NAME optenumassign optflags optcomma { - if (notSkipping()) - { - /* - * Note that we don't use the assigned value. - * This is a hangover from when enums where - * generated in Python. We can remove it when - * we have got around to updating all the .sip - * files. - */ - enumMemberDef *emd, **tail; - - emd = sipMalloc(sizeof (enumMemberDef)); - - emd -> pyname = cacheName(currentSpec, getPythonName(&$3, $1)); - emd -> cname = $1; - emd -> ed = currentEnum; - emd -> next = NULL; - - checkAttributes(currentSpec,emd -> ed -> ecd,emd -> pyname -> text,FALSE); - - /* Append to preserve the order. */ - for (tail = ¤tEnum->members; *tail != NULL; tail = &(*tail)->next) - ; - - *tail = emd; - - if (inMainModule()) - setIsUsedName(emd -> pyname); - } - } - ; - -optcomma: - | ',' - ; - -optenumassign: - | '=' value - ; - -optassign: { - $$ = NULL; - } - | '=' expr { - $$ = $2; - } - ; - -expr: value - | expr binop value { - valueDef *vd; - - if ($1 -> vtype == string_value || $3 -> vtype == string_value) - yyerror("Invalid binary operator for string"); - - /* Find the last value in the existing expression. */ - - for (vd = $1; vd -> next != NULL; vd = vd -> next) - ; - - vd -> vbinop = $2; - vd -> next = $3; - - $$ = $1; - } - ; - -binop: '-' { - $$ = '-'; - } - | '+' { - $$ = '+'; - } - | '*' { - $$ = '*'; - } - | '/' { - $$ = '/'; - } - | '&' { - $$ = '&'; - } - | '|' { - $$ = '|'; - } - ; - -optunop: { - $$ = '\0'; - } - | '!' { - $$ = '!'; - } - | '~' { - $$ = '~'; - } - | '-' { - $$ = '-'; - } - | '+' { - $$ = '+'; - } - ; - -value: optunop simplevalue { - if ($1 != '\0' && $2.vtype == string_value) - yyerror("Invalid unary operator for string"); - - /* - * Convert the value to a simple expression on the - * heap. - */ - - $$ = sipMalloc(sizeof (valueDef)); - - *$$ = $2; - $$ -> vunop = $1; - $$ -> vbinop = '\0'; - $$ -> next = NULL; - } - ; - -scopedname: scopepart - | scopedname TK_SCOPE scopepart { - if (currentSpec -> genc) - yyerror("Scoped names are not allowed in a C module"); - - appendScopedName(&$1,$3); - } - ; - -scopepart: TK_NAME { - $$ = text2scopePart($1); - } - ; - -simplevalue: scopedname { - /* - * We let the C++ compiler decide if the value is a - * valid one - no point in building a full C++ parser - * here. - */ - - $$.vtype = scoped_value; - $$.u.vscp = $1; - } - | basetype '(' exprlist ')' { - fcallDef *fcd; - - fcd = sipMalloc(sizeof (fcallDef)); - *fcd = $3; - fcd -> type = $1; - - $$.vtype = fcall_value; - $$.u.fcd = fcd; - } - | TK_REAL { - $$.vtype = real_value; - $$.u.vreal = $1; - } - | TK_NUMBER { - $$.vtype = numeric_value; - $$.u.vnum = $1; - } - | TK_TRUE { - $$.vtype = numeric_value; - $$.u.vnum = 1; - } - | TK_FALSE { - $$.vtype = numeric_value; - $$.u.vnum = 0; - } - | TK_NULL { - $$.vtype = numeric_value; - $$.u.vnum = 0; - } - | TK_STRING { - $$.vtype = string_value; - $$.u.vstr = $1; - } - | TK_QCHAR { - $$.vtype = qchar_value; - $$.u.vqchar = $1; - } - ; - -exprlist: { - /* No values. */ - - $$.nrArgs = 0; - } - | expr { - /* The single or first expression. */ - - $$.args[0] = $1; - $$.nrArgs = 1; - } - | exprlist ',' expr { - /* Check that it wasn't ...(,expression...). */ - - if ($$.nrArgs == 0) - yyerror("First argument to function call is missing"); - - /* Check there is room. */ - - if ($1.nrArgs == MAX_NR_ARGS) - yyerror("Too many arguments to function call"); - - $$ = $1; - - $$.args[$$.nrArgs] = $3; - $$.nrArgs++; - } - ; - -typedef: TK_TYPEDEF cpptype TK_NAME ';' { - if (notSkipping()) - newTypedef(currentSpec,currentModule,$3,&$2); - } - | TK_TYPEDEF cpptype '(' deref TK_NAME ')' '(' cpptypelist ')' ';' { - if (notSkipping()) - { - argDef ftype; - signatureDef *sig; - - /* Create the full signature on the heap. */ - sig = sipMalloc(sizeof (signatureDef)); - *sig = $8; - sig -> result = $2; - - /* Create the full type. */ - ftype.atype = function_type; - ftype.argflags = 0; - ftype.nrderefs = $4; - ftype.defval = NULL; - ftype.u.sa = sig; - - newTypedef(currentSpec,currentModule,$5,&ftype); - } - } - ; - -struct: TK_STRUCT TK_NAME { - if (notSkipping()) - { - classDef *cd; - - cd = newClass(currentSpec,class_iface,text2scopedName($2)); - - pushScope(cd); - - sectionFlags = SECT_IS_PUBLIC; - } - } optflags '{' classbody '}' ';' { - if (notSkipping()) - { - finishClass(currentSpec, currentModule, currentScope(), &$4); - popScope(); - } - } - ; - -classtmpl: template class { - if (currentSpec->genc) - yyerror("Class templates not allowed in a C module"); - - if (notSkipping()) - { - classTmplDef *tcd; - - /* - * Make sure there is room for the extra class - * name argument. - */ - if ($1.nrArgs == MAX_NR_ARGS) - yyerror("Internal error - increase the value of MAX_NR_ARGS"); - - tcd = sipMalloc(sizeof (classTmplDef)); - tcd->sig = $1; - tcd->cd = $2; - tcd->next = currentSpec->classtemplates; - - currentSpec->classtemplates = tcd; - } - } - ; - -template: TK_TEMPLATE '<' cpptypelist '>' { - $$ = $3; - } - ; - -class: TK_CLASS scopedname { - if (currentSpec -> genc) - yyerror("Class definition not allowed in a C module"); - - if (notSkipping()) - { - classDef *cd; - - cd = newClass(currentSpec, class_iface, scopeScopedName($2)); - - pushScope(cd); - - sectionFlags = SECT_IS_PRIVATE; - } - } superclasses optflags optclassbody ';' { - if (notSkipping()) - { - classDef *cd = currentScope(); - - /* - * See if the class was defined or just - * declared. - */ - if ($6) - { - if ($2->next != NULL) - yyerror("A scoped name cannot be given in a class definition"); - - } - else if (cd->supers != NULL) - yyerror("Class has super-classes but no definition"); - else - setIsOpaque(cd); - - finishClass(currentSpec, currentModule, cd, &$5); - popScope(); - - /* - * Check that external classes have only been - * declared at the global scope. - */ - if (isExternal(cd) && currentScope() != NULL) - yyerror("External classes can only be declared in the global scope"); - - $$ = cd; - } - } - ; - -superclasses: - | ':' superlist - ; - -superlist: superclass - | superlist ',' superclass - ; - -superclass: scopedname { - if (notSkipping()) - { - classDef *cd, *super; - - cd = currentScope(); - - super = findClass(currentSpec,class_iface,$1); - - appendToClassList(&cd -> supers,super); - addToUsedList(&cd->iff->used, super->iff); - } - } - ; - -optclassbody: { - $$ = FALSE; - } - | '{' classbody '}' { - $$ = TRUE; - } - ; - -classbody: classline - | classbody classline - ; - -classline: ifstart - | ifend - | namespace - | struct - | class - | exception - | typedef - | enum - | typecode { - if (notSkipping()) - appendCodeBlock(¤tScope() -> cppcode,$1); - } - | typehdrcode { - if (notSkipping()) - appendCodeBlock(¤tScope() -> hdrcode,$1); - } - | travcode { - if (currentScope()->travcode != NULL) - yyerror("%GCTraverseCode already given for class"); - - if (notSkipping()) - currentScope()->travcode = $1; - } - | clearcode { - if (currentScope()->clearcode != NULL) - yyerror("%GCClearCode already given for class"); - - if (notSkipping()) - currentScope()->clearcode = $1; - } - | readbufcode { - if (currentScope()->readbufcode != NULL) - yyerror("%BIGetReadBufferCode already given for class"); - - if (notSkipping()) - currentScope()->readbufcode = $1; - } - | writebufcode { - if (currentScope()->writebufcode != NULL) - yyerror("%BIGetWriteBufferCode already given for class"); - - if (notSkipping()) - currentScope()->writebufcode = $1; - } - | segcountcode { - if (currentScope()->segcountcode != NULL) - yyerror("%BIGetSegCountCode already given for class"); - - if (notSkipping()) - currentScope()->segcountcode = $1; - } - | charbufcode { - if (currentScope()->charbufcode != NULL) - yyerror("%BIGetCharBufferCode already given for class"); - - if (notSkipping()) - currentScope()->charbufcode = $1; - } - | ctor - | dtor - | varmember - | TK_TOSUBCLASS codeblock { - if (notSkipping()) - { - classDef *cd = currentScope(); - - if (cd -> convtosubcode != NULL) - yyerror("Class has more than one %ConvertToSubClassCode directive"); - - cd -> convtosubcode = $2; - } - } - | TK_TOTYPE codeblock { - if (notSkipping()) - { - classDef *cd = currentScope(); - - if (cd -> convtocode != NULL) - yyerror("Class has more than one %ConvertToTypeCode directive"); - - cd -> convtocode = $2; - } - } - | TK_PUBLIC optslot ':' { - if (currentSpec -> genc) - yyerror("public section not allowed in a C module"); - - if (notSkipping()) - sectionFlags = SECT_IS_PUBLIC | $2; - } - | TK_PROTECTED optslot ':' { - if (currentSpec -> genc) - yyerror("protected section not allowed in a C module"); - - if (notSkipping()) - sectionFlags = SECT_IS_PROT | $2; - } - | TK_PRIVATE optslot ':' { - if (currentSpec -> genc) - yyerror("private section not allowed in a C module"); - - if (notSkipping()) - sectionFlags = SECT_IS_PRIVATE | $2; - } - | TK_SIGNALS ':' { - if (currentSpec -> genc) - yyerror("signals section not allowed in a C module"); - - if (notSkipping()) - sectionFlags = SECT_IS_SIGNAL; - } - ; - -optslot: { - $$ = 0; - } - | TK_SLOTS { - $$ = SECT_IS_SLOT; - } - ; - -dtor: optvirtual '~' TK_NAME '(' ')' optexceptions optabstract optflags ';' methodcode virtualcatchercode { - /* Note that we allow non-virtual dtors in C modules. */ - - if (notSkipping()) - { - classDef *cd = currentScope(); - - if (strcmp(classBaseName(cd),$3) != 0) - yyerror("Destructor doesn't have the same name as its class"); - - if (isDtor(cd)) - yyerror("Destructor has already been defined"); - - if (currentSpec -> genc && $10 == NULL) - yyerror("Destructor in C modules must include %MethodCode"); - - cd -> dealloccode = $10; - cd -> dtorcode = $11; - cd -> dtorexceptions = $6; - cd -> classflags |= sectionFlags; - - if ($7) - { - if (!$1) - yyerror("Abstract destructor must be virtual"); - - setIsAbstractClass(cd); - } - - /* - * The class has a shadow if we have a virtual dtor or some - * dtor code. - */ - if ($1 || $11 != NULL) - { - if (currentSpec -> genc) - yyerror("Virtual destructor or %VirtualCatcherCode not allowed in a C module"); - - setHasShadow(cd); - } - - if (getReleaseGIL(&$8)) - setIsReleaseGILDtor(cd); - else if (getHoldGIL(&$8)) - setIsHoldGILDtor(cd); - } - } - ; - -ctor: TK_EXPLICIT {currentCtorIsExplicit = TRUE;} simplector - | simplector - ; - -simplector: TK_NAME '(' arglist ')' optexceptions optflags optctorsig ';' methodcode { - /* Note that we allow ctors in C modules. */ - - if (notSkipping()) - { - if (currentSpec -> genc) - { - if ($9 == NULL && $3.nrArgs != 0) - yyerror("Constructors with arguments in C modules must include %MethodCode"); - - if (currentCtorIsExplicit) - yyerror("Explicit constructors not allowed in a C module"); - } - - if ((sectionFlags & (SECT_IS_PUBLIC | SECT_IS_PROT | SECT_IS_PRIVATE)) == 0) - yyerror("Constructor must be in the public, private or protected sections"); - - newCtor($1,sectionFlags,&$3,&$6,$9,$5,$7,currentCtorIsExplicit); - } - - free($1); - - currentCtorIsExplicit = FALSE; - } - ; - -optctorsig: { - $$ = NULL; - } - | '[' '(' arglist ')' ']' { - $$ = sipMalloc(sizeof (signatureDef)); - - *$$ = $3; - } - ; - -optsig: { - $$ = NULL; - } - | '[' cpptype '(' arglist ')' ']' { - $$ = sipMalloc(sizeof (signatureDef)); - - *$$ = $4; - $$ -> result = $2; - } - ; - -optvirtual: { - $$ = FALSE; - } - | TK_VIRTUAL { - $$ = TRUE; - } - ; - -function: cpptype TK_NAME '(' arglist ')' optconst optexceptions optabstract optflags optsig ';' methodcode virtualcatchercode { - if (notSkipping()) - { - if (sectionFlags != 0 && (sectionFlags & (SECT_IS_PUBLIC | SECT_IS_PROT | SECT_IS_PRIVATE | SECT_IS_SLOT | SECT_IS_SIGNAL)) == 0) - yyerror("Class function must be in the public, private, protected, slot or signal sections"); - - $4.result = $1; - - newFunction(currentSpec,currentModule, - sectionFlags,currentIsStatic, - currentOverIsVirt, - $2,&$4,$6,$8,&$9,$12,$13,$7,$10); - } - - currentIsStatic = FALSE; - currentOverIsVirt = FALSE; - } - | cpptype TK_OPERATOR operatorname '(' arglist ')' optconst optexceptions optabstract optflags optsig ';' methodcode virtualcatchercode { - if (notSkipping()) - { - classDef *cd = currentScope(); - - /* Handle the unary '+' and '-' operators. */ - if ((cd != NULL && $5.nrArgs == 0) || (cd == NULL && $5.nrArgs == 1)) - { - if (strcmp($3, "__add__") == 0) - $3 = "__pos__"; - else if (strcmp($3, "__sub__") == 0) - $3 = "__neg__"; - } - - $5.result = $1; - - newFunction(currentSpec,currentModule, - sectionFlags,currentIsStatic, - currentOverIsVirt, - $3,&$5,$7,$9,&$10,$13,$14,$8,$11); - } - - currentIsStatic = FALSE; - currentOverIsVirt = FALSE; - } - | TK_OPERATOR cpptype '(' arglist ')' optconst optexceptions optabstract optflags optsig ';' methodcode virtualcatchercode { - classDef *scope = currentScope(); - - if (scope == NULL || $4.nrArgs != 0) - yyerror("Operator casts must be specified in a class and have no arguments"); - - - if (notSkipping()) - { - char *sname; - - switch ($2.atype) - { - case defined_type: - sname = NULL; - break; - - case bool_type: - case cbool_type: - case short_type: - case ushort_type: - case int_type: - case cint_type: - case uint_type: - sname = "__int__"; - break; - - case long_type: - case ulong_type: - case longlong_type: - case ulonglong_type: - sname = "__long__"; - break; - - case float_type: - case cfloat_type: - case double_type: - case cdouble_type: - sname = "__float__"; - break; - - default: - yyerror("Unsupported operator cast"); - } - - if (sname != NULL) - { - $4.result = $2; - - newFunction(currentSpec, currentModule, - sectionFlags, - currentIsStatic, - currentOverIsVirt, sname, - &$4, $6, $8, &$9, $12, $13, - $7, $10); - } - else - { - argList *al; - - /* Check it doesn't already exist. */ - for (al = scope->casts; al != NULL; al = al->next) - if (sameScopedName($2.u.snd, al->arg.u.snd)) - yyerror("This operator cast has already been specified in this class"); - - al = sipMalloc(sizeof (argList)); - al->arg = $2; - al->next = scope->casts; - - scope->casts = al; - } - } - - currentIsStatic = FALSE; - currentOverIsVirt = FALSE; - } - ; - -operatorname: '+' {$$ = "__add__";} - | '-' {$$ = "__sub__";} - | '*' {$$ = "__mul__";} - | '/' {$$ = "__div__";} - | '%' {$$ = "__mod__";} - | '&' {$$ = "__and__";} - | '|' {$$ = "__or__";} - | '^' {$$ = "__xor__";} - | '<' '<' {$$ = "__lshift__";} - | '>' '>' {$$ = "__rshift__";} - | '+' '=' {$$ = "__iadd__";} - | '-' '=' {$$ = "__isub__";} - | '*' '=' {$$ = "__imul__";} - | '/' '=' {$$ = "__idiv__";} - | '%' '=' {$$ = "__imod__";} - | '&' '=' {$$ = "__iand__";} - | '|' '=' {$$ = "__ior__";} - | '^' '=' {$$ = "__ixor__";} - | '<' '<' '=' {$$ = "__ilshift__";} - | '>' '>' '=' {$$ = "__irshift__";} - | '~' {$$ = "__invert__";} - | '(' ')' {$$ = "__call__";} - | '[' ']' {$$ = "__getitem__";} - | '<' {$$ = "__lt__";} - | '<' '=' {$$ = "__le__";} - | '=' '=' {$$ = "__eq__";} - | '!' '=' {$$ = "__ne__";} - | '>' {$$ = "__gt__";} - | '>' '=' {$$ = "__ge__";} - ; - -optconst: { - $$ = FALSE; - } - | TK_CONST { - $$ = TRUE; - } - ; - -optabstract: { - $$ = 0; - } - | '=' TK_NUMBER { - if ($2 != 0) - yyerror("Abstract virtual function '= 0' expected"); - - $$ = TRUE; - } - ; - -optflags: { - $$.nrFlags = 0; - } - | '/' flaglist '/' { - $$ = $2; - } - ; - - -flaglist: flag { - $$.flags[0] = $1; - $$.nrFlags = 1; - } - | flaglist ',' flag { - /* Check there is room. */ - - if ($1.nrFlags == MAX_NR_FLAGS) - yyerror("Too many optional flags"); - - $$ = $1; - - $$.flags[$$.nrFlags++] = $3; - } - ; - -flag: TK_NAME { - $$.ftype = bool_flag; - $$.fname = $1; - } - | TK_NAME '=' flagvalue { - $$ = $3; - $$.fname = $1; - } - ; - -flagvalue: TK_NAME { - $$.ftype = name_flag; - $$.fvalue.sval = $1; - } - | TK_STRING { - $$.ftype = string_flag; - $$.fvalue.sval = $1; - } - | TK_NUMBER { - $$.ftype = integer_flag; - $$.fvalue.ival = $1; - } - ; - -methodcode: { - $$ = NULL; - } - | TK_METHODCODE codeblock { - $$ = $2; - } - ; - -virtualcatchercode: { - $$ = NULL; - } - | TK_VIRTUALCATCHERCODE codeblock { - $$ = $2; - } - ; - -arglist: rawarglist { - int a, nrrxcon, nrrxdis, nrslotcon, nrslotdis, nrarray, nrarraysize; - - nrrxcon = nrrxdis = nrslotcon = nrslotdis = nrarray = nrarraysize = 0; - - for (a = 0; a < $1.nrArgs; ++a) - { - argDef *ad = &$1.args[a]; - - switch (ad -> atype) - { - case rxcon_type: - ++nrrxcon; - break; - - case rxdis_type: - ++nrrxdis; - break; - - case slotcon_type: - ++nrslotcon; - break; - - case slotdis_type: - ++nrslotdis; - break; - } - - if (isArray(ad)) - ++nrarray; - - if (isArraySize(ad)) - ++nrarraysize; - } - - if (nrrxcon != nrslotcon || nrrxcon > 1) - yyerror("SIP_RXOBJ_CON and SIP_SLOT_CON must both be given and at most once"); - - if (nrrxdis != nrslotdis || nrrxdis > 1) - yyerror("SIP_RXOBJ_DIS and SIP_SLOT_DIS must both be given and at most once"); - - if (nrarray != nrarraysize || nrarray > 1) - yyerror("/Array/ and /ArraySize/ must both be given and at most once"); - - $$ = $1; - } - ; - -rawarglist: { - /* No arguments. */ - - $$.nrArgs = 0; - } - | argvalue { - /* The single or first argument. */ - - $$.args[0] = $1; - $$.nrArgs = 1; - } - | rawarglist ',' argvalue { - /* Check that it wasn't ...(,arg...). */ - if ($1.nrArgs == 0) - yyerror("First argument of the list is missing"); - - /* Check there is nothing after an ellipsis. */ - if ($1.args[$1.nrArgs - 1].atype == ellipsis_type) - yyerror("An ellipsis must be at the end of the argument list"); - - /* - * If this argument has no default value, then the - * previous one mustn't either. - */ - if ($3.defval == NULL && $1.args[$1.nrArgs - 1].defval != NULL) - yyerror("Compulsory argument given after optional argument"); - - /* Check there is room. */ - if ($1.nrArgs == MAX_NR_ARGS) - yyerror("Internal error - increase the value of MAX_NR_ARGS"); - - $$ = $1; - - $$.args[$$.nrArgs] = $3; - $$.nrArgs++; - } - ; - -argvalue: TK_SIPSIGNAL optname optassign { - $$.atype = signal_type; - $$.argflags = ARG_IS_CONST; - $$.nrderefs = 0; - $$.name = $2; - $$.defval = $3; - - currentSpec -> sigslots = TRUE; - } - | TK_SIPSLOT optname optassign { - $$.atype = slot_type; - $$.argflags = ARG_IS_CONST; - $$.nrderefs = 0; - $$.name = $2; - $$.defval = $3; - - currentSpec -> sigslots = TRUE; - } - | TK_SIPANYSLOT optname optassign { - $$.atype = anyslot_type; - $$.argflags = ARG_IS_CONST; - $$.nrderefs = 0; - $$.name = $2; - $$.defval = $3; - - currentSpec -> sigslots = TRUE; - } - | TK_SIPRXCON optname { - $$.atype = rxcon_type; - $$.argflags = 0; - $$.nrderefs = 0; - $$.name = $2; - - currentSpec -> sigslots = TRUE; - } - | TK_SIPRXDIS optname { - $$.atype = rxdis_type; - $$.argflags = 0; - $$.nrderefs = 0; - $$.name = $2; - - currentSpec -> sigslots = TRUE; - } - | TK_SIPSLOTCON '(' arglist ')' optname { - $$.atype = slotcon_type; - $$.argflags = ARG_IS_CONST; - $$.nrderefs = 0; - $$.name = $5; - - $3.result.atype = void_type; - $3.result.argflags = 0; - $3.result.nrderefs = 0; - - $$.u.sa = sipMalloc(sizeof (signatureDef)); - *$$.u.sa = $3; - - currentSpec -> sigslots = TRUE; - } - | TK_SIPSLOTDIS '(' arglist ')' optname { - $$.atype = slotdis_type; - $$.argflags = ARG_IS_CONST; - $$.nrderefs = 0; - $$.name = $5; - - $3.result.atype = void_type; - $3.result.argflags = 0; - $3.result.nrderefs = 0; - - $$.u.sa = sipMalloc(sizeof (signatureDef)); - *$$.u.sa = $3; - - currentSpec -> sigslots = TRUE; - } - | TK_QOBJECT optname { - $$.atype = qobject_type; - $$.argflags = 0; - $$.nrderefs = 0; - $$.name = $2; - } - | argtype optassign { - $$ = $1; - $$.defval = $2; - } - ; - -varmember: TK_STATIC {currentIsStatic = TRUE;} varmem - | varmem - ; - -varmem: member - | variable - ; - -member: TK_VIRTUAL {currentOverIsVirt = TRUE;} function - | function - ; - -variable: cpptype TK_NAME optflags ';' optaccesscode optgetcode optsetcode { - if (notSkipping()) - { - /* Check the section. */ - - if (sectionFlags != 0) - { - if ((sectionFlags & SECT_IS_PUBLIC) == 0) - yyerror("Class variables must be in the public section"); - - if (!currentIsStatic && $5 != NULL) - yyerror("%AccessCode cannot be specified for non-static class variables"); - } - - if (currentIsStatic && currentSpec -> genc) - yyerror("Cannot have static members in a C structure"); - - if ($6 != NULL || $7 != NULL) - { - if ($5 != NULL) - yyerror("Cannot mix %AccessCode and %GetCode or %SetCode"); - - if (currentScope() == NULL) - yyerror("Cannot specify %GetCode or %SetCode for global variables"); - } - - newVar(currentSpec,currentModule,$2,currentIsStatic,&$1,&$3,$5,$6,$7); - } - - currentIsStatic = FALSE; - } - ; - -cpptype: TK_CONST basetype deref optref { - $$ = $2; - $$.nrderefs = $3; - $$.argflags = ARG_IS_CONST | $4; - $$.name = NULL; - } - | basetype deref optref { - $$ = $1; - $$.nrderefs = $2; - $$.argflags = $3; - $$.name = NULL; - } - ; - -argtype: cpptype optname optflags { - $$ = $1; - $$.name = $2; - - if (findOptFlag(&$3,"AllowNone",bool_flag) != NULL) - $$.argflags |= ARG_ALLOW_NONE; - - if (findOptFlag(&$3,"GetWrapper",bool_flag) != NULL) - $$.argflags |= ARG_GET_WRAPPER; - - if (findOptFlag(&$3,"Array",bool_flag) != NULL) - $$.argflags |= ARG_ARRAY; - - if (findOptFlag(&$3,"ArraySize",bool_flag) != NULL) - $$.argflags |= ARG_ARRAY_SIZE; - - if (findOptFlag(&$3,"Transfer",bool_flag) != NULL) - $$.argflags |= ARG_XFERRED; - - if (findOptFlag(&$3,"TransferThis",bool_flag) != NULL) - $$.argflags |= ARG_THIS_XFERRED; - - if (findOptFlag(&$3,"TransferBack",bool_flag) != NULL) - $$.argflags |= ARG_XFERRED_BACK; - - if (findOptFlag(&$3,"In",bool_flag) != NULL) - $$.argflags |= ARG_IN; - - if (findOptFlag(&$3,"Out",bool_flag) != NULL) - $$.argflags |= ARG_OUT; - - if (findOptFlag(&$3,"Constrained",bool_flag) != NULL) - { - $$.argflags |= ARG_CONSTRAINED; - - switch ($$.atype) - { - case bool_type: - $$.atype = cbool_type; - break; - - case int_type: - $$.atype = cint_type; - break; - - case float_type: - $$.atype = cfloat_type; - break; - - case double_type: - $$.atype = cdouble_type; - break; - } - } - } - ; - -optref: { - $$ = 0; - } - | '&' { - if (currentSpec -> genc) - yyerror("References not allowed in a C module"); - - $$ = ARG_IS_REF; - } - ; - -deref: { - $$ = 0; - } - | deref '*' { - $$ = $1 + 1; - } - ; - -basetype: scopedname { - $$.atype = defined_type; - $$.u.snd = $1; - } - | scopedname '<' cpptypelist '>' { - templateDef *td; - - td = sipMalloc(sizeof(templateDef)); - td -> fqname = $1; - td -> types = $3; - - $$.atype = template_type; - $$.u.td = td; - } - | TK_STRUCT scopedname { - /* In a C module all structures must be defined. */ - if (currentSpec -> genc) - { - $$.atype = defined_type; - $$.u.snd = $2; - } - else - { - $$.atype = struct_type; - $$.u.sname = $2; - } - } - | TK_UNSIGNED TK_SHORT { - $$.atype = ushort_type; - } - | TK_SHORT { - $$.atype = short_type; - } - | TK_UNSIGNED { - $$.atype = uint_type; - } - | TK_UNSIGNED TK_INT { - $$.atype = uint_type; - } - | TK_INT { - $$.atype = int_type; - } - | TK_LONG { - $$.atype = long_type; - } - | TK_UNSIGNED TK_LONG { - $$.atype = ulong_type; - } - | TK_LONG TK_LONG { - $$.atype = longlong_type; - } - | TK_UNSIGNED TK_LONG TK_LONG { - $$.atype = ulonglong_type; - } - | TK_FLOAT { - $$.atype = float_type; - } - | TK_DOUBLE { - $$.atype = double_type; - } - | TK_BOOL { - $$.atype = bool_type; - } - | TK_SIGNED TK_CHAR { - $$.atype = sstring_type; - } - | TK_UNSIGNED TK_CHAR { - $$.atype = ustring_type; - } - | TK_CHAR { - $$.atype = string_type; - } - | TK_WCHAR_T { - $$.atype = wstring_type; - } - | TK_VOID { - $$.atype = void_type; - } - | TK_PYOBJECT { - $$.atype = pyobject_type; - } - | TK_PYTUPLE { - $$.atype = pytuple_type; - } - | TK_PYLIST { - $$.atype = pylist_type; - } - | TK_PYDICT { - $$.atype = pydict_type; - } - | TK_PYCALLABLE { - $$.atype = pycallable_type; - } - | TK_PYSLICE { - $$.atype = pyslice_type; - } - | TK_PYTYPE { - $$.atype = pytype_type; - } - | TK_ELLIPSIS { - $$.atype = ellipsis_type; - } - ; - -cpptypelist: cpptype { - /* The single or first type. */ - - $$.args[0] = $1; - $$.nrArgs = 1; - } - | cpptypelist ',' cpptype { - /* Check there is nothing after an ellipsis. */ - if ($1.args[$1.nrArgs - 1].atype == ellipsis_type) - yyerror("An ellipsis must be at the end of the argument list"); - - /* Check there is room. */ - if ($1.nrArgs == MAX_NR_ARGS) - yyerror("Internal error - increase the value of MAX_NR_ARGS"); - - $$ = $1; - - $$.args[$$.nrArgs] = $3; - $$.nrArgs++; - } - ; - -optexceptions: { - $$ = NULL; - } - | TK_THROW '(' exceptionlist ')' { - if (currentSpec->genc) - yyerror("Exceptions not allowed in a C module"); - - if (notSkipping() && inMainModule()) - { - int e; - ifaceFileList **ifl; - - /* - * Make sure the exceptions' header files are - * included. We unconditionally mark them to - * be included in the current scope's header - * file to save us the effort of checking if - * they are being used with a protected method, - * a virtual or a signal. - */ - ifl = (currentScope() != NULL) ? ¤tScope()->iff->used : ¤tSpec->used; - - for (e = 0; e < $3->nrArgs; ++e) - addToUsedList(ifl, $3->args[e]->iff); - } - - $$ = $3; - } - ; - -exceptionlist: { - /* Empty list so use a blank. */ - - $$ = sipMalloc(sizeof (throwArgs)); - $$ -> nrArgs = 0; - } - | scopedname { - /* The only or first exception. */ - - $$ = sipMalloc(sizeof (throwArgs)); - $$ -> nrArgs = 1; - $$ -> args[0] = findException(currentSpec, $1, FALSE); - } - | exceptionlist ',' scopedname { - /* Check that it wasn't ...(,arg...). */ - - if ($1 -> nrArgs == 0) - yyerror("First exception of throw specifier is missing"); - - /* Check there is room. */ - - if ($1 -> nrArgs == MAX_NR_ARGS) - yyerror("Internal error - increase the value of MAX_NR_ARGS"); - - $$ = $1; - $$ -> args[$$ -> nrArgs++] = findException(currentSpec, $3, FALSE); - } - ; - -%% - - -/* - * Parse the specification. - */ -void parse(sipSpec *spec,FILE *fp,char *filename,stringList *tsl, - stringList *xfl) -{ - classTmplDef *tcd; - - /* Initialise the spec. */ - - spec -> modules = NULL; - spec -> namecache = NULL; - spec -> ifacefiles = NULL; - spec -> classes = NULL; - spec -> classtemplates = NULL; - spec -> proxies = NULL; - spec -> exceptions = NULL; - spec -> mappedtypes = NULL; - spec -> mappedtypetemplates = NULL; - spec -> qobjclass = -1; - spec -> enums = NULL; - spec -> vars = NULL; - spec -> othfuncs = NULL; - spec -> overs = NULL; - spec -> typedefs = NULL; - spec -> copying = NULL; - spec -> exphdrcode = NULL; - spec -> hdrcode = NULL; - spec -> cppcode = NULL; - spec -> docs = NULL; - spec -> preinitcode = NULL; - spec -> postinitcode = NULL; - spec -> unitcode = NULL; - spec -> used = NULL; - spec -> sigslots = FALSE; - spec -> genc = -1; - spec -> options = NULL; - - currentSpec = spec; - neededQualifiers = tsl; - excludedQualifiers = xfl; - currentModule = NULL; - currentMappedType = NULL; - currentOverIsVirt = FALSE; - currentCtorIsExplicit = FALSE; - currentIsStatic = FALSE; - previousFile = NULL; - skipStackPtr = 0; - currentScopeIdx = 0; - sectionFlags = 0; - - newModule(fp,filename); - spec -> module = currentModule; - - yyparse(); - - handleEOF(); - handleEOM(); - - /* - * Go through each template class and remove it from the list of - * classes. - */ - for (tcd = spec->classtemplates; tcd != NULL; tcd = tcd->next) - { - classDef **cdp; - - for (cdp = &spec->classes; *cdp != NULL; cdp = &(*cdp)->next) - if (*cdp == tcd->cd) - { - ifaceFileDef **ifdp; - - /* Remove the interface file as well. */ - for (ifdp = &spec->ifacefiles; *ifdp != NULL; ifdp = &(*ifdp)->next) - if (*ifdp == tcd->cd->iff) - { - *ifdp = (*ifdp)->next; - break; - } - - *cdp = (*cdp)->next; - break; - } - } -} - - -/* - * Tell the parser that a complete file has now been read. - */ -void parserEOF(char *name,parserContext *pc) -{ - previousFile = sipStrdup(name); - newContext = *pc; -} - - -/* - * Append a class definition to a class list if it doesn't already appear. - * Append is needed specifically for the list of super-classes because the - * order is important to Python. - */ -void appendToClassList(classList **clp,classDef *cd) -{ - classList *new; - - /* Find the end of the list. */ - - while (*clp != NULL) - { - if ((*clp) -> cd == cd) - return; - - clp = &(*clp) -> next; - } - - new = sipMalloc(sizeof (classList)); - - new -> cd = cd; - new -> next = NULL; - - *clp = new; -} - - -/* - * Create a new module for the current specification and make it current. - */ -static void newModule(FILE *fp,char *filename) -{ - moduleDef *newmod; - - parseFile(fp,filename,currentModule,FALSE); - - newmod = sipMalloc(sizeof (moduleDef)); - newmod -> fullname = NULL; - newmod -> name = NULL; - newmod -> version = -1; - newmod -> modflags = 0; - newmod -> modulenr = -1; - newmod -> file = filename; - newmod -> qualifiers = NULL; - newmod -> root.cd = NULL; - newmod -> root.child = NULL; - newmod -> nrtimelines = 0; - newmod -> nrclasses = 0; - newmod -> nrexceptions = 0; - newmod -> nrmappedtypes = 0; - newmod -> nrenums = 0; - newmod -> nrtypedefs = 0; - newmod -> nrvirthandlers = 0; - newmod -> virthandlers = NULL; - newmod -> license = NULL; - newmod -> allimports = NULL; - newmod -> imports = NULL; - newmod -> next = currentSpec -> modules; - - currentModule = currentSpec->modules = newmod; -} - - -/* - * Switch to parsing a new file. - */ -static void parseFile(FILE *fp,char *name,moduleDef *prevmod,int optional) -{ - parserContext pc; - - pc.ifdepth = skipStackPtr; - pc.prevmod = prevmod; - - setInputFile(fp,name,&pc,optional); -} - - -/* - * Find an interface file, or create a new one. - */ -ifaceFileDef *findIfaceFile(sipSpec *pt, moduleDef *mod, scopedNameDef *fqname, - ifaceFileType iftype, argDef *ad) -{ - ifaceFileDef *iff; - - /* See if the name is already used. */ - - for (iff = pt -> ifacefiles; iff != NULL; iff = iff -> next) - { - if (!sameScopedName(iff -> fqcname,fqname)) - continue; - - /* - * They must be the same type except that we allow a class if - * if we want an exception. This is because we allow classes - * to be used before they are defined. - */ - if (iff -> type != iftype) - if (iftype != exception_iface || iff -> type != class_iface) - yyerror("A class, exception, namespace or mapped type has already been defined with the same name"); - - /* Ignore an external class declared in another module. */ - if (iftype == class_iface && iff->module != mod) - { - classDef *cd; - - for (cd = pt->classes; cd != NULL; cd = cd->next) - if (cd->iff == iff) - break; - - if (cd != NULL && iff->module != NULL && isExternal(cd)) - continue; - } - - /* - * If this is a mapped type with the same name defined in a - * different module, then check that this type isn't the same - * as any of the mapped types defined in that module. - */ - if (iftype == mappedtype_iface && iff -> module != mod) - { - mappedTypeDef *mtd; - - for (mtd = pt -> mappedtypes; mtd != NULL; mtd = mtd -> next) - { - if (mtd -> iff != iff) - continue; - - if (ad -> atype != template_type || - mtd -> type.atype != template_type || - sameBaseType(ad,&mtd -> type)) - yyerror("Mapped type has already been defined in another module"); - } - - /* - * If we got here then we have a mapped type based on - * an existing template, but with unique parameters. - * We don't want to use interface files from other - * modules, so skip this one. - */ - - continue; - } - - /* Ignore a namespace defined in another module. */ - if (iftype == namespace_iface && iff->module != mod) - continue; - - return iff; - } - - iff = sipMalloc(sizeof (ifaceFileDef)); - - iff -> name = cacheName(pt,scopedNameTail(fqname)); - iff -> type = iftype; - iff -> fqcname = fqname; - iff -> module = NULL; - iff -> used = NULL; - iff -> next = pt -> ifacefiles; - - pt -> ifacefiles = iff; - - return iff; -} - - -/* - * Find a class definition in a parse tree. - */ -static classDef *findClass(sipSpec *pt,ifaceFileType iftype, - scopedNameDef *fqname) -{ - return findClassWithInterface(pt, findIfaceFile(pt, currentModule, fqname, iftype, NULL)); -} - - -/* - * Find a class definition given an existing interface file. - */ -static classDef *findClassWithInterface(sipSpec *pt, ifaceFileDef *iff) -{ - classDef *cd; - - for (cd = pt -> classes; cd != NULL; cd = cd -> next) - if (cd -> iff == iff) - return cd; - - /* Create a new one. */ - cd = sipMalloc(sizeof (classDef)); - - cd -> iff = iff; - cd -> pyname = classBaseName(cd); - cd -> classnr = -1; - cd -> classflags = 0; - cd -> userflags = 0; - cd -> ecd = NULL; - cd -> dtorexceptions = NULL; - cd -> real = NULL; - cd -> node = NULL; - cd -> supers = NULL; - cd -> mro = NULL; - cd -> td = NULL; - cd -> ctors = NULL; - cd -> defctor = NULL; - cd -> dealloccode = NULL; - cd -> dtorcode = NULL; - cd -> members = NULL; - cd -> overs = NULL; - cd -> casts = NULL; - cd -> vmembers = NULL; - cd -> visible = NULL; - cd -> cppcode = NULL; - cd -> hdrcode = NULL; - cd -> convtosubcode = NULL; - cd -> subbase = NULL; - cd -> convtocode = NULL; - cd -> travcode = NULL; - cd -> clearcode = NULL; - cd -> readbufcode = NULL; - cd -> writebufcode = NULL; - cd -> segcountcode = NULL; - cd -> charbufcode = NULL; - cd -> next = pt -> classes; - - pt -> classes = cd; - - return cd; -} - - -/* - * Add an interface file to an interface file list if it isn't already there. - */ -ifaceFileList *addToUsedList(ifaceFileList **ifflp, ifaceFileDef *iff) -{ - ifaceFileList *iffl; - - while ((iffl = *ifflp) != NULL) - { - /* Don't bother if it is already there. */ - if (iffl -> iff == iff) - return iffl; - - ifflp = &iffl -> next; - } - - iffl = sipMalloc(sizeof (ifaceFileList)); - - iffl->iff = iff; - iffl->header = FALSE; - iffl->next = NULL; - - *ifflp = iffl; - - return iffl; -} - - -/* - * Find an undefined (or create a new) exception definition in a parse tree. - */ -static exceptionDef *findException(sipSpec *pt, scopedNameDef *fqname, int new) -{ - exceptionDef *xd, **tail; - ifaceFileDef *iff; - classDef *cd; - - iff = findIfaceFile(pt, currentModule, fqname, exception_iface, NULL); - - /* See if it is an existing one. */ - for (xd = pt->exceptions; xd != NULL; xd = xd->next) - if (xd->iff == iff) - return xd; - - /* - * If it is an exception interface file then we have never seen this - * name before. We require that exceptions are defined before being - * used, but don't make the same requirement of classes (for reasons of - * backwards compatibility). Therefore the name must be reinterpreted - * as a (as yet undefined) class. - */ - if (new) - if (iff->type == exception_iface) - cd = NULL; - else - yyerror("There is already a class with the same name or the exception has been used before being defined"); - else - { - if (iff->type == exception_iface) - iff->type = class_iface; - - cd = findClassWithInterface(pt, iff); - } - - /* Create a new one. */ - xd = sipMalloc(sizeof (exceptionDef)); - - xd->exceptionnr = -1; - xd->iff = iff; - xd->pyname = NULL; - xd->cd = cd; - xd->bibase = NULL; - xd->base = NULL; - xd->hdrcode = NULL; - xd->raisecode = NULL; - xd->next = NULL; - - /* Append it to the list. */ - for (tail = &pt->exceptions; *tail != NULL; tail = &(*tail)->next) - ; - - *tail = xd; - - return xd; -} - - -/* - * Find an undefined (or create a new) class definition in a parse tree. - */ -static classDef *newClass(sipSpec *pt,ifaceFileType iftype, - scopedNameDef *fqname) -{ - int flags; - classDef *cd, *scope; - codeBlock *hdrcode; - - if (sectionFlags & SECT_IS_PRIVATE) - yyerror("Classes, structs and namespaces must be in the public or or protected sections"); - - flags = 0; - - if ((scope = currentScope()) != NULL) - { - if (sectionFlags & SECT_IS_PROT) - flags = CLASS_IS_PROTECTED; - - hdrcode = scope -> hdrcode; - } - else - hdrcode = NULL; - - if (pt -> genc) - { - /* C structs are always global types. */ - while (fqname -> next != NULL) - fqname = fqname -> next; - - scope = NULL; - } - - cd = findClass(pt,iftype,fqname); - - /* Check it hasn't already been defined. */ - if (iftype != namespace_iface && cd->iff->module != NULL) - yyerror("The struct/class has already been defined"); - - /* Complete the initialisation. */ - cd->classflags |= flags; - cd->ecd = scope; - cd->iff->module = currentModule; - - appendCodeBlock(&cd->hdrcode, hdrcode); - - /* See if it is a namespace extender. */ - if (iftype == namespace_iface) - { - classDef *ns; - - for (ns = pt->classes; ns != NULL; ns = ns->next) - { - if (ns == cd) - continue; - - if (ns->iff->type != namespace_iface) - continue; - - if (!sameScopedName(ns->iff->fqcname, fqname)) - continue; - - cd->real = ns; - break; - } - } - - return cd; -} - - -/* - * Tidy up after finishing a class definition. - */ -static void finishClass(sipSpec *pt, moduleDef *mod, classDef *cd, optFlags *of) -{ - char *pyname; - optFlag *flg; - - /* Get the Python name and see if it is different to the C++ name. */ - pyname = getPythonName(of, classBaseName(cd)); - - cd -> pyname = NULL; - checkAttributes(pt, cd->ecd, pyname, FALSE); - cd->pyname = pyname; - - if (cd->pyname != classBaseName(cd)) - setIsRenamedClass(cd); - - if ((flg = findOptFlag(of, "TypeFlags", integer_flag)) != NULL) - cd->userflags = flg->fvalue.ival; - - if (isOpaque(cd)) - { - if (findOptFlag(of, "External", bool_flag) != NULL) - setIsExternal(cd); - } - else - { - int seq_might, seq_not; - memberDef *md; - - if (findOptFlag(of, "NoDefaultCtors", bool_flag) != NULL) - setNoDefaultCtors(cd); - - if (cd -> ctors == NULL) - { - if (!noDefaultCtors(cd)) - { - /* Provide a default ctor. */ - - cd->ctors = sipMalloc(sizeof (ctorDef)); - - cd->ctors->ctorflags = SECT_IS_PUBLIC; - cd->ctors->pysig.nrArgs = 0; - cd->ctors->cppsig = &cd -> ctors -> pysig; - cd->ctors->exceptions = NULL; - cd->ctors->methodcode = NULL; - cd->ctors->prehook = NULL; - cd->ctors->posthook = NULL; - cd->ctors->next = NULL; - - cd->defctor = cd->ctors; - - setCanCreate(cd); - } - } - else if (cd -> defctor == NULL) - { - ctorDef *ct, *last = NULL; - - for (ct = cd -> ctors; ct != NULL; ct = ct -> next) - { - if (!isPublicCtor(ct)) - continue; - - if (ct -> pysig.nrArgs == 0 || ct -> pysig.args[0].defval != NULL) - { - cd -> defctor = ct; - break; - } - - if (last == NULL) - last = ct; - } - - /* The last resort is the first public ctor. */ - if (cd->defctor == NULL) - cd->defctor = last; - } - - if (findOptFlag(of,"Abstract",bool_flag) != NULL) - { - setIsAbstractClass(cd); - setIsIncomplete(cd); - resetCanCreate(cd); - } - - /* We assume a public dtor if nothing specific was provided. */ - if (!isDtor(cd)) - setIsPublicDtor(cd); - - if (findOptFlag(of, "DelayDtor", bool_flag) != NULL) - { - setIsDelayedDtor(cd); - setHasDelayedDtors(mod); - } - - /* - * There are subtle differences between the add and concat methods and - * the multiply and repeat methods. The number versions can have their - * operands swapped and may return NotImplemented. If the user has - * used the /Numeric/ annotation or there are other numeric operators - * then we use add/multiply. Otherwise, if there are indexing - * operators then we use concat/repeat. - */ - seq_might = seq_not = FALSE; - - for (md = cd -> members; md != NULL; md = md -> next) - switch (md -> slot) - { - case getitem_slot: - case setitem_slot: - case delitem_slot: - /* This might be a sequence. */ - seq_might = TRUE; - break; - - case sub_slot: - case isub_slot: - case div_slot: - case idiv_slot: - case mod_slot: - case imod_slot: - case pos_slot: - case neg_slot: - /* This is definately not a sequence. */ - seq_not = TRUE; - break; - } - - if (!seq_not && seq_might) - for (md = cd -> members; md != NULL; md = md -> next) - { - /* Ignore if the user has been explicit. */ - if (isNumeric(md)) - continue; - - switch (md -> slot) - { - case add_slot: - md -> slot = concat_slot; - break; - - case iadd_slot: - md -> slot = iconcat_slot; - break; - - case mul_slot: - md -> slot = repeat_slot; - break; - - case imul_slot: - md -> slot = irepeat_slot; - break; - } - } - } - - if (inMainModule()) - { - setIsUsedName(cd->iff->name); - setIsClassName(cd->iff->name); - } -} - - -/* - * Create a new mapped type. - */ -static mappedTypeDef *newMappedType(sipSpec *pt,argDef *ad) -{ - mappedTypeDef *mtd; - scopedNameDef *snd; - ifaceFileDef *iff; - - /* Check that the type is one we want to map. */ - switch (ad -> atype) - { - case defined_type: - snd = ad -> u.snd; - break; - - case template_type: - snd = ad -> u.td -> fqname; - break; - - case struct_type: - snd = ad -> u.sname; - break; - - default: - yyerror("Invalid type for %MappedType"); - } - - iff = findIfaceFile(pt, currentModule, snd, mappedtype_iface, ad); - - if (inMainModule()) - setIsUsedName(iff -> name); - - /* Check it hasn't already been defined. */ - for (mtd = pt -> mappedtypes; mtd != NULL; mtd = mtd -> next) - if (mtd -> iff == iff) - { - /* - * We allow types based on the same template but with - * different arguments. - */ - - if (ad -> atype != template_type || - sameBaseType(ad,&mtd -> type)) - yyerror("Mapped type has already been defined in this module"); - } - - /* The module may not have been set yet. */ - iff -> module = currentModule; - - /* Create a new mapped type. */ - mtd = allocMappedType(ad); - - mtd -> iff = iff; - mtd -> next = pt -> mappedtypes; - - pt -> mappedtypes = mtd; - - return mtd; -} - - -/* - * Allocate, intialise and return a mapped type structure. - */ -mappedTypeDef *allocMappedType(argDef *type) -{ - mappedTypeDef *mtd; - - mtd = sipMalloc(sizeof (mappedTypeDef)); - - mtd->type = *type; - mtd->type.argflags = 0; - mtd->type.nrderefs = 0; - - mtd->mappednr = -1; - mtd->iff = NULL; - mtd->hdrcode = NULL; - mtd->convfromcode = NULL; - mtd->convtocode = NULL; - mtd->next = NULL; - - return mtd; -} - - -/* - * Create a new enum. - */ -static enumDef *newEnum(sipSpec *pt,moduleDef *mod,char *name,optFlags *of, - int flags) -{ - enumDef *ed; - classDef *escope = currentScope(); - - ed = sipMalloc(sizeof (enumDef)); - - if (name != NULL) - { - ed -> fqcname = text2scopedName(name); - ed -> pyname = cacheName(pt, getPythonName(of, name)); - - checkAttributes(pt, escope, ed->pyname->text, FALSE); - } - else - { - ed -> fqcname = NULL; - ed -> pyname = NULL; - } - - ed -> enumflags = flags; - ed -> enumnr = -1; - ed -> ecd = escope; - ed -> pcd = (flags & SECT_IS_PROT) ? escope : NULL; - ed -> module = mod; - ed -> members = NULL; - ed -> slots = NULL; - ed -> overs = NULL; - ed -> next = pt -> enums; - - if (name != NULL && strcmp(ed->pyname->text, name) != 0) - setIsRenamedEnum(ed); - - pt -> enums = ed; - - if (escope != NULL) - setHasEnums(escope); - - return ed; -} - - -/* - * Get the type values and (optionally) the type names for substitution in - * handwritten code. - */ -void appendTypeStrings(scopedNameDef *ename, signatureDef *patt, signatureDef *src, signatureDef *known, scopedNameDef **names, scopedNameDef **values) -{ - int a; - - for (a = 0; a < patt->nrArgs; ++a) - { - argDef *pad = &patt->args[a]; - - if (pad->atype == defined_type) - { - char *nam = NULL; - - /* - * If the type names are already known then check that - * this is one of them. - */ - if (known == NULL) - nam = scopedNameTail(pad->u.snd); - else if (pad->u.snd->next == NULL) - { - int k; - - for (k = 0; k < known->nrArgs; ++k) - if (strcmp(pad->u.snd->name, known->args[k].u.snd->name) == 0) - { - nam = pad->u.snd->name; - break; - } - } - - if (nam == NULL) - continue; - - /* Add the name. */ - appendScopedName(names, text2scopePart(nam)); - - /* Add the corresponding value. */ - appendScopedName(values, text2scopePart(getType(ename, &src->args[a]))); - } - else if (pad->atype == template_type) - { - argDef *sad = &src->args[a]; - - /* These checks shouldn't be necessary, but... */ - if (sad->atype == template_type && pad->u.td->types.nrArgs == sad->u.td->types.nrArgs) - appendTypeStrings(ename, &pad->u.td->types, &sad->u.td->types, known, names, values); - } - } -} - - -/* - * Convert a type to a string. We impose some limitations because I'm too lazy - * to handle everything that might be needed one day. - */ -static char *getType(scopedNameDef *ename, argDef *ad) -{ - if (ad->atype == defined_type) - return scopedNameToString(ad->u.snd); - - fatalScopedName(ename); - fatal(": unsupported type argument to template class instantiation\n"); - - return NULL; -} - - -/* - * Convert a scoped name to a string on the heap. - */ -static char *scopedNameToString(scopedNameDef *name) -{ - static const char scope_string[] = "::"; - size_t len; - scopedNameDef *snd; - char *s, *dp; - - /* Work out the length of buffer needed. */ - len = 0; - - for (snd = name; snd != NULL; snd = snd->next) - { - len += strlen(snd->name); - - if (snd->next != NULL) - len += strlen(scope_string); - } - - /* Allocate and populate the buffer. */ - dp = s = sipMalloc(len + 1); - - for (snd = name; snd != NULL; snd = snd->next) - { - strcpy(dp, snd->name); - dp += strlen(snd->name); - - if (snd->next != NULL) - { - strcpy(dp, scope_string); - dp += strlen(scope_string); - } - } - - return s; -} - - -/* - * Instantiate a class template. - */ -static void instantiateClassTemplate(sipSpec *pt, moduleDef *mod, classDef *scope, scopedNameDef *fqname, classTmplDef *tcd, templateDef *td) -{ - scopedNameDef *type_names, *type_values; - classDef *cd; - ctorDef *oct, **cttail; - memberDef *omd, **mdtail; - overDef *ood, **odtail; - argDef *ad; - ifaceFileList *iffl, **used; - - type_names = type_values = NULL; - appendTypeStrings(classFQCName(tcd->cd), &tcd->sig, &td->types, NULL, &type_names, &type_values); - - /* - * Add a mapping from the template name to the instantiated name. If - * we have got this far we know there is room for it. - */ - ad = &tcd->sig.args[tcd->sig.nrArgs++]; - ad->atype = defined_type; - ad->name = NULL; - ad->argflags = 0; - ad->nrderefs = 0; - ad->defval = NULL; - ad->u.snd = classFQCName(tcd->cd); - - appendScopedName(&type_names, text2scopePart(scopedNameTail(classFQCName(tcd->cd)))); - appendScopedName(&type_values, text2scopePart(scopedNameToString(fqname))); - - /* Create the new class. */ - cd = sipMalloc(sizeof (classDef)); - - /* Start with a shallow copy. */ - *cd = *tcd->cd; - - cd->pyname = scopedNameTail(fqname); - cd->td = td; - - /* Handle the interface file. */ - cd->iff = findIfaceFile(pt, mod, fqname, class_iface, NULL); - cd->iff->module = mod; - - /* Make a copy of the used list and add the enclosing scope. */ - used = &cd->iff->used; - - for (iffl = tcd->cd->iff->used; iffl != NULL; iffl = iffl->next) - addToUsedList(used, iffl->iff); - - if (scope != NULL) - addToUsedList(&cd->iff->used, scope->iff); - - if (inMainModule()) - { - setIsUsedName(cd->iff->name); - setIsClassName(cd->iff->name); - } - - cd->ecd = currentScope(); - - /* Handle the ctors. */ - cd->ctors = NULL; - cttail = &cd->ctors; - - for (oct = tcd->cd->ctors; oct != NULL; oct = oct->next) - { - ctorDef *nct = sipMalloc(sizeof (ctorDef)); - - /* Start with a shallow copy. */ - *nct = *oct; - - templateSignature(&nct->pysig, FALSE, tcd, td, cd); - - if (oct->cppsig == NULL) - nct->cppsig = NULL; - else if (oct->cppsig == &oct->pysig) - nct->cppsig = &nct->pysig; - else - { - nct->cppsig = sipMalloc(sizeof (signatureDef)); - - *nct->cppsig = *oct->cppsig; - - templateSignature(nct->cppsig, FALSE, tcd, td, cd); - } - - nct->methodcode = templateCode(pt, used, nct->methodcode, type_names, type_values); - - nct->next = NULL; - *cttail = nct; - cttail = &nct->next; - - /* Handle the default ctor. */ - if (tcd->cd->defctor == oct) - cd->defctor = nct; - } - - cd->dealloccode = templateCode(pt, used, cd->dealloccode, type_names, type_values); - cd->dtorcode = templateCode(pt, used, cd->dtorcode, type_names, type_values); - - /* Handle the members, ie. the common parts of overloads. */ - cd->members = NULL; - mdtail = &cd->members; - - for (omd = tcd->cd->members; omd != NULL; omd = omd->next) - { - memberDef *nmd = sipMalloc(sizeof (memberDef)); - - /* Start with a shallow copy. */ - *nmd = *omd; - - nmd->module = mod; - - nmd->next = NULL; - *mdtail = nmd; - mdtail = &nmd->next; - } - - /* Handle the overloads. */ - cd->overs = NULL; - odtail = &cd->overs; - - for (ood = tcd->cd->overs; ood != NULL; ood = ood->next) - { - overDef *nod = sipMalloc(sizeof (overDef)); - memberDef *nmd; - - /* Start with a shallow copy. */ - *nod = *ood; - - for (nmd = cd->members, omd = tcd->cd->members; omd != NULL; omd = omd->next, nmd = nmd->next) - if (omd == ood->common) - { - nod->common = nmd; - break; - } - - templateSignature(&nod->pysig, TRUE, tcd, td, cd); - - if (ood->cppsig == &ood->pysig) - nod->cppsig = &nod->pysig; - else - { - nod->cppsig = sipMalloc(sizeof (signatureDef)); - - *nod->cppsig = *ood->cppsig; - - templateSignature(nod->cppsig, TRUE, tcd, td, cd); - } - - nod->methodcode = templateCode(pt, used, nod->methodcode, type_names, type_values); - - /* Handle any virtual handler. */ - if (ood->virthandler != NULL) - { - nod->virthandler = sipMalloc(sizeof (virtHandlerDef)); - - /* Start with a shallow copy. */ - *nod->virthandler = *ood->virthandler; - - if (ood->virthandler->cppsig == &ood->pysig) - nod->virthandler->cppsig = &nod->pysig; - else - { - nod->virthandler->cppsig = sipMalloc(sizeof (signatureDef)); - - *nod->virthandler->cppsig = *ood->virthandler->cppsig; - - templateSignature(nod->virthandler->cppsig, TRUE, tcd, td, cd); - } - - nod->virthandler->module = mod; - nod->virthandler->virtcode = templateCode(pt, used, nod->virthandler->virtcode, type_names, type_values); - nod->virthandler->next = mod->virthandlers; - - mod->virthandlers = nod->virthandler; - } - - nod->next = NULL; - *odtail = nod; - odtail = &nod->next; - } - - cd->cppcode = templateCode(pt, used, cd->cppcode, type_names, type_values); - cd->hdrcode = templateCode(pt, used, cd->hdrcode, type_names, type_values); - cd->convtosubcode = templateCode(pt, used, cd->convtosubcode, type_names, type_values); - cd->convtocode = templateCode(pt, used, cd->convtocode, type_names, type_values); - cd->travcode = templateCode(pt, used, cd->travcode, type_names, type_values); - cd->clearcode = templateCode(pt, used, cd->clearcode, type_names, type_values); - cd->readbufcode = templateCode(pt, used, cd->readbufcode, type_names, type_values); - cd->writebufcode = templateCode(pt, used, cd->writebufcode, type_names, type_values); - cd->segcountcode = templateCode(pt, used, cd->segcountcode, type_names, type_values); - cd->charbufcode = templateCode(pt, used, cd->charbufcode, type_names, type_values); - cd->next = pt->classes; - - pt->classes = cd; - - tcd->sig.nrArgs--; - - freeScopedName(type_names); - freeScopedName(type_values); -} - - -/* - * Replace any template arguments in a signature. - */ -static void templateSignature(signatureDef *sd, int result, classTmplDef *tcd, templateDef *td, classDef *ncd) -{ - int a; - - if (result) - templateType(&sd->result, tcd, td, ncd); - - for (a = 0; a < sd->nrArgs; ++a) - templateType(&sd->args[a], tcd, td, ncd); -} - - -/* - * Replace any template arguments in a type. - */ -static void templateType(argDef *ad, classTmplDef *tcd, templateDef *td, classDef *ncd) -{ - int a; - char *name; - - /* Ignore if it isn't an unscoped name. */ - if (ad->atype != defined_type || ad->u.snd->next != NULL) - return; - - name = ad->u.snd->name; - - for (a = 0; a < tcd->sig.nrArgs - 1; ++a) - if (strcmp(name, scopedNameTail(tcd->sig.args[a].u.snd)) == 0) - { - ad->atype = td->types.args[a].atype; - - /* We take the constrained flag from the real type. */ - resetIsConstrained(ad); - - if (isConstrained(&td->types.args[a])) - setIsConstrained(ad); - - ad->u = td->types.args[a].u; - - return; - } - - /* Handle the class name itself. */ - if (strcmp(name, scopedNameTail(classFQCName(tcd->cd))) == 0) - { - ad->atype = class_type; - ad->u.cd = ncd; - } -} - - -/* - * Replace any template arguments in a literal code block. - */ -codeBlock *templateCode(sipSpec *pt, ifaceFileList **used, codeBlock *ocb, scopedNameDef *names, scopedNameDef *values) -{ - codeBlock *ncb = NULL, **tail = &ncb; - - while (ocb != NULL) - { - char *at = ocb->frag; - - do - { - char *first = NULL; - codeBlock *cb; - scopedNameDef *nam, *val, *nam_first, *val_first; - - /* - * Go through the rest of this fragment looking for - * each of the types and the name of the class itself. - */ - nam = names; - val = values; - - while (nam != NULL && val != NULL) - { - char *cp; - - if ((cp = strstr(at, nam->name)) != NULL) - if (first == NULL || first > cp) - { - nam_first = nam; - val_first = val; - first = cp; - } - - nam = nam->next; - val = val->next; - } - - /* Create the new fragment. */ - cb = sipMalloc(sizeof (codeBlock)); - - if (at == ocb->frag) - { - cb->filename = ocb->filename; - cb->linenr = ocb->linenr; - } - else - cb->filename = NULL; - - cb->next = NULL; - *tail = cb; - tail = &cb->next; - - /* See if anything was found. */ - if (first == NULL) - { - /* We can just point to this. */ - cb->frag = at; - - /* All done with this one. */ - at = NULL; - } - else - { - static char *gen_names[] = { - "sipForceConvertToTransfer_", - "sipForceConvertTo_", - "sipConvertFromTransfer_", - "sipConvertFrom_", - "sipClass_", - "sipEnum_", - "sipException_", - NULL - }; - - char *dp, *sp, **gn; - int genname = FALSE; - - /* - * If the context in which the text is used is - * in the name of a SIP generated object then - * translate any "::" scoping to "_". - */ - for (gn = gen_names; *gn != NULL; ++gn) - if (search_back(first, at, *gn)) - { - addUsedFromCode(pt, used, val_first->name); - genname = TRUE; - break; - } - - /* Fragment the fragment. */ - cb->frag = sipMalloc(first - at + strlen(val_first->name) + 1); - - strncpy(cb->frag, at, first - at); - - dp = &cb->frag[first - at]; - sp = val_first->name; - - if (genname) - { - char gch; - - while ((gch = *sp++) != '\0') - if (gch == ':' && *sp == ':') - { - *dp++ = '_'; - ++sp; - } - else - *dp++ = gch; - - *dp = '\0'; - } - else - strcpy(dp, sp); - - /* Move past the replaced text. */ - at = first + strlen(nam_first->name); - } - } - while (at != NULL && *at != '\0'); - - ocb = ocb->next; - } - - return ncb; -} - - -/* - * Return TRUE if the text at the end of a string matches the target string. - */ -static int search_back(const char *end, const char *start, const char *target) -{ - size_t tlen = strlen(target); - - if (start + tlen >= end) - return FALSE; - - return (strncmp(end - tlen, target, tlen) == 0); -} - - -/* - * Add any needed interface files based on handwritten code. - */ -static void addUsedFromCode(sipSpec *pt, ifaceFileList **used, const char *sname) -{ - ifaceFileDef *iff; - enumDef *ed; - - for (iff = pt->ifacefiles; iff != NULL; iff = iff->next) - { - if (iff->type != class_iface && iff->type != exception_iface) - continue; - - if (sameName(iff->fqcname, sname)) - { - addToUsedList(used, iff); - - return; - } - } - - for (ed = pt->enums; ed != NULL; ed = ed->next) - { - if (ed->ecd == NULL) - continue; - - if (sameName(ed->fqcname, sname)) - { - addToUsedList(used, ed->ecd->iff); - - return; - } - } -} - - -/* - * Compare a scoped name with its string equivalent. - */ -static int sameName(scopedNameDef *snd, const char *sname) -{ - while (snd != NULL && *sname != '\0') - { - const char *sp = snd->name; - - while (*sp != '\0' && *sname != ':' && *sname != '\0') - if (*sp++ != *sname++) - return FALSE; - - if (*sp != '\0' || (*sname != ':' && *sname != '\0')) - return FALSE; - - snd = snd->next; - - if (*sname == ':') - sname += 2; - } - - return (snd == NULL && *sname == '\0'); -} - - -/* - * Create a new typedef. - */ -static void newTypedef(sipSpec *pt,moduleDef *mod,char *name,argDef *type) -{ - typedefDef *td; - scopedNameDef *fqname = text2scopedName(name); - classDef *scope = currentScope(); - - /* See if we are instantiating a template class. */ - if (type->atype == template_type) - { - classTmplDef *tcd; - templateDef *td = type->u.td; - - for (tcd = pt->classtemplates; tcd != NULL; tcd = tcd->next) - if (sameScopedName(tcd->cd->iff->fqcname, td->fqname)) - { - if (!sameTemplateSignature(&tcd->sig, &td->types, FALSE)) - continue; - - instantiateClassTemplate(pt, mod, scope, fqname, tcd, td); - - /* All done. */ - return; - } - } - - /* Check it doesn't already exist. */ - for (td = pt -> typedefs; td != NULL; td = td -> next) - if (sameScopedName(td -> fqname,fqname)) - { - fatalScopedName(fqname); - fatal(" already defined\n"); - } - - td = sipMalloc(sizeof (typedefDef)); - - td -> fqname = fqname; - td -> ecd = scope; - td -> module = mod; - td -> type = *type; - td -> next = pt -> typedefs; - - mod -> nrtypedefs++; - - pt -> typedefs = td; -} - - -/* - * Return TRUE if the template signatures are the same. A deep comparison is - * used for mapped type templates where we want to recurse into any nested - * templates. - */ -int sameTemplateSignature(signatureDef *sd1, signatureDef *sd2, int deep) -{ - int a; - - if (sd1->nrArgs != sd2->nrArgs) - return FALSE; - - for (a = 0; a < sd1->nrArgs; ++a) - { - argDef *ad1 = &sd1->args[a]; - argDef *ad2 = &sd2->args[a]; - - /* - * If we are doing a shallow comparision (ie. for class - * templates) then a type name on the left hand side matches - * anything on the right hand side. - */ - if (ad1->atype == defined_type && !deep) - continue; - - /* - * For type names only compare the references and pointers, and - * do the same for any nested templates. - */ - if (ad1->atype == defined_type && ad2->atype == defined_type) - { - if (isReference(ad1) != isReference(ad2) || ad1->nrderefs != ad2->nrderefs) - return FALSE; - } - else if (ad1->atype == template_type && ad2->atype == template_type) - { - if (!sameTemplateSignature(&ad1->u.td->types, &ad2->u.td->types, deep)) - return FALSE; - } - else if (!sameBaseType(ad1, ad2)) - return FALSE; - } - - return TRUE; -} - - -/* - * Create a new variable. - */ -static void newVar(sipSpec *pt,moduleDef *mod,char *name,int isstatic, - argDef *type,optFlags *of,codeBlock *acode,codeBlock *gcode, - codeBlock *scode) -{ - varDef *var; - classDef *escope = currentScope(); - nameDef *nd = cacheName(pt,getPythonName(of,name)); - - if (inMainModule()) - setIsUsedName(nd); - - checkAttributes(pt,escope,nd -> text,FALSE); - - var = sipMalloc(sizeof (varDef)); - - var -> pyname = nd; - var -> fqcname = text2scopedName(name); - var -> ecd = escope; - var -> module = mod; - var -> varflags = 0; - var -> type = *type; - var -> accessfunc = acode; - var -> getcode = gcode; - var -> setcode = scode; - var -> next = pt -> vars; - - if (isstatic || (escope != NULL && escope->iff->type == namespace_iface)) - setIsStaticVar(var); - - pt -> vars = var; -} - - -/* - * Create a new ctor. - */ -static void newCtor(char *name,int sectFlags,signatureDef *args, - optFlags *optflgs,codeBlock *methodcode, - throwArgs *exceptions,signatureDef *cppsig,int explicit) -{ - ctorDef *ct, **ctp; - classDef *cd = currentScope(); - - /* Check the name of the constructor. */ - if (strcmp(classBaseName(cd),name) != 0) - yyerror("Constructor doesn't have the same name as its class"); - - /* Add to the list of constructors. */ - ct = sipMalloc(sizeof (ctorDef)); - - ct -> ctorflags = sectFlags; - ct -> pysig = *args; - ct -> cppsig = (cppsig != NULL ? cppsig : &ct -> pysig); - ct -> exceptions = exceptions; - ct -> methodcode = methodcode; - ct -> next = NULL; - - if (!isPrivateCtor(ct)) - setCanCreate(cd); - - if (isProtectedCtor(ct)) - setHasShadow(cd); - - if (explicit) - setIsExplicitCtor(ct); - - getHooks(optflgs,&ct -> prehook,&ct -> posthook); - - if (getReleaseGIL(optflgs)) - setIsReleaseGILCtor(ct); - else if (getHoldGIL(optflgs)) - setIsHoldGILCtor(ct); - - if (findOptFlag(optflgs,"NoDerived",bool_flag) != NULL) - { - if (cppsig != NULL) - yyerror("The /NoDerived/ annotation cannot be used with a C++ signature"); - - if (methodcode == NULL) - yyerror("The /NoDerived/ annotation must be used with %MethodCode"); - - ct->cppsig = NULL; - } - - if (findOptFlag(optflgs,"Default",bool_flag) != NULL) - { - if (cd -> defctor != NULL) - yyerror("A constructor with the /Default/ annotation has already been defined"); - - cd -> defctor = ct; - } - - /* Append to the list. */ - for (ctp = &cd->ctors; *ctp != NULL; ctp = &(*ctp)->next) - ; - - *ctp = ct; -} - - -/* - * Create a new function. - */ -static void newFunction(sipSpec *pt,moduleDef *mod,int sflags,int isstatic, - int isvirt,char *name,signatureDef *sig,int isconst, - int isabstract,optFlags *optflgs,codeBlock *methodcode, - codeBlock *vcode,throwArgs *exceptions, - signatureDef *cppsig) -{ - classDef *cd = currentScope(); - nameDef *pname; - int factory, xferback; - overDef *od, **odp, **headp; - optFlag *of; - virtHandlerDef *vhd; - - /* Extra checks for a C module. */ - if (pt -> genc) - { - if (cd != NULL) - yyerror("Function declaration not allowed in a struct in a C module"); - - if (isstatic) - yyerror("Static functions not allowed in a C module"); - - if (exceptions != NULL) - yyerror("Exceptions not allowed in a C module"); - } - - headp = (cd != NULL ? &cd -> overs : &pt -> overs); - - /* See if it is a factory method. */ - if (findOptFlag(optflgs,"Factory",bool_flag) != NULL) - factory = TRUE; - else - { - int a; - - factory = FALSE; - - /* Check /TransferThis/ wasn't specified. */ - if (cd == NULL || isstatic) - for (a = 0; a < sig -> nrArgs; ++a) - if (isThisTransferred(&sig -> args[a])) - yyerror("/TransferThis/ may only be specified in constructors and class methods"); - } - - /* See if the result is to be returned to Python ownership. */ - xferback = (findOptFlag(optflgs,"TransferBack",bool_flag) != NULL); - - if (factory && xferback) - yyerror("/TransferBack/ and /Factory/ cannot both be specified"); - - /* Use the C++ name if a Python name wasn't given. */ - pname = cacheName(pt, getPythonName(optflgs, name)); - - /* Create a new overload definition. */ - - od = sipMalloc(sizeof (overDef)); - - /* Set the overload flags. */ - - od -> overflags = sflags; - - if (factory) - setIsFactory(od); - - if (xferback) - setIsResultTransferredBack(od); - - if (isProtected(od)) - setHasShadow(cd); - - if ((isSlot(od) || isSignal(od)) && !isPrivate(od)) - { - if (isSignal(od)) - setHasShadow(cd); - - pt -> sigslots = TRUE; - } - - if (isSignal(od) && (methodcode != NULL || vcode != NULL)) - yyerror("Cannot provide code for signals"); - - if (isstatic) - { - if (isSignal(od)) - yyerror("Static functions cannot be signals"); - - if (isvirt) - yyerror("Static functions cannot be virtual"); - - setIsStatic(od); - } - - if (isconst) - setIsConst(od); - - if (isabstract) - { - if (sflags == 0) - yyerror("Non-class function specified as abstract"); - - setIsAbstract(od); - } - - if ((of = findOptFlag(optflgs,"AutoGen",opt_name_flag)) != NULL) - { - setIsAutoGen(od); - - if (of -> fvalue.sval != NULL) - { - qualDef *qd; - - if ((qd = findQualifier(of -> fvalue.sval)) == NULL || qd -> qtype != feature_qualifier) - yyerror("No such feature"); - - if (excludedFeature(excludedQualifiers,qd)) - resetIsAutoGen(od); - } - } - - if (isvirt) - { - if (isSignal(od) && !optNoEmitters(pt)) - yyerror("Virtual signals aren't supported"); - - setIsVirtual(od); - setHasShadow(cd); - - vhd = sipMalloc(sizeof (virtHandlerDef)); - - vhd -> virthandlernr = -1; - vhd -> vhflags = 0; - vhd -> pysig = &od -> pysig; - vhd -> cppsig = (cppsig != NULL ? cppsig : &od -> pysig); - vhd -> module = currentModule; - vhd -> virtcode = vcode; - vhd -> next = currentModule -> virthandlers; - - if (factory || xferback) - setIsTransferVH(vhd); - - currentModule -> virthandlers = vhd; - } - else - { - if (vcode != NULL) - yyerror("%VirtualCatcherCode provided for non-virtual function"); - - vhd = NULL; - } - - od -> cppname = name; - od -> pysig = *sig; - od -> cppsig = (cppsig != NULL ? cppsig : &od -> pysig); - od -> exceptions = exceptions; - od -> methodcode = methodcode; - od -> virthandler = vhd; - od -> common = findFunction(pt,mod,cd,pname,(methodcode != NULL),sig -> nrArgs); - - if (findOptFlag(optflgs,"Numeric",bool_flag) != NULL) - setIsNumeric(od -> common); - - /* Methods that run in new threads must be virtual. */ - if (findOptFlag(optflgs,"NewThread",bool_flag) != NULL) - { - argDef *res; - - if (!isvirt) - yyerror("/NewThread/ may only be specified for virtual functions"); - - /* - * This is an arbitary limitation to make the code generator - * slightly easier - laziness on my part. - */ - res = &od -> cppsig -> result; - - if (res -> atype != void_type || res -> nrderefs != 0) - yyerror("/NewThread/ may only be specified for void functions"); - - setIsNewThread(od); - } - - getHooks(optflgs,&od -> prehook,&od -> posthook); - - if (getReleaseGIL(optflgs)) - setIsReleaseGIL(od); - else if (getHoldGIL(optflgs)) - setIsHoldGIL(od); - - od -> next = NULL; - - /* Append to the list. */ - for (odp = headp; *odp != NULL; odp = &(*odp)->next) - ; - - *odp = od; -} - - -/* - * Return the Python name based on the C/C++ name and any /PyName/ annotation. - */ -static char *getPythonName(optFlags *optflgs, char *cname) -{ - char *pname; - optFlag *of; - - if ((of = findOptFlag(optflgs, "PyName", name_flag)) != NULL) - pname = of -> fvalue.sval; - else - pname = cname; - - return pname; -} - - -/* - * Cache a name in a module. - */ -static nameDef *cacheName(sipSpec *pt,char *name) -{ - nameDef *nd; - - /* See if it already exists. */ - for (nd = pt -> namecache; nd != NULL; nd = nd -> next) - if (strcmp(nd -> text,name) == 0) - return nd; - - /* Create a new one. */ - nd = sipMalloc(sizeof (nameDef)); - - nd -> nameflags = 0; - nd -> module = currentSpec -> module; - nd -> text = name; - nd -> next = pt -> namecache; - - pt -> namecache = nd; - - return nd; -} - - -/* - * Find (or create) an overloaded function name. - */ -static memberDef *findFunction(sipSpec *pt,moduleDef *mod,classDef *cd, - nameDef *pname,int hwcode,int nrargs) -{ - static struct slot_map { - char *name; /* The slot name. */ - slotType type; /* The corresponding type. */ - int needs_hwcode; /* If handwritten code is required. */ - int nrargs; /* Nr. of arguments. */ - } slot_table[] = { - {"__str__", str_slot, TRUE, 0}, - {"__unicode__", unicode_slot, TRUE, 0}, - {"__int__", int_slot, FALSE, 0}, - {"__long__", long_slot, FALSE, 0}, - {"__float__", float_slot, FALSE, 0}, - {"__len__", len_slot, TRUE, 0}, - {"__contains__", contains_slot, TRUE, 1}, - {"__add__", add_slot, FALSE, 1}, - {"__sub__", sub_slot, FALSE, 1}, - {"__mul__", mul_slot, FALSE, 1}, - {"__div__", div_slot, FALSE, 1}, - {"__mod__", mod_slot, FALSE, 1}, - {"__and__", and_slot, FALSE, 1}, - {"__or__", or_slot, FALSE, 1}, - {"__xor__", xor_slot, FALSE, 1}, - {"__lshift__", lshift_slot, FALSE, 1}, - {"__rshift__", rshift_slot, FALSE, 1}, - {"__iadd__", iadd_slot, FALSE, 1}, - {"__isub__", isub_slot, FALSE, 1}, - {"__imul__", imul_slot, FALSE, 1}, - {"__idiv__", idiv_slot, FALSE, 1}, - {"__imod__", imod_slot, FALSE, 1}, - {"__iand__", iand_slot, FALSE, 1}, - {"__ior__", ior_slot, FALSE, 1}, - {"__ixor__", ixor_slot, FALSE, 1}, - {"__ilshift__", ilshift_slot, FALSE, 1}, - {"__irshift__", irshift_slot, FALSE, 1}, - {"__invert__", invert_slot, FALSE, 0}, - {"__call__", call_slot, FALSE, -1}, - {"__getitem__", getitem_slot, FALSE, -1}, - {"__setitem__", setitem_slot, TRUE, -1}, - {"__delitem__", delitem_slot, TRUE, -1}, - {"__lt__", lt_slot, FALSE, 1}, - {"__le__", le_slot, FALSE, 1}, - {"__eq__", eq_slot, FALSE, 1}, - {"__ne__", ne_slot, FALSE, 1}, - {"__gt__", gt_slot, FALSE, 1}, - {"__ge__", ge_slot, FALSE, 1}, - {"__cmp__", cmp_slot, FALSE, 1}, - {"__nonzero__", nonzero_slot, TRUE, 0}, - {"__neg__", neg_slot, FALSE, 0}, - {"__pos__", pos_slot, FALSE, 0}, - {"__abs__", abs_slot, TRUE, 0}, - {"__repr__", repr_slot, TRUE, 0}, - {"__hash__", hash_slot, TRUE, 0}, - {NULL} - }; - - memberDef *md, **flist; - struct slot_map *sm; - slotType st; - - /* Get the slot type. */ - st = no_slot; - - for (sm = slot_table; sm -> name != NULL; ++sm) - if (strcmp(sm -> name,pname -> text) == 0) - { - if (sm -> needs_hwcode && !hwcode) - yyerror("This Python slot requires %MethodCode"); - - if (sm -> nrargs < 0) - { - int min_nr; - - /* These require a minimum number. */ - switch (sm -> type) - { - case getitem_slot: - case delitem_slot: - min_nr = 1; - break; - - case setitem_slot: - min_nr = 2; - break; - - default: - min_nr = 0; - } - - if (nrargs < min_nr) - yyerror("Insufficient number of arguments to Python slot"); - } - else if (cd == NULL) - { - /* Global operators need one extra argument. */ - if (sm -> nrargs + 1 != nrargs) - yyerror("Incorrect number of arguments to global operator"); - } - else if (sm -> nrargs != nrargs) - yyerror("Incorrect number of arguments to Python slot"); - - st = sm -> type; - - break; - } - - if (inMainModule()) - setIsUsedName(pname); - - /* Check there is no name clash. */ - checkAttributes(pt,cd,pname -> text,TRUE); - - /* See if it already exists. */ - flist = (cd != NULL ? &cd -> members : &pt -> othfuncs); - - for (md = *flist; md != NULL; md = md -> next) - if (md -> pyname == pname && md -> module == mod) - return md; - - /* Create a new one. */ - md = sipMalloc(sizeof (memberDef)); - - md -> pyname = pname; - md -> memberflags = 0; - md -> slot = st; - md -> module = mod; - md -> next = *flist; - - *flist = md; - - /* Global operators are a subset. */ - if (cd == NULL && st != no_slot && st != neg_slot && st != pos_slot && !isNumberSlot(md) && !isRichCompareSlot(md)) - yyerror("Global operators must be either numeric or comparison operators"); - - return md; -} - - -/* - * Search a set of flags for a particular one and check its type. - */ -static optFlag *findOptFlag(optFlags *flgs,char *name,flagType ft) -{ - int f; - - for (f = 0; f < flgs -> nrFlags; ++f) - { - optFlag *of = &flgs -> flags[f]; - - if (strcmp(of -> fname,name) == 0) - { - /* - * An optional name can look like a boolean or a name. - */ - - if (ft == opt_name_flag) - { - if (of -> ftype == bool_flag) - { - of -> ftype = opt_name_flag; - of -> fvalue.sval = NULL; - } - else if (of -> ftype == name_flag) - of -> ftype = opt_name_flag; - } - - if (ft != of -> ftype) - yyerror("Optional flag has a value of the wrong type"); - - return of; - } - } - - return NULL; -} - - -/* - * A name is going to be used as a Python attribute name within a Python scope - * (ie. a Python dictionary), so check against what we already know is going in - * the same scope in case there is a clash. - */ -static void checkAttributes(sipSpec *pt,classDef *pyscope,char *attr,int isfunc) -{ - enumDef *ed; - varDef *vd; - classDef *cd; - - /* Check the enums. */ - - for (ed = pt -> enums; ed != NULL; ed = ed -> next) - { - enumMemberDef *emd; - - if (ed -> ecd != pyscope || ed -> pyname == NULL) - continue; - - if (strcmp(ed->pyname->text, attr) == 0) - yyerror("There is already an enum in scope with the same Python name"); - - for (emd = ed -> members; emd != NULL; emd = emd -> next) - if (strcmp(emd -> pyname -> text, attr) == 0) - yyerror("There is already an enum member in scope with the same Python name"); - } - - /* Check the variables. */ - - for (vd = pt -> vars; vd != NULL; vd = vd -> next) - { - if (vd -> ecd != pyscope) - continue; - - if (strcmp(vd -> pyname -> text, attr) == 0) - yyerror("There is already a variable in scope with the same Python name"); - } - - /* - * Only check the members if this attribute isn't a member because we - * can handle members with the same name in the same scope. - */ - if (!isfunc) - { - memberDef *md, *membs; - - membs = (pyscope != NULL ? pyscope -> members : pt -> othfuncs); - - for (md = membs; md != NULL; md = md -> next) - { - overDef *od, *overs; - - if (strcmp(md -> pyname -> text, attr) != 0) - continue; - - /* Check for a conflict with all overloads. */ - - overs = (pyscope != NULL ? pyscope -> overs : pt -> overs); - - for (od = overs; od != NULL; od = od -> next) - { - if (od -> common != md) - continue; - - yyerror("There is already a function in scope with the same Python name"); - } - } - } - - /* Check the classes. */ - - for (cd = pt -> classes; cd != NULL; cd = cd -> next) - { - if (cd -> ecd != pyscope || cd -> pyname == NULL) - continue; - - if (strcmp(cd->pyname, attr) == 0 && !isExternal(cd)) - yyerror("There is already a class or namespace in scope with the same Python name"); - } - - /* Check the exceptions. */ - - if (pyscope == NULL) - { - exceptionDef *xd; - - for (xd = pt->exceptions; xd != NULL; xd = xd->next) - if (xd->pyname != NULL && strcmp(xd->pyname, attr) == 0) - yyerror("There is already an exception with the same Python name"); - } -} - - -/* - * Append a code block to a list of them. Append is needed to give the - * specifier easy control over the order of the documentation. - */ -static void appendCodeBlock(codeBlock **headp,codeBlock *new) -{ - while (*headp != NULL) - headp = &(*headp) -> next; - - *headp = new; -} - - -/* - * Handle the end of a fully parsed a file. - */ -static void handleEOF() -{ - /* - * Check that the number of nested if's is the same as when we started - * the file. - */ - - if (skipStackPtr > newContext.ifdepth) - fatal("Too many %%If statements in %s\n",previousFile); - - if (skipStackPtr < newContext.ifdepth) - fatal("Too many %%End statements in %s\n",previousFile); -} - - -/* - * Handle the end of a fully parsed a module. - */ -static void handleEOM() -{ - /* Check it has been named. */ - - if (currentModule -> name == NULL) - fatal("No %%Module has been specified for module defined in %s\n",previousFile); - - /* The previous module is now current. */ - - currentModule = newContext.prevmod; -} - - -/* - * Find an existing qualifier. - */ -static qualDef *findQualifier(char *name) -{ - moduleDef *mod; - - for (mod = currentSpec -> modules; mod != NULL; mod = mod -> next) - { - qualDef *qd; - - for (qd = mod -> qualifiers; qd != NULL; qd = qd -> next) - if (strcmp(qd -> name,name) == 0) - return qd; - } - - return NULL; -} - - -/* - * Return a copy of a scoped name. - */ -scopedNameDef *copyScopedName(scopedNameDef *snd) -{ - scopedNameDef *head; - - head = NULL; - - while (snd != NULL) - { - appendScopedName(&head,text2scopePart(snd -> name)); - snd = snd -> next; - } - - return head; -} - - -/* - * Append a name to a list of scopes. - */ -void appendScopedName(scopedNameDef **headp,scopedNameDef *newsnd) -{ - while (*headp != NULL) - headp = &(*headp) -> next; - - *headp = newsnd; -} - - -/* - * Free a scoped name - but not the text itself. - */ -void freeScopedName(scopedNameDef *snd) -{ - while (snd != NULL) - { - scopedNameDef *next = snd -> next; - - free(snd); - - snd = next; - } -} - - -/* - * Convert a text string to a scope part structure. - */ -scopedNameDef *text2scopePart(char *text) -{ - scopedNameDef *snd; - - snd = sipMalloc(sizeof (scopedNameDef)); - - snd -> name = text; - snd -> next = NULL; - - return snd; -} - - -/* - * Convert a text string to a fully scoped name. - */ -static scopedNameDef *text2scopedName(char *text) -{ - return scopeScopedName(text2scopePart(text)); -} - - -/* - * Prepend any current scope to a scoped name. - */ -static scopedNameDef *scopeScopedName(scopedNameDef *name) -{ - classDef *cd = currentScope(); - scopedNameDef *snd; - - snd = (cd != NULL ? copyScopedName(cd->iff->fqcname) : NULL); - - appendScopedName(&snd, name); - - return snd; -} - - -/* - * Return a pointer to the tail part of a scoped name. - */ -char *scopedNameTail(scopedNameDef *snd) -{ - if (snd == NULL) - return NULL; - - while (snd -> next != NULL) - snd = snd -> next; - - return snd -> name; -} - - -/* - * Push the given scope onto the scope stack. - */ -static void pushScope(classDef *scope) -{ - if (currentScopeIdx >= MAX_NESTED_SCOPE) - fatal("Internal error: increase the value of MAX_NESTED_SCOPE\n"); - - scopeStack[currentScopeIdx] = scope; - sectFlagsStack[currentScopeIdx] = sectionFlags; - - ++currentScopeIdx; -} - - -/* - * Pop the scope stack. - */ -static void popScope(void) -{ - if (currentScopeIdx > 0) - sectionFlags = sectFlagsStack[--currentScopeIdx]; -} - - -/* - * Return non-zero if the current input should be parsed rather than be - * skipped. - */ -static int notSkipping() -{ - return (skipStackPtr == 0 ? TRUE : skipStack[skipStackPtr - 1]); -} - - -/* - * Return the value of an expression involving a time period. - */ -static int timePeriod(char *lname,char *uname) -{ - int this, line; - qualDef *qd, *lower, *upper; - moduleDef *mod; - - if (lname == NULL) - lower = NULL; - else if ((lower = findQualifier(lname)) == NULL || lower -> qtype != time_qualifier) - yyerror("Lower bound is not a time version"); - - if (uname == NULL) - upper = NULL; - else if ((upper = findQualifier(uname)) == NULL || upper -> qtype != time_qualifier) - yyerror("Upper bound is not a time version"); - - /* Sanity checks on the bounds. */ - - if (lower == NULL && upper == NULL) - yyerror("Lower and upper bounds cannot both be omitted"); - - if (lower != NULL && upper != NULL) - { - if (lower -> module != upper -> module || lower -> line != upper -> line) - yyerror("Lower and upper bounds are from different timelines"); - - if (lower == upper) - yyerror("Lower and upper bounds must be different"); - - if (lower -> order > upper -> order) - yyerror("Later version specified as lower bound"); - } - - /* Go through each slot in the relevant timeline. */ - - if (lower != NULL) - { - mod = lower -> module; - line = lower -> line; - } - else - { - mod = upper -> module; - line = upper -> line; - } - - this = FALSE; - - for (qd = mod -> qualifiers; qd != NULL; qd = qd -> next) - { - if (qd -> qtype != time_qualifier || qd -> line != line) - continue; - - if (lower != NULL && qd -> order < lower -> order) - continue; - - if (upper != NULL && qd -> order >= upper -> order) - continue; - - /* - * This is within the required range so if it is also needed - * then the expression is true. - */ - - if (isNeeded(qd)) - { - this = TRUE; - break; - } - } - - return this; -} - - -/* - * Return the value of an expression involving a single platform or feature. - */ -static int platOrFeature(char *name,int optnot) -{ - int this; - qualDef *qd; - - if ((qd = findQualifier(name)) == NULL || qd -> qtype == time_qualifier) - yyerror("No such platform or feature"); - - /* Assume this sub-expression is false. */ - - this = FALSE; - - if (qd -> qtype == feature_qualifier) - { - if (!excludedFeature(excludedQualifiers,qd)) - this = TRUE; - } - else if (isNeeded(qd)) - this = TRUE; - - if (optnot) - this = !this; - - return this; -} - - -/* - * Return TRUE if the given qualifier is excluded. - */ -int excludedFeature(stringList *xsl,qualDef *qd) -{ - while (xsl != NULL) - { - if (strcmp(qd -> name,xsl -> s) == 0) - return TRUE; - - xsl = xsl -> next; - } - - return FALSE; -} - - -/* - * Return TRUE if the given qualifier is needed. - */ -static int isNeeded(qualDef *qd) -{ - stringList *sl; - - for (sl = neededQualifiers; sl != NULL; sl = sl -> next) - if (strcmp(qd -> name,sl -> s) == 0) - return TRUE; - - return FALSE; -} - - -/* - * Return the current scope. currentScope() is only valid if notSkipping() - * returns non-zero. - */ -static classDef *currentScope(void) -{ - return (currentScopeIdx > 0 ? scopeStack[currentScopeIdx - 1] : NULL); -} - - -/* - * Create a new qualifier. - */ -static void newQualifier(moduleDef *mod,int line,int order,char *name,qualType qt) -{ - qualDef *qd; - - /* Check it doesn't already exist. */ - - if (findQualifier(name) != NULL) - yyerror("Version is already defined"); - - qd = sipMalloc(sizeof (qualDef)); - qd -> name = name; - qd -> qtype = qt; - qd -> module = mod; - qd -> line = line; - qd -> order = order; - qd -> next = mod -> qualifiers; - mod -> qualifiers = qd; -} - - -/* - * Create a new imported module. - */ -static void newImport(char *name) -{ - moduleDef *from, *mod; - moduleListDef *mld; - - /* Create a new module if it has already been imported. */ - for (mod = currentSpec -> modules; mod != NULL; mod = mod -> next) - if (strcmp(mod -> file,name) == 0) - break; - - from = currentModule; - - if (mod == NULL) - { - newModule(NULL,name); - mod = currentModule; - } - - /* Add the new import unless it has already been imported. */ - for (mld = from->imports; mld != NULL; mld = mld->next) - if (mld->module == mod) - return; - - mld = sipMalloc(sizeof (moduleListDef)); - mld -> module = mod; - mld -> next = from->imports; - - from->imports = mld; -} - - -/* - * Set up pointers to hook names. - */ -static void getHooks(optFlags *optflgs,char **pre,char **post) -{ - optFlag *of; - - if ((of = findOptFlag(optflgs,"PreHook",name_flag)) != NULL) - *pre = of -> fvalue.sval; - else - *pre = NULL; - - if ((of = findOptFlag(optflgs,"PostHook",name_flag)) != NULL) - *post = of -> fvalue.sval; - else - *post = NULL; -} - - -/* - * Get the /ReleaseGIL/ option flag. - */ -static int getReleaseGIL(optFlags *optflgs) -{ - return (findOptFlag(optflgs, "ReleaseGIL", bool_flag) != NULL); -} - - -/* - * Get the /HoldGIL/ option flag. - */ -static int getHoldGIL(optFlags *optflgs) -{ - return (findOptFlag(optflgs, "HoldGIL", bool_flag) != NULL); -} - - -/* - * Return TRUE if the QtNoEmitters option was specified. - */ -int optNoEmitters(sipSpec *pt) -{ - return optFind(pt, "QtNoEmitters"); -} - - -/* - * Return TRUE if the QtRegisterTypes option was specified. - */ -int optRegisterTypes(sipSpec *pt) -{ - return optFind(pt, "QtRegisterTypes"); -} - - -/* - * Return TRUE if the Qt4Q_OBJECT option was specified. - */ -int optQ_OBJECT4(sipSpec *pt) -{ - return optFind(pt, "Qt4Q_OBJECT"); -} - - -/* - * Return TRUE if a particular option was specified with %SIPOptions. - */ -static int optFind(sipSpec *pt, const char *opt) -{ - stringList *sl; - - for (sl = pt->options; sl != NULL; sl = sl->next) - if (strcmp(sl->s, opt) == 0) - return TRUE; - - return FALSE; -} diff --git a/python/sip/sipgen/sip.h b/python/sip/sipgen/sip.h deleted file mode 100644 index a259a6dc..00000000 --- a/python/sip/sipgen/sip.h +++ /dev/null @@ -1,1027 +0,0 @@ -/* - * The main header file for SIP. - * - * Copyright (c) 2007 - * Riverbank Computing Limited <info@riverbankcomputing.co.uk> - * - * This file is part of SIP. - * - * This copy of SIP is licensed for use under the terms of the SIP License - * Agreement. See the file LICENSE for more details. - * - * SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - - -#ifndef SIP_H -#define SIP_H - -#include <stdio.h> -#include <sys/types.h> - - -#ifdef TRUE -#undef TRUE -#endif - -#ifdef FALSE -#undef FALSE -#endif - -#define TRUE 1 -#define FALSE 0 - - -#define DEFAULT_OFILE_EXT ".o" /* Default object file extension. */ - -#define MAX_NR_ARGS 20 /* Max. nr. args. to a function or template. */ - - -/* For convenience. */ - -#define classBaseName(cd) ((cd)->iff->name->text) -#define classFQCName(cd) ((cd)->iff->fqcname) - - -/* Handle module flags. */ - -#define MOD_HAS_DELAYED_DTORS 0x0001 /* It has a class with a delayed dtor. */ - -#define hasDelayedDtors(m) ((m)->modflags & MOD_HAS_DELAYED_DTORS) -#define setHasDelayedDtors(m) ((m)->modflags |= MOD_HAS_DELAYED_DTORS) - - -/* Handle section flags. */ - -#define SECT_IS_PUBLIC 0x01 /* It is public. */ -#define SECT_IS_PROT 0x02 /* It is protected. */ -#define SECT_IS_PRIVATE 0x04 /* It is private. */ -#define SECT_IS_SLOT 0x08 /* It is a slot. */ -#define SECT_IS_SIGNAL 0x10 /* It is a signal. */ -#define SECT_MASK 0x1f /* The mask of all flags. */ - - -/* Handle class flags. These are combined with the section flags. */ - -#define CLASS_HAS_ENUMS 0x00000100 /* It has enums. */ -#define CLASS_HAS_SIGSLOTS 0x00000200 /* It has signals or slots. */ -#define CLASS_IS_ABSTRACT 0x00000400 /* It is an abstract class. */ -#define CLASS_HAS_SHADOW 0x00000800 /* It is has a shadow class. */ -#define CLASS_IS_OPAQUE 0x00001000 /* It is opaque. */ -#define CLASS_HAS_VAR_HANDLERS 0x00002000 /* It has variable handlers. */ -#define CLASS_DTOR_RELEASE_GIL 0x00004000 /* The dtor releases the GIL. */ -#define CLASS_IS_PROTECTED 0x00008000 /* It is protected. */ -#define CLASS_IS_PROTECTED_SAV 0x00010000 /* It is protected (saved). */ -#define CLASS_IS_RENAMED 0x00020000 /* It has a different Python name. */ -#define CLASS_IS_INCOMPLETE 0x00040000 /* The specification is incomplete. */ -#define CLASS_CAN_CREATE 0x00080000 /* It has usable ctors. */ -#define CLASS_IS_EXTERNAL 0x00100000 /* It is external. */ -#define CLASS_IS_DELAYED_DTOR 0x00200000 /* The dtor is delayed. */ -#define CLASS_NO_DEFAULT_CTORS 0x00400000 /* Don't create default ctors. */ -#define CLASS_QOBJECT_SUB 0x00800000 /* It is derived from TQObject. */ -#define CLASS_DTOR_HOLD_GIL 0x01000000 /* The dtor holds the GIL. */ - -#define hasEnums(cd) ((cd)->classflags & CLASS_HAS_ENUMS) -#define setHasEnums(cd) ((cd)->classflags |= CLASS_HAS_ENUMS) -#define hasSigSlots(cd) ((cd)->classflags & CLASS_HAS_SIGSLOTS) -#define setHasSigSlots(cd) ((cd)->classflags |= CLASS_HAS_SIGSLOTS) -#define isAbstractClass(cd) ((cd)->classflags & CLASS_IS_ABSTRACT) -#define setIsAbstractClass(cd) ((cd)->classflags |= CLASS_IS_ABSTRACT) -#define hasShadow(cd) ((cd)->classflags & CLASS_HAS_SHADOW) -#define setHasShadow(cd) ((cd)->classflags |= CLASS_HAS_SHADOW) -#define resetHasShadow(cd) ((cd)->classflags &= ~CLASS_HAS_SHADOW) -#define isOpaque(cd) ((cd)->classflags & CLASS_IS_OPAQUE) -#define setIsOpaque(cd) ((cd)->classflags |= CLASS_IS_OPAQUE) -#define hasVarHandlers(cd) ((cd)->classflags & CLASS_HAS_VAR_HANDLERS) -#define setHasVarHandlers(cd) ((cd)->classflags |= CLASS_HAS_VAR_HANDLERS) -#define isProtectedClass(cd) ((cd)->classflags & CLASS_IS_PROTECTED) -#define setIsProtectedClass(cd) ((cd)->classflags |= CLASS_IS_PROTECTED) -#define resetIsProtectedClass(cd) ((cd)->classflags &= ~CLASS_IS_PROTECTED) -#define wasProtectedClass(cd) ((cd)->classflags & CLASS_IS_PROTECTED_SAV) -#define setWasProtectedClass(cd) ((cd)->classflags |= CLASS_IS_PROTECTED_SAV) -#define resetWasProtectedClass(cd) ((cd)->classflags &= ~CLASS_IS_PROTECTED_SAV) -#define isReleaseGILDtor(c) ((cd)->classflags & CLASS_DTOR_RELEASE_GIL) -#define setIsReleaseGILDtor(c) ((cd)->classflags |= CLASS_DTOR_RELEASE_GIL) -#define isRenamedClass(cd) ((cd)->classflags & CLASS_IS_RENAMED) -#define setIsRenamedClass(cd) ((cd)->classflags |= CLASS_IS_RENAMED) -#define isIncomplete(cd) ((cd)->classflags & CLASS_IS_INCOMPLETE) -#define setIsIncomplete(cd) ((cd)->classflags |= CLASS_IS_INCOMPLETE) -#define canCreate(cd) ((cd)->classflags & CLASS_CAN_CREATE) -#define setCanCreate(cd) ((cd)->classflags |= CLASS_CAN_CREATE) -#define resetCanCreate(cd) ((cd)->classflags &= ~CLASS_CAN_CREATE) -#define isExternal(cd) ((cd)->classflags & CLASS_IS_EXTERNAL) -#define setIsExternal(cd) ((cd)->classflags |= CLASS_IS_EXTERNAL) -#define isDelayedDtor(cd) ((cd)->classflags & CLASS_IS_DELAYED_DTOR) -#define setIsDelayedDtor(cd) ((cd)->classflags |= CLASS_IS_DELAYED_DTOR) -#define noDefaultCtors(cd) ((cd)->classflags & CLASS_NO_DEFAULT_CTORS) -#define setNoDefaultCtors(cd) ((cd)->classflags |= CLASS_NO_DEFAULT_CTORS) -#define isQObjectSubClass(cd) ((cd)->classflags & CLASS_QOBJECT_SUB) -#define setIsQObjectSubClass(cd) ((cd)->classflags |= CLASS_QOBJECT_SUB) -#define isHoldGILDtor(c) ((cd)->classflags & CLASS_DTOR_HOLD_GIL) -#define setIsHoldGILDtor(c) ((cd)->classflags |= CLASS_DTOR_HOLD_GIL) - -#define isPublicDtor(cd) ((cd)->classflags & SECT_IS_PUBLIC) -#define setIsPublicDtor(cd) ((cd)->classflags |= SECT_IS_PUBLIC) -#define isProtectedDtor(cd) ((cd)->classflags & SECT_IS_PROT) -#define isPrivateDtor(cd) ((cd)->classflags & SECT_IS_PRIVATE) - -#define isDtor(cd) ((cd)->classflags & (SECT_IS_PUBLIC | SECT_IS_PROT | SECT_IS_PRIVATE)) - - -/* Handle ctor flags. These are combined with the section flags. */ - -#define CTOR_RELEASE_GIL 0x00000100 /* The ctor releases the GIL. */ -#define CTOR_EXPLICIT 0x00000200 /* The ctor is explicit. */ -#define CTOR_CAST 0x00000400 /* The ctor is a cast. */ -#define CTOR_HOLD_GIL 0x00000800 /* The ctor holds the GIL. */ - -#define isPublicCtor(c) ((c)->ctorflags & SECT_IS_PUBLIC) -#define setIsPublicCtor(c) ((c)->ctorflags |= SECT_IS_PUBLIC) -#define isProtectedCtor(c) ((c)->ctorflags & SECT_IS_PROT) -#define setIsProtectedCtor(c) ((c)->ctorflags |= SECT_IS_PROT) -#define isPrivateCtor(c) ((c)->ctorflags & SECT_IS_PRIVATE) -#define setIsPrivateCtor(c) ((c)->ctorflags |= SECT_IS_PRIVATE) - -#define isReleaseGILCtor(c) ((c)->ctorflags & CTOR_RELEASE_GIL) -#define setIsReleaseGILCtor(c) ((c)->ctorflags |= CTOR_RELEASE_GIL) -#define isExplicitCtor(c) ((c)->ctorflags & CTOR_EXPLICIT) -#define setIsExplicitCtor(c) ((c)->ctorflags |= CTOR_EXPLICIT) -#define isCastCtor(c) ((c)->ctorflags & CTOR_CAST) -#define isHoldGILCtor(c) ((c)->ctorflags & CTOR_HOLD_GIL) -#define setIsHoldGILCtor(c) ((c)->ctorflags |= CTOR_HOLD_GIL) - - -/* Handle member flags. */ - -#define MEMBR_NUMERIC 0x0001 /* It is a numeric slot. */ - -#define isNumeric(m) ((m)->memberflags & MEMBR_NUMERIC) -#define setIsNumeric(m) ((m)->memberflags |= MEMBR_NUMERIC) - - -/* Handle enum flags. These are combined with the section flags. */ - -#define ENUM_WAS_PROT 0x00000100 /* It was defined as protected. */ -#define ENUM_IS_RENAMED 0x00000200 /* It has been renamed. */ - -#define isProtectedEnum(e) ((e)->enumflags & SECT_IS_PROT) -#define setIsProtectedEnum(e) ((e)->enumflags |= SECT_IS_PROT) -#define resetIsProtectedEnum(e) ((e)->enumflags &= ~SECT_IS_PROT) - -#define wasProtectedEnum(e) ((e)->enumflags & ENUM_WAS_PROT) -#define setWasProtectedEnum(e) ((e)->enumflags |= ENUM_WAS_PROT) -#define resetWasProtectedEnum(e) ((e)->enumflags &= ~ENUM_WAS_PROT) -#define isRenamedEnum(e) ((e)->enumflags & ENUM_IS_RENAMED) -#define setIsRenamedEnum(e) ((e)->enumflags |= ENUM_IS_RENAMED) - - -/* Handle hierarchy flags. */ - -#define HIER_IS_DUPLICATE 0x0001 /* It is a super class duplicate. */ -#define HIER_HAS_DUPLICATE 0x0002 /* It has a super class duplicate. */ - -#define isDuplicateSuper(m) ((m)->mroflags & HIER_IS_DUPLICATE) -#define setIsDuplicateSuper(m) ((m)->mroflags |= HIER_IS_DUPLICATE) -#define hasDuplicateSuper(m) ((m)->mroflags & HIER_HAS_DUPLICATE) -#define setHasDuplicateSuper(m) ((m)->mroflags |= HIER_HAS_DUPLICATE) - - -/* Handle overload flags. These are combined with the section flags. */ - -#define OVER_IS_VIRTUAL 0x00000100 /* It is virtual. */ -#define OVER_IS_ABSTRACT 0x00000200 /* It is abstract. */ -#define OVER_IS_CONST 0x00000400 /* It is a const function. */ -#define OVER_IS_STATIC 0x00000800 /* It is a static function. */ -#define OVER_IS_AUTOGEN 0x00001000 /* It is auto-generated. */ -#define OVER_IS_NEW_THREAD 0x00002000 /* It is in a new thread. */ -#define OVER_IS_FACTORY 0x00004000 /* It is a factory method. */ -#define OVER_XFERRED_BACK 0x00008000 /* Ownership is transferred back. */ -#define OVER_RELEASE_GIL 0x00010000 /* The function releases the GIL. */ -#define OVER_IS_VIRTUAL_REIMP 0x00020000 /* It is a re-implementation of a virtual. */ -#define OVER_DONT_DEREF_SELF 0x00040000 /* For comparison operators, don't dereference self. */ -#define OVER_HOLD_GIL 0x00080000 /* The function holds the GIL. */ - -#define isPublic(o) ((o)->overflags & SECT_IS_PUBLIC) -#define setIsPublic(o) ((o)->overflags |= SECT_IS_PUBLIC) -#define isProtected(o) ((o)->overflags & SECT_IS_PROT) -#define setIsProtected(o) ((o)->overflags |= SECT_IS_PROT) -#define isPrivate(o) ((o)->overflags & SECT_IS_PRIVATE) -#define setIsPrivate(o) ((o)->overflags |= SECT_IS_PRIVATE) -#define isSlot(o) ((o)->overflags & SECT_IS_SLOT) -#define setIsSlot(o) ((o)->overflags |= SECT_IS_SLOT) -#define isSignal(o) ((o)->overflags & SECT_IS_SIGNAL) -#define setIsSignal(o) ((o)->overflags |= SECT_IS_SIGNAL) - -#define isVirtual(o) ((o)->overflags & OVER_IS_VIRTUAL) -#define setIsVirtual(o) ((o)->overflags |= OVER_IS_VIRTUAL) -#define isAbstract(o) ((o)->overflags & OVER_IS_ABSTRACT) -#define setIsAbstract(o) ((o)->overflags |= OVER_IS_ABSTRACT) -#define isConst(o) ((o)->overflags & OVER_IS_CONST) -#define setIsConst(o) ((o)->overflags |= OVER_IS_CONST) -#define isStatic(o) ((o)->overflags & OVER_IS_STATIC) -#define setIsStatic(o) ((o)->overflags |= OVER_IS_STATIC) -#define isAutoGen(o) ((o)->overflags & OVER_IS_AUTOGEN) -#define setIsAutoGen(o) ((o)->overflags |= OVER_IS_AUTOGEN) -#define resetIsAutoGen(o) ((o)->overflags &= ~OVER_IS_AUTOGEN) -#define isNewThread(o) ((o)->overflags & OVER_IS_NEW_THREAD) -#define setIsNewThread(o) ((o)->overflags |= OVER_IS_NEW_THREAD) -#define isFactory(o) ((o)->overflags & OVER_IS_FACTORY) -#define setIsFactory(o) ((o)->overflags |= OVER_IS_FACTORY) -#define isResultTransferredBack(o) ((o)->overflags & OVER_XFERRED_BACK) -#define setIsResultTransferredBack(o) ((o)->overflags |= OVER_XFERRED_BACK) -#define isReleaseGIL(o) ((o)->overflags & OVER_RELEASE_GIL) -#define setIsReleaseGIL(o) ((o)->overflags |= OVER_RELEASE_GIL) -#define isVirtualReimp(o) ((o)->overflags & OVER_IS_VIRTUAL_REIMP) -#define setIsVirtualReimp(o) ((o)->overflags |= OVER_IS_VIRTUAL_REIMP) -#define dontDerefSelf(o) ((o)->overflags & OVER_DONT_DEREF_SELF) -#define setDontDerefSelf(o) ((o)->overflags |= OVER_DONT_DEREF_SELF) -#define isHoldGIL(o) ((o)->overflags & OVER_HOLD_GIL) -#define setIsHoldGIL(o) ((o)->overflags |= OVER_HOLD_GIL) - - -/* Handle variable flags. */ - -#define VAR_IS_STATIC 0x01 /* It is a static variable. */ -#define VAR_NEEDS_HANDLER 0x02 /* It the variable needs a handler. */ - -#define isStaticVar(v) ((v)->varflags & VAR_IS_STATIC) -#define setIsStaticVar(v) ((v)->varflags |= VAR_IS_STATIC) -#define needsHandler(v) ((v)->varflags & VAR_NEEDS_HANDLER) -#define setNeedsHandler(v) ((v)->varflags |= VAR_NEEDS_HANDLER) - - -/* Handle argument flags. */ - -#define ARG_IS_REF 0x0001 /* It is a reference. */ -#define ARG_IS_CONST 0x0002 /* It is a const. */ -#define ARG_XFERRED 0x0004 /* Ownership is transferred. */ -#define ARG_THIS_XFERRED 0x0008 /* Ownership of this is transferred. */ -#define ARG_XFERRED_BACK 0x0010 /* Ownership is transferred back. */ -#define ARG_ARRAY 0x0020 /* Used as an array. */ -#define ARG_ARRAY_SIZE 0x0040 /* Used as an array size. */ -#define ARG_ALLOW_NONE 0x0080 /* Allow None as a value. */ -#define ARG_GET_WRAPPER 0x0100 /* Get the wrapper object. */ -#define ARG_IN 0x0200 /* It passes an argument. */ -#define ARG_OUT 0x0400 /* It returns a result. */ -#define ARG_CONSTRAINED 0x0800 /* Suppress type conversion. */ - -#define isReference(a) ((a)->argflags & ARG_IS_REF) -#define setIsReference(a) ((a)-> argflags |= ARG_IS_REF) -#define resetIsReference(a) ((a)->argflags &= ~ARG_IS_REF) -#define isConstArg(a) ((a)->argflags & ARG_IS_CONST) -#define setIsConstArg(a) ((a)->argflags |= ARG_IS_CONST) -#define resetIsConstArg(a) ((a)->argflags &= ~ARG_IS_CONST) -#define isTransferred(a) ((a)->argflags & ARG_XFERRED) -#define setIsTransferred(a) ((a)->argflags |= ARG_XFERRED) -#define isThisTransferred(a) ((a)->argflags & ARG_THIS_XFERRED) -#define setIsThisTransferred(a) ((a)->argflags |= ARG_THIS_XFERRED) -#define isTransferredBack(a) ((a)->argflags & ARG_XFERRED_BACK) -#define setIsTransferredBack(a) ((a)->argflags |= ARG_XFERRED_BACK) -#define isArray(a) ((a)->argflags & ARG_ARRAY) -#define setArray(a) ((a)->argflags |= ARG_ARRAY) -#define isArraySize(a) ((a)->argflags & ARG_ARRAY_SIZE) -#define setArraySize(a) ((a)->argflags |= ARG_ARRAY_SIZE) -#define isAllowNone(a) ((a)->argflags & ARG_ALLOW_NONE) -#define setAllowNone(a) ((a)->argflags |= ARG_ALLOW_NONE) -#define isGetWrapper(a) ((a)->argflags & ARG_GET_WRAPPER) -#define setGetWrapper(a) ((a)->argflags |= ARG_GET_WRAPPER) -#define isInArg(a) ((a)->argflags & ARG_IN) -#define setIsInArg(a) ((a)->argflags |= ARG_IN) -#define isOutArg(a) ((a)->argflags & ARG_OUT) -#define setIsOutArg(a) ((a)->argflags |= ARG_OUT) -#define isConstrained(a) ((a)->argflags & ARG_CONSTRAINED) -#define setIsConstrained(a) ((a)->argflags |= ARG_CONSTRAINED) -#define resetIsConstrained(a) ((a)->argflags &= ~ARG_CONSTRAINED) - - -/* Handle name flags. */ - -#define NAME_IS_USED 0x01 /* It is used in the main module. */ -#define NAME_IS_CLASS 0x02 /* It is the name of a class. */ - -#define isUsedName(n) ((n)->nameflags & NAME_IS_USED) -#define setIsUsedName(n) ((n)->nameflags |= NAME_IS_USED) -#define resetIsUsedName(n) ((n)->nameflags &= ~NAME_IS_USED) -#define isClassName(n) ((n)->nameflags & NAME_IS_CLASS) -#define setIsClassName(n) ((n)->nameflags |= NAME_IS_CLASS) -#define resetIsClassName(n) ((n)->nameflags &= ~NAME_IS_CLASS) - - -/* Handle virtual handler flags. */ - -#define VH_IS_DUPLICATE 0x01 /* It is a duplicate. */ -#define VH_TRANSFERS 0x02 /* It transfers ownership of the result. */ - -#define isDuplicateVH(vh) ((vh)->vhflags & VH_IS_DUPLICATE) -#define setIsDuplicateVH(vh) ((vh)->vhflags |= VH_IS_DUPLICATE) -#define resetIsDuplicateVH(vh) ((vh)->vhflags &= ~VH_IS_DUPLICATE) -#define isTransferVH(vh) ((vh)->vhflags & VH_TRANSFERS) -#define setIsTransferVH(vh) ((vh)->vhflags |= VH_TRANSFERS) - - -/* Slot types. */ - -typedef enum { - str_slot, - unicode_slot, - int_slot, - long_slot, - float_slot, - len_slot, - contains_slot, - add_slot, - concat_slot, - sub_slot, - mul_slot, - repeat_slot, - div_slot, - mod_slot, - and_slot, - or_slot, - xor_slot, - lshift_slot, - rshift_slot, - iadd_slot, - iconcat_slot, - isub_slot, - imul_slot, - irepeat_slot, - idiv_slot, - imod_slot, - iand_slot, - ior_slot, - ixor_slot, - ilshift_slot, - irshift_slot, - invert_slot, - call_slot, - getitem_slot, - setitem_slot, - delitem_slot, - lt_slot, - le_slot, - eq_slot, - ne_slot, - gt_slot, - ge_slot, - cmp_slot, - nonzero_slot, - neg_slot, - pos_slot, - abs_slot, - repr_slot, - hash_slot, - no_slot -} slotType; - - -/* - * Argument types. Always add new ones at the end because the numeric values - * can appear in generated code. - */ -typedef enum { - no_type, - defined_type, - class_type, - struct_type, - void_type, - enum_type, - template_type, - signal_type, - slot_type, - rxcon_type, - rxdis_type, - slotcon_type, - slotdis_type, - ustring_type, - string_type, - short_type, - ushort_type, - cint_type, - int_type, - uint_type, - long_type, - ulong_type, - float_type, - cfloat_type, - double_type, - cdouble_type, - bool_type, - mapped_type, - pyobject_type, - pytuple_type, - pylist_type, - pydict_type, - pycallable_type, - pyslice_type, - qobject_type, - function_type, - pytype_type, - ellipsis_type, - longlong_type, - ulonglong_type, - anyslot_type, - cbool_type, - sstring_type, - wstring_type -} argType; - - -/* Value types. */ - -typedef enum { - qchar_value, - string_value, - numeric_value, - real_value, - scoped_value, - fcall_value -} valueType; - - -/* Version types. */ - -typedef enum { - time_qualifier, - platform_qualifier, - feature_qualifier -} qualType; - - -/* Interface file types. */ - -typedef enum { - exception_iface, - mappedtype_iface, - namespace_iface, - class_iface -} ifaceFileType; - - -/* A software license. */ - -typedef struct { - char *type; /* The license type. */ - char *licensee; /* The licensee. */ - char *timestamp; /* The timestamp. */ - char *sig; /* The signature. */ -} licenseDef; - - -/* A version qualifier. */ - -typedef struct _qualDef { - char *name; /* The qualifier name. */ - qualType qtype; /* The qualifier type. */ - struct _moduleDef *module; /* The defining module. */ - int line; /* Timeline if it is a time. */ - int order; /* Order if it is a time. */ - struct _qualDef *next; /* Next in the list. */ -} qualDef; - - -/* A scoped name. */ - -typedef struct _scopedNameDef { - char *name; /* The name. */ - struct _scopedNameDef *next; /* Next in the scope list. */ -} scopedNameDef; - - -/* A name. */ - -typedef struct _nameDef { - int nameflags; /* The name flags. */ - struct _moduleDef *module; /* The main module. */ - char *text; /* The text of the name. */ - struct _nameDef *next; /* Next in the list. */ -} nameDef; - - -/* - * A node in the tree of classes used to determine the order in which the - * classes need to be created. - */ - -typedef struct _nodeDef { - int ordered; /* Set if in order. */ - struct _classDef *cd; /* The class. */ - struct _nodeDef *parent; /* The parent. */ - struct _nodeDef *child; /* The first child. */ - struct _nodeDef *next; /* The next sibling. */ -} nodeDef; - - -/* A module definition. */ - -typedef struct _moduleDef { - char *fullname; /* The full module name. */ - char *name; /* The module base name. */ - int version; /* The module version. */ - int modflags; /* The module flags. */ - int modulenr; /* The module number. */ - char *file; /* The filename. */ - qualDef *qualifiers; /* The list of qualifiers. */ - nodeDef root; /* Root of class tree. */ - int nrtimelines; /* The nr. of timelines. */ - int nrclasses; /* The nr. of classes. */ - int nrexceptions; /* The nr. of exceptions. */ - int nrmappedtypes; /* The nr. of mapped types. */ - int nrenums; /* The nr. of named enums. */ - int nrtypedefs; /* The nr. of typedefs. */ - int nrvirthandlers; /* The nr. of virtual handlers. */ - struct _virtHandlerDef *virthandlers; /* The virtual handlers. */ - licenseDef *license; /* The software license. */ - struct _moduleListDef *allimports; /* The list of all imports. */ - struct _moduleListDef *imports; /* The list of direct imports. */ - struct _moduleDef *next; /* Next in the list. */ -} moduleDef; - - -/* An entry in a linked module list. */ - -typedef struct _moduleListDef { - moduleDef *module; /* The module itself. */ - struct _moduleListDef *next; /* The next in the list. */ -} moduleListDef; - - -/* A literal code block. */ - -typedef struct _codeBlock { - char *frag; /* The code itself. */ - char *filename; /* The original file. */ - int linenr; /* The line in the file. */ - struct _codeBlock *next; /* Next in the list. */ -} codeBlock; - - -/* The arguments to a throw specifier. */ - -typedef struct _throwArgs { - int nrArgs; /* The number of arguments. */ - struct _exceptionDef *args[MAX_NR_ARGS]; /* The arguments. */ -} throwArgs; - - -/* An exception. */ - -typedef struct _exceptionDef { - int exceptionnr; /* The exception number. */ - struct _ifaceFileDef *iff; /* The interface file. */ - char *pyname; /* The exception Python name. */ - struct _classDef *cd; /* The exception class. */ - char *bibase; /* The builtin base exception. */ - struct _exceptionDef *base; /* The defined base exception. */ - codeBlock *hdrcode; /* Optional header code. */ - codeBlock *raisecode; /* Raise exception code. */ - struct _exceptionDef *next; /* The next in the list. */ -} exceptionDef; - - -/* A value. */ - -typedef struct _valueDef { - valueType vtype; /* The type. */ - char vunop; /* Any unary operator. */ - char vbinop; /* Any binary operator. */ - union { - char vqchar; /* Quoted character value. */ - long vnum; /* Numeric value. */ - double vreal; /* Real value. */ - char *vstr; /* String value. */ - scopedNameDef *vscp; /* Scoped value. */ - struct _fcallDef *fcd; /* Function call. */ - } u; - struct _valueDef *next; /* Next in the expression. */ -} valueDef; - - -/* A member function argument (or result). */ - -typedef struct { - argType atype; /* The type. */ - char *name; /* The name. */ - int argflags; /* The argument flags. */ - int nrderefs; /* Nr. of dereferences. */ - valueDef *defval; /* The default value. */ - union { - struct _signatureDef *sa; /* If it is a function. */ - struct _templateDef *td; /* If it is a template. */ - struct _scopedNameDef *snd; /* If it is a defined type. */ - struct _classDef *cd; /* If it is a class. */ - struct _enumDef *ed; /* If it is an enum. */ - struct _scopedNameDef *sname; /* If it is a struct. */ - struct _mappedTypeDef *mtd; /* If it is a mapped type. */ - } u; -} argDef; - - - -/* An entry in a linked argument list. */ -typedef struct _argList { - argDef arg; /* The argument itself. */ - struct _argList *next; /* Next in the list. */ -} argList; - - -/* A function call. */ - -typedef struct _fcallDef { - argDef type; /* The type. */ - int nrArgs; /* The number of arguments. */ - struct _valueDef *args[MAX_NR_ARGS]; /* The arguments. */ -} fcallDef; - - -/* An interface file definition. */ - -typedef struct _ifaceFileDef { - nameDef *name; /* The name. */ - ifaceFileType type; /* Interface file type. */ - scopedNameDef *fqcname; /* The fully qualified C++ name. */ - moduleDef *module; /* The owning module. */ - struct _ifaceFileList *used; /* Interface files used. */ - struct _ifaceFileDef *next; /* Next in the list. */ -} ifaceFileDef; - - -/* An entry in a linked interface file list. */ - -typedef struct _ifaceFileList { - ifaceFileDef *iff; /* The interface file itself. */ - int header; /* If needed in the .h file. */ - struct _ifaceFileList *next; /* Next in the list. */ -} ifaceFileList; - - -/* A mapped type. */ - -typedef struct _mappedTypeDef { - argDef type; /* The type being mapped. */ - int mappednr; /* The mapped type number. */ - ifaceFileDef *iff; /* The interface file. */ - codeBlock *hdrcode; /* Header code. */ - codeBlock *convfromcode; /* Convert from C++ code. */ - codeBlock *convtocode; /* Convert to C++ code. */ - struct _mappedTypeDef *next; /* Next in the list. */ -} mappedTypeDef; - - -/* A function signature. */ - -typedef struct _signatureDef { - argDef result; /* The result. */ - int nrArgs; /* The number of arguments. */ - argDef args[MAX_NR_ARGS]; /* The arguments. */ -} signatureDef; - - -/* A list of function signatures. */ - -typedef struct _signatureList { - struct _signatureDef *sd; /* The signature. */ - struct _signatureList *next; /* Next in the list. */ -} signatureList; - - -/* A template type. */ - -typedef struct _templateDef { - scopedNameDef *fqname; /* The name. */ - signatureDef types; /* The types. */ -} templateDef; - - -/* A list of virtual handlers. */ - -typedef struct _virtHandlerDef { - int virthandlernr; /* The nr. of the virtual handler. */ - int vhflags; /* The virtual handler flags. */ - signatureDef *pysig; /* The Python signature. */ - signatureDef *cppsig; /* The C++ signature. */ - struct _moduleDef *module; /* The defining module. */ - codeBlock *virtcode; /* Virtual handler code. */ - struct _virtHandlerDef *next; /* Next in the list. */ -} virtHandlerDef; - - -/* A typedef definition. */ - -typedef struct _typedefDef { - scopedNameDef *fqname; /* The fully qualified name. */ - struct _classDef *ecd; /* The enclosing class. */ - moduleDef *module; /* The owning module. */ - argDef type; /* The actual type. */ - struct _typedefDef *next; /* Next in the list. */ -} typedefDef; - - -/* A variable definition. */ - -typedef struct _varDef { - nameDef *pyname; /* The variable Python name. */ - scopedNameDef *fqcname; /* The fully qualified C/C++ name. */ - struct _classDef *ecd; /* The enclosing class. */ - moduleDef *module; /* The owning module. */ - int varflags; /* The variable flags. */ - argDef type; /* The actual type. */ - codeBlock *accessfunc; /* The access function. */ - codeBlock *getcode; /* The get code. */ - codeBlock *setcode; /* The set code. */ - struct _varDef *next; /* Next in the list. */ -} varDef; - - -/* An overloaded member function definition. */ - -typedef struct _overDef { - char *cppname; /* The C++ name. */ - int overflags; /* The overload flags. */ - struct _memberDef *common; /* Common parts. */ - signatureDef pysig; /* The Python signature. */ - signatureDef *cppsig; /* The C++ signature. */ - throwArgs *exceptions; /* The exceptions. */ - codeBlock *methodcode; /* Method code. */ - virtHandlerDef *virthandler; /* The virtual handler. */ - char *prehook; /* The pre-hook name. */ - char *posthook; /* The post-hook name. */ - struct _overDef *next; /* Next in the list. */ -} overDef; - - -/* An overloaded constructor definition. */ - -typedef struct _ctorDef { - int ctorflags; /* The ctor flags. */ - signatureDef pysig; /* The Python signature. */ - signatureDef *cppsig; /* The C++ signature, NULL if /NoDerived/. */ - throwArgs *exceptions; /* The exceptions. */ - codeBlock *methodcode; /* Method code. */ - char *prehook; /* The pre-hook name. */ - char *posthook; /* The post-hook name. */ - struct _ctorDef *next; /* Next in the list. */ -} ctorDef; - - -/* An enumerated type member definition. */ - -typedef struct _enumMemberDef { - nameDef *pyname; /* The Python name. */ - char *cname; /* The C/C++ name. */ - struct _enumDef *ed; /* The enclosing enum. */ - struct _enumMemberDef *next; /* Next in the list. */ -} enumMemberDef; - - -/* An enumerated type definition. */ - -typedef struct _enumDef { - int enumflags; /* The enum flags. */ - scopedNameDef *fqcname; /* The name (may be NULL). */ - nameDef *pyname; /* The Python name (may be NULL). */ - int enumnr; /* The enum number. */ - struct _classDef *ecd; /* The enclosing class. */ - struct _classDef *pcd; /* The publishing class. */ - moduleDef *module; /* The owning module. */ - enumMemberDef *members; /* The list of members. */ - struct _memberDef *slots; /* The list of slots. */ - struct _overDef *overs; /* The list of slot overloads. */ - struct _enumDef *next; /* Next in the list. */ -} enumDef; - - -/* An member function definition. */ - -typedef struct _memberDef { - nameDef *pyname; /* The Python name. */ - int memberflags; /* The member flags. */ - slotType slot; /* The slot type. */ - moduleDef *module; /* The owning module. */ - struct _memberDef *next; /* Next in the list. */ -} memberDef; - - -/* A list of visible member functions. */ - -typedef struct _visibleList { - memberDef *m; /* The member definition. */ - struct _classDef *cd; /* The class. */ - struct _visibleList *next; /* Next in the list. */ -} visibleList; - - -/* An entry in a linked class list. */ - -typedef struct _classList { - struct _classDef *cd; /* The class itself. */ - struct _classList *next; /* Next in the list. */ -} classList; - - -/* A virtual overload definition. */ - -typedef struct _virtOverDef { - overDef o; /* The overload. */ - struct _classDef *scope; /* The overload scope. */ - struct _virtOverDef *next; /* Next in the list. */ -} virtOverDef; - - -/* A class that appears in a class's hierarchy. */ - -typedef struct _mroDef { - struct _classDef *cd; /* The class. */ - int mroflags; /* The hierarchy flags. */ - struct _mroDef *next; /* The next in the list. */ -} mroDef; - - -/* A class definition. */ - -typedef struct _classDef { - int classflags; /* The class flags. */ - int userflags; /* The user type flags. */ - int classnr; /* The class number. */ - char *pyname; /* The Python name. */ - ifaceFileDef *iff; /* The interface file. */ - struct _classDef *ecd; /* The enclosing scope. */ - struct _classDef *real; /* The real class if this is a proxy or extender. */ - nodeDef *node; /* Position in class tree. */ - classList *supers; /* The parent classes. */ - mroDef *mro; /* The super-class hierarchy. */ - templateDef *td; /* The instantiated template. */ - ctorDef *ctors; /* The constructors. */ - ctorDef *defctor; /* The default ctor. */ - codeBlock *dealloccode; /* Handwritten dealloc code. */ - codeBlock *dtorcode; /* Handwritten dtor code. */ - throwArgs *dtorexceptions; /* The dtor exceptions. */ - memberDef *members; /* The member functions. */ - overDef *overs; /* The overloads. */ - argList *casts; /* The operator casts. */ - virtOverDef *vmembers; /* The virtual members. */ - visibleList *visible; /* The visible members. */ - codeBlock *cppcode; /* Class C++ code. */ - codeBlock *hdrcode; /* Class header code. */ - codeBlock *convtosubcode; /* Convert to sub C++ code. */ - struct _classDef *subbase; /* Sub-class base class. */ - codeBlock *convtocode; /* Convert to C++ code. */ - codeBlock *travcode; /* Traverse code. */ - codeBlock *clearcode; /* Clear code. */ - codeBlock *readbufcode; /* Read buffer code. */ - codeBlock *writebufcode; /* Write buffer code. */ - codeBlock *segcountcode; /* Segment count code. */ - codeBlock *charbufcode; /* Character buffer code. */ - struct _classDef *next; /* Next in the list. */ -} classDef; - - -/* A class template definition. */ - -typedef struct _classTmplDef { - signatureDef sig; /* The template arguments. */ - classDef *cd; /* The class itself. */ - struct _classTmplDef *next; /* The next in the list. */ -} classTmplDef; - - -/* A mapped type template definition. */ - -typedef struct _mappedTypeTmplDef { - signatureDef sig; /* The template arguments. */ - mappedTypeDef *mt; /* The mapped type itself. */ - struct _mappedTypeTmplDef *next; /* The next in the list. */ -} mappedTypeTmplDef; - - -/* The parse tree corresponding to the specification file. */ - -typedef struct { - moduleDef *module; /* This module. */ - moduleDef *modules; /* The list of modules. */ - nameDef *namecache; /* The name cache. */ - ifaceFileDef *ifacefiles; /* The list of interface files. */ - classDef *classes; /* The list of classes. */ - classTmplDef *classtemplates; /* The list of class templates. */ - classDef *proxies; /* The list of proxy classes. */ - exceptionDef *exceptions; /* The list of exceptions. */ - mappedTypeDef *mappedtypes; /* The mapped types. */ - mappedTypeTmplDef *mappedtypetemplates; /* The list of mapped type templates. */ - int qobjclass; /* TQObject class, -1 if none. */ - enumDef *enums; /* List of enums. */ - varDef *vars; /* List of variables. */ - memberDef *othfuncs; /* List of other functions. */ - overDef *overs; /* Global overloads. */ - typedefDef *typedefs; /* List of typedefs. */ - codeBlock *copying; /* Software license. */ - codeBlock *exphdrcode; /* Exported header code. */ - codeBlock *hdrcode; /* Header code. */ - codeBlock *cppcode; /* Global C++ code. */ - codeBlock *docs; /* Documentation. */ - codeBlock *preinitcode; /* Pre-initialisation code. */ - codeBlock *postinitcode; /* Post-initialisation code. */ - codeBlock *unitcode; /* Compilation unit code. */ - ifaceFileList *used; /* Interface files used. */ - int sigslots; /* Set if signals or slots are used. */ - int genc; /* Set if we are generating C code. */ - struct _stringList *options; /* The list of options. */ -} sipSpec; - - -/* A list of strings. */ - -typedef struct _stringList { - const char *s; /* The string. */ - struct _stringList *next; /* The next in the list. */ -} stringList; - - -/* File specific context information for the parser. */ - -typedef struct _parserContext { - int ifdepth; /* The depth of nested if's. */ - moduleDef *prevmod; /* The previous module. */ -} parserContext; - - -extern char *sipVersion; /* The version of SIP. */ -extern stringList *includeDirList; /* The include directory list for SIP files. */ - - -void parse(sipSpec *,FILE *,char *,stringList *,stringList *); -void parserEOF(char *,parserContext *); -void transform(sipSpec *); -void generateCode(sipSpec *,char *,char *,char *,char *,int,int,int,int,stringList *); -void generateAPI(sipSpec *pt, const char *apiFile); -void generateXML(sipSpec *pt, const char *xmlFile); -void generateExpression(valueDef *vd, FILE *fp); -void warning(char *,...); -void fatal(char *,...); -void fatalScopedName(scopedNameDef *); -void setInputFile(FILE *,char *,parserContext *,int); -void *sipMalloc(size_t); -char *sipStrdup(char *); -char *concat(const char *, ...); -void append(char **,char *); -ifaceFileList *addToUsedList(ifaceFileList **, ifaceFileDef *); -int excludedFeature(stringList *,qualDef *); -int sameSignature(signatureDef *,signatureDef *,int); -int sameTemplateSignature(signatureDef *sd1, signatureDef *sd2, int deep); -int sameScopedName(scopedNameDef *,scopedNameDef *); -int sameBaseType(argDef *,argDef *); -char *scopedNameTail(scopedNameDef *); -scopedNameDef *text2scopePart(char *); -scopedNameDef *copyScopedName(scopedNameDef *); -void appendScopedName(scopedNameDef **,scopedNameDef *); -void freeScopedName(scopedNameDef *); -void appendToClassList(classList **,classDef *); -void prcode(FILE *fp, const char *fmt, ...); -void prOverloadName(FILE *fp, overDef *od); -void prScopedPythonName(FILE *fp, classDef *scope, const char *pyname); -void prOverloadDecl(FILE *fp, overDef *od, int defval); -int isIntReturnSlot(memberDef *md); -int isLongReturnSlot(memberDef *md); -int isVoidReturnSlot(memberDef *md); -int isNumberSlot(memberDef *md); -int isRichCompareSlot(memberDef *md); -mappedTypeDef *allocMappedType(argDef *type); -void appendString(stringList **headp, const char *s); -void appendTypeStrings(scopedNameDef *ename, signatureDef *patt, signatureDef *src, signatureDef *known, scopedNameDef **names, scopedNameDef **values); -codeBlock *templateCode(sipSpec *pt, ifaceFileList **used, codeBlock *ocb, scopedNameDef *names, scopedNameDef *values); -ifaceFileDef *findIfaceFile(sipSpec *pt, moduleDef *mod, scopedNameDef *fqname, ifaceFileType iftype, argDef *ad); -int optNoEmitters(sipSpec *pt); -int optRegisterTypes(sipSpec *pt); -int optQ_OBJECT4(sipSpec *pt); -void yywarning(char *); - - -/* These are only here because bison publically references them. */ - -/* Represent a set of option flags. */ - -#define MAX_NR_FLAGS 5 - -typedef enum { - bool_flag, - string_flag, - name_flag, - opt_name_flag, - integer_flag -} flagType; - -typedef struct { - char *fname; /* The flag name. */ - flagType ftype; /* The flag type. */ - union { /* The flag value. */ - char *sval; /* A string value. */ - long ival; /* An integer value. */ - } fvalue; -} optFlag; - -typedef struct { - int nrFlags; /* The number of flags. */ - optFlag flags[MAX_NR_FLAGS]; /* Each flag. */ -} optFlags; - -#endif diff --git a/python/sip/sipgen/sipgen.sbf b/python/sip/sipgen/sipgen.sbf deleted file mode 100644 index 911b216b..00000000 --- a/python/sip/sipgen/sipgen.sbf +++ /dev/null @@ -1,16 +0,0 @@ -# This is the build file for the code generator. -# -# Copyright (c) 2007 -# Riverbank Computing Limited <info@riverbankcomputing.co.uk> -# -# This file is part of SIP. -# -# This copy of SIP is licensed for use under the terms of the SIP License -# Agreement. See the file LICENSE for more details. -# -# SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -target = sip -sources = main.c transform.c gencode.c export.c heap.c parser.c lexer.c -headers = sip.h parser.h diff --git a/python/sip/sipgen/transform.c b/python/sip/sipgen/transform.c deleted file mode 100644 index d19fb719..00000000 --- a/python/sip/sipgen/transform.c +++ /dev/null @@ -1,2856 +0,0 @@ -/* - * The parse tree transformation module for SIP. - * - * Copyright (c) 2007 - * Riverbank Computing Limited <info@riverbankcomputing.co.uk> - * - * This file is part of SIP. - * - * This copy of SIP is licensed for use under the terms of the SIP License - * Agreement. See the file LICENSE for more details. - * - * SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - - -#include <stddef.h> -#include <string.h> -#include <stdlib.h> - -#include "sip.h" - - -static int samePythonSignature(signatureDef *sd1, signatureDef *sd2); -static int nextSignificantArg(signatureDef *sd, int a); -static int sameArgType(argDef *a1, argDef *a2, int strict); -static int supportedType(classDef *,overDef *,argDef *,int); -static int sameOverload(overDef *od1,overDef *od2); -static int sameVirtualHandler(virtHandlerDef *vhd1,virtHandlerDef *vhd2); -static int isSubClass(classDef *cc,classDef *pc); -static void setAllImports(sipSpec *pt, moduleDef *mod); -static void addUniqueModule(moduleDef *mod, moduleDef *imp); -static void ensureInput(classDef *,overDef *,argDef *); -static void defaultInput(argDef *); -static void defaultOutput(classDef *,overDef *,argDef *); -static void assignClassNrs(sipSpec *,moduleDef *,nodeDef *); -static void assignEnumNrs(sipSpec *pt); -static void positionClass(classDef *); -static void addNodeToParent(nodeDef *,classDef *); -static void addAutoOverload(sipSpec *,classDef *,overDef *); -static void ifaceFileIsUsed(sipSpec *, ifaceFileDef *, argDef *); -static void ifaceFilesAreUsed(sipSpec *, ifaceFileDef *, overDef *); -static void ifaceFilesAreUsedByMethod(sipSpec *, classDef *, memberDef *); -static void ifaceFilesAreUsedFromOther(sipSpec *pt, signatureDef *sd); -static void scopeDefaultValue(sipSpec *,classDef *,argDef *); -static void setHierarchy(sipSpec *,classDef *,classDef *,classList **); -static void transformCtors(sipSpec *,classDef *); -static void transformCasts(sipSpec *,classDef *); -static void addDefaultCopyCtor(classDef *); -static void transformOverloads(sipSpec *,classDef *,overDef *); -static void transformVariableList(sipSpec *); -static void transformMappedTypes(sipSpec *); -static void getVisibleMembers(sipSpec *,classDef *); -static void getVirtuals(sipSpec *pt,classDef *cd); -static void getClassVirtuals(classDef *,classDef *); -static void transformTypedefs(sipSpec *pt); -static void resolveMappedTypeTypes(sipSpec *,mappedTypeDef *); -static void resolveCtorTypes(sipSpec *,classDef *,ctorDef *); -static void resolveFuncTypes(sipSpec *,moduleDef *,classDef *,overDef *); -static void resolvePySigTypes(sipSpec *,moduleDef *,classDef *,overDef *,signatureDef *,int); -static void resolveVariableType(sipSpec *,varDef *); -static void fatalNoDefinedType(scopedNameDef *); -static void getBaseType(sipSpec *,moduleDef *,classDef *,argDef *); -static void searchScope(sipSpec *,classDef *,scopedNameDef *,argDef *); -static void searchMappedTypes(sipSpec *,scopedNameDef *,argDef *); -static void searchTypedefs(sipSpec *,scopedNameDef *,argDef *); -static void searchEnums(sipSpec *,scopedNameDef *,argDef *); -static void searchClasses(sipSpec *,moduleDef *mod,scopedNameDef *,argDef *); -static void appendToMRO(mroDef *,mroDef ***,classDef *); -static void moveClassCasts(sipSpec *pt, classDef *cd); -static void moveGlobalSlot(sipSpec *pt, memberDef *gmd); -static void filterVirtualHandlers(moduleDef *mod); -static ifaceFileDef *getIfaceFile(argDef *ad); -static mappedTypeDef *instantiateMappedTypeTemplate(sipSpec *pt, moduleDef *mod, mappedTypeTmplDef *mtt, argDef *type); -static classDef *getProxy(sipSpec *pt, classDef *cd); - - -/* - * Transform the parse tree. - */ - -void transform(sipSpec *pt) -{ - moduleDef *mod; - moduleListDef *mld; - classDef *cd, *rev, **tail; - classList *newl; - overDef *od; - mappedTypeDef *mtd; - virtHandlerDef *vhd; - int nr; - - if (pt -> module -> name == NULL) - fatal("No %%Module has been specified for the module\n"); - - /* - * The class list has the main module's classes at the front and the - * ones from the module at the most nested %Import at the end. This - * affects some of the following algorithms, eg. when assigning class - * numbers. We have to have consistency whenever a module is used. To - * achieve this we reverse the order of the classes. - */ - rev = NULL; - cd = pt -> classes; - - while (cd != NULL) - { - classDef *next = cd -> next; - - cd -> next = rev; - rev = cd; - - /* - * Mark any TQObject class. This flag will ripple through all derived - * classes when we set the hierarchy. - */ - if (strcmp(classBaseName(cd), "TQObject") == 0) - setIsQObjectSubClass(cd); - - cd = next; - } - - pt -> classes = rev; - - /* Build the list of all imports for each module. */ - for (mod = pt->modules; mod != NULL; mod = mod->next) - setAllImports(pt, mod); - - /* Check each class has been defined. */ - for (cd = pt -> classes; cd != NULL; cd = cd -> next) - if (cd -> iff -> module == NULL) - { - fatalScopedName(classFQCName(cd)); - fatal(" has not been defined\n"); - } - - /* - * Set the super-class hierarchy for each class and re-order the list - * of classes so that no class appears before a super class or an - * enclosing scope class. - */ - newl = NULL; - - for (cd = pt -> classes; cd != NULL; cd = cd -> next) - setHierarchy(pt,cd,cd,&newl); - - /* Replace the old list with the new one. */ - tail = &pt -> classes; - - while (newl != NULL) - { - classList *cl = newl; - - *tail = cl -> cd; - tail = &cl -> cd -> next; - - newl = cl -> next; - free(cl); - } - - *tail = NULL; - - /* Transform typedefs, variables and global functions. */ - transformTypedefs(pt); - transformVariableList(pt); - transformOverloads(pt,NULL,pt -> overs); - - /* Transform class ctors, functions and casts. */ - for (cd = pt -> classes; cd != NULL; cd = cd -> next) - { - transformCtors(pt,cd); - - if (!pt -> genc) - { - transformOverloads(pt,cd,cd -> overs); - transformCasts(pt, cd); - } - } - - /* Transform mapped types based on templates. */ - transformMappedTypes(pt); - - /* Handle default ctors now that the argument types are resolved. */ - if (!pt -> genc) - for (cd = pt -> classes; cd != NULL; cd = cd -> next) - if (!noDefaultCtors(cd) && !isOpaque(cd) && cd->iff->type != namespace_iface) - addDefaultCopyCtor(cd); - - /* - * Go through each class and add it to it's defining module's tree of - * classes. The tree reflects the namespace hierarchy. - */ - for (cd = pt -> classes; cd != NULL; cd = cd -> next) - addNodeToParent(&cd -> iff -> module -> root,cd); - - for (cd = pt -> classes; cd != NULL; cd = cd -> next) - positionClass(cd); - - /* Assign module specific class numbers for all modules. */ - for (mod = pt->modules; mod != NULL; mod = mod->next) - assignClassNrs(pt, mod, &mod->root); - - /* Assign module specific enum numbers for all enums. */ - assignEnumNrs(pt); - - /* Add any automatically generated methods. */ - for (cd = pt -> classes; cd != NULL; cd = cd -> next) - for (od = cd -> overs; od != NULL; od = od -> next) - if (isAutoGen(od)) - addAutoOverload(pt,cd,od); - - /* Allocate mapped types numbers. */ - for (mtd = pt -> mappedtypes; mtd != NULL; mtd = mtd -> next) - mtd -> mappednr = mtd -> iff -> module -> nrmappedtypes++; - - /* - * Move casts and slots around to their correct classes (if in the same - * module) or create proxies for them (if cross-module). - */ - if (!pt -> genc) - { - memberDef *md; - - for (cd = pt -> classes; cd != NULL; cd = cd -> next) - if (cd->iff->module == pt->module) - moveClassCasts(pt, cd); - - for (md = pt->othfuncs; md != NULL; md = md->next) - if (md->slot != no_slot && md->module == pt->module) - moveGlobalSlot(pt, md); - } - - /* Generate the different class views. */ - for (cd = pt -> classes; cd != NULL; cd = cd -> next) - { - ifaceFileDef *iff = cd -> iff; - - if (iff -> type == class_iface) - { - /* Get the list of visible member functions. */ - getVisibleMembers(pt,cd); - - /* Get the virtual members. */ - if (hasShadow(cd)) - getVirtuals(pt,cd); - } - else if (iff -> type == namespace_iface && iff -> module == pt -> module) - { - memberDef *md; - - for (md = cd -> members; md != NULL; md = md -> next) - ifaceFilesAreUsedByMethod(pt, cd, md); - } - } - - /* - * In case there are any global functions that need external interface - * files. - */ - for (od = pt -> overs; od != NULL; od = od -> next) - if (od->common->module == pt->module) - ifaceFilesAreUsedFromOther(pt, &od->pysig); - - /* - * Remove redundant virtual handlers. It's important that earlier, - * ie. those at the deepest level of %Import, are done first. - */ - nr = 0; - - for (mld = pt->module->allimports; mld != NULL; mld = mld->next) - { - mld->module->modulenr = nr++; - filterVirtualHandlers(mld->module); - } - - pt->module->modulenr = nr; - filterVirtualHandlers(pt->module); - - /* - * Make sure we have the interface files for all types from other modules - * that are used in virtual handlers implemented in this module. - */ - for (vhd = pt->module->virthandlers; vhd != NULL; vhd = vhd->next) - if (!isDuplicateVH(vhd)) - ifaceFilesAreUsedFromOther(pt, vhd->cppsig); - - /* Update proxies with some information from the real classes. */ - for (cd = pt->proxies; cd != NULL; cd = cd->next) - cd->classnr = cd->real->classnr; -} - - -/* - * Set the list of all imports for a module. The list is ordered so that a - * module appears before any module that imports it. - */ -static void setAllImports(sipSpec *pt, moduleDef *mod) -{ - moduleListDef *mld; - - /* - * Handle the trivial case where there are no imports, or the list has - * already been done. - */ - if (mod->imports == NULL || mod->allimports != NULL) - return; - - /* Make sure all the direct imports are done first. */ - for (mld = mod->imports; mld != NULL; mld = mld->next) - setAllImports(pt, mld->module); - - /* - * Now build the list from our direct imports lists but ignoring - * duplicates. - */ - for (mld = mod->imports; mld != NULL; mld = mld->next) - { - moduleListDef *amld; - - for (amld = mld->module->allimports; amld != NULL; amld = amld->next) - addUniqueModule(mod, amld->module); - - addUniqueModule(mod, mld->module); - } -} - - -/* - * Append a module to the list of all imported modules if it isn't already - * there. - */ -static void addUniqueModule(moduleDef *mod, moduleDef *imp) -{ - moduleListDef **tail; - - for (tail = &mod->allimports; *tail != NULL; tail = &(*tail)->next) - if ((*tail)->module == imp) - return; - - *tail = sipMalloc(sizeof (moduleListDef)); - - (*tail)->module = imp; - (*tail)->next = NULL; -} - - -/* - * Move any class casts to its correct class, or publish as a ctor extender. - */ -static void moveClassCasts(sipSpec *pt, classDef *cd) -{ - argList *al; - - for (al = cd->casts; al != NULL; al = al->next) - { - classDef *dcd = al->arg.u.cd; - ctorDef *ct, **ctp; - argDef *ad; - - /* - * If the destination class is in a different module then use - * a proxy. - */ - if (dcd->iff->module != pt->module) - dcd = getProxy(pt, dcd); - - /* Create the new ctor. */ - ct = sipMalloc(sizeof (ctorDef)); - - ct->ctorflags = SECT_IS_PUBLIC | CTOR_CAST; - ct->cppsig = &ct->pysig; - ct->exceptions = NULL; - ct->methodcode = NULL; - ct->prehook = NULL; - ct->posthook = NULL; - ct->next = NULL; - - /* Add the source class as the only argument. */ - ad = &ct->pysig.args[0]; - - ad->atype = class_type; - ad->name = NULL; - ad->argflags = ARG_IN | (al->arg.argflags & (ARG_IS_REF | ARG_IS_CONST)); - ad->nrderefs = al->arg.nrderefs; - ad->defval = NULL; - ad->u.cd = cd; - - ifaceFileIsUsed(pt, dcd->iff, ad); - - ct->pysig.nrArgs = 1; - - /* Append it to the list. */ - for (ctp = &dcd->ctors; *ctp != NULL; ctp = &(*ctp)->next) - if (sameSignature(&(*ctp)->pysig, &ct->pysig, FALSE)) - { - fatal("operator "); - fatalScopedName(classFQCName(dcd)); - fatal("::"); - fatalScopedName(classFQCName(dcd)); - fatal("("); - fatalScopedName(classFQCName(cd)); - fatal(") already defined\n"); - } - - *ctp = ct; - } -} - - -/* - * If possible, move a global slot to its correct class. - */ -static void moveGlobalSlot(sipSpec *pt, memberDef *gmd) -{ - overDef **odp = &pt->overs, *od; - - while ((od = *odp) != NULL) - { - int second; - argDef *arg0, *arg1; - memberDef *md, **mdhead; - overDef **odhead; - moduleDef *mod; - nameDef *nd; - - if (od->common != gmd) - { - odp = &od->next; - continue; - } - - /* - * We know that the slot has the right number of arguments, but the - * first or second one needs to be a class or enum defined in the same - * module. Otherwise we leave it as it is and publish it as a slot - * extender. - */ - arg0 = &od->pysig.args[0]; - arg1 = &od->pysig.args[1]; - - second = FALSE; - nd = NULL; - - if (arg0->atype == class_type) - { - mdhead = &arg0->u.cd->members; - odhead = &arg0->u.cd->overs; - mod = arg0->u.cd->iff->module; - } - else if (arg0->atype == enum_type) - { - mdhead = &arg0->u.ed->slots; - odhead = &arg0->u.ed->overs; - mod = arg0->u.ed->module; - nd = arg0->u.ed->pyname; - } - else if (arg1->atype == class_type) - { - mdhead = &arg1->u.cd->members; - odhead = &arg1->u.cd->overs; - mod = arg1->u.cd->iff->module; - second = TRUE; - } - else if (arg1->atype == enum_type) - { - mdhead = &arg1->u.ed->slots; - odhead = &arg1->u.ed->overs; - mod = arg1->u.ed->module; - nd = arg1->u.ed->pyname; - second = TRUE; - } - else - { - fatal("One of the arguments of "); - prOverloadName(stderr, od); - fatal(" must be a class or enum\n"); - } - - /* - * For rich comparisons the first argument must be a class or - * an enum. For cross-module slots then it may only be a - * class. (This latter limitation is artificial, but is - * unlikely to be a problem in practice.) - */ - if (isRichCompareSlot(gmd)) - { - if (second) - { - fatal("The first argument of "); - prOverloadName(stderr, od); - fatal(" must be a class or enum\n"); - } - - if (mod != gmd->module && arg0->atype == enum_type) - { - fatal("The first argument of "); - prOverloadName(stderr, od); - fatal(" must be a class\n"); - } - } - - if (mod != gmd->module) - { - if (isRichCompareSlot(gmd)) - { - classDef *pcd = getProxy(pt, arg0->u.cd); - memberDef *pmd; - overDef *pod; - - /* Create a new proxy member if needed. */ - for (pmd = pcd->members; pmd != NULL; pmd = pmd->next) - if (pmd->slot == gmd->slot) - break; - - if (pmd == NULL) - { - pmd = sipMalloc(sizeof (memberDef)); - - pmd->pyname = gmd->pyname; - pmd->memberflags = 0; - pmd->slot = gmd->slot; - pmd->module = mod; - pmd->next = pcd->members; - - pcd->members = pmd; - } - - /* Add the proxy overload. */ - pod = sipMalloc(sizeof (overDef)); - - *pod = *od; - pod->common = pmd; - pod->next = pcd->overs; - - pcd->overs = pod; - - /* Remove the first argument. */ - pod->pysig.args[0] = pod->pysig.args[1]; - pod->pysig.nrArgs = 1; - - /* Remove from the list. */ - *odp = od->next; - } - else - odp = &od->next; - - continue; - } - - /* Remove from the list. */ - *odp = od->next; - - /* - * The only time we need the name of an enum is when it has - * slots. - */ - if (nd != NULL) - setIsUsedName(nd); - - /* See if there is already a member or create a new one. */ - for (md = *mdhead; md != NULL; md = md->next) - if (md->slot == gmd->slot) - break; - - if (md == NULL) - { - md = sipMalloc(sizeof (memberDef)); - - *md = *gmd; - - md->module = mod; - md->next = *mdhead; - - *mdhead = md; - } - - /* Move the overload. */ - setIsPublic(od); - od->common = md; - od->next = *odhead; - - *odhead = od; - - /* Remove the first argument of comparison operators. */ - if (isRichCompareSlot(md)) - { - /* Remember if the argument was a pointer. */ - if (arg0->nrderefs > 0) - setDontDerefSelf(od); - - *arg0 = *arg1; - od->pysig.nrArgs = 1; - } - } -} - - -/* - * Create a proxy for a class if it doesn't already exist. Proxies are used as - * containers for cross-module extenders. - */ -static classDef *getProxy(sipSpec *pt, classDef *cd) -{ - classDef *pcd; - - for (pcd = pt->proxies; pcd != NULL; pcd = pcd->next) - if (pcd->iff == cd->iff) - return pcd; - - pcd = sipMalloc(sizeof (classDef)); - - pcd->classflags = 0; - pcd->userflags = 0; - pcd->classnr = -1; - pcd->pyname = cd->pyname; - pcd->iff = cd->iff; - pcd->ecd = cd->ecd; - pcd->real = cd; - pcd->node = NULL; - pcd->supers = cd->supers; - pcd->mro = cd->mro; - pcd->td = NULL; - pcd->ctors = NULL; - pcd->defctor = NULL; - pcd->dealloccode = NULL; - pcd->dtorcode = NULL; - pcd->dtorexceptions = NULL; - pcd->members = NULL; - pcd->overs = NULL; - pcd->casts = NULL; - pcd->vmembers = NULL; - pcd->visible = NULL; - pcd->cppcode = NULL; - pcd->hdrcode = NULL; - pcd->convtosubcode = NULL; - pcd->subbase = NULL; - pcd->convtocode = NULL; - pcd->travcode = NULL; - pcd->clearcode = NULL; - pcd->readbufcode = NULL; - pcd->writebufcode = NULL; - pcd->segcountcode = NULL; - pcd->charbufcode = NULL; - pcd->next = pt->proxies; - - pt->proxies = pcd; - - return pcd; -} - - -/* - * Go through the virtual handlers filtering those that can duplicate earlier - * ones. Make sure each virtual is numbered within its module, and according - * to their position in the list (ignoring duplicates). - */ -static void filterVirtualHandlers(moduleDef *mod) -{ - virtHandlerDef *vhd; - - for (vhd = mod->virthandlers; vhd != NULL; vhd = vhd->next) - { - virtHandlerDef *best, *best_thismod, *hd; - - best = best_thismod = NULL; - - /* - * If this has handwritten code then we will want to use it. - * Otherwise, look for a handler in earlier modules. - */ - if (vhd->virtcode == NULL) - { - moduleListDef *mld; - - for (mld = mod->allimports; mld != NULL && mld->module != mod; mld = mld->next) - { - for (hd = mld->module->virthandlers; hd != NULL; hd = hd->next) - if (sameVirtualHandler(vhd, hd)) - { - best = hd; - break; - } - - /* - * No need to check later modules as this will either be the - * right one, or a duplicate of the right one. - */ - if (best != NULL) - break; - } - } - - /* - * Find the best candidate in this module in case we want to give it - * our handwritten code. - */ - for (hd = mod->virthandlers; hd != vhd; hd = hd->next) - if (sameVirtualHandler(vhd, hd)) - { - best_thismod = hd; - break; - } - - /* - * We don't use this one if it doesn't have virtual code and there is - * an alternative, or if it does have virtual code and there is already - * an alternative in the same module which doesn't have virtual code. - */ - if ((vhd->virtcode == NULL && (best != NULL || best_thismod != NULL)) || - (vhd->virtcode != NULL && best_thismod != NULL && best_thismod->virtcode == NULL)) - { - virtHandlerDef *saved; - - /* - * If the alternative is in the same module and we have virtual - * code then give it to the alternative. Note that there is a bug - * here. If there are three handlers, the first without code and - * the second and third with code then which code is transfered to - * the first is down to luck. We should really only transfer code - * to methods that are known to be re-implementations - just having - * the same signature isn't enough. - */ - if (best_thismod != NULL) - { - if (best_thismod->virtcode == NULL && vhd->virtcode != NULL) - { - best_thismod->virtcode = vhd->virtcode; - resetIsDuplicateVH(best_thismod); - } - - best = best_thismod; - } - - /* Use the better one in place of this one. */ - saved = vhd->next; - *vhd = *best; - setIsDuplicateVH(vhd); - vhd->next = saved; - } - else - vhd->virthandlernr = mod->nrvirthandlers++; - } -} - - -/* - * Add an overload that is automatically generated (typically by Qt's moc). - */ -static void addAutoOverload(sipSpec *pt,classDef *autocd,overDef *autood) -{ - classDef *cd; - - /* Find every class that has this one in its hierarchy. */ - - for (cd = pt -> classes; cd != NULL; cd = cd -> next) - { - mroDef *mro; - - if (cd == autocd) - continue; - - for (mro = cd -> mro; mro != NULL; mro = mro -> next) - if (mro -> cd == autocd) - { - memberDef *md; - overDef *od; - - /* Another overload may already exist. */ - - for (md = cd -> members; md != NULL; md = md -> next) - if (md -> pyname == autood -> common -> pyname) - break; - - if (md == NULL) - { - md = sipMalloc(sizeof (memberDef)); - - md -> pyname = autood -> common -> pyname; - md -> memberflags = autood -> common -> memberflags; - md -> slot = autood -> common -> slot; - md -> module = cd -> iff -> module; - md -> next = cd -> members; - cd -> members = md; - } - - od = sipMalloc(sizeof (overDef)); - - *od = *autood; - od -> common = md; - od -> next = cd -> overs; - cd -> overs = od; - - resetIsAutoGen(od); - - if (cd -> iff -> module == pt -> module) - setIsUsedName(md -> pyname); - - break; - } - } -} - - -/* - * Set the complete hierarchy for a class. - */ -static void setHierarchy(sipSpec *pt,classDef *base,classDef *cd, - classList **head) -{ - mroDef **tailp = &cd -> mro; - - /* See if it has already been done. */ - if (cd -> mro != NULL) - return; - - if (cd -> ecd != NULL) - setHierarchy(pt,base,cd -> ecd,head); - - if (cd -> iff -> type == class_iface) - { - classList *cl; - - /* The first thing is itself. */ - appendToMRO(cd -> mro,&tailp,cd); - - if (cd -> convtosubcode != NULL) - cd -> subbase = cd; - - /* Now do it's superclasses. */ - for (cl = cd -> supers; cl != NULL; cl = cl -> next) - { - mroDef *mro; - - /* - * Make sure the super-class's hierarchy has been done. - */ - setHierarchy(pt,base,cl -> cd,head); - - /* Append the super-classes hierarchy. */ - for (mro = cl -> cd -> mro; mro != NULL; mro = mro -> next) - { - appendToMRO(cd -> mro,&tailp,mro -> cd); - - /* - * If the super-class is a TQObject sub-class then this one is - * as well. - */ - if (isQObjectSubClass(mro->cd)) - setIsQObjectSubClass(cd); - - /* - * If the super-class has a shadow then this one should have - * one as well. - */ - if (hasShadow(mro->cd)) - setHasShadow(cd); - - /* - * Ensure that the sub-class base class is the furthest up the - * hierarchy. - */ - if (mro->cd->subbase != NULL) - cd->subbase = mro->cd->subbase; - } - } - } - - /* - * We can't have a shadow if the specification is incomplete, there is - * a private dtor, there are no none-private ctors or there are private - * abstract methods. - */ - if (isIncomplete(cd) || isPrivateDtor(cd) || !canCreate(cd)) - resetHasShadow(cd); - else - { - overDef *od; - - /* - * Note that we should be able to provide better support for - * abstract private methods than we do at the moment. - */ - for (od = cd->overs; od != NULL; od = od->next) - if (isAbstract(od) && isPrivate(od)) - { - resetHasShadow(cd); - - /* - * It also means we cannot create an instance - * from Python. - */ - resetCanCreate(cd); - - break; - } - } - - /* Add it to the new list. */ - appendToClassList(head,cd); -} - - -/* - * Append a class definition to an mro list - */ -static void appendToMRO(mroDef *head,mroDef ***tailp,classDef *cd) -{ - mroDef *mro, *new; - - new = sipMalloc(sizeof (mroDef)); - - new -> cd = cd; - new -> mroflags = 0; - new -> next = NULL; - - /* See if it is a duplicate. */ - - for (mro = head; mro != NULL; mro = mro -> next) - if (mro -> cd == cd) - { - setIsDuplicateSuper(new); - - if (!isDuplicateSuper(mro)) - setHasDuplicateSuper(mro); - - break; - } - - /* Append to the list and update the tail pointer. */ - **tailp = new; - *tailp = &new -> next; -} - - -/* - * Get the base types for all typedefs. - */ -static void transformTypedefs(sipSpec *pt) -{ - typedefDef *td; - - for (td = pt -> typedefs; td != NULL; td = td -> next) - getBaseType(pt, td->module, td -> ecd, &td -> type); -} - - -/* - * Transform the data types for mapped types based on a template. - */ -static void transformMappedTypes(sipSpec *pt) -{ - mappedTypeDef *mt; - - for (mt = pt -> mappedtypes; mt != NULL; mt = mt -> next) - { - /* Nothing to do if this isn't template based. */ - - if (mt -> type.atype == template_type) - resolveMappedTypeTypes(pt,mt); - } -} - - -/* - * Transform the data types for a list of ctors. - */ -static void transformCtors(sipSpec *pt, classDef *cd) -{ - ctorDef *ct; - - for (ct = cd->ctors; ct != NULL; ct = ct->next) - { - ctorDef *prev; - - resolveCtorTypes(pt, cd, ct); - - /* - * Now check that the Python signature doesn't conflict with an - * earlier one. - */ - for (prev = cd->ctors; prev != ct; prev = prev->next) - if (samePythonSignature(&prev->pysig, &ct->pysig)) - { - fatalScopedName(classFQCName(cd)); - fatal(" has ctors with the same Python signature\n"); - } - } -} - - -/* - * Transform the data type for a list of casts. - */ -static void transformCasts(sipSpec *pt, classDef *cd) -{ - argList *al; - - for (al = cd->casts; al != NULL; al = al->next) - { - getBaseType(pt, cd->iff->module, cd, &al->arg); - - if (al->arg.atype != class_type) - { - fatalScopedName(classFQCName(cd)); - fatal(" operator cast must be to a class\n"); - } - } -} - - -/* - * Add a default copy ctor is required. - */ -static void addDefaultCopyCtor(classDef *cd) -{ - ctorDef *copyct; - mroDef *mro; - - /* See if there is a private copy ctor in the hierarchy. */ - - copyct = NULL; - - for (mro = cd -> mro; mro != NULL; mro = mro -> next) - { - ctorDef *ct; - - if (isDuplicateSuper(mro)) - continue; - - for (ct = mro -> cd -> ctors; ct != NULL; ct = ct -> next) - { - argDef *ad = &ct -> pysig.args[0]; - - /* See if is a copy ctor. */ - if (ct -> pysig.nrArgs != 1 || ad -> nrderefs != 0 || - !isReference(ad) || ad -> atype != class_type || - ad -> u.cd != mro -> cd) - continue; - - /* Stop now if the copy ctor is private. */ - if (isPrivateCtor(ct)) - return; - - /* - * Remember if it's in the class we are dealing with. - */ - if (mro == cd -> mro) - copyct = ct; - - break; - } - } - - if (copyct == NULL) - { - ctorDef **tailp; - - /* Create a default public copy ctor. */ - - copyct = sipMalloc(sizeof (ctorDef)); - - copyct -> ctorflags = SECT_IS_PUBLIC; - copyct -> pysig.nrArgs = 1; - copyct -> pysig.args[0].name = "other"; - copyct -> pysig.args[0].atype = class_type; - copyct -> pysig.args[0].u.cd = cd; - copyct -> pysig.args[0].argflags = (ARG_IS_REF | ARG_IS_CONST | ARG_IN); - copyct -> pysig.args[0].nrderefs = 0; - copyct -> pysig.args[0].defval = NULL; - - copyct -> cppsig = ©ct -> pysig; - copyct -> exceptions = NULL; - copyct -> methodcode = NULL; - copyct -> prehook = NULL; - copyct -> posthook = NULL; - copyct -> next = NULL; - - /* Append it to the list. */ - for (tailp = &cd -> ctors; *tailp != NULL; tailp = &(*tailp) -> next) - ; - - *tailp = copyct; - } -} - - -/* - * Transform the data types for a list of overloads. - */ -static void transformOverloads(sipSpec *pt, classDef *scope, overDef *overs) -{ - overDef *od; - - for (od = overs; od != NULL; od = od -> next) - { - overDef *prev; - - resolveFuncTypes(pt, od->common->module, scope, od); - - /* - * Now check that the Python signature doesn't conflict with an - * earlier one. - */ - for (prev = overs; prev != od; prev = prev->next) - { - if (prev->common != od->common) - continue; - - if (samePythonSignature(&prev->pysig, &od->pysig)) - { - if (scope != NULL) - { - fatalScopedName(classFQCName(scope)); - fatal("::"); - } - - fatal("%s() has overloaded functions with the same Python signature\n", od->common->pyname->text); - } - } - } -} - - -/* - * Transform the data types for the variables. - */ -static void transformVariableList(sipSpec *pt) -{ - varDef *vd; - - for (vd = pt -> vars; vd != NULL; vd = vd -> next) - resolveVariableType(pt,vd); -} - - -/* - * Set the list of visible member functions for a class. - */ -static void getVisibleMembers(sipSpec *pt,classDef *cd) -{ - mroDef *mro; - - cd -> visible = NULL; - - for (mro = cd -> mro; mro != NULL; mro = mro -> next) - { - memberDef *md; - classDef *mrocd; - - if (isDuplicateSuper(mro)) - continue; - - mrocd = mro -> cd; - - /* - * If the base class is in the main module, see if it needs to - * publish any protected enums. - */ - if (cd -> iff -> module == pt -> module) - { - enumDef *ed; - - for (ed = pt -> enums; ed != NULL; ed = ed -> next) - { - /* Skip unless we are the publisher. */ - if (ed -> pcd != mrocd) - continue; - - /* - * If we are not in the main module then the - * base class must take over as the publisher. - */ - if (mrocd -> iff -> module != pt -> module) - ed -> pcd = cd; - } - } - - for (md = mrocd -> members; md != NULL; md = md -> next) - { - visibleList *vl; - - /* - * See if it is already in the list. This has the desired side - * effect of eliminating any functions that have an implementation - * closer to this class in the hierarchy. This is the only reason - * to define private functions. - */ - for (vl = cd->visible; vl != NULL; vl = vl->next) - if (vl->m->pyname == md->pyname) - break; - - /* See if it is a new member function. */ - - if (vl == NULL) - { - overDef *od; - - vl = sipMalloc(sizeof (visibleList)); - - vl -> m = md; - vl -> cd = mrocd; - vl -> next = cd -> visible; - - addToUsedList(&cd->iff->used, mrocd->iff); - - cd -> visible = vl; - - for (od = mrocd -> overs; od != NULL; od = od -> next) - if (od -> common == md) - { - if (isAbstract(od)) - setIsAbstractClass(cd); - - ifaceFilesAreUsed(pt, cd->iff, od); - - /* See if we need the name. */ - if (cd->iff->module != pt->module) - continue; - - if (isProtected(od) || (isSignal(od) && !optNoEmitters(pt))) - setIsUsedName(md->pyname); - } - } - } - } -} - - -/* - * Get all the virtuals for a particular class. - */ -static void getVirtuals(sipSpec *pt,classDef *cd) -{ - mroDef *mro; - virtOverDef *vod; - - for (mro = cd -> mro; mro != NULL; mro = mro -> next) - { - if (isDuplicateSuper(mro)) - continue; - - getClassVirtuals(cd,mro -> cd); - } - - /* - * Identify any re-implementations of virtuals. We have to do this for - * all classes, not just those in the main module. - */ - for (vod = cd -> vmembers; vod != NULL; vod = vod -> next) - { - overDef *od; - - for (od = cd->overs; od != NULL; od = od->next) - { - if (isVirtual(od)) - continue; - - if (strcmp(vod->o.cppname, od->cppname) == 0 && sameOverload(&vod->o, od)) - { - setIsVirtualReimp(od); - break; - } - } - - /* - * If this class is defined in the main module make sure we get - * the API files for all the visible virtuals. - */ - if (cd->iff->module == pt->module) - { - /* Make sure we get the name. */ - setIsUsedName(vod -> o.common -> pyname); - - ifaceFilesAreUsed(pt, cd->iff, &vod -> o); - } - } -} - - -/* - * Get the list of visible virtual functions for a class. - */ -static void getClassVirtuals(classDef *base,classDef *cd) -{ - overDef *od; - - for (od = cd -> overs; od != NULL; od = od -> next) - { - virtOverDef **tailp, *vod; - - if (!isVirtual(od) || isPrivate(od)) - continue; - - /* - * See if a virtual of this name and signature is already in - * the list. - */ - for (tailp = &base -> vmembers; (vod = *tailp) != NULL; tailp = &vod -> next) - if (strcmp(vod -> o.cppname,od -> cppname) == 0 && sameOverload(&vod -> o,od)) - break; - - if (vod == NULL) - { - /* - * See if there is a non-virtual reimplementation - * nearer in the class hierarchy. - */ - - mroDef *mro; - classDef *scope = NULL; - overDef *eod; - - for (mro = base -> mro; mro -> cd != cd; mro = mro -> next) - { - if (isDuplicateSuper(mro)) - continue; - - /* - * Ignore classes that are on a different - * branch of the class hierarchy. - */ - if (!isSubClass(mro -> cd,cd)) - continue; - - for (eod = mro -> cd -> overs; eod != NULL; eod = eod -> next) - if (strcmp(eod -> cppname,od -> cppname) == 0 && sameSignature(eod -> cppsig,od -> cppsig,TRUE) && isConst(eod) == isConst(od) && !isAbstract(eod)) - { - scope = mro -> cd; - break; - } - - if (scope != NULL) - break; - } - - vod = sipMalloc(sizeof (virtOverDef)); - - vod -> o = *od; - vod -> scope = (scope != NULL ? scope : cd); - vod -> next = NULL; - - *tailp = vod; - - /* - * If there was a nearer reimplementation then we use - * its protection and abstract flags. - */ - if (scope != NULL) - { - vod -> o.overflags &= ~(SECT_MASK | OVER_IS_ABSTRACT); - vod -> o.overflags |= (SECT_MASK | OVER_IS_ABSTRACT) & eod -> overflags; - } - } - } -} - - -/* - * Return TRUE is a class is derived from another. - */ -static int isSubClass(classDef *cc,classDef *pc) -{ - mroDef *mro; - - /* - * In other words, does the parent class appear in the child class's - * MRO list. - */ - for (mro = cc -> mro; mro != NULL; mro = mro -> next) - if (mro -> cd == pc) - return TRUE; - - return FALSE; -} - - -/* - * Resolve the types of a mapped type based on a template. - */ -static void resolveMappedTypeTypes(sipSpec *pt,mappedTypeDef *mt) -{ - int a; - templateDef *td = mt -> type.u.td; - - for (a = 0; a < td -> types.nrArgs; ++a) - { - getBaseType(pt, mt->iff->module, NULL, &td->types.args[a]); - - ifaceFileIsUsed(pt, mt->iff, &td->types.args[a]); - } -} - - -/* - * Resolve the types of a ctor. - */ -static void resolveCtorTypes(sipSpec *pt,classDef *scope,ctorDef *ct) -{ - int a; - - /* Handle any C++ signature. */ - if (ct->cppsig != NULL && ct->cppsig != &ct->pysig) - for (a = 0; a < ct -> cppsig -> nrArgs; ++a) - getBaseType(pt, scope->iff->module, scope, &ct->cppsig->args[a]); - - /* Handle the Python signature. */ - for (a = 0; a < ct -> pysig.nrArgs; ++a) - { - argDef *ad = &ct -> pysig.args[a]; - - getBaseType(pt, scope->iff->module, scope, ad); - - if (!supportedType(scope,NULL,ad,FALSE) && (ct -> cppsig == &ct -> pysig || ct -> methodcode == NULL)) - { - fatalScopedName(classFQCName(scope)); - fatal(" unsupported ctor argument type - provide %%MethodCode and a C++ signature\n"); - } - - ifaceFileIsUsed(pt, scope->iff, ad); - scopeDefaultValue(pt,scope,ad); - } -} - - -/* - * Resolve the types of a function. - */ -static void resolveFuncTypes(sipSpec *pt, moduleDef *mod, classDef *scope, overDef *od) -{ - argDef *res; - - /* Handle any C++ signature. */ - if (od -> cppsig != &od -> pysig) - { - int a; - - getBaseType(pt,mod, scope, &od->cppsig->result); - - for (a = 0; a < od -> cppsig -> nrArgs; ++a) - getBaseType(pt, mod, scope, &od->cppsig->args[a]); - } - - /* Handle the Python signature. */ - resolvePySigTypes(pt, mod, scope, od, &od->pysig,isSignal(od)); - - /* These slots must return int. */ - res = &od -> pysig.result; - - if (isIntReturnSlot(od->common)) - if (res -> atype != int_type || res -> nrderefs != 0 || - isReference(res) || isConstArg(res)) - fatal("%s slots must return int\n",od -> common -> pyname -> text); - - /* These slots must return void. */ - if (isVoidReturnSlot(od -> common)) - if (res -> atype != void_type || res -> nrderefs != 0 || - isReference(res) || isConstArg(res)) - fatal("%s slots must return void\n",od -> common -> pyname -> text); - - /* These slots must return long. */ - if (isLongReturnSlot(od->common)) - if (res->atype != long_type || res->nrderefs != 0 || - isReference(res) || isConstArg(res)) - fatal("%s slots must return long\n", od->common->pyname->text); -} - - -/* - * Resolve the types of a Python signature. - */ -static void resolvePySigTypes(sipSpec *pt, moduleDef *mod, classDef *scope, - overDef *od, signatureDef *pysig, int issignal) -{ - int a; - argDef *res = &pysig -> result; - - if (res -> atype != void_type || res -> nrderefs != 0) - { - if (issignal) - { - if (scope != NULL) - { - fatalScopedName(classFQCName(scope)); - fatal("::"); - } - - fatal("%s() signals must return void\n",od -> cppname); - } - - getBaseType(pt, mod, scope, res); - - /* Results must be simple. */ - if (!supportedType(scope,od,res,FALSE) && (od -> cppsig == &od -> pysig || od -> methodcode == NULL)) - { - if (scope != NULL) - { - fatalScopedName(classFQCName(scope)); - fatal("::"); - } - - fatal("%s() unsupported function return type - provide %%MethodCode and a %s signature\n",od -> cppname,(pt -> genc ? "C" : "C++")); - } - } - - for (a = 0; a < pysig -> nrArgs; ++a) - { - argDef *ad = &pysig -> args[a]; - - getBaseType(pt, mod, scope, ad); - - if (ad -> atype == slotcon_type) - resolvePySigTypes(pt, mod, scope, od, ad->u.sa, TRUE); - - /* - * Note signal arguments are restricted in their types because we don't - * (yet) support handwritten code for them. - */ - if (issignal) - { - if (!supportedType(scope,od,ad,FALSE)) - { - if (scope != NULL) - { - fatalScopedName(classFQCName(scope)); - fatal("::"); - } - - fatal("%s() unsupported signal argument type\n"); - } - } - else if (!supportedType(scope,od,ad,TRUE) && (od -> cppsig == &od -> pysig || od -> methodcode == NULL || (isVirtual(od) && od -> virthandler -> virtcode == NULL))) - { - if (scope != NULL) - { - fatalScopedName(classFQCName(scope)); - fatal("::"); - } - - if (isVirtual(od)) - fatal("%s() unsupported function argument type - provide %%Method code, a valid %%VirtualCatcherCode and a valid C++ signature\n",od -> cppname); - - fatal("%s() unsupported function argument type - provide %%Method code and a valid %s signature\n",od -> cppname,(pt -> genc ? "C" : "C++")); - } - - if (scope != NULL) - scopeDefaultValue(pt,scope,ad); - } -} - - -/* - * Resolve the type of a variable. - */ -static void resolveVariableType(sipSpec *pt,varDef *vd) -{ - int bad = TRUE; - argDef *vtype = &vd -> type; - - getBaseType(pt, vd->module, vd->ecd, vtype); - - switch (vtype -> atype) - { - case mapped_type: - case class_type: - /* Class, Class & and Class * are supported. */ - - if (vtype -> nrderefs <= 1) - bad = FALSE; - break; - - case sstring_type: - case ustring_type: - case string_type: - case wstring_type: - /* - * (signed/unsigned) char, (signed/unsigned) char *, wchar_t, wchar_t * - * are supported. - */ - - if (!isReference(vtype) && vtype -> nrderefs <= 1) - bad = FALSE; - break; - - case cfloat_type: - case float_type: - case cdouble_type: - case double_type: - case enum_type: - case bool_type: - case cbool_type: - case ushort_type: - case short_type: - case uint_type: - case cint_type: - case int_type: - case ulong_type: - case long_type: - case ulonglong_type: - case longlong_type: - case pyobject_type: - case pytuple_type: - case pylist_type: - case pydict_type: - case pycallable_type: - case pyslice_type: - case pytype_type: - /* These are supported without pointers or references. */ - - if (!isReference(vtype) && vtype -> nrderefs == 0) - bad = FALSE; - break; - - case struct_type: - case void_type: - /* A simple pointer is supported. */ - - if (!isReference(vtype) && vtype -> nrderefs == 1) - bad = FALSE; - break; - } - - if (bad) - { - fatalScopedName(vd -> fqcname); - fatal(" has an unsupported type\n"); - } - - if (vtype -> atype != class_type && vd -> accessfunc != NULL) - { - fatalScopedName(vd -> fqcname); - fatal(" has %%AccessCode but isn't a class instance\n"); - } - - if (vd -> ecd != NULL) - ifaceFileIsUsed(pt, vd->ecd->iff, vtype); - else - ifaceFileIsUsed(pt, NULL, vtype); - - /* - * Instance variables or static class variables (unless they are - * constants) need a handler. - */ - if (vd -> ecd != NULL && vd -> accessfunc == NULL && - (!isStaticVar(vd) || vtype -> nrderefs != 0 || !isConstArg(vtype))) - { - setNeedsHandler(vd); - setHasVarHandlers(vd -> ecd); - } -} - - -/* - * See if a type is supported by the generated code. - */ -static int supportedType(classDef *cd,overDef *od,argDef *ad,int outputs) -{ - switch (ad -> atype) - { - case anyslot_type: - /* - * This must be an input, and must also have handwritten code. - */ - - ensureInput(cd,od,ad); - return FALSE; - - case signal_type: - case slot_type: - case rxcon_type: - case rxdis_type: - case slotcon_type: - case slotdis_type: - case qobject_type: - case ellipsis_type: - /* These can only appear in argument lists without * or &. */ - - ensureInput(cd,od,ad); - return TRUE; - - case sstring_type: - case ustring_type: - case string_type: - case wstring_type: - if (isReference(ad)) - { - if (outputs && ad -> nrderefs <= 1) - { - defaultOutput(cd,od,ad); - return TRUE; - } - } - else if (ad -> nrderefs == 0) - { - ensureInput(cd,od,ad); - return TRUE; - } - else if (ad -> nrderefs == 1) - { - if (outputs) - defaultInput(ad); - else - ensureInput(cd,od,ad); - - return TRUE; - } - else if (ad -> nrderefs == 2 && outputs) - { - defaultOutput(cd,od,ad); - return TRUE; - } - - break; - - case cfloat_type: - case float_type: - case cdouble_type: - case double_type: - case enum_type: - case bool_type: - case cbool_type: - case ushort_type: - case short_type: - case uint_type: - case cint_type: - case int_type: - case ulong_type: - case long_type: - case ulonglong_type: - case longlong_type: - case pyobject_type: - case pytuple_type: - case pylist_type: - case pydict_type: - case pycallable_type: - case pyslice_type: - case pytype_type: - if (isReference(ad)) - { - if (ad -> nrderefs == 0 && outputs) - { - defaultOutput(cd,od,ad); - return TRUE; - } - } - else if (ad -> nrderefs == 0) - { - ensureInput(cd,od,ad); - return TRUE; - } - else if (ad -> nrderefs == 1 && outputs) - { - defaultOutput(cd,od,ad); - return TRUE; - } - - break; - - case mapped_type: - case class_type: - if (isReference(ad)) - { - if (ad -> nrderefs == 0) - { - defaultInput(ad); - return TRUE; - } - else if (ad -> nrderefs == 1 && outputs) - { - defaultOutput(cd,od,ad); - return TRUE; - } - } - else if (ad -> nrderefs == 0) - { - ensureInput(cd,od,ad); - return TRUE; - } - else if (ad -> nrderefs == 1) - { - if (outputs) - defaultInput(ad); - else - ensureInput(cd,od,ad); - - return TRUE; - } - else if (ad -> nrderefs == 2 && outputs) - { - defaultOutput(cd,od,ad); - return TRUE; - } - - break; - - case struct_type: - case void_type: - if (isReference(ad)) - { - if (ad -> nrderefs == 1 && outputs) - { - defaultOutput(cd,od,ad); - return TRUE; - } - } - else if (ad -> nrderefs == 1) - { - ensureInput(cd,od,ad); - return TRUE; - } - else if (ad -> nrderefs == 2 && outputs) - { - defaultOutput(cd,od,ad); - return TRUE; - } - - break; - } - - /* Unsupported if we got this far. */ - return FALSE; -} - - -/* - * Ensure the direction of an argument is an input. - */ -static void ensureInput(classDef *cd,overDef *od,argDef *ad) -{ - if (isOutArg(ad)) - { - if (cd != NULL) - { - fatalScopedName(classFQCName(cd)); - fatal("::"); - } - - if (od != NULL) - fatal("%s",od -> cppname); - - fatal("() invalid argument type for /Out/\n"); - } - - setIsInArg(ad); -} - - -/* - * Default the direction of an argument to an input. - */ -static void defaultInput(argDef *ad) -{ - if (!isInArg(ad) && !isOutArg(ad)) - setIsInArg(ad); -} - - -/* - * Default the direction of an argument to an output unless the argument is - * const. - */ -static void defaultOutput(classDef *cd,overDef *od,argDef *ad) -{ - if (isOutArg(ad)) - { - if (isConstArg(ad)) - { - if (cd != NULL) - { - fatalScopedName(classFQCName(cd)); - fatal("::"); - } - - if (od != NULL) - fatal("%s",od -> cppname); - - fatal("() const argument cannot have /Out/ specified\n"); - } - } - else if (!isInArg(ad)) - if (isConstArg(ad)) - setIsInArg(ad); - else - setIsOutArg(ad); -} - - -/* - * Put a scoped name to stderr. - */ -void fatalScopedName(scopedNameDef *snd) -{ - while (snd != NULL) - { - fatal("%s",snd -> name); - - snd = snd -> next; - - if (snd != NULL) - fatal("::"); - } -} - - -/* - * Compare two overloads and return TRUE if they are the same. - */ -static int sameOverload(overDef *od1,overDef *od2) -{ - /* They must both be const, or both not. */ - if (isConst(od1) != isConst(od2)) - return FALSE; - - return sameSignature(&od1 -> pysig,&od2 -> pysig,TRUE); -} - - -/* - * Compare two virtual handlers and return TRUE if they are the same. - */ -static int sameVirtualHandler(virtHandlerDef *vhd1,virtHandlerDef *vhd2) -{ - if (isTransferVH(vhd1) != isTransferVH(vhd2)) - return FALSE; - - if (!sameArgType(&vhd1->pysig->result, &vhd2->pysig->result, TRUE)) - return FALSE; - - if (!sameSignature(vhd1->pysig, vhd2->pysig, TRUE)) - return FALSE; - - if (vhd1->pysig == vhd1->cppsig && vhd2->pysig == vhd2->cppsig) - return TRUE; - - if (!sameArgType(&vhd1->cppsig->result, &vhd2->cppsig->result, TRUE)) - return FALSE; - - return sameSignature(vhd1->cppsig, vhd2->cppsig, TRUE); -} - - -/* - * Compare two signatures and return TRUE if they are the same. - */ -int sameSignature(signatureDef *sd1,signatureDef *sd2,int strict) -{ - int a; - - if (strict) - { - /* The number of arguments must be the same. */ - if (sd1 -> nrArgs != sd2 -> nrArgs) - return FALSE; - } - else - { - int na1, na2; - - /* We only count the compulsory arguments. */ - na1 = 0; - - for (a = 0; a < sd1 -> nrArgs; ++a) - { - if (sd1 -> args[a].defval != NULL) - break; - - ++na1; - } - - na2 = 0; - - for (a = 0; a < sd2 -> nrArgs; ++a) - { - if (sd2 -> args[a].defval != NULL) - break; - - ++na2; - } - - if (na1 != na2) - return FALSE; - } - - /* The arguments must be the same. */ - for (a = 0; a < sd1 -> nrArgs; ++a) - { - if (!strict && sd1 -> args[a].defval != NULL) - break; - - if (!sameArgType(&sd1 -> args[a],&sd2 -> args[a],strict)) - return FALSE; - } - - /* Must be the same if we've got this far. */ - return TRUE; -} - - -#define pyAsString(t) ((t) == ustring_type || (t) == sstring_type || \ - (t) == string_type) -#define pyAsFloat(t) ((t) == cfloat_type || (t) == float_type || \ - (t) == cdouble_type || (t) == double_type) -#define pyAsInt(t) ((t) == cint_type || (t) == bool_type || \ - (t) == short_type || (t) == ushort_type || \ - (t) == int_type || (t) == uint_type) -#define pyAsLong(t) ((t) == long_type || (t) == longlong_type) -#define pyAsULong(t) ((t) == ulong_type || (t) == ulonglong_type) -#define pyAsAuto(t) ((t) == bool_type || \ - (t) == short_type || (t) == ushort_type || \ - (t) == int_type || (t) == uint_type || \ - (t) == float_type || (t) == double_type) - -/* - * Compare two argument types and return TRUE if they are the same. "strict" - * means as C++ would see it, rather than Python. - */ -static int sameArgType(argDef *a1, argDef *a2, int strict) -{ - /* The references must be the same. */ - if (isReference(a1) != isReference(a2) || a1->nrderefs != a2->nrderefs) - return FALSE; - - if (strict) - { - /* The const should be the same. */ - if (isConstArg(a1) != isConstArg(a2)) - return FALSE; - - return sameBaseType(a1,a2); - } - - /* Python will see all these as strings. */ - if (pyAsString(a1->atype) && pyAsString(a2->atype)) - return TRUE; - - /* Python will see all these as floats. */ - if (pyAsFloat(a1->atype) && pyAsFloat(a2->atype)) - return TRUE; - - /* Python will see all these as ints. */ - if (pyAsInt(a1->atype) && pyAsInt(a2->atype)) - return TRUE; - - /* Python will see all these as longs. */ - if (pyAsLong(a1->atype) && pyAsLong(a2->atype)) - return TRUE; - - /* Python will see all these as unsigned longs. */ - if (pyAsULong(a1->atype) && pyAsULong(a2->atype)) - return TRUE; - - /* Python will automatically convert between these. */ - if (pyAsAuto(a1->atype) && pyAsAuto(a2->atype)) - return TRUE; - - /* All the special cases have been handled. */ - return sameBaseType(a1, a2); -} - - -/* - * Compare two basic types and return TRUE if they are the same. - */ - -int sameBaseType(argDef *a1,argDef *a2) -{ - /* The types must be the same. */ - - if (a1 -> atype != a2 ->atype) - return FALSE; - - switch (a1 -> atype) - { - case class_type: - if (a1 -> u.cd != a2 -> u.cd) - return FALSE; - - break; - - case enum_type: - if (a1 -> u.ed != a2 -> u.ed) - return FALSE; - - break; - - case slotcon_type: - case slotdis_type: - if (!sameSignature(a1 -> u.sa,a2 -> u.sa,TRUE)) - return FALSE; - - break; - - case template_type: - { - int a; - templateDef *td1, *td2; - - td1 = a1 -> u.td; - td2 = a2 -> u.td; - - if (!sameScopedName(td1 -> fqname,td2 -> fqname) != 0 || - td1 -> types.nrArgs != td2 -> types.nrArgs) - return FALSE; - - for (a = 0; a < td1 -> types.nrArgs; ++a) - if (!sameBaseType(&td1 -> types.args[a],&td2 -> types.args[a])) - return FALSE; - - break; - } - - case struct_type: - if (!sameScopedName(a1 -> u.sname,a2 -> u.sname) != 0) - return FALSE; - - break; - - case defined_type: - if (!sameScopedName(a1 -> u.snd,a2 -> u.snd)) - return FALSE; - - break; - - case mapped_type: - if (a1 -> u.mtd != a2 -> u.mtd) - return FALSE; - - break; - } - - /* Must be the same if we've got this far. */ - - return TRUE; -} - - -/* - * See if two Python signatures are the same as far as Python is concerned. - */ -static int samePythonSignature(signatureDef *sd1, signatureDef *sd2) -{ - int a1, a2; - - a1 = a2 = -1; - - for (;;) - { - a1 = nextSignificantArg(sd1, a1); - a2 = nextSignificantArg(sd2, a2); - - if (a1 < 0 || a2 < 0) - break; - - if (!sameArgType(&sd1->args[a1], &sd2->args[a2], FALSE)) - return FALSE; - } - - return (a1 < 0 && a2 < 0); - -} - - -/* - * Return the next significant argument from a Python signature (ie. one that - * is not optional or an output only argument. Return -1 if there isn't one. - */ -static int nextSignificantArg(signatureDef *sd, int a) -{ - while (++a < sd->nrArgs) - { - if (sd->args[a].defval != NULL) - break; - - if (isInArg(&sd->args[a])) - return a; - } - - return -1; -} - - -/* - * Return TRUE if two scoped names are the same. - */ - -int sameScopedName(scopedNameDef *snd1,scopedNameDef *snd2) -{ - while (snd1 != NULL && snd2 != NULL && strcmp(snd1 -> name,snd2 -> name) == 0) - { - snd1 = snd1 -> next; - snd2 = snd2 -> next; - } - - return (snd1 == NULL && snd2 == NULL); -} - - -/* - * Add an explicit scope to the default value of an argument if possible. - */ - -static void scopeDefaultValue(sipSpec *pt,classDef *cd,argDef *ad) -{ - valueDef *vd, **tailp, *newvd; - - /* - * We do a quick check to see if we need to do anything. This means - * we can limit the times we need to copy the default value. It needs - * to be copied because it will be shared by class versions that have - * been created on the fly and it may need to be scoped differently for - * each of those versions. - */ - - for (vd = ad -> defval; vd != NULL; vd = vd -> next) - if (vd -> vtype == scoped_value && vd -> u.vscp -> next == NULL) - break; - - if (vd == NULL) - return; - - /* - * It's not certain that we will do anything, but we assume we will and - * start copying. - */ - - newvd = NULL; - tailp = &newvd; - - for (vd = ad -> defval; vd != NULL; vd = vd -> next) - { - mroDef *mro; - scopedNameDef *origname; - valueDef *new; - - /* Make the copy. */ - - new = sipMalloc(sizeof (valueDef)); - - *new = *vd; - *tailp = new; - tailp = &new -> next; - - /* - * Skip this part of the expression if it isn't a named value - * or it already has a scope. - */ - - if (vd -> vtype != scoped_value || vd -> u.vscp -> next != NULL) - continue; - - /* - * Search the class hierarchy for an enum value with the same - * name. If we don't find one, leave it as it is (the compiler - * will find out if this is a problem). - */ - - origname = vd -> u.vscp; - - for (mro = cd -> mro; mro != NULL; mro = mro -> next) - { - enumDef *ed; - - if (isDuplicateSuper(mro)) - continue; - - for (ed = pt -> enums; ed != NULL; ed = ed -> next) - { - enumMemberDef *emd; - - if (ed -> ecd != mro -> cd) - continue; - - for (emd = ed -> members; emd != NULL; emd = emd -> next) - if (strcmp(emd -> cname,origname -> name) == 0) - { - scopedNameDef *snd; - - /* - * Take the scope from the - * class that the enum was - * defined in. - */ - - snd = copyScopedName(mro -> cd -> iff -> fqcname); - appendScopedName(&snd,origname); - - new -> u.vscp = snd; - - /* Nothing more to do. */ - - break; - } - - if (emd != NULL) - break; - } - - if (ed != NULL) - break; - } - } - - ad -> defval = newvd; -} - - -/* - * Make sure a type is a base type. - */ -static void getBaseType(sipSpec *pt, moduleDef *mod, classDef *defscope, argDef *type) -{ - /* Loop until we've got to a base type. */ - while (type -> atype == defined_type) - { - scopedNameDef *snd = type -> u.snd; - - type -> atype = no_type; - - if (defscope != NULL) - searchScope(pt,defscope,snd,type); - - if (type -> atype == no_type) - searchMappedTypes(pt,snd,type); - - if (type -> atype == no_type) - searchTypedefs(pt,snd,type); - - if (type -> atype == no_type) - searchEnums(pt,snd,type); - - if (type -> atype == no_type) - searchClasses(pt, mod, snd, type); - - if (type -> atype == no_type) - fatalNoDefinedType(snd); - } - - /* Get the base type of any slot arguments. */ - if (type -> atype == slotcon_type || type -> atype == slotdis_type) - { - int sa; - - for (sa = 0; sa < type -> u.sa -> nrArgs; ++sa) - getBaseType(pt, mod, defscope, &type->u.sa->args[sa]); - } - - /* See if the type refers to an instantiated template. */ - if (type->atype == template_type) - { - classDef *cd; - - for (cd = pt->classes; cd != NULL; cd = cd->next) - if (cd->td != NULL && - sameScopedName(cd->td->fqname, type->u.td->fqname) && - sameSignature(&cd->td->types, &type->u.td->types, TRUE)) - { - type->atype = class_type; - type->u.cd = cd; - - break; - } - } - - /* Replace the base type if it has been mapped. */ - if (type -> atype == struct_type || type -> atype == template_type) - { - searchMappedTypes(pt,NULL,type); - - /* - * If we still have a template then see if we need to - * automatically instantiate it. - */ - if (type->atype == template_type) - { - mappedTypeTmplDef *mtt; - - for (mtt = pt->mappedtypetemplates; mtt != NULL; mtt = mtt->next) - if (sameScopedName(type->u.td->fqname, mtt->mt->type.u.td->fqname) && sameTemplateSignature(&type->u.td->types, &mtt->mt->type.u.td->types, TRUE)) - { - type->u.mtd = instantiateMappedTypeTemplate(pt, mod, mtt, type); - type->atype = mapped_type; - - break; - } - } - } -} - - -/* - * Instantiate a mapped type template and return it. - */ -static mappedTypeDef *instantiateMappedTypeTemplate(sipSpec *pt, moduleDef *mod, mappedTypeTmplDef *mtt, argDef *type) -{ - scopedNameDef *type_names, *type_values; - mappedTypeDef *mtd; - - type_names = type_values = NULL; - appendTypeStrings(type->u.td->fqname, &mtt->mt->type.u.td->types, &type->u.td->types, &mtt->sig, &type_names, &type_values); - - mtd = allocMappedType(type); - - mtd->iff = findIfaceFile(pt, mod, type->u.td->fqname, mappedtype_iface, type); - mtd->iff->module = mod; - - mtd->hdrcode = templateCode(pt, &mtd->iff->used, mtt->mt->hdrcode, type_names, type_values); - mtd->convfromcode = templateCode(pt, &mtd->iff->used, mtt->mt->convfromcode, type_names, type_values); - mtd->convtocode = templateCode(pt, &mtd->iff->used, mtt->mt->convtocode, type_names, type_values); - - mtd->next = pt->mappedtypes; - pt->mappedtypes = mtd; - - if (type_names != NULL) - freeScopedName(type_names); - - if (type_values != NULL) - freeScopedName(type_values); - - return mtd; -} - - -/* - * Search for a name in a scope and return the corresponding type. - */ - -static void searchScope(sipSpec *pt,classDef *scope,scopedNameDef *snd, - argDef *ad) -{ - scopedNameDef *tmpsnd = NULL; - mroDef *mro; - - for (mro = scope -> mro; mro != NULL; mro = mro -> next) - { - if (isDuplicateSuper(mro)) - continue; - - /* Append the name to the scope and see if it exists. */ - - tmpsnd = copyScopedName(classFQCName(mro -> cd)); - appendScopedName(&tmpsnd,copyScopedName(snd)); - - searchMappedTypes(pt,tmpsnd,ad); - - if (ad -> atype != no_type) - break; - - searchTypedefs(pt,tmpsnd,ad); - - if (ad -> atype != no_type) - break; - - searchEnums(pt,tmpsnd,ad); - - if (ad -> atype != no_type) - break; - - searchClasses(pt, mro->cd->iff->module, tmpsnd, ad); - - if (ad -> atype != no_type) - break; - - freeScopedName(tmpsnd); - tmpsnd = NULL; - } - - if (tmpsnd != NULL) - freeScopedName(tmpsnd); -} - - -/* - * Search the mapped types for a name and return the type. - */ - -static void searchMappedTypes(sipSpec *pt,scopedNameDef *snd,argDef *ad) -{ - mappedTypeDef *mtd; - scopedNameDef *oname; - - /* Patch back to defined types so we can use sameBaseType(). */ - if (snd != NULL) - { - oname = ad -> u.snd; - ad -> u.snd = snd; - ad -> atype = defined_type; - } - - for (mtd = pt -> mappedtypes; mtd != NULL; mtd = mtd -> next) - if (sameBaseType(ad,&mtd -> type)) - { - /* Copy the type. */ - ad -> atype = mapped_type; - ad -> u.mtd = mtd; - - return; - } - - /* Restore because we didn't find anything. */ - if (snd != NULL) - { - ad -> u.snd = oname; - ad -> atype = no_type; - } -} - - -/* - * Search the typedefs for a name and return the type. - */ - -static void searchTypedefs(sipSpec *pt,scopedNameDef *snd,argDef *ad) -{ - typedefDef *td; - - for (td = pt -> typedefs; td != NULL; td = td -> next) - if (sameScopedName(td -> fqname,snd)) - { - /* Copy the type. */ - - ad -> atype = td -> type.atype; - ad -> argflags |= td -> type.argflags; - ad -> nrderefs += td -> type.nrderefs; - ad -> u = td -> type.u; - - break; - } -} - - -/* - * Search the enums for a name and return the type. - */ - -static void searchEnums(sipSpec *pt,scopedNameDef *snd,argDef *ad) -{ - enumDef *ed; - - for (ed = pt -> enums; ed != NULL; ed = ed -> next) - { - if (ed -> fqcname == NULL) - continue; - - if (sameScopedName(ed -> fqcname,snd)) - { - ad -> atype = enum_type; - ad -> u.ed = ed; - - break; - } - } -} - - -/* - * Search the classes for one with a particular name and return it as a type. - */ -static void searchClasses(sipSpec *pt, moduleDef *mod, scopedNameDef *cname, argDef *ad) -{ - classDef *cd; - - for (cd = pt -> classes; cd != NULL; cd = cd -> next) - { - /* - * Ignore an external class unless it was declared in the same - * context (ie. module) as the name is being used. - */ - if (isExternal(cd) && cd->iff->module != mod) - continue; - - if (sameScopedName(classFQCName(cd), cname)) - { - ad -> atype = class_type; - ad -> u.cd = cd; - - break; - } - } -} - - -/* - * Print an error message describing an undefined type to stderr and terminate. - */ - -static void fatalNoDefinedType(scopedNameDef *snd) -{ - fatalScopedName(snd); - fatal(" is undefined\n"); -} - - -/* - * Make sure all external interface files for all other functions of a module - * are used. - */ -static void ifaceFilesAreUsedFromOther(sipSpec *pt, signatureDef *sd) -{ - int a; - ifaceFileDef *iff; - - if ((iff = getIfaceFile(&sd->result)) != NULL && iff->module != pt->module) - addToUsedList(&pt->used, iff); - - for (a = 0; a < sd->nrArgs; ++a) - if ((iff = getIfaceFile(&sd->args[a])) != NULL && iff->module != pt->module) - addToUsedList(&pt->used, iff); -} - - -/* - * Make sure all interface files for all overloads of a method are used. - */ -static void ifaceFilesAreUsedByMethod(sipSpec *pt, classDef *cd, memberDef *md) -{ - overDef *od; - - for (od = cd -> overs; od != NULL; od = od -> next) - if (od -> common == md) - ifaceFilesAreUsed(pt, cd->iff, od); -} - - -/* - * Make sure all interface files for a signature are used. - */ -static void ifaceFilesAreUsed(sipSpec *pt, ifaceFileDef *iff, overDef *od) -{ - int a; - - ifaceFileIsUsed(pt, iff, &od->pysig.result); - - for (a = 0; a < od->pysig.nrArgs; ++a) - ifaceFileIsUsed(pt, iff, &od->pysig.args[a]); - - if (od->cppsig != &od->pysig) - { - ifaceFileIsUsed(pt, iff, &od->cppsig->result); - - for (a = 0; a < od->cppsig->nrArgs; ++a) - ifaceFileIsUsed(pt, iff, &od->cppsig->args[a]); - } -} - - -/* - * If a type has an interface file then add it to the appropriate list of used - * interface files so that the header file is #included in the generated code. - */ -static void ifaceFileIsUsed(sipSpec *pt, ifaceFileDef *iff, argDef *ad) -{ - ifaceFileDef *usediff; - - if ((usediff = getIfaceFile(ad)) != NULL && usediff != iff) - { - ifaceFileList *iffl, **used; - - used = (iff != NULL ? &iff->used : &pt->used); - - iffl = addToUsedList(used, usediff); - - /* - * If the type is a protected enum then its scoping shadow - * class is needed in the generated header file. - */ - if (ad->atype == enum_type && isProtectedEnum(ad->u.ed)) - iffl->header = TRUE; - } -} - - -/* - * Return the interface file for a type, or NULL if it doesn't have one. - */ -static ifaceFileDef *getIfaceFile(argDef *ad) -{ - ifaceFileDef *iff; - - switch (ad -> atype) - { - case class_type: - iff = ad -> u.cd -> iff; - break; - - case mapped_type: - iff = ad -> u.mtd -> iff; - break; - - case enum_type: - if (ad -> u.ed -> fqcname != NULL && ad -> u.ed -> ecd != NULL) - { - iff = ad -> u.ed -> ecd -> iff; - break; - } - - /* Drop through. */ - - default: - iff = NULL; - } - - return iff; -} - - -/* - * Position a class so that it is after all its super-classes. - */ -static void positionClass(classDef *cd) -{ - classList *cl; - - /* See if it has already been done. */ - if (cd -> node -> ordered) - return; - - for (cl = cd -> supers; cl != NULL; cl = cl -> next) - { - nodeDef **ndp, *nd1, *nd2, *rp; - - /* Ignore super-classes from different modules. */ - if (cl -> cd -> iff -> module != cd -> iff -> module) - continue; - - /* Make sure the super-class is positioned. */ - positionClass(cl -> cd); - - /* - * Find ancestors of the two that are siblings (ie. they have a - * common parent). - */ - rp = &cd -> iff -> module -> root; - - for (nd1 = cd -> node; nd1 != rp; nd1 = nd1 -> parent) - { - for (nd2 = cl -> cd -> node; nd2 != rp; nd2 = nd2 -> parent) - if (nd1 -> parent == nd2 -> parent) - break; - - if (nd2 != rp) - break; - } - - /* - * The first node must appear after the second in the common - * parent's list of children. - */ - for (ndp = &nd1 -> parent -> child; *ndp != NULL; ndp = &(*ndp) -> next) - { - nodeDef *nd = *ndp; - - if (nd == nd2) - break; - - if (nd == nd1) - { - /* Remove this one from the list. */ - *ndp = nd -> next; - - /* Find the super-class ancestor. */ - while (*ndp != nd2) - ndp = &(*ndp) -> next; - - /* - * Put this one back after the super-class - * ancestor. - */ - nd -> next = (*ndp) -> next; - (*ndp) -> next = nd; - - break; - } - } - } - - cd -> node -> ordered = TRUE; -} - - -/* - * Make sure a class is in the namespace tree. - */ -static void addNodeToParent(nodeDef *root,classDef *cd) -{ - nodeDef *nd, *parent; - - /* Skip classes already in the tree. */ - if (cd -> node != NULL) - return; - - /* Add this child to the parent. */ - nd = sipMalloc(sizeof (nodeDef)); - - nd -> ordered = FALSE; - nd -> cd = cd; - nd -> child = NULL; - - /* Get the address of the parent node. */ - if (cd -> ecd == NULL) - parent = root; - else - { - /* Make sure the parent is in the tree. */ - addNodeToParent(root,cd -> ecd); - - parent = cd -> ecd -> node; - } - - nd -> parent = parent; - - /* Insert this at the head of the parent's children. */ - nd -> next = parent -> child; - parent -> child = nd; - - /* Remember where we are in the tree. */ - cd -> node = nd; -} - - -/* - * Assign the module specific class number for a class and all it's children. - */ -static void assignClassNrs(sipSpec *pt,moduleDef *mod,nodeDef *nd) -{ - classDef *cd; - nodeDef *cnd; - - /* Assign the class if it's not the root. */ - if ((cd = nd -> cd) != NULL) - { - cd -> classnr = mod -> nrclasses++; - - /* - * If we find a class defined in the main module called TQObject, assume - * it's Qt. - */ - if (mod == pt -> module && strcmp(classBaseName(cd),"TQObject") == 0) - pt -> qobjclass = cd -> classnr; - } - - /* Assign all it's children. */ - for (cnd = nd -> child; cnd != NULL; cnd = cnd -> next) - assignClassNrs(pt,mod,cnd); -} - - -/* - * Assign the module specific enum number for all named enums. - */ -static void assignEnumNrs(sipSpec *pt) -{ - enumDef *ed; - - for (ed = pt -> enums; ed != NULL; ed = ed -> next) - if (ed -> fqcname != NULL) - ed -> enumnr = ed -> module -> nrenums++; -} diff --git a/python/sip/siplib/bool.cpp b/python/sip/siplib/bool.cpp deleted file mode 100644 index c21a0c79..00000000 --- a/python/sip/siplib/bool.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// This contains all the C++ code that is needed by the sip module. -// -// Copyright (c) 2007 -// Riverbank Computing Limited <info@riverbankcomputing.co.uk> -// -// This file is part of SIP. -// -// This copy of SIP is licensed for use under the terms of the SIP License -// Agreement. See the file LICENSE for more details. -// -// SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - -// Set a C++ bool for the main C implementation of the module. -extern "C" void sipSetBool(void *ptr, int val) -{ - *reinterpret_cast<bool *>(ptr) = val; -} diff --git a/python/sip/siplib/objmap.c b/python/sip/siplib/objmap.c deleted file mode 100644 index efc7bc2a..00000000 --- a/python/sip/siplib/objmap.c +++ /dev/null @@ -1,264 +0,0 @@ -/* - * This module implements a hash table class for mapping C/C++ addresses to the - * corresponding wrapped Python object. - * - * Copyright (c) 2007 - * Riverbank Computing Limited <info@riverbankcomputing.co.uk> - * - * This file is part of SIP. - * - * This copy of SIP is licensed for use under the terms of the SIP License - * Agreement. See the file LICENSE for more details. - * - * SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - - -#include <string.h> - -#include "sip.h" -#include "sipint.h" - - -#define hash_1(k,s) (((unsigned long)(k)) % (s)) -#define hash_2(k,s) ((s) - 2 - (hash_1((k),(s)) % ((s) - 2))) - - -/* Prime numbers to use as hash table sizes. */ -static unsigned long hash_primes[] = { - 521, 1031, 2053, 4099, - 8209, 16411, 32771, 65537, 131101, 262147, - 524309, 1048583, 2097169, 4194319, 8388617, 16777259, - 33554467, 67108879, 134217757, 268435459, 536870923, 1073741827, - 2147483659U,0 -}; - - -static sipHashEntry *newHashTable(unsigned long); -static sipHashEntry *findHashEntry(sipObjectMap *,void *); -static void reorganiseMap(sipObjectMap *om); - - -/* - * Initialise an object map. - */ -void sipOMInit(sipObjectMap *om) -{ - om -> primeIdx = 0; - om -> unused = om -> size = hash_primes[om -> primeIdx]; - om -> stale = 0; - om -> hash_array = newHashTable(om -> size); -} - - -/* - * Finalise an object map. - */ -void sipOMFinalise(sipObjectMap *om) -{ - sip_api_free(om -> hash_array); -} - - -/* - * Allocate and initialise a new hash table. - */ -static sipHashEntry *newHashTable(unsigned long size) -{ - size_t nbytes; - sipHashEntry *hashtab; - - nbytes = sizeof (sipHashEntry) * size; - - if ((hashtab = (sipHashEntry *)sip_api_malloc(nbytes)) != NULL) - memset(hashtab,0,nbytes); - - return hashtab; -} - - -/* - * Return a pointer to the hash entry that is used, or should be used, for the - * given C/C++ address. - */ -static sipHashEntry *findHashEntry(sipObjectMap *om,void *key) -{ - unsigned long hash, inc; - void *hek; - - hash = hash_1(key,om -> size); - inc = hash_2(key,om -> size); - - while ((hek = om -> hash_array[hash].key) != NULL && hek != key) - hash = (hash + inc) % om -> size; - - return &om -> hash_array[hash]; -} - - -/* - * Return the wrapped Python object of a specific type for a C/C++ address or - * NULL if it wasn't found. - */ -sipWrapper *sipOMFindObject(sipObjectMap *om,void *key, sipWrapperType *type) -{ - sipHashEntry *he = findHashEntry(om, key); - sipWrapper *w; - - /* Go through each wrapped object at this address. */ - for (w = he->first; w != NULL; w = w->next) - { - /* - * If this wrapped object is of the given type, or a sub-type - * of it, or vice versa, then we assume it is the same C++ - * object. - */ - if (PyObject_TypeCheck(w, (PyTypeObject *)type) || - PyType_IsSubtype((PyTypeObject *)type, w->ob_type)) - return w; - } - - return NULL; -} - - -/* - * Add a C/C++ address and the corresponding wrapped Python object to the map. - */ -void sipOMAddObject(sipObjectMap *om,sipWrapper *val) -{ - sipHashEntry *he = findHashEntry(om,val -> u.cppPtr); - - /* - * If the bucket is in use then we appear to have several objects at - * the same address. - */ - if (he -> first != NULL) - { - /* - * This can happen for three reasons. A variable of one class - * can be declared at the start of another class. Therefore - * there are two objects, of different classes, with the same - * address. The second reason is that the old C/C++ object has - * been deleted by C/C++ but we didn't get to find out for some - * reason, and a new C/C++ instance has been created at the - * same address. The third reason is if we are in the process - * of deleting a Python object but the C++ object gets wrapped - * again because the C++ dtor called a method that has been - * re-implemented in Python. The absence of the SIP_SHARE_MAP - * flag tells us that a new C++ instance has just been created - * and so we know the second reason is the correct one so we - * mark the old pointers as invalid and reuse the entry. - * Otherwise we just add this one to the existing list of - * objects at this address. - */ - if (!(val -> flags & SIP_SHARE_MAP)) - { - sipWrapper *w; - - for (w = he -> first; w != NULL; w = w -> next) - w -> u.cppPtr = NULL; - - he -> first = NULL; - } - - val -> next = he -> first; - he -> first = val; - - return; - } - - /* See if the bucket was unused or stale. */ - if (he -> key == NULL) - { - he -> key = val -> u.cppPtr; - om -> unused--; - } - else - om -> stale--; - - /* Add the rest of the new value. */ - he -> first = val; - val -> next = NULL; - - reorganiseMap(om); -} - - -/* - * Reorganise a map if it is running short of space. - */ -static void reorganiseMap(sipObjectMap *om) -{ - unsigned long old_size, i; - sipHashEntry *ohe, *old_tab; - - /* Don't bother if it still has more than 12% available. */ - if (om -> unused > om -> size >> 3) - return; - - /* - * If reorganising (ie. making the stale buckets unused) using the same - * sized table would make 25% available then do that. Otherwise use a - * bigger table (if possible). - */ - if (om -> unused + om -> stale < om -> size >> 2 && hash_primes[om -> primeIdx + 1] != 0) - om -> primeIdx++; - - old_size = om -> size; - old_tab = om -> hash_array; - - om -> unused = om -> size = hash_primes[om -> primeIdx]; - om -> stale = 0; - om -> hash_array = newHashTable(om -> size); - - /* Transfer the entries from the old table to the new one. */ - ohe = old_tab; - - for (i = 0; i < old_size; ++i) - { - if (ohe -> key != NULL && ohe -> first != NULL) - { - *findHashEntry(om,ohe -> key) = *ohe; - om -> unused--; - } - - ++ohe; - } - - sip_api_free(old_tab); -} - - -/* - * Remove a C/C++ object from the table. Return 0 if it was removed - * successfully. - */ -int sipOMRemoveObject(sipObjectMap *om,sipWrapper *val) -{ - sipHashEntry *he = findHashEntry(om,val -> u.cppPtr); - sipWrapper **wp; - - for (wp = &he -> first; *wp != NULL; wp = &(*wp) -> next) - if (*wp == val) - { - *wp = val -> next; - - /* - * If the bucket is now empty then count it as stale. - * Note that we do not NULL the key and count it as - * unused because that might throw out the search for - * another entry that wanted to go here, found it - * already occupied, and was put somewhere else. In - * other words, searches must be repeatable until we - * reorganise the table. - */ - if (he -> first == NULL) - om -> stale++; - - return 0; - } - - return -1; -} diff --git a/python/sip/siplib/qtlib.c b/python/sip/siplib/qtlib.c deleted file mode 100644 index f3ba4301..00000000 --- a/python/sip/siplib/qtlib.c +++ /dev/null @@ -1,1254 +0,0 @@ -/* - * The SIP library code that implements the interface to the optional module - * supplied Qt support. - * - * Copyright (c) 2007 - * Riverbank Computing Limited <info@riverbankcomputing.co.uk> - * - * This file is part of SIP. - * - * This copy of SIP is licensed for use under the terms of the SIP License - * Agreement. See the file LICENSE for more details. - * - * SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - - -#include <Python.h> -#include <string.h> - -#include "sip.h" -#include "sipint.h" - - -/* This is how Qt "types" signals and slots. */ -#define isQtSlot(s) (*(s) == '1') -#define isQtSignal(s) (*(s) == '2') - - -static PyObject *py_sender = NULL; /* The last Python signal sender. */ - - -static int isSameSlot(sipSlot *,PyObject *,const char *); -static int emitQtSig(sipWrapper *,const char *,PyObject *); -static int emitToSlotList(sipSlotList *rxlist, PyObject *sigargs); -static int addSlotToPySigList(sipWrapper *,const char *,PyObject *,const char *); -static void removeSlotFromPySigList(sipWrapper *,const char *,PyObject *,const char *); -static PyObject *getWeakRef(PyObject *obj); -static sipPySig *findPySignal(sipWrapper *,const char *); -static char *sipStrdup(const char *); -static int saveSlot(sipSlot *sp, PyObject *rxObj, const char *slot); -static void *createUniversalSlot(sipWrapper *txSelf, const char *sig, PyObject *rxObj, const char *slot, const char **member); -static void *findSignal(void *txrx, const char **sig); -static void *newSignal(void *txrx, const char **sig); -static void freeSlot(sipSlot *slot); - - -/* - * Return the most recent signal sender. - */ -PyObject *sip_api_get_sender() -{ - PyObject *sender; - const void *qt_sender; - - /* - * If there is a Qt sender then it is more recent than the last Python - * sender, so use it instead. - */ - if ((qt_sender = sipQtSupport->qt_get_sender()) != NULL) - sender = sip_api_convert_from_instance((void *)qt_sender, sipQObjectClass, NULL); - else - { - if ((sender = py_sender) == NULL) - sender = Py_None; - - Py_INCREF(sender); - } - - return sender; -} - - -/* - * Release the resources held by a connection. - */ -void sip_api_free_connection(sipSlotConnection *conn) -{ - freeSlot(&conn->sc_slot); -} - - -/* - * Compare two connections and return TRUE if they are the same. - */ -int sip_api_same_connection(sipSlotConnection *conn, void *tx, const char *sig, - PyObject *rxObj, const char *slot) -{ - return (conn->sc_transmitter == tx && - sipQtSupport->qt_same_name(conn->sc_signature->sg_signature, sig) && - isSameSlot(&conn->sc_slot, rxObj, slot)); -} - - -/* - * Parse the signal arguments for a connection. - */ -sipSignature *sip_api_parse_signature(const char *sig) -{ - static sipSignature *psig_list = NULL; - sipSignature *psig; - const char *sp, *ep; - - /* - * First see if it has already been parsed. Note that both sides of a - * connection will probably be parsed twice because the function names will - * be different even though the signatures will probably be the same. We - * could be more clever, the most saving is when repeatedly emitting a - * signal for which this is sufficient. - */ - for (psig = psig_list; psig != NULL; psig = psig->sg_next) - if (sipQtSupport->qt_same_name(psig->sg_signature, sig)) - return psig; - - /* Create a new one including space for the copy of the signature. */ - if ((psig = (sipSignature *)sip_api_malloc(sizeof (sipSignature) + strlen(sig) + 1)) == NULL) - return NULL; - - psig->sg_signature = (char *)&psig[1]; - psig->sg_nrargs = 0; - psig->sg_args = 0; - - /* Find the start and end of the arguments. */ - sp = strchr(sig, '('); - ep = strrchr(sig, ')'); - - /* If the signal isn't well formed we assume Qt will pick it up. */ - if (sp && ep && sp < ep) - { - /* - * Copy the signature arguments while counting them and - * removing non-significant spaces. Each argument is left as a - * '\0' terminated string. - */ - char *dp = psig->sg_signature; - int depth = 0, nrcommas = 0, argstart = TRUE; - - for (;;) - { - char ch = *++sp; - - if (strchr(",*&)<>", ch)) - { - /* Backup over any previous trailing space. */ - if (dp > psig->sg_signature && dp[-1] == ' ') - --dp; - - if (sp == ep) - { - *dp = '\0'; - break; - } - - if (ch == ',' && depth == 0) - { - *dp++ = '\0'; - ++nrcommas; - argstart = TRUE; - } - else - { - *dp++ = ch; - - /* - * Make sure commas in template - * arguments are ignored. - */ - if (ch == '<') - ++depth; - else if (ch == '>') - --depth; - } - } - else if (ch == ' ') - { - /* Ignore leading and multiple spaces. */ - if (!argstart && dp[-1] != ' ') - *dp++ = ch; - } - else - { - *dp++ = ch; - argstart = FALSE; - } - } - - /* Handle the arguments now they are in a normal form. */ - if (*psig->sg_signature) - { - char *arg = psig->sg_signature; - int a; - - /* Allocate the space. */ - psig->sg_nrargs = nrcommas + 1; - - if ((psig->sg_args = (sipSigArg *)sip_api_malloc(sizeof (sipSigArg) * psig->sg_nrargs)) == NULL) - { - sip_api_free(psig); - return NULL; - } - - for (a = 0; a < psig->sg_nrargs; ++a) - { - size_t btlen = 0; - int unsup, isref = FALSE, indir = 0; - sipSigArgType sat = unknown_sat; - - /* Find the start of the significant part of the type. */ - dp = arg; - - if (strncmp(dp, "const ", 6) == 0) - dp += 6; - - /* - * Find the length of the base type, the number of indirections - * and if it is a reference. - */ - for (ep = dp; *ep; ++ep) - if (*ep == '&') - isref = TRUE; - else if (*ep == '*') - ++indir; - else - ++btlen; - - /* - * Assume that anything other than a base type is unsupported. - */ - unsup = (isref || indir); - - /* Parse the base type. */ - switch (btlen) - { - case 3: - if (strncmp(dp, "int", 3) == 0) - sat = int_sat; - break; - - case 4: - if (strncmp(dp, "bool", 4) == 0) - sat = bool_sat; - else if (strncmp(dp, "long", 4) == 0) - sat = long_sat; - else if (strncmp(dp, "char", 4) == 0) - { - sat = (indir ? string_sat : char_sat); - unsup = (isref || indir > 1); - } - else if (strncmp(dp, "void", 4) == 0) - { - sat = void_sat; - unsup = (isref || indir != 1); - } - break; - - case 5: - if (strncmp(dp, "float", 5) == 0) - sat = float_sat; - else if (strncmp(dp, "short", 5) == 0) - sat = short_sat; - break; - - case 6: - if (strncmp(dp, "double", 6) == 0) - sat = double_sat; - break; - - case 7: - if (strncmp(dp, "__int64", 7) == 0) - sat = longlong_sat; - else if (strncmp(dp, "wchar_t", 7) == 0) - { - sat = (indir ? wstring_sat : wchar_sat); - unsup = (isref || indir > 1); - } - break; - - case 8: - if (strncmp(dp, "unsigned", 8) == 0) - sat = uint_sat; - else if (strncmp(dp, "TQVariant", 8) == 0) - { - if (indir == 0) - { - sat = qvariant_sat; - unsup = FALSE; - } - else if (indir == 1) - { - sat = qvariantp_sat; - unsup = FALSE; - } - } - break; - - case 9: - if (strncmp(dp, "long long", 9) == 0) - sat = longlong_sat; - break; - - case 11: - if (strncmp(dp, "signed char", 11) == 0) - { - sat = (indir ? sstring_sat : schar_sat); - unsup = (isref || indir > 1); - } - break; - - case 12: - if (strncmp(dp, "unsigned int", 12) == 0) - sat = uint_sat; - break; - - case 13: - if (strncmp(dp, "unsigned long", 13) == 0) - sat = ulong_sat; - else if (strncmp(dp, "unsigned char", 13) == 0) - { - sat = (indir ? ustring_sat : uchar_sat); - unsup = (isref || indir > 1); - } - else if (strncmp(dp, "PyQt_PyObject", 13) == 0 && indir == 0) - { - sat = pyobject_sat; - unsup = FALSE; - } - break; - - case 14: - if (strncmp(dp, "unsigned short", 14) == 0) - sat = ushort_sat; - break; - - case 16: - if (strncmp(dp, "unsigned __int64", 16) == 0) - sat = ulonglong_sat; - break; - - case 18: - if (strncmp(dp, "unsigned long long", 18) == 0) - sat = ulonglong_sat; - break; - } - - if (sat == unknown_sat) - sipFindSigArgType(dp, btlen, &psig->sg_args[a], indir); - else - { - if (unsup) - sat = unknown_sat; - - psig->sg_args[a].atype = sat; - } - - /* Move to the start of the next argument. */ - arg += strlen(arg) + 1; - } - } - } - - /* Make a deep copy of the signal. */ - strcpy(psig->sg_signature, sig); - - /* Add it to the list so it can be re-used. */ - psig->sg_next = psig_list; - psig_list = psig; - - return psig; -} - - -/* - * Find an existing signal. - */ -static void *findSignal(void *txrx, const char **sig) -{ - sipSignature *psig; - - /* - * Handle the trivial case where the Qt implementation doesn't support - * universal signals. - */ - if (sipQtSupport->qt_is_qt_signal == NULL) - return txrx; - - /* See if this a shortcircuited Python signal. */ - if (strchr(*sig, '(') == NULL) - return sipQtSupport->qt_find_universal_signal_shortcut(txrx, *sig, sig); - - /* See if the existing object can be used itself. */ - if (sipQtSupport->qt_is_qt_signal(txrx, *sig)) - return txrx; - - if ((psig = sip_api_parse_signature(*sig)) == NULL) - return NULL; - - /* Find an ordinary universal signal. */ - return sipQtSupport->qt_find_universal_signal(txrx, psig); -} - - -/* - * Return a usable signal, creating a new universal signal if needed. - */ -static void *newSignal(void *txrx, const char **sig) -{ - sipSignature *psig; - - /* - * Handle the trivial case where the Qt implementation doesn't support - * universal signals. - */ - if (sipQtSupport->qt_is_qt_signal == NULL) - return txrx; - - /* See if this a shortcircuited Python signal. */ - if (strchr(*sig, '(') == NULL) - return sipQtSupport->qt_create_universal_signal_shortcut(txrx, *sig, sig); - - /* See if the existing object can be used itself. */ - if (sipQtSupport->qt_is_qt_signal(txrx, *sig)) - return txrx; - - if ((psig = sip_api_parse_signature(*sig)) == NULL) - return NULL; - - /* Create an ordinary universal signal. */ - return sipQtSupport->qt_create_universal_signal(txrx, psig); -} - - -/* - * Create a universal slot. Returns a pointer to it or 0 if there was an - * error. - */ -static void *createUniversalSlot(sipWrapper *txSelf, const char *sig, - PyObject *rxObj, const char *slot, - const char **member) -{ - sipSlotConnection conn; - void *us; - - /* Initialise the connection. */ - conn.sc_transmitter = (txSelf ? sipGetAddress(txSelf) : 0); - - /* Save the real slot. */ - if (saveSlot(&conn.sc_slot, rxObj, slot) < 0) - return 0; - - /* Parse the signature and create the universal slot. */ - if ((conn.sc_signature = sip_api_parse_signature(sig)) == NULL || (us = sipQtSupport->qt_create_universal_slot(txSelf, &conn, member)) == NULL) - { - sip_api_free_connection(&conn); - return 0; - } - - return us; -} - - -/* - * Emit a Python or Qt signal. - */ -int sip_api_emit_signal(PyObject *self,const char *sig,PyObject *sigargs) -{ - sipPySig *ps; - void *tx; - sipWrapper *w = (sipWrapper *)self; - - /* - * Don't do anything if signals are blocked. Qt signals would be blocked - * anyway, but this blocks Python signals as well. - */ - if ((tx = sip_api_get_cpp_ptr(w, sipQObjectClass)) == NULL || sipQtSupport->qt_signals_blocked(tx)) - return 0; - - if (isQtSignal(sig)) - { - sipSignature *psig; - - /* Handle Qt implementations that emit using generated code. */ - if (!sipQtSupport->qt_emit_signal) - return emitQtSig(w, sig, sigargs); - - /* See if the signal is a shortcut. */ - if (strchr(sig, '(') == NULL) - return sipQtSupport->qt_emit_signal_shortcut(tx, sig, sigargs); - - if ((psig = sip_api_parse_signature(sig)) == NULL) - return -1; - - if (psig->sg_nrargs != PyTuple_GET_SIZE(sigargs)) - PyErr_Format(PyExc_TypeError, "Signal has %d arguments, but %d given", psig->sg_nrargs, PyTuple_GET_SIZE(sigargs)); - - return sipQtSupport->qt_emit_signal(tx, psig, sigargs); - } - - if ((ps = findPySignal(w,sig)) != NULL) - { - int rc; - - /* Forget the last Qt sender and remember this one. */ - sipQtSupport->qt_forget_sender(); - py_sender = self; - - rc = emitToSlotList(ps -> rxlist,sigargs); - - /* Forget this as a sender. */ - py_sender = NULL; - - return rc; - } - - return 0; -} - - -/* - * Search the Python signal list for a signal. - */ -static sipPySig *findPySignal(sipWrapper *w,const char *sig) -{ - sipPySig *ps; - - for (ps = w -> pySigList; ps != NULL; ps = ps -> next) - if (sipQtSupport->qt_same_name(ps -> name,sig)) - return ps; - - return NULL; -} - - -/* - * Search a signal table for a signal. If found, call the emitter function - * with the signal arguments. Return 0 if the signal was emitted or <0 if - * there was an error. - */ -static int emitQtSig(sipWrapper *w,const char *sig,PyObject *sigargs) -{ - sipQtSignal *tab; - - /* Search the table. */ - for (tab = ((sipWrapperType *)(w -> ob_type)) -> type -> td_emit; tab -> st_name != NULL; ++tab) - { - const char *sp, *tp; - int found; - - /* Compare only the base name. */ - sp = &sig[1]; - tp = tab -> st_name; - - found = TRUE; - - while (*sp != '\0' && *sp != '(' && *tp != '\0') - if (*sp++ != *tp++) - { - found = FALSE; - break; - } - - if (found) - return (*tab -> st_emitfunc)(w,sigargs); - } - - /* It wasn't found if we got this far. */ - PyErr_Format(PyExc_NameError,"Invalid signal %s",&sig[1]); - - return -1; -} - - -/* - * Send a signal to a single slot (Qt or Python). - */ -int sip_api_emit_to_slot(sipSlot *slot, PyObject *sigargs) -{ - PyObject *sa, *oxtype, *oxvalue, *oxtb, *sfunc, *newmeth, *sref; - - /* Keep some compilers quiet. */ - oxtype = oxvalue = oxtb = NULL; - - /* Fan out Qt signals. */ - if (slot -> name != NULL && slot -> name[0] != '\0') - return sip_api_emit_signal(slot -> pyobj,slot -> name,sigargs); - - /* Get the object to call, resolving any weak references. */ - if (slot -> weakSlot == NULL) - sref = NULL; - else if ((sref = PyWeakref_GetObject(slot -> weakSlot)) == NULL) - return -1; - else - Py_INCREF(sref); - - if (sref == Py_None) - { - /* - * If the real object has gone then we pretend everything is Ok. This - * mimics the Qt behaviour of not caring if a receiving object has been - * deleted. - */ - Py_DECREF(sref); - return 0; - } - - if (slot -> pyobj == NULL) - { - PyObject *self = (sref != NULL ? sref : slot->meth.mself); - - /* See if any underlying C++ instance has gone. */ - if (self != NULL && sip_api_wrapper_check(self) && ((sipWrapper *)self)->u.cppPtr == NULL) - { - Py_XDECREF(sref); - return 0; - } - - if ((sfunc = PyMethod_New(slot->meth.mfunc, self, slot->meth.mclass)) == NULL) - { - Py_XDECREF(sref); - return -1; - } - - /* Make sure we garbage collect the new method. */ - newmeth = sfunc; - } - else if (slot -> name != NULL) - { - char *mname = slot -> name + 1; - PyObject *self = (sref != NULL ? sref : slot->pyobj); - - /* See if any underlying C++ instance has gone. */ - if (self != NULL && sip_api_wrapper_check(self) && ((sipWrapper *)self)->u.cppPtr == NULL) - { - Py_XDECREF(sref); - return 0; - } - - if ((sfunc = PyObject_GetAttrString(self, mname)) == NULL || !PyCFunction_Check(sfunc)) - { - /* - * Note that in earlier versions of SIP this error would be - * detected when the slot was connected. - */ - PyErr_Format(PyExc_NameError,"Invalid slot %s",mname); - - Py_XDECREF(sref); - return -1; - } - - /* Make sure we garbage collect the new method. */ - newmeth = sfunc; - } - else if (slot->pyobj == Py_None) - { - /* - * This was a lambda function that has been freed by the cyclic garbage - * collector so ignore it. - */ - Py_XDECREF(sref); - return 0; - } - else - { - sfunc = slot -> pyobj; - newmeth = NULL; - } - - /* - * We make repeated attempts to call a slot. If we work out that it failed - * because of an immediate type error we try again with one less argument. - * We keep going until we run out of arguments to drop. This emulates the - * Qt ability of the slot to accept fewer arguments than a signal provides. - */ - sa = sigargs; - Py_INCREF(sa); - - for (;;) - { - PyObject *nsa, *xtype, *xvalue, *xtb, *resobj; - - if ((resobj = PyEval_CallObject(sfunc,sa)) != NULL) - { - Py_DECREF(resobj); - - Py_XDECREF(newmeth); - Py_XDECREF(sref); - - /* Remove any previous exception. */ - - if (sa != sigargs) - { - Py_XDECREF(oxtype); - Py_XDECREF(oxvalue); - Py_XDECREF(oxtb); - PyErr_Clear(); - } - - Py_DECREF(sa); - - return 0; - } - - /* Get the exception. */ - PyErr_Fetch(&xtype,&xvalue,&xtb); - - /* - * See if it is unacceptable. An acceptable failure is a type error - * with no traceback - so long as we can still reduce the number of - * arguments and try again. - */ - if (!PyErr_GivenExceptionMatches(xtype,PyExc_TypeError) || - xtb != NULL || - PyTuple_GET_SIZE(sa) == 0) - { - /* - * If there is a traceback then we must have called the slot and - * the exception was later on - so report the exception as is. - */ - if (xtb != NULL) - { - if (sa != sigargs) - { - Py_XDECREF(oxtype); - Py_XDECREF(oxvalue); - Py_XDECREF(oxtb); - } - - PyErr_Restore(xtype,xvalue,xtb); - } - else if (sa == sigargs) - PyErr_Restore(xtype,xvalue,xtb); - else - { - /* - * Discard the latest exception and restore the original one. - */ - Py_XDECREF(xtype); - Py_XDECREF(xvalue); - Py_XDECREF(xtb); - - PyErr_Restore(oxtype,oxvalue,oxtb); - } - - break; - } - - /* If this is the first attempt, save the exception. */ - if (sa == sigargs) - { - oxtype = xtype; - oxvalue = xvalue; - oxtb = xtb; - } - else - { - Py_XDECREF(xtype); - Py_XDECREF(xvalue); - Py_XDECREF(xtb); - } - - /* Create the new argument tuple. */ - if ((nsa = PyTuple_GetSlice(sa,0,PyTuple_GET_SIZE(sa) - 1)) == NULL) - { - /* Tidy up. */ - Py_XDECREF(oxtype); - Py_XDECREF(oxvalue); - Py_XDECREF(oxtb); - - break; - } - - Py_DECREF(sa); - sa = nsa; - } - - Py_XDECREF(newmeth); - Py_XDECREF(sref); - - Py_DECREF(sa); - - return -1; -} - - -/* - * Send a signal to the slots (Qt or Python) in a Python list. - */ -static int emitToSlotList(sipSlotList *rxlist,PyObject *sigargs) -{ - int rc; - - /* Apply the arguments to each slot method. */ - rc = 0; - - while (rxlist != NULL && rc >= 0) - { - sipSlotList *next; - - /* - * We get the next in the list before calling the slot in case the list - * gets changed by the slot - usually because the slot disconnects - * itself. - */ - next = rxlist -> next; - rc = sip_api_emit_to_slot(&rxlist -> rx, sigargs); - rxlist = next; - } - - return rc; -} - - -/* - * Add a slot to a transmitter's Python signal list. The signal is a Python - * signal, the slot may be either a Qt signal, a Qt slot, a Python signal or a - * Python slot. - */ -static int addSlotToPySigList(sipWrapper *txSelf,const char *sig, - PyObject *rxObj,const char *slot) -{ - sipPySig *ps; - sipSlotList *psrx; - - /* Create a new one if necessary. */ - if ((ps = findPySignal(txSelf,sig)) == NULL) - { - if ((ps = (sipPySig *)sip_api_malloc(sizeof (sipPySig))) == NULL) - return -1; - - if ((ps -> name = sipStrdup(sig)) == NULL) - { - sip_api_free(ps); - return -1; - } - - ps -> rxlist = NULL; - ps -> next = txSelf -> pySigList; - - txSelf -> pySigList = ps; - } - - /* Create the new receiver. */ - if ((psrx = (sipSlotList *)sip_api_malloc(sizeof (sipSlotList))) == NULL) - return -1; - - if (saveSlot(&psrx->rx, rxObj, slot) < 0) - { - sip_api_free(psrx); - return -1; - } - - psrx -> next = ps -> rxlist; - ps -> rxlist = psrx; - - return 0; -} - - -/* - * Compare two slots to see if they are the same. - */ -static int isSameSlot(sipSlot *slot1,PyObject *rxobj2,const char *slot2) -{ - /* See if they are signals or Qt slots, ie. they have a name. */ - if (slot1 -> name != NULL) - return (slot2 != NULL && - sipQtSupport->qt_same_name(slot1 -> name,slot2) && - slot1 -> pyobj == rxobj2); - - /* Both must be Python slots. */ - if (slot2 != NULL) - return 0; - - /* See if they are Python methods. */ - if (slot1 -> pyobj == NULL) - return (PyMethod_Check(rxobj2) && - slot1 -> meth.mfunc == PyMethod_GET_FUNCTION(rxobj2) && - slot1 -> meth.mself == PyMethod_GET_SELF(rxobj2) && - slot1 -> meth.mclass == PyMethod_GET_CLASS(rxobj2)); - - if (PyMethod_Check(rxobj2)) - return 0; - - /* The objects must be the same. */ - return (slot1 -> pyobj == rxobj2); -} - - -/* - * Convert a valid Python signal or slot to an existing universal slot. - */ -void *sipGetRx(sipWrapper *txSelf,const char *sigargs,PyObject *rxObj, - const char *slot,const char **memberp) -{ - if (slot != NULL) - if (isQtSlot(slot) || isQtSignal(slot)) - { - void *rx; - - *memberp = slot; - - if ((rx = sip_api_get_cpp_ptr((sipWrapper *)rxObj, sipQObjectClass)) == NULL) - return NULL; - - if (isQtSignal(slot)) - rx = findSignal(rx, memberp); - - return rx; - } - - /* - * The slot was either a Python callable or PyQt3 Python signal so there - * should be a universal slot. - */ - return sipQtSupport->qt_find_slot(sipGetAddress(txSelf), sigargs, rxObj, slot, memberp); -} - - -/* - * Convert a Python receiver (either a Python signal or slot or a Qt signal or - * slot) to a Qt receiver. It is only ever called when the signal is a Qt - * signal. Return NULL is there was an error. - */ -void *sip_api_convert_rx(sipWrapper *txSelf,const char *sig,PyObject *rxObj, - const char *slot,const char **memberp) -{ - if (slot == NULL) - return createUniversalSlot(txSelf, sig, rxObj, NULL, memberp); - - if (isQtSlot(slot) || isQtSignal(slot)) - { - void *rx; - - *memberp = slot; - - if ((rx = sip_api_get_cpp_ptr((sipWrapper *)rxObj, sipQObjectClass)) == NULL) - return NULL; - - if (isQtSignal(slot)) - rx = newSignal(rx, memberp); - - return rx; - } - - /* The slot is a Python signal so we need a universal slot to catch it. */ - return createUniversalSlot(txSelf, sig, rxObj, slot, memberp); -} - - -/* - * Connect a Qt signal or a Python signal to a Qt slot, a Qt signal, a Python - * slot or a Python signal. This is all possible combinations. - */ -PyObject *sip_api_connect_rx(PyObject *txObj,const char *sig,PyObject *rxObj, - const char *slot, int type) -{ - sipWrapper *txSelf = (sipWrapper *)txObj; - - /* Handle Qt signals. */ - if (isQtSignal(sig)) - { - void *tx, *rx; - const char *member, *real_sig; - int res; - - if ((tx = sip_api_get_cpp_ptr(txSelf, sipQObjectClass)) == NULL) - return NULL; - - real_sig = sig; - - if ((tx = newSignal(tx, &real_sig)) == NULL) - return NULL; - - if ((rx = sip_api_convert_rx(txSelf, sig, rxObj, slot, &member)) == NULL) - return NULL; - - res = sipQtSupport->qt_connect(tx, real_sig, rx, member, type); - - return PyBool_FromLong(res); - } - - /* Handle Python signals. */ - if (addSlotToPySigList(txSelf, sig, rxObj, slot) < 0) - return NULL; - - Py_INCREF(Py_True); - return Py_True; -} - - -/* - * Disconnect a signal to a signal or a Qt slot. - */ -PyObject *sip_api_disconnect_rx(PyObject *txObj,const char *sig, - PyObject *rxObj,const char *slot) -{ - sipWrapper *txSelf = (sipWrapper *)txObj; - - /* Handle Qt signals. */ - if (isQtSignal(sig)) - { - void *tx, *rx; - const char *member; - int res; - - if ((tx = sip_api_get_cpp_ptr(txSelf, sipQObjectClass)) == NULL) - return NULL; - - if ((rx = sipGetRx(txSelf, sig, rxObj, slot, &member)) == NULL) - { - Py_INCREF(Py_False); - return Py_False; - } - - /* Handle Python signals. */ - tx = findSignal(tx, &sig); - - res = sipQtSupport->qt_disconnect(tx, sig, rx, member); - - /* - * Delete it if it is a universal slot as this will be it's only - * connection. If the slot is actually a universal signal then it - * should leave it in place. - */ - sipQtSupport->qt_destroy_universal_slot(rx); - - return PyBool_FromLong(res); - } - - /* Handle Python signals. */ - removeSlotFromPySigList(txSelf,sig,rxObj,slot); - - Py_INCREF(Py_True); - return Py_True; -} - - -/* - * Remove a slot from a transmitter's Python signal list. - */ -static void removeSlotFromPySigList(sipWrapper *txSelf,const char *sig, - PyObject *rxObj,const char *slot) -{ - sipPySig *ps; - - if ((ps = findPySignal(txSelf,sig)) != NULL) - { - sipSlotList **psrxp; - - for (psrxp = &ps -> rxlist; *psrxp != NULL; psrxp = &(*psrxp) -> next) - { - sipSlotList *psrx = *psrxp; - - if (isSameSlot(&psrx -> rx,rxObj,slot)) - { - *psrxp = psrx -> next; - sipFreeSlotList(psrx); - break; - } - } - } -} - - -/* - * Free a sipSlot structure. - */ -static void freeSlot(sipSlot *slot) -{ - if (slot->name != NULL) - sip_api_free(slot->name); - else - { - PyObject *lam = slot->pyobj; - - if (lam != NULL && (lam == Py_None || sipLambdaSlot(lam))) - Py_DECREF(lam); - } - - /* Remove any weak reference. */ - Py_XDECREF(slot->weakSlot); -} - - -/* - * Free a sipSlotList structure on the heap. - */ -void sipFreeSlotList(sipSlotList *rx) -{ - freeSlot(&rx->rx); - sip_api_free(rx); -} - - -/* - * Implement strdup() using sip_api_malloc(). - */ -static char *sipStrdup(const char *s) -{ - char *d; - - if ((d = (char *)sip_api_malloc(strlen(s) + 1)) != NULL) - strcpy(d,s); - - return d; -} - - -/* - * Initialise a slot, returning 0 if there was no error. If the signal was a - * Qt signal, then the slot may be a Python signal or a Python slot. If the - * signal was a Python signal, then the slot may be anything. - */ -static int saveSlot(sipSlot *sp, PyObject *rxObj, const char *slot) -{ - sp -> weakSlot = NULL; - - if (slot == NULL) - { - sp -> name = NULL; - - if (PyMethod_Check(rxObj)) - { - /* - * Python creates methods on the fly. We could increment the - * reference count to keep it alive, but that would keep "self" - * alive as well and would probably be a circular reference. - * Instead we remember the component parts and hope they are still - * valid when we re-create the method when we need it. - */ - sipSaveMethod(&sp -> meth,rxObj); - - /* Notice if the class instance disappears. */ - sp -> weakSlot = getWeakRef(sp -> meth.mself); - - /* This acts a flag to say that the slot is a method. */ - sp -> pyobj = NULL; - } - else - { - PyObject *self; - - /* - * We know that it is another type of callable, ie. a - * function/builtin. - */ - - if (PyCFunction_Check(rxObj) && - (self = PyCFunction_GET_SELF(rxObj)) != NULL && - sip_api_wrapper_check(self)) - { - /* - * It is a wrapped C++ class method. We can't keep a copy - * because they are generated on the fly and we can't take a - * reference as that may keep the instance (ie. self) alive. - * We therefore treat it as if the user had specified the slot - * at "obj, TQT_SLOT('meth()')" rather than "obj.meth" (see below). - */ - - const char *meth; - - /* Get the method name. */ - meth = ((PyCFunctionObject *)rxObj) -> m_ml -> ml_name; - - if ((sp -> name = (char *)sip_api_malloc(strlen(meth) + 2)) == NULL) - return -1; - - /* - * Copy the name and set the marker that it needs converting to - * a built-in method. - */ - sp -> name[0] = '\0'; - strcpy(&sp -> name[1],meth); - - sp -> pyobj = self; - sp -> weakSlot = getWeakRef(self); - } - else - { - /* - * A bit of a hack to allow lamba functions to be used as - * slots. - */ - if (sipLambdaSlot(rxObj)) - Py_INCREF(rxObj); - - /* - * It's unlikely that we will succeed in getting a weak - * reference to the slot, but there is no harm in trying (and - * future versions of Python may support references to more - * object types). - */ - sp -> pyobj = rxObj; - sp -> weakSlot = getWeakRef(rxObj); - } - } - } - else if ((sp -> name = sipStrdup(slot)) == NULL) - return -1; - else if (isQtSlot(slot)) - { - /* - * The user has decided to connect a Python signal to a Qt slot and - * specified the slot as "obj, TQT_SLOT('meth()')" rather than "obj.meth". - */ - - char *tail; - - /* Remove any arguments. */ - if ((tail = strchr(sp -> name,'(')) != NULL) - *tail = '\0'; - - /* - * A bit of a hack to indicate that this needs converting to a built-in - * method. - */ - sp -> name[0] = '\0'; - - /* Notice if the class instance disappears. */ - sp -> weakSlot = getWeakRef(rxObj); - - sp -> pyobj = rxObj; - } - else - /* It's a Qt signal. */ - sp -> pyobj = rxObj; - - return 0; -} - - -/* - * Return a weak reference to the given object. - */ -static PyObject *getWeakRef(PyObject *obj) -{ - PyObject *wr; - - if ((wr = PyWeakref_NewRef(obj,NULL)) == NULL) - PyErr_Clear(); - - return wr; -} - - -/* - * See if an object is a lambda function. - */ -int sipLambdaSlot(PyObject *slotObj) -{ - if (!PyFunction_Check(slotObj)) - return FALSE; - - return (strcmp(PyString_AsString(((PyFunctionObject *)slotObj)->func_name), "<lambda>") == 0); -} diff --git a/python/sip/siplib/sip.h b/python/sip/siplib/sip.h deleted file mode 100644 index 92bcda4e..00000000 --- a/python/sip/siplib/sip.h +++ /dev/null @@ -1,1302 +0,0 @@ -/* - * The SIP module interface. - * - * Copyright (c) 2007 - * Riverbank Computing Limited <info@riverbankcomputing.co.uk> - * - * This file is part of SIP. - * - * This copy of SIP is licensed for use under the terms of the SIP License - * Agreement. See the file LICENSE for more details. - * - * SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - - -#ifndef _SIP_H -#define _SIP_H - - -/* - * This gets round a problem with Qt's moc and Python v2.3. Strictly speaking - * it's a Qt problem but later versions of Python include a fix for it so we - * might as well too. - */ -#undef slots - - -#include <Python.h> - -/* - * There is a mis-feature somewhere with the Borland compiler. This works - * around it. - */ -#if defined(__BORLANDC__) -#include <rpc.h> -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Sanity check on the Python version. */ -#if PY_VERSION_HEX < 0x02030000 -#error "This version of SIP requires Python v2.3 or later" -#endif - - -/* - * Define the SIP version number. - */ -#define SIP_VERSION 0x040600 -#define SIP_VERSION_STR "4.6" - - -/* - * Define the current API version number. SIP must handle modules with the - * same major number and with the same or earlier minor number. Whenever data - * structure elements are added they must be appended and the minor number - * incremented. Whenever data structure elements are removed or the order - * changed then the major number must be incremented and the minor number set - * to 0. - * - * History: - * - * 3.4 Added qt_find_connection() to the Qt support API. - * Added sip_api_string_as_char(), sip_api_unicode_as_wchar(), - * sip_api_unicode_as_wstring(), sip_api_find_class(), - * sip_api_find_named_enum() and sip_api_parse_signature(). - * Added the 'A', 'w' and 'x' format characters to sip_api_parse_args(), - * sip_api_parse_result(), sip_api_build_result() and - * sip_api_call_method(). - * - * 3.3 Added sip_api_register_int_types(). - * - * 3.2 Added sip_api_export_symbol() and sip_api_import_symbol(). - * - * 3.1 Added sip_api_add_mapped_type_instance(). - * - * 3.0 Moved the Qt support out of the sip module and into PyQt. This is - * such a dramatic change that there is no point in attempting to maintain - * backwards compatibility. - * - * 2.0 Added the td_flags field to the sipTypeDef structure. - * Added the first_child, sibling_next, sibling_prev and parent fields to - * the sipWrapper structure. - * Added the td_traverse and td_clear fields to the sipTypeDef structure. - * Added the em_api_minor field to the sipExportedModuleDef structure. - * Added sip_api_bad_operator_arg(). - * Added sip_api_wrapper_check(). - * - * 1.1 Added support for __pos__ and __abs__. - * - * 1.0 Removed all deprecated parts of the API. - * Removed the td_proxy field from the sipTypeDef structure. - * Removed the create proxy function from the 'q' and 'y' format - * characters to sip_api_parse_args(). - * Removed sip_api_emit_to_slot(). - * Reworked the enum related structures. - * - * 0.2 Added the 'H' format character to sip_api_parse_args(). - * - * 0.1 Added sip_api_add_class_instance(). - * Added the 't' format character to sip_api_parse_args(). - * Deprecated the 'J' and 'K' format characters to sip_api_parse_result(). - * - * 0.0 Original version. - */ -#define SIP_API_MAJOR_NR 3 -#define SIP_API_MINOR_NR 4 - - -/* Some compatibility stuff to help with handwritten code for SIP v3. */ -#if !defined(ANY) -#define ANY void -#endif - - -/* Some Python compatibility stuff. */ -#if PY_VERSION_HEX >= 0x02050000 -#define SIP_SSIZE_T Py_ssize_t -#else -#define SIP_SSIZE_T int -#endif - - -/* - * The mask that can be passed to sipTrace(). - */ -#define SIP_TRACE_CATCHERS 0x0001 -#define SIP_TRACE_CTORS 0x0002 -#define SIP_TRACE_DTORS 0x0004 -#define SIP_TRACE_INITS 0x0008 -#define SIP_TRACE_DEALLOCS 0x0010 -#define SIP_TRACE_METHODS 0x0020 - - -/* - * Hide some thread dependent stuff. - */ -#ifdef WITH_THREAD -typedef PyGILState_STATE sip_gilstate_t; -#define SIP_RELEASE_GIL(gs) PyGILState_Release(gs); -#define SIP_BLOCK_THREADS {PyGILState_STATE sipGIL = PyGILState_Ensure(); -#define SIP_UNBLOCK_THREADS PyGILState_Release(sipGIL);} -#else -typedef int sip_gilstate_t; -#define SIP_RELEASE_GIL(gs) -#define SIP_BLOCK_THREADS -#define SIP_UNBLOCK_THREADS -#endif - - -/* - * The metatype of a wrapper type. - */ -typedef struct _sipWrapperType { - /* - * The super-metatype. This must be first in the structure so that it can - * be cast to a PyTypeObject *. - */ - PyHeapTypeObject super; - - /* The additional type information. */ - struct _sipTypeDef *type; - - /* The list of init extenders. */ - struct _sipInitExtenderDef *iextend; - - /* The optional PyQt defined Q_OBJECT information. */ - void *qt_qobject; -} sipWrapperType; - - -/* - * The type of a C/C++ wrapper object. - */ -typedef struct _sipWrapper { - PyObject_HEAD - - /* For the user to use. */ - PyObject *user; - - union { - /* C/C++ object pointer. */ - void *cppPtr; - - /* Access function. */ - void *(*afPtr)(); - } u; - - /* Object flags. */ - int flags; - - /* The instance dictionary. */ - PyObject *dict; - - /* Python signal list (complex). */ - struct _sipPySig *pySigList; - - /* Next object at this address. */ - struct _sipWrapper *next; - - /* First child object. */ - struct _sipWrapper *first_child; - - /* Next sibling. */ - struct _sipWrapper *sibling_next; - - /* Previous sibling. */ - struct _sipWrapper *sibling_prev; - - /* Owning object. */ - struct _sipWrapper *parent; -} sipWrapper; - - -/* - * Some convenient function pointers. - */ -typedef void *(*sipInitFunc)(sipWrapper *, PyObject *, sipWrapper **, int *); -typedef int (*sipTraverseFunc)(void *, visitproc, void *); -typedef int (*sipClearFunc)(void *); -typedef SIP_SSIZE_T (*sipBufferFunc)(PyObject *, void *, SIP_SSIZE_T, void **); -typedef SIP_SSIZE_T (*sipSegCountFunc)(PyObject *, void *, SIP_SSIZE_T *); -typedef void (*sipDeallocFunc)(sipWrapper *); -typedef void *(*sipCastFunc)(void *, sipWrapperType *); -typedef sipWrapperType *(*sipSubClassConvertFunc)(void **); -typedef void *(*sipForceConvertToFunc)(PyObject *, int *); -typedef int (*sipConvertToFunc)(PyObject *, void **, int *, PyObject *); -typedef PyObject *(*sipConvertFromFunc)(void *, PyObject *); -typedef int (*sipVirtHandlerFunc)(void *, PyObject *, ...); -typedef int (*sipEmitFunc)(sipWrapper *, PyObject *); -typedef void (*sipReleaseFunc)(void *, int); - - -/* - * The information describing an encoded class ID. - */ -typedef struct _sipEncodedClassDef { - /* The class number. */ - unsigned sc_class:16; - - /* The module number (255 for this one). */ - unsigned sc_module:8; - - /* A context specific flag. */ - unsigned sc_flag:1; -} sipEncodedClassDef; - - -/* - * The information describing an enum member. - */ -typedef struct _sipEnumMemberDef { - /* The member name. */ - const char *em_name; - - /* The member value. */ - int em_val; - - /* The member enum, -ve if anonymous. */ - int em_enum; -} sipEnumMemberDef; - - -/* - * The information describing a named enum. - */ -typedef struct _sipEnumDef { - /* The Python name of the enum. */ - const char *e_name; - - /* The C/C++ name of the enum, NULL if the same as the Python name. */ - const char *e_cname; - - /* The scoping type. */ - int e_scope; - - /* The Python slots. */ - struct _sipPySlotDef *e_pyslots; -} sipEnumDef; - - -/* - * The information describing static instances. - */ -typedef struct _sipInstancesDef { - /* The classes. */ - struct _sipClassInstanceDef *id_class; - - /* The void *. */ - struct _sipVoidPtrInstanceDef *id_voidp; - - /* The chars. */ - struct _sipCharInstanceDef *id_char; - - /* The strings. */ - struct _sipStringInstanceDef *id_string; - - /* The ints. */ - struct _sipIntInstanceDef *id_int; - - /* The longs. */ - struct _sipLongInstanceDef *id_long; - - /* The unsigned longs. */ - struct _sipUnsignedLongInstanceDef *id_ulong; - - /* The long longs. */ - struct _sipLongLongInstanceDef *id_llong; - - /* The unsigned long longs. */ - struct _sipUnsignedLongLongInstanceDef *id_ullong; - - /* The doubles. */ - struct _sipDoubleInstanceDef *id_double; - - /* The enums. */ - struct _sipEnumInstanceDef *id_enum; -} sipInstancesDef; - - -/* - * The information describing a type initialiser extender. - */ -typedef struct _sipInitExtenderDef { - /* The extender function. */ - sipInitFunc ie_extender; - - /* The class being extended. */ - sipEncodedClassDef ie_class; - - /* The next extender for this class. */ - struct _sipInitExtenderDef *ie_next; -} sipInitExtenderDef; - - -/* - * The information describing a sub-class convertor. - */ -typedef struct _sipSubClassConvertorDef { - /* The convertor. */ - sipSubClassConvertFunc scc_convertor; - - /* The encoded base type. */ - sipEncodedClassDef scc_base; - - /* The base type. */ - sipWrapperType *scc_basetype; -} sipSubClassConvertorDef; - - -/* - * The different Python slot types. - */ -typedef enum { - str_slot, /* __str__ */ - int_slot, /* __int__ */ - long_slot, /* __long__ */ - float_slot, /* __float__ */ - len_slot, /* __len__ */ - contains_slot, /* __contains__ */ - add_slot, /* __add__ for number */ - concat_slot, /* __add__ for sequence types */ - sub_slot, /* __sub__ */ - mul_slot, /* __mul__ for number types */ - repeat_slot, /* __mul__ for sequence types */ - div_slot, /* __div__ */ - mod_slot, /* __mod__ */ - and_slot, /* __and__ */ - or_slot, /* __or__ */ - xor_slot, /* __xor__ */ - lshift_slot, /* __lshift__ */ - rshift_slot, /* __rshift__ */ - iadd_slot, /* __iadd__ for number types */ - iconcat_slot, /* __iadd__ for sequence types */ - isub_slot, /* __isub__ */ - imul_slot, /* __imul__ for number types */ - irepeat_slot, /* __imul__ for sequence types */ - idiv_slot, /* __idiv__ */ - imod_slot, /* __imod__ */ - iand_slot, /* __iand__ */ - ior_slot, /* __ior__ */ - ixor_slot, /* __ixor__ */ - ilshift_slot, /* __ilshift__ */ - irshift_slot, /* __irshift__ */ - invert_slot, /* __invert__ */ - call_slot, /* __call__ */ - getitem_slot, /* __getitem__ */ - setitem_slot, /* __setitem__ */ - delitem_slot, /* __delitem__ */ - lt_slot, /* __lt__ */ - le_slot, /* __le__ */ - eq_slot, /* __eq__ */ - ne_slot, /* __ne__ */ - gt_slot, /* __gt__ */ - ge_slot, /* __ge__ */ - cmp_slot, /* __cmp__ */ - nonzero_slot, /* __nonzero__ */ - neg_slot, /* __neg__ */ - repr_slot, /* __repr__ */ - hash_slot, /* __hash__ */ - pos_slot, /* __pos__ */ - abs_slot /* __abs__ */ -} sipPySlotType; - - -/* - * The information describing a Python slot function. - */ -typedef struct _sipPySlotDef { - /* The function. */ - void *psd_func; - - /* The type. */ - sipPySlotType psd_type; -} sipPySlotDef; - - -/* - * The information describing a Python slot extender. - */ -typedef struct _sipPySlotExtenderDef { - /* The function. */ - void *pse_func; - - /* The type. */ - sipPySlotType pse_type; - - /* The encoded class. */ - sipEncodedClassDef pse_class; -} sipPySlotExtenderDef; - - -/* - * This enumerates the different dynamic signal argument types. - */ -typedef enum { - unknown_sat, - char_sat, - uchar_sat, - string_sat, - ustring_sat, - short_sat, - ushort_sat, - int_sat, - uint_sat, - long_sat, - ulong_sat, - longlong_sat, - ulonglong_sat, - float_sat, - double_sat, - enum_sat, - bool_sat, - void_sat, - class_sat, - classp_sat, - mtype_sat, - mtypep_sat, - qvariant_sat, - qvariantp_sat, - pyobject_sat, - schar_sat, - sstring_sat, - wchar_sat, - wstring_sat -} sipSigArgType; - - -/* - * The information describing a typedef. - */ -typedef struct _sipTypedefDef { - /* The typedef name. */ - const char *tdd_name; - - /* The typedef type. */ - sipSigArgType tdd_type; - - /* The type name for enum_sat, class_sat and mtype_sat. */ - const char *tdd_type_name; - - /* The defining module, NULL if the current one. */ - const char *tdd_mod_name; -} sipTypedefDef; - - -/* - * The information describing a type. - */ -typedef struct _sipTypeDef { - /* The module. */ - struct _sipExportedModuleDef *td_module; - - /* Type flags, see the sipType*() macros. */ - int td_flags; - - /* The Python name of the type. */ - const char *td_name; - - /* The C/C++ name of the type, NULL if the same as the Python name. */ - const char *td_cname; - - /* The scoping type. */ - sipEncodedClassDef td_scope; - - /* The super-types. */ - sipEncodedClassDef *td_supers; - - /* The table of Python slots. */ - sipPySlotDef *td_pyslots; - - /* The number of lazy methods. */ - int td_nrmethods; - - /* The table of lazy methods. */ - PyMethodDef *td_methods; - - /* The number of lazy enum members. */ - int td_nrenummembers; - - /* The table of lazy enum members. */ - sipEnumMemberDef *td_enummembers; - - /* The variable table. */ - PyMethodDef *td_variables; - - /* The initialisation function. */ - sipInitFunc td_init; - - /* The traverse function. */ - sipTraverseFunc td_traverse; - - /* The clear function. */ - sipClearFunc td_clear; - - /* The read buffer function. */ - sipBufferFunc td_readbuffer; - - /* The write buffer function. */ - sipBufferFunc td_writebuffer; - - /* The segment count function. */ - sipSegCountFunc td_segcount; - - /* The char buffer function. */ - sipBufferFunc td_charbuffer; - - /* The deallocation function. */ - sipDeallocFunc td_dealloc; - - /* The cast function, 0 if a C struct. */ - sipCastFunc td_cast; - - /* The release function. */ - sipReleaseFunc td_release; - - /* The force convert to function, 0 if a C++ namespace. */ - sipForceConvertToFunc td_fcto; - - /* The convert to function. */ - sipConvertToFunc td_cto; - - /* Emit table for Qt signals. */ - struct _sipQtSignal *td_emit; - - /* The static instances. */ - sipInstancesDef td_instances; - - /* The next namespace extender. */ - struct _sipTypeDef *td_nsextender; -} sipTypeDef; - - -/* - * The information describing an external type. - */ -typedef struct _sipExternalTypeDef { - /* The index into the type table. */ - int et_nr; - - /* The name of the type. */ - const char *et_name; -} sipExternalTypeDef; - - -/* - * The information describing a mapped class. - */ -typedef struct _sipMappedType { - /* The corresponding C++ definition. */ - const char *mt_name; - - /* The release function. */ - sipReleaseFunc mt_release; - - /* The force convert to function. */ - sipForceConvertToFunc mt_fcto; - - /* The convert to function. */ - sipConvertToFunc mt_cto; - - /* The convert from function. */ - sipConvertFromFunc mt_cfrom; -} sipMappedType; - - -/* - * Defines an entry in the module specific list of delayed dtor calls. - */ -typedef struct _sipDelayedDtor { - /* The C/C++ instance. */ - void *dd_ptr; - - /* The class name. */ - const char *dd_name; - - /* Non-zero if dd_ptr is a derived class instance. */ - int dd_isderived; - - /* Next in the list. */ - struct _sipDelayedDtor *dd_next; -} sipDelayedDtor; - - -/* - * The information describing an imported module. - */ -typedef struct _sipImportedModuleDef { - /* The module name. */ - const char *im_name; - - /* The required version. */ - int im_version; - - /* The imported module. */ - struct _sipExportedModuleDef *im_module; -} sipImportedModuleDef; - - -/* - * The main client module structure. - */ -typedef struct _sipExportedModuleDef { - /* The next in the list. */ - struct _sipExportedModuleDef *em_next; - - /* The SIP API minor version number. */ - unsigned em_api_minor; - - /* The module name. */ - const char *em_name; - - /* The module name as an object. */ - PyObject *em_nameobj; - - /* The module version. */ - int em_version; - - /* The imported modules. */ - sipImportedModuleDef *em_imports; - - /* The optional Qt support API. */ - struct _sipQtAPI *em_qt_api; - - /* The number of types. */ - int em_nrtypes; - - /* The table of type types. */ - struct _sipWrapperType **em_types; - - /* The table of external types. */ - sipExternalTypeDef *em_external; - - /* The table of mapped types. */ - sipMappedType **em_mappedtypes; - - /* The number of enums. */ - int em_nrenums; - - /* The table of enum types. */ - PyTypeObject **em_enums; - - /* The table of enum type data. */ - sipEnumDef *em_enumdefs; - - /* The number of members in global enums. */ - int em_nrenummembers; - - /* The table of members in global enums. */ - sipEnumMemberDef *em_enummembers; - - /* The table of typedefs. */ - sipTypedefDef *em_typedefs; - - /* The table of virtual handlers. */ - sipVirtHandlerFunc *em_virthandlers; - - /* The sub-class convertors. */ - sipSubClassConvertorDef *em_convertors; - - /* The static instances. */ - sipInstancesDef em_instances; - - /* The license. */ - struct _sipLicenseDef *em_license; - - /* The table of exception types. */ - PyObject **em_exceptions; - - /* The table of Python slot extenders. */ - sipPySlotExtenderDef *em_slotextend; - - /* The table of initialiser extenders. */ - sipInitExtenderDef *em_initextend; - - /* The delayed dtor handler. */ - void (*em_delayeddtors)(const sipDelayedDtor *); - - /* The list of delayed dtors. */ - sipDelayedDtor *em_ddlist; -} sipExportedModuleDef; - - -/* - * The information describing a license to be added to a dictionary. - */ -typedef struct _sipLicenseDef { - /* The type of license. */ - const char *lc_type; - - /* The licensee. */ - const char *lc_licensee; - - /* The timestamp. */ - const char *lc_timestamp; - - /* The signature. */ - const char *lc_signature; -} sipLicenseDef; - - -/* - * The information describing a void pointer instance to be added to a - * dictionary. - */ -typedef struct _sipVoidPtrInstanceDef { - /* The void pointer name. */ - const char *vi_name; - - /* The void pointer value. */ - void *vi_val; -} sipVoidPtrInstanceDef; - - -/* - * The information describing a char instance to be added to a dictionary. - */ -typedef struct _sipCharInstanceDef { - /* The char name. */ - const char *ci_name; - - /* The char value. */ - char ci_val; -} sipCharInstanceDef; - - -/* - * The information describing a string instance to be added to a dictionary. - */ -typedef struct _sipStringInstanceDef { - /* The string name. */ - const char *si_name; - - /* The string value. */ - const char *si_val; -} sipStringInstanceDef; - - -/* - * The information describing an int instance to be added to a dictionary. - */ -typedef struct _sipIntInstanceDef { - /* The int name. */ - const char *ii_name; - - /* The int value. */ - int ii_val; -} sipIntInstanceDef; - - -/* - * The information describing a long instance to be added to a dictionary. - */ -typedef struct _sipLongInstanceDef { - /* The long name. */ - const char *li_name; - - /* The long value. */ - long li_val; -} sipLongInstanceDef; - - -/* - * The information describing an unsigned long instance to be added to a - * dictionary. - */ -typedef struct _sipUnsignedLongInstanceDef { - /* The unsigned long name. */ - const char *uli_name; - - /* The unsigned long value. */ - unsigned long uli_val; -} sipUnsignedLongInstanceDef; - - -/* - * The information describing a long long instance to be added to a dictionary. - */ -typedef struct _sipLongLongInstanceDef { - /* The long long name. */ - const char *lli_name; - - /* The long long value. */ -#if defined(HAVE_LONG_LONG) - PY_LONG_LONG lli_val; -#else - long lli_val; -#endif -} sipLongLongInstanceDef; - - -/* - * The information describing an unsigned long long instance to be added to a - * dictionary. - */ -typedef struct _sipUnsignedLongLongInstanceDef { - /* The unsigned long long name. */ - const char *ulli_name; - - /* The unsigned long long value. */ -#if defined(HAVE_LONG_LONG) - unsigned PY_LONG_LONG ulli_val; -#else - unsigned long ulli_val; -#endif -} sipUnsignedLongLongInstanceDef; - - -/* - * The information describing a double instance to be added to a dictionary. - */ -typedef struct _sipDoubleInstanceDef { - /* The double name. */ - const char *di_name; - - /* The double value. */ - double di_val; -} sipDoubleInstanceDef; - - -/* - * The information describing a class instance to be added to a dictionary. - */ -typedef struct _sipClassInstanceDef { - /* The class instance name. */ - const char *ci_name; - - /* The actual instance. */ - void *ci_ptr; - - /* A pointer to the Python type. */ - struct _sipWrapperType **ci_type; - - /* The wrapping flags. */ - int ci_flags; -} sipClassInstanceDef; - - -/* - * The information describing an enum instance to be added to a dictionary. - */ -typedef struct _sipEnumInstanceDef { - /* The enum instance name. */ - const char *ei_name; - - /* The enum value. */ - int ei_val; - - /* A pointer to the Python type. */ - PyTypeObject **ei_type; -} sipEnumInstanceDef; - - -/* - * Define a mapping between a wrapped type identified by a string and the - * corresponding Python type. - */ -typedef struct _sipStringTypeClassMap { - /* The type as a string. */ - const char *typeString; - - /* A pointer to the Python type. */ - struct _sipWrapperType **pyType; -} sipStringTypeClassMap; - - -/* - * Define a mapping between a wrapped type identified by an integer and the - * corresponding Python type. - */ -typedef struct _sipIntTypeClassMap { - /* The type as an integer. */ - int typeInt; - - /* A pointer to the Python type. */ - struct _sipWrapperType **pyType; -} sipIntTypeClassMap; - - -/* - * A Python method's component parts. This allows us to re-create the method - * without changing the reference counts of the components. - */ -typedef struct _sipPyMethod { - /* The function. */ - PyObject *mfunc; - - /* Self if it is a bound method. */ - PyObject *mself; - - /* The class. */ - PyObject *mclass; -} sipPyMethod; - - -/* - * Cache a reference to a Python member function. - */ -typedef struct _sipMethodCache { - /* Method cache flags. */ - int mcflags; - - /* The method. */ - sipPyMethod pyMethod; -} sipMethodCache; - - -/* - * A slot (in the Qt, rather than Python, sense). - */ -typedef struct _sipSlot { - /* Name if a Qt or Python signal. */ - char *name; - - /* Signal or Qt slot object. */ - PyObject *pyobj; - - /* Python slot method, pyobj is NULL. */ - sipPyMethod meth; - - /* A weak reference to the slot. */ - PyObject *weakSlot; -} sipSlot; - - -/* - * An entry in a linked list of slots. - */ -typedef struct _sipSlotList { - /* The receiver. */ - sipSlot rx; - - /* Next in the list. */ - struct _sipSlotList *next; -} sipSlotList; - - -/* - * A Python signal. - */ -typedef struct _sipPySig { - /* The name of the signal. */ - char *name; - - /* The list of receivers. */ - sipSlotList *rxlist; - - /* Next in the list. */ - struct _sipPySig *next; -} sipPySig; - - -/* - * This defines a single dynamic signal argument type. - */ -typedef struct _sipSigArg { - /* The type. */ - sipSigArgType atype; - - union { - /* The Python type for classes. */ - sipWrapperType *wt; - - /* The data for mapped types. */ - sipMappedType *mt; - - /* The Python type for named enums. */ - PyTypeObject *et; - } u; -} sipSigArg; - - -/* - * A parsed signal signature. - */ -typedef struct _sipSignature { - /* The number of arguments. */ - int sg_nrargs; - - /* The parsed arguments (heap). */ - sipSigArg *sg_args; - - /* The unparsed signature (heap). */ - char *sg_signature; - - /* The next in the list. */ - struct _sipSignature *sg_next; -} sipSignature; - - -/* - * A connection to a universal slot. - */ -typedef struct _sipSlotConnection { - /* The transmitter TQObject. */ - void *sc_transmitter; - - /* The parsed signature. */ - const sipSignature *sc_signature; - - /* The slot. */ - sipSlot sc_slot; -} sipSlotConnection; - - -/* - * Maps the name of a Qt signal to a wrapper function to emit it. - */ -typedef struct _sipQtSignal { - /* The signal name. */ - char *st_name; - - /* The emitter function. */ - sipEmitFunc st_emitfunc; -} sipQtSignal; - - -/* - * The API exported by the SIP module, ie. pointers to all the data and - * functions that can be used by generated code. - */ -typedef struct _sipAPIDef { - /* - * This must be the first entry and it's signature must not change so that - * version number mismatches can be detected and reported. - */ - int (*api_export_module)(sipExportedModuleDef *client, unsigned api_major, - unsigned api_minor, PyObject *mod_dict); - - /* - * The following are part of the public API. - */ - void (*api_bad_catcher_result)(PyObject *method); - void (*api_bad_length_for_slice)(SIP_SSIZE_T seqlen, SIP_SSIZE_T slicelen); - PyObject *(*api_build_result)(int *isErr, const char *fmt, ...); - PyObject *(*api_call_method)(int *isErr, PyObject *method, const char *fmt, - ...); - PyObject *(*api_class_name)(PyObject *self); - PyObject *(*api_connect_rx)(PyObject *txObj, const char *sig, - PyObject *rxObj, const char *slot, int type); - SIP_SSIZE_T (*api_convert_from_sequence_index)(SIP_SSIZE_T idx, - SIP_SSIZE_T len); - int (*api_can_convert_to_instance)(PyObject *pyObj, sipWrapperType *type, - int flags); - int (*api_can_convert_to_mapped_type)(PyObject *pyObj, - const sipMappedType *mt, int flags); - void *(*api_convert_to_instance)(PyObject *pyObj, sipWrapperType *type, - PyObject *transferObj, int flags, int *statep, int *iserrp); - void *(*api_convert_to_mapped_type)(PyObject *pyObj, - const sipMappedType *mt, PyObject *transferObj, int flags, - int *statep, int *iserrp); - void *(*api_force_convert_to_instance)(PyObject *pyObj, - sipWrapperType *type, PyObject *transferObj, int flags, - int *statep, int *iserrp); - void *(*api_force_convert_to_mapped_type)(PyObject *pyObj, - const sipMappedType *mt, PyObject *transferObj, int flags, - int *statep, int *iserrp); - void (*api_release_instance)(void *cpp, sipWrapperType *type, int state); - void (*api_release_mapped_type)(void *cpp, const sipMappedType *mt, - int state); - PyObject *(*api_convert_from_instance)(void *cpp, sipWrapperType *type, - PyObject *transferObj); - PyObject *(*api_convert_from_new_instance)(void *cpp, sipWrapperType *type, - PyObject *transferObj); - PyObject *(*api_convert_from_mapped_type)(void *cpp, - const sipMappedType *mt, PyObject *transferObj); - void *(*api_convert_to_cpp)(PyObject *sipSelf, sipWrapperType *type, - int *iserrp); - int (*api_get_state)(PyObject *transferObj); - const sipMappedType *(*api_find_mapped_type)(const char *type); - PyObject *(*api_disconnect_rx)(PyObject *txObj, const char *sig, - PyObject *rxObj, const char *slot); - int (*api_emit_signal)(PyObject *self, const char *sig, PyObject *sigargs); - void (*api_free)(void *mem); - PyObject *(*api_get_sender)(); - PyObject *(*api_get_wrapper)(void *cppPtr, sipWrapperType *type); - void *(*api_malloc)(size_t nbytes); - sipWrapperType *(*api_map_int_to_class)(int typeInt, - const sipIntTypeClassMap *map, int maplen); - sipWrapperType *(*api_map_string_to_class)(const char *typeString, - const sipStringTypeClassMap *map, int maplen); - int (*api_parse_result)(int *isErr, PyObject *method, PyObject *res, - const char *fmt, ...); - void (*api_trace)(unsigned mask, const char *fmt, ...); - void (*api_transfer)(PyObject *self, int toCpp); - void (*api_transfer_back)(PyObject *self); - void (*api_transfer_to)(PyObject *self, PyObject *owner); - int (*api_wrapper_check)(PyObject *o); - unsigned long (*api_long_as_unsigned_long)(PyObject *o); - PyObject *(*api_convert_from_named_enum)(int eval, PyTypeObject *et); - - /* - * The following may be used by Qt support code but no other handwritten - * code. - */ - PyObject *(*api_convert_from_void_ptr)(void *val); - void (*api_free_connection)(sipSlotConnection *conn); - int (*api_emit_to_slot)(sipSlot *slot, PyObject *sigargs); - int (*api_same_connection)(sipSlotConnection *conn, void *tx, - const char *sig, PyObject *rxObj, const char *slot); - void *(*api_convert_rx)(sipWrapper *txSelf, const char *sigargs, - PyObject *rxObj, const char *slot, const char **memberp); - - /* - * The following are not part of the public API. - */ - int (*api_parse_args)(int *argsParsedp, PyObject *sipArgs, - const char *fmt, ...); - int (*api_parse_pair)(int *argsParsedp, PyObject *arg0, PyObject *arg1, - const char *fmt, ...); - void (*api_common_ctor)(sipMethodCache *cache, int nrmeths); - void (*api_common_dtor)(sipWrapper *sipSelf); - void *(*api_convert_to_void_ptr)(PyObject *obj); - void (*api_no_function)(int argsParsed, const char *func); - void (*api_no_method)(int argsParsed, const char *classname, - const char *method); - void (*api_abstract_method)(const char *classname, const char *method); - void (*api_bad_class)(const char *classname); - void (*api_bad_set_type)(const char *classname, const char *var); - void *(*api_get_cpp_ptr)(sipWrapper *w, sipWrapperType *type); - void *(*api_get_complex_cpp_ptr)(sipWrapper *w); - PyObject *(*api_is_py_method)(sip_gilstate_t *gil, sipMethodCache *pymc, - sipWrapper *sipSelf, char *cname, char *mname); - void (*api_call_hook)(const char *hookname); - void (*api_start_thread)(void); - void (*api_end_thread)(void); - void (*api_raise_unknown_exception)(void); - void (*api_raise_class_exception)(sipWrapperType *type, void *ptr); - void (*api_raise_sub_class_exception)(sipWrapperType *type, void *ptr); - int (*api_add_class_instance)(PyObject *dict, const char *name, - void *cppPtr, sipWrapperType *wt); - int (*api_add_enum_instance)(PyObject *dict, const char *name, int value, - PyTypeObject *type); - void (*api_bad_operator_arg)(PyObject *self, PyObject *arg, - sipPySlotType st); - PyObject *(*api_pyslot_extend)(sipExportedModuleDef *mod, sipPySlotType st, - sipWrapperType *type, PyObject *arg0, PyObject *arg1); - void (*api_add_delayed_dtor)(sipWrapper *w); - int (*api_add_mapped_type_instance)(PyObject *dict, const char *name, - void *cppPtr, const sipMappedType *mt); - - /* - * The following are part of the public API. - */ - int (*api_export_symbol)(const char *name, void *sym); - void *(*api_import_symbol)(const char *name); - - /* - * The following may be used by Qt support code but no other handwritten - * code. - */ - int (*api_register_int_types)(PyObject *args); - sipSignature *(*api_parse_signature)(const char *sig); - - /* - * The following are part of the public API. - */ - sipWrapperType *(*api_find_class)(const char *type); - PyTypeObject *(*api_find_named_enum)(const char *type); - - /* - * The following are not part of the public API. - */ - char (*api_string_as_char)(PyObject *obj); -#if defined(HAVE_WCHAR_H) - wchar_t (*api_unicode_as_wchar)(PyObject *obj); - wchar_t *(*api_unicode_as_wstring)(PyObject *obj); -#else - int (*api_unicode_as_wchar)(PyObject *obj); - int *(*api_unicode_as_wstring)(PyObject *obj); -#endif -} sipAPIDef; - - -/* - * The API implementing the optional Qt support. - */ -typedef struct _sipQtAPI { - struct _sipWrapperType **qt_qobject; - int (*qt_is_qt_signal)(void *, const char *); - void *(*qt_create_universal_signal_shortcut)(void *, const char *, - const char **); - void *(*qt_create_universal_signal)(void *, const struct _sipSignature *); - void *(*qt_find_universal_signal_shortcut)(void *, const char *, - const char **); - void *(*qt_find_universal_signal)(void *, const struct _sipSignature *); - int (*qt_emit_signal_shortcut)(void *, const char *, PyObject *); - int (*qt_emit_signal)(void *, const struct _sipSignature *, PyObject *); - void *(*qt_create_universal_slot)(struct _sipWrapper *, - struct _sipSlotConnection *, const char **); - void (*qt_destroy_universal_slot)(void *); - void *(*qt_find_slot)(void *, const char *, PyObject *, const char *, - const char **); - int (*qt_connect)(void *, const char *, void *, const char *, int); - int (*qt_disconnect)(void *, const char *, void *, const char *); - int (*qt_signals_blocked)(void *); - const void *(*qt_get_sender)(); - void (*qt_forget_sender)(); - int (*qt_same_name)(const char *, const char *); - sipSlotConnection *(*qt_find_connection)(void *, void **); -} sipQtAPI; - - -/* - * These are flags that can be passed to sipCanConvertToInstance(), - * sipConvertToInstance() and sipForceConvertToInstance(). - */ -#define SIP_NOT_NONE 0x01 /* Disallow None. */ -#define SIP_NO_CONVERTORS 0x02 /* Disable any type convertors. */ - - -/* - * These are the state flags returned by %ConvertToTypeCode. Note that these - * share the same "namespace" as the flags below. - */ -#define SIP_TEMPORARY 0x0001 /* A temporary instance. */ -#define SIP_DERIVED_CLASS 0x0002 /* The instance is derived. */ - - -/* - * Useful macros, not part of the public API. - */ -#define SIP_PY_OWNED 0x0004 /* Owned by Python. */ -#define SIP_INDIRECT 0x0008 /* If there is a level of indirection. */ -#define SIP_ACCFUNC 0x0010 /* If there is an access function. */ -#define SIP_NOT_IN_MAP 0x0020 /* If Python object not in the map. */ -#define SIP_SHARE_MAP 0x0040 /* If the map slot might be occupied. */ -#define SIP_CPP_HAS_REF 0x0080 /* If C/C++ has a reference. */ - -#define sipIsPyOwned(w) ((w)->flags & SIP_PY_OWNED) -#define sipSetPyOwned(w) ((w)->flags |= SIP_PY_OWNED) -#define sipResetPyOwned(w) ((w)->flags &= ~SIP_PY_OWNED) -#define sipIsDerived(w) ((w)->flags & SIP_DERIVED_CLASS) -#define sipIsIndirect(w) ((w)->flags & SIP_INDIRECT) -#define sipIsAccessFunc(w) ((w)->flags & SIP_ACCFUNC) -#define sipNotInMap(w) ((w)->flags & SIP_NOT_IN_MAP) -#define sipCppHasRef(w) ((w)->flags & SIP_CPP_HAS_REF) -#define sipSetCppHasRef(w) ((w)->flags |= SIP_CPP_HAS_REF) -#define sipResetCppHasRef(w) ((w)->flags &= ~SIP_CPP_HAS_REF) - - -#define SIP_TYPE_ABSTRACT 0x0001 /* If the type is abstract. */ -#define SIP_TYPE_SCC 0x0002 /* If the type is subject to sub-class convertors. */ -#define SIP_TYPE_FLAGS_SHIFT 8 /* The user type flags shift. */ -#define SIP_TYPE_FLAGS_MASK 0x0f00 /* The user type flags mask. */ - -#define sipTypeIsAbstract(wt) ((wt)->type->td_flags & SIP_TYPE_ABSTRACT) -#define sipTypeHasSCC(wt) ((wt)->type->td_flags & SIP_TYPE_SCC) -#define sipTypeFlags(wt) (((wt)->type->td_flags & SIP_TYPE_FLAGS_MASK) >> SIP_TYPE_FLAGS_SHIFT) - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/python/sip/siplib/sipint.h b/python/sip/siplib/sipint.h deleted file mode 100644 index 0a8f2459..00000000 --- a/python/sip/siplib/sipint.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * This file defines the SIP library internal interfaces. - * - * Copyright (c) 2007 - * Riverbank Computing Limited <info@riverbankcomputing.co.uk> - * - * This file is part of SIP. - * - * This copy of SIP is licensed for use under the terms of the SIP License - * Agreement. See the file LICENSE for more details. - * - * SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - - -#ifndef _SIPINT_H -#define _SIPINT_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#undef TRUE -#define TRUE 1 - -#undef FALSE -#define FALSE 0 - - -/* - * This defines a single entry in an object map's hash table. - */ -typedef struct -{ - void *key; /* The C/C++ address. */ - sipWrapper *first; /* The first object at this address. */ -} sipHashEntry; - - -/* - * This defines the interface to a hash table class for mapping C/C++ addresses - * to the corresponding wrapped Python object. - */ -typedef struct -{ - int primeIdx; /* Index into table sizes. */ - unsigned long size; /* Size of hash table. */ - unsigned long unused; /* Nr. unused in hash table. */ - unsigned long stale; /* Nr. stale in hash table. */ - sipHashEntry *hash_array; /* Current hash table. */ -} sipObjectMap; - - -extern PyInterpreterState *sipInterpreter; /* The interpreter. */ - - -extern sipQtAPI *sipQtSupport; /* The Qt support API. */ -extern sipWrapperType *sipQObjectClass; /* The Python TQObject class. */ - -void *sip_api_convert_rx(sipWrapper *txSelf, const char *sigargs, - PyObject *rxObj, const char *slot, - const char **memberp); -void *sipGetRx(sipWrapper *txSelf,const char *sigargs,PyObject *rxObj, - const char *slot,const char **memberp); -int sip_api_emit_signal(PyObject *self,const char *sig,PyObject *sigargs); -PyObject *sip_api_get_sender(); -PyObject *sip_api_connect_rx(PyObject *txObj,const char *sig, - PyObject *rxObj,const char *slot, int type); -PyObject *sip_api_disconnect_rx(PyObject *txObj,const char *sig, - PyObject *rxObj,const char *slot); -sipSignature *sip_api_parse_signature(const char *sig); - - -/* - * These are part of the SIP API but are also used within the SIP module. - */ -void *sip_api_malloc(size_t nbytes); -void sip_api_free(void *mem); -void *sip_api_get_cpp_ptr(sipWrapper *w,sipWrapperType *type); -PyObject *sip_api_convert_from_instance(void *cppPtr, sipWrapperType *type, - PyObject *transferObj); -void sip_api_start_thread(void); -void sip_api_end_thread(void); -PyObject *sip_api_convert_from_void_ptr(void *val); -PyObject *sip_api_convert_from_named_enum(int eval, PyTypeObject *et); -int sip_api_wrapper_check(PyObject *o); -void sip_api_free_connection(sipSlotConnection *conn); -int sip_api_emit_to_slot(sipSlot *slot, PyObject *sigargs); -int sip_api_same_connection(sipSlotConnection *conn, void *tx, const char *sig, - PyObject *rxObj, const char *slot); - - -/* - * These are not part of the SIP API but are used within the SIP module. - */ -void sipFreeSlotList(sipSlotList *rx); -void sipSaveMethod(sipPyMethod *pm,PyObject *meth); -void *sipGetPending(sipWrapper **op, int *fp); -PyObject *sipWrapSimpleInstance(void *cppPtr, sipWrapperType *type, - sipWrapper *owner, int initflags); -int sipLambdaSlot(PyObject *slotObj); - -void sipOMInit(sipObjectMap *om); -void sipOMFinalise(sipObjectMap *om); -sipWrapper *sipOMFindObject(sipObjectMap *om,void *key,sipWrapperType *type); -void sipOMAddObject(sipObjectMap *om,sipWrapper *val); -int sipOMRemoveObject(sipObjectMap *om,sipWrapper *val); - -void sipSetBool(void *ptr,int val); - -void *sipGetAddress(sipWrapper *w); -void sipFindSigArgType(const char *name, size_t len, sipSigArg *at, int indir); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/python/sip/siplib/siplib.c b/python/sip/siplib/siplib.c deleted file mode 100644 index a715e830..00000000 --- a/python/sip/siplib/siplib.c +++ /dev/null @@ -1,7902 +0,0 @@ -/* - * SIP library code. - * - * Copyright (c) 2007 - * Riverbank Computing Limited <info@riverbankcomputing.co.uk> - * - * This file is part of SIP. - * - * This copy of SIP is licensed for use under the terms of the SIP License - * Agreement. See the file LICENSE for more details. - * - * SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - - -#include <Python.h> -#include <stdio.h> -#include <stdarg.h> -#include <stddef.h> -#include <string.h> - -#include "sip.h" -#include "sipint.h" - - -/* - * These are the functions that make up the public and private SIP API. - */ -static void sip_api_bad_catcher_result(PyObject *method); -static void sip_api_bad_length_for_slice(SIP_SSIZE_T seqlen, - SIP_SSIZE_T slicelen); -static PyObject *sip_api_build_result(int *isErr, const char *fmt, ...); -static PyObject *sip_api_call_method(int *isErr, PyObject *method, - const char *fmt, ...); -static PyObject *sip_api_class_name(PyObject *self); -static SIP_SSIZE_T sip_api_convert_from_sequence_index(SIP_SSIZE_T idx, - SIP_SSIZE_T len); -static int sip_api_can_convert_to_instance(PyObject *pyObj, - sipWrapperType *type, int flags); -static int sip_api_can_convert_to_mapped_type(PyObject *pyObj, - const sipMappedType *mt, int flags); -static void *sip_api_convert_to_instance(PyObject *pyObj, sipWrapperType *type, - PyObject *transferObj, int flags, int *statep, int *iserrp); -static void *sip_api_convert_to_mapped_type(PyObject *pyObj, - const sipMappedType *mt, PyObject *transferObj, int flags, int *statep, - int *iserrp); -static void *sip_api_force_convert_to_instance(PyObject *pyObj, - sipWrapperType *type, PyObject *transferObj, int flags, int *statep, - int *iserrp); -static void *sip_api_force_convert_to_mapped_type(PyObject *pyObj, - const sipMappedType *mt, PyObject *transferObj, int flags, int *statep, - int *iserrp); -static void sip_api_release_instance(void *cpp, sipWrapperType *type, - int state); -static void sip_api_release_mapped_type(void *cpp, const sipMappedType *mt, - int state); -static PyObject *sip_api_convert_from_new_instance(void *cpp, - sipWrapperType *type, PyObject *transferObj); -static PyObject *sip_api_convert_from_mapped_type(void *cpp, - const sipMappedType *mt, PyObject *transferObj); -static void *sip_api_convert_to_cpp(PyObject *sipSelf, sipWrapperType *type, - int *iserrp); -static int sip_api_get_state(PyObject *transferObj); -static const sipMappedType *sip_api_find_mapped_type(const char *type); -static PyObject *sip_api_get_wrapper(void *cppPtr, sipWrapperType *type); -static sipWrapperType *sip_api_map_int_to_class(int typeInt, - const sipIntTypeClassMap *map, int maplen); -static sipWrapperType *sip_api_map_string_to_class(const char *typeString, - const sipStringTypeClassMap *map, int maplen); -static int sip_api_parse_result(int *isErr, PyObject *method, PyObject *res, - const char *fmt, ...); -static void sip_api_trace(unsigned mask,const char *fmt,...); -static void sip_api_transfer(PyObject *self, int toCpp); -static void sip_api_transfer_back(PyObject *self); -static void sip_api_transfer_to(PyObject *self, PyObject *owner); -static int sip_api_export_module(sipExportedModuleDef *client, - unsigned api_major, unsigned api_minor, PyObject *mod_dict); -static int sip_api_parse_args(int *argsParsedp, PyObject *sipArgs, - const char *fmt, ...); -static int sip_api_parse_pair(int *argsParsedp, PyObject *sipArg0, - PyObject *sipArg1, const char *fmt, ...); -static void sip_api_common_ctor(sipMethodCache *cache, int nrmeths); -static void sip_api_common_dtor(sipWrapper *sipSelf); -static void *sip_api_convert_to_void_ptr(PyObject *obj); -static void sip_api_no_function(int argsParsed, const char *func); -static void sip_api_no_method(int argsParsed, const char *classname, - const char *method); -static void sip_api_abstract_method(const char *classname, const char *method); -static void sip_api_bad_class(const char *classname); -static void sip_api_bad_set_type(const char *classname, const char *var); -static void *sip_api_get_complex_cpp_ptr(sipWrapper *w); -static PyObject *sip_api_is_py_method(sip_gilstate_t *gil, - sipMethodCache *pymc, sipWrapper *sipSelf, char *cname, char *mname); -static void sip_api_call_hook(const char *hookname); -static void sip_api_raise_unknown_exception(void); -static void sip_api_raise_class_exception(sipWrapperType *type, void *ptr); -static void sip_api_raise_sub_class_exception(sipWrapperType *type, void *ptr); -static int sip_api_add_class_instance(PyObject *dict, const char *name, - void *cppPtr, sipWrapperType *wt); -static int sip_api_add_mapped_type_instance(PyObject *dict, const char *name, - void *cppPtr, const sipMappedType *mt); -static int sip_api_add_enum_instance(PyObject *dict, const char *name, - int value, PyTypeObject *type); -static void sip_api_bad_operator_arg(PyObject *self, PyObject *arg, - sipPySlotType st); -static PyObject *sip_api_pyslot_extend(sipExportedModuleDef *mod, - sipPySlotType st, sipWrapperType *type, PyObject *arg0, - PyObject *arg1); -static void sip_api_add_delayed_dtor(sipWrapper *w); -static unsigned long sip_api_long_as_unsigned_long(PyObject *o); -static int sip_api_export_symbol(const char *name, void *sym); -static void *sip_api_import_symbol(const char *name); -static int sip_api_register_int_types(PyObject *args); -static sipWrapperType *sip_api_find_class(const char *type); -static PyTypeObject *sip_api_find_named_enum(const char *type); -static char sip_api_string_as_char(PyObject *obj); -#if defined(HAVE_WCHAR_H) -static wchar_t sip_api_unicode_as_wchar(PyObject *obj); -static wchar_t *sip_api_unicode_as_wstring(PyObject *obj); -#else -static int sip_api_unicode_as_wchar(PyObject *obj); -static int *sip_api_unicode_as_wstring(PyObject *obj); -#endif - - -/* - * The data structure that represents the SIP API. - */ -static const sipAPIDef sip_api = { - /* This must be first. */ - sip_api_export_module, - /* - * The following are part of the public API. - */ - sip_api_bad_catcher_result, - sip_api_bad_length_for_slice, - sip_api_build_result, - sip_api_call_method, - sip_api_class_name, - sip_api_connect_rx, - sip_api_convert_from_sequence_index, - sip_api_can_convert_to_instance, - sip_api_can_convert_to_mapped_type, - sip_api_convert_to_instance, - sip_api_convert_to_mapped_type, - sip_api_force_convert_to_instance, - sip_api_force_convert_to_mapped_type, - sip_api_release_instance, - sip_api_release_mapped_type, - sip_api_convert_from_instance, - sip_api_convert_from_new_instance, - sip_api_convert_from_mapped_type, - sip_api_convert_to_cpp, - sip_api_get_state, - sip_api_find_mapped_type, - sip_api_disconnect_rx, - sip_api_emit_signal, - sip_api_free, - sip_api_get_sender, - sip_api_get_wrapper, - sip_api_malloc, - sip_api_map_int_to_class, - sip_api_map_string_to_class, - sip_api_parse_result, - sip_api_trace, - sip_api_transfer, - sip_api_transfer_back, - sip_api_transfer_to, - sip_api_wrapper_check, - sip_api_long_as_unsigned_long, - /* - * The following may be used by Qt support code but by no other handwritten - * code. - */ - sip_api_convert_from_named_enum, - sip_api_convert_from_void_ptr, - sip_api_free_connection, - sip_api_emit_to_slot, - sip_api_same_connection, - sip_api_convert_rx, - /* - * The following are not part of the public API. - */ - sip_api_parse_args, - sip_api_parse_pair, - sip_api_common_ctor, - sip_api_common_dtor, - sip_api_convert_to_void_ptr, - sip_api_no_function, - sip_api_no_method, - sip_api_abstract_method, - sip_api_bad_class, - sip_api_bad_set_type, - sip_api_get_cpp_ptr, - sip_api_get_complex_cpp_ptr, - sip_api_is_py_method, - sip_api_call_hook, - sip_api_start_thread, - sip_api_end_thread, - sip_api_raise_unknown_exception, - sip_api_raise_class_exception, - sip_api_raise_sub_class_exception, - sip_api_add_class_instance, - sip_api_add_enum_instance, - sip_api_bad_operator_arg, - sip_api_pyslot_extend, - sip_api_add_delayed_dtor, - sip_api_add_mapped_type_instance, - /* - * The following are part of the public API. - */ - sip_api_export_symbol, - sip_api_import_symbol, - /* - * The following may be used by Qt support code but by no other handwritten - * code. - */ - sip_api_register_int_types, - sip_api_parse_signature, - /* - * The following are part of the public API. - */ - sip_api_find_class, - sip_api_find_named_enum, - /* - * The following are not part of the public API. - */ - sip_api_string_as_char, - sip_api_unicode_as_wchar, - sip_api_unicode_as_wstring, -}; - - -#define PARSE_OK 0x00000000 /* Parse is Ok so far. */ -#define PARSE_MANY 0x10000000 /* Too many arguments. */ -#define PARSE_FEW 0x20000000 /* Too few arguments. */ -#define PARSE_TYPE 0x30000000 /* Argument with a bad type. */ -#define PARSE_UNBOUND 0x40000000 /* Unbound method. */ -#define PARSE_FORMAT 0x50000000 /* Bad format character. */ -#define PARSE_RAISED 0x60000000 /* Exception already raised. */ -#define PARSE_STICKY 0x80000000 /* The error sticks. */ -#define PARSE_MASK 0xf0000000 - -/* - * Note that some of the following flags safely share values because they - * cannot be used at the same time. - */ -#define FORMAT_DEREF 0x01 /* The pointer will be dereferenced. */ -#define FORMAT_FACTORY 0x02 /* Implement /Factory/ in a VH. */ -#define FORMAT_TRANSFER 0x02 /* Implement /Transfer/. */ -#define FORMAT_NO_STATE 0x04 /* Don't return the C/C++ state. */ -#define FORMAT_TRANSFER_BACK 0x04 /* Implement /TransferBack/. */ -#define FORMAT_GET_WRAPPER 0x08 /* Implement /GetWrapper/. */ -#define FORMAT_NO_CONVERTORS 0x10 /* Suppress any convertors. */ -#define FORMAT_TRANSFER_THIS 0x20 /* Support for /TransferThis/. */ - -#define SIP_MC_FOUND 0x01 /* If we have looked for the method. */ -#define SIP_MC_ISMETH 0x02 /* If we looked and there was one. */ - -#define sipFoundMethod(m) ((m)->mcflags & SIP_MC_FOUND) -#define sipSetFoundMethod(m) ((m)->mcflags |= SIP_MC_FOUND) -#define sipIsMethod(m) ((m)->mcflags & SIP_MC_ISMETH) -#define sipSetIsMethod(m) ((m)->mcflags |= SIP_MC_ISMETH) - - -/* - * An entry in a linked list of name/symbol pairs. - */ -typedef struct _sipSymbol { - const char *name; /* The name. */ - void *symbol; /* The symbol. */ - struct _sipSymbol *next; /* The next in the list. */ -} sipSymbol; - - -/* - * An entry in a linked list of Python objects. - */ -typedef struct _sipPyObject { - PyObject *object; /* The Python object. */ - struct _sipPyObject *next; /* The next in the list. */ -} sipPyObject; - - -static PyTypeObject sipWrapperType_Type; -static sipWrapperType sipWrapper_Type; -static PyTypeObject sipVoidPtr_Type; - -PyInterpreterState *sipInterpreter = NULL; -sipQtAPI *sipQtSupport = NULL; -sipWrapperType *sipQObjectClass; -sipPyObject *sipRegisteredIntTypes = NULL; -sipSymbol *sipSymbolList = NULL; - - -/* - * Various strings as Python objects created as and when needed. - */ -static PyObject *licenseName = NULL; -static PyObject *licenseeName = NULL; -static PyObject *typeName = NULL; -static PyObject *timestampName = NULL; -static PyObject *signatureName = NULL; - -static sipObjectMap cppPyMap; /* The C/C++ to Python map. */ -static sipExportedModuleDef *clientList = NULL; /* List of registered clients. */ -static unsigned traceMask = 0; /* The current trace mask. */ - -static sipTypeDef *currentType = NULL; /* The type being created. */ - - -static void addSlots(sipWrapperType *wt, sipTypeDef *td); -static void initSlots(PyTypeObject *to, PyNumberMethods *nb, - PySequenceMethods *sq, PyMappingMethods *mp, sipPySlotDef *slots, - int force); -static void *findSlot(PyObject *self, sipPySlotType st); -static void *findSlotInType(sipTypeDef *td, sipPySlotType st); -static int objobjargprocSlot(PyObject *self, PyObject *arg1, PyObject *arg2, - sipPySlotType st); -static int ssizeobjargprocSlot(PyObject *self, SIP_SSIZE_T arg1, - PyObject *arg2, sipPySlotType st); -static PyObject *buildObject(PyObject *tup, const char *fmt, va_list va); -static int parsePass1(sipWrapper **selfp, int *selfargp, int *argsParsedp, - PyObject *sipArgs, const char *fmt, va_list va); -static int parsePass2(sipWrapper *self, int selfarg, int nrargs, - PyObject *sipArgs, const char *fmt, va_list va); -static int getSelfFromArgs(sipWrapperType *type, PyObject *args, int argnr, - sipWrapper **selfp); -static PyObject *createEnumMember(sipTypeDef *td, sipEnumMemberDef *enm); -static PyObject *handleGetLazyAttr(PyObject *nameobj, sipWrapperType *wt, - sipWrapper *w); -static int handleSetLazyAttr(PyObject *nameobj, PyObject *valobj, - sipWrapperType *wt, sipWrapper *w); -static int getNonStaticVariables(sipWrapperType *wt, sipWrapper *w, - PyObject **ndict); -static void findLazyAttr(sipWrapperType *wt, char *name, PyMethodDef **pmdp, - sipEnumMemberDef **enmp, PyMethodDef **vmdp, sipTypeDef **in); -static int compareMethodName(const void *key, const void *el); -static int compareEnumMemberName(const void *key, const void *el); -static int checkPointer(void *ptr); -static void *cast_cpp_ptr(void *ptr, sipWrapperType *src_type, - sipWrapperType *dst_type); -static void badArgs(int argsParsed, const char *classname, const char *method); -static void finalise(void); -static sipWrapperType *createType(sipExportedModuleDef *client, - sipTypeDef *type, PyObject *mod_dict); -static PyTypeObject *createEnum(sipExportedModuleDef *client, sipEnumDef *ed, - PyObject *mod_dict); -static const char *getBaseName(const char *name); -static PyObject *getBaseNameObject(const char *name); -static PyObject *createTypeDict(PyObject *mname); -static sipExportedModuleDef *getClassModule(sipEncodedClassDef *enc, - sipExportedModuleDef *em); -static sipWrapperType *getClassType(sipEncodedClassDef *enc, - sipExportedModuleDef *em); -static sipWrapperType *convertSubClass(sipWrapperType *type, void **cppPtr); -static void *getPtrTypeDef(sipWrapper *self, sipTypeDef **td); -static int addInstances(PyObject *dict, sipInstancesDef *id); -static int addVoidPtrInstances(PyObject *dict, sipVoidPtrInstanceDef *vi); -static int addCharInstances(PyObject *dict, sipCharInstanceDef *ci); -static int addStringInstances(PyObject *dict, sipStringInstanceDef *si); -static int addIntInstances(PyObject *dict, sipIntInstanceDef *ii); -static int addLongInstances(PyObject *dict, sipLongInstanceDef *li); -static int addUnsignedLongInstances(PyObject *dict, - sipUnsignedLongInstanceDef *uli); -static int addLongLongInstances(PyObject *dict, sipLongLongInstanceDef *lli); -static int addUnsignedLongLongInstances(PyObject *dict, - sipUnsignedLongLongInstanceDef *ulli); -static int addDoubleInstances(PyObject *dict, sipDoubleInstanceDef *di); -static int addEnumInstances(PyObject *dict, sipEnumInstanceDef *ei); -static int addSingleEnumInstance(PyObject *dict, const char *name, int value, - PyTypeObject *type); -static int addClassInstances(PyObject *dict, sipClassInstanceDef *ci); -static int addSingleClassInstance(PyObject *dict, const char *name, - void *cppPtr, sipWrapperType *wt, int initflags); -static int addLicense(PyObject *dict, sipLicenseDef *lc); -static PyObject *cast(PyObject *self, PyObject *args); -static PyObject *callDtor(PyObject *self, PyObject *args); -static PyObject *isDeleted(PyObject *self, PyObject *args); -static PyObject *setDeleted(PyObject *self, PyObject *args); -static PyObject *setTraceMask(PyObject *self, PyObject *args); -static PyObject *wrapInstance(PyObject *self, PyObject *args); -static PyObject *unwrapInstance(PyObject *self, PyObject *args); -static PyObject *transfer(PyObject *self, PyObject *args); -static PyObject *transferBack(PyObject *self, PyObject *args); -static PyObject *transferTo(PyObject *self, PyObject *args); -static int sipWrapperType_Check(PyObject *op); -static void addToParent(sipWrapper *self, sipWrapper *owner); -static void removeFromParent(sipWrapper *self); -static sipWrapperType *findClass(sipExportedModuleDef *emd, const char *name, - size_t len); -static int findClassArg(sipExportedModuleDef *emd, const char *name, - size_t len, sipSigArg *at, int indir); -static int findMtypeArg(sipMappedType **mttab, const char *name, size_t len, - sipSigArg *at, int indir); -static PyTypeObject *findEnum(sipExportedModuleDef *emd, const char *name, - size_t len); -static int findEnumArg(sipExportedModuleDef *emd, const char *name, size_t len, - sipSigArg *at, int indir); -static int sameScopedName(const char *pyname, const char *name, size_t len); -static int nameEq(const char *with, const char *name, size_t len); -static int isExactWrappedType(sipWrapperType *wt); -static void release(void *addr, sipTypeDef *td, int state); -static void callPyDtor(sipWrapper *self); -static int qt_and_sip_api_3_4(void); -static int visitSlot(sipSlot *slot, visitproc visit, void *arg); -static void clearAnyLambda(sipSlot *slot); -static int parseCharArray(PyObject *obj, char **ap, int *aszp); -static int parseChar(PyObject *obj, char *ap); -static int parseCharString(PyObject *obj, char **ap); -#if defined(HAVE_WCHAR_H) -static int parseWCharArray(PyObject *obj, wchar_t **ap, int *aszp); -static int parseWChar(PyObject *obj, wchar_t *ap); -static int parseWCharString(PyObject *obj, wchar_t **ap); -#else -static void raiseNoWChar(); -#endif - - -/* - * The Python module initialisation function. - */ -#if defined(SIP_STATIC_MODULE) -void initsip(void) -#else -PyMODINIT_FUNC initsip(void) -#endif -{ - static PyMethodDef methods[] = { - {"cast", cast, METH_VARARGS, NULL}, - {"delete", callDtor, METH_VARARGS, NULL}, - {"isdeleted", isDeleted, METH_VARARGS, NULL}, - {"setdeleted", setDeleted, METH_VARARGS, NULL}, - {"settracemask", setTraceMask, METH_VARARGS, NULL}, - {"transfer", transfer, METH_VARARGS, NULL}, - {"transferback", transferBack, METH_VARARGS, NULL}, - {"transferto", transferTo, METH_VARARGS, NULL}, - {"wrapinstance", wrapInstance, METH_VARARGS, NULL}, - {"unwrapinstance", unwrapInstance, METH_VARARGS, NULL}, - {NULL, NULL, 0, NULL} - }; - - int rc; - PyObject *mod, *mod_dict, *obj; - -#ifdef WITH_THREAD - PyEval_InitThreads(); -#endif - - /* Initialise the types. */ - sipWrapperType_Type.tp_base = &PyType_Type; - - if (PyType_Ready(&sipWrapperType_Type) < 0) - Py_FatalError("sip: Failed to initialise sip.wrappertype type"); - - if (PyType_Ready((PyTypeObject *)&sipWrapper_Type) < 0) - Py_FatalError("sip: Failed to initialise sip.wrapper type"); - - if (PyType_Ready(&sipVoidPtr_Type) < 0) - Py_FatalError("sip: Failed to initialise sip.voidptr type"); - - mod = Py_InitModule("sip", methods); - mod_dict = PyModule_GetDict(mod); - - /* Publish the SIP API. */ - if ((obj = PyCObject_FromVoidPtr((void *)&sip_api, NULL)) == NULL) - Py_FatalError("sip: Failed to create _C_API object"); - - rc = PyDict_SetItemString(mod_dict, "_C_API", obj); - Py_DECREF(obj); - - if (rc < 0) - Py_FatalError("sip: Failed to add _C_API object to module dictionary"); - - /* Add the SIP version number, but don't worry about errors. */ - if ((obj = PyInt_FromLong(SIP_VERSION)) != NULL) - { - PyDict_SetItemString(mod_dict, "SIP_VERSION", obj); - Py_DECREF(obj); - } - - if ((obj = PyString_FromString(SIP_VERSION_STR)) != NULL) - { - PyDict_SetItemString(mod_dict, "SIP_VERSION_STR", obj); - Py_DECREF(obj); - } - - /* Add the type objects, but don't worry about errors. */ - PyDict_SetItemString(mod_dict, "wrappertype", (PyObject *)&sipWrapperType_Type); - PyDict_SetItemString(mod_dict, "wrapper", (PyObject *)&sipWrapper_Type); - PyDict_SetItemString(mod_dict, "voidptr", (PyObject *)&sipVoidPtr_Type); - - /* Initialise the module if it hasn't already been done. */ - if (sipInterpreter == NULL) - { - Py_AtExit(finalise); - - /* Initialise the object map. */ - sipOMInit(&cppPyMap); - - sipQtSupport = NULL; - - /* - * Get the current interpreter. This will be shared between all - * threads. - */ - sipInterpreter = PyThreadState_Get()->interp; - } -} - - -/* - * Display a printf() style message to stderr according to the current trace - * mask. - */ -static void sip_api_trace(unsigned mask, const char *fmt, ...) -{ - va_list ap; - - va_start(ap,fmt); - - if (mask & traceMask) - vfprintf(stderr, fmt, ap); - - va_end(ap); -} - - -/* - * Set the trace mask. - */ -static PyObject *setTraceMask(PyObject *self, PyObject *args) -{ - unsigned new_mask; - - if (PyArg_ParseTuple(args, "I:settracemask", &new_mask)) - { - traceMask = new_mask; - - Py_INCREF(Py_None); - return Py_None; - } - - return NULL; -} - - -/* - * Transfer the ownership of an instance to C/C++. - */ -static PyObject *transferTo(PyObject *self, PyObject *args) -{ - PyObject *w, *owner; - - if (PyArg_ParseTuple(args, "O!O:transferto", &sipWrapper_Type, &w, &owner)) - { - if (owner == Py_None) - owner = NULL; - else if (!sip_api_wrapper_check(owner)) - { - PyErr_Format(PyExc_TypeError, "transferto() argument 2 must be sip.wrapper, not %s", owner->ob_type->tp_name); - return NULL; - } - - sip_api_transfer_to(w, owner); - - Py_INCREF(Py_None); - return Py_None; - } - - return NULL; -} - - -/* - * Transfer the ownership of an instance to Python. - */ -static PyObject *transferBack(PyObject *self, PyObject *args) -{ - PyObject *w; - - if (PyArg_ParseTuple(args, "O!:transferback", &sipWrapper_Type, &w)) - { - sip_api_transfer_back(w); - - Py_INCREF(Py_None); - return Py_None; - } - - return NULL; -} - - -/* - * Transfer the ownership of an instance. This is deprecated. - */ -static PyObject *transfer(PyObject *self, PyObject *args) -{ - PyObject *w; - int toCpp; - - if (PyArg_ParseTuple(args, "O!i:transfer", &sipWrapper_Type, &w, &toCpp)) - { - if (toCpp) - sip_api_transfer_to(w, NULL); - else - sip_api_transfer_back(w); - - Py_INCREF(Py_None); - return Py_None; - } - - return NULL; -} - - -/* - * Cast an instance to one of it's sub or super-classes by returning a new - * Python object with the superclass type wrapping the same C++ instance. - */ -static PyObject *cast(PyObject *self, PyObject *args) -{ - sipWrapper *w; - sipWrapperType *wt, *type; - void *addr; - PyTypeObject *ft, *tt; - - if (!PyArg_ParseTuple(args, "O!O!:cast", &sipWrapper_Type, &w, &sipWrapperType_Type, &wt)) - return NULL; - - ft = ((PyObject *)w)->ob_type; - tt = (PyTypeObject *)wt; - - if (ft == tt || PyType_IsSubtype(tt, ft)) - type = NULL; - else if (PyType_IsSubtype(ft, tt)) - type = wt; - else - { - PyErr_SetString(PyExc_TypeError, "argument 1 of sip.cast() must be an instance of a sub or super-type of argument 2"); - return NULL; - } - - if ((addr = sip_api_get_cpp_ptr(w, type)) == NULL) - return NULL; - - /* - * We don't put this new object into the map so that the original object is - * always found. It would also totally confuse the map logic. - */ - return sipWrapSimpleInstance(addr, wt, NULL, (w->flags | SIP_NOT_IN_MAP) & ~SIP_PY_OWNED); -} - - -/* - * Call an instance's dtor. - */ -static PyObject *callDtor(PyObject *self, PyObject *args) -{ - sipWrapper *w; - void *addr; - sipTypeDef *td; - - if (!PyArg_ParseTuple(args, "O!:delete", &sipWrapper_Type, &w)) - return NULL; - - addr = getPtrTypeDef(w, &td); - - if (checkPointer(addr) < 0) - return NULL; - - /* - * Transfer ownership to C++ so we don't try to release it again when the - * Python object is garbage collected. - */ - removeFromParent(w); - sipResetPyOwned(w); - - release(addr, td, w->flags); - - Py_INCREF(Py_None); - return Py_None; -} - - -/* - * Check if an instance still exists without raising an exception. - */ -static PyObject *isDeleted(PyObject *self, PyObject *args) -{ - sipWrapper *w; - PyObject *res; - - if (!PyArg_ParseTuple(args, "O!:isdeleted", &sipWrapper_Type, &w)) - return NULL; - - res = (sipGetAddress(w) == NULL ? Py_True : Py_False); - - Py_INCREF(res); - return res; -} - - -/* - * Mark an instance as having been deleted. - */ -static PyObject *setDeleted(PyObject *self, PyObject *args) -{ - sipWrapper *w; - - if (!PyArg_ParseTuple(args, "O!:setdeleted", &sipWrapper_Type, &w)) - return NULL; - - /* - * Transfer ownership to C++ so we don't try to release it when the Python - * object is garbage collected. - */ - removeFromParent(w); - sipResetPyOwned(w); - - w->u.cppPtr = NULL; - - Py_INCREF(Py_None); - return Py_None; -} - - -/* - * Unwrap an instance. - */ -static PyObject *unwrapInstance(PyObject *self, PyObject *args) -{ - sipWrapper *w; - - if (PyArg_ParseTuple(args, "O!:unwrapinstance", &sipWrapper_Type, &w)) - { - void *addr; - - /* - * We just get the pointer but don't try and cast it (which isn't - * needed and wouldn't work with the way casts are currently - * implemented if we are unwrapping something derived from a wrapped - * class). - */ - if ((addr = sip_api_get_cpp_ptr(w, NULL)) == NULL) - return NULL; - - return PyLong_FromVoidPtr(addr); - } - - return NULL; -} - - -/* - * Wrap an instance. - */ -static PyObject *wrapInstance(PyObject *self, PyObject *args) -{ - unsigned long addr; - sipWrapperType *wt; - - if (PyArg_ParseTuple(args, "kO!:wrapinstance", &addr, &sipWrapperType_Type, &wt)) - return sip_api_convert_from_instance((void *)addr, wt, NULL); - - return NULL; -} - - -/* - * Register a client module. A negative value is returned and an exception - * raised if there was an error. Not normally needed by handwritten code. - */ -static int sip_api_export_module(sipExportedModuleDef *client, - unsigned api_major, unsigned api_minor, PyObject *mod_dict) -{ - sipExportedModuleDef *em; - sipImportedModuleDef *im; - sipSubClassConvertorDef *scc; - sipWrapperType **mw; - sipEnumMemberDef *emd; - sipInitExtenderDef *ie; - int i; - - /* Check that we can support it. */ - - if (api_major != SIP_API_MAJOR_NR || api_minor > SIP_API_MINOR_NR) - { -#if SIP_API_MINOR_NR > 0 - PyErr_Format(PyExc_RuntimeError, "the sip module supports API v%d.0 to v%d.%d but the %s module requires API v%d.%d", SIP_API_MAJOR_NR, SIP_API_MAJOR_NR, SIP_API_MINOR_NR, client->em_name, api_major,api_minor); -#else - PyErr_Format(PyExc_RuntimeError, "the sip module supports API v%d.0 but the %s module requires API v%d.%d", SIP_API_MAJOR_NR, client->em_name, api_major,api_minor); -#endif - - return -1; - } - - /* Convert the module name to an object. */ - if ((client->em_nameobj = PyString_FromString(client->em_name)) == NULL) - return -1; - - for (em = clientList; em != NULL; em = em->em_next) - { - /* SIP clients must have unique names. */ - if (strcmp(em->em_name, client->em_name) == 0) - { - PyErr_Format(PyExc_RuntimeError, "the sip module has already registered a module called %s", client->em_name); - - return -1; - } - - /* Only one module can claim to wrap TQObject. */ - if (em->em_qt_api != NULL && client->em_qt_api != NULL) - { - PyErr_Format(PyExc_RuntimeError, "the %s and %s modules both wrap the TQObject class", client->em_name, em->em_name); - - return -1; - } - } - - /* Import any required modules. */ - if ((im = client->em_imports) != NULL) - { - while (im->im_name != NULL) - { - PyObject *mod; - - if ((mod = PyImport_ImportModule(im->im_name)) == NULL) - return -1; - - for (em = clientList; em != NULL; em = em->em_next) - if (strcmp(em->em_name, im->im_name) == 0) - break; - - if (em == NULL) - { - PyErr_Format(PyExc_RuntimeError, "the %s module failed to register with the sip module", im->im_name); - - return -1; - } - - /* Check the versions are compatible. */ - if (im->im_version >= 0 || em->em_version >= 0) - if (im->im_version != em->em_version) - { - PyErr_Format(PyExc_RuntimeError, "the %s module is version %d but the %s module requires version %d", em->em_name, em->em_version, client->em_name, im->im_version); - - return -1; - } - - /* Save the imported module. */ - im->im_module = em; - - ++im; - } - } - - /* Create the module's classes. */ - if ((mw = client->em_types) != NULL) - for (i = 0; i < client->em_nrtypes; ++i, ++mw) - { - sipTypeDef *td = (sipTypeDef *)*mw; - - /* Skip external classes. */ - if (td == NULL) - continue; - - /* See if this is a namespace extender. */ - if (td->td_name == NULL) - { - sipTypeDef **last; - sipWrapperType *wt = getClassType(&td->td_scope, client); - - /* Append this type to the real one. */ - last = &wt->type->td_nsextender; - - while (*last != NULL) - last = &(*last)->td_nsextender; - - *last = td; - - /* - * Set this so that the extender's original - * module can be found. - */ - td->td_module = client; - - /* - * Save the real namespace type so that it is - * the correct scope for any enums or classes - * defined in this module. - */ - *mw = wt; - } - else if ((*mw = createType(client, td, mod_dict)) == NULL) - return -1; - } - - /* Set any Qt support API. */ - if (client->em_qt_api != NULL) - { - sipQtSupport = client->em_qt_api; - sipQObjectClass = *sipQtSupport->qt_qobject; - } - - /* Append any initialiser extenders to the relevant classes. */ - if ((ie = client->em_initextend) != NULL) - while (ie->ie_extender != NULL) - { - sipWrapperType *wt = getClassType(&ie->ie_class, client); - - ie->ie_next = wt->iextend; - wt->iextend = ie; - - ++ie; - } - - /* Set the base class object for any sub-class convertors. */ - if ((scc = client->em_convertors) != NULL) - while (scc->scc_convertor != NULL) - { - scc->scc_basetype = getClassType(&scc->scc_base, client); - - ++scc; - } - - /* Create the module's enums. */ - if (client->em_nrenums != 0) - { - if ((client->em_enums = sip_api_malloc(client->em_nrenums * sizeof (PyTypeObject *))) == NULL) - return -1; - - for (i = 0; i < client->em_nrenums; ++i) - if ((client->em_enums[i] = createEnum(client, &client->em_enumdefs[i], mod_dict)) == NULL) - return -1; - } - - for (emd = client->em_enummembers, i = 0; i < client->em_nrenummembers; ++i, ++emd) - { - PyObject *mo; - - if ((mo = sip_api_convert_from_named_enum(emd->em_val, client->em_enums[emd->em_enum])) == NULL) - return -1; - - if (PyDict_SetItemString(mod_dict, emd->em_name, mo) < 0) - return -1; - - Py_DECREF(mo); - } - - - /* - * Add any class static instances. We need to do this once all types are - * fully formed because of potential interdependencies. - */ - if ((mw = client->em_types) != NULL) - for (i = 0; i < client->em_nrtypes; ++i) - { - sipWrapperType *wt; - - if ((wt = *mw++) != NULL && addInstances(((PyTypeObject *)wt)->tp_dict, &wt->type->td_instances) < 0) - return -1; - } - - /* Add any global static instances. */ - if (addInstances(mod_dict, &client->em_instances) < 0) - return -1; - - /* Add any license. */ - if (client->em_license != NULL && addLicense(mod_dict, client->em_license) < 0) - return -1; - - /* See if the new module satisfies any outstanding external types. */ - for (em = clientList; em != NULL; em = em->em_next) - { - sipExternalTypeDef *etd; - - if (em->em_external == NULL) - continue; - - for (etd = em->em_external; etd->et_nr >= 0; ++etd) - { - if (etd->et_name == NULL) - continue; - - mw = client->em_types; - - for (i = 0; i < client->em_nrtypes; ++i) - { - sipWrapperType *wt; - const char *tname; - - if ((wt = *mw++) == NULL) - continue; - - tname = strchr(wt->type->td_name, '.') + 1; - - if (strcmp(etd->et_name, tname) == 0) - { - em->em_types[etd->et_nr] = wt; - etd->et_name = NULL; - - break; - } - } - } - } - - /* Add to the list of client modules. */ - client->em_next = clientList; - clientList = client; - - return 0; -} - - -/* - * Called by the interpreter to do any final clearing up, just in case the - * interpreter will re-start. - */ -static void finalise(void) -{ - sipExportedModuleDef *em; - - /* Mark the Python API as unavailable. */ - sipInterpreter = NULL; - - /* Handle any delayed dtors. */ - for (em = clientList; em != NULL; em = em->em_next) - if (em->em_ddlist != NULL) - { - em->em_delayeddtors(em->em_ddlist); - - /* Free the list. */ - do - { - sipDelayedDtor *dd = em->em_ddlist; - - em->em_ddlist = dd->dd_next; - sip_api_free(dd); - } - while (em->em_ddlist != NULL); - } - - licenseName = NULL; - licenseeName = NULL; - typeName = NULL; - timestampName = NULL; - signatureName = NULL; - - /* Release all memory we've allocated directly. */ - sipOMFinalise(&cppPyMap); - - /* Re-initialise those globals that (might) need it. */ - clientList = NULL; -} - - -/* - * Add a wrapped C/C++ pointer to the list of delayed dtors. - */ -static void sip_api_add_delayed_dtor(sipWrapper *w) -{ - void *ptr; - sipTypeDef *td; - sipExportedModuleDef *em; - - if ((ptr = getPtrTypeDef(w, &td)) == NULL) - return; - - /* Find the defining module. */ - for (em = clientList; em != NULL; em = em->em_next) - { - int i; - - for (i = 0; i < em->em_nrtypes; ++i) - if (em->em_types[i] != NULL && em->em_types[i]->type == td) - { - sipDelayedDtor *dd; - - if ((dd = sip_api_malloc(sizeof (sipDelayedDtor))) == NULL) - return; - - /* Add to the list. */ - dd->dd_ptr = ptr; - dd->dd_name = getBaseName(td->td_name); - dd->dd_isderived = sipIsDerived(w); - dd->dd_next = em->em_ddlist; - - em->em_ddlist = dd; - - return; - } - } -} - - -/* - * A wrapper around the Python memory allocater that will raise an exception if - * if the allocation fails. - */ -void *sip_api_malloc(size_t nbytes) -{ - void *mem; - - if ((mem = PyMem_Malloc(nbytes)) == NULL) - PyErr_NoMemory(); - - return mem; -} - - -/* - * A wrapper around the Python memory de-allocater. - */ -void sip_api_free(void *mem) -{ - PyMem_Free(mem); -} - - -/* - * Extend a Python slot by looking in other modules to see if there is an - * extender function that can handle the arguments. - */ -static PyObject *sip_api_pyslot_extend(sipExportedModuleDef *mod, - sipPySlotType st, sipWrapperType *type, - PyObject *arg0, PyObject *arg1) -{ - sipExportedModuleDef *em; - - /* Go through each module. */ - for (em = clientList; em != NULL; em = em->em_next) - { - sipPySlotExtenderDef *ex; - - /* Skip the module that couldn't handle the arguments. */ - if (em == mod) - continue; - - /* Skip if the module doesn't have any extenders. */ - if (em->em_slotextend == NULL) - continue; - - /* Go through each extender. */ - for (ex = em->em_slotextend; ex->pse_func != NULL; ++ex) - { - PyObject *res; - - /* Skip if not the right slot type. */ - if (ex->pse_type != st) - continue; - - /* Check against the type if one was given. */ - if (type != NULL && type != getClassType(&ex->pse_class, NULL)) - continue; - - PyErr_Clear(); - - res = ((binaryfunc)ex->pse_func)(arg0, arg1); - - if (res != Py_NotImplemented) - return res; - } - } - - /* The arguments couldn't handled anywhere. */ - PyErr_Clear(); - - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; -} - - -/* - * Call the Python re-implementation of a C++ virtual. - */ -static PyObject *sip_api_call_method(int *isErr, PyObject *method, - const char *fmt, ...) -{ - PyObject *args, *res; - va_list va; - - va_start(va,fmt); - - if ((args = PyTuple_New(strlen(fmt))) != NULL && buildObject(args,fmt,va) != NULL) - res = PyEval_CallObject(method,args); - else - { - res = NULL; - - if (isErr != NULL) - *isErr = TRUE; - } - - Py_XDECREF(args); - - va_end(va); - - return res; -} - - -/* - * Build a result object based on a format string. - */ -static PyObject *sip_api_build_result(int *isErr, const char *fmt, ...) -{ - PyObject *res = NULL; - int badfmt, tupsz; - va_list va; - - va_start(va,fmt); - - /* Basic validation of the format string. */ - - badfmt = FALSE; - - if (*fmt == '(') - { - char *ep; - - if ((ep = strchr(fmt,')')) == NULL || ep[1] != '\0') - badfmt = TRUE; - else - tupsz = ep - fmt - 1; - } - else if (strlen(fmt) == 1) - tupsz = -1; - else - badfmt = TRUE; - - if (badfmt) - PyErr_Format(PyExc_SystemError,"sipBuildResult(): invalid format string \"%s\"",fmt); - else if (tupsz < 0 || (res = PyTuple_New(tupsz)) != NULL) - res = buildObject(res,fmt,va); - - va_end(va); - - if (res == NULL && isErr != NULL) - *isErr = TRUE; - - return res; -} - - -/* - * Get the values off the stack and put them into an object. - */ -static PyObject *buildObject(PyObject *obj, const char *fmt, va_list va) -{ - char ch, termch; - int i; - - /* - * The format string has already been checked that it is properly - * formed if it is enclosed in parenthesis. - */ - if (*fmt == '(') - { - termch = ')'; - ++fmt; - } - else - termch = '\0'; - - i = 0; - - while ((ch = *fmt++) != termch) - { - PyObject *el; - - switch (ch) - { - case 'a': - { - char *s; - int l; - - s = va_arg(va, char *); - l = va_arg(va, int); - - if (s != NULL) - el = PyString_FromStringAndSize(s, (SIP_SSIZE_T)l); - else - { - Py_INCREF(Py_None); - el = Py_None; - } - } - - break; - - case 'A': -#if defined(HAVE_WCHAR_H) - { - wchar_t *s; - int l; - - s = va_arg(va, wchar_t *); - l = va_arg(va, int); - - if (s != NULL) - el = PyUnicode_FromWideChar(s, (SIP_SSIZE_T)l); - else - { - Py_INCREF(Py_None); - el = Py_None; - } - } -#else - raiseNoWChar(); - el = NULL; -#endif - - break; - - case 'b': - el = PyBool_FromLong(va_arg(va,int)); - break; - - case 'c': - { - char c = va_arg(va, int); - - el = PyString_FromStringAndSize(&c,1); - } - - break; - - case 'w': -#if defined(HAVE_WCHAR_H) - { - wchar_t c = va_arg(va, int); - - el = PyUnicode_FromWideChar(&c, 1); - } -#else - raiseNoWChar(); - el = NULL; -#endif - - break; - - case 'e': - el = PyInt_FromLong(va_arg(va,int)); - break; - - case 'E': - { - int ev = va_arg(va, int); - PyTypeObject *et = va_arg(va, PyTypeObject *); - - el = sip_api_convert_from_named_enum(ev, et); - } - - break; - - case 'd': - case 'f': - el = PyFloat_FromDouble(va_arg(va,double)); - break; - - case 'h': - case 'i': - el = PyInt_FromLong(va_arg(va,int)); - break; - - case 'l': - el = PyLong_FromLong(va_arg(va,long)); - break; - - case 'm': - el = PyLong_FromUnsignedLong(va_arg(va, unsigned long)); - break; - - case 'n': -#if defined(HAVE_LONG_LONG) - el = PyLong_FromLongLong(va_arg(va, PY_LONG_LONG)); -#else - el = PyLong_FromLong(va_arg(va, long)); -#endif - break; - - case 'o': -#if defined(HAVE_LONG_LONG) - el = PyLong_FromUnsignedLongLong(va_arg(va, unsigned PY_LONG_LONG)); -#else - el = PyLong_FromUnsignedLong(va_arg(va, unsigned long)); -#endif - break; - - case 's': - { - char *s = va_arg(va, char *); - - if (s != NULL) - el = PyString_FromString(s); - else - { - Py_INCREF(Py_None); - el = Py_None; - } - } - - break; - - case 'x': -#if defined(HAVE_WCHAR_H) - { - wchar_t *s = va_arg(va, wchar_t *); - - if (s != NULL) - el = PyUnicode_FromWideChar(s, (SIP_SSIZE_T)wcslen(s)); - else - { - Py_INCREF(Py_None); - el = Py_None; - } - } -#else - raiseNoWChar(); - el = NULL; -#endif - - break; - - case 't': - case 'u': - el = PyLong_FromUnsignedLong(va_arg(va, unsigned)); - break; - - case 'B': - { - void *p = va_arg(va,void *); - sipWrapperType *wt = va_arg(va, sipWrapperType *); - PyObject *xfer = va_arg(va, PyObject *); - - el = sip_api_convert_from_new_instance(p, wt, xfer); - } - - break; - - case 'C': - { - void *p = va_arg(va,void *); - sipWrapperType *wt = va_arg(va, sipWrapperType *); - PyObject *xfer = va_arg(va, PyObject *); - - el = sip_api_convert_from_instance(p, wt, xfer); - } - - break; - - case 'D': - { - void *p = va_arg(va, void *); - const sipMappedType *mt = va_arg(va, const sipMappedType *); - PyObject *xfer = va_arg(va, PyObject *); - - el = sip_api_convert_from_mapped_type(p, mt, xfer); - } - - break; - - case 'M': - case 'O': - { - void *sipCpp = va_arg(va,void *); - sipWrapperType *wt = va_arg(va,sipWrapperType *); - - el = sip_api_convert_from_instance(sipCpp,wt,NULL); - } - - break; - - case 'N': - case 'P': - { - void *sipCpp = va_arg(va,void *); - sipWrapperType *wt = va_arg(va,sipWrapperType *); - - el = sip_api_convert_from_new_instance(sipCpp,wt,NULL); - } - - break; - - case 'R': - el = va_arg(va,PyObject *); - break; - - case 'S': - el = va_arg(va,PyObject *); - Py_INCREF(el); - break; - - case 'T': - { - void *sipCpp = va_arg(va,void *); - sipConvertFromFunc func = va_arg(va,sipConvertFromFunc); - - el = func(sipCpp, NULL); - } - - break; - - case 'V': - el = sip_api_convert_from_void_ptr(va_arg(va,void *)); - break; - - default: - PyErr_Format(PyExc_SystemError,"buildObject(): invalid format character '%c'",ch); - el = NULL; - } - - if (el == NULL) - { - Py_XDECREF(obj); - return NULL; - } - - if (obj == NULL) - return el; - - PyTuple_SET_ITEM(obj,i,el); - ++i; - } - - return obj; -} - - -/* - * Parse a result object based on a format string. - */ -static int sip_api_parse_result(int *isErr, PyObject *method, PyObject *res, - const char *fmt, ...) -{ - int tupsz, rc = 0; - va_list va; - - va_start(va,fmt); - - /* Basic validation of the format string. */ - - if (*fmt == '(') - { - char *ep; - - if ((ep = strchr(fmt,')')) == NULL || ep[1] != '\0') - { - PyErr_Format(PyExc_SystemError, "sipParseResult(): invalid format string \"%s\"", fmt); - rc = -1; - } - else - { - tupsz = ep - ++fmt; - - if (tupsz >= 0 && (!PyTuple_Check(res) || PyTuple_GET_SIZE(res) != tupsz)) - { - sip_api_bad_catcher_result(method); - rc = -1; - } - } - } - else - tupsz = -1; - - if (rc == 0) - { - char ch; - int i = 0; - - while ((ch = *fmt++) != '\0' && ch != ')' && rc == 0) - { - PyObject *arg; - int invalid = FALSE; - - if (tupsz > 0) - { - arg = PyTuple_GET_ITEM(res,i); - ++i; - } - else - arg = res; - - switch (ch) - { - case 'a': - { - char **p = va_arg(va, char **); - int *szp = va_arg(va, int *); - - if (parseCharArray(arg, p, szp) < 0) - invalid = TRUE; - } - - break; - - case 'A': -#if defined(HAVE_WCHAR_H) - { - wchar_t **p = va_arg(va, wchar_t **); - int *szp = va_arg(va, int *); - - if (parseWCharArray(arg, p, szp) < 0) - invalid = TRUE; - } -#else - raiseNoWChar(); - invalid = TRUE; -#endif - - break; - - case 'b': - { - int v = PyInt_AsLong(arg); - - if (PyErr_Occurred()) - invalid = TRUE; - else - sipSetBool(va_arg(va,void *),v); - } - - break; - - case 'c': - { - char *p = va_arg(va, char *); - - if (parseChar(arg, p) < 0) - invalid = TRUE; - } - - break; - - case 'w': -#if defined(HAVE_WCHAR_H) - { - wchar_t *p = va_arg(va, wchar_t *); - - if (parseWChar(arg, p) < 0) - invalid = TRUE; - } -#else - raiseNoWChar(); - invalid = TRUE; -#endif - - break; - - case 'd': - { - double v = PyFloat_AsDouble(arg); - - if (PyErr_Occurred()) - invalid = TRUE; - else - *va_arg(va,double *) = v; - } - - break; - - case 'e': - { - int v = PyInt_AsLong(arg); - - if (PyErr_Occurred()) - invalid = TRUE; - else - *va_arg(va,int *) = v; - } - - break; - - case 'E': - { - PyTypeObject *et = va_arg(va, PyTypeObject *); - int *p = va_arg(va, int *); - - if (PyObject_TypeCheck(arg, et)) - *p = PyInt_AsLong(arg); - else - invalid = TRUE; - } - - break; - - case 'f': - { - float v = PyFloat_AsDouble(arg); - - if (PyErr_Occurred()) - invalid = TRUE; - else - *va_arg(va,float *) = v; - } - - break; - - case 'h': - { - short v = PyInt_AsLong(arg); - - if (PyErr_Occurred()) - invalid = TRUE; - else - *va_arg(va,short *) = v; - } - - break; - - case 't': - { - unsigned short v = sip_api_long_as_unsigned_long(arg); - - if (PyErr_Occurred()) - invalid = TRUE; - else - *va_arg(va,unsigned short *) = v; - } - - break; - - case 'i': - { - int v = PyInt_AsLong(arg); - - if (PyErr_Occurred()) - invalid = TRUE; - else - *va_arg(va,int *) = v; - } - - break; - - case 'u': - { - unsigned v = sip_api_long_as_unsigned_long(arg); - - if (PyErr_Occurred()) - invalid = TRUE; - else - *va_arg(va,unsigned *) = v; - } - - break; - - case 'l': - { - long v = PyLong_AsLong(arg); - - if (PyErr_Occurred()) - invalid = TRUE; - else - *va_arg(va,long *) = v; - } - - break; - - case 'm': - { - unsigned long v = sip_api_long_as_unsigned_long(arg); - - if (PyErr_Occurred()) - invalid = TRUE; - else - *va_arg(va, unsigned long *) = v; - } - - break; - - case 'n': - { -#if defined(HAVE_LONG_LONG) - PY_LONG_LONG v = PyLong_AsLongLong(arg); -#else - long v = PyLong_AsLong(arg); -#endif - - if (PyErr_Occurred()) - invalid = TRUE; - else -#if defined(HAVE_LONG_LONG) - *va_arg(va, PY_LONG_LONG *) = v; -#else - *va_arg(va, long *) = v; -#endif - } - - break; - - case 'o': - { -#if defined(HAVE_LONG_LONG) - unsigned PY_LONG_LONG v = PyLong_AsUnsignedLongLong(arg); -#else - unsigned long v = PyLong_AsUnsignedLong(arg); -#endif - - if (PyErr_Occurred()) - invalid = TRUE; - else -#if defined(HAVE_LONG_LONG) - *va_arg(va, unsigned PY_LONG_LONG *) = v; -#else - *va_arg(va, unsigned long *) = v; -#endif - } - - break; - - case 's': - { - char **p = va_arg(va, char **); - - if (parseCharString(arg, p) < 0) - invalid = TRUE; - } - - break; - - case 'x': -#if defined(HAVE_WCHAR_H) - { - wchar_t **p = va_arg(va, wchar_t **); - - if (parseWCharString(arg, p) < 0) - invalid = TRUE; - } -#else - raiseNoWChar(); - invalid = TRUE; -#endif - - break; - - case 'C': - { - if (*fmt == '\0') - invalid = TRUE; - else - { - int flags = *fmt++ - '0'; - int iserr = FALSE; - sipWrapperType *type; - void **cpp; - int *state; - - type = va_arg(va, sipWrapperType *); - - if (flags & FORMAT_NO_STATE) - state = NULL; - else - state = va_arg(va, int *); - - cpp = va_arg(va, void **); - - *cpp = sip_api_force_convert_to_instance(arg, type, (flags & FORMAT_FACTORY ? arg : NULL), (flags & FORMAT_DEREF ? SIP_NOT_NONE : 0), state, &iserr); - - if (iserr) - invalid = TRUE; - } - } - - break; - - case 'D': - { - if (*fmt == '\0') - invalid = TRUE; - else - { - int flags = *fmt++ - '0'; - int iserr = FALSE; - const sipMappedType *mt; - void **cpp; - int *state; - - mt = va_arg(va, const sipMappedType *); - - if (flags & FORMAT_NO_STATE) - state = NULL; - else - state = va_arg(va, int *); - - cpp = va_arg(va, void **); - - *cpp = sip_api_force_convert_to_mapped_type(arg, mt, (flags & FORMAT_FACTORY ? arg : NULL), (flags & FORMAT_DEREF ? SIP_NOT_NONE : 0), state, &iserr); - - if (iserr) - invalid = TRUE; - } - } - - break; - - case 'L': - { - sipForceConvertToFunc func = va_arg(va,sipForceConvertToFunc); - void **sipCpp = va_arg(va,void **); - int iserr = FALSE; - - *sipCpp = func(arg,&iserr); - - if (iserr) - invalid = TRUE; - } - - break; - - case 'M': - { - sipForceConvertToFunc func = va_arg(va,sipForceConvertToFunc); - void **sipCpp = va_arg(va,void **); - int iserr = FALSE; - - *sipCpp = func(arg,&iserr); - - if (iserr || *sipCpp == NULL) - invalid = TRUE; - } - - break; - - case 'N': - { - PyTypeObject *type = va_arg(va,PyTypeObject *); - PyObject **p = va_arg(va,PyObject **); - - if (arg == Py_None || PyObject_TypeCheck(arg,type)) - { - Py_INCREF(arg); - *p = arg; - } - else - invalid = TRUE; - } - - break; - - case 'O': - Py_INCREF(arg); - *va_arg(va,PyObject **) = arg; - break; - - case 'T': - { - PyTypeObject *type = va_arg(va,PyTypeObject *); - PyObject **p = va_arg(va,PyObject **); - - if (PyObject_TypeCheck(arg,type)) - { - Py_INCREF(arg); - *p = arg; - } - else - invalid = TRUE; - } - - break; - - case 'V': - { - void *v = sip_api_convert_to_void_ptr(arg); - - if (PyErr_Occurred()) - invalid = TRUE; - else - *va_arg(va,void **) = v; - } - - break; - - case 'Z': - if (arg != Py_None) - invalid = TRUE; - - break; - - default: - PyErr_Format(PyExc_SystemError,"sipParseResult(): invalid format character '%c'",ch); - rc = -1; - } - - if (invalid) - { - sip_api_bad_catcher_result(method); - rc = -1; - break; - } - } - } - - va_end(va); - - if (isErr != NULL && rc < 0) - *isErr = TRUE; - - return rc; -} - - -/* - * A thin wrapper around PyLong_AsUnsignedLong() that works around a bug in - * Python versions prior to v2.4 where an integer (or a named enum) causes an - * error. - */ -static unsigned long sip_api_long_as_unsigned_long(PyObject *o) -{ -#if PY_VERSION_HEX < 0x02040000 - if (o != NULL && !PyLong_Check(o) && PyInt_Check(o)) - { - long v = PyInt_AsLong(o); - - if (v < 0) - { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned long"); - - return (unsigned long)-1; - } - - return v; - } -#endif - - return PyLong_AsUnsignedLong(o); -} - - -/* - * Parse the arguments to a C/C++ function without any side effects. - */ -static int sip_api_parse_args(int *argsParsedp, PyObject *sipArgs, - const char *fmt, ...) -{ - int valid, nrargs, selfarg; - sipWrapper *self; - PyObject *single_arg; - va_list va; - - /* Previous sticky errors stop subsequent parses. */ - if (*argsParsedp & PARSE_STICKY) - return 0; - - /* See if we are parsing a tuple or a single argument. */ - if (PyTuple_Check(sipArgs)) - { - Py_INCREF(sipArgs); - nrargs = PyTuple_GET_SIZE(sipArgs); - } - else if ((single_arg = PyTuple_New(1)) != NULL) - { - Py_INCREF(sipArgs); - PyTuple_SET_ITEM(single_arg,0,sipArgs); - - sipArgs = single_arg; - nrargs = 1; - } - else - return 0; - - /* - * The first pass checks all the types and does conversions that are - * cheap and have no side effects. - */ - va_start(va,fmt); - valid = parsePass1(&self,&selfarg,&nrargs,sipArgs,fmt,va); - va_end(va); - - if (valid != PARSE_OK) - { - int pvalid, pnrargs; - - /* - * Use this error if there was no previous error, or if we - * have parsed more arguments this time, or if the previous - * error was that there were too many arguments. - */ - pvalid = (*argsParsedp & PARSE_MASK); - pnrargs = (*argsParsedp & ~PARSE_MASK); - - if (pvalid == PARSE_OK || pnrargs < nrargs || - (pnrargs == nrargs && pvalid == PARSE_MANY)) - *argsParsedp = valid | nrargs; - - Py_DECREF(sipArgs); - - return 0; - } - - /* - * The second pass does any remaining conversions now that we know we - * have the right signature. - */ - va_start(va,fmt); - valid = parsePass2(self,selfarg,nrargs,sipArgs,fmt,va); - va_end(va); - - if (valid != PARSE_OK) - { - *argsParsedp = valid | PARSE_STICKY; - - Py_DECREF(sipArgs); - - return 0; - } - - *argsParsedp = nrargs; - - Py_DECREF(sipArgs); - - return 1; -} - - -/* - * Parse a pair of arguments to a C/C++ function without any side effects. - */ -static int sip_api_parse_pair(int *argsParsedp, PyObject *sipArg0, - PyObject *sipArg1, const char *fmt, ...) -{ - int valid, nrargs, selfarg; - sipWrapper *self; - PyObject *args; - va_list va; - - /* Previous sticky errors stop subsequent parses. */ - if (*argsParsedp & PARSE_STICKY) - return 0; - - if ((args = PyTuple_New(2)) == NULL) - return 0; - - Py_INCREF(sipArg0); - PyTuple_SET_ITEM(args, 0, sipArg0); - - Py_INCREF(sipArg1); - PyTuple_SET_ITEM(args, 1, sipArg1); - - nrargs = 2; - - /* - * The first pass checks all the types and does conversions that are - * cheap and have no side effects. - */ - va_start(va,fmt); - valid = parsePass1(&self,&selfarg,&nrargs,args,fmt,va); - va_end(va); - - if (valid != PARSE_OK) - { - int pvalid, pnrargs; - - /* - * Use this error if there was no previous error, or if we - * have parsed more arguments this time, or if the previous - * error was that there were too many arguments. - */ - pvalid = (*argsParsedp & PARSE_MASK); - pnrargs = (*argsParsedp & ~PARSE_MASK); - - if (pvalid == PARSE_OK || pnrargs < nrargs || - (pnrargs == nrargs && pvalid == PARSE_MANY)) - *argsParsedp = valid | nrargs; - - Py_DECREF(args); - - return 0; - } - - /* - * The second pass does any remaining conversions now that we know we - * have the right signature. - */ - va_start(va,fmt); - valid = parsePass2(self,selfarg,nrargs,args,fmt,va); - va_end(va); - - if (valid != PARSE_OK) - { - *argsParsedp = valid | PARSE_STICKY; - - Py_DECREF(args); - - return 0; - } - - *argsParsedp = nrargs; - - Py_DECREF(args); - - return 1; -} - - -/* - * First pass of the argument parse, converting those that can be done so - * without any side effects. Return PARSE_OK if the arguments matched. - */ -static int parsePass1(sipWrapper **selfp, int *selfargp, int *argsParsedp, - PyObject *sipArgs, const char *fmt, va_list va) -{ - int valid, compulsory, nrargs, argnr, nrparsed; - - valid = PARSE_OK; - nrargs = *argsParsedp; - nrparsed = 0; - compulsory = TRUE; - argnr = 0; - - /* - * Handle those format characters that deal with the "self" argument. - * They will always be the first one. - */ - *selfp = NULL; - *selfargp = FALSE; - - switch (*fmt++) - { - case 'B': - case 'p': - { - PyObject *self; - sipWrapperType *type; - - self = *va_arg(va,PyObject **); - type = va_arg(va,sipWrapperType *); - va_arg(va,void **); - - if (self == NULL) - { - if ((valid = getSelfFromArgs(type,sipArgs,argnr,selfp)) != PARSE_OK) - break; - - *selfargp = TRUE; - ++nrparsed; - ++argnr; - } - else - *selfp = (sipWrapper *)self; - - break; - } - - case 'C': - *selfp = (sipWrapper *)va_arg(va,PyObject *); - break; - - default: - --fmt; - } - - /* Now handle the remaining arguments. */ - while (valid == PARSE_OK) - { - char ch; - PyObject *arg; - - PyErr_Clear(); - - /* See if the following arguments are optional. */ - if ((ch = *fmt++) == '|') - { - compulsory = FALSE; - ch = *fmt++; - } - - /* See if we don't expect anything else. */ - - if (ch == '\0') - { - /* Invalid if there are still arguments. */ - if (argnr < nrargs) - valid = PARSE_MANY; - - break; - } - - /* See if we have run out of arguments. */ - - if (argnr == nrargs) - { - /* - * It is an error if we are still expecting compulsory - * arguments unless the current argume is an ellipsis. - */ - if (ch != 'W' && ch != '\0' && compulsory) - valid = PARSE_FEW; - - break; - } - - /* Get the next argument. */ - arg = PyTuple_GET_ITEM(sipArgs,argnr); - ++argnr; - - switch (ch) - { - case 'W': - /* Ellipsis. */ - break; - - case 's': - { - /* String or None. */ - - char **p = va_arg(va, char **); - - if (parseCharString(arg, p) < 0) - valid = PARSE_TYPE; - - break; - } - - case 'x': -#if defined(HAVE_WCHAR_H) - { - /* Wide string or None. */ - - wchar_t **p = va_arg(va, wchar_t **); - - if (parseWCharString(arg, p) < 0) - valid = PARSE_TYPE; - - break; - } -#else - raiseNoWChar(); - valid = PARSE_RAISED; - break; -#endif - - case 'U': - { - /* - * Slot name or callable, return the name or - * callable. - */ - - char **sname = va_arg(va, char **); - PyObject **scall = va_arg(va, PyObject **); - - *sname = NULL; - *scall = NULL; - - if (PyString_Check(arg)) - { - char *s = PyString_AS_STRING(arg); - - if (*s == '1' || *s == '2' || *s == '9') - *sname = s; - else - valid = PARSE_TYPE; - } - else if (PyCallable_Check(arg)) - *scall = arg; - else if (arg != Py_None) - valid = PARSE_TYPE; - - break; - } - - case 'S': - { - /* Slot name, return the name. */ - - if (PyString_Check(arg)) - { - char *s = PyString_AS_STRING(arg); - - if (*s == '1' || *s == '2' || *s == '9') - *va_arg(va,char **) = s; - else - valid = PARSE_TYPE; - } - else - valid = PARSE_TYPE; - - break; - } - - case 'G': - { - /* Signal name, return the name. */ - - if (PyString_Check(arg)) - { - char *s = PyString_AS_STRING(arg); - - if (*s == '2' || *s == '9') - *va_arg(va,char **) = s; - else - valid = PARSE_TYPE; - } - else - valid = PARSE_TYPE; - - break; - } - - case 'J': - { - /* Class instance. */ - - if (*fmt == '\0') - valid = PARSE_FORMAT; - else - { - int flags = *fmt++ - '0'; - sipWrapperType *type; - int iflgs = 0; - - type = va_arg(va,sipWrapperType *); - va_arg(va,void **); - - if (flags & FORMAT_DEREF) - iflgs |= SIP_NOT_NONE; - - if (flags & (FORMAT_GET_WRAPPER|FORMAT_TRANSFER_THIS)) - va_arg(va,PyObject **); - - if (flags & FORMAT_NO_CONVERTORS) - iflgs |= SIP_NO_CONVERTORS; - else - va_arg(va, int *); - - if (!sip_api_can_convert_to_instance(arg, type, iflgs)) - valid = PARSE_TYPE; - } - - break; - } - - case 'M': - { - /* Mapped type instance. */ - - if (*fmt == '\0') - valid = PARSE_FORMAT; - else - { - int flags = *fmt++ - '0'; - sipMappedType *mt; - int iflgs = 0; - - mt = va_arg(va, sipMappedType *); - va_arg(va, void **); - va_arg(va, int *); - - if (flags & FORMAT_DEREF) - iflgs |= SIP_NOT_NONE; - - if (!sip_api_can_convert_to_mapped_type(arg, mt, iflgs)) - valid = PARSE_TYPE; - } - - break; - } - - - case 'N': - { - /* Python object of given type or None. */ - - PyTypeObject *type = va_arg(va,PyTypeObject *); - PyObject **p = va_arg(va,PyObject **); - - if (arg == Py_None || PyObject_TypeCheck(arg,type)) - *p = arg; - else - valid = PARSE_TYPE; - - break; - } - - case 'P': - { - /* - * Python object of any type with a - * sub-format. - */ - - *va_arg(va,PyObject **) = arg; - - /* Skip the sub-format. */ - if (*fmt++ == '\0') - valid = PARSE_FORMAT; - - break; - } - - case 'T': - { - /* Python object of given type. */ - - PyTypeObject *type = va_arg(va,PyTypeObject *); - PyObject **p = va_arg(va,PyObject **); - - if (PyObject_TypeCheck(arg,type)) - *p = arg; - else - valid = PARSE_TYPE; - - break; - } - - case 'R': - { - /* Sub-class of TQObject. */ - - if (sipQtSupport == NULL || !PyObject_TypeCheck(arg, (PyTypeObject *)sipQObjectClass)) - valid = PARSE_TYPE; - else - *va_arg(va,PyObject **) = arg; - - break; - } - - case 'F': - { - /* Python callable object. */ - - if (PyCallable_Check(arg)) - *va_arg(va,PyObject **) = arg; - else - valid = PARSE_TYPE; - - break; - } - - case 'H': - { - /* Python callable object or None. */ - - if (arg == Py_None || PyCallable_Check(arg)) - *va_arg(va,PyObject **) = arg; - else - valid = PARSE_TYPE; - - break; - } - - case 'q': - { - /* Qt receiver to connect. */ - - va_arg(va,char *); - va_arg(va,void **); - va_arg(va,const char **); - - if (sipQtSupport == NULL || !PyObject_TypeCheck(arg, (PyTypeObject *)sipQObjectClass)) - valid = PARSE_TYPE; - - break; - } - - case 'Q': - { - /* Qt receiver to disconnect. */ - - va_arg(va,char *); - va_arg(va,void **); - va_arg(va,const char **); - - if (sipQtSupport == NULL || !PyObject_TypeCheck(arg, (PyTypeObject *)sipQObjectClass)) - valid = PARSE_TYPE; - - break; - } - - case 'y': - { - /* Python slot to connect. */ - - va_arg(va,char *); - va_arg(va,void **); - va_arg(va,const char **); - - if (sipQtSupport == NULL || !PyCallable_Check(arg)) - valid = PARSE_TYPE; - - break; - } - - case 'Y': - { - /* Python slot to disconnect. */ - - va_arg(va,char *); - va_arg(va,void **); - va_arg(va,const char **); - - if (sipQtSupport == NULL || !PyCallable_Check(arg)) - valid = PARSE_TYPE; - - break; - } - - case 'a': - { - /* Char array or None. */ - - char **p = va_arg(va, char **); - int *szp = va_arg(va, int *); - - if (parseCharArray(arg, p, szp) < 0) - valid = PARSE_TYPE; - - break; - } - - case 'A': -#if defined(HAVE_WCHAR_H) - { - /* Wide char array or None. */ - - wchar_t **p = va_arg(va, wchar_t **); - int *szp = va_arg(va, int *); - - if (parseWCharArray(arg, p, szp) < 0) - valid = PARSE_TYPE; - - break; - } -#else - raiseNoWChar(); - valid = PARSE_RAISED; - break -#endif - - case 'c': - { - /* Character. */ - - char *p = va_arg(va, char *); - - if (parseChar(arg, p) < 0) - valid = PARSE_TYPE; - - break; - } - - case 'w': -#if defined(HAVE_WCHAR_H) - { - /* Wide character. */ - - wchar_t *p = va_arg(va, wchar_t *); - - if (parseWChar(arg, p) < 0) - valid = PARSE_TYPE; - - break; - } -#else - raiseNoWChar(); - valid = PARSE_RAISED; - break -#endif - - case 'b': - { - /* Bool. */ - - int v = PyInt_AsLong(arg); - - if (PyErr_Occurred()) - valid = PARSE_TYPE; - else - sipSetBool(va_arg(va,void *),v); - - break; - } - - case 'e': - { - /* Anonymous enum. */ - - int v = PyInt_AsLong(arg); - - if (PyErr_Occurred()) - valid = PARSE_TYPE; - else - *va_arg(va,int *) = v; - - break; - } - - case 'E': - { - /* Named enum. */ - - PyTypeObject *et = va_arg(va, PyTypeObject *); - - va_arg(va, int *); - - if (!PyObject_TypeCheck(arg, et)) - valid = PARSE_TYPE; - } - - break; - - case 'i': - { - /* Integer. */ - - int v = PyInt_AsLong(arg); - - if (PyErr_Occurred()) - valid = PARSE_TYPE; - else - *va_arg(va,int *) = v; - - break; - } - - case 'u': - { - /* Unsigned integer. */ - - unsigned v = sip_api_long_as_unsigned_long(arg); - - if (PyErr_Occurred()) - valid = PARSE_TYPE; - else - *va_arg(va, unsigned *) = v; - - break; - } - - case 'h': - { - /* Short integer. */ - - short v = PyInt_AsLong(arg); - - if (PyErr_Occurred()) - valid = PARSE_TYPE; - else - *va_arg(va,short *) = v; - - break; - } - - case 't': - { - /* Unsigned short integer. */ - - unsigned short v = sip_api_long_as_unsigned_long(arg); - - if (PyErr_Occurred()) - valid = PARSE_TYPE; - else - *va_arg(va, unsigned short *) = v; - - break; - } - - case 'l': - { - /* Long integer. */ - - long v = PyLong_AsLong(arg); - - if (PyErr_Occurred()) - valid = PARSE_TYPE; - else - *va_arg(va,long *) = v; - - break; - } - - case 'm': - { - /* Unsigned long integer. */ - - unsigned long v = sip_api_long_as_unsigned_long(arg); - - if (PyErr_Occurred()) - valid = PARSE_TYPE; - else - *va_arg(va, unsigned long *) = v; - - break; - } - - case 'n': - { - /* Long long integer. */ - -#if defined(HAVE_LONG_LONG) - PY_LONG_LONG v = PyLong_AsLongLong(arg); -#else - long v = PyLong_AsLong(arg); -#endif - - if (PyErr_Occurred()) - valid = PARSE_TYPE; - else -#if defined(HAVE_LONG_LONG) - *va_arg(va, PY_LONG_LONG *) = v; -#else - *va_arg(va, long *) = v; -#endif - - break; - } - - case 'o': - { - /* Unsigned long long integer. */ - -#if defined(HAVE_LONG_LONG) - unsigned PY_LONG_LONG v = PyLong_AsUnsignedLongLong(arg); -#else - unsigned long v = PyLong_AsUnsignedLong(arg); -#endif - - if (PyErr_Occurred()) - valid = PARSE_TYPE; - else -#if defined(HAVE_LONG_LONG) - *va_arg(va, unsigned PY_LONG_LONG *) = v; -#else - *va_arg(va, unsigned long *) = v; -#endif - - break; - } - - case 'f': - { - /* Float. */ - - double v = PyFloat_AsDouble(arg); - - if (PyErr_Occurred()) - valid = PARSE_TYPE; - else - *va_arg(va,float *) = (float)v; - - break; - } - - case 'X': - { - /* Constrained (ie. exact) types. */ - - switch (*fmt++) - { - case 'b': - { - /* Boolean. */ - - if (PyBool_Check(arg)) - sipSetBool(va_arg(va,void *),(arg == Py_True)); - else - valid = PARSE_TYPE; - - break; - } - - case 'd': - { - /* Double float. */ - - if (PyFloat_Check(arg)) - *va_arg(va,double *) = PyFloat_AS_DOUBLE(arg); - else - valid = PARSE_TYPE; - - break; - } - - case 'f': - { - /* Float. */ - - if (PyFloat_Check(arg)) - *va_arg(va,float *) = (float)PyFloat_AS_DOUBLE(arg); - else - valid = PARSE_TYPE; - - break; - } - - case 'i': - { - /* Integer. */ - - if (PyInt_Check(arg)) - *va_arg(va,int *) = PyInt_AS_LONG(arg); - else - valid = PARSE_TYPE; - - break; - } - - default: - valid = PARSE_FORMAT; - } - - break; - } - - case 'd': - { - /* Double float. */ - - double v = PyFloat_AsDouble(arg); - - if (PyErr_Occurred()) - valid = PARSE_TYPE; - else - *va_arg(va,double *) = v; - - break; - } - - case 'v': - { - /* Void pointer. */ - - void *v = sip_api_convert_to_void_ptr(arg); - - if (PyErr_Occurred()) - valid = PARSE_TYPE; - else - *va_arg(va,void **) = v; - - break; - } - - default: - valid = PARSE_FORMAT; - } - - if (valid == PARSE_OK) - { - if (ch == 'W') - { - /* - * An ellipsis matches everything and ends the - * parse. - */ - nrparsed = nrargs; - break; - } - - ++nrparsed; - } - } - - *argsParsedp = nrparsed; - - return valid; -} - - -/* - * Second pass of the argument parse, converting the remaining ones that might - * have side effects. Return PARSE_OK if there was no error. - */ -static int parsePass2(sipWrapper *self, int selfarg, int nrargs, - PyObject *sipArgs, const char *fmt, va_list va) -{ - int a, valid; - - valid = PARSE_OK; - - /* Handle the converions of "self" first. */ - switch (*fmt++) - { - case 'B': - { - /* - * The address of a C++ instance when calling one of - * its public methods. - */ - - sipWrapperType *type; - void **p; - - *va_arg(va,PyObject **) = (PyObject *)self; - type = va_arg(va,sipWrapperType *); - p = va_arg(va,void **); - - if ((*p = sip_api_get_cpp_ptr(self,type)) == NULL) - valid = PARSE_RAISED; - - break; - } - - case 'p': - { - /* - * The address of a C++ instance when calling one of - * its protected methods. - */ - - void **p; - - *va_arg(va,PyObject **) = (PyObject *)self; - va_arg(va,sipWrapperType *); - p = va_arg(va,void **); - - if ((*p = sip_api_get_complex_cpp_ptr(self)) == NULL) - valid = PARSE_RAISED; - - break; - } - - case 'C': - va_arg(va,PyObject *); - break; - - default: - --fmt; - } - - for (a = (selfarg ? 1 : 0); a < nrargs && *fmt != 'W' && valid == PARSE_OK; ++a) - { - char ch; - PyObject *arg = PyTuple_GET_ITEM(sipArgs,a); - - /* Skip the optional character. */ - if ((ch = *fmt++) == '|') - ch = *fmt++; - - /* - * Do the outstanding conversions. For most types it has - * already been done, so we are just skipping the parameters. - */ - switch (ch) - { - case 'q': - { - /* Qt receiver to connect. */ - - char *sig = va_arg(va,char *); - void **rx = va_arg(va,void **); - const char **slot = va_arg(va,const char **); - - if ((*rx = sip_api_convert_rx(self,sig,arg,*slot,slot)) == NULL) - valid = PARSE_RAISED; - - break; - } - - case 'Q': - { - /* Qt receiver to disconnect. */ - - char *sig = va_arg(va,char *); - void **rx = va_arg(va,void **); - const char **slot = va_arg(va,const char **); - - *rx = sipGetRx(self,sig,arg,*slot,slot); - break; - } - - case 'y': - { - /* Python slot to connect. */ - - char *sig = va_arg(va,char *); - void **rx = va_arg(va,void **); - const char **slot = va_arg(va,const char **); - - if ((*rx = sip_api_convert_rx(self,sig,arg,NULL,slot)) == NULL) - valid = PARSE_RAISED; - - break; - } - - case 'Y': - { - /* Python slot to disconnect. */ - - char *sig = va_arg(va,char *); - void **rx = va_arg(va,void **); - const char **slot = va_arg(va,const char **); - - *rx = sipGetRx(self,sig,arg,NULL,slot); - break; - } - - case 'J': - { - /* Class instance. */ - - int flags = *fmt++ - '0'; - sipWrapperType *type; - void **p; - int iflgs = 0; - int iserr = FALSE; - int *state; - PyObject *xfer, **wrapper; - - type = va_arg(va,sipWrapperType *); - p = va_arg(va,void **); - - if (flags & FORMAT_TRANSFER) - xfer = (self ? (PyObject *)self : arg); - else if (flags & FORMAT_TRANSFER_BACK) - xfer = Py_None; - else - xfer = NULL; - - if (flags & FORMAT_DEREF) - iflgs |= SIP_NOT_NONE; - - if (flags & (FORMAT_GET_WRAPPER|FORMAT_TRANSFER_THIS)) - wrapper = va_arg(va, PyObject **); - - if (flags & FORMAT_NO_CONVERTORS) - { - iflgs |= SIP_NO_CONVERTORS; - state = NULL; - } - else - state = va_arg(va, int *); - - *p = sip_api_convert_to_instance(arg, type, xfer, iflgs, state, &iserr); - - if (iserr) - valid = PARSE_RAISED; - - if (flags & FORMAT_GET_WRAPPER) - *wrapper = (*p != NULL ? arg : NULL); - else if (flags & FORMAT_TRANSFER_THIS && *p != NULL) - *wrapper = arg; - - break; - } - - case 'M': - { - /* Mapped type instance. */ - - int flags = *fmt++ - '0'; - sipMappedType *mt; - void **p; - int iflgs = 0; - int iserr = FALSE; - int *state; - PyObject *xfer; - - mt = va_arg(va, sipMappedType *); - p = va_arg(va, void **); - state = va_arg(va, int *); - - if (flags & FORMAT_TRANSFER) - xfer = (self ? (PyObject *)self : arg); - else if (flags & FORMAT_TRANSFER_BACK) - xfer = Py_None; - else - xfer = NULL; - - if (flags & FORMAT_DEREF) - iflgs |= SIP_NOT_NONE; - - *p = sip_api_convert_to_mapped_type(arg, mt, xfer, iflgs, state, &iserr); - - if (iserr) - valid = PARSE_RAISED; - - break; - } - - case 'P': - { - /* - * Python object of any type with a - * sub-format. - */ - - PyObject **p = va_arg(va,PyObject **); - int flags = *fmt++ - '0'; - - if (flags & FORMAT_TRANSFER) - { - Py_XINCREF(*p); - } - else if (flags & FORMAT_TRANSFER_BACK) - { - Py_XDECREF(*p); - } - - break; - } - - case 'X': - { - /* Constrained (ie. exact) type. */ - - ++fmt; - va_arg(va,void *); - - break; - } - - - case 'E': - { - /* Named enum. */ - - int *p; - - va_arg(va, PyTypeObject *); - p = va_arg(va, int *); - - *p = PyInt_AsLong(arg); - - break; - } - - /* - * Every other argument is a pointer and only differ in how - * many there are. - */ - case 'N': - case 'T': - case 'a': - case 'A': - va_arg(va,void *); - - /* Drop through. */ - - default: - va_arg(va,void *); - } - } - - /* Handle any ellipsis argument. */ - if (*fmt == 'W' && valid == PARSE_OK) - { - PyObject *al; - - /* Create a tuple for any remaining arguments. */ - if ((al = PyTuple_New(nrargs - a)) != NULL) - { - int da = 0; - - while (a < nrargs) - { - PyObject *arg = PyTuple_GET_ITEM(sipArgs,a); - - /* Add the remaining argument to the tuple. */ - Py_INCREF(arg); - PyTuple_SET_ITEM(al, da, arg); - - ++a; - ++da; - } - - /* Return the tuple. */ - *va_arg(va, PyObject **) = al; - } - else - valid = PARSE_RAISED; - } - - return valid; -} - - -/* - * Carry out actions common to all ctors. - */ -static void sip_api_common_ctor(sipMethodCache *cache,int nrmeths) -{ - /* This is thread safe. */ - while (nrmeths-- > 0) - cache++->mcflags = 0; -} - - -/* - * Carry out actions common to all dtors. - */ -static void sip_api_common_dtor(sipWrapper *sipSelf) -{ - if (sipSelf != NULL && sipInterpreter != NULL) - { - SIP_BLOCK_THREADS - - callPyDtor(sipSelf); - - if (!sipNotInMap(sipSelf)) - sipOMRemoveObject(&cppPyMap,sipSelf); - - /* This no longer points to anything useful. */ - sipSelf->u.cppPtr = NULL; - - /* - * If C/C++ has a reference (and therefore no parent) then remove it. - * Otherwise remove the object from any parent. - */ - if (sipCppHasRef(sipSelf)) - { - sipResetCppHasRef(sipSelf); - Py_DECREF(sipSelf); - } - else - removeFromParent(sipSelf); - - SIP_UNBLOCK_THREADS - } -} - - -/* - * Call self.__dtor__() if it is implemented. - */ -static void callPyDtor(sipWrapper *self) -{ - sip_gilstate_t sipGILState; - sipMethodCache pymc; - PyObject *meth; - - /* No need to cache the method, it will only be called once. */ - pymc.mcflags = 0; - meth = sip_api_is_py_method(&sipGILState, &pymc, self, NULL, "__dtor__"); - - if (meth != NULL) - { - PyObject *res = sip_api_call_method(0, meth, "", NULL); - - Py_DECREF(meth); - - /* Discard any result. */ - Py_XDECREF(res); - - SIP_RELEASE_GIL(sipGILState); - } -} - - -/* - * Add a wrapper to it's parent owner if it has one. The wrapper must not - * currently have a parent and, therefore, no siblings. - */ -static void addToParent(sipWrapper *self, sipWrapper *owner) -{ - if (owner != NULL) - { - if (owner->first_child != NULL) - { - self->sibling_next = owner->first_child; - owner->first_child->sibling_prev = self; - } - - owner->first_child = self; - self->parent = owner; - - /* - * The owner holds a real reference so that the cyclic garbage - * collector works properly. - */ - Py_INCREF(self); - } -} - - -/* - * Remove a wrapper from it's parent if it has one. - */ -static void removeFromParent(sipWrapper *self) -{ - if (self->parent != NULL) - { - if (self->parent->first_child == self) - self->parent->first_child = self->sibling_next; - - if (self->sibling_next != NULL) - self->sibling_next->sibling_prev = self->sibling_prev; - - if (self->sibling_prev != NULL) - self->sibling_prev->sibling_next = self->sibling_next; - - self->parent = NULL; - self->sibling_next = NULL; - self->sibling_prev = NULL; - - /* - * We must do this last, after all the pointers are correct, - * because this is used by the clear slot. - */ - Py_DECREF(self); - } -} - - -/* - * Convert a sequence index. Return the index or a negative value if there was - * an error. - */ -static SIP_SSIZE_T sip_api_convert_from_sequence_index(SIP_SSIZE_T idx, - SIP_SSIZE_T len) -{ - /* Negative indices start from the other end. */ - if (idx < 0) - idx = len + idx; - - if (idx < 0 || idx >= len) - { - PyErr_Format(PyExc_IndexError, "sequence index out of range"); - return -1; - } - - return idx; -} - - -/* - * Create and return a single type object. - */ -static sipWrapperType *createType(sipExportedModuleDef *client, - sipTypeDef *type, PyObject *mod_dict) -{ - PyObject *name, *bases, *typedict, *args, *dict; - sipEncodedClassDef *sup; - sipWrapperType *wt; - - /* Create an object corresponding to the type name. */ - if ((name = getBaseNameObject(type->td_name)) == NULL) - goto reterr; - - /* Create the tuple of super types. */ - if ((sup = type->td_supers) == NULL) - { - static PyObject *nobases = NULL; - - if (nobases == NULL && (nobases = Py_BuildValue("(O)",&sipWrapper_Type)) == NULL) - goto relname; - - Py_INCREF(nobases); - bases = nobases; - } - else - { - int i, nrsupers = 0; - - do - ++nrsupers; - while (!sup++->sc_flag); - - if ((bases = PyTuple_New(nrsupers)) == NULL) - goto relname; - - for (sup = type->td_supers, i = 0; i < nrsupers; ++i, ++sup) - { - PyObject *st = (PyObject *)getClassType(sup, client); - - Py_INCREF(st); - PyTuple_SET_ITEM(bases,i,st); - } - } - - /* Create the type dictionary. */ - if ((typedict = createTypeDict(client->em_nameobj)) == NULL) - goto relbases; - - /* Initialise the rest of the type and pass it via the back door. */ - type->td_module = client; - currentType = type; - - /* Create the type by calling the metatype. */ - if ((args = Py_BuildValue("OOO",name,bases,typedict)) == NULL) - goto reldict; - - if ((wt = (sipWrapperType *)PyObject_Call((PyObject *)&sipWrapperType_Type,args,NULL)) == NULL) - goto relargs; - - /* Get the dictionary into which the type will be placed. */ - if (type->td_scope.sc_flag) - dict = mod_dict; - else - dict = ((PyTypeObject *)getClassType(&type->td_scope, client))->tp_dict; - - /* Add the type to the "parent" dictionary. */ - if (PyDict_SetItem(dict,name,(PyObject *)wt) < 0) - goto reltype; - - /* We can now release our references. */ - Py_DECREF(args); - Py_DECREF(typedict); - Py_DECREF(bases); - Py_DECREF(name); - - return wt; - - /* Unwind after an error. */ - -reltype: - Py_DECREF((PyObject *)wt); - -relargs: - Py_DECREF(args); - -reldict: - Py_DECREF(typedict); - -relbases: - Py_DECREF(bases); - -relname: - Py_DECREF(name); - -reterr: - return NULL; -} - - -/* - * Create and return an enum type object. - */ -static PyTypeObject *createEnum(sipExportedModuleDef *client, sipEnumDef *ed, - PyObject *mod_dict) -{ - static PyObject *bases = NULL; - PyObject *name, *typedict, *args, *dict; - PyTypeObject *et; - - /* Get the module and dictionary into which the type will be placed. */ - if (ed->e_scope < 0) - dict = mod_dict; - else - dict = ((PyTypeObject *)client->em_types[ed->e_scope])->tp_dict; - - /* Create the base type tuple if it hasn't already been done. */ - if (bases == NULL && (bases = Py_BuildValue("(O)",&PyInt_Type)) == NULL) - goto reterr; - - /* Create an object corresponding to the type name. */ - if ((name = getBaseNameObject(ed->e_name)) == NULL) - goto reterr; - - /* Create the type dictionary. */ - if ((typedict = createTypeDict(client->em_nameobj)) == NULL) - goto relname; - - /* Create the type by calling the metatype. */ - if ((args = Py_BuildValue("OOO",name,bases,typedict)) == NULL) - goto reldict; - - if ((et = (PyTypeObject *)PyObject_Call((PyObject *)&PyType_Type,args,NULL)) == NULL) - goto relargs; - - /* Initialise any slots. */ - if (ed->e_pyslots != NULL) - initSlots(et, et->tp_as_number, et->tp_as_sequence, et->tp_as_mapping, ed->e_pyslots, TRUE); - - /* Add the type to the "parent" dictionary. */ - if (PyDict_SetItem(dict,name,(PyObject *)et) < 0) - goto reltype; - - /* We can now release our references. */ - Py_DECREF(args); - Py_DECREF(typedict); - Py_DECREF(name); - - return et; - - /* Unwind after an error. */ - -reltype: - Py_DECREF((PyObject *)et); - -relargs: - Py_DECREF(args); - -reldict: - Py_DECREF(typedict); - -relname: - Py_DECREF(name); - -reterr: - return NULL; -} - - -/* - * Return a pointer to the basename of a Python "pathname". - */ -static const char *getBaseName(const char *name) -{ - const char *bn; - - if ((bn = strrchr(name, '.')) != NULL) - ++bn; - else - bn = name; - - return bn; -} - - -/* - * Create a Python object corresponding to the basename of a Python "pathname". - */ -static PyObject *getBaseNameObject(const char *name) -{ - return PyString_FromString(getBaseName(name)); -} - - -/* - * Create a type dictionary for dynamic type being created in the module with - * the specified name. - */ -static PyObject *createTypeDict(PyObject *mname) -{ - static PyObject *proto = NULL; - static PyObject *mstr = NULL; - PyObject *dict; - - /* Create a prototype dictionary. */ - if (proto == NULL) - { - if ((proto = PyDict_New()) == NULL) - return NULL; - - /* - * These tell pickle that SIP generated classes can't be - * pickled. - */ - if (PyDict_SetItemString(proto, "__reduce_ex__", Py_None) < 0 || - PyDict_SetItemString(proto, "__reduce__", Py_None) < 0) - { - Py_DECREF(proto); - proto = NULL; - - return NULL; - } - } - - /* Create an object for "__module__". */ - if (mstr == NULL && (mstr = PyString_FromString("__module__")) == NULL) - return NULL; - - if ((dict = PyDict_Copy(proto)) == NULL) - return NULL; - - /* We need to set the module name as an attribute for dynamic types. */ - if (PyDict_SetItem(dict, mstr, mname) < 0) - { - Py_DECREF(dict); - return NULL; - } - - return dict; -} - - -/* - * Add a set of static instances to a dictionary. - */ -static int addInstances(PyObject *dict,sipInstancesDef *id) -{ - if (id->id_class != NULL && addClassInstances(dict,id->id_class) < 0) - return -1; - - if (id->id_voidp != NULL && addVoidPtrInstances(dict,id->id_voidp) < 0) - return -1; - - if (id->id_char != NULL && addCharInstances(dict,id->id_char) < 0) - return -1; - - if (id->id_string != NULL && addStringInstances(dict,id->id_string) < 0) - return -1; - - if (id->id_int != NULL && addIntInstances(dict, id->id_int) < 0) - return -1; - - if (id->id_long != NULL && addLongInstances(dict,id->id_long) < 0) - return -1; - - if (id->id_ulong != NULL && addUnsignedLongInstances(dict, id->id_ulong) < 0) - return -1; - - if (id->id_llong != NULL && addLongLongInstances(dict, id->id_llong) < 0) - return -1; - - if (id->id_ullong != NULL && addUnsignedLongLongInstances(dict, id->id_ullong) < 0) - return -1; - - if (id->id_double != NULL && addDoubleInstances(dict,id->id_double) < 0) - return -1; - - if (id->id_enum != NULL && addEnumInstances(dict,id->id_enum) < 0) - return -1; - - return 0; -} - - -/* - * Get "self" from the argument tuple for a method called as - * Class.Method(self, ...) rather than self.Method(...). - */ -static int getSelfFromArgs(sipWrapperType *type, PyObject *args, int argnr, - sipWrapper **selfp) -{ - PyObject *self; - - /* Get self from the argument tuple. */ - - if (argnr >= PyTuple_GET_SIZE(args)) - return PARSE_UNBOUND; - - self = PyTuple_GET_ITEM(args, argnr); - - if (!PyObject_TypeCheck(self, (PyTypeObject *)type)) - return PARSE_UNBOUND; - - *selfp = (sipWrapper *)self; - - return PARSE_OK; -} - - -/* - * Handle the result of a call to the class/instance setattro methods. - */ -static int handleSetLazyAttr(PyObject *nameobj,PyObject *valobj, - sipWrapperType *wt,sipWrapper *w) -{ - char *name; - PyMethodDef *pmd, *vmd; - sipEnumMemberDef *enm; - - /* See if it was a lazy attribute. */ - if ((name = PyString_AsString(nameobj)) == NULL) - return -1; - - pmd = NULL; - enm = NULL; - vmd = NULL; - - findLazyAttr(wt,name,&pmd,&enm,&vmd,NULL); - - if (vmd != NULL) - { - if (valobj == NULL) - { - PyErr_Format(PyExc_ValueError,"%s.%s cannot be deleted",wt->type->td_name,name); - - return -1; - } - - if ((vmd->ml_flags & METH_STATIC) != 0 || w != NULL) - { - PyObject *res; - - if ((res = (*vmd->ml_meth)((PyObject *)w,valobj)) == NULL) - return -1; - - /* Ignore the result (which should be Py_None). */ - Py_DECREF(res); - - return 0; - } - - PyErr_SetObject(PyExc_AttributeError,nameobj); - - return -1; - } - - /* It isn't a variable. */ - return 1; -} - - -/* - * Handle the result of a call to the class/instance getattro methods. - */ -static PyObject *handleGetLazyAttr(PyObject *nameobj,sipWrapperType *wt, - sipWrapper *w) -{ - char *name; - PyMethodDef *pmd, *vmd; - sipEnumMemberDef *enm; - sipTypeDef *in; - - /* If it was an error, propagate it. */ - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return NULL; - - PyErr_Clear(); - - /* See if it was a lazy attribute. */ - if ((name = PyString_AsString(nameobj)) == NULL) - return NULL; - - pmd = NULL; - enm = NULL; - vmd = NULL; - - findLazyAttr(wt,name,&pmd,&enm,&vmd,&in); - - if (pmd != NULL) - return PyCFunction_New(pmd,(PyObject *)w); - - if (enm != NULL) - { - PyObject *attr; - - /* - * Convert the value to an object. Note that we cannot cache - * it in the type dictionary because a sub-type might have a - * lazy attribute of the same name. In this case (because we - * call the standard getattro code first) this one would be - * wrongly found in preference to the one in the sub-class. - * The example in PyQt is TQScrollView::ResizePolicy and - * TQListView::WidthMode both having a member called Manual. - * One way around this might be to cache them in a separate - * dictionary and search that before doing the binary search - * through the lazy enum table. - */ - if ((attr = createEnumMember(in, enm)) == NULL) - return NULL; - - return attr; - } - - if (vmd != NULL) - if ((vmd->ml_flags & METH_STATIC) != 0 || w != NULL) - return (*vmd->ml_meth)((PyObject *)w,NULL); - - PyErr_SetObject(PyExc_AttributeError,nameobj); - - return NULL; -} - - -/* - * Create a Python object for an enum member. - */ -static PyObject *createEnumMember(sipTypeDef *td, sipEnumMemberDef *enm) -{ - if (enm->em_enum < 0) - return PyInt_FromLong(enm->em_val); - - return sip_api_convert_from_named_enum(enm->em_val, td->td_module->em_enums[enm->em_enum]); -} - - -/* - * Create a Python object for a member of a named enum. - */ -PyObject *sip_api_convert_from_named_enum(int eval, PyTypeObject *et) -{ - PyObject *args, *mo; - - if ((args = Py_BuildValue("(i)", eval)) == NULL) - return NULL; - - mo = PyObject_Call((PyObject *)et, args, NULL); - - Py_DECREF(args); - - return mo; -} - - -/* - * Find definition for a lazy class attribute. - */ -static void findLazyAttr(sipWrapperType *wt,char *name,PyMethodDef **pmdp, - sipEnumMemberDef **enmp,PyMethodDef **vmdp, - sipTypeDef **in) -{ - sipTypeDef *td, *nsx; - sipEncodedClassDef *sup; - - /* The base type doesn't have any type information. */ - if ((td = wt->type) == NULL) - return; - - /* Search the possible linked list of namespace extenders. */ - nsx = td; - - do - { - /* Try the methods. */ - if (nsx->td_nrmethods > 0 && - (*pmdp = (PyMethodDef *)bsearch(name, nsx->td_methods, nsx->td_nrmethods, sizeof (PyMethodDef), compareMethodName)) != NULL) - return; - - /* Try the enum members. */ - if (nsx->td_nrenummembers > 0 && - (*enmp = (sipEnumMemberDef *)bsearch(name, nsx->td_enummembers, nsx->td_nrenummembers, sizeof (sipEnumMemberDef), compareEnumMemberName)) != NULL) - { - if (in != NULL) - *in = nsx; - - return; - } - - /* Try the variables. Note, these aren't sorted. */ - if (nsx->td_variables != NULL) - { - PyMethodDef *md; - - for (md = nsx->td_variables; md->ml_name != NULL; ++md) - if (strcmp(name, md->ml_name) == 0) - { - *vmdp = md; - return; - } - } - - nsx = nsx->td_nsextender; - } - while (nsx != NULL); - - /* Check the base classes. */ - if ((sup = td->td_supers) != NULL) - do - { - findLazyAttr(getClassType(sup, td->td_module), name, pmdp, enmp, vmdp, in); - - if (*pmdp != NULL || *enmp != NULL || *vmdp != NULL) - break; - } - while (!sup++->sc_flag); -} - - -/* - * The bsearch() helper function for searching a sorted method table. - */ -static int compareMethodName(const void *key,const void *el) -{ - return strcmp((const char *)key,((const PyMethodDef *)el)->ml_name); -} - - -/* - * The bsearch() helper function for searching a sorted enum member table. - */ -static int compareEnumMemberName(const void *key,const void *el) -{ - return strcmp((const char *)key,((const sipEnumMemberDef *)el)->em_name); -} - - -/* - * Report a function with invalid argument types. - */ -static void sip_api_no_function(int argsParsed, const char *func) -{ - badArgs(argsParsed,NULL,func); -} - - -/* - * Report a method/function/signal with invalid argument types. - */ -static void sip_api_no_method(int argsParsed, const char *classname, const char *method) -{ - badArgs(argsParsed,classname,method); -} - - -/* - * Report an abstract method called with an unbound self. - */ -static void sip_api_abstract_method(const char *classname, const char *method) -{ - PyErr_Format(PyExc_TypeError,"%s.%s() is abstract and cannot be called as an unbound method", classname, method); -} - - -/* - * Handle error reporting for bad arguments to various things. - */ -static void badArgs(int argsParsed, const char *classname, const char *method) -{ - char *sep; - int nrparsed = argsParsed & ~PARSE_MASK; - - if (classname != NULL) - sep = "."; - else - { - classname = ""; - sep = ""; - } - - switch (argsParsed & PARSE_MASK) - { - case PARSE_FEW: - PyErr_Format(PyExc_TypeError,"insufficient number of arguments to %s%s%s()",classname,sep,method); - break; - - case PARSE_MANY: - PyErr_Format(PyExc_TypeError,"too many arguments to %s%s%s(), %d at most expected",classname,sep,method,nrparsed); - break; - - case PARSE_TYPE: - PyErr_Format(PyExc_TypeError,"argument %d of %s%s%s() has an invalid type",nrparsed + 1,classname,sep,method); - break; - - case PARSE_FORMAT: - PyErr_Format(PyExc_TypeError,"invalid format to sipParseArgs() from %s%s%s()",classname,sep,method); - break; - - case PARSE_UNBOUND: - PyErr_Format(PyExc_TypeError,"first argument of unbound method %s%s%s() must be a %s instance",classname,sep,method,classname); - break; - - case PARSE_RAISED: - /* It has already been taken care of. */ - - break; - - case PARSE_OK: - /* This is raised by a private re-implementation. */ - PyErr_Format(PyExc_AttributeError,"%s%s%s is a private method",classname,sep,method); - break; - } -} - - -/* - * Report a bad operator argument. Only a small subset of operators need to - * be handled (those that don't return Py_NotImplemented). - */ -static void sip_api_bad_operator_arg(PyObject *self, PyObject *arg, - sipPySlotType st) -{ - const char *sn = NULL; - - /* Try and get the text to match a Python exception. */ - - switch (st) - { - case concat_slot: - case iconcat_slot: - PyErr_Format(PyExc_TypeError, "cannot concatenate '%s' and '%s' objects", self->ob_type->tp_name, arg->ob_type->tp_name); - break; - - case repeat_slot: - sn = "*"; - break; - - case irepeat_slot: - sn = "*="; - break; - - default: - sn = "unknown"; - } - - if (sn != NULL) - PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for %s: '%s' and '%s'", sn, self->ob_type->tp_name, arg->ob_type->tp_name); -} - - -/* - * Report a sequence length that does not match the length of a slice. - */ -static void sip_api_bad_length_for_slice(SIP_SSIZE_T seqlen, - SIP_SSIZE_T slicelen) -{ - PyErr_Format(PyExc_ValueError, -#if PY_VERSION_HEX >= 0x02050000 - "attempt to assign sequence of size %zd to slice of size %zd", -#else - "attempt to assign sequence of size %d to slice of size %d", -#endif - seqlen, slicelen); -} - - -/* - * Report a Python object that cannot be converted to a particular class. - */ -static void sip_api_bad_class(const char *classname) -{ - PyErr_Format(PyExc_TypeError,"cannot convert Python object to an instance of %s",classname); -} - - -/* - * Report a Python class variable with an unexpected type. - */ -static void sip_api_bad_set_type(const char *classname,const char *var) -{ - PyErr_Format(PyExc_TypeError,"invalid type for variable %s.%s",classname,var); -} - - -/* - * Report a Python member function with an unexpected return type. - */ -static void sip_api_bad_catcher_result(PyObject *method) -{ - const char *cname; - char *mname; - - /* - * This is part of the public API so we make no assumptions about the - * method object. - */ - if (!PyMethod_Check(method) || - PyMethod_GET_FUNCTION(method) == NULL || - !PyFunction_Check(PyMethod_GET_FUNCTION(method)) || - PyMethod_GET_SELF(method) == NULL) - { - PyErr_Format(PyExc_TypeError,"invalid argument to sipBadCatcherResult()"); - return; - } - - mname = PyString_AsString(((PyFunctionObject *)PyMethod_GET_FUNCTION(method))->func_name); - - if (mname == NULL) - return; - - cname = PyMethod_GET_SELF(method)->ob_type->tp_name; - - PyErr_Format(PyExc_TypeError,"invalid result type from %s.%s()",cname,mname); -} - - -/* - * Return the name of the class corresponding to a wrapper object. This comes - * with a reference. - */ -static PyObject *sip_api_class_name(PyObject *self) -{ - return PyString_FromString(self->ob_type->tp_name); -} - - -/* - * Return non-zero if the object is a C++ instance wrapper. - */ -int sip_api_wrapper_check(PyObject *o) -{ - return PyObject_TypeCheck(o,(PyTypeObject *)&sipWrapper_Type); -} - - -/* - * Return non-zero if the object is a C++ instance wrapper type. - */ -static int sipWrapperType_Check(PyObject *op) -{ - return PyObject_TypeCheck(op,(PyTypeObject *)&sipWrapperType_Type); -} - - -/* - * Transfer ownership of a class instance to Python from C/C++. - */ -static void sip_api_transfer_back(PyObject *self) -{ - if (self != NULL && sip_api_wrapper_check(self)) - { - sipWrapper *w = (sipWrapper *)self; - - if (sipCppHasRef(w)) - { - sipResetCppHasRef(w); - Py_DECREF(w); - } - else - removeFromParent(w); - - sipSetPyOwned(w); - } -} - - -/* - * Transfer ownership of a class instance to C/C++ from Python. - */ -static void sip_api_transfer_to(PyObject *self, PyObject *owner) -{ - /* - * There is a legitimate case where we try to transfer a PyObject that - * may not be a SIP generated class. The virtual handler code calls - * this function to keep the C/C++ instance alive when it gets rid of - * the Python object returned by the Python method. A class may have - * handwritten code that converts a regular Python type - so we can't - * assume that we can simply cast to sipWrapper. - */ - if (self != NULL && sip_api_wrapper_check(self) && (owner == NULL || sip_api_wrapper_check(owner))) - { - sipWrapper *w = (sipWrapper *)self; - - /* - * Keep the object alive while we do the transfer. If C++ has a - * reference then there is no need to increment it, just reset the flag - * and the following decrement will bring everything back to the way it - * should be. - */ - if (sipCppHasRef(w)) - sipResetCppHasRef(w); - else - { - Py_INCREF(self); - removeFromParent(w); - } - - addToParent(w, (sipWrapper *)owner); - - Py_DECREF(self); - - sipResetPyOwned(w); - } -} - - -/* - * Transfer ownership of a class instance from Python to C/C++, or vice versa. - * This is deprecated. - */ -static void sip_api_transfer(PyObject *self, int toCpp) -{ - if (toCpp) - sip_api_transfer_to(self, self); - else - sip_api_transfer_back(self); -} - - -/* - * Add a license to a dictionary. - */ -static int addLicense(PyObject *dict,sipLicenseDef *lc) -{ - int rc; - PyObject *ldict, *proxy, *o; - - /* Convert the strings we use to objects if not already done. */ - - if (licenseName == NULL && (licenseName = PyString_FromString("__license__")) == NULL) - return -1; - - if (licenseeName == NULL && (licenseeName = PyString_FromString("Licensee")) == NULL) - return -1; - - if (typeName == NULL && (typeName = PyString_FromString("Type")) == NULL) - return -1; - - if (timestampName == NULL && (timestampName = PyString_FromString("Timestamp")) == NULL) - return -1; - - if (signatureName == NULL && (signatureName = PyString_FromString("Signature")) == NULL) - return -1; - - /* We use a dictionary to hold the license information. */ - if ((ldict = PyDict_New()) == NULL) - return -1; - - /* The license type is compulsory, the rest are optional. */ - if (lc->lc_type == NULL || (o = PyString_FromString(lc->lc_type)) == NULL) - goto deldict; - - rc = PyDict_SetItem(ldict,typeName,o); - Py_DECREF(o); - - if (rc < 0) - goto deldict; - - if (lc->lc_licensee != NULL) - { - if ((o = PyString_FromString(lc->lc_licensee)) == NULL) - goto deldict; - - rc = PyDict_SetItem(ldict,licenseeName,o); - Py_DECREF(o); - - if (rc < 0) - goto deldict; - } - - if (lc->lc_timestamp != NULL) - { - if ((o = PyString_FromString(lc->lc_timestamp)) == NULL) - goto deldict; - - rc = PyDict_SetItem(ldict,timestampName,o); - Py_DECREF(o); - - if (rc < 0) - goto deldict; - } - - if (lc->lc_signature != NULL) - { - if ((o = PyString_FromString(lc->lc_signature)) == NULL) - goto deldict; - - rc = PyDict_SetItem(ldict,signatureName,o); - Py_DECREF(o); - - if (rc < 0) - goto deldict; - } - - /* Create a read-only proxy. */ - if ((proxy = PyDictProxy_New(ldict)) == NULL) - goto deldict; - - Py_DECREF(ldict); - - rc = PyDict_SetItem(dict,licenseName,proxy); - Py_DECREF(proxy); - - return rc; - -deldict: - Py_DECREF(ldict); - - return -1; -} - - -/* - * Add the void pointer instances to a dictionary. - */ -static int addVoidPtrInstances(PyObject *dict,sipVoidPtrInstanceDef *vi) -{ - while (vi->vi_name != NULL) - { - int rc; - PyObject *w; - - if ((w = sip_api_convert_from_void_ptr(vi->vi_val)) == NULL) - return -1; - - rc = PyDict_SetItemString(dict,vi->vi_name,w); - Py_DECREF(w); - - if (rc < 0) - return -1; - - ++vi; - } - - return 0; -} - - -/* - * Add the char instances to a dictionary. - */ -static int addCharInstances(PyObject *dict,sipCharInstanceDef *ci) -{ - while (ci->ci_name != NULL) - { - int rc; - PyObject *w; - - if ((w = PyString_FromStringAndSize(&ci->ci_val,1)) == NULL) - return -1; - - rc = PyDict_SetItemString(dict,ci->ci_name,w); - Py_DECREF(w); - - if (rc < 0) - return -1; - - ++ci; - } - - return 0; -} - - -/* - * Add the string instances to a dictionary. - */ -static int addStringInstances(PyObject *dict,sipStringInstanceDef *si) -{ - while (si->si_name != NULL) - { - int rc; - PyObject *w; - - if ((w = PyString_FromString(si->si_val)) == NULL) - return -1; - - rc = PyDict_SetItemString(dict,si->si_name,w); - Py_DECREF(w); - - if (rc < 0) - return -1; - - ++si; - } - - return 0; -} - - -/* - * Add the int instances to a dictionary. - */ -static int addIntInstances(PyObject *dict, sipIntInstanceDef *ii) -{ - while (ii->ii_name != NULL) - { - int rc; - PyObject *w; - - if ((w = PyInt_FromLong(ii->ii_val)) == NULL) - return -1; - - rc = PyDict_SetItemString(dict, ii->ii_name, w); - Py_DECREF(w); - - if (rc < 0) - return -1; - - ++ii; - } - - return 0; -} - - -/* - * Add the long instances to a dictionary. - */ -static int addLongInstances(PyObject *dict,sipLongInstanceDef *li) -{ - while (li->li_name != NULL) - { - int rc; - PyObject *w; - - if ((w = PyLong_FromLong(li->li_val)) == NULL) - return -1; - - rc = PyDict_SetItemString(dict,li->li_name,w); - Py_DECREF(w); - - if (rc < 0) - return -1; - - ++li; - } - - return 0; -} - - -/* - * Add the unsigned long instances to a dictionary. - */ -static int addUnsignedLongInstances(PyObject *dict, sipUnsignedLongInstanceDef *uli) -{ - while (uli->uli_name != NULL) - { - int rc; - PyObject *w; - - if ((w = PyLong_FromUnsignedLong(uli->uli_val)) == NULL) - return -1; - - rc = PyDict_SetItemString(dict, uli->uli_name, w); - Py_DECREF(w); - - if (rc < 0) - return -1; - - ++uli; - } - - return 0; -} - - -/* - * Add the long long instances to a dictionary. - */ -static int addLongLongInstances(PyObject *dict, sipLongLongInstanceDef *lli) -{ - while (lli->lli_name != NULL) - { - int rc; - PyObject *w; - -#if defined(HAVE_LONG_LONG) - if ((w = PyLong_FromLongLong(lli->lli_val)) == NULL) -#else - if ((w = PyLong_FromLong(lli->lli_val)) == NULL) -#endif - return -1; - - rc = PyDict_SetItemString(dict, lli->lli_name, w); - Py_DECREF(w); - - if (rc < 0) - return -1; - - ++lli; - } - - return 0; -} - - -/* - * Add the unsigned long long instances to a dictionary. - */ -static int addUnsignedLongLongInstances(PyObject *dict, sipUnsignedLongLongInstanceDef *ulli) -{ - while (ulli->ulli_name != NULL) - { - int rc; - PyObject *w; - -#if defined(HAVE_LONG_LONG) - if ((w = PyLong_FromUnsignedLongLong(ulli->ulli_val)) == NULL) -#else - if ((w = PyLong_FromUnsignedLong(ulli->ulli_val)) == NULL) -#endif - return -1; - - rc = PyDict_SetItemString(dict, ulli->ulli_name, w); - Py_DECREF(w); - - if (rc < 0) - return -1; - - ++ulli; - } - - return 0; -} - - -/* - * Add the double instances to a dictionary. - */ -static int addDoubleInstances(PyObject *dict,sipDoubleInstanceDef *di) -{ - while (di->di_name != NULL) - { - int rc; - PyObject *w; - - if ((w = PyFloat_FromDouble(di->di_val)) == NULL) - return -1; - - rc = PyDict_SetItemString(dict,di->di_name,w); - Py_DECREF(w); - - if (rc < 0) - return -1; - - ++di; - } - - return 0; -} - - -/* - * Wrap a set of enum instances and add them to a dictionary. - */ -static int addEnumInstances(PyObject *dict, sipEnumInstanceDef *ei) -{ - while (ei->ei_name != NULL) - { - if (addSingleEnumInstance(dict, ei->ei_name, ei->ei_val, *ei->ei_type) < 0) - return -1; - - ++ei; - } - - return 0; -} - - -/* - * Wrap a single enum instance and add it to a dictionary. - */ -static int addSingleEnumInstance(PyObject *dict, const char *name, int value, - PyTypeObject *type) -{ - int rc; - PyObject *w; - - if ((w = sip_api_convert_from_named_enum(value, type)) == NULL) - return -1; - - rc = PyDict_SetItemString(dict, name, w); - Py_DECREF(w); - - return rc; -} - - -/* - * Wrap an enum instance and add it to a dictionary. - */ -static int sip_api_add_enum_instance(PyObject *dict, const char *name, - int value, PyTypeObject *type) -{ - /* If this is a wrapped type then get the type dictionary. */ - if (sipWrapperType_Check(dict)) - dict = ((PyTypeObject *)dict)->tp_dict; - - return addSingleEnumInstance(dict, name, value, type); -} - - -/* - * Wrap a set of class instances and add them to a dictionary. - */ -static int addClassInstances(PyObject *dict, sipClassInstanceDef *ci) -{ - while (ci->ci_name != NULL) - { - if (addSingleClassInstance(dict, ci->ci_name, ci->ci_ptr, *ci->ci_type, ci->ci_flags) < 0) - return -1; - - ++ci; - } - - return 0; -} - - -/* - * Wrap a single class instance and add it to a dictionary. - */ -static int addSingleClassInstance(PyObject *dict, const char *name, - void *cppPtr, sipWrapperType *wt, int initflags) -{ - int rc; - PyObject *w; - - if ((w = sipWrapSimpleInstance(cppPtr,wt,NULL,initflags)) == NULL) - return -1; - - rc = PyDict_SetItemString(dict,name,w); - Py_DECREF(w); - - return rc; -} - - -/* - * Wrap a class instance and add it to a dictionary. - */ -static int sip_api_add_class_instance(PyObject *dict, const char *name, - void *cppPtr, sipWrapperType *wt) -{ - /* If this is a wrapped type then get the type dictionary. */ - if (sipWrapperType_Check(dict)) - dict = ((PyTypeObject *)dict)->tp_dict; - - return addSingleClassInstance(dict, name, cppPtr, wt, 0); -} - - -/* - * Wrap a mapped type instance and add it to a dictionary. - */ -static int sip_api_add_mapped_type_instance(PyObject *dict, const char *name, - void *cppPtr, const sipMappedType *mt) -{ - int rc; - PyObject *w; - - /* If this is a wrapped type then get the type dictionary. */ - if (sipWrapperType_Check(dict)) - dict = ((PyTypeObject *)dict)->tp_dict; - - if ((w = mt->mt_cfrom(cppPtr, NULL)) == NULL) - return -1; - - rc = PyDict_SetItemString(dict, name, w); - Py_DECREF(w); - - return rc; -} - - -/* - * Get the C/C++ pointer for a complex object. - */ -static void *sip_api_get_complex_cpp_ptr(sipWrapper *w) -{ - if (!sipIsDerived(w)) - { - PyErr_SetString(PyExc_RuntimeError,"no access to protected functions or signals for objects not created from Python"); - - return NULL; - } - - if (checkPointer(w->u.cppPtr) < 0) - return NULL; - - return w->u.cppPtr; -} - - -/* - * Return the Python member function corresponding to a C/C++ virtual function, - * if any. If one was found then the Python lock is acquired. - */ -static PyObject *sip_api_is_py_method(sip_gilstate_t *gil,sipMethodCache *pymc, - sipWrapper *sipSelf,char *cname, - char *mname) -{ - /* We might still have C++ going after the interpreter has gone. */ - if (sipInterpreter == NULL) - return NULL; - - /* - * It's possible that the Python object has been deleted but the - * underlying (complex) C/C++ instance is still working and trying to - * handle virtual functions. Or an instance has started handling - * virtual functions before its ctor has returned. In either case say - * there is no Python method. - */ - if (sipSelf == NULL) - return NULL; - -#ifdef WITH_THREAD - *gil = PyGILState_Ensure(); -#endif - - /* See if we have already looked for the Python method. */ - if (!sipFoundMethod(pymc)) - { - PyObject *methobj; - - /* - * Using PyMethod_Check() rather than PyCallable_Check() has - * the added benefits of ensuring the (common) case of there - * being no Python method is handled as a direct call to C/C++ - * (rather than converted to Python and then back to C/C++) and - * makes sure that abstract virtuals are trapped. - */ - if ((methobj = PyObject_GetAttrString((PyObject *)sipSelf,mname)) != NULL) - { - if (PyMethod_Check(methobj)) - { - sipSetIsMethod(pymc); - sipSaveMethod(&pymc->pyMethod,methobj); - } - - Py_DECREF(methobj); - } - - PyErr_Clear(); - - sipSetFoundMethod(pymc); - } - else if (sipIsMethod(pymc)) - PyErr_Clear(); - - if (sipIsMethod(pymc)) - return PyMethod_New(pymc->pyMethod.mfunc,pymc->pyMethod.mself,pymc->pyMethod.mclass); - - if (cname != NULL) - PyErr_Format(PyExc_NotImplementedError,"%s.%s() is abstract and must be overridden",cname,mname); - -#ifdef WITH_THREAD - PyGILState_Release(*gil); -#endif - - return NULL; -} - - -/* - * Convert a C/C++ pointer to the object that wraps it. - */ -static PyObject *sip_api_get_wrapper(void *cppPtr,sipWrapperType *type) -{ - return (PyObject *)sipOMFindObject(&cppPyMap,cppPtr,type); -} - - -/* - * Return the C/C++ pointer from a wrapper without any checks. - */ -void *sipGetAddress(sipWrapper *w) -{ - if (sipIsAccessFunc(w)) - return (*w->u.afPtr)(); - - if (sipIsIndirect(w)) - return *((void **)w->u.cppPtr); - - return w->u.cppPtr; -} - - -/* - * Get the C/C++ pointer from a wrapper and optionally cast it to the required - * type. - */ -void *sip_api_get_cpp_ptr(sipWrapper *w,sipWrapperType *type) -{ - void *ptr = sipGetAddress(w); - - if (checkPointer(ptr) < 0) - return NULL; - - if (type != NULL) - ptr = cast_cpp_ptr(ptr, (sipWrapperType *)w->ob_type, type); - - return ptr; -} - - -/* - * Cast a C/C++ pointer from a source type to a destination type. - */ -static void *cast_cpp_ptr(void *ptr, sipWrapperType *src_type, - sipWrapperType *dst_type) -{ - sipCastFunc cast = src_type->type->td_cast; - - /* C structures don't have cast functions. */ - if (cast != NULL) - ptr = (*cast)(ptr, dst_type); - - return ptr; -} - - -/* - * Check that a pointer is non-NULL. - */ -static int checkPointer(void *ptr) -{ - if (ptr == NULL) - { - PyErr_SetString(PyExc_RuntimeError,"underlying C/C++ object has been deleted"); - return -1; - } - - return 0; -} - - -/* - * Check to see if a Python object can be converted to a wrapped type. - */ -static int sip_api_can_convert_to_instance(PyObject *pyObj, - sipWrapperType *type, int flags) -{ - int ok; - sipConvertToFunc cto = type->type->td_cto; - - /* None is handled outside the type checkers. */ - if (pyObj == Py_None) - ok = ((flags & SIP_NOT_NONE) == 0); - else if (cto == NULL || (flags & SIP_NO_CONVERTORS) != 0) - ok = PyObject_TypeCheck(pyObj, (PyTypeObject *)type); - else - ok = cto(pyObj, NULL, NULL, NULL); - - return ok; -} - - -/* - * Check to see if a Python object can be converted to a mapped type. - */ -static int sip_api_can_convert_to_mapped_type(PyObject *pyObj, - const sipMappedType *mt, - int flags) -{ - int ok; - - /* None is handled outside the type checkers. */ - if (pyObj == Py_None) - ok = ((flags & SIP_NOT_NONE) == 0); - else - ok = mt->mt_cto(pyObj, NULL, NULL, NULL); - - return ok; -} - - -/* - * Convert a Python object to a C/C++ pointer, assuming a previous call to - * sip_api_can_convert_to_instance() has been successful. Allow ownership to - * be transferred and any type convertors to be disabled. - */ -static void *sip_api_convert_to_instance(PyObject *pyObj, sipWrapperType *type, - PyObject *transferObj, int flags, - int *statep, int *iserrp) -{ - void *cpp = NULL; - int state = 0; - sipConvertToFunc cto = type->type->td_cto; - - /* Don't convert if there has already been an error. */ - if (!*iserrp) - { - /* Do the conversion. */ - if (pyObj == Py_None) - cpp = NULL; - else if (cto == NULL || (flags & SIP_NO_CONVERTORS) != 0) - { - if ((cpp = sip_api_get_cpp_ptr((sipWrapper *)pyObj, type)) == NULL) - *iserrp = TRUE; - else if (transferObj != NULL) - if (transferObj == Py_None) - sip_api_transfer_back(pyObj); - else - sip_api_transfer_to(pyObj, transferObj); - } - else - state = cto(pyObj, &cpp, iserrp, transferObj); - } - - if (statep != NULL) - *statep = state; - - return cpp; -} - - -/* - * Convert a Python object to a C/C++ pointer, assuming a previous call to - * sip_api_can_convert_to_mapped_type() has been successful. Allow ownership - * to be transferred. - */ -static void *sip_api_convert_to_mapped_type(PyObject *pyObj, - const sipMappedType *mt, - PyObject *transferObj, int flags, - int *statep, int *iserrp) -{ - void *cpp = NULL; - int state = 0; - - /* Don't convert if there has already been an error. */ - if (!*iserrp) - if (pyObj == Py_None) - cpp = NULL; - else - state = mt->mt_cto(pyObj, &cpp, iserrp, transferObj); - - if (statep != NULL) - *statep = state; - - return cpp; -} - - -/* - * Convert a Python object to a C/C++ pointer and raise an exception if it - * can't be done. - */ -static void *sip_api_force_convert_to_instance(PyObject *pyObj, - sipWrapperType *type, - PyObject *transferObj, - int flags, int *statep, - int *iserrp) -{ - /* Don't even try if there has already been an error. */ - if (*iserrp) - return NULL; - - /* See if the object's type can be converted. */ - if (!sip_api_can_convert_to_instance(pyObj, type, flags)) - { - PyErr_Format(PyExc_TypeError, "%s cannot be converted to %s in this context", pyObj->ob_type->tp_name, type->type->td_name); - - if (statep != NULL) - *statep = 0; - - *iserrp = TRUE; - return NULL; - } - - /* Do the conversion. */ - return sip_api_convert_to_instance(pyObj, type, transferObj, flags, statep, iserrp); -} - - -/* - * Convert a Python object to a C/C++ pointer and raise an exception if it - * can't be done. - */ -static void *sip_api_force_convert_to_mapped_type(PyObject *pyObj, - const sipMappedType *mt, - PyObject *transferObj, - int flags, int *statep, - int *iserrp) -{ - /* Don't even try if there has already been an error. */ - if (*iserrp) - return NULL; - - /* See if the object's type can be converted. */ - if (!sip_api_can_convert_to_mapped_type(pyObj, mt, flags)) - { - PyErr_Format(PyExc_TypeError, "%s cannot be converted to %s in this context", pyObj->ob_type->tp_name, mt->mt_name); - - if (statep != NULL) - *statep = 0; - - *iserrp = TRUE; - return NULL; - } - - /* Do the conversion. */ - return sip_api_convert_to_mapped_type(pyObj, mt, transferObj, flags, statep, iserrp); -} - - -/* - * Release a possibly temporary instance created by a type convertor. - */ -static void sip_api_release_instance(void *cpp, sipWrapperType *type, int state) -{ - /* See if there is something to release. */ - if (state & SIP_TEMPORARY) - release(cpp, type->type, state); -} - - -/* - * Release an instance. - */ -static void release(void *addr, sipTypeDef *td, int state) -{ - sipReleaseFunc rel = td->td_release; - - /* - * If there is no release function then it must be a C structure and we can - * just free it. - */ - if (rel == NULL) - sip_api_free(addr); - else - rel(addr, state); -} - - -/* - * Release a possibly temporary mapped type created by a type convertor. - */ -static void sip_api_release_mapped_type(void *cpp, const sipMappedType *mt, - int state) -{ - /* See if there is something to release. */ - if (state & SIP_TEMPORARY) - { - sipReleaseFunc rel = mt->mt_release; - - /* - * If there is no release function then it must be a C - * structure and we can just free it. - */ - if (rel == NULL) - sip_api_free(cpp); - else - rel(cpp, state); - } -} - - -/* - * Convert a C/C++ instance to a Python instance. - */ -PyObject *sip_api_convert_from_instance(void *cpp, sipWrapperType *type, - PyObject *transferObj) -{ - PyObject *py; - - /* Handle None. */ - if (cpp == NULL) - { - Py_INCREF(Py_None); - return Py_None; - } - - /* Apply any sub-class convertor. */ - if (sipTypeHasSCC(type)) - type = convertSubClass(type, &cpp); - - /* See if we have already wrapped it. */ - if ((py = sip_api_get_wrapper(cpp, type)) != NULL) - Py_INCREF(py); - else if ((py = sipWrapSimpleInstance(cpp, type, NULL, SIP_SHARE_MAP)) == NULL) - return NULL; - - /* Handle any ownership transfer. */ - if (transferObj != NULL) - if (transferObj == Py_None) - sip_api_transfer_back(py); - else - sip_api_transfer_to(py, transferObj); - - return py; -} - - -/* - * Convert a new C/C++ instance to a Python instance. - */ -static PyObject *sip_api_convert_from_new_instance(void *cpp, - sipWrapperType *type, - PyObject *transferObj) -{ - sipWrapper *owner; - - /* Handle None. */ - if (cpp == NULL) - { - Py_INCREF(Py_None); - return Py_None; - } - - /* Apply any sub-class convertor. */ - if (sipTypeHasSCC(type)) - type = convertSubClass(type, &cpp); - - /* Handle any ownership transfer. */ - if (transferObj != NULL && transferObj != Py_None) - owner = (sipWrapper *)transferObj; - else - owner = NULL; - - return sipWrapSimpleInstance(cpp, type, owner, (owner == NULL ? SIP_PY_OWNED : 0)); -} - - -/* - * Convert a C/C++ instance implemented as a mapped type to a Python object. - */ -static PyObject *sip_api_convert_from_mapped_type(void *cpp, - const sipMappedType *mt, - PyObject *transferObj) -{ - /* Handle None. */ - if (cpp == NULL) - { - Py_INCREF(Py_None); - return Py_None; - } - - return mt->mt_cfrom(cpp, transferObj); -} - - -/* - * Convert a Python instance of a class to a C/C++ object pointer, checking - * that the instance's class is derived from a given base type. - */ -static void *sip_api_convert_to_cpp(PyObject *sipSelf,sipWrapperType *type, - int *iserrp) -{ - return sip_api_convert_to_instance(sipSelf, type, NULL, SIP_NO_CONVERTORS, NULL, iserrp); -} - - -/* - * Implement the normal transfer policy for the result of %ConvertToTypeCode, - * ie. it is temporary unless it is being transferred from Python. - */ -int sip_api_get_state(PyObject *transferObj) -{ - return (transferObj == NULL || transferObj == Py_None) ? SIP_TEMPORARY : 0; -} - - -/* - * Return the mapped type structure for a particular mapped type. - */ -static const sipMappedType *sip_api_find_mapped_type(const char *type) -{ - sipExportedModuleDef *em; - - for (em = clientList; em != NULL; em = em->em_next) - { - sipMappedType **mtypes, *mt; - - if ((mtypes = em->em_mappedtypes) == NULL) - continue; - - while ((mt = *mtypes++) != NULL) - { - const char *s1 = mt->mt_name, *s2 = type; - - /* - * Compare while ignoring spaces so that we don't impose a rigorous - * naming standard. - */ - do - { - while (*s1 == ' ') - ++s1; - - while (*s2 == ' ') - ++s2; - - if (*s1 == '\0' && *s2 == '\0') - return mt; - } - while (*s1++ == *s2++); - } - } - - return NULL; -} - - -/* - * Return the type structure for a particular class. - */ -static sipWrapperType *sip_api_find_class(const char *type) -{ - sipExportedModuleDef *em; - size_t type_len = strlen(type); - - for (em = clientList; em != NULL; em = em->em_next) - { - sipWrapperType *wt = findClass(em, type, type_len); - - if (wt != NULL) - return wt; - } - - return NULL; -} - - -/* - * Return the type structure for a particular named enum. - */ -static PyTypeObject *sip_api_find_named_enum(const char *type) -{ - sipExportedModuleDef *em; - size_t type_len = strlen(type); - - for (em = clientList; em != NULL; em = em->em_next) - { - PyTypeObject *py = findEnum(em, type, type_len); - - if (py != NULL) - return py; - } - - return NULL; -} - - -/* - * Save the components of a Python method. - */ -void sipSaveMethod(sipPyMethod *pm,PyObject *meth) -{ - pm->mfunc = PyMethod_GET_FUNCTION(meth); - pm->mself = PyMethod_GET_SELF(meth); - pm->mclass = PyMethod_GET_CLASS(meth); -} - - -/* - * Call a hook. - */ -static void sip_api_call_hook(const char *hookname) -{ - PyObject *dictofmods, *mod, *dict, *hook, *res; - - /* Get the dictionary of modules. */ - if ((dictofmods = PyImport_GetModuleDict()) == NULL) - return; - - /* Get the __builtin__ module. */ - if ((mod = PyDict_GetItemString(dictofmods,"__builtin__")) == NULL) - return; - - /* Get it's dictionary. */ - if ((dict = PyModule_GetDict(mod)) == NULL) - return; - - /* Get the function hook. */ - if ((hook = PyDict_GetItemString(dict,hookname)) == NULL) - return; - - /* Call the hook and discard any result. */ - res = PyObject_CallObject(hook,NULL); - - Py_XDECREF(res); -} - - -/* - * Call any sub-class convertors for a given type returning a pointer to the - * sub-type object, and possibly modifying the C++ address (in the case of - * multiple inheritence). - */ -static sipWrapperType *convertSubClass(sipWrapperType *type, void **cppPtr) -{ - sipExportedModuleDef *em; - - if (*cppPtr == NULL) - return NULL; - - /* - * Note that this code depends on the fact that a module appears in the - * list of modules before any module it imports, ie. sub-class convertors - * will be invoked for more specific types first. - */ - for (em = clientList; em != NULL; em = em->em_next) - { - sipSubClassConvertorDef *scc; - - if ((scc = em->em_convertors) == NULL) - continue; - - while (scc->scc_convertor != NULL) - { - /* - * The base type is the "root" class that may have a number of - * convertors each handling a "branch" of the derived tree of - * classes. The "root" normally implements the base function that - * provides the RTTI used by the convertors and is re-implemented - * by derived classes. We therefore see if the target type is a - * sub-class of the root, ie. see if the convertor might be able to - * convert the target type to something more specific. - */ - if (PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)scc->scc_basetype)) - { - void *ptr; - sipWrapperType *subtype; - - ptr = cast_cpp_ptr(*cppPtr, type, scc->scc_basetype); - subtype = (*scc->scc_convertor)(&ptr); - - /* - * We are only interested in types that are not super-classes - * of the target. This happens either because it is in an - * earlier convertor than the one that handles the type or it - * is in a later convertor that handles a different branch of - * the hierarchy. Either way, the ordering of the modules - * ensures that there will be no more than one and that it will - * be the right one. - */ - if (subtype != NULL && !PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)subtype)) - { - *cppPtr = ptr; - return subtype; - } - } - - ++scc; - } - } - - /* - * We haven't found the exact type, so return the most specific type that - * it must be. This can happen legitimately if the wrapped library is - * returning an internal class that is down-cast to a more generic class. - * Also we want this function to be safe when a class doesn't have any - * convertors. - */ - return type; -} - - -/* - * The bsearch() helper function for searching a sorted string map table. - */ -static int compareStringMapEntry(const void *key,const void *el) -{ - return strcmp((const char *)key,((const sipStringTypeClassMap *)el)->typeString); -} - - -/* - * A convenience function for %ConvertToSubClassCode for types represented as a - * string. Returns the Python class object or NULL if the type wasn't - * recognised. - */ -static sipWrapperType *sip_api_map_string_to_class(const char *typeString, - const sipStringTypeClassMap *map, - int maplen) -{ - sipStringTypeClassMap *me; - - me = (sipStringTypeClassMap *)bsearch((const void *)typeString, - (const void *)map,maplen, - sizeof (sipStringTypeClassMap), - compareStringMapEntry); - - return ((me != NULL) ? *me->pyType : NULL); -} - - -/* - * The bsearch() helper function for searching a sorted integer map table. - */ -static int compareIntMapEntry(const void *keyp,const void *el) -{ - int key = *(int *)keyp; - - if (key > ((const sipIntTypeClassMap *)el)->typeInt) - return 1; - - if (key < ((const sipIntTypeClassMap *)el)->typeInt) - return -1; - - return 0; -} - - -/* - * A convenience function for %ConvertToSubClassCode for types represented as - * an integer. Returns the Python class object or NULL if the type wasn't - * recognised. - */ -static sipWrapperType *sip_api_map_int_to_class(int typeInt, - const sipIntTypeClassMap *map, - int maplen) -{ - sipIntTypeClassMap *me; - - me = (sipIntTypeClassMap *)bsearch((const void *)&typeInt, - (const void *)map,maplen, - sizeof (sipIntTypeClassMap), - compareIntMapEntry); - - return ((me != NULL) ? *me->pyType : NULL); -} - - -/* - * Raise an unknown exception. Make no assumptions about the GIL. - */ -static void sip_api_raise_unknown_exception(void) -{ - static PyObject *mobj = NULL; - - SIP_BLOCK_THREADS - - if (mobj == NULL) - mobj = PyString_FromString("unknown"); - - PyErr_SetObject(PyExc_Exception, mobj); - - SIP_UNBLOCK_THREADS -} - - -/* - * Raise an exception implemented as a class. Make no assumptions about the - * GIL. - */ -static void sip_api_raise_class_exception(sipWrapperType *type,void *ptr) -{ - PyObject *self; - - SIP_BLOCK_THREADS - - self = sipWrapSimpleInstance(ptr,type,NULL,SIP_PY_OWNED); - - PyErr_SetObject((PyObject *)type,self); - - Py_XDECREF(self); - - SIP_UNBLOCK_THREADS -} - - -/* - * Raise an exception implemented as a class or sub-class. Make no assumptions - * about the GIL. - */ -static void sip_api_raise_sub_class_exception(sipWrapperType *type,void *ptr) -{ - PyObject *self; - - SIP_BLOCK_THREADS - - self = sipWrapSimpleInstance(ptr,type,NULL,SIP_PY_OWNED); - - PyErr_SetObject((PyObject *)type,self); - - Py_XDECREF(self); - - SIP_UNBLOCK_THREADS -} - - -/* - * Return the module of an encoded class. - */ -static sipExportedModuleDef *getClassModule(sipEncodedClassDef *enc, - sipExportedModuleDef *em) -{ - if (enc->sc_module != 255) - em = em->em_imports[enc->sc_module].im_module; - - return em; -} - - -/* - * Return the type of an encoded class. - */ -static sipWrapperType *getClassType(sipEncodedClassDef *enc, - sipExportedModuleDef *em) -{ - return getClassModule(enc, em)->em_types[enc->sc_class]; -} - - -/* - * Find a particular slot function for a wrapper. - */ -static void *findSlot(PyObject *self,sipPySlotType st) -{ - sipTypeDef *td = ((sipWrapperType *)(self->ob_type))->type; - sipEncodedClassDef *sup; - void *slot; - - /* Check the immediate type. */ - if ((slot = findSlotInType(td, st)) != NULL) - return slot; - - /* Check the super-types, if there are any. */ - if ((sup = td->td_supers) != NULL) - do - if ((slot = findSlotInType(getClassType(sup, td->td_module)->type, st)) != NULL) - return slot; - while (!sup++->sc_flag); - - /* This should never happen. */ - return NULL; -} - - -/* - * Find a particular slot function in a type. - */ -static void *findSlotInType(sipTypeDef *td, sipPySlotType st) -{ - sipPySlotDef *psd; - - if ((psd = td->td_pyslots) != NULL) - while (psd->psd_func != NULL) - { - if (psd->psd_type == st) - return psd->psd_func; - - ++psd; - } - - return NULL; -} - - -/* - * Return the C/C++ address and the basic type information for a wrapper. - */ -static void *getPtrTypeDef(sipWrapper *self, sipTypeDef **td) -{ - *td = ((sipWrapperType *)self->ob_type)->type; - - return (sipNotInMap(self) ? NULL : self->u.cppPtr); -} - - -/* - * Handle an objobjargproc slot. - */ -static int objobjargprocSlot(PyObject *self,PyObject *arg1,PyObject *arg2, - sipPySlotType st) -{ - int (*f)(PyObject *,PyObject *); - PyObject *args; - int res; - - /* - * Slot handlers require a single PyObject *. The second argument is - * optional. - */ - if (arg2 == NULL) - args = arg1; - else if (PyTuple_Check(arg1)) - { - int i; - - /* - * It's already a tuple so we need to copy it and append the - * value. - */ - if ((args = PyTuple_New(PyTuple_GET_SIZE(arg1) + 1)) == NULL) - return -1; - - for (i = 0; i < PyTuple_GET_SIZE(arg1); ++i) - { - PyObject *o = PyTuple_GET_ITEM(arg1,i); - - PyTuple_SET_ITEM(args,i,o); - Py_INCREF(o); - } - - PyTuple_SET_ITEM(args,i,arg2); - Py_INCREF(arg2); - } - else if ((args = Py_BuildValue("(OO)",arg1,arg2)) == NULL) - return -1; - - f = (int (*)(PyObject *,PyObject *))findSlot(self,st); - - res = f(self,args); - - if (arg2 != NULL) - { - Py_DECREF(args); - } - - return res; -} - - -/* - * Handle an ssizeobjargproc slot. - */ -static int ssizeobjargprocSlot(PyObject *self, SIP_SSIZE_T arg1, - PyObject *arg2, sipPySlotType st) -{ - int (*f)(PyObject *,PyObject *); - PyObject *args; - int res; - - /* - * Slot handlers require a single PyObject *. The second argument is - * optional. - */ - if (arg2 == NULL) -#if PY_VERSION_HEX >= 0x02050000 - args = PyInt_FromSsize_t(arg1); -#else - args = PyInt_FromLong(arg1); -#endif - else -#if PY_VERSION_HEX >= 0x02050000 - args = Py_BuildValue("(nO)", arg1, arg2); -#else - args = Py_BuildValue("(iO)", arg1, arg2); -#endif - - if (args == NULL) - return -1; - - f = (int (*)(PyObject *,PyObject *))findSlot(self,st); - - res = f(self,args); - - Py_DECREF(args); - - return res; -} - - -/***************************************************************************** - * The functions, data types and structures to support a Python type to hold a - * void * that can be converted to an integer. - *****************************************************************************/ - -/* The object data structure. */ -typedef struct { - PyObject_HEAD - void *voidptr; -} sipVoidPtr; - - -/* - * Implement __new__ for the type. - */ -static PyObject *sipVoidPtr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) -{ - PyObject *obj; - void *ptr; - int nargs, bad; - - /* We don't support keyword arguments. */ - if (kwds != NULL) - { - PyErr_SetString(PyExc_TypeError, "keyword arguments are not supported"); - return NULL; - } - - /* Get the single argument. */ - if ((nargs = PyTuple_Size(args)) < 0) - return NULL; - - bad = FALSE; - - if (nargs == 1) - { - PyObject *arg = PyTuple_GET_ITEM(args, 0); - - if (arg == Py_None) - ptr = NULL; - else if (PyCObject_Check(arg)) - ptr = PyCObject_AsVoidPtr(arg); - else if (arg->ob_type == &sipVoidPtr_Type) - { - /* - * The type is immutable so just return the argument. - */ - Py_INCREF(arg); - return arg; - } - else - { - ptr = (void *)PyInt_AsLong(arg); - - if (PyErr_Occurred()) - bad = TRUE; - } - } - else - bad = TRUE; - - if (bad) - { - PyErr_SetString(PyExc_TypeError, "a single integer, CObject, None or another voidptr is required"); - return NULL; - } - - /* Create the instance. */ - if ((obj = subtype->tp_alloc(subtype, 0)) == NULL) - return NULL; - - /* Save the pointer. */ - ((sipVoidPtr *)obj)->voidptr = ptr; - - return obj; -} - - -/* - * Implement int() for the type. - */ -static PyObject *sipVoidPtr_int(sipVoidPtr *v) -{ - return PyInt_FromLong((long)v->voidptr); -} - - -/* - * Implement hex() for the type. - */ -static PyObject *sipVoidPtr_hex(sipVoidPtr *v) -{ - char buf[2 + 16 + 1]; - - PyOS_snprintf(buf, sizeof (buf), "0x%.*lx", (int)(sizeof (void *) * 2), (unsigned long)v->voidptr); - - return PyString_FromString(buf); -} - - -/* - * Implement ascobject() for the type. - */ -static PyObject *sipVoidPtr_ascobject(sipVoidPtr *v, PyObject *arg) -{ - return PyCObject_FromVoidPtr(v->voidptr, NULL); -} - - -/* - * Implement asstring() for the type. - */ -static PyObject *sipVoidPtr_asstring(sipVoidPtr *v,PyObject *arg) -{ - long nbytes = PyInt_AsLong(arg); - - if (PyErr_Occurred()) - return NULL; - - return PyString_FromStringAndSize(v->voidptr,nbytes); -} - - -/* The methods data structure. */ -static PyMethodDef sipVoidPtr_Methods[] = { - {"ascobject", (PyCFunction)sipVoidPtr_ascobject, METH_NOARGS, NULL}, - {"asstring", (PyCFunction)sipVoidPtr_asstring, METH_O, NULL}, - {NULL} -}; - - -/* The number methods data structure. */ -PyNumberMethods sipVoidPtr_NumberMethods = { - 0, /* nb_add */ - 0, /* nb_subtract */ - 0, /* nb_multiply */ - 0, /* nb_divide */ - 0, /* nb_remainder */ - 0, /* nb_divmod */ - 0, /* nb_power */ - 0, /* nb_negative */ - 0, /* nb_positive */ - 0, /* nb_absolute */ - 0, /* nb_nonzero */ - 0, /* nb_invert */ - 0, /* nb_lshift */ - 0, /* nb_rshift */ - 0, /* nb_and */ - 0, /* nb_xor */ - 0, /* nb_or */ - 0, /* nb_coerce */ - (unaryfunc)sipVoidPtr_int, /* nb_int */ - 0, /* nb_long */ - 0, /* nb_float */ - 0, /* nb_oct */ - (unaryfunc)sipVoidPtr_hex, /* nb_hex */ -}; - - -/* The type data structure. */ -static PyTypeObject sipVoidPtr_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "sip.voidptr", /* tp_name */ - sizeof (sipVoidPtr), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - &sipVoidPtr_NumberMethods, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - 0, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - sipVoidPtr_Methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - sipVoidPtr_new, /* tp_new */ -}; - - -/* - * A convenience function to convert a C/C++ void pointer from a Python object. - */ -static void *sip_api_convert_to_void_ptr(PyObject *obj) -{ - if (obj == NULL) - { - PyErr_SetString(PyExc_TypeError,"sip.voidptr is NULL"); - return NULL; - } - - if (obj == Py_None) - return NULL; - - /* Save a conversion if it's not a sub-type. */ - if (obj->ob_type == &sipVoidPtr_Type) - return ((sipVoidPtr *)obj)->voidptr; - - return (void *)PyInt_AsLong(obj); -} - - -/* - * A convenience function to convert a C/C++ void pointer to a Python object. - */ -PyObject *sip_api_convert_from_void_ptr(void *val) -{ - sipVoidPtr *self; - - if (val == NULL) - { - Py_INCREF(Py_None); - return Py_None; - } - - if ((self = PyObject_NEW(sipVoidPtr,&sipVoidPtr_Type)) == NULL) - return NULL; - - self->voidptr = val; - - return (PyObject *)self; -} - - -/* - * Return TRUE if a type is a wrapped type, rather than a sub-type implemented - * in Python or the super-type. - */ -static int isExactWrappedType(sipWrapperType *wt) -{ - char *name; - - /* - * We check by comparing the actual type name with the name used to create - * the original wrapped type. - */ -#if PY_VERSION_HEX >= 0x02050000 - if ((name = PyString_AsString(wt->super.ht_name)) == NULL) -#else - if ((name = PyString_AsString(wt->super.name)) == NULL) -#endif - return FALSE; - - return (strcmp(name, getBaseName(wt->type->td_name)) == 0); -} - - -/***************************************************************************** - * The Python metatype for a C++ wrapper type. - *****************************************************************************/ - -/* - * The type alloc slot. - */ -static PyObject *sipWrapperType_alloc(PyTypeObject *self, SIP_SSIZE_T nitems) -{ - PyObject *o; - - /* Call the standard super-metatype alloc. */ - if ((o = PyType_Type.tp_alloc(self, nitems)) == NULL) - return NULL; - - /* - * Consume any extra type specific information and use it to initialise - * the slots. This only happens for directly wrapped classes (and not - * programmer written sub-classes). This must be done in the alloc - * function because it is the only place we can break out of the - * default new() function before PyType_Ready() is called. - */ - if (currentType != NULL) - { - ((sipWrapperType *)o)->type = currentType; - addSlots((sipWrapperType *)o, currentType); - currentType = NULL; - } - - return o; -} - - -/* - * The type init slot. - */ -static int sipWrapperType_init(sipWrapperType *self, PyObject *args, - PyObject *kwds) -{ - /* Call the standard super-metatype init. */ - if (PyType_Type.tp_init((PyObject *)self, args, kwds) < 0) - return -1; - - /* - * If we don't yet have any extra type specific information (because we are - * a programmer defined sub-class) then get it from the (first) super-type. - */ - if (self->type == NULL) - { - PyTypeObject *sc = ((PyTypeObject *)self)->tp_base; - - /* - * Make sure that the type is derived from sip.wrapper. It might not - * if the type specifies sip.wrappertype as the __metaclass__. - */ - if (sc == NULL || !sipWrapperType_Check((PyObject *)sc)) - { - PyErr_Format(PyExc_TypeError, - "type %s must be derived from sip.wrapper", - ((PyTypeObject *)self)->tp_name); - - return -1; - } - - self->type = ((sipWrapperType *)sc)->type; - } - - return 0; -} - - -/* - * The type getattro slot. - */ -static PyObject *sipWrapperType_getattro(PyObject *obj,PyObject *name) -{ - char *nm; - PyObject *attr; - sipWrapperType *wt = (sipWrapperType *)obj; - - /* - * If we are getting the type dictionary for a base wrapped type then we - * don't want the super-metatype to handle it. - */ - if ((nm = PyString_AsString(name)) == NULL) - return NULL; - - if (strcmp(nm, "__dict__") == 0) - { - int i; - sipTypeDef *td; - sipEnumMemberDef *enm; - PyObject *dict; - PyMethodDef *pmd; - - dict = ((PyTypeObject *)wt)->tp_dict; - - /* The base type doesn't have any type information. */ - if ((td = wt->type) == NULL || !isExactWrappedType(wt)) - { - Py_INCREF(dict); - return dict; - } - - /* - * We can't cache the methods or variables so we need to make a - * temporary copy of the type dictionary and return that (so - * that it will get garbage collected immediately afterwards). - */ - if ((dict = PyDict_Copy(dict)) == NULL) - return NULL; - - /* Search the possible linked list of namespace extenders. */ - do - { - /* - * Add the type's lazy enums. It doesn't matter if - * they are already there. - */ - enm = td->td_enummembers; - - for (i = 0; i < td->td_nrenummembers; ++i) - { - int rc; - PyObject *val; - - if ((val = createEnumMember(td, enm)) == NULL) - return NULL; - - rc = PyDict_SetItemString(dict, enm->em_name, val); - - Py_DECREF(val); - - if (rc < 0) - return NULL; - - ++enm; - } - - /* Do the methods. */ - pmd = td->td_methods; - - for (i = 0; i < td->td_nrmethods; ++i) - { - int rc; - PyObject *meth; - - if ((meth = PyCFunction_New(pmd, NULL)) == NULL) - { - Py_DECREF(dict); - return NULL; - } - - rc = PyDict_SetItemString(dict, pmd->ml_name, meth); - - Py_DECREF(meth); - - if (rc < 0) - { - Py_DECREF(dict); - return NULL; - } - - ++pmd; - } - - /* Do the static variables. */ - if ((pmd = td->td_variables) != NULL) - while (pmd->ml_name != NULL) - { - if ((pmd->ml_flags & METH_STATIC) != 0) - { - int rc; - PyObject *val; - - if ((val = (*pmd->ml_meth)(NULL, NULL)) == NULL) - { - Py_DECREF(dict); - return NULL; - } - - rc = PyDict_SetItemString(dict, pmd->ml_name, val); - - Py_DECREF(val); - - if (rc < 0) - { - Py_DECREF(dict); - return NULL; - } - } - - ++pmd; - } - - td = td->td_nsextender; - } - while (td != NULL); - - return dict; - } - - /* Now try the super-metatype's method. */ - if ((attr = PyType_Type.tp_getattro(obj,name)) != NULL) - return attr; - - return handleGetLazyAttr(name,wt,NULL); -} - - -/* - * The type setattro slot. - */ -static int sipWrapperType_setattro(PyObject *obj,PyObject *name,PyObject *value) -{ - int rc; - - rc = handleSetLazyAttr(name,value,(sipWrapperType *)obj,NULL); - - if (rc <= 0) - return rc; - - /* Try the super-type's method last. */ - return PyType_Type.tp_setattro(obj,name,value); -} - - -/* - * The type data structure. We inherit everything from the standard Python - * metatype except the init and getattro methods and the size of the type - * object created is increased to accomodate the extra information we associate - * with a wrapped type. - */ -static PyTypeObject sipWrapperType_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "sip.wrappertype", /* tp_name */ - sizeof (sipWrapperType), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - sipWrapperType_getattro, /* tp_getattro */ - sipWrapperType_setattro, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - 0, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)sipWrapperType_init, /* tp_init */ - sipWrapperType_alloc, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ -}; - - -/***************************************************************************** - * The Python type that is the super-type for all C++ wrapper types. - *****************************************************************************/ - -/* - * The instance new slot. - */ -static PyObject *sipWrapper_new(sipWrapperType *wt,PyObject *args,PyObject *kwds) -{ - /* See if it is a namespace. */ - if (wt->type->td_fcto == NULL) - { - PyErr_Format(PyExc_TypeError, "%s represents a C++ namespace that cannot be instantiated", wt->type->td_name); - - return NULL; - } - - /* - * See if the object is being created explicitly rather than being wrapped. - */ - if (sipGetPending(NULL, NULL) == NULL) - { - /* - * See if it cannot be instantiated or sub-classed from Python, eg. - * it's an opaque class. Some restrictions might be overcome with - * better SIP support. - */ - if (wt->type->td_init == NULL) - { - PyErr_Format(PyExc_TypeError,"%s cannot be instantiated or sub-classed", wt->type->td_name); - - return NULL; - } - - /* See if it is an abstract type. */ - if (sipTypeIsAbstract(wt) && strcmp(strchr(wt->type->td_name, '.') + 1, ((PyTypeObject *)wt)->tp_name) == 0) - { - PyErr_Format(PyExc_TypeError, "%s represents a C++ abstract class and cannot be instantiated", wt->type->td_name); - - return NULL; - } - } - - /* Call the standard super-type new. */ - return PyBaseObject_Type.tp_new((PyTypeObject *)wt, args, kwds); -} - - -/* - * The instance init slot. - */ -static int sipWrapper_init(sipWrapper *self,PyObject *args,PyObject *kwds) -{ - void *sipNew; - int sipFlags; - sipWrapper *owner; - - if (self->ob_type == (PyTypeObject *)&sipWrapper_Type) - { - PyErr_SetString(PyExc_TypeError,"the sip.wrapper type cannot be instantiated"); - return -1; - } - - if (kwds != NULL) - { - PyErr_SetString(PyExc_TypeError,"keyword arguments are not supported"); - return -1; - } - - /* Check there is no existing C++ instance waiting to be wrapped. */ - if ((sipNew = sipGetPending(&owner, &sipFlags)) == NULL) - { - int argsparsed = 0; - sipWrapperType *wt = (sipWrapperType *)self->ob_type; - - /* Call the C++ ctor. */ - owner = NULL; - - if ((sipNew = wt->type->td_init(self, args, &owner, &argsparsed)) != NULL) - sipFlags = SIP_DERIVED_CLASS; - else - { - int pstate = argsparsed & PARSE_MASK; - sipInitExtenderDef *ie = wt->iextend; - - /* - * While we just have signature errors, try any initialiser - * extenders. - */ - while (ie != NULL && (pstate == PARSE_MANY || pstate == PARSE_FEW || pstate == PARSE_TYPE)) - { - argsparsed = 0; - - if ((sipNew = ie->ie_extender(self, args, &owner, &argsparsed)) != NULL) - break; - - pstate = argsparsed & PARSE_MASK; - ie = ie->ie_next; - } - - if (sipNew == NULL) - { - /* - * If the arguments were parsed without error then assume an - * exception has already been raised for why the instance - * wasn't created. - */ - if (pstate == PARSE_OK) - argsparsed = PARSE_RAISED; - - badArgs(argsparsed, NULL, getBaseName(wt->type->td_name)); - return -1; - } - - sipFlags = 0; - } - - if (owner == NULL) - sipFlags |= SIP_PY_OWNED; - } - - addToParent(self, owner); - - self->u.cppPtr = sipNew; - self->flags = sipFlags; - - if (!sipNotInMap(self)) - sipOMAddObject(&cppPyMap,self); - - return 0; -} - - -/* - * The instance traverse slot. - */ -static int sipWrapper_traverse(sipWrapper *self, visitproc visit, void *arg) -{ - int vret; - void *ptr; - sipTypeDef *td; - sipWrapper *w; - sipPySig *ps; - - /* Call the nearest handwritten traverse code in the class hierachy. */ - if ((ptr = getPtrTypeDef(self, &td)) != NULL) - { - sipTypeDef *ctd = td; - - if (td->td_traverse == NULL) - { - sipEncodedClassDef *sup; - - if ((sup = td->td_supers) != NULL) - do - ctd = getClassType(sup, td->td_module)->type; - while (ctd->td_traverse == NULL && !sup++->sc_flag); - } - - if (ctd->td_traverse != NULL) - if ((vret = ctd->td_traverse(ptr, visit, arg)) != 0) - return vret; - } - - if (qt_and_sip_api_3_4()) - { - void *tx = sipGetAddress(self); - - if (tx != NULL) - { - sipSlotConnection *conn; - void *context = NULL; - - while ((conn = sipQtSupport->qt_find_connection(tx, &context)) != NULL) - { - if ((vret = visitSlot(&conn->sc_slot, visit, arg)) != 0) - return vret; - - if (context == NULL) - break; - } - } - } - - for (ps = self->pySigList; ps != NULL; ps = ps->next) - { - sipSlotList *psrx; - - for (psrx = ps->rxlist; psrx != NULL; psrx = psrx->next) - if ((vret = visitSlot(&psrx->rx, visit, arg)) != 0) - return vret; - } - - if (self->user != NULL) - if ((vret = visit(self->user, arg)) != 0) - return vret; - - if (self->dict != NULL) - if ((vret = visit(self->dict, arg)) != 0) - return vret; - - for (w = self->first_child; w != NULL; w = w->sibling_next) - { - /* - * We don't traverse if the wrapper is a child of itself. We - * do this so that wrapped objects returned by virtual methods - * with the /Factory/ don't have those objects collected. This - * then means that plugins implemented in Python have a chance - * of working. - */ - if (w != self) - if ((vret = visit((PyObject *)w, arg)) != 0) - return vret; - } - - return 0; -} - - -/* - * The instance clear slot. - */ -static int sipWrapper_clear(sipWrapper *self) -{ - int vret = 0; - void *ptr; - sipTypeDef *td; - PyObject *tmp; - sipPySig *ps; - - /* Call the nearest handwritten clear code in the class hierachy. */ - if ((ptr = getPtrTypeDef(self, &td)) != NULL) - { - sipTypeDef *ctd = td; - - if (td->td_clear == NULL) - { - sipEncodedClassDef *sup; - - if ((sup = td->td_supers) != NULL) - do - ctd = getClassType(sup, td->td_module)->type; - while (ctd->td_clear == NULL && !sup++->sc_flag); - } - - if (ctd->td_clear != NULL) - vret = ctd->td_clear(ptr); - } - - /* Remove any lambda slots connected via a proxy. */ - if (qt_and_sip_api_3_4()) - { - void *tx = sipGetAddress(self); - - if (tx != NULL) - { - sipSlotConnection *conn; - void *context = NULL; - - while ((conn = sipQtSupport->qt_find_connection(tx, &context)) != NULL) - { - clearAnyLambda(&conn->sc_slot); - - if (context == NULL) - break; - } - } - } - - /* Remove any lambda slots connected to PyQt v3 Python signals. */ - for (ps = self->pySigList; ps != NULL; ps = ps->next) - { - sipSlotList *psrx; - - for (psrx = ps->rxlist; psrx != NULL; psrx = psrx->next) - clearAnyLambda(&psrx->rx); - } - - /* Remove any user object. */ - tmp = self->user; - self->user = NULL; - Py_XDECREF(tmp); - - /* Remove the instance dictionary. */ - tmp = self->dict; - self->dict = NULL; - Py_XDECREF(tmp); - - /* Detach children (which will be owned by C/C++. */ - while (self->first_child != NULL) - { - /* - * Although this object is being garbage collected it doesn't follow - * that it's children should be. So we make sure that the child stays - * alive and remember we have done so. - */ - Py_INCREF(self->first_child); - sipSetCppHasRef(self->first_child); - - removeFromParent(self->first_child); - } - - return vret; -} - - -/* - * The instance read buffer slot. - */ -static SIP_SSIZE_T sipWrapper_getreadbuffer(sipWrapper *self, - SIP_SSIZE_T segment, void **ptrptr) -{ - void *ptr; - sipTypeDef *td; - - if ((ptr = getPtrTypeDef(self, &td)) == NULL) - return -1; - - return td->td_readbuffer((PyObject *)self, ptr, segment, ptrptr); -} - - -/* - * The instance write buffer slot. - */ -static SIP_SSIZE_T sipWrapper_getwritebuffer(sipWrapper *self, - SIP_SSIZE_T segment, void **ptrptr) -{ - void *ptr; - sipTypeDef *td; - - if ((ptr = getPtrTypeDef(self, &td)) == NULL) - return -1; - - return td->td_writebuffer((PyObject *)self, ptr, segment, ptrptr); -} - - -/* - * The instance segment count slot. - */ -static SIP_SSIZE_T sipWrapper_getsegcount(sipWrapper *self, SIP_SSIZE_T *lenp) -{ - void *ptr; - sipTypeDef *td; - - if ((ptr = getPtrTypeDef(self, &td)) == NULL) - return 0; - - return td->td_segcount((PyObject *)self, ptr, lenp); -} - - -/* - * The instance char buffer slot. - */ -static SIP_SSIZE_T sipWrapper_getcharbuffer(sipWrapper *self, - SIP_SSIZE_T segment, void **ptrptr) -{ - void *ptr; - sipTypeDef *td; - - if ((ptr = getPtrTypeDef(self, &td)) == NULL) - return -1; - - return td->td_charbuffer((PyObject *)self, ptr, segment, ptrptr); -} - - -/* - * The instance dealloc slot. - */ -static void sipWrapper_dealloc(sipWrapper *self) -{ - sipTypeDef *td; - - if (getPtrTypeDef(self, &td) != NULL) - { - /* - * Remove the object from the map before calling the class specific - * dealloc code. This code calls the C++ dtor and may result in - * further calls that pass the instance as an argument. If this is - * still in the map then it's reference count would be increased (to - * one) and bad things happen when it drops back to zero again. (An - * example is PyQt events generated during the dtor call being passed - * to an event filter implemented in Python.) By removing it from the - * map first we ensure that a new Python object is created. - */ - sipOMRemoveObject(&cppPyMap, self); - - /* Call the C++ dtor if there is one. */ - if (td->td_dealloc != NULL) - td->td_dealloc(self); - } - - /* - * Now that the C++ object no longer exists we can tidy up the Python - * object. We used to do this first but that meant lambda slots were - * removed too soon (if they were connected to TQObject.destroyed()). - */ - sipWrapper_clear(self); - - while (self->pySigList != NULL) - { - sipPySig *ps; - sipSlotList *psrx; - - /* Take this one out of the list. */ - ps = self->pySigList; - self->pySigList = ps->next; - - while ((psrx = ps->rxlist) != NULL) - { - ps->rxlist = psrx->next; - sipFreeSlotList(psrx); - } - - sip_api_free(ps->name); - sip_api_free(ps); - } - - /* Call the standard super-type dealloc. */ - PyBaseObject_Type.tp_dealloc((PyObject *)self); -} - - -/* - * The instance call slot. Note that keyword arguments aren't supported. - */ -static PyObject *sipWrapper_call(PyObject *self,PyObject *args,PyObject *kw) -{ - PyObject *(*f)(PyObject *,PyObject *); - - f = (PyObject *(*)(PyObject *,PyObject *))findSlot(self,call_slot); - - return f(self,args); -} - - -/* - * The sequence instance item slot. - */ -static PyObject *sipWrapper_sq_item(PyObject *self, SIP_SSIZE_T n) -{ - PyObject *(*f)(PyObject *,PyObject *); - PyObject *arg, *res; - -#if PY_VERSION_HEX >= 0x02050000 - if ((arg = PyInt_FromSsize_t(n)) == NULL) -#else - if ((arg = PyInt_FromLong(n)) == NULL) -#endif - return NULL; - - f = (PyObject *(*)(PyObject *,PyObject *))findSlot(self,getitem_slot); - - res = f(self,arg); - - Py_DECREF(arg); - - return res; -} - - -/* - * The mapping instance assign subscript slot. - */ -static int sipWrapper_mp_ass_subscript(PyObject *self,PyObject *key, - PyObject *value) -{ - return objobjargprocSlot(self,key,value,(value != NULL ? setitem_slot : delitem_slot)); -} - - -/* - * The sequence instance assign item slot. - */ -static int sipWrapper_sq_ass_item(PyObject *self, SIP_SSIZE_T i, PyObject *o) -{ - return ssizeobjargprocSlot(self, i, o, (o != NULL ? setitem_slot : delitem_slot)); -} - - -/* - * The instance rich compare slot. - */ -static PyObject *sipWrapper_richcompare(PyObject *self,PyObject *arg,int op) -{ - PyObject *(*f)(PyObject *,PyObject *); - sipPySlotType st; - - /* Convert the operation to a slot type. */ - switch (op) - { - case Py_LT: - st = lt_slot; - break; - - case Py_LE: - st = le_slot; - break; - - case Py_EQ: - st = eq_slot; - break; - - case Py_NE: - st = ne_slot; - break; - - case Py_GT: - st = gt_slot; - break; - - case Py_GE: - st = ge_slot; - break; - } - - /* It might not exist if not all the above have been implemented. */ - if ((f = (PyObject *(*)(PyObject *,PyObject *))findSlot(self,st)) == NULL) - { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - - return f(self,arg); -} - - -/* - * The instance getattro slot. - */ -static PyObject *sipWrapper_getattro(PyObject *obj,PyObject *name) -{ - char *nm; - PyObject *attr; - sipWrapperType *wt = (sipWrapperType *)obj->ob_type; - sipWrapper *w = (sipWrapper *)obj; - - /* - * If we are getting the instance dictionary of a base wrapper type - * then we don't want the metatype to handle it. - */ - if ((nm = PyString_AsString(name)) == NULL) - return NULL; - - if (strcmp(nm, "__dict__") == 0) - { - PyObject *tmpdict = NULL; - - if (isExactWrappedType(wt) && getNonStaticVariables(wt, w, &tmpdict) < 0) - { - Py_XDECREF(tmpdict); - return NULL; - } - - /* - * If a copy of the instance dictionary wasn't created then - * just return the original. Note that Python doesn't want a - * proxy. - */ - if (tmpdict == NULL) - if ((tmpdict = w->dict) == NULL) - tmpdict = PyDict_New(); - else - Py_INCREF(tmpdict); - - return tmpdict; - } - - /* Try the super-type's method first. */ - if ((attr = PyBaseObject_Type.tp_getattro(obj,name)) != NULL) - return attr; - - return handleGetLazyAttr(name,wt,w); -} - - -/* - * Add the values of all non-static variables to a dictionary (first making a - * copy of the dictionary if needed). - */ -static int getNonStaticVariables(sipWrapperType *wt,sipWrapper *w, - PyObject **ndict) -{ - PyMethodDef *pmd; - - if ((pmd = wt->type->td_variables) != NULL) - while (pmd->ml_name != NULL) - { - if ((pmd->ml_flags & METH_STATIC) == 0) - { - int rc; - PyObject *val, *dict; - - /* - * Create a copy of the original dictionary if - * it hasn't already been done. - */ - if ((dict = *ndict) == NULL) - { - if ((dict = PyDict_Copy(w->dict)) == NULL) - return -1; - - *ndict = dict; - } - - if ((val = (*pmd->ml_meth)((PyObject *)w,NULL)) == NULL) - return -1; - - rc = PyDict_SetItemString(dict,pmd->ml_name,val); - - Py_DECREF(val); - - if (rc < 0) - return -1; - } - - ++pmd; - } - - return 0; -} - - -/* - * The instance setattro slot. - */ -static int sipWrapper_setattro(PyObject *obj,PyObject *name,PyObject *value) -{ - int rc; - - rc = handleSetLazyAttr(name,value,(sipWrapperType *)obj->ob_type,(sipWrapper *)obj); - - if (rc <= 0) - return rc; - - /* Try the super-type's method last. */ - return PyBaseObject_Type.tp_setattro(obj,name,value); -} - - -/* - * The type data structure. Note that we pretend to be a mapping object and a - * sequence object at the same time. Python will choose one over another, - * depending on the context, but we implement as much as we can and don't make - * assumptions about which Python will choose. - */ -static sipWrapperType sipWrapper_Type = { - { - { - PyObject_HEAD_INIT(&sipWrapperType_Type) - 0, /* ob_size */ - "sip.wrapper", /* tp_name */ - sizeof (sipWrapper), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)sipWrapper_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - sipWrapper_getattro, /* tp_getattro */ - sipWrapper_setattro, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - 0, /* tp_doc */ - (traverseproc)sipWrapper_traverse, /* tp_traverse */ - (inquiry)sipWrapper_clear, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - offsetof(sipWrapper,dict), /* tp_dictoffset */ - (initproc)sipWrapper_init, /* tp_init */ - 0, /* tp_alloc */ - (newfunc)sipWrapper_new, /* tp_new */ - 0, /* tp_free */ - }, - }, - 0, - 0 -}; - - -/* - * Add the slots for a type and all its super-types. - */ -static void addSlots(sipWrapperType *wt, sipTypeDef *td) -{ - sipEncodedClassDef *sup; - - /* Add the buffer interface. */ - if (td->td_readbuffer != NULL) -#if PY_VERSION_HEX >= 0x02050000 - wt->super.as_buffer.bf_getreadbuffer = (readbufferproc)sipWrapper_getreadbuffer; -#else - wt->super.as_buffer.bf_getreadbuffer = (getreadbufferproc)sipWrapper_getreadbuffer; -#endif - - if (td->td_writebuffer != NULL) -#if PY_VERSION_HEX >= 0x02050000 - wt->super.as_buffer.bf_getwritebuffer = (writebufferproc)sipWrapper_getwritebuffer; -#else - wt->super.as_buffer.bf_getwritebuffer = (getwritebufferproc)sipWrapper_getwritebuffer; -#endif - - if (td->td_segcount != NULL) -#if PY_VERSION_HEX >= 0x02050000 - wt->super.as_buffer.bf_getsegcount = (segcountproc)sipWrapper_getsegcount; -#else - wt->super.as_buffer.bf_getsegcount = (getsegcountproc)sipWrapper_getsegcount; -#endif - - if (td->td_charbuffer != NULL) -#if PY_VERSION_HEX >= 0x02050000 - wt->super.as_buffer.bf_getcharbuffer = (charbufferproc)sipWrapper_getcharbuffer; -#else - wt->super.as_buffer.bf_getcharbuffer = (getcharbufferproc)sipWrapper_getcharbuffer; -#endif - - /* Add the slots for this type. */ - if (td->td_pyslots != NULL) - initSlots((PyTypeObject *)wt, &wt->super.as_number, &wt->super.as_sequence, &wt->super.as_mapping, td->td_pyslots, FALSE); - - /* Recurse through any super-types. */ - if ((sup = td->td_supers) != NULL) - do - addSlots(wt, getClassType(sup, td->td_module)->type); - while (!sup++->sc_flag); -} - - -/* - * Add the slot handler for each slot present in the type, optionally replacing - * any that have already been defined. - */ -static void initSlots(PyTypeObject *to, PyNumberMethods *nb, PySequenceMethods *sq, PyMappingMethods *mp, sipPySlotDef *slots, int force) -{ - void *f; - - while ((f = slots->psd_func) != NULL) - switch (slots++->psd_type) - { - case str_slot: - if (force || to->tp_str == NULL) - to->tp_str = (reprfunc)f; - break; - - case int_slot: - if (nb != NULL) - if (force || nb->nb_int == NULL) - nb->nb_int = (unaryfunc)f; - break; - - case long_slot: - if (nb != NULL) - if (force || nb->nb_long == NULL) - nb->nb_long = (unaryfunc)f; - break; - - case float_slot: - if (nb != NULL) - if (force || nb->nb_float == NULL) - nb->nb_float = (unaryfunc)f; - break; - - case len_slot: - if (mp != NULL) - if (force || mp->mp_length == NULL) -#if PY_VERSION_HEX >= 0x02050000 - mp->mp_length = (lenfunc)f; -#else - mp->mp_length = (inquiry)f; -#endif - if (sq != NULL) - if (force || sq->sq_length == NULL) -#if PY_VERSION_HEX >= 0x02050000 - sq->sq_length = (lenfunc)f; -#else - sq->sq_length = (inquiry)f; -#endif - break; - - case contains_slot: - if (sq != NULL) - if (force || sq->sq_contains == NULL) - sq->sq_contains = (objobjproc)f; - break; - - case add_slot: - if (nb != NULL) - if (force || nb->nb_add == NULL) - nb->nb_add = (binaryfunc)f; - break; - - case concat_slot: - if (sq != NULL) - if (force || sq->sq_concat == NULL) - sq->sq_concat = (binaryfunc)f; - break; - - case sub_slot: - if (nb != NULL) - if (force || nb->nb_subtract == NULL) - nb->nb_subtract = (binaryfunc)f; - break; - - case mul_slot: - if (nb != NULL) - if (force || nb->nb_multiply == NULL) - nb->nb_multiply = (binaryfunc)f; - break; - - case repeat_slot: - if (sq != NULL) - if (force || sq->sq_repeat == NULL) -#if PY_VERSION_HEX >= 0x02050000 - sq->sq_repeat = (ssizeargfunc)f; -#else - sq->sq_repeat = (intargfunc)f; -#endif - break; - - case div_slot: - if (nb != NULL) - { - if (force || nb->nb_divide == NULL) - nb->nb_divide = (binaryfunc)f; - - if (force || nb->nb_true_divide == NULL) - nb->nb_true_divide = (binaryfunc)f; - } - break; - - case mod_slot: - if (nb != NULL) - if (force || nb->nb_remainder == NULL) - nb->nb_remainder = (binaryfunc)f; - break; - - case and_slot: - if (nb != NULL) - if (force || nb->nb_and == NULL) - nb->nb_and = (binaryfunc)f; - break; - - case or_slot: - if (nb != NULL) - if (force || nb->nb_or == NULL) - nb->nb_or = (binaryfunc)f; - break; - - case xor_slot: - if (nb != NULL) - if (force || nb->nb_xor == NULL) - nb->nb_xor = (binaryfunc)f; - break; - - case lshift_slot: - if (nb != NULL) - if (force || nb->nb_lshift == NULL) - nb->nb_lshift = (binaryfunc)f; - break; - - case rshift_slot: - if (nb != NULL) - if (force || nb->nb_rshift == NULL) - nb->nb_rshift = (binaryfunc)f; - break; - - case iadd_slot: - if (nb != NULL) - if (force || nb->nb_inplace_add == NULL) - nb->nb_inplace_add = (binaryfunc)f; - break; - - case iconcat_slot: - if (sq != NULL) - if (force || sq->sq_inplace_concat == NULL) - sq->sq_inplace_concat = (binaryfunc)f; - break; - - case isub_slot: - if (nb != NULL) - if (force || nb->nb_inplace_subtract == NULL) - nb->nb_inplace_subtract = (binaryfunc)f; - break; - - case imul_slot: - if (nb != NULL) - if (force || nb->nb_inplace_multiply == NULL) - nb->nb_inplace_multiply = (binaryfunc)f; - break; - - case irepeat_slot: - if (sq != NULL) - if (force || sq->sq_inplace_repeat == NULL) -#if PY_VERSION_HEX >= 0x02050000 - sq->sq_inplace_repeat = (ssizeargfunc)f; -#else - sq->sq_inplace_repeat = (intargfunc)f; -#endif - break; - - case idiv_slot: - if (nb != NULL) - { - if (force || nb->nb_inplace_divide == NULL) - nb->nb_inplace_divide = (binaryfunc)f; - - if (force || nb->nb_inplace_true_divide == NULL) - nb->nb_inplace_true_divide = (binaryfunc)f; - } - break; - - case imod_slot: - if (nb != NULL) - if (force || nb->nb_inplace_remainder == NULL) - nb->nb_inplace_remainder = (binaryfunc)f; - break; - - case iand_slot: - if (nb != NULL) - if (force || nb->nb_inplace_and == NULL) - nb->nb_inplace_and = (binaryfunc)f; - break; - - case ior_slot: - if (nb != NULL) - if (force || nb->nb_inplace_or == NULL) - nb->nb_inplace_or = (binaryfunc)f; - break; - - case ixor_slot: - if (nb != NULL) - if (force || nb->nb_inplace_xor == NULL) - nb->nb_inplace_xor = (binaryfunc)f; - break; - - case ilshift_slot: - if (nb != NULL) - if (force || nb->nb_inplace_lshift == NULL) - nb->nb_inplace_lshift = (binaryfunc)f; - break; - - case irshift_slot: - if (nb != NULL) - if (force || nb->nb_inplace_rshift == NULL) - nb->nb_inplace_rshift = (binaryfunc)f; - break; - - case invert_slot: - if (nb != NULL) - if (force || nb->nb_invert == NULL) - nb->nb_invert = (unaryfunc)f; - break; - - case call_slot: - if (force || to->tp_call == NULL) - to->tp_call = sipWrapper_call; - break; - - case getitem_slot: - if (mp != NULL) - if (force || mp->mp_subscript == NULL) - mp->mp_subscript = (binaryfunc)f; - if (sq != NULL) - if (force || sq->sq_item == NULL) - sq->sq_item = sipWrapper_sq_item; - break; - - case setitem_slot: - case delitem_slot: - if (mp != NULL) - if (force || mp->mp_ass_subscript == NULL) - mp->mp_ass_subscript = sipWrapper_mp_ass_subscript; - if (sq != NULL) - if (force || sq->sq_ass_item == NULL) - sq->sq_ass_item = sipWrapper_sq_ass_item; - break; - - case lt_slot: - case le_slot: - case eq_slot: - case ne_slot: - case gt_slot: - case ge_slot: - if (force || to->tp_richcompare == NULL) - to->tp_richcompare = sipWrapper_richcompare; - break; - - case cmp_slot: - if (force || to->tp_compare == NULL) - to->tp_compare = (cmpfunc)f; - break; - - case nonzero_slot: - if (nb != NULL) - if (force || nb->nb_nonzero == NULL) - nb->nb_nonzero = (inquiry)f; - break; - - case neg_slot: - if (nb != NULL) - if (force || nb->nb_negative == NULL) - nb->nb_negative = (unaryfunc)f; - break; - - case repr_slot: - if (force || to->tp_repr == NULL) - to->tp_repr = (reprfunc)f; - break; - - case hash_slot: - if (force || to->tp_hash == NULL) - to->tp_hash = (hashfunc)f; - break; - - case pos_slot: - if (nb != NULL) - if (force || nb->nb_positive == NULL) - nb->nb_positive = (unaryfunc)f; - break; - - case abs_slot: - if (nb != NULL) - if (force || nb->nb_absolute == NULL) - nb->nb_absolute = (unaryfunc)f; - break; - } -} - - -/* - * Search for a named class and return the wrapper type. - */ -static sipWrapperType *findClass(sipExportedModuleDef *emd, const char *name, - size_t len) -{ - int i; - sipWrapperType **wtp = emd->em_types; - - for (i = 0; i < emd->em_nrtypes; ++i) - { - sipWrapperType *wt; - - if ((wt = *wtp++) == NULL) - continue; - - if (wt->type->td_cname != NULL) - { - if (!nameEq(wt->type->td_cname, name, len)) - continue; - } - else if (!sameScopedName(wt->type->td_name, name, len)) - continue; - - return wt; - } - - return NULL; -} - - -/* - * Search for a named class and return TRUE and the necessary information to - * create an instance of it if it was found. - */ -static int findClassArg(sipExportedModuleDef *emd, const char *name, - size_t len, sipSigArg *at, int indir) -{ - sipWrapperType *wt = findClass(emd, name, len); - - if (wt == NULL) - return FALSE; - - if (indir == 0) - at->atype = class_sat; - else if (indir == 1) - at->atype = classp_sat; - else - at->atype = unknown_sat; - - at->u.wt = wt; - - return TRUE; -} - - -/* - * Search for a mapped type and return TRUE and the necessary information to - * create an instance of it if it was found. - */ -static int findMtypeArg(sipMappedType **mttab, const char *name, size_t len, - sipSigArg *at, int indir) -{ - sipMappedType *mt; - - while ((mt = *mttab++) != NULL) - if (nameEq(mt->mt_name, name, len)) - { - if (indir == 0) - at->atype = mtype_sat; - else if (indir == 1) - at->atype = mtypep_sat; - else - at->atype = unknown_sat; - - at->u.mt = mt; - - return TRUE; - } - - return FALSE; -} - - -/* - * Search for a named enum in a particular module and return the corresponding - * type object. - */ -static PyTypeObject *findEnum(sipExportedModuleDef *emd, const char *name, - size_t len) -{ - int i; - sipEnumDef *ed; - - for (ed = emd->em_enumdefs, i = 0; i < emd->em_nrenums; ++i, ++ed) - { - if (ed->e_cname != NULL) - { - if (!nameEq(ed->e_cname, name, len)) - continue; - } - else if (!sameScopedName(ed->e_name, name, len)) - continue; - - return emd->em_enums[i]; - } - - return NULL; -} - - -/* - * Search for a named enum and return TRUE and the necessary information to - * create an instance of it if it was found. - */ -static int findEnumArg(sipExportedModuleDef *emd, const char *name, size_t len, - sipSigArg *at, int indir) -{ - PyTypeObject *py = findEnum(emd, name, len); - - if (py == NULL) - return FALSE; - - if (indir == 0) - at->atype = enum_sat; - else - at->atype = unknown_sat; - - at->u.et = py; - - return TRUE; -} - - -/* - * Search for a named type and the necessary information to create an instance - * of it. - */ -void sipFindSigArgType(const char *name, size_t len, sipSigArg *at, int indir) -{ - sipExportedModuleDef *em; - sipPyObject *po; - - at->atype = unknown_sat; - - for (em = clientList; em != NULL; em = em->em_next) - { - sipTypedefDef *tdd; - - /* Search for a typedef. */ - if ((tdd = em->em_typedefs) != NULL) - while (tdd->tdd_name != NULL) - { - if (nameEq(tdd->tdd_name, name, len)) - { - sipExportedModuleDef *tem; - const char *tn; - size_t tnlen; - - at->atype = tdd->tdd_type; - - /* Done with the simple cases. */ - if ((tn = tdd->tdd_type_name) == NULL) - return; - - /* - * Find the module that this class, mapped type or enum is - * defined in. - */ - if (tdd->tdd_mod_name == NULL) - tem = em; - else - for (tem = clientList; tem != NULL; tem = tem->em_next) - if (strcmp(tem->em_name, tdd->tdd_mod_name) == 0) - break; - - tnlen = strlen(tn); - - switch (tdd->tdd_type) - { - case class_sat: - findClassArg(tem, tn, tnlen, at, indir); - break; - - case mtype_sat: - findMtypeArg(tem->em_mappedtypes, tn, tnlen, at, indir); - break; - - case enum_sat: - findEnumArg(tem, tn, tnlen, at, indir); - break; - } - - /* We should have found it by now. */ - return; - } - - ++tdd; - } - - /* Search for a class. */ - if (em->em_types != NULL && findClassArg(em, name, len, at, indir)) - return; - - /* Search for a mapped type. */ - if (em->em_mappedtypes != NULL && findMtypeArg(em->em_mappedtypes, name, len, at, indir)) - return; - - /* Search for an enum. */ - if (em->em_enums != NULL && findEnumArg(em, name, len, at, indir)) - return; - } - - /* Search for a dynamically registered int type. */ - for (po = sipRegisteredIntTypes; po != NULL; po = po->next) - { - int i; - - for (i = 0; i < PyTuple_GET_SIZE(po->object); ++i) - { - char *int_nm = PyString_AsString(PyTuple_GET_ITEM(po->object, i)); - - if (int_nm == NULL) - continue; - - if (nameEq(int_nm, name, len)) - { - at->atype = int_sat; - return; - } - } - } -} - - -/* - * Compare a '\0' terminated string with the first len characters of a second - * and return a non-zero value if they are equal. - */ -static int nameEq(const char *with, const char *name, size_t len) -{ - return (strlen(with) == len && strncmp(with, name, len) == 0); -} - - -/* - * Return TRUE if a Python scoped name and a fixed length C++ scoped name - * match. - */ -static int sameScopedName(const char *pyname, const char *name, size_t len) -{ - char ch; - - /* Skip the module name from the Python name. */ - pyname = strchr(pyname, '.') + 1; - - while ((ch = *pyname++) != '\0' && len) - if (ch == '.') - { - if (len < 2 || name[0] != ':' || name[1] != ':') - return FALSE; - - name += 2; - len -= 2; - } - else if (ch == name[0]) - { - ++name; - --len; - } - else - return FALSE; - - return (ch == '\0' && len == 0); -} - - -/* - * Register a Python tuple of type names that will be interpreted as ints if - * they are seen as signal arguments. - */ -static int sip_api_register_int_types(PyObject *args) -{ - sipPyObject *po; - int bad_args = FALSE; - - /* Raise an exception if the arguments are bad. */ - if (PyTuple_Check(args)) - { - int i; - - for (i = 0; i < PyTuple_GET_SIZE(args); ++i) - if (!PyString_Check(PyTuple_GET_ITEM(args, i))) - { - bad_args = TRUE; - break; - } - } - else - bad_args = TRUE; - - if (bad_args) - { - PyErr_SetString(PyExc_TypeError, "all arguments must be strings"); - return -1; - } - - if ((po = sip_api_malloc(sizeof (sipPyObject))) == NULL) - return -1; - - Py_INCREF(args); - - po->object = args; - po->next = sipRegisteredIntTypes; - - sipRegisteredIntTypes = po; - - return 0; -} - - -/* - * Register a symbol with a name. A negative value is returned if the name was - * already registered. - */ -static int sip_api_export_symbol(const char *name, void *sym) -{ - sipSymbol *ss; - - if (sip_api_import_symbol(name) != NULL) - return -1; - - if ((ss = sip_api_malloc(sizeof (sipSymbol))) == NULL) - return -1; - - ss->name = name; - ss->symbol = sym; - ss->next = sipSymbolList; - - sipSymbolList = ss; - - return 0; -} - - -/* - * Return the symbol registered with the given name. NULL is returned if the - * name was not registered. - */ -static void *sip_api_import_symbol(const char *name) -{ - sipSymbol *ss; - - for (ss = sipSymbolList; ss != NULL; ss = ss->next) - if (strcmp(ss->name, name) == 0) - return ss->symbol; - - return NULL; -} - - -/* - * Returns TRUE if the Qt support is present and conforms to the v3.4 or later - * of the SIP API. - */ -static int qt_and_sip_api_3_4(void) -{ - return (sipQtSupport != NULL && sipQObjectClass->type->td_module->em_api_minor >= 4); -} - - -/* - * Visit a slot connected to an object for the cyclic garbage collector. - */ -static int visitSlot(sipSlot *slot, visitproc visit, void *arg) -{ - if (slot->pyobj != NULL && sipLambdaSlot(slot->pyobj)) - return visit(slot->pyobj, arg); - - return 0; -} - - -/* - * Clear a slot if it is a lambda function. - */ -static void clearAnyLambda(sipSlot *slot) -{ - PyObject *lam = slot->pyobj; - - if (lam != NULL && sipLambdaSlot(lam)) - { - /* - * Replace the lambda function with None. We don't use NULL as this - * has another meaning. - */ - Py_INCREF(Py_None); - slot->pyobj = Py_None; - - Py_DECREF(lam); - } -} - - -/* - * Convert a Python object to a character. - */ -static char sip_api_string_as_char(PyObject *obj) -{ - char ch; - - if (parseChar(obj, &ch) < 0) - { - PyErr_SetString(PyExc_ValueError, "string of length 1 expected"); - - return '\0'; - } - - return ch; -} - - -/* - * Parse a character array and return it's address and length. - */ -static int parseCharArray(PyObject *obj, char **ap, int *aszp) -{ - if (obj == Py_None) - { - *ap = NULL; - *aszp = 0; - } - else if (PyString_Check(obj)) - { - *ap = PyString_AS_STRING(obj); - *aszp = (int)PyString_GET_SIZE(obj); - } - else - return -1; - - return 0; -} - - -/* - * Parse a character and return it. - */ -static int parseChar(PyObject *obj, char *ap) -{ - if (!PyString_Check(obj) || PyString_GET_SIZE(obj) != 1) - return -1; - - *ap = *PyString_AS_STRING(obj); - - return 0; -} - - -/* - * Parse a character string and return it. - */ -static int parseCharString(PyObject *obj, char **ap) -{ - if (obj == Py_None) - *ap = NULL; - else if (PyString_Check(obj)) - *ap = PyString_AS_STRING(obj); - else - return -1; - - return 0; -} - - -#if defined(HAVE_WCHAR_H) -/* - * Convert a Python object to a wide character. - */ -static wchar_t sip_api_unicode_as_wchar(PyObject *obj) -{ - wchar_t ch; - - if (parseWChar(obj, &ch) < 0) - { - PyErr_SetString(PyExc_ValueError, "unicode string of length 1 expected"); - - return L'\0'; - } - - return ch; -} - - -/* - * Convert a Python object to a wide character string on the heap. - */ -static wchar_t *sip_api_unicode_as_wstring(PyObject *obj) -{ - wchar_t *p; - - if (parseWCharString(obj, &p) < 0) - { - PyErr_SetString(PyExc_ValueError, "unicode string expected"); - - return NULL; - } - - return p; -} - - -/* - * Parse a wide character array and return it's address and length. - */ -static int parseWCharArray(PyObject *obj, wchar_t **ap, int *aszp) -{ - if (obj == Py_None) - { - *ap = NULL; - *aszp = 0; - } - else if (PyUnicode_Check(obj)) - { - SIP_SSIZE_T ulen; - wchar_t *wc; - - ulen = PyUnicode_GET_SIZE(obj); - - if ((wc = sip_api_malloc(ulen * sizeof (wchar_t))) == NULL) - return -1; - - ulen = PyUnicode_AsWideChar((PyUnicodeObject *)obj, wc, ulen); - - if (ulen < 0) - { - sip_api_free(wc); - return -1; - } - - *ap = wc; - *aszp = (int)ulen; - } - else - return -1; - - return 0; -} - - -/* - * Parse a wide character and return it. - */ -static int parseWChar(PyObject *obj, wchar_t *ap) -{ - if (!PyUnicode_Check(obj) || PyUnicode_GET_SIZE(obj) != 1) - return -1; - - if (PyUnicode_AsWideChar((PyUnicodeObject *)obj, ap, 1) != 1) - return -1; - - return 0; -} - - -/* - * Parse a wide character string and return it. - */ -static int parseWCharString(PyObject *obj, wchar_t **ap) -{ - if (obj == Py_None) - *ap = NULL; - else if (PyUnicode_Check(obj)) - { - SIP_SSIZE_T ulen; - wchar_t *wc; - - ulen = PyUnicode_GET_SIZE(obj); - - if ((wc = sip_api_malloc((ulen + 1) * sizeof (wchar_t))) == NULL) - return -1; - - ulen = PyUnicode_AsWideChar((PyUnicodeObject *)obj, wc, ulen); - - if (ulen < 0) - { - sip_api_free(wc); - return -1; - } - - wc[ulen] = L'\0'; - - *ap = wc; - } - else - return -1; - - return 0; -} - -#else - -/* - * Convert a Python object to a wide character. - */ -static int sip_api_unicode_as_wchar(PyObject *obj) -{ - raiseNoWChar(); - - return 0; -} - - -/* - * Convert a Python object to a wide character. - */ -static int *sip_api_unicode_as_wstring(PyObject *obj) -{ - raiseNoWChar(); - - return NULL; -} - - -/* - * Report the need for absent wide character support. - */ -static void raiseNoWChar() -{ - PyErr_SetString(PyExc_SystemError, "sip built without wchar_t support"); -} - -#endif diff --git a/python/sip/siplib/siplib.sbf b/python/sip/siplib/siplib.sbf deleted file mode 100644 index 2499d1b8..00000000 --- a/python/sip/siplib/siplib.sbf +++ /dev/null @@ -1,16 +0,0 @@ -# This is the build file for the extension module. -# -# Copyright (c) 2007 -# Riverbank Computing Limited <info@riverbankcomputing.co.uk> -# -# This file is part of SIP. -# -# This copy of SIP is licensed for use under the terms of the SIP License -# Agreement. See the file LICENSE for more details. -# -# SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -target = sip -sources = siplib.c qtlib.c threads.c objmap.c bool.cpp -headers = sip.h sipint.h diff --git a/python/sip/siplib/threads.c b/python/sip/siplib/threads.c deleted file mode 100644 index c4ee75ff..00000000 --- a/python/sip/siplib/threads.c +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Thread support for the SIP library. This module provides the hooks for - * C++ classes that provide a thread interface to interact properly with the - * Python threading infrastructure. - * - * Copyright (c) 2007 - * Riverbank Computing Limited <info@riverbankcomputing.co.uk> - * - * This file is part of SIP. - * - * This copy of SIP is licensed for use under the terms of the SIP License - * Agreement. See the file LICENSE for more details. - * - * SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - - -#include "sip.h" -#include "sipint.h" - - -/* - * The data associated with pending request to wrap an object. - */ -typedef struct _pendingDef { - void *cpp; /* The C/C++ object ot be wrapped. */ - sipWrapper *owner; /* The owner of the object. */ - int flags; /* The flags. */ -} pendingDef; - - -#ifdef WITH_THREAD - -#include <pythread.h> - - -/* - * The per thread data we need to maintain. - */ -typedef struct _threadDef { - long thr_ident; /* The thread identifier. */ - pendingDef pending; /* An object waiting to be wrapped. */ - struct _threadDef *next; /* Next in the list. */ -} threadDef; - - -static threadDef *threads = NULL; /* Linked list of threads. */ - - -static threadDef *currentThreadDef(void); - -#endif - - -static pendingDef pending; /* An object waiting to be wrapped. */ - - -/* - * Get the address of any C/C++ object waiting to be wrapped. - */ -void *sipGetPending(sipWrapper **op, int *fp) -{ - pendingDef *pp; - -#ifdef WITH_THREAD - threadDef *td; - - if ((td = currentThreadDef()) != NULL) - pp = &td->pending; - else - pp = &pending; -#else - pp = &pending; -#endif - - if (pp->cpp != NULL) - { - if (op != NULL) - *op = pp->owner; - - if (fp != NULL) - *fp = pp->flags; - } - - return pp->cpp; -} - - -/* - * Convert a new C/C++ pointer to a Python instance. - */ -PyObject *sipWrapSimpleInstance(void *cppPtr, sipWrapperType *type, - sipWrapper *owner, int flags) -{ - static PyObject *nullargs = NULL; - - pendingDef old_pending; - PyObject *self; -#ifdef WITH_THREAD - threadDef *td; -#endif - - if (nullargs == NULL && (nullargs = PyTuple_New(0)) == NULL) - return NULL; - - if (cppPtr == NULL) - { - Py_INCREF(Py_None); - return Py_None; - } - - /* - * Object creation can trigger the Python garbage collector which in turn - * can execute arbitrary Python code which can then call this function - * recursively. Therefore we save any existing pending object before - * setting the new one. - */ -#ifdef WITH_THREAD - if ((td = currentThreadDef()) != NULL) - { - old_pending = td->pending; - - td->pending.cpp = cppPtr; - td->pending.owner = owner; - td->pending.flags = flags; - } - else - { - old_pending = pending; - - pending.cpp = cppPtr; - pending.owner = owner; - pending.flags = flags; - } -#else - old_pending = pending; - - pending.cpp = cppPtr; - pending.owner = owner; - pending.flags = flags; -#endif - - self = PyObject_Call((PyObject *)type, nullargs, NULL); - -#ifdef WITH_THREAD - if (td != NULL) - td->pending = old_pending; - else - pending = old_pending; -#else - pending = old_pending; -#endif - - return self; -} - - -/* - * This is called from a newly created thread to initialise some thread local - * storage. - */ -void sip_api_start_thread(void) -{ -#ifdef WITH_THREAD - threadDef *td; - - /* Save the thread ID. First, find an empty slot in the list. */ - for (td = threads; td != NULL; td = td->next) - if (td->thr_ident == 0) - break; - - if (td == NULL) - { - td = sip_api_malloc(sizeof (threadDef)); - td->next = threads; - threads = td; - } - - if (td != NULL) - { - td->thr_ident = PyThread_get_thread_ident(); - td->pending.cpp = NULL; - } -#endif -} - - -/* - * Handle the termination of a thread. The thread state should already have - * been handled by the last call to PyGILState_Release(). - */ -void sip_api_end_thread(void) -{ -#ifdef WITH_THREAD - threadDef *td; - - /* We have the GIL at this point. */ - if ((td = currentThreadDef()) != NULL) - td->thr_ident = 0; -#endif -} - - -#ifdef WITH_THREAD - -/* - * Return the thread data for the current thread or NULL if it wasn't - * recognised. - */ -static threadDef *currentThreadDef(void) -{ - threadDef *td; - long ident = PyThread_get_thread_ident(); - - for (td = threads; td != NULL; td = td->next) - if (td->thr_ident == ident) - break; - - return td; -} - -#endif diff --git a/python/sip/siputils.py b/python/sip/siputils.py deleted file mode 100644 index d4e596ca..00000000 --- a/python/sip/siputils.py +++ /dev/null @@ -1,2354 +0,0 @@ -# This module is intended to be used by the build/installation scripts of -# extension modules created with SIP. It provides information about file -# locations, version numbers etc., and provides some classes and functions. -# -# Copyright (c) 2007 -# Riverbank Computing Limited <info@riverbankcomputing.co.uk> -# -# This file is part of SIP. -# -# This copy of SIP is licensed for use under the terms of the SIP License -# Agreement. See the file LICENSE for more details. -# -# SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - -import sys -import os -import string -import types -import stat -import re - - -# These are installation specific values created when SIP was configured. -# @SIP_CONFIGURATION@ - -# The stack of configuration dictionaries. -_config_stack = [] - - -class Configuration(object): - """The class that represents SIP configuration values. - """ - def __init__(self, sub_cfg=None): - """Initialise an instance of the class. - - sub_cfg is the list of sub-class configurations. It should be None - when called normally. - """ - # Find the build macros in the closest imported module from where this - # was originally defined. - self._macros = None - - for cls in self.__class__.__mro__: - if cls is object: - continue - - mod = sys.modules[cls.__module__] - - if hasattr(mod, "_default_macros"): - self._macros = mod._default_macros - break - - if sub_cfg: - cfg = sub_cfg - else: - cfg = [] - - cfg.append(_pkg_config) - - global _config_stack - _config_stack = cfg - - def __getattr__(self, name): - """Allow configuration values and user options to be handled as - instance variables. - - name is the name of the configuration value or user option. - """ - for cfg in _config_stack: - try: - return cfg[name] - except KeyError: - pass - - raise AttributeError, "\"%s\" is not a valid configuration value or user option" % name - - def build_macros(self): - """Return the dictionary of platform specific build macros. - """ - return self._macros - - def set_build_macros(self, macros): - """Set the dictionary of build macros to be use when generating - Makefiles. - - macros is the dictionary of platform specific build macros. - """ - self._macros = macros - - -class _UniqueList: - """A limited list that ensures all its elements are unique. - """ - def __init__(self, value=None): - """Initialise the instance. - - value is the initial value of the list. - """ - if value is None: - self._list = [] - else: - self._list = value - - def append(self, value): - """Append a value to the list if it isn't already present. - - value is the value to append. - """ - if value not in self._list: - self._list.append(value) - - def lextend(self, value): - """A normal list extend ignoring the uniqueness. - - value is the list of elements to append. - """ - self._list.extend(value) - - def extend(self, value): - """Append each element of a value to a list if it isn't already - present. - - value is the list of elements to append. - """ - for el in value: - self.append(el) - - def as_list(self): - """Return the list as a raw list. - """ - return self._list - - -class _Macro: - """A macro that can be manipulated as a list. - """ - def __init__(self, name, value): - """Initialise the instance. - - name is the name of the macro. - value is the initial value of the macro. - """ - self._name = name - self.set(value) - - def set(self, value): - """Explicitly set the value of the macro. - - value is the new value. It may be a string, a list of strings or a - _UniqueList instance. - """ - self._macro = [] - - if isinstance(value, _UniqueList): - value = value.as_list() - - if type(value) == types.ListType: - self.extend(value) - else: - self.append(value) - - def append(self, value): - """Append a value to the macro. - - value is the value to append. - """ - if value: - self._macro.append(value) - - def extend(self, value): - """Append each element of a value to the macro. - - value is the list of elements to append. - """ - for el in value: - self.append(el) - - def as_list(self): - """Return the macro as a list. - """ - return self._macro - - -class Makefile: - """The base class for the different types of Makefiles. - """ - def __init__(self, configuration, console=0, qt=0, opengl=0, python=0, - threaded=0, warnings=1, debug=0, dir=None, - makefile="Makefile", installs=None, universal=''): - """Initialise an instance of the target. All the macros are left - unchanged allowing scripts to manipulate them at will. - - configuration is the current configuration. - console is set if the target is a console (rather than windows) target. - qt is set if the target uses Qt. For Qt v4 a list of Qt libraries may - be specified and a simple non-zero value implies QtCore and QtGui. - opengl is set if the target uses OpenGL. - python is set if the target #includes Python.h. - debug is set to generated a debugging version of the target. - threaded is set if the target requires thread support. It is - automatically set if the target uses Qt and Qt has thread support - enabled. - warnings is set if compiler warning messages are required. - debug is set if debugging symbols should be generated. - dir is the directory for build files and Makefiles. - makefile is the name of the Makefile. - installs is a list of extra install targets. Each element is a two - part list, the first of which is the source and the second is the - destination. If the source is another list then it is a set of source - files and the destination is a directory. - universal is the name of the SDK if the target is a MacOS/X universal - binary. - """ - if qt: - if not hasattr(configuration, "qt_version"): - error("The target uses Qt but pyqtconfig has not been imported.") - - # For Qt v4 interpret Qt support as meaning link against the core - # and GUI libraries (which corresponds to the default qmake - # configuration). Also allow a list of Qt v4 modules to be - # specified. - if configuration.qt_version >= 0x040000: - if type(qt) != types.ListType: - qt = ["QtCore", "QtGui"] - - self._threaded = configuration.qt_threaded - else: - self._threaded = threaded - - if sys.platform != "darwin": - universal = '' - - self.config = configuration - self.console = console - self._qt = qt - self._opengl = opengl - self._python = python - self._warnings = warnings - self._debug = debug - self._dir = dir - self._makefile = makefile - self._installs = installs - self._universal = universal - - self._finalised = 0 - - # Copy the macros and convert them all to instance lists. - macros = configuration.build_macros() - - for m in macros.keys(): - # Allow the user to override the default. - try: - val = getattr(configuration, m) - except AttributeError: - val = macros[m] - - # These require special handling as they are (potentially) a set of - # space separated values rather than a single value that might - # contain spaces. - if m in ("DEFINES", "CONFIG") or m[:6] in ("INCDIR", "LIBDIR"): - val = string.split(val) - - # We also want to treat lists of libraries in the same way so that - # duplicates get eliminated. - if m[:4] == "LIBS": - val = string.split(val) - - self.__dict__[m] = _Macro(m, val) - - # This is used to alter the configuration more significantly than can - # be done with just configuration files. - self.generator = self.optional_string("MAKEFILE_GENERATOR", "UNIX") - - # These are what configuration scripts normally only need to change. - self.extra_cflags = [] - self.extra_cxxflags = [] - self.extra_defines = [] - self.extra_include_dirs = [] - self.extra_lflags = [] - self.extra_lib_dirs = [] - self.extra_libs = [] - - # Get these once and make them available to sub-classes. - if sys.platform == "win32": - def_copy = "copy" - def_rm = "del" - def_mkdir = "mkdir" - def_chk_dir_exists = "if not exist" - else: - def_copy = "cp -f" - def_rm = "rm -f" - def_mkdir = "mkdir -p" - def_chk_dir_exists = "test -d" - - self.copy = self.optional_string("COPY", def_copy) - self.rm = self.optional_string("DEL_FILE", def_rm) - self.mkdir = self.optional_string("MKDIR", def_mkdir) - self.chkdir = self.optional_string("CHK_DIR_EXISTS", def_chk_dir_exists) - - - def finalise(self): - """Finalise the macros by doing any consolidation that isn't specific - to a Makefile. - """ - # Extract the things we might need from the Windows Qt configuration. - if self._qt: - wcfg = string.split(self.config.qt_winconfig) - win_shared = ("shared" in wcfg) - win_exceptions = ("exceptions" in wcfg) - win_rtti = ("rtti" in wcfg) - win_stl = ("stl" in wcfg) - else: - win_shared = 1 - win_exceptions = 0 - win_rtti = 0 - win_stl = 0 - - # Get what we are going to transform. - cflags = _UniqueList() - cflags.extend(self.extra_cflags) - cflags.extend(self.optional_list("CFLAGS")) - - cxxflags = _UniqueList() - cxxflags.extend(self.extra_cxxflags) - cxxflags.extend(self.optional_list("CXXFLAGS")) - - defines = _UniqueList() - defines.extend(self.extra_defines) - defines.extend(self.optional_list("DEFINES")) - - incdir = _UniqueList(["."]) - incdir.extend(self.extra_include_dirs) - incdir.extend(self.optional_list("INCDIR")) - - lflags = _UniqueList() - lflags.extend(self.extra_lflags) - lflags.extend(self.optional_list("LFLAGS")) - - libdir = _UniqueList() - libdir.extend(self.extra_lib_dirs) - libdir.extend(self.optional_list("LIBDIR")) - - # Handle MacOS/X universal binaries. - if self._universal: - unicflags = ('-arch ppc -arch i386 -isysroot %s' % self._universal).split() - unilflags = ('-arch ppc -arch i386 -Wl,-syslibroot,%s' % self._universal).split() - - cflags.lextend(unicflags) - cxxflags.lextend(unicflags) - lflags.lextend(unilflags) - - # Don't use a unique list as libraries may need to be searched more - # than once. Also MacOS/X uses the form "-framework lib" so we don't - # want to lose the multiple "-framework". - libs = [] - - for l in self.extra_libs: - libs.append(self.platform_lib(l)) - - if self._qt: - libs.extend(self._dependent_libs(l)) - - libs.extend(self.optional_list("LIBS")) - - rpaths = _UniqueList() - - for l in self.extra_lib_dirs: - # Ignore relative directories. This is really a hack to handle - # SIP v3 inter-module linking. - if os.path.dirname(l) not in ("", ".", ".."): - rpaths.append(l) - - if self._python: - incdir.append(self.config.py_inc_dir) - incdir.append(self.config.py_conf_inc_dir) - - if sys.platform == "cygwin": - libdir.append(self.config.py_lib_dir) - - py_lib = "python%u.%u" % ((self.config.py_version >> 16), ((self.config.py_version >> 8) & 0xff)) - libs.append(self.platform_lib(py_lib)) - elif sys.platform == "win32": - libdir.append(self.config.py_lib_dir) - - py_lib = "python%u%u" % ((self.config.py_version >> 16), ((self.config.py_version >> 8) & 0xff)) - - # For Borland use the OMF version of the Python library if it - # exists, otherwise assume that Python was built with Borland - # and use the normal library. - if self.generator == "BMAKE": - bpy_lib = py_lib + "_bcpp" - bpy_lib_path = os.path.join(self.config.py_lib_dir, self.platform_lib(bpy_lib)) - - if os.access(bpy_lib_path, os.F_OK): - py_lib = bpy_lib - - if self._debug: - py_lib = py_lib + "_d" - - if self.generator != "MINGW": - cflags.append("/D_DEBUG") - cxxflags.append("/D_DEBUG") - - libs.append(self.platform_lib(py_lib)) - - if self.generator in ("MSVC", "MSVC.NET", "BMAKE"): - if win_exceptions: - cflags_exceptions = "CFLAGS_EXCEPTIONS_ON" - cxxflags_exceptions = "CXXFLAGS_EXCEPTIONS_ON" - else: - cflags_exceptions = "CFLAGS_EXCEPTIONS_OFF" - cxxflags_exceptions = "CXXFLAGS_EXCEPTIONS_OFF" - - cflags.extend(self.optional_list(cflags_exceptions)) - cxxflags.extend(self.optional_list(cxxflags_exceptions)) - - if win_rtti: - cflags_rtti = "CFLAGS_RTTI_ON" - cxxflags_rtti = "CXXFLAGS_RTTI_ON" - else: - cflags_rtti = "CFLAGS_RTTI_OFF" - cxxflags_rtti = "CXXFLAGS_RTTI_OFF" - - cflags.extend(self.optional_list(cflags_rtti)) - cxxflags.extend(self.optional_list(cxxflags_rtti)) - - if win_stl: - cflags_stl = "CFLAGS_STL_ON" - cxxflags_stl = "CXXFLAGS_STL_ON" - else: - cflags_stl = "CFLAGS_STL_OFF" - cxxflags_stl = "CXXFLAGS_STL_OFF" - - cflags.extend(self.optional_list(cflags_stl)) - cxxflags.extend(self.optional_list(cxxflags_stl)) - - if self._debug: - if win_shared: - cflags_mt = "CFLAGS_MT_DLLDBG" - cxxflags_mt = "CXXFLAGS_MT_DLLDBG" - else: - cflags_mt = "CFLAGS_MT_DBG" - cxxflags_mt = "CXXFLAGS_MT_DBG" - - cflags_debug = "CFLAGS_DEBUG" - cxxflags_debug = "CXXFLAGS_DEBUG" - lflags_debug = "LFLAGS_DEBUG" - else: - if win_shared: - cflags_mt = "CFLAGS_MT_DLL" - cxxflags_mt = "CXXFLAGS_MT_DLL" - else: - cflags_mt = "CFLAGS_MT" - cxxflags_mt = "CXXFLAGS_MT" - - cflags_debug = "CFLAGS_RELEASE" - cxxflags_debug = "CXXFLAGS_RELEASE" - lflags_debug = "LFLAGS_RELEASE" - - if self.generator in ("MSVC", "MSVC.NET", "BMAKE"): - if self._threaded: - cflags.extend(self.optional_list(cflags_mt)) - cxxflags.extend(self.optional_list(cxxflags_mt)) - - if self.console: - cflags.extend(self.optional_list("CFLAGS_CONSOLE")) - cxxflags.extend(self.optional_list("CXXFLAGS_CONSOLE")) - - cflags.extend(self.optional_list(cflags_debug)) - cxxflags.extend(self.optional_list(cxxflags_debug)) - lflags.extend(self.optional_list(lflags_debug)) - - if self._warnings: - cflags_warn = "CFLAGS_WARN_ON" - cxxflags_warn = "CXXFLAGS_WARN_ON" - else: - cflags_warn = "CFLAGS_WARN_OFF" - cxxflags_warn = "CXXFLAGS_WARN_OFF" - - cflags.extend(self.optional_list(cflags_warn)) - cxxflags.extend(self.optional_list(cxxflags_warn)) - - if self._threaded: - cflags.extend(self.optional_list("CFLAGS_THREAD")) - cxxflags.extend(self.optional_list("CXXFLAGS_THREAD")) - lflags.extend(self.optional_list("LFLAGS_THREAD")) - - if self._qt: - if self.generator != "UNIX" and win_shared: - defines.append("QT_DLL") - - if not self._debug: - defines.append("QT_NO_DEBUG") - - if self.config.qt_version >= 0x040000: - for mod in self._qt: - if mod == "QtCore": - defines.append("QT_CORE_LIB") - elif mod == "QtGui": - defines.append("QT_GUI_LIB") - elif mod == "QtNetwork": - defines.append("QT_NETWORK_LIB") - elif mod == "QtOpenGL": - defines.append("QT_OPENGL_LIB") - elif mod == "QtSql": - defines.append("QT_SQL_LIB") - elif mod == "QtTest": - defines.append("QT_TEST_LIB") - elif mod == "QtXml": - defines.append("QT_XML_LIB") - elif self._threaded: - defines.append("QT_THREAD_SUPPORT") - - # Handle library directories. - libdir_qt = self.optional_list("LIBDIR_QT") - libdir.extend(libdir_qt) - rpaths.extend(libdir_qt) - - if self.config.qt_version >= 0x040000: - # For Windows: the macros that define the dependencies on - # Windows libraries. - wdepmap = { - "QtCore": "LIBS_CORE", - "QtGui": "LIBS_GUI", - "QtNetwork": "LIBS_NETWORK", - "QtOpenGL": "LIBS_OPENGL" - } - - # For Windows: the dependencies between Qt libraries. - qdepmap = { - "QtAssistant": ("QtCore", "QtGui", "QtNetwork"), - "QtGui": ("QtCore", ), - "QtNetwork": ("QtCore", ), - "QtOpenGL": ("QtCore", "QtGui"), - "QtSql": ("QtCore", ), - "QtSvg": ("QtCore", "QtGui", "QtXml"), - "QtTest": ("QtCore", "QtGui"), - "QtXml": ("QtCore", ), - "QtDesigner": ("QtCore", "QtGui"), - "QAxContainer": ("QtCore", "QtGui") - } - - # The QtSql .prl file doesn't include QtGui as a dependency (at - # least on Linux) so we explcitly set the dependency here for - # everything. - if "QtSql" in self._qt: - if "QtGui" not in self._qt: - self._qt.append("QtGui") - - # With Qt v4.2.0, the QtAssistantClient library is now a shared - # library on UNIX. The QtAssistantClient .prl file doesn't - # include QtGui and QtNetwork as a dependency any longer. This - # seems to be a bug in Qt v4.2.0. We explicitly set the - # dependencies here. - if self.config.qt_version >= 0x040200 and "QtAssistant" in self._qt: - if "QtGui" not in self._qt: - self._qt.append("QtGui") - if "QtNetwork" not in self._qt: - self._qt.append("QtNetwork") - - for mod in self._qt: - lib = self._qt4_module_to_lib(mod) - libs.append(self.platform_lib(lib, self._is_framework(mod))) - - if sys.platform == "win32": - # On Windows the dependent libraries seem to be in - # qmake.conf rather than the .prl file and the - # inter-dependencies between Qt libraries don't seem to - # be anywhere. - deps = _UniqueList() - - if mod in wdepmap.keys(): - deps.extend(self.optional_list(wdepmap[mod])) - - if mod in qdepmap.keys(): - for qdep in qdepmap[mod]: - # Ignore the dependency if it is explicitly - # linked. - if qdep not in self._qt: - libs.append(self.platform_lib(self._qt4_module_to_lib(qdep))) - - if qdep in wdepmap.keys(): - deps.extend(self.optional_list(wdepmap[qdep])) - - libs.extend(deps.as_list()) - else: - libs.extend(self._dependent_libs(lib, self._is_framework(mod))) - else: - # Windows needs the version number appended if Qt is a DLL. - qt_lib = self.config.qt_lib - - if self.generator in ("MSVC", "MSVC.NET", "BMAKE") and win_shared: - qt_lib = qt_lib + string.replace(version_to_string(self.config.qt_version), ".", "") - - if self.config.qt_edition == "non-commercial": - qt_lib = qt_lib + "nc" - - libs.append(self.platform_lib(qt_lib, self.config.qt_framework)) - libs.extend(self._dependent_libs(self.config.qt_lib)) - - # Handle header directories. - try: - specd_base = self.config.qt_data_dir - except AttributeError: - specd_base = self.config.qt_dir - - specd = os.path.join(specd_base, "mkspecs", "default") - - if not os.access(specd, os.F_OK): - specd = os.path.join(specd_base, "mkspecs", self.config.platform) - - incdir.append(specd) - - qtincdir = self.optional_list("INCDIR_QT") - - if qtincdir: - if self.config.qt_version >= 0x040000: - for mod in self._qt: - if mod == "QAxContainer": - incdir.append(os.path.join(qtincdir[0], "ActiveQt")) - elif self._is_framework(mod): - if mod == "QtAssistant" and self.config.qt_version < 0x040202: - mod = "QtAssistantClient" - - incdir.append(os.path.join(libdir_qt[0], mod + ".framework", "Headers")) - else: - incdir.append(os.path.join(qtincdir[0], mod)) - - # This must go after the module include directories. - incdir.extend(qtincdir) - - if self._opengl: - incdir.extend(self.optional_list("INCDIR_OPENGL")) - lflags.extend(self.optional_list("LFLAGS_OPENGL")) - libdir.extend(self.optional_list("LIBDIR_OPENGL")) - libs.extend(self.optional_list("LIBS_OPENGL")) - - if self._qt or self._opengl: - incdir.extend(self.optional_list("INCDIR_X11")) - libdir.extend(self.optional_list("LIBDIR_X11")) - libs.extend(self.optional_list("LIBS_X11")) - - if self._threaded: - libs.extend(self.optional_list("LIBS_THREAD")) - libs.extend(self.optional_list("LIBS_RTMT")) - else: - libs.extend(self.optional_list("LIBS_RT")) - - if self.console: - libs.extend(self.optional_list("LIBS_CONSOLE")) - - libs.extend(self.optional_list("LIBS_WINDOWS")) - - lflags.extend(self._platform_rpaths(rpaths.as_list())) - - # Save the transformed values. - self.CFLAGS.set(cflags) - self.CXXFLAGS.set(cxxflags) - self.DEFINES.set(defines) - self.INCDIR.set(incdir) - self.LFLAGS.set(lflags) - self.LIBDIR.set(libdir) - self.LIBS.set(libs) - - # Don't do it again because it has side effects. - self._finalised = 1 - - def _is_framework(self, mod): - """Return true if the given Qt module is a framework. - """ - return (self.config.qt_framework and (self.config.qt_version >= 0x040200 or mod != "QtAssistant")) - - def _qt4_module_to_lib(self, mname): - """Return the name of the Qt4 library corresponding to a module. - - mname is the name of the module. - """ - if mname == "QtAssistant": - if self.config.qt_version >= 0x040202 and sys.platform == "darwin": - lib = mname - else: - lib = "QtAssistantClient" - else: - lib = mname - - if self._debug: - if sys.platform == "win32": - lib = lib + "d" - elif self.config.qt_version < 0x040200 or sys.platform == "darwin": - lib = lib + "_debug" - - if sys.platform == "win32": - if (mname in ("QtCore", "QtGui", "QtNetwork", "QtOpenGL", - "QtSql", "QtSvg", "QtTest", "QtXml", "QtDesigner") or - (self.config.qt_version >= 0x040200 and mname == "QtAssistant")): - lib = lib + "4" - - return lib - - def optional_list(self, name): - """Return an optional Makefile macro as a list. - - name is the name of the macro. - """ - return self.__dict__[name].as_list() - - def optional_string(self, name, default=""): - """Return an optional Makefile macro as a string. - - name is the name of the macro. - default is the default value - """ - s = string.join(self.optional_list(name)) - - if not s: - s = default - - return s - - def required_string(self, name): - """Return a required Makefile macro as a string. - - name is the name of the macro. - """ - s = self.optional_string(name) - - if not s: - raise ValueError, "\"%s\" must have a non-empty value" % name - - return s - - def _platform_rpaths(self, rpaths): - """Return a list of platform specific rpath flags. - - rpaths is the cannonical list of rpaths. - """ - flags = [] - prefix = self.optional_string("RPATH") - - if prefix: - for r in rpaths: - flags.append(_quote(prefix + r)) - - return flags - - def platform_lib(self, clib, framework=0): - """Return a library name in platform specific form. - - clib is the library name in cannonical form. - framework is set of the library is implemented as a MacOS framework. - """ - if self.generator in ("MSVC", "MSVC.NET", "BMAKE"): - plib = clib + ".lib" - elif sys.platform == "darwin" and framework: - plib = "-framework " + clib - else: - plib = "-l" + clib - - return plib - - def _dependent_libs(self, clib, framework=0): - """Return a list of additional libraries (in platform specific form) - that must be linked with a library. - - clib is the library name in cannonical form. - framework is set of the library is implemented as a MacOS framework. - """ - prl_libs = [] - - if self.generator in ("MSVC", "MSVC.NET", "BMAKE"): - prl_name = os.path.join(self.config.qt_lib_dir, clib + ".prl") - elif sys.platform == "darwin" and framework: - prl_name = os.path.join(self.config.qt_lib_dir, clib + ".framework", clib + ".prl") - else: - prl_name = os.path.join(self.config.qt_lib_dir, "lib" + clib + ".prl") - - if os.access(prl_name, os.F_OK): - try: - f = open(prl_name, "r") - except IOError, detail: - error("Unable to open \"%s\": %s" % (prl_name, detail)) - - line = f.readline() - while line: - line = string.strip(line) - if line and line[0] != "#": - eq = string.find(line, "=") - if eq > 0 and string.strip(line[:eq]) == "QMAKE_PRL_LIBS": - prl_libs = string.split(line[eq + 1:]) - break - - line = f.readline() - - f.close() - - return prl_libs - - - def parse_build_file(self, filename): - """ - Parse a build file and return the corresponding dictionary. - - filename is the name of the build file. If it is a dictionary instead - then its contents are validated. - """ - if type(filename) is types.DictType: - bfname = "dictionary" - dict = filename - else: - if self._dir: - bfname = os.path.join(self._dir, filename) - else: - bfname = filename - - dict = {} - - try: - f = open(bfname, "r") - except IOError, detail: - error("Unable to open \"%s\": %s" % (bfname, detail)) - - line_nr = 1 - line = f.readline() - - while line: - line = string.strip(line) - - if line and line[0] != "#": - eq = string.find(line, "=") - - if eq <= 0: - error("\"%s\" line %d: Line must be in the form 'name = value value...'." % (bfname, line_nr)) - - dict[string.strip(line[:eq])] = string.strip(line[eq + 1:]) - - line_nr = line_nr + 1 - line = f.readline() - - f.close() - - # Check the compulsory values. - for i in ("target", "sources"): - try: - dict[i] - except KeyError: - error("\"%s\" is missing from \"%s\"." % (i, bfname)) - - # Get the optional values. - for i in ("headers", "moc_headers"): - try: - dict[i] - except KeyError: - dict[i] = "" - - # Generate the list of objects. - if self.generator in ("MSVC", "MSVC.NET", "BMAKE"): - ext = ".obj" - else: - ext = ".o" - - olist = [] - - for f in string.split(dict["sources"]): - root, discard = os.path.splitext(f) - olist.append(root + ext) - - for f in string.split(dict["moc_headers"]): - if not self._qt: - error("\"%s\" defines \"moc_headers\" for a non-Qt module." % bfname) - - root, discard = os.path.splitext(f) - olist.append("moc_" + root + ext) - - dict["objects"] = string.join(olist) - - return dict - - def clean_build_file_objects(self, mfile, build): - """Generate the clean target. - - mfile is the file object. - build is the dictionary created from the build file. - """ - mfile.write("\t-%s $(TARGET)\n" % self.rm) - - for f in string.split(build["objects"]): - mfile.write("\t-%s %s\n" % (self.rm, f)) - - for f in string.split(build["moc_headers"]): - root, discard = os.path.splitext(f) - mfile.write("\t-%s moc_%s.cpp\n" % (self.rm, root)) - - def ready(self): - """The Makefile is now ready to be used. - """ - if not self._finalised: - self.finalise() - - def generate(self): - """Generate the Makefile. - """ - self.ready() - - if self._dir: - mfname = os.path.join(self._dir, self._makefile) - else: - mfname = self._makefile - - try: - mfile = open(mfname, "w") - except IOError, detail: - error("Unable to create \"%s\": %s" % (mfname, detail)) - - self.generate_macros_and_rules(mfile) - self.generate_target_default(mfile) - self.generate_target_install(mfile) - - if self._installs: - if type(self._installs) != types.ListType: - self._installs = [self._installs] - - for src, dst in self._installs: - self.install_file(mfile, src, dst) - - self.generate_target_clean(mfile) - - mfile.close() - - def generate_macros_and_rules(self, mfile): - """The default implementation of the macros and rules generation. - - mfile is the file object. - """ - mfile.write("CC = %s\n" % self.required_string("CC")) - mfile.write("CXX = %s\n" % self.required_string("CXX")) - mfile.write("LINK = %s\n" % self.required_string("LINK")) - - cppflags = [] - - for f in self.optional_list("DEFINES"): - cppflags.append("-D" + f) - - for f in self.optional_list("INCDIR"): - cppflags.append("-I" + _quote(f)) - - libs = [] - - if self.generator in ("MSVC", "MSVC.NET"): - libdir_prefix = "/LIBPATH:" - else: - libdir_prefix = "-L" - - for ld in self.optional_list("LIBDIR"): - if sys.platform == "darwin" and self.config.qt_framework: - fflag = "-F" + _quote(ld) - libs.append(fflag) - cppflags.append(fflag) - - libs.append(libdir_prefix + _quote(ld)) - - libs.extend(self.optional_list("LIBS")) - - mfile.write("CPPFLAGS = %s\n" % string.join(cppflags)) - - mfile.write("CFLAGS = %s\n" % self.optional_string("CFLAGS")) - mfile.write("CXXFLAGS = %s\n" % self.optional_string("CXXFLAGS")) - mfile.write("LFLAGS = %s\n" % self.optional_string("LFLAGS")) - - mfile.write("LIBS = %s\n" % string.join(libs)) - - if self._qt: - mfile.write("MOC = %s\n" % _quote(self.required_string("MOC"))) - - # These probably don't matter. - if self.generator == "MINGW": - mfile.write(".SUFFIXES: .cpp .cxx .cc .C .c\n\n") - elif self.generator == "UNIX": - mfile.write(".SUFFIXES: .c .o .cpp .cc .cxx .C\n\n") - else: - mfile.write(".SUFFIXES: .c .cpp .cc .cxx .C\n\n") - - if self.generator in ("MSVC", "MSVC.NET"): - mfile.write(""" -{.}.cpp{}.obj:: -\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -Fo @<< -\t$< -<< - -{.}.cc{}.obj:: -\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -Fo @<< -\t$< -<< - -{.}.cxx{}.obj:: -\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -Fo @<< -\t$< -<< - -{.}.C{}.obj:: -\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -Fo @<< -\t$< -<< - -{.}.c{}.obj:: -\t$(CC) -c $(CFLAGS) $(CPPFLAGS) -Fo @<< -\t$< -<< -""") - elif self.generator == "BMAKE": - mfile.write(""" -.cpp.obj: -\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o$@ $< - -.cc.obj: -\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o$@ $< - -.cxx.obj: -\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o$@ $< - -.C.obj: -\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o$@ $< - -.c.obj: -\t$(CC) -c $(CFLAGS) $(CPPFLAGS) -o$@ $< -""") - else: - mfile.write(""" -.cpp.o: -\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $< - -.cc.o: -\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $< - -.cxx.o: -\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $< - -.C.o: -\t$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $< - -.c.o: -\t$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< -""") - - def generate_target_default(self, mfile): - """The default implementation of the default target. - - mfile is the file object. - """ - mfile.write("\nall:\n") - - def generate_target_install(self, mfile): - """The default implementation of the install target. - - mfile is the file object. - """ - mfile.write("\ninstall:\n") - - def generate_target_clean(self, mfile): - """The default implementation of the clean target. - - mfile is the file object. - """ - mfile.write("\nclean:\n") - - def install_file(self, mfile, src, dst, strip=0): - """Install one or more files in a directory. - - mfile is the file object. - src is the name of a single file to install, or the list of a number of - files to install. - dst is the name of the destination directory. - strip is set if the files should be stripped after been installed. - """ - # Help package builders. - if self.generator == "UNIX": - dst = "$(DESTDIR)" + dst - - mfile.write("\t@%s %s " % (self.chkdir, _quote(dst))) - - if self.generator == "UNIX": - mfile.write("|| ") - - mfile.write("%s %s\n" % (self.mkdir, _quote(dst))) - - if type(src) != types.ListType: - src = [src] - - # Get the strip command if needed. - if strip: - strip_cmd = self.optional_string("STRIP") - - if not strip_cmd: - strip = 0 - - for sf in src: - target = _quote(os.path.join(dst, os.path.basename(sf))) - - mfile.write("\t%s %s %s\n" % (self.copy, _quote(sf), target)) - - if strip: - mfile.write("\t%s %s\n" % (strip_cmd, target)) - - -class ParentMakefile(Makefile): - """The class that represents a parent Makefile. - """ - def __init__(self, configuration, subdirs, dir=None, makefile="Makefile", - installs=None): - """Initialise an instance of a parent Makefile. - - subdirs is the sequence of subdirectories. - """ - Makefile.__init__(self, configuration, dir=dir, makefile=makefile, installs=installs) - - self._subdirs = subdirs - - def generate_macros_and_rules(self, mfile): - """Generate the macros and rules. - - mfile is the file object. - """ - # We don't want them. - pass - - def generate_target_default(self, mfile): - """Generate the default target. - - mfile is the file object. - """ - self._subdir_target(mfile) - - def generate_target_install(self, mfile): - """Generate the install target. - - mfile is the file object. - """ - self._subdir_target(mfile, "install") - - def generate_target_clean(self, mfile): - """Generate the clean target. - - mfile is the file object. - """ - self._subdir_target(mfile, "clean") - - def _subdir_target(self, mfile, target="all"): - """Create a target for a list of sub-directories. - - mfile is the file object. - target is the name of the target. - """ - if target == "all": - tname = "" - else: - tname = " " + target - - mfile.write("\n" + target + ":\n") - - for d in self._subdirs: - if self.generator == "MINGW": - mfile.write("\t@$(MAKE) -C %s%s\n" % (d, tname)) - elif self.generator == "UNIX": - mfile.write("\t@(cd %s; $(MAKE)%s)\n" % (d, tname)) - else: - mfile.write("\tcd %s\n" % d) - mfile.write("\t$(MAKE)%s\n" % tname) - mfile.write("\t@cd ..\n") - - -class PythonModuleMakefile(Makefile): - """The class that represents a Python module Makefile. - """ - def __init__(self, configuration, dstdir, srcdir=None, dir=None, - makefile="Makefile", installs=None): - """Initialise an instance of a parent Makefile. - - dstdir is the name of the directory where the module's Python code will - be installed. - srcdir is the name of the directory (relative to the directory in which - the Makefile will be created) containing the module's Python code. It - defaults to the same directory. - """ - Makefile.__init__(self, configuration, dir=dir, makefile=makefile, installs=installs) - - if not srcdir: - srcdir = "." - - if dir: - self._moddir = os.path.join(dir, srcdir) - else: - self._moddir = srcdir - - self._srcdir = srcdir - self._dstdir = dstdir - - def generate_macros_and_rules(self, mfile): - """Generate the macros and rules. - - mfile is the file object. - """ - # We don't want them. - pass - - def generate_target_install(self, mfile): - """Generate the install target. - - mfile is the file object. - """ - Makefile.generate_target_install(self, mfile) - - os.path.walk(self._moddir, self._visit, mfile) - - def _visit(self, mfile, dirname, names): - """Install the files from a particular directory. - - mfile is the file object. - dirname is the sub-directory. - names is the list of files to install from the sub-directory. - """ - tail = dirname[len(self._moddir):] - - flist = [] - for f in names: - # Ignore certain files. - if f in ("Makefile", ): - continue - - if os.path.isfile(os.path.join(dirname, f)): - flist.append(os.path.join(self._srcdir + tail, f)) - - self.install_file(mfile, flist, self._dstdir + tail) - - -class ModuleMakefile(Makefile): - """The class that represents a Python extension module Makefile - """ - def __init__(self, configuration, build_file, install_dir=None, static=0, - console=0, qt=0, opengl=0, threaded=0, warnings=1, debug=0, - dir=None, makefile="Makefile", installs=None, strip=1, - export_all=0, universal=''): - """Initialise an instance of a module Makefile. - - build_file is the file containing the target specific information. If - it is a dictionary instead then its contents are validated. - install_dir is the directory the target will be installed in. - static is set if the module should be built as a static library. - strip is set if the module should be stripped of unneeded symbols when - installed. The default is 1. - export_all is set if all the module's symbols should be exported rather - than just the module's initialisation function. Exporting all symbols - increases the size of the module and slows down module load times but - may avoid problems with modules that use exceptions. The default is 0. - """ - Makefile.__init__(self, configuration, console, qt, opengl, 1, threaded, warnings, debug, dir, makefile, installs, universal) - - self._build = self.parse_build_file(build_file) - self._install_dir = install_dir - self._dir = dir - self.static = static - - # Don't strip or restrict the exports if this is a debug or static - # build. - if debug or static: - self._strip = 0 - self._limit_exports = 0 - else: - self._strip = strip - - # The deprecated configuration flag has precedence. - if self.config.export_all: - self._limit_exports = 0 - else: - self._limit_exports = not export_all - - # Save the target name for later. - self._target = self._build["target"] - - if sys.platform != "win32" and static: - self._target = "lib" + self._target - - if sys.platform == "win32" and debug: - self._target = self._target + "_d" - - def finalise(self): - """Finalise the macros common to all module Makefiles. - """ - if self.console: - lflags_console = "LFLAGS_CONSOLE" - else: - lflags_console = "LFLAGS_WINDOWS" - - if self.static: - self.DEFINES.append("SIP_STATIC_MODULE") - else: - self.CFLAGS.extend(self.optional_list("CFLAGS_SHLIB")) - self.CXXFLAGS.extend(self.optional_list("CXXFLAGS_SHLIB")) - - lflags_dll = self.optional_list("LFLAGS_DLL") - - if lflags_dll: - self.LFLAGS.extend(lflags_dll) - elif self.console: - lflags_console = "LFLAGS_CONSOLE_DLL" - else: - lflags_console = "LFLAGS_WINDOWS_DLL" - - # We use this to explictly create bundles on MacOS. Apple's Python - # can handle extension modules that are bundles or dynamic - # libraries, but python.org versions need bundles (unless built - # with DYNLOADFILE=dynload_shlib.o). - if sys.platform == "darwin": - lflags_plugin = ["-bundle"] - else: - lflags_plugin = self.optional_list("LFLAGS_PLUGIN") - - if not lflags_plugin: - lflags_plugin = self.optional_list("LFLAGS_SHLIB") - - self.LFLAGS.extend(lflags_plugin) - - self.LFLAGS.extend(self.optional_list(lflags_console)) - - if sys.platform == "darwin": - # We use the -F flag to explictly specify the directory containing - # the Python framework rather than rely on the default search path. - # This allows Apple's Python to be used even if a later python.org - # version is also installed. - dl = string.split(sys.exec_prefix, os.sep) - try: - dl = dl[:dl.index("Python.framework")] - except ValueError: - error("SIP requires Python to be built as a framework") - self.LFLAGS.append("-F%s" % string.join(dl, os.sep)) - self.LFLAGS.append("-framework Python") - - Makefile.finalise(self) - - if not self.static: - if self.optional_string("AIX_SHLIB"): - # AIX needs a lot of special handling. - if self.required_string('LINK') == 'g++': - # g++ is used for linking. - # For SIP v4 and g++: - # 1.) Import the python symbols - aix_lflags = ['-Wl,-bI:%s/python.exp' % self.config.py_lib_dir] - - if self._limit_exports: - aix_lflags.append('-Wl,-bnoexpall') - aix_lflags.append('-Wl,-bnoentry') - aix_lflags.append('-Wl,-bE:%s.exp' % self._target) - else: - # IBM VisualAge C++ is used for linking. - # For SIP v4 and xlC: - # 1.) Create a shared object - # 2.) Import the python symbols - aix_lflags = ['-qmkshrobj', - '-bI:%s/python.exp' % self.config.py_lib_dir] - - if self._limit_exports: - aix_lflags.append('-bnoexpall') - aix_lflags.append('-bnoentry') - aix_lflags.append('-bE:%s.exp' % self._target) - - self.LFLAGS.extend(aix_lflags) - else: - if self._limit_exports: - if sys.platform[:5] == 'linux': - self.LFLAGS.extend(['-Wl,--version-script=%s.exp' % self._target]) - elif sys.platform[:5] == 'sunos': - if self.required_string('LINK') == 'g++': - self.LFLAGS.extend(['-Wl,-z,noversion', '-Wl,-M,%s.exp' % self._target]) - else: - self.LFLAGS.extend(['-z' 'noversion', '-M', '%s.exp' % self._target]) - elif sys.platform[:5] == 'hp-ux': - self.LFLAGS.extend(['-Wl,+e,init%s' % self._target]) - elif sys.platform[:5] == 'irix' and self.required_string('LINK') != 'g++': - # Doesn't work when g++ is used for linking on IRIX. - self.LFLAGS.extend(['-Wl,-exported_symbol,init%s' % self._target]) - - # Force the shared linker if there is one. - link_shlib = self.optional_list("LINK_SHLIB") - - if link_shlib: - self.LINK.set(link_shlib) - - def module_as_lib(self, mname): - """Return the name of a SIP v3.x module when it is used as a library. - This will raise an exception when used with SIP v4.x modules. - - mname is the name of the module. - """ - raise ValueError, "module_as_lib() can only be used with SIP v3.x" - - def generate_macros_and_rules(self, mfile): - """Generate the macros and rules generation. - - mfile is the file object. - """ - if self.static: - if sys.platform == "win32": - ext = "lib" - else: - ext = "a" - else: - if sys.platform == "win32": - ext = "pyd" - elif sys.platform == "darwin": - ext = "so" - elif sys.platform == "cygwin": - ext = "dll" - else: - ext = self.optional_string("EXTENSION_PLUGIN") - if not ext: - ext = self.optional_string("EXTENSION_SHLIB", "so") - - mfile.write("TARGET = %s\n" % (self._target + "." + ext)) - mfile.write("OFILES = %s\n" % self._build["objects"]) - mfile.write("HFILES = %s %s\n" % (self._build["headers"], self._build["moc_headers"])) - mfile.write("\n") - - if self.static: - if self.generator in ("MSVC", "MSVC.NET", "BMAKE"): - mfile.write("LIB = %s\n" % self.required_string("LIB")) - elif self.generator == "MINGW": - mfile.write("AR = %s\n" % self.required_string("LIB")) - self._ranlib = None - else: - mfile.write("AR = %s\n" % self.required_string("AR")) - - self._ranlib = self.optional_string("RANLIB") - - if self._ranlib: - mfile.write("RANLIB = %s\n" % self._ranlib) - - Makefile.generate_macros_and_rules(self, mfile) - - def generate_target_default(self, mfile): - """Generate the default target. - - mfile is the file object. - """ - mfile.write("\n$(TARGET): $(OFILES)\n") - - if self.generator in ("MSVC", "MSVC.NET"): - if self.static: - mfile.write("\t$(LIB) /OUT:$(TARGET) @<<\n") - mfile.write("\t $(OFILES)\n") - mfile.write("<<\n") - else: - mfile.write("\t$(LINK) $(LFLAGS) /OUT:$(TARGET) @<<\n") - mfile.write("\t $(OFILES) $(LIBS)\n") - mfile.write("<<\n") - - if "embed_manifest_dll" in self.optional_list("CONFIG"): - mfile.write("\tmt -nologo -manifest $(TARGET).manifest -outputresource:$(TARGET);2\n") - elif self.generator == "BMAKE": - if self.static: - mfile.write("\t-%s $(TARGET)\n" % (self.rm)) - mfile.write("\t$(LIB) $(TARGET) @&&|\n") - - for of in string.split(self._build["objects"]): - mfile.write("+%s \\\n" % (of)) - - mfile.write("|\n") - else: - mfile.write("\t$(LINK) @&&|\n") - mfile.write("\t$(LFLAGS) $(OFILES) ,$(TARGET),,$(LIBS),%s\n" % (self._target)) - mfile.write("|\n") - - # Create the .def file that renames the entry point. - defname = self._target + ".def" - - if self._dir: - defname = os.path.join(self._dir, defname) - - try: - dfile = open(defname, "w") - except IOError, detail: - error("Unable to create \"%s\": %s" % (defname, detail)) - - dfile.write("EXPORTS\n") - dfile.write("init%s=_init%s\n" % (self._target, self._target)) - - dfile.close() - - else: - if self.static: - mfile.write("\t-%s $(TARGET)\n" % self.rm) - mfile.write("\t$(AR) $(TARGET) $(OFILES)\n") - - if self._ranlib: - mfile.write("\t$(RANLIB) $(TARGET)\n") - else: - if self._limit_exports: - # Create an export file for AIX, Linux and Solaris. - if sys.platform[:5] == 'linux': - mfile.write("\t@echo '{ global: init%s; local: *; };' > %s.exp\n" % (self._target, self._target)) - elif sys.platform[:5] == 'sunos': - mfile.write("\t@echo '{ global: init%s; local: *; };' > %s.exp\n" % (self._target, self._target)) - elif sys.platform[:3] == 'aix': - mfile.write("\t@echo '#!' >%s.exp" % self._target) - mfile.write("; \\\n\t echo 'init%s' >>%s.exp\n" % (self._target, self._target)) - - mfile.write("\t$(LINK) $(LFLAGS) -o $(TARGET) $(OFILES) $(LIBS)\n") - - mfile.write("\n$(OFILES): $(HFILES)\n") - - for mf in string.split(self._build["moc_headers"]): - root, discard = os.path.splitext(mf) - cpp = "moc_" + root + ".cpp" - - mfile.write("\n%s: %s\n" % (cpp, mf)) - mfile.write("\t$(MOC) -o %s %s\n" % (cpp, mf)) - - def generate_target_install(self, mfile): - """Generate the install target. - - mfile is the file object. - """ - if self._install_dir is None: - self._install_dir = self.config.default_mod_dir - - mfile.write("\ninstall: $(TARGET)\n") - self.install_file(mfile, "$(TARGET)", self._install_dir, self._strip) - - def generate_target_clean(self, mfile): - """Generate the clean target. - - mfile is the file object. - """ - mfile.write("\nclean:\n") - self.clean_build_file_objects(mfile, self._build) - - # Remove any export file on AIX, Linux and Solaris. - if self._limit_exports and (sys.platform[:5] == 'linux' or - sys.platform[:5] == 'sunos' or - sys.platform[:3] == 'aix'): - mfile.write("\t-%s %s.exp\n" % (self.rm, self._target)) - - -class SIPModuleMakefile(ModuleMakefile): - """The class that represents a SIP generated module Makefile. - """ - def finalise(self): - """Finalise the macros for a SIP generated module Makefile. - """ - self.INCDIR.append(self.config.sip_inc_dir) - - ModuleMakefile.finalise(self) - - -class ProgramMakefile(Makefile): - """The class that represents a program Makefile. - """ - def __init__(self, configuration, build_file=None, install_dir=None, - console=0, qt=0, opengl=0, python=0, threaded=0, warnings=1, - debug=0, dir=None, makefile="Makefile", installs=None, - universal=''): - """Initialise an instance of a program Makefile. - - build_file is the file containing the target specific information. If - it is a dictionary instead then its contents are validated. - install_dir is the directory the target will be installed in. - """ - Makefile.__init__(self, configuration, console, qt, opengl, python, threaded, warnings, debug, dir, makefile, installs, universal) - - self._install_dir = install_dir - - if build_file: - self._build = self.parse_build_file(build_file) - else: - self._build = None - - def build_command(self, source): - """Create a command line that will build an executable. Returns a - tuple of the name of the executable and the command line. - - source is the name of the source file. - """ - self.ready() - - # The name of the executable. - exe, ignore = os.path.splitext(source) - - if sys.platform in ("win32", "cygwin"): - exe = exe + ".exe" - - # The command line. - build = [] - - build.append(self.required_string("CXX")) - - for f in self.optional_list("DEFINES"): - build.append("-D" + f) - - for f in self.optional_list("INCDIR"): - build.append("-I" + _quote(f)) - - build.extend(self.optional_list("CXXFLAGS")) - - # Borland requires all flags to precede all file names. - if self.generator != "BMAKE": - build.append(source) - - if self.generator in ("MSVC", "MSVC.NET"): - build.append("-Fe") - build.append("/link") - libdir_prefix = "/LIBPATH:" - elif self.generator == "BMAKE": - build.append("-e" + exe) - libdir_prefix = "-L" - else: - build.append("-o") - build.append(exe) - libdir_prefix = "-L" - - for ld in self.optional_list("LIBDIR"): - if sys.platform == "darwin" and self.config.qt_framework: - build.append("-F" + _quote(ld)) - - build.append(libdir_prefix + _quote(ld)) - - lflags = self.optional_list("LFLAGS") - - # This is a huge hack demonstrating my lack of understanding of how the - # Borland compiler works. - if self.generator == "BMAKE": - blflags = [] - - for lf in lflags: - for f in string.split(lf): - # Tell the compiler to pass the flags to the linker. - if f[-1] == "-": - f = "-l-" + f[1:-1] - elif f[0] == "-": - f = "-l" + f[1:] - - # Remove any explicit object files otherwise the compiler - # will complain that they can't be found, but they don't - # seem to be needed. - if string.lower(f[-4:]) != ".obj": - blflags.append(f) - - lflags = blflags - - build.extend(lflags) - - build.extend(self.optional_list("LIBS")) - - if self.generator == "BMAKE": - build.append(source) - - return (exe, string.join(build)) - - def finalise(self): - """Finalise the macros for a program Makefile. - """ - if self.generator in ("MSVC", "MSVC.NET"): - self.LFLAGS.append("/INCREMENTAL:NO") - - if self.console: - lflags_console = "LFLAGS_CONSOLE" - else: - lflags_console = "LFLAGS_WINDOWS" - - self.LFLAGS.extend(self.optional_list(lflags_console)) - - Makefile.finalise(self) - - def generate_macros_and_rules(self, mfile): - """Generate the macros and rules generation. - - mfile is the file object. - """ - if not self._build: - raise ValueError, "pass a filename as build_file when generating a Makefile" - - target = self._build["target"] - - if sys.platform in ("win32", "cygwin"): - target = target + ".exe" - - mfile.write("TARGET = %s\n" % target) - mfile.write("OFILES = %s\n" % self._build["objects"]) - mfile.write("HFILES = %s\n" % self._build["headers"]) - mfile.write("\n") - - Makefile.generate_macros_and_rules(self, mfile) - - def generate_target_default(self, mfile): - """Generate the default target. - - mfile is the file object. - """ - mfile.write("\n$(TARGET): $(OFILES)\n") - - if self.generator in ("MSVC", "MSVC.NET"): - mfile.write("\t$(LINK) $(LFLAGS) /OUT:$(TARGET) @<<\n") - mfile.write("\t $(OFILES) $(LIBS)\n") - mfile.write("<<\n") - - if "embed_manifest_dll" in self.optional_list("CONFIG"): - mfile.write("\tmt -nologo -manifest $(TARGET).manifest -outputresource:$(TARGET);1\n") - elif self.generator == "BMAKE": - mfile.write("\t$(LINK) @&&|\n") - mfile.write("\t$(LFLAGS) $(OFILES) ,$(TARGET),,$(LIBS),,\n") - mfile.write("|\n") - else: - mfile.write("\t$(LINK) $(LFLAGS) -o $(TARGET) $(OFILES) $(LIBS)\n") - - mfile.write("\n$(OFILES): $(HFILES)\n") - - for mf in string.split(self._build["moc_headers"]): - root, discard = os.path.splitext(mf) - cpp = "moc_" + root + ".cpp" - - mfile.write("\n%s: %s\n" % (cpp, mf)) - mfile.write("\t$(MOC) -o %s %s\n" % (cpp, mf)) - - def generate_target_install(self, mfile): - """Generate the install target. - - mfile is the file object. - """ - if self._install_dir is None: - self._install_dir = self.config.default_bin_dir - - mfile.write("\ninstall: $(TARGET)\n") - self.install_file(mfile, "$(TARGET)", self._install_dir) - - def generate_target_clean(self, mfile): - """Generate the clean target. - - mfile is the file object. - """ - mfile.write("\nclean:\n") - self.clean_build_file_objects(mfile, self._build) - - -def _quote(s): - """Return a string surrounded by double quotes it if contains a space. - - s is the string. - """ - if string.find(s, " ") >= 0: - s = '"' + s + '"' - - return s - - -def version_to_string(v): - """Convert a 3 part version number encoded as a hexadecimal value to a - string. - """ - return "%u.%u.%u" % (((v >> 16) & 0xff), ((v >> 8) & 0xff), (v & 0xff)) - - -def read_version(filename, description, numdefine=None, strdefine=None): - """Read the version information for a package from a file. The information - is specified as #defines of a numeric (hexadecimal or decimal) value and/or - a string value. - - filename is the name of the file. - description is the descriptive name of the package. - numdefine is the name of the #define of the numeric version. It is ignored - if it is None. - strdefine is the name of the #define of the string version. It is ignored - if it is None. - - Returns a tuple of the version as a number and as a string. - """ - need_num = numdefine is not None - need_str = strdefine is not None - - vers = None - versstr = None - - f = open(filename) - l = f.readline() - - while l and (need_num or need_str): - wl = string.split(l) - if len(wl) >= 3 and wl[0] == "#define": - if need_num and wl[1] == numdefine: - v = wl[2] - - if v[0:2] == "0x": - vers = string.atoi(v,16) - else: - dec = int(v) - maj = dec / 100 - min = (dec % 100) / 10 - bug = (dec % 10) - vers = (maj << 16) + (min << 8) + bug - - need_num = 0 - - if need_str and wl[1] == strdefine: - # Take account of embedded spaces. - versstr = string.join(wl[2:])[1:-1] - need_str = 0 - - l = f.readline() - - f.close() - - if need_num or need_str: - error("The %s version number could not be determined by parsing %s." % (description, filename)) - - return (vers, versstr) - - -def create_content(dict, macros=None): - """Convert a dictionary to a string (typically to use as the content to a - call to create_config_module()). Dictionary values that are strings are - quoted. Dictionary values that are lists are converted to quoted strings. - - dict is the dictionary. - macros is the optional dictionary of platform specific build macros. - """ - content = "_pkg_config = {\n" - - keys = dict.keys() - keys.sort() - - # Format it nicely. - width = 0 - - for k in keys: - klen = len(k) - - if width < klen: - width = klen - - for k in keys: - val = dict[k] - vtype = type(val) - - if val is None: - val = "None" - elif vtype == types.ListType: - val = "'" + string.join(val) + "'" - elif vtype == types.StringType: - val = "'" + val + "'" - elif vtype == types.IntType: - if string.find(k, "version") >= 0: - # Assume it's a hexadecimal version number. It doesn't matter - # if it isn't, we are just trying to make it look pretty. - val = "0x%06x" % val - else: - val = str(val) - else: - val = "'" + str(val) + "'" - - content = content + " '" + k + "':" + (" " * (width - len(k) + 2)) + string.replace(val, "\\", "\\\\") - - if k != keys[-1]: - content = content + "," - - content = content + "\n" - - content = content + "}\n\n" - - # Format the optional macros. - content = content + "_default_macros = " - - if macros: - content = content + "{\n" - - names = macros.keys() - names.sort() - - width = 0 - for c in names: - clen = len(c) - if width < clen: - width = clen - - for c in names: - if c == names[-1]: - sep = "" - else: - sep = "," - - k = "'" + c + "':" - content = content + " %-*s '%s'%s\n" % (1 + width + 2, k, string.replace(macros[c], "\\", "\\\\"), sep) - - content = content + "}\n" - else: - content = content + "None\n" - - return content - - -def create_config_module(module, template, content, macros=None): - """Create a configuration module by replacing "@" followed by - "SIP_CONFIGURATION" followed by "@" in a template file with a content - string. - - module is the name of the module file. - template is the name of the template file. - content is the content string. If it is a dictionary it is first converted - to a string using create_content(). - macros is an optional dictionary of platform specific build macros. It is - only used if create_content() is called to convert the content to a string. - """ - if type(content) == types.DictType: - content = create_content(content, macros) - - # Allow this file to used as a template. - key = "@" + "SIP_CONFIGURATION" + "@" - - df = open(module, "w") - sf = open(template, "r") - - line = sf.readline() - while line: - if string.find(line, key) >= 0: - line = content - - df.write(line) - - line = sf.readline() - - -def version_to_sip_tag(version, tags, description): - """Convert a version number to a SIP tag. - - version is the version number. If it is negative then the latest version - is assumed. (This is typically useful if a snapshot is indicated by a - negative version number.) - tags is the dictionary of tags keyed by version number. The tag used is - the one with the smallest key (ie. earliest version) that is greater than - the given version number. - description is the descriptive name of the package used for error messages. - - Returns the corresponding tag. - """ - vl = tags.keys() - vl.sort() - - # For a snapshot use the latest tag. - if version < 0: - tag = tags[vl[-1]] - else: - for v in vl: - if version < v: - tag = tags[v] - break - else: - error("Unsupported %s version: 0x%06x." % (description, version)) - - return tag - - -def error(msg): - """Display an error message and terminate. - - msg is the text of the error message. - """ - sys.stderr.write(format("Error: " + msg) + "\n") - sys.exit(1) - - -def inform(msg): - """Display an information message. - - msg is the text of the error message. - """ - sys.stdout.write(format(msg) + "\n") - - -def format(msg, leftmargin=0, rightmargin=78): - """Format a message by inserting line breaks at appropriate places. - - msg is the text of the message. - leftmargin is the position of the left margin. - rightmargin is the position of the right margin. - - Return the formatted message. - """ - curs = leftmargin - fmsg = " " * leftmargin - - for w in string.split(msg): - l = len(w) - if curs != leftmargin and curs + l > rightmargin: - fmsg = fmsg + "\n" + (" " * leftmargin) - curs = leftmargin - - if curs > leftmargin: - fmsg = fmsg + " " - curs = curs + 1 - - fmsg = fmsg + w - curs = curs + l - - return fmsg - - -def parse_build_macros(filename, names, overrides=None, properties=None): - """Parse a qmake compatible file of build system macros and convert it to a - dictionary. A macro is a name/value pair. The dictionary is returned or - None if any of the overrides was invalid. - - filename is the name of the file to parse. - names is a list of the macro names to extract from the file. - overrides is an optional list of macro names and values that modify those - found in the file. They are of the form "name=value" (in which case the - value replaces the value found in the file) or "name+=value" (in which case - the value is appended to the value found in the file). - properties is an optional dictionary of property name and values that are - used to resolve any expressions of the form "$[name]" in the file. - """ - # Validate and convert the overrides to a dictionary. - orides = {} - - if overrides is not None: - for oride in overrides: - prefix = "" - name_end = string.find(oride, "+=") - - if name_end >= 0: - prefix = "+" - val_start = name_end + 2 - else: - name_end = string.find(oride, "=") - - if name_end >= 0: - val_start = name_end + 1 - else: - return None - - name = oride[:name_end] - - if name not in names: - return None - - orides[name] = prefix + oride[val_start:] - - # This class defines a file like object that handles the nested include() - # directives in qmake files. - class qmake_build_file_reader: - def __init__(self, filename): - self.filename = filename - self.currentfile = None - self.filestack = [] - self.pathstack = [] - self.cond_fname = None - self._openfile(filename) - - def _openfile(self, filename): - try: - f = open(filename, 'r') - except IOError, detail: - # If this file is conditional then don't raise an error. - if self.cond_fname == filename: - return - - error("Unable to open %s: %s" % (filename, detail)) - - if self.currentfile: - self.filestack.append(self.currentfile) - self.pathstack.append(self.path) - - self.currentfile = f - self.path = os.path.dirname(filename) - - def readline(self): - line = self.currentfile.readline() - sline = line.strip() - - if self.cond_fname and sline == '}': - # The current condition is closed. - self.cond_fname = None - line = self.currentfile.readline() - elif sline.startswith('exists(') and sline.endswith('{'): - # A new condition is opened so extract the filename. - self.cond_fname = self._normalise(sline[:-1].strip()[7:-1].strip()) - line = self.currentfile.readline() - elif sline.startswith('include('): - nextfile = self._normalise(sline[8:-1].strip()) - self._openfile(nextfile) - return self.readline() - - if not line and self.filestack: - self.currentfile = self.filestack.pop() - self.path = self.pathstack.pop() - return self.readline() - - return line - - # Normalise a filename by expanding any environment variables and - # making sure it is absolute. - def _normalise(self, fname): - if "$(" in fname: - fname = os.path.normpath(self._expandvars(fname)) - - if not os.path.isabs(fname): - fname = os.path.join(self.path, fname) - - return fname - - # Expand the environment variables in a filename. - def _expandvars(self, fname): - i = 0 - while True: - m = re.search(r'\$\((\w+)\)', fname[i:]) - if not m: - break - - i, j = m.span(0) - name = m.group(1) - if name in os.environ: - tail = fname[j:] - fname = fname[:i] + os.environ[name] - i = len(fname) - fname += tail - else: - i = j - - return fname - - f = qmake_build_file_reader(filename) - - # Get everything into a dictionary. - raw = { - "DIR_SEPARATOR": os.sep, - "LITERAL_WHITESPACE": " ", - "LITERAL_DOLLAR": "$", - "LITERAL_HASH": "#" - } - - line = f.readline() - while line: - # Handle line continuations. - while len(line) > 1 and line[-2] == "\\": - line = line[:-2] - - next = f.readline() - - if next: - line = line + next - else: - break - - line = string.strip(line) - - # Ignore comments. - if line and line[0] != "#": - assstart = string.find(line, "+") - if assstart > 0 and line[assstart + 1] == '=': - assend = assstart + 1 - else: - assstart = string.find(line, "=") - assend = assstart - - if assstart > 0: - lhs = string.strip(line[:assstart]) - rhs = string.strip(line[assend + 1:]) - - raw[lhs] = rhs - - line = f.readline() - - # Go through the raw dictionary extracting the macros we need and - # resolving any macro expansions. First of all, make sure every macro has - # a value. - refined = {} - - for m in names: - refined[m] = "" - - macro_prefix = "QMAKE_" - - for lhs in raw.keys(): - # Strip any prefix. - if string.find(lhs, macro_prefix) == 0: - reflhs = lhs[len(macro_prefix):] - else: - reflhs = lhs - - # See if we are interested in this one. - if reflhs not in names: - continue - - rhs = raw[lhs] - - # Resolve any references. - estart = string.find(rhs, "$$(") - mstart = string.find(rhs, "$$") - - while mstart >= 0 and mstart != estart: - rstart = mstart + 2 - if rstart < len(rhs) and rhs[rstart] == "{": - rstart = rstart + 1 - term = "}" - elif rstart < len(rhs) and rhs[rstart] == "[": - rstart = rstart + 1 - term = "]" - else: - term = string.whitespace - - mend = rstart - while mend < len(rhs) and rhs[mend] not in term: - mend = mend + 1 - - lhs = rhs[rstart:mend] - - if term in "}]": - mend = mend + 1 - - if term == "]": - if properties is None or lhs not in properties.keys(): - error("%s: property '%s' is not defined." % (filename, lhs)) - - value = properties[lhs] - else: - try: - value = raw[lhs] - except KeyError: - error("%s: macro '%s' is not defined." % (filename, lhs)) - - rhs = rhs[:mstart] + value + rhs[mend:] - estart = string.find(rhs, "$$(") - mstart = string.find(rhs, "$$") - - # Expand any POSIX style environment variables. - pleadin = ["$$(", "$("] - - for pl in pleadin: - estart = string.find(rhs, pl) - - if estart >= 0: - nstart = estart + len(pl) - break - else: - estart = -1 - - while estart >= 0: - eend = string.find(rhs[nstart:], ")") - - if eend < 0: - break - - eend = nstart + eend - - name = rhs[nstart:eend] - - try: - env = os.environ[name] - except KeyError: - env = "" - - rhs = rhs[:estart] + env + rhs[eend + 1:] - - for pl in pleadin: - estart = string.find(rhs, pl) - - if estart >= 0: - nstart = estart + len(pl) - break - else: - estart = -1 - - # Expand any Windows style environment variables. - estart = string.find(rhs, "%") - - while estart >= 0: - eend = string.find(rhs[estart + 1:], "%") - - if eend < 0: - break - - eend = estart + 1 + eend - - name = rhs[estart + 1:eend] - - try: - env = os.environ[name] - except KeyError: - env = "" - - rhs = rhs[:estart] + env + rhs[eend + 1:] - - estart = string.find(rhs, "%") - - refined[reflhs] = rhs - - # Handle the user overrides. - for lhs in orides.keys(): - rhs = refined[lhs] - oride = orides[lhs] - - if string.find(oride, "+") == 0: - if rhs: - rhs = rhs + " " + oride[1:] - else: - rhs = oride[1:] - else: - rhs = oride - - refined[lhs] = rhs - - return refined - - -def create_wrapper(script, wrapper, gui=0): - """Create a platform dependent executable wrapper around a Python script. - - script is the full pathname of the script. - wrapper is the name of the wrapper file to create. - gui is non-zero if a GUI enabled version of the interpreter should be used. - - Returns the platform specific name of the wrapper. - """ - if sys.platform == "win32": - wrapper = wrapper + ".bat" - - wf = open(wrapper, "w") - - if sys.platform == "win32": - exe = sys.executable - - if gui: - exe = exe[:-4] + "w.exe" - - wf.write("@\"%s\" \"%s\" %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9\n" % (exe, script)) - elif sys.platform == "darwin": - # python, pythonw and sys.executable are all different images. We - # would prefer to use the latter (because it includes the version - # number) but that would mean being unable to support the "gui" - # argument. - if gui: - exe = "pythonw" - else: - exe = "python" - - wf.write("exec %s %s ${1+\"$@\"}\n" % (exe, script)) - else: - wf.write("exec %s %s ${1+\"$@\"}\n" % (sys.executable, script)) - - wf.close() - - if sys.platform != "win32": - sbuf = os.stat(wrapper) - mode = sbuf.st_mode - mode |= (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) - - os.chmod(wrapper, mode) - - return wrapper diff --git a/python/sip/specs/aix-g++ b/python/sip/specs/aix-g++ deleted file mode 100644 index 438185a6..00000000 --- a/python/sip/specs/aix-g++ +++ /dev/null @@ -1,79 +0,0 @@ -# -# qmake configuration for aix-g++ -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -mpowerpc -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -D_THREAD_SAFE - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -QMAKE_LFLAGS_THREAD = -L/usr/lib/threads -QMAKE_AIX_SHLIB = 1 - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthreads - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/aix-g++-64 b/python/sip/specs/aix-g++-64 deleted file mode 100644 index 231f3dd3..00000000 --- a/python/sip/specs/aix-g++-64 +++ /dev/null @@ -1,79 +0,0 @@ -# -# qmake configuration for aix-g++-64 -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -maix64 -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -D_THREAD_SAFE - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -maix64 -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -QMAKE_LFLAGS_THREAD = -L/usr/lib/threads -QMAKE_AIX_SHLIB = 1 - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthreads - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar -X64 cq -QMAKE_RANLIB = ranlib -X64 - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/aix-xlc b/python/sip/specs/aix-xlc deleted file mode 100644 index fd288a36..00000000 --- a/python/sip/specs/aix-xlc +++ /dev/null @@ -1,82 +0,0 @@ -# -# qmake configuration for aix-xlc -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = xlc -QMAKE_CC_THREAD = xlc_r -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -qstrict -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -QMAKE_CFLAGS_RELEASE = -O3 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -qthreaded - -QMAKE_CXX = xlC -QMAKE_CXX_THREAD = xlC_r -QMAKE_CXXFLAGS = -+ $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = -QMAKE_LIBDIR_X11 = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = xlC -QMAKE_LINK_THREAD = xlC_r -QMAKE_LINK_SHLIB = ld -QMAKE_LINK_SHLIB_CMD = makeC++SharedLib -p 0 \ - -o $(TARGET) $(LFLAGS) $(OBJECTS) $(OBJMOC) $(LIBS) -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -QMAKE_LFLAGS_THREAD = -L/usr/lib/threads -QMAKE_AIX_SHLIB = 1 - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthreads - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cq -QMAKE_RANLIB = ranlib - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/aix-xlc-64 b/python/sip/specs/aix-xlc-64 deleted file mode 100644 index 56501e75..00000000 --- a/python/sip/specs/aix-xlc-64 +++ /dev/null @@ -1,84 +0,0 @@ -# -# qmake configuration for aix-xlc -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = xlc -QMAKE_CC_THREAD = xlc_r -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -qstrict -q64 -# -qwarn64 turns on too many bogus warnings and shadows real warnings -#QMAKE_CFLAGS_WARN_ON = -qwarn64 -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -QMAKE_CFLAGS_RELEASE = -O3 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -qthreaded - -QMAKE_CXX = xlC -QMAKE_CXX_THREAD = xlC_r -QMAKE_CXXFLAGS = -+ $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = -QMAKE_LIBDIR_X11 = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = xlC -QMAKE_LINK_THREAD = xlC_r -QMAKE_LINK_SHLIB = ld -QMAKE_LINK_SHLIB_CMD = makeC++SharedLib -p 0 -X 64 \ - -o $(TARGET) $(LFLAGS) $(OBJECTS) $(OBJMOC) $(LIBS) -QMAKE_LFLAGS = -q64 -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -QMAKE_LFLAGS_THREAD = -L/usr/lib/threads -QMAKE_AIX_SHLIB = 1 - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthreads - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar -X64 cq -QMAKE_RANLIB = ranlib -X64 - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/bsdi-g++ b/python/sip/specs/bsdi-g++ deleted file mode 100644 index e1a43a05..00000000 --- a/python/sip/specs/bsdi-g++ +++ /dev/null @@ -1,84 +0,0 @@ -# -# $Id$ -# -# qmake configuration for bsdi-g++ -# -# Written for WindRiver BSD/OS 4.0. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $(QTDIR)/include -QMAKE_LIBDIR_QT = $(QTDIR)/lib -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_QT = -lqt -QMAKE_LIBS_QT_THREAD = -lqt-mt -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXmu -QMAKE_LIBS_OPENGL_QT = -lGL -lXmu -QMAKE_LIBS_THREAD = - -QMAKE_MOC = $(QTDIR)/bin/moc -QMAKE_UIC = $(QTDIR)/bin/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p diff --git a/python/sip/specs/cygwin-g++ b/python/sip/specs/cygwin-g++ deleted file mode 100644 index d045bce8..00000000 --- a/python/sip/specs/cygwin-g++ +++ /dev/null @@ -1,86 +0,0 @@ -# -# $Id$ -# -# qmake configuration for cygwin-g++ -# -# Written for Qt/X11 on Cygwin, using the POSIX API. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release incremental link_prl -QMAKE_INCREMENTAL_STYLE = sublib - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = byacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -pipe -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -D_REENTRANT - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $(QTDIR)/include -QMAKE_LIBDIR_QT = $(QTDIR)/lib -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,-rpath, -QMAKE_CYGWIN_SHLIB = 1 -QMAKE_CYGWIN_EXE = 1 - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_QT = -lqt -QMAKE_LIBS_QT_THREAD = -lqt-mt -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXmu -QMAKE_LIBS_OPENGL_QT = -lGL -lXmu -QMAKE_LIBS_THREAD = -lpthread - -QMAKE_MOC = $(QTDIR)/bin/moc -QMAKE_UIC = $(QTDIR)/bin/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p diff --git a/python/sip/specs/darwin-g++ b/python/sip/specs/darwin-g++ deleted file mode 100644 index 11e62dc7..00000000 --- a/python/sip/specs/darwin-g++ +++ /dev/null @@ -1,89 +0,0 @@ -# -# qmake configuration for darwin-g++ -# -# Written for Qt/X11 on Darwin and XFree86 -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl native_precompiled_headers -QT += core gui -DEFINES += __USE_WS_X11__ - -QMAKE_CC = cc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -pipe -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_EXTENSION_SHLIB = dylib -QMAKE_EXTENSION_PLUGIN = so -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = - -QMAKE_CXX = c++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = - -QMAKE_INCDIR = /usr/local/include -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = c++ -QMAKE_LINK_SHLIB = c++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_APP = -prebind -QMAKE_LFLAGS_SHLIB = -prebind -dynamiclib -single_module -headerpad_max_install_names -QMAKE_LFLAGS_PLUGIN = -bundle -QMAKE_LFLAGS_THREAD = - -QMAKE_LFLAGS_VERSION = -current_version$${LITERAL_WHITESPACE} -QMAKE_LFLAGS_COMPAT_VERSION = -compatibility_version$${LITERAL_WHITESPACE} - -QMAKE_RPATH = - -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cq -QMAKE_RANLIB = ranlib -s - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_COPY_FILE = $$QMAKE_COPY -QMAKE_COPY_DIR = $$QMAKE_COPY -r -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/dgux-g++ b/python/sip/specs/dgux-g++ deleted file mode 100644 index 8267828a..00000000 --- a/python/sip/specs/dgux-g++ +++ /dev/null @@ -1,77 +0,0 @@ -# -# $Id$ -# -# qmake configuration for dgux-g++ -# -# Written for DG/UX R4.20MU06. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $(QTDIR)/include -QMAKE_LIBDIR_QT = $(QTDIR)/lib -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-h, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_QT = -lqt - -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXmu -QMAKE_LIBS_OPENGL_QT = -lGL -lXmu - -QMAKE_MOC = $(QTDIR)/bin/moc -QMAKE_UIC = $(QTDIR)/bin/uic - -QMAKE_AR = ar cq -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p diff --git a/python/sip/specs/freebsd-g++ b/python/sip/specs/freebsd-g++ deleted file mode 100644 index 7a424109..00000000 --- a/python/sip/specs/freebsd-g++ +++ /dev/null @@ -1,80 +0,0 @@ -# -# qmake configuration for freebsd-g++ -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -pipe -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -pthread -D_THREAD_SAFE - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -# Addon software goes into /usr/local on the BSDs, by default we will look there -QMAKE_INCDIR = /usr/local/include -QMAKE_LIBDIR = /usr/local/lib -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -pthread -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/freebsd-g++34 b/python/sip/specs/freebsd-g++34 deleted file mode 100644 index 24c77866..00000000 --- a/python/sip/specs/freebsd-g++34 +++ /dev/null @@ -1,80 +0,0 @@ -# -# qmake configuration for freebsd-g++34 (using g++34 from ports/lang/gcc34) -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = gcc34 -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -pipe -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -pthread -D_THREAD_SAFE - -QMAKE_CXX = g++34 -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -# Addon software goes into /usr/local on the BSDs, by default we will look there -QMAKE_INCDIR = /usr/local/include -QMAKE_LIBDIR = /usr/local/lib -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = g++34 -QMAKE_LINK_SHLIB = g++34 -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -pthread -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/freebsd-g++40 b/python/sip/specs/freebsd-g++40 deleted file mode 100644 index cb8f58ef..00000000 --- a/python/sip/specs/freebsd-g++40 +++ /dev/null @@ -1,80 +0,0 @@ -# -# qmake configuration for freebsd-g++40 (using g++40 from ports/lang/gcc40) -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = gcc40 -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -pipe -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -pthread -D_THREAD_SAFE - -QMAKE_CXX = g++40 -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -# Addon software goes into /usr/local on the BSDs, by default we will look there -QMAKE_INCDIR = /usr/local/include -QMAKE_LIBDIR = /usr/local/lib -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = g++40 -QMAKE_LINK_SHLIB = g++40 -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -pthread -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/freebsd-icc b/python/sip/specs/freebsd-icc deleted file mode 100644 index 71d08b79..00000000 --- a/python/sip/specs/freebsd-icc +++ /dev/null @@ -1,105 +0,0 @@ -# -# qmake configuration for freebsd-icc -# -# Written for Intel C++ 7.1 and 8.0 on FreeBSD -# -# Note: Some of the remarks from the Intel compiler are disabled (even -# with 'warn_on' specified): -# -# remark #171: invalid type conversion: "int" to "void *" -# remark #193: zero used for undefined preprocessing identifier -# remark #279: controlling expression is constant -# remark #304: access control not specified ("public" by default) -# remark #310: old-style parameter list (anachronism) -# remark #383: value copied to temporary, reference to temporary used -# remark #424: extra ";" ignored -# remark #444: destructor for base class "Class" is not virtual -# remark #488: template parameter "T" is not used in declaring the parameter -# types of function template "function" -# remark #810: conversion from "type1" to "type2" may loose significant bits -# remark #858: type qualifier on return type is meaningless -# remark #967: conversion from "type1" to "type2"; sizes do not match -# remark #981: operands are evaluated in unspecified order -# remark #1418: external definition with no prior declaration -# remark #1419: external declaration in primary source file -# warning #1476: field uses tail padding of a base class -# warning #1477: GNU C++ compilers may use bit field padding -# warning #1572: floating-point equality and inequality comparisons are unreliable -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = icc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -wd858,1572 -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -w2 -wd171,193,279,304,310,383,424,444,488,810,967,981,1418,1419,1476,1477 -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -KPIC -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -D_THREAD_SAFE - -QMAKE_CXX = icpc -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -# Addon software goes into /usr/local on the BSDs, by default we will look there -QMAKE_INCDIR = /usr/local/include -QMAKE_LIBDIR = /usr/local/lib -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = icpc -QMAKE_LINK_SHLIB = icpc -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Qoption,ld,-soname, -QMAKE_LFLAGS_THREAD = -mt -QMAKE_RPATH = -Qoption,ld,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/hpux-acc b/python/sip/specs/hpux-acc deleted file mode 100644 index 0a78d972..00000000 --- a/python/sip/specs/hpux-acc +++ /dev/null @@ -1,103 +0,0 @@ -# -# qmake configuration for hpux-acc -# -# We define _POSIX_C_SOURCE to 199506L when using threads, therefore -# we also need to redefine _HPUX_SOURCE. See pthread(3t) for more details. -# -# From the "HP aC++ Online Programmer's Guide": -# Using +DS to Specify Instruction Scheduling: -# * By default, the compiler performs scheduling tuned for the system -# on which you are compiling, or, if specified, tuned for the setting -# of the +DA option. -# -# From the online "C/HP-UX Reference Manual": -# -Aa -# Enables strict ANSI C compliance. -# -Ae -# Enables ANSI C compliance, HP value-added features (as described -# for +e option), and _HPUX_SOURCE name space macro. It is equivalent -# to -Aa +e -D_HPUX_SOURCE. -# +e -# Enables the following HP value added features while compiling in -# ANSI C mode: sized enum, long long, long pointers, compiler supplied -# defaults for missing arguments to intrinsic calls, and $ in identifier -# HP C extensions. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = cc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -Ae +DAportable -w -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = +O1 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = +Z -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -D_POSIX_C_SOURCE=199506L -D_HPUX_SOURCE - -QMAKE_CXX = aCC -QMAKE_CXXFLAGS = -AA +DAportable -w -D__STRICT_ANSI__ -D_HPUX_SOURCE -QMAKE_CXXFLAGS_DEPS = +M -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = -D_POSIX_C_SOURCE=199506L - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/include/X11R6 -QMAKE_LIBDIR_X11 = /usr/lib/X11R6 -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /opt/graphics/OpenGL/include /usr/contrib/X11R6/include -QMAKE_LIBDIR_OPENGL = /opt/graphics/OpenGL/lib /usr/contrib/X11R6/lib - -QMAKE_LINK = aCC -QMAKE_LINK_SHLIB = aCC -QMAKE_LFLAGS = -AA +DAportable -Wl,+s -QMAKE_LFLAGS_RELEASE = -O -QMAKE_LFLAGS_DEBUG = -g -QMAKE_LFLAGS_SHLIB = -b -Wl,-a,shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,+h, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,+b, -QMAKE_HPUX_SHLIB = 1 -QMAKE_EXTENSION_SHLIB = sl - -QMAKE_LIBS = -lm -QMAKE_LIBS_DYNLOAD = -ldld -QMAKE_LIBS_X11 = -lXext -lX11 -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXt -QMAKE_LIBS_OPENGL_QT = -lGL -lXt -QMAKE_LIBS_THREAD = -lpthread -QMAKE_LIBS_YACC = -ly - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/hpux-acc-64 b/python/sip/specs/hpux-acc-64 deleted file mode 100644 index 083c4038..00000000 --- a/python/sip/specs/hpux-acc-64 +++ /dev/null @@ -1,124 +0,0 @@ -# -# qmake configuration for hpux-n64 -# -# We define _POSIX_C_SOURCE to 199506L when using threads, therefore -# we also need to redefine _HPUX_SOURCE. -# From pthread(3t): -# Some documentation will recommend the use of -D_REENTRANT for -# compilation. While this also functions properly, it is considered -# an obsolescent form. -# See pthread(3t) for more details. -# -# From the "HP aC++ Online Programmer's Guide": -# When +DA2.0W is specified: -# * 64-bit SVR4 Executable and Linking Format (ELF) object files -# are generated for PA-RISC 2.0. -# * The preprocessor predefined macro, __LP64__ is defined. -# * The correct path for 64-bit system and language libraries is -# selected. -# When +DD32 is specified: -# * The size of an int, long, or pointer data type is 32-bits. -# The size of an int data type is 32-bits. The size of a long or -# pointer data type is 64-bits. -# * This is the default, currently equivalent to +DA1.1 architecture. -# When +DD64 is specified: -# * The size of an int data type is 32-bits. The size of a long or -# pointer data type is 64-bits. -# * This is currently equivalent to +DA2.OW architecture. -# * The preprocessor predefined macro, __LP64__ is defined. -# Using +DS to Specify Instruction Scheduling: -# * By default, the compiler performs scheduling tuned for the system -# on which you are compiling, or, if specified, tuned for the setting -# of the +DA option. -# -# From the online "C/HP-UX Reference Manual": -# -Aa -# Enables strict ANSI C compliance. -# -Ae -# Enables ANSI C compliance, HP value-added features (as described -# for +e option), and _HPUX_SOURCE name space macro. It is equivalent -# to -Aa +e -D_HPUX_SOURCE. -# +e -# Enables the following HP value added features while compiling in -# ANSI C mode: sized enum, long long, long pointers, compiler supplied -# defaults for missing arguments to intrinsic calls, and $ in identifier -# HP C extensions. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = cc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -Ae +DA2.0W -w -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = +O1 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = +Z -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -D_POSIX_C_SOURCE=199506L -D_HPUX_SOURCE - -QMAKE_CXX = aCC -QMAKE_CXXFLAGS = -AA +DA2.0W -w -D__STRICT_ANSI__ -D_HPUX_SOURCE -QMAKE_CXXFLAGS_DEPS = +M -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = -D_POSIX_C_SOURCE=199506L - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/include/X11R6 -QMAKE_LIBDIR_X11 = /usr/lib/X11R6/pa20_64 -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /opt/graphics/OpenGL/include /usr/contrib/X11R6/include -QMAKE_LIBDIR_OPENGL = /opt/graphics/OpenGL/lib/pa20_64 /usr/contrib/X11R6/lib/pa20_64 - -QMAKE_LINK = aCC -QMAKE_LINK_SHLIB = aCC -QMAKE_LFLAGS = -AA +DA2.0W -Wl,+s -QMAKE_LFLAGS_RELEASE = -O -QMAKE_LFLAGS_DEBUG = -g -QMAKE_LFLAGS_SHLIB = -b -Wl,-a,shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,+h, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,+b, -QMAKE_HPUX_SHLIB = 3 -QMAKE_EXTENSION_SHLIB = sl - -QMAKE_LIBS = -lm -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXt -QMAKE_LIBS_OPENGL_QT = -lGL -lXt -QMAKE_LIBS_THREAD = -lpthread -QMAKE_LIBS_YACC = -ly - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/hpux-acc-o64 b/python/sip/specs/hpux-acc-o64 deleted file mode 100644 index e6739a70..00000000 --- a/python/sip/specs/hpux-acc-o64 +++ /dev/null @@ -1,123 +0,0 @@ -# -# qmake configuration for hpux-o64 -# -# We define _POSIX_C_SOURCE to 199506L when using threads, therefore -# we also need to redefine _HPUX_SOURCE. -# From pthread(3t): -# Some documentation will recommend the use of -D_REENTRANT for -# compilation. While this also functions properly, it is considered -# an obsolescent form. -# See pthread(3t) for more details. -# -# From the "HP aC++ Online Programmer's Guide": -# When +DA2.0W is specified: -# * 64-bit SVR4 Executable and Linking Format (ELF) object files -# are generated for PA-RISC 2.0. -# * The preprocessor predefined macro, __LP64__ is defined. -# * The correct path for 64-bit system and language libraries is -# selected. -# When +DD32 is specified: -# * The size of an int, long, or pointer data type is 32-bits. -# The size of an int data type is 32-bits. The size of a long or -# pointer data type is 64-bits. -# * This is the default, currently equivalent to +DA1.1 architecture. -# When +DD64 is specified: -# * The size of an int data type is 32-bits. The size of a long or -# pointer data type is 64-bits. -# * This is currently equivalent to +DA2.OW architecture. -# * The preprocessor predefined macro, __LP64__ is defined. -# Using +DS to Specify Instruction Scheduling: -# * By default, the compiler performs scheduling tuned for the system -# on which you are compiling, or, if specified, tuned for the setting -# of the +DA option. -# -# From the online "C/HP-UX Reference Manual": -# -Aa -# Enables strict ANSI C compliance. -# -Ae -# Enables ANSI C compliance, HP value-added features (as described -# for +e option), and _HPUX_SOURCE name space macro. It is equivalent -# to -Aa +e -D_HPUX_SOURCE. -# +e -# Enables the following HP value added features while compiling in -# ANSI C mode: sized enum, long long, long pointers, compiler supplied -# defaults for missing arguments to intrinsic calls, and $ in identifier -# HP C extensions. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = cc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -Ae +DA2.0 -w -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -QMAKE_CFLAGS_RELEASE = -O +Oentrysched +Onolimit -QMAKE_CFLAGS_DEBUG = -y -g -QMAKE_CFLAGS_SHLIB = +Z -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -D_POSIX_C_SOURCE=199506L -D_HPUX_SOURCE - -QMAKE_CXX = aCC -QMAKE_CXXFLAGS = +DA2.0 -w -D__STRICT_ANSI__ -D_HPUX_SOURCE -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = -g -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = -D_POSIX_C_SOURCE=199506L - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/include/X11R6 -QMAKE_LIBDIR_X11 = /usr/lib/X11R6 -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /opt/graphics/OpenGL/include /usr/contrib/X11R6/include -QMAKE_LIBDIR_OPENGL = /opt/graphics/OpenGL/lib /usr/contrib/X11R6/lib - -QMAKE_LINK = aCC -QMAKE_LINK_SHLIB = aCC -QMAKE_LFLAGS = +DA2.0 -Wl,+s -QMAKE_LFLAGS_RELEASE = -O -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -b -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,+h, -QMAKE_RPATH = -Wl,+b, -QMAKE_HPUX_SHLIB = 2 -QMAKE_EXTENSION_SHLIB = sl - -QMAKE_LIBS = -lm -QMAKE_LIBS_DYNLOAD = -ldld -QMAKE_LIBS_X11 = -lXext -lX11 -QMAKE_LIBS_X11SM = -lSM -lICE - -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread -QMAKE_LIBS_YACC = -ly - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/hpux-cc b/python/sip/specs/hpux-cc deleted file mode 100644 index 4ccc1316..00000000 --- a/python/sip/specs/hpux-cc +++ /dev/null @@ -1,100 +0,0 @@ -# -# $Id$ -# -# qmake configuration for hpux-cc -# -# We define _POSIX_C_SOURCE to 199506L when using threads, therefore -# we also need to redefine _HPUX_SOURCE. -# See pthread(3t) for more details. -# -# From the "HP aC++ Online Programmer's Guide": -# Using +DS to Specify Instruction Scheduling: -# * By default, the compiler performs scheduling tuned for the system -# on which you are compiling, or, if specified, tuned for the setting -# of the +DA option. -# -# From the online "C/HP-UX Reference Manual": -# -Aa -# Enables strict ANSI C compliance. -# -Ae -# Enables ANSI C compliance, HP value-added features (as described -# for +e option), and _HPUX_SOURCE name space macro. It is equivalent -# to -Aa +e -D_HPUX_SOURCE. -# +e -# Enables the following HP value added features while compiling in -# ANSI C mode: sized enum, long long, long pointers, compiler supplied -# defaults for missing arguments to intrinsic calls, and $ in identifier -# HP C extensions. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl - -QMAKE_CC = cc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -Ae +DA1.1e -w -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -QMAKE_CFLAGS_RELEASE = -O -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = +Z -QMAKE_CFLAGS_YACC = - -QMAKE_CXX = CC -QMAKE_CXXFLAGS = +DA1.1e -w +a1 -D_HPUX_SOURCE -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/include/X11R6 -QMAKE_LIBDIR_X11 = /usr/lib/X11R6 -QMAKE_INCDIR_QT = $(QTDIR)/include -QMAKE_LIBDIR_QT = $(QTDIR)/lib -QMAKE_INCDIR_OPENGL = /opt/graphics/OpenGL/include /usr/contrib/X11R6/include -QMAKE_LIBDIR_OPENGL = /opt/graphics/OpenGL/lib /usr/contrib/X11R6/lib - -QMAKE_LINK = CC -QMAKE_LINK_SHLIB = CC -# CC generates template code during linking, and so needs -I's -QMAKE_LFLAGS = +DA1.1e -Wl,+s -L/usr/lib -I$$QMAKE_INCDIR_X11 -I$$QMAKE_INCDIR_QT -QMAKE_LFLAGS_RELEASE = -O -s -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -b -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,+h, -QMAKE_RPATH = -Wl,+b, -QMAKE_HPUX_SHLIB = 1 - -QMAKE_LIBS = -lm -QMAKE_LIBS_DYNLOAD = -ldld -QMAKE_LIBS_X11 = -lXext -lX11 -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_QT = -lqt - -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXmu -QMAKE_LIBS_OPENGL_QT = -lGL -lXmu - -QMAKE_MOC = $(QTDIR)/bin/moc -QMAKE_UIC = $(QTDIR)/bin/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p diff --git a/python/sip/specs/hpux-g++ b/python/sip/specs/hpux-g++ deleted file mode 100644 index 55339938..00000000 --- a/python/sip/specs/hpux-g++ +++ /dev/null @@ -1,85 +0,0 @@ -# -# qmake configuration for hpux-g++ -# -# We define _POSIX_C_SOURCE to 199506L when using threads, -# therefore we also need to redefine _HPUX_SOURCE. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl plugin_no_soname -QT += core gui - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -D_POSIX_C_SOURCE=199506L -D_HPUX_SOURCE - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -D_HPUX_SOURCE -DGLU_VERSION_1_2 -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = -D_POSIX_C_SOURCE=199506L - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = -QMAKE_LIBDIR_X11 = /usr/lib/X11R6 -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /opt/Mesa/include /usr/contrib/X11R6/include -QMAKE_LIBDIR_OPENGL = /opt/Mesa/lib /usr/contrib/X11R6/lib - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -Wl,+s -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -fPIC -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,+h, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,+b, -QMAKE_HPUX_SHLIB = 1 -QMAKE_EXTENSION_SHLIB = sl - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldld -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread -QMAKE_LIBS_YACC = -ly - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/hpux-g++-64 b/python/sip/specs/hpux-g++-64 deleted file mode 100644 index 0b81fcd7..00000000 --- a/python/sip/specs/hpux-g++-64 +++ /dev/null @@ -1,85 +0,0 @@ -# -# qmake configuration for hpux-g++-64 -# -# We define _POSIX_C_SOURCE to 199506L when using threads, -# therefore we also need to redefine _HPUX_SOURCE. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -D_POSIX_C_SOURCE=199506L -D_HPUX_SOURCE - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -D_HPUX_SOURCE -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = -D_POSIX_C_SOURCE=199506L - -QMAKE_INCDIR = -QMAKE_LIBDIR = /usr/lib/pa20_64 -QMAKE_INCDIR_X11 = /usr/include/X11R6 -QMAKE_LIBDIR_X11 = /usr/lib/X11R6/pa20_64 -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /opt/Mesa/include /usr/contrib/X11R6/include -QMAKE_LIBDIR_OPENGL = /opt/Mesa/lib/pa20_64 /usr/contrib/X11R6/lib/pa20_64 - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -Wl,+s -lpthread -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -fPIC -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,+h, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,+b, -QMAKE_HPUX_SHLIB = 3 -QMAKE_EXTENSION_SHLIB = sl - -QMAKE_LIBS = -lm -QMAKE_LIBS_DYNLOAD = -ldld -QMAKE_LIBS_X11 = -lXext -lX11 -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread -QMAKE_LIBS_YACC = -ly - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/hpuxi-acc b/python/sip/specs/hpuxi-acc deleted file mode 100644 index 1596ac2d..00000000 --- a/python/sip/specs/hpuxi-acc +++ /dev/null @@ -1,122 +0,0 @@ -# -# qmake configuration for hpuxi-acc-32 -# -# We define _POSIX_C_SOURCE to 199506L when using threads, therefore -# we also need to redefine _HPUX_SOURCE. -# From pthread(3t): -# Some documentation will recommend the use of -D_REENTRANT for -# compilation. While this also functions properly, it is considered -# an obsolescent form. -# See pthread(3t) for more details. -# -# From the "HP aC++ Online Programmer's Guide": -# When +DA2.0W is specified: -# * 64-bit SVR4 Executable and Linking Format (ELF) object files -# are generated for PA-RISC 2.0. -# * The preprocessor predefined macro, __LP64__ is defined. -# * The correct path for 64-bit system and language libraries is -# selected. -# When +DD32 is specified: -# * The size of an int, long, or pointer data type is 32-bits. -# The size of an int data type is 32-bits. The size of a long or -# pointer data type is 64-bits. -# * This is the default, currently equivalent to +DA1.1 architecture. -# When +DD64 is specified: -# * The size of an int data type is 32-bits. The size of a long or -# pointer data type is 64-bits. -# * This is currently equivalent to +DA2.OW architecture. -# * The preprocessor predefined macro, __LP64__ is defined. -# Using +DS to Specify Instruction Scheduling: -# * By default, the compiler performs scheduling tuned for the system -# on which you are compiling, or, if specified, tuned for the setting -# of the +DA option. -# -# From the online "C/HP-UX Reference Manual": -# -Aa -# Enables strict ANSI C compliance. -# -Ae -# Enables ANSI C compliance, HP value-added features (as described -# for +e option), and _HPUX_SOURCE name space macro. It is equivalent -# to -Aa +e -D_HPUX_SOURCE. -# +e -# Enables the following HP value added features while compiling in -# ANSI C mode: sized enum, long long, long pointers, compiler supplied -# defaults for missing arguments to intrinsic calls, and $ in identifier -# HP C extensions. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release plugin_no_soname -QT += core gui - -QMAKE_CC = cc -QMAKE_LEX = lex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = +DD32 +DSitanium -w -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = +O2 +Osize -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = +Z -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -D_POSIX_C_SOURCE=199506L -D_HPUX_SOURCE - -QMAKE_CXX = aCC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -D__STRICT_ANSI__ -D_HPUX_SOURCE -QMAKE_CXXFLAGS_DEPS = +M -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = -D_POSIX_C_SOURCE=199506L - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/include/X11R6 -QMAKE_LIBDIR_X11 = /usr/lib/hpux32/X11R6 -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /opt/graphics/OpenGL/include /usr/contrib/X11R6/include -QMAKE_LIBDIR_OPENGL = /opt/graphics/OpenGL/lib/hpux32 /usr/contrib/X11R6/lib/hpux32 - -QMAKE_LINK = aCC -QMAKE_LINK_SHLIB = aCC -QMAKE_LFLAGS = +DD32 +DSitanium -Wl,+s -QMAKE_LFLAGS_RELEASE = +O2 -QMAKE_LFLAGS_DEBUG = -g -QMAKE_LFLAGS_SHLIB = -b -Wl,-a,shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,+h, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = - -QMAKE_LIBS = -lm -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXt -QMAKE_LIBS_OPENGL_QT = -lGL -lXt -QMAKE_LIBS_THREAD = -lpthread -QMAKE_LIBS_YACC = -ly - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/hpuxi-acc-64 b/python/sip/specs/hpuxi-acc-64 deleted file mode 100644 index 0763d140..00000000 --- a/python/sip/specs/hpuxi-acc-64 +++ /dev/null @@ -1,122 +0,0 @@ -# -# qmake configuration for hpuxi-acc-64 -# -# We define _POSIX_C_SOURCE to 199506L when using threads, therefore -# we also need to redefine _HPUX_SOURCE. -# From pthread(3t): -# Some documentation will recommend the use of -D_REENTRANT for -# compilation. While this also functions properly, it is considered -# an obsolescent form. -# See pthread(3t) for more details. -# -# From the "HP aC++ Online Programmer's Guide": -# When +DA2.0W is specified: -# * 64-bit SVR4 Executable and Linking Format (ELF) object files -# are generated for PA-RISC 2.0. -# * The preprocessor predefined macro, __LP64__ is defined. -# * The correct path for 64-bit system and language libraries is -# selected. -# When +DD32 is specified: -# * The size of an int, long, or pointer data type is 32-bits. -# The size of an int data type is 32-bits. The size of a long or -# pointer data type is 64-bits. -# * This is the default, currently equivalent to +DA1.1 architecture. -# When +DD64 is specified: -# * The size of an int data type is 32-bits. The size of a long or -# pointer data type is 64-bits. -# * This is currently equivalent to +DA2.OW architecture. -# * The preprocessor predefined macro, __LP64__ is defined. -# Using +DS to Specify Instruction Scheduling: -# * By default, the compiler performs scheduling tuned for the system -# on which you are compiling, or, if specified, tuned for the setting -# of the +DA option. -# -# From the online "C/HP-UX Reference Manual": -# -Aa -# Enables strict ANSI C compliance. -# -Ae -# Enables ANSI C compliance, HP value-added features (as described -# for +e option), and _HPUX_SOURCE name space macro. It is equivalent -# to -Aa +e -D_HPUX_SOURCE. -# +e -# Enables the following HP value added features while compiling in -# ANSI C mode: sized enum, long long, long pointers, compiler supplied -# defaults for missing arguments to intrinsic calls, and $ in identifier -# HP C extensions. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release plugin_no_soname -QT += core gui - -QMAKE_CC = cc -QMAKE_LEX = lex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = +DD64 +DSitanium -w -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = +O2 +Osize -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = +Z -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -D_POSIX_C_SOURCE=199506L -D_HPUX_SOURCE - -QMAKE_CXX = aCC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -D__STRICT_ANSI__ -D_HPUX_SOURCE -QMAKE_CXXFLAGS_DEPS = +M -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = -D_POSIX_C_SOURCE=199506L - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/include/X11R6 -QMAKE_LIBDIR_X11 = /usr/lib/hpux64/X11R6 -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /opt/graphics/OpenGL/include /usr/contrib/X11R6/include -QMAKE_LIBDIR_OPENGL = /opt/graphics/OpenGL/lib/hpux64 /usr/contrib/X11R6/lib/hpux64 - -QMAKE_LINK = aCC -QMAKE_LINK_SHLIB = aCC -QMAKE_LFLAGS = +DD64 +DSitanium -Wl,+s -QMAKE_LFLAGS_RELEASE = +O2 -QMAKE_LFLAGS_DEBUG = -g -QMAKE_LFLAGS_SHLIB = -b -Wl,-a,shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,+h, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = - -QMAKE_LIBS = -lm -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXt -QMAKE_LIBS_OPENGL_QT = -lGL -lXt -QMAKE_LIBS_THREAD = -lpthread -QMAKE_LIBS_YACC = -ly - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/hurd-g++ b/python/sip/specs/hurd-g++ deleted file mode 100644 index 88539e81..00000000 --- a/python/sip/specs/hurd-g++ +++ /dev/null @@ -1,77 +0,0 @@ -# -# qmake configuration for hurd-g++ -# -# Submitted by uch@nop.or.jp as "gnu-g++". -# Renamed to "hurd-g++" because people were confusing GNU/Hurd with GNU/Linux. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -QT += core gui -CONFIG += qt warn_on release link_prl - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm - -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/irix-cc b/python/sip/specs/irix-cc deleted file mode 100644 index efc47bc6..00000000 --- a/python/sip/specs/irix-cc +++ /dev/null @@ -1,113 +0,0 @@ -# -# qmake configuration for irix-cc -# -# From cc(1): -# -n32 -# Generates a (new) 32-bit object. This defaults to -mips3 if -# -mips4 has not been specified. -# -LANG: ... -# The language feature option group controls the source language -# interpretation assumed by the compiler. The individual controls -# in this group are as follows: -# ansi-for-init-scope [ = ( ON|OFF ) ] -# Enables or disables the ANSI scoping rules for for-init -# declarations (the scope of the name declared extends to -# the end of the for statement). This enables the behavior -# that is required by the C++ standard. The default value -# is OFF, which is the ARM behavior (the scope of the name -# declared extends to the end of the block enclosing the for -# statement). -# bool [ = ( ON|OFF ) ] -# Enables or disables the predefined bool data type, along -# with the predefined values true and false. Use this option -# only to suppress this type in old code that defines bool -# itself. Because this option changes the mangling of function -# names with bool parameters, all files comprising a program -# should be compiled with consistent options. -# Default is ON. -# The _BOOL feature macro can be used in #ifdefs to do conditional -# compilation based on whether or not this option is enabled. -# std -# Enables use of the standard C++ library and standard- -# conforming iostream library. Specifying this flag also -# triggers other standard-conforming behavior, such as the -# new rules for the scope of for loop initializers. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = cc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -n32 -signed -woff 1209,1355,1375,1424,3303 -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -fullwarn -QMAKE_CFLAGS_WARN_OFF = -QMAKE_CFLAGS_RELEASE = -O2 -OPT:Olimit=3000 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -QMAKE_CFLAGS_YACC = -woff 1110,1174,3262 -QMAKE_CFLAGS_THREAD = - -QMAKE_CXX = CC -QMAKE_CXXFLAGS = -n32 -signed -LANG:std:libc_in_namespace_std=ON -woff 1209,1355,1375,1424,3303 -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = -QMAKE_LIBDIR_X11 = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = CC -QMAKE_LINK_SHLIB = CC -QMAKE_LFLAGS = -n32 -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -g -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -lm -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = CC -ar -o -QMAKE_RANLIB = - -QMAKE_CLEAN = -r $(OBJECTS_DIR)so_locations $(OBJECTS_DIR)ii_files - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/irix-cc-64 b/python/sip/specs/irix-cc-64 deleted file mode 100644 index f83d1f93..00000000 --- a/python/sip/specs/irix-cc-64 +++ /dev/null @@ -1,113 +0,0 @@ -# -# qmake configuration for irix-cc-64 -# -# From cc(1): -# -64 -# Generates a 64-bit object. This defaults to -mips4 if -mips3 has -# not been specified. -# -LANG: ... -# The language feature option group controls the source language -# interpretation assumed by the compiler. The individual controls -# in this group are as follows: -# ansi-for-init-scope [ = ( ON|OFF ) ] -# Enables or disables the ANSI scoping rules for for-init -# declarations (the scope of the name declared extends to -# the end of the for statement). This enables the behavior -# that is required by the C++ standard. The default value -# is OFF, which is the ARM behavior (the scope of the name -# declared extends to the end of the block enclosing the for -# statement). -# bool [ = ( ON|OFF ) ] -# Enables or disables the predefined bool data type, along -# with the predefined values true and false. Use this option -# only to suppress this type in old code that defines bool -# itself. Because this option changes the mangling of function -# names with bool parameters, all files comprising a program -# should be compiled with consistent options. -# Default is ON. -# The _BOOL feature macro can be used in #ifdefs to do conditional -# compilation based on whether or not this option is enabled. -# std -# Enables use of the standard C++ library and standard- -# conforming iostream library. Specifying this flag also -# triggers other standard-conforming behavior, such as the -# new rules for the scope of for loop initializers. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = cc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -64 -signed -woff 1209,1355,1375,1424,3303 -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -fullwarn -QMAKE_CFLAGS_WARN_OFF = -QMAKE_CFLAGS_RELEASE = -O2 -OPT:Olimit=3000 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -QMAKE_CFLAGS_YACC = -woff 1110,1174,3262 -QMAKE_CFLAGS_THREAD = - -QMAKE_CXX = CC -QMAKE_CXXFLAGS = -64 -signed -LANG:std:libc_in_namespace_std=ON -woff 1209,1355,1375,1424,3303 -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = -QMAKE_LIBDIR_X11 = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = CC -QMAKE_LINK_SHLIB = CC -QMAKE_LFLAGS = -64 -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -g -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -lm -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = CC -ar -o -QMAKE_RANLIB = - -QMAKE_CLEAN = -r $(OBJECTS_DIR)so_locations $(OBJECTS_DIR)ii_files - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/irix-cc-o32 b/python/sip/specs/irix-cc-o32 deleted file mode 100644 index ff6732f4..00000000 --- a/python/sip/specs/irix-cc-o32 +++ /dev/null @@ -1,89 +0,0 @@ -# -# $Id$ -# -# qmake configuration for irix-cc-o32 -# -# From cc(1): -# -o32 or -32 -# Generates an (old) 32-bit object. See the o32(5) man page for -# option descriptions and details. This defaults to -mips2 if -# -mips1 has not been specified. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl - -QMAKE_CC = cc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS = -o32 -signed -woff 3115,3203,3260,3672,3937 -QMAKE_CFLAGS_WARN_ON = -fullwarn -QMAKE_CFLAGS_WARN_OFF = -QMAKE_CFLAGS_RELEASE = -O2 -Olimit 3000 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -QMAKE_CFLAGS_YACC = -woff 3203,3262 -QMAKE_CFLAGS_THREAD = - -QMAKE_CXX = CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = -QMAKE_LIBDIR_X11 = -QMAKE_INCDIR_QT = $(QTDIR)/include -QMAKE_LIBDIR_QT = $(QTDIR)/lib -QMAKE_INCDIR_OPENGL = -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = CC -QMAKE_LINK_SHLIB = CC -QMAKE_LFLAGS = -o32 -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_QT = -lqt -QMAKE_LIBS_QT_THREAD = -lqt-mt -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXmu -lm -QMAKE_LIBS_OPENGL_QT = -lGL -lXmu -QMAKE_LIBS_THREAD = -lpthread - -QMAKE_MOC = $(QTDIR)/bin/moc -QMAKE_UIC = $(QTDIR)/bin/uic - -QMAKE_AR = ar cq -QMAKE_RANLIB = - -QMAKE_CLEAN = -r $(OBJECTS_DIR)so_locations $(OBJECTS_DIR)ii_files - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p diff --git a/python/sip/specs/irix-g++ b/python/sip/specs/irix-g++ deleted file mode 100644 index 5deaa1c6..00000000 --- a/python/sip/specs/irix-g++ +++ /dev/null @@ -1,84 +0,0 @@ -# -# qmake configuration for irix-g++ -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = -QMAKE_LIBDIR_X11 = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -Wl,-LD_LAYOUT:lgot_buffer=1000 -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -lC -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -# libGLU is using the SGI C++ library internally and this somehow clashes -# with the GNU C++ library (similar name mangling and symbol names?) -# so we add -lC so that the SGI C++ library is used first... -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cq -QMAKE_RANLIB = - -QMAKE_CLEAN = so_locations - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/irix-g++-64 b/python/sip/specs/irix-g++-64 deleted file mode 100644 index ade0ad3f..00000000 --- a/python/sip/specs/irix-g++-64 +++ /dev/null @@ -1,84 +0,0 @@ -# -# qmake configuration for irix-g++-64 -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -mabi=64 -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = -QMAKE_LIBDIR_X11 = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -mabi=64 -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -Wl,-LD_LAYOUT:lgot_buffer=1000 -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -lC -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -# libGLU is using the SGI C++ library internally and this somehow clashes -# with the GNU C++ library (similar name mangling and symbol names?) -# so we add -lC so that the SGI C++ library is used first... -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cq -QMAKE_RANLIB = - -QMAKE_CLEAN = so_locations - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/linux-cxx b/python/sip/specs/linux-cxx deleted file mode 100644 index fd5aae25..00000000 --- a/python/sip/specs/linux-cxx +++ /dev/null @@ -1,78 +0,0 @@ -# -# qmake configuration for linux-cxx -# -# Written for Compaq C++ for GNU/Linux on Alpha -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = ccc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -w -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -QMAKE_CFLAGS_YACC = -Olimit 1000 - -QMAKE_CXX = cxx -QMAKE_CXXFLAGS = -w -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = cxx -QMAKE_LINK_SHLIB = cxx -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_NIS = -lnsl - -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/linux-ecc-64 b/python/sip/specs/linux-ecc-64 deleted file mode 100644 index a6b43277..00000000 --- a/python/sip/specs/linux-ecc-64 +++ /dev/null @@ -1,84 +0,0 @@ -# -# qmake configuration for linux-ecc-64 -# -# Written for Intel C++ 7.1 and 8.0 for Linux -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = ecc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -KPIC -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -D_REENTRANT - -QMAKE_CXX = ecpc -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = ecpc -QMAKE_LINK_SHLIB = ecpc -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Qoption,ld,-soname, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Qoption,ld,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_CLEAN = -r $(OBJECTS_DIR)/ti_files - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/linux-g++ b/python/sip/specs/linux-g++ deleted file mode 100644 index 9d94ff32..00000000 --- a/python/sip/specs/linux-g++ +++ /dev/null @@ -1,90 +0,0 @@ -# -# qmake configuration for linux-g++ -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release incremental link_prl -QT += core gui -QMAKE_INCREMENTAL_STYLE = sublib - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_YACCFLAGS_MANGLE = -p $base -b $base -QMAKE_YACC_HEADER = $base.tab.h -QMAKE_YACC_SOURCE = $base.tab.c -QMAKE_CFLAGS = -pipe -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -D_REENTRANT -QMAKE_CFLAGS_HIDESYMS = -fvisibility=hidden - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD -QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_COPY_FILE = $(COPY) -QMAKE_COPY_DIR = $(COPY) -r -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_STRIP = strip -QMAKE_STRIPFLAGS_LIB += --strip-unneeded -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/linux-g++-32 b/python/sip/specs/linux-g++-32 deleted file mode 100644 index c0b7b79b..00000000 --- a/python/sip/specs/linux-g++-32 +++ /dev/null @@ -1,90 +0,0 @@ -# -# qmake configuration for linux-g++ -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release incremental link_prl -QT += core gui -QMAKE_INCREMENTAL_STYLE = sublib - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_YACCFLAGS_MANGLE = -p $base -b $base -QMAKE_YACC_HEADER = $base.tab.h -QMAKE_YACC_SOURCE = $base.tab.c -QMAKE_CFLAGS = -m32 -pipe -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -D_REENTRANT -QMAKE_CFLAGS_HIDESYMS = -fvisibility=hidden - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD -QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -m32 -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_COPY_FILE = $(COPY) -QMAKE_COPY_DIR = $(COPY) -r -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_STRIP = strip -QMAKE_STRIPFLAGS_LIB += --strip-unneeded -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/linux-g++-64 b/python/sip/specs/linux-g++-64 deleted file mode 100644 index 7bdd3b14..00000000 --- a/python/sip/specs/linux-g++-64 +++ /dev/null @@ -1,93 +0,0 @@ -# -# qmake configuration for linux-g++ -# -# Written for GNU/Linux platforms that have both lib and lib64 directories, -# like the AMD Opteron. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release incremental link_prl -QT += core gui -QMAKE_INCREMENTAL_STYLE = sublib - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_YACCFLAGS_MANGLE = -p $base -b $base -QMAKE_YACC_HEADER = $base.tab.h -QMAKE_YACC_SOURCE = $base.tab.c -QMAKE_CFLAGS = -m64 -pipe -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -D_REENTRANT -QMAKE_CFLAGS_HIDESYMS = -fvisibility=hidden - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD -QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib64 -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib64 - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -m64 -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_COPY_FILE = $(COPY) -QMAKE_COPY_DIR = $(COPY) -r -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_STRIP = strip -QMAKE_STRIPFLAGS_LIB += --strip-unneeded -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/linux-icc b/python/sip/specs/linux-icc deleted file mode 100644 index a14034c2..00000000 --- a/python/sip/specs/linux-icc +++ /dev/null @@ -1,107 +0,0 @@ -# -# qmake configuration for linux-icc -# -# Written for Intel C++ 5.0.1, 6.0.1, 7.0 and 8.0 for GNU/Linux -# -# Note: Some of the remarks from the Intel compiler are disabled (even -# with 'warn_on' specified): -# -# remark #171: invalid type conversion: "int" to "void *" -# remark #193: zero used for undefined preprocessing identifier -# remark #279: controlling expression is constant -# remark #304: access control not specified ("public" by default) -# remark #310: old-style parameter list (anachronism) -# remark #383: value copied to temporary, reference to temporary used -# remark #424: extra ";" ignored -# remark #444: destructor for base class "Class" is not virtual -# remark #488: template parameter "T" is not used in declaring the parameter -# types of function template "function" -# remark #810: conversion from "type1" to "type2" may loose significant bits -# remark #858: type qualifier on return type is meaningless -# remark #967: conversion from "type1" to "type2"; sizes do not match -# remark #981: operands are evaluated in unspecified order -# remark #1418: external definition with no prior declaration -# remark #1419: external declaration in primary source file -# warning #1476: field uses tail padding of a base class -# warning #1477: GNU C++ compilers may use bit field padding -# warning #1572: floating-point equality and inequality comparisons are unreliable -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = icc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -wd858,1572 -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -w2 -wd171,193,279,304,310,383,424,444,488,810,967,981,1418,1419,1476,1477 -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -KPIC -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -D_REENTRANT - -QMAKE_CXX = icpc -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = icpc -QMAKE_LINK_SHLIB = icpc -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Qoption,ld,-soname, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Qoption,ld,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_CLEAN = -r $(OBJECTS_DIR)/ti_files - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/linux-kcc b/python/sip/specs/linux-kcc deleted file mode 100644 index 6a9cf088..00000000 --- a/python/sip/specs/linux-kcc +++ /dev/null @@ -1,93 +0,0 @@ -# -# qmake configuration for linux-kcc -# -# Written for KAI C++ 4.0f for GNU/Linux -# -# This product has been discontinued, use Intel C++ instead. -# -# From the KAI C++ man page for Linux: -# --[no_]thread_safe -# [Waive or] Request thread-safe handling of system-allocated objects. -# To guarantee thread safety, this option must be used when both -# compiling and linking. Thread-safe C++ is not link-compatible with -# (the default) non-thread-safe C++. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = KCC -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = --c --display_error_number --backend -pipe -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = +K2 -QMAKE_CFLAGS_DEBUG = +K0 -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = --diag_suppress 111,177 -QMAKE_CFLAGS_THREAD = --thread_safe - -QMAKE_CXX = KCC -QMAKE_CXXFLAGS = --display_error_number --diag_suppress 611,1142 --backend -pipe -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = KCC -QMAKE_LINK_SHLIB = KCC -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = --soname$$LITERAL_WHITESPACE -QMAKE_LFLAGS_THREAD = --thread_safe -QMAKE_RPATH = -rpath$$LITERAL_WHITESPACE - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_CLEAN = -r $(OBJECTS_DIR)ti_files - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/linux-kylix b/python/sip/specs/linux-kylix deleted file mode 100644 index 335f839d..00000000 --- a/python/sip/specs/linux-kylix +++ /dev/null @@ -1,82 +0,0 @@ -# -# qmake configuration for linux-kylix -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release incremental link_prl -QT += core gui -QMAKE_INCREMENTAL_STYLE = sublib - -QMAKE_CC = bc++ -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -m -QMAKE_CFLAGS_WARN_ON = -w -QMAKE_CFLAGS_WARN_OFF = -w- -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -v -y -QMAKE_CFLAGS_SHLIB = -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = - -QMAKE_CXX = bc++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -P -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = bc++ -QMAKE_LINK_SHLIB = bc++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -lv -ly -QMAKE_LFLAGS_SHLIB = -ltD -lTpd -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -lN -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -llibdl -QMAKE_LIBS_X11 = -llibXext -llibX11 -llibm -QMAKE_LIBS_X11SM = -llibSM -llibICE -QMAKE_LIBS_NIS = -llibnsl -QMAKE_LIBS_OPENGL = -llibGLU -llibGL -llibXmu -QMAKE_LIBS_OPENGL_QT = -llibGL -llibXmu -QMAKE_LIBS_THREAD = -llibpthread - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_STRIP = strip -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/linux-lsb b/python/sip/specs/linux-lsb deleted file mode 100644 index 95367161..00000000 --- a/python/sip/specs/linux-lsb +++ /dev/null @@ -1,90 +0,0 @@ -# -# qmake configuration for linux-g++ -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release incremental link_prl -QT += core gui -QMAKE_INCREMENTAL_STYLE = sublib - -QMAKE_CC = lsbcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_YACCFLAGS_MANGLE = -p $base -b $base -QMAKE_YACC_HEADER = $base.tab.h -QMAKE_YACC_SOURCE = $base.tab.c -QMAKE_CFLAGS = -pipe -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -D_REENTRANT -QMAKE_CFLAGS_HIDESYMS = -fvisibility=hidden - -QMAKE_CXX = lsbc++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD -QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = lsbc++ -QMAKE_LINK_SHLIB = lsbc++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_COPY_FILE = $(COPY) -QMAKE_COPY_DIR = $(COPY) -r -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_STRIP = strip -QMAKE_STRIPFLAGS_LIB += --strip-unneeded -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/linux-pgcc b/python/sip/specs/linux-pgcc deleted file mode 100644 index fae849dc..00000000 --- a/python/sip/specs/linux-pgcc +++ /dev/null @@ -1,82 +0,0 @@ -# -# qmake configuration for linux-pgcc -# -# Written for the Portland Group compiler 6.0-5 -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = pgcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -fast -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fpic -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -D_REENTRANT - -QMAKE_CXX = pgCC -QMAKE_CXXFLAGS = --display_error_number --diag_suppress815 $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = pgCC -QMAKE_LINK_SHLIB = pgCC -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -fpic -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -R - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/lynxos-g++ b/python/sip/specs/lynxos-g++ deleted file mode 100644 index da2ebe70..00000000 --- a/python/sip/specs/lynxos-g++ +++ /dev/null @@ -1,85 +0,0 @@ -# -# qmake configuration for lynxos-g++ -# -# Written for LynxOS 4.0 -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release incremental link_prl -QT += core gui -QMAKE_INCREMENTAL_STYLE = sublib - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -pipe -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -D_REENTRANT - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/include/X11 -QMAKE_LIBDIR_X11 = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/include/GL -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_STRIP = strip -QMAKE_STRIPFLAGS_LIB += --strip-unneeded -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/macx-g++ b/python/sip/specs/macx-g++ deleted file mode 100644 index d28fda9f..00000000 --- a/python/sip/specs/macx-g++ +++ /dev/null @@ -1,97 +0,0 @@ -# -# qmake configuration for macx-g++ -# -# Mac OS X + command-line compiler -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release app_bundle incremental global_init_link_order lib_version_first plugin_no_soname link_prl -QT += core gui -QMAKE_INCREMENTAL_STYLE = sublibs -QMAKE_COMPILER_DEFINES += __APPLE__ __GNUC__ - -QMAKE_CC = cc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_YACCFLAGS_MANGLE = -p $base -b $base -QMAKE_YACC_HEADER = $base.tab.h -QMAKE_YACC_SOURCE = $base.tab.c -QMAKE_RESOURCE = /Developer/Tools/Rez -QMAKE_CFLAGS = -pipe -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -Os -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_EXTENSION_SHLIB = dylib -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_HIDESYMS = -fvisibility=hidden -QMAKE_CFLAGS_PPC = -arch ppc -QMAKE_CFLAGS_X86 = -arch i386 - -QMAKE_CXX = c++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden -QMAKE_CXXFLAGS_PPC = $$QMAKE_CFLAGS_PPC -QMAKE_CXXFLAGS_X86 = $$QMAKE_CFLAGS_X86 - -QMAKE_LIBDIR = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /System/Library/Frameworks/OpenGL.framework/Headers \ - /System/Library/Frameworks/AGL.framework/Headers/ - -QMAKE_LINK = $$QMAKE_CXX -QMAKE_FIX_RPATH = install_name_tool -id -QMAKE_LINK_SHLIB = $$QMAKE_CXX -QMAKE_LFLAGS = -headerpad_max_install_names -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_APP = -QMAKE_LFLAGS_SHLIB = -single_module -dynamiclib -QMAKE_LFLAGS_INCREMENTAL = -undefined suppress -flat_namespace -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -install_name$${LITERAL_WHITESPACE} -QMAKE_LFLAGS_THREAD = -QMAKE_LFLAGS_PPC = -arch ppc -QMAKE_LFLAGS_X86 = -arch i386 - -QMAKE_LFLAGS_VERSION = -current_version$${LITERAL_WHITESPACE} -QMAKE_LFLAGS_COMPAT_VERSION = -compatibility_version$${LITERAL_WHITESPACE} - -QMAKE_RPATH = - -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_OPENGL = -framework OpenGL -framework AGL -QMAKE_LIBS_OPENGL_QT = $$QMAKE_LIBS_OPENGL -QMAKE_LIBS_THREAD = - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cq -QMAKE_RANLIB = ranlib -s - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_COPY_FILE = $$QMAKE_COPY -QMAKE_COPY_DIR = $$QMAKE_COPY -R -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/macx-mwerks b/python/sip/specs/macx-mwerks deleted file mode 100644 index 76c425a7..00000000 --- a/python/sip/specs/macx-mwerks +++ /dev/null @@ -1,25 +0,0 @@ -# -# qmake configuration for macx-mwerks -# -# Mac OS X + Metrowerks compiler -# - -MAKEFILE_GENERATOR = METROWERKS -TEMPLATE = app -QT += core gui -CONFIG += qt release warn_off separate_volume link_prl - -DEFINES += QT_NO_STL __MACOSX__ __CF_USE_FRAMEWORK_INCLUDES__ - -CODEWARRIOR_LINKER = Mach-O PPC Linker -QMAKE_EXTENSION_SHLIB = dylib -QMAKE_VOLUMENAME = OS X Volume -FRAMEWORKPATH = {System}/Library/Frameworks/ -QMAKE_CRT_OBJECTS = crt1.o -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBS = -framework System -QMAKE_INCDIR_OPENGL = /System/Library/Frameworks/OpenGL.framework/Headers \ - /System/Library/Frameworks/AGL.framework/Headers/ -QMAKE_LIBS_OPENGL = -framework OpenGL -framework AGL -QMAKE_LIBS_OPENGL_QT = $$QMAKE_LIBS_OPENGL -load(qt_config) diff --git a/python/sip/specs/macx-pbuilder b/python/sip/specs/macx-pbuilder deleted file mode 100644 index 1e806d15..00000000 --- a/python/sip/specs/macx-pbuilder +++ /dev/null @@ -1,83 +0,0 @@ -# -# qmake configuration for macx-pbuilder -# -# Mac OS X + Project Builder -# - -MAKEFILE_GENERATOR = PROJECTBUILDER -TEMPLATE = app -CONFIG += qt warn_on release lib_version_first incremental plugin_no_soname link_prl app_bundle -QT += core gui -QMAKE_COMPILER_DEFINES += __APPLE__ __GNUC__ - -QMAKE_CC = -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_RESOURCE = /Developer/Tools/Rez -QMAKE_CFLAGS = -pipe -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -QMAKE_CFLAGS_RELEASE = -Os -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_EXTENSION_SHLIB = dylib -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses - -QMAKE_CXX = -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC - -QMAKE_INCDIR = /usr/local/include \ - /System/Library/Frameworks/CarbonCore.framework/Headers -QMAKE_LIBDIR = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /System/Library/Frameworks/OpenGL.framework/Headers \ - /System/Library/Frameworks/AGL.framework/Headers/ - -QMAKE_LINK = c++ -QMAKE_LINK_SHLIB = c++ -QMAKE_LFLAGS = -headerpad_max_install_names -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_APP = -QMAKE_LFLAGS_SHLIB = -single_module -dynamiclib -QMAKE_LFLAGS_INCREMENTAL = -undefined suppress -flat_namespace -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -#QMAKE_LFLAGS_SONAME = -install_name$${LITERAL_WHITESPACE}@executable_path/../Frameworks/ -QMAKE_LFLAGS_SONAME = -install_name$${LITERAL_WHITESPACE} -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = - -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_THREAD = -QMAKE_LIBS_OPENGL = -framework OpenGL -framework AGL -QMAKE_LIBS_OPENGL_QT = $$QMAKE_LIBS_OPENGL - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cq -QMAKE_RANLIB = ranlib -s - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_COPY_FILE = $$QMAKE_COPY -QMAKE_COPY_DIR = $$QMAKE_COPY -R -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/macx-xcode b/python/sip/specs/macx-xcode deleted file mode 100644 index d2a5789a..00000000 --- a/python/sip/specs/macx-xcode +++ /dev/null @@ -1,83 +0,0 @@ -# -# qmake configuration for macx-xcode -# -# Mac OS X + XCode -# - -MAKEFILE_GENERATOR = XCODE -TEMPLATE = app -CONFIG += qt warn_on release lib_version_first incremental plugin_no_soname link_prl app_bundle -QT += core gui -QMAKE_COMPILER_DEFINES += __APPLE__ __GNUC__ - -QMAKE_CC = -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_RESOURCE = /Developer/Tools/Rez -QMAKE_CFLAGS = -pipe -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -QMAKE_CFLAGS_RELEASE = -Os -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_EXTENSION_SHLIB = dylib -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses - -QMAKE_CXX = -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC - -QMAKE_INCDIR = /usr/local/include \ - /System/Library/Frameworks/CarbonCore.framework/Headers -QMAKE_LIBDIR = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /System/Library/Frameworks/OpenGL.framework/Headers \ - /System/Library/Frameworks/AGL.framework/Headers/ - -QMAKE_LINK = c++ -QMAKE_LINK_SHLIB = c++ -QMAKE_LFLAGS = -headerpad_max_install_names -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_APP = -QMAKE_LFLAGS_SHLIB = -single_module -dynamiclib -QMAKE_LFLAGS_INCREMENTAL = -undefined suppress -flat_namespace -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -#QMAKE_LFLAGS_SONAME = -install_name$${LITERAL_WHITESPACE}@executable_path/../Frameworks/ -QMAKE_LFLAGS_SONAME = -install_name$${LITERAL_WHITESPACE} -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = - -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_THREAD = -QMAKE_LIBS_OPENGL = -framework OpenGL -framework AGL -QMAKE_LIBS_OPENGL_QT = $$QMAKE_LIBS_OPENGL - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cq -QMAKE_RANLIB = ranlib -s - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_COPY_FILE = $$QMAKE_COPY -QMAKE_COPY_DIR = $$QMAKE_COPY -R -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/macx-xlc b/python/sip/specs/macx-xlc deleted file mode 100644 index 262764b2..00000000 --- a/python/sip/specs/macx-xlc +++ /dev/null @@ -1,94 +0,0 @@ -# -# qmake configuration for macx-xlc -# -# Mac OS X + IBM's XL C/C++ Advanced Edition for Mac OS X -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release app_bundle global_init_link_order lib_version_first plugin_no_soname link_prl -QT += core gui - -QMAKE_CC = xlc -QMAKE_CC_THREAD = xlc_r -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -qstrict -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -QMAKE_CFLAGS_RELEASE = -O3 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_EXTENSION_SHLIB = dylib -QMAKE_CFLAGS_SHLIB = -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -qthreaded -QMAKE_EXTENSION_SHLIB = dylib -QMAKE_COMPILER_DEFINES += __APPLE__ __xlc__ - -QMAKE_CXX = xlc++ -QMAKE_CXX_THREAD = xlc++_r -QMAKE_CXXFLAGS = -+ $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = -QMAKE_LIBDIR_X11 = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /System/Library/Frameworks/OpenGL.framework/Headers \ - /System/Library/Frameworks/AGL.framework/Headers/ -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = xlc++ -QMAKE_LINK_THREAD = xlc++_r -QMAKE_LINK_SHLIB = ld -#QMAKE_LINK_SHLIB_CMD = makeC++SharedLib -p 0 \ -# -o $(TARGETD) \ -# $(LFLAGS) $(OBJECTS) $(OBJMOC) $(LIBS); \ -# $(AR) lib$(QMAKE_TARGET).a $(TARGETD); \ -# $(RANLIB) lib$(QMAKE_TARGET).a; \ -# mv lib$(QMAKE_TARGET).a $(DESTDIR) -QMAKE_LFLAGS = -headerpad_max_install_names -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -prebind -qmkshrobj -QMAKE_LFLAGS_PLUGIN = -bundle -QMAKE_LFLAGS_SONAME = -#QMAKE_LFLAGS_THREAD = -L/usr/lib/threads -#QMAKE_AIX_SHLIB = 1 -#QMAKE_LFLAGS_VERSION = -current_version$${LITERAL_WHITESPACE} -#QMAKE_LFLAGS_COMPAT_VERSION = -compatibility_version$${LITERAL_WHITESPACE} - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_OPENGL = -framework OpenGL -framework AGL -QMAKE_LIBS_OPENGL_QT = $$QMAKE_LIBS_OPENGL -#QMAKE_LIBS_THREAD = -lpthreads - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cq -QMAKE_RANLIB = ranlib -s - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_COPY_FILE = $$QMAKE_COPY -QMAKE_COPY_DIR = $$QMAKE_COPY -R -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/netbsd-g++ b/python/sip/specs/netbsd-g++ deleted file mode 100644 index 0b112b10..00000000 --- a/python/sip/specs/netbsd-g++ +++ /dev/null @@ -1,80 +0,0 @@ -# -# qmake configuration for netbsd-g++ -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -pipe -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -pthread - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = /usr/local/include -QMAKE_LIBDIR = /usr/local/lib -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LINK_SHLIB_CMD = $$QMAKE_LINK_SHLIB $$QMAKE_LFLAGS_SHLIB $(LFLAGS) $$QMAKE_LFLAGS -o $(TARGETD) $(OBJECTS) $(OBJMOC) $(LIBS) -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -pthread -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = ranlib - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/openbsd-g++ b/python/sip/specs/openbsd-g++ deleted file mode 100644 index 86caacdb..00000000 --- a/python/sip/specs/openbsd-g++ +++ /dev/null @@ -1,81 +0,0 @@ -# -# qmake configuration for openbsd-g++ -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -pipe -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -pthread - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = /usr/local/include -QMAKE_LIBDIR = /usr/local/lib -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LINK_SHLIB_CMD = $$QMAKE_LINK_SHLIB $(LFLAGS) \ - $$QMAKE_CFLAGS_SHLIB $$QMAKE_LFLAGS \ - -o $(TARGETD) $(OBJECTS) $(OBJMOC) $(LIBS) -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -pthread - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar q -QMAKE_RANLIB = ranlib - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/qnx-g++ b/python/sip/specs/qnx-g++ deleted file mode 100644 index c2411d4d..00000000 --- a/python/sip/specs/qnx-g++ +++ /dev/null @@ -1,81 +0,0 @@ -# -# qmake configuration for qnx-g++ -# -# Written for QNX RTOS v6 with X11 -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -pipe -fno-inline -fno-pack-struct -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -fno-inline -fno-pack-struct -QMAKE_CFLAGS_THREAD = -D_REENTRANT - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /usr/X11R6/include -QMAKE_LIBDIR_X11 = /usr/X11R6/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/X11R6/include -QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -lunix -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/reliant-cds b/python/sip/specs/reliant-cds deleted file mode 100644 index 998bf5f4..00000000 --- a/python/sip/specs/reliant-cds +++ /dev/null @@ -1,85 +0,0 @@ -# -# $Id$ -# -# qmake configuration for reliant-cds -# -# Written for Reliant UNIX 5.45 using the CDS++ C/C++ compiler V2.0C. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl - -QMAKE_CC = cc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -v -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -KPIC -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -K pthread - -QMAKE_CXX = CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /opt/X/include/X11 -QMAKE_LIBDIR_X11 = /opt/X/lib -QMAKE_INCDIR_QT = $(QTDIR)/include -QMAKE_LIBDIR_QT = $(QTDIR)/lib -QMAKE_INCDIR_OPENGL = -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = CC -QMAKE_LINK_SHLIB = CC -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -G -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -h$$LITERAL_WHITESPACE -QMAKE_LFLAGS_THREAD = -K pthread -QMAKE_RPATH = -Wl,-Brpath= - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lresolv -lsocket -lnsl -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_QT = -lqt -QMAKE_LIBS_QT_THREAD = -lqt-mt -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXmu -QMAKE_LIBS_OPENGL_QT = -lGL -lXmu -QMAKE_LIBS_THREAD = - -QMAKE_MOC = $(QTDIR)/bin/moc -QMAKE_UIC = $(QTDIR)/bin/uic - -QMAKE_AR = CC -xar -o -QMAKE_RANLIB = - -QMAKE_CLEAN = -r $(OBJECTS_DIR)/Templates.DB - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p diff --git a/python/sip/specs/reliant-cds-64 b/python/sip/specs/reliant-cds-64 deleted file mode 100644 index 7374b730..00000000 --- a/python/sip/specs/reliant-cds-64 +++ /dev/null @@ -1,85 +0,0 @@ -# -# $Id$ -# -# qmake configuration for reliant-cds-64 -# -# Written for Reliant UNIX 5.45 using the CDS++ C/C++ compiler V2.0C. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl - -QMAKE_CC = cc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -Klp64 -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -v -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -KPIC -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -K pthread - -QMAKE_CXX = CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = /opt/X/include/X11 -QMAKE_LIBDIR_X11 = /opt/X/lib -QMAKE_INCDIR_QT = $(QTDIR)/include -QMAKE_LIBDIR_QT = $(QTDIR)/lib -QMAKE_INCDIR_OPENGL = -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = CC -QMAKE_LINK_SHLIB = CC -QMAKE_LFLAGS = -Klp64 -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -G -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -h$$LITERAL_WHITESPACE -QMAKE_LFLAGS_THREAD = -K pthread -QMAKE_RPATH = -Wl,-Brpath= - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lresolv -lsocket -lnsl -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_QT = -lqt -QMAKE_LIBS_QT_THREAD = -lqt-mt -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXmu -QMAKE_LIBS_OPENGL_QT = -lGL -lXmu -QMAKE_LIBS_THREAD = - -QMAKE_MOC = $(QTDIR)/bin/moc -QMAKE_UIC = $(QTDIR)/bin/uic - -QMAKE_AR = CC -xar -o -QMAKE_RANLIB = - -QMAKE_CLEAN = -r $(OBJECTS_DIR)/Templates.DB - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p diff --git a/python/sip/specs/sco-cc b/python/sip/specs/sco-cc deleted file mode 100644 index 8a4a3924..00000000 --- a/python/sip/specs/sco-cc +++ /dev/null @@ -1,78 +0,0 @@ -# -# qmake configuration for sco-cc -# -# Written for SCO OpenServer with UDK -# -# -Wf,--diag_suppress,838 -# turns off warning about missing return types in X headers -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -QT += core gui -CONFIG += qt warn_on release link_prl - -QMAKE_CC = cc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -KPIC -QMAKE_CFLAGS_YACC = -Wf,--diag_suppress,111 -Wf,--diag_suppress,177 - -QMAKE_CXX = CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -Wf,--display_error_number -Wf,--diag_suppress,838 -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -Tused -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = -QMAKE_LIBDIR_X11 = /usr/X/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = CC -QMAKE_LINK_SHLIB = CC -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -G -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -h$$LITERAL_WHITESPACE - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lresolv -lsocket -lnsl -lm -QMAKE_LIBS_X11SM = -lSM -lICE - -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXt -QMAKE_LIBS_OPENGL_QT = -lGL - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cq -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/sco-g++ b/python/sip/specs/sco-g++ deleted file mode 100644 index 9a488e83..00000000 --- a/python/sip/specs/sco-g++ +++ /dev/null @@ -1,77 +0,0 @@ -# -# qmake configuration for sco-g++ -# -# Written for SCO OpenServer 5.0.6 with Skunkware's compiler -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = -QMAKE_LIBDIR_X11 = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -G -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -h$$LITERAL_WHITESPACE -QMAKE_RPATH = - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lsocket -lm - -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/solaris-cc b/python/sip/specs/solaris-cc deleted file mode 100644 index 3e1f4285..00000000 --- a/python/sip/specs/solaris-cc +++ /dev/null @@ -1,85 +0,0 @@ -# -# qmake configuration for solaris-cc -# -# Written for Forte Developer 6 and Sun ONE Studio 7 and 8 -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = cc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -xM -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -KPIC -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -mt - -QMAKE_CXX = CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = -O2 -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = /usr/sfw/include -QMAKE_LIBDIR = /usr/sfw/lib -QMAKE_INCDIR_X11 = /usr/openwin/include -QMAKE_LIBDIR_X11 = /usr/openwin/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/openwin/include -QMAKE_LIBDIR_OPENGL = /usr/openwin/lib - -QMAKE_LINK = CC -QMAKE_LINK_SHLIB = CC -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -G -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -h$$LITERAL_WHITESPACE -QMAKE_LFLAGS_THREAD = -mt -QMAKE_RPATH = -R - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lresolv -lsocket -lnsl -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_NIS = -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread -lrt -QMAKE_LIBS_NETWORK = -lresolv -lsocket -lxnet - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = CC -xar -o -QMAKE_RANLIB = - -QMAKE_CLEAN = -r $(OBJECTS_DIR)Templates.DB $(OBJECTS_DIR)SunWS_cache - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/solaris-cc-64 b/python/sip/specs/solaris-cc-64 deleted file mode 100644 index cd1af176..00000000 --- a/python/sip/specs/solaris-cc-64 +++ /dev/null @@ -1,102 +0,0 @@ -# -# qmake configuration for solaris-cc-64 -# -# Written for Forte Developer 6 and Sun ONE Studio 7 and 8 -# -# From the standards(5) manual page: -# The XNS4 specification is safe for use only in ILP32 (32-bit) -# environments and should not be used for LP64 (64-bit) -# application environments. Use XNS5, which has LP64-clean -# interfaces that are portable across ILP32 and LP64 environments. -# [...] -# For platforms supporting the LP64 (64-bit) programming environment -# where the SC5.0 Compilers have been installed, SUSv2-conforming LP64 -# applications using XNS5 library calls should be built with command -# lines of the form: -# c89 $(getconf XBS5_LP64_OFF64_CFLAGS) -D_XOPEN_SOURCE=500 \ -# $(getconf XBS5_LP64_OFF64_LDFLAGS) foo.c -o foo \ -# $(getconf XBS5_LP64_OFF64_LIBS) -lxnet -# So it appears that _XOPEN_SOURCE=500 should be defined when building -# 64-bit applications (on Solaris 7 and better). But then __EXTENSIONS__ -# should be defined as well to recover all the default system interface. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = cc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -xarch=generic64 -D_XOPEN_SOURCE=500 -D__EXTENSIONS__ -QMAKE_CFLAGS_DEPS = -xM -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -KPIC -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -mt - -QMAKE_CXX = CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = -O -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = /usr/sfw/include -QMAKE_LIBDIR = /usr/sfw/lib/64 -QMAKE_INCDIR_X11 = /usr/openwin/include -QMAKE_LIBDIR_X11 = /usr/openwin/lib/64 -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/openwin/include -QMAKE_LIBDIR_OPENGL = /usr/openwin/lib/64 - -QMAKE_LINK = CC -QMAKE_LINK_SHLIB = CC -QMAKE_LFLAGS = -xarch=generic64 -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -G -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -h$$LITERAL_WHITESPACE -QMAKE_LFLAGS_THREAD = -mt -QMAKE_RPATH = -R - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lresolv -lsocket -lnsl -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_NIS = -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread -lrt -QMAKE_LIBS_NETWORK = -lresolv -lsocket -lxnet - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = CC -xar -o -QMAKE_RANLIB = - -QMAKE_CLEAN = -r $(OBJECTS_DIR)Templates.DB $(OBJECTS_DIR)SunWS_cache - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/solaris-g++ b/python/sip/specs/solaris-g++ deleted file mode 100644 index 09d141d1..00000000 --- a/python/sip/specs/solaris-g++ +++ /dev/null @@ -1,87 +0,0 @@ -# -# qmake configuration for solaris-g++ -# -# The X11 header files used to be broken on Solaris until patches were -# released in early 2001 for Solaris 2.6, 7, and 8. On Solaris 2.5.1 -# or non-patched systems -fpermissive works around the incompatibility -# between GCC 2.95 or better and Solaris - but we still get warnings -# because we don't use -isystem. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -D_REENTRANT - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = /usr/sfw/include -QMAKE_LIBDIR = /usr/sfw/lib -QMAKE_INCDIR_X11 = /usr/openwin/include -QMAKE_LIBDIR_X11 = /usr/openwin/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/openwin/include -QMAKE_LIBDIR_OPENGL = /usr/openwin/lib - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -g -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -h$$LITERAL_WHITESPACE -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,-R, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lresolv -lsocket -lnsl -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_NIS = -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread -lrt -QMAKE_LIBS_NETWORK = -lresolv -lsocket -lxnet - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cq -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/solaris-g++-64 b/python/sip/specs/solaris-g++-64 deleted file mode 100644 index c85882a2..00000000 --- a/python/sip/specs/solaris-g++-64 +++ /dev/null @@ -1,104 +0,0 @@ -# -# qmake configuration for solaris-g++64 -# -# The X11 header files used to be broken on Solaris until patches were -# released in early 2001 for Solaris 2.6, 7, and 8. On Solaris 2.5.1 -# or non-patched systems -fpermissive works around the incompatibility -# between GCC 2.95 or better and Solaris - but we still get warnings -# because we don't use -isystem. -# -# From the standards(5) manual page: -# The XNS4 specification is safe for use only in ILP32 (32-bit) -# environments and should not be used for LP64 (64-bit) -# application environments. Use XNS5, which has LP64-clean -# interfaces that are portable across ILP32 and LP64 environments. -# [...] -# For platforms supporting the LP64 (64-bit) programming environment -# where the SC5.0 Compilers have been installed, SUSv2-conforming LP64 -# applications using XNS5 library calls should be built with command -# lines of the form: -# c89 $(getconf XBS5_LP64_OFF64_CFLAGS) -D_XOPEN_SOURCE=500 \ -# $(getconf XBS5_LP64_OFF64_LDFLAGS) foo.c -o foo \ -# $(getconf XBS5_LP64_OFF64_LIBS) -lxnet -# So it appears that _XOPEN_SOURCE=500 should be defined when building -# 64-bit applications (on Solaris 7 and better). But then __EXTENSIONS__ -# should be defined as well to recover all the default system interface. -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -m64 -D_XOPEN_SOURCE=500 -D__EXTENSIONS__ -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -D_REENTRANT - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = /usr/sfw/include -QMAKE_LIBDIR = /usr/sfw/lib/64 -QMAKE_INCDIR_X11 = /usr/openwin/include -QMAKE_LIBDIR_X11 = /usr/openwin/lib/64 -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = /usr/openwin/include -QMAKE_LIBDIR_OPENGL = /usr/openwin/lib/64 - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -m64 -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -g -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -h$$LITERAL_WHITESPACE -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,-R, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lresolv -lsocket -lnsl -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_NIS = -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread -lrt -QMAKE_LIBS_NETWORK = -lresolv -lsocket -lxnet - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cq -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/tru64-cxx b/python/sip/specs/tru64-cxx deleted file mode 100644 index b7154be9..00000000 --- a/python/sip/specs/tru64-cxx +++ /dev/null @@ -1,79 +0,0 @@ -# -# qmake configuration for tru64-cxx -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl plugin_no_soname -QT += core gui - -QMAKE_CC = cc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -QMAKE_CFLAGS_YACC = -Olimit 1000 -QMAKE_CFLAGS_THREAD = -pthread - -QMAKE_CXX = cxx -QMAKE_CXXFLAGS = -x cxx -model ansi $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = -QMAKE_LIBDIR_X11 = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = cxx -QMAKE_LINK_SHLIB = cxx -QMAKE_LFLAGS = -model ansi -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_THREAD = -pthread -QMAKE_LFLAGS_SONAME = -soname$$LITERAL_WHITESPACE -QMAKE_RPATH = -rpath$$LITERAL_WHITESPACE - -QMAKE_LIBS = -lm -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_X11 = -lXext -lX11 -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lrt - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/tru64-g++ b/python/sip/specs/tru64-g++ deleted file mode 100644 index eb3a7581..00000000 --- a/python/sip/specs/tru64-g++ +++ /dev/null @@ -1,79 +0,0 @@ -# -# qmake configuration for tru64-g++ -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl plugin_no_soname -QT += core gui - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -D_REENTRANT - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = -QMAKE_LIBDIR_X11 = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_THREAD = -QMAKE_LFLAGS_SONAME = -Wl,-soname, -QMAKE_RPATH = -Wl,-rpath, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_X11 = -lXext -lX11 -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lpthread -lexc -lrt - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cqs -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/unixware-cc b/python/sip/specs/unixware-cc deleted file mode 100644 index 61b0d7f6..00000000 --- a/python/sip/specs/unixware-cc +++ /dev/null @@ -1,84 +0,0 @@ -# -# qmake configuration for unixware-cc -# -# Written for UnixWare 7 with UDK or OUDK -# -# -Wf,--diag_suppress,838 -# turns off warning about missing return types in X headers -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = cc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_WARN_ON = -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -KPIC -QMAKE_CFLAGS_YACC = -Wf,--diag_suppress,111 -Wf,--diag_suppress,177 -QMAKE_CFLAGS_THREAD = -Kthread - -QMAKE_CXX = CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -Wf,--display_error_number -Wf,--diag_suppress,838 -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -Tused -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = -QMAKE_LIBDIR_X11 = /usr/X/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = CC -QMAKE_LINK_SHLIB = CC -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -G -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -h$$LITERAL_WHITESPACE -QMAKE_LFLAGS_THREAD = -Kthread -QMAKE_RPATH = -R - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lresolv -lsocket -lnsl -lm -QMAKE_LIBS_X11SM = -lSM -lICE - -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXt -QMAKE_LIBS_OPENGL_QT = -lGL - -QMAKE_LIBS_THREAD = - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cq -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/unixware-g++ b/python/sip/specs/unixware-g++ deleted file mode 100644 index cd7735ee..00000000 --- a/python/sip/specs/unixware-g++ +++ /dev/null @@ -1,81 +0,0 @@ -# -# qmake configuration for unixware-g++ -# -# Written for UnixWare 7 with OSTK -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release link_prl -QT += core gui - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = yacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -W -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_SHLIB = -fPIC -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD - -QMAKE_INCDIR = -QMAKE_LIBDIR = -QMAKE_INCDIR_X11 = -QMAKE_LIBDIR_X11 = /usr/X/lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] -QMAKE_INCDIR_OPENGL = -QMAKE_LIBDIR_OPENGL = - -QMAKE_LINK = g++ -QMAKE_LINK_SHLIB = g++ -QMAKE_LFLAGS = -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_SHLIB = -shared -QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_SONAME = -QMAKE_LFLAGS_THREAD = -QMAKE_RPATH = -Wl,-R, - -QMAKE_LIBS = -QMAKE_LIBS_DYNLOAD = -ldl -QMAKE_LIBS_X11 = -lXext -lX11 -lresolv -lsocket -lnsl -lm -QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXt -QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_LIBS_THREAD = -lthread - -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - -QMAKE_AR = ar cq -QMAKE_RANLIB = - -QMAKE_TAR = tar -cf -QMAKE_GZIP = gzip -9f - -QMAKE_COPY = cp -f -QMAKE_MOVE = mv -f -QMAKE_DEL_FILE = rm -f -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p -load(qt_config) diff --git a/python/sip/specs/win32-borland b/python/sip/specs/win32-borland deleted file mode 100644 index 63bf07ae..00000000 --- a/python/sip/specs/win32-borland +++ /dev/null @@ -1,90 +0,0 @@ -# -# qmake configuration for win32-borland -# -# Written for Borland C++ -# - -MAKEFILE_GENERATOR = BMAKE -TEMPLATE = app -CONFIG += qt warn_on release link_prl copy_dir_files no_empty_targets cd_change_global debug_and_release debug_and_release_target -QT += core gui -DEFINES += UNICODE -QMAKE_NOFORCE = 1 -QMAKE_COMPILER_DEFINES += __BORLANDC__ WIN32 - -QMAKE_CC = bcc32 -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = byacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -tWR -tWM -QMAKE_CFLAGS_WARN_ON = -w -w-hid -QMAKE_CFLAGS_WARN_OFF = -w- -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -v -QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_CONSOLE = -tWC - -QMAKE_CXX = $$QMAKE_CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_CONSOLE = $$QMAKE_CFLAGS_CONSOLE -QMAKE_CXXFLAGS_STL_ON = -QMAKE_CXXFLAGS_STL_OFF = -QMAKE_CXXFLAGS_RTTI_ON = -QMAKE_CXXFLAGS_RTTI_OFF = -RT- -QMAKE_CXXFLAGS_EXCEPTIONS_ON = -QMAKE_CXXFLAGS_EXCEPTIONS_OFF = -x- - -QMAKE_INCDIR = -QMAKE_LIBDIR = $(BCB)\lib -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] - -QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -o$obj $src -QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -o$@ $< -QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -o$obj $src -QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -o$@ $< - -QMAKE_LINK = ilink32 -QMAKE_LFLAGS = -c -x -Gn -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = -v -QMAKE_LFLAGS_CONSOLE = -ap -Tpe c0x32.obj -QMAKE_LFLAGS_WINDOWS = -aa -Tpe c0w32.obj -QMAKE_LFLAGS_DLL= -Gi -aa -Tpd c0d32.obj - -QMAKE_LIBS = import32.lib cw32mti.lib -QMAKE_LIBS_CORE = -QMAKE_LIBS_GUI = -QMAKE_LIBS_NETWORK = ws2_32.lib -QMAKE_LIBS_OPENGL = -QMAKE_LIBS_COMPAT = -QMAKE_LIBS_QT_ENTRY = -lqtmain - -#QMAKE_LIBS_OPENGL = -#QMAKE_LFLAGS_OPENGL = /dopengl32.dll - -QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe -QMAKE_UIC = $$[QT_INSTALL_BINS]\uic.exe -QMAKE_IDC = $$[QT_INSTALL_BINS]\idc.exe - -QMAKE_IDL = midl -QMAKE_LIB = tlib /C /P256 -QMAKE_RC = brcc32 -dQ_CC_BOR - -QMAKE_ZIP = zip -r -9 - -QMAKE_COPY = copy /y -QMAKE_COPY_DIR = xcopy /s /q /y /i -QMAKE_MOVE = move -QMAKE_DEL_FILE = del -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = if not exist -QMAKE_MKDIR = mkdir - -load(qt_config) diff --git a/python/sip/specs/win32-g++ b/python/sip/specs/win32-g++ deleted file mode 100644 index 0c45103d..00000000 --- a/python/sip/specs/win32-g++ +++ /dev/null @@ -1,102 +0,0 @@ -# -# qmake configuration for win32-g++ -# -# Written for MinGW -# - -MAKEFILE_GENERATOR = MINGW -TEMPLATE = app -CONFIG += qt warn_on release link_prl copy_dir_files debug_and_release debug_and_release_target precompile_header -QT += core gui -DEFINES += UNICODE QT_LARGEFILE_SUPPORT -QMAKE_COMPILER_DEFINES += __GNUC__ WIN32 - -QMAKE_EXT_OBJ = .o - -QMAKE_CC = gcc -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = byacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -Wall -QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -QMAKE_CFLAGS_DEBUG = -g -QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses -QMAKE_CFLAGS_THREAD = -mthreads - -QMAKE_CXX = g++ -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD -QMAKE_CXXFLAGS_RTTI_ON = -frtti -QMAKE_CXXFLAGS_RTTI_OFF = -fno-rtti -QMAKE_CXXFLAGS_EXCEPTIONS_ON = -fexceptions -QMAKE_CXXFLAGS_EXCEPTIONS_OFF = -fno-exceptions - -QMAKE_INCDIR = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] - -QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -o $obj $src -QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< -QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src -QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< - -QMAKE_LINK = g++ -QMAKE_LFLAGS = -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -QMAKE_LFLAGS_RELEASE = -Wl,-s -QMAKE_LFLAGS_DEBUG = -QMAKE_LFLAGS_CONSOLE = -Wl,-subsystem,console -QMAKE_LFLAGS_WINDOWS = -Wl,-subsystem,windows -QMAKE_LFLAGS_DLL = -shared -QMAKE_LINK_OBJECT_MAX = 10 -QMAKE_LINK_OBJECT_SCRIPT= object_script - - -QMAKE_LIBS = -QMAKE_LIBS_CORE = -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 -lws2_32 -QMAKE_LIBS_GUI = -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lws2_32 -lole32 -luuid -luser32 -QMAKE_LIBS_NETWORK = -lws2_32 -QMAKE_LIBS_OPENGL = -lopengl32 -lglu32 -lgdi32 -luser32 -QMAKE_LIBS_COMPAT = -ladvapi32 -lshell32 -lcomdlg32 -luser32 -lgdi32 -lws2_32 -QMAKE_LIBS_QT_ENTRY = -lmingw32 -lqtmain - -MINGW_IN_SHELL = $$(MINGW_IN_SHELL) -isEqual(MINGW_IN_SHELL, 1) { - QMAKE_DIR_SEP = / - QMAKE_COPY = cp - QMAKE_COPY_DIR = xcopy /s /q /y /i - QMAKE_MOVE = mv - QMAKE_DEL_FILE = rm - QMAKE_MKDIR = mkdir - QMAKE_DEL_DIR = rmdir -} else { - QMAKE_COPY = copy /y - QMAKE_COPY_DIR = xcopy /s /q /y /i - QMAKE_MOVE = move - QMAKE_DEL_FILE = del - QMAKE_MKDIR = mkdir - QMAKE_DEL_DIR = rmdir -} -QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc.exe -QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe -QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe - -QMAKE_IDL = midl -QMAKE_LIB = ar -ru -QMAKE_RC = windres - -QMAKE_ZIP = zip -r -9 - -QMAKE_STRIP = strip -QMAKE_STRIPFLAGS_LIB += --strip-unneeded -QMAKE_CHK_DIR_EXISTS = if not exist -load(qt_config) diff --git a/python/sip/specs/win32-icc b/python/sip/specs/win32-icc deleted file mode 100644 index ca00e9e5..00000000 --- a/python/sip/specs/win32-icc +++ /dev/null @@ -1,87 +0,0 @@ -# -# qmake configuration for win32-icc -# -# Written for Intel C++ -# - -MAKEFILE_GENERATOR = MSVC -TEMPLATE = app -CONFIG += qt warn_on release incremental flat link_prl precompile_header copy_dir_files debug_and_release debug_and_release_target -QT += core gui -DEFINES += UNICODE QT_LARGEFILE_SUPPORT -QMAKE_COMPILER_DEFINES += __INTEL_COMPILER _MSC_VER=1300 WIN32 - -QMAKE_CC = icl -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = byacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -nologo -Zm200 -QMAKE_CFLAGS_WARN_ON = -W3 /Qwd673 -QMAKE_CFLAGS_WARN_OFF = -W0 /Qwd673 -QMAKE_CFLAGS_RELEASE = -O2 -MD -QMAKE_CFLAGS_DEBUG = -Zi -MDd -QMAKE_CFLAGS_YACC = - -QMAKE_CXX = $$QMAKE_CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS /Zc:forScope -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_STL_ON = -GX -QMAKE_CXXFLAGS_STL_OFF = -QMAKE_CXXFLAGS_RTTI_ON = -GR -QMAKE_CXXFLAGS_RTTI_OFF = -QMAKE_CXXFLAGS_EXCEPTIONS_ON = -GX -QMAKE_CXXFLAGS_EXCEPTIONS_OFF = - -QMAKE_INCDIR = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] - -QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CC_IMP_BATCH = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ @<< -QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<< - -QMAKE_LINK = link -QMAKE_LFLAGS = /NOLOGO -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = /DEBUG -QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:console -QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:windows -QMAKE_LFLAGS_DLL = /DLL -QMAKE_LFLAGS_QT_DLL = /BASE:0x39D00000 - -QMAKE_LIBS = -QMAKE_LIBS_CORE = kernel32.lib user32.lib shell32.lib uuid.lib ole32.lib advapi32.lib ws2_32.lib -QMAKE_LIBS_GUI = gdi32.lib comdlg32.lib oleaut32.lib imm32.lib winmm.lib winspool.lib ws2_32.lib ole32.lib user32.lib -QMAKE_LIBS_NETWORK = ws2_32.lib -QMAKE_LIBS_OPENGL = opengl32.lib glu32.lib gdi32.lib user32.lib delayimp.lib -QMAKE_LIBS_COMPAT = advapi32.lib shell32.lib comdlg32.lib user32.lib gdi32.lib ws2_32.lib -QMAKE_LIBS_QT_ENTRY = -lqtmain - -QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe -QMAKE_UIC = $$[QT_INSTALL_BINS]\uic.exe -QMAKE_IDC = $$[QT_INSTALL_BINS]\idc.exe - -QMAKE_IDL = midl -QMAKE_LIB = lib /NOLOGO -QMAKE_RC = rc - -QMAKE_ZIP = zip -r -9 - -QMAKE_COPY = copy /y -QMAKE_COPY_DIR = xcopy /s /q /y /i -QMAKE_MOVE = move -QMAKE_DEL_FILE = del -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = if not exist -QMAKE_MKDIR = mkdir - -DSP_EXTENSION = .dsp -load(qt_config) diff --git a/python/sip/specs/win32-msvc b/python/sip/specs/win32-msvc deleted file mode 100644 index 2332b6b9..00000000 --- a/python/sip/specs/win32-msvc +++ /dev/null @@ -1,86 +0,0 @@ -# -# qmake configuration for win32-msvc -# -# Written for Microsoft C++ -# - -MAKEFILE_GENERATOR = MSVC -TEMPLATE = app -CONFIG += qt warn_on release incremental flat link_prl precompile_header copy_dir_files cd_change_global no_delete_multiple_files debug_and_release debug_and_release_target -QT += core gui -DEFINES += UNICODE QT_LARGEFILE_SUPPORT -QMAKE_COMPILER_DEFINES += _MSC_VER=1200 WIN32 - -QMAKE_CC = cl -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = byacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -nologo -Zm200 -QMAKE_CFLAGS_WARN_ON = -W3 -QMAKE_CFLAGS_WARN_OFF = -W0 -QMAKE_CFLAGS_RELEASE = -O1 -MD -QMAKE_CFLAGS_DEBUG = -Zi -MDd -QMAKE_CFLAGS_YACC = - -QMAKE_CXX = $$QMAKE_CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_STL_ON = -GX -QMAKE_CXXFLAGS_STL_OFF = -QMAKE_CXXFLAGS_RTTI_ON = -GR -QMAKE_CXXFLAGS_RTTI_OFF = -QMAKE_CXXFLAGS_EXCEPTIONS_ON = -GX -QMAKE_CXXFLAGS_EXCEPTIONS_OFF = - -QMAKE_INCDIR = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] - -QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CC_IMP_BATCH = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ @<< -QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<< - -QMAKE_LINK = link -QMAKE_LFLAGS = /NOLOGO -QMAKE_LFLAGS_RELEASE = /INCREMENTAL:NO -QMAKE_LFLAGS_DEBUG = /DEBUG -QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:console -QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:windows -QMAKE_LFLAGS_DLL = /DLL - -QMAKE_LIBS = -QMAKE_LIBS_CORE = kernel32.lib user32.lib shell32.lib uuid.lib ole32.lib advapi32.lib ws2_32.lib -QMAKE_LIBS_GUI = gdi32.lib comdlg32.lib oleaut32.lib imm32.lib winmm.lib winspool.lib ws2_32.lib ole32.lib user32.lib -QMAKE_LIBS_NETWORK = ws2_32.lib -QMAKE_LIBS_OPENGL = opengl32.lib glu32.lib gdi32.lib user32.lib delayimp.lib -QMAKE_LIBS_COMPAT = advapi32.lib shell32.lib comdlg32.lib user32.lib gdi32.lib ws2_32.lib -QMAKE_LIBS_QT_ENTRY = -lqtmain - -QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe -QMAKE_UIC = $$[QT_INSTALL_BINS]\uic.exe -QMAKE_IDC = $$[QT_INSTALL_BINS]\idc.exe - -QMAKE_IDL = midl -QMAKE_LIB = lib /NOLOGO -QMAKE_RC = rc - -QMAKE_ZIP = zip -r -9 - -QMAKE_COPY = copy /y -QMAKE_COPY_DIR = xcopy /s /q /y /i -QMAKE_MOVE = move -QMAKE_DEL_FILE = del -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = if not exist -QMAKE_MKDIR = mkdir - -DSP_EXTENSION = .dsp -load(qt_config) diff --git a/python/sip/specs/win32-msvc.net b/python/sip/specs/win32-msvc.net deleted file mode 100644 index 5fbb7566..00000000 --- a/python/sip/specs/win32-msvc.net +++ /dev/null @@ -1,88 +0,0 @@ -# -# qmake configuration for win32-msvc.net -# -# Written for Microsoft C++.NET -# - -MAKEFILE_GENERATOR = MSVC.NET -TEMPLATE = app -CONFIG += qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files debug_and_release debug_and_release_target -QT += core gui -DEFINES += UNICODE WIN32 QT_LARGEFILE_SUPPORT -QMAKE_COMPILER_DEFINES += _MSC_VER=1300 WIN32 - -QMAKE_CC = cl -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = byacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -nologo -Zm200 -QMAKE_CFLAGS_WARN_ON = -W3 -QMAKE_CFLAGS_WARN_OFF = -W0 -QMAKE_CFLAGS_RELEASE = -O2 -MD -QMAKE_CFLAGS_DEBUG = -Zi -MDd -QMAKE_CFLAGS_YACC = - -QMAKE_CXX = $$QMAKE_CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -w34100 -w34189 -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_STL_ON = -EHsc -QMAKE_CXXFLAGS_STL_OFF = -QMAKE_CXXFLAGS_RTTI_ON = -GR -QMAKE_CXXFLAGS_RTTI_OFF = -QMAKE_CXXFLAGS_EXCEPTIONS_ON = -EHsc -QMAKE_CXXFLAGS_EXCEPTIONS_OFF = - -QMAKE_INCDIR = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] - -QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CC_IMP_BATCH = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ @<< -QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<< - -QMAKE_LINK = link -QMAKE_LFLAGS = /NOLOGO -QMAKE_LFLAGS_RELEASE = /INCREMENTAL:NO -QMAKE_LFLAGS_DEBUG = /DEBUG -QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:CONSOLE -QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS -QMAKE_LFLAGS_DLL = /DLL - -QMAKE_LIBS_CORE = kernel32.lib user32.lib shell32.lib uuid.lib ole32.lib advapi32.lib ws2_32.lib -QMAKE_LIBS_GUI = gdi32.lib comdlg32.lib oleaut32.lib imm32.lib winmm.lib winspool.lib ws2_32.lib ole32.lib user32.lib -QMAKE_LIBS_NETWORK = ws2_32.lib -QMAKE_LIBS_OPENGL = opengl32.lib glu32.lib gdi32.lib user32.lib -QMAKE_LIBS_COMPAT = advapi32.lib shell32.lib comdlg32.lib user32.lib gdi32.lib ws2_32.lib - -QMAKE_LIBS_QT_ENTRY = -lqtmain - -QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe -QMAKE_UIC = $$[QT_INSTALL_BINS]\uic.exe -QMAKE_IDC = $$[QT_INSTALL_BINS]\idc.exe - -QMAKE_IDL = midl -QMAKE_LIB = lib /NOLOGO -QMAKE_RC = rc - -QMAKE_ZIP = zip -r -9 - -QMAKE_COPY = copy /y -QMAKE_COPY_DIR = xcopy /s /q /y /i -QMAKE_MOVE = move -QMAKE_DEL_FILE = del -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = if not exist -QMAKE_MKDIR = mkdir - -VCPROJ_EXTENSION = .vcproj -VCSOLUTION_EXTENSION = .sln -VCPROJ_KEYWORD = Qt4VSv1.0 -load(qt_config) diff --git a/python/sip/specs/win32-msvc2005 b/python/sip/specs/win32-msvc2005 deleted file mode 100644 index 1205df40..00000000 --- a/python/sip/specs/win32-msvc2005 +++ /dev/null @@ -1,88 +0,0 @@ -# -# qmake configuration for win32-msvc2005 -# -# Written for Microsoft VC2005.NET -# - -MAKEFILE_GENERATOR = MSVC.NET -TEMPLATE = app -CONFIG += qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files debug_and_release debug_and_release_target embed_manifest_dll -QT += core gui -DEFINES += UNICODE WIN32 QT_LARGEFILE_SUPPORT -QMAKE_COMPILER_DEFINES += _MSC_VER=1400 WIN32 - -QMAKE_CC = cl -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = byacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t- -QMAKE_CFLAGS_WARN_ON = -W3 -QMAKE_CFLAGS_WARN_OFF = -W0 -QMAKE_CFLAGS_RELEASE = -O2 -MD -QMAKE_CFLAGS_DEBUG = -Zi -MDd -QMAKE_CFLAGS_YACC = - -QMAKE_CXX = $$QMAKE_CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -w34100 -w34189 -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_STL_ON = -EHsc -QMAKE_CXXFLAGS_STL_OFF = -QMAKE_CXXFLAGS_RTTI_ON = -GR -QMAKE_CXXFLAGS_RTTI_OFF = -QMAKE_CXXFLAGS_EXCEPTIONS_ON = -EHsc -QMAKE_CXXFLAGS_EXCEPTIONS_OFF = - -QMAKE_INCDIR = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] - -QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CC_IMP_BATCH = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ @<< -QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<< - -QMAKE_LINK = link -QMAKE_LFLAGS = /NOLOGO -QMAKE_LFLAGS_RELEASE = /INCREMENTAL:NO -QMAKE_LFLAGS_DEBUG = /DEBUG -QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:CONSOLE -QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS -QMAKE_LFLAGS_DLL = /DLL - -QMAKE_LIBS_CORE = kernel32.lib user32.lib shell32.lib uuid.lib ole32.lib advapi32.lib ws2_32.lib -QMAKE_LIBS_GUI = gdi32.lib comdlg32.lib oleaut32.lib imm32.lib winmm.lib winspool.lib ws2_32.lib ole32.lib user32.lib -QMAKE_LIBS_NETWORK = ws2_32.lib -QMAKE_LIBS_OPENGL = opengl32.lib glu32.lib gdi32.lib user32.lib -QMAKE_LIBS_COMPAT = advapi32.lib shell32.lib comdlg32.lib user32.lib gdi32.lib ws2_32.lib - -QMAKE_LIBS_QT_ENTRY = -lqtmain - -QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe -QMAKE_UIC = $$[QT_INSTALL_BINS]\uic.exe -QMAKE_IDC = $$[QT_INSTALL_BINS]\idc.exe - -QMAKE_IDL = midl -QMAKE_LIB = lib /NOLOGO -QMAKE_RC = rc - -QMAKE_ZIP = zip -r -9 - -QMAKE_COPY = copy /y -QMAKE_COPY_DIR = xcopy /s /q /y /i -QMAKE_MOVE = move -QMAKE_DEL_FILE = del -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = if not exist -QMAKE_MKDIR = mkdir - -VCPROJ_EXTENSION = .vcproj -VCSOLUTION_EXTENSION = .sln -VCPROJ_KEYWORD = Qt4VSv1.0 -load(qt_config) diff --git a/python/sip/specs/win32-watcom b/python/sip/specs/win32-watcom deleted file mode 100644 index 463778bd..00000000 --- a/python/sip/specs/win32-watcom +++ /dev/null @@ -1,69 +0,0 @@ -# -# $Id$ -# -# qmake configuration for win32-watcom -# -# Written for Watcom C++, now OpenWatcom. -# - -TEMPLATE = app -CONFIG += qt warn_on release link_prl - -QMAKE_CC = wcl386 -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = byacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -zq -QMAKE_CFLAGS_WARN_ON = -w2 -QMAKE_CFLAGS_WARN_OFF = -w0 -QMAKE_CFLAGS_RELEASE = -ox -QMAKE_CFLAGS_DEBUG = -d2 -QMAKE_CFLAGS_YACC = - -QMAKE_CXX = $$QMAKE_CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC - -QMAKE_INCDIR = -QMAKE_INCDIR_QT = $(QTDIR)\include - -QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -fo=$obj $src -QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -fo=$obj $src - -QMAKE_LINK = wlink -QMAKE_LFLAGS = op quiet op c -QMAKE_LFLAGS_RELEASE = -QMAKE_LFLAGS_DEBUG = d all -QMAKE_LFLAGS_CONSOLE = sys nt -QMAKE_LFLAGS_WINDOWS = sys nt_win -QMAKE_LFLAGS_CONSOLE_DLL= sys nt -QMAKE_LFLAGS_WINDOWS_DLL= sys nt_win - -QMAKE_LIBS = -QMAKE_LIBS_CONSOLE = -QMAKE_LIBS_WINDOWS = -QMAKE_LIBS_QT = %QTDIR%\lib\qt.lib -QMAKE_LIBS_QT_ENTRY = %QTDIR%\lib\qtmain.lib - -QMAKE_LIBS_OPENGL = opengl32.lib - -QMAKE_MOC = $(QTDIR)/bin/moc.exe -QMAKE_UIC = $(QTDIR)/bin/uic.exe -QMAKE_IDC = $(QTDIR)/bin/idc.exe - -QMAKE_LIB = wlib -b -c -n -q -p=512 -QMAKE_RC = rc - -QMAKE_ZIP = zip -r -9 - -QMAKE_COPY = copy -QMAKE_MOVE = move -QMAKE_DEL_FILE = del -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = test -d -QMAKE_MKDIR = mkdir -p |