Re: Giving member field semantics to C++ style accessor functions
Daniel Oberlin <DOberlin <at> cambridgesoft.com>
2008-04-02 13:22:04 GMT
I prefer the original accessors to be hidden, so the default behavior is
exactly what I am looking for.
This is great. Thank you very much!
Dan
Daniel M. Oberlin
CambridgeSoft Corporation
100 CambridgePark Drive
Cambridge, MA 02140 USA
617.259.9959
dmo <at> cambridgesoft.com
-----Original Message-----
From: Xavier Delacour [mailto:xavier.delacour <at> gmail.com]
Sent: Wednesday, April 02, 2008 9:20 AM
To: Daniel Oberlin
Cc: swig-user <at> lists.sourceforge.net
Subject: Re: [Swig-user] Giving member field semantics to C++ style
accessor functions
It seems it'll hide the original accessors, per:
%ignore Class::GetMethod();
%ignore Class::GetMethod() const;
#if #SetMethod != #AttributeName
%ignore Class::SetMethod;
#endif
You could copy the attribute.swg file into your own project and remove
these, or make them optional somehow and submit a patch.
Xavier
On Wed, Apr 2, 2008 at 9:07 AM, Daniel Oberlin
<DOberlin <at> cambridgesoft.com> wrote:
> Xavier,
>
> Thank you for your very quick response!
>
> I don't think that this is in the web documentation, or I would have
> seen it.
>
> Does this also hide the original accessor functions get_a() and
set_a(),
> or are these still available?
>
> Thanks,
>
> Dan
>
> Daniel M. Oberlin
> CambridgeSoft Corporation
> 100 CambridgePark Drive
> Cambridge, MA 02140 USA
> 617.259.9959
> dmo <at> cambridgesoft.com
>
>
>
>
> -----Original Message-----
> From: Xavier Delacour [mailto:xavier.delacour <at> gmail.com]
> Sent: Wednesday, April 02, 2008 9:02 AM
> To: Daniel Oberlin
> Cc: swig-user <at> lists.sourceforge.net
> Subject: Re: [Swig-user] Giving member field semantics to C++ style
> accessor functions
>
> I think typemaps/attribute.swg does what you want.
>
> Given an interface:
>
> %include <attribute.swg>
> %attribute(A, int, a, get_a, set_a);
> struct A
> {
> int get_a() const;
> void set_a(int aa);
> };
>
> You'll get usage:
>
> x = A()
> x.a = 3 # calls A::set_a
> print x.a # calls A::get_a
>
> Xavier
>
> On Wed, Apr 2, 2008 at 8:54 AM, Daniel Oberlin
> <DOberlin <at> cambridgesoft.com> wrote:
> >
> >
> >
> >
> > Hello SWIG List,
> >
> >
> >
> > I have a question which I could not answer in the SWIG
documentation.
> I am
> > using SWIG 1.34 to wrap C++ code for Python and C#.
> >
> >
> >
> > I have some C++ accessor functions - for example:
> >
> >
> >
> > void SetValue(int value);
> >
> > int GetValue();
> >
> >
> >
> > and I would like for SWIG to present these setters and getters to
the
> target
> > language with member field semantics:
> >
> >
> >
> > setting:
> >
> > obj.Value = 34
> >
> >
> >
> > getting:
> >
> > v = obj.Value
> >
> >
> >
> > Is there a way to do this conveniently using SWIG?
> >
> >
> >
> > So far I have been extremely impressed with SWIG as a tool. It is
> very
> > powerful and comprehensive.
> >
> >
> >
> > Sincerely,
> >
> > Dan
> >
> > Daniel M. Oberlin
> > CambridgeSoft Corporation
> > 100 CambridgePark Drive
> > Cambridge, MA 02140 USA
> > 617.259.9959
> > dmo <at> cambridgesoft.com
> >
> >
> >
>
------------------------------------------------------------------------
> -
> > Check out the new SourceForge.net Marketplace.
> > It's the best place to buy or sell services for
> > just about anything Open Source.
> >
> >
>
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketp
> lace
> > _______________________________________________
> > Swig-user mailing list
> > Swig-user <at> lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/swig-user
> >
> >
>
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace