From: az az <azr...@ho...> - 2009-02-25 10:42:25
|
Hi, I'm trying to extending the %attribute swig macro to avoid giving the name of the getter/setter. To do such job, i've created an %autoAttribute macro: %include "attribute.i" #ifndef MakeAttributeGetter(AttributeName) #define MakeAttributeGetter(AttributeName) get ## AttributeName #endif #ifndef MakeAttributeSetter(AttributeName) #define MakeAttributeSetter(AttributeName) set ## AttributeName #endif %define %autoAttribute(Class, AttributeType, AttributeName) %attribute(Class, AttributeType, AttributeName, MakeAttributeGetter(AttributeName), MakeAttributeGetter(AttributeName)); %enddef But it would be great if the user of autoattribute could change the "get" string directly with a define, for instance: #define AGETTER get_ %include "autoattribute.i" class Foo { public: int get_Toto(); void set_Toto(int value); } %autoAttribute(Foo, int, Toto); But i'm stuck because the ## operator is done before the resolution of the "defines" and the generated code lookslike #define Foo_Toto_get(self_) self_->AGETTERToto() instead of: #define Foo_Toto_get(self_) self_->get_Toto() Is there a way to make it work as expected? Another couple of questions: Can we infers the attribute type from the return type of the setter? Can we make a rule to automatically create attributes when function start with "get" or "set" (kind of name-mapping instead of type-mapping). Thanks a lot for your time and maybe your answers. I've got a poor english, and i hope to be fully understandable. If not, do not hesitate to ask for precisions. Best regards, Greg _________________________________________________________________ Vous voulez savoir ce que vous pouvez faire avec le nouveau Windows Live ? Lancez-vous ! http://www.microsoft.com/windows/windowslive/default.aspx |