diff options
Diffstat (limited to 'examples/dynamic_dispatch_table.lua')
-rw-r--r-- | examples/dynamic_dispatch_table.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/dynamic_dispatch_table.lua b/examples/dynamic_dispatch_table.lua new file mode 100644 index 0000000..c515621 --- /dev/null +++ b/examples/dynamic_dispatch_table.lua @@ -0,0 +1,16 @@ +local get_length_table = { + [".."] = function(match) + local bytes = string.byte(match, 1, 2) + local length = bytes[1] * 256^2 + bytes[2] -- TODO byte order? + local get_binary_data_table = { + [string.rep(".", length)] = function(match) + command_queue:enqueue(match) + dispatch_table:register_handler_table(get_length_table) + end + } + + dispatch_table:register_handler_table(get_binary_data_table) + end +} + +return get_length_table |