godotengine / godotengine/godot
[GDExtension] Incorrect signature or documentation in generated gdextension_interface.h
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Reproducible in 4.2.1.stable.mono.official.b09f793f5
### System information
Godot v4.2.1.stable.mono - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3070 (NVIDIA; 31.0.15.4665) - AMD Ryzen 7 5800X3D 8-Core Processor (16 Threads)
### Issue description
The generated `gdextension_interface.h` file contains a function signature that incorrectly drops the `const` qualifier from its return value.
```c
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndexConst)(
GDExtensionConstTypePtr p_self,
GDExtensionInt p_index);
```
This function should return `GDExtensionConstTypePtr` to preserve the `const` qualifier on the input `p_self`. Additionally, this is the expected behaviour described in its documentation:
```c
/**
* @name packed_color_array_operator_index_const
* @since 4.1
*
* Gets a __const__ pointer to a color in a PackedColorArray.
*
* @param p_self A const pointer to a const PackedColorArray object.
* @param p_index The index of the Color to get.
*
* @return A __const__ pointer to the requested Color.
*/
```
There are a number of similar functions operating on various `PackedArray` types which do correctly return `const` qualified values. E.g.:
* `packed_float32_array_operator_index_const`
* `packed_float64_array_operator_index_const`
* `packed_int32_array_operator_index_const`
* etc.
### Steps to reproduce
Generate the file using:
```
godot --dump-gdextension-interface --headless
```
### Minimal reproduction project (MRP)
N/A
Contributor guide
Assessment
This issue has not been assessed yet.