From 8611d7d9c82712173b61ff608301744ee359416d Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 13 Jul 2022 00:07:10 +0200 Subject: [PATCH] Removed rpc keywords from cscript. Note that networking should still work with it using rset_config (like how it works in engine side code). --- modules/cscript/cscript.cpp | 33 +------ modules/cscript/cscript.h | 1 - modules/cscript/cscript_compiler.cpp | 3 - modules/cscript/cscript_editor.cpp | 3 +- modules/cscript/cscript_function.cpp | 1 - modules/cscript/cscript_function.h | 4 - modules/cscript/cscript_parser.cpp | 118 +------------------------- modules/cscript/cscript_parser.h | 5 -- modules/cscript/cscript_tokenizer.cpp | 23 ----- modules/cscript/cscript_tokenizer.h | 8 -- 10 files changed, 4 insertions(+), 195 deletions(-) diff --git a/modules/cscript/cscript.cpp b/modules/cscript/cscript.cpp index b93744797..558ff2623 100644 --- a/modules/cscript/cscript.cpp +++ b/modules/cscript/cscript.cpp @@ -1284,34 +1284,11 @@ ScriptLanguage *CScriptInstance::get_language() { } MultiplayerAPI::RPCMode CScriptInstance::get_rpc_mode(const StringName &p_method) const { - const CScript *cscript = script.ptr(); - - while (cscript) { - const Map::Element *E = cscript->member_functions.find(p_method); - if (E) { - if (E->get()->get_rpc_mode() != MultiplayerAPI::RPC_MODE_DISABLED) { - return E->get()->get_rpc_mode(); - } - } - cscript = cscript->_base; - } - + //note that methods set up using rpc_config should still work, even if they are declared in scripts. return MultiplayerAPI::RPC_MODE_DISABLED; } MultiplayerAPI::RPCMode CScriptInstance::get_rset_mode(const StringName &p_variable) const { - const CScript *cscript = script.ptr(); - - while (cscript) { - const Map::Element *E = cscript->member_indices.find(p_variable); - if (E) { - if (E->get().rpc_mode) { - return E->get().rpc_mode; - } - } - cscript = cscript->_base; - } - return MultiplayerAPI::RPC_MODE_DISABLED; } @@ -1784,14 +1761,6 @@ void CScriptLanguage::get_reserved_words(List *p_words) const { "return", "match", "while", - "remote", - "sync", - "master", - "puppet", - "slave", - "remotesync", - "mastersync", - "puppetsync", nullptr }; diff --git a/modules/cscript/cscript.h b/modules/cscript/cscript.h index 9fdabb1d8..0c613652f 100644 --- a/modules/cscript/cscript.h +++ b/modules/cscript/cscript.h @@ -60,7 +60,6 @@ class CScript : public Script { int index; StringName setter; StringName getter; - MultiplayerAPI::RPCMode rpc_mode; CScriptDataType data_type; }; diff --git a/modules/cscript/cscript_compiler.cpp b/modules/cscript/cscript_compiler.cpp index 50835f35d..74f7d9d0e 100644 --- a/modules/cscript/cscript_compiler.cpp +++ b/modules/cscript/cscript_compiler.cpp @@ -1729,7 +1729,6 @@ Error CScriptCompiler::_parse_function(CScript *p_script, const CScriptParser::C if (p_func) { gdfunc->_static = p_func->_static; - gdfunc->rpc_mode = p_func->rpc_mode; gdfunc->argument_types.resize(p_func->argument_types.size()); for (int i = 0; i < p_func->argument_types.size(); i++) { gdfunc->argument_types.write[i] = _gdtype_from_datatype(p_func->argument_types[i], p_script); @@ -1737,7 +1736,6 @@ Error CScriptCompiler::_parse_function(CScript *p_script, const CScriptParser::C gdfunc->return_type = _gdtype_from_datatype(p_func->return_type, p_script); } else { gdfunc->_static = false; - gdfunc->rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED; gdfunc->return_type = CScriptDataType(); gdfunc->return_type.has_type = true; gdfunc->return_type.kind = CScriptDataType::BUILTIN; @@ -1944,7 +1942,6 @@ Error CScriptCompiler::_parse_class_level(CScript *p_script, const CScriptParser minfo.index = p_script->member_indices.size(); minfo.setter = p_class->variables[i].setter; minfo.getter = p_class->variables[i].getter; - minfo.rpc_mode = p_class->variables[i].rpc_mode; minfo.data_type = _gdtype_from_datatype(p_class->variables[i].data_type, p_script); PropertyInfo prop_info = minfo.data_type; diff --git a/modules/cscript/cscript_editor.cpp b/modules/cscript/cscript_editor.cpp index 564ab74b7..46f5ddf83 100644 --- a/modules/cscript/cscript_editor.cpp +++ b/modules/cscript/cscript_editor.cpp @@ -2195,8 +2195,7 @@ static void _find_identifiers(const CScriptCompletionContext &p_context, bool p_ "and", "in", "not", "or", "false", "PI", "TAU", "INF", "NAN", "self", "true", "as", "assert", "breakpoint", "class", "extends", "is", "func", "preload", "setget", "signal", "tool", "yield", "const", "enum", "export", "onready", "static", "var", "break", "continue", "if", "elif", - "else", "for", "pass", "return", "match", "while", "remote", "sync", "master", "puppet", "slave", - "remotesync", "mastersync", "puppetsync", + "else", "for", "pass", "return", "match", "while", nullptr }; diff --git a/modules/cscript/cscript_function.cpp b/modules/cscript/cscript_function.cpp index 5559563ce..3c2377a67 100644 --- a/modules/cscript/cscript_function.cpp +++ b/modules/cscript/cscript_function.cpp @@ -1699,7 +1699,6 @@ CScriptFunction::CScriptFunction() : function_list(this) { _stack_size = 0; _call_size = 0; - rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED; name = ""; #ifdef DEBUG_ENABLED _func_cname = nullptr; diff --git a/modules/cscript/cscript_function.h b/modules/cscript/cscript_function.h index 1c7cdb420..478f9afc7 100644 --- a/modules/cscript/cscript_function.h +++ b/modules/cscript/cscript_function.h @@ -246,7 +246,6 @@ private: int _call_size; int _initial_line; bool _static; - MultiplayerAPI::RPCMode rpc_mode; CScript *_script; @@ -355,9 +354,6 @@ public: Variant call(CScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state = nullptr); - _FORCE_INLINE_ MultiplayerAPI::RPCMode get_rpc_mode() const { - return rpc_mode; - } CScriptFunction(); ~CScriptFunction(); }; diff --git a/modules/cscript/cscript_parser.cpp b/modules/cscript/cscript_parser.cpp index 602d500ba..d809e6288 100644 --- a/modules/cscript/cscript_parser.cpp +++ b/modules/cscript/cscript_parser.cpp @@ -4035,8 +4035,6 @@ void CScriptParser::_parse_class(ClassNode *p_class) { #ifdef DEBUG_ENABLED function->arguments_usage = arguments_usage; #endif // DEBUG_ENABLED - function->rpc_mode = rpc_mode; - rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED; if (name == "_init") { if (_static) { @@ -4710,9 +4708,9 @@ void CScriptParser::_parse_class(ClassNode *p_class) { #undef _ADVANCE_AND_CONSUME_NEWLINES } - if (tokenizer->get_token() != CScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != CScriptTokenizer::TK_PR_ONREADY && tokenizer->get_token() != CScriptTokenizer::TK_PR_REMOTE && tokenizer->get_token() != CScriptTokenizer::TK_PR_MASTER && tokenizer->get_token() != CScriptTokenizer::TK_PR_PUPPET && tokenizer->get_token() != CScriptTokenizer::TK_PR_SYNC && tokenizer->get_token() != CScriptTokenizer::TK_PR_REMOTESYNC && tokenizer->get_token() != CScriptTokenizer::TK_PR_MASTERSYNC && tokenizer->get_token() != CScriptTokenizer::TK_PR_PUPPETSYNC && tokenizer->get_token() != CScriptTokenizer::TK_PR_SLAVE) { + if (tokenizer->get_token() != CScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != CScriptTokenizer::TK_PR_ONREADY) { current_export = PropertyInfo(); - _set_error("Expected \"var\", \"onready\", \"remote\", \"master\", \"puppet\", \"sync\", \"remotesync\", \"mastersync\", \"puppetsync\"."); + _set_error("Expected \"var\", \"onready\"."); return; } @@ -4728,114 +4726,6 @@ void CScriptParser::_parse_class(ClassNode *p_class) { continue; } break; - case CScriptTokenizer::TK_PR_REMOTE: { - //may be fallthrough from export, ignore if so - tokenizer->advance(); - if (current_export.type) { - if (tokenizer->get_token() != CScriptTokenizer::TK_PR_VAR) { - _set_error("Expected \"var\"."); - return; - } - - } else { - if (tokenizer->get_token() != CScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != CScriptTokenizer::TK_PR_FUNCTION) { - _set_error("Expected \"var\" or \"func\"."); - return; - } - } - rpc_mode = MultiplayerAPI::RPC_MODE_REMOTE; - - continue; - } break; - case CScriptTokenizer::TK_PR_MASTER: { - //may be fallthrough from export, ignore if so - tokenizer->advance(); - if (current_export.type) { - if (tokenizer->get_token() != CScriptTokenizer::TK_PR_VAR) { - _set_error("Expected \"var\"."); - return; - } - - } else { - if (tokenizer->get_token() != CScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != CScriptTokenizer::TK_PR_FUNCTION) { - _set_error("Expected \"var\" or \"func\"."); - return; - } - } - - rpc_mode = MultiplayerAPI::RPC_MODE_MASTER; - continue; - } break; - case CScriptTokenizer::TK_PR_SLAVE: -#ifdef DEBUG_ENABLED - _add_warning(CScriptWarning::DEPRECATED_KEYWORD, tokenizer->get_token_line(), "slave", "puppet"); -#endif - FALLTHROUGH; - case CScriptTokenizer::TK_PR_PUPPET: { - //may be fallthrough from export, ignore if so - tokenizer->advance(); - if (current_export.type) { - if (tokenizer->get_token() != CScriptTokenizer::TK_PR_VAR) { - _set_error("Expected \"var\"."); - return; - } - - } else { - if (tokenizer->get_token() != CScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != CScriptTokenizer::TK_PR_FUNCTION) { - _set_error("Expected \"var\" or \"func\"."); - return; - } - } - - rpc_mode = MultiplayerAPI::RPC_MODE_PUPPET; - continue; - } break; - case CScriptTokenizer::TK_PR_REMOTESYNC: - case CScriptTokenizer::TK_PR_SYNC: { - //may be fallthrough from export, ignore if so - tokenizer->advance(); - if (tokenizer->get_token() != CScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != CScriptTokenizer::TK_PR_FUNCTION) { - if (current_export.type) { - _set_error("Expected \"var\"."); - } else { - _set_error("Expected \"var\" or \"func\"."); - } - return; - } - - rpc_mode = MultiplayerAPI::RPC_MODE_REMOTESYNC; - continue; - } break; - case CScriptTokenizer::TK_PR_MASTERSYNC: { - //may be fallthrough from export, ignore if so - tokenizer->advance(); - if (tokenizer->get_token() != CScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != CScriptTokenizer::TK_PR_FUNCTION) { - if (current_export.type) { - _set_error("Expected \"var\"."); - } else { - _set_error("Expected \"var\" or \"func\"."); - } - return; - } - - rpc_mode = MultiplayerAPI::RPC_MODE_MASTERSYNC; - continue; - } break; - case CScriptTokenizer::TK_PR_PUPPETSYNC: { - //may be fallthrough from export, ignore if so - tokenizer->advance(); - if (tokenizer->get_token() != CScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != CScriptTokenizer::TK_PR_FUNCTION) { - if (current_export.type) { - _set_error("Expected \"var\"."); - } else { - _set_error("Expected \"var\" or \"func\"."); - } - return; - } - - rpc_mode = MultiplayerAPI::RPC_MODE_PUPPETSYNC; - continue; - } break; case CScriptTokenizer::TK_PR_VAR: { // variable declaration and (eventual) initialization @@ -4860,7 +4750,6 @@ void CScriptParser::_parse_class(ClassNode *p_class) { member._export.name = member.identifier; member.line = tokenizer->get_token_line(); member.usages = 0; - member.rpc_mode = rpc_mode; if (current_class->constant_expressions.has(member.identifier)) { _set_error("A constant named \"" + String(member.identifier) + "\" already exists in this class (at line: " + @@ -4898,8 +4787,6 @@ void CScriptParser::_parse_class(ClassNode *p_class) { #endif // DEBUG_ENABLED tokenizer->advance(); - rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED; - if (tokenizer->get_token() == CScriptTokenizer::TK_COLON) { if (tokenizer->get_token(1) == CScriptTokenizer::TK_OP_ASSIGN) { member.data_type = DataType(); @@ -8850,7 +8737,6 @@ void CScriptParser::clear() { current_class = nullptr; completion_found = false; - rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED; current_function = nullptr; diff --git a/modules/cscript/cscript_parser.h b/modules/cscript/cscript_parser.h index a0c93def2..7bba1a3e6 100644 --- a/modules/cscript/cscript_parser.h +++ b/modules/cscript/cscript_parser.h @@ -164,7 +164,6 @@ public: int line; Node *expression; OperatorNode *initial_assignment; - MultiplayerAPI::RPCMode rpc_mode; int usages; }; @@ -204,7 +203,6 @@ public: struct FunctionNode : public Node { bool _static; - MultiplayerAPI::RPCMode rpc_mode; bool has_yield; bool has_unreachable_code; StringName name; @@ -230,7 +228,6 @@ public: FunctionNode() { type = TYPE_FUNCTION; _static = false; - rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED; has_yield = false; has_unreachable_code = false; } @@ -593,8 +590,6 @@ private: PropertyInfo current_export; - MultiplayerAPI::RPCMode rpc_mode; - void _set_error(const String &p_error, int p_line = -1, int p_column = -1); #ifdef DEBUG_ENABLED void _add_warning(int p_code, int p_line = -1, const String &p_symbol1 = String(), const String &p_symbol2 = String(), const String &p_symbol3 = String(), const String &p_symbol4 = String()); diff --git a/modules/cscript/cscript_tokenizer.cpp b/modules/cscript/cscript_tokenizer.cpp index 000e4099c..4a925e201 100644 --- a/modules/cscript/cscript_tokenizer.cpp +++ b/modules/cscript/cscript_tokenizer.cpp @@ -106,14 +106,6 @@ const char *CScriptTokenizer::token_names[TK_MAX] = { "yield", "signal", "breakpoint", - "rpc", - "sync", - "master", - "puppet", - "slave", - "remotesync", - "mastersync", - "puppetsync", "'['", "']'", "'{'", @@ -211,14 +203,6 @@ static const _kws _keyword_list[] = { { CScriptTokenizer::TK_PR_YIELD, "yield" }, { CScriptTokenizer::TK_PR_SIGNAL, "signal" }, { CScriptTokenizer::TK_PR_BREAKPOINT, "breakpoint" }, - { CScriptTokenizer::TK_PR_REMOTE, "remote" }, - { CScriptTokenizer::TK_PR_MASTER, "master" }, - { CScriptTokenizer::TK_PR_SLAVE, "slave" }, - { CScriptTokenizer::TK_PR_PUPPET, "puppet" }, - { CScriptTokenizer::TK_PR_SYNC, "sync" }, - { CScriptTokenizer::TK_PR_REMOTESYNC, "remotesync" }, - { CScriptTokenizer::TK_PR_MASTERSYNC, "mastersync" }, - { CScriptTokenizer::TK_PR_PUPPETSYNC, "puppetsync" }, { CScriptTokenizer::TK_PR_CONST, "const" }, { CScriptTokenizer::TK_PR_ENUM, "enum" }, //controlflow @@ -257,13 +241,6 @@ bool CScriptTokenizer::is_token_literal(int p_offset, bool variable_safe) const case TK_PR_EXPORT: case TK_PR_SETGET: case TK_PR_SIGNAL: - case TK_PR_REMOTE: - case TK_PR_MASTER: - case TK_PR_PUPPET: - case TK_PR_SYNC: - case TK_PR_REMOTESYNC: - case TK_PR_MASTERSYNC: - case TK_PR_PUPPETSYNC: return true; // Literal for non-variables only: diff --git a/modules/cscript/cscript_tokenizer.h b/modules/cscript/cscript_tokenizer.h index 704554696..961d3c2a0 100644 --- a/modules/cscript/cscript_tokenizer.h +++ b/modules/cscript/cscript_tokenizer.h @@ -111,14 +111,6 @@ public: TK_PR_YIELD, TK_PR_SIGNAL, TK_PR_BREAKPOINT, - TK_PR_REMOTE, - TK_PR_SYNC, - TK_PR_MASTER, - TK_PR_SLAVE, // Deprecated by TK_PR_PUPPET, to remove in 4.0 - TK_PR_PUPPET, - TK_PR_REMOTESYNC, - TK_PR_MASTERSYNC, - TK_PR_PUPPETSYNC, TK_BRACKET_OPEN, TK_BRACKET_CLOSE, TK_CURLY_BRACKET_OPEN,