aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2011-06-22 19:28:20 -0400
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2011-06-22 19:28:20 -0400
commit09e50d3ca36591632e0b4e35deaecd548678b6f4 (patch)
tree5b3dd429184ce2c10f7144dc021d80458ec4dc58 /scripts
parent9932e855027e6025fbbb4690e426d7b55c2c2f4c (diff)
Refactored scripts/gen_iface.lua.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gen_iface.lua172
1 files changed, 97 insertions, 75 deletions
diff --git a/scripts/gen_iface.lua b/scripts/gen_iface.lua
index 8cb5a2f8..6996ff2e 100755
--- a/scripts/gen_iface.lua
+++ b/scripts/gen_iface.lua
@@ -4,14 +4,21 @@
-- This script generates the _SCINTILLA table from SciTE's Lua Interface tables.
local f = io.open('../../scite-latest/scite/src/IFaceTable.cxx')
-local contents = f:read('*all')
+local iface = f:read('*all')
f:close()
-local constants = contents:match('ifaceConstants%[%] = (%b{})')
-local functions = contents:match('ifaceFunctions%[%] = (%b{})')
-local properties = contents:match('ifaceProperties%[%] = (%b{})')
+local string_format = string.format
+local constants, functions, properties = {}, {}, {}
+local types = {
+ void = 0, int = 1, length = 2, position = 3, colour = 4, bool = 5,
+ keymod = 6, string = 7, stringresult = 8, cells = 9, textrange = 10,
+ findtext = 11, formatrange = 12
+}
-local out = [[
+f = io.open('../core/iface.lua', 'w')
+
+-- Write header.
+f:write [[
-- Copyright 2007-2011 Mitchell mitchell<att>caladbolg.net. See LICENSE.
---
@@ -21,99 +28,116 @@ module('_SCINTILLA', package.seeall)
]]
-local types = {
- void = 0, int = 1, length = 2, position = 3, colour = 4, bool = 5,
- keymod = 6, string = 7, stringresult = 8, cells = 9, textrange = 10,
- findtext = 11, formatrange = 12
-}
-
-out = out..[[
----
--- Scintilla constants.
--- @class table
--- @name constants
-constants = {]]
--- {"constant", value}
-for item in constants:sub(2, -2):gmatch('%b{}') do
+-- Constants ({"constant", value}).
+for item in iface:match('Constants%[%] = (%b{})'):sub(2, -2):gmatch('%b{}') do
local name, value = item:match('^{"(.-)",(.-)}')
if not name:find('^IDM_') and not name:find('^SCE_') and
not name:find('^SCLEX_') then
if name == 'SC_MASK_FOLDERS' then value = '-33554432' end
- local line = (" %s = %s,"):format(name, value)
- out = out..line
+ constants[#constants + 1] = string_format('%s=%s', name, value)
end
end
-out = out..string.gsub([[
-SCLEX_CONTAINER = 0,
-SCLEX_NULL = 1,
-SCLEX_LPEG = 999,
-SCLEX_AUTOMATIC = 1000,
-SCN_STYLENEEDED = 2000,
-SCN_CHARADDED = 2001,
-SCN_SAVEPOINTREACHED = 2002,
-SCN_SAVEPOINTLEFT = 2003,
-SCN_MODIFYATTEMPTRO = 2004,
-SCN_KEY = 2005,
-SCN_DOUBLECLICK =2006,
-SCN_UPDATEUI = 2007,
-SCN_MODIFIED = 2008,
-SCN_MACRORECORD = 2009,
-SCN_MARGINCLICK = 2010,
-SCN_NEEDSHOWN = 2011,
-SCN_PAINTED = 2013,
-SCN_USERLISTSELECTION = 2014,
-SCN_URIDROPPED = 2015,
-SCN_DWELLSTART = 2016,
-SCN_DWELLEND = 2017,
-SCN_ZOOM = 2018,
-SCN_HOTSPOTCLICK = 2019,
-SCN_HOTSPOTDOUBLECLICK = 2020,
-SCN_CALLTIPCLICK = 2021,
-SCN_AUTOCSELECTION = 2022,
-SCN_INDICATORCLICK = 2023,
-SCN_INDICATORRELEASE = 2024,]], '\n', ' ')
-out = out..' }\n\n'
-
-out = out..[[
+
+-- Events added to constants.
+local events = {
+ SCN_STYLENEEDED = 2000,
+ SCN_CHARADDED = 2001,
+ SCN_SAVEPOINTREACHED = 2002,
+ SCN_SAVEPOINTLEFT = 2003,
+ SCN_MODIFYATTEMPTRO = 2004,
+ SCN_KEY = 2005,
+ SCN_DOUBLECLICK =2006,
+ SCN_UPDATEUI = 2007,
+ SCN_MODIFIED = 2008,
+ SCN_MACRORECORD = 2009,
+ SCN_MARGINCLICK = 2010,
+ SCN_NEEDSHOWN = 2011,
+ SCN_PAINTED = 2013,
+ SCN_USERLISTSELECTION = 2014,
+ SCN_URIDROPPED = 2015,
+ SCN_DWELLSTART = 2016,
+ SCN_DWELLEND = 2017,
+ SCN_ZOOM = 2018,
+ SCN_HOTSPOTCLICK = 2019,
+ SCN_HOTSPOTDOUBLECLICK = 2020,
+ SCN_CALLTIPCLICK = 2021,
+ SCN_AUTOCSELECTION = 2022,
+ SCN_INDICATORCLICK = 2023,
+ SCN_INDICATORRELEASE = 2024,
+ SCN_AUTOCCANCELLED = 2026,
+ SCN_AUTOCCHARDELETED = 2027,
+ SCN_HOTSPOTRELEASECLICK = 2028
+}
+for event, value in pairs(events) do
+ constants[#constants + 1] = string_format('%s=%d', event, value)
+end
+-- Lexers added to constants.
+local lexers = {
+ SCLEX_CONTAINER = 0,
+ SCLEX_NULL = 1,
+ SCLEX_LPEG = 999,
+ SCLEX_AUTOMATIC = 1000
+}
+for lexer, value in pairs(lexers) do
+ constants[#constants + 1] = string_format('%s=%d', lexer, value)
+end
+
+-- Write constants.
+f:write [[
---
--- Scintilla functions.
+-- Scintilla constants.
-- @class table
--- @name functions
-functions = {]]
--- {"function", msg_id, iface_*, {iface_*, iface_*}}
-for item in functions:sub(2, -2):gmatch('%b{}') do
+-- @name constants
+constants = {]]
+f:write(table.concat(constants, ','))
+f:write('}\n\n')
+
+-- Functions ({"function", msg_id, iface_*, {iface_*, iface_*}}).
+for item in iface:match('Functions%[%] = (%b{})'):sub(2, -2):gmatch('%b{}') do
local name, msg_id, rt_type, p1_type, p2_type =
item:match('^{"(.-)"%D+(%d+)%A+iface_(%a+)%A+iface_(%a+)%A+iface_(%a+)')
name = name:gsub('([a-z])([A-Z])', '%1_%2')
name = name:gsub('([A-Z])([A-Z][a-z])', '%1_%2')
name = name:lower()
- local line = (" %s = {%d, %d, %d, %d},"):format(
- name, msg_id, types[rt_type], types[p1_type], types[p2_type])
- out = out..line
+ local line = string_format('%s={%d,%d,%d,%d}', name, msg_id, types[rt_type],
+ types[p1_type], types[p2_type])
+ functions[#functions + 1] = line
end
-out = out..' }\n\n'
-out = out..[[
+-- Write functions.
+f:write [[
---
--- Scintilla properties.
+-- Scintilla functions.
-- @class table
--- @name properties
-properties = {]]
--- {"property", get_id, set_id, rt_type, p1_type}
-for item in properties:sub(2, -2):gmatch('%b{}') do
+-- @name functions
+functions = {]]
+f:write(table.concat(functions, ','))
+f:write('}\n\n')
+
+-- Properties ({"property", get_id, set_id, rt_type, p1_type}).
+for item in iface:match('Properties%[%] = (%b{})'):sub(2, -2):gmatch('%b{}') do
local name, get_id, set_id, rt_type, p1_type =
item:match('^{"(.-)"%D+(%d+)%D+(%d+)%A+iface_(%a+)%A+iface_(%a+)')
name = name:gsub('([a-z])([A-Z])', '%1_%2')
name = name:gsub('([A-Z])([A-Z][a-z])', '%1_%2')
name = name:lower()
- local line = (" %s = {%d, %d, %d, %d},"):format(
- name, get_id, set_id, types[rt_type], types[p1_type])
- out = out..line
+ properties[#properties + 1] = string_format('%s={%d,%d,%d,%d}', name, get_id,
+ set_id, types[rt_type],
+ types[p1_type])
end
-out = out..' }\n'
-out = out..[[
+-- Write properties.
+f:write [[
+---
+-- Scintilla properties.
+-- @class table
+-- @name properties
+properties = {]]
+f:write(table.concat(properties, ','))
+f:write('}\n\n')
+-- Write footer.
+f:write [[
local marker_number, indic_number, list_type = -1, 7, 0
---
@@ -149,6 +173,4 @@ function next_user_list_type()
end
]]
-f = io.open('../core/iface.lua', 'w')
-f:write(out)
f:close()