Skip to content

Commit

Permalink
Merge branch 'xml' into develop
Browse files Browse the repository at this point in the history
<no random message>
  • Loading branch information
opussf committed Jan 27, 2024
2 parents 008ad19 + 0ce3db7 commit 95ecd44
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/wowStubs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,7 @@ end
-----------------------------------------
-- XML functions
function ParseXML( xmlFile )
print("parse: "..xmlFile )
end

-----------------------------------------
Expand All @@ -1755,7 +1756,9 @@ function ParseTOC( tocFile, useRequire )
if( hash ) then
addonData[ hashKey ] = hashValue
elseif( lua ) then
table.insert( tocFileTable, luaFile )
table.insert( tocFileTable, { "lua", luaFile } )
elseif( xml ) then
table.insert( tocFileTable, { "xml", xmlFile } )
end
tocContents = string.sub( tocContents, lineend+1 )
else
Expand All @@ -1774,15 +1777,18 @@ function ParseTOC( tocFile, useRequire )
--add to the include package.path
package.path = includePath.."?.lua;" .. package.path
end

sharedTable = {}

for _,f in pairs( tocFileTable ) do
if( useRequire ) then
require( f )
else
local loadedfile = assert( loadfile( includePath..f..".lua" ) )
loadedfile( addonName, sharedTable )
if( f[1] == "lua" ) then
if( useRequire ) then
require( f[2] )
else
local loadedfile = assert( loadfile( includePath..f[2]..".lua" ) )
loadedfile( addonName, sharedTable )
end
elseif( f[1] == "xml" ) then
ParseXML( includePath..f[2]..".xml" )
end
end
end
Expand Down
23 changes: 23 additions & 0 deletions test/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,29 @@ end

-----
----- TOC tests
function CreateFile( filename, contents )
pathSeparator = string.sub( package.config, 1, 1 ) -- first character of this string (http://www.lua.org/manual/5.2/manual.html#pdf-package.config)
filePathTable = {
os.getenv( "PWD" ),
"target",
filename,
}
tocFile = table.concat( filePathTable, pathSeparator )
file, err = io.open( tocFile, "w" )
if err then
print( err )
else
file:write( contents )
io.close( file )
end
return tocFile
end
function test.testTOC_()
CreateFile( "test.xml", "<Ui>\n</Ui>\n" )
CreateFile( "test.lua", "print(\"hi\")\n")
generatedFile = CreateFile( "test.toc", "test.lua\ntest.xml\n" )
ParseTOC( generatedFile )
end


----------------------------------
Expand Down

0 comments on commit 95ecd44

Please sign in to comment.