Sha256: 2720fa0ceb08c1a4cefb656a1c3090135f1c70a6cd486875c1b9330343d94709

Contents?: true

Size: 767 Bytes

Versions: 3

Compression:

Stored size: 767 Bytes

Contents

require 'gir_ffi/builder/type/base'
module GirFFI
  module Builder
    module Type

      # Implements the creation of a callback type. The type will be
      # attached to the appropriate namespace module, and will be defined
      # as a callback for FFI.
      class Callback < Base
        def build_class
          unless defined? @klass
            instantiate_callback_class
          end
          @klass
        end

        def instantiate_callback_class
          @klass = optionally_define_constant namespace_module, @classname do
            args = Builder.ffi_function_argument_types info
            ret = Builder.ffi_function_return_type info
            lib.callback @classname.to_sym, args, ret
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gir_ffi-0.0.10 lib/gir_ffi/builder/type/callback.rb
gir_ffi-0.0.9 lib/gir_ffi/builder/type/callback.rb
gir_ffi-0.0.8 lib/gir_ffi/builder/type/callback.rb