Skip to content

Expose the Variant::get_type_by_name() function to GDScript and GDExtensions #13633

@Innokentiy-Alaytsev

Description

@Innokentiy-Alaytsev

Describe the project you are working on

An educational simulation software.

Describe the problem or limitation you are having in your project

I have a structured serialized report. The values representing different metrics are stored in a generic format, i.e. the (conceptual) type of the value is explicitly provided as a string. Some of the types are real types, like float or int, some are "imaginary", i.e. they might not correspond to GDScript/GDExtension classes. Processing the later is simple. Processing the former requires writing a lot of glue code, which can be avoided by using the Variant::get_type_by_name() function. The function already exists in the code base, but it is not available from GDScript or GDExtension.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Expose the the Variant::get_type_by_name() function function to GDScript and GDExtension.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Whatever code is necessary to bind the function Variant::get_type_by_name() in the same way typeof is bound.

The invocation code in GDScript:

var type := get_type_by_name ("int")

assert (TYPE_INT == type)

If this enhancement will not be used often, can it be worked around with a few lines of script?

No.

Is there a reason why this should be core and not an add-on in the asset library?

The Variant::get_type_by_name() function is not exposed in any way.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions