Core: Ensure classes match their header filename

Also drop some unused files.

Renamed:
- `core/dvector.h` -> `pool_vector.h`
- `core/io/resource_import.h` -> `resource_importer.h`
- `core/sort.h` -> `sort_array.h`
- `core/string_db.h` -> `string_name.h`

Dropped:
- `core/allocators.h`
- `core/os/shell.h`
- `core/variant_construct_string.cpp`
This commit is contained in:
Rémi Verschelde 2019-02-12 13:30:56 +01:00
parent cb09abdbbd
commit b7cc2bb1e2
57 changed files with 73 additions and 926 deletions

View File

@ -1,195 +0,0 @@
/*************************************************************************/
/* allocators.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 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 ALLOCATORS_H
#define ALLOCATORS_H
#include "core/os/memory.h"
template <int PREALLOC_COUNT = 64, int MAX_HANDS = 8>
class BalloonAllocator {
enum {
USED_FLAG = (1 << 30),
USED_MASK = USED_FLAG - 1
};
struct Balloon {
Balloon *next;
Balloon *prev;
uint32_t hand;
};
struct Hand {
int used;
int allocated;
Balloon *first;
Balloon *last;
};
Hand hands[MAX_HANDS];
public:
void *alloc(size_t p_size) {
size_t max = (1 << MAX_HANDS);
ERR_FAIL_COND_V(p_size > max, NULL);
unsigned int hand = 0;
while (p_size > (size_t)(1 << hand))
++hand;
Hand &h = hands[hand];
if (h.used == h.allocated) {
for (int i = 0; i < PREALLOC_COUNT; i++) {
Balloon *b = (Balloon *)memalloc(sizeof(Balloon) + (1 << hand));
b->hand = hand;
if (h.last) {
b->prev = h.last;
h.last->next = b;
h.last = b;
} else {
b->prev = NULL;
h.last = b;
h.first = b;
}
}
h.last->next = NULL;
h.allocated += PREALLOC_COUNT;
}
Balloon *pick = h.last;
ERR_FAIL_COND_V((pick->hand & USED_FLAG), NULL);
// remove last
h.last = h.last->prev;
h.last->next = NULL;
pick->next = h.first;
h.first->prev = pick;
pick->prev = NULL;
h.first = pick;
h.used++;
pick->hand |= USED_FLAG;
return (void *)(pick + 1);
}
void free(void *p_ptr) {
Balloon *b = (Balloon *)p_ptr;
b -= 1;
ERR_FAIL_COND(!(b->hand & USED_FLAG));
b->hand = b->hand & USED_MASK; // not used
int hand = b->hand;
Hand &h = hands[hand];
if (b == h.first)
h.first = b->next;
if (b->prev)
b->prev->next = b->next;
if (b->next)
b->next->prev = b->prev;
if (h.last != b) {
h.last->next = b;
b->prev = h.last;
b->next = NULL;
h.last = b;
}
h.used--;
if (h.used <= (h.allocated - (PREALLOC_COUNT * 2))) { // this is done to ensure no alloc/free is done constantly
for (int i = 0; i < PREALLOC_COUNT; i++) {
ERR_CONTINUE(h.last->hand & USED_FLAG);
Balloon *new_last = h.last->prev;
if (new_last)
new_last->next = NULL;
memfree(h.last);
h.last = new_last;
}
h.allocated -= PREALLOC_COUNT;
}
}
BalloonAllocator() {
for (int i = 0; i < MAX_HANDS; i++) {
hands[i].allocated = 0;
hands[i].used = 0;
hands[i].first = NULL;
hands[i].last = NULL;
}
}
void clear() {
for (int i = 0; i < MAX_HANDS; i++) {
while (hands[i].first) {
Balloon *b = hands[i].first;
hands[i].first = b->next;
memfree(b);
}
hands[i].allocated = 0;
hands[i].used = 0;
hands[i].first = NULL;
hands[i].last = NULL;
}
}
~BalloonAllocator() {
clear();
}
};
#endif // ALLOCATORS_H

View File

@ -31,7 +31,7 @@
#ifndef CORE_STRING_NAMES_H
#define CORE_STRING_NAMES_H
#include "core/string_db.h"
#include "core/string_name.h"
class CoreStringNames {

View File

@ -31,7 +31,7 @@
#ifndef GLOBAL_CONSTANTS_H
#define GLOBAL_CONSTANTS_H
#include "core/string_db.h"
#include "core/string_name.h"
class GlobalConstants {
public:

View File

@ -34,7 +34,7 @@
#include "core/math/math_defs.h"
#include "core/math/math_funcs.h"
#include "core/node_path.h"
#include "core/string_db.h"
#include "core/string_name.h"
#include "core/typedefs.h"
#include "core/ustring.h"

View File

@ -32,8 +32,8 @@
#define IMAGE_H
#include "core/color.h"
#include "core/dvector.h"
#include "core/math/rect2.h"
#include "core/pool_vector.h"
#include "core/resource.h"
/**

View File

@ -31,8 +31,8 @@
#ifndef FILE_ACCESS_BUFFERED_H
#define FILE_ACCESS_BUFFERED_H
#include "core/dvector.h"
#include "core/os/file_access.h"
#include "core/pool_vector.h"
#include "core/ustring.h"
class FileAccessBuffered : public FileAccess {

View File

@ -54,7 +54,7 @@ class FileAccessBufferedFA : public FileAccessBuffered {
cache.offset = p_offset;
cache.buffer.resize(p_size);
// on dvector
// on PoolVector
//PoolVector<uint8_t>::Write write = cache.buffer.write();
//f.get_buffer(write.ptrw(), p_size);

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* resource_import.cpp */
/* resource_importer.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_import.h"
#include "resource_importer.h"
#include "core/os/os.h"
#include "core/variant_parser.h"

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* resource_import.h */
/* resource_importer.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef RESOURCE_IMPORT_H
#define RESOURCE_IMPORT_H
#ifndef RESOURCE_IMPORTER_H
#define RESOURCE_IMPORTER_H
#include "core/io/resource_loader.h"
@ -110,4 +110,4 @@ public:
virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL) = 0;
};
#endif // RESOURCE_IMPORT_H
#endif // RESOURCE_IMPORTER_H

View File

@ -30,7 +30,7 @@
#include "resource_loader.h"
#include "core/io/resource_import.h"
#include "core/io/resource_importer.h"
#include "core/os/file_access.h"
#include "core/os/os.h"
#include "core/path_remap.h"

View File

@ -32,7 +32,7 @@
#define GLOBALS_LIST_H
#include "core/os/memory.h"
#include "core/sort.h"
#include "core/sort_array.h"
/**
* Generic Templatized Linked List Implementation.

View File

@ -31,11 +31,11 @@
#ifndef BSP_TREE_H
#define BSP_TREE_H
#include "core/dvector.h"
#include "core/math/aabb.h"
#include "core/math/face3.h"
#include "core/math/plane.h"
#include "core/method_ptrcall.h"
#include "core/pool_vector.h"
#include "core/variant.h"
#include "core/vector.h"
/**

View File

@ -31,12 +31,12 @@
#ifndef GEOMETRY_H
#define GEOMETRY_H
#include "core/dvector.h"
#include "core/math/face3.h"
#include "core/math/rect2.h"
#include "core/math/triangulate.h"
#include "core/math/vector3.h"
#include "core/object.h"
#include "core/pool_vector.h"
#include "core/print_string.h"
#include "core/vector.h"

View File

@ -30,7 +30,7 @@
#include "triangle_mesh.h"
#include "core/sort.h"
#include "core/sort_array.h"
int TriangleMesh::_create_bvh(BVH *p_bvh, BVH **p_bb, int p_from, int p_size, int p_depth, int &max_depth, int &max_alloc) {

View File

@ -31,7 +31,7 @@
#ifndef NODE_PATH_H
#define NODE_PATH_H
#include "core/string_db.h"
#include "core/string_name.h"
#include "core/ustring.h"
/**

View File

@ -1,46 +0,0 @@
/*************************************************************************/
/* shell.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 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 "shell.h"
Shell *Shell::singleton = NULL;
Shell *Shell::get_singleton() {
return singleton;
}
Shell::~Shell() {
}
Shell::Shell() {
singleton = this;
}

View File

@ -1,52 +0,0 @@
/*************************************************************************/
/* shell.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 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 SHELL_H
#define SHELL_H
#include "core/typedefs.h"
#include "core/ustring.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class Shell {
static Shell *singleton;
public:
static Shell *get_singleton();
virtual void execute(String p_path) = 0;
Shell();
virtual ~Shell();
};
#endif

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* dvector.cpp */
/* pool_vector.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,9 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "dvector.h"
#include "pool_vector.h"
Mutex *dvector_lock = NULL;
Mutex *pool_vector_lock = NULL;
PoolAllocator *MemoryPool::memory_pool = NULL;
uint8_t *MemoryPool::pool_memory = NULL;

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* dvector.h */
/* pool_vector.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef DVECTOR_H
#define DVECTOR_H
#ifndef POOL_VECTOR_H
#define POOL_VECTOR_H
#include "core/os/copymem.h"
#include "core/os/memory.h"
@ -188,19 +188,19 @@ class PoolVector {
}
}
void _reference(const PoolVector &p_dvector) {
void _reference(const PoolVector &p_pool_vector) {
if (alloc == p_dvector.alloc)
if (alloc == p_pool_vector.alloc)
return;
_unreference();
if (!p_dvector.alloc) {
if (!p_pool_vector.alloc) {
return;
}
if (p_dvector.alloc->refcount.ref()) {
alloc = p_dvector.alloc;
if (p_pool_vector.alloc->refcount.ref()) {
alloc = p_pool_vector.alloc;
}
}
@ -460,11 +460,11 @@ public:
void invert();
void operator=(const PoolVector &p_dvector) { _reference(p_dvector); }
void operator=(const PoolVector &p_pool_vector) { _reference(p_pool_vector); }
PoolVector() { alloc = NULL; }
PoolVector(const PoolVector &p_dvector) {
PoolVector(const PoolVector &p_pool_vector) {
alloc = NULL;
_reference(p_dvector);
_reference(p_pool_vector);
}
~PoolVector() { _unreference(); }
};
@ -640,4 +640,4 @@ void PoolVector<T>::invert() {
}
}
#endif
#endif // POOL_VECTOR_H

View File

@ -47,7 +47,7 @@
#include "core/io/packet_peer_udp.h"
#include "core/io/pck_packer.h"
#include "core/io/resource_format_binary.h"
#include "core/io/resource_import.h"
#include "core/io/resource_importer.h"
#include "core/io/stream_peer_ssl.h"
#include "core/io/tcp_server.h"
#include "core/io/translation_loader_po.h"

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* sort.h */
/* sort_array.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef SORT_H
#define SORT_H
#ifndef SORT_ARRAY_H
#define SORT_ARRAY_H
#include "core/typedefs.h"
@ -327,4 +327,4 @@ public:
}
};
#endif
#endif // SORT_ARRAY_H

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* string_db.cpp */
/* string_name.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "string_db.h"
#include "string_name.h"
#include "core/os/os.h"
#include "core/print_string.h"

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* string_db.h */
/* string_name.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef STRING_DB_H
#define STRING_DB_H
#ifndef STRING_NAME_H
#define STRING_NAME_H
#include "core/os/mutex.h"
#include "core/safe_refcount.h"
@ -169,4 +169,4 @@ public:
StringName _scs_create(const char *p_chr);
#endif
#endif // STRING_NAME_H

View File

@ -38,7 +38,6 @@
#include "core/array.h"
#include "core/color.h"
#include "core/dictionary.h"
#include "core/dvector.h"
#include "core/io/ip_address.h"
#include "core/math/aabb.h"
#include "core/math/basis.h"
@ -49,6 +48,7 @@
#include "core/math/transform_2d.h"
#include "core/math/vector3.h"
#include "core/node_path.h"
#include "core/pool_vector.h"
#include "core/ref_ptr.h"
#include "core/rid.h"
#include "core/ustring.h"

View File

@ -1,438 +0,0 @@
/*************************************************************************/
/* variant_construct_string.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 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 "variant.h"
class VariantConstruct {
enum TokenType {
TK_CURLY_BRACKET_OPEN,
TK_CURLY_BRACKET_CLOSE,
TK_BRACKET_OPEN,
TK_BRACKET_CLOSE,
TK_IDENTIFIER,
TK_STRING,
TK_NUMBER,
TK_COLON,
TK_COMMA,
TK_EOF,
TK_MAX
};
enum Expecting {
EXPECT_OBJECT,
EXPECT_OBJECT_KEY,
EXPECT_COLON,
EXPECT_OBJECT_VALUE,
};
struct Token {
TokenType type;
Variant value;
};
static const char *tk_name[TK_MAX];
static String _print_var(const Variant &p_var);
static Error _get_token(const CharType *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str);
static Error _parse_value(Variant &value, Token &token, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str, Variant::ObjectConstruct *p_construct, void *p_ud);
static Error _parse_array(Array &array, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str, Variant::ObjectConstruct *p_construct, void *p_ud);
static Error _parse_dict(Dictionary &dict, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str, Variant::ObjectConstruct *p_construct, void *p_ud);
public:
static Error parse(const String &p_string, Variant &r_ret, String &r_err_str, int &r_err_line, Variant::ObjectConstruct *p_construct, void *p_ud);
};
const char *VariantConstruct::tk_name[TK_MAX] = {
"'{'",
"'}'",
"'['",
"']'",
"identifier",
"string",
"number",
"':'",
"','",
"EOF",
};
Error VariantConstruct::_get_token(const CharType *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str) {
while (true) {
switch (p_str[index]) {
case '\n': {
line++;
index++;
break;
};
case 0: {
r_token.type = TK_EOF;
return OK;
} break;
case '{': {
r_token.type = TK_CURLY_BRACKET_OPEN;
index++;
return OK;
};
case '}': {
r_token.type = TK_CURLY_BRACKET_CLOSE;
index++;
return OK;
};
case '[': {
r_token.type = TK_BRACKET_OPEN;
index++;
return OK;
};
case ']': {
r_token.type = TK_BRACKET_CLOSE;
index++;
return OK;
};
case ':': {
r_token.type = TK_COLON;
index++;
return OK;
};
case ',': {
r_token.type = TK_COMMA;
index++;
return OK;
};
case '"': {
index++;
String str;
while (true) {
if (p_str[index] == 0) {
r_err_str = "Unterminated String";
return ERR_PARSE_ERROR;
} else if (p_str[index] == '"') {
index++;
break;
} else if (p_str[index] == '\\') {
//escaped characters...
index++;
CharType next = p_str[index];
if (next == 0) {
r_err_str = "Unterminated String";
return ERR_PARSE_ERROR;
}
CharType res = 0;
switch (next) {
case 'b': res = 8; break;
case 't': res = 9; break;
case 'n': res = 10; break;
case 'f': res = 12; break;
case 'r': res = 13; break;
case '\"': res = '\"'; break;
case '\\': res = '\\'; break;
case '/': res = '/'; break;
case 'u': {
//hexnumbarh - oct is deprecated
for (int j = 0; j < 4; j++) {
CharType c = p_str[index + j + 1];
if (c == 0) {
r_err_str = "Unterminated String";
return ERR_PARSE_ERROR;
}
if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))) {
r_err_str = "Malformed hex constant in string";
return ERR_PARSE_ERROR;
}
CharType v;
if (c >= '0' && c <= '9') {
v = c - '0';
} else if (c >= 'a' && c <= 'f') {
v = c - 'a';
v += 10;
} else if (c >= 'A' && c <= 'F') {
v = c - 'A';
v += 10;
} else {
ERR_PRINT("BUG");
v = 0;
}
res <<= 4;
res |= v;
}
index += 4; //will add at the end anyway
} break;
default: {
r_err_str = "Invalid escape sequence";
return ERR_PARSE_ERROR;
} break;
}
str += res;
} else {
if (p_str[index] == '\n')
line++;
str += p_str[index];
}
index++;
}
r_token.type = TK_STRING;
r_token.value = str;
return OK;
} break;
default: {
if (p_str[index] <= 32) {
index++;
break;
}
if (p_str[index] == '-' || (p_str[index] >= '0' && p_str[index] <= '9')) {
//a number
const CharType *rptr;
double number = String::to_double(&p_str[index], &rptr);
index += (rptr - &p_str[index]);
r_token.type = TK_NUMBER;
r_token.value = number;
return OK;
} else if ((p_str[index] >= 'A' && p_str[index] <= 'Z') || (p_str[index] >= 'a' && p_str[index] <= 'z')) {
String id;
while ((p_str[index] >= 'A' && p_str[index] <= 'Z') || (p_str[index] >= 'a' && p_str[index] <= 'z')) {
id += p_str[index];
index++;
}
r_token.type = TK_IDENTIFIER;
r_token.value = id;
return OK;
} else {
r_err_str = "Unexpected character.";
return ERR_PARSE_ERROR;
}
}
}
}
return ERR_PARSE_ERROR;
}
Error VariantConstruct::_parse_value(Variant &value, Token &token, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str, Variant::ObjectConstruct *p_construct, void *p_ud) {
if (token.type == TK_CURLY_BRACKET_OPEN) {
Dictionary d;
Error err = _parse_dict(d, p_str, index, p_len, line, r_err_str, p_construct, p_ud);
if (err)
return err;
value = d;
return OK;
} else if (token.type == TK_BRACKET_OPEN) {
Array a;
Error err = _parse_array(a, p_str, index, p_len, line, r_err_str, p_construct, p_ud);
if (err)
return err;
value = a;
return OK;
} else if (token.type == TK_IDENTIFIER) {
String id = token.value;
if (id == "true")
value = true;
else if (id == "false")
value = false;
else if (id == "null")
value = Variant();
else {
r_err_str = "Expected 'true','false' or 'null', got '" + id + "'.";
return ERR_PARSE_ERROR;
}
return OK;
} else if (token.type == TK_NUMBER) {
value = token.value;
return OK;
} else if (token.type == TK_STRING) {
value = token.value;
return OK;
} else {
r_err_str = "Expected value, got " + String(tk_name[token.type]) + ".";
return ERR_PARSE_ERROR;
}
return ERR_PARSE_ERROR;
}
Error VariantConstruct::_parse_array(Array &array, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str, Variant::ObjectConstruct *p_construct, void *p_ud) {
Token token;
bool need_comma = false;
while (index < p_len) {
Error err = _get_token(p_str, index, p_len, token, line, r_err_str);
if (err != OK)
return err;
if (token.type == TK_BRACKET_CLOSE) {
return OK;
}
if (need_comma) {
if (token.type != TK_COMMA) {
r_err_str = "Expected ','";
return ERR_PARSE_ERROR;
} else {
need_comma = false;
continue;
}
}
Variant v;
err = _parse_value(v, token, p_str, index, p_len, line, r_err_str, p_construct, p_ud);
if (err)
return err;
array.push_back(v);
need_comma = true;
}
return OK;
}
Error VariantConstruct::_parse_dict(Dictionary &dict, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str, Variant::ObjectConstruct *p_construct, void *p_ud) {
bool at_key = true;
Variant key;
Token token;
bool need_comma = false;
while (index < p_len) {
if (at_key) {
Error err = _get_token(p_str, index, p_len, token, line, r_err_str);
if (err != OK)
return err;
if (token.type == TK_CURLY_BRACKET_CLOSE) {
return OK;
}
if (need_comma) {
if (token.type != TK_COMMA) {
r_err_str = "Expected '}' or ','";
return ERR_PARSE_ERROR;
} else {
need_comma = false;
continue;
}
}
err = _parse_value(key, token, p_str, index, p_len, line, r_err_str, p_construct, p_ud);
if (err != OK)
return err;
err = _get_token(p_str, index, p_len, token, line, r_err_str);
if (err != OK)
return err;
if (token.type != TK_COLON) {
r_err_str = "Expected ':'";
return ERR_PARSE_ERROR;
}
at_key = false;
} else {
Error err = _get_token(p_str, index, p_len, token, line, r_err_str);
if (err != OK)
return err;
Variant v;
err = _parse_value(v, token, p_str, index, p_len, line, r_err_str, p_construct, p_ud);
if (err)
return err;
dict[key] = v;
need_comma = true;
at_key = true;
}
}
return OK;
}
Error VariantConstruct::parse(const String &p_string, Variant &r_ret, String &r_err_str, int &r_err_line, Variant::ObjectConstruct *p_construct, void *p_ud) {
const CharType *str = p_string.ptr();
int idx = 0;
int len = p_string.length();
Token token;
r_err_line = 0;
String aux_key;
Error err = _get_token(str, idx, len, token, r_err_line, r_err_str);
if (err)
return err;
return _parse_value(r_ret, token, str, idx, len, r_err_line, r_err_str, p_construct, p_ud);
}

View File

@ -40,7 +40,7 @@
#include "core/cowdata.h"
#include "core/error_macros.h"
#include "core/os/memory.h"
#include "core/sort.h"
#include "core/sort_array.h"
template <class T>
class VectorWriteProxy {

View File

@ -31,7 +31,7 @@
#ifndef RASTERIZERSTORAGEGLES2_H
#define RASTERIZERSTORAGEGLES2_H
#include "core/dvector.h"
#include "core/pool_vector.h"
#include "core/self_list.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual/shader_language.h"

View File

@ -1,67 +0,0 @@
/*************************************************************************/
/* shell_windows.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 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. */
/*************************************************************************/
#ifdef WINDOWS_ENABLED
#ifdef UWP_ENABLED
// Use Launcher class on windows 8
#else
//
// C++ Implementation: shell_windows
//
// Description:
//
//
// Author: Juan Linietsky <reduzio@gmail.com>, (C) 2008
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "shell_windows.h"
#include <windows.h>
void ShellWindows::execute(String p_path) {
ShellExecuteW(NULL, L"open", p_path.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
ShellWindows::ShellWindows() {
}
ShellWindows::~ShellWindows() {
}
#endif
#endif

View File

@ -1,52 +0,0 @@
/*************************************************************************/
/* shell_windows.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 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 SHELL_WINDOWS_H
#define SHELL_WINDOWS_H
#include "core/os/shell.h"
#ifdef WINDOWS_ENABLED
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class ShellWindows : public Shell {
public:
virtual void execute(String p_path);
ShellWindows();
~ShellWindows();
};
#endif
#endif

View File

@ -30,7 +30,7 @@
#include "editor_file_system.h"
#include "core/io/resource_import.h"
#include "core/io/resource_importer.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/os/file_access.h"

View File

@ -31,7 +31,7 @@
#ifndef EDITOR_IMPORT_PLUGIN_H
#define EDITOR_IMPORT_PLUGIN_H
#include "core/io/resource_import.h"
#include "core/io/resource_importer.h"
class EditorImportPlugin : public ResourceImporter {
GDCLASS(EditorImportPlugin, Reference)

View File

@ -32,7 +32,7 @@
#define RESOURCE_IMPORTER_BITMASK_H
#include "core/image.h"
#include "core/io/resource_import.h"
#include "core/io/resource_importer.h"
class StreamBitMap;

View File

@ -31,7 +31,7 @@
#ifndef RESOURCEIMPORTERCSVTRANSLATION_H
#define RESOURCEIMPORTERCSVTRANSLATION_H
#include "core/io/resource_import.h"
#include "core/io/resource_importer.h"
class ResourceImporterCSVTranslation : public ResourceImporter {
GDCLASS(ResourceImporterCSVTranslation, ResourceImporter)

View File

@ -32,7 +32,7 @@
#define RESOURCE_IMPORTER_IMAGE_H
#include "core/image.h"
#include "core/io/resource_import.h"
#include "core/io/resource_importer.h"
class ResourceImporterImage : public ResourceImporter {
GDCLASS(ResourceImporterImage, ResourceImporter)

View File

@ -32,7 +32,7 @@
#define RESOURCE_IMPORTER_LAYERED_TEXTURE_H
#include "core/image.h"
#include "core/io/resource_import.h"
#include "core/io/resource_importer.h"
class StreamTexture;

View File

@ -31,7 +31,7 @@
#ifndef RESOURCEIMPORTERSCENE_H
#define RESOURCEIMPORTERSCENE_H
#include "core/io/resource_import.h"
#include "core/io/resource_importer.h"
#include "scene/resources/animation.h"
#include "scene/resources/mesh.h"
#include "scene/resources/shape.h"

View File

@ -32,7 +32,7 @@
#define RESOURCEIMPORTTEXTURE_H
#include "core/image.h"
#include "core/io/resource_import.h"
#include "core/io/resource_importer.h"
class StreamTexture;

View File

@ -31,7 +31,7 @@
#ifndef RESOURCEIMPORTWAV_H
#define RESOURCEIMPORTWAV_H
#include "core/io/resource_import.h"
#include "core/io/resource_importer.h"
class ResourceImporterWAV : public ResourceImporter {
GDCLASS(ResourceImporterWAV, ResourceImporter)

View File

@ -32,7 +32,7 @@
#define IMPORTDOCK_H
#include "core/io/config_file.h"
#include "core/io/resource_import.h"
#include "core/io/resource_importer.h"
#include "editor/editor_file_system.h"
#include "editor/editor_inspector.h"
#include "scene/gui/box_container.h"

View File

@ -35,7 +35,7 @@
#include "core/os/keyboard.h"
#include "core/print_string.h"
#include "core/project_settings.h"
#include "core/sort.h"
#include "core/sort_array.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/plugins/animation_player_editor_plugin.h"

View File

@ -32,7 +32,7 @@
#include "core/math/face3.h"
#include "core/math/geometry.h"
#include "core/os/os.h"
#include "core/sort.h"
#include "core/sort_array.h"
#include "thirdparty/misc/triangulator.h"
void CSGBrush::clear() {

View File

@ -31,7 +31,6 @@
#ifndef CSG_H
#define CSG_H
#include "core/dvector.h"
#include "core/map.h"
#include "core/math/aabb.h"
#include "core/math/plane.h"
@ -39,6 +38,7 @@
#include "core/math/transform.h"
#include "core/math/vector3.h"
#include "core/oa_hash_map.h"
#include "core/pool_vector.h"
#include "scene/resources/material.h"
struct CSGBrush {

View File

@ -34,7 +34,7 @@
#include "core/os/memory.h"
#include "core/color.h"
#include "core/dvector.h"
#include "core/pool_vector.h"
#include "core/variant.h"

View File

@ -31,7 +31,7 @@
#include "gdnative/pool_arrays.h"
#include "core/array.h"
#include "core/dvector.h"
#include "core/pool_vector.h"
#include "core/variant.h"
#include "core/color.h"

View File

@ -30,7 +30,7 @@
#include "gdnative/string.h"
#include "core/string_db.h"
#include "core/string_name.h"
#include "core/ustring.h"
#include "core/variant.h"

View File

@ -30,7 +30,7 @@
#include "gdnative/string_name.h"
#include "core/string_db.h"
#include "core/string_name.h"
#include "core/ustring.h"
#include <string.h>

View File

@ -36,7 +36,7 @@
#include "core/reference.h"
#include "core/script_language.h"
#include "core/self_list.h"
#include "core/string_db.h"
#include "core/string_name.h"
#include "core/variant.h"
class GDScriptInstance;

View File

@ -32,7 +32,7 @@
#define GDSCRIPT_TOKENIZER_H
#include "core/pair.h"
#include "core/string_db.h"
#include "core/string_name.h"
#include "core/ustring.h"
#include "core/variant.h"
#include "core/vmap.h"

View File

@ -33,7 +33,7 @@
#ifdef MONO_GLUE_ENABLED
#include "core/reference.h"
#include "core/string_db.h"
#include "core/string_name.h"
#include "../csharp_script.h"
#include "../mono_gd/gd_mono_internals.h"

View File

@ -32,7 +32,7 @@
#define RESOURCEIMPORTEROGGVORBIS_H
#include "audio_stream_ogg_vorbis.h"
#include "core/io/resource_import.h"
#include "core/io/resource_importer.h"
class ResourceImporterOGGVorbis : public ResourceImporter {
GDCLASS(ResourceImporterOGGVorbis, ResourceImporter)

View File

@ -32,7 +32,7 @@
#define SCENE_STRING_NAMES_H
#include "core/node_path.h"
#include "core/string_db.h"
#include "core/string_name.h"
class SceneStringNames {
friend void register_scene_types();

View File

@ -32,7 +32,7 @@
#include "core/math/geometry.h"
#include "core/math/quick_hull.h"
#include "core/sort.h"
#include "core/sort_array.h"
#define _POINT_SNAP 0.001953125
#define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.0002

View File

@ -31,7 +31,7 @@
#include "shape_2d_sw.h"
#include "core/math/geometry.h"
#include "core/sort.h"
#include "core/sort_array.h"
void Shape2DSW::configure(const Rect2 &p_aabb) {
aabb = p_aabb;

View File

@ -33,7 +33,7 @@
#include "core/list.h"
#include "core/map.h"
#include "core/string_db.h"
#include "core/string_name.h"
#include "core/typedefs.h"
#include "core/ustring.h"
#include "core/variant.h"

View File

@ -33,7 +33,7 @@
#include "core/io/marshalls.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#include "core/sort.h"
#include "core/sort_array.h"
#include "visual_server_canvas.h"
#include "visual_server_global.h"
#include "visual_server_scene.h"

View File

@ -31,7 +31,6 @@
#ifndef VISUAL_SERVER_RASTER_H
#define VISUAL_SERVER_RASTER_H
#include "core/allocators.h"
#include "core/math/octree.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual_server.h"

View File

@ -33,7 +33,6 @@
#include "servers/visual/rasterizer.h"
#include "core/allocators.h"
#include "core/math/geometry.h"
#include "core/math/octree.h"
#include "core/os/semaphore.h"
@ -120,7 +119,6 @@ public:
VS::ScenarioDebugMode debug;
RID self;
// well wtf, balloon allocator is slower?
Octree<Instance, true> octree;