From 24a75df6d18307ec1e99a9c3146d860ffb94b251 Mon Sep 17 00:00:00 2001 From: actboy168 Date: Fri, 26 Apr 2024 23:22:34 +0800 Subject: [PATCH] remove path obj --- doc/luamake.lua | 5 ++--- scripts/pathutil.lua | 37 +++++++------------------------------ scripts/version.lua | 2 +- 3 files changed, 10 insertions(+), 34 deletions(-) diff --git a/doc/luamake.lua b/doc/luamake.lua index 1681469..d7c6d07 100644 --- a/doc/luamake.lua +++ b/doc/luamake.lua @@ -1,9 +1,8 @@ ---@meta luamake ----@class fs.path ---@class LmPath ---@alias LmStrlist any ----@alias LmValue string | fs.path | LmPath +---@alias LmValue string | LmPath ---@class LmTargetAttri ---@field builddir string? @@ -79,7 +78,7 @@ end --- --- Create an absolute path, base is workdir. --- ----@param value string | fs.path +---@param value string ---@return LmPath function lm:path(value) end diff --git a/scripts/pathutil.lua b/scripts/pathutil.lua index abd4222..469b732 100644 --- a/scripts/pathutil.lua +++ b/scripts/pathutil.lua @@ -1,13 +1,7 @@ local fsutil = require "fsutil" - -local mt = {} - -local function create_internal(path) - return setmetatable({ value = path }, mt) -end +local fs = require "bee.filesystem" local function path_normalize(base, path) - path = tostring(path) if path:sub(1, 1) ~= "$" then if not fsutil.is_absolute(path) then path = fsutil.normalize(base, path) @@ -18,40 +12,23 @@ local function path_normalize(base, path) end local function is(path) - return mt == getmetatable(path) + return type(path) == "userdata" end local function create(workdir, path) - if type(path) == "userdata" then - path = tostring(path) - else - path = path_normalize(workdir, path) - end - return create_internal(path) + return fs.path(path_normalize(workdir, path)) end local function tostr(base, path) if is(path) then - return path.value + return tostring(path) + else + return path_normalize(base, path) end - return path_normalize(base, path) end local function tovalue(path) - if is(path) then - return true, path.value - end - return false, tostring(path) -end - -function mt.__concat(lft, rht) - if type(lft) == "string" then - local path = lft..rht.value - return create_internal(path) - else - local path = lft.value..rht - return create_internal(path) - end + return is(path), tostring(path) end return { diff --git a/scripts/version.lua b/scripts/version.lua index 567987d..2b8b260 100644 --- a/scripts/version.lua +++ b/scripts/version.lua @@ -1 +1 @@ -return "1.9" +return "1.10"