/* * call-seq: * bind(type[, id[, last]]) {|evt| } -> self * * bind the block to the given event type. id and id-range are optional. * ===Arguments * * type Symbol/Integer * * id Symbol/Integer * * last Symbol/Integer * ===Return value * self * === Exceptions * [ArgumentError] * * when the evthander prevent the binding of the given type. */ DLL_LOCAL VALUE _bind(int argc,VALUE *argv,VALUE self) { VALUE type,id,last,proc; rb_scan_args(argc, argv, "12&",&type,&id,&last,&proc); wxEventType ctype = unwrapEventType(type); #if wxUSE_TEXTCTRL if(ctype == wxEVT_TEXT_ENTER && rb_obj_is_kind_of(self, rb_cWXTextCtrl)) { wxTextCtrl* textctrl = unwrap<wxTextCtrl*>(self); if(!textctrl->HasFlag(wxTE_PROCESS_ENTER)) { rb_raise(rb_eArgError, "'%" PRIsVALUE "' for '%" PRIsVALUE "' needs 'process_enter' option.", RB_OBJ_STRING(type), RB_OBJ_STRING(self) ); } } #endif if(NIL_P(proc)) proc = rb_block_proc(); _self->Bind(wxEventTypeTag<wxEvent>(ctype),RubyFunctor(proc),unwrapID(id),unwrapID(last)); return self; }
DLL_LOCAL void not_valid(VALUE val, VALUE klass) { rb_raise( rb_eTypeError, "%" PRIsVALUE " is not valid %" PRIsVALUE, RB_OBJ_STRING(val), RB_CLASSNAME(klass) ); }
int unwrap_iconflag(const VALUE &val,int mask) { int result = unwrapenum(val,"icon_flag"); if((result & mask) != result) rb_raise(rb_eTypeError,"%" PRIsVALUE " is not a in %d mask", RB_OBJ_STRING(val), mask); return result; }
bool check_negative_size(VALUE val, wxSize &size) { size = unwrap<wxSize>(val); if(size.GetHeight() <= 0 || size.GetWidth() <= 0) { rb_raise(rb_eArgError,"%" PRIsVALUE " does have invalid size.", RB_OBJ_STRING(rb_inspect(val))); return false; } return true; }
static int parse_keyword_arg_i(VALUE key, VALUE value, VALUE self) { if (key == ID2SYM(rb_intern("name"))) { rb_iv_set(self, "@name", value); } else { rb_raise(rb_eArgError, "unknown keyword: %"PRIsVALUE, RB_OBJ_STRING(key)); } return ST_CONTINUE; }
DLL_LOCAL bool window_parent_check(VALUE window, wxWindow* parent, T* &w) { w = unwrap<T*>(window); if(w && w->GetParent() != parent) { rb_raise(rb_eArgError, "%" PRIsVALUE " has wrong parent.", RB_OBJ_STRING(window) ); return false; } return true; }
static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj) { double value = RFLOAT_VALUE(obj); char allow_nan = state->allow_nan; VALUE tmp = rb_funcall(obj, i_to_s, 0); if (!allow_nan) { if (isinf(value)) { fbuffer_free(buffer); rb_raise(eGeneratorError, "%u: %"PRIsVALUE" not allowed in JSON", __LINE__, RB_OBJ_STRING(tmp)); } else if (isnan(value)) { fbuffer_free(buffer); rb_raise(eGeneratorError, "%u: %"PRIsVALUE" not allowed in JSON", __LINE__, RB_OBJ_STRING(tmp)); } } fbuffer_append_str(buffer, tmp); }