From 8c7c932c786bf68365960ccf8bb523246dbb6e95 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 6 Mar 2023 15:50:31 +0100 Subject: [PATCH] Update codegen, make use of source location information --- CMakeLists.txt | 3 ++- include/openspace/scripting/lualibrary.h | 5 +++++ src/scripting/scriptengine.cpp | 6 +++++- support/coding/codegen | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09410db6b9..2d26714a60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -163,7 +163,8 @@ add_custom_target( add_dependencies(run_codegen codegen) add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/__codegen.h" - COMMAND codegen ARGS "${PROJECT_SOURCE_DIR}/modules" "${PROJECT_SOURCE_DIR}/src" + COMMAND codegen ARGS "modules" "src" + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" VERBATIM ) set_target_properties(codegen-lib PROPERTIES FOLDER "support") diff --git a/include/openspace/scripting/lualibrary.h b/include/openspace/scripting/lualibrary.h index 03e0b71ce4..a65375e756 100644 --- a/include/openspace/scripting/lualibrary.h +++ b/include/openspace/scripting/lualibrary.h @@ -61,6 +61,11 @@ struct LuaLibrary { std::string returnType; /// A help text describing what the function does/ std::string helpText; + /// The source location where the implementation for this Lua file is located + struct { + std::string file = ""; + int line = 0; + } sourceLocation; }; /// The name of the library std::string name; diff --git a/src/scripting/scriptengine.cpp b/src/scripting/scriptengine.cpp index 8ada8ce913..6c740cb7f0 100644 --- a/src/scripting/scriptengine.cpp +++ b/src/scripting/scriptengine.cpp @@ -113,7 +113,11 @@ namespace { } json << "],"; json << fmt::format(replStr, "returnType", escapedJson(f.returnType)); - json << fmt::format(replStr2, "help", escapedJson(f.helpText)); + json << fmt::format(replStr, "help", escapedJson(f.helpText)); + json << fmt::format( + "\"sourceLocation\": {{ \"file\": {}, \"line\": {} }}", + escapedJson(f.sourceLocation.file), f.sourceLocation.line + ); json << "}"; if (&f != &library.functions.back() || !library.documentations.empty()) { json << ","; diff --git a/support/coding/codegen b/support/coding/codegen index 1aa8bf72c7..3ceac9b873 160000 --- a/support/coding/codegen +++ b/support/coding/codegen @@ -1 +1 @@ -Subproject commit 1aa8bf72c72ad2a9f9a6b659fd68af4d7dd9d3fc +Subproject commit 3ceac9b8733bf8fa536d02bf5ca113140177f9f2