Boost logo

Boost :

From: Thomas Malik (Thomas_Malik%LGBANK_at_[hidden])
Date: 2001-09-13 05:36:39


On Fri, 07 Sep 2001, you wrote:
> --- In boost_at_y..., conversy_at_l... wrote:
> > --- In boost_at_y..., rwgk_at_y... wrote:
> > > --- In boost_at_y..., conversy_at_l... wrote:
> > > > currently this code prints "0", but I want it to print "1"...
> > >
> > > This is known as the "returned reference problem":
> > > http://groups.yahoo.com/group/boost/message/10144
> >
> > is there any plan to include the features describe in this mail,
> such
> > as own_args ?
>
> See:
>
> http://cci.lbl.gov/~rwgk/boost.python/projects.html
>
>
>
> Info: http://www.boost.org Unsubscribe:
> <mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
I just created a 'reference' type for boost::python, just an object holding
a pointer to the 'real' object type. It's done a template class, built on
the stuff in boost::python::detail, and provides
to_python/from_python/make_ref
template functions.
Use is as follows:
in refmodule.cpp:
BOOST_PYTHON_MODULE_INIT(ref)
{
  try
  {
      python::module_builder this_module("ref");
      this_module.def(make_ref<int>, "make_ref");
      this_module.def(make_ref<const char*>, "make_ref");
     ... other reference types needed
  }
  catch(...)
  {
      python::handle_exception();
  }
}

reftest.py
import ref
>> r=ref.make_ref(1)
>> print r
<reference to int object at b4f40>
>> print type(r)
<type 'reference to int'>
>> print r()
1
>> function_with_intref_parameter(r)
>> print r()
10

The whole module is fairly short. Any interest ?

BTW. did my first mail, concerning unsigned char* conversions did get to
the mailing list ?
I didn't receive any comments on it.

--
Thomas Malik
Landesbank Baden-Wuerttemberg (Stuttgart, Germany)
Abt. 2340 Tel. (+49 711) 124-7049
Thomas_Malik%lgbank_at_[hidden]
______________________________________________________________________
--------------------------------------------------------------------------------------------
Bitte beachten Sie, dass der Inhalt dieser E-Mail einschließlich eventuell
angehängter Dokumente vertraulich ist. Falls Sie nicht der angegebene
Empfänger sind oder falls diese E-Mail irrtümlich an Sie adressiert wurde,
dürfen Sie die E-Mail und eventuell angehängte Dokumente weder öffnen,
lesen, kopieren, verbreiten noch ihren Inhalt in irgendeiner Weise nutzen.
Bitte verständigen Sie den Absender sofort und löschen Sie die E-Mail
sodann.
Die Sicherheit von Übermittlungen per E-Mail kann nicht garantiert werden.
Per E-Mail übermittelte Informationen können abgefangen oder geändert
werden, verloren gehen oder zerstört werden, verspätet oder unvollständig
ankommen, oder Viren enthalten. Der Absender übernimmt daher keine Gewähr
für Irrtümer oder Auslassungen jeder Art im Inhalt sowie sonstige Risiken,
die auf die Übermittlung per E-Mail zurückzuführen sind. Falls Sie eine
Bestätigung wünschen, fordern Sie bitte den Inhalt der E-Mail als Hardcopy
an.
This e-mail and any attached files are confidential. If you are not the
named addressee or if this transmission has been addressed to you in error,
any disclosure, reproduction, copying, distrubtion, or other dissemination
or use of this communication is prohibited. If you have received this
transmission in error please notify the sender immediately and then delete
this e-mail.
E-mail transmission cannot be guaranteed to be secure or free from error 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 or
any other of such risks which arise as a result of e-mail transmission. If
verification is required, please request a hard copy version.
---------------------------------------------------------------------------------------------

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk