diff options
author | Mattes D <github@xoft.cz> | 2016-06-05 21:32:24 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2016-07-18 22:11:38 +0200 |
commit | 984c0a2cef204c595703009416a0d8cd87147484 (patch) | |
tree | c7641a552c65bca8c2f103c46d91adddaf1f0a1d /src/Bindings/BindingsProcessor.lua | |
parent | APIDump: Changed not to use globals, added more doxycomments. (diff) | |
download | cuberite-984c0a2cef204c595703009416a0d8cd87147484.tar cuberite-984c0a2cef204c595703009416a0d8cd87147484.tar.gz cuberite-984c0a2cef204c595703009416a0d8cd87147484.tar.bz2 cuberite-984c0a2cef204c595703009416a0d8cd87147484.tar.lz cuberite-984c0a2cef204c595703009416a0d8cd87147484.tar.xz cuberite-984c0a2cef204c595703009416a0d8cd87147484.tar.zst cuberite-984c0a2cef204c595703009416a0d8cd87147484.zip |
Diffstat (limited to 'src/Bindings/BindingsProcessor.lua')
-rw-r--r-- | src/Bindings/BindingsProcessor.lua | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/src/Bindings/BindingsProcessor.lua b/src/Bindings/BindingsProcessor.lua index 417a8f48c..f48bc455f 100644 --- a/src/Bindings/BindingsProcessor.lua +++ b/src/Bindings/BindingsProcessor.lua @@ -129,6 +129,8 @@ function parser_hook(a_Code) local curr = classContainer.curr if (curr.n and (curr.n > 0)) then curr[curr.n].next_DoxyComment = g_ForwardDoxyComments[tonumber(comment:sub(2, -2))] + else + curr.first_child_DoxyComment = g_ForwardDoxyComments[tonumber(comment:sub(2, -2))] end return strsub(a_Code, e + 1) end @@ -368,6 +370,9 @@ local function outputClassFunctionDocs(a_File, a_Class, a_Functions) a_File:write("\t\t\t\t\t\t{\n\t\t\t\t\t\t\tType = \"", ret.Type, "\",\n\t\t\t\t\t\t},\n") end a_File:write("\t\t\t\t\t},\n") + if (desc.IsStatic) then + a_File:write("\t\t\t\t\tIsStatic = true,\n") + end if (desc.DoxyComment) then a_File:write("\t\t\t\t\tDesc = ", string.format("%q", desc.DoxyComment), ",\n") end @@ -577,9 +582,15 @@ end ---- Recursively applies the next_DoxyComment member to the next item in the container +--- Recursively applies the next_DoxyComment member to the next item, and first_child_DoxyComment to first child item in the container. -- a_Container is the ToLua++'s table potentially containing children as its array members local function applyNextDoxyComments(a_Container) + -- Apply the DoxyComment to the first child, if appropriate: + if (a_Container[1] and a_Container.first_child_DoxyComment) then + a_Container[1].DoxyComment = a_Container.first_child_DoxyComment + end + + -- Apply each child's next_DoxyComment to the actual next child: local i = 1 while (a_Container[i]) do if (a_Container[i].next_DoxyComment) then @@ -613,7 +624,10 @@ local function genPackageDocs(a_Self) local i = 1 local filenames = {} while (a_Self[i]) do - if (a_Self[i].genDocs) then + if ( + a_Self[i]:check_public_access() and -- Do not export private and protected members + a_Self[i].genDocs + ) then a_Self[i]:genDocs(filenames) end i = i + 1 @@ -665,7 +679,10 @@ local function genClassDocs(a_Self, a_Filenames) local variables = {} local constants = {} while (a_Self[i]) do - if (a_Self[i].genMemberDocs) then + if ( + a_Self[i]:check_public_access() and -- Don't export private and protected members + a_Self[i].genMemberDocs + ) then a_Self[i]:genMemberDocs(functions, variables, constants) end i = i + 1 @@ -747,6 +764,10 @@ local function genFunctionMemberDocs(a_Self, a_Functions, a_Variables, a_Constan Parameters = parseFunctionParameters(a_Self), Returns = parseFunctionReturns(a_Self), } + local _, _, hasStatic = string.find(a_Self.mod, "^%s*(static)") + if (hasStatic) then + desc.IsStatic = true + end table.insert(fn, desc) end @@ -805,6 +826,15 @@ end -- a_Package is ToLua++'s classPackage object function pre_output_hook(a_Package) OutputLuaStateHelpers(a_Package) + + -- Generate the documentation: + -- (must generate documentation before ToLua++ writes the bindings, because "static" information is lost at that point) + local isSuccess, msg = generateDocs(a_Package) + if not(isSuccess) then + print("API docs haven't been generated due to an error: " .. (msg or "<no message>")) + else + print("API docs have been generated."); + end end @@ -815,15 +845,7 @@ end -- Called by ToLua++ after writing its generated files. -- a_Package is ToLua++'s classPackage object function post_output_hook(a_Package) - -- Generate the documentation: - local isSuccess, msg = generateDocs(a_Package) - if not(isSuccess) then - print("Lua bindings have been generated.") - print("API docs haven't been generated due to an error: " .. (msg or "<no message>")) - return - end - - print("Lua bindings and docs have been generated.") + print("Lua bindings have been generated.") end @@ -855,7 +877,7 @@ function preprocess_hook(a_Package) g_BackwardDoxyComments.n = n return "\19" .. n .."\20\n" end - ) + ) -- Replace ///< comments with an ID into a lookup table wrapped in DC3 and DC4 local f = io.open("code_out.cpp", "wb") f:write(a_Package.code) f:close() |