summaryrefslogtreecommitdiff
path: root/core/os
diff options
context:
space:
mode:
Diffstat (limited to 'core/os')
-rw-r--r--core/os/dir_access.cpp38
-rw-r--r--core/os/dir_access.h4
-rw-r--r--core/os/file_access.cpp72
-rw-r--r--core/os/file_access.h5
-rw-r--r--core/os/keyboard.cpp11
-rw-r--r--core/os/main_loop.cpp6
-rw-r--r--core/os/main_loop.h1
-rw-r--r--core/os/memory.cpp11
-rw-r--r--core/os/memory.h9
-rw-r--r--core/os/midi_driver.cpp5
-rw-r--r--core/os/midi_driver.h1
-rw-r--r--core/os/mutex.h1
-rw-r--r--core/os/os.cpp48
-rw-r--r--core/os/os.h3
-rw-r--r--core/os/rw_lock.cpp1
-rw-r--r--core/os/rw_lock.h2
-rw-r--r--core/os/thread.cpp5
-rw-r--r--core/os/thread.h1
-rw-r--r--core/os/thread_dummy.h2
-rw-r--r--core/os/threaded_array_processor.h3
20 files changed, 0 insertions, 229 deletions
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index 53b959a580..520968c9a9 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -36,9 +36,7 @@
#include "core/project_settings.h"
String DirAccess::_get_root_path() const {
-
switch (_access_type) {
-
case ACCESS_RESOURCES:
return ProjectSettings::get_singleton()->get_resource_path();
case ACCESS_USERDATA:
@@ -48,9 +46,7 @@ String DirAccess::_get_root_path() const {
}
}
String DirAccess::_get_root_string() const {
-
switch (_access_type) {
-
case ACCESS_RESOURCES:
return "res://";
case ACCESS_USERDATA:
@@ -61,7 +57,6 @@ String DirAccess::_get_root_string() const {
}
int DirAccess::get_current_drive() {
-
String path = get_current_dir().to_lower();
for (int i = 0; i < get_drive_count(); i++) {
String d = get_drive(i).to_lower();
@@ -73,21 +68,17 @@ int DirAccess::get_current_drive() {
}
bool DirAccess::drives_are_shortcuts() {
-
return false;
}
static Error _erase_recursive(DirAccess *da) {
-
List<String> dirs;
List<String> files;
da->list_dir_begin();
String n = da->get_next();
while (n != String()) {
-
if (n != "." && n != "..") {
-
if (da->current_is_dir())
dirs.push_back(n);
else
@@ -100,10 +91,8 @@ static Error _erase_recursive(DirAccess *da) {
da->list_dir_end();
for (List<String>::Element *E = dirs.front(); E; E = E->next()) {
-
Error err = da->change_dir(E->get());
if (err == OK) {
-
err = _erase_recursive(da);
if (err) {
da->change_dir("..");
@@ -123,7 +112,6 @@ static Error _erase_recursive(DirAccess *da) {
}
for (List<String>::Element *E = files.front(); E; E = E->next()) {
-
Error err = da->remove(da->get_current_dir().plus_file(E->get()));
if (err) {
return err;
@@ -134,12 +122,10 @@ static Error _erase_recursive(DirAccess *da) {
}
Error DirAccess::erase_contents_recursive() {
-
return _erase_recursive(this);
}
Error DirAccess::make_dir_recursive(String p_dir) {
-
if (p_dir.length() < 1) {
return OK;
};
@@ -178,11 +164,9 @@ Error DirAccess::make_dir_recursive(String p_dir) {
String curpath = base;
for (int i = 0; i < subdirs.size(); i++) {
-
curpath = curpath.plus_file(subdirs[i]);
Error err = make_dir(curpath);
if (err != OK && err != ERR_ALREADY_EXISTS) {
-
ERR_FAIL_V(err);
}
}
@@ -191,17 +175,12 @@ Error DirAccess::make_dir_recursive(String p_dir) {
}
String DirAccess::fix_path(String p_path) const {
-
switch (_access_type) {
-
case ACCESS_RESOURCES: {
-
if (ProjectSettings::get_singleton()) {
if (p_path.begins_with("res://")) {
-
String resource_path = ProjectSettings::get_singleton()->get_resource_path();
if (resource_path != "") {
-
return p_path.replace_first("res:/", resource_path);
};
return p_path.replace_first("res://", "");
@@ -210,12 +189,9 @@ String DirAccess::fix_path(String p_path) const {
} break;
case ACCESS_USERDATA: {
-
if (p_path.begins_with("user://")) {
-
String data_dir = OS::get_singleton()->get_user_data_dir();
if (data_dir != "") {
-
return p_path.replace_first("user:/", data_dir);
};
return p_path.replace_first("user://", "");
@@ -223,7 +199,6 @@ String DirAccess::fix_path(String p_path) const {
} break;
case ACCESS_FILESYSTEM: {
-
return p_path;
} break;
case ACCESS_MAX:
@@ -236,16 +211,12 @@ String DirAccess::fix_path(String p_path) const {
DirAccess::CreateFunc DirAccess::create_func[ACCESS_MAX] = { nullptr, nullptr, nullptr };
DirAccess *DirAccess::create_for_path(const String &p_path) {
-
DirAccess *da = nullptr;
if (p_path.begins_with("res://")) {
-
da = create(ACCESS_RESOURCES);
} else if (p_path.begins_with("user://")) {
-
da = create(ACCESS_USERDATA);
} else {
-
da = create(ACCESS_FILESYSTEM);
}
@@ -253,7 +224,6 @@ DirAccess *DirAccess::create_for_path(const String &p_path) {
}
DirAccess *DirAccess::open(const String &p_path, Error *r_error) {
-
DirAccess *da = create_for_path(p_path);
ERR_FAIL_COND_V_MSG(!da, nullptr, "Cannot create DirAccess for path '" + p_path + "'.");
@@ -269,7 +239,6 @@ DirAccess *DirAccess::open(const String &p_path, Error *r_error) {
}
DirAccess *DirAccess::create(AccessType p_access) {
-
DirAccess *da = create_func[p_access] ? create_func[p_access]() : nullptr;
if (da) {
da->_access_type = p_access;
@@ -279,7 +248,6 @@ DirAccess *DirAccess::create(AccessType p_access) {
};
String DirAccess::get_full_path(const String &p_path, AccessType p_access) {
-
DirAccess *d = DirAccess::create(p_access);
if (!d)
return p_path;
@@ -291,7 +259,6 @@ String DirAccess::get_full_path(const String &p_path, AccessType p_access) {
}
Error DirAccess::copy(String p_from, String p_to, int p_chmod_flags) {
-
//printf("copy %s -> %s\n",p_from.ascii().get_data(),p_to.ascii().get_data());
Error err;
FileAccess *fsrc = FileAccess::open(p_from, FileAccess::READ, &err);
@@ -303,7 +270,6 @@ Error DirAccess::copy(String p_from, String p_to, int p_chmod_flags) {
FileAccess *fdst = FileAccess::open(p_to, FileAccess::WRITE, &err);
if (err) {
-
fsrc->close();
memdelete(fsrc);
ERR_PRINT("Failed to open " + p_to);
@@ -315,7 +281,6 @@ Error DirAccess::copy(String p_from, String p_to, int p_chmod_flags) {
fsrc->seek(0);
err = OK;
while (size--) {
-
if (fsrc->get_error() != OK) {
err = fsrc->get_error();
break;
@@ -367,9 +332,7 @@ Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flag
list_dir_begin();
String n = get_next();
while (n != String()) {
-
if (n != "." && n != "..") {
-
if (current_is_dir())
dirs.push_back(n);
else {
@@ -440,7 +403,6 @@ Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags) {
}
bool DirAccess::exists(String p_dir) {
-
DirAccess *da = DirAccess::create_for_path(p_dir);
bool valid = da->change_dir(p_dir) == OK;
memdelete(da);
diff --git a/core/os/dir_access.h b/core/os/dir_access.h
index cac0d0ec7c..06b3abca8c 100644
--- a/core/os/dir_access.h
+++ b/core/os/dir_access.h
@@ -61,7 +61,6 @@ protected:
template <class T>
static DirAccess *_create_builtin() {
-
return memnew(T);
}
@@ -114,7 +113,6 @@ public:
template <class T>
static void make_default(AccessType p_access) {
-
create_func[p_access] = _create_builtin<T>;
}
@@ -125,9 +123,7 @@ public:
};
struct DirAccessRef {
-
_FORCE_INLINE_ DirAccess *operator->() {
-
return f;
}
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index cb8705f706..f31842bcae 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -43,7 +43,6 @@ FileAccess::FileCloseFailNotify FileAccess::close_fail_notify = nullptr;
bool FileAccess::backup_save = false;
FileAccess *FileAccess::create(AccessType p_access) {
-
ERR_FAIL_INDEX_V(p_access, ACCESS_MAX, nullptr);
FileAccess *ret = create_func[p_access]();
@@ -52,7 +51,6 @@ FileAccess *FileAccess::create(AccessType p_access) {
}
bool FileAccess::exists(const String &p_name) {
-
if (PackedData::get_singleton() && PackedData::get_singleton()->has_path(p_name))
return true;
@@ -64,22 +62,17 @@ bool FileAccess::exists(const String &p_name) {
}
void FileAccess::_set_access_type(AccessType p_access) {
-
_access_type = p_access;
};
FileAccess *FileAccess::create_for_path(const String &p_path) {
-
FileAccess *ret = nullptr;
if (p_path.begins_with("res://")) {
-
ret = create(ACCESS_RESOURCES);
} else if (p_path.begins_with("user://")) {
-
ret = create(ACCESS_USERDATA);
} else {
-
ret = create(ACCESS_FILESYSTEM);
}
@@ -87,12 +80,10 @@ FileAccess *FileAccess::create_for_path(const String &p_path) {
}
Error FileAccess::reopen(const String &p_path, int p_mode_flags) {
-
return _open(p_path, p_mode_flags);
};
FileAccess *FileAccess::open(const String &p_path, int p_mode_flags, Error *r_error) {
-
//try packed data first
FileAccess *ret = nullptr;
@@ -111,7 +102,6 @@ FileAccess *FileAccess::open(const String &p_path, int p_mode_flags, Error *r_er
if (r_error)
*r_error = err;
if (err != OK) {
-
memdelete(ret);
ret = nullptr;
}
@@ -120,7 +110,6 @@ FileAccess *FileAccess::open(const String &p_path, int p_mode_flags, Error *r_er
}
FileAccess::CreateFunc FileAccess::get_create_func(AccessType p_access) {
-
return create_func[p_access];
};
@@ -130,15 +119,11 @@ String FileAccess::fix_path(const String &p_path) const {
String r_path = p_path.replace("\\", "/");
switch (_access_type) {
-
case ACCESS_RESOURCES: {
-
if (ProjectSettings::get_singleton()) {
if (r_path.begins_with("res://")) {
-
String resource_path = ProjectSettings::get_singleton()->get_resource_path();
if (resource_path != "") {
-
return r_path.replace("res:/", resource_path);
};
return r_path.replace("res://", "");
@@ -147,12 +132,9 @@ String FileAccess::fix_path(const String &p_path) const {
} break;
case ACCESS_USERDATA: {
-
if (r_path.begins_with("user://")) {
-
String data_dir = OS::get_singleton()->get_user_data_dir();
if (data_dir != "") {
-
return r_path.replace("user:/", data_dir);
};
return r_path.replace("user://", "");
@@ -160,7 +142,6 @@ String FileAccess::fix_path(const String &p_path) const {
} break;
case ACCESS_FILESYSTEM: {
-
return r_path;
} break;
case ACCESS_MAX:
@@ -173,7 +154,6 @@ String FileAccess::fix_path(const String &p_path) const {
/* these are all implemented for ease of porting, then can later be optimized */
uint16_t FileAccess::get_16() const {
-
uint16_t res;
uint8_t a, b;
@@ -181,7 +161,6 @@ uint16_t FileAccess::get_16() const {
b = get_8();
if (endian_swap) {
-
SWAP(a, b);
}
@@ -192,7 +171,6 @@ uint16_t FileAccess::get_16() const {
return res;
}
uint32_t FileAccess::get_32() const {
-
uint32_t res;
uint16_t a, b;
@@ -200,7 +178,6 @@ uint32_t FileAccess::get_32() const {
b = get_16();
if (endian_swap) {
-
SWAP(a, b);
}
@@ -211,7 +188,6 @@ uint32_t FileAccess::get_32() const {
return res;
}
uint64_t FileAccess::get_64() const {
-
uint64_t res;
uint32_t a, b;
@@ -219,7 +195,6 @@ uint64_t FileAccess::get_64() const {
b = get_32();
if (endian_swap) {
-
SWAP(a, b);
}
@@ -231,14 +206,12 @@ uint64_t FileAccess::get_64() const {
}
float FileAccess::get_float() const {
-
MarshallFloat m;
m.i = get_32();
return m.f;
};
real_t FileAccess::get_real() const {
-
if (real_is_double)
return get_double();
else
@@ -246,20 +219,17 @@ real_t FileAccess::get_real() const {
}
double FileAccess::get_double() const {
-
MarshallDouble m;
m.l = get_64();
return m.d;
};
String FileAccess::get_token() const {
-
CharString token;
CharType c = get_8();
while (!eof_reached()) {
-
if (c <= ' ') {
if (token.length())
break;
@@ -281,16 +251,13 @@ class CharBuffer {
int written = 0;
bool grow() {
-
if (vector.resize(next_power_of_2(1 + written)) != OK) {
-
return false;
}
if (buffer == stack_buffer) { // first chunk?
for (int i = 0; i < written; i++) {
-
vector.write[i] = stack_buffer[i];
}
}
@@ -309,9 +276,7 @@ public:
}
_FORCE_INLINE_ void push_back(char c) {
-
if (written >= capacity) {
-
ERR_FAIL_COND(!grow());
}
@@ -319,19 +284,16 @@ public:
}
_FORCE_INLINE_ const char *get_data() const {
-
return buffer;
}
};
String FileAccess::get_line() const {
-
CharBuffer line;
CharType c = get_8();
while (!eof_reached()) {
-
if (c == '\n' || c == '\0') {
line.push_back(0);
return String::utf8(line.get_data());
@@ -345,7 +307,6 @@ String FileAccess::get_line() const {
}
Vector<String> FileAccess::get_csv_line(const String &p_delim) const {
-
ERR_FAIL_COND_V(p_delim.length() != 1, Vector<String>());
String l;
@@ -357,7 +318,6 @@ Vector<String> FileAccess::get_csv_line(const String &p_delim) const {
l += get_line() + "\n";
qc = 0;
for (int i = 0; i < l.length(); i++) {
-
if (l[i] == '"')
qc++;
}
@@ -371,7 +331,6 @@ Vector<String> FileAccess::get_csv_line(const String &p_delim) const {
bool in_quote = false;
String current;
for (int i = 0; i < l.length(); i++) {
-
CharType c = l[i];
CharType s[2] = { 0, 0 };
@@ -384,7 +343,6 @@ Vector<String> FileAccess::get_csv_line(const String &p_delim) const {
current += s;
i++;
} else {
-
in_quote = !in_quote;
}
} else {
@@ -399,7 +357,6 @@ Vector<String> FileAccess::get_csv_line(const String &p_delim) const {
}
int FileAccess::get_buffer(uint8_t *p_dst, int p_length) const {
-
int i = 0;
for (i = 0; i < p_length && !eof_reached(); i++)
p_dst[i] = get_8();
@@ -425,14 +382,12 @@ String FileAccess::get_as_utf8_string() const {
}
void FileAccess::store_16(uint16_t p_dest) {
-
uint8_t a, b;
a = p_dest & 0xFF;
b = p_dest >> 8;
if (endian_swap) {
-
SWAP(a, b);
}
@@ -440,14 +395,12 @@ void FileAccess::store_16(uint16_t p_dest) {
store_8(b);
}
void FileAccess::store_32(uint32_t p_dest) {
-
uint16_t a, b;
a = p_dest & 0xFFFF;
b = p_dest >> 16;
if (endian_swap) {
-
SWAP(a, b);
}
@@ -455,14 +408,12 @@ void FileAccess::store_32(uint32_t p_dest) {
store_16(b);
}
void FileAccess::store_64(uint64_t p_dest) {
-
uint32_t a, b;
a = p_dest & 0xFFFFFFFF;
b = p_dest >> 32;
if (endian_swap) {
-
SWAP(a, b);
}
@@ -471,7 +422,6 @@ void FileAccess::store_64(uint64_t p_dest) {
}
void FileAccess::store_real(real_t p_real) {
-
if (sizeof(real_t) == 4)
store_float(p_real);
else
@@ -479,21 +429,18 @@ void FileAccess::store_real(real_t p_real) {
}
void FileAccess::store_float(float p_dest) {
-
MarshallFloat m;
m.f = p_dest;
store_32(m.i);
};
void FileAccess::store_double(double p_dest) {
-
MarshallDouble m;
m.d = p_dest;
store_64(m.l);
};
uint64_t FileAccess::get_modified_time(const String &p_file) {
-
if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_file))
return 0;
@@ -506,7 +453,6 @@ uint64_t FileAccess::get_modified_time(const String &p_file) {
}
uint32_t FileAccess::get_unix_permissions(const String &p_file) {
-
if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_file))
return 0;
@@ -519,7 +465,6 @@ uint32_t FileAccess::get_unix_permissions(const String &p_file) {
}
Error FileAccess::set_unix_permissions(const String &p_file, uint32_t p_permissions) {
-
FileAccess *fa = create_for_path(p_file);
ERR_FAIL_COND_V_MSG(!fa, ERR_CANT_CREATE, "Cannot create FileAccess for path '" + p_file + "'.");
@@ -529,7 +474,6 @@ Error FileAccess::set_unix_permissions(const String &p_file, uint32_t p_permissi
}
void FileAccess::store_string(const String &p_string) {
-
if (p_string.length() == 0)
return;
@@ -538,14 +482,12 @@ void FileAccess::store_string(const String &p_string) {
}
void FileAccess::store_pascal_string(const String &p_string) {
-
CharString cs = p_string.utf8();
store_32(cs.length());
store_buffer((uint8_t *)&cs[0], cs.length());
};
String FileAccess::get_pascal_string() {
-
uint32_t sl = get_32();
CharString cs;
cs.resize(sl + 1);
@@ -559,13 +501,11 @@ String FileAccess::get_pascal_string() {
};
void FileAccess::store_line(const String &p_line) {
-
store_string(p_line);
store_8('\n');
}
void FileAccess::store_csv_line(const Vector<String> &p_values, const String &p_delim) {
-
ERR_FAIL_COND(p_delim.length() != 1);
String line = "";
@@ -587,13 +527,11 @@ void FileAccess::store_csv_line(const Vector<String> &p_values, const String &p_
}
void FileAccess::store_buffer(const uint8_t *p_src, int p_length) {
-
for (int i = 0; i < p_length; i++)
store_8(p_src[i]);
}
Vector<uint8_t> FileAccess::get_file_as_array(const String &p_path, Error *r_error) {
-
FileAccess *f = FileAccess::open(p_path, READ, r_error);
if (!f) {
if (r_error) { // if error requested, do not throw error
@@ -609,7 +547,6 @@ Vector<uint8_t> FileAccess::get_file_as_array(const String &p_path, Error *r_err
}
String FileAccess::get_file_as_string(const String &p_path, Error *r_error) {
-
Error err;
Vector<uint8_t> array = get_file_as_array(p_path, &err);
if (r_error) {
@@ -628,7 +565,6 @@ String FileAccess::get_file_as_string(const String &p_path, Error *r_error) {
}
String FileAccess::get_md5(const String &p_file) {
-
FileAccess *f = FileAccess::open(p_file, READ);
if (!f)
return String();
@@ -639,10 +575,8 @@ String FileAccess::get_md5(const String &p_file) {
unsigned char step[32768];
while (true) {
-
int br = f->get_buffer(step, 32768);
if (br > 0) {
-
ctx.update(step, br);
}
if (br < 4096)
@@ -658,7 +592,6 @@ String FileAccess::get_md5(const String &p_file) {
}
String FileAccess::get_multiple_md5(const Vector<String> &p_file) {
-
CryptoCore::MD5Context ctx;
ctx.start();
@@ -669,10 +602,8 @@ String FileAccess::get_multiple_md5(const Vector<String> &p_file) {
unsigned char step[32768];
while (true) {
-
int br = f->get_buffer(step, 32768);
if (br > 0) {
-
ctx.update(step, br);
}
if (br < 4096)
@@ -688,7 +619,6 @@ String FileAccess::get_multiple_md5(const Vector<String> &p_file) {
}
String FileAccess::get_sha256(const String &p_file) {
-
FileAccess *f = FileAccess::open(p_file, READ);
if (!f)
return String();
@@ -699,10 +629,8 @@ String FileAccess::get_sha256(const String &p_file) {
unsigned char step[32768];
while (true) {
-
int br = f->get_buffer(step, 32768);
if (br > 0) {
-
ctx.update(step, br);
}
if (br < 4096)
diff --git a/core/os/file_access.h b/core/os/file_access.h
index 0ee29abbc9..a956ae12f4 100644
--- a/core/os/file_access.h
+++ b/core/os/file_access.h
@@ -41,7 +41,6 @@
*/
class FileAccess {
-
public:
enum AccessType {
ACCESS_RESOURCES,
@@ -73,7 +72,6 @@ private:
static CreateFunc create_func[ACCESS_MAX]; /** default file access creation function for a platform */
template <class T>
static FileAccess *_create_builtin() {
-
return memnew(T);
}
@@ -172,7 +170,6 @@ public:
template <class T>
static void make_default(AccessType p_access) {
-
create_func[p_access] = _create_builtin<T>;
}
@@ -181,9 +178,7 @@ public:
};
struct FileAccessRef {
-
_FORCE_INLINE_ FileAccess *operator->() {
-
return f;
}
diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp
index c65d3fefc2..d088151a6d 100644
--- a/core/os/keyboard.cpp
+++ b/core/os/keyboard.cpp
@@ -293,9 +293,7 @@ static const _KeyCodeText _keycodes[] = {
};
bool keycode_has_unicode(uint32_t p_keycode) {
-
switch (p_keycode) {
-
case KEY_ESCAPE:
case KEY_TAB:
case KEY_BACKTAB:
@@ -394,7 +392,6 @@ bool keycode_has_unicode(uint32_t p_keycode) {
}
String keycode_get_string(uint32_t p_code) {
-
String codestr;
if (p_code & KEY_MASK_SHIFT) {
codestr += find_keycode_name(KEY_SHIFT);
@@ -418,9 +415,7 @@ String keycode_get_string(uint32_t p_code) {
const _KeyCodeText *kct = &_keycodes[0];
while (kct->text) {
-
if (kct->code == (int)p_code) {
-
codestr += kct->text;
return codestr;
}
@@ -433,11 +428,9 @@ String keycode_get_string(uint32_t p_code) {
}
int find_keycode(const String &p_code) {
-
const _KeyCodeText *kct = &_keycodes[0];
while (kct->text) {
-
if (p_code.nocasecmp_to(kct->text) == 0) {
return kct->code;
}
@@ -448,11 +441,9 @@ int find_keycode(const String &p_code) {
}
const char *find_keycode_name(int p_keycode) {
-
const _KeyCodeText *kct = &_keycodes[0];
while (kct->text) {
-
if (kct->code == p_keycode) {
return kct->text;
}
@@ -463,12 +454,10 @@ const char *find_keycode_name(int p_keycode) {
}
int keycode_get_count() {
-
const _KeyCodeText *kct = &_keycodes[0];
int count = 0;
while (kct->text) {
-
count++;
kct++;
}
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index b29e3f6142..7c00af8d1f 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -33,7 +33,6 @@
#include "core/script_language.h"
void MainLoop::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("init"), &MainLoop::init);
ClassDB::bind_method(D_METHOD("iteration", "delta"), &MainLoop::iteration);
ClassDB::bind_method(D_METHOD("idle", "delta"), &MainLoop::idle);
@@ -56,12 +55,10 @@ void MainLoop::_bind_methods() {
};
void MainLoop::set_init_script(const Ref<Script> &p_init_script) {
-
init_script = p_init_script;
}
void MainLoop::init() {
-
if (init_script.is_valid())
set_script(init_script);
@@ -69,14 +66,12 @@ void MainLoop::init() {
get_script_instance()->call("_initialize");
}
bool MainLoop::iteration(float p_time) {
-
if (get_script_instance())
return get_script_instance()->call("_iteration", p_time);
return false;
}
bool MainLoop::idle(float p_time) {
-
if (get_script_instance())
return get_script_instance()->call("_idle", p_time);
@@ -84,7 +79,6 @@ bool MainLoop::idle(float p_time) {
}
void MainLoop::finish() {
-
if (get_script_instance()) {
get_script_instance()->call("_finalize");
set_script(Variant()); //clear script
diff --git a/core/os/main_loop.h b/core/os/main_loop.h
index c7cc8f01e0..90790a45a1 100644
--- a/core/os/main_loop.h
+++ b/core/os/main_loop.h
@@ -36,7 +36,6 @@
#include "core/script_language.h"
class MainLoop : public Object {
-
GDCLASS(MainLoop, Object);
OBJ_CATEGORY("Main Loop");
diff --git a/core/os/memory.cpp b/core/os/memory.cpp
index 0e48592cc1..8457c52092 100644
--- a/core/os/memory.cpp
+++ b/core/os/memory.cpp
@@ -38,28 +38,23 @@
#include <stdlib.h>
void *operator new(size_t p_size, const char *p_description) {
-
return Memory::alloc_static(p_size, false);
}
void *operator new(size_t p_size, void *(*p_allocfunc)(size_t p_size)) {
-
return p_allocfunc(p_size);
}
#ifdef _MSC_VER
void operator delete(void *p_mem, const char *p_description) {
-
CRASH_NOW_MSG("Call to placement delete should not happen.");
}
void operator delete(void *p_mem, void *(*p_allocfunc)(size_t p_size)) {
-
CRASH_NOW_MSG("Call to placement delete should not happen.");
}
void operator delete(void *p_mem, void *p_pointer, size_t check, const char *p_description) {
-
CRASH_NOW_MSG("Call to placement delete should not happen.");
}
#endif
@@ -72,7 +67,6 @@ uint64_t Memory::max_usage = 0;
uint64_t Memory::alloc_count = 0;
void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) {
-
#ifdef DEBUG_ENABLED
bool prepad = true;
#else
@@ -102,7 +96,6 @@ void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) {
}
void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) {
-
if (p_memory == nullptr) {
return alloc_static(p_bytes, p_pad_align);
}
@@ -144,7 +137,6 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) {
return mem + PAD_ALIGN;
}
} else {
-
mem = (uint8_t *)realloc(mem, p_bytes);
ERR_FAIL_COND_V(mem == nullptr && p_bytes > 0, nullptr);
@@ -154,7 +146,6 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) {
}
void Memory::free_static(void *p_ptr, bool p_pad_align) {
-
ERR_FAIL_COND(p_ptr == nullptr);
uint8_t *mem = (uint8_t *)p_ptr;
@@ -177,13 +168,11 @@ void Memory::free_static(void *p_ptr, bool p_pad_align) {
free(mem);
} else {
-
free(mem);
}
}
uint64_t Memory::get_mem_available() {
-
return -1; // 0xFFFF...
}
diff --git a/core/os/memory.h b/core/os/memory.h
index 03c6a80e89..42723152e4 100644
--- a/core/os/memory.h
+++ b/core/os/memory.h
@@ -41,7 +41,6 @@
#endif
class Memory {
-
Memory();
#ifdef DEBUG_ENABLED
static uint64_t mem_usage;
@@ -87,7 +86,6 @@ _ALWAYS_INLINE_ void postinitialize_handler(void *) {}
template <class T>
_ALWAYS_INLINE_ T *_post_initialize(T *p_obj) {
-
postinitialize_handler(p_obj);
return p_obj;
}
@@ -110,7 +108,6 @@ _ALWAYS_INLINE_ bool predelete_handler(void *) {
template <class T>
void memdelete(T *p_class) {
-
if (!predelete_handler(p_class))
return; // doesn't want to be deleted
if (!__has_trivial_destructor(T))
@@ -121,7 +118,6 @@ void memdelete(T *p_class) {
template <class T, class A>
void memdelete_allocator(T *p_class) {
-
if (!predelete_handler(p_class))
return; // doesn't want to be deleted
if (!__has_trivial_destructor(T))
@@ -140,7 +136,6 @@ void memdelete_allocator(T *p_class) {
template <typename T>
T *memnew_arr_template(size_t p_elements, const char *p_descr = "") {
-
if (p_elements == 0)
return nullptr;
/** overloading operator new[] cannot be done , because it may not return the real allocated address (it may pad the 'element count' before the actual array). Because of that, it must be done by hand. This is the
@@ -171,14 +166,12 @@ T *memnew_arr_template(size_t p_elements, const char *p_descr = "") {
template <typename T>
size_t memarr_len(const T *p_class) {
-
uint64_t *ptr = (uint64_t *)p_class;
return *(ptr - 1);
}
template <typename T>
void memdelete_arr(T *p_class) {
-
uint64_t *ptr = (uint64_t *)p_class;
if (!__has_trivial_destructor(T)) {
@@ -193,7 +186,6 @@ void memdelete_arr(T *p_class) {
}
struct _GlobalNil {
-
int color = 1;
_GlobalNil *right;
_GlobalNil *left;
@@ -203,7 +195,6 @@ struct _GlobalNil {
};
struct _GlobalNilClass {
-
static _GlobalNil _nil;
};
diff --git a/core/os/midi_driver.cpp b/core/os/midi_driver.cpp
index efd87d3ab6..e9919aeb86 100644
--- a/core/os/midi_driver.cpp
+++ b/core/os/midi_driver.cpp
@@ -36,17 +36,14 @@
uint8_t MIDIDriver::last_received_message = 0x00;
MIDIDriver *MIDIDriver::singleton = nullptr;
MIDIDriver *MIDIDriver::get_singleton() {
-
return singleton;
}
void MIDIDriver::set_singleton() {
-
singleton = this;
}
void MIDIDriver::receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_t length) {
-
Ref<InputEventMIDI> event;
event.instance();
uint32_t param_position = 1;
@@ -122,12 +119,10 @@ void MIDIDriver::receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_
}
PackedStringArray MIDIDriver::get_connected_inputs() {
-
PackedStringArray list;
return list;
}
MIDIDriver::MIDIDriver() {
-
set_singleton();
}
diff --git a/core/os/midi_driver.h b/core/os/midi_driver.h
index b7377a8a40..bc922e1fcf 100644
--- a/core/os/midi_driver.h
+++ b/core/os/midi_driver.h
@@ -39,7 +39,6 @@
*/
class MIDIDriver {
-
static MIDIDriver *singleton;
static uint8_t last_received_message;
diff --git a/core/os/mutex.h b/core/os/mutex.h
index 69a15f96de..d42cbed821 100644
--- a/core/os/mutex.h
+++ b/core/os/mutex.h
@@ -82,7 +82,6 @@ extern template class MutexLock<MutexImpl<std::mutex>>;
#else
class FakeMutex {
-
FakeMutex() {}
};
diff --git a/core/os/os.cpp b/core/os/os.cpp
index cdc9f1e0ff..02d1dfe895 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -43,7 +43,6 @@
OS *OS::singleton = nullptr;
OS *OS::get_singleton() {
-
return singleton;
}
@@ -84,7 +83,6 @@ uint64_t OS::get_splash_tick_msec() const {
return _msec_splash;
}
uint64_t OS::get_unix_time() const {
-
return 0;
};
uint64_t OS::get_system_time_secs() const {
@@ -116,12 +114,10 @@ void OS::add_logger(Logger *p_logger) {
}
void OS::print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, Logger::ErrorType p_type) {
-
_logger->log_error(p_function, p_file, p_line, p_code, p_rationale, p_type);
}
void OS::print(const char *p_format, ...) {
-
va_list argp;
va_start(argp, p_format);
@@ -140,54 +136,44 @@ void OS::printerr(const char *p_format, ...) {
};
void OS::set_low_processor_usage_mode(bool p_enabled) {
-
low_processor_usage_mode = p_enabled;
}
bool OS::is_in_low_processor_usage_mode() const {
-
return low_processor_usage_mode;
}
void OS::set_low_processor_usage_mode_sleep_usec(int p_usec) {
-
low_processor_usage_mode_sleep_usec = p_usec;
}
int OS::get_low_processor_usage_mode_sleep_usec() const {
-
return low_processor_usage_mode_sleep_usec;
}
String OS::get_executable_path() const {
-
return _execpath;
}
int OS::get_process_id() const {
-
return -1;
};
void OS::vibrate_handheld(int p_duration_ms) {
-
WARN_PRINT("vibrate_handheld() only works with Android and iOS");
}
bool OS::is_stdout_verbose() const {
-
return _verbose_stdout;
}
void OS::dump_memory_to_file(const char *p_file) {
-
//Memory::dump_static_mem_to_file(p_file);
}
static FileAccess *_OSPRF = nullptr;
static void _OS_printres(Object *p_obj) {
-
Resource *res = Object::cast_to<Resource>(p_obj);
if (!res)
return;
@@ -200,10 +186,8 @@ static void _OS_printres(Object *p_obj) {
}
void OS::print_all_resources(String p_to_file) {
-
ERR_FAIL_COND(p_to_file != "" && _OSPRF);
if (p_to_file != "") {
-
Error err;
_OSPRF = FileAccess::open(p_to_file, FileAccess::WRITE, &err);
if (err != OK) {
@@ -215,7 +199,6 @@ void OS::print_all_resources(String p_to_file) {
ObjectDB::debug_objects(_OS_printres);
if (p_to_file != "") {
-
if (_OSPRF)
memdelete(_OSPRF);
_OSPRF = nullptr;
@@ -223,42 +206,34 @@ void OS::print_all_resources(String p_to_file) {
}
void OS::print_resources_in_use(bool p_short) {
-
ResourceCache::dump(nullptr, p_short);
}
void OS::dump_resources_to_file(const char *p_file) {
-
ResourceCache::dump(p_file);
}
void OS::set_no_window_mode(bool p_enable) {
-
_no_window = p_enable;
}
bool OS::is_no_window_mode_enabled() const {
-
return _no_window;
}
int OS::get_exit_code() const {
-
return _exit_code;
}
void OS::set_exit_code(int p_code) {
-
_exit_code = p_code;
}
String OS::get_locale() const {
-
return "en";
}
// Helper function to ensure that a dir name/path will be valid on the OS
String OS::get_safe_dir_name(const String &p_dir_name, bool p_allow_dir_separator) const {
-
Vector<String> invalid_chars = String(": * ? \" < > |").split(" ");
if (p_allow_dir_separator) {
// Dir separators are allowed, but disallow ".." to avoid going up the filesystem
@@ -278,50 +253,42 @@ String OS::get_safe_dir_name(const String &p_dir_name, bool p_allow_dir_separato
// Get properly capitalized engine name for system paths
String OS::get_godot_dir_name() const {
-
// Default to lowercase, so only override when different case is needed
return String(VERSION_SHORT_NAME).to_lower();
}
// OS equivalent of XDG_DATA_HOME
String OS::get_data_path() const {
-
return ".";
}
// OS equivalent of XDG_CONFIG_HOME
String OS::get_config_path() const {
-
return ".";
}
// OS equivalent of XDG_CACHE_HOME
String OS::get_cache_path() const {
-
return ".";
}
// Path to macOS .app bundle resources
String OS::get_bundle_resource_dir() const {
-
return ".";
};
// OS specific path for user://
String OS::get_user_data_dir() const {
-
return ".";
};
// Absolute path to res://
String OS::get_resource_dir() const {
-
return ProjectSettings::get_singleton()->get_resource_path();
}
// Access system-specific dirs like Documents, Downloads, etc.
String OS::get_system_dir(SystemDir p_dir) const {
-
return ".";
}
@@ -332,22 +299,18 @@ Error OS::shell_open(String p_uri) {
// implement these with the canvas?
uint64_t OS::get_static_memory_usage() const {
-
return Memory::get_mem_usage();
}
uint64_t OS::get_static_memory_peak_usage() const {
-
return Memory::get_mem_max_usage();
}
Error OS::set_cwd(const String &p_cwd) {
-
return ERR_CANT_OPEN;
}
uint64_t OS::get_free_static_memory() const {
-
return Memory::get_mem_available();
}
@@ -355,7 +318,6 @@ void OS::yield() {
}
void OS::ensure_user_data_dir() {
-
String dd = get_user_data_dir();
DirAccess *da = DirAccess::open(dd);
if (da) {
@@ -371,28 +333,23 @@ void OS::ensure_user_data_dir() {
}
String OS::get_model_name() const {
-
return "GenericDevice";
}
void OS::set_cmdline(const char *p_execpath, const List<String> &p_args) {
-
_execpath = p_execpath;
_cmdline = p_args;
};
String OS::get_unique_id() const {
-
ERR_FAIL_V("");
}
int OS::get_processor_count() const {
-
return 1;
}
bool OS::can_use_threads() const {
-
#ifdef NO_THREADS
return false;
#else
@@ -401,12 +358,10 @@ bool OS::can_use_threads() const {
}
void OS::set_has_server_feature_callback(HasServerFeatureCallback p_callback) {
-
has_server_feature_callback = p_callback;
}
bool OS::has_feature(const String &p_feature) {
-
if (p_feature == get_name())
return true;
#ifdef DEBUG_ENABLED
@@ -485,7 +440,6 @@ List<String> OS::get_restart_on_exit_arguments() const {
}
PackedStringArray OS::get_connected_midi_inputs() {
-
if (MIDIDriver::get_singleton())
return MIDIDriver::get_singleton()->get_connected_inputs();
@@ -494,13 +448,11 @@ PackedStringArray OS::get_connected_midi_inputs() {
}
void OS::open_midi_inputs() {
-
if (MIDIDriver::get_singleton())
MIDIDriver::get_singleton()->open();
}
void OS::close_midi_inputs() {
-
if (MIDIDriver::get_singleton())
MIDIDriver::get_singleton()->close();
}
diff --git a/core/os/os.h b/core/os/os.h
index 4340823cf4..9296e17bb2 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -42,7 +42,6 @@
#include <stdarg.h>
class OS {
-
static OS *singleton;
String _execpath;
List<String> _cmdline;
@@ -185,7 +184,6 @@ public:
};
struct Date {
-
int year;
Month month;
int day;
@@ -194,7 +192,6 @@ public:
};
struct Time {
-
int hour;
int min;
int sec;
diff --git a/core/os/rw_lock.cpp b/core/os/rw_lock.cpp
index 81df7f7ea6..a668fe2b4c 100644
--- a/core/os/rw_lock.cpp
+++ b/core/os/rw_lock.cpp
@@ -37,7 +37,6 @@
RWLock *(*RWLock::create_func)() = nullptr;
RWLock *RWLock::create() {
-
ERR_FAIL_COND_V(!create_func, nullptr);
return create_func();
diff --git a/core/os/rw_lock.h b/core/os/rw_lock.h
index 8dca8a230a..e519cea439 100644
--- a/core/os/rw_lock.h
+++ b/core/os/rw_lock.h
@@ -52,7 +52,6 @@ public:
};
class RWLockRead {
-
RWLock *lock;
public:
@@ -68,7 +67,6 @@ public:
};
class RWLockWrite {
-
RWLock *lock;
public:
diff --git a/core/os/thread.cpp b/core/os/thread.cpp
index a8eb0b2a9f..399efb19a4 100644
--- a/core/os/thread.cpp
+++ b/core/os/thread.cpp
@@ -38,29 +38,24 @@ Error (*Thread::set_name_func)(const String &) = nullptr;
Thread::ID Thread::_main_thread_id = 0;
Thread::ID Thread::get_caller_id() {
-
if (get_thread_id_func)
return get_thread_id_func();
return 0;
}
Thread *Thread::create(ThreadCreateCallback p_callback, void *p_user, const Settings &p_settings) {
-
if (create_func) {
-
return create_func(p_callback, p_user, p_settings);
}
return nullptr;
}
void Thread::wait_to_finish(Thread *p_thread) {
-
if (wait_to_finish_func)
wait_to_finish_func(p_thread);
}
Error Thread::set_name(const String &p_name) {
-
if (set_name_func)
return set_name_func(p_name);
diff --git a/core/os/thread.h b/core/os/thread.h
index 005217dca7..f761d4ca43 100644
--- a/core/os/thread.h
+++ b/core/os/thread.h
@@ -46,7 +46,6 @@ public:
};
struct Settings {
-
Priority priority;
Settings() { priority = PRIORITY_NORMAL; }
};
diff --git a/core/os/thread_dummy.h b/core/os/thread_dummy.h
index 066ee498ac..37d9ee0846 100644
--- a/core/os/thread_dummy.h
+++ b/core/os/thread_dummy.h
@@ -36,7 +36,6 @@
#include "core/os/thread.h"
class ThreadDummy : public Thread {
-
static Thread *create(ThreadCreateCallback p_callback, void *p_user, const Settings &p_settings = Settings());
public:
@@ -46,7 +45,6 @@ public:
};
class RWLockDummy : public RWLock {
-
static RWLock *create();
public:
diff --git a/core/os/threaded_array_processor.h b/core/os/threaded_array_processor.h
index 00dc53286e..0a435961e1 100644
--- a/core/os/threaded_array_processor.h
+++ b/core/os/threaded_array_processor.h
@@ -54,7 +54,6 @@ struct ThreadArrayProcessData {
template <class T>
void process_array_thread(void *ud) {
-
T &data = *(T *)ud;
while (true) {
uint32_t index = atomic_increment(&data.index);
@@ -66,7 +65,6 @@ void process_array_thread(void *ud) {
template <class C, class M, class U>
void thread_process_array(uint32_t p_elements, C *p_instance, M p_method, U p_userdata) {
-
ThreadArrayProcessData<C, U> data;
data.method = p_method;
data.instance = p_instance;
@@ -93,7 +91,6 @@ void thread_process_array(uint32_t p_elements, C *p_instance, M p_method, U p_us
template <class C, class M, class U>
void thread_process_array(uint32_t p_elements, C *p_instance, M p_method, U p_userdata) {
-
ThreadArrayProcessData<C, U> data;
data.method = p_method;
data.instance = p_instance;