예제 #1
0
static VALUE
nst_method_missing(int argc, VALUE *argv, VALUE self)
{
    VALUE s, tag, obj;

    if (argc == 2) {
        s = rb_sym_to_s(argv[0]);
        if (RSTRING_PTR(s)[RSTRING_LEN(s)-1] == '=') {
            tag = rb_str_intern(rb_str_new(RSTRING_PTR(s), RSTRING_LEN(s)-1));
            obj = nst_field(self, tag);
            if (RTEST(obj)) {
                rb_funcall(obj, rb_intern("store"), 1, argv[1]);
                return argv[1];
            }
        }
        return rb_call_super(argc,argv);
    }
    if (argc == 1) {
        obj = nst_field(self,argv[0]);
        if (RTEST(obj)) {
            return obj;
        }
    }
    return rb_call_super(argc,argv);
}
예제 #2
0
/* Read using an internal buffer to avoid system calls */
static VALUE buffered_file_read(VALUE self, VALUE arg_length) {
  long length = FIX2INT(arg_length);
  VALUE buffer = rb_ivar_get(self, id_ivar_buffer);
  long buffer_length = RSTRING_LEN(buffer);
  long buffer_index = FIX2INT(rb_ivar_get(self, id_ivar_buffer_index));
  VALUE result = Qnil;
  VALUE super_arg = Qnil;

  if (length <= (buffer_length - buffer_index)) {
    /* Return part of the buffer without having to go to the OS */
    result = rb_str_substr(buffer, buffer_index, length);
    buffer_index += length;
    rb_ivar_set(self, id_ivar_buffer_index, INT2FIX(buffer_index));
    return result;
  } else if (length > BUFFER_SIZE) {
    /* Reading more than our buffer */
    if (buffer_length > 0) {
      if (buffer_index > 0) {
        rb_funcall(buffer, id_method_slice_bang, 1, rb_range_new(INT2FIX(0), INT2FIX(buffer_index - 1), Qfalse));
        buffer_length = RSTRING_LEN(buffer);
        buffer_index = 0;
        rb_ivar_set(self, id_ivar_buffer_index, INT2FIX(0));
      }
      super_arg = INT2FIX(length - buffer_length);
      rb_str_append(buffer, rb_funcall(rb_call_super(1, &super_arg), id_method_to_s, 0));
      return rb_funcall(buffer, id_method_slice_bang, 1, rb_const_get(cBufferedFile, id_const_ALL_RANGE));
    } else {
      return rb_call_super(1, &arg_length);
    }
  } else {
    /* Read into the buffer */
    if (buffer_index > 0) {
      rb_funcall(buffer, id_method_slice_bang, 1, rb_range_new(INT2FIX(0), INT2FIX(buffer_index - 1), Qfalse));
      buffer_length = RSTRING_LEN(buffer);
      buffer_index = 0;
      rb_ivar_set(self, id_ivar_buffer_index, INT2FIX(0));
    }
    super_arg = INT2FIX(BUFFER_SIZE - buffer_length);
    rb_str_append(buffer, rb_funcall(rb_call_super(1, &super_arg), id_method_to_s, 0));
    buffer_length = RSTRING_LEN(buffer);
    if (buffer_length <= 0) {
      return Qnil;
    }

    if (length <= buffer_length) {
      result = rb_str_substr(buffer, buffer_index, length);
      buffer_index += length;
      rb_ivar_set(self, id_ivar_buffer_index, INT2FIX(buffer_index));
      return result;
    } else {
      return rb_funcall(buffer, id_method_slice_bang, 1, rb_const_get(cBufferedFile, id_const_ALL_RANGE));
    }
  }
}
VALUE _new(int argc,VALUE *argv,VALUE self)
{
	VALUE name;
	if(argc==2)
		return rb_call_super(2,argv);
	else{
		rb_scan_args(argc, argv, "01",&name);
		VALUE result[2];
		result[0]=wrap(CEGUI::String(CEGUI::ClippedContainer::WidgetTypeName));
		result[1]=name;
		return rb_call_super(2,result);
	}
}
static VALUE
interface_s_append_features(VALUE self, VALUE klass)
{
    if (!rb_obj_is_kind_of(klass, cInstantiatable))
        rb_raise(rb_eTypeError, "Not a subclass of GLib::Instantiatable");
    return rb_call_super(1, &klass);
}
예제 #5
0
VALUE _isAncestor(VALUE self,VALUE val)
{
	if(rb_obj_is_kind_of(val, rb_cInteger)){
		return wrap(_self->isAncestor(NUM2ULONG(val)));
	}else
		return rb_call_super(1,&val);
}
VALUE frequencycounter_initialize(VALUE self, VALUE serial) {
  PhidgetInfo *info = device_info(self);
  CPhidgetFrequencyCounterHandle frequencycounter = 0;
  ensure(CPhidgetFrequencyCounter_create(&frequencycounter));
  info->handle = (CPhidgetHandle)frequencycounter;
  return rb_call_super(1, &serial);
}
예제 #7
0
/*
 * A {QueueStatsRequest} object instance to request queue statistics.
 * Request queue statistics.
 *
 * @overload initialize(options={})
 *
 *   @example
 *     QueueStatsRequest.new(
 *       :port_no => port_no,
 *       :queue_id => queue_id
 *     )
 *
 *   @param [Hash] options
 *     the options to create a message with.
 *
 *   @option options [Number] :port_no
 *     request statistics for a specific port if specified, otherwise set port_no
 *     to +OFPP_ALL+ for all ports.
 *
 *   @option options [Number] :queue_id
 *     request statistics for a specific queue_id or set queue_id to +OFPQ_ALL+
 *     for all queues.
 *
 *   @return [QueueStatsRequest]
 *     an object that encapsulates the +OFPT_STATS_REQUEST(OFPST_QUEUE)+ OpenFlow
 *     message.
 */
