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

Compare commits

...

203 Commits

Author SHA1 Message Date
Joel de Guzman
9743ad0a69 module, class_ .def dispatching
[SVN r14963]
2002-08-19 18:46:44 +00:00
Joel de Guzman
432a9b85e7 Using PP Iteration
[SVN r14950]
2002-08-19 11:15:10 +00:00
Joel de Guzman
9d51d39d7a const class signature + simplified comments in class and module
[SVN r14817]
2002-08-13 18:38:39 +00:00
Joel de Guzman
a33ee22259 Removed obsolete commented code
[SVN r14816]
2002-08-13 18:24:22 +00:00
Joel de Guzman
943b96f902 Misc comments from Dave
[SVN r14815]
2002-08-13 17:52:30 +00:00
Joel de Guzman
d52bc52515 More comments...
[SVN r14811]
2002-08-13 12:41:51 +00:00
Joel de Guzman
fe19b49273 sprinkled with comments
[SVN r14810]
2002-08-13 12:07:16 +00:00
Joel de Guzman
e56f6833e6 API changes + signature template and get_signature(sig) functions
[SVN r14807]
2002-08-13 10:06:27 +00:00
Joel de Guzman
502e67c114 jamfile
[SVN r14790]
2002-08-12 15:29:23 +00:00
Joel de Guzman
cdf49c6ac0 Default Arguments Handling
[SVN r14786]
2002-08-12 14:22:36 +00:00
nobody
bbc90bcc9c This commit was manufactured by cvs2svn to create branch
'python-v2-dev'.

[SVN r14785]
2002-08-12 13:35:54 +00:00
Dave Abrahams
2103e691db initial commit
[SVN r14738]
2002-08-08 15:45:58 +00:00
Dave Abrahams
cf15a99730 Repair type initialization problem
[SVN r14736]
2002-08-08 06:14:48 +00:00
Dave Abrahams
a3102b552c Add casts to work around missing extern "C" in Python headers.
[SVN r14735]
2002-08-08 05:52:30 +00:00
Dave Abrahams
bd0257cbe5 Full docstring support
[SVN r14734]
2002-08-07 23:03:02 +00:00
Dave Abrahams
56e7b2a592 * object(f), where f is a function pointer now works. Returning a
* function pointer from a function should work also.
* make_function/make_constructor now return object instead of a raw pointer.
* module::setattr() now accepts anything which can be passed to object's constructor.

* Rework upcast<> to catch more errors at compile-time instead of infinite-looping.
* Rationalize class<>::def() in preparation for docstring support
* Partial docstring support in module::def (untested)
* dependent<> trick moved to detail namespace and separate header

* Added __doc__ attribute to C++ function wrapper objects
* Sunk implementation of function_object into a library source file.


[SVN r14724]
2002-08-06 23:59:27 +00:00
Dave Abrahams
61d030748c Moving an #include works around a VC6 ICE
[SVN r14723]
2002-08-06 23:51:51 +00:00
Dave Abrahams
f59ed991fe VC6 bug workarounds
[SVN r14722]
2002-08-06 23:44:31 +00:00
Dave Abrahams
2bdf958663 Suppress warnings by eliminating unneeded specializations of is_pointer_to_function<>.
[SVN r14721]
2002-08-06 23:32:52 +00:00
Dave Abrahams
bd8b6a2a64 Workaround a CWPro7.2 bug
[SVN r14720]
2002-08-06 23:23:28 +00:00
Dave Abrahams
88528e338b Correct version for VC7.1 workaround
[SVN r14719]
2002-08-06 22:36:43 +00:00
Dave Abrahams
88b3bf1887 VC 7, 7.1a workaround
[SVN r14701]
2002-08-05 21:55:28 +00:00
Dave Abrahams
6907df1457 bug fixes
[SVN r14623]
2002-07-27 05:50:10 +00:00
Dave Abrahams
19036c14f5 handle<> -> object
[SVN r14603]
2002-07-25 18:07:25 +00:00
Dave Abrahams
ddb1236f2f Begin transition away from handle<>
[SVN r14602]
2002-07-25 16:29:30 +00:00
Dave Abrahams
30ef9c6418 back_reference<> uses object instead of handle<>
[SVN r14600]
2002-07-25 15:20:06 +00:00
Dave Abrahams
8763fd1c53 scope default constructor gets current scope; killed scope::get()
[SVN r14599]
2002-07-25 14:52:11 +00:00
Dave Abrahams
5976005c4a Make Boost.Python v1 work again
[SVN r14595]
2002-07-25 10:52:10 +00:00
Dave Abrahams
63eed8994a class_<> is now derived from object
[SVN r14594]
2002-07-25 04:41:21 +00:00
Dave Abrahams
f458dbdbcb Added scope
[SVN r14593]
2002-07-25 02:23:01 +00:00
Dave Abrahams
b7421fd5cd Fix Ralf's boo-boo.
[SVN r14592]
2002-07-24 16:58:46 +00:00
Dave Abrahams
a2feb04509 pytype_object_manager_traits -> pytype_object_mgr_traits (< 31 chars)
[SVN r14587]
2002-07-24 13:31:29 +00:00
Ralf W. Grosse-Kunstleve
e25fee71a2 additional compile-time check: must_be_derived_from_pickle_suite
[SVN r14568]
2002-07-22 23:43:00 +00:00
Ralf W. Grosse-Kunstleve
bfe2a6656c pickle_group renamed -> pickle_suite
[SVN r14565]
2002-07-22 19:35:44 +00:00
Ralf W. Grosse-Kunstleve
e15ca5c642 full integration of (revised) pickle support
[SVN r14557]
2002-07-22 06:54:39 +00:00
Dave Abrahams
3232c5be86 Fixed test of null handle returns to reflect new returning-None behavior
[SVN r14553]
2002-07-21 11:11:15 +00:00
Ralf W. Grosse-Kunstleve
1c5a50d4cb pickle support implementation details hidden in namespace detail
[SVN r14550]
2002-07-21 09:39:35 +00:00
Ralf W. Grosse-Kunstleve
4ef5f77161 additional files for pickle support; no modification of any existing files
[SVN r14549]
2002-07-21 07:49:00 +00:00
Dave Abrahams
d27e5a5e1d Rationalize object_manager
[SVN r14548]
2002-07-21 05:03:11 +00:00
Ralf W. Grosse-Kunstleve
7ecf76490c one #undef was missing
[SVN r14544]
2002-07-20 00:14:20 +00:00
Ralf W. Grosse-Kunstleve
12120413f9 #undef isspace etc.
[SVN r14539]
2002-07-19 20:10:11 +00:00
Dave Abrahams
c0eea6e667 fix link
[SVN r14530]
2002-07-19 18:06:05 +00:00
Dave Abrahams
5c54aecdda initial commit
[SVN r14529]
2002-07-19 18:05:18 +00:00
Dave Abrahams
5cfc0cce14 str, dict, and tuple!
[SVN r14519]
2002-07-18 15:52:18 +00:00
Dave Abrahams
d9a58ef830 str, dict, and tuple!
[SVN r14518]
2002-07-18 15:27:29 +00:00
Dave Abrahams
dfd85da9d7 str, dict, and tuple!
[SVN r14517]
2002-07-18 15:17:08 +00:00
Dave Abrahams
94edc13393 Doc fixup
[SVN r14516]
2002-07-18 12:58:37 +00:00
Dave Abrahams
a9baa519f3 Extract implemented
[SVN r14510]
2002-07-18 05:00:34 +00:00
Dave Abrahams
a6c859c9cc Roll back most of Dave Hawkes' changes for the time being.
[SVN r14503]
2002-07-17 19:58:05 +00:00
Dave Abrahams
f9a67b34b2 Roll back most of Dave Hawkes' changes for the time being.
[SVN r14501]
2002-07-17 18:36:14 +00:00
Dave Abrahams
6ac5735d14 MSVC fixes
[SVN r14500]
2002-07-17 18:31:02 +00:00
Dave Abrahams
9d5e8b9ad8 Bug fix
[SVN r14495]
2002-07-17 14:06:15 +00:00
Dave Abrahams
bd72ee9cd1 Add missing #include
[SVN r14494]
2002-07-17 14:05:53 +00:00
Dave Abrahams
c2e115b6a5 Add missing typename
[SVN r14493]
2002-07-17 14:05:31 +00:00
David Hawkes
61ba4cd1ce Sub-module / sub-class and API changes
[SVN r14488]
2002-07-17 06:51:08 +00:00
Dave Abrahams
244e0fa5e6 More converter centralization
[SVN r14487]
2002-07-17 01:54:58 +00:00
Dave Abrahams
134bc44c45 destroy_reference -> destroy_referent
[SVN r14486]
2002-07-17 01:53:33 +00:00
Dave Abrahams
1d2dc98f50 MSVC6 workaround
[SVN r14485]
2002-07-16 20:01:38 +00:00
Dave Abrahams
7a05b89a93 MSVC6 workaround
[SVN r14484]
2002-07-16 17:15:36 +00:00
Dave Abrahams
2bfeb20550 Added type checking when converting some Python types from python as return values.
[SVN r14478]
2002-07-16 11:45:10 +00:00
Dave Abrahams
fa779034b5 VC7.1 workarounds
[SVN r14477]
2002-07-16 11:31:36 +00:00
Ralf W. Grosse-Kunstleve
ea5cfdcdce missing inline keywords added (MIPSpro 7.3 diagnostics)
[SVN r14469]
2002-07-15 20:07:04 +00:00
Ralf W. Grosse-Kunstleve
ba1eab1bf0 is_string_literal<char* const> specialization enabled for MIPSpro; this fixes the list.test failures.
[SVN r14468]
2002-07-15 19:09:57 +00:00
Dave Abrahams
149c60bd2e Still further rationalized conversion registry
[SVN r14462]
2002-07-14 23:25:56 +00:00
Dave Abrahams
9795a27482 Even further rationalized conversion registry
[SVN r14458]
2002-07-14 20:36:54 +00:00
Dave Abrahams
baccdba75c Better error reporting
[SVN r14456]
2002-07-14 18:44:28 +00:00
Dave Abrahams
93b4c6291a Removed flotsam
[SVN r14455]
2002-07-14 18:42:43 +00:00
Dave Abrahams
815edf1ba5 Apply VC6 workaround and None default constructor patch from Dave Hawkes.
[SVN r14452]
2002-07-14 16:26:10 +00:00
Dave Abrahams
df7b4d81c7 Tests for Tru64 CXX regression
[SVN r14451]
2002-07-14 16:09:46 +00:00
Dave Abrahams
3e07ba1012 tru64cxx6.5 workarounds
[SVN r14450]
2002-07-14 16:07:39 +00:00
Dave Abrahams
32c6906750 Remove circular dependency on working converters
[SVN r14449]
2002-07-14 14:37:20 +00:00
Dave Abrahams
3ebe4c47ba Better error reporting
[SVN r14448]
2002-07-14 13:04:27 +00:00
Dave Abrahams
5b803f00e1 VC6 workarounds
[SVN r14447]
2002-07-14 12:38:41 +00:00
Dave Abrahams
9a0118d991 untabify
[SVN r14444]
2002-07-13 21:36:57 +00:00
Dave Abrahams
093aae1f46 Further rationalized conversion registry
[SVN r14441]
2002-07-13 18:44:51 +00:00
Dave Abrahams
e431318dc0 Added some more tests
[SVN r14437]
2002-07-13 15:16:50 +00:00
Dave Abrahams
c15812add2 long long fixes
[SVN r14434]
2002-07-13 12:11:53 +00:00
Dave Abrahams
3375cdbb49 Fixed for VC7.1
[SVN r14433]
2002-07-13 12:11:06 +00:00
Dave Abrahams
559b564714 tru64cxx6.5 fixes
[SVN r14421]
2002-07-12 14:32:20 +00:00
Dave Abrahams
3ac4cfb9a7 Fix mistaken cast
[SVN r14420]
2002-07-12 11:37:31 +00:00
Dave Abrahams
a4d651ce9a Kill tru64cxx warnings
[SVN r14419]
2002-07-12 11:36:15 +00:00
Dave Abrahams
d3bbc0eaa5 Work around older EDG bug
[SVN r14415]
2002-07-11 21:41:12 +00:00
Dave Abrahams
9ff90c98cd Merged registry tracing
[SVN r14414]
2002-07-11 21:32:39 +00:00
Dave Abrahams
b8aaf7d7b1 Rationalized conversion registry
Better error reporting


[SVN r14412]
2002-07-11 21:04:33 +00:00
Dave Abrahams
c0ecde90bc Test a few different lvalue conversions
[SVN r14411]
2002-07-11 21:03:30 +00:00
Dave Abrahams
83719a6f48 Attempted fix for long long handling
[SVN r14410]
2002-07-11 20:44:22 +00:00
Dave Abrahams
28011bbf55 Remove tuple/string dependencies for Achim
[SVN r14402]
2002-07-10 21:41:11 +00:00
Paul Mensonides
88170f6dc4 updated to new iteration interface
[SVN r14388]
2002-07-10 06:32:00 +00:00
Dave Abrahams
931aab22bb Use Paul M's preprocessor iteration
[SVN r14384]
2002-07-09 19:35:48 +00:00
Dave Abrahams
6cb4fbb1c4 Use Paul M's preprocessor iteration
[SVN r14383]
2002-07-09 19:21:52 +00:00
Dave Abrahams
54a551e488 Add missing prototype
[SVN r14381]
2002-07-09 18:58:45 +00:00
Dave Abrahams
5a0d84f185 Smarter range checking
[SVN r14380]
2002-07-09 18:57:53 +00:00
Dave Abrahams
222396759b MWERKS bug workaround
[SVN r14379]
2002-07-09 18:49:09 +00:00
Dave Abrahams
128c0ed5a1 Fixes for MSVC
[SVN r14378]
2002-07-09 18:43:00 +00:00
Dave Abrahams
ea74e34446 CWPro8 bug workarounds
[SVN r14377]
2002-07-09 18:38:02 +00:00
Dave Abrahams
c7225a059f workaround for CWPro7.2
[SVN r14372]
2002-07-09 15:20:18 +00:00
Dave Abrahams
c1f8ae662f Added missing typename
[SVN r14367]
2002-07-09 10:27:18 +00:00
Dave Abrahams
7d3227128c rvalue_data -> rvalue_from_python_data
[SVN r14357]
2002-07-08 21:35:18 +00:00
Dave Abrahams
182b6755f5 rvalue_data -> rvalue_from_python_data
[SVN r14355]
2002-07-08 19:17:00 +00:00
Dave Abrahams
0945f79ced Various kinds of cleanup and code massage; preparing for rvalue from_python protocol change
[SVN r14353]
2002-07-08 17:17:31 +00:00
Dave Abrahams
8b611322e5 Use new void_return mechanism
[SVN r14352]
2002-07-08 17:14:26 +00:00
Dave Abrahams
b255796b33 Bug fixes
[SVN r14308]
2002-07-05 15:25:40 +00:00
Dave Abrahams
2ae7c60780 Fix refcounting bugs in class object; add regression
Removed flotsam


[SVN r14287]
2002-07-02 23:34:21 +00:00
Dave Abrahams
279ad90a3c copy_ctor_self => assignment_self
[SVN r14286]
2002-07-02 23:31:40 +00:00
Dave Abrahams
bed7a7d29c Python long support
[SVN r14271]
2002-07-01 21:25:01 +00:00
Dave Abrahams
f02a3c5b47 Now inheriting object_cref from object
[SVN r14270]
2002-07-01 21:23:10 +00:00
Dave Abrahams
d7df5126ce list implementation
[SVN r14263]
2002-06-29 19:51:12 +00:00
Dave Abrahams
97ecfe7e03 a couple more tests
[SVN r14262]
2002-06-29 19:27:42 +00:00
Dave Abrahams
f30fde3a52 list implementation
[SVN r14261]
2002-06-29 19:24:11 +00:00
Dave Abrahams
d7273dee1c added missing 'explicit'
[SVN r14260]
2002-06-29 18:49:43 +00:00
Dave Abrahams
55dff4d512 slicing
[SVN r14219]
2002-06-20 21:47:26 +00:00
Ralf W. Grosse-Kunstleve
693b21188c previous patch breaks Visual C++ 6 & 7 compilations. Roll-back to a state that allows others to use CVS while we do more experiments.
[SVN r14208]
2002-06-20 10:33:34 +00:00
Ralf W. Grosse-Kunstleve
220734ccac workaround for IRIX CC (EDG238) bug; move to namespace boost::python::api
[SVN r14193]
2002-06-20 02:53:25 +00:00
Ralf W. Grosse-Kunstleve
bf84024d6b maybe slower but certainly conforming
[SVN r14190]
2002-06-20 00:19:59 +00:00
Ralf W. Grosse-Kunstleve
7bb39ae541 IRIX CC (EDG 238) fix/workaround.
[SVN r14189]
2002-06-19 23:00:43 +00:00
Dave Abrahams
d250057a7c GCC 3 workaround
[SVN r14188]
2002-06-19 22:58:58 +00:00
Dave Abrahams
d07454659a Work around some gcc-2.95.x bugs
Optimize code slightly by eliminating temporaries


[SVN r14185]
2002-06-19 19:18:21 +00:00
Dave Abrahams
913d2984ce Fixed object proxy chaining for everything bug GCC 2.9x
[SVN r14183]
2002-06-19 16:34:26 +00:00
Dave Abrahams
e2d75c0b76 Fixed is_borrowed_ptr
[SVN r14174]
2002-06-19 02:45:39 +00:00
Dave Abrahams
8aba486295 Fix tru64cxx problems, remove operator*/-> from object
[SVN r14173]
2002-06-19 02:12:14 +00:00
Dave Abrahams
66f2cd81a8 object operator support
[SVN r14168]
2002-06-18 13:49:09 +00:00
Dave Abrahams
87bda9e124 work around early EDG problem
[SVN r14164]
2002-06-17 22:26:17 +00:00
Dave Abrahams
954d019895 work around early EDG problem
[SVN r14163]
2002-06-17 20:23:13 +00:00
Dave Abrahams
41132af773 Bug fix
[SVN r14160]
2002-06-16 22:59:09 +00:00
Dave Abrahams
9a5b89da59 initial checkin
[SVN r14159]
2002-06-16 21:31:29 +00:00
Dave Abrahams
c12ffa21da beginning of object support
[SVN r14157]
2002-06-16 20:41:54 +00:00
Dave Abrahams
0b5937a396 type -> boost::type
[SVN r14154]
2002-06-16 20:18:51 +00:00
Dave Abrahams
773bb0651e borrow() -> borrowed()
type -> boost::type


[SVN r14153]
2002-06-16 20:13:38 +00:00
Dave Abrahams
8817b1e2af fixed missing template parameter
[SVN r14140]
2002-06-13 14:06:08 +00:00
Dave Abrahams
366ee6d24b reference<> => handle<>
[SVN r14136]
2002-06-12 21:59:17 +00:00
Dave Abrahams
0d58869d6e Fix refcounting bug
[SVN r14135]
2002-06-12 21:57:35 +00:00
Dave Abrahams
52ba3c7f80 expect_non_null optimization
[SVN r14134]
2002-06-12 20:52:53 +00:00
Dave Abrahams
14d2bae238 initial commit
[SVN r14131]
2002-06-11 19:51:44 +00:00
Dave Abrahams
e331512473 fix typo
[SVN r14130]
2002-06-11 15:48:32 +00:00
Dave Abrahams
1de6a21f3a Fix transform_iterator nonconformance
[SVN r14114]
2002-06-08 16:51:16 +00:00
Dave Abrahams
43d8c81104 use sys.maxint
[SVN r14112]
2002-06-08 15:35:10 +00:00
Ralf W. Grosse-Kunstleve
89930f34d7 undo accidental commit
[SVN r14103]
2002-06-07 17:14:13 +00:00
Ralf W. Grosse-Kunstleve
59ea6b120c MIPSpro 7.3.1.3 adjustments
[SVN r14102]
2002-06-07 16:37:24 +00:00
Ralf W. Grosse-Kunstleve
7c312d358b work-around for mipspro linker problem.
[SVN r14095]
2002-06-06 21:57:16 +00:00
Dave Abrahams
ac2746f680 * Generalized use of force_instantiate()
* Proper handling for numeric conversion overflows
* Moved internal converter names out of the way to prepare for user conversions
* Added comments
* Fixed a bug where None could be converted to the NULL target of a member function call, causing a crash.
* Wiped out and restarted todo.txt
* long long support
* Added more regression tests and checks for current limitations


[SVN r14094]
2002-06-06 20:24:39 +00:00
Ralf W. Grosse-Kunstleve
e2b4178f42 work-around for MIPSpro 7.3.1.3 problems that avoids #ifdef
[SVN r14085]
2002-06-05 23:47:18 +00:00
Ralf W. Grosse-Kunstleve
266954be99 adjustments for SGI MIPSpro 7.3.1.3m; tested with gcc, tru64_cxx65, vc7 tool sets.
[SVN r14084]
2002-06-05 22:13:34 +00:00
Dave Abrahams
2e3ae9decb fixup for __module__ attribute setting
[SVN r14082]
2002-06-04 20:26:18 +00:00
Dave Abrahams
6741698f71 Added comment as syncmail test
[SVN r14080]
2002-06-04 12:38:14 +00:00
Dave Abrahams
ccae1cc430 cleanup refcounting/naming
[SVN r14077]
2002-06-04 04:18:47 +00:00
Dave Abrahams
241a5bf4e5 operators documentation
[SVN r14076]
2002-06-04 03:30:34 +00:00
Dave Abrahams
e36aba8c66 bug fix
[SVN r14075]
2002-06-04 03:22:37 +00:00
Dave Abrahams
1a0baef147 fixed mod. date
[SVN r14074]
2002-06-04 02:41:30 +00:00
Ralf W. Grosse-Kunstleve
9a49d267eb EDG 245: trailing comma is nonstandard
[SVN r14073]
2002-06-03 19:12:40 +00:00
Ralf W. Grosse-Kunstleve
7a832f1fdb automatic addition of __module__ to class dict
[SVN r14072]
2002-06-03 18:35:59 +00:00
Dave Abrahams
16c391c78c enable operators.hpp for v2
eliminate dependence on full boost/function.hpp


[SVN r14071]
2002-06-02 19:09:03 +00:00
Dave Abrahams
92aae63af2 str(), pow(), complex() support
[SVN r14070]
2002-06-02 18:35:09 +00:00
Dave Abrahams
b042644c85 bind() doesn't work on extern "C" functions
[SVN r14069]
2002-06-02 12:01:35 +00:00
Dave Abrahams
97afc4bd0c operator support
[SVN r14068]
2002-06-02 05:44:06 +00:00
Dave Abrahams
a67b29a576 Flotsam removal; in theory this works around some Sun incompatibility also.
See http://mail.python.org/pipermail/c++-sig/2002-May/001193.html


[SVN r14066]
2002-06-02 05:39:41 +00:00
Dave Abrahams
97c87d0a99 fixed #include guard
[SVN r14065]
2002-06-02 05:35:30 +00:00
Dave Abrahams
fedf8d9935 Apply Martin's KCC bug workaround
[SVN r14062]
2002-05-29 21:24:25 +00:00
Dave Abrahams
23bfb84e38 Finally, it works on AIX!
[SVN r14061]
2002-05-29 20:32:49 +00:00
Dave Abrahams
c7d16fbf9e Pearu's test
[SVN r14057]
2002-05-29 13:02:14 +00:00
Dave Abrahams
033a3dd620 doc updates
[SVN r14056]
2002-05-29 12:59:39 +00:00
Dave Abrahams
f5a0b2fed8 Bug fix, thanks to Pearu Pearson for pointing it out!
[SVN r14055]
2002-05-28 23:47:38 +00:00
Dave Abrahams
b03dcfb7de doc updates
[SVN r14054]
2002-05-28 20:42:12 +00:00
Dave Abrahams
502094439c Kill superfluous forward declaration
[SVN r14048]
2002-05-28 20:26:41 +00:00
Dave Abrahams
c15f812366 bugfix
[SVN r14035]
2002-05-24 11:16:22 +00:00
Dave Abrahams
dd1b102282 result() fixes
[SVN r14031]
2002-05-23 22:42:09 +00:00
Dave Abrahams
67b3cdc7b7 lvalue_from_pytype + documentation
[SVN r14030]
2002-05-23 16:38:44 +00:00
Dave Abrahams
051994bdf4 initial commit
[SVN r14027]
2002-05-23 16:28:37 +00:00
Dave Abrahams
0f7c12b517 Added result() test
[SVN r14025]
2002-05-23 16:25:45 +00:00
Dave Abrahams
aa2b0090d3 bugfix
[SVN r14022]
2002-05-23 16:17:53 +00:00
Dave Abrahams
00b27c20da Added detail/result.hpp and tests
[SVN r14000]
2002-05-21 23:18:58 +00:00
Dave Abrahams
7ecd7e84d9 Cleaned up internals and generalized detail::target()
[SVN r13998]
2002-05-21 16:37:30 +00:00
Dave Abrahams
49c2dbd4a7 respect <sysinclude>
[SVN r13997]
2002-05-21 16:35:49 +00:00
Dave Abrahams
cf46535b66 instance_holder moved to boost::python
[SVN r13994]
2002-05-21 16:16:25 +00:00
Dave Abrahams
91e2e6f207 Bugfixes
[SVN r13981]
2002-05-19 20:29:56 +00:00
Dave Abrahams
b63434ce2e Added composition
[SVN r13980]
2002-05-19 20:29:40 +00:00
Dave Abrahams
dde6c42421 initial commit
[SVN r13979]
2002-05-19 20:23:00 +00:00
Dave Abrahams
beb6cca88d initial commit
[SVN r13976]
2002-05-19 14:06:16 +00:00
Dave Abrahams
ba2f18ce21 Lots of documentation updates, plus the associated code shuffling needed to expose the right things to users
[SVN r13975]
2002-05-19 04:57:44 +00:00
Dave Abrahams
c928eded74 bugfix
[SVN r13962]
2002-05-17 05:04:37 +00:00
Dave Abrahams
9baefc2e56 Documentation updates
[SVN r13961]
2002-05-17 05:02:44 +00:00
Dave Abrahams
313fe2c76c input iterator support
[SVN r13960]
2002-05-17 05:01:53 +00:00
Dave Abrahams
53c69e7ad5 Merged from RC_1_28_0
[SVN r13944]
2002-05-16 00:56:42 +00:00
Dave Abrahams
3ff935d4c4 initial commit
[SVN r13844]
2002-05-13 17:03:05 +00:00
Dave Abrahams
9fa89e8596 Added iterator support plus a minimal test to look for refcount problems.
[SVN r13843]
2002-05-13 16:41:50 +00:00
Dave Abrahams
6c20af07f7 Added setattr(), and the ability to query the class registry to see if a class has already been created
[SVN r13842]
2002-05-13 16:40:34 +00:00
Dave Abrahams
56abd7ba70 Added setattr()
[SVN r13841]
2002-05-13 16:39:25 +00:00
Dave Abrahams
dc1769b28a Handle reference<T> in make_function() calls.
[SVN r13840]
2002-05-13 16:35:07 +00:00
Dave Abrahams
97b863101b Add result_type definition
[SVN r13839]
2002-05-13 16:33:55 +00:00
Dave Abrahams
0a1b62a760 Added is_reference_to_class, is_pointer_to_class
[SVN r13838]
2002-05-13 16:32:59 +00:00
Dave Abrahams
f2fa852f1a initial commit
[SVN r13837]
2002-05-13 16:31:42 +00:00
Dave Abrahams
59f4ddf5af Work around MSVC6 bug
[SVN r13836]
2002-05-13 16:30:09 +00:00
Dave Abrahams
673d857bd8 Added setattr()
[SVN r13835]
2002-05-13 16:29:43 +00:00
Dave Abrahams
36be16b3e9 Quick bugfix
[SVN r13825]
2002-05-11 17:11:51 +00:00
Dave Abrahams
390bb1988d implemented back_reference<>
[SVN r13811]
2002-05-10 15:48:27 +00:00
Dave Abrahams
63deae3ab2 Moved pointee up from detail
[SVN r13810]
2002-05-10 15:47:59 +00:00
Dave Abrahams
710374ed1e Added Dereferenceable, ResultConverter
[SVN r13809]
2002-05-10 15:47:04 +00:00
Dave Abrahams
8f1dc2522a Added Dereferenceable
[SVN r13808]
2002-05-10 15:46:37 +00:00
Dave Abrahams
9c3dd76e25 obsolete
[SVN r13807]
2002-05-10 15:42:52 +00:00
Dave Abrahams
3328087de1 Added missing add_property chaining
[SVN r13806]
2002-05-10 15:41:44 +00:00
Dave Abrahams
ec3f5ff40b initial commit
[SVN r13799]
2002-05-10 09:44:24 +00:00
Dave Abrahams
3b000f080e tweak
[SVN r13798]
2002-05-10 09:38:07 +00:00
Dave Abrahams
09046c53ef ResultConverter/ResultConverterGenerator
[SVN r13793]
2002-05-10 04:00:33 +00:00
Dave Abrahams
13331d3eab updated
[SVN r13792]
2002-05-10 00:58:31 +00:00
300 changed files with 21929 additions and 14220 deletions

22
Jamfile
View File

@@ -4,8 +4,22 @@ subproject libs/python ;
SEARCH on <module@>python.jam = $(BOOST_BUILD_PATH) ;
include <module@>python.jam ;
local bpl-ldflags ;
if $(UNIX) && ( $(OS) = AIX )
{
bpl-linkflags = <linkflags>"-e initlibbpl" ;
}
dll bpl
:
src/list.cpp
src/long.cpp
src/dict.cpp
src/tuple.cpp
src/str.cpp
src/aix_init_module.cpp
src/converter/from_python.cpp
src/converter/registry.cpp
src/converter/type_id.cpp
@@ -13,12 +27,16 @@ dll bpl
src/object/function.cpp
src/object/inheritance.cpp
src/object/life_support.cpp
src/object/pickle_support.cpp
src/errors.cpp
src/module.cpp
src/objects.cpp
src/converter/builtin_converters.cpp
src/converter/callback.cpp
src/converter/arg_to_python_base.cpp
src/object/iterator.cpp
src/object_protocol.cpp
src/object_operators.cpp
:
$(BOOST_PYTHON_V2_PROPERTIES)
<define>BOOST_PYTHON_SOURCE
$(bpl-linkflags)
;

View File

