remove set_mstr
parent
1846fee1a0
commit
62d4afccd2
|
@ -82,7 +82,6 @@ struct OSTD_EXPORT CsValue {
|
|||
void set_null();
|
||||
void set_code(CsBytecode *val);
|
||||
void set_cstr(ostd::ConstCharRange val);
|
||||
void set_mstr(ostd::CharRange val);
|
||||
void set_ident(CsIdent *val);
|
||||
void set_macro(ostd::ConstCharRange val);
|
||||
|
||||
|
@ -281,7 +280,7 @@ struct OSTD_EXPORT CsAlias: CsIdent {
|
|||
void get_cstr(CsValue &v) const;
|
||||
void get_cval(CsValue &v) const;
|
||||
private:
|
||||
CsAlias(ostd::ConstCharRange n, char *a, int flags);
|
||||
CsAlias(ostd::ConstCharRange n, CsString a, int flags);
|
||||
CsAlias(ostd::ConstCharRange n, CsInt a, int flags);
|
||||
CsAlias(ostd::ConstCharRange n, CsFloat a, int flags);
|
||||
CsAlias(ostd::ConstCharRange n, int flags);
|
||||
|
|
|
@ -97,16 +97,18 @@ void CsValue::set_float(CsFloat val) {
|
|||
}
|
||||
|
||||
void CsValue::set_str(CsString val) {
|
||||
if (val.size() == 0) {
|
||||
csv_cleanup(p_type, p_stor);
|
||||
p_type = CsValueType::String;
|
||||
p_len = val.size();
|
||||
if (p_len == 0) {
|
||||
/* ostd zero length strings cannot be disowned */
|
||||
char *buf = new char[1];
|
||||
buf[0] = '\0';
|
||||
set_mstr(buf);
|
||||
csv_get<char *>(p_stor) = buf;
|
||||
return;
|
||||
}
|
||||
ostd::CharRange cr = val.iter();
|
||||
csv_get<char *>(p_stor) = val.data();
|
||||
val.disown();
|
||||
set_mstr(cr);
|
||||
}
|
||||
|
||||
void CsValue::set_null() {
|
||||
|
@ -127,13 +129,6 @@ void CsValue::set_cstr(ostd::ConstCharRange val) {
|
|||
csv_get<char const *>(p_stor) = val.data();
|
||||
}
|
||||
|
||||
void CsValue::set_mstr(ostd::CharRange val) {
|
||||
csv_cleanup(p_type, p_stor);
|
||||
p_type = CsValueType::String;
|
||||
p_len = val.size();
|
||||
csv_get<char *>(p_stor) = val.data();
|
||||
}
|
||||
|
||||
void CsValue::set_ident(CsIdent *val) {
|
||||
csv_cleanup(p_type, p_stor);
|
||||
p_type = CsValueType::Ident;
|
||||
|
|
|
@ -57,11 +57,11 @@ CsSvar::CsSvar(ostd::ConstCharRange name, CsString v, CsVarCb f, int fl):
|
|||
p_storage(ostd::move(v)), p_overrideval()
|
||||
{}
|
||||
|
||||
CsAlias::CsAlias(ostd::ConstCharRange name, char *a, int fl):
|
||||
CsAlias::CsAlias(ostd::ConstCharRange name, CsString a, int fl):
|
||||
CsIdent(CsIdentType::Alias, name, fl),
|
||||
p_acode(nullptr), p_astack(nullptr)
|
||||
{
|
||||
p_val.set_mstr(a);
|
||||
p_val.set_str(ostd::move(a));
|
||||
}
|
||||
CsAlias::CsAlias(ostd::ConstCharRange name, CsInt a, int fl):
|
||||
CsIdent(CsIdentType::Alias, name, fl),
|
||||
|
@ -1008,7 +1008,7 @@ static inline void cs_loop_conc(
|
|||
if (n <= 0 || !idv.has_alias()) {
|
||||
return;
|
||||
}
|
||||
CsVector<char> s;
|
||||
CsString s;
|
||||
for (CsInt i = 0; i < n; ++i) {
|
||||
idv.set_int(offset + i * step);
|
||||
idv.push();
|
||||
|
@ -1021,16 +1021,13 @@ static inline void cs_loop_conc(
|
|||
default:
|
||||
break;
|
||||
}
|
||||
CsString vstr = ostd::move(v.get_str());
|
||||
if (space && i) {
|
||||
s.push(' ');
|
||||
s += ' ';
|
||||
}
|
||||
s.push_n(vstr.data(), vstr.size());
|
||||
s += v.get_str();
|
||||
}
|
||||
end:
|
||||
s.push('\0');
|
||||
ostd::Size len = s.size() - 1;
|
||||
res.set_mstr(ostd::CharRange(s.disown(), len));
|
||||
res.set_str(ostd::move(s));
|
||||
}
|
||||
|
||||
void cs_init_lib_base(CsState &gcs) {
|
||||
|
|
Loading…
Reference in New Issue