Update codegen, make use of source location information

This commit is contained in:
Alexander Bock
2023-03-06 15:50:31 +01:00
parent 9287eb6122
commit 8c7c932c78
4 changed files with 13 additions and 3 deletions
+2 -1
View File
@@ -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")
+5
View File
@@ -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 = "<none>";
int line = 0;
} sourceLocation;
};
/// The name of the library
std::string name;
+5 -1
View File
@@ -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 << ",";