Commit graph

630 commits

Author SHA1 Message Date
George Marques 0b3819d213
Improve GDNative api.json generator
- Add indexed type to the builtin types output, which is useful for
  bindings implementing array-like access.
- Use getter type instead of hint for property types, as the hint can be
  unreliable and include multiple comma-separated possible types.
2021-02-09 11:37:15 -03:00
George Marques 66ed69edb3
Further changes to GDNative API
- Moved Variant struct definition to its own file so it can be used
  without include cycles (like on Dictionary).
- Add `index` operator function so bindings like C++ can implement the
  operator[] overload (which needs a reference to the actual value).
- Added missing new/destroy functions to Vector3i array.
- Added print error/warning functions as helpers so bindings can print
  messages in the same manner as Godot itself does.
2021-02-09 11:33:35 -03:00
Rafał Mikrut f7209b459b Initialize class/struct variables with default values in modules/ 2021-02-08 10:57:18 +01:00
Miguel de Icaza f02252e37d C conformance: Include stdbool.h to define bool
`bool` is otherwise not defined in C.
2021-02-02 18:11:00 +01:00
Rémi Verschelde 5525cd85c6
Merge pull request #45315 from RandomShaper/modernize_thread
Modernize Thread
2021-01-31 15:24:56 +01:00
George Marques 8a8dbd76b1
Add GDNative JSON generator for the builtin API
Which can be used by language bindings to generate code statically. This
is generated as a different file from the class API because it has
different requirements (the builtin types have constructors and don't
have signals), so bindings can better make use of each JSON file without
extra parsing.

This also cleans up a bit the old API generator, mainly initializing
structs and renaming "instanciable" to the more correct "instantiable".

