anchor.diff:  	
   	// methods
   <% Vector2.each do |method| %>
  -<%= "    rb_define_method(cVector2, \"#{method.rb_name}\", RUBY_METHOD_FUNC(vector2_#{method.c_name}), #{method.args.size});" %>
  +<%= "    rb_define_method(cVector2, \"#{method.rb_name}\", RUBY_METHOD_FUNC(vector2_#{method.c_name}), #{method.args ? method.args.size : -1});" %>
   <% end %>
   
   
  
positive.code: 	if (TYPE(orig) != T_DATA || RDATA(orig)->dfree != (RUBY_DATA_FUNC)vector2_free)
  		rb_raise(rb_eTypeError, "wrong argument type");
  
  	Vector2d* orig_vec = GetVec2(orig);
  	Vector2d* copy_vec = GetVec2(copy);
  	*copy_vec = *orig_vec;
  
  	return copy;
  }
  
  <%
  def vec2_accessors *args
  	getters = args.map {|a| CMethod.new("get_#{a}", a, [], <<-CODE)}
  	    GET_VEC2(self);
  		return rb_float_new(self_vec->x);
  	CODE
  	setters = args.map {|a| CMethod.new("set_#{a}", a, ['value'], <<-CODE)}
  		GET_VEC2(self);
  	    self_vec->x = v2d(value);
  	    return value;
      CODE
  	getters + setters
  end
  
  CMethod = Struct.new :c_name, :rb_name, :args, :code
  Vector2 = [
  	CMethod.new('initialize', 'initialize', ['x', 'y'], <<-CODE),
  		GET_VEC2(self);
  		self_vec->Set(v2d(x), v2d(y));
  		return self;
      CODE
  	CMethod.new('add', '+', ['other'], <<-CODE),
  		if (TYPE(other) != T_DATA || RDATA(other)->dfree != (RUBY_DATA_FUNC)vector2_free)
  		    rb_raise(rb_eTypeError, "wrong argument type");
  	    VALUE result = vector2_alloc(cVector2);
  		GET_VEC2(self);
  		GET_VEC2(other);
  		GET_VEC2(result);
  	    *result_vec = *self_vec + *other_vec;
  	    return result;
  	CODE
  	CMethod.new('len', 'len', [], <<-CODE),
  	    GET_VEC2(self);
  	    return rb_float_new(self_vec->Len());
  	CODE
  	CMethod.new('get_elem', '[]', ['index'], <<-CODE),
  	    GET_VEC2(self);
  	    GET_LONG(index);
  		return rb_float_new((*self_vec)[index_long]);
  	CODE
  ] + vec2_accessors('x', 'y')
  %>
  
  <% Vector2.each do |method| %>
  <%= "static VALUE vector2_#{method.c_name}(#{(['self'] + method.args).map {|arg| "VALUE #{arg}"}.join(', ')})" %>
  <%= "\{\n#{method.code}\}" %>
  <% end %>
  
  
negative.code: 	cVector2 = rb_define_class("Vector2", rb_cObject);
  	rb_define_alloc_func(cVector2, vector2_alloc);
  	rb_define_method(cVector2, "initialize_copy", RUBY_METHOD_FUNC(vector2_initialize_copy), 1);
  	// coerce
  	// to_3d
  	// lerp
  