summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/dlscript/api_generator.cpp16
-rw-r--r--modules/dlscript/dl_script.cpp96
-rw-r--r--modules/dlscript/dl_script.h2
-rw-r--r--modules/dlscript/godot.cpp15
-rw-r--r--modules/dlscript/godot.h4
-rw-r--r--modules/dlscript/godot/godot_node_path.cpp8
-rw-r--r--modules/dlscript/godot/godot_node_path.h1
-rw-r--r--modules/dlscript/godot/godot_quat.cpp2
-rw-r--r--modules/dlscript/godot/godot_string.cpp2
-rw-r--r--modules/dlscript/godot/godot_transform.cpp2
-rw-r--r--modules/dlscript/godot/godot_variant.cpp20
-rw-r--r--modules/dlscript/godot/godot_variant.h8
-rw-r--r--modules/gdscript/gd_parser.cpp2
13 files changed, 141 insertions, 37 deletions
diff --git a/modules/dlscript/api_generator.cpp b/modules/dlscript/api_generator.cpp
index 2c2497b5b1..c8e38ca9a3 100644
--- a/modules/dlscript/api_generator.cpp
+++ b/modules/dlscript/api_generator.cpp
@@ -1,5 +1,7 @@
#include "api_generator.h"
+#ifdef TOOLS_ENABLED
+
#include "class_db.h"
#include "core/global_config.h"
#include "os/file_access.h"
@@ -228,8 +230,8 @@ List<ClassAPI> generate_c_api_classes() {
method_api.has_varargs = method_bind && method_bind->is_vararg();
// Method flags
- if (method_bind && method_bind->get_hint_flags()) {
- const uint32_t flags = method_bind->get_hint_flags();
+ if (method_info.flags) {
+ const uint32_t flags = method_info.flags;
method_api.is_editor = flags & METHOD_FLAG_EDITOR;
method_api.is_noscript = flags & METHOD_FLAG_NOSCRIPT;
method_api.is_const = flags & METHOD_FLAG_CONST;
@@ -238,6 +240,8 @@ List<ClassAPI> generate_c_api_classes() {
method_api.is_from_script = flags & METHOD_FLAG_FROM_SCRIPT;
}
+ method_api.is_virtual = method_api.is_virtual || method_api.method_name[0] == '_';
+
// method argument name and type
for (int i = 0; i < method_api.argument_count; i++) {
@@ -344,6 +348,7 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) {
source.push_back(String("\t\t\t\t\"is_const\": ") + (e->get().is_const ? "true" : "false") + ",\n");
source.push_back(String("\t\t\t\t\"is_reverse\": ") + (e->get().is_reverse ? "true" : "false") + ",\n");
source.push_back(String("\t\t\t\t\"is_virtual\": ") + (e->get().is_virtual ? "true" : "false") + ",\n");
+ source.push_back(String("\t\t\t\t\"has_varargs\": ") + (e->get().has_varargs ? "true" : "false") + ",\n");
source.push_back(String("\t\t\t\t\"is_from_script\": ") + (e->get().is_from_script ? "true" : "false") + ",\n");
source.push_back("\t\t\t\t\"arguments\": [\n");
for (int i = 0; i < e->get().argument_names.size(); i++) {
@@ -368,15 +373,22 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) {
//
+#endif
+
/*
* Saves the whole Godot API to a JSON file located at
* p_path
*/
Error generate_c_api(const String &p_path) {
+#ifndef TOOLS_ENABLED
+ return ERR_BUG;
+#else
+
List<ClassAPI> api = generate_c_api_classes();
List<String> json_source = generate_c_api_json(api);
return save_file(p_path, json_source);
+#endif
}
diff --git a/modules/dlscript/dl_script.cpp b/modules/dlscript/dl_script.cpp
index 9917018891..449d7b4b17 100644
--- a/modules/dlscript/dl_script.cpp
+++ b/modules/dlscript/dl_script.cpp
@@ -176,36 +176,84 @@ Error DLScript::reload(bool p_keep_state) {
bool DLScript::has_method(const StringName &p_method) const {
if (!script_data)
return false;
- return script_data->methods.has(p_method);
+ DLScriptData *data = script_data;
+
+ while (data) {
+ if (data->methods.has(p_method))
+ return true;
+
+ data = data->base_data;
+ }
+
+ return false;
}
MethodInfo DLScript::get_method_info(const StringName &p_method) const {
if (!script_data)
return MethodInfo();
+ DLScriptData *data = script_data;
+
+ while (data) {
+ if (data->methods.has(p_method))
+ return data->methods[p_method].info;
+
+ data = data->base_data;
+ }
+
ERR_FAIL_COND_V(!script_data->methods.has(p_method), MethodInfo());
- return script_data->methods[p_method].info;
+ return MethodInfo();
}
void DLScript::get_script_method_list(List<MethodInfo> *p_list) const {
if (!script_data) return;
- for (Map<StringName, DLScriptData::Method>::Element *E = script_data->methods.front(); E; E = E->next()) {
- p_list->push_back(E->get().info);
+
+ Set<MethodInfo> methods;
+ DLScriptData *data = script_data;
+
+ while (data) {
+ for (Map<StringName, DLScriptData::Method>::Element *E = data->methods.front(); E; E = E->next()) {
+ methods.insert(E->get().info);
+ }
+ data = data->base_data;
+ }
+
+ for (Set<MethodInfo>::Element *E = methods.front(); E; E = E->next()) {
+ p_list->push_back(E->get());
}
}
void DLScript::get_script_property_list(List<PropertyInfo> *p_list) const {
if (!script_data) return;
- for (Map<StringName, DLScriptData::Property>::Element *E = script_data->properties.front(); E; E = E->next()) {
- p_list->push_back(E->get().info);
+
+ Set<PropertyInfo> properties;
+ DLScriptData *data = script_data;
+
+ while (data) {
+ for (Map<StringName, DLScriptData::Property>::Element *E = data->properties.front(); E; E = E->next()) {
+ properties.insert(E->get().info);
+ }
+ data = data->base_data;
+ }
+
+ for (Set<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
+ p_list->push_back(E->get());
}
}
bool DLScript::get_property_default_value(const StringName &p_property, Variant &r_value) const {
if (!script_data) return false;
- if (script_data->properties.has(p_property)) {
- r_value = script_data->properties[p_property].default_value;
- return true;
+
+ DLScriptData *data = script_data;
+
+ while (data) {
+ if (data->properties.has(p_property)) {
+ r_value = data->properties[p_property].default_value;
+ return true;
+ }
+
+ data = data->base_data;
}
+
return false;
}
@@ -225,14 +273,38 @@ ScriptLanguage *DLScript::get_language() const {
bool DLScript::has_script_signal(const StringName &p_signal) const {
if (!script_data)
return false;
- return script_data->signals_.has(p_signal);
+
+ DLScriptData *data = script_data;
+
+ while (data) {
+ if (data->signals_.has(p_signal)) {
+ return true;
+ }
+
+ data = data->base_data;
+ }
+
+ return false;
}
void DLScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
if (!script_data)
return;
- for (Map<StringName, DLScriptData::Signal>::Element *S = script_data->signals_.front(); S; S = S->next()) {
- r_signals->push_back(S->get().signal);
+
+ Set<MethodInfo> signals_;
+ DLScriptData *data = script_data;
+
+ while (data) {
+
+ for (Map<StringName, DLScriptData::Signal>::Element *S = data->signals_.front(); S; S = S->next()) {
+ signals_.insert(S->get().signal);
+ }
+
+ data = data->base_data;
+ }
+
+ for (Set<MethodInfo>::Element *E = signals_.front(); E; E = E->next()) {
+ r_signals->push_back(E->get());
}
}
diff --git a/modules/dlscript/dl_script.h b/modules/dlscript/dl_script.h
index 18af85382a..497208c832 100644
--- a/modules/dlscript/dl_script.h
+++ b/modules/dlscript/dl_script.h
@@ -241,6 +241,8 @@ class DLInstance : public ScriptInstance {
public:
_FORCE_INLINE_ Object *get_owner() { return owner; }
+ _FORCE_INLINE_ void *get_userdata() { return userdata; }
+
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;
diff --git a/modules/dlscript/godot.cpp b/modules/dlscript/godot.cpp
index e987e8cf18..9a488ad612 100644
--- a/modules/dlscript/godot.cpp
+++ b/modules/dlscript/godot.cpp
@@ -28,16 +28,11 @@
/*************************************************************************/
#include "godot.h"
-#include <cassert>
-#include <cstdlib>
-
#include "class_db.h"
#include "dl_script.h"
#include "global_config.h"
#include "variant.h"
-#include <memory.h>
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -175,6 +170,16 @@ void GDAPI godot_script_register_signal(const char *p_name, const godot_signal *
library->_register_script_signal(p_name, p_signal);
}
+void GDAPI *godot_dlinstance_get_userdata(godot_object *p_instance) {
+ Object *instance = (Object *)p_instance;
+ if (!instance)
+ return NULL;
+ if (instance->get_script_instance() && instance->get_script_instance()->get_language() == DLScriptLanguage::get_singleton()) {
+ return ((DLInstance *)instance->get_script_instance())->get_userdata();
+ }
+ return NULL;
+}
+
// System functions
void GDAPI *godot_alloc(int p_bytes) {
return memalloc(p_bytes);
diff --git a/modules/dlscript/godot.h b/modules/dlscript/godot.h
index 0c28c1fd2c..75f1f47ed1 100644
--- a/modules/dlscript/godot.h
+++ b/modules/dlscript/godot.h
@@ -121,8 +121,6 @@ typedef int godot_int;
typedef float godot_real;
-typedef double godot_real64; // for Variant in 3.0
-
/////// Object (forward declared)
typedef void godot_object;
@@ -375,6 +373,8 @@ typedef struct godot_signal {
void GDAPI godot_script_register_signal(const char *p_name, const godot_signal *p_signal);
+void GDAPI *godot_dlinstance_get_userdata(godot_object *p_instance);
+
////// System Functions
//using these will help Godot track how much memory is in use in debug mode
diff --git a/modules/dlscript/godot/godot_node_path.cpp b/modules/dlscript/godot/godot_node_path.cpp
index cc0652c75b..8b79175e44 100644
--- a/modules/dlscript/godot/godot_node_path.cpp
+++ b/modules/dlscript/godot/godot_node_path.cpp
@@ -2,8 +2,6 @@
#include "path_db.h"
-#include <memory.h> // why is there no <cmemory> btw?
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -22,6 +20,12 @@ void GDAPI godot_node_path_new(godot_node_path *p_np, const godot_string *p_from
memnew_placement_custom(np, NodePath, NodePath(*from));
}
+void GDAPI godot_node_path_copy(godot_node_path *p_np, const godot_node_path *p_from) {
+ NodePath *np = (NodePath *)p_np;
+ NodePath *from = (NodePath *)p_from;
+ *np = *from;
+}
+
godot_string GDAPI godot_node_path_get_name(const godot_node_path *p_np, const godot_int p_idx) {
const NodePath *np = (const NodePath *)p_np;
godot_string str;
diff --git a/modules/dlscript/godot/godot_node_path.h b/modules/dlscript/godot/godot_node_path.h
index b322e55d83..04f1e70c1d 100644
--- a/modules/dlscript/godot/godot_node_path.h
+++ b/modules/dlscript/godot/godot_node_path.h
@@ -16,6 +16,7 @@ typedef struct godot_node_path {
#include "../godot.h"
void GDAPI godot_node_path_new(godot_node_path *p_np, const godot_string *p_from);
+void GDAPI godot_node_path_copy(godot_node_path *p_np, const godot_node_path *p_from);
godot_string GDAPI godot_node_path_get_name(const godot_node_path *p_np, const godot_int p_idx);
godot_int GDAPI godot_node_path_get_name_count(const godot_node_path *p_np);
diff --git a/modules/dlscript/godot/godot_quat.cpp b/modules/dlscript/godot/godot_quat.cpp
index 5571614e07..9bd2eb0639 100644
--- a/modules/dlscript/godot/godot_quat.cpp
+++ b/modules/dlscript/godot/godot_quat.cpp
@@ -2,8 +2,6 @@
#include "math/quat.h"
-#include <memory.h> // why is there no <cmemory> btw?
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/modules/dlscript/godot/godot_string.cpp b/modules/dlscript/godot/godot_string.cpp
index 1501743e02..97d0985a50 100644
--- a/modules/dlscript/godot/godot_string.cpp
+++ b/modules/dlscript/godot/godot_string.cpp
@@ -3,7 +3,7 @@
#include "string_db.h"
#include "ustring.h"
-#include <memory.h> // why is there no <cmemory> btw?
+#include <string.h>
#ifdef __cplusplus
extern "C" {
diff --git a/modules/dlscript/godot/godot_transform.cpp b/modules/dlscript/godot/godot_transform.cpp
index 18d218e6c4..c8da519f6b 100644
--- a/modules/dlscript/godot/godot_transform.cpp
+++ b/modules/dlscript/godot/godot_transform.cpp
@@ -2,8 +2,6 @@
#include "math/transform.h"
-#include <memory.h> // why is there no <cmemory> btw?
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/modules/dlscript/godot/godot_variant.cpp b/modules/dlscript/godot/godot_variant.cpp
index e7c47ff9ff..3681f89753 100644
--- a/modules/dlscript/godot/godot_variant.cpp
+++ b/modules/dlscript/godot/godot_variant.cpp
@@ -34,7 +34,12 @@ void GDAPI godot_variant_new_bool(godot_variant *p_v, const godot_bool p_b) {
memnew_placement_custom(v, Variant, Variant(p_b));
}
-void GDAPI godot_variant_new_int(godot_variant *p_v, const uint64_t p_i) {
+void GDAPI godot_variant_new_uint(godot_variant *p_v, const uint64_t p_i) {
+ Variant *v = (Variant *)p_v;
+ memnew_placement_custom(v, Variant, Variant(p_i));
+}
+
+void GDAPI godot_variant_new_int(godot_variant *p_v, const int64_t p_i) {
Variant *v = (Variant *)p_v;
memnew_placement_custom(v, Variant, Variant(p_i));
}
@@ -199,14 +204,19 @@ godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_v) {
return v->operator bool();
}
-uint64_t GDAPI godot_variant_as_int(const godot_variant *p_v) {
+uint64_t GDAPI godot_variant_as_uint(const godot_variant *p_v) {
+ const Variant *v = (const Variant *)p_v;
+ return v->operator uint64_t();
+}
+
+int64_t GDAPI godot_variant_as_int(const godot_variant *p_v) {
const Variant *v = (const Variant *)p_v;
- return v->operator godot_int();
+ return v->operator int64_t();
}
-godot_real GDAPI godot_variant_as_real(const godot_variant *p_v) {
+double GDAPI godot_variant_as_real(const godot_variant *p_v) {
const Variant *v = (const Variant *)p_v;
- return v->operator godot_real();
+ return v->operator double();
}
godot_string GDAPI godot_variant_as_string(const godot_variant *p_v) {
diff --git a/modules/dlscript/godot/godot_variant.h b/modules/dlscript/godot/godot_variant.h
index 0b91af863d..1ff5ba4a57 100644
--- a/modules/dlscript/godot/godot_variant.h
+++ b/modules/dlscript/godot/godot_variant.h
@@ -71,7 +71,8 @@ void GDAPI godot_variant_copy(godot_variant *p_dest, const godot_variant *p_src)
void GDAPI godot_variant_new_nil(godot_variant *p_v);
void GDAPI godot_variant_new_bool(godot_variant *p_v, const godot_bool p_b);
-void GDAPI godot_variant_new_int(godot_variant *p_v, const uint64_t p_i);
+void GDAPI godot_variant_new_uint(godot_variant *p_v, const uint64_t p_i);
+void GDAPI godot_variant_new_int(godot_variant *p_v, const int64_t p_i);
void GDAPI godot_variant_new_real(godot_variant *p_v, const double p_r);
void GDAPI godot_variant_new_string(godot_variant *p_v, const godot_string *p_s);
void GDAPI godot_variant_new_vector2(godot_variant *p_v, const godot_vector2 *p_v2);
@@ -100,8 +101,9 @@ void GDAPI godot_variant_new_pool_vector3_array(godot_variant *p_v, const godot_
void GDAPI godot_variant_new_pool_color_array(godot_variant *p_v, const godot_pool_color_array *p_pca);
godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_v);
-uint64_t GDAPI godot_variant_as_int(const godot_variant *p_v);
-godot_real GDAPI godot_variant_as_real(const godot_variant *p_v);
+uint64_t GDAPI godot_variant_as_uint(const godot_variant *p_v);
+int64_t GDAPI godot_variant_as_int(const godot_variant *p_v);
+double GDAPI godot_variant_as_real(const godot_variant *p_v);
godot_string GDAPI godot_variant_as_string(const godot_variant *p_v);
godot_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_v);
godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_v);
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index 1540bb51f8..4c2965c8ec 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -2420,7 +2420,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
p_block->sub_blocks.push_back(cf_if->body);
if (!_enter_indent_block(cf_if->body)) {
- _set_error("Expected intended block after 'if'");
+ _set_error("Expected indented block after 'if'");
p_block->end_line = tokenizer->get_token_line();
return;
}