VALUE rb_Fonts_set_default_size(VALUE self, VALUE id, VALUE size) { unsigned long position = rb_num2long(id); while(rb_Fonts_Size_Tbl.size() <= position) rb_Fonts_Size_Tbl.push_back(16); rb_Fonts_Size_Tbl[position] = static_cast<unsigned int>(rb_num2long(size)); return self; }
static void debug_out(VALUE v) { char* p = StringValuePtr(v); printf("-- %d, %d, %s\n", rb_num2long(rb_funcall(v, rb_intern("size"), 0)), strlen(p), p); fflush(stdout); }
long rb_fix2int(VALUE obj) { long num = rb_num2long(obj); if((int)num != num) { rb_raise(rb_eRangeError, "integer too big to convert into unsigned int"); } return num; }
VALUE rb_Fonts_get_default_size(VALUE self, VALUE id) { long lid = rb_num2long(id); if(lid >= rb_Fonts_Size_Tbl.size()) { return LONG2FIX(16); } return rb_int2inum(static_cast<long>(rb_Fonts_Size_Tbl[lid])); }
VALUE rb_Fonts_define_shadow_color(VALUE self, VALUE id, VALUE color) { if(rb_obj_is_kind_of(color, rb_cColor) != Qtrue) { rb_raise(rb_eTypeError, "Expected Color got %s.", RSTRING_PTR(rb_class_name(CLASS_OF(color)))); return self; } rb_ary_store(rb_ivar_get(rb_mFonts, rb_Fonts_ivSColor), rb_num2long(id), color); return self; }
VALUE rb_Fonts_load_font(VALUE self, VALUE id, VALUE str) { unsigned long position = normalize_long(rb_num2long(id), 0, 255); rb_check_type(str, T_STRING); while(rb_Fonts_font_tbl.size() <= position) { rb_Fonts_font_tbl.push_back(sf::Font()); } rb_Fonts_font_tbl[position].loadFromFile(RSTRING_PTR(str)); return self; }
static int rf_mintval(const char *path,ID method,char *methname,int def) { VALUE arg = rf_mcall(path,method,methname,Qnil); VALUE retval; int error; if (FIXNUM_P(arg)) { return rb_fix2int(arg); } else if (RTEST(arg)) { if (!rb_respond_to(arg,id_to_i)) { return def; } retval = rb_protect(rf_int_protected, arg, &error); /* Did it error? */ if (error) return def; return rb_num2long(retval); } else { return def; } }
static VALUE numeric_spec_rb_num2long(VALUE self, VALUE num) { return LONG2NUM(rb_num2long(num)); }
static VALUE numeric_spec_rb_int2num(VALUE self, VALUE num) { return INT2NUM(rb_num2long(num)); }