• Catalyst - A pure lua framework for metaclasses (with inheritance) in GMod 13
    1 replies, posted
I developed this library earlier this year. It provides a (fairly) rudimentary framework for metaclasses, complete with inheritance. I have found it insanely increases my productivity while coding in GLua. [url=http://www.filedropper.com/ggcatalyst_1]Here is a zip of the repo.[/url] I'll get a public repo up eventually. Example definition of a class: [code]local _MT, QUEUE = Catalyst.MetaClass.Generate("Queue"); function QUEUE:Initialize ( starting_list ) self._in_stack = Stack(starting_list); self._out_stack = Stack(); end[/code] How to instantiate an object: [code]queue = Queue();[/code] Inheritance will pass through all methods that are not already defined on the child class and which do not start with an underscore. The super class Initialize is never automatically called, but you can do so by using the CallSuper method. How to inherit, where "Base" is the super class: [code]local _MT, QUEUE = Catalyst.MetaClass.Generate("Queue", "Base");[/code] How to call a method in the super class that you've overwritten in the child class: [code]self:CallSuper("Initialize", ...);[/code] How to call an abstract method which may or may not be defined (i.e. to call a method on a class which inherits from this one): [code]self:CallAbstract("OnPickup", ...);[/code] There is also introduced the concept of a Templated Class, of which more can be learned about on the readme in the repo. If you have any question or find any bugs, feel free to post here or send me a PM. P.S. I posted this here because it's more for the developer community than it is for the consumer.
Out of curiosity, does anyone have a copy of the repo? I was just wondering how this framework even worked.
Sorry, you need to Log In to post a reply to this thread.