@@ -89,11 +89,12 @@ local CPP_SOURCES =
;
lib boost_python_static : ../src/$(CPP_SOURCES).cpp
# requirements
: $(BOOST_PYTHON_INCLUDES)
# requirements
: $(BOOST_PYTHON_INCLUDES)
<shared-linkable>true
<define>BOOST_PYTHON_STATIC_LIB=1
[ difference $(PYTHON_PROPERTIES) : <define>BOOST_PYTHON_DYNAMIC_LIB ]
<define>BOOST_PYTHON_STATIC_LIB=1
[ difference $(PYTHON_PROPERTIES) : <define>BOOST_PYTHON_DYNAMIC_LIB ]
: <suppress>true # don't build this unless the user asks for it by name
;
dll boost_python
@@ -106,6 +107,14 @@ dll boost_python
$(PYTHON_PROPERTIES)
;
stage bin-stage : <dll>boost_python
:
<tag><debug>"_debug"
<tag><debug-python>"_pydebug"
:
debug release
;
############# comprehensive module and test ###########
bpl-test boost_python_test
: ../test/comprehensive.cpp ;

View File

@@ -3,15 +3,20 @@
if ! $(gNO_PYTHON_INSTALL)
{
ECHO "Couldn't find Python $(PYTHON_VERSION) installation in $(PYTHON_ROOT)" ;
ECHO "---------------------------------------------------------------------" ;
ECHO skipping Boost.Python library build ;
ECHO You can configure the location of your python installation, by setting: ;
ECHO PYTHON_ROOT - currently \"$(PYTHON_ROOT)\" ;
ECHO PYTHON_VERSION - currently \"$(PYTHON_VERSION)\" ;
ECHO "PYTHON_ROOT - currently" \"$(PYTHON_ROOT:J=" ")\" ;
ECHO "PYTHON_VERSION - The 2-part python Major.Minor version number (e.g." ;
ECHO " \"2.2\", NOT \"2.2.1\") - currently" \"$(PYTHON_VERSION)\" ;
ECHO ;
ECHO "The following are automatically configured from PYTHON_ROOT if not otherwise set" ;
ECHO " PYTHON_INCLUDES - path to Python #include directories; currently" \"$(PYTHON_INCLUDES)\" ;
ECHO " PYTHON_LIB_PATH - path to Python library; currently" \"$(PYTHON_LIB_PATH)\" ;
ECHO " PYTHON_STDLIB_PATH - path to Python standard library modules; currently" \"$(PYTHON_STDLIB_PATH)\" ;
ECHO "The following are automatically configured from PYTHON_ROOT if not" ;
ECHO "otherwise set:" ;
ECHO " PYTHON_INCLUDES - path to Python #include directories; currently" \"$(PYTHON_INCLUDES:J=" ")\" ;
ECHO " PYTHON_LIB_PATH - path to Python library; currently" ;
ECHO " " \"$(PYTHON_LIB_PATH:J=" ")\" ;
ECHO " PYTHON_STDLIB_PATH - path to Python standard library modules; currently" ;
ECHO " " \"$(PYTHON_STDLIB_PATH:J=" ")\" ;
ECHO "---------------------------------------------------------------------" ;
}
gNO_PYTHON_INSTALL ?= true ;

View File

@@ -1,136 +0,0 @@
# Microsoft Developer Studio Project File - Name="example1" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=example1 - Win32 DebugPython
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "example1.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "example1.mak" CFG="example1 - Win32 DebugPython"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "example1 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "example1 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "example1 - Win32 DebugPython" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "example1 - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE1_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE1_EXPORTS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release/hello.dll" /libpath:"c:\tools\python\libs"
!ELSEIF "$(CFG)" == "example1 - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE1_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm- /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE1_EXPORTS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /out:"Debug/hello.dll" /pdbtype:sept /libpath:"c:\tools\python\libs"
!ELSEIF "$(CFG)" == "example1 - Win32 DebugPython"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "example1___Win32_DebugPython"
# PROP BASE Intermediate_Dir "example1___Win32_DebugPython"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "DebugPython"
# PROP Intermediate_Dir "DebugPython"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE1_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm- /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE1_EXPORTS" /D "BOOST_DEBUG_PYTHON" /YX /FD /GZ /EHs /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /out:"Debug/hello.dll" /pdbtype:sept /libpath:"c:\tools\python\libs"
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /out:"DebugPython/hello_d.dll" /pdbtype:sept /libpath:"c:\tools\python\src\PCbuild"
!ENDIF
# Begin Target
# Name "example1 - Win32 Release"
# Name "example1 - Win32 Debug"
# Name "example1 - Win32 DebugPython"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\example\example1.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -1,136 +0,0 @@
# Microsoft Developer Studio Project File - Name="getting_started1" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=getting_started1 - Win32 DebugPython
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "getting_started1.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "getting_started1.mak" CFG="getting_started1 - Win32 DebugPython"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "getting_started1 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "getting_started1 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "getting_started1 - Win32 DebugPython" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=xicl6.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "getting_started1 - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /libpath:"c:\tools\python\libs"
!ELSEIF "$(CFG)" == "getting_started1 - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GR /GX /ZI /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept /libpath:"c:\tools\python\libs"
!ELSEIF "$(CFG)" == "getting_started1 - Win32 DebugPython"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "DebugPython"
# PROP BASE Intermediate_Dir "DebugPython"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "DebugPython"
# PROP Intermediate_Dir "DebugPython"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /D "BOOST_DEBUG_PYTHON" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /pdb:"DebugPython/boost_python_test_d.pdb" /debug /machine:I386 /out:"DebugPython/getting_started1_d.dll" /pdbtype:sept /libpath:"c:\tools\python\src\PCbuild"
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "getting_started1 - Win32 Release"
# Name "getting_started1 - Win32 Debug"
# Name "getting_started1 - Win32 DebugPython"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\example\getting_started1.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -1,135 +0,0 @@
# Microsoft Developer Studio Project File - Name="getting_started2" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=getting_started2 - Win32 DebugPython
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "getting_started2.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "getting_started2.mak" CFG="getting_started2 - Win32 DebugPython"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "getting_started2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "getting_started2 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "getting_started2 - Win32 DebugPython" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "getting_started2"
# PROP Scc_LocalPath "."
CPP=xicl6.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "getting_started2 - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /libpath:"c:\tools\python\libs"
!ELSEIF "$(CFG)" == "getting_started2 - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm- /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept /libpath:"c:\tools\python\libs"
!ELSEIF "$(CFG)" == "getting_started2 - Win32 DebugPython"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "getting_started2___Win32_DebugPython"
# PROP BASE Intermediate_Dir "getting_started2___Win32_DebugPython"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "getting_started2___Win32_DebugPython"
# PROP Intermediate_Dir "getting_started2___Win32_DebugPython"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm- /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /D "BOOST_DEBUG_PYTHON" /FR /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"DebugPython/getting_started2_d.dll" /pdbtype:sept /libpath:"c:\tools\python\src\pcbuild"
!ENDIF
# Begin Target
# Name "getting_started2 - Win32 Release"
# Name "getting_started2 - Win32 Debug"
# Name "getting_started2 - Win32 DebugPython"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\example\getting_started2.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -1,135 +0,0 @@
# Microsoft Developer Studio Project File - Name="rwgk1" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=rwgk1 - Win32 DebugPython
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "rwgk1.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "rwgk1.mak" CFG="rwgk1 - Win32 DebugPython"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "rwgk1 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "rwgk1 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "rwgk1 - Win32 DebugPython" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "rwgk1 - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RWGK1_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RWGK1_EXPORTS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /libpath:"c:\tools\python\libs"
!ELSEIF "$(CFG)" == "rwgk1 - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RWGK1_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm- /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RWGK1_EXPORTS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /pdbtype:sept /libpath:"c:\tools\python\libs"
!ELSEIF "$(CFG)" == "rwgk1 - Win32 DebugPython"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "rwgk1___Win32_DebugPython"
# PROP BASE Intermediate_Dir "rwgk1___Win32_DebugPython"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "DebugPython"
# PROP Intermediate_Dir "DebugPython"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RWGK1_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm- /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RWGK1_EXPORTS" /D "BOOST_DEBUG_PYTHON" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /pdbtype:sept /libpath:"c:\tools\python\libs"
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /out:"DebugPython/rwgk1_d.dll" /pdbtype:sept /libpath:"C:\tools\python\src\PCbuild"
!ENDIF
# Begin Target
# Name "rwgk1 - Win32 Release"
# Name "rwgk1 - Win32 Debug"
# Name "rwgk1 - Win32 DebugPython"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\example\rwgk1.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -1,145 +0,0 @@
# Microsoft Developer Studio Project File - Name="test" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=test - Win32 DebugPython
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "test.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "test.mak" CFG="test - Win32 DebugPython"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "test - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "test - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "test - Win32 DebugPython" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "test - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /YX /FD /Zm200 /c
# SUBTRACT CPP /Fr
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release/boost_python_test.dll" /libpath:"c:\tools\python\libs"
!ELSEIF "$(CFG)" == "test - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm- /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /YX /FD /GZ /Zm200 /c
# SUBTRACT CPP /Fr
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /out:"Debug/boost_python_test.dll" /pdbtype:sept /libpath:"c:\tools\python\libs"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "test - Win32 DebugPython"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "test___Win32_DebugPython"
# PROP BASE Intermediate_Dir "test___Win32_DebugPython"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "DebugPython"
# PROP Intermediate_Dir "DebugPython"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /YX /FD /GZ /Zm200 /c
# ADD CPP /nologo /MDd /W3 /Gm- /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /D "BOOST_DEBUG_PYTHON" /YX /FD /GZ /Zm200 /EHs /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /pdbtype:sept /libpath:"c:\tools\python\libs"
# SUBTRACT BASE LINK32 /pdb:none
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /out:"DebugPython/boost_python_test_d.dll" /pdbtype:sept /libpath:"c:\tools\python\src\PCbuild"
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "test - Win32 Release"
# Name "test - Win32 Debug"
# Name "test - Win32 DebugPython"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\test\comprehensive.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\test\comprehensive.hpp
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -9,172 +9,214 @@
"../../../c++boost.gif" alt="c++boost.gif (8819 bytes)">Building an
Extension Module</h1>
<p>The build process for Boost is currently undergoing some evolution,
and, it is to be hoped, improvement. The following facts may help:
<h2>Building Boost.Python</h2>
<hr>
Makefiles for various platforms and a Visual Studio project
reside in the Boost subdirectory <tt>libs/python/build</tt>.
Build targets include:
<p>Every Boost.Python extension module must be linked with the
<code>boost_python</code> shared library. To build
<code>boost_python</code>, use <a
href="../../../tools/build/index.html">Boost.Build</a> in the
usual way from the <code>libs/python/build</code> subdirectory
of your boost installation (if you have already built boost from
the top level this may have no effect, since the work is already
done).
<h3>Configuration</h3>
You may need to configure the following variables to point Boost.Build at your Python installation:
<table border="1">
<tr><th>Variable Name <th>Semantics <th>Default <th>Notes
<tr>
<td><code>PYTHON_ROOT</code>
<td>The root directory of your Python installation
<td>Windows:&nbsp;<code>c:/tools/python</code>
Unix:&nbsp;<code>/usr/local</code>
<td>On Unix, this is the <code>--with-prefix=</code> directory
used to configure Python
<tr>
<td><code>PYTHON_VERSION</code>
<td>The The 2-part python Major.Minor version number
<td>Windows:&nbsp;<code>2.1</code>
Unix:&nbsp;<code>1.5</code>
<td>Be sure not to include a third number, e.g. <b>not</b>
&quot;<code>2.2.1</code>&quot;, even if that's the version you
have.
<tr>
<td><code>PYTHON_INCLUDES</code>
<td>path to Python <code>#include</code> directories
<td>Autoconfigured from <code>PYTHON_ROOT</code>
<tr>
<td><code>PYTHON_LIB_PATH</code>
<td>path to Python library object.
<td>Autoconfigured from <code>PYTHON_ROOT</code>
<tr>
<td><code>PYTHON_STDLIB_PATH</code>
<td>path to Python standard library modules
<td>Autoconfigured from <code>PYTHON_ROOT</code>
<tr>
<td><code>CYGWIN_ROOT</code>
<td>path to the user's Cygwin installation
<td>
<td><a href="http://www.cygwin.com">Cygwin</a> only. This and the following two settings are
useful when building with multiple toolsets on Windows, since
Cygwin requires a different build of Python.
<tr>
<td><code>GCC_PYTHON_ROOT</code>
<td>path to the user's Cygwin Python installation
<td><code>$(CYGWIN_ROOT)/usr/local</code>
<td><a href="http://www.cygwin.com">Cygwin</a> only
<tr>
<td><code>GCC_DEBUG_PYTHON_ROOT</code>
<td>path to the user's Cygwin <code><a
href="#variants">pydebug</a></code> build
<td><code>$(CYGWIN_ROOT)/usr/local/pydebug</code>
<td><a href="http://www.cygwin.com">Cygwin</a> only
</table>
<h3>Results</h3>
<p>The build process will create a
<code>libs/python/build/bin-stage</code> subdirectory of the
boost root (or of <code>$(ALL_LOCATE_TARGET)</code>,
if you have set that variable), containing the built
libraries. The libraries are actually built to unique
directories for each toolset and variant elsewhere in the
filesystem, and copied to the
<code>bin-stage</code> directory as a convenience, so if you
build with multiple toolsets at once, the product of later
toolsets will overwrite that of earlier toolsets in
<code>bin-stage</code>.
<h3>Testing</h3>
<p>To build and test Boost.Python from within the
<code>libs/python/build</code> directory, invoke
<blockquote>
<pre>
bjam -sTOOLS=<i><a href="../../../tools/build/index.html#Tools">toolset</a></i> test
</pre>
</blockquote>
This will
update all of the Boost.Python v1 test and example targets. The tests
are relatively quiet by default. To get more-verbose output, you might try
<blockquote>
<pre>
bjam -sTOOLS=<i><a href="../../../tools/build/index.html#Tools">toolset</a></i> -sPYTHON_TEST_ARGS=-v test
</pre>
</blockquote>
which will print each test's Python code with the expected output as
it passes.
<h2>Building your Extension Module</h2>
Though there are other approaches, the easiest way to build an
extension module using Boost.Python is with Boost.Build. Until
Boost.Build v2 is released, cross-project build dependencies are
not supported, so it works most smoothly if you add a new
subproject to your boost installation. The
<code>libs/python/example</code> subdirectory of your boost
installation contains a minimal example (along with many extra
sources). To copy the example subproject:
<ol>
<li>Create a new subdirectory in, <code>libs/python</code>, say
<code>libs/python/my_project</code>.
<li>Copy <code><a
href="../example/Jamfile">libs/python/example/Jamfile</a></code>
to your new directory.
<li>Edit the Jamfile as appropriate for your project. You'll
want to change the &quot;<code>subproject</code>&quot; rule
invocation at the top, and the names of some of the source files
and/or targets.
</ol>
If you can't modify or copy your boost installation, the
alternative is to create your own Boost.Build project. A similar
example you can use as a starting point is available in <code><a
href="../example/project.zip">this archive</a></code>. You'll
need to edit the Jamfile and Jamrules files, depending on the
relative location of your Boost installation and the new
project. Note that automatic testing of extension modules is not
available in this configuration.
<h2><a name="variants">Build Variants</a></h2>
Three <a
href="../../../tools/build/build_system.htm#variants">variant</a>
configurations of all python-related targets are supported, and
can be selected by setting the <code><a
href="../../../tools/build/build_system.htm#user_globals">BUILD</a></code>
variable:
<ul>
<li>The <tt>boost_python</tt> library for static linking with your
extension module. On the various Unices, this library will be
called <tt>libboost_python.a</tt>. When using Visual C++, the
library will be called <tt>boost_python.lib</tt>.
<li><code>release</code> (optimization, <tt>-DNDEBUG</tt>)
<p>
<li>A comprehensive test of Boost.Python features. This test builds
a Boost.Python extension module, then runs Python to import the
module, and runs a series of tests on it using <tt><a href=
"../test/doctest.py">doctest</a></tt>. Source code for the module
and tests is available in the Boost subdirectory
<tt>libs/python/test</tt>.
<li><code>debug</code> (no optimization <tt>-D_DEBUG</tt>)
<p>
<li>Various examples from the Boost subdirectory
<tt>libs/python/example</tt>.
All these examples include a doctest modeled
on the comprehensive test above.
</ul>
<hr>
There is a group of makefiles with support for simultaneous
compilation on multiple platforms and a consistent set of
features that build the <tt>boost_python</tt> library for static
linking, the comprehensive test, and all examples in
<tt>libs/python/example</tt>:
<ul>
<li><a href="../build/vc60.mak">vc60.mak</a>:
Visual C++ 6.0 Service Pack 4
<li><a href="../build/mingw32.mak">mingw32.mak</a>:
mingw32 (Win32-targeted) gcc 2.95.2
<li><a href="../build/linux_gcc.mak">linux_gcc.mak</a>:
gcc 2.95.2 on Linux/Unix
<li><a href="../build/tru64_cxx.mak">tru64_cxx.mak</a>:
Compaq Alpha using the Compaq cxx compiler
<li><a href="../build/irix_CC.mak">irix_CC.mak</a>:
Silicon Graphics IRIX 6.5 CC compiler
</ul>
<a href="http://cctbx.sourceforge.net/page_installation_adv.html#installation_boost_python"
>Usage of these makefiles is described here.</a>
<hr>
There is another group of makefiles for GNU make.
These makefiles are less redundant than the makefiles
in the group above,
but the list of compilation targets is not as complete
and there is no support for simultaneous compilation
on multiple platforms.
<ul>
<li><a href="../build/como.mak">como.mak</a>:
Comeau C++ on Linux
<li><a href="../build/gcc.mak">gcc.mak</a>:
GCC on Linux/Unix.
</ul>
<hr>
A project workspace for Microsoft Visual Studio is provided at <tt><a
href="../build/build.dsw">libs/python/build/build.dsw</a></tt>. The
include paths for this project may need to be changed for your
installation. They currently assume that python has been installed at
<tt>c:\tools\python</tt>. Three configurations of all targets are
supported:
<ul>
<li>Release (optimization, <tt>-DNDEBUG</tt>)
<li>Debug (no optimization <tt>-D_DEBUG</tt>)
<li>DebugPython (no optimization, <tt>-D_DEBUG
<li><code>debug-python</code> (no optimization, <tt>-D_DEBUG
-DBOOST_DEBUG_PYTHON</tt>)
</ul>
<p>When extension modules are built with Visual C++ using
<p>The first two variants of the <code>boost_python</code>
library are built by default, and are compatible with the
default Python distribution. The <code>debug-python</code>
variant corresponds to a specially-built debugging version of
Python. On Unix platforms, this python is built by adding
<code>--with-pydebug</code> when configuring the Python
build. On Windows, the debugging version of Python is generated
by the &quot;Win32 Debug&quot; target of the
<code>PCBuild.dsw</code> Visual C++ 6.0 project in the
<code>PCBuild</code> subdirectory of your Python distribution.
Extension modules built with Python debugging enabled are <b>not
link-compatible</b> with a non-debug build of Python. Since few
people actually have a debug build of Python (it doesn't come
with the standard distribution), the normal
<code>debug</code> variant builds modules which are compatible
with ordinary Python.
<p>On many windows compilers, when extension modules are built
with
<tt>-D_DEBUG</tt>, Python defaults to <i>force</i> linking with a
special debugging version of the Python DLL. Since this debug DLL
isn't supplied with the default Python installation for Windows,
Boost.Python uses <tt><a href=
"../../../boost/python/detail/wrap_python.hpp">boost/python/detail/wrap_python.hpp</a></tt>
to temporarily undefine <tt>_DEBUG</tt> when <tt>Python.h</tt> is
<tt>#include</tt>d.
<tt>#include</tt>d - unless <code>BOOST_DEBUG_PYTHON</code> is defined.
<p>If you want the extra runtime checks available with the debugging
version of the library, <tt>#define BOOST_DEBUG_PYTHON</tt> to
re-enable library forcing, and link with the DebugPython version of
<tt>boost_python.lib</tt>. You'll need to get the debugging version
of the Python executable (<tt>python_d.exe</tt>) and DLL
(<tt>python20_d.dll</tt> or <tt>python15_d.dll</tt>). The Python
sources include project files for building these. If you <a href=
"http://www.python.org">download</a> them, change the name of the
top-level directory to <tt>src</tt>, and install it under
<tt>c:\tools\python</tt>, the workspace supplied by Boost.Python will
be able to use it without modification. Just open
<tt>c:\tools\python\src\pcbuild\pcbuild.dsw</tt> and invoke "build
all" to generate all the debugging targets.
<p>If you want the extra runtime checks available with the
debugging version of the library, <tt>#define
BOOST_DEBUG_PYTHON</tt> to re-enable python debuggin, and link
with the <code>debug-python</code> variant of
<tt>boost_python</tt>.
<p>If you do not <tt>#define BOOST_DEBUG_PYTHON</tt>, be sure that
any source files <tt>#include &lt;<a href=
any source files in your extension module <tt>#include &lt;<a href=
"../../../boost/python/detail/wrap_python.hpp">boost/python/detail/wrap_python.hpp</a>&gt;</tt>
instead of the usual <tt>Python.h</tt>, or you will have link
incompatibilities.<br>
<hr>
If your platform isn't directly supported, you can build a static
library from the following source files (in the Boost subdirectory
<tt>libs/python/src</tt>), or compile them directly and link the
resulting objects into your extension module:
<ul>
<li><a href=
"../../../libs/python/src/classes.cpp">classes.cpp</a>
<li><a href=
"../../../libs/python/src/conversions.cpp">conversions.cpp</a>
<li><a href=
"../../../libs/python/src/cross_module.cpp">cross_module.cpp</a>
<li><a href=
"../../../libs/python/src/extension_class.cpp">extension_class.cpp</a>
<li><a href=
"../../../libs/python/src/functions.cpp">functions.cpp</a>
<li><a href=
"../../../libs/python/src/init_function.cpp">init_function.cpp</a>
<li><a href=
"../../../libs/python/src/module_builder.cpp">module_builder.cpp</a>
<li><a href=
"../../../libs/python/src/objects.cpp">objects.cpp</a>
<li><a href=
"../../../libs/python/src/types.cpp">types.cpp</a>
</ul>
<hr>
Next: <a href="enums.html">Wrapping Enums</a> Previous: <a href=
"under-the-hood.html">A Peek Under the Hood</a> Up: <a href=
"index.html">Top</a>
<hr>
<p>&copy; Copyright David Abrahams 2000. Permission to copy, use, modify,
<p>&copy; Copyright David Abrahams 2002. Permission to copy, use, modify,
sell and distribute this document is granted provided this copyright
notice appears in all copies. This document is provided ``as is'' without
express or implied warranty, and with no claim as to its suitability for
any purpose.
<p>Updated: Apr 17, 2001 (R.W. Grosse-Kunstleve)
<p>Updated: May 15, 2002 (David Abrahams)
</div>

View File

@@ -18,6 +18,21 @@
<em>should</em> simply ``reflect'' your C++ classes and functions into
Python.
<p>
<table border="1">
<tr><td> <b>Note:</b> this is the last official release of
Boost.Python v1. Development of this version of the library has
stopped; it will be retired soon in favor of the redesigned and
improved version 2. A summary of the development goals is available on
the Python <a href="http://www.python.org/sigs/c++-sig/">C++-sig</a>
page, which also serves as a mailing list for users of both versions
of the library. A preview of the v2 documentation is available <a
href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/boost/boost/libs/python/doc/v2/index.html?rev=HEAD&content-type=text/html">here</a>,
and instructions for getting started with a prerelease are available
upon request.
</table>
<h2>Supported Platforms</h2>
<p>Boost.Python is known to have been tested
against <a href="http://www.python/org/2.2.1">Python 2.2.1</a> using

View File

@@ -81,10 +81,10 @@ BOOST_PYTHON_MODULE_INIT(my_module)
    python::module_builder my_module("my_module");
    python::class_builder&lt;Base&gt; base_class(my_module, "Base");
    base_class.def(python::constructor&lt;void&gt;());
    base_class.def(python::constructor&lt;&gt;());
    python::class_builder&lt;Derived&gt; derived_class(my_module, "Derived");
    derived_class.def(python::constructor&lt;void&gt;());
    derived_class.def(python::constructor&lt;&gt;());
<b>// Establish the inheritance relationship between Base and Derived
derived_class.declare_base(base_class);</b>
@@ -137,10 +137,10 @@ struct Derived2 { int f(); };
<hr>
...
   python::class_builder&lt;Base&gt; base2_class(my_module, "Base2");
   base2_class.def(python::constructor&lt;void&gt;());
   base2_class.def(python::constructor&lt;&gt;());
   python::class_builder&lt;Derived2&gt; derived2_class(my_module, "Derived2");
   derived2_class.def(python::constructor&lt;void&gt;());
   derived2_class.def(python::constructor&lt;&gt;());
derived_class.declare_base(base_class, <b>python::without_downcast</b>);
</pre>
</blockquote>

View File

@@ -9,7 +9,8 @@
"header">
<tr>
<td valign="top" width="300">
<h3><a href="http://www.boost.org"><img height="86" width="277" alt="C++ Boost" src="../c++boost.gif" border="0"></a></h3>
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>
@@ -119,7 +120,7 @@ more-sophisticated overloading mechanism than the current
simple-minded &quot;first match&quot; approach, as I suggested <a
href="Mar2002.html#implicit_conversions">last month</a>.
<h3><a name="v1">Boost.Python V1 Mainenance</a></h3>
<h3><a name="v1">Boost.Python V1 Maintenance</a></h3>
As much as I'm looking forward to retiring Boost.Python v1, a
significant amount of effort has been being spent dealing with support

124
doc/v2/CallPolicies.html Normal file
View File

@@ -0,0 +1,124 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
<title>Boost.Python - CallPolicies Concept</title>
</head>
<body link="#0000ff" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>
<h2 align="center">CallPolicies Concept</h2>
</td>
</tr>
</table>
<hr>
<dl class="page-index">
<dt><a href="#introduction">Introduction</a></dt>
<dt><a href="#composition">CallPolicies Composition</a></dt>
<dt><a href="#concept-requirements">Concept Requirements</a></dt>
<dl class="page-index">
<dt><a href="#CallPolicies-concept">CallPolicies Concept</a></dt>
</dl>
</dl>
<h2><a name="introduction"></a>Introduction</h2>
<p>Models of the CallPolicies concept are used to specialize the
behavior of Python callable objects generated by Boost.Python to
wrapped C++ objects like function and member function
pointers, providing three behaviors:
<ol>
<li> <code>precall</code> - Python argument tuple management before
the wrapped object is invoked
<li> <code>result_converter</code> - C++ return value handling
<li> <code>postcall</code> - Python argument tuple and result
management after the wrapped object is invoked
</ol>
<h2><a name="composition"></a>CallPolicies Composition</h2>
In order to allow the use of multiple models of CallPolicies in the
same callable object, Boost.Python's CallPolicies class templates
provide a chaining interface which allows them to be recursively
composed. This interface takes the form of an optional template
parameter, <code>Base</code> which defaults to <a
href="default_call_policies.html#default_call_policies-spec">
<code>default_call_policies</code></a>. By convention, the
<code>precall</code> function of the
<code>Base</code> is invoked <i>after</i> the <code>precall</code>
function supplied by the outer template, and the <code>postcall</code>
function of the <code>Base</code> is invoked <i>before</i> the
<code>postcall</code> function of the outer template. If a
<code>result_converter</code> is supplied by the outer template, it
<i>replaces</i> any <code>result_converter</code> supplied by the
<code>Base</code>. For an example, see <a
href="return_internal_reference.html#return_internal_reference-spec">
<code>return_internal_reference</code></a>.
<h2><a name="concept-requirements"></a>Concept Requirements</h2>
<h3><a name="CallPolicies-concept"></a>CallPolicies Concept</h3>
<p>In the table below, <code><b>x</b></code> denotes an object whose
type <code><b>P</b></code> is a model of CallPolicies,
<code><b>a</b></code> denotes a <code>PyObject*</code> pointing to
a Python argument tuple object, and <code><b>r</b></code> denotes a
<code>PyObject*</code> referring to a &quot;preliminary&quot; result
object.
<table summary="CallPolicies expressions" border="1" cellpadding="5">
<tr>
<td><b>Expression</b></td>
<td><b>Type</b></td>
<td><b>Result/Semantics</b></td>
</tr>
<tr>
<td valign="top"><code>x.precall(a)</code></td>
<td>convertible to <code>bool</code>
<td>returns <code>false</code> and <code><a
href="http://www.python.org/doc/2.2/api/exceptionHandling.html#l2h-71">PyErr_Occurred</a>()&nbsp;!=&nbsp;0</code>
upon failure, <code>true</code> otherwise.
<tr>
<td valign="top"><code>P::result_converter</code></td>
<td>A model of <a href="ResultConverter.html#ResultConverterGenerator-concept">ResultConverterGenerator</a>.
<td>An MPL unarymetafunction object used produce the
&quot;preliminary&quot result object.
<tr>
<td valign="top"><code>x.postcall(a, r)</code></td>
<td>convertible to <code>PyObject*</code>
<td>0 <code>0</code> and <code><a
href="http://www.python.org/doc/2.2/api/exceptionHandling.html#l2h-71">PyErr_Occurred</a>()&nbsp;!=&nbsp;0</code>
upon failure. Must &quot;conserve references&quot; even in the
event of an exception. In other words, if <code>r</code> is not
returned, its reference count must be decremented; if another
existing object is returned, its reference count must be
incremented.
</table>
Models of CallPolicies are required to be <a
href="../../../utility/CopyConstructible.html">CopyConstructible</a>.
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
19 May, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave
Abrahams</a> 2002. All Rights Reserved.</i>
<p>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.
</body>
</html>

View File

@@ -0,0 +1,66 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
<title>Boost.Python - Dereferenceable Concept</title>
</head>
<body link="#0000ff" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>
<h2 align="center">Dereferenceable Concept</h2>
</td>
</tr>
</table>
<hr>
<dl class="page-index">
<dt><a href="#introduction">Introduction</a></dt>
<dt><a href="#concept-requirements">Concept Requirements</a></dt>
<dl class="page-index">
<dt><a href="#Dereferenceable-concept">Dereferenceable Concept</a></dt>
</dl>
</dl>
<h2><a name="introduction"></a>Introduction</h2>
<p>Instances of a dereferenceable type can be used like a pointer to access an lvalue.
<h2><a name="concept-requirements"></a>Concept Requirements</h2>
<h3><a name="Dereferenceable-concept"></a>Dereferenceable Concept</h3>
<p>In the table below, <code><b>x</b></code> denotes an object whose
type is a model of Dereferenceable.
<table summary="Dereferenceable expressions" border="1" cellpadding="5">
<tr>
<td><b>Expression</b></td>
<td><b>Requirements</b></td>
</tr>
<tr>
<td valign="top"><code>*x</code></td>
<td>An lvalue
</tr>
</table>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
10 May, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave
Abrahams</a> 2002. All Rights Reserved.</i>
<p>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.
</body>
</html>

93
doc/v2/Extractor.html Executable file
View File

@@ -0,0 +1,93 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
<title>Boost.Python - Extractor Concept</title>
</head>
<body link="#0000ff" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>
<h2 align="center">Extractor Concept</h2>
</td>
</tr>
</table>
<hr>
<dl class="page-index">
<dt><a href="#introduction">Introduction</a></dt>
<dt><a href="#concept-requirements">Concept Requirements</a></dt>
<dl class="page-index">
<dt><a href="#Extractor-concept">Extractor Concept</a></dt>
</dl>
<dt><a href="#notes">Notes</a></dt>
</dl>
<h2><a name="introduction"></a>Introduction</h2>
<p>An Extractor is a class which Boost.Python can use to extract C++
objects from Python objects, and is typically used by facilities that
define <code>from_python</code> conversions for
&quot;traditional&quot; Python extension types.
<h2><a name="concept-requirements"></a>Concept Requirements</h2>
<h3><a name="Extractor-concept"></a>Extractor Concept</h3>
<p>In the table below, <code><b>X</b></code> denotes a model of
Extractor and <code><b>a</b></code> denotes an instance of a Python
object type.
<table summary="Extractor expressions" border="1" cellpadding="5">
<tr>
<td><b>Expression</b></td>
<td><b>Type</b></td>
<td><b>Semantics</b></td>
</tr>
<tr>
<td valign="top"><code>X::execute(a)</code></td>
<td>non-void
<td>Returns the C++ object being extracted. The
<code>execute</code> function must not be overloaded.
</tr>
<tr>
<td valign="top"><code>&amp;a.ob_type</code>
<td><code><a
href="http://www.python.org/doc/2.2/ext/dnt-type-methods.html">PyTypeObject</a>**</code>
<td>Points to the <code>ob_type</code> field of an object which is
layout-compatible with <code>PyObject</code>
</tr>
</tr>
</table>
<h2><a name="notes"></a>Notes</h2>
Informally, an Extractor's <code>execute</code> member must be a
non-overloaded static function whose single argument is a Python
object type. Acceptable Python object types include those publicly (and
unambiguously) derived from <code>PyObject</code>, and POD types which
are layout-compatible with PyObject.
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
22 May, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave
Abrahams</a> 2002. All Rights Reserved.</i>
<p>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.
</body>
</html>

71
doc/v2/HolderGenerator.html Executable file
View File

@@ -0,0 +1,71 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
<title>Boost.Python - Holder Concept</title>
</head>
<body link="#0000ff" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>
<h2 align="center">HolderGenerator Concept</h2>
</td>
</tr>
</table>
<hr>
<dl class="page-index">
<dt><a href="#introduction">Introduction</a></dt>
<dt><a href="#concept-requirements">Concept Requirements</a></dt>
<dl class="page-index">
<dt><a href="#HolderGenerator-concept">HolderGenerator Concept</a></dt>
</dl>
</dl>
<h2><a name="introduction"></a>Introduction</h2>
<p>A HolderGenerator is a unary metafunction class which returns types
suitable for holding instances of its argument in a wrapped C++ class
instance.
<h2><a name="concept-requirements"></a>Concept Requirements</h2>
<h3><a name="HolderGenerator-concept"></a>HolderGenerator Concept</h3>
<p>In the table below, <code><b>G</b></code> denotes an type which
models HolderGenerator, and <code><b>X</b></code> denotes a class
type.
<table summary="Holder expressions" border="1" cellpadding="5">
<tr>
<td><b>Expression</b></td>
<td><b>Requirements</b></td>
</tr>
<tr>
<td valign="top"><code>G::apply&lt;X&gt;::type</code></td>
<td>A concrete subclass of <a
href="instance_holder.html#instance_holder-spec">instance_holder</a>
which can hold objects of type <code>X</code>.
</tr>
</table>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
20 May, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave
Abrahams</a> 2002. All Rights Reserved.</i>
<p>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.
</body>
</html>

226
doc/v2/Jun2002.html Normal file
View File

@@ -0,0 +1,226 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../boost.css">
<title>Boost.Python - June 2002 Progress Report</title>
</head>
<body link="#0000ff" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>
<h2 align="center">June 2002 Progress Report</h2>
</td>
</tr>
</table>
<hr>
<h2>Contents</h2>
<dl class="index">
<dt><a href="#intro">Introduction</a></dt>
<dt><a href="#handle"><code>handle&lt;T&gt;</code></a></dt>
<dt><a href="#object"><code>object</code></a></dt>
<dl class="index">
<dt><a href="#operators"><code>object</code> operators</a></dt>
<dt><a href="#conversions"><code>object</code> conversions</a></dt>
</dl>
<dt><a href="#list"><code>list</code></a></dt>
<dt><a href="#numerics"><code>Numerics</code></a></dt>
<dt><a href="#community">Community</a></dt>
<dt><a href="#next">What's Next</a></dt>
</dl>
<h2><a name="intro">Introduction</a></h2>
July was mostly focused on allowing expressive manipulation of
individual Python objects, or what Ralf Grosse-Kunstleve calls
&quot;Writing Python in C++&quot;. The work began with this <a
href="http://mail.python.org/pipermail/c++-sig/2002-June/001311.html">posting</a>,
which outlines the issues and intention.
<h2><a name="handle"><code>handle&lt;T&gt;</code></a></h2>
The most basic element needed was a replacement for the
<code>reference&lt;&gt;</code> class template and the
<code>ref</code> typedef from Boost.Python v1, a simple smart
pointer to a Python object. The old v1 typedef
&quot;<code>ref</code>&quot; (for
<code>reference&lt;PyObject&gt;</code>) had to be retired because I
thought it would be too confusing given the importance of <code><a
href="../../../bind/ref.html">boost::ref</a>()</code> to this
library. I began a <a
href="http://mail.python.org/pipermail/c++-sig/2002-June/001311.html">discussion</a>of
possible names, and it was eventually <a
href="http://mail.python.org/pipermail/c++-sig/2002-June/001337.html">decided</a>
to rename <code>reference</code> to <code>handle</code> and supply a
default argument so that <code>ref</code> could be spelled
<code>handle&lt;&gt;</code> without an additional typedef. There
were also some interface changes to make it safer and more-efficient
to interface with the raw
<code>PyObject*</code>s forced on us by Python's 'C' API. A
discussion of those protocols can be found <a
href="http://mail.python.org/pipermail/c++-sig/2002-June/001401.html">here</a>.
<h2><a name="handle"><code>object</code></a></h2>
It is intended that users will seldom need or want to work with
<code>handle&lt;&gt;</code>; its major distinguishing features are
that it gives direct access to the underlying object representation
through <code>operator*</code> and <code>operator-&gt;</code>, and
that can be <code>NULL</code>, both sources of danger. Instead the
library provides a class called <code>object</code>, which
encapsulates a valid Python object and provides a similar interface to
Python's.
<h3><a name="operators"><code>object</code> operators</a></h3>
The first challenge was to provide support for object manipulations
using a Python-like syntax, mostly in the form of operator overloads:
<table border="1">
<tr><th>Python <th>C++
<tr>
<td><code>y = x.foo</code> <td><code>y = x.attr(&quot;foo&quot;);
<tr>
<td><code>x.foo = 1</code> <td><code>x.attr(&quot;foo&quot;) = 1;
<tr>
<td><code>y = x[z]</code> <td><code>y = x[z];
<tr>
<td><code>x[z] = 1</code> <td><code>x[z] = 1;
<tr>
<td><code>y = x[3:-1]</code> <td><code>y = x.slice(3,-1);
<tr>
<td><code>y = x[3:]</code> <td><code>y = x.slice(3,_);
<tr>
<td><code>y = x[:-2]</code> <td><code>y = x.slice(_,-2);
<tr>
<td><code>z = x(1, y)</code> <td><code>z = x(1, y);
<tr>
<td><code>z = x.f(1, y)</code> <td><code>z = x.attr(&quot;f&quot;)(1, y);
<tr>
<td><code>not x</code> <td><code>!x
<tr>
<td><code>x and y</code> <td><code>x and y
</table>
I'm still a unsatisfied with the interface for attribute access. There
original proposal used a syntax like this one:
<pre>
y = x._(&quot;foo&quot;);
x._(&quot;foo&quot;) = 1;
</pre>
which was only marginally better than what we've got. Niki Spahiev
then <a
href="http://mail.python.org/pipermail/c++-sig/2002-June/001447.html">pointed
out</a> a potential conflict with the macro which GNU Gettext <a
href="http://www.gnu.org/manual/gettext/html_mono/gettext.html#SEC6">suggests</a>
people define. This unfortunate state of affairs forced us into using
<code>attr</code> instead. I'd still like to find a better interface,
but the lack of overloadable C++ operators which aren't already used
in Python is an obstacle. The comma operator is still a possibility,
but it has the wrong precedence:
<pre>
y = x,&quot;foo&quot; // error
x,&quot;foo&quot; = 1; // error
y = (x,&quot;foo&quot;); // ok
(x,&quot;foo&quot;) = 1; // ok
</pre>
Well, I guess we could consider adding that to the interface without
removing <code>attr()</code>, to see how it plays out...
<h3><a name="operators"><code>object</code> conversions</a></h3>
The <code>object</code> class also provided an opportunity to replace
Boost.Python v1's <code>to_python()</code> as a user-level
interface. Instead, <code>object</code> has a templated constructor
which can be used to convert any C++ object to Python using the same
underlying mechanisms used for the arguments to <code><a
href="call.html">call</a>&lt;&gt;</code>.
<p>Incidentally, the implementation of operator and conversion support
for object uncovered an inordinate number of compiler bugs in our
targeted platforms. It was a lot more &quot;interesting&quot; than it
should have been.
<h2><a name="list"><code>list</code></a></h2>
With <code>object</code> implemented, it was time to begin replacing
the ad-hoc implementations of <code>list</code>, <code>string</code>,
and <code>dictionary</code> supplied by Boost.Python v1 with something
more robust. I started with <code>list</code> as an example. Because
<code>object</code> already provides all of the requisite operators,
publicly deriving <code>list</code> from object seemed like a good
choice. The remaining issues were what do do about the one-argument
list constructor (which in Python attempts to convert its argument to
a list), and how to deal converting with <code>list</code> arguments
to wrapped functions. Some of the issues are laid out in <a
href="http://mail.python.org/pipermail/c++-sig/2002-June/001551.html">this
thread</a>. Ultimately, it was decided that <code>list(x)</code>
should do the same thing in C++ as in Python (conversion), while
<code>list</code> arguments should only match Python
<code>list</code>s (and <code>list</code> subclasses). The
implementation worked well, and provided a <a
href="http://mail.python.org/pipermail/c++-sig/2002-June/001586.html">roadmap</a>
for the protocol to be used for implementation of the other built-in
types.
<h2><a name="numerics">Numerics</a></h2>
Support for C++ <code>long long</code> and <code>unsigned long
long</code>
(and <code>__int64</code> on MSVC) to/from python conversions was
added this month. We also improved handling of numeric overflows when
converting, e.g., a Python int to a type with a more limited range of
representation.
<h2><a name="community">Community</a></h2>
<ul>
<li>Ralf W. Grosse-Kunstleve and Nick Sauter have implemented
<a href="http://cci.lbl.gov/boost/">multiplatform nightly
build-and-test</a> runs for Boost.Python V2 at LBL.
<li>Dave Hawkes has made significant progress on generating the
Python <a
href="http://mail.python.org/pipermail/c++-sig/2002-June/001503.html">built-in
function and API wrappers</a>
<li>Achim Domma has agreed to take up the job of implementing the
<code>str</code>, <code>dict</code>, and <code>tuple</code> classes.
</ul>
Deep thanks to all the Boost.Python contributors! This project
wouldn't be possible without your participation.
<h2><a name="next">What's Next</a></h2>
As I write this we are already well into the month of July, so I
suggest you consult the <a
href="http://mail.python.org/pipermail/c++-sig/2002-July/">Mailing
List Archive</a> if you want to know what's been happening. Otherwise
you'll just have to wait till next month (hopefully the beginning).
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
19 July, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave Abrahams</a>
2002. All Rights Reserved.</i></p>
</body>
</html>

View File

@@ -9,7 +9,8 @@
"header">
<tr>
<td valign="top" width="300">
<h3><a href="http://www.boost.org"><img height="86" width="277" alt="C++ Boost" src="../c++boost.gif" border="0"></a></h3>
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>

309
doc/v2/May2002.html Normal file
View File

@@ -0,0 +1,309 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../boost.css">
<title>Boost.Python - May 2002 Progress Report</title>
</head>
<body link="#0000ff" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>
<h2 align="center">May 2002 Progress Report</h2>
</td>
</tr>
</table>
<hr>
<h2>Contents</h2>
<dl class="index">
<dt><a href="#intro">Introduction</a></dt>
<dt><a href="#features">New Features</a></dt>
<dl>
<dt><a href="#aix_shared">Shared Library Support for AIX</a><dd>
<dt><a href="#class_enhancements">Class Enhancements</a><dd>
<dl>
<dt><a href="#operators">Operators</a><dd>
<dt><a href="#iterators">Iterators</a><dd>
<dt><a href="#properties">Properties</a><dd>
<dt><a href="#setattr">setattr</a><dd>
<dt><a href="#module">__module__ Attribute</a><dd>
</dl>
<dt><a href="#back_reference">back_reference</a><dd>
</dl>
<dt><a href="#documentation">Documentation</a></dt>
<dt><a href="#misc">Miscellaneous</a></dt>
<dl class="index">
<dt><a href="#converters">Converters</a></dt>
<dt><a href="#checkins">Checkins Mailing List</a></dt>
<dt><a href="#shared">Shared Libraries</a></dt>
</dl>
<dt><a href="#next">What's Next</a></dt>
</dl>
<h2><a name="intro">Introduction</a></h2>
Aside from library development, work on Boost.Python in May was
focused on reducing the support burden. In recent weeks, responding to
requests for support, espcially surrounding building the library, had
begun to impede progress on development. There was a major push to
release a stable 1.28.0 of Boost, including documentation of <a
href="../../../../tools/build/index.html">Boost.Build</a> and specific
<a href="../building.html">instructions</a> for building Boost.Python
v1. The documentation for Boost.Python v2 was also updated as
described <a href="#documentation">here</a>.
<h2><a name="features">New Features</a></h2>
<h3><a name="aix_shared">Shared Library Support for AIX</a></h3>
The Kull group required the ability to build and test Boost.Python
extensions on AIX, a platform with &quot;creatively designed&quot;
shared library semantics. Making this work was a multi-pronged
effort, involving changes to Boost.Build and some great research by
Martin Casado which uncovered the key mechanism required to allow
shared libraries to use functions from the Python executable. The
current solution used in Boost.Build relies on a <a
href="../../../../tools/build/gen_aix_import_file.py">Python
Script</a> as part of the build process. This is not a problem for
Boost.Python, as Python will be available. However, the commands
issued by the script are so simple that a 100%-pure-Boost.Jam
solution is surely possible. Linking on AIX is sufficiently
interesting to have skewed the Boost.Python development schedule a
bit.
<h3><a name="class_enhancements">Class Enhancements</a></h3>
<h4><a name="operators">Operators</a></h4>
Support for exposing C++ operators and functions as the corresponding
Python special methods was added. Thinking that the Boost.Python
<a href="../special.html#numeric">v1 interface</a> was a little too
esoteric (especially the use of
<code>left_operand&lt;...&gt;/right_operand&lt;...&gt;</code> for
asymmetric operands), I introduced a simple form of <a
href="http://osl.iu.edu/~tveldhui/papers/Expression-Templates/exprtmpl.html">expression
templates</a> which allow users to simply write the expressions that
should be wrapped, as in this <a href="operators.html#examples">example</a>.
<h4><a name="iterators">Iterators</a></h4>
Python iterator support as required by the Kull project resulted in a
highly flexible interface allowing:
<dl>
<dt>Direct exposure of a class' <code>begin()</code> and
<code>end()</code> functions:
<pre>
...
.def(&quot;__iter__&quot;, iterator&lt;list_int&gt;())
</pre>
<dd>
<dt>Creation of iterators from member functions...
<pre>
...
.def(&quot;__iter__&quot;
, range(&amp;my_class::x_begin, &amp;my_class::x_end))
)
</pre>
<dd>
<dt>...and member data:
<pre>
...
.def(&quot;__iter__&quot;
, range(&amp;std::pair&lt;char*,char*&gt;::first, &amp;std::pair&lt;char*,char*&gt;::second))
)
</pre>
<dd>
<dt>The ability to specify <a
href="CallPolicies.html">CallPolicies</a>, e.g. to prevent copying of
heavyweight values:
<pre>
...
.def(&quot;__iter__&quot;,
, range&lt;return_value_policy&lt;copy_non_const_reference&gt; &gt;(
&amp;my_sequence&lt;heavy&gt;::begin
, &amp;my_sequence&lt;heavy&gt;::end))
</pre>
<dd>
</dl>
<h4><a name="properties">Properties</a></h4>
The Kull iteration interfaces also required the ability to iterate
over a sequence specified by an instance's attribute:
<pre>
&gt;&gt;&gt; f = field()
&gt;&gt;&gt; for e in f.elements:
... print e,
</pre>
This forced the exposure of the <a
href="http://www.python.org/2.2/descrintro.html#property"><code>property</code></a>
interface used internally to implement the data member exposure
facility described in <a
href="Mar2002#data_members">March</a>. Properties are an
incredibly useful idiom, so it's good to be able to provide them
at little new development cost.
<h4><a name="setattr">setattr</a></h4>
<code>class_&lt;&gt;</code> acquired a <code>setattr</code> member
function which allows users to easily add new Python objects as class
attributes.
<h4><a name="module">__module__ Attribute</a></h4>
Ralf Grosse-Kunstleve has been working on pickling support for v2. To
make it work correctly, he had to make sure that a class'
<code>__module__</code> attribute was set correctly.
<h3><a name="back_reference"><code>back_reference</code></a></h3>
The new <code>back_reference&lt;T&gt;</code> template can be used as a
function parameter when the user needs access to both a <code>T</code>
argument and to the Python object which manages it. The function will
only match in the overload resolution process if it would match the
same function signature with <code>T</code> substituted for
<code>back_reference&lt;T&gt;</code>. This feature is not yet
documented.
<h2><a name="documentation">Documentation</a></h2>
In a major effort to prepare Boost.Python v2 to replace v1, many pages
of new reference documentation were added:
<blockquote>
<dl>
<dt><a href="CallPolicies.html">CallPolicies.html</a><dd>
<dt><a href="Dereferenceable.html">Dereferenceable.html</a><dd>
<dt><a href="Extractor.html">Extractor.html</a><dd>
<dt><a href="HolderGenerator.html">HolderGenerator.html</a><dd>
<dt><a href="ResultConverter.html">ResultConverter.html</a><dd>
<dt><a href="call_method.html">call_method.html</a><dd>
<dt><a href="callbacks.html">callbacks.html</a><dd>
<dt><a href="data_members.html">data_members.html</a><dd>
<dt><a href="has_back_reference.html">has_back_reference.html</a><dd>
<dt><a href="implicit.html">implicit.html</a><dd>
<dt><a href="instance_holder.html">instance_holder.html</a><dd>
<dt><a href="operators.html">operators.html</a><dd>
<dt><a href="ptr.html">ptr.html</a><dd>
<dt><a href="type_id.html">type_id.html</a><dd>
<dt><a href="with_custodian_and_ward.html">with_custodian_and_ward.html</a><dd>
</dl>
</blockquote>
Major updates were made to the following pages:
<blockquote>
<dl>
<dt><a href="call.html">call.html</a><dd> <dt><a href="updated">updated</a><dd>
<dt><a href="class.html">class.html</a><dd>
<dt><a href="reference.html">reference.html</a><dd>
</dl>
</blockquote>
As usual, careful documentation forces one to consider the
interface again, and there were many interface changes
associated with this effort, including the elevation of the
following components from implementation detail to
first-class library citizen:
<blockquote>
<dl>
<dt>type_id.hpp<dd>
<dt>pointee.hpp<dd>
<dt>lvalue_from_pytype.hpp<dd></dl>
</dl>
</blockquote>
<h2><a name="misc">Miscellaneous</a></h2>
<h3><a name="converters">Converters</a></h3>
It appears that the world of C++ &lt;==&gt; Python conversion rules is
an endlessly-rich area of exploration. Completing the conversions for
<code>char</code> and <code>char const*</code> types, as described at
the end of <a href="Apr2002.html#missing">April's report</a>,
uncovered some interesting new shades to the problem. It turns out to
be worth distinguishing mutable and immutable lvalue conversions,
because despite the fact that Python doesn't understand
<code>const</code>, it does understand immutability (c.f. Python
strings, which expose an immutable <code>char</code> pointer). It is
also worth recognizing types which represent lvalue <i>sequences</i>,
to prevent Python <code>&quot;foobar&quot;</code> from being silently
truncated to C++ <code>'f'</code>. More details on this insight can be
found in the mailing list <a
href="http://mail.python.org/pipermail/c++-sig/2002-May/001023.html">
archive</a>. I don't plan to do anything about this immediately, but I
do think it's the right direction to go in the long run.
<h3><a name="checkins">Checkins Mailing List</a></h3>
In order to better coordinate changes made by multiple developers, I
enabled <a
href="http://sourceforge.net/docman/display_doc.php?docid=772&group_id=1">syncmail</a>
for the Boost.Python CVS trees, and established an associated <a
href="http://lists.sourceforge.net/lists/listinfo/boost-python-cvs">mailing
list</a>. Subscribe to this list to receive notices of each new
checkin.
<h3><a name="shared">Shared Libraries</a></h3>
Beyond the vagaries of dynamic linking on AIX, I have been
participating in a more-general discussion of dynamic linking for
C++. Needless to say, C++ dynamic linking is of critical importance to
Boost.Python: all extension modules are normally built as shared
libraries, and Boost.Python extension modules share a common library
as well.
In fact, there are at least two separate conversations. One
in the C++ standard extensions mailing list concerns what can be
standardized for C++ and shared libraries; the other, mostly on the <a
href="http://gcc.gnu.org/ml/gcc/">gcc</a> mailing list, concerns the
behavior of GCC on Posix/ELF platforms.
Some of the GCC threads are here:
<blockquote>
<a
href="http://gcc.gnu.org/ml/gcc/2002-05/msg02002.html">http://gcc.gnu.org/ml/gcc/2002-05/msg02002.html</a><br>
<a
href="http://gcc.gnu.org/ml/gcc/2002-05/msg02945.html">http://gcc.gnu.org/ml/gcc/2002-05/msg02945.html</a><br>
<a href="http://gcc.gnu.org/ml/gcc/2002-05/msg01758.html">http://gcc.gnu.org/ml/gcc/2002-05/msg01758.html</a>
</blockquote>
<h2><a name="next">What's Next</a></h2>
Development is focused on what's needed to be able to retire
Boost.Python v1. At the moment, that means deciding the user-friendly
interfaces for to_/from_python conversion, and formally exposing the
Python object smart pointers and object wrapper classes. Quite a few
questions have also been showing up recently about how to embed Python
with Boost.Python, and how to link with it statically; the solutions
to these issues will probably have to be formalized before long.
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 June, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave Abrahams</a>
2002. All Rights Reserved.</i></p>
</body>
</html>