static VALUE
queue_stats_request_init( int argc, VALUE *argv, VALUE self ) {
  VALUE options;
  if ( !rb_scan_args( argc, argv, "01", &options )) {
    options = rb_hash_new();
  }
  rb_call_super( 1, &options );
  VALUE port_no = rb_hash_aref( options, ID2SYM( rb_intern( "port_no" ) ) );
  if ( port_no == Qnil ) {
    port_no = UINT2NUM( OFPP_ALL );
  }
  rb_iv_set( self, "@port_no", port_no );
  VALUE queue_id = rb_hash_aref( options, ID2SYM( rb_intern( "queue_id" ) ) );
  if ( queue_id == Qnil ) {
    queue_id = UINT2NUM( OFPQ_ALL );
  }
  rb_iv_set( self, "@queue_id", queue_id );


  buffer *message;
  Data_Get_Struct( self, buffer, message );
  ( ( struct ofp_header * ) ( message->data ) )->xid = htonl( get_stats_request_num2uint( self, "@transaction_id" ) );
  struct ofp_stats_request *stats_request;
  stats_request = ( struct ofp_stats_request * ) message->data;
  stats_request->flags = htons ( get_stats_request_num2uint16( self, "@flags" ) );

  stats_request = ( struct ofp_stats_request * ) message->data;
  struct ofp_queue_stats_request *queue_stats_request;
  queue_stats_request = ( struct ofp_queue_stats_request * ) stats_request->body;
  queue_stats_request->port_no = htons( get_stats_request_num2uint16( self, "@port_no" ) );
  queue_stats_request->queue_id = htonl( get_stats_request_num2uint( self, "@queue_id" ) );
  return self;
}
예제 #8
0
VALUE textled_initialize(VALUE self, VALUE serial) {
  PhidgetInfo *info = device_info(self);
  CPhidgetTextLEDHandle textled = 0;
  ensure(CPhidgetTextLED_create(&textled));
  info->handle = (CPhidgetHandle)textled;
  return rb_call_super(1, &serial);
}
예제 #9
0
VALUE stepper_initialize(VALUE self, VALUE serial) {
  PhidgetInfo *info = device_info(self);
  CPhidgetStepperHandle stepper = 0;
  ensure(CPhidgetStepper_create(&stepper));
  info->handle = (CPhidgetHandle)stepper;
  return rb_call_super(1, &serial);
}
예제 #10
0
파일: wxDirDialog.cpp 프로젝트: Hanmac/rwx
/*
 * call-seq:
 *   DirDialog.new(parent, name, [options])
 *   DirDialog.new(parent, [options])
 *
 * creates a new DirDialog widget.
 * ===Arguments
 * * parent of this window or nil
 * * name is a String describing a resource in a loaded xrc
 *
 * *options: Hash with possible options to set:
 *   * path String default path
 *   * message String
 *
 *   * must_exist Style Flag does set MUST_EXIST
 *   * change_dir Style Flag does set CHANGE_DIR
 *
*/
DLL_LOCAL VALUE _initialize(int argc,VALUE *argv,VALUE self)
{
	VALUE parent,name,hash;
	rb_scan_args(argc, argv, "11:",&parent,&name,&hash);
	if(!_created && !rb_obj_is_kind_of(name,rb_cString))
	{
		wxString message(wxDirSelectorPromptStr);
		wxString path(wxEmptyString);
		int style(wxDD_DEFAULT_STYLE);

		if(rb_obj_is_kind_of(hash,rb_cHash))
		{
			set_default_values(hash,message,path,style);

			TopLevel::set_style_flags(hash,style);
			set_style_flags(hash,style);
		}

		_self->Create(unwrap<wxWindow*>(parent),message,path,style);
		
	}

	rb_call_super(argc,argv);

	if(rb_obj_is_kind_of(name, rb_cString) &&
		rb_obj_is_kind_of(hash, rb_cHash))
	{
		set_obj_option(hash, "message", &wxDirDialog::SetMessage, _self);
		set_obj_option(hash, "path", &wxDirDialog::SetPath, _self);
	}

	return self;
}
예제 #11
0
static VALUE
range_include(VALUE range, VALUE val)
{
    VALUE beg = RANGE_BEG(range);
    VALUE end = RANGE_END(range);
    int nv = FIXNUM_P(beg) || FIXNUM_P(end) ||
	     rb_obj_is_kind_of(beg, rb_cNumeric) ||
	     rb_obj_is_kind_of(end, rb_cNumeric);

    if (nv ||
	!NIL_P(rb_check_to_integer(beg, "to_int")) ||
	!NIL_P(rb_check_to_integer(end, "to_int"))) {
	if (r_le(beg, val)) {
	    if (EXCL(range)) {
		if (r_lt(val, end))
		    return Qtrue;
	    }
	    else {
		if (r_le(val, end))
		    return Qtrue;
	    }
	}
	return Qfalse;
    }
    /* TODO: ruby_frame->this_func = rb_intern("include?"); */
    return rb_call_super(1, &val);
}
예제 #12
0
static VALUE
range_max(VALUE range)
{
    VALUE e = RANGE_END(range);
    int ip = FIXNUM_P(e) || rb_obj_is_kind_of(e, rb_cInteger);

    if (rb_block_given_p() || (EXCL(range) && !ip)) {
	return rb_call_super(0, 0);
    }
    else {
	VALUE b = RANGE_BEG(range);
	int c = rb_cmpint(rb_funcall(b, id_cmp, 1, e), b, e);

	if (c > 0)
	    return Qnil;
	if (EXCL(range)) {
	    if (c == 0) return Qnil;
	    if (FIXNUM_P(e)) {
		return LONG2NUM(FIX2LONG(e) - 1);
	    }
	    return rb_funcall(e, '-', 1, INT2FIX(1));
	}
	return e;
    }
}
예제 #13
0
VALUE _initialize_copy(VALUE self, VALUE other)
{
	VALUE result = rb_call_super(1,&other);
	_set_d_width(self,_get_d_width(other));
	_set_d_height(self,_get_d_height(other));
	return result;
}
예제 #14
0
VALUE GLError_initialize(VALUE obj,VALUE message, VALUE error_id)
{
	rb_call_super(1, &message);
	rb_iv_set(obj, "@id", error_id);

	return obj;
}
예제 #15
0
/* Get the current file position */
static VALUE buffered_file_pos(VALUE self) {
  VALUE parent_pos = rb_call_super(0, NULL);
  long long ll_pos = NUM2LL(parent_pos);
  long buffer_length = RSTRING_LEN(rb_ivar_get(self, id_ivar_buffer));
  long buffer_index = FIX2INT(rb_ivar_get(self, id_ivar_buffer_index));
  return LL2NUM(ll_pos - (long long)(buffer_length - buffer_index));
}
예제 #16
0
파일: rmutil.c 프로젝트: r-project/BS
/*
    Method:     ImageMagickError#initialize(msg, loc)
    Purpose:    initialize a new ImageMagickError object - store
                the "loc" string in the @magick_location instance variable
*/
VALUE
ImageMagickError_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE super_argv[1] = {(VALUE)0};
    int super_argc = 0;
    volatile VALUE extra = Qnil;

    switch(argc)
    {
        case 2:
            extra = argv[1];
        case 1:
            super_argv[0] = argv[0];
            super_argc = 1;
        case 0:
            break;
        default:
            rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 2)", argc);
    }

    (void) rb_call_super(super_argc, (const VALUE *)super_argv);
    (void) rb_iv_set(self, "@"MAGICK_LOC, extra);


    return self;
}
예제 #17
0
VALUE _initialize_copy(VALUE self, VALUE other)
{
	VALUE result = rb_call_super(1,&other);
	_set_d_scale(self,_get_d_scale(other));
	_set_d_offset(self,_get_d_offset(other));
	return result;
}
예제 #18
0
/*
 * call-seq:
 *   pathname.freeze -> obj
 *
 * Freezes this Pathname.
 *
 * See Object.freeze.
 */
