Skip to content

Commit

Permalink
… except now RBS broke because we know too much
Browse files Browse the repository at this point in the history
  • Loading branch information
ParadoxV5 committed Sep 16, 2023
1 parent 8997556 commit 5fc08db
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
5 changes: 4 additions & 1 deletion lib/godot/array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ def self.from(enum, **kwargs)
def self.[](*elems, **kwargs)
array = new(**kwargs)
array.resize(elems.size)
elems.each_with_index {|elem, index| array[index] = elem }
elems.each_with_index do|elem, index|
#@type var elem: untyped
array[index] = elem
end
array
end

Expand Down
2 changes: 1 addition & 1 deletion lib/godot/mixins.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Godot
module Mixins
module Mixins
%i[
NilClass
TrueClass
Expand Down
2 changes: 1 addition & 1 deletion lib/godot/ruby_language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _remove_named_global_constant(...) = Autoloads.remove_const(...)
# bool _supports_documentation ( ) virtual const
# void _thread_enter ( ) virtual
# void _thread_exit ( ) virtual
# String _validate_path ( String path ) virtual const
# String _validate_path ( String path ) virtual const
#
# ?
# void _finish ( ) virtual
Expand Down
4 changes: 2 additions & 2 deletions lib/godot/variant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def set(...)
def method_missing(name, *args)
# Zeroth, Ruby suffixes are special
case name[-1]
when '='
when '='
public_send(:[]=, # https://github.com/soutaro/steep/issues/914
name[..-1], #: ::String
*args
Expand All @@ -40,7 +40,7 @@ def method_missing(name, *args)
self[name]
rescue KeyError
# Second, check methods
godot_send(name, *args) # `rescue` attaches `KeyError` cause if this raises
godot_send(name, *args) # `rescue` attaches `KeyError` cause if this raises
end
else
godot_send(name, *args) # Same as in the `rescue KeyError` block, just without any `KeyError` causes
Expand Down
11 changes: 5 additions & 6 deletions sig/array.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ module Godot
class Variant
#class AbstractArray[E < (Variant | bool)] < Variant
# https://github.com/ruby/rbs/issues/1471
class AbstractArray[unchecked out E < Variant] < Variant

def self.from: [E < Variant] (_Each[E] enum, **bot kwargs) -> AbstractArray[E]
def self.[]: [E < Variant] (*E elems, **bot kwargs) -> AbstractArray[E]
class AbstractArray[unchecked out E < Variant] < Variant
def self.from: [E < Variant] (_Each[type_like[E]] enum, **bot kwargs) -> instance
def self.[]: [E < Variant] (*type_like[E] elems, **bot kwargs) -> instance

type index = _ToGodot[Int | Float]
def []: (index key) -> E
def get: (index key) -> E?
def []=: (index key, E value) -> E
def set: (index key, E value) -> E?
def []=: (index key, type_like[E] value) -> E
def set: (index key, type_like[E] value) -> E?

include _Each[E]
def each: () -> Enumerator[E, self]
Expand Down
3 changes: 2 additions & 1 deletion sig/variant.rbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module Godot
interface _ToGodot[out G < Variant] def to_godot: () -> G end

type type_like[out T < Variant] = Kernel & _ToGodot[T]
type variant_like = type_like[Variant]
type variant = Variant | bool?
type variant_like = Kernel & _ToGodot[Variant]
class Variant
include Godot
VARIANT_TYPE: Integer
Expand Down

0 comments on commit 5fc08db

Please sign in to comment.