logo       

Re: Preventing a user to refer to non-existent struct members: msg#00108

programming.swig

Subject: Re: Preventing a user to refer to non-existent struct members


On Wed, 15 Sep 2004, Robert Lupton wrote:

> I can avoid this (in python 2.3 at least) by setting __slots__ in the
> class definition to the C-level members (i.e.
> .__swig_getmethods__.keys()).
>
> Unfortunately, I don't see how I can do this without post-processing the
> swig-generated interface.py file. Is there a trick known to the
> cognoscenti? Or is there a better way of doing this?

I know nothing about __slots__ or __swig_getmethods__, but I think you can
use %pythoncode to insert code that will accomplish the modifications that
you describe. Something along these lines might do the trick:

%pythoncode %{

for foo in globals().values():
if type(foo) == type and not foo == object:
foo.__slots__ = foo.__swig_getmethods__.keys()

%}

Josh

--
Joshua L. Cherry, Ph.D.
NCBI/NLM/NIH (Contractor)
jcherry@xxxxxxxxxxxxxxxx
_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise