-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
65 lines (51 loc) · 1.86 KB
/
Copy pathinit.lua
File metadata and controls
65 lines (51 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---@diagnostic disable: lowercase-global
---@diagnostic disable-next-line: unused-local
local mname, murl -- Standard lua `require` arguments
, margs = ... -- Reserved for user custom extension
---@class simpleclass.INIT_OPTIONS
local options = {}
--==================================== INIT OPTIONS ====================================--
options.GLOBAL_IMPORT = true;
options.INTERFACE_INCLUDED = true;
options.DEFAULT_I_FEATURE = "general";
--==================================== INIT OPTIONS ====================================--
-- Merge import options
if type(margs) == "table" then
for k, v in next, margs do
if v ~= nil then
options[k] = v
end
end
end
local M = require "simpleclass.m" ---@class simpleclass
require "simpleclass.object"
require "simpleclass.class"
require "simpleclass.super"
---Whether to register classes as global variables automatically.
---Default true when import globally, false otherwise. Could be overridden in runtime.
---@type boolean
M.AUTO_GLOBAL = false
---@alias simpleclass.I_FEATURE
---| "general" Full interface feature.
---| "nocheck" Skip interface checking.
---| "lexical" Only interface syntax. (for LS analysis)
---Interface feature to use, meaningless if interface module not included.
---**Warning**: switch in "general" & "nocheck" is safe, BUT "lexical" skipping definition is irreversible.
---@type simpleclass.I_FEATURE
M.I_FEATURE = options.DEFAULT_I_FEATURE
---Include interface module
if options.INTERFACE_INCLUDED then
require "simpleclass.interface"
end
---Global import
if options.GLOBAL_IMPORT then
M.AUTO_GLOBAL = true
class = M.class
super = M.super
interface = M.interface
cls_type = M.type
object = M.object ---@type object
isinstance = object.isInstance
issubclass = object.isExtends
end
return M