Module: GirFFI::Builder::InOutArgument

Defined in:
lib/gir_ffi/builder/argument.rb

Overview

Implements argument processing for arguments with direction :inout.

Class Method Summary collapse

Class Method Details

.build(var_gen, arginfo, libmodule) ⇒ Object



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/gir_ffi/builder/argument.rb', line 238

def self.build var_gen, arginfo, libmodule
  type = arginfo.argument_type
  klass = case type.tag
          when :interface
            case type.interface.info_type
            when :enum, :flags
              EnumInOutArgument
            else
              InterfaceInOutArgument
            end
          when :array
            if type.zero_terminated?
              StrvInOutArgument
            else
              case type.array_type
              when :c
                CArrayInOutArgument
              when :array
                it = Argument::InOutBase.new var_gen, arginfo.name, type
                it.extend WithTypedContainerInOutPreMethod
                it.extend WithTypedContainerPostMethod
                return it
              end
            end
          when :glist, :gslist
            it = Argument::InOutBase.new var_gen, arginfo.name, type
            it.extend WithTypedContainerInOutPreMethod
            it.extend WithTypedContainerPostMethod
            return it
          when :ghash
            it = Argument::InOutBase.new var_gen, arginfo.name, type
            it.extend WithTypedContainerInOutPreMethod
            it.extend WithTypedContainerPostMethod
            return it
          else
            RegularInOutArgument
          end

  klass.new var_gen, arginfo.name, type
end