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

Compare commits

..

331 Commits

Author SHA1 Message Date
Dave Abrahams
0eb039a500 NULL shared_ptr conversions, more tests for custom to-python shared_ptr registrations
[SVN r18263]
2003-04-16 14:32:14 +00:00
nobody
ba3b0a7c5d This commit was manufactured by cvs2svn to create branch
'unlabeled-1.1.2'.

[SVN r17835]
2003-03-12 12:47:45 +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
Dave Abrahams
b990d7580d Changes for MPL v2
[SVN r13504]
2002-04-16 14:29:30 +00:00
nobody
536dbe28a6 This commit was manufactured by cvs2svn to create branch
'unlabeled-1.1.2'.

[SVN r13257]
2002-03-24 15:19:57 +00:00
Dave Abrahams
27f99ba783 no message
[SVN r10384]
2001-06-21 22:49:06 +00:00
nobody
4c30bb98f9 This commit was manufactured by cvs2svn to create branch
'unlabeled-1.1.2'.

[SVN r9436]
2001-03-04 19:00:43 +00:00
Ralf W. Grosse-Kunstleve
582dc47885 Makefile for Windows mingw32 (a gcc type compiler).
[SVN r9388]
2001-03-03 02:54:03 +00:00
Ralf W. Grosse-Kunstleve
5666c21037 Enhanced pickle safety measures.
[SVN r9358]
2001-02-27 18:56:57 +00:00
Ralf W. Grosse-Kunstleve
16264a3f2d Safer pickle support (explicit auto_pickle parameter)
[SVN r9313]
2001-02-22 20:47:36 +00:00
Ralf W. Grosse-Kunstleve
046fb553c5 map [plain] char '\0' <-> "" (Python string of length 0)
[SVN r9306]
2001-02-21 10:00:27 +00:00
Ralf W. Grosse-Kunstleve
3eb98f54a1 Mapping of std::complex<T> <-> Python complex.
[SVN r9305]
2001-02-21 08:01:54 +00:00
Ralf W. Grosse-Kunstleve
f1d4a38121 Added to/from_python converters for [plain] char.
Reverted to original converters for un/signed char.


[SVN r9046]
2001-02-09 03:31:32 +00:00
Ralf W. Grosse-Kunstleve
6d3b960cb7 -lm on link-line for comprehensive.so eliminates warning.
[SVN r9021]
2001-02-08 01:37:27 +00:00
Ralf W. Grosse-Kunstleve
2aed6f022e rational.hpp (used in comprehensive.cpp) requires -ftemplate-depth-21
[SVN r9020]
2001-02-08 01:35:55 +00:00
nobody
724c91b7b2 This commit was manufactured by cvs2svn to create branch
'unlabeled-1.1.2'.

[SVN r9018]
2001-02-07 23:58:45 +00:00
Ralf W. Grosse-Kunstleve
1e272b9c14 BPL support for exporting/importing class wrappers.
[SVN r8788]
2001-01-27 17:35:02 +00:00
nobody
2ceaa9133d This commit was manufactured by cvs2svn to create branch
'unlabeled-1.1.2'.

[SVN r8787]
2001-01-27 17:35:01 +00:00
324 changed files with 2249 additions and 34631 deletions

2
build/.cvsignore Normal file
View File

@@ -0,0 +1,2 @@
Makefile
patch_tru64_to_gcc

36
build/Jamfile Normal file
View File

@@ -0,0 +1,36 @@
subproject libs/python/build ;
SOURCES = classes.cpp conversions.cpp extension_class.cpp functions.cpp
init_function.cpp module_builder.cpp
objects.cpp types.cpp cross_module.cpp ;
PYTHON_ROOT ?= c:/tools/python ;
PYTHON_INCLUDES = $(BOOST_ROOT) $(PYTHON_ROOT)$(SLASH)include ;
lib libboost_python : ../src/$(SOURCES) : <include>$(PYTHON_INCLUDES) <shared-linkable>true ;
rule boost-python
{
dll $(<) : $(>) :
$(3) <include>$(PYTHON_INCLUDES)
<msvc><library-path>$(PYTHON_ROOT)/libs
<gcc><*><library-file>$(PYTHON_ROOT)/libs/python20.lib
: $(4) ;
}
boost-python boost_python_test : <lib>libboost_python ../test/comprehensive.cpp ;
boost-python abstract : <lib>libboost_python ../example/abstract.cpp ;
boost-python getting_started1 : <lib>libboost_python ../example/getting_started1.cpp ;
boost-python getting_started2 : <lib>libboost_python ../example/getting_started2.cpp ;
boost-python simple_vector : <lib>libboost_python ../example/simple_vector.cpp ;
boost-python do_it_yourself_converters : <lib>libboost_python ../example/do_it_yourself_converters.cpp ;
boost-python pickle1 : <lib>libboost_python ../example/pickle1.cpp ;
boost-python pickle2 : <lib>libboost_python ../example/pickle2.cpp ;
boost-python pickle3 : <lib>libboost_python ../example/pickle3.cpp ;
boost-python noncopyable_export : <lib>libboost_python ../example/noncopyable_export.cpp ;
boost-python noncopyable_import : <lib>libboost_python ../example/noncopyable_import.cpp ;
boost-python ivect : <lib>libboost_python ../example/ivect.cpp ;
boost-python dvect : <lib>libboost_python ../example/dvect.cpp ;

194
build/Makefile.gcc Normal file
View File

