anchor.diff:          return args;
       }
   
  +% prepare_one_one = lambda do
  +	RubyString str = rstr.isNil() ? RubyString.newEmptyString(context.runtime) : rstr.convertToString();
  +        IRubyObject[] argv;
  +	if (one instanceof RubyArray) {
  +            argv = ((RubyArray)one).toJavaArrayMaybeUnsafe();
  +        } else {
  +            argv = new IRubyObject[1];
  +            argv[0] = one;
  +        }
  +% end
  +
  +% prepare_one_two = lambda do
  +	RubyString str = rstr.isNil() ? RubyString.newEmptyString(context.runtime) : rstr.convertToString();
  +	IRubyObject[] argv = {one, two};
  +% end
  +
   % append_one = lambda do |bits, dir|
       @JRubyMethod(name = "append_int<%= bits %><%= dir %>!")
  -    static public IRubyObject append_int<%= bits %><%= dir %>_bang(ThreadContext context, IRubyObject self, IRubyObject str, IRubyObject one)
  -    {
  -	if (str.isNil()) str = RubyString.newEmptyString(context.runtime);
  -	IRubyObject[] argv = {one};
  -        append_int<%= bits %><%= dir %>_int((RubyString)str, argv, 0, 1);
  +    static public IRubyObject append_int<%= bits %><%= dir %>_bang(ThreadContext context, IRubyObject self, IRubyObject rstr, IRubyObject one)
  +    {
  +        <%- prepare_one_one.() -%>
  +        append_int<%= bits %><%= dir %>_int((RubyString)str, argv, 0, argv.length);
           return str;
       }
   
       @JRubyMethod(name = "append_int<%= bits %><%= dir %>!")
  -    static public IRubyObject append_int<%= bits %><%= dir %>_bang(ThreadContext context, IRubyObject self, IRubyObject str, IRubyObject one, IRubyObject two)
  -    {
  -	if (str.isNil()) str = RubyString.newEmptyString(context.runtime);
  -	IRubyObject[] argv = {one, two};
  +    static public IRubyObject append_int<%= bits %><%= dir %>_bang(ThreadContext context, IRubyObject self, IRubyObject rstr, IRubyObject one, IRubyObject two)
  +    {
  +        <%- prepare_one_two.() -%>
           append_int<%= bits %><%= dir %>_int((RubyString)str, argv, 0, 2);
           return str;
       }
  
positive.code:     @JRubyMethod(name = "append_int<%= bits %><%= dir %>!", rest = true)
      static public IRubyObject append_int<%= bits %><%= dir %>_bang(ThreadContext context, IRubyObject self, IRubyObject[] argv)
      {
          AppendArgs args = checkAppendArgs(context, argv, <%= bits %>);
          append_int<%= bits %><%= dir %>_int(args.str, args.argv, args.begin, args.argv.length - args.begin);
          return args.str;
      }
  % end
  
  
negative.code: 	    bytes[begin+<%= pos %>] = (byte)((length >>> <%= byte * 8 %>) & 0xff);
  	    <%- end -%>
  	}
          return str;
  % end
  
  % append_intsize_ber = lambda do |bitsize, bits, dir|
  %   bytesize = bitsize / 8
  %   bytelist = (0...bytesize).to_a ; bytelist.reverse!  if dir == '_be'
      @JRubyMethod(name = "append_int<%= bitsize %>size_ber<%= dir %>!")
      public static IRubyObject append_int<%= bitsize %>size_ber<%= dir %>_bang(ThreadContext context, IRubyObject self, IRubyObject rstr, IRubyObject one)
      {
          <%- prepare_one_one.() -%>
          <%- set_intsize.(bytelist, 0) -%>
      }
  
      @JRubyMethod(name = "append_int<%= bitsize %>size_ber<%= dir %>!")
      public static IRubyObject append_int<%= bitsize %>size_ber<%= dir %>_bang(ThreadContext context, IRubyObject self, IRubyObject rstr, IRubyObject one, IRubyObject two)
      {
          <%- prepare_one_two.() -%>
          <%- set_intsize.(bytelist, 0) -%>
      }
  
      @JRubyMethod(name = "append_int<%= bitsize %>size_ber<%= dir %>!", rest = true)
      public static IRubyObject append_int<%= bitsize %>size_ber<%= dir %>_bang(ThreadContext context, IRubyObject self, IRubyObject[] argv)
      {
  	RubyString str = argv[0].isNil() ? RubyString.newEmptyString(context.runtime) : argv[0].convertToString();
          <%- set_intsize.(bytelist, 1) -%>
      }
  % end
  
  