[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Ruby bindings follow on to r26229

From: Kouhei Sutou <kou_at_cozmixng.org>
Date: 2007-08-24 13:54:54 CEST

Hi,

In <ae6cb1100708232157j5273ab11mafaf61ba18a175b@mail.gmail.com>
  "Re: [PATCH] Ruby bindings follow on to r26229" on Thu, 23 Aug 2007 21:57:54 -0700,
  "Joe Swatosh" <joe.swatosh@gmail.com> wrote:

> > > Index: subversion/bindings/swig/ruby/svn/core.rb
> > > ===================================================================
> > > --- subversion/bindings/swig/ruby/svn/core.rb (revision 26229)
> > > +++ subversion/bindings/swig/ruby/svn/core.rb (working copy)
> > > @@ -624,14 +624,16 @@
> > > end
> > > end
> > >
> > > - def diff(to)
> > > - Core.mergeinfo_diff(self, to).collect do |result|
> > > + def diff(to, consider_inheritance=nil)
> > > + consider_inheritance ||= RANGELIST_IGNORE_INHERITANCE
> > > + Core.mergeinfo_diff(self, to, consider_inheritance).collect do |result|
> >
> > I think we can use svn_depth_t like approach: We can set
> > default value by SWIG not Ruby. %typemap(in) svn_depth_t
> > typemap in include/svn_types.swg will help you.
> >
> > In the feature, I want to support another way to specify
> > constant value. Currently, we use SOME_CONSTANT
> > (e.g. RANGELIST_IGNORE_INHERITANCE) to specify constant
> > value but I want to support :constant_name
> > (e.g. :inheritance). I think we can do this in SWIG layer.
> >
>
> I have no idea how to do this. I'm interested to see how you accomplish it.

Here is my idea (not tested):

#ifdef SWIGRUBY
%typemap(in) svn_merge_range_inheritance_t {
  if (NIL_P($input)) {
    $1 = svn_rangelist_ignore_inheritance;
  else {
    $1 = NUM2INT($input);
  }
}
#endif

And here is my feature idea (pseudo code):

#ifdef SWIGRUBY
%typemap(in) svn_merge_range_inheritance_t {
  if (NIL_P($input)) {
    $1 = svn_rangelist_ignore_inheritance;
  else if (RTEST(rb_obj_is_kind_of($input, rb_cNumeric))) {
    $1 = NUM2INT($input);
  } else {
    VALUE const_name;
    const_name = rb_str_new2("RANGELIST_");
    rb_str_concat(const_name,
                  rb_funcall(rb_funcall($input, rb_intern("to_s"), 0),
                             rb_intern("upcase"), 0));
    $1 = rb_const_get(cSvnCore, rb_intern(StringValuePtr(rb_str_concat)));
  }
}
#endif

> >
> > > Index: subversion/bindings/swig/ruby/test/test_core.rb
> > > ===================================================================
> > > --- subversion/bindings/swig/ruby/test/test_core.rb (revision 26229)
> > > +++ subversion/bindings/swig/ruby/test/test_core.rb (working copy)
> > > @@ -746,7 +746,7 @@
> > >
> > > def test_merge_info_to_s
> > > info = Svn::Core::MergeInfo.parse("/trunk: 5,7,9-13")
> > > - assert_equal("/trunk:5,7,9-13", info.to_s)
> > > + assert_equal("/trunk:5*,7*,9-13*", info.to_s)
> > > assert_not_equal("/trunk:5,7,9-13", info.inspect)
> >
> > Does we need to update the above assert_not_equal line too?
> >
>
> What are we asserting? Should the line be
>
> assert_not_equal(info.to_s, info.inspect)
>
> perhaps?

Ah, yes. You're right. I customized to_s and inspect.

Thanks,

--
kou
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Aug 24 13:52:29 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.