@@ -0,0 +1,194 @@
# Usage:
#
# Create a new empty directory anywhere (preferably not in the boost tree).
# Copy this Makefile to that new directory and rename it to "Makefile"
# Set the MYBOOST pathname below.
#
# make softlinks Create softlinks to source code and tests
# make Compile all sources
# make test Run doctest tests
# make clean Remove all object files
# make unlink Remove softlinks
MYBOOST= /net/cci/rwgk/myboost
PYEXE= /usr/local/Python-1.5.2/bin/python
PYINC= -I/usr/local/Python-1.5.2/include/python1.5
#PYEXE= /usr/local/Python-2.0/bin/python
#PYINC= -I/usr/local/Python-2.0/include/python2.0
#STLPORTINC= -I/usr/local/STLport-4.1b3/stlport
#STLPORTOPTS= \
# -D__USE_STD_IOSTREAM \
# -D__STL_NO_SGI_IOSTREAMS \
# -D__STL_USE_NATIVE_STRING \
# -D__STL_NO_NEW_C_HEADERS \
# -D_RWSTD_COMPILE_INSTANTIATE=1
#STLPORTINC= -I/usr/local/STLport-4.1b4/stlport
#STLPORTOPTS= -D__NO_USE_STD_IOSTREAM -D__STL_NO_SGI_IOSTREAMS
#STLPORTINC= -I/net/cci/xp/C++_C_headers
STDOPTS= -ftemplate-depth-21
WARNOPTS=
CPP= g++
CPPOPTS= $(STLPORTINC) $(STLPORTOPTS) -I$(MYBOOST) $(PYINC) \
$(STDOPTS) $(WARNOPTS) -g
LD= g++
LDOPTS= -shared
BPL_SRC = $(MYBOOST)/libs/python/src
BPL_TST = $(MYBOOST)/libs/python/test
BPL_EXA = $(MYBOOST)/libs/python/example
SOFTLINKS = \
$(BPL_SRC)/classes.cpp \
$(BPL_SRC)/conversions.cpp \
$(BPL_SRC)/extension_class.cpp \
$(BPL_SRC)/functions.cpp \
$(BPL_SRC)/import_extension_class.cpp \
$(BPL_SRC)/init_function.cpp \
$(BPL_SRC)/module_builder.cpp \
$(BPL_SRC)/objects.cpp \
$(BPL_SRC)/types.cpp \
$(BPL_TST)/comprehensive.cpp \
$(BPL_TST)/comprehensive.hpp \
$(BPL_TST)/comprehensive.py \
$(BPL_TST)/doctest.py \
$(BPL_EXA)/abstract.cpp \
$(BPL_EXA)/dvect.cpp \
$(BPL_EXA)/dvect.h \
$(BPL_EXA)/getting_started1.cpp \
$(BPL_EXA)/getting_started2.cpp \
$(BPL_EXA)/getting_started3.cpp \
$(BPL_EXA)/getting_started4.cpp \
$(BPL_EXA)/getting_started5.cpp \
$(BPL_EXA)/passing_char.cpp \
$(BPL_EXA)/cmplx.cpp \
$(BPL_EXA)/ivect.cpp \
$(BPL_EXA)/ivect.h \
$(BPL_EXA)/noncopyable_export.cpp \
$(BPL_EXA)/noncopyable_import.cpp \
$(BPL_EXA)/store.h \
$(BPL_EXA)/test_abstract.py \
$(BPL_EXA)/test_getting_started1.py \
$(BPL_EXA)/test_getting_started2.py \
$(BPL_EXA)/test_getting_started3.py \
$(BPL_EXA)/test_getting_started4.py \
$(BPL_EXA)/test_getting_started5.py \
$(BPL_EXA)/tst_passing_char.py \
$(BPL_EXA)/tst_cmplx.py \
$(BPL_EXA)/tst_dvect.py \
$(BPL_EXA)/tst_ivect.py \
$(BPL_EXA)/tst_noncopyable.py
OBJ = classes.o conversions.o extension_class.o functions.o \
import_extension_class.o init_function.o module_builder.o \
objects.o types.o
.SUFFIXES: .o .cpp
all: libbpl.a test.so abstract.so \
getting_started1.so getting_started2.so getting_started3.so \
getting_started4.so getting_started5.so \
passing_char.so cmplx.so \
noncopyable_export.so noncopyable_import.so \
ivect.so dvect.so
softlinks:
@ for pn in $(SOFTLINKS); \
do \
bn=`basename "$$pn"`; \
if [ ! -e "$$bn" ]; then \
echo "ln -s $$pn ."; \
ln -s "$$pn" .; \
else \
echo "info: no softlink created (file exists): $$bn"; \
fi; \
done
unlink:
@ for pn in $(SOFTLINKS); \
do \
bn=`basename "$$pn"`; \
if [ -L "$$bn" ]; then \
echo "rm $$bn"; \
rm "$$bn"; \
elif [ -e "$$bn" ]; then \
echo "info: not a softlink: $$bn"; \
fi; \
done
libbpl.a: $(OBJ)
rm -f libbpl.a
ar r libbpl.a $(OBJ)
test.so: $(OBJ) comprehensive.o
$(LD) $(LDOPTS) $(OBJ) comprehensive.o -o test.so -lm
abstract.so: $(OBJ) abstract.o
$(LD) $(LDOPTS) $(OBJ) abstract.o -o abstract.so
getting_started1.so: $(OBJ) getting_started1.o
$(LD) $(LDOPTS) $(OBJ) getting_started1.o -o getting_started1.so
getting_started2.so: $(OBJ) getting_started2.o
$(LD) $(LDOPTS) $(OBJ) getting_started2.o -o getting_started2.so
getting_started3.so: $(OBJ) getting_started3.o
$(LD) $(LDOPTS) $(OBJ) getting_started3.o -o getting_started3.so
getting_started4.so: $(OBJ) getting_started4.o
$(LD) $(LDOPTS) $(OBJ) getting_started4.o -o getting_started4.so
getting_started5.so: $(OBJ) getting_started5.o
$(LD) $(LDOPTS) $(OBJ) getting_started5.o -o getting_started5.so
passing_char.so: $(OBJ) passing_char.o
$(LD) $(LDOPTS) $(OBJ) passing_char.o -o passing_char.so
cmplx.so: $(OBJ) cmplx.o
$(LD) $(LDOPTS) $(OBJ) cmplx.o -o cmplx.so -lm
noncopyable_export.so: $(OBJ) noncopyable_export.o
$(LD) $(LDOPTS) $(OBJ) $(HIDDEN) noncopyable_export.o -o noncopyable_export.so
noncopyable_import.so: $(OBJ) noncopyable_import.o
$(LD) $(LDOPTS) $(OBJ) $(HIDDEN) noncopyable_import.o -o noncopyable_import.so
ivect.cpp: ivect.h dvect.h
ivect.so: $(OBJ) ivect.o
$(LD) $(LDOPTS) $(OBJ) $(HIDDEN) ivect.o -o ivect.so
dvect.cpp: ivect.h dvect.h
dvect.so: $(OBJ) dvect.o
$(LD) $(LDOPTS) $(OBJ) $(HIDDEN) dvect.o -o dvect.so
.cpp.o:
$(CPP) $(CPPOPTS) -c $*.cpp
test:
$(PYEXE) comprehensive.py
$(PYEXE) test_abstract.py
$(PYEXE) test_getting_started1.py
$(PYEXE) test_getting_started2.py
$(PYEXE) test_getting_started3.py
$(PYEXE) test_getting_started4.py
$(PYEXE) test_getting_started5.py
clean:
rm -f $(OBJ) libbpl.a libbpl.a.input
rm -f comprehensive.o test.so
rm -f abstract.o abstract.so
rm -f getting_started1.o getting_started1.so
rm -f getting_started2.o getting_started2.so
rm -f getting_started3.o getting_started3.so
rm -f getting_started4.o getting_started4.so
rm -f getting_started5.o getting_started5.so
rm -f passing_char.o passing_char.so
rm -f cmplx.o cmplx.so
rm -f noncopyable_export.o noncopyable_export.so
rm -f noncopyable_import.o noncopyable_import.so
rm -f ivect.o ivect.so
rm -f dvect.o dvect.so
rm -f so_locations *.pyc
rm -rf cxx_repository

269
build/Makefile.mingw32 Normal file
View File

