[C++-sig] Boost Python wrapper<> causing a compile error C2664 in vc++ 8.0
Roman Yakovenko
roman.yakovenko at gmail.com
Fri Sep 7 21:54:10 CEST 2007
On 9/7/07, Matthew Scouten (TT) <Matthew.Scouten at tradingtechnologies.com>
wrote:
>
> I am trying to wrap a class with virtual functions in c++, to be over
> loaded in Python, and called from c++.
> I have been working up to full functionality gradually but I have hit a
> road block.
> My code (trimmed to only relevant parts, with the identifiers changed to
> protect the guilty):
>
> class CProofOfConcept {
>
> public:
>
> int x;
>
>
>
> CProofOfConcept(void);
>
> //CProofOfConcept(float f);
>
> std::string conceptProven(std::string = "My kingdom for a
> valid arg!");
>
> virtual std::string reality(void) const;
>
> std::string ProofOfCallback();
>
> virtual std::string sureality(void);
>
> virtual ~CProofOfConcept(void);
>
>
>
> private:
>
> float y;
>
> };
>
>
>
> class CProofOfConceptWrapper: public CProofOfConcept, public
> wrapper<CProofOfConcept>
>
> {
>
> };
>
>
>
> BOOST_PYTHON_MODULE(poc)
>
> {
>
> class_<CProofOfConceptWrapper>("CPOC")
>
> .def("reality",
> &CProofOfConceptWrapper::reality)
>
> .def_readwrite("x",
> &CProofOfConceptWrapper::x)
>
> .def("ProofOfCallback" ,
> &CProofOfConceptWrapper::ProofOfCallback)
>
> ;
>
> }
>
Here is the code Py++ generated:
struct CProofOfConcept_wrapper : CProofOfConcept, bp::wrapper<
CProofOfConcept > {
CProofOfConcept_wrapper(CProofOfConcept const & arg )
: CProofOfConcept( arg )
, bp::wrapper< CProofOfConcept >(){
// copy constructor
}
CProofOfConcept_wrapper( )
: CProofOfConcept( )
, bp::wrapper< CProofOfConcept >(){
// null constructor
}
....
};
BOOST_PYTHON_MODULE(pyplusplus){
bp::class_< CProofOfConcept_wrapper >( "CProofOfConcept" )
.def( bp::init< >() )
....
}
P.S. If you just start with Boost.Python I suggest you to try Py++ (
http://language-binding.net/pyplusplus/documentation/tutorials/pyplusplus_gui.html).
I think you will not be disappointed.
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20070907/30d1b1f7/attachment.htm>
More information about the Cplusplus-sig
mailing list