albertodemichelis / squirrel

Official repository for the programming language Squirrel
http://www.squirrel-lang.org
MIT License
894 stars 148 forks source link

Enabling static access with the _get meta method. #266

Open Katsuya100 opened 1 year ago

Katsuya100 commented 1 year ago

I would like to be able to implement the following to support C# and C++ static variable bindings.

class StaticGetSample
{
    function _get(key)
    {
        switch (key)
        {
            case "foo":
                return "a";
            case "bar":
                return "b";
        }
        return null;
    }
}

// output `a`.
print(StaticGetSample.foo);

Meta method call of SQClass was implemented with reference to the implementation of SQInstance.