[chuck-users] determining the type of an Object in code

Tom Lieber lieber at princeton.edu
Tue Feb 10 22:25:21 EST 2009


2009/2/10 mike clemow <gelfmuse at gmail.com>:
> I recently pulled from CVS and started fooling around and discovered a
> remarkably simple hack.  There's a method in Object, toString(), which
> returns a string containing the class of the object as well as the
> reference ID.  Like this (supposing a class called "Test"):
>
> "Test:11ceff0"
>
> There's also a stub in chuck_lang.cpp for a method getType(), which
> isn't implemented (yet).  So, I copied the implementation of
> toString(), minus the printing of the reference ID, and placed it
> where the implementation of getType() should be.  Now all objects (not
> UGens yet, although that would be sweet) respond to getType().

Haha, awesome! I guess if getType() is going to be something different
you're a little screwed, but an interesting solution.

Do you have a GitHub account to publish this in a fork with? Not
necessary, but even if you just clone it locally and make a branch on
your computer, then it'll be easier to maintain the change as versions
go by.

-- 
Tom Lieber
http://AllTom.com/


More information about the chuck-users mailing list