diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/bind/core_bind.cpp | 13 | ||||
-rw-r--r-- | core/bind/core_bind.h | 2 | ||||
-rw-r--r-- | core/dictionary.cpp | 103 | ||||
-rw-r--r-- | core/io/SCsub | 1 | ||||
-rw-r--r-- | core/io/compression.cpp | 20 | ||||
-rw-r--r-- | core/io/compression.h | 2 | ||||
-rw-r--r-- | core/io/config_file.cpp | 20 | ||||
-rw-r--r-- | core/io/config_file.h | 3 | ||||
-rw-r--r-- | core/math/a_star.cpp | 72 | ||||
-rw-r--r-- | core/math/a_star.h | 7 | ||||
-rw-r--r-- | core/math/math_funcs.cpp | 15 | ||||
-rw-r--r-- | core/math/math_funcs.h | 5 | ||||
-rw-r--r-- | core/math/matrix3.cpp | 25 | ||||
-rw-r--r-- | core/ordered_hash_map.h | 42 | ||||
-rw-r--r-- | core/os/keyboard.cpp | 22 | ||||
-rw-r--r-- | core/os/os.h | 1 | ||||
-rw-r--r-- | core/project_settings.cpp | 6 | ||||
-rw-r--r-- | core/translation.cpp | 136 | ||||
-rw-r--r-- | core/translation.h | 3 | ||||
-rw-r--r-- | core/ustring.cpp | 64 | ||||
-rw-r--r-- | core/ustring.h | 5 | ||||
-rw-r--r-- | core/variant_call.cpp | 601 | ||||
-rw-r--r-- | core/version.h | 4 |
23 files changed, 671 insertions, 501 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index b47e611a51..c369f4bffe 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -413,6 +413,7 @@ String _OS::get_latin_keyboard_variant() const { case OS::LATIN_KEYBOARD_QZERTY: return "QZERTY"; case OS::LATIN_KEYBOARD_DVORAK: return "DVORAK"; case OS::LATIN_KEYBOARD_NEO: return "NEO"; + case OS::LATIN_KEYBOARD_COLEMAK: return "COLEMAK"; default: return "ERROR"; } } @@ -1315,6 +1316,16 @@ Vector<int> _Geometry::triangulate_polygon(const Vector<Vector2> &p_polygon) { return Geometry::triangulate_polygon(p_polygon); } +Vector<Point2> _Geometry::convex_hull_2d(const Vector<Point2> &p_points) { + + return Geometry::convex_hull_2d(p_points); +} + +Vector<Vector3> _Geometry::clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane) { + + return Geometry::clip_polygon(p_points, p_plane); +} + Dictionary _Geometry::make_atlas(const Vector<Size2> &p_rects) { Dictionary ret; @@ -1375,6 +1386,8 @@ void _Geometry::_bind_methods() { ClassDB::bind_method(D_METHOD("point_is_inside_triangle", "point", "a", "b", "c"), &_Geometry::point_is_inside_triangle); ClassDB::bind_method(D_METHOD("triangulate_polygon", "polygon"), &_Geometry::triangulate_polygon); + ClassDB::bind_method(D_METHOD("convex_hull_2d", "points"), &_Geometry::convex_hull_2d); + ClassDB::bind_method(D_METHOD("clip_polygon", "points", "plane"), &_Geometry::clip_polygon); ClassDB::bind_method(D_METHOD("make_atlas", "sizes"), &_Geometry::make_atlas); } diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 7f8c734e36..bbbb40d926 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -363,6 +363,8 @@ public: int get_uv84_normal_bit(const Vector3 &p_vector); Vector<int> triangulate_polygon(const Vector<Vector2> &p_polygon); + Vector<Point2> convex_hull_2d(const Vector<Point2> &p_points); + Vector<Vector3> clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane); Dictionary make_atlas(const Vector<Size2> &p_rects); diff --git a/core/dictionary.cpp b/core/dictionary.cpp index bb2e892951..1b431f9ec9 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "dictionary.h" +#include "ordered_hash_map.h" #include "safe_refcount.h" #include "variant.h" @@ -39,22 +40,8 @@ struct _DictionaryVariantHash { struct DictionaryPrivate { - struct Data { - Variant variant; - int order; - }; - SafeRefCount refcount; - HashMap<Variant, Data, _DictionaryVariantHash> variant_map; - int counter; -}; - -struct DictionaryPrivateSort { - - bool operator()(const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *A, const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *B) const { - - return A->data.order < B->data.order; - } + OrderedHashMap<Variant, Variant, _DictionaryVariantHash> variant_map; }; void Dictionary::get_key_list(List<Variant> *p_keys) const { @@ -62,61 +49,45 @@ void Dictionary::get_key_list(List<Variant> *p_keys) const { if (_p->variant_map.empty()) return; - int count = _p->variant_map.size(); - const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair **pairs = (const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair **)alloca(count * sizeof(HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *)); - _p->variant_map.get_key_value_ptr_array(pairs); - - SortArray<const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *, DictionaryPrivateSort> sort; - sort.sort(pairs, count); - - for (int i = 0; i < count; i++) { - p_keys->push_back(pairs[i]->key); + for (OrderedHashMap<Variant, Variant, _DictionaryVariantHash>::Element E = _p->variant_map.front(); E; E = E.next()) { + p_keys->push_back(E.key()); } } Variant &Dictionary::operator[](const Variant &p_key) { - DictionaryPrivate::Data *v = _p->variant_map.getptr(p_key); - - if (!v) { - - DictionaryPrivate::Data d; - d.order = _p->counter++; - _p->variant_map[p_key] = d; - v = _p->variant_map.getptr(p_key); - } - return v->variant; + return _p->variant_map[p_key]; } const Variant &Dictionary::operator[](const Variant &p_key) const { - return _p->variant_map[p_key].variant; + return ((const OrderedHashMap<Variant, Variant, _DictionaryVariantHash> *)&_p->variant_map)->operator[](p_key); } const Variant *Dictionary::getptr(const Variant &p_key) const { - const DictionaryPrivate::Data *v = _p->variant_map.getptr(p_key); - if (!v) + OrderedHashMap<Variant, Variant, _DictionaryVariantHash>::ConstElement E = ((const OrderedHashMap<Variant, Variant, _DictionaryVariantHash> *)&_p->variant_map)->find(p_key); + + if (!E) return NULL; - else - return &v->variant; + return &E.get(); } Variant *Dictionary::getptr(const Variant &p_key) { - DictionaryPrivate::Data *v = _p->variant_map.getptr(p_key); - if (!v) + OrderedHashMap<Variant, Variant, _DictionaryVariantHash>::Element E = _p->variant_map.find(p_key); + + if (!E) return NULL; - else - return &v->variant; + return &E.get(); } Variant Dictionary::get_valid(const Variant &p_key) const { - DictionaryPrivate::Data *v = _p->variant_map.getptr(p_key); - if (!v) + OrderedHashMap<Variant, Variant, _DictionaryVariantHash>::ConstElement E = ((const OrderedHashMap<Variant, Variant, _DictionaryVariantHash> *)&_p->variant_map)->find(p_key); + + if (!E) return Variant(); - else - return v->variant; + return E.get(); } int Dictionary::size() const { @@ -171,7 +142,6 @@ void Dictionary::_ref(const Dictionary &p_from) const { void Dictionary::clear() { _p->variant_map.clear(); - _p->counter = 0; } void Dictionary::_unref() const { @@ -205,15 +175,10 @@ Array Dictionary::keys() const { if (_p->variant_map.empty()) return varr; - int count = _p->variant_map.size(); - const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair **pairs = (const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair **)alloca(count * sizeof(HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *)); - _p->variant_map.get_key_value_ptr_array(pairs); - - SortArray<const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *, DictionaryPrivateSort> sort; - sort.sort(pairs, count); - - for (int i = 0; i < count; i++) { - varr[i] = pairs[i]->key; + int i = 0; + for (OrderedHashMap<Variant, Variant, _DictionaryVariantHash>::Element E = _p->variant_map.front(); E; E = E.next()) { + varr[i] = E.key(); + i++; } return varr; @@ -226,15 +191,10 @@ Array Dictionary::values() const { if (_p->variant_map.empty()) return varr; - int count = _p->variant_map.size(); - const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair **pairs = (const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair **)alloca(count * sizeof(HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *)); - _p->variant_map.get_key_value_ptr_array(pairs); - - SortArray<const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *, DictionaryPrivateSort> sort; - sort.sort(pairs, count); - - for (int i = 0; i < count; i++) { - varr[i] = pairs[i]->data.variant; + int i = 0; + for (OrderedHashMap<Variant, Variant, _DictionaryVariantHash>::Element E = _p->variant_map.front(); E; E = E.next()) { + varr[i] = E.get(); + i++; } return varr; @@ -242,7 +202,15 @@ Array Dictionary::values() const { const Variant *Dictionary::next(const Variant *p_key) const { - return _p->variant_map.next(p_key); + if (p_key == NULL) { + // caller wants to get the first element + return &_p->variant_map.front().key(); + } + OrderedHashMap<Variant, Variant, _DictionaryVariantHash>::Element E = _p->variant_map.find(*p_key); + + if (E && E.next()) + return &E.next().key(); + return NULL; } Dictionary Dictionary::copy() const { @@ -273,7 +241,6 @@ Dictionary::Dictionary() { _p = memnew(DictionaryPrivate); _p->refcount.init(); - _p->counter = 0; } Dictionary::~Dictionary() { diff --git a/core/io/SCsub b/core/io/SCsub index 4efc902717..79b56cb716 100644 --- a/core/io/SCsub +++ b/core/io/SCsub @@ -5,3 +5,4 @@ Import('env') env.add_source_files(env.core_sources, "*.cpp") Export('env') + diff --git a/core/io/compression.cpp b/core/io/compression.cpp index fbe97e54c7..51d48901cf 100644 --- a/core/io/compression.cpp +++ b/core/io/compression.cpp @@ -78,9 +78,16 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size, } break; case MODE_ZSTD: { - + ZSTD_CCtx *cctx = ZSTD_createCCtx(); + ZSTD_CCtx_setParameter(cctx, ZSTD_p_compressionLevel, zstd_level); + if (zstd_long_distance_matching) { + ZSTD_CCtx_setParameter(cctx, ZSTD_p_enableLongDistanceMatching, 1); + ZSTD_CCtx_setParameter(cctx, ZSTD_p_windowLog, zstd_window_log_size); + } int max_dst_size = get_max_compressed_buffer_size(p_src_size, MODE_ZSTD); - return ZSTD_compress(p_dst, max_dst_size, p_src, p_src_size, zstd_level); + int ret = ZSTD_compressCCtx(cctx, p_dst, max_dst_size, p_src, p_src_size, zstd_level); + ZSTD_freeCCtx(cctx); + return ret; } break; } @@ -165,8 +172,11 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p return total; } break; case MODE_ZSTD: { - - return ZSTD_decompress(p_dst, p_dst_max_size, p_src, p_src_size); + ZSTD_DCtx *dctx = ZSTD_createDCtx(); + if (zstd_long_distance_matching) ZSTD_DCtx_setMaxWindowSize(dctx, 1 << zstd_window_log_size); + int ret = ZSTD_decompressDCtx(dctx, p_dst, p_dst_max_size, p_src, p_src_size); + ZSTD_freeDCtx(dctx); + return ret; } break; } @@ -176,3 +186,5 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p int Compression::zlib_level = Z_DEFAULT_COMPRESSION; int Compression::gzip_level = Z_DEFAULT_COMPRESSION; int Compression::zstd_level = 3; +bool Compression::zstd_long_distance_matching = false; +int Compression::zstd_window_log_size = 27; diff --git a/core/io/compression.h b/core/io/compression.h index 22d8109d4f..5a9aedec31 100644 --- a/core/io/compression.h +++ b/core/io/compression.h @@ -38,6 +38,8 @@ public: static int zlib_level; static int gzip_level; static int zstd_level; + static bool zstd_long_distance_matching; + static int zstd_window_log_size; enum Mode { MODE_FASTLZ, diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp index daa6b01d6e..2b60150832 100644 --- a/core/io/config_file.cpp +++ b/core/io/config_file.cpp @@ -75,7 +75,7 @@ void ConfigFile::set_value(const String &p_section, const String &p_key, const V } else { if (!values.has(p_section)) { - values[p_section] = Map<String, Variant>(); + values[p_section] = OrderedHashMap<String, Variant>(); } values[p_section][p_key] = p_value; @@ -106,16 +106,16 @@ bool ConfigFile::has_section_key(const String &p_section, const String &p_key) c void ConfigFile::get_sections(List<String> *r_sections) const { - for (const Map<String, Map<String, Variant> >::Element *E = values.front(); E; E = E->next()) { - r_sections->push_back(E->key()); + for (OrderedHashMap<String, OrderedHashMap<String, Variant> >::ConstElement E = values.front(); E; E = E.next()) { + r_sections->push_back(E.key()); } } void ConfigFile::get_section_keys(const String &p_section, List<String> *r_keys) const { ERR_FAIL_COND(!values.has(p_section)); - for (const Map<String, Variant>::Element *E = values[p_section].front(); E; E = E->next()) { - r_keys->push_back(E->key()); + for (OrderedHashMap<String, Variant>::ConstElement E = values[p_section].front(); E; E = E.next()) { + r_keys->push_back(E.key()); } } @@ -135,17 +135,17 @@ Error ConfigFile::save(const String &p_path) { return err; } - for (Map<String, Map<String, Variant> >::Element *E = values.front(); E; E = E->next()) { + for (OrderedHashMap<String, OrderedHashMap<String, Variant> >::Element E = values.front(); E; E = E.next()) { if (E != values.front()) file->store_string("\n"); - file->store_string("[" + E->key() + "]\n\n"); + file->store_string("[" + E.key() + "]\n\n"); - for (Map<String, Variant>::Element *F = E->get().front(); F; F = F->next()) { + for (OrderedHashMap<String, Variant>::Element F = E.get().front(); F; F = F.next()) { String vstr; - VariantWriter::write_to_string(F->get(), vstr); - file->store_string(F->key() + "=" + vstr + "\n"); + VariantWriter::write_to_string(F.get(), vstr); + file->store_string(F.key() + "=" + vstr + "\n"); } } diff --git a/core/io/config_file.h b/core/io/config_file.h index 8ed8a069e4..29bd369a24 100644 --- a/core/io/config_file.h +++ b/core/io/config_file.h @@ -30,13 +30,14 @@ #ifndef CONFIG_FILE_H #define CONFIG_FILE_H +#include "core/ordered_hash_map.h" #include "reference.h" class ConfigFile : public Reference { GDCLASS(ConfigFile, Reference); - Map<String, Map<String, Variant> > values; + OrderedHashMap<String, OrderedHashMap<String, Variant> > values; PoolStringArray _get_sections() const; PoolStringArray _get_section_keys(const String &p_section) const; diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index ffe1089965..7e26761abf 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -42,8 +42,10 @@ int AStar::get_available_point_id() const { } void AStar::add_point(int p_id, const Vector3 &p_pos, real_t p_weight_scale) { + ERR_FAIL_COND(p_id < 0); ERR_FAIL_COND(p_weight_scale < 1); + if (!points.has(p_id)) { Point *pt = memnew(Point); pt->id = p_id; @@ -64,12 +66,29 @@ Vector3 AStar::get_point_position(int p_id) const { return points[p_id]->pos; } + +void AStar::set_point_position(int p_id, const Vector3 &p_pos) { + + ERR_FAIL_COND(!points.has(p_id)); + + points[p_id]->pos = p_pos; +} + real_t AStar::get_point_weight_scale(int p_id) const { ERR_FAIL_COND_V(!points.has(p_id), 0); return points[p_id]->weight_scale; } + +void AStar::set_point_weight_scale(int p_id, real_t p_weight_scale) { + + ERR_FAIL_COND(!points.has(p_id)); + ERR_FAIL_COND(p_weight_scale < 1); + + points[p_id]->weight_scale = p_weight_scale; +} + void AStar::remove_point(int p_id) { ERR_FAIL_COND(!points.has(p_id)); @@ -130,6 +149,7 @@ bool AStar::has_point(int p_id) const { } Array AStar::get_points() { + Array point_list; for (const Map<int, Point *>::Element *E = points.front(); E; E = E->next()) { @@ -139,6 +159,21 @@ Array AStar::get_points() { return point_list; } +PoolVector<int> AStar::get_point_connections(int p_id) { + + ERR_FAIL_COND_V(!points.has(p_id), PoolVector<int>()); + + PoolVector<int> point_list; + + Point *p = points[p_id]; + + for (int i = 0; i < p->neighbours.size(); i++) { + point_list.push_back(p->neighbours[i]->id); + } + + return point_list; +} + bool AStar::are_points_connected(int p_id, int p_with_id) const { Segment s(p_id, p_with_id); @@ -171,6 +206,7 @@ int AStar::get_closest_point(const Vector3 &p_point) const { return closest_id; } + Vector3 AStar::get_closest_position_in_segment(const Vector3 &p_point) const { real_t closest_dist = 1e20; @@ -222,15 +258,15 @@ bool AStar::_solve(Point *begin_point, Point *end_point) { while (!found_route) { if (open_list.first() == NULL) { - //could not find path sadly + // No path found break; } - //check open list + // Check open list SelfList<Point> *least_cost_point = NULL; real_t least_cost = 1e30; - //this could be faster (cache previous results) + // TODO: Cache previous results for (SelfList<Point> *E = open_list.first(); E; E = E->next()) { Point *p = E->self(); @@ -246,7 +282,7 @@ bool AStar::_solve(Point *begin_point, Point *end_point) { } Point *p = least_cost_point->self(); - //open the neighbours for search + // Open the neighbours for search int es = p->neighbours.size(); for (int i = 0; i < es; i++) { @@ -256,7 +292,7 @@ bool AStar::_solve(Point *begin_point, Point *end_point) { real_t distance = _compute_cost(p->id, e->id) * e->weight_scale + p->distance; if (e->last_pass == pass) { - //oh this was visited already, can we win the cost? + // Already visited, is this cheaper? if (e->distance > distance) { @@ -264,15 +300,15 @@ bool AStar::_solve(Point *begin_point, Point *end_point) { e->distance = distance; } } else { - //add to open neighbours + // Add to open neighbours e->prev_point = p; e->distance = distance; - e->last_pass = pass; //mark as used + e->last_pass = pass; // Mark as used open_list.add(&e->list); if (e == end_point) { - //oh my reached end! stop algorithm + // End reached; stop algorithm found_route = true; break; } @@ -285,7 +321,7 @@ bool AStar::_solve(Point *begin_point, Point *end_point) { open_list.remove(least_cost_point); } - //clear the openf list + // Clear the openf list while (open_list.first()) { open_list.remove(open_list.first()); } @@ -294,6 +330,7 @@ bool AStar::_solve(Point *begin_point, Point *end_point) { } float AStar::_estimate_cost(int p_from_id, int p_to_id) { + if (get_script_instance() && get_script_instance()->has_method(SceneStringNames::get_singleton()->_estimate_cost)) return get_script_instance()->call(SceneStringNames::get_singleton()->_estimate_cost, p_from_id, p_to_id); @@ -301,6 +338,7 @@ float AStar::_estimate_cost(int p_from_id, int p_to_id) { } float AStar::_compute_cost(int p_from_id, int p_to_id) { + if (get_script_instance() && get_script_instance()->has_method(SceneStringNames::get_singleton()->_compute_cost)) return get_script_instance()->call(SceneStringNames::get_singleton()->_compute_cost, p_from_id, p_to_id); @@ -331,9 +369,9 @@ PoolVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) { if (!found_route) return PoolVector<Vector3>(); - //midpoints + // Midpoints Point *p = end_point; - int pc = 1; //begin point + int pc = 1; // Begin point while (p != begin_point) { pc++; p = p->prev_point; @@ -352,7 +390,7 @@ PoolVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) { p = p->prev_point; } - w[0] = p->pos; //assign first + w[0] = p->pos; // Assign first } return path; @@ -382,9 +420,9 @@ PoolVector<int> AStar::get_id_path(int p_from_id, int p_to_id) { if (!found_route) return PoolVector<int>(); - //midpoints + // Midpoints Point *p = end_point; - int pc = 1; //begin point + int pc = 1; // Begin point while (p != begin_point) { pc++; p = p->prev_point; @@ -403,7 +441,7 @@ PoolVector<int> AStar::get_id_path(int p_from_id, int p_to_id) { p = p->prev_point; } - w[0] = p->id; //assign first + w[0] = p->id; // Assign first } return path; @@ -414,11 +452,15 @@ void AStar::_bind_methods() { ClassDB::bind_method(D_METHOD("get_available_point_id"), &AStar::get_available_point_id); ClassDB::bind_method(D_METHOD("add_point", "id", "position", "weight_scale"), &AStar::add_point, DEFVAL(1.0)); ClassDB::bind_method(D_METHOD("get_point_position", "id"), &AStar::get_point_position); + ClassDB::bind_method(D_METHOD("set_point_position", "id", "position"), &AStar::set_point_position); ClassDB::bind_method(D_METHOD("get_point_weight_scale", "id"), &AStar::get_point_weight_scale); + ClassDB::bind_method(D_METHOD("set_point_weight_scale", "id", "weight_scale"), &AStar::set_point_weight_scale); ClassDB::bind_method(D_METHOD("remove_point", "id"), &AStar::remove_point); ClassDB::bind_method(D_METHOD("has_point", "id"), &AStar::has_point); ClassDB::bind_method(D_METHOD("get_points"), &AStar::get_points); + ClassDB::bind_method(D_METHOD("get_point_connections"), &AStar::get_point_connections); + ClassDB::bind_method(D_METHOD("connect_points", "id", "to_id", "bidirectional"), &AStar::connect_points, DEFVAL(true)); ClassDB::bind_method(D_METHOD("disconnect_points", "id", "to_id"), &AStar::disconnect_points); ClassDB::bind_method(D_METHOD("are_points_connected", "id", "to_id"), &AStar::are_points_connected); diff --git a/core/math/a_star.h b/core/math/a_star.h index 2c1e2e2cf7..b7b7e54125 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -33,6 +33,8 @@ #include "reference.h" #include "self_list.h" /** + A* pathfinding algorithm + @author Juan Linietsky <reduzio@gmail.com> */ @@ -53,7 +55,7 @@ class AStar : public Reference { Vector<Point *> neighbours; - //used for pathfinding + // Used for pathfinding Point *prev_point; real_t distance; @@ -102,9 +104,12 @@ public: void add_point(int p_id, const Vector3 &p_pos, real_t p_weight_scale = 1); Vector3 get_point_position(int p_id) const; + void set_point_position(int p_id, const Vector3 &p_pos); real_t get_point_weight_scale(int p_id) const; + void set_point_weight_scale(int p_id, real_t p_weight_scale); void remove_point(int p_id); bool has_point(int p_id) const; + PoolVector<int> get_point_connections(int p_id); Array get_points(); void connect_points(int p_id, int p_with_id, bool bidirectional = true); diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp index 6fb688f16b..64e01e5841 100644 --- a/core/math/math_funcs.cpp +++ b/core/math/math_funcs.cpp @@ -176,3 +176,18 @@ float Math::random(float from, float to) { float ret = (float)r / (float)RANDOM_MAX; return (ret) * (to - from) + from; } + +int Math::wrapi(int value, int min, int max) { + --max; + int rng = max - min + 1; + value = ((value - min) % rng); + if (value < 0) + return max + 1 + value; + else + return min + value; +} + +float Math::wrapf(float value, float min, float max) { + float rng = max - min; + return min + (value - min) - (rng * floor((value - min) / rng)); +} diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 65b2ffb0df..7715e5d6e5 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -207,6 +207,9 @@ public: static _ALWAYS_INLINE_ double round(double p_val) { return (p_val >= 0) ? Math::floor(p_val + 0.5) : -Math::floor(-p_val + 0.5); } static _ALWAYS_INLINE_ float round(float p_val) { return (p_val >= 0) ? Math::floor(p_val + 0.5) : -Math::floor(-p_val + 0.5); } + static int wrapi(int value, int min, int max); + static float wrapf(float value, float min, float max); + // double only, as these functions are mainly used by the editor and not performance-critical, static double ease(double p_x, double p_c); static int step_decimals(double p_step); @@ -268,7 +271,7 @@ public: #elif defined(_MSC_VER) && _MSC_VER < 1800 __asm fld a __asm fistp b -/*#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) + /*#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) // use AT&T inline assembly style, document that // we use memory as output (=m) and input (m) __asm__ __volatile__ ( diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp index 85421c074b..ab3bca79ae 100644 --- a/core/math/matrix3.cpp +++ b/core/math/matrix3.cpp @@ -279,7 +279,7 @@ Vector3 Basis::get_signed_scale() const { // Decomposes a Basis into a rotation-reflection matrix (an element of the group O(3)) and a positive scaling matrix as B = O.S. // Returns the rotation-reflection matrix via reference argument, and scaling information is returned as a Vector3. -// This (internal) function is too specıfıc and named too ugly to expose to users, and probably there's no need to do so. +// This (internal) function is too specific and named too ugly to expose to users, and probably there's no need to do so. Vector3 Basis::rotref_posscale_decomposition(Basis &rotref) const { #ifdef MATH_CHECKS ERR_FAIL_COND_V(determinant() == 0, Vector3()); @@ -371,31 +371,30 @@ Vector3 Basis::get_euler_xyz() const { #ifdef MATH_CHECKS ERR_FAIL_COND_V(is_rotation() == false, euler); #endif - euler.y = Math::asin(elements[0][2]); - if (euler.y < Math_PI * 0.5) { - if (euler.y > -Math_PI * 0.5) { + real_t sy = elements[0][2]; + if (sy < 1.0) { + if (sy > -1.0) { // is this a pure Y rotation? if (elements[1][0] == 0.0 && elements[0][1] == 0.0 && elements[1][2] == 0 && elements[2][1] == 0 && elements[1][1] == 1) { - // return the simplest form + // return the simplest form (human friendlier in editor and scripts) euler.x = 0; euler.y = atan2(elements[0][2], elements[0][0]); euler.z = 0; } else { euler.x = Math::atan2(-elements[1][2], elements[2][2]); + euler.y = Math::asin(sy); euler.z = Math::atan2(-elements[0][1], elements[0][0]); } - } else { - real_t r = Math::atan2(elements[1][0], elements[1][1]); + euler.x = -Math::atan2(elements[0][1], elements[1][1]); + euler.y = -Math_PI / 2.0; euler.z = 0.0; - euler.x = euler.z - r; } } else { - real_t r = Math::atan2(elements[0][1], elements[1][1]); - euler.z = 0; - euler.x = r - euler.z; + euler.x = Math::atan2(elements[0][1], elements[1][1]); + euler.y = Math_PI / 2.0; + euler.z = 0.0; } - return euler; } @@ -445,7 +444,7 @@ Vector3 Basis::get_euler_yxz() const { if (m12 > -1) { // is this a pure X rotation? if (elements[1][0] == 0 && elements[0][1] == 0 && elements[0][2] == 0 && elements[2][0] == 0 && elements[0][0] == 1) { - // return the simplest form + // return the simplest form (human friendlier in editor and scripts) euler.x = atan2(-m12, elements[1][1]); euler.y = 0; euler.z = 0; diff --git a/core/ordered_hash_map.h b/core/ordered_hash_map.h index 9e95f963e1..1ed5a5d369 100644 --- a/core/ordered_hash_map.h +++ b/core/ordered_hash_map.h @@ -93,8 +93,12 @@ public: return *this; } - friend bool operator==(const Element &, const Element &); - friend bool operator!=(const Element &, const Element &); + _FORCE_INLINE_ bool operator==(const Element &p_other) const { + return this->list_element == p_other.list_element; + } + _FORCE_INLINE_ bool operator!=(const Element &p_other) const { + return this->list_element != p_other.list_element; + } operator bool() const { return (list_element != NULL); @@ -157,8 +161,12 @@ public: return ConstElement(list_element ? list_element->prev() : NULL); } - friend bool operator==(const ConstElement &, const ConstElement &); - friend bool operator!=(const ConstElement &, const ConstElement &); + _FORCE_INLINE_ bool operator==(const ConstElement &p_other) const { + return this->list_element == p_other.list_element; + } + _FORCE_INLINE_ bool operator!=(const ConstElement &p_other) const { + return this->list_element != p_other.list_element; + } operator bool() const { return (list_element != NULL); @@ -181,7 +189,7 @@ public: }; ConstElement find(const K &p_key) const { - typename InternalList::Element **list_element = map.getptr(p_key); + typename InternalList::Element *const *list_element = map.getptr(p_key); if (list_element) { return ConstElement(*list_element); } @@ -288,28 +296,4 @@ public: } }; -template <class K, class V, class Hasher, class Comparator, uint8_t MIN_HASH_TABLE_POWER, uint8_t RELATIONSHIP> -bool operator==(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::Element &first, - const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::Element &second) { - return (first.list_element == second.list_element); -} - -template <class K, class V, class Hasher, class Comparator, uint8_t MIN_HASH_TABLE_POWER, uint8_t RELATIONSHIP> -bool operator!=(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::Element &first, - const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::Element &second) { - return (first.list_element != second.list_element); -} - -template <class K, class V, class Hasher, class Comparator, uint8_t MIN_HASH_TABLE_POWER, uint8_t RELATIONSHIP> -bool operator==(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::ConstElement &first, - const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::ConstElement &second) { - return (first.list_element == second.list_element); -} - -template <class K, class V, class Hasher, class Comparator, uint8_t MIN_HASH_TABLE_POWER, uint8_t RELATIONSHIP> -bool operator!=(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::ConstElement &first, - const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::ConstElement &second) { - return (first.list_element != second.list_element); -} - #endif // ORDERED_HASH_MAP_H diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp index 30e7d5e791..edf4f3e2f9 100644 --- a/core/os/keyboard.cpp +++ b/core/os/keyboard.cpp @@ -505,6 +505,27 @@ static const _KeyCodeReplace _keycode_replace_neo[] = { { 0, 0 } }; +static const _KeyCodeReplace _keycode_replace_colemak[] = { + { KEY_E, KEY_F }, + { KEY_R, KEY_P }, + { KEY_T, KEY_G }, + { KEY_Y, KEY_J }, + { KEY_U, KEY_L }, + { KEY_I, KEY_U }, + { KEY_O, KEY_Y }, + { KEY_P, KEY_SEMICOLON }, + { KEY_S, KEY_R }, + { KEY_D, KEY_S }, + { KEY_F, KEY_T }, + { KEY_G, KEY_D }, + { KEY_J, KEY_N }, + { KEY_K, KEY_E }, + { KEY_L, KEY_I }, + { KEY_SEMICOLON, KEY_O }, + { KEY_N, KEY_K }, + { 0, 0 } +}; + int keycode_get_count() { const _KeyCodeText *kct = &_keycodes[0]; @@ -537,6 +558,7 @@ int latin_keyboard_keycode_convert(int p_keycode) { case OS::LATIN_KEYBOARD_QZERTY: kcr = _keycode_replace_qzerty; break; case OS::LATIN_KEYBOARD_DVORAK: kcr = _keycode_replace_dvorak; break; case OS::LATIN_KEYBOARD_NEO: kcr = _keycode_replace_neo; break; + case OS::LATIN_KEYBOARD_COLEMAK: kcr = _keycode_replace_colemak; break; default: return p_keycode; } diff --git a/core/os/os.h b/core/os/os.h index 48effe99da..f5e479ac0b 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -409,6 +409,7 @@ public: LATIN_KEYBOARD_QZERTY, LATIN_KEYBOARD_DVORAK, LATIN_KEYBOARD_NEO, + LATIN_KEYBOARD_COLEMAK, }; virtual LatinKeyboardVariant get_latin_keyboard_variant() const; diff --git a/core/project_settings.cpp b/core/project_settings.cpp index c4d1b199a0..2e4fc26784 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -1036,10 +1036,16 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("debug/settings/profiler/max_functions", 16384); //assigning here, because using GLOBAL_GET on every block for compressing can be slow + Compression::zstd_long_distance_matching = GLOBAL_DEF("compression/formats/zstd/long_distance_matching", false); + custom_prop_info["compression/formats/zstd/long_distance_matching"] = PropertyInfo(Variant::BOOL, "compression/formats/zstd/long_distance_matching"); Compression::zstd_level = GLOBAL_DEF("compression/formats/zstd/compression_level", 3); custom_prop_info["compression/formats/zstd/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/zstd/compression_level", PROPERTY_HINT_RANGE, "1,22,1"); + Compression::zstd_window_log_size = GLOBAL_DEF("compression/formats/zstd/window_log_size", 27); + custom_prop_info["compression/formats/zstd/window_log_size"] = PropertyInfo(Variant::INT, "compression/formats/zstd/window_log_size", PROPERTY_HINT_RANGE, "10,30,1"); + Compression::zlib_level = GLOBAL_DEF("compression/formats/zlib/compression_level", Z_DEFAULT_COMPRESSION); custom_prop_info["compression/formats/zlib/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/zlib/compression_level", PROPERTY_HINT_RANGE, "-1,9,1"); + Compression::gzip_level = GLOBAL_DEF("compression/formats/gzip/compression_level", Z_DEFAULT_COMPRESSION); custom_prop_info["compression/formats/gzip/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/gzip/compression_level", PROPERTY_HINT_RANGE, "-1,9,1"); diff --git a/core/translation.cpp b/core/translation.cpp index 54dbaf6ed5..058db956e5 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -753,65 +753,17 @@ static const char *locale_names[] = { 0 }; -bool TranslationServer::is_locale_valid(const String &p_locale) { - - const char **ptr = locale_list; - - while (*ptr) { - - if (*ptr == p_locale) - return true; - ptr++; - } - - return false; -} - -Vector<String> TranslationServer::get_all_locales() { - - Vector<String> locales; - - const char **ptr = locale_list; - - while (*ptr) { - locales.push_back(*ptr); - ptr++; - } - - return locales; -} - -Vector<String> TranslationServer::get_all_locale_names() { - - Vector<String> locales; - - const char **ptr = locale_names; - - while (*ptr) { - locales.push_back(*ptr); - ptr++; - } - - return locales; -} +static const char *locale_renames[][2] = { + { "no", "nb" }, + { NULL, NULL } +}; static String get_trimmed_locale(const String &p_locale) { return p_locale.substr(0, 2); } -static bool is_valid_locale(const String &p_locale) { - - const char **ptr = locale_list; - - while (*ptr) { - if (p_locale == *ptr) - return true; - ptr++; - } - - return false; -} +/////////////////////////////////////////////// PoolVector<String> Translation::_get_messages() const { @@ -857,14 +809,13 @@ void Translation::_set_messages(const PoolVector<String> &p_messages) { void Translation::set_locale(const String &p_locale) { - // replaces '-' with '_' for macOS Sierra-style locales - String univ_locale = p_locale.replace("-", "_"); + String univ_locale = TranslationServer::standardize_locale(p_locale); - if (!is_valid_locale(univ_locale)) { + if (!TranslationServer::is_locale_valid(univ_locale)) { String trimmed_locale = get_trimmed_locale(univ_locale); - ERR_EXPLAIN("Invalid Locale: " + trimmed_locale); - ERR_FAIL_COND(!is_valid_locale(trimmed_locale)); + ERR_EXPLAIN("Invalid locale: " + trimmed_locale); + ERR_FAIL_COND(!TranslationServer::is_locale_valid(trimmed_locale)); locale = trimmed_locale; } else { @@ -929,16 +880,47 @@ Translation::Translation() /////////////////////////////////////////////// -void TranslationServer::set_locale(const String &p_locale) { +bool TranslationServer::is_locale_valid(const String &p_locale) { + + const char **ptr = locale_list; + + while (*ptr) { + + if (*ptr == p_locale) + return true; + ptr++; + } + + return false; +} - // replaces '-' with '_' for macOS Sierra-style locales +String TranslationServer::standardize_locale(const String &p_locale) { + + // Replaces '-' with '_' for macOS Sierra-style locales String univ_locale = p_locale.replace("-", "_"); - if (!is_valid_locale(univ_locale)) { + // Handles known non-ISO locale names used e.g. on Windows + int idx = 0; + while (locale_renames[idx][0] != NULL) { + if (locale_renames[idx][0] == univ_locale) { + univ_locale = locale_renames[idx][1]; + break; + } + idx++; + } + + return univ_locale; +} + +void TranslationServer::set_locale(const String &p_locale) { + + String univ_locale = standardize_locale(p_locale); + + if (!is_locale_valid(univ_locale)) { String trimmed_locale = get_trimmed_locale(univ_locale); - ERR_EXPLAIN("Invalid Locale: " + trimmed_locale); - ERR_FAIL_COND(!is_valid_locale(trimmed_locale)); + ERR_EXPLAIN("Invalid locale: " + trimmed_locale); + ERR_FAIL_COND(!is_locale_valid(trimmed_locale)); locale = trimmed_locale; } else { @@ -963,6 +945,34 @@ String TranslationServer::get_locale_name(const String &p_locale) const { return locale_name_map[p_locale]; } +Vector<String> TranslationServer::get_all_locales() { + + Vector<String> locales; + + const char **ptr = locale_list; + + while (*ptr) { + locales.push_back(*ptr); + ptr++; + } + + return locales; +} + +Vector<String> TranslationServer::get_all_locale_names() { + + Vector<String> locales; + + const char **ptr = locale_names; + + while (*ptr) { + locales.push_back(*ptr); + ptr++; + } + + return locales; +} + void TranslationServer::add_translation(const Ref<Translation> &p_translation) { translations.insert(p_translation); diff --git a/core/translation.h b/core/translation.h index 5fec1d9f45..0cdab3b0bc 100644 --- a/core/translation.h +++ b/core/translation.h @@ -85,8 +85,6 @@ class TranslationServer : public Object { public: _FORCE_INLINE_ static TranslationServer *get_singleton() { return singleton; } - //yes, portuguese is supported! - void set_enabled(bool p_enabled) { enabled = p_enabled; } _FORCE_INLINE_ bool is_enabled() const { return enabled; } @@ -103,6 +101,7 @@ public: static Vector<String> get_all_locales(); static Vector<String> get_all_locale_names(); static bool is_locale_valid(const String &p_locale); + static String standardize_locale(const String &p_locale); void set_tool_translation(const Ref<Translation> &p_translation); StringName tool_translate(const StringName &p_message) const; diff --git a/core/ustring.cpp b/core/ustring.cpp index b85996e3d1..415494ddc8 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -2476,6 +2476,11 @@ bool String::begins_with(const char *p_string) const { return *p_string == 0; } +bool String::is_enclosed_in(const String &p_string) const { + + return begins_with(p_string) && ends_with(p_string); +} + bool String::is_subsequence_of(const String &p_string) const { return _base_is_subsequence_of(p_string, false); @@ -2486,6 +2491,11 @@ bool String::is_subsequence_ofi(const String &p_string) const { return _base_is_subsequence_of(p_string, true); } +bool String::is_quoted() const { + + return is_enclosed_in("\"") || is_enclosed_in("'"); +} + bool String::_base_is_subsequence_of(const String &p_string, bool case_insensitive) const { int len = length(); @@ -2747,6 +2757,48 @@ CharType String::ord_at(int p_idx) const { return operator[](p_idx); } +String String::dedent() const { + + String new_string; + String indent; + bool has_indent = false; + bool has_text = false; + int line_start = 0; + int indent_stop = -1; + + for (int i = 0; i < length(); i++) { + + CharType c = operator[](i); + if (c == '\n') { + if (has_text) + new_string += substr(indent_stop, i - indent_stop); + new_string += "\n"; + has_text = false; + line_start = i + 1; + indent_stop = -1; + } else if (!has_text) { + if (c > 32) { + has_text = true; + if (!has_indent) { + has_indent = true; + indent = substr(line_start, i - line_start); + indent_stop = i; + } + } + if (has_indent && indent_stop < 0) { + int j = i - line_start; + if (j >= indent.length() || c != indent[j]) + indent_stop = i; + } + } + } + + if (has_text) + new_string += substr(indent_stop, length() - indent_stop); + + return new_string; +} + String String::strip_edges(bool left, bool right) const { int len = length(); @@ -3906,6 +3958,18 @@ String String::sprintf(const Array &values, bool *error) const { return formatted; } +String String::quote(String quotechar) const { + return quotechar + *this + quotechar; +} + +String String::unquote() const { + if (!is_quoted()) { + return *this; + } + + return substr(1, length() - 2); +} + #include "translation.h" #ifdef TOOLS_ENABLED diff --git a/core/ustring.h b/core/ustring.h index ab4e325f2c..353c8e6c1d 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -118,8 +118,10 @@ public: bool begins_with(const String &p_string) const; bool begins_with(const char *p_string) const; bool ends_with(const String &p_string) const; + bool is_enclosed_in(const String &p_string) const; bool is_subsequence_of(const String &p_string) const; bool is_subsequence_ofi(const String &p_string) const; + bool is_quoted() const; Vector<String> bigrams() const; float similarity(const String &p_string) const; String format(const Variant &values, String placeholder = "{_}") const; @@ -132,6 +134,8 @@ public: String lpad(int min_length, const String &character = " ") const; String rpad(int min_length, const String &character = " ") const; String sprintf(const Array &values, bool *error) const; + String quote(String quotechar = "\"") const; + String unquote() const; static String num(double p_num, int p_decimals = -1); static String num_scientific(double p_num); static String num_real(double p_num); @@ -172,6 +176,7 @@ public: String left(int p_pos) const; String right(int p_pos) const; + String dedent() const; String strip_edges(bool left = true, bool right = true) const; String strip_escapes() const; String get_extension() const; diff --git a/core/variant_call.cpp b/core/variant_call.cpp index d141621fbb..05f0478003 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -54,9 +54,8 @@ struct _VariantCall { Variant::Type return_type; bool _const; -#ifdef DEBUG_ENABLED bool returns; -#endif + VariantFunc func; _FORCE_INLINE_ bool verify_arguments(const Variant **p_args, Variant::CallError &r_error) { @@ -146,7 +145,7 @@ struct _VariantCall { #endif } - static void addfunc(bool p_const, Variant::Type p_type, Variant::Type p_return, const StringName &p_name, VariantFunc p_func, const Vector<Variant> &p_defaultarg, const Arg &p_argtype1 = Arg(), const Arg &p_argtype2 = Arg(), const Arg &p_argtype3 = Arg(), const Arg &p_argtype4 = Arg(), const Arg &p_argtype5 = Arg()) { + static void addfunc(bool p_const, Variant::Type p_type, Variant::Type p_return, bool p_has_return, const StringName &p_name, VariantFunc p_func, const Vector<Variant> &p_defaultarg, const Arg &p_argtype1 = Arg(), const Arg &p_argtype2 = Arg(), const Arg &p_argtype3 = Arg(), const Arg &p_argtype4 = Arg(), const Arg &p_argtype5 = Arg()) { FuncData funcdata; funcdata.func = p_func; @@ -154,7 +153,7 @@ struct _VariantCall { funcdata._const = p_const; #ifdef DEBUG_ENABLED funcdata.return_type = p_return; - funcdata.returns = p_return != Variant::NIL; + funcdata.returns = p_has_return; #endif if (p_argtype1.name) { @@ -261,6 +260,7 @@ struct _VariantCall { VCALL_LOCALMEM0R(String, to_lower); VCALL_LOCALMEM1R(String, left); VCALL_LOCALMEM1R(String, right); + VCALL_LOCALMEM0R(String, dedent); VCALL_LOCALMEM2R(String, strip_edges); VCALL_LOCALMEM0R(String, get_extension); VCALL_LOCALMEM0R(String, get_basename); @@ -1051,7 +1051,6 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i return String(); // math types - case VECTOR2: return Vector2(); // 5 case RECT2: return Rect2(); @@ -1234,7 +1233,7 @@ Variant::Type Variant::get_method_return_type(Variant::Type p_type, const String return Variant::NIL; if (r_has_return) - *r_has_return = E->get().return_type; + *r_has_return = E->get().returns; return E->get().return_type; } @@ -1376,215 +1375,238 @@ void register_variant_methods() { _VariantCall::construct_funcs = memnew_arr(_VariantCall::ConstructFunc, Variant::VARIANT_MAX); _VariantCall::constant_data = memnew_arr(_VariantCall::ConstantData, Variant::VARIANT_MAX); +#define ADDFUNC0R(m_vtype, m_ret, m_class, m_method, m_defarg) \ + _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg); +#define ADDFUNC1R(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \ + _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1))); +#define ADDFUNC2R(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \ + _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2))); +#define ADDFUNC3R(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \ + _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3))); +#define ADDFUNC4R(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \ + _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4))); + +#define ADDFUNC0RNC(m_vtype, m_ret, m_class, m_method, m_defarg) \ + _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg); +#define ADDFUNC1RNC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \ + _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1))); +#define ADDFUNC2RNC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \ + _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2))); +#define ADDFUNC3RNC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \ + _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3))); +#define ADDFUNC4RNC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \ + _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4))); + #define ADDFUNC0(m_vtype, m_ret, m_class, m_method, m_defarg) \ - _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg); + _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg); #define ADDFUNC1(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \ - _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1))); + _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1))); #define ADDFUNC2(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \ - _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2))); + _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2))); #define ADDFUNC3(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \ - _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3))); + _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3))); #define ADDFUNC4(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \ - _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4))); + _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4))); #define ADDFUNC0NC(m_vtype, m_ret, m_class, m_method, m_defarg) \ - _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg); + _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg); #define ADDFUNC1NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \ - _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1))); + _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1))); #define ADDFUNC2NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \ - _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2))); + _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2))); #define ADDFUNC3NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \ - _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3))); + _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3))); #define ADDFUNC4NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \ - _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4))); + _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4))); /* STRING */ - ADDFUNC1(STRING, INT, String, casecmp_to, STRING, "to", varray()); - ADDFUNC1(STRING, INT, String, nocasecmp_to, STRING, "to", varray()); - ADDFUNC0(STRING, INT, String, length, varray()); - ADDFUNC2(STRING, STRING, String, substr, INT, "from", INT, "len", varray()); - - ADDFUNC2(STRING, INT, String, find, STRING, "what", INT, "from", varray(0)); - - ADDFUNC1(STRING, INT, String, find_last, STRING, "what", varray()); - ADDFUNC2(STRING, INT, String, findn, STRING, "what", INT, "from", varray(0)); - ADDFUNC2(STRING, INT, String, rfind, STRING, "what", INT, "from", varray(-1)); - ADDFUNC2(STRING, INT, String, rfindn, STRING, "what", INT, "from", varray(-1)); - ADDFUNC1(STRING, BOOL, String, match, STRING, "expr", varray()); - ADDFUNC1(STRING, BOOL, String, matchn, STRING, "expr", varray()); - ADDFUNC1(STRING, BOOL, String, begins_with, STRING, "text", varray()); - ADDFUNC1(STRING, BOOL, String, ends_with, STRING, "text", varray()); - ADDFUNC1(STRING, BOOL, String, is_subsequence_of, STRING, "text", varray()); - ADDFUNC1(STRING, BOOL, String, is_subsequence_ofi, STRING, "text", varray()); - ADDFUNC0(STRING, POOL_STRING_ARRAY, String, bigrams, varray()); - ADDFUNC1(STRING, REAL, String, similarity, STRING, "text", varray()); - - ADDFUNC2(STRING, STRING, String, format, NIL, "values", STRING, "placeholder", varray("{_}")); - ADDFUNC2(STRING, STRING, String, replace, STRING, "what", STRING, "forwhat", varray()); - ADDFUNC2(STRING, STRING, String, replacen, STRING, "what", STRING, "forwhat", varray()); - ADDFUNC2(STRING, STRING, String, insert, INT, "position", STRING, "what", varray()); - ADDFUNC0(STRING, STRING, String, capitalize, varray()); - ADDFUNC2(STRING, POOL_STRING_ARRAY, String, split, STRING, "divisor", BOOL, "allow_empty", varray(true)); - ADDFUNC2(STRING, POOL_REAL_ARRAY, String, split_floats, STRING, "divisor", BOOL, "allow_empty", varray(true)); - - ADDFUNC0(STRING, STRING, String, to_upper, varray()); - ADDFUNC0(STRING, STRING, String, to_lower, varray()); - - ADDFUNC1(STRING, STRING, String, left, INT, "position", varray()); - ADDFUNC1(STRING, STRING, String, right, INT, "position", varray()); - ADDFUNC2(STRING, STRING, String, strip_edges, BOOL, "left", BOOL, "right", varray(true, true)); - ADDFUNC0(STRING, STRING, String, get_extension, varray()); - ADDFUNC0(STRING, STRING, String, get_basename, varray()); - ADDFUNC1(STRING, STRING, String, plus_file, STRING, "file", varray()); - ADDFUNC1(STRING, INT, String, ord_at, INT, "at", varray()); + ADDFUNC1R(STRING, INT, String, casecmp_to, STRING, "to", varray()); + ADDFUNC1R(STRING, INT, String, nocasecmp_to, STRING, "to", varray()); + ADDFUNC0R(STRING, INT, String, length, varray()); + ADDFUNC2R(STRING, STRING, String, substr, INT, "from", INT, "len", varray()); + + ADDFUNC2R(STRING, INT, String, find, STRING, "what", INT, "from", varray(0)); + + ADDFUNC1R(STRING, INT, String, find_last, STRING, "what", varray()); + ADDFUNC2R(STRING, INT, String, findn, STRING, "what", INT, "from", varray(0)); + ADDFUNC2R(STRING, INT, String, rfind, STRING, "what", INT, "from", varray(-1)); + ADDFUNC2R(STRING, INT, String, rfindn, STRING, "what", INT, "from", varray(-1)); + ADDFUNC1R(STRING, BOOL, String, match, STRING, "expr", varray()); + ADDFUNC1R(STRING, BOOL, String, matchn, STRING, "expr", varray()); + ADDFUNC1R(STRING, BOOL, String, begins_with, STRING, "text", varray()); + ADDFUNC1R(STRING, BOOL, String, ends_with, STRING, "text", varray()); + ADDFUNC1R(STRING, BOOL, String, is_subsequence_of, STRING, "text", varray()); + ADDFUNC1R(STRING, BOOL, String, is_subsequence_ofi, STRING, "text", varray()); + ADDFUNC0R(STRING, POOL_STRING_ARRAY, String, bigrams, varray()); + ADDFUNC1R(STRING, REAL, String, similarity, STRING, "text", varray()); + + ADDFUNC2R(STRING, STRING, String, format, NIL, "values", STRING, "placeholder", varray("{_}")); + ADDFUNC2R(STRING, STRING, String, replace, STRING, "what", STRING, "forwhat", varray()); + ADDFUNC2R(STRING, STRING, String, replacen, STRING, "what", STRING, "forwhat", varray()); + ADDFUNC2R(STRING, STRING, String, insert, INT, "position", STRING, "what", varray()); + ADDFUNC0R(STRING, STRING, String, capitalize, varray()); + ADDFUNC2R(STRING, POOL_STRING_ARRAY, String, split, STRING, "divisor", BOOL, "allow_empty", varray(true)); + ADDFUNC2R(STRING, POOL_REAL_ARRAY, String, split_floats, STRING, "divisor", BOOL, "allow_empty", varray(true)); + + ADDFUNC0R(STRING, STRING, String, to_upper, varray()); + ADDFUNC0R(STRING, STRING, String, to_lower, varray()); + + ADDFUNC1R(STRING, STRING, String, left, INT, "position", varray()); + ADDFUNC1R(STRING, STRING, String, right, INT, "position", varray()); + ADDFUNC2R(STRING, STRING, String, strip_edges, BOOL, "left", BOOL, "right", varray(true, true)); + ADDFUNC0R(STRING, STRING, String, get_extension, varray()); + ADDFUNC0R(STRING, STRING, String, get_basename, varray()); + ADDFUNC1R(STRING, STRING, String, plus_file, STRING, "file", varray()); + ADDFUNC1R(STRING, INT, String, ord_at, INT, "at", varray()); + ADDFUNC0R(STRING, STRING, String, dedent, varray()); ADDFUNC2(STRING, NIL, String, erase, INT, "position", INT, "chars", varray()); - ADDFUNC0(STRING, INT, String, hash, varray()); - ADDFUNC0(STRING, STRING, String, md5_text, varray()); - ADDFUNC0(STRING, STRING, String, sha256_text, varray()); - ADDFUNC0(STRING, POOL_BYTE_ARRAY, String, md5_buffer, varray()); - ADDFUNC0(STRING, POOL_BYTE_ARRAY, String, sha256_buffer, varray()); - ADDFUNC0(STRING, BOOL, String, empty, varray()); - ADDFUNC0(STRING, BOOL, String, is_abs_path, varray()); - ADDFUNC0(STRING, BOOL, String, is_rel_path, varray()); - ADDFUNC0(STRING, STRING, String, get_base_dir, varray()); - ADDFUNC0(STRING, STRING, String, get_file, varray()); - ADDFUNC0(STRING, STRING, String, xml_escape, varray()); - ADDFUNC0(STRING, STRING, String, xml_unescape, varray()); - ADDFUNC0(STRING, STRING, String, c_escape, varray()); - ADDFUNC0(STRING, STRING, String, c_unescape, varray()); - ADDFUNC0(STRING, STRING, String, json_escape, varray()); - ADDFUNC0(STRING, STRING, String, percent_encode, varray()); - ADDFUNC0(STRING, STRING, String, percent_decode, varray()); - ADDFUNC0(STRING, BOOL, String, is_valid_identifier, varray()); - ADDFUNC0(STRING, BOOL, String, is_valid_integer, varray()); - ADDFUNC0(STRING, BOOL, String, is_valid_float, varray()); - ADDFUNC0(STRING, BOOL, String, is_valid_html_color, varray()); - ADDFUNC0(STRING, BOOL, String, is_valid_ip_address, varray()); - ADDFUNC0(STRING, INT, String, to_int, varray()); - ADDFUNC0(STRING, REAL, String, to_float, varray()); - ADDFUNC0(STRING, INT, String, hex_to_int, varray()); - ADDFUNC1(STRING, STRING, String, pad_decimals, INT, "digits", varray()); - ADDFUNC1(STRING, STRING, String, pad_zeros, INT, "digits", varray()); - - ADDFUNC0(STRING, POOL_BYTE_ARRAY, String, to_ascii, varray()); - ADDFUNC0(STRING, POOL_BYTE_ARRAY, String, to_utf8, varray()); - - ADDFUNC0(VECTOR2, VECTOR2, Vector2, normalized, varray()); - ADDFUNC0(VECTOR2, REAL, Vector2, length, varray()); - ADDFUNC0(VECTOR2, REAL, Vector2, angle, varray()); - ADDFUNC0(VECTOR2, REAL, Vector2, length_squared, varray()); - ADDFUNC0(VECTOR2, BOOL, Vector2, is_normalized, varray()); - ADDFUNC1(VECTOR2, REAL, Vector2, distance_to, VECTOR2, "to", varray()); - ADDFUNC1(VECTOR2, REAL, Vector2, distance_squared_to, VECTOR2, "to", varray()); - ADDFUNC1(VECTOR2, REAL, Vector2, angle_to, VECTOR2, "to", varray()); - ADDFUNC1(VECTOR2, REAL, Vector2, angle_to_point, VECTOR2, "to", varray()); - ADDFUNC2(VECTOR2, VECTOR2, Vector2, linear_interpolate, VECTOR2, "b", REAL, "t", varray()); - ADDFUNC4(VECTOR2, VECTOR2, Vector2, cubic_interpolate, VECTOR2, "b", VECTOR2, "pre_a", VECTOR2, "post_b", REAL, "t", varray()); - ADDFUNC1(VECTOR2, VECTOR2, Vector2, rotated, REAL, "phi", varray()); - ADDFUNC0(VECTOR2, VECTOR2, Vector2, tangent, varray()); - ADDFUNC0(VECTOR2, VECTOR2, Vector2, floor, varray()); - ADDFUNC1(VECTOR2, VECTOR2, Vector2, snapped, VECTOR2, "by", varray()); - ADDFUNC0(VECTOR2, REAL, Vector2, aspect, varray()); - ADDFUNC1(VECTOR2, REAL, Vector2, dot, VECTOR2, "with", varray()); - ADDFUNC1(VECTOR2, VECTOR2, Vector2, slide, VECTOR2, "n", varray()); - ADDFUNC1(VECTOR2, VECTOR2, Vector2, bounce, VECTOR2, "n", varray()); - ADDFUNC1(VECTOR2, VECTOR2, Vector2, reflect, VECTOR2, "n", varray()); - //ADDFUNC1(VECTOR2,REAL,Vector2,cross,VECTOR2,"with",varray()); - ADDFUNC0(VECTOR2, VECTOR2, Vector2, abs, varray()); - ADDFUNC1(VECTOR2, VECTOR2, Vector2, clamped, REAL, "length", varray()); - - ADDFUNC0(RECT2, REAL, Rect2, get_area, varray()); - ADDFUNC1(RECT2, BOOL, Rect2, intersects, RECT2, "b", varray()); - ADDFUNC1(RECT2, BOOL, Rect2, encloses, RECT2, "b", varray()); - ADDFUNC0(RECT2, BOOL, Rect2, has_no_area, varray()); - ADDFUNC1(RECT2, RECT2, Rect2, clip, RECT2, "b", varray()); - ADDFUNC1(RECT2, RECT2, Rect2, merge, RECT2, "b", varray()); - ADDFUNC1(RECT2, BOOL, Rect2, has_point, VECTOR2, "point", varray()); - ADDFUNC1(RECT2, RECT2, Rect2, grow, REAL, "by", varray()); - ADDFUNC2(RECT2, RECT2, Rect2, grow_margin, INT, "margin", REAL, "by", varray()); - ADDFUNC4(RECT2, RECT2, Rect2, grow_individual, REAL, "left", REAL, "top", REAL, "right", REAL, " bottom", varray()); - ADDFUNC1(RECT2, RECT2, Rect2, expand, VECTOR2, "to", varray()); - - ADDFUNC0(VECTOR3, INT, Vector3, min_axis, varray()); - ADDFUNC0(VECTOR3, INT, Vector3, max_axis, varray()); - ADDFUNC0(VECTOR3, REAL, Vector3, length, varray()); - ADDFUNC0(VECTOR3, REAL, Vector3, length_squared, varray()); - ADDFUNC0(VECTOR3, BOOL, Vector3, is_normalized, varray()); - ADDFUNC0(VECTOR3, VECTOR3, Vector3, normalized, varray()); - ADDFUNC0(VECTOR3, VECTOR3, Vector3, inverse, varray()); - ADDFUNC1(VECTOR3, VECTOR3, Vector3, snapped, REAL, "by", varray()); - ADDFUNC2(VECTOR3, VECTOR3, Vector3, rotated, VECTOR3, "axis", REAL, "phi", varray()); - ADDFUNC2(VECTOR3, VECTOR3, Vector3, linear_interpolate, VECTOR3, "b", REAL, "t", varray()); - ADDFUNC4(VECTOR3, VECTOR3, Vector3, cubic_interpolate, VECTOR3, "b", VECTOR3, "pre_a", VECTOR3, "post_b", REAL, "t", varray()); - ADDFUNC1(VECTOR3, REAL, Vector3, dot, VECTOR3, "b", varray()); - ADDFUNC1(VECTOR3, VECTOR3, Vector3, cross, VECTOR3, "b", varray()); - ADDFUNC1(VECTOR3, BASIS, Vector3, outer, VECTOR3, "b", varray()); - ADDFUNC0(VECTOR3, BASIS, Vector3, to_diagonal_matrix, varray()); - ADDFUNC0(VECTOR3, VECTOR3, Vector3, abs, varray()); - ADDFUNC0(VECTOR3, VECTOR3, Vector3, floor, varray()); - ADDFUNC0(VECTOR3, VECTOR3, Vector3, ceil, varray()); - ADDFUNC1(VECTOR3, REAL, Vector3, distance_to, VECTOR3, "b", varray()); - ADDFUNC1(VECTOR3, REAL, Vector3, distance_squared_to, VECTOR3, "b", varray()); - ADDFUNC1(VECTOR3, REAL, Vector3, angle_to, VECTOR3, "to", varray()); - ADDFUNC1(VECTOR3, VECTOR3, Vector3, slide, VECTOR3, "n", varray()); - ADDFUNC1(VECTOR3, VECTOR3, Vector3, bounce, VECTOR3, "n", varray()); - ADDFUNC1(VECTOR3, VECTOR3, Vector3, reflect, VECTOR3, "n", varray()); - - ADDFUNC0(PLANE, PLANE, Plane, normalized, varray()); - ADDFUNC0(PLANE, VECTOR3, Plane, center, varray()); - ADDFUNC0(PLANE, VECTOR3, Plane, get_any_point, varray()); - ADDFUNC1(PLANE, BOOL, Plane, is_point_over, VECTOR3, "point", varray()); - ADDFUNC1(PLANE, REAL, Plane, distance_to, VECTOR3, "point", varray()); - ADDFUNC2(PLANE, BOOL, Plane, has_point, VECTOR3, "point", REAL, "epsilon", varray(CMP_EPSILON)); - ADDFUNC1(PLANE, VECTOR3, Plane, project, VECTOR3, "point", varray()); - ADDFUNC2(PLANE, VECTOR3, Plane, intersect_3, PLANE, "b", PLANE, "c", varray()); - ADDFUNC2(PLANE, VECTOR3, Plane, intersects_ray, VECTOR3, "from", VECTOR3, "dir", varray()); - ADDFUNC2(PLANE, VECTOR3, Plane, intersects_segment, VECTOR3, "begin", VECTOR3, "end", varray()); - - ADDFUNC0(QUAT, REAL, Quat, length, varray()); - ADDFUNC0(QUAT, REAL, Quat, length_squared, varray()); - ADDFUNC0(QUAT, QUAT, Quat, normalized, varray()); - ADDFUNC0(QUAT, BOOL, Quat, is_normalized, varray()); - ADDFUNC0(QUAT, QUAT, Quat, inverse, varray()); - ADDFUNC1(QUAT, REAL, Quat, dot, QUAT, "b", varray()); - ADDFUNC1(QUAT, VECTOR3, Quat, xform, VECTOR3, "v", varray()); - ADDFUNC2(QUAT, QUAT, Quat, slerp, QUAT, "b", REAL, "t", varray()); - ADDFUNC2(QUAT, QUAT, Quat, slerpni, QUAT, "b", REAL, "t", varray()); - ADDFUNC4(QUAT, QUAT, Quat, cubic_slerp, QUAT, "b", QUAT, "pre_a", QUAT, "post_b", REAL, "t", varray()); - - ADDFUNC0(COLOR, INT, Color, to_rgba32, varray()); - ADDFUNC0(COLOR, INT, Color, to_argb32, varray()); - ADDFUNC0(COLOR, REAL, Color, gray, varray()); - ADDFUNC0(COLOR, COLOR, Color, inverted, varray()); - ADDFUNC0(COLOR, COLOR, Color, contrasted, varray()); - ADDFUNC2(COLOR, COLOR, Color, linear_interpolate, COLOR, "b", REAL, "t", varray()); - ADDFUNC1(COLOR, COLOR, Color, blend, COLOR, "over", varray()); - ADDFUNC1(COLOR, STRING, Color, to_html, BOOL, "with_alpha", varray(true)); - - ADDFUNC0(_RID, INT, RID, get_id, varray()); - - ADDFUNC0(NODE_PATH, BOOL, NodePath, is_absolute, varray()); - ADDFUNC0(NODE_PATH, INT, NodePath, get_name_count, varray()); - ADDFUNC1(NODE_PATH, STRING, NodePath, get_name, INT, "idx", varray()); - ADDFUNC0(NODE_PATH, INT, NodePath, get_subname_count, varray()); - ADDFUNC1(NODE_PATH, STRING, NodePath, get_subname, INT, "idx", varray()); - ADDFUNC0(NODE_PATH, STRING, NodePath, get_property, varray()); - ADDFUNC0(NODE_PATH, BOOL, NodePath, is_empty, varray()); - - ADDFUNC0(DICTIONARY, INT, Dictionary, size, varray()); - ADDFUNC0(DICTIONARY, BOOL, Dictionary, empty, varray()); + ADDFUNC0R(STRING, INT, String, hash, varray()); + ADDFUNC0R(STRING, STRING, String, md5_text, varray()); + ADDFUNC0R(STRING, STRING, String, sha256_text, varray()); + ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, md5_buffer, varray()); + ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, sha256_buffer, varray()); + ADDFUNC0R(STRING, BOOL, String, empty, varray()); + ADDFUNC0R(STRING, BOOL, String, is_abs_path, varray()); + ADDFUNC0R(STRING, BOOL, String, is_rel_path, varray()); + ADDFUNC0R(STRING, STRING, String, get_base_dir, varray()); + ADDFUNC0R(STRING, STRING, String, get_file, varray()); + ADDFUNC0R(STRING, STRING, String, xml_escape, varray()); + ADDFUNC0R(STRING, STRING, String, xml_unescape, varray()); + ADDFUNC0R(STRING, STRING, String, c_escape, varray()); + ADDFUNC0R(STRING, STRING, String, c_unescape, varray()); + ADDFUNC0R(STRING, STRING, String, json_escape, varray()); + ADDFUNC0R(STRING, STRING, String, percent_encode, varray()); + ADDFUNC0R(STRING, STRING, String, percent_decode, varray()); + ADDFUNC0R(STRING, BOOL, String, is_valid_identifier, varray()); + ADDFUNC0R(STRING, BOOL, String, is_valid_integer, varray()); + ADDFUNC0R(STRING, BOOL, String, is_valid_float, varray()); + ADDFUNC0R(STRING, BOOL, String, is_valid_html_color, varray()); + ADDFUNC0R(STRING, BOOL, String, is_valid_ip_address, varray()); + ADDFUNC0R(STRING, INT, String, to_int, varray()); + ADDFUNC0R(STRING, REAL, String, to_float, varray()); + ADDFUNC0R(STRING, INT, String, hex_to_int, varray()); + ADDFUNC1R(STRING, STRING, String, pad_decimals, INT, "digits", varray()); + ADDFUNC1R(STRING, STRING, String, pad_zeros, INT, "digits", varray()); + + ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, to_ascii, varray()); + ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, to_utf8, varray()); + + ADDFUNC0R(VECTOR2, VECTOR2, Vector2, normalized, varray()); + ADDFUNC0R(VECTOR2, REAL, Vector2, length, varray()); + ADDFUNC0R(VECTOR2, REAL, Vector2, angle, varray()); + ADDFUNC0R(VECTOR2, REAL, Vector2, length_squared, varray()); + ADDFUNC0R(VECTOR2, BOOL, Vector2, is_normalized, varray()); + ADDFUNC1R(VECTOR2, REAL, Vector2, distance_to, VECTOR2, "to", varray()); + ADDFUNC1R(VECTOR2, REAL, Vector2, distance_squared_to, VECTOR2, "to", varray()); + ADDFUNC1R(VECTOR2, REAL, Vector2, angle_to, VECTOR2, "to", varray()); + ADDFUNC1R(VECTOR2, REAL, Vector2, angle_to_point, VECTOR2, "to", varray()); + ADDFUNC2R(VECTOR2, VECTOR2, Vector2, linear_interpolate, VECTOR2, "b", REAL, "t", varray()); + ADDFUNC4R(VECTOR2, VECTOR2, Vector2, cubic_interpolate, VECTOR2, "b", VECTOR2, "pre_a", VECTOR2, "post_b", REAL, "t", varray()); + ADDFUNC1R(VECTOR2, VECTOR2, Vector2, rotated, REAL, "phi", varray()); + ADDFUNC0R(VECTOR2, VECTOR2, Vector2, tangent, varray()); + ADDFUNC0R(VECTOR2, VECTOR2, Vector2, floor, varray()); + ADDFUNC1R(VECTOR2, VECTOR2, Vector2, snapped, VECTOR2, "by", varray()); + ADDFUNC0R(VECTOR2, REAL, Vector2, aspect, varray()); + ADDFUNC1R(VECTOR2, REAL, Vector2, dot, VECTOR2, "with", varray()); + ADDFUNC1R(VECTOR2, VECTOR2, Vector2, slide, VECTOR2, "n", varray()); + ADDFUNC1R(VECTOR2, VECTOR2, Vector2, bounce, VECTOR2, "n", varray()); + ADDFUNC1R(VECTOR2, VECTOR2, Vector2, reflect, VECTOR2, "n", varray()); + //ADDFUNC1R(VECTOR2,REAL,Vector2,cross,VECTOR2,"with",varray()); + ADDFUNC0R(VECTOR2, VECTOR2, Vector2, abs, varray()); + ADDFUNC1R(VECTOR2, VECTOR2, Vector2, clamped, REAL, "length", varray()); + + ADDFUNC0R(RECT2, REAL, Rect2, get_area, varray()); + ADDFUNC1R(RECT2, BOOL, Rect2, intersects, RECT2, "b", varray()); + ADDFUNC1R(RECT2, BOOL, Rect2, encloses, RECT2, "b", varray()); + ADDFUNC0R(RECT2, BOOL, Rect2, has_no_area, varray()); + ADDFUNC1R(RECT2, RECT2, Rect2, clip, RECT2, "b", varray()); + ADDFUNC1R(RECT2, RECT2, Rect2, merge, RECT2, "b", varray()); + ADDFUNC1R(RECT2, BOOL, Rect2, has_point, VECTOR2, "point", varray()); + ADDFUNC1R(RECT2, RECT2, Rect2, grow, REAL, "by", varray()); + ADDFUNC2R(RECT2, RECT2, Rect2, grow_margin, INT, "margin", REAL, "by", varray()); + ADDFUNC4R(RECT2, RECT2, Rect2, grow_individual, REAL, "left", REAL, "top", REAL, "right", REAL, " bottom", varray()); + ADDFUNC1R(RECT2, RECT2, Rect2, expand, VECTOR2, "to", varray()); + + ADDFUNC0R(VECTOR3, INT, Vector3, min_axis, varray()); + ADDFUNC0R(VECTOR3, INT, Vector3, max_axis, varray()); + ADDFUNC0R(VECTOR3, REAL, Vector3, length, varray()); + ADDFUNC0R(VECTOR3, REAL, Vector3, length_squared, varray()); + ADDFUNC0R(VECTOR3, BOOL, Vector3, is_normalized, varray()); + ADDFUNC0R(VECTOR3, VECTOR3, Vector3, normalized, varray()); + ADDFUNC0R(VECTOR3, VECTOR3, Vector3, inverse, varray()); + ADDFUNC1R(VECTOR3, VECTOR3, Vector3, snapped, REAL, "by", varray()); + ADDFUNC2R(VECTOR3, VECTOR3, Vector3, rotated, VECTOR3, "axis", REAL, "phi", varray()); + ADDFUNC2R(VECTOR3, VECTOR3, Vector3, linear_interpolate, VECTOR3, "b", REAL, "t", varray()); + ADDFUNC4R(VECTOR3, VECTOR3, Vector3, cubic_interpolate, VECTOR3, "b", VECTOR3, "pre_a", VECTOR3, "post_b", REAL, "t", varray()); + ADDFUNC1R(VECTOR3, REAL, Vector3, dot, VECTOR3, "b", varray()); + ADDFUNC1R(VECTOR3, VECTOR3, Vector3, cross, VECTOR3, "b", varray()); + ADDFUNC1R(VECTOR3, BASIS, Vector3, outer, VECTOR3, "b", varray()); + ADDFUNC0R(VECTOR3, BASIS, Vector3, to_diagonal_matrix, varray()); + ADDFUNC0R(VECTOR3, VECTOR3, Vector3, abs, varray()); + ADDFUNC0R(VECTOR3, VECTOR3, Vector3, floor, varray()); + ADDFUNC0R(VECTOR3, VECTOR3, Vector3, ceil, varray()); + ADDFUNC1R(VECTOR3, REAL, Vector3, distance_to, VECTOR3, "b", varray()); + ADDFUNC1R(VECTOR3, REAL, Vector3, distance_squared_to, VECTOR3, "b", varray()); + ADDFUNC1R(VECTOR3, REAL, Vector3, angle_to, VECTOR3, "to", varray()); + ADDFUNC1R(VECTOR3, VECTOR3, Vector3, slide, VECTOR3, "n", varray()); + ADDFUNC1R(VECTOR3, VECTOR3, Vector3, bounce, VECTOR3, "n", varray()); + ADDFUNC1R(VECTOR3, VECTOR3, Vector3, reflect, VECTOR3, "n", varray()); + + ADDFUNC0R(PLANE, PLANE, Plane, normalized, varray()); + ADDFUNC0R(PLANE, VECTOR3, Plane, center, varray()); + ADDFUNC0R(PLANE, VECTOR3, Plane, get_any_point, varray()); + ADDFUNC1R(PLANE, BOOL, Plane, is_point_over, VECTOR3, "point", varray()); + ADDFUNC1R(PLANE, REAL, Plane, distance_to, VECTOR3, "point", varray()); + ADDFUNC2R(PLANE, BOOL, Plane, has_point, VECTOR3, "point", REAL, "epsilon", varray(CMP_EPSILON)); + ADDFUNC1R(PLANE, VECTOR3, Plane, project, VECTOR3, "point", varray()); + ADDFUNC2R(PLANE, VECTOR3, Plane, intersect_3, PLANE, "b", PLANE, "c", varray()); + ADDFUNC2R(PLANE, VECTOR3, Plane, intersects_ray, VECTOR3, "from", VECTOR3, "dir", varray()); + ADDFUNC2R(PLANE, VECTOR3, Plane, intersects_segment, VECTOR3, "begin", VECTOR3, "end", varray()); + + ADDFUNC0R(QUAT, REAL, Quat, length, varray()); + ADDFUNC0R(QUAT, REAL, Quat, length_squared, varray()); + ADDFUNC0R(QUAT, QUAT, Quat, normalized, varray()); + ADDFUNC0R(QUAT, BOOL, Quat, is_normalized, varray()); + ADDFUNC0R(QUAT, QUAT, Quat, inverse, varray()); + ADDFUNC1R(QUAT, REAL, Quat, dot, QUAT, "b", varray()); + ADDFUNC1R(QUAT, VECTOR3, Quat, xform, VECTOR3, "v", varray()); + ADDFUNC2R(QUAT, QUAT, Quat, slerp, QUAT, "b", REAL, "t", varray()); + ADDFUNC2R(QUAT, QUAT, Quat, slerpni, QUAT, "b", REAL, "t", varray()); + ADDFUNC4R(QUAT, QUAT, Quat, cubic_slerp, QUAT, "b", QUAT, "pre_a", QUAT, "post_b", REAL, "t", varray()); + + ADDFUNC0R(COLOR, INT, Color, to_rgba32, varray()); + ADDFUNC0R(COLOR, INT, Color, to_argb32, varray()); + ADDFUNC0R(COLOR, REAL, Color, gray, varray()); + ADDFUNC0R(COLOR, COLOR, Color, inverted, varray()); + ADDFUNC0R(COLOR, COLOR, Color, contrasted, varray()); + ADDFUNC2R(COLOR, COLOR, Color, linear_interpolate, COLOR, "b", REAL, "t", varray()); + ADDFUNC1R(COLOR, COLOR, Color, blend, COLOR, "over", varray()); + ADDFUNC1R(COLOR, STRING, Color, to_html, BOOL, "with_alpha", varray(true)); + + ADDFUNC0R(_RID, INT, RID, get_id, varray()); + + ADDFUNC0R(NODE_PATH, BOOL, NodePath, is_absolute, varray()); + ADDFUNC0R(NODE_PATH, INT, NodePath, get_name_count, varray()); + ADDFUNC1R(NODE_PATH, STRING, NodePath, get_name, INT, "idx", varray()); + ADDFUNC0R(NODE_PATH, INT, NodePath, get_subname_count, varray()); + ADDFUNC1R(NODE_PATH, STRING, NodePath, get_subname, INT, "idx", varray()); + ADDFUNC0R(NODE_PATH, STRING, NodePath, get_property, varray()); + ADDFUNC0R(NODE_PATH, BOOL, NodePath, is_empty, varray()); + + ADDFUNC0R(DICTIONARY, INT, Dictionary, size, varray()); + ADDFUNC0R(DICTIONARY, BOOL, Dictionary, empty, varray()); ADDFUNC0NC(DICTIONARY, NIL, Dictionary, clear, varray()); - ADDFUNC1(DICTIONARY, BOOL, Dictionary, has, NIL, "key", varray()); - ADDFUNC1(DICTIONARY, BOOL, Dictionary, has_all, ARRAY, "keys", varray()); + ADDFUNC1R(DICTIONARY, BOOL, Dictionary, has, NIL, "key", varray()); + ADDFUNC1R(DICTIONARY, BOOL, Dictionary, has_all, ARRAY, "keys", varray()); ADDFUNC1(DICTIONARY, NIL, Dictionary, erase, NIL, "key", varray()); - ADDFUNC0(DICTIONARY, INT, Dictionary, hash, varray()); - ADDFUNC0(DICTIONARY, ARRAY, Dictionary, keys, varray()); - ADDFUNC0(DICTIONARY, ARRAY, Dictionary, values, varray()); + ADDFUNC0R(DICTIONARY, INT, Dictionary, hash, varray()); + ADDFUNC0R(DICTIONARY, ARRAY, Dictionary, keys, varray()); + ADDFUNC0R(DICTIONARY, ARRAY, Dictionary, values, varray()); - ADDFUNC0(ARRAY, INT, Array, size, varray()); - ADDFUNC0(ARRAY, BOOL, Array, empty, varray()); + ADDFUNC0R(ARRAY, INT, Array, size, varray()); + ADDFUNC0R(ARRAY, BOOL, Array, empty, varray()); ADDFUNC0NC(ARRAY, NIL, Array, clear, varray()); - ADDFUNC0(ARRAY, INT, Array, hash, varray()); + ADDFUNC0R(ARRAY, INT, Array, hash, varray()); ADDFUNC1NC(ARRAY, NIL, Array, push_back, NIL, "value", varray()); ADDFUNC1NC(ARRAY, NIL, Array, push_front, NIL, "value", varray()); ADDFUNC1NC(ARRAY, NIL, Array, append, NIL, "value", varray()); @@ -1592,165 +1614,160 @@ void register_variant_methods() { ADDFUNC2NC(ARRAY, NIL, Array, insert, INT, "position", NIL, "value", varray()); ADDFUNC1NC(ARRAY, NIL, Array, remove, INT, "position", varray()); ADDFUNC1NC(ARRAY, NIL, Array, erase, NIL, "value", varray()); - ADDFUNC0(ARRAY, NIL, Array, front, varray()); - ADDFUNC0(ARRAY, NIL, Array, back, varray()); - ADDFUNC2(ARRAY, INT, Array, find, NIL, "what", INT, "from", varray(0)); - ADDFUNC2(ARRAY, INT, Array, rfind, NIL, "what", INT, "from", varray(-1)); - ADDFUNC1(ARRAY, INT, Array, find_last, NIL, "value", varray()); - ADDFUNC1(ARRAY, INT, Array, count, NIL, "value", varray()); - ADDFUNC1(ARRAY, BOOL, Array, has, NIL, "value", varray()); - ADDFUNC0NC(ARRAY, NIL, Array, pop_back, varray()); - ADDFUNC0NC(ARRAY, NIL, Array, pop_front, varray()); + ADDFUNC0R(ARRAY, NIL, Array, front, varray()); + ADDFUNC0R(ARRAY, NIL, Array, back, varray()); + ADDFUNC2R(ARRAY, INT, Array, find, NIL, "what", INT, "from", varray(0)); + ADDFUNC2R(ARRAY, INT, Array, rfind, NIL, "what", INT, "from", varray(-1)); + ADDFUNC1R(ARRAY, INT, Array, find_last, NIL, "value", varray()); + ADDFUNC1R(ARRAY, INT, Array, count, NIL, "value", varray()); + ADDFUNC1R(ARRAY, BOOL, Array, has, NIL, "value", varray()); + ADDFUNC0RNC(ARRAY, NIL, Array, pop_back, varray()); + ADDFUNC0RNC(ARRAY, NIL, Array, pop_front, varray()); ADDFUNC0NC(ARRAY, NIL, Array, sort, varray()); ADDFUNC2NC(ARRAY, NIL, Array, sort_custom, OBJECT, "obj", STRING, "func", varray()); ADDFUNC0NC(ARRAY, NIL, Array, invert, varray()); - ADDFUNC0NC(ARRAY, ARRAY, Array, duplicate, varray()); + ADDFUNC0RNC(ARRAY, ARRAY, Array, duplicate, varray()); - ADDFUNC0(POOL_BYTE_ARRAY, INT, PoolByteArray, size, varray()); + ADDFUNC0R(POOL_BYTE_ARRAY, INT, PoolByteArray, size, varray()); ADDFUNC2(POOL_BYTE_ARRAY, NIL, PoolByteArray, set, INT, "idx", INT, "byte", varray()); ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, push_back, INT, "byte", varray()); ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, append, INT, "byte", varray()); ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, append_array, POOL_BYTE_ARRAY, "array", varray()); ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, remove, INT, "idx", varray()); - ADDFUNC2(POOL_BYTE_ARRAY, INT, PoolByteArray, insert, INT, "idx", INT, "byte", varray()); + ADDFUNC2R(POOL_BYTE_ARRAY, INT, PoolByteArray, insert, INT, "idx", INT, "byte", varray()); ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, resize, INT, "idx", varray()); ADDFUNC0(POOL_BYTE_ARRAY, NIL, PoolByteArray, invert, varray()); - ADDFUNC2(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, subarray, INT, "from", INT, "to", varray()); + ADDFUNC2R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, subarray, INT, "from", INT, "to", varray()); - ADDFUNC0(POOL_BYTE_ARRAY, STRING, PoolByteArray, get_string_from_ascii, varray()); - ADDFUNC0(POOL_BYTE_ARRAY, STRING, PoolByteArray, get_string_from_utf8, varray()); - ADDFUNC1(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, compress, INT, "compression_mode", varray(0)); - ADDFUNC2(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, decompress, INT, "buffer_size", INT, "compression_mode", varray(0)); + ADDFUNC0R(POOL_BYTE_ARRAY, STRING, PoolByteArray, get_string_from_ascii, varray()); + ADDFUNC0R(POOL_BYTE_ARRAY, STRING, PoolByteArray, get_string_from_utf8, varray()); + ADDFUNC1R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, compress, INT, "compression_mode", varray(0)); + ADDFUNC2R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, decompress, INT, "buffer_size", INT, "compression_mode", varray(0)); - ADDFUNC0(POOL_INT_ARRAY, INT, PoolIntArray, size, varray()); + ADDFUNC0R(POOL_INT_ARRAY, INT, PoolIntArray, size, varray()); ADDFUNC2(POOL_INT_ARRAY, NIL, PoolIntArray, set, INT, "idx", INT, "integer", varray()); ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, push_back, INT, "integer", varray()); ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, append, INT, "integer", varray()); ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, append_array, POOL_INT_ARRAY, "array", varray()); ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, remove, INT, "idx", varray()); - ADDFUNC2(POOL_INT_ARRAY, INT, PoolIntArray, insert, INT, "idx", INT, "integer", varray()); + ADDFUNC2R(POOL_INT_ARRAY, INT, PoolIntArray, insert, INT, "idx", INT, "integer", varray()); ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, resize, INT, "idx", varray()); ADDFUNC0(POOL_INT_ARRAY, NIL, PoolIntArray, invert, varray()); - ADDFUNC0(POOL_REAL_ARRAY, INT, PoolRealArray, size, varray()); + ADDFUNC0R(POOL_REAL_ARRAY, INT, PoolRealArray, size, varray()); ADDFUNC2(POOL_REAL_ARRAY, NIL, PoolRealArray, set, INT, "idx", REAL, "value", varray()); ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, push_back, REAL, "value", varray()); ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, append, REAL, "value", varray()); ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, append_array, POOL_REAL_ARRAY, "array", varray()); ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, remove, INT, "idx", varray()); - ADDFUNC2(POOL_REAL_ARRAY, INT, PoolRealArray, insert, INT, "idx", REAL, "value", varray()); + ADDFUNC2R(POOL_REAL_ARRAY, INT, PoolRealArray, insert, INT, "idx", REAL, "value", varray()); ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, resize, INT, "idx", varray()); ADDFUNC0(POOL_REAL_ARRAY, NIL, PoolRealArray, invert, varray()); - ADDFUNC0(POOL_STRING_ARRAY, INT, PoolStringArray, size, varray()); + ADDFUNC0R(POOL_STRING_ARRAY, INT, PoolStringArray, size, varray()); ADDFUNC2(POOL_STRING_ARRAY, NIL, PoolStringArray, set, INT, "idx", STRING, "string", varray()); ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, push_back, STRING, "string", varray()); ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, append, STRING, "string", varray()); ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, append_array, POOL_STRING_ARRAY, "array", varray()); ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, remove, INT, "idx", varray()); - ADDFUNC2(POOL_STRING_ARRAY, INT, PoolStringArray, insert, INT, "idx", STRING, "string", varray()); + ADDFUNC2R(POOL_STRING_ARRAY, INT, PoolStringArray, insert, INT, "idx", STRING, "string", varray()); ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, resize, INT, "idx", varray()); ADDFUNC0(POOL_STRING_ARRAY, NIL, PoolStringArray, invert, varray()); ADDFUNC1(POOL_STRING_ARRAY, STRING, PoolStringArray, join, STRING, "delimiter", varray()); - ADDFUNC0(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, size, varray()); + ADDFUNC0R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, size, varray()); ADDFUNC2(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, set, INT, "idx", VECTOR2, "vector2", varray()); ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, push_back, VECTOR2, "vector2", varray()); ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, append, VECTOR2, "vector2", varray()); ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, append_array, POOL_VECTOR2_ARRAY, "array", varray()); ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, remove, INT, "idx", varray()); - ADDFUNC2(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, insert, INT, "idx", VECTOR2, "vector2", varray()); + ADDFUNC2R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, insert, INT, "idx", VECTOR2, "vector2", varray()); ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, resize, INT, "idx", varray()); ADDFUNC0(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, invert, varray()); - ADDFUNC0(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, size, varray()); + ADDFUNC0R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, size, varray()); ADDFUNC2(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, set, INT, "idx", VECTOR3, "vector3", varray()); ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, push_back, VECTOR3, "vector3", varray()); ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, append, VECTOR3, "vector3", varray()); ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, append_array, POOL_VECTOR3_ARRAY, "array", varray()); ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, remove, INT, "idx", varray()); - ADDFUNC2(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, insert, INT, "idx", VECTOR3, "vector3", varray()); + ADDFUNC2R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, insert, INT, "idx", VECTOR3, "vector3", varray()); ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, resize, INT, "idx", varray()); ADDFUNC0(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, invert, varray()); - ADDFUNC0(POOL_COLOR_ARRAY, INT, PoolColorArray, size, varray()); + ADDFUNC0R(POOL_COLOR_ARRAY, INT, PoolColorArray, size, varray()); ADDFUNC2(POOL_COLOR_ARRAY, NIL, PoolColorArray, set, INT, "idx", COLOR, "color", varray()); ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, push_back, COLOR, "color", varray()); ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, append, COLOR, "color", varray()); ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, append_array, POOL_COLOR_ARRAY, "array", varray()); ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, remove, INT, "idx", varray()); - ADDFUNC2(POOL_COLOR_ARRAY, INT, PoolColorArray, insert, INT, "idx", COLOR, "color", varray()); + ADDFUNC2R(POOL_COLOR_ARRAY, INT, PoolColorArray, insert, INT, "idx", COLOR, "color", varray()); ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, resize, INT, "idx", varray()); ADDFUNC0(POOL_COLOR_ARRAY, NIL, PoolColorArray, invert, varray()); //pointerbased - ADDFUNC0(RECT3, REAL, Rect3, get_area, varray()); - ADDFUNC0(RECT3, BOOL, Rect3, has_no_area, varray()); - ADDFUNC0(RECT3, BOOL, Rect3, has_no_surface, varray()); - ADDFUNC1(RECT3, BOOL, Rect3, intersects, RECT3, "with", varray()); - ADDFUNC1(RECT3, BOOL, Rect3, encloses, RECT3, "with", varray()); - ADDFUNC1(RECT3, RECT3, Rect3, merge, RECT3, "with", varray()); - ADDFUNC1(RECT3, RECT3, Rect3, intersection, RECT3, "with", varray()); - ADDFUNC1(RECT3, BOOL, Rect3, intersects_plane, PLANE, "plane", varray()); - ADDFUNC2(RECT3, BOOL, Rect3, intersects_segment, VECTOR3, "from", VECTOR3, "to", varray()); - ADDFUNC1(RECT3, BOOL, Rect3, has_point, VECTOR3, "point", varray()); - ADDFUNC1(RECT3, VECTOR3, Rect3, get_support, VECTOR3, "dir", varray()); - ADDFUNC0(RECT3, VECTOR3, Rect3, get_longest_axis, varray()); - ADDFUNC0(RECT3, INT, Rect3, get_longest_axis_index, varray()); - ADDFUNC0(RECT3, REAL, Rect3, get_longest_axis_size, varray()); - ADDFUNC0(RECT3, VECTOR3, Rect3, get_shortest_axis, varray()); - ADDFUNC0(RECT3, INT, Rect3, get_shortest_axis_index, varray()); - ADDFUNC0(RECT3, REAL, Rect3, get_shortest_axis_size, varray()); - ADDFUNC1(RECT3, RECT3, Rect3, expand, VECTOR3, "to_point", varray()); - ADDFUNC1(RECT3, RECT3, Rect3, grow, REAL, "by", varray()); - ADDFUNC1(RECT3, VECTOR3, Rect3, get_endpoint, INT, "idx", varray()); - - ADDFUNC0(TRANSFORM2D, TRANSFORM2D, Transform2D, inverse, varray()); - ADDFUNC0(TRANSFORM2D, TRANSFORM2D, Transform2D, affine_inverse, varray()); - ADDFUNC0(TRANSFORM2D, REAL, Transform2D, get_rotation, varray()); - ADDFUNC0(TRANSFORM2D, VECTOR2, Transform2D, get_origin, varray()); - ADDFUNC0(TRANSFORM2D, VECTOR2, Transform2D, get_scale, varray()); - ADDFUNC0(TRANSFORM2D, TRANSFORM2D, Transform2D, orthonormalized, varray()); - ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, rotated, REAL, "phi", varray()); - ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, scaled, VECTOR2, "scale", varray()); - ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, translated, VECTOR2, "offset", varray()); - ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, xform, NIL, "v", varray()); - ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, xform_inv, NIL, "v", varray()); - ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, basis_xform, NIL, "v", varray()); - ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, basis_xform_inv, NIL, "v", varray()); - ADDFUNC2(TRANSFORM2D, TRANSFORM2D, Transform2D, interpolate_with, TRANSFORM2D, "transform", REAL, "weight", varray()); - - ADDFUNC0(BASIS, BASIS, Basis, inverse, varray()); - ADDFUNC0(BASIS, BASIS, Basis, transposed, varray()); - ADDFUNC0(BASIS, BASIS, Basis, orthonormalized, varray()); - ADDFUNC0(BASIS, REAL, Basis, determinant, varray()); - ADDFUNC2(BASIS, BASIS, Basis, rotated, VECTOR3, "axis", REAL, "phi", varray()); - ADDFUNC1(BASIS, BASIS, Basis, scaled, VECTOR3, "scale", varray()); - ADDFUNC0(BASIS, VECTOR3, Basis, get_scale, varray()); - ADDFUNC0(BASIS, VECTOR3, Basis, get_euler, varray()); - ADDFUNC1(BASIS, REAL, Basis, tdotx, VECTOR3, "with", varray()); - ADDFUNC1(BASIS, REAL, Basis, tdoty, VECTOR3, "with", varray()); - ADDFUNC1(BASIS, REAL, Basis, tdotz, VECTOR3, "with", varray()); - ADDFUNC1(BASIS, VECTOR3, Basis, xform, VECTOR3, "v", varray()); - ADDFUNC1(BASIS, VECTOR3, Basis, xform_inv, VECTOR3, "v", varray()); - ADDFUNC0(BASIS, INT, Basis, get_orthogonal_index, varray()); - - ADDFUNC0(TRANSFORM, TRANSFORM, Transform, inverse, varray()); - ADDFUNC0(TRANSFORM, TRANSFORM, Transform, affine_inverse, varray()); - ADDFUNC0(TRANSFORM, TRANSFORM, Transform, orthonormalized, varray()); - ADDFUNC2(TRANSFORM, TRANSFORM, Transform, rotated, VECTOR3, "axis", REAL, "phi", varray()); - ADDFUNC1(TRANSFORM, TRANSFORM, Transform, scaled, VECTOR3, "scale", varray()); - ADDFUNC1(TRANSFORM, TRANSFORM, Transform, translated, VECTOR3, "ofs", varray()); - ADDFUNC2(TRANSFORM, TRANSFORM, Transform, looking_at, VECTOR3, "target", VECTOR3, "up", varray()); - ADDFUNC2(TRANSFORM, TRANSFORM, Transform, interpolate_with, TRANSFORM, "transform", REAL, "weight", varray()); - ADDFUNC1(TRANSFORM, NIL, Transform, xform, NIL, "v", varray()); - ADDFUNC1(TRANSFORM, NIL, Transform, xform_inv, NIL, "v", varray()); - -#ifdef DEBUG_ENABLED - _VariantCall::type_funcs[Variant::TRANSFORM].functions["xform"].returns = true; - _VariantCall::type_funcs[Variant::TRANSFORM].functions["xform_inv"].returns = true; -#endif + ADDFUNC0R(RECT3, REAL, Rect3, get_area, varray()); + ADDFUNC0R(RECT3, BOOL, Rect3, has_no_area, varray()); + ADDFUNC0R(RECT3, BOOL, Rect3, has_no_surface, varray()); + ADDFUNC1R(RECT3, BOOL, Rect3, intersects, RECT3, "with", varray()); + ADDFUNC1R(RECT3, BOOL, Rect3, encloses, RECT3, "with", varray()); + ADDFUNC1R(RECT3, RECT3, Rect3, merge, RECT3, "with", varray()); + ADDFUNC1R(RECT3, RECT3, Rect3, intersection, RECT3, "with", varray()); + ADDFUNC1R(RECT3, BOOL, Rect3, intersects_plane, PLANE, "plane", varray()); + ADDFUNC2R(RECT3, BOOL, Rect3, intersects_segment, VECTOR3, "from", VECTOR3, "to", varray()); + ADDFUNC1R(RECT3, BOOL, Rect3, has_point, VECTOR3, "point", varray()); + ADDFUNC1R(RECT3, VECTOR3, Rect3, get_support, VECTOR3, "dir", varray()); + ADDFUNC0R(RECT3, VECTOR3, Rect3, get_longest_axis, varray()); + ADDFUNC0R(RECT3, INT, Rect3, get_longest_axis_index, varray()); + ADDFUNC0R(RECT3, REAL, Rect3, get_longest_axis_size, varray()); + ADDFUNC0R(RECT3, VECTOR3, Rect3, get_shortest_axis, varray()); + ADDFUNC0R(RECT3, INT, Rect3, get_shortest_axis_index, varray()); + ADDFUNC0R(RECT3, REAL, Rect3, get_shortest_axis_size, varray()); + ADDFUNC1R(RECT3, RECT3, Rect3, expand, VECTOR3, "to_point", varray()); + ADDFUNC1R(RECT3, RECT3, Rect3, grow, REAL, "by", varray()); + ADDFUNC1R(RECT3, VECTOR3, Rect3, get_endpoint, INT, "idx", varray()); + + ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, inverse, varray()); + ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, affine_inverse, varray()); + ADDFUNC0R(TRANSFORM2D, REAL, Transform2D, get_rotation, varray()); + ADDFUNC0R(TRANSFORM2D, VECTOR2, Transform2D, get_origin, varray()); + ADDFUNC0R(TRANSFORM2D, VECTOR2, Transform2D, get_scale, varray()); + ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, orthonormalized, varray()); + ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, rotated, REAL, "phi", varray()); + ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, scaled, VECTOR2, "scale", varray()); + ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, translated, VECTOR2, "offset", varray()); + ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, xform, NIL, "v", varray()); + ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, xform_inv, NIL, "v", varray()); + ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, basis_xform, NIL, "v", varray()); + ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, basis_xform_inv, NIL, "v", varray()); + ADDFUNC2R(TRANSFORM2D, TRANSFORM2D, Transform2D, interpolate_with, TRANSFORM2D, "transform", REAL, "weight", varray()); + + ADDFUNC0R(BASIS, BASIS, Basis, inverse, varray()); + ADDFUNC0R(BASIS, BASIS, Basis, transposed, varray()); + ADDFUNC0R(BASIS, BASIS, Basis, orthonormalized, varray()); + ADDFUNC0R(BASIS, REAL, Basis, determinant, varray()); + ADDFUNC2R(BASIS, BASIS, Basis, rotated, VECTOR3, "axis", REAL, "phi", varray()); + ADDFUNC1R(BASIS, BASIS, Basis, scaled, VECTOR3, "scale", varray()); + ADDFUNC0R(BASIS, VECTOR3, Basis, get_scale, varray()); + ADDFUNC0R(BASIS, VECTOR3, Basis, get_euler, varray()); + ADDFUNC1R(BASIS, REAL, Basis, tdotx, VECTOR3, "with", varray()); + ADDFUNC1R(BASIS, REAL, Basis, tdoty, VECTOR3, "with", varray()); + ADDFUNC1R(BASIS, REAL, Basis, tdotz, VECTOR3, "with", varray()); + ADDFUNC1R(BASIS, VECTOR3, Basis, xform, VECTOR3, "v", varray()); + ADDFUNC1R(BASIS, VECTOR3, Basis, xform_inv, VECTOR3, "v", varray()); + ADDFUNC0R(BASIS, INT, Basis, get_orthogonal_index, varray()); + + ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, inverse, varray()); + ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, affine_inverse, varray()); + ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, orthonormalized, varray()); + ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, rotated, VECTOR3, "axis", REAL, "phi", varray()); + ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, scaled, VECTOR3, "scale", varray()); + ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, translated, VECTOR3, "ofs", varray()); + ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, looking_at, VECTOR3, "target", VECTOR3, "up", varray()); + ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, interpolate_with, TRANSFORM, "transform", REAL, "weight", varray()); + ADDFUNC1R(TRANSFORM, NIL, Transform, xform, NIL, "v", varray()); + ADDFUNC1R(TRANSFORM, NIL, Transform, xform_inv, NIL, "v", varray()); /* REGISTER CONSTRUCTORS */ diff --git a/core/version.h b/core/version.h index 436f30ef01..7d2c47df6a 100644 --- a/core/version.h +++ b/core/version.h @@ -30,8 +30,8 @@ #include "version_generated.gen.h" #ifdef VERSION_PATCH -#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_PATCH) "." _MKSTR(VERSION_STATUS) "." _MKSTR(VERSION_REVISION) +#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_PATCH) "." _MKSTR(VERSION_STATUS) "." _MKSTR(VERSION_REVISION) VERSION_MODULE_CONFIG #else -#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_STATUS) "." _MKSTR(VERSION_REVISION) +#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_STATUS) "." _MKSTR(VERSION_REVISION) VERSION_MODULE_CONFIG #endif // VERSION_PATCH #define VERSION_FULL_NAME "" _MKSTR(VERSION_NAME) " v" VERSION_MKSTRING |