@@ -0,0 +1,269 @@
# Usage:
#
# Create a new empty directory anywhere (preferably not in the boost tree).
# Copy this Makefile to that new directory and rename it to "Makefile"
# Set the MYBOOST_* pathnames below.
#
# The idea is that the build directory is on a Unix filesystem that
# is mounted on a PC using SAMBA. Use this makefile under both Unix
# and Windows:
#
# Unix: make softlinks Create softlinks to source code and tests
# Win: make Compile all sources
# Win: make test Run doctest tests
# Unix: make clean Remove all object files
# Unix: make unlink Remove softlinks
# To install mingw32, follow instructions at:
# http://starship.python.net/crew/kernr/mingw32/Notes.html
# In particular, install:
# ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/gcc-2.95.2/gcc-2.95.2-msvcrt.exe
# ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/gcc-2.95.2/fixes/quote-fix-msvcrt.exe
# http://starship.python.net/crew/kernr/mingw32/Python-1.5.2-mingw32.zip
# Unpack the first two archives in the default locations and update your PATH.
# Unpack the third archive in \usr.
# Note: comprehensive.cpp generates compiler errors and later crashes.
# Could this be fixed with compiler options?
MYBOOST_UNIX= /net/cci/rwgk/myboost
MYBOOST_WIN= "L:\myboost"
PYEXE= "C:\Program files\Python\python.exe"
PYINC= -I"C:\usr\include\python1.5"
PYLIB= "C:\usr\lib\libpython15.a"
STDOPTS= -ftemplate-depth-21
WARNOPTS=
CPP= g++
CPPOPTS= $(STLPORTINC) $(STLPORTOPTS) -I$(MYBOOST_WIN) $(PYINC) \
$(STDOPTS) $(WARNOPTS) -g
LD= g++
LDOPTS= -shared
BPL_SRC = $(MYBOOST_UNIX)/libs/python/src
BPL_TST = $(MYBOOST_UNIX)/libs/python/test
BPL_EXA = $(MYBOOST_UNIX)/libs/python/example
SOFTLINKS = \
$(BPL_SRC)/classes.cpp \
$(BPL_SRC)/conversions.cpp \
$(BPL_SRC)/extension_class.cpp \
$(BPL_SRC)/functions.cpp \
$(BPL_SRC)/import_extension_class.cpp \
$(BPL_SRC)/init_function.cpp \
$(BPL_SRC)/module_builder.cpp \
$(BPL_SRC)/objects.cpp \
$(BPL_SRC)/types.cpp \
$(BPL_TST)/comprehensive.cpp \
$(BPL_TST)/comprehensive.hpp \
$(BPL_TST)/comprehensive.py \
$(BPL_TST)/doctest.py \
$(BPL_EXA)/abstract.cpp \
$(BPL_EXA)/dvect.cpp \
$(BPL_EXA)/dvect.h \
$(BPL_EXA)/getting_started1.cpp \
$(BPL_EXA)/getting_started2.cpp \
$(BPL_EXA)/getting_started3.cpp \
$(BPL_EXA)/getting_started4.cpp \
$(BPL_EXA)/getting_started5.cpp \
$(BPL_EXA)/passing_char.cpp \
$(BPL_EXA)/cmplx.cpp \
$(BPL_EXA)/ivect.cpp \
$(BPL_EXA)/ivect.h \
$(BPL_EXA)/noncopyable_export.cpp \
$(BPL_EXA)/noncopyable_import.cpp \
$(BPL_EXA)/store.h \
$(BPL_EXA)/test_abstract.py \
$(BPL_EXA)/test_getting_started1.py \
$(BPL_EXA)/test_getting_started2.py \
$(BPL_EXA)/test_getting_started3.py \
$(BPL_EXA)/test_getting_started4.py \
$(BPL_EXA)/test_getting_started5.py \
$(BPL_EXA)/tst_passing_char.py \
$(BPL_EXA)/tst_cmplx.py \
$(BPL_EXA)/tst_dvect.py \
$(BPL_EXA)/tst_ivect.py \
$(BPL_EXA)/tst_noncopyable.py
DEFS= \
test \
abstract \
getting_started1 \
getting_started2 \
getting_started3 \
getting_started4 \
getting_started5 \
passing_char \
cmplx \
noncopyable_export \
noncopyable_import \
ivect \
dvect
OBJ = classes.o conversions.o extension_class.o functions.o \
import_extension_class.o init_function.o module_builder.o \
objects.o types.o
.SUFFIXES: .o .cpp
all: libbpl.a test.pyd abstract.pyd \
getting_started1.pyd getting_started2.pyd getting_started3.pyd \
getting_started4.pyd getting_started5.pyd \
passing_char.pyd cmplx.pyd \
noncopyable_export.pyd noncopyable_import.pyd \
ivect.pyd dvect.pyd
softlinks: defs
@ for pn in $(SOFTLINKS); \
do \
bn=`basename "$$pn"`; \
if [ ! -e "$$bn" ]; then \
echo "ln -s $$pn ."; \
ln -s "$$pn" .; \
else \
echo "info: no softlink created (file exists): $$bn"; \
fi; \
done
unlink: rmdefs
@ for pn in $(SOFTLINKS); \
do \
bn=`basename "$$pn"`; \
if [ -L "$$bn" ]; then \
echo "rm $$bn"; \
rm "$$bn"; \
elif [ -e "$$bn" ]; then \
echo "info: not a softlink: $$bn"; \
fi; \
done
defs:
@ for def in $(DEFS); \
do \
echo "EXPORTS\n\tinit$$def" > $$def.def; \
done
rmdefs:
@ for def in $(DEFS); \
do \
rm $$def.def; \
done
libbpl.a: $(OBJ)
del libbpl.a
ar r libbpl.a $(OBJ)
DLLWRAPOPTS= --driver-name g++ -s \
--entry _DllMainCRTStartup@12 --target=i386-mingw32
test.pyd: $(OBJ) comprehensive.o
dllwrap $(DLLWRAPOPTS) \
--dllname test.pyd \
--def test.def \
$(OBJ) comprehensive.o $(PYLIB)
abstract.pyd: $(OBJ) abstract.o
dllwrap $(DLLWRAPOPTS) \
--dllname abstract.pyd \
--def abstract.def \
$(OBJ) abstract.o $(PYLIB)
getting_started1.pyd: $(OBJ) getting_started1.o
dllwrap $(DLLWRAPOPTS) \
--dllname getting_started1.pyd \
--def getting_started1.def \
$(OBJ) getting_started1.o $(PYLIB)
getting_started2.pyd: $(OBJ) getting_started2.o
dllwrap $(DLLWRAPOPTS) \
--dllname getting_started2.pyd \
--def getting_started2.def \
$(OBJ) getting_started2.o $(PYLIB)
getting_started3.pyd: $(OBJ) getting_started3.o
dllwrap $(DLLWRAPOPTS) \
--dllname getting_started3.pyd \
--def getting_started3.def \
$(OBJ) getting_started3.o $(PYLIB)
getting_started4.pyd: $(OBJ) getting_started4.o
dllwrap $(DLLWRAPOPTS) \
--dllname getting_started4.pyd \
--def getting_started4.def \
$(OBJ) getting_started4.o $(PYLIB)
getting_started5.pyd: $(OBJ) getting_started5.o
dllwrap $(DLLWRAPOPTS) \
--dllname getting_started5.pyd \
--def getting_started5.def \
$(OBJ) getting_started5.o $(PYLIB)
passing_char.pyd: $(OBJ) passing_char.o
dllwrap $(DLLWRAPOPTS) \
--dllname passing_char.pyd \
--def passing_char.def \
$(OBJ) passing_char.o $(PYLIB)
cmplx.pyd: $(OBJ) cmplx.o
dllwrap $(DLLWRAPOPTS) \
--dllname cmplx.pyd \
--def cmplx.def \
$(OBJ) cmplx.o $(PYLIB)
noncopyable_export.pyd: $(OBJ) noncopyable_export.o
dllwrap $(DLLWRAPOPTS) \
--dllname noncopyable_export.pyd \
--def noncopyable_export.def \
$(OBJ) noncopyable_export.o $(PYLIB)
noncopyable_import.pyd: $(OBJ) noncopyable_import.o
dllwrap $(DLLWRAPOPTS) \
--dllname noncopyable_import.pyd \
--def noncopyable_import.def \
$(OBJ) noncopyable_import.o $(PYLIB)
ivect.cpp: ivect.h dvect.h
ivect.pyd: $(OBJ) ivect.o
dllwrap $(DLLWRAPOPTS) \
--dllname ivect.pyd \
--def ivect.def \
$(OBJ) ivect.o $(PYLIB)
dvect.cpp: ivect.h dvect.h
dvect.pyd: $(OBJ) dvect.o
dllwrap $(DLLWRAPOPTS) \
--dllname dvect.pyd \
--def dvect.def \
$(OBJ) dvect.o $(PYLIB)
.cpp.o:
$(CPP) $(CPPOPTS) -c $*.cpp
test:
$(PYEXE) comprehensive.py
$(PYEXE) test_abstract.py
$(PYEXE) test_getting_started1.py
$(PYEXE) test_getting_started2.py
$(PYEXE) test_getting_started3.py
$(PYEXE) test_getting_started4.py
$(PYEXE) test_getting_started5.py
clean:
rm -f $(OBJ) libbpl.a libbpl.a.input
rm -f comprehensive.o test.pyd
rm -f abstract.o abstract.pyd
rm -f getting_started1.o getting_started1.pyd
rm -f getting_started2.o getting_started2.pyd
rm -f getting_started3.o getting_started3.pyd
rm -f getting_started4.o getting_started4.pyd
rm -f getting_started5.o getting_started5.pyd
rm -f passing_char.o passing_char.pyd
rm -f cmplx.o cmplx.pyd
rm -f noncopyable_export.o noncopyable_export.pyd
rm -f noncopyable_import.o noncopyable_import.pyd
rm -f ivect.o ivect.pyd
rm -f dvect.o dvect.pyd
rm -f so_locations *.pyc
rm -rf cxx_repository

