Commit graph

528 commits

Author SHA1 Message Date
Pedro J. Estébanez 469fa47e06
Make all file access 64-bit (uint64_t)
This changes the types of a big number of variables.

General rules:
- Using `uint64_t` in general. We also considered `int64_t` but eventually
  settled on keeping it unsigned, which is also closer to what one would expect
  with `size_t`/`off_t`.
- We only keep `int64_t` for `seek_end` (takes a negative offset from the end)
  and for the `Variant` bindings, since `Variant::INT` is `int64_t`. This means
  we only need to guard against passing negative values in `core_bind.cpp`.
- Using `uint32_t` integers for concepts not needing such a huge range, like
  pages, blocks, etc.

In addition:
- Improve usage of integer types in some related places; namely, `DirAccess`,
  core binds.

Note:
- On Windows, `_ftelli64` reports invalid values when using 32-bit MinGW with
  version < 8.0. This was an upstream bug fixed in 8.0. It breaks support for
  big files on 32-bit Windows builds made with that toolchain. We might add a
  workaround.

Fixes #44363.
Fixes godotengine/godot-proposals#400.

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2021-05-17 15:06:19 +02:00
Rémi Verschelde 8247667a3e
Core: Drop custom copymem/zeromem defines
We've been using standard C library functions `memcpy`/`memset` for these since
2016 with 67f65f6639.

There was still the possibility for third-party platform ports to override the
definitions with a custom header, but this doesn't seem useful anymore.
2021-04-27 16:26:27 +02:00
George Marques f8dd7917ec
Add flag to stop printing to stdout/stderr
This allows the terminal output to be suppressed but still be captured
by print/error handlers.
2021-04-06 07:36:41 -03:00
Rémi Verschelde c6b9ceadf2
Merge pull request #47163 from bruvzg/macos_sandbox_file_dialog
FileDialog: add Back/Forward buttons, add message for inaccessible folders.
2021-03-26 00:00:25 +01:00
Aaron Franke a5324787c8
Rename some more global enums (Key, Joy, MIDI) 2021-03-23 07:13:23 -04:00
bruvzg b202a0dd2a
FileDialog: add Back/Forward buttons, add message for inaccessible folders. 2021-03-23 08:03:41 +02:00
Alex Hirsch c28428fe4d Allow nullptr with zero length in FileAccess get_buffer
fix #47071
2021-03-16 22:55:11 +01:00
Rémi Verschelde 8051307efe
Merge pull request #46810 from W4RH4WK/file-access-get-buffer-parameter-checks
Add parameter checks to FileAccess get_buffer functions
2021-03-14 01:11:55 +01:00
Anshul7sp1 91181c2086 Fixes small typos and grammar correction 2021-03-12 19:05:16 +05:30
Alex Hirsch cdf3099c68 Add parameter checkes to FileAccess get_buffer functions
fix #46540
2021-03-09 13:55:20 +01:00
bruvzg 741e1cf672
Move caller_id init to Thread constructor to fix UWP build. 2021-03-09 08:40:30 +02:00
bruvzg 9887c2b4f0
Improve thread IDs to avoid collisions with threads not created by the Godot API. 2021-03-07 00:17:20 +02:00
Fabio Alessandrelli dfbeb5ae29 Fix thread_process_array when NO_THREADS. 2021-02-26 12:13:20 +01:00
Rémi Verschelde 94f78f276b
Merge pull request #45061 from razonixx/Add_warning_when_dir_is_inaccesible
Add descriptive error message when trying to access a dir fails
2021-02-25 22:39:59 +01:00
Carlos Cabello edb8c11970 Add descriptive error message when trying to access a dir fails 2021-02-25 22:24:21 +01:00
Emmanuel Leblond 60d2c1fd47
Remove GDScript bindings for OS.get/set_exit_code, SceneTree.quit(<exit_code>) should be used instead 2021-02-25 18:34:50 +01:00
Emmanuel Leblond 0e4abcb77f
Fix Godot returned status code on unexpected error 2021-02-25 18:01:37 +01:00
Pedro J. Estébanez afc5af8dfa Prevent thread wait on itself for finish 2021-02-25 13:16:27 +01:00
Rémi Verschelde 247b7e2448
Merge pull request #46131 from bruvzg/move_tablet_to_ds
Move tablet driver API from OS to DisplayServer
2021-02-18 20:36:46 +01:00
Pedro J. Estébanez 8e128726f0 Modernize atomics
- Based on C++11's `atomic`
- Reworked `SafeRefCount` (based on the rewrite by @hpvb)
- Replaced free atomic functions by the new `SafeNumeric<T>`
- Replaced wrong cases of `volatile bool` by the new `SafeFlag`
- Platform-specific implementations no longer needed

