1 /** 2 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.gdnative; 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.reference; 24 import godot.gdnativelibrary; 25 /** 26 27 */ 28 @GodotBaseClass struct GDNative 29 { 30 enum string _GODOT_internal_name = "GDNative"; 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("set_library") GodotMethod!(void, GDNativeLibrary) setLibrary; 41 @GodotName("get_library") GodotMethod!(GDNativeLibrary) getLibrary; 42 @GodotName("initialize") GodotMethod!(bool) initialize; 43 @GodotName("terminate") GodotMethod!(bool) terminate; 44 @GodotName("call_native") GodotMethod!(Variant, String, String, Array) callNative; 45 } 46 bool opEquals(in GDNative other) const { return _godot_object.ptr is other._godot_object.ptr; } 47 GDNative opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 48 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 49 mixin baseCasts; 50 static GDNative _new() 51 { 52 static godot_class_constructor constructor; 53 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("GDNative"); 54 if(constructor is null) return typeof(this).init; 55 return cast(GDNative)(constructor()); 56 } 57 @disable new(size_t s); 58 /** 59 60 */ 61 void setLibrary(GDNativeLibrary library) 62 { 63 checkClassBinding!(typeof(this))(); 64 ptrcall!(void)(_classBinding.setLibrary, _godot_object, library); 65 } 66 /** 67 68 */ 69 Ref!GDNativeLibrary getLibrary() const 70 { 71 checkClassBinding!(typeof(this))(); 72 return ptrcall!(GDNativeLibrary)(_classBinding.getLibrary, _godot_object); 73 } 74 /** 75 76 */ 77 bool initialize() 78 { 79 checkClassBinding!(typeof(this))(); 80 return ptrcall!(bool)(_classBinding.initialize, _godot_object); 81 } 82 /** 83 84 */ 85 bool terminate() 86 { 87 checkClassBinding!(typeof(this))(); 88 return ptrcall!(bool)(_classBinding.terminate, _godot_object); 89 } 90 /** 91 92 */ 93 Variant callNative(StringArg0, StringArg1)(in StringArg0 calling_type, in StringArg1 procedure_name, in Array arguments) 94 { 95 checkClassBinding!(typeof(this))(); 96 return ptrcall!(Variant)(_classBinding.callNative, _godot_object, calling_type, procedure_name, arguments); 97 } 98 /** 99 100 */ 101 @property GDNativeLibrary library() 102 { 103 return getLibrary(); 104 } 105 /// ditto 106 @property void library(GDNativeLibrary v) 107 { 108 setLibrary(v); 109 } 110 }