From 79f5192a2ce9245fde425da0ea00440c5c3a1731 Mon Sep 17 00:00:00 2001 From: Ylva Selling Date: Tue, 21 May 2024 11:23:26 +0200 Subject: [PATCH] Fix issue of sorting by placing arguments in array (#3238) Co-authored-by: Ylva Selling --- modules/gaia/scripts/filtering.lua | 4 +-- .../globebrowsing/scripts/layer_support.lua | 16 +++++----- .../globebrowsing/scripts/node_support.lua | 4 +-- modules/space/scripts/spice.lua | 2 +- scripts/core_scripts.lua | 32 +++++++++---------- src/scripting/scriptengine.cpp | 8 ++--- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/modules/gaia/scripts/filtering.lua b/modules/gaia/scripts/filtering.lua index a1f7adea56..6179d3acd6 100644 --- a/modules/gaia/scripts/filtering.lua +++ b/modules/gaia/scripts/filtering.lua @@ -1,7 +1,7 @@ openspace.gaia.documentation = { { Name = "addClippingBox", - Arguments = { name = "String", size = "vec3", position = "vec3" }, + Arguments = {{ "name", "String" },{ "size", "vec3" }, { "position", "vec3" }}, Documentation = "Creates a clipping box for the Gaia renderable in the first argument" }, { @@ -11,7 +11,7 @@ openspace.gaia.documentation = { }, { Name = "addClippingSphere", - Arguments = { name = "String", radius = "Number" }, + Arguments = {{ "name", "String" }, { "radius", "Number" }}, Documentation = "Creates a clipping sphere for the Gaia renderable in the first argument" } } diff --git a/modules/globebrowsing/scripts/layer_support.lua b/modules/globebrowsing/scripts/layer_support.lua index 3622156feb..1e3eb45961 100644 --- a/modules/globebrowsing/scripts/layer_support.lua +++ b/modules/globebrowsing/scripts/layer_support.lua @@ -1,7 +1,7 @@ openspace.globebrowsing.documentation = { { Name = "createTemporalGibsGdalXml", - Arguments = { layerName = "String", resolution = "String", format = "String" }, + Arguments = {{ "layerName", "String" }, { "resolution", "String" }, { "format", "String" }}, Documentation = [[ Creates an XML configuration for a temporal GIBS dataset to be used in a TemporalTileprovider @@ -9,7 +9,7 @@ openspace.globebrowsing.documentation = { }, { Name = "createGibsGdalXml", - Arguments = { layerName = "String", date = "String", resolution = "String", format = "String" }, + Arguments = {{ "layerName", "String" }, { "date", "String" }, { "resolution", "String" }, { "format", "String" }}, Documentation = "Creates an XML configuration for a GIBS dataset." .. "Arguments are: layerName, date, resolution, format." .. @@ -32,7 +32,7 @@ openspace.globebrowsing.documentation = { }, { Name = "addGibsLayer", - Arguments = { layer = "String", resolution = "String", format = "String", startDate = "String", endDate = "String" }, + Arguments = {{ "layer", "String" }, { "resolution", "String" }, { "format", "String" }, { "startDate", "String" }, { "endDate", "String" }}, Documentation = "Adds a new layer from NASA GIBS to the Earth globe. Arguments " .. "are: imagery layer name, imagery resolution, start date, end date, format. " .. "For all specifications, see " .. @@ -42,7 +42,7 @@ openspace.globebrowsing.documentation = { }, { Name = "parseInfoFile", - Arguments = { file = "String" }, + Arguments = {{ "file", "String" }}, Documentation = "Parses the passed info file and return the table with the information " .. "provided in the info file. The return table contains the optional keys: " .. @@ -53,7 +53,7 @@ openspace.globebrowsing.documentation = { }, { Name = "addBlendingLayersFromDirectory", - Arguments = { directory = "String", nodeName = "String" }, + Arguments = {{ "directory", "String" }, { "nodeName", "String" }}, Documentation = "Retrieves all info files recursively in the directory passed as the first " .. "argument to this function. The color and height tables retrieved from these " .. @@ -63,7 +63,7 @@ openspace.globebrowsing.documentation = { }, { Name = "addFocusNodesFromDirectory", - Arguments = { directory = "String", nodeName = "String" }, + Arguments = {{ "directory", "String" }, { "nodeName", "String" }}, Documentation = "Retrieves all info files recursively in the directory passed as the first " .. "argument to this function. The name and location retrieved from these info " .. @@ -73,7 +73,7 @@ openspace.globebrowsing.documentation = { }, { Name = "addFocusNodeFromLatLong", - Arguments = { name = "String", globeIdentifier = "String", latitude = "Number", longitude = "Number", altitude = "Number" }, + Arguments = {{ "name", "String" }, { "globeIdentifier", "String" }, { "latitude", "Number" }, { "longitude", "Number" }, { "altitude", "Number" }}, Documentation = "Creates a new SceneGraphNode that can be used as focus node. " .. "Usage: openspace.globebrowsing.addFocusNodeFromLatLong(" .. @@ -81,7 +81,7 @@ openspace.globebrowsing.documentation = { }, { Name = "loadWMSServersFromFile", - Arguments = { filePath = "String" }, + Arguments = {{ "filePath", "String" }}, Documentation = "Loads all WMS servers from the provided file and passes them to the " .. "'openspace.globebrowsing.loadWMSCapabilities' file." diff --git a/modules/globebrowsing/scripts/node_support.lua b/modules/globebrowsing/scripts/node_support.lua index 35f275b7f8..d0154a160f 100644 --- a/modules/globebrowsing/scripts/node_support.lua +++ b/modules/globebrowsing/scripts/node_support.lua @@ -1,7 +1,7 @@ openspace.globebrowsing.documentation = { { Name = "setNodePosition", - Arguments = { nodeIdentifer = "String", globeIdentifier = "String", latitude = "Number", longitude = "Number", altitude = "Number" }, + Arguments = {{ "nodeIdentifer", "String" }, { "globeIdentifier", "String" }, { "latitude", "Number" }, { "longitude", "Number" }, { "altitude", "Number" }}, Documentation = "Sets the position of a SceneGraphNode that has GlobeTranslation/GlobeRotations. " .. "Usage: openspace.globebrowsing.setNodePosition(" .. @@ -9,7 +9,7 @@ openspace.globebrowsing.documentation = { }, { Name = "setNodePositionFromCamera", - Arguments = { nodeIdentifer = "String", useAltitude = "Boolean" }, + Arguments = {{ "nodeIdentifer", "String" }, { "useAltitude", "Boolean" }}, Documentation = "Sets the position of a SceneGraphNode that has GlobeTranslation/GlobeRotations" .. " to match the camera. Only uses camera position not rotation. If useAltitude" .. diff --git a/modules/space/scripts/spice.lua b/modules/space/scripts/spice.lua index 0c9dc9f851..d0d53e918f 100644 --- a/modules/space/scripts/spice.lua +++ b/modules/space/scripts/spice.lua @@ -1,7 +1,7 @@ openspace.space.documentation = { { Name = "tleToSpiceTranslation", - Arguments = { tlePath = "String" }, + Arguments = {{ "tlePath", "String" }}, Return = "{ Translation, SpiceKernel }", Documentation = [[ Takes the provided TLE file, converts it into a SPICE kernel and returns a diff --git a/scripts/core_scripts.lua b/scripts/core_scripts.lua index 602b50e5a5..91884ac3d0 100644 --- a/scripts/core_scripts.lua +++ b/scripts/core_scripts.lua @@ -1,20 +1,20 @@ openspace.documentation = { { Name = "markInterestingNodes", - Arguments = { sceneGraphNodes = "String[]" }, + Arguments = {{ "sceneGraphNodes", "String[]" }}, Documentation = "This function marks the scene graph nodes identified by name " .. "as interesting, which will provide shortcut access to focus buttons and " .. "featured properties" }, { Name = "markInterestingTimes", - Arguments = { times = "Table[]" }, + Arguments = {{ "times", "Table[]" }}, Documentation = "This function marks interesting times for the current scene, " .. "which will create shortcuts for a quick access" }, { Name = "removeInterestingNodes", - Arguments = { sceneGraphNodes = "String[]" }, + Arguments = {{ "sceneGraphNodes", "String[]" }}, Documentation = "This function removes unmarks the scene graph nodes " .. "identified by name as interesting, thus removing the shortcuts from the " .. "features properties list" @@ -36,36 +36,36 @@ openspace.documentation = { }, { Name = "rebindKey", - Arguments = { oldKey = "String", newKey = "String" }, + Arguments = {{ "oldKey", "String" }, { "newKey", "String" }}, Documentation = "Rebinds all scripts from the old key (first argument) to the " .. "new key (second argument)" }, { Name = "appendToListProperty", - Arguments = { identifier = "String", value = "any" }, + Arguments = {{ "identifier","String" }, { "value", "any" }}, Documentation = "Add a value to the list property with the given identifier. " .. "The value can be any type, as long as it is the correct type for the given " .. "property. Note that a number will be converted to a string automatically." }, { Name = "addToPropertyValue", - Arguments = { identifier = "String", value = "String | Number" }, + Arguments = {{ "identifier", "String" } , { "value", "String | Number" }}, Documentation = "Add a value to the property with the given identifier. " .. "Works on both numerical and string properties, where adding to a string " .. "property means appending the given string value to the existing string value." }, { Name = "invertBooleanProperty", - Arguments = { identifier = "String" }, + Arguments = {{ "identifier", "String" }}, Documentation = "Inverts the value of a boolean property with the given ".. "identifier" }, { Name = "fadeIn", Arguments = { - identifier = "String", - fadeTime = "Number?", - endScript = "String?" + { "identifier", "String" }, + { "fadeTime", "Number?" }, + { "endScript", "String?" } }, Documentation = "Fades in the node(s) with the given identifier over the given " .. "time in seconds. The identifier can contain a tag and/or a wildcard to target " .. @@ -77,9 +77,9 @@ openspace.documentation = { { Name = "fadeOut", Arguments = { - identifier = "String", - fadeTime = "Number?", - endScript = "String?" + { "identifier", "String" }, + { "fadeTime", "Number?" }, + { "endScript", "String?" } }, Documentation = "Fades out the node(s) with the given identifier over the given " .. "time in seconds. The identifier can contain a tag and/or a wildcard to target " .. @@ -91,9 +91,9 @@ openspace.documentation = { { Name = "toggleFade", Arguments = { - identifier = "String", - fadeTime = "Number?", - endScript = "String?" + { "identifier", "String" }, + { "fadeTime", "Number?" }, + { "endScript", "String?" } }, Documentation = [[Toggles the fade state of the node(s) with the given identifier over the given time in seconds. The identifier can contain a tag and/or a wildcard to target diff --git a/src/scripting/scriptengine.cpp b/src/scripting/scriptengine.cpp index a7e2e84306..fa90a3eaa3 100644 --- a/src/scripting/scriptengine.cpp +++ b/src/scripting/scriptengine.cpp @@ -47,7 +47,7 @@ namespace { struct [[codegen::Dictionary(Documentation)]] Parameters { std::string name; - std::map arguments; + std::vector> arguments; std::optional returnValue [[codegen::key("Return")]]; std::optional documentation; }; @@ -347,11 +347,11 @@ void ScriptEngine::addLibraryFunctions(lua_State* state, LuaLibrary& library, LuaLibrary::Function func; func.name = p.name; - for (const std::pair& pair : p.arguments) + for (const std::vector& pair : p.arguments) { LuaLibrary::Function::Argument arg; - arg.name = pair.first; - arg.type = pair.second; + arg.name = pair[0]; + arg.type = pair[1]; func.arguments.push_back(arg); } func.returnType = p.returnValue.value_or(func.returnType);