Class: Godot::RubyLanguage

Inherits:
ScriptLanguageExtension
  • Object
show all
Defined in:
lib/godot_rb/ruby_language.rb

Overview

Singleton pattern (singleton INSTANCE alone conflicts with RubyScript design)
TODO what does it take to make it a singleton instance?

Constant Summary collapse

INSTANCE =

!
Dictionary _get_global_class_name ( String path ) virtual const

LSP integration
String _auto_indent_code ( String code, int from_line, int to_line ) virtual const
Dictionary _complete_code ( String code, String path, Object owner ) virtual const
int _find_function ( String class_name, String function_name ) virtual const
Dictionary[] _get_built_in_templates ( StringName object ) virtual const
PackedStringArray _get_reserved_words ( ) virtual const
bool _is_control_flow_keyword ( String keyword ) virtual const
bool _overrides_external_editor ( ) virtual
Dictionary _lookup_code ( String code, String symbol, String path, Object owner ) virtual const
Dictionary _validate ( String script, String path, bool validate_functions, bool validate_errors, bool validate_warnings, bool validate_safe_lines ) virtual const

Debugger integration
String _debug_get_error ( ) virtual const
Dictionary _debug_get_globals ( int max_subitems, int max_depth ) virtual
int _debug_get_stack_level_count ( ) virtual const
String _debug_get_stack_level_function ( int level ) virtual const
void* debug_get_stack_level_instance ( int level ) virtual
int _debug_get_stack_level_line ( int level ) virtual const
Dictionary _debug_get_stack_level_locals ( int level, int max_subitems, int max_depth ) virtual
Dictionary _debug_get_stack_level_members ( int level, int max_subitems, int max_depth ) virtual
String _debug_parse_stack_level_expression ( int level, String expression, int max_subitems, int max_depth ) virtual

Profiling integration
int _profiling_get_accumulated_data ( ScriptLanguageExtensionProfilingInfo* info_array, int info_max ) virtual
int _profiling_get_frame_data ( ScriptLanguageExtensionProfilingInfo* info_array, int info_max ) virtual
void _profiling_start ( ) virtual
void _profiling_stop ( ) virtual

!
void _reload_all_scripts ( ) virtual
void _reload_tool_script ( Script script, bool soft_reload ) virtual
void _thread_enter ( ) virtual
void _thread_exit ( ) virtual

?
String _make_function ( String class_name, String function_name, PackedStringArray function_args ) virtual const
Script _make_template ( String template, String class_name, String base_class_name ) virtual const
Error _open_in_external_editor ( ScriptExtension script, int line, int column ) virtual

RubyScript.new(self).new

Instance Method Summary collapse

Instance Method Details

#_add_global_constant(name, value) ⇒ Object

Same as add_named_global_constant, but does not set if the value is falsy. This is because
Godot Engine preloads nils
in case the autoload fails to load.
Here in Ruby, we’ll just let NameError fail fast instead of leaving nil error risks.
FIXME: name might not be capitalized



41
42
43
# File 'lib/godot_rb/ruby_language.rb', line 41

def _add_global_constant(name, value)
  value and add_named_global_constant(name, value)
end

#_add_named_global_constant(name, value) ⇒ Object



44
# File 'lib/godot_rb/ruby_language.rb', line 44

def _add_named_global_constant(name, value) = RubyScript::Autoloads.const_set(name, value)

#_can_inherit_from_fileObject



23
24
# File 'lib/godot_rb/ruby_language.rb', line 23

def _can_inherit_from_file = true
# Whether or not users may name classes in the Script dialog – no for both GDScript and C#

#_create_scriptObject



51
# File 'lib/godot_rb/ruby_language.rb', line 51

def _create_script = RubyScript.new

#_debug_get_current_stack_infoObject

Debugging not supported yet



60
# File 'lib/godot_rb/ruby_language.rb', line 60

def _debug_get_current_stack_info = Array.new

#_finishObject



55
56
57
# File 'lib/godot_rb/ruby_language.rb', line 55

def _finish
  #TODO clear all user scripts
end

#_frameObject

??



54
# File 'lib/godot_rb/ruby_language.rb', line 54

def _frame = nil

#_get_comment_delimitersObject

What =begin-=end?



20
21
# File 'lib/godot_rb/ruby_language.rb', line 20

def _get_comment_delimiters = PackedStringArray['#'] # What `=begin`-`=end`?
# for syntax-highlighting

#_get_extensionObject



18
# File 'lib/godot_rb/ruby_language.rb', line 18

def _get_extension = 'rb'

#_get_nameObject

TODO: don’t generate a new Variant on every call



15
# File 'lib/godot_rb/ruby_language.rb', line 15

def _get_name = 'Ruby'

#_get_public_annotationsObject

Godot API for Ruby?



63
# File 'lib/godot_rb/ruby_language.rb', line 63

def _get_public_annotations = Array.new

#_get_public_constantsObject



64
# File 'lib/godot_rb/ruby_language.rb', line 64

def _get_public_constants = Dictionary.new

#_get_public_functionsObject



65
# File 'lib/godot_rb/ruby_language.rb', line 65

def _get_public_functions = Array.new

#_get_recognized_extensionsObject



19
# File 'lib/godot_rb/ruby_language.rb', line 19

def _get_recognized_extensions = PackedStringArray.from %w[rb rbw gemspec]

#_get_string_delimitersObject

for syntax-highlighting



22
# File 'lib/godot_rb/ruby_language.rb', line 22

def _get_string_delimiters = PackedStringArray.from %w[" ' / `].map { "#{_1} #{_1}" }

#_get_typeObject



16
# File 'lib/godot_rb/ruby_language.rb', line 16

def _get_type = 'RubyScript'.to_godot

#_handles_global_class_type(type) ⇒ Object



17
# File 'lib/godot_rb/ruby_language.rb', line 17

def _handles_global_class_type(type) = _get_type == type

#_has_named_classesObject

Whether or not users may name classes in the Script dialog – no for both GDScript and C#



25
26
# File 'lib/godot_rb/ruby_language.rb', line 25

def _has_named_classes = false
#TODO: templates

#_is_using_templatesObject

TODO: templates



27
28
# File 'lib/godot_rb/ruby_language.rb', line 27

def _is_using_templates = false
# RDoc or Yardoc?

#_remove_named_global_constant(name) ⇒ Object



45
46
47
48
49
# File 'lib/godot_rb/ruby_language.rb', line 45

def _remove_named_global_constant(name)
  RubyScript::Autoloads.remove_const(name)
rescue NameError => e
  warn e
end

#_supports_builtin_modeObject

What is “Builtin mode”?



31
32
33
# File 'lib/godot_rb/ruby_language.rb', line 31

def _supports_builtin_mode = false
# All paths are fair game
# @return error message (always empty here)

#_supports_documentationObject

RDoc or Yardoc?



29
30
# File 'lib/godot_rb/ruby_language.rb', line 29

def _supports_documentation = false
# What is “Builtin mode”?

#_validate_path(_path) ⇒ Object

All paths are fair game

Returns:

  • error message (always empty here)



34
# File 'lib/godot_rb/ruby_language.rb', line 34

def _validate_path(_path) = ''