1 /**
2 An external library containing functions or script classes to use in Godot.
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.gdnativelibrary;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.resource;
25 import godot.configfile;
26 /**
27 An external library containing functions or script classes to use in Godot.
28 
29 A GDNative library can implement $(D NativeScript)s, global functions to call with the $(D GDNative) class, or low-level engine extensions through interfaces such as $(D ARVRInterfaceGDNative). The library must be compiled for each platform and architecture that the project will run on.
30 */
31 @GodotBaseClass struct GDNativeLibrary
32 {
33 	package(godot) enum string _GODOT_internal_name = "GDNativeLibrary";
34 public:
35 @nogc nothrow:
36 	union { /** */ godot_object _godot_object; /** */ Resource _GODOT_base; }
37 	alias _GODOT_base this;
38 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
39 	package(godot) __gshared bool _classBindingInitialized = false;
40 	package(godot) static struct GDNativeClassBinding
41 	{
42 		__gshared:
43 		@GodotName("get_config_file") GodotMethod!(ConfigFile) getConfigFile;
44 		@GodotName("get_current_dependencies") GodotMethod!(PoolStringArray) getCurrentDependencies;
45 		@GodotName("get_current_library_path") GodotMethod!(String) getCurrentLibraryPath;
46 		@GodotName("get_symbol_prefix") GodotMethod!(String) getSymbolPrefix;
47 		@GodotName("is_reloadable") GodotMethod!(bool) isReloadable;
48 		@GodotName("is_singleton") GodotMethod!(bool) isSingleton;
49 		@GodotName("set_config_file") GodotMethod!(void, ConfigFile) setConfigFile;
50 		@GodotName("set_load_once") GodotMethod!(void, bool) setLoadOnce;
51 		@GodotName("set_reloadable") GodotMethod!(void, bool) setReloadable;
52 		@GodotName("set_singleton") GodotMethod!(void, bool) setSingleton;
53 		@GodotName("set_symbol_prefix") GodotMethod!(void, String) setSymbolPrefix;
54 		@GodotName("should_load_once") GodotMethod!(bool) shouldLoadOnce;
55 	}
56 	/// 
57 	pragma(inline, true) bool opEquals(in GDNativeLibrary other) const
58 	{ return _godot_object.ptr is other._godot_object.ptr; }
59 	/// 
60 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
61 	{ _godot_object.ptr = n; return null; }
62 	/// 
63 	pragma(inline, true) bool opEquals(typeof(null) n) const
64 	{ return _godot_object.ptr is n; }
65 	/// 
66 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
67 	mixin baseCasts;
68 	/// Construct a new instance of GDNativeLibrary.
69 	/// Note: use `memnew!GDNativeLibrary` instead.
70 	static GDNativeLibrary _new()
71 	{
72 		static godot_class_constructor constructor;
73 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("GDNativeLibrary");
74 		if(constructor is null) return typeof(this).init;
75 		return cast(GDNativeLibrary)(constructor());
76 	}
77 	@disable new(size_t s);
78 	/**
79 	
80 	*/
81 	Ref!ConfigFile getConfigFile()
82 	{
83 		checkClassBinding!(typeof(this))();
84 		return ptrcall!(ConfigFile)(GDNativeClassBinding.getConfigFile, _godot_object);
85 	}
86 	/**
87 	Returns paths to all dependency libraries for the current platform and architecture.
88 	*/
89 	PoolStringArray getCurrentDependencies() const
90 	{
91 		checkClassBinding!(typeof(this))();
92 		return ptrcall!(PoolStringArray)(GDNativeClassBinding.getCurrentDependencies, _godot_object);
93 	}
94 	/**
95 	Returns the path to the dynamic library file for the current platform and architecture.
96 	*/
97 	String getCurrentLibraryPath() const
98 	{
99 		checkClassBinding!(typeof(this))();
100 		return ptrcall!(String)(GDNativeClassBinding.getCurrentLibraryPath, _godot_object);
101 	}
102 	/**
103 	
104 	*/
105 	String getSymbolPrefix() const
106 	{
107 		checkClassBinding!(typeof(this))();
108 		return ptrcall!(String)(GDNativeClassBinding.getSymbolPrefix, _godot_object);
109 	}
110 	/**
111 	
112 	*/
113 	bool isReloadable() const
114 	{
115 		checkClassBinding!(typeof(this))();
116 		return ptrcall!(bool)(GDNativeClassBinding.isReloadable, _godot_object);
117 	}
118 	/**
119 	
120 	*/
121 	bool isSingleton() const
122 	{
123 		checkClassBinding!(typeof(this))();
124 		return ptrcall!(bool)(GDNativeClassBinding.isSingleton, _godot_object);
125 	}
126 	/**
127 	
128 	*/
129 	void setConfigFile(ConfigFile config_file)
130 	{
131 		checkClassBinding!(typeof(this))();
132 		ptrcall!(void)(GDNativeClassBinding.setConfigFile, _godot_object, config_file);
133 	}
134 	/**
135 	
136 	*/
137 	void setLoadOnce(in bool load_once)
138 	{
139 		checkClassBinding!(typeof(this))();
140 		ptrcall!(void)(GDNativeClassBinding.setLoadOnce, _godot_object, load_once);
141 	}
142 	/**
143 	
144 	*/
145 	void setReloadable(in bool reloadable)
146 	{
147 		checkClassBinding!(typeof(this))();
148 		ptrcall!(void)(GDNativeClassBinding.setReloadable, _godot_object, reloadable);
149 	}
150 	/**
151 	
152 	*/
153 	void setSingleton(in bool singleton)
154 	{
155 		checkClassBinding!(typeof(this))();
156 		ptrcall!(void)(GDNativeClassBinding.setSingleton, _godot_object, singleton);
157 	}
158 	/**
159 	
160 	*/
161 	void setSymbolPrefix(in String symbol_prefix)
162 	{
163 		checkClassBinding!(typeof(this))();
164 		ptrcall!(void)(GDNativeClassBinding.setSymbolPrefix, _godot_object, symbol_prefix);
165 	}
166 	/**
167 	
168 	*/
169 	bool shouldLoadOnce() const
170 	{
171 		checkClassBinding!(typeof(this))();
172 		return ptrcall!(bool)(GDNativeClassBinding.shouldLoadOnce, _godot_object);
173 	}
174 	/**
175 	This resource in INI-style $(D ConfigFile) format, as in `.gdnlib` files.
176 	*/
177 	@property ConfigFile configFile()
178 	{
179 		return getConfigFile();
180 	}
181 	/// ditto
182 	@property void configFile(ConfigFile v)
183 	{
184 		setConfigFile(v);
185 	}
186 	/**
187 	If `true`, Godot loads only one copy of the library and each script that references the library will share static data like static or global variables.
188 	If `false`, Godot loads a separate copy of the library into memory for each script that references it.
189 	*/
190 	@property bool loadOnce()
191 	{
192 		return shouldLoadOnce();
193 	}
194 	/// ditto
195 	@property void loadOnce(bool v)
196 	{
197 		setLoadOnce(v);
198 	}
199 	/**
200 	If `true`, the editor will temporarily unload the library whenever the user switches away from the editor window, allowing the user to recompile the library without restarting Godot.
201 	$(B Note:) If the library defines tool scripts that run inside the editor, `reloadable` must be `false`. Otherwise, the editor will attempt to unload the tool scripts while they're in use and crash.
202 	*/
203 	@property bool reloadable()
204 	{
205 		return isReloadable();
206 	}
207 	/// ditto
208 	@property void reloadable(bool v)
209 	{
210 		setReloadable(v);
211 	}
212 	/**
213 	If `true`, Godot loads the library at startup rather than the first time a script uses the library, calling `{prefix}gdnative_singleton` after initializing the library (where `{prefix}` is the value of $(D symbolPrefix)). The library remains loaded as long as Godot is running.
214 	$(B Note:) A singleton library cannot be $(D reloadable).
215 	*/
216 	@property bool singleton()
217 	{
218 		return isSingleton();
219 	}
220 	/// ditto
221 	@property void singleton(bool v)
222 	{
223 		setSingleton(v);
224 	}
225 	/**
226 	The prefix this library's entry point functions begin with. For example, a GDNativeLibrary would declare its `gdnative_init` function as `godot_gdnative_init` by default.
227 	On platforms that require statically linking libraries (currently only iOS), each library must have a different `symbol_prefix`.
228 	*/
229 	@property String symbolPrefix()
230 	{
231 		return getSymbolPrefix();
232 	}
233 	/// ditto
234 	@property void symbolPrefix(String v)
235 	{
236 		setSymbolPrefix(v);
237 	}
238 }