1 /*************************************************************************/
2 /*  godot_nativescript.h                                                 */
3 /*************************************************************************/
4 /*                       This file is part of:                           */
5 /*                           GODOT ENGINE                                */
6 /*                    http://www.godotengine.org                         */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur.                 */
9 /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md)    */
10 /*                                                                       */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the       */
13 /* "Software"), to deal in the Software without restriction, including   */
14 /* without limitation the rights to use, copy, modify, merge, publish,   */
15 /* distribute, sublicense, and/or sell copies of the Software, and to    */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions:                                             */
18 /*                                                                       */
19 /* The above copyright notice and this permission notice shall be        */
20 /* included in all copies or substantial portions of the Software.       */
21 /*                                                                       */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
29 /*************************************************************************/
30 module godot.abi.nativescript;
31 
32 @nogc nothrow:
33 extern (C):
34 
35 import godot.abi.types;
36 
37 enum godot_nativescript_method_rpc_mode {
38     GODOT_METHOD_RPC_MODE_DISABLED,
39     GODOT_METHOD_RPC_MODE_ANY_PEER,
40     GODOT_METHOD_RPC_MODE_AUTHORITY,
41 }
42 
43 struct godot_nativescript_method_attributes {
44     godot_nativescript_method_rpc_mode rpc_type;
45 }
46 
47 enum godot_nativescript_property_hint {
48     GODOT_PROPERTY_HINT_NONE, ///< no hint provided.
49     GODOT_PROPERTY_HINT_RANGE, ///< hint_text = "min,max,step,slider; //slider is optional"
50     GODOT_PROPERTY_HINT_EXP_RANGE, ///< hint_text = "min,max,step", exponential edit
51     GODOT_PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc"
52     GODOT_PROPERTY_HINT_EXP_EASING, /// exponential easing funciton (Math::ease)
53     GODOT_PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer)
54     GODOT_PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer)
55     GODOT_PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags)
56     GODOT_PROPERTY_HINT_LAYERS_2D_RENDER,
57     GODOT_PROPERTY_HINT_LAYERS_2D_PHYSICS,
58     GODOT_PROPERTY_HINT_LAYERS_2D_NAVIGATION,
59     GODOT_PROPERTY_HINT_LAYERS_3D_RENDER,
60     GODOT_PROPERTY_HINT_LAYERS_3D_PHYSICS,
61     GODOT_PROPERTY_HINT_LAYERS_3D_NAVIGATION,
62     GODOT_PROPERTY_HINT_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,"
63     GODOT_PROPERTY_HINT_DIR, ///< a directort path must be passed
64     GODOT_PROPERTY_HINT_GLOBAL_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,"
65     GODOT_PROPERTY_HINT_GLOBAL_DIR, ///< a directort path must be passed
66     GODOT_PROPERTY_HINT_RESOURCE_TYPE, ///< a resource object type
67     GODOT_PROPERTY_HINT_MULTILINE_TEXT, ///< used for string properties that can contain multiple lines
68     GODOT_PROPERTY_HINT_PLACEHOLDER_TEXT, ///< used to set a placeholder text for string properties
69     GODOT_PROPERTY_HINT_COLOR_NO_ALPHA, ///< used for ignoring alpha component when editing a color
70     GODOT_PROPERTY_HINT_IMAGE_COMPRESS_LOSSY,
71     GODOT_PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS,
72     GODOT_PROPERTY_HINT_OBJECT_ID,
73     GODOT_PROPERTY_HINT_TYPE_STRING, ///< a type string, the hint is the base type to choose
74     GODOT_PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE, ///< so something else can provide this (used in scripts)
75     GODOT_PROPERTY_HINT_METHOD_OF_VARIANT_TYPE, ///< a method of a type
76     GODOT_PROPERTY_HINT_METHOD_OF_BASE_TYPE, ///< a method of a base type
77     GODOT_PROPERTY_HINT_METHOD_OF_INSTANCE, ///< a method of an instance
78     GODOT_PROPERTY_HINT_METHOD_OF_SCRIPT, ///< a method of a script & base
79     GODOT_PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE, ///< a property of a type
80     GODOT_PROPERTY_HINT_PROPERTY_OF_BASE_TYPE, ///< a property of a base type
81     GODOT_PROPERTY_HINT_PROPERTY_OF_INSTANCE, ///< a property of an instance
82     GODOT_PROPERTY_HINT_PROPERTY_OF_SCRIPT, ///< a property of a script & base
83     GODOT_PROPERTY_HINT_MAX,
84 }
85 
86 enum godot_nativescript_property_usage_flags {
87 
88     GODOT_PROPERTY_USAGE_STORAGE = 1,
89     GODOT_PROPERTY_USAGE_EDITOR = 2,
90     GODOT_PROPERTY_USAGE_NETWORK = 4,
91     GODOT_PROPERTY_USAGE_EDITOR_HELPER = 8,
92     GODOT_PROPERTY_USAGE_CHECKABLE = 16, //used for editing global variables
93     GODOT_PROPERTY_USAGE_CHECKED = 32, //used for editing global variables
94     GODOT_PROPERTY_USAGE_INTERNATIONALIZED = 64, //hint for internationalized strings
95     GODOT_PROPERTY_USAGE_GROUP = 128, //used for grouping props in the editor
96     GODOT_PROPERTY_USAGE_CATEGORY = 256,
97     GODOT_PROPERTY_USAGE_SUBGROUP = 512,
98     GODOT_PROPERTY_USAGE_NO_INSTANCE_STATE = 2048,
99     GODOT_PROPERTY_USAGE_RESTART_IF_CHANGED = 4096,
100     GODOT_PROPERTY_USAGE_SCRIPT_VARIABLE = 8192,
101     GODOT_PROPERTY_USAGE_STORE_IF_NULL = 16384,
102     GODOT_PROPERTY_USAGE_ANIMATE_AS_TRIGGER = 32768,
103     GODOT_PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED = 65536,
104 
105     GODOT_PROPERTY_USAGE_DEFAULT = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_EDITOR | GODOT_PROPERTY_USAGE_NETWORK,
106     GODOT_PROPERTY_USAGE_DEFAULT_INTL = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_EDITOR | GODOT_PROPERTY_USAGE_NETWORK | GODOT_PROPERTY_USAGE_INTERNATIONALIZED,
107     GODOT_PROPERTY_USAGE_NO_EDITOR = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_NETWORK,
108 }
109 
110 struct godot_nativescript_property_attributes {
111 align(1):
112     godot_nativescript_method_rpc_mode rset_type;
113 
114     godot_int type;
115     godot_nativescript_property_hint hint = godot_nativescript_property_hint
116         .GODOT_PROPERTY_HINT_NONE;
117     godot_string hint_string;
118     godot_nativescript_property_usage_flags usage = godot_nativescript_property_usage_flags
119         .GODOT_PROPERTY_USAGE_DEFAULT;
120     godot_variant default_value;
121 }
122 
123 struct godot_nativescript_instance_create_func {
124     // instance pointer, method_data - return user data
125     void* function(godot_object, void*) create_func;
126     void* method_data;
127     void function(void*) free_func;
128 }
129 
130 struct godot_nativescript_instance_destroy_func {
131     // instance pointer, method data, user data
132     void function(godot_object, void*, void*) destroy_func;
133     void* method_data;
134     void function(void*) free_func;
135 }
136 
137 struct godot_nativescript_instance_method {
138     // instance pointer, method data, user data, num args, args - return result as varaint
139     godot_variant function(godot_object, void*, void*, int, godot_variant**) method;
140     void* method_data;
141     void function(void*) free_func;
142 }
143 
144 struct godot_nativescript_property_set_func {
145     // instance pointer, method data, user data, value
146     void function(godot_object, void*, void*, godot_variant*) set_func;
147     void* method_data;
148     void function(void*) free_func;
149 }
150 
151 struct godot_nativescript_property_get_func {
152     // instance pointer, method data, user data, value
153     godot_variant function(godot_object, void*, void*) get_func;
154     void* method_data;
155     void function(void*) free_func;
156 }
157 
158 struct godot_nativescript_signal_argument {
159 align(1):
160     godot_string name;
161     godot_int type;
162     godot_nativescript_property_hint hint;
163     godot_string hint_string;
164     godot_nativescript_property_usage_flags usage;
165     godot_variant default_value;
166 }
167 
168 struct godot_nativescript_signal {
169     godot_string name;
170     int num_args;
171     godot_nativescript_signal_argument* args;
172     int num_default_args;
173     godot_variant* default_args;
174 }
175 
176 // NativeScript 1.1
177 
178 struct godot_nativescript_method_argument {
179     godot_string name;
180     godot_variant_type type;
181     godot_nativescript_property_hint hint;
182     godot_string hint_string;
183 }
184 
185 struct godot_nativescript_instance_binding_functions {
186     void* function(void*, const void*, godot_object) alloc_instance_binding_data;
187     void function(void*, void*) free_instance_binding_data;
188     void function(void*, godot_object) refcount_incremented_instance_binding;
189     bool function(void*, godot_object) refcount_decremented_instance_binding;
190     void* data;
191     void function(void*) free_func;
192 }