diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2017-08-27 21:07:15 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2017-08-27 22:13:45 +0200 |
commit | 7ad14e7a3e6f87ddc450f7e34621eb5200808451 (patch) | |
tree | 8804d0dd24cc126087462edfbbbf73ed61b56b0e /modules/gdscript | |
parent | 37da8155a4500a9386027b4d791a86186bc7ab4a (diff) |
Dead code tells no tales
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/gd_compiler.h | 13 | ||||
-rw-r--r-- | modules/gdscript/gd_editor.cpp | 124 | ||||
-rw-r--r-- | modules/gdscript/gd_function.cpp | 16 | ||||
-rw-r--r-- | modules/gdscript/gd_script.cpp | 104 | ||||
-rw-r--r-- | modules/gdscript/gd_tokenizer.cpp | 50 | ||||
-rw-r--r-- | modules/gdscript/register_types.cpp | 103 |
6 files changed, 6 insertions, 404 deletions
diff --git a/modules/gdscript/gd_compiler.h b/modules/gdscript/gd_compiler.h index 5caa3b0ee1..ac713ae75b 100644 --- a/modules/gdscript/gd_compiler.h +++ b/modules/gdscript/gd_compiler.h @@ -91,7 +91,6 @@ class GDCompiler { } } - //int get_identifier_pos(const StringName& p_dentifier) const; HashMap<Variant, int, VariantHasher, VariantComparator> constant_map; Map<StringName, int> name_map; @@ -127,17 +126,6 @@ class GDCompiler { int call_max; }; -#if 0 - void _create_index(const GDParser::OperatorNode *on); - void _create_call(const GDParser::OperatorNode *on); - - - int _parse_expression(const GDParser::Node *p_expr,CodeGen& codegen); - void _parse_block(GDParser::BlockNode *p_block); - void _parse_function(GDParser::FunctionNode *p_func); - Ref<GDScript> _parse_class(GDParser::ClassNode *p_class); -#endif - bool _is_class_member_property(CodeGen &codegen, const StringName &p_name); bool _is_class_member_property(GDScript *owner, const StringName &p_name); @@ -146,7 +134,6 @@ class GDCompiler { bool _create_unary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level); bool _create_binary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer = false); - //int _parse_subexpression(CodeGen& codegen,const GDParser::BlockNode *p_block,const GDParser::Node *p_expression); int _parse_assign_right_expression(CodeGen &codegen, const GDParser::OperatorNode *p_expression, int p_stack_level); int _parse_expression(CodeGen &codegen, const GDParser::Node *p_expression, int p_stack_level, bool p_root = false, bool p_initializer = false); Error _parse_block(CodeGen &codegen, const GDParser::BlockNode *p_block, int p_stack_level = 0, int p_break_addr = -1, int p_continue_addr = -1); diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index 349918f317..b0a18b4b4b 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -27,12 +27,14 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#include "gd_script.h" + #include "editor/editor_settings.h" #include "gd_compiler.h" -#include "gd_script.h" #include "global_constants.h" #include "os/file_access.h" #include "project_settings.h" + #ifdef TOOLS_ENABLED #include "editor/editor_file_system.h" #include "editor/editor_settings.h" @@ -1672,21 +1674,6 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N return; //found } } -#if 0 - //use class directly, no code was found - if (!isfunction) { - for (const Map<StringName,Variant>::Element *E=scr->get_constants().front();E;E=E->next()) { - options.insert(E->key()); - } - } - for (const Map<StringName,GDFunction>::Element *E=scr->get_member_functions().front();E;E=E->next()) { - options.insert(String(E->key())+"("); - } - - for (const Set<StringName>::Element *E=scr->get_members().front();E;E=E->next()) { - options.insert(E->get()); - } -#endif } if (scr->get_base().is_valid()) @@ -2027,99 +2014,6 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N } } } -#if 0 - bool _static=context.function->_static; - - - - - for(int i=0;i<context._class->static_functions.size();i++) { - if (context._class->static_functions[i]->arguments.size()) - result.insert(context._class->static_functions[i]->name.operator String()+"("); - else - result.insert(context._class->static_functions[i]->name.operator String()+"()"); - } - - if (!p_static) { - - for(int i=0;i<context._class->functions.size();i++) { - if (context._class->functions[i]->arguments.size()) - result.insert(context._class->functions[i]->name.operator String()+"("); - else - result.insert(context._class->functions[i]->name.operator String()+"()"); - } - } - - Ref<Reference> base = _get_parent_class(context); - - while(true) { - - Ref<GDScript> script = base; - Ref<GDNativeClass> nc = base; - if (script.is_valid()) { - - if (!p_static && !p_only_functions) { - for (const Set<StringName>::Element *E=script->get_members().front();E;E=E->next()) { - result.insert(E->get().operator String()); - } - } - - if (!p_only_functions) { - for (const Map<StringName,Variant>::Element *E=script->get_constants().front();E;E=E->next()) { - result.insert(E->key().operator String()); - } - } - - for (const Map<StringName,GDFunction>::Element *E=script->get_member_functions().front();E;E=E->next()) { - if (!p_static || E->get().is_static()) { - if (E->get().get_argument_count()) - result.insert(E->key().operator String()+"("); - else - result.insert(E->key().operator String()+"()"); - } - } - - if (!p_only_functions) { - for (const Map<StringName,Ref<GDScript> >::Element *E=script->get_subclasses().front();E;E=E->next()) { - result.insert(E->key().operator String()); - } - } - - base=script->get_base(); - if (base.is_null()) - base=script->get_native(); - } else if (nc.is_valid()) { - - if (!p_only_functions) { - - StringName type = nc->get_name(); - List<String> constants; - ClassDB::get_integer_constant_list(type,&constants); - for(List<String>::Element *E=constants.front();E;E=E->next()) { - result.insert(E->get()); - } - - List<MethodInfo> methods; - ClassDB::get_method_list(type,&methods); - for(List<MethodInfo>::Element *E=methods.front();E;E=E->next()) { - if (E->get().arguments.size()) - result.insert(E->get().name+"("); - else - result.insert(E->get().name+"()"); - } - } - break; - } else - break; - - } - - for(int i=0;i<GDFunctions::FUNC_MAX;i++) { - - result.insert(GDFunctions::get_func_name(GDFunctions::Function(i))); - } - -#endif } Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_forced, String &r_call_hint) { @@ -2852,18 +2746,6 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol } } } -#if 0 - GDCompletionIdentifier identifier; - if (_guess_identifier_type(context,p.get_completion_line(),p_symbol,identifier)) { - - print_line("var type: "+Variant::get_type_name(identifier.type)); - if (identifier.script.is_valid()) { - print_line("var script: "+identifier.script->get_path()); - } - print_line("obj type: "+String(identifier.obj_type)); - print_line("value: "+String(identifier.value)); - } -#endif } } break; diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp index 0c9eca894f..81bf4664d8 100644 --- a/modules/gdscript/gd_function.cpp +++ b/modules/gdscript/gd_function.cpp @@ -1319,22 +1319,6 @@ void GDFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName, } } -#if 0 -void GDFunction::clear() { - - name=StringName(); - constants.clear(); - _stack_size=0; - code.clear(); - _constants_ptr=NULL; - _constant_count=0; - _global_names_ptr=NULL; - _global_names_count=0; - _code_ptr=NULL; - _code_size=0; - -} -#endif GDFunction::GDFunction() : function_list(this) { diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 476fca6382..cf6529d5ae 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "gd_script.h" + #include "gd_compiler.h" #include "global_constants.h" #include "io/file_access_encrypted.h" @@ -42,11 +43,6 @@ GDNativeClass::GDNativeClass(const StringName &p_name) { name = p_name; } -/*void GDNativeClass::call_multilevel(const StringName& p_method,const Variant** p_args,int p_argcount){ - - -}*/ - bool GDNativeClass::_get(const StringName &p_name, Variant &r_ret) const { bool ok; @@ -183,7 +179,6 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallErro bool GDScript::can_instance() const { - //return valid; //any script in GDscript can instance return valid || (!tool && !ScriptServer::is_scripting_enabled()); } @@ -218,49 +213,6 @@ void GDScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) { placeholders.erase(p_placeholder); } - -/* -void GDScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) { - - - List<PropertyInfo> plist; - GDScript *scr=this; - - Map<StringName,Variant> default_values; - while(scr) { - - Vector<_GDScriptMemberSort> msort; - for(Map<StringName,PropertyInfo>::Element *E=scr->member_info.front();E;E=E->next()) { - - _GDScriptMemberSort ms; - ERR_CONTINUE(!scr->member_indices.has(E->key())); - ms.index=scr->member_indices[E->key()].index; - ms.name=E->key(); - - msort.push_back(ms); - - } - - msort.sort(); - msort.invert(); - for(int i=0;i<msort.size();i++) { - - plist.push_front(scr->member_info[msort[i].name]); - if (scr->member_default_values.has(msort[i].name)) - default_values[msort[i].name]=scr->member_default_values[msort[i].name]; - else { - Variant::CallError err; - default_values[msort[i].name]=Variant::construct(scr->member_info[msort[i].name].type,NULL,0,err); - } - } - - scr=scr->_base; - } - - - p_placeholder->update(plist,default_values); - -}*/ #endif void GDScript::get_script_method_list(List<MethodInfo> *p_list) const { @@ -428,7 +380,6 @@ void GDScript::set_source_code(const String &p_code) { source = p_code; #ifdef TOOLS_ENABLED source_changed_cache = true; -//print_line("SC CHANGED "+get_path()); #endif } @@ -655,12 +606,6 @@ Error GDScript::reload(bool p_keep_state) { _set_subclass_path(E->get(), path); } -#ifdef TOOLS_ENABLED -/*for (Set<PlaceHolderScriptInstance*>::Element *E=placeholders.front();E;E=E->next()) { - - _update_placeholder(E->get()); - }*/ -#endif return OK; } @@ -1141,53 +1086,10 @@ void GDInstance::get_property_list(List<PropertyInfo> *p_properties) const { props.push_front(sptr->member_info[msort[i].name]); } -#if 0 - if (sptr->member_functions.has("_get_property_list")) { - - Variant::CallError err; - GDFunction *f = const_cast<GDFunction*>(sptr->member_functions["_get_property_list"]); - Variant plv = f->call(const_cast<GDInstance*>(this),NULL,0,err); - - if (plv.get_type()!=Variant::ARRAY) { - - ERR_PRINT("_get_property_list: expected array returned"); - } else { - - Array pl=plv; - - for(int i=0;i<pl.size();i++) { - - Dictionary p = pl[i]; - PropertyInfo pinfo; - if (!p.has("name")) { - ERR_PRINT("_get_property_list: expected 'name' key of type string.") - continue; - } - if (!p.has("type")) { - ERR_PRINT("_get_property_list: expected 'type' key of type integer.") - continue; - } - pinfo.name=p["name"]; - pinfo.type=Variant::Type(int(p["type"])); - if (p.has("hint")) - pinfo.hint=PropertyHint(int(p["hint"])); - if (p.has("hint_string")) - pinfo.hint_string=p["hint_string"]; - if (p.has("usage")) - pinfo.usage=p["usage"]; - - - props.push_back(pinfo); - } - } - } -#endif sptr = sptr->_base; } - //props.invert(); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { p_properties->push_back(E->get()); @@ -1390,10 +1292,6 @@ GDInstance::~GDInstance() { } /************* SCRIPT LANGUAGE **************/ -/************* SCRIPT LANGUAGE **************/ -/************* SCRIPT LANGUAGE **************/ -/************* SCRIPT LANGUAGE **************/ -/************* SCRIPT LANGUAGE **************/ GDScriptLanguage *GDScriptLanguage::singleton = NULL; diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index 6ab7361c92..5f85158232 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "gd_tokenizer.h" + #include "gd_functions.h" #include "io/marshalls.h" #include "map.h" @@ -504,7 +505,6 @@ void GDTokenizerText::_advance() { _make_newline(i); return; } -#if 1 //py style tokenizer case '#': { // line comment skip while (GETCHAR(0) != '\n') { @@ -526,57 +526,9 @@ void GDTokenizerText::_advance() { return; } break; -#endif case '/': { switch (GETCHAR(1)) { -#if 0 // c style tokenizer - case '*': { // block comment - int pos = code_pos+2; - int new_line=line; - int new_col=column+2; - - while(true) { - if (_code[pos]=='0') { - _make_error("Unterminated Comment"); - code_pos=pos; - return; - } - if (_code[pos]=='*' && _code[pos+1]=='/') { - new_col+=2; - pos+=2; //compensate - break; - } else if (_code[pos]=='\n') { - new_line++; - new_col=1; - } else { - new_col++; - } - pos++; - } - - column=new_col; - line=new_line; - code_pos=pos; - continue; - - } break; - case '/': { // line comment skip - - while(GETCHAR(0)!='\n') { - code_pos++; - if (GETCHAR(0)==0) { //end of file - _make_error("Unterminated Comment"); - return; - } - } - INCPOS(1); - column=1; - line++; - continue; - - } break; -#endif case '=': { // diveq _make_token(TK_OP_ASSIGN_DIV); diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp index 2354c4063e..036274c8f2 100644 --- a/modules/gdscript/register_types.cpp +++ b/modules/gdscript/register_types.cpp @@ -37,103 +37,7 @@ GDScriptLanguage *script_language_gd = NULL; ResourceFormatLoaderGDScript *resource_loader_gd = NULL; ResourceFormatSaverGDScript *resource_saver_gd = NULL; -#if 0 -#ifdef TOOLS_ENABLED -#include "editor/editor_import_export.h" -#include "editor/editor_node.h" -#include "editor/editor_settings.h" -#include "gd_tokenizer.h" - -class EditorExportGDScript : public EditorExportPlugin { - - GDCLASS(EditorExportGDScript,EditorExportPlugin); - -public: - - virtual Vector<uint8_t> custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform) { - //compile gdscript to bytecode - - if (EditorImportExport::get_singleton()->script_get_action()!=EditorImportExport::SCRIPT_ACTION_NONE) { - - if (p_path.ends_with(".gd")) { - Vector<uint8_t> file = FileAccess::get_file_as_array(p_path); - if (file.empty()) - return file; - String txt; - txt.parse_utf8((const char*)file.ptr(),file.size()); - file = GDTokenizerBuffer::parse_code_string(txt); - - if (!file.empty()) { - - if (EditorImportExport::get_singleton()->script_get_action()==EditorImportExport::SCRIPT_ACTION_ENCRYPT) { - - String tmp_path=EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/script.gde"); - FileAccess *fa = FileAccess::open(tmp_path,FileAccess::WRITE); - String skey=EditorImportExport::get_singleton()->script_get_encryption_key().to_lower(); - Vector<uint8_t> key; - key.resize(32); - for(int i=0;i<32;i++) { - int v=0; - if (i*2<skey.length()) { - CharType ct = skey[i*2]; - if (ct>='0' && ct<='9') - ct=ct-'0'; - else if (ct>='a' && ct<='f') - ct=10+ct-'a'; - v|=ct<<4; - } - - if (i*2+1<skey.length()) { - CharType ct = skey[i*2+1]; - if (ct>='0' && ct<='9') - ct=ct-'0'; - else if (ct>='a' && ct<='f') - ct=10+ct-'a'; - v|=ct; - } - key[i]=v; - } - FileAccessEncrypted *fae=memnew(FileAccessEncrypted); - Error err = fae->open_and_parse(fa,key,FileAccessEncrypted::MODE_WRITE_AES256); - if (err==OK) { - - fae->store_buffer(file.ptr(),file.size()); - p_path=p_path.get_basename()+".gde"; - } - - memdelete(fae); - - file=FileAccess::get_file_as_array(tmp_path); - return file; - - - } else { - - p_path=p_path.get_basename()+".gdc"; - return file; - } - } - - } - } - - return Vector<uint8_t>(); - } - - - EditorExportGDScript(){} - -}; - -static void register_editor_plugin() { - - Ref<EditorExportGDScript> egd = memnew( EditorExportGDScript ); - EditorImportExport::get_singleton()->add_export_plugin(egd); -} - -#endif -#endif void register_gdscript_types() { ClassDB::register_class<GDScript>(); @@ -146,13 +50,8 @@ void register_gdscript_types() { ResourceLoader::add_resource_format_loader(resource_loader_gd); resource_saver_gd = memnew(ResourceFormatSaverGDScript); ResourceSaver::add_resource_format_saver(resource_saver_gd); -#if 0 -#ifdef TOOLS_ENABLED - - EditorNode::add_init_callback(register_editor_plugin); -#endif -#endif } + void unregister_gdscript_types() { ScriptServer::unregister_language(script_language_gd); |