ClassRegistry

gdext.internal.register.ClassRegistry
object ClassRegistry

Process-global registry backing the static GDExtension class callbacks.

GDExtension callbacks are C function pointers and cannot capture Scala closures, so all per-class and per-instance state lives here and is reached from the static trampolines via opaque tokens:

  • class token: a small integer passed to Godot as class_userdata. The create/get-virtual callbacks use it to find the ClassDescriptor.
  • instance token: a small integer handed to object_set_instance as the instance pointer. The free/virtual-call callbacks use it to find the live GodotScriptClass.

Using integer tokens (rather than raw object addresses) keeps the GC from ever seeing a disguised pointer to a managed object — the Scala instances are held alive by strong references in instances until explicitly freed.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def addExportReleaser(className: String, f: GodotScriptClass => Unit): Unit
def addInstance(obj: GodotScriptClass, objectId: Long): Long

Register a freshly-bound Scala instance. objectId is the Godot instance id of the engine object it is bound to (0 if unknown), used to index the instance so instanceForObjectId can recover this exact object when the same engine node is later fetched through Gd[T].

Register a freshly-bound Scala instance. objectId is the Godot instance id of the engine object it is bound to (0 if unknown), used to index the instance so instanceForObjectId can recover this exact object when the same engine node is later fetched through Gd[T].

Attributes

def classFor(token: Long): ClassDescriptor
def clearClasses(): Unit

Forget all class registrations (instances are kept; see callers).

Forget all class registrations (instances are kept; see callers).

Attributes

def foreachInstance(f: GodotScriptClass => Unit): Unit

Every live Scala instance (for teardown passes).

Every live Scala instance (for teardown passes).

Attributes

def instanceFor(token: Long): GodotScriptClass
def instanceForObjectId(objectId: Long): GodotScriptClass

The canonical Scala instance bound to the engine object with this instance id, or null if none is bound (e.g. a pure engine object).

The canonical Scala instance bound to the engine object with this instance id, or null if none is bound (e.g. a pure engine object).

Attributes

def isClassRegistered(className: String): Boolean

True if a class with this Godot name is already registered.

True if a class with this Godot name is already registered.

Attributes

def parentNameOf(className: String): String

The Godot parent-class name registered for className, or null if unknown. Lets callers order unregistration children-before-parents (Godot refuses to unregister a class while a registered extension class still inherits it).

The Godot parent-class name registered for className, or null if unknown. Lets callers order unregistration children-before-parents (Godot refuses to unregister a class while a registered extension class still inherits it).

Attributes

def registerClass(desc: ClassDescriptor): Long
def registeredClassNames: Array[String]

Names of all currently-registered classes.

Names of all currently-registered classes.

Attributes

def releaseExports(inst: GodotScriptClass): Unit

Run the export releasers of inst's class and every registered parent.

Run the export releasers of inst's class and every registered parent.

Attributes

def removeInstance(token: Long): GodotScriptClass