diff options
| author | Juan Linietsky <reduzio@gmail.com> | 2020-04-20 19:06:00 -0300 | 
|---|---|---|
| committer | Juan Linietsky <reduzio@gmail.com> | 2020-04-21 10:15:40 +0200 | 
| commit | 5d4dc2d45caef77cdb52e365bc02f64d54046df5 (patch) | |
| tree | fb09d0a007a7a4fb4c45826e0e5955da4a11a07c /modules | |
| parent | 7343ec13d9d32cedb2511db0ab5d1ed454404d65 (diff) | |
Add ability to bind typed arrays to script API
Note: Only replaced 2 instances to test, Node.get_children and TileMap.get_used_cells
Note: Will do a mass replace on later PRs of whathever I can find, but probably need
a tool to grep through doc.
Warning: Mono will break, needs to be fixed (and so do TypeScript and NativeScript, need to ask respective maintainers)
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/gdnative/nativescript/nativescript.cpp | 7 | ||||
| -rw-r--r-- | modules/gdnative/nativescript/nativescript.h | 2 | ||||
| -rw-r--r-- | modules/gdnative/pluginscript/pluginscript_script.cpp | 7 | ||||
| -rw-r--r-- | modules/gdnative/pluginscript/pluginscript_script.h | 2 | ||||
| -rw-r--r-- | modules/gdscript/gdscript.cpp | 18 | ||||
| -rw-r--r-- | modules/gdscript/gdscript.h | 2 | ||||
| -rw-r--r-- | modules/mono/csharp_script.cpp | 12 | ||||
| -rw-r--r-- | modules/mono/csharp_script.h | 2 | ||||
| -rw-r--r-- | modules/visual_script/visual_script.cpp | 4 | ||||
| -rw-r--r-- | modules/visual_script/visual_script.h | 2 | 
10 files changed, 58 insertions, 0 deletions
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 96a17c99b8..ed3ec44bf7 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -111,6 +111,13 @@ void NativeScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder)  #endif +bool NativeScript::inherits_script(const Ref<Script> &p_script) const { +#ifndef _MSC_VER +#warning inheritance needs to be implemented in NativeScript +#endif +	return false; +} +  void NativeScript::set_class_name(String p_class_name) {  	class_name = p_class_name;  } diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h index 249b8fa42a..7e7598e06c 100644 --- a/modules/gdnative/nativescript/nativescript.h +++ b/modules/gdnative/nativescript/nativescript.h @@ -133,6 +133,8 @@ protected:  public:  	inline NativeScriptDesc *get_script_desc() const; +	bool inherits_script(const Ref<Script> &p_script) const; +  	void set_class_name(String p_class_name);  	String get_class_name() const; diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp index a4c84dc0ca..6b303c8716 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.cpp +++ b/modules/gdnative/pluginscript/pluginscript_script.cpp @@ -140,6 +140,13 @@ bool PluginScript::can_instance() const {  	return can;  } +bool PluginScript::inherits_script(const Ref<Script> &p_script) const { +#ifndef _MSC_VER +#warning inheritance needs to be implemented in PluginScript +#endif +	return false; +} +  Ref<Script> PluginScript::get_base_script() const {  	if (_ref_base_parent.is_valid()) {  		return Ref<PluginScript>(_ref_base_parent); diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h index 5c93ae38f5..70b9ca980b 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.h +++ b/modules/gdnative/pluginscript/pluginscript_script.h @@ -72,6 +72,8 @@ private:  protected:  	static void _bind_methods(); +	bool inherits_script(const Ref<Script> &p_script) const; +  	PluginScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, Callable::CallError &r_error);  	Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error); diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 00bf464f63..98366f7957 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -895,6 +895,24 @@ Ref<GDScript> GDScript::get_base() const {  	return base;  } +bool GDScript::inherits_script(const Ref<Script> &p_script) const { +	Ref<GDScript> gd = p_script; +	if (gd.is_null()) { +		return false; +	} + +	const GDScript *s = this; + +	while (s) { +		if (s == p_script.ptr()) { +			return true; +		} +		s = s->_base; +	} + +	return false; +} +  bool GDScript::has_script_signal(const StringName &p_signal) const {  	if (_signals.has(p_signal))  		return true; diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h index 9758818162..5fdc25669f 100644 --- a/modules/gdscript/gdscript.h +++ b/modules/gdscript/gdscript.h @@ -151,6 +151,8 @@ protected:  public:  	virtual bool is_valid() const { return valid; } +	bool inherits_script(const Ref<Script> &p_script) const; +  	const Map<StringName, Ref<GDScript>> &get_subclasses() const { return subclasses; }  	const Map<StringName, Variant> &get_constants() const { return constants; }  	const Set<StringName> &get_members() const { return members; } diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 1f9576b756..f5911275c9 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -3536,6 +3536,18 @@ void CSharpScript::get_script_signal_list(List<MethodInfo> *r_signals) const {  	}  } +bool CSharpScript::inherits_script(const Ref<Script> &p_script) const { +	Ref<CSharpScript> cs = p_script; +	if (cs.is_null()) { +		return false; +	} + +#ifndef _MSC_VER +#warning TODO: Implement CSharpScript::inherits_script and other relevant changes after GH-38063. +#endif +	return false; +} +  Ref<Script> CSharpScript::get_base_script() const {  	// TODO search in metadata file once we have it, not important any way? diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index ff7449e38e..05e2857538 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -194,6 +194,8 @@ public:  	virtual bool is_tool() const { return tool; }  	virtual bool is_valid() const { return valid; } +	bool inherits_script(const Ref<Script> &p_script) const; +  	virtual Ref<Script> get_base_script() const;  	virtual ScriptLanguage *get_language() const; diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 7cc52eef36..fe1d82f977 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -1460,6 +1460,10 @@ VisualScript::VisualScript() {  	is_tool_script = false;  } +bool VisualScript::inherits_script(const Ref<Script> &p_script) const { +	return this == p_script.ptr(); //there is no inheritance in visual scripts, so this is enough +} +  StringName VisualScript::get_default_func() const {  	return StringName("f_312843592");  } diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index 29309aa156..c154e56703 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -272,6 +272,8 @@ protected:  	static void _bind_methods();  public: +	bool inherits_script(const Ref<Script> &p_script) const; +  	// TODO: Remove it in future when breaking changes are acceptable  	StringName get_default_func() const;  	void add_function(const StringName &p_name);  |