ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> cpp-sig
cpp-sig
[C++-sig] Returning pointer to abstract class from pure virtual class method
by Roman Hwang other posts by this author
Oct 12 2009 12:00AM messages near this date
Re: [C++-sig] Compile error when using exception_translation.hpp | [C++-sig] Boost.python: extracting an array
Hello.

I'm new to Python, but really want to use it with my C++ code.

I faced a problem while returning pointer to abstract class from pure
virtual class method.
I tried to search the web, but found nothing.

struct ICoreWrapper : ICore, wrapper<ICore> 
{
	virtual IRegistry* CreateRegistry()
		{ return this-> get_override("CreateRegistry")(); }

};

struct IRegistryWrapper : IRegistry, wrapper<IRegistry> 
{
	virtual void DoSomestuff()
                        { return this-> get_override("DoSomestuff")(); }
};

ICore* CreateCoreW()
{
	return new CCore;
}

BOOST_PYTHON_MODULE_INIT(CorePy)
{
	class_<IRegistryWrapper, boost::noncopyable> ("IRegistry")
		.def("DoSomestuff", pure_virtual(&IRegistry::DoSomestuff))
		;

	class_<ICoreWrapper, boost::noncopyable> ("ICore")
		.def("CreateRegistry", pure_virtual(&ICore::CreateRegistry),
return_value_policy<reference_existing_object> ())
		;

	def("CreateCore", CreateCoreW,
return_value_policy<reference_existing_object> ());
}

The Python code looks like this:
> >> import CorePy
> >> c = CorePy.CreateCore()
> >> b = c.CreateRegistry()

I get Debug Error

Run-Time Check Failure #0 - The value of ESP was not properly saved
across a function call.
This is usually a result of calling a function declared with one
calling convention with a function pointer declared
with a different calling convention.

Please tell me what I do wrong.
Or whether this code is supported or not.

Thanks

Roman Hwang.
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@[...].org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved