summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--locale/en-us/setting.lua2
-rw-r--r--locale/pt-br/setting.lua2
-rw-r--r--locale/zh-cn/setting.lua2
-rw-r--r--locale/zh-tw/setting.lua2
-rw-r--r--script/plugins/ffi/init.lua16
-rw-r--r--test/plugins/ffi/test.lua2
6 files changed, 19 insertions, 7 deletions
diff --git a/locale/en-us/setting.lua b/locale/en-us/setting.lua
index 984125e8..b15f3659 100644
--- a/locale/en-us/setting.lua
+++ b/locale/en-us/setting.lua
@@ -440,3 +440,5 @@ command.exportDocument =
'Lua: Export Document ...'
command.addon_manager.open =
'Lua: Open Addon Manager ...'
+command.reloadFFIMeta =
+'Lua: Reload luajit ffi meta'
diff --git a/locale/pt-br/setting.lua b/locale/pt-br/setting.lua
index 63e2b7fc..5297bddd 100644
--- a/locale/pt-br/setting.lua
+++ b/locale/pt-br/setting.lua
@@ -440,3 +440,5 @@ command.exportDocument = -- TODO: need translate!
'Lua: Export Document ...'
command.addon_manager.open = -- TODO: need translate!
'Lua: Open Addon Manager ...'
+command.reloadFFIMeta = -- TODO: need translate!
+'Lua: Reload luajit ffi meta'
diff --git a/locale/zh-cn/setting.lua b/locale/zh-cn/setting.lua
index b407ca14..72ff9c75 100644
--- a/locale/zh-cn/setting.lua
+++ b/locale/zh-cn/setting.lua
@@ -439,3 +439,5 @@ command.exportDocument =
'Lua: 导出文档...'
command.addon_manager.open =
'Lua: 打开插件管理器...'
+command.reloadFFIMeta =
+'Lua: 重新生成luajit的FFI模块C语言元数据'
diff --git a/locale/zh-tw/setting.lua b/locale/zh-tw/setting.lua
index 0b40177f..351e6ca0 100644
--- a/locale/zh-tw/setting.lua
+++ b/locale/zh-tw/setting.lua
@@ -439,3 +439,5 @@ command.exportDocument = -- TODO: need translate!
'Lua: Export Document ...'
command.addon_manager.open = -- TODO: need translate!
'Lua: Open Addon Manager ...'
+command.reloadFFIMeta = -- TODO: need translate!
+'Lua: Reload luajit ffi meta'
diff --git a/script/plugins/ffi/init.lua b/script/plugins/ffi/init.lua
index f835d73f..17159ff2 100644
--- a/script/plugins/ffi/init.lua
+++ b/script/plugins/ffi/init.lua
@@ -1,12 +1,11 @@
-local searchCode = require 'plugins.ffi.searchCode'
-local cdefRerence = require 'plugins.ffi.cdefRerence'
local cdriver = require 'plugins.ffi.c-parser.cdriver'
local util = require 'plugins.ffi.c-parser.util'
local utility = require 'utility'
local SDBMHash = require 'SDBMHash'
local config = require 'config'
local fs = require 'bee.filesystem'
-local scope = require 'workspace.scope'
+local ws = require 'workspace'
+local furi = require 'file-uri'
local namespace <const> = 'ffi.namespace*.'
@@ -360,12 +359,15 @@ function m.build_single(codes, fileDir, uri)
if not texts then
return
end
+ local fullPath = fileDir /ws.getRelativePath(uri)
- local hash = ('%08x'):format(SDBMHash():hash(uri))
- local encoding = config.get(nil, 'Lua.runtime.fileEncoding')
- local filePath = fileDir / table.concat({ hash, encoding }, '_')
+ if fullPath:stem():string():find '%.' then
+ local newPath = fullPath:parent_path() / (fullPath:stem():string():gsub('%.', '/') .. ".lua")
+ fs.create_directories(newPath:parent_path())
+ fullPath = newPath
+ end
- utility.saveFile(tostring(filePath) .. '.d.lua', table.concat(texts, '\n'))
+ utility.saveFile(tostring(fullPath), table.concat(texts, '\n'))
return true
end
diff --git a/test/plugins/ffi/test.lua b/test/plugins/ffi/test.lua
index 68cec156..b46fe962 100644
--- a/test/plugins/ffi/test.lua
+++ b/test/plugins/ffi/test.lua
@@ -8,6 +8,8 @@ local template = require 'config.template'
template['Lua.runtime.version'].default = 'LuaJIT'
+TESTURI = furi.encode('/unittest.ffi.lua')
+
---@async
local function TestBuilder()
local builder = require 'core.command.reloadFFIMeta'