199
build/Makefile.tru64 Normal file
View File

@@ -0,0 +1,199 @@
# Usage:
#
# Create a new empty directory anywhere (preferably not in the boost tree).
# Copy this Makefile to that new directory and rename it to "Makefile"
# Set the MYBOOST pathname below.
#
# make softlinks Create softlinks to source code and tests
# make Compile all sources
# make test Run doctest tests
# make clean Remove all object files
# make unlink Remove softlinks
MYBOOST= /net/cci/rwgk/myboost
PYEXE= /usr/local/Python-1.5.2/bin/python
PYINC= -I/usr/local/Python-1.5.2/include/python1.5
#PYEXE= /usr/local/Python-2.0/bin/python
#PYINC= -I/usr/local/Python-2.0/include/python2.0
#STLPORTINC= -I/usr/local/STLport-4.1b3/stlport
#STLPORTOPTS= \
# -D__USE_STD_IOSTREAM \
# -D__STL_NO_SGI_IOSTREAMS \
# -D__STL_USE_NATIVE_STRING \
# -D__STL_NO_NEW_C_HEADERS \
# -D_RWSTD_COMPILE_INSTANTIATE=1
#STLPORTINC= -I/usr/local/STLport-4.1b4/stlport
#STLPORTOPTS= -D__NO_USE_STD_IOSTREAM -D__STL_NO_SGI_IOSTREAMS
STLPORTINC= -I/net/cci/xp/C++_C_headers
STDOPTS= -std strict_ansi
WARNOPTS= -msg_disable 186,450,1115
# use -msg_display_number to obtain integer tags for -msg_disable
CPP= cxx
CPPOPTS= $(STLPORTINC) $(STLPORTOPTS) -I$(MYBOOST) $(PYINC) \
$(STDOPTS) $(WARNOPTS) -g
LD= cxx
LDOPTS= -shared -expect_unresolved 'Py*' -expect_unresolved '_Py*'
#HIDDEN= -hidden
BPL_SRC = $(MYBOOST)/libs/python/src
BPL_TST = $(MYBOOST)/libs/python/test
BPL_EXA = $(MYBOOST)/libs/python/example
SOFTLINKS = \
$(BPL_SRC)/classes.cpp \
$(BPL_SRC)/conversions.cpp \
$(BPL_SRC)/extension_class.cpp \
$(BPL_SRC)/functions.cpp \
$(BPL_SRC)/import_extension_class.cpp \
$(BPL_SRC)/init_function.cpp \
$(BPL_SRC)/module_builder.cpp \
$(BPL_SRC)/objects.cpp \
$(BPL_SRC)/types.cpp \
$(BPL_TST)/comprehensive.cpp \
$(BPL_TST)/comprehensive.hpp \
$(BPL_TST)/comprehensive.py \
$(BPL_TST)/doctest.py \
$(BPL_EXA)/abstract.cpp \
$(BPL_EXA)/dvect.cpp \
$(BPL_EXA)/dvect.h \
$(BPL_EXA)/getting_started1.cpp \
$(BPL_EXA)/getting_started2.cpp \
$(BPL_EXA)/getting_started3.cpp \
$(BPL_EXA)/getting_started4.cpp \
$(BPL_EXA)/getting_started5.cpp \
$(BPL_EXA)/passing_char.cpp \
$(BPL_EXA)/cmplx.cpp \
$(BPL_EXA)/ivect.cpp \
$(BPL_EXA)/ivect.h \
$(BPL_EXA)/noncopyable_export.cpp \
$(BPL_EXA)/noncopyable_import.cpp \
$(BPL_EXA)/store.h \
$(BPL_EXA)/test_abstract.py \
$(BPL_EXA)/test_getting_started1.py \
$(BPL_EXA)/test_getting_started2.py \
$(BPL_EXA)/test_getting_started3.py \
$(BPL_EXA)/test_getting_started4.py \
$(BPL_EXA)/test_getting_started5.py \
$(BPL_EXA)/tst_passing_char.py \
$(BPL_EXA)/tst_cmplx.py \
$(BPL_EXA)/tst_dvect.py \
$(BPL_EXA)/tst_ivect.py \
$(BPL_EXA)/tst_noncopyable.py
OBJ = classes.o conversions.o extension_class.o functions.o \
import_extension_class.o init_function.o module_builder.o \
objects.o types.o
.SUFFIXES: .o .cpp
all: libbpl.a test.so abstract.so \
getting_started1.so getting_started2.so getting_started3.so \
getting_started4.so getting_started5.so \
passing_char.so cmplx.so \
noncopyable_export.so noncopyable_import.so \
ivect.so dvect.so
softlinks:
@ for pn in $(SOFTLINKS); \
do \
bn=`basename "$$pn"`; \
if [ ! -e "$$bn" ]; then \
echo "ln -s $$pn ."; \
ln -s "$$pn" .; \
else \
echo "info: no softlink created (file exists): $$bn"; \
fi; \
done
unlink:
@ for pn in $(SOFTLINKS); \
do \
bn=`basename "$$pn"`; \
if [ -L "$$bn" ]; then \
echo "rm $$bn"; \
rm "$$bn"; \
elif [ -e "$$bn" ]; then \
echo "info: not a softlink: $$bn"; \
fi; \
done
libbpl.a: $(OBJ)
rm -f libbpl.a
ls -1 ./cxx_repository/*.o > libbpl.a.input
ar r libbpl.a $(OBJ) -input libbpl.a.input
rm -f libbpl.a.input
test.so: $(OBJ) comprehensive.o
$(LD) $(LDOPTS) $(OBJ) comprehensive.o -o test.so -lm
abstract.so: $(OBJ) abstract.o
$(LD) $(LDOPTS) $(OBJ) abstract.o -o abstract.so
getting_started1.so: $(OBJ) getting_started1.o
$(LD) $(LDOPTS) $(OBJ) getting_started1.o -o getting_started1.so
getting_started2.so: $(OBJ) getting_started2.o
$(LD) $(LDOPTS) $(OBJ) getting_started2.o -o getting_started2.so
getting_started3.so: $(OBJ) getting_started3.o
$(LD) $(LDOPTS) $(OBJ) getting_started3.o -o getting_started3.so
getting_started4.so: $(OBJ) getting_started4.o
$(LD) $(LDOPTS) $(OBJ) getting_started4.o -o getting_started4.so
getting_started5.so: $(OBJ) getting_started5.o
$(LD) $(LDOPTS) $(OBJ) getting_started5.o -o getting_started5.so
passing_char.so: $(OBJ) passing_char.o
$(LD) $(LDOPTS) $(OBJ) passing_char.o -o passing_char.so
cmplx.so: $(OBJ) cmplx.o
$(LD) $(LDOPTS) $(OBJ) cmplx.o -o cmplx.so -lm
noncopyable_export.so: $(OBJ) noncopyable_export.o
$(LD) $(LDOPTS) $(OBJ) $(HIDDEN) noncopyable_export.o -o noncopyable_export.so
noncopyable_import.so: $(OBJ) noncopyable_import.o
$(LD) $(LDOPTS) $(OBJ) $(HIDDEN) noncopyable_import.o -o noncopyable_import.so
ivect.cpp: ivect.h dvect.h
ivect.so: $(OBJ) ivect.o
$(LD) $(LDOPTS) $(OBJ) $(HIDDEN) ivect.o -o ivect.so
dvect.cpp: ivect.h dvect.h
dvect.so: $(OBJ) dvect.o
$(LD) $(LDOPTS) $(OBJ) $(HIDDEN) dvect.o -o dvect.so
.cpp.o:
$(CPP) $(CPPOPTS) -c $*.cpp
test:
$(PYEXE) comprehensive.py
$(PYEXE) test_abstract.py
$(PYEXE) test_getting_started1.py
$(PYEXE) test_getting_started2.py
$(PYEXE) test_getting_started3.py
$(PYEXE) test_getting_started4.py
$(PYEXE) test_getting_started5.py
clean:
rm -f $(OBJ) libbpl.a libbpl.a.input
rm -f comprehensive.o test.so
rm -f abstract.o abstract.so
rm -f getting_started1.o getting_started1.so
rm -f getting_started2.o getting_started2.so
rm -f getting_started3.o getting_started3.so
rm -f getting_started4.o getting_started4.so
rm -f getting_started5.o getting_started5.so
rm -f passing_char.o passing_char.so
rm -f cmplx.o cmplx.so
rm -f noncopyable_export.o noncopyable_export.so
rm -f noncopyable_import.o noncopyable_import.so
rm -f ivect.o ivect.so
rm -f dvect.o dvect.so
rm -f so_locations *.pyc
rm -rf cxx_repository

223
doc/pickle.html Normal file
View File

@@ -0,0 +1,223 @@
<html>
<head>
<title>BPL Pickle Support</title>
</head>
<body>
<img src="../../../c++boost.gif"
alt="c++boost.gif (8819 bytes)"
align="center"
width="277" height="86">
</body>
<hr>
<h1>BPL Pickle Support</h1>
Pickle is a Python module for object serialization, also known
as persistence, marshalling, or flattening.
<p>
It is often necessary to save and restore the contents of an object to
a file. One approach to this problem is to write a pair of functions
that read and write data from a file in a special format. A powerful
alternative approach is to use Python's pickle module. Exploiting
Python's ability for introspection, the pickle module recursively
converts nearly arbitrary Python objects into a stream of bytes that
can be written to a file.
<p>
The Boost Python Library supports the pickle module by emulating the
interface implemented by Jim Fulton's ExtensionClass module that is
included in the ZOPE distribution
(<a href="http://www.zope.org/">http://www.zope.org/</a>).
This interface is similar to that for regular Python classes as
described in detail in the Python Library Reference for pickle:
<blockquote>
<a href="http://www.python.org/doc/current/lib/module-pickle.html"
>http://www.python.org/doc/current/lib/module-pickle.html</a>
</blockquote>
<hr>
<h1>The BPL Pickle Interface</h1>
At the user level, the BPL pickle interface involves three special
methods:
<dl>
<dt>
<strong>__getinitargs__</strong>
<dd>
When an instance of a BPL extension class is pickled, the pickler
tests if the instance has a __getinitargs__ method. This method must
return a Python tuple. When the instance is restored by the
unpickler, the contents of this tuple are used as the arguments for
the class constructor.
<p>
If __getinitargs__ is not defined, the class constructor will be
called without arguments.
<p>
<dt>
<strong>__getstate__</strong>
<dd>
When an instance of a BPL extension class is pickled, the pickler
tests if the instance has a __getstate__ method. This method should
return a Python object representing the state of the instance.
<p>
If __getstate__ is not defined, the instance's __dict__ is pickled
(if it is not empty).
<p>
<dt>
<strong>__setstate__</strong>
<dd>
When an instance of a BPL extension class is restored by the
unpickler, it is first constructed using the result of
__getinitargs__ as arguments (see above). Subsequently the unpickler
tests if the new instance has a __setstate__ method. If so, this
method is called with the result of __getstate__ (a Python object) as
the argument.
<p>
If __setstate__ is not defined, the result of __getstate__ must be
a Python dictionary. The items of this dictionary are added to
the instance's __dict__.
</dl>
If both __getstate__ and __setstate__ are defined, the Python object
returned by __getstate__ need not be a dictionary. The __getstate__ and
__setstate__ methods can do what they want.
<hr>
<h1>Pitfalls and Safety Guards</h1>
In BPL extension modules with many extension classes, providing
complete pickle support for all classes would be a significant
overhead. In general complete pickle support should only be implemented
for extension classes that will eventually be pickled. However, the
author of a BPL extension module might not anticipate correctly which
classes need support for pickle. Unfortunately, the pickle protocol
described above has two important pitfalls that the end user of a BPL
extension module might not be aware of:
<dl>
<dt>
<strong>Pitfall 1:</strong>
Both __getinitargs__ and __getstate__ are not defined.
<dd>
In this situation the unpickler calls the class constructor without
arguments and then adds the __dict__ that was pickled by default to
that of the new instance.
<p>
However, most C++ classes wrapped with the BPL will have member data
that are not restored correctly by this procedure. To alert the user
to this problem, a safety guard is provided. If both __getinitargs__
and __getstate__ are not defined, the BPL tests if the class has an
attribute __dict_defines_state__. An exception is raised if this
attribute is not defined:
<pre>
RuntimeError: Incomplete pickle support (__dict_defines_state__ not set)
</pre>
In the rare cases where this is not the desired behavior, the safety
guard can deliberately be disabled. The corresponding C++ code for
this is, e.g.:
<pre>
class_builder<your_class> py_your_class(your_module, "your_class");
py_your_class.dict_defines_state();
</pre>
It is also possible to override the safety guard at the Python level.
E.g.:
<pre>
import your_bpl_module
class your_class(your_bpl_module.your_class):
__dict_defines_state__ = 1
</pre>
<p>
<dt>
<strong>Pitfall 2:</strong>
__getstate__ is defined and the instance's __dict__ is not empty.
<dd>
The author of a BPL extension class might provide a __getstate__
method without considering the possibilities that:
<p>
<ul>
<li>
his class is used as a base class. Most likely the __dict__ of
instances of the derived class needs to be pickled in order to
restore the instances correctly.
<p>
<li>
the user adds items to the instance's __dict__ directly. Again,
the __dict__ of the instance then needs to be pickled.
</ul>
<p>
To alert the user to this highly unobvious problem, a safety guard is
provided. If __getstate__ is defined and the instance's __dict__ is
not empty, the BPL tests if the class has an attribute
__getstate_manages_dict__. An exception is raised if this attribute
is not defined:
<pre>
RuntimeError: Incomplete pickle support (__getstate_manages_dict__ not set)
</pre>
To resolve this problem, it should first be established that the
__getstate__ and __setstate__ methods manage the instances's __dict__
correctly. Note that this can be done both at the C++ and the Python
level. Finally, the safety guard should intentionally be overridden.
E.g. in C++:
<pre>
class_builder<your_class> py_your_class(your_module, "your_class");
py_your_class.getstate_manages_dict();
</pre>
In Python:
<pre>
import your_bpl_module
class your_class(your_bpl_module.your_class):
__getstate_manages_dict__ = 1
def __getstate__(self):
# your code here
def __setstate__(self, state):
# your code here
</pre>
</dl>
<hr>
<h1>Practical Advice</h1>
<ul>
<li>
Avoid using __getstate__ if the instance can also be reconstructed
by way of __getinitargs__. This automatically avoids Pitfall 2.
<p>
<li>
If __getstate__ is required, include the instance's __dict__ in the
Python object that is returned.
</ul>
<hr>
<address>
Author: Ralf W. Grosse-Kunstleve, March 2001
</address>
</html>

6
example/README Normal file
View File

@@ -0,0 +1,6 @@
To get started with the Boost Python Library, use the examples
getting_started?.cpp and abstract.cpp.
The files example1.cpp and rwgk1.cpp are obsolete. They are only
included because the makefiles in the build directory still refer to
them. This will be fixed later.

34
example/abstract.cpp Normal file
View File

@@ -0,0 +1,34 @@
// Example by Ullrich Koethe
#include "boost/python/class_builder.hpp"
#include <string>
struct Abstract
{
virtual std::string test() = 0;
};
struct Abstract_callback: Abstract
{
Abstract_callback(PyObject * self)
: m_self(self)
{}
std::string test()
{
return boost::python::callback<std::string>::call_method(m_self, "test");
}
PyObject * m_self;
};
extern "C"
DL_EXPORT(void)
initabstract()
{
boost::python::module_builder a("abstract");
boost::python::class_builder<Abstract, Abstract_callback>
a_class(a, "Abstract");
a_class.def(boost::python::constructor<>()); // wrap a constructor
a_class.def(&Abstract::test, "test");
}

42
example/cmplx.cpp Normal file
View File

@@ -0,0 +1,42 @@
#include <iostream>
#include <complex>
namespace { // Avoid cluttering the global namespace.
std::complex<double> dpolar(double rho, double theta) {
return std::polar(rho, theta);
}
double dreal(const std::complex<double>& c) { return c.real(); }
double dimag(std::complex<double> c) { return c.imag(); }
std::complex<float> fpolar(float rho, float theta) {
return std::polar(rho, theta);
}
double freal(const std::complex<float>& c) { return c.real(); }
double fimag(std::complex<float> c) { return c.imag(); }
}
#include <boost/python/class_builder.hpp>
namespace python = boost::python;
extern "C"
DL_EXPORT(void)
initcmplx()
{
try
{
// Create an object representing this extension module.
python::module_builder this_module("cmplx");
this_module.def(dpolar, "dpolar");
this_module.def(dreal, "dreal");
this_module.def(dimag, "dimag");
this_module.def(fpolar, "fpolar");
this_module.def(freal, "freal");
this_module.def(fimag, "fimag");
}
catch(...)
{
python::handle_exception(); // Deal with the exception for Python
}
}

View File

@@ -0,0 +1,32 @@
#include <string>
namespace { // Avoid cluttering the global namespace.
// A couple of simple C++ functions that we want to expose to Python.
std::string greet() { return "hello, world"; }
int square(int number) { return number * number; }
}
#include <boost/python/class_builder.hpp>
namespace python = boost::python;
// Python requires an exported function called init<module-name> in every
// extension module. This is where we build the module contents.
extern "C"
DL_EXPORT(void)
initgetting_started1()
{
try
{
// Create an object representing this extension module.
python::module_builder this_module("getting_started1");
// Add regular functions to the module.
this_module.def(greet, "greet");
this_module.def(square, "square");
}
catch(...)
{
python::handle_exception(); // Deal with the exception for Python
}
}

View File

@@ -0,0 +1,51 @@
#include <iostream>
#include <string>
#include <boost/python/class_builder.hpp>
namespace python = boost::python;
namespace { // Avoid cluttering the global namespace.
// A friendly class.
class world
{
private:
std::string country;
public:
world(const std::string& country) { this->country = country; }
std::string greet() const { return "Hello from " + country + "!"; }
};
// A function taking a world object as an argument.
std::string invite(const world& w) {
return w.greet() + " Please come soon!";
}
}
extern "C"
DL_EXPORT(void)
initgetting_started2()
{
try
{
// Create an object representing this extension module.
python::module_builder this_module("getting_started2");
// Create the Python type object for our extension class.
python::class_builder<world> world_class(this_module, "world");
// Add the __init__ function.
world_class.def(python::constructor<std::string>());
// Add a regular member function.
world_class.def(&world::greet, "greet");
// Add invite() as a regular function to the module.
this_module.def(invite, "invite");
// Even better, invite() can also be made a member of world_class!!!
world_class.def(invite, "invite");
}
catch(...)
{
python::handle_exception(); // Deal with the exception for Python
}
}

View File

@@ -0,0 +1,147 @@
/*
This example shows how to make an Extension Class "pickleable".
Python's pickle module implements a basic but powerful algorithm
for "pickling" (a.k.a. serializing, marshalling or flattening)
nearly arbitrary Python objects.
The user can influence how an Extension Class instance is pickled
by defining three special methods: __getinitargs__(),
__getstate__(), and __setstate(). This interface is similar to
that for regular Python classes as described in detail in the
Python Library Reference for pickle:
http://www.python.org/doc/current/lib/module-pickle.html
When an Extension Class instance is pickled, __getinitargs__() is
called, if implemented. This method should return a tuple
containing the arguments to be passed to the class constructor when
the object is restored.
If there is no __getstate__() method, the instance's __dict__ is
pickled if it is not empty. If __getstate__() is defined, it should
return an object representing the state of the instance.
If there is no __setstate__() method, __getstate__() must return a
dictionary. When the instance is restored, the items in this dictionary
are added to the instance's __dict__.
If the Extension Class defines __setstate__(), the pickle loader
calls it with the result of __getstate__() as arguments. In this
case, the state object need not be a dictionary. The
__getstate__() and __setstate__() methods can do what they want.
If both __getinitargs__() and __getstate__() are defined, the
instance is restored by first calling the constructor with
the result of __getinitargs__() as argument. After the instance
is reconstructed, the __dict__ is updated or __setstate__() is
called if implemented.
The mechanism described here is an exact replication of that one
implemented by Jim Fulton's ExtensionClass (included in Zope 2.2.2).
*/
#include <iostream>
#include <string>
#include <boost/python/class_builder.hpp>
namespace python = boost::python;
namespace { // Avoid cluttering the global namespace.
// A friendly class.
class world
{
private:
std::string country;
int secret_number;
public:
world(const std::string& country) : secret_number(0) {
this->country = country;
}
std::string greet() const { return "Hello from " + country + "!"; }
std::string get_country() const { return country; }
void set_secret_number(int number) { secret_number = number; }
int get_secret_number() const { return secret_number; }
};
// Support for pickle.
python::tuple world_getinitargs(const world& w) {
python::tuple result(1);
result.set_item(0, w.get_country());
return result;
}
python::tuple world_getstate(const world& w) {
python::tuple result(1);
result.set_item(0, w.get_secret_number());
return result;
}
void world_setstate(world& w, python::tuple state) {
if (state.size() != 1) {
PyErr_SetString(PyExc_ValueError,
"Unexpected argument in call to __setstate__.");
throw python::error_already_set();
}
int number = BOOST_PYTHON_CONVERSION::from_python(state[0].get(),
python::type<int>());
if (number != 42)
w.set_secret_number(number);
}
template <class T>
class a_number {
private:
T m_number;
public:
a_number() : m_number(0) {}
a_number(T number) : m_number(number) {}
const T get() const { return m_number; }
};
}
extern "C"
DL_EXPORT(void)
initgetting_started3()
{
try
{
// Create an object representing this extension module.
python::module_builder this_module("getting_started3");
// Create the Python type object for our extension class.
python::class_builder<world> world_class(this_module, "world");
// Add the __init__ function.
world_class.def(python::constructor<std::string>());
// Add a regular member function.
world_class.def(&world::greet, "greet");
world_class.def(&world::get_secret_number, "get_secret_number");
world_class.def(&world::set_secret_number, "set_secret_number");
// Support for pickle.
world_class.def(world_getinitargs, "__getinitargs__");
world_class.def(world_getstate, "__getstate__");
world_class.def(world_setstate, "__setstate__");
// This Python class has no pickle support.
python::class_builder<a_number<int> >
py_a_lame_number(this_module, "a_lame_number");
py_a_lame_number.def(python::constructor<>());
py_a_lame_number.def(python::constructor<int>());
py_a_lame_number.def(&a_number<int>::get, "get");
// Enable pickling of the object's __dict__.
python::class_builder<a_number<double> >
py_a_number(this_module, "a_number");
py_a_number.dict_defines_state();
py_a_number.def(python::constructor<>());
py_a_number.def(python::constructor<double>());
py_a_number.def(&a_number<double>::get, "get");
}
catch(...)
{
python::handle_exception(); // Deal with the exception for Python
}
}

