- Fixed createFrame bug
- Added custom XML/Attributes
This commit is contained in:
@@ -318,7 +318,7 @@ function Container:getChild(path)
|
|||||||
return v
|
return v
|
||||||
else
|
else
|
||||||
if(v:isType("Container"))then
|
if(v:isType("Container"))then
|
||||||
return v:find(table.concat(parts, "/", 2))
|
return v:find(table.concat(parts, "/", 2))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -98,6 +98,10 @@ end
|
|||||||
function basalt.createFrame()
|
function basalt.createFrame()
|
||||||
local frame = basalt.create("BaseFrame")
|
local frame = basalt.create("BaseFrame")
|
||||||
frame:postInit()
|
frame:postInit()
|
||||||
|
if(main==nil)then
|
||||||
|
main = tostring(term.current())
|
||||||
|
basalt.setActiveFrame(frame, true)
|
||||||
|
end
|
||||||
return frame
|
return frame
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ local XMLParser = {
|
|||||||
end
|
end
|
||||||
i = j + 1
|
i = j + 1
|
||||||
end
|
end
|
||||||
local text = string.sub(xmlText, i);
|
|
||||||
if #stack > 1 then
|
if #stack > 1 then
|
||||||
error("XMLParser: unclosed " .. stack[#stack].tag)
|
error("XMLParser: unclosed " .. stack[#stack].tag)
|
||||||
end
|
end
|
||||||
@@ -77,21 +76,21 @@ local XMLParser = {
|
|||||||
local function findExpressions(text)
|
local function findExpressions(text)
|
||||||
local expressions = {}
|
local expressions = {}
|
||||||
local lastIndex = 1
|
local lastIndex = 1
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
local startPos, endPos, expr = text:find("%${([^}]+)}", lastIndex)
|
local startPos, endPos, expr = text:find("%${([^}]+)}", lastIndex)
|
||||||
if not startPos then break end
|
if not startPos then break end
|
||||||
|
|
||||||
table.insert(expressions, {
|
table.insert(expressions, {
|
||||||
start = startPos,
|
start = startPos,
|
||||||
ending = endPos,
|
ending = endPos,
|
||||||
expression = expr,
|
expression = expr,
|
||||||
raw = text:sub(startPos, endPos)
|
raw = text:sub(startPos, endPos)
|
||||||
})
|
})
|
||||||
|
|
||||||
lastIndex = endPos + 1
|
lastIndex = endPos + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
return expressions
|
return expressions
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -170,6 +169,10 @@ end
|
|||||||
|
|
||||||
local BaseElement = {}
|
local BaseElement = {}
|
||||||
|
|
||||||
|
function BaseElement.setup(element)
|
||||||
|
element.defineProperty(element, "customXML", {default = {attributes={},children={}}, type = "table"})
|
||||||
|
end
|
||||||
|
|
||||||
--- Generates this element from XML nodes
|
--- Generates this element from XML nodes
|
||||||
--- @shortDescription Generates this element from XML nodes
|
--- @shortDescription Generates this element from XML nodes
|
||||||
--- @param self BaseElement The element to generate from XML nodes
|
--- @param self BaseElement The element to generate from XML nodes
|
||||||
@@ -196,7 +199,8 @@ function BaseElement:fromXML(node, scope)
|
|||||||
errorManager.error("XMLParser: property '" .. k .. "' not found in element '" .. self:getType() .. "'")
|
errorManager.error("XMLParser: property '" .. k .. "' not found in element '" .. self:getType() .. "'")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
errorManager.error("XMLParser: property '" .. k .. "' not found in element '" .. self:getType() .. "'")
|
local customXML = self.get("customXML")
|
||||||
|
customXML.attributes[k] = convertValue(v, scope)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -229,6 +233,10 @@ function BaseElement:fromXML(node, scope)
|
|||||||
else
|
else
|
||||||
self[child.tag](self)
|
self[child.tag](self)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
local customXML = self.get("customXML")
|
||||||
|
child.value = convertValue(child.value, scope)
|
||||||
|
customXML.children[child.tag] = child
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -241,7 +249,7 @@ local Container = {}
|
|||||||
--- Loads an XML string and parses it into the element
|
--- Loads an XML string and parses it into the element
|
||||||
--- @shortDescription Loads an XML string and parses it into the element
|
--- @shortDescription Loads an XML string and parses it into the element
|
||||||
--- @param self Container The element to load the XML into
|
--- @param self Container The element to load the XML into
|
||||||
--- @param nodes string The XML string to load
|
--- @param content string The XML string to load
|
||||||
--- @param scope table The scope to use
|
--- @param scope table The scope to use
|
||||||
--- @return Container self The element instance
|
--- @return Container self The element instance
|
||||||
function Container:loadXML(content, scope)
|
function Container:loadXML(content, scope)
|
||||||
|
|||||||
Reference in New Issue
Block a user