Browse Source

Fix how tolua++ renaming is being documented in Lua generated API.

Yao Wei Tjong 姚伟忠 12 years ago
parent
commit
4f73aa26b9
2 changed files with 35 additions and 12 deletions
  1. 7 2
      Docs/LuaScriptAPI.dox
  2. 28 10
      Source/Engine/LuaScript/pkgs/pkgToDox.lua

+ 7 - 2
Docs/LuaScriptAPI.dox

@@ -151,7 +151,7 @@ Properties:
 
 Methods:
 
-- TOLUA_TEMPLATE_BIND(T, Vector3)
+- TOLUA_TEMPLATE_BIND(T, Vector3, RayQueryResult)
 - PODVector()
 - PODVector(const PODVector<T>& vector)
 - ~PODVector()
@@ -1151,6 +1151,7 @@ Methods:
 - void Update(const FrameInfo& frame)
 - void AddManualDrawable(Drawable* drawable)
 - void RemoveManualDrawable(Drawable* drawable)
+- void Raycast(PODVector<RayQueryResult> &result, const Ray& ray, RayQueryLevel level, float maxDistance, unsigned char drawableFlags) const
 - RayQueryResult RaycastSingle(const Ray& ray, RayQueryLevel level, float maxDistance, unsigned char drawableFlags) const
 - unsigned GetNumLevels() const
 - void QueueUpdate(Drawable* drawable)
@@ -4781,6 +4782,7 @@ Properties:
 
 - unsigned format
 - bool autoUpdate
+
 \section LuaScriptAPI_GlobalFunctions Global functions
 - Context* GetContext()
 - Object* GetEventSender()
@@ -5040,7 +5042,6 @@ Properties:
 - float M_RADTODEG
 - unsigned NUM_FRUSTUM_PLANES
 - unsigned NUM_FRUSTUM_VERTICES
-- $renaming SharedPtr<HttpRequest> @ HttpRequestSPtr
 - unsigned FIRST_REPLICATED_ID
 - unsigned LAST_REPLICATED_ID
 - unsigned FIRST_LOCAL_ID
@@ -5364,6 +5365,10 @@ Properties:
 - int DRAG_RESIZE_BOTTOMLEFT
 - int DRAG_RESIZE_LEFT
 
+\section LuaScriptAPI_RenameTypes Rename types
+- PODVector<RayQueryResult> becomes RayQueryResultVector
+- SharedPtr<HttpRequest> becomes HttpRequestSPtr
+
 */
 
 }

+ 28 - 10
Source/Engine/LuaScript/pkgs/pkgToDox.lua

@@ -9,6 +9,7 @@ enums = {}
 classes = {}
 globalConstants = {}
 globalFunctions = {}
+renamings = {}
 
 -- trim string.
 function trim(s)
@@ -118,10 +119,15 @@ function handleLine(line)
             return
         end
         
-        if line:find(")") == nil then -- global function.
-            table.insert(globalConstants, line)
-        else
+        if line:find(")") ~= nil then -- global function.
             table.insert(globalFunctions, line)
+        else
+            local i, _, oldName, newName = line:find("$renaming%s+(.-)%s*@%s*(.-)%s*$") 
+            if i ~= nill then -- renaming types.
+                renamings[oldName] = newName
+            else
+                table.insert(globalConstants, line)
+            end
         end
         
         return
@@ -178,7 +184,7 @@ function writeGlobalFunctions(ofile)
     for _, line in ipairs(globalFunctions) do
         line = line:gsub("%w+ @ ", "")
         line = line:gsub(";", "")
-        ofile:write("- " .. line .. "\n")
+        ofile:write("- ", line, "\n")
     end
     
     ofile:write("\n")
@@ -190,13 +196,13 @@ function writeGlobalConstants(ofile)
         line = line:gsub("static ", "")
         line = line:gsub("const ", "")
         line = line:gsub(";", "")
-        ofile:write("- " .. line .. "\n")
+        ofile:write("- ", line, "\n")
     end
         
     for _, line in ipairs(enums) do
         line = line:gsub(",", "")
         line = line:gsub(" = .*", "")
-        ofile:write("- int " .. line .. "\n")
+        ofile:write("- int ", line, "\n")
     end
     
     ofile:write("\n")
@@ -210,7 +216,7 @@ function writeClasses(ofile)
             line = line:gsub("class ", "")
             line = line:gsub("struct ", "")
             line = line:gsub("public ", "")
-            ofile:write("\n### " .. line .. "\n\nMethods:\n\n")
+            ofile:write("\n### ", line, "\n\nMethods:\n\n")
             firstProperty = true
         else
             line = line:gsub(";", "")
@@ -218,7 +224,7 @@ function writeClasses(ofile)
                 line = line:gsub(" %w+ @ ", " ")
                 line = line:gsub("explicit ", "")
                 line = line:gsub("tolua_outside ", "")
-                ofile:write("- " .. line .. "\n")
+                ofile:write("- ", line, "\n")
             else
                 if firstProperty then
                     firstProperty = false
@@ -230,14 +236,25 @@ function writeClasses(ofile)
                 line = line:gsub("tolua_property__has_set ", "")
                 line = line:gsub("tolua_property__no_prefix ", "")
                 if line:find("tolua_readonly") == nil then
-                    ofile:write("- " .. line .. "\n")
+                    ofile:write("- ", line, "\n")
                 else
                     line = line:gsub("tolua_readonly ", "")
-                    ofile:write("- " .. line .. " (readonly)\n")
+                    ofile:write("- ", line, " (readonly)\n")
                 end
             end
         end
     end
+
+    ofile:write("\n")
+end
+
+function writeRenamings(ofile)
+    ofile:write("\\section LuaScriptAPI_RenameTypes Rename types\n")
+    for oldName, newName in pairs(renamings) do
+        ofile:write("- ", oldName, " becomes ", newName, "\n")
+    end
+
+    ofile:write("\n")
 end
 
 ofile = io.open(arg[1], "w")
@@ -253,6 +270,7 @@ ofile:write("\n")
 writeClasses(ofile)
 writeGlobalFunctions(ofile)
 writeGlobalConstants(ofile)
+writeRenamings(ofile)
 
 ofile:write([[
 */