Skip to content

Commit

Permalink
Update RBS for Struct
Browse files Browse the repository at this point in the history
* add `Struct#layout`; see ffi#1072 regarding incomplete docs
* (temporarily?) un-type `Struct.ptr` `flags` arg: ffi#1073
  • Loading branch information
ParadoxV5 committed Dec 31, 2023
1 parent 9d892ef commit 9c0615b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion sig/ffi/buffer.rbs
Expand Up @@ -11,7 +11,8 @@ module FFI
def +: (Integer) -> Buffer
def inspect: ...
def order: () -> AbstractMemory::order_out
| (AbstractMemory::order_in|untyped order) -> Buffer
| (AbstractMemory::order_in order) -> Buffer
| (untyped order) -> (self|Buffer)
def slice: (Integer offset, Integer length) -> Buffer
end
end
9 changes: 5 additions & 4 deletions sig/ffi/struct.rbs
Expand Up @@ -6,19 +6,19 @@ module FFI
StructByReference[Struct[AbstractMemory, untyped], AbstractMemory],
AbstractMemory, instance, untyped
]
def self.ptr: (?:inout | :in | :out flags) -> ptr
def self.ptr: (?untyped flags) -> ptr # https://github.com/ffi/ffi/issues/1073
alias self.by_ref self.ptr
def self.in: () -> ptr
def self.out: () -> ptr
def self.val: () -> StructByValue[singleton(Struct)]
alias self.by_value self.val

alias self.alloc_inout self.new
alias self.alloc_in self.new
alias self.alloc_out self.new
alias self.alloc_inout self.new
alias self.new_inout self.new
alias self.new_in self.new
alias self.new_out self.new
alias self.new_inout self.new

def self.auto_ptr: () -> Type::Mapped[
ManagedStructConverter[ManagedStruct[AutoPointer, untyped], AutoPointer],
Expand All @@ -39,8 +39,9 @@ module FFI
def []=: (Symbol field_name, E value) -> E
alias align alignment
def clear: () -> self
def order: (?AbstractMemory::order_in order) -> AbstractMemory::order_out
def layout: () -> StructLayout
def null?: () -> bool
def order: (?AbstractMemory::order_in order) -> AbstractMemory::order_out
def pointer: () -> P
alias to_ptr pointer
def values: () -> Array[E]
Expand Down

0 comments on commit 9c0615b

Please sign in to comment.