summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/array.cpp11
-rw-r--r--core/array.h6
-rw-r--r--core/class_db.cpp10
-rw-r--r--core/class_db.h8
-rw-r--r--core/io/logger.cpp11
-rw-r--r--core/io/marshalls.cpp3
-rw-r--r--core/os/os.h2
-rw-r--r--core/project_settings.cpp4
-rw-r--r--core/register_core_types.cpp18
-rw-r--r--core/string_db.h3
10 files changed, 65 insertions, 11 deletions
diff --git a/core/array.cpp b/core/array.cpp
index 30184a002e..171c11776c 100644
--- a/core/array.cpp
+++ b/core/array.cpp
@@ -233,9 +233,10 @@ struct _ArrayVariantSort {
}
};
-void Array::sort() {
+Array &Array::sort() {
_p->array.sort_custom<_ArrayVariantSort>();
+ return *this;
}
struct _ArrayVariantSortCustom {
@@ -253,19 +254,21 @@ struct _ArrayVariantSortCustom {
return res;
}
};
-void Array::sort_custom(Object *p_obj, const StringName &p_function) {
+Array &Array::sort_custom(Object *p_obj, const StringName &p_function) {
- ERR_FAIL_NULL(p_obj);
+ ERR_FAIL_NULL_V(p_obj, *this);
SortArray<Variant, _ArrayVariantSortCustom> avs;
avs.compare.obj = p_obj;
avs.compare.func = p_function;
avs.sort(_p->array.ptr(), _p->array.size());
+ return *this;
}
-void Array::invert() {
+Array &Array::invert() {
_p->array.invert();
+ return *this;
}
void Array::push_front(const Variant &p_value) {
diff --git a/core/array.h b/core/array.h
index 8a647dd13b..2c29103108 100644
--- a/core/array.h
+++ b/core/array.h
@@ -68,9 +68,9 @@ public:
Variant front() const;
Variant back() const;
- void sort();
- void sort_custom(Object *p_obj, const StringName &p_function);
- void invert();
+ Array &sort();
+ Array &sort_custom(Object *p_obj, const StringName &p_function);
+ Array &invert();
int find(const Variant &p_value, int p_from = 0) const;
int rfind(const Variant &p_value, int p_from = -1) const;
diff --git a/core/class_db.cpp b/core/class_db.cpp
index f5ddd9c761..12310f6151 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -205,6 +205,7 @@ ClassDB::ClassInfo::ClassInfo() {
creation_func = NULL;
inherits_ptr = NULL;
disabled = false;
+ exposed = false;
}
ClassDB::ClassInfo::~ClassInfo() {
}
@@ -1284,6 +1285,15 @@ bool ClassDB::is_class_enabled(StringName p_class) {
return !ti->disabled;
}
+bool ClassDB::is_class_exposed(StringName p_class) {
+
+ OBJTYPE_RLOCK;
+
+ ClassInfo *ti = classes.getptr(p_class);
+ ERR_FAIL_COND_V(!ti, false);
+ return ti->exposed;
+}
+
StringName ClassDB::get_category(const StringName &p_node) {
ERR_FAIL_COND_V(!classes.has(p_node), StringName());
diff --git a/core/class_db.h b/core/class_db.h
index f6b97748b0..5910a2ce01 100644
--- a/core/class_db.h
+++ b/core/class_db.h
@@ -127,6 +127,7 @@ public:
StringName inherits;
StringName name;
bool disabled;
+ bool exposed;
Object *(*creation_func)();
ClassInfo();
~ClassInfo();
@@ -168,6 +169,7 @@ public:
ClassInfo *t = classes.getptr(T::get_class_static());
ERR_FAIL_COND(!t);
t->creation_func = &creator<T>;
+ t->exposed = true;
T::register_custom_data_to_otdb();
}
@@ -176,6 +178,9 @@ public:
GLOBAL_LOCK_FUNCTION;
T::initialize_class();
+ ClassInfo *t = classes.getptr(T::get_class_static());
+ ERR_FAIL_COND(!t);
+ t->exposed = true;
//nothing
}
@@ -193,6 +198,7 @@ public:
ClassInfo *t = classes.getptr(T::get_class_static());
ERR_FAIL_COND(!t);
t->creation_func = &_create_ptr_func<T>;
+ t->exposed = true;
T::register_custom_data_to_otdb();
}
@@ -347,6 +353,8 @@ public:
static void set_class_enabled(StringName p_class, bool p_enable);
static bool is_class_enabled(StringName p_class);
+ static bool is_class_exposed(StringName p_class);
+
static void add_resource_base_extension(const StringName &p_extension, const StringName &p_class);
static void get_resource_base_extensions(List<String> *p_extensions);
static void get_extensions_for_type(const StringName &p_class, List<String> *p_extensions);
diff --git a/core/io/logger.cpp b/core/io/logger.cpp
index b94007d316..ad6371f1e1 100644
--- a/core/io/logger.cpp
+++ b/core/io/logger.cpp
@@ -33,6 +33,17 @@
#include "os/os.h"
#include "print_string.h"
+// va_copy was defined in the C99, but not in C++ standards before C++11.
+// When you compile C++ without --std=c++<XX> option, compilers still define
+// va_copy, otherwise you have to use the internal version (__va_copy).
+#if !defined(va_copy)
+#if defined(__GNUC__)
+#define va_copy(d, s) __va_copy(d, s)
+#else
+#define va_copy(d, s) ((d) = (s))
+#endif
+#endif
+
bool Logger::should_log(bool p_err) {
return (!p_err || _print_error_enabled) && (p_err || _print_line_enabled);
}
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 0834d6c321..d388a622de 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -1140,8 +1140,9 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
if (buf) {
encode_uint32(0, buf);
buf += 4;
- r_len += 4;
}
+ r_len += 4;
+
} else {
_encode_string(obj->get_class(), buf, r_len);
diff --git a/core/os/os.h b/core/os/os.h
index 6fcfd71332..48effe99da 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -204,7 +204,7 @@ public:
virtual String get_installed_templates_path() const { return ""; }
virtual String get_executable_path() const;
- virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL) = 0;
+ virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false) = 0;
virtual Error kill(const ProcessID &p_pid) = 0;
virtual int get_process_id() const;
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index ff2be87b07..3994011c06 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -667,8 +667,8 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin
file->store_line("; Engine configuration file.");
file->store_line("; It's best edited using the editor UI and not directly,");
file->store_line("; since the parameters that go here are not all obvious.");
- file->store_line("; ");
- file->store_line("; Format: ");
+ file->store_line(";");
+ file->store_line("; Format:");
file->store_line("; [section] ; section goes between []");
file->store_line("; param=value ; assign values to parameters");
file->store_line("");
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 0e34a3eea5..c6d7cd44e8 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -40,6 +40,7 @@
#include "io/config_file.h"
#include "io/http_client.h"
#include "io/marshalls.h"
+#include "io/networked_multiplayer_peer.h"
#include "io/packet_peer.h"
#include "io/packet_peer_udp.h"
#include "io/pck_packer.h"
@@ -109,6 +110,8 @@ void register_core_types() {
ClassDB::register_class<Object>();
+ ClassDB::register_virtual_class<Script>();
+
ClassDB::register_class<Reference>();
ClassDB::register_class<WeakRef>();
ClassDB::register_class<Resource>();
@@ -136,6 +139,7 @@ void register_core_types() {
ClassDB::register_virtual_class<IP>();
ClassDB::register_virtual_class<PacketPeer>();
ClassDB::register_class<PacketPeerStream>();
+ ClassDB::register_virtual_class<NetworkedMultiplayerPeer>();
ClassDB::register_class<MainLoop>();
//ClassDB::register_type<OptimizedSaver>();
ClassDB::register_class<Translation>();
@@ -185,6 +189,20 @@ void register_core_settings() {
void register_core_singletons() {
+ ClassDB::register_class<ProjectSettings>();
+ ClassDB::register_virtual_class<IP>();
+ ClassDB::register_class<_Geometry>();
+ ClassDB::register_class<_ResourceLoader>();
+ ClassDB::register_class<_ResourceSaver>();
+ ClassDB::register_class<_OS>();
+ ClassDB::register_class<_Engine>();
+ ClassDB::register_class<_ClassDB>();
+ ClassDB::register_class<_Marshalls>();
+ ClassDB::register_class<TranslationServer>();
+ ClassDB::register_virtual_class<Input>();
+ ClassDB::register_class<InputMap>();
+ ClassDB::register_class<_JSON>();
+
ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ProjectSettings", ProjectSettings::get_singleton()));
ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("IP", IP::get_singleton()));
ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Geometry", _Geometry::get_singleton()));
diff --git a/core/string_db.h b/core/string_db.h
index 2bef29fab8..de91e2abd8 100644
--- a/core/string_db.h
+++ b/core/string_db.h
@@ -113,6 +113,9 @@ public:
else
return 0;
}
+ _FORCE_INLINE_ const void *data_unique_pointer() const {
+ return (void *)_data;
+ }
bool operator!=(const StringName &p_name) const;
_FORCE_INLINE_ operator String() const {