// // Dump_Series: C // void Dump_Series(REBSER *series, const char *memo) { if (!series) return; Debug_Fmt( "%s Series %x \"%s\":" " wide: %2d" " size: %6d" " bias: %d" " tail: %d" " rest: %d" " flags: %x", memo, series, "-", // !label SER_WIDE(series), SER_TOTAL(series), SER_BIAS(series), SER_LEN(series), SER_REST(series), series->info.bits // flags + width ); if (Is_Array_Series(series)) { Dump_Values(ARR_HEAD(AS_ARRAY(series)), SER_LEN(series)); } else Dump_Bytes( SER_DATA_RAW(series), (SER_LEN(series) + 1) * SER_WIDE(series) ); }
// // Insert_Series: C // // Insert a series of values (bytes, longs, reb-vals) into the // series at the given index. Expand it if necessary. Does // not add a terminator to tail. // REBCNT Insert_Series( REBSER *s, REBCNT index, const REBYTE *data, REBCNT len ) { if (index > SER_LEN(s)) index = SER_LEN(s); Expand_Series(s, index, len); // tail += len memcpy( SER_DATA_RAW(s) + (SER_WIDE(s) * index), data, SER_WIDE(s) * len ); return index + len; }
// // RL_Series: C // // Get series information. // // Returns: // Returns information related to a series. // Arguments: // series - any series pointer (string or block) // what - indicates what information to return (see RXI_SER enum) // Notes: // Invalid what arg nums will return zero. // RL_API REBUPT RL_Series(REBSER *series, REBCNT what) { switch (what) { case RXI_SER_DATA: return cast(REBUPT, SER_DATA_RAW(series)); case RXI_SER_TAIL: return SER_LEN(series); case RXI_SER_LEFT: return SER_AVAIL(series); case RXI_SER_SIZE: return SER_REST(series); case RXI_SER_WIDE: return SER_WIDE(series); } return 0; }
// // Append_Series: C // // Append value(s) onto the tail of a series. The len is // the number of units (bytes, REBVALS, etc.) of the data, // and does not include the terminator (which will be added). // The new tail position will be returned as the result. // A terminator will be added to the end of the appended data. // void Append_Series(REBSER *s, const REBYTE *data, REBCNT len) { REBCNT len_old = SER_LEN(s); REBYTE wide = SER_WIDE(s); assert(!Is_Array_Series(s)); EXPAND_SERIES_TAIL(s, len); memcpy(SER_DATA_RAW(s) + (wide * len_old), data, wide * len); TERM_SERIES(s); }
// // Val_Byte_Len: C // // Get length of series in bytes. // REBCNT Val_Byte_Len(const REBVAL *value) { if (VAL_INDEX(value) >= VAL_LEN_HEAD(value)) return 0; return (VAL_LEN_HEAD(value) - VAL_INDEX(value)) * SER_WIDE(VAL_SERIES(value)); }