Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Impliment Class Property To Accept Class As Type #7

Description

@rdlaitila

Implement functionality to allow a class property to have a type of another class. For example:

local MyClass = require('MyClass')

local MyOtherClass = upperclass:define("MyOtherClass")

property : myClassProperty {
    nil;
    get='public';
    set='private';
    type=MyClass
}

function public:__construct()
    self.myClassProperty = MyClass()
end

return upperclass:compile(MyOtherClass)

When a class property is attempted to be set, it will check if the input value's class name (CLASS.imp.name) matches the class name of the property's type field. Ex:

if INPUT_VALUE.__imp__.name == TYPE_VALUE.__imp__.name then
    -- Allow set
end

The type field must be unquoted with the lua variable containing the class definition.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions