From dfa262215344adabdc370191523ff08f32c93914 Mon Sep 17 00:00:00 2001 From: frosch Date: Sun, 24 Mar 2024 19:02:16 +0100 Subject: [PATCH] Codechange: Unify naming of squirrel built-in types in Script API docs --- src/script/api/doxygen_filter.awk | 10 ++++++++++ src/script/api/script_admin.hpp | 4 ++-- src/script/api/script_controller.hpp | 4 ++-- src/script/api/script_info_docs.hpp | 2 +- src/script/api/script_priorityqueue.hpp | 8 ++++---- src/script/api/script_text.hpp | 4 ++-- 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/script/api/doxygen_filter.awk b/src/script/api/doxygen_filter.awk index d396cc66e8..342d90abd5 100644 --- a/src/script/api/doxygen_filter.awk +++ b/src/script/api/doxygen_filter.awk @@ -136,6 +136,16 @@ BEGIN { next } +# Convert/unify type names +{ + gsub(/\/, "int") + gsub(/\/, "table") + gsub(/\/, "int") + gsub(/\/, "object") + gsub(/std::optional/, "string") + gsub(/(const )?std::string *[*&]?/, "string ") +} + # Store comments /\/\*\*.*\*\// { comment_buffer = $0; comment = "false"; next; } /\/\*.*\*\// { comment_buffer = ""; comment = "false"; next; } diff --git a/src/script/api/script_admin.hpp b/src/script/api/script_admin.hpp index 877506e98d..b168b3423b 100644 --- a/src/script/api/script_admin.hpp +++ b/src/script/api/script_admin.hpp @@ -27,13 +27,13 @@ public: /** * Send information to the AdminPort. The information can be anything * as long as it isn't a class or instance thereof. - * @param table The information to send, in a table. For example: { param = "param" }. + * @param data The information to send, in a table. For example: { param = "param" }. * @return True if and only if the data was successfully converted to JSON * and send to the AdminPort. * @note If the resulting JSON of your table is larger than 1450 bytes, * nothing will be sent (and false will be returned). */ - static bool Send(void *table); + static bool Send(table data); #endif /* DOXYGEN_API */ }; diff --git a/src/script/api/script_controller.hpp b/src/script/api/script_controller.hpp index 1a26c006d4..aed7596f03 100644 --- a/src/script/api/script_controller.hpp +++ b/src/script/api/script_controller.hpp @@ -92,7 +92,7 @@ public: * * @return Data of the script that should be stored in the save game. */ - SquirrelTable Save(); + table Save(); /** * Load saved data just before calling #Start. @@ -100,7 +100,7 @@ public: * @param version Version number of the script that created the \a data. * @param data Data that was saved (return value of #Save). */ - void Load(int version, SquirrelTable data); + void Load(int version, table data); #endif /* DOXYGEN_API */ /** diff --git a/src/script/api/script_info_docs.hpp b/src/script/api/script_info_docs.hpp index b0b32ffc95..286dc9e33a 100644 --- a/src/script/api/script_info_docs.hpp +++ b/src/script/api/script_info_docs.hpp @@ -252,5 +252,5 @@ public: * @note This is a function provided by OpenTTD, you don't have to * include it in your Script but should just call it from GetSettings. */ - void AddLabels(const char *setting_name, table value_names); + void AddLabels(string setting_name, table value_names); }; diff --git a/src/script/api/script_priorityqueue.hpp b/src/script/api/script_priorityqueue.hpp index 43c173b350..74aecc7507 100644 --- a/src/script/api/script_priorityqueue.hpp +++ b/src/script/api/script_priorityqueue.hpp @@ -42,21 +42,21 @@ public: * @param priority The priority to assign the item. * @return True if the item was inserted, false if it was already in the queue. */ - bool Insert(void *item, SQInteger priority); + bool Insert(object item, SQInteger priority); /** * Remove and return the item with the lowest priority. * @return The item with the lowest priority, removed from the queue. Returns null on an empty queue. * @pre !IsEmpty() */ - void *Pop(); + object Pop(); /** * Get the item with the lowest priority, keeping it in the queue. * @return The item with the lowest priority. Returns null on an empty queue. * @pre !IsEmpty() */ - void *Peek(); + object Peek(); /** * Check if an items is already included in the queue. @@ -64,7 +64,7 @@ public: * @return true if the items is already in the queue. * @note Performance is O(n), use only when absolutely required. */ - bool Exists(void *item); + bool Exists(object item); /** * Clear the queue, making Count() returning 0 and IsEmpty() returning true. diff --git a/src/script/api/script_text.hpp b/src/script/api/script_text.hpp index dc9f1c1513..5cc3a52fe3 100644 --- a/src/script/api/script_text.hpp +++ b/src/script/api/script_text.hpp @@ -112,14 +112,14 @@ public: * @param parameter Which parameter to set. * @param value The value of the parameter. Has to be string, integer or an instance of the class ScriptText. */ - void SetParam(int parameter, Object value); + void SetParam(int parameter, object value); /** * Add a value as parameter (appending it). * @param value The value of the parameter. Has to be string, integer or an instance of the class ScriptText. * @return The same object as on which this is called, so you can chain. */ - ScriptText *AddParam(Object value); + ScriptText *AddParam(object value); #endif /* DOXYGEN_API */ /**