View File

@@ -0,0 +1,104 @@
#include <boost/python/class_builder.hpp>
namespace python = boost::python;
namespace { // Avoid cluttering the global namespace.
// A wrapper is used to define additional constructors.
//
struct vector_double_wrapper: std::vector<double>
{
// Tell the compiler how to convert a base class object to
// this wrapper object.
vector_double_wrapper(PyObject*, const std::vector<double>& vd)
: std::vector<double>(vd) {}
vector_double_wrapper(PyObject* self)
: std::vector<double>() {}
vector_double_wrapper(PyObject* self, const int n)
: std::vector<double>(n) {}
vector_double_wrapper(PyObject* self, python::tuple tuple)
: std::vector<double>(tuple.size())
{
std::vector<double>::iterator vd = begin();
for (int i = 0; i < tuple.size(); i++)
vd[i] = BOOST_PYTHON_CONVERSION::from_python(tuple[i].get(),
python::type<double>());
}
};
double getitem(const std::vector<double>& vd, const std::size_t key) {
return vd[key];
}
void setitem(std::vector<double>& vd, const std::size_t key,
const double &d) {
std::vector<double>::iterator vditer = vd.begin();
vditer[key] = d;
}
void delitem(std::vector<double>& vd, const std::size_t key) {
std::vector<double>::iterator vditer = vd.begin();
vd.erase(&vditer[key]);
}
// Convert vector_double to a regular Python tuple.
//
python::tuple as_tuple(const std::vector<double>& vd)
{
python::tuple t(vd.size());
for (int i = 0; i < vd.size(); i++) t.set_item(i,
python::ref(BOOST_PYTHON_CONVERSION::to_python(vd[i])));
return t;
}
// Function returning a vector_double object to Python.
//
std::vector<double> foo(const int n)
{
std::vector<double> vd(n);
std::vector<double>::iterator vditer = vd.begin();
for (int i = 0; i < n; i++) vditer[i] = double(i);
return vd;
}
// Same as foo(), but avoid copying on return.
//
std::auto_ptr<std::vector<double> > bar(const int n)
{
std::auto_ptr<std::vector<double> > vdptr(new std::vector<double>(n));
std::vector<double>::iterator vditer = vdptr->begin();
for (int i = 0; i < n; i++) vditer[i] = double(10 * i);
return vdptr;
}
}
extern "C"
DL_EXPORT(void)
initgetting_started4()
{
try
{
python::module_builder this_module("getting_started4");
python::class_builder<std::vector<double>, vector_double_wrapper>
vector_double(this_module, "vector_double");
vector_double.def(python::constructor<>());
vector_double.def(python::constructor<const int>());
vector_double.def(python::constructor<python::tuple>());
vector_double.def(&std::vector<double>::size, "__len__");
vector_double.def(getitem, "__getitem__");
vector_double.def(setitem, "__setitem__");
vector_double.def(delitem, "__delitem__");
vector_double.def(as_tuple, "as_tuple");
this_module.def(foo, "foo");
this_module.def(bar, "bar");
}
catch(...)
{
python::handle_exception(); // Deal with the exception for Python
}
}

