Advertisement
Rochet2

Analysis.lua

Oct 27th, 2015
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.82 KB | None | 0 0
  1.  
  2. -- scroll to bottom for output folder
  3. -- Path to elunadoc
  4. local PATH = "E:/Cores/Eluna/core_trinity/trin_wotlk/source/src/LuaEngine"
  5.  
  6. local function FindEnumsFromDoc(event, player, msg)
  7.     if (msg:lower() ~= "mmeth") then
  8.         return
  9.     end
  10.  
  11.     -- utility
  12.     local function WriteFile(path, str)
  13.         local f = assert(io.open(path, "w"))
  14.         f:write(str)
  15.         f:close()
  16.     end
  17.     local function OpenFile(path)
  18.         local f = assert(io.open(path, "r"))
  19.         local str = f:read("*all")
  20.         f:close()
  21.         return str
  22.     end
  23.     local function scandir(path, files)
  24.         local f = io.popen('dir "'..path..'" /b /s /A-D-H')
  25.         if (not f) then return files end
  26.  
  27.         for fullpath in f:lines() do
  28.             if (fullpath:find("Methods%.h$")) then
  29.                 table.insert(files, fullpath)
  30.             end
  31.         end
  32.         f:close()
  33.         return files
  34.     end
  35.  
  36.     local listedfunc = {}
  37.  
  38.     local kk = 0
  39.     local alt = {
  40.         -- LuaPacket = "LuaWorldPacket",
  41.         -- LuaQuery = "LuaElunaQuery",
  42.     }
  43.     for name, namesp in OpenFile(PATH.."/LuaFunctions.cpp"):gmatch("{%s*[%w_]+%s*,%s*\"(%w+)\"%s*,%s*&(%w+)::%w+%s*}") do
  44.         namesp = alt[namesp] or namesp
  45.         listedfunc[namesp.." "..name] = true
  46.         kk = kk+1
  47.     end
  48.  
  49.     local ik = 0
  50.     for k,v in ipairs(scandir(PATH, {})) do
  51.         local f = OpenFile(v)
  52.         local namesp = f:match("namespace (%w+)")
  53.         for name in f:gmatch("int%s+(%w+)%(lua_State%*%s+/?%*?L%*?/?") do
  54.             -- print(namesp.."::"..name)
  55.             if not listedfunc[namesp.." "..name] then
  56.                 print(namesp.."::"..name.." doesnt exist")
  57.             end
  58.             ik = ik+1
  59.         end
  60.     end
  61.     print(kk, ik)
  62.     return false
  63. end
  64.  
  65. RegisterPlayerEvent(42, FindEnumsFromDoc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement