Changeset 205

Show
Ignore:
Timestamp:
09/25/2007 00:57:39 (11 months ago)
Author:
why
Message:

* shoes/ruby.c: ahh, ended up needing App.method_missing for anything that ends up getting added to Canvas or Shoes classes at runtime. perhaps could use method_added in the future. this gave me a chance to wrap up ts_funcall2 which means Shoes actually has a hack by the wonderful Guy Decoux!
* samples/mask.rb: using title now that the above is fixed.

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/samples/mask.rb

    r204 r205  
    77 
    88  mask do 
    9     text "<span font_desc='34px'>Shoes</span>" 
     9    title "Shoes" 
    1010  end 
    1111end 
  • trunk/shoes/ruby.c

    r203 r205  
    3232{ 
    3333  return rb_funcall2(tmp[0], (ID)tmp[1], (int)tmp[2], (VALUE *)tmp[3]); 
     34} 
     35 
     36VALUE 
     37ts_funcall2(VALUE obj, ID meth, int argc, VALUE *argv) 
     38{ 
     39  VALUE tmp[4]; 
     40  tmp[0] = obj; 
     41  tmp[1] = (VALUE)meth;  
     42  tmp[2] = (VALUE)argc; 
     43  tmp[3] = (VALUE)argv; 
     44  return rb_iterate((VALUE(*)(VALUE))ts_each, (VALUE)tmp, CASTHOOK(rb_yield), 0); 
    3445} 
    3546 
     
    11191130 
    11201131VALUE 
    1121 shoes_method_missing_color(int argc, VALUE *argv, VALUE self) 
    1122 { 
    1123   VALUE c, cname, alpha; 
    1124   rb_scan_args(argc, argv, "11", &cname, &alpha); 
     1132shoes_app_method_missing(int argc, VALUE *argv, VALUE self) 
     1133{ 
     1134  shoes_app *app; 
     1135  VALUE c, cname, alpha, canvas; 
     1136 
     1137  cname = argv[0]; 
     1138  Data_Get_Struct(self, shoes_app, app); 
     1139 
     1140  canvas = rb_ary_entry(app->nesting, RARRAY_LEN(app->nesting) - 1); 
     1141  if (!NIL_P(canvas) && rb_respond_to(canvas, SYM2ID(cname))) 
     1142  { 
     1143    return ts_funcall2(canvas, SYM2ID(cname), argc - 1, argv + 1); 
     1144  } 
     1145 
     1146  // 
     1147  // Create colors by name 
     1148  // 
    11251149  c = rb_hash_aref(cColors, cname); 
    11261150  if (NIL_P(c)) 
     
    11311155  } 
    11321156 
     1157  rb_scan_args(argc, argv, "11", &cname, &alpha); 
    11331158  if (!NIL_P(alpha)) 
    11341159  { 
     
    25442569  rb_define_method(cColor, "to_pattern", CASTHOOK(shoes_color_to_pattern), 0); 
    25452570 
    2546   rb_define_method(cApp, "method_missing", CASTHOOK(shoes_method_missing_color), -1); 
     2571  rb_define_method(cApp, "method_missing", CASTHOOK(shoes_app_method_missing), -1); 
    25472572 
    25482573  rb_const_set(cShoes, rb_intern("COLORS"), rb_hash_new());