diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/command_queue_mt.h | 126 | ||||
-rw-r--r-- | core/dictionary.cpp | 14 | ||||
-rw-r--r-- | core/dictionary.h | 1 | ||||
-rw-r--r-- | core/dvector.h | 13 | ||||
-rw-r--r-- | core/global_constants.cpp | 14 | ||||
-rw-r--r-- | core/io/resource_loader.cpp | 6 | ||||
-rw-r--r-- | core/variant_call.cpp | 8 |
7 files changed, 177 insertions, 5 deletions
diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h index b1e0066c35..409543bf25 100644 --- a/core/command_queue_mt.h +++ b/core/command_queue_mt.h @@ -152,6 +152,23 @@ class CommandQueueMT { virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7); } }; + template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7,class P8> + struct Command8 : public CommandBase { + + T*instance; + M method; + typename GetSimpleTypeT<P1>::type_t p1; + typename GetSimpleTypeT<P2>::type_t p2; + typename GetSimpleTypeT<P3>::type_t p3; + typename GetSimpleTypeT<P4>::type_t p4; + typename GetSimpleTypeT<P5>::type_t p5; + typename GetSimpleTypeT<P6>::type_t p6; + typename GetSimpleTypeT<P7>::type_t p7; + typename GetSimpleTypeT<P8>::type_t p8; + + virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7,p8); } + }; + /* comands that return */ template<class T,class M,class R> @@ -270,6 +287,25 @@ class CommandQueueMT { virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6,p7); sync->sem->post(); sync->in_use=false; ; } }; + template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7,class P8,class R> + struct CommandRet8 : public CommandBase { + + T*instance; + M method; + typename GetSimpleTypeT<P1>::type_t p1; + typename GetSimpleTypeT<P2>::type_t p2; + typename GetSimpleTypeT<P3>::type_t p3; + typename GetSimpleTypeT<P4>::type_t p4; + typename GetSimpleTypeT<P5>::type_t p5; + typename GetSimpleTypeT<P6>::type_t p6; + typename GetSimpleTypeT<P7>::type_t p7; + typename GetSimpleTypeT<P8>::type_t p8; + R* ret; + SyncSemaphore *sync; + + virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6,p7,p8); sync->sem->post(); sync->in_use=false; ; } + }; + /** commands that don't return but sync */ /* comands that return */ @@ -390,6 +426,25 @@ class CommandQueueMT { virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7); sync->sem->post(); sync->in_use=false; ; } }; + template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7,class P8> + struct CommandSync8 : public CommandBase { + + T*instance; + M method; + typename GetSimpleTypeT<P1>::type_t p1; + typename GetSimpleTypeT<P2>::type_t p2; + typename GetSimpleTypeT<P3>::type_t p3; + typename GetSimpleTypeT<P4>::type_t p4; + typename GetSimpleTypeT<P5>::type_t p5; + typename GetSimpleTypeT<P6>::type_t p6; + typename GetSimpleTypeT<P7>::type_t p7; + typename GetSimpleTypeT<P8>::type_t p8; + + SyncSemaphore *sync; + + virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7,p8); sync->sem->post(); sync->in_use=false; ; } + }; + /***** BASE *******/ enum { @@ -639,6 +694,27 @@ public: if (sync) sync->post(); } + + template<class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7,class P8> + void push( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8 ) { + + Command8<T,M,P1,P2,P3,P4,P5,P6,P7,P8> * cmd = allocate_and_lock< Command8<T,M,P1,P2,P3,P4,P5,P6,P7,P8> >(); + + cmd->instance=p_instance; + cmd->method=p_method; + cmd->p1=p1; + cmd->p2=p2; + cmd->p3=p3; + cmd->p4=p4; + cmd->p5=p5; + cmd->p6=p6; + cmd->p7=p7; + cmd->p8=p8; + + unlock(); + + if (sync) sync->post(); + } /*** PUSH AND RET COMMANDS ***/ @@ -806,6 +882,31 @@ public: ss->sem->wait(); } + template<class T, class M, class P1, class P2, class P3, class P4, class P5, class P6,class P7,class P8,class R> + void push_and_ret( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,P7 p7,P8 p8, R* r_ret ) { + + CommandRet8<T,M,P1,P2,P3,P4,P5,P6,P7,P8,R> * cmd = allocate_and_lock< CommandRet8<T,M,P1,P2,P3,P4,P5,P6,P7,P8,R> >(); + + cmd->instance=p_instance; + cmd->method=p_method; + cmd->p1=p1; + cmd->p2=p2; + cmd->p3=p3; + cmd->p4=p4; + cmd->p5=p5; + cmd->p6=p6; + cmd->p7=p7; + cmd->p8=p8; + cmd->ret=r_ret; + SyncSemaphore *ss=_alloc_sync_sem(); + cmd->sync=ss; + + unlock(); + + if (sync) sync->post(); + ss->sem->wait(); + } + template<class T, class M> void push_and_sync( T * p_instance, M p_method) { @@ -971,6 +1072,31 @@ public: ss->sem->wait(); } + template<class T, class M, class P1, class P2, class P3, class P4, class P5, class P6,class P7,class P8> + void push_and_sync( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,P7 p7,P8 p8) { + + CommandSync8<T,M,P1,P2,P3,P4,P5,P6,P7,P8> * cmd = allocate_and_lock< CommandSync8<T,M,P1,P2,P3,P4,P5,P6,P7,P8> >(); + + cmd->instance=p_instance; + cmd->method=p_method; + cmd->p1=p1; + cmd->p2=p2; + cmd->p3=p3; + cmd->p4=p4; + cmd->p5=p5; + cmd->p6=p6; + cmd->p7=p7; + cmd->p8=p8; + + SyncSemaphore *ss=_alloc_sync_sem(); + cmd->sync=ss; + + unlock(); + + if (sync) sync->post(); + ss->sem->wait(); + } + void wait_and_flush_one() { ERR_FAIL_COND(!sync); sync->wait(); diff --git a/core/dictionary.cpp b/core/dictionary.cpp index 75c8531251..6204a87054 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -199,6 +199,18 @@ Array Dictionary::keys() const { } +Array Dictionary::values() const { + + Array varr; + varr.resize(size()); + const Variant *key=NULL; + int i=0; + while((key=next(key))){ + varr[i++] = _p->variant_map[*key]; + } + return varr; +} + const Variant* Dictionary::next(const Variant* p_key) const { return _p->variant_map.next(p_key); @@ -250,5 +262,3 @@ Dictionary::~Dictionary() { _unref(); } - - diff --git a/core/dictionary.h b/core/dictionary.h index c854e95ee6..ae79fab9c3 100644 --- a/core/dictionary.h +++ b/core/dictionary.h @@ -81,6 +81,7 @@ public: const Variant* next(const Variant* p_key=NULL) const; Array keys() const; + Array values() const; Dictionary(const Dictionary& p_from); Dictionary(bool p_shared=false); diff --git a/core/dvector.h b/core/dvector.h index fbb1fc4824..a5519ed604 100644 --- a/core/dvector.h +++ b/core/dvector.h @@ -285,6 +285,7 @@ public: Error resize(int p_size); + void invert(); void operator=(const DVector& p_dvector) { reference(p_dvector); } DVector() {} @@ -424,6 +425,18 @@ Error DVector<T>::resize(int p_size) { return OK; } +template<class T> +void DVector<T>::invert() { + T temp; + Write w = write(); + int s = size(); + int half_s = s/2; + for(int i=0;i<half_s;i++) { + temp = w[i]; + w[i] = w[s-i-1]; + w[s-i-1] = temp; + } +} #endif diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 3cf4ff8f83..63764383ff 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -478,7 +478,21 @@ static _GlobalConstant _global_constants[]={ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_STORAGE ), BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_EDITOR ), BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_NETWORK ), + + BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_EDITOR_HELPER ), + BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_CHECKABLE ), + BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_CHECKED ), + BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_INTERNATIONALIZED ), + BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_BUNDLE ), + BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_CATEGORY ), + BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_STORE_IF_NONZERO ), + BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_STORE_IF_NONONE ), + BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_NO_INSTANCE_STATE ), + BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_RESTART_IF_CHANGED ), + BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_DEFAULT ), + BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_DEFAULT_INTL ), + BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_NOEDITOR ), BIND_GLOBAL_CONSTANT( METHOD_FLAG_NORMAL ), BIND_GLOBAL_CONSTANT( METHOD_FLAG_EDITOR ), diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index b547dc0e85..1bb80e74eb 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -319,7 +319,11 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_ if (OS::get_singleton()->is_stdout_verbose()) print_line("load resource: "+local_path+" (cached)"); - return RES( ResourceCache::get(local_path ) ); + Ref<Resource> res_cached = ResourceCache::get(local_path); + Ref<ResourceInteractiveLoaderDefault> ril = Ref<ResourceInteractiveLoaderDefault>(memnew(ResourceInteractiveLoaderDefault)); + + ril->resource = res_cached; + return ril; } if (OS::get_singleton()->is_stdout_verbose()) diff --git a/core/variant_call.cpp b/core/variant_call.cpp index f5dcd75691..eb3ab65f40 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -262,7 +262,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM0R(String,basename); VCALL_LOCALMEM1R(String,plus_file); VCALL_LOCALMEM1R(String,ord_at); - //VCALL_LOCALMEM2R(String,erase); + VCALL_LOCALMEM2(String,erase); VCALL_LOCALMEM0R(String,hash); VCALL_LOCALMEM0R(String,md5_text); VCALL_LOCALMEM0R(String,md5_buffer); @@ -339,6 +339,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(Vector2,reflect); VCALL_LOCALMEM0R(Vector2,angle); // VCALL_LOCALMEM1R(Vector2,cross); + VCALL_LOCALMEM0R(Vector2,abs); VCALL_LOCALMEM0R(Rect2,get_area); VCALL_LOCALMEM1R(Rect2,intersects); @@ -445,6 +446,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1(Dictionary,erase); VCALL_LOCALMEM0R(Dictionary,hash); VCALL_LOCALMEM0R(Dictionary,keys); + VCALL_LOCALMEM0R(Dictionary,values); VCALL_LOCALMEM1R(Dictionary,parse_json); VCALL_LOCALMEM0R(Dictionary,to_json); @@ -1284,7 +1286,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(STRING,STRING,String,basename,varray()); ADDFUNC1(STRING,STRING,String,plus_file,STRING,"file",varray()); ADDFUNC1(STRING,STRING,String,ord_at,INT,"at",varray()); -// ADDFUNC2(STRING,String,erase,INT,INT,varray()); + ADDFUNC2(STRING,NIL,String,erase,INT,"pos",INT,"chars", varray()); ADDFUNC0(STRING,INT,String,hash,varray()); ADDFUNC0(STRING,STRING,String,md5_text,varray()); ADDFUNC0(STRING,RAW_ARRAY,String,md5_buffer,varray()); @@ -1335,6 +1337,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC1(VECTOR2,VECTOR2,Vector2,slide,VECTOR2,"vec",varray()); ADDFUNC1(VECTOR2,VECTOR2,Vector2,reflect,VECTOR2,"vec",varray()); //ADDFUNC1(VECTOR2,REAL,Vector2,cross,VECTOR2,"with",varray()); + ADDFUNC0(VECTOR2,VECTOR2,Vector2,abs,varray()); ADDFUNC0(RECT2,REAL,Rect2,get_area,varray()); ADDFUNC1(RECT2,BOOL,Rect2,intersects,RECT2,"b",varray()); @@ -1434,6 +1437,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC1(DICTIONARY,NIL,Dictionary,erase,NIL,"value",varray()); ADDFUNC0(DICTIONARY,INT,Dictionary,hash,varray()); ADDFUNC0(DICTIONARY,ARRAY,Dictionary,keys,varray()); + ADDFUNC0(DICTIONARY,ARRAY,Dictionary,values,varray()); ADDFUNC1(DICTIONARY,INT,Dictionary,parse_json,STRING,"json",varray()); ADDFUNC0(DICTIONARY,STRING,Dictionary,to_json,varray()); |