File: function.rbs

package info (click to toggle)
ruby-ffi 1.17.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,988 kB
  • sloc: ruby: 9,446; ansic: 7,713; xml: 151; sh: 51; makefile: 14
file content (39 lines) | stat: -rw-r--r-- 1,150 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
module FFI
  interface _Function
    # TODO: leads to a endless recursion when used with -rrbs/test/setup
    # def attach: (Module mod, String name) -> self
    def call: (*untyped args) -> untyped
    def param_types: () -> Array[Type]
    def return_type: () -> Type
  end

  class Function < Pointer
    include _Function
    # ?blocking: boolish?, ?convention: Library::convention?, ?enums: Enums?
    def initialize:
      (
        ffi_type return_type, Array[ffi_type] param_types,
        ?Hash[Symbol, untyped] options
      ) { (*untyped) -> untyped } -> self
    | (
        ffi_type return_type, Array[ffi_type] param_types, Proc | Pointer proc,
        ?Hash[Symbol, untyped] options
      ) -> self

    def autorelease?: ...
    alias autorelease autorelease?
    def autorelease=: ...
    def free: () -> self
  end

  class VariadicInvoker
    include _Function
    def initialize:
      (
        Pointer function, Array[ffi_type] parameter_types, ffi_type return_type,
        Hash[Symbol, untyped] options #TODO
      ) -> void

    def invoke: (Array[Type] parameter_types, Array[untyped] parameter_values) -> untyped
  end
end