Skip to content

Commit b47e768

Browse files
Merge pull request #698 from MikaylaFischler/697-add-and-move-full-type-hinting-for-mekanism-peripherals
697 add and move full type hinting for mekanism peripherals
2 parents e45277e + b2b011d commit b47e768

40 files changed

+478
-238
lines changed

coordinator/backplane.lua

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ function backplane.init_displays(config)
7979

8080
local disp, iface = ppm.get_periph(config.MainDisplay), config.MainDisplay
8181

82+
---@cast disp Monitor
8283
displays.main = disp
8384
displays.main_iface = iface
8485

@@ -102,6 +103,7 @@ function backplane.init_displays(config)
102103
if not config.DisableFlowView then
103104
disp, iface = ppm.get_periph(config.FlowDisplay), config.FlowDisplay
104105

106+
---@cast disp Monitor
105107
displays.flow = disp
106108
displays.flow_iface = iface
107109

@@ -126,6 +128,7 @@ function backplane.init_displays(config)
126128
for i = 1, config.UnitCount do
127129
disp, iface = ppm.get_periph(config.UnitDisplays[i]), config.UnitDisplays[i]
128130

131+
---@cast disp Monitor
129132
displays.unit_displays[i] = disp
130133
displays.unit_ifaces[i] = iface
131134

@@ -212,7 +215,10 @@ function backplane.init(config, __shared_memory)
212215

213216
-- Speaker Init
214217

215-
_bp.speaker = ppm.get_device("speaker")
218+
local speaker = ppm.get_device("speaker")
219+
220+
---@cast speaker Speaker|nil
221+
_bp.speaker = speaker
216222

217223
if not _bp.speaker then
218224
log_boot("annunciator alarm speaker not found")
@@ -258,7 +264,7 @@ end
258264

259265
-- handle a backplane peripheral attach
260266
---@param type string
261-
---@param device table
267+
---@param device ppm_generic
262268
---@param iface string
263269
function backplane.attach(type, device, iface)
264270
local MQ__RENDER_DATA = _bp.smem.q_types.MQ__RENDER_DATA
@@ -377,7 +383,7 @@ end
377383

378384
-- handle a backplane peripheral detach
379385
---@param type string
380-
---@param device table
386+
---@param device ppm_generic
381387
---@param iface string
382388
function backplane.detach(type, device, iface)
383389
local MQ__RENDER_CMD = _bp.smem.q_types.MQ__RENDER_CMD

