From e0d21d2158e8d03ee3139392284915c19ee4619b Mon Sep 17 00:00:00 2001 From: reduz Date: Mon, 28 Dec 2015 15:59:20 -0300 Subject: Ability to set autoloads as singleton global variables --- modules/gdscript/gd_script.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'modules/gdscript/gd_script.cpp') diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 62006cf18b..ef53dcfe71 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -2570,6 +2570,12 @@ void GDScriptLanguage::_add_global(const StringName& p_name,const Variant& p_val _global_array=global_array.ptr(); } +void GDScriptLanguage::add_global_constant(const StringName& p_variable,const Variant& p_value) { + + _add_global(p_variable,p_value); +} + + void GDScriptLanguage::init() { -- cgit v1.2.3 From 30c12297dc6df7d35df140475c0cec7308aea77a Mon Sep 17 00:00:00 2001 From: reduz Date: Mon, 28 Dec 2015 19:31:52 -0300 Subject: - added 'onready' keyword to gdscript. Defers initialization of member variables until _ready() is run. --- modules/gdscript/gd_script.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'modules/gdscript/gd_script.cpp') diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index ef53dcfe71..70c7887766 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -2652,6 +2652,7 @@ void GDScriptLanguage::get_reserved_words(List *p_words) const { "elif", "enum", "extends" , + "onready", "for" , "func" , "if" , -- cgit v1.2.3 From 7d2d1442f83e6a7a57a1823a6cf5af53e5419d5f Mon Sep 17 00:00:00 2001 From: reduz Date: Tue, 29 Dec 2015 12:11:21 -0300 Subject: -add breakpoint statement to ease with debugging, closes #3165 --- modules/gdscript/gd_script.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'modules/gdscript/gd_script.cpp') diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 70c7887766..1c19328fe8 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -1077,6 +1077,14 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a ip+=2; } continue; + case OPCODE_BREAKPOINT: { +#ifdef DEBUG_ENABLED + if (ScriptDebugger::get_singleton()) { + GDScriptLanguage::get_singleton()->debug_break("Breakpoint Statement",true); + } +#endif + ip+=1; + } continue; case OPCODE_LINE: { CHECK_SPACE(2); @@ -2672,6 +2680,7 @@ void GDScriptLanguage::get_reserved_words(List *p_words) const { "or", "export", "assert", + "breakpoint", "yield", "static", "float", -- cgit v1.2.3 From 5be9ff7b6715a661e85f99b108f96340de7ef435 Mon Sep 17 00:00:00 2001 From: George Marques Date: Fri, 1 Jan 2016 11:50:53 -0200 Subject: Update copyright to 2016 in headers --- modules/gdscript/gd_script.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gdscript/gd_script.cpp') diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 1c19328fe8..9b9b0e4b8c 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ -- cgit v1.2.3 From 0e0a7c9494622543e4ca2a865f3784babc4a2a78 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 2 Jan 2016 13:56:58 -0300 Subject: -properly handle newline in \ (line continuation) in gdscript, fixes #2112 -also fix a small crash in export detection with scripts that include themselves --- modules/gdscript/gd_script.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'modules/gdscript/gd_script.cpp') diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 9b9b0e4b8c..9dddfdc1d9 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -33,17 +33,6 @@ #include "os/file_access.h" #include "io/file_access_encrypted.h" -/* TODO: - - *populate globals - *do checks as close to debugger as possible (but don't do debugger) - *const check plz - *check arguments and default arguments in GDFunction - -get property list in instance? - *missing opcodes - -const checks - -make thread safe - */ @@ -1740,16 +1729,21 @@ bool GDScript::_update_exports() { } } - Ref bf = ResourceLoader::load(path); + if (path!=get_path()) { + + Ref bf = ResourceLoader::load(path); - if (bf.is_valid()) { + if (bf.is_valid()) { - //print_line("parent is: "+bf->get_path()); - base_cache=bf; - bf->inheriters_cache.insert(get_instance_ID()); + //print_line("parent is: "+bf->get_path()); + base_cache=bf; + bf->inheriters_cache.insert(get_instance_ID()); - //bf->_update_exports(p_instances,true,false); + //bf->_update_exports(p_instances,true,false); + } + } else { + ERR_PRINT(("Path extending itself in "+path).utf8().get_data()); } } -- cgit v1.2.3 From 1597082c85a2bf3ddca0414de1fa32fb5f2e5350 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 2 Jan 2016 20:17:31 -0300 Subject: -Ability to roll-back script-exported properties to their default value on the script, closes #2128 --- modules/gdscript/gd_script.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'modules/gdscript/gd_script.cpp') diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 9dddfdc1d9..03e79393e2 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -1592,6 +1592,28 @@ void GDScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) { }*/ #endif + +bool GDScript::get_property_default_value(const StringName& p_property, Variant &r_value) const { + +#ifdef TOOLS_ENABLED + + //for (const Map::Element *I=member_default_values.front();I;I=I->next()) { + // print_line("\t"+String(String(I->key())+":"+String(I->get()))); + //} + const Map::Element *E=member_default_values_cache.find(p_property); + if (E) { + r_value=E->get(); + return true; + } + + if (base_cache.is_valid()) { + return base_cache->get_property_default_value(p_property,r_value); + } +#endif + return false; + +} + ScriptInstance* GDScript::instance_create(Object *p_this) { -- cgit v1.2.3 From cb39db0b02c2d69994e2cd523844a2a9d3087d85 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 3 Jan 2016 21:11:11 -0300 Subject: Fixed bug with default arguments in gdscript, closes #2024 --- modules/gdscript/gd_script.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'modules/gdscript/gd_script.cpp') diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 03e79393e2..d753a9f167 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -221,6 +221,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a r_err.error=Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; r_err.argument=_argument_count; + return Variant(); } else if (p_argcount < _argument_count - _default_arg_count) { -- cgit v1.2.3 From 1a9c3a134df879e17c939156dfcddfdf283ac447 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 10 Jan 2016 23:13:02 -0300 Subject: -Make Akien happy, fixes #3068 (seems I wrote all the code, then forgot to use the enum...) --- modules/gdscript/gd_script.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gdscript/gd_script.cpp') diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index d753a9f167..9a3f50d3b8 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -1139,7 +1139,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a if (!GDScriptLanguage::get_singleton()->debug_break(err_text,false)) { // debugger break did not happen - _err_print_error(err_func.utf8().get_data(),err_file.utf8().get_data(),err_line,err_text.utf8().get_data()); + _err_print_error(err_func.utf8().get_data(),err_file.utf8().get_data(),err_line,err_text.utf8().get_data(),ERR_HANDLER_SCRIPT); } -- cgit v1.2.3