logo       

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

programming.swig

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


Ok, I have a feature working that prevents the to refer to non-existent struct members,
but I need help with the name.

Please check this documentation, and if everyone is happy with the "static" name,
I'll use it. If not, please suggest a better one.

Marcelo

/*
Use the "static" feature to make a wrapped class behaves as a "static" one,
ie, a python class that doesn't dynamically add new attributes.

For example, for the class

%feature("static") A;
struct A
{
int a;
int b;
};

you will get:

aa = A()
aa.a = 1 # Ok
aa.b = 1 # Ok
aa.c = 3 # error

Since "static" is a feature, if you use it like

%feature("static");

it will make all the wrapped classes static ones.

The implementation is based on the recipe:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158

and works for modern (-modern) and plain python.

*/


_______________________________________________
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