The argument description in help text was updated to better reflect how
it should be used. The <path> argument is mandatory.
2021-01-29 11:40:37 -03: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
George Marques fa498f6105
Merge pull request #45373 from aaronfranke/gdnative-sizeof
Define GDNative sizes using sizeof(godot_real) and sizeof(int32_t)
2021-01-26 14:00:32 -03:00
Rémi Verschelde f7dd6975fb
Merge pull request #44617 from geekrelief/gdnative_unload
free library when no nativescripts reference it
2021-01-26 15:52:33 +01:00
Aaron Franke 6c197cf259
Define GDNative sizes using sizeof(godot_real_t) and sizeof(int32_t) 2021-01-25 16:42:14 -05:00
George Marques 29e5dd06c7
GDNative: Remove print functions
Those are now utilities so the function pointer can be fetched when
needed.
2021-01-25 09:28:32 -03:00
George Marques 030d1d6a17
GDNative: New core API
This API now uses the discovery functions present in Variant instead of
wrapping every built-in function. Users now need to query for function
pointers and use those.
2021-01-25 09:28:02 -03:00
zero13cool 9f3d7d9709 Changed type to make it work on x32 architecture. 2021-01-05 01:44:52 +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
Rémi Verschelde 058f3fe069
Merge pull request #44149 from madmiraal/rename-tangent-orthogonal
Rename Vector2.tangent() to Vector2.orthogonal()
2020-12-28 16:00:12 +01:00
Marcel Admiraal b628912af0 Rename Rect2 and Rect2i grow_margin() to grow_side() 2020-12-28 12:47:33 +00:00
Marcel Admiraal 5b937d493f Rename empty() to is_empty() 2020-12-28 10:39:56 +00:00
O01eg 1393ededfd
Fix visibility for GCC 2020-12-25 09:56:00 +03:00
geekrelief cc5d8bb5ad Removes the gdnative library when no script (gdns) references it any longer. This enables hot reload for gdnative. 2020-12-23 06:36:01 -08:00
Marcel Admiraal 4b8b803931 Rename Control margin to offset 2020-12-23 06:25:56 +00:00
Marcel Admiraal fdf92ca298 Rename XRPositionalTracker methods
Renames:
- set_type() -> set_tracker_type()
- set_name() -> set_tracker_name()
- get_tracks_orientation() - `is_tracking_orientation()
- get_tracks_position() -> `is_tracking_position()
- get_hand() -> get_tracker_hand()
- set_hand() -> set_tracker_hand()
2020-12-21 06:32:53 +00:00
Rémi Verschelde bccbd4be90
Merge pull request #44261 from madmiraal/rename-trackerhand-enums
Rename TrackerHand enums
2020-12-21 00:26:44 +01:00
Marcel Admiraal 2df9a8ccad Rename Rect2 and Rect2i clip() to intersection() 2020-12-19 12:59:08 +00:00
Marcel Admiraal 8509c8c8fc Rename AcceptDialog get_ok() to get_ok_button()
Also renames:
- AcceptDialog add_cancel() to add_cancel_button()
- ConfirmationDiaglog get_cancel() to get_cancel_button()
2020-12-14 18:43:52 +00:00
bruvzg c1d261fdb0
[Complex Text Layouts] Add variable fonts support. 2020-12-13 18:43:39 +02:00
Marcel Admiraal e40ab06599 Rename TrackerHand enums
Renames:
TRACKER_LEFT_HAND -> TRACKER_HAND_LEFT
TRACKER_RIGHT_HAND -> TRACKER_HAND_RIGHT
2020-12-10 10:30:45 +00:00
Rémi Verschelde edb3686ee2
Merge pull request #44190 from touilleMan/constify-ScriptLanguage.can_inherit_from_file
Constify ScriptLanguage.can_inherit_from_file
2020-12-08 13:59:46 +01:00
Rémi Verschelde 360cfeedac
Merge pull request #44176 from touilleMan/global_class_naming-for-pluginscript
Add PluginScript support for global class naming/icon path
2020-12-08 13:51:06 +01:00
Emmanuel Leblond c4c18a2c58
Add PluginScript support for global class naming/icon path 2020-12-08 13:17:22 +01:00
Emmanuel Leblond a211812932
Constify ScriptLanguage.can_inherit_from_file 2020-12-08 13:06:15 +01:00
Emmanuel Leblond 014efeb272
Allow PluginScript to customize language's can_inherit_from_file attribute 2020-12-08 00:56:01 +01:00
Rémi Verschelde e20011b0da
Merge pull request #44076 from Faless/js/4.x_gdnative
[HTML5] Optional GDNative Support
2020-12-07 15:34:33 +01:00
Marcel Admiraal a24c38d1a8 Rename Vector2.tangent() to Vector2.orthogonal() 2020-12-06 18:16:06 +00:00
Fabio Alessandrelli dd9503dc19 [HTML5] Make GDNative support feature-based.
This is suboptimal as it requires adding an extra compile flag, but
rewriting how feature tags work is beyond the scope of this work.
2020-12-05 01:12:52 +01:00
Fabio Alessandrelli ca34b5e57a [HTML5] GDNative support via SIDE_MODULE.
Working with emscripten >= 2.0.10
2020-12-05 00:52:43 +01:00
George Marques 02f60812ed
Rename TYPE_REAL to TYPE_FLOAT
To be consistent with the naming everywhere else.
2020-12-04 09:47:26 -03:00
Thakee Nathees 42bfa16996 Refactor DocData into core and editor (DocTools) parts 2020-12-02 00:48:39 +05:30
Thakee Nathees d0e7d9b62f Documentation generation for GDScript
- ClassDoc added to GDScript and property reflection data were extracted
from parse tree

- GDScript comments are collected from tokenizer for documentation and
applied to the ClassDoc by the GDScript compiler

- private docs were excluded (name with underscore prefix and doesn't
have any doc comments)

- default values (of non exported vars), arguments are extraced from the
parser

- Integrated with GDScript 2.0 and new enums were added.

- merge conflicts fixed
2020-11-29 19:45:36 +05:30
bruvzg 07d14f5bb8
[Complex Text Layouts] Implement GDNative interface for TextServer. 2020-11-26 13:55:29 +02:00
Rémi Verschelde d76806d322
Core: Always enable ptrcall, remove PTRCALL_ENABLED define
ptrcall is now also used to optimize calls in GDScript, on top of the existing
use by the GDNative and Mono modules.

