lib/webidl/parse_tree/argument.rb in webidl-0.1.3 vs lib/webidl/parse_tree/argument.rb in webidl-0.1.4

- old
+ new

@@ -3,18 +3,23 @@ class Argument < Treetop::Runtime::SyntaxNode def build(parent) xattrs = eal.build(parent) unless eal.empty? - arg = Ast::Argument.new( - id.build, - type.build(parent), - :optional => optional.any?, - :variadic => variadic.any?, - :extended_attributes => xattrs - ) + options = {:extended_attributes => xattrs} - arg + if arg.respond_to?(:optional) && arg.optional.any? + options[:optional] = true + options[:default] = arg.default.build if arg.default.any? + else + options[:variadic] = arg.variadic.any? + end + + Ast::Argument.new( + arg.name.build, + arg.type.build(parent), + options + ) end end # Argument end # ParseTree end # WebIDL \ No newline at end of file