Class: Barracuda::Buffer

Inherits:
Array show all
Defined in:
ext/barracuda.c

Instance Method Summary collapse

Methods inherited from Array

#data_type

Constructor Details

#initialize(*args) ⇒ Object



406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# File 'ext/barracuda.c', line 406

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;
}

Instance Method Details

#dirty?Boolean

Returns:

  • (Boolean)


290
291
292
293
294
295
296
297
298
299
300
# File 'ext/barracuda.c', line 290

static VALUE
buffer_dirty(VALUE self)
{
    GET_BUFFER();
    if (buffer->dirty == Qtrue) return Qtrue;
    if (buffer->data == NULL) return Qtrue;
    if (buffer->cachebuf == NULL) return Qtrue;
    if (RARRAY_LEN(self) != buffer->num_items) return Qtrue;
    if (SYM2ID(rb_funcall(self, id_data_type, 0)) != buffer->type) return Qtrue;
    return Qfalse;
}

#mark_dirtyObject



302
303
304
305
306
307
# File 'ext/barracuda.c', line 302

static VALUE
buffer_mark_dirty(VALUE self)
{
    GET_BUFFER();
    return (buffer->dirty = Qtrue);
}

#outvarObject



275
276
277
278
279
280
281
# File 'ext/barracuda.c', line 275

static VALUE
buffer_outvar(VALUE self)
{
    GET_BUFFER();
    buffer->outvar = Qtrue;
    return self;
}

#outvar?Boolean

Returns:

  • (Boolean)


283
284
285
286
287
288
# File 'ext/barracuda.c', line 283

static VALUE
buffer_is_outvar(VALUE self)
{
    GET_BUFFER();
    return buffer->outvar;
}