1 /**
2 State of a function call after yielding.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.gdscriptfunctionstate;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.meta;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.object;
22 import godot.reference;
23 /**
24 State of a function call after yielding.
25 
26 Calling $(D @GDScript.yield) within a function will cause that function to yield and return its current state as an object of this type. The yielded function call can then be resumed later by calling $(D resume) on this state object.
27 */
28 @GodotBaseClass struct GDScriptFunctionState
29 {
30 	enum string _GODOT_internal_name = "GDScriptFunctionState";
31 public:
32 @nogc nothrow:
33 	union { godot_object _godot_object; Reference _GODOT_base; }
34 	alias _GODOT_base this;
35 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
36 	package(godot) __gshared bool _classBindingInitialized = false;
37 	package(godot) static struct _classBinding
38 	{
39 		__gshared:
40 		@GodotName("resume") GodotMethod!(Variant, Variant) resume;
41 		@GodotName("is_valid") GodotMethod!(bool, bool) isValid;
42 		@GodotName("_signal_callback") GodotMethod!(Variant, GodotVarArgs) _signalCallback;
43 	}
44 	bool opEquals(in GDScriptFunctionState other) const { return _godot_object.ptr is other._godot_object.ptr; }
45 	GDScriptFunctionState opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
46 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
47 	mixin baseCasts;
48 	static GDScriptFunctionState _new()
49 	{
50 		static godot_class_constructor constructor;
51 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("GDScriptFunctionState");
52 		if(constructor is null) return typeof(this).init;
53 		return cast(GDScriptFunctionState)(constructor());
54 	}
55 	@disable new(size_t s);
56 	/**
57 	Resume execution of the yielded function call.
58 	If handed an argument, return the argument from the $(D @GDScript.yield) call in the yielded function call. You can pass e.g. an $(D Array) to hand multiple arguments.
59 	This function returns what the resumed function call returns, possibly another function state if yielded again.
60 	*/
61 	Variant resume(VariantArg0)(in VariantArg0 arg = Variant.nil)
62 	{
63 		checkClassBinding!(typeof(this))();
64 		return ptrcall!(Variant)(_classBinding.resume, _godot_object, arg);
65 	}
66 	/**
67 	Check whether the function call may be resumed. This is not the case if the function state was already resumed.
68 	If `extended_check` is enabled, it also checks if the associated script and object still exist. The extended check is done in debug mode as part of $(D GDScriptFunctionState.resume), but you can use this if you know you may be trying to resume without knowing for sure the object and/or script have survived up to that point.
69 	*/
70 	bool isValid(in bool extended_check = false) const
71 	{
72 		checkClassBinding!(typeof(this))();
73 		return ptrcall!(bool)(_classBinding.isValid, _godot_object, extended_check);
74 	}
75 	/**
76 	
77 	*/
78 	Variant _signalCallback(VarArgs...)(VarArgs varArgs)
79 	{
80 		Array _GODOT_args = Array.empty_array;
81 		foreach(vai, VA; VarArgs)
82 		{
83 			_GODOT_args.append(varArgs[vai]);
84 		}
85 		String _GODOT_method_name = String("_signal_callback");
86 		return this.callv(_GODOT_method_name, _GODOT_args);
87 	}
88 }