Commit graph

56 commits

Author SHA1 Message Date
Emmanuel Leblond f9ba2efe1e
Modify Dictionary::operator== to do real key/value comparison with recursive support (and add unittests) 2021-10-30 13:11:01 +02:00
Rémi Verschelde cd21cc683a
SCons: Set DEBUG_ENABLED and DEV_ENABLED in SConstruct
They're the same for all platforms so they don't need to be repeated in all
platform definitions.
2021-10-15 10:26:58 +02:00
reduz 5ad4f26659 Implement the ability to disable classes
* This PR adds the ability to disable classes when building.
* For now it's only possible to do this via command like:
  `scons disable_classes=RayCast2D,Area3D`
* Eventually, a proper UI will be implemented to create a build config file to do this at large scale, as well as detect what is used in the project.
2021-07-13 09:25:14 -03:00
Rémi Verschelde b5334d14f7
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆
2021-01-01 20:19:21 +01:00
jcgollnick 3347cc25b8 Fix SGN macro
This version behaves the way the documentation states: 0 values will resolve to 0 instead of +1
2020-11-27 13:02:12 -06:00
reduz 127458ed17 Reorganized core/ directory, it was too fatty already
-Removed FuncRef, since Callable makes it obsolete
-Removed int_types.h as its obsolete in c++11+
-Changed color names code
2020-11-07 20:17:12 -03:00
Marios Staikopoulos e5d7c7d5fc Alpha Hash and Alpha2Coverage Implementation 2020-11-02 20:11:20 -08:00
reduz ee06a70ea6 Refactor MethodBind to use variadic templates
Removed make_binders and the old style generated binders.
2020-10-18 12:28:44 +02:00
Rémi Verschelde 0ee0fa42e6 Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2020-05-14 21:57:34 +02:00
Rémi Verschelde 1c2f2a805d typedefs: Cleanup unused macros and unnecessary checks
We now require a compiler with C++17 support, so we don't need to
check for features added to GCC 5 or Clang 3.2.

Clang builtin availability checks were unused anyway as Clang defines
`__GNUC__` as it's also a GNU C implementation.

Fixes #36986.
2020-03-11 21:44:56 +01:00
Rémi Verschelde 2cf6ac6c50 Replace FALLTHROUGH macro by C++17 [[fallthrough]]
This attribute is now part of the standard we target so we no longer
need compiler-specific hacks.

Also enables -Wimplicit-fallthrough for Clang now that we can properly
support it. It's already on by default for GCC's -Wextra.

Fixes new warnings raised by Clang's -Wimplicit-fallthrough.
2020-02-23 00:52:50 +01:00
Juan Linietsky 04bb6a708a Created the callable_mp macro, for signals to call method pointers directly. 2020-02-21 13:46:45 +01:00
Rémi Verschelde a7f49ac9a1 Update copyright statements to 2020
Happy new year to the wonderful Godot community!

We're starting a new decade with a well-established, non-profit, free
and open source game engine, and tons of further improvements in the
pipeline from hundreds of contributors.

Godot will keep getting better, and we're looking forward to all the
games that the community will keep developing and releasing with it.
2020-01-01 11:16:22 +01:00
Rafał Mikrut 99d8626f4a Fix some overflows and unitialized variables 2019-11-20 16:22:16 +01:00
Marcel Admiraal c2aa3e2351 Remove circular include between core/typedefs.h and core/error_macros.h 2019-10-08 11:03:57 +02:00
Rémi Verschelde fc370b3feb Fix -Wimplicit-fallthrough warnings from GCC 8
Adds `FALLTHROUGH` macro to specify when a fallthrough is intentional.
Can be replaced by `[[fallthrough]]` if/when we switch to C++17.