52
example/passing_char.cpp Normal file
View File

@@ -0,0 +1,52 @@
#include <iostream>
namespace { // Avoid cluttering the global namespace.
// In C++, char, signed char and unsigned char are three distinct types.
// The Boost Python Library maps signed & unsigned char to
// Python integers. Plain char is mapped to a Python string with
// exactly one character.
// Plain char.
char get_char() { return 'ÿ'; }
void use_char(char c) {
std::cout << c << std::endl;
}
// signed char.
signed char get_signed_char() { return -128; }
void use_signed_char(signed char c) {
std::cout << c << " " << static_cast<int>(c) << std::endl;
}
// unsigned char.
unsigned char get_unsigned_char() { return 128; }
void use_unsigned_char(unsigned char c) {
std::cout << c << " " << static_cast<unsigned int>(c) << std::endl;
}
}
#include <boost/python/class_builder.hpp>
namespace python = boost::python;
extern "C"
DL_EXPORT(void)
initpassing_char()
{
try
{
// Create an object representing this extension module.
python::module_builder this_module("passing_char");
this_module.def(get_char, "get_char");
this_module.def(use_char, "use_char");
this_module.def(get_signed_char, "get_signed_char");
this_module.def(use_signed_char, "use_signed_char");
this_module.def(get_unsigned_char, "get_unsigned_char");
this_module.def(use_unsigned_char, "use_unsigned_char");
}
catch(...)
{
python::handle_exception(); // Deal with the exception for Python
}
}

