Fix docs don't give justification for manual construction.
Clarify how to apply manual StringName construction as an
optimization and that "string intern" means "work at parse time".
There are several godot-demo-projects (including 3d/platformer) that
incorrectly use StringName literals (they use & literals instead of just
passing strings), so clearly this is confusing.
AThousandShips did a disassembly test to prove it automatically converts
constant strings to StringName for annotated functions:
func do_test(_var: StringName, _var2: String):
pass
func test():
do_test("abc", "def")
Yields:
Disassembling do_test(_var, _var2)
0: line 2: pass
2: == END ==
Disassembling test()
0: line 5: do_test("abc", "def")
2: call self.do_test(const(&"abc"), const("def"))
10: assign stack(3) = false
12: == END ==
It also happens with built-in functions such as those of Input.
- Create CSharpScript for generic C# types.
- `ScriptPathAttributeGenerator` registers the path for the generic type definition.
- `ScriptManagerBridge` lookup uses the generic type definition that was registered by the generator.
- Constructed generic types use a virtual `csharp://` path so they can be registered in the map and loaded as if there was a different file for each constructed type, even though they all share the same real path.
- This allows getting the base type for a C# type that derives from a generic type.
- Shows base scripts in the _Add Node_ and _Create Resource_ dialogs even when they are generic types.
- `get_global_class_name` implementation was moved to C# and now always returns the base type even if the script is not a global class (this behavior matches GDScript).
- Create `CSharpScript::TypeInfo` struct to hold all the type information about the C# type that corresponds to the `CSharpScript`, and use it as the parameter in `UpdateScriptClassInfo` to avoid adding more parameters.
Besides the regular option to export GDScript as binary tokens, this
also includes a compression option on top of it. The binary format
needs to encode some information which generally makes it bigger than
the source text. This option reduces that difference by using Zstandard
compression on the buffer.
This adds back a function available in 3.x: exporting the GDScript
files in a binary form by converting the tokens recognized by the
tokenizer into a data format.
It is enabled by default on export but can be manually disabled. The
format helps with loading times since, the tokens are easily
reconstructed, and with hiding the source code, since recovering it
would require a specialized tool. Code comments are not stored in this
format.
The `--test` command can also include a `--use-binary-tokens` flag
which will run the GDScript tests with the binary format instead of the
regular source code by converting them in-memory before the test runs.