View Full Version : Test for read-only property?

04 April 2009, 09:00 PM
Is there a way to test if a variable is read only? I am trying to do mass amounts of getProperty/setProperty calls using getPropNames, but some of the properties I'm running into are read only. I'd rather be able to do a simple automated test rather than manually excluding property names or falling back on a try/catch. A try/catch might be the way to go, but I want to avoid it if possible because of the slowdown (noticing major slowdown already and I'm testing on something very small in comparison to what I'm planning to be using this for).

I asked something similar in the past about making sure the value type being assigned to a property is actually valid, and the best solution seemed to be parsing the stream value returned by showProperties. I'm not sure this will work in this situation because of inconsistencies between the formatting of showInterfaces and showProperties. I think read|write is missing all together from showProperties actually.

Anyways, any suggestions would be great. Thanks!

04 April 2009, 01:02 AM
I think try/catch is your only option. You could, however, keep a cache of parent classes and property names, and store their read/write, animateable, value type, etc. in that cache.

That way if a user selects a sphere for the very first time, things get cached, and any other sphere selection/parsing can just use the cache.

I did indeed expect a read/write check somewhere along the lines of isPropertyAnimatable, but alas.

04 April 2009, 07:34 PM
Nuts! It certainly would make things a lot easier. Ah well. Thanks for having a look Richard!

CGTalk Moderation
04 April 2009, 07:34 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.