23
example/test_abstract.py Normal file
View File

@@ -0,0 +1,23 @@
# Example by Ullrich Koethe
r'''>>> from abstract import *
>>> class A(Abstract):
... def __init__(self, text):
... Abstract.__init__(self) # call the base class constructor
... self.text = text
... def test(self): # implement abstract function
... return self.text
...
>>> a = A("Hello")
>>> a.test()
'Hello'
'''
def run(args = None):
if args is not None:
import sys
sys.argv = args
import doctest, test_abstract
doctest.testmod(test_abstract)
if __name__ == '__main__':
run()

View File

@@ -0,0 +1,17 @@
r'''>>> import getting_started1
>>> print getting_started1.greet()
hello, world
>>> number = 11
>>> print number, '*', number, '=', getting_started1.square(number)
11 * 11 = 121
'''
def run(args = None):
if args is not None:
import sys
sys.argv = args
import doctest, test_getting_started1
doctest.testmod(test_getting_started1)
if __name__ == '__main__':
run()

View File

@@ -0,0 +1,19 @@
r'''>>> import getting_started2
>>> w = getting_started2.world('California')
>>> print w.greet()
Hello from California!
>>> print getting_started2.invite(w)
Hello from California! Please come soon!
>>> print w.invite()
Hello from California! Please come soon!
'''
def run(args = None):
if args is not None:
import sys
sys.argv = args
import doctest, test_getting_started2
doctest.testmod(test_getting_started2)
if __name__ == '__main__':
run()

