@startuml
autoactivate on
header Overview of the ""RubyLanguage"" Family’s Call Sequence
footer page %page% of %lastpage%
participant godot [
//Godot Engine//
//& GDExtension//
]
participant lang [
""Godot::""
""RubyLanguage""
singleton
]
participant script [
Script
(""Godot::RubyScript""
instance)
]
participant class [
""Godot::Object""
class
]
participant instance [
""GDExtension""
""ScriptInstancePtr""
]
participant object [
""Godot::Object""
instance
]
title Load ""RubyLanguage""
activate godot
create lang
godot -> lang: ""godot_rb_setup""
create script
lang -> script: ""set_script""
create instance
script -> instance: ""instance_create""
return ""ScriptInstancePtr(RubyLanguage)""
return ""RubyScript(RubyLanguage)""
return ""register_""\n""script_language""
newpage Load ""script.rb""
godot -> lang: ""create_script""
create script
lang -> script: ""initialize""
script -> godot: ""super""
return Godot internal ""Object""
script -> script: ""set_script""
create instance
script -> instance: ""instance_create""
return ""ScriptInstancePtr(RubyScript)""
return ""RubyScript(RubyScript)""
return ""self""
return ""Godot::RubyScript""
godot -> script: load
create class
script -> class: ""eval""
return ""self""
return
newpage Instantiate ""MyScript""
godot -> script: ""new""
script -> class: ""new""
create object
class -> object: ""initialize""
object -> godot: ""super""
return Blank-slate, script-less ""Godot::Object""
object -> godot: ""set_script""
godot -> instance: ""ScriptInstancePtr(RubyScript).instance_create""
instance -> script: ""instance_create""
script -> object: Protect from GC
return
script -> instance: ""script_instance_create""
return ""self""
return ""ScriptInstancePtr(Object)""
return ""ScriptInstancePtr(Object)""
return
return ""self""
return ""Godot::Object""\ninstance
return ""Godot::Object"" instance
newpage: Check and Call (existent) ""MyScript#member"" (attribute or method)
godot -> script: ""get_members""
script -> class: ""#instance_methods""
return ""Array[Symbol]""
return ""Godot::Array[StringName]""
godot -> instance: call ""member""
instance -> object: ""::member""
object -> class: ""#member"" (instance method)
note left: There’d probably seldom be an eigenclass.
opt GDScript Interop
class -> godot: Call GDScript (Godot Engine) method from Ruby
return ""ret.to_godot""
end
return ""ret""
return ""ret""
return ""ret.to_godot""
newpage Cleanup
note across:
For Ruby objects, the destruction ❌ means queued for GC mark-and-sweep.
GDExtension counterparts may be immediately ""free""d.
godot -> instance: ""free""
instance ->> object: Unlock GC
return
destroy object
return
destroy instance
godot -> script: ""free_instance_func""
script ->> class: Unlock GC
return
destroy class
return
destroy script
godot -> godot: ""godot_rb_cleanup""
godot -> lang!!: ""unregister_""\n""script_language""
return
destroy godot
@enduml