summaryrefslogtreecommitdiff
path: root/modules/mono/csharp_script.cpp
AgeCommit message (Collapse)Author
2020-07-26Merge pull request #40595 from neikeq/godot-net-sdk-and-net-standardRémi Verschelde
C#: Switch games to MSBuild Sdks and .NET Standard
2020-07-25C#: Switch games to MSBuild Sdks and .NET StandardIgnacio Etcheverry
Godot.NET.Sdk ------------- Godot uses its own custom MSBuild Sdk for game projects. This new Sdk adds its own functionality on top of 'Microsoft.NET.Sdk'. The new Sdk is resolved from the NuGet package. All the default boilerplate was moved from game projects to the Sdk. The default csproj for game project can now be as simple as: ``` <Project Sdk="Godot.NET.Sdk/4.0.0-dev2"> <PropertyGroup> <TargetFramework>netstandard2.1</TargetFramework> </PropertyGroup> </Project> ``` Source files are included by automatically so Godot no longer needs to keep the csproj in sync when creating new source files. Define constants ---------------- Godot defines a list of constants for conditional compilation. When exporting games, this list also included engine 'features' and platform 'bits'. There were a few problems with that: - The 'features' constants were only defined when exporting games. Not when building the game for running in the editor player. - If the project was built externally by an IDE, the constants wouldn't be defined at all. The new Sdk assigns default values to these constants when not built from the Godot editor, i.e.: when built from an IDE or from the command line. The default define constants are determined from the system MSBuild is running on. However, it's not possible for MSBuild to determine the set of supported engine features. It's also not possible to determine if a project is being built to run on a 32-bit or 64-bit Godot executable. As such the 'features' and 'bits' constants had to be removed. The benefit of checking those at compile time was questionable, and they can still be checked at runtime. The new list of define constants includes: - GODOT - GODOT_<PLATFORM> Defaults to the platform MSBuild is running on. - GODOT_<PC/MOBILE/WEB> - TOOLS When building with the 'Debug' configuration (editor and editor player). - GODOT_REAL_T_IS_DOUBLE Not defined by default unless $(GodotRealTIsDouble) is overriden to be 'true'. .NET Standard ------------- The target framework of game projects was changed to 'netstandard2.1'.
2020-07-24Remove multilevel callsGeorge Marques
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-13Commit other files changed by file_format.shAaron Franke
2020-07-05Mono/C#: Fix several clang-tidy warnings and cleanupIgnacio Etcheverry
2020-05-30Fixes building mono release templatesNutmegStudio
2020-05-22Mono/C#: Fix values not updated in remote inspectorIgnacio Etcheverry
2020-05-19Mono/C#: Remove script load error about not a Godot.ObjectIgnacio Etcheverry
Any C# file can be loaded as script and at load time we don't yet know if it's actually meant to be used as a script. As such, such an check can result in a lot of false errors. If the file is really meant to be used as a script, an error would be printed later when attempting to instantiate it any way.
2020-05-14Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocksRémi Verschelde
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-14Modernize remaining uses of 0/NULL instead of nullptr (C++11)Rémi Verschelde
Using clang-tidy's `modernize-use-nullptr`. https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
2020-05-11Merge pull request #38638 from pepegadeveloper123/mono_inherited_scene_bugRémi Verschelde
Fix inherited C# scene not inheriting parent's fields
2020-05-10Implement CSharpScript::inherits_scriptIgnacio Etcheverry
2020-05-11Inherited C# scene not inheriting parent's fieldspepegadeveloper123
When a child scene inherits a parent scene with a C# root node, the parent scene's export variables appear to assume values set in the parent scene, in the child scene's Inspector. However, when the child scene is played, the parent scene's export variables assume default values. When a node is created, it inherits its parent C# script's fields from the map CSharpScriptInstance::script->member_info. However this map was not initialized outside the editor, and this commit ensured it is. This fixes issues #36480 and #37581.
2020-05-09Mono: Fix hot-reloading of nested classesIgnacio Etcheverry
2020-04-21Add ability to bind typed arrays to script APIJuan Linietsky
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-20Exposed RenderingDevice to script APIJuan Linietsky
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-02Replace NULL with nullptrlupoDharkael
2020-04-01Merge pull request #37484 from Calinou/csharp-verbatim-string-highlightRémi Verschelde
Remove syntax highlighting for C# verbatim strings due to bugs
2020-04-01Remove syntax highlighting for C# verbatim strings due to bugsHugo Locurcio
This closes #32336.
2020-03-31Mono/C#: Add iOS supportIgnacio Etcheverry
Right now, games only work on devices when exported with FullAOT+Interpreter. There are some issues left that need to addressed for FullAOT alone. Right now, it's giving issues with the Godot.NativeCalls static constructor.
2020-03-18Merge pull request #37116 from neikeq/issue-12917Rémi Verschelde
Sync csproj when files are changed from the Godot FileSystem dock
2020-03-18Sync csproj when files are changed from the Godot FileSystem dockIgnacio Etcheverry
2020-03-18Merge pull request #36756 from aaronfranke/mono-vec2i3iIgnacio Roldán Etcheverry
[Mono] Add Vector2i and Vector3i
2020-03-17[Mono] Marshaling for Vector2i, Vector3i, and Rect2iAaron Franke
2020-03-17Mono/C#: Optimize the way we store GC handles for scriptsIgnacio Etcheverry
Don't store GC handles for C# script instances and instance bindings as 'Ref<MonoGCHandle>'; store the raw data instead. Initially this was not possible as we needed to store a Variant, but this had not been the case for a looong time yet the stored type was never updated.
2020-03-17Fix C# bindings after recent breaking changesIgnacio Etcheverry
Implementation for new Variant types Callable, Signal, StringName. Added support for PackedInt64Array and PackedFloat64Array. Add generation of signal members as events, as well as support for user created signals as events. NOTE: As of now, raising such events will not emit the signal. As such, one must use `EmitSignal` instead of raising the event directly. Removed old ThreadLocal fallback class. It's safe to use thread_local now since it's supported on all minimum versions of compilers we support.
2020-03-17Style: Set clang-format Standard to Cpp11Rémi Verschelde
For us, it practically only changes the fact that `A<A<int>>` is now used instead of the C++03 compatible `A<A<int> >`. Note: clang-format 10+ changed the `Standard` arguments to fully specified `c++11`, `c++14`, etc. versions, but we can't use `c++17` now if we want to preserve compatibility with clang-format 8 and 9. `Cpp11` is still supported as deprecated alias for `Latest`.
2020-03-08Refactor ScriptDebugger.Fabio Alessandrelli
EngineDebugger is the new interface to access the debugger. It tries to be as agnostic as possible on the data that various subsystems can expose. It allows 2 types of interactions: - Profilers: A subsystem can register a profiler, assigning it a unique name. That name can be used to activate the profiler or add data to it. The registered profiler can be composed of up to 3 functions: - Toggle: called when the profiler is activated/deactivated. - Add: called whenever data is added to the debugger (via `EngineDebugger::profiler_add_frame_data`) - Tick: called every frame (during idle), receives frame times. - Captures: (Only relevant in remote debugger for now) A subsystem can register a capture, assigning it a unique name. When receiving a message, the remote debugger will check if it starts with `[prefix]:` and call the associated capture with name `prefix`. Port MultiplayerAPI, Servers, Scripts, Visual, Performance to the new profiler system. Port SceneDebugger and RemoteDebugger to the new capture system. The LocalDebugger also uses the new profiler system for scripts profiling.
2020-02-28Removed interactive loader, added proper thread loading.Juan Linietsky
2020-02-26Reimplement Mutex with C++'s <mutex>Pedro J. Estébanez
Main: - It's now implemented thanks to `<mutex>`. No more platform-specific implementations. - `BinaryMutex` (non-recursive) is added, as an alternative for special cases. - Doesn't need allocation/deallocation anymore. It can live in the stack and be part of other classes. - Because of that, it's methods are now `const` and the inner mutex is `mutable` so it can be easily used in `const` contexts. - A no-op implementation is provided if `NO_THREADS` is defined. No more need to add `#ifdef NO_THREADS` just for this. - `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`. - Thread-safe utilities are therefore simpler now. Misc.: - `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same. - Every case of lock, do-something, unlock is replaced by `MutexLock` (complex cases where it's not straightfoward are kept as as explicit lock and unlock). - `ShaderRD` contained an `std::mutex`, which has been replaced by `Mutex`.
2020-02-25Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.Juan Linietsky
- Renames PackedIntArray to PackedInt32Array. - Renames PackedFloatArray to PackedFloat32Array. - Adds PackedInt64Array and PackedFloat64Array. - Renames Variant::REAL to Variant::FLOAT for consistency. Packed arrays are for storing large amount of data and creating stuff like meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of memory. That said, many users requested the ability to have 64 bits packed arrays for their games, so this is just an optional added type. For Variant, the float datatype is always 64 bits, and exposed as `float`. We still have `real_t` which is the datatype that can change from 32 to 64 bits depending on a compile flag (not entirely working right now, but that's the idea). It affects math related datatypes and code only. Neither Variant nor PackedArray make use of real_t, which is only intended for math precision, so the term is removed from there to keep only float.
2020-02-20Reworked signal connection system, added support for Callable and Signal ↵Juan Linietsky
objects and made them default.
2020-02-18PoolVector is gone, replaced by VectorJuan Linietsky
Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are sugar for `Vector<Type>`.
2020-02-15Changed logic and optimized ObjectID in ObjectDB and Variant, removed RefPtr.Juan Linietsky
2020-02-13Remove deprecated sync and slave networking keywordsRémi Verschelde
Those keywords were deprecated for 3.1 in #22087. Also fix token name for `TK_REMOTE`, should be "remote" like the keyword.
2020-02-12Fix Mono and GDNative builds after changes to ObjectIDRémi Verschelde
Issues caused by cf8c679a23b21d6c6f29cba6a54eaa2eed88bf92. The Mono change is actually a bugfix (used the int instead of ObjectID by mistake). The GDNative change is a temporary revert until a more exhaustive approach is taken to make 'godot_int' 64-bit, is confirmed wanted by GDNative users.
2020-02-12Optmized data sent during RPC and RSet calls.Andrea Catania
- Now is sent the method ID rather the full function name. - The passed IDs (Node and Method) are compressed so to use less possible space. - The variant (INT and BOOL) is now encoded and compressed so to use much less data. - Optimized RPCMode retrieval for GDScript functions. - Added checksum to assert the methods are the same across peers. This work has been kindly sponsored by IMVU.
2020-02-08Remove do{ } while(0) wrapper around error macros.Marcel Admiraal
As pointed out by Faless, a do{ } while(0) wrapper around a continue or break just ends the do{ } while(0) loop. The do{ } while(0) loop exists to enable the macro to be used as a function which requires a semicolon. The alternative approach is to use an if(1) { } else ((void)0) wrapper. Since the macro already has an if(unlikely(m_cond)) { } this patch simply adds the else ((void)0) to this if statement instead. For consistency all the macros have been updated in the same way, and trailing else warnings corrected. However, the wrappers around ERR_PRINT and WARN_PRINT were removed, because they generated too many ambiguous trailing else warnings. They are also single line macros so a wrapper is not needed.
2020-02-05Remove duplicate ERR_PRINT macro.Marcel Admiraal
2020-01-24Merge pull request #35527 from neikeq/issue-35259Rémi Verschelde
Mono/C#: Fix _update_exports possible crash with Reference types
2020-01-24Mono/C#: Fix _update_exports possible crash with Reference typesIgnacio Etcheverry
The code was attempting to dynamic cast the native instance to Reference after the managed instance was disposed. As the managed instance acts as a Ref, the native instance was freed during that disposal. This made the dynamic cast fail and we attempted to memdelete a second time. The fix is to make the dynamic cast before disposal.
2020-01-23Mono/C#: Lighten up unsafe reference checksIgnacio Etcheverry
Because of the weird case with multi-threading and ResourceLoader, it can be the case that a resource is GCed while being referenced again in the main thread. In such cases, a new unsafe reference is created before the finalizer thread removes the previous one.
2020-01-19Fix ClassDB API portability with some android and editor classesIgnacio Etcheverry
- `EditorNavigationMeshGenerator` was being registered as part of the Core API, even after d3f48f88bb84d22b7805ce971ac86cf1953a29fd. We must make sure to set Editor as the current ClassDB API type before creating an instance. - The `VisualScriptEngineSingleton.constant` property has a property hint string that's different between tools and non-tools builds. This commit makes the hint string to no longer be set in `_bind_methods`, and to instead set it in `_validate_property`. This way it's ignored when calculating the API hash. - `JavaClassWrapper` is now registered in ClassDB on all platforms, using a dummy implementation on platforms other than Android. This fixes API portability between Android and other platforms. - Updated `--class-db-json` command to ignore non-virtual methods that start with an underscore (see: 4be87c6016a5893cbde897924e540df4c988cee5).
2020-01-16Merge pull request #35208 from neikeq/mono-lazy-thread-attachIgnacio Roldán Etcheverry
Mono/C#: Script interface calls now attach the current thread
2020-01-16Mono/C#: Script interface calls now attach the current threadIgnacio Etcheverry
Added guards to all C# script interface calls to attach the current thread for the current scope if the thread is not already attached. This is far from ideal, as attaching the thread is not cheap and all managed thread local storage is lost when we detach the thread at the end of the calls. However, it's the best we can do for now to avoid crashing when an unattached thread tries to interact with C# code.
2020-01-15Mono/C#: Fix false positive in unsafe reference checksIgnacio Etcheverry
2020-01-13Mono/C#: Add error checks to detect possible Reference leaksIgnacio Etcheverry
2020-01-13Mono/C#: Fix _update_exports() leaking temporary Object/Node instancesIgnacio Etcheverry
2020-01-01Update copyright statements to 2020Rémi Verschelde
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.
2019-12-24Cleans up headers included in editor_node.hHaoyu Qiu