From 9e477babb3bf0ce5179395c2a5155a3f3cd36798 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 4 Jan 2017 17:37:45 -0300 Subject: -GDScript support for accessing properties directly -Added code lookup and code completion support for properties too --- core/object_type_db.cpp | 16 ++++++++++++++++ core/object_type_db.h | 1 + 2 files changed, 17 insertions(+) (limited to 'core') diff --git a/core/object_type_db.cpp b/core/object_type_db.cpp index babbb6b8ad..94cc865b62 100644 --- a/core/object_type_db.cpp +++ b/core/object_type_db.cpp @@ -991,6 +991,22 @@ StringName ClassDB::get_property_getter(StringName p_class,const StringName p_pr return StringName(); } +bool ClassDB::has_property(const StringName& p_class, const StringName& p_property, bool p_no_inheritance) { + + + ClassInfo *type=classes.getptr(p_class); + ClassInfo *check=type; + while(check) { + if (check->property_setget.has(p_property)) + return true; + + if (p_no_inheritance) + break; + check=check->inherits_ptr; + } + + return false; +} void ClassDB::set_method_flags(StringName p_class,StringName p_method,int p_flags) { diff --git a/core/object_type_db.h b/core/object_type_db.h index aebe767028..3613d351e4 100644 --- a/core/object_type_db.h +++ b/core/object_type_db.h @@ -481,6 +481,7 @@ public: static void get_property_list(StringName p_class, List *p_list, bool p_no_inheritance=false, const Object *p_validator=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 has_property(const StringName& p_class,const StringName& p_property,bool p_no_inheritance=false); 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_getter(StringName p_class,const StringName p_property); -- cgit v1.2.3