godotengine / godotengine/godot-cpp
[BUG] Templates are messing everything up!!
- Dominant language
- C++
- Stars
- 2.7k
- Forks
- 809
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 8
Description
I have the following code.
``` cpp
namespace godot {
class Vertex : public Reference {
GODOT_CLASS(Vertex, Reference);
public:
void _init() {}
static void _register_methods() {}
Vertex() { Godot::print("Construct"); }
~Vertex() { Godot::print("Destruct"); }
};
class ListDigraph : public Reference {
GODOT_CLASS(ListDigraph, Reference);
public:
template
Ref __add_vertex() {
return Ref::__internal_constructor(T::_new());
}
virtual Ref add_vertex() { return __add_vertex(); }
void _init() {}
static void _register_methods() {}
ListDigraph() {}
~ListDigraph() {}
};
/////////////////////////////////////////////////////////////////////////
class PropertyVertex : public Vertex {
GODOT_SUBCLASS(PropertyVertex, Vertex);
public:
void _init() {}
static void _register_methods() {}
PropertyVertex() {}
~PropertyVertex() {}
};
class PropertyGraph : public ListDigraph {
GODOT_SUBCLASS(PropertyGraph, ListDigraph);
public:
Ref add_vertex() override { return __add_vertex(); }
void _init() {}
static void _register_methods() {}
PropertyGraph() {}
~PropertyGraph() {}
};
}
```
Code compiles OK the problem is in the GDScript API:
```python
var g = ListDigraph.new()
print(g.add_vertex())
# Oututs
#Construct
#[Reference:1137]
#Destruct
var p = PropertyGraph.new()
print(p.add_vertex())
# Oututs
#[Reference:1140]
```
even though "PropertyVertex" is a "Vertex" its construct and destruct code are not printed.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.