Here's a super simplistic example. Say I have a class that draws shapes, and I want to be able to specify the shape to draw as one of the parameters.
<layout id="WatchFace">
<drawable id="myShape" class="ShapeDrawer">
<param name="color">Graphics.COLOR_ORANGE</param>
<param name="shape">"Circle"</param>
</drawable>
</layout>
For example the code might look like this:
class Circle { } class ShapeDrawer extends Ui.Drawable { protected var shape; function initialize(params) { Drawable.initialize(params); var shapeName = params.get(:shape); shape = new shapeName(); // Obviously this won't work } }
Is it possible in Monkey C to instantiate a class dynamically? I haven't been able to find any documentation that seems to support loading a class by name.
My next thought was perhaps there was support to load a class through a resource file, since classes like Drawable, Bitmap, and Font can be instantiated. But I'm not sure if it is possible to load a user defined class that way.
If neither of these are possible, are there any other mechanisms available to load a class?