Hi, Anyone have any ideas on how to make win32-api compatible with 1.9.x? It seems 1.9 doesn''t allow stuff like RSTRING(ptr)->len; you must instead use wrapper macros like RSTRING_LEN(ptr). I''m not really sure why. Anyway, I''ve added a have_macro check to the extconf.rb file, so we detect if we''re on 1.9.x via: #ifndef HAVE_RSTRING_LEN #define HAVE_RSTRING_LEN xxx <- What should go here? #endif Regards, Dan
On Wed, Feb 18, 2009 at 2:31 PM, Berger, Daniel <Daniel.Berger at qwest.com> wrote:> Hi, > > Anyone have any ideas on how to make win32-api compatible with 1.9.x? > > It seems 1.9 doesn''t allow stuff like RSTRING(ptr)->len; you must instead use wrapper macros like RSTRING_LEN(ptr). I''m not really sure why. > > Anyway, I''ve added a have_macro check to the extconf.rb file, so we detect if we''re on 1.9.x via: > > #ifndef HAVE_RSTRING_LEN > #define HAVE_RSTRING_LEN xxx <- What should go here? > #endif >Why a macro check? This is the average working solution to it: http://github.com/fauna/mongrel/blob/HEAD/ext/http11/http11.c#L11-16 HTH, -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup?ry
On 18 Feb 2009, at 16:55, Luis Lavena wrote:> On Wed, Feb 18, 2009 at 2:31 PM, Berger, Daniel <Daniel.Berger at qwest.com > > wrote: >> >> It seems 1.9 doesn''t allow stuff like RSTRING(ptr)->len; you must >> instead use wrapper macros like RSTRING_LEN(ptr). I''m not really >> sure why.To allow restructuring of the value at the other end of ptr?> This is the average working solution to it: > > http://github.com/fauna/mongrel/blob/HEAD/ext/http11/http11.c#L11-16Less needed here, so went for simpler: http://github.com/eventmachine/eventmachine/commit/a9cee3895048ffbd2a5e1da804b319d99ff68443
On Wed, Feb 18, 2009 at 4:04 PM, James Tucker <jftucker at gmail.com> wrote:> > On 18 Feb 2009, at 16:55, Luis Lavena wrote: > >> On Wed, Feb 18, 2009 at 2:31 PM, Berger, Daniel <Daniel.Berger at qwest.com> >> wrote: >>> >>> It seems 1.9 doesn''t allow stuff like RSTRING(ptr)->len; you must instead >>> use wrapper macros like RSTRING_LEN(ptr). I''m not really sure why. > > To allow restructuring of the value at the other end of ptr? > >> This is the average working solution to it: >> >> http://github.com/fauna/mongrel/blob/HEAD/ext/http11/http11.c#L11-16 > > Less needed here, so went for simpler: > > http://github.com/eventmachine/eventmachine/commit/a9cee3895048ffbd2a5e1da804b319d99ff68443 >Hmn, that is lot of noise and conditionals through your code... What is wrong with defining those when don''t exist and update your code for it? -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup?ry
> -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Luis Lavena > Sent: Wednesday, February 18, 2009 11:42 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] 1.9.x compatibility for win32-api > > On Wed, Feb 18, 2009 at 4:04 PM, James Tucker > <jftucker at gmail.com> wrote: > > > > On 18 Feb 2009, at 16:55, Luis Lavena wrote: > > > >> On Wed, Feb 18, 2009 at 2:31 PM, Berger, Daniel > >> <Daniel.Berger at qwest.com> > >> wrote: > >>> > >>> It seems 1.9 doesn''t allow stuff like RSTRING(ptr)->len; you must > >>> instead use wrapper macros like RSTRING_LEN(ptr). I''m not > really sure why. > > > > To allow restructuring of the value at the other end of ptr? > > > >> This is the average working solution to it: > >> > >> > http://github.com/fauna/mongrel/blob/HEAD/ext/http11/http11.c#L11-16 > > > > Less needed here, so went for simpler: > > > > > http://github.com/eventmachine/eventmachine/commit/a9cee3895048ffbd2a5 > > e1da804b319d99ff68443 > > > > Hmn, that is lot of noise and conditionals through your code... > > What is wrong with defining those when don''t exist and update > your code for it?Yeah, I think I prefer the http11.c approach. I''m a little stuck at the moment, as it appears 1.9.x has separate macros for RARRAY(ptr) vs RARRAY(ptr)->[index]. Anyone happen to know what it is? Anyway, this is what I''ve got so far. If anyone can fill in the "???" for me that would be swell. // Ruby 1.9.x #ifndef RSTRING_PTR #define RSTRING_PTR(s) (RSTRING(s)->ptr) #endif #ifndef RSTRING_LEN #define RSTRING_LEN(s) (RSTRING(s)->len) #endif #ifndef RARRAY_PTR #define RARRAY_PTR(a) (RARRAY(a)->ptr) #define RARRAY_?????? (RARRAY(a)->ptr[i]) #endif #ifndef RARRAY_LEN #define RARRAY_LEN(a) (RARRAY(a)->len) #endif Regards, Dan
On Wed, Feb 18, 2009 at 5:17 PM, Berger, Daniel <Daniel.Berger at qwest.com> wrote:> > [...] > > I''m a little stuck at the moment, as it appears 1.9.x has separate macros for RARRAY(ptr) vs RARRAY(ptr)->[index]. Anyone happen to know what it is? > > Anyway, this is what I''ve got so far. If anyone can fill in the "???" for me that would be swell. > > // Ruby 1.9.x > #ifndef RSTRING_PTR > #define RSTRING_PTR(s) (RSTRING(s)->ptr) > #endif > #ifndef RSTRING_LEN > #define RSTRING_LEN(s) (RSTRING(s)->len) > #endif > > #ifndef RARRAY_PTR > #define RARRAY_PTR(a) (RARRAY(a)->ptr) > #define RARRAY_?????? (RARRAY(a)->ptr[i]) > #endif > #ifndef RARRAY_LEN > #define RARRAY_LEN(a) (RARRAY(a)->len) > #endif >This ticket has a good example: http://redmine.ruby-lang.org/issues/show/839 RARRAY_PTR(a)[i] Only RARRAY_PTR(a) needs to get defined, since the index from the array will work out of the box in both cases. Did that help? -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup?ry
> -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Luis Lavena > Sent: Wednesday, February 18, 2009 12:44 PM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] 1.9.x compatibility for win32-api > > On Wed, Feb 18, 2009 at 5:17 PM, Berger, Daniel > <Daniel.Berger at qwest.com> wrote: > > > > [...] > > > > I''m a little stuck at the moment, as it appears 1.9.x has > separate macros for RARRAY(ptr) vs RARRAY(ptr)->[index]. > Anyone happen to know what it is? > > > > Anyway, this is what I''ve got so far. If anyone can fill in > the "???" for me that would be swell. > > > > // Ruby 1.9.x > > #ifndef RSTRING_PTR > > #define RSTRING_PTR(s) (RSTRING(s)->ptr) #endif #ifndef RSTRING_LEN > > #define RSTRING_LEN(s) (RSTRING(s)->len) #endif > > > > #ifndef RARRAY_PTR > > #define RARRAY_PTR(a) (RARRAY(a)->ptr) #define RARRAY_?????? > > (RARRAY(a)->ptr[i]) #endif #ifndef RARRAY_LEN #define RARRAY_LEN(a) > > (RARRAY(a)->len) #endif > > > > This ticket has a good example: > > http://redmine.ruby-lang.org/issues/show/839 > > RARRAY_PTR(a)[i] > > Only RARRAY_PTR(a) needs to get defined, since the index from > the array will work out of the box in both cases. > > Did that help?Yes, thanks. Regards, Dan