110
doc/v2/ResultConverter.html Normal file
View File

@@ -0,0 +1,110 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
<title>Boost.Python - ResultConverter Concept</title>
</head>
<body link="#0000ff" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>
<h2 align="center">ResultConverter Concept</h2>
</td>
</tr>
</table>
<hr>
<dl class="page-index">
<dt><a href="#introduction">Introduction</a></dt>
<dt><a href="#concept-requirements">Concept Requirements</a></dt>
<dl class="page-index">
<dt><a href="#ResultConverter-concept">ResultConverter Concept</a></dt>
<dt><a href="#ResultConverterGenerator-concept">ResultConverterGenerator Concept</a></dt>
</dl>
</dl>
<h2><a name="introduction"></a>Introduction</h2>
<p>A ResultConverter for a type <code>T</code> is a type whose
instances can be used to convert C++ return values of type
<code>T</code> <code>to_python</code>. A ResultConverterGenerator is
an MPL unary metafunction class which, given the return type of a C++
function, returns a ResultConverter for that type. ResultConverters in
Boost.Python generally inspect library's registry of converters to
find a suitable converter, but converters which don't use the registry
are also possible.
<h2><a name="concept-requirements"></a>Concept Requirements</h2>
<h3><a name="ResultConverter-concept"></a>ResultConverter Concept</h3>
<p>In the table below, <code><b>C</b></code> denotes a ResultConverter
type for a type <b><code>R</code></b> , <code><b>c</b></code> denotes
an object of type <code><b>C</b></code> , and <code><b>r</b></code>
denotes an object of type <code><b>R</b></code>.
<table summary="ResultConverter expressions" border="1" cellpadding="5">
<tr>
<td><b>Expression</b></td>
<td><b>Type</b></td>
<td><b>Semantics</b></td>
</tr>
<tr>
<td valign="top"><code>C c;</code></td>
<td>
<td>Constructs a <code>C</code> object.
</tr>
<tr>
<td valign="top"><code>c.convertible()</code></td>
<td>convertible to <code>bool</code></td>
<td><code>false</code> iff no conversion from any <code>R</code> value
to a Python object is possible.</td>
</tr>
<tr>
<td valign="top"><code>c(r)</code></td>
<td>convertible to <code>PyObject*</code></td>
<td>A pointer to a Python object corresponding to <code>r</code>,
or <code>0</code> iff <code>r</code> could not be converted
<code>to_python</code>, in which case <a
href="http://www.python.org/doc/current/api/exceptionHandling.html#l2h-71">PyErr_Occurred</a>
should return non-zero.</td>
</tr>
</table>
<h3><a name="ResultConverterGenerator-concept"></a>ResultConverterGenerator Concept</h3>
<p>In the table below, <code><b>G</b></code> denotes a
ResultConverterGenerator type and <code><b>R</b></code> denotes a possible
C++ function return type.
<table summary="ResultConverterGenerator expressions" border="1" cellpadding="5">
<tr>
<td><b>Expression</b></td>
<td><b>Requirements</b></td>
</tr>
<tr>
<td valign="top"><code>G::apply&lt;R&gt;::type</code></td>
<td>A ResultConverter type for <code>R</code>.</td>
</table>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
09 May, 2002 <!--Luann's birthday! -->
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave
Abrahams</a> 2002. All Rights Reserved.</i>
<p>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.
</body>
</html>

View File

@@ -9,7 +9,8 @@
"header">
<tr>
<td valign="top" width="300">
<h3><a href="http://www.boost.org"><img height="86" width="277" alt="C++ Boost" src="../c++boost.gif" border="0"></a></h3>
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>

View File

@@ -9,7 +9,8 @@
"header">
<tr>
<td valign="top" width="300">
<h3><a href="http://www.boost.org"><img height="86" width="277" alt="C++ Boost" src="../c++boost.gif" border="0"></a></h3>
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>

View File

@@ -9,7 +9,8 @@
"header">
<tr>
<td valign="top" width="300">
<h3><a href="http://www.boost.org"><img height="86" width="277" alt="C++ Boost" src="../c++boost.gif" border="0"></a></h3>
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>

View File

@@ -9,7 +9,8 @@
"header">
<tr>
<td valign="top" width="300">
<h3><a href="http://www.boost.org"><img height="86" width="277" alt="C++ Boost" src="../c++boost.gif" border="0"></a></h3>
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>
@@ -34,7 +35,7 @@
<p>
<code>&lt;boost/python/call_method.hpp&gt;</code> defines the <a
href="#call_method-spec"><code>call_method</code></a> family of overloaded function
templates, used to invoke Python callable objects from C++.
templates, used to invoke callable attributes of Python objects from C++.
<h2><a name="functions"></a>Functions</h2>
<pre>
@@ -131,7 +132,7 @@ BOOST_PYTHON_MODULE_INIT(my_module)
</pre>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
9 May, 2002 <!-- Luann's birthday! -->
10 May, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave Abrahams</a>

View File

@@ -9,7 +9,8 @@
"header">
<tr>
<td valign="top" width="300">
<h3><a href="http://www.boost.org"><img height="86" width="277" alt="C++ Boost" src="../c++boost.gif" border="0"></a></h3>
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>

View File