It no longer makes sense to make it optional.
2020-11-25 14:08:17 +01:00
Aaron Franke 02161aad5a
Remove empty lines around braces with the formatting script 2020-11-16 23:38:11 -05:00
reduz 635d33dc6c Refactor variant built-in methods yet again.
* Using C-style function pointers now, InternalMethod is gone.
* This ensures much better performance in typed code.
* Renamed builtin_funcs to utility_funcs, to avoid naming confusion
2020-11-11 16:36:36 -03:00
Fabio Alessandrelli 05261cceaf Fix gdnative build when WebRTC module is disabled. 2020-11-10 11:42:51 +01:00
Rémi Verschelde b51dca64a6
Merge pull request #43383 from vnen/gdnative-string-header
GDNative: Define special char types in string.h
2020-11-10 09:40:26 +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
George Marques 82576371ef
GDNative: Define special char types in string.h
Those are standard types in C++ but not in C.

This also removes the wchar header which is not needed anymore and use
stddef.h instead (which is needed for size_t).
2020-11-07 16:09:14 -03:00
Hugo Locurcio 7adb6b91b3
Remove Color.contrasted() as its behavior is barely useful
Returning the most contrasting color isn't a trivial task, as there
are often many possible choices. It's usually best left for the user
to implement using a script.
2020-11-03 04:46:08 -05:00
Hugo Locurcio a1d9c67f43
Optimize SVG using svgcleaner --multipass
This decreases the editor binary size by about 8 KB.
2020-10-25 10:02:37 +01:00
Andrii Doroshenko (Xrayez) 650ae413ce GDNative XR: remove redundant config.py
It's not an engine module. This is handled by GDNative's
`SCsub` instead, as done for other subdirectories already.
2020-10-24 23:04:07 +03:00
Stephan Dilly f49199bcc3
add iOS Simulator platform
without this we have to manually drop a `x86_64` builds of gdnative libs into the Xcode project to allow running in `iOS Simulator`
2020-09-19 15:09:36 +02:00
Andrii Doroshenko (Xrayez) 174b6e817f Move GDNative String tests to respective module
GDNative-specific tests moved out of main `tests/` folder into
`modules/gdnative/tests`.

Include path for GDNative headers are still hardcoded in `tests/SCsub`,
but made conditional now.

Also fixed test case tag typos.

Co-authored-by: bruvzg <7645683+bruvzg@users.noreply.github.com>
2020-09-11 14:51:38 +03:00
bruvzg 80b8eff6aa
[Complex Test Layouts] Change String to use UTF-32 encoding on all platforms. 2020-09-03 19:56:24 +03:00
Hugo Locurcio c4903a603b
Add link titles for all links in the class reference
This makes them display in a nicer way in the editor help.
(The title will display instead of the full URL.)
2020-08-31 14:22:07 +02:00
Aaron Franke 56e2c6c704
Make all String float conversion methods be 64-bit 2020-07-27 18:38:53 -04:00
Andrii Doroshenko (Xrayez) d86de6c98e SCons: Refactor running commands through builders
A new `env.Run` method is added which allows to control the verbosity
of builders output automatically depending on whether the "verbose"
option is set. It also allows to optionally run any SCons commands in a
subprocess using the existing `run_in_subprocess` method, unifying
the interface. `Action` objects wrap all builder functions to include a
short build message associated with any action.

Notably, this removes quite verbose output generated by `make_doc_header`
and `make_editor_icons_action` builders.
2020-07-28 00:09:21 +03:00
Rémi Verschelde f940e5e000 CI: Install master version of psf/black
Until https://github.com/psf/black/pull/1328 makes it in a stable release,
we have to use the latest from Git.