Co-authored-by: Hein-Pieter van Braam-Stewart <hp@tmm.cx>
2021-02-18 17:12:46 +01:00
bruvzg 3e0262509f
Move tablet driver API from OS to DisplayServer. 2021-02-18 17:12:24 +02:00
Pedro J. Estébanez 99fe462452 Modernize Thread
- Based on C++11's `thread` and `thread_local`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed (except for the few cases of non-portable functions)
- Simpler for `NO_THREADS`
- Thread ids are now the same across platforms (main is 1; others follow)
2021-01-29 12:02:13 +01:00
Pedro J. Estébanez 8ed259b792 Modernize RWLock
- Based on C++14's `shared_time_mutex`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
2021-01-19 11:53:10 +01:00
Marcel Admiraal 2a74b388d0 Split OS::execute into two methods
1. execute(): Executes a command and returns the results.
2. create_process(): Creates a new process and returns the new process' id.
2021-01-09 10:03:23 +00: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
Marcel Admiraal d9e9eb8d04 Rename MainLoop methods to match Node methods 2020-12-22 12:34:57 +00:00
Alf Kraus 68fdd753a7 wrong double quote output with .csv fixed 2020-12-11 11:42:43 +01:00
bruvzg 644f739660
Static analyzer fixes:
Removes unused code in OS.
Fixes return types.
Fixes few typos.
2020-12-09 10:17:53 +02:00
bruvzg 493da99269
[Complex Text Layouts] Implement TextServer interface. Implement Fallback TextServer. 2020-11-26 13:55:26 +02:00
Rafał Mikrut 7bd03b7188 Initialize class/struct variables with default values in core/ and drivers/ 2020-11-23 17:38:46 +01:00
Aaron Franke 02161aad5a
Remove empty lines around braces with the formatting script 2020-11-16 23:38:11 -05:00
Rémi Verschelde 32464e569f
Merge pull request #40748 from RandomShaper/improve_packed_fs_api
Improve/fix packed data API
2020-11-10 10:59:34 +01: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
HaSa1002 f8ac4c4d75 MainLoop: Remove deprecated methods 2020-11-01 12:38:30 +01:00
Rémi Verschelde 819c3524a5
OS: Remove unused get_splash_tick_msec
It was added in 3e20391bf6 but it doesn't seem
particularly useful, and it was only implemented for the custom splash branch
and not the default one, so it could return an uninitialized int.
2020-09-24 15:40:30 +02:00
bruvzg 80b8eff6aa
[Complex Test Layouts] Change String to use UTF-32 encoding on all platforms. 2020-09-03 19:56:24 +03:00
Andrii Doroshenko (Xrayez) 0cc05c5a31 Register GDScript test tools as test commands to run via command-line 2020-09-02 01:43:26 +03:00
Pedro J. Estébanez f38949a44d Improve/fix packed data API
- Enhance directory API
- Fix `FileAccess::exists()` not checking for PackedData being disabled
- Fix moving to the parent directory (`..`)
- Allow absolute paths in existence checks
2020-07-27 12:06:40 +02:00
PouleyKetchoupp b2d27214aa Keep debug & verbose options after loading project from project manager 2020-07-09 09:51:32 +02:00
Fabio Alessandrelli 1b6e3458b2 Move frame delaying functions from Main to OS.
Will allow specific platforms to override it and avoid blocking on the
main/GUI thread.
2020-06-30 19:39:09 +02:00
Juan Linietsky 438c380458 Add a separate application focus/in notification out from Window focus notification. 2020-06-30 10:40:06 -03:00
Rémi Verschelde 4b5b60de85
Merge pull request #39189 from touilleMan/issue-38925
Unify OS.get_system_time_* and OS.get_unix_time
2020-06-15 23:57:16 +02:00
Hugo Locurcio 9c0d214776
Print errors when calling MIDI input methods on unsupported platforms
This partially addresses #32065.
2020-05-31 19:10:27 +02:00
Emmanuel Leblond c6de3872f9
Remove OS.get_system_time_secs/get_system_time_msecs and change OS.get_unix_time return type to double 2020-05-31 14:19:31 +02:00
bruvzg d0b5174b6a
[Windows] Add tablet driver selection. 2020-05-20 09:37:32 +03:00
Rémi Verschelde 85220fec01 Style: Remove unnecessary semicolons from core
Semicolons are not necessary after function definitions or control flow
blocks, and having some code use them makes things inconsistent (and
occasionally can mess up `clang-format`'s formatting).

Removing them is tedious work though, I had to do this manually (regex
+ manual review) as I couldn't find a tool for that. All other code
folders would need to get the same treatment.
2020-05-19 15:57:56 +02:00
Rémi Verschelde ca3192d18a Style: Fix unnecessary semicolons that confused clang-format 2020-05-19 11:24:58 +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 07bc4e2f96 Style: Enforce separation line between function definitions
I couldn't find a tool that enforces it, so I went the manual route:
```
find -name "thirdparty" -prune \
  -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \
  -o -name "*.glsl" > files
perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files)
misc/scripts/fix_style.sh -c
```

This adds a newline after all `}` on the first column, unless they
are followed by `#` (typically `#endif`). This leads to having lots
of places with two lines between function/class definitions, but
clang-format then fixes it as we enforce max one line of separation.

This doesn't fix potential occurrences of function definitions which
are indented (e.g. for a helper class defined in a .cpp), but it's
better than nothing. Also can't be made to run easily on CI/hooks so
we'll have to be careful with new code.

Part of #33027.
2020-05-14 16:54:55 +02:00
Rémi Verschelde 0be6d925dc Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to
will now be changed automatically to remove the first empty line.

This makes us lean closer to 1TBS (the one true brace style) instead
of hybridating it with some Allman-inspired spacing.

There's still the case of braces around single-statement blocks that
needs to be addressed (but clang-format can't help with that, but
clang-tidy may if we agree about it).

Part of #33027.
2020-05-14 16:54:55 +02:00