Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions binding_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
result.append(f"\tconst {return_type} *ptr() const;")
result.append(f"\t{return_type} *ptrw();")
iterators = """
struct ConstIterator;
struct Iterator {
_FORCE_INLINE_ $TYPE &operator*() const {
return *elem_ptr;
Expand All @@ -853,6 +854,10 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
Iterator() {}
Iterator(const Iterator &p_it) { elem_ptr = p_it.elem_ptr; }

operator ConstIterator() const {
return ConstIterator(elem_ptr);
}

private:
$TYPE *elem_ptr = nullptr;
};
Expand Down Expand Up @@ -912,6 +917,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
result.append("\tVariant &operator[](int64_t p_index);")
result.append("\tvoid set_typed(uint32_t p_type, const StringName &p_class_name, const Variant &p_script);")
result.append("""
struct ConstIterator;
struct Iterator {
_FORCE_INLINE_ Variant &operator*() const;
_FORCE_INLINE_ Variant *operator->() const;
Expand All @@ -925,6 +931,10 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
Iterator() {}
Iterator(const Iterator &p_it) { elem_ptr = p_it.elem_ptr; }

operator ConstIterator() const {
return ConstIterator(elem_ptr);
}

private:
Variant *elem_ptr = nullptr;
};
Expand Down
5 changes: 5 additions & 0 deletions include/godot_cpp/templates/local_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class LocalVector {
return data[p_index];
}

struct ConstIterator;
struct Iterator {
_FORCE_INLINE_ T &operator*() const {
return *elem_ptr;
Expand All @@ -201,6 +202,10 @@ class LocalVector {
Iterator() {}
Iterator(const Iterator &p_it) { elem_ptr = p_it.elem_ptr; }

operator ConstIterator() const {
return ConstIterator(elem_ptr);
}

private:
T *elem_ptr = nullptr;
};
Expand Down
5 changes: 5 additions & 0 deletions include/godot_cpp/templates/rb_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class RBMap {

typedef KeyValue<K, V> ValueType;

struct ConstIterator;
struct Iterator {
friend class RBMap<K, V, C, A>;

Expand Down Expand Up @@ -128,6 +129,10 @@ class RBMap {
Iterator() {}
Iterator(const Iterator &p_it) { E = p_it.E; }

operator ConstIterator() const {
return ConstIterator(E);
}

private:
Element *E = nullptr;
};
Expand Down
5 changes: 5 additions & 0 deletions include/godot_cpp/templates/rb_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class RBSet {

typedef T ValueType;

struct ConstIterator;
struct Iterator {
_FORCE_INLINE_ T &operator*() const {
return E->get();
Expand All @@ -106,6 +107,10 @@ class RBSet {
Iterator() {}
Iterator(const Iterator &p_it) { E = p_it.E; }

operator ConstIterator() const {
return ConstIterator(E);
}

private:
Element *E = nullptr;
};
Expand Down
5 changes: 5 additions & 0 deletions include/godot_cpp/templates/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class Vector {
return false;
}

struct ConstIterator;
struct Iterator {
_FORCE_INLINE_ T &operator*() const {
return *elem_ptr;
Expand All @@ -239,6 +240,10 @@ class Vector {
Iterator() {}
Iterator(const Iterator &p_it) { elem_ptr = p_it.elem_ptr; }

operator ConstIterator() const {
return ConstIterator(elem_ptr);
}

private:
T *elem_ptr = nullptr;
};
Expand Down
Loading