Apply new style fixes done by latest black.
2020-07-26 19:48:25 +02:00
George Marques 2b9d9bc364
Remove multilevel calls
In general they are more confusing to users because they expect
inheritance to fully override parent methods. This behavior can be
enabled by script writers using a simple super() call.
2020-07-24 14:13:58 -03:00
Rémi Verschelde a5fb445121
Merge pull request #40450 from asmaloney/spelling
Fix spelling & grammar in comments, docs, and messages
2020-07-21 22:14:04 +02:00
Andy Maloney 4dda62f591 Fix spelling & grammar in comments, docs, and messages 2020-07-21 15:17:23 -04:00
Aaron Franke 83e324d670
Update core documentation to match recent C# changes
Also a few minor API changes like adding AABB.abs()

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2020-07-21 14:44:53 -04:00
Rémi Verschelde 6497a3fb50
Merge pull request #40291 from hinlopen/dialog-size
Resize various dialogs
2020-07-15 12:13:33 +02:00
Rémi Verschelde 9bda8df46c
Merge pull request #40386 from touilleMan/correct-Reference-is_reference-api.json
Correct is_reference attribute in api.json for Reference class
2020-07-15 08:29:36 +02:00
Emmanuel Leblond 37de4982ca
Add missing has_default_value field for signals in api.json 2020-07-14 23:12:44 +02:00
Emmanuel Leblond b5c80088ce
Correct is_reference attribute in api.json for Reference class 2020-07-14 18:20:20 +02:00
Stijn Hinlopen 526e060b73 Resize dialogs (FileDialog, EditorFileDialog, Reparent, SceneTreeDialog and resource depency dialogs). 2020-07-14 14:35:22 +02:00
Aaron Franke 9986439352
Commit other files changed by file_format.sh 2020-07-13 14:14:11 -04:00
Marcel Admiraal 26fcf2b04c Add override keywords. 2020-07-10 13:56:54 +01:00
Aaron Franke af80bcd2f8
Add sort and has methods to PackedArrays 2020-07-06 22:16:39 -04:00
Rémi Verschelde c020eea184
Merge pull request #40092 from hinlopen/remove-find-last
Remove String::find_last (same as rfind)
2020-07-04 01:38:01 +02:00
Stijn Hinlopen 929b98d24b Remove String::find_last (same as rfind) 2020-07-03 15:26:22 +02:00
Rémi Verschelde 64aa25b2e5
Merge pull request #40050 from naithar/feature/ios-gdnative-master-2
[4.0] Add support of iOS's dynamic libraries to GDNative
2020-07-03 07:48:13 +02:00
Sergey Minakov 294416c84c GDNative export: do not add fake lookup table if static lib is not used 2020-07-02 17:43:04 +03:00
Sergey Minakov ad2248a3bd GDNative Editor: Support selecting frameworks for iOS 2020-07-02 13:00:27 +03:00
Sergey Minakov 9086599ae6 GDNative: support dynamic loading of iOS frameworks 2020-07-02 12:55:49 +03:00
Rémi Verschelde a8a2769bb6
Merge pull request #38713 from aaronfranke/string-64bit
Make all String integer conversion methods be 64-bit
2020-07-01 16:01:05 +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
Mark Kuo 3b05d2c989 VideoStreamGDNative: close file in cleanup
We should close the file handle when we are done.
2020-06-28 10:20:07 +10:00
Rémi Verschelde 23f7f86914 Style: Fix copyright headers 2020-06-25 16:33:44 +02:00
Rémi Verschelde 08ef0aab16 Export: Rename 'Windows Universal' to 'UWP'
It's otherwise too easy to be confused between 'Windows Desktop' (Win32)
and 'Windows Universal' (UWP).
2020-06-19 16:31:28 +02:00
Rémi Verschelde ba0db95909 DocData: Skip language-specific ClassDoc without methods/constants
Removes the useless `@C#`, `@NativeScript` and `@VisualScript` entries.
2020-06-17 15:09:07 +02:00
bruvzg c3e615e21b
GDNative: merge API structs, bump version of merged structs. 2020-06-11 18:26:47 +03:00
Aaron Franke e5ae89775a
Remove 32-bit String hex_to_int method 2020-06-03 00:03:34 -04:00
Aaron Franke bb8aa107fd
Remove 32-bit String to_int method 2020-06-03 00:03:34 -04:00
bruvzg 9fbc424d4c
GDNative: Add bindings for the Packed*Array ptr() and ptrw() functions. 2020-05-26 17:02:02 +03:00
bruvzg 74eecd1d6b
GDNative add new core types. 2020-05-18 15:52:20 +03:00
bruvzg 48d133a5fd
Fix GDNative wrapper type sizes (RID, Variant, Packed*Array), add size checking static asserts. 2020-05-16 13:58:42 +03: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
Rémi Verschelde a1aaed5a84 Remove redundant void argument lists
Using clang-tidy's `modernize-redundant-void-arg`.
https://clang.llvm.org/extra/clang-tidy/checks/modernize-redundant-void-arg.html
2020-05-14 13:51:45 +02:00
Rémi Verschelde 1f6f364a56 Port member initialization from constructor to declaration (C++11)
Using `clang-tidy`'s `modernize-use-default-member-init` check and
manual review of the changes, and some extra manual changes that
`clang-tidy` failed to do.

