KoboldAI-Client/extern/lualibs/pl/class.lua

7 lines
3.6 KiB
Lua

-- Penlight 1.11.0-1 | /lua/pl/class.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a,b,c,d,e,f,g,h,i=_G.error,_G.getmetatable,_G.io,_G.pairs,_G.rawget,_G.rawset,_G.setmetatable,_G.tostring,_G.type;local j;local function k(l,m,...)local n=e(l,'_init')local o=e(l,'_parent_with_init')if o then if not n then n=e(o,'_init')o=e(o,'_parent_with_init')end;if o then f(m,'super',function(m,...)k(o,m,...)end)end else f(m,'super',nil)end;local p=n(m,...)if o then f(m,'super',nil)end;return p end;local function q(self,r)if r==nil then return b(self)end;local s=b(self)if not s then return false end;while s do if s==r then return true end;s=e(s,'_base')end;return false end;local function t(r,m)if i(r)~='table'or not e(r,'is_a')then return false end;return r.is_a(m,r)end;local function u(r,m)return g(m,r)end;local function v(m)local w=m._class;local x=e(w,'_name')g(m,nil)local y=h(m)g(m,w)if x then y=x..y:gsub('table','')end;return y end;local function z(A,B,C)for D,E in d(B)do if not C or A[D]==nil then A[D]=E end end end;local function F(G,H,l)local w={}local I=i(G)=='table'and not b(G)if I then l=G;G=l._base else l=l or{}end;if i(G)=='table'then z(l,G,I)l._base=G;if e(l,'_handler')then w.__index=l._handler end elseif G~=nil then a("must derive from a table type",3)end;l.__index=l;g(l,w)if not I then if G and e(G,'_init')then l._parent_with_init=G end;l._init=nil end;if G and e(G,'_class_init')then G._class_init(l,H)end;w.__call=function(J,...)local m;if e(l,'_create')then m=l._create(...)end;if not m then m={}end;g(m,l)if e(l,'_init')or e(l,'_parent_with_init')then local p=k(l,m,...)if p then m=p;g(m,l)end end;if G and e(G,'_post_init')then G._post_init(m)end;return m end;l.catch=function(self,K)if i(self)=="function"then K=self end;l._handler=K;w.__index=K end;l.is_a=q;l.class_of=t;l.cast=u;l._class=l;if not e(l,'__tostring')then l.__tostring=v end;return l end;local L;L=g({},{__call=function(M,...)return F(...)end,__index=function(N,O)if O=='class'then c.stderr:write('require("pl.class").class is deprecated. Use require("pl.class")\n')return L end;j=j or require'pl.compat'local P=j.getfenv(2)return function(...)local l=F(...)l._name=O;f(P,O,l)return l end end})L.properties=L()function L.properties._class_init(r)r.__index=function(Q,O)local E=r[O]if E then return E end;E=e(r,'get_'..O)if E then return E(Q)end;return e(Q,'_'..O)end;r.__newindex=function(Q,O,R)local S='set_'..O;local T=r[S]if T then T(Q,R)else f(Q,O,R)end end end;return L