From c28936ba6d109b9880d34e9b1f41d409428d109b Mon Sep 17 00:00:00 2001 From: Pierre-Thomas Meisels Date: Mon, 18 Apr 2022 20:17:03 +0200 Subject: Add core types enums description to extension api json --- core/extension/extension_api_dump.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'core/extension') diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp index edd48cf9cd..9d846f87c2 100644 --- a/core/extension/extension_api_dump.cpp +++ b/core/extension/extension_api_dump.cpp @@ -473,6 +473,38 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { d["constants"] = constants; } } + { + //enums + Array enums; + + List enum_names; + Variant::get_enums_for_type(type, &enum_names); + for (const StringName &enum_name : enum_names) { + Dictionary enum_dict; + enum_dict["name"] = String(enum_name); + + List enumeration_names; + Variant::get_enumerations_for_enum(type, enum_name, &enumeration_names); + + Array values; + + for (const StringName &enumeration : enumeration_names) { + Dictionary values_dict; + values_dict["name"] = String(enumeration); + values_dict["value"] = Variant::get_enum_value(type, enum_name, enumeration); + values.push_back(values_dict); + } + + if (values.size()) { + enum_dict["values"] = values; + } + enums.push_back(enum_dict); + } + + if (enums.size()) { + d["enums"] = enums; + } + } { //operators Array operators; -- cgit v1.2.3