View File

@@ -0,0 +1,56 @@
r'''>>> import getting_started3
>>> import re
>>> import pickle
>>> getting_started3.world.__module__
'getting_started3'
>>> getting_started3.world.__safe_for_unpickling__
1
>>> getting_started3.world.__reduce__()
'world'
>>> assert re.match(
... "\(<extension class getting_started3.world at [0-9a-fA-FxX]+>, \('Hello',\), \(0,\)\)",
... repr(getting_started3.world('Hello').__reduce__()))
>>>
>>> for number in (24, 42):
... wd = getting_started3.world('California')
... wd.set_secret_number(number)
... pstr = pickle.dumps(wd)
... print pstr
... wl = pickle.loads(pstr)
... print wd.greet(), wd.get_secret_number()
... print wl.greet(), wl.get_secret_number()
cgetting_started3
world
p0
(S'California'
p1
tp2
R(I24
tp3
bp4
.
Hello from California! 24
Hello from California! 24
cgetting_started3
world
p0
(S'California'
p1
tp2
R(I42
tp3
bp4
.
Hello from California! 42
Hello from California! 0
'''
def run(args = None):
if args is not None:
import sys
sys.argv = args
import doctest, test_getting_started3
doctest.testmod(test_getting_started3)
if __name__ == '__main__':
run()

View File

@@ -0,0 +1,35 @@
r'''>>> import getting_started4
>>> v=getting_started4.vector_double()
>>> print v.as_tuple()
()
>>> v=getting_started4.vector_double(5)
>>> print v.as_tuple()
(0.0, 0.0, 0.0, 0.0, 0.0)
>>> print len(v)
5
>>> v=getting_started4.vector_double((3,4,5))
>>> print v.as_tuple()
(3.0, 4.0, 5.0)
>>> print v[1]
4.0
>>> v[1] = 40
>>> print v.as_tuple()
(3.0, 40.0, 5.0)
>>> del v[1]
>>> print v.as_tuple()
(3.0, 5.0)
>>> print getting_started4.foo(11).as_tuple()
(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0)
>>> print getting_started4.bar(12).as_tuple()
(0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0)
'''
def run(args = None):
if args is not None:
import sys
sys.argv = args
import doctest, test_getting_started4
doctest.testmod(test_getting_started4)
if __name__ == '__main__':
run()

View File

@@ -0,0 +1,22 @@
r'''>>> import getting_started5
>>> ixset = getting_started5.IndexingSet()
>>> ixset.add((1,2,3))
>>> ixset.add((4,5,6))
>>> ixset.add((7,8,9))
>>> print ixset.get(0)
(1, 2, 3)
>>> print ixset.get(1)
(4, 5, 6)
>>> print ixset.get(2)
(7, 8, 9)
'''
def run(args = None):
if args is not None:
import sys
sys.argv = args
import doctest, test_getting_started5
doctest.testmod(test_getting_started5)
if __name__ == '__main__':
run()

20
example/tst_cmplx.py Normal file
View File

@@ -0,0 +1,20 @@
import cmplx
c = cmplx.dpolar(1, 1)
print c
print cmplx.dreal(c)
print cmplx.dimag(c)
c = cmplx.fpolar(1, 1)
print c
print cmplx.freal(c)
print cmplx.fimag(c)
print cmplx.dreal(c)
print cmplx.dimag(c)
try:
cmplx.freal("")
except TypeError:
pass
else:
raise SystemError

View File

@@ -0,0 +1,20 @@
import passing_char
print passing_char.get_char()
print passing_char.get_signed_char()
print passing_char.get_unsigned_char()
for arg in (-97, 97, -140, 140, "a", "ab", ""):
try:
print 'char', arg, ':'
passing_char.use_char(arg)
except (TypeError, ValueError), e:
print e.args[0]
try:
print 'signed char', arg, ':'
passing_char.use_signed_char(arg)
except (TypeError, ValueError), e:
print e.args[0]
try:
print 'unsigned char', arg, ':'
passing_char.use_unsigned_char(arg)
except (TypeError, ValueError), e:
print e.args[0]

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

@@ -5,30 +5,17 @@
// 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>
# include <boost/mpl/list.hpp>
# include <boost/preprocessor/enum_params_with_a_default.hpp>
# include <boost/preprocessor/enum_params.hpp>
namespace boost { namespace python {
enum no_init_t { no_init };
namespace detail
{
template <class Args>
struct args_base {};
}
}}
namespace boost { namespace python {
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
template < BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_MPL_LIMIT_LIST_SIZE, typename A, ::boost::mpl::aux::none) >
struct args : ::boost::mpl::list< BOOST_PP_ENUM_PARAMS(BOOST_MPL_LIMIT_LIST_SIZE,A) >::type
{};
}} // namespace boost::python
# endif // ARGS_DWA2002323_HPP
#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

@@ -6,16 +6,16 @@
#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/mpl/list.hpp>
# include <boost/mpl/select_if.hpp>
# include <boost/mpl/identity.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
template < BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_MPL_LIMIT_LIST_SIZE, typename B, ::boost::mpl::aux::none) >
struct bases : ::boost::mpl::list< BOOST_PP_ENUM_PARAMS(BOOST_MPL_LIMIT_LIST_SIZE,B) >
{};
namespace detail
@@ -25,14 +25,14 @@ namespace boost { namespace python {
{
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) > >
template < BOOST_PP_ENUM_PARAMS(BOOST_MPL_LIMIT_LIST_SIZE,class B) >
struct specifies_bases< bases< BOOST_PP_ENUM_PARAMS(BOOST_MPL_LIMIT_LIST_SIZE,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&);
template < BOOST_PP_ENUM_PARAMS(BOOST_MPL_LIMIT_LIST_SIZE,class B) >
static char is_bases_helper(bases< BOOST_PP_ENUM_PARAMS(BOOST_MPL_LIMIT_LIST_SIZE,B) > const&);
static char (& is_bases_helper(...) )[256];
@@ -47,7 +47,7 @@ namespace boost { namespace python {
# endif
template <class T, class Prev = bases<> >
struct select_bases
: mpl::if_c<
: mpl::select_if_c<
specifies_bases<T>::value
, T
, Prev

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

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