diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/bind/core_bind.cpp | 28 | ||||
-rw-r--r-- | core/bind/core_bind.h | 4 | ||||
-rw-r--r-- | core/command_queue_mt.h | 4 | ||||
-rw-r--r-- | core/global_constants.cpp | 10 | ||||
-rw-r--r-- | core/globals.cpp | 8 | ||||
-rw-r--r-- | core/method_bind.h | 1 | ||||
-rw-r--r-- | core/os/os.h | 2 | ||||
-rw-r--r-- | core/os/pc_joystick_map.h | 86 | ||||
-rw-r--r-- | core/os/thread.cpp | 4 | ||||
-rw-r--r-- | core/os/thread.h | 6 | ||||
-rw-r--r-- | core/variant_parser.cpp | 7 |
11 files changed, 45 insertions, 115 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 674ca72782..b291ee396b 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -390,6 +390,12 @@ bool _OS::is_ok_left_and_cancel_right() const { return OS::get_singleton()->get_swap_ok_cancel(); } +Error _OS::set_thread_name(const String& p_name) { + + return Thread::set_name(p_name); +}; + + /* enum Weekday { DAY_SUNDAY, @@ -877,6 +883,8 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("alert","text","title"),&_OS::alert,DEFVAL("Alert!")); + ObjectTypeDB::bind_method(_MD("set_thread_name","name"),&_OS::set_thread_name); + BIND_CONSTANT( DAY_SUNDAY ); BIND_CONSTANT( DAY_MONDAY ); @@ -1895,13 +1903,7 @@ void _Thread::_start_func(void *ud) { Variant::CallError ce; const Variant* arg[1]={&t->userdata}; - // we don't know our thread pointer yet :( - if (t->name == "") { - // come up with a better name using maybe the filename on the Script? - //t->thread->set_name(t->target_method); - } else { - //t->thread->set_name(t->name); - }; + Thread::set_name(t->target_method); t->ret=t->target_instance->call(t->target_method,arg,1,ce); if (ce.error!=Variant::CallError::CALL_OK) { @@ -1992,24 +1994,12 @@ Variant _Thread::wait_to_finish() { return r; } -Error _Thread::set_name(const String &p_name) { - - name = p_name; - - if (thread) { - return thread->set_name(p_name); - }; - - return OK; -}; - void _Thread::_bind_methods() { ObjectTypeDB::bind_method(_MD("start:Error","instance","method","userdata","priority"),&_Thread::start,DEFVAL(Variant()),DEFVAL(PRIORITY_NORMAL)); ObjectTypeDB::bind_method(_MD("get_id"),&_Thread::get_id); ObjectTypeDB::bind_method(_MD("is_active"),&_Thread::is_active); ObjectTypeDB::bind_method(_MD("wait_to_finish:Variant"),&_Thread::wait_to_finish); - ObjectTypeDB::bind_method(_MD("set_name:Error", "name"),&_Thread::set_name); BIND_CONSTANT( PRIORITY_LOW ); BIND_CONSTANT( PRIORITY_NORMAL ); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index d647f431ea..30cc93fa11 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -270,6 +270,8 @@ public: bool is_ok_left_and_cancel_right() const; + Error set_thread_name(const String& p_name); + static _OS *get_singleton() { return singleton; } _OS(); @@ -512,7 +514,6 @@ protected: Object *target_instance; StringName target_method; Thread *thread; - String name; static void _bind_methods(); static void _start_func(void *ud); public: @@ -528,7 +529,6 @@ public: String get_id() const; bool is_active() const; Variant wait_to_finish(); - Error set_name(const String& p_name); _Thread(); ~_Thread(); diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h index 4fd33e3a55..142668f6f6 100644 --- a/core/command_queue_mt.h +++ b/core/command_queue_mt.h @@ -34,7 +34,6 @@ #include "os/mutex.h" #include "os/memory.h" #include "simple_type.h" -#include "print_string.h" /** @author Juan Linietsky <reduzio@gmail.com> */ @@ -175,7 +174,7 @@ class CommandQueueMT { R* ret; SyncSemaphore *sync; - virtual void call() { *ret = (instance->*method)(p1); sync->sem->post(); print_line("post"); sync->in_use=false; ; } + virtual void call() { *ret = (instance->*method)(p1); sync->sem->post(); sync->in_use=false; } }; template<class T,class M,class P1,class P2,class R> @@ -676,7 +675,6 @@ public: if (sync) sync->post(); ss->sem->wait(); - print_line("wait"); } template<class T, class M, class P1, class P2,class R> diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 92e50a8b96..89d918fed9 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -476,6 +476,16 @@ static _GlobalConstant _global_constants[]={ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_EDITOR ), BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_NETWORK ), BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_DEFAULT ), + + BIND_GLOBAL_CONSTANT( METHOD_FLAG_NORMAL ), + BIND_GLOBAL_CONSTANT( METHOD_FLAG_EDITOR ), + BIND_GLOBAL_CONSTANT( METHOD_FLAG_NOSCRIPT ), + BIND_GLOBAL_CONSTANT( METHOD_FLAG_CONST ), + BIND_GLOBAL_CONSTANT( METHOD_FLAG_REVERSE ), + BIND_GLOBAL_CONSTANT( METHOD_FLAG_VIRTUAL ), + BIND_GLOBAL_CONSTANT( METHOD_FLAG_FROM_SCRIPT ), + BIND_GLOBAL_CONSTANT( METHOD_FLAGS_DEFAULT ), + {"TYPE_NIL",Variant::NIL}, {"TYPE_BOOL",Variant::BOOL}, {"TYPE_INT",Variant::INT}, diff --git a/core/globals.cpp b/core/globals.cpp index 5f52420735..d63f9c1bb4 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -916,6 +916,14 @@ static String _encode_variant(const Variant& p_variant) { float val = p_variant; return rtos(val)+(val==int(val)?".0":""); } break; + case Variant::VECTOR2: { + Vector2 val = p_variant; + return String("Vector2(")+rtos(val.x)+String(", ")+rtos(val.y)+String(")"); + } break; + case Variant::VECTOR3: { + Vector3 val = p_variant; + return String("Vector3(")+rtos(val.x)+ String(", ") +rtos(val.y)+ String(", ") +rtos(val.z)+String(")"); + } break; case Variant::STRING: { String val = p_variant; return "\""+val.xml_escape()+"\""; diff --git a/core/method_bind.h b/core/method_bind.h index 4c2598e50c..da3d7c1062 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -50,6 +50,7 @@ enum MethodFlags { METHOD_FLAG_CONST=8, METHOD_FLAG_REVERSE=16, // used for events METHOD_FLAG_VIRTUAL=32, + METHOD_FLAG_FROM_SCRIPT=64, METHOD_FLAGS_DEFAULT=METHOD_FLAG_NORMAL, }; diff --git a/core/os/os.h b/core/os/os.h index e53980a8fe..cc001972b8 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -173,6 +173,8 @@ public: virtual bool is_window_maximized() const { return true; } + + virtual void set_iterations_per_second(int p_ips); virtual int get_iterations_per_second() const; diff --git a/core/os/pc_joystick_map.h b/core/os/pc_joystick_map.h deleted file mode 100644 index df123c5c1b..0000000000 --- a/core/os/pc_joystick_map.h +++ /dev/null @@ -1,86 +0,0 @@ -/*************************************************************************/ -/* pc_joystick_map.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* 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 */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef PC_JOYSTICK_MAP_H -#define PC_JOYSTICK_MAP_H - -#include "input_event.h" - -static const int _pc_joystick_button_remap[JOY_BUTTON_MAX]={ - - JOY_SELECT, - JOY_L3, - JOY_R3, - JOY_START, - - JOY_DPAD_UP, - JOY_DPAD_RIGHT, - JOY_DPAD_DOWN, - JOY_DPAD_LEFT, - - JOY_L2, - JOY_R2, - JOY_L, - JOY_R, - - JOY_SNES_X, - JOY_SNES_A, - JOY_SNES_B, - JOY_SNES_Y, - - // JOY_HOME = 16 -}; - - -static int _pc_joystick_get_native_button(int p_pc_button) { - - if (p_pc_button<0 || p_pc_button>=JOY_BUTTON_MAX) - return p_pc_button; - return _pc_joystick_button_remap[p_pc_button]; -} - -static const int _pc_joystick_axis_remap[JOY_AXIS_MAX]={ - JOY_ANALOG_0_X, - JOY_ANALOG_0_Y, - JOY_ANALOG_1_X, - JOY_ANALOG_1_Y, - JOY_ANALOG_2_X, - JOY_ANALOG_2_Y, - JOY_AXIS_6, - JOY_AXIS_7 -}; - - -static int _pc_joystick_get_native_axis(int p_pc_axis) { - - if (p_pc_axis<0 || p_pc_axis>=JOY_BUTTON_MAX) - return p_pc_axis; - return _pc_joystick_axis_remap[p_pc_axis]; -} - -#endif // PC_JOYSTICK_MAP_H diff --git a/core/os/thread.cpp b/core/os/thread.cpp index 7fb1e969d4..f5d984876d 100644 --- a/core/os/thread.cpp +++ b/core/os/thread.cpp @@ -32,6 +32,7 @@ Thread* (*Thread::create_func)(ThreadCreateCallback,void *,const Settings&)=NULL; Thread::ID (*Thread::get_thread_ID_func)()=NULL; void (*Thread::wait_to_finish_func)(Thread*)=NULL; +Error (*Thread::set_name_func)(const String&)=NULL; Thread::ID Thread::_main_thread_id=0; @@ -60,6 +61,9 @@ void Thread::wait_to_finish(Thread *p_thread) { Error Thread::set_name(const String &p_name) { + if (set_name_func) + return set_name_func(p_name); + return ERR_UNAVAILABLE; }; diff --git a/core/os/thread.h b/core/os/thread.h index 5711561809..4fead72b94 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -63,6 +63,7 @@ protected: static Thread* (*create_func)(ThreadCreateCallback p_callback,void *,const Settings&); static ID (*get_thread_ID_func)(); static void (*wait_to_finish_func)(Thread*); + static Error (*set_name_func)(const String&); friend class Main; @@ -73,10 +74,9 @@ protected: public: - virtual Error set_name(const String& p_name); - virtual ID get_ID() const=0; - + + static Error set_name(const String &p_name); _FORCE_INLINE_ static ID get_main_ID() { return _main_thread_id; } ///< get the ID of the main thread static ID get_caller_ID(); ///< get the ID of the caller function ID static void wait_to_finish(Thread *p_thread); ///< waits until thread is finished, and deallocates it. diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 3efa87de80..a3775156ac 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -338,6 +338,8 @@ Error VariantParser::get_token(Stream *p_stream, Token& r_token, int &line, Stri exp_beg=true; } else if ((c=='-' || c=='+') && !exp_sign && !exp_beg) { + if (c=='-') + is_float=true; exp_sign=true; } else { @@ -358,6 +360,7 @@ Error VariantParser::get_token(Stream *p_stream, Token& r_token, int &line, Stri r_token.type=TK_NUMBER; + if (is_float) r_token.value=num.to_double(); else @@ -542,7 +545,7 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in value=true; else if (id=="false") value=false; - else if (id=="null") + else if (id=="null" || id=="nil") value=Variant(); else if (id=="Vector2"){ @@ -1282,7 +1285,7 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in arr.resize(len); DVector<Color>::Write w = arr.write(); for(int i=0;i<len;i++) { - w[i]=Color(args[i*3+0],args[i*3+1],args[i*3+2],args[i*3+3]); + w[i]=Color(args[i*4+0],args[i*4+1],args[i*4+2],args[i*4+3]); } } |