From: ts Date: 2002-05-12T01:09:28+09:00 Subject: Re: Ruby extensions - pushing classes into other modules >>>>> "D" == Daniel Berger writes: D> I want to create a base class called "Sys" that would simply serve as a ^^^^^ module, no ? D> common namespace for future modules. I don't want to have to do a D> I would like to be able to stick each class in its own .c file. This Well, in your sys.c you write something like this (*warning* not tested) VALUE sys_mSys; void Init_sys() { sys_mSys = rb_define_module("Sys"); Init_uname(); Init_hostname(); /* ... */ } In uname.c extern VALUE sys_mSys; void Init_uname() { VALUE sys_cUname; sys_cUname = rb_define_class_under(sys_mSys, "Uname", rb_cObject); /* ... */ } This suppose that sys_mSys is a global variable. D> would not only help reduce serious bloat in one file, it would allow D> others to easily add their own extensions under the 'Sys' namespace. Now if I want to extend the Sys namespace with my private class Sys::Own, I'll write in the file own.c void Init_own() { VALUE sys_mSys, own_cOwn; rb_require("sys"); sys_mSys = rb_const_get(rb_cObject, rb_intern("Sys")); own_cOwn = rb_define_class_under(sys_mSys, "Own", rb_cObject); /* ... */ } Guy Decoux