[Gambas-devel] Provide special auto-instance of a class

tobi tobias at ...692...
Wed Apr 4 18:54:52 CEST 2012


Hi,

I have a non-static class and want to derive a special object of it upon class load. The
GB_AUTO_CREATABLE() macro doesn't really help because it's not about an ordinary object, I have to
insert special values. The best would be if I could derive an object from that class, modify it
behind the scenes and provide it for project-global use under a certain name. I read that there are
no project-global variables in Gambas (I actually never needed them) so this is not an option.
As an alternative I'd create a new static auto-creatable class that just inherits my ordinary class
and overwrites its _new() special method. Despite I'm optimistic about that approach I want to ask
if there is an even more elegant way? (I also can't think of any class that does suchlike, it's
maybe just beyond my daily use of Gambas)

In particular, if it helps, it is about: The ncurses library provides an stdscr window after being
initialised which represents the terminal in full dimensions. I wrote an (almost working) window
class in which stdscr shall be encapsulated upon ncurses instanciation.

Regards,
Tobi





More information about the Devel mailing list