1 /** 2 Exits a function and returns an optional value. 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.visualscriptreturn; 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.classdb; 23 import godot.visualscriptnode; 24 import godot.resource; 25 import godot.reference; 26 /** 27 Exits a function and returns an optional value. 28 29 Ends the execution of a function and returns control to the calling function. Optionally, it can return a $(D Variant) value. 30 $(B Input Ports:) 31 - Sequence 32 - Data (variant): `result` (optional) 33 $(B Output Ports:) 34 none 35 */ 36 @GodotBaseClass struct VisualScriptReturn 37 { 38 enum string _GODOT_internal_name = "VisualScriptReturn"; 39 public: 40 @nogc nothrow: 41 union { godot_object _godot_object; VisualScriptNode _GODOT_base; } 42 alias _GODOT_base this; 43 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 44 package(godot) __gshared bool _classBindingInitialized = false; 45 package(godot) static struct _classBinding 46 { 47 __gshared: 48 @GodotName("set_return_type") GodotMethod!(void, long) setReturnType; 49 @GodotName("get_return_type") GodotMethod!(Variant.Type) getReturnType; 50 @GodotName("set_enable_return_value") GodotMethod!(void, bool) setEnableReturnValue; 51 @GodotName("is_return_value_enabled") GodotMethod!(bool) isReturnValueEnabled; 52 } 53 bool opEquals(in VisualScriptReturn other) const { return _godot_object.ptr is other._godot_object.ptr; } 54 VisualScriptReturn opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 55 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 56 mixin baseCasts; 57 static VisualScriptReturn _new() 58 { 59 static godot_class_constructor constructor; 60 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("VisualScriptReturn"); 61 if(constructor is null) return typeof(this).init; 62 return cast(VisualScriptReturn)(constructor()); 63 } 64 @disable new(size_t s); 65 /** 66 67 */ 68 void setReturnType(in long type) 69 { 70 checkClassBinding!(typeof(this))(); 71 ptrcall!(void)(_classBinding.setReturnType, _godot_object, type); 72 } 73 /** 74 75 */ 76 Variant.Type getReturnType() const 77 { 78 checkClassBinding!(typeof(this))(); 79 return ptrcall!(Variant.Type)(_classBinding.getReturnType, _godot_object); 80 } 81 /** 82 83 */ 84 void setEnableReturnValue(in bool enable) 85 { 86 checkClassBinding!(typeof(this))(); 87 ptrcall!(void)(_classBinding.setEnableReturnValue, _godot_object, enable); 88 } 89 /** 90 91 */ 92 bool isReturnValueEnabled() const 93 { 94 checkClassBinding!(typeof(this))(); 95 return ptrcall!(bool)(_classBinding.isReturnValueEnabled, _godot_object); 96 } 97 /** 98 If `true` the `return` input port is available. 99 */ 100 @property bool returnEnabled() 101 { 102 return isReturnValueEnabled(); 103 } 104 /// ditto 105 @property void returnEnabled(bool v) 106 { 107 setEnableReturnValue(v); 108 } 109 /** 110 The return value's data type. 111 */ 112 @property Variant.Type returnType() 113 { 114 return getReturnType(); 115 } 116 /// ditto 117 @property void returnType(long v) 118 { 119 setReturnType(v); 120 } 121 }