Skip to content

Commit 6bd2f25

Browse files
committed
Stash code useful for magic property access
1 parent 83b7a3a commit 6bd2f25

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

fluent/_nodes.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,17 @@ function FTL.Message:set_attribute (attribute)
124124
local k = #attributes + 1
125125
attributes[k] = attribute
126126
map[id] = k
127+
-- TODO Fix with working catch?
128+
-- getmetatable(self)[id] = attribute
127129
end
128130

129131
function FTL.Message:get_attribute (attribute)
130-
local attributes = rawget(self, "attributes") or error ("No attributes")
132+
-- local raw = rawget(self, attribute)
133+
-- if raw then return raw end
134+
-- if not rawget(self, "id") then
135+
-- error("Penlight bug, please use get_attribute() rather than table index syntax for now")
136+
-- end
137+
local attributes = rawget(self, "attributes")
131138
local map = getmetatable(attributes).map
132139
local k = map[attribute]
133140
return attributes[k]

fluent/resource.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,17 @@ function FluentResource:load_node (node)
5656
id_name = "-" .. id_name
5757
end
5858
map[id_name] = k
59+
-- TODO Fix with working catch?
60+
-- getmetatable(self)[id_name] = node
5961
end
6062
end
6163

6264
function FluentResource:get_message (identifier, isterm)
65+
-- local raw = rawget(self, identifier)
66+
-- if raw then return raw end
67+
-- if not rawget(self, "id") then
68+
-- error("Penlight bug, please use get_message() rather than table index syntax for now")
69+
-- end
6370
local id = string.match(identifier, "^(%a[-_%a%d]+)")
6471
if not id then return end
6572
local name = (isterm and "-" or "") .. id

0 commit comments

Comments
 (0)