Commit Graph

184 Commits

Author SHA1 Message Date
Rémi Verschelde a0c87d4c11
Merge pull request #57620 from Haydoggo/expression-exp-fix
Fix Expression's parsing of positive exponent literals
2022-02-05 10:14:10 +01:00
Hayden 1305ff92f7 Make parser treat all exponent literals as float 2022-02-05 16:34:26 +13:00
Rémi Verschelde e223bad86d
Core: Move Vector2i to its own `vector2i.h` header
Also reduce interdependencies and clean up a bit.
2022-02-04 16:32:21 +01:00
Rémi Verschelde 5f56d385b0
Core: Move Rect2i to its own `rect2i.h` header
And take the opportunity to improve interdependencies a bit with forward
declares where possible.
2022-02-04 14:17:30 +01:00
bruvzg 244db37508
Cleanup and move char functions to the `char_utils.h` header. 2022-02-04 11:35:01 +02:00
Anilforextra adbe948bda String: Add contains(). 2022-02-04 01:28:02 +05:45
Markus Sauermann 23a4fe5b27 Fix incorrect Rect2i calculations: intersects and encloses
Clarify expand documentation
2022-01-31 19:03:57 +01:00
Nathan Franke 8a0a3accee
simplify formatting scripts, add a clang-tidy script, and run clang-tidy 2022-01-29 04:41:03 -06:00
Rémi Verschelde e6caaf4c80
Merge pull request #57205 from TechnoPorg/variant-template-cast
Allow method binds to take Object subclasses as arguments
2022-01-27 23:46:37 +01:00
Wilson E. Alvarez 3eb5e0ac50
Rename String::is_subsequence_ofi to String::is_subsequence_ofn 2022-01-26 18:03:56 -05:00
TechnoPorg 051ef479c9 Allow method binds to take Object subclasses as arguments
This commit adds a condition to VariantCaster that casts Variants of type OBJECT to any type T, if T is derived from Object.
This change enables a fair bit of code cleanup. First, the Variant implicit cast operators for Node and Control can be removed, which allows for some invalid includes to be removed. Second, helper methods in Tree whose sole purpose was to cast arguments to TreeItem * are no longer necessary.
A few small changes also had to be made to other files, due to the changes cascading down all the includes.
2022-01-25 09:03:36 -07:00
Rémi Verschelde 668d6a1c5c
Merge pull request #56337 from cdemirer/fix-array-dictionary-id 2022-01-23 00:46:53 +01:00
Rémi Verschelde 9912492e93
Merge pull request #56668 from akien-mga/array-slice-nicer-bound-checks 2022-01-18 13:22:35 +01:00
Aaron Franke 13939734e0
Replace String::num_real code with a wrapper around String::num 2022-01-15 00:21:49 -06:00
Aaron Franke d9506cade1
Add tests for Vector2/Vector2i/Vector3/Vector3i 2022-01-14 01:59:55 -06:00
luz paz 858bcd5058 Fix various typos
Found via `codespell -q 3 -S ./thirdparty,*.po,./DONORS.md -L ackward,ang,ans,ba,beng,cas,childs,childrens,dof,doubleclick,expct,fave,findn,gird,hist,inh,inout,leapyear,lod,nd,numer,ois,ony,paket,ro,seeked,sinc,switchs,te,uint,varn,vew`
2022-01-13 23:20:01 -05:00
Rémi Verschelde c6cefb1b79
`Array`: Relax `slice` bound checks to properly handle negative indices
The same is done for `Vector` (and thus `Packed*Array`).

`begin` and `end` can now take any value and will be clamped to
`[-size(), size()]`. Negative values are a shorthand for indexing the array
from the last element upward.

`end` is given a default `INT_MAX` value (which will be clamped to `size()`)
so that the `end` parameter can be omitted to go from `begin` to the max size
of the array.

This makes `slice` works similarly to numpy's and JavaScript's.
2022-01-10 22:42:03 +01:00
Haoyu Qiu c0d3bdc0ca Add list initialization support for Vector & LocalVector 2022-01-05 20:42:09 +08:00
Rémi Verschelde fe52458154
Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +01:00
cdemirer e2ed9d13eb Fix Array and Dictionary id() and dictionary test bug 2021-12-30 13:14:09 +08:00
Haoyu Qiu e4e4e475f8 Make `--doctool` locale aware
* Adds `indent(str)` to `String`:
    * Indent the (multiline) string with the given indentation.
    * This method is added in order to keep the translated XML correctly
      indented.
* Moves the loading of tool/doc translation into
  `editor/editor_translation.{h,cpp}`.
    * This will be used from both `EditorSettings` and the doc tool from
      `main`.
* Makes use of doc translation when generating XML class references, and
  setup the translation locale based on `-l LOCALE` CLI parameter.

The XML class reference won't be translated if `-l LOCALE` parameter is
not given, or when it's `-l en`.
2021-12-16 17:49:22 +08:00
Nathan Franke 49403cbfa0
Replace String comparisons with "", String() to is_empty()
Also:
- Adds two stress tests to test_string.h
- Changes to .empty() on std::strings
2021-12-09 04:48:38 -06:00
Rémi Verschelde 46d384060e
Merge pull request #35901 from nathanfranke/pool-byte-array-subarray-exclusive 2021-12-07 14:00:59 +01:00
Rémi Verschelde 3f1a8e2f77
Merge pull request #55545 from akien-mga/doc-aabb-has_point
AABB: Improve docs and test for `has_point`
2021-12-02 21:10:53 +01:00
Rémi Verschelde 2017590ef6
AABB: Improve docs and test for `has_point`
Contrarily to the 2D Rect2i counterpart, it doesn't make much sense in 3D
and for floating-point AABBs to exclude points on some of its faces.
2021-12-02 15:45:55 +01:00
Rémi Verschelde 7da392bcc5
Don't return reference on copy assignment operators
We prefer to prevent using chained assignment (`T a = b = c = T();`) as this
can lead to confusing code and subtle bugs.

According to https://en.wikipedia.org/wiki/Assignment_operator_(C%2B%2B), C++
allows any arbitrary return type, so this is standard compliant.

This could be re-assessed if/when we have an actual need for a behavior more
akin to that of the C++ STL, for now this PR simply changes a handful of
cases which were inconsistent with the rest of the codebase (`void` return
type was already the most common case prior to this commit).
2021-11-30 16:26:29 +01:00
Nathan Franke dd30253cdc
PackedByteArray, Array slice end exclusive, rename subarray to slice 2021-11-26 22:13:12 -06:00
Rémi Verschelde b1bf82d2b4
Merge pull request #52456 from kleonc/image-fill-rect 2021-11-24 16:34:01 +01:00
Lightning_A e078f970db Rename `remove()` to `remove_at()` when removing by index 2021-11-23 18:58:57 -07:00
kleonc 91595b16e3 Add Image::fill_rect method 2021-11-23 18:06:23 +01:00
Paulb23 eb9100f085 Fix divide by zero in pck_packer 2021-11-17 18:07:29 +00:00
Rémi Verschelde 36c4451a7b
Rect2: Clarify docs for `has_point` excluding bottom and right borders
Improve tests, as well as documentation for `expand`.
2021-11-11 22:51:29 +01:00
Rémi Verschelde 2beaae4b6f
String: Remove `erase` method, bindings can't mutate String 2021-11-11 11:23:32 +01:00
Aaron Franke 99a282f631
Move and organize tests into subfolders 2021-11-07 00:43:31 -06:00