I've just jumped a little bit into attribute craziness. I want to have a C++ vector as an attribute, but as obviously there is no macro for that, I am trying to create the attribute using attribute_new. So, here's what I did:
class_addattr(classPtr, attribute_new("points", _sym_pointer, ATTR_FLAGS_NONE, NULL, NULL));
CLASS_ATTR_ACCESSORS(classPtr, "points", getPoints, setPoints);
CLASS_ATTR_DEFAULT(classPtr, "points", ATTR_FLAGS_NONE, "0. 0. 1. 1.");
I choose _sym_pointer because that was the option that was the closest to a C++ vector. One weirdness is, that I couldn't really figure out how to set accessors within the attribute_new method. Just by putting it there, I got a compiler error, so finally I needed to use the CLASS_ATTR_ACCESSORS macro for this (although the documentation says that I could have set the accessors directly in attribute_new). But the real bug is: each time when I instantiate the object, I get the following warning (four times for each instantiation, probably because there are four items in the default value list):
method object_clone called on invalid object
The same happens if I set the attribute type to _sym_object. However (and this is also weird) if I set the attribute type to _sym_char, everything works fine.
Is this a bug? And BTW, is there a reason why there is no 'untyped' type selector for an attribute? I mean, even with _sym_pointer, it is not exactly the type of a C++ vector anyway...