The warning is now enabled by default for GCC on `extra` warnings level
(part of GCC's `-Wextra`). It's not enabled in Clang's `-Wextra` yet,
but we could enable it manually once we switch to C++11. There's no
equivalent feature in MSVC for now.

Fixes #26135.
2019-04-05 15:14:53 +02:00
marxin e7f22ebdcd Enable warnings=extra on clang and GCC testers.
And remove 2 warnings from warnings=extra.
2019-04-02 17:14:47 +02:00
Rémi Verschelde aff3dd36ba
Merge pull request #25495 from IronicallySerious/fix-expand-macros
Fix parameterised macros in core. Addresses #25488
2019-03-16 11:20:52 -07:00
marxin 64bce5a24b Use GCC builtins for bswap as compiler can then emit these via instructions.
Using current macros, one get for:

static inline int BSWAP32(int x) {
	return ((x << 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x >> 24));
}
int main(int argc, char **argv)
{
  return BSWAP32(argc);
}

main:
.LFB1:
	.cfi_startproc
	movl	%edi, %eax
	movl	%edi, %edx
	sarl	$24, %edx
	sall	$24, %eax
	orl	%edx, %eax
	movl	%edi, %edx
	sarl	$8, %edi
	sall	$8, %edx
	andl	$65280, %edi
	andl	$16711680, %edx
	orl	%edx, %eax
	orl	%edi, %eax
	ret

while using:

int main(int argc, char **argv)
{
  return __builtin_bswap32(argc);
}

one gets:

main:
.LFB0:
	.cfi_startproc
	movl	%edi, %eax
	bswap	%eax
	ret
2019-03-05 22:27:02 +01:00
marxin aff84ec55d Fix -Wsuggest-attribute=format warnings. 2019-02-27 06:56:50 +01:00
marxin 7de7f0ef17 Fix all -Wtype-limits warnings. 2019-02-21 19:34:35 +01:00
IronicallySerious 4121df235e Fix parameterised macros in core. Addresses #25488
This adds the saves the programmer of doing something like SWAP(x++, y--)
and getting the wrong result unless the parameters are evaluated
before use.
2019-02-18 22:08:42 +05:30
Rémi Verschelde b16c309f82 Update copyright statements to 2019
Happy new year to the wonderful Godot community!
2019-01-01 12:58:10 +01:00
Juan Linietsky 75c29879b0 Disable forced inline when building in debug. 2018-10-02 13:54:15 -03:00
Rémi Verschelde d8b30d42f5 Fix warnings for operator precedence disambiguation [-Wparentheses]
Fixes the following GCC 5 warnings:
```
core/io/resource_format_binary.cpp:1721:29: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
core/typedefs.h:108:24: warning: suggest parentheses around comparison in operand of '!=' [-Wparentheses]
editor/plugins/spatial_editor_plugin.cpp:2202:58: warning: suggest parentheses around comparison in operand of '!=' [-Wparentheses]
editor/plugins/spatial_editor_plugin.cpp:5002:12: warning: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses]
main/input_default.cpp:346:59: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
main/input_default.cpp:348:60: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
main/input_default.cpp:579:57: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
modules/gridmap/grid_map_editor_plugin.cpp:613:14: warning: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses]
modules/theora/video_stream_theora.cpp:335:34: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
modules/theora/video_stream_theora.cpp:336:35: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
modules/visual_script/visual_script_property_selector.cpp:215:38: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
scene/gui/rich_text_label.cpp:424:84: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
scene/gui/rich_text_label.cpp:512:80: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
scene/gui/scroll_container.cpp:173:36: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
scene/gui/scroll_container.cpp:173:86: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
scene/gui/tree.cpp:1419:98: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
```
2018-09-27 10:29:48 +02:00
Rémi Verschelde 277b24dfb7 Make core/ includes absolute, remove subfolders from include path
This allows more consistency in the manner we include core headers,
where previously there would be a mix of absolute, relative and
include path-dependent includes.
2018-09-12 09:52:22 +02:00
Aaron Franke 9170d932e3 [Core] Grammar, move defs to defs
Math constant definitions belong in `math_defs.h`. Also, the grammer in these files really needed some updating.
2018-08-10 22:42:02 -05:00
Hein-Pieter van Braam 0e29f7974b Reduce unnecessary COW on Vector by make writing explicit
This commit makes operator[] on Vector const and adds a write proxy to it.  From
now on writes to Vectors need to happen through the .write proxy. So for
instance:

Vector<int> vec;
vec.push_back(10);
std::cout << vec[0] << std::endl;
vec.write[0] = 20;

Failing to use the .write proxy will cause a compilation error.

In addition COWable datatypes can now embed a CowData pointer to their data.
This means that String, CharString, and VMap no longer use or derive from
Vector.

_ALWAYS_INLINE_ and _FORCE_INLINE_ are now equivalent for debug and non-debug
builds. This is a lot faster for Vector in the editor and while running tests.
The reason why this difference used to exist is because force-inlined methods
used to give a bad debugging experience. After extensive testing with modern
compilers this is no longer the case.
2018-07-26 00:54:16 +02:00
karroffel 43ae1c712f fix nameclash with MSVC 2018-07-18 19:28:26 +02:00
Rémi Verschelde 7c9f7452f4 Style: Format code with clang-format 6.0.1 2018-07-18 16:27:03 +02:00
Rémi Verschelde e4213e66b2 Add missing copyright headers and fix formatting
Using `misc/scripts/fix_headers.py` on all Godot files.
Some missing header guards were added, and the header inclusion order
was fixed in the Bullet module.
2018-01-05 01:22:23 +01:00
Rémi Verschelde b50a9114b1 Update copyright statements to 2018
Happy new year to the wonderful Godot community!
2018-01-01 14:40:47 +01:00
Rémi Verschelde 13c2ff9320 Style: Apply new clang-format 5.0 style to all files 2017-12-07 08:02:00 +01:00
Marcelo Fernandez a97d7d948b Improved *_FAIL_INDEX error macros to print the index/size 2017-10-22 12:17:41 -03:00
Hein-Pieter van Braam 22358babda Implement Linux-style likely()/unlikely() macros
This implement branch prediction macros likely() and unlikely() like in
Linux. When using these macros please ensure that when you use them the
condition in the branch really is very, very likely or unlikely. Think
90+% of the time. Primarily useful for error checking. (And I implement
these macros for all our error checking macros now)

See this article for more information:
https://kernelnewbies.org/FAQ/LikelyUnlikely

There are more places where these macros may make sense in renderer and
physics engine. Placing them will come in another commit down the line.
2017-09-21 18:28:28 +02:00
Rémi Verschelde bd282ff43f Use HTTPS URL for Godot's website in the headers 2017-08-27 14:16:55 +02:00
Marcelo Fernandez eab850524e Add closest_power_of_2 func and implement mix_rate/latency on OS X 2017-08-17 19:51:13 -03:00
Rémi Verschelde 99529fb80d Move VERSION_MKSTRING logic to version.h
Fixes a bug where the VERSION_PATCH define is not yet in scope if
typedefs.h is included before version.h at compilation time.

(cherry picked from commit 3b687c5474)
2017-04-20 12:14:34 +02:00
Rémi Verschelde df61dc4b2b Add "Godot Engine contributors" copyright line 2017-04-08 00:11:42 +02:00
Rémi Verschelde 5dbf1809c6 A Whole New World (clang-format edition)
I can show you the code
Pretty, with proper whitespace
Tell me, coder, now when did
You last write readable code?

I can open your eyes
Make you see your bad indent
Force you to respect the style
The core devs agreed upon

A whole new world
A new fantastic code format
A de facto standard
With some sugar
Enforced with clang-format

A whole new world
A dazzling style we all dreamed of
And when we read it through
It's crystal clear
That now we're in a whole new world of code
2017-03-05 16:44:50 +01:00
Rémi Verschelde 2a0ddc1e89 Style: Various fixes to play nice with clang-format 2017-01-16 08:49:52 +01:00
Juan Linietsky 53ce643e52 -Changed memory functions, Memory::alloc_static*, simplified them, made them aligned to 16
-Changed Vector<> template to fit this.
2017-01-06 10:15:44 -03:00
Rémi Verschelde c7bc44d5ad Welcome in 2017, dear changelog reader!
That year should bring the long-awaited OpenGL ES 3.0 compatible renderer
with state-of-the-art rendering techniques tuned to work as low as middle
end handheld devices - without compromising with the possibilities given
for higher end desktop games of course. Great times ahead for the Godot
community and the gamers that will play our games!
2017-01-01 22:03:33 +01:00
Juan Linietsky fb9d1498bf Cleaner way to enable ptrcall 2016-06-26 11:59:25 -03:00
Rémi Verschelde 81b449908e Add support for patch versions (2.0.x)
(cherry picked from commit 706d576f7b)
2016-03-22 18:41:09 +01:00
Hubert Jarosz 4a4f247914
remove trailing whitespace 2016-03-09 00:00:52 +01:00
est31 0b24a13fa0 Fix bug with nearest_power_of_2_templated
We have to shift log(num of bits) many times not num of bytes many.
2016-02-29 06:51:19 +01:00
Rémi Verschelde 32e1a56cd3 Merge pull request #3771 from est31/fix_memalloc
Fix allocation bug
2016-02-23 22:12:25 +01:00
Ariel Manzur 0846ab6a5f fixes array allocation bug and sets DEFAULT_ALIGNMENT to 1. probably needs testing 2016-02-19 05:40:24 -03:00
est31 fb1e52f4d8 Fix allocation bug if compiled with modern clang or gcc
* Add overflow checked intrinsic abstractions that check on overflow.
* Use them for memory allocation code.
* Use size_t type for memory allocation code to support full platform dependent width.

Fixes #3756.
2016-02-19 07:58:42 +01:00