coordinator/process.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ function process.save(mode, alt_mode, burn_target, range_start, range_stop, char
498498
end
499499

500500
-- handle a start command acknowledgement
501-
---@param response table ack and configuration reply
501+
---@param response auto_start_ack ack and configuration reply
502502
function process.start_ack_handle(response)
503503
local ack = response[1]
504504

coordinator/startup.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ local renderer = require("coordinator.renderer")
2020
local sounder = require("coordinator.sounder")
2121
local threads = require("coordinator.threads")
2222

23-
local COORDINATOR_VERSION = "v1.8.1"
23+
local COORDINATOR_VERSION = "v1.8.2"
2424

2525
local CHUNK_LOAD_DELAY_S = 30.0
2626

graphics/core.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ local flasher = require("graphics.flasher")
77

88
local core = {}
99

10-
core.version = "2.4.10"
10+
core.version = "2.4.11"
1111

1212
core.flasher = flasher
1313
core.events = events

graphics/element.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ function element.new(args, constraint, child_offset_x, child_offset_y)
552552

553553
-- get all children
554554
---@nodiscard
555-
---@return table children table of graphics_element objects
555+
---@return graphics_element[] children this element's children
556556
function public.get_children()
557557
local list = {}
558558
for k, v in pairs(protected.children) do list[k] = v.get() end

graphics/elements/PipeNetwork.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ return function (args)
163163
end
164164

165165
-- draw a particular map cell
166-
---@param map table 2D cell map
166+
---@param map _pipe_map_entry[][] 2D cell map
167167
---@param x integer x coord
168168
---@param y integer y coord
169169
local function draw_map_cell(map, x, y)
170-
local entry = map[x][y] ---@type _pipe_map_entry already confirmed not false
170+
local entry = map[x][y]
171171
local char
172172
local invert = false
173173

pocket/startup.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ local pocket = require("pocket.pocket")
2222
local renderer = require("pocket.renderer")
2323
local threads = require("pocket.threads")
2424

25-
local POCKET_VERSION = "v1.1.0"
25+
local POCKET_VERSION = "v1.1.1"
2626

2727
local println = util.println
2828
local println_ts = util.println_ts

pocket/ui/docs.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ local function tip(body)
7070
end
7171

7272
---@param type DOC_LIST_TYPE
73-
---@param items table
74-
---@param colors table|nil colors for indicators or nil for normal lists
73+
---@param items string[]
74+
---@param colors color[]|nil colors for indicators or nil for normal lists
7575
local function list(type, items, colors)
7676
---@class pocket_doc_list
7777
local list_def = { type = DOC_ITEM_TYPE.LIST, list_type = type, items = items, colors = colors }

pocket/ui/pages/guide_section.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ local DOC_TYPE = docs.DOC_ITEM_TYPE
2525
local LIST_TYPE = docs.DOC_LIST_TYPE
2626

2727
-- new guide documentation section
28-
---@param data { [1]: pocket_app, [2]: Div, [3]: Div[], [4]: { [string]: function }, [5]: [ string, string, string, function ][], [6]: cpair, [7]: cpair }
28+
---@param data pkt__sect_construct_data
2929
---@param base_page nav_tree_page
3030
---@param title string
31-
---@param items table
31+
---@param items pkt__doc_item[]
3232
---@param scroll_height integer
3333
---@return nav_tree_page
3434
return function (data, base_page, title, items, scroll_height)
@@ -53,7 +53,7 @@ return function (data, base_page, title, items, scroll_height)
5353
local page_end
5454

5555
for i = 1, #items do
56-
local item = items[i] ---@type pocket_doc_sect|pocket_doc_subsect|pocket_doc_text|pocket_doc_note|pocket_doc_tip|pocket_doc_list
56+
local item = items[i]
5757

5858
if item.type == DOC_TYPE.SECTION then
5959
---@cast item pocket_doc_sect

reactor-plc/backplane.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ function backplane.init(config, __shared_memory)
114114

115115
-- mount a virtual peripheral to init the RPS with
116116
local _, dev = ppm.mount_virtual()
117+
---@diagnostic disable-next-line: assign-type-mismatch
117118
plc_dev.reactor = dev
118119

119120
log.info("BKPLN: mounted virtual device as reactor")
@@ -156,7 +157,7 @@ end
156157
-- handle a backplane peripheral attach
157158
---@param iface string
158159
---@param type string
159-
---@param device table
160+
---@param device ppm_generic
160161
---@param print_no_fp function
161162
function backplane.attach(iface, type, device, print_no_fp)
162163
local MQ__RPS_CMD = _bp.smem.q_types.MQ__RPS_CMD
@@ -170,6 +171,8 @@ function backplane.attach(iface, type, device, print_no_fp)
170171

171172
if type ~= nil and device ~= nil then
172173
if type == "fissionReactorLogicAdapter" then
174+
---@cast device FissionReactor
175+
173176
if not state.no_reactor then
174177
log.warning("BKPLN: !! DANGER !! an additional reactor (" .. iface .. ") was connected and will not be used!")
175178
log.warning(multi_reactor_warn)
@@ -269,7 +272,7 @@ end
269272
-- handle a backplane peripheral detach
270273
---@param iface string
271274
---@param type string
272-
---@param device table
275+
---@param device ppm_generic
273276
---@param print_no_fp function
274277
function backplane.detach(iface, type, device, print_no_fp)
275278
local MQ__RPS_CMD = _bp.smem.q_types.MQ__RPS_CMD
@@ -281,6 +284,8 @@ function backplane.detach(iface, type, device, print_no_fp)
281284
local sys = _bp.smem.plc_sys
282285

283286
if type == "fissionReactorLogicAdapter" then
287+
---@cast device FissionReactor
288+
284289
log.info("BKPLN: REACTOR LINK_DOWN " .. iface)
285290

286291
-- detect and warn about multiple reactors

0 commit comments

Comments
 (0)