Module: GirFFI::Builder::OutArgument

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

Overview

Implements argument processing for arguments with direction :out.

Class Method Summary collapse

Class Method Details

.build(var_gen, arginfo, libmodule) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/gir_ffi/builder/argument.rb', line 120

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
              EnumOutArgument
            else
              if arginfo.caller_allocates?
                AllocatedInterfaceOutArgument
              else
                InterfaceOutArgument
              end
            end
          when :array
            if type.zero_terminated?
              InterfaceOutArgument
            else
              case type.array_type
              when :c
                CArrayOutArgument
              when :array
                it = PointerLikeOutArgument.new var_gen, arginfo.name, type
                it.extend WithTypedContainerPostMethod
                return it
              end
            end
          when :glist, :gslist
            it = PointerLikeOutArgument.new var_gen, arginfo.name, type
            it.extend WithTypedContainerPostMethod
            return it
          when :ghash
            it = PointerLikeOutArgument.new var_gen, arginfo.name, type
            it.extend WithTypedContainerPostMethod
            return it
          else
            RegularOutArgument
          end
  klass.new var_gen, arginfo.name, type
end