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
Re: [C++-sig] Wrappend objects identity problem
by Victor Nakoryakov other posts by this author
Mar 30 2006 4:43AM messages near this date
Re: [C++-sig] Wrappend objects identity problem | Re: [C++-sig] Wrappend objects identity problem
Victor Nakoryakov wrote:
>  Ok, I think my previous post was too complicated, here is simplified 
>  version:
>  
>  
> >class A
> >{
> >};
> >
> >boost::shared_ptr<A> ptr;
> >boost::shared_ptr<A> getA()
> >{
> >	if (!ptr)
> >		ptr = boost::shared_ptr<A>(new A);
> >
> >	return ptr;
> >}
> >
> >void Init()
> >{
> >	python::class_< A, boost::shared_ptr<A>, boost::noncopyable >( "AClass", python::no_init 
);
> >	python::def("getA", &getA);
> >}
>  
>  
>  And py code is:
>  
>  
> >a1 = getA()
> >a2 = getA()
> >l = [a1, a2]
> >print a1
> >print a2
> >print getA() in l
> >print a1 is a2
> >print a1 == a2
>  
>  
>  Output is:
>  
>  <_mymodule.AClass object at 0x017DB070>
>  <_mymodule.AClass object at 0x017DB0B0>  <- another address!
>  False
>  False
>  False
>  
>  The question is the same: What I have to do to have the same address of 
>  AClass every time I call getA() from python.
>  
>  I can't find solution already for 3 days. Have anyone ideas?
>  

Ok... The question is simplified. Who knows a chain that converts 
HeldType (boost::shared_ptr<A>  in this case) to PyObject* ? And where I 
can done any overloads or specializations to force c++ to return the 
same PyObject* for the same raw pointer to A instance?

I don't know is it question simplification, or vice versa, but anyway 
I'm in great need of an answer.

-- 
Victor (aka nail) Nakoryakov
nail-mail<at> mail<dot>ru

Krasnoznamensk, Moscow, Russia

_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig
Thread:
Victor Nakoryakov
Victor Nakoryakov
David Abrahams
David Abrahams
Victor Nakoryakov
Andreas Beyer
Roman Yakovenko
Victor Nakoryakov
Victor Nakoryakov
Victor Nakoryakov
Kelly Burkhart
Victor Nakoryakov
Roman Yakovenko
Victor Nakoryakov
Roman Yakovenko
Victor Nakoryakov

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