-- -- Copyright (c) 2008-2014 the Urho3D project. -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -- THE SOFTWARE. -- -- Highly based on "ToDoxHook.lua", adjusted for Zerobrane Studio API format. -- Compatible with Zerobrane Studio 0.41+ (Zerobrane Studio 0.40 and below may have issues) --[[ Copy result in your Zerobrane Studio's folder "api/lua" and set it in your "interpreters" file with the filename (excluding it's lua extension) into the "api" table variable. ]]-- require "ToDoxHook" function printFunction(self,ident,close,isfunc) local func = {} func.mod = self.mod func.type = self.type func.ptr = self.ptr func.name = self.name func.lname = self.lname func.const = self.const func.cname = self.cname func.lname = self.lname if isfunc then func.name = func.lname end currentFunction = func local i = 1 while self.args[i] do self.args[i]:print(ident.." ",",") i = i + 1 end currentFunction = nil if currentClass == nil then table.insert(globalFunctions, func) else if func.name == "delete" then func.type = "void" end if currentClass.functions == nil then currentClass.functions = { func } else table.insert(currentClass.functions, func) end end end -- Workaround for Zerobrane Studio's tool-tip with overloaded functions function adjustClassesOverloadFuncs() for i, class in ipairs(classes) do if classes[i].functions ~= nil then for j, func in ipairs(classes[i].functions) do for k, searchfunc in ipairs(classes[i].functions) do -- don't apply on same if k ~= j and func.name == searchfunc.name then if classes[i].functions[j].overloads == nil then classes[i].functions[j].overloads = {} end table.insert(classes[i].functions[j].overloads, searchfunc) table.remove(classes[i].functions, k) adjustClassesOverloadFuncs() return end end end end end end function writeFunctionArgs(file, declarations) local count = table.maxn(declarations) for i = 1, count do local declaration = declarations[i] if declaration.type ~= "void" then -- add paramter type local param_str = declaration.type -- add pointer or reference if declaration.ptr ~= "" then param_str = param_str .. declaration.ptr end -- add paramter name param_str = param_str .. " " .. declaration.name -- add paramter default value if declaration.def ~= "" then param_str = param_str .. " = " .. declaration.def end file:write(param_str) end if i ~= count then file:write(", ") end end end function writeFunctionReturn(file, func) local return_str = "" if func.type ~= "" and func.type ~= "void" then return_str = return_str .. func.type end if func.ptr ~= "" then if func.type == "" and classname ~= nil then return_str = return_str .. classname end return_str = return_str .. func.ptr end file:write(return_str) end function writeInheritances(file, classname) for i, inheritance in ipairs(classes) do if inheritance.name == classname then if inheritance.functions ~= nil then for j, func in ipairs(inheritance.functions) do writeFunction(file, func, classname, true) end end if inheritance.properties ~= nil then for j, property in ipairs(inheritance.properties) do writeProperty(file, property) end end -- append inheritance functions & properties if inheritance.base ~= "" then writeInheritances(file, inheritance.base) end end end end function writeClasses(file) sortByName(classes) adjustClassesOverloadFuncs() file:write("\n\n -- Classes") for i, class in ipairs(classes) do file:write("\n " .. class.name .. " = {") if class.functions ~= nil or class.properties ~= nil then file:write("\n childs = {") end if class.functions ~= nil then for i, func in ipairs(class.functions) do writeFunction(file, func, class.name) end end if class.properties ~= nil then for i, property in ipairs(class.properties) do writeProperty(file, property) end end -- append inheritance functions & properties if class.base ~= "" then writeInheritances(file, class.base) end if class.functions ~= nil or class.properties ~= nil then file:write("\n },") end file:write("\n type = \"class\"") file:write("\n },") end end function writeEnumerates(file) sortByName(enumerates) file:write("\n\n -- Enumerations\n") for i, enumerate in ipairs(enumerates) do for i, value in ipairs(enumerate.values) do file:write("\n " .. value .. " = {") file:write("\n description = \"(Readonly) int for '" .. enumerate.name .. "'\",") file:write("\n type = \"value\"") file:write("\n },") end end end function writeFunction(file, func, classname, isInheritance, asFunc) -- ignore operators if func.name:find("^operator[=%+%-%*%(%)\\