Merge pull request #10117 from neikeq/pr-classdb-getpropidx
ClassDB: Adds get_property_index method
This commit is contained in:
commit
97e942dd42
@ -937,6 +937,28 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ClassDB::get_property_index(const StringName &p_class, const StringName &p_property, bool *r_is_valid) {
|
||||||
|
|
||||||
|
ClassInfo *type = classes.getptr(p_class);
|
||||||
|
ClassInfo *check = type;
|
||||||
|
while (check) {
|
||||||
|
const PropertySetGet *psg = check->property_setget.getptr(p_property);
|
||||||
|
if (psg) {
|
||||||
|
|
||||||
|
if (r_is_valid)
|
||||||
|
*r_is_valid = true;
|
||||||
|
|
||||||
|
return psg->index;
|
||||||
|
}
|
||||||
|
|
||||||
|
check = check->inherits_ptr;
|
||||||
|
}
|
||||||
|
if (r_is_valid)
|
||||||
|
*r_is_valid = false;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
Variant::Type ClassDB::get_property_type(const StringName &p_class, const StringName &p_property, bool *r_is_valid) {
|
Variant::Type ClassDB::get_property_type(const StringName &p_class, const StringName &p_property, bool *r_is_valid) {
|
||||||
|
|
||||||
ClassInfo *type = classes.getptr(p_class);
|
ClassInfo *type = classes.getptr(p_class);
|
||||||
|
@ -480,6 +480,7 @@ public:
|
|||||||
static bool set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid = NULL);
|
static bool set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid = NULL);
|
||||||
static bool get_property(Object *p_object, const StringName &p_property, Variant &r_value);
|
static bool get_property(Object *p_object, const StringName &p_property, Variant &r_value);
|
||||||
static bool has_property(const StringName &p_class, const StringName &p_property, bool p_no_inheritance = false);
|
static bool has_property(const StringName &p_class, const StringName &p_property, bool p_no_inheritance = false);
|
||||||
|
static int get_property_index(const StringName &p_class, const StringName &p_property, bool *r_is_valid = NULL);
|
||||||
static Variant::Type get_property_type(const StringName &p_class, const StringName &p_property, bool *r_is_valid = NULL);
|
static Variant::Type get_property_type(const StringName &p_class, const StringName &p_property, bool *r_is_valid = NULL);
|
||||||
static StringName get_property_setter(StringName p_class, const StringName p_property);
|
static StringName get_property_setter(StringName p_class, const StringName p_property);
|
||||||
static StringName get_property_getter(StringName p_class, const StringName p_property);
|
static StringName get_property_getter(StringName p_class, const StringName p_property);
|
||||||
|
Loading…
Reference in New Issue
Block a user