| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | /*************************************************************************/ | 
					
						
							| 
									
										
										
										
											2017-01-16 08:04:19 +01:00
										 |  |  | /*  class_db.h                                                           */ | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*                       This file is part of:                           */ | 
					
						
							|  |  |  | /*                           GODOT ENGINE                                */ | 
					
						
							| 
									
										
										
										
											2017-08-27 14:16:55 +02:00
										 |  |  | /*                      https://godotengine.org                          */ | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | /*************************************************************************/ | 
					
						
							| 
									
										
										
										
											2019-01-01 12:53:14 +01:00
										 |  |  | /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur.                 */ | 
					
						
							|  |  |  | /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md)    */ | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* Permission is hereby granted, free of charge, to any person obtaining */ | 
					
						
							|  |  |  | /* a copy of this software and associated documentation files (the       */ | 
					
						
							|  |  |  | /* "Software"), to deal in the Software without restriction, including   */ | 
					
						
							|  |  |  | /* without limitation the rights to use, copy, modify, merge, publish,   */ | 
					
						
							|  |  |  | /* distribute, sublicense, and/or sell copies of the Software, and to    */ | 
					
						
							|  |  |  | /* permit persons to whom the Software is furnished to do so, subject to */ | 
					
						
							|  |  |  | /* the following conditions:                                             */ | 
					
						
							|  |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* The above copyright notice and this permission notice shall be        */ | 
					
						
							|  |  |  | /* included in all copies or substantial portions of the Software.       */ | 
					
						
							|  |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */ | 
					
						
							|  |  |  | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */ | 
					
						
							|  |  |  | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ | 
					
						
							|  |  |  | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */ | 
					
						
							|  |  |  | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */ | 
					
						
							|  |  |  | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */ | 
					
						
							|  |  |  | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							| 
									
										
										
										
											2018-01-05 00:50:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-16 08:04:19 +01:00
										 |  |  | #ifndef CLASS_DB_H
 | 
					
						
							|  |  |  | #define CLASS_DB_H
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 18:13:45 +02:00
										 |  |  | #include "core/method_bind.h"
 | 
					
						
							|  |  |  | #include "core/object.h"
 | 
					
						
							|  |  |  | #include "core/print_string.h"
 | 
					
						
							| 
									
										
										
										
											2017-01-16 08:04:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | /**
 | 
					
						
							|  |  |  | 	@author Juan Linietsky <reduzio@gmail.com> | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-21 17:40:41 +02:00
										 |  |  | /**	To bind more then 6 parameters include this:
 | 
					
						
							| 
									
										
										
										
											2018-09-11 18:13:45 +02:00
										 |  |  |  *  #include "core/method_bind_ext.gen.inc" | 
					
						
							| 
									
										
										
										
											2018-08-21 17:40:41 +02:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | #define DEFVAL(m_defval) (m_defval)
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | //#define SIMPLE_METHODDEF
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG_METHODS_ENABLED
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct MethodDefinition { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	StringName name; | 
					
						
							|  |  |  | 	Vector<StringName> args; | 
					
						
							| 
									
										
										
										
											2016-03-09 00:00:52 +01:00
										 |  |  | 	MethodDefinition() {} | 
					
						
							| 
									
										
										
										
											2017-12-06 21:36:34 +01:00
										 |  |  | 	MethodDefinition(const char *p_name) : | 
					
						
							|  |  |  | 			name(p_name) {} | 
					
						
							|  |  |  | 	MethodDefinition(const StringName &p_name) : | 
					
						
							|  |  |  | 			name(p_name) {} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | MethodDefinition D_METHOD(const char *p_name); | 
					
						
							|  |  |  | MethodDefinition D_METHOD(const char *p_name, const char *p_arg1); | 
					
						
							|  |  |  | MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2); | 
					
						
							|  |  |  | MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3); | 
					
						
							|  |  |  | MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4); | 
					
						
							|  |  |  | MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5); | 
					
						
							|  |  |  | MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6); | 
					
						
							|  |  |  | MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7); | 
					
						
							|  |  |  | MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8); | 
					
						
							|  |  |  | MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9); | 
					
						
							|  |  |  | MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10); | 
					
						
							| 
									
										
										
										
											2017-10-20 00:24:49 +02:00
										 |  |  | MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10, const char *p_arg11); | 
					
						
							| 
									
										
										
											
												Added all missing VisualServer bindings
- Added bindings for multimesh, immediate, skeleton, light, reflection probe, gi probe, lightmap, particles, camera, environment, scenario, instance
- Removed draw and sync, were duplicates of force_* equivalents
- Bumped binders max arguments from 11 to 13
- Wrote some wrappers as not all methods were variant-friendly
											
										 
											2018-01-20 16:18:51 +01:00
										 |  |  | MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10, const char *p_arg11, const char *p_arg12); | 
					
						
							|  |  |  | MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10, const char *p_arg11, const char *p_arg12, const char *p_arg13); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //#define NO_VARIADIC_MACROS
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef NO_VARIADIC_MACROS
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | static _FORCE_INLINE_ const char *D_METHOD(const char *m_name, ...) { | 
					
						
							|  |  |  | 	return m_name; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-13 12:47:24 +01:00
										 |  |  | // When DEBUG_METHODS_ENABLED is set this will let the engine know
 | 
					
						
							|  |  |  | // the argument names for easier debugging.
 | 
					
						
							|  |  |  | #define D_METHOD(m_c, ...) m_c
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | class ClassDB { | 
					
						
							| 
									
										
										
										
											2016-09-14 19:37:37 -03:00
										 |  |  | public: | 
					
						
							|  |  |  | 	enum APIType { | 
					
						
							|  |  |  | 		API_CORE, | 
					
						
							|  |  |  | 		API_EDITOR, | 
					
						
							|  |  |  | 		API_NONE | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-14 19:37:37 -03:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	struct PropertySetGet { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		int index; | 
					
						
							|  |  |  | 		StringName setter; | 
					
						
							|  |  |  | 		StringName getter; | 
					
						
							|  |  |  | 		MethodBind *_setptr; | 
					
						
							|  |  |  | 		MethodBind *_getptr; | 
					
						
							| 
									
										
										
										
											2015-12-05 14:18:22 -03:00
										 |  |  | 		Variant::Type type; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 	struct ClassInfo { | 
					
						
							| 
									
										
										
										
											2016-03-09 00:00:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-14 19:37:37 -03:00
										 |  |  | 		APIType api; | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 		ClassInfo *inherits_ptr; | 
					
						
							| 
									
										
										
										
											2018-07-02 15:08:35 -03:00
										 |  |  | 		HashMap<StringName, MethodBind *> method_map; | 
					
						
							|  |  |  | 		HashMap<StringName, int> constant_map; | 
					
						
							| 
									
										
										
										
											2018-03-30 16:20:24 +02:00
										 |  |  | 		HashMap<StringName, List<StringName> > enum_map; | 
					
						
							| 
									
										
										
										
											2018-07-02 15:08:35 -03:00
										 |  |  | 		HashMap<StringName, MethodInfo> signal_map; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		List<PropertyInfo> property_list; | 
					
						
							|  |  |  | #ifdef DEBUG_METHODS_ENABLED
 | 
					
						
							|  |  |  | 		List<StringName> constant_order; | 
					
						
							|  |  |  | 		List<StringName> method_order; | 
					
						
							| 
									
										
										
										
											2017-06-23 15:10:46 -03:00
										 |  |  | 		Set<StringName> methods_in_properties; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		List<MethodInfo> virtual_methods; | 
					
						
							|  |  |  | 		StringName category; | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-07-02 15:08:35 -03:00
										 |  |  | 		HashMap<StringName, PropertySetGet> property_setget; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		StringName inherits; | 
					
						
							|  |  |  | 		StringName name; | 
					
						
							|  |  |  | 		bool disabled; | 
					
						
							| 
									
										
										
										
											2017-10-09 23:49:17 +02:00
										 |  |  | 		bool exposed; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		Object *(*creation_func)(); | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 		ClassInfo(); | 
					
						
							|  |  |  | 		~ClassInfo(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2016-03-09 00:00:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	template <class T> | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	static Object *creator() { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		return memnew(T); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-03-09 00:00:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-07 18:25:37 -03:00
										 |  |  | 	static RWLock *lock; | 
					
						
							| 
									
										
										
										
											2018-07-02 15:08:35 -03:00
										 |  |  | 	static HashMap<StringName, ClassInfo> classes; | 
					
						
							|  |  |  | 	static HashMap<StringName, StringName> resource_base_extensions; | 
					
						
							|  |  |  | 	static HashMap<StringName, StringName> compat_classes; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG_METHODS_ENABLED
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	static MethodBind *bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const MethodDefinition &method_name, const Variant **p_defs, int p_defcount); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	static MethodBind *bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const char *method_name, const Variant **p_defs, int p_defcount); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-14 19:37:37 -03:00
										 |  |  | 	static APIType current_api; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	static void _add_class2(const StringName &p_class, const StringName &p_inherits); | 
					
						
							| 
									
										
										
										
											2016-03-09 00:00:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-08 11:30:02 -03:00
										 |  |  | 	static HashMap<StringName, HashMap<StringName, Variant> > default_values; | 
					
						
							| 
									
										
										
										
											2019-06-01 16:42:22 +03:00
										 |  |  | 	static Set<StringName> default_values_cached; | 
					
						
							| 
									
										
										
										
											2018-11-08 11:30:02 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	// DO NOT USE THIS!!!!!! NEEDS TO BE PUBLIC BUT DO NOT USE NO MATTER WHAT!!!
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	template <class T> | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 	static void _add_class() { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		_add_class2(T::get_class_static(), T::get_parent_class_static()); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	template <class T> | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 	static void register_class() { | 
					
						
							| 
									
										
										
										
											2016-03-09 00:00:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		GLOBAL_LOCK_FUNCTION; | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 		T::initialize_class(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		ClassInfo *t = classes.getptr(T::get_class_static()); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		ERR_FAIL_COND(!t); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		t->creation_func = &creator<T>; | 
					
						
							| 
									
										
										
										
											2017-10-09 23:49:17 +02:00
										 |  |  | 		t->exposed = true; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		T::register_custom_data_to_otdb(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	template <class T> | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 	static void register_virtual_class() { | 
					
						
							| 
									
										
										
										
											2016-03-09 00:00:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		GLOBAL_LOCK_FUNCTION; | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 		T::initialize_class(); | 
					
						
							| 
									
										
										
										
											2017-10-09 23:49:17 +02:00
										 |  |  | 		ClassInfo *t = classes.getptr(T::get_class_static()); | 
					
						
							|  |  |  | 		ERR_FAIL_COND(!t); | 
					
						
							|  |  |  | 		t->exposed = true; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		//nothing
 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	template <class T> | 
					
						
							|  |  |  | 	static Object *_create_ptr_func() { | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		return T::create(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	template <class T> | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 	static void register_custom_instance_class() { | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		GLOBAL_LOCK_FUNCTION; | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 		T::initialize_class(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		ClassInfo *t = classes.getptr(T::get_class_static()); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 		ERR_FAIL_COND(!t); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		t->creation_func = &_create_ptr_func<T>; | 
					
						
							| 
									
										
										
										
											2017-10-09 23:49:17 +02:00
										 |  |  | 		t->exposed = true; | 
					
						
							| 
									
										
										
										
											2014-02-13 18:03:28 -03:00
										 |  |  | 		T::register_custom_data_to_otdb(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	static void get_class_list(List<StringName> *p_classes); | 
					
						
							|  |  |  | 	static void get_inheriters_from_class(const StringName &p_class, List<StringName> *p_classes); | 
					
						
							| 
									
										
										
										
											2019-04-08 19:18:03 -03:00
										 |  |  | 	static void get_direct_inheriters_from_class(const StringName &p_class, List<StringName> *p_classes); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	static StringName get_parent_class_nocheck(const StringName &p_class); | 
					
						
							|  |  |  | 	static StringName get_parent_class(const StringName &p_class); | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 	static bool class_exists(const StringName &p_class); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	static bool is_parent_class(const StringName &p_class, const StringName &p_inherits); | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 	static bool can_instance(const StringName &p_class); | 
					
						
							|  |  |  | 	static Object *instance(const StringName &p_class); | 
					
						
							|  |  |  | 	static APIType get_api_type(const StringName &p_class); | 
					
						
							| 
									
										
										
										
											2016-09-14 19:37:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	static uint64_t get_api_hash(APIType p_api); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	template <class N, class M> | 
					
						
							|  |  |  | 	static MethodBind *bind_method(N p_method_name, M p_method) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		MethodBind *bind = create_method_bind(p_method); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, NULL, 0); //use static function, much smaller binary usage
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	template <class N, class M> | 
					
						
							|  |  |  | 	static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		MethodBind *bind = create_method_bind(p_method); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		const Variant *ptr[1] = { &p_def1 }; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 1); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	template <class N, class M> | 
					
						
							|  |  |  | 	static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		MethodBind *bind = create_method_bind(p_method); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		const Variant *ptr[2] = { &p_def1, &p_def2 }; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 2); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	template <class N, class M> | 
					
						
							|  |  |  | 	static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2, const Variant &p_def3) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		MethodBind *bind = create_method_bind(p_method); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		const Variant *ptr[3] = { &p_def1, &p_def2, &p_def3 }; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 3); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	template <class N, class M> | 
					
						
							|  |  |  | 	static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2, const Variant &p_def3, const Variant &p_def4) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		MethodBind *bind = create_method_bind(p_method); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		const Variant *ptr[4] = { &p_def1, &p_def2, &p_def3, &p_def4 }; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 4); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	template <class N, class M> | 
					
						
							|  |  |  | 	static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2, const Variant &p_def3, const Variant &p_def4, const Variant &p_def5) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		MethodBind *bind = create_method_bind(p_method); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		const Variant *ptr[5] = { &p_def1, &p_def2, &p_def3, &p_def4, &p_def5 }; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 5); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-09-17 11:53:29 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	template <class N, class M> | 
					
						
							|  |  |  | 	static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2, const Variant &p_def3, const Variant &p_def4, const Variant &p_def5, const Variant &p_def6) { | 
					
						
							| 
									
										
										
										
											2014-09-17 11:53:29 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		MethodBind *bind = create_method_bind(p_method); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		const Variant *ptr[6] = { &p_def1, &p_def2, &p_def3, &p_def4, &p_def5, &p_def6 }; | 
					
						
							| 
									
										
										
										
											2014-09-17 11:53:29 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 6); | 
					
						
							| 
									
										
										
										
											2014-09-17 11:53:29 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	template <class M> | 
					
						
							|  |  |  | 	static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		GLOBAL_LOCK_FUNCTION; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		MethodBind *bind = create_vararg_method_bind(p_method, p_info); | 
					
						
							|  |  |  | 		ERR_FAIL_COND_V(!bind, NULL); | 
					
						
							| 
									
										
										
										
											2016-08-06 02:20:59 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		bind->set_name(p_name); | 
					
						
							|  |  |  | 		bind->set_default_arguments(p_default_args); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		String instance_type = bind->get_instance_class(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		ClassInfo *type = classes.getptr(instance_type); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		if (!type) { | 
					
						
							|  |  |  | 			memdelete(bind); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			ERR_FAIL_COND_V(!type, NULL); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (type->method_map.has(p_name)) { | 
					
						
							|  |  |  | 			memdelete(bind); | 
					
						
							|  |  |  | 			// overloading not supported
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			ERR_EXPLAIN("Method already bound: " + instance_type + "::" + p_name); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			ERR_FAIL_V(NULL); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		type->method_map[p_name] = bind; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | #ifdef DEBUG_METHODS_ENABLED
 | 
					
						
							| 
									
										
										
										
											2017-08-27 14:16:32 +02:00
										 |  |  | 		// FIXME: <reduz> set_return_type is no longer in MethodBind, so I guess it should be moved to vararg method bind
 | 
					
						
							|  |  |  | 		//bind->set_return_type("Variant");
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		type->method_order.push_back(p_name); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return bind; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	static void add_signal(StringName p_class, const MethodInfo &p_signal); | 
					
						
							|  |  |  | 	static bool has_signal(StringName p_class, StringName p_signal); | 
					
						
							|  |  |  | 	static bool get_signal(StringName p_class, StringName p_signal, MethodInfo *r_signal); | 
					
						
							|  |  |  | 	static void get_signal_list(StringName p_class, List<MethodInfo> *p_signals, bool p_no_inheritance = false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	static void add_property_group(StringName p_class, const String &p_name, const String &p_prefix = ""); | 
					
						
							|  |  |  | 	static void add_property(StringName p_class, const PropertyInfo &p_pinfo, const StringName &p_setter, const StringName &p_getter, int p_index = -1); | 
					
						
							| 
									
										
										
										
											2019-06-01 16:42:22 +03:00
										 |  |  | 	static void set_property_default_value(StringName p_class, const StringName &p_name, const Variant &p_default); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	static void get_property_list(StringName p_class, List<PropertyInfo> *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); | 
					
						
							| 
									
										
										
										
											2017-08-06 02:04:10 +02:00
										 |  |  | 	static int get_property_index(const StringName &p_class, const StringName &p_property, bool *r_is_valid = NULL); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	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); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	static bool has_method(StringName p_class, StringName p_method, bool p_no_inheritance = false); | 
					
						
							|  |  |  | 	static void set_method_flags(StringName p_class, StringName p_method, int p_flags); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-23 15:10:46 -03:00
										 |  |  | 	static void get_method_list(StringName p_class, List<MethodInfo> *p_methods, bool p_no_inheritance = false, bool p_exclude_from_properties = false); | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 	static MethodBind *get_method(StringName p_class, StringName p_name); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	static void add_virtual_method(const StringName &p_class, const MethodInfo &p_method, bool p_virtual = true); | 
					
						
							|  |  |  | 	static void get_virtual_methods(const StringName &p_class, List<MethodInfo> *p_methods, bool p_no_inheritance = false); | 
					
						
							| 
									
										
										
										
											2016-03-09 00:00:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-20 17:45:01 +02:00
										 |  |  | 	static void bind_integer_constant(const StringName &p_class, const StringName &p_enum, const StringName &p_name, int p_constant); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	static void get_integer_constant_list(const StringName &p_class, List<String> *p_constants, bool p_no_inheritance = false); | 
					
						
							|  |  |  | 	static int get_integer_constant(const StringName &p_class, const StringName &p_name, bool *p_success = NULL); | 
					
						
							| 
									
										
										
										
											2017-08-20 17:45:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	static StringName get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false); | 
					
						
							|  |  |  | 	static void get_enum_list(const StringName &p_class, List<StringName> *p_enums, bool p_no_inheritance = false); | 
					
						
							|  |  |  | 	static void get_enum_constants(const StringName &p_class, const StringName &p_enum, List<StringName> *p_constants, bool p_no_inheritance = false); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-08 11:30:02 -03:00
										 |  |  | 	static Variant class_get_default_property_value(const StringName &p_class, const StringName &p_property); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	static StringName get_category(const StringName &p_node); | 
					
						
							| 
									
										
										
										
											2015-08-25 23:00:11 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	static void set_class_enabled(StringName p_class, bool p_enable); | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 	static bool is_class_enabled(StringName p_class); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-09 23:49:17 +02:00
										 |  |  | 	static bool is_class_exposed(StringName p_class); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	static void add_resource_base_extension(const StringName &p_extension, const StringName &p_class); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	static void get_resource_base_extensions(List<String> *p_extensions); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	static void get_extensions_for_type(const StringName &p_class, List<String> *p_extensions); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	static void add_compatibility_class(const StringName &p_class, const StringName &p_fallback); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	static void init(); | 
					
						
							| 
									
										
										
										
											2016-09-14 19:37:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	static void set_current_api(APIType p_api); | 
					
						
							| 
									
										
										
										
											2019-04-06 16:12:59 +02:00
										 |  |  | 	static APIType get_current_api(); | 
					
						
							| 
									
										
										
										
											2019-06-01 16:42:22 +03:00
										 |  |  | 	static void cleanup_defaults(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	static void cleanup(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-20 17:45:01 +02:00
										 |  |  | #ifdef DEBUG_METHODS_ENABLED
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BIND_CONSTANT(m_constant) \
 | 
					
						
							|  |  |  | 	ClassDB::bind_integer_constant(get_class_static(), StringName(), #m_constant, m_constant); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BIND_ENUM_CONSTANT(m_constant) \
 | 
					
						
							|  |  |  | 	ClassDB::bind_integer_constant(get_class_static(), __constant_get_enum_name(m_constant, #m_constant), #m_constant, m_constant); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | #define BIND_CONSTANT(m_constant) \
 | 
					
						
							| 
									
										
										
										
											2017-08-20 17:45:01 +02:00
										 |  |  | 	ClassDB::bind_integer_constant(get_class_static(), StringName(), #m_constant, m_constant); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BIND_ENUM_CONSTANT(m_constant) \
 | 
					
						
							|  |  |  | 	ClassDB::bind_integer_constant(get_class_static(), StringName(), #m_constant, m_constant); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef TOOLS_ENABLED
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | #define BIND_VMETHOD(m_method) \
 | 
					
						
							|  |  |  | 	ClassDB::add_virtual_method(get_class_static(), m_method); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BIND_VMETHOD(m_method)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-16 08:04:19 +01:00
										 |  |  | #endif // CLASS_DB_H
 |