[Ironruby-core] ClassInitGenerator issues
w.kelly at qut.edu.au
Tue Feb 26 02:02:36 EST 2008
If I define a new library class called say Digest::Class, ie a class called "Class" within a module called "Digest" then when I run the ClassInitGenerator it produces a method name clash between the LoadClass_Class generated for this new class and the one generated for the standard Ruby "Class".
I define a new extension class:
public class MD5: Base
As part of the loading of this class I need to initialize a class variable:
@@metadata = System.Security.Cryptography.MD5.Create();
Any idea how this initialization could/should be handled?
I'd be happy with a workaround for the moment.
In the longer term, rather than extending ClassInitGenerator to handle this specific case, can I suggest that developers of such extension classes be given the option to implement some kind of Init hook method that will get executed as part of each classes' definition process? This would be equivalent to code that Ruby programmers can put inside a class or module definition. This hook method would be passed the class or module being initialized. We could then manually do whatever we needed, eg attach singleton methods, define constants, set class variables, etc.
More information about the Ironruby-core