Also went manually through all of `core` to find occurrences that
`clang-tidy` couldn't handle, especially all initializations done
in a constructor without using initializer lists.
2020-05-14 10:01:56 +02:00
Rémi Verschelde 94721f5ab8 Revert "Renamed plane's d to distance"
This reverts commit ec7b481170.

This was wrong, `d` is not a distance but the `d` constant in the
parametric equation `ax + by + cz = d` describing the plane.
2020-05-10 16:47:11 +02:00
Rémi Verschelde e956e80c1f Style: clang-format: Disable AllowShortIfStatementsOnASingleLine
Part of #33027, also discussed in #29848.

Enforcing the use of brackets even on single line statements would be
preferred, but `clang-format` doesn't have this functionality yet.
2020-05-10 13:12:16 +02:00
Marcus Elg ec7b481170 Renamed plane's d to distance 2020-05-10 12:12:51 +02:00
Aaron Franke 540156b387
[Core] Rename linear_interpolate to lerp 2020-04-29 04:02:49 -04:00
Rémi Verschelde fdf58a5858 Rename InputFilter back to Input
It changed name as part of the DisplayServer and input refactoring
in #37317, with the rationale that input no longer goes through the
main loop, so the previous Input singleton now only does filtering.

But the gains in consistency are quite limited in the renaming, and
it breaks compatibility for all scripts and tutorials that access
the Input singleton via the scripting language. A temporary option
was suggested to keep the scripting singleton named `Input` even if
its type is `InputFilter`, but that adds inconsistency and breaks C#.

Fixes godotengine/godot-proposals#639.
Fixes #37319.
Fixes #37690.
2020-04-28 15:19:49 +02:00
Juan Linietsky 5d4dc2d45c Add ability to bind typed arrays to script API
Note: Only replaced 2 instances to test, Node.get_children and TileMap.get_used_cells
Note: Will do a mass replace on later PRs of whathever I can find, but probably need
a tool to grep through doc.
Warning: Mono will break, needs to be fixed (and so do TypeScript and NativeScript, need to ask respective maintainers)
2020-04-21 10:15:40 +02:00
Juan Linietsky ae09b55a19 Exposed RenderingDevice to script API
Also added an easier way to load native GLSL shaders.

Extras:

Had to fix no-cache for subresources in resource loader, it was not properly working, making shaders not properly reload.

Note:

The precommit hooks are broken because they don't seem to support enums from one class being used in another.
Feel free to fix this after merging this PR.
2020-04-20 21:21:58 -03:00
Rémi Verschelde 2cd952bd84 Fix handling of PROPERTY_USAGE_SUBGROUP in DocData and editor
Subgroups were added in #37678 but not properly handled everywhere
where PROPERTY_USAGE_GROUP is.
2020-04-20 17:13:06 +02:00
Rémi Verschelde d41444b0d8
Merge pull request #37693 from lupoDharkael/remove-hint
Remove obsolete enums
2020-04-10 11:47:44 +02:00