static VALUE
path_freeze(VALUE self)
{
    rb_call_super(0, 0);
    rb_str_freeze(get_strpath(self));
    return self;
}
예제 #19
0
/*
 * call-seq:
 *   pathname.untaint -> obj
 *
 * Untaints this Pathname.
 *
 * See Object.untaint.
 */
static VALUE
path_untaint(VALUE self)
{
    rb_call_super(0, 0);
    rb_obj_untaint(get_strpath(self));
    return self;
}
예제 #20
0
VALUE CeguiEventSet_method_missing(int argc,VALUE *argv,VALUE self)
{
	VALUE methID,arg;
	rb_scan_args(argc, argv, "1*",&methID,&arg);
	methID = rb_funcall(methID,rb_intern("to_s"),0);
	return rb_call_super(argc,argv);
}
예제 #21
0
파일: enumerator.c 프로젝트: takuto-h/ruby
static VALUE
lazy_zip(int argc, VALUE *argv, VALUE obj)
{
    VALUE ary, v;
    long i;
    rb_block_call_func *func = lazy_zip_arrays_func;

    if (rb_block_given_p()) {
	return rb_call_super(argc, argv);
    }

    ary = rb_ary_new2(argc);
    for (i = 0; i < argc; i++) {
	v = rb_check_array_type(argv[i]);
	if (NIL_P(v)) {
	    for (; i < argc; i++) {
		if (!rb_respond_to(argv[i], id_each)) {
		    rb_raise(rb_eTypeError, "wrong argument type %s (must respond to :each)",
			rb_obj_classname(argv[i]));
		}
	    }
	    ary = rb_ary_new4(argc, argv);
	    func = lazy_zip_func;
	    break;
	}
	rb_ary_push(ary, v);
    }

    return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj,
					 func, ary),
			   ary, lazy_receiver_size);
}
예제 #22
0
static VALUE
buffer_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE buf_value;
    struct buffer *buffer;

    rb_call_super(argc, argv);

    if (argc == 1 && TYPE(argv[0]) == T_ARRAY) {
        VALUE value = rb_ivar_get(argv[0], id_data_type);
        if (RTEST(value)) rb_ivar_set(self, id_data_type, value);
    }

    buffer = ALLOC(struct buffer);
    MEMZERO(buffer, struct buffer, 1);
    buffer->outvar = Qfalse;
    buffer->dirty = Qtrue;
    buf_value = Data_Wrap_Struct(rb_cObject, 0, free_buffer_data, buffer);
    rb_ivar_set(self, id_buffer_data, buf_value);

    if (RARRAY_LEN(self) > 0 && NIL_P(RARRAY_PTR(self)[0])) { /* outvar */
        buffer->outvar = Qtrue;
    }

    return self;
}
예제 #23
0
파일: range.c 프로젝트: DashYang/sim
static VALUE
range_max(int argc, VALUE *argv, VALUE range)
{
    VALUE e = RANGE_END(range);
    int nm = FIXNUM_P(e) || rb_obj_is_kind_of(e, rb_cNumeric);

    if (rb_block_given_p() || (EXCL(range) && !nm) || argc) {
	return rb_call_super(argc, argv);
    }
    else {
	VALUE b = RANGE_BEG(range);
	int c = rb_cmpint(rb_funcall(b, id_cmp, 1, e), b, e);

	if (c > 0)
	    return Qnil;
	if (EXCL(range)) {
	    if (!FIXNUM_P(e) && !rb_obj_is_kind_of(e, rb_cInteger)) {
		rb_raise(rb_eTypeError, "cannot exclude non Integer end value");
	    }
	    if (c == 0) return Qnil;
	    if (!FIXNUM_P(b) && !rb_obj_is_kind_of(b,rb_cInteger)) {
		rb_raise(rb_eTypeError, "cannot exclude end value with non Integer begin value");
	    }
	    if (FIXNUM_P(e)) {
		return LONG2NUM(FIX2LONG(e) - 1);
	    }
	    return rb_funcall(e, '-', 1, INT2FIX(1));
	}
	return e;
    }
}
예제 #24
0
VALUE analog_initialize(VALUE self, VALUE serial) {
  PhidgetInfo *info = device_info(self);
  CPhidgetAnalogHandle analog = 0;
  ensure(CPhidgetAnalog_create(&analog));
  info->handle = (CPhidgetHandle)analog;
  return rb_call_super(1, &serial);
}
예제 #25
0
/*
 * call-seq:
 *   ComboCtrl.new(parent, name, [options])
 *   ComboCtrl.new(parent, [options])
 *
 * creates a new ComboCtrl widget.
 * ===Arguments
 * * parent of this window or nil
 * * name is a String describing a resource in a loaded xrc
 *
 * *options: Hash with possible options to set:
 *   * items [String]
 *   * select Integer
 *   * value String
*/
DLL_LOCAL VALUE _initialize(int argc,VALUE *argv,VALUE self)
{
	VALUE parent,name,hash;
	rb_scan_args(argc, argv, "11:",&parent,&name,&hash);

	if(!_created  && !rb_obj_is_kind_of(name,rb_cString)) {
		wxWindowID id(wxID_ANY);
		wxString value;
		int style(0);

		if(rb_obj_is_kind_of(hash,rb_cHash)) {
			set_hash_option(hash,"id",id,unwrapID);
			set_hash_option(hash,"value",value);
			set_hash_option(hash,"style",style);

			TextCtrl::set_style_flags(hash,style);
		}
		_self->Create(
			unwrap<wxWindow*>(parent),id,value,
			wxDefaultPosition,wxDefaultSize,style
		);
		
	}

	rb_call_super(argc,argv);

	if(rb_obj_is_kind_of(name,rb_cString) && rb_obj_is_kind_of(hash,rb_cHash)) {
		set_obj_option(hash, "value", &wxComboCtrl::SetValue,_self);
	}

	return self;
}
예제 #26
0
VALUE interfacekit_close(VALUE self) {
  PhidgetInfo *info = device_info(self);

  ensure(CPhidgetInterfaceKit_set_OnInputChange_Handler((CPhidgetInterfaceKitHandle) info->handle, NULL, NULL));
  ensure(CPhidgetInterfaceKit_set_OnSensorChange_Handler((CPhidgetInterfaceKitHandle) info->handle, NULL, NULL));

  return rb_call_super(0,NULL);
}
예제 #27
0
VALUE gps_close(VALUE self) {
  PhidgetInfo *info = device_info(self);

  ensure(CPhidgetGPS_set_OnPositionChange_Handler((CPhidgetGPSHandle)info->handle, NULL, NULL));
 	ensure(CPhidgetGPS_set_OnPositionFixStatusChange_Handler((CPhidgetGPSHandle)info->handle, NULL, NULL));

  return rb_call_super(0,NULL);
}
예제 #28
0
static VALUE
gp_error_initialize(VALUE self, VALUE code)
{
    VALUE *message = ALLOCA_N(VALUE, 1);
    rb_ivar_set(self, s_code, code);
    message[0] = rb_funcall(code, s_to_s, 0);
    return rb_call_super(1, message);
}
예제 #29
0
VALUE _initialize_copy(VALUE self, VALUE other)
{
	VALUE result = rb_call_super(1,&other);
	_set_d_x(self,_get_d_x(other));
	_set_d_y(self,_get_d_y(other));
	_set_d_z(self,_get_d_z(other));
	return result;
}
예제 #30
0
/*
 * If passed one argument, this is identical to Kgio::Socket.connect.
 * If passed two or three arguments, it uses its superclass method:
 *
 *   Socket.new(domain, socktype [, protocol ])
 */
static VALUE kgio_new(int argc, VALUE *argv, VALUE klass)
{
	if (argc == 1)
		/* backwards compat, the only way for kgio <= 2.7.4 */
		return stream_connect(klass, argv[0], 1);

	return rb_call_super(argc, argv);
}