Class: LibFST::Writer
- Inherits:
-
Object
- Object
- LibFST::Writer
- Defined in:
- lib/libfst/writer.rb,
ext/libfst_rb.c
Defined Under Namespace
Classes: Variable
Instance Attribute Summary collapse
- #filename ⇒ String readonly
- #variables ⇒ Array<Variable> readonly
Instance Method Summary collapse
-
#close ⇒ Object
Finalize the output file then close it.
-
#create_float_variable(name, direction: :implicit) ⇒ Variable
Helper to create a variable of type
:vcd_real. -
#create_integer64_variable(name, direction: :implicit) ⇒ Variable
Helper to create a 64-bit variable of type
:vcd_integer. -
#create_integer_variable(name, direction: :implicit) ⇒ Variable
Helper to create a 32-bit variable of type
:vcd_integer. -
#create_logic_variable(name, direction: :implicit, length: 1) ⇒ Variable
Helper to create a variable of type
:sv_logic. - #create_variable(name, type: , direction: :implicit, length: 0, alias_of: nil, sup_type_str: nil, sup_var_type: nil, sup_data_type: nil) ⇒ Variable
- #dump_size_limit_reached? ⇒ Boolean
-
#emit_dump_active(enable) ⇒ self
Create a new blackout chain block.
-
#emit_time_change(time) ⇒ self
Advance the time cursor.
-
#emit_value_change(handle, data) ⇒ self
Use this method to emit a value change of a variable of known size (
lengthdifferent from 0 in #create_variable). - #flush_context ⇒ self
- #fseek_failed? ⇒ Boolean
- #initialize(out_file_name, compress_hier: true) ⇒ Object constructor
-
#set_attribute_begin(name, type: , subtype: nil, arg: 0) ⇒ self
Attributes of type
:miscdo not need a closing #set_attribute_end, others do. - #set_attribute_end ⇒ self
-
#set_comment(comment) ⇒ self
Set the comment to be written to the output file.
-
#set_date_string(date) ⇒ self
Set the date string to be written in the output file.
- #set_dump_size_limit(numbytes) ⇒ self
- #set_envvar(envvar) ⇒ self
-
#set_file_type(type) ⇒ self
Indicate the file type.
-
#set_pack_type(type) ⇒ self
Set the packing type.
- #set_repack_on_close(enable) ⇒ self
- #set_scope(type, name: nil, component: nil) ⇒ self
- #set_source_instantiation_stem(path, line, use_realpath: false) ⇒ self
- #set_source_stem(path, line, use_realpath: false) ⇒ self
-
#set_time_scale(timescale) ⇒ Integer
Set time scale, as a power of 10.
-
#set_time_zero(time) ⇒ self
Set time zero.
- #set_upscope ⇒ self
-
#set_use_parallel_mode(enable) ⇒ self
Set whether to use parallel write mode or not (multithreaded).
- #set_value_list(valuelist) ⇒ self
-
#set_version_string(version) ⇒ self
Set the version string to be written to the output file.
Constructor Details
#initialize(out_file_name, compress_hier: true) ⇒ Object
1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 |
# File 'ext/libfst_rb.c', line 1036 static VALUE libfst_writer_initialize(int argc, VALUE *argv, VALUE self) { VALUE fname; VALUE kw; const ID kwkeys[1] = {id_compress_hier}; VALUE kwvalues[1] = {Qundef}; rb_scan_args(argc, argv, "1:", &fname, &kw); fname = rb_funcallv(rb_cFile, , 1, &fname); const char *cfname = rb_string_value_cstr(&fname); rb_ivar_set(self, id_at_filename, fname); int ccomphier = 1; if (!NIL_P(kw)) { rb_get_kwargs(kw, kwkeys, 0, 1, kwvalues); if (kwvalues[0] != Qundef) { if (kwvalues[0] == Qnil || kwvalues[0] == Qfalse) ccomphier = 0; else ccomphier = 1; } } fstwriterctx_t *wctx; TypedData_Get_Struct(self, fstwriterctx_t, &libfst_writer_type, wctx); wctx->ctx = fstWriterCreate(cfname, ccomphier); if (!wctx->ctx) rb_raise(rb_eRuntimeError, "cannot create FST file \"%"PRIsVALUE"\"", fname); rb_ivar_set(self, id_at_variables, rb_ary_new()); return self; } |
Instance Method Details
#close ⇒ Object
Finalize the output file then close it. After this method has been called, the object is not valid anymore.
1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 |
# File 'ext/libfst_rb.c', line 1082 static VALUE libfst_writer_close(VALUE self) { fstwriterctx_t *wctx; TypedData_Get_Struct(self, fstwriterctx_t, &libfst_writer_type, wctx); if (!wctx->ctx) rb_raise(rb_eRuntimeError, "%s object is not valid", rb_obj_classname(self)); fstWriterClose(wctx->ctx); wctx->ctx = NULL; int state = 0; rb_protect(delete_temp_hier_file, self, &state); if (state) rb_set_errinfo(Qnil); return self; } |
#create_float_variable(name, direction: :implicit) ⇒ Variable
Helper to create a variable of type :vcd_real
24 25 26 |
# File 'lib/libfst/writer.rb', line 24 def create_float_variable(name, direction: :implicit) create_variable(name, type: :vcd_real, direction: direction) end |
#create_integer64_variable(name, direction: :implicit) ⇒ Variable
Helper to create a 64-bit variable of type :vcd_integer
38 39 40 |
# File 'lib/libfst/writer.rb', line 38 def create_integer64_variable(name, direction: :implicit) create_variable(name, type: :vcd_integer, direction: direction, length: 64) end |
#create_integer_variable(name, direction: :implicit) ⇒ Variable
Helper to create a 32-bit variable of type :vcd_integer
31 32 33 |
# File 'lib/libfst/writer.rb', line 31 def create_integer_variable(name, direction: :implicit) create_variable(name, type: :vcd_integer, direction: direction, length: 32) end |
#create_logic_variable(name, direction: :implicit, length: 1) ⇒ Variable
Helper to create a variable of type :sv_logic
45 46 47 |
# File 'lib/libfst/writer.rb', line 45 def create_logic_variable(name , direction: :implicit, length: 1) create_variable(name, type: :sv_logic, direction: direction, length: length) end |
#create_variable(name, type: , direction: :implicit, length: 0, alias_of: nil, sup_type_str: nil, sup_var_type: nil, sup_data_type: nil) ⇒ Variable
1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 |
# File 'ext/libfst_rb.c', line 1872 static VALUE libfst_writer_create_variable(int argc, VALUE *argv, VALUE self) { VALUE rbname; VALUE kw; const ID kwkeys[7] = {id_type, id_direction, id_length, id_alias_of, id_sup_type_str, id_sup_var_type, id_sup_data_type}; VALUE kwvalues[7] = {Qundef, Qundef, Qundef, Qundef, Qundef, Qundef, Qundef}; const char *name = NULL; enum fstVarType vt; enum fstVarDir vd = FST_VD_IMPLICIT; uint32_t len = 0; fstHandle aliasHandle = 0; const char *type = NULL; enum fstSupplementalVarType svt = FST_SVT_NONE; enum fstSupplementalDataType sdt = FST_SDT_NONE; VALUE alias_variable = Qnil; rb_scan_args(argc, argv, "01:", &rbname, &kw); rb_get_kwargs(kw, kwkeys, 0, 7, kwvalues); if (kwvalues[3] != Qundef && !NIL_P(kwvalues[3])) { if (rb_obj_is_kind_of(kwvalues[3], c_WVariable)) { alias_variable = kwvalues[3]; aliasHandle = rb_to_unsigned_int(rb_ivar_get(alias_variable, id_at_handle)); } else { rb_raise(rb_eTypeError, "invalid alias, expecting a %"PRIsVALUE", not a %s", c_WVariable, rb_obj_classname(kwvalues[3])); } if (!NIL_P(rb_ivar_get(alias_variable, id_at_alias_of))) rb_raise(rb_eRuntimeError, "do not alias a %"PRIsVALUE" which already is an alias for another %"PRIsVALUE, c_WVariable, c_WVariable); if (rb_ivar_get(alias_variable, id_at_writer) != self) rb_raise(rb_eRuntimeError, "cannot alias a variable of another %s", rb_obj_classname(self)); } if (!NIL_P(rbname)) { name = rb_string_value_cstr(&rbname); } else if (!NIL_P(alias_variable)) { rbname = rb_ivar_get(alias_variable, id_at_name); name = rb_string_value_cstr(&rbname); } else { rb_raise(rb_eArgError, "wrong number of arguments (given 0, expected 1)"); } if (kwvalues[0] != Qundef && !NIL_P(kwvalues[0])) vt = symbol_to_fstVarType(kwvalues[0]); else if (!NIL_P(alias_variable)) vt = symbol_to_fstVarType(rb_ivar_get(alias_variable, id_at_type)); else rb_raise(rb_eArgError, "missing keyword: :type"); if (kwvalues[1] != Qundef && !NIL_P(kwvalues[1])) vd = symbol_to_fstVarDir(kwvalues[1]); else if (alias_variable != Qnil) vd = symbol_to_fstVarDir(rb_ivar_get(alias_variable, id_at_direction)); if (kwvalues[2] != Qundef && !NIL_P(kwvalues[2])) len = rb_to_unsigned_int(kwvalues[2]); else if (alias_variable != Qnil) len = rb_to_unsigned_int(rb_ivar_get(alias_variable, id_at_length)); if (kwvalues[4] != Qundef && !NIL_P(kwvalues[4])) { type = rb_string_value_cstr(&kwvalues[4]); } else if (alias_variable != Qnil && rb_ivar_get(alias_variable, id_at_sup_type_str) != Qnil) { kwvalues[4] = rb_ivar_get(alias_variable, id_at_sup_type_str); type = rb_string_value_cstr(&kwvalues[4]); } if (kwvalues[5] != Qundef && !NIL_P(kwvalues[5])) { svt = symbol_to_fstSupplementalVarType(kwvalues[5]); } else if (alias_variable != Qnil && rb_ivar_get(alias_variable, id_at_sup_var_type) != Qnil) { kwvalues[5] = rb_ivar_get(alias_variable, id_at_sup_var_type); svt = symbol_to_fstSupplementalVarType(kwvalues[5]); } if (kwvalues[6] != Qundef && !NIL_P(kwvalues[6])) { sdt = symbol_to_fstSupplementalDataType(kwvalues[6]); } else if (alias_variable != Qnil && rb_ivar_get(alias_variable, id_at_sup_data_type) != Qnil) { kwvalues[6] = rb_ivar_get(alias_variable, id_at_sup_data_type); sdt = symbol_to_fstSupplementalDataType(kwvalues[6]); } switch (vt) { case FST_VT_SV_INT: /* declare as size = 32 */ len = 32; break; case FST_VT_SV_SHORTINT: /* declare as size = 16 */ len = 16; break; case FST_VT_SV_LONGINT: /* declare as size = 64 */ len = 64; break; case FST_VT_SV_BYTE: /* declare as size = 8 */ len = 8; break; case FST_VT_GEN_STRING: /* generic string type (max len is defined dynamically via fstWriterEmitVariableLengthValueChange) */ len = 0; break; case FST_VT_VCD_EVENT: len = 1; break; case FST_VT_VCD_INTEGER: case FST_VT_VCD_PARAMETER: if (len == 0) len = 32; break; case FST_VT_VCD_SUPPLY0: case FST_VT_VCD_SUPPLY1: case FST_VT_VCD_TIME: case FST_VT_VCD_TRI: case FST_VT_VCD_TRIAND: case FST_VT_VCD_TRIOR: case FST_VT_VCD_TRIREG: case FST_VT_VCD_TRI0: case FST_VT_VCD_TRI1: case FST_VT_VCD_WAND: case FST_VT_VCD_WOR: case FST_VT_VCD_PORT: case FST_VT_VCD_SPARRAY: case FST_VT_VCD_WIRE: case FST_VT_VCD_REG: case FST_VT_SV_BIT: case FST_VT_SV_LOGIC: if (len == 0) len = 1; break; case FST_VT_VCD_REAL: case FST_VT_VCD_REAL_PARAMETER: case FST_VT_VCD_REALTIME: case FST_VT_SV_SHORTREAL: /* declare and emit same as FST_VT_VCD_REAL (needs to be emitted as double, not a float) */ len = 8; /* recast number of bytes to that of what a double is */ break; // case FST_VT_SV_ENUM: /* declare as appropriate type range */ default: break; } fstHandle var = 0; void *ctx = libfst_writer_from_rbobj(self); if (type == NULL && svt == FST_SVT_NONE && sdt == FST_SDT_NONE) var = fstWriterCreateVar(ctx, vt, vd, len, name, aliasHandle); else var = fstWriterCreateVar2(ctx, vt, vd, len, name, aliasHandle, type, svt, sdt); VALUE args[10]; args[0] = ULONG2NUM(var); // handle args[1] = self; // writer args[2] = rbname; // name args[3] = fstVarType_to_symbol(vt); // type args[4] = fstVarDir_to_symbol(vd); // direction args[5] = ULONG2NUM(len); // length args[6] = alias_variable; // alias args[7] = (kwvalues[4] != Qundef ? kwvalues[4] : Qnil); // sup_type_str args[8] = (kwvalues[5] != Qundef ? kwvalues[5] : Qnil); // sup_var_type args[9] = (kwvalues[6] != Qundef ? kwvalues[6] : Qnil); // sup_data_type VALUE variable = rb_class_new_instance(10, args, c_WVariable); rb_ary_push(rb_ivar_get(self, id_at_variables), variable); return variable; } |
#dump_size_limit_reached? ⇒ Boolean
1137 1138 1139 1140 1141 |
# File 'ext/libfst_rb.c', line 1137 static VALUE libfst_writer_dump_size_limit_reached(VALUE self) { void *ctx = libfst_writer_from_rbobj(self); return (fstWriterGetDumpSizeLimitReached(ctx) ? Qtrue : Qfalse); } |
#emit_dump_active(enable) ⇒ self
Create a new blackout chain block.
1692 1693 1694 1695 1696 1697 1698 |
# File 'ext/libfst_rb.c', line 1692 static VALUE libfst_writer_emit_dump_active(VALUE self, VALUE enable) { int en = rb_to_boolean(enable); void *ctx = libfst_writer_from_rbobj(self); fstWriterEmitDumpActive(ctx, en); return self; } |
#emit_time_change(time) ⇒ self
Advance the time cursor.
1679 1680 1681 1682 1683 1684 1685 |
# File 'ext/libfst_rb.c', line 1679 static VALUE libfst_writer_emit_time_change(VALUE self, VALUE time) { uint64_t t = rb_to_uint64t(time); void *ctx = libfst_writer_from_rbobj(self); fstWriterEmitTimeChange(ctx, t); return self; } |
#emit_value_change(handle, data) ⇒ self
Use this method to emit a value change of a variable of known size (length different from 0 in #create_variable).
data.bytesize must match the length parameter of the variable creation.
2048 2049 2050 2051 2052 2053 2054 2055 |
# File 'ext/libfst_rb.c', line 2048 static VALUE libfst_writer_emit_value_change(VALUE self, VALUE handle, VALUE data) { fstHandle hndl = rb_to_unsigned_int(handle); const char *dt = rb_string_value_ptr(&data); void *ctx = libfst_writer_from_rbobj(self); fstWriterEmitValueChange(ctx, hndl, dt); return self; } |
#flush_context ⇒ self
1158 1159 1160 1161 1162 1163 |
# File 'ext/libfst_rb.c', line 1158 static VALUE libfst_writer_flush_context(VALUE self) { void *ctx = libfst_writer_from_rbobj(self); fstWriterFlushContext(ctx); return self; } |
#fseek_failed? ⇒ Boolean
1128 1129 1130 1131 1132 |
# File 'ext/libfst_rb.c', line 1128 static VALUE libfst_writer_fseek_failed(VALUE self) { void *ctx = libfst_writer_from_rbobj(self); return (fstWriterGetFseekFailed(ctx) ? Qtrue : Qfalse); } |
#set_attribute_begin(name, type: , subtype: nil, arg: 0) ⇒ self
Attributes of type :misc do not need a closing #set_attribute_end, others do.
1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 |
# File 'ext/libfst_rb.c', line 1510 static VALUE libfst_writer_set_attribute_begin(int argc, VALUE *argv, VALUE self) { VALUE rbname; VALUE kw; const ID kwkeys[3] = {id_type, id_subtype, id_arg}; VALUE kwvalues[3] = {Qundef, Qundef, Qundef}; rb_scan_args(argc, argv, "1:", &rbname, &kw); const char *attrname = rb_string_value_cstr(&rbname); rb_get_kwargs(kw, kwkeys, 1, 2, kwvalues); enum fstAttrType type = symbol_to_fstAttrType(kwvalues[0]); uint64_t arg = 0; if (kwvalues[2] != Qundef && kwvalues[2] != Qnil) arg = rb_to_uint64t(kwvalues[2]); if (kwvalues[1] == Qundef) kwvalues[1] = Qnil; int subtype = symbol_to_subtype(kwvalues[1], type); void *ctx = libfst_writer_from_rbobj(self); fstWriterSetAttrBegin(ctx, type, subtype, attrname, arg); return self; } |
#set_attribute_end ⇒ self
1351 1352 1353 1354 1355 1356 |
# File 'ext/libfst_rb.c', line 1351 static VALUE libfst_writer_set_attribute_end(VALUE self) { void *ctx = libfst_writer_from_rbobj(self); fstWriterSetAttrEnd(ctx); return self; } |
#set_comment(comment) ⇒ self
Set the comment to be written to the output file.
1182 1183 1184 1185 1186 1187 1188 |
# File 'ext/libfst_rb.c', line 1182 static VALUE libfst_writer_set_comment(VALUE self, VALUE comment) { void *ctx = libfst_writer_from_rbobj(self); const char *str = rb_string_value_cstr(&comment); fstWriterSetComment(ctx, str); return self; } |
#set_date_string(date) ⇒ self
Set the date string to be written in the output file
1104 1105 1106 1107 1108 1109 1110 |
# File 'ext/libfst_rb.c', line 1104 static VALUE libfst_writer_set_date_string(VALUE self, VALUE date) { void *ctx = libfst_writer_from_rbobj(self); const char *str = rb_string_value_cstr(&date); fstWriterSetDate(ctx, str); return self; } |
#set_dump_size_limit(numbytes) ⇒ self
1147 1148 1149 1150 1151 1152 1153 |
# File 'ext/libfst_rb.c', line 1147 static VALUE libfst_writer_set_dump_size_limit(VALUE self, VALUE numbytes) { void *ctx = libfst_writer_from_rbobj(self); uint64_t limit = rb_to_uint64t(numbytes); fstWriterSetDumpSizeLimit(ctx, limit); return self; } |
#set_envvar(envvar) ⇒ self
1276 1277 1278 1279 1280 1281 1282 |
# File 'ext/libfst_rb.c', line 1276 static VALUE libfst_writer_set_envvar(VALUE self, VALUE envvar) { void *ctx = libfst_writer_from_rbobj(self); const char *str = rb_string_value_cstr(&envvar); fstWriterSetEnvVar(ctx, str); return self; } |
#set_file_type(type) ⇒ self
Indicate the file type.
1237 1238 1239 1240 1241 1242 |
# File 'ext/libfst_rb.c', line 1237 static VALUE libfst_writer_set_file_type(VALUE self, VALUE type) { void *ctx = libfst_writer_from_rbobj(self); fstWriterSetFileType(ctx, symbol_to_fstFileType(type)); return self; } |
#set_pack_type(type) ⇒ self
Set the packing type.
1265 1266 1267 1268 1269 1270 |
# File 'ext/libfst_rb.c', line 1265 static VALUE libfst_writer_set_pack_type(VALUE self, VALUE type) { void *ctx = libfst_writer_from_rbobj(self); fstWriterSetPackType(ctx, symbol_to_fstWriterPackType(type)); return self; } |
#set_repack_on_close(enable) ⇒ self
1207 1208 1209 1210 1211 1212 1213 |
# File 'ext/libfst_rb.c', line 1207 static VALUE libfst_writer_set_repack_on_close(VALUE self, VALUE enable) { void *ctx = libfst_writer_from_rbobj(self); int en = rb_to_boolean(enable); fstWriterSetRepackOnClose(ctx, en); return self; } |
#set_scope(type, name: nil, component: nil) ⇒ self
1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 |
# File 'ext/libfst_rb.c', line 1650 static VALUE libfst_writer_set_scope(int argc, VALUE *argv, VALUE self) { VALUE rbtype; VALUE kw; const ID kwkeys[2] = {id_name, id_component}; VALUE kwvalues[2] = {Qundef, Qundef}; rb_scan_args(argc, argv, "1:", &rbtype, &kw); enum fstScopeType scopetype = symbol_to_fstScopeType(rbtype); const char *scopename = NULL; const char *scopecomp = NULL; if (!NIL_P(kw)) { rb_get_kwargs(kw, kwkeys, 0, 2, kwvalues); if (kwvalues[0] != Qundef && !NIL_P(kwvalues[0])) scopename = rb_string_value_cstr(&kwvalues[0]); if (kwvalues[1] != Qundef && !NIL_P(kwvalues[1])) scopecomp = rb_string_value_cstr(&kwvalues[1]); } void *ctx = libfst_writer_from_rbobj(self); fstWriterSetScope(ctx, scopetype, scopename, scopecomp); return self; } |
#set_source_instantiation_stem(path, line, use_realpath: false) ⇒ self
1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 |
# File 'ext/libfst_rb.c', line 1568 static VALUE libfst_writer_set_source_instantiation_stem(int argc, VALUE *argv, VALUE self) { VALUE rbpath, rbline, kw; const ID kwkeys[1] = {id_use_realpath}; VALUE kwvalues[1] = {Qundef}; rb_scan_args(argc, argv, "2:", &rbpath, &rbline, &kw); rb_get_kwargs(kw, kwkeys, 0, 1, kwvalues); const char *path = rb_string_value_cstr(&rbpath); unsigned int line = rb_to_unsigned_int(rbline); int use_realpath = 0; if (kwvalues[0] != Qundef) use_realpath = rb_to_boolean(kwvalues[0]); void *ctx = libfst_writer_from_rbobj(self); fstWriterSetSourceInstantiationStem(ctx, path, line, use_realpath); return self; } |
#set_source_stem(path, line, use_realpath: false) ⇒ self
1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 |
# File 'ext/libfst_rb.c', line 1540 static VALUE libfst_writer_set_source_stem(int argc, VALUE *argv, VALUE self) { VALUE rbpath, rbline, kw; const ID kwkeys[1] = {id_use_realpath}; VALUE kwvalues[1] = {Qundef}; rb_scan_args(argc, argv, "2:", &rbpath, &rbline, &kw); rb_get_kwargs(kw, kwkeys, 0, 1, kwvalues); const char *path = rb_string_value_cstr(&rbpath); unsigned int line = rb_to_unsigned_int(rbline); int use_realpath = 0; if (kwvalues[0] != Qundef) use_realpath = rb_to_boolean(kwvalues[0]); void *ctx = libfst_writer_from_rbobj(self); fstWriterSetSourceStem(ctx, path, line, use_realpath); return self; } |
#set_time_scale(timescale) ⇒ Integer
Set time scale, as a power of 10.
1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 |
# File 'ext/libfst_rb.c', line 1311 static VALUE libfst_writer_set_time_scale(VALUE self, VALUE timescale) { int ts = 0; if (rb_obj_is_kind_of(timescale, rb_cInteger)) { ts = NUM2INT(timescale); if (ts > 0 || ts < -15) rb_raise(rb_eRangeError, "valid integer timescale values are between 0 and -15"); } else if (rb_obj_is_kind_of(timescale, rb_cSymbol)) { ID id = rb_sym2id(timescale); if (id == id_s) ts = 0; else if (id == id_ms) ts = -3; else if (id == id_us) ts = -6; else if (id == id_ns) ts = -9; else if (id == id_ps) ts = -12; else if (id == id_fs) ts = -15; else rb_raise(rb_eRuntimeError, "valid timescale symbols are :s, :ms, :us, :ns, :ps and :fs"); } else if (rb_obj_is_kind_of(timescale, rb_cFloat)) { double d = NUM2DBL(timescale); if (d <= 1e-21 || d > 1.0) rb_raise(rb_eRangeError, "valid float timescale values are between 1e-21 and 1.0"); double l = log10(d); ts = (int)l; if (l != (double)ts) rb_raise(rb_eRangeError, "valid float timescale values must be powers of 10, such as 10e-3"); } void *ctx = libfst_writer_from_rbobj(self); fstWriterSetTimescale(ctx, ts); return INT2NUM(ts); } |
#set_time_zero(time) ⇒ self
Set time zero.
1170 1171 1172 1173 1174 1175 |
# File 'ext/libfst_rb.c', line 1170 static VALUE libfst_writer_set_time_zero(VALUE self, VALUE time) { void *ctx = libfst_writer_from_rbobj(self); fstWriterSetTimezero(ctx, NUM2LL(time)); return self; } |
#set_upscope ⇒ self
1299 1300 1301 1302 1303 1304 |
# File 'ext/libfst_rb.c', line 1299 static VALUE libfst_writer_set_upscope(VALUE self) { void *ctx = libfst_writer_from_rbobj(self); fstWriterSetUpscope(ctx); return self; } |
#set_use_parallel_mode(enable) ⇒ self
Set whether to use parallel write mode or not (multithreaded)
1195 1196 1197 1198 1199 1200 1201 |
# File 'ext/libfst_rb.c', line 1195 static VALUE libfst_writer_set_use_parallel_mode(VALUE self, VALUE enable) { void *ctx = libfst_writer_from_rbobj(self); int en = rb_to_boolean(enable); fstWriterSetParallelMode(ctx, en); return self; } |
#set_value_list(valuelist) ⇒ self
1288 1289 1290 1291 1292 1293 1294 |
# File 'ext/libfst_rb.c', line 1288 static VALUE libfst_writer_set_value_list(VALUE self, VALUE valuelist) { void *ctx = libfst_writer_from_rbobj(self); const char *str = rb_string_value_cstr(&valuelist); fstWriterSetValueList(ctx, str); return self; } |
#set_version_string(version) ⇒ self
Set the version string to be written to the output file.
1117 1118 1119 1120 1121 1122 1123 |
# File 'ext/libfst_rb.c', line 1117 static VALUE libfst_writer_set_version_string(VALUE self, VALUE version) { void *ctx = libfst_writer_from_rbobj(self); const char *str = rb_string_value_cstr(&version); fstWriterSetVersion(ctx, str); return self; } |