@@ -72,30 +72,34 @@
<p><code>&lt;boost/python/class.hpp&gt;</code> defines the interface
through which users expose their C++ classes to Python. It declares the
<code>class_</code> class template, which is parameterized on the class
type being exposed, and the <code>args</code> and <code>bases</code>
utility class templates in the anonymous namespace (the latter definitions
will probably be moved in a future release).
<code>class_</code> class template, which is parameterized on the
class type being exposed. It also exposes the <code>args</code>
and <code>bases</code> utility class templates, which are used in
conjunction with <code>class_</code>.
<p><code>&lt;boost/python/class_fwd.hpp&gt;</code> contains a forward
declaration of the <code>class_</code> class template.
<h2><a name="classes"></a>Classes</h2>
<h2><a name="classes"></a>Classes</h2>
<h3><a name="class_-spec"></a>Class template <code>class_&lt;T, Bases, <a
href="HolderGenerator.html">HolderGenerator</a>&gt;</code></h3>
<h3><a name="class_-spec"></a>Class template <code>class_&lt;T, <font color="#007f00">Bases, HeldType, NonCopyable</font>&gt;</code></h3>
<p>Creates a Python class associated with the C++ type passed as its first
parameter. Its template arguments are:<br>
<p>Creates a Python class associated with the C++ type passed as
its first parameter. Although it has four template parameters,
only the first one is required. The three optional arguments can
actually be supplied <font color="#007f00"><b>in any
order</b></font>; Boost.Python determines the role of the argument
from its type.<br>
<br>
<table border="1" summary="class_ template parameters">
<tr>
<th>Parameter
<th>Template Parameter
<th>Requirements
<th>Semantics
<th>Default
<tr>
@@ -103,57 +107,158 @@
<td>A class type.
<tr>
<td><code>Bases</code>
<td>An <a href="../../../mpl/doc/Sequences.html">MPL sequence</a> of
C++ base classes of <code>T</code>.
<td>An unspecified empty sequence
<td>The class being wrapped
<tr>
<td><code>HolderGenerator</code>
<td><code><font color="#007f00">Bases</font></code>
<td>A model of <code><a href=
"HolderGenerator.html">HolderGenerator</a></code>.
<td>A specialization of <a
href="#bases-spec"><code>bases&lt;...&gt;</code></a> which
specifies previously-exposed C++ base classes of <code>T</code><a href="#footnote_1">[1]</a>.
<td>Registers <code>from_python</code> conversions from
wrapped <code>T</code> instances to each of its exposed direct
and indirect bases. For each polymorphic base <code>B</code>,
registers conversions from indirectly-held wrapped
<code>B</code> instances to <code>T</code>.
<td><code><a href="#bases">bases&lt;&gt;</a></code>
<tr>
<td><code><font color="#007f00">HeldType</font></code>
<td>Must be <code>T</code>, a class derived
from <code>T</code>, or a <a
href="Dereferenceable.html">Dereferenceable</a> type for which
<code><a
href="pointee.html#pointee-spec">pointee</a>&lt;HeldType&gt;::type</code>
is <code>T</code> or a class derived from <code>T</code>.
</dl>
<td>Specifies the type which is actually embedded in a Python
object wrapping a <code>T</code> instance. More details <a
href="#HeldType">below</a>.
<td><code>T</code>
<tr>
<td><code><font color="#007f00">NonCopyable</font></code>
<td>If supplied, must be <a
href="../../../utility/utility.htm#Class noncopyable">boost::noncopyable</a>.
<td> Suppresses automatic registration of <code>to_python</code>
conversions which copy
<code>T</code> instances. Required when <code>T</code> has no
publicly-accessible copy constructor.
<td>An unspecified type other than <code>boost::noncopyable</code>.
<td><code>boost::python::objects::value_holder_generator</code>
</table>
<h4><a name="class_-spec-synopsis"></a>Class template <code>class_</code>
synopsis</h4>
<h4><a name="#HeldType">HeldType Semantics</a></h4>
<ol>
<li>
If <code>HeldType</code> is derived from T, its
exposed constructor(s) must accept an initial
<code>PyObject*</code> argument which refers back to the Python
object that contains it, as shown in <a
href="call_method.html#example">this example</a>. This argument is
not included in the argument list type passed to <a
href="#def_init-spec"><code>def_init()</code></a>, below, nor is
it passed explicitly by users when Python instances of
<code>T</code> are created. This is the idiom which allows C++ virtual
functions to be overridden in Python. Boost.Python automatically
registers additional converters which allow wrapped instances of
<code>T</code> to be passed to wrapped C++ functions expecting
<code>HeldType</code> arguments.
<li>Because Boost.Python will always allow
wrapped instances of <code>T</code> to be passed in place of
<code>HeldType</code> arguments, specifying a smart pointer for
<code>HeldType</code> allows users to pass Python
<code>T</code> instances where a smart pointer-to-<code>T</code> is
expected. Smart pointers such as <code>std::auto_ptr&lt;&gt;</code>
or <code><a
href="../../../smart_ptr/shared_ptr.htm">boost::shared_ptr&lt;&gt;</a></code>
which contain a nested type <code>element_type</code> designating
the referent type are automatically supported; additional smart
pointer types can be supported by specializing <a
href="pointee.html#pointee-spec">pointee&lt;HeldType&gt;</a>.
<li>
As in case 1 above, when <code>HeldType</code> is a smart pointer to
a class derived from <code>T</code>, the initial
<code>PyObject*</code> argument must be supplied by all exposed
constructors.
<li>
Except in cases 1 and 3, users may optionally specify that T itself
gets initialized with a similar initial <code>PyObject*</code>
argument by specializing <a
href="has_back_reference.html#has_back_reference-spec">has_back_reference<T></a>.
</ol>
<h4><a name="class_-spec-synopsis"></a>Class template
<code>class_</code> synopsis</h4>
<pre>
namespace boost { namespace python
{
template &lt;class T
, class Bases = <i>none</i>
, class HolderGenerator = objects::value_holder_generator&gt;
class class_
<font color="#007f00"> , class Bases = bases&lt;&gt;
, class HeldType = T
, class NonCopyable = <i>unspecified</i>
&gt;
</font> class class_
{
class_();
class_(char const* name);
template &lt;class F&gt;
class_&amp; def(char const* name, F f);
// exposing constructors
class_&amp; def_init();
template &lt;class Fn, class CallPolicy&gt;
class_&amp; def(char const* name, Fn fn, CallPolicy policy);
template &lt;class Args&gt;
class_&amp; def_init(Args const&amp; = Args());
class_&amp; def_init();
template &lt;class Args, class CallPolicy&gt;
class_&amp; def_init(Args const&amp;, CallPolicy policy);
// exposing member functions
template &lt;class F&gt;
class_&amp; def(char const* name, F f);
template &lt;class Fn, class CallPolies&gt;
class_&amp; def(char const* name, Fn fn, CallPolies);
// exposing operators
template &lt;<i>unspecified</i>&gt;
class_&amp; def(<a href="operators.html#operator_-spec">detail::operator_</a>&lt;unspecified&gt;);
// exposing data members
template &lt;class D&gt;
class_&amp; def_readonly(char const* name, D T::*pm);
template &lt;class D&gt;
class_&amp; def_readwrite(char const* name, D T::*pm);
// Raw attribute modification
class_& setattr(char const* name, ref const&);
// property creation
void add_property(char const* name, ref const&amp; fget);
void add_property(char const* name, ref const&amp; fget, ref const&amp; fset);
// accessing the Python class object
ref object() const;
};
}}
</pre>
<h4><a name="class_-spec-ctors"></a>Class template <code>class_</code>
constructors</h4>
<h4><a name="class_-spec-ctors"></a>Class template <code>class_</code> constructors</h4>
<pre>
class_()
class_();
</pre>
<dl class="function-semantics">
@@ -169,7 +274,7 @@ class_()
Python classes without user intervention.
</dl>
<pre>
class_(char const* name)
class_(char const* name);
</pre>
<dl class="function-semantics">
@@ -186,27 +291,75 @@ class_(char const* name)
<h4><a name="class_-spec-modifiers"></a>Class template <code>class_</code>
modifier functions</h4>
<pre>
template &lt;class F&gt;
class_&amp; def(char const* name, F f)
template &lt;class Fn, class CallPolicy&gt;
class_&amp; def(char const* name, Fn f, CallPolicy policy)
<pre>
class_&amp; def_init();
template &lt;class Args&gt;
class_&amp; def_init(Args const&amp; argument_types);
template &lt;class Args, class CallPolicies&gt;
class_&amp; def_init(Args const&amp; argument_types, CallPolicies policies);
</pre>
<dl class="function-semantics">
<dt><b>Requires:</b> <code>f</code> is a non-null pointer-to-function or
pointer-to-member-function. <code>name</code> is a ntbs which conforms to
Python's <a href=
<dt><b>Requires:</b> <code>Args</code> is an <a
href="../../../mpl/doc/Sequences.html">MPL sequence</a> of C++ argument
types (<i>A1, A2,... AN</i>) such that if
<code>a1, a2</code>... <code>aN</code> are objects of type
<i>A1, A2,... AN</i> respectively, the expression
<code>T(a1, a2</code>... <code>aN</code>) is valid. In the first form,
the expression <code>T()</code> must be valid.
<dt><b>Effects:</b> Adds the result of
<code><a href=
"make_function.html#make_constructor-spec">make_constructor</a>&lt;args&lt;&gt;,Holder&gt;()</code>,
<code><a href=
"make_function.html#make_constructor-spec">make_constructor</a>&lt;Args,Holder&gt;()</code>, or
<code><a href=
"make_function.html#make_constructor-spec">make_constructor</a>&lt;Args,Holder&gt;(policies)</code>,
respectively, to the Boost.Python extension class being defined under the name
"__init__". <code>Holder</code> is a concrete subclass of <a
href="instance_holder.html#instance_holder-spec">instance_holder</a>
which holds the <code>HeldType</code>. If the extension class
already has an "__init__" attribute, the usual <a
href="http:overloading.html">overloading procedure</a> applies.
<dt><b>Returns:</b> <code>*this</code>
<dt><b>Rationale:</b> Allows users to easily expose a class' constructor
to Python.
</dl>
<br>
<pre>
template &lt;class F&gt;
class_&amp; def(char const* name, F f);
template &lt;class Fn, class CallPolicies&gt;
class_&amp; def(char const* name, Fn f, CallPolicies policies);
</pre>
<dl class="function-semantics">
<dt><b>Requires:</b> <code>f</code> is a non-null
pointer-to-function or pointer-to-member-function, or a callable
Python object passed as a <code>PyObject*</code> or <a
href="reference_hpp.html#ref-spec"><code>ref</code></a>. <code>name</code>
is a ntbs which conforms to Python's <a href=
"http://www.python.org/doc/2.2/ref/identifiers.html">identifier
naming rules</a>. In the first form, the return type of
<code>f</code> is not a reference and is not a pointer other
than <code>char const*</code> or <code>PyObject*</code>. In the
second form <code>policy</code> is a model of <a
second form <code>policies</code> is a model of <a
href="CallPolicies.html">CallPolicies</a>.
<dt><b>Effects:</b> Adds the result of <code><a href=
"make_function.html#make_function-spec">make_function</a>(f)</code> to
"make_function.html#make_function-spec">make_function</a>(f)</code> or <code><a href=
"make_function.html#make_function-spec">make_function</a>(f,&nbsp;policies)</code> to
the Boost.Python extension class being defined, with the given
<code>name</code>. If the extension class already has an attribute named
<code><i>name</i></code>, the usual <a href=
@@ -214,37 +367,110 @@ class_&amp; def(char const* name, Fn f, CallPolicy policy)
<dt><b>Returns:</b> <code>*this</code>
</dl>
<pre>
template &lt;class Args&gt;
class_&amp; def_init(Args const&amp; argument_types)
class_&amp; def_init()
<pre>
template &lt;<i>unspecified</i>&gt;
class_&amp; def(<a href="operators.html#operator_-spec">detail::operator_</a>&lt;unspecified&gt;);
</pre>
<dl class="function-semantics">
<dt><b>Requires:</b> in the first form, argument_types must be an <a
href="../../../mpl/doc/Sequences.html">MPL sequence</a> of C++ argument
types (<i>A1, A2,... AN</i>) such that if
<code>a1, a2</code>... <code>aN</code> are objects of type
<i>A1, A2,... AN</i> respectively, the expression
<code>T(a1, a2</code>... <code>aN</code>) is valid. In the second form,
the expression <code>T()</code> must be valid.
<dt><b>Effects:</b> Adds a Python <a
href="http://www.python.org/doc/ref/specialnames.html">special
method</a> as described <a href="operators.html">here</a>.
<dt><b>Effects:</b> Adds the result of <code><a href=
"make_function.html#make_constructor-spec">make_constructor</a>&lt;T,Args,HolderGenerator&gt;()</code>
to the Boost.Python extension class being defined with the name
"__init__". If the 2nd form is used, an unspecified empty <a href=
"../../../mpl/doc/Sequences.html">MPL sequence</a> type is substituted
for <code>Args</code>. If the extension class already has an "__init__"
attribute, the usual <a href="http:overloading.html">overloading
procedure</a> applies.
<dt><b>Returns:</b> <code>*this</code>
</dl>
<pre>
template &lt;class F&gt;
class_&amp; setattr(char const* name, ref x);
</pre>
<dl class="function-semantics">
<dt><b>Requires:</b> <code>name</code> is a ntbs which conforms to
Python's <a href=
"http://www.python.org/doc/2.2/ref/identifiers.html">identifier
naming rules</a>.
<dt><b>Effects:</b> <code><a href="http://www.python.org/doc/current/api/object.html#l2h-166">PyObject_SetAttrString</a>(this->object(),&nbsp;name,&nbsp;x.get());</code>
<dt><b>Returns:</b> <code>*this</code>
</dl>
<br>
<pre>
void add_property(char const* name, ref const&amp; fget);
void add_property(char const* name, ref const&amp; fget, ref const&amp; fset);
</pre>
<dl class="function-semantics">
<dt><b>Requires:</b> <code>name</code> is a ntbs which conforms to
Python's <a href=
"http://www.python.org/doc/2.2/ref/identifiers.html">identifier
naming rules</a>.
<dt><b>Effects:</b> Creates a new Python <a
href="http://www.python.org/2.2/descrintro.html#property"><code>property</code></a>
class instance, passing <code>fget.get()</code> (and
<code>fset.get()</code> in the second form) to its constructor,
then adds that property to the Python class object under
construction with the given attribute <code>name</code>.
<dt><b>Returns:</b> <code>*this</code>
<dt><b>Rationale:</b> Allows users to easily expose a class' constructor
to Python.
<dt><b>Rationale:</b> Allows users to easily expose a class'
data member such that it can be inspected from Python with a
natural syntax.
</dl>
<br>
<pre>
template &lt;class D&gt;
class_&amp; def_readonly(char const* name, D T::*pm);
</pre>
<dl class="function-semantics">
<dt><b>Requires:</b> <code>name</code> is a ntbs which conforms to
Python's <a href=
"http://www.python.org/doc/2.2/ref/identifiers.html">identifier
naming rules</a>.
<dt><b>Effects:</b>
<pre>
this-&gt;add_property(name, ref(<a href="data_members.html#make_getter-spec">make_getter</a>(pm)));
</pre>
<dt><b>Returns:</b> <code>*this</code>
<dt><b>Rationale:</b> Allows users to easily expose a class'
data member such that it can be inspected from Python with a
natural syntax.
</dl>
<br>
<pre>
template &lt;class D&gt;
class_&amp; def_readwrite(char const* name, D T::*pm);
</pre>
<dl class="function-semantics">
<dt><b>Effects:</b>
<pre>
ref fget(<a href="data_members.html#make_getter-spec">make_getter</a>(pm));
ref fset(<a href="data_members.html#make_setter-spec">make_setter</a>(pm));
this-&gt;add_property(name, fget, fset);
</pre>
<dt><b>Returns:</b> <code>*this</code>
<dt><b>Rationale:</b> Allows users to easily expose a class'
data member such that it can be inspected and set from Python with a
natural syntax.
<h4><a name="class_-spec-observers"></a>Class template <code>class_</code>
observer functions</h4>
<pre>
@@ -264,39 +490,42 @@ ref object() const;
<h3><a name="args-spec"></a>Class template
<code>args&lt;T1, T2,</code>...<code>TN&gt;</code></h3>
<p>Essentially an alias for <code>boost::mpl::type_list</code> which users
can use in <code>def_init</code> calls to make their code more readable.
Currently it is in the global unnammed namespace, but that will probably
change.
<p>A conveniently-named <a
href="../../../mpl/doc/Sequences.html">MPL sequence</a> which
users pass to <code><a
href="#class_-spec-modifiers">def_init</a></code> calls to make
their code more readable.
<h4><a name="args-spec-synopsis"></a>Class template <code>args</code>
synopsis</h4>
<pre>
namespace
namespace boost { namespace python
{
template &lt;T1 = <i>unspecified</i>,...TN = <i>unspecified</i>&gt;
struct args : ::boost::mpl::type_list&lt;T1,...TN&gt;::type
struct args
{};
}
}}
</pre>
<h3><a name="bases-spec"></a>Class template
<code>bases&lt;T1, T2,</code>...<code>TN&gt;</code></h3>
<p>Essentially an alias for <code>boost::mpl::type_list</code> which users
can use in <code>class_&lt;</code>...<code>&gt;</code> instantiations to
make their code more readable. Currently it is in the global unnammed
namespace, but that will probably change.
<p>An <a
href="../../../mpl/doc/Sequences.html">MPL sequence</a> which
can be used in <code>class_&lt;</code>...<code>&gt;</code>
instantiations indicate a list of base classes. Although users
can pass any MPL sequence in place of args, above, the use of
<code>bases</code> to indicate base classes is mandatory.
<h4><a name="bases-spec-synopsis"></a>Class template <code>bases</code>
synopsis</h4>
<pre>
namespace
namespace boost { namespace python
{
template &lt;T1 = <i>unspecified</i>,...TN = <i>unspecified</i>&gt;
struct bases : ::boost::mpl::type_list&lt;T1,...TN&gt;::type
struct bases
{};
}
}}
</pre>
<h2><a name="examples"></a>Example(s)</h2>
@@ -311,24 +540,47 @@ class Foo : public Bar, public Baz
std::string const&amp; name() { return m_name; }
void name(char const*);
double value; // public data
private:
...
};
</pre>
A corresponding Boost.Python extension class can be created with:
A corresponding Boost.Python extension class can be created with:
<pre>
using namespace boost::python;
ref foo =
class_&lt;Foo,bases&lt;Bar,Baz&gt; &gt;()
ref foo = class_&lt;Foo,bases&lt;Bar,Baz&gt; &gt;()
.def_init(args&lt;int,char const*&gt;())
.def_init(args&lt;double&gt;())
.def("get_name", &amp;Foo::get_name, return_internal_reference&lt;&gt;())
.def("set_name", &amp;Foo::set_name)
.def_readwrite("value", &amp;Foo::value)
.object();
</pre>
<hr>
<a name="footnote_1">[1]</a> By &quot;previously-exposed&quot; we mean that the for each
<code>B</code> in <code>bases</code>, an instance of
<code>class_&lt;B&gt;</code> must have already been
constructed. Ensuring this in a portable manner when a class and its
bases are exposed in the same module entails using separate
<i>full-expressions</i>, rather than chaining consecutive definitions with
&quot;<code>.add(...)</code>.
<pre>
module m(&quot;module_name&quot;);
m.add(class_&lt;Base&gt;()
.def_init());
m.add(class_&lt;Derived, bases&lt;Base&gt;&gt;()
.def_init());
</pre>
Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
05 November, 2001
09 May, 2002 <!-- Luann's birthday! -->
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->

View File

@@ -9,7 +9,8 @@
"header">
<tr>
<td valign="top" width="300">
<h3><a href="http://www.boost.org"><img height="86" width="277" alt="C++ Boost" src="../c++boost.gif" border="0"></a></h3>
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>

View File

@@ -50,7 +50,7 @@
<code>copy_const_reference</code></h3>
<p><code>copy_const_reference</code> is a model of <a href=
"ResultConverterGenerator.html">ResultConverterGenerator</a> which can be
"ResultConverter.html#ResultConverterGenerator-concept">ResultConverterGenerator</a> which can be
used to wrap C++ functions returning a reference-to-const type such that
the referenced value is copied into a new Python object.

View File

@@ -51,7 +51,7 @@
<code>copy_non_const_reference</code></h3>
<p><code>copy_non_const_reference</code> is a model of <a href=
"ResultConverterGenerator.html">ResultConverterGenerator</a> which can be
"ResultConverter.html#ResultConverterGenerator-concept">ResultConverterGenerator</a> which can be
used to wrap C++ functions returning a reference-to-non-const type such
that the referenced value is copied into a new Python object.

View File

@@ -111,7 +111,7 @@ PyObject* postcall(PyObject*, PyObject* result);
<code>default_result_converter</code></h3>
<p><code>default_result_converter</code> is a model of <a href=
"ResultConverterGenerator.html">ResultConverterGenerator</a> which can be
"ResultConverter.html#ResultConverterGenerator-concept">ResultConverterGenerator</a> which can be
used to wrap C++ functions returning non-pointer types, <code>char
const*</code>, and <code>PyObject*</code>, by-value.

View File

@@ -9,7 +9,8 @@
"header">
<tr>
<td valign="top" width="300">
<h3><a href="http://www.boost.org"><img height="86" width="277" alt="C++ Boost" src="../c++boost.gif" border="0"></a></h3>
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>

View File

