From kevinkunzmann at gmx.net Sun Mar 2 00:30:20 2014 From: kevinkunzmann at gmx.net (Kevin Kunzmann) Date: Sun, 02 Mar 2014 00:30:20 +0100 Subject: [C++-sig] getting the tutorial up and running Message-ID: <53126D8C.7030401@gmx.net> Hi! I just successfully built boost using bootstrap and .\b2 on Windows 8.1 with msvc 11.0. I put it in C:\local\boost_1_55_0 In my home directory I created user-config.jam: # MSVC configuration using msvc : 11.0 ; # Python configuration using python : : C:/Users/Kevin/Anaconda ; as I use the anaconda python distribution. It seems to recognize it, as I do not get any ojections when invoking bjam in C:\local\boost_1_55_0\libs\python\example\tutorial, here is the complete output: C:\local\boost_1_55_0\libs\python\example\tutorial>bjam link.jam: No such file or directory ...patience... ...patience... ...found 1678 targets... ...updating 14 targets... common.mkdir bin common.mkdir bin\msvc-11.0 common.mkdir bin\msvc-11.0\debug compile-c-c++ bin\msvc-11.0\debug\hello.obj hello.cpp msvc.link.dll bin\msvc-11.0\debug\hello_ext.pyd LINK : fatal error LNK1104: cannot open file 'boost_python-vc110-mt-gd-1_55.lib' call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\vc\vcvarsall.b at" x86 >nul link /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /MACHINE:X86 /MANIFEST /subsystem:conso le /out:"bin\msvc-11.0\debug\hello_ext.pyd" /IMPLIB:"bin\msvc-11.0\debug\hello_e xt.lib" /LIBPATH:"C:\Users\Kevin\Anaconda\libs" @"bin\msvc-11.0\debug\hello_ex t.pyd.rsp" if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% ...failed msvc.link.dll bin\msvc-11.0\debug\hello_ext.pyd bin\msvc-11.0\debug\he llo_ext.lib bin\msvc-11.0\debug\hello_ext.pdb bin\msvc-11.0\debug\hello_ext.pdb. .. common.copy boost_python-vc110-gd-1_55.dll ..\..\..\..\bin.v2\libs\python\build\msvc-11.0\debug\boost_python-vc110-gd-1_55. dll 1 Datei(en) kopiert. ...skipped hello_ext.pyd for lack of hello_ext.pyd... common.mkdir bin\hello.test common.mkdir bin\hello.test\msvc-11.0 common.mkdir bin\hello.test\msvc-11.0\debug ...skipped hello for lack of hello_ext.pyd... ...failed updating 3 targets... ...skipped 3 targets... ...updated 8 targets... C:\local\boost_1_55_0\libs\python\example\tutorial> what went wrong here? what is link.jam and where do I get it from? best, Kevin -------------- next part -------------- An HTML attachment was scrubbed... URL: From nikolay.mladenov at gmail.com Sun Mar 2 19:34:25 2014 From: nikolay.mladenov at gmail.com (Nikolay Mladenov) Date: Sun, 2 Mar 2014 13:34:25 -0500 Subject: [C++-sig] getting the tutorial up and running In-Reply-To: <53126D8C.7030401@gmx.net> References: <53126D8C.7030401@gmx.net> Message-ID: IIRC when you build boost you have to use --with-python as bjam option or the python libs are not built On Sat, Mar 1, 2014 at 6:30 PM, Kevin Kunzmann wrote: > Hi! > > I just successfully built boost using bootstrap and .\b2 on Windows 8.1 > with msvc 11.0. I put it in C:\local\boost_1_55_0 > > In my home directory I created user-config.jam: > > # MSVC configuration > using msvc : 11.0 ; > > # Python configuration > using python : : C:/Users/Kevin/Anaconda ; > > as I use the anaconda python distribution. It seems to recognize it, as I > do not get any ojections when invoking bjam in > C:\local\boost_1_55_0\libs\python\example\tutorial, here is the complete > output: > > C:\local\boost_1_55_0\libs\python\example\tutorial>bjam > link.jam: No such file or directory > ...patience... > ...patience... > ...found 1678 targets... > ...updating 14 targets... > common.mkdir bin > common.mkdir bin\msvc-11.0 > common.mkdir bin\msvc-11.0\debug > compile-c-c++ bin\msvc-11.0\debug\hello.obj > hello.cpp > msvc.link.dll bin\msvc-11.0\debug\hello_ext.pyd > LINK : fatal error LNK1104: cannot open file > 'boost_python-vc110-mt-gd-1_55.lib' > > > call "C:\Program Files (x86)\Microsoft Visual Studio > 11.0\vc\vcvarsall.b > at" x86 >nul > link /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /MACHINE:X86 /MANIFEST > /subsystem:conso > le /out:"bin\msvc-11.0\debug\hello_ext.pyd" > /IMPLIB:"bin\msvc-11.0\debug\hello_e > xt.lib" /LIBPATH:"C:\Users\Kevin\Anaconda\libs" > @"bin\msvc-11.0\debug\hello_ex > t.pyd.rsp" > if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% > > ...failed msvc.link.dll bin\msvc-11.0\debug\hello_ext.pyd > bin\msvc-11.0\debug\he > llo_ext.lib bin\msvc-11.0\debug\hello_ext.pdb > bin\msvc-11.0\debug\hello_ext.pdb. > .. > common.copy boost_python-vc110-gd-1_55.dll > > ..\..\..\..\bin.v2\libs\python\build\msvc-11.0\debug\boost_python-vc110-gd-1_55. > dll > 1 Datei(en) kopiert. > ...skipped hello_ext.pyd for lack of > hello_ext.pyd... > common.mkdir bin\hello.test > common.mkdir bin\hello.test\msvc-11.0 > common.mkdir bin\hello.test\msvc-11.0\debug > ...skipped hello for lack of > bug>hello_ext.pyd... > ...failed updating 3 targets... > ...skipped 3 targets... > ...updated 8 targets... > > C:\local\boost_1_55_0\libs\python\example\tutorial> > > what went wrong here? what is link.jam and where do I get it from? > > best, > > Kevin > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > https://mail.python.org/mailman/listinfo/cplusplus-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevinkunzmann at gmx.net Mon Mar 3 10:46:09 2014 From: kevinkunzmann at gmx.net (Kevin Kunzmann) Date: Mon, 03 Mar 2014 10:46:09 +0100 Subject: [C++-sig] getting the tutorial up and running In-Reply-To: References: <53126D8C.7030401@gmx.net> Message-ID: <53144F61.5090505@gmx.net> Hey, thanks, still not working - I suspect it's the include and library paths for the command line compiler now, how do I add my boost directory to them? Output is still: C:\local\boost_1_55_0\libs\python\example\tutorial>bjam link.jam: No such file or directory ...patience... ...patience... ...found 1678 targets... ...updating 6 targets... msvc.link.dll bin\msvc-11.0\debug\hello_ext.pyd LINK : fatal error LNK1104: cannot open file 'boost_python-vc110-mt-gd-1_55.lib' call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\vc\vcvarsall.b at" x86 >nul link /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /MACHINE:X86 /MANIFEST /subsystem:conso le /out:"bin\msvc-11.0\debug\hello_ext.pyd" /IMPLIB:"bin\msvc-11.0\debug\hello_e xt.lib" /LIBPATH:"C:\Users\Kevin\Anaconda\libs" @"bin\msvc-11.0\debug\hello_ex t.pyd.rsp" if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% ...failed msvc.link.dll bin\msvc-11.0\debug\hello_ext.pyd bin\msvc-11.0\debug\he llo_ext.lib bin\msvc-11.0\debug\hello_ext.pdb bin\msvc-11.0\debug\hello_ext.pdb. .. ...skipped hello_ext.pyd for lack of hello_ext.pyd... ...skipped hello for lack of hello_ext.pyd... ...failed updating 3 targets... ...skipped 3 targets... C:\local\boost_1_55_0\libs\python\example\tutorial> do I have to worry about link.jam? best, Kevin On 02.03.2014 19:34, Nikolay Mladenov wrote: > IIRC when you build boost you have to use --with-python as bjam > option or the python libs are not built > > > On Sat, Mar 1, 2014 at 6:30 PM, Kevin Kunzmann > wrote: > > Hi! > > I just successfully built boost using bootstrap and .\b2 on > Windows 8.1 with msvc 11.0. I put it in C:\local\boost_1_55_0 > > In my home directory I created user-config.jam: > > # MSVC configuration > using msvc : 11.0 ; > > # Python configuration > using python : : C:/Users/Kevin/Anaconda ; > > as I use the anaconda python distribution. It seems to recognize > it, as I do not get any ojections when invoking bjam in > C:\local\boost_1_55_0\libs\python\example\tutorial, here is the > complete output: > > C:\local\boost_1_55_0\libs\python\example\tutorial>bjam > link.jam: No such file or directory > ...patience... > ...patience... > ...found 1678 targets... > ...updating 14 targets... > common.mkdir bin > common.mkdir bin\msvc-11.0 > common.mkdir bin\msvc-11.0\debug > compile-c-c++ bin\msvc-11.0\debug\hello.obj > hello.cpp > msvc.link.dll bin\msvc-11.0\debug\hello_ext.pyd > LINK : fatal error LNK1104: cannot open file > 'boost_python-vc110-mt-gd-1_55.lib' > > > call "C:\Program Files (x86)\Microsoft Visual Studio > 11.0\vc\vcvarsall.b > at" x86 >nul > link /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /MACHINE:X86 > /MANIFEST /subsystem:conso > le /out:"bin\msvc-11.0\debug\hello_ext.pyd" > /IMPLIB:"bin\msvc-11.0\debug\hello_e > xt.lib" /LIBPATH:"C:\Users\Kevin\Anaconda\libs" > @"bin\msvc-11.0\debug\hello_ex > t.pyd.rsp" > if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% > > ...failed msvc.link.dll bin\msvc-11.0\debug\hello_ext.pyd > bin\msvc-11.0\debug\he > llo_ext.lib bin\msvc-11.0\debug\hello_ext.pdb > bin\msvc-11.0\debug\hello_ext.pdb. > .. > common.copy boost_python-vc110-gd-1_55.dll > ..\..\..\..\bin.v2\libs\python\build\msvc-11.0\debug\boost_python-vc110-gd-1_55. > dll > 1 Datei(en) kopiert. > ...skipped hello_ext.pyd for lack of > hello_ext.pyd... > common.mkdir bin\hello.test > common.mkdir bin\hello.test\msvc-11.0 > common.mkdir bin\hello.test\msvc-11.0\debug > ...skipped hello for lack of > bug>hello_ext.pyd... > ...failed updating 3 targets... > ...skipped 3 targets... > ...updated 8 targets... > > C:\local\boost_1_55_0\libs\python\example\tutorial> > > what went wrong here? what is link.jam and where do I get it from? > > best, > > Kevin > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > https://mail.python.org/mailman/listinfo/cplusplus-sig > > > > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > https://mail.python.org/mailman/listinfo/cplusplus-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at schnoberts.com Mon Mar 3 20:23:58 2014 From: andy at schnoberts.com (Andy Schneider) Date: Mon, 3 Mar 2014 19:23:58 +0000 Subject: [C++-sig] as_to_python_function and abstract C++ classes Message-ID: <3D541E28-6D28-4918-ACCC-58407C59444E@schnoberts.com> Hi, Since I upgraded to gcc 4.8 I can no longer use as_to_python_function with T being a type that's abstract (i.e. has >= 1 pure virtual method). This is because in gcc 4.8 the following: template static void convert_function_must_take_value_or_const_reference(U(*)(T), int, T* = 0) {} fails to compile since T is not constructible. Is this a known issue? Is there interest in a fix for this or are there are better ways to be constructing conversion functions in a typesafe manner in Boost.Python? Kind regards, Andy From nikolay.mladenov at gmail.com Tue Mar 4 15:27:20 2014 From: nikolay.mladenov at gmail.com (Nikolay Mladenov) Date: Tue, 4 Mar 2014 09:27:20 -0500 Subject: [C++-sig] getting the tutorial up and running In-Reply-To: <53144F61.5090505@gmx.net> References: <53126D8C.7030401@gmx.net> <53144F61.5090505@gmx.net> Message-ID: did you verify the existence of boost_python-vc110-mt-gd-1_55.lib in your C:\local\boost_1_55_0\stage folder? On Mon, Mar 3, 2014 at 4:46 AM, Kevin Kunzmann wrote: > Hey, > > thanks, still not working - I suspect it's the include and library paths > for the command line compiler now, how do I add my boost directory to them? > > Output is still: > > C:\local\boost_1_55_0\libs\python\example\tutorial>bjam > link.jam: No such file or directory > ...patience... > ...patience... > ...found 1678 targets... > ...updating 6 targets... > > msvc.link.dll bin\msvc-11.0\debug\hello_ext.pyd > LINK : fatal error LNK1104: cannot open file > 'boost_python-vc110-mt-gd-1_55.lib' > > > call "C:\Program Files (x86)\Microsoft Visual Studio > 11.0\vc\vcvarsall.b > at" x86 >nul > link /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /MACHINE:X86 /MANIFEST > /subsystem:conso > le /out:"bin\msvc-11.0\debug\hello_ext.pyd" > /IMPLIB:"bin\msvc-11.0\debug\hello_e > xt.lib" /LIBPATH:"C:\Users\Kevin\Anaconda\libs" > @"bin\msvc-11.0\debug\hello_ex > t.pyd.rsp" > if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% > > ...failed msvc.link.dll bin\msvc-11.0\debug\hello_ext.pyd > bin\msvc-11.0\debug\he > llo_ext.lib bin\msvc-11.0\debug\hello_ext.pdb > bin\msvc-11.0\debug\hello_ext.pdb. > .. > ...skipped hello_ext.pyd for lack of > hello_ext.pyd... > ...skipped hello for lack of > bug>hello_ext.pyd... > ...failed updating 3 targets... > ...skipped 3 targets... > > C:\local\boost_1_55_0\libs\python\example\tutorial> > > do I have to worry about link.jam? > > best, > > Kevin > > > > On 02.03.2014 19:34, Nikolay Mladenov wrote: > > IIRC when you build boost you have to use --with-python as bjam option or > the python libs are not built > > > On Sat, Mar 1, 2014 at 6:30 PM, Kevin Kunzmann wrote: > >> Hi! >> >> I just successfully built boost using bootstrap and .\b2 on Windows 8.1 >> with msvc 11.0. I put it in C:\local\boost_1_55_0 >> >> In my home directory I created user-config.jam: >> >> # MSVC configuration >> using msvc : 11.0 ; >> >> # Python configuration >> using python : : C:/Users/Kevin/Anaconda ; >> >> as I use the anaconda python distribution. It seems to recognize it, as I >> do not get any ojections when invoking bjam in >> C:\local\boost_1_55_0\libs\python\example\tutorial, here is the complete >> output: >> >> C:\local\boost_1_55_0\libs\python\example\tutorial>bjam >> link.jam: No such file or directory >> ...patience... >> ...patience... >> ...found 1678 targets... >> ...updating 14 targets... >> common.mkdir bin >> common.mkdir bin\msvc-11.0 >> common.mkdir bin\msvc-11.0\debug >> compile-c-c++ bin\msvc-11.0\debug\hello.obj >> hello.cpp >> msvc.link.dll bin\msvc-11.0\debug\hello_ext.pyd >> LINK : fatal error LNK1104: cannot open file >> 'boost_python-vc110-mt-gd-1_55.lib' >> >> >> call "C:\Program Files (x86)\Microsoft Visual Studio >> 11.0\vc\vcvarsall.b >> at" x86 >nul >> link /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /MACHINE:X86 /MANIFEST >> /subsystem:conso >> le /out:"bin\msvc-11.0\debug\hello_ext.pyd" >> /IMPLIB:"bin\msvc-11.0\debug\hello_e >> xt.lib" /LIBPATH:"C:\Users\Kevin\Anaconda\libs" >> @"bin\msvc-11.0\debug\hello_ex >> t.pyd.rsp" >> if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% >> >> ...failed msvc.link.dll bin\msvc-11.0\debug\hello_ext.pyd >> bin\msvc-11.0\debug\he >> llo_ext.lib bin\msvc-11.0\debug\hello_ext.pdb >> bin\msvc-11.0\debug\hello_ext.pdb. >> .. >> common.copy boost_python-vc110-gd-1_55.dll >> >> ..\..\..\..\bin.v2\libs\python\build\msvc-11.0\debug\boost_python-vc110-gd-1_55. >> dll >> 1 Datei(en) kopiert. >> ...skipped hello_ext.pyd for lack of >> hello_ext.pyd... >> common.mkdir bin\hello.test >> common.mkdir bin\hello.test\msvc-11.0 >> common.mkdir bin\hello.test\msvc-11.0\debug >> ...skipped hello for lack of >> > bug>hello_ext.pyd... >> ...failed updating 3 targets... >> ...skipped 3 targets... >> ...updated 8 targets... >> >> C:\local\boost_1_55_0\libs\python\example\tutorial> >> >> what went wrong here? what is link.jam and where do I get it from? >> >> best, >> >> Kevin >> >> _______________________________________________ >> Cplusplus-sig mailing list >> Cplusplus-sig at python.org >> https://mail.python.org/mailman/listinfo/cplusplus-sig >> > > > > _______________________________________________ > Cplusplus-sig mailing listCplusplus-sig at python.orghttps://mail.python.org/mailman/listinfo/cplusplus-sig > > > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > https://mail.python.org/mailman/listinfo/cplusplus-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From raghavendra.jain at gmail.com Sat Mar 8 05:29:31 2014 From: raghavendra.jain at gmail.com (Raghvendra Jain) Date: Sat, 8 Mar 2014 13:29:31 +0900 Subject: [C++-sig] Installation of boost.python using boost 1.55.0 Message-ID: Hi all, I've setup the PATH for C:\Python27, and execute the 'bootstrap' in the boost folder. The error message displayed: Building Boost.Build engine "VCVARS32.BAT" is not recognized as commands or executable programs/bat file. What should I do ? Best Regards, Raghav On Sun, Mar 2, 2014 at 8:30 AM, Kevin Kunzmann wrote: > Hi! > > I just successfully built boost using bootstrap and .\b2 on Windows 8.1 > with msvc 11.0. I put it in C:\local\boost_1_55_0 > > In my home directory I created user-config.jam: > > # MSVC configuration > using msvc : 11.0 ; > > # Python configuration > using python : : C:/Users/Kevin/Anaconda ; > > as I use the anaconda python distribution. It seems to recognize it, as I > do not get any ojections when invoking bjam in > C:\local\boost_1_55_0\libs\python\example\tutorial, here is the complete > output: > > C:\local\boost_1_55_0\libs\python\example\tutorial>bjam > link.jam: No such file or directory > ...patience... > ...patience... > ...found 1678 targets... > ...updating 14 targets... > common.mkdir bin > common.mkdir bin\msvc-11.0 > common.mkdir bin\msvc-11.0\debug > compile-c-c++ bin\msvc-11.0\debug\hello.obj > hello.cpp > msvc.link.dll bin\msvc-11.0\debug\hello_ext.pyd > LINK : fatal error LNK1104: cannot open file > 'boost_python-vc110-mt-gd-1_55.lib' > > > call "C:\Program Files (x86)\Microsoft Visual Studio > 11.0\vc\vcvarsall.b > at" x86 >nul > link /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /MACHINE:X86 /MANIFEST > /subsystem:conso > le /out:"bin\msvc-11.0\debug\hello_ext.pyd" > /IMPLIB:"bin\msvc-11.0\debug\hello_e > xt.lib" /LIBPATH:"C:\Users\Kevin\Anaconda\libs" > @"bin\msvc-11.0\debug\hello_ex > t.pyd.rsp" > if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% > > ...failed msvc.link.dll bin\msvc-11.0\debug\hello_ext.pyd > bin\msvc-11.0\debug\he > llo_ext.lib bin\msvc-11.0\debug\hello_ext.pdb > bin\msvc-11.0\debug\hello_ext.pdb. > .. > common.copy boost_python-vc110-gd-1_55.dll > > ..\..\..\..\bin.v2\libs\python\build\msvc-11.0\debug\boost_python-vc110-gd-1_55. > dll > 1 Datei(en) kopiert. > ...skipped hello_ext.pyd for lack of > hello_ext.pyd... > common.mkdir bin\hello.test > common.mkdir bin\hello.test\msvc-11.0 > common.mkdir bin\hello.test\msvc-11.0\debug > ...skipped hello for lack of > bug>hello_ext.pyd... > ...failed updating 3 targets... > ...skipped 3 targets... > ...updated 8 targets... > > C:\local\boost_1_55_0\libs\python\example\tutorial> > > what went wrong here? what is link.jam and where do I get it from? > > best, > > Kevin > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > https://mail.python.org/mailman/listinfo/cplusplus-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From deepankar.sharma at gmail.com Sat Mar 8 21:17:55 2014 From: deepankar.sharma at gmail.com (Deepankar Sharma) Date: Sat, 8 Mar 2014 15:17:55 -0500 Subject: [C++-sig] How to wrap class enums Message-ID: Any pointers on how to expose class enums to Python? Given the following enum what would the boost code to expose it to python look like? The page at http://www.boost.org/doc/libs/1_55_0/libs/python/doc/v2/enum.html only lists examples of old style enums. enum class t_functions { ADD, SUB, MUL, DIV }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From herron at ELLINGTON.com Mon Mar 10 16:42:12 2014 From: herron at ELLINGTON.com (Liam Herron) Date: Mon, 10 Mar 2014 15:42:12 +0000 Subject: [C++-sig] How to wrap class enums In-Reply-To: References: Message-ID: <96426055F003C542B3FB8A0928736DF916D03F@ex0.ELLINGTON.com> Here is an example: // c++ code class A { public: enum ATypes { ONE, TWO, THREE }; }; // boost python code object obj_A = class_ ("A", "A simple A object", init<>() ) ; { scope in_A(obj_A); enum_ ("ATypes") .value("ONE", A::ONE) .value("TWO", A::TWO) .value("THREE", A::THREE) ; } Hope that helps. Liam From: Cplusplus-sig [mailto:cplusplus-sig-bounces+herron=ellington.com at python.org] On Behalf Of Deepankar Sharma Sent: Saturday, March 08, 2014 3:18 PM To: cplusplus-sig at python.org Subject: [C++-sig] How to wrap class enums Any pointers on how to expose class enums to Python? Given the following enum what would the boost code to expose it to python look like? The page at http://www.boost.org/doc/libs/1_55_0/libs/python/doc/v2/enum.html only lists examples of old style enums. enum class t_functions { ADD, SUB, MUL, DIV }; ============================================================================================= Email transmissions can not be guaranteed to be secure or error-free, as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of email transmission. In addition, the information contained in this email message is intended only for use of the individual or entity named above. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution,or copying of this communication, disclosure of the parties to it, or any action taken or omitted to be taken in reliance on it, is strictly prohibited, and may be unlawful. If you are not the intended recipient please delete this email message. ============================================================================================== -------------- next part -------------- An HTML attachment was scrubbed... URL: From wichert at wiggy.net Tue Mar 11 19:16:31 2014 From: wichert at wiggy.net (Wichert Akkerman) Date: Tue, 11 Mar 2014 19:16:31 +0100 Subject: [C++-sig] How to wrap class enums In-Reply-To: <96426055F003C542B3FB8A0928736DF916D03F@ex0.ELLINGTON.com> References: <96426055F003C542B3FB8A0928736DF916D03F@ex0.ELLINGTON.com> Message-ID: On 10 Mar 2014, at 16:42, Liam Herron wrote: > Here is an example: > > // c++ code > > class A > { > public: > enum ATypes > { > ONE, > TWO, > THREE > }; > }; That is an enum in a class, which is an entirely different beast. Class enums are a C++11 addition and look like this: enum class ATypes { ONE, TWO, THREE }; Regards, Wichert. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Martin.Franzke at t-systems.com Wed Mar 12 09:20:04 2014 From: Martin.Franzke at t-systems.com (Martin.Franzke at t-systems.com) Date: Wed, 12 Mar 2014 09:20:04 +0100 Subject: [C++-sig] How to wrap class enums In-Reply-To: References: Message-ID: <5F36B451F397CC4AAEB701F6E14011F0F1452D5501@HE113565.emea1.cds.t-internal.com> Hi, it works exactly the same as for old style enums, you only have to prepend the enum class scope (color::) to reference the values in the c++ code. enum class color { red = 1, green = 2, blue = 4 }; color identity_(color x) { return x; } BOOST_PYTHON_MODULE(enums) { enum_("color") .value("red", color::red) .value("green", color::green) .export_values() .value("blue", color::blue) ; def("identity", identity_); } What you can't do this way is to create new style python enums (see http://docs.python.org/3.4/library/enum.html), but as the documentation says, the python class is derived from Python's int type. Regards Martin Von: Cplusplus-sig [mailto:cplusplus-sig-bounces+martin.franzke=t-systems.com at python.org] Im Auftrag von Deepankar Sharma Gesendet: Samstag, 8. M?rz 2014 21:18 An: cplusplus-sig at python.org Betreff: [C++-sig] How to wrap class enums Any pointers on how to expose class enums to Python? Given the following enum what would the boost code to expose it to python look like? The page at http://www.boost.org/doc/libs/1_55_0/libs/python/doc/v2/enum.html only lists examples of old style enums. enum class t_functions { ADD, SUB, MUL, DIV }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From bluescarni at gmail.com Wed Mar 19 18:23:47 2014 From: bluescarni at gmail.com (Francesco Biscani) Date: Wed, 19 Mar 2014 17:23:47 +0000 Subject: [C++-sig] Exposing a generic template system in Boost.Python Message-ID: Greetings, I have been trying to think of a solution about this for a few days now, but I did not get very far. I am exposing specific instances of C++ template classes using Boost.Python. Let's say for the sake of argument that I am exposing std::vector. What I would like to achieve on the Python side would be some kind of unified interface of this kind: # Define a vector-of-ints type. vec_int = vector["int"] # Define a vector-of-doubles type. vec_float = vector["double"] ... etc., possibly with exceptions being raised if a template type which has not been exposed is requested. Additionally, the system should automagically work with nested generic types: # Define a vector-of-vectors-of-ints type. vec_vec_int = vector[vector["int"]] I have played around with some ideas, but it seems like I can never get to a point where the design does not look bloated and/or brittle. Thus I am wondering, is there anyone that tackled a problem like this before in Boost.Python and has pointers/suggestions on how to do this properly? Support for things like default template arguments would definitely be a plus. FWIW, I have access to C++11 on the C++ side, so I can deal with variadic templates and other amenities in a not-so-kludgy way. Thanks for any input, Francesco. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan at seefeld.name Wed Mar 19 18:36:27 2014 From: stefan at seefeld.name (Stefan Seefeld) Date: Wed, 19 Mar 2014 13:36:27 -0400 Subject: [C++-sig] Exposing a generic template system in Boost.Python In-Reply-To: References: Message-ID: <5329D59B.3050707@seefeld.name> Francesco, I have done something like what you are suggesting. It essentially boils down to defining a function template like template void define_vector(char const *name) { class_<...> vector(name); ... } and then calling that multiple times: define_vector("IVector"); define_vector("LVector"); ... Providing a factory function that instantiates one of those based on a value-type selector as you want can be easily done on the Python side. I don't think this can be automated any further. In particular, it is clear that any type you may want to instantiate in Python has to be compiled explicitly into the extension module. I.e., you need to explicitly instantiate the templates above, by explicitly calling the functions for the types you want to see supported at runtime. There is no JIT compilation for this. Stefan -- ...ich hab' noch einen Koffer in Berlin... From nikolay.mladenov at gmail.com Wed Mar 19 21:27:07 2014 From: nikolay.mladenov at gmail.com (Nikolay Mladenov) Date: Wed, 19 Mar 2014 16:27:07 -0400 Subject: [C++-sig] Exposing a generic template system in Boost.Python In-Reply-To: <5329D59B.3050707@seefeld.name> References: <5329D59B.3050707@seefeld.name> Message-ID: To add to Stefan's answer: I do the the same and also use visitors to add the same sets of members to classes, with possible customizations via trait classes. HTH On Wed, Mar 19, 2014 at 1:36 PM, Stefan Seefeld wrote: > Francesco, > > I have done something like what you are suggesting. It essentially boils > down to defining a function template like > > template > void define_vector(char const *name) > { > class_<...> vector(name); > ... > } > > > and then calling that multiple times: > > define_vector("IVector"); > define_vector("LVector"); > ... > > Providing a factory function that instantiates one of those based on a > value-type selector as you want can be easily done on the Python side. > > I don't think this can be automated any further. In particular, it is > clear that any type you may want to instantiate in Python has to be > compiled explicitly into the extension module. I.e., you need to > explicitly instantiate the templates above, by explicitly calling the > functions for the types you want to see supported at runtime. There is > no JIT compilation for this. > > Stefan > > -- > > ...ich hab' noch einen Koffer in Berlin... > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > https://mail.python.org/mailman/listinfo/cplusplus-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bluescarni at gmail.com Thu Mar 20 12:30:23 2014 From: bluescarni at gmail.com (Francesco Biscani) Date: Thu, 20 Mar 2014 11:30:23 +0000 Subject: [C++-sig] Exposing a generic template system in Boost.Python In-Reply-To: References: <5329D59B.3050707@seefeld.name> Message-ID: Hello Stefan and Nikolay, thanks for the replies. I have been using as well approaches similar to those you outlined. My main concern is the automation of the whole procedure. I have a fairly complicated hierarchy of template classes that I am exposing, and I need to be able to add new exposed instances in a kind of programmatic way (e.g., I am using a global counter n that gets increased each time a new instance is exposed, and I am calling the exposed classes "__vecor_type_0", "__vecor_type_1", ..., "__vecor_type_n"). Then I need to re-establish the connection between these names and the "template system" implemented on the Python side. I think it would be nice to have a Boost.Python mechanism to handle this type of usage, but for now I will try to get something working for my specific case (and then maybe reply here if I manage and if there is interest). Thanks for the help and kind regards, Francesco. On 19 March 2014 20:27, Nikolay Mladenov wrote: > To add to Stefan's answer: > > I do the the same and also use visitors to add the same sets of members to > classes, with possible customizations via trait classes. > > HTH > > > On Wed, Mar 19, 2014 at 1:36 PM, Stefan Seefeld wrote: > >> Francesco, >> >> I have done something like what you are suggesting. It essentially boils >> down to defining a function template like >> >> template >> void define_vector(char const *name) >> { >> class_<...> vector(name); >> ... >> } >> >> >> and then calling that multiple times: >> >> define_vector("IVector"); >> define_vector("LVector"); >> ... >> >> Providing a factory function that instantiates one of those based on a >> value-type selector as you want can be easily done on the Python side. >> >> I don't think this can be automated any further. In particular, it is >> clear that any type you may want to instantiate in Python has to be >> compiled explicitly into the extension module. I.e., you need to >> explicitly instantiate the templates above, by explicitly calling the >> functions for the types you want to see supported at runtime. There is >> no JIT compilation for this. >> >> Stefan >> >> -- >> >> ...ich hab' noch einen Koffer in Berlin... >> >> _______________________________________________ >> Cplusplus-sig mailing list >> Cplusplus-sig at python.org >> https://mail.python.org/mailman/listinfo/cplusplus-sig >> > > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > https://mail.python.org/mailman/listinfo/cplusplus-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: