Return-Path: X-Original-To: apmail-subversion-dev-archive@minotaur.apache.org Delivered-To: apmail-subversion-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2E3F317F29 for ; Tue, 17 Nov 2015 13:51:44 +0000 (UTC) Received: (qmail 38534 invoked by uid 500); 17 Nov 2015 13:51:44 -0000 Delivered-To: apmail-subversion-dev-archive@subversion.apache.org Received: (qmail 38479 invoked by uid 500); 17 Nov 2015 13:51:44 -0000 Mailing-List: contact dev-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@subversion.apache.org Received: (qmail 38469 invoked by uid 99); 17 Nov 2015 13:51:43 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Nov 2015 13:51:43 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 462711A0A87 for ; Tue, 17 Nov 2015 13:51:43 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.007 X-Spam-Level: *** X-Spam-Status: No, score=3.007 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.008, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id FSytLpUxdZsr for ; Tue, 17 Nov 2015 13:51:38 +0000 (UTC) Received: from mail-ig0-f171.google.com (mail-ig0-f171.google.com [209.85.213.171]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 6D93622F16 for ; Tue, 17 Nov 2015 13:51:38 +0000 (UTC) Received: by igcph11 with SMTP id ph11so79146458igc.1 for ; Tue, 17 Nov 2015 05:51:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=G/9wPhioUgSdh196xZN4jYSZpIXGC0IDlgiykrt7R5o=; b=CkT42EMoJVgcmOu5oGCEZon7CpqN6eqrMfPcjYPPTPUB+qPRVX964XBj65JIPFScVy KkfIKt3rD/TgWzmvsG6PhoJXLYFwNq6sqxSZsHp7wFHwYLvL6mNQyo5lHQbiLwtjoXb1 tGaCB8ep+SuPHrd3yJEAIOdllL+I+L+2gU53g9lvcZQVDbDSl7Exwk4yLepy5UYvGU/R Z7xskpAgOJ4Fh55bALUWUgIfciSIEEP5hqiQEV8tbebD2e+8bVr83LDnd1p827nXVY5q RvXkieiUNZ40L/2COvZS7Mc5TRYd2CMWCoUpjVHJSrS1ntZZvHHuVjHT9hHw7HqfLxIg 4rcw== MIME-Version: 1.0 X-Received: by 10.50.25.228 with SMTP id f4mr2049291igg.21.1447768291816; Tue, 17 Nov 2015 05:51:31 -0800 (PST) Sender: vega.james@gmail.com Received: by 10.107.16.225 with HTTP; Tue, 17 Nov 2015 05:51:31 -0800 (PST) Received: by 10.107.16.225 with HTTP; Tue, 17 Nov 2015 05:51:31 -0800 (PST) In-Reply-To: <876110ycap.fsf@wandisco.com> References: <20151109042607.GA13855@freya.jamessan.com> <876110ycap.fsf@wandisco.com> Date: Tue, 17 Nov 2015 08:51:31 -0500 X-Google-Sender-Auth: k5XwN7ntasSVbImqF7ww2ihiPGQ Message-ID: Subject: Re: [PATCH] Fix modification of nil value in Ruby test suite From: James McCoy To: Philip Martin Cc: Subversion devel mailing list Content-Type: multipart/alternative; boundary=047d7bd758c4c03dbb0524bcd2fc --047d7bd758c4c03dbb0524bcd2fc Content-Type: text/plain; charset=UTF-8 On Nov 17, 2015 8:40 AM, "Philip Martin" wrote: > > James McCoy writes: > > > --- a/subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.c > > +++ b/subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.c > > @@ -3230,14 +3230,16 @@ svn_swig_rb_make_stream(VALUE io) > > stream_p = &stream; > > r2c_swig_type2(io, "svn_stream_t *", (void **)stream_p); > > } else { > > + if (NIL_P(io)) { > > + io = rb_class_new_instance(0, NULL, rb_cObject); > > + } > > VALUE rb_pool = rb_pool_new(Qnil); > > - apr_pool_wrapper_t *pool_wrapper; > > - apr_pool_wrapper_t **pool_wrapper_p; > > + apr_pool_t *pool; > > + > > + svn_swig_rb_get_pool(0, NULL, io, &rb_pool, &pool); > > > > rb_set_pool(io, rb_pool); > > - pool_wrapper_p = &pool_wrapper; > > - r2c_swig_type2(rb_pool, "apr_pool_wrapper_t *", (void **)pool_wrapper_p); > > - stream = svn_stream_create((void *)io, pool_wrapper->pool); > > + stream = svn_stream_create((void *)io, pool); > > svn_stream_set_read2(stream, NULL /* only full read support */, > > read_handler_rbio); > > svn_stream_set_write(stream, write_handler_rbio); > > That works when I try it but I'm not familar with Ruby. I know Ruby has > GC but what controls the lifetime of the io object and how long does it > need to persist? Good questions. I don't know the answers, unfortunately. I just tried to follow the style of other, similar code as I don't really grok Ruby's C API and didn't find great documentation about it. Cheers, James --047d7bd758c4c03dbb0524bcd2fc Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

On Nov 17, 2015 8:40 AM, "Philip Martin" <philip.martin@wandisco.com>= wrote:
>
> James McCoy <jamessan@debian= .org> writes:
>
> > --- a/subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.= c
> > +++ b/subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.= c
> > @@ -3230,14 +3230,16 @@ svn_swig_rb_make_stream(VALUE io)
> >=C2=A0 =C2=A0 =C2=A0 stream_p =3D &stream;
> >=C2=A0 =C2=A0 =C2=A0 r2c_swig_type2(io, "svn_stream_t *"= , (void **)stream_p);
> >=C2=A0 =C2=A0 } else {
> > +=C2=A0 =C2=A0 if (NIL_P(io)) {
> > +=C2=A0 =C2=A0 =C2=A0 io =3D rb_class_new_instance(0, NULL, rb_cO= bject);
> > +=C2=A0 =C2=A0 }
> >=C2=A0 =C2=A0 =C2=A0 VALUE rb_pool =3D rb_pool_new(Qnil);
> > -=C2=A0 =C2=A0 apr_pool_wrapper_t *pool_wrapper;
> > -=C2=A0 =C2=A0 apr_pool_wrapper_t **pool_wrapper_p;
> > +=C2=A0 =C2=A0 apr_pool_t *pool;
> > +
> > +=C2=A0 =C2=A0 svn_swig_rb_get_pool(0, NULL, io, &rb_pool, &a= mp;pool);
> >
> >=C2=A0 =C2=A0 =C2=A0 rb_set_pool(io, rb_pool);
> > -=C2=A0 =C2=A0 pool_wrapper_p =3D &pool_wrapper;
> > -=C2=A0 =C2=A0 r2c_swig_type2(rb_pool, "apr_pool_wrapper_t *= ", (void **)pool_wrapper_p);
> > -=C2=A0 =C2=A0 stream =3D svn_stream_create((void *)io, pool_wrap= per->pool);
> > +=C2=A0 =C2=A0 stream =3D svn_stream_create((void *)io, pool); > >=C2=A0 =C2=A0 =C2=A0 svn_stream_set_read2(stream, NULL /* only ful= l read support */,
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0read_handler_rbio);
> >=C2=A0 =C2=A0 =C2=A0 svn_stream_set_write(stream, write_handler_rb= io);
>
> That works when I try it but I'm not familar with Ruby.=C2=A0 I kn= ow Ruby has
> GC but what controls the lifetime of the io object and how long does i= t
> need to persist?

Good questions. I don't know the answers, unfortunately.= I just tried to follow the style of other, similar code as I don't rea= lly grok Ruby's C API and didn't find great documentation about it.=

Cheers,
James

--047d7bd758c4c03dbb0524bcd2fc--