chore: upgrade ts2lua-unreal to v0.3.1 with lowercase lib/module.lua & lib/class.lua and commit framework refactor
This commit is contained in:
1 parent
783dccf53d
commit
3572f2da43
206 files changed
+14442
-13186
No files matched your search
+15
-143
@@ -4,142 +4,6 @@ local function __TS__New(target, ...)
|
||||
return instance
|
||||
end
|
||||
|
||||
local function __TS__CountVarargs(...)
|
||||
return select("#", ...)
|
||||
end
|
||||
|
||||
local function __TS__SparseArrayNew(...)
|
||||
local sparseArray = {...}
|
||||
sparseArray.sparseLength = __TS__CountVarargs(...)
|
||||
return sparseArray
|
||||
end
|
||||
|
||||
local function __TS__SparseArrayPush(sparseArray, ...)
|
||||
local args = {...}
|
||||
local argsLen = __TS__CountVarargs(...)
|
||||
local listLen = sparseArray.sparseLength
|
||||
for i = 1, argsLen do
|
||||
sparseArray[listLen + i] = args[i]
|
||||
end
|
||||
sparseArray.sparseLength = listLen + argsLen
|
||||
end
|
||||
|
||||
local function __TS__SparseArraySpread(sparseArray)
|
||||
local _unpack = unpack or table.unpack
|
||||
return _unpack(sparseArray, 1, sparseArray.sparseLength)
|
||||
end
|
||||
|
||||
local function __TS__ArraySplice(self, ...)
|
||||
local args = {...}
|
||||
local len = #self
|
||||
local actualArgumentCount = __TS__CountVarargs(...)
|
||||
local start = args[1]
|
||||
local deleteCount = args[2]
|
||||
if start < 0 then
|
||||
start = len + start
|
||||
if start < 0 then
|
||||
start = 0
|
||||
end
|
||||
elseif start > len then
|
||||
start = len
|
||||
end
|
||||
local itemCount = actualArgumentCount - 2
|
||||
if itemCount < 0 then
|
||||
itemCount = 0
|
||||
end
|
||||
local actualDeleteCount
|
||||
if actualArgumentCount == 0 then
|
||||
actualDeleteCount = 0
|
||||
elseif actualArgumentCount == 1 then
|
||||
actualDeleteCount = len - start
|
||||
else
|
||||
actualDeleteCount = deleteCount or 0
|
||||
if actualDeleteCount < 0 then
|
||||
actualDeleteCount = 0
|
||||
end
|
||||
if actualDeleteCount > len - start then
|
||||
actualDeleteCount = len - start
|
||||
end
|
||||
end
|
||||
local out = {}
|
||||
for k = 1, actualDeleteCount do
|
||||
local from = start + k
|
||||
if self[from] ~= nil then
|
||||
out[k] = self[from]
|
||||
end
|
||||
end
|
||||
if itemCount < actualDeleteCount then
|
||||
for k = start + 1, len - actualDeleteCount do
|
||||
local from = k + actualDeleteCount
|
||||
local to = k + itemCount
|
||||
if self[from] then
|
||||
self[to] = self[from]
|
||||
else
|
||||
self[to] = nil
|
||||
end
|
||||
end
|
||||
for k = len - actualDeleteCount + itemCount + 1, len do
|
||||
self[k] = nil
|
||||
end
|
||||
elseif itemCount > actualDeleteCount then
|
||||
for k = len - actualDeleteCount, start + 1, -1 do
|
||||
local from = k + actualDeleteCount
|
||||
local to = k + itemCount
|
||||
if self[from] then
|
||||
self[to] = self[from]
|
||||
else
|
||||
self[to] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
local j = start + 1
|
||||
for i = 3, actualArgumentCount do
|
||||
self[j] = args[i]
|
||||
j = j + 1
|
||||
end
|
||||
for k = #self, len - actualDeleteCount + itemCount + 1, -1 do
|
||||
self[k] = nil
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
local function __TS__ArraySort(self, compareFn)
|
||||
if compareFn ~= nil then
|
||||
table.sort(
|
||||
self,
|
||||
function(a, b) return compareFn(nil, a, b) < 0 end
|
||||
)
|
||||
else
|
||||
table.sort(self)
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
local function __TS__ArrayIndexOf(self, searchElement, fromIndex)
|
||||
if fromIndex == nil then
|
||||
fromIndex = 0
|
||||
end
|
||||
local len = #self
|
||||
if len == 0 then
|
||||
return -1
|
||||
end
|
||||
if fromIndex >= len then
|
||||
return -1
|
||||
end
|
||||
if fromIndex < 0 then
|
||||
fromIndex = len + fromIndex
|
||||
if fromIndex < 0 then
|
||||
fromIndex = 0
|
||||
end
|
||||
end
|
||||
for i = fromIndex + 1, len do
|
||||
if self[i] == searchElement then
|
||||
return i - 1
|
||||
end
|
||||
end
|
||||
return -1
|
||||
end
|
||||
|
||||
local function __TS__ClassExtends(target, base)
|
||||
target.____super = base
|
||||
local staticMetatable = setmetatable({__index = base}, base)
|
||||
@@ -202,14 +66,22 @@ local function __TS__InstanceOf(obj, classTbl)
|
||||
return false
|
||||
end
|
||||
|
||||
local function __TS__ArraySetLength(self, length)
|
||||
if length < 0 or length ~= length or length == math.huge or math.floor(length) ~= length then
|
||||
error(
|
||||
"invalid array length: " .. tostring(length),
|
||||
0
|
||||
)
|
||||
end
|
||||
for i = length + 1, #self do
|
||||
self[i] = nil
|
||||
end
|
||||
return length
|
||||
end
|
||||
|
||||
return {
|
||||
__TS__New = __TS__New,
|
||||
__TS__SparseArrayNew = __TS__SparseArrayNew,
|
||||
__TS__SparseArrayPush = __TS__SparseArrayPush,
|
||||
__TS__SparseArraySpread = __TS__SparseArraySpread,
|
||||
__TS__ArraySplice = __TS__ArraySplice,
|
||||
__TS__ArraySort = __TS__ArraySort,
|
||||
__TS__ArrayIndexOf = __TS__ArrayIndexOf,
|
||||
__TS__ClassExtends = __TS__ClassExtends,
|
||||
__TS__InstanceOf = __TS__InstanceOf
|
||||
__TS__InstanceOf = __TS__InstanceOf,
|
||||
__TS__ArraySetLength = __TS__ArraySetLength
|
||||
}
|
||||
Reference in new issue
Block a user