@@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../boost.css">
<title>Boost.Python - &lt;{{header}}&gt;</title>
<title>Boost.Python - &lt;boost/python/errors.hpp&gt;</title>
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
@@ -28,7 +28,7 @@
<dd>
<dl class="page-index">
<dt><a href="#class-spec">Class <code>error_already_set</code></a>
<dt><a href="#error_already_set-spec">Class <code>error_already_set</code></a>
<dd>
<dl class="page-index">
@@ -44,6 +44,7 @@
<dt><a href="#handle_exception-spec">handle_exception</a>
<dt><a href="#expect_non_null-spec">expect_non_null</a>
<dt><a href="#throw_error_already_set-spec">throw_error_already_set</a>
</dl>
<dt><a href="#examples">Examples</a>
@@ -68,7 +69,7 @@
"http://www.python.org/doc/2.2/api/exceptionHandling.html#l2h-71">PyErr_Occurred()</a>
returns a value convertible to <code>true</code>.
<h4><a name="class-spec-synopsis"></a>Class error_already_set synopsis</h4>
<h4><a name="error_already_set-spec-synopsis"></a>Class error_already_set synopsis</h4>
<pre>
namespace boost { namespace python
{
@@ -117,9 +118,7 @@ void handle_exception() throw();
an enclosing <code>try</code> block.
</dl>
<pre>
<a name="expect_non_null-spec">PyObject* expect_non_null(PyObject* x);</a>
template &lt;class T&gt; T* expect_non_null(T* x);
<a name="expect_non_null-spec">template &lt;class T&gt; T* expect_non_null(T* x);</a>
</pre>
<dl class="expect_non_null-semantics">
@@ -135,6 +134,16 @@ template &lt;class T&gt; T* expect_non_null(T* x);
return 0 on error.
</dl>
<pre>
<a name="throw_error_already_set-spec">void throw_error_already_set();</a>
</pre>
<dl class="throw_error_already_set-semantics">
<dt><b>Effects:</b> <code>throw&nbsp;<a href=
"#error_already_set-spec">error_already_set</a>();</code>
</dl>
<h2><a name="examples"></a>Examples</h2>
<pre>
#include &lt;string&gt;
@@ -223,7 +232,7 @@ same_name2(PyObject* args, PyObject* keywords)
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
05 November, 2001
17 November, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->

View File

@@ -9,7 +9,8 @@
"header">
<tr>
<td valign="top" width="300">
<h3><a href="http://www.boost.org"><img height="86" width="277" alt="C++ Boost" src="../c++boost.gif" border="0"></a></h3>
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>

View File

@@ -16,9 +16,8 @@
"100%" summary="header">
<tr>
<td valign="top" width="300">
<h3><a href="http://www.boost.org"><img height="86"
width="277" alt="C++ Boost" src="../c++boost.gif"
border="0"></a></h3>
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
<td valign="top">
<h1 class="c1">Boost.Python</h1>

View File

@@ -151,7 +151,7 @@ std::size_t length_if_string(PyObject* p)
if (!converter.convertible())
return 0;
else
return converter().size();
return converter(p).size();
}
</pre>

View File

@@ -9,7 +9,8 @@
"header">
<tr>
<td valign="top" width="300">
<h3><a href="http://www.boost.org"><img height="86" width="277" alt="C++ Boost" src="../c++boost.gif" border="0"></a></h3>
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>
@@ -26,6 +27,7 @@
<dt><a href="rationale.html">Rationale</a></dt>
<dt><a href="definitions.html">Definitions</a></dt>
<dt><a href="faq.html">Frequently Asked Questions (FAQs)</a></dt>
<dt><a href="progress_reports.html">Progress Reports</a></dt>
<dt><a href="bibliography.html">Bibliography</a></dt>
<dt><a href="acknowledgments.html">Acknowledgments</a></dt>
</dl>

209
doc/v2/instance_holder.html Executable file
View File

@@ -0,0 +1,209 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content=
"text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../boost.css">
<title>Boost.Python - &lt;boost/python/instance_holder.hpp&gt;</title>
<style type="text/css">
p.c4 {font-style: italic}
span.c3 {color: #ff0000}
h2.c2 {text-align: center}
h1.c1 {text-align: center}
</style>
<table border="0" cellpadding="7" cellspacing="0" width="100%"
summary="header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width=
"277" alt="C++ Boost" src="../../../../c++boost.gif" border=
"0"></a></h3>
<td valign="top">
<h1 class="c1">Boost.Python</h1>
<h2 class="c2">Header &lt;boost/python/instance_holder.hpp&gt;</h2>
</table>
<hr>
<h2>Contents</h2>
<dl class="page-index">
<dt><a href="#introduction">Introduction</a>
<dt><a href="#classes">Classes</a>
<dd>
<dl class="page-index">
<dt><a href="#instance_holder-spec">Class
<code>instance_holder</code></a>
<dd>
<dl class="page-index">
<dt><a href="#instance_holder-spec-synopsis">Class
<code>instance_holder</code> synopsis</a>
<dt><a href="#instance_holder-spec-ctors">Class
<code>instance_holder</code> destructor</a>
<dt><a href="#instance_holder-spec-modifiers">Class
<code>instance_holder</code> modifier functions</a>
<dt><a href="#instance_holder-spec-observers">Class
<code>instance_holder</code> observer functions</a>
</dl>
</dl>
<dt><a href="#examples">Example</a>
</dl>
<hr>
<h2><a name="introduction"></a>Introduction</h2>
<p><code>&lt;boost/python/instance_holder.hpp&gt;</code> provides
<code>class&nbsp;instance_holder</code>, the base class for types
which hold C++ instances of wrapped classes.
<h2><a name="classes"></a>Classes</h2>
<h3><a name="instance_holder-spec"></a>Class <code>instance_holder</code></h3>
<p><code>instance_holder</code> is an abstract base class whose
concrete derived classes hold C++ class instances within their
Python object wrappers. To allow multiple inheritance in Python
from C++ class wrappers, each such Python object contains a chain
of <code>instance_holder</code>s. When an <code>__init__</code>
function for a wrapped C++ class is invoked, a new
<code>instance_holder</code> instance is created and installed in
the Python object using its <code><a
href="#instance_holder-spec-modifiers">install</a></code>()
function. Each concrete class derived from
<code>instance_holder</code> must provide a <code><a
href="#instance_holder-spec-observers">holds</a>()</code>
implementation which allows Boost.Python to query it for the
type(s) it is holding. In order to support the held type's wrapped
constructor(s), the class must also provide constructors that can
accept an initial <code>PyObject*</code> argument referring to the
owning Python object, and which forward the rest of their
arguments to the constructor of the held type. The initial
argument is needed to enable virtual function overriding in
Python, and may be ignored, depending on the specific
<code>instance_holder</code> subclass.
<h4><a name="instance_holder-spec-synopsis"></a>Class instance_holder
synopsis</h4>
<pre>
namespace boost { namespace python
{
class instance_holder : <a href="../../../utility/utility.htm#Class noncopyable">noncopyable</a>
{
public:
// destructor
virtual ~instance_holder();
// instance_holder modifiers
void install(PyObject* inst) throw();
// instance_holder observers
virtual void* holds(type_info) = 0;
};
}}
</pre>
<h4><a name="instance_holder-spec-ctors">Class <code>instance_holder</code>
destructor</a></h4>
<pre>
virtual ~instance_holder();
</pre>
<dl class="function-semantics">
<dt><b>Effects:</b> destroys the object
</dl>
<h4><a name="instance_holder-spec-modifiers">Class
<code>instance_holder</code> modifiers</a></h4>
<pre>
void install(PyObject* inst) throw();
</pre>
<dl class="function-semantics">
<dt><b>Requires:</b> <code>inst</code> is a Python instance of a
wrapped C++ class type, or is a type derived from a wrapped C++
class type.
<dt><b>Effects:</b> installs the new instance at the head of the
Python object's chain of held instances.
<dt><b>Throws:</b> nothing
</dl>
<h4><a name="instance_holder-spec-observers">Class <code>instance_holder</code>
observers</a></h4>
<pre>
virtual void* holds(type_info x) = 0;
</pre>
<dl class="function-semantics">
<dt><b>Returns:</b> A pointer to an object of the type described
by <code>x</code> if <code>*this</code> contains such an object,
0 otherwise.
</dl>
<h2><a name="examples"></a>Example</h2>
The following is a simplified version of the instance holder template
used by Boost.Python to wrap classes held by smart pointers:
<pre>
template &lt;class SmartPtr, class Value&gt;
struct pointer_holder : instance_holder
{
// construct from the SmartPtr type
pointer_holder(SmartPtr p)
:m_p(p)
// Forwarding constructors for the held type
pointer_holder(PyObject*)
:m_p(new Value())
{
}
template&lt;class A0&gt;
pointer_holder(PyObject*,A0 a0)
:m_p(new Value(a0))
{
}
template&lt;class A0,class A1&gt;
pointer_holder(PyObject*,A0 a0,A1 a1)
:m_p(new Value(a0,a1))
{
}
...
private: // required holder implementation
void* holds(type_info dst_t)
{
// holds an instance of the SmartPtr type...
if (dst_t == python::type_id&lt;SmartPtr&gt;())
return &amp;this-&gt;m_p;
// ...and an instance of the SmartPtr's element_type, if the
// pointer is non-null
return python::type_id&lt;Value&gt;() == dst_t ? &amp;*this-&gt;m_p : 0;
}
private: // data members
SmartPtr m_p;
};
</pre>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
29 May, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
<p class="c4">&copy; Copyright <a href=
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002. All
Rights Reserved.

364
doc/v2/iterator.html Normal file
View File

@@ -0,0 +1,364 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../boost.css">
<title>Boost.Python - &lt;boost/python/iterator.hpp&gt;</title>
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
<td valign="top">
<h1 align="center">Boost.Python</h1>
<h2 align="center">Header &lt;boost/python/iterator.hpp&gt;</h2>
</table>
<hr>
<h2>Contents</h2>
<dl class="page-index">
<dt><a href="#introduction">Introduction</a>
<dt><a href="#classes">Classes</a>
<dd>
<dl class="page-index">
<dt><a href="#iterator-spec">Class template <code>iterator</code></a>
<dd>
<dl class="page-index">
<dt><a href="#iterator-spec-synopsis">Class
<code>iterator</code> synopsis</a>
<dt><a href="#iterator-spec-ctors">Class template <code>iterator</code>
constructor</a>
</dl>
</dl>
<dl class="page-index">
<dt><a href="#iterators-spec">Class template <code>iterators</code></a>
<dd>
<dl class="page-index">
<dt><a href="#iterators-spec-synopsis">Class
<code>iterators</code> synopsis</a>
<dt><a href="#iterators-spec-types">Class template
<code>iterators</code> nested types</a>
<dt><a href="#iterators-spec-statics">Class template
<code>iterators</code> static functions</a>
</dl>
</dl>
<dt><a href="#functions">Functions</a>
<dd>
<dl class="page-index">
<dt><a href="#range-spec">range</a>
</dl>
<dt><a href="#examples">Examples</a>
</dl>
<hr>
<h2><a name="introduction"></a>Introduction</h2>
<p><code>&lt;boost/python/iterator.hpp&gt;</code> provides types
and functions for creating <a
href="http://www.python.org/doc/current/lib/typeiter.html">Python
iterators</a> from <a
href="http://www.sgi.com/tech/stl/Container.html">C++
Containers</a> and <a
href="http://www.sgi.com/tech/stl/Iterators.html">Iterators</a>. Note
that if your <code>class_</code> supports random-access iterators,
implementing
<code><a
href="http://www.python.org/doc/current/ref/sequence-types.html#l2h-128">__getitem__</a></code>
(also known as the Sequence Protocol) may serve you better than
using this facility: Python will automatically create an iterator
type for you (see <a
href="http://www.python.org/doc/current/lib/built-in-funcs.html#l2h-35">iter()</a>),
and each access can be range-checked, leaving no possiblity of
accessing through an invalidated C++ iterator.
<h2><a name="classes"></a>Classes</h2>
<h3><a name="iterator-spec"></a>Class Template <code>iterator</code></h3>
<p>Instances of <code>iterator&lt;C,P&gt;</code> hold a reference
to a callable Python object which, when invoked from Python,
expects a single argument <code>c</code> convertible to
<code>C</code> and creates a Python iterator that traverses
[<code>c.begin()</code>,
<code>c.end()</code>). The optional <a
href="CallPolicies.html">CallPolicies</a>
<code>P</code> can be used to control how elements are returned
during iteration.
<p>In the table below, <code><b>c</b></code> is an instance of <code>Container</code>.
<table border="1" summary="iterator template parameters">
<tr>
<th>Template Parameter
<th>Requirements
<th>Semantics
<th>Default
<tr>
<td><code>Container</code>
<td>[c.begin(),c.end()) is a valid <a
href="http://www.sgi.com/tech/stl/Iterators.html">Iterator
range</a>.
<td>The result will convert its argument to
<code>c</code> and call
<code>c.begin()</code> and <code>c.end()</code> to acquire
iterators. To invoke <code>Container</code>'s
<code>const</code> <code>begin()</code> and <code>end()</code>
functions, make it <code>const</code>.
<tr>
<td><code>NextPolicies</code>
<td>A default-constructible model of <a
href="CallPolicies.html#CallPolicies-concept">CallPolicies</a>.
<td>Applied to the resulting iterators' <code>next()</code> method.
<td>An unspecified model of <a
href="CallPolicies.html#CallPolicies-concept">CallPolicies</a>
which always makes a copy of the
result of deferencing the underlying C++ iterator
</table>
<h4><a name="iterator-spec-synopsis"></a>Class Template iterator synopsis</h4>
<pre>
namespace boost { namespace python
{
template &lt;class Container
, class NextPolicies = <i>unspecified</i>&gt;
struct iterator : reference&lt;PyObject*&gt;
{
iterator();
};
}}
</pre>
<h4><a name="iterator-spec-constructors"></a>Class Template
iterator constructor</h4>
<pre>
iterator()
</pre>
<dl class="function-semantics">
<dt><b>Effects:</b> Initializes its base class with the result
of:
<pre>
range&lt;NextPolicies&gt;(&amp;iterators&lt;Container&gt;::begin, &amp;iterators&lt;Container&gt;::end)
</pre>
<dt><b>Postconditions:</b> <code>this-&gt;get()</code> points to
a Python callable object which creates a Python iterator as
described above.
<dt><b>Rationale:</b> Provides an easy way to create iterators
for the common case where a C++ class being wrapped provides
<code>begin()</code> and <code>end()</code>.
</dl>
<!-- -->
<h3><a name="iterators-spec"></a>Class Template <code>iterators</code></h3>
<p>A utility class template which provides a way to reliably call
its argument's <code>begin()</code> and <code>end()</code> member
functions. Note that there is no portable way to take the address
of a member function of a C++ standard library container, so
<code>iterators&lt;&gt;</code> can be particularly helpful when
wrapping them.
<p>In the table below, <code><b>x</b></code> is an instance of <code>C</code>.
<table border="1" summary="iterator template parameters">
<tr>
<th>Required Valid Expression
<th>Type
<tr>
<td><code>x.begin()</code>
<td>Convertible to <code>C::const_iterator</code> if <code>C</code> is a
<code>const</code> type; convertible to <code>C::iterator</code> otherwise.
<tr>
<td><code>x.end()</code>
<td>Convertible to <code>C::const_iterator</code> if <code>C</code> is a
<code>const</code> type; convertible to <code>C::iterator</code> otherwise.
</table>
<h4><a name="iterators-spec-synopsis"></a>Class Template iterators synopsis</h4>
<pre>
namespace boost { namespace python
{
template &lt;class C&gt;
struct iterators
{
typedef typename C::[const_]iterator iterator;
static iterator begin(C&amp; x);
static iterator end(C&amp; x);
};
}}
</pre>
<h4><a name="iterators-spec-types"></a>Class Template
iterators nested types</h4>
If C is a <code>const</code> type,
<pre>
typedef typename C::const_iterator iterator;
</pre>
Otherwise:
<pre>
typedef typename C::iterator iterator;
</pre>
<h4><a name="iterators-spec-statics"></a>Class Template
iterators static functions</h4>
<pre>
static iterator begin(C&amp;);
</pre>
<dl class="function-semantics">
<dt><b>Returns:</b> <code>x.begin()</code>
</dl>
<pre>
static iterator end(C&amp;);
</pre>
<dl class="function-semantics">
<dt><b>Returns:</b> <code>x.end()</code>
</dl>
<!-- -->
<h2><a name="functions"></a>Functions</h2>
<pre>
<a name=
"range-spec">template</a> &lt;class NextPolicies, class Target, class Accessor1, class Accessor2&gt;
reference&lt;PyObject*&gt range(Accessor1 start, Accessor2 finish);
template &lt;class NextPolicies, class Accessor1, class Accessor2&gt;
reference&lt;PyObject*&gt range(Accessor1 start, Accessor2 finish);
template &lt;class Accessor1, class Accessor2&gt;
reference&lt;PyObject*&gt range(Accessor1 start, Accessor2 finish);
</pre>
<dl class="range-semantics">
<dt><b>Requires:</b> <code>NextPolicies</code> is a
default-constructible model of <a
href="CallPolicies.html#CallPolicies-concept">CallPolicies</a>.
<dt><b>Effects:</b> <dl>
The first form creates a Python callable
object which, when invoked, converts its argument to a
<code>Target</code> object
<code>x</code>, and creates a Python iterator which traverses
[<code><a
href="../../../bind/bind.html">bind</a>(start,_1)(x)</code>,&nbsp;<code><a
href="../../../bind/bind.html">bind</a>(finish,_1)(x)</code>),
applying <code>NextPolicies</code> to the iterator's
<code>next()</code> function.
<dd>
<dt>The second form is identical to
the first, except that <code>Target</code> is deduced from
<code>Accessor1</code> as follows:
<ol>
<li>If <code>Accessor1</code> is a function type,
<code>Target</code> is the type of its first argument.
<li>If <code>Accessor1</code> is a data member pointer of the
form <code>R&nbsp;(T::*)</code>, <code>Target</code> is
identical to <code>T</code>.
<li>If <code>Accessor1</code> is a member function pointer of
the form
<code>R&nbsp;(T::*)(</code><i>arguments...</i><code>)</code>&nbsp;<i>cv-opt</i>,
where <i>cv-opt</i> is an optional <code>cv-qualifier</code>,
<code>Target</code> is identical to <code>T</code>.
</ol>
<dd>
<dt>The third form is identical to the second, except that
<code>NextPolicies</code> is an unspecified model of <a
href="CallPolicies.html#CallPolicies-concept">CallPolicies</a>
which always makes a copy of the
result of deferencing the underlying C++ iterator<dd>
</dl>
<dt><b>Rationale:</b> The use of <code><a
href="../../../bind/bind.html">boost::bind</a>()</code> allows
C++ iterators to be accessed through functions, member functions
or data member pointers. Customization of
<code>NextPolicies</code> (e.g. using <code><a
href="return_internal_reference.html#return_internal_reference-spec"
>return_internal_reference</a></code>) is useful when it is
expensive to copy sequence elements of a wrapped class
type. Customization of <code>Target</code> is useful when
<code>Accessor1</code> is a function object, or when a base
class of the intended target type would otherwise be deduced.
</dl>
<h2><a name="examples"></a>Examples</h2>
<pre>
#include &lt;boost/python/module.hpp&gt;
#include &lt;boost/python/class.hpp&gt;
#include &lt;boost/python/return_internal_reference.hpp&gt;
#include &lt;vector&gt;
using namespace boost::python;
BOOST_PYTHON_MODULE_INIT(demo)
{
module(&quot;demo&quot;)
.add(
class_&lt;std::vector&lt;double&gt; &gt;(&quot;dvec&quot;)
.def(&quot;__iter__&quot;, iterator&lt;std::vector&lt;double&gt; &gt;())
...
)
;
}
</pre>
A more comprehensive example can be found in:
<code><dl>
<dt><a href="../../test/iterator.cpp">libs/python/test/iterator.cpp</a><dd>
<dt><a href="../../test/input_iterator.cpp">libs/python/test/input_iterator.cpp</a><dd>
<dt><a href="../../test/iterator.py">libs/python/test/input_iterator.py</a><dd>
</code>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave
Abrahams</a> 2002. All Rights Reserved.</i>

View File

@@ -1,279 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../boost.css">
<title>Boost.Python - &lt;boost/python/lvalue_from_python.hpp&gt;</title>
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
<td valign="top">
<h1 align="center">Boost.Python</h1>
<h2 align="center">Header &lt;boost/python/lvalue_from_python.hpp&gt;</h2>
</table>
<hr>
<h2>Contents</h2>
<dl class="page-index">
<dt><a href="#introduction">Introduction</a>
<dt><a href="#classes">Classes</a>
<dd>
<dl class="page-index">
<dt><a href="#lvalue_from_python-spec">Class Template <code>lvalue_from_python</code></a>
<dd>
<dl class="page-index">
<dt><a href="#lvalue_from_python-spec-synopsis">Class Template
<code>lvalue_from_python</code> synopsis</a>
<dt><a href="#lvalue_from_python-spec-ctors">Class Template
<code>lvalue_from_python</code> constructor</a>
</dl>
</dl>
<dl class="page-index">
<dt><a href="#get_member-spec">Class Template <code>get_member</code></a>
<dd>
<dl class="page-index">
<dt><a href="#get_member-spec-synopsis">Class Template
<code>get_member</code> synopsis</a>
<dt><a href="#get_member-spec-statics">Class Template
<code>get_member</code> static functions</a>
</dl>
</dl>
<dt><a href="#examples">Example</a>
</dl>
<hr>
<h2><a name="introduction"></a>Introduction</h2>
<code>&lt;boost/python/lvalue_from_python.hpp&gt;</code> supplies
a facility for extracting C++ objects from within instances of a
given Python type. This is typically useful for dealing with
&quot;traditional&quot; Python extension types.
<h2><a name="classes"></a>Classes</h2>
<h3><a name="lvalue_from_python-spec"></a>Class template <code>lvalue_from_python</code></h3>
<p>Class template <code>lvalue_from_python</code> will register
from_python converters which extract a references and pointers to
a C++ type which is held within an object of a given Python
type. Its template arguments are:
<p>
<table border="1" summary="lvalue_from_python template parameters">
<caption>
<b><code>lvalue_from_python</code> Requirements</b><br>
In the table below, <b><code>x</code></b> denotes an object of type <code>PythonObject&amp;</code>
</caption>
<tr>
<th>Parameter
<th>Requirements
<th>Description
<th>Default
<tr>
<td><code>python_type</code>
<td>A compile-time constant <code><a
href="http://www.python.org/doc/2.2/ext/dnt-type-methods.html">PyTypeObject</a>*</code>
<td>The Python type of instances convertible by this
converter. Python subtypes are also convertible.
<tr>
<td><code>Value</code>
<td>A non-reference type.
<td>The C++ type to be extracted
<tr>
<td><code>PythonObject</code>
<td>initial <code>sizeof(PyObject)</code> bytes are
layout-compatible with <code>PyObject</code>.
<td>The C++ type used to hold Python instances of
<code>python_type</code>.
<td><code>Value</code>
<tr>
<td><code>Extract</code>
<td><code>Value&amp; v = Extract::execute(x);</code>
<td>A type whose static <code>execute</code> function extracts a <code>Value</code> reference from within an object of type <code>PythonObject</code>.
<td>An unspecified type whose <code>execute</code> function consists of <code>return&nbsp;x;</code>
</table>
If only the first two template arguments are supplied, these
converters extract the entire <code>PythonObject</code> as a
whole.
<p>
If the lifetime of the <code>lvalue_from_python</code> object ends
before the last attempt to convert to one its target types, the
behavior is undefined. The easiest way to ensure correct behavior
is to declare an <code>lvalue_from_python</code> instance as a
static local in a <a
href="module.html#BOOST_PYTHON_MODULE_INIT-spec">module init
function</a>, as shown in the <a href="#examples">example</a>
below.
<h4><a name="lvalue_from_python-spec-synopsis"></a>Class template <code>lvalue_from_python</code> synopsis</h4>
<pre>
namespace boost { namespace python
{
template &lt;
PyTypeObject const* python_type
, class Value
, class PythonObject = Value
, class Extract = <i>unspecified</i>
&gt;
class lvalue_from_python
{
lvalue_from_python();
};
}}
</pre>
<h4><a name="lvalue_from_python-spec-ctors"></a>Class template <code>lvalue_from_python</code> constructor</h4>
<pre>
lvalue_from_python();
</pre>
<dl class="function-semantics">
<dt><b>Effects:</b> Registers from_python converters which
extract
<code>Value&amp;</code>, <code>Value const&amp;</code>,
<code>Value*</code>, or <code>Value const*</code> from Python
objects of type <code>python_type</code> using
<code>Extract::execute()</code>.
</dl>
<h3><a name="get_member-spec"></a>Class template <code>get_member</code></h3>
<p><code>get_member</code> can be used with
<code>lvalue_from_python</code> in the common case where the C++
type to be extracted is a member of the Python object.
<h4><a name="get_member-spec-synopsis"></a>Class template <code>get_member</code> synopsis</h4>
<pre>
namespace boost { namespace python
{
template &lt;class Class, class Member, Member (Class::*mp)&gt;
struct get_member
{
static Member&amp; execute(Class&amp; c);
};
}}
</pre>
<h4><a name="get_member-spec-statics"></a>Class template <code>get_member</code> static functions</h4>
<pre>
Member&amp; execute(Class&amp; c);
</pre>
<dl class="function-semantics">
<dt><b>Returns:</b> <code>c.*mp</code>
</dl>
<h2><a name="examples"></a>Example</h2>
This example presumes that someone has implemented the standard <a
href="http://www.python.org/doc/2.2/ext/dnt-basics.html">noddy
example module</a> from the Python documentation, and we want to build
a module which manipulates <code>Noddy</code>s. Since
<code>noddy_NoddyObject</code> is so simple that it carries no
interesting information, the example is a bit contrived: it assumes
you want to keep track of one particular object for some reason.
<h3>C++ module definition</h3>
<pre>
#include &lt;boost/python/reference.hpp&gt;
#include &lt;boost/python/module.hpp&gt;
// definition lifted from the Python docs
typedef struct {
PyObject_HEAD
} noddy_NoddyObject;
using namespace boost::python;
static ref cache;
bool is_cached(noddy_NoddyObject* x)
{
return x == cache.get();
}
void set_cache(noddy_NoddyObject* x)
{
cache.reset((PyObject*)x, ref::increment_count);
}
BOOST_PYTHON_MODULE_INIT(noddy_cache)
{
module noddy_cache(&quot;noddy_cache&quot;)
.def(&quot;is_cached&quot;, is_cached)
.def(&quot;set_cache&quot;, set_cache)
;
}
</pre>
<h3>Python code</h3>
<pre>
&gt;&gt;&gt; import noddy
&gt;&gt;&gt; n = noddy.new_noddy()
&gt;&gt;&gt; import noddy_cache
&gt;&gt;&gt; noddy_cache.is_cached(n)
0
&gt;&gt;&gt; noddy_cache.set_cache(n)
&gt;&gt;&gt; noddy_cache.is_cached(n)
1
&gt;&gt;&gt; noddy_cache.is_cached(noddy.new_noddy())
0
</pre>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
05 November, 2001
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave
Abrahams</a> 2002. All Rights Reserved.</i>

283
doc/v2/lvalue_from_pytype.html Executable file
View File

@@ -0,0 +1,283 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../boost.css">
<title>Boost.Python - &lt;boost/python/lvalue_from_python.hpp&gt;</title>
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
<td valign="top">
<h1 align="center">Boost.Python</h1>
<h2 align="center">Header &lt;boost/python/lvalue_from_pytype.hpp&gt;</h2>
</table>
<hr>
<h2>Contents</h2>
<dl class="page-index">
<dt><a href="#introduction">Introduction</a>
<dt><a href="#classes">Classes</a>
<dd>
<dl class="page-index">
<dt><a href="#lvalue_from_pytype-spec">Class Template <code>lvalue_from_pytype</code></a>
<dd>
<dl class="page-index">
<dt><a href="#lvalue_from_pytype-spec-synopsis">Class Template
<code>lvalue_from_pytype</code> synopsis</a>
<dt><a href="#lvalue_from_pytype-spec-ctors">Class Template
<code>lvalue_from_pytype</code> constructor</a>
</dl>
</dl>
<dl class="page-index">
<dt><a href="#extract_identity-spec">Class Template <code>extract_identity</code></a>
<dd>
<dl class="page-index">
<dt><a href="#extract_identity-spec-synopsis">Class Template
<code>extract_identity</code> synopsis</a>
<dt><a href="#extract_identity-spec-statics">Class Template
<code>extract_identity</code> static functions</a>
</dl>
<dt><a href="#extract_member-spec">Class Template <code>extract_member</code></a>
<dd>
<dl class="page-index">
<dt><a href="#extract_member-spec-synopsis">Class Template
<code>extract_member</code> synopsis</a>
<dt><a href="#extract_member-spec-statics">Class Template
<code>extract_member</code> static functions</a>
</dl>
</dl>
<dt><a href="#examples">Example</a>
</dl>
<hr>
<h2><a name="introduction"></a>Introduction</h2>
<code>&lt;boost/python/lvalue_from_pytype.hpp&gt;</code> supplies
a facility for extracting C++ objects from within Python instances
of a given type. This is typically useful for dealing with
&quot;traditional&quot; Python extension types.
<h2><a name="classes"></a>Classes</h2>
<h3><a name="lvalue_from_pytype-spec"></a>Class template <code>lvalue_from_pytype</code></h3>
<p>Class template <code>lvalue_from_pytype</code> will register
from_python converters which, given an object of the given Python
type, can extract references and pointers to a particular C++
type. Its template arguments are:
<p>
<table border="1" summary="lvalue_from_pytype template parameters">
<caption>
<b><code>lvalue_from_pytype</code> Requirements</b><br>
In the table below, <b><code>x</code></b> denotes an object of type <code>PythonObject&amp;</code>
</caption>
<tr>
<th>Parameter
<th>Requirements
<th>Semantics
<tr>
<td><code>Extractor</code>
<td>a model of <a
href="Extractor.html#Extractor-concept">Extractor</a> whose
execute function returns a reference type.
<td>Extracts the lvalue from the Python object once its type has been confirmed
<tr>
<td><code>python_type</code>
<td>A compile-time constant <code><a
href="http://www.python.org/doc/2.2/ext/dnt-type-methods.html">PyTypeObject</a>*</code>
<td>The Python type of instances convertible by this
converter. Python subtypes are also convertible.
</table>
<h4><a name="lvalue_from_pytype-spec-synopsis"></a>Class template <code>lvalue_from_pytype</code> synopsis</h4>
<pre>
namespace boost { namespace python
{
template &lt;class Extractor, PyTypeObject const* python_type&gt;
struct lvalue_from_pytype
{
lvalue_from_pytype();
};
}}
</pre>
<h4><a name="lvalue_from_pytype-spec-ctors"></a>Class template <code>lvalue_from_pytype</code> constructor</h4>
<pre>
lvalue_from_pytype();
</pre>
<dl class="function-semantics">
<dt><b>Effects:</b> Registers converters which can convert
Python objects of the given type to lvalues of the type returned
by <code>Extractor::execute</code>.
</dl>
<h3><a name="extract_identity-spec"></a>Class template <code>extract_identity</code></h3>
<p><code>extract_identity</code> is a model of <a
href="Extractor.html#Extractor-concept">Extractor</a> which can be
used in the common case where the C++ type to be extracted is the
same as the Python object type.
<h4><a name="extract_identity-spec-synopsis"></a>Class template
<code>extract_identity</code> synopsis</h4>
<pre>
namespace boost { namespace python
{
template &lt;class InstanceType&gt;
struct extract_identity
{
static InstanceType&amp; execute(InstanceType&amp; c);
};
}}
</pre>
<h4><a name="extract_identity-spec-statics"></a>Class template <code>extract_identity</code> static functions</h4>
<pre>
InstanceType&amp; execute(InstanceType&amp; c);
</pre>
<dl class="function-semantics">
<dt><b>Returns:</b> <code>c</code>
</dl>
<h3><a name="extract_member-spec"></a>Class template <code>extract_member</code></h3>
<p><code>extract_member</code> is a model of <a
href="Extractor.html#Extractor-concept">Extractor</a> which can be
used in the common case in the common case where the C++
type to be extracted is a member of the Python object.
<h4><a name="extract_member-spec-synopsis"></a>Class template <code>extract_member</code> synopsis</h4>
<pre>
namespace boost { namespace python
{
template &lt;class InstanceType, class MemberType, MemberType (InstanceType::*member)&gt;
struct extract_member
{
static MemberType&amp; execute(InstanceType&amp; c);
};
}}
</pre>
<h4><a name="extract_member-spec-statics"></a>Class template <code>extract_member</code> static functions</h4>
<pre>
static MemberType&amp; execute(InstanceType&amp; c);
</pre>
<dl class="function-semantics">
<dt><b>Returns:</b> <code>c.*member</code>
</dl>
<h2><a name="examples"></a>Example</h2>
This example presumes that someone has implemented the standard <a
href="http://www.python.org/doc/2.2/ext/dnt-basics.html">noddy
example module</a> from the Python documentation, and we want to build
a module which manipulates <code>Noddy</code>s. Since
<code>noddy_NoddyObject</code> is so simple that it carries no
interesting information, the example is a bit contrived: it assumes
you want to keep track of one particular object for some reason. This
module would have to be dynamically linked to the module which defines
<code>noddy_NoddyType</code>.
<h3>C++ module definition</h3>
<pre>
#include &lt;boost/python/reference.hpp&gt;
#include &lt;boost/python/module.hpp&gt;
// definition lifted from the Python docs
typedef struct {
PyObject_HEAD
} noddy_NoddyObject;
using namespace boost::python;
static reference&lt;PyObject&gt; cache;
bool is_cached(noddy_NoddyObject* x)
{
return x == cache.get();
}
void set_cache(noddy_NoddyObject* x)
{
cache.reset((PyObject*)x, ref::increment_count);
}
BOOST_PYTHON_MODULE_INIT(noddy_cache)
{
module noddy_cache(&quot;noddy_cache&quot;)
.def(&quot;is_cached&quot;, is_cached)
.def(&quot;set_cache&quot;, set_cache)
;
// register Noddy lvalue converter
lvalue_from_pytype&lt;extract_identity&lt;noddy_NoddyObject&gt;,&amp;noddy_NoddyType&gt;();
}
</pre>
<h3>Python code</h3>
<pre>
&gt;&gt;&gt; import noddy
&gt;&gt;&gt; n = noddy.new_noddy()
&gt;&gt;&gt; import noddy_cache
&gt;&gt;&gt; noddy_cache.is_cached(n)
0
&gt;&gt;&gt; noddy_cache.set_cache(n)
&gt;&gt;&gt; noddy_cache.is_cached(n)
1
&gt;&gt;&gt; noddy_cache.is_cached(noddy.new_noddy())
0
</pre>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
05 November, 2001
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave
Abrahams</a> 2002. All Rights Reserved.</i>

View File

@@ -78,12 +78,17 @@ objects::function* make_function(F f, Policies const&amp; policies)
<a name=
"make_constructor-spec">template &lt;class T, class ArgList, class Generator&gt;
objects::function* make_constructor();</a>
template &lt;class ArgList, class Generator, class Policies&gt;
objects::function* make_constructor(Policies const&amp; policies)
</pre>
<dl class="function-semantics">
<dt><b>Requires:</b> <code>T</code> is a class type. <code>ArgList</code>
is an <a href="../../../mpl/doc/Sequences.html">MPL sequence</a> of C++
argument types (<i>A1, A2,... AN</i>) such that if
<dt><b>Requires:</b> <code>T</code> is a class
type. <code>Policies</code> is a model of <a
href="CallPolicies.html">CallPolicies</a>. <code>ArgList</code>
is an <a href="../../../mpl/doc/Sequences.html">MPL sequence</a>
of C++ argument types (<i>A1, A2,... AN</i>) such that if
<code>a1, a2</code>... <code>aN</code> are objects of type
<i>A1, A2,... AN</i> respectively, the expression <code>new
Generator::apply&lt;T&gt;::type(a1, a2</code>... <code>aN</code>) is
@@ -94,8 +99,12 @@ objects::function* make_constructor();</a>
from Python, expects its first argument to be a Boost.Python extension
class object. It converts its remaining its arguments to C++ and passes
them to the constructor of a dynamically-allocated
<code>Generator::apply&lt;T&gt;::type</code> object. The result is
installed in the extension class object.
<code>Generator::apply&lt;T&gt;::type</code> object, which is
then installed in the extension class object. In the second
form, the <code>policies</code> are applied to the arguments and
result (<a
href="http://www.python.org/doc/current/lib/bltin-null-object.html">None</a>)
of the Python callable object
<dt><b>Returns:</b> The new Python callable object
</dl>

View File

@@ -50,7 +50,7 @@
<code>manage_new_object</code></h3>
<p><code>manage_new_object</code> is a model of <a href=
"ResultConverterGenerator.html">ResultConverterGenerator</a> which can be
"ResultConverter.html#ResultConverterGenerator-concept">ResultConverterGenerator</a> which can be
used to wrap C++ functions which return a pointer to an object allocated
with a <i>new-expression</i>, and expect the caller to take responsibility
for deleting that object.
@@ -105,7 +105,7 @@ using namespace boost::python;
BOOST_PYTHON_MODULE_INIT(my_module)
{
module("my_module")
.def("make_foo", make_foo)
.def("make_foo", make_foo, return_value_policy&lt;manage_new_object&gt;)
.add(
class_&lt;Foo&gt;()
.def("get_x", &amp;Foo::get_x)

View File

@@ -60,7 +60,8 @@
<h2><a name="introduction"></a>Introduction</h2>
<p>{{Introductory text}}
<p>This header provides the basic facilities needed to create an
extension module.
<h2><a name="macros"></a>Macros</h2>

531
doc/v2/operators.html Executable file
View File

@@ -0,0 +1,531 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../boost.css">
<title>Boost.Python - &lt;boost/python/operators.hpp&gt;</title>
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
<td valign="top">
<h1 align="center">Boost.Python</h1>
<h2 align="center">Header &lt;boost/python/operators.hpp&gt;</h2>
</table>
<hr>
<h2>Contents</h2>
<dl class="page-index">
<dt><a href="#introduction">Introduction</a>
<dt><a href="#classes">Classes</a>
<dd>
<dl class="page-index">
<dt><a href="#self_t-spec">Class <code>self_ns::self_t</code></a>
<dd>
<dl class="page-index">
<dt><a href="#self_t-spec-synopsis">Class <code>self_t</code> synopsis</a>
<dt><a href="#self_t-spec-inplace">Class <code>self_t</code> inplace operators</a>
<dt><a href="#self_t-spec-comparisons">Class <code>self_t</code> comparison functions</a>
<dt><a href="#self_t-spec-ops">Class <code>self_t</code> non-member operations</a>
<dt><a href="#self_t-spec-value-unary-ops">Class <code>self_t</code> unary operations</a>
<dt><a href="#self_t-spec-value-value-ops">Class <code>self_t</code> value operations</a>
</dl>
<dt><a href="#other-spec">Class template <code>other</code></a>
<dd>
<dl class="page-index">
<dt><a href="#other-spec-synopsis">Class <code>other</code> synopsis</a>
</dl>
<dt><a href="#operator_-spec">Class template <code>operator_</code></a>
<dd>
<dl class="page-index">
<dt><a href="#operator_-spec-synopsis">Class <code>operator_</code> synopsis</a>
</dl>
</dl>
<dt><a href="#objects">Objects</a>
<dd>
<dl class="page-index">
<dt><a href="#self-spec">self</a>
</dl>
<dt><a href="#examples">Examples</a>
</dl>
<hr>
<h2><a name="introduction"></a>Introduction</h2>
<p><code>&lt;boost/python/operators.hpp&gt;</code> provides types
and functions for automatically generating Python <a
href="http://www.python.org/doc/ref/specialnames.html">special
methods</a> from the corresponding C++ constructs. Most of these
constructs are operator expressions, hence the name. To use the
facility, substitute the <code><a
href="#self-spec">self</a></code> object for an object of the
class type being wrapped in the expression to be exposed, and pass
the result to <a
href="class.html#class_-spec-modifiers">class_&lt;&gt;::def()</a>. Much
of what is exposed in this header should be considered part of the
implementation, so is not documented in detail here.
<h2><a name="classes"></a>Classes</h2>
<h3><a name="self_t-spec"></a>Class <code>self_ns::self_t</code></h3>
<p><code>self_ns::self_t</code> is the actual type of the <a
href="#self-spec"><code>self</code></a> object. The library
isolates <code>self_t</code> in its own namespace,
<code>self_ns</code>, in order to prevent the generalized operator
templates which operate on it from being found by
argument-dependent lookup in other contexts. This should be
considered an implementation detail, since users should never have
to mention <code>self_t</code> directly.
<h4><a name="self_t-spec-synopsis"></a>Class <code>self_ns::self_t</code> synopsis</h4>
<pre>
namespace boost { namespace python { namespace self_ns {
{
class self_t {};
// inplace operators
template &lt;class T&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator+=(self_t, T);
template &lt;class T&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator-=(self_t, T);
template &lt;class T&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator*=(self_t, T);
template &lt;class T&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator/=(self_t, T);
template &lt;class T&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator%=(self_t, T);
template &lt;class T&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator&gt;&gt;=(self_t, T);
template &lt;class T&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator&lt;&lt;=(self_t, T);
template &lt;class T&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator&amp;=(self_t, T);
template &lt;class T&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator^=(self_t, T);
template &lt;class T&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator|=(self_t, T);
// comparisons
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator==(L const&amp;, R const&amp;);
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator!=(L const&amp;, R const&amp;);
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator&lt;(L const&amp;, R const&amp;);
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator&gt;(L const&amp;, R const&amp;);
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator&lt;=(L const&amp;, R const&amp;);
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator&gt;=(L const&amp;, R const&amp;);
// non-member operations
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator+(L const&amp;, R const&amp);
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator-(L const&amp;, R const&amp);
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator*(L const&amp;, R const&amp);
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator/(L const&amp;, R const&amp);
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator%(L const&amp;, R const&amp);
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator&gt;&gt;(L const&amp;, R const&amp);
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator&lt;&lt;(L const&amp;, R const&amp);
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator&amp;(L const&amp;, R const&amp);
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator^(L const&amp;, R const&amp);
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator|(L const&amp;, R const&amp);
template &lt;class L, class R&gt; <a
href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; pow(L const&amp;, R const&amp);
// unary operations
<a href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator-(self_t);
<a href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator+(self_t);
<a href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; operator~(self_t);
// value operations
<a href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; int_(self_t);
<a href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; long_(self_t);
<a href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; float_(self_t);
<a href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; complex_(self_t);
<a href="#operator_-spec">operator_</a>&lt;<i>unspecified</i>&gt; str(self_t);
}}};
</pre>
The tables below describe the methods generated when the results of
the expressions described are passed as arguments to <a
href="class.html#class_-spec-modifiers">class_&lt;&gt;::def()</a>.
<code><b>x</b></code> is an object of the class type being wrapped.
<h4><a name="self_t-spec-inplace"></a>Class <code>self_t</code> inplace operators</h4>
In the table below, If <code><b>r</b></code> is an object of type
<code><a href="#other-spec">other</a>&lt;T&gt;</code>,
<code><b>y</b></code> is an object of type <code>T</code>; otherwise,
<code><b>y</b></code> is an object of the same type as
<code><b>r</b></code>.
<table border="1">
<tr>
<th>C++ Expression
<th>Python Method Name
<th>C++ Implementation
<tr><td><code>self&nbsp;+=&nbsp;r</code>
<td><code>__iadd__</code>
<td><code>x&nbsp;+=&nbsp;y</code>
<tr><td><code>self&nbsp;-=&nbsp;r</code>
<td><code>__isub__</code>
<td><code>x&nbsp;-=&nbsp;y</code>
<tr><td><code>self&nbsp;*=&nbsp;r</code>
<td><code>__imul__</code>
<td><code>x&nbsp;*=&nbsp;y</code>
<tr><td><code>self&nbsp;/=&nbsp;r</code>
<td><code>__idiv__</code>
<td><code>x&nbsp;/=&nbsp;y</code>
<tr><td><code>self&nbsp;%=&nbsp;r</code>
<td><code>__imod__</code>
<td><code>x&nbsp;%=&nbsp;y</code>
<tr><td><code>self&nbsp;&gt;&gt;=&nbsp;r</code>
<td><code>__irshift__</code>
<td><code>x&nbsp;&gt;&gt;=&nbsp;y</code>
<tr><td><code>self&nbsp;&lt;&lt;=&nbsp;r</code>
<td><code>__ilshift__</code>
<td><code>x&nbsp;&lt;&lt;=&nbsp;y</code>
<tr><td><code>self&nbsp;&amp;=&nbsp;r</code>
<td><code>__iand__</code>
<td><code>x&nbsp;&amp;=&nbsp;y</code>
<tr><td><code>self&nbsp;^=&nbsp;r</code>
<td><code>__ixor__</code>
<td><code>x&nbsp;^=&nbsp;y</code>
<tr><td><code>self&nbsp;|=&nbsp;r</code>
<td><code>__ior__</code>
<td><code>x&nbsp;|=&nbsp;y</code>
</table>
<h4><a name="self_t-spec-comparisons"></a>Class <code>self_t</code> comparison
functions</h4>
In the tables below, if <code><b>r</b></code> is of type <code><a
href="#self_t-spec">self_t</a></code>, <code><b>y</b></code> is an object
of the same type as <code>x</code>;
<br>
if <code><b>l</b></code> or <code><b>r</b></code> is an object of type <code><a
href="#other-spec">other</a>&lt;T&gt;</code>,
<code><b>y</b></code> is an object of type <code>T</code>;
<br>
otherwise, <code><b>y</b></code> is an object of the same type as
<code><b>l</b></code> or <code><b>r</b></code>.<br>
<code><b>l</b></code>
is never of type <code><a href="#self_t-spec">self_t</a></code>.
<p>
The column of <b>Python Expressions</b> illustrates the expressions
that will be supported in Python for objects convertible to the types
of <code>x</code> and <code>y</code>. The secondary operation arises
due to Python's <a
href="http://www.python.org/doc/ref/customization.html#l2h-89">reflection
rules</a> for rich comparison operators, and are only used when the
corresponding operation is not defined as a method of the
<code>y</code> object.
<table border="1">
<tr><th>C++ Expression <th>Python Method Name <th>C++ Implementation
<th>Python Expressions<br>(primary, secondary)
<code>
<tr><td>self&nbsp;==&nbsp;r <td>__eq__ <td>x&nbsp;==&nbsp;y
<td>x&nbsp;==&nbsp;y, y&nbsp;==&nbsp;x
<tr><td>l&nbsp;==&nbsp;self <td>__eq__ <td>y&nbsp;==&nbsp;x
<td>y&nbsp;==&nbsp;x, x&nbsp;==&nbsp;y
<tr><td>self&nbsp;!=&nbsp;r <td>__ne__ <td>x&nbsp;!=&nbsp;y
<td>x&nbsp;!=&nbsp;y, y&nbsp;!=&nbsp;x
<tr><td>l&nbsp;!=&nbsp;self <td>__ne__ <td>y&nbsp;!=&nbsp;x
<td>y&nbsp;!=&nbsp;x, x&nbsp;!=&nbsp;y
<tr><td>self&nbsp;&lt;&nbsp;r <td>__lt__ <td>x&nbsp;&lt;&nbsp;y
<td>x&nbsp;&lt;&nbsp;y, y&nbsp;&gt;&nbsp;x
<tr><td>l&nbsp;&lt;&nbsp;self <td>__gt__ <td>y&nbsp;&lt;&nbsp;x
<td>y&nbsp;&gt;&nbsp;x, x&nbsp;&lt;&nbsp;y
<tr><td>self&nbsp;&gt;&nbsp;r <td>__gt__ <td>x&nbsp;&gt;&nbsp;y
<td>x&nbsp;&gt;&nbsp;y, y&nbsp;&lt;&nbsp;x
<tr><td>l&nbsp;&gt;&nbsp;self <td>__lt__ <td>y&nbsp;&gt;&nbsp;x
<td>y&nbsp;&lt;&nbsp;x, x&nbsp;&gt;&nbsp;y
<tr><td>self&nbsp;&lt;=&nbsp;r <td>__le__ <td>x&nbsp;&lt;=&nbsp;y
<td>x&nbsp;&lt;=&nbsp;y, y&nbsp;&gt;=&nbsp;x
<tr><td>l&nbsp;&lt;=&nbsp;self <td>__ge__ <td>y&nbsp;&lt;=&nbsp;x
<td>y&nbsp;&gt;=&nbsp;x, x&nbsp;&lt;=&nbsp;y
<tr><td>self&nbsp;&gt;=&nbsp;r <td>__ge__ <td>x&nbsp;&gt;=&nbsp;y
<td>x&nbsp;&gt;=&nbsp;y, y&nbsp;&lt;=&nbsp;x
<tr><td>l&nbsp;&gt;=&nbsp;self <td>__le__ <td>y&nbsp;&gt;=&nbsp;x
<td>y&nbsp;&lt;=&nbsp;x, x&nbsp;&gt;=&nbsp;y
</code>
</table>
<h4><a name="self_t-spec-ops"></a>Class
<code>self_t</code> non-member operations</h4>
The operations whose names begin with &quot;<code>__r</code>&quot;
below will only be called if the left-hand operand does not already
support the given operation, as described <a
href="http://www.python.org/doc/current/ref/numeric-types.html#l2h-152">here</a>.
<table border="1">
<tr><th>C++ Expression <th>Python Method Name <th>C++ Implementation
<code>
<tr><td>self&nbsp;+&nbsp;r <td>__add__ <td>x&nbsp;+&nbsp;y
<tr><td>l&nbsp;+&nbsp;self <td>__radd__ <td>y&nbsp;+&nbsp;x
<tr><td>self&nbsp;-&nbsp;r <td>__sub__ <td>x&nbsp;-&nbsp;y
<tr><td>l&nbsp;-&nbsp;self <td>__rsub__ <td>y&nbsp;-&nbsp;x
<tr><td>self&nbsp;*&nbsp;r <td>__mul__ <td>x&nbsp;*&nbsp;y
<tr><td>l&nbsp;*&nbsp;self <td>__rmul__ <td>y&nbsp;*&nbsp;x
<tr><td>self&nbsp;/&nbsp;r <td>__div__ <td>x&nbsp;/&nbsp;y
<tr><td>l&nbsp;/&nbsp;self <td>__rdiv__ <td>y&nbsp;/&nbsp;x
<tr><td>self&nbsp;%&nbsp;r <td>__mod__ <td>x&nbsp;%&nbsp;y
<tr><td>l&nbsp;%&nbsp;self <td>__rmod__ <td>y&nbsp;%&nbsp;x
<tr><td>self&nbsp;&gt;&gt;&nbsp;r <td>__rshift__ <td>x&nbsp;&gt;&gt;&nbsp;y
<tr><td>l&nbsp;&gt;&gt;&nbsp;self <td>__rrshift__ <td>y&nbsp;&gt;&gt;&nbsp;x
<tr><td>self&nbsp;&lt;&lt;&nbsp;r <td>__lshift__ <td>x&nbsp;&lt;&lt;&nbsp;y
<tr><td>l&nbsp;&lt;&lt;&nbsp;self <td>__rlshift__ <td>y&nbsp;&lt;&lt;&nbsp;x
<tr><td>self&nbsp;&amp;&nbsp;r <td>__and__ <td>x&nbsp;&amp;&nbsp;y
<tr><td>l&nbsp;&amp;&nbsp;self <td>__rand__ <td>y&nbsp;&amp;&nbsp;x
<tr><td>self&nbsp;^&nbsp;r <td>__xor__ <td>x&nbsp;^&nbsp;y
<tr><td>l&nbsp;^&nbsp;self <td>__rxor__ <td>y&nbsp;^&nbsp;x
<tr><td>self&nbsp;|&nbsp;r <td>__or__ <td>x&nbsp;|&nbsp;y
<tr><td>l&nbsp;|&nbsp;self <td>__ror__ <td>y&nbsp;|&nbsp;x
<tr><td>pow(self,&nbsp;r) <td>__pow__ <td>pow(x,&nbsp;y)
<tr><td>pow(l,&nbsp;self) <td>__rpow__ <td>pow(y,&nbsp;x)
</code>
</table>
<h4><a name="self_t-spec-unary-ops"></a>Class
<code>self_t</code> unary operations</h4>
<table border="1">
<tr><th>C++ Expression <th>Python Method Name <th>C++ Implementation
<code>
<tr><td>-self <td>__neg__ <td>-x
<tr><td>+self<td>__pos__ <td>+x
<tr><td>~self<td>__invert__ <td>~x
</code>
</table>
<h4><a name="self_t-spec-value-ops"></a>Class
<code>self_t</code> value operations</h4>
<table border="1">
<tr><th>C++ Expression <th>Python Method Name <th>C++ Implementation
<code>
<tr><td>int_(self)<td>__int__ <td>long(x)
<tr><td>long_<td>__long__ <td>PyLong_FromLong(x)
<tr><td>float_<td>__float__ <td>double(x)
<tr><td>complex_<td>__complex__ <td>std::complex&lt;double&gt;(x)
<tr><td>str<td>__str__ <td><a href="../../../conversion/lexical_cast.htm#lexical_cast">lexical_cast</a>&lt;std::string&gt;(x)
</code>
</table>
<h3><a name="other-spec"></a>Class Template <code>other</code></h3>
<p>Instances of <code>other&lt;T&gt;</code> can be used in
operator expressions with <a href="#self-spec">self</a>; the
result is equivalent to the same expression with a <code>T</code>
object in place of <code>other&lt;T&gt;</code>. Use
<code>other&lt;T&gt;</code> to prevent construction of a
<code>T</code> object in case it is heavyweight, when no
constructor is available, or simply for clarity.
<h4><a name="other-spec-synopsis"></a>Class Template other synopsis</h4>
<pre>
namespace boost { namespace python
{
template &lt;class T&gt;
struct other
{
};
}}
</pre>
<!-- -->
<h3><a name="operator_-spec"></a>Class Template <code>detail::operator_</code></h3>
<p>Instantiations of <code>detail::operator_&lt;&gt;</code> are
used as the return type of operator expressions involving <code><a
href="#self-spec">self</a></code>. This should be considered an
implementation detail and is only documented here as a way of
showing how the result of <code>self</code>-expressions match
calls to <a
href="class.html#class_-spec-modifiers">class_&lt;&gt;::def()</a>.
<h4><a name="operator_-spec-synopsis"></a>Class Template
<code>detail::operator_</code> synopsis</h4>
<pre>
namespace boost { namespace python { namespace detail
{
template &lt;<i>unspecified</i>&gt;
struct operator_
{
};
}}}
</pre>
<h2><a name="objects"></a>Objects</h2>
<p><a name="self-spec"><code>self</code></a>
<pre>
namespace boost { namespace python
{
extern self_ns self;
}}
</pre>
<h2><a name="examples"></a>Example</h2>
<pre>
#include &lt;boost/python/module.hpp&gt;
#include &lt;boost/python/class.hpp&gt;
#include &lt;boost/python/operators.hpp&gt;
#include &lt;boost/operators.hpp&gt;
struct number
: boost::<a href="../../../utility/operators.htm#grpd_oprs">integer_arithmetic</a>&lt;number&gt;
{
number(long x_) : x(x_) {}
operator long() const { return x; }
number&amp; operator+=(number const&amp; rhs)
{ x += rhs }
number&amp; operator-=(number const&amp; rhs);
{ x -= rhs }
number&amp; operator*=(number const&amp; rhs)
{ x *= rhs }
number&amp; operator/=(number const&amp; rhs);
{ x /= rhs }
number&amp; operator%=(number const&amp; rhs);
{ x %= rhs }
long x;
};
using namespace boost::python;
BOOST_PYTHON_MODULE_INIT(demo)
{
module(&quot;demo&quot;)
.add(
class_&lt;number&gt;(&quot;number&quot;)
// interoperate with self
.def(self += self)
.def(self + self)
.def(self -= self)
.def(self - self)
.def(self *= self)
.def(self * self)
.def(self /= self)
.def(self / self)
.def(self %= self)
.def(self % self)
// Convert to Python int
.def(int_(self))
// interoperate with long
.def(self += long())
.def(self + long())
.def(long() + self)
.def(self -= long())
.def(self - long())
.def(long() - self)
.def(self *= long())
.def(self * long())
.def(long() * self)
.def(self /= long())
.def(self / long())
.def(long() / self)
.def(self %= long())
.def(self % long())
.def(long() % self)
)
;
}
</pre>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
3 June, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave
Abrahams</a> 2002. All Rights Reserved.</i>

View File

@@ -9,7 +9,8 @@
"header">
<tr>
<td valign="top" width="300">
<h3><a href="http://www.boost.org"><img height="86" width="277" alt="C++ Boost" src="../c++boost.gif" border="0"></a></h3>
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>

View File

@@ -0,0 +1,44 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../boost.css">
<title>Boost.Python - Progress Reports</title>
</head>
<body link="#0000ff" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>
<h2 align="center">Progress Reports</h2>
</td>
</tr>
</table>
<hr>
Monthly progress reports are required as part of Boost Consulting's
contract with LLNL for Boost.Python development. These reports contain
a useful record of the project history, including the rationale for
design decisions and links to relevant discussions.
<dl class="page-index">
<dt><a href="feb2002.html">February 2002</a></dt>
<dt><a href="Mar2002.html">March 2002</a></dt>
<dt><a href="Apr2002.html">April 2002</a></dt>
<dt><a href="May2002.html">May 2002</a></dt>
<dt><a href="Jun2002.html">June 2002</a></dt>
</dl>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
18 July, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave Abrahams</a>
2002. All Rights Reserved.</i></p>
</body>
</html>

View File

@@ -93,11 +93,11 @@
which can be similarly used to prevent copying of referents.
<p><code>ptr(p)</code> returns an instance of <code><a
href="#pointer_wrapper">pointer_wrapper&lt;&gt;</a></code>, which
href="#pointer_wrapper-spec">pointer_wrapper&lt;&gt;</a></code>, which
can be detected using the <code><a
href="#pointer_wrapper">is_pointer_wrapper&lt;&gt;</a></code>
href="#is_pointer_wrapper-spec">is_pointer_wrapper&lt;&gt;</a></code>
metafunction; <code><a
href="#pointer_wrapper">unwrap_pointer&lt;&gt;</a></code> is a
href="#unwrap_pointer-spec">unwrap_pointer&lt;&gt;</a></code> is a
metafunction which extracts the original pointer type from a
<code>pointer_wrapper&lt;&gt;</code>. These classes can be thought
of as implementation details.
@@ -252,7 +252,7 @@ void pass_as_arg(expensive_to_copy* x, PyObject* f)
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
07 May, 2002
29 May, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->

View File

@@ -9,7 +9,8 @@
"header">
<tr>
<td valign="top" width="300">
<h3><a href="http://www.boost.org"><img height="86" width="277" alt="C++ Boost" src="../c++boost.gif" border="0"></a></h3>
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>

View File

@@ -1,191 +1,280 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content=
"text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../boost.css">
<title>Boost.Python - Reference</title>
<style type="text/css">
p.c3 {font-style: italic}
h2.c2 {text-align: center}
h1.c1 {text-align: center}
</style>
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"reference">
<table border="0" cellpadding="7" cellspacing="0" width="100%"
summary="reference">
<tr>
<td valign="top" width="300">
<h3><a href="http://www.boost.org"><img height="86" width="277" alt=
"C++ Boost" src="../c++boost.gif" border="0"></a></h3>
<h3><a href="http://www.boost.org"><img height="86" width=
"277" alt="C++ Boost" src="../../../../c++boost.gif" border=
"0"></a></h3>
<td valign="top">
<h1 align="center">Boost.Python</h1>
<h1 class="c1">Boost.Python</h1>
<h2 align="center">Reference</h2>
<h2 class="c2">Reference</h2>
</table>
<hr>
<h2>Contents</h2>
<dl class="Reference">
<dt><a href="#concepts">Concepts</a>
<dt><a href="#high_level">High Level Components</a>
<dt><a href="#models_of_call_policies">Models of CallPolicies</a>
<dt><a href="#invocation">Function Invocation and Creation</a>
<dt><a href="#return_handler_generators">Models of ReturnHandlerGenerator</a>
<dd>
<dl class="index">
<dt><a href="#models_of_call_policies">Models of
CallPolicies</a>
<dt><a href="#models_of_result_converter">Models of
ResultConverter</a>
<dt><a href="#result_converter_generators">Models of
ResultConverterGenerator</a>
</dl>
<dt><a href="#type_conversion">To/From Python Type Conversion</a>
<dt><a href="#by_name">Index By Name</a>
<dt><a href="#utility">Utility and Infrastructure</a>
</dl>
<a name="high_level"></a>
<hr>
<!-- xxxxx -->
<h2>High Level Components</h2>
<h2><a name="concepts">Concepts</a></h2>
<dl class="index">
<dt><a href=
"CallPolicies.html#CallPolicies-concept">CallPolicies</a>
<dt><a href=
"Dereferenceable.html#Dereferenceable-concept">Dereferenceable</a>
<dt><a href=
"Dereferenceable.html#Extractor-concept">Extractor</a>
<dt><a href=
"HolderGenerator.html#HolderGenerator-concept">HolderGenerator</a>
<dt><a href=
"ResultConverter.html#ResultConverter-concept">ResultConverter</a>
<dt><a href=
"ResultConverter.html#ResultConverterGenerator-concept">ResultConverterGenerator</a>
</dl>
<h2><a name="high_level">High Level Components</a></h2>
<dl>
<dt><a href="class.html">class.hpp/class_fwd.hpp</a>
<dd>
<a name="general_purpose"></a>
<h3>General Purpose</h3>
<dl class="index">
<dt><a href="call.html">call.hpp</a>
<dd>
<dl class="index">
<dt><a href="call.html#functions">Functions</a>
<dd>
<dl class="index">
<dt><a href=
"call.html#call-spec">call</a>
</dl>
</dl>
<dt><a href="call_method.html">call_method.hpp</a>
<dd>
<dl class="index">
<dt><a href="call_method.html#functions">Functions</a>
<dd>
<dl class="index">
<dt><a href=
"call_method.html#call_method-spec">call_method</a>
</dl>
</dl>
<dt><a href="class.html">class.hpp/class_fwd.hpp</a>
<dt><a href="class.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href="class.html#classes">Classes</a>
<dt><a href="class.html#class_-spec">class_</a>
<dd>
<dl class="index">
<dt><a href="class.html#class_-spec">class_</a>
<dt><a href="class.html#bases-spec">bases</a>
<dt><a href="class.html#bases-spec">bases</a>
<dt><a href="class.html#args-spec">args</a>
</dl>
</dl>
<dt><a href="data_members.html">data_members.hpp</a>
<dd>
<dl class="index">
<dt><a href="data_members.html#functions">Functions</a>
<dd>
<dl class="index">
<dt><a href=
"data_members.html#make_getter-spec">make_getter</a>
<dt><a href=
"data_members.html#make_setter-spec">make_setter</a>
</dl>
</dl>
<dt><a href="errors.html">errors.hpp</a>
<dd>
<dl class="index">
<dt><a href="errors.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"errors.html#error_already_set-spec">error_already_set</a>
</dl>
<dt><a href="errors.html#functions">Functions</a>
<dd>
<dl class="index">
<dt><a href=
"errors.html#handle_exception-spec">handle_exception</a>
<dt><a href=
"errors.html#expect_non_null-spec">expect_non_null</a>
</dl>
</dl>
<dt><a href="make_function.html">make_function.hpp</a>
<dd>
<dl class="index">
<dt><a href="make_function.html#classes">Functions</a>
<dd>
<dl class="index">
<dt><a href=
"make_function.html#make_function-spec">make_function</a>
<dt><a href=
"make_.html#make_constructor-spec">make_constructor</a>
</dl>
</dl>
<dt><a href="module.html">module.hpp</a>
<dd>
<dl class="index">
<dt><a href="module.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href="module.html#module-spec">module</a>
</dl>
</dl>
<dt><a href="objects.html">objects.hpp</a>
<dd>
<dl class="index">
<dt><a href="objects.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href="objects.html#xxx-spec">not yet documented</a>
</dl>
</dl>
<dt><a href="reference_hpp.html">reference.hpp</a>
<dd>
<dl class="index">
<dt><a href="reference_hpp.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href="reference_hpp.html#reference-spec">reference</a>
</dl>
<dt><a href="reference_hpp.html#types">Types</a>
<dd>
<dl class="index">
<dt><a href="reference_hpp.html#ref-spec">ref</a>
</dl>
<dt><a href="class.html#args-spec">args</a>
</dl>
</dl>
<dt><a href="errors.html">errors.hpp</a>
<a name="models_of_call_policies"></a>
<dd>
<dl class="index">
<dt><a href="errors.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"errors.html#error_already_set-spec">error_already_set</a>
</dl>
<dt><a href="errors.html#functions">Functions</a>
<dd>
<dl class="index">
<dt><a href=
"errors.html#handle_exception-spec">handle_exception</a>
<dt><a href=
"errors.html#expect_non_null-spec">expect_non_null</a>
</dl>
</dl>
<dt><a href="iterator.html">iterator.hpp</a>
<dd>
<dl class="index">
<dt><a href="iterator.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href="iterator.html#iterator-spec">iterator</a>
<dt><a href="iterator.html#iterators-spec">iterators</a>
</dl>
<dt><a href="iterator.html#functions">Functions</a>
<dd>
<dl class="index">
<dt><a href="iterator.html#range-spec">range</a>
</dl>
</dl>
<dt><a href="module.html">module.hpp</a>
<dd>
<dl class="index">
<dt><a href="module.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href="module.html#module-spec">module</a>
</dl>
</dl>
<dt><a href="objects.html">objects.hpp</a>
<dd>
<dl class="index">
<dt><a href="objects.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href="objects.html#xxx-spec">not yet
documented</a>
</dl>
</dl>
<dt><a href="operators.html">operators.hpp</a>
<dd>
<dl class="index">
<dt><a href="operators.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href="operators.html#self_t-spec">self_t</a>
<dt><a href="operators.html#other-spec">other</a>
<dt><a href="operators.html#operator_-spec">operator_</a>
</dl>
<dt><a href="operators.html#functions">Objects</a>
<dd>
<dl class="index">
<dt><a href="operators.html#self-spec">self</a>
</dl>
</dl>
</dl>
<h2><a name="invocation">Function Invocation and Creation</a></h2>
<dl class="index">
<dt><a href="call.html">call.hpp</a>
<dd>
<dl class="index">
<dt><a href="call.html#functions">Functions</a>
<dd>
<dl class="index">
<dt><a href="call.html#call-spec">call</a>
</dl>
</dl>
<dt><a href="call_method.html">call_method.hpp</a>
<dd>
<dl class="index">
<dt><a href="call_method.html#functions">Functions</a>
<dd>
<dl class="index">
<dt><a href=
"call_method.html#call_method-spec">call_method</a>
</dl>
</dl>
<dt><a href="data_members.html">data_members.hpp</a>
<dd>
<dl class="index">
<dt><a href="data_members.html#functions">Functions</a>
<dd>
<dl class="index">
<dt><a href=
"data_members.html#make_getter-spec">make_getter</a>
<dt><a href=
"data_members.html#make_setter-spec">make_setter</a>
</dl>
</dl>
<dt><a href="make_function.html">make_function.hpp</a>
<dd>
<dl class="index">
<dt><a href="make_function.html#classes">Functions</a>
<dd>
<dl class="index">
<dt><a href=
"make_function.html#make_function-spec">make_function</a>
<dt><a href=
"make_function.html#make_constructor-spec">make_constructor</a>
</dl>
</dl>
<dt><a href="ptr.html">ptr.hpp</a>
<dd>
<dl class="index">
<dt><a href="ptr.html#functions">Functions</a>
<dd>
<dl class="index">
<dt><a href="ptr.html#ptr-spec">ptr</a>
</dl>
<dt><a href="ptr.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"ptr.html#pointer_wrapper-spec">pointer_wrapper</a>
</dl>
<dt><a href="ptr.html#metafunctions">MetaFunctions</a>
<dd>
<dl class="index">
<dt><a href=
"ptr.html#is_pointer_wrapper-spec">is_pointer_wrapper</a>
<dt><a href=
"ptr.html#unwrap_pointer-spec">unwrap_pointer</a>
</dl>
</dl>
<a name="models_of_call_policies"></a>
<h3>Models of CallPolicies</h3>
@@ -195,15 +284,18 @@
<dd>
<dl class="index">
<dt><a href="default_call_policies.html#classes">Classes</a>
<dt><a href=
"default_call_policies.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"default_call_policies.html#default_call_policies-spec">default_call_policies</a>
<dt><a href=
"default_call_policies.html#default_call_policies-spec">
default_call_policies</a>
<dt><a href=
"default_call_policies.html#default_result_converter-spec">default_result_converter</a>
<dt><a href=
"default_call_policies.html#default_result_converter-spec">
default_result_converter</a>
</dl>
</dl>
@@ -212,25 +304,28 @@
<dd>
<dl class="index">
<dt><a href="return_internal_reference.html#classes">Classes</a>
<dt><a href=
"return_internal_reference.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
<dt><a href=
"return_internal_reference.html#return_internal_reference-spec">
return_internal_reference</a>
</dl>
</dl>
<dt><a href="return_value_policy.html">return_value_policy.hpp</a>
<dt><a href=
"return_value_policy.html">return_value_policy.hpp</a>
<dd>
<dl class="index">
<dt><a href="return_value_policy.html#classes">Classes</a>
<dt><a href=
"return_value_policy.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
<dt><a href=
"return_value_policy.html#return_value_policy-spec">return_value_policy</a>
</dl>
</dl>
@@ -240,179 +335,28 @@
<dd>
<dl class="index">
<dt><a href="with_custodian_and_ward.html#classes">Classes</a>
<dt><a href=
"with_custodian_and_ward.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"with_custodian_and_ward.html#with_custodian_and_ward-spec">with_custodian_and_ward</a>
<dt><a href=
"with_custodian_and_ward.html#with_custodian_and_ward-spec">
with_custodian_and_ward</a>
<dt><a href=
<dt><a href=
"with_custodian_and_ward.html#with_custodian_and_ward_postcall-spec">
with_custodian_and_ward_postcall</a>
</dl>
</dl>
</dl>
<a name="return_handler_generators"></a>
<a name="models_of_result_converter"></a>
<h3>Models of ReturnHandlerGenerator</h3>
<h3>Models of ResultConverter</h3>
<dl class="index">
<dt><a href="copy_const_reference.html">copy_const_reference.hpp</a>
<dd>
<dl class="index">
<dt><a href="copy_const_reference.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"copy_const_reference.html#copy_const_reference-spec">copy_const_reference</a>
</dl>
</dl>
<dt><a href=
"copy_non_const_reference.html">copy_non_const_reference.hpp</a>
<dd>
<dl class="index">
<dt><a href="copy_non_const_reference.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"copy_non_const_reference.html#copy_non_const_reference-spec">
copy_non_const_reference</a>
</dl>
</dl>
<dt><a href="manage_new_object.html">manage_new_object.hpp</a>
<dd>
<dl class="index">
<dt><a href="manage_new_object.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"manage_new_object.html#manage_new_object-spec">manage_new_object</a>
</dl>
</dl>
<dt><a href=
"reference_existing_object.html">reference_existing_object.hpp</a>
<dd>
<dl class="index">
<dt><a href="reference_existing_object.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"reference_existing_object.html#reference_existing_object-spec">
reference_existing_object</a>
</dl>
</dl>
<dt><a href=
"lvalue_from_python.html">reference_from_python.hpp</a>
<dd>
<dl class="index">
<dt><a href="lvalue_from_python.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"lvalue_from_python.html#reference_from_python-spec">reference_from_python</a>
<dt><a href=
"lvalue_from_python.html#get_member-spec">get_member</a>
</dl>
</dl>
</dl>
<a name="type_conversion"></a>
<h3>To/From Python Type Conversion</h3>
<dl class="index">
<dt><a href="from_python.html">from_python.hpp</a>
<dd>
<dl class="index">
<dt><a href="from_python.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"from_python.html#from_python-spec">from_python</a>
</dl>
</dl>
<dt><a href="has_back_reference.html">has_back_reference.hpp</a>
<dd>
<dl class="index">
<dt><a href="has_back_reference.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href="has_back_reference.html#has_back_reference-spec">has_back_reference</a>
</dl>
</dl>
<dt><a href="implicit.html">implicit.hpp</a>
<dd>
<dl class="index">
<dt><a href="implicit.html#functions">Functions</a>
<dd>
<dl class="index">
<dt><a href=
"implicit.html#implicitly_convertible-spec">implicitly_convertible</a>
</dl>
</dl>
<dt><a href="ptr.html">ptr.hpp</a>
<dd>
<dl class="index">
<dt><a href="ptr.html#functions">Functions</a>
<dd>
<dl class="index">
<dt><a href="ptr.html#ptr-spec">ptr</a>
</dl>
<dt><a href="ptr.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href="ptr.html#pointer_wrapper-spec">pointer_wrapper</a>
</dl>
<dt><a href="ptr.html#metafunctions">MetaFunctions</a>
<dd>
<dl class="index">
<dt><a href="ptr.html#is_pointer_wrapper-spec">is_pointer_wrapper</a>
<dt><a href="ptr.html#unwrap_pointer-spec">unwrap_pointer</a>
</dl>
</dl>
<dt><a href="to_python_converter.html">to_python_converter.hpp</a>
<dd>
<dl class="index">
<dt><a href="to_python_converter.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"to_python_converter.html#to_python_converter-spec">to_python_converter</a>
</dl>
</dl>
<dt><a href="to_python_indirect.html">to_python_indirect.hpp</a>
"to_python_indirect.html">to_python_indirect.hpp</a>
<dd>
<dl class="index">
@@ -420,7 +364,7 @@
<dd>
<dl class="index">
<dt><a href=
<dt><a href=
"to_python_indirect.html#to_python_indirect-spec">to_python_indirect</a>
</dl>
</dl>
@@ -437,43 +381,231 @@
"to_python_value.html#to_python_value-spec">to_python_value</a>
</dl>
</dl>
</dl>
<a name="result_converter_generators"></a>
<dt><a href="type_from_python.html">type_from_python.hpp</a>
<h3>Models of ResultConverterGenerator</h3>
<dl class="index">
<dt><a href=
"copy_const_reference.html">copy_const_reference.hpp</a>
<dd>
<dl class="index">
<dt><a href="type_from_python.html#classes">Classes</a>
<dt><a href=
"copy_const_reference.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"type_from_python.html#type_from_python-spec">type_from_python</a>
<dt><a href=
"copy_const_reference.html#copy_const_reference-spec">
copy_const_reference</a>
</dl>
</dl>
<dt><a href="value_from_python.html">value_from_python.hpp</a>
<dt><a href=
"copy_non_const_reference.html">copy_non_const_reference.hpp</a>
<dd>
<dl class="index">
<dt><a href="value_from_python.html#classes">Classes</a>
<dt><a href=
"copy_non_const_reference.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"value_from_python.html#value_from_python-spec">value_from_python</a>
<dt><a href=
"copy_non_const_reference.html#copy_non_const_reference-spec">
copy_non_const_reference</a>
</dl>
</dl>
<dt><a href=
"manage_new_object.html">manage_new_object.hpp</a>
<dd>
<dl class="index">
<dt><a href="manage_new_object.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"manage_new_object.html#manage_new_object-spec">manage_new_object</a>
</dl>
</dl>
<dt><a href=
"reference_existing_object.html">reference_existing_object.hpp</a>
<dd>
<dl class="index">
<dt><a href=
"reference_existing_object.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"reference_existing_object.html#reference_existing_object-spec">
reference_existing_object</a>
</dl>
</dl>
</dl>
</dl>
<h2><a name="type_conversion">To/From Python Type
Conversion</a></h2>
<dl class="index">
<dt><a href="from_python.html">from_python.hpp</a>
<dd>
<dl class="index">
<dt><a href="from_python.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"from_python.html#from_python-spec">from_python</a>
</dl>
</dl>
<dt><a href="implicit.html">implicit.hpp</a>
<dd>
<dl class="index">
<dt><a href="implicit.html#functions">Functions</a>
<dd>
<dl class="index">
<dt><a href=
"implicit.html#implicitly_convertible-spec">implicitly_convertible</a>
</dl>
</dl>
<dt><a href="lvalue_from_pytype.html">lvalue_from_pytype.hpp</a>
<dd>
<dl class="index">
<dt><a href="lvalue_from_pytype.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"lvalue_from_pytype.html#lvalue_from_pytype-spec">lvalue_from_pytype</a>
<dt><a href=
"lvalue_from_pytype.html#extract_identity-spec">extract_identity</a>
<dt><a href=
"lvalue_from_pytype.html#extract_member-spec">extract_member</a>
</dl>
</dl>
<dt><a href=
"to_python_converter.html">to_python_converter.hpp</a>
<dd>
<dl class="index">
<dt><a href="to_python_converter.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"to_python_converter.html#to_python_converter-spec">to_python_converter</a>
</dl>
</dl>
</dl>
<h2><a name="utility">Utility and Infrastructure</a></h2>
<dl>
<dt><a href="has_back_reference.html">has_back_reference.hpp</a>
<dd>
<dl class="index">
<dt><a href="has_back_reference.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"has_back_reference.html#has_back_reference-spec">has_back_reference</a>
</dl>
</dl>
<dt><a href="instance_holder.html">instance_holder.hpp</a>
<dd>
<dl class="index">
<dt><a href="instance_holder.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"instance_holder.html#instance_holder-spec">instance_holder</a>
</dl>
</dl>
<dt><a href="pointee.html">pointee.hpp</a>
<dd>
<dl class="index">
<dt><a href="pointee.html#classes">Classes</a>
<dd>
<dl class="index">
<dt>class template <a href=
"pointee.html#pointee">pointee</a>
</dl>
</dl>
<dt><a href="reference_hpp.html">reference.hpp</a>
<dd>
<dl class="index">
<dt><a href="reference_hpp.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href=
"reference_hpp.html#reference-spec">reference</a>
</dl>
<dt><a href="reference_hpp.html#types">Types</a>
<dd>
<dl class="index">
<dt><a href="reference_hpp.html#ref-spec">ref</a>
</dl>
</dl>
<dt><a href="type_id.html">type_id.hpp</a>
<dd>
<dl class="index">
<dt><a href="type_id.html#functions">Functions</a>
<dd>
<dl class="index">
<dt><a href="type_id.html#type_id-spec">type_id</a>
</dl>
<dt><a href="type_id.html#classes">Classes</a>
<dd>
<dl class="index">
<dt><a href="type_id.html#type_info-spec">type_info</a>
</dl>
</dl>
</dl>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
05 November, 2002
3 June, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave
Abrahams</a> 2002. All Rights Reserved.</i>
<p class="c3">&copy; Copyright <a href=
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002. All
Rights Reserved.

View File

@@ -51,7 +51,7 @@
<code>reference_existing_object</code></h3>
<p><code>reference_existing_object</code> is a model of <a href=
"ResultConverterGenerator.html">ResultConverterGenerator</a> which can be
"ResultConverter.html#ResultConverterGenerator-concept">ResultConverterGenerator</a> which can be
used to wrap C++ functions which return a reference or pointer to a C++
object. When the wrapped function is called, the value referenced by its
return value is not copied. A new Python object is created which contains a

View File

@@ -49,7 +49,7 @@
<code>return_value_policy</code> instantiations are simply models
of <a href=
"CallPolicies.html">CallPolicies</a> which are composed of a <a href=
"ResultConverterGenerator.html">ResultConverterGenerator</a> and optional <code>Base</code> <a href=
"ResultConverter.html#ResultConverterGenerator-concept">ResultConverterGenerator</a> and optional <code>Base</code> <a href=
"CallPolicies.html">CallPolicies</a>.
<h2><a name="classes"></a>Classes</h2>
@@ -69,7 +69,7 @@
<th>Default
<tr>
<td><code>ResultConverterGenerator</code>
<td><a href="ResultConverter.html#ResultConverterGenerator-concept">ResultConverterGenerator</a>
<td>A model of <a href=
"ResultConverterGenerator.html">ResultConverterGenerator</a>.

View File

@@ -146,7 +146,7 @@ struct tag_to_noddy
BOOST_PYTHON_MODULE_INIT(to_python_converter)
{
module to_python(&quot;to_python_converter&quot;)
module(&quot;to_python_converter&quot;)
.def(&quot;make_tag&quot;, make_tag)
;
to_python_converter&lt;tag, tag_to_noddy&gt;();

View File

@@ -107,7 +107,7 @@ of its first argument type to python as extension class instances, using the own
</table>
Instantiations of <code>to_python_indirect</code> are models of <a
href="ResultConverter.html">ResultConverter</a>.
href="ResultConverter.html#ResultConverter-concept">ResultConverter</a>.
<h4><a name="to_python_indirect-spec-synopsis"></a>Class template <code>to_python_indirect</code> synopsis</h4>
@@ -174,7 +174,7 @@ struct make_reference_holder
struct reference_existing_object
{
// metafunction returning the <a href="ResultConverter.html">ResultConverter</a>
// metafunction returning the <a href="ResultConverter.html#ResultConverter-concept">ResultConverter</a>
template &lt;class T&gt;
struct apply
{

101
doc/v2/to_python_value.html Normal file
View File

@@ -0,0 +1,101 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../boost.css">
<title>Boost.Python - &lt;boost/python/to_python_value.hpp&gt;</title>
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
<td valign="top">
<h1 align="center">Boost.Python</h1>
<h2 align="center">Header
&lt;boost/python/to_python_value.hpp&gt;</h2>
</table>
<hr>
<h2>Contents</h2>
<dl class="page-index">
<dt><a href="#classes">Classes</a>
<dd>
<dl class="page-index">
<dt><a href="#to_python_value-spec">Class
<code>to_python_value</code></a>
<dd>
<dl class="page-index">
<dt><a href="#to_python_value-spec-synopsis">Class template
<code>to_python_value</code> synopsis</a>
<dt><a href="#to_python_value-spec-observers">Class template
<code>to_python_value</code> observer functions</a>
</dl>
</dl>
</dl>
<hr>
<h2><a name="classes"></a>Classes</h2>
<h3><a name="to_python_value-spec"></a>Class template
<code>to_python_value</code></h3>
<p><code>to_python_value</code> is a model of <a href=
"ResultConverter.html#ResultConverter-concept">ResultConverter</a>
which copies its argument into a new Python object.
<h4><a name="to_python_value-spec-synopsis"></a>Class
<code>to_python_value</code> synopsis</h4>
<pre>
namespace boost { namespace python
{
template &lt;class T&gt;
struct to_python_value
{
typedef typename <a href="../../../type_traits/index.htm#transformations">add_reference</a>&lt;
typename <a href="../../../type_traits/index.htm#transformations">add_const</a>&lt;T&gt;::type
&gt;::type argument_type;
static bool convertible();
PyObject* operator()(argument_type) const;
};
}}
</pre>
<h4><a name="to_python_value-spec-observers"></a>Class
<code>to_python_value</code> observers</h4>
<pre>
static bool convertible();
</pre>
<dl class="function-semantics">
<dt><b>Returns:</b> <code>true</code> iff a converter has been registered which can convert <code>T</code> to python by-value.
</dl>
<pre>
PyObject* operator()(argument_type x) const;
</pre>
<dl class="function-semantics">
<dt><b>Requires:</b> <code>convertible()&nbsp;==&nbsp;true</code>
<dt><b>Effects:</b> converts <code>x</code> to python
<dt><b>Returns:</b> the resulting Python object iff a converter for <code>T</code> has been registered, <code>0</code> otherwise.
</dl>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
15 February, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave
Abrahams</a> 2002. All Rights Reserved.</i>

219
doc/v2/type_id.html Executable file
View File

@@ -0,0 +1,219 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content=
"text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../boost.css">
<title>Boost.Python - &lt;boost/python/type_id.hpp&gt;</title>
<style type="text/css">
p.c4 {font-style: italic}
span.c3 {color: #ff0000}
h2.c2 {text-align: center}
h1.c1 {text-align: center}
</style>
<table border="0" cellpadding="7" cellspacing="0" width="100%"
summary="header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width=
"277" alt="C++ Boost" src="../../../../c++boost.gif" border=
"0"></a></h3>
<td valign="top">
<h1 class="c1">Boost.Python</h1>
<h2 class="c2">Header &lt;boost/python/type_id.hpp&gt;</h2>
</table>
<hr>
<h2>Contents</h2>
<dl class="page-index">
<dt><a href="#introduction">Introduction</a>
<dt><a href="#classes">Classes</a>
<dd>
<dl class="page-index">
<dt><a href="#type_info-spec">Class
<code>type_info</code></a>
<dd>
<dl class="page-index">
<dt><a href="#type_info-spec-synopsis">Class
<code>type_info</code> synopsis</a>
<dt><a href="#type_infospec-ctors">Class
<code>type_info</code> constructor</a>
<dt><a href="#type_infospec-comparisons">Class
<code>type_info</code> comparison functions</a>
<dt><a href="#type_infospec-observers">Class
<code>type_info</code> observer functions</a>
</dl>
</dl>
<dt><a href="#functions">Functions</a>
<dd>
<dl class="page-index">
<dt><a href="#type_id-spec">type_id</a>
</dl>
<dt><a href="#examples">Example</a>
</dl>
<hr>
<h2><a name="introduction"></a>Introduction</h2>
<p><code>&lt;boost/python/type_id.hpp&gt;</code> provides types and
functions for runtime type identification like those of of
<code>&lt;typeinfo&gt;</code>. It exists mostly to work around
certain compiler bugs and platform-dependent interactions with
shared libraries.
<h2><a name="classes"></a>Classes</h2>
<h3><a name="type_info-spec"></a>Class <code>type_info</code></h3>
<p><code>type_info</code> instances identify a type. As
<code>std::type_info</code> is specified to (but unlike its
implementation in some compilers),
<code>boost::python::type_info</code> never represents top-level
references or cv-qualification (see section 5.2.8 in the C++
standard). Unlike <code>std::type_info</code>,
<code>boost::python::type_info</code> instances are copyable, and
comparisons always work reliably across shared library boundaries.
<h4><a name="type_info-spec-synopsis"></a>Class type_info
synopsis</h4>
<pre>
namespace boost { namespace python
{
class type_info : <a href=
"../../../utility/operators.htm#totally_ordered1">totally_ordered</a>&lt;type_info&gt;
{
public:
// constructor
type_info(std::type_info const&amp; = typeid(void));
// comparisons
bool operator&lt;(type_info const&amp; rhs) const;
bool operator==(type_info const&amp; rhs) const;
// observers
char const* name() const;
};
}}
</pre>
<h4><a name="type_infospec-ctors">Class <code>type_info</code>
constructor</a></h4>
<pre>
type_info(std::type_info const&amp; = typeid(void));
</pre>
<dl class="function-semantics">
<dt><b>Effects:</b> constructs a <code>type_info</code> object
which identifies the same type as its argument.
<dt><b>Rationale:</b> Since it is occasionally neccessary to make
an array of <code>type_info</code> objects a benign default
argument is supplied. <span class="c3"><b>Note:</b></span> this
constructor does <i>not</i> correct for non-conformance of
compiler <code>typeid()</code> implementations. See <code><a
href="#type_id-spec">type_id</a></code>, below.
</dl>
<h4><a name="type_infospec-comparisons">Class
<code>type_info</code> comparisons</a></h4>
<pre>
bool operator&lt;(type_info const&amp; rhs) const;
</pre>
<dl class="function-semantics">
<dt><b>Effects:</b> yields a total order over
<code>type_info</code> objects.
</dl>
<pre>
bool operator==(type_info const&amp; rhs) const;
</pre>
<dl class="function-semantics">
<dt><b>Returns:</b> <code>true</code> iff the two values describe
the same type.
</dl>
<dl class="function-semantics">
<dt><b>Note:</b> The use of <code><a href=
"../../../utility/operators.htm#totally_ordered1">totally_ordered</a>&lt;type_info&gt;</code>
as a private base class supplies operators <code>&lt;=</code>,
<code>&gt;=</code>, <code>&gt;</code>, and <code>!=</code>
</dl>
<h4><a name="type_infospec-observers">Class <code>type_info</code>
observers</a></h4>
<pre>
char const* name() const;
</pre>
<dl class="function-semantics">
<dt><b>Returns:</b> The result of calling <code>name()</code> on
the argument used to construct the object.
</dl>
<h2><a name="functions"></a>Functions</h2>
<pre>
std::ostream&amp; operator&lt;&lt;(std::ostream&amp;s, type_info const&amp;x);
</pre>
<dl class="function-semantics">
<dt><b>Effects:</b> Writes a description of the type described by
to <code>x</code> into <code>s</code>.
<dt><b>Rationale:</b> Not every C++ implementation provides a
truly human-readable <code>type_info::name()</code> string, but
for some we may be able to decode the string and produce a
reasonable representation.
</dl>
<pre>
<a name="type_id-spec">template &lt;class T&gt; type_info type_id</a>()
</pre>
<dl class="function-semantics">
<dt><b>Returns:</b> <code>type_info(typeid(T))</code>
<dt><b>Note:</b> On some non-conforming C++ implementations, the
code is not actually as simple as described above; the semantics
are adjusted to work <i>as-if</i> the C++ implementation were
conforming.
</dl>
<h2><a name="examples"></a>Example</h2>
The following example, though silly, illustrates how the
<code>type_id</code> facility might be used
<pre>
#include &lt;boost/python/type_id.hpp&gt;
// Returns true iff the user passes an int argument
template &lt;class T&gt;
bool is_int(T x)
{
using boost::python::type_id;
return type_id&lt;T&gt;() == type_id&lt;int&gt;();
}
</pre>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
18 November, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
<p class="c4">&copy; Copyright <a href=
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002. All
Rights Reserved.

View File

@@ -0,0 +1,289 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../boost.css">
<title>Boost.Python - &lt;boost/python/with_custodian_and_ward.hpp&gt;</title>
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
<td valign="top">
<h1 align="center">Boost.Python</h1>
<h2 align="center">Header &lt;boost/python/with_custodian_and_ward.hpp&gt;</h2>
</table>
<hr>
<h2>Contents</h2>
<dl class="page-index">
<dt><a href="#introduction">Introduction</a>
<dt><a href="#classes">Classes</a>
<dd>
<dl class="page-index">
<dt><a href="#with_custodian_and_ward-spec">Class Template <code>with_custodian_and_ward</code></a>
<dd>
<dl class="page-index">
<dt><a href="#with_custodian_and_ward-spec-synopsis">Class Template
<code>with_custodian_and_ward</code> synopsis</a>
<dt><a href="#with_custodian_and_ward-spec-statics">Class
<code>with_custodian_and_ward</code> static functions</a>
</dl>
<dt><a href="#with_custodian_and_ward_postcall-spec">Class Template <code>with_custodian_and_ward_postcall</code></a>
<dd>
<dl class="page-index">
<dt><a href="#with_custodian_and_ward_postcall-spec-synopsis">Class Template
<code>with_custodian_and_ward_postcall</code> synopsis</a>
<dt><a href="#with_custodian_and_ward_postcall-spec-statics">Class
<code>with_custodian_and_ward_postcall</code> static functions</a>
</dl>
</dl>
<dt><a href="#examples">Example</a>
</dl>
<hr>
<h2><a name="introduction">Introduction</a></h2>
This header provides faciliites for establishing a lifetime
dependency between two of a function's Python argument or result
objects. The <i>ward</i> object will not be destroyed until after
the custodian as long as the <i>custodian</i> object supports <a
href="http://www.python.org/doc/current/lib/module-weakref.html">weak
references</a> (Boost.Python extension classes all support weak
references). The two class templates
<code>with_custodian_and_ward</code> and
<code>with_custodian_and_ward_postcall</code> differ in the point
at which they take effect.
<p>In order to reduce the chance of inadvertently
creating dangling pointers, the default is to do lifetime binding
<i>before</i> the underlying C++ object is invoked. However,
before invocation the result object is not available, so
<code>with_custodian_and_ward_postcall</code> is provided to bind
lifetimes after invocation. Also, if a C++ exception is thrown
after <code>with_custodian_and_ward&lt;&gt;::precall</code> but
before the underlying C++ object actually stores a pointer, the
lifetime of the custodian and ward objects will be artificially
bound together, so one might choose
<code>with_custodian_and_ward_postcall</code> instead, depending
on the semantics of the function being wrapped.
<h2><a name="classes"></a>Classes</h2>
<h3><a name="with_custodian_and_ward-spec"></a>Class template <code>with_custodian_and_ward</code></h3>
<table border="1" summary="with_custodian_and_ward template parameters">
<caption>
<b><code>with_custodian_and_ward</code> template parameters</b>
</caption>
<tr>
<th>Parameter
<th>Requirements
<th>Description
<th>Default
<tr>
<td><code>custodian</code>
<td>A positive compile-time constant of type
<code>std::size_t</code>.
<td>The 1-based index of the parameter which is the dependency in the
lifetime relationship to be established. If used to
wrap a member function, parameter 1 is the target object
(<code>*this</code>). Note that if the target Python object
type doesn't support weak references, a Python
<code>TypeError</code> exception will be raised when the
C++ object being wrapped is called.
<tr>
<td><code>ward</code>
<td>A positive compile-time constant of type
<code>std::size_t</code>.
<td>The 1-based index of the parameter which is the dependent in the
lifetime relationship to be established. If used to
wrap a member function, parameter 1 is the target object
(<code>*this</code>).
<tr>
<td><code>Base</code>
<td>A model of <a href="CallPolicies.html">CallPolicies</a>
<td>Used for <a href="CallPolicies.html#composition">policy composition</a>.
<td><code><a href="default_call_policies.html#default_call_policies-spec">default_call_policies</a></code>
</table>
<h4><a name="with_custodian_and_ward-spec-synopsis"></a>Class template <code>with_custodian_and_ward</code> synopsis</h4>
<pre>
namespace boost { namespace python
{
template &lt;std::size_t custodian, std::size_t ward, class Base = default_call_policies&gt;
struct with_custodian_and_ward : Base
{
static bool precall(PyObject* args);
};
}}
</pre>
<h4><a name="with_custodian_and_ward-spec-statics"></a>Class
<code>with_custodian_and_ward</code> static functions</h4>
<pre>
bool precall(PyObject* args);
</pre>
<dl class="function-semantics">
<dt><b>Requires:</b> <code><a href="http://www.python.org/doc/2.2/api/tupleObjects.html#l2h-476">PyTuple_Check</a>(args) != 0</code>
<dt><b>Effects:</b> Makes the lifetime of the argument indicated
by <code>ward</code> dependent on the lifetime of the argument
indicated by <code>custodian</code>.
<dt><b>Returns:</b> <code>false</code> and <code><a
href="http://www.python.org/doc/2.2/api/exceptionHandling.html#l2h-71">PyErr_Occurred</a>()&nbsp;!=&nbsp;0</code>
upon failure, <code>true</code> otherwise.
</dl>
<!-- xxxxxx -->
<h3><a name="with_custodian_and_ward_postcall-spec"></a>Class template <code>with_custodian_and_ward_postcall</code></h3>
<table border="1" summary="with_custodian_and_ward_postcall template parameters">
<caption>
<b><code>with_custodian_and_ward_postcall</code> template parameters</b>
</caption>
<tr>
<th>Parameter
<th>Requirements
<th>Description
<th>Default
<tr>
<td><code>custodian</code>
<td>A compile-time constant of type
<code>std::size_t</code>.
<td>The index of the parameter which is the dependency in the
lifetime relationship to be established. Zero indicates the
result object; 1 indicates the first argument. If used to wrap
a member function, parameter 1 is the target object
(<code>*this</code>). Note that if the target Python object
type doesn't support weak references, a Python
<code>TypeError</code> exception will be raised when the
C++ object being wrapped is called.
<tr>
<td><code>ward</code>
<td>A compile-time constant of type <code>std::size_t</code>.
<td>The index of the parameter which is the dependent in the
lifetime relationship to be established. Zero indicates the
result object; 1 indicates the first argument. If used to wrap
a member function, parameter 1 is the target object
(<code>*this</code>).
<tr>
<td><code>Base</code>
<td>A model of <a href="CallPolicies.html">CallPolicies</a>
<td>Used for <a href="CallPolicies.html#composition">policy
composition</a>.
<td><code><a href="default_call_policies.html#default_call_policies-spec">default_call_policies</a></code>
</table>
<h4><a name="with_custodian_and_ward_postcall-spec-synopsis"></a>Class template <code>with_custodian_and_ward_postcall</code> synopsis</h4>
<pre>
namespace boost { namespace python
{
template &lt;std::size_t custodian, std::size_t ward, class Base = default_call_policies&gt;
struct with_custodian_and_ward_postcall : Base
{
static PyObject* postcall(PyObject* args, PyObject* result);
};
}}
</pre>
<h4><a name="with_custodian_and_ward_postcall-spec-statics"></a>Class
<code>with_custodian_and_ward_postcall</code> static functions</h4>
<pre>
PyObject* postcall(PyObject* args, PyObject* result);
</pre>
<dl class="function-semantics">
<dt><b>Requires:</b> <code><a
href="http://www.python.org/doc/2.2/api/tupleObjects.html#l2h-476">PyTuple_Check</a>(args)
!= 0</code>, <code>result&nbsp;!=&nbsp;0</code>.
<dt><b>Effects:</b> Makes the lifetime of the object indicated
by <code>ward</code> dependent on the lifetime of the object
indicated by <code>custodian</code>.
<dt><b>Returns:</b> <code>0</code> and <code><a
href="http://www.python.org/doc/2.2/api/exceptionHandling.html#l2h-71">PyErr_Occurred</a>()&nbsp;!=&nbsp;0</code>
upon failure, <code>true</code> otherwise.
</dl>
<h2><a name="examples"></a>Example</h2>
The following example shows how
<code>with_custodian_and_ward_postcall</code> is used by the library
to implement <code><a
href="return_internal_reference.html#return_internal_reference-spec">return_internal_reference</a></code>
<pre>
template &lt;std::size_t owner_arg = 1, class Base = default_call_policies&gt;
struct return_internal_reference
: with_custodian_and_ward_postcall&lt;0, owner_arg, Base&gt;
{
typedef <a href="reference_existing_object.html#reference_existing_object-spec">reference_existing_object</a> result_converter;
};
</pre>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
29 May, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave
Abrahams</a> 2002. All Rights Reserved.</i>

BIN
example/Attic/project.zip Normal file

Binary file not shown.

39
example/Jamfile Normal file
View File

@@ -0,0 +1,39 @@
# Specify our location in the boost project hierarchy
subproject libs/python/example ;
# Declares the following targets:
#
# 1. an extension module called "getting_started1", which is
# built from "getting_started1.cpp". Built by default
#
# 2. A test target called my-test.test which runs
# test_getting_started1.py with the extension module above. Built
# when out-of date, but only if invoked by name or if the global
# "test" target is invoked.
#
# 3. A test target called my-test.run wihch runs the above test
# unconditionally. Built only when invoked by name.
#
# To see verbose test output, add "-sPYTHON_TEST_ARGS=-v" to the bjam
# command-line before the first target.
#
# Include definitions needed for Python modules
SEARCH on python.jam = $(BOOST_BUILD_PATH) ;
include python.jam ;
# Declare a Python extension called getting_started1
extension getting_started1
: # sources
getting_started1.cpp
# dependencies
<dll>../build/boost_python
;
# Declare a test for the extension module
boost-python-runtest my-test
: # Python test driver
test_getting_started1.py
# extension modules to use
<pyd>getting_started1 ;

View File

@@ -19,6 +19,3 @@ Examples for the cross-module support are provided by:
ivect.cpp
See also: libs/python/doc/cross_module.html
The files example1.cpp and rwgk1.cpp are obsolete. They are only
included because the Visual Studio project in the build directory still
refers to them.

View File

@@ -1,43 +0,0 @@
#include <string.h>
namespace hello {
class world
{
public:
world(int) {}
~world() {}
const char* get() const { return "hi, world"; }
};
size_t length(const world& x) { return strlen(x.get()); }
}
#include <boost/python/class_builder.hpp>
// Python requires an exported function called init<module-name> in every
// extension module. This is where we build the module contents.
BOOST_PYTHON_MODULE_INIT(hello)
{
// create an object representing this extension module
boost::python::module_builder hello("hello");
// Create the Python type object for our extension class
boost::python::class_builder<hello::world> world_class(hello, "world");
// Add the __init__ function
world_class.def(boost::python::constructor<int>());
// Add a regular member function
world_class.def(&hello::world::get, "get");
// Add a regular function to the module
hello.def(hello::length, "length");
}
// Win32 DLL boilerplate
#if defined(_WIN32)
#include <windows.h>
extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID)
{
return 1;
}
#endif // _WIN32

BIN
example/project.zip Normal file

Binary file not shown.

View File

@@ -1,24 +0,0 @@
#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.
BOOST_PYTHON_MODULE_INIT(rwgk1)
{
// Create an object representing this extension module.
python::module_builder this_module("rwgk1");
// Add regular functions to the module.
this_module.def(greet, "greet");
this_module.def(square, "square");
}

View File

@@ -3,34 +3,37 @@
// 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_DWA2002128_HPP
# define FROM_PYTHON_DWA2002128_HPP
#ifndef ARG_FROM_PYTHON_DWA2002128_HPP
# define ARG_FROM_PYTHON_DWA2002128_HPP
# include <boost/python/converter/from_python.hpp>
# include <boost/python/converter/arg_from_python.hpp>
namespace boost { namespace python {
template <class T>
struct from_python
: converter::select_from_python<T>::type
struct arg_from_python
: converter::select_arg_from_python<T>::type
{
typedef typename converter::select_from_python<T>::type base;
from_python(PyObject*);
typedef typename converter::select_arg_from_python<T>::type base;
arg_from_python(PyObject*);
};
// specialization for PyObject*
template <>
struct from_python<PyObject*>
struct arg_from_python<PyObject*>
{
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 from_python<PyObject* const&>
struct arg_from_python<PyObject* const&>
{
from_python(PyObject*) {}
typedef PyObject* const& result_type;
arg_from_python(PyObject*) {}
bool convertible() const { return true; }
PyObject*const& operator()(PyObject*const& source) const { return source; }
};
@@ -39,11 +42,11 @@ struct from_python<PyObject* const&>
// implementations
//
template <class T>
inline from_python<T>::from_python(PyObject* source)
inline arg_from_python<T>::arg_from_python(PyObject* source)
: base(source)
{
}
}} // namespace boost::python
#endif // FROM_PYTHON_DWA2002128_HPP
#endif // ARG_FROM_PYTHON_DWA2002128_HPP

View File

@@ -1,3 +1,5 @@
#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
@@ -5,33 +7,35 @@
// to its suitability for any purpose.
#ifndef ARGS_DWA2002323_HPP
# define ARGS_DWA2002323_HPP
# include <boost/config.hpp>
# include <boost/mpl/type_list.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/enum_params.hpp>
# include <boost/preprocessor/enum_params_with_a_default.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/config.hpp>
# if !defined(__EDG_VERSION__) || __EDG_VERSION__ > 245
namespace boost { namespace python {
# include <boost/python/detail/preprocessor.hpp>
# include <boost/mpl/type_list.hpp>
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/iterate.hpp>
# if !defined(__EDG_VERSION__) || __EDG_VERSION__ > 245
namespace boost { namespace python {
// A type list for specifying arguments
template < BOOST_MPL_LIST_DEFAULT_PARAMETERS(typename A, boost::mpl::null_argument) >
struct args : boost::mpl::type_list< BOOST_MPL_LIST_PARAMETERS(A) >::type
template < BOOST_PYTHON_ENUM_WITH_DEFAULT(BOOST_PYTHON_MAX_ARITY, typename A, boost::mpl::null_argument) >
struct args : boost::mpl::type_list< BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, A) >::type
{};
}} // namespace boost::python
# else // slow template instantiators need this other version with
// explicit specializations of mpl::size<> and
// mpl::at<>. Eventually, however, inheritance from mpl::list
// *should* be eliminated and the two versions unified, just in
// order to get true arity independence
# else // slow template instantiators need this other version with
// explicit specializations of mpl::size<> and
// mpl::at<>. Eventually, however, inheritance from mpl::list
// *should* be eliminated and the two versions unified, just in
// order to get true arity independence
namespace boost { namespace python {
namespace boost { namespace python {
template < BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PYTHON_MAX_ARITY, class A, boost::mpl::null_argument) >
template < BOOST_PYTHON_ENUM_WITH_DEFAULT(BOOST_PYTHON_MAX_ARITY, typename A, boost::mpl::null_argument) >
struct args
{};
@@ -42,32 +46,45 @@ namespace boost { namespace mpl {
template <class T> struct size;
template <long N, class Seq> struct at;
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/args.hpp>
# endif
# define BOOST_PP_ITERATION_PARAMS_1 (4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/args.hpp>, 1))
# include BOOST_PP_ITERATE()
# define BOOST_PYTHON_ARGS_SIZE(index,ignored) \
template <BOOST_PP_ENUM_PARAMS(index, class A)> \
struct size<boost::python::args<BOOST_PP_ENUM_PARAMS(index, A)> > \
{ \
BOOST_STATIC_CONSTANT(long, value = index); \
}; \
# define BOOST_PP_ITERATION_PARAMS_1 (4, (0, BOOST_PYTHON_MAX_ARITY - 1, <boost/python/args.hpp>, 2))
# include BOOST_PP_ITERATE()
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_ARGS_SIZE, nil)
# define BOOST_PYTHON_ARGS_AT(index,ignored) \
template < \
BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(BOOST_PYTHON_ARITY_FINISH), class A)> \
struct at<index, boost::python::args< \
BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(BOOST_PYTHON_ARITY_FINISH), A)> > \
{ \
typedef BOOST_PP_CAT(A,index) type; \
}; \
BOOST_PP_REPEAT_FROM_TO_2ND(
BOOST_PP_DEC(BOOST_PYTHON_ARITY_START), BOOST_PP_DEC(BOOST_PYTHON_ARITY_FINISH)
, BOOST_PYTHON_ARGS_AT, data)
}}
# endif
#endif // ARGS_DWA2002323_HPP
}} // namespace boost::mpl
# endif // __EDG_VERSION__
# endif // ARGS_DWA2002323_HPP
/* ---------- size ---------- */
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == 1
# line BOOST_PP_LINE(__LINE__, args.hpp(size))
# define N BOOST_PP_ITERATION()
template <BOOST_PYTHON_UNARY_ENUM(N, class A)>
struct size<boost::python::args<BOOST_PYTHON_UNARY_ENUM(N, A)> >
{
BOOST_STATIC_CONSTANT(long, value = N);
};
# undef N
/* ---------- at ---------- */
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == 2
# line BOOST_PP_LINE(__LINE__, args.hpp(at))
# define N BOOST_PP_ITERATION()
template <BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, class A)>
struct at<N, boost::python::args<BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, A)> >
{
typedef BOOST_PP_CAT(A, N) type;
};
# undef N
#endif

View File

@@ -0,0 +1,101 @@
// 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/handle.hpp>
# include <boost/python/object_fwd.hpp>
# include <boost/python/detail/dependent.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

@@ -0,0 +1,36 @@
// 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

@@ -0,0 +1,20 @@
// 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,49 +1,63 @@
#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/python/converter/callback.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/enum.hpp>
# include <boost/preprocessor/enum_params.hpp>
# include <boost/preprocessor/repeat.hpp>
# include <boost/preprocessor/cat.hpp>
# include <boost/type.hpp>
# ifndef CALL_DWA2002411_HPP
# define CALL_DWA2002411_HPP
namespace boost { namespace python {
# include <boost/type.hpp>
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/call.hpp>
# endif
# 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>
# define BOOST_PYTHON_CALL_FUNCTION(nargs,ignored) \
template < \
class R \
BOOST_PP_COMMA_IF(nargs) BOOST_PP_ENUM_PARAMS(nargs, class A) \
> \
typename converter::callback_from_python<R>::result_type \
call(PyObject* callable \
BOOST_PP_COMMA_IF(nargs) BOOST_PYTHON_ENUM_PARAMS2(nargs, (A,const& a)) \
, boost::type<R>* = 0 \
) \
{ \
converter::callback_from_python<R> converter; \
return converter( \
PyEval_CallFunction( \
callable \
, const_cast<char*>(BOOST_PYTHON_ARG_STRING(nargs)) \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PP_ENUM(nargs,BOOST_PYTHON_CALLBACK_TO_PYTHON_GET,nil) \
)); \
}
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/preprocessor/repeat.hpp>
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CALL_FUNCTION,data)
namespace boost { namespace python {
# define BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET(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
# 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(N, BOOST_PYTHON_FIXED, "O") ")")
BOOST_PP_REPEAT(N, BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET, nil)
));
}
# undef N
#endif

View File

@@ -1,50 +1,63 @@
#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
# ifndef CALL_METHOD_DWA2002411_HPP
# define CALL_METHOD_DWA2002411_HPP
# include <boost/python/converter/callback.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/enum.hpp>
# include <boost/preprocessor/enum_params.hpp>
# include <boost/preprocessor/repeat.hpp>
# include <boost/preprocessor/cat.hpp>
# include <boost/type.hpp>
# include <boost/type.hpp>
namespace boost { namespace python {
# 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>
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/call_method.hpp>
# endif
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/preprocessor/repeat.hpp>
# define BOOST_PYTHON_CALL_METHOD_FUNCTION(nargs,ignored) \
template < \
class R \
BOOST_PP_COMMA_IF(nargs) BOOST_PP_ENUM_PARAMS(nargs, class A) \
> \
typename converter::callback_from_python<R>::result_type \
call_method(PyObject* self, char const* name \
BOOST_PP_COMMA_IF(nargs) BOOST_PYTHON_ENUM_PARAMS2(nargs, (A,const& a)) \
, boost::type<R>* = 0 \
) \
{ \
converter::callback_from_python<R> converter; \
return converter( \
PyEval_CallMethod( \
self \
, const_cast<char*>(name) \
, const_cast<char*>(BOOST_PYTHON_ARG_STRING(nargs)) \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PP_ENUM(nargs,BOOST_PYTHON_CALLBACK_TO_PYTHON_GET,nil) \
)); \
}
namespace boost { namespace python {
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CALL_METHOD_FUNCTION,data)
# define BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET(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
# 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(N, BOOST_PYTHON_FIXED, "O") ")")
BOOST_PP_REPEAT(N, BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET, nil)
));
}
# undef N
#endif // BOOST_PP_IS_ITERATING

106
include/boost/python/cast.hpp Executable file
View File

@@ -0,0 +1,106 @@
// 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

@@ -9,10 +9,9 @@
# include <boost/python/class_fwd.hpp>
# include <boost/python/bases.hpp>
# include <boost/python/args.hpp>
# include <boost/python/reference.hpp>
# include <boost/python/handle.hpp>
# include <boost/python/object/class.hpp>
# include <boost/python/converter/type_id.hpp>
# include <boost/python/detail/wrap_function.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>
@@ -24,34 +23,47 @@
# include <boost/python/object/class_wrapper.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/defaults_def.hpp>
# include <boost/python/signature.hpp>
namespace boost { namespace python {
namespace boost { namespace python {
namespace detail
{
struct write_type_id;
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 Holder>
static inline void register_copy_constructor(mpl::bool_t<true> const&, Holder*, ref const& obj, T* = 0)
static inline void register_copy_constructor(mpl::bool_t<true> const&, Holder*, object const& obj, T* = 0)
{
objects::class_wrapper<T,Holder> x(obj);
}
// Tag dispatched to have no effect.
template <class T, class Holder>
static inline void register_copy_constructor(mpl::bool_t<false> const&, Holder*, ref const&, T* = 0)
static inline void register_copy_constructor(mpl::bool_t<false> const&, Holder*, object const&, T* = 0)
{
}
// Forward declaration (detail/defaults_def.hpp)
struct func_stubs_base;
}
//
@@ -68,24 +80,26 @@ template <
>
class class_ : public objects::class_base
{
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;
public:
// Automatically derive the class name - only works on some
// compilers because type_info::name is sometimes mangled (gcc)
class_();
// Construct with the class name. [ Would have used a default
// argument but gcc-2.95.2 choked on typeid(T).name() as a default
// parameter value]
class_(char const* name);
class_(char const* name, char const* doc = 0);
// Wrap a member function or a non-member function which can take
@@ -94,55 +108,51 @@ class class_ : public objects::class_base
template <class F>
self& def(char const* name, F f)
{
// Use function::add_to_namespace to achieve overloading if
// appropriate.
objects::function::add_to_namespace(
this->object(), name,
ref(detail::wrap_function(
// This bit of nastiness casts F to a member function of T if possible.
detail::member_function_cast<T,F>::stage1(f).stage2((T*)0).stage3(f)
)));
this->def_impl(name, f, default_call_policies(), 0, &f);
return *this;
}
template <class Fn, class CallPolicy>
self& def(char const* name, Fn fn, CallPolicy policy)
template <class Arg1T, class Arg2T>
self& def(char const* name, Arg1T arg1, Arg2T const& arg2, char const* doc = 0)
{
this->def(name
, boost::python::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)
, policy)
);
dispatch_def(name, arg1, arg2, doc, &arg2);
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&)
{
def("__init__",
make_constructor<Args>(
return this->def("__init__",
python::make_constructor<Args>(
// Using runtime type selection works around a CWPro7 bug.
objects::select_holder<T,held_type>((held_type*)0).get()
)
);
return *this;
}
template <class Args, class CallPolicy>
self& def_init(Args const&, CallPolicy policy)
template <class Args, class CallPolicyOrDoc>
self& def_init(Args const&, CallPolicyOrDoc const& policy_or_doc, char const* doc = 0)
{
def("__init__",
make_constructor<Args>(
policy
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.
, objects::select_holder<T,held_type>((held_type*)0).get()
)
, helper::get_doc(policy_or_doc, doc)
);
return *this;
}
// Define the default constructor.
@@ -158,32 +168,100 @@ class class_ : public objects::class_base
template <class D>
self& def_readonly(char const* name, D T::*pm)
{
ref fget(make_getter(pm));
this->add_property(name, fget);
this->add_property(name, make_getter(pm));
return *this;
}
template <class D>
self& def_readwrite(char const* name, D T::*pm)
{
ref fget(make_getter(pm));
ref fset(make_setter(pm));
this->add_property(name, fget, fset);
return this->add_property(name, make_getter(pm), make_setter(pm));
}
// Property creation
self& add_property(char const* name, object const& fget);
self& add_property(char const* name, object const& fget, object const& fset);
template <class U>
self& setattr(char const* name, U const& x)
{
this->base::setattr(name, object(x));
return *this;
}
// return the underlying object
// ref object() const;
// 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: // types
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);
}
template <class Fn, class CallPolicyOrDoc>
void dispatch_def(
char const* name,
Fn fn,
CallPolicyOrDoc const& policy_or_doc,
char const* doc,
void const*)
{
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 <typename StubsT, typename SigT>
void dispatch_def(
char const* name,
SigT sig,
StubsT const& stubs,
char const* doc,
detail::func_stubs_base const*)
{
// 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), doc);
}
private: // types
typedef objects::class_id class_id;
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
@@ -192,13 +270,13 @@ class class_ : public objects::class_base
id_vector()
{
// Stick the derived class id into the first element of the array
ids[0] = converter::undecorated_type_id<T>();
ids[0] = type_id<T>();
// Write the rest of the elements into succeeding positions.
class_id* p = ids + 1;
mpl::for_each<bases, void, detail::write_type_id>::execute(&p);
}
BOOST_STATIC_CONSTANT(
std::size_t, size = mpl::size<bases>::value + 1);
class_id ids[size];
@@ -212,28 +290,43 @@ class class_ : public objects::class_base
//
template <class T, class X1, class X2, class X3>
inline class_<T,X1,X2,X3>::class_()
: class_base(typeid(T).name(), id_vector::size, id_vector().ids)
: base(typeid(T).name(), id_vector::size, id_vector().ids)
{
// register converters
objects::register_class_from_python<T,bases>();
detail::register_copy_constructor<T>(
mpl::bool_t<is_copyable>()
, objects::select_holder<T,held_type>((held_type*)0).get()
, this->object());
, *this);
}
template <class T, class X1, class X2, class X3>
inline class_<T,X1,X2,X3>::class_(char const* name)
: class_base(name, id_vector::size, id_vector().ids)
inline class_<T,X1,X2,X3>::class_(char const* name, char const* doc)
: base(name, id_vector::size, id_vector().ids, doc)
{
// register converters
objects::register_class_from_python<T,bases>();
detail::register_copy_constructor<T>(
mpl::bool_t<is_copyable>()
, objects::select_holder<T,held_type>((held_type*)0).get()
, this->object());
, *this);
}
template <class T, class X1, class X2, class X3>
inline class_<T,X1,X2,X3>& class_<T,X1,X2,X3>::add_property(char const* name, object const& fget)
{
base::add_property(name, fget);
return *this;
}
template <class T, class X1, class X2, class X3>
inline class_<T,X1,X2,X3>& class_<T,X1,X2,X3>::add_property(char const* name, object const& fget, object const& fset)
{
base::add_property(name, fget, fset);
return *this;
}
namespace detail
@@ -252,9 +345,9 @@ namespace detail
typedef void type;
// Here's the runtime behavior
static void execute(converter::undecorated_type_id_t** p)
static void execute(type_info** p)
{
*(*p)++ = converter::undecorated_type_id<T>();
*(*p)++ = type_id<T>();
}
};
};

View File

@@ -18,9 +18,10 @@ namespace detail
template <
class T // class being wrapped
, class X1 = detail::not_specified
, class X2 = detail::not_specified
, class X3 = detail::not_specified
// 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_;

View File

@@ -0,0 +1,336 @@
// 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/select_type.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::select_type<
obj_mgr
, object_manager_value_arg_from_python<T>
, typename mpl::select_type<
obj_mgr_ref
, object_manager_ref_arg_from_python<T>
, typename mpl::select_type<
ptr
, pointer_arg_from_python<T>
, typename mpl::select_type<
ptr_cref
, pointer_cref_arg_from_python<T>
, typename mpl::select_type<
ref
, reference_arg_from_python<T>
, typename mpl::select_type<
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

@@ -0,0 +1,246 @@
// 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/converter/object_manager.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 {
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::select_type<
is_string
, arg_to_python<char const*>
, typename mpl::select_type<
function
, function_arg_to_python<T>
, typename mpl::select_type<
manager
, object_manager_arg_to_python<T>
, typename mpl::select_type<
ptr
, pointer_deep_arg_to_python<T>
, typename mpl::select_type<
ptr_wrapper
, pointer_shallow_arg_to_python<unwrapped_ptr>
, typename mpl::select_type<
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

@@ -0,0 +1,35 @@
// 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 > 13102171
: handle<>
# endif
{
arg_to_python_base(void const volatile* source, registration const&);
# if defined(BOOST_MSVC) && BOOST_MSVC > 1300 && _MSC_FULL_VER <= 13102171
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

@@ -7,87 +7,106 @@
# define BUILTIN_CONVERTERS_DWA2002124_HPP
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/detail/none.hpp>
# include <boost/python/reference.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; }
};
}
namespace converter
{
template <class T> struct callback_to_python;
BOOST_PYTHON_DECL PyObject* do_call_to_python(char);
BOOST_PYTHON_DECL PyObject* do_call_to_python(char const*);
BOOST_PYTHON_DECL PyObject* do_call_to_python(PyObject*);
BOOST_PYTHON_DECL PyObject* do_callback_to_python(PyObject*);
}
# define BOOST_PYTHON_CALL_TO_PYTHON_BY_VALUE(T, expr) \
template <> struct to_python_value<T&> \
: detail::builtin_to_python \
{ \
PyObject* operator()(T const& x) const \
{ \
return (expr); \
} \
}; \
template <> struct to_python_value<T const&> \
: detail::builtin_to_python \
{ \
PyObject* operator()(T const& x) const \
{ \
return (expr); \
} \
// 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_CALLBACK_TO_PYTHON_BY_VALUE(T, expr) \
namespace converter \
{ \
template <> struct callback_to_python< T > \
{ \
callback_to_python(T const& x) \
: m_held(expr) {} \
PyObject* get() const \
{ return m_held.get(); } \
private: \
ref m_held; \
}; \
# 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) {} \
}; \
}
# define BOOST_PYTHON_TO_PYTHON_BY_VALUE(T, expr) \
BOOST_PYTHON_CALL_TO_PYTHON_BY_VALUE(T,expr) \
BOOST_PYTHON_CALLBACK_TO_PYTHON_BY_VALUE(T,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_call_to_python(x))
BOOST_PYTHON_TO_PYTHON_BY_VALUE(char const*, converter::do_call_to_python(x))
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_CALL_TO_PYTHON_BY_VALUE(PyObject*, converter::do_call_to_python(x))
BOOST_PYTHON_CALLBACK_TO_PYTHON_BY_VALUE(PyObject*, converter::do_callback_to_python(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()))

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_type.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_type<
ptr
, pointer_callback_from_python<T>
, typename mpl::select_type<
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_type<
ptr
, pointer_deep_callback_to_python<T>
, typename mpl::select_type<
ptr_wrapper
, pointer_shallow_callback_to_python<unwrapped_ptr>
, typename mpl::select_type<
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

@@ -3,19 +3,16 @@
// 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>
#ifndef CONSTRUCTOR_FUNCTION_DWA200278_HPP
# define CONSTRUCTOR_FUNCTION_DWA200278_HPP
namespace boost { namespace python { namespace converter {
struct rvalue_stage1_data
{
void* convertible;
constructor_function construct;
};
// 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 // FROM_PYTHON_STAGE1_DATA_DWA2002223_HPP
#endif // CONSTRUCTOR_FUNCTION_DWA200278_HPP

View File

@@ -3,16 +3,13 @@
// 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>
#ifndef CONVERTIBLE_FUNCTION_DWA200278_HPP
# define CONVERTIBLE_FUNCTION_DWA200278_HPP
namespace boost { namespace python { namespace converter {
struct rvalue_stage1_data;
typedef void (*constructor_function)(PyObject* source, rvalue_stage1_data*);
typedef void* (*convertible_function)(PyObject*);
}}} // namespace boost::python::converter
#endif // FROM_PYTHON_FUNCTION_DWA2002128_HPP
#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

@@ -3,235 +3,41 @@
// 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_DWA2002127_HPP
# define FROM_PYTHON_DWA2002127_HPP
#ifndef FIND_FROM_PYTHON_DWA2002223_HPP
# define FIND_FROM_PYTHON_DWA2002223_HPP
# include <boost/python/converter/find_from_python.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/converter/from_python_data.hpp>
# include <boost/mpl/select_type.hpp>
# include <boost/python/converter/registry.hpp>
# include <boost/python/converter/lvalue_from_python_chain.hpp>
# include <boost/python/converter/rvalue_from_python_chain.hpp>
# include <boost/python/detail/void_ptr.hpp>
# include <boost/python/converter/rvalue_from_python_data.hpp>
namespace boost { namespace python { namespace converter {
namespace boost { namespace python { namespace converter {
struct from_python_base
{
public: // member functions
from_python_base(void* result);
from_python_base(PyObject*, lvalue_from_python_registration const* chain);
bool convertible() const;
protected: // member functions
void*const& result() const;
private: // data members
void* m_result;
};
struct registration;
struct rvalue_from_python_chain;
// Used when T == U*const&
template <class T>
struct pointer_const_reference_from_python
{
pointer_const_reference_from_python(PyObject*);
T operator()(PyObject*) const;
bool convertible() const;
private:
typename detail::referent_storage<T>::type m_result;
};
BOOST_PYTHON_DECL void* get_lvalue_from_python(
PyObject* source, registration const&);
// Used when T == U*
template <class T>
struct pointer_from_python : from_python_base
{
pointer_from_python(PyObject*);
T operator()(PyObject*) const;
};
BOOST_PYTHON_DECL rvalue_from_python_chain const* implicit_conversion_chain(
PyObject* source, registration const&);
// Used when T == U& and (T != V const& or T == W volatile&)
template <class T>
struct reference_from_python : from_python_base
{
reference_from_python(PyObject*);
T operator()(PyObject*) const;
};
BOOST_PYTHON_DECL rvalue_from_python_stage1_data rvalue_from_python_stage1(
PyObject* source, registration const&);
// ------- rvalue converters ---------
BOOST_PYTHON_DECL void* rvalue_from_python_stage2(
PyObject* source, rvalue_from_python_stage1_data&, registration const&);
// Used for the case where T is a non-pointer, non-reference type OR
// is a const non-volatile reference to a non-pointer type.
template <class T>
class rvalue_from_python
{
typedef typename boost::add_reference<
typename boost::add_const<T>::type
>::type result_type;
public:
rvalue_from_python(PyObject*);
bool convertible() const;
result_type operator()(PyObject*);
private:
rvalue_data<result_type> m_data;
};
BOOST_PYTHON_DECL void* rvalue_result_from_python(
PyObject*, rvalue_from_python_stage1_data&);
template <class T>
struct select_from_python
{
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_PYTHON_DECL void* reference_result_from_python(PyObject*, registration const&);
BOOST_PYTHON_DECL void* pointer_result_from_python(PyObject*, registration const&);
typedef typename mpl::select_type<
ptr
, pointer_from_python<T>
, typename mpl::select_type<
ptr_cref
, pointer_const_reference_from_python<T>
, typename mpl::select_type<
ref
, reference_from_python<T>
, rvalue_from_python<T>
>::type
>::type
>::type type;
};
BOOST_PYTHON_DECL void void_result_from_python(PyObject*);
//
// implementations
//
inline from_python_base::from_python_base(void* result)
: m_result(result)
{
}
inline from_python_base::from_python_base(
PyObject* source
, lvalue_from_python_registration const* chain)
: m_result(find(source, chain))
{
}
inline bool from_python_base::convertible() const
{
return m_result != 0;
}
inline void*const& from_python_base::result() const
{
return m_result;
}
// --------
namespace detail
{
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_const_reference_from_python<T>::pointer_const_reference_from_python(PyObject* p)
{
python::detail::write_void_ptr_reference(
m_result.bytes
, p == Py_None ? p : find(p, lvalue_from_python_chain<T>::value)
, (T(*)())0);
}
template <class T>
inline bool pointer_const_reference_from_python<T>::convertible() const
{
return python::detail::void_ptr_to_reference(m_result.bytes, (T(*)())0) != 0;
}
template <class T>
inline T pointer_const_reference_from_python<T>::operator()(PyObject* p) const
{
return (p == Py_None)
? detail::null_ptr_reference((T(*)())0)
: python::detail::void_ptr_to_reference(m_result.bytes, (T(*)())0);
}
// --------
template <class T>
inline pointer_from_python<T>::pointer_from_python(PyObject* p)
: from_python_base(p == Py_None ? p : find(p, lvalue_from_python_chain<T>::value))
{
}
template <class T>
inline T pointer_from_python<T>::operator()(PyObject* p) const
{
return (p == Py_None) ? 0 : T(result());
}
// --------
template <class T>
inline reference_from_python<T>::reference_from_python(PyObject* p)
: from_python_base(find(p,lvalue_from_python_chain<T>::value))
{
}
template <class T>
inline T reference_from_python<T>::operator()(PyObject*) const
{
return python::detail::void_ptr_to_reference(result(), (T(*)())0);
}
// -------
template <class T>
inline rvalue_from_python<T>::rvalue_from_python(PyObject* obj)
: m_data(find(obj, rvalue_from_python_chain<T>::value))
{
}
template <class T>
inline bool rvalue_from_python<T>::convertible() const
{
return m_data.stage1.convertible != 0;
}
template <class T>
inline typename rvalue_from_python<T>::result_type
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);
}
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 // FROM_PYTHON_DWA2002127_HPP
#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_type.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_type< \
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

@@ -5,9 +5,9 @@
// to its suitability for any purpose.
#ifndef IMPLICIT_DWA2002326_HPP
# define IMPLICIT_DWA2002326_HPP
# include <boost/python/converter/from_python_data.hpp>
# include <boost/python/converter/from_python_stage1_data.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 {
@@ -16,27 +16,29 @@ struct implicit
{
static void* convertible(PyObject* obj)
{
// Find a converter registration which can produce a Source
// instance from obj
return const_cast<rvalue_from_python_registration*>(
find_chain(obj, rvalue_from_python_chain<Source>::value));
// 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_stage1_data* data)
static void construct(PyObject* obj, rvalue_from_python_stage1_data* data)
{
// This is the registration we got from the convertible step
rvalue_from_python_registration const* registration
= static_cast<rvalue_from_python_registration*>(data->convertible);
// 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_data<Source> intermediate_data(registration->convertible(obj));
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 (registration->construct != 0)
registration->construct(obj, &intermediate_data.stage1);
if (chain->construct != 0)
chain->construct(obj, &intermediate_data.stage1);
void* storage = ((rvalue_base_data<Target>*)data)->storage.bytes;
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

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_type<
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

@@ -0,0 +1,116 @@
// 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

@@ -0,0 +1,232 @@
// 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/select_type.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::select_type<
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::select_type<
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::select_type<
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

@@ -6,7 +6,7 @@
#ifndef POINTER_TYPE_ID_DWA2002222_HPP
# define POINTER_TYPE_ID_DWA2002222_HPP
# include <boost/python/converter/type_id.hpp>
# include <boost/python/type_id.hpp>
# include <boost/type_traits/composite_traits.hpp>
namespace boost { namespace python { namespace converter {
@@ -17,9 +17,9 @@ namespace detail
struct pointer_typeid_select
{
template <class T>
static inline undecorated_type_id_t execute(T*(*)() = 0)
static inline type_info execute(T*(*)() = 0)
{
return undecorated_type_id<T>();
return type_id<T>();
}
};
@@ -27,37 +27,37 @@ namespace detail
struct pointer_typeid_select<true>
{
template <class T>
static inline undecorated_type_id_t execute(T* const volatile&(*)() = 0)
static inline type_info execute(T* const volatile&(*)() = 0)
{
return undecorated_type_id<T>();
return type_id<T>();
}
template <class T>
static inline undecorated_type_id_t execute(T*volatile&(*)() = 0)
static inline type_info execute(T*volatile&(*)() = 0)
{
return undecorated_type_id<T>();
return type_id<T>();
}
template <class T>
static inline undecorated_type_id_t execute(T*const&(*)() = 0)
static inline type_info execute(T*const&(*)() = 0)
{
return undecorated_type_id<T>();
return type_id<T>();
}
template <class T>
static inline undecorated_type_id_t execute(T*&(*)() = 0)
static inline type_info execute(T*&(*)() = 0)
{
return undecorated_type_id<T>();
return type_id<T>();
}
};
}
// Usage: pointer_type_id<T>()
//
// Returns an undecorated_type_id_t associated with the type pointed
// 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>
undecorated_type_id_t pointer_type_id(T(*)() = 0)
type_info pointer_type_id(T(*)() = 0)
{
return detail::pointer_typeid_select<
is_reference<T>::value

View File

@@ -0,0 +1,42 @@
// 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

@@ -0,0 +1,36 @@
// 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

@@ -0,0 +1,99 @@
// 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

@@ -0,0 +1,43 @@
// 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

@@ -3,37 +3,52 @@
// 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
#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 rvalue_from_python_chain_impl
struct registered_base
{
static rvalue_from_python_registration*const& value;
static registration const& converters;
};
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<
struct registered
: detail::registered_base<
typename add_reference<
typename add_cv<T>::type
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 // RVALUE_FROM_PYTHON_CHAIN_DWA200237_HPP
#endif // REGISTERED_DWA2002710_HPP

View File

@@ -0,0 +1,63 @@
// 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

@@ -6,23 +6,62 @@
#ifndef REGISTRATIONS_DWA2002223_HPP
# define REGISTRATIONS_DWA2002223_HPP
# include <boost/python/converter/from_python_function.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_registration
struct lvalue_from_python_chain
{
void* (*convert)(PyObject* source);
lvalue_from_python_registration* next;
convertible_function convert;
lvalue_from_python_chain* next;
};
struct rvalue_from_python_registration
struct rvalue_from_python_chain
{
void* (*convertible)(PyObject*);
convertible_function convertible;
constructor_function construct;
rvalue_from_python_registration* next;
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

@@ -5,47 +5,46 @@
// to its suitability for any purpose.
#ifndef REGISTRY_DWA20011127_HPP
# define REGISTRY_DWA20011127_HPP
# include <boost/python/converter/type_id.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/from_python_function.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 lvalue_from_python_registration;
struct rvalue_from_python_registration;
struct registration;
// This namespace acts as a sort of singleton
namespace registry
{
BOOST_PYTHON_DECL lvalue_from_python_registration*& lvalue_converters(undecorated_type_id_t);
BOOST_PYTHON_DECL rvalue_from_python_registration*& rvalue_converters(undecorated_type_id_t);
// 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 to_python_function_t const&
get_to_python_function(undecorated_type_id_t);
BOOST_PYTHON_DECL void insert(to_python_function_t, undecorated_type_id_t);
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*), undecorated_type_id_t);
BOOST_PYTHON_DECL void insert(void* (*convert)(PyObject*), type_info);
// Insert an rvalue from_python converter
BOOST_PYTHON_DECL void insert(
void* (*convertible)(PyObject*)
convertible_function
, constructor_function
, undecorated_type_id_t
, type_info
);
// Insert an rvalue from_python converter at the tail of the
// chain. Used for implicit conversions
BOOST_PYTHON_DECL void push_back(
void* (*convertible)(PyObject*)
convertible_function
, constructor_function
, undecorated_type_id_t
, type_info
);
BOOST_PYTHON_DECL PyTypeObject*& class_object(undecorated_type_id_t key);
}
}}} // namespace boost::python::converter

View File

@@ -0,0 +1,150 @@
// 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/object_manager.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 {
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::select_type<
obj_mgr
, return_object_manager_from_python<T>
, typename mpl::select_type<
ptr
, return_pointer_from_python<T>
, typename mpl::select_type<
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

@@ -0,0 +1,138 @@
// 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 <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

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