Method: RCSimCinterface.rcsim_make_value_bitstring

Defined in:
ext/hruby_sim/hruby_rcsim_build.c

.rcsim_make_value_bitstring(typeV, contentV) ⇒ Object

Creating a bitstring value C object.



706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 706

VALUE rcsim_make_value_bitstring(VALUE mod, VALUE typeV, VALUE contentV) {
    // printf("rcsim_make_value_bitstring\n");
    /* Get the type. */
    Type type;
    value_to_rcsim(TypeS,typeV,type);
    /* Create the value. */
    Value value = make_value(type,0);
    // printf("value=%p\n",value);
    // printf("Created from bitstring value=%p with type=%p\n",value,value->type);
    // printf("and width=%llu\n",type_width(value->type));
    /* Set it to bitstring. */
    value->numeric = 0;
    /* Generate the string of the content. */
    char* str = StringValueCStr(contentV);
    value->capacity = strlen(str)+1;
    value->data_str = calloc(value->capacity,sizeof(char));
    // printf("value->data_str=%p\n",value->data_str);
    strcpy(value->data_str,str);
    /* Returns the C value embedded into a ruby VALUE. */
    VALUE res;
    rcsim_to_value(ValueS,value,res);
    return res;
}