Class: Babeltrace::CTF::ArrayDecl

Inherits:
Declaration show all
Defined in:
lib/babeltrace/ctf/events.rb,
ext/babeltrace_c/babeltrace.c

Overview

< Declaration

Instance Attribute Summary

Attributes inherited from Declaration

#declaration

Instance Method Summary collapse

Methods inherited from Declaration

create, #field_type, #initialize

Constructor Details

This class inherits a constructor from Babeltrace::CTF::Declaration

Instance Method Details

#def_classObject



530
531
532
533
534
535
536
537
538
# File 'lib/babeltrace/ctf/events.rb', line 530

def def_class
  e = elem
  if e.kind_of?(IntegerDecl) && e.len == 8 && 
       ( e.encoding == :ASCII || e.encoding == :UTF8 )
    ArrayTextDef
  else
    ArrayDef
  end
end

#elemObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'ext/babeltrace_c/babeltrace.c', line 20

static VALUE babeltrace_ctf_array_decl_elem(VALUE self) {

  VALUE decl = rb_ivar_get(self, rb_intern("@declaration"));
  VALUE p = rb_funcall(decl, rb_intern("pointer"), 0);
  VALUE address = rb_funcall(p, rb_intern("address"), 0);

  const struct declaration_array *ptr = sizeof(ptr) == 4 ? (const struct declaration_array *) NUM2ULONG(address) : (const struct declaration_array *) NUM2ULL(address);
  struct bt_declaration *elem = ptr->elem;

  VALUE ffi_ptr = rb_funcall(c_ffi_pointer, rb_intern("new"), 1, ULL2NUM( sizeof(ptr) == 4 ? (unsigned long long int) (unsigned long int) elem : (unsigned long long int) elem ));

  VALUE idecl = rb_funcall(c_internal_declaration, rb_intern("new"), 1, ffi_ptr);
  VALUE arr_decl = rb_funcall(c_ctf_array_declaration, rb_intern("create"), 1, idecl);
  return arr_decl;
}

#lenObject



540
541
542
# File 'lib/babeltrace/ctf/events.rb', line 540

def len
  @declaration.get_array_len
end