summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/dds/texture_loader_dds.cpp10
-rw-r--r--modules/gdnative/gdnative.cpp50
-rw-r--r--modules/gdnative/gdnative.h2
-rw-r--r--modules/gdnative/godot.h43
-rw-r--r--modules/gdnative/godot/godot_basis.cpp180
-rw-r--r--modules/gdnative/godot/godot_basis.h32
-rw-r--r--modules/gdnative/godot/godot_string.cpp5
-rw-r--r--modules/gdnative/godot/godot_string.h2
-rw-r--r--modules/gdnative/godot/godot_vector2.cpp348
-rw-r--r--modules/gdnative/godot/godot_vector2.h62
-rw-r--r--modules/gdnative/godot/godot_vector3.cpp396
-rw-r--r--modules/gdnative/godot/godot_vector3.h90
-rw-r--r--modules/gdscript/gd_editor.cpp25
-rw-r--r--modules/gdscript/gd_script.cpp4
-rw-r--r--modules/gdscript/gd_script.h2
-rw-r--r--modules/multiscript/SCsub7
-rw-r--r--modules/multiscript/config.py8
-rw-r--r--modules/multiscript/multiscript.cpp750
-rw-r--r--modules/multiscript/multiscript.h200
-rw-r--r--modules/multiscript/register_types.cpp51
-rw-r--r--modules/multiscript/register_types.h31
-rw-r--r--modules/visual_script/visual_script.cpp12
-rw-r--r--modules/visual_script/visual_script.h2
-rw-r--r--modules/visual_script/visual_script_editor.cpp20
-rw-r--r--modules/visual_script/visual_script_editor.h3
-rw-r--r--modules/webp/image_loader_webp.cpp10
26 files changed, 1851 insertions, 494 deletions
diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp
index f80e6e501e..d79b7685d1 100644
--- a/modules/dds/texture_loader_dds.cpp
+++ b/modules/dds/texture_loader_dds.cpp
@@ -144,12 +144,14 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
f->get_32();
f->get_32();
- /*print_line("DDS width: "+itos(width));
+ /*
+ print_line("DDS width: "+itos(width));
print_line("DDS height: "+itos(height));
- print_line("DDS mipmaps: "+itos(mipmaps));*/
+ print_line("DDS mipmaps: "+itos(mipmaps));
- //printf("fourcc: %x fflags: %x, rgbbits: %x, fsize: %x\n",format_fourcc,format_flags,format_rgb_bits,format_size);
- //printf("rmask: %x gmask: %x, bmask: %x, amask: %x\n",format_red_mask,format_green_mask,format_blue_mask,format_alpha_mask);
+ printf("fourcc: %x fflags: %x, rgbbits: %x, fsize: %x\n",format_fourcc,format_flags,format_rgb_bits,format_size);
+ printf("rmask: %x gmask: %x, bmask: %x, amask: %x\n",format_red_mask,format_green_mask,format_blue_mask,format_alpha_mask);
+ */
//must avoid this later
while (f->get_pos() < 128)
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index b543a486d3..09859d95bd 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -391,6 +391,54 @@ void GDNativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
}
}
+Variant GDNativeScript::_new(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+
+ /* STEP 1, CREATE */
+
+ if (!library.is_valid() || ((String)script_name).empty() || !script_data) {
+ r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ return Variant();
+ }
+
+ r_error.error = Variant::CallError::CALL_OK;
+ REF ref;
+ Object *owner = NULL;
+
+ GDNativeScriptData *_baseptr = script_data;
+ while (_baseptr->base_data) {
+ _baseptr = _baseptr->base_data;
+ }
+
+ if (!(_baseptr->base_native_type == "")) {
+ owner = ClassDB::instance(_baseptr->base_native_type);
+ } else {
+ owner = memnew(Reference); //by default, no base means use reference
+ }
+
+ Reference *r = owner->cast_to<Reference>();
+ if (r) {
+ ref = REF(r);
+ }
+
+ // GDScript does it like this: _create_instance(p_args, p_argcount, owner, r != NULL, r_error);
+ // @Todo support varargs for constructors.
+ GDNativeInstance *instance = (GDNativeInstance *)instance_create(owner);
+
+ owner->set_script_instance(instance);
+ if (!instance) {
+ if (ref.is_null()) {
+ memdelete(owner); //no owner, sorry
+ }
+ return Variant();
+ }
+
+ if (ref.is_valid()) {
+ return ref;
+ } else {
+ return owner;
+ }
+}
+
Ref<GDNativeLibrary> GDNativeScript::get_library() const {
return library;
}
@@ -438,6 +486,8 @@ void GDNativeScript::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_script_name"), &GDNativeScript::get_script_name);
ClassDB::bind_method(D_METHOD("set_script_name", "script_name"), &GDNativeScript::set_script_name);
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &GDNativeScript::_new, MethodInfo(Variant::OBJECT, "new"));
+
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library");
ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "script_name"), "set_script_name", "get_script_name");
}
diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h
index 89270b4e26..27e0c3788b 100644
--- a/modules/gdnative/gdnative.h
+++ b/modules/gdnative/gdnative.h
@@ -184,6 +184,8 @@ public:
virtual void get_script_method_list(List<MethodInfo> *p_list) const;
virtual void get_script_property_list(List<PropertyInfo> *p_list) const;
+ Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+
Ref<GDNativeLibrary> get_library() const;
void set_library(Ref<GDNativeLibrary> p_library);
diff --git a/modules/gdnative/godot.h b/modules/gdnative/godot.h
index 0d7aece23b..b05cafbe50 100644
--- a/modules/gdnative/godot.h
+++ b/modules/gdnative/godot.h
@@ -38,12 +38,26 @@ extern "C" {
#define GDAPI_EXPORT
#endif
-#if !defined(_WIN32) && !defined(_MSC_VER)
+#ifdef _WIN32
+#if defined(GDAPI_EXPORT)
+#define GDCALLINGCONV
+#define GDAPI __declspec(dllexport) GDCALLINGCONV
+#else
+#define GDCALLINGCONV
+#define GDAPI __declspec(dllimport) GDCALLINGCONV
+#endif
+#elif defined(__APPLE__)
+#include "TargetConditionals.h"
+#if TARGET_OS_IPHONE
+#define GDCALLINGCONV
#define GDAPI
-#elif defined(GDAPI_EXPORT)
-#define GDAPI __declspec(dllexport)
+#elif TARGET_OS_MAC
+#define GDCALLINGCONV __attribute__((sysv_abi))
+#define GDAPI GDCALLINGCONV
+#endif
#else
-#define GDAPI __declspec(dllimport)
+#define GDCALLINGCONV __attribute__((sysv_abi))
+#define GDAPI GDCALLINGCONV
#endif
#include <stdbool.h>
@@ -314,16 +328,16 @@ typedef struct godot_property_attributes {
typedef struct godot_instance_create_func {
// instance pointer, method_data - return user data
- void *(*create_func)(godot_object *, void *);
+ GDCALLINGCONV void *(*create_func)(godot_object *, void *);
void *method_data;
- void (*free_func)(void *);
+ GDCALLINGCONV void (*free_func)(void *);
} godot_instance_create_func;
typedef struct godot_instance_destroy_func {
// instance pointer, method data, user data
- void (*destroy_func)(godot_object *, void *, void *);
+ GDCALLINGCONV void (*destroy_func)(godot_object *, void *, void *);
void *method_data;
- void (*free_func)(void *);
+ GDCALLINGCONV void (*free_func)(void *);
} godot_instance_destroy_func;
void GDAPI godot_script_register_class(const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func);
@@ -332,25 +346,25 @@ void GDAPI godot_script_register_tool_class(const char *p_name, const char *p_ba
typedef struct godot_instance_method {
// instance pointer, method data, user data, num args, args - return result as varaint
- godot_variant (*method)(godot_object *, void *, void *, int, godot_variant **);
+ GDCALLINGCONV godot_variant (*method)(godot_object *, void *, void *, int, godot_variant **);
void *method_data;
- void (*free_func)(void *);
+ GDCALLINGCONV void (*free_func)(void *);
} godot_instance_method;
void GDAPI godot_script_register_method(const char *p_name, const char *p_function_name, godot_method_attributes p_attr, godot_instance_method p_method);
typedef struct godot_property_set_func {
// instance pointer, method data, user data, value
- void (*set_func)(godot_object *, void *, void *, godot_variant);
+ GDCALLINGCONV void (*set_func)(godot_object *, void *, void *, godot_variant);
void *method_data;
- void (*free_func)(void *);
+ GDCALLINGCONV void (*free_func)(void *);
} godot_property_set_func;
typedef struct godot_property_get_func {
// instance pointer, method data, user data, value
- godot_variant (*get_func)(godot_object *, void *, void *);
+ GDCALLINGCONV godot_variant (*get_func)(godot_object *, void *, void *);
void *method_data;
- void (*free_func)(void *);
+ GDCALLINGCONV void (*free_func)(void *);
} godot_property_get_func;
void GDAPI godot_script_register_property(const char *p_name, const char *p_path, godot_property_attributes *p_attr, godot_property_set_func p_set_func, godot_property_get_func p_get_func);
@@ -376,6 +390,7 @@ void GDAPI godot_script_register_signal(const char *p_name, const godot_signal *
void GDAPI *godot_native_get_userdata(godot_object *p_instance);
+// Calling convention?
typedef godot_object *(*godot_class_constructor)();
godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname);
diff --git a/modules/gdnative/godot/godot_basis.cpp b/modules/gdnative/godot/godot_basis.cpp
index 4322acc401..474cd3d448 100644
--- a/modules/gdnative/godot/godot_basis.cpp
+++ b/modules/gdnative/godot/godot_basis.cpp
@@ -38,48 +38,176 @@ extern "C" {
void _basis_api_anchor() {
}
-void GDAPI godot_basis_new(godot_basis *p_basis) {
- Basis *basis = (Basis *)p_basis;
- *basis = Basis();
+void GDAPI godot_basis_new(godot_basis *p_v) {
+ Basis *v = (Basis *)p_v;
+ *v = Basis();
}
-void GDAPI godot_basis_new_with_euler_quat(godot_basis *p_basis, const godot_quat *p_euler) {
- Basis *basis = (Basis *)p_basis;
+void GDAPI godot_basis_new_with_euler_quat(godot_basis *p_v, const godot_quat *p_euler) {
+ Basis *v = (Basis *)p_v;
Quat *euler = (Quat *)p_euler;
- *basis = Basis(*euler);
+ *v = Basis(*euler);
}
-void GDAPI godot_basis_new_with_euler(godot_basis *p_basis, const godot_vector3 *p_euler) {
- Basis *basis = (Basis *)p_basis;
- Vector3 *euler = (Vector3 *)p_euler;
- *basis = Basis(*euler);
+void GDAPI godot_basis_new_with_euler(godot_basis *p_v, const godot_vector3 p_euler) {
+ Basis *v = (Basis *)p_v;
+ Vector3 *euler = (Vector3 *)&p_euler;
+ *v = Basis(*euler);
}
-godot_quat GDAPI godot_basis_as_quat(const godot_basis *p_basis) {
- const Basis *basis = (const Basis *)p_basis;
+void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *p_v, const godot_vector3 p_axis, const godot_real p_phi) {
+ Basis *v = (Basis *)p_v;
+ const Vector3 *axis = (Vector3 *)&p_axis;
+ *v = Basis(*axis, p_phi);
+}
+
+void GDAPI godot_basis_new_with_rows(godot_basis *p_v, const godot_vector3 p_row0, const godot_vector3 p_row1, const godot_vector3 p_row2) {
+ Basis *v = (Basis *)p_v;
+ const Vector3 *row0 = (Vector3 *)&p_row0;
+ const Vector3 *row1 = (Vector3 *)&p_row1;
+ const Vector3 *row2 = (Vector3 *)&p_row2;
+ *v = Basis(*row0, *row1, *row2);
+}
+
+godot_quat GDAPI godot_basis_as_quat(const godot_basis *p_v) {
+ const Basis *v = (const Basis *)p_v;
godot_quat quat;
Quat *p_quat = (Quat *)&quat;
- *p_quat = basis->operator Quat();
+ *p_quat = v->operator Quat();
return quat;
}
-godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_basis) {
- const Basis *basis = (const Basis *)p_basis;
- godot_vector3 euler;
- Vector3 *p_euler = (Vector3 *)&euler;
- *p_euler = basis->get_euler();
- return euler;
-}
-
/*
* p_elements is a pointer to an array of 3 (!!) vector3
*/
-void GDAPI godot_basis_get_elements(godot_basis *p_basis, godot_vector3 *p_elements) {
- Basis *basis = (Basis *)p_basis;
+void GDAPI godot_basis_get_elements(godot_basis *p_v, godot_vector3 *p_elements) {
+ Basis *v = (Basis *)p_v;
Vector3 *elements = (Vector3 *)p_elements;
- elements[0] = basis->elements[0];
- elements[1] = basis->elements[1];
- elements[2] = basis->elements[2];
+ elements[0] = v->elements[0];
+ elements[1] = v->elements[1];
+ elements[2] = v->elements[2];
+}
+
+godot_vector3 GDAPI godot_basis_get_axis(const godot_basis *p_v, const godot_int p_axis) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Basis *v = (Basis *)p_v;
+ *d = v->get_axis(p_axis);
+ return dest;
+}
+
+void GDAPI godot_basis_set_axis(godot_basis *p_v, const godot_int p_axis, const godot_vector3 p_value) {
+ Basis *v = (Basis *)p_v;
+ const Vector3 *value = (Vector3 *)&p_value;
+ v->set_axis(p_axis, *value);
+}
+
+godot_vector3 GDAPI godot_basis_get_row(const godot_basis *p_v, const godot_int p_row) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Basis *v = (Basis *)p_v;
+ *d = v->get_row(p_row);
+ return dest;
+}
+
+void GDAPI godot_basis_set_row(godot_basis *p_v, const godot_int p_row, const godot_vector3 p_value) {
+ Basis *v = (Basis *)p_v;
+ const Vector3 *value = (Vector3 *)&p_value;
+ v->set_row(p_row, *value);
+}
+
+godot_real godot_basis_determinant(const godot_basis *p_v) {
+ Basis *v = (Basis *)p_v;
+ return v->determinant();
+}
+
+godot_vector3 godot_basis_get_euler(const godot_basis *p_v) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Basis *v = (Basis *)p_v;
+ *d = v->get_euler();
+ return dest;
+}
+
+godot_int godot_basis_get_orthogonal_index(const godot_basis *p_v) {
+ const Basis *v = (Basis *)p_v;
+ return v->get_orthogonal_index();
+}
+
+godot_vector3 godot_basis_get_scale(const godot_basis *p_v) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Basis *v = (Basis *)p_v;
+ *d = v->get_scale();
+ return dest;
+}
+
+void godot_basis_inverse(godot_basis *p_dest, const godot_basis *p_v) {
+ Basis *d = (Basis *)p_dest;
+ const Basis *v = (Basis *)p_v;
+ *d = v->inverse();
+}
+
+void godot_basis_orthonormalized(godot_basis *p_dest, const godot_basis *p_v) {
+ Basis *d = (Basis *)p_dest;
+ const Basis *v = (Basis *)p_v;
+ *d = v->orthonormalized();
+}
+
+void godot_basis_rotated(godot_basis *p_dest, const godot_basis *p_v, const godot_vector3 p_axis, const godot_real p_phi) {
+ Basis *d = (Basis *)p_dest;
+ const Basis *v = (Basis *)p_v;
+ const Vector3 *axis = (Vector3 *)&p_axis;
+ *d = v->rotated(*axis, p_phi);
+}
+
+void godot_basis_scaled(godot_basis *p_dest, const godot_basis *p_v, const godot_vector3 p_scale) {
+ Basis *d = (Basis *)p_dest;
+ const Basis *v = (Basis *)p_v;
+ const Vector3 *scale = (Vector3 *)&p_scale;
+ *d = v->scaled(*scale);
+}
+
+godot_real godot_basis_tdotx(const godot_basis *p_v, const godot_vector3 p_with) {
+ const Basis *v = (Basis *)p_v;
+ const Vector3 *with = (Vector3 *)&p_with;
+ return v->tdotx(*with);
+}
+
+godot_real godot_basis_tdoty(const godot_basis *p_v, const godot_vector3 p_with) {
+ const Basis *v = (Basis *)p_v;
+ const Vector3 *with = (Vector3 *)&p_with;
+ return v->tdoty(*with);
+}
+
+godot_real godot_basis_tdotz(const godot_basis *p_v, const godot_vector3 p_with) {
+ const Basis *v = (Basis *)p_v;
+ const Vector3 *with = (Vector3 *)&p_with;
+ return v->tdotz(*with);
+}
+
+void godot_basis_transposed(godot_basis *p_dest, const godot_basis *p_v) {
+ Basis *d = (Basis *)p_dest;
+ const Basis *v = (Basis *)p_v;
+ *d = v->transposed();
+}
+
+godot_vector3 godot_basis_xform(const godot_basis *p_v, const godot_vector3 p_vect) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Basis *v = (Basis *)p_v;
+ const Vector3 *vect = (Vector3 *)&p_vect;
+ *d = v->xform(*vect);
+ return dest;
+}
+
+godot_vector3 godot_basis_xform_inv(const godot_basis *p_v, const godot_vector3 p_vect) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Basis *v = (Basis *)p_v;
+ const Vector3 *vect = (Vector3 *)&p_vect;
+ *d = v->xform_inv(*vect);
+ return dest;
}
#ifdef __cplusplus
diff --git a/modules/gdnative/godot/godot_basis.h b/modules/gdnative/godot/godot_basis.h
index e65e5b6830..2803396997 100644
--- a/modules/gdnative/godot/godot_basis.h
+++ b/modules/gdnative/godot/godot_basis.h
@@ -45,17 +45,37 @@ typedef struct godot_basis {
#include "../godot.h"
#include "godot_quat.h"
-void GDAPI godot_basis_new(godot_basis *p_basis);
-void GDAPI godot_basis_new_with_euler_quat(godot_basis *p_basis, const godot_quat *p_euler);
-void GDAPI godot_basis_new_with_euler(godot_basis *p_basis, const godot_vector3 *p_euler);
+void GDAPI godot_basis_new(godot_basis *p_v);
+void GDAPI godot_basis_new_with_euler_quat(godot_basis *p_v, const godot_quat *p_euler);
+void GDAPI godot_basis_new_with_euler(godot_basis *p_v, const godot_vector3 p_euler);
+void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *p_v, const godot_vector3 p_axis, const godot_real p_phi);
+void GDAPI godot_basis_new_with_rows(godot_basis *p_v, const godot_vector3 p_row0, const godot_vector3 p_row1, const godot_vector3 p_row2);
-godot_quat GDAPI godot_basis_as_quat(const godot_basis *p_basis);
-godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_basis);
+godot_quat GDAPI godot_basis_as_quat(const godot_basis *p_v);
/*
* p_elements is a pointer to an array of 3 (!!) vector3
*/
-void GDAPI godot_basis_get_elements(godot_basis *p_basis, godot_vector3 *p_elements);
+void GDAPI godot_basis_get_elements(godot_basis *p_v, godot_vector3 *p_elements);
+godot_vector3 GDAPI godot_basis_get_axis(const godot_basis *p_v, const godot_int p_axis);
+void GDAPI godot_basis_set_axis(godot_basis *p_v, const godot_int p_axis, const godot_vector3 p_value);
+godot_vector3 GDAPI godot_basis_get_row(const godot_basis *p_v, const godot_int p_row);
+void GDAPI godot_basis_set_row(godot_basis *p_v, const godot_int p_row, const godot_vector3 p_value);
+
+godot_real godot_basis_determinant(const godot_basis *p_v);
+godot_vector3 godot_basis_get_euler(const godot_basis *p_v);
+godot_int godot_basis_get_orthogonal_index(const godot_basis *p_v);
+godot_vector3 godot_basis_get_scale(const godot_basis *p_v);
+void godot_basis_inverse(godot_basis *p_dest, const godot_basis *p_v);
+void godot_basis_orthonormalized(godot_basis *p_dest, const godot_basis *p_v);
+void godot_basis_rotated(godot_basis *p_dest, const godot_basis *p_v, const godot_vector3 p_axis, const godot_real p_phi);
+void godot_basis_scaled(godot_basis *p_dest, const godot_basis *p_v, const godot_vector3 p_scale);
+godot_real godot_basis_tdotx(const godot_basis *p_v, const godot_vector3 p_with);
+godot_real godot_basis_tdoty(const godot_basis *p_v, const godot_vector3 p_with);
+godot_real godot_basis_tdotz(const godot_basis *p_v, const godot_vector3 p_with);
+void godot_basis_transposed(godot_basis *p_dest, const godot_basis *p_v);
+godot_vector3 godot_basis_xform(const godot_basis *p_v, const godot_vector3 p_vect);
+godot_vector3 godot_basis_xform_inv(const godot_basis *p_v, const godot_vector3 p_vect);
#ifdef __cplusplus
}
diff --git a/modules/gdnative/godot/godot_string.cpp b/modules/gdnative/godot/godot_string.cpp
index 757b8510cf..92c0b04041 100644
--- a/modules/gdnative/godot/godot_string.cpp
+++ b/modules/gdnative/godot/godot_string.cpp
@@ -80,6 +80,11 @@ const char GDAPI *godot_string_c_str(const godot_string *p_str) {
return s->utf8().get_data();
}
+const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_str) {
+ const String *s = (const String *)p_str;
+ return s->c_str();
+}
+
godot_bool GDAPI godot_string_operator_equal(const godot_string *p_a, const godot_string *p_b) {
String *a = (String *)p_a;
String *b = (String *)p_b;
diff --git a/modules/gdnative/godot/godot_string.h b/modules/gdnative/godot/godot_string.h
index 9289531c5e..83ed5d6ec1 100644
--- a/modules/gdnative/godot/godot_string.h
+++ b/modules/gdnative/godot/godot_string.h
@@ -35,6 +35,7 @@ extern "C" {
#endif
#include <stdint.h>
+#include <wchar.h>
#ifndef GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED
typedef struct godot_string {
@@ -53,6 +54,7 @@ void GDAPI godot_string_copy_string(const godot_string *p_dest, const godot_stri
wchar_t GDAPI *godot_string_operator_index(godot_string *p_str, const godot_int p_idx);
const char GDAPI *godot_string_c_str(const godot_string *p_str);
+const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_str);
godot_bool GDAPI godot_string_operator_equal(const godot_string *p_a, const godot_string *p_b);
godot_bool GDAPI godot_string_operator_less(const godot_string *p_a, const godot_string *p_b);
diff --git a/modules/gdnative/godot/godot_vector2.cpp b/modules/gdnative/godot/godot_vector2.cpp
index ad5107f9a8..87e60b6245 100644
--- a/modules/gdnative/godot/godot_vector2.cpp
+++ b/modules/gdnative/godot/godot_vector2.cpp
@@ -37,11 +37,12 @@ extern "C" {
void _vector2_api_anchor() {}
-void GDAPI godot_vector2_new(godot_vector2 *p_v, godot_real p_x,
- godot_real p_y) {
- Vector2 *v = (Vector2 *)p_v;
+godot_vector2 GDAPI godot_vector2_new(const godot_real p_x, const godot_real p_y) {
+ godot_vector2 value;
+ Vector2 *v = (Vector2 *)&value;
v->x = p_x;
v->y = p_y;
+ return value;
}
void GDAPI godot_vector2_set_x(godot_vector2 *p_v, const godot_real p_x) {
@@ -55,11 +56,11 @@ void GDAPI godot_vector2_set_y(godot_vector2 *p_v, const godot_real p_y) {
}
godot_real GDAPI godot_vector2_get_x(const godot_vector2 *p_v) {
- Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *v = (Vector2 *)p_v;
return v->x;
}
godot_real GDAPI godot_vector2_get_y(const godot_vector2 *p_v) {
- Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *v = (Vector2 *)p_v;
return v->y;
}
@@ -67,224 +68,227 @@ void GDAPI godot_vector2_normalize(godot_vector2 *p_v) {
Vector2 *v = (Vector2 *)p_v;
v->normalize();
}
-void GDAPI godot_vector2_normalized(godot_vector2 *p_dest,
- const godot_vector2 *p_src) {
- Vector2 *v = (Vector2 *)p_src;
- Vector2 *d = (Vector2 *)p_dest;
+godot_vector2 GDAPI godot_vector2_normalized(const godot_vector2 *p_v) {
+ godot_vector2 dest;
+ const Vector2 *v = (Vector2 *)p_v;
+ Vector2 *d = (Vector2 *)&dest;
*d = v->normalized();
+ return dest;
}
godot_real GDAPI godot_vector2_length(const godot_vector2 *p_v) {
- Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *v = (Vector2 *)p_v;
return v->length();
}
godot_real GDAPI godot_vector2_length_squared(const godot_vector2 *p_v) {
- Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *v = (Vector2 *)p_v;
return v->length_squared();
}
-godot_real GDAPI godot_vector2_distance_to(const godot_vector2 *p_a,
- const godot_vector2 *p_b) {
- Vector2 *a = (Vector2 *)p_a;
- Vector2 *b = (Vector2 *)p_b;
- return a->distance_to(*b);
+godot_real GDAPI godot_vector2_distance_to(const godot_vector2 *p_v, const godot_vector2 p_b) {
+ const Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *b = (Vector2 *)&p_b;
+ return v->distance_to(*b);
}
-godot_real GDAPI godot_vector2_distance_squared_to(const godot_vector2 *p_a,
- const godot_vector2 *p_b) {
- Vector2 *a = (Vector2 *)p_a;
- Vector2 *b = (Vector2 *)p_b;
- return a->distance_squared_to(*b);
+godot_real GDAPI godot_vector2_distance_squared_to(const godot_vector2 *p_v, const godot_vector2 p_b) {
+ const Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *b = (Vector2 *)&p_b;
+ return v->distance_squared_to(*b);
}
-void GDAPI godot_vector2_operator_add(godot_vector2 *p_dest,
- const godot_vector2 *p_a,
- const godot_vector2 *p_b) {
- Vector2 *dest = (Vector2 *)p_dest;
- const Vector2 *a = (Vector2 *)p_a;
- const Vector2 *b = (Vector2 *)p_b;
- *dest = *a + *b;
+godot_vector2 GDAPI godot_vector2_operator_add(const godot_vector2 *p_v, const godot_vector2 p_b) {
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ const Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *b = (Vector2 *)&p_b;
+ *d = *v + *b;
+ return dest;
}
-void GDAPI godot_vector2_operator_subtract(godot_vector2 *p_dest,
- const godot_vector2 *p_a,
- const godot_vector2 *p_b) {
- Vector2 *dest = (Vector2 *)p_dest;
- const Vector2 *a = (Vector2 *)p_a;
- const Vector2 *b = (Vector2 *)p_b;
- *dest = *a - *b;
+godot_vector2 GDAPI godot_vector2_operator_subtract(const godot_vector2 *p_v, const godot_vector2 p_b) {
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ const Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *b = (Vector2 *)&p_b;
+ *d = *v - *b;
+ return dest;
}
-void GDAPI godot_vector2_operator_multiply_vector(godot_vector2 *p_dest,
- const godot_vector2 *p_a,
- const godot_vector2 *p_b) {
- Vector2 *dest = (Vector2 *)p_dest;
- const Vector2 *a = (Vector2 *)p_a;
- const Vector2 *b = (Vector2 *)p_b;
- *dest = *a * *b;
+godot_vector2 GDAPI godot_vector2_operator_multiply_vector(const godot_vector2 *p_v, const godot_vector2 p_b) {
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ const Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *b = (Vector2 *)&p_b;
+ *d = *v * *b;
+ return dest;
}
-void GDAPI godot_vector2_operator_multiply_scalar(godot_vector2 *p_dest,
- const godot_vector2 *p_a,
- const godot_real p_b) {
- Vector2 *dest = (Vector2 *)p_dest;
- const Vector2 *a = (Vector2 *)p_a;
- *dest = *a * p_b;
+godot_vector2 GDAPI godot_vector2_operator_multiply_scalar(const godot_vector2 *p_v, const godot_real p_b) {
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ const Vector2 *v = (Vector2 *)p_v;
+ *d = *v * p_b;
+ return dest;
}
-void GDAPI godot_vector2_operator_divide_vector(godot_vector2 *p_dest,
- const godot_vector2 *p_a,
- const godot_vector2 *p_b) {
- Vector2 *dest = (Vector2 *)p_dest;
- const Vector2 *a = (Vector2 *)p_a;
- const Vector2 *b = (Vector2 *)p_b;
- *dest = *a / *b;
+godot_vector2 GDAPI godot_vector2_operator_divide_vector(const godot_vector2 *p_v, const godot_vector2 p_b) {
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ const Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *b = (Vector2 *)&p_b;
+ *d = *v / *b;
+ return dest;
}
-void GDAPI godot_vector2_operator_divide_scalar(godot_vector2 *p_dest,
- const godot_vector2 *p_a,
- const godot_real p_b) {
- Vector2 *dest = (Vector2 *)p_dest;
- const Vector2 *a = (Vector2 *)p_a;
- *dest = *a / p_b;
+godot_vector2 GDAPI godot_vector2_operator_divide_scalar(const godot_vector2 *p_v, const godot_real p_b) {
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ const Vector2 *v = (Vector2 *)p_v;
+ *d = *v / p_b;
+ return dest;
}
-godot_bool GDAPI godot_vector2_operator_equal(const godot_vector2 *p_a,
- const godot_vector2 *p_b) {
- const Vector2 *a = (Vector2 *)p_a;
- const Vector2 *b = (Vector2 *)p_b;
- return *a == *b;
+godot_bool GDAPI godot_vector2_operator_equal(const godot_vector2 *p_v, const godot_vector2 p_b) {
+ const Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *b = (Vector2 *)&p_b;
+ return *v == *b;
}
-godot_bool GDAPI godot_vector2_operator_less(const godot_vector2 *p_a,
- const godot_vector2 *p_b) {
- const Vector2 *a = (Vector2 *)p_a;
- const Vector2 *b = (Vector2 *)p_b;
- return *a < *b;
+godot_bool GDAPI godot_vector2_operator_less(const godot_vector2 *p_v, const godot_vector2 p_b) {
+ const Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *b = (Vector2 *)&p_b;
+ return *v < *b;
}
-void GDAPI godot_vector2_abs(godot_vector2 *p_dest,
- const godot_vector2 *p_src) {
- const Vector2 *src = (Vector2 *)p_src;
- Vector2 *dest = (Vector2 *)p_dest;
- *dest = src->abs();
+godot_vector2 GDAPI godot_vector2_abs(const godot_vector2 *p_v) {
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ const Vector2 *v = (Vector2 *)p_v;
+ *d = v->abs();
+ return dest;
}
-godot_real GDAPI godot_vector2_angle(const godot_vector2 *p_src) {
- const Vector2 *src = (Vector2 *)p_src;
- return src->angle();
+godot_real GDAPI godot_vector2_angle(const godot_vector2 *p_v) {
+ const Vector2 *v = (Vector2 *)p_v;
+ return v->angle();
}
-godot_real GDAPI godot_vector2_angle_to(const godot_vector2 *p_src,
- const godot_vector2 *p_to) {
- const Vector2 *src = (Vector2 *)p_src;
- const Vector2 *to = (Vector2 *)p_to;
- return src->angle_to(*to);
+godot_real GDAPI godot_vector2_angle_to(const godot_vector2 *p_v, const godot_vector2 p_to) {
+ const Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *to = (Vector2 *)&p_to;
+ return v->angle_to(*to);
}
-godot_real GDAPI godot_vector2_angle_to_point(const godot_vector2 *p_src,
- const godot_vector2 *p_to) {
- const Vector2 *src = (Vector2 *)p_src;
- const Vector2 *to = (Vector2 *)p_to;
- return src->angle_to_point(*to);
+godot_real GDAPI godot_vector2_angle_to_point(const godot_vector2 *p_v, const godot_vector2 p_to) {
+ const Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *to = (Vector2 *)&p_to;
+ return v->angle_to_point(*to);
}
-void GDAPI godot_vector2_clamped(godot_vector2 *p_dest,
- const godot_vector2 *p_src,
- godot_real length) {
- const Vector2 *src = (Vector2 *)p_src;
- Vector2 *dest = (Vector2 *)p_dest;
- *dest = src->clamped(length);
+godot_vector2 GDAPI godot_vector2_clamped(const godot_vector2 *p_v, const godot_real length) {
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ const Vector2 *v = (Vector2 *)p_v;
+ *d = v->clamped(length);
+ return dest;
}
-void GDAPI godot_vector2_cubic_interpolate(
- godot_vector2 *p_dest, const godot_vector2 *p_src, const godot_vector2 *p_b,
- const godot_vector2 *p_pre_a, const godot_vector2 *p_post_b, godot_real t) {
- Vector2 *dest = (Vector2 *)p_dest;
- const Vector2 *src = (Vector2 *)p_src;
- const Vector2 *b = (Vector2 *)p_b;
- const Vector2 *pre_a = (Vector2 *)p_pre_a;
- const Vector2 *post_b = (Vector2 *)p_post_b;
- *dest = src->cubic_interpolate(*b, *pre_a, *post_b, t);
+godot_vector2 GDAPI godot_vector2_cubic_interpolate(
+ const godot_vector2 *p_v, const godot_vector2 p_b, const godot_vector2 p_pre_a,
+ const godot_vector2 p_post_b, godot_real t) {
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ const Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *b = (Vector2 *)&p_b;
+ const Vector2 *pre_a = (Vector2 *)&p_pre_a;
+ const Vector2 *post_b = (Vector2 *)&p_post_b;
+ *d = v->cubic_interpolate(*b, *pre_a, *post_b, t);
+ return dest;
}
-godot_real GDAPI godot_vector2_dot(const godot_vector2 *p_src,
- const godot_vector2 *p_with) {
- const Vector2 *src = (Vector2 *)p_src;
- const Vector2 *with = (Vector2 *)p_with;
- return src->dot(*with);
+godot_real GDAPI godot_vector2_dot(const godot_vector2 *p_v, const godot_vector2 p_with) {
+ const Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *with = (Vector2 *)&p_with;
+ return v->dot(*with);
}
-void GDAPI godot_vector2_floor(godot_vector2 *p_dest,
- const godot_vector2 *p_src) {
- const Vector2 *src = (Vector2 *)p_src;
- Vector2 *dest = (Vector2 *)p_dest;
- *dest = src->floor();
+godot_vector2 GDAPI godot_vector2_floor(const godot_vector2 *p_v) {
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ const Vector2 *v = (Vector2 *)p_v;
+ *d = v->floor();
+ return dest;
}
-godot_real GDAPI godot_vector2_aspect(const godot_vector2 *p_src) {
- const Vector2 *src = (Vector2 *)p_src;
- return src->aspect();
+godot_real GDAPI godot_vector2_aspect(const godot_vector2 *p_v) {
+ const Vector2 *v = (Vector2 *)p_v;
+ return v->aspect();
}
-void GDAPI godot_vector2_linear_interpolate(godot_vector2 *p_dest,
- const godot_vector2 *p_src,
- const godot_vector2 *p_b,
+godot_vector2 GDAPI godot_vector2_linear_interpolate(
+ const godot_vector2 *p_v,
+ const godot_vector2 p_b,
godot_real t) {
- Vector2 *dest = (Vector2 *)p_dest;
- const Vector2 *src = (Vector2 *)p_src;
- const Vector2 *b = (Vector2 *)p_b;
- *dest = src->linear_interpolate(*b, t);
-}
-
-void GDAPI godot_vector2_reflect(godot_vector2 *p_dest,
- const godot_vector2 *p_src,
- const godot_vector2 *p_vec) {
- const Vector2 *src = (Vector2 *)p_src;
- const Vector2 *vec = (Vector2 *)p_vec;
- Vector2 *dest = (Vector2 *)p_dest;
- *dest = src->reflect(*vec);
-}
-
-void GDAPI godot_vector2_rotated(godot_vector2 *p_dest,
- const godot_vector2 *p_src, godot_real phi) {
- const Vector2 *src = (Vector2 *)p_src;
- Vector2 *dest = (Vector2 *)p_dest;
- *dest = src->rotated(phi);
-}
-
-void GDAPI godot_vector2_slide(godot_vector2 *p_dest,
- const godot_vector2 *p_src,
- godot_vector2 *p_vec) {
- const Vector2 *src = (Vector2 *)p_src;
- const Vector2 *vec = (Vector2 *)p_vec;
- Vector2 *dest = (Vector2 *)p_dest;
- *dest = src->slide(*vec);
-}
-
-void GDAPI godot_vector2_snapped(godot_vector2 *p_dest,
- const godot_vector2 *p_src,
- godot_vector2 *p_by) {
- const Vector2 *src = (Vector2 *)p_src;
- const Vector2 *by = (Vector2 *)p_by;
- Vector2 *dest = (Vector2 *)p_dest;
- *dest = src->snapped(*by);
-}
-
-void GDAPI godot_vector2_tangent(godot_vector2 *p_dest,
- const godot_vector2 *p_src) {
- const Vector2 *src = (Vector2 *)p_src;
- Vector2 *dest = (Vector2 *)p_dest;
- *dest = src->tangent();
-}
-
-void GDAPI godot_vector2_to_string(godot_string *p_dest,
- const godot_vector2 *p_src) {
- const Vector2 *src = (Vector2 *)p_src;
- String *dest = (String *)p_dest;
- *dest = "(" + *src + ")";
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ const Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *b = (Vector2 *)&p_b;
+ *d = v->linear_interpolate(*b, t);
+ return dest;
+}
+
+godot_vector2 GDAPI godot_vector2_reflect(const godot_vector2 *p_v, const godot_vector2 p_vec) {
+ const Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *vec = (Vector2 *)&p_vec;
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ *d = v->reflect(*vec);
+ return dest;
+}
+
+godot_vector2 GDAPI godot_vector2_rotated(const godot_vector2 *p_v, godot_real phi) {
+ const Vector2 *v = (Vector2 *)p_v;
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ *d = v->rotated(phi);
+ return dest;
+}
+
+godot_vector2 GDAPI godot_vector2_slide(const godot_vector2 *p_v, godot_vector2 p_vec) {
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ const Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *vec = (Vector2 *)&p_vec;
+ *d = v->slide(*vec);
+ return dest;
+}
+
+godot_vector2 GDAPI godot_vector2_snapped(const godot_vector2 *p_v, godot_vector2 p_by) {
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ const Vector2 *v = (Vector2 *)p_v;
+ const Vector2 *by = (Vector2 *)&p_by;
+ *d = v->snapped(*by);
+ return dest;
+}
+
+godot_vector2 GDAPI godot_vector2_tangent(const godot_vector2 *p_v) {
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ const Vector2 *v = (Vector2 *)p_v;
+ *d = v->tangent();
+ return dest;
+}
+
+godot_string GDAPI godot_vector2_to_string(const godot_vector2 *p_v) {
+ godot_string dest;
+ String *d = (String *)&dest;
+ const Vector2 *v = (Vector2 *)p_v;
+ *d = "(" + *v + ")";
+ return dest;
}
#ifdef __cplusplus
diff --git a/modules/gdnative/godot/godot_vector2.h b/modules/gdnative/godot/godot_vector2.h
index 4d957d4c7f..36a4f01d03 100644
--- a/modules/gdnative/godot/godot_vector2.h
+++ b/modules/gdnative/godot/godot_vector2.h
@@ -45,7 +45,7 @@ typedef struct godot_vector2 {
#include "../godot.h"
-void GDAPI godot_vector2_new(godot_vector2 *p_v, const godot_real p_x, const godot_real p_y);
+godot_vector2 GDAPI godot_vector2_new(const godot_real p_x, const godot_real p_y);
void GDAPI godot_vector2_set_x(godot_vector2 *p_v, const godot_real p_x);
void GDAPI godot_vector2_set_y(godot_vector2 *p_v, const godot_real p_y);
@@ -53,43 +53,43 @@ godot_real GDAPI godot_vector2_get_x(const godot_vector2 *p_v);
godot_real GDAPI godot_vector2_get_y(const godot_vector2 *p_v);
void GDAPI godot_vector2_normalize(godot_vector2 *p_v);
-void GDAPI godot_vector2_normalized(godot_vector2 *p_dest, const godot_vector2 *p_src);
+godot_vector2 GDAPI godot_vector2_normalized(const godot_vector2 *p_v);
godot_real GDAPI godot_vector2_length(const godot_vector2 *p_v);
godot_real GDAPI godot_vector2_length_squared(const godot_vector2 *p_v);
-godot_real GDAPI godot_vector2_distance_to(const godot_vector2 *p_a, const godot_vector2 *p_b);
-godot_real GDAPI godot_vector2_distance_squared_to(const godot_vector2 *p_a, const godot_vector2 *p_b);
+godot_real GDAPI godot_vector2_distance_to(const godot_vector2 *p_v, const godot_vector2 p_b);
+godot_real GDAPI godot_vector2_distance_squared_to(const godot_vector2 *p_v, const godot_vector2 p_b);
-void GDAPI godot_vector2_abs(godot_vector2 *p_dest, const godot_vector2 *p_src);
-godot_real GDAPI godot_vector2_angle(const godot_vector2 *p_src);
-godot_real GDAPI godot_vector2_angle_to(const godot_vector2 *p_src, const godot_vector2 *p_to);
-godot_real GDAPI godot_vector2_angle_to_point(const godot_vector2 *p_src, const godot_vector2 *p_to);
-void GDAPI godot_vector2_clamped(godot_vector2 *p_dest, const godot_vector2 *p_src, godot_real length);
-void GDAPI godot_vector2_cubic_interpolate(godot_vector2 *p_dest, const godot_vector2 *p_src,
- const godot_vector2 *p_b, const godot_vector2 *p_pre_a,
- const godot_vector2 *p_post_b, godot_real t);
-godot_real GDAPI godot_vector2_dot(const godot_vector2 *p_src, const godot_vector2 *p_with);
-void GDAPI godot_vector2_floor(godot_vector2 *p_dest, const godot_vector2 *p_src);
-godot_real GDAPI godot_vector2_aspect(const godot_vector2 *p_src);
-void GDAPI godot_vector2_linear_interpolate(godot_vector2 *p_dest, const godot_vector2 *p_src,
- const godot_vector2 *p_b, godot_real t);
-void GDAPI godot_vector2_reflect(godot_vector2 *p_dest, const godot_vector2 *p_src, const godot_vector2 *p_vec);
-void GDAPI godot_vector2_rotated(godot_vector2 *p_dest, const godot_vector2 *p_src, godot_real phi);
-void GDAPI godot_vector2_slide(godot_vector2 *p_dest, const godot_vector2 *p_src, godot_vector2 *p_vec);
-void GDAPI godot_vector2_snapped(godot_vector2 *p_dest, const godot_vector2 *p_src, godot_vector2 *p_by);
-void GDAPI godot_vector2_tangent(godot_vector2 *p_dest, const godot_vector2 *p_src);
-void GDAPI godot_vector2_to_string(godot_string *p_dest, const godot_vector2 *p_src);
+godot_vector2 GDAPI godot_vector2_abs(const godot_vector2 *p_v);
+godot_real GDAPI godot_vector2_angle(const godot_vector2 *p_v);
+godot_real GDAPI godot_vector2_angle_to(const godot_vector2 *p_v, const godot_vector2 p_to);
+godot_real GDAPI godot_vector2_angle_to_point(const godot_vector2 *p_v, const godot_vector2 p_to);
+godot_vector2 GDAPI godot_vector2_clamped(const godot_vector2 *p_v, godot_real length);
+godot_vector2 GDAPI godot_vector2_cubic_interpolate(const godot_vector2 *p_v,
+ const godot_vector2 p_b, const godot_vector2 p_pre_a,
+ const godot_vector2 p_post_b, godot_real t);
+godot_real GDAPI godot_vector2_dot(const godot_vector2 *p_v, const godot_vector2 p_with);
+godot_vector2 GDAPI godot_vector2_floor(const godot_vector2 *p_v);
+godot_real GDAPI godot_vector2_aspect(const godot_vector2 *p_v);
+godot_vector2 GDAPI godot_vector2_linear_interpolate(const godot_vector2 *p_v,
+ const godot_vector2 p_b, godot_real t);
+godot_vector2 GDAPI godot_vector2_reflect(const godot_vector2 *p_v, const godot_vector2 p_vec);
+godot_vector2 GDAPI godot_vector2_rotated(const godot_vector2 *p_v, godot_real phi);
+godot_vector2 GDAPI godot_vector2_slide(const godot_vector2 *p_v, godot_vector2 p_vec);
+godot_vector2 GDAPI godot_vector2_snapped(const godot_vector2 *p_v, godot_vector2 p_by);
+godot_vector2 GDAPI godot_vector2_tangent(const godot_vector2 *p_v);
+godot_string GDAPI godot_vector2_to_string(const godot_vector2 *p_v);
-void GDAPI godot_vector2_operator_add(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_vector2 *p_b);
-void GDAPI godot_vector2_operator_subtract(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_vector2 *p_b);
-void GDAPI godot_vector2_operator_multiply_vector(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_vector2 *p_b);
-void GDAPI godot_vector2_operator_multiply_scalar(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_real p_b);
-void GDAPI godot_vector2_operator_divide_vector(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_vector2 *p_b);
-void GDAPI godot_vector2_operator_divide_scalar(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_real p_b);
+godot_vector2 GDAPI godot_vector2_operator_add(const godot_vector2 *p_v, const godot_vector2 p_b);
+godot_vector2 GDAPI godot_vector2_operator_subtract(const godot_vector2 *p_v, const godot_vector2 p_b);
+godot_vector2 GDAPI godot_vector2_operator_multiply_vector(const godot_vector2 *p_v, const godot_vector2 p_b);
+godot_vector2 GDAPI godot_vector2_operator_multiply_scalar(const godot_vector2 *p_v, const godot_real p_b);
+godot_vector2 GDAPI godot_vector2_operator_divide_vector(const godot_vector2 *p_v, const godot_vector2 p_b);
+godot_vector2 GDAPI godot_vector2_operator_divide_scalar(const godot_vector2 *p_v, const godot_real p_b);
-godot_bool GDAPI godot_vector2_operator_equal(const godot_vector2 *p_a, const godot_vector2 *p_b);
-godot_bool GDAPI godot_vector2_operator_less(const godot_vector2 *p_a, const godot_vector2 *p_b);
+godot_bool GDAPI godot_vector2_operator_equal(const godot_vector2 *p_v, const godot_vector2 p_b);
+godot_bool GDAPI godot_vector2_operator_less(const godot_vector2 *p_v, const godot_vector2 p_b);
#ifdef __cplusplus
}
diff --git a/modules/gdnative/godot/godot_vector3.cpp b/modules/gdnative/godot/godot_vector3.cpp
index 41d1c1abf5..5f71b9f7e4 100644
--- a/modules/gdnative/godot/godot_vector3.cpp
+++ b/modules/gdnative/godot/godot_vector3.cpp
@@ -38,9 +38,11 @@ extern "C" {
void _vector3_api_anchor() {
}
-void GDAPI godot_vector3_new(godot_vector3 *p_v, const godot_real p_x, const godot_real p_y, const godot_real p_z) {
- Vector3 *v = (Vector3 *)p_v;
+godot_vector3 GDAPI godot_vector3_new(const godot_real p_x, const godot_real p_y, const godot_real p_z) {
+ godot_vector3 value;
+ Vector3 *v = (Vector3 *)&value;
*v = Vector3(p_x, p_y, p_z);
+ return value;
}
void GDAPI godot_vector3_set_axis(godot_vector3 *p_v, const godot_int p_axis, const godot_real p_val) {
@@ -78,217 +80,261 @@ void GDAPI godot_vector3_normalize(godot_vector3 *p_v) {
v->normalize();
}
-void GDAPI godot_vector3_normalized(godot_vector3 *p_dest, const godot_vector3 *p_src) {
- Vector3 *src = (Vector3 *)p_src;
- Vector3 *dest = (Vector3 *)p_dest;
- *dest = src->normalized();
-}
-
-void godot_vector3_inverse(godot_vector3 *p_dest, const godot_vector3 *p_src) {
- Vector3 *dest = (Vector3 *)p_dest;
- const Vector3 *src = (Vector3 *)p_src;
- *dest = src->inverse();
-}
-
-void godot_vector3_zero(godot_vector3 *p_src) {
- Vector3 *src = (Vector3 *)p_src;
- src->zero();
-}
-
-void godot_vector3_snap(godot_vector3 *p_src, godot_real val) {
- Vector3 *src = (Vector3 *)p_src;
- src->snap(val);
-}
-
-void godot_vector3_snapped(godot_vector3 *p_dest, const godot_vector3 *p_src, godot_real val) {
- Vector3 *dest = (Vector3 *)p_dest;
- const Vector3 *src = (Vector3 *)p_src;
- *dest = src->snapped(val);
-}
-
-void godot_vector3_rotate(godot_vector3 *p_src, const godot_vector3 *p_axis, godot_real phi) {
- Vector3 *src = (Vector3 *)p_src;
- const Vector3 *axis = (Vector3 *)p_axis;
- src->rotate(*axis, phi);
-}
-
-void godot_vector3_rotated(godot_vector3 *p_dest, const godot_vector3 *p_src,
- const godot_vector3 *p_axis, godot_real phi) {
- Vector3 *dest = (Vector3 *)p_dest;
- const Vector3 *src = (Vector3 *)p_src;
- const Vector3 *axis = (Vector3 *)p_axis;
- *dest = src->rotated(*axis, phi);
-}
-
-void godot_vector3_linear_interpolate(godot_vector3 *p_dest, const godot_vector3 *p_src,
- const godot_vector3 *p_b, godot_real t) {
- Vector3 *dest = (Vector3 *)p_dest;
- const Vector3 *src = (Vector3 *)p_src;
- const Vector3 *b = (Vector3 *)p_b;
- *dest = src->linear_interpolate(*b, t);
-}
-
-void godot_vector3_cubic_interpolate(godot_vector3 *p_dest, const godot_vector3 *p_src,
- const godot_vector3 *p_b, const godot_vector3 *p_pre_a,
- const godot_vector3 *p_post_b, godot_real t) {
- Vector3 *dest = (Vector3 *)p_dest;
- const Vector3 *src = (Vector3 *)p_src;
- const Vector3 *b = (Vector3 *)p_b;
- const Vector3 *pre_a = (Vector3 *)p_pre_a;
- const Vector3 *post_b = (Vector3 *)p_post_b;
- *dest = src->cubic_interpolate(*b, *pre_a, *post_b, t);
-}
-
-void godot_vector3_cubic_interpolaten(godot_vector3 *p_dest, const godot_vector3 *p_src,
- const godot_vector3 *p_b, const godot_vector3 *p_pre_a,
- const godot_vector3 *p_post_b, godot_real t) {
- Vector3 *dest = (Vector3 *)p_dest;
- const Vector3 *src = (Vector3 *)p_src;
- const Vector3 *b = (Vector3 *)p_b;
- const Vector3 *pre_a = (Vector3 *)p_pre_a;
- const Vector3 *post_b = (Vector3 *)p_post_b;
- *dest = src->cubic_interpolaten(*b, *pre_a, *post_b, t);
-}
-
-void godot_vector3_cross(godot_vector3 *p_dest, const godot_vector3 *p_src, const godot_vector3 *p_b) {
- Vector3 *dest = (Vector3 *)p_dest;
- const Vector3 *src = (Vector3 *)p_src;
- const Vector3 *b = (Vector3 *)p_b;
- *dest = src->cross(*b);
-}
-
-godot_real godot_vector3_dot(const godot_vector3 *p_src, const godot_vector3 *p_b) {
- const Vector3 *src = (Vector3 *)p_src;
- const Vector3 *b = (Vector3 *)p_b;
- return src->dot(*b);
-}
-
-void godot_vector3_outer(godot_basis *p_dest, const godot_vector3 *p_src, const godot_vector3 *p_b) {
- Basis *dest = (Basis *)p_dest;
- const Vector3 *src = (Vector3 *)p_src;
- const Vector3 *b = (Vector3 *)p_b;
- *dest = src->outer(*b);
+godot_vector3 GDAPI godot_vector3_normalized(const godot_vector3 *p_v) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ Vector3 *v = (Vector3 *)p_v;
+ *d = v->normalized();
+ return dest;
}
-void godot_vector3_to_diagonal_matrix(godot_basis *p_dest, const godot_vector3 *p_src) {
- Basis *dest = (Basis *)p_dest;
- const Vector3 *src = (Vector3 *)p_src;
- *dest = src->to_diagonal_matrix();
+godot_vector3 godot_vector3_inverse(const godot_vector3 *p_v) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Vector3 *v = (Vector3 *)p_v;
+ *d = v->inverse();
+ return dest;
}
-void godot_vector3_abs(godot_vector3 *p_dest, const godot_vector3 *p_src) {
- Vector3 *dest = (Vector3 *)p_dest;
- const Vector3 *src = (Vector3 *)p_src;
- *dest = src->abs();
+void godot_vector3_zero(godot_vector3 *p_v) {
+ Vector3 *v = (Vector3 *)p_v;
+ v->zero();
}
-void godot_vector3_floor(godot_vector3 *p_dest, const godot_vector3 *p_src) {
- Vector3 *dest = (Vector3 *)p_dest;
- const Vector3 *src = (Vector3 *)p_src;
- *dest = src->floor();
+void godot_vector3_snap(godot_vector3 *p_v, const godot_real val) {
+ Vector3 *v = (Vector3 *)p_v;
+ v->snap(val);
}
-void godot_vector3_ceil(godot_vector3 *p_dest, const godot_vector3 *p_src) {
- const Vector3 *src = (Vector3 *)p_src;
- Vector3 *dest = (Vector3 *)p_dest;
- *dest = src->ceil();
+godot_vector3 godot_vector3_snapped(const godot_vector3 *p_v, const godot_real val) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Vector3 *v = (Vector3 *)p_v;
+ *d = v->snapped(val);
+ return dest;
}
-godot_real GDAPI godot_vector3_distance_to(const godot_vector3 *p_a, const godot_vector3 *p_b) {
- Vector3 *a = (Vector3 *)p_a;
- Vector3 *b = (Vector3 *)p_b;
- return a->distance_to(*b);
+void godot_vector3_rotate(godot_vector3 *p_v, const godot_vector3 p_axis, const godot_real phi) {
+ Vector3 *v = (Vector3 *)p_v;
+ const Vector3 *axis = (Vector3 *)&p_axis;
+ v->rotate(*axis, phi);
+}
+
+godot_vector3 godot_vector3_rotated(const godot_vector3 *p_v, const godot_vector3 p_axis, const godot_real phi) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Vector3 *v = (Vector3 *)p_v;
+ const Vector3 *axis = (Vector3 *)&p_axis;
+ *d = v->rotated(*axis, phi);
+ return dest;
+}
+
+godot_vector3 godot_vector3_linear_interpolate(const godot_vector3 *p_v, const godot_vector3 p_b, const godot_real t) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Vector3 *v = (Vector3 *)p_v;
+ const Vector3 *b = (Vector3 *)&p_b;
+ *d = v->linear_interpolate(*b, t);
+ return dest;
+}
+
+godot_vector3 godot_vector3_cubic_interpolate(const godot_vector3 *p_v,
+ const godot_vector3 p_b, const godot_vector3 p_pre_a,
+ const godot_vector3 p_post_b, const godot_real t) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Vector3 *v = (Vector3 *)p_v;
+ const Vector3 *b = (Vector3 *)&p_b;
+ const Vector3 *pre_a = (Vector3 *)&p_pre_a;
+ const Vector3 *post_b = (Vector3 *)&p_post_b;
+ *d = v->cubic_interpolate(*b, *pre_a, *post_b, t);
+ return dest;
+}
+
+godot_vector3 godot_vector3_cubic_interpolaten(const godot_vector3 *p_v,
+ const godot_vector3 p_b, const godot_vector3 p_pre_a,
+ const godot_vector3 p_post_b, const godot_real t) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Vector3 *v = (Vector3 *)p_v;
+ const Vector3 *b = (Vector3 *)&p_b;
+ const Vector3 *pre_a = (Vector3 *)&p_pre_a;
+ const Vector3 *post_b = (Vector3 *)&p_post_b;
+ *d = v->cubic_interpolaten(*b, *pre_a, *post_b, t);
+ return dest;
+}
+
+godot_vector3 godot_vector3_cross(const godot_vector3 *p_v, const godot_vector3 p_b) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Vector3 *v = (Vector3 *)p_v;
+ const Vector3 *b = (Vector3 *)&p_b;
+ *d = v->cross(*b);
+ return dest;
+}
+
+godot_real godot_vector3_dot(const godot_vector3 *p_v, const godot_vector3 p_b) {
+ const Vector3 *v = (Vector3 *)p_v;
+ const Vector3 *b = (Vector3 *)&p_b;
+ return v->dot(*b);
+}
+
+godot_basis godot_vector3_outer(const godot_vector3 *p_v, const godot_vector3 p_b) {
+ godot_basis dest;
+ Basis *d = (Basis *)&dest;
+ const Vector3 *v = (Vector3 *)p_v;
+ const Vector3 *b = (Vector3 *)&p_b;
+ *d = v->outer(*b);
+ return dest;
+}
+
+godot_basis godot_vector3_to_diagonal_matrix(const godot_vector3 *p_v) {
+ godot_basis dest;
+ Basis *d = (Basis *)&dest;
+ const Vector3 *v = (Vector3 *)p_v;
+ *d = v->to_diagonal_matrix();
+ return dest;
+}
+
+godot_vector3 godot_vector3_abs(const godot_vector3 *p_v) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Vector3 *v = (Vector3 *)p_v;
+ *d = v->abs();
+ return dest;
+}
+
+godot_vector3 godot_vector3_floor(const godot_vector3 *p_v) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Vector3 *v = (Vector3 *)p_v;
+ *d = v->floor();
+ return dest;
+}
+
+godot_vector3 godot_vector3_ceil(const godot_vector3 *p_v) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Vector3 *v = (Vector3 *)p_v;
+ *d = v->ceil();
+ return dest;
+}
+
+godot_real GDAPI godot_vector3_distance_to(const godot_vector3 *p_v, const godot_vector3 p_b) {
+ Vector3 *v = (Vector3 *)p_v;
+ Vector3 *b = (Vector3 *)&p_b;
+ return v->distance_to(*b);
}
-godot_real GDAPI godot_vector3_distance_squared_to(const godot_vector3 *p_a, const godot_vector3 *p_b) {
- Vector3 *a = (Vector3 *)p_a;
- Vector3 *b = (Vector3 *)p_b;
- return a->distance_squared_to(*b);
+godot_real GDAPI godot_vector3_distance_squared_to(const godot_vector3 *p_v, const godot_vector3 p_b) {
+ Vector3 *v = (Vector3 *)p_v;
+ Vector3 *b = (Vector3 *)&p_b;
+ return v->distance_squared_to(*b);
}
-godot_real GDAPI godot_vector3_angle_to(const godot_vector3 *p_a, const godot_vector3 *p_b) {
- Vector3 *a = (Vector3 *)p_a;
- Vector3 *b = (Vector3 *)p_b;
- return a->angle_to(*b);
+godot_real GDAPI godot_vector3_angle_to(const godot_vector3 *p_v, const godot_vector3 p_b) {
+ Vector3 *v = (Vector3 *)p_v;
+ Vector3 *b = (Vector3 *)&p_b;
+ return v->angle_to(*b);
}
-void godot_vector3_slide(godot_vector3 *p_dest, const godot_vector3 *p_src, const godot_vector3 *p_vec) {
- const Vector3 *src = (Vector3 *)p_src;
- const Vector3 *vec = (Vector3 *)p_vec;
- Vector3 *dest = (Vector3 *)p_dest;
- *dest = src->slide(*vec);
+godot_vector3 godot_vector3_slide(const godot_vector3 *p_v, const godot_vector3 p_vec) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Vector3 *v = (Vector3 *)p_v;
+ const Vector3 *vec = (Vector3 *)&p_vec;
+ *d = v->slide(*vec);
+ return dest;
}
-void godot_vector3_bounce(godot_vector3 *p_dest, const godot_vector3 *p_src, const godot_vector3 *p_vec) {
- const Vector3 *src = (Vector3 *)p_src;
- const Vector3 *vec = (Vector3 *)p_vec;
- Vector3 *dest = (Vector3 *)p_dest;
- *dest = src->bounce(*vec);
+godot_vector3 godot_vector3_bounce(const godot_vector3 *p_v, const godot_vector3 p_vec) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Vector3 *v = (Vector3 *)p_v;
+ const Vector3 *vec = (Vector3 *)&p_vec;
+ *d = v->bounce(*vec);
+ return dest;
}
-void godot_vector3_reflect(godot_vector3 *p_dest, const godot_vector3 *p_src, const godot_vector3 *p_vec) {
- const Vector3 *src = (Vector3 *)p_src;
- const Vector3 *vec = (Vector3 *)p_vec;
- Vector3 *dest = (Vector3 *)p_dest;
- *dest = src->reflect(*vec);
+godot_vector3 godot_vector3_reflect(const godot_vector3 *p_v, const godot_vector3 p_vec) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ const Vector3 *v = (Vector3 *)p_v;
+ const Vector3 *vec = (Vector3 *)&p_vec;
+ *d = v->reflect(*vec);
+ return dest;
}
-void GDAPI godot_vector3_operator_add(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_vector3 *p_b) {
- Vector3 *dest = (Vector3 *)p_dest;
- Vector3 *a = (Vector3 *)p_a;
- Vector3 *b = (Vector3 *)p_b;
- *dest = *a + *b;
+godot_vector3 GDAPI godot_vector3_operator_add(const godot_vector3 *p_v, const godot_vector3 p_b) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ Vector3 *v = (Vector3 *)p_v;
+ Vector3 *b = (Vector3 *)&p_b;
+ *d = *v + *b;
+ return dest;
}
-void GDAPI godot_vector3_operator_subtract(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_vector3 *p_b) {
- Vector3 *dest = (Vector3 *)p_dest;
- Vector3 *a = (Vector3 *)p_a;
- Vector3 *b = (Vector3 *)p_b;
- *dest = *a - *b;
+godot_vector3 GDAPI godot_vector3_operator_subtract(const godot_vector3 *p_v, const godot_vector3 p_b) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ Vector3 *v = (Vector3 *)p_v;
+ Vector3 *b = (Vector3 *)&p_b;
+ *d = *v - *b;
+ return dest;
}
-void GDAPI godot_vector3_operator_multiply_vector(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_vector3 *p_b) {
- Vector3 *dest = (Vector3 *)p_dest;
- Vector3 *a = (Vector3 *)p_a;
- Vector3 *b = (Vector3 *)p_b;
- *dest = *a * *b;
+godot_vector3 GDAPI godot_vector3_operator_multiply_vector(const godot_vector3 *p_v, const godot_vector3 p_b) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ Vector3 *v = (Vector3 *)p_v;
+ Vector3 *b = (Vector3 *)&p_b;
+ *d = *v * *b;
+ return dest;
}
-void GDAPI godot_vector3_operator_multiply_scalar(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_real p_b) {
- Vector3 *dest = (Vector3 *)p_dest;
- Vector3 *a = (Vector3 *)p_a;
- *dest = *a * p_b;
+godot_vector3 GDAPI godot_vector3_operator_multiply_scalar(const godot_vector3 *p_v, const godot_real p_b) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ Vector3 *v = (Vector3 *)p_v;
+ *d = *v * p_b;
+ return dest;
}
-void GDAPI godot_vector3_operator_divide_vector(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_vector3 *p_b) {
- Vector3 *dest = (Vector3 *)p_dest;
- Vector3 *a = (Vector3 *)p_a;
- Vector3 *b = (Vector3 *)p_b;
- *dest = *a / *b;
+godot_vector3 GDAPI godot_vector3_operator_divide_vector(const godot_vector3 *p_v, const godot_vector3 p_b) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ Vector3 *v = (Vector3 *)p_v;
+ Vector3 *b = (Vector3 *)&p_b;
+ *d = *v / *b;
+ return dest;
}
-void GDAPI godot_vector3_operator_divide_scalar(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_real p_b) {
- Vector3 *dest = (Vector3 *)p_dest;
- Vector3 *a = (Vector3 *)p_a;
- *dest = *a / p_b;
+godot_vector3 GDAPI godot_vector3_operator_divide_scalar(const godot_vector3 *p_v, const godot_real p_b) {
+ godot_vector3 dest;
+ Vector3 *d = (Vector3 *)&dest;
+ Vector3 *v = (Vector3 *)p_v;
+ *d = *v / p_b;
+ return dest;
}
-godot_bool GDAPI godot_vector3_operator_equal(const godot_vector3 *p_a, const godot_vector3 *p_b) {
- Vector3 *a = (Vector3 *)p_a;
- Vector3 *b = (Vector3 *)p_b;
- return *a == *b;
+godot_bool GDAPI godot_vector3_operator_equal(const godot_vector3 *p_v, const godot_vector3 p_b) {
+ Vector3 *v = (Vector3 *)p_v;
+ Vector3 *b = (Vector3 *)&p_b;
+ return *v == *b;
}
-godot_bool GDAPI godot_vector3_operator_less(const godot_vector3 *p_a, const godot_vector3 *p_b) {
- Vector3 *a = (Vector3 *)p_a;
- Vector3 *b = (Vector3 *)p_b;
- return *a < *b;
+godot_bool GDAPI godot_vector3_operator_less(const godot_vector3 *p_v, const godot_vector3 p_b) {
+ Vector3 *v = (Vector3 *)p_v;
+ Vector3 *b = (Vector3 *)&p_b;
+ return *v < *b;
}
-void GDAPI godot_vector3_to_string(godot_string *p_dest, const godot_vector3 *p_src) {
- const Vector3 *src = (Vector3 *)p_src;
- String *dest = (String *)p_dest;
- *dest = "(" + *src + ")";
+godot_string GDAPI godot_vector3_to_string(const godot_vector3 *p_v) {
+ godot_string dest;
+ String *d = (String *)&dest;
+ const Vector3 *v = (Vector3 *)p_v;
+ *d = "(" + *v + ")";
+ return dest;
}
#ifdef __cplusplus
diff --git a/modules/gdnative/godot/godot_vector3.h b/modules/gdnative/godot/godot_vector3.h
index bc141bcfec..654ddd7792 100644
--- a/modules/gdnative/godot/godot_vector3.h
+++ b/modules/gdnative/godot/godot_vector3.h
@@ -49,7 +49,7 @@ typedef struct godot_vector3 {
#include "../godot.h"
#include "godot_basis.h"
-void GDAPI godot_vector3_new(godot_vector3 *p_v, const godot_real p_x, const godot_real p_y, const godot_real p_z);
+godot_vector3 GDAPI godot_vector3_new(const godot_real p_x, const godot_real p_y, const godot_real p_z);
void GDAPI godot_vector3_set_axis(godot_vector3 *p_v, const godot_int p_axis, const godot_real p_val);
godot_real GDAPI godot_vector3_get_axis(const godot_vector3 *p_v, const godot_int p_axis);
@@ -61,50 +61,50 @@ godot_real GDAPI godot_vector3_length(const godot_vector3 *p_v);
godot_real GDAPI godot_vector3_length_squared(const godot_vector3 *p_v);
void GDAPI godot_vector3_normalize(godot_vector3 *p_v);
-void GDAPI godot_vector3_normalized(godot_vector3 *p_dest, const godot_vector3 *p_src);
-
-void GDAPI godot_vector3_inverse(godot_vector3 *p_dest, const godot_vector3 *p_src);
-void GDAPI godot_vector3_zero(godot_vector3 *p_src);
-void GDAPI godot_vector3_snap(godot_vector3 *p_src, godot_real val);
-void GDAPI godot_vector3_snapped(godot_vector3 *p_dest, const godot_vector3 *p_src, godot_real val);
-void GDAPI godot_vector3_rotate(godot_vector3 *p_src, const godot_vector3 *p_axis, godot_real phi);
-void GDAPI godot_vector3_rotated(godot_vector3 *p_dest, const godot_vector3 *p_src,
- const godot_vector3 *p_axis, godot_real phi);
-void GDAPI godot_vector3_linear_interpolate(godot_vector3 *p_dest, const godot_vector3 *p_src,
- const godot_vector3 *p_b, godot_real t);
-void GDAPI godot_vector3_cubic_interpolate(godot_vector3 *p_dest, const godot_vector3 *p_src,
- const godot_vector3 *p_b, const godot_vector3 *p_pre_a,
- const godot_vector3 *p_post_b, godot_real t);
-void GDAPI godot_vector3_cubic_interpolaten(godot_vector3 *p_dest, const godot_vector3 *p_src,
- const godot_vector3 *p_b, const godot_vector3 *p_pre_a,
- const godot_vector3 *p_post_b, godot_real t);
-void GDAPI godot_vector3_cross(godot_vector3 *p_dest, const godot_vector3 *p_src, const godot_vector3 *p_b);
-godot_real GDAPI godot_vector3_dot(const godot_vector3 *p_src, const godot_vector3 *p_b);
-void GDAPI godot_vector3_outer(godot_basis *dest, const godot_vector3 *p_src, const godot_vector3 *p_b);
-void GDAPI godot_vector3_to_diagonal_matrix(godot_basis *dest, const godot_vector3 *p_src);
-void GDAPI godot_vector3_abs(godot_vector3 *p_dest, const godot_vector3 *p_src);
-void GDAPI godot_vector3_floor(godot_vector3 *p_dest, const godot_vector3 *p_src);
-void GDAPI godot_vector3_ceil(godot_vector3 *p_dest, const godot_vector3 *p_src);
-
-godot_real GDAPI godot_vector3_distance_to(const godot_vector3 *p_a, const godot_vector3 *p_b);
-godot_real GDAPI godot_vector3_distance_squared_to(const godot_vector3 *p_a, const godot_vector3 *p_b);
-godot_real GDAPI godot_vector3_angle_to(const godot_vector3 *p_a, const godot_vector3 *p_b);
-
-void GDAPI godot_vector3_slide(godot_vector3 *p_dest, const godot_vector3 *p_src, const godot_vector3 *p_vec);
-void GDAPI godot_vector3_bounce(godot_vector3 *p_dest, const godot_vector3 *p_src, const godot_vector3 *p_vec);
-void GDAPI godot_vector3_reflect(godot_vector3 *p_dest, const godot_vector3 *p_src, const godot_vector3 *p_vec);
-
-void GDAPI godot_vector3_operator_add(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_vector3 *p_b);
-void GDAPI godot_vector3_operator_subtract(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_vector3 *p_b);
-void GDAPI godot_vector3_operator_multiply_vector(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_vector3 *p_b);
-void GDAPI godot_vector3_operator_multiply_scalar(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_real p_b);
-void GDAPI godot_vector3_operator_divide_vector(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_vector3 *p_b);
-void GDAPI godot_vector3_operator_divide_scalar(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_real p_b);
-
-godot_bool GDAPI godot_vector3_operator_equal(const godot_vector3 *p_a, const godot_vector3 *p_b);
-godot_bool GDAPI godot_vector3_operator_less(const godot_vector3 *p_a, const godot_vector3 *p_b);
-
-void GDAPI godot_vector3_to_string(godot_string *p_dest, const godot_vector3 *p_src);
+godot_vector3 GDAPI godot_vector3_normalized(const godot_vector3 *p_v);
+
+godot_vector3 GDAPI godot_vector3_inverse(const godot_vector3 *p_v);
+void GDAPI godot_vector3_zero(godot_vector3 *p_v);
+void GDAPI godot_vector3_snap(godot_vector3 *p_v, const godot_real val);
+godot_vector3 GDAPI godot_vector3_snapped(const godot_vector3 *p_v, const godot_real val);
+void GDAPI godot_vector3_rotate(godot_vector3 *p_v, const godot_vector3 p_axis, const godot_real phi);
+godot_vector3 GDAPI godot_vector3_rotated(const godot_vector3 *p_v,
+ const godot_vector3 p_axis, const godot_real phi);
+godot_vector3 GDAPI godot_vector3_linear_interpolate(const godot_vector3 *p_v,
+ const godot_vector3 p_b, const godot_real t);
+godot_vector3 GDAPI godot_vector3_cubic_interpolate(const godot_vector3 *p_v,
+ const godot_vector3 p_b, const godot_vector3 p_pre_a,
+ const godot_vector3 p_post_b, const godot_real t);
+godot_vector3 GDAPI godot_vector3_cubic_interpolaten(const godot_vector3 *p_v,
+ const godot_vector3 p_b, const godot_vector3 p_pre_a,
+ const godot_vector3 p_post_b, const godot_real t);
+godot_vector3 GDAPI godot_vector3_cross(const godot_vector3 *p_v, const godot_vector3 p_b);
+godot_real GDAPI godot_vector3_dot(const godot_vector3 *p_v, const godot_vector3 p_b);
+godot_basis GDAPI godot_vector3_outer(const godot_vector3 *p_v, const godot_vector3 p_b);
+godot_basis GDAPI godot_vector3_to_diagonal_matrix(const godot_vector3 *p_v);
+godot_vector3 GDAPI godot_vector3_abs(const godot_vector3 *p_v);
+godot_vector3 GDAPI godot_vector3_floor(const godot_vector3 *p_v);
+godot_vector3 GDAPI godot_vector3_ceil(const godot_vector3 *p_v);
+
+godot_real GDAPI godot_vector3_distance_to(const godot_vector3 *p_v, const godot_vector3 p_b);
+godot_real GDAPI godot_vector3_distance_squared_to(const godot_vector3 *p_v, const godot_vector3 p_b);
+godot_real GDAPI godot_vector3_angle_to(const godot_vector3 *p_v, const godot_vector3 p_b);
+
+godot_vector3 GDAPI godot_vector3_slide(const godot_vector3 *p_v, const godot_vector3 p_vec);
+godot_vector3 GDAPI godot_vector3_bounce(const godot_vector3 *p_v, const godot_vector3 p_vec);
+godot_vector3 GDAPI godot_vector3_reflect(const godot_vector3 *p_v, const godot_vector3 p_vec);
+
+godot_vector3 GDAPI godot_vector3_operator_add(const godot_vector3 *p_v, const godot_vector3 p_b);
+godot_vector3 GDAPI godot_vector3_operator_subtract(const godot_vector3 *p_v, const godot_vector3 p_b);
+godot_vector3 GDAPI godot_vector3_operator_multiply_vector(const godot_vector3 *p_v, const godot_vector3 p_b);
+godot_vector3 GDAPI godot_vector3_operator_multiply_scalar(const godot_vector3 *p_v, const godot_real p_b);
+godot_vector3 GDAPI godot_vector3_operator_divide_vector(const godot_vector3 *p_v, const godot_vector3 p_b);
+godot_vector3 GDAPI godot_vector3_operator_divide_scalar(const godot_vector3 *p_v, const godot_real p_b);
+
+godot_bool GDAPI godot_vector3_operator_equal(const godot_vector3 *p_v, const godot_vector3 p_b);
+godot_bool GDAPI godot_vector3_operator_less(const godot_vector3 *p_v, const godot_vector3 p_b);
+
+godot_string GDAPI godot_vector3_to_string(const godot_vector3 *p_v);
#ifdef __cplusplus
}
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index f50c9074b7..2a3015c185 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#include "editor/editor_settings.h"
#include "gd_compiler.h"
#include "gd_script.h"
#include "global_config.h"
@@ -2415,8 +2416,27 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
#endif
+String GDScriptLanguage::_get_indentation() const {
+#ifdef TOOLS_ENABLED
+ bool use_space_indentation = EDITOR_DEF("text_editor/indent/type", "Tabs") == "Tabs" ? 0 : 1;
+
+ if (use_space_indentation) {
+ int indent_size = EDITOR_DEF("text_editor/indent/size", 4);
+
+ String space_indent = "";
+ for (int i = 0; i < indent_size; i++) {
+ space_indent += " ";
+ }
+ return space_indent;
+ }
+#endif
+ return "\t";
+}
+
void GDScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_to_line) const {
+ String indent = _get_indentation();
+
Vector<String> lines = p_code.split("\n");
List<int> indent_stack;
@@ -2456,8 +2476,9 @@ void GDScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_t
if (i >= p_from_line) {
l = "";
- for (int j = 0; j < indent_stack.size(); j++)
- l += "\t";
+ for (int j = 0; j < indent_stack.size(); j++) {
+ l += indent;
+ }
l += st;
} else if (i > p_to_line) {
diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp
index 2367f60740..fe20a842cf 100644
--- a/modules/gdscript/gd_script.cpp
+++ b/modules/gdscript/gd_script.cpp
@@ -1696,9 +1696,9 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
//same thing for placeholders
#ifdef TOOLS_ENABLED
- while (E->get()->placeholders.size()) {
+ for (Set<PlaceHolderScriptInstance *>::Element *P = E->get()->placeholders.front(); P; P = P->next()) {
- Object *obj = E->get()->placeholders.front()->get()->get_owner();
+ Object *obj = P->get()->get_owner();
//save instance info
List<Pair<StringName, Variant> > state;
if (obj->get_script_instance()) {
diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h
index 93f8ee8721..00ae136790 100644
--- a/modules/gdscript/gd_script.h
+++ b/modules/gdscript/gd_script.h
@@ -384,12 +384,14 @@ public:
virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = NULL) const;
virtual Script *create_script() const;
virtual bool has_named_classes() const;
+ virtual bool can_inherit_from_file() { return true; }
virtual int find_function(const String &p_function, const String &p_code) const;
virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, String &r_call_hint);
#ifdef TOOLS_ENABLED
virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_base_path, Object *p_owner, LookupResult &r_result);
#endif
+ virtual String _get_indentation() const;
virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);
diff --git a/modules/multiscript/SCsub b/modules/multiscript/SCsub
new file mode 100644
index 0000000000..0882406761
--- /dev/null
+++ b/modules/multiscript/SCsub
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+
+Import('env')
+
+env.add_source_files(env.modules_sources, "*.cpp")
+
+Export('env')
diff --git a/modules/multiscript/config.py b/modules/multiscript/config.py
new file mode 100644
index 0000000000..5698a37295
--- /dev/null
+++ b/modules/multiscript/config.py
@@ -0,0 +1,8 @@
+
+
+def can_build(platform):
+ return True
+
+
+def configure(env):
+ pass
diff --git a/modules/multiscript/multiscript.cpp b/modules/multiscript/multiscript.cpp
new file mode 100644
index 0000000000..b2633b7207
--- /dev/null
+++ b/modules/multiscript/multiscript.cpp
@@ -0,0 +1,750 @@
+/*************************************************************************/
+/* multiscript.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "multiscript.h"
+
+bool MultiScriptInstance::set(const StringName &p_name, const Variant &p_value) {
+
+ ScriptInstance **sarr = instances.ptr();
+ int sc = instances.size();
+
+ for (int i = 0; i < sc; i++) {
+
+ if (!sarr[i])
+ continue;
+
+ bool found = sarr[i]->set(p_name, p_value);
+ if (found)
+ return true;
+ }
+
+ if (String(p_name).begins_with("script_")) {
+ bool valid;
+ owner->set(p_name, p_value, &valid);
+ return valid;
+ }
+ return false;
+}
+
+bool MultiScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
+
+ ScriptInstance **sarr = instances.ptr();
+ int sc = instances.size();
+
+ for (int i = 0; i < sc; i++) {
+
+ if (!sarr[i])
+ continue;
+
+ bool found = sarr[i]->get(p_name, r_ret);
+ if (found)
+ return true;
+ }
+ if (String(p_name).begins_with("script_")) {
+ bool valid;
+ r_ret = owner->get(p_name, &valid);
+ return valid;
+ }
+ return false;
+}
+void MultiScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
+
+ ScriptInstance **sarr = instances.ptr();
+ int sc = instances.size();
+
+ Set<String> existing;
+
+ for (int i = 0; i < sc; i++) {
+
+ if (!sarr[i])
+ continue;
+
+ List<PropertyInfo> pl;
+ sarr[i]->get_property_list(&pl);
+
+ for (List<PropertyInfo>::Element *E = pl.front(); E; E = E->next()) {
+
+ if (existing.has(E->get().name))
+ continue;
+
+ p_properties->push_back(E->get());
+ existing.insert(E->get().name);
+ }
+ }
+
+ p_properties->push_back(PropertyInfo(Variant::NIL, "Scripts", PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY));
+
+ for (int i = 0; i < owner->scripts.size(); i++) {
+
+ p_properties->push_back(PropertyInfo(Variant::OBJECT, "script_" + String::chr('a' + i), PROPERTY_HINT_RESOURCE_TYPE, "Script", PROPERTY_USAGE_EDITOR));
+ }
+
+ if (owner->scripts.size() < 25) {
+
+ p_properties->push_back(PropertyInfo(Variant::OBJECT, "script_" + String::chr('a' + (owner->scripts.size())), PROPERTY_HINT_RESOURCE_TYPE, "Script", PROPERTY_USAGE_EDITOR));
+ }
+}
+
+void MultiScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
+
+ ScriptInstance **sarr = instances.ptr();
+ int sc = instances.size();
+
+ Set<StringName> existing;
+
+ for (int i = 0; i < sc; i++) {
+
+ if (!sarr[i])
+ continue;
+
+ List<MethodInfo> ml;
+ sarr[i]->get_method_list(&ml);
+
+ for (List<MethodInfo>::Element *E = ml.front(); E; E = E->next()) {
+
+ if (existing.has(E->get().name))
+ continue;
+
+ p_list->push_back(E->get());
+ existing.insert(E->get().name);
+ }
+ }
+}
+bool MultiScriptInstance::has_method(const StringName &p_method) const {
+
+ ScriptInstance **sarr = instances.ptr();
+ int sc = instances.size();
+
+ for (int i = 0; i < sc; i++) {
+
+ if (!sarr[i])
+ continue;
+
+ if (sarr[i]->has_method(p_method))
+ return true;
+ }
+
+ return false;
+}
+
+Variant MultiScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+
+ ScriptInstance **sarr = instances.ptr();
+ int sc = instances.size();
+
+ for (int i = 0; i < sc; i++) {
+
+ if (!sarr[i])
+ continue;
+
+ Variant r = sarr[i]->call(p_method, p_args, p_argcount, r_error);
+ if (r_error.error == Variant::CallError::CALL_OK)
+ return r;
+ else if (r_error.error != Variant::CallError::CALL_ERROR_INVALID_METHOD)
+ return r;
+ }
+
+ r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ return Variant();
+}
+
+void MultiScriptInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) {
+
+ ScriptInstance **sarr = instances.ptr();
+ int sc = instances.size();
+
+ for (int i = 0; i < sc; i++) {
+
+ if (!sarr[i])
+ continue;
+
+ sarr[i]->call_multilevel(p_method, p_args, p_argcount);
+ }
+}
+void MultiScriptInstance::notification(int p_notification) {
+
+ // ScriptInstance **sarr = instances.ptr();
+ int sc = instances.size();
+
+ for (int i = 0; i < sc; i++) {
+
+ ScriptInstance *instance = instances[i];
+
+ if (!instance)
+ continue;
+
+ instance->notification(p_notification);
+ }
+}
+
+Ref<Script> MultiScriptInstance::get_script() const {
+
+ return owner;
+}
+
+ScriptLanguage *MultiScriptInstance::get_language() {
+
+ return MultiScriptLanguage::get_singleton();
+}
+
+MultiScriptInstance::~MultiScriptInstance() {
+
+ owner->remove_instance(object);
+}
+
+Variant::Type MultiScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
+ bool valid = false;
+ Variant::Type type;
+
+ ScriptInstance **sarr = instances.ptr();
+ int sc = instances.size();
+
+ for (int i = 0; i < sc; i++) {
+
+ if (!sarr[i])
+ continue;
+
+ type = sarr[i]->get_property_type(p_name, &valid);
+ if (valid) {
+ *r_is_valid = valid;
+ return type;
+ }
+ }
+ *r_is_valid = false;
+ return Variant::NIL;
+}
+
+ScriptInstance::RPCMode MultiScriptInstance::get_rpc_mode(const StringName &p_method) const {
+ ScriptInstance **sarr = instances.ptr();
+ int sc = instances.size();
+
+ for (int i = 0; i < sc; i++) {
+
+ if (!sarr[i])
+ continue;
+ if (sarr[i]->has_method(p_method))
+ return sarr[i]->get_rpc_mode(p_method);
+ }
+ return RPC_MODE_DISABLED;
+}
+
+ScriptInstance::RPCMode MultiScriptInstance::get_rset_mode(const StringName &p_variable) const {
+ ScriptInstance **sarr = instances.ptr();
+ int sc = instances.size();
+
+ for (int i = 0; i < sc; i++) {
+
+ if (!sarr[i])
+ continue;
+
+ List<PropertyInfo> properties;
+ sarr[i]->get_property_list(&properties);
+
+ for (List<PropertyInfo>::Element *P = properties.front(); P; P = P->next()) {
+ if (P->get().name == p_variable) {
+ return sarr[i]->get_rset_mode(p_variable);
+ }
+ }
+ }
+ return RPC_MODE_DISABLED;
+}
+
+///////////////////
+
+bool MultiScript::is_tool() const {
+
+ for (int i = 0; i < scripts.size(); i++) {
+
+ if (scripts[i]->is_tool())
+ return true;
+ }
+
+ return false;
+}
+
+bool MultiScript::_set(const StringName &p_name, const Variant &p_value) {
+
+ _THREAD_SAFE_METHOD_
+
+ String s = String(p_name);
+ if (s.begins_with("script_")) {
+
+ int idx = s[7];
+ if (idx == 0)
+ return false;
+ idx -= 'a';
+
+ ERR_FAIL_COND_V(idx < 0, false);
+
+ Ref<Script> s = p_value;
+
+ if (idx < scripts.size()) {
+
+ if (s.is_null())
+ remove_script(idx);
+ else
+ set_script(idx, s);
+ } else if (idx == scripts.size()) {
+ if (s.is_null())
+ return false;
+ add_script(s);
+ } else
+ return false;
+
+ return true;
+ }
+
+ return false;
+}
+
+bool MultiScript::_get(const StringName &p_name, Variant &r_ret) const {
+
+ _THREAD_SAFE_METHOD_
+
+ String s = String(p_name);
+ if (s.begins_with("script_")) {
+
+ int idx = s[7];
+ if (idx == 0)
+ return false;
+ idx -= 'a';
+
+ ERR_FAIL_COND_V(idx < 0, false);
+
+ if (idx < scripts.size()) {
+
+ r_ret = get_script(idx);
+ return true;
+ } else if (idx == scripts.size()) {
+ r_ret = Ref<Script>();
+ return true;
+ }
+ }
+
+ return false;
+}
+void MultiScript::_get_property_list(List<PropertyInfo> *p_list) const {
+
+ _THREAD_SAFE_METHOD_
+
+ for (int i = 0; i < scripts.size(); i++) {
+
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "script_" + String::chr('a' + i), PROPERTY_HINT_RESOURCE_TYPE, "Script"));
+ }
+
+ if (scripts.size() < 25) {
+
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "script_" + String::chr('a' + (scripts.size())), PROPERTY_HINT_RESOURCE_TYPE, "Script"));
+ }
+}
+
+void MultiScript::set_script(int p_idx, const Ref<Script> &p_script) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_INDEX(p_idx, scripts.size());
+ ERR_FAIL_COND(p_script.is_null());
+
+ scripts[p_idx] = p_script;
+ Ref<Script> s = p_script;
+
+ for (Map<Object *, MultiScriptInstance *>::Element *E = instances.front(); E; E = E->next()) {
+
+ MultiScriptInstance *msi = E->get();
+ ScriptInstance *si = msi->instances[p_idx];
+ if (si) {
+ msi->instances[p_idx] = NULL;
+ memdelete(si);
+ }
+
+ if (p_script->can_instance())
+ msi->instances[p_idx] = s->instance_create(msi->object);
+ }
+}
+
+Ref<Script> MultiScript::get_script(int p_idx) const {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_INDEX_V(p_idx, scripts.size(), Ref<Script>());
+
+ return scripts[p_idx];
+}
+void MultiScript::add_script(const Ref<Script> &p_script) {
+
+ _THREAD_SAFE_METHOD_
+ ERR_FAIL_COND(p_script.is_null());
+ Multi *script_owner = memnew(Multi);
+ script_instances.push_back(script_owner);
+ scripts.push_back(p_script);
+ Ref<Script> s = p_script;
+
+ for (Map<Object *, MultiScriptInstance *>::Element *E = instances.front(); E; E = E->next()) {
+
+ MultiScriptInstance *msi = E->get();
+
+ if (p_script->can_instance()) {
+ script_owner->real_owner = msi->object;
+ msi->instances.push_back(s->instance_create(script_owner));
+ } else {
+ msi->instances.push_back(NULL);
+ }
+
+ msi->object->_change_notify();
+ }
+
+ _change_notify();
+}
+
+void MultiScript::remove_script(int p_idx) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_INDEX(p_idx, scripts.size());
+
+ scripts.remove(p_idx);
+ script_instances.remove(p_idx);
+
+ for (Map<Object *, MultiScriptInstance *>::Element *E = instances.front(); E; E = E->next()) {
+
+ MultiScriptInstance *msi = E->get();
+ ScriptInstance *si = msi->instances[p_idx];
+ msi->instances.remove(p_idx);
+ if (si) {
+ memdelete(si);
+ }
+
+ msi->object->_change_notify();
+ }
+}
+
+void MultiScript::remove_instance(Object *p_object) {
+
+ _THREAD_SAFE_METHOD_
+ instances.erase(p_object);
+}
+
+bool MultiScript::can_instance() const {
+
+ return true;
+}
+
+StringName MultiScript::get_instance_base_type() const {
+
+ return StringName();
+}
+ScriptInstance *MultiScript::instance_create(Object *p_this) {
+
+ _THREAD_SAFE_METHOD_
+ MultiScriptInstance *msi = memnew(MultiScriptInstance);
+ msi->object = p_this;
+ msi->owner = this;
+
+ for (int i = 0; i < scripts.size(); i++) {
+
+ ScriptInstance *si;
+
+ if (scripts[i]->can_instance()) {
+ script_instances[i]->real_owner = p_this;
+ si = scripts[i]->instance_create(script_instances[i]);
+ } else {
+ si = NULL;
+ }
+
+ msi->instances.push_back(si);
+ }
+
+ instances[p_this] = msi;
+ p_this->_change_notify();
+ return msi;
+}
+bool MultiScript::instance_has(const Object *p_this) const {
+
+ _THREAD_SAFE_METHOD_
+ return instances.has((Object *)p_this);
+}
+
+bool MultiScript::has_source_code() const {
+
+ return false;
+}
+String MultiScript::get_source_code() const {
+
+ return "";
+}
+void MultiScript::set_source_code(const String &p_code) {
+}
+Error MultiScript::reload(bool p_keep_state) {
+
+ for (int i = 0; i < scripts.size(); i++)
+ scripts[i]->reload(p_keep_state);
+
+ return OK;
+}
+
+String MultiScript::get_node_type() const {
+
+ return "";
+}
+
+void MultiScript::_bind_methods() {
+}
+
+ScriptLanguage *MultiScript::get_language() const {
+
+ return MultiScriptLanguage::get_singleton();
+}
+
+///////////////
+
+MultiScript::MultiScript() {
+}
+
+MultiScript::~MultiScript() {
+ for (int i = 0; i < script_instances.size(); i++) {
+ memdelete(script_instances[i]);
+ }
+
+ script_instances.resize(0);
+}
+
+Ref<Script> MultiScript::get_base_script() const {
+ Ref<MultiScript> base_script;
+ return base_script;
+}
+
+bool MultiScript::has_method(const StringName &p_method) const {
+ for (int i = 0; i < scripts.size(); i++) {
+ if (scripts[i]->has_method(p_method)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+MethodInfo MultiScript::get_method_info(const StringName &p_method) const {
+ for (int i = 0; i < scripts.size(); i++) {
+ if (scripts[i]->has_method(p_method)) {
+ return scripts[i]->get_method_info(p_method);
+ }
+ }
+ return MethodInfo();
+}
+
+bool MultiScript::has_script_signal(const StringName &p_signal) const {
+ for (int i = 0; i < scripts.size(); i++) {
+ if (scripts[i]->has_script_signal(p_signal)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void MultiScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
+ for (int i = 0; i < scripts.size(); i++) {
+ scripts[i]->get_script_signal_list(r_signals);
+ }
+}
+
+bool MultiScript::get_property_default_value(const StringName &p_property, Variant &r_value) const {
+ for (int i = 0; i < scripts.size(); i++) {
+
+ if (scripts[i]->get_property_default_value(p_property, r_value)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void MultiScript::get_script_method_list(List<MethodInfo> *p_list) const {
+ for (int i = 0; i < scripts.size(); i++) {
+ scripts[i]->get_script_method_list(p_list);
+ }
+}
+
+void MultiScript::get_script_property_list(List<PropertyInfo> *p_list) const {
+ for (int i = 0; i < scripts.size(); i++) {
+ scripts[i]->get_script_property_list(p_list);
+ }
+}
+
+void MultiScript::update_exports() {
+ for (int i = 0; i < scripts.size(); i++) {
+ scripts[i]->update_exports();
+ }
+}
+
+MultiScriptLanguage *MultiScriptLanguage::singleton = NULL;
+
+MultiScriptLanguage *MultiScriptLanguage::get_singleton() {
+ return singleton;
+}
+
+String MultiScriptLanguage::get_name() const {
+ return "MultiScript";
+}
+
+void MultiScriptLanguage::init() {}
+
+String MultiScriptLanguage::get_type() const {
+ return "MultiScript";
+}
+
+String MultiScriptLanguage::get_extension() const {
+ return "";
+}
+
+Error MultiScriptLanguage::execute_file(const String &p_path) {
+ return OK;
+}
+
+void MultiScriptLanguage::finish() {}
+
+void MultiScriptLanguage::get_reserved_words(List<String> *p_words) const {}
+
+void MultiScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {}
+
+void MultiScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const {}
+
+Ref<Script> MultiScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const {
+ MultiScript *s = memnew(MultiScript);
+ s->base_class_name = p_base_class_name;
+ return Ref<MultiScript>(s);
+}
+
+bool MultiScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_fn) const {
+ return true;
+}
+
+Script *MultiScriptLanguage::create_script() const {
+ return memnew(MultiScript);
+}
+
+bool MultiScriptLanguage::has_named_classes() const {
+ return false;
+}
+
+int MultiScriptLanguage::find_function(const String &p_function, const String &p_code) const {
+ return -1;
+}
+
+String MultiScriptLanguage::make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const {
+ return "";
+}
+
+String MultiScriptLanguage::debug_get_error() const {
+ return "";
+}
+
+int MultiScriptLanguage::debug_get_stack_level_count() const {
+ return 0;
+}
+
+int MultiScriptLanguage::debug_get_stack_level_line(int p_level) const {
+ return 0;
+}
+
+String MultiScriptLanguage::debug_get_stack_level_function(int p_level) const {
+ return "";
+}
+
+String MultiScriptLanguage::debug_get_stack_level_source(int p_level) const {
+ return "";
+}
+
+void MultiScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {}
+
+void MultiScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {}
+
+void MultiScriptLanguage::debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {}
+
+String MultiScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) {
+ return "";
+}
+
+void MultiScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const {}
+
+void MultiScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const {}
+
+MultiScriptLanguage::MultiScriptLanguage() {
+ singleton = this;
+}
+
+MultiScriptLanguage::~MultiScriptLanguage() {}
+
+void MultiScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_to_line) const {
+}
+
+void MultiScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) {
+}
+
+void MultiScriptLanguage::reload_all_scripts() {
+}
+
+void MultiScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) {
+}
+
+void MultiScriptLanguage::get_public_constants(List<Pair<String, Variant> > *p_constants) const {
+}
+
+void MultiScriptLanguage::profiling_start() {
+}
+
+void MultiScriptLanguage::profiling_stop() {
+}
+
+int MultiScriptLanguage::profiling_get_accumulated_data(ScriptLanguage::ProfilingInfo *p_info_arr, int p_info_max) {
+ return 0;
+}
+
+int MultiScriptLanguage::profiling_get_frame_data(ScriptLanguage::ProfilingInfo *p_info_arr, int p_info_max) {
+ return 0;
+}
+
+void Multi::_bind_methods() {
+ // ClassDB::bind_method("call", &Multi::call);
+ // ClassDB::bind_method("call_multilevel", &Multi::call_multilevel);
+ // ClassDB::bind_method("call_multilevel_reversed", &Multi::call_multilevel_reversed);
+}
+
+Variant Multi::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+ if (real_owner)
+ return real_owner->call(p_method, p_args, p_argcount, r_error);
+ return Variant();
+}
+
+void Multi::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) {
+ if (real_owner)
+ real_owner->call_multilevel(p_method, p_args, p_argcount);
+}
+
+void Multi::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) {
+ if (real_owner)
+ real_owner->call_multilevel_reversed(p_method, p_args, p_argcount);
+}
diff --git a/modules/multiscript/multiscript.h b/modules/multiscript/multiscript.h
new file mode 100644
index 0000000000..7ec1d5402f
--- /dev/null
+++ b/modules/multiscript/multiscript.h
@@ -0,0 +1,200 @@
+/*************************************************************************/
+/* multiscript.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef MULTISCRIPT_H
+#define MULTISCRIPT_H
+
+#include "os/thread_safe.h"
+#include "script_language.h"
+
+class MultiScript;
+
+class Multi : public Object {
+ GDCLASS(Multi, Object)
+
+ friend class MultiScript;
+
+ Object *real_owner;
+
+public:
+ static void _bind_methods();
+
+ virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ virtual void call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount);
+ virtual void call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount);
+};
+
+class MultiScriptInstance : public ScriptInstance {
+ friend class MultiScript;
+ mutable Vector<ScriptInstance *> instances;
+ Object *object;
+ mutable MultiScript *owner;
+
+public:
+ virtual bool set(const StringName &p_name, const Variant &p_value);
+ virtual bool get(const StringName &p_name, Variant &r_ret) const;
+ virtual void get_property_list(List<PropertyInfo> *p_properties) const;
+
+ virtual void get_method_list(List<MethodInfo> *p_list) const;
+ virtual bool has_method(const StringName &p_method) const;
+ virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ virtual void call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount);
+ virtual void notification(int p_notification);
+
+ virtual Ref<Script> get_script() const;
+
+ virtual ScriptLanguage *get_language();
+ virtual ~MultiScriptInstance();
+
+ // ScriptInstance interface
+public:
+ Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid) const;
+ RPCMode get_rpc_mode(const StringName &p_method) const;
+ RPCMode get_rset_mode(const StringName &p_variable) const;
+};
+
+class MultiScript : public Script {
+
+ _THREAD_SAFE_CLASS_
+ friend class MultiScriptInstance;
+ friend class MultiScriptLanguage;
+ GDCLASS(MultiScript, Script)
+
+ StringName base_class_name;
+
+ Vector<Ref<Script> > scripts;
+ Vector<Multi *> script_instances;
+
+ Map<Object *, MultiScriptInstance *> instances;
+
+protected:
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
+
+ static void _bind_methods();
+
+public:
+ void remove_instance(Object *p_object);
+ virtual bool can_instance() const;
+
+ virtual StringName get_instance_base_type() const;
+ virtual ScriptInstance *instance_create(Object *p_this);
+ virtual bool instance_has(const Object *p_this) const;
+
+ virtual bool has_source_code() const;
+ virtual String get_source_code() const;
+ virtual void set_source_code(const String &p_code);
+ virtual Error reload(bool p_keep_state = false);
+
+ virtual bool is_tool() const;
+
+ virtual String get_node_type() const;
+
+ void set_script(int p_idx, const Ref<Script> &p_script);
+ Ref<Script> get_script(int p_idx) const;
+ void remove_script(int p_idx);
+ void add_script(const Ref<Script> &p_script);
+
+ virtual ScriptLanguage *get_language() const;
+
+ MultiScript();
+ ~MultiScript();
+
+ virtual Ref<Script> get_base_script() const;
+ virtual bool has_method(const StringName &p_method) const;
+ virtual MethodInfo get_method_info(const StringName &p_method) const;
+ virtual bool has_script_signal(const StringName &p_signal) const;
+ virtual void get_script_signal_list(List<MethodInfo> *r_signals) const;
+ virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const;
+ virtual void get_script_method_list(List<MethodInfo> *p_list) const;
+ virtual void get_script_property_list(List<PropertyInfo> *p_list) const;
+ virtual void update_exports();
+};
+
+class MultiScriptLanguage : public ScriptLanguage {
+
+ static MultiScriptLanguage *singleton;
+
+public:
+ static _FORCE_INLINE_ MultiScriptLanguage *get_singleton();
+ virtual String get_name() const;
+
+ /* LANGUAGE FUNCTIONS */
+ virtual void init();
+ virtual String get_type() const;
+ virtual String get_extension() const;
+ virtual Error execute_file(const String &p_path);
+ virtual void finish();
+
+ /* EDITOR FUNCTIONS */
+ virtual void get_reserved_words(List<String> *p_words) const;
+ virtual void get_comment_delimiters(List<String> *p_delimiters) const;
+ virtual void get_string_delimiters(List<String> *p_delimiters) const;
+ virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
+ virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_fn = NULL) const;
+ virtual Script *create_script() const;
+ virtual bool has_named_classes() const;
+ virtual int find_function(const String &p_function, const String &p_code) const;
+ virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
+
+ /* DEBUGGER FUNCTIONS */
+
+ virtual String debug_get_error() const;
+ virtual int debug_get_stack_level_count() const;
+ virtual int debug_get_stack_level_line(int p_level) const;
+ virtual String debug_get_stack_level_function(int p_level) const;
+ virtual String debug_get_stack_level_source(int p_level) const;
+ virtual void debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
+ virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
+ virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
+ virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1);
+
+ /* LOADER FUNCTIONS */
+
+ virtual void get_recognized_extensions(List<String> *p_extensions) const;
+ virtual void get_public_functions(List<MethodInfo> *p_functions) const;
+
+ MultiScriptLanguage();
+ virtual ~MultiScriptLanguage();
+
+ // ScriptLanguage interface
+public:
+ void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
+ void add_global_constant(const StringName &p_variable, const Variant &p_value);
+ void reload_all_scripts();
+ void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload);
+ void get_public_constants(List<Pair<String, Variant> > *p_constants) const;
+ void profiling_start();
+ void profiling_stop();
+ int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max);
+ int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max);
+};
+
+#endif // MULTISCRIPT_H
diff --git a/modules/multiscript/register_types.cpp b/modules/multiscript/register_types.cpp
new file mode 100644
index 0000000000..8170a2d9c1
--- /dev/null
+++ b/modules/multiscript/register_types.cpp
@@ -0,0 +1,51 @@
+/*************************************************************************/
+/* register_types.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "register_types.h"
+
+#include "multiscript.h"
+
+#include "core/script_language.h"
+
+static MultiScriptLanguage *script_multi_script = NULL;
+
+void register_multiscript_types() {
+ script_multi_script = memnew(MultiScriptLanguage);
+ ScriptServer::register_language(script_multi_script);
+ ClassDB::register_class<MultiScript>();
+
+ // ClassDB::register_class<Multi>();
+}
+
+void unregister_multiscript_types() {
+ if (script_multi_script) {
+ ScriptServer::unregister_language(script_multi_script);
+ memdelete(script_multi_script);
+ }
+}
diff --git a/modules/multiscript/register_types.h b/modules/multiscript/register_types.h
new file mode 100644
index 0000000000..b18d1adff2
--- /dev/null
+++ b/modules/multiscript/register_types.h
@@ -0,0 +1,31 @@
+/*************************************************************************/
+/* register_types.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+void register_multiscript_types();
+void unregister_multiscript_types();
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index 53521c55a7..aec60391d3 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -1073,6 +1073,18 @@ void VisualScript::get_script_property_list(List<PropertyInfo> *p_list) const {
}
}
+int VisualScript::get_member_line(const StringName &p_member) const {
+#ifdef TOOLS_ENABLED
+ if (has_function(p_member)) {
+ for (Map<int, Function::NodeData>::Element *E = functions[p_member].nodes.front(); E; E = E->next()) {
+ if (E->get().node->cast_to<VisualScriptFunction>())
+ return E->key();
+ }
+ }
+#endif
+ return -1;
+}
+
#ifdef TOOLS_ENABLED
bool VisualScript::are_subnodes_edited() const {
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index ee8ed2c965..273a819611 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -356,6 +356,8 @@ public:
virtual void get_script_property_list(List<PropertyInfo> *p_list) const;
+ virtual int get_member_line(const StringName &p_member) const;
+
#ifdef TOOLS_ENABLED
virtual bool are_subnodes_edited() const;
#endif
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 7247636920..f1816a762e 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -2153,7 +2153,7 @@ void VisualScriptEditor::goto_line(int p_line, bool p_with_error) {
_update_graph();
_update_members();
- call_deferred("_center_on_node", p_line); //editor might be just created and size might not exist yet
+ call_deferred("call_deferred", "_center_on_node", p_line); //editor might be just created and size might not exist yet
return;
}
@@ -2163,6 +2163,12 @@ void VisualScriptEditor::goto_line(int p_line, bool p_with_error) {
void VisualScriptEditor::trim_trailing_whitespace() {
}
+void VisualScriptEditor::convert_indent_to_spaces() {
+}
+
+void VisualScriptEditor::convert_indent_to_tabs() {
+}
+
void VisualScriptEditor::ensure_focus() {
graph->grab_focus();
@@ -2192,18 +2198,6 @@ void VisualScriptEditor::get_breakpoints(List<int> *p_breakpoints) {
}
}
-bool VisualScriptEditor::goto_method(const String &p_method) {
-
- if (!script->has_function(p_method))
- return false;
-
- edited_func = p_method;
- selected = edited_func;
- _update_members();
- _update_graph();
- return true;
-}
-
void VisualScriptEditor::add_callback(const String &p_function, PoolStringArray p_args) {
if (script->has_function(p_function)) {
diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h
index 7322da5cfb..1fd97cc1bc 100644
--- a/modules/visual_script/visual_script_editor.h
+++ b/modules/visual_script/visual_script_editor.h
@@ -240,11 +240,12 @@ public:
virtual void set_edit_state(const Variant &p_state);
virtual void goto_line(int p_line, bool p_with_error = false);
virtual void trim_trailing_whitespace();
+ virtual void convert_indent_to_spaces();
+ virtual void convert_indent_to_tabs();
virtual void ensure_focus();
virtual void tag_saved_version();
virtual void reload(bool p_soft);
virtual void get_breakpoints(List<int> *p_breakpoints);
- virtual bool goto_method(const String &p_method);
virtual void add_callback(const String &p_function, PoolStringArray p_args);
virtual void update_settings();
virtual void set_debugger_active(bool p_active);
diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp
index 39c8f812ac..889eac71a7 100644
--- a/modules/webp/image_loader_webp.cpp
+++ b/modules/webp/image_loader_webp.cpp
@@ -87,9 +87,11 @@ static Image _webp_lossy_unpack(const PoolVector<uint8_t> &p_buffer) {
ERR_FAIL_V(Image());
}
- //print_line("width: "+itos(features.width));
- //print_line("height: "+itos(features.height));
- //print_line("alpha: "+itos(features.has_alpha));
+ /*
+ print_line("width: "+itos(features.width));
+ print_line("height: "+itos(features.height));
+ print_line("alpha: "+itos(features.has_alpha));
+ */
PoolVector<uint8_t> dst_image;
int datasize = features.width * features.height * (features.has_alpha ? 4 : 3);
@@ -130,9 +132,11 @@ Error ImageLoaderWEBP::load_image(Image *p_image, FileAccess *f) {
ERR_FAIL_V(ERR_FILE_CORRUPT);
}
+ /*
print_line("width: " + itos(features.width));
print_line("height: " + itos(features.height));
print_line("alpha: " + itos(features.has_alpha));
+ */
src_w = PoolVector<uint8_t>::Write();