mirror of
https://github.com/boostorg/python.git
synced 2026-01-23 17:52:17 +00:00
Compare commits
203 Commits
boost-1.28
...
svn-branch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9743ad0a69 | ||
|
|
432a9b85e7 | ||
|
|
9d51d39d7a | ||
|
|
a33ee22259 | ||
|
|
943b96f902 | ||
|
|
d52bc52515 | ||
|
|
fe19b49273 | ||
|
|
e56f6833e6 | ||
|
|
502e67c114 | ||
|
|
cdf49c6ac0 | ||
|
|
bbc90bcc9c | ||
|
|
2103e691db | ||
|
|
cf15a99730 | ||
|
|
a3102b552c | ||
|
|
bd0257cbe5 | ||
|
|
56e7b2a592 | ||
|
|
61d030748c | ||
|
|
f59ed991fe | ||
|
|
2bdf958663 | ||
|
|
bd8b6a2a64 | ||
|
|
88528e338b | ||
|
|
88b3bf1887 | ||
|
|
6907df1457 | ||
|
|
19036c14f5 | ||
|
|
ddb1236f2f | ||
|
|
30ef9c6418 | ||
|
|
8763fd1c53 | ||
|
|
5976005c4a | ||
|
|
63eed8994a | ||
|
|
f458dbdbcb | ||
|
|
b7421fd5cd | ||
|
|
a2feb04509 | ||
|
|
e25fee71a2 | ||
|
|
bfe2a6656c | ||
|
|
e15ca5c642 | ||
|
|
3232c5be86 | ||
|
|
1c5a50d4cb | ||
|
|
4ef5f77161 | ||
|
|
d27e5a5e1d | ||
|
|
7ecf76490c | ||
|
|
12120413f9 | ||
|
|
c0eea6e667 | ||
|
|
5c54aecdda | ||
|
|
5cfc0cce14 | ||
|
|
d9a58ef830 | ||
|
|
dfd85da9d7 | ||
|
|
94edc13393 | ||
|
|
a9baa519f3 | ||
|
|
a6c859c9cc | ||
|
|
f9a67b34b2 | ||
|
|
6ac5735d14 | ||
|
|
9d5e8b9ad8 | ||
|
|
bd72ee9cd1 | ||
|
|
c2e115b6a5 | ||
|
|
61ba4cd1ce | ||
|
|
244e0fa5e6 | ||
|
|
134bc44c45 | ||
|
|
1d2dc98f50 | ||
|
|
7a05b89a93 | ||
|
|
2bfeb20550 | ||
|
|
fa779034b5 | ||
|
|
ea5cfdcdce | ||
|
|
ba1eab1bf0 | ||
|
|
149c60bd2e | ||
|
|
9795a27482 | ||
|
|
baccdba75c | ||
|
|
93b4c6291a | ||
|
|
815edf1ba5 | ||
|
|
df7b4d81c7 | ||
|
|
3e07ba1012 | ||
|
|
32c6906750 | ||
|
|
3ebe4c47ba | ||
|
|
5b803f00e1 | ||
|
|
9a0118d991 | ||
|
|
093aae1f46 | ||
|
|
e431318dc0 | ||
|
|
c15812add2 | ||
|
|
3375cdbb49 | ||
|
|
559b564714 | ||
|
|
3ac4cfb9a7 | ||
|
|
a4d651ce9a | ||
|
|
d3bbc0eaa5 | ||
|
|
9ff90c98cd | ||
|
|
b8aaf7d7b1 | ||
|
|
c0ecde90bc | ||
|
|
83719a6f48 | ||
|
|
28011bbf55 | ||
|
|
88170f6dc4 | ||
|
|
931aab22bb | ||
|
|
6cb4fbb1c4 | ||
|
|
54a551e488 | ||
|
|
5a0d84f185 | ||
|
|
222396759b | ||
|
|
128c0ed5a1 | ||
|
|
ea74e34446 | ||
|
|
c7225a059f | ||
|
|
c1f8ae662f | ||
|
|
7d3227128c | ||
|
|
182b6755f5 | ||
|
|
0945f79ced | ||
|
|
8b611322e5 | ||
|
|
b255796b33 | ||
|
|
2ae7c60780 | ||
|
|
279ad90a3c | ||
|
|
bed7a7d29c | ||
|
|
f02a3c5b47 | ||
|
|
d7df5126ce | ||
|
|
97ecfe7e03 | ||
|
|
f30fde3a52 | ||
|
|
d7273dee1c | ||
|
|
55dff4d512 | ||
|
|
693b21188c | ||
|
|
220734ccac | ||
|
|
bf84024d6b | ||
|
|
7bb39ae541 | ||
|
|
d250057a7c | ||
|
|
d07454659a | ||
|
|
913d2984ce | ||
|
|
e2d75c0b76 | ||
|
|
8aba486295 | ||
|
|
66f2cd81a8 | ||
|
|
87bda9e124 | ||
|
|
954d019895 | ||
|
|
41132af773 | ||
|
|
9a5b89da59 | ||
|
|
c12ffa21da | ||
|
|
0b5937a396 | ||
|
|
773bb0651e | ||
|
|
8817b1e2af | ||
|
|
366ee6d24b | ||
|
|
0d58869d6e | ||
|
|
52ba3c7f80 | ||
|
|
14d2bae238 | ||
|
|
e331512473 | ||
|
|
1de6a21f3a | ||
|
|
43d8c81104 | ||
|
|
89930f34d7 | ||
|
|
59ea6b120c | ||
|
|
7c312d358b | ||
|
|
ac2746f680 | ||
|
|
e2b4178f42 | ||
|
|
266954be99 | ||
|
|
2e3ae9decb | ||
|
|
6741698f71 | ||
|
|
ccae1cc430 | ||
|
|
241a5bf4e5 | ||
|
|
e36aba8c66 | ||
|
|
1a0baef147 | ||
|
|
9a49d267eb | ||
|
|
7a832f1fdb | ||
|
|
16c391c78c | ||
|
|
92aae63af2 | ||
|
|
b042644c85 | ||
|
|
97afc4bd0c | ||
|
|
a67b29a576 | ||
|
|
97c87d0a99 | ||
|
|
fedf8d9935 | ||
|
|
23bfb84e38 | ||
|
|
c7d16fbf9e | ||
|
|
033a3dd620 | ||
|
|
f5a0b2fed8 | ||
|
|
b03dcfb7de | ||
|
|
502094439c | ||
|
|
c15f812366 | ||
|
|
dd1b102282 | ||
|
|
67b3cdc7b7 | ||
|
|
051994bdf4 | ||
|
|
0f7c12b517 | ||
|
|
aa2b0090d3 | ||
|
|
00b27c20da | ||
|
|
7ecd7e84d9 | ||
|
|
49c2dbd4a7 | ||
|
|
cf46535b66 | ||
|
|
91e2e6f207 | ||
|
|
b63434ce2e | ||
|
|
dde6c42421 | ||
|
|
beb6cca88d | ||
|
|
ba2f18ce21 | ||
|
|
c928eded74 | ||
|
|
9baefc2e56 | ||
|
|
313fe2c76c | ||
|
|
53c69e7ad5 | ||
|
|
3ff935d4c4 | ||
|
|
9fa89e8596 | ||
|
|
6c20af07f7 | ||
|
|
56abd7ba70 | ||
|
|
dc1769b28a | ||
|
|
97b863101b | ||
|
|
0a1b62a760 | ||
|
|
f2fa852f1a | ||
|
|
59f4ddf5af | ||
|
|
673d857bd8 | ||
|
|
36be16b3e9 | ||
|
|
390bb1988d | ||
|
|
63deae3ab2 | ||
|
|
710374ed1e | ||
|
|
8f1dc2522a | ||
|
|
9c3dd76e25 | ||
|
|
3328087de1 | ||
|
|
ec3f5ff40b | ||
|
|
3b000f080e | ||
|
|
09046c53ef | ||
|
|
13331d3eab |
22
Jamfile
22
Jamfile
@@ -4,8 +4,22 @@ subproject libs/python ;
|
|||||||
SEARCH on <module@>python.jam = $(BOOST_BUILD_PATH) ;
|
SEARCH on <module@>python.jam = $(BOOST_BUILD_PATH) ;
|
||||||
include <module@>python.jam ;
|
include <module@>python.jam ;
|
||||||
|
|
||||||
|
local bpl-ldflags ;
|
||||||
|
|
||||||
|
if $(UNIX) && ( $(OS) = AIX )
|
||||||
|
{
|
||||||
|
bpl-linkflags = <linkflags>"-e initlibbpl" ;
|
||||||
|
}
|
||||||
|
|
||||||
dll bpl
|
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/from_python.cpp
|
||||||
src/converter/registry.cpp
|
src/converter/registry.cpp
|
||||||
src/converter/type_id.cpp
|
src/converter/type_id.cpp
|
||||||
@@ -13,12 +27,16 @@ dll bpl
|
|||||||
src/object/function.cpp
|
src/object/function.cpp
|
||||||
src/object/inheritance.cpp
|
src/object/inheritance.cpp
|
||||||
src/object/life_support.cpp
|
src/object/life_support.cpp
|
||||||
|
src/object/pickle_support.cpp
|
||||||
src/errors.cpp
|
src/errors.cpp
|
||||||
src/module.cpp
|
src/module.cpp
|
||||||
src/objects.cpp
|
|
||||||
src/converter/builtin_converters.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)
|
$(BOOST_PYTHON_V2_PROPERTIES)
|
||||||
<define>BOOST_PYTHON_SOURCE
|
<define>BOOST_PYTHON_SOURCE
|
||||||
|
$(bpl-linkflags)
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -89,11 +89,12 @@ local CPP_SOURCES =
|
|||||||
;
|
;
|
||||||
|
|
||||||
lib boost_python_static : ../src/$(CPP_SOURCES).cpp
|
lib boost_python_static : ../src/$(CPP_SOURCES).cpp
|
||||||
# requirements
|
# requirements
|
||||||
: $(BOOST_PYTHON_INCLUDES)
|
: $(BOOST_PYTHON_INCLUDES)
|
||||||
<shared-linkable>true
|
<shared-linkable>true
|
||||||
<define>BOOST_PYTHON_STATIC_LIB=1
|
<define>BOOST_PYTHON_STATIC_LIB=1
|
||||||
[ difference $(PYTHON_PROPERTIES) : <define>BOOST_PYTHON_DYNAMIC_LIB ]
|
[ 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
|
dll boost_python
|
||||||
@@ -106,6 +107,14 @@ dll boost_python
|
|||||||
$(PYTHON_PROPERTIES)
|
$(PYTHON_PROPERTIES)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
stage bin-stage : <dll>boost_python
|
||||||
|
:
|
||||||
|
<tag><debug>"_debug"
|
||||||
|
<tag><debug-python>"_pydebug"
|
||||||
|
:
|
||||||
|
debug release
|
||||||
|
;
|
||||||
|
|
||||||
############# comprehensive module and test ###########
|
############# comprehensive module and test ###########
|
||||||
bpl-test boost_python_test
|
bpl-test boost_python_test
|
||||||
: ../test/comprehensive.cpp ;
|
: ../test/comprehensive.cpp ;
|
||||||
|
|||||||
@@ -3,15 +3,20 @@
|
|||||||
|
|
||||||
if ! $(gNO_PYTHON_INSTALL)
|
if ! $(gNO_PYTHON_INSTALL)
|
||||||
{
|
{
|
||||||
ECHO "Couldn't find Python $(PYTHON_VERSION) installation in $(PYTHON_ROOT)" ;
|
ECHO "---------------------------------------------------------------------" ;
|
||||||
ECHO skipping Boost.Python library build ;
|
ECHO skipping Boost.Python library build ;
|
||||||
ECHO You can configure the location of your python installation, by setting: ;
|
ECHO You can configure the location of your python installation, by setting: ;
|
||||||
ECHO PYTHON_ROOT - currently \"$(PYTHON_ROOT)\" ;
|
ECHO "PYTHON_ROOT - currently" \"$(PYTHON_ROOT:J=" ")\" ;
|
||||||
ECHO PYTHON_VERSION - currently \"$(PYTHON_VERSION)\" ;
|
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 ;
|
||||||
ECHO "The following are automatically configured from PYTHON_ROOT if not otherwise set" ;
|
ECHO "The following are automatically configured from PYTHON_ROOT if not" ;
|
||||||
ECHO " PYTHON_INCLUDES - path to Python #include directories; currently" \"$(PYTHON_INCLUDES)\" ;
|
ECHO "otherwise set:" ;
|
||||||
ECHO " PYTHON_LIB_PATH - path to Python library; currently" \"$(PYTHON_LIB_PATH)\" ;
|
ECHO " PYTHON_INCLUDES - path to Python #include directories; currently" \"$(PYTHON_INCLUDES:J=" ")\" ;
|
||||||
ECHO " PYTHON_STDLIB_PATH - path to Python standard library modules; currently" \"$(PYTHON_STDLIB_PATH)\" ;
|
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 ;
|
gNO_PYTHON_INSTALL ?= true ;
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -9,172 +9,214 @@
|
|||||||
"../../../c++boost.gif" alt="c++boost.gif (8819 bytes)">Building an
|
"../../../c++boost.gif" alt="c++boost.gif (8819 bytes)">Building an
|
||||||
Extension Module</h1>
|
Extension Module</h1>
|
||||||
|
|
||||||
<p>The build process for Boost is currently undergoing some evolution,
|
<h2>Building Boost.Python</h2>
|
||||||
and, it is to be hoped, improvement. The following facts may help:
|
|
||||||
|
|
||||||
<hr>
|
<p>Every Boost.Python extension module must be linked with the
|
||||||
Makefiles for various platforms and a Visual Studio project
|
<code>boost_python</code> shared library. To build
|
||||||
reside in the Boost subdirectory <tt>libs/python/build</tt>.
|
<code>boost_python</code>, use <a
|
||||||
Build targets include:
|
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: <code>c:/tools/python</code>
|
||||||
|
Unix: <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: <code>2.1</code>
|
||||||
|
Unix: <code>1.5</code>
|
||||||
|
<td>Be sure not to include a third number, e.g. <b>not</b>
|
||||||
|
"<code>2.2.1</code>", 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 "<code>subproject</code>" 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>
|
<ul>
|
||||||
<li>The <tt>boost_python</tt> library for static linking with your
|
<li><code>release</code> (optimization, <tt>-DNDEBUG</tt>)
|
||||||
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>.
|
|
||||||
|
|
||||||
<p>
|
<li><code>debug</code> (no optimization <tt>-D_DEBUG</tt>)
|
||||||
<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>.
|
|
||||||
|
|
||||||
<p>
|
<li><code>debug-python</code> (no optimization, <tt>-D_DEBUG
|
||||||
<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
|
|
||||||
-DBOOST_DEBUG_PYTHON</tt>)
|
-DBOOST_DEBUG_PYTHON</tt>)
|
||||||
</ul>
|
</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 "Win32 Debug" 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
|
<tt>-D_DEBUG</tt>, Python defaults to <i>force</i> linking with a
|
||||||
special debugging version of the Python DLL. Since this debug DLL
|
special debugging version of the Python DLL. Since this debug DLL
|
||||||
isn't supplied with the default Python installation for Windows,
|
isn't supplied with the default Python installation for Windows,
|
||||||
Boost.Python uses <tt><a href=
|
Boost.Python uses <tt><a href=
|
||||||
"../../../boost/python/detail/wrap_python.hpp">boost/python/detail/wrap_python.hpp</a></tt>
|
"../../../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
|
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
|
<p>If you want the extra runtime checks available with the
|
||||||
version of the library, <tt>#define BOOST_DEBUG_PYTHON</tt> to
|
debugging version of the library, <tt>#define
|
||||||
re-enable library forcing, and link with the DebugPython version of
|
BOOST_DEBUG_PYTHON</tt> to re-enable python debuggin, and link
|
||||||
<tt>boost_python.lib</tt>. You'll need to get the debugging version
|
with the <code>debug-python</code> variant of
|
||||||
of the Python executable (<tt>python_d.exe</tt>) and DLL
|
<tt>boost_python</tt>.
|
||||||
(<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 do not <tt>#define BOOST_DEBUG_PYTHON</tt>, be sure that
|
<p>If you do not <tt>#define BOOST_DEBUG_PYTHON</tt>, be sure that
|
||||||
any source files <tt>#include <<a href=
|
any source files in your extension module <tt>#include <<a href=
|
||||||
"../../../boost/python/detail/wrap_python.hpp">boost/python/detail/wrap_python.hpp</a>></tt>
|
"../../../boost/python/detail/wrap_python.hpp">boost/python/detail/wrap_python.hpp</a>></tt>
|
||||||
instead of the usual <tt>Python.h</tt>, or you will have link
|
instead of the usual <tt>Python.h</tt>, or you will have link
|
||||||
incompatibilities.<br>
|
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>
|
<hr>
|
||||||
Next: <a href="enums.html">Wrapping Enums</a> Previous: <a href=
|
Next: <a href="enums.html">Wrapping Enums</a> Previous: <a href=
|
||||||
"under-the-hood.html">A Peek Under the Hood</a> Up: <a href=
|
"under-the-hood.html">A Peek Under the Hood</a> Up: <a href=
|
||||||
"index.html">Top</a>
|
"index.html">Top</a>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
<p>© Copyright David Abrahams 2000. Permission to copy, use, modify,
|
<p>© Copyright David Abrahams 2002. Permission to copy, use, modify,
|
||||||
sell and distribute this document is granted provided this copyright
|
sell and distribute this document is granted provided this copyright
|
||||||
notice appears in all copies. This document is provided ``as is'' without
|
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
|
express or implied warranty, and with no claim as to its suitability for
|
||||||
any purpose.
|
any purpose.
|
||||||
|
|
||||||
<p>Updated: Apr 17, 2001 (R.W. Grosse-Kunstleve)
|
<p>Updated: May 15, 2002 (David Abrahams)
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -18,6 +18,21 @@
|
|||||||
<em>should</em> simply ``reflect'' your C++ classes and functions into
|
<em>should</em> simply ``reflect'' your C++ classes and functions into
|
||||||
Python.
|
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>
|
<h2>Supported Platforms</h2>
|
||||||
<p>Boost.Python is known to have been tested
|
<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
|
against <a href="http://www.python/org/2.2.1">Python 2.2.1</a> using
|
||||||
|
|||||||
@@ -81,10 +81,10 @@ BOOST_PYTHON_MODULE_INIT(my_module)
|
|||||||
python::module_builder my_module("my_module");
|
python::module_builder my_module("my_module");
|
||||||
|
|
||||||
python::class_builder<Base> base_class(my_module, "Base");
|
python::class_builder<Base> base_class(my_module, "Base");
|
||||||
base_class.def(python::constructor<void>());
|
base_class.def(python::constructor<>());
|
||||||
|
|
||||||
python::class_builder<Derived> derived_class(my_module, "Derived");
|
python::class_builder<Derived> derived_class(my_module, "Derived");
|
||||||
derived_class.def(python::constructor<void>());
|
derived_class.def(python::constructor<>());
|
||||||
<b>// Establish the inheritance relationship between Base and Derived
|
<b>// Establish the inheritance relationship between Base and Derived
|
||||||
derived_class.declare_base(base_class);</b>
|
derived_class.declare_base(base_class);</b>
|
||||||
|
|
||||||
@@ -137,10 +137,10 @@ struct Derived2 { int f(); };
|
|||||||
<hr>
|
<hr>
|
||||||
...
|
...
|
||||||
python::class_builder<Base> base2_class(my_module, "Base2");
|
python::class_builder<Base> base2_class(my_module, "Base2");
|
||||||
base2_class.def(python::constructor<void>());
|
base2_class.def(python::constructor<>());
|
||||||
|
|
||||||
python::class_builder<Derived2> derived2_class(my_module, "Derived2");
|
python::class_builder<Derived2> derived2_class(my_module, "Derived2");
|
||||||
derived2_class.def(python::constructor<void>());
|
derived2_class.def(python::constructor<>());
|
||||||
derived_class.declare_base(base_class, <b>python::without_downcast</b>);
|
derived_class.declare_base(base_class, <b>python::without_downcast</b>);
|
||||||
</pre>
|
</pre>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
"header">
|
"header">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<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>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<h1 align="center">Boost.Python</h1>
|
<h1 align="center">Boost.Python</h1>
|
||||||
@@ -119,7 +120,7 @@ more-sophisticated overloading mechanism than the current
|
|||||||
simple-minded "first match" approach, as I suggested <a
|
simple-minded "first match" approach, as I suggested <a
|
||||||
href="Mar2002.html#implicit_conversions">last month</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
|
As much as I'm looking forward to retiring Boost.Python v1, a
|
||||||
significant amount of effort has been being spent dealing with support
|
significant amount of effort has been being spent dealing with support
|
||||||
|
|||||||
124
doc/v2/CallPolicies.html
Normal file
124
doc/v2/CallPolicies.html
Normal 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 "preliminary" 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>() != 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
|
||||||
|
"preliminary" 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>() != 0</code>
|
||||||
|
upon failure. Must "conserve references" 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>© 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>
|
||||||
66
doc/v2/Dereferenceable.html
Normal file
66
doc/v2/Dereferenceable.html
Normal 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>© 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
93
doc/v2/Extractor.html
Executable 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
|
||||||
|
"traditional" 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>&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>© 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
71
doc/v2/HolderGenerator.html
Executable 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<X>::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>© 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
226
doc/v2/Jun2002.html
Normal 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<T></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
|
||||||
|
"Writing Python in C++". 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<T></code></a></h2>
|
||||||
|
|
||||||
|
The most basic element needed was a replacement for the
|
||||||
|
<code>reference<></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
|
||||||
|
"<code>ref</code>" (for
|
||||||
|
<code>reference<PyObject></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<></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<></code>; its major distinguishing features are
|
||||||
|
that it gives direct access to the underlying object representation
|
||||||
|
through <code>operator*</code> and <code>operator-></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("foo");
|
||||||
|
<tr>
|
||||||
|
<td><code>x.foo = 1</code> <td><code>x.attr("foo") = 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("f")(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._("foo");
|
||||||
|
x._("foo") = 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,"foo" // error
|
||||||
|
x,"foo" = 1; // error
|
||||||
|
|
||||||
|
y = (x,"foo"); // ok
|
||||||
|
(x,"foo") = 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><></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 "interesting" 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>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave Abrahams</a>
|
||||||
|
2002. All Rights Reserved.</i></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
"header">
|
"header">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<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>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<h1 align="center">Boost.Python</h1>
|
<h1 align="center">Boost.Python</h1>
|
||||||
|
|||||||
309
doc/v2/May2002.html
Normal file
309
doc/v2/May2002.html
Normal 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 "creatively designed"
|
||||||
|
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<...>/right_operand<...></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("__iter__", iterator<list_int>())
|
||||||
|
</pre>
|
||||||
|
<dd>
|
||||||
|
|
||||||
|
<dt>Creation of iterators from member functions...
|
||||||
|
<pre>
|
||||||
|
...
|
||||||
|
.def("__iter__"
|
||||||
|
, range(&my_class::x_begin, &my_class::x_end))
|
||||||
|
)
|
||||||
|
</pre>
|
||||||
|
<dd>
|
||||||
|
|
||||||
|
<dt>...and member data:
|
||||||
|
<pre>
|
||||||
|
...
|
||||||
|
.def("__iter__"
|
||||||
|
, range(&std::pair<char*,char*>::first, &std::pair<char*,char*>::second))
|
||||||
|
)
|
||||||
|
</pre>
|
||||||
|
<dd>
|
||||||
|
|
||||||
|
<dt>The ability to specify <a
|
||||||
|
href="CallPolicies.html">CallPolicies</a>, e.g. to prevent copying of
|
||||||
|
heavyweight values:
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
...
|
||||||
|
.def("__iter__",
|
||||||
|
, range<return_value_policy<copy_non_const_reference> >(
|
||||||
|
&my_sequence<heavy>::begin
|
||||||
|
, &my_sequence<heavy>::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>
|
||||||
|
>>> f = field()
|
||||||
|
>>> 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_<></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<T></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<T></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++ <==> 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>"foobar"</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>© 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
110
doc/v2/ResultConverter.html
Normal 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<R>::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>© 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>
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
"header">
|
"header">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<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>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<h1 align="center">Boost.Python</h1>
|
<h1 align="center">Boost.Python</h1>
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
"header">
|
"header">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<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>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<h1 align="center">Boost.Python</h1>
|
<h1 align="center">Boost.Python</h1>
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
"header">
|
"header">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<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>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<h1 align="center">Boost.Python</h1>
|
<h1 align="center">Boost.Python</h1>
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
"header">
|
"header">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<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>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<h1 align="center">Boost.Python</h1>
|
<h1 align="center">Boost.Python</h1>
|
||||||
@@ -34,7 +35,7 @@
|
|||||||
<p>
|
<p>
|
||||||
<code><boost/python/call_method.hpp></code> defines the <a
|
<code><boost/python/call_method.hpp></code> defines the <a
|
||||||
href="#call_method-spec"><code>call_method</code></a> family of overloaded function
|
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>
|
<h2><a name="functions"></a>Functions</h2>
|
||||||
<pre>
|
<pre>
|
||||||
@@ -131,7 +132,7 @@ BOOST_PYTHON_MODULE_INIT(my_module)
|
|||||||
</pre>
|
</pre>
|
||||||
<p>Revised
|
<p>Revised
|
||||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
<!--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" -->
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
||||||
</p>
|
</p>
|
||||||
<p><i>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave Abrahams</a>
|
<p><i>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave Abrahams</a>
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
"header">
|
"header">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<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>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<h1 align="center">Boost.Python</h1>
|
<h1 align="center">Boost.Python</h1>
|
||||||
|
|||||||
@@ -72,30 +72,34 @@
|
|||||||
|
|
||||||
<p><code><boost/python/class.hpp></code> defines the interface
|
<p><code><boost/python/class.hpp></code> defines the interface
|
||||||
through which users expose their C++ classes to Python. It declares the
|
through which users expose their C++ classes to Python. It declares the
|
||||||
<code>class_</code> class template, which is parameterized on the class
|
<code>class_</code> class template, which is parameterized on the
|
||||||
type being exposed, and the <code>args</code> and <code>bases</code>
|
class type being exposed. It also exposes the <code>args</code>
|
||||||
utility class templates in the anonymous namespace (the latter definitions
|
and <code>bases</code> utility class templates, which are used in
|
||||||
will probably be moved in a future release).
|
conjunction with <code>class_</code>.
|
||||||
|
|
||||||
<p><code><boost/python/class_fwd.hpp></code> contains a forward
|
<p><code><boost/python/class_fwd.hpp></code> contains a forward
|
||||||
declaration of the <code>class_</code> class template.
|
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_<T, Bases, <a
|
<h3><a name="class_-spec"></a>Class template <code>class_<T, <font color="#007f00">Bases, HeldType, NonCopyable</font>></code></h3>
|
||||||
href="HolderGenerator.html">HolderGenerator</a>></code></h3>
|
|
||||||
|
|
||||||
<p>Creates a Python class associated with the C++ type passed as its first
|
<p>Creates a Python class associated with the C++ type passed as
|
||||||
parameter. Its template arguments are:<br>
|
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>
|
<br>
|
||||||
|
|
||||||
|
|
||||||
<table border="1" summary="class_ template parameters">
|
<table border="1" summary="class_ template parameters">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Parameter
|
<th>Template Parameter
|
||||||
|
|
||||||
<th>Requirements
|
<th>Requirements
|
||||||
|
|
||||||
|
<th>Semantics
|
||||||
|
|
||||||
<th>Default
|
<th>Default
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
@@ -103,57 +107,158 @@
|
|||||||
|
|
||||||
<td>A class type.
|
<td>A class type.
|
||||||
|
|
||||||
<tr>
|
<td>The class being wrapped
|
||||||
<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
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>HolderGenerator</code>
|
<td><code><font color="#007f00">Bases</font></code>
|
||||||
|
|
||||||
<td>A model of <code><a href=
|
<td>A specialization of <a
|
||||||
"HolderGenerator.html">HolderGenerator</a></code>.
|
href="#bases-spec"><code>bases<...></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<></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><HeldType>::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>
|
</table>
|
||||||
|
|
||||||
<h4><a name="class_-spec-synopsis"></a>Class template <code>class_</code>
|
<h4><a name="#HeldType">HeldType Semantics</a></h4>
|
||||||
synopsis</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<></code>
|
||||||
|
or <code><a
|
||||||
|
href="../../../smart_ptr/shared_ptr.htm">boost::shared_ptr<></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<HeldType></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>
|
<pre>
|
||||||
namespace boost { namespace python
|
namespace boost { namespace python
|
||||||
{
|
{
|
||||||
|
|
||||||
template <class T
|
template <class T
|
||||||
, class Bases = <i>none</i>
|
<font color="#007f00"> , class Bases = bases<>
|
||||||
, class HolderGenerator = objects::value_holder_generator>
|
, class HeldType = T
|
||||||
class class_
|
, class NonCopyable = <i>unspecified</i>
|
||||||
|
>
|
||||||
|
</font> class class_
|
||||||
{
|
{
|
||||||
class_();
|
class_();
|
||||||
class_(char const* name);
|
class_(char const* name);
|
||||||
|
|
||||||
template <class F>
|
// exposing constructors
|
||||||
class_& def(char const* name, F f);
|
class_& def_init();
|
||||||
|
|
||||||
template <class Fn, class CallPolicy>
|
|
||||||
class_& def(char const* name, Fn fn, CallPolicy policy);
|
|
||||||
|
|
||||||
template <class Args>
|
template <class Args>
|
||||||
class_& def_init(Args const& = Args());
|
class_& def_init(Args const& = Args());
|
||||||
|
|
||||||
class_& def_init();
|
template <class Args, class CallPolicy>
|
||||||
|
class_& def_init(Args const&, CallPolicy policy);
|
||||||
|
|
||||||
|
// exposing member functions
|
||||||
|
template <class F>
|
||||||
|
class_& def(char const* name, F f);
|
||||||
|
|
||||||
|
template <class Fn, class CallPolies>
|
||||||
|
class_& def(char const* name, Fn fn, CallPolies);
|
||||||
|
|
||||||
|
// exposing operators
|
||||||
|
template <<i>unspecified</i>>
|
||||||
|
class_& def(<a href="operators.html#operator_-spec">detail::operator_</a><unspecified>);
|
||||||
|
|
||||||
|
// exposing data members
|
||||||
|
template <class D>
|
||||||
|
class_& def_readonly(char const* name, D T::*pm);
|
||||||
|
|
||||||
|
template <class D>
|
||||||
|
class_& 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& fget);
|
||||||
|
void add_property(char const* name, ref const& fget, ref const& fset);
|
||||||
|
|
||||||
|
// accessing the Python class object
|
||||||
ref object() const;
|
ref object() const;
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h4><a name="class_-spec-ctors"></a>Class template <code>class_</code>
|
<h4><a name="class_-spec-ctors"></a>Class template <code>class_</code> constructors</h4>
|
||||||
constructors</h4>
|
|
||||||
<pre>
|
<pre>
|
||||||
class_()
|
class_();
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<dl class="function-semantics">
|
<dl class="function-semantics">
|
||||||
@@ -169,7 +274,7 @@ class_()
|
|||||||
Python classes without user intervention.
|
Python classes without user intervention.
|
||||||
</dl>
|
</dl>
|
||||||
<pre>
|
<pre>
|
||||||
class_(char const* name)
|
class_(char const* name);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<dl class="function-semantics">
|
<dl class="function-semantics">
|
||||||
@@ -186,27 +291,75 @@ class_(char const* name)
|
|||||||
|
|
||||||
<h4><a name="class_-spec-modifiers"></a>Class template <code>class_</code>
|
<h4><a name="class_-spec-modifiers"></a>Class template <code>class_</code>
|
||||||
modifier functions</h4>
|
modifier functions</h4>
|
||||||
<pre>
|
|
||||||
template <class F>
|
|
||||||
class_& def(char const* name, F f)
|
|
||||||
|
|
||||||
template <class Fn, class CallPolicy>
|
<pre>
|
||||||
class_& def(char const* name, Fn f, CallPolicy policy)
|
class_& def_init();
|
||||||
|
|
||||||
|
template <class Args>
|
||||||
|
class_& def_init(Args const& argument_types);
|
||||||
|
|
||||||
|
template <class Args, class CallPolicies>
|
||||||
|
class_& def_init(Args const& argument_types, CallPolicies policies);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<dl class="function-semantics">
|
<dl class="function-semantics">
|
||||||
<dt><b>Requires:</b> <code>f</code> is a non-null pointer-to-function or
|
<dt><b>Requires:</b> <code>Args</code> is an <a
|
||||||
pointer-to-member-function. <code>name</code> is a ntbs which conforms to
|
href="../../../mpl/doc/Sequences.html">MPL sequence</a> of C++ argument
|
||||||
Python's <a href=
|
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><args<>,Holder>()</code>,
|
||||||
|
|
||||||
|
<code><a href=
|
||||||
|
"make_function.html#make_constructor-spec">make_constructor</a><Args,Holder>()</code>, or
|
||||||
|
|
||||||
|
<code><a href=
|
||||||
|
"make_function.html#make_constructor-spec">make_constructor</a><Args,Holder>(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 <class F>
|
||||||
|
class_& def(char const* name, F f);
|
||||||
|
|
||||||
|
template <class Fn, class CallPolicies>
|
||||||
|
class_& 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
|
"http://www.python.org/doc/2.2/ref/identifiers.html">identifier
|
||||||
naming rules</a>. In the first form, the return type of
|
naming rules</a>. In the first form, the return type of
|
||||||
<code>f</code> is not a reference and is not a pointer other
|
<code>f</code> is not a reference and is not a pointer other
|
||||||
than <code>char const*</code> or <code>PyObject*</code>. In the
|
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>.
|
href="CallPolicies.html">CallPolicies</a>.
|
||||||
|
|
||||||
<dt><b>Effects:</b> Adds the result of <code><a href=
|
<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, policies)</code> to
|
||||||
the Boost.Python extension class being defined, with the given
|
the Boost.Python extension class being defined, with the given
|
||||||
<code>name</code>. If the extension class already has an attribute named
|
<code>name</code>. If the extension class already has an attribute named
|
||||||
<code><i>name</i></code>, the usual <a href=
|
<code><i>name</i></code>, the usual <a href=
|
||||||
@@ -214,37 +367,110 @@ class_& def(char const* name, Fn f, CallPolicy policy)
|
|||||||
|
|
||||||
<dt><b>Returns:</b> <code>*this</code>
|
<dt><b>Returns:</b> <code>*this</code>
|
||||||
</dl>
|
</dl>
|
||||||
<pre>
|
|
||||||
template <class Args>
|
|
||||||
class_& def_init(Args const& argument_types)
|
|
||||||
|
|
||||||
class_& def_init()
|
<pre>
|
||||||
|
template <<i>unspecified</i>>
|
||||||
|
class_& def(<a href="operators.html#operator_-spec">detail::operator_</a><unspecified>);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<dl class="function-semantics">
|
<dl class="function-semantics">
|
||||||
<dt><b>Requires:</b> in the first form, argument_types must be an <a
|
<dt><b>Effects:</b> Adds a Python <a
|
||||||
href="../../../mpl/doc/Sequences.html">MPL sequence</a> of C++ argument
|
href="http://www.python.org/doc/ref/specialnames.html">special
|
||||||
types (<i>A1, A2,... AN</i>) such that if
|
method</a> as described <a href="operators.html">here</a>.
|
||||||
<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 the result of <code><a href=
|
<dt><b>Returns:</b> <code>*this</code>
|
||||||
"make_function.html#make_constructor-spec">make_constructor</a><T,Args,HolderGenerator>()</code>
|
</dl>
|
||||||
to the Boost.Python extension class being defined with the name
|
|
||||||
"__init__". If the 2nd form is used, an unspecified empty <a href=
|
<pre>
|
||||||
"../../../mpl/doc/Sequences.html">MPL sequence</a> type is substituted
|
template <class F>
|
||||||
for <code>Args</code>. If the extension class already has an "__init__"
|
class_& setattr(char const* name, ref x);
|
||||||
attribute, the usual <a href="http:overloading.html">overloading
|
</pre>
|
||||||
procedure</a> applies.
|
|
||||||
|
<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(), name, x.get());</code>
|
||||||
|
|
||||||
|
<dt><b>Returns:</b> <code>*this</code>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
void add_property(char const* name, ref const& fget);
|
||||||
|
void add_property(char const* name, ref const& fget, ref const& 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>Returns:</b> <code>*this</code>
|
||||||
|
|
||||||
<dt><b>Rationale:</b> Allows users to easily expose a class' constructor
|
<dt><b>Rationale:</b> Allows users to easily expose a class'
|
||||||
to Python.
|
data member such that it can be inspected from Python with a
|
||||||
|
natural syntax.
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<pre>
|
||||||
|
template <class D>
|
||||||
|
class_& 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->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 <class D>
|
||||||
|
class_& 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->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>
|
<h4><a name="class_-spec-observers"></a>Class template <code>class_</code>
|
||||||
observer functions</h4>
|
observer functions</h4>
|
||||||
<pre>
|
<pre>
|
||||||
@@ -264,39 +490,42 @@ ref object() const;
|
|||||||
<h3><a name="args-spec"></a>Class template
|
<h3><a name="args-spec"></a>Class template
|
||||||
<code>args<T1, T2,</code>...<code>TN></code></h3>
|
<code>args<T1, T2,</code>...<code>TN></code></h3>
|
||||||
|
|
||||||
<p>Essentially an alias for <code>boost::mpl::type_list</code> which users
|
<p>A conveniently-named <a
|
||||||
can use in <code>def_init</code> calls to make their code more readable.
|
href="../../../mpl/doc/Sequences.html">MPL sequence</a> which
|
||||||
Currently it is in the global unnammed namespace, but that will probably
|
users pass to <code><a
|
||||||
change.
|
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>
|
<h4><a name="args-spec-synopsis"></a>Class template <code>args</code>
|
||||||
synopsis</h4>
|
synopsis</h4>
|
||||||
<pre>
|
<pre>
|
||||||
namespace
|
namespace boost { namespace python
|
||||||
{
|
{
|
||||||
template <T1 = <i>unspecified</i>,...TN = <i>unspecified</i>>
|
template <T1 = <i>unspecified</i>,...TN = <i>unspecified</i>>
|
||||||
struct args : ::boost::mpl::type_list<T1,...TN>::type
|
struct args
|
||||||
{};
|
{};
|
||||||
}
|
}}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><a name="bases-spec"></a>Class template
|
<h3><a name="bases-spec"></a>Class template
|
||||||
<code>bases<T1, T2,</code>...<code>TN></code></h3>
|
<code>bases<T1, T2,</code>...<code>TN></code></h3>
|
||||||
|
|
||||||
<p>Essentially an alias for <code>boost::mpl::type_list</code> which users
|
<p>An <a
|
||||||
can use in <code>class_<</code>...<code>></code> instantiations to
|
href="../../../mpl/doc/Sequences.html">MPL sequence</a> which
|
||||||
make their code more readable. Currently it is in the global unnammed
|
can be used in <code>class_<</code>...<code>></code>
|
||||||
namespace, but that will probably change.
|
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>
|
<h4><a name="bases-spec-synopsis"></a>Class template <code>bases</code>
|
||||||
synopsis</h4>
|
synopsis</h4>
|
||||||
<pre>
|
<pre>
|
||||||
namespace
|
namespace boost { namespace python
|
||||||
{
|
{
|
||||||
template <T1 = <i>unspecified</i>,...TN = <i>unspecified</i>>
|
template <T1 = <i>unspecified</i>,...TN = <i>unspecified</i>>
|
||||||
struct bases : ::boost::mpl::type_list<T1,...TN>::type
|
struct bases
|
||||||
{};
|
{};
|
||||||
}
|
}}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h2><a name="examples"></a>Example(s)</h2>
|
<h2><a name="examples"></a>Example(s)</h2>
|
||||||
@@ -311,24 +540,47 @@ class Foo : public Bar, public Baz
|
|||||||
|
|
||||||
std::string const& name() { return m_name; }
|
std::string const& name() { return m_name; }
|
||||||
void name(char const*);
|
void name(char const*);
|
||||||
|
|
||||||
|
double value; // public data
|
||||||
private:
|
private:
|
||||||
...
|
...
|
||||||
};
|
};
|
||||||
</pre>
|
</pre>
|
||||||
A corresponding Boost.Python extension class can be created with:
|
|
||||||
|
A corresponding Boost.Python extension class can be created with:
|
||||||
<pre>
|
<pre>
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
ref foo =
|
|
||||||
class_<Foo,bases<Bar,Baz> >()
|
ref foo = class_<Foo,bases<Bar,Baz> >()
|
||||||
.def_init(args<int,char const*>())
|
.def_init(args<int,char const*>())
|
||||||
.def_init(args<double>())
|
.def_init(args<double>())
|
||||||
.def("get_name", &Foo::get_name, return_internal_reference<>())
|
.def("get_name", &Foo::get_name, return_internal_reference<>())
|
||||||
.def("set_name", &Foo::set_name)
|
.def("set_name", &Foo::set_name)
|
||||||
|
.def_readwrite("value", &Foo::value)
|
||||||
.object();
|
.object();
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<a name="footnote_1">[1]</a> By "previously-exposed" we mean that the for each
|
||||||
|
<code>B</code> in <code>bases</code>, an instance of
|
||||||
|
<code>class_<B></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
|
||||||
|
"<code>.add(...)</code>.
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
module m("module_name");
|
||||||
|
m.add(class_<Base>()
|
||||||
|
.def_init());
|
||||||
|
m.add(class_<Derived, bases<Base>>()
|
||||||
|
.def_init());
|
||||||
|
</pre>
|
||||||
|
|
||||||
Revised
|
Revised
|
||||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
<!--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" -->
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
"header">
|
"header">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<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>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<h1 align="center">Boost.Python</h1>
|
<h1 align="center">Boost.Python</h1>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
<code>copy_const_reference</code></h3>
|
<code>copy_const_reference</code></h3>
|
||||||
|
|
||||||
<p><code>copy_const_reference</code> is a model of <a href=
|
<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
|
used to wrap C++ functions returning a reference-to-const type such that
|
||||||
the referenced value is copied into a new Python object.
|
the referenced value is copied into a new Python object.
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
<code>copy_non_const_reference</code></h3>
|
<code>copy_non_const_reference</code></h3>
|
||||||
|
|
||||||
<p><code>copy_non_const_reference</code> is a model of <a href=
|
<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
|
used to wrap C++ functions returning a reference-to-non-const type such
|
||||||
that the referenced value is copied into a new Python object.
|
that the referenced value is copied into a new Python object.
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ PyObject* postcall(PyObject*, PyObject* result);
|
|||||||
<code>default_result_converter</code></h3>
|
<code>default_result_converter</code></h3>
|
||||||
|
|
||||||
<p><code>default_result_converter</code> is a model of <a href=
|
<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
|
used to wrap C++ functions returning non-pointer types, <code>char
|
||||||
const*</code>, and <code>PyObject*</code>, by-value.
|
const*</code>, and <code>PyObject*</code>, by-value.
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
"header">
|
"header">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<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>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<h1 align="center">Boost.Python</h1>
|
<h1 align="center">Boost.Python</h1>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<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">
|
<link rel="stylesheet" type="text/css" href="../boost.css">
|
||||||
|
|
||||||
<title>Boost.Python - <{{header}}></title>
|
<title>Boost.Python - <boost/python/errors.hpp></title>
|
||||||
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
||||||
"header">
|
"header">
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<dl class="page-index">
|
<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>
|
<dd>
|
||||||
<dl class="page-index">
|
<dl class="page-index">
|
||||||
@@ -44,6 +44,7 @@
|
|||||||
<dt><a href="#handle_exception-spec">handle_exception</a>
|
<dt><a href="#handle_exception-spec">handle_exception</a>
|
||||||
|
|
||||||
<dt><a href="#expect_non_null-spec">expect_non_null</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>
|
</dl>
|
||||||
|
|
||||||
<dt><a href="#examples">Examples</a>
|
<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>
|
"http://www.python.org/doc/2.2/api/exceptionHandling.html#l2h-71">PyErr_Occurred()</a>
|
||||||
returns a value convertible to <code>true</code>.
|
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>
|
<pre>
|
||||||
namespace boost { namespace python
|
namespace boost { namespace python
|
||||||
{
|
{
|
||||||
@@ -117,9 +118,7 @@ void handle_exception() throw();
|
|||||||
an enclosing <code>try</code> block.
|
an enclosing <code>try</code> block.
|
||||||
</dl>
|
</dl>
|
||||||
<pre>
|
<pre>
|
||||||
<a name="expect_non_null-spec">PyObject* expect_non_null(PyObject* x);</a>
|
<a name="expect_non_null-spec">template <class T> T* expect_non_null(T* x);</a>
|
||||||
|
|
||||||
template <class T> T* expect_non_null(T* x);
|
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<dl class="expect_non_null-semantics">
|
<dl class="expect_non_null-semantics">
|
||||||
@@ -135,6 +134,16 @@ template <class T> T* expect_non_null(T* x);
|
|||||||
return 0 on error.
|
return 0 on error.
|
||||||
</dl>
|
</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 <a href=
|
||||||
|
"#error_already_set-spec">error_already_set</a>();</code>
|
||||||
|
</dl>
|
||||||
|
|
||||||
<h2><a name="examples"></a>Examples</h2>
|
<h2><a name="examples"></a>Examples</h2>
|
||||||
<pre>
|
<pre>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -223,7 +232,7 @@ same_name2(PyObject* args, PyObject* keywords)
|
|||||||
|
|
||||||
<p>Revised
|
<p>Revised
|
||||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
<!--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" -->
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
"header">
|
"header">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<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>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<h1 align="center">Boost.Python</h1>
|
<h1 align="center">Boost.Python</h1>
|
||||||
|
|||||||
@@ -16,9 +16,8 @@
|
|||||||
"100%" summary="header">
|
"100%" summary="header">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<td valign="top" width="300">
|
||||||
<h3><a href="http://www.boost.org"><img height="86"
|
<h3><a href="../../../../index.htm"><img height="86" width="277" alt=
|
||||||
width="277" alt="C++ Boost" src="../c++boost.gif"
|
"C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
|
||||||
border="0"></a></h3>
|
|
||||||
|
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<h1 class="c1">Boost.Python</h1>
|
<h1 class="c1">Boost.Python</h1>
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ std::size_t length_if_string(PyObject* p)
|
|||||||
if (!converter.convertible())
|
if (!converter.convertible())
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return converter().size();
|
return converter(p).size();
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
"header">
|
"header">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<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>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<h1 align="center">Boost.Python</h1>
|
<h1 align="center">Boost.Python</h1>
|
||||||
@@ -26,6 +27,7 @@
|
|||||||
<dt><a href="rationale.html">Rationale</a></dt>
|
<dt><a href="rationale.html">Rationale</a></dt>
|
||||||
<dt><a href="definitions.html">Definitions</a></dt>
|
<dt><a href="definitions.html">Definitions</a></dt>
|
||||||
<dt><a href="faq.html">Frequently Asked Questions (FAQs)</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="bibliography.html">Bibliography</a></dt>
|
||||||
<dt><a href="acknowledgments.html">Acknowledgments</a></dt>
|
<dt><a href="acknowledgments.html">Acknowledgments</a></dt>
|
||||||
</dl>
|
</dl>
|
||||||
|
|||||||
209
doc/v2/instance_holder.html
Executable file
209
doc/v2/instance_holder.html
Executable 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 - <boost/python/instance_holder.hpp></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 <boost/python/instance_holder.hpp></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><boost/python/instance_holder.hpp></code> provides
|
||||||
|
<code>class 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 <class SmartPtr, class Value>
|
||||||
|
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<class A0>
|
||||||
|
pointer_holder(PyObject*,A0 a0)
|
||||||
|
:m_p(new Value(a0))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class A0,class A1>
|
||||||
|
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<SmartPtr>())
|
||||||
|
return &this->m_p;
|
||||||
|
|
||||||
|
// ...and an instance of the SmartPtr's element_type, if the
|
||||||
|
// pointer is non-null
|
||||||
|
return python::type_id<Value>() == dst_t ? &*this->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">© Copyright <a href=
|
||||||
|
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002. All
|
||||||
|
Rights Reserved.
|
||||||
|
|
||||||
364
doc/v2/iterator.html
Normal file
364
doc/v2/iterator.html
Normal 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 - <boost/python/iterator.hpp></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 <boost/python/iterator.hpp></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><boost/python/iterator.hpp></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<C,P></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 <class Container
|
||||||
|
, class NextPolicies = <i>unspecified</i>>
|
||||||
|
struct iterator : reference<PyObject*>
|
||||||
|
{
|
||||||
|
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<NextPolicies>(&iterators<Container>::begin, &iterators<Container>::end)
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<dt><b>Postconditions:</b> <code>this->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<></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 <class C>
|
||||||
|
struct iterators
|
||||||
|
{
|
||||||
|
typedef typename C::[const_]iterator iterator;
|
||||||
|
static iterator begin(C& x);
|
||||||
|
static iterator end(C& 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&);
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<dl class="function-semantics">
|
||||||
|
<dt><b>Returns:</b> <code>x.begin()</code>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
static iterator end(C&);
|
||||||
|
</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> <class NextPolicies, class Target, class Accessor1, class Accessor2>
|
||||||
|
reference<PyObject*> range(Accessor1 start, Accessor2 finish);
|
||||||
|
|
||||||
|
template <class NextPolicies, class Accessor1, class Accessor2>
|
||||||
|
reference<PyObject*> range(Accessor1 start, Accessor2 finish);
|
||||||
|
|
||||||
|
template <class Accessor1, class Accessor2>
|
||||||
|
reference<PyObject*> 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>, <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 (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 (T::*)(</code><i>arguments...</i><code>)</code> <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 <boost/python/module.hpp>
|
||||||
|
#include <boost/python/class.hpp>
|
||||||
|
#include <boost/python/return_internal_reference.hpp>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using namespace boost::python;
|
||||||
|
BOOST_PYTHON_MODULE_INIT(demo)
|
||||||
|
{
|
||||||
|
module("demo")
|
||||||
|
.add(
|
||||||
|
class_<std::vector<double> >("dvec")
|
||||||
|
.def("__iter__", iterator<std::vector<double> >())
|
||||||
|
...
|
||||||
|
)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
</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>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
||||||
|
Abrahams</a> 2002. All Rights Reserved.</i>
|
||||||
|
|
||||||
@@ -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 - <boost/python/lvalue_from_python.hpp></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 <boost/python/lvalue_from_python.hpp></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><boost/python/lvalue_from_python.hpp></code> supplies
|
|
||||||
a facility for extracting C++ objects from within instances of a
|
|
||||||
given Python type. This is typically useful for dealing with
|
|
||||||
"traditional" 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&</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& 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 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 <
|
|
||||||
PyTypeObject const* python_type
|
|
||||||
, class Value
|
|
||||||
, class PythonObject = Value
|
|
||||||
, class Extract = <i>unspecified</i>
|
|
||||||
>
|
|
||||||
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&</code>, <code>Value const&</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 <class Class, class Member, Member (Class::*mp)>
|
|
||||||
struct get_member
|
|
||||||
{
|
|
||||||
static Member& execute(Class& c);
|
|
||||||
};
|
|
||||||
}}
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h4><a name="get_member-spec-statics"></a>Class template <code>get_member</code> static functions</h4>
|
|
||||||
<pre>
|
|
||||||
Member& execute(Class& 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 <boost/python/reference.hpp>
|
|
||||||
#include <boost/python/module.hpp>
|
|
||||||
|
|
||||||
// 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("noddy_cache")
|
|
||||||
.def("is_cached", is_cached)
|
|
||||||
.def("set_cache", set_cache)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h3>Python code</h3>
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
>>> import noddy
|
|
||||||
>>> n = noddy.new_noddy()
|
|
||||||
>>> import noddy_cache
|
|
||||||
>>> noddy_cache.is_cached(n)
|
|
||||||
0
|
|
||||||
>>> noddy_cache.set_cache(n)
|
|
||||||
>>> noddy_cache.is_cached(n)
|
|
||||||
1
|
|
||||||
>>> 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>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
|
||||||
Abrahams</a> 2002. All Rights Reserved.</i>
|
|
||||||
|
|
||||||
283
doc/v2/lvalue_from_pytype.html
Executable file
283
doc/v2/lvalue_from_pytype.html
Executable 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 - <boost/python/lvalue_from_python.hpp></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 <boost/python/lvalue_from_pytype.hpp></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><boost/python/lvalue_from_pytype.hpp></code> supplies
|
||||||
|
a facility for extracting C++ objects from within Python instances
|
||||||
|
of a given type. This is typically useful for dealing with
|
||||||
|
"traditional" 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&</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 <class Extractor, PyTypeObject const* python_type>
|
||||||
|
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 <class InstanceType>
|
||||||
|
struct extract_identity
|
||||||
|
{
|
||||||
|
static InstanceType& execute(InstanceType& c);
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h4><a name="extract_identity-spec-statics"></a>Class template <code>extract_identity</code> static functions</h4>
|
||||||
|
<pre>
|
||||||
|
InstanceType& execute(InstanceType& 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 <class InstanceType, class MemberType, MemberType (InstanceType::*member)>
|
||||||
|
struct extract_member
|
||||||
|
{
|
||||||
|
static MemberType& execute(InstanceType& c);
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h4><a name="extract_member-spec-statics"></a>Class template <code>extract_member</code> static functions</h4>
|
||||||
|
<pre>
|
||||||
|
static MemberType& execute(InstanceType& 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 <boost/python/reference.hpp>
|
||||||
|
#include <boost/python/module.hpp>
|
||||||
|
|
||||||
|
// definition lifted from the Python docs
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
} noddy_NoddyObject;
|
||||||
|
|
||||||
|
using namespace boost::python;
|
||||||
|
static reference<PyObject> 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("noddy_cache")
|
||||||
|
.def("is_cached", is_cached)
|
||||||
|
.def("set_cache", set_cache)
|
||||||
|
;
|
||||||
|
|
||||||
|
// register Noddy lvalue converter
|
||||||
|
lvalue_from_pytype<extract_identity<noddy_NoddyObject>,&noddy_NoddyType>();
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h3>Python code</h3>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
>>> import noddy
|
||||||
|
>>> n = noddy.new_noddy()
|
||||||
|
>>> import noddy_cache
|
||||||
|
>>> noddy_cache.is_cached(n)
|
||||||
|
0
|
||||||
|
>>> noddy_cache.set_cache(n)
|
||||||
|
>>> noddy_cache.is_cached(n)
|
||||||
|
1
|
||||||
|
>>> 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>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
||||||
|
Abrahams</a> 2002. All Rights Reserved.</i>
|
||||||
|
|
||||||
@@ -78,12 +78,17 @@ objects::function* make_function(F f, Policies const& policies)
|
|||||||
<a name=
|
<a name=
|
||||||
"make_constructor-spec">template <class T, class ArgList, class Generator>
|
"make_constructor-spec">template <class T, class ArgList, class Generator>
|
||||||
objects::function* make_constructor();</a>
|
objects::function* make_constructor();</a>
|
||||||
|
|
||||||
|
template <class ArgList, class Generator, class Policies>
|
||||||
|
objects::function* make_constructor(Policies const& policies)
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<dl class="function-semantics">
|
<dl class="function-semantics">
|
||||||
<dt><b>Requires:</b> <code>T</code> is a class type. <code>ArgList</code>
|
<dt><b>Requires:</b> <code>T</code> is a class
|
||||||
is an <a href="../../../mpl/doc/Sequences.html">MPL sequence</a> of C++
|
type. <code>Policies</code> is a model of <a
|
||||||
argument types (<i>A1, A2,... AN</i>) such that if
|
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
|
<code>a1, a2</code>... <code>aN</code> are objects of type
|
||||||
<i>A1, A2,... AN</i> respectively, the expression <code>new
|
<i>A1, A2,... AN</i> respectively, the expression <code>new
|
||||||
Generator::apply<T>::type(a1, a2</code>... <code>aN</code>) is
|
Generator::apply<T>::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
|
from Python, expects its first argument to be a Boost.Python extension
|
||||||
class object. It converts its remaining its arguments to C++ and passes
|
class object. It converts its remaining its arguments to C++ and passes
|
||||||
them to the constructor of a dynamically-allocated
|
them to the constructor of a dynamically-allocated
|
||||||
<code>Generator::apply<T>::type</code> object. The result is
|
<code>Generator::apply<T>::type</code> object, which is
|
||||||
installed in the extension class object.
|
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
|
<dt><b>Returns:</b> The new Python callable object
|
||||||
</dl>
|
</dl>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
<code>manage_new_object</code></h3>
|
<code>manage_new_object</code></h3>
|
||||||
|
|
||||||
<p><code>manage_new_object</code> is a model of <a href=
|
<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
|
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
|
with a <i>new-expression</i>, and expect the caller to take responsibility
|
||||||
for deleting that object.
|
for deleting that object.
|
||||||
@@ -105,7 +105,7 @@ using namespace boost::python;
|
|||||||
BOOST_PYTHON_MODULE_INIT(my_module)
|
BOOST_PYTHON_MODULE_INIT(my_module)
|
||||||
{
|
{
|
||||||
module("my_module")
|
module("my_module")
|
||||||
.def("make_foo", make_foo)
|
.def("make_foo", make_foo, return_value_policy<manage_new_object>)
|
||||||
.add(
|
.add(
|
||||||
class_<Foo>()
|
class_<Foo>()
|
||||||
.def("get_x", &Foo::get_x)
|
.def("get_x", &Foo::get_x)
|
||||||
|
|||||||
@@ -60,7 +60,8 @@
|
|||||||
|
|
||||||
<h2><a name="introduction"></a>Introduction</h2>
|
<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>
|
<h2><a name="macros"></a>Macros</h2>
|
||||||
|
|
||||||
|
|||||||
531
doc/v2/operators.html
Executable file
531
doc/v2/operators.html
Executable 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 - <boost/python/operators.hpp></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 <boost/python/operators.hpp></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><boost/python/operators.hpp></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_<>::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 <class T> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator+=(self_t, T);
|
||||||
|
template <class T> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator-=(self_t, T);
|
||||||
|
template <class T> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator*=(self_t, T);
|
||||||
|
template <class T> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator/=(self_t, T);
|
||||||
|
template <class T> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator%=(self_t, T);
|
||||||
|
template <class T> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator>>=(self_t, T);
|
||||||
|
template <class T> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator<<=(self_t, T);
|
||||||
|
template <class T> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator&=(self_t, T);
|
||||||
|
template <class T> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator^=(self_t, T);
|
||||||
|
template <class T> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator|=(self_t, T);
|
||||||
|
|
||||||
|
// comparisons
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator==(L const&, R const&);
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator!=(L const&, R const&);
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator<(L const&, R const&);
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator>(L const&, R const&);
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator<=(L const&, R const&);
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator>=(L const&, R const&);
|
||||||
|
|
||||||
|
// non-member operations
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator+(L const&, R const&);
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator-(L const&, R const&);
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator*(L const&, R const&);
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator/(L const&, R const&);
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator%(L const&, R const&);
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator>>(L const&, R const&);
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator<<(L const&, R const&);
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator&(L const&, R const&);
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator^(L const&, R const&);
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> operator|(L const&, R const&);
|
||||||
|
template <class L, class R> <a
|
||||||
|
href="#operator_-spec">operator_</a><<i>unspecified</i>> pow(L const&, R const&);
|
||||||
|
|
||||||
|
// unary operations
|
||||||
|
<a href="#operator_-spec">operator_</a><<i>unspecified</i>> operator-(self_t);
|
||||||
|
<a href="#operator_-spec">operator_</a><<i>unspecified</i>> operator+(self_t);
|
||||||
|
<a href="#operator_-spec">operator_</a><<i>unspecified</i>> operator~(self_t);
|
||||||
|
|
||||||
|
// value operations
|
||||||
|
<a href="#operator_-spec">operator_</a><<i>unspecified</i>> int_(self_t);
|
||||||
|
<a href="#operator_-spec">operator_</a><<i>unspecified</i>> long_(self_t);
|
||||||
|
<a href="#operator_-spec">operator_</a><<i>unspecified</i>> float_(self_t);
|
||||||
|
<a href="#operator_-spec">operator_</a><<i>unspecified</i>> complex_(self_t);
|
||||||
|
<a href="#operator_-spec">operator_</a><<i>unspecified</i>> 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_<>::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><T></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 += r</code>
|
||||||
|
<td><code>__iadd__</code>
|
||||||
|
<td><code>x += y</code>
|
||||||
|
|
||||||
|
<tr><td><code>self -= r</code>
|
||||||
|
<td><code>__isub__</code>
|
||||||
|
<td><code>x -= y</code>
|
||||||
|
|
||||||
|
<tr><td><code>self *= r</code>
|
||||||
|
<td><code>__imul__</code>
|
||||||
|
<td><code>x *= y</code>
|
||||||
|
|
||||||
|
<tr><td><code>self /= r</code>
|
||||||
|
<td><code>__idiv__</code>
|
||||||
|
<td><code>x /= y</code>
|
||||||
|
|
||||||
|
<tr><td><code>self %= r</code>
|
||||||
|
<td><code>__imod__</code>
|
||||||
|
<td><code>x %= y</code>
|
||||||
|
|
||||||
|
<tr><td><code>self >>= r</code>
|
||||||
|
<td><code>__irshift__</code>
|
||||||
|
<td><code>x >>= y</code>
|
||||||
|
|
||||||
|
<tr><td><code>self <<= r</code>
|
||||||
|
<td><code>__ilshift__</code>
|
||||||
|
<td><code>x <<= y</code>
|
||||||
|
|
||||||
|
<tr><td><code>self &= r</code>
|
||||||
|
<td><code>__iand__</code>
|
||||||
|
<td><code>x &= y</code>
|
||||||
|
|
||||||
|
<tr><td><code>self ^= r</code>
|
||||||
|
<td><code>__ixor__</code>
|
||||||
|
<td><code>x ^= y</code>
|
||||||
|
|
||||||
|
<tr><td><code>self |= r</code>
|
||||||
|
<td><code>__ior__</code>
|
||||||
|
<td><code>x |= 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><T></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 == r <td>__eq__ <td>x == y
|
||||||
|
<td>x == y, y == x
|
||||||
|
|
||||||
|
<tr><td>l == self <td>__eq__ <td>y == x
|
||||||
|
<td>y == x, x == y
|
||||||
|
|
||||||
|
<tr><td>self != r <td>__ne__ <td>x != y
|
||||||
|
<td>x != y, y != x
|
||||||
|
|
||||||
|
<tr><td>l != self <td>__ne__ <td>y != x
|
||||||
|
<td>y != x, x != y
|
||||||
|
|
||||||
|
<tr><td>self < r <td>__lt__ <td>x < y
|
||||||
|
<td>x < y, y > x
|
||||||
|
|
||||||
|
<tr><td>l < self <td>__gt__ <td>y < x
|
||||||
|
<td>y > x, x < y
|
||||||
|
|
||||||
|
<tr><td>self > r <td>__gt__ <td>x > y
|
||||||
|
<td>x > y, y < x
|
||||||
|
|
||||||
|
<tr><td>l > self <td>__lt__ <td>y > x
|
||||||
|
<td>y < x, x > y
|
||||||
|
|
||||||
|
<tr><td>self <= r <td>__le__ <td>x <= y
|
||||||
|
<td>x <= y, y >= x
|
||||||
|
|
||||||
|
<tr><td>l <= self <td>__ge__ <td>y <= x
|
||||||
|
<td>y >= x, x <= y
|
||||||
|
|
||||||
|
<tr><td>self >= r <td>__ge__ <td>x >= y
|
||||||
|
<td>x >= y, y <= x
|
||||||
|
|
||||||
|
<tr><td>l >= self <td>__le__ <td>y >= x
|
||||||
|
<td>y <= x, x >= 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 "<code>__r</code>"
|
||||||
|
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 + r <td>__add__ <td>x + y
|
||||||
|
<tr><td>l + self <td>__radd__ <td>y + x
|
||||||
|
|
||||||
|
<tr><td>self - r <td>__sub__ <td>x - y
|
||||||
|
<tr><td>l - self <td>__rsub__ <td>y - x
|
||||||
|
|
||||||
|
<tr><td>self * r <td>__mul__ <td>x * y
|
||||||
|
<tr><td>l * self <td>__rmul__ <td>y * x
|
||||||
|
|
||||||
|
<tr><td>self / r <td>__div__ <td>x / y
|
||||||
|
<tr><td>l / self <td>__rdiv__ <td>y / x
|
||||||
|
|
||||||
|
<tr><td>self % r <td>__mod__ <td>x % y
|
||||||
|
<tr><td>l % self <td>__rmod__ <td>y % x
|
||||||
|
|
||||||
|
<tr><td>self >> r <td>__rshift__ <td>x >> y
|
||||||
|
<tr><td>l >> self <td>__rrshift__ <td>y >> x
|
||||||
|
|
||||||
|
<tr><td>self << r <td>__lshift__ <td>x << y
|
||||||
|
<tr><td>l << self <td>__rlshift__ <td>y << x
|
||||||
|
|
||||||
|
<tr><td>self & r <td>__and__ <td>x & y
|
||||||
|
<tr><td>l & self <td>__rand__ <td>y & x
|
||||||
|
|
||||||
|
<tr><td>self ^ r <td>__xor__ <td>x ^ y
|
||||||
|
<tr><td>l ^ self <td>__rxor__ <td>y ^ x
|
||||||
|
|
||||||
|
<tr><td>self | r <td>__or__ <td>x | y
|
||||||
|
<tr><td>l | self <td>__ror__ <td>y | x
|
||||||
|
|
||||||
|
<tr><td>pow(self, r) <td>__pow__ <td>pow(x, y)
|
||||||
|
<tr><td>pow(l, self) <td>__rpow__ <td>pow(y, 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<double>(x)
|
||||||
|
<tr><td>str<td>__str__ <td><a href="../../../conversion/lexical_cast.htm#lexical_cast">lexical_cast</a><std::string>(x)
|
||||||
|
|
||||||
|
</code>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3><a name="other-spec"></a>Class Template <code>other</code></h3>
|
||||||
|
|
||||||
|
<p>Instances of <code>other<T></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<T></code>. Use
|
||||||
|
<code>other<T></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 <class T>
|
||||||
|
struct other
|
||||||
|
{
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
|
||||||
|
<h3><a name="operator_-spec"></a>Class Template <code>detail::operator_</code></h3>
|
||||||
|
|
||||||
|
<p>Instantiations of <code>detail::operator_<></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_<>::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 <<i>unspecified</i>>
|
||||||
|
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 <boost/python/module.hpp>
|
||||||
|
#include <boost/python/class.hpp>
|
||||||
|
#include <boost/python/operators.hpp>
|
||||||
|
#include <boost/operators.hpp>
|
||||||
|
|
||||||
|
struct number
|
||||||
|
: boost::<a href="../../../utility/operators.htm#grpd_oprs">integer_arithmetic</a><number>
|
||||||
|
{
|
||||||
|
number(long x_) : x(x_) {}
|
||||||
|
operator long() const { return x; }
|
||||||
|
|
||||||
|
number& operator+=(number const& rhs)
|
||||||
|
{ x += rhs }
|
||||||
|
number& operator-=(number const& rhs);
|
||||||
|
{ x -= rhs }
|
||||||
|
number& operator*=(number const& rhs)
|
||||||
|
{ x *= rhs }
|
||||||
|
number& operator/=(number const& rhs);
|
||||||
|
{ x /= rhs }
|
||||||
|
number& operator%=(number const& rhs);
|
||||||
|
{ x %= rhs }
|
||||||
|
|
||||||
|
long x;
|
||||||
|
};
|
||||||
|
|
||||||
|
using namespace boost::python;
|
||||||
|
BOOST_PYTHON_MODULE_INIT(demo)
|
||||||
|
{
|
||||||
|
module("demo")
|
||||||
|
.add(
|
||||||
|
class_<number>("number")
|
||||||
|
// 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>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
||||||
|
Abrahams</a> 2002. All Rights Reserved.</i>
|
||||||
|
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
"header">
|
"header">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<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>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<h1 align="center">Boost.Python</h1>
|
<h1 align="center">Boost.Python</h1>
|
||||||
|
|||||||
44
doc/v2/progress_reports.html
Normal file
44
doc/v2/progress_reports.html
Normal 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>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave Abrahams</a>
|
||||||
|
2002. All Rights Reserved.</i></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -93,11 +93,11 @@
|
|||||||
which can be similarly used to prevent copying of referents.
|
which can be similarly used to prevent copying of referents.
|
||||||
|
|
||||||
<p><code>ptr(p)</code> returns an instance of <code><a
|
<p><code>ptr(p)</code> returns an instance of <code><a
|
||||||
href="#pointer_wrapper">pointer_wrapper<></a></code>, which
|
href="#pointer_wrapper-spec">pointer_wrapper<></a></code>, which
|
||||||
can be detected using the <code><a
|
can be detected using the <code><a
|
||||||
href="#pointer_wrapper">is_pointer_wrapper<></a></code>
|
href="#is_pointer_wrapper-spec">is_pointer_wrapper<></a></code>
|
||||||
metafunction; <code><a
|
metafunction; <code><a
|
||||||
href="#pointer_wrapper">unwrap_pointer<></a></code> is a
|
href="#unwrap_pointer-spec">unwrap_pointer<></a></code> is a
|
||||||
metafunction which extracts the original pointer type from a
|
metafunction which extracts the original pointer type from a
|
||||||
<code>pointer_wrapper<></code>. These classes can be thought
|
<code>pointer_wrapper<></code>. These classes can be thought
|
||||||
of as implementation details.
|
of as implementation details.
|
||||||
@@ -252,7 +252,7 @@ void pass_as_arg(expensive_to_copy* x, PyObject* f)
|
|||||||
|
|
||||||
<p>Revised
|
<p>Revised
|
||||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
<!--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" -->
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
"header">
|
"header">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<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>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<h1 align="center">Boost.Python</h1>
|
<h1 align="center">Boost.Python</h1>
|
||||||
|
|||||||
@@ -1,191 +1,280 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
<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">
|
<link rel="stylesheet" type="text/css" href="../boost.css">
|
||||||
|
|
||||||
<title>Boost.Python - Reference</title>
|
<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=
|
<table border="0" cellpadding="7" cellspacing="0" width="100%"
|
||||||
"reference">
|
summary="reference">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<td valign="top" width="300">
|
||||||
<h3><a href="http://www.boost.org"><img height="86" width="277" alt=
|
<h3><a href="http://www.boost.org"><img height="86" width=
|
||||||
"C++ Boost" src="../c++boost.gif" border="0"></a></h3>
|
"277" alt="C++ Boost" src="../../../../c++boost.gif" border=
|
||||||
|
"0"></a></h3>
|
||||||
|
|
||||||
<td valign="top">
|
<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>
|
</table>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<h2>Contents</h2>
|
<h2>Contents</h2>
|
||||||
|
|
||||||
<dl class="Reference">
|
<dl class="Reference">
|
||||||
|
<dt><a href="#concepts">Concepts</a>
|
||||||
|
|
||||||
<dt><a href="#high_level">High Level Components</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="#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>
|
</dl>
|
||||||
<a name="high_level"></a>
|
<hr>
|
||||||
|
<!-- xxxxx -->
|
||||||
|
|
||||||
<h2>High Level Components</h2>
|
<h2><a name="concepts">Concepts</a></h2>
|
||||||
|
|
||||||
<dl class="index">
|
<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>
|
<dd>
|
||||||
<a name="general_purpose"></a>
|
|
||||||
|
|
||||||
<h3>General Purpose</h3>
|
|
||||||
|
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
|
<dt><a href="class.html#classes">Classes</a>
|
||||||
<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>
|
|
||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href="class.html#classes">Classes</a>
|
<dt><a href="class.html#class_-spec">class_</a>
|
||||||
|
|
||||||
<dd>
|
<dt><a href="class.html#bases-spec">bases</a>
|
||||||
<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#args-spec">args</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>
|
|
||||||
</dl>
|
</dl>
|
||||||
</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>
|
<h3>Models of CallPolicies</h3>
|
||||||
|
|
||||||
@@ -195,15 +284,18 @@
|
|||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href="default_call_policies.html#classes">Classes</a>
|
<dt><a href=
|
||||||
|
"default_call_policies.html#classes">Classes</a>
|
||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href=
|
<dt><a href=
|
||||||
"default_call_policies.html#default_call_policies-spec">default_call_policies</a>
|
"default_call_policies.html#default_call_policies-spec">
|
||||||
|
default_call_policies</a>
|
||||||
|
|
||||||
<dt><a href=
|
<dt><a href=
|
||||||
"default_call_policies.html#default_result_converter-spec">default_result_converter</a>
|
"default_call_policies.html#default_result_converter-spec">
|
||||||
|
default_result_converter</a>
|
||||||
</dl>
|
</dl>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
@@ -212,25 +304,28 @@
|
|||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href="return_internal_reference.html#classes">Classes</a>
|
<dt><a href=
|
||||||
|
"return_internal_reference.html#classes">Classes</a>
|
||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href=
|
<dt><a href=
|
||||||
"return_internal_reference.html#return_internal_reference-spec">
|
"return_internal_reference.html#return_internal_reference-spec">
|
||||||
return_internal_reference</a>
|
return_internal_reference</a>
|
||||||
</dl>
|
</dl>
|
||||||
</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>
|
<dd>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href="return_value_policy.html#classes">Classes</a>
|
<dt><a href=
|
||||||
|
"return_value_policy.html#classes">Classes</a>
|
||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href=
|
<dt><a href=
|
||||||
"return_value_policy.html#return_value_policy-spec">return_value_policy</a>
|
"return_value_policy.html#return_value_policy-spec">return_value_policy</a>
|
||||||
</dl>
|
</dl>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -240,179 +335,28 @@
|
|||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<dl class="index">
|
<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>
|
<dd>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href=
|
<dt><a href=
|
||||||
"with_custodian_and_ward.html#with_custodian_and_ward-spec">with_custodian_and_ward</a>
|
"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.html#with_custodian_and_ward_postcall-spec">
|
||||||
with_custodian_and_ward_postcall</a>
|
with_custodian_and_ward_postcall</a>
|
||||||
</dl>
|
</dl>
|
||||||
</dl>
|
</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">
|
<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=
|
<dt><a href=
|
||||||
"copy_non_const_reference.html">copy_non_const_reference.hpp</a>
|
"to_python_indirect.html">to_python_indirect.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>
|
|
||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
@@ -420,7 +364,7 @@
|
|||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href=
|
<dt><a href=
|
||||||
"to_python_indirect.html#to_python_indirect-spec">to_python_indirect</a>
|
"to_python_indirect.html#to_python_indirect-spec">to_python_indirect</a>
|
||||||
</dl>
|
</dl>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -437,43 +381,231 @@
|
|||||||
"to_python_value.html#to_python_value-spec">to_python_value</a>
|
"to_python_value.html#to_python_value-spec">to_python_value</a>
|
||||||
</dl>
|
</dl>
|
||||||
</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>
|
<dd>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href="type_from_python.html#classes">Classes</a>
|
<dt><a href=
|
||||||
|
"copy_const_reference.html#classes">Classes</a>
|
||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href=
|
<dt><a href=
|
||||||
"type_from_python.html#type_from_python-spec">type_from_python</a>
|
"copy_const_reference.html#copy_const_reference-spec">
|
||||||
|
copy_const_reference</a>
|
||||||
</dl>
|
</dl>
|
||||||
</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>
|
<dd>
|
||||||
<dl class="index">
|
<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>
|
<dd>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href=
|
<dt><a href=
|
||||||
"value_from_python.html#value_from_python-spec">value_from_python</a>
|
"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>
|
||||||
</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>
|
</dl>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<p>Revised
|
<p>Revised
|
||||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
<!--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" -->
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
||||||
|
|
||||||
|
|
||||||
<p><i>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
<p class="c3">© Copyright <a href=
|
||||||
Abrahams</a> 2002. All Rights Reserved.</i>
|
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002. All
|
||||||
|
Rights Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
<code>reference_existing_object</code></h3>
|
<code>reference_existing_object</code></h3>
|
||||||
|
|
||||||
<p><code>reference_existing_object</code> is a model of <a href=
|
<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++
|
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
|
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
|
return value is not copied. A new Python object is created which contains a
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
<code>return_value_policy</code> instantiations are simply models
|
<code>return_value_policy</code> instantiations are simply models
|
||||||
of <a href=
|
of <a href=
|
||||||
"CallPolicies.html">CallPolicies</a> which are composed of a <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>.
|
"CallPolicies.html">CallPolicies</a>.
|
||||||
|
|
||||||
<h2><a name="classes"></a>Classes</h2>
|
<h2><a name="classes"></a>Classes</h2>
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
<th>Default
|
<th>Default
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>ResultConverterGenerator</code>
|
<td><a href="ResultConverter.html#ResultConverterGenerator-concept">ResultConverterGenerator</a>
|
||||||
|
|
||||||
<td>A model of <a href=
|
<td>A model of <a href=
|
||||||
"ResultConverterGenerator.html">ResultConverterGenerator</a>.
|
"ResultConverterGenerator.html">ResultConverterGenerator</a>.
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ struct tag_to_noddy
|
|||||||
|
|
||||||
BOOST_PYTHON_MODULE_INIT(to_python_converter)
|
BOOST_PYTHON_MODULE_INIT(to_python_converter)
|
||||||
{
|
{
|
||||||
module to_python("to_python_converter")
|
module("to_python_converter")
|
||||||
.def("make_tag", make_tag)
|
.def("make_tag", make_tag)
|
||||||
;
|
;
|
||||||
to_python_converter<tag, tag_to_noddy>();
|
to_python_converter<tag, tag_to_noddy>();
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ of its first argument type to python as extension class instances, using the own
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
Instantiations of <code>to_python_indirect</code> are models of <a
|
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>
|
<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
|
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 <class T>
|
template <class T>
|
||||||
struct apply
|
struct apply
|
||||||
{
|
{
|
||||||
|
|||||||
101
doc/v2/to_python_value.html
Normal file
101
doc/v2/to_python_value.html
Normal 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 - <boost/python/to_python_value.hpp></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
|
||||||
|
<boost/python/to_python_value.hpp></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 <class T>
|
||||||
|
struct to_python_value
|
||||||
|
{
|
||||||
|
typedef typename <a href="../../../type_traits/index.htm#transformations">add_reference</a><
|
||||||
|
typename <a href="../../../type_traits/index.htm#transformations">add_const</a><T>::type
|
||||||
|
>::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() == 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>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
||||||
|
Abrahams</a> 2002. All Rights Reserved.</i>
|
||||||
|
|
||||||
219
doc/v2/type_id.html
Executable file
219
doc/v2/type_id.html
Executable 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 - <boost/python/type_id.hpp></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 <boost/python/type_id.hpp></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><boost/python/type_id.hpp></code> provides types and
|
||||||
|
functions for runtime type identification like those of of
|
||||||
|
<code><typeinfo></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><type_info>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// constructor
|
||||||
|
type_info(std::type_info const& = typeid(void));
|
||||||
|
|
||||||
|
// comparisons
|
||||||
|
bool operator<(type_info const& rhs) const;
|
||||||
|
bool operator==(type_info const& 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& = 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<(type_info const& 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& 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><type_info></code>
|
||||||
|
as a private base class supplies operators <code><=</code>,
|
||||||
|
<code>>=</code>, <code>></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& operator<<(std::ostream&s, type_info const&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 <class T> 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 <boost/python/type_id.hpp>
|
||||||
|
|
||||||
|
// Returns true iff the user passes an int argument
|
||||||
|
template <class T>
|
||||||
|
bool is_int(T x)
|
||||||
|
{
|
||||||
|
using boost::python::type_id;
|
||||||
|
return type_id<T>() == type_id<int>();
|
||||||
|
}
|
||||||
|
</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">© Copyright <a href=
|
||||||
|
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002. All
|
||||||
|
Rights Reserved.
|
||||||
|
|
||||||
289
doc/v2/with_custodian_and_ward.html
Normal file
289
doc/v2/with_custodian_and_ward.html
Normal 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 - <boost/python/with_custodian_and_ward.hpp></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 <boost/python/with_custodian_and_ward.hpp></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<>::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 <std::size_t custodian, std::size_t ward, class Base = default_call_policies>
|
||||||
|
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>() != 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 <std::size_t custodian, std::size_t ward, class Base = default_call_policies>
|
||||||
|
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 != 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>() != 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 <std::size_t owner_arg = 1, class Base = default_call_policies>
|
||||||
|
struct return_internal_reference
|
||||||
|
: with_custodian_and_ward_postcall<0, owner_arg, Base>
|
||||||
|
{
|
||||||
|
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>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
||||||
|
Abrahams</a> 2002. All Rights Reserved.</i>
|
||||||
|
|
||||||
BIN
example/Attic/project.zip
Normal file
BIN
example/Attic/project.zip
Normal file
Binary file not shown.
39
example/Jamfile
Normal file
39
example/Jamfile
Normal 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 ;
|
||||||
@@ -19,6 +19,3 @@ Examples for the cross-module support are provided by:
|
|||||||
ivect.cpp
|
ivect.cpp
|
||||||
See also: libs/python/doc/cross_module.html
|
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.
|
|
||||||
|
|||||||
@@ -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
BIN
example/project.zip
Normal file
Binary file not shown.
@@ -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");
|
|
||||||
}
|
|
||||||
29
include/boost/python/from_python.hpp → include/boost/python/arg_from_python.hpp
Normal file → Executable file
29
include/boost/python/from_python.hpp → include/boost/python/arg_from_python.hpp
Normal file → Executable file
@@ -3,34 +3,37 @@
|
|||||||
// copyright notice appears in all copies. This software is provided
|
// copyright notice appears in all copies. This software is provided
|
||||||
// "as is" without express or implied warranty, and with no claim as
|
// "as is" without express or implied warranty, and with no claim as
|
||||||
// to its suitability for any purpose.
|
// to its suitability for any purpose.
|
||||||
#ifndef FROM_PYTHON_DWA2002128_HPP
|
#ifndef ARG_FROM_PYTHON_DWA2002128_HPP
|
||||||
# define 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 {
|
namespace boost { namespace python {
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct from_python
|
struct arg_from_python
|
||||||
: converter::select_from_python<T>::type
|
: converter::select_arg_from_python<T>::type
|
||||||
{
|
{
|
||||||
typedef typename converter::select_from_python<T>::type base;
|
typedef typename converter::select_arg_from_python<T>::type base;
|
||||||
from_python(PyObject*);
|
arg_from_python(PyObject*);
|
||||||
};
|
};
|
||||||
|
|
||||||
// specialization for PyObject*
|
// specialization for PyObject*
|
||||||
template <>
|
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; }
|
bool convertible() const { return true; }
|
||||||
PyObject* operator()(PyObject* source) const { return source; }
|
PyObject* operator()(PyObject* source) const { return source; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
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; }
|
bool convertible() const { return true; }
|
||||||
PyObject*const& operator()(PyObject*const& source) const { return source; }
|
PyObject*const& operator()(PyObject*const& source) const { return source; }
|
||||||
};
|
};
|
||||||
@@ -39,11 +42,11 @@ struct from_python<PyObject* const&>
|
|||||||
// implementations
|
// implementations
|
||||||
//
|
//
|
||||||
template <class T>
|
template <class T>
|
||||||
inline from_python<T>::from_python(PyObject* source)
|
inline arg_from_python<T>::arg_from_python(PyObject* source)
|
||||||
: base(source)
|
: base(source)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}} // namespace boost::python
|
}} // namespace boost::python
|
||||||
|
|
||||||
#endif // FROM_PYTHON_DWA2002128_HPP
|
#endif // ARG_FROM_PYTHON_DWA2002128_HPP
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#if !defined(BOOST_PP_IS_ITERATING)
|
||||||
|
|
||||||
// Copyright David Abrahams 2002. Permission to copy, use,
|
// Copyright David Abrahams 2002. Permission to copy, use,
|
||||||
// modify, sell and distribute this software is granted provided this
|
// modify, sell and distribute this software is granted provided this
|
||||||
// copyright notice appears in all copies. This software is provided
|
// copyright notice appears in all copies. This software is provided
|
||||||
@@ -5,33 +7,35 @@
|
|||||||
// to its suitability for any purpose.
|
// to its suitability for any purpose.
|
||||||
#ifndef ARGS_DWA2002323_HPP
|
#ifndef ARGS_DWA2002323_HPP
|
||||||
# define ARGS_DWA2002323_HPP
|
# define ARGS_DWA2002323_HPP
|
||||||
# include <boost/config.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>
|
|
||||||
|
|
||||||
# if !defined(__EDG_VERSION__) || __EDG_VERSION__ > 245
|
# include <boost/python/detail/preprocessor.hpp>
|
||||||
namespace boost { namespace python {
|
|
||||||
|
|
||||||
|
# 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
|
// A type list for specifying arguments
|
||||||
template < BOOST_MPL_LIST_DEFAULT_PARAMETERS(typename A, boost::mpl::null_argument) >
|
template < BOOST_PYTHON_ENUM_WITH_DEFAULT(BOOST_PYTHON_MAX_ARITY, typename A, boost::mpl::null_argument) >
|
||||||
struct args : boost::mpl::type_list< BOOST_MPL_LIST_PARAMETERS(A) >::type
|
struct args : boost::mpl::type_list< BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, A) >::type
|
||||||
{};
|
{};
|
||||||
|
|
||||||
}} // namespace boost::python
|
}} // namespace boost::python
|
||||||
|
|
||||||
# else // slow template instantiators need this other version with
|
# else // slow template instantiators need this other version with
|
||||||
// explicit specializations of mpl::size<> and
|
// explicit specializations of mpl::size<> and
|
||||||
// mpl::at<>. Eventually, however, inheritance from mpl::list
|
// mpl::at<>. Eventually, however, inheritance from mpl::list
|
||||||
// *should* be eliminated and the two versions unified, just in
|
// *should* be eliminated and the two versions unified, just in
|
||||||
// order to get true arity independence
|
// 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
|
struct args
|
||||||
{};
|
{};
|
||||||
|
|
||||||
@@ -42,32 +46,45 @@ namespace boost { namespace mpl {
|
|||||||
template <class T> struct size;
|
template <class T> struct size;
|
||||||
template <long N, class Seq> struct at;
|
template <long N, class Seq> struct at;
|
||||||
|
|
||||||
# ifndef BOOST_PYTHON_GENERATE_CODE
|
# define BOOST_PP_ITERATION_PARAMS_1 (4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/args.hpp>, 1))
|
||||||
# include <boost/python/preprocessed/args.hpp>
|
# include BOOST_PP_ITERATE()
|
||||||
# endif
|
|
||||||
|
|
||||||
# define BOOST_PYTHON_ARGS_SIZE(index,ignored) \
|
# define BOOST_PP_ITERATION_PARAMS_1 (4, (0, BOOST_PYTHON_MAX_ARITY - 1, <boost/python/args.hpp>, 2))
|
||||||
template <BOOST_PP_ENUM_PARAMS(index, class A)> \
|
# include BOOST_PP_ITERATE()
|
||||||
struct size<boost::python::args<BOOST_PP_ENUM_PARAMS(index, A)> > \
|
|
||||||
{ \
|
|
||||||
BOOST_STATIC_CONSTANT(long, value = index); \
|
|
||||||
}; \
|
|
||||||
|
|
||||||
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(
|
}} // namespace boost::mpl
|
||||||
BOOST_PP_DEC(BOOST_PYTHON_ARITY_START), BOOST_PP_DEC(BOOST_PYTHON_ARITY_FINISH)
|
|
||||||
, BOOST_PYTHON_ARGS_AT, data)
|
# endif // __EDG_VERSION__
|
||||||
|
|
||||||
}}
|
# endif // ARGS_DWA2002323_HPP
|
||||||
# endif
|
|
||||||
#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
|
||||||
|
|||||||
101
include/boost/python/back_reference.hpp
Normal file
101
include/boost/python/back_reference.hpp
Normal 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
|
||||||
36
include/boost/python/base_type_traits.hpp
Executable file
36
include/boost/python/base_type_traits.hpp
Executable 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
|
||||||
20
include/boost/python/borrowed.hpp
Executable file
20
include/boost/python/borrowed.hpp
Executable 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
|
||||||
@@ -1,49 +1,63 @@
|
|||||||
|
#if !defined(BOOST_PP_IS_ITERATING)
|
||||||
|
|
||||||
// Copyright David Abrahams 2002. Permission to copy, use,
|
// Copyright David Abrahams 2002. Permission to copy, use,
|
||||||
// modify, sell and distribute this software is granted provided this
|
// modify, sell and distribute this software is granted provided this
|
||||||
// copyright notice appears in all copies. This software is provided
|
// copyright notice appears in all copies. This software is provided
|
||||||
// "as is" without express or implied warranty, and with no claim as
|
// "as is" without express or implied warranty, and with no claim as
|
||||||
// to its suitability for any purpose.
|
// to its suitability for any purpose.
|
||||||
#ifndef CALL_DWA2002411_HPP
|
|
||||||
# define CALL_DWA2002411_HPP
|
|
||||||
|
|
||||||
# include <boost/python/converter/callback.hpp>
|
# ifndef CALL_DWA2002411_HPP
|
||||||
# include <boost/python/detail/preprocessor.hpp>
|
# define CALL_DWA2002411_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>
|
|
||||||
|
|
||||||
namespace boost { namespace python {
|
# include <boost/type.hpp>
|
||||||
|
|
||||||
# ifndef BOOST_PYTHON_GENERATE_CODE
|
# include <boost/python/converter/arg_to_python.hpp>
|
||||||
# include <boost/python/preprocessed/call.hpp>
|
# include <boost/python/converter/return_from_python.hpp>
|
||||||
# endif
|
# include <boost/python/detail/preprocessor.hpp>
|
||||||
|
# include <boost/python/detail/void_return.hpp>
|
||||||
|
|
||||||
# define BOOST_PYTHON_CALL_FUNCTION(nargs,ignored) \
|
# include <boost/preprocessor/comma_if.hpp>
|
||||||
template < \
|
# include <boost/preprocessor/iterate.hpp>
|
||||||
class R \
|
# include <boost/preprocessor/repeat.hpp>
|
||||||
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) \
|
|
||||||
)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
}} // 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
|
||||||
|
|||||||
@@ -1,50 +1,63 @@
|
|||||||
|
#if !defined(BOOST_PP_IS_ITERATING)
|
||||||
|
|
||||||
// Copyright David Abrahams 2002. Permission to copy, use,
|
// Copyright David Abrahams 2002. Permission to copy, use,
|
||||||
// modify, sell and distribute this software is granted provided this
|
// modify, sell and distribute this software is granted provided this
|
||||||
// copyright notice appears in all copies. This software is provided
|
// copyright notice appears in all copies. This software is provided
|
||||||
// "as is" without express or implied warranty, and with no claim as
|
// "as is" without express or implied warranty, and with no claim as
|
||||||
// to its suitability for any purpose.
|
// to its suitability for any purpose.
|
||||||
#ifndef CALL_METHOD_DWA2002411_HPP
|
# ifndef CALL_METHOD_DWA2002411_HPP
|
||||||
# define CALL_METHOD_DWA2002411_HPP
|
# define CALL_METHOD_DWA2002411_HPP
|
||||||
|
|
||||||
# include <boost/python/converter/callback.hpp>
|
# include <boost/type.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>
|
|
||||||
|
|
||||||
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/preprocessor/comma_if.hpp>
|
||||||
# include <boost/python/preprocessed/call_method.hpp>
|
# include <boost/preprocessor/iterate.hpp>
|
||||||
# endif
|
# include <boost/preprocessor/repeat.hpp>
|
||||||
|
|
||||||
# define BOOST_PYTHON_CALL_METHOD_FUNCTION(nargs,ignored) \
|
namespace boost { namespace python {
|
||||||
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) \
|
|
||||||
)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
}} // 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
106
include/boost/python/cast.hpp
Executable 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
|
||||||
@@ -9,10 +9,9 @@
|
|||||||
# include <boost/python/class_fwd.hpp>
|
# include <boost/python/class_fwd.hpp>
|
||||||
# include <boost/python/bases.hpp>
|
# include <boost/python/bases.hpp>
|
||||||
# include <boost/python/args.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/object/class.hpp>
|
||||||
# include <boost/python/converter/type_id.hpp>
|
# include <boost/python/type_id.hpp>
|
||||||
# include <boost/python/detail/wrap_function.hpp>
|
|
||||||
# include <boost/python/detail/member_function_cast.hpp>
|
# include <boost/python/detail/member_function_cast.hpp>
|
||||||
# include <boost/python/object/class_converters.hpp>
|
# include <boost/python/object/class_converters.hpp>
|
||||||
# include <boost/type_traits/ice.hpp>
|
# include <boost/type_traits/ice.hpp>
|
||||||
@@ -24,34 +23,47 @@
|
|||||||
# include <boost/python/object/class_wrapper.hpp>
|
# include <boost/python/object/class_wrapper.hpp>
|
||||||
# include <boost/python/data_members.hpp>
|
# include <boost/python/data_members.hpp>
|
||||||
# include <boost/utility.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
|
namespace detail
|
||||||
{
|
{
|
||||||
struct write_type_id;
|
struct write_type_id;
|
||||||
|
|
||||||
template <class T, class Prev = detail::not_specified>
|
template <class T, class Prev = detail::not_specified>
|
||||||
struct select_held_type;
|
struct select_held_type;
|
||||||
|
|
||||||
template <class T1, class T2, class T3>
|
template <class T1, class T2, class T3>
|
||||||
struct has_noncopyable;
|
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
|
// Register a to_python converter for a class T, depending on the
|
||||||
// type of the first (tag) argument. The 2nd argument is a pointer
|
// 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
|
// to the type of holder that must be created. The 3rd argument is a
|
||||||
// reference to the Python type object to be created.
|
// reference to the Python type object to be created.
|
||||||
template <class T, class Holder>
|
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);
|
objects::class_wrapper<T,Holder> x(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tag dispatched to have no effect.
|
// Tag dispatched to have no effect.
|
||||||
template <class T, class Holder>
|
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
|
class class_ : public objects::class_base
|
||||||
{
|
{
|
||||||
|
typedef objects::class_base base;
|
||||||
|
|
||||||
typedef class_<T,X1,X2,X3> self;
|
typedef class_<T,X1,X2,X3> self;
|
||||||
BOOST_STATIC_CONSTANT(bool, is_copyable = (!detail::has_noncopyable<X1,X2,X3>::value));
|
BOOST_STATIC_CONSTANT(bool, is_copyable = (!detail::has_noncopyable<X1,X2,X3>::value));
|
||||||
|
|
||||||
typedef typename detail::select_held_type<
|
typedef typename detail::select_held_type<
|
||||||
X1, typename detail::select_held_type<
|
X1, typename detail::select_held_type<
|
||||||
X2, typename detail::select_held_type<
|
X2, typename detail::select_held_type<
|
||||||
X3
|
X3
|
||||||
>::type>::type>::type held_type;
|
>::type>::type>::type held_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Automatically derive the class name - only works on some
|
// Automatically derive the class name - only works on some
|
||||||
// compilers because type_info::name is sometimes mangled (gcc)
|
// compilers because type_info::name is sometimes mangled (gcc)
|
||||||
class_();
|
class_();
|
||||||
|
|
||||||
// Construct with the class name. [ Would have used a default
|
// Construct with the class name. [ Would have used a default
|
||||||
// argument but gcc-2.95.2 choked on typeid(T).name() as a default
|
// argument but gcc-2.95.2 choked on typeid(T).name() as a default
|
||||||
// parameter value]
|
// 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
|
// 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>
|
template <class F>
|
||||||
self& def(char const* name, F f)
|
self& def(char const* name, F f)
|
||||||
{
|
{
|
||||||
// Use function::add_to_namespace to achieve overloading if
|
this->def_impl(name, f, default_call_policies(), 0, &f);
|
||||||
// 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)
|
|
||||||
)));
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Fn, class CallPolicy>
|
template <class Arg1T, class Arg2T>
|
||||||
self& def(char const* name, Fn fn, CallPolicy policy)
|
self& def(char const* name, Arg1T arg1, Arg2T const& arg2, char const* doc = 0)
|
||||||
{
|
{
|
||||||
this->def(name
|
dispatch_def(name, arg1, arg2, doc, &arg2);
|
||||||
, 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)
|
|
||||||
);
|
|
||||||
|
|
||||||
return *this;
|
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
|
// Define the constructor with the given Args, which should be an
|
||||||
// MPL sequence of types.
|
// MPL sequence of types.
|
||||||
template <class Args>
|
template <class Args>
|
||||||
self& def_init(Args const&)
|
self& def_init(Args const&)
|
||||||
{
|
{
|
||||||
def("__init__",
|
return this->def("__init__",
|
||||||
make_constructor<Args>(
|
python::make_constructor<Args>(
|
||||||
// Using runtime type selection works around a CWPro7 bug.
|
// Using runtime type selection works around a CWPro7 bug.
|
||||||
objects::select_holder<T,held_type>((held_type*)0).get()
|
objects::select_holder<T,held_type>((held_type*)0).get()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Args, class CallPolicy>
|
template <class Args, class CallPolicyOrDoc>
|
||||||
self& def_init(Args const&, CallPolicy policy)
|
self& def_init(Args const&, CallPolicyOrDoc const& policy_or_doc, char const* doc = 0)
|
||||||
{
|
{
|
||||||
def("__init__",
|
typedef detail::def_helper<CallPolicyOrDoc> helper;
|
||||||
make_constructor<Args>(
|
|
||||||
policy
|
return this->def(
|
||||||
|
"__init__",
|
||||||
|
python::make_constructor<Args>(
|
||||||
|
helper::get_policy(policy_or_doc)
|
||||||
// Using runtime type selection works around a CWPro7 bug.
|
// Using runtime type selection works around a CWPro7 bug.
|
||||||
, objects::select_holder<T,held_type>((held_type*)0).get()
|
, objects::select_holder<T,held_type>((held_type*)0).get()
|
||||||
)
|
)
|
||||||
|
, helper::get_doc(policy_or_doc, doc)
|
||||||
);
|
);
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the default constructor.
|
// Define the default constructor.
|
||||||
@@ -158,32 +168,100 @@ class class_ : public objects::class_base
|
|||||||
template <class D>
|
template <class D>
|
||||||
self& def_readonly(char const* name, D T::*pm)
|
self& def_readonly(char const* name, D T::*pm)
|
||||||
{
|
{
|
||||||
ref fget(make_getter(pm));
|
this->add_property(name, make_getter(pm));
|
||||||
this->add_property(name, fget);
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class D>
|
template <class D>
|
||||||
self& def_readwrite(char const* name, D T::*pm)
|
self& def_readwrite(char const* name, D T::*pm)
|
||||||
{
|
{
|
||||||
ref fget(make_getter(pm));
|
return this->add_property(name, make_getter(pm), make_setter(pm));
|
||||||
ref fset(make_setter(pm));
|
}
|
||||||
this->add_property(name, fget, fset);
|
|
||||||
|
// 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 *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the underlying object
|
// Pickle support
|
||||||
// ref object() const;
|
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 objects::class_id class_id;
|
||||||
|
|
||||||
typedef typename detail::select_bases<X1
|
typedef typename detail::select_bases<X1
|
||||||
, typename detail::select_bases<X2
|
, typename detail::select_bases<X2
|
||||||
, typename boost::python::detail::select_bases<X3>::type
|
, typename boost::python::detail::select_bases<X3>::type
|
||||||
>::type
|
>::type
|
||||||
>::type bases;
|
>::type bases;
|
||||||
|
|
||||||
// A helper class which will contain an array of id objects to be
|
// A helper class which will contain an array of id objects to be
|
||||||
// passed to the base class constructor
|
// passed to the base class constructor
|
||||||
struct id_vector
|
struct id_vector
|
||||||
@@ -192,13 +270,13 @@ class class_ : public objects::class_base
|
|||||||
id_vector()
|
id_vector()
|
||||||
{
|
{
|
||||||
// Stick the derived class id into the first element of the array
|
// 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.
|
// Write the rest of the elements into succeeding positions.
|
||||||
class_id* p = ids + 1;
|
class_id* p = ids + 1;
|
||||||
mpl::for_each<bases, void, detail::write_type_id>::execute(&p);
|
mpl::for_each<bases, void, detail::write_type_id>::execute(&p);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_STATIC_CONSTANT(
|
BOOST_STATIC_CONSTANT(
|
||||||
std::size_t, size = mpl::size<bases>::value + 1);
|
std::size_t, size = mpl::size<bases>::value + 1);
|
||||||
class_id ids[size];
|
class_id ids[size];
|
||||||
@@ -212,28 +290,43 @@ class class_ : public objects::class_base
|
|||||||
//
|
//
|
||||||
template <class T, class X1, class X2, class X3>
|
template <class T, class X1, class X2, class X3>
|
||||||
inline class_<T,X1,X2,X3>::class_()
|
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
|
// register converters
|
||||||
objects::register_class_from_python<T,bases>();
|
objects::register_class_from_python<T,bases>();
|
||||||
|
|
||||||
detail::register_copy_constructor<T>(
|
detail::register_copy_constructor<T>(
|
||||||
mpl::bool_t<is_copyable>()
|
mpl::bool_t<is_copyable>()
|
||||||
, objects::select_holder<T,held_type>((held_type*)0).get()
|
, objects::select_holder<T,held_type>((held_type*)0).get()
|
||||||
, this->object());
|
, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class X1, class X2, class X3>
|
template <class T, class X1, class X2, class X3>
|
||||||
inline class_<T,X1,X2,X3>::class_(char const* name)
|
inline class_<T,X1,X2,X3>::class_(char const* name, char const* doc)
|
||||||
: class_base(name, id_vector::size, id_vector().ids)
|
: base(name, id_vector::size, id_vector().ids, doc)
|
||||||
{
|
{
|
||||||
// register converters
|
// register converters
|
||||||
objects::register_class_from_python<T,bases>();
|
objects::register_class_from_python<T,bases>();
|
||||||
|
|
||||||
detail::register_copy_constructor<T>(
|
detail::register_copy_constructor<T>(
|
||||||
mpl::bool_t<is_copyable>()
|
mpl::bool_t<is_copyable>()
|
||||||
, objects::select_holder<T,held_type>((held_type*)0).get()
|
, 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
|
namespace detail
|
||||||
@@ -252,9 +345,9 @@ namespace detail
|
|||||||
typedef void type;
|
typedef void type;
|
||||||
|
|
||||||
// Here's the runtime behavior
|
// 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>();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ namespace detail
|
|||||||
|
|
||||||
template <
|
template <
|
||||||
class T // class being wrapped
|
class T // class being wrapped
|
||||||
, class X1 = detail::not_specified
|
// arbitrarily-ordered optional arguments. Full qualification needed for MSVC6
|
||||||
, class X2 = detail::not_specified
|
, class X1 = ::boost::python::detail::not_specified
|
||||||
, class X3 = detail::not_specified
|
, class X2 = ::boost::python::detail::not_specified
|
||||||
|
, class X3 = ::boost::python::detail::not_specified
|
||||||
>
|
>
|
||||||
class class_;
|
class class_;
|
||||||
|
|
||||||
|
|||||||
336
include/boost/python/converter/arg_from_python.hpp
Executable file
336
include/boost/python/converter/arg_from_python.hpp
Executable 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
|
||||||
246
include/boost/python/converter/arg_to_python.hpp
Executable file
246
include/boost/python/converter/arg_to_python.hpp
Executable 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
|
||||||
35
include/boost/python/converter/arg_to_python_base.hpp
Executable file
35
include/boost/python/converter/arg_to_python_base.hpp
Executable 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
|
||||||
@@ -7,87 +7,106 @@
|
|||||||
# define BUILTIN_CONVERTERS_DWA2002124_HPP
|
# define BUILTIN_CONVERTERS_DWA2002124_HPP
|
||||||
# include <boost/python/detail/wrap_python.hpp>
|
# include <boost/python/detail/wrap_python.hpp>
|
||||||
# include <boost/python/detail/none.hpp>
|
# include <boost/python/detail/none.hpp>
|
||||||
# include <boost/python/reference.hpp>
|
# include <boost/python/handle.hpp>
|
||||||
# include <string>
|
# include <string>
|
||||||
# include <complex>
|
# 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 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
|
// Provide specializations of to_python_value
|
||||||
template <class T> struct to_python_value;
|
template <class T> struct to_python_value;
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
// Since there's no registry lookup, always report the existence of
|
||||||
|
// a converter.
|
||||||
struct builtin_to_python
|
struct builtin_to_python
|
||||||
{
|
{
|
||||||
static bool convertible() { return true; }
|
static bool convertible() { return true; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace converter
|
// Use expr to create the PyObject corresponding to x
|
||||||
{
|
# define BOOST_PYTHON_RETURN_TO_PYTHON_BY_VALUE(T, expr) \
|
||||||
template <class T> struct callback_to_python;
|
template <> struct to_python_value<T&> \
|
||||||
BOOST_PYTHON_DECL PyObject* do_call_to_python(char);
|
: detail::builtin_to_python \
|
||||||
BOOST_PYTHON_DECL PyObject* do_call_to_python(char const*);
|
{ \
|
||||||
BOOST_PYTHON_DECL PyObject* do_call_to_python(PyObject*);
|
inline PyObject* operator()(T const& x) const \
|
||||||
BOOST_PYTHON_DECL PyObject* do_callback_to_python(PyObject*);
|
{ \
|
||||||
}
|
return (expr); \
|
||||||
|
} \
|
||||||
# define BOOST_PYTHON_CALL_TO_PYTHON_BY_VALUE(T, expr) \
|
}; \
|
||||||
template <> struct to_python_value<T&> \
|
template <> struct to_python_value<T const&> \
|
||||||
: detail::builtin_to_python \
|
: detail::builtin_to_python \
|
||||||
{ \
|
{ \
|
||||||
PyObject* operator()(T const& x) const \
|
inline PyObject* operator()(T const& x) const \
|
||||||
{ \
|
{ \
|
||||||
return (expr); \
|
return (expr); \
|
||||||
} \
|
} \
|
||||||
}; \
|
|
||||||
template <> struct to_python_value<T const&> \
|
|
||||||
: detail::builtin_to_python \
|
|
||||||
{ \
|
|
||||||
PyObject* operator()(T const& x) const \
|
|
||||||
{ \
|
|
||||||
return (expr); \
|
|
||||||
} \
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# define BOOST_PYTHON_CALLBACK_TO_PYTHON_BY_VALUE(T, expr) \
|
# define BOOST_PYTHON_ARG_TO_PYTHON_BY_VALUE(T, expr) \
|
||||||
namespace converter \
|
namespace converter \
|
||||||
{ \
|
{ \
|
||||||
template <> struct callback_to_python< T > \
|
template <> struct arg_to_python< T > \
|
||||||
{ \
|
: handle<> \
|
||||||
callback_to_python(T const& x) \
|
{ \
|
||||||
: m_held(expr) {} \
|
arg_to_python(T const& x) \
|
||||||
PyObject* get() const \
|
: python::handle<>(expr) {} \
|
||||||
{ return m_held.get(); } \
|
}; \
|
||||||
private: \
|
|
||||||
ref m_held; \
|
|
||||||
}; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# define BOOST_PYTHON_TO_PYTHON_BY_VALUE(T, expr) \
|
// Specialize argument and return value converters for T using expr
|
||||||
BOOST_PYTHON_CALL_TO_PYTHON_BY_VALUE(T,expr) \
|
# define BOOST_PYTHON_TO_PYTHON_BY_VALUE(T, expr) \
|
||||||
BOOST_PYTHON_CALLBACK_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) \
|
# define BOOST_PYTHON_TO_INT(T) \
|
||||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(signed T, PyInt_FromLong(x)) \
|
BOOST_PYTHON_TO_PYTHON_BY_VALUE(signed T, PyInt_FromLong(x)) \
|
||||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned 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))
|
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(char)
|
||||||
|
|
||||||
BOOST_PYTHON_TO_INT(short)
|
BOOST_PYTHON_TO_INT(short)
|
||||||
BOOST_PYTHON_TO_INT(int)
|
BOOST_PYTHON_TO_INT(int)
|
||||||
BOOST_PYTHON_TO_INT(long)
|
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
|
# 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, converter::do_return_to_python(x))
|
||||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(char const*, converter::do_call_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(std::string, PyString_FromString(x.c_str()))
|
||||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(float, PyFloat_FromDouble(x))
|
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(double, PyFloat_FromDouble(x))
|
||||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(long 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_RETURN_TO_PYTHON_BY_VALUE(PyObject*, converter::do_return_to_python(x))
|
||||||
BOOST_PYTHON_CALLBACK_TO_PYTHON_BY_VALUE(PyObject*, converter::do_callback_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<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<double>, PyComplex_FromDoubles(x.real(), x.imag()))
|
||||||
BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::complex<long double>, PyComplex_FromDoubles(x.real(), x.imag()))
|
BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::complex<long double>, PyComplex_FromDoubles(x.real(), x.imag()))
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -3,19 +3,16 @@
|
|||||||
// copyright notice appears in all copies. This software is provided
|
// copyright notice appears in all copies. This software is provided
|
||||||
// "as is" without express or implied warranty, and with no claim as
|
// "as is" without express or implied warranty, and with no claim as
|
||||||
// to its suitability for any purpose.
|
// to its suitability for any purpose.
|
||||||
#ifndef FROM_PYTHON_STAGE1_DATA_DWA2002223_HPP
|
#ifndef CONSTRUCTOR_FUNCTION_DWA200278_HPP
|
||||||
# define FROM_PYTHON_STAGE1_DATA_DWA2002223_HPP
|
# define CONSTRUCTOR_FUNCTION_DWA200278_HPP
|
||||||
|
|
||||||
# include <boost/python/converter/from_python_function.hpp>
|
|
||||||
|
|
||||||
namespace boost { namespace python { namespace converter {
|
namespace boost { namespace python { namespace converter {
|
||||||
|
|
||||||
struct rvalue_stage1_data
|
// Declares the type of functions used to construct C++ objects for
|
||||||
{
|
// rvalue from_python conversions.
|
||||||
void* convertible;
|
struct rvalue_from_python_stage1_data;
|
||||||
constructor_function construct;
|
typedef void (*constructor_function)(PyObject* source, rvalue_from_python_stage1_data*);
|
||||||
};
|
|
||||||
|
|
||||||
}}} // namespace boost::python::converter
|
}}} // namespace boost::python::converter
|
||||||
|
|
||||||
#endif // FROM_PYTHON_STAGE1_DATA_DWA2002223_HPP
|
#endif // CONSTRUCTOR_FUNCTION_DWA200278_HPP
|
||||||
@@ -3,16 +3,13 @@
|
|||||||
// copyright notice appears in all copies. This software is provided
|
// copyright notice appears in all copies. This software is provided
|
||||||
// "as is" without express or implied warranty, and with no claim as
|
// "as is" without express or implied warranty, and with no claim as
|
||||||
// to its suitability for any purpose.
|
// to its suitability for any purpose.
|
||||||
#ifndef FROM_PYTHON_FUNCTION_DWA2002128_HPP
|
#ifndef CONVERTIBLE_FUNCTION_DWA200278_HPP
|
||||||
# define FROM_PYTHON_FUNCTION_DWA2002128_HPP
|
# define CONVERTIBLE_FUNCTION_DWA200278_HPP
|
||||||
|
|
||||||
# include <boost/python/detail/wrap_python.hpp>
|
|
||||||
|
|
||||||
namespace boost { namespace python { namespace converter {
|
namespace boost { namespace python { namespace converter {
|
||||||
|
|
||||||
struct rvalue_stage1_data;
|
typedef void* (*convertible_function)(PyObject*);
|
||||||
typedef void (*constructor_function)(PyObject* source, rvalue_stage1_data*);
|
|
||||||
|
|
||||||
}}} // namespace boost::python::converter
|
}}} // namespace boost::python::converter
|
||||||
|
|
||||||
#endif // FROM_PYTHON_FUNCTION_DWA2002128_HPP
|
#endif // CONVERTIBLE_FUNCTION_DWA200278_HPP
|
||||||
@@ -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
|
|
||||||
@@ -3,235 +3,41 @@
|
|||||||
// copyright notice appears in all copies. This software is provided
|
// copyright notice appears in all copies. This software is provided
|
||||||
// "as is" without express or implied warranty, and with no claim as
|
// "as is" without express or implied warranty, and with no claim as
|
||||||
// to its suitability for any purpose.
|
// to its suitability for any purpose.
|
||||||
#ifndef FROM_PYTHON_DWA2002127_HPP
|
#ifndef FIND_FROM_PYTHON_DWA2002223_HPP
|
||||||
# define FROM_PYTHON_DWA2002127_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/python/detail/wrap_python.hpp>
|
||||||
# include <boost/type_traits/transform_traits.hpp>
|
# include <boost/python/converter/rvalue_from_python_data.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>
|
|
||||||
|
|
||||||
namespace boost { namespace python { namespace converter {
|
namespace boost { namespace python { namespace converter {
|
||||||
|
|
||||||
struct from_python_base
|
struct registration;
|
||||||
{
|
struct rvalue_from_python_chain;
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Used when T == U*const&
|
BOOST_PYTHON_DECL void* get_lvalue_from_python(
|
||||||
template <class T>
|
PyObject* source, registration const&);
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Used when T == U*
|
BOOST_PYTHON_DECL rvalue_from_python_chain const* implicit_conversion_chain(
|
||||||
template <class T>
|
PyObject* source, registration const&);
|
||||||
struct pointer_from_python : from_python_base
|
|
||||||
{
|
|
||||||
pointer_from_python(PyObject*);
|
|
||||||
T operator()(PyObject*) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Used when T == U& and (T != V const& or T == W volatile&)
|
BOOST_PYTHON_DECL rvalue_from_python_stage1_data rvalue_from_python_stage1(
|
||||||
template <class T>
|
PyObject* source, registration const&);
|
||||||
struct reference_from_python : from_python_base
|
|
||||||
{
|
|
||||||
reference_from_python(PyObject*);
|
|
||||||
T operator()(PyObject*) 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
|
BOOST_PYTHON_DECL void* rvalue_result_from_python(
|
||||||
// is a const non-volatile reference to a non-pointer type.
|
PyObject*, rvalue_from_python_stage1_data&);
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T>
|
BOOST_PYTHON_DECL void* reference_result_from_python(PyObject*, registration const&);
|
||||||
struct select_from_python
|
BOOST_PYTHON_DECL void* pointer_result_from_python(PyObject*, registration const&);
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
typedef typename mpl::select_type<
|
BOOST_PYTHON_DECL void void_result_from_python(PyObject*);
|
||||||
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 throw_no_pointer_from_python(PyObject*, registration const&);
|
||||||
// implementations
|
BOOST_PYTHON_DECL void throw_no_reference_from_python(PyObject*, registration const&);
|
||||||
//
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}}} // namespace boost::python::converter
|
}}} // namespace boost::python::converter
|
||||||
|
|
||||||
#endif // FROM_PYTHON_DWA2002127_HPP
|
#endif // FIND_FROM_PYTHON_DWA2002223_HPP
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -5,9 +5,9 @@
|
|||||||
// to its suitability for any purpose.
|
// to its suitability for any purpose.
|
||||||
#ifndef IMPLICIT_DWA2002326_HPP
|
#ifndef IMPLICIT_DWA2002326_HPP
|
||||||
# define IMPLICIT_DWA2002326_HPP
|
# define IMPLICIT_DWA2002326_HPP
|
||||||
# include <boost/python/converter/from_python_data.hpp>
|
# include <boost/python/converter/rvalue_from_python_data.hpp>
|
||||||
# include <boost/python/converter/from_python_stage1_data.hpp>
|
|
||||||
# include <boost/python/converter/registrations.hpp>
|
# include <boost/python/converter/registrations.hpp>
|
||||||
|
# include <boost/python/converter/registered.hpp>
|
||||||
|
|
||||||
namespace boost { namespace python { namespace converter {
|
namespace boost { namespace python { namespace converter {
|
||||||
|
|
||||||
@@ -16,27 +16,29 @@ struct implicit
|
|||||||
{
|
{
|
||||||
static void* convertible(PyObject* obj)
|
static void* convertible(PyObject* obj)
|
||||||
{
|
{
|
||||||
// Find a converter registration which can produce a Source
|
// Find a converter chain which can produce a Source instance
|
||||||
// instance from obj
|
// from obj. The user has told us that Source can be converted
|
||||||
return const_cast<rvalue_from_python_registration*>(
|
// to Target, and instantiating construct() below, ensures
|
||||||
find_chain(obj, rvalue_from_python_chain<Source>::value));
|
// 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
|
// This is the chain we got from the convertible step
|
||||||
rvalue_from_python_registration const* registration
|
rvalue_from_python_chain const* chain
|
||||||
= static_cast<rvalue_from_python_registration*>(data->convertible);
|
= static_cast<rvalue_from_python_chain*>(data->convertible);
|
||||||
|
|
||||||
// Call the convertible function again
|
// 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
|
// Use the result to construct the source type if the first
|
||||||
// converter was an rvalue converter.
|
// converter was an rvalue converter.
|
||||||
if (registration->construct != 0)
|
if (chain->construct != 0)
|
||||||
registration->construct(obj, &intermediate_data.stage1);
|
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
|
# if !defined(BOOST_MSVC) || _MSC_FULL_VER != 13012108 // vc7.01 alpha workaround
|
||||||
new (storage) Target(*static_cast<Source*>(intermediate_data.stage1.convertible));
|
new (storage) Target(*static_cast<Source*>(intermediate_data.stage1.convertible));
|
||||||
# else
|
# else
|
||||||
|
|||||||
@@ -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
|
|
||||||
116
include/boost/python/converter/obj_mgr_arg_from_python.hpp
Normal file
116
include/boost/python/converter/obj_mgr_arg_from_python.hpp
Normal 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
|
||||||
232
include/boost/python/converter/object_manager.hpp
Executable file
232
include/boost/python/converter/object_manager.hpp
Executable 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
|
||||||
@@ -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
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
#ifndef POINTER_TYPE_ID_DWA2002222_HPP
|
#ifndef POINTER_TYPE_ID_DWA2002222_HPP
|
||||||
# define 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>
|
# include <boost/type_traits/composite_traits.hpp>
|
||||||
|
|
||||||
namespace boost { namespace python { namespace converter {
|
namespace boost { namespace python { namespace converter {
|
||||||
@@ -17,9 +17,9 @@ namespace detail
|
|||||||
struct pointer_typeid_select
|
struct pointer_typeid_select
|
||||||
{
|
{
|
||||||
template <class 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>();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -27,37 +27,37 @@ namespace detail
|
|||||||
struct pointer_typeid_select<true>
|
struct pointer_typeid_select<true>
|
||||||
{
|
{
|
||||||
template <class T>
|
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>
|
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>
|
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>
|
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>()
|
// 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.
|
// to by T, which may be a pointer or a reference to a pointer.
|
||||||
template <class T>
|
template <class T>
|
||||||
undecorated_type_id_t pointer_type_id(T(*)() = 0)
|
type_info pointer_type_id(T(*)() = 0)
|
||||||
{
|
{
|
||||||
return detail::pointer_typeid_select<
|
return detail::pointer_typeid_select<
|
||||||
is_reference<T>::value
|
is_reference<T>::value
|
||||||
|
|||||||
42
include/boost/python/converter/pyobject_traits.hpp
Normal file
42
include/boost/python/converter/pyobject_traits.hpp
Normal 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
|
||||||
36
include/boost/python/converter/pyobject_type.hpp
Normal file
36
include/boost/python/converter/pyobject_type.hpp
Normal 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
|
||||||
99
include/boost/python/converter/pytype_arg_from_python.hpp
Normal file
99
include/boost/python/converter/pytype_arg_from_python.hpp
Normal 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
|
||||||
43
include/boost/python/converter/pytype_object_mgr_traits.hpp
Normal file
43
include/boost/python/converter/pytype_object_mgr_traits.hpp
Normal 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
|
||||||
@@ -3,37 +3,52 @@
|
|||||||
// copyright notice appears in all copies. This software is provided
|
// copyright notice appears in all copies. This software is provided
|
||||||
// "as is" without express or implied warranty, and with no claim as
|
// "as is" without express or implied warranty, and with no claim as
|
||||||
// to its suitability for any purpose.
|
// to its suitability for any purpose.
|
||||||
#ifndef RVALUE_FROM_PYTHON_CHAIN_DWA200237_HPP
|
#ifndef REGISTERED_DWA2002710_HPP
|
||||||
# define RVALUE_FROM_PYTHON_CHAIN_DWA200237_HPP
|
# define REGISTERED_DWA2002710_HPP
|
||||||
|
# include <boost/python/type_id.hpp>
|
||||||
# include <boost/python/converter/registry.hpp>
|
# include <boost/python/converter/registry.hpp>
|
||||||
|
# include <boost/python/converter/registrations.hpp>
|
||||||
# include <boost/type_traits/transform_traits.hpp>
|
# include <boost/type_traits/transform_traits.hpp>
|
||||||
# include <boost/type_traits/cv_traits.hpp>
|
# include <boost/type_traits/cv_traits.hpp>
|
||||||
|
|
||||||
namespace boost { namespace python { namespace converter {
|
namespace boost { namespace python { namespace converter {
|
||||||
|
|
||||||
|
struct registration;
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template <class T>
|
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>
|
template <class T>
|
||||||
struct rvalue_from_python_chain
|
struct registered
|
||||||
: detail::rvalue_from_python_chain_impl<
|
: detail::registered_base<
|
||||||
typename add_reference<
|
typename add_reference<
|
||||||
typename add_cv<T>::type
|
typename add_cv<T>::type
|
||||||
>::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
|
}}} // namespace boost::python::converter
|
||||||
|
|
||||||
#endif // RVALUE_FROM_PYTHON_CHAIN_DWA200237_HPP
|
#endif // REGISTERED_DWA2002710_HPP
|
||||||
63
include/boost/python/converter/registered_pointee.hpp
Normal file
63
include/boost/python/converter/registered_pointee.hpp
Normal 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
|
||||||
@@ -6,23 +6,62 @@
|
|||||||
#ifndef REGISTRATIONS_DWA2002223_HPP
|
#ifndef REGISTRATIONS_DWA2002223_HPP
|
||||||
# define 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 {
|
namespace boost { namespace python { namespace converter {
|
||||||
|
|
||||||
struct lvalue_from_python_registration
|
struct lvalue_from_python_chain
|
||||||
{
|
{
|
||||||
void* (*convert)(PyObject* source);
|
convertible_function convert;
|
||||||
lvalue_from_python_registration* next;
|
lvalue_from_python_chain* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rvalue_from_python_registration
|
struct rvalue_from_python_chain
|
||||||
{
|
{
|
||||||
void* (*convertible)(PyObject*);
|
convertible_function convertible;
|
||||||
constructor_function construct;
|
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
|
}}} // namespace boost::python::converter
|
||||||
|
|
||||||
#endif // REGISTRATIONS_DWA2002223_HPP
|
#endif // REGISTRATIONS_DWA2002223_HPP
|
||||||
|
|||||||
@@ -5,47 +5,46 @@
|
|||||||
// to its suitability for any purpose.
|
// to its suitability for any purpose.
|
||||||
#ifndef REGISTRY_DWA20011127_HPP
|
#ifndef REGISTRY_DWA20011127_HPP
|
||||||
# define 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/config.hpp>
|
||||||
# include <boost/python/detail/wrap_python.hpp>
|
# include <boost/python/detail/wrap_python.hpp>
|
||||||
# include <boost/python/converter/to_python_function_type.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 {
|
namespace boost { namespace python { namespace converter {
|
||||||
|
|
||||||
struct lvalue_from_python_registration;
|
struct registration;
|
||||||
struct rvalue_from_python_registration;
|
|
||||||
|
|
||||||
// This namespace acts as a sort of singleton
|
// This namespace acts as a sort of singleton
|
||||||
namespace registry
|
namespace registry
|
||||||
{
|
{
|
||||||
BOOST_PYTHON_DECL lvalue_from_python_registration*& lvalue_converters(undecorated_type_id_t);
|
// Get the registration corresponding to the type, creating it if neccessary
|
||||||
BOOST_PYTHON_DECL rvalue_from_python_registration*& rvalue_converters(undecorated_type_id_t);
|
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&
|
BOOST_PYTHON_DECL void insert(to_python_function_t, type_info);
|
||||||
get_to_python_function(undecorated_type_id_t);
|
|
||||||
|
|
||||||
BOOST_PYTHON_DECL void insert(to_python_function_t, undecorated_type_id_t);
|
|
||||||
|
|
||||||
// Insert an lvalue from_python converter
|
// 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
|
// Insert an rvalue from_python converter
|
||||||
BOOST_PYTHON_DECL void insert(
|
BOOST_PYTHON_DECL void insert(
|
||||||
void* (*convertible)(PyObject*)
|
convertible_function
|
||||||
, constructor_function
|
, constructor_function
|
||||||
, undecorated_type_id_t
|
, type_info
|
||||||
);
|
);
|
||||||
|
|
||||||
// Insert an rvalue from_python converter at the tail of the
|
// Insert an rvalue from_python converter at the tail of the
|
||||||
// chain. Used for implicit conversions
|
// chain. Used for implicit conversions
|
||||||
BOOST_PYTHON_DECL void push_back(
|
BOOST_PYTHON_DECL void push_back(
|
||||||
void* (*convertible)(PyObject*)
|
convertible_function
|
||||||
, constructor_function
|
, constructor_function
|
||||||
, undecorated_type_id_t
|
, type_info
|
||||||
);
|
);
|
||||||
|
|
||||||
BOOST_PYTHON_DECL PyTypeObject*& class_object(undecorated_type_id_t key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}}} // namespace boost::python::converter
|
}}} // namespace boost::python::converter
|
||||||
|
|||||||
150
include/boost/python/converter/return_from_python.hpp
Executable file
150
include/boost/python/converter/return_from_python.hpp
Executable 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*>(®istered<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
|
||||||
138
include/boost/python/converter/rvalue_from_python_data.hpp
Normal file
138
include/boost/python/converter/rvalue_from_python_data.hpp
Normal 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
Reference in New Issue
Block a user