Chipmunk 4.1.0 not compatible with Ruby 1.9.1 (+patch)

Discuss any Chipmunk bugs here.
Post Reply
Beoran
Posts: 19
Joined: Sat Apr 12, 2008 2:02 pm
Contact:

Chipmunk 4.1.0 not compatible with Ruby 1.9.1 (+patch)

Post by Beoran »

Compiling Chipmunk 4.1.0 against ruby1.9.1-preview gives the following error:

Code: Select all

rb_chipmunk.c: In function ‘rb_momentForPoly’:
rb_chipmunk.c:68: error: ‘struct RArray’ has no member named ‘len’
rb_chipmunk.c:72: error: ‘struct RArray’ has no member named ‘ptr’
make: *** [rb_chipmunk.o] Error 1
This is due to the fact that
RARRAY(arr)->len;
and
RARRAY(arr)->ptr;
were never officially sanctioned by ruby, though they happened to work in 1.8.x
We should aways use RUBY_ARRAY_LEN and RUBY_ARRAY_PTR in stead.

Patch is below:

Code: Select all

Common subdirectories: ruby/doc and ruby1.9/doc
diff ruby/rb_chipmunk.c ruby1.9/rb_chipmunk.c
68c68
< 	int numVerts = RARRAY(arr)->len;
---
> 	int numVerts = RARRAY_LEN(arr);
72c72
< 		verts[i] = *VGET(RARRAY(arr)->ptr[i]);
---
> 		verts[i] = *VGET(RARRAY_PTR(arr)[i]);
diff ruby/rb_cpShape.c ruby1.9/rb_cpShape.c
224c224
< 	int numVerts = RARRAY(arr)->len;
---
> 	int numVerts = RARRAY_LEN(arr);
228c228
< 		verts[i] = *VGET(RARRAY(arr)->ptr[i]);
---
> 		verts[i] = *VGET(RARRAY_PTR(arr)[i]);
Could you please incorporate this fix and release a new version of Chipmunk, so we are ready for when ruby 1.9.1 comes out in January next year? Thank you very much, and keep up the good work on Chipmunk.
ippa
Posts: 14
Joined: Mon Aug 25, 2008 4:53 am
Contact:

Re: Chipmunk 4.1.0 not compatible with Ruby 1.9.1 (+patch)

Post by ippa »

great work and +1 :)
http://rubylicio.us/ - tasty links for the ruby connoisseur.
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests