Gamend.GDScript.Registry (gamend_plugin_tools v1.0.1220)

Copy Markdown View Source

What every script in a plugin exposes to the others.

Godot makes a script globally reachable by declaring class_name Foo, and any other script then calls Foo.method() without importing anything. That is the mechanism here too: the compiler parses every scripts/*.gd first, records the ones that name themselves, and resolves cross-script calls against that record -- so a typo or a wrong argument count is still a compile error, across files as well as within one.

Reference mode is decided for the whole plugin rather than per file. A reference passed from one script to another has to stay a reference, and it can: they run in the same hook process, so the heap is shared. Cross-script calls go straight to the private body and skip the boundary entirely, which is why the boxing cost is still paid once per hook invocation rather than once per call.

Summary

Functions

Build the registry from parsed scripts: [{module, statements}].

True when any script mutates in place or declares a class.

Types

entry()

@type entry() :: %{
  module: String.t(),
  functions: MapSet.t({String.t(), non_neg_integer()})
}

t()

@type t() :: %{optional(String.t()) => entry()}

Functions

build(scripts)

@spec build([{String.t(), [tuple()]}]) :: t()

Build the registry from parsed scripts: [{module, statements}].

ref_mode?(scripts, mutates?)

@spec ref_mode?([{String.t(), [tuple()]}], (list() -> boolean())) :: boolean()

True when any script mutates in place or declares a class.