diff --git a/cs_gen.cc b/cs_gen.cc index 2a79551f..4c2b7da4 100644 --- a/cs_gen.cc +++ b/cs_gen.cc @@ -430,7 +430,7 @@ lookupid: CsIdent *id = gs.cs.new_ident(lookup.get()); if (id) { switch (id->get_type()) { - case CsIdentType::ivar: + case CsIdentType::Ivar: gs.code.push( CODE_IVAR | cs_ret_code(ltype, RET_INT) | (id->get_index() << 8) @@ -447,7 +447,7 @@ lookupid: break; } return; - case CsIdentType::fvar: + case CsIdentType::Fvar: gs.code.push( CODE_FVAR | cs_ret_code(ltype, RET_FLOAT) | (id->get_index() << 8) @@ -464,7 +464,7 @@ lookupid: break; } return; - case CsIdentType::svar: + case CsIdentType::Svar: switch (ltype) { case VAL_POP: return; @@ -485,7 +485,7 @@ lookupid: break; } goto done; - case CsIdentType::alias: + case CsIdentType::Alias: switch (ltype) { case VAL_POP: return; @@ -519,7 +519,7 @@ lookupid: break; } goto done; - case CsIdentType::command: { + case CsIdentType::Command: { int comtype = CODE_COM, numargs = 0; if (prevargs >= MaxResults) { gs.code.push(CODE_ENTER); @@ -750,16 +750,16 @@ lookupid: CsIdent *id = gs.cs.new_ident(lookup.get()); if (id) { switch (id->get_type()) { - case CsIdentType::ivar: + case CsIdentType::Ivar: gs.code.push(CODE_IVAR | (id->get_index() << 8)); goto done; - case CsIdentType::fvar: + case CsIdentType::Fvar: gs.code.push(CODE_FVAR | (id->get_index() << 8)); goto done; - case CsIdentType::svar: + case CsIdentType::Svar: gs.code.push(CODE_SVARM | (id->get_index() << 8)); goto done; - case CsIdentType::alias: + case CsIdentType::Alias: gs.code.push( (id->get_index() < MaxArguments ? CODE_LOOKUPMARG @@ -1103,7 +1103,7 @@ static void compilestatements(GenState &gs, int rettype, int brak, int prevargs) CsIdent *id = gs.cs.new_ident(idname.get()); if (id) { switch (id->get_type()) { - case CsIdentType::alias: + case CsIdentType::Alias: more = compilearg(gs, VAL_ANY, prevargs); if (!more) { gs.gen_str(); @@ -1115,7 +1115,7 @@ static void compilestatements(GenState &gs, int rettype, int brak, int prevargs) ) | (id->get_index() << 8) ); goto endstatement; - case CsIdentType::ivar: + case CsIdentType::Ivar: more = compilearg(gs, VAL_INT, prevargs); if (!more) { gs.gen_int(); @@ -1124,7 +1124,7 @@ static void compilestatements(GenState &gs, int rettype, int brak, int prevargs) CODE_IVAR1 | (id->get_index() << 8) ); goto endstatement; - case CsIdentType::fvar: + case CsIdentType::Fvar: more = compilearg(gs, VAL_FLOAT, prevargs); if (!more) { gs.gen_float(); @@ -1133,7 +1133,7 @@ static void compilestatements(GenState &gs, int rettype, int brak, int prevargs) CODE_FVAR1 | (id->get_index() << 8) ); goto endstatement; - case CsIdentType::svar: + case CsIdentType::Svar: more = compilearg(gs, VAL_CSTR, prevargs); if (!more) { gs.gen_str(); diff --git a/cs_val.cc b/cs_val.cc index fd115758..fac969f0 100644 --- a/cs_val.cc +++ b/cs_val.cc @@ -13,10 +13,10 @@ static inline T &csv_get(U &stor) { template static inline void csv_cleanup(CsValueType tv, T &stor) { switch (tv) { - case CsValueType::string: + case CsValueType::String: delete[] csv_get(stor); break; - case CsValueType::code: { + case CsValueType::Code: { ostd::Uint32 *bcode = csv_get(stor); if (bcode[-1] == CODE_START) { delete[] bcode; @@ -29,7 +29,7 @@ static inline void csv_cleanup(CsValueType tv, T &stor) { } CsValue::CsValue(): - p_stor(), p_len(0), p_type(CsValueType::null) + p_stor(), p_len(0), p_type(CsValueType::Null) {} CsValue::~CsValue() { @@ -46,23 +46,23 @@ CsValue::CsValue(CsValue &&v): CsValue() { CsValue &CsValue::operator=(CsValue const &v) { csv_cleanup(p_type, p_stor); - p_type = CsValueType::null; + p_type = CsValueType::Null; switch (v.get_type()) { - case CsValueType::integer: - case CsValueType::number: - case CsValueType::ident: + case CsValueType::Int: + case CsValueType::Float: + case CsValueType::Ident: p_len = v.p_len; p_type = v.p_type; p_stor = v.p_stor; break; - case CsValueType::string: - case CsValueType::cstring: - case CsValueType::macro: + case CsValueType::String: + case CsValueType::Cstring: + case CsValueType::Macro: set_str( ostd::ConstCharRange(csv_get(v.p_stor), v.p_len) ); break; - case CsValueType::code: + case CsValueType::Code: set_code(cs_copy_code(v.get_code())); break; default: @@ -76,7 +76,7 @@ CsValue &CsValue::operator=(CsValue &&v) { p_stor = v.p_stor; p_type = v.p_type; p_len = v.p_len; - v.p_type = CsValueType::null; + v.p_type = CsValueType::Null; return *this; } @@ -86,13 +86,13 @@ CsValueType CsValue::get_type() const { void CsValue::set_int(CsInt val) { csv_cleanup(p_type, p_stor); - p_type = CsValueType::integer; + p_type = CsValueType::Int; csv_get(p_stor) = val; } void CsValue::set_float(CsFloat val) { csv_cleanup(p_type, p_stor); - p_type = CsValueType::number; + p_type = CsValueType::Float; csv_get(p_stor) = val; } @@ -111,44 +111,44 @@ void CsValue::set_str(CsString val) { void CsValue::set_null() { csv_cleanup(p_type, p_stor); - p_type = CsValueType::null; + p_type = CsValueType::Null; } void CsValue::set_code(CsBytecode *val) { csv_cleanup(p_type, p_stor); - p_type = CsValueType::code; + p_type = CsValueType::Code; csv_get(p_stor) = val; } void CsValue::set_cstr(ostd::ConstCharRange val) { csv_cleanup(p_type, p_stor); - p_type = CsValueType::cstring; + p_type = CsValueType::Cstring; p_len = val.size(); csv_get(p_stor) = val.data(); } void CsValue::set_mstr(ostd::CharRange val) { csv_cleanup(p_type, p_stor); - p_type = CsValueType::string; + p_type = CsValueType::String; p_len = val.size(); csv_get(p_stor) = val.data(); } void CsValue::set_ident(CsIdent *val) { csv_cleanup(p_type, p_stor); - p_type = CsValueType::ident; + p_type = CsValueType::Ident; csv_get(p_stor) = val; } void CsValue::set_macro(ostd::ConstCharRange val) { csv_cleanup(p_type, p_stor); - p_type = CsValueType::macro; + p_type = CsValueType::Macro; p_len = val.size(); csv_get(p_stor) = val.data(); } void CsValue::force_null() { - if (get_type() == CsValueType::null) { + if (get_type() == CsValueType::Null) { return; } set_null(); @@ -157,17 +157,17 @@ void CsValue::force_null() { CsFloat CsValue::force_float() { CsFloat rf = 0.0f; switch (get_type()) { - case CsValueType::integer: + case CsValueType::Int: rf = csv_get(p_stor); break; - case CsValueType::string: - case CsValueType::macro: - case CsValueType::cstring: + case CsValueType::String: + case CsValueType::Macro: + case CsValueType::Cstring: rf = cs_parse_float( ostd::ConstCharRange(csv_get(p_stor), p_len) ); break; - case CsValueType::number: + case CsValueType::Float: return csv_get(p_stor); default: break; @@ -179,17 +179,17 @@ CsFloat CsValue::force_float() { CsInt CsValue::force_int() { CsInt ri = 0; switch (get_type()) { - case CsValueType::number: + case CsValueType::Float: ri = csv_get(p_stor); break; - case CsValueType::string: - case CsValueType::macro: - case CsValueType::cstring: + case CsValueType::String: + case CsValueType::Macro: + case CsValueType::Cstring: ri = cs_parse_int( ostd::ConstCharRange(csv_get(p_stor), p_len) ); break; - case CsValueType::integer: + case CsValueType::Int: return csv_get(p_stor); default: break; @@ -201,17 +201,17 @@ CsInt CsValue::force_int() { ostd::ConstCharRange CsValue::force_str() { CsString rs; switch (get_type()) { - case CsValueType::number: + case CsValueType::Float: rs = ostd::move(floatstr(csv_get(p_stor))); break; - case CsValueType::integer: + case CsValueType::Int: rs = ostd::move(intstr(csv_get(p_stor))); break; - case CsValueType::macro: - case CsValueType::cstring: + case CsValueType::Macro: + case CsValueType::Cstring: rs = ostd::ConstCharRange(csv_get(p_stor), p_len); break; - case CsValueType::string: + case CsValueType::String: return ostd::ConstCharRange(csv_get(p_stor), p_len); default: break; @@ -222,13 +222,13 @@ ostd::ConstCharRange CsValue::force_str() { CsInt CsValue::get_int() const { switch (get_type()) { - case CsValueType::number: + case CsValueType::Float: return CsInt(csv_get(p_stor)); - case CsValueType::integer: + case CsValueType::Int: return csv_get(p_stor); - case CsValueType::string: - case CsValueType::macro: - case CsValueType::cstring: + case CsValueType::String: + case CsValueType::Macro: + case CsValueType::Cstring: return cs_parse_int( ostd::ConstCharRange(csv_get(p_stor), p_len) ); @@ -240,13 +240,13 @@ CsInt CsValue::get_int() const { CsFloat CsValue::get_float() const { switch (get_type()) { - case CsValueType::number: + case CsValueType::Float: return csv_get(p_stor); - case CsValueType::integer: + case CsValueType::Int: return CsFloat(csv_get(p_stor)); - case CsValueType::string: - case CsValueType::macro: - case CsValueType::cstring: + case CsValueType::String: + case CsValueType::Macro: + case CsValueType::Cstring: return cs_parse_float( ostd::ConstCharRange(csv_get(p_stor), p_len) ); @@ -257,14 +257,14 @@ CsFloat CsValue::get_float() const { } CsBytecode *CsValue::get_code() const { - if (get_type() != CsValueType::code) { + if (get_type() != CsValueType::Code) { return nullptr; } return csv_get(p_stor); } CsIdent *CsValue::get_ident() const { - if (get_type() != CsValueType::ident) { + if (get_type() != CsValueType::Ident) { return nullptr; } return csv_get(p_stor); @@ -272,13 +272,13 @@ CsIdent *CsValue::get_ident() const { CsString CsValue::get_str() const { switch (get_type()) { - case CsValueType::string: - case CsValueType::macro: - case CsValueType::cstring: + case CsValueType::String: + case CsValueType::Macro: + case CsValueType::Cstring: return ostd::ConstCharRange(csv_get(p_stor), p_len); - case CsValueType::integer: + case CsValueType::Int: return intstr(csv_get(p_stor)); - case CsValueType::number: + case CsValueType::Float: return floatstr(csv_get(p_stor)); default: break; @@ -288,9 +288,9 @@ CsString CsValue::get_str() const { ostd::ConstCharRange CsValue::get_strr() const { switch (get_type()) { - case CsValueType::string: - case CsValueType::macro: - case CsValueType::cstring: + case CsValueType::String: + case CsValueType::Macro: + case CsValueType::Cstring: return ostd::ConstCharRange(csv_get(p_stor), p_len); default: break; @@ -300,17 +300,17 @@ ostd::ConstCharRange CsValue::get_strr() const { void CsValue::get_val(CsValue &r) const { switch (get_type()) { - case CsValueType::string: - case CsValueType::macro: - case CsValueType::cstring: + case CsValueType::String: + case CsValueType::Macro: + case CsValueType::Cstring: r.set_str( ostd::ConstCharRange(csv_get(p_stor), p_len) ); break; - case CsValueType::integer: + case CsValueType::Int: r.set_int(csv_get(p_stor)); break; - case CsValueType::number: + case CsValueType::Float: r.set_float(csv_get(p_stor)); break; default: @@ -329,7 +329,7 @@ OSTD_EXPORT bool cs_code_is_empty(CsBytecode *code) { } bool CsValue::code_is_empty() const { - if (get_type() != CsValueType::code) { + if (get_type() != CsValueType::Code) { return true; } return cscript::cs_code_is_empty(csv_get(p_stor)); @@ -354,13 +354,13 @@ static inline bool cs_get_bool(ostd::ConstCharRange s) { bool CsValue::get_bool() const { switch (get_type()) { - case CsValueType::number: + case CsValueType::Float: return csv_get(p_stor) != 0; - case CsValueType::integer: + case CsValueType::Int: return csv_get(p_stor) != 0; - case CsValueType::string: - case CsValueType::macro: - case CsValueType::cstring: + case CsValueType::String: + case CsValueType::Macro: + case CsValueType::Cstring: return cs_get_bool( ostd::ConstCharRange(csv_get(p_stor), p_len) ); diff --git a/cs_vm.cc b/cs_vm.cc index be827553..8190cecf 100644 --- a/cs_vm.cc +++ b/cs_vm.cc @@ -169,9 +169,9 @@ static inline ostd::Uint32 *forcecode(CsState &cs, CsValue &v) { static inline void forcecond(CsState &cs, CsValue &v) { switch (v.get_type()) { - case CsValueType::string: - case CsValueType::macro: - case CsValueType::cstring: + case CsValueType::String: + case CsValueType::Macro: + case CsValueType::Cstring: if (!v.get_strr().empty()) { forcecode(cs, v); } else { @@ -193,17 +193,17 @@ static ostd::Uint32 emptyblock[VAL_ANY][2] = { static inline void force_arg(CsValue &v, int type) { switch (type) { case RET_STR: - if (v.get_type() != CsValueType::string) { + if (v.get_type() != CsValueType::String) { v.force_str(); } break; case RET_INT: - if (v.get_type() != CsValueType::integer) { + if (v.get_type() != CsValueType::Int) { v.force_int(); } break; case RET_FLOAT: - if (v.get_type() != CsValueType::number) { + if (v.get_type() != CsValueType::Float) { v.force_float(); } break; @@ -487,16 +487,16 @@ static inline int cs_get_lookupu_type( CsState &cs, CsValue &arg, CsIdent *&id, ostd::Uint32 op ) { if ( - arg.get_type() != CsValueType::string && - arg.get_type() != CsValueType::macro && - arg.get_type() != CsValueType::cstring + arg.get_type() != CsValueType::String && + arg.get_type() != CsValueType::Macro && + arg.get_type() != CsValueType::Cstring ) { return -2; /* default case */ } id = cs.get_ident(arg.get_strr()); if (id) { switch(id->get_type()) { - case CsIdentType::alias: + case CsIdentType::Alias: if (id->get_flags() & IDF_UNKNOWN) { break; } @@ -507,13 +507,13 @@ static inline int cs_get_lookupu_type( return ID_UNKNOWN; } return ID_ALIAS; - case CsIdentType::svar: + case CsIdentType::Svar: return ID_SVAR; - case CsIdentType::ivar: + case CsIdentType::Ivar: return ID_IVAR; - case CsIdentType::fvar: + case CsIdentType::Fvar: return ID_FVAR; - case CsIdentType::command: { + case CsIdentType::Command: { arg.set_null(); CsValue buf[MaxArguments]; callcommand(cs, static_cast(id), buf, arg, 0, true); @@ -680,7 +680,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) { case CODE_JUMP_RESULT_TRUE: { ostd::Uint32 len = op >> 8; --numargs; - if (args[numargs].get_type() == CsValueType::code) { + if (args[numargs].get_type() == CsValueType::Code) { cs.run(args[numargs].get_code(), result); } else { result = ostd::move(args[numargs]); @@ -693,7 +693,7 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) { case CODE_JUMP_RESULT_FALSE: { ostd::Uint32 len = op >> 8; --numargs; - if (args[numargs].get_type() == CsValueType::code) { + if (args[numargs].get_type() == CsValueType::Code) { cs.run(args[numargs].get_code(), result); } else { result = ostd::move(args[numargs]); @@ -818,23 +818,23 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) { CsValue &arg = args[numargs - 1]; GenState gs(cs); switch (arg.get_type()) { - case CsValueType::integer: + case CsValueType::Int: gs.code.reserve(8); gs.code.push(CODE_START); gs.gen_int(arg.get_int()); gs.code.push(CODE_RESULT); gs.code.push(CODE_EXIT); break; - case CsValueType::number: + case CsValueType::Float: gs.code.reserve(8); gs.code.push(CODE_START); gs.gen_float(arg.get_float()); gs.code.push(CODE_RESULT); gs.code.push(CODE_EXIT); break; - case CsValueType::string: - case CsValueType::macro: - case CsValueType::cstring: + case CsValueType::String: + case CsValueType::Macro: + case CsValueType::Cstring: gs.code.reserve(64); gs.gen_main(arg.get_strr()); break; @@ -854,9 +854,9 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) { case CODE_COND: { CsValue &arg = args[numargs - 1]; switch (arg.get_type()) { - case CsValueType::string: - case CsValueType::macro: - case CsValueType::cstring: { + case CsValueType::String: + case CsValueType::Macro: + case CsValueType::Cstring: { ostd::ConstCharRange s = arg.get_strr(); if (!s.empty()) { GenState gs(cs); @@ -895,9 +895,9 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) { CsValue &arg = args[numargs - 1]; CsIdent *id = cs.identmap[DummyIdx]; if ( - arg.get_type() == CsValueType::string || - arg.get_type() == CsValueType::macro || - arg.get_type() == CsValueType::cstring + arg.get_type() == CsValueType::String || + arg.get_type() == CsValueType::Macro || + arg.get_type() == CsValueType::Cstring ) { id = cs.new_ident(arg.get_strr()); } @@ -1402,9 +1402,9 @@ static ostd::Uint32 *runcode(CsState &cs, ostd::Uint32 *code, CsValue &result) { int callargs = op >> 8, offset = numargs - callargs; CsValue &idarg = args[offset - 1]; if ( - idarg.get_type() != CsValueType::string && - idarg.get_type() != CsValueType::macro && - idarg.get_type() != CsValueType::cstring + idarg.get_type() != CsValueType::String && + idarg.get_type() != CsValueType::Macro && + idarg.get_type() != CsValueType::Cstring ) { litval: result = ostd::move(idarg); @@ -1500,7 +1500,7 @@ noid: force_arg(result, op & CODE_RET_MASK); continue; } - if (a->get_value().get_type() == CsValueType::null) { + if (a->get_value().get_type() == CsValueType::Null) { goto noid; } cs_call_alias( @@ -1546,7 +1546,7 @@ void CsState::run(CsIdent *id, CsValueRange args, CsValue &ret) { break; } /* fallthrough */ - case CsIdentType::command: + case CsIdentType::Command: if (nargs < static_cast(id)->get_num_args()) { CsValue buf[MaxArguments]; memcpy(buf, args.data(), args.size() * sizeof(CsValue)); @@ -1562,14 +1562,14 @@ void CsState::run(CsIdent *id, CsValueRange args, CsValue &ret) { } nargs = 0; break; - case CsIdentType::ivar: + case CsIdentType::Ivar: if (args.empty()) { print_var(static_cast(id)); } else { set_var_int_checked(static_cast(id), args); } break; - case CsIdentType::fvar: + case CsIdentType::Fvar: if (args.empty()) { print_var(static_cast(id)); } else { @@ -1578,7 +1578,7 @@ void CsState::run(CsIdent *id, CsValueRange args, CsValue &ret) { ); } break; - case CsIdentType::svar: + case CsIdentType::Svar: if (args.empty()) { print_var(static_cast(id)); } else { @@ -1587,14 +1587,14 @@ void CsState::run(CsIdent *id, CsValueRange args, CsValue &ret) { ); } break; - case CsIdentType::alias: { + case CsIdentType::Alias: { CsAlias *a = static_cast(id); if (a->get_index() < MaxArguments) { if (!(p_stack->usedargs & (1 << a->get_index()))) { break; } } - if (a->get_value().get_type() == CsValueType::null) { + if (a->get_value().get_type() == CsValueType::Null) { break; } cs_call_alias( diff --git a/cubescript.cc b/cubescript.cc index 1b8d8d02..a7a777c3 100644 --- a/cubescript.cc +++ b/cubescript.cc @@ -41,48 +41,48 @@ CsVar::CsVar(CsIdentType tp, ostd::ConstCharRange name, CsVarCb f, int fl): CsIvar::CsIvar( ostd::ConstCharRange name, CsInt m, CsInt x, CsInt v, CsVarCb f, int fl ): - CsVar(CsIdentType::ivar, name, ostd::move(f), fl | ((m > x) ? IDF_READONLY : 0)), + CsVar(CsIdentType::Ivar, name, ostd::move(f), fl | ((m > x) ? IDF_READONLY : 0)), p_storage(v), p_minval(m), p_maxval(x), p_overrideval(0) {} CsFvar::CsFvar( ostd::ConstCharRange name, CsFloat m, CsFloat x, CsFloat v, CsVarCb f, int fl ): - CsVar(CsIdentType::fvar, name, ostd::move(f), fl | ((m > x) ? IDF_READONLY : 0)), + CsVar(CsIdentType::Fvar, name, ostd::move(f), fl | ((m > x) ? IDF_READONLY : 0)), p_storage(v), p_minval(m), p_maxval(x), p_overrideval(0) {} CsSvar::CsSvar(ostd::ConstCharRange name, CsString v, CsVarCb f, int fl): - CsVar(CsIdentType::svar, name, ostd::move(f), fl), + CsVar(CsIdentType::Svar, name, ostd::move(f), fl), p_storage(ostd::move(v)), p_overrideval() {} CsAlias::CsAlias(ostd::ConstCharRange name, char *a, int fl): - CsIdent(CsIdentType::alias, name, fl), + CsIdent(CsIdentType::Alias, name, fl), p_acode(nullptr), p_astack(nullptr) { p_val.set_mstr(a); } CsAlias::CsAlias(ostd::ConstCharRange name, CsInt a, int fl): - CsIdent(CsIdentType::alias, name, fl), + CsIdent(CsIdentType::Alias, name, fl), p_acode(nullptr), p_astack(nullptr) { p_val.set_int(a); } CsAlias::CsAlias(ostd::ConstCharRange name, CsFloat a, int fl): - CsIdent(CsIdentType::alias, name, fl), + CsIdent(CsIdentType::Alias, name, fl), p_acode(nullptr), p_astack(nullptr) { p_val.set_float(a); } CsAlias::CsAlias(ostd::ConstCharRange name, int fl): - CsIdent(CsIdentType::alias, name, fl), + CsIdent(CsIdentType::Alias, name, fl), p_acode(nullptr), p_astack(nullptr) { p_val.set_null(); } CsAlias::CsAlias(ostd::ConstCharRange name, CsValue v, int fl): - CsIdent(CsIdentType::alias, name, fl), + CsIdent(CsIdentType::Alias, name, fl), p_acode(nullptr), p_astack(nullptr), p_val(ostd::move(v)) {} @@ -90,12 +90,12 @@ CsCommand::CsCommand( ostd::ConstCharRange name, ostd::ConstCharRange args, int nargs, CsCommandCb f ): - CsIdent(CsIdentType::command, name, 0), + CsIdent(CsIdentType::Command, name, 0), p_cargs(args), p_cb_cftv(ostd::move(f)), p_numargs(nargs) {} bool CsIdent::is_alias() const { - return get_type() == CsIdentType::alias; + return get_type() == CsIdentType::Alias; } CsAlias *CsIdent::get_alias() { @@ -113,7 +113,7 @@ CsAlias const *CsIdent::get_alias() const { } bool CsIdent::is_command() const { - return get_type() == CsIdentType::command; + return get_type() == CsIdentType::Command; } CsCommand *CsIdent::get_command() { @@ -131,12 +131,12 @@ CsCommand const *CsIdent::get_command() const { } bool CsIdent::is_special() const { - return get_type() == CsIdentType::special; + return get_type() == CsIdentType::Special; } bool CsIdent::is_var() const { CsIdentType tp = get_type(); - return (tp >= CsIdentType::ivar) && (tp <= CsIdentType::svar); + return (tp >= CsIdentType::Ivar) && (tp <= CsIdentType::Svar); } CsVar *CsIdent::get_var() { @@ -154,7 +154,7 @@ CsVar const *CsIdent::get_var() const { } bool CsIdent::is_ivar() const { - return get_type() == CsIdentType::ivar; + return get_type() == CsIdentType::Ivar; } CsIvar *CsIdent::get_ivar() { @@ -172,7 +172,7 @@ CsIvar const *CsIdent::get_ivar() const { } bool CsIdent::is_fvar() const { - return get_type() == CsIdentType::fvar; + return get_type() == CsIdentType::Fvar; } CsFvar *CsIdent::get_fvar() { @@ -190,7 +190,7 @@ CsFvar const *CsIdent::get_fvar() const { } bool CsIdent::is_svar() const { - return get_type() == CsIdentType::svar; + return get_type() == CsIdentType::Svar; } CsSvar *CsIdent::get_svar() { @@ -399,25 +399,25 @@ void CsState::clear_override(CsIdent &id) { return; } switch (id.get_type()) { - case CsIdentType::alias: { + case CsIdentType::Alias: { CsAlias &a = static_cast(id); CsAliasInternal::clean_code(&a); a.get_value().set_str(""); break; } - case CsIdentType::ivar: { + case CsIdentType::Ivar: { CsIvar &iv = static_cast(id); iv.set_value(iv.p_overrideval); iv.changed(); break; } - case CsIdentType::fvar: { + case CsIdentType::Fvar: { CsFvar &fv = static_cast(id); fv.set_value(fv.p_overrideval); fv.changed(); break; } - case CsIdentType::svar: { + case CsIdentType::Svar: { CsSvar &sv = static_cast(id); sv.set_value(sv.p_overrideval); sv.changed(); @@ -460,11 +460,11 @@ CsIdent *CsState::new_ident(ostd::ConstCharRange name, int flags) { CsIdent *CsState::force_ident(CsValue &v) { switch (v.get_type()) { - case CsValueType::ident: + case CsValueType::Ident: return v.get_ident(); - case CsValueType::macro: - case CsValueType::cstring: - case CsValueType::string: { + case CsValueType::Macro: + case CsValueType::Cstring: + case CsValueType::String: { CsIdent *id = new_ident(v.get_strr()); v.set_ident(id); return id; @@ -520,7 +520,7 @@ void CsState::set_alias(ostd::ConstCharRange name, CsValue v) { CsIdent *id = get_ident(name); if (id) { switch (id->get_type()) { - case CsIdentType::alias: { + case CsIdentType::Alias: { CsAlias *a = static_cast(id); if (a->get_index() < MaxArguments) { CsAliasInternal::set_arg(a, *this, v); @@ -529,13 +529,13 @@ void CsState::set_alias(ostd::ConstCharRange name, CsValue v) { } return; } - case CsIdentType::ivar: + case CsIdentType::Ivar: set_var_int_checked(static_cast(id), v.get_int()); break; - case CsIdentType::fvar: + case CsIdentType::Fvar: set_var_float_checked(static_cast(id), v.get_float()); break; - case CsIdentType::svar: + case CsIdentType::Svar: set_var_str_checked(static_cast(id), v.get_str()); break; default: @@ -587,17 +587,17 @@ void CsState::print_var(CsSvar *sv) { void CsState::print_var(CsVar *v) { switch (v->get_type()) { - case CsIdentType::ivar: { + case CsIdentType::Ivar: { CsIvar *iv = static_cast(v); print_var(iv); break; } - case CsIdentType::fvar: { + case CsIdentType::Fvar: { CsFvar *fv = static_cast(v); print_var(fv); break; } - case CsIdentType::svar: { + case CsIdentType::Svar: { CsSvar *sv = static_cast(v); print_var(sv); break; @@ -609,17 +609,17 @@ void CsState::print_var(CsVar *v) { void CsAlias::get_cstr(CsValue &v) const { switch (p_val.get_type()) { - case CsValueType::macro: + case CsValueType::Macro: v.set_macro(p_val.get_strr()); break; - case CsValueType::string: - case CsValueType::cstring: + case CsValueType::String: + case CsValueType::Cstring: v.set_cstr(p_val.get_strr()); break; - case CsValueType::integer: + case CsValueType::Int: v.set_str(ostd::move(intstr(p_val.get_int()))); break; - case CsValueType::number: + case CsValueType::Float: v.set_str(ostd::move(floatstr(p_val.get_float()))); break; default: @@ -630,17 +630,17 @@ void CsAlias::get_cstr(CsValue &v) const { void CsAlias::get_cval(CsValue &v) const { switch (p_val.get_type()) { - case CsValueType::macro: + case CsValueType::Macro: v.set_macro(p_val.get_strr()); break; - case CsValueType::string: - case CsValueType::cstring: + case CsValueType::String: + case CsValueType::Cstring: v.set_cstr(p_val.get_strr()); break; - case CsValueType::integer: + case CsValueType::Int: v.set_int(p_val.get_int()); break; - case CsValueType::number: + case CsValueType::Float: v.set_float(p_val.get_float()); break; default: @@ -651,7 +651,7 @@ void CsAlias::get_cval(CsValue &v) const { CsIdentType CsIdent::get_type() const { if (p_type > ID_ALIAS) { - return CsIdentType::special; + return CsIdentType::Special; } return CsIdentType(p_type); } @@ -1055,7 +1055,7 @@ void cs_init_lib_base(CsState &cs) { CsInt val = args[0].get_int(); for (ostd::Size i = 1; (i + 1) < args.size(); i += 2) { if ( - (args[i].get_type() == CsValueType::null) || + (args[i].get_type() == CsValueType::Null) || (args[i].get_int() == val) ) { cs.run(args[i + 1].get_code(), res); @@ -1068,7 +1068,7 @@ void cs_init_lib_base(CsState &cs) { CsFloat val = args[0].get_float(); for (ostd::Size i = 1; (i + 1) < args.size(); i += 2) { if ( - (args[i].get_type() == CsValueType::null) || + (args[i].get_type() == CsValueType::Null) || (args[i].get_float() == val) ) { cs.run(args[i + 1].get_code(), res); @@ -1081,7 +1081,7 @@ void cs_init_lib_base(CsState &cs) { CsString val = args[0].get_str(); for (ostd::Size i = 1; (i + 1) < args.size(); i += 2) { if ( - (args[i].get_type() == CsValueType::null) || + (args[i].get_type() == CsValueType::Null) || (args[i].get_str() == val) ) { cs.run(args[i + 1].get_code(), res); diff --git a/cubescript.hh b/cubescript.hh index dfd16612..ae9ccfd8 100644 --- a/cubescript.hh +++ b/cubescript.hh @@ -61,7 +61,7 @@ OSTD_EXPORT bool cs_code_is_empty(CsBytecode *code); struct CsIdent; enum class CsValueType { - null = 0, integer, number, string, cstring, code, macro, ident + Null = 0, Int, Float, String, Cstring, Code, Macro, Ident }; struct OSTD_EXPORT CsValue { @@ -119,7 +119,7 @@ struct CsIdentStack { struct CsState; enum class CsIdentType { - ivar = 0, fvar, svar, command, alias, special + Ivar = 0, Fvar, Svar, Command, Alias, Special }; struct CsVar; @@ -603,7 +603,7 @@ namespace util { for (ostd::Size i = 0; i < vals.size(); ++i) { auto s = ostd::appender(); switch (vals[i].get_type()) { - case CsValueType::integer: { + case CsValueType::Int: { auto r = format_int( ostd::forward(writer), vals[i].get_int() ); @@ -612,7 +612,7 @@ namespace util { } break; } - case CsValueType::number: { + case CsValueType::Float: { auto r = format_float( ostd::forward(writer), vals[i].get_float() ); @@ -621,9 +621,9 @@ namespace util { } break; } - case CsValueType::string: - case CsValueType::cstring: - case CsValueType::macro: { + case CsValueType::String: + case CsValueType::Cstring: + case CsValueType::Macro: { auto sv = vals[i].get_strr(); ret += writer.put_n(sv.data(), sv.size()); break; diff --git a/tools/repl.cc b/tools/repl.cc index c848effc..dae27f49 100644 --- a/tools/repl.cc +++ b/tools/repl.cc @@ -189,7 +189,7 @@ static void do_call(CsState &cs, ostd::ConstCharRange line) { return; } signal(SIGINT, SIG_DFL); - if (ret.get_type() != CsValueType::null) { + if (ret.get_type() != CsValueType::Null) { ostd::writeln(ret.get_str()); } }