Browse Source

Use macros to access len, needed for ruby 1.9

tags/v0.99.beta19
Pascal Terjan pterjan 12 years ago
parent
commit
36990e1fa5
2 changed files with 12 additions and 12 deletions
  1. +10
    -10
      ruby/caca-canvas.c
  2. +2
    -2
      ruby/caca-dither.c

+ 10
- 10
ruby/caca-canvas.c View File

@@ -274,7 +274,7 @@ static VALUE draw_polyline(VALUE self, VALUE points, VALUE ch)
int error = 0;
VALUE v, x, y;

n = RARRAY(points)->len;
n = RARRAY_LEN(points);

ax = (int*)malloc(n*sizeof(int));
if(!ax)
@@ -290,7 +290,7 @@ static VALUE draw_polyline(VALUE self, VALUE points, VALUE ch)
for(i=0; i<n; i++)
{
v = rb_ary_entry(points, i);
if((TYPE(v) == T_ARRAY) && (RARRAY(v)->len == 2))
if((TYPE(v) == T_ARRAY) && (RARRAY_LEN(v) == 2))
{
x = rb_ary_entry(v,0);
y = rb_ary_entry(v,1);
@@ -336,7 +336,7 @@ static VALUE draw_thin_polyline(VALUE self, VALUE points)
int error = 0;
VALUE v, x, y;

n = RARRAY(points)->len;
n = RARRAY_LEN(points);

ax = (int*)malloc(n*sizeof(int));
if(!ax)
@@ -352,7 +352,7 @@ static VALUE draw_thin_polyline(VALUE self, VALUE points)
for(i=0; i<n; i++)
{
v = rb_ary_entry(points, i);
if((TYPE(v) == T_ARRAY) && (RARRAY(v)->len == 2))
if((TYPE(v) == T_ARRAY) && (RARRAY_LEN(v) == 2))
{
x = rb_ary_entry(v,0);
y = rb_ary_entry(v,1);
@@ -459,7 +459,7 @@ static VALUE fill_triangle_textured(VALUE self, VALUE coords, VALUE texture, VAL
float cuv[6];
VALUE v;

l = RARRAY(coords)->len;
l = RARRAY_LEN(coords);
if(l != 6 && l != 3)
{
rb_raise(rb_eArgError, "invalid coords list");
@@ -471,14 +471,14 @@ static VALUE fill_triangle_textured(VALUE self, VALUE coords, VALUE texture, VAL
ccoords[i] = NUM2INT(v);
else
{
if((TYPE(v) != T_ARRAY) || (RARRAY(v)->len != 2))
if((TYPE(v) != T_ARRAY) || (RARRAY_LEN(v) != 2))
rb_raise(rb_eArgError, "invalid coords list");
ccoords[2*i] = NUM2INT(rb_ary_entry(v, 0));
ccoords[2*i+1] = NUM2INT(rb_ary_entry(v, 1));
}
}

l = RARRAY(uv)->len;
l = RARRAY_LEN(uv);
if(l != 6 && l != 3)
{
rb_raise(rb_eArgError, "invalid uv list");
@@ -490,7 +490,7 @@ static VALUE fill_triangle_textured(VALUE self, VALUE coords, VALUE texture, VAL
cuv[i] = NUM2DBL(v);
else
{
if((TYPE(v) != T_ARRAY) || (RARRAY(v)->len != 2))
if((TYPE(v) != T_ARRAY) || (RARRAY_LEN(v) != 2))
rb_raise(rb_eArgError, "invalid uv list");
ccoords[2*i] = NUM2DBL(rb_ary_entry(v, 0));
ccoords[2*i+1] = NUM2DBL(rb_ary_entry(v, 1));
@@ -600,7 +600,7 @@ static VALUE render_canvas(VALUE self, VALUE font, VALUE width, VALUE height, VA
static VALUE import_from_memory(VALUE self, VALUE data, VALUE format)
{
long int bytes;
bytes = caca_import_canvas_from_memory (_SELF, StringValuePtr(data), RSTRING(StringValue(data))->len, StringValuePtr(format));
bytes = caca_import_canvas_from_memory (_SELF, StringValuePtr(data), RSTRING_LEN(StringValue(data)), StringValuePtr(format));
if(bytes <= 0)
rb_raise(rb_eRuntimeError, strerror(errno));

@@ -610,7 +610,7 @@ static VALUE import_from_memory(VALUE self, VALUE data, VALUE format)
static VALUE import_area_from_memory(VALUE self, VALUE x, VALUE y, VALUE data, VALUE format)
{
long int bytes;
bytes = caca_import_area_from_memory (_SELF, NUM2INT(x), NUM2INT(y), StringValuePtr(data), RSTRING(StringValue(data))->len, StringValuePtr(format));
bytes = caca_import_area_from_memory (_SELF, NUM2INT(x), NUM2INT(y), StringValuePtr(data), RSTRING_LEN(StringValue(data)), StringValuePtr(format));
if(bytes <= 0)
rb_raise(rb_eRuntimeError, strerror(errno));



+ 2
- 2
ruby/caca-dither.c View File

@@ -48,7 +48,7 @@ static VALUE set_dither_palette(VALUE self, VALUE palette)
VALUE v, r, g, b, a;
int error = 0;

if(RARRAY(palette)->len != 256)
if(RARRAY_LEN(palette) != 256)
{
rb_raise(rb_eArgError, "Palette must contain 256 elements");
}
@@ -84,7 +84,7 @@ static VALUE set_dither_palette(VALUE self, VALUE palette)
for(i=0; i<256; i++)
{
v = rb_ary_entry(palette, i);
if((TYPE(v) == T_ARRAY) && (RARRAY(v)->len == 4))
if((TYPE(v) == T_ARRAY) && (RARRAY_LEN(v) == 4))
{
r = rb_ary_entry(v,0);
g = rb_ary_entry(v,1);


Loading…
Cancel
Save