You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.2 KiB
Lua
61 lines
1.2 KiB
Lua
require "oop.init"
|
|
|
|
local IObject = mixin("test1", "test2", "test3", "test4")
|
|
|
|
local prop = Property(IObject)
|
|
prop:accessor("key1", 1)
|
|
prop:accessor("key2", 2)
|
|
|
|
function IObject:__init()
|
|
end
|
|
|
|
function IObject:test1()
|
|
print("key1", self:get_key1())
|
|
self:set_key2(4)
|
|
print("key2", self:get_key2())
|
|
self:set_key3(6)
|
|
print("key3", self:get_key3())
|
|
end
|
|
|
|
function IObject:test2()
|
|
print("key2", self.key2)
|
|
end
|
|
|
|
function IObject:test3()
|
|
print("key3", self.key3)
|
|
end
|
|
|
|
local Object = class(nil, IObject)
|
|
local prop2 = Property(Object)
|
|
prop2:accessor("key3", 3)
|
|
function Object:__init()
|
|
end
|
|
|
|
function Object:__release()
|
|
print("release", self)
|
|
end
|
|
|
|
function Object:run()
|
|
print("key3", self:get_key3())
|
|
print("key1", self:get_key1())
|
|
print("key2", self:get_key2())
|
|
self:invoke("test1")
|
|
end
|
|
|
|
local TEST1 = Enum("TEST1", 0, "ONE", "THREE", "TWO")
|
|
print(TEST1.TWO)
|
|
local TEST2 = Enum("TEST2", 1, "ONE", "THREE", "TWO")
|
|
TEST2.FOUR = TEST2()
|
|
print(TEST2.TWO, TEST2.FOUR)
|
|
local TEST3 = Enum("TEST3", 0)
|
|
TEST3("ONE")
|
|
TEST3("TWO")
|
|
TEST3("FOUR", 4)
|
|
local five = TEST3("FIVE")
|
|
print(TEST3.TWO, TEST3.FOUR, TEST3.FIVE, five)
|
|
|
|
local obj = Object()
|
|
obj:run()
|
|
|
|
return Object
|