lib/gir_ffi/builder/function.rb in gir_ffi-0.2.2 vs lib/gir_ffi/builder/function.rb in gir_ffi-0.2.3

- old
+ new

@@ -11,16 +11,15 @@ end def generate vargen = GirFFI::VariableNameGenerator.new @data = @info.args.map {|arg| Argument.build vargen, arg, @libmodule} - @rvdata = ReturnValue.build vargen, @info + @rvdata = ReturnValueFactory.build vargen, @info alldata = @data.dup << @rvdata alldata.each {|data| - data.prepare idx = data.type_info.array_length if idx > -1 data.length_arg = @data[idx] @data[idx].array_arg = data end @@ -36,20 +35,21 @@ private def setup_error_argument vargen klass = @info.throws? ? ErrorArgument : NullArgument - @errarg = klass.new vargen, nil, nil, nil - @errarg.prepare + @errarg = klass.new vargen, nil, nil end def filled_out_template lines = pre - lines << "#{capture}::#{@libmodule}.#{@info.symbol} #{callargs.join(', ')}" + lines << "#{capture}#{@libmodule}.#{@info.symbol} #{callargs.join(', ')}" lines << post - code = "def #{@info.safe_name} #{inargs.join(', ')}\n" + meta = @info.method? ? '' : "self." + + code = "def #{meta}#{@info.safe_name} #{inargs.join(', ')}\n" code << lines.join("\n").indent code << "\nend\n" end def inargs @@ -79,10 +79,10 @@ def post po = (@data.map(&:post) + @data.map(&:postpost) + @rvdata.post) po.unshift @errarg.post - po += @data.map {|d| d.cleanup} + po += @data.map {|item| item.cleanup} retvals = ([@rvdata.retval] + @data.map(&:retval)).compact po << "return #{retvals.join(', ')}" unless retvals.empty? po.flatten