2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-19 16:32:16 +00:00

Compare commits

..

441 Commits

Author SHA1 Message Date
nobody
7c7b1d4909 This commit was manufactured by cvs2svn to create tag
'version_0-9-4'.

[SVN r18816]
2003-06-17 01:56:46 +00:00
Bruno da Silva de Oliveira
73e2ab5125 - Added a new test exercising the new automatic inheritation
[SVN r18815]
2003-06-17 01:56:45 +00:00
Bruno da Silva de Oliveira
7ea2ab1672 - If you export a derived class without exporting its base classes, the derived class will explicitly export the bases's methods and attributes. Before, if you were interested in the bases's methods, you had to export the base classes too.
- Added a new function, no_override. When a member function is specified as "no_override", no virtual wrappers are generated for it, improving performance and letting the code more clean.

- There was a bug in which the policy of virtual member functions was being ignored (patch by Roman Sulzhyk).


[SVN r18814]
2003-06-17 01:34:26 +00:00
Bruno da Silva de Oliveira
c821e903f8 Added tests for linux.
[SVN r18809]
2003-06-16 20:36:36 +00:00
Ralf W. Grosse-Kunstleve
54db04521a MIPSpro workaround
[SVN r18744]
2003-06-09 13:10:34 +00:00
Bruno da Silva de Oliveira
91fdecd76f - Changed the filename of one of the doc files to limit it to 32 chars.
[SVN r18709]
2003-06-08 22:51:37 +00:00
Dave Abrahams
f140a74a13 Added MinGW tips
[SVN r18695]
2003-06-06 11:18:34 +00:00
Bruno da Silva de Oliveira
4854a2a81b - Added another entry, about ESSS.
[SVN r18685]
2003-06-06 00:04:51 +00:00
Bruno da Silva de Oliveira
d94bb65006 - Major improvements in memory usage.
[SVN r18681]
2003-06-05 15:14:52 +00:00
Bruno da Silva de Oliveira
6ca5280b2c - Fixed bug in GCCXMLParser
[SVN r18672]
2003-06-04 22:07:27 +00:00
Dave Abrahams
5da3e1deea Leak bug fixed thanks to gideon may <gideon-at-computer.org> for
reporting it.


[SVN r18671]
2003-06-04 20:47:39 +00:00
Dave Abrahams
1ae85d0e39 Added Jayacard
[SVN r18660]
2003-06-04 02:23:13 +00:00
Bruno da Silva de Oliveira
256e3a467c - Appliced a patch from Giulio Eulisse that allows unnamed enumerations to be
exported with an AllFromHeader construct


[SVN r18657]
2003-06-03 20:58:22 +00:00
Ralf W. Grosse-Kunstleve
4477fe4dd6 Python 2.3 Tru64 cxx compatibility & a little cleanup
[SVN r18652]
2003-06-03 02:58:43 +00:00
Bruno da Silva de Oliveira
5d1e245858 - New construct, add_method.
[SVN r18650]
2003-06-03 01:48:51 +00:00
Ralf W. Grosse-Kunstleve
ec750a44c9 missing include added (to avoid gcc 3.2 and tru64_cxx errors)
[SVN r18646]
2003-06-02 13:17:11 +00:00
Dave Abrahams
006f1d9802 Tests for to-python conversion of NULL shared_ptrs that didn't
originate as Python objects.


[SVN r18637]
2003-06-01 14:49:51 +00:00
Dave Abrahams
638b3d4ee1 added a small comment
[SVN r18636]
2003-06-01 14:48:53 +00:00
Dave Abrahams
a1cc1651fa clarified cygwin instructions
[SVN r18632]
2003-05-31 22:03:29 +00:00
Bruno da Silva de Oliveira
9fe141f5ad - Fixed bug related to --multiple and Vars
[SVN r18630]
2003-05-31 21:20:23 +00:00
Bruno da Silva de Oliveira
d52f0c7d40 - New tests
[SVN r18629]
2003-05-31 21:18:09 +00:00
Bruno da Silva de Oliveira
bb55c4a855 no message
[SVN r18628]
2003-05-31 20:57:03 +00:00
Dave Abrahams
f1a06b14de Handle null shared_ptrs
[SVN r18627]
2003-05-31 16:40:42 +00:00
Dave Abrahams
286f3dc093 Added #include <boost/python/detail/prefix.hpp> to ensure that all public Boost.Python headers begin by #including Python.h before as many system headers as possible.
[SVN r18626]
2003-05-31 14:53:02 +00:00
Dave Abrahams
a731322782 Test linking with the static library also.
[SVN r18624]
2003-05-31 13:44:16 +00:00
Dave Abrahams
0db07ec25e Added missing #include thanks to Ben Hutchings <ben.hutchings-at-businesswebsoftware.com>
[SVN r18623]
2003-05-31 13:43:29 +00:00
Bruno da Silva de Oliveira
bc112ba65f - Fixed bug in the generation of virtual methods.
[SVN r18619]
2003-05-30 21:52:33 +00:00
Dave Abrahams
62ba322658 updated ImageMagick info.
[SVN r18597]
2003-05-29 14:00:00 +00:00
Dave Abrahams
02135b550d OpenSceneGraph has a web page
[SVN r18596]
2003-05-29 13:14:48 +00:00
Ralf W. Grosse-Kunstleve
ee4b06bb50 static keyword removed (Aye, Aye Sir David Abrahams!)
[SVN r18570]
2003-05-27 21:07:40 +00:00
Ralf W. Grosse-Kunstleve
16c5435ca8 fix typo
[SVN r18554]
2003-05-26 22:03:46 +00:00
Bruno da Silva de Oliveira
2595049748 - Added the Techniques section
[SVN r18552]
2003-05-26 21:10:41 +00:00
Ralf W. Grosse-Kunstleve
5911691c0d workaround for silly MIPSpro compiler
[SVN r18550]
2003-05-26 19:46:05 +00:00
Ralf W. Grosse-Kunstleve
e369bddc84 avoid use of sizeof to enable compilation with buggy gcc 3.3; change as per David Abrahams' instructions
[SVN r18549]
2003-05-26 19:06:00 +00:00
Ralf W. Grosse-Kunstleve
dccf2bbb4a Tru64 cxx compatibility
[SVN r18548]
2003-05-26 19:03:24 +00:00
Bruno da Silva de Oliveira
eaab3fc038 - Fixed link to the tutorial
[SVN r18519]
2003-05-23 21:06:22 +00:00
Bruno da Silva de Oliveira
858e1aba67 - Support for global variables
- Bug fixes in ClassExporter


[SVN r18518]
2003-05-23 20:37:35 +00:00
Bruno da Silva de Oliveira
19eff7791d - HeaderExporter now doesn't export names that begin with "_"
- Bug in ClassExporter, was adding an attribute to the members of base classes in GenerateVirtualMethods


[SVN r18516]
2003-05-23 19:13:52 +00:00
Bruno da Silva de Oliveira
c81af4ffe0 - Two new questions, about compiling time and creating packages.
[SVN r18515]
2003-05-23 18:01:39 +00:00
Dave Abrahams
9675e4233b Fix a bug in dangling reference/pointer detection. Thanks to Daniel
Paull <dlp-at-fractaltechnologies.com> for reporting it.


[SVN r18498]
2003-05-22 15:13:22 +00:00
Dave Abrahams
e6a176bb1e Add initializer list for silly GCC
[SVN r18491]
2003-05-22 01:35:53 +00:00
Dave Abrahams
ff0980914b reinstate workarounds for vc7
[SVN r18490]
2003-05-22 01:34:04 +00:00
Dave Abrahams
43e5ccd0a7 object_core.hpp - allow wrapping of objects which take object managers in their constructors.
forward.hpp
pointer_holder.hpp
value_holder.hpp
test/long.[py/cpp]

pointee.hpp,    - begin making borland work.
cv_category.hpp,
referent_storage.hpp
instance.hpp

self.hpp        - removed flotsam

signature.hpp   - use vector instead of list

destroy.hpp     - removed needless complication

make_keyword_range_fn.hpp - support for simpler init using vectors

class_converters.hpp - workaround for pro7

inheritance.hpp - simplified; took out pro7 workarounds; factored out
                  inheritance_query.hpp to reduce recompilation
                  dependencies

make_ptr_instance.hpp - add missing typename

registry.cpp    - add a little invariant checking for metrowerks

class.cpp       - stopped relying on class_id typedef

test/data_members.cpp - added a few more tests to make sure things compile at least.
test/destroy_test.cpp - removed cheating has_trivial_destructor tests
test/enum.cpp         - added some pro7 workarounds
test/virtual_functions.[py/cpp] - added _some_ tests for callbacks which return by reference.


[SVN r18489]
2003-05-21 22:17:23 +00:00
Dave Abrahams
66d6272942 Use mpl::vector and simplify constructor generation so we don't have
to constantly reverse lists.


[SVN r18487]
2003-05-21 21:53:30 +00:00
Dave Abrahams
2f1b828967 Getter setter bugfixes for attribute access
[SVN r18486]
2003-05-21 21:52:26 +00:00
Dave Abrahams
622636dcf1 Killed unneeded #include
[SVN r18485]
2003-05-21 21:51:03 +00:00
Dave Abrahams
0c22c276bf Workaround CW bug
[SVN r18472]
2003-05-20 19:01:44 +00:00
Bruno da Silva de Oliveira
7a4a79c74e no message
[SVN r18461]
2003-05-20 03:17:19 +00:00
Bruno da Silva de Oliveira
06f454e1d3 - Some small memory improvements
[SVN r18459]
2003-05-20 01:35:13 +00:00
Bruno da Silva de Oliveira
c1dbd52de1 - Fixed bug where functions with the same name where not being exported correctly
[SVN r18458]
2003-05-19 23:58:35 +00:00
Dave Abrahams
c3f5679188 Bug fix
[SVN r18372]
2003-05-08 20:18:14 +00:00
Bruno da Silva de Oliveira
97e2628f95 - Fixed bug where GCCXML was generating more than one declaration of a given class
[SVN r18359]
2003-05-08 10:38:51 +00:00
Dave Abrahams
6cecfcb704 restore from disk crash
[SVN r18353]
2003-05-08 02:19:10 +00:00
Ralf W. Grosse-Kunstleve
022a5a16f5 Python 2.3b1 compatibility: LONG_LONG -> PY_LONG_LONG
[SVN r18337]
2003-05-01 05:19:47 +00:00
Bruno da Silva de Oliveira
a39a834e75 - Now trying to export forward declared classes gives a warning.
- Forward-declared classes are ignored with AllFromHeader
- Bug: now it's possible to exclude classes, functions and enums from AllFromHeader


[SVN r18289]
2003-04-23 00:42:34 +00:00
Dave Abrahams
2a1210384a Warning suppression from Dominique Devriese <dominique.devriese-at-student.kuleuven.ac.be>
[SVN r18288]
2003-04-22 14:21:37 +00:00
Bruno da Silva de Oliveira
d497611069 - New code (more generic) for declaring the smart pointer converters
[SVN r18269]
2003-04-16 22:35:09 +00:00
Dave Abrahams
46d8786f5a Tweak citations, etc.
[SVN r18265]
2003-04-16 16:12:34 +00:00
Dave Abrahams
b8028729eb NULL shared_ptr conversions, more tests for custom to-python shared_ptr registrations
[SVN r18263]
2003-04-16 14:32:14 +00:00
Dave Abrahams
30e7768a87 warning suppression
[SVN r18261]
2003-04-16 14:29:27 +00:00
Dave Abrahams
10dc663e07 *** empty log message ***
[SVN r18259]
2003-04-16 13:39:28 +00:00
Joel de Guzman
42fc57d761 tweaks
[SVN r18255]
2003-04-15 12:48:27 +00:00
Dave Abrahams
74cd2f4844 Fix bug report from Jacek Generowicz <jacek.generowicz-at-cern.ch>
[SVN r18254]
2003-04-15 11:10:53 +00:00
Bruno da Silva de Oliveira
a15135f1c1 - Fixed a inheritance bug, and added a test for it.
[SVN r18251]
2003-04-14 23:34:33 +00:00
Dave Abrahams
ccd84c0be6 Small changes to support new iterator adaptors in sandbox
[SVN r18212]
2003-04-09 11:57:59 +00:00
Joel de Guzman
510215f284 typo fixes
[SVN r18201]
2003-04-08 01:20:58 +00:00
Bruno da Silva de Oliveira
c7ea0aacd6 - Lots of fixes in the documentation
- Fixed support for return_opaque_pointer policy


[SVN r18199]
2003-04-08 01:01:32 +00:00
Bruno da Silva de Oliveira
f7f089d2d4 - Fixed bug where the order of instantiations in the --multiple mode could end up wrong
[SVN r18198]
2003-04-07 18:15:50 +00:00
Bruno da Silva de Oliveira
82721c77a1 - now includes documentation in the distribution
[SVN r18197]
2003-04-07 12:13:02 +00:00
Bruno da Silva de Oliveira
1c9bf7d91c - Generating code for the improved support of static data members of Boost.Python
[SVN r18193]
2003-04-06 20:47:10 +00:00
Bruno da Silva de Oliveira
9bf78396cb - fixed bug where return_opaque_pointer was not being added to the user context
[SVN r18192]
2003-04-06 13:43:19 +00:00
Bruno da Silva de Oliveira
d994e4719c - New unittests for linux, now testing single and multi modes
[SVN r18189]
2003-04-05 18:14:52 +00:00
Bruno da Silva de Oliveira
44b886bb76 - Added a new line after the end of the "_main.cpp" files in multiple mode
[SVN r18188]
2003-04-05 18:11:44 +00:00
Bruno da Silva de Oliveira
8d2f012bcf - added new option for generating bindings: --multiple
- some refactoring of the code
- now detects forward declarations and prints a warning about them


[SVN r18187]
2003-04-05 17:05:12 +00:00
Dave Abrahams
a86deed5f6 dummy
[SVN r18158]
2003-04-02 12:57:33 +00:00
Dave Abrahams
3fd9ad7a60 implement static data members
[SVN r18157]
2003-04-02 12:56:37 +00:00
Bruno da Silva de Oliveira
319a5cf97c - Added the experimental command line option -R, which is a workaround a gccxml's preprocessor bug
[SVN r18138]
2003-03-30 21:06:10 +00:00
Bruno da Silva de Oliveira
0fd503d6af - Bug where the full name of the operator wasn't used in the declaration
- Now converter operators that return char* or string are automatically named __str__ in Python
- Update documentation with info about Psyco


[SVN r18127]
2003-03-28 21:02:24 +00:00
Bruno da Silva de Oliveira
bf696026bd - Performance improvements (better psyco support, cache in CppParser)
[SVN r18123]
2003-03-28 12:47:15 +00:00
Bruno da Silva de Oliveira
734657244b - Changed the error message about missing policies.
[SVN r18118]
2003-03-27 23:40:59 +00:00
Bruno da Silva de Oliveira
d2470e4f9c - Fixed bug where virtual methods could end exported twice in the wrapper.
[SVN r18116]
2003-03-27 23:24:40 +00:00
Bruno da Silva de Oliveira
28a2792280 no message
[SVN r18107]
2003-03-27 17:23:52 +00:00
Bruno da Silva de Oliveira
cd985a33d8 - Added files to create a binary distribution
[SVN r18106]
2003-03-27 17:14:41 +00:00
Bruno da Silva de Oliveira
726d2beffd - Doc fix, about accessing the operators in the interface file
[SVN r18097]
2003-03-26 18:35:53 +00:00
Bruno da Silva de Oliveira
f04be3fc1b - No more "needs policy" warnings for functions that return PyObject*
[SVN r18096]
2003-03-26 15:25:38 +00:00
Bruno da Silva de Oliveira
b6927410d9 - Fixed stupid bug in HandlePolicy
[SVN r18095]
2003-03-26 15:06:14 +00:00
Bruno da Silva de Oliveira
44b2e1ef8b - Default policy for functions/methods that return const T& is now
return_value_policy<copy_const_reference>().


[SVN r18077]
2003-03-24 23:25:14 +00:00
Bruno da Silva de Oliveira
3d01e6af89 no message
[SVN r18067]
2003-03-23 18:29:11 +00:00
Bruno da Silva de Oliveira
00387b2076 - Documentation for smart-pointers
[SVN r18066]
2003-03-23 18:27:18 +00:00
Bruno da Silva de Oliveira
f9bf514801 - Added unittests for linux
[SVN r18065]
2003-03-23 18:23:09 +00:00
Bruno da Silva de Oliveira
fa27bddfab - added a case: wrapper for a virtual method
[SVN r18062]
2003-03-22 19:35:55 +00:00
Bruno da Silva de Oliveira
f27e8f8ddc no message
[SVN r18061]
2003-03-22 19:34:49 +00:00
Bruno da Silva de Oliveira
5b2623ff2e - bumped version number
[SVN r18060]
2003-03-22 19:33:33 +00:00
Bruno da Silva de Oliveira
a83a726b6e - Fixed bug where wrappers for virtual methods were ignored.
[SVN r18059]
2003-03-22 19:31:19 +00:00
Bruno da Silva de Oliveira
93df7e00a7 - Added new flags: -h, --help, -v, --version
[SVN r18058]
2003-03-22 18:20:16 +00:00
Bruno da Silva de Oliveira
6b7748a88d - Now exporting virtual methods from base classes too
[SVN r18057]
2003-03-22 18:19:25 +00:00
Bruno da Silva de Oliveira
f102c77fa2 no message
[SVN r18056]
2003-03-22 18:18:25 +00:00
Bruno da Silva de Oliveira
a4fa261b77 - New page about smart pointers, and misc fixes
[SVN r18055]
2003-03-22 18:16:01 +00:00
Dave Abrahams
8a15fefc6c update HippoDraw site
[SVN r18053]
2003-03-22 17:29:01 +00:00
Bruno da Silva de Oliveira
12a4cc16be - Added MANUAL support for shared_ptr and auto_ptrs. In the future, support should be automatic.
[SVN r18041]
2003-03-21 14:24:20 +00:00
Dave Abrahams
6335716342 fixed binary-ness
[SVN r18038]
2003-03-20 20:33:48 +00:00
Dave Abrahams
db0602ac2a *** empty log message ***
[SVN r18037]
2003-03-20 20:31:57 +00:00
Bruno da Silva de Oliveira
390ad530f1 - Bug: GenerateName in infos.py doesn't cover all possible cases.
[SVN r18028]
2003-03-20 04:55:38 +00:00
Dave Abrahams
6eb2e8d68a paper updates
[SVN r18027]
2003-03-20 02:56:22 +00:00
Dave Abrahams
b804b3b221 fix typo
[SVN r18025]
2003-03-20 02:53:47 +00:00
Joel de Guzman
936c1118bd Bump to v1.6.0
[SVN r18021]
2003-03-19 23:33:19 +00:00
Bruno da Silva de Oliveira
4ba7b8a8ff - Updated to reflect changes in declarations.py
[SVN r17997]
2003-03-19 05:55:28 +00:00
Bruno da Silva de Oliveira
70601e9da0 no message
[SVN r17995]
2003-03-19 05:54:26 +00:00
Bruno da Silva de Oliveira
c32d1f9614 - Fixed bug where the PointerDeclaration of functions and methods didn't have the & operator
[SVN r17994]
2003-03-19 05:03:49 +00:00
Dave Abrahams
e031f78ad4 news updates; added links to paper
[SVN r17993]
2003-03-19 03:57:59 +00:00
Bruno da Silva de Oliveira
7d0273051a - Fixed bug where an union that was a class member crashed pyste (unions are still not exported)
- Added support for int, double, float and long operators


[SVN r17989]
2003-03-19 02:49:18 +00:00
Bruno da Silva de Oliveira
29d537571b - Unit tests for the examples
[SVN r17987]
2003-03-19 02:47:29 +00:00
Dave Abrahams
39f243f76b Check in html and pdf versions
[SVN r17985]
2003-03-19 01:47:30 +00:00
Dave Abrahams
0712360cc9 Add funcptr FAQ
[SVN r17975]
2003-03-18 14:41:04 +00:00
Dave Abrahams
02c125cbb4 Add funcptr FAQ
[SVN r17974]
2003-03-18 14:40:09 +00:00
Bruno da Silva de Oliveira
13256fb7e9 - Fixed bugs in Linux
[SVN r17969]
2003-03-18 05:16:01 +00:00
Bruno da Silva de Oliveira
f11d757807 - Fixed bug where the permission bits were being copied to the tmp file
[SVN r17934]
2003-03-15 02:51:51 +00:00
Bruno da Silva de Oliveira
2e123849fb no message
[SVN r17931]
2003-03-14 23:39:04 +00:00
Bruno da Silva de Oliveira
2f6cfaf0e9 - Fixed definition of private default implementations
[SVN r17928]
2003-03-14 22:27:32 +00:00
Bruno da Silva de Oliveira
f9b216d6f9 - Now generating wrappers for protected and private virtual methods
[SVN r17924]
2003-03-14 21:12:55 +00:00
Dave Abrahams
5fdd10d77e respond to Ralf's suggestions
[SVN r17900]
2003-03-13 22:58:03 +00:00
Dave Abrahams
41de02d528 Added development history
[SVN r17899]
2003-03-13 22:05:50 +00:00
Ralf W. Grosse-Kunstleve
1c3d08f23a adjustment for MIPSpro
[SVN r17865]
2003-03-12 23:18:16 +00:00
Bruno da Silva de Oliveira
0f1dc1fd50 - fixed bug where non-public virtual methods where being exported
- fixed " call_method<%s>"  to " call_method< %s >"


[SVN r17860]
2003-03-12 21:26:45 +00:00
Dave Abrahams
cd06018820 opaque pointer conversions from Gottfried.Ganssauge@haufe.de
[SVN r17859]
2003-03-12 17:56:41 +00:00
Dave Abrahams
7816eb6344 fix copyrights
[SVN r17841]
2003-03-12 13:51:17 +00:00
Dave Abrahams
9813f4b55f Fix copyrights
[SVN r17840]
2003-03-12 13:50:18 +00:00
Dave Abrahams
f81ca21b22 opaque pointer conversions from Gottfried.Ganssauge@haufe.de
Acknowledgements for all


[SVN r17834]
2003-03-12 12:47:44 +00:00
Bruno da Silva de Oliveira
f1b7620c9e no message
[SVN r17828]
2003-03-12 03:42:37 +00:00
Bruno da Silva de Oliveira
7d5c453f59 no message
[SVN r17825]
2003-03-12 01:39:28 +00:00
Bruno da Silva de Oliveira
bc4feb42b5 - fixed "deepcopy" of infos bug
[SVN r17824]
2003-03-12 01:32:48 +00:00
Bruno da Silva de Oliveira
ca9920874f - fixed default arguments in virtual methods
[SVN r17823]
2003-03-12 01:32:00 +00:00
Bruno da Silva de Oliveira
415991f6fc - added a link to the Pyste documentation
[SVN r17806]
2003-03-11 03:34:28 +00:00
Bruno da Silva de Oliveira
20c52def19 - first version
[SVN r17805]
2003-03-11 03:29:22 +00:00
Bruno da Silva de Oliveira
7dcacbcfc4 - first version
[SVN r17804]
2003-03-11 03:20:24 +00:00
Ralf W. Grosse-Kunstleve
34bf1560a9 non-template function make_function1 must be inline
[SVN r17791]
2003-03-09 17:26:06 +00:00
Dave Abrahams
39195ac97a Fix for older EDGs
[SVN r17786]
2003-03-08 12:36:18 +00:00
Dave Abrahams
6aa71e1f72 Remove flotsam
[SVN r17783]
2003-03-08 08:53:19 +00:00
Dave Abrahams
257a6c45f8 Remove flotsam
[SVN r17782]
2003-03-08 08:51:45 +00:00
Dave Abrahams
d34a11b584 Fix for Python 2.3 long->int conversion behavior change
[SVN r17779]
2003-03-08 05:28:54 +00:00
Dave Abrahams
ca64c96133 Added dangling_reference FAQ
Various idiomatic MPL cleanups in indirect_traits.hpp
raw_function support
Patches for CWPro7.2
Patches to pass tests under Python 2.3 with the new bool type.
Tests for member operators returning const objects
Fixes for testing Boost.Python under Cygwin


[SVN r17777]
2003-03-08 03:53:19 +00:00
Ralf W. Grosse-Kunstleve
ff734e3269 MIPSpro compatibility
[SVN r17772]
2003-03-08 00:25:47 +00:00
Dave Abrahams
d028a60cc2 Workaround for vc7 bug (and regression test)
[SVN r17708]
2003-03-03 17:21:30 +00:00
Dave Abrahams
577f58149c tests for operators returning const objects
[SVN r17700]
2003-03-02 22:11:20 +00:00
Dave Abrahams
4b97e191b8 Fix formatting errors
[SVN r17697]
2003-03-02 15:25:35 +00:00
Ralf W. Grosse-Kunstleve
15a148ab10 minor polishing, corrections
[SVN r17696]
2003-03-02 02:50:49 +00:00
Dave Abrahams
5ac7741ca9 Updates for ACCU
[SVN r17695]
2003-03-02 00:55:07 +00:00
Dave Abrahams
4c7cff6e8e fix bad link
[SVN r17691]
2003-03-01 18:25:41 +00:00
Dave Abrahams
c6ca85b525 Added embedding tutorial from Dirk Gerrits. Thanks, Dirk!
[SVN r17690]
2003-03-01 18:19:38 +00:00
Dave Abrahams
99f45b474e Fix broken links
[SVN r17671]
2003-02-27 13:07:41 +00:00
Dave Abrahams
ee44c90e85 Fixes for Python and Cygwin testing
[SVN r17667]
2003-02-27 02:20:01 +00:00
Dave Abrahams
2c4fa48f46 Fixes for Intel5
[SVN r17658]
2003-02-26 13:48:16 +00:00
Aleksey Gurtovoy
90fcd9369d MPL names/directory structure refactoring
[SVN r17651]
2003-02-25 23:11:41 +00:00
Dave Abrahams
923feda9f7 update
[SVN r17627]
2003-02-25 03:54:38 +00:00
Dave Abrahams
6d7d2ea5fe initial checkin
[SVN r17626]
2003-02-25 03:31:36 +00:00
Dave Abrahams
4874a1801b Improved Boost.Python build reliability and documentation.
[SVN r17623]
2003-02-25 02:15:55 +00:00
Dave Abrahams
479d8fc0f6 shared_ptr deleter introspection support
miscellaneous cleanups and MPL idiom-izing


[SVN r17622]
2003-02-25 01:03:40 +00:00
Dave Abrahams
1c346b2531 fix metafunctions for MPL
[SVN r17621]
2003-02-25 00:57:33 +00:00
Dave Abrahams
5cdebaf896 gcc-2.95 workaround
[SVN r17620]
2003-02-25 00:56:55 +00:00
Joel de Guzman
600602f9dc Tutorial updates
[SVN r17598]
2003-02-23 03:53:36 +00:00
Joel de Guzman
2a530bb9d2 Tutorial updates. Added virtual functions with default implementations and reshufled the overloading topics to discuss manual overloading first.
[SVN r17597]
2003-02-23 02:23:15 +00:00
Dave Abrahams
acdad5caf3 better auto_ptr support
[SVN r17592]
2003-02-22 18:11:08 +00:00
Dave Abrahams
b42b243287 vc++7.1 bug workarounds
[SVN r17591]
2003-02-22 18:07:05 +00:00
Dave Abrahams
a76f5f3db7 mpl-ish cleanup
[SVN r17585]
2003-02-22 01:02:31 +00:00
Dave Abrahams
4e9f745d4a Fixups for cygwin
[SVN r17570]
2003-02-21 08:10:55 +00:00
Aleksey Gurtovoy
101961a7c6 remove old MSVC 6.5 workaround
[SVN r17564]
2003-02-20 21:31:46 +00:00
Aleksey Gurtovoy
29d1f860c1 ETI fixes
[SVN r17563]
2003-02-20 21:29:39 +00:00
Dave Abrahams
2663e73f1c Automatically add library-path values to RUN_PATH/RUN_LD_LIBRARY_PATH
[SVN r17562]
2003-02-20 20:28:05 +00:00
Aleksey Gurtovoy
1f9d0bb196 MSVC 7.0 ETI workaround
[SVN r17556]
2003-02-20 13:35:16 +00:00
Joel de Guzman
ff9f262fac tutorial update
[SVN r17512]
2003-02-18 18:44:16 +00:00
Dave Abrahams
472dc3bd41 made binary
[SVN r17320]
2003-02-11 17:30:23 +00:00
Dave Abrahams
6f91b93519 removed to make binary
[SVN r17319]
2003-02-11 17:29:27 +00:00
Joel de Guzman
47291f68b2 removed unnecessary file
[SVN r17318]
2003-02-11 12:18:47 +00:00
Ralf W. Grosse-Kunstleve
2b5ef3c572 Python 2.3 compatibility
[SVN r17271]
2003-02-07 18:56:16 +00:00
Ralf W. Grosse-Kunstleve
9c50496d93 second half of introduction rewritten; SWIG, SIP, CXX acknowledged as suggested by the PyConDC reviewers; technical points moved to Library Overview section
[SVN r17259]
2003-02-07 01:07:39 +00:00
Ralf W. Grosse-Kunstleve
80488e2f23 improved serialization and object interface sections; some sentences added to the end of the conclusion
[SVN r17258]
2003-02-06 22:42:36 +00:00
Dave Abrahams
ad8da7166b edits
[SVN r17257]
2003-02-06 20:56:26 +00:00
Dave Abrahams
55cb918c51 Add ownership question
[SVN r17250]
2003-02-06 13:50:53 +00:00
Dave Abrahams
ac55c5ccf7 Add FAQ reference
[SVN r17249]
2003-02-06 13:50:31 +00:00
Ralf W. Grosse-Kunstleve
5bcf90766f draft thinking hybrid section added
[SVN r17242]
2003-02-05 19:58:43 +00:00
Dave Abrahams
8f12fdea4a Remove workaround patches
[SVN r17128]
2003-01-31 18:37:11 +00:00
Dave Abrahams
6f687ee402 Added a FAQ
[SVN r17010]
2003-01-23 17:38:57 +00:00
Dave Abrahams
9dfe98abb0 bug fix + regression test
[SVN r17002]
2003-01-23 04:32:10 +00:00
Dave Abrahams
399cf70b92 Add staticmethod support from Nikolay Mladenov <nickm-at-sitius.com>
[SVN r16946]
2003-01-19 19:12:30 +00:00
Joel de Guzman
571790097a minor error fixed PodBayDoorException const& x
[SVN r16926]
2003-01-18 01:44:48 +00:00
Ralf W. Grosse-Kunstleve
21f3c7c8c2 Mac OS X status
[SVN r16904]
2003-01-15 06:19:23 +00:00
Vladimir Prus
9d26167ec1 Change use-requirements to usage-requirements in some library Jamfiles.
[SVN r16884]
2003-01-13 12:31:12 +00:00
Vladimir Prus
ba4906d05c Update V2 Jamfile for Boost.
[SVN r16882]
2003-01-13 10:05:01 +00:00
Dave Abrahams
e13a11eb7f Fix dict bug
[SVN r16866]
2003-01-11 00:18:59 +00:00
Ralf W. Grosse-Kunstleve
72b214b8db details from the introduction moved to design goals section
[SVN r16864]
2003-01-10 19:22:13 +00:00
Ralf W. Grosse-Kunstleve
84a8fb71b8 meager result after a real hard try
[SVN r16863]
2003-01-10 19:00:05 +00:00
Dave Abrahams
4f5272cab9 Folded in Ralf's first set of edits
[SVN r16856]
2003-01-10 15:17:46 +00:00
Dave Abrahams
5895047e23 Initial Checkin
[SVN r16855]
2003-01-10 15:11:05 +00:00
Dave Abrahams
50bcf8db34 Apply workarounds for msvc-stlport
[SVN r16854]
2003-01-10 15:04:05 +00:00
Dave Abrahams
7defd3bbed support for BOOST_PYTHON_STATIC_MODULE
clarification


[SVN r16788]
2003-01-07 18:03:17 +00:00
Dave Abrahams
b9ecc931b0 support for BOOST_PYTHON_STATIC_MODULE
[SVN r16787]
2003-01-07 17:44:06 +00:00
Dave Abrahams
b84a8fd737 support for BOOST_PYTHON_STATIC_MODULE
[SVN r16786]
2003-01-07 17:38:08 +00:00
Dave Abrahams
2b1a2ce09c Build static versions of the library too.
[SVN r16785]
2003-01-07 17:30:51 +00:00
Dave Abrahams
bcf36610e1 Check in VisualStudio support from Brett Calcott
[SVN r16717]
2002-12-29 17:27:52 +00:00
Dave Abrahams
1bb3254d4d Check in changes from Brett Calcott
[SVN r16716]
2002-12-29 16:53:48 +00:00
Beman Dawes
0f95d507c4 add or update See www.boost.org comments
[SVN r16708]
2002-12-27 16:51:53 +00:00
Dave Abrahams
aa58e21bda Bug fix, thanks to "Daniel Paull" <dlp@fractaltechnologies.com> for
reporting it.


[SVN r16698]
2002-12-24 04:49:33 +00:00
Dave Abrahams
eac0412d18 Fixed comment
[SVN r16676]
2002-12-21 22:12:31 +00:00
Dave Abrahams
0c8aa84f2f Enable automatic downcasting to registered classes for pointers, references, and smart pointers
[SVN r16673]
2002-12-20 18:19:18 +00:00
Dave Abrahams
3d874d1618 Major simplification of from_python conversion avoids registering
converters for every class.


[SVN r16669]
2002-12-20 00:04:40 +00:00
Dave Abrahams
b8edd99dbd Fix typo thanks to "William Trenker" <wtrenker@hotmail.com>
[SVN r16657]
2002-12-18 21:12:02 +00:00
Dave Abrahams
0df5ebf0fa Fix to allow accessing enums as data members
[SVN r16656]
2002-12-18 21:11:16 +00:00
Dave Abrahams
809535b934 clarifications
[SVN r16655]
2002-12-18 21:09:15 +00:00
Dave Abrahams
854e957b78 Workaround for MacOS GCC problem:
#define B0 0


[SVN r16654]
2002-12-18 19:09:34 +00:00
Dave Abrahams
df24f29232 nonconformance workaround from Gottfried.Ganssauge@HAUFE.DE
[SVN r16653]
2002-12-18 17:56:42 +00:00
Joel de Guzman
14c7d9ab14 typo error __rsub__ to __sub__
[SVN r16641]
2002-12-18 01:23:21 +00:00
Dave Abrahams
0e36ac6b72 Bug fix with construction of std::exception
[SVN r16625]
2002-12-16 21:14:30 +00:00
Dave Abrahams
0d2cdbbdfe GCC-2.95.2 workarounds
[SVN r16620]
2002-12-16 04:01:50 +00:00
Dave Abrahams
48f9bee21e Fix typo due to "William Trenker" <wtrenker@hotmail.com>
[SVN r16619]
2002-12-16 03:30:34 +00:00
Dave Abrahams
dd8fc049ff update news
[SVN r16607]
2002-12-14 00:17:22 +00:00
Dave Abrahams
abd22f1273 Handle unsigned long values that don't fit in a long.
[SVN r16606]
2002-12-14 00:10:52 +00:00
Dave Abrahams
4a5817d8ba enum export
[SVN r16604]
2002-12-13 20:04:34 +00:00
Dave Abrahams
eab084c9a2 enum export
[SVN r16603]
2002-12-13 19:58:24 +00:00
Dave Abrahams
80ea2383a7 Fix references to test library
[SVN r16585]
2002-12-10 23:05:38 +00:00
Dave Abrahams
ec76fbe027 Apply fixes from Dirk Gerrits <dirk@gerrits.homeip.net>
[SVN r16517]
2002-12-04 17:10:55 +00:00
Dave Abrahams
c772038e77 Apply fixes from Dirk Gerrits <dirk@gerrits.homeip.net>
[SVN r16506]
2002-12-04 13:36:03 +00:00
Dave Abrahams
59b1a8e71c Apply fixes from Dirk Gerrits <dirk@gerrits.homeip.net>
[SVN r16491]
2002-12-03 18:08:12 +00:00
Dave Abrahams
83c38876fe Simplify, simplify!!
[SVN r16483]
2002-12-02 22:57:47 +00:00
Dave Abrahams
9163c40a1a Further suppressed internal structure overflow problems which were cropping up with msvc6/7.
[SVN r16482]
2002-12-02 19:41:45 +00:00
Dave Abrahams
8b79380977 Less-taxing version of MPL lambda support for msvc6/7
[SVN r16480]
2002-12-02 16:18:35 +00:00
Dave Abrahams
34c9d895c8 Relaxed rules for using scope()
[SVN r16476]
2002-12-02 14:29:11 +00:00
Dave Abrahams
bf8bb83ec5 initial commit
[SVN r16473]
2002-12-02 12:40:18 +00:00
Dave Abrahams
328697952f automatic shared_ptr from_python conversions
[SVN r16467]
2002-12-02 01:37:39 +00:00
Dave Abrahams
3c19b89d9a Added reset()
[SVN r16466]
2002-12-01 16:14:44 +00:00
Dave Abrahams
ae9f394906 Added reset()
[SVN r16465]
2002-12-01 16:07:54 +00:00
Dave Abrahams
8467f36b80 Kill errant `typename'
[SVN r16464]
2002-12-01 04:40:05 +00:00
Dave Abrahams
43a9571b2c Fixed some technical problems with smart pointer support uncovered by
STLPort's debug mode. Unfortunately, had to expand Dereferenceable
requirements.


[SVN r16459]
2002-11-29 22:43:27 +00:00
Dave Abrahams
bbef71dc7d Progress on embedding example for unix.
[SVN r16458]
2002-11-29 20:23:54 +00:00
Dave Abrahams
c4df3c6562 Bug fix
[SVN r16442]
2002-11-27 14:23:07 +00:00
Dave Abrahams
0ad3bfd0ab Finally fixed polymorphism issues
[SVN r16435]
2002-11-27 07:04:32 +00:00
Dave Abrahams
fb7c450b76 Added is_reference_to_member_function_pointer
[SVN r16434]
2002-11-27 06:19:45 +00:00
Dave Abrahams
3fc70519cf Use boost is_polymorphic trait
[SVN r16433]
2002-11-27 06:19:13 +00:00
Dave Abrahams
98c2bf8ff2 Restored some missing v1 acknowledgements
[SVN r16432]
2002-11-27 02:18:52 +00:00
Dave Abrahams
f9c8bf15bb Restore CWPro7.2 to health. Also improve source organization slightly
[SVN r16416]
2002-11-26 02:47:17 +00:00
Dave Abrahams
a7e19ffb0b Refactored def() logic; moved assert_default_constructible into the
holder selectorbecause it was getting the wrong answer in some cases.


[SVN r16415]
2002-11-26 01:06:41 +00:00
Dave Abrahams
7609a1c7c6 Refactored; added static assertions against the specification of a default implementation
[SVN r16414]
2002-11-25 22:03:42 +00:00
Dave Abrahams
087e2d6e35 Add additional argument for default implementation of virtual functions
Fully commented


[SVN r16413]
2002-11-25 21:57:23 +00:00
Dave Abrahams
bb7710a5a2 Suppress GCC warning
[SVN r16412]
2002-11-25 21:19:35 +00:00
Dave Abrahams
0d582e0e79 Suppress GCC warning
[SVN r16411]
2002-11-25 20:54:37 +00:00
Dave Abrahams
3d0579cc08 Fix for VC7. For some reason lexical_cast doesn't seem to work out too
well. We'll need to be careful how we do type_info decoding once we
get the G++ fixes in.


[SVN r16410]
2002-11-25 20:52:49 +00:00
Dave Abrahams
352e390c7b Added tests for embedding demonstration
[SVN r16409]
2002-11-25 18:32:14 +00:00
Dave Abrahams
394037a127 updated
[SVN r16408]
2002-11-25 16:12:27 +00:00
Dave Abrahams
9d4e235cf6 add imul notes
[SVN r16397]
2002-11-25 03:41:34 +00:00
Dave Abrahams
cfbc1a6b48 Fully removed convertible() test from to_python converter protocol
Added tests for detecting unregistered classes when converting
indirectly to python.


[SVN r16396]
2002-11-25 01:57:57 +00:00
Dave Abrahams
31b8b58de9 CW workaround
[SVN r16393]
2002-11-24 21:45:09 +00:00
Dave Abrahams
a77a835694 New function invocation mechanism. This is the major groundwork for handling virtual functions with default implementations properly
[SVN r16390]
2002-11-24 03:26:28 +00:00
Dave Abrahams
dca5c5108b update
[SVN r16389]
2002-11-24 03:25:13 +00:00
Dave Abrahams
e14e4e156c New function invocation mechanism. This is the major groundwork for handling virtual functions with default implementations properly
[SVN r16388]
2002-11-24 02:43:24 +00:00
Dave Abrahams
05ce65d9d2 cleanup
[SVN r16387]
2002-11-23 22:31:13 +00:00
Dave Abrahams
b952e45036 Clip unneeded bind.hpp #include
[SVN r16386]
2002-11-23 22:30:48 +00:00
Dave Abrahams
4c630512fe Add missing add_const #include
[SVN r16385]
2002-11-23 22:18:23 +00:00
Dave Abrahams
0461d25de6 Add some qualification
[SVN r16384]
2002-11-23 22:16:55 +00:00
Dave Abrahams
2df120af72 Suppress a VC6 ICE
[SVN r16383]
2002-11-23 22:16:00 +00:00
Dave Abrahams
791b7e1a1b Tidy
[SVN r16381]
2002-11-23 20:03:49 +00:00
Dave Abrahams
f6f4e59473 Add notes about targeting Cygwin GCC
[SVN r16380]
2002-11-23 20:03:24 +00:00
Dave Abrahams
60924e82e2 On our way to polymorphism
[SVN r16374]
2002-11-23 02:59:45 +00:00
Dave Abrahams
75bd427b8e Bugfix
[SVN r16354]
2002-11-21 00:21:23 +00:00
Dave Abrahams
715118ce39 Bugfix
[SVN r16353]
2002-11-21 00:19:27 +00:00
Dave Abrahams
e3deb8275d update
[SVN r16351]
2002-11-20 23:07:32 +00:00
Dave Abrahams
c30e12f956 Make scope constructor explicit
[SVN r16350]
2002-11-20 22:58:57 +00:00
Ralf W. Grosse-Kunstleve
983b23db92 some missing html markup added
[SVN r16349]
2002-11-20 18:09:17 +00:00
Ralf W. Grosse-Kunstleve
ed2da9bedb list cctbx
[SVN r16348]
2002-11-20 18:01:44 +00:00
Dave Abrahams
409ff3c179 Added missing test
[SVN r16337]
2002-11-20 03:04:51 +00:00
Dave Abrahams
39eab72293 bugfixes
add_property now uses member_function_cast


[SVN r16335]
2002-11-20 01:14:16 +00:00
Dave Abrahams
71ea2bec86 more notes
[SVN r16330]
2002-11-19 17:39:40 +00:00
Dave Abrahams
c9af6ca94b Add missing copyright notices
[SVN r16329]
2002-11-19 17:39:17 +00:00
Dave Abrahams
72d5bac69f Add PSF copyright and change summary
[SVN r16327]
2002-11-19 16:56:55 +00:00
Dave Abrahams
6e0733afa2 Remove Tom's email address
[SVN r16315]
2002-11-19 01:33:07 +00:00
Dave Abrahams
e660cc50c6 Added Support link
[SVN r16299]
2002-11-17 05:59:12 +00:00
Dave Abrahams
e6b40f54cd initial commit
[SVN r16298]
2002-11-17 05:58:45 +00:00
Dave Abrahams
c2af21169d More notes
[SVN r16297]
2002-11-16 23:48:09 +00:00
Dave Abrahams
4f7af97f8c Bug fix thanks to Mark Russell <mrussell8081@pacbell.net>
[SVN r16296]
2002-11-16 23:23:45 +00:00
Dave Abrahams
57f54952c3 Bug fix thanks to Mark Russell <mrussell8081@pacbell.net>
[SVN r16295]
2002-11-16 23:22:30 +00:00
Dave Abrahams
b321b6d9db Tweaks, pseudocode
[SVN r16294]
2002-11-16 22:45:46 +00:00
Dave Abrahams
56c5227cf7 added note
[SVN r16293]
2002-11-16 22:28:28 +00:00
Dave Abrahams
ae2931ba1b initial commit
[SVN r16292]
2002-11-16 22:12:46 +00:00
Dave Abrahams
9e3589ec4d Added projects page link
[SVN r16290]
2002-11-16 20:50:21 +00:00
Dave Abrahams
61b7094dbd Added EMSolve entry
[SVN r16289]
2002-11-16 20:48:43 +00:00
Dave Abrahams
50ecc751d1 Added Fortress entry
[SVN r16288]
2002-11-16 20:39:56 +00:00
Dave Abrahams
bb536a0eaa One more step towards handling polymorphism: now we can sort out a 4th parameter
[SVN r16287]
2002-11-16 20:03:59 +00:00
Dave Abrahams
8b7527318d vc6/7 workaround
[SVN r16286]
2002-11-16 20:01:44 +00:00
Dave Abrahams
f2ac0145da is_reference_to_function_pointer implementation
[SVN r16278]
2002-11-16 06:55:04 +00:00
Dave Abrahams
06fe0f1bcc is_reference_to_function implementation
[SVN r16276]
2002-11-16 06:00:52 +00:00
Dave Abrahams
7ea2447246 Bug fix
[SVN r16273]
2002-11-16 03:38:24 +00:00
Dave Abrahams
0adf4477a3 vc7.1 workaround
[SVN r16267]
2002-11-16 00:45:26 +00:00
Dave Abrahams
b3311fd59d *** empty log message ***
[SVN r16266]
2002-11-15 22:19:40 +00:00
Dave Abrahams
ae109f13a2 *** empty log message ***
[SVN r16260]
2002-11-15 17:29:15 +00:00
Dave Abrahams
cb1901e111 initial commit
[SVN r16259]
2002-11-15 17:02:31 +00:00
Dave Abrahams
bbc052bedc Fix example
[SVN r16256]
2002-11-15 12:25:29 +00:00
Dave Abrahams
f2797ec262 Auto-detection of class memebers wrapped with make_getter()
[SVN r16241]
2002-11-14 17:41:13 +00:00
Dave Abrahams
a21727741f c1204 workaround documented
[SVN r16235]
2002-11-14 12:16:40 +00:00
Dave Abrahams
5f022269b1 Added News page, links back to top of docs
[SVN r16229]
2002-11-14 02:09:43 +00:00
Dave Abrahams
0e76fcf706 auto_ptr support
[SVN r16228]
2002-11-14 01:40:16 +00:00
Dave Abrahams
6b4dc2901d Fix broken link
[SVN r16227]
2002-11-13 22:56:41 +00:00
Dave Abrahams
bcf864fce3 Attempt to handle derived target types
[SVN r16224]
2002-11-13 17:22:48 +00:00
Dave Abrahams
0168d8fbc8 Be more explicit about the Cygwin stuff
[SVN r16215]
2002-11-12 19:36:19 +00:00
Dave Abrahams
88b1c1b926 Allow member pointers from base classes in def_readonly and
def_readwrite.


[SVN r16214]
2002-11-12 17:48:56 +00:00
Dave Abrahams
1f93827b63 Squash bogus warnings
[SVN r16196]
2002-11-11 13:49:09 +00:00
Dave Abrahams
8e3ba0bba3 Improve error messages
[SVN r16147]
2002-11-07 14:41:40 +00:00
Dave Abrahams
42a0441cb8 Doc fix from "Brett Calcott" <brett.calcott@paradise.net.nz>
[SVN r16145]
2002-11-07 13:12:05 +00:00
Joel de Guzman
7b091b86d2 tutorial tweaks
[SVN r16004]
2002-10-28 08:30:31 +00:00
Dave Abrahams
f346eaf693 grammar fix
[SVN r16001]
2002-10-28 07:33:01 +00:00
Dave Abrahams
038be89766 Build with Cygwin
[SVN r16000]
2002-10-28 04:22:14 +00:00
Dave Abrahams
a682dd9362 Fix a doc bug
[SVN r15981]
2002-10-25 04:47:39 +00:00
Joel de Guzman
387e8aadc6 changes to no_init and deriving classes
[SVN r15979]
2002-10-24 21:33:40 +00:00
Joel de Guzman
da273519fd added non_copyable to second version of class_<Base, BaseWrap...
[SVN r15978]
2002-10-24 21:12:37 +00:00
Joel de Guzman
8c2d6bb31b correction Var-->Num
[SVN r15977]
2002-10-24 20:50:04 +00:00
Vladimir Prus
3cb4a029e0 Improve Boost.Python building.
* libs/python/build/Jamfile.v2: Sense the location of python headers. Export
  include paths.

* libs/python/example/Jamfile.v2: New file.

* new/targets.jam: Use refined properties for constructed
    dependency properties

* new/gcc.jam: Handle 'find-library'. Set soname for dynamic libraries.

* new/builtin.jam: New feature 'find-library'.


[SVN r15966]
2002-10-23 12:12:00 +00:00
Dave Abrahams
037f952136 Added funding credit
[SVN r15948]
2002-10-16 22:47:44 +00:00
Dave Abrahams
7fc441801d Allow embedded nulls in std::string <-> Python string conversions,
patch from greg Landrum <greglandrum@mindspring.com>.

Tests by Dave A.


[SVN r15945]
2002-10-16 20:24:38 +00:00
Dave Abrahams
c389e057b4 Added return_by_value, enhanced data member support to handle constant members
[SVN r15935]
2002-10-15 15:46:34 +00:00
Dave Abrahams
2c7829f50e initial checkin
[SVN r15930]
2002-10-15 11:59:39 +00:00
Dave Abrahams
0593074196 Patches to support Synopsis
[SVN r15906]
2002-10-12 15:37:34 +00:00
Dave Abrahams
c7626150fc Move final RC_1_29_0 changes back to trunk
[SVN r15877]
2002-10-10 18:11:14 +00:00
Dave Abrahams
f6990fedc7 Move final RC_1_29_0 changes back to trunk
[SVN r15875]
2002-10-10 18:09:46 +00:00
Dave Abrahams
adb02376eb Move final RC_1_29_0 changes back to trunk
[SVN r15872]
2002-10-10 18:05:51 +00:00
Dave Abrahams
65b6eb0c27 Move final RC_1_29_0 changes back to trunk
[SVN r15871]
2002-10-10 18:01:58 +00:00
Dave Abrahams
654354e681 GCC 2.96 bug workaround
[SVN r15864]
2002-10-10 15:59:12 +00:00
Joel de Guzman
f1a709e074 final tweaks
[SVN r15846]
2002-10-10 08:59:19 +00:00
Joel de Guzman
87b011e7e8 Python V1 Archive (tested)
[SVN r15845]
2002-10-10 07:31:08 +00:00
Joel de Guzman
6bb7c2d7b3 minor tweaks
[SVN r15844]
2002-10-10 07:28:03 +00:00
Joel de Guzman
7d9770762c more minor tweaks
[SVN r15843]
2002-10-10 07:27:10 +00:00
Joel de Guzman
df8c8f025c tweak
[SVN r15842]
2002-10-10 07:21:33 +00:00
Joel de Guzman
51264c30cc Typo...
[SVN r15841]
2002-10-10 07:18:22 +00:00
Joel de Guzman
1d5fb97981 Tutorial updates
[SVN r15840]
2002-10-10 07:13:17 +00:00
Joel de Guzman
a06540e471 grammar correction
[SVN r15835]
2002-10-10 00:08:37 +00:00
Dave Abrahams
f79dc1c2e7 Bug fix (thanks to Leonardo Rochael Almeida <leo@hiper.com.br>).
[SVN r15828]
2002-10-09 16:14:19 +00:00
Joel de Guzman
8a94c597a0 More tweaks (tutorial)
[SVN r15826]
2002-10-09 14:31:39 +00:00
Dave Abrahams
8a9a3a00bd Fix a major problem of path specification
[SVN r15825]
2002-10-09 13:18:26 +00:00
Dave Abrahams
8c8b4ee332 Fix up a small build specification problem
[SVN r15822]
2002-10-09 11:57:17 +00:00
Joel de Guzman
a295ac6590 Tutorials...
[SVN r15818]
2002-10-09 07:44:34 +00:00
Joel de Guzman
e49e0d2705 tutorial added
[SVN r15817]
2002-10-09 05:03:22 +00:00
Dave Abrahams
4fd20185e9 Clean up Boost.Python v1 flotsam, update documentation
[SVN r15815]
2002-10-09 02:52:47 +00:00
Dave Abrahams
920125794a Workaround GCC 3.x problem
[SVN r15790]
2002-10-07 19:23:08 +00:00
Dave Abrahams
ca6c28ed93 merge Joel's copyrights
[SVN r15772]
2002-10-07 13:42:55 +00:00
Dave Abrahams
e9757c46e3 *** empty log message ***
[SVN r15741]
2002-10-05 19:46:26 +00:00
Dave Abrahams
7e840acd19 Repair AIX build
[SVN r15740]
2002-10-05 19:31:43 +00:00
Dave Abrahams
6f76db9c6c quick bug fix
[SVN r15738]
2002-10-05 17:42:34 +00:00
Dave Abrahams
86489dd5a7 Make AIX work again
[SVN r15737]
2002-10-05 17:29:32 +00:00
Dave Abrahams
33f139e516 Patches for CWPro8.3
[SVN r15735]
2002-10-05 16:45:37 +00:00
Dave Abrahams
30d9331079 Remove Boost.Python v1 from main trunk
[SVN r15723]
2002-10-05 04:37:49 +00:00
Dave Abrahams
8207dc756a Workaround for IRIX CC
[SVN r15722]
2002-10-05 00:23:10 +00:00
Dave Abrahams
1887594d8a Bug fix
[SVN r15721]
2002-10-04 23:27:35 +00:00
Dave Abrahams
ee17b41e62 Clean up module flotsam
[SVN r15720]
2002-10-04 21:58:21 +00:00
Dave Abrahams
5e8d775b87 Support for MinGW-2.0
[SVN r15719]
2002-10-04 21:34:32 +00:00
Dave Abrahams
f4d457998f doc update
[SVN r15709]
2002-10-04 14:24:25 +00:00
Dave Abrahams
bd0175c167 Backport to Python 2.2
[SVN r15706]
2002-10-04 13:05:57 +00:00
Dave Abrahams
81ffe96c76 Update Tru64 workarounds
[SVN r15705]
2002-10-04 05:14:45 +00:00
Dave Abrahams
e5fbe651d8 Tru64 CXX updates
[SVN r15704]
2002-10-04 03:46:43 +00:00
Dave Abrahams
a91112e5d9 doc update
[SVN r15702]
2002-10-04 00:45:29 +00:00
Dave Abrahams
2b5f421501 Remove needless specialization
[SVN r15701]
2002-10-03 23:59:08 +00:00
Dave Abrahams
ecd7905e8f doc update
[SVN r15697]
2002-10-03 23:21:48 +00:00
Dave Abrahams
8f989f318b doc update
[SVN r15684]
2002-10-03 20:59:43 +00:00
Dave Abrahams
7b9dad44d1 doc update
[SVN r15683]
2002-10-03 20:18:53 +00:00
Dave Abrahams
f5eab48017 doc update
[SVN r15682]
2002-10-03 18:54:19 +00:00
Dave Abrahams
66ff762fbb doc update
[SVN r15681]
2002-10-03 18:40:58 +00:00
Dave Abrahams
2bdd01d084 doc update
[SVN r15680]
2002-10-03 18:20:06 +00:00
Dave Abrahams
2bdc4cdffa doc update
[SVN r15679]
2002-10-03 16:49:55 +00:00
Dave Abrahams
90a6d484b7 doc update
[SVN r15675]
2002-10-03 14:53:32 +00:00
Dave Abrahams
021aa51707 doc update
[SVN r15674]
2002-10-03 14:07:13 +00:00
Dave Abrahams
48fffd7a7b doc update
[SVN r15667]
2002-10-03 13:09:24 +00:00
Ralf W. Grosse-Kunstleve
17033037eb explains that enable_pickling() is an implementation detail
[SVN r15666]
2002-10-03 12:41:22 +00:00
Ralf W. Grosse-Kunstleve
f43b913302 reference doc for .def_pickle()
[SVN r15665]
2002-10-03 12:41:12 +00:00
Aleksey Gurtovoy
f7b087ed8f get rid of leftover MPL includes
[SVN r15664]
2002-10-03 09:28:47 +00:00
Aleksey Gurtovoy
8cecbe31a7 fix for empty type_list problem
[SVN r15663]
2002-10-03 09:23:27 +00:00
Dave Abrahams
f2055b0d80 doc update
[SVN r15654]
2002-10-02 20:33:14 +00:00
Dave Abrahams
28e5bedf49 doc update
[SVN r15647]
2002-10-02 12:00:22 +00:00
Dave Abrahams
f8a9b922be *** empty log message ***
[SVN r15645]
2002-10-02 11:20:56 +00:00
Dave Abrahams
2a199af8f7 doc update
[SVN r15641]
2002-10-01 23:03:09 +00:00
Dave Abrahams
2373020225 doc update
[SVN r15639]
2002-10-01 22:48:24 +00:00
Dave Abrahams
e13d09242c doc update
[SVN r15621]
2002-10-01 17:22:26 +00:00
Dave Abrahams
09eba4c38f Separate init.hpp docs from class.hpp
[SVN r15616]
2002-10-01 15:12:46 +00:00
Dave Abrahams
2aa23a317d separate overloads.hpp
BOOST_PYTHON_MODULE_INIT -> BOOST_PYTHON_MODULE


[SVN r15615]
2002-10-01 15:08:08 +00:00
Dave Abrahams
5cd513859d separate overloads.hpp
BOOST_PYTHON_MODULE_INIT -> BOOST_PYTHON_MODULE


[SVN r15609]
2002-10-01 14:40:41 +00:00
Joel de Guzman
c6cba55667 Placed the non-void and void stub structs inside the main stub struct.
[SVN r15597]
2002-10-01 03:55:54 +00:00
Dave Abrahams
65ce6ddf1d doc update
[SVN r15596]
2002-10-01 03:45:33 +00:00
Dave Abrahams
fa7b1404c1 Bugfix
[SVN r15595]
2002-10-01 03:44:51 +00:00
Dave Abrahams
61b528c85d doc update
[SVN r15593]
2002-10-01 01:16:25 +00:00
Dave Abrahams
77b1b247c4 doc updates
[SVN r15577]
2002-09-30 22:05:20 +00:00
Dave Abrahams
a06430c5fa doc updates
[SVN r15573]
2002-09-30 17:40:47 +00:00
Dave Abrahams
0e38aa7f37 doc updates
[SVN r15571]
2002-09-30 16:52:57 +00:00
Dave Abrahams
707ce53c16 Bugfix
[SVN r15563]
2002-09-30 03:35:53 +00:00
Dave Abrahams
19982e5551 doc update
[SVN r15562]
2002-09-29 20:40:33 +00:00
Dave Abrahams
170bbea166 doc update
[SVN r15561]
2002-09-29 20:30:17 +00:00
Dave Abrahams
6b5ea675c3 doc update
[SVN r15559]
2002-09-29 20:18:04 +00:00
Dave Abrahams
d873aec9e6 doc update
[SVN r15557]
2002-09-29 19:15:53 +00:00
Dave Abrahams
0d1efb61e2 doc update
[SVN r15556]
2002-09-29 19:06:13 +00:00
Dave Abrahams
a27c2f7a80 doc update
[SVN r15555]
2002-09-29 18:47:48 +00:00
Dave Abrahams
36d85eb02e doc update
[SVN r15552]
2002-09-29 17:51:31 +00:00
Dave Abrahams
9ae0940e99 doc update
[SVN r15551]
2002-09-29 17:41:39 +00:00
Dave Abrahams
2f4e12916d doc update
[SVN r15550]
2002-09-29 16:26:04 +00:00
Dave Abrahams
c860d74cba doc update
[SVN r15549]
2002-09-29 16:17:52 +00:00
Dave Abrahams
8cd3e16e26 Documentation update
[SVN r15548]
2002-09-29 16:06:02 +00:00
Dave Abrahams
94063f7862 Keyword argument support tweak
[SVN r15544]
2002-09-29 03:25:04 +00:00
Dave Abrahams
a0ff708d29 Fixes for AIX
[SVN r15541]
2002-09-28 13:27:00 +00:00
Dave Abrahams
6bfbeb3dfa make minimal a more-useful test
[SVN r15540]
2002-09-28 13:26:12 +00:00
Dave Abrahams
3158d28264 Keyword argument support
[SVN r15534]
2002-09-28 07:48:27 +00:00
Dave Abrahams
997e84f117 Keyword argument support
[SVN r15533]
2002-09-28 07:35:15 +00:00
Dave Abrahams
bc91db64d7 PP optimization
[SVN r15528]
2002-09-26 13:21:19 +00:00
Dave Abrahams
82ef6ec659 more .IRIX workarounds
[SVN r15527]
2002-09-26 13:09:57 +00:00
Dave Abrahams
374b55be8a IRIX workarounds, eliminate dead header
[SVN r15526]
2002-09-26 12:13:47 +00:00
Dave Abrahams
72e1c1a7f6 bugfix
[SVN r15525]
2002-09-26 12:00:04 +00:00
Dave Abrahams
173021377e Restore msvc-stlport workaround
[SVN r15522]
2002-09-26 03:29:59 +00:00
Dave Abrahams
17879958ca NumPy (Numeric and numarray) support
[SVN r15521]
2002-09-26 00:16:16 +00:00
Dave Abrahams
31a8be0434 Patches for Intel C++ 7.0 beta
[SVN r15520]
2002-09-26 00:15:36 +00:00
Dave Abrahams
87d619e02a fixup comments
[SVN r15519]
2002-09-26 00:15:09 +00:00
Dave Abrahams
f4aa72373b Serious bugfix
[SVN r15518]
2002-09-26 00:11:30 +00:00
Ralf W. Grosse-Kunstleve
3cb9ecae78 workaround for MIPSpro compiler bug is now in boost/function/function_base.hpp
[SVN r15517]
2002-09-25 20:04:34 +00:00
Joel de Guzman
88caf4f5b6 added missing typename
[SVN r15471]
2002-09-21 08:01:24 +00:00
Joel de Guzman
a75ee50533 Removed def_init(...) from class_
[SVN r15468]
2002-09-21 02:50:29 +00:00
Dave Abrahams
8e941417a5 Workaround slow Windows Intel C++ debug symbol generation
[SVN r15452]
2002-09-19 16:11:34 +00:00
Dave Abrahams
e8d2bbd2c9 VC6 fixes
[SVN r15438]
2002-09-18 13:24:15 +00:00
Dave Abrahams
065a53b997 Apply more preprocessor optimizations
[SVN r15435]
2002-09-18 04:54:31 +00:00
Dave Abrahams
ca5a222aec quickie bugfix
[SVN r15433]
2002-09-18 04:07:20 +00:00
Dave Abrahams
4320c73336 Apply more preprocessor optimizations
[SVN r15432]
2002-09-18 04:05:32 +00:00
Dave Abrahams
7f98265272 Merge Joel's changes to trunk!
[SVN r15430]
2002-09-18 02:20:39 +00:00
Dave Abrahams
0b75a8e94e Adjust version number for old EDG workaround
[SVN r15421]
2002-09-17 20:43:46 +00:00
Dave Abrahams
eb3e237e47 Added a compile-only test for functions returning non-const references
[SVN r15420]
2002-09-17 20:36:17 +00:00
Dave Abrahams
b1796c0acb Work around recent changes to bind which cause bound data members to be returned by const&
[SVN r15417]
2002-09-17 19:32:50 +00:00
Dave Abrahams
bff10e5711 Suppress warnings for old EDGs
[SVN r15415]
2002-09-17 17:37:59 +00:00
Dave Abrahams
0f559f3f97 Older EDG workaround
[SVN r15397]
2002-09-17 03:55:29 +00:00
Dave Abrahams
34aead4d49 Older EDG workaround
[SVN r15396]
2002-09-17 03:47:10 +00:00
Dave Abrahams
7cc01e155c Kill extra ;
[SVN r15395]
2002-09-17 02:05:11 +00:00
Dave Abrahams
7fe5fb92b4 Patch for KCC bug
[SVN r15381]
2002-09-16 15:26:20 +00:00
Dave Abrahams
b084f8a616 Restore main trunk to health
[SVN r15378]
2002-09-16 12:46:26 +00:00
Dave Abrahams
802a2f3fdb Restore main trunk to health
[SVN r15362]
2002-09-16 04:15:53 +00:00
Dave Abrahams
06f6f2ff21 Restore main trunk to health
[SVN r15359]
2002-09-16 04:03:39 +00:00
Joel de Guzman
b37198106d Changed args<...> to init<...> and changed class_(no_init) to class_("name", no_init)
[SVN r15345]
2002-09-15 21:42:49 +00:00
Joel de Guzman
604928adc4 new API changes
[SVN r15344]
2002-09-15 21:13:12 +00:00
Dave Abrahams
4a6762540d bugfix
[SVN r15324]
2002-09-14 16:19:22 +00:00
Dave Abrahams
af5176be70 msvc6 (with STLPort) workaround
[SVN r15316]
2002-09-14 02:04:17 +00:00
Dave Abrahams
482006ed1a Roll workaround forward to CWPro8.2 release
[SVN r15314]
2002-09-13 23:55:46 +00:00
Dave Abrahams
5923e20b7e Roll back MinGW 2.0 "fix" that still doesn't work, and breaks MSVC6.
[SVN r15313]
2002-09-13 22:57:04 +00:00
Ralf W. Grosse-Kunstleve
14cca4610b workaround for older EDG compilers (IRIX CC)
[SVN r15292]
2002-09-13 05:46:46 +00:00
Dave Abrahams
2dbb0093c1 PP usage speedups (mostly for EDG)
[SVN r15286]
2002-09-13 01:48:50 +00:00
Dave Abrahams
d91b6e9a1b Compile (but still can't link) with MinGW-2.0 (GCC-3.2)
[SVN r15285]
2002-09-12 23:58:15 +00:00
413 changed files with 6953 additions and 34695 deletions

View File

@@ -1,52 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef ARG_FROM_PYTHON_DWA2002128_HPP
# define ARG_FROM_PYTHON_DWA2002128_HPP
# include <boost/python/converter/arg_from_python.hpp>
namespace boost { namespace python {
template <class T>
struct arg_from_python
: converter::select_arg_from_python<T>::type
{
typedef typename converter::select_arg_from_python<T>::type base;
arg_from_python(PyObject*);
};
// specialization for PyObject*
template <>
struct arg_from_python<PyObject*>
{
typedef PyObject* result_type;
arg_from_python(PyObject*) {}
bool convertible() const { return true; }
PyObject* operator()(PyObject* source) const { return source; }
};
template <>
struct arg_from_python<PyObject* const&>
{
typedef PyObject* const& result_type;
arg_from_python(PyObject*) {}
bool convertible() const { return true; }
PyObject*const& operator()(PyObject*const& source) const { return source; }
};
//
// implementations
//
template <class T>
inline arg_from_python<T>::arg_from_python(PyObject* source)
: base(source)
{
}
}} // namespace boost::python
#endif // ARG_FROM_PYTHON_DWA2002128_HPP

View File

@@ -1,34 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef ARGS_DWA2002323_HPP
# define ARGS_DWA2002323_HPP
# include <boost/config.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/python/detail/type_list.hpp>
namespace boost { namespace python {
enum no_init_t { no_init };
namespace detail
{
template <class Args>
struct args_base {};
}
}}
namespace boost { namespace python {
// A type list for specifying arguments
template < BOOST_PYTHON_ENUM_WITH_DEFAULT(BOOST_PYTHON_MAX_ARITY, typename A, mpl::void_) >
struct args : detail::args_base<args<BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, A)> >
, detail::type_list< BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, A) >::type
{};
}} // namespace boost::python
# endif // ARGS_DWA2002323_HPP

View File

@@ -1,101 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef BACK_REFERENCE_DWA2002510_HPP
# define BACK_REFERENCE_DWA2002510_HPP
# include <boost/python/object_fwd.hpp>
# include <boost/python/detail/dependent.hpp>
# include <boost/python/detail/raw_pyobject.hpp>
namespace boost { namespace python {
template <class T>
struct back_reference
{
private: // types
typedef typename detail::dependent<object,T>::type source_t;
public:
typedef T type;
back_reference(PyObject*, T);
source_t const& source() const;
T get() const;
private:
source_t m_source;
T m_value;
};
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template<typename T>
class is_back_reference
{
public:
BOOST_STATIC_CONSTANT(bool, value = false);
};
template<typename T>
class is_back_reference<back_reference<T> >
{
public:
BOOST_STATIC_CONSTANT(bool, value = true);
};
# else // no partial specialization
}} // namespace boost::python
#include <boost/type.hpp>
namespace boost { namespace python {
namespace detail
{
typedef char (&yes_back_reference_t)[1];
typedef char (&no_back_reference_t)[2];
no_back_reference_t is_back_reference_test(...);
template<typename T>
yes_back_reference_t is_back_reference_test(boost::type< back_reference<T> >);
}
template<typename T>
class is_back_reference
{
public:
BOOST_STATIC_CONSTANT(
bool, value = (
sizeof(detail::is_back_reference_test(boost::type<T>()))
== sizeof(detail::yes_back_reference_t)));
};
# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
//
// implementations
//
template <class T>
back_reference<T>::back_reference(PyObject* p, T x)
: m_source(detail::borrowed_reference(p))
, m_value(x)
{
}
template <class T>
typename back_reference<T>::source_t const& back_reference<T>::source() const
{
return m_source;
}
template <class T>
T back_reference<T>::get() const
{
return m_value;
}
}} // namespace boost::python
#endif // BACK_REFERENCE_DWA2002510_HPP

View File

@@ -1,36 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef BASE_TYPE_TRAITS_DWA2002614_HPP
# define BASE_TYPE_TRAITS_DWA2002614_HPP
namespace boost { namespace python {
namespace detail
{
struct unspecialized {};
}
// Derive from unspecialized so we can detect whether traits are
// specialized
template <class T> struct base_type_traits
: detail::unspecialized
{};
template <>
struct base_type_traits<PyObject>
{
typedef PyObject type;
};
template <>
struct base_type_traits<PyTypeObject>
{
typedef PyObject type;
};
}} // namespace boost::python
#endif // BASE_TYPE_TRAITS_DWA2002614_HPP

View File

@@ -1,60 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef BASES_DWA2002321_HPP
# define BASES_DWA2002321_HPP
# include <boost/type_traits/object_traits.hpp>
# include <boost/python/detail/type_list.hpp>
# include <boost/mpl/if.hpp>
# include <boost/preprocessor/enum_params_with_a_default.hpp>
# include <boost/preprocessor/enum_params.hpp>
namespace boost { namespace python {
// A type list for specifying bases
template < BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PYTHON_MAX_BASES, typename B, mpl::void_) >
struct bases : detail::type_list< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, B) >::type
{};
namespace detail
{
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class T> struct specifies_bases
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
template < BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, class B) >
struct specifies_bases< bases< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, B) > >
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
# else
template < BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, class B) >
static char is_bases_helper(bases< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, B) > const&);
static char (& is_bases_helper(...) )[256];
template <class T> struct specifies_bases
{
private:
static typename add_reference<T>::type make();
BOOST_STATIC_CONSTANT(bool, non_ref = !is_reference<T>::value);
public:
BOOST_STATIC_CONSTANT(bool, value = non_ref & (sizeof(is_bases_helper(make())) == 1));
};
# endif
template <class T, class Prev = bases<> >
struct select_bases
: mpl::if_c<
specifies_bases<T>::value
, T
, Prev
>
{
};
}
}} // namespace boost::python
#endif // BASES_DWA2002321_HPP

View File

@@ -1,20 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef BORROWED_DWA2002614_HPP
# define BORROWED_DWA2002614_HPP
# include <boost/python/detail/borrowed_ptr.hpp>
namespace boost { namespace python {
template <class T>
inline python::detail::borrowed<T>* borrowed(T* p)
{
return (detail::borrowed<T>*)p;
}
}} // namespace boost::python
#endif // BORROWED_DWA2002614_HPP

View File

@@ -1,64 +0,0 @@
#if !defined(BOOST_PP_IS_ITERATING)
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
# ifndef CALL_DWA2002411_HPP
# define CALL_DWA2002411_HPP
# include <boost/type.hpp>
# include <boost/python/converter/arg_to_python.hpp>
# include <boost/python/converter/return_from_python.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/python/detail/void_return.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/preprocessor/repeat.hpp>
# include <boost/preprocessor/debug/line.hpp>
namespace boost { namespace python {
# define BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET(z, n, _) \
, converter::arg_to_python<A##n>(a##n).get()
# define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/call.hpp>))
# include BOOST_PP_ITERATE()
# undef BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET
}} // namespace boost::python
# endif // CALL_DWA2002411_HPP
#elif BOOST_PP_ITERATION_DEPTH() == 1
# line BOOST_PP_LINE(__LINE__, call.hpp)
# define N BOOST_PP_ITERATION()
template <
class R
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)
>
typename detail::returnable<R>::type
call(PyObject* callable
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, A, const& a)
, boost::type<R>* = 0
)
{
converter::return_from_python<R> converter;
return converter(
PyEval_CallFunction(
callable
, const_cast<char*>("(" BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FIXED, "O") ")")
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET, nil)
));
}
# undef N
#endif

View File

@@ -1,64 +0,0 @@
#if !defined(BOOST_PP_IS_ITERATING)
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
# ifndef CALL_METHOD_DWA2002411_HPP
# define CALL_METHOD_DWA2002411_HPP
# include <boost/type.hpp>
# include <boost/python/converter/arg_to_python.hpp>
# include <boost/python/converter/return_from_python.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/python/detail/void_return.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/preprocessor/repeat.hpp>
# include <boost/preprocessor/debug/line.hpp>
namespace boost { namespace python {
# define BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET(z, n, _) \
, converter::arg_to_python<A##n>(a##n).get()
# define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/call_method.hpp>))
# include BOOST_PP_ITERATE()
# undef BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET
}} // namespace boost::python
# endif // CALL_METHOD_DWA2002411_HPP
#elif BOOST_PP_ITERATION_DEPTH() == 1
# line BOOST_PP_LINE(__LINE__, call_method.hpp)
# define N BOOST_PP_ITERATION()
template <
class R
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)
>
typename detail::returnable<R>::type
call_method(PyObject* self, char const* name
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, A, const& a)
, boost::type<R>* = 0
)
{
converter::return_from_python<R> converter;
return converter(
PyEval_CallMethod(
self
, const_cast<char*>(name)
, const_cast<char*>("(" BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FIXED, "O") ")")
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET, nil)
));
}
# undef N
#endif // BOOST_PP_IS_ITERATING

View File

@@ -1,829 +0,0 @@
// (C) Copyright David Abrahams 2000. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// The author gratefully acknowleges the support of Dragon Systems, Inc., in
// producing this work.
//
// This file was generated for 10-argument python callbacks by gen_callback.python
#ifndef CALLBACK_DWA_052100_H_
# define CALLBACK_DWA_052100_H_
# include <boost/python/detail/config.hpp>
# include <boost/python/conversions.hpp>
namespace boost { namespace python {
namespace detail {
template <class T>
inline void callback_adjust_refcount(PyObject*, type<T>) {}
inline void callback_adjust_refcount(PyObject* p, type<PyObject*>)
{ Py_INCREF(p); }
}
// Calling Python from C++
template <class R>
struct callback
{
static R call_method(PyObject* self, const char* name)
{
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("()")));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
static R call(PyObject* self)
{
ref result(PyEval_CallFunction(self, const_cast<char*>("()")));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1>
static R call_method(PyObject* self, const char* name, const A1& a1)
{
ref p1(to_python(a1));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(O)"),
p1.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1>
static R call(PyObject* self, const A1& a1)
{
ref p1(to_python(a1));
ref result(PyEval_CallFunction(self, const_cast<char*>("(O)"),
p1.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2>
static R call_method(PyObject* self, const char* name, const A1& a1, const A2& a2)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OO)"),
p1.get(),
p2.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2>
static R call(PyObject* self, const A1& a1, const A2& a2)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OO)"),
p1.get(),
p2.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2, class A3>
static R call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OOO)"),
p1.get(),
p2.get(),
p3.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2, class A3>
static R call(PyObject* self, const A1& a1, const A2& a2, const A3& a3)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OOO)"),
p1.get(),
p2.get(),
p3.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2, class A3, class A4>
static R call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2, class A3, class A4>
static R call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2, class A3, class A4, class A5>
static R call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2, class A3, class A4, class A5>
static R call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2, class A3, class A4, class A5, class A6>
static R call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2, class A3, class A4, class A5, class A6>
static R call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
static R call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref p7(to_python(a7));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OOOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get(),
p7.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
static R call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref p7(to_python(a7));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OOOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get(),
p7.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
static R call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref p7(to_python(a7));
ref p8(to_python(a8));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OOOOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get(),
p7.get(),
p8.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
static R call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref p7(to_python(a7));
ref p8(to_python(a8));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OOOOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get(),
p7.get(),
p8.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
static R call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref p7(to_python(a7));
ref p8(to_python(a8));
ref p9(to_python(a9));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OOOOOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get(),
p7.get(),
p8.get(),
p9.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
static R call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref p7(to_python(a7));
ref p8(to_python(a8));
ref p9(to_python(a9));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OOOOOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get(),
p7.get(),
p8.get(),
p9.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
static R call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref p7(to_python(a7));
ref p8(to_python(a8));
ref p9(to_python(a9));
ref p10(to_python(a10));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OOOOOOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get(),
p7.get(),
p8.get(),
p9.get(),
p10.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
static R call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref p7(to_python(a7));
ref p8(to_python(a8));
ref p9(to_python(a9));
ref p10(to_python(a10));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OOOOOOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get(),
p7.get(),
p8.get(),
p9.get(),
p10.get()));
detail::callback_adjust_refcount(result.get(), type<R>());
return from_python(result.get(), type<R>());
}
};
// This specialization wouldn't be needed, but MSVC6 doesn't correctly allow the following:
// void g();
// void f() { return g(); }
template <>
struct callback<void>
{
static void call_method(PyObject* self, const char* name)
{
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("()")));
}
static void call(PyObject* self)
{
ref result(PyEval_CallFunction(self, const_cast<char*>("()")));
}
template <class A1>
static void call_method(PyObject* self, const char* name, const A1& a1)
{
ref p1(to_python(a1));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(O)"),
p1.get()));
}
template <class A1>
static void call(PyObject* self, const A1& a1)
{
ref p1(to_python(a1));
ref result(PyEval_CallFunction(self, const_cast<char*>("(O)"),
p1.get()));
}
template <class A1, class A2>
static void call_method(PyObject* self, const char* name, const A1& a1, const A2& a2)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OO)"),
p1.get(),
p2.get()));
}
template <class A1, class A2>
static void call(PyObject* self, const A1& a1, const A2& a2)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OO)"),
p1.get(),
p2.get()));
}
template <class A1, class A2, class A3>
static void call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OOO)"),
p1.get(),
p2.get(),
p3.get()));
}
template <class A1, class A2, class A3>
static void call(PyObject* self, const A1& a1, const A2& a2, const A3& a3)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OOO)"),
p1.get(),
p2.get(),
p3.get()));
}
template <class A1, class A2, class A3, class A4>
static void call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get()));
}
template <class A1, class A2, class A3, class A4>
static void call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get()));
}
template <class A1, class A2, class A3, class A4, class A5>
static void call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get()));
}
template <class A1, class A2, class A3, class A4, class A5>
static void call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get()));
}
template <class A1, class A2, class A3, class A4, class A5, class A6>
static void call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get()));
}
template <class A1, class A2, class A3, class A4, class A5, class A6>
static void call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get()));
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
static void call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref p7(to_python(a7));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OOOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get(),
p7.get()));
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
static void call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref p7(to_python(a7));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OOOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get(),
p7.get()));
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
static void call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref p7(to_python(a7));
ref p8(to_python(a8));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OOOOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get(),
p7.get(),
p8.get()));
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
static void call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref p7(to_python(a7));
ref p8(to_python(a8));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OOOOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get(),
p7.get(),
p8.get()));
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
static void call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref p7(to_python(a7));
ref p8(to_python(a8));
ref p9(to_python(a9));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OOOOOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get(),
p7.get(),
p8.get(),
p9.get()));
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
static void call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref p7(to_python(a7));
ref p8(to_python(a8));
ref p9(to_python(a9));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OOOOOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get(),
p7.get(),
p8.get(),
p9.get()));
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
static void call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref p7(to_python(a7));
ref p8(to_python(a8));
ref p9(to_python(a9));
ref p10(to_python(a10));
ref result(PyEval_CallMethod(self, const_cast<char*>(name),
const_cast<char*>("(OOOOOOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get(),
p7.get(),
p8.get(),
p9.get(),
p10.get()));
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
static void call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10)
{
ref p1(to_python(a1));
ref p2(to_python(a2));
ref p3(to_python(a3));
ref p4(to_python(a4));
ref p5(to_python(a5));
ref p6(to_python(a6));
ref p7(to_python(a7));
ref p8(to_python(a8));
ref p9(to_python(a9));
ref p10(to_python(a10));
ref result(PyEval_CallFunction(self, const_cast<char*>("(OOOOOOOOOO)"),
p1.get(),
p2.get(),
p3.get(),
p4.get(),
p5.get(),
p6.get(),
p7.get(),
p8.get(),
p9.get(),
p10.get()));
}
};
// Make it a compile-time error to try to return a const char* from a virtual
// function. The standard conversion
//
// from_python(PyObject* string, boost::python::type<const char*>)
//
// returns a pointer to the character array which is internal to string. The
// problem with trying to do this in a standard callback function is that the
// Python string would likely be destroyed upon return from the calling function
// (boost::python::callback<const char*>::call[_method]) when its reference count is
// decremented. If you absolutely need to do this and you're sure it's safe (it
// usually isn't), you can use
//
// boost::python::string result(boost::python::callback<boost::python::string>::call[_method](...args...));
// ...result.c_str()... // access the char* array
template <>
struct callback<const char*>
{
// Try hard to generate a readable error message
typedef struct unsafe_since_python_string_may_be_destroyed {} call, call_method;
};
}} // namespace boost::python
#endif // CALLBACK_DWA_052100_H_

File diff suppressed because it is too large Load Diff

View File

@@ -1,106 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef CAST_DWA200269_HPP
# define CAST_DWA200269_HPP
# include <boost/python/detail/wrap_python.hpp>
# include <boost/type_traits/same_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/type.hpp>
# include <boost/python/base_type_traits.hpp>
# include <boost/python/detail/convertible.hpp>
namespace boost { namespace python {
namespace detail
{
template <class Source, class Target> inline Target* upcast_impl(Source*, Target*);
template <class Source, class Target>
inline Target* upcast(Source* p, yes_convertible, no_convertible, Target*)
{
return p;
}
template <class Source, class Target>
inline Target* upcast(Source* p, no_convertible, no_convertible, Target*)
{
typedef typename base_type_traits<Source>::type base;
return detail::upcast_impl((base*)p, (Target*)0);
}
template <bool is_same = true>
struct upcaster
{
template <class T>
static inline T* execute(T* x, T*) { return x; }
};
template <>
struct upcaster<false>
{
template <class Source, class Target>
static inline Target* execute(Source* x, Target*)
{
return detail::upcast(
x, detail::convertible<Target*>::check(x)
, detail::convertible<Source*>::check((Target*)0)
, (Target*)0);
}
};
template <class Target, class Source>
inline Target* downcast(Source* p, yes_convertible)
{
return static_cast<Target*>(p);
}
template <class Target, class Source>
inline Target* downcast(Source* p, no_convertible, boost::type<Target>* = 0)
{
typedef typename base_type_traits<Source>::type base;
return (Target*)detail::downcast<base>(p, convertible<Source*>::check((base*)0));
}
template <class T>
inline void assert_castable(boost::type<T>* = 0)
{
typedef char must_be_a_complete_type[sizeof(T)];
}
template <class Source, class Target>
inline Target* upcast_impl(Source* x, Target*)
{
typedef typename add_cv<Source>::type src_t;
typedef typename add_cv<Target>::type target_t;
static bool const same = is_same<src_t,target_t>::value;
return detail::upcaster<same>::execute(x, (Target*)0);
}
}
template <class Target, class Source>
inline Target* upcast(Source* x, Target* = 0)
{
detail::assert_castable<Source>();
detail::assert_castable<Target>();
return detail::upcast_impl(x, (Target*)0);
}
template <class Target, class Source>
inline Target* downcast(Source* x, Target* = 0)
{
detail::assert_castable<Source>();
detail::assert_castable<Target>();
return detail::downcast<Target>(x, detail::convertible<Source*>::check((Target*)0));
}
}} // namespace boost::python
#endif // CAST_DWA200269_HPP

View File

@@ -1,436 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef CLASS_DWA200216_HPP
# define CLASS_DWA200216_HPP
# include <boost/python/class_fwd.hpp>
# include <boost/python/object/class.hpp>
# include <boost/python/bases.hpp>
# include <boost/python/args.hpp>
# include <boost/python/object.hpp>
# include <boost/python/type_id.hpp>
# include <boost/python/detail/member_function_cast.hpp>
# include <boost/python/object/class_converters.hpp>
# include <boost/type_traits/ice.hpp>
# include <boost/type_traits/same_traits.hpp>
# include <boost/mpl/size.hpp>
# include <boost/mpl/for_each.hpp>
# include <boost/mpl/bool_c.hpp>
# include <boost/python/object/select_holder.hpp>
# include <boost/python/object/class_wrapper.hpp>
# include <boost/python/object/make_instance.hpp>
# include <boost/python/data_members.hpp>
# include <boost/utility.hpp>
# include <boost/python/detail/operator_id.hpp>
# include <boost/python/object/pickle_support.hpp>
# include <boost/python/make_function.hpp>
# include <boost/python/object/add_to_namespace.hpp>
# include <boost/python/detail/def_helper.hpp>
# include <boost/python/detail/force_instantiate.hpp>
# include <boost/python/detail/defaults_def.hpp>
# include <boost/python/signature.hpp>
# include <boost/python/init.hpp>
namespace boost { namespace python {
namespace detail
{
// This function object is used with mpl::for_each to write the id
// of the type a pointer to which is passed as its 2nd compile-time
// argument. into the iterator pointed to by its runtime argument
struct write_type_id
{
write_type_id(type_info**p) : p(p) {}
// Here's the runtime behavior
template <class T>
void operator()(T*) const
{
*(*p)++ = type_id<T>();
};
type_info** p;
};
template <class T, class Prev = detail::not_specified>
struct select_held_type;
template <class T1, class T2, class T3>
struct has_noncopyable;
template <detail::operator_id, class L, class R>
struct operator_;
// Register a to_python converter for a class T, depending on the
// type of the first (tag) argument. The 2nd argument is a pointer
// to the type of holder that must be created. The 3rd argument is a
// reference to the Python type object to be created.
template <class T, class SelectHolder>
static inline void register_copy_constructor(mpl::bool_c<true> const&, SelectHolder const& , T* = 0)
{
typedef typename SelectHolder::type holder;
force_instantiate(objects::class_wrapper<T,holder, objects::make_instance<T,holder> >());
SelectHolder::register_();
}
// Tag dispatched to have no effect.
template <class T, class SelectHolder>
static inline void register_copy_constructor(mpl::bool_c<false> const&, SelectHolder const&, T* = 0)
{
SelectHolder::register_();
}
template <class T> int assert_default_constructible(T const&);
}
//
// class_<T,Bases,HolderGenerator>
//
// This is the primary mechanism through which users will expose
// C++ classes to Python. The three template arguments are:
//
template <
class T // class being wrapped
, class X1 // = detail::not_specified
, class X2 // = detail::not_specified
, class X3 // = detail::not_specified
>
class class_ : public objects::class_base
{
private: // types
typedef objects::class_base base;
typedef class_<T,X1,X2,X3> self;
BOOST_STATIC_CONSTANT(bool, is_copyable = (!detail::has_noncopyable<X1,X2,X3>::value));
typedef typename detail::select_held_type<
X1, typename detail::select_held_type<
X2, typename detail::select_held_type<
X3
>::type>::type>::type held_type;
typedef objects::select_holder<T,held_type> holder_selector;
typedef typename detail::select_bases<X1
, typename detail::select_bases<X2
, typename boost::python::detail::select_bases<X3>::type
>::type
>::type bases;
// A helper class which will contain an array of id objects to be
// passed to the base class constructor
struct id_vector
{
id_vector()
{
// Stick the derived class id into the first element of the array
ids[0] = type_id<T>();
// Write the rest of the elements into succeeding positions.
type_info* p = ids + 1;
mpl::for_each(detail::write_type_id(&p), (bases*)0, (add_pointer<mpl::_>*)0);
}
BOOST_STATIC_CONSTANT(
std::size_t, size = mpl::size<bases>::value + 1);
type_info ids[size];
};
friend struct id_vector;
public:
// Automatically derive the class name - only works on some
// compilers because type_info::name is sometimes mangled (gcc)
// class_(); // With default-constructor init function
// class_(no_init_t); // With no init function
// Construct with the class name, with or without docstring, and default init() function
class_(char const* name, char const* doc = 0);
// Construct with class name, no docstring, and no init() function
class_(char const* name, no_init_t);
// Construct with class name, docstring, and no init() function
class_(char const* name, char const* doc, no_init_t);
template <class DerivedT>
inline class_(char const* name, init_base<DerivedT> const& i)
: base(name, id_vector::size, id_vector().ids)
{
this->register_();
define_init(*this, i.derived());
this->set_instance_size(holder_selector::additional_size());
}
template <class DerivedT>
inline class_(char const* name, char const* doc, init_base<DerivedT> const& i)
: base(name, id_vector::size, id_vector().ids, doc)
{
this->register_();
define_init(*this, i.derived());
this->set_instance_size(holder_selector::additional_size());
}
// Wrap a member function or a non-member function which can take
// a T, T cv&, or T cv* as its first parameter, or a callable
// python object.
template <class F>
self& def(char const* name, F f)
{
this->def_impl(name, f, default_call_policies(), 0, &f);
return *this;
}
template <class DerivedT>
self& def(init_base<DerivedT> const& i)
{
define_init(*this, i.derived());
return *this;
}
template <class Arg1T, class Arg2T>
self& def(char const* name, Arg1T arg1, Arg2T const& arg2)
{
// The arguments may be:
// def(name, function)
// def(name, function, policy)
// def(name, function, doc_string)
// def(name, signature, stubs)
dispatch_def(&arg2, name, arg1, arg2);
return *this;
}
template <class Arg1T, class Arg2T, class Arg3T>
self& def(char const* name, Arg1T arg1, Arg2T const& arg2, Arg3T const& arg3)
{
// The arguments are definitely:
// def(name, function, policy, doc_string) // TODO: exchange policy, doc_string position
dispatch_def(&arg2, name, arg1, arg2, arg3);
return *this;
}
template <detail::operator_id id, class L, class R>
self& def(detail::operator_<id,L,R> const& op)
{
typedef detail::operator_<id,L,R> op_t;
return this->def(op.name(), &op_t::template apply<T>::execute);
}
// Define the constructor with the given Args, which should be an
// MPL sequence of types.
template <class Args>
self& def_init(Args const&)
{
return this->def("__init__",
python::make_constructor<Args>(
// Using runtime type selection works around a CWPro7 bug.
holder_selector::execute((held_type*)0).get()
)
);
}
template <class Args, class CallPolicyOrDoc>
self& def_init(Args const&, CallPolicyOrDoc const& policy_or_doc, char const* doc = 0)
{
typedef detail::def_helper<CallPolicyOrDoc> helper;
return this->def(
"__init__",
python::make_constructor<Args>(
helper::get_policy(policy_or_doc)
// Using runtime type selection works around a CWPro7 bug.
, holder_selector::execute((held_type*)0).get()
)
, helper::get_doc(policy_or_doc, doc)
);
}
// Define the default constructor.
self& def_init()
{
this->def_init(mpl::list0<>::type());
return *this;
}
//
// Data member access
//
template <class D>
self& def_readonly(char const* name, D T::*pm)
{
this->add_property(name, make_getter(pm));
return *this;
}
template <class D>
self& def_readwrite(char const* name, D T::*pm)
{
return this->add_property(name, make_getter(pm), make_setter(pm));
}
// Property creation
template <class Get>
self& add_property(char const* name, Get const& fget)
{
base::add_property(name, object(fget));
return *this;
}
template <class Get, class Set>
self& add_property(char const* name, Get const& fget, Set const& fset)
{
base::add_property(name, object(fget), object(fset));
return *this;
}
template <class U>
self& setattr(char const* name, U const& x)
{
this->base::setattr(name, object(x));
return *this;
}
// Pickle support
template <typename PickleSuiteType>
self& def_pickle(PickleSuiteType const& x)
{
error_messages::must_be_derived_from_pickle_suite(x);
detail::pickle_suite_finalize<PickleSuiteType>::register_(
*this,
&PickleSuiteType::getinitargs,
&PickleSuiteType::getstate,
&PickleSuiteType::setstate,
PickleSuiteType::getstate_manages_dict());
return *this;
}
private: // helper functions
template <class Fn, class Policies>
inline void def_impl(char const* name, Fn fn, Policies const& policies
, char const* doc, ...)
{
objects::add_to_namespace(
*this, name,
make_function(
// This bit of nastiness casts F to a member function of T if possible.
detail::member_function_cast<T,Fn>::stage1(fn).stage2((T*)0).stage3(fn)
, policies)
, doc);
}
template <class F>
inline void def_impl(char const* name, F f, default_call_policies const&
, char const* doc, object const*)
{
objects::add_to_namespace(*this, name, f, doc);
}
inline void register_() const;
template <class Fn, class CallPolicyOrDoc>
void dispatch_def(
void const*,
char const* name,
Fn fn,
CallPolicyOrDoc const& policy_or_doc,
char const* doc = 0)
{
typedef detail::def_helper<CallPolicyOrDoc> helper;
this->def_impl(
name, fn, helper::get_policy(policy_or_doc),
helper::get_doc(policy_or_doc, doc), &fn);
}
template <class StubsT, class SigT>
void dispatch_def(
detail::func_stubs_base const*,
char const* name,
SigT sig,
StubsT const& stubs)
{
// convert sig to a type_list (see detail::get_signature in signature.hpp)
// before calling detail::define_with_defaults.
detail::define_with_defaults(
name, stubs, *this, detail::get_signature(sig));
}
};
//
// implementations
//
// register converters
template <class T, class X1, class X2, class X3>
inline void class_<T,X1,X2,X3>::register_() const
{
objects::register_class_from_python<T,bases>();
detail::register_copy_constructor<T>(
mpl::bool_c<is_copyable>()
, holder_selector::execute((held_type*)0)
);
}
template <class T, class X1, class X2, class X3>
inline class_<T,X1,X2,X3>::class_(char const* name, char const* doc)
: base(name, id_vector::size, id_vector().ids, doc)
{
this->register_();
detail::force_instantiate(sizeof(detail::assert_default_constructible(T())));
this->def_init();
this->set_instance_size(holder_selector::additional_size());
}
template <class T, class X1, class X2, class X3>
inline class_<T,X1,X2,X3>::class_(char const* name, no_init_t)
: base(name, id_vector::size, id_vector().ids)
{
this->register_();
this->def_no_init();
}
template <class T, class X1, class X2, class X3>
inline class_<T,X1,X2,X3>::class_(char const* name, char const* doc, no_init_t)
: base(name, id_vector::size, id_vector().ids, doc)
{
this->register_();
this->def_no_init();
}
namespace detail
{
template <class T1, class T2, class T3>
struct has_noncopyable
: type_traits::ice_or<
is_same<T1,noncopyable>::value
, is_same<T2,noncopyable>::value
, is_same<T3,noncopyable>::value>
{};
template <class T, class Prev>
struct select_held_type
: mpl::if_c<
type_traits::ice_or<
specifies_bases<T>::value
, is_same<T,noncopyable>::value
>::value
, Prev
, T
>
{
};
}
}} // namespace boost::python
#endif // CLASS_DWA200216_HPP

View File

@@ -1,182 +0,0 @@
// Revision History:
// Mar 03 01 added: pickle safety measures (Ralf W. Grosse-Kunstleve)
#ifndef CLASS_WRAPPER_DWA101000_H_
# define CLASS_WRAPPER_DWA101000_H_
#include <boost/python/detail/extension_class.hpp>
#include <boost/python/operators.hpp>
#include <boost/python/module_builder.hpp>
#include <boost/python/conversions.hpp>
#include <boost/python/detail/cast.hpp>
#include <boost/python/reference.hpp>
namespace boost { namespace python {
// Syntactic sugar to make wrapping classes more convenient
template <class T, class U = detail::held_instance<T> >
class class_builder
: python_extension_class_converters<T, U> // Works around MSVC6.x/GCC2.95.2 bug described below
{
public:
class_builder(module_builder& module, const char* name)
: m_class(new detail::extension_class<T, U>(name))
{
module.add(ref(as_object(m_class.get()), ref::increment_count), name);
}
template <class OtherT, class OtherU>
class_builder(class_builder<OtherT, OtherU>& cls, const char* name)
: m_class(new detail::extension_class<T, U>(name))
{
cls.add(ref(as_object(m_class.get()), ref::increment_count), name);
}
template <class OtherT, class OtherU>
class_builder(detail::extension_class<OtherT, OtherU>* cls,
const char* name)
: m_class(new detail::extension_class<T, U>(name))
{
cls->set_attribute(name,
ref(as_object(m_class.get()), ref::increment_count));
}
~class_builder()
{}
inline void dict_defines_state() {
add(ref(BOOST_PYTHON_CONVERSION::to_python(1)), "__dict_defines_state__");
}
inline void getstate_manages_dict() {
add(ref(BOOST_PYTHON_CONVERSION::to_python(1)), "__getstate_manages_dict__");
}
// define constructors
template <class signature>
void def(const signature& s)
{ m_class->def(s); }
// export heterogeneous reverse-argument operators
// (type of lhs: 'left', of rhs: 'right')
// usage: foo_class.def(boost::python::operators<(boost::python::op_add | boost::python::op_sub), Foo>(),
// boost::python::left_operand<int const &>());
template <long which, class left, class right>
void def(operators<which, right> o1, left_operand<left> o2)
{ m_class->def(o1, o2); }
// export heterogeneous operators (type of lhs: 'left', of rhs: 'right')
// usage: foo_class.def(boost::python::operators<(boost::python::op_add | boost::python::op_sub), Foo>(),
// boost::python::right_operand<int const &>());
template <long which, class left, class right>
void def(operators<which, left> o1, right_operand<right> o2)
{ m_class->def(o1, o2); }
// define a function that passes Python arguments and keywords
// to C++ verbatim (as a 'tuple const &' and 'dictionary const &'
// respectively). This is useful for manual argument passing.
// It's also the only possibility to pass keyword arguments to C++.
// Fn must have a signatur that is compatible to
// PyObject * (*)(PyObject * aTuple, PyObject * aDictionary)
template <class Fn>
void def_raw(Fn fn, const char* name)
{ m_class->def_raw(fn, name); }
// define member functions. In fact this works for free functions, too -
// they act like static member functions, or if they start with the
// appropriate self argument (as a pointer or reference), they can be used
// just like ordinary member functions -- just like Python!
template <class Fn>
void def(Fn fn, const char* name)
{ m_class->def(fn, name); }
// Define a virtual member function with a default implementation.
// default_fn should be a function which provides the default implementation.
// Be careful that default_fn does not in fact call fn virtually!
template <class Fn, class DefaultFn>
void def(Fn fn, const char* name, DefaultFn default_fn)
{ m_class->def(fn, name, default_fn); }
// Provide a function which implements x.<name>, reading from the given
// member (pm) of the T obj
template <class MemberType>
void def_getter(MemberType T::*pm, const char* name)
{ m_class->def_getter(pm, name); }
// Provide a function which implements assignment to x.<name>, writing to
// the given member (pm) of the T obj
template <class MemberType>
void def_setter(MemberType T::*pm, const char* name)
{ m_class->def_getter(pm, name); }
// Expose the given member (pm) of the T obj as a read-only attribute
template <class MemberType>
void def_readonly(MemberType T::*pm, const char* name)
{ m_class->def_readonly(pm, name); }
// Expose the given member (pm) of the T obj as a read/write attribute
template <class MemberType>
void def_read_write(MemberType T::*pm, const char* name)
{ m_class->def_read_write(pm, name); }
// define the standard coercion needed for operator overloading
void def_standard_coerce()
{ m_class->def_standard_coerce(); }
// declare the given class a base class of this one and register
// conversion functions
template <class S, class V>
void declare_base(class_builder<S, V> const & base)
{
m_class->declare_base(base.get_extension_class());
}
// declare the given class a base class of this one and register
// upcast conversion function
template <class S, class V>
void declare_base(class_builder<S, V> const & base, without_downcast_t)
{
m_class->declare_base(base.get_extension_class(), without_downcast);
}
// get the embedded ExtensioClass object
detail::extension_class<T, U> * get_extension_class() const
{
return m_class.get();
}
// set an arbitrary attribute. Useful for non-function class data members,
// e.g. enums
void add(PyObject* x, const char* name)
{ m_class->set_attribute(name, x); }
void add(ref x, const char* name)
{ m_class->set_attribute(name, x); }
private:
// declare the given class a base class of this one and register
// conversion functions
template <class S, class V>
void declare_base(detail::extension_class<S, V> * base)
{
m_class->declare_base(base);
}
// declare the given class a base class of this one and register
// upcast conversion function
template <class S, class V>
void declare_base(detail::extension_class<S, V> * base, without_downcast_t)
{
m_class->declare_base(base, without_downcast);
}
reference<detail::extension_class<T, U> > m_class;
};
// The bug mentioned at the top of this file is that on certain compilers static
// global functions declared within the body of a class template will only be
// generated when the class template is constructed, and when (for some reason)
// the construction does not occur via a new-expression. Otherwise, we could
// rely on the initialization of the m_class data member to cause all of the
// to_/from_python functions to come into being.
}} // namespace boost::python
#endif // CLASS_WRAPPER_DWA101000_H_

View File

@@ -1,30 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef CLASS_FWD_DWA200222_HPP
# define CLASS_FWD_DWA200222_HPP
# include <boost/python/detail/not_specified.hpp>
# include <boost/python/args.hpp>
# include <boost/python/bases.hpp>
namespace boost { namespace python {
namespace detail
{
struct empty_list;
}
template <
class T // class being wrapped
// arbitrarily-ordered optional arguments. Full qualification needed for MSVC6
, class X1 = ::boost::python::detail::not_specified
, class X2 = ::boost::python::detail::not_specified
, class X3 = ::boost::python::detail::not_specified
>
class class_;
}} // namespace boost::python
#endif // CLASS_FWD_DWA200222_HPP

View File

@@ -1,677 +0,0 @@
// (C) Copyright David Abrahams 2000. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// The author gratefully acknowleges the support of Dragon Systems, Inc., in
// producing this work.
#ifndef SUBCLASS_DWA051500_H_
# define SUBCLASS_DWA051500_H_
# include <boost/python/detail/config.hpp>
# include <boost/python/detail/types.hpp>
# include <boost/python/objects.hpp>
# include <boost/python/detail/singleton.hpp>
# include <boost/utility.hpp>
# include <boost/python/conversions.hpp>
# include <boost/python/callback.hpp>
namespace boost { namespace python {
// A simple type which acts something like a built-in Python class obj.
class BOOST_PYTHON_DECL instance
: public boost::python::detail::python_object
{
public:
instance(PyTypeObject* class_);
~instance();
// Standard Python functions.
PyObject* repr();
int compare(PyObject*);
PyObject* str();
long hash();
PyObject* call(PyObject* args, PyObject* keywords);
PyObject* getattr(const char* name, bool use_special_function = true);
int setattr(const char* name, PyObject* value);
// Mapping methods
int length();
PyObject* get_subscript(PyObject* key);
void set_subscript(PyObject* key, PyObject* value);
// Sequence methods
PyObject* get_slice(int start, int finish);
void set_slice(int start, int finish, PyObject* value);
// Number methods
PyObject* add(PyObject* other);
PyObject* subtract(PyObject* other);
PyObject* multiply(PyObject* other);
PyObject* divide(PyObject* other);
PyObject* remainder(PyObject* other);
PyObject* divmod(PyObject* other);
PyObject* power(PyObject*, PyObject*);
PyObject* negative();
PyObject* positive();
PyObject* absolute();
int nonzero();
PyObject* invert();
PyObject* lshift(PyObject* other);
PyObject* rshift(PyObject* other);
PyObject* do_and(PyObject* other);
PyObject* do_xor(PyObject* other);
PyObject* do_or(PyObject* other);
int coerce(PyObject**, PyObject**);
PyObject* as_int();
PyObject* as_long();
PyObject* as_float();
PyObject* oct();
PyObject* hex();
// Rich comparisons
PyObject* lt(PyObject* other);
PyObject* le(PyObject* other);
PyObject* eq(PyObject* other);
PyObject* ne(PyObject* other);
PyObject* gt(PyObject* other);
PyObject* ge(PyObject* other);
// Inplace operations.
PyObject* inplace_add(PyObject* other);
PyObject* inplace_subtract(PyObject* other);
PyObject* inplace_multiply(PyObject* other);
PyObject* inplace_divide(PyObject* other);
PyObject* inplace_remainder(PyObject* other);
PyObject* inplace_power(PyObject* exponent, PyObject* modulus);
PyObject* inplace_lshift(PyObject* other);
PyObject* inplace_rshift(PyObject* other);
PyObject* inplace_and(PyObject* other);
PyObject* inplace_or(PyObject* other);
PyObject* inplace_xor(PyObject* other);
private: // noncopyable, without the size bloat
instance(const instance&);
void operator=(const instance&);
private: // helper functions
int setattr_dict(PyObject* value);
private:
dictionary m_name_space;
};
template <class T> class meta_class;
namespace detail {
class BOOST_PYTHON_DECL class_base : public type_object_base
{
public:
class_base(PyTypeObject* meta_class_obj, string name, tuple bases, const dictionary& name_space);
tuple bases() const;
string name() const;
dictionary& dict();
// Standard Python functions.
PyObject* getattr(const char* name);
int setattr(const char* name, PyObject* value);
PyObject* repr() const;
void add_base(ref base);
protected:
bool initialize_instance(instance* obj, PyObject* args, PyObject* keywords);
private: // virtual functions
// Subclasses should override this to delete the particular obj type
virtual void delete_instance(PyObject*) const = 0;
private: // boost::python::type_object_base required interface implementation
void instance_dealloc(PyObject*) const; // subclasses should not override this
private: // noncopyable, without the size bloat
class_base(const class_base&);
void operator=(const class_base&);
private:
string m_name;
tuple m_bases;
dictionary m_name_space;
};
void enable_named_method(class_base* type_obj, const char* name);
}
// A type which acts a lot like a built-in Python class. T is the obj type,
// so class_t<instance> is a very simple "class-alike".
template <class T>
class class_t : public boost::python::detail::class_base
{
public:
class_t(meta_class<T>* meta_class_obj, string name, tuple bases, const dictionary& name_space);
~class_t();
// Standard Python functions.
PyObject* call(PyObject* args, PyObject* keywords);
private: // Implement mapping methods on instances
PyObject* instance_repr(PyObject*) const;
int instance_compare(PyObject*, PyObject* other) const;
PyObject* instance_str(PyObject*) const;
long instance_hash(PyObject*) const;
int instance_mapping_length(PyObject*) const;
PyObject* instance_mapping_subscript(PyObject*, PyObject*) const;
int instance_mapping_ass_subscript(PyObject*, PyObject*, PyObject*) const;
private: // Implement sequence methods on instances
int instance_sequence_length(PyObject*) const;
PyObject* instance_sequence_item(PyObject* obj, int n) const;
int instance_sequence_ass_item(PyObject* obj, int n, PyObject* value) const;
PyObject* instance_sequence_slice(PyObject*, int start, int finish) const;
int instance_sequence_ass_slice(PyObject*, int start, int finish, PyObject* value) const;
private: // Implement number methods on instances
PyObject* instance_number_add(PyObject*, PyObject*) const;
PyObject* instance_number_subtract(PyObject*, PyObject*) const;
PyObject* instance_number_multiply(PyObject*, PyObject*) const;
PyObject* instance_number_divide(PyObject*, PyObject*) const;
PyObject* instance_number_remainder(PyObject*, PyObject*) const;
PyObject* instance_number_divmod(PyObject*, PyObject*) const;
PyObject* instance_number_power(PyObject*, PyObject*, PyObject*) const;
PyObject* instance_number_negative(PyObject*) const;
PyObject* instance_number_positive(PyObject*) const;
PyObject* instance_number_absolute(PyObject*) const;
int instance_number_nonzero(PyObject*) const;
PyObject* instance_number_invert(PyObject*) const;
PyObject* instance_number_lshift(PyObject*, PyObject*) const;
PyObject* instance_number_rshift(PyObject*, PyObject*) const;
PyObject* instance_number_and(PyObject*, PyObject*) const;
PyObject* instance_number_xor(PyObject*, PyObject*) const;
PyObject* instance_number_or(PyObject*, PyObject*) const;
int instance_number_coerce(PyObject*, PyObject**, PyObject**) const;
PyObject* instance_number_int(PyObject*) const;
PyObject* instance_number_long(PyObject*) const;
PyObject* instance_number_float(PyObject*) const;
PyObject* instance_number_oct(PyObject*) const;
PyObject* instance_number_hex(PyObject*) const;
PyObject* instance_number_inplace_add(PyObject*, PyObject*) const;
PyObject* instance_number_inplace_subtract(PyObject*, PyObject*) const;
PyObject* instance_number_inplace_multiply(PyObject*, PyObject*) const;
PyObject* instance_number_inplace_divide(PyObject*, PyObject*) const;
PyObject* instance_number_inplace_remainder(PyObject*, PyObject*) const;
PyObject* instance_number_inplace_power(PyObject*, PyObject*, PyObject*) const;
PyObject* instance_number_inplace_lshift(PyObject*, PyObject*) const;
PyObject* instance_number_inplace_rshift(PyObject*, PyObject*) const;
PyObject* instance_number_inplace_and(PyObject*, PyObject*) const;
PyObject* instance_number_inplace_or(PyObject*, PyObject*) const;
PyObject* instance_number_inplace_xor(PyObject*, PyObject*) const;
private: // Implement rich comparisons
PyObject* instance_lt(PyObject*, PyObject*) const;
PyObject* instance_le(PyObject*, PyObject*) const;
PyObject* instance_eq(PyObject*, PyObject*) const;
PyObject* instance_ne(PyObject*, PyObject*) const;
PyObject* instance_gt(PyObject*, PyObject*) const;
PyObject* instance_ge(PyObject*, PyObject*) const;
private: // Miscellaneous "special" methods
PyObject* instance_call(PyObject* obj, PyObject* args, PyObject* keywords) const;
PyObject* instance_getattr(PyObject* obj, const char* name) const;
int instance_setattr(PyObject* obj, const char* name, PyObject* value) const;
private: // Implementation of boost::python::detail::class_base required interface
void delete_instance(PyObject*) const;
};
// The type of a class_t<T> object.
template <class T>
class meta_class
: public boost::python::detail::reprable<
boost::python::detail::callable<
boost::python::detail::getattrable<
boost::python::detail::setattrable<
boost::python::detail::type_object<class_t<T> > > > > >,
private boost::noncopyable
{
public:
meta_class();
// Standard Python functions.
PyObject* call(PyObject* args, PyObject* keywords);
struct type_object
: boost::python::detail::singleton<type_object,
boost::python::detail::callable<
boost::python::detail::type_object<meta_class> > >
{
type_object() : singleton_base(&PyType_Type) {}
};
};
//
// Member function implementations.
//
template <class T>
meta_class<T>::meta_class()
: properties(type_object::instance())
{
}
template <class T>
class_t<T>::class_t(meta_class<T>* meta_class_obj, string name, tuple bases, const dictionary& name_space)
: boost::python::detail::class_base(meta_class_obj, name, bases, name_space)
{
}
template <class T>
class_t<T>::~class_t()
{
}
template <class T>
void class_t<T>::delete_instance(PyObject* obj) const
{
delete downcast<T>(obj);
}
template <class T>
PyObject* class_t<T>::call(PyObject* args, PyObject* keywords)
{
reference<T> result(new T(this));
if (!this->initialize_instance(result.get(), args, keywords))
return 0;
else
return result.release();
}
template <class T>
PyObject* class_t<T>::instance_repr(PyObject* obj) const
{
return downcast<T>(obj)->repr();
}
template <class T>
int class_t<T>::instance_compare(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->compare(other);
}
template <class T>
PyObject* class_t<T>::instance_str(PyObject* obj) const
{
return downcast<T>(obj)->str();
}
template <class T>
long class_t<T>::instance_hash(PyObject* obj) const
{
return downcast<T>(obj)->hash();
}
template <class T>
int class_t<T>::instance_mapping_length(PyObject* obj) const
{
return downcast<T>(obj)->length();
}
template <class T>
int class_t<T>::instance_sequence_length(PyObject* obj) const
{
return downcast<T>(obj)->length();
}
template <class T>
PyObject* class_t<T>::instance_mapping_subscript(PyObject* obj, PyObject* key) const
{
return downcast<T>(obj)->get_subscript(key);
}
template <class T>
PyObject* class_t<T>::instance_sequence_item(PyObject* obj, int n) const
{
ref key(to_python(n));
return downcast<T>(obj)->get_subscript(key.get());
}
template <class T>
int class_t<T>::instance_sequence_ass_item(PyObject* obj, int n, PyObject* value) const
{
ref key(to_python(n));
downcast<T>(obj)->set_subscript(key.get(), value);
return 0;
}
template <class T>
int class_t<T>::instance_mapping_ass_subscript(PyObject* obj, PyObject* key, PyObject* value) const
{
downcast<T>(obj)->set_subscript(key, value);
return 0;
}
bool BOOST_PYTHON_DECL adjust_slice_indices(PyObject* obj, int& start, int& finish);
template <class T>
PyObject* class_t<T>::instance_sequence_slice(PyObject* obj, int start, int finish) const
{
if (!adjust_slice_indices(obj, start, finish))
return 0;
return downcast<T>(obj)->get_slice(start, finish);
}
template <class T>
int class_t<T>::instance_sequence_ass_slice(PyObject* obj, int start, int finish, PyObject* value) const
{
if (!adjust_slice_indices(obj, start, finish))
return -1;
downcast<T>(obj)->set_slice(start, finish, value);
return 0;
}
template <class T>
PyObject* class_t<T>::instance_call(PyObject* obj, PyObject* args, PyObject* keywords) const
{
return downcast<T>(obj)->call(args, keywords);
}
template <class T>
PyObject* class_t<T>::instance_getattr(PyObject* obj, const char* name) const
{
return downcast<T>(obj)->getattr(name);
}
template <class T>
int class_t<T>::instance_setattr(PyObject* obj, const char* name, PyObject* value) const
{
return downcast<T>(obj)->setattr(name, value);
}
template <class T>
PyObject* class_t<T>::instance_number_add(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->add(other);
}
template <class T>
PyObject* class_t<T>::instance_number_subtract(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->subtract(other);
}
template <class T>
PyObject* class_t<T>::instance_number_multiply(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->multiply(other);
}
template <class T>
PyObject* class_t<T>::instance_number_divide(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->divide(other);
}
template <class T>
PyObject* class_t<T>::instance_number_remainder(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->remainder(other);
}
template <class T>
PyObject* class_t<T>::instance_number_divmod(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->divmod(other);
}
template <class T>
PyObject* class_t<T>::instance_number_power(PyObject* obj, PyObject* exponent, PyObject* modulus) const
{
return downcast<T>(obj)->power(exponent, modulus);
}
template <class T>
PyObject* class_t<T>::instance_number_negative(PyObject* obj) const
{
return downcast<T>(obj)->negative();
}
template <class T>
PyObject* class_t<T>::instance_number_positive(PyObject* obj) const
{
return downcast<T>(obj)->positive();
}
template <class T>
PyObject* class_t<T>::instance_number_absolute(PyObject* obj) const
{
return downcast<T>(obj)->absolute();
}
template <class T>
int class_t<T>::instance_number_nonzero(PyObject* obj) const
{
return downcast<T>(obj)->nonzero();
}
template <class T>
PyObject* class_t<T>::instance_number_invert(PyObject* obj) const
{
return downcast<T>(obj)->invert();
}
template <class T>
PyObject* class_t<T>::instance_number_lshift(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->lshift(other);
}
template <class T>
PyObject* class_t<T>::instance_number_rshift(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->rshift(other);
}
template <class T>
PyObject* class_t<T>::instance_number_and(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->do_and(other);
}
template <class T>
PyObject* class_t<T>::instance_number_xor(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->do_xor(other);
}
template <class T>
PyObject* class_t<T>::instance_number_or(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->do_or(other);
}
template <class T>
int class_t<T>::instance_number_coerce(PyObject* obj, PyObject** x, PyObject** y) const
{
return downcast<T>(obj)->coerce(x, y);
}
template <class T>
PyObject* class_t<T>::instance_number_int(PyObject* obj) const
{
return downcast<T>(obj)->as_int();
}
template <class T>
PyObject* class_t<T>::instance_number_long(PyObject* obj) const
{
return downcast<T>(obj)->as_long();
}
template <class T>
PyObject* class_t<T>::instance_number_float(PyObject* obj) const
{
return downcast<T>(obj)->as_float();
}
template <class T>
PyObject* class_t<T>::instance_number_oct(PyObject* obj) const
{
return downcast<T>(obj)->oct();
}
template <class T>
PyObject* class_t<T>::instance_number_hex(PyObject* obj) const
{
return downcast<T>(obj)->hex();
}
template <class T>
PyObject* class_t<T>::instance_number_inplace_add(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->inplace_add(other);
}
template <class T>
PyObject* class_t<T>::instance_number_inplace_subtract(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->inplace_subtract(other);
}
template <class T>
PyObject* class_t<T>::instance_number_inplace_multiply(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->inplace_multiply(other);
}
template <class T>
PyObject* class_t<T>::instance_number_inplace_divide(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->inplace_divide(other);
}
template <class T>
PyObject* class_t<T>::instance_number_inplace_remainder(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->inplace_remainder(other);
}
template <class T>
PyObject* class_t<T>::instance_number_inplace_power(PyObject* obj, PyObject* exponent, PyObject* modulus) const
{
return downcast<T>(obj)->inplace_power(exponent, modulus);
}
template <class T>
PyObject* class_t<T>::instance_number_inplace_lshift(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->inplace_lshift(other);
}
template <class T>
PyObject* class_t<T>::instance_number_inplace_rshift(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->inplace_rshift(other);
}
template <class T>
PyObject* class_t<T>::instance_number_inplace_and(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->inplace_and(other);
}
template <class T>
PyObject* class_t<T>::instance_number_inplace_or(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->inplace_or(other);
}
template <class T>
PyObject* class_t<T>::instance_number_inplace_xor(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->inplace_xor(other);
}
template <class T>
PyObject* class_t<T>::instance_lt(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->lt(other);
}
template <class T>
PyObject* class_t<T>::instance_le(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->le(other);
}
template <class T>
PyObject* class_t<T>::instance_eq(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->eq(other);
}
template <class T>
PyObject* class_t<T>::instance_ne(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->ne(other);
}
template <class T>
PyObject* class_t<T>::instance_gt(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->gt(other);
}
template <class T>
PyObject* class_t<T>::instance_ge(PyObject* obj, PyObject* other) const
{
return downcast<T>(obj)->ge(other);
}
namespace detail {
inline dictionary& class_base::dict()
{
return m_name_space;
}
inline tuple class_base::bases() const
{
return m_bases;
}
}
template <class T>
PyObject* meta_class<T>::call(PyObject* args, PyObject* /*keywords*/)
{
PyObject* name;
PyObject* bases;
PyObject* name_space;
if (!PyArg_ParseTuple(args, const_cast<char*>("O!O!O!"),
&PyString_Type, &name,
&PyTuple_Type, &bases,
&PyDict_Type, &name_space))
{
return 0;
}
return as_object(
new class_t<T>(this, string(ref(name, ref::increment_count)),
tuple(ref(bases, ref::increment_count)),
dictionary(ref(name_space, ref::increment_count)))
);
}
namespace detail {
const string& setattr_string();
const string& getattr_string();
const string& delattr_string();
inline string class_base::name() const
{
return m_name;
}
}
}} // namespace boost::python
#endif

View File

@@ -1,415 +0,0 @@
// (C) Copyright David Abrahams 2000. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// The author gratefully acknowleges the support of Dragon Systems, Inc., in
// producing this work.
//
// Revision History:
// 31 Jul 01 convert int/double to complex (Peter Bienstman)
// 04 Mar 01 Fixed std::complex<> stuff to work with MSVC (David Abrahams)
// 03 Mar 01 added: converters for [plain] char and std::complex
// (Ralf W. Grosse-Kunstleve)
#ifndef METHOD_DWA122899_H_
# define METHOD_DWA122899_H_
# include <boost/python/detail/config.hpp>
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/detail/none.hpp>
# include <boost/python/detail/signatures.hpp>
# include <boost/shared_ptr.hpp>
# include <boost/python/errors.hpp>
# include <string>
# ifdef BOOST_MSVC6_OR_EARLIER
# pragma warning(push)
# pragma warning(disable:4275) // disable a bogus warning caused by <complex>
# endif
# include <complex>
# ifdef BOOST_MSVC6_OR_EARLIER
# pragma warning(pop)
# endif
BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE // this is a gcc 2.95.2 bug workaround
// This can be instantiated on an enum to provide the to_python/from_python
// conversions, provided the values can fit in a long.
template <class EnumType>
class py_enum_as_int_converters
{
friend EnumType from_python(PyObject* x, boost::python::type<EnumType>)
{
return static_cast<EnumType>(
from_python(x, boost::python::type<long>()));
}
friend EnumType from_python(PyObject* x, boost::python::type<const EnumType&>)
{
return static_cast<EnumType>(
from_python(x, boost::python::type<long>()));
}
friend PyObject* to_python(EnumType x)
{
return to_python(static_cast<long>(x));
}
};
BOOST_PYTHON_END_CONVERSION_NAMESPACE
namespace boost { namespace python {
template <class EnumType> class enum_as_int_converters
: public BOOST_PYTHON_CONVERSION::py_enum_as_int_converters<EnumType> {};
template <class P, class T> class wrapped_pointer;
//#pragma warn_possunwant off
inline void decref_impl(PyObject* p) { Py_DECREF(p); }
inline void xdecref_impl(PyObject* p) { Py_XDECREF(p); }
//#pragma warn_possunwant reset
template <class T>
inline void decref(T* p)
{
char* const raw_p = reinterpret_cast<char*>(p);
char* const p_base = raw_p - offsetof(PyObject, ob_refcnt);
decref_impl(reinterpret_cast<PyObject*>(p_base));
}
template <class T>
inline void xdecref(T* p)
{
char* const raw_p = reinterpret_cast<char*>(p);
char* const p_base = raw_p - offsetof(PyObject, ob_refcnt);
xdecref_impl(reinterpret_cast<PyObject*>(p_base));
}
namespace detail {
void expect_complex(PyObject*);
template <class T>
std::complex<T> complex_from_python(PyObject* p, boost::python::type<T>)
{
if (PyInt_Check(p)) return std::complex<T>(PyInt_AS_LONG(p));
if (PyLong_Check(p)) return std::complex<T>(PyLong_AsDouble(p));
if (PyFloat_Check(p)) return std::complex<T>(PyFloat_AS_DOUBLE(p));
expect_complex(p);
return std::complex<T>(
static_cast<T>(PyComplex_RealAsDouble(p)),
static_cast<T>(PyComplex_ImagAsDouble(p)));
}
template <class T>
PyObject* complex_to_python(const std::complex<T>& sc) {
Py_complex pcc;
pcc.real = sc.real();
pcc.imag = sc.imag();
return PyComplex_FromCComplex(pcc);
}
}
}} // namespace boost::python
BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE
//
// Converters
//
PyObject* to_python(long);
BOOST_PYTHON_DECL long from_python(PyObject* p, boost::python::type<long>);
long from_python(PyObject* p, boost::python::type<const long&>);
BOOST_PYTHON_DECL PyObject* to_python(unsigned long);
BOOST_PYTHON_DECL unsigned long from_python(PyObject* p, boost::python::type<unsigned long>);
unsigned long from_python(PyObject* p, boost::python::type<const unsigned long&>);
PyObject* to_python(int);
BOOST_PYTHON_DECL int from_python(PyObject*, boost::python::type<int>);
int from_python(PyObject*, boost::python::type<const int&>);
BOOST_PYTHON_DECL PyObject* to_python(unsigned int);
BOOST_PYTHON_DECL unsigned int from_python(PyObject*, boost::python::type<unsigned int>);
unsigned int from_python(PyObject*, boost::python::type<const unsigned int&>);
PyObject* to_python(short);
BOOST_PYTHON_DECL short from_python(PyObject*, boost::python::type<short>);
short from_python(PyObject*, boost::python::type<const short&>);
BOOST_PYTHON_DECL PyObject* to_python(unsigned short);
BOOST_PYTHON_DECL unsigned short from_python(PyObject*, boost::python::type<unsigned short>);
unsigned short from_python(PyObject*, boost::python::type<const unsigned short&>);
BOOST_PYTHON_DECL PyObject* to_python(char);
BOOST_PYTHON_DECL char from_python(PyObject*, boost::python::type<char>);
char from_python(PyObject*, boost::python::type<const char&>);
BOOST_PYTHON_DECL PyObject* to_python(signed char);
BOOST_PYTHON_DECL signed char from_python(PyObject*, boost::python::type<signed char>);
signed char from_python(PyObject*, boost::python::type<const signed char&>);
BOOST_PYTHON_DECL PyObject* to_python(unsigned char);
BOOST_PYTHON_DECL unsigned char from_python(PyObject*, boost::python::type<unsigned char>);
unsigned char from_python(PyObject*, boost::python::type<const unsigned char&>);
BOOST_PYTHON_DECL float from_python(PyObject*, boost::python::type<float>);
BOOST_PYTHON_DECL double from_python(PyObject*, boost::python::type<double>);
# if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
PyObject* to_python(float);
PyObject* to_python(double);
# else
BOOST_PYTHON_DECL PyObject* to_python(float);
BOOST_PYTHON_DECL PyObject* to_python(double);
# endif
float from_python(PyObject*, boost::python::type<const float&>);
double from_python(PyObject*, boost::python::type<const double&>);
PyObject* to_python(bool);
BOOST_PYTHON_DECL bool from_python(PyObject*, boost::python::type<bool>);
bool from_python(PyObject*, boost::python::type<const bool&>);
BOOST_PYTHON_DECL PyObject* to_python(void);
BOOST_PYTHON_DECL void from_python(PyObject*, boost::python::type<void>);
PyObject* to_python(const char* s);
BOOST_PYTHON_DECL const char* from_python(PyObject*, boost::python::type<const char*>);
BOOST_PYTHON_DECL PyObject* to_python(const std::string& s);
BOOST_PYTHON_DECL std::string from_python(PyObject*, boost::python::type<std::string>);
std::string from_python(PyObject*, boost::python::type<const std::string&>);
inline PyObject* to_python(const std::complex<float>& x)
{
return boost::python::detail::complex_to_python<float>(x);
}
inline PyObject* to_python(const std::complex<double>& x)
{
return boost::python::detail::complex_to_python<double>(x);
}
inline std::complex<double> from_python(PyObject* p,
boost::python::type<std::complex<double> >) {
return boost::python::detail::complex_from_python(p, boost::python::type<double>());
}
inline std::complex<double> from_python(PyObject* p,
boost::python::type<const std::complex<double>&>) {
return boost::python::detail::complex_from_python(p, boost::python::type<double>());
}
inline std::complex<float> from_python(PyObject* p,
boost::python::type<std::complex<float> >) {
return boost::python::detail::complex_from_python(p, boost::python::type<float>());
}
inline std::complex<float> from_python(PyObject* p,
boost::python::type<const std::complex<float>&>) {
return boost::python::detail::complex_from_python(p, boost::python::type<float>());
}
// For when your C++ function really wants to pass/return a PyObject*
PyObject* to_python(PyObject*);
PyObject* from_python(PyObject*, boost::python::type<PyObject*>);
// Some standard conversions to/from smart pointer types. You can add your own
// from these examples. These are not generated using the friend technique from
// wrapped_pointer because:
//
// 1. We want to be able to extend conversion to/from WrappedPointers using
// arbitrary smart pointer types.
//
// 2. It helps with compilation independence. This way, code which creates
// wrappers for functions accepting and returning smart_ptr<T> does not
// have to have already seen the invocation of wrapped_type<T>.
//
// Unfortunately, MSVC6 is so incredibly lame that we have to rely on the friend
// technique to auto_generate standard pointer conversions for wrapped
// types. This means that you need to write a non-templated function for each
// specific smart_ptr<T> which you want to convert from_python. For example,
//
// namespace boost { namespace python {
// #ifdef MUST_SUPPORT_MSVC
//
// MyPtr<Foo> from_python(PyObject*p, type<MyPtr<Foo> >)
// { return smart_ptr_from_python(p, type<MyPtr<Foo> >(), type<Foo>());}
// }
//
// MyPtr<Bar> from_python(PyObject*p, type<MyPtr<Bar> >)
// { return smart_ptr_from_python(p, type<MyPtr<Bar> >(), type<Bar>());}
//
// ... // definitions for MyPtr<Baz>, MyPtr<Mumble>, etc.
//
// #else
//
// // Just once for all MyPtr<T>
// template <class T>
// MyPtr<T> from_python(PyObject*p, type<MyPtr<T> >)
// {
// return smart_ptr_from_python(p, type<MyPtr<T> >(), type<T>());
// }
//
// #endif
// }} // namespace boost::python
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
template <class T>
boost::shared_ptr<T> from_python(PyObject*p, boost::python::type<boost::shared_ptr<T> >)
{
return smart_ptr_from_python(p, boost::python::type<boost::shared_ptr<T> >(), boost::python::type<T>());
}
#endif
#if 0
template <class T>
PyObject* to_python(std::auto_ptr<T> p)
{
return new boost::python::wrapped_pointer<std::auto_ptr<T>, T>(p);
}
template <class T>
PyObject* to_python(boost::shared_ptr<T> p)
{
return new boost::python::wrapped_pointer<boost::shared_ptr<T>, T>(p);
}
#endif
//
// inline implementations
//
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
inline PyObject* to_python(double d)
{
return PyFloat_FromDouble(d);
}
inline PyObject* to_python(float f)
{
return PyFloat_FromDouble(f);
}
#endif
inline PyObject* to_python(long l)
{
return PyInt_FromLong(l);
}
inline PyObject* to_python(int x)
{
return PyInt_FromLong(x);
}
inline PyObject* to_python(short x)
{
return PyInt_FromLong(x);
}
inline PyObject* to_python(bool b)
{
return PyInt_FromLong(b);
}
inline PyObject* to_python(void)
{
return boost::python::detail::none();
}
inline PyObject* to_python(const char* s)
{
return PyString_FromString(s);
}
inline std::string from_python(PyObject* p, boost::python::type<const std::string&>)
{
return from_python(p, boost::python::type<std::string>());
}
inline PyObject* to_python(PyObject* p)
{
Py_INCREF(p);
return p;
}
inline PyObject* from_python(PyObject* p, boost::python::type<PyObject*>)
{
return p;
}
inline const char* from_python(PyObject* p, boost::python::type<const char* const&>)
{
return from_python(p, boost::python::type<const char*>());
}
inline double from_python(PyObject* p, boost::python::type<const double&>)
{
return from_python(p, boost::python::type<double>());
}
inline float from_python(PyObject* p, boost::python::type<const float&>)
{
return from_python(p, boost::python::type<float>());
}
inline int from_python(PyObject* p, boost::python::type<const int&>)
{
return from_python(p, boost::python::type<int>());
}
inline short from_python(PyObject* p, boost::python::type<const short&>)
{
return from_python(p, boost::python::type<short>());
}
inline long from_python(PyObject* p, boost::python::type<const long&>)
{
return from_python(p, boost::python::type<long>());
}
inline bool from_python(PyObject* p, boost::python::type<const bool&>)
{
return from_python(p, boost::python::type<bool>());
}
inline unsigned int from_python(PyObject* p, boost::python::type<const unsigned int&>)
{
return from_python(p, boost::python::type<unsigned int>());
}
inline unsigned short from_python(PyObject* p, boost::python::type<const unsigned short&>)
{
return from_python(p, boost::python::type<unsigned short>());
}
inline char from_python(PyObject* p, boost::python::type<const char&>)
{
return from_python(p, boost::python::type<char>());
}
inline signed char from_python(PyObject* p, boost::python::type<const signed char&>)
{
return from_python(p, boost::python::type<signed char>());
}
inline unsigned char from_python(PyObject* p, boost::python::type<const unsigned char&>)
{
return from_python(p, boost::python::type<unsigned char>());
}
inline unsigned long from_python(PyObject* p, boost::python::type<const unsigned long&>)
{
return from_python(p, boost::python::type<unsigned long>());
}
BOOST_PYTHON_END_CONVERSION_NAMESPACE
#endif // METHOD_DWA122899_H_

View File

@@ -1,336 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef ARG_FROM_PYTHON_DWA2002127_HPP
# define ARG_FROM_PYTHON_DWA2002127_HPP
# include <boost/python/converter/from_python.hpp>
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/detail/indirect_traits.hpp>
# include <boost/type_traits/transform_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/python/converter/rvalue_from_python_data.hpp>
# include <boost/mpl/if.hpp>
# include <boost/python/converter/registry.hpp>
# include <boost/python/converter/registered.hpp>
# include <boost/python/converter/registered_pointee.hpp>
# include <boost/python/detail/void_ptr.hpp>
# include <boost/python/back_reference.hpp>
# include <boost/python/detail/referent_storage.hpp>
# include <boost/python/converter/obj_mgr_arg_from_python.hpp>
namespace boost { namespace python
{
template <class T> struct arg_from_python;
}}
// This header defines Python->C++ function argument converters,
// parametrized on the argument type.
namespace boost { namespace python { namespace converter {
//
// lvalue converters
//
// These require that an lvalue of the type U is stored somewhere in
// the Python object being converted.
// Used when T == U*const&
template <class T>
struct pointer_cref_arg_from_python
{
typedef T result_type;
pointer_cref_arg_from_python(PyObject*);
T operator()(PyObject*) const;
bool convertible() const;
private: // storage for a U*
// needed because not all compilers will let us declare U* as the
// return type of operator() -- we return U*const& instead
typename python::detail::referent_storage<T>::type m_result;
};
// Base class for pointer and reference converters
struct arg_lvalue_from_python_base
{
public: // member functions
arg_lvalue_from_python_base(void* result);
bool convertible() const;
protected: // member functions
void*const& result() const;
private: // data members
void* m_result;
};
// Used when T == U*
template <class T>
struct pointer_arg_from_python : arg_lvalue_from_python_base
{
typedef T result_type;
pointer_arg_from_python(PyObject*);
T operator()(PyObject*) const;
};
// Used when T == U& and (T != V const& or T == W volatile&)
template <class T>
struct reference_arg_from_python : arg_lvalue_from_python_base
{
typedef T result_type;
reference_arg_from_python(PyObject*);
T operator()(PyObject*) const;
};
// ===================
//
// rvalue converters
//
// These require only that an object of type T can be created from
// the given Python object, but not that the T object exist
// somewhere in storage.
//
// Used when T is a plain value (non-pointer, non-reference) type or
// a (non-volatile) const reference to a plain value type.
template <class T>
struct arg_rvalue_from_python
{
typedef typename boost::add_reference<
typename boost::add_const<T>::type
>::type result_type;
arg_rvalue_from_python(PyObject*);
bool convertible() const;
result_type operator()(PyObject*);
private:
rvalue_from_python_data<result_type> m_data;
};
// ==================
// Converts to a (PyObject*,T) bundle, for when you need a reference
// back to the Python object
template <class T>
struct back_reference_arg_from_python
: boost::python::arg_from_python<typename T::type>
{
typedef T result_type;
back_reference_arg_from_python(PyObject*);
T operator()(PyObject*);
private:
typedef boost::python::arg_from_python<typename T::type> base;
};
// ==================
// This metafunction selects the appropriate arg_from_python converter
// type for an argument of type T.
template <class T>
struct select_arg_from_python
{
BOOST_STATIC_CONSTANT(
bool, obj_mgr = is_object_manager<T>::value);
BOOST_STATIC_CONSTANT(
bool, obj_mgr_ref = is_reference_to_object_manager<T>::value);
BOOST_STATIC_CONSTANT(
bool, ptr = is_pointer<T>::value);
BOOST_STATIC_CONSTANT(
bool, ptr_cref
= boost::python::detail::is_reference_to_pointer<T>::value
&& boost::python::detail::is_reference_to_const<T>::value
&& !boost::python::detail::is_reference_to_volatile<T>::value);
BOOST_STATIC_CONSTANT(
bool, ref =
boost::python::detail::is_reference_to_non_const<T>::value
|| boost::python::detail::is_reference_to_volatile<T>::value);
BOOST_STATIC_CONSTANT(
bool, back_ref =
boost::python::is_back_reference<T>::value);
typedef typename mpl::if_c<
obj_mgr
, object_manager_value_arg_from_python<T>
, typename mpl::if_c<
obj_mgr_ref
, object_manager_ref_arg_from_python<T>
, typename mpl::if_c<
ptr
, pointer_arg_from_python<T>
, typename mpl::if_c<
ptr_cref
, pointer_cref_arg_from_python<T>
, typename mpl::if_c<
ref
, reference_arg_from_python<T>
, typename mpl::if_c<
back_ref
, back_reference_arg_from_python<T>
, arg_rvalue_from_python<T>
>::type
>::type
>::type
>::type
>::type
>::type type;
};
// ==================
//
// implementations
//
// arg_lvalue_from_python_base
//
inline arg_lvalue_from_python_base::arg_lvalue_from_python_base(void* result)
: m_result(result)
{
}
inline bool arg_lvalue_from_python_base::convertible() const
{
return m_result != 0;
}
inline void*const& arg_lvalue_from_python_base::result() const
{
return m_result;
}
// pointer_cref_arg_from_python
//
namespace detail
{
// null_ptr_reference -- a function returning a reference to a null
// pointer of type U. Needed so that extractors for T*const& can
// convert Python's None.
template <class T>
struct null_ptr_owner
{
static T value;
};
template <class T> T null_ptr_owner<T>::value = 0;
template <class U>
inline U& null_ptr_reference(U&(*)())
{
return null_ptr_owner<U>::value;
}
}
template <class T>
inline pointer_cref_arg_from_python<T>::pointer_cref_arg_from_python(PyObject* p)
{
// T == U*const&: store a U* in the m_result storage. Nonzero
// indicates success. If find returns nonzero, it's a pointer to
// a U object.
python::detail::write_void_ptr_reference(
m_result.bytes
, p == Py_None ? p : converter::get_lvalue_from_python(p, registered_pointee<T>::converters)
, (T(*)())0);
}
template <class T>
inline bool pointer_cref_arg_from_python<T>::convertible() const
{
return python::detail::void_ptr_to_reference(m_result.bytes, (T(*)())0) != 0;
}
template <class T>
inline T pointer_cref_arg_from_python<T>::operator()(PyObject* p) const
{
return (p == Py_None) // None ==> 0
? detail::null_ptr_reference((T(*)())0)
// Otherwise, return a U*const& to the m_result storage.
: python::detail::void_ptr_to_reference(m_result.bytes, (T(*)())0);
}
// pointer_arg_from_python
//
template <class T>
inline pointer_arg_from_python<T>::pointer_arg_from_python(PyObject* p)
: arg_lvalue_from_python_base(
p == Py_None ? p : converter::get_lvalue_from_python(p, registered_pointee<T>::converters))
{
}
template <class T>
inline T pointer_arg_from_python<T>::operator()(PyObject* p) const
{
return (p == Py_None) ? 0 : T(result());
}
// reference_arg_from_python
//
template <class T>
inline reference_arg_from_python<T>::reference_arg_from_python(PyObject* p)
: arg_lvalue_from_python_base(converter::get_lvalue_from_python(p,registered<T>::converters))
{
}
template <class T>
inline T reference_arg_from_python<T>::operator()(PyObject*) const
{
return python::detail::void_ptr_to_reference(result(), (T(*)())0);
}
// arg_rvalue_from_python
//
template <class T>
inline arg_rvalue_from_python<T>::arg_rvalue_from_python(PyObject* obj)
: m_data(converter::rvalue_from_python_stage1(obj, registered<T>::converters))
{
}
template <class T>
inline bool arg_rvalue_from_python<T>::convertible() const
{
return m_data.stage1.convertible != 0;
}
template <class T>
inline typename arg_rvalue_from_python<T>::result_type
arg_rvalue_from_python<T>::operator()(PyObject* p)
{
if (m_data.stage1.construct != 0)
m_data.stage1.construct(p, &m_data.stage1);
return python::detail::void_ptr_to_reference(m_data.stage1.convertible, (result_type(*)())0);
}
// back_reference_arg_from_python
//
template <class T>
back_reference_arg_from_python<T>::back_reference_arg_from_python(PyObject* x)
: base(x)
{
}
template <class T>
inline T
back_reference_arg_from_python<T>::operator()(PyObject* x)
{
return T(x, base::operator()(x));
}
}}} // namespace boost::python::converter
#endif // ARG_FROM_PYTHON_DWA2002127_HPP

View File

@@ -1,247 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef ARG_TO_PYTHON_DWA200265_HPP
# define ARG_TO_PYTHON_DWA200265_HPP
# include <boost/python/ptr.hpp>
# include <boost/python/converter/registered.hpp>
# include <boost/python/converter/registered_pointee.hpp>
# include <boost/python/converter/arg_to_python_base.hpp>
# include <boost/python/to_python_indirect.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/type_traits/composite_traits.hpp>
# include <boost/type_traits/function_traits.hpp>
# include <boost/python/detail/indirect_traits.hpp>
# include <boost/python/detail/convertible.hpp>
# include <boost/python/detail/string_literal.hpp>
# include <boost/python/base_type_traits.hpp>
// Bring in specializations
# include <boost/python/converter/builtin_converters.hpp>
# include <boost/python/tag.hpp>
# include <boost/python/object/function_handle.hpp>
namespace boost { namespace python { namespace converter {
template <class T> struct is_object_manager;
namespace detail
{
BOOST_PYTHON_DECL void throw_no_class_registered();
template <class T>
struct function_arg_to_python : handle<>
{
function_arg_to_python(T const& x);
};
template <class T>
struct reference_arg_to_python : handle<>
{
reference_arg_to_python(T& x);
private:
static PyObject* get_object(T& x);
};
template <class T>
struct value_arg_to_python : arg_to_python_base
{
// Throw an exception if the conversion can't succeed
value_arg_to_python(T const&);
};
template <class Ptr>
struct pointer_deep_arg_to_python : arg_to_python_base
{
// Throw an exception if the conversion can't succeed
pointer_deep_arg_to_python(Ptr);
};
template <class Ptr>
struct pointer_shallow_arg_to_python : handle<>
{
// Throw an exception if the conversion can't succeed
pointer_shallow_arg_to_python(Ptr);
private:
static PyObject* get_object(Ptr p);
};
// Convert types that manage a Python object to_python
template <class T>
struct object_manager_arg_to_python
{
object_manager_arg_to_python(T const& x) : m_src(x) {}
PyObject* get() const
{
return python::upcast<PyObject>(get_managed_object(m_src, tag));
}
private:
T const& m_src;
};
template <class T>
struct select_arg_to_python
{
// Special handling for char const[N]; interpret them as char
// const* for the sake of conversion
BOOST_STATIC_CONSTANT(
bool, is_string = python::detail::is_string_literal<T const>::value);
BOOST_STATIC_CONSTANT(
bool, function = is_function<T>::value | python::detail::is_pointer_to_function<T>::value | is_member_function_pointer<T>::value);
BOOST_STATIC_CONSTANT(
bool, manager = is_object_manager<T>::value);
BOOST_STATIC_CONSTANT(
bool, ptr = is_pointer<T>::value);
BOOST_STATIC_CONSTANT(
bool, ref_wrapper = is_reference_wrapper<T>::value);
BOOST_STATIC_CONSTANT(
bool, ptr_wrapper = is_pointer_wrapper<T>::value);
typedef typename unwrap_reference<T>::type unwrapped_referent;
typedef typename unwrap_pointer<T>::type unwrapped_ptr;
typedef typename mpl::if_c<
is_string
, arg_to_python<char const*>
, typename mpl::if_c<
function
, function_arg_to_python<T>
, typename mpl::if_c<
manager
, object_manager_arg_to_python<T>
, typename mpl::if_c<
ptr
, pointer_deep_arg_to_python<T>
, typename mpl::if_c<
ptr_wrapper
, pointer_shallow_arg_to_python<unwrapped_ptr>
, typename mpl::if_c<
ref_wrapper
, reference_arg_to_python<unwrapped_referent>
, value_arg_to_python<T>
>::type
>::type
>::type
>::type
>::type
>::type
type;
};
}
template <class T>
struct arg_to_python
: detail::select_arg_to_python<T>::type
{
typedef typename detail::select_arg_to_python<T>::type base;
public: // member functions
// Throw an exception if the conversion can't succeed
arg_to_python(T const& x);
};
//
// implementations
//
namespace detail
{
// reject_raw_object_ptr -- cause a compile-time error if the user
// should pass a raw Python object pointer
using python::detail::yes_convertible;
using python::detail::no_convertible;
using python::detail::unspecialized;
template <class T> struct cannot_convert_raw_PyObject;
template <class T, class Convertibility>
struct reject_raw_object_helper
{
static void error(Convertibility)
{
cannot_convert_raw_PyObject<T*>::to_python_use_handle_instead();
}
static void error(...) {}
};
template <class T>
inline void reject_raw_object_ptr(T*)
{
reject_raw_object_helper<T,yes_convertible>::error(
python::detail::convertible<PyObject const volatile*>::check((T*)0));
typedef typename remove_cv<T>::type value_type;
reject_raw_object_helper<T,no_convertible>::error(
python::detail::convertible<unspecialized*>::check(
(base_type_traits<value_type>*)0
));
}
// ---------
template <class T>
inline function_arg_to_python<T>::function_arg_to_python(T const& x)
: handle<>(python::objects::make_function_handle(x))
{
}
template <class T>
inline value_arg_to_python<T>::value_arg_to_python(T const& x)
: arg_to_python_base(&x, registered<T>::converters)
{
}
template <class Ptr>
inline pointer_deep_arg_to_python<Ptr>::pointer_deep_arg_to_python(Ptr x)
: arg_to_python_base(x, registered_pointee<Ptr>::converters)
{
detail::reject_raw_object_ptr((Ptr)0);
}
template <class T>
inline PyObject* reference_arg_to_python<T>::get_object(T& x)
{
to_python_indirect<T&,python::detail::make_reference_holder> convert;
if (!convert.convertible())
throw_no_class_registered();
return convert(x);
}
template <class T>
inline reference_arg_to_python<T>::reference_arg_to_python(T& x)
: handle<>(reference_arg_to_python<T>::get_object(x))
{
}
template <class Ptr>
inline pointer_shallow_arg_to_python<Ptr>::pointer_shallow_arg_to_python(Ptr x)
: handle<>(pointer_shallow_arg_to_python<Ptr>::get_object(x))
{
detail::reject_raw_object_ptr((Ptr)0);
}
template <class Ptr>
inline PyObject* pointer_shallow_arg_to_python<Ptr>::get_object(Ptr x)
{
to_python_indirect<Ptr,python::detail::make_reference_holder> convert;
if (!convert.convertible())
throw_no_class_registered();
return x ? convert(x) : python::detail::none();
}
}
template <class T>
inline arg_to_python<T>::arg_to_python(T const& x)
: base(x)
{}
}}} // namespace boost::python::converter
#endif // ARG_TO_PYTHON_DWA200265_HPP

View File

@@ -1,35 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef ARG_TO_PYTHON_BASE_DWA200237_HPP
# define ARG_TO_PYTHON_BASE_DWA200237_HPP
# include <boost/python/converter/to_python_function_type.hpp>
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/handle.hpp>
namespace boost { namespace python { namespace converter {
struct registration;
namespace detail
{
struct BOOST_PYTHON_DECL arg_to_python_base
# if !defined(BOOST_MSVC) || BOOST_MSVC <= 1300 || _MSC_FULL_VER > 13102179
: handle<>
# endif
{
arg_to_python_base(void const volatile* source, registration const&);
# if defined(BOOST_MSVC) && BOOST_MSVC > 1300 && _MSC_FULL_VER <= 13102179
PyObject* get() const { return m_ptr.get(); }
PyObject* release() { return m_ptr.release(); }
private:
handle<> m_ptr;
# endif
};
}
}}} // namespace boost::python::converter
#endif // ARG_TO_PYTHON_BASE_DWA200237_HPP

View File

@@ -1,123 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef BUILTIN_CONVERTERS_DWA2002124_HPP
# define BUILTIN_CONVERTERS_DWA2002124_HPP
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/detail/none.hpp>
# include <boost/python/handle.hpp>
# include <string>
# include <complex>
// Since all we can use to decide how to convert an object to_python
// is its C++ type, there can be only one such converter for each
// type. Therefore, for built-in conversions we can bypass registry
// lookups using explicit specializations of arg_to_python and
// result_to_python.
namespace boost { namespace python {
namespace converter
{
template <class T> struct arg_to_python;
BOOST_PYTHON_DECL PyObject* do_return_to_python(char);
BOOST_PYTHON_DECL PyObject* do_return_to_python(char const*);
BOOST_PYTHON_DECL PyObject* do_return_to_python(PyObject*);
BOOST_PYTHON_DECL PyObject* do_arg_to_python(PyObject*);
}
// Provide specializations of to_python_value
template <class T> struct to_python_value;
namespace detail
{
// Since there's no registry lookup, always report the existence of
// a converter.
struct builtin_to_python
{
static bool convertible() { return true; }
};
}
// Use expr to create the PyObject corresponding to x
# define BOOST_PYTHON_RETURN_TO_PYTHON_BY_VALUE(T, expr) \
template <> struct to_python_value<T&> \
: detail::builtin_to_python \
{ \
inline PyObject* operator()(T const& x) const \
{ \
return (expr); \
} \
}; \
template <> struct to_python_value<T const&> \
: detail::builtin_to_python \
{ \
inline PyObject* operator()(T const& x) const \
{ \
return (expr); \
} \
};
# define BOOST_PYTHON_ARG_TO_PYTHON_BY_VALUE(T, expr) \
namespace converter \
{ \
template <> struct arg_to_python< T > \
: handle<> \
{ \
arg_to_python(T const& x) \
: python::handle<>(expr) {} \
}; \
}
// Specialize argument and return value converters for T using expr
# define BOOST_PYTHON_TO_PYTHON_BY_VALUE(T, expr) \
BOOST_PYTHON_RETURN_TO_PYTHON_BY_VALUE(T,expr) \
BOOST_PYTHON_ARG_TO_PYTHON_BY_VALUE(T,expr)
// Specialize converters for signed and unsigned T to Python Int
# define BOOST_PYTHON_TO_INT(T) \
BOOST_PYTHON_TO_PYTHON_BY_VALUE(signed T, PyInt_FromLong(x)) \
BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned T, PyInt_FromLong(x))
// Bool is not signed.
BOOST_PYTHON_TO_PYTHON_BY_VALUE(bool, PyInt_FromLong(x))
// note: handles signed char and unsigned char, but not char (see below)
BOOST_PYTHON_TO_INT(char)
BOOST_PYTHON_TO_INT(short)
BOOST_PYTHON_TO_INT(int)
BOOST_PYTHON_TO_INT(long)
// using Python's macro instead of Boost's - we don't seem to get the
// config right all the time.
# ifdef HAVE_LONG_LONG
BOOST_PYTHON_TO_PYTHON_BY_VALUE(signed LONG_LONG, PyLong_FromLongLong(x))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned LONG_LONG, PyLong_FromUnsignedLongLong(x))
# endif
# undef BOOST_TO_PYTHON_INT
BOOST_PYTHON_TO_PYTHON_BY_VALUE(char, converter::do_return_to_python(x))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(char const*, converter::do_return_to_python(x))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::string, PyString_FromString(x.c_str()))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(float, PyFloat_FromDouble(x))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(double, PyFloat_FromDouble(x))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(long double, PyFloat_FromDouble(x))
BOOST_PYTHON_RETURN_TO_PYTHON_BY_VALUE(PyObject*, converter::do_return_to_python(x))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::complex<float>, PyComplex_FromDoubles(x.real(), x.imag()))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::complex<double>, PyComplex_FromDoubles(x.real(), x.imag()))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::complex<long double>, PyComplex_FromDoubles(x.real(), x.imag()))
namespace converter
{
void initialize_builtin_converters();
}
}} // namespace boost::python::converter
#endif // BUILTIN_CONVERTERS_DWA2002124_HPP

View File

@@ -1,278 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef CALLBACK_DWA2002228_HPP
# define CALLBACK_DWA2002228_HPP
# include <boost/python/converter/type_id.hpp>
# include <boost/python/converter/to_python_function.hpp>
# include <boost/python/converter/pointee_to_python_function.hpp>
# include <boost/python/converter/from_python.hpp>
# include <boost/mpl/select_if.hpp>
# include <boost/python/converter/callback_to_python_base.hpp>
# include <boost/python/converter/callback_from_python_base.hpp>
# include <boost/python/converter/builtin_converters.hpp>
# include <boost/python/to_python_indirect.hpp>
# include <boost/python/detail/none.hpp>
# include <boost/python/ptr.hpp>
# include <boost/python/errors.hpp>
namespace boost { namespace python { namespace converter {
namespace detail
{
template <class T>
struct pointer_callback_from_python
{
pointer_callback_from_python();
T operator()(PyObject*) const;
};
template <class T>
struct reference_callback_from_python
{
reference_callback_from_python();
T operator()(PyObject*) const;
};
template <class T>
struct rvalue_callback_from_python
{
rvalue_callback_from_python();
T const& operator()(PyObject*);
private:
rvalue_data<T> m_data;
};
template <class T>
struct select_callback_from_python
{
BOOST_STATIC_CONSTANT(
bool, ptr = is_pointer<T>::value);
BOOST_STATIC_CONSTANT(
bool, ref = is_reference<T>::value);
typedef typename mpl::select_if_c<
ptr
, pointer_callback_from_python<T>
, typename mpl::select_if_c<
ref
, reference_callback_from_python<T>
, rvalue_callback_from_python<T>
>::type
>::type type;
};
template <class T>
struct reference_callback_to_python : callback_to_python_holder
{
reference_callback_to_python(T& x);
private:
static PyObject* get_object(T& x);
};
template <class T>
struct value_callback_to_python : callback_to_python_base
{
// Throw an exception if the conversion can't succeed
value_callback_to_python(T const&);
};
template <class Ptr>
struct pointer_deep_callback_to_python : callback_to_python_base
{
// Throw an exception if the conversion can't succeed
pointer_deep_callback_to_python(Ptr);
};
template <class Ptr>
struct pointer_shallow_callback_to_python : callback_to_python_holder
{
// Throw an exception if the conversion can't succeed
pointer_shallow_callback_to_python(Ptr);
private:
static PyObject* get_object(Ptr p);
};
template <class T>
struct select_callback_to_python
{
BOOST_STATIC_CONSTANT(
bool, ptr = is_pointer<T>::value);
BOOST_STATIC_CONSTANT(
bool, ref_wrapper = is_reference_wrapper<T>::value);
BOOST_STATIC_CONSTANT(
bool, ptr_wrapper = is_pointer_wrapper<T>::value);
typedef typename unwrap_reference<T>::type unwrapped_referent;
typedef typename unwrap_pointer<T>::type unwrapped_ptr;
typedef typename mpl::select_if_c<
ptr
, pointer_deep_callback_to_python<T>
, typename mpl::select_if_c<
ptr_wrapper
, pointer_shallow_callback_to_python<unwrapped_ptr>
, typename mpl::select_if_c<
ref_wrapper
, reference_callback_to_python<unwrapped_referent>
, value_callback_to_python<T>
>::type
>::type
>::type type;
};
}
template <class T>
struct callback_from_python
: detail::select_callback_from_python<T>::type
{
typedef T result_type;
};
struct void_result
{
private:
void_result() {}
void operator=(void_result const&);
// I would prefer to make this completely untouchable, but few
// compilers support template friends
# if 0
void_result(void_result const&);
# endif
friend struct callback_from_python<void>;
};
// Specialization as a convenience for call and call_method
template <>
struct callback_from_python<void>
{
typedef void_result result_type;
result_type operator()(PyObject* x) const
{
Py_DECREF(expect_non_null(x));
return result_type();
}
};
template <class T>
struct callback_to_python
: detail::select_callback_to_python<T>::type
{
typedef typename detail::select_callback_to_python<T>::type base;
public: // member functions
// Throw an exception if the conversion can't succeed
callback_to_python(T const& x);
};
// Convenience macros for call<> and call_method<> code generation
# define BOOST_PYTHON_CALLBACK_TO_PYTHON_GET(index,ignored) \
converter::callback_to_python<BOOST_PP_CAT(A,index)>( \
BOOST_PP_CAT(a,index)).get()
# define BOOST_PYTHON_ARG_STRING(nargs) \
"(" BOOST_PP_REPEAT(nargs,BOOST_PYTHON_PROJECT_2ND,"O") ")"
//
// Implementations
//
namespace detail
{
template <class T>
inline rvalue_callback_from_python<T>::rvalue_callback_from_python()
: m_data(rvalue_from_python_chain<T>::value)
{
throw_if_not_registered(m_data.stage1);
}
template <class T>
inline T const& rvalue_callback_from_python<T>::operator()(PyObject* obj)
{
return *(T*)convert_rvalue(obj, m_data.stage1, m_data.storage.bytes);
}
BOOST_PYTHON_DECL void throw_no_class_registered();
template <class T>
inline reference_callback_from_python<T>::reference_callback_from_python()
{
detail::throw_if_not_registered(lvalue_from_python_chain<T,true>::value);
}
template <class T>
inline T reference_callback_from_python<T>::operator()(PyObject* obj) const
{
return python::detail::void_ptr_to_reference(
callback_convert_reference(obj, lvalue_from_python_chain<T,true>::value)
, (T(*)())0);
}
template <class T>
inline pointer_callback_from_python<T>::pointer_callback_from_python()
{
detail::throw_if_not_registered(lvalue_from_python_chain<T,true>::value);
}
template <class T>
inline T pointer_callback_from_python<T>::operator()(PyObject* obj) const
{
return T(callback_convert_pointer(obj, lvalue_from_python_chain<T,true>::value));
}
template <class T>
inline value_callback_to_python<T>::value_callback_to_python(T const& x)
: callback_to_python_base(&x, to_python_function<T>::value)
{
}
template <class Ptr>
inline pointer_deep_callback_to_python<Ptr>::pointer_deep_callback_to_python(Ptr x)
: callback_to_python_base(x, pointee_to_python_function<Ptr>::value)
{
}
template <class T>
inline PyObject* reference_callback_to_python<T>::get_object(T& x)
{
to_python_indirect<T&,python::detail::make_reference_holder> convert;
if (!convert.convertible())
throw_no_class_registered();
return convert(x);
}
template <class T>
inline reference_callback_to_python<T>::reference_callback_to_python(T& x)
: callback_to_python_holder(get_object(x))
{
}
template <class Ptr>
inline pointer_shallow_callback_to_python<Ptr>::pointer_shallow_callback_to_python(Ptr x)
: callback_to_python_holder(get_object(x))
{}
template <class Ptr>
inline PyObject* pointer_shallow_callback_to_python<Ptr>::get_object(Ptr x)
{
to_python_indirect<Ptr,python::detail::make_reference_holder> convert;
if (!convert.convertible())
throw_no_class_registered();
return x ? convert(x) : python::detail::none();
}
}
template <class T>
inline callback_to_python<T>::callback_to_python(T const& x)
: base(x)
{}
}}} // namespace boost::python::converter
#endif // CALLBACK_DWA2002228_HPP

View File

@@ -1,25 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef CALLBACK_FROM_PYTHON_BASE_DWA200237_HPP
# define CALLBACK_FROM_PYTHON_BASE_DWA200237_HPP
namespace boost { namespace python { namespace converter {
namespace detail
{
// Throw an exception
BOOST_PYTHON_DECL void throw_if_not_registered(rvalue_stage1_data const&);
BOOST_PYTHON_DECL void* convert_rvalue(PyObject*, rvalue_stage1_data& data, void* storage);
BOOST_PYTHON_DECL void throw_if_not_registered(lvalue_from_python_registration*const&);
BOOST_PYTHON_DECL void* callback_convert_reference(PyObject*, lvalue_from_python_registration*const&);
BOOST_PYTHON_DECL void* callback_convert_pointer(PyObject*, lvalue_from_python_registration*const&);
}
}}} // namespace boost::python::converter
#endif // CALLBACK_FROM_PYTHON_BASE_DWA200237_HPP

View File

@@ -1,45 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef CALLBACK_TO_PYTHON_BASE_DWA200237_HPP
# define CALLBACK_TO_PYTHON_BASE_DWA200237_HPP
# include <boost/python/converter/to_python_function_type.hpp>
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/reference.hpp>
namespace boost { namespace python { namespace converter {
namespace detail
{
struct callback_to_python_holder
{
callback_to_python_holder(PyObject* obj);
inline PyObject* get() const;
private:
ref m_held;
};
struct BOOST_PYTHON_DECL callback_to_python_base : callback_to_python_holder
{
callback_to_python_base(void const volatile* source, to_python_function_t);
};
//
// implmentation
//
inline callback_to_python_holder::callback_to_python_holder(PyObject* obj)
: m_held(obj)
{
}
inline PyObject* callback_to_python_holder::get() const
{
return m_held.get();
}
}
}}} // namespace boost::python::converter
#endif // CALLBACK_TO_PYTHON_BASE_DWA200237_HPP

View File

@@ -1,18 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef CONSTRUCTOR_FUNCTION_DWA200278_HPP
# define CONSTRUCTOR_FUNCTION_DWA200278_HPP
namespace boost { namespace python { namespace converter {
// Declares the type of functions used to construct C++ objects for
// rvalue from_python conversions.
struct rvalue_from_python_stage1_data;
typedef void (*constructor_function)(PyObject* source, rvalue_from_python_stage1_data*);
}}} // namespace boost::python::converter
#endif // CONSTRUCTOR_FUNCTION_DWA200278_HPP

View File

@@ -1,15 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef CONVERTIBLE_FUNCTION_DWA200278_HPP
# define CONVERTIBLE_FUNCTION_DWA200278_HPP
namespace boost { namespace python { namespace converter {
typedef void* (*convertible_function)(PyObject*);
}}} // namespace boost::python::converter
#endif // CONVERTIBLE_FUNCTION_DWA200278_HPP

View File

@@ -1,29 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef FIND_FROM_PYTHON_DWA2002223_HPP
# define FIND_FROM_PYTHON_DWA2002223_HPP
# include <boost/python/detail/config.hpp>
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/converter/from_python_stage1_data.hpp>
namespace boost { namespace python { namespace converter {
struct lvalue_from_python_registration;
struct rvalue_from_python_registration;
BOOST_PYTHON_DECL void* find(
PyObject* source, lvalue_from_python_registration const*);
BOOST_PYTHON_DECL rvalue_stage1_data find(
PyObject* source, rvalue_from_python_registration const*);
BOOST_PYTHON_DECL rvalue_from_python_registration const* find_chain(
PyObject* source, rvalue_from_python_registration const*);
}}} // namespace boost::python::converter
#endif // FIND_FROM_PYTHON_DWA2002223_HPP

View File

@@ -1,43 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef FIND_FROM_PYTHON_DWA2002223_HPP
# define FIND_FROM_PYTHON_DWA2002223_HPP
# include <boost/python/detail/config.hpp>
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/converter/rvalue_from_python_data.hpp>
namespace boost { namespace python { namespace converter {
struct registration;
struct rvalue_from_python_chain;
BOOST_PYTHON_DECL void* get_lvalue_from_python(
PyObject* source, registration const&);
BOOST_PYTHON_DECL rvalue_from_python_chain const* implicit_conversion_chain(
PyObject* source, registration const&);
BOOST_PYTHON_DECL rvalue_from_python_stage1_data rvalue_from_python_stage1(
PyObject* source, registration const&);
BOOST_PYTHON_DECL void* rvalue_from_python_stage2(
PyObject* source, rvalue_from_python_stage1_data&, registration const&);
BOOST_PYTHON_DECL void* rvalue_result_from_python(
PyObject*, rvalue_from_python_stage1_data&);
BOOST_PYTHON_DECL void* reference_result_from_python(PyObject*, registration const&);
BOOST_PYTHON_DECL void* pointer_result_from_python(PyObject*, registration const&);
BOOST_PYTHON_DECL void void_result_from_python(PyObject*);
BOOST_PYTHON_DECL void throw_no_pointer_from_python(PyObject*, registration const&);
BOOST_PYTHON_DECL void throw_no_reference_from_python(PyObject*, registration const&);
}}} // namespace boost::python::converter
#endif // FIND_FROM_PYTHON_DWA2002223_HPP

View File

@@ -1,129 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef FROM_PYTHON_AUX_DATA_DWA2002128_HPP
# define FROM_PYTHON_AUX_DATA_DWA2002128_HPP
# include <boost/python/detail/char_array.hpp>
# include <boost/mpl/select_if.hpp>
# include <boost/type_traits/same_traits.hpp>
# include <boost/type_traits/transform_traits.hpp>
# include <boost/static_assert.hpp>
# include <boost/python/converter/from_python_stage1_data.hpp>
# include <boost/type_traits/composite_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/python/detail/destroy.hpp>
# include <boost/preprocessor/list/for_each_i.hpp>
# include <boost/preprocessor/tuple/to_list.hpp>
# include <boost/preprocessor/cat.hpp>
namespace boost { namespace python { namespace converter {
namespace detail
{
template <class T> struct referent_size;
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class T>
struct referent_size<T&>
{
BOOST_STATIC_CONSTANT(
std::size_t, value = sizeof(T));
};
# else
template <class T> struct referent_size
{
static T f();
BOOST_STATIC_CONSTANT(std::size_t, value = sizeof(f()));
};
# endif
struct alignment_dummy;
typedef void (*function_ptr)();
typedef int (alignment_dummy::*member_ptr);
typedef int (alignment_dummy::*member_function_ptr)();
# define BOOST_PYTHON_ALIGNMENT_TYPES BOOST_PP_TUPLE_TO_LIST( \
11, ( \
char, short, int, long, float, double, long double \
, void*, function_ptr, member_ptr, member_function_ptr))
# define BOOST_PYTHON_CHOOSE_LOWER_SIZE(R,P,I,T) \
typename mpl::select_if_c< \
sizeof(T) <= target, T, char>::type BOOST_PP_CAT(t,I);
# define BOOST_PYTHON_CHOOSE_T(R,P,I,T) T BOOST_PP_CAT(t,I);
template <std::size_t target>
union lower_size
{
BOOST_PP_LIST_FOR_EACH_I(
BOOST_PYTHON_CHOOSE_LOWER_SIZE
, ignored, BOOST_PYTHON_ALIGNMENT_TYPES)
};
template <class Align, std::size_t size>
union aligned_storage
{
Align align;
char bytes[size];
};
template <class Reference>
struct referent_storage
{
typedef lower_size<referent_size<Reference>::value> align_t;
typedef aligned_storage<align_t,referent_size<Reference>::value> type;
};
}
template <class T>
struct rvalue_base_data
{
rvalue_stage1_data stage1;
typename detail::referent_storage<
typename add_reference<T>::type
>::type storage;
};
template <class T>
struct rvalue_data : rvalue_base_data<T>
{
rvalue_data(rvalue_stage1_data const&);
rvalue_data(void*);
~rvalue_data();
private:
typedef typename add_reference<typename add_cv<T>::type>::type ref_type;
};
//
// Implementataions
//
template <class T>
inline rvalue_data<T>::rvalue_data(rvalue_stage1_data const& stage1)
{
this->stage1 = stage1;
}
template <class T>
inline rvalue_data<T>::rvalue_data(void* convertible)
{
this->stage1.convertible = convertible;
}
template <class T>
inline rvalue_data<T>::~rvalue_data()
{
if (this->stage1.convertible == this->storage.bytes)
python::detail::destroy_reference<ref_type>(this->storage.bytes);
}
}}} // namespace boost::python::converter
#endif // FROM_PYTHON_AUX_DATA_DWA2002128_HPP

View File

@@ -1,18 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef FROM_PYTHON_FUNCTION_DWA2002128_HPP
# define FROM_PYTHON_FUNCTION_DWA2002128_HPP
# include <boost/python/detail/wrap_python.hpp>
namespace boost { namespace python { namespace converter {
struct rvalue_stage1_data;
typedef void (*constructor_function)(PyObject* source, rvalue_stage1_data*);
}}} // namespace boost::python::converter
#endif // FROM_PYTHON_FUNCTION_DWA2002128_HPP

View File

@@ -1,21 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef FROM_PYTHON_STAGE1_DATA_DWA2002223_HPP
# define FROM_PYTHON_STAGE1_DATA_DWA2002223_HPP
# include <boost/python/converter/from_python_function.hpp>
namespace boost { namespace python { namespace converter {
struct rvalue_stage1_data
{
void* convertible;
constructor_function construct;
};
}}} // namespace boost::python::converter
#endif // FROM_PYTHON_STAGE1_DATA_DWA2002223_HPP

View File

@@ -1,57 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef IMPLICIT_DWA2002326_HPP
# define IMPLICIT_DWA2002326_HPP
# include <boost/python/converter/rvalue_from_python_data.hpp>
# include <boost/python/converter/registrations.hpp>
# include <boost/python/converter/registered.hpp>
namespace boost { namespace python { namespace converter {
template <class Source, class Target>
struct implicit
{
static void* convertible(PyObject* obj)
{
// Find a converter chain which can produce a Source instance
// from obj. The user has told us that Source can be converted
// to Target, and instantiating construct() below, ensures
// that at compile-time.
return const_cast<rvalue_from_python_chain*>(
converter::implicit_conversion_chain(obj, registered<Source>::converters));
}
static void construct(PyObject* obj, rvalue_from_python_stage1_data* data)
{
// This is the chain we got from the convertible step
rvalue_from_python_chain const* chain
= static_cast<rvalue_from_python_chain*>(data->convertible);
// Call the convertible function again
rvalue_from_python_data<Source> intermediate_data(chain->convertible(obj));
// Use the result to construct the source type if the first
// converter was an rvalue converter.
if (chain->construct != 0)
chain->construct(obj, &intermediate_data.stage1);
void* storage = ((rvalue_from_python_storage<Target>*)data)->storage.bytes;
# if !defined(BOOST_MSVC) || _MSC_FULL_VER != 13012108 // vc7.01 alpha workaround
new (storage) Target(*static_cast<Source*>(intermediate_data.stage1.convertible));
# else
Target x(*static_cast<Source*>(intermediate_data.stage1.convertible));
new (storage) Target(x);
# endif
// record successful construction
data->convertible = storage;
}
};
}}} // namespace boost::python::converter
#endif // IMPLICIT_DWA2002326_HPP

View File

@@ -1,70 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef LVALUE_FROM_PYTHON_CHAIN_DWA200237_HPP
# define LVALUE_FROM_PYTHON_CHAIN_DWA200237_HPP
# include <boost/python/converter/pointer_type_id.hpp>
# include <boost/python/converter/registry.hpp>
# include <boost/type_traits/cv_traits.hpp>
namespace boost { namespace python { namespace converter {
// Given T == U*cv&, T == U*, or T == U&, lvalue_from_python_chain<T>
// declares a "templated global reference" to the lvalue from_python
// converter chain for U. The optional bool second argument callback,
// when true, removes special treatment for T == U*cv& so that the
// converter for U* is found.
namespace detail
{
template <class T>
struct ptr_or_ptr_ref_lvalue_from_python_chain
{
static lvalue_from_python_registration*const& value;
};
template <class T>
lvalue_from_python_registration*const&
ptr_or_ptr_ref_lvalue_from_python_chain<T>::value
= registry::lvalue_converters(pointer_type_id<T>());
template <class T>
struct ref_lvalue_from_python_chain
{
static lvalue_from_python_registration*const& value;
};
template <class T>
lvalue_from_python_registration*const&
ref_lvalue_from_python_chain<T>::value
= registry::lvalue_converters(undecorated_type_id<T>());
template <class T, bool callback>
struct select_lvalue_from_python_chain
{
BOOST_STATIC_CONSTANT(
bool, ptr
= !callback && boost::python::detail::is_reference_to_pointer<T>::value
|| is_pointer<T>::value);
typedef typename add_reference<typename add_cv<T>::type>::type normalized;
typedef typename mpl::select_if_c<
ptr
, ptr_or_ptr_ref_lvalue_from_python_chain<normalized>
, ref_lvalue_from_python_chain<normalized>
>::type type;
};
}
template <class T, bool callback = false>
struct lvalue_from_python_chain
: detail::select_lvalue_from_python_chain<T,callback>::type
{
};
}}} // namespace boost::python::converter
#endif // LVALUE_FROM_PYTHON_CHAIN_DWA200237_HPP

View File

@@ -1,116 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef OBJ_MGR_ARG_FROM_PYTHON_DWA2002628_HPP
# define OBJ_MGR_ARG_FROM_PYTHON_DWA2002628_HPP
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/detail/referent_storage.hpp>
# include <boost/python/detail/destroy.hpp>
# include <boost/python/detail/construct.hpp>
# include <boost/python/converter/object_manager.hpp>
# include <boost/python/detail/raw_pyobject.hpp>
# include <boost/python/tag.hpp>
//
// arg_from_python converters for Python type wrappers, to be used as
// base classes for specializations.
//
namespace boost { namespace python { namespace converter {
template <class T>
struct object_manager_value_arg_from_python
{
typedef T result_type;
object_manager_value_arg_from_python(PyObject*);
bool convertible() const;
T operator()(PyObject*) const;
private:
PyObject* m_source;
};
// Used for converting reference-to-object-manager arguments from
// python. The process used here is a little bit odd. Upon
// construction, we build the object manager object in the m_result
// object, *forcing* it to accept the source Python object by casting
// its pointer to detail::borrowed_reference. This is supposed to
// bypass any type checking of the source object. The convertible
// check then extracts the owned object and checks it. If the check
// fails, nothing else in the program ever gets to touch this strange
// "forced" object.
template <class Ref>
struct object_manager_ref_arg_from_python
{
typedef Ref result_type;
object_manager_ref_arg_from_python(PyObject*);
bool convertible() const;
Ref operator()(PyObject*) const;
~object_manager_ref_arg_from_python();
private:
typename python::detail::referent_storage<Ref>::type m_result;
};
//
// implementations
//
template <class T>
inline object_manager_value_arg_from_python<T>::object_manager_value_arg_from_python(PyObject* x)
: m_source(x)
{
}
template <class T>
inline bool object_manager_value_arg_from_python<T>::convertible() const
{
return object_manager_traits<T>::check(m_source);
}
template <class T>
inline T object_manager_value_arg_from_python<T>::operator()(PyObject* x) const
{
return T(python::detail::borrowed_reference(x));
}
template <class Ref>
inline object_manager_ref_arg_from_python<Ref>::object_manager_ref_arg_from_python(PyObject* x)
{
python::detail::construct_referent<Ref>(&m_result.bytes, python::detail::borrowed_reference(x));
}
template <class Ref>
inline object_manager_ref_arg_from_python<Ref>::~object_manager_ref_arg_from_python()
{
python::detail::destroy_referent<Ref>(this->m_result.bytes);
}
namespace detail
{
template <class T>
inline bool object_manager_ref_check(T const& x)
{
return object_manager_traits<T>::check(get_managed_object(x, tag));
}
}
template <class Ref>
inline bool object_manager_ref_arg_from_python<Ref>::convertible() const
{
return detail::object_manager_ref_check(
python::detail::void_ptr_to_reference(this->m_result.bytes, (Ref(*)())0));
}
template <class Ref>
inline Ref object_manager_ref_arg_from_python<Ref>::operator()(PyObject*) const
{
return python::detail::void_ptr_to_reference(
this->m_result.bytes, (Ref(*)())0);
}
}}} // namespace boost::python::converter
#endif // OBJ_MGR_ARG_FROM_PYTHON_DWA2002628_HPP

View File

@@ -1,232 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef OBJECT_MANAGER_DWA2002614_HPP
# define OBJECT_MANAGER_DWA2002614_HPP
# include <boost/python/handle.hpp>
# include <boost/python/cast.hpp>
# include <boost/python/converter/pyobject_traits.hpp>
# include <boost/type_traits/object_traits.hpp>
# include <boost/mpl/if.hpp>
# include <boost/python/detail/indirect_traits.hpp>
// Facilities for dealing with types which always manage Python
// objects. Some examples are object, list, str, et. al. Different
// to_python/from_python conversion rules apply here because in
// contrast to other types which are typically embedded inside a
// Python object, these are wrapped around a Python object. For most
// object managers T, a C++ non-const T reference argument does not
// imply the existence of a T lvalue embedded in the corresponding
// Python argument, since mutating member functions on T actually only
// modify the held Python object.
//
// handle<T> is an object manager, though strictly speaking it should
// not be. In other words, even though mutating member functions of
// hanlde<T> actually modify the handle<T> and not the T object,
// handle<T>& arguments of wrapped functions will bind to "rvalues"
// wrapping the actual Python argument, just as with other object
// manager classes. Making an exception for handle<T> is simply not
// worth the trouble.
//
// borrowed<T> cv* is an object manager so that we can use the general
// to_python mechanisms to convert raw Python object pointers to
// python, without the usual semantic problems of using raw pointers.
// Object Manager Concept requirements:
//
// T is an Object Manager
// p is a PyObject*
// x is a T
//
// * object_manager_traits<T>::is_specialized == true
//
// * T(detail::borrowed_reference(p))
// Manages p without checking its type
//
// * get_managed_object(x, boost::python::tag)
// Convertible to PyObject*
//
// Additional requirements if T can be converted from_python:
//
// * T(object_manager_traits<T>::adopt(p))
// steals a reference to p, or throws a TypeError exception if
// p doesn't have an appropriate type. May assume p is non-null
//
// * X::check(p)
// convertible to bool. True iff T(X::construct(p)) will not
// throw.
// Forward declarations
//
namespace boost { namespace python
{
namespace api
{
class object;
}
}}
namespace boost { namespace python { namespace converter {
// Specializations for handle<T>
template <class T>
struct handle_object_manager_traits
: pyobject_traits<typename T::element_type>
{
private:
typedef pyobject_traits<typename T::element_type> base;
public:
BOOST_STATIC_CONSTANT(bool, is_specialized = true);
// Initialize with a null_ok pointer for efficiency, bypassing the
// null check since the source is always non-null.
static null_ok<typename T::element_type>* adopt(PyObject* p)
{
return python::allow_null(base::checked_downcast(p));
}
};
template <class T>
struct default_object_manager_traits
{
BOOST_STATIC_CONSTANT(
bool, is_specialized = python::detail::is_borrowed_ptr<T>::value
);
};
template <class T>
struct object_manager_traits
: mpl::if_c<
is_handle<T>::value
, handle_object_manager_traits<T>
, default_object_manager_traits<T>
>::type
{
};
//
// Traits for detecting whether a type is an object manager or a
// (cv-qualified) reference to an object manager.
//
template <class T>
struct is_object_manager
{
BOOST_STATIC_CONSTANT(
bool, value = object_manager_traits<T>::is_specialized);
};
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class T>
struct is_reference_to_object_manager
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
template <class T>
struct is_reference_to_object_manager<T&>
: is_object_manager<T>
{
};
template <class T>
struct is_reference_to_object_manager<T const&>
: is_object_manager<T>
{
};
template <class T>
struct is_reference_to_object_manager<T volatile&>
: is_object_manager<T>
{
};
template <class T>
struct is_reference_to_object_manager<T const volatile&>
: is_object_manager<T>
{
};
# else
namespace detail
{
typedef char (&yes_reference_to_object_manager)[1];
typedef char (&no_reference_to_object_manager)[2];
// A number of nastinesses go on here in order to work around MSVC6
// bugs.
template <class T>
struct is_object_manager_help
{
typedef typename mpl::if_c<
is_object_manager<T>::value
, yes_reference_to_object_manager
, no_reference_to_object_manager
>::type type;
// If we just use the type instead of the result of calling this
// function, VC6 will ICE.
static type call();
};
// A set of overloads for each cv-qualification. The same argument
// is passed twice: the first one is used to unwind the cv*, and the
// second one is used to avoid relying on partial ordering for
// overload resolution.
template <class U>
typename is_object_manager_help<U>
is_object_manager_helper(U*, void*);
template <class U>
typename is_object_manager_help<U>
is_object_manager_helper(U const*, void const*);
template <class U>
typename is_object_manager_help<U>
is_object_manager_helper(U volatile*, void volatile*);
template <class U>
typename is_object_manager_help<U>
is_object_manager_helper(U const volatile*, void const volatile*);
template <class T>
struct is_reference_to_object_manager_nonref
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
template <class T>
struct is_reference_to_object_manager_ref
{
static T sample_object;
BOOST_STATIC_CONSTANT(
bool, value
= (sizeof(is_object_manager_helper(&sample_object, &sample_object).call())
== sizeof(detail::yes_reference_to_object_manager)
)
);
};
}
template <class T>
struct is_reference_to_object_manager
{
typedef typename mpl::if_c<
is_reference<T>::value
, detail::is_reference_to_object_manager_ref<T>
, detail::is_reference_to_object_manager_nonref<T>
> chooser;
BOOST_STATIC_CONSTANT(bool, value = chooser::type::value);
};
# endif
}}} // namespace boost::python::converter
#endif // OBJECT_MANAGER_DWA2002614_HPP

View File

@@ -1,51 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef POINTEE_TO_PYTHON_FUNCTION_DWA2002128_HPP
# define POINTEE_TO_PYTHON_FUNCTION_DWA2002128_HPP
# include <boost/python/detail/wrap_python.hpp>
# include <boost/type_traits/transform_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/python/converter/type_id.hpp>
# include <boost/python/converter/registry.hpp>
# include <boost/python/converter/to_python_function_type.hpp>
# include <boost/python/converter/pointer_type_id.hpp>
namespace boost { namespace python { namespace converter {
// pointee_to_python_function --
//
// essentially a "templated global reference" which holds the
// converter for converting a type to Python by-value. We "normalize"
// T by adding "const volatile&" so that fewer global variables and
// associated static initializations are generated.
namespace detail
{
template <class T>
struct pointee_to_python_function_base
{
static to_python_function_t const& value;
};
template <class T>
to_python_function_t const&
pointee_to_python_function_base<T>::value
= converter::registry::get_to_python_function(pointer_type_id<T>());
}
template <class T>
struct pointee_to_python_function
: detail::pointee_to_python_function_base<
typename add_reference<
typename add_cv<T>::type
>::type
>
{
};
}}} // namespace boost::python::converter
#endif // POINTEE_TO_PYTHON_FUNCTION_DWA2002128_HPP

View File

@@ -1,69 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef POINTER_TYPE_ID_DWA2002222_HPP
# define POINTER_TYPE_ID_DWA2002222_HPP
# include <boost/python/type_id.hpp>
# include <boost/type_traits/composite_traits.hpp>
namespace boost { namespace python { namespace converter {
namespace detail
{
template <bool is_ref = false>
struct pointer_typeid_select
{
template <class T>
static inline type_info execute(T*(*)() = 0)
{
return type_id<T>();
}
};
template <>
struct pointer_typeid_select<true>
{
template <class T>
static inline type_info execute(T* const volatile&(*)() = 0)
{
return type_id<T>();
}
template <class T>
static inline type_info execute(T*volatile&(*)() = 0)
{
return type_id<T>();
}
template <class T>
static inline type_info execute(T*const&(*)() = 0)
{
return type_id<T>();
}
template <class T>
static inline type_info execute(T*&(*)() = 0)
{
return type_id<T>();
}
};
}
// Usage: pointer_type_id<T>()
//
// Returns a type_info associated with the type pointed
// to by T, which may be a pointer or a reference to a pointer.
template <class T>
type_info pointer_type_id(T(*)() = 0)
{
return detail::pointer_typeid_select<
is_reference<T>::value
>::execute((T(*)())0);
}
}}} // namespace boost::python::converter
#endif // POINTER_TYPE_ID_DWA2002222_HPP

View File

@@ -1,42 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef PYOBJECT_TRAITS_DWA2002720_HPP
# define PYOBJECT_TRAITS_DWA2002720_HPP
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/converter/pyobject_type.hpp>
namespace boost { namespace python { namespace converter {
template <class> struct pyobject_traits;
template <>
struct pyobject_traits<PyObject>
{
// All objects are convertible to PyObject
static bool check(PyObject*) { return true; }
static PyObject* checked_downcast(PyObject* x) { return x; }
};
//
// Specializations
//
# define BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(T) \
template <> struct pyobject_traits<Py##T##Object> \
: pyobject_type<Py##T##Object, &Py##T##_Type> {}
// This is not an exhaustive list; should be expanded.
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Type);
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(List);
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Int);
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Long);
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Dict);
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Tuple);
}}} // namespace boost::python::converter
#endif // PYOBJECT_TRAITS_DWA2002720_HPP

View File

@@ -1,36 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef PYOBJECT_TYPE_DWA2002720_HPP
# define PYOBJECT_TYPE_DWA2002720_HPP
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/cast.hpp>
namespace boost { namespace python { namespace converter {
BOOST_PYTHON_DECL PyObject* checked_downcast_impl(PyObject*, PyTypeObject*);
// Used as a base class for specializations which need to provide
// Python type checking capability.
template <class Object, PyTypeObject* pytype>
struct pyobject_type
{
static bool check(PyObject* x)
{
return ::PyObject_IsInstance(x, (PyObject*)pytype);
}
static Object* checked_downcast(PyObject* x)
{
return python::downcast<Object>(
(checked_downcast_impl)(x, pytype)
);
}
};
}}} // namespace boost::python::converter
#endif // PYOBJECT_TYPE_DWA2002720_HPP

View File

@@ -1,99 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef PYTYPE_ARG_FROM_PYTHON_DWA2002628_HPP
# define PYTYPE_ARG_FROM_PYTHON_DWA2002628_HPP
# include <boost/python/detail/wrap_python.hpp>
//
// arg_from_python converters for Python type wrappers, to be used as
// base classes for specializations.
//
namespace boost { namespace python { namespace converter {
template <PyTypeObject* python_type>
struct pytype_arg_from_python
{
pytype_arg_from_python(PyObject*);
bool convertible() const;
private:
PyObject* m_src;
};
// rvalue converter base
template <class Wrapper, PyTypeObject* python_type>
struct pytype_wrapper_value_arg_from_python
: pytype_arg_from_python<python_type>
{
typedef Wrapper result_type;
pytype_wrapper_value_arg_from_python(PyObject*);
Wrapper operator()(PyObject*) const;
};
// Special case for Wrapper& - must store an lvalue internally. This
// OK because the entire state of the object is actually in the Python
// object.
template <class Wrapper, PyTypeObject* python_type>
struct pytype_wrapper_ref_arg_from_python
: pytype_arg_from_python<python_type>
{
typedef Wrapper& result_type;
pytype_wrapper_ref_arg_from_python(PyObject*);
Wrapper& operator()(PyObject*) const;
private:
mutable Wrapper m_result;
};
//
// implementations
//
template <PyTypeObject* python_type>
inline pytype_arg_from_python<python_type>::pytype_arg_from_python(PyObject* x)
: m_src(x)
{
}
template <PyTypeObject* python_type>
inline bool pytype_arg_from_python<python_type>::convertible() const
{
return PyObject_IsInstance(m_src, (PyObject*)python_type);
}
template <class Wrapper, PyTypeObject* python_type>
pytype_wrapper_value_arg_from_python<Wrapper,python_type>::pytype_wrapper_value_arg_from_python(
PyObject* p)
: pytype_arg_from_python<python_type>(p)
{
}
template <class Wrapper, PyTypeObject* python_type>
Wrapper pytype_wrapper_value_arg_from_python<Wrapper,python_type>::operator()(
PyObject* x) const
{
return Wrapper(python::detail::borrowed_reference(x));
}
template <class Wrapper, PyTypeObject* python_type>
pytype_wrapper_ref_arg_from_python<Wrapper,python_type>::pytype_wrapper_ref_arg_from_python(
PyObject* p)
: pytype_arg_from_python<python_type>(p)
, m_result(python::detail::borrowed_reference(p))
{
}
template <class Wrapper, PyTypeObject* python_type>
Wrapper& pytype_wrapper_ref_arg_from_python<Wrapper,python_type>::operator()(
PyObject* x) const
{
return m_result;
}
}}} // namespace boost::python::converter
#endif // PYTYPE_ARG_FROM_PYTHON_DWA2002628_HPP

View File

@@ -1,43 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef PYTYPE_OBJECT_MANAGER_TRAITS_DWA2002716_HPP
# define PYTYPE_OBJECT_MANAGER_TRAITS_DWA2002716_HPP
# include <boost/python/detail/raw_pyobject.hpp>
# include <boost/python/cast.hpp>
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/converter/pyobject_type.hpp>
# include <boost/python/errors.hpp>
namespace boost { namespace python { namespace converter {
// Provide a forward declaration as a convenience for clients, who all
// need it.
template <class T> struct object_manager_traits;
// Derive specializations of object_manager_traits from this class
// when T is an object manager for a particular Python type hierarchy.
//
template <PyTypeObject* pytype, class T>
struct pytype_object_manager_traits
: pyobject_type<T, pytype> // provides check()
{
BOOST_STATIC_CONSTANT(bool, is_specialized = true);
static inline python::detail::new_reference adopt(PyObject*);
};
//
// implementations
//
template <PyTypeObject* pytype, class T>
inline python::detail::new_reference pytype_object_manager_traits<pytype,T>::adopt(PyObject* x)
{
return python::detail::new_reference(python::pytype_check(pytype, x));
}
}}} // namespace boost::python::converter
#endif // PYTYPE_OBJECT_MANAGER_TRAITS_DWA2002716_HPP

View File

@@ -1,54 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef REGISTERED_DWA2002710_HPP
# define REGISTERED_DWA2002710_HPP
# include <boost/python/type_id.hpp>
# include <boost/python/converter/registry.hpp>
# include <boost/python/converter/registrations.hpp>
# include <boost/type_traits/transform_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
namespace boost { namespace python { namespace converter {
struct registration;
namespace detail
{
template <class T>
struct registered_base
{
static registration const& converters;
};
}
template <class T>
struct registered
: detail::registered_base<
typename add_reference<
typename add_cv<T>::type
>::type
>
{
};
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// collapses a few more types to the same static instance
template <class T>
struct registered<T&> : registered<T> {};
# endif
//
// implementations
//
namespace detail
{
template <class T>
registration const& registered_base<T>::converters
= registry::lookup(type_id<T>());
}
}}} // namespace boost::python::converter
#endif // REGISTERED_DWA2002710_HPP

View File

@@ -1,63 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef REGISTERED_POINTEE_DWA2002710_HPP
# define REGISTERED_POINTEE_DWA2002710_HPP
# include <boost/python/converter/registered.hpp>
# include <boost/python/converter/pointer_type_id.hpp>
# include <boost/python/converter/registry.hpp>
# include <boost/type_traits/transform_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
namespace boost { namespace python { namespace converter {
struct registration;
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class T>
struct registered_pointee
: registered<
typename remove_pointer<
typename remove_cv<
typename remove_reference<T>::type
>::type
>::type
>
{
};
# else
namespace detail
{
template <class T>
struct registered_pointee_base
{
static registration const& converters;
};
}
template <class T>
struct registered_pointee
: detail::registered_pointee_base<
typename add_reference<
typename add_cv<T>::type
>::type
>
{
};
//
// implementations
//
namespace detail
{
template <class T>
registration const& registered_pointee_base<T>::converters
= registry::lookup(pointer_type_id<T>());
}
# endif
}}} // namespace boost::python::converter
#endif // REGISTERED_POINTEE_DWA2002710_HPP

View File

@@ -1,67 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef REGISTRATIONS_DWA2002223_HPP
# define REGISTRATIONS_DWA2002223_HPP
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/converter/convertible_function.hpp>
# include <boost/python/converter/constructor_function.hpp>
# include <boost/python/converter/to_python_function_type.hpp>
# include <boost/python/type_id.hpp>
namespace boost { namespace python { namespace converter {
struct lvalue_from_python_chain
{
convertible_function convert;
lvalue_from_python_chain* next;
};
struct rvalue_from_python_chain
{
convertible_function convertible;
constructor_function construct;
rvalue_from_python_chain* next;
};
struct registration
{
explicit registration(type_info);
const python::type_info target_type;
// The chain of eligible from_python converters when an lvalue is required
lvalue_from_python_chain* lvalue_chain;
// The chain of eligible from_python converters when an rvalue is acceptable
rvalue_from_python_chain* rvalue_chain;
// The unique to_python converter for the associated C++ type.
to_python_function_t to_python;
// The class object associated with this type
PyTypeObject* class_object;
};
//
// implementations
//
inline registration::registration(type_info target_type)
: target_type(target_type)
, lvalue_chain(0)
, rvalue_chain(0)
, to_python(0)
, class_object(0)
{}
inline bool operator<(registration const& lhs, registration const& rhs)
{
return lhs.target_type < rhs.target_type;
}
}}} // namespace boost::python::converter
#endif // REGISTRATIONS_DWA2002223_HPP

View File

@@ -1,52 +0,0 @@
// Copyright David Abrahams 2001. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef REGISTRY_DWA20011127_HPP
# define REGISTRY_DWA20011127_HPP
# include <boost/python/type_id.hpp>
# include <boost/python/detail/config.hpp>
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/converter/to_python_function_type.hpp>
# include <boost/python/converter/rvalue_from_python_data.hpp>
# include <boost/python/converter/constructor_function.hpp>
# include <boost/python/converter/convertible_function.hpp>
namespace boost { namespace python { namespace converter {
struct registration;
// This namespace acts as a sort of singleton
namespace registry
{
// Get the registration corresponding to the type, creating it if neccessary
BOOST_PYTHON_DECL registration const& lookup(type_info);
// Return a pointer to the corresponding registration, if one exists
BOOST_PYTHON_DECL registration const* query(type_info);
BOOST_PYTHON_DECL void insert(to_python_function_t, type_info);
// Insert an lvalue from_python converter
BOOST_PYTHON_DECL void insert(void* (*convert)(PyObject*), type_info);
// Insert an rvalue from_python converter
BOOST_PYTHON_DECL void insert(
convertible_function
, constructor_function
, type_info
);
// Insert an rvalue from_python converter at the tail of the
// chain. Used for implicit conversions
BOOST_PYTHON_DECL void push_back(
convertible_function
, constructor_function
, type_info
);
}
}}} // namespace boost::python::converter
#endif // REGISTRY_DWA20011127_HPP

View File

@@ -1,151 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef RETURN_FROM_PYTHON_DWA200265_HPP
# define RETURN_FROM_PYTHON_DWA200265_HPP
# include <boost/python/converter/from_python.hpp>
# include <boost/python/converter/rvalue_from_python_data.hpp>
# include <boost/python/converter/registered.hpp>
# include <boost/python/converter/registered_pointee.hpp>
# include <boost/python/detail/void_ptr.hpp>
# include <boost/call_traits.hpp>
# include <boost/python/detail/void_return.hpp>
namespace boost { namespace python { namespace converter {
template <class T> struct is_object_manager;
namespace detail
{
template <class T>
struct return_pointer_from_python
{
typedef T result_type;
T operator()(PyObject*) const;
};
template <class T>
struct return_reference_from_python
{
typedef T result_type;
T operator()(PyObject*) const;
};
template <class T>
struct return_rvalue_from_python
{
typedef typename call_traits<T>::param_type result_type;
return_rvalue_from_python();
result_type operator()(PyObject*);
private:
rvalue_from_python_data<T> m_data;
};
template <class T>
struct return_object_manager_from_python
{
typedef T result_type;
result_type operator()(PyObject*) const;
};
template <class T>
struct select_return_from_python
{
BOOST_STATIC_CONSTANT(
bool, obj_mgr = is_object_manager<T>::value);
BOOST_STATIC_CONSTANT(
bool, ptr = is_pointer<T>::value);
BOOST_STATIC_CONSTANT(
bool, ref = is_reference<T>::value);
typedef typename mpl::if_c<
obj_mgr
, return_object_manager_from_python<T>
, typename mpl::if_c<
ptr
, return_pointer_from_python<T>
, typename mpl::if_c<
ref
, return_reference_from_python<T>
, return_rvalue_from_python<T>
>::type
>::type
>::type type;
};
}
template <class T>
struct return_from_python
: detail::select_return_from_python<T>::type
{
};
// Specialization as a convenience for call and call_method
template <>
struct return_from_python<void>
{
typedef python::detail::returnable<void>::type result_type;
result_type operator()(PyObject* x) const
{
(void_result_from_python)(x);
# ifdef BOOST_NO_VOID_RETURNS
return result_type();
# endif
}
};
//
// Implementations
//
namespace detail
{
template <class T>
inline return_rvalue_from_python<T>::return_rvalue_from_python()
: m_data(
const_cast<registration*>(&registered<T>::converters)
)
{
}
template <class T>
inline typename return_rvalue_from_python<T>::result_type
return_rvalue_from_python<T>::operator()(PyObject* obj)
{
return *(T*)
(rvalue_result_from_python)(obj, m_data.stage1);
}
template <class T>
inline T return_reference_from_python<T>::operator()(PyObject* obj) const
{
return python::detail::void_ptr_to_reference(
(reference_result_from_python)(obj, registered<T>::converters)
, (T(*)())0);
}
template <class T>
inline T return_pointer_from_python<T>::operator()(PyObject* obj) const
{
return T(
(pointer_result_from_python)(obj, registered_pointee<T>::converters)
);
}
template <class T>
inline T return_object_manager_from_python<T>::operator()(PyObject* obj) const
{
return T(
object_manager_traits<T>::adopt(obj)
);
}
}
}}} // namespace boost::python::converter
#endif // RETURN_FROM_PYTHON_DWA200265_HPP

View File

@@ -1,39 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef RVALUE_FROM_PYTHON_CHAIN_DWA200237_HPP
# define RVALUE_FROM_PYTHON_CHAIN_DWA200237_HPP
# include <boost/python/converter/registry.hpp>
# include <boost/type_traits/transform_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
namespace boost { namespace python { namespace converter {
namespace detail
{
template <class T>
struct rvalue_from_python_chain_impl
{
static rvalue_from_python_registration*const& value;
};
template <class T>
rvalue_from_python_registration*const& rvalue_from_python_chain_impl<T>::value
= registry::rvalue_converters(undecorated_type_id<T>());
}
template <class T>
struct rvalue_from_python_chain
: detail::rvalue_from_python_chain_impl<
typename add_reference<
typename add_cv<T>::type
>::type
>
{
};
}}} // namespace boost::python::converter
#endif // RVALUE_FROM_PYTHON_CHAIN_DWA200237_HPP

View File

@@ -1,140 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef FROM_PYTHON_AUX_DATA_DWA2002128_HPP
# define FROM_PYTHON_AUX_DATA_DWA2002128_HPP
# include <boost/python/converter/constructor_function.hpp>
# include <boost/python/detail/referent_storage.hpp>
# include <boost/python/detail/destroy.hpp>
# include <boost/static_assert.hpp>
# include <boost/type_traits/add_reference.hpp>
# include <boost/type_traits/add_cv.hpp>
# include <cstddef>
// Data management for potential rvalue conversions from Python to C++
// types. When a client requests a conversion to T* or T&, we
// generally require that an object of type T exists in the source
// Python object, and the code here does not apply**. This implements
// conversions which may create new temporaries of type T. The classic
// example is a conversion which converts a Python tuple to a
// std::vector. Since no std::vector lvalue exists in the Python
// object -- it must be created "on-the-fly" by the converter, and
// which must manage the lifetime of the created object.
//
// Note that the client is not precluded from using a registered
// lvalue conversion to T in this case. In other words, we will
// happily accept a Python object which /does/ contain a std::vector
// lvalue, provided an appropriate converter is registered. So, while
// this is an rvalue conversion from the client's point-of-view, the
// converter registry may serve up lvalue or rvalue conversions for
// the target type.
//
// ** C++ argument from_python conversions to T const& are an
// exception to the rule for references: since in C++, const
// references can bind to temporary rvalues, we allow rvalue
// converters to be chosen when the target type is T const& for some
// T.
namespace boost { namespace python { namespace converter {
// Conversions begin by filling in and returning a copy of this
// structure. The process looks up a converter in the rvalue converter
// registry for the target type. It calls the convertible() function
// of each registered converter, passing the source PyObject* as an
// argument, until a non-null result is returned. This result goes in
// the convertible field, and the converter's construct() function is
// stored in the construct field.
//
// If no appropriate converter is found, conversion fails and the
// convertible field is null. When used in argument conversion for
// wrapped C++ functions, it causes overload resolution to reject the
// current function but not to fail completely. If an exception is
// thrown, overload resolution stops and the exception propagates back
// through the caller.
//
// If an lvalue converter is matched, its convertible() function is
// expected to return a pointer to the stored T object; its
// construct() function will be NULL. The convertible() function of
// rvalue converters may return any non-singular pointer; the actual
// target object will only be available once the converter's
// construct() function is called.
struct rvalue_from_python_stage1_data
{
void* convertible;
constructor_function construct;
};
// Augments rvalue_from_python_stage1_data by adding storage for
// constructing an object of remove_reference<T>::type. The
// construct() function of rvalue converters (stored in m_construct
// above) will cast the rvalue_from_python_stage1_data to an
// appropriate instantiation of this template in order to access that
// storage.
template <class T>
struct rvalue_from_python_storage
{
rvalue_from_python_stage1_data stage1;
// Storage for the result, in case an rvalue must be constructed
typename python::detail::referent_storage<
typename add_reference<T>::type
>::type storage;
};
// Augments rvalue_from_python_storage<T> with a destructor. If
// stage1.convertible == storage.bytes, it indicates that an object of
// remove_reference<T>::type has been constructed in storage and
// should will be destroyed in ~rvalue_from_python_data(). It is
// crucial that successful rvalue conversions establish this equality
// and that unsuccessful ones do not.
template <class T>
struct rvalue_from_python_data : rvalue_from_python_storage<T>
{
# if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) \
&& (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 245) \
&& (!defined(__DECCXX_VER) || __DECCXX_VER > 60590014)
// This must always be a POD struct with m_data its first member.
BOOST_STATIC_ASSERT(offsetof(rvalue_from_python_storage<T>,stage1) == 0);
# endif
// The usual constructor
rvalue_from_python_data(rvalue_from_python_stage1_data const&);
// This constructor just sets m_convertible -- used by
// implicitly_convertible<> to perform the final step of the
// conversion, where the construct() function is already known.
rvalue_from_python_data(void* convertible);
// Destroys any object constructed in the storage.
~rvalue_from_python_data();
private:
typedef typename add_reference<typename add_cv<T>::type>::type ref_type;
};
//
// Implementataions
//
template <class T>
inline rvalue_from_python_data<T>::rvalue_from_python_data(rvalue_from_python_stage1_data const& stage1)
{
this->stage1 = stage1;
}
template <class T>
inline rvalue_from_python_data<T>::rvalue_from_python_data(void* convertible)
{
this->stage1.convertible = convertible;
}
template <class T>
inline rvalue_from_python_data<T>::~rvalue_from_python_data()
{
if (this->stage1.convertible == this->storage.bytes)
python::detail::destroy_referent<ref_type>(this->storage.bytes);
}
}}} // namespace boost::python::converter
#endif // FROM_PYTHON_AUX_DATA_DWA2002128_HPP

View File

@@ -1,70 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef SMART_PTR_DWA2002123_HPP
# define SMART_PTR_DWA2002123_HPP
# include <boost/python/converter/class.hpp>
# include <boost/python/object/pointer_holder.hpp>
namespace boost { namespace python { namespace converter {
template <class Pointer, class Value>
class smart_ptr_wrapper
: wrapper<Pointer const&>
{
smart_ptr_wrapper(ref const& type_)
: m_class_object(type_)
{
assert(type_->ob_type == (PyTypeObject*)class_metatype().get());
}
PyObject* convert(Pointer x) const;
private:
ref m_class_object;
smart_ptr_converters();
}
//
// implementations
//
template <class Pointer, class Value>
PyObject* smart_ptr_wrapper<Pointer,Value>::convert(Pointer x) const
{
if (x.operator->() == 0)
return detail::none();
// Don't call the type to do the construction, since that
// would require the registration of an __init__ copy
// constructor. Instead, just construct the object in place.
PyObject* raw_result = (PyObject*)PyObject_New(
instance, (PyTypeObject*)m_class_object.get());
if (raw_result == 0)
return 0;
// Everything's OK; Bypass NULL checks but guard against
// exceptions.
ref result(raw_result, ref::allow_null());
// Build a value_holder to contain the object using the copy
// constructor
objects::pointer_holder<Pointer,Value>*
p = new objects::pointer_holder<Pointer,Value>(x);
// Install it in the instance
p->install(raw_result);
// Return the new result
return result.release();
}
}}} // namespace boost::python::converter
#endif // SMART_PTR_DWA2002123_HPP

View File

@@ -1,50 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef TO_PYTHON_FUNCTION_DWA2002128_HPP
# define TO_PYTHON_FUNCTION_DWA2002128_HPP
# include <boost/python/detail/wrap_python.hpp>
# include <boost/type_traits/transform_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/python/converter/type_id.hpp>
# include <boost/python/converter/registry.hpp>
# include <boost/python/converter/to_python_function_type.hpp>
namespace boost { namespace python { namespace converter {
// to_python_function --
//
// essentially a "templated global reference" which holds the
// converter for converting a type to Python by-value. We "normalize"
// T by adding "const volatile&" so that fewer global variables and
// associated static initializations are generated.
namespace detail
{
template <class T>
struct to_python_function_base
{
static to_python_function_t const& value;
};
template <class T>
to_python_function_t const&
to_python_function_base<T>::value
= converter::registry::get_to_python_function(undecorated_type_id<T>());
}
template <class T>
struct to_python_function
: detail::to_python_function_base<
typename add_reference<
typename add_cv<T>::type
>::type
>
{
};
}}} // namespace boost::python::converter
#endif // TO_PYTHON_FUNCTION_DWA2002128_HPP

View File

@@ -1,30 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef TO_PYTHON_FUNCTION_TYPE_DWA200236_HPP
# define TO_PYTHON_FUNCTION_TYPE_DWA200236_HPP
# include <boost/python/detail/wrap_python.hpp>
namespace boost { namespace python { namespace converter {
// The type of stored function pointers which actually do conversion
// by-value. The void* points to the object to be converted, and
// type-safety is preserved through runtime registration.
typedef PyObject* (*to_python_function_t)(void const*);
// Given a typesafe to_python conversion function, produces a
// to_python_function_t which can be registered in the usual way.
template <class T, class ToPython>
struct as_to_python_function
{
static PyObject* convert(void const* x)
{
return ToPython::convert(*(T const*)x);
}
};
}}} // namespace boost::python::converter
#endif // TO_PYTHON_FUNCTION_TYPE_DWA200236_HPP

View File

@@ -1,176 +0,0 @@
// Copyright David Abrahams 2001. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef TYPE_ID_DWA20011127_HPP
# define TYPE_ID_DWA20011127_HPP
# include <boost/python/detail/config.hpp>
# include <boost/python/detail/indirect_traits.hpp>
# include <boost/python/detail/msvc_typeinfo.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/type_traits/composite_traits.hpp>
# include <boost/mpl/select_if.hpp>
# include <boost/operators.hpp>
# include <boost/type.hpp>
# include <typeinfo>
# include <iosfwd>
# include <cstring>
namespace boost { namespace python { namespace converter {
// for this compiler at least, cross-shared-library type_info
// comparisons don't work, so use typeid(x).name() instead. It's not
// yet clear what the best default strategy is.
# if defined(__GNUC__) && __GNUC__ >= 3
# define BOOST_PYTHON_TYPE_ID_NAME
# endif
// type ids which represent the same information as std::type_info
// (i.e. the top-level reference and cv-qualifiers are stripped), but
// which works across shared libraries.
struct undecorated_type_id_t : totally_ordered<undecorated_type_id_t>
{
undecorated_type_id_t(std::type_info const&);
// default constructor needed to build arrays, etc.
undecorated_type_id_t();
bool operator<(undecorated_type_id_t const& rhs) const;
bool operator==(undecorated_type_id_t const& rhs) const;
char const* name() const;
friend BOOST_PYTHON_DECL std::ostream& operator<<(
std::ostream&, undecorated_type_id_t const&);
private: // data members
# ifdef BOOST_PYTHON_TYPE_ID_NAME
typedef char const* base_id_t;
# else
typedef std::type_info const* base_id_t;
# endif
base_id_t m_base_type;
};
struct type_id_t : totally_ordered<type_id_t>
{
enum decoration { const_ = 0x1, volatile_ = 0x2, reference = 0x4 };
type_id_t(undecorated_type_id_t, decoration = decoration());
bool operator<(type_id_t const& rhs) const;
bool operator==(type_id_t const& rhs) const;
friend BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream&, type_id_t const&);
operator undecorated_type_id_t const&() const;
private: // type
typedef undecorated_type_id_t base_id_t;
private: // data members
decoration m_decoration;
base_id_t m_base_type;
};
template <class T>
inline undecorated_type_id_t undecorated_type_id(boost::type<T>* = 0)
{
return undecorated_type_id_t(
# if (!defined(BOOST_MSVC) || BOOST_MSVC > 1300) && (!defined(BOOST_INTEL_CXX_VERSION) || BOOST_INTEL_CXX_VERSION > 600)
typeid(T)
# else // strip the decoration which msvc and Intel mistakenly leave in
python::detail::msvc_typeid<T>()
# endif
);
}
template <class T>
inline type_id_t type_id(boost::type<T>* = 0)
{
return type_id_t(
undecorated_type_id<T>()
, type_id_t::decoration(
(is_const<T>::value || python::detail::is_reference_to_const<T>::value
? type_id_t::const_ : 0)
| (is_volatile<T>::value || python::detail::is_reference_to_volatile<T>::value
? type_id_t::volatile_ : 0)
| (is_reference<T>::value ? type_id_t::reference : 0)
)
);
}
inline undecorated_type_id_t::undecorated_type_id_t(std::type_info const& id)
: m_base_type(
# ifdef BOOST_PYTHON_TYPE_ID_NAME
id.name()
# else
&id
# endif
)
{
}
inline undecorated_type_id_t::undecorated_type_id_t()
: m_base_type()
{
}
inline type_id_t::type_id_t(undecorated_type_id_t base_t, decoration decoration)
: m_decoration(decoration)
, m_base_type(base_t)
{
}
inline bool undecorated_type_id_t::operator<(undecorated_type_id_t const& rhs) const
{
# ifdef BOOST_PYTHON_TYPE_ID_NAME
return std::strcmp(m_base_type, rhs.m_base_type) < 0;
# else
return m_base_type->before(*rhs.m_base_type);
# endif
}
inline bool type_id_t::operator<(type_id_t const& rhs) const
{
return m_decoration < rhs.m_decoration
|| m_decoration == rhs.m_decoration
&& m_base_type < rhs.m_base_type;
}
inline bool undecorated_type_id_t::operator==(undecorated_type_id_t const& rhs) const
{
# ifdef BOOST_PYTHON_TYPE_ID_NAME
return !std::strcmp(m_base_type, rhs.m_base_type);
# else
return *m_base_type == *rhs.m_base_type;
# endif
}
inline bool type_id_t::operator==(type_id_t const& rhs) const
{
return m_decoration == rhs.m_decoration && m_base_type == rhs.m_base_type;
}
inline type_id_t::operator undecorated_type_id_t const&() const
{
return m_base_type;
}
inline char const* undecorated_type_id_t::name() const
{
# ifdef BOOST_PYTHON_TYPE_ID_NAME
return m_base_type;
# else
return m_base_type->name();
# endif
}
BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream&, undecorated_type_id_t const&);
BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream&, type_id_t const&);
}}} // namespace boost::python::converter
#endif // TYPE_ID_DWA20011127_HPP

View File

@@ -1,42 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef COPY_CONST_REFERENCE_DWA2002131_HPP
# define COPY_CONST_REFERENCE_DWA2002131_HPP
# include <boost/python/detail/indirect_traits.hpp>
# include <boost/mpl/if.hpp>
# include <boost/python/to_python_value.hpp>
namespace boost { namespace python {
namespace detail
{
template <class R>
struct copy_const_reference_expects_a_const_reference_return_type
# if defined(__GNUC__) && __GNUC__ >= 3 || defined(__EDG__)
{}
# endif
;
}
template <class T> struct to_python_value;
struct copy_const_reference
{
template <class T>
struct apply
{
typedef typename mpl::if_c<
detail::is_reference_to_const<T>::value
, to_python_value<T>
, detail::copy_const_reference_expects_a_const_reference_return_type<T>
>::type type;
};
};
}} // namespace boost::python
#endif // COPY_CONST_REFERENCE_DWA2002131_HPP

View File

@@ -1,41 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef COPY_MUTABLE_REFERENCE_DWA2002131_HPP
# define COPY_MUTABLE_REFERENCE_DWA2002131_HPP
# include <boost/python/detail/indirect_traits.hpp>
# include <boost/mpl/select_if.hpp>
# include <boost/python/to_python_value.hpp>
namespace boost { namespace python {
namespace detail
{
template <class R>
struct copy_mutable_reference_expects_a_reference_to_non_const_return_type
# if defined(__GNUC__) && __GNUC__ >= 3 || defined(__EDG__)
{}
# endif
;
}
template <class T> struct to_python_value;
struct copy_mutable_reference
{
template <class T>
struct apply
{
typedef typename mpl::select_if_c<
detail::is_reference_to_non_const<T>::value
, to_python_value<T>
, detail::copy_mutable_reference_expects_a_reference_to_non_const_return_type<T>
>::type type;
};
};
}} // namespace boost::python
#endif // COPY_MUTABLE_REFERENCE_DWA2002131_HPP

View File

@@ -1,42 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef COPY_NON_CONST_REFERENCE_DWA2002131_HPP
# define COPY_NON_CONST_REFERENCE_DWA2002131_HPP
# include <boost/python/detail/indirect_traits.hpp>
# include <boost/mpl/if.hpp>
# include <boost/python/to_python_value.hpp>
namespace boost { namespace python {
namespace detail
{
template <class R>
struct copy_non_const_reference_expects_a_non_const_reference_return_type
# if defined(__GNUC__) && __GNUC__ >= 3 || defined(__EDG__)
{}
# endif
;
}
template <class T> struct to_python_value;
struct copy_non_const_reference
{
template <class T>
struct apply
{
typedef typename mpl::if_c<
boost::python::detail::is_reference_to_non_const<T>::value
, to_python_value<T>
, detail::copy_non_const_reference_expects_a_non_const_reference_return_type<T>
>::type type;
};
};
}} // namespace boost::python
#endif // COPY_NON_CONST_REFERENCE_DWA2002131_HPP

View File

@@ -1,329 +0,0 @@
/* (C) Copyright Ralf W. Grosse-Kunstleve 2001. Permission to copy, use,
modify, sell and distribute this software is granted provided this
copyright notice appears in all copies. This software is provided
"as is" without express or implied warranty, and with no claim as to
its suitability for any purpose.
Revision History:
17 Apr 01 merged into boost CVS trunk (Ralf W. Grosse-Kunstleve)
*/
/* Implementation of Boost.Python cross-module support.
See root/libs/python/doc/cross_module.html for details.
*/
#ifndef CROSS_MODULE_HPP
# define CROSS_MODULE_HPP
# include <boost/python/class_builder.hpp>
namespace boost { namespace python {
struct BOOST_PYTHON_DECL import_error: error_already_set {};
struct BOOST_PYTHON_DECL export_error : error_already_set {};
void BOOST_PYTHON_DECL throw_import_error();
void BOOST_PYTHON_DECL throw_export_error();
namespace detail
{
// Concept: throw exception if api_major is changed
// show warning on stderr if api_minor is changed
const int export_converters_api_major = 4;
const int export_converters_api_minor = 1;
extern BOOST_PYTHON_DECL const char* converters_attribute_name;
BOOST_PYTHON_DECL void* import_converter_object(const std::string& module_name,
const std::string& py_class_name,
const std::string& attribute_name);
BOOST_PYTHON_DECL void check_export_converters_api(const int importing_major,
const int importing_minor,
const int imported_major,
const int imported_minor);
}
}} // namespace boost::python
// forward declaration
namespace boost { namespace python { namespace detail {
template <class T> class import_extension_class;
}}}
BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE
/* This class template is instantiated by import_converters<T>.
This class is a look-alike of class python_extension_class_converters.
The converters in this class are wrappers that call converters
imported from another module.
To ensure that the dynamic loader resolves all symbols in the
intended way, the signature of all friend functions is changed with
respect to the original functions in class
python_extension_class_converters by adding an arbitrary additional
parameter with a default value, in this case "bool sig = false".
See also: comments for class export_converter_object_base below.
*/
template <class T>
class python_import_extension_class_converters
{
public:
friend python_import_extension_class_converters py_extension_class_converters(boost::python::type<T>, bool sig = false) {
return python_import_extension_class_converters();
}
PyObject* to_python(const T& x) const {
return boost::python::detail::import_extension_class<T>::get_converters()->to_python(x);
}
friend T* from_python(PyObject* p, boost::python::type<T*> t, bool sig = false) {
return boost::python::detail::import_extension_class<T>::get_converters()->from_python_Ts(p, t);
}
friend const T* from_python(PyObject* p, boost::python::type<const T*> t, bool sig = false) {
return boost::python::detail::import_extension_class<T>::get_converters()->from_python_cTs(p, t);
}
friend const T* from_python(PyObject* p, boost::python::type<const T*const&> t, bool sig = false) {
return boost::python::detail::import_extension_class<T>::get_converters()->from_python_cTscr(p, t);
}
friend T* from_python(PyObject* p, boost::python::type<T* const&> t, bool sig = false) {
return boost::python::detail::import_extension_class<T>::get_converters()->from_python_Tscr(p, t);
}
friend T& from_python(PyObject* p, boost::python::type<T&> t, bool sig = false) {
return boost::python::detail::import_extension_class<T>::get_converters()->from_python_Tr(p, t);
}
friend const T& from_python(PyObject* p, boost::python::type<const T&> t, bool sig = false) {
return boost::python::detail::import_extension_class<T>::get_converters()->from_python_cTr(p, t);
}
friend const T& from_python(PyObject* p, boost::python::type<T> t, bool sig = false) {
return boost::python::detail::import_extension_class<T>::get_converters()->from_python_T(p, t);
}
friend std::auto_ptr<T>& from_python(PyObject* p, boost::python::type<std::auto_ptr<T>&> t, bool sig = false) {
return boost::python::detail::import_extension_class<T>::get_converters()->from_python_aTr(p, t);
}
friend std::auto_ptr<T> from_python(PyObject* p, boost::python::type<std::auto_ptr<T> > t, bool sig = false) {
return boost::python::detail::import_extension_class<T>::get_converters()->from_python_aT(p, t);
}
friend const std::auto_ptr<T>& from_python(PyObject* p, boost::python::type<const std::auto_ptr<T>&> t, bool sig = false) {
return boost::python::detail::import_extension_class<T>::get_converters()->from_python_caTr(p, t);
}
friend PyObject* to_python(std::auto_ptr<T> x, bool sig = false) {
return boost::python::detail::import_extension_class<T>::get_converters()->to_python(x);
}
friend boost::shared_ptr<T>& from_python(PyObject* p, boost::python::type<boost::shared_ptr<T>&> t, bool sig = false) {
return boost::python::detail::import_extension_class<T>::get_converters()->from_python_sTr(p, t);
}
friend const boost::shared_ptr<T>& from_python(PyObject* p, boost::python::type<boost::shared_ptr<T> > t, bool sig = false) {
return boost::python::detail::import_extension_class<T>::get_converters()->from_python_sT(p, t);
}
friend const boost::shared_ptr<T>& from_python(PyObject* p, boost::python::type<const boost::shared_ptr<T>&> t, bool sig = false) {
return boost::python::detail::import_extension_class<T>::get_converters()->from_python_csTr(p, t);
}
friend PyObject* to_python(boost::shared_ptr<T> x, bool sig = false) {
return boost::python::detail::import_extension_class<T>::get_converters()->to_python(x);
}
};
BOOST_PYTHON_END_CONVERSION_NAMESPACE
namespace boost { namespace python {
BOOST_PYTHON_IMPORT_CONVERSION(python_import_extension_class_converters);
/* This class template is instantiated by export_converters().
A pointer to this class is exported/imported via the Python API.
Using the Python API ensures maximum portability.
All member functions are virtual. This is, what we export/import
is essentially just a pointer to a vtbl.
To work around a deficiency of Visual C++ 6.0, the name of each
from_python() member functions is made unique by appending a few
characters (derived in a ad-hoc manner from the corresponding type).
*/
template <class T>
struct export_converter_object_base
{
virtual int get_api_major() const { return detail::export_converters_api_major; }
virtual int get_api_minor() const { return detail::export_converters_api_minor; }
virtual PyObject* to_python(const T& x) = 0;
virtual T* from_python_Ts(PyObject* p, boost::python::type<T*> t) = 0;
virtual const T* from_python_cTs(PyObject* p, boost::python::type<const T*> t) = 0;
virtual const T* from_python_cTscr(PyObject* p, boost::python::type<const T*const&> t) = 0;
virtual T* from_python_Tscr(PyObject* p, boost::python::type<T* const&> t) = 0;
virtual T& from_python_Tr(PyObject* p, boost::python::type<T&> t) = 0;
virtual const T& from_python_cTr(PyObject* p, boost::python::type<const T&> t) = 0;
virtual const T& from_python_T(PyObject* p, boost::python::type<T> t) = 0;
virtual std::auto_ptr<T>& from_python_aTr(PyObject* p, boost::python::type<std::auto_ptr<T>&> t) = 0;
virtual std::auto_ptr<T> from_python_aT(PyObject* p, boost::python::type<std::auto_ptr<T> > t) = 0;
virtual const std::auto_ptr<T>& from_python_caTr(PyObject* p, boost::python::type<const std::auto_ptr<T>&> t) = 0;
virtual PyObject* to_python(std::auto_ptr<T> x) = 0;
virtual boost::shared_ptr<T>& from_python_sTr(PyObject* p, boost::python::type<boost::shared_ptr<T>&> t) = 0;
virtual const boost::shared_ptr<T>& from_python_sT(PyObject* p, boost::python::type<boost::shared_ptr<T> > t) = 0;
virtual const boost::shared_ptr<T>& from_python_csTr(PyObject* p, boost::python::type<const boost::shared_ptr<T>&> t) = 0;
virtual PyObject* to_python(boost::shared_ptr<T> x) = 0;
};
// Converters to be used if T is not copyable.
template <class T>
struct export_converter_object_noncopyable : export_converter_object_base<T>
{
virtual PyObject* to_python(const T& x) {
PyErr_SetString(PyExc_RuntimeError,
"to_python(const T&) converter not exported");
throw_import_error();
return 0;
}
virtual T* from_python_Ts(PyObject* p, boost::python::type<T*> t) {
return BOOST_PYTHON_CONVERSION::from_python(p, t);
}
virtual const T* from_python_cTs(PyObject* p, boost::python::type<const T*> t) {
return BOOST_PYTHON_CONVERSION::from_python(p, t);
}
virtual const T* from_python_cTscr(PyObject* p, boost::python::type<const T*const&> t) {
return BOOST_PYTHON_CONVERSION::from_python(p, t);
}
virtual T* from_python_Tscr(PyObject* p, boost::python::type<T* const&> t) {
return BOOST_PYTHON_CONVERSION::from_python(p, t);
}
virtual T& from_python_Tr(PyObject* p, boost::python::type<T&> t) {
return BOOST_PYTHON_CONVERSION::from_python(p, t);
}
virtual const T& from_python_cTr(PyObject* p, boost::python::type<const T&> t) {
return BOOST_PYTHON_CONVERSION::from_python(p, t);
}
virtual const T& from_python_T(PyObject* p, boost::python::type<T> t) {
return BOOST_PYTHON_CONVERSION::from_python(p, t);
}
virtual std::auto_ptr<T>& from_python_aTr(PyObject* p, boost::python::type<std::auto_ptr<T>&> t) {
return BOOST_PYTHON_CONVERSION::from_python(p, t);
}
virtual std::auto_ptr<T> from_python_aT(PyObject* p, boost::python::type<std::auto_ptr<T> > t) {
return BOOST_PYTHON_CONVERSION::from_python(p, t);
}
virtual const std::auto_ptr<T>& from_python_caTr(PyObject* p, boost::python::type<const std::auto_ptr<T>&> t) {
return BOOST_PYTHON_CONVERSION::from_python(p, t);
}
virtual PyObject* to_python(std::auto_ptr<T> x) {
return BOOST_PYTHON_CONVERSION::to_python(x);
}
virtual boost::shared_ptr<T>& from_python_sTr(PyObject* p, boost::python::type<boost::shared_ptr<T>&> t) {
return BOOST_PYTHON_CONVERSION::from_python(p, t);
}
virtual const boost::shared_ptr<T>& from_python_sT(PyObject* p, boost::python::type<boost::shared_ptr<T> > t) {
return BOOST_PYTHON_CONVERSION::from_python(p, t);
}
virtual const boost::shared_ptr<T>& from_python_csTr(PyObject* p, boost::python::type<const boost::shared_ptr<T>&> t) {
return BOOST_PYTHON_CONVERSION::from_python(p, t);
}
virtual PyObject* to_python(boost::shared_ptr<T> x) {
return BOOST_PYTHON_CONVERSION::to_python(x);
}
};
// The addditional to_python() converter that can be used if T is copyable.
template <class T>
struct export_converter_object : export_converter_object_noncopyable<T>
{
virtual PyObject* to_python(const T& x) {
return BOOST_PYTHON_CONVERSION::py_extension_class_converters(boost::python::type<T>()).to_python(x);
}
};
namespace detail
{
/* This class template is instantiated by import_converters<T>.
Its purpose is to import the converter_object via the Python API.
The actual import is only done once. The pointer to the
imported converter object is kept in the static data member
imported_converters.
*/
template <class T>
class import_extension_class
: public python_import_extension_class_converters<T>
{
public:
inline import_extension_class(const char* module, const char* py_class) {
m_module = module;
m_py_class = py_class;
}
static boost::python::export_converter_object_base<T>* get_converters();
private:
static std::string m_module;
static std::string m_py_class;
static boost::python::export_converter_object_base<T>* imported_converters;
};
template <class T> std::string import_extension_class<T>::m_module;
template <class T> std::string import_extension_class<T>::m_py_class;
template <class T>
boost::python::export_converter_object_base<T>*
import_extension_class<T>::imported_converters = 0;
template <class T>
boost::python::export_converter_object_base<T>*
import_extension_class<T>::get_converters() {
if (imported_converters == 0) {
void* cobject
= import_converter_object(m_module, m_py_class,
converters_attribute_name);
imported_converters
= static_cast<boost::python::export_converter_object_base<T>*>(cobject);
check_export_converters_api(
export_converters_api_major,
export_converters_api_minor,
imported_converters->get_api_major(),
imported_converters->get_api_minor());
}
return imported_converters;
}
}}} // namespace boost::python::detail
namespace boost { namespace python {
// Implementation of export_converters().
template <class T, class U>
void export_converters(class_builder<T, U>& cb)
{
static export_converter_object<T> export_cvts;
cb.add(
ref(PyCObject_FromVoidPtr(reinterpret_cast<void*>(&export_cvts), NULL)),
detail::converters_attribute_name);
}
// Implementation of export_converters_noncopyable().
template <class T, class U>
void export_converters_noncopyable(class_builder<T, U>& cb)
{
static export_converter_object_noncopyable<T> export_cvts;
cb.add(
ref(PyCObject_FromVoidPtr(reinterpret_cast<void*>(&export_cvts), NULL)),
detail::converters_attribute_name);
}
// Implementation of import_converters<T>.
template <class T>
class import_converters
: python_import_extension_class_converters<T> // Works around MSVC6.x/GCC2.95.2 bug described
// at the bottom of class_builder.hpp.
{
public:
import_converters(const char* module, const char* py_class)
: m_class(new detail::import_extension_class<T>(module, py_class))
{ }
private:
boost::shared_ptr<detail::import_extension_class<T> > m_class;
};
}} // namespace boost::python
#endif // CROSS_MODULE_HPP

View File

@@ -1,111 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef DATA_MEMBERS_DWA2002328_HPP
# define DATA_MEMBERS_DWA2002328_HPP
# include <boost/python/detail/config.hpp>
# include <boost/python/detail/wrap_python.hpp>
# include <boost/type_traits/transform_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/python/return_value_policy.hpp>
# include <boost/python/copy_non_const_reference.hpp>
# include <boost/python/object/function_object.hpp>
# include <boost/python/arg_from_python.hpp>
# include <boost/bind.hpp>
namespace boost { namespace python {
namespace detail
{
template <class Data, class Class, class Policies>
struct member
{
static PyObject* get(Data Class::*pm, PyObject* args_, PyObject*, Policies const& policies)
{
arg_from_python<Class*> c0(PyTuple_GET_ITEM(args_, 0));
if (!c0.convertible()) return 0;
// find the result converter
typedef typename Policies::result_converter result_converter;
typedef typename boost::add_reference<Data>::type source;
typename mpl::apply1<result_converter,source>::type cr;
if (!cr.convertible()) return 0;
if (!policies.precall(args_)) return 0;
PyObject* result = cr( (c0(PyTuple_GET_ITEM(args_, 0)))->*pm );
return policies.postcall(args_, result);
}
static PyObject* set(Data Class::*pm, PyObject* args_, PyObject*, Policies const& policies)
{
// check that each of the arguments is convertible
arg_from_python<Class*> c0(PyTuple_GET_ITEM(args_, 0));
if (!c0.convertible()) return 0;
typedef typename add_const<Data>::type target1;
typedef typename add_reference<target1>::type target;
arg_from_python<target> c1(PyTuple_GET_ITEM(args_, 1));
if (!c1.convertible()) return 0;
if (!policies.precall(args_)) return 0;
(c0(PyTuple_GET_ITEM(args_, 0)))->*pm = c1(PyTuple_GET_ITEM(args_, 1));
return policies.postcall(args_, detail::none());
}
};
}
template <class C, class D>
object make_getter(D C::*pm)
{
typedef return_value_policy<copy_non_const_reference> default_policy;
return objects::function_object(
::boost::bind(
&detail::member<D,C,default_policy>::get, pm, _1, _2
, default_policy())
, 1);
}
template <class C, class D, class Policies>
object make_getter(D C::*pm, Policies const& policies)
{
return objects::function_object(
::boost::bind(
&detail::member<D,C,Policies>::get, pm, _1, _2
, policies)
, 1);
}
template <class C, class D>
object make_setter(D C::*pm)
{
return objects::function_object(
::boost::bind(
&detail::member<D,C,default_call_policies>::set, pm, _1, _2
, default_call_policies())
, 2);
}
template <class C, class D, class Policies>
object make_setter(D C::*pm, Policies const& policies)
{
return objects::function_object(
::boost::bind(
&detail::member<D,C,Policies>::set, pm, _1, _2
, policies)
, 2);
}
}} // namespace boost::python
#endif // DATA_MEMBERS_DWA2002328_HPP

View File

@@ -1,94 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef DEF_DWA200292_HPP
# define DEF_DWA200292_HPP
# include <boost/python/object_fwd.hpp>
# include <boost/python/make_function.hpp>
# include <boost/python/detail/def_helper.hpp>
# include <boost/python/detail/defaults_def.hpp>
# include <boost/python/scope.hpp>
# include <boost/python/signature.hpp>
namespace boost { namespace python {
namespace detail
{
void BOOST_PYTHON_DECL scope_setattr_doc(char const* name, object const& obj, char const* doc);
template <class Fn, class CallPolicyOrDoc>
void
dispatch_def(
void const*,
char const* name,
Fn fn,
CallPolicyOrDoc const& policy_or_doc,
char const* doc = 0)
{
typedef detail::def_helper<CallPolicyOrDoc> helper;
detail::scope_setattr_doc(
name, boost::python::make_function(fn, helper::get_policy(policy_or_doc)),
helper::get_doc(policy_or_doc, doc));
}
template <class StubsT, class SigT>
void dispatch_def(
detail::func_stubs_base const*,
char const* name,
SigT sig,
StubsT const& stubs)
{
// convert sig to a type_list (see detail::get_signature in signature.hpp)
// before calling detail::define_with_defaults.
scope current;
detail::define_with_defaults(
name, stubs, current, detail::get_signature(sig));
}
}
template <class Fn>
void def(char const* name, Fn fn)
{
detail::scope_setattr_doc(name, boost::python::make_function(fn), 0);
}
template <class Arg1T, class Arg2T>
void def(char const* name, Arg1T arg1, Arg2T const& arg2)
{
// The arguments may be:
// def(name, function)
// def(name, function, policy)
// def(name, function, doc_string)
// def(name, signature, stubs)
detail::dispatch_def(&arg2, name, arg1, arg2);
}
template <class Arg1T, class Arg2T, class Arg3T>
void def(char const* name, Arg1T arg1, Arg2T const& arg2, Arg3T const& arg3)
{
// The arguments are definitely:
// def(name, function, policy, doc_string) // TODO: exchange policy, doc_string position
detail::dispatch_def(&arg2, name, arg1, arg2, arg3);
}
//template <class Arg1T, class Arg2T, class Arg3T>
//void def(char const* name, Arg1T arg1, Arg2T const& arg2, Arg3T const& arg3, char const* doc)
//{
// // The arguments are definitely:
// // arg1: signature
// // arg2: stubs
// // arg3: policy
//
// detail::dispatch_def(&arg2, name, arg1, arg2, arg3, doc);
//}
}} // namespace boost::python
#endif // DEF_DWA200292_HPP

View File

@@ -1,78 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef DEFAULT_CALL_POLICIES_DWA2002131_HPP
# define DEFAULT_CALL_POLICIES_DWA2002131_HPP
# include <boost/python/detail/wrap_python.hpp>
# include <boost/mpl/if.hpp>
# include <boost/python/to_python_value.hpp>
# include <boost/type_traits/transform_traits.hpp>
namespace boost { namespace python {
template <class T> struct to_python_value;
namespace detail
{
// for "readable" error messages
template <class T> struct specify_a_result_policy_to_wrap_functions_returning
# if defined(__GNUC__) && __GNUC__ >= 3 || defined(__EDG__)
{}
# endif
;
}
struct default_result_converter;
struct default_call_policies
{
// Nothing to do
static bool precall(PyObject*)
{
return true;
}
// Pass the result through
static PyObject* postcall(PyObject*, PyObject* result)
{
return result;
}
typedef default_result_converter result_converter;
};
struct default_result_converter
{
template <class R>
struct apply
{
BOOST_STATIC_CONSTANT(bool, is_illegal = is_reference<R>::value || is_pointer<R>::value);
typedef typename mpl::if_c<
is_illegal
, detail::specify_a_result_policy_to_wrap_functions_returning<R>
, boost::python::to_python_value<
typename add_reference<typename add_const<R>::type>::type
>
>::type type;
};
};
// Exceptions for c strings an PyObject*s
template <>
struct default_result_converter::apply<char const*>
{
typedef boost::python::to_python_value<char const*const&> type;
};
template <>
struct default_result_converter::apply<PyObject*>
{
typedef boost::python::to_python_value<PyObject*const&> type;
};
}} // namespace boost::python
#endif // DEFAULT_CALL_POLICIES_DWA2002131_HPP

View File

@@ -1,24 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef AIX_INIT_MODULE_DWA2002529_HPP
# define AIX_INIT_MODULE_DWA2002529_HPP
# ifdef _AIX
# include <boost/python/detail/wrap_python.hpp>
# include <cstdio>
namespace boost { namespace python { namespace detail {
extern "C"
{
typedef PyObject* (*so_load_function)(char*,char*,FILE*);
}
void aix_init_module(so_load_function, char const* name, void (*init_module)());
}}} // namespace boost::python::detail
# endif
#endif // AIX_INIT_MODULE_DWA2002529_HPP

View File

@@ -1,14 +0,0 @@
#ifndef BOOST_PYTHON_API_PLACE_HOLDER_HPP
#define BOOST_PYTHON_API_PLACE_HOLDER_HPP
namespace boost { namespace python {
inline long len(object const& obj)
{
long result = PyObject_Length(obj.ptr());
if (PyErr_Occurred()) throw_error_already_set();
return result;
}
}} // namespace boost::python
#endif // BOOST_PYTHON_API_PLACE_HOLDER_HPP

View File

@@ -1,127 +0,0 @@
#if !defined(BOOST_PP_IS_ITERATING)
// (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// This work was funded in part by Lawrence Berkeley National Labs
//
// This file generated for 5-argument member functions and 6-argument free
// functions by gen_arg_tuple_size.python
#ifndef ARG_TUPLE_SIZE_DWA20011201_HPP
# define ARG_TUPLE_SIZE_DWA20011201_HPP
# include <boost/config.hpp>
# include <boost/python/detail/char_array.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/preprocessor/debug/line.hpp>
namespace boost { namespace python { namespace detail {
// Computes (at compile-time) the number of elements that a Python
// argument tuple must have in order to be passed to a wrapped C++
// (member) function of the given type.
template <class F> struct arg_tuple_size;
// We will use the "sizeof() trick" to work around the lack of
// partial specialization in MSVC6 and its broken-ness in borland.
// See http://opensource.adobe.com or
// http://groups.yahoo.com/group/boost/message/5441 for
// more examples
// The following helper functions are never actually called, since
// they are only used within a sizeof() expression, but the type of
// their return value is used to discriminate between various free
// and member function pointers at compile-time.
// Specializations for function pointers
# define BOOST_PP_ITERATION_PARAMS_1 \
(4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/arg_tuple_size.hpp>, BOOST_PYTHON_FUNCTION_POINTER))
# include BOOST_PP_ITERATE()
// Specializations for member function pointers
# define BOOST_PP_ITERATION_PARAMS_1 \
(4, (0, BOOST_PYTHON_CV_COUNT - 1, <boost/python/detail/arg_tuple_size.hpp>, BOOST_PYTHON_POINTER_TO_MEMBER))
# include BOOST_PP_ITERATE()
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template <class F>
struct arg_tuple_size
{
// The sizeof() magic happens here
BOOST_STATIC_CONSTANT(std::size_t, value
= sizeof(arg_tuple_size_helper(F(0)).elements) - 1);
};
# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
}}} // namespace boost::python::detail
#endif // ARG_TUPLE_SIZE_DWA20011201_HPP
// --------------- function pointers --------------- //
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_FUNCTION_POINTER
# line BOOST_PP_LINE(__LINE__, arg_tuple_size.hpp(function pointers))
# define N BOOST_PP_ITERATION()
# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template <class R BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
struct arg_tuple_size<R (*)(BOOST_PYTHON_UNARY_ENUM(N, A))>
{
BOOST_STATIC_CONSTANT(std::size_t, value = N);
};
# else
template<class R BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
char_array<N> arg_tuple_size_helper(
R (*)(BOOST_PYTHON_UNARY_ENUM(N, A)));
# endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
# undef N
// --------------- pointers-to-members --------------- //
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_POINTER_TO_MEMBER
// Outer iteration over cv-qualifications
# define BOOST_PP_ITERATION_PARAMS_2 \
(3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/arg_tuple_size.hpp>))
# include BOOST_PP_ITERATE()
#elif BOOST_PP_ITERATION_DEPTH() == 2 && BOOST_PP_RELATIVE_FLAGS(1) == BOOST_PYTHON_POINTER_TO_MEMBER
# line BOOST_PP_LINE(__LINE__, arg_tuple_size.hpp(pointers-to-members))
// Inner iteration over arities
# define N BOOST_PP_ITERATION()
# define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template <class R, class T BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
struct arg_tuple_size<R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q>
{
BOOST_STATIC_CONSTANT(std::size_t, value = N + 1U);
};
# else
template <class R, class T BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
char_array<N + 1> arg_tuple_size_helper(
R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q);
# endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
# undef Q
# undef N
#endif // !defined(BOOST_PP_IS_ITERATING)

View File

@@ -1,60 +0,0 @@
// (C) Copyright David Abrahams 2000. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// The author gratefully acknowleges the support of Dragon Systems, Inc., in
// producing this work.
//
// Revision History:
// Mar 01 01 Use PyObject_INIT() instead of trying to hand-initialize (David Abrahams)
#ifndef BASE_OBJECT_DWA051600_H_
# define BASE_OBJECT_DWA051600_H_
# include <boost/python/detail/config.hpp>
# include <boost/python/detail/wrap_python.hpp>
# include <cstring>
namespace boost { namespace python { namespace detail {
// base_object - adds a constructor and non-virtual destructor to a
// base Python type (e.g. PyObject, PyTypeObject).
template <class PythonType>
struct base_object : PythonType
{
typedef PythonType base_python_type;
// Initializes type and reference count. All other fields of base_python_type are 0
base_object(PyTypeObject* type_obj);
// Decrements reference count on the type
~base_object();
};
// Easy typedefs for common usage
typedef base_object<PyObject> python_object;
typedef base_object<PyTypeObject> python_type;
//
// base_object member function implementations
//
template <class PythonType>
base_object<PythonType>::base_object(PyTypeObject* type_obj)
{
base_python_type* bp = this;
BOOST_CSTD_::memset(bp, 0, sizeof(base_python_type));
Py_INCREF(type_obj);
PyObject_INIT(bp, type_obj);
}
template <class PythonType>
inline base_object<PythonType>::~base_object()
{
Py_DECREF(ob_type);
}
}}} // namespace boost::python::detail
#endif // BASE_OBJECT_DWA051600_H_

View File

@@ -1,112 +0,0 @@
#ifndef BORROWED_PTR_DWA20020601_HPP
# define BORROWED_PTR_DWA20020601_HPP
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
# include <boost/config.hpp>
# include <boost/type.hpp>
# include <boost/mpl/if.hpp>
# include <boost/type_traits/object_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/python/tag.hpp>
namespace boost { namespace python { namespace detail {
template<class T> class borrowed
{
typedef T type;
};
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template<typename T>
struct is_borrowed_ptr
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
# if !defined(__MWERKS__) || __MWERKS__ > 0x3000
template<typename T>
struct is_borrowed_ptr<borrowed<T>*>
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
template<typename T>
struct is_borrowed_ptr<borrowed<T> const*>
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
template<typename T>
struct is_borrowed_ptr<borrowed<T> volatile*>
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
template<typename T>
struct is_borrowed_ptr<borrowed<T> const volatile*>
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
# else
template<typename T>
struct is_borrowed
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
template<typename T>
struct is_borrowed<borrowed<T> >
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
template<typename T>
struct is_borrowed_ptr<T*>
: is_borrowed<typename remove_cv<T>::type>
{
};
# endif
# else // no partial specialization
typedef char (&yes_borrowed_ptr_t)[1];
typedef char (&no_borrowed_ptr_t)[2];
no_borrowed_ptr_t is_borrowed_ptr_test(...);
template <class T>
typename mpl::if_c<
is_pointer<T>::value
, T
, int
>::type
is_borrowed_ptr_test1(boost::type<T>);
template<typename T>
yes_borrowed_ptr_t is_borrowed_ptr_test(borrowed<T> const volatile*);
template<typename T>
class is_borrowed_ptr
{
public:
BOOST_STATIC_CONSTANT(
bool, value = (
sizeof(detail::is_borrowed_ptr_test(is_borrowed_ptr_test1(boost::type<T>())))
== sizeof(detail::yes_borrowed_ptr_t)));
};
# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
}
template <class T>
inline T* get_managed_object(detail::borrowed<T> const volatile* p, tag_t)
{
return (T*)p;
}
}} // namespace boost::python::detail
#endif // #ifndef BORROWED_PTR_DWA20020601_HPP

View File

@@ -1,66 +0,0 @@
// Copyright David Abrahams 2001. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef CALL_OBJECT_DWA20011222_HPP
# define CALL_OBJECT_DWA20011222_HPP
# include <boost/python/errors.hpp>
# include <boost/python/detail/types.hpp>
# include <boost/bind.hpp>
namespace boost { namespace python {
namespace detail
{
// A function object adaptor which turns a function returning R into
// an "equivalent" function returning void, but taking an R& in
// which the adapted function's result is stored.
template <class R, class F>
struct return_by_reference
{
typedef void return_type;
return_by_reference(R& result, F f)
: m_result(result)
, m_f(f)
{
}
void operator()() const
{
m_result = m_f();
}
R& m_result;
F m_f;
};
// An object generator for the above adaptors
template <class R, class F>
return_by_reference<R,F> bind_return(R& result, F f)
{
return return_by_reference<R,F>(result, f);
}
// Given a function object f with signature
//
// R f(PyTypeObject*,PyObject*)
//
// calls f inside of handle_exception_impl, placing f's result in
// ret. Returns true iff an exception is thrown by f, leaving ret
// unmodified.
template <class R, class F>
bool call_object(R& ret, PyObject* obj, F f)
{
return handle_exception(
detail::bind_return(
ret
, boost::bind<R>(
f, static_cast<type_object_base*>(obj->ob_type), obj)));
}
} // namespace detail
}} // namespace boost::python
#endif // CALL_OBJECT_DWA20011222_HPP

View File

@@ -1,105 +0,0 @@
#if !defined(BOOST_PP_IS_ITERATING)
// (C) Copyright David Abrahams 2000. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// The author gratefully acknowleges the support of Dragon Systems, Inc., in
// producing this work.
//
// This file generated for 10-argument member functions and 11-argument free
// functions by gen_caller.python
# ifndef CALLER_DWA20011214_HPP
# define CALLER_DWA20011214_HPP
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/detail/returning.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/type_traits/composite_traits.hpp>
# include <boost/type_traits/same_traits.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/preprocessor/debug/line.hpp>
namespace boost { namespace python
{
template <class T> struct to_python;
}}
namespace boost { namespace python { namespace detail {
struct caller
{
typedef PyObject* result_type;
// function pointers
# define BOOST_PP_ITERATION_PARAMS_1 \
(4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/caller.hpp>, BOOST_PYTHON_FUNCTION_POINTER))
# include BOOST_PP_ITERATE()
// pointers-to-members
# define BOOST_PP_ITERATION_PARAMS_1 \
(4, (0, 3, <boost/python/detail/caller.hpp>, BOOST_PYTHON_POINTER_TO_MEMBER))
# include BOOST_PP_ITERATE()
};
}}} // namespace boost::python::detail
# endif // CALLER_DWA20011214_HPP
/* ---------- function pointers --------- */
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_FUNCTION_POINTER
# line BOOST_PP_LINE(__LINE__, detail/caller.hpp(function pointers))
# define N BOOST_PP_ITERATION()
template <
class P, class R
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)
>
PyObject* operator()(
R (*pf)(BOOST_PYTHON_UNARY_ENUM(N, A))
, PyObject* args
, PyObject* keywords
, P const& policies) const
{
return returning<R>::call(pf, args, keywords, &policies);
}
# undef N
/* ---------- pointers-to-members ---------- */
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_POINTER_TO_MEMBER
// outer over cv-qualifiers
# define BOOST_PP_ITERATION_PARAMS_2 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/caller.hpp>))
# include BOOST_PP_ITERATE()
#elif BOOST_PP_ITERATION_DEPTH() == 2
// inner over arities
#define N BOOST_PP_ITERATION()
#define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
template <
class P, class R, class T
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)
>
PyObject* operator()(
R (T::*pmf)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q
, PyObject* args, PyObject* keywords
, P const& policies
) const
{
return returning<R>::call(pmf, args, keywords, &policies);
}
#undef N
#undef Q
#endif

View File

@@ -1,81 +0,0 @@
// (C) Copyright David Abrahams 2000. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// The author gratefully acknowleges the support of Dragon Systems, Inc., in
// producing this work.
#ifndef CAST_DWA052500_H_
# define CAST_DWA052500_H_
# ifndef BOOST_PYTHON_V2
# include <boost/python/detail/wrap_python.hpp>
# include <boost/operators.hpp>
namespace boost { namespace python {
namespace detail {
inline PyTypeObject* as_base_object(const PyTypeObject*, PyObject* p)
{
return reinterpret_cast<PyTypeObject*>(p);
}
inline PyObject* as_base_object(const PyObject*, PyObject* p)
{
return p;
}
inline const PyTypeObject* as_base_object(const PyTypeObject*, const PyObject* p)
{
return reinterpret_cast<const PyTypeObject*>(p);
}
inline const PyObject* as_base_object(const PyObject*, const PyObject* p)
{
return p;
}
} // namespace detail
// Convert a pointer to any type derived from PyObject or PyTypeObject to a PyObject*
inline PyObject* as_object(PyObject* p) { return p; }
inline PyObject* as_object(PyTypeObject* p) { return reinterpret_cast<PyObject*>(p); }
// If I didn't have to support stupid MSVC6 we could just use a simple template function:
// template <class T> T* downcast(PyObject*).
template <class T>
struct downcast
{
downcast(PyObject* p)
: m_p(static_cast<T*>(detail::as_base_object((T*)0, p)))
{}
downcast(const PyObject* p)
: m_p(static_cast<T*>(detail::as_base_object((const T*)0, p)))
{}
downcast(PyTypeObject* p)
: m_p(static_cast<T*>(p))
{}
downcast(const PyTypeObject* p)
: m_p(static_cast<T*>(p))
{}
operator T*() const { return m_p; }
// MSVC doesn't like boost::dereferencable unless T has a default
// constructor, so operator-> must be defined by hand :(
T* operator->() const { return &**this; }
T* get() const { return m_p; }
T& operator*() const { return *m_p; }
private:
T* m_p;
};
}} // namespace boost::python
# endif // BOOST_PYTHON_V2
#endif // CAST_DWA052500_H_

View File

@@ -1,23 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef CHAR_ARRAY_DWA2002129_HPP
# define CHAR_ARRAY_DWA2002129_HPP
namespace boost { namespace python { namespace detail {
// This little package is used to transmit the number of arguments
// from the helper functions below to the sizeof() expression below.
// Because we can never have an array of fewer than 1 element, we
// add 1 to n and then subtract 1 from the result of sizeof() below.
template <int n>
struct char_array
{
char elements[n+1];
};
}}} // namespace boost::python::detail
#endif // CHAR_ARRAY_DWA2002129_HPP

View File

@@ -1,117 +0,0 @@
// (C) Copyright David Abrahams 2000. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// The author gratefully acknowleges the support of Dragon Systems, Inc., in
// producing this work.
// Revision History:
// 04 Mar 01 Some fixes so it will compile with Intel C++ (Dave Abrahams)
#ifndef CONFIG_DWA052200_H_
# define CONFIG_DWA052200_H_
# include <boost/config.hpp>
# ifdef BOOST_NO_OPERATORS_IN_NAMESPACE
// A gcc bug forces some symbols into the global namespace
# define BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE
# define BOOST_PYTHON_END_CONVERSION_NAMESPACE
# define BOOST_PYTHON_CONVERSION
# define BOOST_PYTHON_IMPORT_CONVERSION(x) using ::x
# else
# define BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE namespace boost { namespace python {
# define BOOST_PYTHON_END_CONVERSION_NAMESPACE }} // namespace boost::python
# define BOOST_PYTHON_CONVERSION boost::python
# define BOOST_PYTHON_IMPORT_CONVERSION(x) void never_defined() // so we can follow the macro with a ';'
# endif
# if defined(BOOST_MSVC)
# if _MSC_VER <= 1200
# define BOOST_MSVC6_OR_EARLIER 1
# endif
# pragma warning (disable : 4786)
# elif defined(__ICL) && __ICL < 600 // Intel C++ 5
# pragma warning(disable: 985) // identifier was truncated in debug information
# endif
// The STLport puts all of the standard 'C' library names in std (as far as the
// user is concerned), but without it you need a fix if you're using MSVC or
// Intel C++
# if defined(BOOST_MSVC_STD_ITERATOR)
# define BOOST_CSTD_
# else
# define BOOST_CSTD_ std
# endif
/*****************************************************************************
*
* Set up dll import/export options:
*
****************************************************************************/
// backwards compatibility:
#ifdef BOOST_PYTHON_STATIC_LIB
# define BOOST_PYTHON_STATIC_LINK
# elif !defined(BOOST_PYTHON_DYNAMIC_LIB)
# define BOOST_PYTHON_DYNAMIC_LIB
#endif
#if defined(__MWERKS__) \
|| (defined(__DECCXX_VER) && __DECCXX_VER <= 60590002) \
|| (defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730)
# define BOOST_PYTHON_NO_TEMPLATE_EXPORT
#endif
#if defined(BOOST_PYTHON_DYNAMIC_LIB) && defined(_WIN32)
# if defined(BOOST_PYTHON_SOURCE)
# define BOOST_PYTHON_DECL __declspec(dllexport)
# define BOOST_PYTHON_BUILD_DLL
# else
# define BOOST_PYTHON_DECL __declspec(dllimport)
# endif
// MinGW, at least, has some problems exporting template instantiations
# if defined(__GNUC__) && __GNUC__ < 3 && !defined(__CYGWIN__)
# define BOOST_PYTHON_NO_TEMPLATE_EXPORT
# endif
#endif
#ifndef BOOST_PYTHON_DECL
# define BOOST_PYTHON_DECL
#endif
#ifndef BOOST_PYTHON_EXPORT
# define BOOST_PYTHON_EXPORT extern
#endif
#if !defined(BOOST_PYTHON_NO_TEMPLATE_EXPORT)
# define BOOST_PYTHON_EXPORT_CLASS_TEMPLATE(instantiation) BOOST_PYTHON_EXPORT template class BOOST_PYTHON_DECL instantiation
#else
# define BOOST_PYTHON_EXPORT_CLASS_TEMPLATE(instantiation) struct ThIsTyPeNeVeRuSeD
#endif
#if defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730
// Work around a compiler bug.
// boost::python::detail::function has to be seen by the compiler before the
// boost::function class template.
namespace boost { namespace python { namespace detail {
class function;
}}}
#endif
#if (defined(__DECCXX_VER) && __DECCXX_VER <= 60590014)
// Replace broken Tru64/cxx offsetof macro
# define BOOST_PYTHON_OFFSETOF(s_name, s_member) \
((size_t)__INTADDR__(&(((s_name *)0)->s_member)))
#else
# define BOOST_PYTHON_OFFSETOF offsetof
#endif
#endif // CONFIG_DWA052200_H_

View File

@@ -1,43 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef CONSTRUCT_REFERENCE_DWA2002716_HPP
# define CONSTRUCT_REFERENCE_DWA2002716_HPP
namespace boost { namespace python { namespace detail {
template <class T, class Arg>
void construct_pointee(void* storage, Arg& x
# if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
, T const volatile*
# else
, T const*
# endif
)
{
new (storage) T(x);
}
template <class T, class Arg>
void construct_referent_impl(void* storage, Arg& x, T&(*)())
{
construct_pointee(storage, x, (T*)0);
}
template <class T, class Arg>
void construct_referent(void* storage, Arg const& x, T(*tag)() = 0)
{
construct_referent_impl(storage, x, tag);
}
template <class T, class Arg>
void construct_referent(void* storage, Arg& x, T(*tag)() = 0)
{
construct_referent_impl(storage, x, tag);
}
}}} // namespace boost::python::detail
#endif // CONSTRUCT_REFERENCE_DWA2002716_HPP

View File

@@ -1,39 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef CONVERTIBLE_DWA2002614_HPP
# define CONVERTIBLE_DWA2002614_HPP
# if defined(__EDG_VERSION__) && __EDG_VERSION__ <= 241
# include <boost/mpl/if.hpp>
# include <boost/type_traits/conversion_traits.hpp>
# endif
// Supplies a runtime is_convertible check which can be used with tag
// dispatching to work around the Metrowerks Pro7 limitation with boost::is_convertible
namespace boost { namespace python { namespace detail {
typedef char* yes_convertible;
typedef int* no_convertible;
template <class Target>
struct convertible
{
# if !defined(__EDG_VERSION__) || __EDG_VERSION__ > 241 || __EDG_VERSION__ == 238
static inline no_convertible check(...) { return 0; }
static inline yes_convertible check(Target) { return 0; }
# else
template <class X>
static inline typename mpl::if_c<
is_convertible<X,Target>::value
, yes_convertible
, no_convertible
>::type check(X const&) { return 0; }
# endif
};
}}} // namespace boost::python::detail
#endif // CONVERTIBLE_DWA2002614_HPP

View File

@@ -1,34 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef CV_CATEGORY_DWA200222_HPP
# define CV_CATEGORY_DWA200222_HPP
# include <boost/type_traits/cv_traits.hpp>
namespace boost { namespace python { namespace detail {
template <bool is_const_, bool is_volatile_>
struct cv_tag
{
BOOST_STATIC_CONSTANT(bool, is_const = is_const_);
BOOST_STATIC_CONSTANT(bool, is_volatile = is_const_);
};
typedef cv_tag<false,false> cv_unqualified;
typedef cv_tag<true,false> const_;
typedef cv_tag<false,true> volatile_;
typedef cv_tag<true,true> const_volatile_;
template <class T>
struct cv_category
{
BOOST_STATIC_CONSTANT(bool, c = is_const<T>::value);
BOOST_STATIC_CONSTANT(bool, v = is_volatile<T>::value);
typedef cv_tag<c,v> type;
};
}}} // namespace boost::python::detail
#endif // CV_CATEGORY_DWA200222_HPP

View File

@@ -1,77 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef DECORATED_TYPE_ID_DWA2002517_HPP
# define DECORATED_TYPE_ID_DWA2002517_HPP
# include <boost/python/type_id.hpp>
# include <boost/python/detail/indirect_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
namespace boost { namespace python { namespace detail {
struct decorated_type_info : totally_ordered<decorated_type_info>
{
enum decoration { const_ = 0x1, volatile_ = 0x2, reference = 0x4 };
decorated_type_info(type_info, decoration = decoration());
inline bool operator<(decorated_type_info const& rhs) const;
inline bool operator==(decorated_type_info const& rhs) const;
friend BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream&, decorated_type_info const&);
operator type_info const&() const;
private: // type
typedef type_info base_id_t;
private: // data members
decoration m_decoration;
base_id_t m_base_type;
};
template <class T>
inline decorated_type_info decorated_type_id(boost::type<T>* = 0)
{
return decorated_type_info(
type_id<T>()
, decorated_type_info::decoration(
(is_const<T>::value || python::detail::is_reference_to_const<T>::value
? decorated_type_info::const_ : 0)
| (is_volatile<T>::value || python::detail::is_reference_to_volatile<T>::value
? decorated_type_info::volatile_ : 0)
| (is_reference<T>::value ? decorated_type_info::reference : 0)
)
);
}
inline decorated_type_info::decorated_type_info(type_info base_t, decoration decoration)
: m_decoration(decoration)
, m_base_type(base_t)
{
}
inline bool decorated_type_info::operator<(decorated_type_info const& rhs) const
{
return m_decoration < rhs.m_decoration
|| m_decoration == rhs.m_decoration
&& m_base_type < rhs.m_base_type;
}
inline bool decorated_type_info::operator==(decorated_type_info const& rhs) const
{
return m_decoration == rhs.m_decoration && m_base_type == rhs.m_base_type;
}
inline decorated_type_info::operator type_info const&() const
{
return m_base_type;
}
BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream&, decorated_type_info const&);
}}} // namespace boost::python::detail
#endif // DECORATED_TYPE_ID_DWA2002517_HPP

View File

@@ -1,61 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef DEF_HELPER_DWA200287_HPP
# define DEF_HELPER_DWA200287_HPP
# include <boost/type_traits/ice.hpp>
# include <boost/type_traits/same_traits.hpp>
# include <boost/python/detail/string_literal.hpp>
namespace boost { namespace python { namespace detail {
//
// def_helper<T> --
//
// A helper for def() functions which determines how to interpret
// an argument of type T which could be either CallPolicies or a
// string literal representing a docstring.
//
// Generates two static functions:
//
// get_policy(x), where x is of type T, returns a policies
// object: either a reference to x or default_call_policies()
// if x is a string literal.
//
// get_doc(x, s), where s convertible to char const*, returns x
// if x is a string literal, s otherwise.
template <bool is_string = false>
struct def_helper_impl
{
template <class P>
static P const& get_policy(P const& x) { return x; }
template <class P>
static char const* get_doc(P const&, char const* doc) { return doc; }
};
template <>
struct def_helper_impl<true>
{
static python::default_call_policies get_policy(char const*) { return default_call_policies(); }
static char const* get_doc(char const* doc, char const*) { return doc; }
};
template <class T>
struct def_helper
: def_helper_impl<
type_traits::ice_or<
is_string_literal<T const>::value
, is_same<T, char const*>::value
, is_same<T, char*>::value
>::value
>
{};
}}} // namespace boost::python::detail
#endif // DEF_HELPER_DWA200287_HPP

View File

@@ -1,249 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
//
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
//
///////////////////////////////////////////////////////////////////////////////
#if !defined(BOOST_PP_IS_ITERATING)
#ifndef DEFAULTS_DEF_JDG20020811_HPP
#define DEFAULTS_DEF_JDG20020811_HPP
#include <boost/python/detail/defaults_gen.hpp>
#include <boost/type_traits.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/size.hpp>
#include <boost/static_assert.hpp>
#include <boost/preprocessor/iterate.hpp>
#include <boost/python/class_fwd.hpp>
#include <boost/python/object/function.hpp>
#include <boost/python/scope.hpp>
#include <boost/preprocessor/debug/line.hpp>
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace python {
struct module;
namespace objects
{
struct class_base;
}
namespace detail {
template <class Func, class CallPolicies, class NameSpaceT>
static void name_space_def(
NameSpaceT& name_space,
char const* name,
Func f,
CallPolicies const& policies,
char const* doc,
objects::class_base*
)
{
name_space.def(
name, f, policies, doc);
}
template <class Func, class CallPolicies>
static void name_space_def(
object& name_space,
char const* name,
Func f,
CallPolicies const& policies,
char const* doc,
...
)
{
scope within(name_space);
def(name, f, policies, doc);
}
// For backward compatibility
template <class Func, class CallPolicies, class NameSpaceT>
static void name_space_def(
NameSpaceT& name_space,
char const* name,
Func f,
CallPolicies const& policies,
char const* doc,
module*
)
{
name_space.def(
name, f, policies, doc);
}
///////////////////////////////////////////////////////////////////////////////
//
// This Boost PP code generates expansions for
//
// template <typename StubsT, typename NameSpaceT>
// inline void
// define_stub_function(
// char const* name, StubsT s, NameSpaceT& name_space, mpl::int_c<N>)
// {
// name_space.def(name, &StubsT::func_N);
// }
//
// where N runs from 0 to BOOST_PYTHON_MAX_ARITY
//
// The set of overloaded functions (define_stub_function) expects:
//
// 1. char const* name: function name that will be visible to python
// 2. StubsT: a function stubs struct (see defaults_gen.hpp)
// 3. NameSpaceT& name_space: a python::class_ or python::module instance
// 4. int_t<N>: the Nth overloaded function (StubsT::func_N)
// (see defaults_gen.hpp)
// 5. char const* name: doc string
//
///////////////////////////////////////////////////////////////////////////////
template <int N>
struct define_stub_function {};
#define BOOST_PP_ITERATION_PARAMS_1 \
(3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/defaults_def.hpp>))
#include BOOST_PP_ITERATE()
///////////////////////////////////////////////////////////////////////////////
//
// define_with_defaults_helper<N>
//
// This helper template struct does the actual recursive definition.
// There's a generic version define_with_defaults_helper<N> and a
// terminal case define_with_defaults_helper<0>. The struct and its
// specialization has a sole static member function def that expects:
//
// 1. char const* name: function name that will be visible to python
// 2. StubsT: a function stubs struct (see defaults_gen.hpp)
// 3. NameSpaceT& name_space: a python::class_ or python::module instance
// 4. char const* name: doc string
//
// The def static member function calls a corresponding
// define_stub_function<N>. The general case recursively calls
// define_with_defaults_helper<N-1>::def until it reaches the
// terminal case case define_with_defaults_helper<0>.
//
///////////////////////////////////////////////////////////////////////////////
template <int N>
struct define_with_defaults_helper {
template <class StubsT, class CallPolicies, class NameSpaceT>
static void
def(
char const* name,
StubsT stubs,
CallPolicies const& policies,
NameSpaceT& name_space,
char const* doc)
{
// define the NTH stub function of stubs
define_stub_function<N>::define(name, stubs, policies, name_space, doc);
// call the next define_with_defaults_helper
define_with_defaults_helper<N-1>::def(name, stubs, policies, name_space, doc);
}
};
///////////////////////////////////////
template <>
struct define_with_defaults_helper<0> {
template <class StubsT, class CallPolicies, class NameSpaceT>
static void
def(
char const* name,
StubsT stubs,
CallPolicies const& policies,
NameSpaceT& name_space,
char const* doc)
{
// define the Oth stub function of stubs
define_stub_function<0>::define(name, stubs, policies, name_space, doc);
// return
}
};
///////////////////////////////////////////////////////////////////////////////
//
// define_with_defaults
//
// 1. char const* name: function name that will be visible to python
// 2. StubsT: a function stubs struct (see defaults_gen.hpp)
// 3. CallPolicies& policies: Call policies
// 4. NameSpaceT& name_space: a python::class_ or python::module instance
// 5. SigT sig: Function signature typelist (see defaults_gen.hpp)
// 6. char const* name: doc string
//
// This is the main entry point. This function recursively defines all
// stub functions of StubT (see defaults_gen.hpp) in NameSpaceT name_space which
// can be either a python::class_ or a python::module. The sig argument
// is a typelist that specifies the return type, the class (for member
// functions, and the arguments. Here are some SigT examples:
//
// int foo(int) mpl::list<int, int>
// void bar(int, int) mpl::list<void, int, int>
// void C::foo(int) mpl::list<void, C, int>
//
///////////////////////////////////////////////////////////////////////////////
template <class StubsT, class NameSpaceT, class SigT>
inline void
define_with_defaults(
char const* name,
StubsT const& stubs,
NameSpaceT& name_space,
SigT sig)
{
typedef typename mpl::front<SigT>::type return_type;
typedef typename StubsT::v_type v_type;
typedef typename StubsT::nv_type nv_type;
typedef typename mpl::if_c<
boost::is_same<void, return_type>::value
, v_type
, nv_type
>::type stubs_type;
BOOST_STATIC_ASSERT(
(stubs_type::max_args) <= mpl::size<SigT>::value);
typedef typename stubs_type::template gen<SigT> gen_type;
define_with_defaults_helper<stubs_type::n_funcs-1>::def
(name, gen_type(), stubs.call_policies(), name_space, stubs.doc_string());
}
} // namespace detail
}} // namespace boost::python
///////////////////////////////////////////////////////////////////////////////
#endif // DEFAULTS_DEF_JDG20020811_HPP
#else // defined(BOOST_PP_IS_ITERATING)
// PP vertical iteration code
template <>
struct define_stub_function<BOOST_PP_ITERATION()> {
template <class StubsT, class CallPolicies, class NameSpaceT>
static void define(
char const* name,
StubsT,
CallPolicies const& policies,
NameSpaceT& name_space,
char const* doc)
{
detail::name_space_def(name_space,
name,
&StubsT::BOOST_PP_CAT(func_, BOOST_PP_ITERATION()),
policies,
doc, &name_space);
}
};
#endif // !defined(BOOST_PP_IS_ITERATING)

View File

@@ -1,388 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
//
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef DEFAULTS_GEN_JDG20020807_HPP
#define DEFAULTS_GEN_JDG20020807_HPP
#include <boost/python/detail/preprocessor.hpp>
#include <boost/preprocessor/repeat.hpp>
#include <boost/preprocessor/repeat_from_to.hpp>
#include <boost/preprocessor/enum.hpp>
#include <boost/preprocessor/enum_params.hpp>
#include <boost/preprocessor/tuple.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/arithmetic/sub.hpp>
#include <boost/preprocessor/stringize.hpp>
#include <boost/preprocessor/inc.hpp>
#include <boost/preprocessor/empty.hpp>
#include <boost/preprocessor/comma_if.hpp>
#include <boost/config.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/front.hpp>
namespace boost { namespace python {
///////////////////////////////////////////////////////////////////////////////
//
// func_stubs_base is used as a base class for all function stubs.
//
///////////////////////////////////////////////////////////////////////////////
namespace detail
{
struct func_stubs_base {};
}
template <class CallPoliciesT, class StubsT>
struct func_stubs_with_call_policies
: public detail::func_stubs_base
{
typedef typename StubsT::nv_type nv_type;
typedef typename StubsT::v_type v_type;
func_stubs_with_call_policies(CallPoliciesT const& policies_, char const* doc_)
: policies(policies_), doc(doc_) {}
char const* doc_string() const
{ return doc; }
CallPoliciesT
call_policies() const
{ return policies; }
CallPoliciesT policies;
char const* doc;
};
}} // namespace boost::python
///////////////////////////////////////////////////////////////////////////////
#define BOOST_PYTHON_TYPEDEF_GEN(z, index, data) \
typedef typename BOOST_PP_CAT(iter, index)::next \
BOOST_PP_CAT(iter, BOOST_PP_INC(index)); \
typedef typename BOOST_PP_CAT(iter, index)::type BOOST_PP_CAT(T, index); \
#define BOOST_PYTHON_FUNC_WRAPPER_GEN(z, index, data) \
static RT BOOST_PP_CAT(func_, \
BOOST_PP_SUB_D(1, index, BOOST_PP_TUPLE_ELEM(3, 1, data))) ( \
BOOST_PYTHON_BINARY_ENUM( \
index, T, arg)) \
{ \
BOOST_PP_TUPLE_ELEM(3, 2, data) \
BOOST_PP_TUPLE_ELEM(3, 0, data)( \
BOOST_PP_ENUM_PARAMS( \
index, \
arg)); \
}
#define BOOST_PYTHON_GEN_FUNCTION(fname, fstubs_name, n_args, n_dflts, ret) \
struct fstubs_name { \
\
BOOST_STATIC_CONSTANT(int, n_funcs = BOOST_PP_INC(n_dflts)); \
BOOST_STATIC_CONSTANT(int, max_args = n_funcs); \
\
template <typename SigT> \
struct gen { \
\
typedef typename ::boost::mpl::begin<SigT>::type rt_iter; \
typedef typename rt_iter::type RT; \
typedef typename rt_iter::next iter0; \
\
BOOST_PP_REPEAT_2ND( \
n_args, \
BOOST_PYTHON_TYPEDEF_GEN, \
0) \
\
BOOST_PP_REPEAT_FROM_TO( \
BOOST_PP_SUB_D(1, n_args, n_dflts), \
BOOST_PP_INC(n_args), \
BOOST_PYTHON_FUNC_WRAPPER_GEN, \
(fname, BOOST_PP_SUB_D(1, n_args, n_dflts), ret)) \
}; \
}; \
///////////////////////////////////////////////////////////////////////////////
#define BOOST_PYTHON_MEM_FUNC_WRAPPER_GEN(z, index, data) \
static RT BOOST_PP_CAT(func_, \
BOOST_PP_SUB_D(1, index, BOOST_PP_TUPLE_ELEM(3, 1, data))) ( \
ClassT& obj BOOST_PP_COMMA_IF(index) \
BOOST_PYTHON_BINARY_ENUM(index, T, arg) \
) \
{ \
BOOST_PP_TUPLE_ELEM(3, 2, data) obj.BOOST_PP_TUPLE_ELEM(3, 0, data)( \
BOOST_PP_ENUM_PARAMS(index, arg) \
); \
}
#define BOOST_PYTHON_GEN_MEM_FUNCTION(fname, fstubs_name, n_args, n_dflts, ret) \
struct fstubs_name { \
\
BOOST_STATIC_CONSTANT(int, n_funcs = BOOST_PP_INC(n_dflts)); \
BOOST_STATIC_CONSTANT(int, max_args = n_funcs + 1); \
\
template <typename SigT> \
struct gen { \
\
typedef typename ::boost::mpl::begin<SigT>::type rt_iter; \
typedef typename rt_iter::type RT; \
\
typedef typename rt_iter::next class_iter; \
typedef typename class_iter::type ClassT; \
typedef typename class_iter::next iter0; \
\
BOOST_PP_REPEAT_2ND( \
n_args, \
BOOST_PYTHON_TYPEDEF_GEN, \
0) \
\
BOOST_PP_REPEAT_FROM_TO( \
BOOST_PP_SUB_D(1, n_args, n_dflts), \
BOOST_PP_INC(n_args), \
BOOST_PYTHON_MEM_FUNC_WRAPPER_GEN, \
(fname, BOOST_PP_SUB_D(1, n_args, n_dflts), ret)) \
}; \
};
///////////////////////////////////////////////////////////////////////////////
#if defined(BOOST_MSVC)
#define BOOST_PYTHON_GEN_FUNCTION_STUB(fname, fstubs_name, n_args, n_dflts) \
BOOST_PYTHON_GEN_FUNCTION \
(fname, BOOST_PP_CAT(fstubs_name, _NV), n_args, n_dflts, return) \
BOOST_PYTHON_GEN_FUNCTION \
(fname, BOOST_PP_CAT(fstubs_name, _V), n_args, n_dflts, ;) \
struct fstubs_name \
: public boost::python::detail::func_stubs_base { \
\
typedef BOOST_PP_CAT(fstubs_name, _NV) nv_type; \
typedef BOOST_PP_CAT(fstubs_name, _V) v_type; \
typedef fstubs_name self_t; \
\
fstubs_name(char const* doc_ = 0) \
: doc(doc_) {} \
\
char const* doc_string() const \
{ return doc; } \
\
default_call_policies \
call_policies() const \
{ return default_call_policies(); } \
\
template <class CallPoliciesT> \
func_stubs_with_call_policies<CallPoliciesT, self_t> \
operator[](CallPoliciesT const& policies) const \
{ \
return func_stubs_with_call_policies<CallPoliciesT, self_t> \
(policies, doc); \
} \
\
char const* doc; \
}; \
///////////////////////////////////////////////////////////////////////////////
#define BOOST_PYTHON_GEN_MEM_FUNCTION_STUB(fname, fstubs_name, n_args, n_dflts) \
BOOST_PYTHON_GEN_MEM_FUNCTION \
(fname, BOOST_PP_CAT(fstubs_name, _NV), n_args, n_dflts, return) \
BOOST_PYTHON_GEN_MEM_FUNCTION \
(fname, BOOST_PP_CAT(fstubs_name, _V), n_args, n_dflts, ;) \
struct fstubs_name \
: public boost::python::detail::func_stubs_base { \
\
typedef BOOST_PP_CAT(fstubs_name, _NV) nv_type; \
typedef BOOST_PP_CAT(fstubs_name, _V) v_type; \
typedef fstubs_name self_t; \
\
fstubs_name(char const* doc_ = 0) \
: doc(doc_) {} \
\
char const* doc_string() const \
{ return doc; } \
\
default_call_policies \
call_policies() const \
{ return default_call_policies(); } \
\
template <class CallPoliciesT> \
func_stubs_with_call_policies<CallPoliciesT, self_t> \
operator[](CallPoliciesT const& policies) const \
{ \
return func_stubs_with_call_policies<CallPoliciesT, self_t> \
(policies, doc); \
} \
\
char const* doc; \
}; \
#else
///////////////////////////////////////////////////////////////////////////////
#define BOOST_PYTHON_GEN_FUNCTION_STUB(fname, fstubs_name, n_args, n_dflts) \
BOOST_PYTHON_GEN_FUNCTION \
(fname, BOOST_PP_CAT(fstubs_name, _NV), n_args, n_dflts, return) \
struct fstubs_name \
: public boost::python::detail::func_stubs_base { \
\
typedef BOOST_PP_CAT(fstubs_name, _NV) nv_type; \
typedef BOOST_PP_CAT(fstubs_name, _NV) v_type; \
typedef fstubs_name self_t; \
\
fstubs_name(char const* doc_ = 0) \
: doc(doc_) {} \
\
char const* doc_string() const \
{ return doc; } \
\
default_call_policies \
call_policies() const \
{ return default_call_policies(); } \
\
template <class CallPoliciesT> \
func_stubs_with_call_policies<CallPoliciesT, self_t> \
operator[](CallPoliciesT const& policies) const \
{ \
return func_stubs_with_call_policies<CallPoliciesT, self_t> \
(policies, doc); \
} \
\
char const* doc; \
}; \
///////////////////////////////////////////////////////////////////////////////
#define BOOST_PYTHON_GEN_MEM_FUNCTION_STUB(fname, fstubs_name, n_args, n_dflts) \
BOOST_PYTHON_GEN_MEM_FUNCTION \
(fname, BOOST_PP_CAT(fstubs_name, _NV), n_args, n_dflts, return) \
struct fstubs_name \
: public boost::python::detail::func_stubs_base { \
\
typedef BOOST_PP_CAT(fstubs_name, _NV) nv_type; \
typedef BOOST_PP_CAT(fstubs_name, _NV) v_type; \
typedef fstubs_name self_t; \
\
fstubs_name(char const* doc_ = 0) \
: doc(doc_) {} \
\
char const* doc_string() const \
{ return doc; } \
\
default_call_policies \
call_policies() const \
{ return default_call_policies(); } \
\
template <class CallPoliciesT> \
func_stubs_with_call_policies<CallPoliciesT, self_t> \
operator[](CallPoliciesT const& policies) const \
{ \
return func_stubs_with_call_policies<CallPoliciesT, self_t> \
(policies, doc); \
} \
\
char const* doc; \
}; \
#endif // defined(BOOST_MSVC)
///////////////////////////////////////////////////////////////////////////////
//
// MAIN MACROS
//
// Given generator_name, fname, min_args and max_args, These macros
// generate function stubs that forward to a function or member function
// named fname. max_args is the arity of the function or member function
// fname. fname can have default arguments. min_args is the minimum
// arity that fname can accept.
//
// There are two versions:
//
// 1. BOOST_PYTHON_FUNCTION_OVERLOADS for free functions
// 2. BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS for member functions.
//
// For instance, given a function:
//
// int
// foo(int a, char b = 1, unsigned c = 2, double d = 3)
// {
// return a + b + c + int(d);
// }
//
// The macro invocation:
//
// BOOST_PYTHON_FUNCTION_OVERLOADS(foo_stubs, foo, 1, 4)
//
// Generates this code:
//
// struct foo_stubs_NV {
//
// static const int n_funcs = 4;
// static const int max_args = n_funcs;
//
// template <typename SigT>
// struct gen {
//
// typedef typename ::boost::mpl::begin<SigT>::type rt_iter;
// typedef typename rt_iter::type RT;
// typedef typename rt_iter::next iter0;
// typedef typename iter0::type T0;
// typedef typename iter0::next iter1;
// typedef typename iter1::type T1;
// typedef typename iter1::next iter2;
// typedef typename iter2::type T2;
// typedef typename iter2::next iter3;
// typedef typename iter3::type T3;
// typedef typename iter3::next iter4;
//
// static RT func_0(T0 arg0)
// { return foo(arg0); }
//
// static RT func_1(T0 arg0, T1 arg1)
// { return foo(arg0, arg1); }
//
// static RT func_2(T0 arg0, T1 arg1, T2 arg2)
// { return foo(arg0, arg1, arg2); }
//
// static RT func_3(T0 arg0, T1 arg1, T2 arg2, T3 arg3)
// { return foo(arg0, arg1, arg2, arg3); }
// };
// };
//
// struct foo_stubs
// : public boost::python::detail::func_stubs_base {
//
// typedef foo_stubs_NV nv_type;
// typedef foo_stubs_NV v_type;
// };
//
// The typedefs nv_type and v_type are used to handle compilers that
// do not support void returns. The example above typedefs nv_type
// and v_type to foo_stubs_NV. On compilers that do not support
// void returns, there are two versions: foo_stubs_NV and foo_stubs_V.
// The "V" version is almost identical to the "NV" version except
// for the return type (void) and the lack of the return keyword.
//
///////////////////////////////////////////////////////////////////////////////
#define BOOST_PYTHON_FUNCTION_OVERLOADS(generator_name, fname, min_args, max_args) \
BOOST_PYTHON_GEN_FUNCTION_STUB( \
fname, \
generator_name, \
max_args, \
BOOST_PP_SUB_D(1, max_args, min_args))
#define BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(generator_name, fname, min_args, max_args) \
BOOST_PYTHON_GEN_MEM_FUNCTION_STUB( \
fname, \
generator_name, \
max_args, \
BOOST_PP_SUB_D(1, max_args, min_args))
// deprecated macro names (to be removed)
#define BOOST_PYTHON_FUNCTION_GENERATOR BOOST_PYTHON_FUNCTION_OVERLOADS
#define BOOST_PYTHON_MEM_FUN_GENERATOR BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS
///////////////////////////////////////////////////////////////////////////////
#endif // DEFAULTS_GEN_JDG20020807_HPP

View File

@@ -1,28 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef DEPENDENT_DWA200286_HPP
# define DEPENDENT_DWA200286_HPP
namespace boost { namespace python { namespace detail {
// A way to turn a concrete type T into a type dependent on U. This
// keeps conforming compilers (those implementing proper 2-phase
// name lookup for templates) from complaining about incomplete
// types in situations where it would otherwise be inconvenient or
// impossible to re-order code so that all types are defined in time.
// One such use is when we must return an incomplete T from a member
// function template (which must be defined in the class body to
// keep MSVC happy).
template <class T, class U>
struct dependent
{
typedef T type;
};
}}} // namespace boost::python::detail
#endif // DEPENDENT_DWA200286_HPP

View File

@@ -1,83 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef DESTROY_DWA2002221_HPP
# define DESTROY_DWA2002221_HPP
# include <boost/type_traits/composite_traits.hpp>
# include <boost/type_traits/object_traits.hpp>
namespace boost { namespace python { namespace detail {
template <bool array, bool trivial_destructor> struct value_destroyer;
template <>
struct value_destroyer<false,false>
{
template <class T>
static void execute(T const volatile* p)
{
p->T::~T();
}
};
template <>
struct value_destroyer<true,false>
{
template <class A, class T>
static void execute(A*, T const volatile* const first)
{
for (T const volatile* p = first; p != first + sizeof(A)/sizeof(T); ++p)
value_destroyer<
boost::is_array<T>::value
,boost::has_trivial_destructor<T>::value
>::execute(p);
}
template <class T>
static void execute(T const volatile* p)
{
execute(p, *p);
}
};
template <>
struct value_destroyer<true,true>
{
template <class T>
static void execute(T const volatile* p)
{
}
};
template <>
struct value_destroyer<false,true>
{
template <class T>
static void execute(T const volatile* p)
{
}
};
template <class T>
inline void destroy_referent_impl(void* p, T& (*)())
{
// note: cv-qualification needed for MSVC6
// must come *before* T for metrowerks
value_destroyer<
(boost::is_array<T>::value)
,(boost::has_trivial_destructor<T>::value)
>::execute((const volatile T*)p);
}
template <class T>
inline void destroy_referent(void* p, T(*)() = 0)
{
destroy_referent_impl(p, (T(*)())0);
}
}}} // namespace boost::python::detail
#endif // DESTROY_DWA2002221_HPP

View File

@@ -1,48 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef EXCEPTION_HANDLER_DWA2002810_HPP
# define EXCEPTION_HANDLER_DWA2002810_HPP
# include <boost/function/function0.hpp>
# include <boost/function/function2.hpp>
namespace boost { namespace python { namespace detail {
struct BOOST_PYTHON_DECL exception_handler;
typedef function2<bool, exception_handler const&, function0<void> const&> handler_function;
struct BOOST_PYTHON_DECL exception_handler
{
private: // types
public:
explicit exception_handler(handler_function const& impl);
inline bool handle(function0<void> const& f) const;
bool operator()(function0<void> const& f) const;
static exception_handler* chain;
private:
static exception_handler* tail;
handler_function m_impl;
exception_handler* m_next;
};
inline bool exception_handler::handle(function0<void> const& f) const
{
return this->m_impl(*this, f);
}
BOOST_PYTHON_DECL void register_exception_handler(handler_function const& f);
}}} // namespace boost::python::detail
#endif // EXCEPTION_HANDLER_DWA2002810_HPP

File diff suppressed because it is too large Load Diff

View File

@@ -1,33 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef FORCE_INSTANTIATE_DWA200265_HPP
# define FORCE_INSTANTIATE_DWA200265_HPP
namespace boost { namespace python { namespace detail {
// Allows us to force the argument to be instantiated without
// incurring unused variable warnings
# if !defined(BOOST_MSVC) || BOOST_MSVC == 1200 || _MSC_FULL_VER > 13102196
template <class T>
inline void force_instantiate(T const&) {}
# else
# pragma optimize("g", off)
inline void force_instantiate_impl(...) {}
# pragma optimize("", on)
template <class T>
inline void force_instantiate(T const& x)
{
detail::force_instantiate_impl(&x);
}
# endif
}}} // namespace boost::python::detail
#endif // FORCE_INSTANTIATE_DWA200265_HPP

View File

@@ -1,311 +0,0 @@
// (C) Copyright David Abrahams 2000. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// The author gratefully acknowleges the support of Dragon Systems, Inc., in
// producing this work.
#ifndef FUNCTIONS_DWA051400_H_
# define FUNCTIONS_DWA051400_H_
# include <boost/python/detail/config.hpp>
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/reference.hpp>
# include <boost/python/detail/signatures.hpp>
# include <boost/python/caller.hpp>
# include <boost/call_traits.hpp>
# include <boost/python/objects.hpp>
# include <boost/python/detail/base_object.hpp>
# include <typeinfo>
# include <vector>
namespace boost { namespace python { namespace detail {
// forward declaration
class extension_instance;
// function --
// the common base class for all overloadable function and method objects
// supplied by the library.
class BOOST_PYTHON_DECL function : public python_object
{
public:
function();
// function objects are reasonably rare, so we guess we can afford a virtual table.
// This cuts down on the number of distinct type objects which need to be defined.
virtual ~function() {}
PyObject* call(PyObject* args, PyObject* keywords) const;
static void add_to_namespace(reference<function> f, const char* name, PyObject* dict);
private:
virtual PyObject* do_call(PyObject* args, PyObject* keywords) const = 0;
virtual const char* description() const = 0;
private:
struct type_object;
private:
reference<function> m_overloads; // A linked list of the function overloads
};
// wrapped_function_pointer<> --
// A single function or member function pointer wrapped and presented to
// Python as a callable object.
//
// Template parameters:
// R - the return type of the function pointer
// F - the complete type of the wrapped function pointer
template <class R, class F>
struct wrapped_function_pointer : function
{
typedef F ptr_fun; // pointer-to--function or pointer-to-member-function
wrapped_function_pointer(ptr_fun pf)
: m_pf(pf) {}
private:
PyObject* do_call(PyObject* args, PyObject* keywords) const
{
// This is where the boundary between the uniform Python function
// interface and the statically-checked C++ function interface is
// crossed.
return caller<R>::call(m_pf, args, keywords);
}
const char* description() const
{ return typeid(F).name(); }
private:
const ptr_fun m_pf;
};
// raw_arguments_function
// A function that passes the Python argument tuple and keyword dictionary
// verbatim to C++ (useful for customized argument parsing and variable
// argument lists)
template <class Ret, class Args, class Keywords>
struct raw_arguments_function : function
{
typedef Ret (*ptr_fun)(Args, Keywords);
raw_arguments_function(ptr_fun pf)
: m_pf(pf) {}
private:
PyObject* do_call(PyObject* args, PyObject* keywords) const
{
ref dict(keywords ?
ref(keywords, ref::increment_count) :
ref(PyDict_New()));
return to_python(
(*m_pf)(from_python(args, boost::python::type<Args>()),
from_python(dict.get(), boost::python::type<Keywords>())));
}
const char* description() const
{ return typeid(ptr_fun).name(); }
private:
const ptr_fun m_pf;
};
// virtual_function<> --
// A virtual function with a default implementation wrapped and presented
// to Python as a callable object.
//
// Template parameters:
// T - the type of the target class
// R - the return type of the function pointer
// V - the virtual function pointer being wrapped
// (should be of the form R(T::*)(<args>), or R (*)(T, <args>))
// D - a function which takes a T&, const T&, T*, or const T* first
// parameter and calls T::f on it /non-virtually/, where V
// approximates &T::f.
template <class T, class R, class V, class D>
class virtual_function : public function
{
public:
virtual_function(V virtual_function_ptr, D default_implementation)
: m_virtual_function_ptr(virtual_function_ptr),
m_default_implementation(default_implementation)
{}
private:
PyObject* do_call(PyObject* args, PyObject* keywords) const;
const char* description() const
{ return typeid(V).name(); }
private:
const V m_virtual_function_ptr;
const D m_default_implementation;
};
// A helper function for new_member_function(), below. Implements the core
// functionality once the return type has already been deduced. R is expected to
// be type<X>, where X is the actual return type of pmf.
template <class F, class R>
function* new_wrapped_function_aux(R, F pmf)
{
// We can't just use "typename R::Type" below because MSVC (incorrectly) pukes.
typedef typename R::type return_type;
return new wrapped_function_pointer<return_type, F>(pmf);
}
// Create and return a new member function object wrapping the given
// pointer-to-member function
template <class F>
inline function* new_wrapped_function(F pmf)
{
// Deduce the return type and pass it off to the helper function above
return new_wrapped_function_aux(return_value(pmf), pmf);
}
template <class R, class Args, class keywords>
function* new_raw_arguments_function(R (*pmf)(Args, keywords))
{
return new raw_arguments_function<R, Args, keywords>(pmf);
}
// A helper function for new_virtual_function(), below. Implements the core
// functionality once the return type has already been deduced. R is expected to
// be type<X>, where X is the actual return type of V.
template <class T, class R, class V, class D>
inline function* new_virtual_function_aux(
type<T>, R, V virtual_function_ptr, D default_implementation
)
{
// We can't just use "typename R::Type" below because MSVC (incorrectly) pukes.
typedef typename R::type return_type;
return new virtual_function<T, return_type, V, D>(
virtual_function_ptr, default_implementation);
}
// Create and return a new virtual_function object wrapping the given
// virtual_function_ptr and default_implementation
template <class T, class V, class D>
inline function* new_virtual_function(
type<T>, V virtual_function_ptr, D default_implementation
)
{
// Deduce the return type and pass it off to the helper function above
return new_virtual_function_aux(
type<T>(), return_value(virtual_function_ptr),
virtual_function_ptr, default_implementation);
}
// A function with a bundled "bound target" object. This is what is produced by
// the expression a.b where a is an instance or extension_instance object and b
// is a callable object not found in the obj namespace but on its class or
// a base class.
class BOOST_PYTHON_DECL bound_function : public python_object
{
public:
static bound_function* create(const ref& target, const ref& fn);
bound_function(const ref& target, const ref& fn);
PyObject* call(PyObject*args, PyObject* keywords) const;
PyObject* getattr(const char* name) const;
private:
struct type_object;
friend struct type_object;
ref m_target;
ref m_unbound_function;
private: // data members for allocation/deallocation optimization
bound_function* m_free_list_link;
static bound_function* free_list;
};
// Special functions designed to access data members of a wrapped C++ object.
template <class ClassType, class MemberType>
class getter_function : public function
{
public:
typedef MemberType ClassType::* pointer_to_member;
getter_function(pointer_to_member pm)
: m_pm(pm) {}
private:
PyObject* do_call(PyObject* args, PyObject* keywords) const;
const char* description() const
{ return typeid(MemberType (*)(const ClassType&)).name(); }
private:
pointer_to_member m_pm;
};
template <class ClassType, class MemberType>
class setter_function : public function
{
public:
typedef MemberType ClassType::* pointer_to_member;
setter_function(pointer_to_member pm)
: m_pm(pm) {}
private:
PyObject* do_call(PyObject* args, PyObject* keywords) const;
const char* description() const
{ return typeid(void (*)(const ClassType&, const MemberType&)).name(); }
private:
pointer_to_member m_pm;
};
template <class ClassType, class MemberType>
PyObject* getter_function<ClassType, MemberType>::do_call(
PyObject* args, PyObject* /* keywords */) const
{
PyObject* self;
if (!PyArg_ParseTuple(args, const_cast<char*>("O"), &self))
return 0;
return to_python(
from_python(self, type<const ClassType*>())->*m_pm);
}
template <class ClassType, class MemberType>
PyObject* setter_function<ClassType, MemberType>::do_call(
PyObject* args, PyObject* /* keywords */) const
{
PyObject* self;
PyObject* value;
if (!PyArg_ParseTuple(args, const_cast<char*>("OO"), &self, &value))
return 0;
typedef typename boost::call_traits<MemberType>::const_reference extract_type;
from_python(self, type<ClassType*>())->*m_pm
= from_python(value, type<extract_type>());
return none();
}
template <class T, class R, class V, class D>
PyObject* virtual_function<T,R,V,D>::do_call(PyObject* args, PyObject* keywords) const
{
// If the target object is held by pointer, we must call through the virtual
// function pointer to the most-derived override.
PyObject* target = PyTuple_GetItem(args, 0);
if (target != 0)
{
extension_instance* self = get_extension_instance(target);
if (self->wrapped_objects().size() == 1
&& !self->wrapped_objects()[0]->held_by_value())
{
return caller<R>::call(m_virtual_function_ptr, args, keywords);
}
}
return caller<R>::call(m_default_implementation, args, keywords);
}
}}} // namespace boost::python::detail
#endif // FUNCTIONS_DWA051400_H_

View File

@@ -1,117 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef IF_ELSE_DWA2002322_HPP
# define IF_ELSE_DWA2002322_HPP
# include <boost/config.hpp>
namespace boost { namespace python { namespace detail {
template <class T> struct elif_selected;
template <class T>
struct if_selected
{
template <bool b>
struct elif : elif_selected<T>
{
};
template <class U>
struct else_
{
typedef T type;
};
};
# if defined(BOOST_MSVC) && (BOOST_MSVC == 1300)
namespace msvc70_aux {
template< bool > struct inherit_from
{
template< typename T > struct result
{
typedef T type;
};
};
template<> struct inherit_from<true>
{
template< typename T > struct result
{
struct type {};
};
};
template< typename T >
struct never_true
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
} // namespace msvc70_aux
#endif // # if defined(BOOST_MSVC) && (BOOST_MSVC == 1300)
template <class T>
struct elif_selected
{
# if !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300 || defined(__MWERKS__) && __MWERKS__ <= 0x2407)
template <class U> class then;
# elif defined(BOOST_MSVC) && (BOOST_MSVC == 1300)
template <class U>
struct then : msvc70_aux::inherit_from< msvc70_aux::never_true<U>::value >
::template result< if_selected<T> >::type
{
};
# else
template <class U>
struct then : if_selected<T>
{
};
# endif
};
# if !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300 || defined(__MWERKS__) && __MWERKS__ <= 0x2407)
template <class T>
template <class U>
class elif_selected<T>::then : public if_selected<T>
{
};
# endif
template <bool b> struct if_
{
template <class T>
struct then : if_selected<T>
{
};
};
struct if_unselected
{
template <bool b> struct elif : if_<b>
{
};
template <class U>
struct else_
{
typedef U type;
};
};
template <>
struct if_<false>
{
template <class T>
struct then : if_unselected
{
};
};
}}} // namespace boost::python::detail
#endif // IF_ELSE_DWA2002322_HPP

View File

@@ -1,395 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef INDIRECT_TRAITS_DWA2002131_HPP
# define INDIRECT_TRAITS_DWA2002131_HPP
# include <boost/type_traits/is_function.hpp>
# include <boost/type_traits/detail/ice_and.hpp>
# include <boost/type_traits/is_reference.hpp>
# include <boost/type_traits/is_pointer.hpp>
# include <boost/type_traits/is_class.hpp>
# include <boost/type_traits/is_const.hpp>
# include <boost/type_traits/is_volatile.hpp>
# include <boost/type_traits/remove_cv.hpp>
# include <boost/type_traits/remove_reference.hpp>
# include <boost/type_traits/remove_pointer.hpp>
# include <boost/mpl/if.hpp>
namespace boost { namespace python { namespace detail {
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class T>
struct is_reference_to_const
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
template <class T>
struct is_reference_to_const<T const&>
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
# if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround
template<class T>
struct is_reference_to_const<T const volatile&>
{
static const bool value = true;
};
# endif
# if 0 // Corresponding code doesn't work on MSVC yet
template <class T>
struct is_reference_to_function
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
template <class T>
struct is_reference_to_function<T&>
{
BOOST_STATIC_CONSTANT(bool, value = is_function<T>::value);
};
template <class T>
struct is_reference_to_function<T const&>
{
BOOST_STATIC_CONSTANT(bool, value = is_function<T>::value);
};
template <class T>
struct is_reference_to_function<T volatile&>
{
BOOST_STATIC_CONSTANT(bool, value = is_function<T>::value);
};
template <class T>
struct is_reference_to_function<T const volatile&>
{
BOOST_STATIC_CONSTANT(bool, value = is_function<T>::value);
};
# endif
template <class T>
struct is_pointer_to_function
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
template <class T>
struct is_pointer_to_function<T*>
{
// There's no such thing as a pointer-to-cv-function, so we don't need specializations for those
BOOST_STATIC_CONSTANT(bool, value = is_function<T>::value);
};
template <class T>
struct is_reference_to_non_const
{
BOOST_STATIC_CONSTANT(
bool, value = (
::boost::type_traits::ice_and<
::boost::is_reference<T>::value
, ::boost::type_traits::ice_not<
::boost::python::detail::is_reference_to_const<T>::value>::value
>::value)
);
};
template <class T>
struct is_reference_to_volatile
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
template <class T>
struct is_reference_to_volatile<T volatile&>
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
# if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround
template <class T>
struct is_reference_to_volatile<T const volatile&>
{
static const bool value = true;
};
# endif
template <class T>
struct is_reference_to_pointer
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
template <class T>
struct is_reference_to_pointer<T*&>
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
template <class T>
struct is_reference_to_pointer<T* const&>
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
template <class T>
struct is_reference_to_pointer<T* volatile&>
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
template <class T>
struct is_reference_to_pointer<T* const volatile&>
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
template <class T>
struct is_reference_to_class
{
BOOST_STATIC_CONSTANT(
bool, value
= (boost::type_traits::ice_and<
is_reference<T>::value
, is_class<
typename remove_cv<
typename remove_reference<T>::type
>::type
>::value
>::value)
);
};
template <class T>
struct is_pointer_to_class
{
BOOST_STATIC_CONSTANT(
bool, value
= (boost::type_traits::ice_and<
is_pointer<T>::value
, is_class<
typename remove_cv<
typename remove_pointer<T>::type
>::type
>::value
>::value)
);
};
# else
typedef char (&inner_yes_type)[3];
typedef char (&inner_no_type)[2];
typedef char (&outer_no_type)[1];
template <typename V>
struct is_const_help
{
typedef typename mpl::if_c<
is_const<V>::value
, inner_yes_type
, inner_no_type
>::type type;
};
template <typename V>
struct is_volatile_help
{
typedef typename mpl::if_c<
is_volatile<V>::value
, inner_yes_type
, inner_no_type
>::type type;
};
template <typename V>
struct is_pointer_help
{
typedef typename mpl::if_c<
is_pointer<V>::value
, inner_yes_type
, inner_no_type
>::type type;
};
template <typename V>
struct is_class_help
{
typedef typename mpl::if_c<
is_class<V>::value
, inner_yes_type
, inner_no_type
>::type type;
};
# if 0 // doesn't seem to work yet
template <class T>
struct is_reference_to_function
{
static T t;
BOOST_STATIC_CONSTANT(
bool, value
= sizeof(::boost::type_traits::is_function_ptr_tester(t)) == sizeof(::boost::type_traits::yes_type));
# endif
template <class T>
struct is_pointer_to_function
{
static T t;
BOOST_STATIC_CONSTANT(
bool, value
= sizeof(::boost::type_traits::is_function_ptr_tester(t)) == sizeof(::boost::type_traits::yes_type));
};
struct false_helper1
{
template <class T>
struct apply
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
};
template <typename V>
typename is_const_help<V>::type reference_to_const_helper(V&);
outer_no_type
reference_to_const_helper(...);
template <bool ref = true>
struct is_reference_to_const_helper1
{
template <class T>
struct apply
{
static T t;
BOOST_STATIC_CONSTANT(
bool, value
= sizeof(reference_to_const_helper(t)) == sizeof(inner_yes_type));
};
};
template <>
struct is_reference_to_const_helper1<false> : false_helper1
{
};
template <class T>
struct is_reference_to_const
: is_reference_to_const_helper1<is_reference<T>::value>::template apply<T>
{
};
template <bool ref = true>
struct is_reference_to_non_const_helper1
{
template <class T>
struct apply
{
static T t;
BOOST_STATIC_CONSTANT(
bool, value
= sizeof(reference_to_const_helper(t)) == sizeof(inner_no_type));
};
};
template <>
struct is_reference_to_non_const_helper1<false> : false_helper1
{
};
template <class T>
struct is_reference_to_non_const
: is_reference_to_non_const_helper1<is_reference<T>::value>::template apply<T>
{
};
template <typename V>
typename is_volatile_help<V>::type reference_to_volatile_helper(V&);
outer_no_type
reference_to_volatile_helper(...);
template <bool ref = true>
struct is_reference_to_volatile_helper1
{
template <class T>
struct apply
{
static T t;
BOOST_STATIC_CONSTANT(
bool, value
= sizeof(reference_to_volatile_helper(t)) == sizeof(inner_yes_type));
};
};
template <>
struct is_reference_to_volatile_helper1<false> : false_helper1
{
};
template <class T>
struct is_reference_to_volatile
: is_reference_to_volatile_helper1<is_reference<T>::value>::template apply<T>
{
};
template <typename V>
typename is_pointer_help<V>::type reference_to_pointer_helper(V&);
outer_no_type reference_to_pointer_helper(...);
template <class T>
struct is_reference_to_pointer
{
static T t;
BOOST_STATIC_CONSTANT(
bool, value
= (is_reference<T>::value
&& sizeof(reference_to_pointer_helper(t)) == sizeof(inner_yes_type))
);
};
template <typename V>
typename is_class_help<V>::type reference_to_class_helper(V const volatile&);
outer_no_type reference_to_class_helper(...);
template <class T>
struct is_reference_to_class
{
static T t;
BOOST_STATIC_CONSTANT(
bool, value
= (is_reference<T>::value
&& sizeof(reference_to_class_helper(t)) == sizeof(inner_yes_type))
);
};
template <typename V>
typename is_class_help<V>::type pointer_to_class_helper(V const volatile*);
outer_no_type pointer_to_class_helper(...);
template <class T>
struct is_pointer_to_class
{
static T t;
BOOST_STATIC_CONSTANT(
bool, value
= (is_pointer<T>::value
&& sizeof(pointer_to_class_helper(t)) == sizeof(inner_yes_type))
);
};
# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
}}} // namespace boost::python::detail
#endif // INDIRECT_TRAITS_DWA2002131_HPP

View File

@@ -1,562 +0,0 @@
// (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// The author gratefully acknowleges the support of Dragon Systems, Inc., in
// producing this work.
//
// This file was generated for %d-argument constructors by gen_init_function.python
#ifndef INIT_FUNCTION_DWA052000_H_
# define INIT_FUNCTION_DWA052000_H_
# include <boost/python/detail/config.hpp>
# include <boost/python/detail/functions.hpp>
# include <boost/python/detail/signatures.hpp>
# include <typeinfo>
namespace boost { namespace python {
namespace detail {
// parameter_traits - so far, this is a way to pass a const T& when we can be
// sure T is not a reference type, and a raw T otherwise. This should be
// rolled into boost::call_traits. Ordinarily, parameter_traits would be
// written:
//
// template <class T> struct parameter_traits
// {
// typedef const T& const_reference;
// };
//
// template <class T> struct parameter_traits<T&>
// {
// typedef T& const_reference;
// };
//
// template <> struct parameter_traits<void>
// {
// typedef void const_reference;
// };
//
// ...but since we can't partially specialize on reference types, we need this
// long-winded but equivalent incantation.
// const_ref_selector -- an implementation detail of parameter_traits (below). This uses
// the usual "poor man's partial specialization" hack for MSVC.
template <bool is_ref>
struct const_ref_selector
{
template <class T>
struct const_ref
{
typedef const T& type;
};
};
template <>
struct const_ref_selector<true>
{
template <class T>
struct const_ref
{
typedef T type;
};
};
# ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable: 4181)
# endif // BOOST_MSVC
template <class T>
struct parameter_traits
{
private:
enum { is_ref = boost::is_reference<T>::value };
typedef const_ref_selector<is_ref> selector;
public:
typedef typename selector::template const_ref<T>::type const_reference;
};
# ifdef BOOST_MSVC
# pragma warning(pop)
# endif // BOOST_MSVC
// Full spcialization for void
template <>
struct parameter_traits<void>
{
typedef void const_reference;
};
struct reference_parameter_base {};
template <class T>
class reference_parameter
: public reference_parameter_base
{
public:
typedef typename parameter_traits<T>::const_reference const_reference;
reference_parameter(const_reference value)
: value(value) {}
operator const_reference() { return value; }
private:
const_reference value;
};
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class T>
struct unwrap_parameter
{
typedef typename boost::add_reference<T>::type type;
};
template <class T>
struct unwrap_parameter<reference_parameter<T> >
{
typedef typename reference_parameter<T>::const_reference type;
};
# else
template <bool is_wrapped>
struct unwrap_parameter_helper
{
template <class T>
struct apply
{
typedef typename T::const_reference type;
};
};
template <>
struct unwrap_parameter_helper<false>
{
template <class T>
struct apply
{
typedef typename add_reference<T>::type type;
};
};
template <class T>
struct unwrap_parameter
{
BOOST_STATIC_CONSTANT(
bool, is_wrapped = (is_base_and_derived<T,reference_parameter_base>::value));
typedef typename unwrap_parameter_helper<
is_wrapped
>::template apply<T>::type type;
};
# endif
class extension_instance;
class instance_holder_base;
class init;
template <class T> struct init0;
template <class T, class A1> struct init1;
template <class T, class A1, class A2> struct init2;
template <class T, class A1, class A2, class A3> struct init3;
template <class T, class A1, class A2, class A3, class A4> struct init4;
template <class T, class A1, class A2, class A3, class A4, class A5> struct init5;
template <class T, class A1, class A2, class A3, class A4, class A5, class A6> struct init6;
template <class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> struct init7;
template <class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> struct init8;
template <class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> struct init9;
template <class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> struct init10;
template <class T>
struct init_function
{
# ifdef BOOST_MSVC6_OR_EARLIER
# define typename
# endif
static init* create(signature0) {
return new init0<T>;
}
template <class A1>
static init* create(signature1<A1>) {
return new init1<T,
typename detail::parameter_traits<A1>::const_reference>;
}
template <class A1, class A2>
static init* create(signature2<A1, A2>) {
return new init2<T,
typename detail::parameter_traits<A1>::const_reference,
typename detail::parameter_traits<A2>::const_reference>;
}
template <class A1, class A2, class A3>
static init* create(signature3<A1, A2, A3>) {
return new init3<T,
typename detail::parameter_traits<A1>::const_reference,
typename detail::parameter_traits<A2>::const_reference,
typename detail::parameter_traits<A3>::const_reference>;
}
template <class A1, class A2, class A3, class A4>
static init* create(signature4<A1, A2, A3, A4>) {
return new init4<T,
typename detail::parameter_traits<A1>::const_reference,
typename detail::parameter_traits<A2>::const_reference,
typename detail::parameter_traits<A3>::const_reference,
typename detail::parameter_traits<A4>::const_reference>;
}
template <class A1, class A2, class A3, class A4, class A5>
static init* create(signature5<A1, A2, A3, A4, A5>) {
return new init5<T,
typename detail::parameter_traits<A1>::const_reference,
typename detail::parameter_traits<A2>::const_reference,
typename detail::parameter_traits<A3>::const_reference,
typename detail::parameter_traits<A4>::const_reference,
typename detail::parameter_traits<A5>::const_reference>;
}
template <class A1, class A2, class A3, class A4, class A5, class A6>
static init* create(signature6<A1, A2, A3, A4, A5, A6>) {
return new init6<T,
typename detail::parameter_traits<A1>::const_reference,
typename detail::parameter_traits<A2>::const_reference,
typename detail::parameter_traits<A3>::const_reference,
typename detail::parameter_traits<A4>::const_reference,
typename detail::parameter_traits<A5>::const_reference,
typename detail::parameter_traits<A6>::const_reference>;
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
static init* create(signature7<A1, A2, A3, A4, A5, A6, A7>) {
return new init7<T,
typename detail::parameter_traits<A1>::const_reference,
typename detail::parameter_traits<A2>::const_reference,
typename detail::parameter_traits<A3>::const_reference,
typename detail::parameter_traits<A4>::const_reference,
typename detail::parameter_traits<A5>::const_reference,
typename detail::parameter_traits<A6>::const_reference,
typename detail::parameter_traits<A7>::const_reference>;
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
static init* create(signature8<A1, A2, A3, A4, A5, A6, A7, A8>) {
return new init8<T,
typename detail::parameter_traits<A1>::const_reference,
typename detail::parameter_traits<A2>::const_reference,
typename detail::parameter_traits<A3>::const_reference,
typename detail::parameter_traits<A4>::const_reference,
typename detail::parameter_traits<A5>::const_reference,
typename detail::parameter_traits<A6>::const_reference,
typename detail::parameter_traits<A7>::const_reference,
typename detail::parameter_traits<A8>::const_reference>;
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
static init* create(signature9<A1, A2, A3, A4, A5, A6, A7, A8, A9>) {
return new init9<T,
typename detail::parameter_traits<A1>::const_reference,
typename detail::parameter_traits<A2>::const_reference,
typename detail::parameter_traits<A3>::const_reference,
typename detail::parameter_traits<A4>::const_reference,
typename detail::parameter_traits<A5>::const_reference,
typename detail::parameter_traits<A6>::const_reference,
typename detail::parameter_traits<A7>::const_reference,
typename detail::parameter_traits<A8>::const_reference,
typename detail::parameter_traits<A9>::const_reference>;
}
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
static init* create(signature10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>) {
return new init10<T,
typename detail::parameter_traits<A1>::const_reference,
typename detail::parameter_traits<A2>::const_reference,
typename detail::parameter_traits<A3>::const_reference,
typename detail::parameter_traits<A4>::const_reference,
typename detail::parameter_traits<A5>::const_reference,
typename detail::parameter_traits<A6>::const_reference,
typename detail::parameter_traits<A7>::const_reference,
typename detail::parameter_traits<A8>::const_reference,
typename detail::parameter_traits<A9>::const_reference,
typename detail::parameter_traits<A10>::const_reference>;
}
#ifdef BOOST_MSVC6_OR_EARLIER
# undef typename
#endif
};
class BOOST_PYTHON_DECL init : public function
{
private: // override function hook
PyObject* do_call(PyObject* args, PyObject* keywords) const;
private:
virtual instance_holder_base* create_holder(extension_instance* self, PyObject* tail_args, PyObject* keywords) const = 0;
};
template <class T>
struct init0 : init
{
virtual instance_holder_base* create_holder(extension_instance* self, PyObject* args, PyObject* /*keywords*/) const
{
if (!PyArg_ParseTuple(args, const_cast<char*>("")))
throw_argument_error();
return new T(self
);
}
const char* description() const
{ return typeid(void (*)(T&)).name(); }
};
template <class T, class A1>
struct init1 : init
{
virtual instance_holder_base* create_holder(extension_instance* self, PyObject* args, PyObject* /*keywords*/) const
{
PyObject* a1;
if (!PyArg_ParseTuple(args, const_cast<char*>("O"), &a1))
throw_argument_error();
return new T(self,
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>()))
);
}
const char* description() const
{ return typeid(void (*)(T&, A1)).name(); }
};
template <class T, class A1, class A2>
struct init2 : init
{
virtual instance_holder_base* create_holder(extension_instance* self, PyObject* args, PyObject* /*keywords*/) const
{
PyObject* a1;
PyObject* a2;
if (!PyArg_ParseTuple(args, const_cast<char*>("OO"), &a1, &a2))
throw_argument_error();
return new T(self,
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>()))
);
}
const char* description() const
{ return typeid(void (*)(T&, A1, A2)).name(); }
};
template <class T, class A1, class A2, class A3>
struct init3 : init
{
virtual instance_holder_base* create_holder(extension_instance* self, PyObject* args, PyObject* /*keywords*/) const
{
PyObject* a1;
PyObject* a2;
PyObject* a3;
if (!PyArg_ParseTuple(args, const_cast<char*>("OOO"), &a1, &a2, &a3))
throw_argument_error();
return new T(self,
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>())),
boost::python::detail::reference_parameter<A3>(from_python(a3, type<A3>()))
);
}
const char* description() const
{ return typeid(void (*)(T&, A1, A2, A3)).name(); }
};
template <class T, class A1, class A2, class A3, class A4>
struct init4 : init
{
virtual instance_holder_base* create_holder(extension_instance* self, PyObject* args, PyObject* /*keywords*/) const
{
PyObject* a1;
PyObject* a2;
PyObject* a3;
PyObject* a4;
if (!PyArg_ParseTuple(args, const_cast<char*>("OOOO"), &a1, &a2, &a3, &a4))
throw_argument_error();
return new T(self,
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>())),
boost::python::detail::reference_parameter<A3>(from_python(a3, type<A3>())),
boost::python::detail::reference_parameter<A4>(from_python(a4, type<A4>()))
);
}
const char* description() const
{ return typeid(void (*)(T&, A1, A2, A3, A4)).name(); }
};
template <class T, class A1, class A2, class A3, class A4, class A5>
struct init5 : init
{
virtual instance_holder_base* create_holder(extension_instance* self, PyObject* args, PyObject* /*keywords*/) const
{
PyObject* a1;
PyObject* a2;
PyObject* a3;
PyObject* a4;
PyObject* a5;
if (!PyArg_ParseTuple(args, const_cast<char*>("OOOOO"), &a1, &a2, &a3, &a4, &a5))
throw_argument_error();
return new T(self,
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>())),
boost::python::detail::reference_parameter<A3>(from_python(a3, type<A3>())),
boost::python::detail::reference_parameter<A4>(from_python(a4, type<A4>())),
boost::python::detail::reference_parameter<A5>(from_python(a5, type<A5>()))
);
}
const char* description() const
{ return typeid(void (*)(T&, A1, A2, A3, A4, A5)).name(); }
};
template <class T, class A1, class A2, class A3, class A4, class A5, class A6>
struct init6 : init
{
virtual instance_holder_base* create_holder(extension_instance* self, PyObject* args, PyObject* /*keywords*/) const
{
PyObject* a1;
PyObject* a2;
PyObject* a3;
PyObject* a4;
PyObject* a5;
PyObject* a6;
if (!PyArg_ParseTuple(args, const_cast<char*>("OOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6))
throw_argument_error();
return new T(self,
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>())),
boost::python::detail::reference_parameter<A3>(from_python(a3, type<A3>())),
boost::python::detail::reference_parameter<A4>(from_python(a4, type<A4>())),
boost::python::detail::reference_parameter<A5>(from_python(a5, type<A5>())),
boost::python::detail::reference_parameter<A6>(from_python(a6, type<A6>()))
);
}
const char* description() const
{ return typeid(void (*)(T&, A1, A2, A3, A4, A5, A6)).name(); }
};
template <class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
struct init7 : init
{
virtual instance_holder_base* create_holder(extension_instance* self, PyObject* args, PyObject* /*keywords*/) const
{
PyObject* a1;
PyObject* a2;
PyObject* a3;
PyObject* a4;
PyObject* a5;
PyObject* a6;
PyObject* a7;
if (!PyArg_ParseTuple(args, const_cast<char*>("OOOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6, &a7))
throw_argument_error();
return new T(self,
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>())),
boost::python::detail::reference_parameter<A3>(from_python(a3, type<A3>())),
boost::python::detail::reference_parameter<A4>(from_python(a4, type<A4>())),
boost::python::detail::reference_parameter<A5>(from_python(a5, type<A5>())),
boost::python::detail::reference_parameter<A6>(from_python(a6, type<A6>())),
boost::python::detail::reference_parameter<A7>(from_python(a7, type<A7>()))
);
}
const char* description() const
{ return typeid(void (*)(T&, A1, A2, A3, A4, A5, A6, A7)).name(); }
};
template <class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
struct init8 : init
{
virtual instance_holder_base* create_holder(extension_instance* self, PyObject* args, PyObject* /*keywords*/) const
{
PyObject* a1;
PyObject* a2;
PyObject* a3;
PyObject* a4;
PyObject* a5;
PyObject* a6;
PyObject* a7;
PyObject* a8;
if (!PyArg_ParseTuple(args, const_cast<char*>("OOOOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8))
throw_argument_error();
return new T(self,
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>())),
boost::python::detail::reference_parameter<A3>(from_python(a3, type<A3>())),
boost::python::detail::reference_parameter<A4>(from_python(a4, type<A4>())),
boost::python::detail::reference_parameter<A5>(from_python(a5, type<A5>())),
boost::python::detail::reference_parameter<A6>(from_python(a6, type<A6>())),
boost::python::detail::reference_parameter<A7>(from_python(a7, type<A7>())),
boost::python::detail::reference_parameter<A8>(from_python(a8, type<A8>()))
);
}
const char* description() const
{ return typeid(void (*)(T&, A1, A2, A3, A4, A5, A6, A7, A8)).name(); }
};
template <class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
struct init9 : init
{
virtual instance_holder_base* create_holder(extension_instance* self, PyObject* args, PyObject* /*keywords*/) const
{
PyObject* a1;
PyObject* a2;
PyObject* a3;
PyObject* a4;
PyObject* a5;
PyObject* a6;
PyObject* a7;
PyObject* a8;
PyObject* a9;
if (!PyArg_ParseTuple(args, const_cast<char*>("OOOOOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9))
throw_argument_error();
return new T(self,
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>())),
boost::python::detail::reference_parameter<A3>(from_python(a3, type<A3>())),
boost::python::detail::reference_parameter<A4>(from_python(a4, type<A4>())),
boost::python::detail::reference_parameter<A5>(from_python(a5, type<A5>())),
boost::python::detail::reference_parameter<A6>(from_python(a6, type<A6>())),
boost::python::detail::reference_parameter<A7>(from_python(a7, type<A7>())),
boost::python::detail::reference_parameter<A8>(from_python(a8, type<A8>())),
boost::python::detail::reference_parameter<A9>(from_python(a9, type<A9>()))
);
}
const char* description() const
{ return typeid(void (*)(T&, A1, A2, A3, A4, A5, A6, A7, A8, A9)).name(); }
};
template <class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
struct init10 : init
{
virtual instance_holder_base* create_holder(extension_instance* self, PyObject* args, PyObject* /*keywords*/) const
{
PyObject* a1;
PyObject* a2;
PyObject* a3;
PyObject* a4;
PyObject* a5;
PyObject* a6;
PyObject* a7;
PyObject* a8;
PyObject* a9;
PyObject* a10;
if (!PyArg_ParseTuple(args, const_cast<char*>("OOOOOOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9, &a10))
throw_argument_error();
return new T(self,
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>())),
boost::python::detail::reference_parameter<A3>(from_python(a3, type<A3>())),
boost::python::detail::reference_parameter<A4>(from_python(a4, type<A4>())),
boost::python::detail::reference_parameter<A5>(from_python(a5, type<A5>())),
boost::python::detail::reference_parameter<A6>(from_python(a6, type<A6>())),
boost::python::detail::reference_parameter<A7>(from_python(a7, type<A7>())),
boost::python::detail::reference_parameter<A8>(from_python(a8, type<A8>())),
boost::python::detail::reference_parameter<A9>(from_python(a9, type<A9>())),
boost::python::detail::reference_parameter<A10>(from_python(a10, type<A10>()))
);
}
const char* description() const
{ return typeid(void (*)(T&, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)).name(); }
};
}}} // namespace boost::python::detail
#endif // INIT_FUNCTION_DWA052000_H_

View File

@@ -1,31 +0,0 @@
# // Copyright David Abrahams 2002. Permission to copy, use,
# // modify, sell and distribute this software is granted provided this
# // copyright notice appears in all copies. This software is provided
# // "as is" without express or implied warranty, and with no claim as
# // to its suitability for any purpose.
#if !defined(BOOST_PP_IS_ITERATING)
# error Boost.Python - do not include this file!
#endif
#define N BOOST_PP_ITERATION()
#define BOOST_PYTHON_MAKE_TUPLE_ARG(z, N, ignored) \
PyTuple_SET_ITEM( \
result.ptr() \
, N \
, python::incref(python::object(a##N).ptr()) \
);
template <BOOST_PYTHON_UNARY_ENUM(N, class A)>
tuple
make_tuple(BOOST_PYTHON_BINARY_ENUM(N, A, const& a))
{
tuple result((detail::new_reference)::PyTuple_New(N));
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_MAKE_TUPLE_ARG, _)
return result;
}
#undef BOOST_PYTHON_MAKE_TUPLE_ARG
#undef N

View File

@@ -1,44 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef MAP_ENTRY_DWA2002118_HPP
# define MAP_ENTRY_DWA2002118_HPP
namespace boost { namespace python { namespace detail {
// A trivial type that works well as the value_type of associative
// vector maps
template <class Key, class Value>
struct map_entry
{
map_entry() {}
map_entry(Key k) : key(k), value() {}
map_entry(Key k, Value v) : key(k), value(v) {}
bool operator<(map_entry const& rhs) const
{
return this->key < rhs.key;
}
Key key;
Value value;
};
template <class Key, class Value>
bool operator<(map_entry<Key,Value> const& e, Key const& k)
{
return e.key < k;
}
template <class Key, class Value>
bool operator<(Key const& k, map_entry<Key,Value> const& e)
{
return k < e.key;
}
}}} // namespace boost::python::detail
#endif // MAP_ENTRY_DWA2002118_HPP

View File

@@ -1,113 +0,0 @@
#if !defined(BOOST_PP_IS_ITERATING)
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
# ifndef MEMBER_FUNCTION_CAST_DWA2002311_HPP
# define MEMBER_FUNCTION_CAST_DWA2002311_HPP
# include <boost/python/detail/preprocessor.hpp>
# include <boost/mpl/if.hpp>
# include <boost/type_traits/composite_traits.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/preprocessor/debug/line.hpp>
namespace boost { namespace python { namespace detail {
template <class S, class FT>
struct cast_helper
{
struct yes_helper
{
static FT stage3(FT x) { return x; }
};
struct no_helper
{
template <class T>
static T stage3(T x) { return x; }
};
static yes_helper stage2(S*) { return yes_helper(); }
static no_helper stage2(void*) { return no_helper(); }
};
struct non_member_function_cast_impl
{
template <class T>
static non_member_function_cast_impl stage1(T) { return non_member_function_cast_impl(); }
template <class T>
static non_member_function_cast_impl stage2(T) { return non_member_function_cast_impl(); }
template <class T>
T stage3(T x) { return x; }
};
template <class T>
struct member_function_cast_impl
{
# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template <class U>
static non_member_function_cast_impl stage1(U)
{
return non_member_function_cast_impl();
}
# endif
// Member functions
# define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 3, <boost/python/detail/member_function_cast.hpp>))
# include BOOST_PP_ITERATE()
};
template <class T, class SF>
struct member_function_cast
# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
: member_function_cast_impl<T>
# else
: mpl::if_c<
is_member_function_pointer<SF>::value
, member_function_cast_impl<T>
, non_member_function_cast_impl
>::type
# endif
{
};
}}} // namespace boost::python::detail
# endif // MEMBER_FUNCTION_CAST_DWA2002311_HPP
#elif BOOST_PP_ITERATION_DEPTH() == 1
// outer over cv-qualifiers
# define BOOST_PP_ITERATION_PARAMS_2 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/member_function_cast.hpp>))
# include BOOST_PP_ITERATE()
#elif BOOST_PP_ITERATION_DEPTH() == 2
# line BOOST_PP_LINE(__LINE__, member_function_cast.hpp)
// inner over arities
# define N BOOST_PP_ITERATION()
# define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
template <
class S, class R
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)
>
static cast_helper<S, R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q>
stage1(R (S::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q)
{
return cast_helper<S, R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q>();
}
# undef N
# undef Q
#endif

View File

@@ -1,45 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef MODULE_BASE_DWA2002227_HPP
# define MODULE_BASE_DWA2002227_HPP
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/handle.hpp>
# include <boost/python/object_fwd.hpp>
namespace boost { namespace python { namespace detail {
class BOOST_PYTHON_DECL module_base
{
public:
// Create a module. REQUIRES: only one module is created per module.
module_base(char const* name, char const* doc = 0);
~module_base();
// Add elements to the module
void add(type_handle const&); // just use the type's name
// Return a reference to the Python module object being built
inline handle<> object() const;
protected:
void setattr_doc(const char* name, python::object const&, char const* doc);
private:
handle<> m_module;
static PyMethodDef initial_methods[1];
};
//
// inline implementations
//
inline handle<> module_base::object() const
{
return m_module;
}
}}} // namespace boost::python::detail
#endif // MODULE_BASE_DWA2002227_HPP

View File

@@ -1,51 +0,0 @@
// Copyright David Hawkes 2002.
// Permission is hereby granted to copy, use and modify this software
// for any purpose, including commercial distribution, provided this
// copyright notice is not removed. No warranty WHATSOEVER is provided with this
// software. Any user(s) accepts this software "as is" and as such they will not
// bind the author(s) to any claim of suitabilty for any purpose.
#ifndef MODULE_INFO
# define MODULE_INFO
#include <boost/python/object.hpp>
namespace boost { namespace python { namespace detail {
class module_info
{
public:
module_info(const char *name)
{
m_module_name = name;
}
void set_module(object const& m)
{
if(!m_primary_module)
m_primary_module = m;
}
object const& get_module() const
{
return m_primary_module;
}
void set_prior_module(object const& m)
{
m_prior_module = m;
}
object const& get_prior_module() const
{
return m_prior_module;
}
const char* get_module_name() const
{
return m_module_name;
}
private:
object m_primary_module;
object m_prior_module;
const char* m_module_name;
};
}}}
#endif // MODULE_INFO

View File

@@ -1,53 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifdef BOOST_PYTHON_V2
# error obsolete
#endif
#ifndef MODULE_INIT_DWA2002529_HPP
# define MODULE_INIT_DWA2002529_HPP
# ifndef BOOST_PYTHON_MODULE_INIT
# if defined(_WIN32) || defined(__CYGWIN__)
# define BOOST_PYTHON_MODULE_INIT(name) \
void init_module_##name(); \
extern "C" __declspec(dllexport) void init##name() \
{ \
boost::python::handle_exception(&init_module_##name); \
} \
void init_module_##name()
# elif defined(_AIX)
# include <boost/python/detail/aix_init_module.hpp>
# define BOOST_PYTHON_MODULE_INIT(name) \
void init_module_##name(); \
extern "C" \
{ \
extern PyObject* _PyImport_LoadDynamicModule(char*, char*, FILE *); \
void init##name() \
{ \
boost::python::detail::aix_init_module(_PyImport_LoadDynamicModule, &init_module_##name); \
} \
} \
void init_module_##name()
# else
# define BOOST_PYTHON_MODULE_INIT(name) \
void init_module_##name(); \
extern "C" void init##name() \
{ \
boost::python::handle_exception(&init_module_##name); \
} \
void init_module_##name()
# endif
# endif
#endif // MODULE_INIT_DWA2002529_HPP

View File

@@ -1,102 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef MSVC_TYPEINFO_DWA200222_HPP
# define MSVC_TYPEINFO_DWA200222_HPP
#include <boost/type.hpp>
#include <typeinfo>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_volatile.hpp>
//
// Fix for MSVC's broken typeid() implementation which doesn't strip
// decoration. This fix doesn't handle cv-qualified array types. It
// could probably be done, but I haven't figured it out yet.
//
# if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 || defined(BOOST_INTEL_CXX_VERSION) && BOOST_INTEL_CXX_VERSION <= 600
namespace boost { namespace python { namespace detail {
typedef std::type_info const& typeinfo;
template<int>struct value_id_accessor;
template<>
struct value_id_accessor<0>
{
template <class T>
static typeinfo get(T*) { return typeid(T); }
};
template<>
struct value_id_accessor<1>
{
template <class T>
static typeinfo get(T const*) { return typeid(T); }
};
template<>
struct value_id_accessor<2>
{
template <class T>
static typeinfo get(T volatile*) { return typeid(T); }
};
template<>
struct value_id_accessor<3>
{
template <class T>
static typeinfo get(T const volatile*) { return typeid(T); }
};
template <bool> struct bool_t{};
template <class T>
inline typeinfo typeid_nonref(boost::type<T>* = 0)
{
bool const c = is_const<T>::value;
bool const v = is_volatile<T>::value;
return value_id_accessor<(2 * v + c)>::get((T*)0);
}
template <class T>
inline typeinfo typeid_ref(T&(*)())
{
return typeid_nonref<T>();
}
template <class T>
inline typeinfo array_ref_typeid(bool_t<true>, bool_t<false>, boost::type<T>* = 0)
{
return typeid_ref((T&(*)())0);
}
template <class T>
inline typeinfo array_ref_typeid(bool_t<false>, bool_t<true>, boost::type<T>* = 0)
{
return typeid_ref((T(*)())0);
}
template <class T>
inline typeinfo array_ref_typeid(bool_t<false>, bool_t<false>, boost::type<T>* = 0)
{
return typeid_ref((T&(*)())0);
}
template <class T>
inline typeinfo msvc_typeid(boost::type<T>* = 0)
{
typedef bool_t<is_array<T>::value> array_tag;
typedef bool_t<is_reference<T>::value> ref_tag;
return array_ref_typeid(array_tag(), ref_tag(), (boost::type<T>*)0);
}
}}} // namespace boost::python::detail
# endif // BOOST_MSVC
#endif // MSVC_TYPEINFO_DWA200222_HPP

View File

@@ -1,21 +0,0 @@
// (C) Copyright David Abrahams 2000. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// The author gratefully acknowleges the support of Dragon Systems, Inc., in
// producing this work.
#ifndef NONE_DWA_052000_H_
# define NONE_DWA_052000_H_
# include <boost/python/detail/config.hpp>
# include <boost/python/detail/wrap_python.hpp>
namespace boost { namespace python { namespace detail {
inline PyObject* none() { Py_INCREF(Py_None); return Py_None; }
}}} // namespace boost::python::detail
#endif // NONE_DWA_052000_H_

View File

@@ -1,15 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef NOT_SPECIFIED_DWA2002321_HPP
# define NOT_SPECIFIED_DWA2002321_HPP
namespace boost { namespace python { namespace detail {
struct not_specified {};
}}} // namespace boost::python::detail
#endif // NOT_SPECIFIED_DWA2002321_HPP

View File

@@ -1,55 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef OPERATOR_ID_DWA2002531_HPP
# define OPERATOR_ID_DWA2002531_HPP
namespace boost { namespace python { namespace detail {
enum operator_id
{
op_add,
op_sub,
op_mul,
op_div,
op_mod,
op_divmod,
op_pow,
op_lshift,
op_rshift,
op_and,
op_xor,
op_or,
op_neg,
op_pos,
op_abs,
op_invert,
op_int,
op_long,
op_float,
op_str,
op_cmp,
op_gt,
op_ge,
op_lt,
op_le,
op_eq,
op_ne,
op_iadd,
op_isub,
op_imul,
op_idiv,
op_imod,
op_ilshift,
op_irshift,
op_iand,
op_ixor,
op_ior,
op_complex
};
}}} // namespace boost::python::detail
#endif // OPERATOR_ID_DWA2002531_HPP

View File

@@ -1,36 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef POINTEE_DWA2002323_HPP
# define POINTEE_DWA2002323_HPP
# include <boost/type_traits/object_traits.hpp>
namespace boost { namespace python { namespace detail {
template <bool is_ptr = true>
struct pointee_impl
{
template <class T> struct apply : remove_pointer<T> {};
};
template <>
struct pointee_impl<false>
{
template <class T> struct apply
{
typedef typename T::element_type type;
};
};
template <class T>
struct pointee
: pointee_impl<is_pointer<T>::value>::template apply<T>
{
};
}}} // namespace boost::python::detail
#endif // POINTEE_DWA2002323_HPP

View File

@@ -1,67 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef PREPROCESSOR_DWA200247_HPP
# define PREPROCESSOR_DWA200247_HPP
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/repeat.hpp>
# include <boost/preprocessor/tuple/elem.hpp>
// stuff that should be in the preprocessor library
# define BOOST_PYTHON_APPLY(x) BOOST_PP_CAT(BOOST_PYTHON_APPLY_, x)
# define BOOST_PYTHON_APPLY_BOOST_PYTHON_ITEM(v) v
# define BOOST_PYTHON_APPLY_BOOST_PYTHON_NIL
// cv-qualifiers
# if !defined(__MWERKS__) || __MWERKS__ > 0x2407
# define BOOST_PYTHON_CV_COUNT 4
# else
# define BOOST_PYTHON_CV_COUNT 1
# endif
# ifndef BOOST_PYTHON_MAX_ARITY
# define BOOST_PYTHON_MAX_ARITY 15
# endif
# ifndef BOOST_PYTHON_MAX_BASES
# define BOOST_PYTHON_MAX_BASES 10
# endif
# define BOOST_PYTHON_CV_QUALIFIER(i) \
BOOST_PYTHON_APPLY( \
BOOST_PP_TUPLE_ELEM(4, i, BOOST_PYTHON_CV_QUALIFIER_I) \
)
# define BOOST_PYTHON_CV_QUALIFIER_I \
( \
BOOST_PYTHON_NIL, \
BOOST_PYTHON_ITEM(const), \
BOOST_PYTHON_ITEM(volatile), \
BOOST_PYTHON_ITEM(const volatile) \
)
// enumerators
# define BOOST_PYTHON_UNARY_ENUM(c, text) BOOST_PP_REPEAT(c, BOOST_PYTHON_UNARY_ENUM_I, text)
# define BOOST_PYTHON_UNARY_ENUM_I(z, n, text) BOOST_PP_COMMA_IF(n) text ## n
# define BOOST_PYTHON_BINARY_ENUM(c, a, b) BOOST_PP_REPEAT(c, BOOST_PYTHON_BINARY_ENUM_I, (a, b))
# define BOOST_PYTHON_BINARY_ENUM_I(z, n, _) BOOST_PP_COMMA_IF(n) BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, _), n) BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 1, _), n)
# define BOOST_PYTHON_ENUM_WITH_DEFAULT(c, text, def) BOOST_PP_REPEAT(c, BOOST_PYTHON_ENUM_WITH_DEFAULT_I, (text, def))
# define BOOST_PYTHON_ENUM_WITH_DEFAULT_I(z, n, _) BOOST_PP_COMMA_IF(n) BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, _), n) = BOOST_PP_TUPLE_ELEM(2, 1, _)
// fixed text (no commas)
# define BOOST_PYTHON_FIXED(z, n, text) text
// flags
# define BOOST_PYTHON_FUNCTION_POINTER 0x0001
# define BOOST_PYTHON_POINTER_TO_MEMBER 0x0002
#endif // PREPROCESSOR_DWA200247_HPP

View File

@@ -1,140 +0,0 @@
// Copy of Python 2.2/2.2.1 Python.h .
// Changes marked with "Boost.Python modification"
#ifndef Py_PYTHON_H
#define Py_PYTHON_H
/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */
/* Enable compiler features; switching on C lib defines doesn't work
here, because the symbols haven't necessarily been defined yet. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
/* Forcing SUSv2 compatibility still produces problems on some
platforms, True64 and SGI IRIX begin two of them, so for now the
define is switched off. */
#if 0
#ifndef _XOPEN_SOURCE
# define _XOPEN_SOURCE 500
#endif
#endif
/* Include nearly all Python header files */
#include "patchlevel.h"
#include "pyconfig.h"
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
/* pyconfig.h may or may not define DL_IMPORT */
#ifndef DL_IMPORT /* declarations for DLL import/export */
#define DL_IMPORT(RTYPE) RTYPE
#endif
#ifndef DL_EXPORT /* declarations for DLL import/export */
#define DL_EXPORT(RTYPE) RTYPE
#endif
#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE)
#define _SGI_MP_SOURCE
#endif
#include <stdio.h>
#ifndef NULL
# error "Python.h requires that stdio.h define NULL."
#endif
#include <string.h>
#include <errno.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if PY_MICRO_VERSION == 1 // Boost.Python modification: emulate Python 2.2
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#endif // Boost.Python modification: emulate Python 2.2
/* CAUTION: Build setups should ensure that NDEBUG is defined on the
* compiler command line when building Python in release mode; else
* assert() calls won't be removed.
*/
#include <assert.h>
#include "pyport.h"
#include "pymem.h"
#include "object.h"
#include "objimpl.h"
#include "pydebug.h"
#include "unicodeobject.h"
#include "intobject.h"
#include "longobject.h"
#include "floatobject.h"
#ifndef WITHOUT_COMPLEX
#include "complexobject.h"
#endif
#include "rangeobject.h"
#include "stringobject.h"
#include "bufferobject.h"
#include "tupleobject.h"
#include "listobject.h"
#include "dictobject.h"
#include "methodobject.h"
#include "moduleobject.h"
#include "funcobject.h"
#include "classobject.h"
#include "fileobject.h"
#include "cobject.h"
#include "traceback.h"
#include "sliceobject.h"
#include "cellobject.h"
extern "C" { // Boost.Python modification: provide missing extern "C"
#include "iterobject.h"
#include "descrobject.h"
} // Boost.Python modification: provide missing extern "C"
#include "weakrefobject.h"
#include "codecs.h"
#include "pyerrors.h"
#include "pystate.h"
#include "modsupport.h"
#include "pythonrun.h"
#include "ceval.h"
#include "sysmodule.h"
#include "intrcheck.h"
#include "import.h"
#include "abstract.h"
#define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a))
#define PyArg_NoArgs(v) PyArg_Parse(v, "")
/* Convert a possibly signed character to a nonnegative int */
/* XXX This assumes characters are 8 bits wide */
#ifdef __CHAR_UNSIGNED__
#define Py_CHARMASK(c) (c)
#else
#define Py_CHARMASK(c) ((c) & 0xff)
#endif
#include "pyfpe.h"
/* These definitions must match corresponding definitions in graminit.h.
There's code in compile.c that checks that they are the same. */
#define Py_single_input 256
#define Py_file_input 257
#define Py_eval_input 258
#ifdef HAVE_PTH
/* GNU pth user-space thread support */
#include <pth.h>
#endif
#endif /* !Py_PYTHON_H */

View File

@@ -1,183 +0,0 @@
#error obsolete
/*
*
* Copyright (c) 1998-2000
* Dr John Maddock
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Dr John Maddock makes no representations
* about the suitability of this software for any purpose.
* It is provided "as is" without express or implied warranty.
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE regex_libary_include.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Automatic library inclusion for Borland/Microsoft compilers.
* Note this is an internal header file included
* by regex.hpp, do not include on its own.
*/
#ifndef BOOST_REGEX_LIBRARY_INCLUDE_HPP
#define BOOST_REGEX_LIBRARY_INCLUDE_HPP
#ifndef BOOST_REGEX_NO_LIB
#if defined(BOOST_MSVC) && !defined(BOOST_REGEX_BUILD_DLL)
#ifdef __SGI_STL_PORT
#ifdef _DLL
// All these are multithreaded:
#if defined(_DEBUG) && defined(__STL_DEBUG)
#pragma comment(lib, "vc6-stlport-re300ddl.lib")
#elif defined(_DEBUG)
#pragma comment(lib, "vc6-stlport-re300dl.lib")
#elif defined(BOOST_REGEX_STATIC_LINK)
// static regex lib, dll runtime
#pragma comment(lib, "vc6-stlport-re300ls.lib")
#else // DEBUG
#pragma comment(lib, "vc6-stlport-re300l.lib")
#endif // _DEBUG
#else // _DLL
#ifdef _MT
#if defined(_DEBUG) && defined(__STL_DEBUG)
#pragma comment(lib, "vc6-stlport-re300ddm.lib")
#elif defined(_DEBUG)
#pragma comment(lib, "vc6-stlport-re300dm.lib")
#else //_DEBUG
#pragma comment(lib, "vc6-stlport-re300m.lib")
#endif //_DEBUG
#else //_MT
// STLPort does not support single threaded builds:
#error STLPort does not support single threaded builds
#endif //_MT
#endif //_DLL
#elif _MSC_VER < 1300
#ifdef _DLL
// All these are multithreaded:
#ifdef _DEBUG
#pragma comment(lib, "vc6-re300dl.lib")
#elif defined(BOOST_REGEX_STATIC_LINK)
// static regex lib, dll runtime
#pragma comment(lib, "vc6-re300ls.lib")
#else // DEBUG
#pragma comment(lib, "vc6-re300l.lib")
#endif // _DEBUG
#else // _DLL
#ifdef _MT
#ifdef _DEBUG
#pragma comment(lib, "vc6-re300dm.lib")
#else //_DEBUG
#pragma comment(lib, "vc6-re300m.lib")
#endif //_DEBUG
#else //_MT
#ifdef _DEBUG
#pragma comment(lib, "vc6-re300d.lib")
#else //_DEBUG
#pragma comment(lib, "vc6-re300.lib")
#endif //_DEBUG
#endif //_MT
#endif //_DLL
#else
#ifdef _DLL
// All these are multithreaded:
#ifdef _DEBUG
#pragma comment(lib, "vc7-re300dl.lib")
#elif defined(BOOST_REGEX_STATIC_LINK)
// static regex lib, dll runtime
#pragma comment(lib, "vc7-re300ls.lib")
#else // DEBUG
#pragma comment(lib, "vc7-re300l.lib")
#endif // _DEBUG
#else // _DLL
#ifdef _MT
#ifdef _DEBUG
#pragma comment(lib, "vc7-re300dm.lib")
#else //_DEBUG
#pragma comment(lib, "vc7-re300m.lib")
#endif //_DEBUG
#else //_MT
#ifdef _DEBUG
#pragma comment(lib, "vc7-re300d.lib")
#else //_DEBUG
#pragma comment(lib, "vc7-re300.lib")
#endif //_DEBUG
#endif //_MT
#endif //_DLL
#endif // __SGI_STL_PORT
#endif //BOOST_MSVC
#if defined(__BORLANDC__) && !defined(BOOST_REGEX_BUILD_DLL)
#if __BORLANDC__ < 0x550
#ifdef BOOST_REGEX_USE_VCL
#ifdef _RTLDLL
#pragma comment(lib, "bcb4re300lv.lib")
#else
#pragma comment(lib, "bcb4re300v.lib")
#endif
#else // VCL
#ifdef _RTLDLL
#ifdef __MT__
#pragma comment(lib, "bcb4re300lm.lib")
#else // __MT__
#pragma comment(lib, "bcb4re300l.lib")
#endif // __MT__
#else //_RTLDLL
#ifdef __MT__
#pragma comment(lib, "bcb4re300m.lib")
#else // __MT__
#pragma comment(lib, "bcb4re300.lib")
#endif // __MT__
#endif // _RTLDLL
#endif // VCL
#else // C++ Builder 5:
#ifdef BOOST_REGEX_USE_VCL
#ifdef _RTLDLL
#pragma comment(lib, "bcb5re300lv.lib")
#else
#pragma comment(lib, "bcb5re300v.lib")
#endif
#else // VCL
#ifdef _RTLDLL
#ifdef __MT__
#pragma comment(lib, "bcb5re300lm.lib")
#else // __MT__
#pragma comment(lib, "bcb5re300l.lib")
#endif // __MT__
#else //_RTLDLL
#ifdef __MT__
#pragma comment(lib, "bcb5re300m.lib")
#else // __MT__
#pragma comment(lib, "bcb5re300.lib")
#endif // __MT__
#endif // _RTLDLL
#endif // VCL
#endif
#endif //__BORLANDC__
#endif //BOOST_REGEX_NO_LIB
#endif // BOOST_REGEX_LIBRARY_INCLUDE_HPP

View File

@@ -1,33 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef RAW_PYOBJECT_DWA2002628_HPP
# define RAW_PYOBJECT_DWA2002628_HPP
namespace boost { namespace python { namespace detail {
//
// Define some types which we can use to get around the vagaries of
// PyObject*. We will use these to initialize object instances, and
// keep them in namespace detail to make sure they stay out of the
// hands of users. That is much simpler than trying to grant
// friendship to all the appropriate parties.
//
// New references are normally checked for null
struct new_reference_t;
typedef new_reference_t* new_reference;
// Borrowed references are assumed to be non-null
struct borrowed_reference_t;
typedef borrowed_reference_t* borrowed_reference;
// New references which aren't checked for null
struct new_non_null_reference_t;
typedef new_non_null_reference_t* new_non_null_reference;
}}} // namespace boost::python::detail
#endif // RAW_PYOBJECT_DWA2002628_HPP

View File

@@ -1,75 +0,0 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef REFERENT_STORAGE_DWA200278_HPP
# define REFERENT_STORAGE_DWA200278_HPP
# include <boost/mpl/if.hpp>
# include <cstddef>
namespace boost { namespace python { namespace detail {
struct alignment_dummy;
typedef void (*function_ptr)();
typedef int (alignment_dummy::*member_ptr);
typedef int (alignment_dummy::*member_function_ptr)();
# define BOOST_PYTHON_ALIGNER(T, n) \
typename mpl::if_c< \
sizeof(T) <= size, T, char>::type t##n
// Storage for size bytes, aligned to all fundamental types no larger than size
template <std::size_t size>
union aligned_storage
{
BOOST_PYTHON_ALIGNER(char, 0);
BOOST_PYTHON_ALIGNER(short, 1);
BOOST_PYTHON_ALIGNER(int, 2);
BOOST_PYTHON_ALIGNER(long, 3);
BOOST_PYTHON_ALIGNER(float, 4);
BOOST_PYTHON_ALIGNER(double, 5);
BOOST_PYTHON_ALIGNER(long double, 6);
BOOST_PYTHON_ALIGNER(void*, 7);
BOOST_PYTHON_ALIGNER(function_ptr, 8);
BOOST_PYTHON_ALIGNER(member_ptr, 9);
BOOST_PYTHON_ALIGNER(member_function_ptr, 10);
char bytes[size];
};
# undef BOOST_PYTHON_ALIGNER
// Compute the size of T's referent. We wouldn't need this at all,
// but sizeof() is broken in CodeWarriors <= 8.0
template <class T> struct referent_size;
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class T>
struct referent_size<T&>
{
BOOST_STATIC_CONSTANT(
std::size_t, value = sizeof(T));
};
# else
template <class T> struct referent_size
{
static T f();
BOOST_STATIC_CONSTANT(std::size_t, value = sizeof(f()));
};
# endif
// A metafunction returning a POD type which can store U, where T ==
// U&. If T is not a reference type, returns a POD which can store T.
template <class T>
struct referent_storage
{
typedef aligned_storage<referent_size<T>::value> type;
};
}}} // namespace boost::python::detail
#endif // REFERENT_STORAGE_DWA200278_HPP

Some files were not shown because too many files have changed in this diff Show More