From 15134935602a546103a26f4b3ecc72da25896f09 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 26 Feb 2014 22:32:57 +0100 Subject: lua: mark table values returned by get_property_native with their type Lua doesn't distinguish between arrays and maps on the language level; there are just tables. Use metatables to mark these tables with their actual types. In particular, it allows distinguishing empty arrays from empty tables. --- player/lua/defaults.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'player/lua') diff --git a/player/lua/defaults.lua b/player/lua/defaults.lua index f8fe05ff82..0a04e26761 100644 --- a/player/lua/defaults.lua +++ b/player/lua/defaults.lua @@ -1,4 +1,11 @@ -mp.UNKNOWN_TYPE = "this value is inserted if the C type is not supported" +mp.UNKNOWN_TYPE.info = "this value is inserted if the C type is not supported" +mp.UNKNOWN_TYPE.type = "UNKNOWN_TYPE" + +mp.ARRAY.info = "native array" +mp.ARRAY.type = "ARRAY" + +mp.MAP.info = "native map" +mp.MAP.type = "MAP" function mp.get_script_name() return mp.script_name -- cgit v1.2.3